@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
|
@@ -0,0 +1,1243 @@
|
|
|
1
|
+
import * as wire from "./wire.js";
|
|
2
|
+
/** Complete SSE envelope: retained UTF-8 content/signatures may expand sixfold in JSON. */
|
|
3
|
+
export const MAX_PI_EVENT_FRAME_BYTES = 54525952;
|
|
4
|
+
export { parseCliDeliveryResult, parseCliMetadataBatch } from "../metadata/contracts.js";
|
|
5
|
+
export const HCODE_ERROR_STATUS = {
|
|
6
|
+
unauthorized: new Set([401]),
|
|
7
|
+
forbidden: new Set([403]),
|
|
8
|
+
legal_acknowledgment_required: new Set([403]),
|
|
9
|
+
auth_dependency_unavailable: new Set([503]),
|
|
10
|
+
hcode_unavailable: new Set([503]),
|
|
11
|
+
invalid_request: new Set([400, 413, 415]),
|
|
12
|
+
unsupported_capability: new Set([422]),
|
|
13
|
+
model_unavailable: new Set([409]),
|
|
14
|
+
hcode_busy: new Set([429]),
|
|
15
|
+
quota_exceeded: new Set([429]),
|
|
16
|
+
idempotency_conflict: new Set([409]),
|
|
17
|
+
request_in_progress: new Set([409]),
|
|
18
|
+
outcome_unknown: new Set([409]),
|
|
19
|
+
upstream_unavailable: new Set([502]),
|
|
20
|
+
settlement_unavailable: new Set([503]),
|
|
21
|
+
};
|
|
22
|
+
function source(value) {
|
|
23
|
+
return wire.member(value, ["forge_web", "cli", "legacy_unknown"]);
|
|
24
|
+
}
|
|
25
|
+
/** Parse trusted-origin discovery data before the account owner qualifies the issuer. */
|
|
26
|
+
export function parseHcodeCliConfig(value) {
|
|
27
|
+
const v = wire.object(value, ["schemaVersion", "environmentId", "origin", "inferenceBaseUrl", "auth"]);
|
|
28
|
+
const auth = wire.object(v.auth, [
|
|
29
|
+
"kind",
|
|
30
|
+
"issuer",
|
|
31
|
+
"clientId",
|
|
32
|
+
"audience",
|
|
33
|
+
"scopes",
|
|
34
|
+
"qualification",
|
|
35
|
+
"maxAccessTokenSeconds",
|
|
36
|
+
"deviceAuthorizationEndpoint",
|
|
37
|
+
"tokenEndpoint",
|
|
38
|
+
"revocationEndpoint",
|
|
39
|
+
"verificationUri",
|
|
40
|
+
"revocation",
|
|
41
|
+
]);
|
|
42
|
+
const origin = wire.member(v.origin, [
|
|
43
|
+
"https://code.dev.humain.com",
|
|
44
|
+
"https://code.stg.humain.com",
|
|
45
|
+
"https://code.humain.com",
|
|
46
|
+
]);
|
|
47
|
+
const inferenceBaseUrl = wire.https(v.inferenceBaseUrl);
|
|
48
|
+
if (inferenceBaseUrl !== `${origin}/api/inference`)
|
|
49
|
+
return wire.invalid();
|
|
50
|
+
const scopes = wire.array(auth.scopes, (entry) => {
|
|
51
|
+
const scope = wire.string(entry, 128);
|
|
52
|
+
if (!/^[\x21\x23-\x5b\x5d-\x7e]+$/.test(scope))
|
|
53
|
+
return wire.invalid();
|
|
54
|
+
return scope;
|
|
55
|
+
}, 32, 1);
|
|
56
|
+
if (wire.https(auth.issuer).endsWith("/"))
|
|
57
|
+
return wire.invalid();
|
|
58
|
+
if (new Set(scopes).size !== scopes.length)
|
|
59
|
+
return wire.invalid();
|
|
60
|
+
return {
|
|
61
|
+
schemaVersion: wire.literal(v.schemaVersion, 1),
|
|
62
|
+
environmentId: wire.string(v.environmentId),
|
|
63
|
+
origin,
|
|
64
|
+
inferenceBaseUrl,
|
|
65
|
+
auth: {
|
|
66
|
+
kind: wire.literal(auth.kind, "oidc-device"),
|
|
67
|
+
qualification: wire.literal(auth.qualification, "owner-qualified-native-device"),
|
|
68
|
+
maxAccessTokenSeconds: wire.integer(auth.maxAccessTokenSeconds, 86400, 1),
|
|
69
|
+
deviceAuthorizationEndpoint: wire.https(auth.deviceAuthorizationEndpoint),
|
|
70
|
+
tokenEndpoint: wire.https(auth.tokenEndpoint),
|
|
71
|
+
revocationEndpoint: wire.https(auth.revocationEndpoint),
|
|
72
|
+
verificationUri: wire.https(auth.verificationUri),
|
|
73
|
+
revocation: wire.literal(auth.revocation, "isolated-device-family"),
|
|
74
|
+
issuer: wire.https(auth.issuer),
|
|
75
|
+
clientId: wire.string(auth.clientId),
|
|
76
|
+
audience: wire.string(auth.audience),
|
|
77
|
+
scopes,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function parseHcodeAccount(value) {
|
|
82
|
+
const v = wire.object(value, [
|
|
83
|
+
"schemaVersion",
|
|
84
|
+
"accountId",
|
|
85
|
+
"environmentId",
|
|
86
|
+
"displayName",
|
|
87
|
+
"email",
|
|
88
|
+
"role",
|
|
89
|
+
"eligibility",
|
|
90
|
+
]);
|
|
91
|
+
const eligibility = wire.object(v.eligibility, ["kind"]);
|
|
92
|
+
const email = wire.nullable(v.email, (entry) => wire.string(entry, 320));
|
|
93
|
+
if (email !== null &&
|
|
94
|
+
!/^(?:[A-Za-z0-9_'+-]+\.)*[A-Za-z0-9_'+-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/.test(email))
|
|
95
|
+
return wire.invalid();
|
|
96
|
+
return {
|
|
97
|
+
schemaVersion: wire.literal(v.schemaVersion, 1),
|
|
98
|
+
accountId: wire.string(v.accountId),
|
|
99
|
+
environmentId: wire.string(v.environmentId),
|
|
100
|
+
displayName: wire.nullable(v.displayName, (entry) => wire.string(entry, 256, 0)),
|
|
101
|
+
email,
|
|
102
|
+
role: wire.member(v.role, ["user", "admin"]),
|
|
103
|
+
eligibility: { kind: wire.literal(eligibility.kind, "eligible") },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function parseValue(value) {
|
|
107
|
+
const v = wire.object(value, ["kind", "value"]);
|
|
108
|
+
if (v.kind === "known")
|
|
109
|
+
return { kind: "known", value: wire.integer(v.value) };
|
|
110
|
+
wire.object(value, ["kind"]);
|
|
111
|
+
return { kind: wire.member(v.kind, ["unknown", "redacted", "unavailable"]) };
|
|
112
|
+
}
|
|
113
|
+
function parseTokens(value, max = 2147483647) {
|
|
114
|
+
const v = wire.object(value, ["input", "output", "cacheRead", "cacheWrite", "total"]);
|
|
115
|
+
const result = {
|
|
116
|
+
input: parseValue(v.input),
|
|
117
|
+
output: parseValue(v.output),
|
|
118
|
+
cacheRead: parseValue(v.cacheRead),
|
|
119
|
+
cacheWrite: parseValue(v.cacheWrite),
|
|
120
|
+
total: parseValue(v.total),
|
|
121
|
+
};
|
|
122
|
+
for (const token of Object.values(result))
|
|
123
|
+
if (token.kind === "known")
|
|
124
|
+
wire.integer(token.value, max);
|
|
125
|
+
if (result.input.kind === "known") {
|
|
126
|
+
if (result.output.kind === "known" &&
|
|
127
|
+
result.total.kind === "known" &&
|
|
128
|
+
(!Number.isSafeInteger(result.input.value + result.output.value) ||
|
|
129
|
+
result.total.value !== result.input.value + result.output.value))
|
|
130
|
+
return wire.invalid();
|
|
131
|
+
if ((result.cacheRead.kind === "known" ? result.cacheRead.value : 0) +
|
|
132
|
+
(result.cacheWrite.kind === "known" ? result.cacheWrite.value : 0) >
|
|
133
|
+
result.input.value)
|
|
134
|
+
return wire.invalid();
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
function parseAllowance(value) {
|
|
139
|
+
const v = wire.object(value, ["kind", "limitMicrocents"]);
|
|
140
|
+
if (v.kind === "limited")
|
|
141
|
+
return { kind: "limited", limitMicrocents: wire.integer(v.limitMicrocents) };
|
|
142
|
+
wire.object(value, ["kind"]);
|
|
143
|
+
return { kind: wire.literal(v.kind, "unlimited") };
|
|
144
|
+
}
|
|
145
|
+
function parseUsageSource(value) {
|
|
146
|
+
const v = wire.object(value, ["surface", "actual", "reserved", "tokens"]);
|
|
147
|
+
return {
|
|
148
|
+
surface: source(v.surface),
|
|
149
|
+
actual: parseValue(v.actual),
|
|
150
|
+
reserved: parseValue(v.reserved),
|
|
151
|
+
tokens: parseTokens(v.tokens, Number.MAX_SAFE_INTEGER),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function parseUsageItem(value) {
|
|
155
|
+
const v = wire.object(value, [
|
|
156
|
+
"id",
|
|
157
|
+
"at",
|
|
158
|
+
"surface",
|
|
159
|
+
"source",
|
|
160
|
+
"capability",
|
|
161
|
+
"operation",
|
|
162
|
+
"provider",
|
|
163
|
+
"model",
|
|
164
|
+
"status",
|
|
165
|
+
"outcome",
|
|
166
|
+
"cost",
|
|
167
|
+
"hold",
|
|
168
|
+
"tokens",
|
|
169
|
+
"complete",
|
|
170
|
+
]);
|
|
171
|
+
return {
|
|
172
|
+
id: wire.string(v.id),
|
|
173
|
+
at: wire.time(v.at),
|
|
174
|
+
surface: source(v.surface),
|
|
175
|
+
source: wire.member(v.source, ["run", "utility"]),
|
|
176
|
+
capability: wire.string(v.capability),
|
|
177
|
+
operation: wire.string(v.operation),
|
|
178
|
+
provider: wire.nullable(v.provider, wire.string),
|
|
179
|
+
model: wire.nullable(v.model, wire.string),
|
|
180
|
+
status: wire.member(v.status, ["reserved", "succeeded", "failed", "blocked"]),
|
|
181
|
+
outcome: wire.member(v.outcome, ["pending", "succeeded", "failed", "cancelled", "unknown"]),
|
|
182
|
+
cost: parseValue(v.cost),
|
|
183
|
+
hold: parseValue(v.hold),
|
|
184
|
+
tokens: parseTokens(v.tokens),
|
|
185
|
+
complete: wire.boolean(v.complete),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export function parseHcodeUsage(value) {
|
|
189
|
+
const v = wire.object(value, [
|
|
190
|
+
"schemaVersion",
|
|
191
|
+
"accountId",
|
|
192
|
+
"environmentId",
|
|
193
|
+
"asOf",
|
|
194
|
+
"freshness",
|
|
195
|
+
"period",
|
|
196
|
+
"currency",
|
|
197
|
+
"unit",
|
|
198
|
+
"allowance",
|
|
199
|
+
"allowanceSource",
|
|
200
|
+
"actual",
|
|
201
|
+
"reserved",
|
|
202
|
+
"committed",
|
|
203
|
+
"remaining",
|
|
204
|
+
"costComplete",
|
|
205
|
+
"unsettledCount",
|
|
206
|
+
"unknownCostCount",
|
|
207
|
+
"tokens",
|
|
208
|
+
"sources",
|
|
209
|
+
"items",
|
|
210
|
+
"nextCursor",
|
|
211
|
+
]);
|
|
212
|
+
const snapshot = parseAllowanceSnapshot(Object.fromEntries(snapshotFields.map((field) => [field, v[field]])));
|
|
213
|
+
const sources = wire.array(v.sources, parseUsageSource, 3);
|
|
214
|
+
if (new Set(sources.map((entry) => entry.surface)).size !== sources.length)
|
|
215
|
+
return wire.invalid();
|
|
216
|
+
return {
|
|
217
|
+
schemaVersion: wire.literal(v.schemaVersion, 1),
|
|
218
|
+
accountId: wire.string(v.accountId),
|
|
219
|
+
environmentId: wire.string(v.environmentId),
|
|
220
|
+
...snapshot,
|
|
221
|
+
freshness: wire.member(v.freshness, ["current", "stale"]),
|
|
222
|
+
allowanceSource: wire.member(v.allowanceSource, ["global", "override"]),
|
|
223
|
+
unsettledCount: wire.integer(v.unsettledCount),
|
|
224
|
+
unknownCostCount: wire.integer(v.unknownCostCount),
|
|
225
|
+
tokens: parseTokens(v.tokens, Number.MAX_SAFE_INTEGER),
|
|
226
|
+
sources,
|
|
227
|
+
items: wire.array(v.items, parseUsageItem, 50),
|
|
228
|
+
nextCursor: wire.nullable(v.nextCursor, (entry) => wire.string(entry, 2048)),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export function parseHcodeUsageQuery(value) {
|
|
232
|
+
const v = wire.query(value);
|
|
233
|
+
let limit = v.limit;
|
|
234
|
+
if (typeof limit === "string" && /^[1-9][0-9]*$/.test(limit))
|
|
235
|
+
limit = Number(limit);
|
|
236
|
+
return {
|
|
237
|
+
...(v.surface === undefined ? {} : { surface: source(v.surface) }),
|
|
238
|
+
...(v.cursor === undefined ? {} : { cursor: wire.string(v.cursor, 2048) }),
|
|
239
|
+
limit: limit === undefined ? 20 : wire.integer(limit, 50, 1),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const efforts = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
243
|
+
const bytes = (value) => new TextEncoder().encode(value).length;
|
|
244
|
+
function scalar(value, max = 1048576, min = 0) {
|
|
245
|
+
const text = wire.string(value, max, min);
|
|
246
|
+
if (bytes(text) > max || /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(text))
|
|
247
|
+
return wire.invalid();
|
|
248
|
+
return text;
|
|
249
|
+
}
|
|
250
|
+
function ascii(value, max = 256) {
|
|
251
|
+
const text = scalar(value, max, 1);
|
|
252
|
+
if (!/^[\x20-\x7e]+$/.test(text))
|
|
253
|
+
return wire.invalid();
|
|
254
|
+
return text;
|
|
255
|
+
}
|
|
256
|
+
function toolName(value) {
|
|
257
|
+
const text = scalar(value, 64, 1);
|
|
258
|
+
if (!/^[A-Za-z0-9_-]+$/.test(text))
|
|
259
|
+
return wire.invalid();
|
|
260
|
+
return text;
|
|
261
|
+
}
|
|
262
|
+
function boundedJson(value, maxDepth = 32, maxNodes = 8192) {
|
|
263
|
+
let nodes = 0;
|
|
264
|
+
const ancestors = new Set();
|
|
265
|
+
function visit(entry, depth) {
|
|
266
|
+
if (++nodes > maxNodes || depth > maxDepth)
|
|
267
|
+
return wire.invalid();
|
|
268
|
+
if (entry === null || typeof entry === "boolean")
|
|
269
|
+
return entry;
|
|
270
|
+
if (typeof entry === "number")
|
|
271
|
+
return wire.number(entry, -Number.MAX_VALUE);
|
|
272
|
+
if (typeof entry === "string")
|
|
273
|
+
return scalar(entry, 12582912);
|
|
274
|
+
if (typeof entry !== "object" || ancestors.has(entry))
|
|
275
|
+
return wire.invalid();
|
|
276
|
+
ancestors.add(entry);
|
|
277
|
+
if (Object.getOwnPropertySymbols(entry).length)
|
|
278
|
+
return wire.invalid();
|
|
279
|
+
let result;
|
|
280
|
+
if (Array.isArray(entry)) {
|
|
281
|
+
if (Object.keys(entry).length !== entry.length)
|
|
282
|
+
return wire.invalid();
|
|
283
|
+
result = Array.from({ length: entry.length }, (_, index) => {
|
|
284
|
+
const descriptor = Object.getOwnPropertyDescriptor(entry, String(index));
|
|
285
|
+
if (!descriptor || !("value" in descriptor))
|
|
286
|
+
return wire.invalid();
|
|
287
|
+
return visit(descriptor.value, depth + 1);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const v = wire.object(entry, Object.keys(entry));
|
|
292
|
+
const out = {};
|
|
293
|
+
for (const key of Object.keys(v)) {
|
|
294
|
+
scalar(key, 1048576);
|
|
295
|
+
if (["__proto__", "constructor", "prototype"].includes(key))
|
|
296
|
+
return wire.invalid();
|
|
297
|
+
const descriptor = Object.getOwnPropertyDescriptor(v, key);
|
|
298
|
+
if (!descriptor || !("value" in descriptor))
|
|
299
|
+
return wire.invalid();
|
|
300
|
+
out[key] = visit(descriptor.value, depth + 1);
|
|
301
|
+
}
|
|
302
|
+
result = out;
|
|
303
|
+
}
|
|
304
|
+
ancestors.delete(entry);
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
return visit(value, 0);
|
|
308
|
+
}
|
|
309
|
+
function jsonObject(value, maxBytes) {
|
|
310
|
+
const parsed = boundedJson(value);
|
|
311
|
+
wire.object(parsed, parsed !== null && typeof parsed === "object" ? Object.keys(parsed) : []);
|
|
312
|
+
if (wire.jsonBytes(parsed) > maxBytes)
|
|
313
|
+
return wire.invalid();
|
|
314
|
+
return parsed;
|
|
315
|
+
}
|
|
316
|
+
function jsonSchema(value) {
|
|
317
|
+
const parsed = jsonObject(value, 131072);
|
|
318
|
+
function refs(entry, position) {
|
|
319
|
+
if (entry === null || typeof entry !== "object")
|
|
320
|
+
return;
|
|
321
|
+
if (Array.isArray(entry)) {
|
|
322
|
+
for (const child of entry)
|
|
323
|
+
refs(child, position === "array" ? "schema" : "data");
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
for (const [key, child] of Object.entries(entry)) {
|
|
327
|
+
let next = "data";
|
|
328
|
+
if (position === "map")
|
|
329
|
+
next = "schema";
|
|
330
|
+
if (position === "schema") {
|
|
331
|
+
if (["$ref", "$dynamicRef", "$recursiveRef", "$id"].includes(key) &&
|
|
332
|
+
(typeof child !== "string" || !child.startsWith("#")))
|
|
333
|
+
wire.invalid();
|
|
334
|
+
if (["properties", "patternProperties", "$defs", "definitions", "dependentSchemas", "dependencies"].includes(key))
|
|
335
|
+
next = "map";
|
|
336
|
+
else if (["allOf", "anyOf", "oneOf", "prefixItems"].includes(key) ||
|
|
337
|
+
(key === "items" && Array.isArray(child)))
|
|
338
|
+
next = "array";
|
|
339
|
+
else if ([
|
|
340
|
+
"additionalProperties",
|
|
341
|
+
"unevaluatedProperties",
|
|
342
|
+
"propertyNames",
|
|
343
|
+
"contains",
|
|
344
|
+
"additionalItems",
|
|
345
|
+
"unevaluatedItems",
|
|
346
|
+
"items",
|
|
347
|
+
"not",
|
|
348
|
+
"if",
|
|
349
|
+
"then",
|
|
350
|
+
"else",
|
|
351
|
+
"contentSchema",
|
|
352
|
+
].includes(key))
|
|
353
|
+
next = "schema";
|
|
354
|
+
}
|
|
355
|
+
refs(child, next);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
refs(parsed, "schema");
|
|
359
|
+
return parsed;
|
|
360
|
+
}
|
|
361
|
+
function rates(value, tier = false) {
|
|
362
|
+
const v = wire.object(value, ["input", "output", "cacheRead", "cacheWrite", ...(tier ? ["inputTokensAbove"] : [])]);
|
|
363
|
+
return {
|
|
364
|
+
input: wire.number(v.input),
|
|
365
|
+
output: wire.number(v.output),
|
|
366
|
+
cacheRead: wire.number(v.cacheRead),
|
|
367
|
+
cacheWrite: wire.number(v.cacheWrite),
|
|
368
|
+
...(tier ? { inputTokensAbove: wire.integer(v.inputTokensAbove) } : {}),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function parseModel(value) {
|
|
372
|
+
const v = wire.object(value, [
|
|
373
|
+
"id",
|
|
374
|
+
"name",
|
|
375
|
+
"api",
|
|
376
|
+
"provider",
|
|
377
|
+
"baseUrl",
|
|
378
|
+
"type",
|
|
379
|
+
"tools",
|
|
380
|
+
"reasoning",
|
|
381
|
+
"input",
|
|
382
|
+
"contextWindow",
|
|
383
|
+
"maxTokens",
|
|
384
|
+
"cost",
|
|
385
|
+
"thinkingLevelMap",
|
|
386
|
+
"inputLimits",
|
|
387
|
+
]);
|
|
388
|
+
const contextWindow = wire.integer(v.contextWindow, Number.MAX_SAFE_INTEGER, 1), maxTokens = wire.integer(v.maxTokens, contextWindow, 1);
|
|
389
|
+
const input = wire.array(v.input, (entry) => wire.member(entry, ["text", "image"]), 2, 1);
|
|
390
|
+
if (input[0] !== "text" || (input.length === 2 && input[1] !== "image"))
|
|
391
|
+
return wire.invalid();
|
|
392
|
+
const map = wire.object(v.thinkingLevelMap, efforts);
|
|
393
|
+
const thinkingLevelMap = {};
|
|
394
|
+
for (const effort of efforts)
|
|
395
|
+
thinkingLevelMap[effort] = map[effort] === null ? null : wire.literal(map[effort], effort);
|
|
396
|
+
const reasoning = wire.boolean(v.reasoning);
|
|
397
|
+
if (!reasoning && efforts.some((e) => e !== "off" && thinkingLevelMap[e] !== null))
|
|
398
|
+
return wire.invalid();
|
|
399
|
+
if (!efforts.some((e) => thinkingLevelMap[e] !== null) ||
|
|
400
|
+
(reasoning && !efforts.some((e) => e !== "off" && thinkingLevelMap[e] !== null)))
|
|
401
|
+
return wire.invalid();
|
|
402
|
+
const costRecord = wire.object(v.cost, ["input", "output", "cacheRead", "cacheWrite", "tiers"]);
|
|
403
|
+
const cost = {
|
|
404
|
+
...rates({
|
|
405
|
+
input: costRecord.input,
|
|
406
|
+
output: costRecord.output,
|
|
407
|
+
cacheRead: costRecord.cacheRead,
|
|
408
|
+
cacheWrite: costRecord.cacheWrite,
|
|
409
|
+
}),
|
|
410
|
+
};
|
|
411
|
+
if (costRecord.tiers !== undefined) {
|
|
412
|
+
const tiers = wire.array(costRecord.tiers, (entry) => {
|
|
413
|
+
const r = rates(entry, true);
|
|
414
|
+
return { ...r, inputTokensAbove: wire.integer(r.inputTokensAbove) };
|
|
415
|
+
}, 1024);
|
|
416
|
+
if (tiers.some((entry, i) => entry.inputTokensAbove <= (tiers[i - 1]?.inputTokensAbove ?? -1)))
|
|
417
|
+
return wire.invalid();
|
|
418
|
+
cost.tiers = tiers;
|
|
419
|
+
}
|
|
420
|
+
const limits = wire.object(v.inputLimits, ["maxRequestBytes", "images"]);
|
|
421
|
+
const inputLimits = {};
|
|
422
|
+
if (limits.maxRequestBytes !== undefined)
|
|
423
|
+
inputLimits.maxRequestBytes = wire.integer(limits.maxRequestBytes, 12582912, 1);
|
|
424
|
+
if (limits.images !== undefined) {
|
|
425
|
+
if (input.length !== 2)
|
|
426
|
+
return wire.invalid();
|
|
427
|
+
const image = wire.object(limits.images, ["resize", "maxPerMessage", "maxPerRequest"]), resize = wire.object(image.resize, ["maxWidth", "maxHeight", "maxBytes", "jpegQuality"]);
|
|
428
|
+
inputLimits.images = {
|
|
429
|
+
maxPerMessage: wire.integer(image.maxPerMessage, 4, 1),
|
|
430
|
+
maxPerRequest: wire.integer(image.maxPerRequest, 4, 1),
|
|
431
|
+
resize: {
|
|
432
|
+
maxWidth: wire.integer(resize.maxWidth, 4096, 1),
|
|
433
|
+
maxHeight: wire.integer(resize.maxHeight, 4096, 1),
|
|
434
|
+
maxBytes: wire.integer(resize.maxBytes, 4194304, 1),
|
|
435
|
+
...(resize.jpegQuality === undefined ? {} : { jpegQuality: wire.integer(resize.jpegQuality, 100, 1) }),
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
if (input.length === 2 && !inputLimits.images)
|
|
440
|
+
return wire.invalid();
|
|
441
|
+
const baseUrl = wire.https(v.baseUrl);
|
|
442
|
+
if (!["https://code.dev.humain.com", "https://code.stg.humain.com", "https://code.humain.com"].some((origin) => baseUrl === `${origin}/api/inference`))
|
|
443
|
+
return wire.invalid();
|
|
444
|
+
return {
|
|
445
|
+
id: scalar(v.id, 256, 1),
|
|
446
|
+
name: scalar(v.name, 256, 1),
|
|
447
|
+
api: wire.literal(v.api, "pi-messages"),
|
|
448
|
+
provider: wire.literal(v.provider, "humain-code-account"),
|
|
449
|
+
baseUrl,
|
|
450
|
+
type: wire.literal(v.type, "chat"),
|
|
451
|
+
tools: wire.boolean(v.tools),
|
|
452
|
+
reasoning,
|
|
453
|
+
input: input,
|
|
454
|
+
contextWindow,
|
|
455
|
+
maxTokens,
|
|
456
|
+
cost,
|
|
457
|
+
thinkingLevelMap,
|
|
458
|
+
inputLimits,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
export function parseHcodeModelList(value) {
|
|
462
|
+
boundedJson(value, 32, 131072);
|
|
463
|
+
const v = wire.object(value, ["object", "data"]);
|
|
464
|
+
const data = wire.array(v.data, parseModel, 1024);
|
|
465
|
+
if (new Set(data.map((model) => model.id)).size !== data.length)
|
|
466
|
+
return wire.invalid();
|
|
467
|
+
return { object: wire.literal(v.object, "list"), data };
|
|
468
|
+
}
|
|
469
|
+
function textBlock(value) {
|
|
470
|
+
const v = wire.object(value, ["type", "text", "textSignature"]);
|
|
471
|
+
return {
|
|
472
|
+
type: wire.literal(v.type, "text"),
|
|
473
|
+
text: scalar(v.text),
|
|
474
|
+
...(v.textSignature === undefined ? {} : { textSignature: scalar(v.textSignature, 262144) }),
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function imageBlock(value) {
|
|
478
|
+
const v = wire.object(value, ["type", "data", "mimeType"]);
|
|
479
|
+
const data = scalar(v.data, 4194304, 4);
|
|
480
|
+
if (data.length % 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data))
|
|
481
|
+
return wire.invalid();
|
|
482
|
+
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
483
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
484
|
+
if ((padding === 2 && (alphabet.indexOf(data.charAt(data.length - 3)) & 15) !== 0) ||
|
|
485
|
+
(padding === 1 && (alphabet.indexOf(data.charAt(data.length - 2)) & 3) !== 0))
|
|
486
|
+
return wire.invalid();
|
|
487
|
+
return {
|
|
488
|
+
type: wire.literal(v.type, "image"),
|
|
489
|
+
data,
|
|
490
|
+
mimeType: wire.member(v.mimeType, ["image/png", "image/jpeg", "image/webp"]),
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function thinkingBlock(value) {
|
|
494
|
+
const v = wire.object(value, ["type", "thinking", "thinkingSignature", "redacted"]);
|
|
495
|
+
const result = {
|
|
496
|
+
type: wire.literal(v.type, "thinking"),
|
|
497
|
+
thinking: scalar(v.thinking),
|
|
498
|
+
...(v.thinkingSignature === undefined ? {} : { thinkingSignature: scalar(v.thinkingSignature, 262144) }),
|
|
499
|
+
...(v.redacted === undefined ? {} : { redacted: wire.boolean(v.redacted) }),
|
|
500
|
+
};
|
|
501
|
+
if (result.redacted && (!result.thinkingSignature || result.thinking !== ""))
|
|
502
|
+
return wire.invalid();
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
function toolCall(value) {
|
|
506
|
+
const v = wire.object(value, ["type", "id", "name", "arguments", "thoughtSignature", "namespace", "argumentsError"]);
|
|
507
|
+
const result = {
|
|
508
|
+
type: wire.literal(v.type, "toolCall"),
|
|
509
|
+
id: ascii(v.id),
|
|
510
|
+
name: toolName(v.name),
|
|
511
|
+
arguments: jsonObject(v.arguments, 65536),
|
|
512
|
+
...(v.thoughtSignature === undefined ? {} : { thoughtSignature: scalar(v.thoughtSignature, 262144) }),
|
|
513
|
+
...(v.namespace === undefined ? {} : { namespace: ascii(v.namespace, 128) }),
|
|
514
|
+
...(v.argumentsError === undefined ? {} : { argumentsError: scalar(v.argumentsError, 65536, 1) }),
|
|
515
|
+
};
|
|
516
|
+
if (result.argumentsError && Object.keys(result.arguments).length)
|
|
517
|
+
return wire.invalid();
|
|
518
|
+
return result;
|
|
519
|
+
}
|
|
520
|
+
function tool(value) {
|
|
521
|
+
const v = wire.object(value, ["name", "description", "parameters", "constrainedSampling"]);
|
|
522
|
+
const result = {
|
|
523
|
+
name: toolName(v.name),
|
|
524
|
+
description: scalar(v.description),
|
|
525
|
+
parameters: jsonSchema(v.parameters),
|
|
526
|
+
};
|
|
527
|
+
if (v.constrainedSampling !== undefined) {
|
|
528
|
+
if (v.constrainedSampling === false)
|
|
529
|
+
result.constrainedSampling = false;
|
|
530
|
+
else {
|
|
531
|
+
const mode = wire.object(v.constrainedSampling, ["type", "strict"]);
|
|
532
|
+
result.constrainedSampling = {
|
|
533
|
+
type: wire.literal(mode.type, "json_schema"),
|
|
534
|
+
strict: wire.member(mode.strict, ["prefer", "require"]),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
function content(value, images) {
|
|
541
|
+
if (typeof value === "string")
|
|
542
|
+
return scalar(value);
|
|
543
|
+
return wire.array(value, (entry) => {
|
|
544
|
+
const v = wire.object(entry, ["type", "text", "textSignature", "data", "mimeType"]);
|
|
545
|
+
return v.type === "image" && images ? imageBlock(entry) : textBlock(entry);
|
|
546
|
+
}, 2048);
|
|
547
|
+
}
|
|
548
|
+
function history(v) {
|
|
549
|
+
for (const key of [
|
|
550
|
+
"usage",
|
|
551
|
+
"diagnostics",
|
|
552
|
+
"timing",
|
|
553
|
+
"durationMs",
|
|
554
|
+
"retryAfterMs",
|
|
555
|
+
"errorMessage",
|
|
556
|
+
"rawStopReason",
|
|
557
|
+
"endTurn",
|
|
558
|
+
"responseId",
|
|
559
|
+
"responseModel",
|
|
560
|
+
"thinkingLevel",
|
|
561
|
+
"details",
|
|
562
|
+
"nestedCalls",
|
|
563
|
+
]) {
|
|
564
|
+
if (v[key] === undefined)
|
|
565
|
+
continue;
|
|
566
|
+
if (key === "usage") {
|
|
567
|
+
const usage = wire.object(v[key], [
|
|
568
|
+
"input",
|
|
569
|
+
"output",
|
|
570
|
+
"cacheRead",
|
|
571
|
+
"cacheWrite",
|
|
572
|
+
"totalTokens",
|
|
573
|
+
"reasoning",
|
|
574
|
+
"cacheWrite1h",
|
|
575
|
+
"usageIncomplete",
|
|
576
|
+
"cost",
|
|
577
|
+
]);
|
|
578
|
+
const cost = wire.object(usage.cost, [
|
|
579
|
+
"input",
|
|
580
|
+
"output",
|
|
581
|
+
"cacheRead",
|
|
582
|
+
"cacheWrite",
|
|
583
|
+
"total",
|
|
584
|
+
"totalFromProvider",
|
|
585
|
+
]);
|
|
586
|
+
if (cost.totalFromProvider !== undefined)
|
|
587
|
+
wire.boolean(cost.totalFromProvider);
|
|
588
|
+
parseHcodePiUsage({ ...usage, cost: { ...cost, totalFromProvider: false } });
|
|
589
|
+
}
|
|
590
|
+
else if (key === "timing") {
|
|
591
|
+
const timing = wire.object(v[key], ["requestStartedAt", "firstTokenMs", "durationMs", "chunkCount"]);
|
|
592
|
+
wire.integer(timing.requestStartedAt);
|
|
593
|
+
if (timing.firstTokenMs !== null)
|
|
594
|
+
wire.number(timing.firstTokenMs, 0, Number.MAX_SAFE_INTEGER);
|
|
595
|
+
wire.number(timing.durationMs, 0, Number.MAX_SAFE_INTEGER);
|
|
596
|
+
wire.integer(timing.chunkCount);
|
|
597
|
+
}
|
|
598
|
+
else if (["durationMs", "retryAfterMs"].includes(key))
|
|
599
|
+
wire.number(v[key], 0, Number.MAX_SAFE_INTEGER);
|
|
600
|
+
else if (key === "endTurn")
|
|
601
|
+
wire.boolean(v[key]);
|
|
602
|
+
else if (["errorMessage", "rawStopReason", "responseId", "responseModel", "thinkingLevel"].includes(key))
|
|
603
|
+
scalar(v[key]);
|
|
604
|
+
else
|
|
605
|
+
boundedJson(v[key]);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function parseMessage(value) {
|
|
609
|
+
const base = wire.object(value, [
|
|
610
|
+
"role",
|
|
611
|
+
"content",
|
|
612
|
+
"timestamp",
|
|
613
|
+
"sections",
|
|
614
|
+
"toolsAdded",
|
|
615
|
+
"toolsRemoved",
|
|
616
|
+
"api",
|
|
617
|
+
"provider",
|
|
618
|
+
"model",
|
|
619
|
+
"stopReason",
|
|
620
|
+
"providerThinkingLevel",
|
|
621
|
+
"toolCallId",
|
|
622
|
+
"toolName",
|
|
623
|
+
"isError",
|
|
624
|
+
"usage",
|
|
625
|
+
"diagnostics",
|
|
626
|
+
"timing",
|
|
627
|
+
"durationMs",
|
|
628
|
+
"retryAfterMs",
|
|
629
|
+
"errorMessage",
|
|
630
|
+
"rawStopReason",
|
|
631
|
+
"endTurn",
|
|
632
|
+
"responseId",
|
|
633
|
+
"responseModel",
|
|
634
|
+
"thinkingLevel",
|
|
635
|
+
"details",
|
|
636
|
+
"nestedCalls",
|
|
637
|
+
]);
|
|
638
|
+
const timestamp = wire.integer(base.timestamp);
|
|
639
|
+
if (base.role === "system") {
|
|
640
|
+
const v = wire.object(value, ["role", "content", "timestamp", "sections", "toolsAdded", "toolsRemoved"]);
|
|
641
|
+
const result = {
|
|
642
|
+
role: "system",
|
|
643
|
+
content: content(v.content, false),
|
|
644
|
+
timestamp,
|
|
645
|
+
};
|
|
646
|
+
if (v.sections !== undefined) {
|
|
647
|
+
const sections = wire.object(v.sections, Object.keys(v.sections));
|
|
648
|
+
if (Object.keys(sections).length > 64)
|
|
649
|
+
return wire.invalid();
|
|
650
|
+
result.sections = {};
|
|
651
|
+
for (const [key, entry] of Object.entries(sections)) {
|
|
652
|
+
scalar(key, 128, 1);
|
|
653
|
+
result.sections[key] = entry === null ? null : scalar(entry);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (v.toolsAdded !== undefined)
|
|
657
|
+
result.toolsAdded = wire.array(v.toolsAdded, tool, 64);
|
|
658
|
+
if (v.toolsRemoved !== undefined)
|
|
659
|
+
result.toolsRemoved = wire.array(v.toolsRemoved, (entry) => {
|
|
660
|
+
const r = wire.object(entry, ["name"]);
|
|
661
|
+
return { name: toolName(r.name) };
|
|
662
|
+
}, 64);
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
if (base.role === "user") {
|
|
666
|
+
const v = wire.object(value, ["role", "content", "timestamp"]);
|
|
667
|
+
return { role: "user", content: content(v.content, true), timestamp };
|
|
668
|
+
}
|
|
669
|
+
if (base.role === "assistant") {
|
|
670
|
+
const v = wire.object(value, [
|
|
671
|
+
"role",
|
|
672
|
+
"content",
|
|
673
|
+
"timestamp",
|
|
674
|
+
"api",
|
|
675
|
+
"provider",
|
|
676
|
+
"model",
|
|
677
|
+
"stopReason",
|
|
678
|
+
"providerThinkingLevel",
|
|
679
|
+
"usage",
|
|
680
|
+
"diagnostics",
|
|
681
|
+
"timing",
|
|
682
|
+
"durationMs",
|
|
683
|
+
"retryAfterMs",
|
|
684
|
+
"errorMessage",
|
|
685
|
+
"rawStopReason",
|
|
686
|
+
"endTurn",
|
|
687
|
+
"responseId",
|
|
688
|
+
"responseModel",
|
|
689
|
+
"thinkingLevel",
|
|
690
|
+
]);
|
|
691
|
+
history(v);
|
|
692
|
+
return {
|
|
693
|
+
role: "assistant",
|
|
694
|
+
content: wire.array(v.content, (entry) => {
|
|
695
|
+
const record = wire.object(entry, [
|
|
696
|
+
"type",
|
|
697
|
+
"text",
|
|
698
|
+
"textSignature",
|
|
699
|
+
"thinking",
|
|
700
|
+
"thinkingSignature",
|
|
701
|
+
"redacted",
|
|
702
|
+
"id",
|
|
703
|
+
"name",
|
|
704
|
+
"arguments",
|
|
705
|
+
"thoughtSignature",
|
|
706
|
+
"namespace",
|
|
707
|
+
"argumentsError",
|
|
708
|
+
]);
|
|
709
|
+
return record.type === "thinking"
|
|
710
|
+
? thinkingBlock(entry)
|
|
711
|
+
: record.type === "toolCall"
|
|
712
|
+
? toolCall(entry)
|
|
713
|
+
: textBlock(entry);
|
|
714
|
+
}, 2048),
|
|
715
|
+
api: scalar(v.api, 256, 1),
|
|
716
|
+
provider: scalar(v.provider, 256, 1),
|
|
717
|
+
model: scalar(v.model, 256, 1),
|
|
718
|
+
stopReason: wire.member(v.stopReason, ["stop", "length", "toolUse", "error", "aborted"]),
|
|
719
|
+
timestamp,
|
|
720
|
+
...(v.providerThinkingLevel === undefined
|
|
721
|
+
? {}
|
|
722
|
+
: { providerThinkingLevel: ascii(v.providerThinkingLevel, 128) }),
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
const v = wire.object(value, [
|
|
726
|
+
"role",
|
|
727
|
+
"content",
|
|
728
|
+
"timestamp",
|
|
729
|
+
"toolCallId",
|
|
730
|
+
"toolName",
|
|
731
|
+
"isError",
|
|
732
|
+
"details",
|
|
733
|
+
"usage",
|
|
734
|
+
"nestedCalls",
|
|
735
|
+
"durationMs",
|
|
736
|
+
]);
|
|
737
|
+
history(v);
|
|
738
|
+
return {
|
|
739
|
+
role: wire.literal(v.role, "toolResult"),
|
|
740
|
+
toolCallId: ascii(v.toolCallId),
|
|
741
|
+
toolName: toolName(v.toolName),
|
|
742
|
+
content: wire.array(v.content, (entry) => {
|
|
743
|
+
const record = wire.object(entry, ["type", "text", "textSignature", "data", "mimeType"]);
|
|
744
|
+
return record.type === "image" ? imageBlock(entry) : textBlock(entry);
|
|
745
|
+
}, 2048),
|
|
746
|
+
isError: wire.boolean(v.isError),
|
|
747
|
+
timestamp,
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
const ignoredOptions = [
|
|
751
|
+
"headers",
|
|
752
|
+
"metadata",
|
|
753
|
+
"provider",
|
|
754
|
+
"baseUrl",
|
|
755
|
+
"apiKey",
|
|
756
|
+
"env",
|
|
757
|
+
"samplingParams",
|
|
758
|
+
"transport",
|
|
759
|
+
"thinkingBudgets",
|
|
760
|
+
"maxRetries",
|
|
761
|
+
"maxRetryDelayMs",
|
|
762
|
+
"timeoutMs",
|
|
763
|
+
"noProgressTimeoutMs",
|
|
764
|
+
"websocketConnectTimeoutMs",
|
|
765
|
+
];
|
|
766
|
+
function parseOptions(value) {
|
|
767
|
+
const v = wire.object(value, [
|
|
768
|
+
"temperature",
|
|
769
|
+
"maxTokens",
|
|
770
|
+
"reasoning",
|
|
771
|
+
"cacheRetention",
|
|
772
|
+
"sessionId",
|
|
773
|
+
"toolChoice",
|
|
774
|
+
...ignoredOptions,
|
|
775
|
+
]);
|
|
776
|
+
for (const key of ignoredOptions)
|
|
777
|
+
if (v[key] !== undefined)
|
|
778
|
+
boundedJson(v[key]);
|
|
779
|
+
const result = {};
|
|
780
|
+
if (v.temperature !== undefined)
|
|
781
|
+
result.temperature = wire.number(v.temperature, 0, 2);
|
|
782
|
+
if (v.maxTokens !== undefined)
|
|
783
|
+
result.maxTokens = wire.integer(v.maxTokens, Number.MAX_SAFE_INTEGER, 1);
|
|
784
|
+
if (v.reasoning !== undefined)
|
|
785
|
+
result.reasoning = wire.member(v.reasoning, ["minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
786
|
+
if (v.cacheRetention !== undefined)
|
|
787
|
+
result.cacheRetention = wire.member(v.cacheRetention, ["none", "short", "long"]);
|
|
788
|
+
if (v.sessionId !== undefined)
|
|
789
|
+
result.sessionId = ascii(v.sessionId);
|
|
790
|
+
if (v.toolChoice !== undefined) {
|
|
791
|
+
if (typeof v.toolChoice === "string")
|
|
792
|
+
result.toolChoice = wire.member(v.toolChoice, ["auto", "none", "required"]);
|
|
793
|
+
else {
|
|
794
|
+
const choice = wire.object(v.toolChoice, ["type", "function"]), f = wire.object(choice.function, ["name"]);
|
|
795
|
+
result.toolChoice = { type: wire.literal(choice.type, "function"), function: { name: toolName(f.name) } };
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return result;
|
|
799
|
+
}
|
|
800
|
+
export function parseHcodeMessagesRequest(value) {
|
|
801
|
+
const raw = boundedJson(value, 48, 1048576);
|
|
802
|
+
if (wire.jsonBytes(raw) > 12582912)
|
|
803
|
+
return wire.invalid();
|
|
804
|
+
const v = wire.object(raw, ["model", "context", "options"]), context = wire.object(v.context, ["messages"]);
|
|
805
|
+
const messages = wire.array(context.messages, parseMessage, 512, 1);
|
|
806
|
+
const result = {
|
|
807
|
+
model: scalar(v.model, 256, 1),
|
|
808
|
+
context: { messages },
|
|
809
|
+
...(v.options === undefined ? {} : { options: parseOptions(v.options) }),
|
|
810
|
+
};
|
|
811
|
+
let blocks = 0, images = 0, imageBytes = 0, schemaBytes = 0;
|
|
812
|
+
const active = new Map(), seen = new Set(), pending = new Map();
|
|
813
|
+
for (const message of messages) {
|
|
814
|
+
if (message.role === "system") {
|
|
815
|
+
const added = message.toolsAdded ?? [], removed = message.toolsRemoved ?? [];
|
|
816
|
+
if (new Set(added.map((t) => t.name)).size !== added.length ||
|
|
817
|
+
new Set(removed.map((t) => t.name)).size !== removed.length ||
|
|
818
|
+
removed.some((r) => added.some((a) => a.name === r.name)))
|
|
819
|
+
return wire.invalid();
|
|
820
|
+
for (const t of removed)
|
|
821
|
+
if (!active.delete(t.name))
|
|
822
|
+
return wire.invalid();
|
|
823
|
+
for (const t of added) {
|
|
824
|
+
active.set(t.name, t);
|
|
825
|
+
schemaBytes += wire.jsonBytes(t.parameters);
|
|
826
|
+
}
|
|
827
|
+
if (active.size > 64 || schemaBytes > 131072)
|
|
828
|
+
return wire.invalid();
|
|
829
|
+
}
|
|
830
|
+
else if (message.role === "toolResult") {
|
|
831
|
+
if (pending.get(message.toolCallId) !== message.toolName)
|
|
832
|
+
return wire.invalid();
|
|
833
|
+
pending.delete(message.toolCallId);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
if (pending.size)
|
|
837
|
+
return wire.invalid();
|
|
838
|
+
if (message.role === "assistant") {
|
|
839
|
+
const calls = message.content.filter((block) => block.type === "toolCall");
|
|
840
|
+
if (calls.length > 64)
|
|
841
|
+
return wire.invalid();
|
|
842
|
+
for (const call of calls) {
|
|
843
|
+
if (seen.has(call.id) || !active.has(call.name) || call.argumentsError)
|
|
844
|
+
return wire.invalid();
|
|
845
|
+
seen.add(call.id);
|
|
846
|
+
pending.set(call.id, call.name);
|
|
847
|
+
}
|
|
848
|
+
if (seen.size > 512)
|
|
849
|
+
return wire.invalid();
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
blocks += typeof message.content === "string" ? 1 : message.content.length;
|
|
853
|
+
if (typeof message.content !== "string") {
|
|
854
|
+
let perMessage = 0;
|
|
855
|
+
for (const block of message.content)
|
|
856
|
+
if (block.type === "image") {
|
|
857
|
+
images++;
|
|
858
|
+
perMessage++;
|
|
859
|
+
const padding = block.data.endsWith("==") ? 2 : block.data.endsWith("=") ? 1 : 0;
|
|
860
|
+
const decoded = (block.data.length / 4) * 3 - padding;
|
|
861
|
+
if (decoded > 3145728)
|
|
862
|
+
return wire.invalid();
|
|
863
|
+
imageBytes += decoded;
|
|
864
|
+
}
|
|
865
|
+
if (perMessage > 4)
|
|
866
|
+
return wire.invalid();
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (pending.size || blocks > 2048 || images > 4 || imageBytes > 8388608)
|
|
870
|
+
return wire.invalid();
|
|
871
|
+
const choice = result.options?.toolChoice;
|
|
872
|
+
if (choice !== undefined && (!active.size || (typeof choice === "object" && !active.has(choice.function.name))))
|
|
873
|
+
return wire.invalid();
|
|
874
|
+
// Count the raw envelope, including ignored bookkeeping, with only actual image payloads emptied.
|
|
875
|
+
const nonImage = wire.jsonBytes(raw) -
|
|
876
|
+
messages.reduce((sum, message) => sum +
|
|
877
|
+
(typeof message.content === "string"
|
|
878
|
+
? 0
|
|
879
|
+
: message.content.reduce((n, block) => n + (block.type === "image" ? block.data.length : 0), 0)), 0);
|
|
880
|
+
if (nonImage > 1048576)
|
|
881
|
+
return wire.invalid();
|
|
882
|
+
return result;
|
|
883
|
+
}
|
|
884
|
+
export function parseHcodePiUsage(value) {
|
|
885
|
+
const v = wire.object(value, [
|
|
886
|
+
"input",
|
|
887
|
+
"output",
|
|
888
|
+
"cacheRead",
|
|
889
|
+
"cacheWrite",
|
|
890
|
+
"totalTokens",
|
|
891
|
+
"reasoning",
|
|
892
|
+
"cacheWrite1h",
|
|
893
|
+
"usageIncomplete",
|
|
894
|
+
"cost",
|
|
895
|
+
]);
|
|
896
|
+
const input = wire.integer(v.input, 2147483647), output = wire.integer(v.output, 2147483647), cacheRead = wire.integer(v.cacheRead, 2147483647), cacheWrite = wire.integer(v.cacheWrite, 2147483647), totalTokens = wire.integer(v.totalTokens, 2147483647);
|
|
897
|
+
if (totalTokens !== input + output + cacheRead + cacheWrite)
|
|
898
|
+
return wire.invalid();
|
|
899
|
+
const cost = wire.object(v.cost, ["input", "output", "cacheRead", "cacheWrite", "total", "totalFromProvider"]);
|
|
900
|
+
const costResult = {
|
|
901
|
+
input: wire.number(cost.input, 0, Number.MAX_SAFE_INTEGER),
|
|
902
|
+
output: wire.number(cost.output, 0, Number.MAX_SAFE_INTEGER),
|
|
903
|
+
cacheRead: wire.number(cost.cacheRead, 0, Number.MAX_SAFE_INTEGER),
|
|
904
|
+
cacheWrite: wire.number(cost.cacheWrite, 0, Number.MAX_SAFE_INTEGER),
|
|
905
|
+
total: wire.number(cost.total, 0, Number.MAX_SAFE_INTEGER),
|
|
906
|
+
...(cost.totalFromProvider === undefined
|
|
907
|
+
? {}
|
|
908
|
+
: { totalFromProvider: wire.literal(cost.totalFromProvider, false) }),
|
|
909
|
+
};
|
|
910
|
+
return {
|
|
911
|
+
input,
|
|
912
|
+
output,
|
|
913
|
+
cacheRead,
|
|
914
|
+
cacheWrite,
|
|
915
|
+
totalTokens,
|
|
916
|
+
cost: costResult,
|
|
917
|
+
...(v.reasoning === undefined ? {} : { reasoning: wire.integer(v.reasoning, output) }),
|
|
918
|
+
...(v.cacheWrite1h === undefined ? {} : { cacheWrite1h: wire.integer(v.cacheWrite1h, cacheWrite) }),
|
|
919
|
+
...(v.usageIncomplete === undefined ? {} : { usageIncomplete: wire.boolean(v.usageIncomplete) }),
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
const safeStreamErrors = [
|
|
923
|
+
"Upstream unavailable.",
|
|
924
|
+
"Settlement unavailable.",
|
|
925
|
+
"Invalid request.",
|
|
926
|
+
"HUMAIN Code account unavailable.",
|
|
927
|
+
"Request aborted.",
|
|
928
|
+
];
|
|
929
|
+
export function parseHcodePiEvent(value) {
|
|
930
|
+
boundedJson(value, 40, 32768);
|
|
931
|
+
const v = wire.object(value, [
|
|
932
|
+
"type",
|
|
933
|
+
"contentIndex",
|
|
934
|
+
"delta",
|
|
935
|
+
"content",
|
|
936
|
+
"contentSignature",
|
|
937
|
+
"redacted",
|
|
938
|
+
"id",
|
|
939
|
+
"toolName",
|
|
940
|
+
"toolCall",
|
|
941
|
+
"reason",
|
|
942
|
+
"usage",
|
|
943
|
+
"errorMessage",
|
|
944
|
+
"responseId",
|
|
945
|
+
"responseModel",
|
|
946
|
+
"providerThinkingLevel",
|
|
947
|
+
]);
|
|
948
|
+
if (v.type === "start") {
|
|
949
|
+
wire.object(value, ["type"]);
|
|
950
|
+
return { type: "start" };
|
|
951
|
+
}
|
|
952
|
+
if (v.type === "done" || v.type === "error") {
|
|
953
|
+
wire.object(value, [
|
|
954
|
+
"type",
|
|
955
|
+
"reason",
|
|
956
|
+
"usage",
|
|
957
|
+
"responseId",
|
|
958
|
+
"responseModel",
|
|
959
|
+
"providerThinkingLevel",
|
|
960
|
+
...(v.type === "error" ? ["errorMessage"] : []),
|
|
961
|
+
]);
|
|
962
|
+
const terminal = {
|
|
963
|
+
usage: parseHcodePiUsage(v.usage),
|
|
964
|
+
...(v.responseId === undefined ? {} : { responseId: ascii(v.responseId) }),
|
|
965
|
+
...(v.responseModel === undefined ? {} : { responseModel: scalar(v.responseModel, 256, 1) }),
|
|
966
|
+
...(v.providerThinkingLevel === undefined
|
|
967
|
+
? {}
|
|
968
|
+
: { providerThinkingLevel: ascii(v.providerThinkingLevel, 128) }),
|
|
969
|
+
};
|
|
970
|
+
if (v.type === "done") {
|
|
971
|
+
if (terminal.usage.usageIncomplete === true)
|
|
972
|
+
return wire.invalid();
|
|
973
|
+
return { type: "done", reason: wire.member(v.reason, ["stop", "length", "toolUse"]), ...terminal };
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
type: "error",
|
|
977
|
+
reason: wire.member(v.reason, ["aborted", "error"]),
|
|
978
|
+
...terminal,
|
|
979
|
+
...(v.errorMessage === undefined ? {} : { errorMessage: wire.member(v.errorMessage, safeStreamErrors) }),
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
const contentIndex = wire.integer(v.contentIndex, 2047);
|
|
983
|
+
if (v.type === "text_start" || v.type === "thinking_start") {
|
|
984
|
+
wire.object(value, ["type", "contentIndex"]);
|
|
985
|
+
return { type: v.type, contentIndex };
|
|
986
|
+
}
|
|
987
|
+
if (v.type === "text_delta" || v.type === "thinking_delta" || v.type === "toolcall_delta") {
|
|
988
|
+
wire.object(value, ["type", "contentIndex", "delta"]);
|
|
989
|
+
return { type: v.type, contentIndex, delta: scalar(v.delta, v.type === "toolcall_delta" ? 65536 : 1048576) };
|
|
990
|
+
}
|
|
991
|
+
if (v.type === "text_end" || v.type === "thinking_end") {
|
|
992
|
+
wire.object(value, [
|
|
993
|
+
"type",
|
|
994
|
+
"contentIndex",
|
|
995
|
+
"content",
|
|
996
|
+
"contentSignature",
|
|
997
|
+
...(v.type === "thinking_end" ? ["redacted"] : []),
|
|
998
|
+
]);
|
|
999
|
+
const end = {
|
|
1000
|
+
contentIndex,
|
|
1001
|
+
content: scalar(v.content, 8388608),
|
|
1002
|
+
...(v.contentSignature === undefined ? {} : { contentSignature: scalar(v.contentSignature, 262144) }),
|
|
1003
|
+
};
|
|
1004
|
+
if (v.type === "text_end")
|
|
1005
|
+
return { type: "text_end", ...end };
|
|
1006
|
+
const redacted = v.redacted === undefined ? undefined : wire.boolean(v.redacted);
|
|
1007
|
+
if (redacted && (!end.contentSignature || end.content !== ""))
|
|
1008
|
+
return wire.invalid();
|
|
1009
|
+
return { type: "thinking_end", ...end, ...(redacted === undefined ? {} : { redacted }) };
|
|
1010
|
+
}
|
|
1011
|
+
if (v.type === "toolcall_start") {
|
|
1012
|
+
wire.object(value, ["type", "contentIndex", "id", "toolName"]);
|
|
1013
|
+
return { type: "toolcall_start", contentIndex, id: ascii(v.id), toolName: toolName(v.toolName) };
|
|
1014
|
+
}
|
|
1015
|
+
wire.object(value, ["type", "contentIndex", "toolCall"]);
|
|
1016
|
+
return { type: wire.literal(v.type, "toolcall_end"), contentIndex, toolCall: toolCall(v.toolCall) };
|
|
1017
|
+
}
|
|
1018
|
+
export function createHcodePiEventValidator() {
|
|
1019
|
+
let started = false, terminal = false, failed = false, retained = 0, malformed = false;
|
|
1020
|
+
const blocks = [], ids = new Set();
|
|
1021
|
+
return {
|
|
1022
|
+
parse(value) {
|
|
1023
|
+
try {
|
|
1024
|
+
if (terminal || failed)
|
|
1025
|
+
return wire.invalid();
|
|
1026
|
+
const event = parseHcodePiEvent(value);
|
|
1027
|
+
if (event.type === "start") {
|
|
1028
|
+
if (started)
|
|
1029
|
+
return wire.invalid();
|
|
1030
|
+
started = true;
|
|
1031
|
+
return event;
|
|
1032
|
+
}
|
|
1033
|
+
if (!started)
|
|
1034
|
+
return wire.invalid();
|
|
1035
|
+
if (event.type === "done" || event.type === "error") {
|
|
1036
|
+
if (event.type === "done" && (blocks.some((b) => !b.ended) || malformed))
|
|
1037
|
+
return wire.invalid();
|
|
1038
|
+
terminal = true;
|
|
1039
|
+
return event;
|
|
1040
|
+
}
|
|
1041
|
+
const kind = event.type.slice(0, event.type.indexOf("_"));
|
|
1042
|
+
if (event.type.endsWith("_start")) {
|
|
1043
|
+
if (event.contentIndex !== blocks.length)
|
|
1044
|
+
return wire.invalid();
|
|
1045
|
+
if (event.type === "toolcall_start") {
|
|
1046
|
+
if (ids.has(event.id) || ids.size >= 64)
|
|
1047
|
+
return wire.invalid();
|
|
1048
|
+
ids.add(event.id);
|
|
1049
|
+
blocks.push({ kind, ended: false, bytes: 0, id: event.id, name: event.toolName });
|
|
1050
|
+
}
|
|
1051
|
+
else
|
|
1052
|
+
blocks.push({ kind, ended: false, bytes: 0 });
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
const block = blocks[event.contentIndex];
|
|
1056
|
+
if (!block || block.ended || block.kind !== kind)
|
|
1057
|
+
return wire.invalid();
|
|
1058
|
+
if ("delta" in event) {
|
|
1059
|
+
const n = bytes(event.delta);
|
|
1060
|
+
block.bytes += n;
|
|
1061
|
+
retained += n;
|
|
1062
|
+
if (kind === "toolcall" && block.bytes > 65536)
|
|
1063
|
+
return wire.invalid();
|
|
1064
|
+
}
|
|
1065
|
+
else {
|
|
1066
|
+
let n;
|
|
1067
|
+
if (event.type === "toolcall_end") {
|
|
1068
|
+
if (event.toolCall.id !== block.id || event.toolCall.name !== block.name)
|
|
1069
|
+
return wire.invalid();
|
|
1070
|
+
malformed ||= event.toolCall.argumentsError !== undefined;
|
|
1071
|
+
n = wire.jsonBytes(event.toolCall);
|
|
1072
|
+
}
|
|
1073
|
+
else if (event.type === "text_end" || event.type === "thinking_end")
|
|
1074
|
+
n = bytes(event.content) + bytes(event.contentSignature ?? "");
|
|
1075
|
+
else
|
|
1076
|
+
return wire.invalid();
|
|
1077
|
+
retained += n - block.bytes;
|
|
1078
|
+
block.bytes = n;
|
|
1079
|
+
block.ended = true;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (retained > 8388608)
|
|
1083
|
+
return wire.invalid();
|
|
1084
|
+
return event;
|
|
1085
|
+
}
|
|
1086
|
+
catch {
|
|
1087
|
+
failed = true;
|
|
1088
|
+
return wire.invalid();
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
finish() {
|
|
1092
|
+
if (failed || !started || !terminal)
|
|
1093
|
+
return wire.invalid();
|
|
1094
|
+
},
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
const snapshotFields = [
|
|
1098
|
+
"asOf",
|
|
1099
|
+
"currency",
|
|
1100
|
+
"unit",
|
|
1101
|
+
"period",
|
|
1102
|
+
"allowance",
|
|
1103
|
+
"actual",
|
|
1104
|
+
"reserved",
|
|
1105
|
+
"committed",
|
|
1106
|
+
"remaining",
|
|
1107
|
+
"costComplete",
|
|
1108
|
+
];
|
|
1109
|
+
function checkAllowanceConsistency(value) {
|
|
1110
|
+
if ((value.allowance.kind === "unlimited") !== (value.remaining.kind === "unlimited"))
|
|
1111
|
+
wire.invalid();
|
|
1112
|
+
if (value.actual.kind === "known" &&
|
|
1113
|
+
value.reserved.kind === "known" &&
|
|
1114
|
+
value.committed.kind === "known" &&
|
|
1115
|
+
(!Number.isSafeInteger(value.actual.value + value.reserved.value) ||
|
|
1116
|
+
value.committed.value !== value.actual.value + value.reserved.value))
|
|
1117
|
+
wire.invalid();
|
|
1118
|
+
if (value.allowance.kind === "limited" &&
|
|
1119
|
+
value.committed.kind === "known" &&
|
|
1120
|
+
value.remaining.kind === "known" &&
|
|
1121
|
+
value.remaining.value !== Math.max(0, value.allowance.limitMicrocents - value.committed.value))
|
|
1122
|
+
wire.invalid();
|
|
1123
|
+
}
|
|
1124
|
+
export function parseAllowanceSnapshot(value) {
|
|
1125
|
+
const v = wire.object(value, snapshotFields), period = wire.object(v.period, ["start", "resetAt"]);
|
|
1126
|
+
const start = wire.time(period.start), resetAt = wire.time(period.resetAt);
|
|
1127
|
+
if (Date.parse(start) >= Date.parse(resetAt))
|
|
1128
|
+
return wire.invalid();
|
|
1129
|
+
const r = wire.object(v.remaining, ["kind", "value"]);
|
|
1130
|
+
const remaining = r.kind === "unlimited"
|
|
1131
|
+
? { kind: wire.literal(wire.object(v.remaining, ["kind"]).kind, "unlimited") }
|
|
1132
|
+
: parseValue(v.remaining);
|
|
1133
|
+
const result = {
|
|
1134
|
+
asOf: wire.time(v.asOf),
|
|
1135
|
+
currency: wire.literal(v.currency, "USD"),
|
|
1136
|
+
unit: wire.literal(v.unit, "microcent"),
|
|
1137
|
+
period: { start, resetAt },
|
|
1138
|
+
allowance: parseAllowance(v.allowance),
|
|
1139
|
+
actual: parseValue(v.actual),
|
|
1140
|
+
reserved: parseValue(v.reserved),
|
|
1141
|
+
committed: parseValue(v.committed),
|
|
1142
|
+
remaining,
|
|
1143
|
+
costComplete: wire.boolean(v.costComplete),
|
|
1144
|
+
};
|
|
1145
|
+
checkAllowanceConsistency(result);
|
|
1146
|
+
return result;
|
|
1147
|
+
}
|
|
1148
|
+
export function parseHcodeAdminResolutionEvidence(value) {
|
|
1149
|
+
const v = wire.object(value, [
|
|
1150
|
+
"kind",
|
|
1151
|
+
"resolutionId",
|
|
1152
|
+
"environmentId",
|
|
1153
|
+
"operationId",
|
|
1154
|
+
"actorId",
|
|
1155
|
+
"at",
|
|
1156
|
+
"expectedRevision",
|
|
1157
|
+
"decision",
|
|
1158
|
+
"costMicrocents",
|
|
1159
|
+
"costSource",
|
|
1160
|
+
"basis",
|
|
1161
|
+
"reason",
|
|
1162
|
+
"evidenceReference",
|
|
1163
|
+
"tokens",
|
|
1164
|
+
]);
|
|
1165
|
+
const reason = scalar(v.reason, 2000, 1), evidenceReference = scalar(v.evidenceReference, 1024, 1);
|
|
1166
|
+
if (!reason.trim() || !evidenceReference.trim())
|
|
1167
|
+
return wire.invalid();
|
|
1168
|
+
const decision = wire.member(v.decision, ["charged", "not-charged"]), basis = wire.member(v.basis, ["provider-evidence", "no-charge-evidence", "administrative-waiver"]), costMicrocents = wire.integer(v.costMicrocents);
|
|
1169
|
+
if (decision === "charged" ? basis !== "provider-evidence" : costMicrocents !== 0 || basis === "provider-evidence")
|
|
1170
|
+
return wire.invalid();
|
|
1171
|
+
return {
|
|
1172
|
+
kind: wire.literal(v.kind, "admin-resolution"),
|
|
1173
|
+
resolutionId: wire.string(v.resolutionId),
|
|
1174
|
+
environmentId: wire.string(v.environmentId),
|
|
1175
|
+
operationId: wire.string(v.operationId),
|
|
1176
|
+
actorId: wire.string(v.actorId),
|
|
1177
|
+
at: wire.time(v.at),
|
|
1178
|
+
expectedRevision: wire.integer(v.expectedRevision),
|
|
1179
|
+
decision,
|
|
1180
|
+
costMicrocents,
|
|
1181
|
+
costSource: wire.literal(v.costSource, "admin_resolved"),
|
|
1182
|
+
basis,
|
|
1183
|
+
reason,
|
|
1184
|
+
evidenceReference,
|
|
1185
|
+
tokens: parseTokens(v.tokens),
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
const errorMessages = {
|
|
1189
|
+
unauthorized: "Authentication required.",
|
|
1190
|
+
forbidden: "Access denied.",
|
|
1191
|
+
legal_acknowledgment_required: "Legal acknowledgment required.",
|
|
1192
|
+
auth_dependency_unavailable: "Authentication unavailable.",
|
|
1193
|
+
hcode_unavailable: "HUMAIN Code account unavailable.",
|
|
1194
|
+
invalid_request: "Invalid request.",
|
|
1195
|
+
unsupported_capability: "Unsupported capability.",
|
|
1196
|
+
model_unavailable: "Model unavailable.",
|
|
1197
|
+
hcode_busy: "HUMAIN Code is busy, retry shortly.",
|
|
1198
|
+
quota_exceeded: "You've reached your monthly allowance.",
|
|
1199
|
+
idempotency_conflict: "Operation already settled.",
|
|
1200
|
+
request_in_progress: "Operation in progress.",
|
|
1201
|
+
outcome_unknown: "Operation outcome unknown.",
|
|
1202
|
+
upstream_unavailable: "Upstream unavailable.",
|
|
1203
|
+
settlement_unavailable: "Settlement unavailable.",
|
|
1204
|
+
};
|
|
1205
|
+
export const HCODE_ALLOWANCE_ESTIMATE_MESSAGE = "Your remaining monthly allowance cannot cover this request.";
|
|
1206
|
+
export function parseHcodeInferenceError(value) {
|
|
1207
|
+
const outer = wire.object(value, ["error"]), v = wire.object(outer.error, ["code", "message", "details"]);
|
|
1208
|
+
const code = wire.member(v.code, Object.keys(errorMessages));
|
|
1209
|
+
if (code === "hcode_busy") {
|
|
1210
|
+
const d = wire.object(v.details, ["dispatched", "automaticRetryAllowed", "retryAfterMs"]);
|
|
1211
|
+
return {
|
|
1212
|
+
error: {
|
|
1213
|
+
code,
|
|
1214
|
+
message: wire.literal(v.message, errorMessages[code]),
|
|
1215
|
+
details: {
|
|
1216
|
+
dispatched: wire.literal(d.dispatched, false),
|
|
1217
|
+
automaticRetryAllowed: wire.literal(d.automaticRetryAllowed, false),
|
|
1218
|
+
retryAfterMs: wire.literal(d.retryAfterMs, 1000),
|
|
1219
|
+
},
|
|
1220
|
+
},
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
if (code === "quota_exceeded") {
|
|
1224
|
+
const d = wire.object(v.details, ["dispatched", "automaticRetryAllowed", "usage"]);
|
|
1225
|
+
return {
|
|
1226
|
+
error: {
|
|
1227
|
+
code,
|
|
1228
|
+
message: wire.member(v.message, [errorMessages[code], HCODE_ALLOWANCE_ESTIMATE_MESSAGE]),
|
|
1229
|
+
details: {
|
|
1230
|
+
dispatched: wire.literal(d.dispatched, false),
|
|
1231
|
+
automaticRetryAllowed: wire.literal(d.automaticRetryAllowed, false),
|
|
1232
|
+
usage: parseAllowanceSnapshot(d.usage),
|
|
1233
|
+
},
|
|
1234
|
+
},
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
if (v.details !== null)
|
|
1238
|
+
return wire.invalid();
|
|
1239
|
+
return {
|
|
1240
|
+
error: { code, message: wire.literal(v.message, errorMessages[code]), details: null },
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
//# sourceMappingURL=contracts.js.map
|