@humain/terminal 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/bundle/chunks/{anthropic-messages-XULXUBIG.js → anthropic-messages-QFCEKGI3.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-JEG2XOYC.js → azure-openai-responses-G4ZMHV37.js} +1 -1
  4. package/dist/bundle/chunks/chunk-7T6XCLJF.js +22 -0
  5. package/dist/bundle/chunks/chunk-D6HHRSB5.js +103 -0
  6. package/dist/bundle/chunks/chunk-EY4DWHQU.js +2 -0
  7. package/dist/bundle/chunks/{chunk-RM336IEI.js → chunk-I47ZWR55.js} +486 -509
  8. package/dist/bundle/chunks/{chunk-JUPSJTFQ.js → chunk-K4JAZYQH.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-HPPQHK3J.js → chunk-KKIB2TVR.js} +1 -1
  10. package/dist/bundle/chunks/chunk-LI2YVPWP.js +2 -0
  11. package/dist/bundle/chunks/{chunk-BZQ53VGE.js → chunk-XSR434CO.js} +1 -1
  12. package/dist/bundle/chunks/compat-QCV26HNS.js +2 -0
  13. package/dist/bundle/chunks/dist-PRPIUY3U.js +2 -0
  14. package/dist/bundle/chunks/esm-E7UVEYTO.js +4 -0
  15. package/dist/bundle/chunks/{extract-TRW5FBY6.js → extract-CTIFQZDJ.js} +15 -14
  16. package/dist/bundle/chunks/{google-generative-ai-OX6VSCA6.js → google-generative-ai-RSUU4MWO.js} +1 -1
  17. package/dist/bundle/chunks/{google-vertex-GW76GSS2.js → google-vertex-CKQPOITO.js} +1 -1
  18. package/dist/bundle/chunks/host-WP3MVKS2.js +2 -0
  19. package/dist/bundle/chunks/{node-KOIP55YZ.js → node-NF43OPII.js} +1 -1
  20. package/dist/bundle/chunks/{node-XY3CBY3C.js → node-UMFM7CDZ.js} +1 -1
  21. package/dist/bundle/chunks/{openai-codex-responses-NPLWP6ZC.js → openai-codex-responses-S34V5ZSD.js} +1 -1
  22. package/dist/bundle/chunks/{openai-completions-OT2GTJKC.js → openai-completions-T2IGVUEI.js} +1 -1
  23. package/dist/bundle/chunks/{openai-responses-5A6CR7GI.js → openai-responses-GYZODCT3.js} +1 -1
  24. package/dist/bundle/chunks/readability-LAGF34IB.js +3 -0
  25. package/dist/bundle/chunks/turndown.cjs-HRMZVRUL.js +2 -0
  26. package/dist/bundle/cli.js +1 -1
  27. package/dist/bundle/index.js +1 -1
  28. package/dist/bundle/rpc-entry.js +1 -1
  29. package/dist/cli.js +1 -5
  30. package/dist/core/agent-session.js +2 -2
  31. package/dist/core/agent-session.js.map +1 -1
  32. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  33. package/dist/core/tools/file-mutation-queue.js +21 -8
  34. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  35. package/dist/core/tools/subagent-env.d.ts +18 -0
  36. package/dist/core/tools/subagent-env.d.ts.map +1 -0
  37. package/dist/core/tools/subagent-env.js +43 -0
  38. package/dist/core/tools/subagent-env.js.map +1 -0
  39. package/dist/core/tools/subagent-scheduler.d.ts +31 -0
  40. package/dist/core/tools/subagent-scheduler.d.ts.map +1 -0
  41. package/dist/core/tools/subagent-scheduler.js +203 -0
  42. package/dist/core/tools/subagent-scheduler.js.map +1 -0
  43. package/dist/core/tools/subagent.d.ts +83 -3
  44. package/dist/core/tools/subagent.d.ts.map +1 -1
  45. package/dist/core/tools/subagent.js +214 -76
  46. package/dist/core/tools/subagent.js.map +1 -1
  47. package/dist/humain/index.d.ts.map +1 -1
  48. package/dist/humain/index.js +2 -0
  49. package/dist/humain/index.js.map +1 -1
  50. package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +78 -0
  51. package/dist/humain/mcp-adapter/vendor/README.md +125 -19
  52. package/dist/humain/mcp-adapter/vendor/agent-plugin-loader.ts +69 -30
  53. package/dist/humain/mcp-adapter/vendor/agent-plugin-provenance.ts +36 -0
  54. package/dist/humain/mcp-adapter/vendor/claude-plugin-loader.ts +365 -0
  55. package/dist/humain/mcp-adapter/vendor/commands.ts +13 -15
  56. package/dist/humain/mcp-adapter/vendor/config.ts +198 -30
  57. package/dist/humain/mcp-adapter/vendor/consent-manager.ts +40 -9
  58. package/dist/humain/mcp-adapter/vendor/direct-tool-surface.ts +250 -0
  59. package/dist/humain/mcp-adapter/vendor/direct-tools.ts +9 -228
  60. package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js +74 -32
  61. package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js.map +1 -1
  62. package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-provenance.d.ts +1 -0
  63. package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-provenance.js +31 -0
  64. package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-provenance.js.map +1 -0
  65. package/dist/humain/mcp-adapter/vendor/dist/claude-plugin-loader.d.ts +9 -0
  66. package/dist/humain/mcp-adapter/vendor/dist/claude-plugin-loader.js +362 -0
  67. package/dist/humain/mcp-adapter/vendor/dist/claude-plugin-loader.js.map +1 -0
  68. package/dist/humain/mcp-adapter/vendor/dist/config.d.ts +3 -1
  69. package/dist/humain/mcp-adapter/vendor/dist/config.js +189 -27
  70. package/dist/humain/mcp-adapter/vendor/dist/config.js.map +1 -1
  71. package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js +7 -16
  72. package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js.map +1 -1
  73. package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js +5 -17
  74. package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js.map +1 -1
  75. package/dist/humain/mcp-adapter/vendor/dist/types.d.ts +30 -4
  76. package/dist/humain/mcp-adapter/vendor/dist/types.js +26 -0
  77. package/dist/humain/mcp-adapter/vendor/dist/types.js.map +1 -1
  78. package/dist/humain/mcp-adapter/vendor/dist/utils.d.ts +6 -0
  79. package/dist/humain/mcp-adapter/vendor/dist/utils.js +65 -6
  80. package/dist/humain/mcp-adapter/vendor/dist/utils.js.map +1 -1
  81. package/dist/humain/mcp-adapter/vendor/host-html-template.ts +20 -19
  82. package/dist/humain/mcp-adapter/vendor/http-ca.ts +84 -0
  83. package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +37102 -15103
  84. package/dist/humain/mcp-adapter/vendor/index.ts +828 -164
  85. package/dist/humain/mcp-adapter/vendor/init.ts +48 -10
  86. package/dist/humain/mcp-adapter/vendor/lazy-loader.ts +7 -0
  87. package/dist/humain/mcp-adapter/vendor/mcp-auth-fetch.ts +113 -0
  88. package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +256 -77
  89. package/dist/humain/mcp-adapter/vendor/mcp-auth.ts +316 -54
  90. package/dist/humain/mcp-adapter/vendor/mcp-code.ts +45 -18
  91. package/dist/humain/mcp-adapter/vendor/mcp-install.ts +60 -0
  92. package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +70 -6
  93. package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +53 -42
  94. package/dist/humain/mcp-adapter/vendor/mcp-panel-theme.ts +105 -0
  95. package/dist/humain/mcp-adapter/vendor/mcp-panel.ts +366 -331
  96. package/dist/humain/mcp-adapter/vendor/mcp-references.ts +9 -14
  97. package/dist/humain/mcp-adapter/vendor/mcp-script-worker.mjs +3 -1
  98. package/dist/humain/mcp-adapter/vendor/mcp-setup-panel.ts +383 -341
  99. package/dist/humain/mcp-adapter/vendor/mcp-status.ts +5 -0
  100. package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +7 -16
  101. package/dist/humain/mcp-adapter/vendor/namespace-tools.ts +61 -3
  102. package/dist/humain/mcp-adapter/vendor/oauth.ts +6 -2
  103. package/dist/humain/mcp-adapter/vendor/package-mcp-loader.ts +5 -17
  104. package/dist/humain/mcp-adapter/vendor/package.json +13 -3
  105. package/dist/humain/mcp-adapter/vendor/prompts.ts +35 -3
  106. package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +108 -7
  107. package/dist/humain/mcp-adapter/vendor/runtime-owner.ts +16 -1
  108. package/dist/humain/mcp-adapter/vendor/sampling-handler.ts +9 -32
  109. package/dist/humain/mcp-adapter/vendor/sandbox-proxy-template.ts +20 -93
  110. package/dist/humain/mcp-adapter/vendor/server-manager.ts +227 -40
  111. package/dist/humain/mcp-adapter/vendor/session-approvals.ts +187 -0
  112. package/dist/humain/mcp-adapter/vendor/skills/mcp-scripting/SKILL.md +9 -1
  113. package/dist/humain/mcp-adapter/vendor/state.ts +10 -1
  114. package/dist/humain/mcp-adapter/vendor/tool-approval.ts +10 -22
  115. package/dist/humain/mcp-adapter/vendor/tool-metadata.ts +14 -0
  116. package/dist/humain/mcp-adapter/vendor/types.ts +57 -4
  117. package/dist/humain/mcp-adapter/vendor/ui-server.ts +36 -28
  118. package/dist/humain/mcp-adapter/vendor/utils.ts +64 -6
  119. package/dist/humain/node-http.d.ts +3 -0
  120. package/dist/humain/node-http.d.ts.map +1 -0
  121. package/dist/humain/node-http.js +119 -0
  122. package/dist/humain/node-http.js.map +1 -0
  123. package/dist/humain/node-provider.d.ts +4 -0
  124. package/dist/humain/node-provider.d.ts.map +1 -0
  125. package/dist/humain/node-provider.js +359 -0
  126. package/dist/humain/node-provider.js.map +1 -0
  127. package/dist/humain/web-access/vendor/abortable.d.ts +3 -0
  128. package/dist/humain/web-access/vendor/abortable.d.ts.map +1 -0
  129. package/dist/humain/web-access/vendor/abortable.js +22 -0
  130. package/dist/humain/web-access/vendor/abortable.js.map +1 -0
  131. package/dist/humain/web-access/vendor/crawl4ai.d.ts +9 -0
  132. package/dist/humain/web-access/vendor/crawl4ai.d.ts.map +1 -0
  133. package/dist/humain/web-access/vendor/crawl4ai.js +187 -0
  134. package/dist/humain/web-access/vendor/crawl4ai.js.map +1 -0
  135. package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
  136. package/dist/humain/web-access/vendor/credential-source.js +1 -0
  137. package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
  138. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  139. package/dist/humain/web-access/vendor/curator-page.js +20 -2
  140. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  141. package/dist/humain/web-access/vendor/curator-run.d.ts +11 -0
  142. package/dist/humain/web-access/vendor/curator-run.d.ts.map +1 -0
  143. package/dist/humain/web-access/vendor/curator-run.js +38 -0
  144. package/dist/humain/web-access/vendor/curator-run.js.map +1 -0
  145. package/dist/humain/web-access/vendor/curator-server.d.ts +1 -0
  146. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  147. package/dist/humain/web-access/vendor/curator-server.js +2 -0
  148. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  149. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  150. package/dist/humain/web-access/vendor/duckduckgo.js +1 -1
  151. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  152. package/dist/humain/web-access/vendor/extract.d.ts +1 -1
  153. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  154. package/dist/humain/web-access/vendor/extract.js +58 -11
  155. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  156. package/dist/humain/web-access/vendor/fetch-params.js +1 -1
  157. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
  158. package/dist/humain/web-access/vendor/gemini-search.d.ts +2 -2
  159. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  160. package/dist/humain/web-access/vendor/gemini-search.js +12 -5
  161. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  162. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  163. package/dist/humain/web-access/vendor/index.js +23 -19
  164. package/dist/humain/web-access/vendor/index.js.map +1 -1
  165. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
  166. package/dist/humain/web-access/vendor/openai-search.js +40 -14
  167. package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
  168. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  169. package/dist/humain/web-access/vendor/page-query.js +6 -2
  170. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  171. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  172. package/dist/humain/web-access/vendor/query-rewrite.js +6 -2
  173. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  174. package/dist/humain/web-access/vendor/serpapi.d.ts +4 -0
  175. package/dist/humain/web-access/vendor/serpapi.d.ts.map +1 -0
  176. package/dist/humain/web-access/vendor/serpapi.js +215 -0
  177. package/dist/humain/web-access/vendor/serpapi.js.map +1 -0
  178. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  179. package/dist/humain/web-access/vendor/ssrf-protection.js +5 -1
  180. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  181. package/dist/humain/web-access/vendor/storage.d.ts.map +1 -1
  182. package/dist/humain/web-access/vendor/storage.js +9 -0
  183. package/dist/humain/web-access/vendor/storage.js.map +1 -1
  184. package/dist/humain/web-access/vendor/summary-review.d.ts +1 -1
  185. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  186. package/dist/humain/web-access/vendor/summary-review.js +35 -24
  187. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  188. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  189. package/dist/humain/web-access/vendor/utils.js +5 -3
  190. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  191. package/dist/index.js +1 -51
  192. package/dist/main.d.ts.map +1 -1
  193. package/dist/main.js +16 -0
  194. package/dist/main.js.map +1 -1
  195. package/dist/modes/interactive/components/login-dialog.d.ts +7 -2
  196. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  197. package/dist/modes/interactive/components/login-dialog.js +46 -21
  198. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  199. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  200. package/dist/modes/interactive/interactive-mode.js +10 -13
  201. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  202. package/dist/modes/json-event.d.ts +8 -0
  203. package/dist/modes/json-event.d.ts.map +1 -1
  204. package/dist/modes/json-event.js +17 -0
  205. package/dist/modes/json-event.js.map +1 -1
  206. package/dist/modes/print-mode.d.ts.map +1 -1
  207. package/dist/modes/print-mode.js +3 -2
  208. package/dist/modes/print-mode.js.map +1 -1
  209. package/docs/environment-variables.md +8 -0
  210. package/docs/humain-terminal.md +6 -0
  211. package/docs/json.md +16 -0
  212. package/docs/providers.md +19 -1
  213. package/npm-shrinkwrap.json +6 -6
  214. package/package.json +2 -2
  215. package/src/humain/mcp-adapter/UPSTREAM.md +56 -7
  216. package/src/humain/mcp-adapter/upstream.json +6 -4
  217. package/src/humain/mcp-adapter/vendor/CHANGELOG.md +78 -0
  218. package/src/humain/web-access/UPSTREAM.md +18 -8
  219. package/src/humain/web-access/upstream.json +6 -5
  220. package/dist/bundle/chunks/chunk-2LC3S3VV.js +0 -105
@@ -30,5 +30,13 @@ export type JsonAgentSessionEvent = Exclude<AgentSessionEvent, {
30
30
  */
31
31
  export declare function toJsonEvent(event: MessageUpdateEvent): JsonMessageUpdateEvent;
32
32
  export declare function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent;
33
+ /** Identity a subagent child stamps on every wire event so a consumer can rebuild the tree. */
34
+ export interface OrchestrationEnvelope {
35
+ taskId?: string;
36
+ parentTaskId?: string;
37
+ depth?: number;
38
+ }
39
+ export declare function orchestrationEnvelope(env?: NodeJS.ProcessEnv): OrchestrationEnvelope;
40
+ export declare function withEnvelope<T extends object>(event: T, envelope: OrchestrationEnvelope): T & OrchestrationEnvelope;
33
41
  export {};
34
42
  //# sourceMappingURL=json-event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-event.d.ts","sourceRoot":"","sources":["../../src/modes/json-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,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AAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAG,CAAC,GAAG,qBAAqB,CAEnH"}
@@ -1,3 +1,4 @@
1
+ import { currentSubagentDepth, currentTaskId, PARENT_TASK_ID_ENV } from "../core/tools/subagent-env.js";
1
2
  function toJsonAssistantMessageEvent(event) {
2
3
  if (event.type === "toolcall_start") {
3
4
  const toolCall = event.partial.content[event.contentIndex];
@@ -26,4 +27,20 @@ export function toJsonEvent(event) {
26
27
  assistantMessageEvent: toJsonAssistantMessageEvent(event.assistantMessageEvent),
27
28
  };
28
29
  }
30
+ export function orchestrationEnvelope(env = process.env) {
31
+ const taskId = currentTaskId(env);
32
+ const parentTaskId = env[PARENT_TASK_ID_ENV]?.trim() || undefined;
33
+ const depth = currentSubagentDepth(env);
34
+ const out = {};
35
+ if (taskId)
36
+ out.taskId = taskId;
37
+ if (parentTaskId)
38
+ out.parentTaskId = parentTaskId;
39
+ if (depth > 0)
40
+ out.depth = depth;
41
+ return out;
42
+ }
43
+ export function withEnvelope(event, envelope) {
44
+ return { ...event, ...envelope };
45
+ }
29
46
  //# sourceMappingURL=json-event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-event.js","sourceRoot":"","sources":["../../src/modes/json-event.ts"],"names":[],"mappings":"AAmBA,SAAS,2BAA2B,CACnC,KAAkD;IAElD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,QAAQ,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,YAAY,qBAAqB,CAAC,CAAC;QAC7F,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;QACnD,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpE,CAAC;IAED,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACnD,OAAO,UAAU,CAAC;AACnB,CAAC;AAUD,MAAM,UAAU,WAAW,CAAC,KAAwB;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;QAC1B,qBAAqB,EAAE,2BAA2B,CAAC,KAAK,CAAC,qBAAqB,CAAC;KAC/E,CAAC;AACH,CAAC","sourcesContent":["import type { Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentSessionEvent } from \"../core/agent-session.ts\";\n\ntype WithoutPartial<T> = T extends { partial: unknown } ? Omit<T, \"partial\"> : T;\n\ntype ToJsonAssistantMessageEvent<T> = T extends { type: \"toolcall_start\"; partial: unknown }\n\t? WithoutPartial<T> & { id: string; toolName: string }\n\t: WithoutPartial<T>;\n\ntype MessageUpdateEvent = Extract<AgentSessionEvent, { type: \"message_update\" }>;\ntype JsonMessageUpdateEvent = {\n\ttype: \"message_update\";\n\tusage: Usage;\n\tassistantMessageEvent: ToJsonAssistantMessageEvent<MessageUpdateEvent[\"assistantMessageEvent\"]>;\n};\n\n/** Session event shape emitted by the JSON and RPC stdout protocols. */\nexport type JsonAgentSessionEvent = Exclude<AgentSessionEvent, { type: \"message_update\" }> | JsonMessageUpdateEvent;\n\nfunction toJsonAssistantMessageEvent(\n\tevent: MessageUpdateEvent[\"assistantMessageEvent\"],\n): JsonMessageUpdateEvent[\"assistantMessageEvent\"] {\n\tif (event.type === \"toolcall_start\") {\n\t\tconst toolCall = event.partial.content[event.contentIndex];\n\t\tif (toolCall?.type !== \"toolCall\") {\n\t\t\tthrow new Error(`toolcall_start content at index ${event.contentIndex} is not a tool call`);\n\t\t}\n\t\tconst { partial: _partial, ...deltaEvent } = event;\n\t\treturn { ...deltaEvent, id: toolCall.id, toolName: toolCall.name };\n\t}\n\n\tif (!(\"partial\" in event)) {\n\t\treturn event;\n\t}\n\n\tconst { partial: _partial, ...deltaEvent } = event;\n\treturn deltaEvent;\n}\n\n/**\n * Remove cumulative assistant snapshots from streaming wire events.\n * `message_start` provides the initial message, deltas build it, and\n * `message_end` provides the final authoritative message. Cumulative usage,\n * tool-call ids, and tool names remain available because their size is constant.\n */\nexport function toJsonEvent(event: MessageUpdateEvent): JsonMessageUpdateEvent;\nexport function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent;\nexport function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent {\n\tif (event.type !== \"message_update\") {\n\t\treturn event;\n\t}\n\tif (event.message.role !== \"assistant\") {\n\t\tthrow new Error(\"message_update message is not an assistant message\");\n\t}\n\n\treturn {\n\t\ttype: \"message_update\",\n\t\tusage: event.message.usage,\n\t\tassistantMessageEvent: toJsonAssistantMessageEvent(event.assistantMessageEvent),\n\t};\n}\n"]}
1
+ {"version":3,"file":"json-event.js","sourceRoot":"","sources":["../../src/modes/json-event.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAkBxG,SAAS,2BAA2B,CACnC,KAAkD;IAElD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG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IAAI,EAAE,IAAI,SAAS,CAAC;IAClE,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,GAAG,GAA0B,EAAE,CAAC;IACtC,IAAI,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IAChC,IAAI,YAAY;QAAE,GAAG,CAAC,YAAY,GAAG,YAAY,CAAC;IAClD,IAAI,KAAK,GAAG,CAAC;QAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;IACjC,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,YAAY,CAAmB,KAAQ,EAAE,QAA+B;IACvF,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import type { Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentSessionEvent } from \"../core/agent-session.ts\";\nimport { currentSubagentDepth, currentTaskId, PARENT_TASK_ID_ENV } from \"../core/tools/subagent-env.ts\";\n\ntype WithoutPartial<T> = T extends { partial: unknown } ? Omit<T, \"partial\"> : T;\n\ntype ToJsonAssistantMessageEvent<T> = T extends { type: \"toolcall_start\"; partial: unknown }\n\t? WithoutPartial<T> & { id: string; toolName: string }\n\t: WithoutPartial<T>;\n\ntype MessageUpdateEvent = Extract<AgentSessionEvent, { type: \"message_update\" }>;\ntype JsonMessageUpdateEvent = {\n\ttype: \"message_update\";\n\tusage: Usage;\n\tassistantMessageEvent: ToJsonAssistantMessageEvent<MessageUpdateEvent[\"assistantMessageEvent\"]>;\n};\n\n/** Session event shape emitted by the JSON and RPC stdout protocols. */\nexport type JsonAgentSessionEvent = Exclude<AgentSessionEvent, { type: \"message_update\" }> | JsonMessageUpdateEvent;\n\nfunction toJsonAssistantMessageEvent(\n\tevent: MessageUpdateEvent[\"assistantMessageEvent\"],\n): JsonMessageUpdateEvent[\"assistantMessageEvent\"] {\n\tif (event.type === \"toolcall_start\") {\n\t\tconst toolCall = event.partial.content[event.contentIndex];\n\t\tif (toolCall?.type !== \"toolCall\") {\n\t\t\tthrow new Error(`toolcall_start content at index ${event.contentIndex} is not a tool call`);\n\t\t}\n\t\tconst { partial: _partial, ...deltaEvent } = event;\n\t\treturn { ...deltaEvent, id: toolCall.id, toolName: toolCall.name };\n\t}\n\n\tif (!(\"partial\" in event)) {\n\t\treturn event;\n\t}\n\n\tconst { partial: _partial, ...deltaEvent } = event;\n\treturn deltaEvent;\n}\n\n/**\n * Remove cumulative assistant snapshots from streaming wire events.\n * `message_start` provides the initial message, deltas build it, and\n * `message_end` provides the final authoritative message. Cumulative usage,\n * tool-call ids, and tool names remain available because their size is constant.\n */\nexport function toJsonEvent(event: MessageUpdateEvent): JsonMessageUpdateEvent;\nexport function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent;\nexport function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent {\n\tif (event.type !== \"message_update\") {\n\t\treturn event;\n\t}\n\tif (event.message.role !== \"assistant\") {\n\t\tthrow new Error(\"message_update message is not an assistant message\");\n\t}\n\n\treturn {\n\t\ttype: \"message_update\",\n\t\tusage: event.message.usage,\n\t\tassistantMessageEvent: toJsonAssistantMessageEvent(event.assistantMessageEvent),\n\t};\n}\n\n/** Identity a subagent child stamps on every wire event so a consumer can rebuild the tree. */\nexport interface OrchestrationEnvelope {\n\ttaskId?: string;\n\tparentTaskId?: string;\n\tdepth?: number;\n}\n\nexport function orchestrationEnvelope(env: NodeJS.ProcessEnv = process.env): OrchestrationEnvelope {\n\tconst taskId = currentTaskId(env);\n\tconst parentTaskId = env[PARENT_TASK_ID_ENV]?.trim() || undefined;\n\tconst depth = currentSubagentDepth(env);\n\tconst out: OrchestrationEnvelope = {};\n\tif (taskId) out.taskId = taskId;\n\tif (parentTaskId) out.parentTaskId = parentTaskId;\n\tif (depth > 0) out.depth = depth;\n\treturn out;\n}\n\nexport function withEnvelope<T extends object>(event: T, envelope: OrchestrationEnvelope): T & OrchestrationEnvelope {\n\treturn { ...event, ...envelope };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"print-mode.d.ts","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAK5E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwI/G"}
1
+ {"version":3,"file":"print-mode.d.ts","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAK5E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyI/G"}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { flushRawStdout, waitForRawStdoutBackpressure, writeRawStdout } from "../core/output-guard.js";
9
9
  import { killTrackedDetachedChildren } from "../utils/shell.js";
10
- import { toJsonEvent } from "./json-event.js";
10
+ import { orchestrationEnvelope, toJsonEvent, withEnvelope } from "./json-event.js";
11
11
  /**
12
12
  * Run in print (single-shot) mode.
13
13
  * Sends prompts to the agent and outputs the result.
@@ -81,9 +81,10 @@ export async function runPrintMode(runtimeHost, options) {
81
81
  });
82
82
  unsubscribe?.();
83
83
  unsubscribeBackpressure?.();
84
+ const envelope = orchestrationEnvelope();
84
85
  unsubscribe = session.subscribe((event) => {
85
86
  if (mode === "json") {
86
- writeRawStdout(`${JSON.stringify(toJsonEvent(event))}\n`);
87
+ writeRawStdout(`${JSON.stringify(withEnvelope(toJsonEvent(event), envelope))}\n`);
87
88
  }
88
89
  });
89
90
  unsubscribeBackpressure =
@@ -1 +1 @@
1
- {"version":3,"file":"print-mode.js","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgB9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAgC,EAAE,OAAyB;IAC7F,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACvE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAClC,IAAI,WAAqC,CAAC;IAC1C,IAAI,uBAAiD,CAAC;IACtD,IAAI,QAAQ,GAAG,KAAK,C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AAW,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE9D,IAAI,WAAW,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;gBACvC,MAAM,YAAY,GAAG,WAA+B,CAAC;gBACrD,IAAI,YAAY,CAAC,UAAU,KAAK,OAAO,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;oBAClF,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,IAAI,WAAW,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;oBACjF,QAAQ,GAAG,CAAC,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACP,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBAC5C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;4BAC7B,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;wBACrC,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,KAAK,MAAM,OAAO,IAAI,qBAAqB,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,cAAc,EAAE,CAAC;QACvB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Print mode (single-shot): Send prompts, output result, exit.\n *\n * Used for:\n * - `pi -p \"prompt\"` - text output\n * - `pi --mode json \"prompt\"` - JSON event stream\n */\n\nimport type { AssistantMessage, ImageContent } from \"@earendil-works/pi-ai\";\nimport type { AgentSessionRuntime } from \"../core/agent-session-runtime.ts\";\nimport { flushRawStdout, waitForRawStdoutBackpressure, writeRawStdout } from \"../core/output-guard.ts\";\nimport { killTrackedDetachedChildren } from \"../utils/shell.ts\";\nimport { toJsonEvent } from \"./json-event.ts\";\n\n/**\n * Options for print mode.\n */\nexport interface PrintModeOptions {\n\t/** Output mode: \"text\" for final response only, \"json\" for all events */\n\tmode: \"text\" | \"json\";\n\t/** Array of additional prompts to send after initialMessage */\n\tmessages?: string[];\n\t/** First message to send (may contain @file content) */\n\tinitialMessage?: string;\n\t/** Images to attach to the initial message */\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Run in print (single-shot) mode.\n * Sends prompts to the agent and outputs the result.\n */\nexport async function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number> {\n\tconst { mode, messages = [], initialMessage, initialImages } = options;\n\tlet exitCode = 0;\n\tlet session = runtimeHost.session;\n\tlet unsubscribe: (() => void) | undefined;\n\tlet unsubscribeBackpressure: (() => void) | undefined;\n\tlet disposed = false;\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tconst disposeRuntime = async (): Promise<void> => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tunsubscribe?.();\n\t\tunsubscribeBackpressure?.();\n\t\tawait runtimeHost.dispose();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid disposeRuntime().finally(() => {\n\t\t\t\t\tprocess.exit(signal === \"SIGHUP\" ? 129 : 143);\n\t\t\t\t});\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tregisterSignalHandlers();\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait rebindSession();\n\t});\n\n\tconst rebindSession = async (): Promise<void> => {\n\t\tsession = runtimeHost.session;\n\t\tawait session.bindExtensions({\n\t\t\tmode: mode === \"json\" ? \"json\" : \"print\",\n\t\t\tcommandContextActions: {\n\t\t\t\twaitForIdle: () => session.waitForIdle(),\n\t\t\t\tnewSession: async (newSessionOptions) => runtimeHost.newSession(newSessionOptions),\n\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\tconst result = await runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tnavigateTree: async (targetId, navigateOptions) => {\n\t\t\t\t\tconst result = await session.navigateTree(targetId, {\n\t\t\t\t\t\tsummarize: navigateOptions?.summarize,\n\t\t\t\t\t\tcustomInstructions: navigateOptions?.customInstructions,\n\t\t\t\t\t\treplaceInstructions: navigateOptions?.replaceInstructions,\n\t\t\t\t\t\tlabel: navigateOptions?.label,\n\t\t\t\t\t});\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tswitchSession: async (sessionPath, switchOptions) => {\n\t\t\t\t\treturn runtimeHost.switchSession(sessionPath, switchOptions);\n\t\t\t\t},\n\t\t\t\treload: async () => {\n\t\t\t\t\tawait session.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tconsole.error(`Extension error (${err.extensionPath}): ${err.error}`);\n\t\t\t},\n\t\t});\n\n\t\tunsubscribe?.();\n\t\tunsubscribeBackpressure?.();\n\t\tunsubscribe = session.subscribe((event) => {\n\t\t\tif (mode === \"json\") {\n\t\t\t\twriteRawStdout(`${JSON.stringify(toJsonEvent(event))}\\n`);\n\t\t\t}\n\t\t});\n\t\tunsubscribeBackpressure =\n\t\t\tmode === \"json\"\n\t\t\t\t? session.agent.subscribe(async () => {\n\t\t\t\t\t\tawait waitForRawStdoutBackpressure();\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t};\n\n\ttry {\n\t\tif (mode === \"json\") {\n\t\t\tconst header = session.sessionManager.getHeader();\n\t\t\tif (header) {\n\t\t\t\twriteRawStdout(`${JSON.stringify(header)}\\n`);\n\t\t\t}\n\t\t}\n\n\t\tawait rebindSession();\n\n\t\tif (initialMessage) {\n\t\t\tawait session.prompt(initialMessage, { images: initialImages });\n\t\t}\n\n\t\tfor (const message of messages) {\n\t\t\tawait session.prompt(message);\n\t\t}\n\n\t\tif (mode === \"text\") {\n\t\t\tconst state = session.state;\n\t\t\tconst lastMessage = state.messages[state.messages.length - 1];\n\n\t\t\tif (lastMessage?.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = lastMessage as AssistantMessage;\n\t\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\t\tconsole.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);\n\t\t\t\t\texitCode = 1;\n\t\t\t\t} else {\n\t\t\t\t\tfor (const content of assistantMsg.content) {\n\t\t\t\t\t\tif (content.type === \"text\") {\n\t\t\t\t\t\t\twriteRawStdout(`${content.text}\\n`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exitCode;\n\t} catch (error: unknown) {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\treturn 1;\n\t} finally {\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tawait disposeRuntime();\n\t\tawait flushRawStdout();\n\t}\n}\n"]}
1
+ {"version":3,"file":"print-mode.js","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CA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E,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,KAAK,MAAM,OAAO,IAAI,qBAAqB,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,cAAc,EAAE,CAAC;QACvB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Print mode (single-shot): Send prompts, output result, exit.\n *\n * Used for:\n * - `pi -p \"prompt\"` - text output\n * - `pi --mode json \"prompt\"` - JSON event stream\n */\n\nimport type { AssistantMessage, ImageContent } from \"@earendil-works/pi-ai\";\nimport type { AgentSessionRuntime } from \"../core/agent-session-runtime.ts\";\nimport { flushRawStdout, waitForRawStdoutBackpressure, writeRawStdout } from \"../core/output-guard.ts\";\nimport { killTrackedDetachedChildren } from \"../utils/shell.ts\";\nimport { orchestrationEnvelope, toJsonEvent, withEnvelope } from \"./json-event.ts\";\n\n/**\n * Options for print mode.\n */\nexport interface PrintModeOptions {\n\t/** Output mode: \"text\" for final response only, \"json\" for all events */\n\tmode: \"text\" | \"json\";\n\t/** Array of additional prompts to send after initialMessage */\n\tmessages?: string[];\n\t/** First message to send (may contain @file content) */\n\tinitialMessage?: string;\n\t/** Images to attach to the initial message */\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Run in print (single-shot) mode.\n * Sends prompts to the agent and outputs the result.\n */\nexport async function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number> {\n\tconst { mode, messages = [], initialMessage, initialImages } = options;\n\tlet exitCode = 0;\n\tlet session = runtimeHost.session;\n\tlet unsubscribe: (() => void) | undefined;\n\tlet unsubscribeBackpressure: (() => void) | undefined;\n\tlet disposed = false;\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tconst disposeRuntime = async (): Promise<void> => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tunsubscribe?.();\n\t\tunsubscribeBackpressure?.();\n\t\tawait runtimeHost.dispose();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid disposeRuntime().finally(() => {\n\t\t\t\t\tprocess.exit(signal === \"SIGHUP\" ? 129 : 143);\n\t\t\t\t});\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tregisterSignalHandlers();\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait rebindSession();\n\t});\n\n\tconst rebindSession = async (): Promise<void> => {\n\t\tsession = runtimeHost.session;\n\t\tawait session.bindExtensions({\n\t\t\tmode: mode === \"json\" ? \"json\" : \"print\",\n\t\t\tcommandContextActions: {\n\t\t\t\twaitForIdle: () => session.waitForIdle(),\n\t\t\t\tnewSession: async (newSessionOptions) => runtimeHost.newSession(newSessionOptions),\n\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\tconst result = await runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tnavigateTree: async (targetId, navigateOptions) => {\n\t\t\t\t\tconst result = await session.navigateTree(targetId, {\n\t\t\t\t\t\tsummarize: navigateOptions?.summarize,\n\t\t\t\t\t\tcustomInstructions: navigateOptions?.customInstructions,\n\t\t\t\t\t\treplaceInstructions: navigateOptions?.replaceInstructions,\n\t\t\t\t\t\tlabel: navigateOptions?.label,\n\t\t\t\t\t});\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tswitchSession: async (sessionPath, switchOptions) => {\n\t\t\t\t\treturn runtimeHost.switchSession(sessionPath, switchOptions);\n\t\t\t\t},\n\t\t\t\treload: async () => {\n\t\t\t\t\tawait session.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tconsole.error(`Extension error (${err.extensionPath}): ${err.error}`);\n\t\t\t},\n\t\t});\n\n\t\tunsubscribe?.();\n\t\tunsubscribeBackpressure?.();\n\t\tconst envelope = orchestrationEnvelope();\n\t\tunsubscribe = session.subscribe((event) => {\n\t\t\tif (mode === \"json\") {\n\t\t\t\twriteRawStdout(`${JSON.stringify(withEnvelope(toJsonEvent(event), envelope))}\\n`);\n\t\t\t}\n\t\t});\n\t\tunsubscribeBackpressure =\n\t\t\tmode === \"json\"\n\t\t\t\t? session.agent.subscribe(async () => {\n\t\t\t\t\t\tawait waitForRawStdoutBackpressure();\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t};\n\n\ttry {\n\t\tif (mode === \"json\") {\n\t\t\tconst header = session.sessionManager.getHeader();\n\t\t\tif (header) {\n\t\t\t\twriteRawStdout(`${JSON.stringify(header)}\\n`);\n\t\t\t}\n\t\t}\n\n\t\tawait rebindSession();\n\n\t\tif (initialMessage) {\n\t\t\tawait session.prompt(initialMessage, { images: initialImages });\n\t\t}\n\n\t\tfor (const message of messages) {\n\t\t\tawait session.prompt(message);\n\t\t}\n\n\t\tif (mode === \"text\") {\n\t\t\tconst state = session.state;\n\t\t\tconst lastMessage = state.messages[state.messages.length - 1];\n\n\t\t\tif (lastMessage?.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = lastMessage as AssistantMessage;\n\t\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\t\tconsole.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);\n\t\t\t\t\texitCode = 1;\n\t\t\t\t} else {\n\t\t\t\t\tfor (const content of assistantMsg.content) {\n\t\t\t\t\t\tif (content.type === \"text\") {\n\t\t\t\t\t\t\twriteRawStdout(`${content.text}\\n`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exitCode;\n\t} catch (error: unknown) {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\treturn 1;\n\t} finally {\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tawait disposeRuntime();\n\t\tawait flushRawStdout();\n\t}\n}\n"]}
@@ -88,6 +88,14 @@ These variables are read by HUMAIN Terminal itself:
88
88
  | `PI_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
89
89
  | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
90
90
  | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
91
+ | `HUMAIN_TERMINAL_SUBAGENT_MAX_DEPTH` | Maximum nesting depth for the `subagent` tool. Default `1`, ceiling `3`. |
92
+ | `HUMAIN_TERMINAL_SUBAGENT_MAX_CONCURRENCY` | Maximum children running at once in parallel mode. Default `4`, ceiling `8`. |
93
+ | `HUMAIN_TERMINAL_SUBAGENT_MAX_TASKS` | Maximum tasks accepted by one parallel call. Default `8`, ceiling `16`. |
94
+ | `HUMAIN_TERMINAL_TASK_ID` | Set by the parent on each child: the child's stable task id. |
95
+ | `HUMAIN_TERMINAL_PARENT_TASK_ID` | Set by the parent on each child: the spawning task id or tool call id. |
96
+ | `HUMAIN_TERMINAL_TASK_BASE_REVISION` | Set by the parent when the task's context packet names a base revision. |
97
+
98
+ Raising `HUMAIN_TERMINAL_SUBAGENT_MAX_DEPTH` multiplies fan-out: each level applies its own task cap, so the tree may reach tasks^depth processes. An aggregate budget is the caller's responsibility. These caps are advisory process configuration read from the environment, not a security boundary; a child with shell access could start a fresh process tree.
91
99
 
92
100
  Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
93
101
 
@@ -55,6 +55,12 @@ Web settings and cached search content live under the HUMAIN agent directory. Th
55
55
 
56
56
  Maintainers can run `npm run check:web-access-upstream` from the repository root to detect a newer upstream release requiring source and dependency review.
57
57
 
58
+ ## HUMAIN Node
59
+
60
+ Use `/login humain-node` to enter a masked API key and optional base URL (default `https://api.node.humain.com/v1`). Alternatively, set `HUMAIN_NODE_API_KEY` and optionally `HUMAIN_NODE_BASE_URL` in your environment.
61
+
62
+ HUMAIN Terminal discovers the models available to that key before offering them in `/model`. Supported models use Node's Responses, Chat Completions, or Messages endpoint with normal streaming, tools, and reported token usage. Account spend, remaining quota, and pricing are not available from the supplied inference API. See [HUMAIN Node setup](providers.md#humain-node).
63
+
58
64
  ## Local Models
59
65
 
60
66
  Set `HUMAIN_TERMINAL_LOCAL_BASE_URL` to an OpenAI-compatible `/v1` endpoint. Models come from `HUMAIN_TERMINAL_LOCAL_MODELS` when set, otherwise HUMAIN Terminal performs a bounded `/v1/models` discovery request.
package/docs/json.md CHANGED
@@ -91,6 +91,22 @@ usage at completion. Use `contentIndex` and `delta` to assemble live text, think
91
91
  arguments if needed. A `toolcall_start` event also includes the constant-sized `id` and `toolName`
92
92
  fields. `message_end` contains the final authoritative message.
93
93
 
94
+ ### Subagent identity fields
95
+
96
+ When the process runs as a subagent child (spawned by the `subagent` tool), every
97
+ event carries three additional top-level fields so a consumer can rebuild the
98
+ delegation tree:
99
+
100
+ | Field | Type | Meaning |
101
+ |---|---|---|
102
+ | `taskId` | string | Stable id of this child, set by the parent (`HUMAIN_TERMINAL_TASK_ID`). |
103
+ | `parentTaskId` | string | Task id of the spawning process, or its tool call id at the top level (`HUMAIN_TERMINAL_PARENT_TASK_ID`). |
104
+ | `depth` | number | Nesting depth, 1 for a direct child (`HUMAIN_TERMINAL_SUBAGENT_DEPTH`). |
105
+
106
+ Top-level processes emit none of these fields.
107
+
108
+ RPC mode (`--mode rpc`) does not currently stamp these fields; the `subagent` tool always spawns children with `--mode json`.
109
+
94
110
  ## Example
95
111
 
96
112
  ```bash
package/docs/providers.md CHANGED
@@ -6,6 +6,7 @@ HUMAIN Terminal supports subscription-based providers via OAuth and API key prov
6
6
 
7
7
  - [Subscriptions](#subscriptions)
8
8
  - [API Keys](#api-keys)
9
+ - [HUMAIN Node](#humain-node)
9
10
  - [Auth File](#auth-file)
10
11
  - [Cloud Providers](#cloud-providers)
11
12
  - [llama.cpp](#llamacpp)
@@ -72,6 +73,7 @@ humain-terminal
72
73
  | Ant Ling | `ANT_LING_API_KEY` | `ant-ling` |
73
74
  | Azure OpenAI Responses | `AZURE_OPENAI_API_KEY` | `azure-openai-responses` |
74
75
  | OpenAI | `OPENAI_API_KEY` | `openai` |
76
+ | HUMAIN Node | `HUMAIN_NODE_API_KEY` | `humain-node` |
75
77
  | DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
76
78
  | NVIDIA NIM | `NVIDIA_API_KEY` | `nvidia` |
77
79
  | Google Gemini | `GEMINI_API_KEY` | `google` |
@@ -104,7 +106,7 @@ humain-terminal
104
106
  | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
105
107
  | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` | `xiaomi-token-plan-sgp` |
106
108
 
107
- Reference for environment variables and `auth.json` keys: [`const envMap`](../../ai/src/env-api-keys.ts).
109
+ Reference for built-in environment variables and `auth.json` keys: [`const envMap`](../../ai/src/env-api-keys.ts). HUMAIN Node is registered by the bundled HUMAIN extension.
108
110
 
109
111
  #### Auth File
110
112
 
@@ -184,6 +186,22 @@ The `key` field supports command execution, environment interpolation, and liter
184
186
 
185
187
  OAuth credentials are also stored here after `/login` and managed automatically.
186
188
 
189
+ ## HUMAIN Node
190
+
191
+ Run `/login humain-node` (or select **HUMAIN Node** in `/login`). Enter the API key in the masked terminal prompt, then accept `https://api.node.humain.com/v1` or enter a custom base URL. Login validates the key with `GET /models` before saving credentials.
192
+
193
+ To obtain a key, open your Team's **Users** page in HUMAIN Node, select the user for this workload and environment, and create an API key. Save it in your local environment as `HUMAIN_NODE_API_KEY` or in a secret manager. Never paste it into chat. If the environment variable is set, leave the login key prompt blank to use it without copying the key into `auth.json`.
194
+
195
+ `HUMAIN_NODE_BASE_URL` optionally changes the default endpoint. A URL saved during login takes priority. Custom URLs must use HTTPS; HTTP is allowed for localhost testing.
196
+
197
+ After login, use `/model` to select a discovered Node model and submit a prompt normally. For headless use, set `HUMAIN_NODE_API_KEY`, run `humain-terminal --list-models`, then pass a returned model ID with `humain-terminal --provider humain-node --model MODEL_ID -p "Say hello"`.
198
+
199
+ Only models advertising a supported text API, streaming, and tool calling are offered for coding. Node's model metadata chooses Responses, Chat Completions, or Messages and supplies context/output limits and image-input support. Catalogs are refreshed from Node and kept in memory, scoped to the active key and URL; Node models are unavailable offline after a restart. Image generation and realtime sessions are outside the coding model picker.
200
+
201
+ Token and cache usage reported by Node flows into the normal session statistics. The supplied API does not expose account spend, remaining quota, or model prices: zero-valued internal cost fields mean pricing is unavailable, not free usage. Use HUMAIN Node for billing and account usage reports.
202
+
203
+ Failed requests include the supplied `X-Request-ID`. Temporary failures use bounded retries that respect `Retry-After`; quota and weekly-spend limits require action in Node. If a model becomes unavailable, open `/model` to refresh the catalog and select an available model. Run `/logout` and select **HUMAIN Node** to remove saved credentials; unset `HUMAIN_NODE_API_KEY` as well to disconnect an environment-based key.
204
+
187
205
  ## Cloud Providers
188
206
 
189
207
  ### Azure OpenAI
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@humain/terminal",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@humain/terminal",
9
- "version": "0.1.0",
9
+ "version": "0.2.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@humain/terminal-contracts": "0.1.0",
12
+ "@humain/terminal-contracts": "0.2.0",
13
13
  "@aws-sdk/client-bedrock-runtime": "3.1127.0",
14
14
  "@earendil-works/pi-agent-core": "0.85.1",
15
15
  "@earendil-works/pi-ai": "0.85.1",
@@ -950,9 +950,9 @@
950
950
  "hasInstallScript": true
951
951
  },
952
952
  "node_modules/@humain/terminal-contracts": {
953
- "version": "0.1.0",
954
- "resolved": "https://registry.npmjs.org/@humain/terminal-contracts/-/terminal-contracts-0.1.0.tgz",
955
- "integrity": "sha512-Mkzk/Z58b3o1vWn2hZqhI4jDmXJwHeLxdz/73ZzhnrrfgTUBnlTc4YvJR2cOM8pzLEwCpnMdpL0RD/EBn+jT2Q==",
953
+ "version": "0.2.0",
954
+ "resolved": "https://registry.npmjs.org/@humain/terminal-contracts/-/terminal-contracts-0.2.0.tgz",
955
+ "integrity": "sha512-ZMu1vL+ZNtH4rEHqwB5cHBN/BXyhj2DVGMUVwqArUrYXoJZqjNucYUpRYt0/dZ/x+gEZRTC0EvUlYTlPr2SpPg==",
956
956
  "license": "MIT",
957
957
  "dependencies": {
958
958
  "typebox": "1.3.27"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humain/terminal",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "humainTerminalConfig": {
@@ -67,7 +67,7 @@
67
67
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
68
68
  },
69
69
  "dependencies": {
70
- "@humain/terminal-contracts": "0.1.0",
70
+ "@humain/terminal-contracts": "0.2.0",
71
71
  "@aws-sdk/client-bedrock-runtime": "3.1127.0",
72
72
  "@earendil-works/pi-agent-core": "0.85.1",
73
73
  "@earendil-works/pi-ai": "0.85.1",
@@ -1,25 +1,74 @@
1
1
  # pi-mcp-adapter upstream tracking
2
2
 
3
3
  HUMAIN Terminal vendors [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter)
4
- version `2.32.1` so MCP support is available without a separate VM installation.
4
+ version `2.34.0` so MCP support is available without a separate VM installation.
5
5
 
6
6
  The unmodified upstream package is recorded in `upstream.json`, including the
7
- registry integrity and source `gitHead`. The release currentness gate resolves
8
- that exact version from npm and rejects provenance drift before checking whether
9
- a newer version exists.
7
+ registry integrity, tarball shasum, and source `gitHead`. The release currentness
8
+ gate resolves that exact version from npm and rejects provenance drift before
9
+ checking whether a newer version exists.
10
10
 
11
11
  The HUMAIN wrapper establishes Terminal's package manifest as `PI_PACKAGE_DIR`
12
12
  before returning the vendored factory, so its dynamic config and credential
13
13
  lookups stay under `.humain-terminal/agent`. An explicit `PI_PACKAGE_DIR`
14
14
  remains authoritative for downstream distributions and Nix/Guix layouts.
15
15
 
16
+ ## Signature-only provenance for 2.34.0
17
+
18
+ Upstream published `2.34.0` without a `gitHead`, which every release from
19
+ `2.31.0` through `2.33.0` carried. The tarball itself is intact: its sha512
20
+ integrity and shasum match the registry exactly and the registry holds valid npm
21
+ signatures for it, but there is no recorded link back to an upstream source
22
+ commit. `2.34.0` was therefore accepted on integrity, shasum, and npm signature
23
+ alone, and `upstream.json` records that decision explicitly as `"gitHead": null`
24
+ with a `provenanceNote`. The gate treats a recorded `null` as the only way to
25
+ skip the `gitHead` comparison: it still fails on any integrity or shasum
26
+ mismatch, still enforces an exact match whenever a `gitHead` string is recorded,
27
+ and fails again if upstream later starts publishing a `gitHead` for the recorded
28
+ version, so the relaxation cannot outlive the release it was granted for. Restore
29
+ ordinary `gitHead` provenance at the next upstream release that publishes one.
30
+
31
+ ## Host imports
32
+
33
+ Vendored modules import types from `@earendil-works/pi-coding-agent`, which is
34
+ not resolvable here because this repository's coding agent package is
35
+ `@humain/terminal`. Type-only imports are erased at build time and are left
36
+ alone. Every *value* import from that package must be repointed at the
37
+ equivalent repository module, or the bundle will emit an unresolvable external
38
+ import. As of 2.34.0 there are four:
39
+
40
+ | Vendored file | Symbol | Repository module |
41
+ | --- | --- | --- |
42
+ | `mcp-panel.ts` | `copyToClipboard` | `../../../utils/clipboard.ts` |
43
+ | `mcp-panel-theme.ts` | `DynamicBorder` | `../../../modes/interactive/components/dynamic-border.ts` |
44
+ | `index.ts` | `withFileMutationQueue` | `../../../core/tools/file-mutation-queue.ts`, whose queue state lives on `globalThis` under `Symbol.for("humain-terminal:file-mutation-queue")` so the copy inlined into this bundle serializes against the host's `edit`, `write` and `subagent` tools instead of keeping a second queue |
45
+ | `mcp-output-guard.ts` | `DEFAULT_MAX_BYTES`, `DEFAULT_MAX_LINES`, `formatSize`, `truncateHead` | `../../../core/tools/truncate.ts` |
46
+
47
+ After a sync, confirm no value imports remain:
48
+ `grep -rn '@earendil-works/pi-coding-agent' vendor/*.ts` should show only
49
+ `import type` forms and `import { type X }` forms, and the built bundle should
50
+ contain no reference to the package at all.
51
+
52
+ ## Bundled undici
53
+
54
+ `2.33.0` added a direct `undici` `^6` dependency for origin-scoped `caFile` TLS
55
+ trust, and the adapter's `http-ca.ts` requires its `Agent` and its `fetch` to
56
+ come from one undici copy. This repository pins `undici` `8.10.2` for every other
57
+ consumer, so `scripts/build-bundled-mcp-adapter.mjs` aliases `undici` to a
58
+ build-only `undici-v6` alias (`npm:undici@6.28.1`, a root devDependency) and
59
+ inlines it into `vendor/index.bundle.mjs` alone. The shared pin is untouched.
60
+ Because undici is CommonJS, the bundle also carries a `createRequire` banner;
61
+ without it the bundled `require("node:assert")` throws
62
+ `Dynamic require of "node:assert" is not supported` at load time. Keep both when
63
+ changing the bundle script.
64
+
16
65
  During updates:
17
66
 
18
- 1. Fetch and verify the recorded npm tarball integrity and `gitHead`.
67
+ 1. Fetch and verify the recorded npm tarball integrity, shasum, and `gitHead`.
19
68
  2. Review upstream source, dependency, lifecycle, and asset changes.
20
69
  3. Replace `vendor/` from the reviewed tarball.
21
- 4. Reapply the documented HUMAIN host import in `vendor/mcp-panel.ts` and
22
- normalize trailing whitespace in vendored TypeScript for repository checks.
70
+ 4. Reapply the documented HUMAIN host imports above and normalize trailing
71
+ whitespace in vendored TypeScript for repository checks.
23
72
  5. Regenerate `vendor/index.bundle.mjs` with the repository MCP bundle script.
24
73
  6. Update pinned runtime dependencies, every provenance field in `upstream.json`, and this document.
25
74
  7. Run `npm run check:mcp-adapter-upstream`, the MCP bundle tests, and local Node/Bun release smoke tests.
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "pi-mcp-adapter",
3
3
  "repository": "https://github.com/nicobailon/pi-mcp-adapter",
4
- "version": "2.32.1",
5
- "tarball": "https://registry.npmjs.org/pi-mcp-adapter/-/pi-mcp-adapter-2.32.1.tgz",
6
- "integrity": "sha512-GNLYa2U9T5ZqIhZmhx/RTenEjfakJTelq/z6Q+At5SIxyuYvrvobriDEVsnx+lqetVDizUCudTWLfdZytQu0rg==",
7
- "gitHead": "10a45367e033a32026987a75d6f401e37340c86f"
4
+ "version": "2.34.0",
5
+ "tarball": "https://registry.npmjs.org/pi-mcp-adapter/-/pi-mcp-adapter-2.34.0.tgz",
6
+ "integrity": "sha512-3YzoYQlxwKQjk4co0MMnRrhTNWzw5XsoCKCuhfZkIa9XSRBbrOLbi32yu7KOn6Unyk/K0rTof1lX/7cSLobudg==",
7
+ "shasum": "d2dc31a685a94b60a1c3570d9eb8a3b189eff10f",
8
+ "gitHead": null,
9
+ "provenanceNote": "2.34.0 published without gitHead; accepted on integrity, shasum and npm signature (2026-09-17)"
8
10
  }
@@ -7,6 +7,84 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.34.0] - 2026-09-14
11
+
12
+ ### Highlights
13
+
14
+ - Start Pi faster while keeping cached MCP tools, prompts, and commands immediately available.
15
+ - Connect to more OAuth servers with Client ID Metadata Documents.
16
+ - Store OAuth credentials securely in encrypted files when Windows OpenSSH or a headless session cannot use the OS credential store.
17
+ - Load shared configuration and Agent Plugin MCP servers more reliably.
18
+ - Use MCP Apps, private HTTPS servers, and frequently changing tool catalogs with fewer connection problems.
19
+
20
+ ### Added
21
+
22
+ - Windows OpenSSH/network logons can explicitly select externally keyed AES-256-GCM OAuth credential files with `settings.oauthCredentialStore: "encrypted-file"`; error 1312 now points to this option, while the OS store remains the default with no automatic fallback. Thanks to [@pierreh](https://github.com/pierreh) for issue #574.
23
+ - OAuth servers can explicitly opt into operator-hosted Client ID Metadata Documents (SEP-991) with `oauth.clientMetadataUrl`; URL-only/default configurations continue using Dynamic Client Registration. Existing DCR refresh credentials get their normal refresh attempt before migration to CIMD after invalidation. Thanks to [@dsluo](https://github.com/dsluo) for PR #571.
24
+ - User-global or explicitly selected config can opt in to bounded ancestor `.mcp.json` and `<configDir>/mcp.json` discovery with `settings.ancestorConfigRoots`. Discovery is off by default; project files cannot enable or widen it, and the deepest matching existing directory under `$HOME` bounds farthest-first loading. Thanks to [@johnhenaot](https://github.com/johnhenaot) for PR #555.
25
+
26
+ ### Changed
27
+
28
+ - Runtime-heavy MCP modules now load only when first needed, while cached tools, prompts, and commands remain immediately available. Thanks to [@thefakepaulgg](https://github.com/thefakepaulgg) for PR #576.
29
+ - OAuth dependencies now use published MCP SDK releases again, restoring normal npm installs and removing the standalone native-addon dependency. Cross-process OAuth transaction serialization remains unavailable until the official SDK exposes the required support.
30
+
31
+ ### Fixed
32
+
33
+ - Built-in Agent Plugin MCP definitions now preserve literal values through connection and cache handling, validate manifest field types, resolve contained paths through symlinks, and expand plugin placeholders once. Thanks to [@cheetahbyte](https://github.com/cheetahbyte) for #570.
34
+ - Empty, whitespace-only, or comments-only optional MCP config layers are now treated as absent, allowing other precedence layers to load without a warning. Thanks to [@RobertoNegro](https://github.com/RobertoNegro) for PR #567.
35
+ - macOS Keychain and Linux Secret Service now keep ordinary OAuth records in one credential item and compact existing chunks on ordinary reads; Windows Credential Manager retains chunking. Thanks to [@jploskonka](https://github.com/jploskonka) for PR #560.
36
+ - Configured direct tools now hot-load from fresh live catalogs even when a server advertises `ttlMs: 0`, while persisted zero-TTL metadata remains non-cacheable. Thanks to [@dsluo](https://github.com/dsluo) for PR #562. (#561)
37
+ - Switching a server between transports (HTTP to stdio command or socket) now drops an inherited `bearerTokenStore` flag alongside the other URL-bound credential fields. Thanks to [@zhulinchng](https://github.com/zhulinchng) for PR #552.
38
+ - Per-origin `caFile` trust now routes same-origin requests through the bundled undici fetch so the custom CA dispatcher matches the fetch implementation on newer Node releases (Node 26 ships undici v8 while the dependency pins undici v6); previously every `caFile` connection failed with `UND_ERR_INVALID_ARG`. Thanks to [@zhulinchng](https://github.com/zhulinchng) for PR #550.
39
+ - MCP Apps now load provider-declared asset, connection, and frame domains through a session-bound sandbox resource navigation with response-level CSP enforcement. Thanks to [@tekumara](https://github.com/tekumara) for #548.
40
+
41
+ ## [2.33.0] - 2026-09-10
42
+
43
+ ### Highlights
44
+ - Install MCP servers from a URL and complete browser OAuth without leaving the scripting workflow.
45
+ - Keep large tool catalogs out of context until search activates the tools you need.
46
+ - Use OAuth more reliably across multiple Pi processes, private gateways, stalled providers, and dynamic loopback callbacks.
47
+ - Connect to private HTTPS servers with custom CA bundles and run stdio servers with tighter environment isolation.
48
+ - Inspect richer tool schemas and filter larger intermediate results safely in MCP scripts.
49
+
50
+ ### Added
51
+ - HTTPS MCP servers can use an origin-scoped `caFile` PEM trust bundle for Streamable HTTP and SSE without disabling certificate verification. Thanks to [@desmonna](https://github.com/desmonna) for #527.
52
+ - `directTools: "search"` keeps direct tools inactive until `mcp({ search })` finds and activates them. Search-mode tools do not count toward the 75-tool advisory. Thanks to [@chiptoe-svg](https://github.com/chiptoe-svg) for PR #525.
53
+ - Install MCP servers from a URL with `mcp({ action: "install", url: "..." })`. Thanks to [@exoulster](https://github.com/exoulster) for PR #532.
54
+ - Script `tools.describe()` now exposes server-advertised output schemas for `data.structuredContent`, including after metadata refreshes. (#522)
55
+ - Stdio MCP servers can set `inheritEnv: false` while retaining platform defaults and explicit `env` values. Thanks to [@zenolam](https://github.com/zenolam) for #509.
56
+ - Local Claude plugin bundles can now be loaded from trusted configured directories, including bundled MCP servers and skills. Thanks to [@gugu91](https://github.com/gugu91) for PR #493.
57
+ - OAuth loopback redirects can use `{port}` with `localhost`, `127.0.0.1`, or `::1` when a provider permits RFC 8252 dynamic ports. Thanks to [@nrutman](https://github.com/nrutman) for PR #483.
58
+ - Runtime MCP status now includes each server's registered direct-tool count, including resource tools. Thanks to [@FischLu](https://github.com/FischLu) for #482.
59
+
60
+ ### Changed
61
+ - Approval brokers now observe and can gate cached MCP calls; session grants apply only on abstention or no claim. Thanks to [@yanqianglu](https://github.com/yanqianglu) for #534.
62
+ - MCP setup and server panels now follow Pi's active theme and TUI components. (#488)
63
+ - MCP sampling requests now route through Pi's `ModelRegistry.complete`, leaving provider authentication, environment, and base URL handling to the host.
64
+ - `mcp({ connect })` now activates newly discovered direct tools from the connection result, so they become available at the correct point in the transcript. (#490) Thanks to [@chiptoe-svg](https://github.com/chiptoe-svg) for PR #494.
65
+ - OAuth transaction support uses pinned MCP SDK preview builds until the supporting SDK release is available on npm.
66
+
67
+ ### Fixed
68
+ - macOS HTTP connection failures to literal private/link-local IPs now retain network details and suggest Local Network Privacy checks without assuming a privacy denial. Thanks to [@tdhooghe](https://github.com/tdhooghe) for #543.
69
+ - OAuth credential updates now coordinate across Pi processes, release cleanly after failures and cancellation, and keep callback tokens bound to the client that requested them. Optional `PI_MCP_OAUTH_LOG` diagnostics identify transactions without logging credentials. Thanks to [@CharlesMcMillan](https://github.com/CharlesMcMillan) for PR #528.
70
+ - MCP runtime cancellation now works on Node 20.0.0 when `AbortSignal.any` is unavailable. (#537)
71
+ - OAuth now forwards configured service headers to same-origin discovery, registration, token exchange, and refresh requests, enabling authentication behind service-token gateways without leaking credentials to other origins. Thanks to [@ethanbrown3](https://github.com/ethanbrown3) for PR #533 and [@Davasny](https://github.com/Davasny) for reporting #530.
72
+ - Script `mcp({ action: "auth-start" })` now opens the authorization URL and watches the loopback callback to complete OAuth automatically, while retaining pasted `auth-complete` as a fallback. Thanks to [@exoulster](https://github.com/exoulster) for PR #532.
73
+ - Namespace proxy tool names now stay within provider limits without creating collisions for long server names. Thanks to [@saikpr](https://github.com/saikpr) for PR #529.
74
+ - Script calls now preserve intermediate data for filtering within a fixed 16 MiB cumulative transfer budget while retaining final-output limits. (#520)
75
+ - Namespace proxy argument guidance now uses exact search-result tool names for schema inspection. Thanks to [@r1ckyIn](https://github.com/r1ckyIn) for PR #519.
76
+ - Script `tools.describe()` now retains documented input field guidance alongside compact parameter shapes, including formats and units. (#521)
77
+ - Early MCP tool discovery now honors `--mcp-config=<path>`, including paths containing `=`. (#512)
78
+ - Updated `qs` to patched version 6.16.0. (#517)
79
+ - The optional `@earendil-works/pi-ai` peer now supports Pi 0.85 alongside 0.84.1, avoiding npm resolution conflicts. Thanks to [@dyld-w](https://github.com/dyld-w) for #507.
80
+ - Session-scoped MCP tool approvals and MCP App iframe consent now persist on and restore from the active Pi session branch. (#492)
81
+ - The `/mcp` panel no longer marks reconnects as cached when no cache entry was restored. Thanks to [@fyq163](https://github.com/fyq163) for #497.
82
+ - MCP output truncation now uses Pi host truncation semantics and formatting while preserving MCP artifact spill behavior.
83
+ - Updated Ajv's transitive `fast-uri` dependency to patched version 3.1.7. Thanks to [@escuelallenquen](https://github.com/escuelallenquen) for #513.
84
+ - Exclusive mode now honors an explicit `--mcp-config` override instead of always loading the agent-global configuration. Thanks to [@willem445](https://github.com/willem445) for #496.
85
+ - OAuth discovery, dynamic registration, token exchange, and token refresh requests now have a timeout and honor cancellation instead of hanging the agent on stalled providers. Thanks to [@west-david](https://github.com/west-david) for #485 and PR #486.
86
+ - OAuth redirect URI mismatches now preserve refreshable credentials and re-register stale dynamic clients after `invalid_grant`. Thanks to [@CharlesMcMillan](https://github.com/CharlesMcMillan) for PR #495.
87
+
10
88
  ## [2.32.1] - 2026-09-01
11
89
 
12
90
  ### Fixed
@@ -1,7 +1,7 @@
1
1
  # pi-web-access upstream tracking
2
2
 
3
3
  The vendored implementation in `vendor/` is based on
4
- [`pi-web-access`](https://github.com/nicobailon/pi-web-access) version `0.28.0`
4
+ [`pi-web-access`](https://github.com/nicobailon/pi-web-access) version `0.29.0`
5
5
  and remains licensed under the upstream MIT license in `vendor/LICENSE`.
6
6
 
7
7
  `upstream.json` records the npm tarball URL, SHA-1 shasum, SHA-512 integrity,
@@ -16,13 +16,23 @@ TypeScript runtime files and license, reapplying the config-directory changes
16
16
  listed in `upstream.json`, updating the metadata, and running the focused tests,
17
17
  `npm run check`, and local Node/Bun release smoke tests.
18
18
 
19
- The 0.28.0 refresh was reviewed against both published npm tarballs with their
20
- SHA-1 and SHA-512 metadata verified. It adds opt-in Mistral and xAI X search,
21
- ordered concurrent query batches, stored-result identifiers in tool output,
22
- preserved cited Perplexity sources, and abandoned GitHub clone cleanup. Runtime
19
+ The 0.29.0 refresh was reviewed against both published npm tarballs with their
20
+ SHA-1 and SHA-512 metadata verified. It adds SerpApi as an opt-in, key-gated
21
+ Google search provider that stays outside the all-provider fan-out, a
22
+ self-hosted Crawl4AI extraction fallback and SOCKS4/4a/5/5h proxy schemes that
23
+ are both operator opt-in, an approve-remaining-searches curator action, and
24
+ on-demand loading of extraction and AI features. It also refuses to pair a
25
+ custom-`baseUrl` OpenAI credential with the official Responses endpoint and
26
+ stops a loopback redirect from pivoting onto another loopback origin. Runtime
23
27
  dependencies, lifecycle scripts, and the MIT license are unchanged.
24
28
 
25
29
  The three-way refresh retains HUMAIN's `getAgentDir()` config lookup instead
26
- of Pi's XDG/legacy lookup and keeps explicit null proxy scopes so direct web
27
- requests cannot inherit an outer proxy decision. Other recorded HUMAIN patches
28
- remain in place. Mistral remains excluded from automatic all-provider fan-out.
30
+ of Pi's XDG/legacy lookup, which supersedes upstream's own move to
31
+ `~/.pi/agent`, and keeps explicit null proxy scopes so direct web requests
32
+ cannot inherit an outer proxy decision. SOCKS proxy URLs are routed through
33
+ HUMAIN's curl stdin-config transport, so a proxy URL carrying credentials
34
+ never reaches the process argument list. Where upstream moved a patched
35
+ import behind a lazy `import()`, the HUMAIN host-shim swap moved with it, so
36
+ `curator-run.ts` now carries a patch and is recorded in `upstream.json`. Other
37
+ recorded HUMAIN patches remain in place. Mistral and SerpApi are both excluded
38
+ from automatic all-provider fan-out.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pi-web-access",
3
3
  "repository": "https://github.com/nicobailon/pi-web-access",
4
- "version": "0.28.0",
5
- "tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.28.0.tgz",
6
- "shasum": "fa14439d050527f994003c981a1bde7fdde146b0",
7
- "integrity": "sha512-NMiRWiRXt46oNOoef+9WUN9IKzwADXuM9Wu6fPgMBScIVO8wQK3+dUV0CkmkvTHWADv8PBCqxcDSufVwqF++9Q==",
4
+ "version": "0.29.0",
5
+ "tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.29.0.tgz",
6
+ "shasum": "3b1bf8c63920221f9b34856f1eca65db4b97d3b1",
7
+ "integrity": "sha512-1l4sAWYkFhiBynJf/mXuxmCHxjhiAyWJ4rfQVFu8UPa0JQhCS9oXAmNXcL0Q1SfrO00plmb6L4IkypJ3n1Q4Kg==",
8
8
  "humainPatches": [
9
9
  "extract.ts",
10
10
  "gemini-adc.ts",
@@ -20,6 +20,7 @@
20
20
  "declared-web-links.ts",
21
21
  "perplexity.ts",
22
22
  "summary-model-scope.ts",
23
- "utils.ts"
23
+ "utils.ts",
24
+ "curator-run.ts"
24
25
  ]
25
26
  }