singularity-forge/packages/rpc-client
Jeremy eec05b68a8 fix(release): sync all workspace versions and harden release scripts
Two bugs were causing version drift across the repo:

1. Root package.json was silently reverted from 2.74.0 → 2.73.1 during
   commit b03c9401c (a CI optimization rebase). Tag v2.74.0 is already
   published on npm, so the next release would have computed 2.73.2 —
   lower than what's already out — and shipped a broken version.

2. scripts/bump-version.mjs only touches pi-coding-agent + pkg + native
   platform shims. Other workspace packages drift independently:
   - @gsd-build/mcp-server: stuck at 2.52.0 (22 minor versions behind)
   - @gsd-build/rpc-client: stuck at 2.52.0
   - @gsd/pi-ai, pi-tui, pi-agent-core: stuck at 0.57.1
   - @gsd/native, @gsd-build/daemon: stuck at 0.1.0

Changes:

- Bump all non-private workspace packages to 2.74.0 to match the latest
  release tag. Update daemon + mcp-server's internal rpc-client dep
  from ^2.52.0 → ^2.74.0. Regenerate root lockfile.

- scripts/generate-changelog.mjs: compute newVersion from max(latest
  stable tag, package.json) instead of package.json alone. Prevents
  version regressions when package.json is accidentally clobbered by
  rebases or merges.

- scripts/bump-version.mjs: extend to sync all eight non-private
  workspace packages (daemon, mcp-server, native, pi-agent-core, pi-ai,
  pi-coding-agent, pi-tui, rpc-client) including their internal deps
  on each other. Private packages (studio, web) are left alone.

Studio and web remain on their own versioning (private: true, never
published). The native platform shims under native/npm/* are still
synced via native/scripts/sync-platform-versions.cjs from the root
version as before.
2026-04-14 19:35:28 -05:00
..
examples feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00
src feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00
.npmignore feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00
package.json fix(release): sync all workspace versions and harden release scripts 2026-04-14 19:35:28 -05:00
README.md feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00
tsconfig.examples.json feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00
tsconfig.json ci: optimize build workflows and caching 2026-04-14 11:16:47 -05:00

@gsd-build/rpc-client

Standalone RPC client SDK for GSD. Spawn the agent process, perform a v2 protocol handshake, send commands, and consume typed events via an async generator — all in a few lines of TypeScript.

Zero internal dependencies. Ships its own inlined types.

Installation

npm install @gsd-build/rpc-client

Quick Start

import { RpcClient } from '@gsd-build/rpc-client';

const client = new RpcClient({ cwd: process.cwd() });
await client.start();
const { sessionId } = await client.init({ clientId: 'my-app' });
console.log(`Session: ${sessionId}`);

await client.prompt('Create a hello world script');
for await (const event of client.events()) {
  if (event.type === 'execution_complete') break;
  console.log(event.type);
}
await client.shutdown();

API

Constructor

const client = new RpcClient(options?: RpcClientOptions);
Option Type Description
cliPath string Path to the CLI entry point
cwd string Working directory for the agent
env Record<string, string> Environment variables
provider string AI provider (e.g. "anthropic")
model string Model ID (e.g. "claude-sonnet")
args string[] Additional CLI arguments

Lifecycle

Method Description
start() Spawn the agent process
init(opts?) v2 handshake — returns sessionId, capabilities
shutdown() Graceful shutdown
stop() Force-kill the process

Commands

Method Description
prompt(message, images?) Send a prompt
steer(message, images?) Interrupt with a steering message
followUp(message, images?) Queue a follow-up message
abort() Abort current operation
subscribe(events) Subscribe to event types (["*"] for all)

Events

// Async generator — recommended
for await (const event of client.events()) {
  console.log(event.type);
}

// Callback-based
const unsubscribe = client.onEvent((event) => {
  console.log(event.type);
});

Helpers

Method Description
waitForIdle(timeout?) Wait for agent_end event
collectEvents(timeout?) Collect events until idle
promptAndWait(message, images?, t?) Send prompt and collect events

Session & Model

Method Description
getState() Get session state
setModel(provider, modelId) Set model
cycleModel() Cycle to next model
getAvailableModels() List available models
setThinkingLevel(level) Set thinking level
cycleThinkingLevel() Cycle thinking level
compact(instructions?) Compact session context
getSessionStats() Get session statistics
bash(command) Execute a bash command
newSession(parent?) Start a new session
sendUIResponse(id, response) Respond to extension UI requests

Type Exports

All protocol types are exported from the package root:

import type {
  RpcCommand,
  RpcResponse,
  RpcInitResult,
  RpcExecutionCompleteEvent,
  RpcCostUpdateEvent,
  RpcV2Event,
  SessionStats,
  SdkAgentEvent,
  RpcClientOptions,
} from '@gsd-build/rpc-client';

License

MIT