@humain/humain-code 0.6.1 → 0.6.2

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 (207) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/bundle/agent-monitor.js +1 -1
  3. package/dist/bundle/chunks/{anthropic-messages-FGFIMZUF.js → anthropic-messages-MNISFDZA.js} +2 -2
  4. package/dist/bundle/chunks/{azure-openai-responses-6JNTC7KO.js → azure-openai-responses-IV74M5OR.js} +3 -3
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +4 -5
  6. package/dist/bundle/chunks/{chunk-CVC2GV26.js → chunk-2HZ2V3HS.js} +610 -611
  7. package/dist/bundle/chunks/{chunk-IJYVMOB4.js → chunk-2PZ46FSM.js} +3 -3
  8. package/dist/bundle/chunks/{chunk-I6AQOITY.js → chunk-3LP543EX.js} +6 -6
  9. package/dist/bundle/chunks/{chunk-FDGW5ZTG.js → chunk-4J6BGNX2.js} +6 -6
  10. package/dist/bundle/chunks/{chunk-EDONIPUJ.js → chunk-4SQUP6IR.js} +7 -7
  11. package/dist/bundle/chunks/{chunk-P4P7OZ7R.js → chunk-5L4JG6PO.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-GICL5V54.js → chunk-6PD3T2EF.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-CFHOPLW5.js → chunk-75CQYZ63.js} +56 -54
  14. package/dist/bundle/chunks/{chunk-DHW3REC5.js → chunk-A2VPLMF2.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-AOH2O5CP.js → chunk-DCPACGLH.js} +575 -538
  16. package/dist/bundle/chunks/{chunk-M4CHQBAI.js → chunk-DLCBSLHW.js} +1 -1
  17. package/dist/bundle/chunks/chunk-F77J5EQZ.js +3 -0
  18. package/dist/bundle/chunks/{chunk-T3KDZFM4.js → chunk-FHLLDO7U.js} +7 -6
  19. package/dist/bundle/chunks/{chunk-AHSNQWZU.js → chunk-FLVBQ6GS.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-ONR6Q3II.js → chunk-JCTQQ3DX.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-YRUIJ5AH.js → chunk-JEAM6N22.js} +6 -5
  22. package/dist/bundle/chunks/{chunk-LDGCU6PD.js → chunk-K7SDY3VJ.js} +1 -1
  23. package/dist/bundle/chunks/{chunk-IADQJFNH.js → chunk-KM4GQ2BU.js} +5 -4
  24. package/dist/bundle/chunks/{chunk-JFE52VSN.js → chunk-NCC2FAJN.js} +23 -22
  25. package/dist/bundle/chunks/{chunk-RO5YPAJH.js → chunk-PS2FJ7M4.js} +1 -1
  26. package/dist/bundle/chunks/{chunk-HW6HMUXS.js → chunk-SFMDIVZ4.js} +1 -1
  27. package/dist/bundle/chunks/{chunk-B7NJMF7B.js → chunk-WEFEQEIQ.js} +4 -4
  28. package/dist/bundle/chunks/{chunk-6DE7LJKV.js → chunk-WW4SILXG.js} +24 -19
  29. package/dist/bundle/chunks/{cli-BNCWK54K.js → cli-N7KOVPLB.js} +1 -1
  30. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KI6W3USX.js → cloudflare-workers-ai-system-one-KRMHG2L3.js} +1 -1
  31. package/dist/bundle/chunks/codemode-worker.js +10 -4
  32. package/dist/bundle/chunks/{compat-I5VPOXFT.js → compat-MXAZPYDN.js} +9 -9
  33. package/dist/bundle/chunks/{dist-SKBR3C7C.js → dist-3V7ZSLER.js} +29 -26
  34. package/dist/bundle/chunks/dist-66CW64M2.js +8 -0
  35. package/dist/bundle/chunks/{easter-egg-3d-673VRP6Y.js → easter-egg-3d-O2GG2XIG.js} +1 -1
  36. package/dist/bundle/chunks/{execute-PIUR5MUV.js → execute-LMBACTKA.js} +28 -23
  37. package/dist/bundle/chunks/{extract-4O5Z5725.js → extract-CXXLVFC5.js} +7 -7
  38. package/dist/bundle/chunks/{google-generative-ai-635YZEHN.js → google-generative-ai-SBL77OXO.js} +4 -4
  39. package/dist/bundle/chunks/{google-vertex-I3ZJ3SB2.js → google-vertex-NZBNNXMK.js} +6 -6
  40. package/dist/bundle/chunks/{host-OQOEIWHK.js → host-SCZ4IKWR.js} +1 -1
  41. package/dist/bundle/chunks/{mistral-conversations-OKG5GKXR.js → mistral-conversations-DX4YKJSO.js} +14 -13
  42. package/dist/bundle/chunks/{openai-codex-responses-6JYZIFT4.js → openai-codex-responses-LZWBQYVP.js} +38 -37
  43. package/dist/bundle/chunks/{openai-completions-YBNI6CAP.js → openai-completions-7NWH423P.js} +2 -2
  44. package/dist/bundle/chunks/{openai-decisions-5G5YBFRQ.js → openai-decisions-ALJROWBE.js} +1 -1
  45. package/dist/bundle/chunks/{openai-responses-C3APJ6MK.js → openai-responses-5YOLHMCF.js} +3 -3
  46. package/dist/bundle/chunks/{pi-messages-UHYZYEOC.js → pi-messages-NHTQQOPW.js} +1 -1
  47. package/dist/bundle/chunks/{runtime-KE3HDSRT.js → runtime-UVPDE4CX.js} +1 -1
  48. package/dist/bundle/chunks/{typesafe-system-one-VYVAMWQV.js → typesafe-system-one-BHJYAZ6E.js} +1 -1
  49. package/dist/bundle/chunks/virtual-modules-YQPK57CW.js +23 -0
  50. package/dist/bundle/cli-runtime.js +3 -3
  51. package/dist/bundle/index.js +6 -6
  52. package/dist/bundle/rpc-entry.js +2 -2
  53. package/dist/coordination/adapter/commands-integration.d.ts +2 -2
  54. package/dist/coordination/adapter/commands-integration.d.ts.map +1 -1
  55. package/dist/coordination/adapter/commands-integration.js +14 -10
  56. package/dist/coordination/adapter/commands-integration.js.map +1 -1
  57. package/dist/coordination/adapter/delivery.d.ts +3 -0
  58. package/dist/coordination/adapter/delivery.d.ts.map +1 -1
  59. package/dist/coordination/adapter/delivery.js +4 -1
  60. package/dist/coordination/adapter/delivery.js.map +1 -1
  61. package/dist/coordination/adapter/index.d.ts.map +1 -1
  62. package/dist/coordination/adapter/index.js +26 -2
  63. package/dist/coordination/adapter/index.js.map +1 -1
  64. package/dist/coordination/adapter/integration-notices.d.ts +2 -2
  65. package/dist/coordination/adapter/integration-notices.d.ts.map +1 -1
  66. package/dist/coordination/adapter/integration-notices.js +5 -3
  67. package/dist/coordination/adapter/integration-notices.js.map +1 -1
  68. package/dist/coordination/adapter/integration-tool.d.ts +2 -1
  69. package/dist/coordination/adapter/integration-tool.d.ts.map +1 -1
  70. package/dist/coordination/adapter/integration-tool.js +11 -10
  71. package/dist/coordination/adapter/integration-tool.js.map +1 -1
  72. package/dist/coordination/adapter/peer-label.d.ts +5 -0
  73. package/dist/coordination/adapter/peer-label.d.ts.map +1 -0
  74. package/dist/coordination/adapter/peer-label.js +38 -0
  75. package/dist/coordination/adapter/peer-label.js.map +1 -0
  76. package/dist/coordination/adapter/render.d.ts +19 -0
  77. package/dist/coordination/adapter/render.d.ts.map +1 -0
  78. package/dist/coordination/adapter/render.js +107 -0
  79. package/dist/coordination/adapter/render.js.map +1 -0
  80. package/dist/coordination/adapter/tool.d.ts +12 -3
  81. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  82. package/dist/coordination/adapter/tool.js +69 -32
  83. package/dist/coordination/adapter/tool.js.map +1 -1
  84. package/dist/coordination/broker/broker.d.ts +4 -1
  85. package/dist/coordination/broker/broker.d.ts.map +1 -1
  86. package/dist/coordination/broker/broker.js +146 -60
  87. package/dist/coordination/broker/broker.js.map +1 -1
  88. package/dist/coordination/client/client.d.ts.map +1 -1
  89. package/dist/coordination/client/client.js +10 -2
  90. package/dist/coordination/client/client.js.map +1 -1
  91. package/dist/coordination/transport/discovery.d.ts +4 -0
  92. package/dist/coordination/transport/discovery.d.ts.map +1 -1
  93. package/dist/coordination/transport/discovery.js +14 -0
  94. package/dist/coordination/transport/discovery.js.map +1 -1
  95. package/dist/coordination/transport/protocol.d.ts.map +1 -1
  96. package/dist/coordination/transport/protocol.js +3 -0
  97. package/dist/coordination/transport/protocol.js.map +1 -1
  98. package/dist/coordination/transport/types.d.ts +5 -1
  99. package/dist/coordination/transport/types.d.ts.map +1 -1
  100. package/dist/coordination/transport/types.js.map +1 -1
  101. package/dist/core/agent-session.d.ts.map +1 -1
  102. package/dist/core/agent-session.js +6 -2
  103. package/dist/core/agent-session.js.map +1 -1
  104. package/dist/core/bash-executor.d.ts.map +1 -1
  105. package/dist/core/bash-executor.js +13 -36
  106. package/dist/core/bash-executor.js.map +1 -1
  107. package/dist/core/bedrock-account-reporting.d.ts.map +1 -1
  108. package/dist/core/bedrock-account-reporting.js +2 -1
  109. package/dist/core/bedrock-account-reporting.js.map +1 -1
  110. package/dist/core/cache-warmer.d.ts.map +1 -1
  111. package/dist/core/cache-warmer.js +2 -2
  112. package/dist/core/cache-warmer.js.map +1 -1
  113. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  114. package/dist/core/compaction/branch-summarization.js +3 -2
  115. package/dist/core/compaction/branch-summarization.js.map +1 -1
  116. package/dist/core/compaction/compaction.d.ts.map +1 -1
  117. package/dist/core/compaction/compaction.js +2 -2
  118. package/dist/core/compaction/compaction.js.map +1 -1
  119. package/dist/core/extensions/runner.d.ts.map +1 -1
  120. package/dist/core/extensions/runner.js +2 -0
  121. package/dist/core/extensions/runner.js.map +1 -1
  122. package/dist/core/model-runtime.d.ts +2 -0
  123. package/dist/core/model-runtime.d.ts.map +1 -1
  124. package/dist/core/model-runtime.js +7 -7
  125. package/dist/core/model-runtime.js.map +1 -1
  126. package/dist/core/sdk.d.ts.map +1 -1
  127. package/dist/core/sdk.js +8 -0
  128. package/dist/core/sdk.js.map +1 -1
  129. package/dist/core/session-manager.d.ts +6 -0
  130. package/dist/core/session-manager.d.ts.map +1 -1
  131. package/dist/core/session-manager.js +27 -6
  132. package/dist/core/session-manager.js.map +1 -1
  133. package/dist/core/tools/bash.d.ts +2 -1
  134. package/dist/core/tools/bash.d.ts.map +1 -1
  135. package/dist/core/tools/bash.js +39 -3
  136. package/dist/core/tools/bash.js.map +1 -1
  137. package/dist/core/tools/index.d.ts +1 -1
  138. package/dist/core/tools/index.d.ts.map +1 -1
  139. package/dist/core/tools/index.js.map +1 -1
  140. package/dist/core/tools/output-accumulator.d.ts +5 -1
  141. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  142. package/dist/core/tools/output-accumulator.js +45 -16
  143. package/dist/core/tools/output-accumulator.js.map +1 -1
  144. package/dist/core/tools/render-utils.d.ts.map +1 -1
  145. package/dist/core/tools/render-utils.js +2 -2
  146. package/dist/core/tools/render-utils.js.map +1 -1
  147. package/dist/core/tools/renderers/write.js +2 -2
  148. package/dist/core/tools/renderers/write.js.map +1 -1
  149. package/dist/core/tools/subagent.d.ts +22 -0
  150. package/dist/core/tools/subagent.d.ts.map +1 -1
  151. package/dist/core/tools/subagent.js +46 -7
  152. package/dist/core/tools/subagent.js.map +1 -1
  153. package/dist/core/trace-client/credential-store.d.ts.map +1 -1
  154. package/dist/core/trace-client/credential-store.js +2 -0
  155. package/dist/core/trace-client/credential-store.js.map +1 -1
  156. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  157. package/dist/extensions/codemode/execute.js +3 -12
  158. package/dist/extensions/codemode/execute.js.map +1 -1
  159. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +10 -6
  160. package/dist/humain/gateway/secret-store.d.ts.map +1 -1
  161. package/dist/humain/gateway/secret-store.js +26 -12
  162. package/dist/humain/gateway/secret-store.js.map +1 -1
  163. package/dist/humain/gateway/session-store.d.ts +2 -2
  164. package/dist/humain/gateway/session-store.d.ts.map +1 -1
  165. package/dist/humain/gateway/session-store.js +13 -3
  166. package/dist/humain/gateway/session-store.js.map +1 -1
  167. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  168. package/dist/humain/web-access/vendor/extract.js +4 -2
  169. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  170. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  171. package/dist/humain/web-access/vendor/page-query.js +2 -1
  172. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  173. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  174. package/dist/humain/web-access/vendor/query-rewrite.js +2 -1
  175. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  176. package/dist/humain/web-access/vendor/storage.d.ts +2 -0
  177. package/dist/humain/web-access/vendor/storage.d.ts.map +1 -1
  178. package/dist/humain/web-access/vendor/storage.js +71 -9
  179. package/dist/humain/web-access/vendor/storage.js.map +1 -1
  180. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  181. package/dist/humain/web-access/vendor/summary-review.js +2 -1
  182. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  183. package/dist/index.d.ts +1 -1
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js.map +1 -1
  186. package/dist/main.d.ts.map +1 -1
  187. package/dist/main.js +3 -3
  188. package/dist/main.js.map +1 -1
  189. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  190. package/dist/modes/interactive/components/mermaid.js +71 -34
  191. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  192. package/dist/utils/child-process.d.ts.map +1 -1
  193. package/dist/utils/child-process.js +16 -0
  194. package/dist/utils/child-process.js.map +1 -1
  195. package/docs/coordination.md +6 -2
  196. package/docs/development.md +4 -0
  197. package/docs/extensions.md +2 -0
  198. package/docs/providers.md +12 -2
  199. package/examples/extensions/gondolin/index.ts +1 -1
  200. package/examples/extensions/ssh.ts +34 -5
  201. package/npm-shrinkwrap.json +2 -2
  202. package/package.json +1 -1
  203. package/src/coordination/UPSTREAM.md +17 -0
  204. package/src/humain/web-access/UPSTREAM.md +11 -0
  205. package/dist/bundle/chunks/chunk-L6Z6JKKC.js +0 -3
  206. package/dist/bundle/chunks/dist-TVRQXUY6.js +0 -8
  207. package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +0 -23
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.2] - 2026-11-08
4
+
5
+ ### New Features
6
+
7
+ - HUMAIN Gateway sign-in works on WSL: the session key is stored in Windows Credential Manager through Windows PowerShell. See [Linux and WSL prerequisites](docs/providers.md#linux-and-wsl-prerequisites).
8
+ - `fetch_content` works again in the installed CLI (broken in 0.5.4 and 0.6.1).
9
+ - Efficiency and resource-safety fixes from the 2026-11-07 audit ([#82](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/82)): bounded HTTP, shell-output and web-fetch memory, correct retry totals, and faster streaming renders and fullscreen search. Most gains are small in typical sessions; see the issue for measured end-to-end effects.
10
+
11
+ ### Added
12
+
13
+ - Added offline built-artifact efficiency budgets with seven-run medians, a 15% regression limit and platform baselines via `npm run bench:budgets` ([#107](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/107)).
14
+
15
+ ### Changed
16
+
17
+ - Coordination shows readable peer identities, advisory inbound cards and delivery-state outbound cards, with expandable audit details and live suffix-handle addressing ([#63](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/63)).
18
+ - The owner granted a one-time paid Flow eval release-gate waiver for HUMAIN Code CLI 0.6.2 (2026-11-08): Flow gate baselines still do not exist, so a gate run cannot pass. No passing Flow gate is claimed; the CI full test suite and Node/Bun smoke tests remain required.
19
+
20
+ ### Fixed
21
+
22
+ - Bounded MCP and provider HTTP response reads before parsing and preserved request cancellation through response bodies without cancelling shared authorization recovery or GET streams ([#83](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/83))
23
+ - Shell output pauses both stdout and stderr while spill files drain, preserving complete output without an unbounded write queue ([#84](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/84)).
24
+ - Bounded live web-fetch payload memory independently of disk storage, preserving session-owned metadata and disk reloads while limiting spill-failure fallback; copied bounded metadata so substrings cannot retain full page buffers ([#85](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/85))
25
+ - Native subagent retry totals include every attempt, retain compact per-attempt accounting separately from final-attempt usage, and agree with live Flow accounting ([#86](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/86))
26
+ - Skip context clones and tool-result snapshots for unused extension hooks, preserve JSON-string reuse when no provider payload handler is registered, and deliver request events to handlers registered during header transforms ([#87](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/87))
27
+ - Result-only model completions, summaries, and cache warming discard privately owned stream events without changing public buffered replay or custom iteration ([#88](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/88))
28
+ - Compacted-context sizing no longer copies or searches summarized history, while preserving revision caching and stale-usage rules ([#89](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/89))
29
+ - Codex SSE no longer retries permanent HTTP failures as network errors when a retry budget is configured; transient retries, server delays, and usage-limit diagnostics remain intact ([#100](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/100))
30
+ - Reused strict tool-schema preparation within each OpenAI Responses and Google request without caching mutable tool definitions across requests ([#101](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/101))
31
+ - Flow file hashing reuses bounded observation-local scratch while preserving content hashes, file identity, byte caps, and deadlines ([#90](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/90))
32
+ - Flow shares compatible non-signalling process observations within each monitor tick while retaining independent fresh identity checks before signalling ([#91](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/91))
33
+ - Scan session JSONL chunks without rescanning unfinished record prefixes, preserving UTF-8 decoding, malformed-line handling, and unterminated-tail repair ([#92](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/92))
34
+ - Prepared branch-summary messages in linear time while preserving chronological identity, token-budget admission, and control-denial filtering ([#93](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/93))
35
+ - CLI codemode return values share helper output limits before crossing the VM bridge, preserving generic sandbox returns and committing store writes only on success ([#99](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/99))
36
+ - Avoided native whole-prefix checks in growing write previews while preserving terminal sanitation and replacement handling ([#94](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/94))
37
+ - Mermaid streaming skips lexer work for prose mentions and reuses completed diagrams while preserving split-fence detection and authoritative final parsing ([#95](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/95))
38
+ - Native Markdown code cards skip dense source-offset maps when normalization preserves UTF-16 offsets, retaining exact clipboard text and nested source recovery ([#96](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/96))
39
+ - Fullscreen search reuses unchanged transcript indexes and rebuilds only changed row suffixes, preserving Unicode columns and matches across row boundaries ([#97](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/97))
40
+ - Batch durable mailbox retirements within inbound receipt reads before reporting success; failed saves keep mail, report failure and reconnect the receiver for deduplicated redelivery and receipt replay ([#98](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/98))
41
+ - Direct TUI startup profiling honors the HUMAIN benchmark flag with a PI fallback and kills timed-out children instead of hanging ([#102](https://gitlab.humain.com/humain/data-and-ai-modeling/standard/agentic/humain-terminal/-/issues/102))
42
+ - `fetch_content` works again in the installed CLI: the bundled `@mozilla/readability` and `defuddle/node` chunks expose only a default export, so pages failed with "Readability is not a constructor" or "Defuddle is not a function" (source runs were unaffected). Bedrock account reporting had the same problem with the CloudWatch client. A bundle test now rejects named imports from such chunks.
43
+ - HUMAIN Gateway sessions on WSL use Windows Credential Manager instead of a Linux keyring; logins stored in a Linux keyring by older versions are not migrated, so sign in again.
44
+
3
45
  ## [0.6.1] - 2026-11-07
4
46
 
5
47
  ### Fixed
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{runAgentMonitorCommand}from"./chunks/chunk-LDGCU6PD.js";import"./chunks/chunk-VEGJT52D.js";import"./chunks/chunk-IADQJFNH.js";import"./chunks/chunk-JXWJOIH4.js";process.exitCode=await runAgentMonitorCommand(process.env);
2
+ import{runAgentMonitorCommand}from"./chunks/chunk-K7SDY3VJ.js";import"./chunks/chunk-VEGJT52D.js";import"./chunks/chunk-KM4GQ2BU.js";import"./chunks/chunk-JXWJOIH4.js";process.exitCode=await runAgentMonitorCommand(process.env);
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
2
  import{applyOpenRouterReportedCost,isOpenRouterModel}from"./chunk-J7AP2BUJ.js";import{buildCopilotDynamicHeaders,hasCopilotVisionInput}from"./chunk-JEJQVFWK.js";import{iterateSseMessages}from"./chunk-YZMQXAJM.js";import{getServerRetryDelayMs,retryProviderRequest}from"./chunk-BQ3TMEWD.js";import{cacheJsonSerialization}from"./chunk-Q7VXYXY3.js";import{adjustMaxTokensForThinking,buildBaseOptions,clampMaxTokensToContext,getJsonSchemaToolParameters,prefersJsonSchemaStrictSampling,
3
- resolveJsonSchemaStrictSampling,splitErrorToolResultImages,transformMessages}from"./chunk-T3KDZFM4.js";import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import"./chunk-TEOMXMW6.js";import{createRequestObserver,headersToRecord}from"./chunk-5JSLXC2A.js";import{ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV}from"./chunk-KQM7ZGL6.js";
4
- import{getProviderEnvValue}from"./chunk-FACBDLFU.js";import{ToolCallArgumentsStream,parseJsonWithRepair}from"./chunk-NN53K2QQ.js";import{calculateCost,getCurrentTools,getInitialSystemMessage,resolveTranscript}from"./chunk-EDONIPUJ.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import{appendAssistantMessageDiagnostic,getIdentityHeaders,getSystemMessageText,renderSystemMessageUpdate,reportContentProgress}from"./chunk-XMZGB3H4.js";import{Anthropic}from"./chunk-RGUZULEE.js";
3
+ resolveJsonSchemaStrictSampling,splitErrorToolResultImages,transformMessages}from"./chunk-FHLLDO7U.js";import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import"./chunk-TEOMXMW6.js";import{createRequestObserver,headersToRecord}from"./chunk-5JSLXC2A.js";import{ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV}from"./chunk-KQM7ZGL6.js";
4
+ import{getProviderEnvValue}from"./chunk-FACBDLFU.js";import{ToolCallArgumentsStream,parseJsonWithRepair}from"./chunk-NN53K2QQ.js";import{calculateCost,getCurrentTools,getInitialSystemMessage,resolveTranscript}from"./chunk-4SQUP6IR.js";import{AssistantMessageEventStream}from"./chunk-2PZ46FSM.js";import{appendAssistantMessageDiagnostic,getIdentityHeaders,getSystemMessageText,renderSystemMessageUpdate,reportContentProgress}from"./chunk-XMZGB3H4.js";import{Anthropic}from"./chunk-RGUZULEE.js";
5
5
  import"./chunk-JXWJOIH4.js";function supportsDisabledAnthropicThinking(model){let name=`${model.id} ${model.name}`.toLowerCase().replace(/[.\s]+/g,"-");return model.thinkingLevelMap?.off!==null&&!/(?:fable-5|mythos-(?:5|preview)|opus-5-5|sonnet-5-5)(?:-|$)/.test(name)}function resolveCacheRetention(cacheRetention,env){return cacheRetention||(getProviderEnvValue("HUMAIN_TERMINAL_CACHE_RETENTION",env)==="long"||getProviderEnvValue("PI_CACHE_RETENTION",env)==="long"?"long":"short")}function getCacheControl(model,cacheRetention,env){let retention=resolveCacheRetention(cacheRetention,env);if(retention==="none")return{retention};let ttl=retention==="long"&&getAnthropicCompat(model).supportsLongCacheRetention?"1h":void 0;return{retention,cacheControl:{type:"ephemera\
6
6
  l",...ttl&&{ttl}}}}var claudeCodeVersion="2.1.280",claudeCodeTools=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],ccToolLookup=new Map(claudeCodeTools.map(t=>[t.toLowerCase(),t])),toClaudeCodeName=name=>ccToolLookup.get(name.toLowerCase())??name,fromClaudeCodeName=(name,tools)=>{if(tools&&tools.length>0){let lowerName=name.toLowerCase(),matchedTool=tools.find(tool=>tool.
7
7
  name.toLowerCase()===lowerName);if(matchedTool)return matchedTool.name}return name};function convertImageBlock(image){return{type:"image",source:{type:"base64",media_type:image.mimeType,data:image.data}}}function convertContentBlocks(content){if(!content.some(c=>c.type==="image"))return sanitizeSurrogates(content.map(c=>c.text).join(`
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{convertResponsesMessages,convertResponsesTools,getResponsesToolSupport,processResponsesStream}from"./chunk-I6AQOITY.js";import{iterateOpenAIStream}from"./chunk-4ZBGTJJM.js";import{clampOpenAIPromptCacheKey}from"./chunk-PRRNXB7S.js";import{AzureOpenAI}from"./chunk-PCTLFSQG.js";import"./chunk-YZMQXAJM.js";import{getServerRetryDelayMs,retryProviderRequest}from"./chunk-BQ3TMEWD.js";import"./chunk-PJACZCIR.js";import{cacheJsonSerialization}from"./chunk-Q7VXYXY3.js";
3
- import{buildBaseOptions,createGrammarToolInputProperties,resolveSamplingParams}from"./chunk-T3KDZFM4.js";import"./chunk-YTVFIA3A.js";import"./chunk-L2ZPNLYD.js";import{formatProviderError,normalizeProviderError}from"./chunk-TEOMXMW6.js";import{createRequestObserver,headersToRecord,observeFetch}from"./chunk-5JSLXC2A.js";import{resolveAzureConfig,resolveDeploymentName}from"./chunk-CIA6V3BP.js";import"./chunk-FACBDLFU.js";import"./chunk-NN53K2QQ.js";import{
4
- clampThinkingLevel,getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-EDONIPUJ.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import{getIdentityHeaders}from"./chunk-XMZGB3H4.js";import"./chunk-JXWJOIH4.js";var AZURE_TOOL_CALL_PROVIDERS=new Set(["openai","openai-codex","opencode","azure"]),OPENAI_RESPONSES_MIN_OUTPUT_TOKENS=16;function formatAzureOpenAIError(error){return formatProviderError(normalizeProviderError(error),"Azure OpenAI API error")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,model.compat?.supportsMidConvoSystemMessages);return(async()=>{let deploymentName=resolveDeploymentName(model,options),output={role:"\
2
+ import{convertResponsesMessages,convertResponsesTools,getResponsesToolSupport,processResponsesStream}from"./chunk-3LP543EX.js";import{iterateOpenAIStream}from"./chunk-4ZBGTJJM.js";import{clampOpenAIPromptCacheKey}from"./chunk-PRRNXB7S.js";import{AzureOpenAI}from"./chunk-PCTLFSQG.js";import"./chunk-YZMQXAJM.js";import{getServerRetryDelayMs,retryProviderRequest}from"./chunk-BQ3TMEWD.js";import"./chunk-PJACZCIR.js";import{cacheJsonSerialization}from"./chunk-Q7VXYXY3.js";
3
+ import{buildBaseOptions,createGrammarToolInputProperties,resolveSamplingParams}from"./chunk-FHLLDO7U.js";import"./chunk-YTVFIA3A.js";import"./chunk-L2ZPNLYD.js";import{formatProviderError,normalizeProviderError}from"./chunk-TEOMXMW6.js";import{createRequestObserver,headersToRecord,observeFetch}from"./chunk-5JSLXC2A.js";import{resolveAzureConfig,resolveDeploymentName}from"./chunk-CIA6V3BP.js";import"./chunk-FACBDLFU.js";import"./chunk-NN53K2QQ.js";import{
4
+ clampThinkingLevel,getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-4SQUP6IR.js";import{AssistantMessageEventStream}from"./chunk-2PZ46FSM.js";import{getIdentityHeaders}from"./chunk-XMZGB3H4.js";import"./chunk-JXWJOIH4.js";var AZURE_TOOL_CALL_PROVIDERS=new Set(["openai","openai-codex","opencode","azure"]),OPENAI_RESPONSES_MIN_OUTPUT_TOKENS=16;function formatAzureOpenAIError(error){return formatProviderError(normalizeProviderError(error),"Azure OpenAI API error")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,model.compat?.supportsMidConvoSystemMessages);return(async()=>{let deploymentName=resolveDeploymentName(model,options),output={role:"\
5
5
  assistant",content:[],api:"azure-openai-responses",provider:model.provider,model:model.id,usage:{usageIncomplete:!0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),client=createClient(
6
6
  model,apiKey,options,observeFetch(options?.fetch,observe)),grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages),model.compat?.supportsOpenAIGrammarTools??!1),params=buildParams(model,normalizedContext,options,deploymentName,grammarToolInputProperties),onPayload=options?.onPayload,nextParams=await onPayload?.call(options,params,model);nextParams!==void 0&&(params=nextParams),onPayload||cacheJsonSerialization(params.input);let requestOptions={...options?.
7
7
  signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},maxRetries:0},{data:openaiStream,response}=await retryProviderRequest(()=>client.responses.create(params,requestOptions).withResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});if(await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output}),await processResponsesStream(
@@ -1433,9 +1433,8 @@ s2.listenerCount("data")>0),s2.push(buffered),s2.push(null)}),fakeSocket}async _
1433
1433
  s"];function resume(socket){setImmediate(()=>{socket.resume()})}function omit2(obj,...keys){let ret={},key;for(key in obj)keys.includes(key)||(ret[key]=obj[key]);return ret}var streamProgress=new WeakMap,streamProgressKey=Symbol.for("@humain/pi-ai/private-stream-progress");function getStreamProgress(signal){if(!signal)return;let local=streamProgress.get(signal);if(local)return local;try{let reference=Object.getOwnPropertyDescriptor(signal,streamProgressKey)?.value,state2=WeakRef.prototype.deref.call(reference);if(state2===null||typeof state2!="object")return;let onContent=Object.getOwnPropertyDescriptor(state2,"onContent"),retryAt=Object.getOwnPropertyDescriptor(state2,
1434
1434
  "retryAt");return typeof onContent?.value!="function"||retryAt&&(typeof retryAt.value!="number"||!Number.isFinite(retryAt.value)||retryAt.value<=0)?void 0:state2}catch{return}}function reportContentProgress(signal){let progress=getStreamProgress(signal);if(!progress)return;let onContent;try{onContent=Object.getOwnPropertyDescriptor(progress,"onContent")?.value}catch{return}typeof onContent=="function"&&onContent()}function appendAssistantMessageDiagnostic(message,diagnostic){message.diagnostics=[...message.diagnostics??[],diagnostic]}var FifoQueue=class{incoming=[];outgoing=[];get length(){return this.incoming.length+this.outgoing.length}enqueue(value){this.incoming.push(value)}dequeue(){if(this.outgoing.length===0)for(;this.incoming.length>0;)this.outgoing.push(this.incoming.pop());return this.outgoing.pop()}},EventStream=class{queue=new FifoQueue;waiting=new FifoQueue;sink;done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(isComplete,extractResult){this.isComplete=isComplete,this.extractResult=
1435
1435
  extractResult,this.finalResultPromise=new Promise(resolve=>{this.resolveFinalResult=resolve})}push(event){if(this.done)return;if(this.isComplete(event)&&(this.done=!0,this.resolveFinalResult(this.extractResult(event))),this.sink){this.sink(event);return}let waiter=this.waiting.dequeue();waiter?waiter({value:event,done:!1}):this.queue.enqueue(event)}end(result){for(this.done=!0,result!==void 0&&this.resolveFinalResult(result);this.waiting.length>0;)this.waiting.dequeue()({value:void 0,done:!0})}async*[Symbol.
1436
- asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.dequeue();else{if(this.done)return;{let result=await new Promise(resolve=>this.waiting.enqueue(resolve));if(result.done)return;yield result.value}}}result(){return this.finalResultPromise}forwardTo(sink){for(;this.queue.length>0;)sink(this.queue.dequeue());this.sink=sink}},AssistantMessageEventStream=class extends EventStream{#startedAt=Date.now();#startedAtMonotonic=performance.now();constructor(){super(event=>event.type==="done"||
1437
- event.type==="error",event=>{if(event.type==="done")return event.message;if(event.type==="error")return event.error;throw new Error("Unexpected event type for final result")})}push(event){event.type==="done"?this.#time(event.message):event.type==="error"&&this.#time(event.error),super.push(event)}end(result){result!==void 0&&this.#time(result),super.end(result)}#time(message){this.done||message.durationMs!==void 0||message.timestamp<this.#startedAt||(message.durationMs=Math.max(0,Math.round(performance.
1438
- now()-this.#startedAtMonotonic)))}};function contentText(content,separator=`
1436
+ asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.dequeue();else{if(this.done)return;{let result=await new Promise(resolve=>this.waiting.enqueue(resolve));if(result.done)return;yield result.value}}}result(){return this.finalResultPromise}forwardTo(sink){for(;this.queue.length>0;)sink(this.queue.dequeue());this.sink=sink}};var AssistantMessageEventStream=class extends EventStream{#startedAt=Date.now();#startedAtMonotonic=performance.now();constructor(){super(event=>event.type==="done"||event.type==="error",event=>{if(event.type==="done")return event.message;if(event.type==="error")return event.error;throw new Error("Unexpected event type for final result")})}push(event){event.type==="done"?this.#time(event.message):event.type==="error"&&this.#time(event.error),super.push(event)}end(result){result!==void 0&&this.#time(
1437
+ result),super.end(result)}#time(message){this.done||message.durationMs!==void 0||message.timestamp<this.#startedAt||(message.durationMs=Math.max(0,Math.round(performance.now()-this.#startedAtMonotonic)))}};function contentText(content,separator=`
1439
1438
  `){return typeof content=="string"?content:content.filter(block=>block.type==="text").map(block=>block.text).join(separator)}function getSystemMessageText(message){let parts=[contentText(message.content)];for(let text of Object.values(message.sections??{}))text!==null&&parts.push(text);return parts.filter(part=>part.length>0).join(`
1440
1439
 
1441
1440
  `)}function ownedSlice(text,start,end2=text.length){return`${text.slice(start,end2)} `.slice(0,-1)}var PI_AI_VERSION="1.5.0";function getClientVersion(identity){return identity?.version??PI_AI_VERSION}function getClientProduct(identity){return identity?.product??"pi"}function isSystemMessage(message){return message.role==="system"}function getInitialSystemMessage(messages){let first=messages[0];return first&&isSystemMessage(first)?first:void 0}function withoutInitialSystemMessage(messages){return getInitialSystemMessage(messages)?messages.slice(1):messages}function getCurrentTools(messages){let tools=new Map;for(let message of messages)if(isSystemMessage(message)){for(let tool of message.toolsRemoved??[])tools.delete(tool.name);for(let tool of message.toolsAdded??
@@ -1518,8 +1517,8 @@ anyOf)||schema.anyOf.length===0)throw new UnsupportedStrictJsonSchemaError("anyO
1518
1517
  let isObjectSchema=schema.type==="object";if(schema.properties!==void 0&&!isObjectSchema)throw new UnsupportedStrictJsonSchemaError("properties require type object");if(!isObjectSchema)return;if(schema.additionalProperties!==void 0&&schema.additionalProperties!==!1)throw new UnsupportedStrictJsonSchemaError("schema-valued or true additionalProperties is unsupported");if(schema.properties!==void 0&&!isJsonSchemaObject(schema.properties))throw new UnsupportedStrictJsonSchemaError("object propertie\
1519
1518
  s must be a schema map");if(schema.required!==void 0&&(!Array.isArray(schema.required)||schema.required.some(key=>typeof key!="string")))throw new UnsupportedStrictJsonSchemaError("object required must be a string array");let properties=schema.properties??{},propertyNames=Object.keys(properties),required=new Set(Array.isArray(schema.required)?schema.required:[]);if([...required].some(key=>!propertyNames.includes(key)))throw new UnsupportedStrictJsonSchemaError("required contains an unknown prope\
1520
1519
  rty");for(let[key,property]of Object.entries(properties))makeJsonSchemaNodeStrict(property,isUnsupportedKeyword),!required.has(key)&&!schemaAllowsNull(property)&&(properties[key]={anyOf:[property,{type:"null"}]});schema.required=propertyNames,schema.additionalProperties=!1}function makeStrictJsonSchema(schema,isUnsupportedKeyword){let cloned=structuredClone(schema);if(!isJsonSchemaObject(cloned))throw new UnsupportedStrictJsonSchemaError("root schema must have type object");if(makeJsonSchemaNodeStrict(
1521
- cloned,isUnsupportedKeyword),cloned.type!=="object")throw new UnsupportedStrictJsonSchemaError("root schema must have type object");return cloned}function prefersJsonSchemaStrictSampling(tool){let config=tool.constrainedSampling;return!!config&&config.type==="json_schema"&&config.strict==="prefer"}function getJsonSchemaToolParameters(tool,strict){return strict===!0?makeStrictJsonSchema(tool.parameters):tool.parameters}function resolveJsonSchemaStrictSampling(tool,supportsStrictMode,isUnsupportedKeyword){let config=tool.constrainedSampling;if(!(typeof config!="object"||config.type!=="json_schema")){if(supportsStrictMode)try{return makeStrictJsonSchema(tool.parameters,isUnsupportedKeyword),!0}catch(error2){if(!(error2 instanceof UnsupportedStrictJsonSchemaError))throw error2;if(config.strict!=="require")return;throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error2.message}.`)}
1522
- if(config.strict==="require")throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}var CHARS_PER_TOKEN=3.5,ESTIMATED_IMAGE_CHARS=4800;function calculateContextTokens(usage){return usage.totalTokens||usage.input+usage.output+usage.cacheRead+usage.cacheWrite}function safeJsonStringify2(value){try{return JSON.stringify(value)??"undefined"}catch{return"[unserializable]"}}function estimateTextAndImageContentChars(content){if(typeof content=="string")return content.length;let chars2=0;for(let block of content)chars2+=block.type==="text"?block.text.length:ESTIMATED_IMAGE_CHARS;return chars2}
1520
+ cloned,isUnsupportedKeyword),cloned.type!=="object")throw new UnsupportedStrictJsonSchemaError("root schema must have type object");return cloned}function prefersJsonSchemaStrictSampling(tool){let config=tool.constrainedSampling;return!!config&&config.type==="json_schema"&&config.strict==="prefer"}function getJsonSchemaToolParameters(tool,strict){return strict===!0?makeStrictJsonSchema(tool.parameters):tool.parameters}function prepareJsonSchemaTool(tool,supportsStrictMode,isUnsupportedKeyword){let fallback2={strict:void 0,parameters:tool.parameters},config=tool.constrainedSampling;if(typeof config!="object"||config.type!=="json_schema")return fallback2;if(supportsStrictMode)try{return{strict:!0,parameters:makeStrictJsonSchema(tool.parameters,isUnsupportedKeyword)}}catch(error2){if(!(error2 instanceof UnsupportedStrictJsonSchemaError))throw error2;if(config.strict!=="require")return fallback2;throw new Error(`\
1521
+ Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error2.message}.`)}if(config.strict==="require")throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);return fallback2}function resolveJsonSchemaStrictSampling(tool,supportsStrictMode,isUnsupportedKeyword){return prepareJsonSchemaTool(tool,supportsStrictMode,isUnsupportedKeyword).strict}var CHARS_PER_TOKEN=3.5,ESTIMATED_IMAGE_CHARS=4800;function calculateContextTokens(usage){return usage.totalTokens||usage.input+usage.output+usage.cacheRead+usage.cacheWrite}function safeJsonStringify2(value){try{return JSON.stringify(value)??"undefined"}catch{return"[unserializable]"}}function estimateTextAndImageContentChars(content){if(typeof content=="string")return content.length;let chars2=0;for(let block of content)chars2+=block.type==="text"?block.text.length:ESTIMATED_IMAGE_CHARS;return chars2}
1523
1522
  function estimateTextTokens(text){return Math.ceil(text.length/CHARS_PER_TOKEN)}function estimateTextAndImageContentTokens(content){return Math.ceil(estimateTextAndImageContentChars(content)/CHARS_PER_TOKEN)}function estimateMessageTokens(message){let chars2=0;if(message.role==="system")return estimateTextTokens(getSystemMessageText(message))+estimateToolsTokens(message.toolsAdded)+estimateToolsTokens(message.toolsRemoved);if(message.role==="user"||message.role==="toolResult")return estimateTextAndImageContentTokens(
1524
1523
  message.content);for(let block of message.content)block.type==="text"?chars2+=block.text.length:block.type==="thinking"?chars2+=block.thinking.length:chars2+=block.name.length+safeJsonStringify2(block.arguments).length;return Math.ceil(chars2/CHARS_PER_TOKEN)}function getLastAssistantUsageInfo(messages){let latestPrefixTimestamp=Number.NEGATIVE_INFINITY,usageInfo;for(let i5=0;i5<messages.length;i5++){let message=messages[i5];if(message.role==="assistant"){let assistant=message;assistant.timestamp>=
1525
1524
  latestPrefixTimestamp&&assistant.stopReason!=="aborted"&&assistant.stopReason!=="error"&&calculateContextTokens(assistant.usage)>0&&(usageInfo={usage:assistant.usage,index:i5})}latestPrefixTimestamp=Math.max(latestPrefixTimestamp,message.timestamp)}return usageInfo}function estimateContextTokens(context){let messages="messages"in context?context.messages:context,usageInfo=getLastAssistantUsageInfo(messages);if(usageInfo){let usageTokens=calculateContextTokens(usageInfo.usage),trailingTokens=0;for(let i5=usageInfo.