@oscharko-dev/keiko 1.1.6 → 1.1.8
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/dist/ui/csp-hashes.json +7 -7
- package/dist/ui/static/404.html +1 -1
- package/dist/ui/static/__next.__PAGE__.txt +11 -11
- package/dist/ui/static/__next._full.txt +13 -13
- package/dist/ui/static/__next._tree.txt +2 -2
- package/dist/ui/static/_next/static/chunks/02i0eppipph7e.js +1 -0
- package/dist/ui/static/_next/static/chunks/09jwu8wa22c1d.js +1 -0
- package/dist/ui/static/_next/static/chunks/0hc828_gdkyek.js +3 -0
- package/dist/ui/static/_next/static/chunks/0n5hz6kjgs-3-.js +1 -0
- package/dist/ui/static/_next/static/chunks/{2l0gyhe4jpu23.css → 0qv7j1mski9o8.css} +1 -1
- package/dist/ui/static/_next/static/chunks/{0xq716cs1taxh.js → 0vtnpcijh-jqw.js} +1 -1
- package/dist/ui/static/_next/static/chunks/15wj80h_5chl0.js +1 -0
- package/dist/ui/static/_next/static/chunks/{0ak5o5brryicl.js → 18grpx4tuavds.js} +1 -1
- package/dist/ui/static/_next/static/chunks/1be0-x1mk56wu.js +1 -0
- package/dist/ui/static/_next/static/chunks/{0bbv42deftomm.js → 1c1gbfapof8m0.js} +1 -1
- package/dist/ui/static/_next/static/chunks/1dwc7p2rl-hs6.js +1 -0
- package/dist/ui/static/_next/static/chunks/{1piodmepoegnw.js → 1fgcho9v65crw.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{3d-10944zk2o9.js → 1lj5se4u-t-e9.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{1th8j9weqwhgx.js → 1o2cihsnxhmh6.js} +1 -1
- package/dist/ui/static/_next/static/chunks/22x3pxeia7hk_.js +1 -0
- package/dist/ui/static/_next/static/chunks/{0e6em7dg4gr6q.js → 25lgzefdnbdh6.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{2t2wftn5liinr.js → 2iz4lys7fa5a6.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{21t1klb1thn76.js → 306ima8lxo17-.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{2dpxapmdvqlh1.js → 36-tv3y56oau8.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{182b4sf3i-krz.js → 39w0xj7fyy7sp.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{0ks_l2sa4nfn0.js → 3aizxizjzdddj.js} +1 -1
- package/dist/ui/static/_next/static/chunks/3bl12pe7lsanc.js +1 -0
- package/dist/ui/static/_next/static/chunks/3k6g7nzn589fs.js +1 -0
- package/dist/ui/static/_next/static/chunks/{1j_9b-l0n6u-t.js → 3kmozkq6tgqnz.js} +1 -1
- package/dist/ui/static/_next/static/chunks/3q_kn20qriqd7.js +1 -0
- package/dist/ui/static/_next/static/chunks/3r4fz572q3l7s.js +1 -0
- package/dist/ui/static/_next/static/chunks/{1lb8ju8qa0d9m.js → 40g2_9ovqiuiu.js} +1 -1
- package/dist/ui/static/_next/static/chunks/413lmui4la1xe.js +1 -0
- package/dist/ui/static/_next/static/chunks/{turbopack-2w1ixcff5kx3x.js → turbopack-2fb3mn6go2p-t.js} +1 -1
- package/dist/ui/static/_not-found/__next._full.txt +9 -9
- package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +8 -8
- package/dist/ui/static/_not-found/__next._tree.txt +1 -1
- package/dist/ui/static/_not-found.html +1 -1
- package/dist/ui/static/_not-found.txt +9 -9
- package/dist/ui/static/atlassian-connectors/__next._full.txt +13 -13
- package/dist/ui/static/atlassian-connectors/__next._tree.txt +1 -1
- package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +10 -10
- package/dist/ui/static/atlassian-connectors.html +1 -1
- package/dist/ui/static/atlassian-connectors.txt +13 -13
- package/dist/ui/static/index.html +1 -1
- package/dist/ui/static/index.txt +13 -13
- package/dist/ui/static/launch/__next._full.txt +13 -13
- package/dist/ui/static/launch/__next._tree.txt +2 -2
- package/dist/ui/static/launch/__next.launch.__PAGE__.txt +11 -11
- package/dist/ui/static/launch.html +1 -1
- package/dist/ui/static/launch.txt +13 -13
- package/dist/ui/static/local-knowledge/__next._full.txt +13 -13
- package/dist/ui/static/local-knowledge/__next._tree.txt +2 -2
- package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +11 -11
- package/dist/ui/static/local-knowledge/capsule/__next._full.txt +13 -13
- package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +1 -1
- package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +10 -10
- package/dist/ui/static/local-knowledge/capsule.html +1 -1
- package/dist/ui/static/local-knowledge/capsule.txt +13 -13
- package/dist/ui/static/local-knowledge.html +1 -1
- package/dist/ui/static/local-knowledge.txt +13 -13
- package/node_modules/@oscharko-dev/keiko-cli/package.json +14 -14
- package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-connectors/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts +55 -15
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.js +108 -12
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts +924 -33
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.js +1249 -142
- package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +7 -2
- package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api-validation.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api-validation.js +14 -4
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-constants.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-constants.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime.d.ts +7 -0
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts +3 -0
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.js +20 -4
- package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/verified-commit.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/verified-commit.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/verified-commit.js +8 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts +2 -2
- package/node_modules/@oscharko-dev/keiko-contracts/dist/version.js +2 -2
- package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
- package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
- package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-git/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/package.json +7 -7
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
- package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/config.js +4 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.js +136 -24
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.js +1 -0
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.js +38 -4
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.js +12 -3
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/realtime-voice-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/realtime-voice-adapter.js +3 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/rerank-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/rerank-adapter.js +4 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts +9 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.js +87 -5
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/speech-to-text-adapter.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/speech-to-text-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/speech-to-text-adapter.js +158 -10
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/text-to-speech-adapter.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/text-to-speech-adapter.js +176 -12
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +4 -4
- package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
- package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
- package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts +11 -1
- package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-security/dist/errors/gateway.js +33 -0
- package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts +3 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.d.ts +0 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.js +44 -13
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.js +9 -4
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.js +3 -3
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts +2 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.js +3 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.js +143 -32
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.d.ts +7 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.js +29 -8
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts +16 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacadePorts.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts +6 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.js +5 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.d.ts +14 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.js +201 -43
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/launchFailure.d.ts +13 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/launchFailure.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/launchFailure.js +24 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.d.ts +12 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeFunctionalHarness/_governedTools.js +31 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.js +35 -13
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts +16 -4
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.js +74 -14
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.d.ts +33 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.js +277 -44
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.d.ts +6 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.js +4 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionDraftDeliveryRuntime.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionDraftDeliveryRuntime.js +3 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.js +72 -26
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionVerifiedCommitRuntime.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionVerifiedCommitRuntime.js +6 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/researchApprovalIssuance.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/researchApprovalIssuance.js +2 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts +30 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.js +476 -143
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.js +32 -5
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts +16 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.js +2 -23
- package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts +5 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.js +11 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts +24 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.js +215 -38
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.d.ts +6 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-route-deadline.js +27 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts +33 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +256 -25
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.d.ts +2 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-tool-calling-probe.js +11 -4
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts +2 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.js +221 -38
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.js +29 -4
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitTypes.d.ts +2 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitTypes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.js +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistory.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistory.js +48 -3
- package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.js +54 -8
- package/node_modules/@oscharko-dev/keiko-server/package.json +22 -22
- package/node_modules/@oscharko-dev/keiko-tool-catalog/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/package.json +7 -7
- package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
- package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
- package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
- package/package.json +29 -29
- package/release-impact.catalog.json +135 -23
- package/vendor/{oscharko-dev-keiko-cli-1.1.6.tgz → oscharko-dev-keiko-cli-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-connectors-1.1.6.tgz → oscharko-dev-keiko-connectors-1.1.8.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-contracts-1.1.8.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-evaluations-1.1.6.tgz → oscharko-dev-keiko-evaluations-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-evidence-1.1.6.tgz → oscharko-dev-keiko-evidence-1.1.8.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-git-1.1.8.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-harness-1.1.6.tgz → oscharko-dev-keiko-harness-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-local-knowledge-1.1.6.tgz → oscharko-dev-keiko-local-knowledge-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-capture-1.1.6.tgz → oscharko-dev-keiko-memory-capture-1.1.8.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.8.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-memory-governance-1.1.6.tgz → oscharko-dev-keiko-memory-governance-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-retrieval-1.1.6.tgz → oscharko-dev-keiko-memory-retrieval-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-vault-1.1.6.tgz → oscharko-dev-keiko-memory-vault-1.1.8.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-model-gateway-1.1.8.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-quality-intelligence-1.1.6.tgz → oscharko-dev-keiko-quality-intelligence-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-sandbox-1.1.6.tgz → oscharko-dev-keiko-sandbox-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-sdk-1.1.6.tgz → oscharko-dev-keiko-sdk-1.1.8.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-security-1.1.8.tgz +0 -0
- package/vendor/oscharko-dev-keiko-server-1.1.8.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-tool-catalog-1.1.6.tgz → oscharko-dev-keiko-tool-catalog-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-tools-1.1.6.tgz → oscharko-dev-keiko-tools-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-verification-1.1.6.tgz → oscharko-dev-keiko-verification-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-workflows-1.1.6.tgz → oscharko-dev-keiko-workflows-1.1.8.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-workspace-1.1.6.tgz → oscharko-dev-keiko-workspace-1.1.8.tgz} +0 -0
- package/dist/ui/static/_next/static/chunks/0c3w2ubla6ek6.js +0 -1
- package/dist/ui/static/_next/static/chunks/0gnizm29lk3ll.js +0 -1
- package/dist/ui/static/_next/static/chunks/0psckgz_yhen3.js +0 -1
- package/dist/ui/static/_next/static/chunks/19fesd0w1gjhp.js +0 -3
- package/dist/ui/static/_next/static/chunks/1gb6os129fico.js +0 -1
- package/dist/ui/static/_next/static/chunks/1k6f6m-u2q69-.js +0 -1
- package/dist/ui/static/_next/static/chunks/1pze64zkvx8vt.js +0 -1
- package/dist/ui/static/_next/static/chunks/28mbnwl9g65al.js +0 -1
- package/dist/ui/static/_next/static/chunks/2bm60h9zwhm3v.js +0 -1
- package/dist/ui/static/_next/static/chunks/2h_zvmb272ozs.js +0 -1
- package/dist/ui/static/_next/static/chunks/3-5_wuwrev-8c.js +0 -1
- package/dist/ui/static/_next/static/chunks/3-l-8qt163_y6.js +0 -1
- package/dist/ui/static/_next/static/chunks/3doin5vaz4zjs.js +0 -1
- package/vendor/oscharko-dev-keiko-contracts-1.1.6.tgz +0 -0
- package/vendor/oscharko-dev-keiko-git-1.1.6.tgz +0 -0
- package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.6.tgz +0 -0
- package/vendor/oscharko-dev-keiko-model-gateway-1.1.6.tgz +0 -0
- package/vendor/oscharko-dev-keiko-security-1.1.6.tgz +0 -0
- package/vendor/oscharko-dev-keiko-server-1.1.6.tgz +0 -0
- /package/dist/ui/static/_next/static/{ytpWXc-OicMB-rH2zX5b3 → xFln0tD9J1Dx0Nlv71fAF}/_buildManifest.js +0 -0
- /package/dist/ui/static/_next/static/{ytpWXc-OicMB-rH2zX5b3 → xFln0tD9J1Dx0Nlv71fAF}/_clientMiddlewareManifest.js +0 -0
- /package/dist/ui/static/_next/static/{ytpWXc-OicMB-rH2zX5b3 → xFln0tD9J1Dx0Nlv71fAF}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { gatewaySpendRejectionReason } from "./gateway-spend-budget.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CodingRuntimeLaunchRejectedError } from "./coding-runtime/launchFailure.js";
|
|
3
|
+
import { AuthenticationError, CircuitOpenError, ContextOverflowError, MalformedToolCallError, ModelRefusalError, ProviderEmptyAnswerError, ProviderError, ProviderOutputExhaustedError, RateLimitError, TimeoutError, TransportError, } from "@oscharko-dev/keiko-security/errors/gateway";
|
|
3
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
-
import { findConfiguredCapability, resolveCodingSafeSidecarGatewayProfile, } from "@oscharko-dev/keiko-model-gateway";
|
|
5
|
+
import { findConfiguredCapability, resolveCodingSafeSidecarGatewayProfile, ResponseRedactionError, } from "@oscharko-dev/keiko-model-gateway";
|
|
5
6
|
import { countGatewayPromptTokens, } from "@oscharko-dev/keiko-model-gateway/internal/prompt-token-accounting";
|
|
6
|
-
import {
|
|
7
|
-
import { MAX_TIMER_DELAY_MS } from "./abort-race.js";
|
|
7
|
+
import { gatewayRouteDeadlineMs } from "./gateway-route-deadline.js";
|
|
8
8
|
import { compareStrings } from "@oscharko-dev/keiko-contracts/runtime/comparators";
|
|
9
9
|
import { CODING_WORKBENCH_MINIMUM_CODING_CONTEXT_PROMPT_TOKENS } from "@oscharko-dev/keiko-contracts/runtime/coding-workbench";
|
|
10
10
|
import { activityLogEvent, defineActivityLogOperation, } from "@oscharko-dev/keiko-contracts/runtime/observability";
|
|
@@ -13,11 +13,13 @@ import { currentGateway, currentGatewayConfig, currentGatewayVerification, } fro
|
|
|
13
13
|
import { OPENCODE_RUNTIME_MODEL_ALIAS, OPENCODE_RUNTIME_READINESS_PROMPT, } from "./coding-runtime/opencodeLaunchProfile.js";
|
|
14
14
|
import { createOpenCodeGatewayToolCatalogAdvertisement, opencodeGatewayOfferLifetimeMs, hasExactOpenCodeVisibleToolContract, OPENCODE_MODEL_VISIBLE_TOOL_NAMES, } from "./coding-runtime/opencodeToolSchemas.js";
|
|
15
15
|
import { correlationIdOrUnknown, UNKNOWN_CORRELATION_ID } from "./correlation.js";
|
|
16
|
-
import { emitServerDiagnostic, serverDiagnosticFromError } from "./diagnostics-log.js";
|
|
16
|
+
import { describeError, emitServerDiagnostic, serverDiagnosticFromError, } from "./diagnostics-log.js";
|
|
17
17
|
import { readJsonObject } from "./files.js";
|
|
18
|
-
import {
|
|
18
|
+
import { safetyMarginTokensFor } from "@oscharko-dev/keiko-contracts/context-engineering";
|
|
19
|
+
import { ensureCodingWorkbenchContextWindows, isAnyCodingWorkbenchProbePending, isCodingWorkbenchProbePending, } from "./gateway-readiness.js";
|
|
19
20
|
import { getServerLogger } from "./observability/index.js";
|
|
20
21
|
import { STREAMING, errorBody } from "./routes.js";
|
|
22
|
+
import { sseBackpressureReporter, writeOrDestroy, } from "./sse-write.js";
|
|
21
23
|
import { startSseHeartbeat } from "./sse.js";
|
|
22
24
|
import { createCanonicalOpenCodeHandlerCoverage } from "./tool-catalog/catalogToolFacadeBridge.js";
|
|
23
25
|
const ENABLE_TOKENS = new Set(["1", "true", "on", "yes", "enabled"]);
|
|
@@ -62,31 +64,45 @@ function observedPromptSettlement(outcome, selected, unverified) {
|
|
|
62
64
|
* authenticator (not every deployment wires it) is a silent no-op, never a failure.
|
|
63
65
|
*/
|
|
64
66
|
function settlePromptTokenReservation(deps, reservation, actualPromptTokens) {
|
|
67
|
+
const providerReported = actualPromptTokens !== undefined && actualPromptTokens > 0;
|
|
68
|
+
return applyPromptTokenSettlement(deps, reservation, {
|
|
69
|
+
promptTokens: providerReported ? actualPromptTokens : reservation.reservedPromptTokens,
|
|
70
|
+
source: providerReported ? "provider-reported" : "reserved-estimate",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Releases a reservation whose provider call never ran — the client would not take the opening
|
|
75
|
+
* SSE frame, so the buffered path never called the chat factory and the streamed path never pulled
|
|
76
|
+
* the gateway's generator. The conservative rule above keeps the estimate only for a call that WAS
|
|
77
|
+
* dispatched; here nothing was spent, so the whole reservation goes back to the run's budget
|
|
78
|
+
* (#3602 review). Same idempotence and same not-wired fallback as a settlement.
|
|
79
|
+
*/
|
|
80
|
+
function releasePromptTokenReservation(deps, reservation) {
|
|
81
|
+
return applyPromptTokenSettlement(deps, reservation, {
|
|
82
|
+
promptTokens: 0,
|
|
83
|
+
source: "released-unspent",
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function applyPromptTokenSettlement(deps, reservation, usage) {
|
|
65
87
|
if (reservation.settled) {
|
|
66
88
|
if (reservation.settlement === undefined)
|
|
67
89
|
throw new TypeError("missing prompt settlement");
|
|
68
90
|
return reservation.settlement;
|
|
69
91
|
}
|
|
70
92
|
reservation.settled = true;
|
|
71
|
-
const providerReported = actualPromptTokens !== undefined && actualPromptTokens > 0;
|
|
72
|
-
const promptTokens = providerReported ? actualPromptTokens : reservation.reservedPromptTokens;
|
|
73
93
|
const unverified = {
|
|
74
94
|
promptTokens: reservation.reservedPromptTokens,
|
|
75
95
|
source: "reserved-estimate",
|
|
76
96
|
status: "unverified",
|
|
77
97
|
};
|
|
78
|
-
const selected = {
|
|
79
|
-
promptTokens,
|
|
80
|
-
source: providerReported ? "provider-reported" : "reserved-estimate",
|
|
81
|
-
status: "settled",
|
|
82
|
-
};
|
|
98
|
+
const selected = { ...usage, status: "settled" };
|
|
83
99
|
reservation.settlement = unverified;
|
|
84
100
|
const authenticator = runtimeCapabilityAuthenticator(deps);
|
|
85
101
|
if (authenticator?.settlePromptTokens === undefined) {
|
|
86
102
|
reservation.settlement = { ...selected, status: "not-wired" };
|
|
87
103
|
return reservation.settlement;
|
|
88
104
|
}
|
|
89
|
-
const outcome = authenticator.settlePromptTokens(reservation.capability, reservation.reservedPromptTokens, promptTokens);
|
|
105
|
+
const outcome = authenticator.settlePromptTokens(reservation.capability, reservation.reservedPromptTokens, usage.promptTokens);
|
|
90
106
|
reservation.settlement = observedPromptSettlement(outcome, selected, unverified);
|
|
91
107
|
return reservation.settlement;
|
|
92
108
|
}
|
|
@@ -114,6 +130,9 @@ const CODING_SIDECAR_GATEWAY_REQUEST_VALIDATED_OPERATION = defineActivityLogOper
|
|
|
114
130
|
maxRequestBytes: { type: "integer", dataClass: "count", required: true },
|
|
115
131
|
maxPromptTokens: { type: "integer", dataClass: "count", required: true },
|
|
116
132
|
estimatedPromptTokens: { type: "integer", dataClass: "count", required: true },
|
|
133
|
+
// #3591 (1.1.7): the output allowance sent with this request, clamped to the window that
|
|
134
|
+
// remains after the prompt — the value an output-exhausted turn has to be read against.
|
|
135
|
+
maxOutputTokens: { type: "integer", dataClass: "count", required: false },
|
|
117
136
|
inputMessageCount: { type: "integer", dataClass: "count", required: true },
|
|
118
137
|
completeness: { type: "string", dataClass: "completeness-state", required: true },
|
|
119
138
|
loss: { type: "string", dataClass: "loss-state", required: true },
|
|
@@ -137,11 +156,21 @@ const CODING_SIDECAR_GATEWAY_READINESS_INSUFFICIENT_OPERATION = defineActivityLo
|
|
|
137
156
|
type: "string",
|
|
138
157
|
dataClass: "closed-enum",
|
|
139
158
|
required: true,
|
|
140
|
-
values: [
|
|
159
|
+
values: [
|
|
160
|
+
"model-context-window-insufficient",
|
|
161
|
+
"no-tool-calling",
|
|
162
|
+
"tool-calling-unverified",
|
|
163
|
+
"model-verification-pending",
|
|
164
|
+
],
|
|
141
165
|
},
|
|
142
166
|
maxPromptTokens: { type: "integer", dataClass: "count", required: false },
|
|
143
167
|
minimumRequiredPromptTokens: { type: "integer", dataClass: "count", required: false },
|
|
144
|
-
probeMode: {
|
|
168
|
+
probeMode: {
|
|
169
|
+
type: "string",
|
|
170
|
+
dataClass: "closed-enum",
|
|
171
|
+
required: true,
|
|
172
|
+
values: ["passive", "pending"],
|
|
173
|
+
},
|
|
145
174
|
completeness: { type: "string", dataClass: "completeness-state", required: true },
|
|
146
175
|
loss: { type: "string", dataClass: "loss-state", required: true },
|
|
147
176
|
},
|
|
@@ -240,6 +269,9 @@ const CODING_SIDECAR_GATEWAY_REJECTED_OPERATION = defineActivityLogOperation({
|
|
|
240
269
|
},
|
|
241
270
|
estimatedPromptTokens: { type: "integer", dataClass: "count", required: false },
|
|
242
271
|
maxPromptTokens: { type: "integer", dataClass: "count", required: false },
|
|
272
|
+
// #3591 review: the bound the prompt was actually admitted against — `maxPromptTokens` less
|
|
273
|
+
// the safety margin and the minimum output allowance (`admissiblePromptTokens`).
|
|
274
|
+
admissiblePromptTokens: { type: "integer", dataClass: "count", required: false },
|
|
243
275
|
inputMessageCount: { type: "integer", dataClass: "count", required: false },
|
|
244
276
|
maxInputMessages: { type: "integer", dataClass: "count", required: false },
|
|
245
277
|
completeness: { type: "string", dataClass: "completeness-state", required: true },
|
|
@@ -272,7 +304,14 @@ const CODING_SIDECAR_GATEWAY_TURN_FAILED_OPERATION = defineActivityLogOperation(
|
|
|
272
304
|
type: "string",
|
|
273
305
|
dataClass: "closed-enum",
|
|
274
306
|
required: true,
|
|
275
|
-
values: [
|
|
307
|
+
values: [
|
|
308
|
+
"provider-failed",
|
|
309
|
+
"stream-incomplete",
|
|
310
|
+
"turn-rejected",
|
|
311
|
+
"output-exhausted",
|
|
312
|
+
"empty-answer",
|
|
313
|
+
"invalid-tool-call",
|
|
314
|
+
],
|
|
276
315
|
},
|
|
277
316
|
published: { type: "boolean", dataClass: "closed-enum", required: true },
|
|
278
317
|
publicationReason: {
|
|
@@ -288,6 +327,23 @@ const CODING_SIDECAR_GATEWAY_TURN_FAILED_OPERATION = defineActivityLogOperation(
|
|
|
288
327
|
"capacity-pressure",
|
|
289
328
|
],
|
|
290
329
|
},
|
|
330
|
+
// The Keiko-code frames and cause classes of the failure, when the turn failed on an error
|
|
331
|
+
// (PR #3617 review): a model-answer failure writes no error-level diagnostic, so this line is
|
|
332
|
+
// where its frames live.
|
|
333
|
+
frames: {
|
|
334
|
+
type: "string-array",
|
|
335
|
+
dataClass: "safe-platform-class",
|
|
336
|
+
required: false,
|
|
337
|
+
maxLength: 512,
|
|
338
|
+
maxItems: 8,
|
|
339
|
+
},
|
|
340
|
+
causeChain: {
|
|
341
|
+
type: "string-array",
|
|
342
|
+
dataClass: "error-kind",
|
|
343
|
+
required: false,
|
|
344
|
+
maxLength: 128,
|
|
345
|
+
maxItems: 5,
|
|
346
|
+
},
|
|
291
347
|
completeness: { type: "string", dataClass: "completeness-state", required: true },
|
|
292
348
|
loss: { type: "string", dataClass: "loss-state", required: true },
|
|
293
349
|
},
|
|
@@ -309,11 +365,12 @@ const CODING_SIDECAR_GATEWAY_USAGE_SETTLED_OPERATION = defineActivityLogOperatio
|
|
|
309
365
|
runId: { type: "string", dataClass: "opaque-id", required: true, maxLength: 128 },
|
|
310
366
|
completionTokens: { type: "integer", dataClass: "count", required: true },
|
|
311
367
|
promptTokens: { type: "integer", dataClass: "count", required: true },
|
|
368
|
+
// `released-unspent`: the provider call never ran, the whole reservation went back (#3602).
|
|
312
369
|
promptSource: {
|
|
313
370
|
type: "string",
|
|
314
371
|
dataClass: "closed-enum",
|
|
315
372
|
required: true,
|
|
316
|
-
values: ["provider-reported", "reserved-estimate"],
|
|
373
|
+
values: ["provider-reported", "reserved-estimate", "released-unspent"],
|
|
317
374
|
},
|
|
318
375
|
promptSettlementStatus: {
|
|
319
376
|
type: "string",
|
|
@@ -355,6 +412,16 @@ const CODING_SIDECAR_GATEWAY_OUTCOME_OPERATION = defineActivityLogOperation({
|
|
|
355
412
|
},
|
|
356
413
|
completionTokens: { type: "integer", dataClass: "count", required: true },
|
|
357
414
|
outputBytes: { type: "integer", dataClass: "count", required: true },
|
|
415
|
+
// The route backstop armed for this turn (#3602 review); absent on lines written before 1.1.7.
|
|
416
|
+
deadlineMs: { type: "integer", dataClass: "duration", required: false },
|
|
417
|
+
// On a cancelled outcome only: which armed abort source ended the turn, so a stall that ran into
|
|
418
|
+
// the backstop, or a slow client the shared SSE path killed, never reads like a client that left.
|
|
419
|
+
cancellationCause: {
|
|
420
|
+
type: "string",
|
|
421
|
+
dataClass: "closed-enum",
|
|
422
|
+
required: false,
|
|
423
|
+
values: ["client-disconnect", "route-deadline", "backpressure-killed", "run-stopped"],
|
|
424
|
+
},
|
|
358
425
|
completeness: { type: "string", dataClass: "completeness-state", required: true },
|
|
359
426
|
loss: { type: "string", dataClass: "loss-state", required: true },
|
|
360
427
|
},
|
|
@@ -463,6 +530,25 @@ export function _classifyBadRequestReasonForTests(result) {
|
|
|
463
530
|
function isModelReasoningEffort(value) {
|
|
464
531
|
return typeof value === "string" && MODEL_REASONING_EFFORT_SET.has(value);
|
|
465
532
|
}
|
|
533
|
+
// A run's one pending challenge wait: an observed request ends it with true; a refused request, a
|
|
534
|
+
// clear, the start signal, or a newer wait for the same run ends it with false and disarms the run.
|
|
535
|
+
function pendingChallengeWait(runId, signal, armed, waiters) {
|
|
536
|
+
return new Promise((resolve) => {
|
|
537
|
+
const settle = (result) => {
|
|
538
|
+
signal.removeEventListener("abort", abort);
|
|
539
|
+
if (waiters.get(runId) === settle)
|
|
540
|
+
waiters.delete(runId);
|
|
541
|
+
if (!result)
|
|
542
|
+
armed.delete(runId);
|
|
543
|
+
resolve(result);
|
|
544
|
+
};
|
|
545
|
+
const abort = () => {
|
|
546
|
+
settle(false);
|
|
547
|
+
};
|
|
548
|
+
waiters.set(runId, settle);
|
|
549
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
550
|
+
});
|
|
551
|
+
}
|
|
466
552
|
export function createOpenCodeGatewayReadinessRegistry() {
|
|
467
553
|
const observed = new Set();
|
|
468
554
|
const armed = new Set();
|
|
@@ -488,21 +574,12 @@ export function createOpenCodeGatewayReadinessRegistry() {
|
|
|
488
574
|
return Promise.resolve(false);
|
|
489
575
|
waiters.get(runId)?.(false);
|
|
490
576
|
armed.add(runId);
|
|
491
|
-
return
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
armed.delete(runId);
|
|
498
|
-
resolve(result);
|
|
499
|
-
};
|
|
500
|
-
const abort = () => {
|
|
501
|
-
settle(false);
|
|
502
|
-
};
|
|
503
|
-
waiters.set(runId, settle);
|
|
504
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
505
|
-
});
|
|
577
|
+
return pendingChallengeWait(runId, signal, armed, waiters);
|
|
578
|
+
},
|
|
579
|
+
refuseChallenge: (runId) => {
|
|
580
|
+
if (!armed.delete(runId))
|
|
581
|
+
return;
|
|
582
|
+
waiters.get(runId)?.(false);
|
|
506
583
|
},
|
|
507
584
|
noteAdoptionGapDiagnosed: (runId) => {
|
|
508
585
|
if (adoptionGapDiagnosed.has(runId))
|
|
@@ -895,8 +972,25 @@ function emitGatewayEvidenceAggregationDiagnostic(deps, runId) {
|
|
|
895
972
|
message: "sidecar-gateway-evidence-aggregation-failed",
|
|
896
973
|
});
|
|
897
974
|
}
|
|
898
|
-
|
|
899
|
-
|
|
975
|
+
// A cancelled outcome names the abort source that ended the turn. Without an aborted source it is
|
|
976
|
+
// the transport path — an SSE or terminal write found the response gone before its `close`
|
|
977
|
+
// listener ran — which is the client leaving, never the deadline.
|
|
978
|
+
function gatewayOutcomeCancellationCause(cancellation, outcome) {
|
|
979
|
+
if (outcome !== "cancelled")
|
|
980
|
+
return undefined;
|
|
981
|
+
return { cancellationCause: cancellation.cause() ?? "client-disconnect" };
|
|
982
|
+
}
|
|
983
|
+
function recordGatewayOutcome(ctx, deps, runId, cancellation, outcome, completionTokens, outputBytes) {
|
|
984
|
+
getServerLogger().info(activityLogEvent(CODING_SIDECAR_GATEWAY_OUTCOME_OPERATION, { correlationId: correlationIdOrUnknown(ctx.correlationId), parentCorrelationId: runId }, {
|
|
985
|
+
runId,
|
|
986
|
+
outcome,
|
|
987
|
+
completionTokens,
|
|
988
|
+
outputBytes,
|
|
989
|
+
deadlineMs: cancellation.deadlineMs,
|
|
990
|
+
...gatewayOutcomeCancellationCause(cancellation, outcome),
|
|
991
|
+
completeness: "complete",
|
|
992
|
+
loss: "none",
|
|
993
|
+
}));
|
|
900
994
|
try {
|
|
901
995
|
void Promise.resolve(evidenceAggregator(deps)?.record({ runId, outcome, completionTokens, outputBytes })).catch(() => {
|
|
902
996
|
emitGatewayEvidenceAggregationDiagnostic(deps, runId);
|
|
@@ -969,8 +1063,9 @@ function budgetValidationError(parsed, runMetadata, estimatedPromptTokens) {
|
|
|
969
1063
|
if (parsed.messages.length > runMetadata.maxInputMessages) {
|
|
970
1064
|
return contextOverflowRequest(`Request body messages exceed profile maxInputMessages (${String(runMetadata.maxInputMessages)}).`);
|
|
971
1065
|
}
|
|
972
|
-
|
|
973
|
-
|
|
1066
|
+
const admissible = admissiblePromptTokens(runMetadata);
|
|
1067
|
+
if (estimatedPromptTokens > admissible) {
|
|
1068
|
+
return contextOverflowRequest(`Request body estimated prompt tokens exceed profile maxPromptTokens (${String(runMetadata.maxPromptTokens)}) less the reserved output allowance (${String(admissible)} admissible).`);
|
|
974
1069
|
}
|
|
975
1070
|
return undefined;
|
|
976
1071
|
}
|
|
@@ -1013,7 +1108,26 @@ function gatewayDiagnosticCorrelation(ctx, runId) {
|
|
|
1013
1108
|
? { correlationId }
|
|
1014
1109
|
: { correlationId, parentCorrelationId: runId };
|
|
1015
1110
|
}
|
|
1016
|
-
|
|
1111
|
+
// A turn the model ended without a usable answer -- nothing at all, reasoning until its output budget
|
|
1112
|
+
// ran out, or a tool call that never parsed or matched its schema -- is the model's answer, not a
|
|
1113
|
+
// server fault: the warn-level turn-failed line names it. An error-level diagnostic opened a support
|
|
1114
|
+
// incident for every such turn; a lab run of the 1.1.8 candidate behind a LiteLLM hosted_vllm route
|
|
1115
|
+
// opened one on its first empty answer.
|
|
1116
|
+
const MODEL_ANSWER_FAILURES = new Set([
|
|
1117
|
+
"output-exhausted",
|
|
1118
|
+
"empty-answer",
|
|
1119
|
+
"invalid-tool-call",
|
|
1120
|
+
]);
|
|
1121
|
+
function isModelAnswerFailure(error) {
|
|
1122
|
+
const cause = modelTurnFailureCode(error);
|
|
1123
|
+
return cause !== undefined && MODEL_ANSWER_FAILURES.has(cause);
|
|
1124
|
+
}
|
|
1125
|
+
// A model-answer failure writes no error-level diagnostic only when its warn-level turn-failed line
|
|
1126
|
+
// was written. A run no longer running or paused gets no such line, so the diagnostic keeps the
|
|
1127
|
+
// failure's class and frames (PR #3617 review).
|
|
1128
|
+
function emitGatewayFailureDiagnostic(ctx, deps, error, runId, turnFailureRecorded) {
|
|
1129
|
+
if (turnFailureRecorded && isModelAnswerFailure(error))
|
|
1130
|
+
return;
|
|
1017
1131
|
emitServerDiagnostic(deps.diagnostics, serverDiagnosticFromError({
|
|
1018
1132
|
...gatewayDiagnosticCorrelation(ctx, runId),
|
|
1019
1133
|
operation: CODING_SIDECAR_GATEWAY_ROUTE,
|
|
@@ -1022,19 +1136,23 @@ function emitGatewayFailureDiagnostic(ctx, deps, error, runId) {
|
|
|
1022
1136
|
redact: (message) => String(deps.redactor(message)),
|
|
1023
1137
|
}));
|
|
1024
1138
|
}
|
|
1025
|
-
|
|
1139
|
+
/** Writes the run's turn-failed line; false for a run that is no longer running or paused. */
|
|
1140
|
+
function reportGatewayTurnFailure(ctx, deps, runId, failureCode, error) {
|
|
1026
1141
|
const snapshot = deps.codingRuntimeOrchestrator?.getSnapshot(runId);
|
|
1027
1142
|
if (snapshot?.state !== "running" && snapshot?.state !== "paused")
|
|
1028
|
-
return;
|
|
1143
|
+
return false;
|
|
1029
1144
|
const publicationReason = gatewayTurnFailurePublication(deps, runId, snapshot, failureCode);
|
|
1030
|
-
|
|
1145
|
+
const run = { revision: snapshot.revision, state: snapshot.state };
|
|
1146
|
+
logGatewayTurnFailure(ctx, runId, run, failureCode, publicationReason, error);
|
|
1147
|
+
return true;
|
|
1031
1148
|
}
|
|
1032
1149
|
function gatewayTurnFailurePublication(deps, runId, snapshot, failureCode) {
|
|
1033
1150
|
const publication = deps.codingRuntimeEventHub?.publishTurnFailure(runId, snapshot.state, snapshot.revision, failureCode);
|
|
1034
1151
|
const publicationReason = publication?.ok === true ? "published" : (publication?.reason ?? "event-hub-unavailable");
|
|
1035
1152
|
return publicationReason;
|
|
1036
1153
|
}
|
|
1037
|
-
function logGatewayTurnFailure(ctx, runId, revision, state, failureCode, publicationReason) {
|
|
1154
|
+
function logGatewayTurnFailure(ctx, runId, { revision, state }, failureCode, publicationReason, error) {
|
|
1155
|
+
const { frames, causeChain } = describeError(error);
|
|
1038
1156
|
getServerLogger().warn(activityLogEvent(CODING_SIDECAR_GATEWAY_TURN_FAILED_OPERATION, {
|
|
1039
1157
|
...gatewayDiagnosticCorrelation(ctx, runId),
|
|
1040
1158
|
errorKind: failureCode === "turn-rejected" ? "validation-failed" : "unavailable",
|
|
@@ -1045,13 +1163,35 @@ function logGatewayTurnFailure(ctx, runId, revision, state, failureCode, publica
|
|
|
1045
1163
|
failureCode,
|
|
1046
1164
|
published: publicationReason === "published",
|
|
1047
1165
|
publicationReason,
|
|
1166
|
+
...(error === undefined || frames === undefined ? {} : { frames }),
|
|
1167
|
+
...(error === undefined || causeChain === undefined ? {} : { causeChain }),
|
|
1048
1168
|
completeness: "complete",
|
|
1049
1169
|
loss: "none",
|
|
1050
1170
|
}));
|
|
1051
1171
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1172
|
+
// The causes the buffered and the streamed path name the same way. Both output-budget exhaustion
|
|
1173
|
+
// and an empty answer are HTTP 200 provider errors, so they are resolved before any status check.
|
|
1174
|
+
function modelTurnFailureCode(error) {
|
|
1175
|
+
// The gateway's own redaction refused an answer nested too deep to walk: a Workbench guard
|
|
1176
|
+
// rejected the turn, whether or not a tool was called, so it is no invalid tool call and keeps
|
|
1177
|
+
// its error-level diagnostic (PR #3617 review). It extends MalformedToolCallError, so it is named
|
|
1178
|
+
// before that check.
|
|
1179
|
+
if (error instanceof ContextOverflowError ||
|
|
1180
|
+
error instanceof ModelRefusalError ||
|
|
1181
|
+
error instanceof ResponseRedactionError)
|
|
1054
1182
|
return "turn-rejected";
|
|
1183
|
+
if (error instanceof ProviderOutputExhaustedError)
|
|
1184
|
+
return "output-exhausted";
|
|
1185
|
+
if (error instanceof ProviderEmptyAnswerError)
|
|
1186
|
+
return "empty-answer";
|
|
1187
|
+
if (error instanceof MalformedToolCallError)
|
|
1188
|
+
return "invalid-tool-call";
|
|
1189
|
+
return undefined;
|
|
1190
|
+
}
|
|
1191
|
+
function gatewayTurnFailureCode(error) {
|
|
1192
|
+
const modelCause = modelTurnFailureCode(error);
|
|
1193
|
+
if (modelCause !== undefined)
|
|
1194
|
+
return modelCause;
|
|
1055
1195
|
if (error instanceof TimeoutError ||
|
|
1056
1196
|
error instanceof TransportError ||
|
|
1057
1197
|
(error instanceof ProviderError && error.httpStatus === 200))
|
|
@@ -1061,8 +1201,9 @@ function gatewayTurnFailureCode(error) {
|
|
|
1061
1201
|
function gatewayStreamFailureCode(error) {
|
|
1062
1202
|
if (gatewaySpendRejectionReason(error) !== undefined)
|
|
1063
1203
|
return "turn-rejected";
|
|
1064
|
-
|
|
1065
|
-
|
|
1204
|
+
const modelCause = modelTurnFailureCode(error);
|
|
1205
|
+
if (modelCause !== undefined)
|
|
1206
|
+
return modelCause;
|
|
1066
1207
|
if (error instanceof AuthenticationError ||
|
|
1067
1208
|
error instanceof RateLimitError ||
|
|
1068
1209
|
error instanceof CircuitOpenError ||
|
|
@@ -1079,7 +1220,9 @@ function gatewayStreamFailureCode(error) {
|
|
|
1079
1220
|
* stream died after N deltas". `partialUsage` rides along through `serverDiagnosticFromError`, so an
|
|
1080
1221
|
* interrupted turn's accumulated token counts stay visible instead of vanishing with the error.
|
|
1081
1222
|
*/
|
|
1082
|
-
function emitGatewayStreamFailureDiagnostic(ctx, deps, error, runId) {
|
|
1223
|
+
function emitGatewayStreamFailureDiagnostic(ctx, deps, error, runId, turnFailureRecorded) {
|
|
1224
|
+
if (turnFailureRecorded && isModelAnswerFailure(error))
|
|
1225
|
+
return;
|
|
1083
1226
|
emitServerDiagnostic(deps.diagnostics, serverDiagnosticFromError({
|
|
1084
1227
|
...gatewayDiagnosticCorrelation(ctx, runId),
|
|
1085
1228
|
operation: CODING_SIDECAR_GATEWAY_ROUTE,
|
|
@@ -1183,7 +1326,8 @@ function toolContractMismatch(tools) {
|
|
|
1183
1326
|
toolMismatchSha256: toolNameSetDigest([...unexpected, "--missing--", ...missing]),
|
|
1184
1327
|
};
|
|
1185
1328
|
}
|
|
1186
|
-
function emitGatewayToolContractDiagnostic(ctx, deps, runId,
|
|
1329
|
+
function emitGatewayToolContractDiagnostic(ctx, deps, runId, parsed) {
|
|
1330
|
+
const { tools } = parsed;
|
|
1187
1331
|
const { code, reason } = toolContractRejectionReason(tools);
|
|
1188
1332
|
emitServerDiagnostic(deps.diagnostics, {
|
|
1189
1333
|
correlationId: ctx.correlationId ?? UNKNOWN_CORRELATION_ID,
|
|
@@ -1196,8 +1340,18 @@ function emitGatewayToolContractDiagnostic(ctx, deps, runId, tools) {
|
|
|
1196
1340
|
code,
|
|
1197
1341
|
});
|
|
1198
1342
|
logGatewayRejection(ctx, runId, 403, reason, toolContractMismatch(tools));
|
|
1343
|
+
refuseReadinessChallenge(deps, runId, parsed);
|
|
1199
1344
|
reportGatewayTurnFailure(ctx, deps, runId, "turn-rejected");
|
|
1200
1345
|
}
|
|
1346
|
+
// Ends a pending readiness challenge at once when the route refused the challenge's own request: a
|
|
1347
|
+
// deterministic refusal of the readiness prompt cannot turn into an observed request later (#3603).
|
|
1348
|
+
// A refused side request, a title or compaction call the runtime sends meanwhile, leaves the
|
|
1349
|
+
// challenge waiting for the readiness prompt (PR #3617 review).
|
|
1350
|
+
function refuseReadinessChallenge(deps, runId, parsed) {
|
|
1351
|
+
if (parsed !== undefined && isRuntimeReadinessProbe(parsed)) {
|
|
1352
|
+
gatewayReadinessRegistry(deps)?.refuseChallenge(runId);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1201
1355
|
/**
|
|
1202
1356
|
* True when a long managed-tool-set history never invoked one governed keiko_* tool: the model is
|
|
1203
1357
|
* burning turns without adopting the projected suite. Question/todowrite calls do not count as
|
|
@@ -1351,25 +1505,37 @@ function gatewayAuthorityKind(authentication) {
|
|
|
1351
1505
|
function unavailableGatewayReason(resolved) {
|
|
1352
1506
|
return resolved.result.status === "unavailable" ? resolved.result.reason : "missing-provider";
|
|
1353
1507
|
}
|
|
1508
|
+
function sidecarSseTransport(ctx, deps) {
|
|
1509
|
+
const correlationId = correlationIdOrUnknown(ctx.correlationId);
|
|
1510
|
+
return {
|
|
1511
|
+
backpressure: new AbortController(),
|
|
1512
|
+
onBackpressure: sseBackpressureReporter(deps, "coding-sidecar-gateway", correlationId),
|
|
1513
|
+
correlationId,
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
// `AbortSignal.any` carries the reason of the source that aborted first, so a client that leaves
|
|
1517
|
+
// after the deadline already fired still reads as the deadline, never the other way round.
|
|
1518
|
+
function gatewayCancellationCause(signal, sources) {
|
|
1519
|
+
if (!signal.aborted)
|
|
1520
|
+
return undefined;
|
|
1521
|
+
if (signal.reason === sources.client.reason)
|
|
1522
|
+
return "client-disconnect";
|
|
1523
|
+
if (signal.reason === sources.deadline.reason)
|
|
1524
|
+
return "route-deadline";
|
|
1525
|
+
if (signal.reason === sources.backpressure.reason)
|
|
1526
|
+
return "backpressure-killed";
|
|
1527
|
+
return "run-stopped";
|
|
1528
|
+
}
|
|
1354
1529
|
// The route's deadline is a backstop BEHIND the gateway's own end-to-end budget, never the budget
|
|
1355
|
-
// itself.
|
|
1356
|
-
//
|
|
1357
|
-
//
|
|
1358
|
-
//
|
|
1359
|
-
//
|
|
1360
|
-
const GATEWAY_ROUTE_DEADLINE_GRACE_MS = 1_000;
|
|
1530
|
+
// itself (`gateway-route-deadline.ts`, shared with the commit draft since the #3602 review). It used
|
|
1531
|
+
// to be the provider's per-attempt `timeoutMs`: the first attempt that hung spent it, and this
|
|
1532
|
+
// deadline, armed before the gateway started its own clock, aborted the retry the gateway had just
|
|
1533
|
+
// scheduled, so a provider timeout surfaced as a cancellation nobody had asked for and failed the
|
|
1534
|
+
// run (coding run 23, 2026-09-11).
|
|
1361
1535
|
export function codingSidecarGatewayRequestDeadlineMs(config, modelId) {
|
|
1362
|
-
|
|
1363
|
-
//
|
|
1364
|
-
|
|
1365
|
-
? 30_000
|
|
1366
|
-
: providerRequestBudgetMs({
|
|
1367
|
-
...provider,
|
|
1368
|
-
timeoutMs: codingWorkbenchProviderTimeoutMs(provider.timeoutMs),
|
|
1369
|
-
});
|
|
1370
|
-
// Armed with AbortSignal.timeout, which fires at once past 2^31 - 1 ms: an absurd budget must not
|
|
1371
|
-
// turn the backstop into an immediate abort.
|
|
1372
|
-
return Math.min(budget + GATEWAY_ROUTE_DEADLINE_GRACE_MS, MAX_TIMER_DELAY_MS);
|
|
1536
|
+
// The sidecar reaches the gateway both ways — a buffered `chat()` answer or a `chatStream()`
|
|
1537
|
+
// read — so its backstop sits behind the longer of the two budgets.
|
|
1538
|
+
return gatewayRouteDeadlineMs(config, modelId, ["buffered", "streamed"]);
|
|
1373
1539
|
}
|
|
1374
1540
|
function gatewayRequestCancellation(ctx, deps, config, modelId, runId) {
|
|
1375
1541
|
const client = new AbortController();
|
|
@@ -1378,11 +1544,18 @@ function gatewayRequestCancellation(ctx, deps, config, modelId, runId) {
|
|
|
1378
1544
|
};
|
|
1379
1545
|
ctx.req.once("aborted", abortClient);
|
|
1380
1546
|
ctx.res.once("close", abortClient);
|
|
1381
|
-
const
|
|
1547
|
+
const deadlineMs = codingSidecarGatewayRequestDeadlineMs(config, modelId);
|
|
1548
|
+
const deadline = AbortSignal.timeout(deadlineMs);
|
|
1549
|
+
const transport = sidecarSseTransport(ctx, deps);
|
|
1382
1550
|
const runSignal = cancellationRegistry(deps)?.signalFor(runId);
|
|
1383
|
-
const signals = [client.signal, deadline, runSignal].filter((signal) => signal !== undefined);
|
|
1551
|
+
const signals = [client.signal, deadline, transport.backpressure.signal, runSignal].filter((signal) => signal !== undefined);
|
|
1552
|
+
const signal = AbortSignal.any(signals);
|
|
1553
|
+
const sources = { client: client.signal, deadline, backpressure: transport.backpressure.signal };
|
|
1384
1554
|
return {
|
|
1385
|
-
signal
|
|
1555
|
+
signal,
|
|
1556
|
+
deadlineMs,
|
|
1557
|
+
transport,
|
|
1558
|
+
cause: () => gatewayCancellationCause(signal, sources),
|
|
1386
1559
|
dispose: () => {
|
|
1387
1560
|
ctx.req.removeListener("aborted", abortClient);
|
|
1388
1561
|
ctx.res.removeListener("close", abortClient);
|
|
@@ -1395,23 +1568,23 @@ function requestForGatewayDelivery(ctx, parsed, delivery, signal) {
|
|
|
1395
1568
|
async function executeGatewayChat(ctx, deps, binding, parsed, runId, delivery) {
|
|
1396
1569
|
const cancellation = gatewayRequestCancellation(ctx, deps, binding.config, delivery.modelAlias, runId);
|
|
1397
1570
|
try {
|
|
1398
|
-
return await dispatchGatewayChat(ctx, deps, binding, parsed, runId, delivery, cancellation
|
|
1571
|
+
return await dispatchGatewayChat(ctx, deps, binding, parsed, runId, delivery, cancellation);
|
|
1399
1572
|
}
|
|
1400
1573
|
finally {
|
|
1401
1574
|
cancellation.dispose();
|
|
1402
1575
|
}
|
|
1403
1576
|
}
|
|
1404
1577
|
// Extracted so `executeGatewayChat` stays under AGENTS.md §6's 50-line ceiling.
|
|
1405
|
-
async function dispatchGatewayChat(ctx, deps, binding, parsed, runId, delivery,
|
|
1578
|
+
async function dispatchGatewayChat(ctx, deps, binding, parsed, runId, delivery, cancellation) {
|
|
1406
1579
|
const { modelAlias, upstreamStreamingSupported } = delivery;
|
|
1407
|
-
const request = requestForGatewayDelivery(ctx, parsed, delivery,
|
|
1580
|
+
const request = requestForGatewayDelivery(ctx, parsed, delivery, cancellation.signal);
|
|
1408
1581
|
const dispatch = {
|
|
1409
1582
|
deps,
|
|
1410
1583
|
binding,
|
|
1411
1584
|
modelAlias,
|
|
1412
1585
|
request,
|
|
1413
1586
|
runId,
|
|
1414
|
-
|
|
1587
|
+
cancellation,
|
|
1415
1588
|
promptTokenReservation: delivery.promptTokenReservation,
|
|
1416
1589
|
};
|
|
1417
1590
|
let bufferedStream;
|
|
@@ -1419,21 +1592,41 @@ async function dispatchGatewayChat(ctx, deps, binding, parsed, runId, delivery,
|
|
|
1419
1592
|
if (parsed.stream && upstreamStreamingSupported) {
|
|
1420
1593
|
return await streamGatewayChat(ctx, dispatch);
|
|
1421
1594
|
}
|
|
1422
|
-
if (parsed.stream)
|
|
1423
|
-
bufferedStream = beginBufferedOpenAiStream(ctx, modelAlias);
|
|
1595
|
+
if (parsed.stream) {
|
|
1596
|
+
bufferedStream = beginBufferedOpenAiStream(ctx, modelAlias, cancellation.transport);
|
|
1597
|
+
if (bufferedStream === undefined)
|
|
1598
|
+
return settleUndeliverableBufferedStream(ctx, dispatch);
|
|
1599
|
+
}
|
|
1424
1600
|
return await executeBufferedGatewayChat(ctx, dispatch, bufferedStream);
|
|
1425
1601
|
}
|
|
1426
1602
|
catch (error) {
|
|
1427
|
-
return settleFailedGatewayChat(ctx, deps, runId,
|
|
1603
|
+
return settleFailedGatewayChat(ctx, deps, runId, cancellation, error, delivery, bufferedStream);
|
|
1428
1604
|
}
|
|
1429
1605
|
}
|
|
1606
|
+
// The opening frame never reached the client — the shared path killed the stream, or the response
|
|
1607
|
+
// was already gone — so no provider call is started for an answer nobody can receive, exactly as
|
|
1608
|
+
// `beginGatewayStream` ends the streamed path (#3602 review). The outcome names the abort source.
|
|
1609
|
+
function settleUndeliverableBufferedStream(ctx, dispatch) {
|
|
1610
|
+
const { deps, runId, cancellation, promptTokenReservation } = dispatch;
|
|
1611
|
+
recordGatewayOutcome(ctx, deps, runId, cancellation, "cancelled", 0, 0);
|
|
1612
|
+
releaseUndispatchedPromptBudget(ctx, deps, runId, promptTokenReservation);
|
|
1613
|
+
return STREAMING;
|
|
1614
|
+
}
|
|
1615
|
+
// A handshake the client would not take leaves no provider call behind, so the reservation is
|
|
1616
|
+
// released rather than kept as spent, and the usage line records the release (zero prompt tokens,
|
|
1617
|
+
// `released-unspent`) so the ledger movement is reconstructible from the log.
|
|
1618
|
+
function releaseUndispatchedPromptBudget(ctx, deps, runId, reservation) {
|
|
1619
|
+
const settlement = releasePromptTokenReservation(deps, reservation);
|
|
1620
|
+
logGatewayCompletionUsage(ctx, runId, { completionTokens: 0, outputBytes: 0 }, "output-byte-estimate", settlement);
|
|
1621
|
+
}
|
|
1430
1622
|
// Extracted so `executeGatewayChat` stays under AGENTS.md §6's 50-line ceiling.
|
|
1431
|
-
function settleFailedGatewayChat(ctx, deps, runId,
|
|
1432
|
-
|
|
1433
|
-
|
|
1623
|
+
function settleFailedGatewayChat(ctx, deps, runId, cancellation, error, delivery, bufferedStream) {
|
|
1624
|
+
const cancelled = cancellation.signal.aborted;
|
|
1625
|
+
recordGatewayOutcome(ctx, deps, runId, cancellation, cancelled ? "cancelled" : "failed", 0, 0);
|
|
1434
1626
|
const spendReason = gatewaySpendRejectionReason(error);
|
|
1435
|
-
|
|
1436
|
-
reportGatewayTurnFailure(ctx, deps, runId, spendReason === undefined ? gatewayTurnFailureCode(error) : "turn-rejected");
|
|
1627
|
+
const turnFailureRecorded = !cancelled &&
|
|
1628
|
+
reportGatewayTurnFailure(ctx, deps, runId, spendReason === undefined ? gatewayTurnFailureCode(error) : "turn-rejected", error);
|
|
1629
|
+
emitGatewayFailureDiagnostic(ctx, deps, error, runId, turnFailureRecorded);
|
|
1437
1630
|
settlePromptTokenReservation(deps, delivery.promptTokenReservation);
|
|
1438
1631
|
if (spendReason !== undefined && bufferedStream === undefined) {
|
|
1439
1632
|
logGatewayRejection(ctx, runId, 403, spendReason);
|
|
@@ -1444,7 +1637,7 @@ function settleFailedGatewayChat(ctx, deps, runId, cancellationSignal, error, de
|
|
|
1444
1637
|
: settleBufferedOpenAiStreamError(bufferedStream, "error");
|
|
1445
1638
|
}
|
|
1446
1639
|
async function executeBufferedGatewayChat(ctx, dispatch, stream) {
|
|
1447
|
-
const { deps, binding, modelAlias, request, runId,
|
|
1640
|
+
const { deps, binding, modelAlias, request, runId, cancellation, promptTokenReservation } = dispatch;
|
|
1448
1641
|
const response = await chatFactoryFor(deps, binding.gateway)(binding.config, modelAlias)(request);
|
|
1449
1642
|
const promptSettlement = settlePromptTokenReservation(deps, promptTokenReservation, response.usage.promptTokens);
|
|
1450
1643
|
const output = outputMetrics(response);
|
|
@@ -1456,9 +1649,9 @@ async function executeBufferedGatewayChat(ctx, dispatch, stream) {
|
|
|
1456
1649
|
};
|
|
1457
1650
|
logGatewayCompletionUsage(ctx, runId, metrics, usage.source, promptSettlement);
|
|
1458
1651
|
const record = (outcome) => {
|
|
1459
|
-
recordGatewayOutcome(ctx, deps, runId, outcome, metrics.completionTokens, metrics.outputBytes);
|
|
1652
|
+
recordGatewayOutcome(ctx, deps, runId, cancellation, outcome, metrics.completionTokens, metrics.outputBytes);
|
|
1460
1653
|
};
|
|
1461
|
-
if (
|
|
1654
|
+
if (cancellation.signal.aborted) {
|
|
1462
1655
|
record("cancelled");
|
|
1463
1656
|
return stream === undefined
|
|
1464
1657
|
? unavailableError()
|
|
@@ -1470,15 +1663,15 @@ async function executeBufferedGatewayChat(ctx, dispatch, stream) {
|
|
|
1470
1663
|
? unavailableError()
|
|
1471
1664
|
: settleBufferedOpenAiStreamError(stream, "length");
|
|
1472
1665
|
}
|
|
1473
|
-
return deliverBufferedGatewayAnswer(ctx,
|
|
1666
|
+
return deliverBufferedGatewayAnswer(ctx, modelAlias, stream, settledResponse, record);
|
|
1474
1667
|
}
|
|
1475
|
-
function deliverBufferedGatewayAnswer(ctx,
|
|
1668
|
+
function deliverBufferedGatewayAnswer(ctx, modelAlias, stream, response, record) {
|
|
1476
1669
|
if (stream === undefined) {
|
|
1477
|
-
|
|
1670
|
+
record("accepted");
|
|
1478
1671
|
return openAiResponse(modelAlias, response);
|
|
1479
1672
|
}
|
|
1480
1673
|
completeBufferedOpenAiStream(stream, response);
|
|
1481
|
-
|
|
1674
|
+
record(ctx.res.writableEnded && !ctx.res.destroyed ? "accepted" : "cancelled");
|
|
1482
1675
|
return STREAMING;
|
|
1483
1676
|
}
|
|
1484
1677
|
// Closed stream state machine keeps iterator, cancellation, and SSE backpressure transitions together.
|
|
@@ -1489,16 +1682,22 @@ async function streamGatewayChat(ctx, dispatch) {
|
|
|
1489
1682
|
iterator = chatStreamFactoryFor(deps, binding.gateway)(binding.config, modelAlias)(request)[Symbol.asyncIterator]();
|
|
1490
1683
|
}
|
|
1491
1684
|
catch (error) {
|
|
1492
|
-
recordGatewayOutcome(ctx, deps, runId, "failed", 0, 0);
|
|
1493
|
-
|
|
1494
|
-
|
|
1685
|
+
recordGatewayOutcome(ctx, deps, runId, dispatch.cancellation, "failed", 0, 0);
|
|
1686
|
+
const turnFailureRecorded = reportGatewayTurnFailure(ctx, deps, runId, gatewayTurnFailureCode(error), error);
|
|
1687
|
+
emitGatewayFailureDiagnostic(ctx, deps, error, runId, turnFailureRecorded);
|
|
1495
1688
|
settlePromptTokenReservation(deps, promptTokenReservation);
|
|
1496
1689
|
return unavailableError();
|
|
1497
1690
|
}
|
|
1498
1691
|
const session = createGatewayStreamSession(ctx, dispatch, iterator);
|
|
1499
1692
|
try {
|
|
1500
|
-
if (beginGatewayStream(session))
|
|
1693
|
+
if (beginGatewayStream(session)) {
|
|
1501
1694
|
await pumpGatewayStreamWithCancellation(deps, session);
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
// The gateway's stream is an async generator: nothing was sent before the first pull, and
|
|
1698
|
+
// the handshake failed before it, so the reservation is released, not kept as spent.
|
|
1699
|
+
releaseUndispatchedPromptBudget(ctx, deps, runId, promptTokenReservation);
|
|
1700
|
+
}
|
|
1502
1701
|
return STREAMING;
|
|
1503
1702
|
}
|
|
1504
1703
|
finally {
|
|
@@ -1509,7 +1708,8 @@ async function streamGatewayChat(ctx, dispatch) {
|
|
|
1509
1708
|
}
|
|
1510
1709
|
}
|
|
1511
1710
|
async function pumpGatewayStreamWithCancellation(deps, session) {
|
|
1512
|
-
const {
|
|
1711
|
+
const { cancellation, iterator } = session;
|
|
1712
|
+
const cancellationSignal = cancellation.signal;
|
|
1513
1713
|
const cancelIterator = () => {
|
|
1514
1714
|
void iterator.return?.();
|
|
1515
1715
|
};
|
|
@@ -1518,10 +1718,9 @@ async function pumpGatewayStreamWithCancellation(deps, session) {
|
|
|
1518
1718
|
await pumpGatewayStream(session);
|
|
1519
1719
|
}
|
|
1520
1720
|
catch (error) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
}
|
|
1721
|
+
const turnFailureRecorded = !cancellationSignal.aborted &&
|
|
1722
|
+
reportGatewayTurnFailure(session.ctx, deps, session.runId, gatewayStreamFailureCode(error), error);
|
|
1723
|
+
emitGatewayStreamFailureDiagnostic(session.ctx, deps, error, session.runId, turnFailureRecorded);
|
|
1525
1724
|
settleGatewayStreamError(session);
|
|
1526
1725
|
}
|
|
1527
1726
|
finally {
|
|
@@ -1529,7 +1728,7 @@ async function pumpGatewayStreamWithCancellation(deps, session) {
|
|
|
1529
1728
|
}
|
|
1530
1729
|
}
|
|
1531
1730
|
function createGatewayStreamSession(ctx, dispatch, iterator) {
|
|
1532
|
-
const { deps, modelAlias, request, runId,
|
|
1731
|
+
const { deps, modelAlias, request, runId, cancellation, promptTokenReservation } = dispatch;
|
|
1533
1732
|
return {
|
|
1534
1733
|
ctx,
|
|
1535
1734
|
deps,
|
|
@@ -1538,7 +1737,7 @@ function createGatewayStreamSession(ctx, dispatch, iterator) {
|
|
|
1538
1737
|
modelId: modelAlias,
|
|
1539
1738
|
request,
|
|
1540
1739
|
runId,
|
|
1541
|
-
|
|
1740
|
+
cancellation,
|
|
1542
1741
|
iterator,
|
|
1543
1742
|
promptTokenReservation,
|
|
1544
1743
|
metrics: {
|
|
@@ -1557,7 +1756,8 @@ function beginGatewayStream(session) {
|
|
|
1557
1756
|
"Cache-Control": "no-store",
|
|
1558
1757
|
Connection: "keep-alive",
|
|
1559
1758
|
});
|
|
1560
|
-
|
|
1759
|
+
const opened = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, { role: "assistant" }, null), session.cancellation.transport);
|
|
1760
|
+
if (!opened) {
|
|
1561
1761
|
ctx.res.destroy();
|
|
1562
1762
|
recordSessionOutcome(session, "cancelled");
|
|
1563
1763
|
return false;
|
|
@@ -1565,15 +1765,16 @@ function beginGatewayStream(session) {
|
|
|
1565
1765
|
return true;
|
|
1566
1766
|
}
|
|
1567
1767
|
function recordSessionOutcome(session, outcome) {
|
|
1568
|
-
const { ctx, deps, runId, metrics } = session;
|
|
1569
|
-
recordGatewayOutcome(ctx, deps, runId, outcome, metrics.completionTokens, metrics.outputBytes);
|
|
1768
|
+
const { ctx, deps, runId, cancellation, metrics } = session;
|
|
1769
|
+
recordGatewayOutcome(ctx, deps, runId, cancellation, outcome, metrics.completionTokens, metrics.outputBytes);
|
|
1570
1770
|
}
|
|
1571
1771
|
function writeSessionTerminal(session, finishReason) {
|
|
1572
|
-
const { ctx, id, created, modelId, metrics } = session;
|
|
1573
|
-
writeStreamTerminal(ctx, id, created, modelId, finishReason, metrics.promptTokens, metrics.completionTokens);
|
|
1772
|
+
const { ctx, id, created, modelId, metrics, cancellation } = session;
|
|
1773
|
+
writeStreamTerminal({ ctx, id, created, modelId, transport: cancellation.transport }, finishReason, metrics.promptTokens, metrics.completionTokens);
|
|
1574
1774
|
}
|
|
1575
1775
|
async function pumpGatewayStream(session) {
|
|
1576
|
-
const {
|
|
1776
|
+
const { cancellation, iterator } = session;
|
|
1777
|
+
const cancellationSignal = cancellation.signal;
|
|
1577
1778
|
for (;;) {
|
|
1578
1779
|
if (isGatewayRequestCancelled(cancellationSignal)) {
|
|
1579
1780
|
await iterator.return?.();
|
|
@@ -1613,7 +1814,8 @@ async function streamGatewayDelta(session, token) {
|
|
|
1613
1814
|
writeSessionTerminal(session, "length");
|
|
1614
1815
|
return false;
|
|
1615
1816
|
}
|
|
1616
|
-
|
|
1817
|
+
const wrote = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, { content: token }, null), session.cancellation.transport);
|
|
1818
|
+
if (!wrote) {
|
|
1617
1819
|
ctx.res.destroy();
|
|
1618
1820
|
await iterator.return?.();
|
|
1619
1821
|
recordSessionOutcome(session, "cancelled");
|
|
@@ -1635,7 +1837,7 @@ async function streamGatewayResponse(session, response) {
|
|
|
1635
1837
|
return;
|
|
1636
1838
|
}
|
|
1637
1839
|
if (response.toolCalls.length > 0) {
|
|
1638
|
-
const wrote = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, { tool_calls: openAiToolCalls(response.toolCalls) }, null));
|
|
1840
|
+
const wrote = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, { tool_calls: openAiToolCalls(response.toolCalls) }, null), session.cancellation.transport);
|
|
1639
1841
|
if (!wrote) {
|
|
1640
1842
|
ctx.res.destroy();
|
|
1641
1843
|
await iterator.return?.();
|
|
@@ -1688,7 +1890,7 @@ function logGatewayCompletionUsage(ctx, runId, metrics, source, promptSettlement
|
|
|
1688
1890
|
}));
|
|
1689
1891
|
}
|
|
1690
1892
|
function settleGatewayStreamError(session) {
|
|
1691
|
-
if (!session.
|
|
1893
|
+
if (!session.cancellation.signal.aborted) {
|
|
1692
1894
|
recordSessionOutcome(session, "failed");
|
|
1693
1895
|
writeSessionTerminal(session, "error");
|
|
1694
1896
|
}
|
|
@@ -1699,7 +1901,8 @@ function settleGatewayStreamError(session) {
|
|
|
1699
1901
|
function isGatewayRequestCancelled(signal) {
|
|
1700
1902
|
return signal.aborted;
|
|
1701
1903
|
}
|
|
1702
|
-
|
|
1904
|
+
/** Returns undefined when the opening SSE frame could not be delivered; the response is destroyed. */
|
|
1905
|
+
function beginBufferedOpenAiStream(ctx, modelId, transport) {
|
|
1703
1906
|
const id = `chatcmpl-${randomUUID()}`;
|
|
1704
1907
|
const created = Math.floor(Date.now() / 1000);
|
|
1705
1908
|
ctx.res.writeHead(200, {
|
|
@@ -1707,19 +1910,26 @@ function beginBufferedOpenAiStream(ctx, modelId) {
|
|
|
1707
1910
|
"Cache-Control": "no-store",
|
|
1708
1911
|
Connection: "keep-alive",
|
|
1709
1912
|
});
|
|
1710
|
-
|
|
1913
|
+
const opened = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, { role: "assistant" }, null), transport);
|
|
1914
|
+
if (!opened) {
|
|
1711
1915
|
ctx.res.destroy();
|
|
1916
|
+
return undefined;
|
|
1712
1917
|
}
|
|
1713
1918
|
return {
|
|
1714
1919
|
ctx,
|
|
1715
1920
|
id,
|
|
1716
1921
|
created,
|
|
1717
1922
|
modelId,
|
|
1718
|
-
|
|
1923
|
+
transport,
|
|
1924
|
+
stopHeartbeat: startSseHeartbeat(ctx.res, BUFFERED_STREAM_HEARTBEAT_MS, undefined, {
|
|
1925
|
+
controller: transport.backpressure,
|
|
1926
|
+
onBackpressure: transport.onBackpressure,
|
|
1927
|
+
correlationId: transport.correlationId,
|
|
1928
|
+
}),
|
|
1719
1929
|
};
|
|
1720
1930
|
}
|
|
1721
1931
|
function completeBufferedOpenAiStream(session, response) {
|
|
1722
|
-
const { ctx, id, created, modelId, stopHeartbeat } = session;
|
|
1932
|
+
const { ctx, id, created, modelId, transport, stopHeartbeat } = session;
|
|
1723
1933
|
stopHeartbeat();
|
|
1724
1934
|
if (response.content.length > 0 || response.toolCalls.length > 0) {
|
|
1725
1935
|
const wrote = writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, {
|
|
@@ -1727,32 +1937,35 @@ function completeBufferedOpenAiStream(session, response) {
|
|
|
1727
1937
|
...(response.toolCalls.length === 0
|
|
1728
1938
|
? {}
|
|
1729
1939
|
: { tool_calls: openAiToolCalls(response.toolCalls) }),
|
|
1730
|
-
}, null));
|
|
1940
|
+
}, null), transport);
|
|
1731
1941
|
if (!wrote) {
|
|
1732
1942
|
ctx.res.destroy();
|
|
1733
1943
|
return STREAMING;
|
|
1734
1944
|
}
|
|
1735
1945
|
}
|
|
1736
|
-
writeStreamTerminal(
|
|
1946
|
+
writeStreamTerminal(session, response.finishReason, response.usage.promptTokens, response.usage.completionTokens);
|
|
1737
1947
|
return STREAMING;
|
|
1738
1948
|
}
|
|
1739
1949
|
function settleBufferedOpenAiStreamError(session, finishReason) {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
writeStreamTerminal(ctx, id, created, modelId, finishReason, 0, 0);
|
|
1950
|
+
session.stopHeartbeat();
|
|
1951
|
+
writeStreamTerminal(session, finishReason, 0, 0);
|
|
1743
1952
|
return STREAMING;
|
|
1744
1953
|
}
|
|
1745
|
-
function bufferedOpenAiStream(ctx, modelId, response) {
|
|
1746
|
-
|
|
1954
|
+
function bufferedOpenAiStream(ctx, deps, modelId, response) {
|
|
1955
|
+
const session = beginBufferedOpenAiStream(ctx, modelId, sidecarSseTransport(ctx, deps));
|
|
1956
|
+
return session === undefined ? STREAMING : completeBufferedOpenAiStream(session, response);
|
|
1747
1957
|
}
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1958
|
+
// False means the frame did not reach the client: either the response was already gone (the
|
|
1959
|
+
// client's own `close` is the abort source that names it) or the shared path killed the stream for
|
|
1960
|
+
// backpressure (its controller is). A caller that sees false stops producing; it never resumes.
|
|
1961
|
+
function writeOpenAiSse(ctx, payload, transport) {
|
|
1962
|
+
if (ctx.res.writableEnded || ctx.res.destroyed)
|
|
1963
|
+
return false;
|
|
1964
|
+
return writeOrDestroy(ctx.res, `data: ${JSON.stringify(payload)}\n\n`, transport.backpressure, transport.onBackpressure, transport.correlationId);
|
|
1753
1965
|
}
|
|
1754
|
-
function writeStreamTerminal(
|
|
1755
|
-
|
|
1966
|
+
function writeStreamTerminal(stream, finishReason, promptTokens, completionTokens) {
|
|
1967
|
+
const { ctx, id, created, modelId, transport } = stream;
|
|
1968
|
+
writeOpenAiSse(ctx, openAiStreamChunk(id, created, modelId, {}, finishReason), transport);
|
|
1756
1969
|
writeOpenAiSse(ctx, {
|
|
1757
1970
|
id,
|
|
1758
1971
|
object: "chat.completion.chunk",
|
|
@@ -1764,7 +1977,7 @@ function writeStreamTerminal(ctx, id, created, modelId, finishReason, promptToke
|
|
|
1764
1977
|
completion_tokens: completionTokens,
|
|
1765
1978
|
total_tokens: promptTokens + completionTokens,
|
|
1766
1979
|
},
|
|
1767
|
-
});
|
|
1980
|
+
}, transport);
|
|
1768
1981
|
if (!ctx.res.writableEnded && !ctx.res.destroyed)
|
|
1769
1982
|
ctx.res.end("data: [DONE]\n\n");
|
|
1770
1983
|
}
|
|
@@ -1788,20 +2001,95 @@ function openAiStreamChunk(id, created, model, delta, finishReason) {
|
|
|
1788
2001
|
*/
|
|
1789
2002
|
function gatewayReadinessProjection(ctx, deps) {
|
|
1790
2003
|
const result = resolveGatewayProfile(deps).result;
|
|
1791
|
-
if (result
|
|
1792
|
-
result.runMetadata.maxPromptTokens >= CODING_WORKBENCH_MINIMUM_CODING_CONTEXT_PROMPT_TOKENS)
|
|
2004
|
+
if (codingContextFits(result))
|
|
1793
2005
|
return result;
|
|
1794
|
-
const
|
|
1795
|
-
if (
|
|
1796
|
-
|
|
1797
|
-
|
|
2006
|
+
const shortfall = result.status === "available" ? "model-context-window-insufficient" : result.reason;
|
|
2007
|
+
if (shortfall !== "model-context-window-insufficient" &&
|
|
2008
|
+
shortfall !== "no-tool-calling" &&
|
|
2009
|
+
shortfall !== "tool-calling-unverified")
|
|
1798
2010
|
return result;
|
|
2011
|
+
// #3591 (1.1.7): while the automatic probe is still running against a slow gateway the shortfall
|
|
2012
|
+
// is not a verdict. The profile says so, and the Workbench re-reads it instead of refusing.
|
|
2013
|
+
const pending = readinessProbePending(deps, result, shortfall);
|
|
2014
|
+
const reason = pending
|
|
2015
|
+
? "model-verification-pending"
|
|
2016
|
+
: shortfall;
|
|
2017
|
+
logReadinessShortfall(ctx, result, reason, pending);
|
|
2018
|
+
// An open verification replaces the stored shortfall for an unavailable projection too (an
|
|
2019
|
+
// unverified tool-calling proof whose probe is still running), or the Workbench would stop
|
|
2020
|
+
// reading and keep the refusal until an unrelated refresh.
|
|
2021
|
+
if (result.status === "available" || pending)
|
|
2022
|
+
return { status: "unavailable", reason };
|
|
2023
|
+
return result;
|
|
2024
|
+
}
|
|
2025
|
+
// One owner for the rule a coding run's prompt needs: the readiness projection of the default model
|
|
2026
|
+
// and the start of a run with a model chosen in the picker both read it (#3603).
|
|
2027
|
+
function codingContextFits(result) {
|
|
2028
|
+
return (result.status === "available" &&
|
|
2029
|
+
result.runMetadata.maxPromptTokens >= CODING_WORKBENCH_MINIMUM_CODING_CONTEXT_PROMPT_TOKENS);
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Why an available coding profile cannot hold a coding run's prompt, or undefined when it can
|
|
2033
|
+
* (#3603). While the automatic probe that could raise the window is still running, the shortfall
|
|
2034
|
+
* is not a verdict yet; the start then names the pending verification instead.
|
|
2035
|
+
*/
|
|
2036
|
+
export function codingContextShortfall(config, result) {
|
|
2037
|
+
if (codingContextFits(result))
|
|
2038
|
+
return undefined;
|
|
2039
|
+
return config !== undefined && isCodingWorkbenchProbePending(config, result.modelAlias)
|
|
2040
|
+
? "model-verification-pending"
|
|
2041
|
+
: "model-context-window-insufficient";
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* The profile a coding run starts with, for the model chosen in the picker or the default one. A
|
|
2045
|
+
* model the gateway does not admit right now is a typed refusal that names the sidecar's reason
|
|
2046
|
+
* (#3565 Observation 17), never a bare Error the orchestrator can only report as
|
|
2047
|
+
* `authority-resolution-failed`; so is a model whose window cannot hold the run's prompt (#3603).
|
|
2048
|
+
*/
|
|
2049
|
+
export function admitCodingRunModel(config, modelId, reasoningEffort) {
|
|
2050
|
+
const resolved = resolveCodingSafeSidecarGatewayProfile(config, {
|
|
2051
|
+
...(modelId === undefined ? {} : { modelId }),
|
|
2052
|
+
});
|
|
2053
|
+
if (resolved.status !== "available" || config === undefined) {
|
|
2054
|
+
throw new CodingRuntimeLaunchRejectedError("model-unavailable", false, resolved.status === "available" ? "missing-config" : resolved.reason);
|
|
2055
|
+
}
|
|
2056
|
+
const contextShortfall = codingContextShortfall(config, resolved);
|
|
2057
|
+
if (contextShortfall !== undefined) {
|
|
2058
|
+
throw new CodingRuntimeLaunchRejectedError("model-unavailable", false, contextShortfall);
|
|
2059
|
+
}
|
|
2060
|
+
return {
|
|
2061
|
+
profileId: resolved.modelAlias,
|
|
2062
|
+
...admittedReasoningEffort(config, resolved.modelAlias, reasoningEffort),
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
function admittedReasoningEffort(config, modelAlias, reasoningEffort) {
|
|
2066
|
+
if (reasoningEffort === undefined)
|
|
2067
|
+
return {};
|
|
2068
|
+
const efforts = findConfiguredCapability(config, modelAlias)?.reasoningEfforts;
|
|
2069
|
+
if (efforts?.includes(reasoningEffort) !== true) {
|
|
2070
|
+
throw new CodingRuntimeLaunchRejectedError("model-unavailable", false, "reasoning-effort-unavailable");
|
|
2071
|
+
}
|
|
2072
|
+
return { reasoningEffort };
|
|
2073
|
+
}
|
|
2074
|
+
function readinessProbePending(deps, result, shortfall) {
|
|
2075
|
+
if (shortfall === "no-tool-calling")
|
|
2076
|
+
return false;
|
|
2077
|
+
const config = currentGatewayConfig(deps);
|
|
2078
|
+
if (config === undefined)
|
|
2079
|
+
return false;
|
|
2080
|
+
// An unavailable projection (an unverified tool-calling proof) names no model: its verification
|
|
2081
|
+
// is open while any model the Workbench could still elect has an open probe.
|
|
2082
|
+
return result.status === "available"
|
|
2083
|
+
? isCodingWorkbenchProbePending(config, result.modelAlias)
|
|
2084
|
+
: isAnyCodingWorkbenchProbePending(config);
|
|
2085
|
+
}
|
|
2086
|
+
function logReadinessShortfall(ctx, result, reason, pending) {
|
|
1799
2087
|
getServerLogger().warn(activityLogEvent(CODING_SIDECAR_GATEWAY_READINESS_INSUFFICIENT_OPERATION, {
|
|
1800
2088
|
correlationId: correlationIdOrUnknown(ctx.correlationId),
|
|
1801
2089
|
errorKind: "unavailable",
|
|
1802
2090
|
}, {
|
|
1803
2091
|
reason,
|
|
1804
|
-
probeMode: "passive",
|
|
2092
|
+
probeMode: pending ? "pending" : "passive",
|
|
1805
2093
|
...(result.status === "available"
|
|
1806
2094
|
? {
|
|
1807
2095
|
maxPromptTokens: result.runMetadata.maxPromptTokens,
|
|
@@ -1811,9 +2099,6 @@ function gatewayReadinessProjection(ctx, deps) {
|
|
|
1811
2099
|
completeness: "complete",
|
|
1812
2100
|
loss: "none",
|
|
1813
2101
|
}));
|
|
1814
|
-
return result.status === "available"
|
|
1815
|
-
? { status: "unavailable", reason: "model-context-window-insufficient" }
|
|
1816
|
-
: result;
|
|
1817
2102
|
}
|
|
1818
2103
|
export async function handleCodingSidecarGatewayProfile(ctx, deps) {
|
|
1819
2104
|
// What Keiko can determine itself it determines itself: a model whose gateway declared no token
|
|
@@ -1822,10 +2107,25 @@ export async function handleCodingSidecarGatewayProfile(ctx, deps) {
|
|
|
1822
2107
|
// Only while the gateway is the usable source: a subscription source, a disabled policy or a
|
|
1823
2108
|
// missing configuration must never cause a paid provider probe (ADR-0124 D5).
|
|
1824
2109
|
if (elected.status === "available" || elected.reason === "tool-calling-unverified") {
|
|
1825
|
-
|
|
2110
|
+
// #3591 (1.1.7): the browser reads this profile with a 15 s deadline while a probe against a
|
|
2111
|
+
// slow gateway may take minutes. Wait a bounded moment for the elected model's proof; past it,
|
|
2112
|
+
// answer with the projection (`model-verification-pending` while the probe runs) and let
|
|
2113
|
+
// the Workbench read again — never leave the read hanging until the browser gives up.
|
|
2114
|
+
await Promise.race([
|
|
2115
|
+
ensureCodingWorkbenchContextWindows(deps, elected.status === "available" ? elected.modelAlias : undefined, ctx.correlationId),
|
|
2116
|
+
boundedProfileWait(),
|
|
2117
|
+
]);
|
|
1826
2118
|
}
|
|
1827
2119
|
return { status: 200, body: gatewayReadinessProjection(ctx, deps) };
|
|
1828
2120
|
}
|
|
2121
|
+
// Under the browser's 15 s read deadline for this profile (keiko-ui `DEFAULT_READ_TIMEOUT_MS`).
|
|
2122
|
+
export const PROFILE_PROBE_WAIT_MS = 8_000;
|
|
2123
|
+
function boundedProfileWait() {
|
|
2124
|
+
return new Promise((resolve) => {
|
|
2125
|
+
const timer = setTimeout(resolve, PROFILE_PROBE_WAIT_MS);
|
|
2126
|
+
timer.unref();
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
1829
2129
|
function upstreamGatewayStreamingSupported(deps, advertisedSupport) {
|
|
1830
2130
|
return advertisedSupport || deps.codingSidecarGatewayChatStreamFactory !== undefined;
|
|
1831
2131
|
}
|
|
@@ -1837,7 +2137,7 @@ function rejectUnmanagedGatewayToolContract(ctx, deps, parsed, authentication) {
|
|
|
1837
2137
|
const declaresTools = parsed.tools !== undefined && parsed.tools.length > 0;
|
|
1838
2138
|
if (!declaresTools || isExactManagedToolSet(parsed.tools))
|
|
1839
2139
|
return undefined;
|
|
1840
|
-
emitGatewayToolContractDiagnostic(ctx, deps, authentication.runId, parsed
|
|
2140
|
+
emitGatewayToolContractDiagnostic(ctx, deps, authentication.runId, parsed);
|
|
1841
2141
|
return forbiddenGatewayRequest();
|
|
1842
2142
|
}
|
|
1843
2143
|
function runtimeGatewayAdmissionResponse(ctx, deps, parsed, authentication, modelAlias) {
|
|
@@ -1851,7 +2151,7 @@ function runtimeGatewayAdmissionResponse(ctx, deps, parsed, authentication, mode
|
|
|
1851
2151
|
function authenticatedGatewayAdmission(ctx, deps, parsed, authentication, modelAlias) {
|
|
1852
2152
|
const registry = gatewayReadinessRegistry(deps);
|
|
1853
2153
|
if (!isAdmittedManagedToolSet(parsed.tools, registry, authentication.runId)) {
|
|
1854
|
-
emitGatewayToolContractDiagnostic(ctx, deps, authentication.runId, parsed
|
|
2154
|
+
emitGatewayToolContractDiagnostic(ctx, deps, authentication.runId, parsed);
|
|
1855
2155
|
return { kind: "handled", result: forbiddenGatewayRequest() };
|
|
1856
2156
|
}
|
|
1857
2157
|
if (isExactManagedToolSet(parsed.tools) &&
|
|
@@ -1859,7 +2159,7 @@ function authenticatedGatewayAdmission(ctx, deps, parsed, authentication, modelA
|
|
|
1859
2159
|
registry?.claim(authentication.runId) === true) {
|
|
1860
2160
|
return {
|
|
1861
2161
|
kind: "handled",
|
|
1862
|
-
result: fixedReadinessResponse(ctx, modelAlias, parsed.stream === true),
|
|
2162
|
+
result: fixedReadinessResponse(ctx, deps, modelAlias, parsed.stream === true),
|
|
1863
2163
|
};
|
|
1864
2164
|
}
|
|
1865
2165
|
if (isExactManagedToolSet(parsed.tools))
|
|
@@ -1893,11 +2193,13 @@ function logChatRequestRejection(ctx, deps, runId, validationError, observed) {
|
|
|
1893
2193
|
? {
|
|
1894
2194
|
estimatedPromptTokens: observed.estimatedPromptTokens,
|
|
1895
2195
|
maxPromptTokens: observed.bounds.maxPromptTokens,
|
|
2196
|
+
admissiblePromptTokens: admissiblePromptTokens(observed.bounds),
|
|
1896
2197
|
inputMessageCount: observed.parsed.messages.length,
|
|
1897
2198
|
maxInputMessages: observed.bounds.maxInputMessages,
|
|
1898
2199
|
}
|
|
1899
2200
|
: undefined;
|
|
1900
2201
|
logGatewayRejection(ctx, runId, validationError.status, reason, boundedEvidence);
|
|
2202
|
+
refuseReadinessChallenge(deps, runId, observed?.parsed);
|
|
1901
2203
|
reportGatewayTurnFailure(ctx, deps, runId, "turn-rejected");
|
|
1902
2204
|
}
|
|
1903
2205
|
async function readValidatedChatRequest(ctx, deps, resolved, authentication) {
|
|
@@ -1933,13 +2235,41 @@ async function runHandleCodingSidecarGatewayChatCompletions(ctx, deps) {
|
|
|
1933
2235
|
return admission.result;
|
|
1934
2236
|
return executeBudgetedGatewayChat(ctx, deps, resolved, parsed, authentication, estimatedPromptTokens, {
|
|
1935
2237
|
modelAlias: resolved.result.modelAlias,
|
|
1936
|
-
maxOutputTokens: resolved.result.runMetadata
|
|
2238
|
+
maxOutputTokens: admittedOutputTokens(resolved.result.runMetadata, estimatedPromptTokens),
|
|
1937
2239
|
upstreamStreamingSupported: upstreamGatewayStreamingSupported(deps, resolved.result.supportsStreaming),
|
|
1938
2240
|
...(authentication.reasoningEffort === undefined
|
|
1939
2241
|
? {}
|
|
1940
2242
|
: { reasoningEffort: authentication.reasoningEffort }),
|
|
1941
2243
|
});
|
|
1942
2244
|
}
|
|
2245
|
+
// #3591 (1.1.7): the run's output reserve (8k for an undeclared limit) is a reserve against the
|
|
2246
|
+
// whole window, and `maxPromptTokens` IS that whole window. A prompt close to the window would
|
|
2247
|
+
// leave the provider a request larger than its window, so the allowance actually sent is what
|
|
2248
|
+
// remains after the prompt and the safety margin — and the least allowance that still lets the
|
|
2249
|
+
// model answer (and report an exhausted budget instead of failing silently) is reserved at
|
|
2250
|
+
// admission, never added on top of a prompt that already fills the window.
|
|
2251
|
+
export const MINIMUM_ADMITTED_OUTPUT_TOKENS = 512;
|
|
2252
|
+
// What a prompt must leave free of `maxPromptTokens`: the window's safety margin plus the minimum
|
|
2253
|
+
// allowance (or the whole reserve, when that is smaller).
|
|
2254
|
+
function reservedWindowTokens(bounds) {
|
|
2255
|
+
return (safetyMarginTokensFor(bounds.maxPromptTokens, bounds.maxOutputTokens) +
|
|
2256
|
+
Math.min(MINIMUM_ADMITTED_OUTPUT_TOKENS, bounds.maxOutputTokens));
|
|
2257
|
+
}
|
|
2258
|
+
// Review of #3591 (P1): admission used to check the prompt against `maxPromptTokens` alone while
|
|
2259
|
+
// the allowance floored at 512, so a prompt just under the window was sent WITH 512 output tokens
|
|
2260
|
+
// — past the window the probe had proven, and the provider refused the turn. The prompt must
|
|
2261
|
+
// leave the margin and the minimum allowance free, or the turn is refused before any call.
|
|
2262
|
+
export function admissiblePromptTokens(bounds) {
|
|
2263
|
+
return bounds.maxPromptTokens - reservedWindowTokens(bounds);
|
|
2264
|
+
}
|
|
2265
|
+
// The allowance an ADMITTED turn sends: the run's reserve, shrunk to what the prompt leaves after
|
|
2266
|
+
// the safety margin. Admission (`admissiblePromptTokens`) guarantees at least the minimum.
|
|
2267
|
+
export function admittedOutputTokens(bounds, estimatedPromptTokens) {
|
|
2268
|
+
const remaining = bounds.maxPromptTokens -
|
|
2269
|
+
estimatedPromptTokens -
|
|
2270
|
+
safetyMarginTokensFor(bounds.maxPromptTokens, bounds.maxOutputTokens);
|
|
2271
|
+
return Math.min(bounds.maxOutputTokens, remaining);
|
|
2272
|
+
}
|
|
1943
2273
|
function logValidatedRequestBounds(ctx, runId, request, bounds, estimatedPromptTokens) {
|
|
1944
2274
|
getServerLogger().info(activityLogEvent(CODING_SIDECAR_GATEWAY_REQUEST_VALIDATED_OPERATION, {
|
|
1945
2275
|
correlationId: correlationIdOrUnknown(ctx.correlationId),
|
|
@@ -1949,6 +2279,7 @@ function logValidatedRequestBounds(ctx, runId, request, bounds, estimatedPromptT
|
|
|
1949
2279
|
maxRequestBytes: bounds.maxRequestBytes,
|
|
1950
2280
|
maxPromptTokens: bounds.maxPromptTokens,
|
|
1951
2281
|
estimatedPromptTokens,
|
|
2282
|
+
maxOutputTokens: admittedOutputTokens(bounds, estimatedPromptTokens),
|
|
1952
2283
|
inputMessageCount: request.messages.length,
|
|
1953
2284
|
completeness: "complete",
|
|
1954
2285
|
loss: "none",
|
|
@@ -1968,7 +2299,7 @@ function executeBudgetedGatewayChat(ctx, deps, binding, parsed, authentication,
|
|
|
1968
2299
|
offerLifetimeMs: opencodeGatewayOfferLifetimeMs(codingSidecarGatewayRequestDeadlineMs(binding.config, profile.modelAlias)),
|
|
1969
2300
|
});
|
|
1970
2301
|
}
|
|
1971
|
-
function fixedReadinessResponse(ctx, modelId, stream) {
|
|
2302
|
+
function fixedReadinessResponse(ctx, deps, modelId, stream) {
|
|
1972
2303
|
const response = {
|
|
1973
2304
|
modelId,
|
|
1974
2305
|
content: "",
|
|
@@ -1983,5 +2314,7 @@ function fixedReadinessResponse(ctx, modelId, stream) {
|
|
|
1983
2314
|
costClass: "low",
|
|
1984
2315
|
},
|
|
1985
2316
|
};
|
|
1986
|
-
return stream
|
|
2317
|
+
return stream
|
|
2318
|
+
? bufferedOpenAiStream(ctx, deps, modelId, response)
|
|
2319
|
+
: openAiResponse(modelId, response);
|
|
1987
2320
|
}
|