@humain/humain-code 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/bundle/chunks/{anthropic-messages-UZB5HJE3.js → anthropic-messages-XFCDMGD6.js} +4 -4
- package/dist/bundle/chunks/{azure-openai-responses-J3LCMWPQ.js → azure-openai-responses-F4KQM3NK.js} +3 -3
- package/dist/bundle/chunks/{chunk-7EONJCBE.js → chunk-2JNJJ6SZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-3CGMVKHA.js → chunk-3E37CJCE.js} +1 -1
- package/dist/bundle/chunks/{chunk-SQ7NTRLJ.js → chunk-3PJ7NPWN.js} +20 -17
- package/dist/bundle/chunks/{chunk-WRYGY5XG.js → chunk-4MKATHT2.js} +1 -1
- package/dist/bundle/chunks/{chunk-ATFZAFMS.js → chunk-65FLSKDA.js} +1 -1
- package/dist/bundle/chunks/{chunk-P2Y2H7SD.js → chunk-6JTCRCNF.js} +2 -2
- package/dist/bundle/chunks/{chunk-CET2MXXN.js → chunk-6P6MMQUH.js} +1 -1
- package/dist/bundle/chunks/{chunk-APNPBT7Y.js → chunk-BRSLXHED.js} +1 -1
- package/dist/bundle/chunks/{chunk-KONLZKPL.js → chunk-E4VUW4RI.js} +1 -1
- package/dist/bundle/chunks/{chunk-R3VDXQW2.js → chunk-EFY2QPVP.js} +6 -6
- package/dist/bundle/chunks/{chunk-4EV7CK26.js → chunk-F2H47FRF.js} +1 -1
- package/dist/bundle/chunks/{chunk-KQXXBQ57.js → chunk-G2QMON4O.js} +382 -331
- package/dist/bundle/chunks/{chunk-TYN46EVI.js → chunk-GPLWWO5Q.js} +1 -1
- package/dist/bundle/chunks/{chunk-JV7VHOAY.js → chunk-H2B3WLIM.js} +2 -2
- package/dist/bundle/chunks/chunk-H7UPU2SH.js +2093 -0
- package/dist/bundle/chunks/{chunk-NNWNIBLG.js → chunk-JKX5EGOT.js} +1 -1
- package/dist/bundle/chunks/{chunk-4SFWYKL5.js → chunk-JQBZUFH7.js} +467 -440
- package/dist/bundle/chunks/{chunk-D3KYOSQY.js → chunk-JSHKS7VH.js} +1 -1
- package/dist/bundle/chunks/{chunk-C4DHVDYT.js → chunk-JX6YIPNK.js} +1 -1
- package/dist/bundle/chunks/{chunk-Z5UFSRO4.js → chunk-KI7CHPWC.js} +1 -1
- package/dist/bundle/chunks/{chunk-VKQNYZUA.js → chunk-KRBELWQH.js} +1 -1
- package/dist/bundle/chunks/{chunk-AI7EHDAX.js → chunk-LSRXA7OS.js} +1 -1
- package/dist/bundle/chunks/{chunk-WBSGWISD.js → chunk-M5TVWJ5T.js} +5 -4
- package/dist/bundle/chunks/{chunk-XVIQYONJ.js → chunk-MIAXMK5F.js} +1 -1
- package/dist/bundle/chunks/{chunk-WGXMYMPE.js → chunk-PFBAIRCY.js} +2 -2
- package/dist/bundle/chunks/{chunk-CU6KU7JK.js → chunk-PJXBU6CR.js} +47 -44
- package/dist/bundle/chunks/{chunk-OVDMYBIT.js → chunk-PWFM6AQQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-PGVDL4KB.js → chunk-QFDZEUFU.js} +2 -2
- package/dist/bundle/chunks/{chunk-DD5UT56Y.js → chunk-R2KD2HFT.js} +67 -66
- package/dist/bundle/chunks/{chunk-EMBIUIQ2.js → chunk-T2ZGMEMV.js} +46 -45
- package/dist/bundle/chunks/{chunk-IOLLZXQN.js → chunk-U4EAJPMO.js} +138 -126
- package/dist/bundle/chunks/chunk-UZOIHLNU.js +23 -0
- package/dist/bundle/chunks/{chunk-QRYDGY5I.js → chunk-ZSWU5KKA.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-ETKC6B2S.js → cloudflare-workers-ai-system-one-JEZVYITT.js} +1 -1
- package/dist/bundle/chunks/{compat-HS4ARZK3.js → compat-ELBUCH6U.js} +6 -6
- package/dist/bundle/chunks/{curator-server-TC7RVVN2.js → curator-server-QB4GITGS.js} +1 -1
- package/dist/bundle/chunks/{dist-NMEXYUP3.js → dist-CBODG4CA.js} +5 -5
- package/dist/bundle/chunks/{dist-5AQPJ2TI.js → dist-NERIS6SW.js} +1 -1
- package/dist/bundle/chunks/{dist-DYB3AR7C.js → dist-QSYDYE3Y.js} +7 -7
- package/dist/bundle/chunks/{easter-egg-3d-VVUF3C3X.js → easter-egg-3d-VZC5WOYV.js} +1 -1
- package/dist/bundle/chunks/{execute-I3WGGPWL.js → execute-6MEJJF2T.js} +2 -2
- package/dist/bundle/chunks/{extract-QHZTEVJP.js → extract-L373D6O7.js} +2 -2
- package/dist/bundle/chunks/{flow-implementer-QMN3HKE2.js → flow-implementer-3P3BHQ7E.js} +4 -4
- package/dist/bundle/chunks/github-copilot.js +53 -56
- package/dist/bundle/chunks/{google-generative-ai-ZND73WDQ.js → google-generative-ai-WIASMWS3.js} +2 -2
- package/dist/bundle/chunks/{google-vertex-YAH62YRM.js → google-vertex-WSPHRZIZ.js} +3 -3
- package/dist/bundle/chunks/{host-Q565BCXB.js → host-WOLZCWQQ.js} +1 -1
- package/dist/bundle/chunks/{inprocess-453SLFL5.js → inprocess-3PDJKE5F.js} +5 -5
- package/dist/bundle/chunks/interactive-mode-SDUO5OLD.js +5 -0
- package/dist/bundle/chunks/{llama-cpp-classify-Z4GZY4GC.js → llama-cpp-classify-KYZT532X.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-7I5JURDP.js → mistral-conversations-7JYDDRUT.js} +2 -2
- package/dist/bundle/chunks/{node-IMSYVRPL.js → node-N7TPBUJB.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-LTHOMN37.js → openai-codex-responses-7PAML4NF.js} +3 -3
- package/dist/bundle/chunks/{openai-completions-W2X635EE.js → openai-completions-UJDAIGTK.js} +3 -3
- package/dist/bundle/chunks/{openai-decisions-TN2GNOYI.js → openai-decisions-JMSDGR7K.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-DVY4QXOG.js → openai-responses-2WNCE6AY.js} +3 -3
- package/dist/bundle/chunks/{openrouter-images-SE2JMS44.js → openrouter-images-V3UCCO6X.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-WAS6Z5L5.js → pi-messages-TQ7LJUNQ.js} +2 -2
- package/dist/bundle/chunks/{session-picker-XNVLSJ22.js → session-picker-EYKCMFQR.js} +1 -1
- package/dist/bundle/chunks/{startup-ui-3TCT465D.js → startup-ui-7ODOR34R.js} +2 -2
- package/dist/bundle/chunks/{trace-command-7ORDQ3JS.js → trace-command-VM7FBWPE.js} +4 -4
- package/dist/bundle/chunks/{typesafe-system-one-AAZH6S3I.js → typesafe-system-one-YP7GGN4C.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-CIVXCEAN.js → virtual-modules-IU5KWB2C.js} +10 -10
- package/dist/bundle/cli-runtime.js +5 -5
- package/dist/bundle/index.js +8 -8
- package/dist/bundle/rpc-entry.js +4 -4
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +16 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/setup.d.ts +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +3 -2
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +3 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +11 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/keybindings.d.ts +24 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +12 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +13 -9
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +11 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +23 -6
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +4 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +104 -20
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +2 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +10 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/extensions/usage/confirmation.d.ts.map +1 -1
- package/dist/extensions/usage/confirmation.js +1 -1
- package/dist/extensions/usage/confirmation.js.map +1 -1
- package/dist/extensions/usage/index.js +6 -6
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/extensions/usage/panes.d.ts +5 -0
- package/dist/extensions/usage/panes.d.ts.map +1 -0
- package/dist/extensions/usage/panes.js +10 -0
- package/dist/extensions/usage/panes.js.map +1 -0
- package/dist/extensions/usage/popup.d.ts.map +1 -1
- package/dist/extensions/usage/popup.js +9 -18
- package/dist/extensions/usage/popup.js.map +1 -1
- package/dist/humain/gateway/client.d.ts.map +1 -1
- package/dist/humain/gateway/client.js +36 -9
- package/dist/humain/gateway/client.js.map +1 -1
- package/dist/humain/gateway/http.d.ts.map +1 -1
- package/dist/humain/gateway/http.js +26 -6
- package/dist/humain/gateway/http.js.map +1 -1
- package/dist/humain/gateway/provider.d.ts.map +1 -1
- package/dist/humain/gateway/provider.js +9 -2
- package/dist/humain/gateway/provider.js.map +1 -1
- package/dist/humain/hcode/contracts.d.ts +15 -0
- package/dist/humain/hcode/contracts.d.ts.map +1 -1
- package/dist/humain/hcode/contracts.js +85 -10
- package/dist/humain/hcode/contracts.js.map +1 -1
- package/dist/humain/hcode/environment.d.ts.map +1 -1
- package/dist/humain/hcode/environment.js +4 -2
- package/dist/humain/hcode/environment.js.map +1 -1
- package/dist/humain/hcode/facade.d.ts +12 -1
- package/dist/humain/hcode/facade.d.ts.map +1 -1
- package/dist/humain/hcode/facade.js +35 -8
- package/dist/humain/hcode/facade.js.map +1 -1
- package/dist/humain/hcode/images.d.ts.map +1 -1
- package/dist/humain/hcode/images.js +4 -2
- package/dist/humain/hcode/images.js.map +1 -1
- package/dist/humain/hcode/login-copy.d.ts.map +1 -1
- package/dist/humain/hcode/login-copy.js +11 -1
- package/dist/humain/hcode/login-copy.js.map +1 -1
- package/dist/humain/hcode/notices.d.ts +22 -1
- package/dist/humain/hcode/notices.d.ts.map +1 -1
- package/dist/humain/hcode/notices.js +34 -3
- package/dist/humain/hcode/notices.js.map +1 -1
- package/dist/humain/hcode/provider.d.ts +3 -1
- package/dist/humain/hcode/provider.d.ts.map +1 -1
- package/dist/humain/hcode/provider.js +126 -46
- package/dist/humain/hcode/provider.js.map +1 -1
- package/dist/humain/hcode/run-credential.d.ts +21 -0
- package/dist/humain/hcode/run-credential.d.ts.map +1 -0
- package/dist/humain/hcode/run-credential.js +140 -0
- package/dist/humain/hcode/run-credential.js.map +1 -0
- package/dist/humain/hcode/sandbox.d.ts +6 -0
- package/dist/humain/hcode/sandbox.d.ts.map +1 -0
- package/dist/humain/hcode/sandbox.js +139 -0
- package/dist/humain/hcode/sandbox.js.map +1 -0
- package/dist/humain/hcode/selection.d.ts +7 -2
- package/dist/humain/hcode/selection.d.ts.map +1 -1
- package/dist/humain/hcode/selection.js +29 -5
- package/dist/humain/hcode/selection.js.map +1 -1
- package/dist/humain/hcode/transport.d.ts +3 -2
- package/dist/humain/hcode/transport.d.ts.map +1 -1
- package/dist/humain/hcode/transport.js +22 -7
- package/dist/humain/hcode/transport.js.map +1 -1
- package/dist/humain/remote/broker.d.ts +84 -0
- package/dist/humain/remote/broker.d.ts.map +1 -0
- package/dist/humain/remote/broker.js +427 -0
- package/dist/humain/remote/broker.js.map +1 -0
- package/dist/humain/remote/deny-store.d.ts +12 -0
- package/dist/humain/remote/deny-store.d.ts.map +1 -0
- package/dist/humain/remote/deny-store.js +164 -0
- package/dist/humain/remote/deny-store.js.map +1 -0
- package/dist/humain/remote/enablement.d.ts +5 -0
- package/dist/humain/remote/enablement.d.ts.map +1 -0
- package/dist/humain/remote/enablement.js +8 -0
- package/dist/humain/remote/enablement.js.map +1 -0
- package/dist/humain/remote/environment.d.ts +11 -0
- package/dist/humain/remote/environment.d.ts.map +1 -0
- package/dist/humain/remote/environment.js +19 -0
- package/dist/humain/remote/environment.js.map +1 -0
- package/dist/humain/remote/host-watch.d.ts +21 -0
- package/dist/humain/remote/host-watch.d.ts.map +1 -0
- package/dist/humain/remote/host-watch.js +186 -0
- package/dist/humain/remote/host-watch.js.map +1 -0
- package/dist/humain/remote/ipc-posix.d.ts +5 -0
- package/dist/humain/remote/ipc-posix.d.ts.map +1 -0
- package/dist/humain/remote/ipc-posix.js +29 -0
- package/dist/humain/remote/ipc-posix.js.map +1 -0
- package/dist/humain/remote/ipc-windows.d.ts +3 -0
- package/dist/humain/remote/ipc-windows.d.ts.map +1 -0
- package/dist/humain/remote/ipc-windows.js +5 -0
- package/dist/humain/remote/ipc-windows.js.map +1 -0
- package/dist/humain/remote/ipc.d.ts +10 -0
- package/dist/humain/remote/ipc.d.ts.map +1 -0
- package/dist/humain/remote/ipc.js +19 -0
- package/dist/humain/remote/ipc.js.map +1 -0
- package/dist/humain/remote/protocol.d.ts +43 -0
- package/dist/humain/remote/protocol.d.ts.map +1 -0
- package/dist/humain/remote/protocol.js +76 -0
- package/dist/humain/remote/protocol.js.map +1 -0
- package/dist/humain/remote/relay-socket.d.ts +30 -0
- package/dist/humain/remote/relay-socket.d.ts.map +1 -0
- package/dist/humain/remote/relay-socket.js +137 -0
- package/dist/humain/remote/relay-socket.js.map +1 -0
- package/dist/humain/remote/secure-channel.d.ts +10 -0
- package/dist/humain/remote/secure-channel.d.ts.map +1 -0
- package/dist/humain/remote/secure-channel.js +5 -0
- package/dist/humain/remote/secure-channel.js.map +1 -0
- package/dist/humain/remote/terminal.d.ts +48 -0
- package/dist/humain/remote/terminal.d.ts.map +1 -0
- package/dist/humain/remote/terminal.js +119 -0
- package/dist/humain/remote/terminal.js.map +1 -0
- package/dist/humain/remote/tickets.d.ts +35 -0
- package/dist/humain/remote/tickets.d.ts.map +1 -0
- package/dist/humain/remote/tickets.js +132 -0
- package/dist/humain/remote/tickets.js.map +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/account-picker.d.ts +31 -0
- package/dist/modes/interactive/components/account-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/account-picker.js +150 -0
- package/dist/modes/interactive/components/account-picker.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +26 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +35 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +179 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/working-indicator-engine.d.ts +32 -0
- package/dist/modes/interactive/components/working-indicator-engine.d.ts.map +1 -0
- package/dist/modes/interactive/components/working-indicator-engine.js +112 -0
- package/dist/modes/interactive/components/working-indicator-engine.js.map +1 -0
- package/dist/modes/interactive/fullscreen.d.ts +13 -0
- package/dist/modes/interactive/fullscreen.d.ts.map +1 -0
- package/dist/modes/interactive/fullscreen.js +25 -0
- package/dist/modes/interactive/fullscreen.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +19 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +341 -54
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/oauth-account-format.d.ts +9 -0
- package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
- package/dist/modes/interactive/oauth-account-format.js +31 -22
- package/dist/modes/interactive/oauth-account-format.js.map +1 -1
- package/dist/modes/interactive/theme/humain-dark.json +5 -4
- package/dist/modes/interactive/theme/humain-light.json +6 -5
- package/docs/cli.md +1 -1
- package/docs/development.md +7 -0
- package/docs/forge-run-bootstrap.md +46 -0
- package/docs/humain-code.md +2 -2
- package/docs/index.md +2 -1
- package/docs/keybindings.md +10 -0
- package/docs/providers.md +16 -6
- package/docs/quickstart.md +16 -2
- package/docs/settings.md +20 -0
- package/docs/slash-commands.md +4 -2
- package/docs/usage.md +2 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/keybindings.schema.json +12 -0
- package/schemas/settings.schema.json +29 -0
- package/dist/bundle/chunks/chunk-IXQYPQRQ.js +0 -2079
- package/dist/bundle/chunks/chunk-J5TSAJGC.js +0 -22
- package/dist/bundle/chunks/chunk-YPZPCHNV.js +0 -3
- package/dist/bundle/chunks/interactive-mode-MVZOJ5OU.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-copy.js","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMpD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GACxC,iPAAiP,CAAC;AAEnP,MAAM,aAAa,GAA+E;IACjG,sBAAsB,EAAE;QACvB,MAAM,EAAE,8BAA8B;QACtC,GAAG,EAAE,kFAAkF;KACvF;IACD,4BAA4B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,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,sFAAsF,gBAAgB,CAAC,KAAK,CAAC,oDAAoD,KAAK,wCAAwC,CAAC;AACzP,CAAC","sourcesContent":["// Plain-language HUMAIN Code readiness and empty-catalog copy; HTTP messages are sanitized at the facade boundary.\nimport type { HcodeCatalogEmptyReason } from \"./contracts.ts\";\nimport { hcodeDisplayName } from \"./environment.ts\";\nimport type { HcodeLoginReadiness } from \"./facade.ts\";\n\n/** Why a signed-in account has no models: Forge's reason (if it sent one), or the list couldn't be loaded. */\nexport type HcodeEmptyCatalogCause = { kind: \"empty\"; reason?: HcodeCatalogEmptyReason } | { kind: \"failed\" };\n\n/** Guidance for a direct login when the server's sign-in settings don't match this CLI. */\nexport const HCODE_LOGIN_MISMATCH_DETAILS =\n\t\"HUMAIN Code's sign-in settings (/api/cli/config or issuer discovery) don't match what this CLI version accepts. Update the CLI with `humain-code update`, or ask the HUMAIN Code platform team to check the server's CLI sign-in configuration.\";\n\nconst EMPTY_REASONS: Readonly<Record<HcodeCatalogEmptyReason, { reason: string; fix: string }>> = {\n\tno_cli_models_approved: {\n\t\treason: \"no model is approved for CLI\",\n\t\tfix: \"Ask an admin to set a model to Web + CLI or CLI only in Settings > Model Access.\",\n\t},\n\tprovider_key_not_cli_enabled: {\n\t\treason: \"the provider key isn't enabled for CLI\",\n\t\tfix: \"Ask an admin to enable CLI on the key in Settings > Provider Keys.\",\n\t},\n\tcli_capacity_unconfigured: {\n\t\treason: \"CLI capacity hasn't been configured\",\n\t\tfix: \"Ask the HUMAIN Code platform team to check the deployment's CLI capacity limits.\",\n\t},\n\tprovider_key_not_dedicated: {\n\t\treason: \"the provider key is shared or isn't approved for CLI use\",\n\t\tfix: \"Ask an admin to configure a dedicated key for HUMAIN Code CLI.\",\n\t},\n\tmodels_not_qualified: {\n\t\treason: \"this server hasn't finished CLI setup for the approved models\",\n\t\tfix: \"Ask an admin to report it to the HUMAIN Code platform team.\",\n\t},\n};\n\n/** Say why the account's catalog is empty and what to do; servers without a reason keep the generic text. */\nexport function hcodeEmptyCatalogMessage(reason: HcodeCatalogEmptyReason | undefined): string {\n\tif (!reason) return \"Your admin hasn't enabled CLI models yet.\";\n\tconst { reason: why, fix } = EMPTY_REASONS[reason];\n\treturn `No models are available in the CLI: ${why}. ${fix}`;\n}\n\n/** The short reason and who can fix it: an admin, the server's configuration or the network. */\nexport function hcodeEmptyCatalogReason(cause: HcodeEmptyCatalogCause): { reason: string; fix: string } {\n\tif (cause.kind === \"failed\")\n\t\treturn { reason: \"the model list couldn't be loaded\", fix: \"Check your network, VPN or Zscaler.\" };\n\treturn cause.reason\n\t\t? EMPTY_REASONS[cause.reason]\n\t\t: { reason: \"your admin hasn't enabled CLI models yet\", fix: \"Ask an admin to enable a model for CLI.\" };\n}\n\n/** Non-blocking notice after a sign-in that produced no models. */\nexport function hcodeEmptyCatalogNotice(\n\tenvironmentId: string,\n\temail: string | undefined,\n\tcause: HcodeEmptyCatalogCause,\n): string {\n\tconst { reason, fix } = hcodeEmptyCatalogReason(cause);\n\treturn [\n\t\t`✓ Signed in to ${hcodeDisplayName(environmentId)}${email ? ` as ${email}` : \"\"}`,\n\t\t` No models available in the CLI yet: ${reason}.`,\n\t\t` ${fix}`,\n\t\t\" You can keep using your other providers. I'll check again automatically.\",\n\t\t\" /model to retry · /login status for details\",\n\t].join(\"\\n\");\n}\n\n/** `/login` row state for a readiness check; `undefined` means the check is still running. */\nexport function hcodeLoginAvailability(readiness: HcodeLoginReadiness | undefined): {\n\tstate: \"pending\" | \"ready\" | \"failed\";\n\ttext: string;\n} {\n\tif (!readiness) return { state: \"pending\", text: \"checking connection…\" };\n\tswitch (readiness.kind) {\n\t\tcase \"ready\":\n\t\t\treturn { state: \"ready\", text: \"connected\" };\n\t\tcase \"unreachable\":\n\t\t\treturn { state: \"failed\", text: `Can't reach ${readiness.host}: check VPN/Zscaler [Retry]` };\n\t\tcase \"not-configured\":\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\ttext: `HUMAIN Code isn't available on ${readiness.environmentId} yet (server: hcode_unavailable). Try another environment or contact support. [Retry]`,\n\t\t\t};\n\t\tcase \"http-error\":\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\ttext: `Sign-in server returned HTTP ${readiness.status}${readiness.message ? `: ${readiness.message}` : \".\"} [Retry]`,\n\t\t\t};\n\t\tcase \"mismatch\":\n\t\t\treturn { state: \"failed\", text: \"Server sign-in settings don't match this CLI version [Details]\" };\n\t\tcase \"unavailable\":\n\t\t\treturn { state: \"failed\", text: \"Sign-in is not available in this environment [Retry]\" };\n\t}\n}\n\n/** Says that the saved sign-in belongs to another environment and how to use it, e.g. after starting without --env. */\nexport function hcodeSignedInElsewhereNotice(environmentId: string, elsewhere: readonly string[]): string | undefined {\n\tconst other = elsewhere[0];\n\tif (!other) return undefined;\n\treturn `${hcodeDisplayName(environmentId)}: not signed in. HUMAIN Code now defaults to production. Your saved sign-in is for ${hcodeDisplayName(other)} and was not moved: start humain-code with --env ${other} to use it, or /login to sign in here.`;\n}\n"]}
|
|
@@ -2,7 +2,9 @@ import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
|
2
2
|
import { type HcodeInferenceError } from "./contracts.ts";
|
|
3
3
|
export declare const HCODE_PENDING_EXPLANATION = "Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.";
|
|
4
4
|
export declare const HCODE_AMBIGUOUS_NOTICE = "HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.";
|
|
5
|
+
export declare const BUILD_SESSION_ENDED = "Build session ended. Start a new Build run.";
|
|
5
6
|
declare const localReasons: {
|
|
7
|
+
readonly buildSessionEnded: "Build session ended. Start a new Build run.";
|
|
6
8
|
readonly account: "The selected HUMAIN Code account or model is no longer current.";
|
|
7
9
|
readonly transport: "HUMAIN Code only supports SSE for this request.";
|
|
8
10
|
readonly envelope: "The CLI could not build a valid HUMAIN Code request envelope.";
|
|
@@ -17,13 +19,32 @@ declare const localReasons: {
|
|
|
17
19
|
readonly cancelled: "The HUMAIN Code request was cancelled before submission.";
|
|
18
20
|
};
|
|
19
21
|
export type HcodeLocalReason = keyof typeof localReasons;
|
|
22
|
+
declare const localDetails: {
|
|
23
|
+
readonly messageLimit: readonly ["context.messages", "History exceeds 512 messages; compact the session before retrying."];
|
|
24
|
+
readonly schema: readonly ["$", "Request structure failed local schema validation."];
|
|
25
|
+
readonly "message.schema": readonly ["context.messages", "History failed local schema validation."];
|
|
26
|
+
readonly "system.schema": readonly ["context.messages[*]", "A system message failed local schema validation."];
|
|
27
|
+
readonly "user.schema": readonly ["context.messages[*]", "A user message failed local schema validation."];
|
|
28
|
+
readonly "assistant.schema": readonly ["context.messages[*]", "An assistant message failed local schema validation."];
|
|
29
|
+
readonly "assistant.deferred": readonly ["context.messages[*]", "Assistant history contains a deferred response."];
|
|
30
|
+
readonly "toolCall.schema": readonly ["context.messages[*].content[*]", "A tool call failed local schema validation."];
|
|
31
|
+
readonly "toolCall.orphan": readonly ["context.messages[*].content[*]", "Tool-call history is missing a matching result."];
|
|
32
|
+
readonly "toolCall.unknownTool": readonly ["context.messages[*].content[*].name", "Tool-call history references an unavailable tool."];
|
|
33
|
+
readonly "toolCall.argumentsError": readonly ["context.messages[*].content[*].argumentsError", "Tool-call history contains invalid arguments."];
|
|
34
|
+
readonly "toolCall.duplicate": readonly ["context.messages[*].content[*].id", "Tool-call history contains a repeated call."];
|
|
35
|
+
readonly "toolResult.schema": readonly ["context.messages[*]", "A tool result failed local schema validation."];
|
|
36
|
+
readonly "toolResult.orphan": readonly ["context.messages[*]", "Tool-result history has no matching call."];
|
|
37
|
+
readonly "options.schema": readonly ["options", "Request options failed local schema validation."];
|
|
38
|
+
readonly "toolChoice.unknownTool": readonly ["options.toolChoice", "The current tool choice is unavailable."];
|
|
39
|
+
};
|
|
40
|
+
export type HcodeLocalDetail = keyof typeof localDetails;
|
|
20
41
|
/** Header names and closed reason values Forge sends with deterministic refusals. */
|
|
21
42
|
export declare const HCODE_REFUSAL_REASON_HEADERS: {
|
|
22
43
|
readonly model_unavailable: readonly ["x-hcode-model-unavailable-reason", string[]];
|
|
23
44
|
readonly unsupported_capability: readonly ["x-hcode-unsupported-capability-reason", string[]];
|
|
24
45
|
};
|
|
25
46
|
/** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */
|
|
26
|
-
export declare function formatHcodeLocalRefusal(reason: unknown): string | undefined;
|
|
47
|
+
export declare function formatHcodeLocalRefusal(reason: unknown, detail?: unknown): string | undefined;
|
|
27
48
|
/** Format the server's reset instant in UTC, independently of the host timezone. */
|
|
28
49
|
export declare function formatHcodeReset(resetAt: string): string;
|
|
29
50
|
/** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notices.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,mBAAmB,EAA6C,MAAM,gBAAgB,CAAC;AAGrG,eAAO,MAAM,yBAAyB,kKAC0H,CAAC;AAEjK,eAAO,MAAM,sBAAsB,iJAC4G,CAAC;AAEhJ,QAAA,MAAM,YAAY;aACjB,OAAO,EAAE,iEAAiE;aAC1E,SAAS,EAAE,iDAAiD;aAC5D,QAAQ,EAAE,+DAA+D;aACzE,IAAI,EAAE,iEAAiE;aACvE,KAAK,EAAE,kEAAkE;aACzE,SAAS,EAAE,mGAAmG;aAC9G,MAAM,EAAE,yEAAyE;aACjF,KAAK,EAAE,sDAAsD;aAC7D,KAAK,EAAE,wDAAwD;aAC/D,WAAW,EAAE,6DAA6D;aAC1E,MAAM,EAAE,6EAA6E;aACrF,SAAS,E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} from "./http.js";
|
|
3
3
|
export const HCODE_PENDING_EXPLANATION = "Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.";
|
|
4
4
|
export const HCODE_AMBIGUOUS_NOTICE = "HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.";
|
|
5
|
+
export const BUILD_SESSION_ENDED = "Build session ended. Start a new Build run.";
|
|
5
6
|
const localReasons = {
|
|
7
|
+
buildSessionEnded: BUILD_SESSION_ENDED,
|
|
6
8
|
account: "The selected HUMAIN Code account or model is no longer current.",
|
|
7
9
|
transport: "HUMAIN Code only supports SSE for this request.",
|
|
8
10
|
envelope: "The CLI could not build a valid HUMAIN Code request envelope.",
|
|
@@ -16,6 +18,27 @@ const localReasons = {
|
|
|
16
18
|
images: "An image is unsupported or exceeds the selected HUMAIN Code model's limits.",
|
|
17
19
|
cancelled: "The HUMAIN Code request was cancelled before submission.",
|
|
18
20
|
};
|
|
21
|
+
const localDetails = {
|
|
22
|
+
messageLimit: ["context.messages", "History exceeds 512 messages; compact the session before retrying."],
|
|
23
|
+
schema: ["$", "Request structure failed local schema validation."],
|
|
24
|
+
"message.schema": ["context.messages", "History failed local schema validation."],
|
|
25
|
+
"system.schema": ["context.messages[*]", "A system message failed local schema validation."],
|
|
26
|
+
"user.schema": ["context.messages[*]", "A user message failed local schema validation."],
|
|
27
|
+
"assistant.schema": ["context.messages[*]", "An assistant message failed local schema validation."],
|
|
28
|
+
"assistant.deferred": ["context.messages[*]", "Assistant history contains a deferred response."],
|
|
29
|
+
"toolCall.schema": ["context.messages[*].content[*]", "A tool call failed local schema validation."],
|
|
30
|
+
"toolCall.orphan": ["context.messages[*].content[*]", "Tool-call history is missing a matching result."],
|
|
31
|
+
"toolCall.unknownTool": ["context.messages[*].content[*].name", "Tool-call history references an unavailable tool."],
|
|
32
|
+
"toolCall.argumentsError": [
|
|
33
|
+
"context.messages[*].content[*].argumentsError",
|
|
34
|
+
"Tool-call history contains invalid arguments.",
|
|
35
|
+
],
|
|
36
|
+
"toolCall.duplicate": ["context.messages[*].content[*].id", "Tool-call history contains a repeated call."],
|
|
37
|
+
"toolResult.schema": ["context.messages[*]", "A tool result failed local schema validation."],
|
|
38
|
+
"toolResult.orphan": ["context.messages[*]", "Tool-result history has no matching call."],
|
|
39
|
+
"options.schema": ["options", "Request options failed local schema validation."],
|
|
40
|
+
"toolChoice.unknownTool": ["options.toolChoice", "The current tool choice is unavailable."],
|
|
41
|
+
};
|
|
19
42
|
/** Forge's closed `x-hcode-model-unavailable-reason` values, in plain words. */
|
|
20
43
|
const modelUnavailableReasons = {
|
|
21
44
|
catalog_entry_unavailable: "This model is no longer in your HUMAIN Code catalog.",
|
|
@@ -69,10 +92,18 @@ function refusalReason(code, reason) {
|
|
|
69
92
|
return Object.hasOwn(table, reason) ? table[reason] : undefined;
|
|
70
93
|
}
|
|
71
94
|
/** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */
|
|
72
|
-
export function formatHcodeLocalRefusal(reason) {
|
|
95
|
+
export function formatHcodeLocalRefusal(reason, detail) {
|
|
73
96
|
if (typeof reason !== "string" || !Object.hasOwn(localReasons, reason))
|
|
74
97
|
return undefined;
|
|
75
|
-
|
|
98
|
+
if (reason === "buildSessionEnded")
|
|
99
|
+
return BUILD_SESSION_ENDED;
|
|
100
|
+
// Persisted diagnostics are untrusted: only closed detail codes may affect presentation.
|
|
101
|
+
let explanation = "";
|
|
102
|
+
if (reason === "envelope" && typeof detail === "string" && Object.hasOwn(localDetails, detail)) {
|
|
103
|
+
const [path, message] = localDetails[detail];
|
|
104
|
+
explanation = ` ${message} [${detail} at ${path}]`;
|
|
105
|
+
}
|
|
106
|
+
return `${localReasons[reason]}${explanation} No request was sent or charged.`;
|
|
76
107
|
}
|
|
77
108
|
/** Format the server's reset instant in UTC, independently of the host timezone. */
|
|
78
109
|
export function formatHcodeReset(resetAt) {
|
|
@@ -135,7 +166,7 @@ export function formatHcodeMessageNotice(message) {
|
|
|
135
166
|
return undefined;
|
|
136
167
|
if (message.stopReason === "error") {
|
|
137
168
|
const diagnostic = message.diagnostics?.findLast((entry) => entry.type === "provider_http_error");
|
|
138
|
-
const local = formatHcodeLocalRefusal(diagnostic?.details?.hcodeLocalReason);
|
|
169
|
+
const local = formatHcodeLocalRefusal(diagnostic?.details?.hcodeLocalReason, diagnostic?.details?.hcodeLocalDetail);
|
|
139
170
|
if (local)
|
|
140
171
|
return local;
|
|
141
172
|
const refusal = diagnostic?.details?.hcode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notices.js","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GACrC,+JAA+J,CAAC;AAEjK,MAAM,CAAC,MAAM,sBAAsB,GAClC,8IAA8I,CAAC;AAEhJ,MAAM,YAAY,GAAG;IACpB,OAAO,EAAE,iEAAiE;IAC1E,SAAS,EAAE,iDAAiD;IAC5D,QAAQ,EAAE,+DAA+D;IACzE,IAAI,EAAE,iEAAiE;IACvE,KAAK,EAAE,kEAAkE;IACzE,SAAS,EAAE,mGAAmG;IAC9G,MAAM,EAAE,yEAAyE;IACjF,KAAK,EAAE,sDAAsD;IAC7D,KAAK,EAAE,wDAAwD;IAC/D,WAAW,EAAE,6DAA6D;IAC1E,MAAM,EAAE,6EAA6E;IACrF,SAAS,EAAE,0DAA0D;CAC5D,CAAC;AAIX,gFAAgF;AAChF,MAAM,uBAAuB,GAAG;IAC/B,yBAAyB,EAAE,sDAAsD;IACjF,sBAAsB,EAAE,wDAAwD;IAChF,iCAAiC,EAAE,wDAAwD;IAC3F,mCAAmC,EAAE,2DAA2D;IAChG,yBAAyB,EAAE,yDAAyD;IACpF,qBAAqB,EAAE,8CAA8C;IACrE,4B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AAM,MAAM,GAAG,iBAAiB,CAC/B,wBAAwB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAClD,UAAW,CAAC,SAAS,EACrB,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAChD,CAAC;gBACF,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACR,sFAAsF;YACvF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,sBAAsB,CAAC;AAC/B,CAAC","sourcesContent":["// Local, typed presentation of managed refusal facts; never schedules a request or reads a later balance.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type HcodeInferenceError, type HcodeValue, parseHcodeInferenceError } from \"./contracts.ts\";\nimport { HCODE_PROVIDER } from \"./http.ts\";\n\nexport const HCODE_PENDING_EXPLANATION =\n\t\"Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.\";\n\nexport const HCODE_AMBIGUOUS_NOTICE =\n\t\"HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.\";\n\nconst localReasons = {\n\taccount: \"The selected HUMAIN Code account or model is no longer current.\",\n\ttransport: \"HUMAIN Code only supports SSE for this request.\",\n\tenvelope: \"The CLI could not build a valid HUMAIN Code request envelope.\",\n\tsize: \"The request exceeds the HUMAIN Code model's request size limit.\",\n\tmodel: \"The request model does not match the selected HUMAIN Code model.\",\n\treasoning: \"The selected HUMAIN Code model does not support the requested thinking level or thinking history.\",\n\toutput: \"The requested output token limit exceeds the HUMAIN Code model's limit.\",\n\tcache: \"HUMAIN Code requires cache retention to be disabled.\",\n\ttools: \"The selected HUMAIN Code model does not support tools.\",\n\tstrictTools: \"HUMAIN Code does not support required strict tool sampling.\",\n\timages: \"An image is unsupported or exceeds the selected HUMAIN Code model's limits.\",\n\tcancelled: \"The HUMAIN Code request was cancelled before submission.\",\n} as const;\n\nexport type HcodeLocalReason = keyof typeof localReasons;\n\n/** Forge's closed `x-hcode-model-unavailable-reason` values, in plain words. */\nconst modelUnavailableReasons = {\n\tcatalog_entry_unavailable: \"This model is no longer in your HUMAIN Code catalog.\",\n\tcredential_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\texecution_credentials_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\tprovider_quota_isolation_unverified: \"This model's provider key isn't dedicated to HUMAIN Code.\",\n\tquota_mapping_unavailable: \"This model's capacity isn't set up for HUMAIN Code yet.\",\n\tconfiguration_changed: \"An admin changed this model's configuration.\",\n\texecution_config_unavailable: \"HUMAIN Code couldn't load this model's configuration.\",\n\texecution_model_mismatch: \"HUMAIN Code's configuration for this model doesn't match its catalog entry.\",\n\texecution_endpoint_mismatch: \"HUMAIN Code's endpoint for this model doesn't match its catalog entry.\",\n\texecution_region_mismatch: \"HUMAIN Code's provider key is set to a region this model can't run in.\",\n} as const;\n\n/** Forge's closed `x-hcode-unsupported-capability-reason` values, in plain words. */\nconst unsupportedCapabilityReasons = {\n\treasoning: \"This model doesn't support the requested thinking level.\",\n\ttool_choice: \"This model can't force a tool call while thinking.\",\n\ttemperature: \"This model doesn't accept a temperature setting.\",\n\tcache_retention: \"This model doesn't support the requested prompt caching.\",\n\ttools: \"This model doesn't support tools.\",\n\tstrict_tools: \"This model doesn't support strict tool schemas.\",\n\tthinking_history: \"This model can't replay thinking from earlier turns of this conversation.\",\n\ttool_call_history: \"This model can't replay tool calls from earlier turns of this conversation.\",\n\timages: \"This model can't accept these images.\",\n\testimate: \"HUMAIN Code couldn't estimate this request's cost.\",\n} as const;\n\n/** Header names and closed reason values Forge sends with deterministic refusals. */\nexport const HCODE_REFUSAL_REASON_HEADERS = {\n\tmodel_unavailable: [\"x-hcode-model-unavailable-reason\", Object.keys(modelUnavailableReasons)],\n\tunsupported_capability: [\"x-hcode-unsupported-capability-reason\", Object.keys(unsupportedCapabilityReasons)],\n} as const satisfies Partial<Record<HcodeInferenceError[\"error\"][\"code\"], readonly [string, readonly string[]]>>;\n\n// Refusals Forge returns before any provider dispatch; each settles as not dispatched, so nothing is charged.\nconst predispatchCodes = new Set<HcodeInferenceError[\"error\"][\"code\"]>([\n\t\"unauthorized\",\n\t\"forbidden\",\n\t\"legal_acknowledgment_required\",\n\t\"auth_dependency_unavailable\",\n\t\"invalid_request\",\n\t\"unsupported_capability\",\n\t\"model_unavailable\",\n]);\nconst NOT_CHARGED =\n\t\"HUMAIN Code refused this request before running it, so nothing was charged. No automatic retry was sent.\";\n\nfunction refusalReason(code: HcodeInferenceError[\"error\"][\"code\"], reason: unknown): string | undefined {\n\tif (typeof reason !== \"string\") return undefined;\n\tconst table: Record<string, string> =\n\t\tcode === \"model_unavailable\"\n\t\t\t? modelUnavailableReasons\n\t\t\t: code === \"unsupported_capability\"\n\t\t\t\t? unsupportedCapabilityReasons\n\t\t\t\t: {};\n\treturn Object.hasOwn(table, reason) ? table[reason] : undefined;\n}\n\n/** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */\nexport function formatHcodeLocalRefusal(reason: unknown): string | undefined {\n\tif (typeof reason !== \"string\" || !Object.hasOwn(localReasons, reason)) return undefined;\n\treturn `${localReasons[reason as HcodeLocalReason]} No request was sent or charged.`;\n}\n\n/** Format the server's reset instant in UTC, independently of the host timezone. */\nexport function formatHcodeReset(resetAt: string): string {\n\treturn `Resets ${new Date(resetAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\n/** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */\nexport function formatHcodeNotice(\n\tfailure: HcodeInferenceError,\n\treceivedAt: number,\n\treason?: unknown,\n): {\n\tmessage: string;\n\tlines: readonly string[];\n\tretryAfterMs?: number;\n} {\n\tconst error = failure.error;\n\tif (error.code === \"hcode_busy\") {\n\t\tconst retryAt = new Date(receivedAt + error.details.retryAfterMs);\n\t\t// A valid delay can exceed Date's range. Omit the time, not the no-dispatch fact.\n\t\tconst retryTime = Number.isNaN(retryAt.getTime())\n\t\t\t? undefined\n\t\t\t: retryAt.toISOString().split(\".\")[0].replace(\"T\", \" \");\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t...(retryTime ? [`Retry after ${retryTime} UTC.`] : []),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t\tretryAfterMs: error.details.retryAfterMs,\n\t\t};\n\t}\n\tif (error.code === \"quota_exceeded\") {\n\t\tconst usage = error.details.usage;\n\t\tconst money = (value: HcodeValue | { kind: \"unlimited\" }) =>\n\t\t\tvalue.kind === \"known\"\n\t\t\t\t? `${value.value} ${usage.currency} ${usage.unit}${value.value === 1 ? \"\" : \"s\"}`\n\t\t\t\t: value.kind;\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t`Used${usage.costComplete ? \"\" : \" (known subtotal)\"} ${money(usage.actual)}`,\n\t\t\t\t`Pending ${money(usage.reserved)}`,\n\t\t\t\t`Remaining ${money(usage.remaining)}`,\n\t\t\t\tformatHcodeReset(usage.period.resetAt),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t};\n\t}\n\tconst recovery =\n\t\terror.code === \"unauthorized\"\n\t\t\t? \"Sign in again with /login.\"\n\t\t\t: error.code === \"legal_acknowledgment_required\"\n\t\t\t\t? \"Accept terms in the web app, then try again.\"\n\t\t\t\t: error.code === \"model_unavailable\"\n\t\t\t\t\t? \"Choose another model with /model, or ask your admin.\"\n\t\t\t\t\t: error.code === \"unsupported_capability\"\n\t\t\t\t\t\t? \"Change the setting, start a new conversation with /new, or choose another model with /model.\"\n\t\t\t\t\t\t: undefined;\n\tif (!predispatchCodes.has(error.code)) return { message: error.message, lines: [HCODE_AMBIGUOUS_NOTICE] };\n\tconst detail = refusalReason(error.code, reason);\n\treturn {\n\t\tmessage: error.message,\n\t\tlines: [...(detail ? [detail] : []), ...(recovery ? [recovery] : []), NOT_CHARGED],\n\t};\n}\n\n/** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */\nexport function formatHcodeMessageNotice(message: AssistantMessage): string | undefined {\n\tif (message.provider !== HCODE_PROVIDER) return undefined;\n\tif (message.stopReason === \"error\") {\n\t\tconst diagnostic = message.diagnostics?.findLast((entry) => entry.type === \"provider_http_error\");\n\t\tconst local = formatHcodeLocalRefusal(diagnostic?.details?.hcodeLocalReason);\n\t\tif (local) return local;\n\t\tconst refusal = diagnostic?.details?.hcode;\n\t\tif (refusal && typeof refusal === \"object\" && \"error\" in refusal) {\n\t\t\ttry {\n\t\t\t\t// Persisted diagnostics are untrusted. Revalidate only the closed service envelope, never raw error text.\n\t\t\t\tconst notice = formatHcodeNotice(\n\t\t\t\t\tparseHcodeInferenceError({ error: refusal.error }),\n\t\t\t\t\tdiagnostic!.timestamp,\n\t\t\t\t\t\"reason\" in refusal ? refusal.reason : undefined,\n\t\t\t\t);\n\t\t\t\treturn [notice.message, ...notice.lines].join(\"\\n\");\n\t\t\t} catch {\n\t\t\t\t// Malformed or ordinary-provider diagnostics retain their existing safe presentation.\n\t\t\t}\n\t\t}\n\t}\n\treturn HCODE_AMBIGUOUS_NOTICE;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"notices.js","sourceRoot":"","sources":["../../../src/humain/hcode/notices.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GACrC,+JAA+J,CAAC;AAEjK,MAAM,CAAC,MAAM,sBAAsB,GAClC,8IAA8I,CAAC;AAEhJ,MAAM,CAAC,MAAM,mBAAmB,GAAG,6CAA6C,CAAC;AAEjF,MAAM,YAAY,GAAG;IACpB,iBAAi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,EAAE,CAAC,EAAE,WAAW,CAAC;KAClF,CAAC;AACH,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,wBAAwB,CAAC,OAAyB;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,cAAc;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC,CAAC;QAClG,MAAM,KAAK,GAAG,uBAAuB,CACpC,UAAU,EAAE,OAAO,EAAE,gBAAgB,EACrC,UAAU,EAAE,OAAO,EAAE,gBAAgB,CACrC,CAAC;QACF,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,MAAM,OAAO,GAAG,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YAClE,IAAI,CAAC;gBACJ,0GAA0G;gBAC1G,MAAM,MAAM,GAAG,iBAAiB,CAC/B,wBAAwB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAClD,UAAW,CAAC,SAAS,EACrB,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAChD,CAAC;gBACF,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACR,sFAAsF;YACvF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,sBAAsB,CAAC;AAC/B,CAAC","sourcesContent":["// Local, typed presentation of managed refusal facts; never schedules a request or reads a later balance.\nimport type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { type HcodeInferenceError, type HcodeValue, parseHcodeInferenceError } from \"./contracts.ts\";\nimport { HCODE_PROVIDER } from \"./http.ts\";\n\nexport const HCODE_PENDING_EXPLANATION =\n\t\"Pending usage is awaiting provider confirmation. It remains reserved until confirmed or reviewed by an admin. It is not a final charge and is not free usage.\";\n\nexport const HCODE_AMBIGUOUS_NOTICE =\n\t\"HUMAIN Code couldn't confirm this request's outcome. It may still be charged. No automatic retry was sent. Check /usage before trying again.\";\n\nexport const BUILD_SESSION_ENDED = \"Build session ended. Start a new Build run.\";\n\nconst localReasons = {\n\tbuildSessionEnded: BUILD_SESSION_ENDED,\n\taccount: \"The selected HUMAIN Code account or model is no longer current.\",\n\ttransport: \"HUMAIN Code only supports SSE for this request.\",\n\tenvelope: \"The CLI could not build a valid HUMAIN Code request envelope.\",\n\tsize: \"The request exceeds the HUMAIN Code model's request size limit.\",\n\tmodel: \"The request model does not match the selected HUMAIN Code model.\",\n\treasoning: \"The selected HUMAIN Code model does not support the requested thinking level or thinking history.\",\n\toutput: \"The requested output token limit exceeds the HUMAIN Code model's limit.\",\n\tcache: \"HUMAIN Code requires cache retention to be disabled.\",\n\ttools: \"The selected HUMAIN Code model does not support tools.\",\n\tstrictTools: \"HUMAIN Code does not support required strict tool sampling.\",\n\timages: \"An image is unsupported or exceeds the selected HUMAIN Code model's limits.\",\n\tcancelled: \"The HUMAIN Code request was cancelled before submission.\",\n} as const;\n\nexport type HcodeLocalReason = keyof typeof localReasons;\n\nconst localDetails = {\n\tmessageLimit: [\"context.messages\", \"History exceeds 512 messages; compact the session before retrying.\"],\n\tschema: [\"$\", \"Request structure failed local schema validation.\"],\n\t\"message.schema\": [\"context.messages\", \"History failed local schema validation.\"],\n\t\"system.schema\": [\"context.messages[*]\", \"A system message failed local schema validation.\"],\n\t\"user.schema\": [\"context.messages[*]\", \"A user message failed local schema validation.\"],\n\t\"assistant.schema\": [\"context.messages[*]\", \"An assistant message failed local schema validation.\"],\n\t\"assistant.deferred\": [\"context.messages[*]\", \"Assistant history contains a deferred response.\"],\n\t\"toolCall.schema\": [\"context.messages[*].content[*]\", \"A tool call failed local schema validation.\"],\n\t\"toolCall.orphan\": [\"context.messages[*].content[*]\", \"Tool-call history is missing a matching result.\"],\n\t\"toolCall.unknownTool\": [\"context.messages[*].content[*].name\", \"Tool-call history references an unavailable tool.\"],\n\t\"toolCall.argumentsError\": [\n\t\t\"context.messages[*].content[*].argumentsError\",\n\t\t\"Tool-call history contains invalid arguments.\",\n\t],\n\t\"toolCall.duplicate\": [\"context.messages[*].content[*].id\", \"Tool-call history contains a repeated call.\"],\n\t\"toolResult.schema\": [\"context.messages[*]\", \"A tool result failed local schema validation.\"],\n\t\"toolResult.orphan\": [\"context.messages[*]\", \"Tool-result history has no matching call.\"],\n\t\"options.schema\": [\"options\", \"Request options failed local schema validation.\"],\n\t\"toolChoice.unknownTool\": [\"options.toolChoice\", \"The current tool choice is unavailable.\"],\n} as const;\n\nexport type HcodeLocalDetail = keyof typeof localDetails;\n\n/** Forge's closed `x-hcode-model-unavailable-reason` values, in plain words. */\nconst modelUnavailableReasons = {\n\tcatalog_entry_unavailable: \"This model is no longer in your HUMAIN Code catalog.\",\n\tcredential_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\texecution_credentials_unavailable: \"HUMAIN Code has no usable provider key for this model.\",\n\tprovider_quota_isolation_unverified: \"This model's provider key isn't dedicated to HUMAIN Code.\",\n\tquota_mapping_unavailable: \"This model's capacity isn't set up for HUMAIN Code yet.\",\n\tconfiguration_changed: \"An admin changed this model's configuration.\",\n\texecution_config_unavailable: \"HUMAIN Code couldn't load this model's configuration.\",\n\texecution_model_mismatch: \"HUMAIN Code's configuration for this model doesn't match its catalog entry.\",\n\texecution_endpoint_mismatch: \"HUMAIN Code's endpoint for this model doesn't match its catalog entry.\",\n\texecution_region_mismatch: \"HUMAIN Code's provider key is set to a region this model can't run in.\",\n} as const;\n\n/** Forge's closed `x-hcode-unsupported-capability-reason` values, in plain words. */\nconst unsupportedCapabilityReasons = {\n\treasoning: \"This model doesn't support the requested thinking level.\",\n\ttool_choice: \"This model can't force a tool call while thinking.\",\n\ttemperature: \"This model doesn't accept a temperature setting.\",\n\tcache_retention: \"This model doesn't support the requested prompt caching.\",\n\ttools: \"This model doesn't support tools.\",\n\tstrict_tools: \"This model doesn't support strict tool schemas.\",\n\tthinking_history: \"This model can't replay thinking from earlier turns of this conversation.\",\n\ttool_call_history: \"This model can't replay tool calls from earlier turns of this conversation.\",\n\timages: \"This model can't accept these images.\",\n\testimate: \"HUMAIN Code couldn't estimate this request's cost.\",\n} as const;\n\n/** Header names and closed reason values Forge sends with deterministic refusals. */\nexport const HCODE_REFUSAL_REASON_HEADERS = {\n\tmodel_unavailable: [\"x-hcode-model-unavailable-reason\", Object.keys(modelUnavailableReasons)],\n\tunsupported_capability: [\"x-hcode-unsupported-capability-reason\", Object.keys(unsupportedCapabilityReasons)],\n} as const satisfies Partial<Record<HcodeInferenceError[\"error\"][\"code\"], readonly [string, readonly string[]]>>;\n\n// Refusals Forge returns before any provider dispatch; each settles as not dispatched, so nothing is charged.\nconst predispatchCodes = new Set<HcodeInferenceError[\"error\"][\"code\"]>([\n\t\"unauthorized\",\n\t\"forbidden\",\n\t\"legal_acknowledgment_required\",\n\t\"auth_dependency_unavailable\",\n\t\"invalid_request\",\n\t\"unsupported_capability\",\n\t\"model_unavailable\",\n]);\nconst NOT_CHARGED =\n\t\"HUMAIN Code refused this request before running it, so nothing was charged. No automatic retry was sent.\";\n\nfunction refusalReason(code: HcodeInferenceError[\"error\"][\"code\"], reason: unknown): string | undefined {\n\tif (typeof reason !== \"string\") return undefined;\n\tconst table: Record<string, string> =\n\t\tcode === \"model_unavailable\"\n\t\t\t? modelUnavailableReasons\n\t\t\t: code === \"unsupported_capability\"\n\t\t\t\t? unsupportedCapabilityReasons\n\t\t\t\t: {};\n\treturn Object.hasOwn(table, reason) ? table[reason] : undefined;\n}\n\n/** Render a closed, non-reflecting reason for an inference that never reached the send boundary. */\nexport function formatHcodeLocalRefusal(reason: unknown, detail?: unknown): string | undefined {\n\tif (typeof reason !== \"string\" || !Object.hasOwn(localReasons, reason)) return undefined;\n\tif (reason === \"buildSessionEnded\") return BUILD_SESSION_ENDED;\n\t// Persisted diagnostics are untrusted: only closed detail codes may affect presentation.\n\tlet explanation = \"\";\n\tif (reason === \"envelope\" && typeof detail === \"string\" && Object.hasOwn(localDetails, detail)) {\n\t\tconst [path, message] = localDetails[detail as HcodeLocalDetail];\n\t\texplanation = ` ${message} [${detail} at ${path}]`;\n\t}\n\treturn `${localReasons[reason as HcodeLocalReason]}${explanation} No request was sent or charged.`;\n}\n\n/** Format the server's reset instant in UTC, independently of the host timezone. */\nexport function formatHcodeReset(resetAt: string): string {\n\treturn `Resets ${new Date(resetAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\n/** Render schema-validated service facts without reading raw diagnostics or granting automatic retry. */\nexport function formatHcodeNotice(\n\tfailure: HcodeInferenceError,\n\treceivedAt: number,\n\treason?: unknown,\n): {\n\tmessage: string;\n\tlines: readonly string[];\n\tretryAfterMs?: number;\n} {\n\tconst error = failure.error;\n\tif (error.code === \"hcode_busy\") {\n\t\tconst retryAt = new Date(receivedAt + error.details.retryAfterMs);\n\t\t// A valid delay can exceed Date's range. Omit the time, not the no-dispatch fact.\n\t\tconst retryTime = Number.isNaN(retryAt.getTime())\n\t\t\t? undefined\n\t\t\t: retryAt.toISOString().split(\".\")[0].replace(\"T\", \" \");\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t...(retryTime ? [`Retry after ${retryTime} UTC.`] : []),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t\tretryAfterMs: error.details.retryAfterMs,\n\t\t};\n\t}\n\tif (error.code === \"quota_exceeded\") {\n\t\tconst usage = error.details.usage;\n\t\tconst money = (value: HcodeValue | { kind: \"unlimited\" }) =>\n\t\t\tvalue.kind === \"known\"\n\t\t\t\t? `${value.value} ${usage.currency} ${usage.unit}${value.value === 1 ? \"\" : \"s\"}`\n\t\t\t\t: value.kind;\n\t\treturn {\n\t\t\tmessage: error.message,\n\t\t\tlines: [\n\t\t\t\t`Used${usage.costComplete ? \"\" : \" (known subtotal)\"} ${money(usage.actual)}`,\n\t\t\t\t`Pending ${money(usage.reserved)}`,\n\t\t\t\t`Remaining ${money(usage.remaining)}`,\n\t\t\t\tformatHcodeReset(usage.period.resetAt),\n\t\t\t\t\"No request was dispatched. No automatic retry was sent.\",\n\t\t\t],\n\t\t};\n\t}\n\tconst recovery =\n\t\terror.code === \"unauthorized\"\n\t\t\t? \"Sign in again with /login.\"\n\t\t\t: error.code === \"legal_acknowledgment_required\"\n\t\t\t\t? \"Accept terms in the web app, then try again.\"\n\t\t\t\t: error.code === \"model_unavailable\"\n\t\t\t\t\t? \"Choose another model with /model, or ask your admin.\"\n\t\t\t\t\t: error.code === \"unsupported_capability\"\n\t\t\t\t\t\t? \"Change the setting, start a new conversation with /new, or choose another model with /model.\"\n\t\t\t\t\t\t: undefined;\n\tif (!predispatchCodes.has(error.code)) return { message: error.message, lines: [HCODE_AMBIGUOUS_NOTICE] };\n\tconst detail = refusalReason(error.code, reason);\n\treturn {\n\t\tmessage: error.message,\n\t\tlines: [...(detail ? [detail] : []), ...(recovery ? [recovery] : []), NOT_CHARGED],\n\t};\n}\n\n/** Shared print/interactive boundary for validated refusals and separate uncertain-outcome warnings. */\nexport function formatHcodeMessageNotice(message: AssistantMessage): string | undefined {\n\tif (message.provider !== HCODE_PROVIDER) return undefined;\n\tif (message.stopReason === \"error\") {\n\t\tconst diagnostic = message.diagnostics?.findLast((entry) => entry.type === \"provider_http_error\");\n\t\tconst local = formatHcodeLocalRefusal(\n\t\t\tdiagnostic?.details?.hcodeLocalReason,\n\t\t\tdiagnostic?.details?.hcodeLocalDetail,\n\t\t);\n\t\tif (local) return local;\n\t\tconst refusal = diagnostic?.details?.hcode;\n\t\tif (refusal && typeof refusal === \"object\" && \"error\" in refusal) {\n\t\t\ttry {\n\t\t\t\t// Persisted diagnostics are untrusted. Revalidate only the closed service envelope, never raw error text.\n\t\t\t\tconst notice = formatHcodeNotice(\n\t\t\t\t\tparseHcodeInferenceError({ error: refusal.error }),\n\t\t\t\t\tdiagnostic!.timestamp,\n\t\t\t\t\t\"reason\" in refusal ? refusal.reason : undefined,\n\t\t\t\t);\n\t\t\t\treturn [notice.message, ...notice.lines].join(\"\\n\");\n\t\t\t} catch {\n\t\t\t\t// Malformed or ordinary-provider diagnostics retain their existing safe presentation.\n\t\t\t}\n\t\t}\n\t}\n\treturn HCODE_AMBIGUOUS_NOTICE;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Api, type ApiKeyCredential, type Model, type Provider, type TranscriptContext } from "@earendil-works/pi-ai";
|
|
2
|
-
import { type HcodeCatalogEmptyReason } from "./contracts.ts";
|
|
2
|
+
import { type HcodeCatalogEmptyReason, type HcodeCatalogExclusionReason } from "./contracts.ts";
|
|
3
3
|
import { type HcodeEnvironment } from "./environment.ts";
|
|
4
4
|
import type { HcodeAccountPort, HcodeAccountRef } from "./ports.ts";
|
|
5
5
|
/** Account-bound native provider whose owning runtime must dispose its subscription and catalog. */
|
|
@@ -8,6 +8,8 @@ export interface HcodeProvider extends Provider<"pi-messages"> {
|
|
|
8
8
|
dispose(): void;
|
|
9
9
|
/** Forge's reason the current account's catalog is empty, if it sent a known one. */
|
|
10
10
|
catalogEmptyReason(): HcodeCatalogEmptyReason | undefined;
|
|
11
|
+
/** Forge's reason the current account's catalog left out this exact model ID, if it sent a known one. */
|
|
12
|
+
catalogExclusionReason(modelId: string): HcodeCatalogExclusionReason | undefined;
|
|
11
13
|
/** Whether this process has read the current account's catalog; a new process reads it when /model opens. */
|
|
12
14
|
catalogLoaded(): boolean;
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/provider.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,gBAAgB,EAOrB,KAAK,KAAK,EACV,KAAK,QAAQ,EAGb,KAAK,iBAAiB,EACtB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAIhC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,gBAAgB,EAA6C,MAAM,kBAAkB,CAAC;AASpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIpE,oGAAoG;AACpG,MAAM,WAAW,aAAc,SAAQ,QAAQ,CAAC,aAAa,CAAC;IAC7D,iFAAiF;IACjF,OAAO,IAAI,IAAI,CAAC;IAChB,qFAAqF;IACrF,kBAAkB,IAAI,uBAAuB,GAAG,SAAS,CAAC;IAC1D,yGAAyG;IACzG,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS,CAAC;IACjF,6GAA6G;IAC7G,aAAa,IAAI,OAAO,CAAC;CACzB;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB,CAS/E;AAQD,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC,GACzC,iBAAiB,CAuEnB;AAoBD,yGAAyG;AACzG,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,gBAAgB,EACzB,WAAW,GAAE,gBAA4C,GACvD,aAAa,CA+Rf"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Managed account provider: reference-only auth and account-scoped pi-messages catalog.
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
4
|
import { createDelegatedFetch, createProvider, lazyStream, ManagedAssistantMessageQueue, } from "@earendil-works/pi-ai";
|
|
4
5
|
import { piMessagesApi } from "@earendil-works/pi-ai/api/pi-messages.lazy";
|
|
5
6
|
import { sameReference } from "./account-store.js";
|
|
6
7
|
import { deriveHcodeCatalog } from "./catalog.js";
|
|
7
|
-
import { HCODE_CATALOG_EMPTY_REASON_HEADER, parseHcodeCatalogEmptyReason, parseHcodeModelList, } from "./contracts.js";
|
|
8
|
+
import { HCODE_CATALOG_EMPTY_REASON_HEADER, HCODE_CATALOG_EXCLUSIONS_HEADER, parseHcodeCatalogEmptyReason, parseHcodeCatalogExclusions, parseHcodeModelList, } from "./contracts.js";
|
|
8
9
|
import { hcodeDisplayName, resolveHcodeEnvironment } from "./environment.js";
|
|
9
10
|
import { HCODE_PROVIDER, hcodeJson } from "./http.js";
|
|
10
11
|
import { fitHcodeRequestSize, hcodeActivePrompts, hcodeImagePayloadDraft, reportHcodeImageSizeRefusal, } from "./images.js";
|
|
@@ -26,49 +27,97 @@ const replayableToolCallId = /^[A-Za-z0-9_-]{1,64}$/;
|
|
|
26
27
|
const foreignToolCallId = (id) => replayableToolCallId.test(id) ? id : `call_${createHash("sha256").update(id).digest("hex").slice(0, 32)}`;
|
|
27
28
|
// Project history for the destination model without changing the saved transcript.
|
|
28
29
|
export function projectHcodeContext(context, model) {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
30
|
+
const messages = [];
|
|
31
|
+
const activeTools = new Set();
|
|
32
|
+
const pending = new Map();
|
|
33
|
+
const closeTurn = () => {
|
|
34
|
+
for (const call of pending.values()) {
|
|
35
|
+
messages.push({
|
|
36
|
+
role: "toolResult",
|
|
37
|
+
toolCallId: call.id,
|
|
38
|
+
toolName: call.name,
|
|
39
|
+
content: [{ type: "text", text: "No result provided" }],
|
|
40
|
+
isError: true,
|
|
41
|
+
timestamp: call.timestamp,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
pending.clear();
|
|
45
|
+
};
|
|
46
|
+
for (const message of context.messages) {
|
|
47
|
+
if (message.role === "system") {
|
|
48
|
+
// Evaluate calls against the tools declared at their turn, not the final live loadout.
|
|
49
|
+
for (const tool of message.toolsRemoved ?? [])
|
|
50
|
+
activeTools.delete(tool.name);
|
|
51
|
+
for (const tool of message.toolsAdded ?? [])
|
|
52
|
+
activeTools.add(tool.name);
|
|
53
|
+
messages.push(projectHcodeSystemMessage(message));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (message.role === "toolResult") {
|
|
57
|
+
const call = pending.get(message.toolCallId);
|
|
58
|
+
if (!call || call.name !== message.toolName)
|
|
59
|
+
continue;
|
|
60
|
+
pending.delete(message.toolCallId);
|
|
61
|
+
// Execution details and nested calls are session/UI bookkeeping, not model input.
|
|
62
|
+
messages.push({
|
|
63
|
+
role: "toolResult",
|
|
64
|
+
toolCallId: call.id,
|
|
65
|
+
toolName: message.toolName,
|
|
66
|
+
content: message.content,
|
|
67
|
+
isError: message.isError,
|
|
68
|
+
timestamp: message.timestamp,
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
closeTurn();
|
|
73
|
+
if (message.role === "user") {
|
|
74
|
+
messages.push(message);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Incomplete turns were never replayable and may contain calls that never ran.
|
|
78
|
+
if (message.stopReason === "error" || message.stopReason === "aborted" || message.stopReason === "deferred")
|
|
79
|
+
continue;
|
|
80
|
+
const sameModel = message.provider === HCODE_PROVIDER && message.api === "pi-messages" && message.model === model.id;
|
|
81
|
+
const { deferred: _handle, providerThinkingLevel, ...assistant } = message;
|
|
82
|
+
const content = assistant.content.flatMap((block) => {
|
|
83
|
+
if (block.type === "thinking")
|
|
84
|
+
return sameModel && model.reasoning ? [block] : [];
|
|
85
|
+
if (block.type === "text")
|
|
86
|
+
return [sameModel ? block : { type: "text", text: block.text }];
|
|
87
|
+
if (block.argumentsError !== undefined || !activeTools.has(block.name))
|
|
88
|
+
return [];
|
|
89
|
+
const id = sameModel ? block.id : foreignToolCallId(block.id);
|
|
90
|
+
pending.set(block.id, { id, name: block.name, timestamp: message.timestamp });
|
|
91
|
+
if (sameModel)
|
|
92
|
+
return [block];
|
|
93
|
+
const { thoughtSignature: _signature, ...call } = block;
|
|
94
|
+
return [{ ...call, id }];
|
|
95
|
+
});
|
|
96
|
+
if (!content.length && (!sameModel || message.content.length))
|
|
97
|
+
continue;
|
|
98
|
+
messages.push({
|
|
99
|
+
...assistant,
|
|
100
|
+
content,
|
|
101
|
+
stopReason: assistant.stopReason === "toolUse" && !pending.size ? "stop" : assistant.stopReason,
|
|
102
|
+
...(sameModel && providerThinkingLevel !== undefined ? { providerThinkingLevel } : {}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
closeTurn();
|
|
106
|
+
return { ...context, messages };
|
|
107
|
+
}
|
|
108
|
+
function projectHcodeSystemMessage(message) {
|
|
109
|
+
// Catalog v1 qualifies ordinary JSON-schema tools, not provider-side constrained sampling.
|
|
110
|
+
if (!message.toolsAdded?.some((tool) => tool.constrainedSampling))
|
|
111
|
+
return message;
|
|
31
112
|
return {
|
|
32
|
-
...
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (block.type === "thinking")
|
|
41
|
-
return [];
|
|
42
|
-
if (block.type === "text")
|
|
43
|
-
return [{ type: "text", text: block.text }];
|
|
44
|
-
const { thoughtSignature: _signature, ...call } = block;
|
|
45
|
-
const id = foreignToolCallId(call.id);
|
|
46
|
-
if (id !== call.id)
|
|
47
|
-
toolCallIds.set(call.id, id);
|
|
48
|
-
return [{ ...call, id }];
|
|
49
|
-
});
|
|
50
|
-
return content.length ? { ...foreign, content } : [];
|
|
51
|
-
}
|
|
52
|
-
if (message.role === "toolResult" && toolCallIds.has(message.toolCallId))
|
|
53
|
-
return { ...message, toolCallId: toolCallIds.get(message.toolCallId) };
|
|
54
|
-
if (!reasoning && message.role === "assistant" && message.content.some((block) => block.type === "thinking")) {
|
|
55
|
-
const content = message.content.filter((block) => block.type !== "thinking");
|
|
56
|
-
return content.length ? { ...message, content } : [];
|
|
57
|
-
}
|
|
58
|
-
// Catalog v1 qualifies ordinary JSON-schema tools, not provider-side constrained sampling.
|
|
59
|
-
if (message.role !== "system" || !message.toolsAdded?.some((tool) => tool.constrainedSampling))
|
|
60
|
-
return message;
|
|
61
|
-
return {
|
|
62
|
-
...message,
|
|
63
|
-
toolsAdded: message.toolsAdded.map((tool) => {
|
|
64
|
-
const { constrainedSampling, ...ordinaryTool } = tool;
|
|
65
|
-
if (constrainedSampling &&
|
|
66
|
-
constrainedSampling.type === "json_schema" &&
|
|
67
|
-
constrainedSampling.strict === "require")
|
|
68
|
-
throw new HcodeLocalRefusal("strictTools");
|
|
69
|
-
return constrainedSampling ? ordinaryTool : tool;
|
|
70
|
-
}),
|
|
71
|
-
};
|
|
113
|
+
...message,
|
|
114
|
+
toolsAdded: message.toolsAdded.map((tool) => {
|
|
115
|
+
const { constrainedSampling, ...ordinaryTool } = tool;
|
|
116
|
+
if (constrainedSampling &&
|
|
117
|
+
constrainedSampling.type === "json_schema" &&
|
|
118
|
+
constrainedSampling.strict === "require")
|
|
119
|
+
throw new HcodeLocalRefusal("strictTools");
|
|
120
|
+
return constrainedSampling ? ordinaryTool : tool;
|
|
72
121
|
}),
|
|
73
122
|
};
|
|
74
123
|
}
|
|
@@ -79,10 +128,12 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
79
128
|
let scope = null;
|
|
80
129
|
let models = Object.freeze([]);
|
|
81
130
|
let emptyReason;
|
|
131
|
+
let exclusions = new Map();
|
|
82
132
|
const clear = () => {
|
|
83
133
|
scope = null;
|
|
84
134
|
models = Object.freeze([]);
|
|
85
135
|
emptyReason = undefined;
|
|
136
|
+
exclusions = new Map();
|
|
86
137
|
};
|
|
87
138
|
const unsubscribe = account.subscribe(clear);
|
|
88
139
|
const current = () => !disposed && scope && sameReference(account.status(scope.environmentId), scope);
|
|
@@ -170,6 +221,9 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
170
221
|
envelope = changed === undefined ? hook.draft : changed;
|
|
171
222
|
protectedMessages = hook.protectedMessages(envelope.context.messages);
|
|
172
223
|
}
|
|
224
|
+
if (Array.isArray(envelope.context.messages) && envelope.context.messages.length > 512) {
|
|
225
|
+
throw new HcodeLocalRefusal("envelope", "messageLimit");
|
|
226
|
+
}
|
|
173
227
|
const fitted = await fitHcodeRequestSize(canonical, envelope.context.messages, protectedMessages, (messages) => JSON.stringify({ ...envelope, context: { ...envelope.context, messages } }));
|
|
174
228
|
if (!fitted) {
|
|
175
229
|
if (active.size && protectedMessages.size)
|
|
@@ -180,7 +234,11 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
180
234
|
return parseHcodeRequestBody(fitted.body);
|
|
181
235
|
}
|
|
182
236
|
catch (error) {
|
|
183
|
-
|
|
237
|
+
if (error instanceof HcodeLocalRefusal) {
|
|
238
|
+
failure = error;
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
return refuse("envelope");
|
|
184
242
|
}
|
|
185
243
|
},
|
|
186
244
|
onRequest: options?.onRequest,
|
|
@@ -210,7 +268,10 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
210
268
|
details: {
|
|
211
269
|
retryable: false,
|
|
212
270
|
...(failure instanceof HcodeLocalRefusal
|
|
213
|
-
? {
|
|
271
|
+
? {
|
|
272
|
+
hcodeLocalReason: failure.reason,
|
|
273
|
+
...(failure.detail ? { hcodeLocalDetail: failure.detail } : {}),
|
|
274
|
+
}
|
|
214
275
|
: failure?.failure
|
|
215
276
|
? { hcode: failure.diagnostics() }
|
|
216
277
|
: {}),
|
|
@@ -268,6 +329,20 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
268
329
|
getModels,
|
|
269
330
|
getAllModels: getModels,
|
|
270
331
|
catalogEmptyReason: () => (getModels().length ? undefined : emptyReason),
|
|
332
|
+
catalogExclusionReason: (modelId) => {
|
|
333
|
+
// Match `/model` exact references, which compare IDs case-insensitively.
|
|
334
|
+
const normalized = modelId.toLowerCase();
|
|
335
|
+
if (getModels().some((model) => model.id.toLowerCase() === normalized))
|
|
336
|
+
return undefined;
|
|
337
|
+
const exact = exclusions.get(modelId);
|
|
338
|
+
if (exact)
|
|
339
|
+
return exact;
|
|
340
|
+
for (const [id, reason] of exclusions) {
|
|
341
|
+
if (id.toLowerCase() === normalized)
|
|
342
|
+
return reason;
|
|
343
|
+
}
|
|
344
|
+
return undefined;
|
|
345
|
+
},
|
|
271
346
|
catalogLoaded: () => !!current(),
|
|
272
347
|
async refreshModels(context) {
|
|
273
348
|
const expected = context.credential?.type === "api_key" ? credentialReference(context.credential) : null;
|
|
@@ -278,9 +353,11 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
278
353
|
if (!context.allowNetwork || context.signal.aborted)
|
|
279
354
|
return;
|
|
280
355
|
let reason;
|
|
356
|
+
let excluded = new Map();
|
|
281
357
|
const entries = parseHcodeModelList(await hcodeJson(async (url, init) => {
|
|
282
358
|
const response = await account.authorizedFetch(expected, String(url), init ?? {});
|
|
283
359
|
reason = parseHcodeCatalogEmptyReason(response.headers.get(HCODE_CATALOG_EMPTY_REASON_HEADER));
|
|
360
|
+
excluded = parseHcodeCatalogExclusions(response.headers.get(HCODE_CATALOG_EXCLUSIONS_HEADER));
|
|
284
361
|
return response;
|
|
285
362
|
}, `${environment.inferenceBaseUrl}/models`, { signal: context.signal })).data;
|
|
286
363
|
const next = deriveHcodeCatalog(entries, environment);
|
|
@@ -293,9 +370,12 @@ export function createHcodeProvider(account, environment = resolveHcodeEnvironme
|
|
|
293
370
|
context.signal.aborted ||
|
|
294
371
|
!sameReference(account.status(expected.environmentId), expected))
|
|
295
372
|
return;
|
|
373
|
+
// Unchanged approval must not invalidate a picker row or an in-flight selection.
|
|
374
|
+
if (!sameReference(scope, expected) || !isDeepStrictEqual(models, next))
|
|
375
|
+
models = next;
|
|
296
376
|
scope = expected;
|
|
297
|
-
models = next;
|
|
298
377
|
emptyReason = next.length ? undefined : reason;
|
|
378
|
+
exclusions = excluded;
|
|
299
379
|
},
|
|
300
380
|
});
|
|
301
381
|
},
|