@xrkseek/harness 0.5.5 → 0.5.7
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/code-runtime/dist/index.d.ts +4 -0
- package/node_modules/@xrkseek/code-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/code-runtime/dist/index.js +101 -74
- package/node_modules/@xrkseek/code-runtime/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/context-fragments/README.md +5 -1
- package/node_modules/@xrkseek/context-fragments/dist/index.d.ts +5 -25
- package/node_modules/@xrkseek/context-fragments/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/context-fragments/dist/index.js +5 -41
- package/node_modules/@xrkseek/context-fragments/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent/dist/index.js +6 -3
- package/node_modules/@xrkseek/core-agent/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.d.ts +16 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.js +80 -3
- package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts +4 -3
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js +42 -19
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.d.ts +12 -0
- package/node_modules/@xrkseek/core-session/dist/compaction.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.js +107 -31
- package/node_modules/@xrkseek/core-session/dist/compaction.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/image-offload.d.ts +27 -1
- package/node_modules/@xrkseek/core-session/dist/image-offload.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/image-offload.js +62 -0
- package/node_modules/@xrkseek/core-session/dist/image-offload.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/index.d.ts +2 -2
- package/node_modules/@xrkseek/core-session/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/index.js +23 -2
- package/node_modules/@xrkseek/core-session/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/safety/mistake.d.ts +2 -1
- package/node_modules/@xrkseek/core-session/dist/safety/mistake.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/safety/mistake.js +8 -4
- package/node_modules/@xrkseek/core-session/dist/safety/mistake.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js +84 -30
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/store.d.ts +7 -0
- package/node_modules/@xrkseek/core-session/dist/store.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/definition.d.ts +2 -0
- package/node_modules/@xrkseek/core-tools/dist/definition.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/definition.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/pipeline.d.ts +1 -0
- package/node_modules/@xrkseek/core-tools/dist/pipeline.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/pipeline.js +59 -1
- package/node_modules/@xrkseek/core-tools/dist/pipeline.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/run-tool.d.ts +6 -0
- package/node_modules/@xrkseek/core-tools/dist/run-tool.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/run-tool.js +3 -0
- package/node_modules/@xrkseek/core-tools/dist/run-tool.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.js +6 -11
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/std-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/std-tools.js +5 -8
- package/node_modules/@xrkseek/core-tools/dist/std-tools.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/types.d.ts +64 -1
- package/node_modules/@xrkseek/core-tools/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/types.js.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.js +1 -2
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.js +10 -19
- package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/present-deliverable.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/present-deliverable.js +3 -5
- package/node_modules/@xrkseek/exec-fs/dist/present-deliverable.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/read-image.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/read-image.js +4 -2
- package/node_modules/@xrkseek/exec-fs/dist/read-image.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/search.d.ts +3 -1
- package/node_modules/@xrkseek/exec-fs/dist/search.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/search.js +13 -7
- package/node_modules/@xrkseek/exec-fs/dist/search.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/format.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/format.js +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/format.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/schema.js +3 -5
- package/node_modules/@xrkseek/exec-image-gen/dist/schema.js.map +1 -1
- package/node_modules/@xrkseek/exec-lsp/dist/tools.js +1 -1
- package/node_modules/@xrkseek/exec-lsp/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.js +5 -12
- package/node_modules/@xrkseek/exec-memory/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/bytes.d.ts +34 -1
- package/node_modules/@xrkseek/exec-shell/dist/bytes.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/bytes.js +69 -2
- package/node_modules/@xrkseek/exec-shell/dist/bytes.js.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/index.js +40 -11
- package/node_modules/@xrkseek/exec-shell/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/job-view.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-shell/dist/job-view.js +27 -2
- package/node_modules/@xrkseek/exec-shell/dist/job-view.js.map +1 -1
- package/node_modules/@xrkseek/exec-subprocess/dist/index.d.ts +9 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-subprocess/dist/index.js +43 -0
- package/node_modules/@xrkseek/exec-subprocess/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-analyze/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-analyze/dist/tools.js +3 -4
- package/node_modules/@xrkseek/exec-video-analyze/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/schema.js +3 -6
- package/node_modules/@xrkseek/exec-video-gen/dist/schema.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.js +5 -7
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/tools.js +2 -2
- package/node_modules/@xrkseek/exec-web/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/failure.d.ts +8 -0
- package/node_modules/@xrkseek/llm/dist/failure.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm/dist/failure.js +43 -1
- package/node_modules/@xrkseek/llm/dist/failure.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/index.d.ts +32 -2
- package/node_modules/@xrkseek/llm/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm/dist/index.js +49 -3
- package/node_modules/@xrkseek/llm/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts +20 -2
- package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm/dist/retry-policy.js +46 -17
- package/node_modules/@xrkseek/llm/dist/retry-policy.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/stream-idle-timeout.d.ts +46 -0
- package/node_modules/@xrkseek/llm/dist/stream-idle-timeout.d.ts.map +1 -0
- package/node_modules/@xrkseek/llm/dist/stream-idle-timeout.js +141 -0
- package/node_modules/@xrkseek/llm/dist/stream-idle-timeout.js.map +1 -0
- package/node_modules/@xrkseek/llm-anthropic/dist/index.d.ts +9 -0
- package/node_modules/@xrkseek/llm-anthropic/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-anthropic/dist/index.js +27 -11
- package/node_modules/@xrkseek/llm-anthropic/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-gemini/dist/index.d.ts +9 -0
- package/node_modules/@xrkseek/llm-gemini/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-gemini/dist/index.js +26 -10
- package/node_modules/@xrkseek/llm-gemini/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts +9 -0
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js +60 -16
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.d.ts +10 -0
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.js +26 -10
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +12 -5
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +25 -6
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js +2 -2
- package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/protocol/dist/tools.d.ts +2 -0
- package/node_modules/@xrkseek/protocol/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-cron/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-cron/dist/tools.js +1 -2
- package/node_modules/@xrkseek/server-cron/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/approvals.d.ts +9 -2
- package/node_modules/@xrkseek/server-face/dist/approvals.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/approvals.js +8 -4
- package/node_modules/@xrkseek/server-face/dist/approvals.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/auto-review-approve.d.ts +24 -0
- package/node_modules/@xrkseek/server-face/dist/auto-review-approve.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/auto-review-approve.js +43 -0
- package/node_modules/@xrkseek/server-face/dist/auto-review-approve.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/canvas-store.d.ts +10 -0
- package/node_modules/@xrkseek/server-face/dist/canvas-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/canvas-store.js +43 -6
- package/node_modules/@xrkseek/server-face/dist/canvas-store.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/canvas-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/canvas-tools.js +6 -3
- package/node_modules/@xrkseek/server-face/dist/canvas-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/context.d.ts +12 -2
- package/node_modules/@xrkseek/server-face/dist/context.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.js +3 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/durable-prompt.d.ts +14 -1
- package/node_modules/@xrkseek/server-face/dist/durable-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/durable-prompt.js +38 -3
- package/node_modules/@xrkseek/server-face/dist/durable-prompt.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.d.ts +14 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.js +14 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/job.d.ts +8 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/job.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/job.js +16 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/job.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js +111 -25
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/host-open-path.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/host-open-path.js +7 -2
- package/node_modules/@xrkseek/server-face/dist/host-open-path.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +5 -3
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js +5 -3
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts +11 -0
- package/node_modules/@xrkseek/server-face/dist/model-catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/model-catalog.js +25 -3
- package/node_modules/@xrkseek/server-face/dist/model-catalog.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/permission-auto.d.ts +51 -0
- package/node_modules/@xrkseek/server-face/dist/permission-auto.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/permission-auto.js +106 -0
- package/node_modules/@xrkseek/server-face/dist/permission-auto.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/permissions.d.ts +38 -4
- package/node_modules/@xrkseek/server-face/dist/permissions.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/permissions.js +131 -24
- package/node_modules/@xrkseek/server-face/dist/permissions.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/install-defaults.d.ts +8 -0
- package/node_modules/@xrkseek/server-face/dist/projections/install-defaults.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/install-defaults.js +9 -3
- package/node_modules/@xrkseek/server-face/dist/projections/install-defaults.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/auto-review.d.ts +22 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/auto-review.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/auto-review.js +18 -15
- package/node_modules/@xrkseek/server-face/dist/projections/units/auto-review.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.d.ts +4 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.js +8 -5
- package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.d.ts +15 -3
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.js +30 -9
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts +6 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.js +38 -7
- package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts +0 -2
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.js +143 -37
- package/node_modules/@xrkseek/server-face/dist/session-status.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +6 -9
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.js +20 -5
- package/node_modules/@xrkseek/server-face/dist/slash.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +13 -0
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +82 -5
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/types.d.ts +12 -0
- package/node_modules/@xrkseek/server-face/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts +2 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-face.js +85 -8
- package/node_modules/@xrkseek/server-face/dist/workspace-face.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts +30 -3
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.js +87 -17
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-store.d.ts +2 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-store.js +4 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-store.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/auto-review-bridge.d.ts +5 -0
- package/node_modules/@xrkseek/server-host/dist/auto-review-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/auto-review-bridge.js +3 -2
- package/node_modules/@xrkseek/server-host/dist/auto-review-bridge.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.d.ts +6 -2
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +148 -17
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +6 -3
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js +3 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts +12 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts +168 -4
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js +466 -13
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-history.d.ts +53 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-history.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-history.js +177 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-history.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.d.ts +45 -2
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js +148 -10
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.d.ts +123 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js +299 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-tool-pre.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts +5 -3
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js +4 -2
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.js +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.js +3 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.js.map +1 -1
- package/node_modules/@xrkseek/server-http/package.json +46 -44
- package/node_modules/@xrkseek/workspace/dist/skill-propose.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-propose.js +1 -2
- package/node_modules/@xrkseek/workspace/dist/skill-propose.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-tools.js +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -96,6 +96,48 @@ export function throwHttpLlmError(label, status, bodyText, headers) {
|
|
|
96
96
|
...(requestId !== undefined ? { requestId } : {}),
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Human-readable text for an unknown throw. Plain `String(err)` collapses
|
|
101
|
+
* plain objects to `[object Object]`, which then shows up in the retry
|
|
102
|
+
* disclosure as `anthropic: [object Object]`. Prefer Error.message, then
|
|
103
|
+
* `cause`, then JSON, then a stable fallback — never leave the UI with that
|
|
104
|
+
* opaque token.
|
|
105
|
+
*/
|
|
106
|
+
export function describeUnknownError(err) {
|
|
107
|
+
if (typeof err === "string") {
|
|
108
|
+
const trimmed = err.trim();
|
|
109
|
+
return trimmed === "" || trimmed === "[object Object]"
|
|
110
|
+
? "unknown error"
|
|
111
|
+
: trimmed;
|
|
112
|
+
}
|
|
113
|
+
if (err instanceof Error) {
|
|
114
|
+
const message = err.message.trim();
|
|
115
|
+
if (message !== "" && message !== "[object Object]")
|
|
116
|
+
return message;
|
|
117
|
+
if (err.cause !== undefined) {
|
|
118
|
+
const cause = describeUnknownError(err.cause);
|
|
119
|
+
if (cause !== "unknown error")
|
|
120
|
+
return cause;
|
|
121
|
+
}
|
|
122
|
+
return err.name.trim() || "Error";
|
|
123
|
+
}
|
|
124
|
+
if (err && typeof err === "object") {
|
|
125
|
+
const record = err;
|
|
126
|
+
if (typeof record.message === "string" && record.message.trim() !== "") {
|
|
127
|
+
return record.message.trim();
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const json = JSON.stringify(err);
|
|
131
|
+
if (json !== undefined && json !== "{}" && json !== "null")
|
|
132
|
+
return json;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
/* circular / BigInt — fall through */
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const fallback = String(err);
|
|
139
|
+
return fallback === "[object Object]" ? "unknown error" : fallback;
|
|
140
|
+
}
|
|
99
141
|
/** Classify a caught transport / abort error into LlmError when possible. */
|
|
100
142
|
export function classifyCaughtLlmError(err, label) {
|
|
101
143
|
if (err instanceof LlmError)
|
|
@@ -106,7 +148,7 @@ export function classifyCaughtLlmError(err, label) {
|
|
|
106
148
|
if (err instanceof Error && err.name === "TimeoutError") {
|
|
107
149
|
throw new LlmError(`${label}: timeout`, "TIMEOUT", { cause: err });
|
|
108
150
|
}
|
|
109
|
-
const message =
|
|
151
|
+
const message = describeUnknownError(err);
|
|
110
152
|
if (/\btimeout\b/i.test(message)) {
|
|
111
153
|
throw new LlmError(`${label}: ${message}`, "TIMEOUT", { cause: err });
|
|
112
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.js","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,4BAA4B,GAAG,yBAAyB,CAAC;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEpD,iEAAiE;AACjE,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,MAAM,CAAU;IAChB,oBAAoB,CAAU;IAC9B,SAAS,CAAU;IAE5B,YACE,OAAe,EACf,IAAY,EACZ,OAKC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAChE,IAAI,OAAO,EAAE,oBAAoB,KAAK,SAAS,EAAE,CAAC;YAChD,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;QAC3D,CAAC;QACD,IAAI,OAAO,EAAE,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAC3E,CAAC;IAED,SAAS;QACP,OAAO;YACL,OAAO,EAAE,IAAI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xE,CAAC;IACD,MAAM,IAAI,QAAQ,CAChB,GAAG,KAAK,KAAK,OAAO,EAAE,EACtB,WAAW,EACX,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -7,6 +7,11 @@ export interface LlmChatRequest {
|
|
|
7
7
|
parameters: Record<string, unknown>;
|
|
8
8
|
}[];
|
|
9
9
|
readonly signal?: AbortSignal;
|
|
10
|
+
/**
|
|
11
|
+
* Per-request sampling temperature. When set, overrides the adapter factory
|
|
12
|
+
* default (Auto-review uses `0`).
|
|
13
|
+
*/
|
|
14
|
+
readonly temperature?: number;
|
|
10
15
|
/**
|
|
11
16
|
* Resolve image attachment bytes for multimodal user content.
|
|
12
17
|
* Required when messages contain image blocks.
|
|
@@ -92,6 +97,12 @@ export declare function toolCallArgsIncomplete(args: unknown): boolean;
|
|
|
92
97
|
/**
|
|
93
98
|
* Post-provider gate (DSH translate + BlockAssembler): keep/drop, refuse
|
|
94
99
|
* unknown finishes / empty stops / truncated tool JSON outside max-tokens.
|
|
100
|
+
*
|
|
101
|
+
* Mysterious truncation: when the stream ends with incomplete tool JSON and
|
|
102
|
+
* no `length` finish (undefined / `stop`), coerce to `max-tokens` so keep/drop
|
|
103
|
+
* strips unsafe calls. Throwing here used to fail-close the turn; repeated
|
|
104
|
+
* API errors then pinned the mistake counter and left the session mute.
|
|
105
|
+
* A provider that claims `tool-calls` with broken JSON still fail-closes.
|
|
95
106
|
*/
|
|
96
107
|
export declare function finalizeLlmChatResponse(response: LlmChatResponse): LlmChatResponse;
|
|
97
108
|
/**
|
|
@@ -159,8 +170,27 @@ export declare class UnsupportedReasoningEffortError extends Error {
|
|
|
159
170
|
constructor(message: string);
|
|
160
171
|
}
|
|
161
172
|
export declare function isUnsupportedReasoningEffortError(err: unknown): boolean;
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Classification boundary for every adapter fetch site — `post()` *and* the
|
|
175
|
+
* `yield*` that reads the response body. Body reads happen outside the
|
|
176
|
+
* request try/catch, so a socket that dies mid-stream surfaces as a bare
|
|
177
|
+
* undici `TypeError` (`terminated`, `fetch failed`) with no provider code.
|
|
178
|
+
* Route anything unclassified through {@link classifyCaughtLlmError}, which
|
|
179
|
+
* labels it with the adapter id and gives it TRANSPORT / TIMEOUT / ABORTED —
|
|
180
|
+
* all of which the retry policy retries by default.
|
|
181
|
+
*
|
|
182
|
+
* The guard keeps errors that already carry a real classification, because
|
|
183
|
+
* re-wrapping would discard the code the retry policy blacklists (AUTH,
|
|
184
|
+
* QUOTA) or the code `agent-loop` writes into `turn/end.reason.error.code`
|
|
185
|
+
* (`EMPTY_RESPONSE`, `INCOMPLETE_TOOL_CALL`, the provider finish code). It is
|
|
186
|
+
* also the full set of families an adapter can raise: the last three come from
|
|
187
|
+
* `finalizeLlmChatResponse` at end-of-stream. A new classified family must be
|
|
188
|
+
* added here or it will be misreported as a transport failure.
|
|
189
|
+
*/
|
|
190
|
+
export declare function classifyCaughtStreamError(err: unknown, label: string): never;
|
|
191
|
+
export { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, QUOTA_EXCEEDED_CODE, LlmError, classifyCaughtLlmError, describeUnknownError, httpErrorCode, isLlmError, isQuotaExceededError, parseRetryAfterMs, requestIdFromHeaders, throwHttpLlmError, type LlmFailure, } from "./failure.js";
|
|
192
|
+
export { DEFAULT_NON_RETRYABLE_CODES, DEFAULT_RETRY_POLICY, cancellableDelay, computeRetryDelayMs, failureFromUnknown, isRetryableFailure, type ResolvedRetryPolicy, type RetryPolicyMode, } from "./retry-policy.js";
|
|
193
|
+
export { DEFAULT_STREAM_IDLE_TIMEOUT_MS, resolveStreamIdleTimeoutMs, withExtraAbortSignal, withStreamIdleTimeout, type StreamIdleWatchdogOptions, } from "./stream-idle-timeout.js";
|
|
164
194
|
export interface LlmRegistry {
|
|
165
195
|
register(adapter: LlmAdapter): void;
|
|
166
196
|
get(id: string): LlmAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACX,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,EAAE,CAAC;IACJ,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,CACtB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC;QACX,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;QAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,mBAAmB,EAAE,kBAAkB,CAAC;KAC/D,CAAC,CAAC;IACH;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC;AAE7E,MAAM,WAAW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O,CAEvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAa5E;AAED,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,EACR,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,0BAA0B,CAAC;AAGlC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,IAAI,IAAI,SAAS,UAAU,EAAE,CAAC;CAC/B;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAkB/C;AAED,0EAA0E;AAC1E,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,GACpC,OAAO,CAAC,eAAe,CAAC,CA4B1B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classifyCaughtLlmError, isLlmError } from "./failure.js";
|
|
1
2
|
/**
|
|
2
3
|
* Map OpenAI Chat Completions `finish_reason` onto a response (DSH
|
|
3
4
|
* `llm-deepseek/translate.mapFinishReason`).
|
|
@@ -68,9 +69,24 @@ export function toolCallArgsIncomplete(args) {
|
|
|
68
69
|
/**
|
|
69
70
|
* Post-provider gate (DSH translate + BlockAssembler): keep/drop, refuse
|
|
70
71
|
* unknown finishes / empty stops / truncated tool JSON outside max-tokens.
|
|
72
|
+
*
|
|
73
|
+
* Mysterious truncation: when the stream ends with incomplete tool JSON and
|
|
74
|
+
* no `length` finish (undefined / `stop`), coerce to `max-tokens` so keep/drop
|
|
75
|
+
* strips unsafe calls. Throwing here used to fail-close the turn; repeated
|
|
76
|
+
* API errors then pinned the mistake counter and left the session mute.
|
|
77
|
+
* A provider that claims `tool-calls` with broken JSON still fail-closes.
|
|
71
78
|
*/
|
|
72
79
|
export function finalizeLlmChatResponse(response) {
|
|
73
|
-
const
|
|
80
|
+
const incomplete = response.toolCalls?.some((c) => toolCallArgsIncomplete(c.arguments)) ===
|
|
81
|
+
true;
|
|
82
|
+
const mysteriousTruncation = incomplete &&
|
|
83
|
+
response.finishReason !== "max-tokens" &&
|
|
84
|
+
response.finishReason !== "tool-calls" &&
|
|
85
|
+
response.finishReason !== "error";
|
|
86
|
+
const working = mysteriousTruncation
|
|
87
|
+
? { ...response, finishReason: "max-tokens" }
|
|
88
|
+
: response;
|
|
89
|
+
const dropped = applyMaxTokensKeepDrop(working);
|
|
74
90
|
if (dropped.finishReason === "error") {
|
|
75
91
|
throw new ProviderFinishError(dropped.finishError?.message ?? "model stopped with an error finish", dropped.finishError?.code ?? "FINISH_ERROR");
|
|
76
92
|
}
|
|
@@ -154,8 +170,38 @@ export class UnsupportedReasoningEffortError extends Error {
|
|
|
154
170
|
export function isUnsupportedReasoningEffortError(err) {
|
|
155
171
|
return err instanceof UnsupportedReasoningEffortError;
|
|
156
172
|
}
|
|
157
|
-
|
|
158
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Classification boundary for every adapter fetch site — `post()` *and* the
|
|
175
|
+
* `yield*` that reads the response body. Body reads happen outside the
|
|
176
|
+
* request try/catch, so a socket that dies mid-stream surfaces as a bare
|
|
177
|
+
* undici `TypeError` (`terminated`, `fetch failed`) with no provider code.
|
|
178
|
+
* Route anything unclassified through {@link classifyCaughtLlmError}, which
|
|
179
|
+
* labels it with the adapter id and gives it TRANSPORT / TIMEOUT / ABORTED —
|
|
180
|
+
* all of which the retry policy retries by default.
|
|
181
|
+
*
|
|
182
|
+
* The guard keeps errors that already carry a real classification, because
|
|
183
|
+
* re-wrapping would discard the code the retry policy blacklists (AUTH,
|
|
184
|
+
* QUOTA) or the code `agent-loop` writes into `turn/end.reason.error.code`
|
|
185
|
+
* (`EMPTY_RESPONSE`, `INCOMPLETE_TOOL_CALL`, the provider finish code). It is
|
|
186
|
+
* also the full set of families an adapter can raise: the last three come from
|
|
187
|
+
* `finalizeLlmChatResponse` at end-of-stream. A new classified family must be
|
|
188
|
+
* added here or it will be misreported as a transport failure.
|
|
189
|
+
*/
|
|
190
|
+
export function classifyCaughtStreamError(err, label) {
|
|
191
|
+
if (isContextOverflowError(err) ||
|
|
192
|
+
isUnsupportedContentError(err) ||
|
|
193
|
+
isUnsupportedReasoningEffortError(err) ||
|
|
194
|
+
isEmptyResponseError(err) ||
|
|
195
|
+
isProviderFinishError(err) ||
|
|
196
|
+
isIncompleteToolCallError(err) ||
|
|
197
|
+
isLlmError(err)) {
|
|
198
|
+
throw err;
|
|
199
|
+
}
|
|
200
|
+
classifyCaughtLlmError(err, label);
|
|
201
|
+
}
|
|
202
|
+
export { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, QUOTA_EXCEEDED_CODE, LlmError, classifyCaughtLlmError, describeUnknownError, httpErrorCode, isLlmError, isQuotaExceededError, parseRetryAfterMs, requestIdFromHeaders, throwHttpLlmError, } from "./failure.js";
|
|
203
|
+
export { DEFAULT_NON_RETRYABLE_CODES, DEFAULT_RETRY_POLICY, cancellableDelay, computeRetryDelayMs, failureFromUnknown, isRetryableFailure, } from "./retry-policy.js";
|
|
204
|
+
export { DEFAULT_STREAM_IDLE_TIMEOUT_MS, resolveStreamIdleTimeoutMs, withExtraAbortSignal, withStreamIdleTimeout, } from "./stream-idle-timeout.js";
|
|
159
205
|
export function createLlmRegistry() {
|
|
160
206
|
const adapters = new Map();
|
|
161
207
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAwFlE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAyB,EACzB,GAAY;IAEZ,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IACzE,IAAI,GAAG,KAAK,YAAY;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7E,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IACjE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,QAAQ;YACX,YAAY,EAAE,OAAO;YACrB,WAAW,EAAE;gBACX,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE;gBACvB,OAAO,EAAE,kBAAkB,GAAG,EAAE;aACjC;SACF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,uBAAuB,CACrC,QAAyB,EACzB,GAAY;IAEZ,IAAI,GAAG,KAAK,YAAY;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7E,IAAI,GAAG,KAAK,UAAU;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IAC3E,I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,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -7,13 +7,31 @@ export interface ResolvedRetryPolicy {
|
|
|
7
7
|
readonly mode: RetryPolicyMode;
|
|
8
8
|
/** Cap for `normal` mode (ignored when `always`). Default 5. */
|
|
9
9
|
readonly maxRetries: number;
|
|
10
|
-
|
|
10
|
+
/** Codes that must NOT be retried; everything else is. */
|
|
11
|
+
readonly nonRetryableCodes: readonly string[];
|
|
11
12
|
readonly initialDelayMs: number;
|
|
12
13
|
readonly maxDelayMs: number;
|
|
13
14
|
/** Jitter ratio in [0, 1]; default 0.25. */
|
|
14
15
|
readonly jitterRatio: number;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Retry is a blacklist, not a whitelist: every abnormal failure retries —
|
|
19
|
+
* transport, timeout, 5xx, rate limit, empty body, truncated tool JSON,
|
|
20
|
+
* `UNKNOWN`. Enumerating "definitely not worth another attempt" is a short,
|
|
21
|
+
* closed list; enumerating "worth retrying" means guessing every errno a
|
|
22
|
+
* future Node/undici/Chromium release may invent, and any miss is a silent
|
|
23
|
+
* no-retry. So the policy lists the few codes that are deterministic failures
|
|
24
|
+
* and treats everything else as transient.
|
|
25
|
+
*
|
|
26
|
+
* Note what is deliberately absent: a model hitting its output ceiling is
|
|
27
|
+
* not a failure at all. `finish_reason: length` / `stop_reason: max_tokens`
|
|
28
|
+
* map to `finishReason: "max-tokens"` on a *successful* response and never
|
|
29
|
+
* raise, so normal truncation never reaches this predicate — no blacklist
|
|
30
|
+
* entry is needed for it. The only finish that throws is `ProviderFinishError`
|
|
31
|
+
* (`finishReason: "error"`, an unknown wire stop), and that is an abnormal
|
|
32
|
+
* stop, so it retries.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_NON_RETRYABLE_CODES: readonly ["ABORTED", "AUTH", "QUOTA", "INVALID_REQUEST", "CONTEXT_WINDOW_EXCEEDED", "UNSUPPORTED_REASONING_EFFORT", "UNSUPPORTED_CONTENT"];
|
|
17
35
|
export declare const DEFAULT_RETRY_POLICY: ResolvedRetryPolicy;
|
|
18
36
|
export declare function failureFromUnknown(err: unknown): LlmFailure;
|
|
19
37
|
export declare function isRetryableFailure(failure: LlmFailure, policy?: ResolvedRetryPolicy): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,4IAe9B,CAAC;AAEX,eAAO,MAAM,oBAAoB,EAAE,mBAOlC,CAAC;AAmBF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAQ3D;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,UAAU,EACnB,MAAM,GAAE,mBAA0C,GACjD,OAAO,CAGT;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,UAAU,EACpB,MAAM,GAAE,MAAM,MAAoB,GACjC,MAAM,CAeR;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,CAalB"}
|
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider request retry policy (DSH llm-retry normal mode subset).
|
|
3
3
|
*/
|
|
4
|
-
import { isLlmError, } from "./failure.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { describeUnknownError, isLlmError, } from "./failure.js";
|
|
5
|
+
/**
|
|
6
|
+
* Retry is a blacklist, not a whitelist: every abnormal failure retries —
|
|
7
|
+
* transport, timeout, 5xx, rate limit, empty body, truncated tool JSON,
|
|
8
|
+
* `UNKNOWN`. Enumerating "definitely not worth another attempt" is a short,
|
|
9
|
+
* closed list; enumerating "worth retrying" means guessing every errno a
|
|
10
|
+
* future Node/undici/Chromium release may invent, and any miss is a silent
|
|
11
|
+
* no-retry. So the policy lists the few codes that are deterministic failures
|
|
12
|
+
* and treats everything else as transient.
|
|
13
|
+
*
|
|
14
|
+
* Note what is deliberately absent: a model hitting its output ceiling is
|
|
15
|
+
* not a failure at all. `finish_reason: length` / `stop_reason: max_tokens`
|
|
16
|
+
* map to `finishReason: "max-tokens"` on a *successful* response and never
|
|
17
|
+
* raise, so normal truncation never reaches this predicate — no blacklist
|
|
18
|
+
* entry is needed for it. The only finish that throws is `ProviderFinishError`
|
|
19
|
+
* (`finishReason: "error"`, an unknown wire stop), and that is an abnormal
|
|
20
|
+
* stop, so it retries.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_NON_RETRYABLE_CODES = [
|
|
23
|
+
// User cancel / parent dispose: retrying ignores the stop.
|
|
24
|
+
"ABORTED",
|
|
25
|
+
// 401/403 — bad key or missing permission. Same request, same rejection.
|
|
26
|
+
"AUTH",
|
|
27
|
+
// Out of credit / quota exhausted. Retrying only spends more money.
|
|
28
|
+
"QUOTA",
|
|
29
|
+
// 400/413 — malformed request or oversized body; the request must change.
|
|
30
|
+
"INVALID_REQUEST",
|
|
31
|
+
// Context window blown; agent-loop routes this to prune/compact instead.
|
|
32
|
+
"CONTEXT_WINDOW_EXCEEDED",
|
|
33
|
+
// Deployment-locked effort, rejected before provider I/O.
|
|
34
|
+
"UNSUPPORTED_REASONING_EFFORT",
|
|
35
|
+
// Modality or request size the active route cannot serve, ever.
|
|
36
|
+
"UNSUPPORTED_CONTENT",
|
|
11
37
|
];
|
|
12
38
|
export const DEFAULT_RETRY_POLICY = {
|
|
13
39
|
mode: "normal",
|
|
14
40
|
maxRetries: 5,
|
|
15
|
-
|
|
41
|
+
nonRetryableCodes: [...DEFAULT_NON_RETRYABLE_CODES],
|
|
16
42
|
initialDelayMs: 1_000,
|
|
17
43
|
maxDelayMs: 60_000,
|
|
18
44
|
jitterRatio: 0.25,
|
|
@@ -20,6 +46,11 @@ export const DEFAULT_RETRY_POLICY = {
|
|
|
20
46
|
function errorCode(err) {
|
|
21
47
|
if (isLlmError(err))
|
|
22
48
|
return err.code;
|
|
49
|
+
// A cancel is control flow, not a failure: it carries no `code`, so it would
|
|
50
|
+
// read as UNKNOWN and burn the full retry budget after the user hit stop.
|
|
51
|
+
// Same DOMException rule `classifyCaughtLlmError` uses.
|
|
52
|
+
if (err instanceof DOMException && err.name === "AbortError")
|
|
53
|
+
return "ABORTED";
|
|
23
54
|
if (err &&
|
|
24
55
|
typeof err === "object" &&
|
|
25
56
|
"code" in err &&
|
|
@@ -31,19 +62,17 @@ function errorCode(err) {
|
|
|
31
62
|
export function failureFromUnknown(err) {
|
|
32
63
|
if (isLlmError(err))
|
|
33
64
|
return err.toFailure();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return { message: String(err), code: code ?? "UNKNOWN" };
|
|
65
|
+
// Prefer a real message over `String(plainObject)` → `[object Object]`,
|
|
66
|
+
// which otherwise lands verbatim in the llm/retry disclosure.
|
|
67
|
+
return {
|
|
68
|
+
message: describeUnknownError(err),
|
|
69
|
+
code: errorCode(err) ?? "UNKNOWN",
|
|
70
|
+
};
|
|
42
71
|
}
|
|
43
72
|
export function isRetryableFailure(failure, policy = DEFAULT_RETRY_POLICY) {
|
|
44
73
|
if (policy.mode === "always")
|
|
45
74
|
return true;
|
|
46
|
-
return policy.
|
|
75
|
+
return !policy.nonRetryableCodes.includes(failure.code);
|
|
47
76
|
}
|
|
48
77
|
export function computeRetryDelayMs(policy, retry, failure, random = Math.random) {
|
|
49
78
|
if (failure?.providerRetryAfterMs !== undefined &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,GAGX,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,oBAAoB,EACpB,UAAU,GAGX,MAAM,cAAc,CAAC;AAgBtB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,2DAA2D;IAC3D,SAAS;IACT,yEAAyE;IACzE,MAAM;IACN,oEAAoE;IACpE,OAAO;IACP,0EAA0E;IAC1E,iBAAiB;IACjB,yEAAyE;IACzE,yBAAyB;IACzB,0DAA0D;IAC1D,8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pB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default per-event idle budget for a provider stream: 5 minutes. Long enough
|
|
3
|
+
* that a slow-but-streaming model never trips it, short enough that a dead
|
|
4
|
+
* turn ends in minutes instead of never.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
|
|
7
|
+
/**
|
|
8
|
+
* Codex `stream_idle_timeout_ms().unwrap_or(DEFAULT_STREAM_IDLE_TIMEOUT_MS)`
|
|
9
|
+
* — the default is internal, so a missing option means "5 minutes", never
|
|
10
|
+
* "no watchdog". A non-positive or infinite value takes the same branch.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveStreamIdleTimeoutMs(idleTimeoutMs?: number): number;
|
|
13
|
+
export interface StreamIdleWatchdogOptions {
|
|
14
|
+
/** Per-event idle budget; omit for {@link DEFAULT_STREAM_IDLE_TIMEOUT_MS}. */
|
|
15
|
+
readonly idleTimeoutMs?: number;
|
|
16
|
+
/** Adapter id — becomes the error message prefix. */
|
|
17
|
+
readonly label: string;
|
|
18
|
+
/**
|
|
19
|
+
* Caller abort. Ends the stream normally — a cancel is control flow, never
|
|
20
|
+
* a timeout, so it must not surface as `TIMEOUT`.
|
|
21
|
+
*/
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
/**
|
|
24
|
+
* Called once, just before the `TIMEOUT` is raised. Adapters pass a
|
|
25
|
+
* controller that aborts the in-flight request: the body read the watchdog
|
|
26
|
+
* just gave up on is still parked on that socket, and nothing else will ever
|
|
27
|
+
* close it.
|
|
28
|
+
*/
|
|
29
|
+
readonly onIdleTimeout?: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wrap a provider stream so a silence longer than the idle budget throws
|
|
33
|
+
* `TIMEOUT` (retryable — it is not in the non-retryable blacklist) instead of
|
|
34
|
+
* hanging the turn forever. Abort and completion both end the generator
|
|
35
|
+
* normally.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withStreamIdleTimeout<T>(source: AsyncIterable<T>, options: StreamIdleWatchdogOptions): AsyncGenerator<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Fold a watchdog-owned signal into a request without touching the caller's.
|
|
40
|
+
* The idle watchdog aborts it to close the body read it gave up on; the
|
|
41
|
+
* caller's own signal keeps driving cancellation.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withExtraAbortSignal<T extends {
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}>(request: T, extra: AbortSignal): T;
|
|
46
|
+
//# sourceMappingURL=stream-idle-timeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-idle-timeout.d.ts","sourceRoot":"","sources":["../src/stream-idle-timeout.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,SAAU,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAMzE;AAED,MAAM,WAAW,yBAAyB;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAQD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,yBAAyB,GACjC,cAAc,CAAC,CAAC,CAAC,CAyFnB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,EAC9E,OAAO,EAAE,CAAC,EACV,KAAK,EAAE,WAAW,GACjB,CAAC,CAOH"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-event stream idle watchdog (Codex `process_sse_with_treatment`).
|
|
3
|
+
*
|
|
4
|
+
* A provider body that goes quiet is the one failure that raises nothing: the
|
|
5
|
+
* socket stays open, no event arrives, and neither `timeoutMs` — which the
|
|
6
|
+
* registry path never wires — nor the retry loop ever gets to see it, so the
|
|
7
|
+
* turn simply waits. Codex bounds the gap between *events* rather than the
|
|
8
|
+
* whole request, and each delivered event restarts the clock, so a slow but
|
|
9
|
+
* alive model is never killed. We do the same, per event, with an internal
|
|
10
|
+
* default so an adapter that never passes `idleTimeoutMs` still fails instead
|
|
11
|
+
* of waiting forever.
|
|
12
|
+
*
|
|
13
|
+
* Reference:
|
|
14
|
+
* - `codex-rs/model-provider-info/src/lib.rs:63` — `DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300_000`
|
|
15
|
+
* - `codex-rs/model-provider-info/src/lib.rs:505-509` — per-provider `stream_idle_timeout_ms` override
|
|
16
|
+
* - `codex-rs/codex-api/src/sse/responses.rs:532-568` — `biased` select: a closed consumer wins over the timeout arm
|
|
17
|
+
*/
|
|
18
|
+
import { LlmError } from "./failure.js";
|
|
19
|
+
/**
|
|
20
|
+
* Default per-event idle budget for a provider stream: 5 minutes. Long enough
|
|
21
|
+
* that a slow-but-streaming model never trips it, short enough that a dead
|
|
22
|
+
* turn ends in minutes instead of never.
|
|
23
|
+
*/
|
|
24
|
+
export const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300_000;
|
|
25
|
+
/**
|
|
26
|
+
* Codex `stream_idle_timeout_ms().unwrap_or(DEFAULT_STREAM_IDLE_TIMEOUT_MS)`
|
|
27
|
+
* — the default is internal, so a missing option means "5 minutes", never
|
|
28
|
+
* "no watchdog". A non-positive or infinite value takes the same branch.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveStreamIdleTimeoutMs(idleTimeoutMs) {
|
|
31
|
+
return idleTimeoutMs !== undefined &&
|
|
32
|
+
Number.isFinite(idleTimeoutMs) &&
|
|
33
|
+
idleTimeoutMs > 0
|
|
34
|
+
? idleTimeoutMs
|
|
35
|
+
: DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Wrap a provider stream so a silence longer than the idle budget throws
|
|
39
|
+
* `TIMEOUT` (retryable — it is not in the non-retryable blacklist) instead of
|
|
40
|
+
* hanging the turn forever. Abort and completion both end the generator
|
|
41
|
+
* normally.
|
|
42
|
+
*/
|
|
43
|
+
export function withStreamIdleTimeout(source, options) {
|
|
44
|
+
const idleTimeoutMs = resolveStreamIdleTimeoutMs(options.idleTimeoutMs);
|
|
45
|
+
const { label, signal, onIdleTimeout } = options;
|
|
46
|
+
return (async function* idleWatchdog() {
|
|
47
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
48
|
+
// The single live timer, owned by whichever `next()` is in flight. Node
|
|
49
|
+
// keeps a referenced `setTimeout` on the event loop for its full budget,
|
|
50
|
+
// so one left armed after the consumer walked away pins the Electron main
|
|
51
|
+
// process open for minutes.
|
|
52
|
+
let timer;
|
|
53
|
+
const clearTimer = () => {
|
|
54
|
+
if (timer === undefined)
|
|
55
|
+
return;
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
timer = undefined;
|
|
58
|
+
};
|
|
59
|
+
// True when a `next()` was abandoned mid-flight: on the timeout / abort
|
|
60
|
+
// arms the source is parked inside its own `await`, and awaiting its
|
|
61
|
+
// `return()` there would block behind the very socket we just left.
|
|
62
|
+
let parked = false;
|
|
63
|
+
const raceNext = (pending) => new Promise((resolve) => {
|
|
64
|
+
function onAbort() {
|
|
65
|
+
settle({ kind: "aborted" });
|
|
66
|
+
}
|
|
67
|
+
function settle(outcome) {
|
|
68
|
+
clearTimer();
|
|
69
|
+
signal?.removeEventListener("abort", onAbort);
|
|
70
|
+
resolve(outcome);
|
|
71
|
+
}
|
|
72
|
+
timer = setTimeout(() => settle({ kind: "timeout" }), idleTimeoutMs);
|
|
73
|
+
if (signal) {
|
|
74
|
+
if (signal.aborted) {
|
|
75
|
+
onAbort();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
79
|
+
}
|
|
80
|
+
pending.then((result) => settle({ kind: "event", result }),
|
|
81
|
+
// Not `reject`: the source's own failure must reach the adapter's
|
|
82
|
+
// classifier untouched (a bare undici TypeError carries no code), and
|
|
83
|
+
// a rejection reason is not required to be an Error here.
|
|
84
|
+
(err) => settle({ kind: "error", err }));
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
while (true) {
|
|
88
|
+
if (signal?.aborted)
|
|
89
|
+
return;
|
|
90
|
+
parked = false;
|
|
91
|
+
const pending = iterator.next();
|
|
92
|
+
// The timeout / abort arms walk away from `pending`; whatever it does
|
|
93
|
+
// next (usually the rejection the abort we just issued causes) must
|
|
94
|
+
// not surface as an unhandled rejection.
|
|
95
|
+
pending.catch(() => { });
|
|
96
|
+
const outcome = await raceNext(pending);
|
|
97
|
+
if (outcome.kind === "aborted") {
|
|
98
|
+
parked = true;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (outcome.kind === "timeout") {
|
|
102
|
+
parked = true;
|
|
103
|
+
onIdleTimeout?.();
|
|
104
|
+
throw new LlmError(`${label}: idle timeout waiting for stream`, "TIMEOUT");
|
|
105
|
+
}
|
|
106
|
+
if (outcome.kind === "error") {
|
|
107
|
+
// The source failed on its own terms; rethrow it verbatim (a bare
|
|
108
|
+
// undici TypeError must reach the adapter's classifier unrewritten)
|
|
109
|
+
// and do not wait on `return()` for an iterator we no longer trust —
|
|
110
|
+
// exactly the abandoned-read situation the timeout arm avoids.
|
|
111
|
+
parked = true;
|
|
112
|
+
throw outcome.err;
|
|
113
|
+
}
|
|
114
|
+
if (outcome.result.done)
|
|
115
|
+
return;
|
|
116
|
+
// Every event restarts the budget: the timer was cleared above and the
|
|
117
|
+
// next loop iteration arms a fresh one.
|
|
118
|
+
yield outcome.result.value;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
clearTimer();
|
|
123
|
+
if (!parked)
|
|
124
|
+
await iterator.return?.();
|
|
125
|
+
}
|
|
126
|
+
})();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Fold a watchdog-owned signal into a request without touching the caller's.
|
|
130
|
+
* The idle watchdog aborts it to close the body read it gave up on; the
|
|
131
|
+
* caller's own signal keeps driving cancellation.
|
|
132
|
+
*/
|
|
133
|
+
export function withExtraAbortSignal(request, extra) {
|
|
134
|
+
return {
|
|
135
|
+
...request,
|
|
136
|
+
signal: request.signal
|
|
137
|
+
? AbortSignal.any([request.signal, extra])
|
|
138
|
+
: extra,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=stream-idle-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-idle-timeout.js","sourceRoot":"","sources":["../src/stream-idle-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AAEtD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,aAAsB;IAC/D,OAAO,aAAa,KAAK,SAAS;QAChC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC9B,aAAa,GAAG,CAAC;QACjB,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,8BAA8B,CAAC;AACrC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