@humain/humain-code 0.4.15 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/README.md +1 -1
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-TSNY5MWH.js +67 -0
- package/dist/bundle/chunks/azure-openai-responses-Z4DCXO2G.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +59 -42
- package/dist/bundle/chunks/{chunk-W2QRCQBX.js → chunk-26EAEXO5.js} +18 -16
- package/dist/bundle/chunks/chunk-2ZFUMXOZ.js +1790 -0
- package/dist/bundle/chunks/{chunk-W5YJZKPF.js → chunk-3UXBFT4Q.js} +2264 -2432
- package/dist/bundle/chunks/{chunk-OX2IBCCA.js → chunk-3XDL5ZE4.js} +88 -82
- package/dist/bundle/chunks/{chunk-LUL775V7.js → chunk-5K5RFXXO.js} +4 -4
- package/dist/bundle/chunks/{chunk-AIXI6RIE.js → chunk-7PRU6YW3.js} +114 -82
- package/dist/bundle/chunks/{chunk-DUSJT2W4.js → chunk-7VY5IL74.js} +1 -1
- package/dist/bundle/chunks/chunk-AWCJWXGD.js +212 -0
- package/dist/bundle/chunks/chunk-FZUJXM6D.js +816 -0
- package/dist/bundle/chunks/{chunk-KK3KUUMM.js → chunk-G6ABHCPB.js} +115 -95
- package/dist/bundle/chunks/{chunk-NNKA2PAP.js → chunk-HPSQKIWK.js} +1 -1
- package/dist/bundle/chunks/chunk-IJYVMOB4.js +6 -0
- package/dist/bundle/chunks/{chunk-36Q5UVQL.js → chunk-L5OUCJ7N.js} +9 -9
- package/dist/bundle/chunks/chunk-NCQ6WAQK.js +125 -0
- package/dist/bundle/chunks/chunk-NSMMDV3N.js +131 -0
- package/dist/bundle/chunks/{chunk-Z74ZYQPX.js → chunk-OKALNPTJ.js} +80 -210
- package/dist/bundle/chunks/{chunk-UHLW4KJ7.js → chunk-OWLBGSXY.js} +94 -91
- package/dist/bundle/chunks/{chunk-JRX7GYW3.js → chunk-P4UKLIQB.js} +8 -8
- package/dist/bundle/chunks/chunk-PY7SOXCA.js +10 -0
- package/dist/bundle/chunks/chunk-Q7VXYXY3.js +7 -0
- package/dist/bundle/chunks/{chunk-COF5P635.js → chunk-QEF72EIZ.js} +13 -13
- package/dist/bundle/chunks/{chunk-EYIYBQAR.js → chunk-RXOCQRBG.js} +1 -1
- package/dist/bundle/chunks/{chunk-BVHXWQLD.js → chunk-SCBU5WOP.js} +1 -1
- package/dist/bundle/chunks/{chunk-DNGJMRJW.js → chunk-SCIGZFN5.js} +11 -11
- package/dist/bundle/chunks/{chunk-UDVC7A5S.js → chunk-TIFFHHW6.js} +16 -14
- package/dist/bundle/chunks/{chunk-L3J4P5JR.js → chunk-UGJAAWNC.js} +1 -1
- package/dist/bundle/chunks/chunk-V76YPIMT.js +48 -0
- package/dist/bundle/chunks/{chunk-Y3RFGBG2.js → chunk-X3O5MCKJ.js} +1 -1
- package/dist/bundle/chunks/chunk-Y26OS23T.js +80 -0
- package/dist/bundle/chunks/chunk-YDBNMIA3.js +34 -0
- package/dist/bundle/chunks/chunk-YLYOJQQX.js +1951 -0
- package/dist/bundle/chunks/{chunk-TJG52LZB.js → chunk-YMBXWW36.js} +1 -1
- package/dist/bundle/chunks/{cli-SRI4UOSL.js → cli-2NKM2RNJ.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-JGN7NZCV.js → cloudflare-workers-ai-system-one-MUJQ6LT2.js} +1 -1
- package/dist/bundle/chunks/{compat-2S3PCPEI.js → compat-VDGEZSVM.js} +8 -8
- package/dist/bundle/chunks/dist-LKDZAEUQ.js +7 -0
- package/dist/bundle/chunks/{dist-JXEXN6S2.js → dist-XVXV2CL4.js} +1 -1
- package/dist/bundle/chunks/{dist-SGQMXO45.js → dist-ZJIYY3GA.js} +1416 -866
- package/dist/bundle/chunks/dist-cjs-AXBW3N4F.js +182 -0
- package/dist/bundle/chunks/{easter-egg-3d-ZJ2JUFOA.js → easter-egg-3d-VGJ77XZQ.js} +1 -1
- package/dist/bundle/chunks/es-N6YFJOD7.js +1901 -0
- package/dist/bundle/chunks/{esm-NCUV2DF7.js → esm-GIR7QH65.js} +1 -1
- package/dist/bundle/chunks/{execute-LRTXH4YJ.js → execute-ZBEZNJ4E.js} +10 -9
- package/dist/bundle/chunks/{extract-OZW5JHG6.js → extract-RFWEHH6W.js} +16 -15
- package/dist/bundle/chunks/github-copilot.js +34 -47
- package/dist/bundle/chunks/{google-generative-ai-YXXFSTX7.js → google-generative-ai-4OVYRP24.js} +2 -2
- package/dist/bundle/chunks/{google-vertex-3IVWLYJ5.js → google-vertex-3WQAZJQD.js} +2 -2
- package/dist/bundle/chunks/host-63SNKK5Y.js +2 -0
- package/dist/bundle/chunks/jiti-static-loader-7OZNBOCI.js +2 -0
- package/dist/bundle/chunks/{mistral-conversations-Y7GWO3QB.js → mistral-conversations-G3GN6CMT.js} +20 -20
- package/dist/bundle/chunks/{node-ELWNZC34.js → node-A6SZ3T7E.js} +185 -185
- package/dist/bundle/chunks/{node-SPBTZUUS.js → node-DZCAT4Q6.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-NSXWHIDT.js → openai-codex-responses-FJFDAWHI.js} +17 -17
- package/dist/bundle/chunks/openai-completions-IC7WRLTI.js +82 -0
- package/dist/bundle/chunks/{openai-decisions-QWEISDVO.js → openai-decisions-HESOHYZB.js} +1 -1
- package/dist/bundle/chunks/openai-responses-XXCYDFSM.js +24 -0
- package/dist/bundle/chunks/{openrouter-images-BMVMAROU.js → openrouter-images-DT2HMZNO.js} +1 -1
- package/dist/bundle/chunks/pdfjs-EK6K7CXX.js +3593 -0
- package/dist/bundle/chunks/{pi-messages-XNEG23NU.js → pi-messages-SAOV3JNW.js} +1 -1
- package/dist/bundle/chunks/{runtime-VGSK3QCM.js → runtime-HJEUOD4R.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-62YHYXZV.js → typesafe-system-one-HCMGHK6A.js} +1 -1
- package/dist/bundle/chunks/{undici-7EW63V4X.js → undici-4BK3MVJV.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-CFJTDIXL.js +5 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/cli.js +2 -2
- package/dist/bundle/flow/package.json +6 -5
- package/dist/bundle/index.js +8 -8
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/coordination/adapter/index.d.ts.map +1 -1
- package/dist/coordination/adapter/index.js +1 -1
- package/dist/coordination/adapter/index.js.map +1 -1
- package/dist/coordination/adapter/integration-notices.d.ts +1 -1
- package/dist/coordination/adapter/integration-notices.d.ts.map +1 -1
- package/dist/coordination/adapter/integration-notices.js +5 -2
- package/dist/coordination/adapter/integration-notices.js.map +1 -1
- package/dist/coordination/broker/extension-state.js +3 -3
- package/dist/coordination/broker/extension-state.js.map +1 -1
- package/dist/coordination/transport/framing.d.ts.map +1 -1
- package/dist/coordination/transport/framing.js +2 -1
- package/dist/coordination/transport/framing.js.map +1 -1
- package/dist/core/account-reporting.d.ts +3 -1
- package/dist/core/account-reporting.d.ts.map +1 -1
- package/dist/core/account-reporting.js +12 -2
- package/dist/core/account-reporting.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +39 -36
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/codex-usage.d.ts +11 -2
- package/dist/core/codex-usage.d.ts.map +1 -1
- package/dist/core/codex-usage.js +74 -2
- package/dist/core/codex-usage.js.map +1 -1
- package/dist/core/export-html/template.js +21 -16
- package/dist/core/model-config.d.ts +33 -8
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +22 -4
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +56 -43
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +256 -361
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +6 -3
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +19 -5
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +7 -2
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +9 -1
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +63 -12
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +7 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +2 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +2 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +11 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +4 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +8 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +2 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +21 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +7 -10
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +4 -7
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trace/redaction.d.ts.map +1 -1
- package/dist/core/trace/redaction.js +3 -1
- package/dist/core/trace/redaction.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +12 -0
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +5 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +74 -20
- package/dist/humain/flow-accounts-host.d.ts.map +1 -1
- package/dist/humain/flow-accounts-host.js +3 -0
- package/dist/humain/flow-accounts-host.js.map +1 -1
- package/dist/humain/node-provider.d.ts.map +1 -1
- package/dist/humain/node-provider.js +2 -0
- package/dist/humain/node-provider.js.map +1 -1
- package/dist/humain/trace-capture/index.js +3 -3
- package/dist/humain/trace-capture/index.js.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts +2 -0
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.js +50 -4
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +3 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +2 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/deepseek.d.ts +4 -0
- package/dist/humain/web-access/vendor/deepseek.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/deepseek.js +201 -0
- package/dist/humain/web-access/vendor/deepseek.js.map +1 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +4 -2
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.js +49 -5
- package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +3 -3
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +11 -4
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +16 -1
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +12 -6
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/query-rewrite.js +11 -4
- package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
- package/dist/humain/web-access/vendor/searxng.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/searxng.js +2 -1
- package/dist/humain/web-access/vendor/searxng.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts +1 -0
- package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +10 -0
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/summary-review.js +17 -6
- package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +2 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +18 -0
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts +2 -0
- package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +5 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +27 -2
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +4 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -9
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +28 -14
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/oauth-account-format.d.ts +4 -4
- package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
- package/dist/modes/interactive/oauth-account-format.js +5 -2
- package/dist/modes/interactive/oauth-account-format.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +9 -2
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +8 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +2 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/cli.md +3 -3
- package/docs/codemode.md +3 -1
- package/docs/coordination.md +6 -0
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +4 -0
- package/docs/flow.md +6 -0
- package/docs/humain-code-forge-flow-walkthrough.md +1 -1
- package/docs/humain-code.md +2 -4
- package/docs/json.md +2 -2
- package/docs/llama-cpp.md +1 -1
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/rpc-commands.md +1 -1
- package/docs/rpc.md +9 -1
- package/docs/sessions.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/trace.md +4 -0
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +16 -6
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +16 -16
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/minimal-mode.ts +4 -4
- package/examples/extensions/sandbox/package-lock.json +6 -6
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/package.json +2 -2
- package/examples/rpc-subagent-progress-host.ts +6 -2
- package/npm-shrinkwrap.json +129 -171
- package/package.json +19 -19
- package/schemas/models.schema.json +9 -5
- package/schemas/settings.schema.json +32 -0
- package/src/coordination/UPSTREAM.md +31 -1
- package/src/coordination/upstream.json +3 -3
- package/src/humain/adhd/UPSTREAM.md +8 -0
- package/src/humain/caveman/UPSTREAM.md +19 -3
- package/src/humain/caveman/upstream.json +2 -2
- package/src/humain/ponytail/UPSTREAM.md +23 -2
- package/src/humain/ponytail/upstream.json +8 -8
- package/src/humain/ponytail/vendor/skills/ponytail/SKILL.md +1 -1
- package/src/humain/ponytail/vendor/skills/ponytail-debt/SKILL.md +1 -2
- package/src/humain/ponytail/vendor/skills/ponytail-gain/SKILL.md +0 -1
- package/src/humain/web-access/UPSTREAM.md +45 -1
- package/src/humain/web-access/upstream.json +4 -4
- package/dist/bundle/chunks/anthropic-messages-YSAHA7QM.js +0 -67
- package/dist/bundle/chunks/azure-openai-responses-Z5XYDPHS.js +0 -15
- package/dist/bundle/chunks/chunk-2TTB6GIB.js +0 -47
- package/dist/bundle/chunks/chunk-5JHUWRJN.js +0 -1790
- package/dist/bundle/chunks/chunk-A7QKOI62.js +0 -572
- package/dist/bundle/chunks/chunk-FRUFMISJ.js +0 -505
- package/dist/bundle/chunks/chunk-MF2NEHP4.js +0 -1575
- package/dist/bundle/chunks/chunk-MG5PX4KU.js +0 -31
- package/dist/bundle/chunks/chunk-OEOXBLWI.js +0 -540
- package/dist/bundle/chunks/chunk-RYC5BYVE.js +0 -5
- package/dist/bundle/chunks/chunk-YJ3NQWES.js +0 -9
- package/dist/bundle/chunks/dist-MNSGVI4C.js +0 -7
- package/dist/bundle/chunks/dist-cjs-4BMVQ74V.js +0 -179
- package/dist/bundle/chunks/es-YEFEOGR3.js +0 -1905
- package/dist/bundle/chunks/host-2RMBOGA7.js +0 -2
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +0 -2
- package/dist/bundle/chunks/openai-completions-WGBQHTYA.js +0 -79
- package/dist/bundle/chunks/openai-responses-OKGCSIEY.js +0 -23
- package/dist/bundle/chunks/pdfjs-6UVU6XFX.js +0 -3564
- package/dist/bundle/chunks/virtual-modules-7HDINPIK.js +0 -5
- /package/dist/bundle/chunks/{chunk-XQRYOCHA.js → chunk-WZMA7HAJ.js} +0 -0
|
@@ -50,6 +50,24 @@
|
|
|
50
50
|
],
|
|
51
51
|
"default": "auto"
|
|
52
52
|
},
|
|
53
|
+
"sessionShareDestination": {
|
|
54
|
+
"anyOf": [
|
|
55
|
+
{
|
|
56
|
+
"type": "string",
|
|
57
|
+
"const": "auto"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"type": "string",
|
|
61
|
+
"const": "gist"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "string",
|
|
65
|
+
"const": "radius"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"description": "Destination used by /share. \"auto\" uses Radius when authenticated and otherwise creates a GitHub gist.",
|
|
69
|
+
"default": "auto"
|
|
70
|
+
},
|
|
53
71
|
"steeringMode": {
|
|
54
72
|
"anyOf": [
|
|
55
73
|
{
|
|
@@ -720,6 +738,20 @@
|
|
|
720
738
|
"minimum": 0,
|
|
721
739
|
"description": "Estimated tokens available for inline codemode tool declarations.",
|
|
722
740
|
"default": 3000
|
|
741
|
+
},
|
|
742
|
+
"flowImplementer": {
|
|
743
|
+
"anyOf": [
|
|
744
|
+
{
|
|
745
|
+
"type": "string",
|
|
746
|
+
"const": "only"
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
"type": "string",
|
|
750
|
+
"const": "off"
|
|
751
|
+
}
|
|
752
|
+
],
|
|
753
|
+
"description": "Tools of the Flow SMALL/MEDIUM implementer and its repair rounds. \"only\" gives them codemode with codemode.mode \"only\"; \"off\" keeps the plain tool list. HUMAIN_FLOW_IMPLEMENTER_CODEMODE=only|off overrides this.",
|
|
754
|
+
"default": "only"
|
|
723
755
|
}
|
|
724
756
|
}
|
|
725
757
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The transport, broker and client under this directory are derived from
|
|
4
4
|
[`nicobailon/pi-intercom`](https://github.com/nicobailon/pi-intercom) at commit
|
|
5
|
-
`
|
|
5
|
+
`ddf288186d4c40b8a54fbe8c0d136cbe4893a032` (tag `v0.17.1`, version 0.17.1), used under the MIT license in
|
|
6
6
|
`vendor/LICENSE`. Every derived file carries a header naming its origin.
|
|
7
7
|
|
|
8
8
|
Reviewed 2026-10-13: ported the 0.16.1 to 0.17.0 receipt-confirmed delivery, broker-side heartbeat eviction,
|
|
@@ -88,6 +88,36 @@ Focused regression coverage lives in `test/coordination/upstream-refresh.test.ts
|
|
|
88
88
|
`intercom_session_held` entries remain outside the fork's built-in adapter. Human-only ownership and integration
|
|
89
89
|
commands are unchanged; peer messages cannot execute them.
|
|
90
90
|
|
|
91
|
+
## 0.17.1 incremental adaptations
|
|
92
|
+
|
|
93
|
+
Reviewed the complete v0.17.0..v0.17.1 diff. Annotated tag object
|
|
94
|
+
`ce783bbdf9e215f2258c59b54750c555354c741d` peels to
|
|
95
|
+
`ddf288186d4c40b8a54fbe8c0d136cbe4893a032`, matching the remote tag. The MIT
|
|
96
|
+
license is unchanged and matches the existing SHA-256 pin. No upstream tests,
|
|
97
|
+
code, hooks or installers were executed.
|
|
98
|
+
|
|
99
|
+
- Framed socket writes now use `Buffer.allocUnsafeSlow`, so a queued small
|
|
100
|
+
frame retains only its own allocation, not a shared pool slab. HUMAIN's
|
|
101
|
+
existing 8 MiB post-write cap and framed-reader protections remain.
|
|
102
|
+
- Extension-state persistence failures now include the underlying diagnostic,
|
|
103
|
+
retaining `persistFailed`, unchanged revision and unchanged state on failure.
|
|
104
|
+
HUMAIN already fsyncs its exclusively created writable descriptor before
|
|
105
|
+
atomic rename; upstream's Windows read-only-handle repair is unnecessary.
|
|
106
|
+
- HUMAIN already paces mailbox replay through a single drain callback at its
|
|
107
|
+
soft limit. The existing durable mailbox, atomic acceptance, receipt waits,
|
|
108
|
+
lease fencing, isolation and client/supervisor implementation remain intact;
|
|
109
|
+
no upstream broker/client replacement was made.
|
|
110
|
+
- Upstream's bare-reply target fix does not apply: HUMAIN does not vendor
|
|
111
|
+
`reply-tracker.ts` and has no implicit `reply` action. Its tool requires an
|
|
112
|
+
explicit `to` target and supports explicit `replyTo` correlation instead.
|
|
113
|
+
|
|
114
|
+
Only the framing and extension-state headers advance to the 0.17.1 commit;
|
|
115
|
+
other derived-file headers retain their accurate source revisions. Adapted
|
|
116
|
+
regressions live in `test/coordination/upstream-0171.test.ts`; existing
|
|
117
|
+
backpressure, mailbox replay, receipt and atomic-file suites remain the
|
|
118
|
+
coverage for already-equivalent fixes. No dependency or manifest change is
|
|
119
|
+
required.
|
|
120
|
+
|
|
91
121
|
## Not vendored
|
|
92
122
|
|
|
93
123
|
`index.ts` (Pi extension), `config.ts`, `herdr-location.ts`, `project-agent.ts`, `handover.ts`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-intercom",
|
|
3
3
|
"repository": "https://github.com/nicobailon/pi-intercom",
|
|
4
|
-
"commit": "
|
|
5
|
-
"tag": "v0.17.
|
|
6
|
-
"upstreamVersion": "0.17.
|
|
4
|
+
"commit": "ddf288186d4c40b8a54fbe8c0d136cbe4893a032",
|
|
5
|
+
"tag": "v0.17.1",
|
|
6
|
+
"upstreamVersion": "0.17.1",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"vendoredSha256": {
|
|
9
9
|
"LICENSE": "2d20dfacd9742706e564470dc77438608a1e54b0ed46959f080709389209093c"
|
|
@@ -23,6 +23,14 @@ files were compared byte-for-byte against the new commit, so their hashes and
|
|
|
23
23
|
runtime behavior remain unchanged. This provenance-only change reflects a
|
|
24
24
|
reviewed documentation-only release, not a skipped skill update.
|
|
25
25
|
|
|
26
|
+
## Unchanged HEAD verification
|
|
27
|
+
|
|
28
|
+
During the stable upstream refresh, `git ls-remote` still reports HEAD
|
|
29
|
+
`1ecea1993b7fce257ffbd686c070948b5e07eda6`. The skill and MIT license were
|
|
30
|
+
fetched from that exact commit and compared byte-for-byte with the bundled
|
|
31
|
+
files and recorded SHA-256 hashes. Both match. The commit, version, vendor
|
|
32
|
+
files and host remain unchanged. No upstream code or tests were executed.
|
|
33
|
+
|
|
26
34
|
## Not vendored
|
|
27
35
|
|
|
28
36
|
The upstream `extensions/i-have-adhd.ts`, hooks, installers, scripts, tests,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# caveman upstream tracking
|
|
2
2
|
|
|
3
3
|
`vendor/skills/caveman/SKILL.md` and `vendor/skills/ultracave/SKILL.md` come from
|
|
4
|
-
[`JuliusBrussee/caveman`](https://github.com/JuliusBrussee/caveman) at tag `
|
|
5
|
-
`
|
|
4
|
+
[`JuliusBrussee/caveman`](https://github.com/JuliusBrussee/caveman) at tag `v4.0.1`, peeled commit
|
|
5
|
+
`d262ab3882952a59312ff3537cd86d894523c5ab`. Per the upstream `LICENSING.md`,
|
|
6
6
|
everything in the repository from 3.0.0 on is Apache License 2.0, so the files
|
|
7
7
|
are used under Apache-2.0. Contributions made before 3.0.0 to the formerly MIT
|
|
8
8
|
parts (which include the skill) also remain available under MIT, so `vendor/`
|
|
@@ -14,6 +14,22 @@ The vendored files are byte-identical to the pinned commit; `upstream.json`
|
|
|
14
14
|
records their SHA-256 (`vendoredSha256`) and `humainPatches` is empty.
|
|
15
15
|
`test/humain-modules-upstream.test.ts` checks the hashes offline.
|
|
16
16
|
|
|
17
|
+
## 4.0.1 provenance-only refresh
|
|
18
|
+
|
|
19
|
+
Verified annotated tag object `d0be14f2dc92a99d12e717465d6908723ab9bfdb`
|
|
20
|
+
peels to `d262ab3882952a59312ff3537cd86d894523c5ab`, matching the remote tag.
|
|
21
|
+
The complete stable diff affecting the two bundled skills and three license
|
|
22
|
+
files is empty. Each file was read from the target Git object and compared
|
|
23
|
+
byte-for-byte with the bundled copy and its recorded SHA-256. All five files
|
|
24
|
+
remain unchanged; neither skill was removed. `LICENSING.md` was reviewed in
|
|
25
|
+
full and still covers these skills under Apache-2.0 with the retained MIT
|
|
26
|
+
notice for older contributions. Host behavior is unchanged.
|
|
27
|
+
|
|
28
|
+
Changes to compression helpers, CLI, engine, proxy, browser, hooks, installers,
|
|
29
|
+
and other skills remain outside this skill-only integration. None were run or
|
|
30
|
+
imported. The metadata change records the reviewed stable release, not new
|
|
31
|
+
runtime functionality.
|
|
32
|
+
|
|
17
33
|
## Stable release recheck (2026-10-13)
|
|
18
34
|
|
|
19
35
|
The latest stable `v*` tag remains `v3.2.0`, peeled commit
|
|
@@ -97,7 +113,7 @@ Run `npm run check:modules-upstream` to detect a newer tag or HEAD. To update:
|
|
|
97
113
|
```bash
|
|
98
114
|
git clone https://github.com/JuliusBrussee/caveman "$(mktemp -d)/caveman" && cd "$_"
|
|
99
115
|
git checkout <commit>
|
|
100
|
-
git diff
|
|
116
|
+
git diff d262ab3882952a59312ff3537cd86d894523c5ab <commit> -- skills/caveman/SKILL.md skills/ultracave/SKILL.md LICENSE NOTICE LICENSE-MIT LICENSING.md
|
|
101
117
|
shasum -a 256 skills/caveman/SKILL.md skills/ultracave/SKILL.md LICENSE NOTICE LICENSE-MIT
|
|
102
118
|
```
|
|
103
119
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caveman",
|
|
3
3
|
"repository": "https://github.com/JuliusBrussee/caveman",
|
|
4
|
-
"commit": "
|
|
5
|
-
"upstreamVersion": "
|
|
4
|
+
"commit": "d262ab3882952a59312ff3537cd86d894523c5ab",
|
|
5
|
+
"upstreamVersion": "4.0.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"vendoredSha256": {
|
|
8
8
|
"LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30",
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
The vendored files in `vendor/` come from the npm package
|
|
4
4
|
[`@dietrichgebert/ponytail`](https://github.com/DietrichGebert/ponytail) version
|
|
5
|
-
`5.2
|
|
5
|
+
`5.3.2` and remain licensed under the upstream MIT license in `vendor/LICENSE`.
|
|
6
6
|
They were taken from the published npm tarball, not the git repository, after
|
|
7
7
|
verifying the tarball against the registry's `dist.shasum` and `dist.integrity`.
|
|
8
8
|
|
|
9
|
-
Last reviewed: 5.2
|
|
9
|
+
Last reviewed: 5.3.2 during the stable upstream refresh.
|
|
10
10
|
|
|
11
11
|
`upstream.json` records the tarball URL, SHA-1 shasum, SHA-512 integrity, the
|
|
12
12
|
SHA-256 of every vendored file that is byte-identical to the tarball
|
|
@@ -81,6 +81,27 @@ SHA-256 of every vendored file that is byte-identical to the tarball
|
|
|
81
81
|
`Bad:`/`Good:` patch was dropped because the upstream examples are gone). The
|
|
82
82
|
pin test still checks every vendored skill for emoji.
|
|
83
83
|
|
|
84
|
+
## 5.3.2 refresh
|
|
85
|
+
|
|
86
|
+
The 5.2.0 and 5.3.2 published-package diff was reviewed as untrusted input.
|
|
87
|
+
The 5.3.2 tarball SHA-1 (`95842ed4d5dadf4191a8d1d26eba9b9cff56d2fa`) and
|
|
88
|
+
SHA-512 integrity match the registry record. Every extracted file was compared
|
|
89
|
+
with the verified archive. Registry `gitHead` is
|
|
90
|
+
`16352ac229eb08a9598dcae48fe9f2b342567d86`. MIT license, dependencies (none),
|
|
91
|
+
and package scripts are unchanged. No upstream scripts or tests were executed.
|
|
92
|
+
|
|
93
|
+
This is a skills-only refresh. The base skill adds `off` to its argument hint;
|
|
94
|
+
`ponytail-debt` and `ponytail-gain` remove misleading mode-reversion instructions
|
|
95
|
+
from their one-shot output. All three vendored runtime sources are unchanged
|
|
96
|
+
upstream and remain unchanged locally, including HUMAIN's safe config writes.
|
|
97
|
+
|
|
98
|
+
The new Claude Code band, board, hook configuration and transcript importer are
|
|
99
|
+
not vendored. The new help section advertising `/ponytail band` is deliberately
|
|
100
|
+
omitted because HUMAIN does not expose those commands. The help file retains
|
|
101
|
+
HUMAIN environment/configuration paths and bundled-update instructions; its
|
|
102
|
+
`upstreamSourceSha256` records the complete 5.3.2 upstream help, including that
|
|
103
|
+
omitted section. Review/audit skills and all license bytes are unchanged.
|
|
104
|
+
|
|
84
105
|
## 5.2.0 refresh (2026-10-13)
|
|
85
106
|
|
|
86
107
|
The registry's latest stable release is 5.2.0. Both the 5.0.0 baseline and
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dietrichgebert/ponytail",
|
|
3
3
|
"repository": "https://github.com/DietrichGebert/ponytail",
|
|
4
|
-
"version": "5.2
|
|
4
|
+
"version": "5.3.2",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"tarball": "https://registry.npmjs.org/@dietrichgebert/ponytail/-/ponytail-5.2.
|
|
7
|
-
"shasum": "
|
|
8
|
-
"integrity": "sha512-
|
|
6
|
+
"tarball": "https://registry.npmjs.org/@dietrichgebert/ponytail/-/ponytail-5.3.2.tgz",
|
|
7
|
+
"shasum": "95842ed4d5dadf4191a8d1d26eba9b9cff56d2fa",
|
|
8
|
+
"integrity": "sha512-AjJnMi54AXO55kXi0ISNPacLuTjb7e9V4lV2oidyxBOnVoPih8CIAmnfHgwX2VyPsDqwQhJthJ9bNu30MaHuOg==",
|
|
9
9
|
"vendoredSha256": {
|
|
10
10
|
"LICENSE": "fb1bc6909ac3ef82d5c22106e32ef682b0cff66788fa915fb9b53b15c9d2f3ab",
|
|
11
|
-
"skills/ponytail/SKILL.md": "
|
|
11
|
+
"skills/ponytail/SKILL.md": "9badd22a32e19cb884e46dfa8d3aae82bb81dfa5484105b8b4f0262df823a509",
|
|
12
12
|
"skills/ponytail-audit/SKILL.md": "2b3223a02c386d1263e1b08343cb8eb3a53e444cdafb1d79e26c8ec2a8fcad28",
|
|
13
|
-
"skills/ponytail-debt/SKILL.md": "
|
|
14
|
-
"skills/ponytail-gain/SKILL.md": "
|
|
13
|
+
"skills/ponytail-debt/SKILL.md": "b5ec2762f6ba8c4af9ea7173aa6c9f91b88655a25e43f9de0264f6ce8722b25f",
|
|
14
|
+
"skills/ponytail-gain/SKILL.md": "231034a896d6762e4b5c8468287083422c56b499119976ec9f76821f7d083090",
|
|
15
15
|
"skills/ponytail-review/SKILL.md": "33fe4ebe22a460924e5d4a261e223df22e409cc94ab76182bee9fb91a3ef022e"
|
|
16
16
|
},
|
|
17
17
|
"upstreamSourceSha256": {
|
|
18
18
|
"pi-extension/index.js": "a8ff050f3e9ea9c33647ec87d4f67b3380dddc68375685a88c81960af10a879a",
|
|
19
19
|
"hooks/ponytail-config.js": "ae81c3552064c9a9f0b9c0e8ec8a959af56f5599f0c899dd79659ea9a101dfc4",
|
|
20
20
|
"hooks/ponytail-instructions.js": "36521752b3444ef8daa823edaa996170e6af2cd45c82193644acb3a42f3395f4",
|
|
21
|
-
"skills/ponytail-help/SKILL.md": "
|
|
21
|
+
"skills/ponytail-help/SKILL.md": "86ab0ce0af70cbeeeef499d5c884873b393f87f86401dcc45553662ce2c1eff9"
|
|
22
22
|
},
|
|
23
23
|
"humainPatches": [
|
|
24
24
|
"pi-extension/index.ts",
|
|
@@ -6,7 +6,7 @@ description: >
|
|
|
6
6
|
fixing, refactoring, reviewing, choosing dependencies) and when the user says
|
|
7
7
|
"ponytail", "be lazy", "simplest solution", "yagni", or complains about
|
|
8
8
|
over-engineering or bloat. Levels: lite, full (default), ultra.
|
|
9
|
-
argument-hint: "[lite|full|ultra]"
|
|
9
|
+
argument-hint: "[lite|full|ultra|off]"
|
|
10
10
|
license: MIT
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -41,5 +41,4 @@ End with `<N> markers, <M> with no trigger.` Nothing found: `No shortcut debt. C
|
|
|
41
41
|
## Boundaries
|
|
42
42
|
|
|
43
43
|
Reads and reports only, changes nothing. To persist it, ask and it writes the
|
|
44
|
-
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot.
|
|
45
|
-
"normal mode" to revert.
|
|
44
|
+
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot.
|
|
@@ -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.
|
|
4
|
+
[`pi-web-access`](https://github.com/nicobailon/pi-web-access) version `0.42.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,
|
|
@@ -185,3 +185,47 @@ manifest, shrinkwrap or lockfile update is required. Upstream lifecycle scripts
|
|
|
185
185
|
are unchanged and were not executed. Build artifacts and release smoke tests
|
|
186
186
|
must still be checked by the release owner; this refresh used offline focused
|
|
187
187
|
tests and did not build or contact paid providers.
|
|
188
|
+
|
|
189
|
+
## 0.42.0 refresh
|
|
190
|
+
|
|
191
|
+
The published 0.40.0 and 0.42.0 package diff was reviewed. The 0.42.0 tarball
|
|
192
|
+
SHA-1 (`4df2585b6c19c78f64b0c387822ba8516541dfcf`) and SHA-512 integrity match
|
|
193
|
+
the registry record; every extracted file was compared with the verified archive.
|
|
194
|
+
Registry `gitHead` is `18e36f9e0fc2de3c9895a7fda8d39a62ce60f49e`. Dependencies,
|
|
195
|
+
lifecycle scripts and the MIT license are unchanged. No upstream code, hooks,
|
|
196
|
+
installers or tests were executed; only reviewed sources were imported.
|
|
197
|
+
|
|
198
|
+
Imported changes:
|
|
199
|
+
|
|
200
|
+
- DeepSeek search, including curator/provider metadata, key lookup, Unicode query
|
|
201
|
+
limits, domain/date operators, response validation and credential redaction.
|
|
202
|
+
It requires `deepseekApiKey` or `DEEPSEEK_API_KEY` and stays explicit-only:
|
|
203
|
+
neither `auto` nor `all` selects it, even when configured.
|
|
204
|
+
- `toolExposure: "direct" | "deferred"`. HUMAIN still defaults to eager activation
|
|
205
|
+
and direct exposure. Deferred exposure requires non-eager activation and forces
|
|
206
|
+
dynamic loader selection so a fresh session never loses `web_enable`.
|
|
207
|
+
- Page answers, summaries and query rewriting prefer registry `streamSimple`,
|
|
208
|
+
preserving virtual-model/provider routing, session scope, cancellation, and
|
|
209
|
+
uncached side-call options. Existing completion fallbacks remain.
|
|
210
|
+
- GCE metadata ADC when ADC is selected, project/location are present, and no
|
|
211
|
+
explicit ADC path or default ADC file exists. `METADATA_SERVER_DETECTION=none`
|
|
212
|
+
disables discovery; explicit API keys and custom Gemini endpoints still win.
|
|
213
|
+
Metadata requests bypass the proxy and refuse redirects. HUMAIN validates the
|
|
214
|
+
operator's `GCE_METADATA_HOST` as an HTTP(S) origin, preserves an explicit HTTPS
|
|
215
|
+
scheme, bypasses only that exact override origin, and never echoes metadata
|
|
216
|
+
response bodies or transport errors. JSON token parse errors do not quote
|
|
217
|
+
token-bearing input. OAuth token exchanges remain pinned to Google's endpoint;
|
|
218
|
+
existing ADC parsing, credential rejection and redaction patches remain.
|
|
219
|
+
- Windows credential commands locate Git Bash without selecting the legacy WSL
|
|
220
|
+
launcher. The bare `!` rejection, bounded output, timeout, abort handling and
|
|
221
|
+
restricted child environment remain intact.
|
|
222
|
+
- Configurable printable-ASCII `fetchContent.userAgent`, validated before provider
|
|
223
|
+
fallback, and explicit loopback SearXNG support under the existing redirect guard.
|
|
224
|
+
|
|
225
|
+
All existing HUMAIN host-shim, agent-directory, eager-default, explicit null proxy,
|
|
226
|
+
curl stdin-config, request-body privacy, ADC endpoint/redaction, RSC and unsupported
|
|
227
|
+
Baizhi/Z.ai patches remain. The standalone MCP files, distribution bundles and
|
|
228
|
+
provider SDK remain omitted. No manifest, lockfile or shrinkwrap change is needed.
|
|
229
|
+
Offline regression coverage is in `test/humain-web-access-042.test.ts`, alongside
|
|
230
|
+
the existing boundary and refresh suites. Release smoke tests remain the release
|
|
231
|
+
owner's responsibility.
|
|
@@ -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.
|
|
5
|
-
"tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.
|
|
6
|
-
"shasum": "
|
|
7
|
-
"integrity": "sha512-
|
|
4
|
+
"version": "0.42.0",
|
|
5
|
+
"tarball": "https://registry.npmjs.org/pi-web-access/-/pi-web-access-0.42.0.tgz",
|
|
6
|
+
"shasum": "4df2585b6c19c78f64b0c387822ba8516541dfcf",
|
|
7
|
+
"integrity": "sha512-AUtkNFw1wltHSzxEQGF9yjUjijQE75opicgXrOLCX7iRWWXaKoj0fOlPAWUHVMqRRHeUwN6S/sYFrm3+2QOtMQ==",
|
|
8
8
|
"humainPatches": [
|
|
9
9
|
"extract.ts",
|
|
10
10
|
"gemini-adc.ts",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{buildCopilotDynamicHeaders,hasCopilotVisionInput}from"./chunk-JEJQVFWK.js";import{iterateSseMessages}from"./chunk-YZMQXAJM.js";import{retryProviderRequest}from"./chunk-Z33NNMNB.js";import"./chunk-MVYV6MJY.js";import{adjustMaxTokensForThinking,buildBaseOptions,clampMaxTokensToContext,getJsonSchemaToolParameters,getPiUserAgent,resolveJsonSchemaStrictSampling,transformMessages}from"./chunk-UDVC7A5S.js";import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{
|
|
3
|
-
sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{createRequestObserver,headersToRecord}from"./chunk-5CDES42D.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";import{getProviderEnvValue}from"./chunk-FACBDLFU.js";import{parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming}from"./chunk-MG5PX4KU.js";import{
|
|
4
|
-
calculateCost,getCurrentTools,getInitialSystemMessage,getSystemMessageText,renderSystemMessageUpdate,resolveTranscript}from"./chunk-LUL775V7.js";import{AssistantMessageEventStream}from"./chunk-RYC5BYVE.js";import{appendAssistantMessageDiagnostic}from"./chunk-VEYTRNQC.js";import{Anthropic}from"./chunk-A7QKOI62.js";import"./chunk-JXWJOIH4.js";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\
|
|
5
|
-
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.
|
|
6
|
-
name.toLowerCase()===lowerName);if(matchedTool)return matchedTool.name}return name};function convertContentBlocks(content){if(!content.some(c=>c.type==="image"))return sanitizeSurrogates(content.map(c=>c.text).join(`
|
|
7
|
-
`));let blocks=content.map(block=>block.type==="text"?{type:"text",text:sanitizeSurrogates(block.text)}:{type:"image",source:{type:"base64",media_type:block.mimeType,data:block.data}});return blocks.some(b=>b.type==="text")||blocks.unshift({type:"text",text:"(see attached image)"}),blocks}var FINE_GRAINED_TOOL_STREAMING_BETA="fine-grained-tool-streaming-2025-05-14",INTERLEAVED_THINKING_BETA="interleaved-thinking-2025-05-14",SERVER_SIDE_FALLBACK_BETA="server-side-fallback-2026-07-01",MID_CONVERSATION_OUTPUT_CONFIG_BETA="\
|
|
8
|
-
mid-conversation-output-config-2026-07-01",THINKING_BINDING_CONTROLS_BETA="thinking-binding-controls-2026-08-01",INLINE_TOOLS_BETA="inline-tools-2026-09-15",DEFERRED_TOOL_PLACEHOLDER={name:"__pi_deferred_placeholder__",description:"Reserved placeholder. Never available. Never call this.",input_schema:{type:"object",properties:{},required:[]},defer_loading:!0};function shouldUseServerSideFallbackBeta(model){return(model.compat?.allowedFallbackModels?.length??0)>0}function getAnthropicCompat(model){
|
|
9
|
-
let isOpenRouter=model.provider==="openrouter"||model.baseUrl.includes("openrouter.ai");return{supportsEagerToolInputStreaming:model.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:model.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:model.compat?.sendSessionAffinityHeaders??isOpenRouter,sessionAffinityFormat:model.compat?.sessionAffinityFormat??(isOpenRouter?"openrouter":void 0),supportsCacheControlOnTools:model.compat?.supportsCacheControlOnTools??!0,supportsTemperature:model.
|
|
10
|
-
compat?.supportsTemperature??!0,allowEmptySignature:model.compat?.allowEmptySignature??!1,supportsStrictTools:model.compat?.supportsStrictTools??!1,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsMidConvoToolChanges:model.compat?.supportsMidConvoToolChanges??!1}}function mergeHeaders(...headerSources){let merged={};for(let headers of headerSources)headers&&Object.assign(merged,headers);return merged}function mergeClientHeaders(...headerSources){return mergeHeaders(
|
|
11
|
-
{"User-Agent":getPiUserAgent()},...headerSources)}function hasHeader(headers,name){if(!headers)return!1;let expected=name.toLowerCase();for(let[key,value]of Object.entries(headers))if(key.toLowerCase()===expected&&value!==null&&value.trim().length>0)return!0;return!1}function hasRequestAuth(apiKey,headers){return!!apiKey||hasHeader(headers,"authorization")||hasHeader(headers,"x-api-key")||hasHeader(headers,"cf-aig-authorization")}function assertRequestAuth(provider,apiKey,headers){if(!hasRequestAuth(
|
|
12
|
-
apiKey,headers))throw new Error(`No API key for provider: ${provider}`)}var PiAnthropic=class extends Anthropic{_shouldResolveDefaultCredentials(){return!1}};function getAnthropicFederation(model,apiKey,headers,env){if(model.provider!=="anthropic"||hasRequestAuth(apiKey,headers))return;let federationRuleId=getProviderEnvValue(ANTHROPIC_FEDERATION_RULE_ID_ENV,env),organizationId=getProviderEnvValue(ANTHROPIC_ORGANIZATION_ID_ENV,env),identityTokenFile=getProviderEnvValue(ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,
|
|
13
|
-
env);if(!(!federationRuleId||!organizationId||!identityTokenFile))return{organization_id:organizationId,workspace_id:getProviderEnvValue(ANTHROPIC_WORKSPACE_ID_ENV,env),authentication:{type:"oidc_federation",federation_rule_id:federationRuleId,service_account_id:getProviderEnvValue(ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,env),identity_token:{source:"file",path:identityTokenFile}}}}var federationClient,ANTHROPIC_MESSAGE_EVENTS=new Set(["message_start","message_delta","message_stop","content_block_start",
|
|
14
|
-
"content_block_delta","content_block_stop"]);async function*iterateAnthropicEvents(response,signal){if(!response.body)throw new Error("Attempted to iterate over an Anthropic response with no body");let sawMessageStart=!1,sawMessageEnd=!1;for await(let sse of iterateSseMessages(response.body,{signal})){if(sse.event==="error")throw new Error(sse.data);if(ANTHROPIC_MESSAGE_EVENTS.has(sse.event??""))try{let event=parseJsonWithRepair(sse.data);event.type==="message_start"?sawMessageStart=!0:event.type===
|
|
15
|
-
"message_stop"&&(sawMessageEnd=!0),yield event}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Could not parse Anthropic SSE event ${sse.event}: ${message}; data=${sse.data}; raw=${sse.raw.join("\\n")}`)}}if(sawMessageStart&&!sawMessageEnd)throw new Error("Anthropic stream ended before message_stop")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,getAnthropicCompat(model).supportsMidConvoSystemMessages),
|
|
16
|
-
currentTools=getCurrentTools(normalizedContext.messages);return(async()=>{let providerThinkingLevel=model.compat?.supportsMidConvoEffort?options?.effort??"high":void 0,output={role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,...providerThinkingLevel===void 0?{}:{providerThinkingLevel},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()};
|
|
17
|
-
try{let client,isOAuth,usageModel=model,inputUsageIncomplete=!0,optionalUsage={},inputTransformations;if(options?.client)client=options.client,isOAuth=!1;else{let apiKey=options?.apiKey,federation=getAnthropicFederation(model,apiKey,options?.headers,options?.env);federation||assertRequestAuth(model.provider,apiKey,options?.headers);let copilotDynamicHeaders;if(model.provider==="github-copilot"){let hasImages=hasCopilotVisionInput(normalizedContext.messages);copilotDynamicHeaders=buildCopilotDynamicHeaders(
|
|
18
|
-
{messages:normalizedContext.messages,hasImages})}let cacheSessionId=resolveCacheRetention(options?.cacheRetention,options?.env)==="none"?void 0:options?.sessionId,created=createClient(model,apiKey,options?.headers,options?.fetch,copilotDynamicHeaders,cacheSessionId,federation);client=created.client,isOAuth=created.isOAuthToken}let observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),observeMiddleware=async(request,next,ctx)=>(ctx.options!==
|
|
19
|
-
void 0&&typeof request.body=="string"&&await observe(request.body),next(request)),requestOptions={...options?.signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},...options?.onRequest?{middleware:[observeMiddleware]}:{},maxRetries:0},disablePreferredStrictTools=!1,response;for(;;){options?.signal?.throwIfAborted();let built=buildParams(model,normalizedContext,isOAuth,options,disablePreferredStrictTools),params=built.params,nextParams=await options?.onPayload?.(
|
|
20
|
-
params,model);nextParams!==void 0&&(params={...nextParams,stream:!0});try{response=await retryProviderRequest(()=>client.beta.messages.create(params,requestOptions).asResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});break}catch(error){if(options?.signal?.aborted||disablePreferredStrictTools||!built.hasPreferredStrictTools||!(error instanceof Anthropic.APIError)||error.status!==400||error.type!=="invalid_request_error"||!["The compiled g\
|
|
21
|
-
rammar is too large","Too many strict tools (","Schemas contains too many parameters with union types ("].some(message=>error.message.includes(message)))throw error;disablePreferredStrictTools=!0,appendAssistantMessageDiagnostic(output,{type:"anthropic_strict_tools_fallback",timestamp:Date.now(),error:{message:error.message},details:{reason:"strict_tool_limits_exceeded"}})}}await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"s\
|
|
22
|
-
tart",partial:output});let blocks=output.content;for await(let event of iterateAnthropicEvents(response,options?.signal))if(await options?.onProviderStreamEvent?.(event,model),event.type==="message_start"){output.responseId=event.message.id;let transformations=event.message.input_transformations;Array.isArray(transformations)&&(inputTransformations=transformations);let responseModel=event.message.model;responseModel!==model.id&&(output.responseModel=responseModel);let fallbackCost=responseModel===
|
|
23
|
-
model.id?void 0:model.compat?.allowedFallbackModels?.find(fallback=>fallback.provider===model.provider&&fallback.model===responseModel)?.cost;usageModel=fallbackCost?{...model,id:responseModel,cost:fallbackCost}:model,inputUsageIncomplete=hasIncompleteUsage([event.message.usage?.input_tokens]),optionalUsage.cacheRead=event.message.usage?.cache_read_input_tokens,optionalUsage.cacheWrite=event.message.usage?.cache_creation_input_tokens,optionalUsage.cacheWrite1h=event.message.usage?.cache_creation?.
|
|
24
|
-
ephemeral_1h_input_tokens,output.usage.input=event.message.usage?.input_tokens||0,output.usage.output=event.message.usage?.output_tokens||0,output.usage.cacheRead=event.message.usage?.cache_read_input_tokens||0,output.usage.cacheWrite=event.message.usage?.cache_creation_input_tokens||0,output.usage.cacheWrite1h=event.message.usage?.cache_creation?.ephemeral_1h_input_tokens||0,output.usage.totalTokens=output.usage.input+output.usage.output+output.usage.cacheRead+output.usage.cacheWrite,calculateCost(
|
|
25
|
-
usageModel,output.usage)}else if(event.type==="content_block_start"){if(event.content_block.type==="fallback"){if(output.content.length>0)throw new Error("Anthropic performed an unsupported mid-output model fallback");continue}if(event.content_block.type==="text"){let block={type:"text",text:event.content_block.text??"",index:event.index};output.content.push(block),stream2.push({type:"text_start",contentIndex:output.content.length-1,partial:output})}else if(event.content_block.type==="thinking"){
|
|
26
|
-
let block={type:"thinking",thinking:event.content_block.thinking??"",thinkingSignature:event.content_block.signature??"",index:event.index};output.content.push(block),stream2.push({type:"thinking_start",contentIndex:output.content.length-1,partial:output})}else if(event.content_block.type==="redacted_thinking"){let block={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:event.content_block.data,redacted:!0,index:event.index};output.content.push(block),stream2.push({type:"thinkin\
|
|
27
|
-
g_start",contentIndex:output.content.length-1,partial:output})}else if(event.content_block.type==="tool_use"){let block={type:"toolCall",id:event.content_block.id,name:isOAuth?fromClaudeCodeName(event.content_block.name,currentTools):event.content_block.name,arguments:event.content_block.input??{},partialJson:"",index:event.index};output.content.push(block),stream2.push({type:"toolcall_start",contentIndex:output.content.length-1,partial:output})}}else if(event.type==="content_block_delta"){if(event.
|
|
28
|
-
delta.type==="text_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="text"&&(block.text+=event.delta.text,stream2.push({type:"text_delta",contentIndex:index,delta:event.delta.text,partial:output}))}else if(event.delta.type==="thinking_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="thinking"&&(block.thinking+=event.delta.thinking,stream2.push({type:"thinking_delta",contentIndex:index,delta:event.
|
|
29
|
-
delta.thinking,partial:output}))}else if(event.delta.type==="input_json_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="toolCall"&&(block.partialJson+=event.delta.partial_json,block.arguments=parseStreamingJsonWhileStreaming(block,block.partialJson,block.arguments),stream2.push({type:"toolcall_delta",contentIndex:index,delta:event.delta.partial_json,partial:output}))}else if(event.delta.type==="signature_delta"){let index=blocks.findIndex(b=>b.
|
|
30
|
-
index===event.index),block=blocks[index];block&&block.type==="thinking"&&(block.thinkingSignature=block.thinkingSignature||"",block.thinkingSignature+=event.delta.signature)}}else if(event.type==="content_block_stop"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&(delete block.index,block.type==="text"?stream2.push({type:"text_end",contentIndex:index,content:block.text,partial:output}):block.type==="thinking"?stream2.push({type:"thinking_end",contentIndex:index,
|
|
31
|
-
content:block.thinking,partial:output}):block.type==="toolCall"&&(block.arguments=parseStreamingJson(block.partialJson),delete block.partialJson,stream2.push({type:"toolcall_end",contentIndex:index,toolCall:block,partial:output})))}else if(event.type==="message_delta"){let transformations=event.input_transformations;if(Array.isArray(transformations)&&(inputTransformations=transformations),event.delta.stop_reason){output.rawStopReason=event.delta.stop_reason;let stopReasonResult=mapStopReason(event.
|
|
32
|
-
delta.stop_reason,event.delta.stop_details);output.stopReason=stopReasonResult.stopReason,stopReasonResult.errorMessage&&(output.errorMessage=stopReasonResult.errorMessage)}if(event.usage){event.usage.input_tokens!=null&&(output.usage.input=event.usage.input_tokens,inputUsageIncomplete=hasIncompleteUsage([event.usage.input_tokens])),event.usage.output_tokens!=null&&(output.usage.output=event.usage.output_tokens),event.usage.cache_read_input_tokens!==void 0&&(optionalUsage.cacheRead=event.usage.cache_read_input_tokens),
|
|
33
|
-
event.usage.cache_read_input_tokens!=null&&(output.usage.cacheRead=event.usage.cache_read_input_tokens),event.usage.cache_creation_input_tokens!==void 0&&(optionalUsage.cacheWrite=event.usage.cache_creation_input_tokens),event.usage.cache_creation_input_tokens!=null&&(output.usage.cacheWrite=event.usage.cache_creation_input_tokens);let cacheCreation=event.usage.cache_creation;cacheCreation?.ephemeral_1h_input_tokens!==void 0&&(optionalUsage.cacheWrite1h=cacheCreation.ephemeral_1h_input_tokens),cacheCreation?.
|
|
34
|
-
ephemeral_1h_input_tokens!=null&&(output.usage.cacheWrite1h=cacheCreation.ephemeral_1h_input_tokens);let thinkingTokens=event.usage.output_tokens_details?.thinking_tokens;thinkingTokens!==void 0&&(optionalUsage.reasoning=thinkingTokens),event.delta.stop_reason&&(output.usage.usageIncomplete=inputUsageIncomplete||hasIncompleteUsage([event.usage.output_tokens],[event.usage.input_tokens,...Object.values(optionalUsage)])),thinkingTokens!=null&&(output.usage.reasoning=thinkingTokens)}output.usage.totalTokens=
|
|
35
|
-
output.usage.input+output.usage.output+output.usage.cacheRead+output.usage.cacheWrite,output.usage.usageIncomplete||=hasIncompleteUsage([output.usage.totalTokens]),calculateCost(usageModel,output.usage)}if(options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Anthropic stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");for(let block of blocks)
|
|
36
|
-
if(block.type==="toolCall"&&block.partialJson!==void 0){if(output.stopReason!=="length")throw new Error(`Anthropic stream completed with an unfinished tool call: ${block.name} (${block.id})`);block.arguments=parseStreamingJson(block.partialJson),delete block.partialJson}inputTransformations&&inputTransformations.length>0&&appendAssistantMessageDiagnostic(output,{type:"anthropic_input_transformations",timestamp:Date.now(),details:{transformations:inputTransformations.map(transformation=>({type:transformation.
|
|
37
|
-
type??void 0,path:transformation.path??void 0,reason:transformation.reason??void 0}))}}),stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){for(let block of output.content){delete block.index;let partialJson=block.partialJson;block.type==="toolCall"&&partialJson!==void 0&&(block.arguments=parseStreamingJson(partialJson)),delete block.partialJson}output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=error instanceof Error?error.
|
|
38
|
-
message:JSON.stringify(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2};function mapThinkingLevelToEffort(model,level){let mapped=level?model.thinkingLevelMap?.[level]:void 0;if(typeof mapped=="string")return mapped;switch(level){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var streamSimple=(model,context,options)=>{getAnthropicFederation(model,options?.apiKey,options?.headers,options?.
|
|
39
|
-
env)||assertRequestAuth(model.provider,options?.apiKey,options?.headers);let base={...buildBaseOptions(model,context,options,options?.apiKey),toolChoice:options?.toolChoice};if(!options?.reasoning)return stream(model,context,{...base,thinkingEnabled:!1});if(model.compat?.forceAdaptiveThinking===!0){let effort=mapThinkingLevelToEffort(model,options.reasoning);return stream(model,context,{...base,thinkingEnabled:!0,effort})}let adjusted=adjustMaxTokensForThinking(base.maxTokens,model.maxTokens,options.
|
|
40
|
-
reasoning,options.thinkingBudgets),maxTokens=clampMaxTokensToContext(model,context,adjusted.maxTokens);return stream(model,context,{...base,maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(adjusted.thinkingBudget,Math.max(0,maxTokens-1024))})};function isOAuthToken(apiKey){return apiKey.startsWith("sk-ant-oat")}function createClient(model,apiKey,optionsHeaders,fetch,dynamicHeaders,sessionId,federation){if(model.provider==="github-copilot")return{client:new PiAnthropic({apiKey:null,authToken:apiKey??
|
|
41
|
-
null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeClientHeaders({accept:"application/json","anthropic-dangerous-direct-browser-access":"true"},model.headers,dynamicHeaders,optionsHeaders)}),isOAuthToken:!1};if(apiKey&&isOAuthToken(apiKey))return{client:new PiAnthropic({apiKey:null,authToken:apiKey,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeClientHeaders({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","use\
|
|
42
|
-
r-agent":`claude-cli/${claudeCodeVersion}`,"x-app":"cli"},model.headers,optionsHeaders)}),isOAuthToken:!0};let compat=getAnthropicCompat(model),sessionAffinityHeaders={};if(sessionId&&compat.sendSessionAffinityHeaders){let header=compat.sessionAffinityFormat==="openrouter"?"x-session-id":"x-session-affinity";sessionAffinityHeaders[header]=sessionId}let defaultHeaders=mergeClientHeaders({accept:"application/json","anthropic-dangerous-direct-browser-access":"true"},sessionAffinityHeaders,model.headers,
|
|
43
|
-
optionsHeaders);if(federation){let key=JSON.stringify([model.baseUrl,federation]);if(federationClient?.key!==key||federationClient.fetch!==fetch){let client2=new PiAnthropic({apiKey:null,authToken:null,config:federation,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch});federationClient={key,fetch,client:client2}}return{client:federationClient.client.withOptions({defaultHeaders}),isOAuthToken:!1}}return{client:new PiAnthropic({apiKey:apiKey??null,authToken:null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,
|
|
44
|
-
fetch,defaultHeaders}),isOAuthToken:!1}}function getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options){let configuredFeatures;for(let headers of[model.headers,options?.headers])for(let[name,value]of Object.entries(headers??{}))name.toLowerCase()==="anthropic-beta"&&(configuredFeatures=value);if(configuredFeatures===null)return[];if(configuredFeatures!==void 0)return[...new Set(configuredFeatures.split(",").map(feature=>feature.trim()).filter(feature=>feature.length>0))];let features=[];
|
|
45
|
-
return isOAuthToken2&&features.push("claude-code-20250219","oauth-2025-04-20"),shouldUseFineGrainedToolStreamingBeta(model,context)&&features.push(FINE_GRAINED_TOOL_STREAMING_BETA),model.reasoning&&options?.thinkingEnabled===!0&&(options.interleavedThinking??!0)&&model.compat?.forceAdaptiveThinking!==!0&&features.push(INTERLEAVED_THINKING_BETA),shouldUseServerSideFallbackBeta(model)&&features.push(SERVER_SIDE_FALLBACK_BETA),model.compat?.supportsMidConvoEffort===!0&&features.push(MID_CONVERSATION_OUTPUT_CONFIG_BETA,
|
|
46
|
-
THINKING_BINDING_CONTROLS_BETA),nativeToolChanges&&features.push(INLINE_TOOLS_BETA),[...new Set(features)]}function buildParams(model,context,isOAuthToken2,options,disablePreferredStrictTools=!1){let{cacheControl}=getCacheControl(model,options?.cacheRetention,options?.env),compat=getAnthropicCompat(model),initialSystemMessage=getInitialSystemMessage(context.messages),initialSystemText=initialSystemMessage?getSystemMessageText(initialSystemMessage):"",transformedMessages=transformMessages(context.
|
|
47
|
-
messages,model,normalizeToolCallId),conversationMessages=initialSystemMessage?transformedMessages.slice(1):transformedMessages,hasPreferredStrictTools=!1,convertToolDefinitions=(tools,toolCacheControl2)=>{let definitions=convertTools(tools,isOAuthToken2,compat.supportsEagerToolInputStreaming,compat.supportsStrictTools,toolCacheControl2,disablePreferredStrictTools);return definitions.some((definition,index)=>{let config=tools[index].constrainedSampling;return definition.strict===!0&&config&&config.
|
|
48
|
-
type==="json_schema"&&config.strict==="prefer"})&&(hasPreferredStrictTools=!0),definitions},initialTools=initialSystemMessage?.toolsAdded??[],nativeToolChanges=compat.supportsMidConvoSystemMessages&&compat.supportsMidConvoToolChanges&&initialTools.length>0,converted=convertMessages(conversationMessages,isOAuthToken2,cacheControl,compat.allowEmptySignature,model.compat?.supportsMidConvoEffort===!0?model.provider:void 0,nativeToolChanges?convertToolDefinitions:void 0),activeEffort=options?.effort??
|
|
49
|
-
"high",betaFeatures=getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options),params={model:model.id,messages:model.compat?.supportsMidConvoEffort===!0?insertThinkingLevelMessages(converted,activeEffort):converted.messages,max_tokens:options?.maxTokens??model.maxTokens,stream:!0,...betaFeatures.length>0?{betas:betaFeatures}:{}};isOAuthToken2?(params.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...cacheControl?{cache_control:cacheControl}:{}}],
|
|
50
|
-
initialSystemText&¶ms.system.push({type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}})):initialSystemText&&(params.system=[{type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}}]),options?.temperature!==void 0&&!options?.thinkingEnabled&&model.compat?.supportsMidConvoEffort!==!0&&compat.supportsTemperature&&(params.temperature=options.temperature);let toolCacheControl=compat.supportsCacheControlOnTools?
|
|
51
|
-
cacheControl:void 0;if(nativeToolChanges)params.tools=[...convertToolDefinitions(initialTools,toolCacheControl),DEFERRED_TOOL_PLACEHOLDER];else{let tools=getCurrentTools(context.messages);tools.length>0&&(params.tools=convertToolDefinitions(tools,toolCacheControl))}if(model.compat?.supportsMidConvoEffort===!0)params.thinking={type:"adaptive",display:options?.thinkingDisplay??"summarized",block_binding:{prefix_mismatch_behavior:"drop_block"}},params.output_config={effort:"high"};else if(model.reasoning)
|
|
52
|
-
if(options?.thinkingEnabled){let display=options.thinkingDisplay??"summarized";model.compat?.forceAdaptiveThinking===!0?(params.thinking={type:"adaptive",display},options.effort&&(params.output_config={effort:options.effort})):params.thinking={type:"enabled",budget_tokens:options.thinkingBudgetTokens||1024,display}}else options?.thinkingEnabled===!1&&model.thinkingLevelMap?.off!==null&&(params.thinking={type:"disabled"});if(options?.metadata){let userId=options.metadata.user_id;typeof userId=="s\
|
|
53
|
-
tring"&&(params.metadata={user_id:userId})}options?.toolChoice&&(typeof options.toolChoice=="string"?params.tool_choice={type:options.toolChoice}:params.tool_choice=options.toolChoice);let allowedFallbackModels=model.compat?.allowedFallbackModels;return allowedFallbackModels&&allowedFallbackModels.length>0&&(params.fallbacks=allowedFallbackModels.map(fallback=>({model:fallback.model}))),{params,hasPreferredStrictTools}}function normalizeToolCallId(id){return id.replace(/[^a-zA-Z0-9_-]/g,"_").slice(
|
|
54
|
-
0,64)}function convertToolResult(msg){return{type:"tool_result",tool_use_id:msg.toolCallId,content:convertContentBlocks(msg.content),is_error:msg.isError}}function convertMessages(transformedMessages,isOAuthToken2,cacheControl,allowEmptySignature=!1,managedProvider,convertToolDefinitions){let params=[],assistantLevels=new Map,pendingSystemMessages=[],flushPendingSystemMessages=()=>{params.push(...pendingSystemMessages),pendingSystemMessages.length=0};for(let i=0;i<transformedMessages.length;i++){
|
|
55
|
-
let msg=transformedMessages[i];if(msg.role==="system"){let text=renderSystemMessageUpdate(msg),blocks=[];if(text.length>0&&blocks.push({type:"text",text:sanitizeSurrogates(text)}),convertToolDefinitions){let added=msg.toolsAdded??[],redefined=new Set(added.map(tool=>tool.name));for(let tool of msg.toolsRemoved??[])redefined.has(tool.name)||blocks.push({type:"tool_removal",tool:{type:"tool_reference",name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name}});for(let definition of convertToolDefinitions(
|
|
56
|
-
added))blocks.push({type:"tool_addition",tool:{type:"tool_definition",definition}})}blocks.length>0&&pendingSystemMessages.push({role:"system",content:blocks})}else if(msg.role==="user")if(typeof msg.content=="string")msg.content.trim().length>0&¶ms.push({role:"user",content:sanitizeSurrogates(msg.content)});else{let filteredBlocks=msg.content.map(item=>item.type==="text"?{type:"text",text:sanitizeSurrogates(item.text)}:{type:"image",source:{type:"base64",media_type:item.mimeType,data:item.data}}).
|
|
57
|
-
filter(b=>b.type==="text"?b.text.trim().length>0:!0);if(filteredBlocks.length===0)continue;params.push({role:"user",content:filteredBlocks})}else if(msg.role==="assistant"){flushPendingSystemMessages();let blocks=[];for(let block of msg.content)if(block.type==="text"){if(block.text.trim().length===0)continue;blocks.push({type:"text",text:sanitizeSurrogates(block.text)})}else if(block.type==="thinking"){if(block.redacted){blocks.push({type:"redacted_thinking",data:block.thinkingSignature});continue}
|
|
58
|
-
let thinkingSignature=block.thinkingSignature,hasThinkingSignature=!!thinkingSignature&&thinkingSignature.trim().length>0;if(block.thinking.trim().length===0&&!hasThinkingSignature)continue;hasThinkingSignature?blocks.push({type:"thinking",thinking:sanitizeSurrogates(block.thinking),signature:thinkingSignature}):blocks.push(allowEmptySignature?{type:"thinking",thinking:sanitizeSurrogates(block.thinking),signature:""}:{type:"text",text:sanitizeSurrogates(block.thinking)})}else block.type==="toolC\
|
|
59
|
-
all"&&blocks.push({type:"tool_use",id:block.id,name:isOAuthToken2?toClaudeCodeName(block.name):block.name,input:block.arguments??{}});if(blocks.length===0)continue;let messageIndex=params.length;params.push({role:"assistant",content:blocks}),managedProvider!==void 0&&msg.api==="anthropic-messages"&&msg.provider===managedProvider&&isAnthropicEffort(msg.providerThinkingLevel)&&assistantLevels.set(messageIndex,msg.providerThinkingLevel)}else if(msg.role==="toolResult"){let toolResults=[],j=i;for(;j<
|
|
60
|
-
transformedMessages.length&&transformedMessages[j].role==="toolResult";)toolResults.push(convertToolResult(transformedMessages[j])),j++;i=j-1,params.push({role:"user",content:toolResults})}}if(flushPendingSystemMessages(),cacheControl&¶ms.length>0){let lastMessage=params[params.length-1];if(lastMessage.role==="user"||lastMessage.role==="system")if(Array.isArray(lastMessage.content)){let lastBlock=lastMessage.content[lastMessage.content.length-1];lastBlock&&(lastBlock.type==="text"||lastBlock.
|
|
61
|
-
type==="image"||lastBlock.type==="tool_result"||lastBlock.type==="tool_addition"||lastBlock.type==="tool_removal")&&(lastBlock.cache_control=cacheControl)}else typeof lastMessage.content=="string"&&(lastMessage.content=[{type:"text",text:lastMessage.content,cache_control:cacheControl}])}return{messages:params,assistantLevels}}function isAnthropicEffort(value){return value==="low"||value==="medium"||value==="high"||value==="xhigh"||value==="max"}function insertThinkingLevelMessages(converted,activeEffort){
|
|
62
|
-
let messages=[];for(let index=0;index<converted.messages.length;index++){let historicalEffort=converted.assistantLevels.get(index);historicalEffort!==void 0&&messages.push({role:"system",content:[],output_config:{effort:historicalEffort}}),messages.push(converted.messages[index])}return messages.push({role:"system",content:[],output_config:{effort:activeEffort}}),messages}function shouldUseFineGrainedToolStreamingBeta(model,context){return getCurrentTools(context.messages).length>0&&!getAnthropicCompat(
|
|
63
|
-
model).supportsEagerToolInputStreaming}var ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS=new Set(["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","maxItems","uniqueItems","minContains","maxContains","minProperties","maxProperties"]),ANTHROPIC_STRICT_STRING_FORMATS=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),isAnthropicStrictUnsupportedKeyword=(key,value)=>ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS.has(key)?!0:key==="minItems"?value!==0&&
|
|
64
|
-
value!==1:key==="format"?typeof value!="string"||!ANTHROPIC_STRICT_STRING_FORMATS.has(value):!1;function convertTools(tools,isOAuthToken2,supportsEagerToolInputStreaming,supportsStrictTools,cacheControl,disablePreferredStrictTools=!1){return tools?tools.map((tool,index)=>{let config=tool.constrainedSampling,strict=disablePreferredStrictTools&&config&&config.type==="json_schema"&&config.strict==="prefer"?void 0:resolveJsonSchemaStrictSampling(tool,supportsStrictTools,isAnthropicStrictUnsupportedKeyword),
|
|
65
|
-
parameters=getJsonSchemaToolParameters(tool,strict),schema=parameters,legacyInputSchema={type:"object",properties:schema.properties??{},required:schema.required??[]},inputSchema=strict===!0?{...parameters,...legacyInputSchema}:legacyInputSchema;return{name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name,description:tool.description,...supportsEagerToolInputStreaming?{eager_input_streaming:!0}:{},...strict===!0?{strict:!0}:{},input_schema:inputSchema,...cacheControl&&index===tools.length-1?{cache_control:cacheControl}:
|
|
66
|
-
{}}}):[]}function mapStopReason(reason,stopDetails){switch(reason){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:stopDetails?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error",errorMessage:"Provider stopped with: sensitive"};default:
|
|
67
|
-
throw new Error(`Unhandled stop reason: ${reason}`)}}export{stream,streamSimple};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{convertResponsesMessages,convertResponsesTools,processResponsesStream}from"./chunk-2TTB6GIB.js";import{iterateOpenAIStream}from"./chunk-EYIYBQAR.js";import{clampOpenAIPromptCacheKey}from"./chunk-PRRNXB7S.js";import{AzureOpenAI}from"./chunk-AIXI6RIE.js";import"./chunk-YZMQXAJM.js";import{retryProviderRequest}from"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import"./chunk-PJACZCIR.js";import{
|
|
3
|
-
buildBaseOptions,createGrammarToolInputProperties,getPiUserAgent,resolveSamplingParams}from"./chunk-UDVC7A5S.js";import"./chunk-YTVFIA3A.js";import"./chunk-L2ZPNLYD.js";import{createRequestObserver,headersToRecord,observeFetch}from"./chunk-5CDES42D.js";import{resolveAzureConfig,resolveDeploymentName}from"./chunk-CIA6V3BP.js";import"./chunk-FACBDLFU.js";import"./chunk-MG5PX4KU.js";import{clampThinkingLevel,getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-LUL775V7.js";
|
|
4
|
-
import{AssistantMessageEventStream}from"./chunk-RYC5BYVE.js";import"./chunk-VEYTRNQC.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
|
-
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
|
-
model,apiKey,options,observeFetch(options?.fetch,observe)),grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages),model.compat?.supportsOpenAIGrammarTools??!1),params=buildParams(model,normalizedContext,options,deploymentName,grammarToolInputProperties),nextParams=await options?.onPayload?.(params,model);nextParams!==void 0&&(params=nextParams);let requestOptions={...options?.signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.
|
|
7
|
-
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(iterateOpenAIStream(openaiStream,response,client),output,stream2,model,{onProviderStreamEvent:options?.
|
|
8
|
-
onProviderStreamEvent,grammarToolInputProperties}),options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){for(let block of output.content)delete block.index,delete block.
|
|
9
|
-
partialJson,delete block.customInput;output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=formatAzureOpenAIError(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2},streamSimple=(model,context,options)=>{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let base={...buildBaseOptions(model,context,options,apiKey),toolChoice:options?.toolChoice},clampedReasoning=options?.
|
|
10
|
-
reasoning?clampThinkingLevel(model,options.reasoning):void 0;return stream(model,context,{...base,reasoningEffort:clampedReasoning==="off"?void 0:clampedReasoning})};function createClient(model,apiKey,options,fetch){let headers={"User-Agent":getPiUserAgent(),...model.headers};options?.headers&&Object.assign(headers,options.headers);let{baseUrl,apiVersion}=resolveAzureConfig(model,options);return new AzureOpenAI({apiKey,apiVersion,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:headers,baseURL:baseUrl})}
|
|
11
|
-
function buildParams(model,context,options,deploymentName,grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(context.messages),model.compat?.supportsOpenAIGrammarTools??!1)){let supportsAdditionalTools=model.compat?.supportsAdditionalTools??!1,supportsToolSearch=model.compat?.supportsToolSearch??!1,transcriptTools=resolveTranscriptTools(context.messages,supportsAdditionalTools||supportsToolSearch),messages=convertResponsesMessages(model,context,AZURE_TOOL_CALL_PROVIDERS,
|
|
12
|
-
{grammarToolInputProperties,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools,supportsToolSearch,toolOptions:{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1}}),params={model:deploymentName,input:messages,stream:!0,prompt_cache_key:clampOpenAIPromptCacheKey(options?.sessionId),store:!1};options?.maxTokens&&(params.max_output_tokens=Math.max(options.maxTokens,OPENAI_RESPONSES_MIN_OUTPUT_TOKENS)),
|
|
13
|
-
options?.temperature!==void 0&&(params.temperature=options?.temperature),transcriptTools.requestTools.length>0&&(params.tools=convertResponsesTools(transcriptTools.requestTools,{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1})),options?.toolChoice!==void 0&&(params.tool_choice=options.toolChoice);let reasoningEffort=options?.reasoningEffort??(options?.reasoningSummary?"medium":void 0);if(model.reasoning)if(reasoningEffort){
|
|
14
|
-
let effort=options?.reasoningEffort?model.thinkingLevelMap?.[options.reasoningEffort]??options.reasoningEffort:reasoningEffort;params.reasoning={effort,summary:options?.reasoningSummary||"auto"},params.include=["reasoning.encrypted_content"]}else model.thinkingLevelMap?.off!==null&&(params.reasoning={effort:model.thinkingLevelMap?.off??"none"});let samplingParams=resolveSamplingParams(model,reasoningEffort??"off",options?.samplingParams);return samplingParams&&Object.assign(params,samplingParams),
|
|
15
|
-
params}export{stream,streamSimple};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{shortHash}from"./chunk-PJACZCIR.js";import{appendGrammarToolInputJsonDelta,getGrammarToolInput,getJsonSchemaToolParameters,resolveGrammarConstrainedSampling,resolveJsonSchemaStrictSampling,transformMessages}from"./chunk-UDVC7A5S.js";import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{parseStreamingJson,parseStreamingJsonWhileStreaming}from"./chunk-MG5PX4KU.js";import{calculateCost,getSystemMessageText,
|
|
3
|
-
renderSystemMessageUpdate,resolveTranscript,resolveTranscriptTools}from"./chunk-LUL775V7.js";function encodeTextSignatureV1(id,phase){let payload={v:1,id};return phase&&(payload.phase=phase),JSON.stringify(payload)}function parseTextSignature(signature){if(signature){if(signature.startsWith("{"))try{let parsed=JSON.parse(signature);if(parsed.v===1&&typeof parsed.id=="string")return parsed.phase==="commentary"||parsed.phase==="final_answer"?{id:parsed.id,phase:parsed.phase}:{id:parsed.id}}catch{}return{id:signature}}}function convertToolResultOutput(model,content){let textResult=content.
|
|
4
|
-
filter(c=>c.type==="text").map(c=>c.text).join(`
|
|
5
|
-
`),images=content.filter(c=>c.type==="image"),hasText=textResult.length>0;if(images.length===0||!model.input.includes("image"))return sanitizeSurrogates(hasText?textResult:images.length>0?"(see attached image)":"(no tool output)");let output=[];hasText&&output.push({type:"input_text",text:sanitizeSurrogates(textResult)});for(let image of images)output.push({type:"input_image",detail:"auto",image_url:`data:${image.mimeType};base64,${image.data}`});return output}function convertResponsesMessages(model,context,allowedToolCallProviders,options){
|
|
6
|
-
let normalizedContext=resolveTranscript(context,options?.supportsMidConvoSystemMessages),messages=[],normalizeIdPart=part=>{let sanitized=part.replace(/[^a-zA-Z0-9_-]/g,"_");return(sanitized.length>64?sanitized.slice(0,64):sanitized).replace(/_+$/,"")},buildForeignResponsesItemId=itemId=>{let normalized=`fc_${shortHash(itemId)}`;return normalized.length>64?normalized.slice(0,64):normalized},normalizeToolCallId=(id,_targetModel,source)=>{if(!allowedToolCallProviders.has(model.provider)||!id.includes(
|
|
7
|
-
"|"))return normalizeIdPart(id);let[callId,itemId]=id.split("|"),normalizedCallId=normalizeIdPart(callId),normalizedItemId=source.provider!==model.provider||source.api!==model.api?buildForeignResponsesItemId(itemId):normalizeIdPart(itemId);return normalizedItemId.startsWith("fc_")||(normalizedItemId=normalizeIdPart(`fc_${normalizedItemId}`)),`${normalizedCallId}|${normalizedItemId}`},transformedMessages=transformMessages(normalizedContext.messages,model,normalizeToolCallId),transcriptTools=resolveTranscriptTools(
|
|
8
|
-
normalizedContext.messages,(options?.supportsAdditionalTools??!1)||(options?.supportsToolSearch??!1)),appendSystemToolAdditions=(message,seed)=>{let tools=transcriptTools.anchorsAdditions?message.toolsAdded??[]:[];if(tools.length===0)return;if(options?.supportsAdditionalTools){messages.push({type:"additional_tools",role:"developer",tools:convertResponsesTools(tools,options.toolOptions)});return}if(!options?.supportsToolSearch)return;let names=tools.map(tool=>tool.name),callId=`pi_tool_load_${shortHash(
|
|
9
|
-
`${seed}:${names.join(",")}`)}`;messages.push({type:"tool_search_call",call_id:callId,execution:"client",status:"completed",arguments:{query:names.join(" "),limit:names.length}}),messages.push({type:"tool_search_output",call_id:callId,execution:"client",status:"completed",tools:convertResponsesTools(tools,{...options.toolOptions,toolSearchResult:!0})})},includeInitialSystemMessage=options?.includeSystemPrompt??!0,compat=model.compat,instructionRole=model.reasoning&&compat?.supportsDeveloperRole!==
|
|
10
|
-
!1?"developer":"system",msgIndex=0,sourceIndex=0;for(let msg of transformedMessages){let isLeadingSystemMessage=sourceIndex++===0&&msg.role==="system";if(msg.role==="system"){if(isLeadingSystemMessage||appendSystemToolAdditions(msg,`system:${msgIndex}`),!isLeadingSystemMessage||includeInitialSystemMessage){let text=isLeadingSystemMessage?getSystemMessageText(msg):renderSystemMessageUpdate(msg);text.length>0&&messages.push({role:instructionRole,content:sanitizeSurrogates(text)})}}else if(msg.role===
|
|
11
|
-
"user")if(typeof msg.content=="string")messages.push({role:"user",content:[{type:"input_text",text:sanitizeSurrogates(msg.content)}]});else{let content=msg.content.map(item=>item.type==="text"?{type:"input_text",text:sanitizeSurrogates(item.text)}:{type:"input_image",detail:"auto",image_url:`data:${item.mimeType};base64,${item.data}`});if(content.length===0)continue;messages.push({role:"user",content})}else if(msg.role==="assistant"){let output=[],assistantMsg=msg,isSameProviderAndApi=assistantMsg.
|
|
12
|
-
provider===model.provider&&assistantMsg.api===model.api,isSameModel=isSameProviderAndApi&&assistantMsg.model===model.id,isDifferentModel=isSameProviderAndApi&&assistantMsg.model!==model.id,textBlockIndex=0;for(let block of msg.content)if(block.type==="thinking"){if(block.thinkingSignature){let reasoningItem=JSON.parse(block.thinkingSignature);output.push(reasoningItem)}}else if(block.type==="text"){let textBlock=block,parsedSignature=parseTextSignature(textBlock.textSignature),fallbackMessageId=textBlockIndex===
|
|
13
|
-
0?`msg_pi_${msgIndex}`:`msg_pi_${msgIndex}_${textBlockIndex}`;textBlockIndex++;let msgId=parsedSignature?.id;msgId?msgId.length>64&&(msgId=`msg_${shortHash(msgId)}`):msgId=fallbackMessageId,output.push({type:"message",role:"assistant",content:[{type:"output_text",text:sanitizeSurrogates(textBlock.text),annotations:[]}],status:"completed",id:msgId,phase:parsedSignature?.phase})}else if(block.type==="toolCall"){let toolCall=block,[callId,itemIdRaw]=toolCall.id.split("|"),customInputProperty=options?.
|
|
14
|
-
grammarToolInputProperties?.get(toolCall.name),itemId=itemIdRaw,itemIdPrefix=customInputProperty===void 0?"fc_":"ctc_";(isDifferentModel||!itemId?.startsWith(itemIdPrefix))&&(itemId=void 0),customInputProperty!==void 0?output.push({type:"custom_tool_call",id:itemId,call_id:callId,name:toolCall.name,input:sanitizeSurrogates(getGrammarToolInput(toolCall.name,toolCall.arguments,customInputProperty)),...isSameModel&&toolCall.namespace!==void 0?{namespace:toolCall.namespace}:{}}):output.push({type:"f\
|
|
15
|
-
unction_call",id:itemId,call_id:callId,name:toolCall.name,arguments:JSON.stringify(toolCall.arguments),...isSameModel&&toolCall.namespace!==void 0?{namespace:toolCall.namespace}:{}})}if(output.length===0)continue;messages.push(...output)}else if(msg.role==="toolResult"){let[callId]=msg.toolCallId.split("|"),output=convertToolResultOutput(model,msg.content);options?.grammarToolInputProperties?.has(msg.toolName)?messages.push({type:"custom_tool_call_output",call_id:callId,output}):messages.push({type:"\
|
|
16
|
-
function_call_output",call_id:callId,output})}isLeadingSystemMessage||msgIndex++}return messages}function convertResponsesTools(tools,options){let defaultStrict=options?.strict===void 0?!1:options.strict,supportsStrictMode=options?.supportsStrictMode??!0,supportsOpenAIGrammarTools=options?.supportsOpenAIGrammarTools??!1;return tools.map(tool=>{let grammar=resolveGrammarConstrainedSampling(tool,supportsOpenAIGrammarTools);if(grammar)return{type:"custom",name:tool.name,description:tool.description,
|
|
17
|
-
format:{type:"grammar",syntax:grammar.format,definition:grammar.definition},...options?.toolSearchResult?{defer_loading:!0}:{}};let strict=resolveJsonSchemaStrictSampling(tool,supportsStrictMode)??defaultStrict,functionTool={type:"function",name:tool.name,description:tool.description,parameters:getJsonSchemaToolParameters(tool,strict===!0),...options?.toolSearchResult?{defer_loading:!0}:{}};return supportsStrictMode&&(functionTool.strict=strict),functionTool})}function getCustomToolCallInput(block){
|
|
18
|
-
let property=block.customInput?.property;if(property===void 0)return"";let value=block.arguments[property];return typeof value=="string"?value:""}function appendCustomToolCallInput(block,nextInput,close){let customInput=block.customInput;if(!customInput)return;let delta=appendGrammarToolInputJsonDelta(customInput.jsonBuffer,customInput.property,nextInput,close);return block.arguments={[customInput.property]:nextInput},delta}async function processResponsesStream(openaiStream,output,stream,model,options){
|
|
19
|
-
let sawTerminalResponseEvent=!1,outputSlots=new Map,reasoningBlocksById=new Map,applyMessagePhaseStopReason=item=>{item.type==="message"&&item.phase==="final_answer"&&(output.stopReason="stop")},getSlot=(outputIndex,type)=>{let slot=outputSlots.get(outputIndex);return slot?.type===type?slot:void 0},pushToolCallDelta=(slot,delta)=>{delta!==void 0&&stream.push({type:"toolcall_delta",contentIndex:slot.contentIndex,delta,partial:output})},createSlot=(outputIndex,item)=>{if(item.type==="reasoning"){let block={
|
|
20
|
-
type:"thinking",thinking:""};output.content.push(block);let slot={type:"thinking",block,contentIndex:output.content.length-1};return outputSlots.set(outputIndex,slot),stream.push({type:"thinking_start",contentIndex:slot.contentIndex,partial:output}),slot}if(item.type==="message"){applyMessagePhaseStopReason(item);let block={type:"text",text:""};output.content.push(block);let slot={type:"text",block,contentIndex:output.content.length-1};return outputSlots.set(outputIndex,slot),stream.push({type:"\
|
|
21
|
-
text_start",contentIndex:slot.contentIndex,partial:output}),slot}if(item.type==="function_call"){let block={type:"toolCall",id:`${item.call_id}|${item.id}`,name:item.name,arguments:{},...item.namespace!==void 0?{namespace:item.namespace}:{},partialJson:item.arguments||""};output.content.push(block);let slot={type:"toolCall",block,contentIndex:output.content.length-1};return outputSlots.set(outputIndex,slot),stream.push({type:"toolcall_start",contentIndex:slot.contentIndex,partial:output}),slot}if(item.
|
|
22
|
-
type==="custom_tool_call"){let inputProperty=options?.grammarToolInputProperties?.get(item.name)??"input",input=item.input||"",block={type:"toolCall",id:`${item.call_id}|${item.id}`,name:item.name,arguments:{[inputProperty]:input},...item.namespace!==void 0?{namespace:item.namespace}:{},customInput:{property:inputProperty,jsonBuffer:{input:"",started:!1,closed:!1}}};output.content.push(block);let slot={type:"toolCall",block,contentIndex:output.content.length-1};return outputSlots.set(outputIndex,
|
|
23
|
-
slot),stream.push({type:"toolcall_start",contentIndex:slot.contentIndex,partial:output}),slot}},getOrCreateSlot=(outputIndex,item)=>outputSlots.get(outputIndex)??createSlot(outputIndex,item),backfillReasoningSignatures=responseOutput=>{for(let item of responseOutput){if(item.type!=="reasoning"||!item.encrypted_content)continue;let block=reasoningBlocksById.get(item.id);if(!block?.thinkingSignature)continue;let storedItem=JSON.parse(block.thinkingSignature);storedItem.encrypted_content||(block.thinkingSignature=
|
|
24
|
-
JSON.stringify({...storedItem,encrypted_content:item.encrypted_content}))}},finalizeResponse=response=>{if(sawTerminalResponseEvent=!0,backfillReasoningSignatures(response.output??[]),response?.id&&(output.responseId=response.id),response?.usage){let inputDetails=response.usage.input_tokens_details,cachedTokens=inputDetails?.cached_tokens||0,cacheWriteTokens=inputDetails?.cache_write_tokens||0,uncachedInput=(response.usage.input_tokens||0)-cachedTokens-cacheWriteTokens,totalTokens=response.usage.
|
|
25
|
-
total_tokens??(response.usage.input_tokens||0)+(response.usage.output_tokens||0);output.usage={usageIncomplete:hasIncompleteUsage([response.usage.input_tokens,response.usage.output_tokens,uncachedInput,totalTokens],[response.usage.total_tokens,inputDetails?.cached_tokens,inputDetails?.cache_write_tokens,response.usage.output_tokens_details?.reasoning_tokens]),input:Math.max(0,uncachedInput),output:response.usage.output_tokens||0,cacheRead:cachedTokens,cacheWrite:cacheWriteTokens,reasoning:response.
|
|
26
|
-
usage.output_tokens_details?.reasoning_tokens||0,totalTokens,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(calculateCost(model,output.usage),options?.applyServiceTierPricing){let serviceTier=options.resolveServiceTier?options.resolveServiceTier(response?.service_tier,options.serviceTier):response?.service_tier??options.serviceTier;options.applyServiceTierPricing(output.usage,serviceTier)}let status=response?.status,incompleteDetails=response?.incomplete_details,incompleteReason=typeof incompleteDetails?.
|
|
27
|
-
reason=="string"?incompleteDetails.reason:void 0;output.rawStopReason=incompleteReason?`${status}.${incompleteReason}`:status;let mappedStop=mapStopReason(status,incompleteReason);output.stopReason=mappedStop.stopReason,mappedStop.errorMessage===void 0?delete output.errorMessage:output.errorMessage=mappedStop.errorMessage,output.content.some(b=>b.type==="toolCall")&&output.stopReason==="stop"&&(output.stopReason="toolUse")};try{for await(let event of openaiStream)if(await options?.onProviderStreamEvent?.(
|
|
28
|
-
event,model),event.type==="response.created")output.responseId=event.response.id;else if(event.type==="response.output_item.added")createSlot(event.output_index,event.item);else if(event.type==="response.reasoning_summary_text.delta"){let slot=getSlot(event.output_index,"thinking");if(!slot)continue;slot.block.thinking+=event.delta,stream.push({type:"thinking_delta",contentIndex:slot.contentIndex,delta:event.delta,partial:output})}else if(event.type==="response.reasoning_summary_part.done"){let slot=getSlot(
|
|
29
|
-
event.output_index,"thinking");if(!slot)continue;slot.block.thinking+=`
|
|
30
|
-
|
|
31
|
-
`,stream.push({type:"thinking_delta",contentIndex:slot.contentIndex,delta:`
|
|
32
|
-
|
|
33
|
-
`,partial:output})}else if(event.type==="response.reasoning_text.delta"){let slot=getSlot(event.output_index,"thinking");if(!slot)continue;slot.block.thinking+=event.delta,stream.push({type:"thinking_delta",contentIndex:slot.contentIndex,delta:event.delta,partial:output})}else if(event.type==="response.output_text.delta"){let slot=getSlot(event.output_index,"text");if(!slot)continue;slot.block.text+=event.delta,stream.push({type:"text_delta",contentIndex:slot.contentIndex,delta:event.delta,partial:output})}else if(event.
|
|
34
|
-
type==="response.refusal.delta"){let slot=getSlot(event.output_index,"text");if(!slot)continue;slot.block.text+=event.delta,stream.push({type:"text_delta",contentIndex:slot.contentIndex,delta:event.delta,partial:output})}else if(event.type==="response.function_call_arguments.delta"){let slot=getSlot(event.output_index,"toolCall");if(!slot||slot.block.partialJson===void 0)continue;slot.block.partialJson+=event.delta,slot.block.arguments=parseStreamingJsonWhileStreaming(slot.block,slot.block.partialJson,
|
|
35
|
-
slot.block.arguments),pushToolCallDelta(slot,event.delta)}else if(event.type==="response.function_call_arguments.done"){let slot=getSlot(event.output_index,"toolCall");if(!slot||slot.block.partialJson===void 0)continue;let previousPartialJson=slot.block.partialJson;if(slot.block.partialJson=event.arguments,slot.block.arguments=parseStreamingJson(slot.block.partialJson),event.arguments.startsWith(previousPartialJson)){let delta=event.arguments.slice(previousPartialJson.length);delta.length>0&&pushToolCallDelta(
|
|
36
|
-
slot,delta)}}else if(event.type==="response.custom_tool_call_input.delta"){let slot=getSlot(event.output_index,"toolCall");if(!slot?.block.customInput)continue;pushToolCallDelta(slot,appendCustomToolCallInput(slot.block,getCustomToolCallInput(slot.block)+event.delta,!1))}else if(event.type==="response.custom_tool_call_input.done"){let slot=getSlot(event.output_index,"toolCall");if(!slot?.block.customInput)continue;pushToolCallDelta(slot,appendCustomToolCallInput(slot.block,event.input,!0))}else if(event.
|
|
37
|
-
type==="response.output_item.done"){let item=event.item;applyMessagePhaseStopReason(item);let slot=getOrCreateSlot(event.output_index,item);if(item.type==="reasoning"&&slot?.type==="thinking"){let summaryText=item.summary?.map(s=>s.text).join(`
|
|
38
|
-
|
|
39
|
-
`)||"",contentText=item.content?.map(c=>c.text).join(`
|
|
40
|
-
|
|
41
|
-
`)||"";slot.block.thinking=summaryText||contentText||slot.block.thinking,slot.block.thinkingSignature=JSON.stringify(item),reasoningBlocksById.set(item.id,slot.block),stream.push({type:"thinking_end",contentIndex:slot.contentIndex,content:slot.block.thinking,partial:output}),outputSlots.delete(event.output_index)}else item.type==="message"&&slot?.type==="text"?(slot.block.text=item.content?.map(c=>c.type==="output_text"?c.text:c.refusal).join("")||"",slot.block.textSignature=encodeTextSignatureV1(
|
|
42
|
-
item.id,item.phase??void 0),stream.push({type:"text_end",contentIndex:slot.contentIndex,content:slot.block.text,partial:output}),outputSlots.delete(event.output_index)):item.type==="function_call"&&slot?.type==="toolCall"&&slot.block.partialJson!==void 0?(slot.block.arguments=parseStreamingJson(item.arguments||slot.block.partialJson||"{}"),item.namespace!==void 0&&(slot.block.namespace=item.namespace),delete slot.block.partialJson,stream.push({type:"toolcall_end",contentIndex:slot.contentIndex,toolCall:slot.
|
|
43
|
-
block,partial:output}),outputSlots.delete(event.output_index)):item.type==="custom_tool_call"&&slot?.type==="toolCall"&&slot.block.customInput&&(pushToolCallDelta(slot,appendCustomToolCallInput(slot.block,item.input??getCustomToolCallInput(slot.block),!0)),item.namespace!==void 0&&(slot.block.namespace=item.namespace),delete slot.block.customInput,stream.push({type:"toolcall_end",contentIndex:slot.contentIndex,toolCall:slot.block,partial:output}),outputSlots.delete(event.output_index))}else if(event.
|
|
44
|
-
type==="response.completed"||event.type==="response.incomplete")finalizeResponse(event.response);else{if(event.type==="error")throw new Error(`Error Code ${event.code}: ${event.message}`||"Unknown error");if(event.type==="response.failed"){sawTerminalResponseEvent=!0,output.rawStopReason=event.response?.status;let error=event.response?.error,details=event.response?.incomplete_details,msg=error?`${error.code||"unknown"}: ${error.message||"no message"}`:details?.reason?`incomplete: ${details.reason}`:
|
|
45
|
-
"Unknown error (no error details in response)";throw new Error(msg)}}if(!sawTerminalResponseEvent)throw new Error("OpenAI Responses stream ended before a terminal response event");if(output.stopReason==="toolUse")for(let block of output.content){if(block.type!=="toolCall")continue;let toolCall=block;if(toolCall.partialJson!==void 0||toolCall.customInput!==void 0)throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${toolCall.name} (${toolCall.id})`)}}finally{for(let block of output.
|
|
46
|
-
content){if(block.type!=="toolCall")continue;let toolCall=block;toolCall.partialJson!==void 0&&(toolCall.arguments=parseStreamingJson(toolCall.partialJson)),delete toolCall.partialJson,delete toolCall.customInput}}}function mapStopReason(status,incompleteReason){if(!status)return{stopReason:"stop"};switch(status){case"completed":return{stopReason:"stop"};case"incomplete":return incompleteReason==="max_output_tokens"?{stopReason:"length"}:{stopReason:"error",errorMessage:incompleteReason?`Respons\
|
|
47
|
-
e incomplete: ${incompleteReason}`:"Response incomplete without a provider reason"};case"failed":case"cancelled":return{stopReason:"error"};case"in_progress":case"queued":return{stopReason:"stop"};default:{let _exhaustive=status;throw new Error(`Unhandled stop reason: ${_exhaustive}`)}}}export{convertResponsesMessages,convertResponsesTools,processResponsesStream};
|