@humain/humain-code 0.6.2 → 0.7.0
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 +119 -0
- package/README.md +23 -6
- package/dist/agent-monitor/entry.lazy.d.ts +3 -0
- package/dist/agent-monitor/entry.lazy.d.ts.map +1 -0
- package/dist/agent-monitor/entry.lazy.js +3 -0
- package/dist/agent-monitor/entry.lazy.js.map +1 -0
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/adaptive-peer-worker-X2ZNZE3S.js +8 -0
- package/dist/bundle/chunks/adaptive-session-host-7KDSQV5I.js +162 -0
- package/dist/bundle/chunks/anthropic-messages-TQK3FUV3.js +68 -0
- package/dist/bundle/chunks/anthropic.js +13 -10
- package/dist/bundle/chunks/{azure-openai-responses-IV74M5OR.js → azure-openai-responses-JY7OSLH2.js} +6 -6
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -74
- package/dist/bundle/chunks/chunk-2FYYW6FY.js +2 -0
- package/dist/bundle/chunks/{chunk-A2VPLMF2.js → chunk-2G7YVAVF.js} +1 -1
- package/dist/bundle/chunks/chunk-32QLLD2P.js +1114 -0
- package/dist/bundle/chunks/{chunk-3LP543EX.js → chunk-3EDMWQ35.js} +17 -16
- package/dist/bundle/chunks/chunk-3HVHETMU.js +18 -0
- package/dist/bundle/chunks/{chunk-XMZGB3H4.js → chunk-4HTVBBJD.js} +11 -6
- package/dist/bundle/chunks/chunk-4JRER4XK.js +175 -0
- package/dist/bundle/chunks/{chunk-FHLLDO7U.js → chunk-4PRNKB6V.js} +5 -5
- package/dist/bundle/chunks/chunk-4QAXV5T6.js +49 -0
- package/dist/bundle/chunks/{chunk-JCTQQ3DX.js → chunk-4V5VL2BO.js} +1 -1
- package/dist/bundle/chunks/chunk-5B25YXF7.js +24 -0
- package/dist/bundle/chunks/chunk-5L4PBYC7.js +11 -0
- package/dist/bundle/chunks/chunk-66FZJO75.js +5146 -0
- package/dist/bundle/chunks/chunk-6P6GJPYB.js +4 -0
- package/dist/bundle/chunks/chunk-6PNQYO6A.js +10 -0
- package/dist/bundle/chunks/chunk-7NKUVTBL.js +76 -0
- package/dist/bundle/chunks/chunk-AEWYICBL.js +89 -0
- package/dist/bundle/chunks/chunk-AQ4EXORZ.js +14 -0
- package/dist/bundle/chunks/chunk-AZXVJN6E.js +19 -0
- package/dist/bundle/chunks/chunk-CRN54O4D.js +24 -0
- package/dist/bundle/chunks/chunk-CTU2ECLD.js +7 -0
- package/dist/bundle/chunks/{chunk-BQ3TMEWD.js → chunk-EIC7CQX3.js} +4 -3
- package/dist/bundle/chunks/chunk-F6ZAYLU2.js +59 -0
- package/dist/bundle/chunks/chunk-G4QPSFBF.js +493 -0
- package/dist/bundle/chunks/chunk-GME4AWDG.js +23 -0
- package/dist/bundle/chunks/{chunk-SFMDIVZ4.js → chunk-GRJUKEE3.js} +43 -30
- package/dist/bundle/chunks/chunk-GTILMMUF.js +12 -0
- package/dist/bundle/chunks/chunk-GUHNFZ2Q.js +51 -0
- package/dist/bundle/chunks/chunk-GY663MNP.js +11 -0
- package/dist/bundle/chunks/chunk-HTA325LJ.js +56 -0
- package/dist/bundle/chunks/{chunk-5L4JG6PO.js → chunk-I3NDOUHE.js} +8 -7
- package/dist/bundle/chunks/chunk-I5E7RQ5V.js +21 -0
- package/dist/bundle/chunks/chunk-IWZQ25I3.js +5 -0
- package/dist/bundle/chunks/chunk-IYGHKVUG.js +2 -0
- package/dist/bundle/chunks/chunk-J57HOSWD.js +21 -0
- package/dist/bundle/chunks/chunk-JF7FYXAI.js +288 -0
- package/dist/bundle/chunks/chunk-JSZBTGI6.js +10 -0
- package/dist/bundle/chunks/chunk-JYWUOKOI.js +1061 -0
- package/dist/bundle/chunks/{chunk-DLCBSLHW.js → chunk-KRCX3ZBA.js} +1 -1
- package/dist/bundle/chunks/chunk-KTSJYIYC.js +30 -0
- package/dist/bundle/chunks/{chunk-K7SDY3VJ.js → chunk-LB4CIS4F.js} +40 -165
- package/dist/bundle/chunks/{chunk-NN53K2QQ.js → chunk-LYZ37DJP.js} +2 -14
- package/dist/bundle/chunks/chunk-MD7K7RPN.js +20 -0
- package/dist/bundle/chunks/chunk-MX4Q4W6H.js +214 -0
- package/dist/bundle/chunks/{chunk-6PD3T2EF.js → chunk-N2SNMUD3.js} +1 -1
- package/dist/bundle/chunks/chunk-NXA6NEHE.js +54 -0
- package/dist/bundle/chunks/chunk-OB332KMV.js +300 -0
- package/dist/bundle/chunks/chunk-P6AXBESH.js +1883 -0
- package/dist/bundle/chunks/chunk-PPBDDQHP.js +11 -0
- package/dist/bundle/chunks/chunk-PWUDFU5V.js +51 -0
- package/dist/bundle/chunks/chunk-Q5RKNQ2T.js +73 -0
- package/dist/bundle/chunks/chunk-QT6ZHDMP.js +12 -0
- package/dist/bundle/chunks/chunk-R5OOX7RW.js +16 -0
- package/dist/bundle/chunks/chunk-R6YQR7TZ.js +25 -0
- package/dist/bundle/chunks/{chunk-4ZBGTJJM.js → chunk-RNBZBCH2.js} +1 -1
- package/dist/bundle/chunks/chunk-RQU722SY.js +1 -0
- package/dist/bundle/chunks/{chunk-RGUZULEE.js → chunk-RS6PZK35.js} +71 -72
- package/dist/bundle/chunks/{jiti-loader-6P33XTLC.js → chunk-RW7GT7L3.js} +1 -1
- package/dist/bundle/chunks/{chunk-PCTLFSQG.js → chunk-SCINMV4X.js} +1 -1
- package/dist/bundle/chunks/{chunk-NCC2FAJN.js → chunk-SSRCVJZK.js} +28 -28
- package/dist/bundle/chunks/chunk-T5A6T24H.js +93 -0
- package/dist/bundle/chunks/chunk-T7BXP46S.js +3367 -0
- package/dist/bundle/chunks/chunk-TGDPZCSW.js +9 -0
- package/dist/bundle/chunks/{chunk-4J6BGNX2.js → chunk-TWAHPPXN.js} +434 -429
- package/dist/bundle/chunks/chunk-UEW6TUSP.js +36 -0
- package/dist/bundle/chunks/chunk-UZNIPOGS.js +323 -0
- package/dist/bundle/chunks/{chunk-KM4GQ2BU.js → chunk-VFLVWPLZ.js} +5 -6
- package/dist/bundle/chunks/chunk-WAPZN4KP.js +74 -0
- package/dist/bundle/chunks/chunk-WCFHG6NO.js +16 -0
- package/dist/bundle/chunks/chunk-WQ7EJQIT.js +839 -0
- package/dist/bundle/chunks/chunk-WQOOJP7U.js +4 -0
- package/dist/bundle/chunks/chunk-XHDVDJM7.js +17 -0
- package/dist/bundle/chunks/chunk-YPZPCHNV.js +3 -0
- package/dist/bundle/chunks/chunk-Z5YLKK3S.js +41 -0
- package/dist/bundle/chunks/chunk-ZJUU6WOV.js +2052 -0
- package/dist/bundle/chunks/{cli-N7KOVPLB.js → cli-H4LJNE2V.js} +2 -2
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KRMHG2L3.js → cloudflare-workers-ai-system-one-T5R2RVFQ.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +2 -0
- package/dist/bundle/chunks/compat-ZK2DIW3P.js +15 -0
- package/dist/bundle/chunks/dist-EY7YKQHB.js +11 -0
- package/dist/bundle/chunks/dist-FMWWM4H7.js +268 -0
- package/dist/bundle/chunks/dist-NHQTBDHT.js +1107 -0
- package/dist/bundle/chunks/{easter-egg-3d-O2GG2XIG.js → easter-egg-3d-BUEOC3NO.js} +1 -1
- package/dist/bundle/chunks/entry-A2CSLKHC.js +323 -0
- package/dist/bundle/chunks/entry-AL54ZGYO.js +2 -0
- package/dist/bundle/chunks/{execute-LMBACTKA.js → execute-MY5JSEPV.js} +18 -15
- package/dist/bundle/chunks/{extract-CXXLVFC5.js → extract-PTGACPGP.js} +3 -3
- package/dist/bundle/chunks/flow-implementer-APJFY4YI.js +21 -0
- package/dist/bundle/chunks/github-copilot.js +66 -62
- package/dist/bundle/chunks/{google-generative-ai-SBL77OXO.js → google-generative-ai-UL7YEQ6J.js} +2 -3
- package/dist/bundle/chunks/{google-vertex-NZBNNXMK.js → google-vertex-OTMSPUYH.js} +3 -3
- package/dist/bundle/chunks/host-75YAHLDR.js +3 -0
- package/dist/bundle/chunks/index.bundle-THL4EUSU.js +390 -0
- package/dist/bundle/chunks/inprocess-5NP5VJHZ.js +32 -0
- package/dist/bundle/chunks/interactive-mode-IW4PIVAQ.js +5 -0
- package/dist/bundle/chunks/jiti-bun-loader-VSLLRCSD.js +3459 -0
- package/dist/bundle/chunks/jiti-loader-TMJL6S2D.js +2 -0
- package/dist/bundle/chunks/{llama-cpp-classify-PP63BYDF.js → llama-cpp-classify-GJAXULWL.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-DX4YKJSO.js → mistral-conversations-E72Y6OC3.js} +2 -2
- package/dist/bundle/chunks/{node-UGQUSQE6.js → node-ZFIIS5IM.js} +32 -32
- package/dist/bundle/chunks/openai-codex-responses-S7CMCAOY.js +101 -0
- package/dist/bundle/chunks/openai-completions-2Z57N7PC.js +87 -0
- package/dist/bundle/chunks/{openai-decisions-ALJROWBE.js → openai-decisions-JIOJDB4C.js} +1 -1
- package/dist/bundle/chunks/openai-responses-5VBZSTHL.js +27 -0
- package/dist/bundle/chunks/{openrouter-images-FCJT7C7I.js → openrouter-images-S6O7DBEJ.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-NHTQQOPW.js → pi-messages-SMLN5J2W.js} +10 -7
- package/dist/bundle/chunks/runtime-OYTWXIUM.js +2 -0
- package/dist/bundle/chunks/session-picker-DM6S37IF.js +4 -0
- package/dist/bundle/chunks/startup-ui-4GGLWNSU.js +3 -0
- package/dist/bundle/chunks/trace-command-YLDYCL55.js +254 -0
- package/dist/bundle/chunks/typesafe-system-one-7BEL3H5N.js +3 -0
- package/dist/bundle/chunks/virtual-modules-TI3W24YL.js +28 -0
- package/dist/bundle/cli-runtime.js +5 -3
- package/dist/bundle/flow/agents/orch-implementation-fast.md +4 -4
- package/dist/bundle/flow/agents/orch-implementation-strong.md +5 -5
- package/dist/bundle/flow/package.json +35 -3
- package/dist/bundle/index.js +20 -17
- package/dist/bundle/orchestrate/README.md +37 -0
- package/dist/bundle/{flow → orchestrate}/agents/orch-qa-agent.md +1 -1
- package/dist/bundle/{flow → orchestrate}/agents/orch-worker.md +1 -1
- package/dist/bundle/{flow → orchestrate}/agents/orchestrator-lead.md +1 -1
- package/dist/bundle/orchestrate/package.json +29 -0
- package/dist/bundle/rpc-entry.js +5 -3
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +69 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +3 -2
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +4 -3
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts +2 -0
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +6 -6
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/metadata-disclosure.d.ts +4 -0
- package/dist/cli/metadata-disclosure.d.ts.map +1 -0
- package/dist/cli/metadata-disclosure.js +23 -0
- package/dist/cli/metadata-disclosure.js.map +1 -0
- package/dist/cli/project-trust.d.ts.map +1 -1
- package/dist/cli/project-trust.js +4 -1
- package/dist/cli/project-trust.js.map +1 -1
- package/dist/cli/session-picker.lazy.d.ts +3 -0
- package/dist/cli/session-picker.lazy.d.ts.map +1 -0
- package/dist/cli/session-picker.lazy.js +3 -0
- package/dist/cli/session-picker.lazy.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +4 -4
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +38 -14
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli/startup-ui.lazy.d.ts +3 -0
- package/dist/cli/startup-ui.lazy.d.ts.map +1 -0
- package/dist/cli/startup-ui.lazy.js +3 -0
- package/dist/cli/startup-ui.lazy.js.map +1 -0
- package/dist/cli/trace-command.lazy.d.ts +3 -0
- package/dist/cli/trace-command.lazy.d.ts.map +1 -0
- package/dist/cli/trace-command.lazy.js +3 -0
- package/dist/cli/trace-command.lazy.js.map +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/coordination/broker/entry.lazy.d.ts +3 -0
- package/dist/coordination/broker/entry.lazy.d.ts.map +1 -0
- package/dist/coordination/broker/entry.lazy.js +3 -0
- package/dist/coordination/broker/entry.lazy.js.map +1 -0
- package/dist/core/acceptance-command.d.ts +15 -0
- package/dist/core/acceptance-command.d.ts.map +1 -0
- package/dist/core/acceptance-command.js +150 -0
- package/dist/core/acceptance-command.js.map +1 -0
- package/dist/core/acceptance-ledger.d.ts +52 -0
- package/dist/core/acceptance-ledger.d.ts.map +1 -0
- package/dist/core/acceptance-ledger.js +341 -0
- package/dist/core/acceptance-ledger.js.map +1 -0
- package/dist/core/admission-types.d.ts +69 -0
- package/dist/core/admission-types.js +2 -0
- package/dist/core/admission-types.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +7 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +43 -9
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +8 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +13 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +127 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1390 -145
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
- package/dist/core/anthropic-subscription-usage.js +31 -3
- package/dist/core/anthropic-subscription-usage.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -10
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/auto-session-namer.d.ts.map +1 -1
- package/dist/core/auto-session-namer.js +3 -1
- package/dist/core/auto-session-namer.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +3 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bug-report-redaction.d.ts +4 -0
- package/dist/core/bug-report-redaction.d.ts.map +1 -0
- package/dist/core/bug-report-redaction.js +209 -0
- package/dist/core/bug-report-redaction.js.map +1 -0
- package/dist/core/bug-report.d.ts +26 -6
- package/dist/core/bug-report.d.ts.map +1 -1
- package/dist/core/bug-report.js +82 -9
- package/dist/core/bug-report.js.map +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +5 -0
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +6 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +103 -71
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +2 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/extensions/jiti-bun-babel.d.ts +4 -0
- package/dist/core/extensions/jiti-bun-babel.d.ts.map +1 -0
- package/dist/core/extensions/jiti-bun-babel.js +4 -0
- package/dist/core/extensions/jiti-bun-babel.js.map +1 -0
- package/dist/core/extensions/jiti-bun-loader.d.ts +4 -0
- package/dist/core/extensions/jiti-bun-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-bun-loader.js +13 -0
- package/dist/core/extensions/jiti-bun-loader.js.map +1 -0
- package/dist/core/extensions/jiti-bun-loader.lazy.d.ts +3 -0
- package/dist/core/extensions/jiti-bun-loader.lazy.d.ts.map +1 -0
- package/dist/core/extensions/jiti-bun-loader.lazy.js +3 -0
- package/dist/core/extensions/jiti-bun-loader.lazy.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +9 -3
- 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 +4 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -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 +25 -0
- package/dist/core/flow-implementer.d.ts.map +1 -0
- package/dist/core/flow-implementer.js +301 -0
- package/dist/core/flow-implementer.js.map +1 -0
- package/dist/core/internal-process.d.ts +23 -0
- package/dist/core/internal-process.d.ts.map +1 -0
- package/dist/core/internal-process.js +88 -0
- package/dist/core/internal-process.js.map +1 -0
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +52 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +4 -4
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-request-admission.d.ts +51 -0
- package/dist/core/model-request-admission.d.ts.map +1 -0
- package/dist/core/model-request-admission.js +103 -0
- package/dist/core/model-request-admission.js.map +1 -0
- package/dist/core/model-resolver.d.ts +4 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +109 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +56 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +482 -40
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/model-selection-intent.d.ts +14 -0
- package/dist/core/model-selection-intent.d.ts.map +1 -0
- package/dist/core/model-selection-intent.js +15 -0
- package/dist/core/model-selection-intent.js.map +1 -0
- package/dist/core/oauth-account-pool.d.ts +4 -1
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +251 -228
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/os-secret-store.d.ts +25 -0
- package/dist/core/os-secret-store.d.ts.map +1 -0
- package/dist/core/os-secret-store.js +290 -0
- package/dist/core/os-secret-store.js.map +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +62 -2
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +4 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -1
- package/dist/core/private-windows-path.d.ts +4 -0
- package/dist/core/private-windows-path.d.ts.map +1 -0
- package/dist/core/private-windows-path.js +44 -0
- package/dist/core/private-windows-path.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -1
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +6 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-outcome.d.ts +40 -0
- package/dist/core/run-outcome.d.ts.map +1 -0
- package/dist/core/run-outcome.js +91 -0
- package/dist/core/run-outcome.js.map +1 -0
- package/dist/core/run-preflight.d.ts +5 -0
- package/dist/core/run-preflight.d.ts.map +1 -0
- package/dist/core/run-preflight.js +96 -0
- package/dist/core/run-preflight.js.map +1 -0
- package/dist/core/runtime-credentials.d.ts +18 -2
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +65 -9
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +19 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +115 -20
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +2 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +2 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +15 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +114 -22
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +7 -2
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +12 -5
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +11 -0
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash-jobs.d.ts +109 -0
- package/dist/core/tools/bash-jobs.d.ts.map +1 -0
- package/dist/core/tools/bash-jobs.js +563 -0
- package/dist/core/tools/bash-jobs.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -6
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +350 -37
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +11 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +89 -20
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +15 -7
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-custody.d.ts +29 -0
- package/dist/core/tools/file-mutation-custody.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-custody.js +173 -0
- package/dist/core/tools/file-mutation-custody.js.map +1 -0
- package/dist/core/tools/find.d.ts +6 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +84 -38
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +8 -2
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +121 -77
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +3 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +12 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/jobs.d.ts +24 -0
- package/dist/core/tools/jobs.d.ts.map +1 -0
- package/dist/core/tools/jobs.js +86 -0
- package/dist/core/tools/jobs.js.map +1 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +2 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +12 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +88 -8
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/output-cleanup.d.ts +40 -0
- package/dist/core/tools/output-cleanup.d.ts.map +1 -0
- package/dist/core/tools/output-cleanup.js +273 -0
- package/dist/core/tools/output-cleanup.js.map +1 -0
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +15 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read.d.ts +21 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +162 -29
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +3 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js +1 -0
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/subagent.d.ts +5 -1
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +76 -19
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +4 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +24 -1
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +6 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trace/config.js +3 -3
- package/dist/core/trace/config.js.map +1 -1
- package/dist/core/trace/redaction.d.ts.map +1 -1
- package/dist/core/trace/redaction.js +12 -9
- package/dist/core/trace/redaction.js.map +1 -1
- package/dist/core/trace-client/credential-store.d.ts +1 -1
- package/dist/core/trace-client/credential-store.d.ts.map +1 -1
- package/dist/core/trace-client/credential-store.js +20 -3
- package/dist/core/trace-client/credential-store.js.map +1 -1
- package/dist/core/usage-ledger.d.ts +35 -0
- package/dist/core/usage-ledger.d.ts.map +1 -0
- package/dist/core/usage-ledger.js +140 -0
- package/dist/core/usage-ledger.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +24 -15
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts +4 -2
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +8 -4
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +4 -2
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +34 -12
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +23 -2
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +15 -3
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +3 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +18 -6
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/extensions/usage/hcode-overview.d.ts +23 -0
- package/dist/extensions/usage/hcode-overview.d.ts.map +1 -0
- package/dist/extensions/usage/hcode-overview.js +109 -0
- package/dist/extensions/usage/hcode-overview.js.map +1 -0
- package/dist/extensions/usage/index.d.ts +5 -0
- package/dist/extensions/usage/index.d.ts.map +1 -1
- package/dist/extensions/usage/index.js +194 -12
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/extensions/usage/overview.d.ts +5 -0
- package/dist/extensions/usage/overview.d.ts.map +1 -1
- package/dist/extensions/usage/overview.js +21 -1
- package/dist/extensions/usage/overview.js.map +1 -1
- package/dist/extensions/usage/popup.d.ts +14 -3
- package/dist/extensions/usage/popup.d.ts.map +1 -1
- package/dist/extensions/usage/popup.js +199 -25
- package/dist/extensions/usage/popup.js.map +1 -1
- package/dist/humain/adaptive-execution.d.ts +51 -0
- package/dist/humain/adaptive-execution.d.ts.map +1 -0
- package/dist/humain/adaptive-execution.js +100 -0
- package/dist/humain/adaptive-execution.js.map +1 -0
- package/dist/humain/adaptive-peer-process.d.ts +44 -0
- package/dist/humain/adaptive-peer-process.d.ts.map +1 -0
- package/dist/humain/adaptive-peer-process.js +159 -0
- package/dist/humain/adaptive-peer-process.js.map +1 -0
- package/dist/humain/adaptive-peer-worker.d.ts +3 -0
- package/dist/humain/adaptive-peer-worker.d.ts.map +1 -0
- package/dist/humain/adaptive-peer-worker.js +122 -0
- package/dist/humain/adaptive-peer-worker.js.map +1 -0
- package/dist/humain/adaptive-runtime-types.d.ts +621 -0
- package/dist/humain/adaptive-runtime-types.d.ts.map +1 -0
- package/dist/humain/adaptive-runtime-types.js +3 -0
- package/dist/humain/adaptive-runtime-types.js.map +1 -0
- package/dist/humain/adaptive-session-host.d.ts +113 -0
- package/dist/humain/adaptive-session-host.d.ts.map +1 -0
- package/dist/humain/adaptive-session-host.js +1838 -0
- package/dist/humain/adaptive-session-host.js.map +1 -0
- package/dist/humain/adhd/index.d.ts +2 -2
- package/dist/humain/adhd/index.d.ts.map +1 -1
- package/dist/humain/adhd/index.js +22 -13
- package/dist/humain/adhd/index.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +162 -49
- package/dist/humain/caveman/index.d.ts +1 -1
- package/dist/humain/caveman/index.d.ts.map +1 -1
- package/dist/humain/caveman/index.js +21 -12
- package/dist/humain/caveman/index.js.map +1 -1
- package/dist/humain/classify-tool.d.ts +4 -0
- package/dist/humain/classify-tool.d.ts.map +1 -0
- package/dist/humain/classify-tool.js +50 -0
- package/dist/humain/classify-tool.js.map +1 -0
- package/dist/humain/flow-command.d.ts +1 -1
- package/dist/humain/flow-command.d.ts.map +1 -1
- package/dist/humain/flow-command.js +21 -3
- package/dist/humain/flow-command.js.map +1 -1
- package/dist/humain/flow-loader.d.ts +15 -10
- package/dist/humain/flow-loader.d.ts.map +1 -1
- package/dist/humain/flow-loader.js +72 -18
- package/dist/humain/flow-loader.js.map +1 -1
- package/dist/humain/fuse-provider.d.ts +5 -0
- package/dist/humain/fuse-provider.d.ts.map +1 -0
- package/dist/humain/fuse-provider.js +302 -0
- package/dist/humain/fuse-provider.js.map +1 -0
- package/dist/humain/gateway/provider.d.ts.map +1 -1
- package/dist/humain/gateway/provider.js +2 -0
- package/dist/humain/gateway/provider.js.map +1 -1
- package/dist/humain/gateway/secret-store.d.ts +3 -7
- package/dist/humain/gateway/secret-store.d.ts.map +1 -1
- package/dist/humain/gateway/secret-store.js +21 -249
- package/dist/humain/gateway/secret-store.js.map +1 -1
- package/dist/humain/hcode/account-store.d.ts +92 -0
- package/dist/humain/hcode/account-store.d.ts.map +1 -0
- package/dist/humain/hcode/account-store.js +720 -0
- package/dist/humain/hcode/account-store.js.map +1 -0
- package/dist/humain/hcode/account.d.ts +42 -0
- package/dist/humain/hcode/account.d.ts.map +1 -0
- package/dist/humain/hcode/account.js +552 -0
- package/dist/humain/hcode/account.js.map +1 -0
- package/dist/humain/hcode/catalog.d.ts +6 -0
- package/dist/humain/hcode/catalog.d.ts.map +1 -0
- package/dist/humain/hcode/catalog.js +47 -0
- package/dist/humain/hcode/catalog.js.map +1 -0
- package/dist/humain/hcode/contracts.d.ts +389 -0
- package/dist/humain/hcode/contracts.d.ts.map +1 -0
- package/dist/humain/hcode/contracts.js +1243 -0
- package/dist/humain/hcode/contracts.js.map +1 -0
- package/dist/humain/hcode/environment.d.ts +9 -0
- package/dist/humain/hcode/environment.d.ts.map +1 -0
- package/dist/humain/hcode/environment.js +24 -0
- package/dist/humain/hcode/environment.js.map +1 -0
- package/dist/humain/hcode/facade.d.ts +54 -0
- package/dist/humain/hcode/facade.d.ts.map +1 -0
- package/dist/humain/hcode/facade.js +326 -0
- package/dist/humain/hcode/facade.js.map +1 -0
- package/dist/humain/hcode/http.d.ts +10 -0
- package/dist/humain/hcode/http.d.ts.map +1 -0
- package/dist/humain/hcode/http.js +119 -0
- package/dist/humain/hcode/http.js.map +1 -0
- package/dist/humain/hcode/notices.d.ts +15 -0
- package/dist/humain/hcode/notices.d.ts.map +1 -0
- package/dist/humain/hcode/notices.js +69 -0
- package/dist/humain/hcode/notices.js.map +1 -0
- package/dist/humain/hcode/ports.d.ts +34 -0
- package/dist/humain/hcode/ports.d.ts.map +1 -0
- package/dist/humain/hcode/ports.js +2 -0
- package/dist/humain/hcode/ports.js.map +1 -0
- package/dist/humain/hcode/provider.d.ts +15 -0
- package/dist/humain/hcode/provider.d.ts.map +1 -0
- package/dist/humain/hcode/provider.js +200 -0
- package/dist/humain/hcode/provider.js.map +1 -0
- package/dist/humain/hcode/selection.d.ts +16 -0
- package/dist/humain/hcode/selection.d.ts.map +1 -0
- package/dist/humain/hcode/selection.js +37 -0
- package/dist/humain/hcode/selection.js.map +1 -0
- package/dist/humain/hcode/transport.d.ts +22 -0
- package/dist/humain/hcode/transport.d.ts.map +1 -0
- package/dist/humain/hcode/transport.js +368 -0
- package/dist/humain/hcode/transport.js.map +1 -0
- package/dist/humain/hcode/usage.d.ts +5 -0
- package/dist/humain/hcode/usage.d.ts.map +1 -0
- package/dist/humain/hcode/usage.js +66 -0
- package/dist/humain/hcode/usage.js.map +1 -0
- package/dist/humain/hcode/wire.d.ts +16 -0
- package/dist/humain/hcode/wire.d.ts.map +1 -0
- package/dist/humain/hcode/wire.js +104 -0
- package/dist/humain/hcode/wire.js.map +1 -0
- package/dist/humain/index.d.ts +1 -3
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +8 -60
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/login-menu.d.ts.map +1 -1
- package/dist/humain/login-menu.js +8 -1
- package/dist/humain/login-menu.js.map +1 -1
- package/dist/humain/metadata/contracts.d.ts +82 -0
- package/dist/humain/metadata/contracts.d.ts.map +1 -0
- package/dist/humain/metadata/contracts.js +214 -0
- package/dist/humain/metadata/contracts.js.map +1 -0
- package/dist/humain/metadata/identity.d.ts +10 -0
- package/dist/humain/metadata/identity.d.ts.map +1 -0
- package/dist/humain/metadata/identity.js +209 -0
- package/dist/humain/metadata/identity.js.map +1 -0
- package/dist/humain/metadata/index.d.ts +41 -0
- package/dist/humain/metadata/index.d.ts.map +1 -0
- package/dist/humain/metadata/index.js +100 -0
- package/dist/humain/metadata/index.js.map +1 -0
- package/dist/humain/metadata/sender.d.ts +20 -0
- package/dist/humain/metadata/sender.d.ts.map +1 -0
- package/dist/humain/metadata/sender.js +302 -0
- package/dist/humain/metadata/sender.js.map +1 -0
- package/dist/humain/metadata/version.d.ts +8 -0
- package/dist/humain/metadata/version.d.ts.map +1 -0
- package/dist/humain/metadata/version.js +38 -0
- package/dist/humain/metadata/version.js.map +1 -0
- package/dist/humain/node-http.d.ts +2 -0
- package/dist/humain/node-http.d.ts.map +1 -1
- package/dist/humain/node-http.js +9 -4
- package/dist/humain/node-http.js.map +1 -1
- package/dist/humain/node-provider.d.ts +2 -0
- package/dist/humain/node-provider.d.ts.map +1 -1
- package/dist/humain/node-provider.js +39 -8
- package/dist/humain/node-provider.js.map +1 -1
- package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts +1 -1
- package/dist/humain/ponytail/vendor/hooks/ponytail-config.d.ts.map +1 -1
- package/dist/humain/ponytail/vendor/hooks/ponytail-config.js +4 -4
- package/dist/humain/ponytail/vendor/hooks/ponytail-config.js.map +1 -1
- package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.d.ts.map +1 -1
- package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js +7 -0
- package/dist/humain/ponytail/vendor/hooks/ponytail-instructions.js.map +1 -1
- package/dist/humain/ponytail/vendor/pi-extension/index.d.ts.map +1 -1
- package/dist/humain/ponytail/vendor/pi-extension/index.js +12 -1
- package/dist/humain/ponytail/vendor/pi-extension/index.js.map +1 -1
- package/dist/humain/systemone.d.ts +23 -0
- package/dist/humain/systemone.d.ts.map +1 -0
- package/dist/humain/systemone.js +101 -0
- package/dist/humain/systemone.js.map +1 -0
- package/dist/humain/trace-capture/flow-producer.d.ts.map +1 -1
- package/dist/humain/trace-capture/flow-producer.js +3 -3
- package/dist/humain/trace-capture/flow-producer.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +292 -183
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts.map +1 -1
- package/dist/modes/interactive/bug-report.js +82 -36
- package/dist/modes/interactive/bug-report.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +8 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js +11 -5
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +9 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +10 -5
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +55 -29
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +16 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +164 -19
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +3 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +19 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +17 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +78 -1
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +19 -10
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +353 -65
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.lazy.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.lazy.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.lazy.js +3 -0
- package/dist/modes/interactive/interactive-mode.lazy.js.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts +2 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.js +12 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +2 -3
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +4 -5
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +4 -4
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +8 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +2 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.d.ts +4 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +57 -11
- 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 +68 -16
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +7 -5
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +3 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/lazy-validator.d.ts +5 -0
- package/dist/utils/lazy-validator.d.ts.map +1 -0
- package/dist/utils/lazy-validator.js +7 -0
- package/dist/utils/lazy-validator.js.map +1 -0
- package/dist/utils/shell.d.ts +3 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +9 -4
- package/dist/utils/shell.js.map +1 -1
- package/docs/cli.md +23 -5
- package/docs/codemode.md +21 -1
- package/docs/development.md +18 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +4 -0
- package/docs/flow.md +115 -16
- package/docs/headless-modes.md +61 -0
- package/docs/humain-code-forge-architecture.md +65 -13
- package/docs/humain-code-forge-component-scorecard.md +10 -1
- package/docs/humain-code-forge-flow-walkthrough.md +54 -55
- package/docs/humain-code.md +22 -19
- package/docs/index.md +1 -0
- package/docs/keybindings.md +1 -1
- package/docs/models-configuration.md +6 -1
- package/docs/models.md +1 -1
- package/docs/prompt-templates.md +1 -1
- package/docs/providers.md +67 -15
- package/docs/run-preflight.md +47 -0
- package/docs/sdk.md +39 -1
- package/docs/security.md +1 -1
- package/docs/settings.md +12 -5
- package/docs/skills.md +2 -0
- package/docs/slash-commands.md +5 -3
- package/docs/usage.md +29 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/tsconfig.json +13 -0
- package/npm-shrinkwrap.json +67 -67
- package/package.json +25 -19
- package/schemas/models.schema.json +30 -0
- package/schemas/settings.schema.json +28 -9
- package/src/humain/caveman/UPSTREAM.md +19 -3
- package/src/humain/caveman/upstream.json +2 -2
- package/src/humain/ponytail/UPSTREAM.md +16 -1
- package/src/humain/web-access/UPSTREAM.md +10 -0
- package/src/humain/web-access/upstream.json +1 -0
- package/dist/bundle/chunks/anthropic-messages-MNISFDZA.js +0 -66
- package/dist/bundle/chunks/chunk-2HZ2V3HS.js +0 -1985
- package/dist/bundle/chunks/chunk-2PZ46FSM.js +0 -6
- package/dist/bundle/chunks/chunk-4SQUP6IR.js +0 -88
- package/dist/bundle/chunks/chunk-5JSLXC2A.js +0 -3
- package/dist/bundle/chunks/chunk-75CQYZ63.js +0 -1336
- package/dist/bundle/chunks/chunk-DCPACGLH.js +0 -12267
- package/dist/bundle/chunks/chunk-FLVBQ6GS.js +0 -24
- package/dist/bundle/chunks/chunk-H7Y4QY7K.js +0 -11
- package/dist/bundle/chunks/chunk-JEAM6N22.js +0 -139
- package/dist/bundle/chunks/chunk-PS2FJ7M4.js +0 -23
- package/dist/bundle/chunks/chunk-TEOMXMW6.js +0 -23
- package/dist/bundle/chunks/chunk-WEFEQEIQ.js +0 -28
- package/dist/bundle/chunks/chunk-WW4SILXG.js +0 -249
- package/dist/bundle/chunks/compat-MXAZPYDN.js +0 -13
- package/dist/bundle/chunks/dist-3V7ZSLER.js +0 -3166
- package/dist/bundle/chunks/dist-66CW64M2.js +0 -8
- package/dist/bundle/chunks/host-SCZ4IKWR.js +0 -2
- package/dist/bundle/chunks/openai-codex-responses-LZWBQYVP.js +0 -101
- package/dist/bundle/chunks/openai-completions-7NWH423P.js +0 -82
- package/dist/bundle/chunks/openai-responses-5YOLHMCF.js +0 -27
- package/dist/bundle/chunks/runtime-UVPDE4CX.js +0 -2
- package/dist/bundle/chunks/typesafe-system-one-BHJYAZ6E.js +0 -3
- package/dist/bundle/chunks/virtual-modules-YQPK57CW.js +0 -23
- package/dist/humain/legacy-workflow-tiers.d.ts +0 -3
- package/dist/humain/legacy-workflow-tiers.d.ts.map +0 -1
- package/dist/humain/legacy-workflow-tiers.js +0 -46
- package/dist/humain/legacy-workflow-tiers.js.map +0 -1
- /package/dist/bundle/{flow → orchestrate}/agents/orch-architect.md +0 -0
- /package/dist/bundle/{flow → orchestrate}/agents/orch-scout.md +0 -0
- /package/dist/bundle/{flow → orchestrate}/agents/orch-security-review.md +0 -0
- /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-lead.md +0 -0
- /package/dist/bundle/{flow → orchestrate}/agents/orch-technical-review.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import { clampThinkingLevel, commitLoginCredential, createModels, defaultProviderAuthContext, drainStream, getOpenCodeSessionHeaders, lazyStream, ModelsError, normalizeContext, streamWithProgressTimeout, } from "@earendil-works/pi-ai";
|
|
3
|
+
import { clampThinkingLevel, commitLoginCredential, createModels, defaultProviderAuthContext, drainStream, getOpenCodeSessionHeaders, getSupportedThinkingLevels, isModelType, lazyStream, ModelsError, normalizeContext, SubmissionAdmissionError, streamWithProgressTimeout, } from "@earendil-works/pi-ai";
|
|
4
4
|
import { findEnvKeys } from "@earendil-works/pi-ai/compat";
|
|
5
5
|
import * as builtinProviderCatalog from "@earendil-works/pi-ai/providers/all";
|
|
6
6
|
import { getModelListing, setModelListing } from "@earendil-works/pi-ai/providers/model-listing";
|
|
@@ -8,12 +8,19 @@ import { personalizeOpenRouterCatalog } from "@earendil-works/pi-ai/providers/op
|
|
|
8
8
|
import { assertChatModel, assertClassifierInputSupported, assertClassifierModel, assertImageModel, classifierErrorResult, imageErrorResult, } from "@earendil-works/pi-ai/utils/model-operations";
|
|
9
9
|
import { getAgentDir } from "../config.js";
|
|
10
10
|
import { describeGatewayCredential, HUMAIN_GATEWAY_PROVIDER } from "../humain/gateway/constants.js";
|
|
11
|
+
import { resolveHcodeEnvironment } from "../humain/hcode/environment.js";
|
|
12
|
+
import { createHcodeFacade, referenceFromCredential, } from "../humain/hcode/facade.js";
|
|
13
|
+
import { HCODE_PROVIDER } from "../humain/hcode/http.js";
|
|
14
|
+
import { hcodeReferenceCredential } from "../humain/hcode/provider.js";
|
|
15
|
+
import { HCODE_UNSUPPORTED_THINKING_MESSAGE } from "../humain/hcode/selection.js";
|
|
11
16
|
import { FileNodeAccountMetadataStore, InMemoryNodeAccountMetadataStore, } from "../humain/node-account-fallback.js";
|
|
17
|
+
import { hasHumainNodeAdmissionTransport } from "../humain/node-provider.js";
|
|
12
18
|
import { operationSignal, raceWithAbortSignal } from "../utils/abort.js";
|
|
13
19
|
import { ANTHROPIC_PROVIDER_ID, AnthropicRateLimitStore, isOfficialAnthropicBaseUrl, parseAnthropicRateLimits, } from "./anthropic-account-reporting.js";
|
|
14
20
|
import { AccountSourceReplacementError, AuthStorage as DefaultAuthStorage } from "./auth-storage.js";
|
|
15
21
|
import { filterBedrockCatalog } from "./model-catalog-filter.js";
|
|
16
22
|
import { ModelConfig } from "./model-config.js";
|
|
23
|
+
import { admissionIntent, assertAdmittedModelInput, reconcileAdmittedUsage, submissionAdmission, } from "./model-request-admission.js";
|
|
17
24
|
import { FileModelsStore, InMemoryCodingAgentModelsStore } from "./models-store.js";
|
|
18
25
|
import { OAUTH_ACCOUNT_IDENTITY_FIELDS, OAuthAccountPool, sameCredential, } from "./oauth-account-pool.js";
|
|
19
26
|
import { composeModelProvider, configuredRequestAuthStatus, resolveCompatibilityRequestConfig, resolveConfiguredModelHeaders, validateExtensionProvider, } from "./provider-composer.js";
|
|
@@ -78,7 +85,11 @@ class LoginCancellationError extends Error {
|
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
/** Providers whose origin, headers and models are fixed; overlays would bypass their request safeguards. */
|
|
81
|
-
const OVERLAY_REJECTING_PROVIDERS = new Set([HUMAIN_GATEWAY_PROVIDER]);
|
|
88
|
+
const OVERLAY_REJECTING_PROVIDERS = new Set([HUMAIN_GATEWAY_PROVIDER, HCODE_PROVIDER]);
|
|
89
|
+
function assertCustomProviderId(providerId) {
|
|
90
|
+
if (providerId === HCODE_PROVIDER)
|
|
91
|
+
throw new Error("HUMAIN Code account does not accept custom registration or API keys.");
|
|
92
|
+
}
|
|
82
93
|
function rejectsConfigOverlays(providerId) {
|
|
83
94
|
return OVERLAY_REJECTING_PROVIDERS.has(providerId);
|
|
84
95
|
}
|
|
@@ -124,10 +135,14 @@ function swallow(fn) {
|
|
|
124
135
|
*/
|
|
125
136
|
class RequestTracker {
|
|
126
137
|
scope;
|
|
138
|
+
admission;
|
|
139
|
+
model;
|
|
127
140
|
latest;
|
|
128
141
|
settled = false;
|
|
129
|
-
constructor(scope) {
|
|
142
|
+
constructor(scope, model, admission) {
|
|
130
143
|
this.scope = scope;
|
|
144
|
+
this.admission = admission;
|
|
145
|
+
this.model = model;
|
|
131
146
|
}
|
|
132
147
|
/** Wraps a caller `onRequest` so the observer sees the same submissions. */
|
|
133
148
|
hook(caller) {
|
|
@@ -143,7 +158,7 @@ class RequestTracker {
|
|
|
143
158
|
model: value.model,
|
|
144
159
|
};
|
|
145
160
|
try {
|
|
146
|
-
await this.scope
|
|
161
|
+
await this.scope?.observer.onRequest(value, this.scope.purpose);
|
|
147
162
|
}
|
|
148
163
|
catch {
|
|
149
164
|
// Observation is best effort.
|
|
@@ -173,14 +188,17 @@ class RequestTracker {
|
|
|
173
188
|
if (this.settled)
|
|
174
189
|
return;
|
|
175
190
|
this.settled = true;
|
|
176
|
-
if (this.latest)
|
|
191
|
+
if (this.latest) {
|
|
192
|
+
if (this.admission)
|
|
193
|
+
reconcileAdmittedUsage(this.admission, this.latest, outcome.usage, this.model);
|
|
177
194
|
this.report(this.latest, outcome, false);
|
|
178
|
-
|
|
179
|
-
|
|
195
|
+
}
|
|
196
|
+
else if (this.scope)
|
|
197
|
+
swallow(() => this.scope?.observer.onUnattributed?.());
|
|
180
198
|
}
|
|
181
199
|
report(submission, outcome, superseded) {
|
|
182
200
|
const response = {
|
|
183
|
-
purpose: this.scope
|
|
201
|
+
purpose: this.scope?.purpose,
|
|
184
202
|
requestId: submission.requestId,
|
|
185
203
|
submissionId: submission.submissionId,
|
|
186
204
|
submissionNumber: submission.submissionNumber,
|
|
@@ -191,13 +209,21 @@ class RequestTracker {
|
|
|
191
209
|
...outcome,
|
|
192
210
|
superseded,
|
|
193
211
|
};
|
|
194
|
-
swallow(() => this.scope
|
|
212
|
+
swallow(() => this.scope?.observer.onResponse(response));
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
215
|
/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */
|
|
198
216
|
export class ModelRuntime {
|
|
199
217
|
models;
|
|
218
|
+
hcodeFacade;
|
|
219
|
+
sessionOwned;
|
|
220
|
+
hcodeSession;
|
|
221
|
+
/** Shared token-free account/usage facet, independent of the selected model. */
|
|
222
|
+
hcode;
|
|
223
|
+
/** Scalar-only observation bridge; no account, raw enqueue, identity, or flush API. */
|
|
224
|
+
metadata;
|
|
200
225
|
credentials;
|
|
226
|
+
configurationGuard;
|
|
201
227
|
oauthAccountPool;
|
|
202
228
|
/** Secret-free HUMAIN Node fallback policy and user labels; keys stay in the credential pool. */
|
|
203
229
|
nodeAccountMetadata;
|
|
@@ -226,11 +252,25 @@ export class ModelRuntime {
|
|
|
226
252
|
availabilityError;
|
|
227
253
|
credentialOperations = new Map();
|
|
228
254
|
oauthAccountObserver = new AsyncLocalStorage();
|
|
255
|
+
resolvedRequestAuth = new AsyncLocalStorage();
|
|
229
256
|
requestScope = new AsyncLocalStorage();
|
|
257
|
+
admissionScope = new AsyncLocalStorage();
|
|
258
|
+
activeAdmissions = new Set();
|
|
230
259
|
/** Observers of sessions that own this runtime; they attribute direct calls made outside any request scope. */
|
|
231
260
|
ownerObservers = new Set();
|
|
232
|
-
constructor(credentials, oauthAccountPool, nodeAccountMetadata, config, modelsPath, modelsStore, providers, modelNetworkEnabled) {
|
|
261
|
+
constructor(credentials, oauthAccountPool, nodeAccountMetadata, config, modelsPath, modelsStore, providers, modelNetworkEnabled, hcodeFacade, sessionOwned, configurationGuard) {
|
|
262
|
+
this.hcodeFacade = hcodeFacade;
|
|
263
|
+
this.hcode = hcodeFacade.context;
|
|
264
|
+
this.metadata = {
|
|
265
|
+
feature: (...args) => swallow(() => hcodeFacade.metadata.feature(...args)),
|
|
266
|
+
tool: (...args) => swallow(() => hcodeFacade.metadata.tool(...args)),
|
|
267
|
+
inference: (...args) => swallow(() => hcodeFacade.metadata.inference(...args)),
|
|
268
|
+
failure: (...args) => swallow(() => hcodeFacade.metadata.failure(...args)),
|
|
269
|
+
};
|
|
270
|
+
this.sessionOwned = sessionOwned;
|
|
233
271
|
this.credentials = credentials;
|
|
272
|
+
this.configurationGuard = configurationGuard;
|
|
273
|
+
this.assertConfiguration(config);
|
|
234
274
|
this.oauthAccountPool = oauthAccountPool;
|
|
235
275
|
this.nodeAccountMetadata = nodeAccountMetadata;
|
|
236
276
|
this.config = config;
|
|
@@ -243,7 +283,10 @@ export class ModelRuntime {
|
|
|
243
283
|
this.rebuildProviders();
|
|
244
284
|
}
|
|
245
285
|
static async create(options = {}) {
|
|
246
|
-
const
|
|
286
|
+
const environment = resolveHcodeEnvironment(options.hcode?.environment);
|
|
287
|
+
if (options.hcode?.profile && options.hcode.profile.environmentId !== environment.id)
|
|
288
|
+
throw new Error("HUMAIN Code account environment conflicts with the requested environment.");
|
|
289
|
+
const credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath), environment.id, options.configurationGuard);
|
|
247
290
|
const oauthAccountPool = options.oauthAccountPool ??
|
|
248
291
|
(options.credentials
|
|
249
292
|
? OAuthAccountPool.inMemory(credentials.accountStore)
|
|
@@ -281,7 +324,33 @@ export class ModelRuntime {
|
|
|
281
324
|
return listing && { entries: filterBedrockCatalog(listing.entries), models: filtered.getModels };
|
|
282
325
|
});
|
|
283
326
|
});
|
|
284
|
-
const
|
|
327
|
+
const hcodeFacade = createHcodeFacade({
|
|
328
|
+
...options.hcode,
|
|
329
|
+
publication: {
|
|
330
|
+
// A durable decision must reject I/O failure, not use AuthStorage's signal-free cached-read fallback.
|
|
331
|
+
read: async (signal) => referenceFromCredential(await credentials.readStored(HCODE_PROVIDER, { signal: operationSignal(signal) })),
|
|
332
|
+
clear: async (expected, signal) => {
|
|
333
|
+
await credentials.deleteStored(HCODE_PROVIDER, {
|
|
334
|
+
signal,
|
|
335
|
+
ifCurrent: (current) => expected !== null && sameCredential(current, hcodeReferenceCredential(expected)),
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
}, await credentials.readStored(HCODE_PROVIDER, { signal: options.signal }));
|
|
340
|
+
// Trusted builtin installation bypasses no custom registration guard and survives reconstruction.
|
|
341
|
+
providers.push(hcodeFacade.provider);
|
|
342
|
+
const runtime = new ModelRuntime(credentials, oauthAccountPool, nodeAccountMetadata, config, modelsPath, modelsStore, providers, process.env.PI_OFFLINE === undefined, hcodeFacade, options.sessionOwned === true, options.configurationGuard);
|
|
343
|
+
// The public account port must use the same CAS publisher as runtime/provider login.
|
|
344
|
+
hcodeFacade.context.account.login = async (interaction, signal) => {
|
|
345
|
+
const credential = await runtime.login(HCODE_PROVIDER, "api_key", {
|
|
346
|
+
...interaction,
|
|
347
|
+
signal: interaction.signal ? AbortSignal.any([interaction.signal, signal]) : signal,
|
|
348
|
+
});
|
|
349
|
+
const reference = referenceFromCredential(credential);
|
|
350
|
+
if (!reference)
|
|
351
|
+
throw new ModelsError("auth", "HUMAIN Code account changed.");
|
|
352
|
+
return reference;
|
|
353
|
+
};
|
|
285
354
|
runtime.configureRadiusProviders();
|
|
286
355
|
runtime.rebuildProviders();
|
|
287
356
|
const refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;
|
|
@@ -294,20 +363,40 @@ export class ModelRuntime {
|
|
|
294
363
|
: options.signal;
|
|
295
364
|
try {
|
|
296
365
|
if (options.refreshOnCreate !== false) {
|
|
297
|
-
await runtime.refresh({
|
|
366
|
+
await runtime.refresh({
|
|
367
|
+
allowNetwork: refreshFromNetwork,
|
|
368
|
+
// Native catalogs require an explicit account action, not generic startup network consent.
|
|
369
|
+
providers: refreshFromNetwork
|
|
370
|
+
? runtime
|
|
371
|
+
.getProviders()
|
|
372
|
+
.filter((provider) => provider.id !== HCODE_PROVIDER)
|
|
373
|
+
.map((provider) => provider.id)
|
|
374
|
+
: undefined,
|
|
375
|
+
signal,
|
|
376
|
+
});
|
|
298
377
|
}
|
|
299
378
|
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
runtime.dispose();
|
|
381
|
+
throw error;
|
|
382
|
+
}
|
|
300
383
|
finally {
|
|
301
384
|
if (timeout)
|
|
302
385
|
clearTimeout(timeout);
|
|
303
386
|
}
|
|
304
387
|
return runtime;
|
|
305
388
|
}
|
|
389
|
+
assertConfiguration(config) {
|
|
390
|
+
if (this.configurationGuard)
|
|
391
|
+
this.configurationGuard(Object.fromEntries(config.getProviderIds().map((id) => [id, config.getProvider(id)])));
|
|
392
|
+
}
|
|
306
393
|
configureRadiusProviders() {
|
|
307
394
|
this.builtins.clear();
|
|
308
395
|
for (const [providerId, provider] of this.defaultBuiltins)
|
|
309
396
|
this.builtins.set(providerId, provider);
|
|
310
397
|
for (const providerId of this.config.getProviderIds()) {
|
|
398
|
+
if (providerId === HCODE_PROVIDER)
|
|
399
|
+
continue;
|
|
311
400
|
const config = this.config.getProvider(providerId);
|
|
312
401
|
if (config?.oauth !== "radius" || !config.baseUrl)
|
|
313
402
|
continue;
|
|
@@ -440,7 +529,7 @@ export class ModelRuntime {
|
|
|
440
529
|
const extension = this.extensionProviders.get(providerId);
|
|
441
530
|
// HUMAIN Gateway origin, headers and models are fixed; overlays would bypass its request safeguards.
|
|
442
531
|
if (rejectsConfigOverlays(providerId) && (this.config.getProvider(providerId) || extension)) {
|
|
443
|
-
this.compositionErrors.set(providerId, "HUMAIN Gateway does not accept models.json overrides
|
|
532
|
+
this.compositionErrors.set(providerId, `${providerId === HCODE_PROVIDER ? "HUMAIN Code account" : "HUMAIN Gateway"} does not accept models.json overrides.`);
|
|
444
533
|
return base;
|
|
445
534
|
}
|
|
446
535
|
if (!this.config.getProvider(providerId) && !extension) {
|
|
@@ -682,6 +771,8 @@ export class ModelRuntime {
|
|
|
682
771
|
}
|
|
683
772
|
/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */
|
|
684
773
|
getCompatibilityRequestConfig(model) {
|
|
774
|
+
if (model.provider === HCODE_PROVIDER)
|
|
775
|
+
throw new ModelsError("auth", "HUMAIN Code account is unavailable.");
|
|
685
776
|
if (rejectsConfigOverlays(model.provider))
|
|
686
777
|
return resolveCompatibilityRequestConfig(model, undefined, undefined);
|
|
687
778
|
return resolveCompatibilityRequestConfig(model, this.config.getProvider(model.provider), this.extensionProviders.get(model.provider));
|
|
@@ -698,8 +789,18 @@ export class ModelRuntime {
|
|
|
698
789
|
hasConfiguredAuth(providerId) {
|
|
699
790
|
return this.snapshot.configuredProviders.has(providerId);
|
|
700
791
|
}
|
|
792
|
+
/** @internal Pin an already-resolved identity to this model's probe, without changing concurrent requests. */
|
|
793
|
+
withResolvedAuth(model, resolution, accountKey, run) {
|
|
794
|
+
return this.resolvedRequestAuth.run({ model, resolution, accountKey }, run);
|
|
795
|
+
}
|
|
701
796
|
async getAuth(providerOrModel, overrides = {}) {
|
|
702
797
|
const providerId = typeof providerOrModel === "string" ? providerOrModel : providerOrModel.provider;
|
|
798
|
+
const pinned = this.resolvedRequestAuth.getStore();
|
|
799
|
+
if (pinned?.model === providerOrModel) {
|
|
800
|
+
overrides.signal?.throwIfAborted();
|
|
801
|
+
overrides.onOAuthAccount?.(providerId, pinned.accountKey);
|
|
802
|
+
return pinned.resolution;
|
|
803
|
+
}
|
|
703
804
|
const resolution = await this.credentials.authResolution.run(providerId, () => this.oauthAccountObserver.run(overrides.onOAuthAccount, () => typeof providerOrModel === "string"
|
|
704
805
|
? this.models.getAuth(providerOrModel, overrides)
|
|
705
806
|
: this.models.getAuth(providerOrModel, overrides)));
|
|
@@ -786,7 +887,8 @@ export class ModelRuntime {
|
|
|
786
887
|
throw error;
|
|
787
888
|
}
|
|
788
889
|
}
|
|
789
|
-
setRuntimeApiKey(providerId, apiKey, options = {}) {
|
|
890
|
+
async setRuntimeApiKey(providerId, apiKey, options = {}) {
|
|
891
|
+
assertCustomProviderId(providerId);
|
|
790
892
|
const signal = operationSignal(options.signal);
|
|
791
893
|
return this.enqueueCredentialOperation(providerId, signal, async () => {
|
|
792
894
|
this.credentials.setRuntimeApiKey(providerId, apiKey);
|
|
@@ -807,6 +909,13 @@ export class ModelRuntime {
|
|
|
807
909
|
readStoredCredential(providerId, options) {
|
|
808
910
|
return this.protectCredentialOperation(this.credentials.readStored(providerId, options), options?.signal, false);
|
|
809
911
|
}
|
|
912
|
+
/** Wait for started credential and pooled-account writes before process exit. */
|
|
913
|
+
async settleCredentialWrites() {
|
|
914
|
+
while (this.credentialOperations.size > 0)
|
|
915
|
+
await Promise.all(this.credentialOperations.values());
|
|
916
|
+
await this.credentials.settled();
|
|
917
|
+
await this.oauthAccountPool.settled();
|
|
918
|
+
}
|
|
810
919
|
listCredentials(options) {
|
|
811
920
|
return this.protectCredentialOperation(this.credentials.list(options), options?.signal, false);
|
|
812
921
|
}
|
|
@@ -814,6 +923,9 @@ export class ModelRuntime {
|
|
|
814
923
|
accounts = {
|
|
815
924
|
list: (providerId, options) => this.protectCredentialOperation((async () => {
|
|
816
925
|
const { storedEffective } = await this.readAccountSources(providerId, options);
|
|
926
|
+
// Native references are never pooled; a session overlay must not depend on saved storage.
|
|
927
|
+
if (providerId === HCODE_PROVIDER)
|
|
928
|
+
return [];
|
|
817
929
|
const accounts = await this.oauthAccountPool.listAccounts(providerId, options);
|
|
818
930
|
const current = await this.oauthAccountPool.getCurrentAccount(providerId, options);
|
|
819
931
|
return accounts.map(({ key, label, credential, exhaustedUntil }) => ({
|
|
@@ -848,7 +960,30 @@ export class ModelRuntime {
|
|
|
848
960
|
async readAccountSources(providerId, options) {
|
|
849
961
|
const signal = operationSignal(options?.signal);
|
|
850
962
|
const provider = this.models.getProvider(providerId);
|
|
851
|
-
const
|
|
963
|
+
const session = providerId === HCODE_PROVIDER ? this.hcodeSession : undefined;
|
|
964
|
+
const stored = session ? undefined : await this.credentials.readStored(providerId, { signal });
|
|
965
|
+
if (providerId === HCODE_PROVIDER) {
|
|
966
|
+
const credential = session ? hcodeReferenceCredential(session) : stored;
|
|
967
|
+
const checked = await provider?.auth.apiKey?.check?.({
|
|
968
|
+
ctx: defaultProviderAuthContext(),
|
|
969
|
+
credential: credential?.type === "api_key" ? credential : undefined,
|
|
970
|
+
signal,
|
|
971
|
+
});
|
|
972
|
+
return {
|
|
973
|
+
sources: credential
|
|
974
|
+
? [
|
|
975
|
+
{
|
|
976
|
+
source: session ? "runtime" : "auth_json",
|
|
977
|
+
label: this.hcodeFacade.provider.name,
|
|
978
|
+
type: "api_key",
|
|
979
|
+
readOnly: true,
|
|
980
|
+
effective: !!checked,
|
|
981
|
+
},
|
|
982
|
+
]
|
|
983
|
+
: [],
|
|
984
|
+
storedEffective: !session && !!checked,
|
|
985
|
+
};
|
|
986
|
+
}
|
|
852
987
|
const runtimeKey = this.credentials.getRuntimeApiKey(providerId);
|
|
853
988
|
const extensionKey = this.extensionProviders.get(providerId)?.apiKey;
|
|
854
989
|
const modelsKey = this.config.getProvider(providerId)?.apiKey;
|
|
@@ -997,6 +1132,10 @@ export class ModelRuntime {
|
|
|
997
1132
|
return this.oauthAccountPool;
|
|
998
1133
|
}
|
|
999
1134
|
getProviderAuthStatus(providerId) {
|
|
1135
|
+
if (providerId === HCODE_PROVIDER)
|
|
1136
|
+
return this.hasConfiguredAuth(providerId)
|
|
1137
|
+
? { configured: true, source: this.hcodeSession ? "runtime" : "stored" }
|
|
1138
|
+
: { configured: false };
|
|
1000
1139
|
if (this.credentials.hasRuntimeApiKey(providerId))
|
|
1001
1140
|
return { configured: true, source: "runtime" };
|
|
1002
1141
|
if (this.snapshot.storedProviders.has(providerId))
|
|
@@ -1007,8 +1146,32 @@ export class ModelRuntime {
|
|
|
1007
1146
|
const check = this.snapshot.auth.get(providerId);
|
|
1008
1147
|
return check ? { configured: true, source: "environment", label: check.source } : { configured: false };
|
|
1009
1148
|
}
|
|
1010
|
-
async prepareRequest(model, options) {
|
|
1011
|
-
const
|
|
1149
|
+
async prepareRequest(model, options, intent) {
|
|
1150
|
+
const admission = this.currentAdmission();
|
|
1151
|
+
const currentProvider = this.models.getProvider(model.provider);
|
|
1152
|
+
// Capture dispatch values once before qualification or any async auth/header callback can replace them.
|
|
1153
|
+
const provider = currentProvider && (admission || options?.beforeSubmission ? { ...currentProvider } : currentProvider);
|
|
1154
|
+
if (admission || options?.beforeSubmission) {
|
|
1155
|
+
const native = this.nativeExtensionProviders.get(model.provider);
|
|
1156
|
+
// Trust boundary: Node requires source-owned transport identity. Bedrock is installed through the
|
|
1157
|
+
// builtin catalog and source-owned module loader, not native extension registration.
|
|
1158
|
+
if (!intent ||
|
|
1159
|
+
!isModelType(model, "chat") ||
|
|
1160
|
+
!["anthropic-messages", "bedrock-converse-stream", "openai-completions", "openai-responses"].includes(model.api) ||
|
|
1161
|
+
(native !== undefined && (!provider || !hasHumainNodeAdmissionTransport(native, provider))) ||
|
|
1162
|
+
this.extensionProviders.get(model.provider)?.streamSimple) {
|
|
1163
|
+
throw new SubmissionAdmissionError("unsupported-route");
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
this.assertHcodeModel(model);
|
|
1167
|
+
// The agent's automatic transport selects the native provider's only supported protocol.
|
|
1168
|
+
if (model.provider === HCODE_PROVIDER && options && "transport" in options && options.transport === "auto")
|
|
1169
|
+
options = { ...options, transport: "sse" };
|
|
1170
|
+
if (model.provider === HCODE_PROVIDER && this.currentRequestPurpose() === "cache-warming")
|
|
1171
|
+
throw new ModelsError("model_validation", "HUMAIN Code account cache warming is disabled.");
|
|
1172
|
+
const signal = model.provider === HCODE_PROVIDER
|
|
1173
|
+
? AbortSignal.any([this.hcodeFacade.signal, ...(options?.signal ? [options.signal] : [])])
|
|
1174
|
+
: options?.signal;
|
|
1012
1175
|
if (!provider)
|
|
1013
1176
|
throw new ModelsError("provider", `Unknown provider: ${model.provider}`);
|
|
1014
1177
|
let resolvedAccount;
|
|
@@ -1017,7 +1180,7 @@ export class ModelRuntime {
|
|
|
1017
1180
|
const resolution = await this.getAuth(model, {
|
|
1018
1181
|
apiKey: options?.apiKey,
|
|
1019
1182
|
env: options?.env,
|
|
1020
|
-
signal
|
|
1183
|
+
signal,
|
|
1021
1184
|
onOAuthAccount: options?.onOAuthAccount || observesAnthropicLimits
|
|
1022
1185
|
? (provider, key) => {
|
|
1023
1186
|
resolvedAccount = { provider, key };
|
|
@@ -1026,7 +1189,7 @@ export class ModelRuntime {
|
|
|
1026
1189
|
});
|
|
1027
1190
|
if (!resolution)
|
|
1028
1191
|
throw new ModelsError("auth", `Provider is not configured: ${model.provider}`);
|
|
1029
|
-
const { transformHeaders, resolveOnPayload, onOAuthAccount: _onOAuthAccount, ...rawProviderOptions } = options ?? {};
|
|
1192
|
+
const { transformHeaders, resolveOnPayload, onPhysicalTarget: _onPhysicalTarget, onOAuthAccount: _onOAuthAccount, ...rawProviderOptions } = options ?? {};
|
|
1030
1193
|
const providerOptions = rawProviderOptions;
|
|
1031
1194
|
const requestModel = resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model;
|
|
1032
1195
|
const sessionId = "sessionId" in providerOptions && typeof providerOptions.sessionId === "string"
|
|
@@ -1035,6 +1198,8 @@ export class ModelRuntime {
|
|
|
1035
1198
|
let headers = mergeHeaders(mergeHeaders(getOpenCodeSessionHeaders(requestModel, sessionId), resolution.auth.headers), providerOptions.headers);
|
|
1036
1199
|
if (transformHeaders)
|
|
1037
1200
|
headers = await transformHeaders(headers ?? {});
|
|
1201
|
+
// Auth and extension callbacks can yield across native account/catalog replacement.
|
|
1202
|
+
this.assertHcodeModel(model);
|
|
1038
1203
|
const env = resolution.env || providerOptions.env
|
|
1039
1204
|
? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }
|
|
1040
1205
|
: undefined;
|
|
@@ -1065,9 +1230,18 @@ export class ModelRuntime {
|
|
|
1065
1230
|
// The one request boundary: every chat, image, classifier and deferred call is prepared here, so
|
|
1066
1231
|
// the scope bound by the owning session observes it exactly once per real submission.
|
|
1067
1232
|
const scope = this.currentScope();
|
|
1068
|
-
const tracker = scope ? new RequestTracker(scope) : undefined;
|
|
1233
|
+
const tracker = scope || admission ? new RequestTracker(scope, requestModel, admission) : undefined;
|
|
1234
|
+
const gate = admission && intent ? submissionAdmission(admission, requestModel, intent, scope?.purpose) : undefined;
|
|
1235
|
+
const callerGate = providerOptions.beforeSubmission;
|
|
1236
|
+
const beforeSubmission = gate
|
|
1237
|
+
? async (observation) => {
|
|
1238
|
+
// A caller veto precedes allocation; the run-owned gate cannot be replaced by request options.
|
|
1239
|
+
await callerGate?.(observation);
|
|
1240
|
+
await gate(observation);
|
|
1241
|
+
}
|
|
1242
|
+
: callerGate;
|
|
1069
1243
|
// Payload hooks may run from a shared queue; rebind the scope so they see this request's purpose.
|
|
1070
|
-
const callerOnPayload = resolveOnPayload ? resolveOnPayload() : providerOptions.onPayload;
|
|
1244
|
+
const callerOnPayload = resolveOnPayload ? resolveOnPayload(model) : providerOptions.onPayload;
|
|
1071
1245
|
const onPayload = scope && callerOnPayload
|
|
1072
1246
|
? (payload, payloadModel) => this.requestScope.run(scope, () => callerOnPayload(payload, payloadModel))
|
|
1073
1247
|
: callerOnPayload;
|
|
@@ -1076,12 +1250,14 @@ export class ModelRuntime {
|
|
|
1076
1250
|
model: requestModel,
|
|
1077
1251
|
options: {
|
|
1078
1252
|
...providerOptions,
|
|
1253
|
+
signal,
|
|
1079
1254
|
apiKey,
|
|
1080
1255
|
headers,
|
|
1081
1256
|
env,
|
|
1082
1257
|
onPayload,
|
|
1083
1258
|
...(onResponse ? { onResponse } : {}),
|
|
1084
1259
|
...(tracker ? { onRequest: tracker.hook(providerOptions.onRequest) } : {}),
|
|
1260
|
+
...(beforeSubmission ? { beforeSubmission } : {}),
|
|
1085
1261
|
},
|
|
1086
1262
|
tracker,
|
|
1087
1263
|
};
|
|
@@ -1102,13 +1278,78 @@ export class ModelRuntime {
|
|
|
1102
1278
|
* their own observers.
|
|
1103
1279
|
*/
|
|
1104
1280
|
observeRequests(observer, purpose, fn) {
|
|
1281
|
+
// The primary host binds observation after admission; nested observers cannot shed that run's gate.
|
|
1282
|
+
this.admissionScope.getStore()?.observers.add(observer);
|
|
1105
1283
|
return this.requestScope.run({ observer, purpose }, fn);
|
|
1106
1284
|
}
|
|
1285
|
+
/** Bind every descendant model helper to the host's frozen run budget, independently of observers. */
|
|
1286
|
+
async admitRequests(admission, fn) {
|
|
1287
|
+
if (this.admissionScope.getStore())
|
|
1288
|
+
throw new SubmissionAdmissionError("unattributed");
|
|
1289
|
+
const scope = { admission, observers: new Set() };
|
|
1290
|
+
const observer = this.requestScope.getStore()?.observer;
|
|
1291
|
+
if (observer)
|
|
1292
|
+
scope.observers.add(observer);
|
|
1293
|
+
this.activeAdmissions.add(scope);
|
|
1294
|
+
try {
|
|
1295
|
+
return await this.admissionScope.run(scope, fn);
|
|
1296
|
+
}
|
|
1297
|
+
finally {
|
|
1298
|
+
this.activeAdmissions.delete(scope);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
currentAdmission() {
|
|
1302
|
+
const scope = this.admissionScope.getStore();
|
|
1303
|
+
if (!scope && this.activeAdmissions.size > 0) {
|
|
1304
|
+
const observer = this.requestScope.getStore()?.observer;
|
|
1305
|
+
// Only an attributed session owner may run independently; read-only observation grants no admission.
|
|
1306
|
+
if (!observer || !this.ownerObservers.has(observer))
|
|
1307
|
+
throw new SubmissionAdmissionError("unattributed");
|
|
1308
|
+
for (const active of this.activeAdmissions) {
|
|
1309
|
+
if (active.observers.has(observer))
|
|
1310
|
+
throw new SubmissionAdmissionError("unattributed");
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return scope?.admission;
|
|
1314
|
+
}
|
|
1315
|
+
/** Observe only the installed version under the selected environment's lifetime/network veto. */
|
|
1316
|
+
observeHcodeVersion(version) {
|
|
1317
|
+
this.hcodeFacade.observeVersion(version);
|
|
1318
|
+
}
|
|
1319
|
+
/** Export only already-available same-environment support IDs; never bootstrap account or identity state. */
|
|
1320
|
+
getHcodeSupportSnapshot(signal) {
|
|
1321
|
+
return this.hcodeFacade.supportSnapshot(signal);
|
|
1322
|
+
}
|
|
1323
|
+
/** Recheck the selected environment's public native profile without private account I/O. */
|
|
1324
|
+
probeHcodeLogin(signal) {
|
|
1325
|
+
return this.hcodeFacade.probeLogin(signal);
|
|
1326
|
+
}
|
|
1327
|
+
/** Revoke an ephemeral device family once; hosts explicitly own shutdown of injected runtimes. */
|
|
1328
|
+
async shutdownHcodeSession(signal) {
|
|
1329
|
+
try {
|
|
1330
|
+
return await this.hcodeFacade.shutdown(signal);
|
|
1331
|
+
}
|
|
1332
|
+
finally {
|
|
1333
|
+
this.credentials.clearHcodeSessionReference();
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
/** Application teardown must not revoke a borrowed host runtime. */
|
|
1337
|
+
shutdownOwnedHcodeSession(signal) {
|
|
1338
|
+
return this.sessionOwned
|
|
1339
|
+
? this.shutdownHcodeSession(signal)
|
|
1340
|
+
: Promise.resolve({ remoteRevocation: "not-needed" });
|
|
1341
|
+
}
|
|
1342
|
+
/** Stop owned private sends/publication without logout, persisted credential changes or an exit flush. */
|
|
1343
|
+
dispose() {
|
|
1344
|
+
this.credentials.clearHcodeSessionReference();
|
|
1345
|
+
this.hcodeFacade.dispose();
|
|
1346
|
+
}
|
|
1107
1347
|
/** Register a session observer that owns direct calls on this runtime; returns the unregister function. */
|
|
1108
1348
|
addOwnerObserver(observer) {
|
|
1109
1349
|
this.ownerObservers.add(observer);
|
|
1110
1350
|
return () => {
|
|
1111
|
-
this.ownerObservers.delete(observer)
|
|
1351
|
+
if (this.ownerObservers.delete(observer) && this.sessionOwned && this.ownerObservers.size === 0)
|
|
1352
|
+
this.dispose();
|
|
1112
1353
|
};
|
|
1113
1354
|
}
|
|
1114
1355
|
/**
|
|
@@ -1136,23 +1377,120 @@ export class ModelRuntime {
|
|
|
1136
1377
|
/** Change the purpose of requests started by `fn`, keeping the current observer. No-op outside a scope. */
|
|
1137
1378
|
withRequestPurpose(purpose, fn) {
|
|
1138
1379
|
const scope = this.currentScope();
|
|
1139
|
-
return scope ? this.
|
|
1380
|
+
return scope ? this.observeRequests(scope.observer, purpose, fn) : fn();
|
|
1381
|
+
}
|
|
1382
|
+
/** Reject host-supplied native model facts at the SDK/router request boundary. */
|
|
1383
|
+
assertHcodeModel(model) {
|
|
1384
|
+
if (model.provider === HCODE_PROVIDER && this.getPhysicalModel(HCODE_PROVIDER, model.id) !== model)
|
|
1385
|
+
throw new ModelsError("model_validation", "HUMAIN Code account approved model changed or is unavailable.");
|
|
1386
|
+
}
|
|
1387
|
+
/** Keep the outer watchdog from turning a managed request into a resend instruction. */
|
|
1388
|
+
guardHcodeTimeout(model, stream, actualModel, onTimeout) {
|
|
1389
|
+
if (model.provider !== HCODE_PROVIDER && !isVirtualModel(model))
|
|
1390
|
+
return stream;
|
|
1391
|
+
return lazyStream(model, async () => ({
|
|
1392
|
+
async *[Symbol.asyncIterator]() {
|
|
1393
|
+
for await (const event of stream) {
|
|
1394
|
+
if (event.type === "error" &&
|
|
1395
|
+
actualModel().provider === HCODE_PROVIDER &&
|
|
1396
|
+
event.error.diagnostics?.some((entry) => entry.type === "provider_no_progress_timeout")) {
|
|
1397
|
+
onTimeout();
|
|
1398
|
+
event.error.errorMessage = "HUMAIN Code request unavailable. Do not automatically resend.";
|
|
1399
|
+
event.error.diagnostics = [
|
|
1400
|
+
{ type: "provider_http_error", timestamp: Date.now(), details: { retryable: false } },
|
|
1401
|
+
];
|
|
1402
|
+
}
|
|
1403
|
+
yield event;
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
result: () => stream.result(),
|
|
1407
|
+
}));
|
|
1408
|
+
}
|
|
1409
|
+
inferenceObservation(model, started) {
|
|
1410
|
+
// Only a trusted declaration, captured before auth clones, may supply a public pair.
|
|
1411
|
+
const native = this.getPhysicalModel(model.provider, model.id) === model &&
|
|
1412
|
+
(model.provider === HCODE_PROVIDER ||
|
|
1413
|
+
(this.defaultBuiltins.has(model.provider) &&
|
|
1414
|
+
!this.nativeExtensionProviders.has(model.provider) &&
|
|
1415
|
+
!this.extensionProviders.has(model.provider) &&
|
|
1416
|
+
!this.config.getProvider(model.provider)));
|
|
1417
|
+
const provider = native ? model.provider : "other";
|
|
1418
|
+
const id = native && model.provider !== HCODE_PROVIDER ? model.id : "other";
|
|
1419
|
+
return (message, submissions, observedFailure) => {
|
|
1420
|
+
const usage = message?.usage;
|
|
1421
|
+
const known = usage && !usage.usageIncomplete && usage.totalTokens > 0;
|
|
1422
|
+
const token = (value) => known && value !== undefined && Number.isInteger(value) && value >= 0 && value <= 2147483647 ? value : null;
|
|
1423
|
+
const outcome = message?.stopReason === "aborted"
|
|
1424
|
+
? "cancelled"
|
|
1425
|
+
: message?.stopReason === "stop" || message?.stopReason === "toolUse"
|
|
1426
|
+
? usage?.usageIncomplete
|
|
1427
|
+
? "unknown"
|
|
1428
|
+
: "success"
|
|
1429
|
+
: "failure";
|
|
1430
|
+
const retries = Math.max(0, submissions - 1);
|
|
1431
|
+
this.metadata.inference(provider, id, {
|
|
1432
|
+
durationMs: Math.min(2147483647, Math.round(performance.now() - started)),
|
|
1433
|
+
inputTokens: token(usage?.input),
|
|
1434
|
+
outputTokens: token(usage?.output),
|
|
1435
|
+
cacheReadTokens: token(usage?.cacheRead),
|
|
1436
|
+
cacheWriteTokens: token(usage?.cacheWrite),
|
|
1437
|
+
retries,
|
|
1438
|
+
outcome,
|
|
1439
|
+
});
|
|
1440
|
+
if (outcome !== "success") {
|
|
1441
|
+
const http = message?.diagnostics?.findLast((entry) => entry.type === "provider_http_error");
|
|
1442
|
+
const hcode = http?.details?.hcode;
|
|
1443
|
+
const status = hcode && typeof hcode === "object" && "status" in hcode ? hcode.status : http?.details?.status;
|
|
1444
|
+
const code = observedFailure ??
|
|
1445
|
+
(message?.diagnostics?.some((entry) => entry.type === "provider_no_progress_timeout")
|
|
1446
|
+
? "timeout"
|
|
1447
|
+
: status === 401
|
|
1448
|
+
? "auth"
|
|
1449
|
+
: status === 403
|
|
1450
|
+
? "approval"
|
|
1451
|
+
: status === 429
|
|
1452
|
+
? "quota"
|
|
1453
|
+
: message?.stopReason === "length"
|
|
1454
|
+
? "invalid"
|
|
1455
|
+
: "transport");
|
|
1456
|
+
this.metadata.failure("prompt", code, retries, outcome);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1140
1459
|
}
|
|
1141
1460
|
/** Report the outcome of a stream once it ends. */
|
|
1142
|
-
trackStream(stream, tracker) {
|
|
1143
|
-
stream.result().then((message) =>
|
|
1461
|
+
trackStream(stream, tracker, observe) {
|
|
1462
|
+
stream.result().then((message) => {
|
|
1463
|
+
observe?.(message);
|
|
1464
|
+
tracker()?.settleMessage(message);
|
|
1465
|
+
}, () => {
|
|
1466
|
+
observe?.(undefined);
|
|
1467
|
+
tracker()?.settleFailure(false);
|
|
1468
|
+
});
|
|
1144
1469
|
return stream;
|
|
1145
1470
|
}
|
|
1146
1471
|
stream(model, context, options) {
|
|
1147
1472
|
const transcript = normalizeContext(context);
|
|
1148
1473
|
let tracker;
|
|
1149
|
-
|
|
1474
|
+
const observe = this.inferenceObservation(model, performance.now());
|
|
1475
|
+
let observedFailure;
|
|
1476
|
+
let submissions = 0;
|
|
1477
|
+
const callerRequest = options?.onRequest;
|
|
1478
|
+
const onRequest = async (request) => {
|
|
1479
|
+
submissions++;
|
|
1480
|
+
await callerRequest?.(request);
|
|
1481
|
+
};
|
|
1482
|
+
return this.trackStream(this.guardHcodeTimeout(model, streamWithProgressTimeout(model, async (signal) => {
|
|
1150
1483
|
assertChatModel(model);
|
|
1151
|
-
const
|
|
1484
|
+
const intent = admissionIntent(model, options);
|
|
1485
|
+
if (this.currentAdmission())
|
|
1486
|
+
intent.requiredImageCount = assertAdmittedModelInput(model, context);
|
|
1487
|
+
const prepared = await this.prepareRequest(model, { ...options, signal, onRequest }, intent);
|
|
1152
1488
|
tracker = prepared.tracker;
|
|
1153
1489
|
signal.throwIfAborted();
|
|
1154
1490
|
return prepared.provider.stream(prepared.model, transcript, prepared.options);
|
|
1155
|
-
}, options), () =>
|
|
1491
|
+
}, options), () => model, () => {
|
|
1492
|
+
observedFailure = "timeout";
|
|
1493
|
+
}), () => tracker, (message) => observe(message, submissions, observedFailure));
|
|
1156
1494
|
}
|
|
1157
1495
|
complete(model, context, options) {
|
|
1158
1496
|
return drainStream(this.stream(model, context, options));
|
|
@@ -1160,8 +1498,20 @@ export class ModelRuntime {
|
|
|
1160
1498
|
streamSimple(model, context, options) {
|
|
1161
1499
|
const transcript = normalizeContext(context);
|
|
1162
1500
|
let tracker;
|
|
1163
|
-
|
|
1164
|
-
|
|
1501
|
+
let requestModel = model;
|
|
1502
|
+
const started = performance.now();
|
|
1503
|
+
let observe = this.inferenceObservation(model, started);
|
|
1504
|
+
let observedFailure;
|
|
1505
|
+
let submissions = 0;
|
|
1506
|
+
const callerRequest = options?.onRequest;
|
|
1507
|
+
options = {
|
|
1508
|
+
...options,
|
|
1509
|
+
onRequest: async (request) => {
|
|
1510
|
+
submissions++;
|
|
1511
|
+
await callerRequest?.(request);
|
|
1512
|
+
},
|
|
1513
|
+
};
|
|
1514
|
+
return this.trackStream(this.guardHcodeTimeout(model, streamWithProgressTimeout(model, async (signal) => {
|
|
1165
1515
|
let requestOptions = options;
|
|
1166
1516
|
if (isVirtualModel(model)) {
|
|
1167
1517
|
// Requests outside the agent loop are routed here. Callers sized them before routing, so
|
|
@@ -1182,12 +1532,19 @@ export class ModelRuntime {
|
|
|
1182
1532
|
requestModel = route.model;
|
|
1183
1533
|
requestOptions = { ...rest, ...auth, maxTokens, reasoning };
|
|
1184
1534
|
}
|
|
1535
|
+
observe = this.inferenceObservation(requestModel, started);
|
|
1536
|
+
requestOptions?.onPhysicalTarget?.(requestModel);
|
|
1185
1537
|
assertChatModel(requestModel);
|
|
1186
|
-
const
|
|
1538
|
+
const intent = admissionIntent(model, options);
|
|
1539
|
+
if (this.currentAdmission())
|
|
1540
|
+
intent.requiredImageCount = assertAdmittedModelInput(requestModel, context);
|
|
1541
|
+
const prepared = await this.prepareRequest(requestModel, { ...requestOptions, signal }, intent);
|
|
1187
1542
|
tracker = prepared.tracker;
|
|
1188
1543
|
signal.throwIfAborted();
|
|
1189
1544
|
return prepared.provider.streamSimple(prepared.model, transcript, prepared.options);
|
|
1190
|
-
}, options), () =>
|
|
1545
|
+
}, options), () => requestModel, () => {
|
|
1546
|
+
observedFailure = "timeout";
|
|
1547
|
+
}), () => tracker, (message) => observe(message, submissions, observedFailure));
|
|
1191
1548
|
}
|
|
1192
1549
|
completeSimple(model, context, options) {
|
|
1193
1550
|
return drainStream(this.streamSimple(model, context, options));
|
|
@@ -1202,7 +1559,7 @@ export class ModelRuntime {
|
|
|
1202
1559
|
throw new ModelsError("provider", `Provider ${model.provider} does not support deferred responses`);
|
|
1203
1560
|
}
|
|
1204
1561
|
return prepared.provider.fetchDeferred(prepared.model, handle, prepared.options);
|
|
1205
|
-
}), () => tracker);
|
|
1562
|
+
}, undefined, options?.signal), () => tracker);
|
|
1206
1563
|
}
|
|
1207
1564
|
async fetchDeferred(model, handle, options) {
|
|
1208
1565
|
return drainStream(this.streamDeferred(model, handle, options));
|
|
@@ -1254,6 +1611,7 @@ export class ModelRuntime {
|
|
|
1254
1611
|
}
|
|
1255
1612
|
login(providerId, type, interaction, options) {
|
|
1256
1613
|
const signal = operationSignal(interaction.signal);
|
|
1614
|
+
const started = performance.now();
|
|
1257
1615
|
return this.enqueueCredentialOperation(providerId, signal, async () => {
|
|
1258
1616
|
const provider = this.models.getProvider(providerId);
|
|
1259
1617
|
if (!provider)
|
|
@@ -1266,11 +1624,15 @@ export class ModelRuntime {
|
|
|
1266
1624
|
if (!selected || selected.credential.type !== type)
|
|
1267
1625
|
throw new ModelsError("auth", "Account is no longer available for reauthentication");
|
|
1268
1626
|
}
|
|
1269
|
-
|
|
1627
|
+
if (providerId === HCODE_PROVIDER)
|
|
1628
|
+
await this.hcodeFacade.recover(signal);
|
|
1629
|
+
const nativeReference = providerId === HCODE_PROVIDER ? await this.credentials.readStored(providerId, { signal }) : undefined;
|
|
1630
|
+
if (providerId !== HCODE_PROVIDER)
|
|
1631
|
+
await this.oauthAccountPool.adoptCurrentAccount(providerId, { signal });
|
|
1270
1632
|
let promptCancelled = false;
|
|
1271
1633
|
let login;
|
|
1272
1634
|
try {
|
|
1273
|
-
|
|
1635
|
+
const input = {
|
|
1274
1636
|
...interaction,
|
|
1275
1637
|
signal,
|
|
1276
1638
|
prompt: async (prompt) => {
|
|
@@ -1284,7 +1646,32 @@ export class ModelRuntime {
|
|
|
1284
1646
|
throw new LoginCancellationError();
|
|
1285
1647
|
}
|
|
1286
1648
|
},
|
|
1287
|
-
}
|
|
1649
|
+
};
|
|
1650
|
+
login = await raceWithAbortSignal(providerId === HCODE_PROVIDER
|
|
1651
|
+
? this.hcodeFacade
|
|
1652
|
+
.login(input, signal, async (reference) => {
|
|
1653
|
+
// The generic pool intentionally excludes keyless references; only native login may replace its observed reference.
|
|
1654
|
+
const candidate = hcodeReferenceCredential(reference);
|
|
1655
|
+
try {
|
|
1656
|
+
await this.credentials.modify(providerId, async (current) => {
|
|
1657
|
+
if (!sameCredential(current, nativeReference))
|
|
1658
|
+
throw new SafeCredentialError("HUMAIN Code account reference changed. Refresh local models before retrying.");
|
|
1659
|
+
return candidate;
|
|
1660
|
+
}, { signal });
|
|
1661
|
+
}
|
|
1662
|
+
catch (error) {
|
|
1663
|
+
// A backend may reject after writing; compensate only our candidate, never a competing publication.
|
|
1664
|
+
if (nativeReference)
|
|
1665
|
+
await this.credentials.modify(providerId, async (current) => sameCredential(current, candidate) ? nativeReference : undefined);
|
|
1666
|
+
else
|
|
1667
|
+
await this.credentials.deleteStored(providerId, {
|
|
1668
|
+
ifCurrent: (current) => sameCredential(current, candidate),
|
|
1669
|
+
});
|
|
1670
|
+
throw error;
|
|
1671
|
+
}
|
|
1672
|
+
})
|
|
1673
|
+
.then(hcodeReferenceCredential)
|
|
1674
|
+
: method.login(input, options), signal);
|
|
1288
1675
|
}
|
|
1289
1676
|
catch (error) {
|
|
1290
1677
|
if (promptCancelled || signal.aborted)
|
|
@@ -1301,10 +1688,30 @@ export class ModelRuntime {
|
|
|
1301
1688
|
? await this.oauthAccountPool.addAccount(providerId, login, { signal, key: options?.accountKey })
|
|
1302
1689
|
: undefined;
|
|
1303
1690
|
const credential = account?.credential ?? login;
|
|
1304
|
-
if (
|
|
1691
|
+
if (providerId === HCODE_PROVIDER) {
|
|
1692
|
+
const reference = this.hcode.account.status(this.hcode.environmentId);
|
|
1693
|
+
if (!reference || login.type !== "api_key")
|
|
1694
|
+
throw new ModelsError("auth", "HUMAIN Code account changed.");
|
|
1695
|
+
if (this.hcodeFacade.persistence(reference) === "session") {
|
|
1696
|
+
this.hcodeSession = reference;
|
|
1697
|
+
this.credentials.setHcodeSessionReference(login);
|
|
1698
|
+
await this.synchronizeCredentialState(providerId, "login", signal);
|
|
1699
|
+
return login;
|
|
1700
|
+
}
|
|
1701
|
+
this.hcodeSession = undefined;
|
|
1702
|
+
}
|
|
1703
|
+
else if (!account)
|
|
1305
1704
|
await commitLoginCredential(this.credentials.accountStore, providerId, login, signal);
|
|
1306
1705
|
await this.synchronizeCredentialState(providerId, "login", signal);
|
|
1307
1706
|
return credential;
|
|
1707
|
+
}).then((credential) => {
|
|
1708
|
+
this.metadata.feature("login", Math.round(performance.now() - started), "success");
|
|
1709
|
+
return credential;
|
|
1710
|
+
}, (error) => {
|
|
1711
|
+
const outcome = signal.aborted || error instanceof LoginCancellationError ? "cancelled" : "failure";
|
|
1712
|
+
this.metadata.feature("login", Math.round(performance.now() - started), outcome);
|
|
1713
|
+
this.metadata.failure("login", error instanceof CredentialSynchronizationError ? "storage" : "auth", 0, outcome);
|
|
1714
|
+
throw error;
|
|
1308
1715
|
});
|
|
1309
1716
|
}
|
|
1310
1717
|
/**
|
|
@@ -1318,6 +1725,8 @@ export class ModelRuntime {
|
|
|
1318
1725
|
await this.logoutWithStatus(providerId, options);
|
|
1319
1726
|
}
|
|
1320
1727
|
async deleteObservedStoredCredential(providerId, observed, signal) {
|
|
1728
|
+
if (providerId === HCODE_PROVIDER)
|
|
1729
|
+
await this.hcodeFacade.logoutStored(observed, signal);
|
|
1321
1730
|
let status = "changed";
|
|
1322
1731
|
await this.credentials.deleteStored(providerId, {
|
|
1323
1732
|
signal,
|
|
@@ -1354,6 +1763,21 @@ export class ModelRuntime {
|
|
|
1354
1763
|
logoutWithStatus(providerId, options = {}) {
|
|
1355
1764
|
const signal = operationSignal(options.signal);
|
|
1356
1765
|
return this.enqueueCredentialOperation(providerId, signal, async () => {
|
|
1766
|
+
if (providerId === HCODE_PROVIDER)
|
|
1767
|
+
await this.hcodeFacade.recover(signal);
|
|
1768
|
+
if (providerId === HCODE_PROVIDER && this.hcodeSession) {
|
|
1769
|
+
const reference = this.hcodeSession;
|
|
1770
|
+
const retained = this.hcodeFacade.persistence(reference) === "session";
|
|
1771
|
+
try {
|
|
1772
|
+
if (retained)
|
|
1773
|
+
await this.hcode.account.logout(reference, signal);
|
|
1774
|
+
}
|
|
1775
|
+
finally {
|
|
1776
|
+
this.credentials.clearHcodeSessionReference();
|
|
1777
|
+
}
|
|
1778
|
+
await this.synchronizeCredentialState(providerId, "logout", signal);
|
|
1779
|
+
return retained ? "removed" : "unmatched";
|
|
1780
|
+
}
|
|
1357
1781
|
// Raw stored credential (`read` resolves configured API-key values), observed before the pool's read.
|
|
1358
1782
|
const observed = options.accountKey === undefined
|
|
1359
1783
|
? structuredClone(await this.credentials.modify(providerId, async () => undefined, { signal }))
|
|
@@ -1444,7 +1868,9 @@ export class ModelRuntime {
|
|
|
1444
1868
|
if (!fromRegistration && this.pendingRegistrationRefreshes.size > 0) {
|
|
1445
1869
|
await Promise.allSettled([...this.pendingRegistrationRefreshes]);
|
|
1446
1870
|
}
|
|
1447
|
-
|
|
1871
|
+
const config = await ModelConfig.load(this.modelsPath);
|
|
1872
|
+
this.assertConfiguration(config);
|
|
1873
|
+
this.config = config;
|
|
1448
1874
|
this.configureRadiusProviders();
|
|
1449
1875
|
if (options.providers) {
|
|
1450
1876
|
for (const providerId of new Set(options.providers))
|
|
@@ -1489,6 +1915,7 @@ export class ModelRuntime {
|
|
|
1489
1915
|
return { aborted: result.aborted || (options.signal?.aborted ?? false), errors };
|
|
1490
1916
|
}
|
|
1491
1917
|
registerNativeProvider(provider) {
|
|
1918
|
+
assertCustomProviderId(provider.id);
|
|
1492
1919
|
if (!provider.id.trim())
|
|
1493
1920
|
throw new Error("Provider id must not be empty.");
|
|
1494
1921
|
this.extensionProviders.delete(provider.id);
|
|
@@ -1519,6 +1946,8 @@ export class ModelRuntime {
|
|
|
1519
1946
|
};
|
|
1520
1947
|
}
|
|
1521
1948
|
registerProvider(providerId, config) {
|
|
1949
|
+
assertCustomProviderId(providerId);
|
|
1950
|
+
this.configurationGuard?.({ [providerId]: config });
|
|
1522
1951
|
// Validate the incoming registration on its own, like the legacy registry:
|
|
1523
1952
|
// a broken re-registration must throw without touching the stored config.
|
|
1524
1953
|
validateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);
|
|
@@ -1538,6 +1967,7 @@ export class ModelRuntime {
|
|
|
1538
1967
|
this.queueRegistrationRefresh();
|
|
1539
1968
|
}
|
|
1540
1969
|
unregisterProvider(providerId) {
|
|
1970
|
+
assertCustomProviderId(providerId);
|
|
1541
1971
|
this.extensionProviders.delete(providerId);
|
|
1542
1972
|
this.nativeExtensionProviders.delete(providerId);
|
|
1543
1973
|
this.recomposeProvider(providerId);
|
|
@@ -1551,6 +1981,7 @@ export class ModelRuntime {
|
|
|
1551
1981
|
*/
|
|
1552
1982
|
registerVirtualModel(definition) {
|
|
1553
1983
|
const { provider: providerId, id } = definition;
|
|
1984
|
+
assertCustomProviderId(providerId);
|
|
1554
1985
|
if (!providerId.trim() || !id.trim())
|
|
1555
1986
|
throw new Error("Virtual model provider and id must not be empty.");
|
|
1556
1987
|
const existing = this.models.getModel(providerId, id);
|
|
@@ -1571,6 +2002,7 @@ export class ModelRuntime {
|
|
|
1571
2002
|
this.queueRegistrationRefresh();
|
|
1572
2003
|
}
|
|
1573
2004
|
unregisterVirtualModel(providerId, id) {
|
|
2005
|
+
assertCustomProviderId(providerId);
|
|
1574
2006
|
const models = this.virtualModels.get(providerId);
|
|
1575
2007
|
if (!models?.delete(id))
|
|
1576
2008
|
return;
|
|
@@ -1606,17 +2038,27 @@ export class ModelRuntime {
|
|
|
1606
2038
|
failed: failedModel && failed && { model: failedModel, thinkingLevel: failed.thinkingLevel, message: failed },
|
|
1607
2039
|
messages,
|
|
1608
2040
|
});
|
|
2041
|
+
this.assertHcodeModel(route.model);
|
|
1609
2042
|
const target = this.getPhysicalModel(route.model.provider, route.model.id);
|
|
1610
2043
|
const routed = `${name} routed to ${route.model.provider}/${route.model.id}`;
|
|
1611
2044
|
if (!target)
|
|
1612
2045
|
throw new Error(`${routed}, which is not a physical model.`);
|
|
1613
2046
|
if (!this.hasConfiguredAuth(target.provider))
|
|
1614
2047
|
throw new Error(`${routed}, which has no credentials.`);
|
|
1615
|
-
|
|
2048
|
+
if (target.provider === HCODE_PROVIDER && !getSupportedThinkingLevels(target).includes(route.thinkingLevel))
|
|
2049
|
+
throw new Error(HCODE_UNSUPPORTED_THINKING_MESSAGE);
|
|
2050
|
+
return {
|
|
2051
|
+
model: target,
|
|
2052
|
+
thinkingLevel: target.provider === HCODE_PROVIDER ? route.thinkingLevel : clampThinkingLevel(target, route.thinkingLevel),
|
|
2053
|
+
state: route.state,
|
|
2054
|
+
};
|
|
1616
2055
|
}
|
|
1617
2056
|
/** A catalog chat model that is not virtual. */
|
|
1618
2057
|
getPhysicalModel(providerId, modelId) {
|
|
1619
2058
|
const model = this.models.getModel(providerId, modelId);
|
|
2059
|
+
// A custom catalog cannot lend its provider ID to the reserved native target.
|
|
2060
|
+
if (model?.provider === HCODE_PROVIDER && providerId !== HCODE_PROVIDER)
|
|
2061
|
+
return undefined;
|
|
1620
2062
|
return model && !isVirtualModel(model) ? model : undefined;
|
|
1621
2063
|
}
|
|
1622
2064
|
}
|