@humain/humain-code 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +160 -0
- package/README.md +2 -2
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-XFCDMGD6.js +77 -0
- package/dist/bundle/chunks/anthropic.js +25 -24
- package/dist/bundle/chunks/azure-openai-responses-F4KQM3NK.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +460 -431
- package/dist/bundle/chunks/bowser-DXKSTXFQ.js +89 -0
- package/dist/bundle/chunks/{chunk-2G7YVAVF.js → chunk-2JNJJ6SZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-HTA325LJ.js → chunk-2NVGOSBN.js} +1 -1
- package/dist/bundle/chunks/{chunk-5B25YXF7.js → chunk-3CGMVKHA.js} +13 -3
- package/dist/bundle/chunks/{chunk-SCINMV4X.js → chunk-46C6D7UC.js} +22 -21
- package/dist/bundle/chunks/chunk-4MKATHT2.js +24 -0
- package/dist/bundle/chunks/{chunk-TGDPZCSW.js → chunk-4TDNOR36.js} +1 -1
- package/dist/bundle/chunks/{chunk-C6VERWRZ.js → chunk-4XF5JX7X.js} +1 -1
- package/dist/bundle/chunks/{chunk-4HTVBBJD.js → chunk-65FLSKDA.js} +2 -2
- package/dist/bundle/chunks/chunk-6HTHDVJC.js +4 -0
- package/dist/bundle/chunks/{chunk-4PRNKB6V.js → chunk-6P6MMQUH.js} +7 -7
- package/dist/bundle/chunks/{chunk-66FZJO75.js → chunk-6TTMNQXI.js} +472 -3924
- package/dist/bundle/chunks/{chunk-32QLLD2P.js → chunk-6YVORXTX.js} +410 -352
- package/dist/bundle/chunks/chunk-7H2WNBX7.js +11 -0
- package/dist/bundle/chunks/{chunk-2FYYW6FY.js → chunk-7OZNMWAJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-R6YQR7TZ.js → chunk-7WE77IE3.js} +1 -1
- package/dist/bundle/chunks/{chunk-Z5YLKK3S.js → chunk-7WETECIB.js} +1 -1
- package/dist/bundle/chunks/chunk-7X6DNT45.js +78 -0
- package/dist/bundle/chunks/{chunk-KRCX3ZBA.js → chunk-APNPBT7Y.js} +1 -1
- package/dist/bundle/chunks/{chunk-R5OOX7RW.js → chunk-B47PNNLL.js} +9 -2
- package/dist/bundle/chunks/{chunk-PPBDDQHP.js → chunk-CQ2CE3RB.js} +7 -6
- package/dist/bundle/chunks/{chunk-MD7K7RPN.js → chunk-D3KYOSQY.js} +1 -1
- package/dist/bundle/chunks/{chunk-I3NDOUHE.js → chunk-DCXHRP6C.js} +1 -1
- package/dist/bundle/chunks/{chunk-OB332KMV.js → chunk-DD5UT56Y.js} +46 -32
- package/dist/bundle/chunks/{chunk-I5E7RQ5V.js → chunk-DJG2WUNM.js} +5 -5
- package/dist/bundle/chunks/{chunk-4QAXV5T6.js → chunk-E7OBH44W.js} +9 -9
- package/dist/bundle/chunks/{chunk-Q7VXYXY3.js → chunk-ENBDASDN.js} +2 -2
- package/dist/bundle/chunks/{chunk-RS6PZK35.js → chunk-F2H47FRF.js} +249 -216
- package/dist/bundle/chunks/{chunk-2H3LUS62.js → chunk-FJIISX5W.js} +241 -229
- package/dist/bundle/chunks/chunk-FQ4KS5S4.js +23 -0
- package/dist/bundle/chunks/{chunk-SSRCVJZK.js → chunk-GPLWWO5Q.js} +5 -5
- package/dist/bundle/chunks/{chunk-WQOOJP7U.js → chunk-GV5OVRKK.js} +1 -1
- package/dist/bundle/chunks/{chunk-KTSJYIYC.js → chunk-HHWVVNGG.js} +1 -1
- package/dist/bundle/chunks/{chunk-4JRER4XK.js → chunk-HQMUDHC3.js} +19 -19
- package/dist/bundle/chunks/{chunk-G4QPSFBF.js → chunk-IMUFBWEK.js} +216 -223
- package/dist/bundle/chunks/{chunk-RU7ADKA7.js → chunk-J4GII2EE.js} +112 -96
- package/dist/bundle/chunks/{chunk-QT6ZHDMP.js → chunk-JBSWWCT5.js} +1 -1
- package/dist/bundle/chunks/{chunk-PWUDFU5V.js → chunk-JWOPWHVH.js} +4 -4
- package/dist/bundle/chunks/{chunk-AEWYICBL.js → chunk-KI7CHPWC.js} +2 -2
- package/dist/bundle/chunks/{chunk-4V5VL2BO.js → chunk-KLSRGGOH.js} +131 -154
- package/dist/bundle/chunks/{chunk-JF7FYXAI.js → chunk-KONLZKPL.js} +7 -6
- package/dist/bundle/chunks/{chunk-N2SNMUD3.js → chunk-KRBELWQH.js} +1 -1
- package/dist/bundle/chunks/{chunk-UZNIPOGS.js → chunk-L4J7SMJB.js} +1 -1
- package/dist/bundle/chunks/{chunk-EIC7CQX3.js → chunk-LSRXA7OS.js} +1 -1
- package/dist/bundle/chunks/{chunk-GRJUKEE3.js → chunk-MIAXMK5F.js} +4 -4
- package/dist/bundle/chunks/chunk-MPRAQ6ZI.js +41 -0
- package/dist/bundle/chunks/{chunk-GUHNFZ2Q.js → chunk-NICPFMOP.js} +20 -19
- package/dist/bundle/chunks/{chunk-WAPZN4KP.js → chunk-P2Y2H7SD.js} +2 -2
- package/dist/bundle/chunks/{chunk-T7BXP46S.js → chunk-P42E6YY6.js} +1892 -1680
- package/dist/bundle/chunks/{chunk-3EDMWQ35.js → chunk-PFBAIRCY.js} +17 -15
- package/dist/bundle/chunks/{chunk-XHDVDJM7.js → chunk-PVNXN2TC.js} +7 -7
- package/dist/bundle/chunks/{chunk-TWAHPPXN.js → chunk-PWFM6AQQ.js} +1307 -1194
- package/dist/bundle/chunks/{chunk-RNBZBCH2.js → chunk-QJB5YI3I.js} +1 -1
- package/dist/bundle/chunks/{chunk-P6AXBESH.js → chunk-QRRVZYTG.js} +1119 -1098
- package/dist/bundle/chunks/{chunk-WQ7EJQIT.js → chunk-ROFZVEFN.js} +247 -250
- package/dist/bundle/chunks/chunk-SKCJ25SX.js +24 -0
- package/dist/bundle/chunks/{chunk-AZXVJN6E.js → chunk-SXOIQWNX.js} +1 -1
- package/dist/bundle/chunks/{chunk-6E6RHNOU.js → chunk-UXM4WFLH.js} +12 -11
- package/dist/bundle/chunks/{chunk-LB4CIS4F.js → chunk-VCMXBP5S.js} +17 -17
- package/dist/bundle/chunks/{chunk-JYWUOKOI.js → chunk-WBSGWISD.js} +367 -353
- package/dist/bundle/chunks/chunk-XZ7FTBXS.js +2102 -0
- package/dist/bundle/chunks/chunk-YSWDFV2L.js +11 -0
- package/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
- package/dist/bundle/chunks/chunk-ZTG5OKI7.js +3 -0
- package/dist/bundle/chunks/{cli-H4LJNE2V.js → cli-6DJO467D.js} +2 -2
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T5R2RVFQ.js → cloudflare-workers-ai-system-one-JEZVYITT.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +68 -68
- package/dist/bundle/chunks/compat-SRCNS6OQ.js +15 -0
- package/dist/bundle/chunks/curator-server-QB4GITGS.js +3600 -0
- package/dist/bundle/chunks/dist-35STTNYA.js +37 -0
- package/dist/bundle/chunks/{dist-FMWWM4H7.js → dist-4OMLHRJE.js} +2 -2
- package/dist/bundle/chunks/dist-CBODG4CA.js +11 -0
- package/dist/bundle/chunks/{dist-NHQTBDHT.js → dist-TRAK7EXI.js} +91 -257
- package/dist/bundle/chunks/dist-cjs-EROMDUKS.js +193 -0
- package/dist/bundle/chunks/{easter-egg-3d-BUEOC3NO.js → easter-egg-3d-VVUF3C3X.js} +1 -1
- package/dist/bundle/chunks/entry-2GZ3PTWQ.js +2 -0
- package/dist/bundle/chunks/{entry-A2CSLKHC.js → entry-SRYLSS5P.js} +3 -3
- package/dist/bundle/chunks/{event-streams-7YGFEPBZ.js → event-streams-F67JLS6B.js} +1 -1
- package/dist/bundle/chunks/{execute-MY5JSEPV.js → execute-I3WGGPWL.js} +2 -2
- package/dist/bundle/chunks/{extract-PTGACPGP.js → extract-L373D6O7.js} +68 -65
- package/dist/bundle/chunks/{flow-implementer-APJFY4YI.js → flow-implementer-4KO3Q4B5.js} +8 -9
- package/dist/bundle/chunks/github-copilot.js +53 -46
- package/dist/bundle/chunks/google-generative-ai-WIASMWS3.js +22 -0
- package/dist/bundle/chunks/google-vertex-WSPHRZIZ.js +25 -0
- package/dist/bundle/chunks/host-WOLZCWQQ.js +3 -0
- package/dist/bundle/chunks/image-resize-worker.js +3 -3
- package/dist/bundle/chunks/{index.bundle-THL4EUSU.js → index.bundle-HONF3PUD.js} +177 -176
- package/dist/bundle/chunks/{inprocess-5NP5VJHZ.js → inprocess-TOBRVK4C.js} +6 -6
- package/dist/bundle/chunks/interactive-mode-BJJKPBXD.js +5 -0
- package/dist/bundle/chunks/{llama-cpp-classify-GJAXULWL.js → llama-cpp-classify-KYZT532X.js} +1 -1
- package/dist/bundle/chunks/mistral-conversations-7JYDDRUT.js +43 -0
- package/dist/bundle/chunks/{node-UNHECG4X.js → node-MHHE76P4.js} +475 -440
- package/dist/bundle/chunks/{node-ZFIIS5IM.js → node-N7TPBUJB.js} +53 -30
- package/dist/bundle/chunks/{openai-codex-responses-S7CMCAOY.js → openai-codex-responses-7PAML4NF.js} +30 -29
- package/dist/bundle/chunks/openai-codex.js +9 -8
- package/dist/bundle/chunks/{openai-completions-2Z57N7PC.js → openai-completions-UJDAIGTK.js} +22 -22
- package/dist/bundle/chunks/{openai-decisions-JIOJDB4C.js → openai-decisions-JMSDGR7K.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-5VBZSTHL.js → openai-responses-2WNCE6AY.js} +4 -5
- package/dist/bundle/chunks/{openrouter-images-S6O7DBEJ.js → openrouter-images-V3UCCO6X.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +9 -8
- package/dist/bundle/chunks/pdfjs-FE3L72A6.js +3662 -0
- package/dist/bundle/chunks/{pdfjs-decoders-OFXX4HDZ.js → pdfjs-decoders-VCMCTQJ2.js} +1 -1
- package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-I4K6AIV4.js +295 -0
- package/dist/bundle/chunks/pdfjs-openjpeg-PYQCV6CM.js +590 -0
- package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-G363SGDI.js +775 -0
- package/dist/bundle/chunks/{pi-messages-SMLN5J2W.js → pi-messages-TQ7LJUNQ.js} +11 -11
- package/dist/bundle/chunks/radius.js +8 -7
- package/dist/bundle/chunks/{runtime-OYTWXIUM.js → runtime-H7LYNKCZ.js} +1 -1
- package/dist/bundle/chunks/session-picker-4JQEGLDD.js +4 -0
- package/dist/bundle/chunks/startup-ui-AKTA4NDP.js +3 -0
- package/dist/bundle/chunks/{trace-command-YLDYCL55.js → trace-command-7ORDQ3JS.js} +4 -4
- package/dist/bundle/chunks/{typesafe-system-one-7BEL3H5N.js → typesafe-system-one-YP7GGN4C.js} +1 -1
- package/dist/bundle/chunks/{undici-C6S56CGI.js → undici-WVNE45GY.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-3CT5BMBA.js +28 -0
- package/dist/bundle/cli-runtime.js +5 -5
- package/dist/bundle/flow/package.json +5 -5
- package/dist/bundle/index.js +13 -13
- package/dist/bundle/orchestrate/package.json +22 -6
- package/dist/bundle/rpc-entry.js +4 -5
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +9 -6
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +16 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +9 -6
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +3 -2
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +8 -4
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +14 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +30 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +0 -2
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +0 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +31 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +231 -535
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts +4 -2
- package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
- package/dist/core/anthropic-subscription-usage.js +32 -16
- package/dist/core/anthropic-subscription-usage.js.map +1 -1
- package/dist/core/auto-session-namer.js +1 -1
- package/dist/core/auto-session-namer.js.map +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +2 -0
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/exec.d.ts +1 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +4 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts +6 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +57 -20
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/template.js +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +18 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/flow-implementer.d.ts.map +1 -1
- package/dist/core/flow-implementer.js +3 -9
- package/dist/core/flow-implementer.js.map +1 -1
- package/dist/core/keybindings.d.ts +64 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +8 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +13 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-registry.d.ts +3 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +44 -9
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +0 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +28 -8
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +64 -14
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +9 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +138 -23
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/package-manager.d.ts +16 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +46 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +1 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +7 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +5 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-outcome.d.ts +6 -3
- package/dist/core/run-outcome.d.ts.map +1 -1
- package/dist/core/run-outcome.js +36 -9
- package/dist/core/run-outcome.js.map +1 -1
- package/dist/core/run-preflight.d.ts +1 -1
- package/dist/core/run-preflight.d.ts.map +1 -1
- package/dist/core/run-preflight.js +19 -11
- package/dist/core/run-preflight.js.map +1 -1
- package/dist/core/sdk.d.ts +0 -6
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +9 -18
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +0 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +0 -9
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +0 -4
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +0 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash-jobs.d.ts.map +1 -1
- package/dist/core/tools/bash-jobs.js +2 -9
- package/dist/core/tools/bash-jobs.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +28 -16
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts +8 -4
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +10 -15
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +6 -2
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/core/tools/subagent-worktree.d.ts.map +1 -1
- package/dist/core/tools/subagent-worktree.js +2 -10
- package/dist/core/tools/subagent-worktree.js.map +1 -1
- package/dist/core/trace-client/credential-store.d.ts.map +1 -1
- package/dist/core/trace-client/credential-store.js +9 -5
- package/dist/core/trace-client/credential-store.js.map +1 -1
- package/dist/extensions/codemode/execute.js +2 -2
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -4
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/usage/account-reconnect.d.ts +5 -0
- package/dist/extensions/usage/account-reconnect.d.ts.map +1 -0
- package/dist/extensions/usage/account-reconnect.js +12 -0
- package/dist/extensions/usage/account-reconnect.js.map +1 -0
- package/dist/extensions/usage/confirmation.d.ts.map +1 -1
- package/dist/extensions/usage/confirmation.js +1 -1
- package/dist/extensions/usage/confirmation.js.map +1 -1
- package/dist/extensions/usage/hcode-overview.d.ts +6 -19
- package/dist/extensions/usage/hcode-overview.d.ts.map +1 -1
- package/dist/extensions/usage/hcode-overview.js +86 -100
- package/dist/extensions/usage/hcode-overview.js.map +1 -1
- package/dist/extensions/usage/index.d.ts.map +1 -1
- package/dist/extensions/usage/index.js +75 -99
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/extensions/usage/overview.d.ts +22 -17
- package/dist/extensions/usage/overview.d.ts.map +1 -1
- package/dist/extensions/usage/overview.js +98 -13
- package/dist/extensions/usage/overview.js.map +1 -1
- package/dist/extensions/usage/panes.d.ts +5 -0
- package/dist/extensions/usage/panes.d.ts.map +1 -0
- package/dist/extensions/usage/panes.js +10 -0
- package/dist/extensions/usage/panes.js.map +1 -0
- package/dist/extensions/usage/popup.d.ts +9 -14
- package/dist/extensions/usage/popup.d.ts.map +1 -1
- package/dist/extensions/usage/popup.js +87 -183
- package/dist/extensions/usage/popup.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +4 -1
- package/dist/humain/flow-command.js +1 -1
- package/dist/humain/flow-command.js.map +1 -1
- package/dist/humain/flow-loader.d.ts +9 -4
- package/dist/humain/flow-loader.d.ts.map +1 -1
- package/dist/humain/flow-loader.js +30 -21
- package/dist/humain/flow-loader.js.map +1 -1
- package/dist/humain/gateway/client.d.ts +3 -1
- package/dist/humain/gateway/client.d.ts.map +1 -1
- package/dist/humain/gateway/client.js +10 -5
- package/dist/humain/gateway/client.js.map +1 -1
- package/dist/humain/gateway/login.d.ts.map +1 -1
- package/dist/humain/gateway/login.js +160 -53
- package/dist/humain/gateway/login.js.map +1 -1
- package/dist/humain/hcode/account-store.d.ts +29 -5
- package/dist/humain/hcode/account-store.d.ts.map +1 -1
- package/dist/humain/hcode/account-store.js +224 -124
- package/dist/humain/hcode/account-store.js.map +1 -1
- package/dist/humain/hcode/account.d.ts +6 -0
- package/dist/humain/hcode/account.d.ts.map +1 -1
- package/dist/humain/hcode/account.js +348 -129
- package/dist/humain/hcode/account.js.map +1 -1
- package/dist/humain/hcode/catalog-watch.d.ts +21 -0
- package/dist/humain/hcode/catalog-watch.d.ts.map +1 -0
- package/dist/humain/hcode/catalog-watch.js +46 -0
- package/dist/humain/hcode/catalog-watch.js.map +1 -0
- package/dist/humain/hcode/contracts.d.ts +31 -1
- package/dist/humain/hcode/contracts.d.ts.map +1 -1
- package/dist/humain/hcode/contracts.js +205 -136
- package/dist/humain/hcode/contracts.js.map +1 -1
- package/dist/humain/hcode/environment.d.ts +3 -1
- package/dist/humain/hcode/environment.d.ts.map +1 -1
- package/dist/humain/hcode/environment.js +14 -2
- package/dist/humain/hcode/environment.js.map +1 -1
- package/dist/humain/hcode/facade.d.ts +26 -6
- package/dist/humain/hcode/facade.d.ts.map +1 -1
- package/dist/humain/hcode/facade.js +148 -38
- package/dist/humain/hcode/facade.js.map +1 -1
- package/dist/humain/hcode/http.d.ts +3 -1
- package/dist/humain/hcode/http.d.ts.map +1 -1
- package/dist/humain/hcode/http.js +44 -23
- package/dist/humain/hcode/http.js.map +1 -1
- package/dist/humain/hcode/images.d.ts +67 -0
- package/dist/humain/hcode/images.d.ts.map +1 -0
- package/dist/humain/hcode/images.js +465 -0
- package/dist/humain/hcode/images.js.map +1 -0
- package/dist/humain/hcode/login-copy.d.ts +28 -0
- package/dist/humain/hcode/login-copy.d.ts.map +1 -0
- package/dist/humain/hcode/login-copy.js +74 -0
- package/dist/humain/hcode/login-copy.js.map +1 -0
- package/dist/humain/hcode/login-failure.d.ts +26 -0
- package/dist/humain/hcode/login-failure.d.ts.map +1 -0
- package/dist/humain/hcode/login-failure.js +50 -0
- package/dist/humain/hcode/login-failure.js.map +1 -0
- package/dist/humain/hcode/notices.d.ts +45 -1
- package/dist/humain/hcode/notices.d.ts.map +1 -1
- package/dist/humain/hcode/notices.js +124 -7
- package/dist/humain/hcode/notices.js.map +1 -1
- package/dist/humain/hcode/provider.d.ts +9 -3
- package/dist/humain/hcode/provider.d.ts.map +1 -1
- package/dist/humain/hcode/provider.js +204 -20
- package/dist/humain/hcode/provider.js.map +1 -1
- package/dist/humain/hcode/run-credential.d.ts +21 -0
- package/dist/humain/hcode/run-credential.d.ts.map +1 -0
- package/dist/humain/hcode/run-credential.js +140 -0
- package/dist/humain/hcode/run-credential.js.map +1 -0
- package/dist/humain/hcode/sandbox.d.ts +6 -0
- package/dist/humain/hcode/sandbox.d.ts.map +1 -0
- package/dist/humain/hcode/sandbox.js +139 -0
- package/dist/humain/hcode/sandbox.js.map +1 -0
- package/dist/humain/hcode/selection.d.ts +9 -2
- package/dist/humain/hcode/selection.d.ts.map +1 -1
- package/dist/humain/hcode/selection.js +37 -6
- package/dist/humain/hcode/selection.js.map +1 -1
- package/dist/humain/hcode/transport.d.ts +14 -10
- package/dist/humain/hcode/transport.d.ts.map +1 -1
- package/dist/humain/hcode/transport.js +119 -149
- package/dist/humain/hcode/transport.js.map +1 -1
- package/dist/humain/hcode/wire.d.ts +3 -0
- package/dist/humain/hcode/wire.d.ts.map +1 -1
- package/dist/humain/hcode/wire.js +11 -0
- package/dist/humain/hcode/wire.js.map +1 -1
- package/dist/humain/metadata/contracts.d.ts +1 -0
- package/dist/humain/metadata/contracts.d.ts.map +1 -1
- package/dist/humain/metadata/contracts.js +2 -1
- package/dist/humain/metadata/contracts.js.map +1 -1
- package/dist/humain/remote/broker.d.ts +84 -0
- package/dist/humain/remote/broker.d.ts.map +1 -0
- package/dist/humain/remote/broker.js +427 -0
- package/dist/humain/remote/broker.js.map +1 -0
- package/dist/humain/remote/deny-store.d.ts +12 -0
- package/dist/humain/remote/deny-store.d.ts.map +1 -0
- package/dist/humain/remote/deny-store.js +164 -0
- package/dist/humain/remote/deny-store.js.map +1 -0
- package/dist/humain/remote/enablement.d.ts +5 -0
- package/dist/humain/remote/enablement.d.ts.map +1 -0
- package/dist/humain/remote/enablement.js +8 -0
- package/dist/humain/remote/enablement.js.map +1 -0
- package/dist/humain/remote/environment.d.ts +11 -0
- package/dist/humain/remote/environment.d.ts.map +1 -0
- package/dist/humain/remote/environment.js +19 -0
- package/dist/humain/remote/environment.js.map +1 -0
- package/dist/humain/remote/host-watch.d.ts +21 -0
- package/dist/humain/remote/host-watch.d.ts.map +1 -0
- package/dist/humain/remote/host-watch.js +186 -0
- package/dist/humain/remote/host-watch.js.map +1 -0
- package/dist/humain/remote/ipc-posix.d.ts +5 -0
- package/dist/humain/remote/ipc-posix.d.ts.map +1 -0
- package/dist/humain/remote/ipc-posix.js +29 -0
- package/dist/humain/remote/ipc-posix.js.map +1 -0
- package/dist/humain/remote/ipc-windows.d.ts +3 -0
- package/dist/humain/remote/ipc-windows.d.ts.map +1 -0
- package/dist/humain/remote/ipc-windows.js +5 -0
- package/dist/humain/remote/ipc-windows.js.map +1 -0
- package/dist/humain/remote/ipc.d.ts +10 -0
- package/dist/humain/remote/ipc.d.ts.map +1 -0
- package/dist/humain/remote/ipc.js +19 -0
- package/dist/humain/remote/ipc.js.map +1 -0
- package/dist/humain/remote/protocol.d.ts +43 -0
- package/dist/humain/remote/protocol.d.ts.map +1 -0
- package/dist/humain/remote/protocol.js +76 -0
- package/dist/humain/remote/protocol.js.map +1 -0
- package/dist/humain/remote/relay-socket.d.ts +30 -0
- package/dist/humain/remote/relay-socket.d.ts.map +1 -0
- package/dist/humain/remote/relay-socket.js +137 -0
- package/dist/humain/remote/relay-socket.js.map +1 -0
- package/dist/humain/remote/secure-channel.d.ts +10 -0
- package/dist/humain/remote/secure-channel.d.ts.map +1 -0
- package/dist/humain/remote/secure-channel.js +5 -0
- package/dist/humain/remote/secure-channel.js.map +1 -0
- package/dist/humain/remote/terminal.d.ts +48 -0
- package/dist/humain/remote/terminal.d.ts.map +1 -0
- package/dist/humain/remote/terminal.js +119 -0
- package/dist/humain/remote/terminal.js.map +1 -0
- package/dist/humain/remote/tickets.d.ts +35 -0
- package/dist/humain/remote/tickets.d.ts.map +1 -0
- package/dist/humain/remote/tickets.js +132 -0
- package/dist/humain/remote/tickets.js.map +1 -0
- package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/anysearch.js +7 -3
- package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
- package/dist/humain/web-access/vendor/autom.d.ts +4 -0
- package/dist/humain/web-access/vendor/autom.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/autom.js +191 -0
- package/dist/humain/web-access/vendor/autom.js.map +1 -0
- package/dist/humain/web-access/vendor/cloro.d.ts +4 -0
- package/dist/humain/web-access/vendor/cloro.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/cloro.js +236 -0
- package/dist/humain/web-access/vendor/cloro.js.map +1 -0
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +7 -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 +6 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts +8 -0
- package/dist/humain/web-access/vendor/domain-filter-normalization.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/domain-filter-normalization.js +37 -0
- package/dist/humain/web-access/vendor/domain-filter-normalization.js.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +28 -8
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +135 -34
- package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo.d.ts +1 -1
- package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/duckduckgo.js +10 -3
- package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +61 -5
- package/dist/humain/web-access/vendor/extract.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 +35 -5
- 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 +8 -1
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts +5 -0
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +12 -2
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/specstream.d.ts +6 -0
- package/dist/humain/web-access/vendor/specstream.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/specstream.js +253 -0
- package/dist/humain/web-access/vendor/specstream.js.map +1 -0
- package/dist/humain/web-access/vendor/tool-activation.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/tool-activation.js +21 -5
- package/dist/humain/web-access/vendor/tool-activation.js.map +1 -1
- package/dist/humain/web-access/vendor/upgrade-notice.d.ts +1 -1
- package/dist/humain/web-access/vendor/upgrade-notice.js +1 -1
- package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +1 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +3 -0
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/video-extract.js +2 -2
- package/dist/humain/web-access/vendor/video-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts +13 -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 +16 -5
- package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
- package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +109 -29
- package/dist/main.js.map +1 -1
- package/dist/modes/diagnostics-stderr.d.ts +4 -0
- package/dist/modes/diagnostics-stderr.d.ts.map +1 -0
- package/dist/modes/diagnostics-stderr.js +11 -0
- package/dist/modes/diagnostics-stderr.js.map +1 -0
- package/dist/modes/interactive/components/account-picker.d.ts +31 -0
- package/dist/modes/interactive/components/account-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/account-picker.js +150 -0
- package/dist/modes/interactive/components/account-picker.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +5 -2
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +14 -5
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +6 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +10 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -23
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +5 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +17 -6
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.js +2 -1
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +13 -6
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +8 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +41 -9
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +5 -1
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +0 -17
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -78
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/themed-text.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +5 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +3 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +14 -5
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +2 -2
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +35 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +821 -250
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +4 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.js +40 -1
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
- package/dist/modes/interactive/oauth-account-format.d.ts +15 -2
- package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
- package/dist/modes/interactive/oauth-account-format.js +39 -21
- package/dist/modes/interactive/oauth-account-format.js.map +1 -1
- package/dist/modes/interactive/session-share.js +2 -0
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +30 -32
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +26 -39
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +1 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +14 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +9 -0
- package/dist/utils/abort.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +3 -2
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/flush-stdout.d.ts +8 -0
- package/dist/utils/flush-stdout.d.ts.map +1 -0
- package/dist/utils/flush-stdout.js +23 -0
- package/dist/utils/flush-stdout.js.map +1 -0
- package/dist/utils/image-process.d.ts +2 -0
- package/dist/utils/image-process.d.ts.map +1 -1
- package/dist/utils/image-process.js +3 -3
- package/dist/utils/image-process.js.map +1 -1
- package/dist/utils/image-resize-core.js +2 -2
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +19 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/cli.md +1 -1
- package/docs/development.md +0 -13
- package/docs/extensions.md +6 -4
- package/docs/flow.md +4 -62
- package/docs/forge-run-bootstrap.md +46 -0
- package/docs/humain-code-forge-architecture.md +1 -47
- package/docs/humain-code-forge-flow-walkthrough.md +1 -1
- package/docs/humain-code.md +2 -2
- package/docs/index.md +2 -1
- package/docs/keybindings.md +12 -0
- package/docs/llama-cpp.md +5 -5
- package/docs/models-configuration.md +4 -2
- package/docs/nvidia-rtx-llama-cpp.md +5 -5
- package/docs/providers.md +14 -9
- package/docs/quickstart.md +16 -2
- package/docs/rpc-commands.md +1 -1
- package/docs/run-preflight.md +1 -1
- package/docs/slash-commands.md +5 -3
- package/docs/tui.md +2 -0
- package/examples/README.md +0 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/gondolin/index.ts +4 -7
- package/examples/tsconfig.json +96 -76
- package/npm-shrinkwrap.json +285 -764
- package/package.json +24 -37
- package/schemas/keybindings.schema.json +32 -0
- package/schemas/models.schema.json +5 -1
- package/schemas/settings.schema.json +0 -13
- package/src/humain/web-access/UPSTREAM.md +52 -1
- package/src/humain/web-access/upstream.json +5 -5
- package/src/humain/web-access/vendor/CHANGELOG.md +29 -0
- package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +0 -8
- package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +0 -162
- package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +0 -68
- package/dist/bundle/chunks/azure-openai-responses-JY7OSLH2.js +0 -15
- package/dist/bundle/chunks/chunk-5L4PBYC7.js +0 -11
- package/dist/bundle/chunks/chunk-6PNQYO6A.js +0 -10
- package/dist/bundle/chunks/chunk-CRN54O4D.js +0 -24
- package/dist/bundle/chunks/chunk-CTU2ECLD.js +0 -7
- package/dist/bundle/chunks/chunk-DBL35X7L.js +0 -3
- package/dist/bundle/chunks/chunk-GME4AWDG.js +0 -23
- package/dist/bundle/chunks/chunk-GTILMMUF.js +0 -12
- package/dist/bundle/chunks/chunk-J57HOSWD.js +0 -21
- package/dist/bundle/chunks/chunk-KQM7ZGL6.js +0 -11
- package/dist/bundle/chunks/chunk-MX4Q4W6H.js +0 -214
- package/dist/bundle/chunks/chunk-NXA6NEHE.js +0 -54
- package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -2
- package/dist/bundle/chunks/chunk-T5A6T24H.js +0 -93
- package/dist/bundle/chunks/chunk-WCFHG6NO.js +0 -16
- package/dist/bundle/chunks/chunk-ZJUU6WOV.js +0 -2052
- package/dist/bundle/chunks/compat-ZK2DIW3P.js +0 -15
- package/dist/bundle/chunks/dist-EY7YKQHB.js +0 -11
- package/dist/bundle/chunks/dist-J5IUPLMH.js +0 -37
- package/dist/bundle/chunks/dist-cjs-2SKN226B.js +0 -184
- package/dist/bundle/chunks/entry-AL54ZGYO.js +0 -2
- package/dist/bundle/chunks/es5-GYTRHFKS.js +0 -77
- package/dist/bundle/chunks/google-generative-ai-UL7YEQ6J.js +0 -21
- package/dist/bundle/chunks/google-vertex-OTMSPUYH.js +0 -26
- package/dist/bundle/chunks/host-75YAHLDR.js +0 -3
- package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +0 -5
- package/dist/bundle/chunks/mistral-conversations-E72Y6OC3.js +0 -43
- package/dist/bundle/chunks/pdfjs-AKD6EBKN.js +0 -3614
- package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +0 -326
- package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +0 -671
- package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +0 -974
- package/dist/bundle/chunks/session-picker-DM6S37IF.js +0 -4
- package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +0 -3
- package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +0 -28
- package/dist/core/internal-process.d.ts +0 -23
- package/dist/core/internal-process.d.ts.map +0 -1
- package/dist/core/internal-process.js +0 -88
- package/dist/core/internal-process.js.map +0 -1
- package/dist/humain/adaptive-execution.d.ts +0 -51
- package/dist/humain/adaptive-execution.d.ts.map +0 -1
- package/dist/humain/adaptive-execution.js +0 -100
- package/dist/humain/adaptive-execution.js.map +0 -1
- package/dist/humain/adaptive-peer-process.d.ts +0 -44
- package/dist/humain/adaptive-peer-process.d.ts.map +0 -1
- package/dist/humain/adaptive-peer-process.js +0 -159
- package/dist/humain/adaptive-peer-process.js.map +0 -1
- package/dist/humain/adaptive-peer-worker.d.ts +0 -3
- package/dist/humain/adaptive-peer-worker.d.ts.map +0 -1
- package/dist/humain/adaptive-peer-worker.js +0 -122
- package/dist/humain/adaptive-peer-worker.js.map +0 -1
- package/dist/humain/adaptive-runtime-types.d.ts +0 -621
- package/dist/humain/adaptive-runtime-types.d.ts.map +0 -1
- package/dist/humain/adaptive-runtime-types.js +0 -3
- package/dist/humain/adaptive-runtime-types.js.map +0 -1
- package/dist/humain/adaptive-session-host.d.ts +0 -113
- package/dist/humain/adaptive-session-host.d.ts.map +0 -1
- package/dist/humain/adaptive-session-host.js +0 -1838
- package/dist/humain/adaptive-session-host.js.map +0 -1
- package/dist/utils/deprecation.d.ts +0 -4
- package/dist/utils/deprecation.d.ts.map +0 -1
- package/dist/utils/deprecation.js +0 -13
- package/dist/utils/deprecation.js.map +0 -1
- package/examples/plugins/pi-example-plugin/README.md +0 -38
- package/examples/plugins/pi-example-plugin/package.json +0 -10
- package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
- package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
- package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
|
@@ -14,18 +14,16 @@
|
|
|
14
14
|
* Modes use this class and add their own I/O layer on top.
|
|
15
15
|
*/
|
|
16
16
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
|
-
import {
|
|
17
|
+
import { randomUUID } from "node:crypto";
|
|
18
18
|
import { readFileSync } from "node:fs";
|
|
19
19
|
import { basename, dirname } from "node:path";
|
|
20
20
|
import { runToolCall, } from "@earendil-works/pi-agent-core";
|
|
21
|
-
import { contentText, getAssistantRetryDelayMs, getCurrentSystemMessage, getCurrentSystemPrompt, getCurrentTools,
|
|
21
|
+
import { contentText, getAssistantRetryDelayMs, getCurrentSystemMessage, getCurrentSystemPrompt, getCurrentTools, retryDelayMs, } from "@earendil-works/pi-ai";
|
|
22
22
|
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRecoverableLength, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@earendil-works/pi-ai/compat";
|
|
23
|
-
import { adaptiveEvidenceLines, adaptiveStatusText, presentAdaptiveChecklist, selectExecutionEngine, } from "../humain/adaptive-execution.js";
|
|
24
23
|
import { HUMAIN_OBSERVER_EXTENSION_PATHS } from "../humain/bundled-extension-names.js";
|
|
25
|
-
import { loadAdaptiveExecutionHost } from "../humain/flow-loader.js";
|
|
26
24
|
import { HCODE_PROVIDER } from "../humain/hcode/http.js";
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
25
|
+
import { fitHcodeImages, hcodeActivePrompts, hcodeImageMessage, hcodeImageOmissionNotice, observeHcodeImageOmissions, validateHcodeImages, } from "../humain/hcode/images.js";
|
|
26
|
+
import { assertHcodeSelection, captureHcodeSelection, HCODE_SELECTION_CHANGED_MESSAGE, HCODE_UNSUPPORTED_THINKING_MESSAGE, } from "../humain/hcode/selection.js";
|
|
29
27
|
import { getNodeAccountFailure, } from "../humain/node-account-failure.js";
|
|
30
28
|
import { formatNodeSwitchNotice, isNodeFallbackTarget, NODE_FALLBACK_NONE_MESSAGE, nodeFailureExhaustedUntil, } from "../humain/node-account-fallback.js";
|
|
31
29
|
import { HUMAIN_NODE_BASE_URL_ENV, HUMAIN_NODE_PROVIDER } from "../humain/node-provider.js";
|
|
@@ -65,7 +63,7 @@ import { BUILTIN_PATH_PREFIX, createSyntheticSourceInfo, isSyntheticPath } from
|
|
|
65
63
|
import { buildSystemPrompt, buildSystemPromptSections, diffSystemPromptSections, normalizeBuildSystemPromptOptions, } from "./system-prompt.js";
|
|
66
64
|
import { createLocalBashOperations, getBashToolOwner } from "./tools/bash.js";
|
|
67
65
|
import { BashJobManager } from "./tools/bash-jobs.js";
|
|
68
|
-
import { createAllToolDefinitions
|
|
66
|
+
import { createAllToolDefinitions } from "./tools/index.js";
|
|
69
67
|
import { createToolDefinitionFromAgentTool } from "./tools/tool-definition-wrapper.js";
|
|
70
68
|
import { UsageLedger } from "./usage-ledger.js";
|
|
71
69
|
import { addUsageToTotals, combineUsage, createUsageTotals, getSessionUsage } from "./usage-totals.js";
|
|
@@ -193,6 +191,11 @@ export class AgentSession {
|
|
|
193
191
|
_scopedModels;
|
|
194
192
|
_preparedImageRoute;
|
|
195
193
|
_queuedUserInputs = new WeakSet();
|
|
194
|
+
_freshImageInputs = new WeakSet();
|
|
195
|
+
_pendingImageEntries = new Set();
|
|
196
|
+
_rejectedImageEntries = new Set();
|
|
197
|
+
_activeImageEntries = [];
|
|
198
|
+
_managedImageRequest;
|
|
196
199
|
_disposed = false;
|
|
197
200
|
_modelSelectionRevision = 0;
|
|
198
201
|
_autoEffortInteractive = false;
|
|
@@ -269,7 +272,7 @@ export class AgentSession {
|
|
|
269
272
|
_contextEstimate;
|
|
270
273
|
// Bash execution state
|
|
271
274
|
_bashAbortControllers = new Set();
|
|
272
|
-
_bashJobs = new BashJobManager(
|
|
275
|
+
_bashJobs = new BashJobManager();
|
|
273
276
|
// Retain replaced/reloaded owners too: removing a declaration does not stop its effects.
|
|
274
277
|
_bashJobOwners = new Set([this._bashJobs]);
|
|
275
278
|
_pendingBashMessages = [];
|
|
@@ -297,9 +300,11 @@ export class AgentSession {
|
|
|
297
300
|
/**
|
|
298
301
|
* Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
|
|
299
302
|
* servers that are still connecting. They are activated when they are registered, and dropped when
|
|
300
|
-
* `setActiveToolsByName()` deactivates a tool or the next agent run starts.
|
|
303
|
+
* `setActiveToolsByName()` deactivates a tool of that loadout or the next agent run starts.
|
|
301
304
|
*/
|
|
302
305
|
_pendingToolNames = new Set();
|
|
306
|
+
/** The restored or reloaded loadout that `_pendingToolNames` belongs to. */
|
|
307
|
+
_restoredToolNames = new Set();
|
|
303
308
|
_usesDefaultTools;
|
|
304
309
|
_defaultToolModifiers;
|
|
305
310
|
/** Matches the `--tools` entries: tool names or patterns. */
|
|
@@ -319,6 +324,8 @@ export class AgentSession {
|
|
|
319
324
|
_extensionShutdownHandler;
|
|
320
325
|
_extensionErrorListener;
|
|
321
326
|
_extensionErrorUnsubscriber;
|
|
327
|
+
// Set by bindExtensions(): reload() restarts extensions only if the host started them.
|
|
328
|
+
_extensionsBound = false;
|
|
322
329
|
_modelRuntime;
|
|
323
330
|
_runPreflight;
|
|
324
331
|
_usageLedger = UsageLedger.fromEnvironment();
|
|
@@ -341,64 +348,12 @@ export class AgentSession {
|
|
|
341
348
|
_toolDefinitions = new Map();
|
|
342
349
|
_toolPromptSnippets = new Map();
|
|
343
350
|
_toolPromptGuidelines = new Map();
|
|
344
|
-
_executionEngineOption;
|
|
345
|
-
_adaptiveOptions;
|
|
346
|
-
_restoredExecutionEngine;
|
|
347
|
-
_adaptiveRecoveryRead = false;
|
|
348
|
-
_runExecutionEngine;
|
|
349
|
-
_adaptiveHost;
|
|
350
|
-
_adaptivePeerTransformContext;
|
|
351
|
-
_adaptivePeerPrepareRequest;
|
|
352
|
-
_adaptiveCompletion;
|
|
353
|
-
_adaptiveSeal;
|
|
354
|
-
_adaptiveLegacyJobs;
|
|
355
|
-
_adaptiveAdmissionScope = new AsyncLocalStorage();
|
|
356
|
-
/** Selection is immutable while a run is owned; saved legacy context is never promoted. */
|
|
357
|
-
get executionEngine() {
|
|
358
|
-
return (this._runExecutionEngine ??
|
|
359
|
-
(this._restoredExecutionEngine === "adaptive-v2" && this._adaptiveRecoveryRead
|
|
360
|
-
? undefined
|
|
361
|
-
: this._restoredExecutionEngine) ??
|
|
362
|
-
this._executionEngineOption ??
|
|
363
|
-
this.settingsManager.getExecutionEngine());
|
|
364
|
-
}
|
|
365
|
-
/** Evidence-bound local result, shared unchanged by SDK, print, JSON and RPC. */
|
|
366
|
-
get adaptiveCompletion() {
|
|
367
|
-
return this._adaptiveCompletion;
|
|
368
|
-
}
|
|
369
351
|
_includeHarnessDocs;
|
|
370
352
|
_baseSystemPromptOptions;
|
|
371
353
|
/** Prompt options after before_agent_start mutations for the active run. */
|
|
372
354
|
_runSystemPromptOptions;
|
|
373
355
|
_timeLimit;
|
|
374
356
|
constructor(config) {
|
|
375
|
-
if (config.executionEngine !== undefined)
|
|
376
|
-
selectExecutionEngine(config.executionEngine);
|
|
377
|
-
else
|
|
378
|
-
config.settingsManager.getExecutionEngine();
|
|
379
|
-
if (config.adaptiveExecution !== undefined &&
|
|
380
|
-
(!config.adaptiveExecution ||
|
|
381
|
-
typeof config.adaptiveExecution !== "object" ||
|
|
382
|
-
Array.isArray(config.adaptiveExecution)))
|
|
383
|
-
throw new Error("Invalid adaptive execution options");
|
|
384
|
-
this._executionEngineOption = config.executionEngine;
|
|
385
|
-
this._adaptiveOptions =
|
|
386
|
-
config.adaptiveExecution === undefined ? undefined : structuredClone(config.adaptiveExecution);
|
|
387
|
-
const saved = config.sessionManager.getBranch();
|
|
388
|
-
const selection = saved.findLast((entry) => entry.type === "custom" && entry.customType === "execution-engine");
|
|
389
|
-
if (selection?.type === "custom") {
|
|
390
|
-
if (!selection.data ||
|
|
391
|
-
typeof selection.data !== "object" ||
|
|
392
|
-
!("version" in selection.data) ||
|
|
393
|
-
selection.data.version !== 1 ||
|
|
394
|
-
!("engine" in selection.data))
|
|
395
|
-
throw new Error("Invalid persisted execution engine selection");
|
|
396
|
-
this._restoredExecutionEngine = selectExecutionEngine(selection.data.engine);
|
|
397
|
-
}
|
|
398
|
-
else if (saved.some((entry) => entry.type === "custom" && entry.customType === "adaptive-engine-snapshot"))
|
|
399
|
-
this._restoredExecutionEngine = "adaptive-v2";
|
|
400
|
-
else if (saved.some((entry) => entry.type === "message"))
|
|
401
|
-
this._restoredExecutionEngine = "legacy";
|
|
402
357
|
validateTimeLimitSeconds(config.timeLimitSeconds);
|
|
403
358
|
if (config.timeLimitSeconds !== undefined) {
|
|
404
359
|
this._timeLimit = {
|
|
@@ -409,9 +364,6 @@ export class AgentSession {
|
|
|
409
364
|
};
|
|
410
365
|
}
|
|
411
366
|
this.agent = config.agent;
|
|
412
|
-
// Capture caller/SDK policy before primary-only projection, compaction and forced-prompt wrappers.
|
|
413
|
-
this._adaptivePeerTransformContext = config.agent.transformContext;
|
|
414
|
-
this._adaptivePeerPrepareRequest = config.agent.prepareRequest;
|
|
415
367
|
this.sessionManager = config.sessionManager;
|
|
416
368
|
this.settingsManager = config.settingsManager;
|
|
417
369
|
this._scopedModels = config.scopedModels ?? [];
|
|
@@ -493,6 +445,48 @@ export class AgentSession {
|
|
|
493
445
|
effective = effective.filter((message) => message.timestamp !== pending.timestamp);
|
|
494
446
|
}
|
|
495
447
|
}
|
|
448
|
+
const request = this._managedImageRequest;
|
|
449
|
+
this._managedImageRequest = undefined;
|
|
450
|
+
this._pendingImageEntries.clear();
|
|
451
|
+
if (request) {
|
|
452
|
+
const fresh = new Set();
|
|
453
|
+
const rejected = new Set();
|
|
454
|
+
this._activeImageEntries = [];
|
|
455
|
+
for (const input of request.inputs) {
|
|
456
|
+
let present = false;
|
|
457
|
+
for (const message of effective) {
|
|
458
|
+
if (!this._matchesImageInput(input.message, message))
|
|
459
|
+
continue;
|
|
460
|
+
(input.rejected ? rejected : fresh).add(message);
|
|
461
|
+
present = true;
|
|
462
|
+
}
|
|
463
|
+
if (present && !input.rejected)
|
|
464
|
+
this._activeImageEntries.push(input.id);
|
|
465
|
+
}
|
|
466
|
+
const reference = captureHcodeSelection(this._modelRuntime, request.model);
|
|
467
|
+
const fitted = await fitHcodeImages(request.model, effective, {
|
|
468
|
+
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
469
|
+
blockImages: this.settingsManager.getBlockImages(),
|
|
470
|
+
}, fresh, rejected);
|
|
471
|
+
assertHcodeSelection(this._modelRuntime, request.model, reference);
|
|
472
|
+
const refused = fitted.omitted.find(({ index }) => fresh.has(effective[index]));
|
|
473
|
+
if (refused) {
|
|
474
|
+
for (const id of this._activeImageEntries)
|
|
475
|
+
this._rejectedImageEntries.add(id);
|
|
476
|
+
throw new Error(hcodeImageMessage(refused.reason, request.model));
|
|
477
|
+
}
|
|
478
|
+
for (const [index, message] of fitted.messages.entries()) {
|
|
479
|
+
if (fresh.has(effective[index]) && "content" in message && Array.isArray(message.content))
|
|
480
|
+
hcodeActivePrompts.add(message.content);
|
|
481
|
+
}
|
|
482
|
+
const [first] = fitted.omitted;
|
|
483
|
+
if (first)
|
|
484
|
+
this._emit({
|
|
485
|
+
type: "request_images_omitted",
|
|
486
|
+
message: hcodeImageOmissionNotice(fitted.omitted.length, first.reason, request.model),
|
|
487
|
+
});
|
|
488
|
+
return fitted.messages;
|
|
489
|
+
}
|
|
496
490
|
return effective;
|
|
497
491
|
};
|
|
498
492
|
this._buildRuntime({
|
|
@@ -512,11 +506,6 @@ export class AgentSession {
|
|
|
512
506
|
_installOAuthRequestAttribution() {
|
|
513
507
|
const streamFunction = this.agent.streamFunction;
|
|
514
508
|
const attributedStream = (model, context, options) => {
|
|
515
|
-
if (this._adaptiveHost)
|
|
516
|
-
options = {
|
|
517
|
-
...options,
|
|
518
|
-
maxTokens: Math.min(options?.maxTokens ?? this._adaptiveHost.maxOutputTokens, this._adaptiveHost.maxOutputTokens),
|
|
519
|
-
};
|
|
520
509
|
// Auxiliary requests share this transport, but only the agent loop's request owns the
|
|
521
510
|
// assistant message_start event. A concurrent summary must not replace that identity.
|
|
522
511
|
if (this._auxiliaryRequest.getStore() || !options?.signal || options.signal !== this.agent.signal) {
|
|
@@ -762,12 +751,13 @@ export class AgentSession {
|
|
|
762
751
|
* binding follows async context, so concurrent sessions sharing one runtime never cross.
|
|
763
752
|
*/
|
|
764
753
|
_observeRequests(purpose, fn) {
|
|
765
|
-
return this.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
754
|
+
return observeHcodeImageOmissions((message) => this._emit({ type: "request_images_omitted", message }), () => this._modelRuntime.observeRequests(this._requestObserver, purpose, fn), {
|
|
755
|
+
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
756
|
+
onImageSizeRefusal: () => {
|
|
757
|
+
for (const id of this._activeImageEntries)
|
|
758
|
+
this._rejectedImageEntries.add(id);
|
|
759
|
+
},
|
|
760
|
+
});
|
|
771
761
|
}
|
|
772
762
|
_unregisterRequestOwner;
|
|
773
763
|
_requestObserver = {
|
|
@@ -808,23 +798,7 @@ export class AgentSession {
|
|
|
808
798
|
await runner.emitToolResultObserved({ ...observation, type: "tool_result_observed" });
|
|
809
799
|
}
|
|
810
800
|
/** `tool_call` handlers. `parentToolCallId` is set for calls another tool made. */
|
|
811
|
-
async _beforeToolCall(
|
|
812
|
-
const { toolCall, args } = context;
|
|
813
|
-
if (this._adaptiveHost)
|
|
814
|
-
await this._adaptiveHost.beforeTool(toolCall.name, args, !this._baseToolsOverride && this._toolDefinitions.get(toolCall.name)?.sourceInfo.source === "builtin"
|
|
815
|
-
? "native"
|
|
816
|
-
: "unqualified");
|
|
817
|
-
const result = await this._authorizeToolCall(context, parentToolCallId);
|
|
818
|
-
if (this._adaptiveHost) {
|
|
819
|
-
this._adaptiveHost.authorizeToolResult(result);
|
|
820
|
-
// Extensions may mutate event.input in place; only the final arguments can grant custody.
|
|
821
|
-
await this._adaptiveHost.beforeTool(toolCall.name, args, !this._baseToolsOverride && this._toolDefinitions.get(toolCall.name)?.sourceInfo.source === "builtin"
|
|
822
|
-
? "native"
|
|
823
|
-
: "unqualified");
|
|
824
|
-
}
|
|
825
|
-
return result;
|
|
826
|
-
}
|
|
827
|
-
async _authorizeToolCall({ toolCall, args }, parentToolCallId) {
|
|
801
|
+
async _beforeToolCall({ toolCall, args }, parentToolCallId) {
|
|
828
802
|
this._acceptanceLedger?.beginToolCall(toolCall.id, toolCall.name, args);
|
|
829
803
|
const runner = this._extensionRunner;
|
|
830
804
|
if (!runner.hasHandlers("tool_call")) {
|
|
@@ -865,8 +839,8 @@ export class AgentSession {
|
|
|
865
839
|
: undefined;
|
|
866
840
|
const content = hookResult?.content ?? result.content ?? [];
|
|
867
841
|
// Runs after the extension hook so images injected or replaced by extensions are normalized too.
|
|
868
|
-
const resizeOptions = this._limitsModel()?.inputLimits?.images?.resize;
|
|
869
842
|
const model = this._limitsModel();
|
|
843
|
+
const resizeOptions = model?.inputLimits?.images?.resize;
|
|
870
844
|
const normalizedContent = model?.provider === HCODE_PROVIDER || (this.model && isVirtualModel(this.model))
|
|
871
845
|
? content
|
|
872
846
|
: await normalizeToolResultImages(content, {
|
|
@@ -1107,13 +1081,9 @@ export class AgentSession {
|
|
|
1107
1081
|
this._captureForegroundTarget(effectiveModel);
|
|
1108
1082
|
await this._prepareAccountRequest(effectiveModel.provider, signal);
|
|
1109
1083
|
const effectiveThinking = revision === this._thinkingSelectionRevision ? thinkingLevel : this.agent.state.thinkingLevel;
|
|
1110
|
-
await this._validateManagedInput(effectiveModel, context.messages, effectiveThinking);
|
|
1111
|
-
context = await this._normalizeOrdinaryToolImages(context, effectiveModel);
|
|
1112
1084
|
return {
|
|
1113
1085
|
...previous,
|
|
1114
|
-
context,
|
|
1115
|
-
model: effectiveModel,
|
|
1116
|
-
thinkingLevel: effectiveThinking,
|
|
1086
|
+
...(await this._projectRequest(context, effectiveModel, effectiveThinking, projection)),
|
|
1117
1087
|
};
|
|
1118
1088
|
}
|
|
1119
1089
|
for (const entry of projection.entries)
|
|
@@ -1130,6 +1100,7 @@ export class AgentSession {
|
|
|
1130
1100
|
? prepared.route
|
|
1131
1101
|
: await this._modelRuntime.resolveModel(model, convertToLlm(context.messages), {
|
|
1132
1102
|
reason: failed ? "retry" : userTurn ? "user" : "continuation",
|
|
1103
|
+
deferThinkingClamp: true,
|
|
1133
1104
|
thinkingLevel,
|
|
1134
1105
|
signal,
|
|
1135
1106
|
failed,
|
|
@@ -1147,14 +1118,47 @@ export class AgentSession {
|
|
|
1147
1118
|
if (this._exceedsCompactionThreshold(route.model)) {
|
|
1148
1119
|
// Size the kept tail for the routed model too, not the model of the latest response.
|
|
1149
1120
|
await this._runAutoCompaction("threshold", false, undefined, route.model.contextWindow);
|
|
1150
|
-
({ previous, context } = await prepare());
|
|
1121
|
+
({ previous, context, projection } = await prepare());
|
|
1151
1122
|
}
|
|
1152
1123
|
await this._prepareAccountRequest(route.model.provider, signal);
|
|
1153
|
-
await this.
|
|
1154
|
-
context = await this._normalizeOrdinaryToolImages(context, route.model);
|
|
1155
|
-
return { ...previous, context, model: route.model, thinkingLevel: route.thinkingLevel };
|
|
1124
|
+
return { ...previous, ...(await this._projectRequest(context, route.model, route.thinkingLevel, projection)) };
|
|
1156
1125
|
};
|
|
1157
1126
|
}
|
|
1127
|
+
async _projectRequest(context, model, requestedLevel, projection) {
|
|
1128
|
+
if (model.provider === HCODE_PROVIDER) {
|
|
1129
|
+
this._managedImageRequest = {
|
|
1130
|
+
model,
|
|
1131
|
+
inputs: projection.entries.flatMap(({ sourceEntry: { id }, messages }) => {
|
|
1132
|
+
const rejected = this._rejectedImageEntries.has(id);
|
|
1133
|
+
return rejected || this._pendingImageEntries.has(id)
|
|
1134
|
+
? messages.map((message) => ({ id, message, rejected }))
|
|
1135
|
+
: [];
|
|
1136
|
+
}),
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
context = await this._normalizeOrdinaryToolImages(context, model);
|
|
1140
|
+
if (model.provider === HCODE_PROVIDER && !model.reasoning) {
|
|
1141
|
+
context = {
|
|
1142
|
+
...context,
|
|
1143
|
+
messages: context.messages.flatMap((message) => {
|
|
1144
|
+
if (message.role !== "assistant" ||
|
|
1145
|
+
message.provider === model.provider ||
|
|
1146
|
+
!message.content.some((block) => block.type === "thinking"))
|
|
1147
|
+
return [message];
|
|
1148
|
+
const content = message.content.filter((block) => block.type !== "thinking");
|
|
1149
|
+
return content.length ? [{ ...message, content }] : [];
|
|
1150
|
+
}),
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
const thinkingLevel = clampThinkingLevel(model, requestedLevel);
|
|
1154
|
+
if (thinkingLevel !== requestedLevel) {
|
|
1155
|
+
this._emit({
|
|
1156
|
+
type: "request_thinking_clamped",
|
|
1157
|
+
message: `Thinking level for this request adjusted from ${requestedLevel} to ${thinkingLevel} (${model.id}).`,
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
return { context, model, thinkingLevel };
|
|
1161
|
+
}
|
|
1158
1162
|
async _dispatchTurnEndBoundary(message, toolResults) {
|
|
1159
1163
|
this._lastActivityOutcome =
|
|
1160
1164
|
message.stopReason === "aborted" ? "aborted" : message.stopReason === "error" ? "error" : "completed";
|
|
@@ -1372,8 +1376,7 @@ export class AgentSession {
|
|
|
1372
1376
|
}
|
|
1373
1377
|
async _emitAgentSettled() {
|
|
1374
1378
|
this._withdrawControlContinuations();
|
|
1375
|
-
|
|
1376
|
-
this._cacheWarmer?.onAgentSettled();
|
|
1379
|
+
this._cacheWarmer?.onAgentSettled();
|
|
1377
1380
|
this._isAgentRunActive = false;
|
|
1378
1381
|
this._isEmittingAgentSettled = true;
|
|
1379
1382
|
try {
|
|
@@ -1427,9 +1430,10 @@ export class AgentSession {
|
|
|
1427
1430
|
}
|
|
1428
1431
|
// When a user message starts, check if it's from either queue and remove it BEFORE emitting
|
|
1429
1432
|
// This ensures the UI sees the updated queue state
|
|
1430
|
-
|
|
1431
|
-
|
|
1433
|
+
// A failed listener can restore the unstarted suffix, which must still pass validation on redelivery.
|
|
1434
|
+
if (event.type === "message_start")
|
|
1432
1435
|
this._queuedUserInputs.delete(event.message);
|
|
1436
|
+
if (event.type === "message_start" && event.message.role === "user") {
|
|
1433
1437
|
this._overflowRecoveryAttempts = 0;
|
|
1434
1438
|
const messageText = contentText(event.message.content, "");
|
|
1435
1439
|
if (this._acceptanceInitialUserPending)
|
|
@@ -1471,8 +1475,12 @@ export class AgentSession {
|
|
|
1471
1475
|
}
|
|
1472
1476
|
// A request identity is valid only until the next assistant message_start; drop any left by a request
|
|
1473
1477
|
// that never produced one.
|
|
1474
|
-
if (event.type === "agent_end")
|
|
1478
|
+
if (event.type === "agent_end") {
|
|
1475
1479
|
this._oauthRequestAccount = undefined;
|
|
1480
|
+
this._pendingImageEntries.clear();
|
|
1481
|
+
this._activeImageEntries = [];
|
|
1482
|
+
this._managedImageRequest = undefined;
|
|
1483
|
+
}
|
|
1476
1484
|
// Dequeue by the original text before resize hints change it; resume dispatch without dequeuing twice.
|
|
1477
1485
|
if (event.type === "message_start" &&
|
|
1478
1486
|
event.message.role === "user" &&
|
|
@@ -1527,6 +1535,8 @@ export class AgentSession {
|
|
|
1527
1535
|
}
|
|
1528
1536
|
if (entryId) {
|
|
1529
1537
|
this._entryIdsByMessage.set(event.message, entryId);
|
|
1538
|
+
if (this._freshImageInputs.delete(event.message))
|
|
1539
|
+
this._pendingImageEntries.add(entryId);
|
|
1530
1540
|
const input = this._autoEffortInputs.get(event.message);
|
|
1531
1541
|
if (input !== undefined) {
|
|
1532
1542
|
this._autoEffortPendingInputs.set(entryId, input);
|
|
@@ -1909,6 +1919,7 @@ export class AgentSession {
|
|
|
1909
1919
|
this._runPreflight = undefined;
|
|
1910
1920
|
this._autoEffortController?.abort();
|
|
1911
1921
|
this._autoEffortPendingInputs.clear();
|
|
1922
|
+
this._rejectedImageEntries.clear();
|
|
1912
1923
|
void closeSessionFlowControl(this);
|
|
1913
1924
|
this._withdrawControlContinuations();
|
|
1914
1925
|
this._agentRunAbortController?.abort();
|
|
@@ -2030,11 +2041,14 @@ export class AgentSession {
|
|
|
2030
2041
|
setActiveToolsByName(toolNames) {
|
|
2031
2042
|
const previous = this.getActiveToolNames();
|
|
2032
2043
|
this._setActiveTools(toolNames);
|
|
2033
|
-
// A loadout that deactivates a tool
|
|
2034
|
-
// One that only adds tools, like activating tool_search, keeps them
|
|
2044
|
+
// A loadout that deactivates a tool of the restored one replaces it, and its pending tools are
|
|
2045
|
+
// dropped. One that only adds tools, like activating tool_search, keeps them, and so does one
|
|
2046
|
+
// that only deactivates tools outside the restored loadout, such as an extension's own tool that
|
|
2047
|
+
// the restore or reload activated as newly registered.
|
|
2035
2048
|
const active = new Set(this.getActiveToolNames());
|
|
2036
|
-
if (previous.some((name) => !active.has(name)))
|
|
2049
|
+
if (previous.some((name) => !active.has(name) && this._restoredToolNames.has(name))) {
|
|
2037
2050
|
this._pendingToolNames.clear();
|
|
2051
|
+
}
|
|
2038
2052
|
}
|
|
2039
2053
|
_setActiveTools(toolNames) {
|
|
2040
2054
|
const tools = this._applyToolLoadout(toolNames);
|
|
@@ -2305,6 +2319,7 @@ export class AgentSession {
|
|
|
2305
2319
|
*/
|
|
2306
2320
|
_restoreToolsFromTranscript(modifiers = []) {
|
|
2307
2321
|
this._pendingToolNames.clear();
|
|
2322
|
+
this._restoredToolNames.clear();
|
|
2308
2323
|
// All system messages on the branch, including those before a compaction. Compaction snapshots
|
|
2309
2324
|
// are derived from these, so replaying them gives the current loadout.
|
|
2310
2325
|
const systemMessages = this.sessionManager
|
|
@@ -2325,6 +2340,7 @@ export class AgentSession {
|
|
|
2325
2340
|
// Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
|
|
2326
2341
|
// activated when they register. Excluded tools never register, so they are not kept pending.
|
|
2327
2342
|
this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
|
|
2343
|
+
this._restoredToolNames = new Set(applyToolModifiers(getCurrentTools(systemMessages).map((tool) => tool.name), modifiers));
|
|
2328
2344
|
// Ignores names that are not registered.
|
|
2329
2345
|
this._setActiveTools(names);
|
|
2330
2346
|
}
|
|
@@ -2335,32 +2351,10 @@ export class AgentSession {
|
|
|
2335
2351
|
* Start a run from a user or custom message. The session counts as busy from here on, so
|
|
2336
2352
|
* messages sent while before_agent_start handlers run are queued into this run instead of
|
|
2337
2353
|
* starting another, and an abort requested meanwhile aborts the run as soon as it exists.
|
|
2338
|
-
* @param trigger Omit only to reread a restored terminal result without admitting a task.
|
|
2339
2354
|
* @param onStarted Called once the run's messages are prepared, before the first request.
|
|
2340
2355
|
* @param autoEffortText Raw interactive input the automatic effort judge sees for a user trigger.
|
|
2341
2356
|
*/
|
|
2342
|
-
async _startRun(trigger, onStarted, autoEffortText,
|
|
2343
|
-
const recovering = this._restoredExecutionEngine === "adaptive-v2" && !this._adaptiveRecoveryRead;
|
|
2344
|
-
if (!trigger && !recovering)
|
|
2345
|
-
throw new Error("No restored adaptive terminal completion to read");
|
|
2346
|
-
const selectedEngine = recovering
|
|
2347
|
-
? "adaptive-v2"
|
|
2348
|
-
: trigger?.messageType === "custom"
|
|
2349
|
-
? "legacy"
|
|
2350
|
-
: this._restoredExecutionEngine === "legacy"
|
|
2351
|
-
? "legacy"
|
|
2352
|
-
: (this._executionEngineOption ?? this.settingsManager.getExecutionEngine());
|
|
2353
|
-
if (selectedEngine === "adaptive-v2" && this._extensionRunner.getFlagValues().get("flow-admission") !== undefined)
|
|
2354
|
-
throw new Error("Adaptive execution cannot reinterpret a frozen Flow admission; use its original legacy runtime.");
|
|
2355
|
-
const persistSelection = selectedEngine === "adaptive-v2" ||
|
|
2356
|
-
this._runExecutionEngine === "adaptive-v2" ||
|
|
2357
|
-
this._restoredExecutionEngine === "adaptive-v2";
|
|
2358
|
-
this._runExecutionEngine = selectExecutionEngine(selectedEngine);
|
|
2359
|
-
if (!recovering && persistSelection) {
|
|
2360
|
-
this.sessionManager.appendCustomEntry("execution-engine", { version: 1, engine: selectedEngine });
|
|
2361
|
-
this.sessionManager.flush();
|
|
2362
|
-
}
|
|
2363
|
-
this._adaptiveCompletion = undefined;
|
|
2357
|
+
async _startRun(trigger, onStarted, autoEffortText, fileTexts) {
|
|
2364
2358
|
const started = performance.now();
|
|
2365
2359
|
this._isAgentRunActive = true;
|
|
2366
2360
|
this._agentRunAbortRequested = false;
|
|
@@ -2372,276 +2366,13 @@ export class AgentSession {
|
|
|
2372
2366
|
this._oauthPoolWarmupFailed = false;
|
|
2373
2367
|
this._managedRunStopped = false;
|
|
2374
2368
|
this._foregroundTarget = undefined;
|
|
2375
|
-
let messages;
|
|
2376
2369
|
const runAbortController = new AbortController();
|
|
2377
|
-
let adaptiveSignal;
|
|
2378
|
-
let detachAdaptiveSignal;
|
|
2379
2370
|
this._agentRunAbortController = runAbortController;
|
|
2371
|
+
let messages;
|
|
2380
2372
|
try {
|
|
2381
|
-
|
|
2382
|
-
this._adaptiveCompletion = undefined;
|
|
2383
|
-
this._adaptiveSeal = undefined;
|
|
2384
|
-
const branch = this.sessionManager.getBranch();
|
|
2385
|
-
const selection = branch.findLastIndex((entry) => entry.type === "custom" && entry.customType === "execution-engine");
|
|
2386
|
-
// Selection is persisted before admission. Its suffix alone belongs to the interrupted run.
|
|
2387
|
-
const runEntries = recovering && selection >= 0 ? branch.slice(selection + 1) : [];
|
|
2388
|
-
const previous = runEntries.findLast((entry) => entry.type === "custom" && entry.customType === "adaptive-engine-snapshot");
|
|
2389
|
-
const admission = runEntries.findLast((entry) => entry.type === "custom" && entry.customType === "adaptive-engine-admission");
|
|
2390
|
-
const completionSeal = runEntries.findLast((entry) => entry.type === "custom" && entry.customType === "adaptive-engine-completion");
|
|
2391
|
-
const terminal = previous?.type === "custom" &&
|
|
2392
|
-
previous.data !== null &&
|
|
2393
|
-
typeof previous.data === "object" &&
|
|
2394
|
-
"checkpoint" in previous.data &&
|
|
2395
|
-
previous.data.checkpoint === "terminal";
|
|
2396
|
-
if (!trigger && !terminal)
|
|
2397
|
-
throw new Error("Adaptive completion reread requires a terminal snapshot");
|
|
2398
|
-
if (recovering && (previous?.type !== "custom" || admission?.type !== "custom"))
|
|
2399
|
-
throw new Error("Adaptive recovery is unsupported without the original persisted admission; no work replayed");
|
|
2400
|
-
if (this._bashJobs.list().some((job) => job.status === "running" || job.status === "interrupted"))
|
|
2401
|
-
throw new Error("Cannot admit adaptive execution while session jobs are running or cleanup is unconfirmed");
|
|
2402
|
-
if (!this.model)
|
|
2403
|
-
throw new Error("No adaptive model selected");
|
|
2404
|
-
if (trigger?.messageType === "user" &&
|
|
2405
|
-
trigger.images?.length &&
|
|
2406
|
-
(this.settingsManager.getBlockImages() || !this.model.input.includes("image")))
|
|
2407
|
-
throw new Error("Adaptive image capability refused; nothing was dropped or sent");
|
|
2408
|
-
this._cacheWarmer?.cancel();
|
|
2409
|
-
this._adaptiveHost = await loadAdaptiveExecutionHost({
|
|
2410
|
-
cwd: this._cwd,
|
|
2411
|
-
startedAt: { wall: Date.now(), monotonic: performance.now() },
|
|
2412
|
-
sessionId: this.sessionId,
|
|
2413
|
-
text: !trigger
|
|
2414
|
-
? ""
|
|
2415
|
-
: trigger.messageType === "user"
|
|
2416
|
-
? trigger.prompt
|
|
2417
|
-
: contentText(trigger.message.content, ""),
|
|
2418
|
-
facts: [
|
|
2419
|
-
...this._resourceLoader
|
|
2420
|
-
.getAgentsFiles()
|
|
2421
|
-
.agentsFiles.map((file) => `Project context ${file.path}:\n${file.content}`),
|
|
2422
|
-
...this.sessionManager
|
|
2423
|
-
.getBranch()
|
|
2424
|
-
.flatMap((entry) => entry.type === "message" && entry.message.role === "user"
|
|
2425
|
-
? [contentText(entry.message.content, "")].filter((text) => text.trim())
|
|
2426
|
-
: []),
|
|
2427
|
-
],
|
|
2428
|
-
images: trigger?.messageType === "user" ? (trigger.images ?? []) : [],
|
|
2429
|
-
model: this.model,
|
|
2430
|
-
thinkingLevel: () => this.thinkingLevel,
|
|
2431
|
-
runtime: this._modelRuntime,
|
|
2432
|
-
authorityIdentity: createHash("sha256")
|
|
2433
|
-
.update(JSON.stringify({
|
|
2434
|
-
tools: this.getActiveToolNames().map((name) => ({
|
|
2435
|
-
name,
|
|
2436
|
-
source: this._toolDefinitions.get(name)?.sourceInfo,
|
|
2437
|
-
})),
|
|
2438
|
-
overrides: !!this._baseToolsOverride,
|
|
2439
|
-
extensions: this._resourceLoader
|
|
2440
|
-
.getExtensions()
|
|
2441
|
-
.extensions.map((extension) => extension.path),
|
|
2442
|
-
profile: this._extensionRunner.getFlagValues().get("profile") ?? null,
|
|
2443
|
-
flowAdmission: this._extensionRunner.getFlagValues().get("flow-admission") ?? null,
|
|
2444
|
-
trusted: this.settingsManager.isProjectTrusted(),
|
|
2445
|
-
fallback: this.settingsManager.readOAuthAccountActivationPolicy(this.model.provider),
|
|
2446
|
-
nodeFallback: this.model.provider === HUMAIN_NODE_PROVIDER
|
|
2447
|
-
? this._modelRuntime.nodeAccountMetadata.read().policy
|
|
2448
|
-
: null,
|
|
2449
|
-
}))
|
|
2450
|
-
.digest("hex"),
|
|
2451
|
-
...(recovering && admission?.type === "custom" && previous?.type === "custom"
|
|
2452
|
-
? {
|
|
2453
|
-
recovery: {
|
|
2454
|
-
admission: admission.data,
|
|
2455
|
-
snapshot: previous.data,
|
|
2456
|
-
completion: completionSeal?.type === "custom" ? completionSeal.data : undefined,
|
|
2457
|
-
},
|
|
2458
|
-
}
|
|
2459
|
-
: {}),
|
|
2460
|
-
persistAdmission: (admission) => {
|
|
2461
|
-
this.sessionManager.appendCustomEntry("adaptive-engine-admission", admission);
|
|
2462
|
-
this.sessionManager.flush();
|
|
2463
|
-
},
|
|
2464
|
-
signal: runAbortController.signal,
|
|
2465
|
-
mode: this._extensionMode === "tui" ? "interactive" : "headless",
|
|
2466
|
-
deadline: this._timeLimit ? this._timeLimit.startedAt + this._timeLimit.seconds * 1000 : undefined,
|
|
2467
|
-
jobs: this._bashJobs,
|
|
2468
|
-
peerTools: () => this.agent.state.tools.filter((tool) => !this._baseToolsOverride &&
|
|
2469
|
-
["read", "ls", "edit", "write"].includes(tool.name) &&
|
|
2470
|
-
this._toolDefinitions.get(tool.name)?.sourceInfo.source === "builtin"),
|
|
2471
|
-
peerRequest: async (context, signal, maxTokens, state, nativeTools) => {
|
|
2472
|
-
const requestContext = { messages: context.messages, tools: state.tools.slice() };
|
|
2473
|
-
const prepared = await this._adaptivePeerPrepareRequest?.({
|
|
2474
|
-
context: requestContext,
|
|
2475
|
-
model: state.model,
|
|
2476
|
-
thinkingLevel: state.thinkingLevel,
|
|
2477
|
-
}, signal);
|
|
2478
|
-
const model = prepared?.model ?? state.model;
|
|
2479
|
-
const thinking = prepared?.thinkingLevel ?? state.thinkingLevel;
|
|
2480
|
-
const peerContext = prepared?.context ?? requestContext;
|
|
2481
|
-
const executableTools = peerContext.tools ?? [];
|
|
2482
|
-
// Peer custody covers native implementations only; never ignore a hook's replacement or addition.
|
|
2483
|
-
if (executableTools.some((tool) => !nativeTools.includes(tool)))
|
|
2484
|
-
throw new Error("Adaptive prepared peer tool additions/replacements are unsupported");
|
|
2485
|
-
// Providers replay declarations, not executable tools; retain the same removal policy on later turns.
|
|
2486
|
-
const changes = getToolStateChanges(getCurrentTools(peerContext.messages), executableTools);
|
|
2487
|
-
const preparedMessages = changes.toolsAdded.length || changes.toolsRemoved.length
|
|
2488
|
-
? [
|
|
2489
|
-
...peerContext.messages,
|
|
2490
|
-
{ role: "system", content: "", ...changes, timestamp: Date.now() },
|
|
2491
|
-
]
|
|
2492
|
-
: peerContext.messages;
|
|
2493
|
-
// Request-time transforms must not replace or mutate the retained prepared context.
|
|
2494
|
-
const messages = this._adaptivePeerTransformContext
|
|
2495
|
-
? await this._adaptivePeerTransformContext(structuredClone(preparedMessages), signal)
|
|
2496
|
-
: preparedMessages;
|
|
2497
|
-
const normalized = await this._normalizeOrdinaryToolImages({ ...peerContext, messages }, model);
|
|
2498
|
-
const response = await (await this._auxiliaryStreamFunction(model, normalizeContext({
|
|
2499
|
-
...context,
|
|
2500
|
-
messages: await this.agent.convertToLlm(normalized.messages),
|
|
2501
|
-
}), {
|
|
2502
|
-
signal,
|
|
2503
|
-
maxTokens,
|
|
2504
|
-
reasoning: thinking === "off" ? undefined : thinking,
|
|
2505
|
-
thinkingBudgets: this.agent.thinkingBudgets,
|
|
2506
|
-
transport: this.agent.transport,
|
|
2507
|
-
maxRetryDelayMs: this.agent.maxRetryDelayMs,
|
|
2508
|
-
identity: this.agent.identity,
|
|
2509
|
-
onPayload: this.agent.onPayload,
|
|
2510
|
-
onResponse: this.agent.onResponse,
|
|
2511
|
-
onProviderStreamEvent: this.agent.onProviderStreamEvent,
|
|
2512
|
-
})).result();
|
|
2513
|
-
return {
|
|
2514
|
-
response,
|
|
2515
|
-
state: {
|
|
2516
|
-
model,
|
|
2517
|
-
thinkingLevel: thinking,
|
|
2518
|
-
tools: executableTools,
|
|
2519
|
-
messages: preparedMessages,
|
|
2520
|
-
},
|
|
2521
|
-
};
|
|
2522
|
-
},
|
|
2523
|
-
beforePeerTool: (context) => {
|
|
2524
|
-
if (this.agent.beforeToolCall !== this._installedBeforeToolCall ||
|
|
2525
|
-
!this.getActiveToolNames().includes(context.toolCall.name) ||
|
|
2526
|
-
this._toolDefinitions.get(context.toolCall.name)?.sourceInfo.source !== "builtin")
|
|
2527
|
-
throw new Error("Adaptive peer tool authority changed");
|
|
2528
|
-
return this._authorizeToolCall(context);
|
|
2529
|
-
},
|
|
2530
|
-
afterPeerTool: (context, signal) => this.agent.afterToolCall?.(context, signal) ?? Promise.resolve(undefined),
|
|
2531
|
-
persist: async (snapshot) => {
|
|
2532
|
-
if (snapshot.checkpoint === "terminal")
|
|
2533
|
-
this._adaptiveSeal = {
|
|
2534
|
-
runId: snapshot.budget.identity.runId,
|
|
2535
|
-
admissionId: snapshot.budget.identity.admissionId,
|
|
2536
|
-
snapshotIdentity: createHash("sha256").update(JSON.stringify(snapshot)).digest("hex"),
|
|
2537
|
-
};
|
|
2538
|
-
this.sessionManager.appendCustomEntry("adaptive-engine-snapshot", snapshot);
|
|
2539
|
-
this.sessionManager.flush();
|
|
2540
|
-
},
|
|
2541
|
-
publish: (status) => {
|
|
2542
|
-
this._emit({ type: "adaptive_status", status });
|
|
2543
|
-
if (this._extensionMode === "tui")
|
|
2544
|
-
this._extensionUIContext?.setWorkingMessage(adaptiveStatusText(status));
|
|
2545
|
-
},
|
|
2546
|
-
presentChecklist: (summary, checklist, signal) => presentAdaptiveChecklist(summary, checklist, signal, this._extensionUIContext),
|
|
2547
|
-
messages: () => this.messages,
|
|
2548
|
-
recordSubmission: (reservation, phase, lane) => {
|
|
2549
|
-
this.sessionManager.appendCustomEntry("adaptive-request-attestation", {
|
|
2550
|
-
...reservation,
|
|
2551
|
-
phase,
|
|
2552
|
-
lane,
|
|
2553
|
-
});
|
|
2554
|
-
this.sessionManager.flush();
|
|
2555
|
-
},
|
|
2556
|
-
recordUsage: (provider, model, usage) => {
|
|
2557
|
-
const entry = this.sessionManager.appendUsage("adaptive", provider, model, usage);
|
|
2558
|
-
this._emit({ type: "entry_appended", entry });
|
|
2559
|
-
},
|
|
2560
|
-
abortImplementation: () => {
|
|
2561
|
-
this.agent.abort();
|
|
2562
|
-
this.abortCompaction();
|
|
2563
|
-
this.abortRetry();
|
|
2564
|
-
},
|
|
2565
|
-
wakeJob: (record) => {
|
|
2566
|
-
this.sessionManager.appendCustomEntry("adaptive-job-terminal", record);
|
|
2567
|
-
this._pendingCustomMessages.push({
|
|
2568
|
-
role: "custom",
|
|
2569
|
-
customType: "adaptive-job-terminal",
|
|
2570
|
-
content: `Owned job ${record.result.job_id} ${record.result.status}; inspect captured output with jobs before treating it as evidence.`,
|
|
2571
|
-
display: false,
|
|
2572
|
-
timestamp: Date.now(),
|
|
2573
|
-
});
|
|
2574
|
-
},
|
|
2575
|
-
}, {
|
|
2576
|
-
...this._adaptiveOptions,
|
|
2577
|
-
...(adaptiveStartingLevel !== undefined ? { startingLevel: adaptiveStartingLevel } : {}),
|
|
2578
|
-
}, this.settingsManager.getAdaptiveExecutionOptions());
|
|
2579
|
-
if (!recovering || !terminal)
|
|
2580
|
-
onStarted?.();
|
|
2581
|
-
const step = await this._adaptiveHost.next();
|
|
2582
|
-
if (step.kind === "complete") {
|
|
2583
|
-
this._acceptAdaptiveCompletion(step.completion);
|
|
2584
|
-
if (recovering)
|
|
2585
|
-
this._adaptiveRecoveryRead = true;
|
|
2586
|
-
this._adaptiveHost = undefined;
|
|
2587
|
-
this._agentRunAbortController = undefined;
|
|
2588
|
-
// A terminal reread is not the new task. Keep prompt ownership until that task settles.
|
|
2589
|
-
// Interrupted recovery still consumes only its frozen request.
|
|
2590
|
-
if (recovering && terminal && trigger) {
|
|
2591
|
-
runAbortController.signal.throwIfAborted();
|
|
2592
|
-
return this._startRun(trigger, onStarted, autoEffortText, adaptiveStartingLevel, fileTexts);
|
|
2593
|
-
}
|
|
2594
|
-
await this._emitAgentSettled();
|
|
2595
|
-
return;
|
|
2596
|
-
}
|
|
2597
|
-
if (runtimeStreamFunctions.get(this.agent.streamFunction) !== this._modelRuntime)
|
|
2598
|
-
throw new Error("Adaptive primary requires a ModelRuntime-owned stream; custom provider loops are unsupported");
|
|
2599
|
-
adaptiveSignal = step.context.signal;
|
|
2600
|
-
const abortPrimary = () => {
|
|
2601
|
-
this._agentRunAbortRequested = true;
|
|
2602
|
-
this.agent.abort();
|
|
2603
|
-
this.abortCompaction();
|
|
2604
|
-
this.abortRetry();
|
|
2605
|
-
};
|
|
2606
|
-
adaptiveSignal.addEventListener("abort", abortPrimary, { once: true });
|
|
2607
|
-
detachAdaptiveSignal = () => adaptiveSignal?.removeEventListener("abort", abortPrimary);
|
|
2608
|
-
if (adaptiveSignal.aborted)
|
|
2609
|
-
abortPrimary();
|
|
2610
|
-
if (!this._baseToolsOverride) {
|
|
2611
|
-
this._adaptiveLegacyJobs = this._baseToolDefinitions.get("jobs");
|
|
2612
|
-
this._baseToolDefinitions.set("jobs", createJobsToolDefinition(this._cwd, {
|
|
2613
|
-
jobs: this._bashJobs,
|
|
2614
|
-
getRunContext: () => this._adaptiveHost?.runContext,
|
|
2615
|
-
}));
|
|
2616
|
-
this._refreshToolRegistry();
|
|
2617
|
-
}
|
|
2618
|
-
this._appendAdaptiveWork(step.input);
|
|
2619
|
-
if (recovering) {
|
|
2620
|
-
trigger = {
|
|
2621
|
-
messageType: "user",
|
|
2622
|
-
prompt: this._adaptiveHost.prompt.text,
|
|
2623
|
-
images: this._adaptiveHost.prompt.images,
|
|
2624
|
-
};
|
|
2625
|
-
autoEffortText = trigger.prompt;
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
if (!trigger)
|
|
2629
|
-
throw new Error("Adaptive terminal reread cannot dispatch work");
|
|
2630
|
-
const runTrigger = trigger;
|
|
2631
|
-
messages = await this._withAdaptiveAdmission(() => this._prepareRun(runTrigger, runAbortController.signal, autoEffortText));
|
|
2373
|
+
messages = await this._prepareRun(trigger, runAbortController.signal, autoEffortText);
|
|
2632
2374
|
}
|
|
2633
2375
|
catch (error) {
|
|
2634
|
-
detachAdaptiveSignal?.();
|
|
2635
|
-
if (selectedEngine === "adaptive-v2")
|
|
2636
|
-
runAbortController.abort();
|
|
2637
|
-
try {
|
|
2638
|
-
await this._finishAdaptiveExecution();
|
|
2639
|
-
}
|
|
2640
|
-
catch {
|
|
2641
|
-
/* Preserve the originating pre-run refusal. */
|
|
2642
|
-
}
|
|
2643
|
-
if (selectedEngine === "adaptive-v2")
|
|
2644
|
-
await this._emitAgentSettled();
|
|
2645
2376
|
if (this._agentRunAbortController === runAbortController)
|
|
2646
2377
|
this._agentRunAbortController = undefined;
|
|
2647
2378
|
this._runSystemPromptOptions = undefined;
|
|
@@ -2652,8 +2383,7 @@ export class AgentSession {
|
|
|
2652
2383
|
this._modelRuntime.metadata.feature("prompt", Math.round(performance.now() - started), "failure");
|
|
2653
2384
|
throw error;
|
|
2654
2385
|
}
|
|
2655
|
-
|
|
2656
|
-
if (selectedEngine === "legacy" && trigger.messageType === "user" && this._runPreflight) {
|
|
2386
|
+
if (trigger.messageType === "user" && this._runPreflight) {
|
|
2657
2387
|
this._acceptanceLedger = new AcceptanceLedger(trigger.prompt, () => {
|
|
2658
2388
|
for (const owner of this._bashJobOwners)
|
|
2659
2389
|
if (owner.hasActiveEffects)
|
|
@@ -2670,8 +2400,7 @@ export class AgentSession {
|
|
|
2670
2400
|
// have while idle. No run exists yet, so they cannot split a tool call from its result.
|
|
2671
2401
|
this._flushPendingBashMessages();
|
|
2672
2402
|
this._flushPendingCustomMessages();
|
|
2673
|
-
|
|
2674
|
-
onStarted?.();
|
|
2403
|
+
onStarted?.();
|
|
2675
2404
|
// Compaction before the prompt may have scheduled a retry; the new prompt replaces it.
|
|
2676
2405
|
this._failedResponse = undefined;
|
|
2677
2406
|
this._recordSelection();
|
|
@@ -2702,8 +2431,7 @@ export class AgentSession {
|
|
|
2702
2431
|
// agent_start applies an abort requested during preparation or warm-up before any provider request.
|
|
2703
2432
|
await this._observeRequests("chat", () => this.agent.prompt(messages));
|
|
2704
2433
|
while (!this._agentRunAbortRequested) {
|
|
2705
|
-
if (
|
|
2706
|
-
(await this._withAdaptiveAdmission(() => this._handlePostAgentRun()))) {
|
|
2434
|
+
if (await this._handlePostAgentRun()) {
|
|
2707
2435
|
if (this._agentRunAbortRequested)
|
|
2708
2436
|
break;
|
|
2709
2437
|
await this._observeRequests("chat", () => this.agent.continue());
|
|
@@ -2711,22 +2439,8 @@ export class AgentSession {
|
|
|
2711
2439
|
}
|
|
2712
2440
|
if (this._agentRunAbortRequested)
|
|
2713
2441
|
break;
|
|
2714
|
-
let continuation = this.
|
|
2715
|
-
|
|
2716
|
-
: await this._withAdaptiveAdmission(() => this._runBeforeSettleBoundary());
|
|
2717
|
-
if (!continuation && this._adaptiveHost) {
|
|
2718
|
-
this._adaptiveHost.completeAct();
|
|
2719
|
-
const step = await this._adaptiveHost.next();
|
|
2720
|
-
if (step.kind === "complete") {
|
|
2721
|
-
this._acceptAdaptiveCompletion(step.completion);
|
|
2722
|
-
if (recovering)
|
|
2723
|
-
this._adaptiveRecoveryRead = true;
|
|
2724
|
-
break;
|
|
2725
|
-
}
|
|
2726
|
-
this._appendAdaptiveWork(step.input);
|
|
2727
|
-
continuation = true;
|
|
2728
|
-
}
|
|
2729
|
-
else if (!continuation && !this._managedRunStopped && this._acceptanceLedger) {
|
|
2442
|
+
let continuation = await this._runBeforeSettleBoundary();
|
|
2443
|
+
if (!continuation && !this._managedRunStopped && this._acceptanceLedger) {
|
|
2730
2444
|
await this._verifyAcceptance();
|
|
2731
2445
|
continuation =
|
|
2732
2446
|
this.agent.hasQueuedMessages() && this._buildBoundaryContext([], "agent_before_settle").canContinue;
|
|
@@ -2738,17 +2452,9 @@ export class AgentSession {
|
|
|
2738
2452
|
}
|
|
2739
2453
|
finally {
|
|
2740
2454
|
try {
|
|
2741
|
-
detachAdaptiveSignal?.();
|
|
2742
|
-
if (this._adaptiveHost && !this._adaptiveCompletion) {
|
|
2743
|
-
if (!adaptiveSignal?.aborted)
|
|
2744
|
-
runAbortController.abort();
|
|
2745
|
-
await this._finishAdaptiveExecution();
|
|
2746
|
-
}
|
|
2747
2455
|
this._settleAcceptance();
|
|
2748
2456
|
}
|
|
2749
2457
|
finally {
|
|
2750
|
-
this._adaptiveHost = undefined;
|
|
2751
|
-
this._restoreAdaptiveJobs();
|
|
2752
2458
|
if (this._agentRunAbortRequested)
|
|
2753
2459
|
this._finishCancelledRetry();
|
|
2754
2460
|
this._failedResponse = undefined;
|
|
@@ -2943,56 +2649,6 @@ export class AgentSession {
|
|
|
2943
2649
|
}
|
|
2944
2650
|
}
|
|
2945
2651
|
}
|
|
2946
|
-
async _finishAdaptiveExecution() {
|
|
2947
|
-
const host = this._adaptiveHost;
|
|
2948
|
-
if (!host)
|
|
2949
|
-
return;
|
|
2950
|
-
try {
|
|
2951
|
-
host.completeAct();
|
|
2952
|
-
this._acceptAdaptiveCompletion(await host.finished);
|
|
2953
|
-
}
|
|
2954
|
-
finally {
|
|
2955
|
-
this._adaptiveHost = undefined;
|
|
2956
|
-
this._restoreAdaptiveJobs();
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
_restoreAdaptiveJobs() {
|
|
2960
|
-
if (!this._adaptiveLegacyJobs)
|
|
2961
|
-
return;
|
|
2962
|
-
this._baseToolDefinitions.set("jobs", this._adaptiveLegacyJobs);
|
|
2963
|
-
this._adaptiveLegacyJobs = undefined;
|
|
2964
|
-
this._refreshToolRegistry();
|
|
2965
|
-
}
|
|
2966
|
-
_acceptAdaptiveCompletion(completion) {
|
|
2967
|
-
const seal = this._adaptiveSeal;
|
|
2968
|
-
if (seal) {
|
|
2969
|
-
this.sessionManager.appendCustomEntry("adaptive-engine-completion", {
|
|
2970
|
-
version: 1,
|
|
2971
|
-
...seal,
|
|
2972
|
-
verification: completion.verification,
|
|
2973
|
-
workflowOutcome: completion.workflowOutcome,
|
|
2974
|
-
});
|
|
2975
|
-
this.sessionManager.flush();
|
|
2976
|
-
this._adaptiveSeal = undefined;
|
|
2977
|
-
}
|
|
2978
|
-
this._adaptiveCompletion = completion;
|
|
2979
|
-
this._emit({ type: "adaptive_completion", completion });
|
|
2980
|
-
if (this._extensionMode === "tui") {
|
|
2981
|
-
this._extensionUIContext?.setWorkingMessage(undefined);
|
|
2982
|
-
this._extensionUIContext?.notify(adaptiveEvidenceLines(completion).join("\n"), completion.verification === "verified" ? "info" : "warning");
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
_appendAdaptiveWork(input) {
|
|
2986
|
-
this._pendingCustomMessages.push({
|
|
2987
|
-
role: "custom",
|
|
2988
|
-
customType: "adaptive-work",
|
|
2989
|
-
display: false,
|
|
2990
|
-
content: `Admitted adaptive primary work: ${JSON.stringify(input)}\n${input.level >= 1 ? "Make a short plan naming affected contracts and checks before mutation. " : ""}Satisfy each criterion, self-check and report limitations. Host-captured checks and a counterexample are required; your prose or JSON cannot certify behavior. Nested model execution is not authorized. ${input.level === 2 ? 'For genuinely independent work, end a short plan with <adaptive_peers>[{"paths":["relative/owned/path"],"task":"bounded independent task","benefit":"why parallel work helps","tokens":30000}]</adaptive_peers>. At most two scopes; give each enough tokens for bounded input plus output on every request. The host admits disjoint scopes and returns collected summaries to you for integration before checking. Do not delegate unsplittable work. ' : ""}If new facts add or refine scope, append <adaptive_updates>{"requirements":[{"kind":"append","acceptance":"new atomic criterion"}],"facts":["observed fact"]}</adaptive_updates>; refine uses kind=refine plus id. This is a proposal only, never evidence/status/removal authority.`,
|
|
2991
|
-
timestamp: Date.now(),
|
|
2992
|
-
});
|
|
2993
|
-
if (this.agent.state.messages.length)
|
|
2994
|
-
this._flushPendingCustomMessages();
|
|
2995
|
-
}
|
|
2996
2652
|
/**
|
|
2997
2653
|
* Prepare a run and return its starting messages: compact first when needed, emit
|
|
2998
2654
|
* before_agent_start, apply the run's prompt options and tool loadout, and build the starting
|
|
@@ -3043,8 +2699,15 @@ export class AgentSession {
|
|
|
3043
2699
|
this._autoEffortInputs.set(userMessage, autoEffortText);
|
|
3044
2700
|
messages.push(userMessage);
|
|
3045
2701
|
}
|
|
3046
|
-
//
|
|
2702
|
+
// Only submitted input, not context generated by before_agent_start, is fresh.
|
|
3047
2703
|
messages.push(...this._pendingNextTurnMessages);
|
|
2704
|
+
const fresh = messages.slice();
|
|
2705
|
+
for (const message of fresh) {
|
|
2706
|
+
if ("content" in message &&
|
|
2707
|
+
Array.isArray(message.content) &&
|
|
2708
|
+
message.content.some((block) => block.type === "image"))
|
|
2709
|
+
this._freshImageInputs.add(message);
|
|
2710
|
+
}
|
|
3048
2711
|
for (const msg of result.messages) {
|
|
3049
2712
|
messages.push({
|
|
3050
2713
|
role: "custom",
|
|
@@ -3073,6 +2736,7 @@ export class AgentSession {
|
|
|
3073
2736
|
const userTurn = context.slice(lastResponse + 1).some((message) => message.role === "user");
|
|
3074
2737
|
prepared = await this._modelRuntime.resolveModel(selection, context, {
|
|
3075
2738
|
reason: userTurn ? "user" : "continuation",
|
|
2739
|
+
deferThinkingClamp: true,
|
|
3076
2740
|
thinkingLevel: preparedThinking,
|
|
3077
2741
|
state: preparedState,
|
|
3078
2742
|
});
|
|
@@ -3085,7 +2749,7 @@ export class AgentSession {
|
|
|
3085
2749
|
userMessage.content = [{ type: "text", text }, ...normalized.images];
|
|
3086
2750
|
}
|
|
3087
2751
|
if (target?.provider === HCODE_PROVIDER)
|
|
3088
|
-
await this._validateManagedInput(target,
|
|
2752
|
+
await this._validateManagedInput(target, fresh);
|
|
3089
2753
|
if (prepared && selection)
|
|
3090
2754
|
this._preparedImageRoute = {
|
|
3091
2755
|
selection,
|
|
@@ -3182,6 +2846,7 @@ export class AgentSession {
|
|
|
3182
2846
|
return { text, images };
|
|
3183
2847
|
}
|
|
3184
2848
|
async _normalizeOrdinaryToolImages(context, model) {
|
|
2849
|
+
// Managed requests fit the effective transcript after the context hooks.
|
|
3185
2850
|
if (model.provider === HCODE_PROVIDER)
|
|
3186
2851
|
return context;
|
|
3187
2852
|
// History keeps originals for future managed routes; normalize only the resolved ordinary request.
|
|
@@ -3223,35 +2888,58 @@ export class AgentSession {
|
|
|
3223
2888
|
const selection = this.model;
|
|
3224
2889
|
if (!selection)
|
|
3225
2890
|
return;
|
|
3226
|
-
const combined = [...context, ...messages];
|
|
3227
2891
|
const thinkingLevel = this.thinkingLevel;
|
|
3228
2892
|
if (!isVirtualModel(selection)) {
|
|
3229
|
-
await this._validateManagedInput(selection,
|
|
2893
|
+
await this._validateManagedInput(selection, messages);
|
|
3230
2894
|
return;
|
|
3231
2895
|
}
|
|
3232
|
-
const llm = convertToLlm(
|
|
2896
|
+
const llm = convertToLlm([...context, ...messages]);
|
|
3233
2897
|
if (!llm.some((message) => typeof message.content !== "string" && message.content.some((block) => block.type === "image")))
|
|
3234
2898
|
return;
|
|
3235
2899
|
const state = getVirtualModelState(this.sessionManager.getBranch(), selection.provider, selection.id);
|
|
3236
2900
|
const route = await this._modelRuntime.resolveModel(selection, llm, {
|
|
3237
2901
|
reason: "user",
|
|
2902
|
+
deferThinkingClamp: true,
|
|
3238
2903
|
thinkingLevel,
|
|
3239
2904
|
state,
|
|
3240
2905
|
signal,
|
|
3241
2906
|
});
|
|
3242
|
-
await this._validateManagedInput(route.model,
|
|
2907
|
+
await this._validateManagedInput(route.model, messages);
|
|
3243
2908
|
return { selection, route, thinkingLevel, state };
|
|
3244
2909
|
}
|
|
3245
|
-
|
|
2910
|
+
// Context hooks clone messages; correlate the original attachment even if a hook changes the surrounding text.
|
|
2911
|
+
_matchesImageInput(input, message) {
|
|
2912
|
+
if (input === message)
|
|
2913
|
+
return true;
|
|
2914
|
+
if (input.role !== "user" && input.role !== "custom")
|
|
2915
|
+
return false;
|
|
2916
|
+
if (message.role !== input.role || message.timestamp !== input.timestamp)
|
|
2917
|
+
return false;
|
|
2918
|
+
if (input.role === "custom" && (message.role !== "custom" || message.customType !== input.customType))
|
|
2919
|
+
return false;
|
|
2920
|
+
const { content } = input;
|
|
2921
|
+
return (Array.isArray(content) &&
|
|
2922
|
+
Array.isArray(message.content) &&
|
|
2923
|
+
message.content.some((block) => block.type === "image" &&
|
|
2924
|
+
content.some((original) => original.type === "image" && block.mimeType === original.mimeType && block.data === original.data)));
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Check submitted input before persisting it. Historical images are fitted only in the request projection.
|
|
2928
|
+
*/
|
|
2929
|
+
async _validateManagedInput(model, fresh) {
|
|
3246
2930
|
if (model.provider !== HCODE_PROVIDER)
|
|
3247
2931
|
return;
|
|
3248
2932
|
const reference = captureHcodeSelection(this._modelRuntime, model);
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
2933
|
+
const fitted = await fitHcodeImages(model, fresh, {
|
|
2934
|
+
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
2935
|
+
blockImages: this.settingsManager.getBlockImages(),
|
|
2936
|
+
}, new Set(fresh));
|
|
2937
|
+
const [refused] = fitted.omitted;
|
|
2938
|
+
if (refused) {
|
|
2939
|
+
const message = hcodeImageMessage(refused.reason, model);
|
|
2940
|
+
throw new Error(refused.reason === "blocked" ? `${message} Nothing was dropped or sent.` : message);
|
|
2941
|
+
}
|
|
2942
|
+
await validateHcodeImages(model, convertToLlm(fitted.messages));
|
|
3255
2943
|
assertHcodeSelection(this._modelRuntime, model, reference);
|
|
3256
2944
|
}
|
|
3257
2945
|
async _normalizePromptImages(images, model) {
|
|
@@ -3267,8 +2955,6 @@ export class AgentSession {
|
|
|
3267
2955
|
resizeOptions: model?.inputLimits?.images?.resize,
|
|
3268
2956
|
});
|
|
3269
2957
|
if (!processed.ok) {
|
|
3270
|
-
if (this.executionEngine === "adaptive-v2")
|
|
3271
|
-
throw new Error(`Adaptive image input refused: ${processed.message}`);
|
|
3272
2958
|
hints.push(processed.message);
|
|
3273
2959
|
continue;
|
|
3274
2960
|
}
|
|
@@ -3277,15 +2963,6 @@ export class AgentSession {
|
|
|
3277
2963
|
}
|
|
3278
2964
|
return { images: normalizedImages, hints };
|
|
3279
2965
|
}
|
|
3280
|
-
/** Revalidate a reopened terminal run's evidence without submitting a new task or replaying work. */
|
|
3281
|
-
async rereadAdaptiveCompletion() {
|
|
3282
|
-
if (!this.isIdle || this._promptPreflightCount > 0)
|
|
3283
|
-
throw new Error("Wait for the current session operation before rereading adaptive completion");
|
|
3284
|
-
await this._startRun(undefined);
|
|
3285
|
-
if (!this._adaptiveCompletion)
|
|
3286
|
-
throw new Error("Adaptive terminal completion unavailable");
|
|
3287
|
-
return this._adaptiveCompletion;
|
|
3288
|
-
}
|
|
3289
2966
|
/**
|
|
3290
2967
|
* Send a prompt to the agent.
|
|
3291
2968
|
* - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming
|
|
@@ -3326,7 +3003,7 @@ export class AgentSession {
|
|
|
3326
3003
|
this._promptPreflightCount--;
|
|
3327
3004
|
}
|
|
3328
3005
|
if (prepared) {
|
|
3329
|
-
await this._startRun(prepared.trigger, () => preflightResult?.("started"), prepared.autoEffortText, options?.
|
|
3006
|
+
await this._startRun(prepared.trigger, () => preflightResult?.("started"), prepared.autoEffortText, options?.fileTexts);
|
|
3330
3007
|
}
|
|
3331
3008
|
}
|
|
3332
3009
|
/**
|
|
@@ -3557,8 +3234,10 @@ export class AgentSession {
|
|
|
3557
3234
|
this._emitQueueUpdate();
|
|
3558
3235
|
if (autoEffortText !== undefined)
|
|
3559
3236
|
this._autoEffortInputs.set(message, autoEffortText);
|
|
3560
|
-
if (images?.length)
|
|
3237
|
+
if (images?.length) {
|
|
3561
3238
|
this._queuedMessagesWithImages.add(message);
|
|
3239
|
+
this._freshImageInputs.add(message);
|
|
3240
|
+
}
|
|
3562
3241
|
this.agent.steer(message);
|
|
3563
3242
|
}
|
|
3564
3243
|
/**
|
|
@@ -3576,8 +3255,10 @@ export class AgentSession {
|
|
|
3576
3255
|
this._emitQueueUpdate();
|
|
3577
3256
|
if (autoEffortText !== undefined)
|
|
3578
3257
|
this._autoEffortInputs.set(message, autoEffortText);
|
|
3579
|
-
if (images?.length)
|
|
3258
|
+
if (images?.length) {
|
|
3580
3259
|
this._queuedMessagesWithImages.add(message);
|
|
3260
|
+
this._freshImageInputs.add(message);
|
|
3261
|
+
}
|
|
3581
3262
|
this.agent.followUp(message);
|
|
3582
3263
|
}
|
|
3583
3264
|
/** Normalize queued images at delivery without changing the original automatic-effort input. */
|
|
@@ -3635,6 +3316,10 @@ export class AgentSession {
|
|
|
3635
3316
|
this._pendingNextTurnMessages.push(appMessage);
|
|
3636
3317
|
}
|
|
3637
3318
|
else if (this.isStreaming && options?.triggerTurn !== false) {
|
|
3319
|
+
if (Array.isArray(appMessage.content) && appMessage.content.some((block) => block.type === "image")) {
|
|
3320
|
+
this._freshImageInputs.add(appMessage);
|
|
3321
|
+
this._queuedUserInputs.add(appMessage);
|
|
3322
|
+
}
|
|
3638
3323
|
if (options?.deliverAs === "followUp") {
|
|
3639
3324
|
this.agent.followUp(appMessage);
|
|
3640
3325
|
}
|
|
@@ -3790,9 +3475,19 @@ export class AgentSession {
|
|
|
3790
3475
|
* @throws Error if no auth is configured for the model
|
|
3791
3476
|
*/
|
|
3792
3477
|
async setModel(model, options = {}) {
|
|
3793
|
-
await this._selectModel(model, options, "set");
|
|
3478
|
+
const notice = await this._selectModel(model, options, "set");
|
|
3479
|
+
if (notice)
|
|
3480
|
+
this._emit({ type: "thinking_level_adjusted", notice });
|
|
3481
|
+
}
|
|
3482
|
+
/** @internal Whether a model selection has started, even if its auth check is still pending. */
|
|
3483
|
+
get hasRequestedModelSelection() {
|
|
3484
|
+
return this._modelSelectionRevision > 0;
|
|
3485
|
+
}
|
|
3486
|
+
/** Select only a model, retaining the live thinking level where the new model supports it. */
|
|
3487
|
+
async setModelKeepingThinking(model, options = {}) {
|
|
3488
|
+
return this._selectModel(model, options, "set", "keep-current");
|
|
3794
3489
|
}
|
|
3795
|
-
async _selectModel(model, options, source) {
|
|
3490
|
+
async _selectModel(model, options, source, thinkingPolicy = "defaults") {
|
|
3796
3491
|
const started = performance.now();
|
|
3797
3492
|
let outcome = "failure";
|
|
3798
3493
|
try {
|
|
@@ -3802,7 +3497,7 @@ export class AgentSession {
|
|
|
3802
3497
|
if ((source === "set" || reference) && !(await this._modelRuntime.checkAuth(model.provider))) {
|
|
3803
3498
|
if (reference) {
|
|
3804
3499
|
assertHcodeSelection(this._modelRuntime, model, reference);
|
|
3805
|
-
throw new Error(
|
|
3500
|
+
throw new Error("The saved HUMAIN Code sign-in could not authorize model selection. Use /login to sign in again. No model was switched.");
|
|
3806
3501
|
}
|
|
3807
3502
|
throw new Error(`No API key for ${model.provider}/${model.id}`);
|
|
3808
3503
|
}
|
|
@@ -3812,11 +3507,15 @@ export class AgentSession {
|
|
|
3812
3507
|
? HCODE_SELECTION_CHANGED_MESSAGE
|
|
3813
3508
|
: "Model selection changed. Use /model to choose again. No selection was saved.");
|
|
3814
3509
|
const previousModel = this.model;
|
|
3815
|
-
const
|
|
3510
|
+
const requestedLevel = thinkingPolicy === "keep-current"
|
|
3511
|
+
? this.thinkingLevel
|
|
3512
|
+
: this._getThinkingLevelForModelSwitch(model, options.thinkingLevel);
|
|
3816
3513
|
if (reference) {
|
|
3817
3514
|
assertHcodeSelection(this._modelRuntime, model, reference);
|
|
3818
|
-
|
|
3515
|
+
if (options.thinkingLevel !== undefined)
|
|
3516
|
+
this._assertManagedThinkingLevel(model, requestedLevel);
|
|
3819
3517
|
}
|
|
3518
|
+
const thinkingLevel = thinkingPolicy === "keep-current" || reference ? clampThinkingLevel(model, requestedLevel) : requestedLevel;
|
|
3820
3519
|
// Apply model
|
|
3821
3520
|
this.agent.state.model = model;
|
|
3822
3521
|
markModelSelectionChosen(this.sessionManager);
|
|
@@ -3831,6 +3530,8 @@ export class AgentSession {
|
|
|
3831
3530
|
this.setThinkingLevel(thinkingLevel);
|
|
3832
3531
|
await this._emitModelSelect(model, previousModel, source);
|
|
3833
3532
|
outcome = "success";
|
|
3533
|
+
if (requestedLevel !== thinkingLevel)
|
|
3534
|
+
return `Thinking level adjusted from ${requestedLevel} to ${thinkingLevel}.`;
|
|
3834
3535
|
}
|
|
3835
3536
|
finally {
|
|
3836
3537
|
if (options.signal?.aborted)
|
|
@@ -3867,8 +3568,13 @@ export class AgentSession {
|
|
|
3867
3568
|
return this._cycleAvailableModel(direction, options);
|
|
3868
3569
|
}
|
|
3869
3570
|
async _cycleScopedModel(direction, options) {
|
|
3870
|
-
const
|
|
3871
|
-
const scopedModels = this._scopedModels.
|
|
3571
|
+
const available = new Map(this._modelRuntime.getAvailableSnapshot().map((model) => [`${model.provider}\0${model.id}`, model]));
|
|
3572
|
+
const scopedModels = this._scopedModels.flatMap((scoped) => {
|
|
3573
|
+
const model = available.get(`${scoped.model.provider}\0${scoped.model.id}`);
|
|
3574
|
+
if (!model)
|
|
3575
|
+
return [];
|
|
3576
|
+
return [model.provider === HCODE_PROVIDER ? { ...scoped, model } : scoped];
|
|
3577
|
+
});
|
|
3872
3578
|
const currentModel = this.model;
|
|
3873
3579
|
const currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
|
|
3874
3580
|
const nextIndex = getNextCycleIndex(currentIndex, scopedModels.length, direction);
|
|
@@ -3880,8 +3586,8 @@ export class AgentSession {
|
|
|
3880
3586
|
// - Per-model thinking level overrides take priority over the global default
|
|
3881
3587
|
// setThinkingLevel clamps to model capabilities.
|
|
3882
3588
|
// Model persistence does not implicitly rewrite the global thinking default.
|
|
3883
|
-
await this._selectModel(next.model, { ...options, thinkingLevel: options.thinkingLevel ?? next.thinkingLevel }, "cycle");
|
|
3884
|
-
return { model: next.model, thinkingLevel: this.thinkingLevel, isScoped: true };
|
|
3589
|
+
const notice = await this._selectModel(next.model, { ...options, thinkingLevel: options.thinkingLevel ?? next.thinkingLevel }, "cycle");
|
|
3590
|
+
return { model: next.model, thinkingLevel: this.thinkingLevel, isScoped: true, ...(notice ? { notice } : {}) };
|
|
3885
3591
|
}
|
|
3886
3592
|
async _cycleAvailableModel(direction, options) {
|
|
3887
3593
|
const availableModels = this._modelRuntime.getAvailableSnapshot();
|
|
@@ -3893,8 +3599,8 @@ export class AgentSession {
|
|
|
3893
3599
|
const nextModel = availableModels[nextIndex];
|
|
3894
3600
|
// Apply thinking level for the new model.
|
|
3895
3601
|
// Model persistence does not implicitly rewrite the global thinking default.
|
|
3896
|
-
await this._selectModel(nextModel, options, "cycle");
|
|
3897
|
-
return { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: false };
|
|
3602
|
+
const notice = await this._selectModel(nextModel, options, "cycle");
|
|
3603
|
+
return { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: false, ...(notice ? { notice } : {}) };
|
|
3898
3604
|
}
|
|
3899
3605
|
// =========================================================================
|
|
3900
3606
|
// Thinking Level Management
|
|
@@ -4582,6 +4288,7 @@ export class AgentSession {
|
|
|
4582
4288
|
if (bindings.onError !== undefined) {
|
|
4583
4289
|
this._extensionErrorListener = bindings.onError;
|
|
4584
4290
|
}
|
|
4291
|
+
this._extensionsBound = true;
|
|
4585
4292
|
this._applyExtensionBindings(this._extensionRunner);
|
|
4586
4293
|
this._rebuildSystemPrompt(this.getActiveToolNames());
|
|
4587
4294
|
await this._extensionRunner.emit(this._sessionStartEvent);
|
|
@@ -4924,17 +4631,8 @@ export class AgentSession {
|
|
|
4924
4631
|
: createAllToolDefinitions(this._cwd, {
|
|
4925
4632
|
read: { autoResizeImages },
|
|
4926
4633
|
bash: {
|
|
4927
|
-
operations:
|
|
4928
|
-
...bashOperations,
|
|
4929
|
-
exec: (command, cwd, options) => {
|
|
4930
|
-
const qualified = this._adaptiveHost?.qualifyShellExecution(command);
|
|
4931
|
-
return qualified
|
|
4932
|
-
? bashOperations.exec(qualified.command, cwd, { ...options, env: qualified.env })
|
|
4933
|
-
: bashOperations.exec(command, cwd, options);
|
|
4934
|
-
},
|
|
4935
|
-
},
|
|
4634
|
+
operations: bashOperations,
|
|
4936
4635
|
jobs: this._bashJobs,
|
|
4937
|
-
getRunContext: () => this._adaptiveHost?.runContext,
|
|
4938
4636
|
outputHeadTail: this.settingsManager.getBashOutputHeadTail(),
|
|
4939
4637
|
outputCleanup: this.settingsManager.getBashOutputCleanup(),
|
|
4940
4638
|
commandPrefix: shellCommandPrefix,
|
|
@@ -4993,16 +4691,13 @@ export class AgentSession {
|
|
|
4993
4691
|
// Tools the new extensions register later, such as MCP tools, are pending until then.
|
|
4994
4692
|
for (const name of this.getActiveToolNames())
|
|
4995
4693
|
this._pendingToolNames.add(name);
|
|
4694
|
+
this._restoredToolNames = new Set(this.getActiveToolNames());
|
|
4996
4695
|
this._buildRuntime({
|
|
4997
4696
|
activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
|
|
4998
4697
|
flagValues: previousFlagValues,
|
|
4999
4698
|
includeAllExtensionTools: true,
|
|
5000
4699
|
});
|
|
5001
|
-
|
|
5002
|
-
this._extensionCommandContextActions ||
|
|
5003
|
-
this._extensionShutdownHandler ||
|
|
5004
|
-
this._extensionErrorListener;
|
|
5005
|
-
if (hasBindings) {
|
|
4700
|
+
if (this._extensionsBound) {
|
|
5006
4701
|
await options?.beforeSessionStart?.();
|
|
5007
4702
|
await this._extensionRunner.emit({ type: "session_start", reason: "reload" });
|
|
5008
4703
|
this._extensionRunner.reportUnhandledMcpServers();
|
|
@@ -6247,9 +5942,9 @@ export class AgentSession {
|
|
|
6247
5942
|
// Utilities
|
|
6248
5943
|
// =========================================================================
|
|
6249
5944
|
/**
|
|
6250
|
-
* Get text content of last assistant
|
|
5945
|
+
* Get text content of the last assistant reply.
|
|
6251
5946
|
* Useful for /copy command.
|
|
6252
|
-
* @returns Text content, or undefined if no assistant message exists
|
|
5947
|
+
* @returns Text content, or undefined if no assistant message exists or the last reply has no text
|
|
6253
5948
|
*/
|
|
6254
5949
|
getLastAssistantText() {
|
|
6255
5950
|
const lastAssistant = this.messages
|
|
@@ -6259,8 +5954,9 @@ export class AgentSession {
|
|
|
6259
5954
|
if (m.role !== "assistant")
|
|
6260
5955
|
return false;
|
|
6261
5956
|
const msg = m;
|
|
6262
|
-
// Skip aborted
|
|
6263
|
-
|
|
5957
|
+
// Skip messages without text from a turn that did not end normally: aborted, failed or only
|
|
5958
|
+
// calling tools (#12119). A reply that ended normally stays the last reply even without text.
|
|
5959
|
+
if (msg.stopReason !== "stop" && !msg.content.some((c) => c.type === "text" && c.text.trim()))
|
|
6264
5960
|
return false;
|
|
6265
5961
|
return true;
|
|
6266
5962
|
});
|