@agentchatham/cli 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -48,20 +48,31 @@ Retry logic, turn management, watermark tracking stay in `src/dispatcher.ts`.
48
48
  They do not move to SDK. If you find turn-coordination logic in `provider.ts`
49
49
  or an adapter, it belongs in the dispatcher instead.
50
50
 
51
- ## MCP client binding across reconnects
51
+ ## Shared client context across reconnects
52
52
 
53
- `startMcpServer` captures its `ctx` argument by reference. Pass a mutable holder
54
- and update `ctx.client` on every `monitorProvider.onConnect`this keeps MCP tool
55
- calls live across reconnects without recreating the server:
53
+ There is ONE client context the SDK's `ToolContext` shape
54
+ `{ client, store, attachmentCache }` — created once at boot and captured by
55
+ reference by both `startMcpServer` AND the `Dispatcher`. `store` and
56
+ `attachmentCache` are stable singletons; only `client` changes, and it is
57
+ updated in exactly one place (`monitorProvider.onConnect`). That single
58
+ assignment keeps MCP tool calls and dispatcher fetches live across reconnects
59
+ without recreating the server or a separate `setClient` call:
56
60
 
57
61
  ```typescript
58
- const toolCtx: { client: ChathamClient | null; store: ChannelKeyStore } = { client: null, store }
59
- const mcp = await startMcpServer(toolCtx as { client: ChathamClient; store: ChannelKeyStore })
62
+ const ctx: { client: ChathamClient | null; store: ChannelKeyStore; attachmentCache: AttachmentCache } =
63
+ { client: null, store, attachmentCache }
64
+ const mcp = await startMcpServer(ctx as ToolContext)
65
+ const dispatcher = new Dispatcher({ agent, ctx: ctx as ToolContext, signal, onFatal })
60
66
 
61
- // In onConnect:
62
- toolCtx.client = client // MCP tool calls now use the live client
67
+ // In onConnect — ONE update, seen by both the MCP server and the dispatcher:
68
+ ctx.client = client
63
69
  ```
64
70
 
71
+ Do NOT add a second mutable holder or a `Dispatcher.setClient` — thread the one
72
+ `ctx` so the live client has a single source of truth. SDK data functions
73
+ (`listMessages`, `monitorProvider`, `sendCommandResult`, `parseInboundNotification`)
74
+ take their args positionally; destructure `ctx` at those call sites.
75
+
65
76
  ## Tooling
66
77
 
67
78
  - Build: `esbuild` via `build.ts` — bundles to `dist/server.js`, obfuscated, node-native