@xrkseek/harness-cli 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin/classify.js +1 -1
- package/dist/plugin/classify.js.map +1 -1
- package/node_modules/@xrkseek/core-agent/dist/index.d.ts +15 -3
- package/node_modules/@xrkseek/core-agent/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent/dist/index.js +8 -2
- package/node_modules/@xrkseek/core-agent/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/cancel-finalize.d.ts +6 -3
- 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 +50 -4
- 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 +23 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js +223 -43
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.d.ts +32 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js +92 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/llm-retry.js.map +1 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.d.ts +18 -8
- package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.js +187 -29
- package/node_modules/@xrkseek/core-agent-loop/dist/settle-batch.js.map +1 -1
- package/node_modules/@xrkseek/core-session/README.md +1 -1
- package/node_modules/@xrkseek/core-session/dist/chunk-pack.d.ts +18 -4
- package/node_modules/@xrkseek/core-session/dist/chunk-pack.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/chunk-pack.js +114 -34
- package/node_modules/@xrkseek/core-session/dist/chunk-pack.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.js +24 -4
- package/node_modules/@xrkseek/core-session/dist/compaction.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/dangling.d.ts +28 -1
- package/node_modules/@xrkseek/core-session/dist/dangling.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/dangling.js +35 -5
- package/node_modules/@xrkseek/core-session/dist/dangling.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/index.d.ts +3 -2
- package/node_modules/@xrkseek/core-session/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/index.js +3 -2
- package/node_modules/@xrkseek/core-session/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/latch.d.ts +1 -1
- package/node_modules/@xrkseek/core-session/dist/latch.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/latch.js +2 -2
- package/node_modules/@xrkseek/core-session/dist/latch.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/repair-open-turn.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/repair-open-turn.js +44 -4
- package/node_modules/@xrkseek/core-session/dist/repair-open-turn.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts +1 -0
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js +10 -5
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/surface-fold.d.ts +5 -0
- package/node_modules/@xrkseek/core-session/dist/surface-fold.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/surface-fold.js +29 -3
- package/node_modules/@xrkseek/core-session/dist/surface-fold.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/tool-result-prune.d.ts +35 -0
- package/node_modules/@xrkseek/core-session/dist/tool-result-prune.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-session/dist/tool-result-prune.js +99 -0
- package/node_modules/@xrkseek/core-session/dist/tool-result-prune.js.map +1 -0
- package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.js +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts +15 -2
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js +38 -4
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/abort.d.ts +5 -0
- package/node_modules/@xrkseek/core-tools/dist/abort.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/abort.js +14 -0
- package/node_modules/@xrkseek/core-tools/dist/abort.js.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/definition.d.ts +32 -1
- package/node_modules/@xrkseek/core-tools/dist/definition.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/definition.js +1 -0
- package/node_modules/@xrkseek/core-tools/dist/definition.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/execution-mode.d.ts +15 -0
- package/node_modules/@xrkseek/core-tools/dist/execution-mode.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/execution-mode.js +17 -0
- package/node_modules/@xrkseek/core-tools/dist/execution-mode.js.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts +2 -0
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.js +2 -0
- package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/pipeline.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/pipeline.js +36 -10
- package/node_modules/@xrkseek/core-tools/dist/pipeline.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/types.d.ts +7 -0
- 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-fs/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.js +3 -0
- package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-lsp/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-lsp/dist/tools.js +1 -0
- package/node_modules/@xrkseek/exec-lsp/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/index.js +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/registry.d.ts +5 -0
- package/node_modules/@xrkseek/exec-pty/dist/registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/registry.js +17 -1
- package/node_modules/@xrkseek/exec-pty/dist/registry.js.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/render.d.ts +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/render.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/render.js +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/render.js.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-pty/dist/tools.js +15 -4
- package/node_modules/@xrkseek/exec-pty/dist/tools.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 +4 -0
- package/node_modules/@xrkseek/exec-shell/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/search-providers.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/tools.js +2 -0
- package/node_modules/@xrkseek/exec-web/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/failure.d.ts +45 -0
- package/node_modules/@xrkseek/llm/dist/failure.d.ts.map +1 -0
- package/node_modules/@xrkseek/llm/dist/failure.js +115 -0
- package/node_modules/@xrkseek/llm/dist/failure.js.map +1 -0
- package/node_modules/@xrkseek/llm/dist/index.d.ts +80 -1
- package/node_modules/@xrkseek/llm/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm/dist/index.js +167 -2
- package/node_modules/@xrkseek/llm/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts +23 -0
- package/node_modules/@xrkseek/llm/dist/retry-policy.d.ts.map +1 -0
- package/node_modules/@xrkseek/llm/dist/retry-policy.js +74 -0
- package/node_modules/@xrkseek/llm/dist/retry-policy.js.map +1 -0
- package/node_modules/@xrkseek/llm-anthropic/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-anthropic/dist/index.js +152 -22
- package/node_modules/@xrkseek/llm-anthropic/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-deepseek/README.md +3 -3
- package/node_modules/@xrkseek/llm-deepseek/dist/index.d.ts +32 -2
- package/node_modules/@xrkseek/llm-deepseek/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-deepseek/dist/index.js +59 -5
- package/node_modules/@xrkseek/llm-deepseek/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-gemini/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-gemini/dist/index.js +18 -8
- package/node_modules/@xrkseek/llm-gemini/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.d.ts +16 -0
- package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.d.ts.map +1 -0
- package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.js +40 -0
- package/node_modules/@xrkseek/llm-openai-compatible/dist/deepseek-thinking.js.map +1 -0
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts +9 -1
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js +78 -21
- package/node_modules/@xrkseek/llm-openai-compatible/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.js +18 -8
- package/node_modules/@xrkseek/llm-openai-responses/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/llm-registry/dist/registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-registry/dist/registry.js +6 -4
- package/node_modules/@xrkseek/llm-registry/dist/registry.js.map +1 -1
- package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.js +15 -3
- package/node_modules/@xrkseek/llm-registry/dist/routing-adapter.js.map +1 -1
- package/node_modules/@xrkseek/llm-replay/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/llm-replay/dist/index.js +4 -1
- package/node_modules/@xrkseek/llm-replay/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/client.d.ts +3 -1
- package/node_modules/@xrkseek/mcp/dist/client.d.ts.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/client.js +31 -7
- package/node_modules/@xrkseek/mcp/dist/client.js.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/index.d.ts +2 -2
- package/node_modules/@xrkseek/mcp/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/index.js +1 -1
- package/node_modules/@xrkseek/mcp/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/register.d.ts.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/register.js +3 -0
- package/node_modules/@xrkseek/mcp/dist/register.js.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/types.d.ts +10 -0
- package/node_modules/@xrkseek/mcp/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +21 -3
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +31 -8
- 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/preset.d.ts +3 -2
- package/node_modules/@xrkseek/preset-minimal/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/preset.js +13 -7
- package/node_modules/@xrkseek/preset-minimal/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js +5 -1
- 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/index.d.ts +3 -1
- package/node_modules/@xrkseek/protocol/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/index.js +3 -1
- package/node_modules/@xrkseek/protocol/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts +72 -0
- package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/json-schema.js +99 -0
- package/node_modules/@xrkseek/protocol/dist/json-schema.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/messages.d.ts +7 -0
- package/node_modules/@xrkseek/protocol/dist/messages.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/session-events.d.ts +110 -6
- package/node_modules/@xrkseek/protocol/dist/session-events.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/session-events.js +23 -0
- package/node_modules/@xrkseek/protocol/dist/session-events.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/tools.d.ts +15 -0
- package/node_modules/@xrkseek/protocol/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/tools.js +6 -1
- package/node_modules/@xrkseek/protocol/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/validate.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/validate.js +234 -1
- package/node_modules/@xrkseek/protocol/dist/validate.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts +2 -0
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js +26 -8
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.js +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.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 +2 -2
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/llm-resolve.js +1 -1
- package/node_modules/@xrkseek/server-face/dist/llm-resolve.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/registry.d.ts +12 -50
- package/node_modules/@xrkseek/server-face/dist/projections/registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/registry.js +4 -146
- package/node_modules/@xrkseek/server-face/dist/projections/registry.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.js +13 -11
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-breakdown.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.js +27 -25
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-pressure.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.js +31 -29
- package/node_modules/@xrkseek/server-face/dist/projections/units/image-limits.js.map +1 -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 +27 -25
- package/node_modules/@xrkseek/server-face/dist/projections/units/permissions.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/plan.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/plan.js +12 -10
- package/node_modules/@xrkseek/server-face/dist/projections/units/plan.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.js +20 -14
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-list-metadata.js.map +1 -1
- 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 +27 -25
- package/node_modules/@xrkseek/server-face/dist/projections/units/session-stats.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/title.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/title.js +9 -7
- package/node_modules/@xrkseek/server-face/dist/projections/units/title.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/todos.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/todos.js +25 -23
- package/node_modules/@xrkseek/server-face/dist/projections/units/todos.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.js +14 -12
- package/node_modules/@xrkseek/server-face/dist/projections/units/token-usage.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.js +4 -2
- package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts +8 -13
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +29 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/skill-list.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/skill-list.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/skill-list.js +1 -0
- package/node_modules/@xrkseek/server-face/dist/skill-list.js.map +1 -1
- package/node_modules/@xrkseek/server-face/package.json +1 -0
- package/node_modules/@xrkseek/server-host/dist/agent-cache.js +1 -1
- package/node_modules/@xrkseek/server-host/dist/agent-cache.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.d.ts +8 -0
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +39 -1
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/session-projection/README.md +22 -0
- package/node_modules/@xrkseek/session-projection/dist/index.d.ts +100 -0
- package/node_modules/@xrkseek/session-projection/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-projection/dist/index.js +241 -0
- package/node_modules/@xrkseek/session-projection/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/session-projection/dist/types.d.ts +20 -0
- package/node_modules/@xrkseek/session-projection/dist/types.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-projection/dist/types.js +9 -0
- package/node_modules/@xrkseek/session-projection/dist/types.js.map +1 -0
- package/node_modules/@xrkseek/session-projection/package.json +31 -0
- package/node_modules/@xrkseek/workspace/README.md +3 -23
- package/node_modules/@xrkseek/workspace/dist/durable-inject.d.ts +62 -0
- package/node_modules/@xrkseek/workspace/dist/durable-inject.d.ts.map +1 -0
- package/node_modules/@xrkseek/workspace/dist/durable-inject.js +146 -0
- package/node_modules/@xrkseek/workspace/dist/durable-inject.js.map +1 -0
- package/node_modules/@xrkseek/workspace/dist/index.d.ts +25 -13
- package/node_modules/@xrkseek/workspace/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js +77 -17
- package/node_modules/@xrkseek/workspace/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-tools.js +7 -0
- package/node_modules/@xrkseek/workspace/dist/skill-tools.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skills.d.ts +12 -1
- package/node_modules/@xrkseek/workspace/dist/skills.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skills.js +42 -4
- package/node_modules/@xrkseek/workspace/dist/skills.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/slash.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/slash.js +2 -0
- package/node_modules/@xrkseek/workspace/dist/slash.js.map +1 -1
- package/node_modules/@xrkseek/workspace/package.json +2 -1
- package/package.json +3 -1
- package/product-web/assets/index-CcF0Sxxg.js +297 -0
- package/product-web/assets/index-CcF0Sxxg.js.map +1 -0
- package/product-web/assets/langs/{php-9bx0az3O.js → php-DY2VakOf.js} +2 -2
- package/product-web/assets/langs/{php-9bx0az3O.js.map → php-DY2VakOf.js.map} +1 -1
- package/product-web/assets/langs/{ruby-HDLHRjSL.js → ruby-hwtoiFmS.js} +2 -2
- package/product-web/assets/langs/{ruby-HDLHRjSL.js.map → ruby-hwtoiFmS.js.map} +1 -1
- package/product-web/assets/{vendor-CeMKrCZm.js → vendor-CldRVjca.js} +35 -36
- package/product-web/assets/vendor-CldRVjca.js.map +1 -0
- package/product-web/boot.json +1 -1
- package/product-web/index.html +2 -2
- package/product-web/plugins/@xrkseek/client-locale/client.js +3 -3
- package/product-web/plugins/@xrkseek/client-runtime/client.js +37 -1
- package/product-web/plugins/@xrkseek/client-ui-agent-preset/client.js +37 -37
- package/product-web/plugins/@xrkseek/client-ui-commands/client.js +8 -8
- package/product-web/plugins/@xrkseek/client-ui-conversation/client.js +172 -186
- package/product-web/plugins/@xrkseek/client-ui-deliverables/client.js +5 -5
- package/product-web/plugins/@xrkseek/client-ui-directory-picker-browse/client.js +30 -30
- package/product-web/plugins/@xrkseek/client-ui-goal/client.js +4 -4
- package/product-web/plugins/@xrkseek/client-ui-input-trigger/client.js +4 -4
- package/product-web/plugins/@xrkseek/client-ui-jobs/client.js +10 -10
- package/product-web/plugins/@xrkseek/client-ui-layout/client.js +3 -3
- package/product-web/plugins/@xrkseek/client-ui-message-feedback/client.js +3 -3
- package/product-web/plugins/@xrkseek/client-ui-model-selection/client.js +16 -16
- package/product-web/plugins/@xrkseek/client-ui-permission-presets/client.js +4 -4
- package/product-web/plugins/@xrkseek/client-ui-plan/client.js +2 -2
- package/product-web/plugins/@xrkseek/client-ui-settings-general/client.js +15 -15
- package/product-web/plugins/@xrkseek/client-ui-settings-models/client.js +55 -55
- package/product-web/plugins/@xrkseek/client-ui-settings-plugin-inventory/client.js +13 -13
- package/product-web/plugins/@xrkseek/client-ui-settings-plugins/client.js +134 -63
- package/product-web/plugins/@xrkseek/client-ui-sidebar/client.js +14 -14
- package/product-web/plugins/@xrkseek/client-ui-skill/client.js +11 -11
- package/product-web/plugins/@xrkseek/client-ui-subagent/client.js +15 -15
- package/product-web/plugins/@xrkseek/client-ui-theme/client.js +3 -3
- package/product-web/plugins/@xrkseek/client-ui-tool/client.js +43 -43
- package/product-web/plugins/@xrkseek/client-ui-trajectory/client.js +166 -145
- package/product-web/plugins/@xrkseek/client-ui-user-questions/client.js +30 -30
- package/product-web/plugins/@xrkseek/client-ui-workflow-run/client.js +16 -16
- package/product-web/plugins/@xrkseek/client-ui-workspace/client.js +56 -56
- package/node_modules/@xrkseek/server-face/dist/dsh-schema.d.ts +0 -35
- package/node_modules/@xrkseek/server-face/dist/dsh-schema.d.ts.map +0 -1
- package/node_modules/@xrkseek/server-face/dist/dsh-schema.js +0 -116
- package/node_modules/@xrkseek/server-face/dist/dsh-schema.js.map +0 -1
- package/node_modules/@xrkseek/server-face/dist/envelope.d.ts +0 -23
- package/node_modules/@xrkseek/server-face/dist/envelope.d.ts.map +0 -1
- package/node_modules/@xrkseek/server-face/dist/envelope.js +0 -51
- package/node_modules/@xrkseek/server-face/dist/envelope.js.map +0 -1
- package/node_modules/@xrkseek/server-face/dist/rpc-error.d.ts +0 -15
- package/node_modules/@xrkseek/server-face/dist/rpc-error.d.ts.map +0 -1
- package/node_modules/@xrkseek/server-face/dist/rpc-error.js +0 -247
- package/node_modules/@xrkseek/server-face/dist/rpc-error.js.map +0 -1
- package/product-web/assets/index-BwSJq-Ch.js +0 -112
- package/product-web/assets/index-BwSJq-Ch.js.map +0 -1
- package/product-web/assets/vendor-CeMKrCZm.js.map +0 -1
|
@@ -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;AAE3B,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,YAAY,CAAC,EAAE,CACtB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,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;AAE3B,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,QA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2
|
+
* Map OpenAI Chat Completions `finish_reason` onto a response (DSH
|
|
3
|
+
* `llm-deepseek/translate.mapFinishReason`).
|
|
4
|
+
*/
|
|
5
|
+
export function withOpenAiFinishReason(response, raw) {
|
|
6
|
+
if (raw === "length")
|
|
7
|
+
return { ...response, finishReason: "max-tokens" };
|
|
8
|
+
if (raw === "tool_calls")
|
|
9
|
+
return { ...response, finishReason: "tool-calls" };
|
|
10
|
+
if (raw === "stop")
|
|
11
|
+
return { ...response, finishReason: "stop" };
|
|
12
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
13
|
+
return {
|
|
14
|
+
...response,
|
|
15
|
+
finishReason: "error",
|
|
16
|
+
finishError: {
|
|
17
|
+
code: raw.toUpperCase(),
|
|
18
|
+
message: `model stopped: ${raw}`,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
24
|
+
/** Map Anthropic Messages `stop_reason` onto a response. */
|
|
25
|
+
export function withAnthropicStopReason(response, raw) {
|
|
26
|
+
if (raw === "max_tokens")
|
|
27
|
+
return { ...response, finishReason: "max-tokens" };
|
|
28
|
+
if (raw === "tool_use")
|
|
29
|
+
return { ...response, finishReason: "tool-calls" };
|
|
30
|
+
if (raw === "end_turn" || raw === "stop_sequence") {
|
|
31
|
+
return { ...response, finishReason: "stop" };
|
|
32
|
+
}
|
|
33
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
34
|
+
return {
|
|
35
|
+
...response,
|
|
36
|
+
finishReason: "error",
|
|
37
|
+
finishError: {
|
|
38
|
+
code: raw.toUpperCase(),
|
|
39
|
+
message: `model stopped: ${raw}`,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
/** @deprecated Prefer {@link withOpenAiFinishReason}. */
|
|
46
|
+
export function mapOpenAiFinishReason(raw) {
|
|
47
|
+
if (raw === "length")
|
|
48
|
+
return "max-tokens";
|
|
49
|
+
if (raw === "tool_calls")
|
|
50
|
+
return "tool-calls";
|
|
51
|
+
if (raw === "stop")
|
|
52
|
+
return "stop";
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/** @deprecated Prefer {@link withAnthropicStopReason}. */
|
|
56
|
+
export function mapAnthropicStopReason(raw) {
|
|
57
|
+
if (raw === "max_tokens")
|
|
58
|
+
return "max-tokens";
|
|
59
|
+
if (raw === "tool_use")
|
|
60
|
+
return "tool-calls";
|
|
61
|
+
if (raw === "end_turn" || raw === "stop_sequence")
|
|
62
|
+
return "stop";
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* DSH BlockAssembler keep/drop: a `max-tokens` finish drops tool calls that
|
|
67
|
+
* may be truncated.
|
|
68
|
+
*/
|
|
69
|
+
export function applyMaxTokensKeepDrop(response) {
|
|
70
|
+
if (response.finishReason !== "max-tokens" || !response.toolCalls?.length) {
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
content: response.content,
|
|
75
|
+
...(response.reasoning ? { reasoning: response.reasoning } : {}),
|
|
76
|
+
...(response.usage ? { usage: response.usage } : {}),
|
|
77
|
+
finishReason: "max-tokens",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** True when parseArguments stored unparseable JSON as `{ _raw }`. */
|
|
81
|
+
export function toolCallArgsIncomplete(args) {
|
|
82
|
+
return (!!args &&
|
|
83
|
+
typeof args === "object" &&
|
|
84
|
+
!Array.isArray(args) &&
|
|
85
|
+
Object.keys(args).length === 1 &&
|
|
86
|
+
typeof args._raw === "string");
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Post-provider gate (DSH translate + BlockAssembler): keep/drop, refuse
|
|
90
|
+
* unknown finishes / empty stops / truncated tool JSON outside max-tokens.
|
|
91
|
+
*/
|
|
92
|
+
export function finalizeLlmChatResponse(response) {
|
|
93
|
+
const dropped = applyMaxTokensKeepDrop(response);
|
|
94
|
+
if (dropped.finishReason === "error") {
|
|
95
|
+
throw new ProviderFinishError(dropped.finishError?.message ?? "model stopped with an error finish", dropped.finishError?.code ?? "FINISH_ERROR");
|
|
96
|
+
}
|
|
97
|
+
if (dropped.toolCalls?.some((c) => toolCallArgsIncomplete(c.arguments)) &&
|
|
98
|
+
dropped.finishReason !== "max-tokens") {
|
|
99
|
+
throw new IncompleteToolCallError("tool call arguments were truncated or invalid JSON");
|
|
100
|
+
}
|
|
101
|
+
const empty = !dropped.content.trim() &&
|
|
102
|
+
!dropped.reasoning?.trim() &&
|
|
103
|
+
!(dropped.toolCalls && dropped.toolCalls.length > 0);
|
|
104
|
+
// max-tokens may leave a usage-only durable row; do not treat as EMPTY_RESPONSE.
|
|
105
|
+
if (empty &&
|
|
106
|
+
(dropped.finishReason === "stop" || dropped.finishReason === undefined)) {
|
|
107
|
+
throw new EmptyResponseError();
|
|
108
|
+
}
|
|
109
|
+
return dropped;
|
|
110
|
+
}
|
|
1
111
|
/** Provider reported context window / token limit exceeded. */
|
|
2
112
|
export class ContextOverflowError extends Error {
|
|
3
113
|
constructor(message = "context overflow") {
|
|
@@ -19,6 +129,53 @@ export class UnsupportedContentError extends Error {
|
|
|
19
129
|
export function isUnsupportedContentError(err) {
|
|
20
130
|
return err instanceof UnsupportedContentError;
|
|
21
131
|
}
|
|
132
|
+
/** DSH EMPTY_RESPONSE: stop with no text, reasoning, or tool calls. */
|
|
133
|
+
export class EmptyResponseError extends Error {
|
|
134
|
+
code = "EMPTY_RESPONSE";
|
|
135
|
+
constructor(message = "empty model response") {
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = "EmptyResponseError";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export function isEmptyResponseError(err) {
|
|
141
|
+
return err instanceof EmptyResponseError;
|
|
142
|
+
}
|
|
143
|
+
/** Unknown / filtered finish_reason (DSH finish kind error). */
|
|
144
|
+
export class ProviderFinishError extends Error {
|
|
145
|
+
code;
|
|
146
|
+
constructor(message, code) {
|
|
147
|
+
super(message);
|
|
148
|
+
this.name = "ProviderFinishError";
|
|
149
|
+
this.code = code;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export function isProviderFinishError(err) {
|
|
153
|
+
return err instanceof ProviderFinishError;
|
|
154
|
+
}
|
|
155
|
+
/** Tool-call JSON truncated when finish was not max-tokens. */
|
|
156
|
+
export class IncompleteToolCallError extends Error {
|
|
157
|
+
code = "INCOMPLETE_TOOL_CALL";
|
|
158
|
+
constructor(message = "incomplete tool call") {
|
|
159
|
+
super(message);
|
|
160
|
+
this.name = "IncompleteToolCallError";
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function isIncompleteToolCallError(err) {
|
|
164
|
+
return err instanceof IncompleteToolCallError;
|
|
165
|
+
}
|
|
166
|
+
/** Unsupported or deployment-locked reasoning effort (DSH UNSUPPORTED_REASONING_EFFORT). */
|
|
167
|
+
export class UnsupportedReasoningEffortError extends Error {
|
|
168
|
+
code = "UNSUPPORTED_REASONING_EFFORT";
|
|
169
|
+
constructor(message) {
|
|
170
|
+
super(message);
|
|
171
|
+
this.name = "UnsupportedReasoningEffortError";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export function isUnsupportedReasoningEffortError(err) {
|
|
175
|
+
return err instanceof UnsupportedReasoningEffortError;
|
|
176
|
+
}
|
|
177
|
+
export { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, QUOTA_EXCEEDED_CODE, LlmError, classifyCaughtLlmError, httpErrorCode, isLlmError, isQuotaExceededError, parseRetryAfterMs, requestIdFromHeaders, throwHttpLlmError, } from "./failure.js";
|
|
178
|
+
export { DEFAULT_RETRY_POLICY, DEFAULT_RETRYABLE_CODES, cancellableDelay, computeRetryDelayMs, failureFromUnknown, isRetryableFailure, } from "./retry-policy.js";
|
|
22
179
|
export function createLlmRegistry() {
|
|
23
180
|
const adapters = new Map();
|
|
24
181
|
return {
|
|
@@ -45,6 +202,8 @@ export async function collectLlmStream(stream) {
|
|
|
45
202
|
let reasoning = "";
|
|
46
203
|
let toolCalls;
|
|
47
204
|
let usage;
|
|
205
|
+
let finishReason;
|
|
206
|
+
let finishError;
|
|
48
207
|
for await (const ev of stream) {
|
|
49
208
|
if (ev.type === "text-delta")
|
|
50
209
|
content += ev.text;
|
|
@@ -60,13 +219,19 @@ export async function collectLlmStream(stream) {
|
|
|
60
219
|
toolCalls = ev.toolCalls;
|
|
61
220
|
if (ev.usage)
|
|
62
221
|
usage = ev.usage;
|
|
222
|
+
if (ev.finishReason)
|
|
223
|
+
finishReason = ev.finishReason;
|
|
224
|
+
if (ev.finishError)
|
|
225
|
+
finishError = ev.finishError;
|
|
63
226
|
}
|
|
64
227
|
}
|
|
65
|
-
return {
|
|
228
|
+
return finalizeLlmChatResponse({
|
|
66
229
|
content,
|
|
67
230
|
...(reasoning.trim() ? { reasoning } : {}),
|
|
68
231
|
...(toolCalls ? { toolCalls } : {}),
|
|
69
232
|
...(usage ? { usage } : {}),
|
|
70
|
-
|
|
233
|
+
...(finishReason ? { finishReason } : {}),
|
|
234
|
+
...(finishError ? { finishError } : {}),
|
|
235
|
+
});
|
|
71
236
|
}
|
|
72
237
|
//# sourceMappingURL=index.js.map
|
|
@@ -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":"AAoFA;;;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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,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider request retry policy (DSH llm-retry normal mode subset).
|
|
3
|
+
*/
|
|
4
|
+
import { type LlmFailure } from "./failure.js";
|
|
5
|
+
export type RetryPolicyMode = "normal" | "always";
|
|
6
|
+
export interface ResolvedRetryPolicy {
|
|
7
|
+
readonly mode: RetryPolicyMode;
|
|
8
|
+
/** Cap for `normal` mode (ignored when `always`). Default 5. */
|
|
9
|
+
readonly maxRetries: number;
|
|
10
|
+
readonly retryableCodes: readonly string[];
|
|
11
|
+
readonly initialDelayMs: number;
|
|
12
|
+
readonly maxDelayMs: number;
|
|
13
|
+
/** Jitter ratio in [0, 1]; default 0.25. */
|
|
14
|
+
readonly jitterRatio: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_RETRYABLE_CODES: readonly ["EMPTY_RESPONSE", "RATE_LIMIT", "SERVER", "TIMEOUT", "TRANSPORT"];
|
|
17
|
+
export declare const DEFAULT_RETRY_POLICY: ResolvedRetryPolicy;
|
|
18
|
+
export declare function failureFromUnknown(err: unknown): LlmFailure;
|
|
19
|
+
export declare function isRetryableFailure(failure: LlmFailure, policy?: ResolvedRetryPolicy): boolean;
|
|
20
|
+
export declare function computeRetryDelayMs(policy: ResolvedRetryPolicy, retry: number, failure?: LlmFailure, random?: () => number): number;
|
|
21
|
+
/** Cancellable delay; resolves false when aborted before the timer fires. */
|
|
22
|
+
export declare function cancellableDelay(delayMs: number, signal?: AbortSignal): Promise<boolean>;
|
|
23
|
+
//# sourceMappingURL=retry-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,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,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,uBAAuB,6EAM1B,CAAC;AAEX,eAAO,MAAM,oBAAoB,EAAE,mBAOlC,CAAC;AAeF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAU3D;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"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider request retry policy (DSH llm-retry normal mode subset).
|
|
3
|
+
*/
|
|
4
|
+
import { isLlmError, } from "./failure.js";
|
|
5
|
+
export const DEFAULT_RETRYABLE_CODES = [
|
|
6
|
+
"EMPTY_RESPONSE",
|
|
7
|
+
"RATE_LIMIT",
|
|
8
|
+
"SERVER",
|
|
9
|
+
"TIMEOUT",
|
|
10
|
+
"TRANSPORT",
|
|
11
|
+
];
|
|
12
|
+
export const DEFAULT_RETRY_POLICY = {
|
|
13
|
+
mode: "normal",
|
|
14
|
+
maxRetries: 5,
|
|
15
|
+
retryableCodes: [...DEFAULT_RETRYABLE_CODES],
|
|
16
|
+
initialDelayMs: 1_000,
|
|
17
|
+
maxDelayMs: 60_000,
|
|
18
|
+
jitterRatio: 0.25,
|
|
19
|
+
};
|
|
20
|
+
function errorCode(err) {
|
|
21
|
+
if (isLlmError(err))
|
|
22
|
+
return err.code;
|
|
23
|
+
if (err &&
|
|
24
|
+
typeof err === "object" &&
|
|
25
|
+
"code" in err &&
|
|
26
|
+
typeof (err).code === "string") {
|
|
27
|
+
return err.code;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
export function failureFromUnknown(err) {
|
|
32
|
+
if (isLlmError(err))
|
|
33
|
+
return err.toFailure();
|
|
34
|
+
const code = errorCode(err);
|
|
35
|
+
if (err instanceof Error) {
|
|
36
|
+
return {
|
|
37
|
+
message: err.message,
|
|
38
|
+
code: code ?? "UNKNOWN",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { message: String(err), code: code ?? "UNKNOWN" };
|
|
42
|
+
}
|
|
43
|
+
export function isRetryableFailure(failure, policy = DEFAULT_RETRY_POLICY) {
|
|
44
|
+
if (policy.mode === "always")
|
|
45
|
+
return true;
|
|
46
|
+
return policy.retryableCodes.includes(failure.code);
|
|
47
|
+
}
|
|
48
|
+
export function computeRetryDelayMs(policy, retry, failure, random = Math.random) {
|
|
49
|
+
if (failure?.providerRetryAfterMs !== undefined &&
|
|
50
|
+
failure.providerRetryAfterMs > 0) {
|
|
51
|
+
return Math.min(failure.providerRetryAfterMs, policy.maxDelayMs);
|
|
52
|
+
}
|
|
53
|
+
const exponent = Math.min(Math.max(retry - 1, 0), 1024);
|
|
54
|
+
const exponential = Math.min(policy.initialDelayMs * 2 ** exponent, policy.maxDelayMs);
|
|
55
|
+
const jitter = 1 - policy.jitterRatio + 2 * policy.jitterRatio * random();
|
|
56
|
+
return Math.min(exponential * jitter, policy.maxDelayMs);
|
|
57
|
+
}
|
|
58
|
+
/** Cancellable delay; resolves false when aborted before the timer fires. */
|
|
59
|
+
export function cancellableDelay(delayMs, signal) {
|
|
60
|
+
if (signal?.aborted)
|
|
61
|
+
return Promise.resolve(false);
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
const timer = setTimeout(() => {
|
|
64
|
+
signal?.removeEventListener("abort", onAbort);
|
|
65
|
+
resolve(true);
|
|
66
|
+
}, delayMs);
|
|
67
|
+
function onAbort() {
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
resolve(false);
|
|
70
|
+
}
|
|
71
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=retry-policy.js.map
|
|
@@ -0,0 +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;AAetB,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,gBAAgB;IAChB,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,WAAW;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACvD,IAAI,EAAE,QAA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AAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAEhB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAEhB,MAAM,cAAc,CAAC;AAmBtB,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,eAAO,MAAM,qBAAqB,eAAe,CAAC;AA8DlD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IACzD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AA2UD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,UAAU,CA4HZ;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAG1B"}
|
|
@@ -1,9 +1,59 @@
|
|
|
1
1
|
import { DEFAULT_MAX_REQUEST_IMAGE_BYTES, offloadRequestImages, } from "@xrkseek/attachment";
|
|
2
|
-
import { collectLlmStream, ContextOverflowError, UnsupportedContentError, } from "@xrkseek/llm";
|
|
3
|
-
import { asContentBlocks, contentHasImage, flattenText, } from "@xrkseek/protocol";
|
|
2
|
+
import { finalizeLlmChatResponse, collectLlmStream, classifyCaughtLlmError, ContextOverflowError, isLlmError, throwHttpLlmError, UnsupportedContentError, withAnthropicStopReason, } from "@xrkseek/llm";
|
|
3
|
+
import { asContentBlocks, contentHasImage, flattenText, tryParseOpenAiUsage, } from "@xrkseek/protocol";
|
|
4
4
|
export const ANTHROPIC_DEFAULT_BASE_URL = "https://api.anthropic.com";
|
|
5
5
|
export const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
6
6
|
export const ANTHROPIC_API_VERSION = "2023-06-01";
|
|
7
|
+
const EPHEMERAL_CACHE = { type: "ephemeral" };
|
|
8
|
+
/** Soft-merge Anthropic stream usage fragments (input on start, output on delta). */
|
|
9
|
+
function mergeAnthropicUsagePartial(prev, raw) {
|
|
10
|
+
if (!raw || typeof raw !== "object")
|
|
11
|
+
return prev;
|
|
12
|
+
const o = raw;
|
|
13
|
+
const inputRaw = o.input_tokens ?? o.inputTokens;
|
|
14
|
+
const outputRaw = o.output_tokens ?? o.outputTokens;
|
|
15
|
+
const cacheReadRaw = o.cache_read_input_tokens ?? o.cacheReadTokens;
|
|
16
|
+
const cacheWriteRaw = o.cache_creation_input_tokens ?? o.cacheWriteTokens;
|
|
17
|
+
const asNonNeg = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0
|
|
18
|
+
? Math.trunc(v)
|
|
19
|
+
: undefined;
|
|
20
|
+
const input = asNonNeg(inputRaw);
|
|
21
|
+
const output = asNonNeg(outputRaw);
|
|
22
|
+
const cacheRead = asNonNeg(cacheReadRaw);
|
|
23
|
+
const cacheWrite = asNonNeg(cacheWriteRaw);
|
|
24
|
+
if (input === undefined &&
|
|
25
|
+
output === undefined &&
|
|
26
|
+
cacheRead === undefined &&
|
|
27
|
+
cacheWrite === undefined) {
|
|
28
|
+
return prev;
|
|
29
|
+
}
|
|
30
|
+
// Disjoint buckets: subtract cache reads from input when both present (DSH mapUsage).
|
|
31
|
+
let inputTokens = input ?? prev?.inputTokens ?? 0;
|
|
32
|
+
if (input !== undefined && cacheRead !== undefined) {
|
|
33
|
+
inputTokens = Math.max(0, input - cacheRead);
|
|
34
|
+
}
|
|
35
|
+
else if (input === undefined && cacheRead !== undefined && prev?.inputTokens !== undefined) {
|
|
36
|
+
// keep prior uncached input
|
|
37
|
+
inputTokens = prev.inputTokens;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
inputTokens,
|
|
41
|
+
outputTokens: output ?? prev?.outputTokens ?? 0,
|
|
42
|
+
...(cacheRead !== undefined
|
|
43
|
+
? { cacheReadTokens: cacheRead }
|
|
44
|
+
: prev?.cacheReadTokens !== undefined
|
|
45
|
+
? { cacheReadTokens: prev.cacheReadTokens }
|
|
46
|
+
: {}),
|
|
47
|
+
...(cacheWrite !== undefined
|
|
48
|
+
? { cacheWriteTokens: cacheWrite }
|
|
49
|
+
: prev?.cacheWriteTokens !== undefined
|
|
50
|
+
? { cacheWriteTokens: prev.cacheWriteTokens }
|
|
51
|
+
: {}),
|
|
52
|
+
...(prev?.reasoningTokens !== undefined
|
|
53
|
+
? { reasoningTokens: prev.reasoningTokens }
|
|
54
|
+
: {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
7
57
|
function bytesToBase64(data) {
|
|
8
58
|
return Buffer.from(data).toString("base64");
|
|
9
59
|
}
|
|
@@ -123,11 +173,13 @@ function parseResponse(json) {
|
|
|
123
173
|
}
|
|
124
174
|
}
|
|
125
175
|
}
|
|
126
|
-
|
|
176
|
+
const usage = tryParseOpenAiUsage(json?.usage);
|
|
177
|
+
return finalizeLlmChatResponse(withAnthropicStopReason({
|
|
127
178
|
content,
|
|
128
179
|
...(reasoning.trim() ? { reasoning } : {}),
|
|
129
180
|
...(toolCalls.length ? { toolCalls } : {}),
|
|
130
|
-
|
|
181
|
+
...(usage ? { usage } : {}),
|
|
182
|
+
}, json?.stop_reason));
|
|
131
183
|
}
|
|
132
184
|
async function* streamAnthropicSse(res) {
|
|
133
185
|
if (!res.body)
|
|
@@ -140,6 +192,8 @@ async function* streamAnthropicSse(res) {
|
|
|
140
192
|
const toolAcc = new Map();
|
|
141
193
|
let blockIndex = -1;
|
|
142
194
|
let blockType = "";
|
|
195
|
+
let usage;
|
|
196
|
+
let stopRaw;
|
|
143
197
|
const flushEvent = function* (payload) {
|
|
144
198
|
let json;
|
|
145
199
|
try {
|
|
@@ -149,6 +203,25 @@ async function* streamAnthropicSse(res) {
|
|
|
149
203
|
return;
|
|
150
204
|
}
|
|
151
205
|
const ev = json;
|
|
206
|
+
if (ev.type === "message_start") {
|
|
207
|
+
const next = mergeAnthropicUsagePartial(usage, ev.message?.usage);
|
|
208
|
+
if (next) {
|
|
209
|
+
usage = next;
|
|
210
|
+
yield { type: "usage", usage: next };
|
|
211
|
+
}
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (ev.type === "message_delta") {
|
|
215
|
+
if (ev.delta?.stop_reason !== undefined) {
|
|
216
|
+
stopRaw = ev.delta.stop_reason;
|
|
217
|
+
}
|
|
218
|
+
const next = mergeAnthropicUsagePartial(usage, ev.usage);
|
|
219
|
+
if (next) {
|
|
220
|
+
usage = next;
|
|
221
|
+
yield { type: "usage", usage: next };
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
152
225
|
if (ev.type === "content_block_start") {
|
|
153
226
|
blockIndex = typeof ev.index === "number" ? ev.index : blockIndex + 1;
|
|
154
227
|
blockType = ev.content_block?.type ?? "";
|
|
@@ -160,6 +233,15 @@ async function* streamAnthropicSse(res) {
|
|
|
160
233
|
...(name !== undefined ? { name } : {}),
|
|
161
234
|
json: "",
|
|
162
235
|
});
|
|
236
|
+
if (typeof id === "string") {
|
|
237
|
+
yield {
|
|
238
|
+
type: "tool-call-delta",
|
|
239
|
+
index: blockIndex,
|
|
240
|
+
id,
|
|
241
|
+
...(typeof name === "string" ? { name } : {}),
|
|
242
|
+
argumentsDelta: "",
|
|
243
|
+
};
|
|
244
|
+
}
|
|
163
245
|
}
|
|
164
246
|
return;
|
|
165
247
|
}
|
|
@@ -178,9 +260,18 @@ async function* streamAnthropicSse(res) {
|
|
|
178
260
|
}
|
|
179
261
|
else if (delta.type === "input_json_delta" &&
|
|
180
262
|
typeof delta.partial_json === "string") {
|
|
181
|
-
const
|
|
263
|
+
const idx = typeof ev.index === "number" ? ev.index : blockIndex;
|
|
264
|
+
const cur = toolAcc.get(idx) ?? { json: "" };
|
|
182
265
|
cur.json += delta.partial_json;
|
|
183
|
-
toolAcc.set(
|
|
266
|
+
toolAcc.set(idx, cur);
|
|
267
|
+
const id = cur.id ?? `call_${idx}_${(cur.name ?? "unknown").replace(/\W/g, "_")}`;
|
|
268
|
+
yield {
|
|
269
|
+
type: "tool-call-delta",
|
|
270
|
+
index: idx,
|
|
271
|
+
id,
|
|
272
|
+
...(cur.name ? { name: cur.name } : {}),
|
|
273
|
+
argumentsDelta: delta.partial_json,
|
|
274
|
+
};
|
|
184
275
|
}
|
|
185
276
|
}
|
|
186
277
|
};
|
|
@@ -216,11 +307,24 @@ async function* streamAnthropicSse(res) {
|
|
|
216
307
|
arguments: args,
|
|
217
308
|
});
|
|
218
309
|
}
|
|
219
|
-
|
|
220
|
-
type: "done",
|
|
310
|
+
const finalized = finalizeLlmChatResponse(withAnthropicStopReason({
|
|
221
311
|
content,
|
|
222
312
|
...(reasoning.trim() ? { reasoning } : {}),
|
|
223
313
|
...(toolCalls.length ? { toolCalls } : {}),
|
|
314
|
+
...(usage ? { usage } : {}),
|
|
315
|
+
}, stopRaw));
|
|
316
|
+
yield {
|
|
317
|
+
type: "done",
|
|
318
|
+
content: finalized.content,
|
|
319
|
+
...(finalized.reasoning ? { reasoning: finalized.reasoning } : {}),
|
|
320
|
+
...(finalized.toolCalls ? { toolCalls: finalized.toolCalls } : {}),
|
|
321
|
+
...(finalized.usage ? { usage: finalized.usage } : {}),
|
|
322
|
+
...(finalized.finishReason
|
|
323
|
+
? { finishReason: finalized.finishReason }
|
|
324
|
+
: {}),
|
|
325
|
+
...(finalized.finishError
|
|
326
|
+
? { finishError: finalized.finishError }
|
|
327
|
+
: {}),
|
|
224
328
|
};
|
|
225
329
|
}
|
|
226
330
|
/**
|
|
@@ -249,16 +353,32 @@ export function createAnthropicAdapter(options) {
|
|
|
249
353
|
messages,
|
|
250
354
|
stream,
|
|
251
355
|
};
|
|
252
|
-
if (system)
|
|
253
|
-
|
|
356
|
+
if (system) {
|
|
357
|
+
// Prompt-cache breakpoint on the stable system prefix (DSH gold).
|
|
358
|
+
body.system = [
|
|
359
|
+
{
|
|
360
|
+
type: "text",
|
|
361
|
+
text: system,
|
|
362
|
+
cache_control: EPHEMERAL_CACHE,
|
|
363
|
+
},
|
|
364
|
+
];
|
|
365
|
+
}
|
|
254
366
|
if (options.temperature !== undefined)
|
|
255
367
|
body.temperature = options.temperature;
|
|
256
368
|
if (request.tools?.length) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
369
|
+
const tools = request.tools.map((t, i) => {
|
|
370
|
+
const def = {
|
|
371
|
+
name: t.name,
|
|
372
|
+
description: t.description,
|
|
373
|
+
input_schema: t.parameters,
|
|
374
|
+
};
|
|
375
|
+
// Cache breakpoint on the last tool — tools block is sorted/stable.
|
|
376
|
+
if (i === request.tools.length - 1) {
|
|
377
|
+
def.cache_control = EPHEMERAL_CACHE;
|
|
378
|
+
}
|
|
379
|
+
return def;
|
|
380
|
+
});
|
|
381
|
+
body.tools = tools;
|
|
262
382
|
}
|
|
263
383
|
const headers = {
|
|
264
384
|
"content-type": "application/json",
|
|
@@ -274,18 +394,28 @@ export function createAnthropicAdapter(options) {
|
|
|
274
394
|
const signal = request.signal && timeoutSignal
|
|
275
395
|
? AbortSignal.any([request.signal, timeoutSignal])
|
|
276
396
|
: (request.signal ?? timeoutSignal);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
397
|
+
let res;
|
|
398
|
+
try {
|
|
399
|
+
res = await doFetch(endpoint, {
|
|
400
|
+
method: "POST",
|
|
401
|
+
headers,
|
|
402
|
+
body: JSON.stringify(body),
|
|
403
|
+
...(signal ? { signal } : {}),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
catch (err) {
|
|
407
|
+
if (err instanceof DOMException && err.name === "AbortError")
|
|
408
|
+
throw err;
|
|
409
|
+
if (isLlmError(err))
|
|
410
|
+
throw err;
|
|
411
|
+
classifyCaughtLlmError(err, "anthropic");
|
|
412
|
+
}
|
|
283
413
|
if (!res.ok) {
|
|
284
414
|
const text = await res.text();
|
|
285
415
|
if (looksLikeOverflow(res.status, text)) {
|
|
286
416
|
throw new ContextOverflowError(`anthropic overflow (${res.status}): ${text.slice(0, 400)}`);
|
|
287
417
|
}
|
|
288
|
-
|
|
418
|
+
throwHttpLlmError("anthropic", res.status, text, res.headers);
|
|
289
419
|
}
|
|
290
420
|
return res;
|
|
291
421
|
}
|