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

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 (177) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bundle/chunks/{app-server-command-XSPV6BRF.js → app-server-command-RTISWAJY.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-PLUQUK3T.js → chunk-IM4UIHPI.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-IGKWKAMN.js → chunk-XHTF6VKZ.js} +4 -3
  9. package/dist/bundle/chunks/chunk-YD5QZXAK.js +8 -0
  10. package/dist/bundle/chunks/{cli-main-L7WQP5V6.js → cli-main-TO3O4TUE.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-ARGRH6QZ.js} +1 -1
  15. package/dist/bundle/chunks/multi-session-host-HIZZTSYU.js +20 -0
  16. package/dist/bundle/chunks/{package-manager-cli-J26DB6GM.js → package-manager-cli-544JIWNJ.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-S3IEBFEB.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 +24 -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/vercel-ai-gateway.json +1 -1
  168. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  169. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  170. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  171. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  172. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  173. package/package.json +7 -7
  174. package/dist/bundle/chunks/chunk-3Q5PD4KW.js +0 -8
  175. package/dist/bundle/chunks/chunk-YLYLKL7X.js +0 -2
  176. package/dist/bundle/chunks/multi-session-host-SMNZXFPT.js +0 -18
  177. package/dist/bundle/chunks/rotation-stream-SCVFIQ2O.js +0 -2
@@ -1,7 +1,7 @@
1
1
  import { isAbsolute } from "node:path";
2
2
  import { ProviderScope } from "@earendil-works/pi-ai/node/provider-scope";
3
3
  import { RESERVATION_DENIAL_CODES, SessionPathReservations, } from "./session-path-reservations.js";
4
- import { RpcSessionRegistryError, } from "./session-registry.js";
4
+ import { frozenProfile, RpcSessionRegistryError, sessionIdentity, } from "./session-registry.js";
5
5
  import { SessionWorkerClient } from "./session-worker-client.js";
6
6
  import { SESSION_WORKER_LIMITS } from "./session-worker-protocol.js";
7
7
  /** Transport-side lifecycle owner. Caller paths are never inspected on this event loop. */
@@ -29,10 +29,12 @@ export class WorkerSessionRegistry {
29
29
  if (this.size >= SESSION_WORKER_LIMITS.workers)
30
30
  throw new Error("too_many_sessions");
31
31
  const handle = `rpc-${++this.serial}`;
32
+ const storedProfile = frozenProfile(profile);
32
33
  const entry = {
33
34
  state: "opening",
34
35
  scope: new ProviderScope(),
35
- profile: Object.freeze({ ...profile }),
36
+ profile: storedProfile,
37
+ ...sessionIdentity(storedProfile),
36
38
  cwd: profile.cwd,
37
39
  attachments: 1,
38
40
  retainOnDisconnect: options?.retainOnDisconnect === true,
@@ -163,6 +165,8 @@ export class WorkerSessionRegistry {
163
165
  sessionPath: state?.sessionFile ?? entry.sessionPath,
164
166
  cwd: state?.cwd ?? entry.cwd,
165
167
  name: state?.sessionName,
168
+ kind: entry.kind,
169
+ context: entry.context,
166
170
  // A closing entry has already released its last attachment; never publish that as negative.
167
171
  attachments: Math.max(0, entry.attachments),
168
172
  status: entry.state === "quarantined" ? "closing" : entry.state,
@@ -1 +1 @@
1
- {"version":3,"file":"worker-session-registry.js","sourceRoot":"","sources":["../../../src/modes/rpc/worker-session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,OAAO,EAEN,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAKN,uBAAuB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAA0B,MAAM,8BAA8B,CAAC;AAE7F,2FAA2F;AAC3F,MAAM,OAAO,qBAAqB;IASjC,YAAY,OAA4F;QARvF,YAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC7C,iBAAY,GAAG,IAAI,uBAAuB,EAAE,CAAC;Q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AC,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAChC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,gBAAgB,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;IACpF,CAAC;IAEO,UAAU,CAAC,MAAc,EAAE,KAAsB;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;QAC5C,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,uBAAuB,CAAC,aAAa,CAAC,CAAC;QAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;IACjG,CAAC;CACD","sourcesContent":["import { isAbsolute } from \"node:path\";\nimport { ProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { CliRuntimeConfiguration } from \"../../main.ts\";\nimport {\n\ttype LiveWorkerPaths,\n\tRESERVATION_DENIAL_CODES,\n\tSessionPathReservations,\n} from \"./session-path-reservations.ts\";\nimport {\n\ttype OpenRpcSession,\n\ttype RpcSessionEntry,\n\ttype RpcSessionLaunchProfile,\n\ttype RpcSessionOpenOptions,\n\tRpcSessionRegistryError,\n} from \"./session-registry.ts\";\nimport { SessionWorkerClient } from \"./session-worker-client.ts\";\nimport { SESSION_WORKER_LIMITS, type SessionWriteGrant } from \"./session-worker-protocol.ts\";\n\n/** Transport-side lifecycle owner. Caller paths are never inspected on this event loop. */\nexport class WorkerSessionRegistry {\n\tprivate readonly entries = new Map<string, RpcSessionEntry>();\n\tprivate readonly reservations = new SessionPathReservations();\n\tprivate serial = 0;\n\treadonly closeGraceMs: number;\n\tprivate readonly now: () => number;\n\n\tprivate readonly options: { configuration: CliRuntimeConfiguration; closeGraceMs: number; now: () => number };\n\n\tconstructor(options: { configuration: CliRuntimeConfiguration; closeGraceMs: number; now: () => number }) {\n\t\tthis.options = options;\n\t\tthis.closeGraceMs = options.closeGraceMs;\n\t\tthis.now = options.now;\n\t}\n\n\tget size(): number {\n\t\treturn this.entries.size;\n\t}\n\n\tasync openSession(profile: RpcSessionLaunchProfile, options?: RpcSessionOpenOptions): Promise<OpenRpcSession> {\n\t\tif (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath)))\n\t\t\tthrow new RpcSessionRegistryError(\"invalid_path\");\n\t\tif (profile.sessionPath) {\n\t\t\tconst key = this.knownReservationKey(profile.sessionPath);\n\t\t\tconst owner = key ? this.reservations.owner(key) : undefined;\n\t\t\tif (key && owner) return this.attach(owner, key, options);\n\t\t}\n\t\tif (this.size >= SESSION_WORKER_LIMITS.workers) throw new Error(\"too_many_sessions\");\n\t\tconst handle = `rpc-${++this.serial}`;\n\t\tconst entry: RpcSessionEntry = {\n\t\t\tstate: \"opening\",\n\t\t\tscope: new ProviderScope(),\n\t\t\tprofile: Object.freeze({ ...profile }),\n\t\t\tcwd: profile.cwd,\n\t\t\tattachments: 1,\n\t\t\tretainOnDisconnect: options?.retainOnDisconnect === true,\n\t\t\tlastCommandAt: this.now(),\n\t\t\tlifecycleMutex: Promise.resolve(),\n\t\t};\n\t\tconst worker = new SessionWorkerClient({\n\t\t\treserve: (path) => this.reserve(handle, path),\n\t\t\treconcile: (livePaths) => this.reconcile(handle, livePaths),\n\t\t\texit: () => {\n\t\t\t\tif (this.entries.get(handle) !== entry) return;\n\t\t\t\tentry.state = \"closed\";\n\t\t\t\tthis.entries.delete(handle);\n\t\t\t\tthis.reservations.releaseAll(handle);\n\t\t\t\tentry.closeResolve?.();\n\t\t\t},\n\t\t\tfailure: (error) => {\n\t\t\t\tentry.state = \"quarantined\";\n\t\t\t\tprocess.stderr.write(`senpi rpc session ${handle} quarantined: ${error}\\n`);\n\t\t\t},\n\t\t});\n\t\tentry.worker = worker;\n\t\tthis.entries.set(handle, entry);\n\t\ttry {\n\t\t\tconst path = await worker.prepare(this.options.configuration, profile);\n\t\t\tconst owner = this.reservations.owner(path);\n\t\t\tif (owner) {\n\t\t\t\tconst attached = this.attach(owner, path, options);\n\t\t\t\tentry.state = \"quarantined\";\n\t\t\t\tworker.quarantine();\n\t\t\t\treturn attached;\n\t\t\t}\n\t\t\tconst grant = this.reserve(handle, path);\n\t\t\tif (grant !== \"granted\") throw new RpcSessionRegistryError(RESERVATION_DENIAL_CODES[grant]);\n\t\t\tentry.reservationKey = path;\n\t\t\tentry.requestedPathKey = profile.sessionPath ? path : undefined;\n\t\t\tentry.sessionPath = path;\n\t\t\tconst snapshot = await worker.commit();\n\t\t\tif (entry.state !== \"opening\") throw new RpcSessionRegistryError(\"session_closing\");\n\t\t\tentry.durableSessionId = snapshot.state.sessionId;\n\t\t\tentry.cwd = snapshot.state.cwd;\n\t\t\tentry.state = \"open\";\n\t\t\treturn this.openResult(handle, entry);\n\t\t} catch (cause) {\n\t\t\tentry.state = \"quarantined\";\n\t\t\tworker.quarantine();\n\t\t\tthrow cause;\n\t\t}\n\t}\n\n\tpeek(handle: string): RpcSessionEntry | undefined {\n\t\treturn this.entries.get(handle);\n\t}\n\n\tgetForCommand(handle: string, command: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (\n\t\t\tentry.state === \"quarantined\" ||\n\t\t\t(entry.state === \"closing\" &&\n\t\t\t\t![\"abort\", \"abort_bash\", \"extension_ui_response\", \"extension_ui_progress\"].includes(command))\n\t\t)\n\t\t\tthrow new RpcSessionRegistryError(\"session_closing\");\n\t\tif (entry.state !== \"open\" && entry.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.lastCommandAt = this.now();\n\t\treturn entry;\n\t}\n\n\tbeginClose(handle: string, onRole?: (finalizer: boolean) => void, options?: { detach?: boolean }): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.state === \"closing\" || entry.state === \"quarantined\") {\n\t\t\tonRole?.(false);\n\t\t\treturn entry;\n\t\t}\n\t\tif (entry.state !== \"open\" && entry.state !== \"opening\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.attachments--;\n\t\tif (entry.attachments > 0) return entry;\n\t\t// A retained session answers a client's detach by staying open at zero\n\t\t// attachments; only an explicit close or eviction reaches the worker.\n\t\tif (options?.detach && entry.retainOnDisconnect) {\n\t\t\tentry.attachments = 0;\n\t\t\treturn entry;\n\t\t}\n\t\tentry.state = \"closing\";\n\t\tentry.closeCompletion = new Promise((resolve) => {\n\t\t\tentry.closeResolve = resolve;\n\t\t});\n\t\tonRole?.(true);\n\t\treturn entry;\n\t}\n\n\tclose(handle: string): Promise<void> {\n\t\tconst entry = this.beginClose(handle);\n\t\treturn entry.state === \"closing\" ? this.closeMarked(handle) : Promise.resolve();\n\t}\n\n\tasync closeMarked(handle: string): Promise<void> {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"closing\" || !entry.worker) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.closeStarted) return entry.closeCompletion;\n\t\tentry.closeStarted = true;\n\t\t// Reply on a bounded deadline, but keep entry, attachments and reservations until exit.\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tawait Promise.race([\n\t\t\tentry.worker.close(this.closeGraceMs),\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tif (entry.state !== \"closed\") entry.state = \"quarantined\";\n\t\t\t\t\tresolve();\n\t\t\t\t}, this.closeGraceMs);\n\t\t\t}),\n\t\t]);\n\t\tif (timer) clearTimeout(timer);\n\t}\n\n\tlist(): Array<{\n\t\tsessionId: string;\n\t\tdurableSessionId?: string;\n\t\tsessionPath?: string;\n\t\tcwd: string;\n\t\tname?: string;\n\t\tstatus: Exclude<RpcSessionEntry[\"state\"], \"quarantined\">;\n\t\tattachments: number;\n\t}> {\n\t\treturn [...this.entries].map(([sessionId, entry]) => {\n\t\t\tconst state = entry.worker?.snapshot?.state;\n\t\t\treturn {\n\t\t\t\tsessionId,\n\t\t\t\tdurableSessionId: state?.sessionId ?? entry.durableSessionId,\n\t\t\t\tsessionPath: state?.sessionFile ?? entry.sessionPath,\n\t\t\t\tcwd: state?.cwd ?? entry.cwd,\n\t\t\t\tname: state?.sessionName,\n\t\t\t\t// A closing entry has already released its last attachment; never publish that as negative.\n\t\t\t\tattachments: Math.max(0, entry.attachments),\n\t\t\t\tstatus: entry.state === \"quarantined\" ? \"closing\" : entry.state,\n\t\t\t};\n\t\t});\n\t}\n\n\t/** Only compare spellings already tied to a granted identity; do not inspect caller paths here. */\n\tprivate knownReservationKey(path: string): string | undefined {\n\t\tif (this.reservations.owner(path)) return path;\n\t\tfor (const entry of this.entries.values()) {\n\t\t\t// An opening spelling maps only while the key granted for it is still held: a\n\t\t\t// superseded path belongs to nobody and must open its own worker.\n\t\t\tif (\n\t\t\t\tentry.profile.sessionPath === path &&\n\t\t\t\tentry.requestedPathKey &&\n\t\t\t\tthis.reservations.owner(entry.requestedPathKey)\n\t\t\t)\n\t\t\t\treturn entry.requestedPathKey;\n\t\t\tconst snapshot = entry.worker?.snapshot;\n\t\t\tif (snapshot?.state.sessionFile === path) return snapshot.sessionPath;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate attach(owner: string, path: string, options?: RpcSessionOpenOptions): OpenRpcSession {\n\t\tconst entry = this.entries.get(owner);\n\t\tif (entry?.state !== \"open\" || !entry.worker?.bindingReady || entry.worker.snapshot?.sessionPath !== path)\n\t\t\tthrow new RpcSessionRegistryError(\"session_path_in_use\");\n\t\tconst result = this.openResult(owner, entry);\n\t\tentry.attachments++;\n\t\t// Retention is a property of the live session: any attach may ask for it, and\n\t\t// no attach may revoke it for the clients that already rely on it.\n\t\tif (options?.retainOnDisconnect) entry.retainOnDisconnect = true;\n\t\tentry.lastCommandAt = this.now();\n\t\treturn { ...result, attached: true };\n\t}\n\n\t/** Granted paths currently held by a handle; the per-worker budget is bounded by it. */\n\treservationCount(handle: string): number {\n\t\treturn this.reservations.count(handle);\n\t}\n\n\tprivate reserve(handle: string, path: string): SessionWriteGrant {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) return \"conflict\";\n\t\tif (this.reservations.owner(path) === handle) return \"granted\";\n\t\tif (entry.state !== \"opening\" && entry.state !== \"open\") return \"conflict\";\n\t\treturn this.reservations.reserve(handle, path, this.liveWorkerPaths(entry));\n\t}\n\n\t/**\n\t * Releases the grants a worker's latest snapshot no longer claims.\n\t *\n\t * Only a fully open entry reports live writers. An entry still opening, closing or\n\t * quarantined keeps every grant until its real exit, because a worker stuck in a\n\t * syscall can still be writing a path it can no longer report.\n\t */\n\tprivate reconcile(handle: string, livePaths: readonly string[]): void {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"open\") return;\n\t\tconst sessionPath = entry.worker?.snapshot?.sessionPath;\n\t\tthis.reservations.reconcile(handle, { livePaths, sessionPath });\n\t\tif (!sessionPath) return;\n\t\tentry.reservationKey = sessionPath;\n\t\tentry.sessionPath = sessionPath;\n\t}\n\n\t/** The live view a full budget is reconciled against; absent while the entry cannot report one. */\n\tprivate liveWorkerPaths(entry: RpcSessionEntry): LiveWorkerPaths | undefined {\n\t\tconst snapshot = entry.state === \"open\" ? entry.worker?.snapshot : undefined;\n\t\tif (!snapshot) return undefined;\n\t\treturn { livePaths: snapshot.liveSessionPaths, sessionPath: snapshot.sessionPath };\n\t}\n\n\tprivate openResult(handle: string, entry: RpcSessionEntry): OpenRpcSession {\n\t\tconst state = entry.worker?.snapshot?.state;\n\t\tif (!state) throw new RpcSessionRegistryError(\"open_failed\");\n\t\treturn { sessionId: handle, durableSessionId: state.sessionId, sessionPath: state.sessionFile };\n\t}\n}\n"]}
1
+ {"version":3,"file":"wor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AAC;IACjG,CAAC;CACD","sourcesContent":["import { isAbsolute } from \"node:path\";\nimport { ProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { CliRuntimeConfiguration } from \"../../main.ts\";\nimport {\n\ttype LiveWorkerPaths,\n\tRESERVATION_DENIAL_CODES,\n\tSessionPathReservations,\n} from \"./session-path-reservations.ts\";\nimport {\n\tfrozenProfile,\n\ttype OpenRpcSession,\n\ttype RpcSessionEntry,\n\ttype RpcSessionLaunchProfile,\n\ttype RpcSessionOpenOptions,\n\tRpcSessionRegistryError,\n\ttype RpcSessionRow,\n\tsessionIdentity,\n} from \"./session-registry.ts\";\nimport { SessionWorkerClient } from \"./session-worker-client.ts\";\nimport { SESSION_WORKER_LIMITS, type SessionWriteGrant } from \"./session-worker-protocol.ts\";\n\n/** Transport-side lifecycle owner. Caller paths are never inspected on this event loop. */\nexport class WorkerSessionRegistry {\n\tprivate readonly entries = new Map<string, RpcSessionEntry>();\n\tprivate readonly reservations = new SessionPathReservations();\n\tprivate serial = 0;\n\treadonly closeGraceMs: number;\n\tprivate readonly now: () => number;\n\n\tprivate readonly options: { configuration: CliRuntimeConfiguration; closeGraceMs: number; now: () => number };\n\n\tconstructor(options: { configuration: CliRuntimeConfiguration; closeGraceMs: number; now: () => number }) {\n\t\tthis.options = options;\n\t\tthis.closeGraceMs = options.closeGraceMs;\n\t\tthis.now = options.now;\n\t}\n\n\tget size(): number {\n\t\treturn this.entries.size;\n\t}\n\n\tasync openSession(profile: RpcSessionLaunchProfile, options?: RpcSessionOpenOptions): Promise<OpenRpcSession> {\n\t\tif (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath)))\n\t\t\tthrow new RpcSessionRegistryError(\"invalid_path\");\n\t\tif (profile.sessionPath) {\n\t\t\tconst key = this.knownReservationKey(profile.sessionPath);\n\t\t\tconst owner = key ? this.reservations.owner(key) : undefined;\n\t\t\tif (key && owner) return this.attach(owner, key, options);\n\t\t}\n\t\tif (this.size >= SESSION_WORKER_LIMITS.workers) throw new Error(\"too_many_sessions\");\n\t\tconst handle = `rpc-${++this.serial}`;\n\t\tconst storedProfile = frozenProfile(profile);\n\t\tconst entry: RpcSessionEntry = {\n\t\t\tstate: \"opening\",\n\t\t\tscope: new ProviderScope(),\n\t\t\tprofile: storedProfile,\n\t\t\t...sessionIdentity(storedProfile),\n\t\t\tcwd: profile.cwd,\n\t\t\tattachments: 1,\n\t\t\tretainOnDisconnect: options?.retainOnDisconnect === true,\n\t\t\tlastCommandAt: this.now(),\n\t\t\tlifecycleMutex: Promise.resolve(),\n\t\t};\n\t\tconst worker = new SessionWorkerClient({\n\t\t\treserve: (path) => this.reserve(handle, path),\n\t\t\treconcile: (livePaths) => this.reconcile(handle, livePaths),\n\t\t\texit: () => {\n\t\t\t\tif (this.entries.get(handle) !== entry) return;\n\t\t\t\tentry.state = \"closed\";\n\t\t\t\tthis.entries.delete(handle);\n\t\t\t\tthis.reservations.releaseAll(handle);\n\t\t\t\tentry.closeResolve?.();\n\t\t\t},\n\t\t\tfailure: (error) => {\n\t\t\t\tentry.state = \"quarantined\";\n\t\t\t\tprocess.stderr.write(`senpi rpc session ${handle} quarantined: ${error}\\n`);\n\t\t\t},\n\t\t});\n\t\tentry.worker = worker;\n\t\tthis.entries.set(handle, entry);\n\t\ttry {\n\t\t\tconst path = await worker.prepare(this.options.configuration, profile);\n\t\t\tconst owner = this.reservations.owner(path);\n\t\t\tif (owner) {\n\t\t\t\tconst attached = this.attach(owner, path, options);\n\t\t\t\tentry.state = \"quarantined\";\n\t\t\t\tworker.quarantine();\n\t\t\t\treturn attached;\n\t\t\t}\n\t\t\tconst grant = this.reserve(handle, path);\n\t\t\tif (grant !== \"granted\") throw new RpcSessionRegistryError(RESERVATION_DENIAL_CODES[grant]);\n\t\t\tentry.reservationKey = path;\n\t\t\tentry.requestedPathKey = profile.sessionPath ? path : undefined;\n\t\t\tentry.sessionPath = path;\n\t\t\tconst snapshot = await worker.commit();\n\t\t\tif (entry.state !== \"opening\") throw new RpcSessionRegistryError(\"session_closing\");\n\t\t\tentry.durableSessionId = snapshot.state.sessionId;\n\t\t\tentry.cwd = snapshot.state.cwd;\n\t\t\tentry.state = \"open\";\n\t\t\treturn this.openResult(handle, entry);\n\t\t} catch (cause) {\n\t\t\tentry.state = \"quarantined\";\n\t\t\tworker.quarantine();\n\t\t\tthrow cause;\n\t\t}\n\t}\n\n\tpeek(handle: string): RpcSessionEntry | undefined {\n\t\treturn this.entries.get(handle);\n\t}\n\n\tgetForCommand(handle: string, command: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (\n\t\t\tentry.state === \"quarantined\" ||\n\t\t\t(entry.state === \"closing\" &&\n\t\t\t\t![\"abort\", \"abort_bash\", \"extension_ui_response\", \"extension_ui_progress\"].includes(command))\n\t\t)\n\t\t\tthrow new RpcSessionRegistryError(\"session_closing\");\n\t\tif (entry.state !== \"open\" && entry.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.lastCommandAt = this.now();\n\t\treturn entry;\n\t}\n\n\tbeginClose(handle: string, onRole?: (finalizer: boolean) => void, options?: { detach?: boolean }): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.state === \"closing\" || entry.state === \"quarantined\") {\n\t\t\tonRole?.(false);\n\t\t\treturn entry;\n\t\t}\n\t\tif (entry.state !== \"open\" && entry.state !== \"opening\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.attachments--;\n\t\tif (entry.attachments > 0) return entry;\n\t\t// A retained session answers a client's detach by staying open at zero\n\t\t// attachments; only an explicit close or eviction reaches the worker.\n\t\tif (options?.detach && entry.retainOnDisconnect) {\n\t\t\tentry.attachments = 0;\n\t\t\treturn entry;\n\t\t}\n\t\tentry.state = \"closing\";\n\t\tentry.closeCompletion = new Promise((resolve) => {\n\t\t\tentry.closeResolve = resolve;\n\t\t});\n\t\tonRole?.(true);\n\t\treturn entry;\n\t}\n\n\tclose(handle: string): Promise<void> {\n\t\tconst entry = this.beginClose(handle);\n\t\treturn entry.state === \"closing\" ? this.closeMarked(handle) : Promise.resolve();\n\t}\n\n\tasync closeMarked(handle: string): Promise<void> {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"closing\" || !entry.worker) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.closeStarted) return entry.closeCompletion;\n\t\tentry.closeStarted = true;\n\t\t// Reply on a bounded deadline, but keep entry, attachments and reservations until exit.\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tawait Promise.race([\n\t\t\tentry.worker.close(this.closeGraceMs),\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tif (entry.state !== \"closed\") entry.state = \"quarantined\";\n\t\t\t\t\tresolve();\n\t\t\t\t}, this.closeGraceMs);\n\t\t\t}),\n\t\t]);\n\t\tif (timer) clearTimeout(timer);\n\t}\n\n\tlist(): RpcSessionRow[] {\n\t\treturn [...this.entries].map(([sessionId, entry]) => {\n\t\t\tconst state = entry.worker?.snapshot?.state;\n\t\t\treturn {\n\t\t\t\tsessionId,\n\t\t\t\tdurableSessionId: state?.sessionId ?? entry.durableSessionId,\n\t\t\t\tsessionPath: state?.sessionFile ?? entry.sessionPath,\n\t\t\t\tcwd: state?.cwd ?? entry.cwd,\n\t\t\t\tname: state?.sessionName,\n\t\t\t\tkind: entry.kind,\n\t\t\t\tcontext: entry.context,\n\t\t\t\t// A closing entry has already released its last attachment; never publish that as negative.\n\t\t\t\tattachments: Math.max(0, entry.attachments),\n\t\t\t\tstatus: entry.state === \"quarantined\" ? \"closing\" : entry.state,\n\t\t\t};\n\t\t});\n\t}\n\n\t/** Only compare spellings already tied to a granted identity; do not inspect caller paths here. */\n\tprivate knownReservationKey(path: string): string | undefined {\n\t\tif (this.reservations.owner(path)) return path;\n\t\tfor (const entry of this.entries.values()) {\n\t\t\t// An opening spelling maps only while the key granted for it is still held: a\n\t\t\t// superseded path belongs to nobody and must open its own worker.\n\t\t\tif (\n\t\t\t\tentry.profile.sessionPath === path &&\n\t\t\t\tentry.requestedPathKey &&\n\t\t\t\tthis.reservations.owner(entry.requestedPathKey)\n\t\t\t)\n\t\t\t\treturn entry.requestedPathKey;\n\t\t\tconst snapshot = entry.worker?.snapshot;\n\t\t\tif (snapshot?.state.sessionFile === path) return snapshot.sessionPath;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate attach(owner: string, path: string, options?: RpcSessionOpenOptions): OpenRpcSession {\n\t\tconst entry = this.entries.get(owner);\n\t\tif (entry?.state !== \"open\" || !entry.worker?.bindingReady || entry.worker.snapshot?.sessionPath !== path)\n\t\t\tthrow new RpcSessionRegistryError(\"session_path_in_use\");\n\t\tconst result = this.openResult(owner, entry);\n\t\tentry.attachments++;\n\t\t// Retention is a property of the live session: any attach may ask for it, and\n\t\t// no attach may revoke it for the clients that already rely on it.\n\t\tif (options?.retainOnDisconnect) entry.retainOnDisconnect = true;\n\t\tentry.lastCommandAt = this.now();\n\t\treturn { ...result, attached: true };\n\t}\n\n\t/** Granted paths currently held by a handle; the per-worker budget is bounded by it. */\n\treservationCount(handle: string): number {\n\t\treturn this.reservations.count(handle);\n\t}\n\n\tprivate reserve(handle: string, path: string): SessionWriteGrant {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) return \"conflict\";\n\t\tif (this.reservations.owner(path) === handle) return \"granted\";\n\t\tif (entry.state !== \"opening\" && entry.state !== \"open\") return \"conflict\";\n\t\treturn this.reservations.reserve(handle, path, this.liveWorkerPaths(entry));\n\t}\n\n\t/**\n\t * Releases the grants a worker's latest snapshot no longer claims.\n\t *\n\t * Only a fully open entry reports live writers. An entry still opening, closing or\n\t * quarantined keeps every grant until its real exit, because a worker stuck in a\n\t * syscall can still be writing a path it can no longer report.\n\t */\n\tprivate reconcile(handle: string, livePaths: readonly string[]): void {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"open\") return;\n\t\tconst sessionPath = entry.worker?.snapshot?.sessionPath;\n\t\tthis.reservations.reconcile(handle, { livePaths, sessionPath });\n\t\tif (!sessionPath) return;\n\t\tentry.reservationKey = sessionPath;\n\t\tentry.sessionPath = sessionPath;\n\t}\n\n\t/** The live view a full budget is reconciled against; absent while the entry cannot report one. */\n\tprivate liveWorkerPaths(entry: RpcSessionEntry): LiveWorkerPaths | undefined {\n\t\tconst snapshot = entry.state === \"open\" ? entry.worker?.snapshot : undefined;\n\t\tif (!snapshot) return undefined;\n\t\treturn { livePaths: snapshot.liveSessionPaths, sessionPath: snapshot.sessionPath };\n\t}\n\n\tprivate openResult(handle: string, entry: RpcSessionEntry): OpenRpcSession {\n\t\tconst state = entry.worker?.snapshot?.state;\n\t\tif (!state) throw new RpcSessionRegistryError(\"open_failed\");\n\t\treturn { sessionId: handle, durableSessionId: state.sessionId, sessionPath: state.sessionFile };\n\t}\n}\n"]}
package/docs/rpc.md CHANGED
@@ -93,15 +93,56 @@ senpi --mode rpc --listen /tmp/senpi-rpc.sock [options]
93
93
  `unix://@name` where supported by the host platform. Socket mode accepts concurrent connections while retaining one
94
94
  process-global session registry.
95
95
 
96
+ ### Session runtime (`--session-runtime in-process|worker`)
97
+
98
+ `--session-runtime` selects where a multi-session host runs its sessions:
99
+
100
+ - `in-process` - every session runs IN the host process, sharing its event loop. No worker isolate is allocated and
101
+ no session cap applies (capacity is memory, never a refusal). This is the DEFAULT for a `--listen` socket host,
102
+ i.e. for the shared host clients attach to.
103
+ - `worker` - every session owns a worker isolate, bounded by the worker capacity below. This is the DEFAULT for a
104
+ stdio host (`--multi-session` without `--listen`, and `--listen stdio://`) and for embedders, and stays available
105
+ for socket hosts that pass the flag explicitly.
106
+
107
+ An explicit flag wins over both defaults; any other value is a startup error. The flag changes only WHERE sessions
108
+ run - the wire protocol, attachment semantics and lifecycle windows are identical on both runtimes. An in-process
109
+ session is not isolated from the host: a session that blocks the event loop blocks every other session, and there is
110
+ no per-session opening deadline like the worker runtime's 30-second budget.
111
+
112
+ ### Child reaping on a socket host (`SENPI_RPC_HOST_REAPER`)
113
+
114
+ A socket host reaps the exited child processes that no thread is left to wait on. A `worker_threads` Worker owns the
115
+ exit watchers of every child it spawned, so terminating one - which is what the session-worker quarantine does - turns
116
+ its already-exited children into zombies of the HOST process, for every spawn API (`child_process.spawn`, `Bun.spawn`,
117
+ `Bun.$`) and under both the source and compiled runtimes. Children spawned from a live thread are reaped by their own
118
+ runtime and never reach the reaper.
119
+
120
+ Latency and safety: a 1-second unref'd tick enumerates the host's DIRECT children, peeks at each with
121
+ `waitid(P_PID, pid, WEXITED | WNOHANG | WNOWAIT)` - which reads the exit status without consuming it - and only
122
+ `waitpid(pid, WNOHANG)`s a pid that stayed waitable across two ticks at least 30 seconds apart (`waitpid(-1)` is never
123
+ called). So an abandoned child is claimed 30-31 seconds after it exits. That window is what keeps the reaper from
124
+ stealing a child from a live owner: a thread blocked in a synchronous call cannot reap its own child until it unblocks,
125
+ and a stolen child breaks the owner's contract (measured: `child_process` and `Bun.spawn` reject with `ECHILD`,
126
+ `Bun.$` never settles). A thread that blocks synchronously for longer than the window while awaiting a child therefore
127
+ loses that child's exit status; `SENPI_RPC_HOST_REAPER_MIN_WAITABLE_MS` raises the window (never below its 5-second
128
+ floor) and `SENPI_RPC_HOST_REAPER=0` turns reaping off entirely. The bindings need `bun:ffi`: a host running under Node
129
+ logs one warning at startup and reaps nothing. While at least ten children sit waiting, the host logs one line per
130
+ five minutes with the count and the three commonest command names.
131
+
96
132
  On Windows, listeners and clients deterministically map the logical socket path to
97
133
  `\\.\pipe\senpi-rpc-<sha256[:32]>`. Callers keep using the same `unix://` CLI value; the logical path remains the
98
134
  ownership and settings identity, and callers never construct the pipe name themselves.
99
135
 
100
136
  Socket event visibility is attachment-scoped for session content: each connection receives agent output only from sessions
101
137
  attached to that connection, with every record tagged by its routing `sessionId`. Content-free lifecycle records
102
- (`agent_start`, `agent_settled`, `agent_idle`, `session_opened`, and `session_closed`) are broadcast to all registered
103
- connections, including the supervisor's unattached observer, so host lifecycle accounting remains accurate without exposing
104
- session content. Correlated responses and dialog extension UI
138
+ (`agent_start`, `agent_settled`, `agent_idle`, `session_opened`, `session_closed`, and `session_parked`) are broadcast to all
139
+ registered connections, including the supervisor's unattached observer, so host lifecycle accounting remains accurate without
140
+ exposing session content. The one exception is `session_closed` and `session_parked` for a session opened with
141
+ `kind: "worker"`: they are delivered only to
142
+ the connections attached to that session, so machine-driven work neither appears in nor disappears from a client that never
143
+ asked for it. Every other lifecycle record, and every record of an `interactive` session, keeps today's broadcast. Host-level
144
+ records (`host_stalled`, `host_memory_pressure`) are broadcast the same way and describe the host process rather than a
145
+ session. Correlated responses and dialog extension UI
105
146
  requests (select, confirm, input, and editor) are requester-only; other extension UI state records go to the session's
106
147
  attached connections. To observe a foreign session, open it by its existing
107
148
  `sessionPath`; the host attaches that connection during `open_session`.
@@ -118,19 +159,42 @@ factory-rendered records. On a shared socket host, `rendered_components` is regi
118
159
  capable connection leaves a still-attached binding, live component renderers and footer data providers are disposed but
119
160
  their factories are retained; a later capable connection recreates and re-renders them.
120
161
 
162
+ ### Session kind and context (`open_session`)
163
+
164
+ `open_session` accepts two additive, opaque per-session fields. Both are inert inside the host: they never take part in
165
+ auth, model, extension or resource resolution, and they are never merged into the host's parsed CLI configuration.
166
+
167
+ - `kind: "interactive" | "worker"` (default `interactive`) is the session's visibility class. A `worker` session is
168
+ machine-driven work (a task child, a team member): it is omitted from `list_sessions` unless the caller passes
169
+ `include_workers: true`, and its `session_closed` record reaches only the connections attached to it. An `interactive`
170
+ session behaves exactly as before. A value that is neither is refused with `invalid_session_kind` - an unknown kind is
171
+ never downgraded to `interactive`, because that would publish machine-driven work to every client.
172
+ - `context: Record<string, string>` (default `{}`) is an opaque label map. The host stores it frozen for the session's
173
+ life, hands it to that session's extensions as `pi.sessionContext`, and republishes it only on
174
+ `list_sessions { include_workers: true }`. Caps, enforced at the boundary: at most 32 keys, every key matching
175
+ `^[a-z][a-z0-9_]*$`, every value at most 16 KiB, and at most 32 KiB of JSON in total. Anything else is refused with
176
+ `invalid_session_context: <detail>`, where the detail names the cap that was broken.
177
+
178
+ One shared host therefore loads ONE extension set and still lets an extension recognize the session it was loaded for
179
+ (`pi.sessionKind`, `pi.sessionContext`). Probe `session_kind` and `session_context` in `get_protocol_info` capabilities
180
+ before relying on either: an older host ignores both fields and lists every session.
181
+
121
182
  ### Session auto-titling
122
183
 
123
- Auto-generated session titles are on by default only for interactive launches. RPC hosts opt in with
124
- `--auto-title-sessions`:
184
+ Auto-generated session titles are on by default only for interactive launches. A shared host decides titling per
185
+ `open_session`: `auto_title: true` titles that session, `auto_title: false` leaves it untitled, and an omitted field
186
+ keeps the host-wide default (`--auto-title-sessions` or the `auto_title_sessions` client capability). Probe
187
+ `auto_title_per_session` in `get_protocol_info` before relying on the field; an older host ignores it. A non-boolean is
188
+ refused with `invalid_launch_profile`. Sessions resumed with existing context messages are never retitled.
189
+
190
+ `--auto-title-sessions` still opts every session on that host into titling when `auto_title` is omitted. It is
191
+ deprecated for shared hosts — prefer per-session `open_session.auto_title` so two clients on one daemon do not collide
192
+ over a launch-profile flag:
125
193
 
126
194
  ```bash
127
195
  senpi --mode rpc --multi-session --auto-title-sessions
128
196
  ```
129
197
 
130
- With the flag, every session the host opens (classic or multi-session) generates a title from its first user prompt and
131
- publishes it to clients through the existing `session_info_changed` event; no new command or event is involved. Sessions
132
- resumed with existing context messages are never retitled, with or without the flag.
133
-
134
198
  Startup: `senpi --mode rpc --multi-session` → NO default session is constructed (no default `AgentSessionRuntime`, no default extension/watcher load). Classic `senpi --mode rpc` is byte-identical to today. Mode is fixed at process start; there is no runtime transition.
135
199
 
136
200
  ### Interactive sessions and shared-host opt-out
@@ -187,18 +251,25 @@ hosts) sees neither variable and is unaffected. A host whose supervisor is alive
187
251
 
188
252
  ### Shared host occupancy (idle eviction, session cap, empty-host exit)
189
253
 
190
- Every CLI shared-host session owns a worker isolate and a complete runtime. Memory depends on its extensions and
191
- session contents; isolates do not provide process-fatal OOM containment. The host enforces these occupancy bounds:
254
+ On the worker runtime every CLI shared-host session owns a worker isolate and a complete runtime; on the in-process
255
+ runtime (the socket-host default) each session is a runtime in the host process. Memory depends on its extensions and
256
+ session contents; neither runtime provides process-fatal OOM containment. The host enforces these occupancy bounds:
192
257
 
193
258
  - **Idle eviction**: a session with no routed command and no session-owned work for
194
259
  `SENPI_RPC_SESSION_IDLE_EVICTION_MS` (default 30 minutes) is closed through the exact `close_session` sequence
195
260
  (abort → waitForIdle → dispose, all attachments drained, path reservation released) and every attached connection
196
- receives that handle's `session_closed` broadcast plus a final `close_session` response record. "Session-owned
261
+ receives that handle's `session_closed` broadcast plus a final `close_session` response record. A session opened with
262
+ `retain_on_disconnect` is PARKED by that same sweep instead: identical teardown, but the terminal record is
263
+ `session_parked { sessionId, sessionPath }` and there is no `close_session` response, because nothing closed the session -
264
+ the routing handle was released while the session itself stays on disk and reopens with `open_session { sessionPath }`
265
+ (as a NEW handle). A client that does not know `session_parked` ignores it and learns the handle is gone from its next
266
+ command's `unknown_session`. "Session-owned
197
267
  work" is the complete activity contract, not just a streaming turn: an agent run, a running bash command,
198
268
  background terminal jobs and any other published wake source (terminal monitors, loop-guard holds), compaction,
199
269
  and barrier-held session work all defer eviction, and the idle clock restarts when that work settles. An evicted
200
270
  session resumes like any other: the next `open_session` with the same `sessionPath` reopens it.
201
- - **Worker capacity**: at most 20 workers may be preparing, open, closing, or quarantined together. Admission beyond
271
+ - **Worker capacity** (worker runtime only; an in-process host has no session cap of any kind): at most 20 workers
272
+ may be preparing, open, closing, or quarantined together. Admission beyond
202
273
  this bound fails explicitly with `open_failed: too_many_sessions`; it never evicts another session or starts an OS
203
274
  process as a fallback. This is a new externally visible bound for CLI shared mode, which previously admitted
204
275
  unlimited logical sessions. It applies to new worker allocation, not attachments: a known canonical path or
@@ -212,7 +283,8 @@ session contents; isolates do not provide process-fatal OOM containment. The hos
212
283
  `open_session` with that `sessionPath` — from any connection — attaches to the same routing handle and returns
213
284
  `attached: true`. Retention never outranks an explicit teardown: a `close_session` from an attached connection still
214
285
  reaches zero attachments and closes the session, host shutdown closes it, and the idle-eviction window above still
215
- parks it (the file reopens by path afterwards, like any evicted session). It is also bounded by the empty-host exit
286
+ parks it — announced as `session_parked { sessionId, sessionPath }`, after which the file reopens by path like any
287
+ evicted session, and the parked session counts as gone for the empty-host exit below. It is also bounded by the empty-host exit
216
288
  and the supervisor's idle-exit window below: retention survives a client, not the host. Any attach may turn retention
217
289
  on for a live session; no attach turns it off for clients that already rely on it. Omitting the flag is byte-identical
218
290
  to the previous behavior — the session is closed with its last connection. Probe `retain_on_disconnect` in
@@ -226,8 +298,37 @@ session contents; isolates do not provide process-fatal OOM containment. The hos
226
298
  Values are positive integers; invalid values fall through to the defaults. These lifecycle windows run inside the host process,
227
299
  so they hold even for embedders and hand-started hosts that have no supervisor.
228
300
 
301
+ ### Host self-observation (event-loop stalls and memory pressure)
302
+
303
+ Every in-process session shares the host's event loop, so a session that blocks it freezes every other session and the
304
+ transport with it. A multi-session host therefore watches itself. Both observers run on unref'd timers, and both only
305
+ REPORT: nothing here aborts a turn, kills a session, or refuses an `open_session`.
306
+
307
+ - **Event-loop stalls**: a 200 ms timer measures how late it is actually invoked; that lateness is the time the loop
308
+ could serve nobody. Drift above `SENPI_RPC_LOOP_LAG_WARN_MS` (default 500) writes one stderr line per 10 seconds,
309
+ `senpi rpc host stall: event loop blocked <drift>ms (sessionId=<handle> tool=<tool>)`. Drift above
310
+ `SENPI_RPC_LOOP_LAG_ERROR_MS` (default 5000) additionally broadcasts a `host_stalled` record
311
+ (`{ type, driftMs, sessionId?, tool? }`) to every connection, like the other content-free lifecycle records.
312
+ - **Stall attribution**: each routed command is dispatched inside an `AsyncLocalStorage` scope carrying its routing
313
+ `sessionId`, and an in-process session's tool executions open a span carrying `{ sessionId, tool }` for as long as
314
+ the tool runs. A stall is blamed on the synchronous work that finished inside the measured window, or on the tool
315
+ still executing when it ended; when neither exists the record and the log line carry no session, because the stall
316
+ belongs to the host itself. Worker-runtime sessions block their own isolate rather than the host loop and
317
+ deliberately have no tool spans.
318
+ - **Memory pressure**: a 30-second sampler reads the host's RSS. Above `SENPI_RPC_HOST_RSS_WARN_MB` (default 4096) it
319
+ broadcasts `host_memory_pressure` (`{ type, rssMb, sessions }`) on every sample, writes one stderr line per five
320
+ minutes, and HALVES the idle-eviction window above while the host stays above the threshold, so idle sessions return
321
+ their memory sooner. It is released as soon as RSS falls back under the threshold. Capacity remains memory, never a
322
+ refusal: there is no admission control, no session cap, and no kill policy on this path.
323
+
324
+ `host_stalled` and `host_memory_pressure` are additive records: a client that does not know them ignores them.
325
+
229
326
  ### Worker ownership and flow control
230
327
 
328
+ This section describes the WORKER runtime (`--session-runtime worker`). An in-process host owns transport,
329
+ attachments and reservations on one event loop, so none of the cross-thread grants, credits or opening deadlines
330
+ below exist there.
331
+
231
332
  The main host owns transport, attachments and canonical reservations. Workers canonicalize caller-supplied paths;
232
333
  main does not synchronously traverse those paths. An open prepares a path, obtains the main host's exclusive grant,
233
334
  and only then constructs its session writer and runtime. A conflicting alias attaches to an open owner or fails
@@ -310,10 +411,10 @@ containment, or containment of arbitrary native code. They are not an extension
310
411
 
311
412
  | Command | Params | Success data | Notes |
312
413
  | --- | --- | --- | --- |
313
- | `get_protocol_info` | - | `{ protocolVersion: 1, serverVersion: string, capabilities: string[], mode: "classic"\|"multi" }` | Answered in BOTH modes; side-effect-free; the capability probe. Multi-session hosts include `multi_session` and `retain_on_disconnect` plus the negotiated launch capabilities. `retain_on_disconnect` is a HOST capability (a client never sends it) and is advertised only in multi-session mode, where the host owns the attachment refcount. |
314
- | `open_session` | `sessionPath?`, `cwd?`, `provider?`, `modelId?`, `thinkingLevel?`, `permissionPreset?`, `retain_on_disconnect?` (all optional; paths MUST be absolute) | `{ sessionId, state: RpcSessionState, attached?: true }` | `sessionPath` = today's `--session` semantics (open-if-exists else create persisting there, `session-manager.ts:926-940`); `provider`/`modelId` applied only on create (resume restores the session's model — mirrors `SenpiSessionRuntime.ts:198-200`); params form the immutable launch profile (D8). When the path is already held by a fully-open session, the open ATTACHES to it: same routing handle, `attached: true`, one more attachment counted; the runtime is torn down only when the last attachment closes. Idle sessions past the eviction window are closed by the host itself. `retain_on_disconnect: true` (default false) makes a dropped connection DETACH from this session instead of closing it — see "Retained sessions" below. |
315
- | `close_session` | `sessionId` | `{}` | Aborts active work, awaits agent idle + settled persistence for up to the host grace window (default 10s), then quarantines any worker that has not exited without releasing its path reservation; its response is the LAST record tagged with that handle for the first closer — no events after (test-pinned). An admitted concurrent close joins the same teardown and receives its own successful response; output saturation rejects admission with the bounded close-overflow/resync notice described above. |
316
- | `list_sessions` | - | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status, attachments }] }` | Includes `opening`/`closing` entries. Internally quarantined workers remain externally `closing` until exit. `attachments` is the session's live client attachment count; `0` on an `open` row is a retained session with no client attached. |
414
+ | `get_protocol_info` | - | `{ protocolVersion: 1, serverVersion: string, capabilities: string[], mode: "classic"\|"multi" }` | Answered in BOTH modes; side-effect-free; the capability probe. Multi-session hosts include `multi_session`, `retain_on_disconnect`, `session_kind`, `session_context` and `auto_title_per_session` plus the negotiated launch capabilities. Those are HOST capabilities (a client never sends them) and are advertised only in multi-session mode, where the host owns the attachment refcount and the per-session launch profile. |
415
+ | `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?: true }` | `sessionPath` = today's `--session` semantics (open-if-exists else create persisting there, `session-manager.ts:926-940`); `provider`/`modelId` applied only on create (resume restores the session's model — mirrors `SenpiSessionRuntime.ts:198-200`); params form the immutable launch profile (D8). When the path is already held by a fully-open session, the open ATTACHES to it: same routing handle, `attached: true`, one more attachment counted; the runtime is torn down only when the last attachment closes. Idle sessions past the eviction window are closed by the host itself. `retain_on_disconnect: true` (default false) makes a dropped connection DETACH from this session instead of closing it — see "Retained sessions" below. `kind` (default `interactive`) and the opaque `context` map are described under "Session kind and context" above; both are stored frozen for the session's life and never influence auth, model or resource resolution. |
416
+ | `close_session` | `sessionId` | `{}` | Refused with `unknown_session` when the requesting connection never attached to that handle (a close releases the CALLER's attachment, and `list_sessions` publishes every handle). Otherwise aborts active work, awaits agent idle + settled persistence for up to the host grace window (default 10s), then quarantines any worker that has not exited without releasing its path reservation; its response is the LAST record tagged with that handle for the first closer — no events after (test-pinned). An admitted concurrent close joins the same teardown and receives its own successful response; output saturation rejects admission with the bounded close-overflow/resync notice described above. |
417
+ | `list_sessions` | `include_workers?` (default false) | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status, attachments, kind, context? }] }` | Includes `opening`/`closing` entries. Internally quarantined workers remain externally `closing` until exit. `attachments` is the session's live client attachment count; `0` on an `open` row is a retained session with no client attached. Every row carries `kind`. Rows with `kind: "worker"` are omitted unless `include_workers: true`, and `context` is published ONLY on that listing — a default listing carries no `context` at all. |
317
418
  | every existing command | + `sessionId` (REQUIRED in multi mode) | unchanged | Routed to that session. |
318
419
 
319
420
  ### Identities (D6)
@@ -326,12 +427,15 @@ In the response `error` field, machine-matchable:
326
427
 
327
428
  - `unknown_session`
328
429
  - `session_closing`
329
- - `session_path_in_use` (path held by an opening, closing, or quarantined owner; a fully-open current owner is attached instead, and a path a live owner has superseded is released rather than held)
430
+ - `session_path_in_use` (path held by an opening or quarantined owner; a fully-open current owner is attached instead, an owner whose teardown is already in flight is waited out on the in-process runtime, and a path a live owner has superseded is released rather than held)
330
431
  - `session_reservation_limit` (this worker already holds 64 live session paths; the open or session replacement was refused without disturbing the existing session)
331
432
  - `missing_session_id` (session-scoped command without `sessionId` in multi mode)
332
433
  - `multi_session_disabled` (`open_session` in classic mode)
333
434
  - `invalid_path` (relative `sessionPath`/`cwd`)
334
435
  - `open_failed: <detail>`
436
+ - `invalid_session_context: <detail>` (`open_session.context` past a documented cap: more than 32 keys, a key that does not match `^[a-z][a-z0-9_]*$`, a non-string or >16 KiB value, or more than 32 KiB of JSON in total; the detail names the cap and its byte budget)
437
+ - `invalid_session_kind: <detail>` (`open_session.kind` other than `interactive` or `worker`)
438
+ - `invalid_launch_profile: <detail>` (`open_session.auto_title` present but not a boolean)
335
439
  - `media_not_found` (`get_media` for an unknown `toolCallId`, or a `contentIndex` that does not point at an image block)
336
440
 
337
441
  ### Tagging
@@ -344,7 +448,7 @@ Strict FIFO per session; one total stdout order; cross-session order unspecified
344
448
 
345
449
  ### Duplicate/idempotency
346
450
 
347
- Duplicate `open_session` while a path reservation is held by a fully-open session → ATTACH (`attached: true`, same handle), including when that session is retained with zero attachments; while held by an `opening`/`closing` entry (including internal quarantine) → `session_path_in_use`. A path whose owner has already replaced it with another session file is no longer held: that open allocates a new worker and resumes the file. `close_session` releases one attachment; the runtime is disposed only when the last attachment closes. A close for an entry already `closing` joins its in-flight teardown. `close_session` on unknown/already-closed → `unknown_session` error. The grace window is configurable by the host through `SENPI_RPC_CLOSE_GRACE_MS`. Request `id`s are client-owned; the server echoes them without dedup.
451
+ Duplicate `open_session` while a path reservation is held by a fully-open session → ATTACH (`attached: true`, same handle), including when that session is retained with zero attachments; while held by an `opening` entry (or an internally quarantined one) → `session_path_in_use`. A `closing` entry is a session that is ENDING, not one in use: on the in-process runtime (the `--listen` socket host default) the open WAITS for that teardown - bounded by the close grace window that bounds the teardown itself - and then opens the file fresh, so reopening a path after a close never depends on how long disposal takes. The worker runtime still answers `session_path_in_use` there, because a worker's teardown ends with an OS thread exit that no host deadline bounds. A path whose owner has already replaced it with another session file is no longer held: that open allocates a new worker and resumes the file. `close_session` releases one attachment; the runtime is disposed only when the last attachment closes. A close for an entry already `closing` joins its in-flight teardown. `close_session` on unknown/already-closed → `unknown_session` error, and so is a `close_session` from a connection that never attached to that handle — it releases nothing and leaves the session untouched. The grace window is configurable by the host through `SENPI_RPC_CLOSE_GRACE_MS`. Request `id`s are client-owned; the server echoes them without dedup.
348
452
 
349
453
  ## Protocol Overview
350
454
 
@@ -1473,6 +1577,8 @@ Events are streamed to stdout as JSON lines during agent operation. Events do no
1473
1577
  | `loaded_surfaces_changed` | Loaded skills, extensions, or MCP inventory changed; re-read `get_commands` and `get_loaded_surfaces` |
1474
1578
  | `model_changed` | Active model changed (any source), with the thinking level in force afterwards |
1475
1579
  | `service_tier_changed` | Effective service tier or fast-mode state changed |
1580
+ | `host_stalled` | Multi-session host: the event loop was blocked past `SENPI_RPC_LOOP_LAG_ERROR_MS`, with the drift and the session/tool blamed for it |
1581
+ | `host_memory_pressure` | Multi-session host: RSS is above `SENPI_RPC_HOST_RSS_WARN_MB`, with the live session count |
1476
1582
 
1477
1583
  Event types are additive: a client that does not recognise a type must ignore that record rather than fail. `model_changed`
1478
1584
  and `service_tier_changed` were added after the initial protocol and are safe to ignore.
@@ -12,6 +12,30 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## [2026.9.17-4] - 2026-09-17
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ ### Changed
22
+
23
+ ### Fixed
24
+
25
+ ### Removed
26
+
27
+ ## [2026.9.17-3] - 2026-09-17
28
+
29
+ ### Breaking Changes
30
+
31
+ ### Added
32
+
33
+ ### Changed
34
+
35
+ ### Fixed
36
+
37
+ ### Removed
38
+
15
39
  ## [2026.9.17-2] - 2026-09-17
16
40
 
17
41
  ### Breaking Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-codemode",
3
- "version": "2026.9.17-2",
3
+ "version": "2026.9.17-4",
4
4
  "private": true,
5
5
  "description": "Source-only senpi extension package for codemode evaluation tools",
6
6
  "type": "module",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/parser": "8.0.4",
34
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.17-2",
34
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.17-4",
35
35
  "typebox": "1.3.27"
36
36
  },
37
37
  "peerDependencies": {
38
- "@code-yeongyu/senpi": "2026.9.17-2"
38
+ "@code-yeongyu/senpi": "2026.9.17-4"
39
39
  },
40
40
  "devDependencies": {
41
- "@code-yeongyu/senpi": "2026.9.17-2"
41
+ "@code-yeongyu/senpi": "2026.9.17-4"
42
42
  },
43
43
  "keywords": [
44
44
  "senpi",
@@ -0,0 +1,22 @@
1
+ {
2
+ "note": "Vendored WebAssembly artifacts for the structural read fold-boundary engine (#1685). Shipped grammars are limited to languages the frozen read selection binds to `wasm`; every other evaluated grammar is resolved from the pinned measurement dependency at bake-off time only.",
3
+ "runtime": {
4
+ "file": "web-tree-sitter.wasm",
5
+ "package": "web-tree-sitter",
6
+ "version": "0.27.0",
7
+ "source": "web-tree-sitter.wasm",
8
+ "license": "MIT",
9
+ "sha256": "c03bccdc3b448a32848f5ae327e209c982bbb0840d43eec8bc2d5759544a1ed3"
10
+ },
11
+ "grammars": [
12
+ {
13
+ "language": "js",
14
+ "file": "javascript.wasm",
15
+ "package": "@vscode/tree-sitter-wasm",
16
+ "version": "0.3.1",
17
+ "source": "wasm/tree-sitter-javascript.wasm",
18
+ "license": "MIT",
19
+ "sha256": "5fb488d0cabb4775a594bab85682de5ad6ce83c0d6ac997a9f82dd084d571240"
20
+ }
21
+ ]
22
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-agent-core",
3
- "version": "2026.9.17-2",
3
+ "version": "2026.9.17-4",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -57,8 +57,8 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@earendil-works/chord": "0.85.1",
60
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.17-2",
61
- "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.9.17-2",
60
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.17-4",
61
+ "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.9.17-4",
62
62
  "diff": "9.0.0",
63
63
  "ignore": "7.0.8",
64
64
  "typebox": "1.3.27",
@@ -1 +1 @@
1
- {"schemaVersion":3,"generatedAt":"2026-09-17T15:27:03.026Z","structureHash":"b45f6a4319c562112fcf6b48aede79217ff03ab1c9477dce1b934e5701d3471b","files":{"alibaba-token-plan.json":"3a9c1be76d47459371e9fa2feeffc31e7edbbfec65fa9cc41236988efc4cf6d9","amazon-bedrock.json":"d82a76308591b1777c351a22f1bd3e4f332a50464743dfc3610b250e265e531d","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"e9d883ee35d94dba963320b5496bd7dd368d226cbafcf134bfec66a0a24b3b7f","azure-openai-responses.json":"9d2137c68fbf7012872296a02a13a138f7d5246dc09f2ca79e34e6a875b11488","baseten.json":"d155c434294b5167244cffb6dea6793f9669e91e8ab65b564f9510d81b330e37","cerebras.json":"9eaa554e1b02f3665f8f63e6432d253bf81351af7c72001054dd8108aa528a52","cloudflare-ai-gateway.json":"244d98311e81b5f33fa736688d135b29add6a8acee466aa3a5988ac5b022d1eb","cloudflare-workers-ai.json":"07ef63208ff7517fd1a80962f18143e21de399640423329490b157f459ccf995","deepseek.json":"b5f9693ec641e9a957dc5f7a22042b3bb928bac3d7268406619b6f18e21c4b83","fireworks.json":"6283651d25a8861e7d42fe2bdb1cb7dd80802811dfaf61e40c11cc813408c294","github-copilot.json":"2628f6583c2509e1f17412e6a8a8f12cf20750cc8cb82ab4273c63155cee4746","google-vertex.json":"e1631109172dc1f7d7977570420a5bb86258bdd1088427e244a2c51545c4f24d","google.json":"7619bf03edd2a7acb06a2274a14b13c3a61354288abe029a758401d4de36a8fd","groq.json":"e4728fd72e358cd8f25e9a518e9b49a521ef44523d3debe38a7db9e0663c4077","huggingface.json":"a488b6f175b382277ccf7d487f877ef0c698994576bb55d2410838bf9c8c7c41","kimi-coding.json":"2600a474d5a5ab9790dbf9a68701823658bb79bd44554e75c1e869641165e7a3","minimax-cn.json":"65d37e55a6d9585855f94b3fb7739308d107fe248ebd9e1001d1c5d4606ad2c4","minimax.json":"c7dc5765995ae77242916430929c7cc9a782589f7e483e13f7e01663190d028e","mistral.json":"e3a109306644bf2f2fa38fece50b2d3ce1dbe3b87b1f1b9e2d70cce7eb5c0ea1","moonshotai-cn.json":"c4e1801b5dfd61bebcaa33cbfc5ed0c69df14a3bee37da218a558668d817864e","moonshotai.json":"3dab637e7e2648792c786157f85f29026b93393f7098b77593c1180928d371c9","nvidia.json":"2ff6862206269af88a694e627c4b54753055357710adaf49ac8518d102c17407","openai-codex.json":"5b308f19ee369ba78113998361d8f8e6c160690b29947e6f07ccbc12b46289e6","openai.json":"203a1d6bf61178268edf3d3f0ad4a6408eded401c4472bda4ac0ec73142f38ce","opencode-go.json":"a2445f4b48604e06603b2ff1bbb8bd6a199c7a302e996daac599ab3470682e5d","opencode.json":"0ba750d58cbfa724a72e6599554564a0a9d5896754644e463857657ca13dcfcd","opengateway.json":"7a4c98061b7b84c476ba70d6f597019ef53c02c0135b9d8a7507e2c30905c07d","openrouter.json":"1253907ebed6559aa913993f38dad7a47ba408852f6db7bde4a3c8bbf4226aeb","qwen-token-plan-cn.json":"4bf520ed38e5c3045680d2ec2816fa8a69079dbe97f7b929767a63172288da6b","qwen-token-plan-individual.json":"eb040e78595853e980011308b1bf9caacae6dc8a91abbac5ffebd402515dd2a6","qwen-token-plan.json":"a5c67213745329ec3ba79f712f31c1c32a781d7ffb8c04f9819f36c27672531f","together.json":"927c707d06f2236cdab13f14c870fb58bce0614ba7287bbcd57cc9fd66d191ed","venice.json":"d22c3452b1cc969d188ff0307afae3031d610257cdd4e1fecaf2d210406ae82a","vercel-ai-gateway.json":"07eb65d15d0f9579a490bed0d79cb4edaed021adde04187bc50de77e86b356ad","xai.json":"5947370c4a40ad85605f1a17ae09d4d6dd4f9ab120d14fabfb4c5a08a75e6f7e","xiaomi-token-plan-ams.json":"568b9992cf320536a65826e26a414afa5c0d17f083a01af4bd96658d9dd3e705","xiaomi-token-plan-cn.json":"c423857d0bbb0b126394eaf1ebb2a91bf2d1193cc5a4fe77843ff0f4536a0a80","xiaomi-token-plan-sgp.json":"008f1eb41037e93c5ae478f12815cd67bac1978f131ffefa602775bb60b63fea","xiaomi.json":"37acf451bb4364bdca2ecea6b7d962590d9974a87e80cfe34bb800be6a95c13b","zai-coding-cn.json":"d3c969020a7ab978497837a3301c7bca364d704082832221cfe61e6596333e56","zai.json":"f42790c77fb4681a656897a9d860b939916c0ddf979a5f16856bce9573cdf64e"}}
1
+ {"schemaVersion":3,"generatedAt":"2026-09-17T23:19:41.383Z","structureHash":"2e5179003cedb36c3478b629cfbb6fcca2af5c5c6d607cb45094f0acfde4a428","files":{"alibaba-token-plan.json":"3a9c1be76d47459371e9fa2feeffc31e7edbbfec65fa9cc41236988efc4cf6d9","amazon-bedrock.json":"d82a76308591b1777c351a22f1bd3e4f332a50464743dfc3610b250e265e531d","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"e9d883ee35d94dba963320b5496bd7dd368d226cbafcf134bfec66a0a24b3b7f","azure-openai-responses.json":"9d2137c68fbf7012872296a02a13a138f7d5246dc09f2ca79e34e6a875b11488","baseten.json":"d155c434294b5167244cffb6dea6793f9669e91e8ab65b564f9510d81b330e37","cerebras.json":"9eaa554e1b02f3665f8f63e6432d253bf81351af7c72001054dd8108aa528a52","cloudflare-ai-gateway.json":"b62b46dbb24c9a5cd0c10ba5adb58aedc2a1c0616459f36b51e07bb15416e584","cloudflare-workers-ai.json":"07ef63208ff7517fd1a80962f18143e21de399640423329490b157f459ccf995","deepseek.json":"b5f9693ec641e9a957dc5f7a22042b3bb928bac3d7268406619b6f18e21c4b83","fireworks.json":"6283651d25a8861e7d42fe2bdb1cb7dd80802811dfaf61e40c11cc813408c294","github-copilot.json":"2628f6583c2509e1f17412e6a8a8f12cf20750cc8cb82ab4273c63155cee4746","google-vertex.json":"e1631109172dc1f7d7977570420a5bb86258bdd1088427e244a2c51545c4f24d","google.json":"7619bf03edd2a7acb06a2274a14b13c3a61354288abe029a758401d4de36a8fd","groq.json":"e4728fd72e358cd8f25e9a518e9b49a521ef44523d3debe38a7db9e0663c4077","huggingface.json":"a488b6f175b382277ccf7d487f877ef0c698994576bb55d2410838bf9c8c7c41","kimi-coding.json":"2600a474d5a5ab9790dbf9a68701823658bb79bd44554e75c1e869641165e7a3","minimax-cn.json":"65d37e55a6d9585855f94b3fb7739308d107fe248ebd9e1001d1c5d4606ad2c4","minimax.json":"c7dc5765995ae77242916430929c7cc9a782589f7e483e13f7e01663190d028e","mistral.json":"e3a109306644bf2f2fa38fece50b2d3ce1dbe3b87b1f1b9e2d70cce7eb5c0ea1","moonshotai-cn.json":"c4e1801b5dfd61bebcaa33cbfc5ed0c69df14a3bee37da218a558668d817864e","moonshotai.json":"3dab637e7e2648792c786157f85f29026b93393f7098b77593c1180928d371c9","nvidia.json":"2ff6862206269af88a694e627c4b54753055357710adaf49ac8518d102c17407","openai-codex.json":"5b308f19ee369ba78113998361d8f8e6c160690b29947e6f07ccbc12b46289e6","openai.json":"203a1d6bf61178268edf3d3f0ad4a6408eded401c4472bda4ac0ec73142f38ce","opencode-go.json":"a2445f4b48604e06603b2ff1bbb8bd6a199c7a302e996daac599ab3470682e5d","opencode.json":"0ba750d58cbfa724a72e6599554564a0a9d5896754644e463857657ca13dcfcd","opengateway.json":"7a4c98061b7b84c476ba70d6f597019ef53c02c0135b9d8a7507e2c30905c07d","openrouter.json":"ad2289884ca4aa5e66a0fffc4b8853c5deb7e6691f03c61dffac6d9a7513bc2a","qwen-token-plan-cn.json":"4bf520ed38e5c3045680d2ec2816fa8a69079dbe97f7b929767a63172288da6b","qwen-token-plan-individual.json":"eb040e78595853e980011308b1bf9caacae6dc8a91abbac5ffebd402515dd2a6","qwen-token-plan.json":"a5c67213745329ec3ba79f712f31c1c32a781d7ffb8c04f9819f36c27672531f","together.json":"927c707d06f2236cdab13f14c870fb58bce0614ba7287bbcd57cc9fd66d191ed","venice.json":"d22c3452b1cc969d188ff0307afae3031d610257cdd4e1fecaf2d210406ae82a","vercel-ai-gateway.json":"30de1ec1b71d5b9cea3e5f3802b515db5e4a74cec3a4c28addb23eee2ceedd7d","xai.json":"5947370c4a40ad85605f1a17ae09d4d6dd4f9ab120d14fabfb4c5a08a75e6f7e","xiaomi-token-plan-ams.json":"568b9992cf320536a65826e26a414afa5c0d17f083a01af4bd96658d9dd3e705","xiaomi-token-plan-cn.json":"c423857d0bbb0b126394eaf1ebb2a91bf2d1193cc5a4fe77843ff0f4536a0a80","xiaomi-token-plan-sgp.json":"008f1eb41037e93c5ae478f12815cd67bac1978f131ffefa602775bb60b63fea","xiaomi.json":"37acf451bb4364bdca2ecea6b7d962590d9974a87e80cfe34bb800be6a95c13b","zai-coding-cn.json":"c68da532c6e8fa126372e743a2474d9f483ac3260bf9b1fad3ee40183957e141","zai.json":"f42790c77fb4681a656897a9d860b939916c0ddf979a5f16856bce9573cdf64e"}}