@code-yeongyu/senpi 2026.9.17-2 → 2026.9.17-3

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.
Files changed (176) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/bundle/chunks/{app-server-command-XSPV6BRF.js → app-server-command-HDTNYVSW.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-PLUQUK3T.js → chunk-CUBEOOBJ.js} +15 -15
  4. package/dist/bundle/chunks/{chunk-ESZHT7IE.js → chunk-IMTGM3RJ.js} +1 -1
  5. package/dist/bundle/chunks/chunk-OQGI752B.js +2 -0
  6. package/dist/bundle/chunks/{chunk-Z56RXBL6.js → chunk-QDR3GME3.js} +2 -2
  7. package/dist/bundle/chunks/{chunk-ZPO5FWHM.js → chunk-QILSJ5PQ.js} +2 -2
  8. package/dist/bundle/chunks/chunk-V6IBT2QS.js +8 -0
  9. package/dist/bundle/chunks/{chunk-IGKWKAMN.js → chunk-XHTF6VKZ.js} +4 -3
  10. package/dist/bundle/chunks/{cli-main-L7WQP5V6.js → cli-main-IPY5CCRP.js} +1 -1
  11. package/dist/bundle/chunks/{help-fast-path-O6MBSNMK.js → help-fast-path-LFGHCIWO.js} +1 -1
  12. package/dist/bundle/chunks/{host-lifecycle-AI7NH6ZO.js → host-lifecycle-YPVGQSGS.js} +1 -1
  13. package/dist/bundle/chunks/{interactive-host-runtime-DKJKH5DU.js → interactive-host-runtime-KZLF3AZD.js} +1 -1
  14. package/dist/bundle/chunks/{interactive-mode-FUW5LNKL.js → interactive-mode-HFE7ROP2.js} +1 -1
  15. package/dist/bundle/chunks/multi-session-host-VMVADJFM.js +20 -0
  16. package/dist/bundle/chunks/{package-manager-cli-J26DB6GM.js → package-manager-cli-AX4WQCCG.js} +1 -1
  17. package/dist/bundle/chunks/rotation-stream-FSZVBG2T.js +2 -0
  18. package/dist/bundle/chunks/{rpc-mode-A3U63XX7.js → rpc-mode-PDYLQ5BZ.js} +1 -1
  19. package/dist/bundle/chunks/session-worker.js +71 -68
  20. package/dist/bundle/cli.js +1 -1
  21. package/dist/bundle/index.js +1 -1
  22. package/dist/bundle/rpc-entry.js +1 -1
  23. package/dist/cli/args.d.ts +19 -1
  24. package/dist/cli/args.d.ts.map +1 -1
  25. package/dist/cli/args.js +27 -1
  26. package/dist/cli/args.js.map +1 -1
  27. package/dist/core/agent-session-runtime.d.ts +14 -1
  28. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  29. package/dist/core/agent-session-runtime.js.map +1 -1
  30. package/dist/core/auth-storage.js +2 -2
  31. package/dist/core/auth-storage.js.map +1 -1
  32. package/dist/core/credential-pool/rotation-stream.d.ts.map +1 -1
  33. package/dist/core/credential-pool/rotation-stream.js +10 -5
  34. package/dist/core/credential-pool/rotation-stream.js.map +1 -1
  35. package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
  36. package/dist/core/extensions/builtin/mcp/index.js +11 -0
  37. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  38. package/dist/core/extensions/builtin/mcp/service.d.ts +9 -0
  39. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  40. package/dist/core/extensions/builtin/mcp/service.js +14 -1
  41. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  42. package/dist/core/extensions/builtin/mcp/startup-race.d.ts +20 -0
  43. package/dist/core/extensions/builtin/mcp/startup-race.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/mcp/startup-race.js +38 -1
  45. package/dist/core/extensions/builtin/mcp/startup-race.js.map +1 -1
  46. package/dist/core/extensions/index.d.ts +2 -2
  47. package/dist/core/extensions/index.d.ts.map +1 -1
  48. package/dist/core/extensions/index.js +1 -1
  49. package/dist/core/extensions/index.js.map +1 -1
  50. package/dist/core/extensions/loader.d.ts +9 -4
  51. package/dist/core/extensions/loader.d.ts.map +1 -1
  52. package/dist/core/extensions/loader.js +20 -9
  53. package/dist/core/extensions/loader.js.map +1 -1
  54. package/dist/core/extensions/types.d.ts +37 -0
  55. package/dist/core/extensions/types.d.ts.map +1 -1
  56. package/dist/core/extensions/types.js +8 -0
  57. package/dist/core/extensions/types.js.map +1 -1
  58. package/dist/core/footer-data-provider.d.ts +2 -1
  59. package/dist/core/footer-data-provider.d.ts.map +1 -1
  60. package/dist/core/footer-data-provider.js +21 -35
  61. package/dist/core/footer-data-provider.js.map +1 -1
  62. package/dist/core/model-registry.d.ts.map +1 -1
  63. package/dist/core/model-registry.js +3 -2
  64. package/dist/core/model-registry.js.map +1 -1
  65. package/dist/core/model-runtime.d.ts +4 -2
  66. package/dist/core/model-runtime.d.ts.map +1 -1
  67. package/dist/core/model-runtime.js +9 -5
  68. package/dist/core/model-runtime.js.map +1 -1
  69. package/dist/core/provider-api-key-auth.js +3 -3
  70. package/dist/core/provider-api-key-auth.js.map +1 -1
  71. package/dist/core/provider-composer.d.ts +9 -3
  72. package/dist/core/provider-composer.d.ts.map +1 -1
  73. package/dist/core/provider-composer.js +7 -4
  74. package/dist/core/provider-composer.js.map +1 -1
  75. package/dist/core/resolve-config-command.d.ts +10 -0
  76. package/dist/core/resolve-config-command.d.ts.map +1 -0
  77. package/dist/core/resolve-config-command.js +106 -0
  78. package/dist/core/resolve-config-command.js.map +1 -0
  79. package/dist/core/resolve-config-value.d.ts +4 -8
  80. package/dist/core/resolve-config-value.d.ts.map +1 -1
  81. package/dist/core/resolve-config-value.js +16 -105
  82. package/dist/core/resolve-config-value.js.map +1 -1
  83. package/dist/core/resource-loader.d.ts +7 -1
  84. package/dist/core/resource-loader.d.ts.map +1 -1
  85. package/dist/core/resource-loader.js +13 -9
  86. package/dist/core/resource-loader.js.map +1 -1
  87. package/dist/main.d.ts +5 -3
  88. package/dist/main.d.ts.map +1 -1
  89. package/dist/main.js +25 -11
  90. package/dist/main.js.map +1 -1
  91. package/dist/modes/rpc/child-reaper-syscalls.d.ts +18 -0
  92. package/dist/modes/rpc/child-reaper-syscalls.d.ts.map +1 -0
  93. package/dist/modes/rpc/child-reaper-syscalls.js +136 -0
  94. package/dist/modes/rpc/child-reaper-syscalls.js.map +1 -0
  95. package/dist/modes/rpc/child-reaper.d.ts +56 -0
  96. package/dist/modes/rpc/child-reaper.d.ts.map +1 -0
  97. package/dist/modes/rpc/child-reaper.js +140 -0
  98. package/dist/modes/rpc/child-reaper.js.map +1 -0
  99. package/dist/modes/rpc/custom-capability.d.ts +16 -0
  100. package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
  101. package/dist/modes/rpc/custom-capability.js +16 -0
  102. package/dist/modes/rpc/custom-capability.js.map +1 -1
  103. package/dist/modes/rpc/host-memory-sampler.d.ts +48 -0
  104. package/dist/modes/rpc/host-memory-sampler.d.ts.map +1 -0
  105. package/dist/modes/rpc/host-memory-sampler.js +72 -0
  106. package/dist/modes/rpc/host-memory-sampler.js.map +1 -0
  107. package/dist/modes/rpc/loop-lag-watchdog.d.ts +51 -0
  108. package/dist/modes/rpc/loop-lag-watchdog.d.ts.map +1 -0
  109. package/dist/modes/rpc/loop-lag-watchdog.js +78 -0
  110. package/dist/modes/rpc/loop-lag-watchdog.js.map +1 -0
  111. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
  112. package/dist/modes/rpc/multi-session-host.js +34 -0
  113. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  114. package/dist/modes/rpc/rpc-client.d.ts +4 -2
  115. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  116. package/dist/modes/rpc/rpc-client.js +2 -1
  117. package/dist/modes/rpc/rpc-client.js.map +1 -1
  118. package/dist/modes/rpc/rpc-input-validation.d.ts +28 -0
  119. package/dist/modes/rpc/rpc-input-validation.d.ts.map +1 -1
  120. package/dist/modes/rpc/rpc-input-validation.js +63 -0
  121. package/dist/modes/rpc/rpc-input-validation.js.map +1 -1
  122. package/dist/modes/rpc/rpc-mode.d.ts +18 -5
  123. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  124. package/dist/modes/rpc/rpc-mode.js +18 -5
  125. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  126. package/dist/modes/rpc/rpc-types.d.ts +79 -2
  127. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  128. package/dist/modes/rpc/rpc-types.js +6 -0
  129. package/dist/modes/rpc/rpc-types.js.map +1 -1
  130. package/dist/modes/rpc/session-attribution.d.ts +57 -0
  131. package/dist/modes/rpc/session-attribution.d.ts.map +1 -0
  132. package/dist/modes/rpc/session-attribution.js +132 -0
  133. package/dist/modes/rpc/session-attribution.js.map +1 -0
  134. package/dist/modes/rpc/session-binding.d.ts.map +1 -1
  135. package/dist/modes/rpc/session-binding.js +19 -8
  136. package/dist/modes/rpc/session-binding.js.map +1 -1
  137. package/dist/modes/rpc/session-command-router.d.ts +26 -3
  138. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  139. package/dist/modes/rpc/session-command-router.js +95 -19
  140. package/dist/modes/rpc/session-command-router.js.map +1 -1
  141. package/dist/modes/rpc/session-event-fanout.d.ts +2 -0
  142. package/dist/modes/rpc/session-event-fanout.d.ts.map +1 -1
  143. package/dist/modes/rpc/session-event-fanout.js +6 -0
  144. package/dist/modes/rpc/session-event-fanout.js.map +1 -1
  145. package/dist/modes/rpc/session-event-writer.d.ts +29 -0
  146. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  147. package/dist/modes/rpc/session-event-writer.js +57 -0
  148. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  149. package/dist/modes/rpc/session-registry.d.ts +42 -9
  150. package/dist/modes/rpc/session-registry.d.ts.map +1 -1
  151. package/dist/modes/rpc/session-registry.js +49 -3
  152. package/dist/modes/rpc/session-registry.js.map +1 -1
  153. package/dist/modes/rpc/worker-session-registry.d.ts +2 -10
  154. package/dist/modes/rpc/worker-session-registry.d.ts.map +1 -1
  155. package/dist/modes/rpc/worker-session-registry.js +6 -2
  156. package/dist/modes/rpc/worker-session-registry.js.map +1 -1
  157. package/docs/rpc.md +126 -20
  158. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
  159. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  160. package/node_modules/@earendil-works/pi-agent-core/assets/tree-sitter/javascript.wasm +0 -0
  161. package/node_modules/@earendil-works/pi-agent-core/assets/tree-sitter/provenance.json +22 -0
  162. package/node_modules/@earendil-works/pi-agent-core/assets/tree-sitter/web-tree-sitter.wasm +0 -0
  163. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  164. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  165. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  166. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  167. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  168. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  169. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  170. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  171. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  172. package/package.json +7 -7
  173. package/dist/bundle/chunks/chunk-3Q5PD4KW.js +0 -8
  174. package/dist/bundle/chunks/chunk-YLYLKL7X.js +0 -2
  175. package/dist/bundle/chunks/multi-session-host-SMNZXFPT.js +0 -18
  176. package/dist/bundle/chunks/rotation-stream-SCVFIQ2O.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAC;AAOzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,mGAAmG;AACnG,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAIzC,YAAY,OAAe,EAAE,SAA6B,EAAE,SAAkB;QAC7E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,CAAC;YAC9C,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC7C,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAChC,OAAO,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,CAAC;gBAChC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,OAAO,CAAI,QAAqB;QACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,aAAa,GAAG,QAAoD,CAAC;YAC3E,IAAI,aAAa,CAAC,SAAS,KAAK,qBAAqB,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;gBAClF,MAAM,IAAI,sBAAsB,CAC/B,aAAa,CAAC,SAAoE,CAClF,CAAC;YACH,CAAC;YACD,MAAM,IAAI,eAAe,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAClG,CAAC;QACD,8EAA8E;QAC9E,mFAAmF;QACnF,MAAM,eAAe,GAAG,QAAkE,CAAC;QAC3F,OAAO,eAAe,CAAC,IAAS,CAAC;IAClC,CAAC;CACD","sourcesContent":["/**\n * RPC Client for programmatic access to the coding agent.\n *\n * Spawns the agent in RPC mode and provides a typed API for all operations.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { createConnection, type Socket } from \"node:net\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent } from \"@earendil-works/pi-ai\";\nimport type { PromptDisposition, SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { CompactionResult } from \"../../core/compaction/index.ts\";\nimport type { ServiceTier } from \"../../core/extensions/builtin/service-tier.ts\";\nimport { MissingSessionCwdError } from \"../../core/session-cwd.ts\";\n\n/** A command the host refused; `errorCode` carries the typed code when the command defines one. */\nexport class RpcCommandError extends Error {\n\treadonly errorCode: string | undefined;\n\treadonly errorData: unknown;\n\n\tconstructor(message: string, errorCode: string | undefined, errorData: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"RpcCommandError\";\n\t\tthis.errorCode = errorCode;\n\t\tthis.errorData = errorData;\n\t}\n}\n\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport type { JsonAgentSessionEvent } from \"../json-event.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport type {\n\tEditAssistantMessageResult,\n\tRpcAccountFailoverEvent,\n\tRpcAuthAccountsChangedEvent,\n\tRpcCommand,\n\tRpcExtensionEvent,\n\tRpcExtensionUIProgress,\n\tRpcExtensionUIRequest,\n\tRpcExtensionUIResponse,\n\tRpcProviderAccount,\n\tRpcResponse,\n\tRpcSessionModelEntry,\n\tRpcSessionReplacedEvent,\n\tRpcSessionState,\n\tRpcSlashCommand,\n} from \"./rpc-types.ts\";\nimport {\n\treadSocketSecret,\n\tresolveSocketTransportAddress,\n\tsendSocketHandshake,\n\tsocketSecretPath,\n} from \"./socket-transport.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Distributive Omit that works with union types */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\n\n/** RpcCommand without the id field (for internal send) */\ntype RpcCommandBody = DistributiveOmit<RpcCommand, \"id\">;\n\nexport interface RpcClientOptions {\n\t/** Connect to an existing multi-session Unix socket instead of spawning a child. */\n\tsocketPath?: string;\n\t/** Called once when an established transport disconnects. */\n\tonDisconnect?: (error: RpcTransportGoneError) => void;\n\t/** Path to the CLI entry point (default: searches for dist/cli.js) */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Environment variables */\n\tenv?: Record<string, string>;\n\t/** Provider to use */\n\tprovider?: string;\n\t/** Model ID to use */\n\tmodel?: string;\n\t/** Additional CLI arguments */\n\targs?: string[];\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tid: string;\n\tcontextWindow: number;\n\treasoning: boolean;\n\tsupportedThinkingLevels?: ThinkingLevel[];\n}\n\ntype PromptOptions = {\n\timages?: ImageContent[];\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\tthinkingLevel?: ThinkingLevel;\n\tpromptDisposition?: (disposition: PromptDisposition) => void;\n\tpreflightResult?: (success: boolean) => void;\n\tsessionTitlePrompt?: string | false;\n\texpandPromptTemplates?: boolean;\n};\n\nexport type RpcProviderAccountEvent = RpcAuthAccountsChangedEvent | RpcAccountFailoverEvent;\nexport type RpcClientEvent =\n\t| JsonAgentSessionEvent\n\t| RpcProviderAccountEvent\n\t| RpcExtensionEvent\n\t| RpcExtensionUIRequest\n\t// The host swapped the live session behind this connection. Part of the public\n\t// union so a typed client can discriminate on the type and read the new\n\t// `durableSessionId` without casting: the command response carries only\n\t// `{ cancelled }`, and a replacement may be driven by another client or an\n\t// extension, so this is the only channel delivering the new identity.\n\t| RpcSessionReplacedEvent\n\t| { type: \"bash_start\" }\n\t| { type: \"bash_end\" };\nexport type RpcEventListener = (event: RpcClientEvent) => void;\n\nfunction isProviderAccountEvent(event: RpcClientEvent): event is RpcProviderAccountEvent {\n\treturn event.type === \"auth_accounts_changed\" || event.type === \"account_failover\";\n}\n\n// ============================================================================\n// RPC Client\n// ============================================================================\n\nexport class RpcTransportGoneError extends Error {\n\treadonly code = \"rpc_transport_gone\" as const;\n\n\tconstructor(message = \"Shared RPC host is unavailable\") {\n\t\tsuper(message);\n\t\tthis.name = \"RpcTransportGoneError\";\n\t}\n}\n\nexport function isTransportGoneError(error: unknown): error is RpcTransportGoneError {\n\treturn (\n\t\terror instanceof RpcTransportGoneError ||\n\t\t(error instanceof Error &&\n\t\t\t(error.message === \"Client not started\" ||\n\t\t\t\terror.message.startsWith(\"RPC transport is not writable.\") ||\n\t\t\t\terror.message === \"RPC socket closed\"))\n\t);\n}\n\nexport class RpcClientOpenInFlightError extends Error {\n\treadonly code = \"open_session_in_flight\" as const;\n\n\tconstructor() {\n\t\tsuper(\"An open_session request is already in flight\");\n\t\tthis.name = \"RpcClientOpenInFlightError\";\n\t}\n}\n\n// Keep pre-lease startup delivery bounded by both record count and wire size.\nconst MAX_PENDING_SESSION_EVENTS = 512;\nconst MAX_PENDING_SESSION_EVENT_BYTES = 1024 * 1024;\n\nexport class RpcClient {\n\tprivate process: ChildProcess | null = null;\n\tprivate socket: Socket | null = null;\n\tprivate stopReadingStdout: (() => void) | null = null;\n\tprivate eventListeners: RpcEventListener[] = [];\n\tprivate pendingRequests: Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (response: RpcResponse) => void;\n\t\t\treject: (error: Error) => void;\n\t\t\tonResponse?: (response: RpcResponse) => void;\n\t\t\tonReject?: (error: Error) => void;\n\t\t}\n\t> = new Map();\n\tprivate requestId = 0;\n\tprivate sessionId: string | undefined;\n\tprivate pendingOpenSession = false;\n\tprivate pendingSessionEvents: Array<{ sessionId: string; event: RpcClientEvent; bytes: number }> = [];\n\tprivate pendingSessionEventBytes = 0;\n\tprivate stderr = \"\";\n\tprivate exitError: Error | null = null;\n\tprivate disconnectNotified = false;\n\tprivate stopping = false;\n\tprivate options: RpcClientOptions;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Start the RPC agent process.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.process || this.socket) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tthis.exitError = null;\n\t\tthis.stopping = false;\n\t\tthis.disconnectNotified = false;\n\t\tif (this.options.socketPath) {\n\t\t\tawait this.startSocket(this.options.socketPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst cliPath = this.options.cliPath ?? \"dist/cli.js\";\n\t\tconst args = [\"--mode\", \"rpc\"];\n\n\t\tif (this.options.provider) {\n\t\t\targs.push(\"--provider\", this.options.provider);\n\t\t}\n\t\tif (this.options.model) {\n\t\t\targs.push(\"--model\", this.options.model);\n\t\t}\n\t\tif (this.options.args) {\n\t\t\targs.push(...this.options.args);\n\t\t}\n\n\t\tconst childProcess = spawn(\"node\", [cliPath, ...args], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// The spawned child must BE the process this client signals and reaps. An ambient\n\t\t\t\t// SENPI_RUNTIME=bun pin makes the launcher re-exec under Bun via spawnSync, so a\n\t\t\t\t// SIGTERM to the wrapper leaves the Bun host running: it keeps the session lease\n\t\t\t\t// and keeps writing session state after stop() resolved. Pin the runtime to the\n\t\t\t\t// interpreter chosen here, the same way app-server/daemon.ts does; options.env is\n\t\t\t\t// spread last so a caller can still override the pin explicitly.\n\t\t\t\tSENPI_RUNTIME: \"node\",\n\t\t\t\t...this.options.env,\n\t\t\t},\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t// Callers may be console-less on win32 (GUI hosts, detached daemons), and a\n\t\t\t// console-subsystem child would then allocate a fresh visible terminal window.\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.process = childProcess;\n\n\t\t// Collect stderr for debugging\n\t\tchildProcess.stderr?.on(\"data\", (data) => {\n\t\t\tthis.stderr += data.toString();\n\t\t\tprocess.stderr.write(data);\n\t\t});\n\n\t\tchildProcess.once(\"exit\", (code, signal) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst error = this.createProcessExitError(code, signal);\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.once(\"error\", (error) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst processError = new Error(`Agent process error: ${error.message}. Stderr: ${this.stderr}`);\n\t\t\tthis.exitError = processError;\n\t\t\tthis.rejectPendingRequests(processError);\n\t\t});\n\t\tchildProcess.stdin?.on(\"error\", (error) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst stdinError =\n\t\t\t\tthis.exitError ?? new Error(`Agent process stdin error: ${error.message}. Stderr: ${this.stderr}`);\n\t\t\tthis.exitError = stdinError;\n\t\t\tthis.rejectPendingRequests(stdinError);\n\t\t});\n\n\t\t// Set up strict JSONL reader for stdout.\n\t\tthis.stopReadingStdout = attachJsonlLineReader(childProcess.stdout!, (line) => {\n\t\t\tthis.handleLine(line);\n\t\t});\n\n\t\t// Wait a moment for process to initialize\n\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\n\t\tif (this.process.exitCode !== null) {\n\t\t\tconst error = this.exitError ?? this.createProcessExitError(this.process.exitCode, this.process.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Stop the RPC agent process.\n\t */\n\tasync stop(): Promise<void> {\n\t\tthis.pendingOpenSession = false;\n\t\tthis.pendingSessionEvents = [];\n\t\tthis.pendingSessionEventBytes = 0;\n\t\tif (this.socket) {\n\t\t\tthis.stopping = true;\n\t\t\tthis.stopReadingStdout?.();\n\t\t\tthis.stopReadingStdout = null;\n\t\t\tthis.socket.destroy();\n\t\t\tthis.socket = null;\n\t\t\tthis.sessionId = undefined;\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.pendingSessionEvents = [];\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t\treturn;\n\t\t}\n\t\tif (!this.process) return;\n\n\t\tthis.stopReadingStdout?.();\n\t\tthis.stopReadingStdout = null;\n\t\tthis.process.kill(\"SIGTERM\");\n\n\t\t// Wait for process to exit\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.process?.kill(\"SIGKILL\");\n\t\t\t\tresolve();\n\t\t\t}, 1000);\n\n\t\t\tthis.process?.on(\"exit\", () => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\tthis.process = null;\n\t\tthis.pendingRequests.clear();\n\t}\n\n\tprivate async startSocket(path: string): Promise<void> {\n\t\tconst secret = process.platform === \"win32\" ? await readSocketSecret(socketSecretPath(path)) : undefined;\n\t\tconst socket = createConnection(resolveSocketTransportAddress(path, process.platform, secret));\n\t\tthis.socket = socket;\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst onConnect = () => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\tthis.socket = null;\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\tconst cleanup = () => {\n\t\t\t\tsocket.off(\"connect\", onConnect);\n\t\t\t\tsocket.off(\"error\", onError);\n\t\t\t};\n\t\t\tsocket.once(\"connect\", onConnect);\n\t\t\tsocket.once(\"error\", onError);\n\t\t});\n\t\tif (secret) sendSocketHandshake(socket, secret);\n\t\tthis.stopReadingStdout = attachJsonlLineReader(socket, (line) => this.handleLine(line));\n\t\tsocket.once(\"close\", () => {\n\t\t\tif (this.socket !== socket) return;\n\t\t\tthis.socket = null;\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t});\n\t\tsocket.once(\"error\", (error) => {\n\t\t\tif (this.socket !== socket) return;\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t\tvoid error;\n\t\t});\n\t}\n\n\t/**\n\t * Subscribe to agent events.\n\t */\n\tonEvent(listener: RpcEventListener): () => void {\n\t\tthis.eventListeners.push(listener);\n\t\treturn () => {\n\t\t\tconst index = this.eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Get collected stderr output (useful for debugging).\n\t */\n\tgetStderr(): string {\n\t\treturn this.stderr;\n\t}\n\n\t// =========================================================================\n\t// Command Methods\n\t// =========================================================================\n\n\tasync setClientInfo(width: number, capabilities?: string[]): Promise<void> {\n\t\tawait this.send({ type: \"set_client_info\", width, capabilities }, this.sessionId !== undefined);\n\t}\n\n\tasync openSession(options: {\n\t\tsessionPath?: string;\n\t\tcwd?: string;\n\t\tprovider?: string;\n\t\tmodelId?: string;\n\t\tthinkingLevel?: ThinkingLevel;\n\t\tpermissionPreset?: string;\n\t\t/** Keep the session alive when its last client disconnects; needs the host's `retain_on_disconnect`. */\n\t\tretain_on_disconnect?: boolean;\n\t}): Promise<{ sessionId: string; state: RpcSessionState; attached?: boolean }> {\n\t\tif (this.pendingOpenSession) throw new RpcClientOpenInFlightError();\n\t\tthis.pendingOpenSession = true;\n\t\ttry {\n\t\t\tconst response = await this.send({ type: \"open_session\", ...options }, false);\n\t\t\tconst opened = this.getData<{ sessionId: string; state: RpcSessionState; attached?: boolean }>(response);\n\t\t\tthis.sessionId = opened.sessionId;\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.flushPendingSessionEvents();\n\t\t\treturn opened;\n\t\t} catch (error) {\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.pendingSessionEvents = [];\n\t\t\tthis.pendingSessionEventBytes = 0;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync sendExtensionUIResponse(response: RpcExtensionUIResponse): Promise<void> {\n\t\tawait this.send(response, true, undefined, false);\n\t}\n\n\t/** Draft update for an open `question` request; fire-and-forget like the response. */\n\tasync sendExtensionUIProgress(progress: RpcExtensionUIProgress): Promise<void> {\n\t\tawait this.send(progress, true, undefined, false);\n\t}\n\n\tasync closeSession(sessionId = this.sessionId): Promise<void> {\n\t\tif (!sessionId) return;\n\t\ttry {\n\t\t\tawait this.send({ type: \"close_session\", sessionId }, false);\n\t\t} catch (error) {\n\t\t\tif (!isTransportGoneError(error)) throw error;\n\t\t}\n\t\tif (this.sessionId === sessionId) this.sessionId = undefined;\n\t}\n\n\tasync listSessions(): Promise<\n\t\tArray<{\n\t\t\tsessionId: string;\n\t\t\tdurableSessionId?: string;\n\t\t\tsessionPath?: string;\n\t\t\tcwd: string;\n\t\t\tname?: string;\n\t\t\tstatus: \"opening\" | \"open\" | \"closing\" | \"closed\";\n\t\t\t/** Live client attachments; absent from hosts older than the `retain_on_disconnect` capability. */\n\t\t\tattachments?: number;\n\t\t}>\n\t> {\n\t\tconst response = await this.send({ type: \"list_sessions\" }, false);\n\t\treturn this.getData<{\n\t\t\tsessions: Array<{\n\t\t\t\tsessionId: string;\n\t\t\t\tdurableSessionId?: string;\n\t\t\t\tsessionPath?: string;\n\t\t\t\tcwd: string;\n\t\t\t\tname?: string;\n\t\t\t\tstatus: \"opening\" | \"open\" | \"closing\" | \"closed\";\n\t\t\t\tattachments?: number;\n\t\t\t}>;\n\t\t}>(response).sessions;\n\t}\n\n\t/**\n\t * Send a prompt to the agent.\n\t * Returns immediately after sending; use onEvent() to receive streaming events.\n\t * Use waitForIdle() to wait for completion.\n\t *\n\t * The disposition/preflight callbacks mirror AgentSession's local prompt contract:\n\t * they fire synchronously while the response frame is dispatched — before any\n\t * queued message_start event — so optimistic-echo eligibility is settled in wire\n\t * order. A success response without a disposition (older host) maps to \"handled\"\n\t * so the echo degrades to canonical-only rendering instead of double-rendering.\n\t */\n\tasync prompt(message: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(message: string, options?: PromptOptions): Promise<void>;\n\tasync prompt(message: string, optionsOrImages?: PromptOptions | ImageContent[]): Promise<void> {\n\t\tconst options: PromptOptions = Array.isArray(optionsOrImages)\n\t\t\t? { images: optionsOrImages }\n\t\t\t: (optionsOrImages ?? {});\n\t\tconst response = await this.send(\n\t\t\t{\n\t\t\t\ttype: \"prompt\",\n\t\t\t\tmessage,\n\t\t\t\t...(options.images ? { images: options.images } : {}),\n\t\t\t\t...(options.streamingBehavior ? { streamingBehavior: options.streamingBehavior } : {}),\n\t\t\t\t...(options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {}),\n\t\t\t\t...(options.sessionTitlePrompt !== undefined ? { sessionTitlePrompt: options.sessionTitlePrompt } : {}),\n\t\t\t\t...(options.expandPromptTemplates !== undefined\n\t\t\t\t\t? { expandPromptTemplates: options.expandPromptTemplates }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t\ttrue,\n\t\t\t{\n\t\t\t\tonResponse: (wireResponse) => {\n\t\t\t\t\tif (!wireResponse.success) {\n\t\t\t\t\t\toptions?.preflightResult?.(false);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst data = (wireResponse as { data?: { disposition?: PromptDisposition } }).data;\n\t\t\t\t\toptions?.promptDisposition?.(data?.disposition ?? \"handled\");\n\t\t\t\t\toptions?.preflightResult?.(true);\n\t\t\t\t},\n\t\t\t\tonReject: () => {\n\t\t\t\t\toptions?.preflightResult?.(false);\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\tif (!response.success) {\n\t\t\tthrow new Error((response as Extract<RpcResponse, { success: false }>).error);\n\t\t}\n\t}\n\n\tasync appendUserMessage(content: unknown): Promise<void> {\n\t\tawait this.send({ type: \"append_user_message\", content });\n\t}\n\n\tasync appendSessionEntry(entry: import(\"../../core/session-manager.ts\").SessionEntry): Promise<void> {\n\t\tawait this.send({ type: \"append_session_entry\", entry });\n\t}\n\n\tasync sendCustomMessage<T = unknown>(\n\t\tmessage: { customType: string; content: unknown; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void> {\n\t\tawait this.send({ type: \"send_custom_message\", ...message, ...options });\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t */\n\tasync steer(message: string, images?: ImageContent[], recovery?: { enqueueOrder?: number }): Promise<void> {\n\t\tawait this.send({ type: \"steer\", message, images, enqueueOrder: recovery?.enqueueOrder });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t */\n\tasync followUp(message: string, images?: ImageContent[], recovery?: { enqueueOrder?: number }): Promise<void> {\n\t\tawait this.send({ type: \"follow_up\", message, images, enqueueOrder: recovery?.enqueueOrder });\n\t}\n\n\t/**\n\t * Abort current operation.\n\t */\n\tasync abort(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.send({ type: \"abort\" });\n\t\t} catch (error) {\n\t\t\tif (!isTransportGoneError(error)) throw error;\n\t\t}\n\t}\n\n\tasync abortCompaction(): Promise<void> {\n\t\tawait this.send({ type: \"abort_compaction\" });\n\t}\n\n\tasync reload(): Promise<{ cancelled: boolean; reason?: string }> {\n\t\tconst response = await this.send({ type: \"reload\" });\n\t\treturn this.getData(response);\n\t}\n\n\tasync checkReloadVeto(): Promise<{ cancelled: boolean; reason?: string }> {\n\t\tconst response = await this.send({ type: \"check_reload_veto\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Clear queued steering and follow-up messages, returning their text.\n\t */\n\tasync clearQueue(options?: { abortWillFollow?: boolean }): Promise<{\n\t\tsteering: string[];\n\t\tfollowUp: string[];\n\t\tordered: Array<{ text: string; mode: \"steer\" | \"followUp\"; enqueueOrder: number }>;\n\t}> {\n\t\tconst response = await this.send({ type: \"clear_queue\", abortWillFollow: options?.abortWillFollow });\n\t\treturn this.getData(response);\n\t}\n\n\tasync getSteeringMessages(): Promise<string[]> {\n\t\tconst response = await this.send({ type: \"get_steering_messages\" });\n\t\treturn this.getData<{ messages: string[] }>(response).messages;\n\t}\n\n\tasync getFollowUpMessages(): Promise<string[]> {\n\t\tconst response = await this.send({ type: \"get_follow_up_messages\" });\n\t\treturn this.getData<{ messages: string[] }>(response).messages;\n\t}\n\n\tasync abortBranchSummary(): Promise<void> {\n\t\tawait this.send({ type: \"abort_branch_summary\" });\n\t}\n\n\tasync recordBashResult(command: string, result: BashResult, excludeFromContext?: boolean): Promise<void> {\n\t\tawait this.send({ type: \"record_bash_result\", command, result, excludeFromContext });\n\t}\n\n\tasync setLabel(entryId: string, label?: string): Promise<void> {\n\t\tawait this.send({ type: \"set_label\", entryId, label });\n\t}\n\n\t/**\n\t * Start a new session, optionally with parent tracking.\n\t * @param parentSession - Optional parent session path for lineage tracking\n\t * @returns Object with `cancelled: true` if an extension cancelled the new session\n\t */\n\tasync newSession(parentSession?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"new_session\", parentSession });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get current session state.\n\t */\n\tasync getState(): Promise<RpcSessionState> {\n\t\tconst response = await this.send({ type: \"get_state\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set model by provider and ID.\n\t */\n\tasync setModel(\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): Promise<{ provider: string; id: string; systemPromptName?: string }> {\n\t\tconst response = await this.send({ type: \"set_model\", provider, modelId });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Cycle to next model.\n\t */\n\tasync setFavoriteModels(models: RpcSessionModelEntry[]): Promise<void> {\n\t\tawait this.send({ type: \"set_favorite_models\", models });\n\t}\n\n\tasync setScopedModels(models: RpcSessionModelEntry[]): Promise<void> {\n\t\tawait this.send({ type: \"set_scoped_models\", models });\n\t}\n\n\tasync cycleModel(direction: \"forward\" | \"backward\" = \"forward\"): Promise<{\n\t\tmodel: { provider: string; id: string };\n\t\tthinkingLevel: ThinkingLevel;\n\t\tisScoped: boolean;\n\t} | null> {\n\t\tconst response = await this.send({ type: \"cycle_model\", direction });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get list of available models.\n\t */\n\tasync getAvailableModels(): Promise<ModelInfo[]> {\n\t\tconst response = await this.send({ type: \"get_available_models\" });\n\t\treturn this.getData<{ models: ModelInfo[] }>(response).models;\n\t}\n\n\t/**\n\t * Set thinking level.\n\t *\n\t * `scope: \"turn\"` changes only this session's level without rewriting the model's remembered\n\t * level; it throws when the active model does not support the requested level, and the\n\t * session keeps the level it already had.\n\t */\n\tasync setThinkingLevel(level: ThinkingLevel, options?: { scope?: \"turn\" }): Promise<void> {\n\t\tconst response = await this.send({ type: \"set_thinking_level\", level, scope: options?.scope });\n\t\tif (!response.success) {\n\t\t\tthrow new Error((response as Extract<RpcResponse, { success: false }>).error);\n\t\t}\n\t}\n\n\t/**\n\t * Cycle thinking level.\n\t */\n\tasync cycleThinkingLevel(): Promise<{ level: ThinkingLevel } | null> {\n\t\tconst response = await this.send({ type: \"cycle_thinking_level\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get list of available thinking levels for the current model.\n\t */\n\tasync getAvailableThinkingLevels(): Promise<ThinkingLevel[]> {\n\t\tconst response = await this.send({ type: \"get_available_thinking_levels\" });\n\t\treturn this.getData<{ levels: ThinkingLevel[] }>(response).levels;\n\t}\n\n\t/**\n\t * Turn OpenAI Codex fast mode (the `priority` service tier) on or off for the active model.\n\t *\n\t * The choice is remembered per model, so a later session on the same model starts the same\n\t * way. Throws when the request is refused: a non-Codex model, or an active `:priority` model\n\t * pin that fast mode must not undo.\n\t */\n\tasync setFastMode(\n\t\tenabled: boolean,\n\t): Promise<{ enabled: boolean; serviceTier: ServiceTier; provider: string; modelId: string }> {\n\t\tconst response = await this.send({ type: \"set_fast_mode\", enabled });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Current fast-mode state and the service tier requests would carry. */\n\tasync getFastMode(): Promise<{ enabled: boolean; serviceTier: ServiceTier | null }> {\n\t\tconst response = await this.send({ type: \"get_fast_mode\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set steering mode.\n\t */\n\tasync setSteeringMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_steering_mode\", mode });\n\t}\n\n\t/**\n\t * Set follow-up mode.\n\t */\n\tasync setFollowUpMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_follow_up_mode\", mode });\n\t}\n\n\t/**\n\t * Compact session context.\n\t */\n\tasync compact(customInstructions?: string): Promise<CompactionResult> {\n\t\tconst response = await this.send({ type: \"compact\", customInstructions });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set auto-compaction enabled/disabled.\n\t */\n\tasync setAutoCompaction(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_compaction\", enabled });\n\t}\n\n\t/**\n\t * Set auto-retry enabled/disabled.\n\t */\n\tasync setAutoRetry(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_retry\", enabled });\n\t}\n\n\t/**\n\t * Abort in-progress retry.\n\t */\n\tasync abortRetry(): Promise<void> {\n\t\tawait this.send({ type: \"abort_retry\" });\n\t}\n\n\t/**\n\t * Execute a bash command.\n\t */\n\tasync bash(\n\t\tcommand: string,\n\t\toptions?: { excludeFromContext?: boolean; executionId?: string; operations?: Record<string, unknown> },\n\t): Promise<BashResult> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"bash\",\n\t\t\tcommand,\n\t\t\texcludeFromContext: options?.excludeFromContext,\n\t\t\texecutionId: options?.executionId,\n\t\t\toperations: options?.operations,\n\t\t});\n\t\treturn this.getData(response);\n\t}\n\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ cancelled: boolean; editorText?: string; aborted?: boolean; summaryEntry?: unknown }> {\n\t\tconst response = await this.send({ type: \"navigate_tree\", targetId, ...options });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Abort running bash command.\n\t */\n\tasync abortBash(): Promise<void> {\n\t\tawait this.send({ type: \"abort_bash\" });\n\t}\n\n\tasync cleanupBashOutput(path: string): Promise<void> {\n\t\tawait this.send({ type: \"cleanup_bash_output\", path });\n\t}\n\n\t/**\n\t * Get session statistics.\n\t */\n\tasync getSessionStats(): Promise<SessionStats> {\n\t\tconst response = await this.send({ type: \"get_session_stats\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Export session to HTML.\n\t */\n\tasync exportHtml(outputPath?: string, themeName?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_html\", outputPath, themeName });\n\t\treturn this.getData(response);\n\t}\n\n\tasync exportJsonl(outputPath?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_jsonl\", outputPath });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Switch to a different session file.\n\t * @returns Object with `cancelled: true` if an extension cancelled the switch\n\t */\n\tasync switchSession(sessionPath: string, options?: { cwdOverride?: string }): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"switch_session\", sessionPath, cwdOverride: options?.cwdOverride });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Fork from a specific message.\n\t * @returns Object with `text` (the message text) and `cancelled` (if extension cancelled)\n\t */\n\tasync fork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\" },\n\t): Promise<{ text: string; cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"fork\", entryId, position: options?.position });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Clone the current active branch into a new session.\n\t * @returns Object with `cancelled: true` if an extension cancelled the clone\n\t */\n\tasync clone(): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"clone\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get messages available for forking.\n\t */\n\tasync getForkMessages(): Promise<Array<{ entryId: string; text: string }>> {\n\t\tconst response = await this.send({ type: \"get_fork_messages\" });\n\t\treturn this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;\n\t}\n\n\t/**\n\t * Get session entries in append order, optionally only those after the `since` entry id.\n\t */\n\tasync getEntries(since?: string): Promise<{ entries: SessionEntry[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_entries\", since });\n\t\treturn this.getData<{ entries: SessionEntry[]; leafId: string | null }>(response);\n\t}\n\n\t/**\n\t * Get the session entry tree.\n\t */\n\tasync getTree(): Promise<{ tree: SessionTreeNode[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_tree\" });\n\t\treturn this.getData<{ tree: SessionTreeNode[]; leafId: string | null }>(response);\n\t}\n\n\t/**\n\t * Replace an assistant response with an edited copy (branches to the target's parent and appends\n\t * the copy as the new leaf). Pass the `leafId` you last observed as `expectedLeafId` so a stale\n\t * edit is refused with `errorCode: \"stale_leaf\"` instead of rewriting a conversation another client\n\t * moved. Failures reject with an {@link RpcCommandError} carrying the typed `errorCode`.\n\t */\n\tasync editAssistantMessage(\n\t\tentryId: string,\n\t\ttext: string,\n\t\toptions: { expectedLeafId?: string; summarize?: boolean; customInstructions?: string } = {},\n\t): Promise<EditAssistantMessageResult> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"edit_assistant_message\",\n\t\t\tentryId,\n\t\t\ttext,\n\t\t\texpectedLeafId: options.expectedLeafId,\n\t\t\tsummarize: options.summarize,\n\t\t\tcustomInstructions: options.customInstructions,\n\t\t});\n\t\treturn this.getData<EditAssistantMessageResult>(response);\n\t}\n\n\t/**\n\t * Get text of last assistant message.\n\t */\n\tasync getLastAssistantText(): Promise<string | null> {\n\t\tconst response = await this.send({ type: \"get_last_assistant_text\" });\n\t\treturn this.getData<{ text: string | null }>(response).text;\n\t}\n\n\t/**\n\t * Set the session display name.\n\t */\n\tasync setSessionName(name: string): Promise<void> {\n\t\tawait this.send({ type: \"set_session_name\", name });\n\t}\n\n\tasync importJsonl(inputPath: string, cwdOverride?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"import_jsonl\", inputPath, cwdOverride });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get all messages in the session.\n\t */\n\tasync getMessages(): Promise<AgentMessage[]> {\n\t\tconst response = await this.send({ type: \"get_messages\" });\n\t\treturn this.getData<{ messages: AgentMessage[] }>(response).messages;\n\t}\n\n\t/**\n\t * Fetch one media block that arrived as an `image_ref` placeholder.\n\t *\n\t * `contentIndex` is the index inside the tool result's `content` array carried by\n\t * the placeholder's `ref`. Rejects with `media_not_found` when the tool call is\n\t * unknown or the index does not point at an image block.\n\t */\n\tasync getMedia(toolCallId: string, contentIndex: number): Promise<ImageContent> {\n\t\tconst response = await this.send({ type: \"get_media\", toolCallId, contentIndex });\n\t\treturn this.getData<{ toolCallId: string; contentIndex: number; content: ImageContent }>(response).content;\n\t}\n\n\t/**\n\t * Get available commands (extension commands, prompt templates, skills).\n\t */\n\tasync getCommands(): Promise<RpcSlashCommand[]> {\n\t\tconst response = await this.send({ type: \"get_commands\" });\n\t\treturn this.getData<{ commands: RpcSlashCommand[] }>(response).commands;\n\t}\n\n\t/** Invoke one extension-owned RPC request handler and return its structured result. */\n\tasync requestExtension<T = unknown>(name: string, data?: unknown): Promise<T> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"extension_request\",\n\t\t\tname,\n\t\t\t...(data === undefined ? {} : { data }),\n\t\t});\n\t\treturn this.getData<T>(response);\n\t}\n\n\t/** List safe metadata for the named provider's configured account slots. */\n\tasync getProviderAccounts(provider: string): Promise<RpcProviderAccount[]> {\n\t\tconst response = await this.send({ type: \"get_provider_accounts\", provider });\n\t\treturn this.getData<{ accounts: RpcProviderAccount[] }>(response).accounts;\n\t}\n\n\t/** Pin a provider account for future session-affine requests, or clear the pin. */\n\tasync pinProviderAccount(provider: string, name: string | null): Promise<void> {\n\t\tawait this.send({ type: \"account_pin\", provider, name });\n\t}\n\n\t/** Remove a persisted provider account slot. Environment slots are read-only. */\n\tasync removeProviderAccount(provider: string, name: string): Promise<void> {\n\t\tawait this.send({ type: \"account_remove\", provider, name });\n\t}\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Wait for agent to become idle (no streaming).\n\t * Resolves when agent_settled event is received.\n\t */\n\twaitForIdle(timeout = 60000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (event.type === \"agent_settled\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Collect events until agent becomes idle.\n\t */\n\tcollectEvents(timeout = 60000): Promise<JsonAgentSessionEvent[]> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst events: JsonAgentSessionEvent[] = [];\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout collecting events. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (\n\t\t\t\t\tisProviderAccountEvent(event) ||\n\t\t\t\t\tevent.type === \"extension_event\" ||\n\t\t\t\t\tevent.type === \"bash_start\" ||\n\t\t\t\t\tevent.type === \"bash_end\" ||\n\t\t\t\t\tevent.type === \"extension_ui_request\" ||\n\t\t\t\t\t// Connection-level, not part of the agent's event stream.\n\t\t\t\t\tevent.type === \"session_replaced\"\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tevents.push(event);\n\t\t\t\tif (event.type === \"agent_settled\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve(events);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Send prompt and wait for completion, returning all events.\n\t */\n\tasync promptAndWait(message: string, images?: ImageContent[], timeout = 60000): Promise<JsonAgentSessionEvent[]> {\n\t\tconst eventsPromise = this.collectEvents(timeout);\n\t\tawait this.prompt(message, images ? { images } : undefined);\n\t\treturn eventsPromise;\n\t}\n\n\t// =========================================================================\n\t// Internal\n\t// =========================================================================\n\n\tprivate handleLine(line: string): void {\n\t\ttry {\n\t\t\tconst data = JSON.parse(line);\n\n\t\t\t// Check if it's a response to a pending request\n\t\t\tif (data.type === \"response\" && data.id && this.pendingRequests.has(data.id)) {\n\t\t\t\tconst pending = this.pendingRequests.get(data.id)!;\n\t\t\t\tthis.pendingRequests.delete(data.id);\n\t\t\t\t// Response hooks run synchronously inside the frame dispatch so ordering-sensitive\n\t\t\t\t// contracts (e.g. optimistic-echo disposition) settle before the NEXT frame —\n\t\t\t\t// never through the microtask scheduled by resolve().\n\t\t\t\tpending.onResponse?.(data as RpcResponse);\n\t\t\t\tpending.resolve(data as RpcResponse);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Otherwise it's an event. During open_session, retain tagged events until\n\t\t\t// the response establishes the lease so startup hooks are not lost.\n\t\t\tif (typeof data.sessionId === \"string\" && data.sessionId !== this.sessionId) {\n\t\t\t\tif (this.pendingOpenSession) {\n\t\t\t\t\tconst bytes = Buffer.byteLength(line);\n\t\t\t\t\tthis.pendingSessionEvents.push({ sessionId: data.sessionId, event: data as RpcClientEvent, bytes });\n\t\t\t\t\tthis.pendingSessionEventBytes += bytes;\n\t\t\t\t\twhile (\n\t\t\t\t\t\tthis.pendingSessionEvents.length > MAX_PENDING_SESSION_EVENTS ||\n\t\t\t\t\t\tthis.pendingSessionEventBytes > MAX_PENDING_SESSION_EVENT_BYTES\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst oldest = this.pendingSessionEvents.shift();\n\t\t\t\t\t\tif (!oldest) break;\n\t\t\t\t\t\tthis.pendingSessionEventBytes -= oldest.bytes;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const listener of this.eventListeners) {\n\t\t\t\tlistener(data as RpcClientEvent);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore non-JSON lines\n\t\t}\n\t}\n\n\tprivate flushPendingSessionEvents(): void {\n\t\tconst pending = this.pendingSessionEvents;\n\t\tthis.pendingSessionEvents = [];\n\t\tthis.pendingSessionEventBytes = 0;\n\t\tfor (const { sessionId, event } of pending) {\n\t\t\tif (sessionId !== this.sessionId) continue;\n\t\t\tfor (const listener of this.eventListeners) listener(event);\n\t\t}\n\t}\n\n\tprivate createProcessExitError(code: number | null, signal: NodeJS.Signals | null): Error {\n\t\treturn new Error(`Agent process exited (code=${code} signal=${signal}). Stderr: ${this.stderr}`);\n\t}\n\n\tprivate notifyDisconnect(error: RpcTransportGoneError): void {\n\t\tthis.rejectPendingRequests(error);\n\t\tif (!this.disconnectNotified && !this.stopping) {\n\t\t\tthis.disconnectNotified = true;\n\t\t\tthis.options.onDisconnect?.(error);\n\t\t}\n\t}\n\n\tprivate rejectPendingRequests(error: Error): void {\n\t\tfor (const pending of this.pendingRequests.values()) {\n\t\t\tpending.onReject?.(error);\n\t\t\tpending.reject(error);\n\t\t}\n\t\tthis.pendingRequests.clear();\n\t}\n\n\tprivate async send(\n\t\tcommand: RpcCommandBody | RpcExtensionUIResponse | RpcExtensionUIProgress,\n\t\troute = true,\n\t\thooks?: { onResponse?: (response: RpcResponse) => void; onReject?: (error: Error) => void },\n\t\texpectResponse = true,\n\t): Promise<RpcResponse> {\n\t\tconst childProcess = this.process;\n\t\tconst stream = this.socket ?? childProcess?.stdin;\n\t\tif (!stream) {\n\t\t\tthrow new RpcTransportGoneError();\n\t\t}\n\t\tif (this.exitError) {\n\t\t\tthrow this.exitError;\n\t\t}\n\t\tif (childProcess?.exitCode !== null && childProcess?.exitCode !== undefined) {\n\t\t\tconst error = this.createProcessExitError(childProcess.exitCode, childProcess.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stream.destroyed || !stream.writable) {\n\t\t\tconst error = new RpcTransportGoneError();\n\t\t\tthis.notifyDisconnect(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Extension-UI replies and progress carry the host's request id; never mint one.\n\t\tconst ownId =\n\t\t\tcommand.type === \"extension_ui_response\" || command.type === \"extension_ui_progress\" ? command.id : undefined;\n\t\tconst id = ownId ?? `req_${++this.requestId}`;\n\t\tconst fullCommand = {\n\t\t\t...command,\n\t\t\t...(route && this.sessionId && !(\"sessionId\" in command) ? { sessionId: this.sessionId } : {}),\n\t\t\t...(ownId === undefined ? { id } : {}),\n\t\t} as RpcCommand;\n\n\t\tif (!expectResponse) {\n\t\t\tstream.write(serializeJsonLine(fullCommand));\n\t\t\treturn Promise.resolve({ type: \"response\", command: command.type, success: true } as RpcResponse);\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tconst pending = this.pendingRequests.get(id);\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tconst timeoutError = new Error(`Timeout waiting for response to ${command.type}. Stderr: ${this.stderr}`);\n\t\t\t\tpending?.onReject?.(timeoutError);\n\t\t\t\treject(timeoutError);\n\t\t\t}, 30000);\n\n\t\t\tthis.pendingRequests.set(id, {\n\t\t\t\tresolve: (response) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t\t...(hooks?.onResponse ? { onResponse: hooks.onResponse } : {}),\n\t\t\t\t...(hooks?.onReject ? { onReject: hooks.onReject } : {}),\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tstream.write(serializeJsonLine(fullCommand));\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst writeError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tconst pending = this.pendingRequests.get(id);\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tpending?.onReject?.(writeError);\n\t\t\t\tpending?.reject(writeError);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate getData<T>(response: RpcResponse): T {\n\t\tif (!response.success) {\n\t\t\tconst errorResponse = response as Extract<RpcResponse, { success: false }>;\n\t\t\tif (errorResponse.errorCode === \"missing_session_cwd\" && errorResponse.errorData) {\n\t\t\t\tthrow new MissingSessionCwdError(\n\t\t\t\t\terrorResponse.errorData as ConstructorParameters<typeof MissingSessionCwdError>[0],\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new RpcCommandError(errorResponse.error, errorResponse.errorCode, errorResponse.errorData);\n\t\t}\n\t\t// Type assertion: we trust response.data matches T based on the command sent.\n\t\t// This is safe because each public method specifies the correct T for its command.\n\t\tconst successResponse = response as Extract<RpcResponse, { success: true; data: unknown }>;\n\t\treturn successResponse.data as T;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAC;AAOzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,mGAAmG;AACnG,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAIzC,YAAY,OAAe,EAAE,SAA6B,EAAE,SAAkB;QAC7E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;CACD;AAID,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkBtE,OAAO,EACN,gBAAgB,EAChB,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAqE/B,SAAS,sBAAsB,CAAC,KAAqB;IACpD,OAAO,KAAK,CAAC,IAAI,KAAK,uBAAuB,IAAI,KAAK,CAAC,IAAI,KAAK,kB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,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,OAAO,CAAI,QAAqB;QACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,aAAa,GAAG,QAAoD,CAAC;YAC3E,IAAI,aAAa,CAAC,SAAS,KAAK,qBAAqB,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;gBAClF,MAAM,IAAI,sBAAsB,CAC/B,aAAa,CAAC,SAAoE,CAClF,CAAC;YACH,CAAC;YACD,MAAM,IAAI,eAAe,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAClG,CAAC;QACD,8EAA8E;QAC9E,mFAAmF;QACnF,MAAM,eAAe,GAAG,QAAkE,CAAC;QAC3F,OAAO,eAAe,CAAC,IAAS,CAAC;IAClC,CAAC;CACD","sourcesContent":["/**\n * RPC Client for programmatic access to the coding agent.\n *\n * Spawns the agent in RPC mode and provides a typed API for all operations.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { createConnection, type Socket } from \"node:net\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent } from \"@earendil-works/pi-ai\";\nimport type { PromptDisposition, SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { CompactionResult } from \"../../core/compaction/index.ts\";\nimport type { ServiceTier } from \"../../core/extensions/builtin/service-tier.ts\";\nimport { MissingSessionCwdError } from \"../../core/session-cwd.ts\";\n\n/** A command the host refused; `errorCode` carries the typed code when the command defines one. */\nexport class RpcCommandError extends Error {\n\treadonly errorCode: string | undefined;\n\treadonly errorData: unknown;\n\n\tconstructor(message: string, errorCode: string | undefined, errorData: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"RpcCommandError\";\n\t\tthis.errorCode = errorCode;\n\t\tthis.errorData = errorData;\n\t}\n}\n\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport type { JsonAgentSessionEvent } from \"../json-event.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport type {\n\tEditAssistantMessageResult,\n\tRpcAccountFailoverEvent,\n\tRpcAuthAccountsChangedEvent,\n\tRpcCommand,\n\tRpcExtensionEvent,\n\tRpcExtensionUIProgress,\n\tRpcExtensionUIRequest,\n\tRpcExtensionUIResponse,\n\tRpcProviderAccount,\n\tRpcResponse,\n\tRpcSessionModelEntry,\n\tRpcSessionParkedEvent,\n\tRpcSessionReplacedEvent,\n\tRpcSessionState,\n\tRpcSlashCommand,\n} from \"./rpc-types.ts\";\nimport {\n\treadSocketSecret,\n\tresolveSocketTransportAddress,\n\tsendSocketHandshake,\n\tsocketSecretPath,\n} from \"./socket-transport.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Distributive Omit that works with union types */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\n\n/** RpcCommand without the id field (for internal send) */\ntype RpcCommandBody = DistributiveOmit<RpcCommand, \"id\">;\n\nexport interface RpcClientOptions {\n\t/** Connect to an existing multi-session Unix socket instead of spawning a child. */\n\tsocketPath?: string;\n\t/** Called once when an established transport disconnects. */\n\tonDisconnect?: (error: RpcTransportGoneError) => void;\n\t/** Path to the CLI entry point (default: searches for dist/cli.js) */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Environment variables */\n\tenv?: Record<string, string>;\n\t/** Provider to use */\n\tprovider?: string;\n\t/** Model ID to use */\n\tmodel?: string;\n\t/** Additional CLI arguments */\n\targs?: string[];\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tid: string;\n\tcontextWindow: number;\n\treasoning: boolean;\n\tsupportedThinkingLevels?: ThinkingLevel[];\n}\n\ntype PromptOptions = {\n\timages?: ImageContent[];\n\tstreamingBehavior?: \"steer\" | \"followUp\";\n\tthinkingLevel?: ThinkingLevel;\n\tpromptDisposition?: (disposition: PromptDisposition) => void;\n\tpreflightResult?: (success: boolean) => void;\n\tsessionTitlePrompt?: string | false;\n\texpandPromptTemplates?: boolean;\n};\n\nexport type RpcProviderAccountEvent = RpcAuthAccountsChangedEvent | RpcAccountFailoverEvent;\nexport type RpcClientEvent =\n\t| JsonAgentSessionEvent\n\t| RpcProviderAccountEvent\n\t| RpcExtensionEvent\n\t| RpcExtensionUIRequest\n\t// The host swapped the live session behind this connection. Part of the public\n\t// union so a typed client can discriminate on the type and read the new\n\t// `durableSessionId` without casting: the command response carries only\n\t// `{ cancelled }`, and a replacement may be driven by another client or an\n\t// extension, so this is the only channel delivering the new identity.\n\t| RpcSessionReplacedEvent\n\t// The host parked a retained session at its idle window. Part of the public union\n\t// because it REPLACES `session_closed` for that handle: a client that treats it as\n\t// a close loses the session it was told to reopen by path.\n\t| RpcSessionParkedEvent\n\t| { type: \"bash_start\" }\n\t| { type: \"bash_end\" };\nexport type RpcEventListener = (event: RpcClientEvent) => void;\n\nfunction isProviderAccountEvent(event: RpcClientEvent): event is RpcProviderAccountEvent {\n\treturn event.type === \"auth_accounts_changed\" || event.type === \"account_failover\";\n}\n\n// ============================================================================\n// RPC Client\n// ============================================================================\n\nexport class RpcTransportGoneError extends Error {\n\treadonly code = \"rpc_transport_gone\" as const;\n\n\tconstructor(message = \"Shared RPC host is unavailable\") {\n\t\tsuper(message);\n\t\tthis.name = \"RpcTransportGoneError\";\n\t}\n}\n\nexport function isTransportGoneError(error: unknown): error is RpcTransportGoneError {\n\treturn (\n\t\terror instanceof RpcTransportGoneError ||\n\t\t(error instanceof Error &&\n\t\t\t(error.message === \"Client not started\" ||\n\t\t\t\terror.message.startsWith(\"RPC transport is not writable.\") ||\n\t\t\t\terror.message === \"RPC socket closed\"))\n\t);\n}\n\nexport class RpcClientOpenInFlightError extends Error {\n\treadonly code = \"open_session_in_flight\" as const;\n\n\tconstructor() {\n\t\tsuper(\"An open_session request is already in flight\");\n\t\tthis.name = \"RpcClientOpenInFlightError\";\n\t}\n}\n\n// Keep pre-lease startup delivery bounded by both record count and wire size.\nconst MAX_PENDING_SESSION_EVENTS = 512;\nconst MAX_PENDING_SESSION_EVENT_BYTES = 1024 * 1024;\n\nexport class RpcClient {\n\tprivate process: ChildProcess | null = null;\n\tprivate socket: Socket | null = null;\n\tprivate stopReadingStdout: (() => void) | null = null;\n\tprivate eventListeners: RpcEventListener[] = [];\n\tprivate pendingRequests: Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (response: RpcResponse) => void;\n\t\t\treject: (error: Error) => void;\n\t\t\tonResponse?: (response: RpcResponse) => void;\n\t\t\tonReject?: (error: Error) => void;\n\t\t}\n\t> = new Map();\n\tprivate requestId = 0;\n\tprivate sessionId: string | undefined;\n\tprivate pendingOpenSession = false;\n\tprivate pendingSessionEvents: Array<{ sessionId: string; event: RpcClientEvent; bytes: number }> = [];\n\tprivate pendingSessionEventBytes = 0;\n\tprivate stderr = \"\";\n\tprivate exitError: Error | null = null;\n\tprivate disconnectNotified = false;\n\tprivate stopping = false;\n\tprivate options: RpcClientOptions;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Start the RPC agent process.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.process || this.socket) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tthis.exitError = null;\n\t\tthis.stopping = false;\n\t\tthis.disconnectNotified = false;\n\t\tif (this.options.socketPath) {\n\t\t\tawait this.startSocket(this.options.socketPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst cliPath = this.options.cliPath ?? \"dist/cli.js\";\n\t\tconst args = [\"--mode\", \"rpc\"];\n\n\t\tif (this.options.provider) {\n\t\t\targs.push(\"--provider\", this.options.provider);\n\t\t}\n\t\tif (this.options.model) {\n\t\t\targs.push(\"--model\", this.options.model);\n\t\t}\n\t\tif (this.options.args) {\n\t\t\targs.push(...this.options.args);\n\t\t}\n\n\t\tconst childProcess = spawn(\"node\", [cliPath, ...args], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// The spawned child must BE the process this client signals and reaps. An ambient\n\t\t\t\t// SENPI_RUNTIME=bun pin makes the launcher re-exec under Bun via spawnSync, so a\n\t\t\t\t// SIGTERM to the wrapper leaves the Bun host running: it keeps the session lease\n\t\t\t\t// and keeps writing session state after stop() resolved. Pin the runtime to the\n\t\t\t\t// interpreter chosen here, the same way app-server/daemon.ts does; options.env is\n\t\t\t\t// spread last so a caller can still override the pin explicitly.\n\t\t\t\tSENPI_RUNTIME: \"node\",\n\t\t\t\t...this.options.env,\n\t\t\t},\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t// Callers may be console-less on win32 (GUI hosts, detached daemons), and a\n\t\t\t// console-subsystem child would then allocate a fresh visible terminal window.\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.process = childProcess;\n\n\t\t// Collect stderr for debugging\n\t\tchildProcess.stderr?.on(\"data\", (data) => {\n\t\t\tthis.stderr += data.toString();\n\t\t\tprocess.stderr.write(data);\n\t\t});\n\n\t\tchildProcess.once(\"exit\", (code, signal) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst error = this.createProcessExitError(code, signal);\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.once(\"error\", (error) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst processError = new Error(`Agent process error: ${error.message}. Stderr: ${this.stderr}`);\n\t\t\tthis.exitError = processError;\n\t\t\tthis.rejectPendingRequests(processError);\n\t\t});\n\t\tchildProcess.stdin?.on(\"error\", (error) => {\n\t\t\tif (this.process !== childProcess) return;\n\t\t\tconst stdinError =\n\t\t\t\tthis.exitError ?? new Error(`Agent process stdin error: ${error.message}. Stderr: ${this.stderr}`);\n\t\t\tthis.exitError = stdinError;\n\t\t\tthis.rejectPendingRequests(stdinError);\n\t\t});\n\n\t\t// Set up strict JSONL reader for stdout.\n\t\tthis.stopReadingStdout = attachJsonlLineReader(childProcess.stdout!, (line) => {\n\t\t\tthis.handleLine(line);\n\t\t});\n\n\t\t// Wait a moment for process to initialize\n\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\n\t\tif (this.process.exitCode !== null) {\n\t\t\tconst error = this.exitError ?? this.createProcessExitError(this.process.exitCode, this.process.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Stop the RPC agent process.\n\t */\n\tasync stop(): Promise<void> {\n\t\tthis.pendingOpenSession = false;\n\t\tthis.pendingSessionEvents = [];\n\t\tthis.pendingSessionEventBytes = 0;\n\t\tif (this.socket) {\n\t\t\tthis.stopping = true;\n\t\t\tthis.stopReadingStdout?.();\n\t\t\tthis.stopReadingStdout = null;\n\t\t\tthis.socket.destroy();\n\t\t\tthis.socket = null;\n\t\t\tthis.sessionId = undefined;\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.pendingSessionEvents = [];\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t\treturn;\n\t\t}\n\t\tif (!this.process) return;\n\n\t\tthis.stopReadingStdout?.();\n\t\tthis.stopReadingStdout = null;\n\t\tthis.process.kill(\"SIGTERM\");\n\n\t\t// Wait for process to exit\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.process?.kill(\"SIGKILL\");\n\t\t\t\tresolve();\n\t\t\t}, 1000);\n\n\t\t\tthis.process?.on(\"exit\", () => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\tthis.process = null;\n\t\tthis.pendingRequests.clear();\n\t}\n\n\tprivate async startSocket(path: string): Promise<void> {\n\t\tconst secret = process.platform === \"win32\" ? await readSocketSecret(socketSecretPath(path)) : undefined;\n\t\tconst socket = createConnection(resolveSocketTransportAddress(path, process.platform, secret));\n\t\tthis.socket = socket;\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst onConnect = () => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\tthis.socket = null;\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\tconst cleanup = () => {\n\t\t\t\tsocket.off(\"connect\", onConnect);\n\t\t\t\tsocket.off(\"error\", onError);\n\t\t\t};\n\t\t\tsocket.once(\"connect\", onConnect);\n\t\t\tsocket.once(\"error\", onError);\n\t\t});\n\t\tif (secret) sendSocketHandshake(socket, secret);\n\t\tthis.stopReadingStdout = attachJsonlLineReader(socket, (line) => this.handleLine(line));\n\t\tsocket.once(\"close\", () => {\n\t\t\tif (this.socket !== socket) return;\n\t\t\tthis.socket = null;\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t});\n\t\tsocket.once(\"error\", (error) => {\n\t\t\tif (this.socket !== socket) return;\n\t\t\tthis.notifyDisconnect(new RpcTransportGoneError());\n\t\t\tvoid error;\n\t\t});\n\t}\n\n\t/**\n\t * Subscribe to agent events.\n\t */\n\tonEvent(listener: RpcEventListener): () => void {\n\t\tthis.eventListeners.push(listener);\n\t\treturn () => {\n\t\t\tconst index = this.eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Get collected stderr output (useful for debugging).\n\t */\n\tgetStderr(): string {\n\t\treturn this.stderr;\n\t}\n\n\t// =========================================================================\n\t// Command Methods\n\t// =========================================================================\n\n\tasync setClientInfo(width: number, capabilities?: string[]): Promise<void> {\n\t\tawait this.send({ type: \"set_client_info\", width, capabilities }, this.sessionId !== undefined);\n\t}\n\n\tasync openSession(options: {\n\t\tsessionPath?: string;\n\t\tcwd?: string;\n\t\tprovider?: string;\n\t\tmodelId?: string;\n\t\tthinkingLevel?: ThinkingLevel;\n\t\tpermissionPreset?: string;\n\t\t/** Keep the session alive when its last client disconnects; needs the host's `retain_on_disconnect`. */\n\t\tretain_on_disconnect?: boolean;\n\t\t/** Per-session auto-titling; needs the host's `auto_title_per_session`. */\n\t\tauto_title?: boolean;\n\t}): Promise<{ sessionId: string; state: RpcSessionState; attached?: boolean }> {\n\t\tif (this.pendingOpenSession) throw new RpcClientOpenInFlightError();\n\t\tthis.pendingOpenSession = true;\n\t\ttry {\n\t\t\tconst response = await this.send({ type: \"open_session\", ...options }, false);\n\t\t\tconst opened = this.getData<{ sessionId: string; state: RpcSessionState; attached?: boolean }>(response);\n\t\t\tthis.sessionId = opened.sessionId;\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.flushPendingSessionEvents();\n\t\t\treturn opened;\n\t\t} catch (error) {\n\t\t\tthis.pendingOpenSession = false;\n\t\t\tthis.pendingSessionEvents = [];\n\t\t\tthis.pendingSessionEventBytes = 0;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync sendExtensionUIResponse(response: RpcExtensionUIResponse): Promise<void> {\n\t\tawait this.send(response, true, undefined, false);\n\t}\n\n\t/** Draft update for an open `question` request; fire-and-forget like the response. */\n\tasync sendExtensionUIProgress(progress: RpcExtensionUIProgress): Promise<void> {\n\t\tawait this.send(progress, true, undefined, false);\n\t}\n\n\tasync closeSession(sessionId = this.sessionId): Promise<void> {\n\t\tif (!sessionId) return;\n\t\ttry {\n\t\t\tawait this.send({ type: \"close_session\", sessionId }, false);\n\t\t} catch (error) {\n\t\t\tif (!isTransportGoneError(error)) throw error;\n\t\t}\n\t\tif (this.sessionId === sessionId) this.sessionId = undefined;\n\t}\n\n\tasync listSessions(): Promise<\n\t\tArray<{\n\t\t\tsessionId: string;\n\t\t\tdurableSessionId?: string;\n\t\t\tsessionPath?: string;\n\t\t\tcwd: string;\n\t\t\tname?: string;\n\t\t\tstatus: \"opening\" | \"open\" | \"closing\" | \"closed\";\n\t\t\t/** Live client attachments; absent from hosts older than the `retain_on_disconnect` capability. */\n\t\t\tattachments?: number;\n\t\t}>\n\t> {\n\t\tconst response = await this.send({ type: \"list_sessions\" }, false);\n\t\treturn this.getData<{\n\t\t\tsessions: Array<{\n\t\t\t\tsessionId: string;\n\t\t\t\tdurableSessionId?: string;\n\t\t\t\tsessionPath?: string;\n\t\t\t\tcwd: string;\n\t\t\t\tname?: string;\n\t\t\t\tstatus: \"opening\" | \"open\" | \"closing\" | \"closed\";\n\t\t\t\tattachments?: number;\n\t\t\t}>;\n\t\t}>(response).sessions;\n\t}\n\n\t/**\n\t * Send a prompt to the agent.\n\t * Returns immediately after sending; use onEvent() to receive streaming events.\n\t * Use waitForIdle() to wait for completion.\n\t *\n\t * The disposition/preflight callbacks mirror AgentSession's local prompt contract:\n\t * they fire synchronously while the response frame is dispatched — before any\n\t * queued message_start event — so optimistic-echo eligibility is settled in wire\n\t * order. A success response without a disposition (older host) maps to \"handled\"\n\t * so the echo degrades to canonical-only rendering instead of double-rendering.\n\t */\n\tasync prompt(message: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(message: string, options?: PromptOptions): Promise<void>;\n\tasync prompt(message: string, optionsOrImages?: PromptOptions | ImageContent[]): Promise<void> {\n\t\tconst options: PromptOptions = Array.isArray(optionsOrImages)\n\t\t\t? { images: optionsOrImages }\n\t\t\t: (optionsOrImages ?? {});\n\t\tconst response = await this.send(\n\t\t\t{\n\t\t\t\ttype: \"prompt\",\n\t\t\t\tmessage,\n\t\t\t\t...(options.images ? { images: options.images } : {}),\n\t\t\t\t...(options.streamingBehavior ? { streamingBehavior: options.streamingBehavior } : {}),\n\t\t\t\t...(options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {}),\n\t\t\t\t...(options.sessionTitlePrompt !== undefined ? { sessionTitlePrompt: options.sessionTitlePrompt } : {}),\n\t\t\t\t...(options.expandPromptTemplates !== undefined\n\t\t\t\t\t? { expandPromptTemplates: options.expandPromptTemplates }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t\ttrue,\n\t\t\t{\n\t\t\t\tonResponse: (wireResponse) => {\n\t\t\t\t\tif (!wireResponse.success) {\n\t\t\t\t\t\toptions?.preflightResult?.(false);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst data = (wireResponse as { data?: { disposition?: PromptDisposition } }).data;\n\t\t\t\t\toptions?.promptDisposition?.(data?.disposition ?? \"handled\");\n\t\t\t\t\toptions?.preflightResult?.(true);\n\t\t\t\t},\n\t\t\t\tonReject: () => {\n\t\t\t\t\toptions?.preflightResult?.(false);\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\tif (!response.success) {\n\t\t\tthrow new Error((response as Extract<RpcResponse, { success: false }>).error);\n\t\t}\n\t}\n\n\tasync appendUserMessage(content: unknown): Promise<void> {\n\t\tawait this.send({ type: \"append_user_message\", content });\n\t}\n\n\tasync appendSessionEntry(entry: import(\"../../core/session-manager.ts\").SessionEntry): Promise<void> {\n\t\tawait this.send({ type: \"append_session_entry\", entry });\n\t}\n\n\tasync sendCustomMessage<T = unknown>(\n\t\tmessage: { customType: string; content: unknown; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void> {\n\t\tawait this.send({ type: \"send_custom_message\", ...message, ...options });\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t */\n\tasync steer(message: string, images?: ImageContent[], recovery?: { enqueueOrder?: number }): Promise<void> {\n\t\tawait this.send({ type: \"steer\", message, images, enqueueOrder: recovery?.enqueueOrder });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t */\n\tasync followUp(message: string, images?: ImageContent[], recovery?: { enqueueOrder?: number }): Promise<void> {\n\t\tawait this.send({ type: \"follow_up\", message, images, enqueueOrder: recovery?.enqueueOrder });\n\t}\n\n\t/**\n\t * Abort current operation.\n\t */\n\tasync abort(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.send({ type: \"abort\" });\n\t\t} catch (error) {\n\t\t\tif (!isTransportGoneError(error)) throw error;\n\t\t}\n\t}\n\n\tasync abortCompaction(): Promise<void> {\n\t\tawait this.send({ type: \"abort_compaction\" });\n\t}\n\n\tasync reload(): Promise<{ cancelled: boolean; reason?: string }> {\n\t\tconst response = await this.send({ type: \"reload\" });\n\t\treturn this.getData(response);\n\t}\n\n\tasync checkReloadVeto(): Promise<{ cancelled: boolean; reason?: string }> {\n\t\tconst response = await this.send({ type: \"check_reload_veto\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Clear queued steering and follow-up messages, returning their text.\n\t */\n\tasync clearQueue(options?: { abortWillFollow?: boolean }): Promise<{\n\t\tsteering: string[];\n\t\tfollowUp: string[];\n\t\tordered: Array<{ text: string; mode: \"steer\" | \"followUp\"; enqueueOrder: number }>;\n\t}> {\n\t\tconst response = await this.send({ type: \"clear_queue\", abortWillFollow: options?.abortWillFollow });\n\t\treturn this.getData(response);\n\t}\n\n\tasync getSteeringMessages(): Promise<string[]> {\n\t\tconst response = await this.send({ type: \"get_steering_messages\" });\n\t\treturn this.getData<{ messages: string[] }>(response).messages;\n\t}\n\n\tasync getFollowUpMessages(): Promise<string[]> {\n\t\tconst response = await this.send({ type: \"get_follow_up_messages\" });\n\t\treturn this.getData<{ messages: string[] }>(response).messages;\n\t}\n\n\tasync abortBranchSummary(): Promise<void> {\n\t\tawait this.send({ type: \"abort_branch_summary\" });\n\t}\n\n\tasync recordBashResult(command: string, result: BashResult, excludeFromContext?: boolean): Promise<void> {\n\t\tawait this.send({ type: \"record_bash_result\", command, result, excludeFromContext });\n\t}\n\n\tasync setLabel(entryId: string, label?: string): Promise<void> {\n\t\tawait this.send({ type: \"set_label\", entryId, label });\n\t}\n\n\t/**\n\t * Start a new session, optionally with parent tracking.\n\t * @param parentSession - Optional parent session path for lineage tracking\n\t * @returns Object with `cancelled: true` if an extension cancelled the new session\n\t */\n\tasync newSession(parentSession?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"new_session\", parentSession });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get current session state.\n\t */\n\tasync getState(): Promise<RpcSessionState> {\n\t\tconst response = await this.send({ type: \"get_state\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set model by provider and ID.\n\t */\n\tasync setModel(\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): Promise<{ provider: string; id: string; systemPromptName?: string }> {\n\t\tconst response = await this.send({ type: \"set_model\", provider, modelId });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Cycle to next model.\n\t */\n\tasync setFavoriteModels(models: RpcSessionModelEntry[]): Promise<void> {\n\t\tawait this.send({ type: \"set_favorite_models\", models });\n\t}\n\n\tasync setScopedModels(models: RpcSessionModelEntry[]): Promise<void> {\n\t\tawait this.send({ type: \"set_scoped_models\", models });\n\t}\n\n\tasync cycleModel(direction: \"forward\" | \"backward\" = \"forward\"): Promise<{\n\t\tmodel: { provider: string; id: string };\n\t\tthinkingLevel: ThinkingLevel;\n\t\tisScoped: boolean;\n\t} | null> {\n\t\tconst response = await this.send({ type: \"cycle_model\", direction });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get list of available models.\n\t */\n\tasync getAvailableModels(): Promise<ModelInfo[]> {\n\t\tconst response = await this.send({ type: \"get_available_models\" });\n\t\treturn this.getData<{ models: ModelInfo[] }>(response).models;\n\t}\n\n\t/**\n\t * Set thinking level.\n\t *\n\t * `scope: \"turn\"` changes only this session's level without rewriting the model's remembered\n\t * level; it throws when the active model does not support the requested level, and the\n\t * session keeps the level it already had.\n\t */\n\tasync setThinkingLevel(level: ThinkingLevel, options?: { scope?: \"turn\" }): Promise<void> {\n\t\tconst response = await this.send({ type: \"set_thinking_level\", level, scope: options?.scope });\n\t\tif (!response.success) {\n\t\t\tthrow new Error((response as Extract<RpcResponse, { success: false }>).error);\n\t\t}\n\t}\n\n\t/**\n\t * Cycle thinking level.\n\t */\n\tasync cycleThinkingLevel(): Promise<{ level: ThinkingLevel } | null> {\n\t\tconst response = await this.send({ type: \"cycle_thinking_level\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get list of available thinking levels for the current model.\n\t */\n\tasync getAvailableThinkingLevels(): Promise<ThinkingLevel[]> {\n\t\tconst response = await this.send({ type: \"get_available_thinking_levels\" });\n\t\treturn this.getData<{ levels: ThinkingLevel[] }>(response).levels;\n\t}\n\n\t/**\n\t * Turn OpenAI Codex fast mode (the `priority` service tier) on or off for the active model.\n\t *\n\t * The choice is remembered per model, so a later session on the same model starts the same\n\t * way. Throws when the request is refused: a non-Codex model, or an active `:priority` model\n\t * pin that fast mode must not undo.\n\t */\n\tasync setFastMode(\n\t\tenabled: boolean,\n\t): Promise<{ enabled: boolean; serviceTier: ServiceTier; provider: string; modelId: string }> {\n\t\tconst response = await this.send({ type: \"set_fast_mode\", enabled });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Current fast-mode state and the service tier requests would carry. */\n\tasync getFastMode(): Promise<{ enabled: boolean; serviceTier: ServiceTier | null }> {\n\t\tconst response = await this.send({ type: \"get_fast_mode\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set steering mode.\n\t */\n\tasync setSteeringMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_steering_mode\", mode });\n\t}\n\n\t/**\n\t * Set follow-up mode.\n\t */\n\tasync setFollowUpMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_follow_up_mode\", mode });\n\t}\n\n\t/**\n\t * Compact session context.\n\t */\n\tasync compact(customInstructions?: string): Promise<CompactionResult> {\n\t\tconst response = await this.send({ type: \"compact\", customInstructions });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set auto-compaction enabled/disabled.\n\t */\n\tasync setAutoCompaction(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_compaction\", enabled });\n\t}\n\n\t/**\n\t * Set auto-retry enabled/disabled.\n\t */\n\tasync setAutoRetry(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_retry\", enabled });\n\t}\n\n\t/**\n\t * Abort in-progress retry.\n\t */\n\tasync abortRetry(): Promise<void> {\n\t\tawait this.send({ type: \"abort_retry\" });\n\t}\n\n\t/**\n\t * Execute a bash command.\n\t */\n\tasync bash(\n\t\tcommand: string,\n\t\toptions?: { excludeFromContext?: boolean; executionId?: string; operations?: Record<string, unknown> },\n\t): Promise<BashResult> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"bash\",\n\t\t\tcommand,\n\t\t\texcludeFromContext: options?.excludeFromContext,\n\t\t\texecutionId: options?.executionId,\n\t\t\toperations: options?.operations,\n\t\t});\n\t\treturn this.getData(response);\n\t}\n\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ cancelled: boolean; editorText?: string; aborted?: boolean; summaryEntry?: unknown }> {\n\t\tconst response = await this.send({ type: \"navigate_tree\", targetId, ...options });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Abort running bash command.\n\t */\n\tasync abortBash(): Promise<void> {\n\t\tawait this.send({ type: \"abort_bash\" });\n\t}\n\n\tasync cleanupBashOutput(path: string): Promise<void> {\n\t\tawait this.send({ type: \"cleanup_bash_output\", path });\n\t}\n\n\t/**\n\t * Get session statistics.\n\t */\n\tasync getSessionStats(): Promise<SessionStats> {\n\t\tconst response = await this.send({ type: \"get_session_stats\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Export session to HTML.\n\t */\n\tasync exportHtml(outputPath?: string, themeName?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_html\", outputPath, themeName });\n\t\treturn this.getData(response);\n\t}\n\n\tasync exportJsonl(outputPath?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_jsonl\", outputPath });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Switch to a different session file.\n\t * @returns Object with `cancelled: true` if an extension cancelled the switch\n\t */\n\tasync switchSession(sessionPath: string, options?: { cwdOverride?: string }): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"switch_session\", sessionPath, cwdOverride: options?.cwdOverride });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Fork from a specific message.\n\t * @returns Object with `text` (the message text) and `cancelled` (if extension cancelled)\n\t */\n\tasync fork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\" },\n\t): Promise<{ text: string; cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"fork\", entryId, position: options?.position });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Clone the current active branch into a new session.\n\t * @returns Object with `cancelled: true` if an extension cancelled the clone\n\t */\n\tasync clone(): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"clone\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get messages available for forking.\n\t */\n\tasync getForkMessages(): Promise<Array<{ entryId: string; text: string }>> {\n\t\tconst response = await this.send({ type: \"get_fork_messages\" });\n\t\treturn this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;\n\t}\n\n\t/**\n\t * Get session entries in append order, optionally only those after the `since` entry id.\n\t */\n\tasync getEntries(since?: string): Promise<{ entries: SessionEntry[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_entries\", since });\n\t\treturn this.getData<{ entries: SessionEntry[]; leafId: string | null }>(response);\n\t}\n\n\t/**\n\t * Get the session entry tree.\n\t */\n\tasync getTree(): Promise<{ tree: SessionTreeNode[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_tree\" });\n\t\treturn this.getData<{ tree: SessionTreeNode[]; leafId: string | null }>(response);\n\t}\n\n\t/**\n\t * Replace an assistant response with an edited copy (branches to the target's parent and appends\n\t * the copy as the new leaf). Pass the `leafId` you last observed as `expectedLeafId` so a stale\n\t * edit is refused with `errorCode: \"stale_leaf\"` instead of rewriting a conversation another client\n\t * moved. Failures reject with an {@link RpcCommandError} carrying the typed `errorCode`.\n\t */\n\tasync editAssistantMessage(\n\t\tentryId: string,\n\t\ttext: string,\n\t\toptions: { expectedLeafId?: string; summarize?: boolean; customInstructions?: string } = {},\n\t): Promise<EditAssistantMessageResult> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"edit_assistant_message\",\n\t\t\tentryId,\n\t\t\ttext,\n\t\t\texpectedLeafId: options.expectedLeafId,\n\t\t\tsummarize: options.summarize,\n\t\t\tcustomInstructions: options.customInstructions,\n\t\t});\n\t\treturn this.getData<EditAssistantMessageResult>(response);\n\t}\n\n\t/**\n\t * Get text of last assistant message.\n\t */\n\tasync getLastAssistantText(): Promise<string | null> {\n\t\tconst response = await this.send({ type: \"get_last_assistant_text\" });\n\t\treturn this.getData<{ text: string | null }>(response).text;\n\t}\n\n\t/**\n\t * Set the session display name.\n\t */\n\tasync setSessionName(name: string): Promise<void> {\n\t\tawait this.send({ type: \"set_session_name\", name });\n\t}\n\n\tasync importJsonl(inputPath: string, cwdOverride?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"import_jsonl\", inputPath, cwdOverride });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get all messages in the session.\n\t */\n\tasync getMessages(): Promise<AgentMessage[]> {\n\t\tconst response = await this.send({ type: \"get_messages\" });\n\t\treturn this.getData<{ messages: AgentMessage[] }>(response).messages;\n\t}\n\n\t/**\n\t * Fetch one media block that arrived as an `image_ref` placeholder.\n\t *\n\t * `contentIndex` is the index inside the tool result's `content` array carried by\n\t * the placeholder's `ref`. Rejects with `media_not_found` when the tool call is\n\t * unknown or the index does not point at an image block.\n\t */\n\tasync getMedia(toolCallId: string, contentIndex: number): Promise<ImageContent> {\n\t\tconst response = await this.send({ type: \"get_media\", toolCallId, contentIndex });\n\t\treturn this.getData<{ toolCallId: string; contentIndex: number; content: ImageContent }>(response).content;\n\t}\n\n\t/**\n\t * Get available commands (extension commands, prompt templates, skills).\n\t */\n\tasync getCommands(): Promise<RpcSlashCommand[]> {\n\t\tconst response = await this.send({ type: \"get_commands\" });\n\t\treturn this.getData<{ commands: RpcSlashCommand[] }>(response).commands;\n\t}\n\n\t/** Invoke one extension-owned RPC request handler and return its structured result. */\n\tasync requestExtension<T = unknown>(name: string, data?: unknown): Promise<T> {\n\t\tconst response = await this.send({\n\t\t\ttype: \"extension_request\",\n\t\t\tname,\n\t\t\t...(data === undefined ? {} : { data }),\n\t\t});\n\t\treturn this.getData<T>(response);\n\t}\n\n\t/** List safe metadata for the named provider's configured account slots. */\n\tasync getProviderAccounts(provider: string): Promise<RpcProviderAccount[]> {\n\t\tconst response = await this.send({ type: \"get_provider_accounts\", provider });\n\t\treturn this.getData<{ accounts: RpcProviderAccount[] }>(response).accounts;\n\t}\n\n\t/** Pin a provider account for future session-affine requests, or clear the pin. */\n\tasync pinProviderAccount(provider: string, name: string | null): Promise<void> {\n\t\tawait this.send({ type: \"account_pin\", provider, name });\n\t}\n\n\t/** Remove a persisted provider account slot. Environment slots are read-only. */\n\tasync removeProviderAccount(provider: string, name: string): Promise<void> {\n\t\tawait this.send({ type: \"account_remove\", provider, name });\n\t}\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Wait for agent to become idle (no streaming).\n\t * Resolves when agent_settled event is received.\n\t */\n\twaitForIdle(timeout = 60000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (event.type === \"agent_settled\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Collect events until agent becomes idle.\n\t */\n\tcollectEvents(timeout = 60000): Promise<JsonAgentSessionEvent[]> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst events: JsonAgentSessionEvent[] = [];\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout collecting events. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (\n\t\t\t\t\tisProviderAccountEvent(event) ||\n\t\t\t\t\tevent.type === \"extension_event\" ||\n\t\t\t\t\tevent.type === \"bash_start\" ||\n\t\t\t\t\tevent.type === \"bash_end\" ||\n\t\t\t\t\tevent.type === \"extension_ui_request\" ||\n\t\t\t\t\t// Connection-level, not part of the agent's event stream.\n\t\t\t\t\tevent.type === \"session_replaced\" ||\n\t\t\t\t\tevent.type === \"session_parked\"\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tevents.push(event);\n\t\t\t\tif (event.type === \"agent_settled\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve(events);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Send prompt and wait for completion, returning all events.\n\t */\n\tasync promptAndWait(message: string, images?: ImageContent[], timeout = 60000): Promise<JsonAgentSessionEvent[]> {\n\t\tconst eventsPromise = this.collectEvents(timeout);\n\t\tawait this.prompt(message, images ? { images } : undefined);\n\t\treturn eventsPromise;\n\t}\n\n\t// =========================================================================\n\t// Internal\n\t// =========================================================================\n\n\tprivate handleLine(line: string): void {\n\t\ttry {\n\t\t\tconst data = JSON.parse(line);\n\n\t\t\t// Check if it's a response to a pending request\n\t\t\tif (data.type === \"response\" && data.id && this.pendingRequests.has(data.id)) {\n\t\t\t\tconst pending = this.pendingRequests.get(data.id)!;\n\t\t\t\tthis.pendingRequests.delete(data.id);\n\t\t\t\t// Response hooks run synchronously inside the frame dispatch so ordering-sensitive\n\t\t\t\t// contracts (e.g. optimistic-echo disposition) settle before the NEXT frame —\n\t\t\t\t// never through the microtask scheduled by resolve().\n\t\t\t\tpending.onResponse?.(data as RpcResponse);\n\t\t\t\tpending.resolve(data as RpcResponse);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Otherwise it's an event. During open_session, retain tagged events until\n\t\t\t// the response establishes the lease so startup hooks are not lost.\n\t\t\tif (typeof data.sessionId === \"string\" && data.sessionId !== this.sessionId) {\n\t\t\t\tif (this.pendingOpenSession) {\n\t\t\t\t\tconst bytes = Buffer.byteLength(line);\n\t\t\t\t\tthis.pendingSessionEvents.push({ sessionId: data.sessionId, event: data as RpcClientEvent, bytes });\n\t\t\t\t\tthis.pendingSessionEventBytes += bytes;\n\t\t\t\t\twhile (\n\t\t\t\t\t\tthis.pendingSessionEvents.length > MAX_PENDING_SESSION_EVENTS ||\n\t\t\t\t\t\tthis.pendingSessionEventBytes > MAX_PENDING_SESSION_EVENT_BYTES\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst oldest = this.pendingSessionEvents.shift();\n\t\t\t\t\t\tif (!oldest) break;\n\t\t\t\t\t\tthis.pendingSessionEventBytes -= oldest.bytes;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const listener of this.eventListeners) {\n\t\t\t\tlistener(data as RpcClientEvent);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore non-JSON lines\n\t\t}\n\t}\n\n\tprivate flushPendingSessionEvents(): void {\n\t\tconst pending = this.pendingSessionEvents;\n\t\tthis.pendingSessionEvents = [];\n\t\tthis.pendingSessionEventBytes = 0;\n\t\tfor (const { sessionId, event } of pending) {\n\t\t\tif (sessionId !== this.sessionId) continue;\n\t\t\tfor (const listener of this.eventListeners) listener(event);\n\t\t}\n\t}\n\n\tprivate createProcessExitError(code: number | null, signal: NodeJS.Signals | null): Error {\n\t\treturn new Error(`Agent process exited (code=${code} signal=${signal}). Stderr: ${this.stderr}`);\n\t}\n\n\tprivate notifyDisconnect(error: RpcTransportGoneError): void {\n\t\tthis.rejectPendingRequests(error);\n\t\tif (!this.disconnectNotified && !this.stopping) {\n\t\t\tthis.disconnectNotified = true;\n\t\t\tthis.options.onDisconnect?.(error);\n\t\t}\n\t}\n\n\tprivate rejectPendingRequests(error: Error): void {\n\t\tfor (const pending of this.pendingRequests.values()) {\n\t\t\tpending.onReject?.(error);\n\t\t\tpending.reject(error);\n\t\t}\n\t\tthis.pendingRequests.clear();\n\t}\n\n\tprivate async send(\n\t\tcommand: RpcCommandBody | RpcExtensionUIResponse | RpcExtensionUIProgress,\n\t\troute = true,\n\t\thooks?: { onResponse?: (response: RpcResponse) => void; onReject?: (error: Error) => void },\n\t\texpectResponse = true,\n\t): Promise<RpcResponse> {\n\t\tconst childProcess = this.process;\n\t\tconst stream = this.socket ?? childProcess?.stdin;\n\t\tif (!stream) {\n\t\t\tthrow new RpcTransportGoneError();\n\t\t}\n\t\tif (this.exitError) {\n\t\t\tthrow this.exitError;\n\t\t}\n\t\tif (childProcess?.exitCode !== null && childProcess?.exitCode !== undefined) {\n\t\t\tconst error = this.createProcessExitError(childProcess.exitCode, childProcess.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stream.destroyed || !stream.writable) {\n\t\t\tconst error = new RpcTransportGoneError();\n\t\t\tthis.notifyDisconnect(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Extension-UI replies and progress carry the host's request id; never mint one.\n\t\tconst ownId =\n\t\t\tcommand.type === \"extension_ui_response\" || command.type === \"extension_ui_progress\" ? command.id : undefined;\n\t\tconst id = ownId ?? `req_${++this.requestId}`;\n\t\tconst fullCommand = {\n\t\t\t...command,\n\t\t\t...(route && this.sessionId && !(\"sessionId\" in command) ? { sessionId: this.sessionId } : {}),\n\t\t\t...(ownId === undefined ? { id } : {}),\n\t\t} as RpcCommand;\n\n\t\tif (!expectResponse) {\n\t\t\tstream.write(serializeJsonLine(fullCommand));\n\t\t\treturn Promise.resolve({ type: \"response\", command: command.type, success: true } as RpcResponse);\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tconst pending = this.pendingRequests.get(id);\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tconst timeoutError = new Error(`Timeout waiting for response to ${command.type}. Stderr: ${this.stderr}`);\n\t\t\t\tpending?.onReject?.(timeoutError);\n\t\t\t\treject(timeoutError);\n\t\t\t}, 30000);\n\n\t\t\tthis.pendingRequests.set(id, {\n\t\t\t\tresolve: (response) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t\t...(hooks?.onResponse ? { onResponse: hooks.onResponse } : {}),\n\t\t\t\t...(hooks?.onReject ? { onReject: hooks.onReject } : {}),\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tstream.write(serializeJsonLine(fullCommand));\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst writeError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tconst pending = this.pendingRequests.get(id);\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tpending?.onReject?.(writeError);\n\t\t\t\tpending?.reject(writeError);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate getData<T>(response: RpcResponse): T {\n\t\tif (!response.success) {\n\t\t\tconst errorResponse = response as Extract<RpcResponse, { success: false }>;\n\t\t\tif (errorResponse.errorCode === \"missing_session_cwd\" && errorResponse.errorData) {\n\t\t\t\tthrow new MissingSessionCwdError(\n\t\t\t\t\terrorResponse.errorData as ConstructorParameters<typeof MissingSessionCwdError>[0],\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new RpcCommandError(errorResponse.error, errorResponse.errorCode, errorResponse.errorData);\n\t\t}\n\t\t// Type assertion: we trust response.data matches T based on the command sent.\n\t\t// This is safe because each public method specifies the correct T for its command.\n\t\tconst successResponse = response as Extract<RpcResponse, { success: true; data: unknown }>;\n\t\treturn successResponse.data as T;\n\t}\n}\n"]}
@@ -1,5 +1,33 @@
1
1
  export declare const MAX_RPC_MESSAGE_CHARACTERS = 1000000;
2
+ /**
3
+ * Bounds on `open_session.context`. The host stores the blob per session and republishes
4
+ * it on `list_sessions { include_workers: true }`, so it is bounded at the boundary: an
5
+ * unbounded label map would be per-session memory and per-listing bytes a client controls.
6
+ */
7
+ export declare const SESSION_CONTEXT_LIMITS: {
8
+ readonly keys: 32;
9
+ readonly valueBytes: number;
10
+ readonly totalBytes: number;
11
+ };
2
12
  export declare function rpcCommandPayloadError(command: unknown): string | undefined;
13
+ /**
14
+ * Detail for an `open_session.context` the host refuses, or undefined when the value is
15
+ * absent or a valid context. The caller answers with `invalid_session_context: <detail>`;
16
+ * the detail names the cap that was broken so a client can fix the payload without guessing.
17
+ */
18
+ export declare function sessionContextError(context: unknown): string | undefined;
19
+ /**
20
+ * Detail for an `open_session.kind` the host refuses, or undefined when the value is absent
21
+ * or a known kind. An unknown kind is never treated as `interactive`: a typo would publish
22
+ * machine-driven work to every client that lists sessions.
23
+ */
24
+ export declare function sessionKindError(kind: unknown): string | undefined;
25
+ /**
26
+ * Detail for an `open_session.auto_title` the host refuses, or undefined when the
27
+ * value is absent or a boolean. Absent keeps the host-wide default; a non-boolean
28
+ * cannot be coerced without collapsing `true` / `false` / omitted into one state.
29
+ */
30
+ export declare function sessionAutoTitleError(value: unknown): string | undefined;
3
31
  export declare function rpcCommandShapeError(command: unknown): string | undefined;
4
32
  export declare function rpcMessageLengthError(command: unknown): string | undefined;
5
33
  //# sourceMappingURL=rpc-input-validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-input-validation.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input-validation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,UAAY,CAAC;AAuEpD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU3E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKzE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU1E"}
1
+ {"version":3,"file":"rpc-input-validation.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input-validation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,UAAY,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;aAClC,IAAI,EAAE,EAAE;aACR,UAAU;aACV,UAAU;CACD,CAAC;AAyEX,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAwBxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKzE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU1E"}
@@ -1,4 +1,15 @@
1
1
  export const MAX_RPC_MESSAGE_CHARACTERS = 1_000_000;
2
+ /**
3
+ * Bounds on `open_session.context`. The host stores the blob per session and republishes
4
+ * it on `list_sessions { include_workers: true }`, so it is bounded at the boundary: an
5
+ * unbounded label map would be per-session memory and per-listing bytes a client controls.
6
+ */
7
+ export const SESSION_CONTEXT_LIMITS = {
8
+ keys: 32,
9
+ valueBytes: 16 * 1024,
10
+ totalBytes: 32 * 1024,
11
+ };
12
+ const SESSION_CONTEXT_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
2
13
  function validContent(content) {
3
14
  if (typeof content === "string")
4
15
  return true;
@@ -67,6 +78,58 @@ export function rpcCommandPayloadError(command) {
67
78
  }
68
79
  return undefined;
69
80
  }
81
+ /**
82
+ * Detail for an `open_session.context` the host refuses, or undefined when the value is
83
+ * absent or a valid context. The caller answers with `invalid_session_context: <detail>`;
84
+ * the detail names the cap that was broken so a client can fix the payload without guessing.
85
+ */
86
+ export function sessionContextError(context) {
87
+ if (context === undefined)
88
+ return undefined;
89
+ if (typeof context !== "object" || context === null || Array.isArray(context)) {
90
+ return "context must be an object of string values.";
91
+ }
92
+ const entries = Object.entries(context);
93
+ if (entries.length > SESSION_CONTEXT_LIMITS.keys) {
94
+ return `context has ${entries.length} keys, at most ${SESSION_CONTEXT_LIMITS.keys} are accepted.`;
95
+ }
96
+ for (const [key, value] of entries) {
97
+ if (!SESSION_CONTEXT_KEY_PATTERN.test(key)) {
98
+ return `context key "${key}" must match ${SESSION_CONTEXT_KEY_PATTERN.source}.`;
99
+ }
100
+ if (typeof value !== "string")
101
+ return `context value for key "${key}" must be a string.`;
102
+ const valueBytes = Buffer.byteLength(value);
103
+ if (valueBytes > SESSION_CONTEXT_LIMITS.valueBytes) {
104
+ return `context value for key "${key}" is ${valueBytes} bytes, at most ${SESSION_CONTEXT_LIMITS.valueBytes} bytes are accepted.`;
105
+ }
106
+ }
107
+ const totalBytes = Buffer.byteLength(JSON.stringify(context));
108
+ if (totalBytes > SESSION_CONTEXT_LIMITS.totalBytes) {
109
+ return `context is ${totalBytes} bytes of JSON, at most ${SESSION_CONTEXT_LIMITS.totalBytes} bytes are accepted.`;
110
+ }
111
+ return undefined;
112
+ }
113
+ /**
114
+ * Detail for an `open_session.kind` the host refuses, or undefined when the value is absent
115
+ * or a known kind. An unknown kind is never treated as `interactive`: a typo would publish
116
+ * machine-driven work to every client that lists sessions.
117
+ */
118
+ export function sessionKindError(kind) {
119
+ if (kind === undefined || kind === "interactive" || kind === "worker")
120
+ return undefined;
121
+ return `kind must be "interactive" or "worker".`;
122
+ }
123
+ /**
124
+ * Detail for an `open_session.auto_title` the host refuses, or undefined when the
125
+ * value is absent or a boolean. Absent keeps the host-wide default; a non-boolean
126
+ * cannot be coerced without collapsing `true` / `false` / omitted into one state.
127
+ */
128
+ export function sessionAutoTitleError(value) {
129
+ if (value === undefined || typeof value === "boolean")
130
+ return undefined;
131
+ return "auto_title must be a boolean.";
132
+ }
70
133
  export function rpcCommandShapeError(command) {
71
134
  if (typeof command !== "object" || command === null || Array.isArray(command)) {
72
135
  return "RPC command must be a JSON object.";
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-input-validation.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input-validation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAOpD,SAAS,YAAY,CAAC,OAAgB;IACrC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,CACN,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YAC5D,MAAM,KAAK,GAAG,IAA8E,CAAC;YAC7F,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM;gBAC3B,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAChC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,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AC,EAAE,CAAC;QAC1E,OAAO,2EAA2E,CAAC;IACpF,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9E,OAAO,0CAA0C,CAAC;IACnD,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACpD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,OAAO,oCAAoC,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACrD,IAAI,oBAAoB,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,KAAK,GAAG,OAA0B,CAAC;IACzC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACrF,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,0BAA0B,EAAE,CAAC;QAC7F,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,IAAI,oBAAoB,0BAA0B,cAAc,CAAC;AACtF,CAAC","sourcesContent":["export const MAX_RPC_MESSAGE_CHARACTERS = 1_000_000;\n\ninterface RpcMessageInput {\n\ttype?: unknown;\n\tmessage?: unknown;\n}\n\nfunction validContent(content: unknown): boolean {\n\tif (typeof content === \"string\") return true;\n\treturn (\n\t\tArray.isArray(content) &&\n\t\tcontent.every((item) => {\n\t\t\tif (typeof item !== \"object\" || item === null) return false;\n\t\t\tconst value = item as { type?: unknown; text?: unknown; data?: unknown; mimeType?: unknown };\n\t\t\treturn value.type === \"text\"\n\t\t\t\t? typeof value.text === \"string\"\n\t\t\t\t: value.type === \"image\" && typeof value.data === \"string\" && typeof value.mimeType === \"string\";\n\t\t})\n\t);\n}\n\nfunction validBaseEntry(entry: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof entry.id === \"string\" &&\n\t\t(entry.parentId === null || typeof entry.parentId === \"string\") &&\n\t\ttypeof entry.timestamp === \"string\"\n\t);\n}\n\nfunction validSessionEntry(entry: unknown): boolean {\n\tif (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) return false;\n\tconst value = entry as Record<string, unknown>;\n\tif (!validBaseEntry(value)) return false;\n\tswitch (value.type) {\n\t\tcase \"message\": {\n\t\t\tconst message = value.message;\n\t\t\tif (typeof message !== \"object\" || message === null) return false;\n\t\t\tconst item = message as { role?: unknown; content?: unknown };\n\t\t\treturn [\"user\", \"assistant\", \"tool\"].includes(item.role as string) && validContent(item.content);\n\t\t}\n\t\tcase \"thinking_level_change\":\n\t\t\treturn typeof value.thinkingLevel === \"string\";\n\t\tcase \"model_change\":\n\t\t\treturn typeof value.provider === \"string\" && typeof value.modelId === \"string\";\n\t\tcase \"model_change_rejected\":\n\t\t\treturn (\n\t\t\t\ttypeof value.provider === \"string\" && typeof value.modelId === \"string\" && typeof value.detail === \"string\"\n\t\t\t);\n\t\tcase \"compaction\":\n\t\t\treturn (\n\t\t\t\ttypeof value.summary === \"string\" &&\n\t\t\t\ttypeof value.firstKeptEntryId === \"string\" &&\n\t\t\t\ttypeof value.tokensBefore === \"number\"\n\t\t\t);\n\t\tcase \"branch_summary\":\n\t\t\treturn typeof value.fromId === \"string\" && typeof value.summary === \"string\";\n\t\tcase \"custom\":\n\t\t\treturn typeof value.customType === \"string\";\n\t\tcase \"custom_message\":\n\t\t\treturn (\n\t\t\t\ttypeof value.customType === \"string\" && validContent(value.content) && typeof value.display === \"boolean\"\n\t\t\t);\n\t\tcase \"label\":\n\t\t\treturn typeof value.targetId === \"string\" && (value.label === undefined || typeof value.label === \"string\");\n\t\tcase \"session_info\":\n\t\t\treturn value.name === undefined || typeof value.name === \"string\";\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function rpcCommandPayloadError(command: unknown): string | undefined {\n\tif (rpcCommandShapeError(command)) return undefined;\n\tconst value = command as Record<string, unknown>;\n\tif (value.type === \"append_user_message\" && !validContent(value.content)) {\n\t\treturn \"append_user_message content must be a string or text/image content array.\";\n\t}\n\tif (value.type === \"append_session_entry\" && !validSessionEntry(value.entry)) {\n\t\treturn \"append_session_entry entry is malformed.\";\n\t}\n\treturn undefined;\n}\n\nexport function rpcCommandShapeError(command: unknown): string | undefined {\n\tif (typeof command !== \"object\" || command === null || Array.isArray(command)) {\n\t\treturn \"RPC command must be a JSON object.\";\n\t}\n\treturn undefined;\n}\n\nexport function rpcMessageLengthError(command: unknown): string | undefined {\n\tif (rpcCommandShapeError(command)) return undefined;\n\tconst input = command as RpcMessageInput;\n\tif (input.type !== \"prompt\" && input.type !== \"steer\" && input.type !== \"follow_up\") {\n\t\treturn undefined;\n\t}\n\tif (typeof input.message !== \"string\" || input.message.length <= MAX_RPC_MESSAGE_CHARACTERS) {\n\t\treturn undefined;\n\t}\n\treturn `RPC ${input.type} message exceeds ${MAX_RPC_MESSAGE_CHARACTERS} characters.`;\n}\n"]}
1
+ {"version":3,"file":"rpc-input-validation.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input-validation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,EAAE,GAAG,IAAI;IACrB,UAAU,EAAE,EAAE,GAAG,IAAI;CACZ,CAAC;AAEX,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAOxD,SAAS,YAAY,CA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AAQ,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,OAAO,oCAAoC,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACrD,IAAI,oBAAoB,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,KAAK,GAAG,OAA0B,CAAC;IACzC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACrF,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,0BAA0B,EAAE,CAAC;QAC7F,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,IAAI,oBAAoB,0BAA0B,cAAc,CAAC;AACtF,CAAC","sourcesContent":["export const MAX_RPC_MESSAGE_CHARACTERS = 1_000_000;\n\n/**\n * Bounds on `open_session.context`. The host stores the blob per session and republishes\n * it on `list_sessions { include_workers: true }`, so it is bounded at the boundary: an\n * unbounded label map would be per-session memory and per-listing bytes a client controls.\n */\nexport const SESSION_CONTEXT_LIMITS = {\n\tkeys: 32,\n\tvalueBytes: 16 * 1024,\n\ttotalBytes: 32 * 1024,\n} as const;\n\nconst SESSION_CONTEXT_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;\n\ninterface RpcMessageInput {\n\ttype?: unknown;\n\tmessage?: unknown;\n}\n\nfunction validContent(content: unknown): boolean {\n\tif (typeof content === \"string\") return true;\n\treturn (\n\t\tArray.isArray(content) &&\n\t\tcontent.every((item) => {\n\t\t\tif (typeof item !== \"object\" || item === null) return false;\n\t\t\tconst value = item as { type?: unknown; text?: unknown; data?: unknown; mimeType?: unknown };\n\t\t\treturn value.type === \"text\"\n\t\t\t\t? typeof value.text === \"string\"\n\t\t\t\t: value.type === \"image\" && typeof value.data === \"string\" && typeof value.mimeType === \"string\";\n\t\t})\n\t);\n}\n\nfunction validBaseEntry(entry: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof entry.id === \"string\" &&\n\t\t(entry.parentId === null || typeof entry.parentId === \"string\") &&\n\t\ttypeof entry.timestamp === \"string\"\n\t);\n}\n\nfunction validSessionEntry(entry: unknown): boolean {\n\tif (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) return false;\n\tconst value = entry as Record<string, unknown>;\n\tif (!validBaseEntry(value)) return false;\n\tswitch (value.type) {\n\t\tcase \"message\": {\n\t\t\tconst message = value.message;\n\t\t\tif (typeof message !== \"object\" || message === null) return false;\n\t\t\tconst item = message as { role?: unknown; content?: unknown };\n\t\t\treturn [\"user\", \"assistant\", \"tool\"].includes(item.role as string) && validContent(item.content);\n\t\t}\n\t\tcase \"thinking_level_change\":\n\t\t\treturn typeof value.thinkingLevel === \"string\";\n\t\tcase \"model_change\":\n\t\t\treturn typeof value.provider === \"string\" && typeof value.modelId === \"string\";\n\t\tcase \"model_change_rejected\":\n\t\t\treturn (\n\t\t\t\ttypeof value.provider === \"string\" && typeof value.modelId === \"string\" && typeof value.detail === \"string\"\n\t\t\t);\n\t\tcase \"compaction\":\n\t\t\treturn (\n\t\t\t\ttypeof value.summary === \"string\" &&\n\t\t\t\ttypeof value.firstKeptEntryId === \"string\" &&\n\t\t\t\ttypeof value.tokensBefore === \"number\"\n\t\t\t);\n\t\tcase \"branch_summary\":\n\t\t\treturn typeof value.fromId === \"string\" && typeof value.summary === \"string\";\n\t\tcase \"custom\":\n\t\t\treturn typeof value.customType === \"string\";\n\t\tcase \"custom_message\":\n\t\t\treturn (\n\t\t\t\ttypeof value.customType === \"string\" && validContent(value.content) && typeof value.display === \"boolean\"\n\t\t\t);\n\t\tcase \"label\":\n\t\t\treturn typeof value.targetId === \"string\" && (value.label === undefined || typeof value.label === \"string\");\n\t\tcase \"session_info\":\n\t\t\treturn value.name === undefined || typeof value.name === \"string\";\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function rpcCommandPayloadError(command: unknown): string | undefined {\n\tif (rpcCommandShapeError(command)) return undefined;\n\tconst value = command as Record<string, unknown>;\n\tif (value.type === \"append_user_message\" && !validContent(value.content)) {\n\t\treturn \"append_user_message content must be a string or text/image content array.\";\n\t}\n\tif (value.type === \"append_session_entry\" && !validSessionEntry(value.entry)) {\n\t\treturn \"append_session_entry entry is malformed.\";\n\t}\n\treturn undefined;\n}\n\n/**\n * Detail for an `open_session.context` the host refuses, or undefined when the value is\n * absent or a valid context. The caller answers with `invalid_session_context: <detail>`;\n * the detail names the cap that was broken so a client can fix the payload without guessing.\n */\nexport function sessionContextError(context: unknown): string | undefined {\n\tif (context === undefined) return undefined;\n\tif (typeof context !== \"object\" || context === null || Array.isArray(context)) {\n\t\treturn \"context must be an object of string values.\";\n\t}\n\tconst entries = Object.entries(context as Record<string, unknown>);\n\tif (entries.length > SESSION_CONTEXT_LIMITS.keys) {\n\t\treturn `context has ${entries.length} keys, at most ${SESSION_CONTEXT_LIMITS.keys} are accepted.`;\n\t}\n\tfor (const [key, value] of entries) {\n\t\tif (!SESSION_CONTEXT_KEY_PATTERN.test(key)) {\n\t\t\treturn `context key \"${key}\" must match ${SESSION_CONTEXT_KEY_PATTERN.source}.`;\n\t\t}\n\t\tif (typeof value !== \"string\") return `context value for key \"${key}\" must be a string.`;\n\t\tconst valueBytes = Buffer.byteLength(value);\n\t\tif (valueBytes > SESSION_CONTEXT_LIMITS.valueBytes) {\n\t\t\treturn `context value for key \"${key}\" is ${valueBytes} bytes, at most ${SESSION_CONTEXT_LIMITS.valueBytes} bytes are accepted.`;\n\t\t}\n\t}\n\tconst totalBytes = Buffer.byteLength(JSON.stringify(context));\n\tif (totalBytes > SESSION_CONTEXT_LIMITS.totalBytes) {\n\t\treturn `context is ${totalBytes} bytes of JSON, at most ${SESSION_CONTEXT_LIMITS.totalBytes} bytes are accepted.`;\n\t}\n\treturn undefined;\n}\n\n/**\n * Detail for an `open_session.kind` the host refuses, or undefined when the value is absent\n * or a known kind. An unknown kind is never treated as `interactive`: a typo would publish\n * machine-driven work to every client that lists sessions.\n */\nexport function sessionKindError(kind: unknown): string | undefined {\n\tif (kind === undefined || kind === \"interactive\" || kind === \"worker\") return undefined;\n\treturn `kind must be \"interactive\" or \"worker\".`;\n}\n\n/**\n * Detail for an `open_session.auto_title` the host refuses, or undefined when the\n * value is absent or a boolean. Absent keeps the host-wide default; a non-boolean\n * cannot be coerced without collapsing `true` / `false` / omitted into one state.\n */\nexport function sessionAutoTitleError(value: unknown): string | undefined {\n\tif (value === undefined || typeof value === \"boolean\") return undefined;\n\treturn \"auto_title must be a boolean.\";\n}\n\nexport function rpcCommandShapeError(command: unknown): string | undefined {\n\tif (typeof command !== \"object\" || command === null || Array.isArray(command)) {\n\t\treturn \"RPC command must be a JSON object.\";\n\t}\n\treturn undefined;\n}\n\nexport function rpcMessageLengthError(command: unknown): string | undefined {\n\tif (rpcCommandShapeError(command)) return undefined;\n\tconst input = command as RpcMessageInput;\n\tif (input.type !== \"prompt\" && input.type !== \"steer\" && input.type !== \"follow_up\") {\n\t\treturn undefined;\n\t}\n\tif (typeof input.message !== \"string\" || input.message.length <= MAX_RPC_MESSAGE_CHARACTERS) {\n\t\treturn undefined;\n\t}\n\treturn `RPC ${input.type} message exceeds ${MAX_RPC_MESSAGE_CHARACTERS} characters.`;\n}\n"]}
@@ -28,9 +28,9 @@
28
28
  * | Command | Params | Success data | Notes |
29
29
  * | ---------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------- | ----- |
30
30
  * | `get_protocol_info` | - | `{ protocolVersion: 1, serverVersion, capabilities, mode: "classic"|"multi" }` | Answered in BOTH modes; side-effect-free capability probe. |
31
- * | `open_session` | `sessionPath?`, `cwd?`, `provider?`, `modelId?`, `thinkingLevel?`, `permissionPreset?`, `retain_on_disconnect?` (all optional; paths MUST be absolute) | `{ sessionId, state: RpcSessionState, attached?: boolean }` | `sessionPath` = today's `--session` semantics (open-if-exists else create persisting there); `provider`/`modelId` applied only on create (resume restores the session's model); params form the immutable launch profile (D8). `retain_on_disconnect: true` (default false, host capability `retain_on_disconnect`) makes a dropped connection detach instead of closing the session. |
32
- * | `close_session` | `sessionId` | `{}` | Aborts active work and awaits teardown for the host grace window, then force-releases; the first closer's response is the LAST record tagged with that handle, while concurrent closes join and receive targeted success responses. |
33
- * | `list_sessions` | - | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status, attachments }] }` | Includes `opening`/`closing` entries with their status; `attachments` is the live client count (`0` = retained, detached). |
31
+ * | `open_session` | `sessionPath?`, `cwd?`, `provider?`, `modelId?`, `thinkingLevel?`, `permissionPreset?`, `retain_on_disconnect?`, `kind?`, `context?`, `auto_title?` (all optional; paths MUST be absolute) | `{ sessionId, state: RpcSessionState, attached?: boolean }` | `sessionPath` = today's `--session` semantics (open-if-exists else create persisting there); `provider`/`modelId` applied only on create (resume restores the session's model); params form the immutable launch profile (D8). `retain_on_disconnect: true` (default false, host capability `retain_on_disconnect`) makes a dropped connection detach instead of closing the session. `kind: "interactive"|"worker"` (default `interactive`, host capability `session_kind`) sets the session's visibility class. `context` (host capability `session_context`) is an opaque `Record<string,string>` the host never interprets: at most 32 keys matching `^[a-z][a-z0-9_]*$`, each value <= 16 KiB, <= 32 KiB of JSON in total; it reaches that session's extensions as `pi.sessionContext` and nothing else. `auto_title` (host capability `auto_title_per_session`) opts this session into or out of engine-side titling; omitted keeps the host `--auto-title-sessions` / appMode default. |
32
+ * | `close_session` | `sessionId` | `{}` | `unknown_session` when the requesting connection never attached to that handle (a close releases the CALLER's attachment). Otherwise aborts active work and awaits teardown for the host grace window, then force-releases; the first closer's response is the LAST record tagged with that handle, while concurrent closes join and receive targeted success responses. |
33
+ * | `list_sessions` | `include_workers?` (default false) | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status, attachments, kind, context? }] }` | Includes `opening`/`closing` entries with their status; `attachments` is the live client count (`0` = retained, detached). `kind: "worker"` rows are omitted unless `include_workers: true`, and `context` is published ONLY on that listing. |
34
34
  * | `get_steering_messages` / `get_follow_up_messages` / `clear_queue` | queue read or clear parameters | host-authoritative queue values | Interactive attach clients must not read bootstrap queues. |
35
35
  * | `abort_branch_summary` / `record_bash_result` / `set_label` | narrow mutation payloads | `{}` | Routes interactive runtime mutations to the owning host session. |
36
36
  * | every existing command | + `sessionId` (REQUIRED in multi mode) | unchanged | Routed to that session. |
@@ -45,13 +45,23 @@
45
45
  * `unknown_session`, `session_closing`, `session_path_in_use`, `missing_session_id`
46
46
  * (session-scoped command without `sessionId` in multi mode), `multi_session_disabled`
47
47
  * (`open_session` in classic mode), `invalid_path` (relative `sessionPath`/`cwd`),
48
- * `open_failed: <detail>`.
48
+ * `open_failed: <detail>`, `invalid_session_context: <detail>` (a `context` past a
49
+ * documented cap), `invalid_session_kind: <detail>` (a `kind` that is neither
50
+ * `interactive` nor `worker`), `invalid_launch_profile: <detail>` (a non-boolean
51
+ * `auto_title`).
49
52
  *
50
53
  * Tagging: every response/event/`extension_ui_request` belonging to a session
51
54
  * carries top-level `sessionId` (routing handle). `get_protocol_info`/
52
55
  * `list_sessions` responses are untagged. Classic mode: nothing tagged
53
56
  * (byte-identical).
54
57
  *
58
+ * Lifecycle visibility: content-free lifecycle records are broadcast to every
59
+ * connection, EXCEPT `session_closed` and `session_parked` for a `kind: "worker"`
60
+ * session, which are delivered only to the connections attached to that session.
61
+ * `session_parked { sessionId, sessionPath }` replaces `session_closed` when the
62
+ * idle sweep parks a session opened with `retain_on_disconnect`: the routing handle
63
+ * is released, the session itself reopens by `sessionPath`.
64
+ *
55
65
  * Ordering guarantee (D9): strict FIFO per session; one total stdout order;
56
66
  * cross-session order unspecified; fair round-robin between sessions' queued
57
67
  * complete records; NO cross-session batch coalescing (per-session event buffers;
@@ -61,7 +71,10 @@
61
71
  * record completion.
62
72
  *
63
73
  * Duplicate/idempotency: duplicate `open_session` while a path reservation is
64
- * held → `session_path_in_use`. `close_session` on unknown/already-closed →
74
+ * held → `session_path_in_use`; a reservation held by a session whose teardown is
75
+ * already in flight is WAITED OUT on the in-process runtime (bounded by the close
76
+ * grace window) and the path then opens fresh. `close_session` on
77
+ * unknown/already-closed, or from a connection that never attached to that handle →
65
78
  * `unknown_session` error. Request `id`s are client-owned; the server echoes them
66
79
  * without dedup.
67
80
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAgB/E,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAuGjF"}
1
+ {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAgB/E,YAAY,EACX,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAuGjF"}