@qodo/sdk 0.13.4 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +31 -118
- package/README.md +133 -121
- package/bin/qodo-skills.mjs +13 -0
- package/bundled-skills/code-review/SKILL.md +41 -0
- package/bundled-skills/pr-summary/SKILL.md +59 -0
- package/bundled-skills/test-gen/SKILL.md +47 -0
- package/dist/auth/index.browser.d.ts +38 -0
- package/dist/auth/index.browser.d.ts.map +1 -0
- package/dist/auth/index.browser.js +62 -0
- package/dist/auth/index.browser.js.map +1 -0
- package/dist/auth/index.d.ts +44 -30
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +57 -110
- package/dist/auth/index.js.map +1 -1
- package/dist/client/AgentsClient.d.ts +33 -0
- package/dist/client/AgentsClient.d.ts.map +1 -0
- package/dist/client/AgentsClient.js +40 -0
- package/dist/client/AgentsClient.js.map +1 -0
- package/dist/client/ArtifactsClient.d.ts +43 -0
- package/dist/client/ArtifactsClient.d.ts.map +1 -0
- package/dist/client/ArtifactsClient.js +54 -0
- package/dist/client/ArtifactsClient.js.map +1 -0
- package/dist/client/BulletinClient.d.ts +45 -0
- package/dist/client/BulletinClient.d.ts.map +1 -0
- package/dist/client/BulletinClient.js +51 -0
- package/dist/client/BulletinClient.js.map +1 -0
- package/dist/client/InfoClient.d.ts +58 -0
- package/dist/client/InfoClient.d.ts.map +1 -0
- package/dist/client/InfoClient.js +135 -0
- package/dist/client/InfoClient.js.map +1 -0
- package/dist/client/PipelineClient.d.ts +162 -0
- package/dist/client/PipelineClient.d.ts.map +1 -0
- package/dist/client/PipelineClient.js +340 -0
- package/dist/client/PipelineClient.js.map +1 -0
- package/dist/client/QarRegistryClient.d.ts +396 -0
- package/dist/client/QarRegistryClient.d.ts.map +1 -0
- package/dist/client/QarRegistryClient.js +536 -0
- package/dist/client/QarRegistryClient.js.map +1 -0
- package/dist/client/QodoClient.d.ts +296 -0
- package/dist/client/QodoClient.d.ts.map +1 -0
- package/dist/client/QodoClient.js +803 -0
- package/dist/client/QodoClient.js.map +1 -0
- package/dist/client/SpecsClient.d.ts +121 -0
- package/dist/client/SpecsClient.d.ts.map +1 -0
- package/dist/client/SpecsClient.js +252 -0
- package/dist/client/SpecsClient.js.map +1 -0
- package/dist/client/StateClient.d.ts +35 -0
- package/dist/client/StateClient.d.ts.map +1 -0
- package/dist/client/StateClient.js +36 -0
- package/dist/client/StateClient.js.map +1 -0
- package/dist/client/TaskClient.d.ts +706 -0
- package/dist/client/TaskClient.d.ts.map +1 -0
- package/dist/client/TaskClient.js +2522 -0
- package/dist/client/TaskClient.js.map +1 -0
- package/dist/client/ToolClient.d.ts +278 -0
- package/dist/client/ToolClient.d.ts.map +1 -0
- package/dist/client/ToolClient.js +1115 -0
- package/dist/client/ToolClient.js.map +1 -0
- package/dist/client/a2a/index.d.ts +10 -0
- package/dist/client/a2a/index.d.ts.map +1 -0
- package/dist/client/a2a/index.js +9 -0
- package/dist/client/a2a/index.js.map +1 -0
- package/dist/client/a2a/registerA2A.d.ts +170 -0
- package/dist/client/a2a/registerA2A.d.ts.map +1 -0
- package/dist/client/a2a/registerA2A.js +85 -0
- package/dist/client/a2a/registerA2A.js.map +1 -0
- package/dist/client/connection.d.ts +800 -0
- package/dist/client/connection.d.ts.map +1 -0
- package/dist/client/connection.js +2020 -0
- package/dist/client/connection.js.map +1 -0
- package/dist/client/errors.d.ts +735 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +921 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +20 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/inlineGraph.d.ts +66 -0
- package/dist/client/inlineGraph.d.ts.map +1 -0
- package/dist/client/inlineGraph.js +500 -0
- package/dist/client/inlineGraph.js.map +1 -0
- package/dist/client/internal/thenable.d.ts +27 -0
- package/dist/client/internal/thenable.d.ts.map +1 -0
- package/dist/client/internal/thenable.js +31 -0
- package/dist/client/internal/thenable.js.map +1 -0
- package/dist/client/iterator.d.ts +32 -0
- package/dist/client/iterator.d.ts.map +1 -0
- package/dist/client/iterator.js +73 -0
- package/dist/client/iterator.js.map +1 -0
- package/dist/client/mcp/McpClientPool.browser.d.ts +76 -0
- package/dist/client/mcp/McpClientPool.browser.d.ts.map +1 -0
- package/dist/client/mcp/McpClientPool.browser.js +78 -0
- package/dist/client/mcp/McpClientPool.browser.js.map +1 -0
- package/dist/client/mcp/McpClientPool.d.ts +236 -0
- package/dist/client/mcp/McpClientPool.d.ts.map +1 -0
- package/dist/client/mcp/McpClientPool.js +585 -0
- package/dist/client/mcp/McpClientPool.js.map +1 -0
- package/dist/client/mcp/projection.d.ts +109 -0
- package/dist/client/mcp/projection.d.ts.map +1 -0
- package/dist/client/mcp/projection.js +446 -0
- package/dist/client/mcp/projection.js.map +1 -0
- package/dist/client/mcp/substituteEnv.browser.d.ts +18 -0
- package/dist/client/mcp/substituteEnv.browser.d.ts.map +1 -0
- package/dist/client/mcp/substituteEnv.browser.js +20 -0
- package/dist/client/mcp/substituteEnv.browser.js.map +1 -0
- package/dist/client/mcp/substituteEnv.d.ts +45 -0
- package/dist/client/mcp/substituteEnv.d.ts.map +1 -0
- package/dist/client/mcp/substituteEnv.js +63 -0
- package/dist/client/mcp/substituteEnv.js.map +1 -0
- package/dist/client/observers.d.ts +57 -0
- package/dist/client/observers.d.ts.map +1 -0
- package/dist/client/observers.js +203 -0
- package/dist/client/observers.js.map +1 -0
- package/dist/client/options.d.ts +269 -0
- package/dist/client/options.d.ts.map +1 -0
- package/dist/client/options.js +9 -0
- package/dist/client/options.js.map +1 -0
- package/dist/client/tools/_readlineApprovalPrompt.browser.d.ts +17 -0
- package/dist/client/tools/_readlineApprovalPrompt.browser.d.ts.map +1 -0
- package/dist/client/tools/_readlineApprovalPrompt.browser.js +24 -0
- package/dist/client/tools/_readlineApprovalPrompt.browser.js.map +1 -0
- package/dist/client/tools/_readlineApprovalPrompt.d.ts +33 -0
- package/dist/client/tools/_readlineApprovalPrompt.d.ts.map +1 -0
- package/dist/client/tools/_readlineApprovalPrompt.js +90 -0
- package/dist/client/tools/_readlineApprovalPrompt.js.map +1 -0
- package/dist/client/tools/approval.d.ts +280 -0
- package/dist/client/tools/approval.d.ts.map +1 -0
- package/dist/client/tools/approval.js +229 -0
- package/dist/client/tools/approval.js.map +1 -0
- package/dist/client/tools/bindFunctionToolDefs.d.ts +156 -0
- package/dist/client/tools/bindFunctionToolDefs.d.ts.map +1 -0
- package/dist/client/tools/bindFunctionToolDefs.js +360 -0
- package/dist/client/tools/bindFunctionToolDefs.js.map +1 -0
- package/dist/client/tools/defineFunctionTool.d.ts +277 -0
- package/dist/client/tools/defineFunctionTool.d.ts.map +1 -0
- package/dist/client/tools/defineFunctionTool.js +190 -0
- package/dist/client/tools/defineFunctionTool.js.map +1 -0
- package/dist/client/transport.browser.d.ts +20 -0
- package/dist/client/transport.browser.d.ts.map +1 -0
- package/dist/client/transport.browser.js +29 -0
- package/dist/client/transport.browser.js.map +1 -0
- package/dist/client/transport.d.ts +47 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/transport.js +102 -0
- package/dist/client/transport.js.map +1 -0
- package/dist/client/transport.shared.d.ts +30 -0
- package/dist/client/transport.shared.d.ts.map +1 -0
- package/dist/client/transport.shared.js +40 -0
- package/dist/client/transport.shared.js.map +1 -0
- package/dist/client/uuid.d.ts +32 -0
- package/dist/client/uuid.d.ts.map +1 -0
- package/dist/client/uuid.js +65 -0
- package/dist/client/uuid.js.map +1 -0
- package/dist/index.d.ts +88 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +166 -43
- package/dist/index.js.map +1 -1
- package/dist/observability/attributes.d.ts +136 -0
- package/dist/observability/attributes.d.ts.map +1 -0
- package/dist/observability/attributes.js +184 -0
- package/dist/observability/attributes.js.map +1 -0
- package/dist/observability/index.d.ts +14 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/resolveOTel.browser.d.ts +13 -0
- package/dist/observability/resolveOTel.browser.d.ts.map +1 -0
- package/dist/observability/resolveOTel.browser.js +14 -0
- package/dist/observability/resolveOTel.browser.js.map +1 -0
- package/dist/observability/resolveOTel.d.ts +28 -0
- package/dist/observability/resolveOTel.d.ts.map +1 -0
- package/dist/observability/resolveOTel.js +74 -0
- package/dist/observability/resolveOTel.js.map +1 -0
- package/dist/observability/spans.d.ts +198 -0
- package/dist/observability/spans.d.ts.map +1 -0
- package/dist/observability/spans.js +300 -0
- package/dist/observability/spans.js.map +1 -0
- package/dist/observability/traceContext.d.ts +51 -0
- package/dist/observability/traceContext.d.ts.map +1 -0
- package/dist/observability/traceContext.js +151 -0
- package/dist/observability/traceContext.js.map +1 -0
- package/dist/observability/transportMetrics.d.ts +58 -0
- package/dist/observability/transportMetrics.d.ts.map +1 -0
- package/dist/observability/transportMetrics.js +55 -0
- package/dist/observability/transportMetrics.js.map +1 -0
- package/dist/qar/agentSpec.d.ts +93 -0
- package/dist/qar/agentSpec.d.ts.map +1 -0
- package/dist/qar/agentSpec.js +184 -0
- package/dist/qar/agentSpec.js.map +1 -0
- package/dist/qar/clientEvents.d.ts +86 -0
- package/dist/qar/clientEvents.d.ts.map +1 -0
- package/dist/qar/clientEvents.js +36 -0
- package/dist/qar/clientEvents.js.map +1 -0
- package/dist/qar/envelopes.d.ts +227 -0
- package/dist/qar/envelopes.d.ts.map +1 -0
- package/dist/qar/envelopes.js +67 -0
- package/dist/qar/envelopes.js.map +1 -0
- package/dist/qar/generated/envelope.d.ts +332 -0
- package/dist/qar/generated/envelope.d.ts.map +1 -0
- package/dist/qar/generated/envelope.js +15 -0
- package/dist/qar/generated/envelope.js.map +1 -0
- package/dist/qar/generated/qar-info.d.ts +76 -0
- package/dist/qar/generated/qar-info.d.ts.map +1 -0
- package/dist/qar/generated/qar-info.js +15 -0
- package/dist/qar/generated/qar-info.js.map +1 -0
- package/dist/qar/generated/qodo-task-start-payload.d.ts +54 -0
- package/dist/qar/generated/qodo-task-start-payload.d.ts.map +1 -0
- package/dist/qar/generated/qodo-task-start-payload.js +15 -0
- package/dist/qar/generated/qodo-task-start-payload.js.map +1 -0
- package/dist/qar/ids.d.ts +19 -0
- package/dist/qar/ids.d.ts.map +1 -0
- package/dist/qar/ids.js +11 -0
- package/dist/qar/ids.js.map +1 -0
- package/dist/qar/index.d.ts +24 -0
- package/dist/qar/index.d.ts.map +1 -0
- package/dist/qar/index.js +16 -0
- package/dist/qar/index.js.map +1 -0
- package/dist/qar/info.d.ts +37 -0
- package/dist/qar/info.d.ts.map +1 -0
- package/dist/qar/info.js +17 -0
- package/dist/qar/info.js.map +1 -0
- package/dist/qar/json.d.ts +14 -0
- package/dist/qar/json.d.ts.map +1 -0
- package/dist/qar/json.js +9 -0
- package/dist/qar/json.js.map +1 -0
- package/dist/qar/payloads.d.ts +480 -0
- package/dist/qar/payloads.d.ts.map +1 -0
- package/dist/qar/payloads.js +37 -0
- package/dist/qar/payloads.js.map +1 -0
- package/dist/qar/specs.d.ts +604 -0
- package/dist/qar/specs.d.ts.map +1 -0
- package/dist/qar/specs.js +29 -0
- package/dist/qar/specs.js.map +1 -0
- package/dist/qar/taskEvents.d.ts +25 -0
- package/dist/qar/taskEvents.d.ts.map +1 -0
- package/dist/qar/taskEvents.js +22 -0
- package/dist/qar/taskEvents.js.map +1 -0
- package/dist/qar/trace.d.ts +12 -0
- package/dist/qar/trace.d.ts.map +1 -0
- package/dist/qar/trace.js +12 -0
- package/dist/qar/trace.js.map +1 -0
- package/dist/skills/activation.d.ts +177 -0
- package/dist/skills/activation.d.ts.map +1 -0
- package/dist/skills/activation.js +428 -0
- package/dist/skills/activation.js.map +1 -0
- package/dist/skills/cli/index.browser.d.ts +18 -0
- package/dist/skills/cli/index.browser.d.ts.map +1 -0
- package/dist/skills/cli/index.browser.js +27 -0
- package/dist/skills/cli/index.browser.js.map +1 -0
- package/dist/skills/cli/index.d.ts +37 -0
- package/dist/skills/cli/index.d.ts.map +1 -0
- package/dist/skills/cli/index.js +494 -0
- package/dist/skills/cli/index.js.map +1 -0
- package/dist/skills/events.d.ts +255 -0
- package/dist/skills/events.d.ts.map +1 -0
- package/dist/skills/events.js +224 -0
- package/dist/skills/events.js.map +1 -0
- package/dist/skills/index.d.ts +45 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +34 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/inject.d.ts +57 -0
- package/dist/skills/inject.d.ts.map +1 -0
- package/dist/skills/inject.js +162 -0
- package/dist/skills/inject.js.map +1 -0
- package/dist/skills/lockfile.browser.d.ts +56 -0
- package/dist/skills/lockfile.browser.d.ts.map +1 -0
- package/dist/skills/lockfile.browser.js +55 -0
- package/dist/skills/lockfile.browser.js.map +1 -0
- package/dist/skills/lockfile.d.ts +137 -0
- package/dist/skills/lockfile.d.ts.map +1 -0
- package/dist/skills/lockfile.js +423 -0
- package/dist/skills/lockfile.js.map +1 -0
- package/dist/skills/manager.browser.d.ts +94 -0
- package/dist/skills/manager.browser.d.ts.map +1 -0
- package/dist/skills/manager.browser.js +159 -0
- package/dist/skills/manager.browser.js.map +1 -0
- package/dist/skills/manager.d.ts +362 -0
- package/dist/skills/manager.d.ts.map +1 -0
- package/dist/skills/manager.js +1386 -0
- package/dist/skills/manager.js.map +1 -0
- package/dist/skills/mcp/index.d.ts +15 -0
- package/dist/skills/mcp/index.d.ts.map +1 -0
- package/dist/skills/mcp/index.js +12 -0
- package/dist/skills/mcp/index.js.map +1 -0
- package/dist/skills/mcp/path.browser.d.ts +27 -0
- package/dist/skills/mcp/path.browser.d.ts.map +1 -0
- package/dist/skills/mcp/path.browser.js +33 -0
- package/dist/skills/mcp/path.browser.js.map +1 -0
- package/dist/skills/mcp/path.d.ts +57 -0
- package/dist/skills/mcp/path.d.ts.map +1 -0
- package/dist/skills/mcp/path.js +150 -0
- package/dist/skills/mcp/path.js.map +1 -0
- package/dist/skills/mcp/server.browser.d.ts +32 -0
- package/dist/skills/mcp/server.browser.d.ts.map +1 -0
- package/dist/skills/mcp/server.browser.js +53 -0
- package/dist/skills/mcp/server.browser.js.map +1 -0
- package/dist/skills/mcp/server.d.ts +144 -0
- package/dist/skills/mcp/server.d.ts.map +1 -0
- package/dist/skills/mcp/server.js +841 -0
- package/dist/skills/mcp/server.js.map +1 -0
- package/dist/skills/mcp/types.d.ts +72 -0
- package/dist/skills/mcp/types.d.ts.map +1 -0
- package/dist/skills/mcp/types.js +20 -0
- package/dist/skills/mcp/types.js.map +1 -0
- package/dist/skills/mcp/wireDefs.d.ts +58 -0
- package/dist/skills/mcp/wireDefs.d.ts.map +1 -0
- package/dist/skills/mcp/wireDefs.js +141 -0
- package/dist/skills/mcp/wireDefs.js.map +1 -0
- package/dist/skills/parser.d.ts +63 -0
- package/dist/skills/parser.d.ts.map +1 -0
- package/dist/skills/parser.js +755 -0
- package/dist/skills/parser.js.map +1 -0
- package/dist/skills/prefilter.d.ts +104 -0
- package/dist/skills/prefilter.d.ts.map +1 -0
- package/dist/skills/prefilter.js +398 -0
- package/dist/skills/prefilter.js.map +1 -0
- package/dist/skills/preprocess.d.ts +169 -0
- package/dist/skills/preprocess.d.ts.map +1 -0
- package/dist/skills/preprocess.js +535 -0
- package/dist/skills/preprocess.js.map +1 -0
- package/dist/skills/render.d.ts +83 -0
- package/dist/skills/render.d.ts.map +1 -0
- package/dist/skills/render.js +397 -0
- package/dist/skills/render.js.map +1 -0
- package/dist/skills/sources/index.browser.d.ts +29 -0
- package/dist/skills/sources/index.browser.d.ts.map +1 -0
- package/dist/skills/sources/index.browser.js +16 -0
- package/dist/skills/sources/index.browser.js.map +1 -0
- package/dist/skills/sources/index.d.ts +59 -0
- package/dist/skills/sources/index.d.ts.map +1 -0
- package/dist/skills/sources/index.js +471 -0
- package/dist/skills/sources/index.js.map +1 -0
- package/dist/skills/sources/walk.browser.d.ts +17 -0
- package/dist/skills/sources/walk.browser.d.ts.map +1 -0
- package/dist/skills/sources/walk.browser.js +19 -0
- package/dist/skills/sources/walk.browser.js.map +1 -0
- package/dist/skills/sources/walk.d.ts +68 -0
- package/dist/skills/sources/walk.d.ts.map +1 -0
- package/dist/skills/sources/walk.js +264 -0
- package/dist/skills/sources/walk.js.map +1 -0
- package/dist/skills/substitute.d.ts +87 -0
- package/dist/skills/substitute.d.ts.map +1 -0
- package/dist/skills/substitute.js +322 -0
- package/dist/skills/substitute.js.map +1 -0
- package/dist/skills/testing/SkillKit.browser.d.ts +62 -0
- package/dist/skills/testing/SkillKit.browser.d.ts.map +1 -0
- package/dist/skills/testing/SkillKit.browser.js +41 -0
- package/dist/skills/testing/SkillKit.browser.js.map +1 -0
- package/dist/skills/testing/SkillKit.d.ts +130 -0
- package/dist/skills/testing/SkillKit.d.ts.map +1 -0
- package/dist/skills/testing/SkillKit.js +316 -0
- package/dist/skills/testing/SkillKit.js.map +1 -0
- package/dist/skills/testing/index.d.ts +9 -0
- package/dist/skills/testing/index.d.ts.map +1 -0
- package/dist/skills/testing/index.js +8 -0
- package/dist/skills/testing/index.js.map +1 -0
- package/dist/skills/trust.d.ts +72 -0
- package/dist/skills/trust.d.ts.map +1 -0
- package/dist/skills/trust.js +183 -0
- package/dist/skills/trust.js.map +1 -0
- package/dist/skills/types.d.ts +627 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +85 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/skills/validator.d.ts +95 -0
- package/dist/skills/validator.d.ts.map +1 -0
- package/dist/skills/validator.js +486 -0
- package/dist/skills/validator.js.map +1 -0
- package/dist/tracing/PipelineTracer.d.ts +35 -22
- package/dist/tracing/PipelineTracer.d.ts.map +1 -1
- package/dist/tracing/PipelineTracer.js +106 -61
- package/dist/tracing/PipelineTracer.js.map +1 -1
- package/dist/tracing/SdkTracer.d.ts +63 -61
- package/dist/tracing/SdkTracer.d.ts.map +1 -1
- package/dist/tracing/SdkTracer.js +185 -177
- package/dist/tracing/SdkTracer.js.map +1 -1
- package/dist/tracing/index.d.ts +10 -1
- package/dist/tracing/index.d.ts.map +1 -1
- package/dist/tracing/index.js +9 -0
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/types.d.ts +89 -16
- package/dist/tracing/types.d.ts.map +1 -1
- package/dist/tracing/types.js +17 -4
- package/dist/tracing/types.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +10 -20
- package/dist/version.js.map +1 -1
- package/package.json +53 -39
- package/.claude/skills/qodo-agent/SKILL.md +0 -974
- package/.claude/skills/qodo-agent/assets/programmatic-agent.ts +0 -407
- package/.claude/skills/qodo-agent/references/builtin-tools.md +0 -342
- package/.claude/skills/qodo-agent/references/common-issues.md +0 -537
- package/bin/rg +0 -0
- package/dist/api/agent.d.ts +0 -105
- package/dist/api/agent.d.ts.map +0 -1
- package/dist/api/agent.js +0 -963
- package/dist/api/agent.js.map +0 -1
- package/dist/api/analytics.d.ts +0 -43
- package/dist/api/analytics.d.ts.map +0 -1
- package/dist/api/analytics.js +0 -163
- package/dist/api/analytics.js.map +0 -1
- package/dist/api/http.d.ts +0 -5
- package/dist/api/http.d.ts.map +0 -1
- package/dist/api/http.js +0 -62
- package/dist/api/http.js.map +0 -1
- package/dist/api/index.d.ts +0 -12
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -17
- package/dist/api/index.js.map +0 -1
- package/dist/api/taskTracking.d.ts +0 -54
- package/dist/api/taskTracking.d.ts.map +0 -1
- package/dist/api/taskTracking.js +0 -208
- package/dist/api/taskTracking.js.map +0 -1
- package/dist/api/types.d.ts +0 -93
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -2
- package/dist/api/types.js.map +0 -1
- package/dist/api/utils.d.ts +0 -8
- package/dist/api/utils.d.ts.map +0 -1
- package/dist/api/utils.js +0 -63
- package/dist/api/utils.js.map +0 -1
- package/dist/api/websocket.d.ts +0 -203
- package/dist/api/websocket.d.ts.map +0 -1
- package/dist/api/websocket.js +0 -1166
- package/dist/api/websocket.js.map +0 -1
- package/dist/bin/install-skill.d.ts +0 -14
- package/dist/bin/install-skill.d.ts.map +0 -1
- package/dist/bin/install-skill.js +0 -125
- package/dist/bin/install-skill.js.map +0 -1
- package/dist/bin/run-helpers.d.ts +0 -34
- package/dist/bin/run-helpers.d.ts.map +0 -1
- package/dist/bin/run-helpers.js +0 -186
- package/dist/bin/run-helpers.js.map +0 -1
- package/dist/bin/run.d.ts +0 -13
- package/dist/bin/run.d.ts.map +0 -1
- package/dist/bin/run.js +0 -57
- package/dist/bin/run.js.map +0 -1
- package/dist/clients/index.d.ts +0 -10
- package/dist/clients/index.d.ts.map +0 -1
- package/dist/clients/index.js +0 -8
- package/dist/clients/index.js.map +0 -1
- package/dist/clients/info/InfoClient.d.ts +0 -37
- package/dist/clients/info/InfoClient.d.ts.map +0 -1
- package/dist/clients/info/InfoClient.js +0 -69
- package/dist/clients/info/InfoClient.js.map +0 -1
- package/dist/clients/info/index.d.ts +0 -4
- package/dist/clients/info/index.d.ts.map +0 -1
- package/dist/clients/info/index.js +0 -2
- package/dist/clients/info/index.js.map +0 -1
- package/dist/clients/info/types.d.ts +0 -21
- package/dist/clients/info/types.d.ts.map +0 -1
- package/dist/clients/info/types.js +0 -2
- package/dist/clients/info/types.js.map +0 -1
- package/dist/clients/sessions/SessionsClient.d.ts +0 -34
- package/dist/clients/sessions/SessionsClient.d.ts.map +0 -1
- package/dist/clients/sessions/SessionsClient.js +0 -71
- package/dist/clients/sessions/SessionsClient.js.map +0 -1
- package/dist/clients/sessions/index.d.ts +0 -4
- package/dist/clients/sessions/index.d.ts.map +0 -1
- package/dist/clients/sessions/index.js +0 -2
- package/dist/clients/sessions/index.js.map +0 -1
- package/dist/clients/sessions/types.d.ts +0 -20
- package/dist/clients/sessions/types.d.ts.map +0 -1
- package/dist/clients/sessions/types.js +0 -2
- package/dist/clients/sessions/types.js.map +0 -1
- package/dist/clients/tools/ToolsClient.d.ts +0 -39
- package/dist/clients/tools/ToolsClient.d.ts.map +0 -1
- package/dist/clients/tools/ToolsClient.js +0 -95
- package/dist/clients/tools/ToolsClient.js.map +0 -1
- package/dist/clients/tools/index.d.ts +0 -4
- package/dist/clients/tools/index.d.ts.map +0 -1
- package/dist/clients/tools/index.js +0 -2
- package/dist/clients/tools/index.js.map +0 -1
- package/dist/clients/tools/types.d.ts +0 -14
- package/dist/clients/tools/types.d.ts.map +0 -1
- package/dist/clients/tools/types.js +0 -2
- package/dist/clients/tools/types.js.map +0 -1
- package/dist/config/ConfigManager.d.ts +0 -43
- package/dist/config/ConfigManager.d.ts.map +0 -1
- package/dist/config/ConfigManager.js +0 -472
- package/dist/config/ConfigManager.js.map +0 -1
- package/dist/config/index.d.ts +0 -6
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -7
- package/dist/config/index.js.map +0 -1
- package/dist/config/urlConfig.d.ts +0 -15
- package/dist/config/urlConfig.d.ts.map +0 -1
- package/dist/config/urlConfig.js +0 -75
- package/dist/config/urlConfig.js.map +0 -1
- package/dist/constants/errors.d.ts +0 -2
- package/dist/constants/errors.d.ts.map +0 -1
- package/dist/constants/errors.js +0 -2
- package/dist/constants/errors.js.map +0 -1
- package/dist/constants/index.d.ts +0 -7
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -11
- package/dist/constants/index.js.map +0 -1
- package/dist/constants/tools.d.ts +0 -4
- package/dist/constants/tools.d.ts.map +0 -1
- package/dist/constants/tools.js +0 -4
- package/dist/constants/tools.js.map +0 -1
- package/dist/constants/versions.d.ts +0 -2
- package/dist/constants/versions.d.ts.map +0 -1
- package/dist/constants/versions.js +0 -2
- package/dist/constants/versions.js.map +0 -1
- package/dist/context/buildUserContext.d.ts +0 -18
- package/dist/context/buildUserContext.d.ts.map +0 -1
- package/dist/context/buildUserContext.js +0 -34
- package/dist/context/buildUserContext.js.map +0 -1
- package/dist/context/index.d.ts +0 -9
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -9
- package/dist/context/index.js.map +0 -1
- package/dist/context/messageManager.d.ts +0 -42
- package/dist/context/messageManager.d.ts.map +0 -1
- package/dist/context/messageManager.js +0 -322
- package/dist/context/messageManager.js.map +0 -1
- package/dist/context/taskFocus.d.ts +0 -2
- package/dist/context/taskFocus.d.ts.map +0 -1
- package/dist/context/taskFocus.js +0 -26
- package/dist/context/taskFocus.js.map +0 -1
- package/dist/context/userInput.d.ts +0 -3
- package/dist/context/userInput.d.ts.map +0 -1
- package/dist/context/userInput.js +0 -20
- package/dist/context/userInput.js.map +0 -1
- package/dist/mcp/MCPManager.d.ts +0 -109
- package/dist/mcp/MCPManager.d.ts.map +0 -1
- package/dist/mcp/MCPManager.js +0 -592
- package/dist/mcp/MCPManager.js.map +0 -1
- package/dist/mcp/approvedTools.d.ts +0 -4
- package/dist/mcp/approvedTools.d.ts.map +0 -1
- package/dist/mcp/approvedTools.js +0 -19
- package/dist/mcp/approvedTools.js.map +0 -1
- package/dist/mcp/baseServer.d.ts +0 -75
- package/dist/mcp/baseServer.d.ts.map +0 -1
- package/dist/mcp/baseServer.js +0 -107
- package/dist/mcp/baseServer.js.map +0 -1
- package/dist/mcp/builtinServers.d.ts +0 -15
- package/dist/mcp/builtinServers.d.ts.map +0 -1
- package/dist/mcp/builtinServers.js +0 -141
- package/dist/mcp/builtinServers.js.map +0 -1
- package/dist/mcp/dynamicBEServer.d.ts +0 -20
- package/dist/mcp/dynamicBEServer.d.ts.map +0 -1
- package/dist/mcp/dynamicBEServer.js +0 -52
- package/dist/mcp/dynamicBEServer.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -18
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -23
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/mcpInitialization.d.ts +0 -2
- package/dist/mcp/mcpInitialization.d.ts.map +0 -1
- package/dist/mcp/mcpInitialization.js +0 -56
- package/dist/mcp/mcpInitialization.js.map +0 -1
- package/dist/mcp/servers/filesystem.d.ts +0 -44
- package/dist/mcp/servers/filesystem.d.ts.map +0 -1
- package/dist/mcp/servers/filesystem.js +0 -776
- package/dist/mcp/servers/filesystem.js.map +0 -1
- package/dist/mcp/servers/git.d.ts +0 -18
- package/dist/mcp/servers/git.d.ts.map +0 -1
- package/dist/mcp/servers/git.js +0 -441
- package/dist/mcp/servers/git.js.map +0 -1
- package/dist/mcp/servers/ripgrep.d.ts +0 -39
- package/dist/mcp/servers/ripgrep.d.ts.map +0 -1
- package/dist/mcp/servers/ripgrep.js +0 -550
- package/dist/mcp/servers/ripgrep.js.map +0 -1
- package/dist/mcp/servers/shell.d.ts +0 -20
- package/dist/mcp/servers/shell.d.ts.map +0 -1
- package/dist/mcp/servers/shell.js +0 -519
- package/dist/mcp/servers/shell.js.map +0 -1
- package/dist/mcp/serversRegistry.d.ts +0 -55
- package/dist/mcp/serversRegistry.d.ts.map +0 -1
- package/dist/mcp/serversRegistry.js +0 -416
- package/dist/mcp/serversRegistry.js.map +0 -1
- package/dist/mcp/toolProcessor.d.ts +0 -82
- package/dist/mcp/toolProcessor.d.ts.map +0 -1
- package/dist/mcp/toolProcessor.js +0 -392
- package/dist/mcp/toolProcessor.js.map +0 -1
- package/dist/mcp/types.d.ts +0 -29
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js +0 -2
- package/dist/mcp/types.js.map +0 -1
- package/dist/messages/index.d.ts +0 -8
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -7
- package/dist/messages/index.js.map +0 -1
- package/dist/messages/openai.d.ts +0 -26
- package/dist/messages/openai.d.ts.map +0 -1
- package/dist/messages/openai.js +0 -55
- package/dist/messages/openai.js.map +0 -1
- package/dist/messages/types.d.ts +0 -73
- package/dist/messages/types.d.ts.map +0 -1
- package/dist/messages/types.js +0 -78
- package/dist/messages/types.js.map +0 -1
- package/dist/parser/index.d.ts +0 -72
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js +0 -967
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/types.d.ts +0 -153
- package/dist/parser/types.d.ts.map +0 -1
- package/dist/parser/types.js +0 -6
- package/dist/parser/types.js.map +0 -1
- package/dist/parser/utils.d.ts +0 -18
- package/dist/parser/utils.d.ts.map +0 -1
- package/dist/parser/utils.js +0 -64
- package/dist/parser/utils.js.map +0 -1
- package/dist/sdk/QodoSDK.d.ts +0 -218
- package/dist/sdk/QodoSDK.d.ts.map +0 -1
- package/dist/sdk/QodoSDK.js +0 -1115
- package/dist/sdk/QodoSDK.js.map +0 -1
- package/dist/sdk/artifacts.d.ts +0 -156
- package/dist/sdk/artifacts.d.ts.map +0 -1
- package/dist/sdk/artifacts.js +0 -166
- package/dist/sdk/artifacts.js.map +0 -1
- package/dist/sdk/bootstrap.d.ts +0 -16
- package/dist/sdk/bootstrap.d.ts.map +0 -1
- package/dist/sdk/bootstrap.js +0 -28
- package/dist/sdk/bootstrap.js.map +0 -1
- package/dist/sdk/builders.d.ts +0 -54
- package/dist/sdk/builders.d.ts.map +0 -1
- package/dist/sdk/builders.js +0 -117
- package/dist/sdk/builders.js.map +0 -1
- package/dist/sdk/defaults.d.ts +0 -11
- package/dist/sdk/defaults.d.ts.map +0 -1
- package/dist/sdk/defaults.js +0 -39
- package/dist/sdk/defaults.js.map +0 -1
- package/dist/sdk/discovery.d.ts +0 -2
- package/dist/sdk/discovery.d.ts.map +0 -1
- package/dist/sdk/discovery.js +0 -25
- package/dist/sdk/discovery.js.map +0 -1
- package/dist/sdk/events.d.ts +0 -269
- package/dist/sdk/events.d.ts.map +0 -1
- package/dist/sdk/events.js +0 -69
- package/dist/sdk/events.js.map +0 -1
- package/dist/sdk/exit-expression.d.ts +0 -13
- package/dist/sdk/exit-expression.d.ts.map +0 -1
- package/dist/sdk/exit-expression.js +0 -35
- package/dist/sdk/exit-expression.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -17
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/sdk/index.js +0 -17
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/middleware.d.ts +0 -59
- package/dist/sdk/middleware.d.ts.map +0 -1
- package/dist/sdk/middleware.js +0 -69
- package/dist/sdk/middleware.js.map +0 -1
- package/dist/sdk/pipeline/PipelineBuilder.d.ts +0 -79
- package/dist/sdk/pipeline/PipelineBuilder.d.ts.map +0 -1
- package/dist/sdk/pipeline/PipelineBuilder.js +0 -129
- package/dist/sdk/pipeline/PipelineBuilder.js.map +0 -1
- package/dist/sdk/pipeline/PipelineRunner.d.ts +0 -28
- package/dist/sdk/pipeline/PipelineRunner.d.ts.map +0 -1
- package/dist/sdk/pipeline/PipelineRunner.js +0 -326
- package/dist/sdk/pipeline/PipelineRunner.js.map +0 -1
- package/dist/sdk/pipeline/compiler.d.ts +0 -24
- package/dist/sdk/pipeline/compiler.d.ts.map +0 -1
- package/dist/sdk/pipeline/compiler.js +0 -199
- package/dist/sdk/pipeline/compiler.js.map +0 -1
- package/dist/sdk/pipeline/declarative.d.ts +0 -34
- package/dist/sdk/pipeline/declarative.d.ts.map +0 -1
- package/dist/sdk/pipeline/declarative.js +0 -9
- package/dist/sdk/pipeline/declarative.js.map +0 -1
- package/dist/sdk/pipeline/index.d.ts +0 -20
- package/dist/sdk/pipeline/index.d.ts.map +0 -1
- package/dist/sdk/pipeline/index.js +0 -19
- package/dist/sdk/pipeline/index.js.map +0 -1
- package/dist/sdk/pipeline/types.d.ts +0 -93
- package/dist/sdk/pipeline/types.d.ts.map +0 -1
- package/dist/sdk/pipeline/types.js +0 -10
- package/dist/sdk/pipeline/types.js.map +0 -1
- package/dist/sdk/policies.d.ts +0 -163
- package/dist/sdk/policies.d.ts.map +0 -1
- package/dist/sdk/policies.js +0 -243
- package/dist/sdk/policies.js.map +0 -1
- package/dist/sdk/runner/AgentRunner.d.ts +0 -22
- package/dist/sdk/runner/AgentRunner.d.ts.map +0 -1
- package/dist/sdk/runner/AgentRunner.js +0 -222
- package/dist/sdk/runner/AgentRunner.js.map +0 -1
- package/dist/sdk/runner/finalize.d.ts +0 -56
- package/dist/sdk/runner/finalize.d.ts.map +0 -1
- package/dist/sdk/runner/finalize.js +0 -155
- package/dist/sdk/runner/finalize.js.map +0 -1
- package/dist/sdk/runner/formats.d.ts +0 -7
- package/dist/sdk/runner/formats.d.ts.map +0 -1
- package/dist/sdk/runner/formats.js +0 -76
- package/dist/sdk/runner/formats.js.map +0 -1
- package/dist/sdk/runner/index.d.ts +0 -9
- package/dist/sdk/runner/index.d.ts.map +0 -1
- package/dist/sdk/runner/index.js +0 -9
- package/dist/sdk/runner/index.js.map +0 -1
- package/dist/sdk/runner/progress.d.ts +0 -3
- package/dist/sdk/runner/progress.d.ts.map +0 -1
- package/dist/sdk/runner/progress.js +0 -16
- package/dist/sdk/runner/progress.js.map +0 -1
- package/dist/sdk/schemas.d.ts +0 -72
- package/dist/sdk/schemas.d.ts.map +0 -1
- package/dist/sdk/schemas.js +0 -282
- package/dist/sdk/schemas.js.map +0 -1
- package/dist/sdk/trigger-context.d.ts +0 -24
- package/dist/sdk/trigger-context.d.ts.map +0 -1
- package/dist/sdk/trigger-context.js +0 -136
- package/dist/sdk/trigger-context.js.map +0 -1
- package/dist/session/SessionContext.d.ts +0 -89
- package/dist/session/SessionContext.d.ts.map +0 -1
- package/dist/session/SessionContext.js +0 -410
- package/dist/session/SessionContext.js.map +0 -1
- package/dist/session/environment.d.ts +0 -52
- package/dist/session/environment.d.ts.map +0 -1
- package/dist/session/environment.js +0 -27
- package/dist/session/environment.js.map +0 -1
- package/dist/session/history.d.ts +0 -18
- package/dist/session/history.d.ts.map +0 -1
- package/dist/session/history.js +0 -68
- package/dist/session/history.js.map +0 -1
- package/dist/session/index.d.ts +0 -10
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js +0 -9
- package/dist/session/index.js.map +0 -1
- package/dist/session/serverData.d.ts +0 -38
- package/dist/session/serverData.d.ts.map +0 -1
- package/dist/session/serverData.js +0 -261
- package/dist/session/serverData.js.map +0 -1
- package/dist/tracing/pipelineHelpers.d.ts +0 -29
- package/dist/tracing/pipelineHelpers.d.ts.map +0 -1
- package/dist/tracing/pipelineHelpers.js +0 -224
- package/dist/tracing/pipelineHelpers.js.map +0 -1
- package/dist/tracking/Tracker.d.ts +0 -55
- package/dist/tracking/Tracker.d.ts.map +0 -1
- package/dist/tracking/Tracker.js +0 -217
- package/dist/tracking/Tracker.js.map +0 -1
- package/dist/tracking/index.d.ts +0 -8
- package/dist/tracking/index.d.ts.map +0 -1
- package/dist/tracking/index.js +0 -8
- package/dist/tracking/index.js.map +0 -1
- package/dist/tracking/schemas.d.ts +0 -292
- package/dist/tracking/schemas.d.ts.map +0 -1
- package/dist/tracking/schemas.js +0 -91
- package/dist/tracking/schemas.js.map +0 -1
- package/dist/utils/extractSetFlags.d.ts +0 -6
- package/dist/utils/extractSetFlags.d.ts.map +0 -1
- package/dist/utils/extractSetFlags.js +0 -16
- package/dist/utils/extractSetFlags.js.map +0 -1
- package/dist/utils/formatTimeAgo.d.ts +0 -2
- package/dist/utils/formatTimeAgo.d.ts.map +0 -1
- package/dist/utils/formatTimeAgo.js +0 -20
- package/dist/utils/formatTimeAgo.js.map +0 -1
- package/dist/utils/index.d.ts +0 -12
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -12
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/machineId.d.ts +0 -14
- package/dist/utils/machineId.d.ts.map +0 -1
- package/dist/utils/machineId.js +0 -66
- package/dist/utils/machineId.js.map +0 -1
- package/dist/utils/pathUtils.d.ts +0 -22
- package/dist/utils/pathUtils.d.ts.map +0 -1
- package/dist/utils/pathUtils.js +0 -54
- package/dist/utils/pathUtils.js.map +0 -1
- package/scripts/download-ripgrep.js +0 -269
|
@@ -0,0 +1,800 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Connection` — owns the WebSocket, multiplexes inbound envelopes onto
|
|
3
|
+
* subscriptions, encodes outbound envelopes.
|
|
4
|
+
*
|
|
5
|
+
* One `Connection` per `QodoClient.connect()` call. `tasks.start` /
|
|
6
|
+
* `tasks.continue` register a `TaskSubscription`; `client.receive()` registers
|
|
7
|
+
* a raw subscription that taps every inbound envelope. The connection routes
|
|
8
|
+
* inbound envelopes to subscriptions whose `parent_message_id` chain matches.
|
|
9
|
+
*
|
|
10
|
+
* **Reconnect + replay.** The Connection survives transport drops:
|
|
11
|
+
* subscriptions stay alive while the underlying `WSTransport` is replaced via
|
|
12
|
+
* the same factory. On a fresh transport, every active task subscription's
|
|
13
|
+
* `task_id` + `lastSeenMessageId` is sent back to the server as a
|
|
14
|
+
* `task.resubscribe` envelope; the server replays anything after that anchor
|
|
15
|
+
* from its per-session ring buffer (cap 1000 envelopes per session). No
|
|
16
|
+
* client-side outbox — durability is server-side. The 1.x `OutboxTurn` /
|
|
17
|
+
* `Resume` / `ResumeAck` machinery does not exist here.
|
|
18
|
+
*/
|
|
19
|
+
import type { Envelope } from '../qar/envelopes.js';
|
|
20
|
+
import type { MessageId, SessionId, TaskId, ToolCallId } from '../qar/ids.js';
|
|
21
|
+
import type { TaskEvent } from '../qar/taskEvents.js';
|
|
22
|
+
import type { ClientEvent } from '../qar/clientEvents.js';
|
|
23
|
+
import type { SessionState, TaskCancelPayload, TaskContinuePayload, TaskForceResumePayload, TaskResubscribePayload, TaskStartPayload, ToolResponsePayload } from '../qar/payloads.js';
|
|
24
|
+
import type { ClientReconnectOptions } from './options.js';
|
|
25
|
+
import { TraceContextProvider } from '../observability/traceContext.js';
|
|
26
|
+
import type { SpanLifecycle } from '../observability/spans.js';
|
|
27
|
+
import { TransportMetrics } from '../observability/transportMetrics.js';
|
|
28
|
+
import type { WSTransportFactory, WSTransportFactoryArgs } from './transport.js';
|
|
29
|
+
/**
|
|
30
|
+
* Outbound envelopes the SDK constructs.
|
|
31
|
+
*/
|
|
32
|
+
type OutboundPayload = {
|
|
33
|
+
readonly kind: 'task.start';
|
|
34
|
+
readonly payload: TaskStartPayload;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'task.continue';
|
|
37
|
+
readonly payload: TaskContinuePayload;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'task.cancel';
|
|
40
|
+
readonly payload: TaskCancelPayload;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'task.resubscribe';
|
|
43
|
+
readonly payload: TaskResubscribePayload;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'task.forceResume';
|
|
46
|
+
readonly payload: TaskForceResumePayload;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'tool.response';
|
|
49
|
+
readonly payload: ToolResponsePayload;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A subscription on the inbound stream. The connection calls `consider` for
|
|
53
|
+
* every inbound envelope; the subscription returns `true` if it absorbed the
|
|
54
|
+
* envelope (so terminal envelopes don't double-fire elsewhere) and pushes the
|
|
55
|
+
* envelope to its consumer.
|
|
56
|
+
*
|
|
57
|
+
* `task.resubscribe` and tool tunneling plug in via this shape too, so
|
|
58
|
+
* the routing fabric is shared.
|
|
59
|
+
*/
|
|
60
|
+
export interface InboundSubscription {
|
|
61
|
+
/**
|
|
62
|
+
* Called for every inbound envelope. Returns `true` if this subscription
|
|
63
|
+
* consumed the envelope (used so the connection knows it was routed to at
|
|
64
|
+
* least one task subscriber). Subscriptions are independent — a `tool.request`
|
|
65
|
+
* may belong to a task subscription AND surface on the raw `receive()` tap.
|
|
66
|
+
*/
|
|
67
|
+
consider(env: Envelope): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Push a synthetic SDK-internal `qar.client.*` event onto the consumer's
|
|
70
|
+
* iterator. Distinct from `consider` because client events are not
|
|
71
|
+
* envelopes — they have no `message_id` / `session_id` / `payload`.
|
|
72
|
+
*/
|
|
73
|
+
considerClient(ev: ClientEvent): void;
|
|
74
|
+
/** Called when the underlying transport fails. Subscription should fail its consumer. */
|
|
75
|
+
fail(err: Error): void;
|
|
76
|
+
/** Called when the connection closes cleanly. Subscription should close its consumer. */
|
|
77
|
+
close(): void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Argument shape for the `task.started` resolver. Includes the
|
|
81
|
+
* idempotent-admission fields when the ack reports an existing session
|
|
82
|
+
* (`isNew === false`) or a terminal re-dispatch (`previousTaskId` +
|
|
83
|
+
* `previousState` populated). Old SDK call sites that ignore the new
|
|
84
|
+
* fields keep working — only callers exposing the full
|
|
85
|
+
* `TaskAdmissionResult` Promise on `TaskStartIterable` need them.
|
|
86
|
+
*/
|
|
87
|
+
export interface TaskStartedResolverArgs {
|
|
88
|
+
readonly sessionId: SessionId;
|
|
89
|
+
readonly taskId: TaskId;
|
|
90
|
+
/** `true` for fresh admission; `false` for idempotent existing-session return. */
|
|
91
|
+
readonly isNew: boolean;
|
|
92
|
+
/** Session state at ack time (present when `isNew === false`). */
|
|
93
|
+
readonly state?: SessionState;
|
|
94
|
+
/** Prior task id on terminal re-dispatch (the current `taskId` is the NEW task). */
|
|
95
|
+
readonly previousTaskId?: TaskId;
|
|
96
|
+
/** Prior task's terminal state on terminal re-dispatch. */
|
|
97
|
+
readonly previousState?: SessionState;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Argument shape for the `task.force_resumed` resolver — the ack envelope
|
|
101
|
+
* returned by QAR in response to an outbound `task.forceResume`. Carries
|
|
102
|
+
* the recovered task's id, the post-recovery state (typically
|
|
103
|
+
* `'auto-paused'` after in-flight tool/HITL cancellation; reports the
|
|
104
|
+
* actual state on passthrough), and the inherited derived `session_id`.
|
|
105
|
+
*/
|
|
106
|
+
export interface TaskForceResumedResolverArgs {
|
|
107
|
+
readonly sessionId: SessionId;
|
|
108
|
+
readonly taskId: TaskId;
|
|
109
|
+
readonly state: SessionState;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A single task's inbound stream. Routes by parent-message chain: every
|
|
113
|
+
* envelope whose `parent_message_id` is in the chain becomes part of the chain
|
|
114
|
+
* (its `message_id` joins). Terminal envelopes (`task.done`, `error`) close the
|
|
115
|
+
* iterator.
|
|
116
|
+
*
|
|
117
|
+
* On `Connection`-level reconnect, the matching subscription stays alive and
|
|
118
|
+
* the `Connection` stitches the resubscribe envelope's id into `chain` so the
|
|
119
|
+
* server's replayed envelopes route back here transparently.
|
|
120
|
+
*/
|
|
121
|
+
export declare class TaskSubscription implements InboundSubscription, AsyncIterable<TaskEvent>, AsyncIterator<TaskEvent> {
|
|
122
|
+
private readonly rootMessageId;
|
|
123
|
+
private readonly onEarlyReturn;
|
|
124
|
+
private readonly onClose;
|
|
125
|
+
/**
|
|
126
|
+
* Optional transport-counter store. When provided, `consider` increments
|
|
127
|
+
* `replay_envelopes_received_total` for every absorbed envelope that
|
|
128
|
+
* descends from a replay anchor, and `replay_anchor_missing_total` for
|
|
129
|
+
* every `error { code: 'replay_anchor_missing' }` envelope that routes
|
|
130
|
+
* here.
|
|
131
|
+
*/
|
|
132
|
+
private readonly metrics?;
|
|
133
|
+
private readonly queue;
|
|
134
|
+
private readonly chain;
|
|
135
|
+
private taskId;
|
|
136
|
+
/**
|
|
137
|
+
* `message_id` of the most recent inbound envelope that matched this
|
|
138
|
+
* subscription's chain or `task_id`. Anchor for `task.resubscribe` on
|
|
139
|
+
* reconnect — the server replays everything after this point. Stays
|
|
140
|
+
* `undefined` until the first inbound envelope arrives. Connection-scoped
|
|
141
|
+
* envelopes (`flow.pause` / `flow.resume`) don't update it: they're
|
|
142
|
+
* session-scoped, not task-scoped, so they can't anchor a per-task replay
|
|
143
|
+
* window.
|
|
144
|
+
*/
|
|
145
|
+
private lastSeen;
|
|
146
|
+
/**
|
|
147
|
+
* Outbound `task.resubscribe` message ids whose direct descendant marks
|
|
148
|
+
* the start of replay accounting for this subscription. Seeded by
|
|
149
|
+
* {@link attachOutboundMessageId} (auto-reconnect) and the constructor's
|
|
150
|
+
* `rootIsReplayAnchor` flag (manual `tasks.resubscribe`). Stays small —
|
|
151
|
+
* one entry per resubscribe envelope this subscription owns, not one
|
|
152
|
+
* entry per replay envelope received.
|
|
153
|
+
*/
|
|
154
|
+
private readonly replayAnchors;
|
|
155
|
+
/**
|
|
156
|
+
* Once an envelope absorbed by this subscription has been identified as
|
|
157
|
+
* a replay descendant (its `parent_message_id` was in `replayAnchors`),
|
|
158
|
+
* every subsequently-absorbed envelope is also counted as a replay
|
|
159
|
+
* envelope: QAR's per-session ring buffer replays a contiguous chain
|
|
160
|
+
* after the anchor, so the post-anchor continuation is logically the
|
|
161
|
+
* same wire window as the replay itself.
|
|
162
|
+
*
|
|
163
|
+
* Sticky boolean rather than a growing chain Set — cheaper memory
|
|
164
|
+
* profile for long-running subscriptions that survive many reconnects.
|
|
165
|
+
*/
|
|
166
|
+
private replayCountingActive;
|
|
167
|
+
/**
|
|
168
|
+
* @param rootMessageId message_id of the outbound envelope that started the
|
|
169
|
+
* task (the `task.start` or `task.continue`).
|
|
170
|
+
* @param knownTaskId task_id known up front (only for `tasks.continue` /
|
|
171
|
+
* `tasks.cancel` / `tasks.resubscribe` — `tasks.start`
|
|
172
|
+
* doesn't know the id until the first inbound envelope
|
|
173
|
+
* reveals it). Pre-seeding the matcher closes a
|
|
174
|
+
* routing gap where envelopes that carry
|
|
175
|
+
* `payload.task_id` but no chain link to our outbound
|
|
176
|
+
* message would otherwise be missed.
|
|
177
|
+
* @param onEarlyReturn called once if the consumer breaks the iterator
|
|
178
|
+
* before terminal — best-effort `task.cancel`. Pass a
|
|
179
|
+
* no-op for resubscribe-style subscriptions where
|
|
180
|
+
* breaking the loop must NOT cancel the underlying
|
|
181
|
+
* task (the consumer is observing, not driving).
|
|
182
|
+
* @param onClose called once when the subscription is no longer
|
|
183
|
+
* routable (terminal received OR consumer broke).
|
|
184
|
+
*/
|
|
185
|
+
/** Span lifecycle for the task this subscription represents. Closed on terminal/fail/early-return. */
|
|
186
|
+
private readonly span;
|
|
187
|
+
/**
|
|
188
|
+
* Resolver for the `task.started` admission ack. Receives both the
|
|
189
|
+
* inherited `session_id` (server-derived UUID) AND the canonical
|
|
190
|
+
* `task_id` from the envelope's payload — the two ids are distinct on
|
|
191
|
+
* the admission-retry path, where a retried `task.start` carries a
|
|
192
|
+
* fresh `message_id` while the server's canonical task_id stays bound
|
|
193
|
+
* to the FIRST winning attempt.
|
|
194
|
+
*
|
|
195
|
+
* Provided by `TaskClient.subscribeAndSend` for `task.start`
|
|
196
|
+
* subscriptions only — `task.continue` / `task.cancel` /
|
|
197
|
+
* `task.resubscribe` already know the session_id + task_id from a
|
|
198
|
+
* prior admission and don't wire a resolver. `null` once the resolver
|
|
199
|
+
* has fired (resolved OR rejected) — prevents a second resolution
|
|
200
|
+
* from a spec-violating duplicate ack.
|
|
201
|
+
*/
|
|
202
|
+
private taskStartedResolver;
|
|
203
|
+
/**
|
|
204
|
+
* Resolver for the `task.force_resumed` ack — fires when the SDK's
|
|
205
|
+
* outbound `task.forceResume` envelope's response arrives. Wired by
|
|
206
|
+
* `TaskClient.forceResume`. Mirrors {@link taskStartedResolver} in
|
|
207
|
+
* shape and lifecycle (null after fire; rejected if the subscription
|
|
208
|
+
* closes before the ack lands).
|
|
209
|
+
*/
|
|
210
|
+
private taskForceResumedResolver;
|
|
211
|
+
constructor(rootMessageId: MessageId, knownTaskId: TaskId | undefined, onEarlyReturn: (taskId: TaskId | undefined) => void, onClose: (sub: TaskSubscription) => void, span?: SpanLifecycle,
|
|
212
|
+
/**
|
|
213
|
+
* Optional transport-counter store. When provided, `consider` increments
|
|
214
|
+
* `replay_envelopes_received_total` for every absorbed envelope that
|
|
215
|
+
* descends from a replay anchor, and `replay_anchor_missing_total` for
|
|
216
|
+
* every `error { code: 'replay_anchor_missing' }` envelope that routes
|
|
217
|
+
* here.
|
|
218
|
+
*/
|
|
219
|
+
metrics?: TransportMetrics | undefined,
|
|
220
|
+
/**
|
|
221
|
+
* `true` when `rootMessageId` is itself a `task.resubscribe` envelope —
|
|
222
|
+
* its descendants count as replay envelopes for
|
|
223
|
+
* `replay_envelopes_received_total`. Set by the manual
|
|
224
|
+
* `client.tasks.resubscribe(...)` seam; the `tasks.start` /
|
|
225
|
+
* `tasks.continue` paths leave it `false` so live envelopes don't
|
|
226
|
+
* masquerade as replay until an auto-replay anchor is stitched in via
|
|
227
|
+
* {@link attachOutboundMessageId}.
|
|
228
|
+
*/
|
|
229
|
+
rootIsReplayAnchor?: boolean,
|
|
230
|
+
/**
|
|
231
|
+
* Optional resolver fired with the server-derived `session_id` when
|
|
232
|
+
* the `task.started` admission ack arrives on this subscription's
|
|
233
|
+
* chain. Wired by `task.start` paths so the caller's `TaskStartIterable`
|
|
234
|
+
* can expose the derived id via its `sessionId` Promise.
|
|
235
|
+
*
|
|
236
|
+
* Resolver lifecycle:
|
|
237
|
+
* - Resolved on inbound `task.started` whose `parent_message_id`
|
|
238
|
+
* matches the outbound `task.start.message_id`.
|
|
239
|
+
* - Rejected if the subscription terminates (clean close, transport
|
|
240
|
+
* fail, terminal `task.done` / `error`) before any `task.started`
|
|
241
|
+
* arrives — keeps the consumer's `await stream.sessionId` from
|
|
242
|
+
* hanging forever.
|
|
243
|
+
*/
|
|
244
|
+
taskStartedResolver?: {
|
|
245
|
+
readonly resolve: (args: TaskStartedResolverArgs) => void;
|
|
246
|
+
readonly reject: (err: Error) => void;
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* Optional resolver fired with the recovered task's id +
|
|
250
|
+
* post-recovery state when an inbound `task.force_resumed` ack
|
|
251
|
+
* arrives on this subscription's chain. Wired by
|
|
252
|
+
* `TaskClient.forceResume`. Same lifecycle as
|
|
253
|
+
* {@link taskStartedResolver}: rejected on close/error before
|
|
254
|
+
* the ack lands.
|
|
255
|
+
*/
|
|
256
|
+
taskForceResumedResolver?: {
|
|
257
|
+
readonly resolve: (args: TaskForceResumedResolverArgs) => void;
|
|
258
|
+
readonly reject: (err: Error) => void;
|
|
259
|
+
});
|
|
260
|
+
/** The `task_id` once we've seen the first envelope that carries it. */
|
|
261
|
+
get currentTaskId(): TaskId | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Most-recent inbound envelope's `message_id`, or `undefined` if no inbound
|
|
264
|
+
* matched yet. Public so `Connection.replayActiveTasks` can read it without
|
|
265
|
+
* pinning to a specific subscription class.
|
|
266
|
+
*/
|
|
267
|
+
get lastSeenMessageId(): MessageId | undefined;
|
|
268
|
+
/** Whether this subscription has terminated and stopped accepting envelopes. */
|
|
269
|
+
get isTerminated(): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Stitch a new outbound `message_id` (typically a `task.resubscribe`) into
|
|
272
|
+
* this subscription's chain so the server's replies routed via
|
|
273
|
+
* `parent_message_id` link back here. Idempotent — Set.add no-ops on dups.
|
|
274
|
+
*
|
|
275
|
+
* Called by `Connection` after sending a resubscribe on behalf of an
|
|
276
|
+
* already-live subscription (the auto-replay path on reconnect).
|
|
277
|
+
*/
|
|
278
|
+
attachOutboundMessageId(messageId: MessageId): void;
|
|
279
|
+
consider(env: Envelope): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Reject the pending `task.started` resolver, if any. No-op when the
|
|
282
|
+
* resolver has already fired (resolved earlier on the ack, or rejected
|
|
283
|
+
* by a prior terminal). Idempotent — every terminal path can call
|
|
284
|
+
* this without guarding.
|
|
285
|
+
*/
|
|
286
|
+
private rejectTaskStartedIfPending;
|
|
287
|
+
/**
|
|
288
|
+
* Reject the pending `task.force_resumed` resolver, if any. Mirrors
|
|
289
|
+
* {@link rejectTaskStartedIfPending}: idempotent; called from every
|
|
290
|
+
* terminal path so `tasks.forceResume()` Promises don't hang on
|
|
291
|
+
* close / transport failure.
|
|
292
|
+
*/
|
|
293
|
+
private rejectTaskForceResumedIfPending;
|
|
294
|
+
/**
|
|
295
|
+
* End the task span for a `task.done` envelope. `completed` and `canceled`
|
|
296
|
+
* are both clean terminal states (the consumer asked for the cancel, or the
|
|
297
|
+
* task ran to completion); `failed` records an error.
|
|
298
|
+
*/
|
|
299
|
+
private endSpanForDone;
|
|
300
|
+
considerClient(ev: ClientEvent): void;
|
|
301
|
+
fail(err: Error): void;
|
|
302
|
+
close(): void;
|
|
303
|
+
next(): Promise<IteratorResult<TaskEvent>>;
|
|
304
|
+
return(): Promise<IteratorResult<TaskEvent>>;
|
|
305
|
+
throw(err: unknown): Promise<IteratorResult<TaskEvent>>;
|
|
306
|
+
[Symbol.asyncIterator](): AsyncIterator<TaskEvent>;
|
|
307
|
+
private matches;
|
|
308
|
+
/**
|
|
309
|
+
* Public alias for `matches` — exposed so `Connection.dispatchCancelAcked`
|
|
310
|
+
* can route a `task.canceling` envelope to the correct subscription
|
|
311
|
+
* before broadcasting the synthetic `qar.client.cancel_acked` client
|
|
312
|
+
* event. Same chain + `task_id` matcher used for normal envelope
|
|
313
|
+
* routing.
|
|
314
|
+
*/
|
|
315
|
+
matchesEnvelope(env: Envelope): boolean;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Raw subscription from `client.receive()` — taps every inbound envelope plus
|
|
319
|
+
* the synthetic `qar.client.*` lifecycle events. The yielded type is
|
|
320
|
+
* `Envelope | ClientEvent`; consumers narrow on `kind` (the QAR `kind`
|
|
321
|
+
* discriminator stays disjoint from `qar.client.*`).
|
|
322
|
+
*/
|
|
323
|
+
export declare class RawSubscription implements InboundSubscription, AsyncIterable<Envelope | ClientEvent>, AsyncIterator<Envelope | ClientEvent> {
|
|
324
|
+
private readonly onClose;
|
|
325
|
+
private readonly queue;
|
|
326
|
+
constructor(onClose: (sub: RawSubscription) => void);
|
|
327
|
+
consider(env: Envelope): boolean;
|
|
328
|
+
considerClient(ev: ClientEvent): void;
|
|
329
|
+
fail(err: Error): void;
|
|
330
|
+
close(): void;
|
|
331
|
+
next(): Promise<IteratorResult<Envelope | ClientEvent>>;
|
|
332
|
+
return(): Promise<IteratorResult<Envelope | ClientEvent>>;
|
|
333
|
+
throw(err: unknown): Promise<IteratorResult<Envelope | ClientEvent>>;
|
|
334
|
+
[Symbol.asyncIterator](): AsyncIterator<Envelope | ClientEvent>;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Live connection state. Owns the (replaceable) transport and the set of
|
|
338
|
+
* subscriptions; routes inbound envelopes to subscriptions via `consider`.
|
|
339
|
+
*
|
|
340
|
+
* **No connection-level `sessionId`.** Every `task.start` creates a NEW
|
|
341
|
+
* server-derived session, so an envelope's `session_id` is the TASK's
|
|
342
|
+
* session — not a property of the WebSocket. The SDK tracks
|
|
343
|
+
* `task_id → session_id` and `tool_call_id → session_id` here so that
|
|
344
|
+
* outbound ongoing envelopes can be stamped with the right session at
|
|
345
|
+
* encode time without coupling consumer code to per-task session
|
|
346
|
+
* bookkeeping.
|
|
347
|
+
*/
|
|
348
|
+
export declare class Connection {
|
|
349
|
+
private readonly factory;
|
|
350
|
+
private readonly url;
|
|
351
|
+
private readonly headers;
|
|
352
|
+
private readonly traceContext;
|
|
353
|
+
readonly metrics: TransportMetrics;
|
|
354
|
+
private readonly subscriptions;
|
|
355
|
+
/**
|
|
356
|
+
* Map of `task_id → session_id` populated from inbound `task.started`
|
|
357
|
+
* envelopes. Read by {@link sendEnvelope} when encoding `task.continue`
|
|
358
|
+
* / `task.cancel` / `task.resubscribe` so each ongoing envelope
|
|
359
|
+
* carries the same server-derived `session_id` the server bound during
|
|
360
|
+
* admission — preventing multi-task `session_mismatch` without
|
|
361
|
+
* exposing per-task session bookkeeping on the public API.
|
|
362
|
+
*
|
|
363
|
+
* Lifetime: entries are added when `task.started` lands and PRUNED on
|
|
364
|
+
* `task.done` (the wire's terminal ack — task is fully finished). Any
|
|
365
|
+
* later `task.resubscribe` against the same `task_id` would be a
|
|
366
|
+
* cross-process recovery path that has no in-memory session anyway, so
|
|
367
|
+
* pruning doesn't regress that scenario. Cleared on transport close.
|
|
368
|
+
* The auto-reconnect/replay path uses LIVE (non-terminated)
|
|
369
|
+
* subscriptions and adds the session back via the server's replayed
|
|
370
|
+
* `task.started`, so it's unaffected.
|
|
371
|
+
*
|
|
372
|
+
* **Pre-admission invariant.** A live `TaskSubscription` MAY lack an
|
|
373
|
+
* entry in this map: between `tasks.start` writing its outbound
|
|
374
|
+
* `task.start` and the inbound `task.started` ack landing, the
|
|
375
|
+
* subscription is registered in {@link subscriptions} but the
|
|
376
|
+
* `session_id` is not yet pinned here. A WS drop during this window
|
|
377
|
+
* leaves the subscription in an unrecoverable state per the
|
|
378
|
+
* session-identity contract. {@link replayActiveTasks} pre-checks this
|
|
379
|
+
* map before attempting `task.resubscribe` and short-circuits to
|
|
380
|
+
* `sub.fail(QodoColdAddressError)` for un-pinned subs — see that
|
|
381
|
+
* method's JSDoc for the state-machine narrative.
|
|
382
|
+
*/
|
|
383
|
+
private readonly taskSessions;
|
|
384
|
+
/**
|
|
385
|
+
* Map of `tool_call_id → session_id` populated from inbound `tool.request`
|
|
386
|
+
* envelopes. Read by {@link sendEnvelope} when encoding `tool.response`,
|
|
387
|
+
* which carries `responses: ToolResponseItem[]` and inherits the parent
|
|
388
|
+
* `tool.request`'s session via the first response item's `tool_call_id`.
|
|
389
|
+
*
|
|
390
|
+
* Lifetime: entries are added when `tool.request` lands and PRUNED on
|
|
391
|
+
* EITHER (a) the outbound `tool.response` hits the wire (single-use
|
|
392
|
+
* — one request, one response), OR (b) the owning task terminates
|
|
393
|
+
* via `task.done` without the consumer ever responding (manual handler
|
|
394
|
+
* returned `undefined` to indicate async-respond-later, then the task
|
|
395
|
+
* timed out / canceled / completed without the response). Without (b)
|
|
396
|
+
* the map would accumulate orphan `tool_call_id` entries on long-lived
|
|
397
|
+
* connections. Cleared on transport close.
|
|
398
|
+
*/
|
|
399
|
+
private readonly toolCallSessions;
|
|
400
|
+
/**
|
|
401
|
+
* Reverse index of `session_id → Set<ToolCallId>`. Populated on
|
|
402
|
+
* inbound `tool.request`
|
|
403
|
+
* (one entry per call). Used to sweep {@link toolCallSessions} when
|
|
404
|
+
* the owning task terminates without a `tool.response` ever being
|
|
405
|
+
* sent for some of its outstanding calls — the manual-handler
|
|
406
|
+
* respond-later path explicitly allows this, and without the sweep
|
|
407
|
+
* the per-call map entries would survive forever on long-lived
|
|
408
|
+
* connections.
|
|
409
|
+
*
|
|
410
|
+
* Indexed by `session_id` (not `task_id`) because that's the
|
|
411
|
+
* dimension `tool.request` envelopes carry on the wire — the SDK
|
|
412
|
+
* derives the owning session via the envelope's `session_id` field,
|
|
413
|
+
* not via any task_id field on the payload.
|
|
414
|
+
*/
|
|
415
|
+
private readonly outstandingToolCallsBySession;
|
|
416
|
+
/**
|
|
417
|
+
* Reverse index of outbound `task.continue` message_id →
|
|
418
|
+
* `{ taskId, sessionId }` for envelopes
|
|
419
|
+
* that carried a caller-supplied cold-address `sessionId` override.
|
|
420
|
+
* Populated AFTER the wire write (or queued-drain) succeeds; used to
|
|
421
|
+
* identify which `taskSessions` entry to prune when the server rejects
|
|
422
|
+
* the override with `error { code: 'session_mismatch' }`.
|
|
423
|
+
*
|
|
424
|
+
* Without this index, a wrong cold-address override would pollute
|
|
425
|
+
* {@link taskSessions} (because `sendEnvelope`'s post-send write
|
|
426
|
+
* persists the consumer-supplied value as authoritative) and a
|
|
427
|
+
* subsequent no-override call for the same task would silently reuse
|
|
428
|
+
* the already-rejected session instead of raising
|
|
429
|
+
* {@link QodoColdAddressError}.
|
|
430
|
+
*
|
|
431
|
+
* **Generation safety:** the entry stores the sessionId of the
|
|
432
|
+
* override the offending message carried. Pruning is
|
|
433
|
+
* conditional: we delete `taskSessions[taskId]` ONLY when the
|
|
434
|
+
* authoritative entry still matches the rejected sessionId. If a
|
|
435
|
+
* later send for the same task superseded the override with a fresh
|
|
436
|
+
* (valid) sessionId, the rejection for the stale message must NOT
|
|
437
|
+
* blow away the newer authoritative entry. The reverse-map entry for
|
|
438
|
+
* the offending message_id is deleted unconditionally (it's a per-
|
|
439
|
+
* message tombstone; the message is finished one way or the other).
|
|
440
|
+
*
|
|
441
|
+
* Entries are pruned (a) on inbound `error { code: 'session_mismatch' }`
|
|
442
|
+
* for a known offending_message_id (with generation check), and (b)
|
|
443
|
+
* on inbound `task.done` for the matching task_id (terminal sweep).
|
|
444
|
+
* Cleared on transport-terminal cleanup.
|
|
445
|
+
*/
|
|
446
|
+
private readonly outboundOverrideRefs;
|
|
447
|
+
private state;
|
|
448
|
+
/** App-level backpressure flag. Flipped by inbound `flow.pause` / `flow.resume`. */
|
|
449
|
+
private paused;
|
|
450
|
+
/**
|
|
451
|
+
* FIFO of pre-encoded JSON frames that arrived while paused. Drained in
|
|
452
|
+
* insertion order on `flow.resume`. Pre-encoding at queue-time keeps the
|
|
453
|
+
* drain path a thin pass-through to the transport.
|
|
454
|
+
*
|
|
455
|
+
* Each entry is tagged with the envelope's `messageId` so the owning
|
|
456
|
+
* `TaskSubscription` can retract its frame on early termination (abort or
|
|
457
|
+
* iterator break) — without that link, a queued `task.continue` would
|
|
458
|
+
* still go to the wire on `flow.resume` after the consumer has already
|
|
459
|
+
* canceled, producing `cancel → continue` reordering on the server.
|
|
460
|
+
*/
|
|
461
|
+
private readonly pausedQueue;
|
|
462
|
+
private readonly pausedQueueMax;
|
|
463
|
+
/** Reconnect policy. */
|
|
464
|
+
private readonly reconnectMaxAttempts;
|
|
465
|
+
private readonly reconnectInitialBackoffMs;
|
|
466
|
+
private readonly reconnectBackoffMultiplier;
|
|
467
|
+
/**
|
|
468
|
+
* Pending backoff sleeps. Each entry pairs the timer handle with the
|
|
469
|
+
* Promise's resolve callback so `disconnect()` mid-reconnect can both
|
|
470
|
+
* cancel the timer AND wake the loop up so it observes the new state on
|
|
471
|
+
* the next iteration — without the resolver, clearing the timer would
|
|
472
|
+
* leave the await pending forever.
|
|
473
|
+
*/
|
|
474
|
+
private readonly pendingSleeps;
|
|
475
|
+
/** The active transport. Mutable — replaced on every successful reconnect. */
|
|
476
|
+
private transport;
|
|
477
|
+
/** Bound handler instance reused across every transport (initial + reconnects). */
|
|
478
|
+
private readonly handlers;
|
|
479
|
+
private constructor();
|
|
480
|
+
/**
|
|
481
|
+
* Construct + open a fresh connection through the factory. The connection
|
|
482
|
+
* captures the factory + url + headers so it can re-open on transport drops
|
|
483
|
+
* without the caller threading them through again.
|
|
484
|
+
*/
|
|
485
|
+
static open(args: {
|
|
486
|
+
factory: WSTransportFactory;
|
|
487
|
+
url: string;
|
|
488
|
+
headers: Readonly<Record<string, string>>;
|
|
489
|
+
maxPausedQueueSize?: number;
|
|
490
|
+
reconnect?: ClientReconnectOptions;
|
|
491
|
+
traceContext: TraceContextProvider;
|
|
492
|
+
metrics: TransportMetrics;
|
|
493
|
+
}): Promise<Connection>;
|
|
494
|
+
/**
|
|
495
|
+
* Encode and send an outbound envelope. Returns the assigned `message_id` so
|
|
496
|
+
* the caller can track the parent_message_id chain.
|
|
497
|
+
*
|
|
498
|
+
* Optionally accepts a pre-allocated `messageId` so subscriptions can be
|
|
499
|
+
* registered against a known root before the envelope hits the wire — avoids
|
|
500
|
+
* a race where an inbound reply could be dispatched before the subscription
|
|
501
|
+
* is in place.
|
|
502
|
+
*
|
|
503
|
+
* If the connection is in `flow.pause` and `out.kind` is throttled
|
|
504
|
+
* (`task.start` / `task.continue`), the encoded frame is enqueued and drained
|
|
505
|
+
* once `flow.resume` arrives. The returned `messageId` is still allocated
|
|
506
|
+
* synchronously so callers can register subscriptions against it before the
|
|
507
|
+
* envelope hits the wire — same invariant as the unpaused path.
|
|
508
|
+
*
|
|
509
|
+
* Throws `QodoBackpressureError` when the queue is at its cap.
|
|
510
|
+
*/
|
|
511
|
+
sendEnvelope(out: OutboundPayload, opts?: {
|
|
512
|
+
readonly messageId?: MessageId;
|
|
513
|
+
readonly parentMessageId?: MessageId;
|
|
514
|
+
/**
|
|
515
|
+
* Explicit per-Task `session_id` override. Used by the
|
|
516
|
+
* `ToolRequestDispatcher` to stamp the auto-emitted `tool.response`
|
|
517
|
+
* with the session it captured from the inbound `tool.request` envelope
|
|
518
|
+
* (the source of truth for that response's session). When omitted,
|
|
519
|
+
* {@link sendEnvelope} resolves the `session_id` from
|
|
520
|
+
* {@link taskSessions} or {@link toolCallSessions} based on the
|
|
521
|
+
* envelope's `kind`.
|
|
522
|
+
*/
|
|
523
|
+
readonly sessionId?: SessionId;
|
|
524
|
+
}): MessageId;
|
|
525
|
+
/**
|
|
526
|
+
* Resolve the per-Task `session_id` for an outbound ongoing envelope.
|
|
527
|
+
* Caller-supplied `override` wins (the dispatcher path passes the
|
|
528
|
+
* captured inbound `session_id` directly, and the cold-address
|
|
529
|
+
* public-API path passes the consumer-supplied option); otherwise look
|
|
530
|
+
* up by the payload's task_id (`task.continue` / `task.cancel` /
|
|
531
|
+
* `task.resubscribe`) or by the first response item's tool_call_id
|
|
532
|
+
* (`tool.response`).
|
|
533
|
+
*
|
|
534
|
+
* When neither an override NOR an in-memory entry is available, throw
|
|
535
|
+
* {@link QodoColdAddressError} synchronously. Throwing locally:
|
|
536
|
+
*
|
|
537
|
+
* - puts the cold-address remediation right in the error message
|
|
538
|
+
* (consumer should pass `sessionId` from durable storage),
|
|
539
|
+
* - saves a wire round-trip + the misleading `session_mismatch`
|
|
540
|
+
* error message ("envelope session_id differs from connection
|
|
541
|
+
* session" — true but unactionable),
|
|
542
|
+
* - matches the doctrinal correct shape (make it right, not make
|
|
543
|
+
* it work).
|
|
544
|
+
*
|
|
545
|
+
* The primary cross-task session-leak guard is the lookup itself when
|
|
546
|
+
* admission HAS completed.
|
|
547
|
+
*/
|
|
548
|
+
private resolveOutboundSessionId;
|
|
549
|
+
/**
|
|
550
|
+
* Retract a queued throttled envelope by its `message_id`. Called by
|
|
551
|
+
* `TaskSubscription` when it terminates early (abort signal, iterator
|
|
552
|
+
* break, transport failure) so the consumer's cancel intent doesn't race
|
|
553
|
+
* with their own queued frame on the next `flow.resume`.
|
|
554
|
+
*
|
|
555
|
+
* No-op if the messageId isn't queued (already drained, never queued, or
|
|
556
|
+
* a different envelope kind that doesn't enter the throttle path).
|
|
557
|
+
* Returns whether an entry was removed — informational only.
|
|
558
|
+
*/
|
|
559
|
+
dropQueued(messageId: MessageId): boolean;
|
|
560
|
+
/** Send a raw envelope verbatim — escape hatch. */
|
|
561
|
+
sendRawEnvelope(env: Envelope): void;
|
|
562
|
+
/**
|
|
563
|
+
* Look up the server-derived `session_id` for a known `task_id`.
|
|
564
|
+
* Used by span recorders that want to stamp `qar.session_id`
|
|
565
|
+
* on per-Task spans without coupling caller code to the per-Task lookup
|
|
566
|
+
* map. Returns `undefined` when no `task.started` ack has arrived for
|
|
567
|
+
* this `task_id` yet (the start path's span is opened pre-admission and
|
|
568
|
+
* must tolerate this).
|
|
569
|
+
*/
|
|
570
|
+
getSessionForTask(taskId: TaskId): SessionId | undefined;
|
|
571
|
+
/**
|
|
572
|
+
* Look up the `session_id` of the inbound `tool.request` a given
|
|
573
|
+
* `tool_call_id` came from. Used by `ToolClient.respond` to stamp
|
|
574
|
+
* its outbound `tool.response` span with the right session without
|
|
575
|
+
* threading the value through every call site. Returns `undefined` when
|
|
576
|
+
* no matching `tool.request` arrived (test-only path, or a malformed
|
|
577
|
+
* consumer call).
|
|
578
|
+
*/
|
|
579
|
+
getSessionForToolCall(toolCallId: ToolCallId): SessionId | undefined;
|
|
580
|
+
/** Register a subscription. Caller is responsible for unregistering on close. */
|
|
581
|
+
subscribe(sub: InboundSubscription): void;
|
|
582
|
+
unsubscribe(sub: InboundSubscription): void;
|
|
583
|
+
/**
|
|
584
|
+
* Tear down: close transport, fail all subscriptions cleanly. Idempotent.
|
|
585
|
+
* Called by `QodoClient.disconnect()` and by the `onClose` transport handler
|
|
586
|
+
* for clean closes. Mid-reconnect calls switch state to `disconnecting` so
|
|
587
|
+
* the in-flight loop bails on the next tick.
|
|
588
|
+
*/
|
|
589
|
+
close(): void;
|
|
590
|
+
/**
|
|
591
|
+
* Drop any queued envelopes and clear the paused flag. Called on every
|
|
592
|
+
* tear-down path (clean close, transport error, transport close) — leaving
|
|
593
|
+
* frames in the queue past disconnect would either leak memory or surface
|
|
594
|
+
* stale outbound on a future connection that reused this object.
|
|
595
|
+
*
|
|
596
|
+
* Does NOT clear the per-Task / per-Tool-call session-id lookup maps —
|
|
597
|
+
* those must survive the reconnect window so `replayActiveTasks` can
|
|
598
|
+
* stamp the right `session_id` on each `task.resubscribe` envelope it
|
|
599
|
+
* emits. Final cleanup of the session maps lives in
|
|
600
|
+
* {@link clearTerminalState}, invoked from the actual tear-down paths.
|
|
601
|
+
*/
|
|
602
|
+
private clearBackpressureState;
|
|
603
|
+
/**
|
|
604
|
+
* Drop the per-Task and per-Tool-call session-id lookup maps. Called
|
|
605
|
+
* from terminal cleanup paths (`close`,
|
|
606
|
+
* `cleanCloseAndCleanup`, `failHardAndCleanup`, `finalizeDisconnect`) so
|
|
607
|
+
* a future `connect()` reusing the same `Connection` object starts with
|
|
608
|
+
* an empty session-id table. Distinct from {@link clearBackpressureState}
|
|
609
|
+
* because the reconnect path MUST keep these populated for replay.
|
|
610
|
+
*/
|
|
611
|
+
private clearTerminalState;
|
|
612
|
+
/** Whether the connection accepts outbound sends right now. */
|
|
613
|
+
get isOpen(): boolean;
|
|
614
|
+
/**
|
|
615
|
+
* Whether the connection is mid-reconnect. `isOpen` is false during this
|
|
616
|
+
* window; outbound sends throw. Tests + observability surfaces read this
|
|
617
|
+
* to render a "reconnecting" indicator.
|
|
618
|
+
*/
|
|
619
|
+
get isReconnecting(): boolean;
|
|
620
|
+
/**
|
|
621
|
+
* Whether the server has signalled `flow.pause` and we have not yet seen
|
|
622
|
+
* `flow.resume`. While `true`, throttled outbound kinds are queued.
|
|
623
|
+
*/
|
|
624
|
+
get isPaused(): boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Snapshot of the paused-queue depth. Useful for tests and observability;
|
|
627
|
+
* not a live counter (no subscription, no event).
|
|
628
|
+
*/
|
|
629
|
+
get pausedQueueDepth(): number;
|
|
630
|
+
/** Raw outbound predicate — connected AND transport is in OPEN state. */
|
|
631
|
+
private canSend;
|
|
632
|
+
private dispatch;
|
|
633
|
+
/**
|
|
634
|
+
* Translate an inbound `task.canceling` envelope into a typed
|
|
635
|
+
* `ClientCancelAckedEvent` and route it to the subscription whose chain
|
|
636
|
+
* (or `task_id`) matches. Scoped — not connection-wide — so a consumer
|
|
637
|
+
* running multiple tasks only sees the ack for the task they're
|
|
638
|
+
* iterating.
|
|
639
|
+
*
|
|
640
|
+
* Skips taps (`RawSubscription` already received the envelope through
|
|
641
|
+
* `fanout`); fans into `TaskSubscription` (matching by `task_id` /
|
|
642
|
+
* chain) and observer ports (no-op `considerClient`).
|
|
643
|
+
*/
|
|
644
|
+
private dispatchCancelAcked;
|
|
645
|
+
/**
|
|
646
|
+
* Flush the paused queue in FIFO order. Stops if the transport closes
|
|
647
|
+
* mid-drain (a `transport.send` after close would throw and lose the
|
|
648
|
+
* remaining frames silently). Caller is responsible for ensuring `paused`
|
|
649
|
+
* is `false` before invoking — this method does not reset the flag.
|
|
650
|
+
*
|
|
651
|
+
* Drain failure preserves queue state. The earlier shape ("slice +
|
|
652
|
+
* clear + iterate") dropped every
|
|
653
|
+
* REMAINING entry (including their `overrideToSave` metadata) when
|
|
654
|
+
* `transport.send` threw mid-drain. The post-send-success invariant
|
|
655
|
+
* says the override write is conditional on wire-success; an entry
|
|
656
|
+
* that
|
|
657
|
+
* never reaches the wire MUST stay in the queue so the next drain
|
|
658
|
+
* (after the transport recovers and `flow.resume` arrives again,
|
|
659
|
+
* or via the reconnect-loop's eventual retry) can replay it with
|
|
660
|
+
* the same metadata intact.
|
|
661
|
+
*
|
|
662
|
+
* New shape: walk by INDEX without clearing the queue first.
|
|
663
|
+
* - For each entry, send + commit override. If both succeed,
|
|
664
|
+
* mark the index as drained.
|
|
665
|
+
* - If `transport.send` throws OR `canSend()` flips mid-drain,
|
|
666
|
+
* stop immediately, splice off only the successfully drained
|
|
667
|
+
* prefix. Everything from the failing index onward stays in
|
|
668
|
+
* `pausedQueue` for the next drain attempt.
|
|
669
|
+
*
|
|
670
|
+
* The naive `while (length > 0) shift()` form is O(n²) because each
|
|
671
|
+
* `shift()` reindexes the whole array; with a user-configurable cap
|
|
672
|
+
* the blocking time on a large drain shows up in the inbound-message
|
|
673
|
+
* handler. Index-walk + single splice at the end keeps the drain O(n).
|
|
674
|
+
*/
|
|
675
|
+
private drainPausedQueue;
|
|
676
|
+
private fanout;
|
|
677
|
+
private broadcastClient;
|
|
678
|
+
/**
|
|
679
|
+
* Wire-level error from the transport. If the user hasn't disconnected and
|
|
680
|
+
* we have something worth replaying, kick off the reconnect loop. Otherwise
|
|
681
|
+
* fail the subscriptions and shut down.
|
|
682
|
+
*
|
|
683
|
+
* Re-entrancy: a custom `WSTransport.close()` may synchronously invoke
|
|
684
|
+
* `handlers.onClose` (the `WSTransport` interface places no async-vs-sync
|
|
685
|
+
* contract on close-event timing — only that one fires). If we called
|
|
686
|
+
* `disposeTransportSafely()` while `state` was still `'connected'`, the
|
|
687
|
+
* synchronous `onClose` would re-enter `transportClosed`, see state still
|
|
688
|
+
* `'connected'`, and start its own reconnect loop. Then this method would
|
|
689
|
+
* return and start ANOTHER one. To prevent this, we transition state OUT
|
|
690
|
+
* of `'connected'` before disposing — any re-entrant `transportClosed` /
|
|
691
|
+
* `transportFailed` then sees the guard and returns early.
|
|
692
|
+
*/
|
|
693
|
+
private transportFailed;
|
|
694
|
+
/**
|
|
695
|
+
* Transport closed. Clean codes (1000/1001/1005) end the subs cleanly even
|
|
696
|
+
* if reconnect would otherwise be possible — the server told us to go.
|
|
697
|
+
* Unexpected codes drop into the same reconnect loop as `transportFailed`.
|
|
698
|
+
*
|
|
699
|
+
* Re-entrancy: same guard as `transportFailed` — state transitions before
|
|
700
|
+
* disposal so a synchronous `onClose` from `transport.close()` can't fire
|
|
701
|
+
* a second reconnect loop. Clean closes use a separate guard state
|
|
702
|
+
* (`'disconnecting'` → `'disconnected'`) for the same reason.
|
|
703
|
+
*/
|
|
704
|
+
private transportClosed;
|
|
705
|
+
/**
|
|
706
|
+
* Reconnect is worth attempting only when there's at least one in-flight
|
|
707
|
+
* task subscription that can be replayed. A connection with no live tasks
|
|
708
|
+
* and only raw taps gains nothing from a reconnect — the user can call
|
|
709
|
+
* `connect()` fresh next time they need it.
|
|
710
|
+
*/
|
|
711
|
+
private shouldAttemptReconnect;
|
|
712
|
+
/**
|
|
713
|
+
* Reconnect loop. Backs off exponentially, retries up to `maxAttempts`. On
|
|
714
|
+
* success: swap the transport, broadcast `qar.client.reconnected`, fire a
|
|
715
|
+
* `task.resubscribe` per active task. On exhaustion: broadcast
|
|
716
|
+
* `qar.client.reconnect_failed`, fail every subscription.
|
|
717
|
+
*
|
|
718
|
+
* Mid-loop user disconnect is honored — we check `state` after every async
|
|
719
|
+
* boundary and bail with a clean close.
|
|
720
|
+
*/
|
|
721
|
+
private runReconnectLoop;
|
|
722
|
+
/**
|
|
723
|
+
* For each active task subscription, send a `task.resubscribe` envelope
|
|
724
|
+
* using its `lastSeenMessageId` as the anchor. The new envelope's id is
|
|
725
|
+
* stitched into the subscription's chain so the server's replayed
|
|
726
|
+
* envelopes route back transparently.
|
|
727
|
+
*
|
|
728
|
+
* **Active-subscription state machine.** A `TaskSubscription`
|
|
729
|
+
* registered in `this.subscriptions` can be in one of three states at
|
|
730
|
+
* any point in a connection's lifetime:
|
|
731
|
+
*
|
|
732
|
+
* 1. **pre-admission** — `tasks.start` sent its outbound envelope on
|
|
733
|
+
* the wire and the SDK eagerly registered the subscription so
|
|
734
|
+
* inbound routing can find it. The server-derived `session_id`
|
|
735
|
+
* is NOT yet in {@link taskSessions} because no `task.started`
|
|
736
|
+
* ack has been observed. `currentTaskId` IS set (derived from
|
|
737
|
+
* `task.start.message_id` per the wire contract `task_id ==
|
|
738
|
+
* task.start.message_id`).
|
|
739
|
+
* 2. **admitted** — the `task.started` ack landed; the canonical
|
|
740
|
+
* `task_id` is in `currentTaskId` and the matching `session_id`
|
|
741
|
+
* is pinned in {@link taskSessions}. Resubscribe is fully
|
|
742
|
+
* addressable.
|
|
743
|
+
* 3. **terminated** — `task.done`, server-error, transport-fail,
|
|
744
|
+
* or consumer-driven close has flipped `isTerminated` true.
|
|
745
|
+
* `onClose` has already unsubscribed; subs in this state should
|
|
746
|
+
* not be in the iterating snapshot.
|
|
747
|
+
*
|
|
748
|
+
* `replayActiveTasks` must handle states (1) and (2) explicitly.
|
|
749
|
+
* State (1) is **unrecoverable** per the session-identity contract:
|
|
750
|
+
* without an in-memory `session_id`, the SDK cannot construct a
|
|
751
|
+
* wire-valid `task.resubscribe` for the server's pre-merge
|
|
752
|
+
* bind-and-derive ingress (the resubscribe envelope MUST carry the
|
|
753
|
+
* correct `session_id` field per the QAR wire schema).
|
|
754
|
+
*
|
|
755
|
+
* **Implementation note.** The implementation pre-checks the per-Task
|
|
756
|
+
* session map BEFORE attempting the wire send. A state-(1) sub is
|
|
757
|
+
* failed with a freshly-constructed `QodoColdAddressError` whose
|
|
758
|
+
* stack starts cleanly inside `replayActiveTasks` — no wire
|
|
759
|
+
* round-trip is attempted; the failure is local, typed, and
|
|
760
|
+
* origin-traceable. An earlier implementation called
|
|
761
|
+
* {@link sendEnvelope} first and relied on the synchronous throw
|
|
762
|
+
* from {@link resolveOutboundSessionId} to route the failure into
|
|
763
|
+
* `sub.fail(err)` — functionally correct but the thrown error
|
|
764
|
+
* carried a misleading stack (the wire-send frames). The current
|
|
765
|
+
* pre-check approach surfaces a typed local failure instead.
|
|
766
|
+
* The consumer-facing API surface is unchanged: state-(1) subs still
|
|
767
|
+
* surface `QodoColdAddressError` on their iterator. Lost-ack
|
|
768
|
+
* idempotent retry (re-issuing the original `task.start` on the new
|
|
769
|
+
* transport with the same idempotency-key) lives at the layer
|
|
770
|
+
* above; the raw `Connection` ships the typed failure.
|
|
771
|
+
*
|
|
772
|
+
* Every `TaskSubscription` carries a known `task_id` from construction:
|
|
773
|
+
* `tasks.continue` / `tasks.cancel` / `tasks.resubscribe` receive it from
|
|
774
|
+
* the caller, and `tasks.start` derives it from the outbound
|
|
775
|
+
* `task.start.message_id`. The `currentTaskId === undefined` case is
|
|
776
|
+
* therefore unreachable here — we keep an invariant assertion rather
|
|
777
|
+
* than the prior "in-flight task is unrecoverable" `sub.fail` path.
|
|
778
|
+
*/
|
|
779
|
+
private replayActiveTasks;
|
|
780
|
+
private cleanCloseAndCleanup;
|
|
781
|
+
private failHardAndCleanup;
|
|
782
|
+
/**
|
|
783
|
+
* Walk the user-initiated disconnect path from inside the reconnect loop.
|
|
784
|
+
* The subs are still registered (we deferred their close); end them
|
|
785
|
+
* cleanly so `for await` consumers see `done: true` rather than an error.
|
|
786
|
+
*/
|
|
787
|
+
private finalizeDisconnect;
|
|
788
|
+
private disposeTransportSafely;
|
|
789
|
+
private clearPendingTimers;
|
|
790
|
+
/**
|
|
791
|
+
* Sleep for `ms` milliseconds, cancellable by `clearPendingTimers`. Returns
|
|
792
|
+
* even if the timer is cleared early — the caller checks `state` after the
|
|
793
|
+
* await to decide whether to proceed. Cancelling resolves the Promise
|
|
794
|
+
* rather than rejecting it: cancellation is a flow-control signal, not an
|
|
795
|
+
* error, and the reconnect loop's post-await state check handles it.
|
|
796
|
+
*/
|
|
797
|
+
private sleepCancellable;
|
|
798
|
+
}
|
|
799
|
+
export type { WSTransportFactoryArgs };
|
|
800
|
+
//# sourceMappingURL=connection.d.ts.map
|