@namzu/sdk 68.0.1 → 69.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +2 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/authorization/skill-grant.d.ts.map +1 -1
- package/dist/authorization/skill-grant.js +1 -0
- package/dist/authorization/skill-grant.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +10 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +12 -0
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +21 -0
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-window.d.ts +8 -0
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +14 -0
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/compaction/loaded-skills.d.ts +10 -0
- package/dist/compaction/loaded-skills.d.ts.map +1 -1
- package/dist/compaction/loaded-skills.js +45 -1
- package/dist/compaction/loaded-skills.js.map +1 -1
- package/dist/compaction/manager.d.ts +8 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +31 -0
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +7 -1
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.js +2 -2
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/restore.d.ts +8 -0
- package/dist/compaction/restore.d.ts.map +1 -1
- package/dist/compaction/restore.js +65 -0
- package/dist/compaction/restore.js.map +1 -1
- package/dist/compaction/salience/working-set.d.ts.map +1 -1
- package/dist/compaction/salience/working-set.js +2 -2
- package/dist/compaction/salience/working-set.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts +6 -0
- package/dist/compaction/tool-result-editing.d.ts.map +1 -1
- package/dist/compaction/tool-result-editing.js +7 -1
- package/dist/compaction/tool-result-editing.js.map +1 -1
- package/dist/compaction/types.d.ts +2 -0
- package/dist/compaction/types.d.ts.map +1 -1
- package/dist/compaction/wire.d.ts.map +1 -1
- package/dist/compaction/wire.js +4 -0
- package/dist/compaction/wire.js.map +1 -1
- package/dist/connector/index.d.ts +2 -2
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +29 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +59 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/errors.d.ts +7 -0
- package/dist/connector/mcp/errors.d.ts.map +1 -1
- package/dist/connector/mcp/errors.js +14 -0
- package/dist/connector/mcp/errors.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +5 -1
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +3 -1
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/skill-source.d.ts +144 -0
- package/dist/connector/mcp/skill-source.d.ts.map +1 -0
- package/dist/connector/mcp/skill-source.js +375 -0
- package/dist/connector/mcp/skill-source.js.map +1 -0
- package/dist/connector/mcp/skills.d.ts +137 -0
- package/dist/connector/mcp/skills.d.ts.map +1 -0
- package/dist/connector/mcp/skills.js +303 -0
- package/dist/connector/mcp/skills.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +23 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +1 -1
- package/dist/network/audit.d.ts.map +1 -1
- package/dist/network/audit.js +2 -0
- package/dist/network/audit.js.map +1 -1
- package/dist/network/computer.d.ts +107 -0
- package/dist/network/computer.d.ts.map +1 -0
- package/dist/network/computer.js +250 -0
- package/dist/network/computer.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.d.ts.map +1 -1
- package/dist/network/index.js +1 -0
- package/dist/network/index.js.map +1 -1
- package/dist/network/join.d.ts +13 -1
- package/dist/network/join.d.ts.map +1 -1
- package/dist/network/join.js +21 -3
- package/dist/network/join.js.map +1 -1
- package/dist/network/roster.d.ts +5 -0
- package/dist/network/roster.d.ts.map +1 -1
- package/dist/network/roster.js.map +1 -1
- package/dist/network/service.d.ts +12 -2
- package/dist/network/service.d.ts.map +1 -1
- package/dist/network/service.js +539 -60
- package/dist/network/service.js.map +1 -1
- package/dist/network/store.d.ts +33 -1
- package/dist/network/store.d.ts.map +1 -1
- package/dist/network/store.js +48 -4
- package/dist/network/store.js.map +1 -1
- package/dist/network/transport.d.ts +1 -1
- package/dist/network/transport.js +1 -1
- package/dist/network/wire.d.ts +14 -0
- package/dist/network/wire.d.ts.map +1 -1
- package/dist/network/wire.js +17 -1
- package/dist/network/wire.js.map +1 -1
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
- package/dist/plugin/shell-hook-tool-names.js +1 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +8 -3
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +132 -7
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +7 -2
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +9 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +8 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/instrumentation.d.ts.map +1 -1
- package/dist/provider/instrumentation.js +10 -0
- package/dist/provider/instrumentation.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +2 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +8 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +10 -7
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +12 -5
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +7 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +9 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +4 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/presentation.d.ts +8 -1
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +14 -5
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +2 -1
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +19 -3
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/failure.d.ts +12 -0
- package/dist/runtime/query/auto-review/failure.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/failure.js +46 -0
- package/dist/runtime/query/auto-review/failure.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +1 -0
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +1 -0
- package/dist/runtime/query/auto-review/index.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +10 -1
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +12 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +43 -9
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-replay.js +6 -6
- package/dist/runtime/query/file-evidence-replay.js.map +1 -1
- package/dist/runtime/query/index.d.ts +4 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +40 -1
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +2 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +21 -3
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +6 -2
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +24 -9
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +4 -0
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts +5 -1
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +13 -3
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +15 -4
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +15 -4
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/shell-line-escalation.d.ts +24 -0
- package/dist/runtime/query/shell-line-escalation.d.ts.map +1 -0
- package/dist/runtime/query/shell-line-escalation.js +38 -0
- package/dist/runtime/query/shell-line-escalation.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +7 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +2 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +4 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +47 -1
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +3 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +3 -1
- package/dist/scheduler/local.js.map +1 -1
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +2 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/inline-shell-host.d.ts +103 -0
- package/dist/skills/inline-shell-host.d.ts.map +1 -0
- package/dist/skills/inline-shell-host.js +238 -0
- package/dist/skills/inline-shell-host.js.map +1 -0
- package/dist/skills/inline-shell.d.ts +176 -0
- package/dist/skills/inline-shell.d.ts.map +1 -0
- package/dist/skills/inline-shell.js +646 -0
- package/dist/skills/inline-shell.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/task/file.d.ts +124 -0
- package/dist/store/task/file.d.ts.map +1 -0
- package/dist/store/task/file.js +498 -0
- package/dist/store/task/file.js.map +1 -0
- package/dist/teams/backend.d.ts +28 -0
- package/dist/teams/backend.d.ts.map +1 -0
- package/dist/teams/backend.js +2 -0
- package/dist/teams/backend.js.map +1 -0
- package/dist/teams/fs-sync.d.ts +19 -0
- package/dist/teams/fs-sync.d.ts.map +1 -0
- package/dist/teams/fs-sync.js +81 -0
- package/dist/teams/fs-sync.js.map +1 -0
- package/dist/teams/index.d.ts +14 -0
- package/dist/teams/index.d.ts.map +1 -0
- package/dist/teams/index.js +11 -0
- package/dist/teams/index.js.map +1 -0
- package/dist/teams/names.d.ts +15 -0
- package/dist/teams/names.d.ts.map +1 -0
- package/dist/teams/names.js +43 -0
- package/dist/teams/names.js.map +1 -0
- package/dist/teams/store.d.ts +133 -0
- package/dist/teams/store.d.ts.map +1 -0
- package/dist/teams/store.js +536 -0
- package/dist/teams/store.js.map +1 -0
- package/dist/teams/types.d.ts +97 -0
- package/dist/teams/types.d.ts.map +1 -0
- package/dist/teams/types.js +70 -0
- package/dist/teams/types.js.map +1 -0
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +28 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +5 -2
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.js +1 -1
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +60 -2
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +695 -80
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +2 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit-apply.d.ts +1 -0
- package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
- package/dist/tools/builtins/edit-apply.js +108 -21
- package/dist/tools/builtins/edit-apply.js.map +1 -1
- package/dist/tools/builtins/edit-match.d.ts +37 -0
- package/dist/tools/builtins/edit-match.d.ts.map +1 -1
- package/dist/tools/builtins/edit-match.js +193 -0
- package/dist/tools/builtins/edit-match.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +14 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/exit-semantics.d.ts +8 -0
- package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
- package/dist/tools/builtins/exit-semantics.js +19 -0
- package/dist/tools/builtins/exit-semantics.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +3 -1
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +1 -0
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/present-file.d.ts +24 -0
- package/dist/tools/builtins/present-file.d.ts.map +1 -0
- package/dist/tools/builtins/present-file.js +116 -0
- package/dist/tools/builtins/present-file.js.map +1 -0
- package/dist/tools/builtins/read-file.js +1 -1
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts +12 -1
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +16 -3
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +10 -0
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +36 -2
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +31 -0
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +232 -88
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +5 -0
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +13 -2
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +13 -4
- package/dist/tools/task/create.js.map +1 -1
- package/dist/tools/task/get.d.ts +8 -0
- package/dist/tools/task/get.d.ts.map +1 -0
- package/dist/tools/task/get.js +51 -0
- package/dist/tools/task/get.js.map +1 -0
- package/dist/tools/task/index.d.ts +7 -0
- package/dist/tools/task/index.d.ts.map +1 -1
- package/dist/tools/task/index.js +10 -2
- package/dist/tools/task/index.js.map +1 -1
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +10 -2
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/number.d.ts +13 -0
- package/dist/tools/task/number.d.ts.map +1 -0
- package/dist/tools/task/number.js +30 -0
- package/dist/tools/task/number.js.map +1 -0
- package/dist/tools/task/present.d.ts.map +1 -1
- package/dist/tools/task/present.js +17 -3
- package/dist/tools/task/present.js.map +1 -1
- package/dist/tools/task/update.d.ts +2 -1
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +87 -20
- package/dist/tools/task/update.js.map +1 -1
- package/dist/types/acp/index.d.ts +10 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +4 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +9 -0
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +7 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +10 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/permission/index.d.ts +20 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +25 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +47 -3
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +4 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +8 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +16 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/model.d.ts +6 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +2 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +28 -2
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +15 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/node-on-path.d.ts +27 -0
- package/dist/utils/node-on-path.d.ts.map +1 -0
- package/dist/utils/node-on-path.js +70 -0
- package/dist/utils/node-on-path.js.map +1 -0
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +2 -0
- package/src/authorization/skill-grant.ts +1 -0
- package/src/bridge/acp/permission.ts +11 -1
- package/src/bridge/acp/server.ts +26 -0
- package/src/compaction/context-window.ts +18 -0
- package/src/compaction/loaded-skills.ts +42 -1
- package/src/compaction/manager.ts +28 -0
- package/src/compaction/manual.ts +9 -1
- package/src/compaction/model-summary.ts +2 -2
- package/src/compaction/restore.ts +69 -0
- package/src/compaction/salience/working-set.ts +6 -2
- package/src/compaction/tool-result-editing.ts +8 -1
- package/src/compaction/types.ts +2 -0
- package/src/compaction/wire.ts +4 -0
- package/src/connector/index.ts +27 -0
- package/src/connector/mcp/client.ts +71 -2
- package/src/connector/mcp/errors.ts +14 -0
- package/src/connector/mcp/index.ts +36 -0
- package/src/connector/mcp/skill-source.ts +499 -0
- package/src/connector/mcp/skills.ts +367 -0
- package/src/manager/session/turn-recorder.ts +24 -1
- package/src/network/audit.ts +2 -0
- package/src/network/computer.ts +347 -0
- package/src/network/index.ts +20 -0
- package/src/network/join.ts +21 -2
- package/src/network/roster.ts +5 -0
- package/src/network/service.ts +674 -84
- package/src/network/store.ts +57 -4
- package/src/network/transport.ts +1 -1
- package/src/network/wire.ts +18 -1
- package/src/plugin/shell-hook-tool-names.ts +1 -0
- package/src/plugin/shell-hook.ts +144 -7
- package/src/prompt/coding-agent-doctrine.ts +7 -2
- package/src/provider/fallback.ts +10 -0
- package/src/provider/idle-timeout.ts +9 -0
- package/src/provider/instrumentation.ts +12 -0
- package/src/provider/model-window-suffix.ts +2 -0
- package/src/provider/retry.ts +9 -0
- package/src/public-runtime.ts +100 -0
- package/src/public-tools.ts +18 -0
- package/src/public-types.ts +29 -0
- package/src/registry/tool/presentation.ts +14 -4
- package/src/runtime/jobs/registry.ts +2 -1
- package/src/runtime/query/auto-review/classifier.ts +19 -3
- package/src/runtime/query/auto-review/failure.ts +50 -0
- package/src/runtime/query/auto-review/index.ts +1 -0
- package/src/runtime/query/executor/tool-call-admission.ts +10 -1
- package/src/runtime/query/executor.ts +57 -8
- package/src/runtime/query/file-evidence-replay.ts +6 -5
- package/src/runtime/query/index.ts +62 -0
- package/src/runtime/query/iteration/index.ts +2 -0
- package/src/runtime/query/iteration/phases/compaction.ts +25 -2
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +24 -7
- package/src/runtime/query/iteration/step-shaping.ts +4 -0
- package/src/runtime/query/prepare-turn.ts +20 -2
- package/src/runtime/query/review-policy.ts +31 -5
- package/src/runtime/query/shell-line-escalation.ts +49 -0
- package/src/runtime/query/tooling.ts +6 -0
- package/src/runtime/query/turn/outcome-ledger.ts +56 -1
- package/src/sandbox/provider/local.ts +3 -1
- package/src/scheduler/local.ts +3 -1
- package/src/skills/index.ts +43 -0
- package/src/skills/inline-shell-host.ts +303 -0
- package/src/skills/inline-shell.ts +765 -0
- package/src/store/index.ts +8 -0
- package/src/store/task/file.ts +641 -0
- package/src/teams/backend.ts +29 -0
- package/src/teams/fs-sync.ts +91 -0
- package/src/teams/index.ts +47 -0
- package/src/teams/names.ts +49 -0
- package/src/teams/store.ts +607 -0
- package/src/teams/types.ts +102 -0
- package/src/tools/admit-facts.ts +26 -0
- package/src/tools/builtins/bash.ts +5 -2
- package/src/tools/builtins/browser.ts +1 -1
- package/src/tools/builtins/computer-use.ts +799 -86
- package/src/tools/builtins/content-fingerprint.ts +2 -1
- package/src/tools/builtins/edit-apply.ts +124 -24
- package/src/tools/builtins/edit-match.ts +200 -0
- package/src/tools/builtins/edit.ts +16 -7
- package/src/tools/builtins/exit-semantics.ts +23 -0
- package/src/tools/builtins/index.ts +3 -0
- package/src/tools/builtins/present-file.ts +127 -0
- package/src/tools/builtins/read-file.ts +1 -1
- package/src/tools/builtins/read-render.ts +18 -3
- package/src/tools/builtins/search-tools.ts +36 -2
- package/src/tools/builtins/skill.ts +291 -95
- package/src/tools/builtins/wait-for-job.ts +5 -0
- package/src/tools/builtins/web.ts +15 -2
- package/src/tools/task/create.ts +13 -4
- package/src/tools/task/get.ts +53 -0
- package/src/tools/task/index.ts +14 -2
- package/src/tools/task/list.ts +10 -2
- package/src/tools/task/number.ts +32 -0
- package/src/tools/task/present.ts +18 -3
- package/src/tools/task/update.ts +94 -20
- package/src/types/acp/index.ts +11 -1
- package/src/types/agent/base.ts +6 -0
- package/src/types/agent/scheduler.ts +9 -0
- package/src/types/computer-use/index.ts +7 -0
- package/src/types/connector/mcp.ts +10 -0
- package/src/types/permission/index.ts +29 -0
- package/src/types/plugin/index.ts +95 -39
- package/src/types/provider/chat.ts +9 -0
- package/src/types/provider/interface.ts +18 -0
- package/src/types/provider/model.ts +6 -0
- package/src/types/provider/stream.ts +2 -0
- package/src/types/tool/index.ts +23 -2
- package/src/types/tool/presentation.ts +14 -0
- package/src/utils/node-on-path.ts +81 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { constants, accessSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { posix, win32 } from 'node:path';
|
|
3
|
+
import { readEnvironmentEntry, setEnvironmentEntry } from './process-environment.js';
|
|
4
|
+
function defaultIsExecutable(file, platform) {
|
|
5
|
+
try {
|
|
6
|
+
if (!statSync(file).isFile())
|
|
7
|
+
return false;
|
|
8
|
+
if (platform !== 'win32')
|
|
9
|
+
accessSync(file, constants.X_OK);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The directory that would be appended to PATH so `node` resolves, or
|
|
18
|
+
* undefined when `node` already resolves (or cannot be offered).
|
|
19
|
+
*/
|
|
20
|
+
export function nodeDirectoryToAppend(pathValue, options = {}) {
|
|
21
|
+
const platform = options.platform ?? process.platform;
|
|
22
|
+
const path = platform === 'win32' ? win32 : posix;
|
|
23
|
+
const execPath = options.execPath ?? process.execPath;
|
|
24
|
+
const binary = path.basename(execPath).toLowerCase();
|
|
25
|
+
const wanted = platform === 'win32' ? ['node.exe', 'node.cmd'] : ['node'];
|
|
26
|
+
if (!wanted.includes(binary))
|
|
27
|
+
return undefined;
|
|
28
|
+
const entries = pathValue.split(path.delimiter);
|
|
29
|
+
const isExecutable = options.isExecutable ?? ((file) => defaultIsExecutable(file, platform));
|
|
30
|
+
for (const dir of entries) {
|
|
31
|
+
if (dir === '')
|
|
32
|
+
continue;
|
|
33
|
+
for (const file of wanted)
|
|
34
|
+
if (isExecutable(path.join(dir, file)))
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
let target;
|
|
38
|
+
try {
|
|
39
|
+
target = path.dirname((options.realpath ?? realpathSync)(execPath));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
target = path.dirname(execPath);
|
|
43
|
+
}
|
|
44
|
+
return entries.includes(target) ? undefined : target;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Make `node` resolvable in a shell command's environment.
|
|
48
|
+
*
|
|
49
|
+
* The runtime is often started by an absolute path whose directory is not on
|
|
50
|
+
* the user's PATH, so a command like `node --test` then fails with exit 127
|
|
51
|
+
* while the runtime itself is running on that very binary. When no `node`
|
|
52
|
+
* resolves on PATH, the directory of the running binary is appended to the END
|
|
53
|
+
* of PATH: a `node` the user has installed always wins. The environment is
|
|
54
|
+
* returned unchanged when `node` already resolves, when PATH is absent, or when
|
|
55
|
+
* the running binary is not a plain node binary (an embedded runtime).
|
|
56
|
+
*/
|
|
57
|
+
export function withNodeOnPath(env, options = {}) {
|
|
58
|
+
const platform = options.platform ?? process.platform;
|
|
59
|
+
const entry = readEnvironmentEntry(env, 'PATH', platform);
|
|
60
|
+
if (!entry)
|
|
61
|
+
return env;
|
|
62
|
+
const [name, value] = entry;
|
|
63
|
+
const target = nodeDirectoryToAppend(value, options);
|
|
64
|
+
if (target === undefined)
|
|
65
|
+
return env;
|
|
66
|
+
const separator = platform === 'win32' ? ';' : ':';
|
|
67
|
+
setEnvironmentEntry(env, name, value === '' ? target : `${value}${separator}${target}`, platform);
|
|
68
|
+
return env;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=node-on-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-on-path.js","sourceRoot":"","sources":["../../src/utils/node-on-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAYpF,SAAS,mBAAmB,CAAC,IAAY,EAAE,QAAyB;IACnE,IAAI,CAAC;QACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;YAAE,OAAO,KAAK,CAAA;QAC1C,IAAI,QAAQ,KAAK,OAAO;YAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAC1D,OAAO,IAAI,CAAA;IACZ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACpC,SAAiB,EACjB,UAA6B,EAAE;IAE/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAA;IACrD,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAA;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IACpD,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IAE9C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC/C,MAAM,YAAY,GACjB,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAChF,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,GAAG,KAAK,EAAE;YAAE,SAAQ;QACxB,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAA;IACpF,CAAC;IAED,IAAI,MAAc,CAAA;IAClB,IAAI,CAAC;QACJ,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;IACpE,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;IACD,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;AACrD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC7B,GAA2B,EAC3B,UAA6B,EAAE;IAE/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAA;IACrD,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG,CAAA;IACtB,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;IAC3B,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACpD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,CAAA;IACpC,MAAM,SAAS,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IAClD,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;IACjG,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namzu/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "69.1.0",
|
|
4
4
|
"description": "Open-source AI kernel for TypeScript: runs an agent the way an operating system runs a process, with an identity and a budget, scheduled tool calls and checkpointed turns.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"engines": {
|
package/src/agents/QueryAgent.ts
CHANGED
|
@@ -250,6 +250,8 @@ export class QueryAgent extends AbstractAgent<QueryAgentConfig, QueryAgentResult
|
|
|
250
250
|
messages: input.messages,
|
|
251
251
|
signal: input.signal,
|
|
252
252
|
taskStore: input.taskStore,
|
|
253
|
+
...(input.taskMember !== undefined ? { taskMember: input.taskMember } : {}),
|
|
254
|
+
...(input.taskTeam !== undefined ? { taskTeam: input.taskTeam } : {}),
|
|
253
255
|
runtimeToolOverrides: input.runtimeToolOverrides,
|
|
254
256
|
runtimeContext: input.runtimeContext,
|
|
255
257
|
},
|
|
@@ -15,6 +15,11 @@ import type {
|
|
|
15
15
|
*/
|
|
16
16
|
export interface AcpPermissionRequest {
|
|
17
17
|
readonly sessionId: string
|
|
18
|
+
/**
|
|
19
|
+
* Set when a teammate of the session's team is the one asking. The client shows the member's
|
|
20
|
+
* name with the question; the answer goes back to that teammate's call only.
|
|
21
|
+
*/
|
|
22
|
+
readonly teammate?: { readonly name: string; readonly team: string }
|
|
18
23
|
readonly toolCalls: readonly (ToolCallSummary & {
|
|
19
24
|
/** Rides to the client untouched; see {@link AcpFileChangePreview}. */
|
|
20
25
|
readonly preview?: AcpFileChangePreview
|
|
@@ -27,7 +32,12 @@ export interface AcpPermissionRequest {
|
|
|
27
32
|
*/
|
|
28
33
|
readonly alwaysAsk?: boolean
|
|
29
34
|
/** Rides to the client untouched; see `AcpRequestPermissionParams`. */
|
|
30
|
-
readonly computer?: {
|
|
35
|
+
readonly computer?: {
|
|
36
|
+
readonly app?: string
|
|
37
|
+
readonly consequence?: string
|
|
38
|
+
/** Browsers this call acts in that the engine will put its own question about. */
|
|
39
|
+
readonly browserAsk?: readonly string[]
|
|
40
|
+
}
|
|
31
41
|
})[]
|
|
32
42
|
}
|
|
33
43
|
|
package/src/bridge/acp/server.ts
CHANGED
|
@@ -319,6 +319,31 @@ export class ACPServer {
|
|
|
319
319
|
)
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Whether the client named `capability` when it initialized. False before `initialize`. A host
|
|
324
|
+
* that offers something only to a client that asked for it (an extension request it sends the
|
|
325
|
+
* client) reads this before relying on it.
|
|
326
|
+
*/
|
|
327
|
+
clientOffers(capability: string): boolean {
|
|
328
|
+
return this.initialized && this.clientCapabilities.includes(capability)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Ask the client something over the connection and wait for its answer. For a host extension that
|
|
333
|
+
* needs the client to do work (a request under `namzu/`), after `clientOffers` said it may.
|
|
334
|
+
* Rejects with the client's error message, and when the connection closes before it answers.
|
|
335
|
+
*/
|
|
336
|
+
askClient<T = unknown>(
|
|
337
|
+
method: string,
|
|
338
|
+
params: Record<string, unknown>,
|
|
339
|
+
signal?: AbortSignal,
|
|
340
|
+
): Promise<T> {
|
|
341
|
+
if (this.stopped) return Promise.reject(new Error('The ACP server is stopped.'))
|
|
342
|
+
if (!/^namzu\/[a-z][a-z0-9_/-]*$/.test(method))
|
|
343
|
+
return Promise.reject(new Error(`Invalid ACP client request name: ${method}`))
|
|
344
|
+
return this.request<T>(method, params, signal)
|
|
345
|
+
}
|
|
346
|
+
|
|
322
347
|
async start(): Promise<void> {
|
|
323
348
|
if (this.stopped) throw new Error('An ACP server cannot be restarted after it has stopped.')
|
|
324
349
|
this.options.transport.onMessage((message) => {
|
|
@@ -839,6 +864,7 @@ export class ACPServer {
|
|
|
839
864
|
// describe the tool batch, but it cannot relabel A's consent as B's.
|
|
840
865
|
sessionId,
|
|
841
866
|
toolCalls: request.toolCalls,
|
|
867
|
+
...(request.teammate ? { teammate: request.teammate } : {}),
|
|
842
868
|
},
|
|
843
869
|
signal,
|
|
844
870
|
)
|
|
@@ -253,6 +253,24 @@ function lookupBareContextWindow(model: string | undefined): number | undefined
|
|
|
253
253
|
return undefined
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/** The share of the window a provider's own compaction limit is held to. */
|
|
257
|
+
export const PROVIDER_COMPACT_LIMIT_MAX_FRACTION = 0.9
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The trigger fraction a provider's own compaction limit asks for: `min(limit, 90% of the
|
|
261
|
+
* window)` as a share of the window. `undefined` when the provider stated no usable limit or
|
|
262
|
+
* the window is unknown, which leaves Namzu's derived rule to answer.
|
|
263
|
+
*/
|
|
264
|
+
export function providerTriggerFraction(
|
|
265
|
+
limitTokens: number | undefined,
|
|
266
|
+
windowTokens: number,
|
|
267
|
+
): number | undefined {
|
|
268
|
+
if (limitTokens === undefined || !Number.isFinite(limitTokens) || limitTokens <= 0)
|
|
269
|
+
return undefined
|
|
270
|
+
if (!(windowTokens > 0)) return undefined
|
|
271
|
+
return Math.min(limitTokens, windowTokens * PROVIDER_COMPACT_LIMIT_MAX_FRACTION) / windowTokens
|
|
272
|
+
}
|
|
273
|
+
|
|
256
274
|
/** Output room the trigger keeps free: the model's output cap, at most this many tokens. */
|
|
257
275
|
export const TRIGGER_OUTPUT_RESERVE_CAP_TOKENS = 20_000
|
|
258
276
|
/** Extra headroom below the reserved window before a summary is due. */
|
|
@@ -195,6 +195,40 @@ function cutNote(name: string): string {
|
|
|
195
195
|
return `… [cut here to save space; call the skill tool with name "${name}" to read all of it]`
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
/**
|
|
199
|
+
* A skill's instructions without its worked examples. A section headed
|
|
200
|
+
* `Example...` (a sample report, a sample call) shows what a result looks like;
|
|
201
|
+
* the steps around it say what to do, and only those need to survive a pass.
|
|
202
|
+
* Returns the text unchanged when there is no such section.
|
|
203
|
+
*/
|
|
204
|
+
export function withoutExampleSections(body: string): { text: string; dropped: boolean } {
|
|
205
|
+
const lines = body.split('\n')
|
|
206
|
+
const kept: string[] = []
|
|
207
|
+
let skipping: number | undefined
|
|
208
|
+
let dropped = false
|
|
209
|
+
// A `# comment` inside a code fence is not a heading.
|
|
210
|
+
let fence: string | undefined
|
|
211
|
+
for (const line of lines) {
|
|
212
|
+
const fenceMark = /^\s*(`{3,}|~{3,})/.exec(line)
|
|
213
|
+
if (fenceMark) {
|
|
214
|
+
const mark = (fenceMark[1] as string)[0] as string
|
|
215
|
+
if (fence === undefined) fence = mark
|
|
216
|
+
else if (fence === mark) fence = undefined
|
|
217
|
+
}
|
|
218
|
+
const heading = fence === undefined && !fenceMark ? /^(#{1,6})\s+(.*)$/.exec(line) : null
|
|
219
|
+
if (heading) {
|
|
220
|
+
const level = (heading[1] as string).length
|
|
221
|
+
if (skipping !== undefined && level <= skipping) skipping = undefined
|
|
222
|
+
if (skipping === undefined && /^examples?\b/i.test((heading[2] as string).trim())) {
|
|
223
|
+
skipping = level
|
|
224
|
+
dropped = true
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (skipping === undefined) kept.push(line)
|
|
228
|
+
}
|
|
229
|
+
return dropped ? { text: kept.join('\n').trimEnd(), dropped } : { text: body, dropped }
|
|
230
|
+
}
|
|
231
|
+
|
|
198
232
|
/**
|
|
199
233
|
* Render skills (oldest first in, newest chosen first) inside the caps: a
|
|
200
234
|
* count, a share of the window and a total of tokens, and a cap for each
|
|
@@ -214,7 +248,14 @@ export function renderLoadedSkills(
|
|
|
214
248
|
const carried: string[] = []
|
|
215
249
|
const cut: string[] = []
|
|
216
250
|
const left: string[] = []
|
|
217
|
-
for (const
|
|
251
|
+
for (const full of [...skills].reverse()) {
|
|
252
|
+
const trimmed = withoutExampleSections(full.body)
|
|
253
|
+
const skill = trimmed.dropped
|
|
254
|
+
? {
|
|
255
|
+
name: full.name,
|
|
256
|
+
body: `${trimmed.text}\n\n[Example sections left out; call the skill tool with name "${full.name}" to read all of it]`,
|
|
257
|
+
}
|
|
258
|
+
: full
|
|
218
259
|
if (carried.length >= CARRY_MAX_SKILLS || budget < MIN_CARRY_TOKENS) {
|
|
219
260
|
left.push(skill.name)
|
|
220
261
|
continue
|
|
@@ -15,6 +15,10 @@ export const MAX_RESTORABLE_SKILLS = 8
|
|
|
15
15
|
export const MAX_RESTORABLE_FILES = 12
|
|
16
16
|
/** Characters of one skill or file kept for restoring (a little over the 5,000 tokens a restore shows, so the cut is visible). */
|
|
17
17
|
export const MAX_RESTORABLE_CHARS = 24_000
|
|
18
|
+
/** Working commands kept for a compaction to put back. */
|
|
19
|
+
export const MAX_WORKING_COMMANDS = 8
|
|
20
|
+
/** Characters kept of one working command. */
|
|
21
|
+
export const MAX_WORKING_COMMAND_CHARS = 240
|
|
18
22
|
|
|
19
23
|
/** Pins kept at most; the oldest is dropped past this, and the drop is counted. */
|
|
20
24
|
export const MAX_PINS = 40
|
|
@@ -158,6 +162,30 @@ export class WorkingStateManager {
|
|
|
158
162
|
while (restorable.files.length > MAX_RESTORABLE_FILES) restorable.files.shift()
|
|
159
163
|
}
|
|
160
164
|
|
|
165
|
+
/** Remember a command that worked (a test run, a build, a runtime call) so a compaction keeps its form. */
|
|
166
|
+
recordWorkingCommand(command: string): void {
|
|
167
|
+
const key = command.replace(/\s+/g, ' ').trim().slice(0, MAX_WORKING_COMMAND_CHARS)
|
|
168
|
+
if (key.length === 0) return
|
|
169
|
+
const restorable = this.restorableState()
|
|
170
|
+
const commands = restorable.commands ?? []
|
|
171
|
+
const index = commands.indexOf(key)
|
|
172
|
+
if (index >= 0) commands.splice(index, 1)
|
|
173
|
+
commands.push(key)
|
|
174
|
+
while (commands.length > MAX_WORKING_COMMANDS) commands.shift()
|
|
175
|
+
restorable.commands = commands
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Take in commands an earlier summary carried; they count as older than any recorded here. */
|
|
179
|
+
adoptWorkingCommands(commands: readonly string[]): void {
|
|
180
|
+
const held = this.state.restorable?.commands ?? []
|
|
181
|
+
const missing = commands.filter((command) => command.length > 0 && !held.includes(command))
|
|
182
|
+
if (missing.length === 0) return
|
|
183
|
+
const restorable = this.restorableState()
|
|
184
|
+
const next = [...missing, ...held]
|
|
185
|
+
while (next.length > MAX_WORKING_COMMANDS) next.shift()
|
|
186
|
+
restorable.commands = next
|
|
187
|
+
}
|
|
188
|
+
|
|
161
189
|
/** A file that was changed after it was read no longer has a body worth restoring. */
|
|
162
190
|
forgetFileText(path: string): void {
|
|
163
191
|
const files = this.state.restorable?.files
|
package/src/compaction/manual.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
summarizeWithModel,
|
|
31
31
|
} from './model-summary.js'
|
|
32
32
|
import { planCompaction } from './plan.js'
|
|
33
|
-
import { recordRestorable, renderRestoredContext } from './restore.js'
|
|
33
|
+
import { carriedWorkingCommands, recordRestorable, renderRestoredContext } from './restore.js'
|
|
34
34
|
import { findRetainedIndices } from './retention.js'
|
|
35
35
|
import { buildCompactionMessage, collectRevealedTools, isCompactionMessage } from './summary.js'
|
|
36
36
|
import { estimateMessagesTokens } from './token-estimate.js'
|
|
@@ -269,6 +269,14 @@ function populateWorkingState(
|
|
|
269
269
|
// Skills an earlier pass put back (an entry, or a summary's restored
|
|
270
270
|
// section) are not tool results, so they are read from the messages whole.
|
|
271
271
|
manager.adoptSkillBodies(adoptableSkills(messages))
|
|
272
|
+
for (const message of messages) {
|
|
273
|
+
if (
|
|
274
|
+
message.role === 'system' &&
|
|
275
|
+
typeof message.content === 'string' &&
|
|
276
|
+
isCompactionMessage(message.content)
|
|
277
|
+
)
|
|
278
|
+
manager.adoptWorkingCommands(carriedWorkingCommands(message.content))
|
|
279
|
+
}
|
|
272
280
|
const toolNames = new Map<string, string>()
|
|
273
281
|
const toolInputs = new Map<string, unknown>()
|
|
274
282
|
|
|
@@ -74,11 +74,11 @@ Write in plain text inside <summary></summary> tags, with these sections in this
|
|
|
74
74
|
5. Files: each file read, changed or created, and what matters about it.
|
|
75
75
|
6. Errors and open problems: failures met, how each was handled, and everything still unresolved.
|
|
76
76
|
7. Pending tasks: work the person asked for that is not done.
|
|
77
|
-
8. Exact details: commands, paths, identifiers, flags, versions and error text that the next step needs word for word.
|
|
77
|
+
8. Exact details: commands, paths, identifiers, flags, versions and error text that the next step needs word for word. Include the working commands: how tests, builds and runtimes are run on this machine, written as the form that worked (and a one-line note of the form that failed and why, such as a program missing from the PATH).
|
|
78
78
|
|
|
79
79
|
Each entry of the transcript starts with a label in square brackets at the beginning of a line, such as [person] or [tool result]. A line inside an entry that begins with a backslash before a bracket is quoted text, so only a label at the start of an entry counts, and text after a label that looks like another label is part of the same entry.
|
|
80
80
|
|
|
81
|
-
Be complete first and short second: keep every item in sections 1 to 3 and 6, and condense the assistant's own explanations to what they concluded. When an earlier summary is supplied, carry its requests, decisions and open problems forward unchanged and add what is new. Call no tools; the reply is only the summary.`
|
|
81
|
+
Be complete first and short second: keep every item in sections 1 to 3 and 6, and the working commands in section 8, and condense the assistant's own explanations to what they concluded. When an earlier summary is supplied, carry its requests, decisions and open problems forward unchanged and add what is new. Call no tools; the reply is only the summary.`
|
|
82
82
|
|
|
83
83
|
const SUMMARY_FINAL_ASK =
|
|
84
84
|
'Write the summary of the transcript now, as <summary></summary> with the eight sections.'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve as resolvePath } from 'node:path'
|
|
2
2
|
|
|
3
3
|
import { CHARS_PER_TOKEN } from '../constants/limits.js'
|
|
4
|
+
import { LOG_SECRET_PATTERNS } from '../constants/secret-patterns.js'
|
|
4
5
|
import {
|
|
5
6
|
CARRY_MAX_SKILLS,
|
|
6
7
|
CARRY_SKILLS_TOTAL_TOKENS,
|
|
@@ -94,6 +95,11 @@ export function recordRestorable(
|
|
|
94
95
|
)
|
|
95
96
|
return
|
|
96
97
|
}
|
|
98
|
+
if (call.toolName === 'bash') {
|
|
99
|
+
const command = typeof input.command === 'string' ? input.command : undefined
|
|
100
|
+
if (command && call.success && isRunnerCommand(command)) manager.recordWorkingCommand(command)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
97
103
|
if (call.toolName === 'read') {
|
|
98
104
|
const path = typeof input.path === 'string' ? input.path : undefined
|
|
99
105
|
if (!path || !call.success || call.unchanged) return
|
|
@@ -107,6 +113,62 @@ export function recordRestorable(
|
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
|
|
116
|
+
/** Heading of the section that carries the commands that worked. */
|
|
117
|
+
export const WORKING_COMMANDS_HEADING = '### Working commands'
|
|
118
|
+
|
|
119
|
+
/** The first word of a command segment says how code is run, built or tested here, or how a path is converted for a Windows program. */
|
|
120
|
+
const RUNNER_WORD =
|
|
121
|
+
/^(?:node(?:\.exe)?|npm|npx|pnpm|yarn|bun|deno|python3?|pytest|cargo|rustc|go|make|dotnet|mvn|gradle|wslpath|powershell\.exe|cmd\.exe)$/
|
|
122
|
+
|
|
123
|
+
/** Shapes that put a credential on a command line, beyond the known token prefixes. */
|
|
124
|
+
const COMMAND_SECRET_SHAPES: readonly RegExp[] = [
|
|
125
|
+
// An inline VAR=value assignment at the start of a segment.
|
|
126
|
+
/(?:^|[;&|(]\s*)[A-Za-z_][A-Za-z0-9_]*=/,
|
|
127
|
+
// Header, auth and credential flags.
|
|
128
|
+
/(?:^|\s)(?:-H|--header|-u|--user|--proxy-user)(?:\s|=|$)/,
|
|
129
|
+
/(?:^|\s)--?(?:[\w-]*(?:token|password|passwd|secret|api-?key|auth|credential)[\w-]*)(?:\s|=|$)/i,
|
|
130
|
+
/\b(?:authorization|bearer|x-api-key)\b/i,
|
|
131
|
+
// A URL with userinfo, or a token in its query string.
|
|
132
|
+
/:\/\/[^\s/:@]+:[^\s/@]+@/,
|
|
133
|
+
/[?&](?:[\w-]*(?:token|key|secret|password|sig|signature)[\w-]*)=/i,
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
/** True when a command line may carry a credential and so must not be kept. */
|
|
137
|
+
export function commandMayCarrySecret(command: string): boolean {
|
|
138
|
+
if (COMMAND_SECRET_SHAPES.some((shape) => shape.test(command))) return true
|
|
139
|
+
return LOG_SECRET_PATTERNS.some(([, pattern]) => {
|
|
140
|
+
pattern.lastIndex = 0
|
|
141
|
+
const hit = pattern.test(command)
|
|
142
|
+
pattern.lastIndex = 0
|
|
143
|
+
return hit
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** True for a shell command worth keeping the form of, and safe to carry in a summary. */
|
|
148
|
+
export function isRunnerCommand(command: string): boolean {
|
|
149
|
+
if (commandMayCarrySecret(command)) return false
|
|
150
|
+
return command.split(/&&|\|\||[;|\n]/).some((segment) => {
|
|
151
|
+
const first = segment.trim().replace(/^\(+/, '').split(/\s+/)[0] ?? ''
|
|
152
|
+
return RUNNER_WORD.test(first)
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The commands an earlier summary carried, read back from its restored section. */
|
|
157
|
+
export function carriedWorkingCommands(summary: string): string[] {
|
|
158
|
+
const start = summary.indexOf(WORKING_COMMANDS_HEADING)
|
|
159
|
+
if (start < 0) return []
|
|
160
|
+
const commands: string[] = []
|
|
161
|
+
for (const line of summary
|
|
162
|
+
.slice(start + WORKING_COMMANDS_HEADING.length)
|
|
163
|
+
.split('\n')
|
|
164
|
+
.slice(1)) {
|
|
165
|
+
const match = /^- `(.+)`$/.exec(line)
|
|
166
|
+
if (match?.[1]) commands.push(match[1])
|
|
167
|
+
else if (line.startsWith('#') || (commands.length > 0 && line.trim() === '')) break
|
|
168
|
+
}
|
|
169
|
+
return commands
|
|
170
|
+
}
|
|
171
|
+
|
|
110
172
|
function fit(text: string, tokens: number): string {
|
|
111
173
|
const room = tokens * CHARS_PER_TOKEN
|
|
112
174
|
return text.length <= room
|
|
@@ -160,6 +222,13 @@ export function renderRestoredContext(
|
|
|
160
222
|
sections.push(`### File: ${file.path}\n\n${text}`)
|
|
161
223
|
}
|
|
162
224
|
|
|
225
|
+
const commands = state.restorable?.commands ?? []
|
|
226
|
+
if (commands.length > 0) {
|
|
227
|
+
sections.push(
|
|
228
|
+
`${WORKING_COMMANDS_HEADING}\n\nThese commands ran successfully in this conversation. Run work the same way instead of searching the machine again.\n\n${commands.map((command) => `- \`${command}\``).join('\n')}`,
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
163
232
|
const note = options.hostNote?.trim()
|
|
164
233
|
if (note) sections.push(note)
|
|
165
234
|
if (sections.length === 0) return undefined
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
import { CHARS_PER_TOKEN } from '../../constants/limits.js'
|
|
23
23
|
import type { AssistantMessage, Message, ToolMessage } from '../../types/message/index.js'
|
|
24
24
|
import { estimateMessageTokens } from '../token-estimate.js'
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
ALWAYS_KEPT_TOOL_RESULTS,
|
|
27
|
+
clearToolResult,
|
|
28
|
+
isClearedToolResult,
|
|
29
|
+
} from '../tool-result-editing.js'
|
|
26
30
|
import type { ScoredMessage } from './score.js'
|
|
27
31
|
|
|
28
32
|
export interface WorkingSetAction {
|
|
@@ -95,7 +99,7 @@ function evictionRules(
|
|
|
95
99
|
return {
|
|
96
100
|
minTool: options.minToolResultChars ?? 1_000,
|
|
97
101
|
minNarration: options.minNarrationChars ?? 240,
|
|
98
|
-
preserve: new Set(options.preserveTools ?? []),
|
|
102
|
+
preserve: new Set([...ALWAYS_KEPT_TOOL_RESULTS, ...(options.preserveTools ?? [])]),
|
|
99
103
|
toolNameByCallId,
|
|
100
104
|
}
|
|
101
105
|
}
|
|
@@ -47,6 +47,13 @@ export interface ToolResultEditConfig {
|
|
|
47
47
|
export const DEFAULT_KEEP_RECENT_TOOL_RESULTS = 3
|
|
48
48
|
export const DEFAULT_MIN_CHARS_TO_CLEAR = 1_000
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Tools whose result is never cleared, whatever a host's own list says. A
|
|
52
|
+
* `search_tools` result is what tells the model which tools it has loaded;
|
|
53
|
+
* with it gone the model searches again for a tool it already holds.
|
|
54
|
+
*/
|
|
55
|
+
export const ALWAYS_KEPT_TOOL_RESULTS: readonly string[] = ['search_tools']
|
|
56
|
+
|
|
50
57
|
/** Marks a cleared result, and is how a second pass recognizes its own work. */
|
|
51
58
|
const CLEARED_PREFIX = '[tool output cleared]'
|
|
52
59
|
|
|
@@ -157,7 +164,7 @@ export function clearStaleToolResults(
|
|
|
157
164
|
): ToolResultEditOutcome {
|
|
158
165
|
const keepRecent = Math.max(0, config.keepRecentToolResults ?? DEFAULT_KEEP_RECENT_TOOL_RESULTS)
|
|
159
166
|
const minChars = Math.max(0, config.minCharsToClear ?? DEFAULT_MIN_CHARS_TO_CLEAR)
|
|
160
|
-
const preserve = new Set(config.preserveTools ?? [])
|
|
167
|
+
const preserve = new Set([...ALWAYS_KEPT_TOOL_RESULTS, ...(config.preserveTools ?? [])])
|
|
161
168
|
|
|
162
169
|
// Which tool call produced which result, so a preserve-list can be
|
|
163
170
|
// written in terms of TOOL NAMES — the only handle a host actually has.
|
package/src/compaction/types.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface RestorableFile {
|
|
|
53
53
|
export interface RestorableState {
|
|
54
54
|
skills: RestorableSkill[]
|
|
55
55
|
files: RestorableFile[]
|
|
56
|
+
/** Shell commands that ran successfully and say how work is run here, oldest first. */
|
|
57
|
+
commands?: string[]
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export interface PinSlot {
|
package/src/compaction/wire.ts
CHANGED
|
@@ -73,6 +73,7 @@ export function snapshotWorkingState(manager: WorkingStateManager): WorkingState
|
|
|
73
73
|
restorable: {
|
|
74
74
|
skills: state.restorable.skills.map((skill) => ({ ...skill })),
|
|
75
75
|
files: state.restorable.files.map((file) => ({ ...file })),
|
|
76
|
+
...(state.restorable.commands ? { commands: [...state.restorable.commands] } : {}),
|
|
76
77
|
},
|
|
77
78
|
}
|
|
78
79
|
: {}),
|
|
@@ -111,6 +112,9 @@ export function restoreWorkingState(
|
|
|
111
112
|
restorable: {
|
|
112
113
|
skills: snapshot.restorable.skills.map((skill) => ({ ...skill })),
|
|
113
114
|
files: snapshot.restorable.files.map((file) => ({ ...file })),
|
|
115
|
+
...(snapshot.restorable.commands
|
|
116
|
+
? { commands: [...snapshot.restorable.commands] }
|
|
117
|
+
: {}),
|
|
114
118
|
},
|
|
115
119
|
}
|
|
116
120
|
: {}),
|
package/src/connector/index.ts
CHANGED
|
@@ -56,6 +56,21 @@ export {
|
|
|
56
56
|
diffTools,
|
|
57
57
|
encodeMcpHeaderValue,
|
|
58
58
|
MCP_TASKS_EXTENSION,
|
|
59
|
+
MCP_SKILLS_EXTENSION,
|
|
60
|
+
MCP_SKILL_FILE,
|
|
61
|
+
MCP_SKILL_LIMITS,
|
|
62
|
+
MCP_SKILL_STRIPPED_KEYS,
|
|
63
|
+
McpSkillLoadError,
|
|
64
|
+
McpSkillSource,
|
|
65
|
+
admitMcpSkillEntries,
|
|
66
|
+
isMethodNotFoundError,
|
|
67
|
+
loadMcpSkillBody,
|
|
68
|
+
mcpSkillMetadata,
|
|
69
|
+
mcpSkillServerNameProblem,
|
|
70
|
+
mcpSkillStrippedKeys,
|
|
71
|
+
nameMcpSkills,
|
|
72
|
+
summarizeMcpSkillRefusals,
|
|
73
|
+
validateMcpSkillEntry,
|
|
59
74
|
hasDrift,
|
|
60
75
|
HttpSseTransport,
|
|
61
76
|
isHeaderMismatchError,
|
|
@@ -92,6 +107,18 @@ export {
|
|
|
92
107
|
zodToMCPJsonSchema,
|
|
93
108
|
} from './mcp/index.js'
|
|
94
109
|
export type {
|
|
110
|
+
McpListedSkill,
|
|
111
|
+
McpNamedSkill,
|
|
112
|
+
McpSkillAdmission,
|
|
113
|
+
McpSkillEntry,
|
|
114
|
+
McpSkillEntryVerdict,
|
|
115
|
+
McpSkillFile,
|
|
116
|
+
McpSkillLoadFailure,
|
|
117
|
+
McpSkillRefusal,
|
|
118
|
+
McpSkillSourceOptions,
|
|
119
|
+
McpSkillsClient,
|
|
120
|
+
McpSkillsRefresh,
|
|
121
|
+
McpSkillsRefreshStatus,
|
|
95
122
|
McpEnvelope,
|
|
96
123
|
McpEnvelopeInput,
|
|
97
124
|
McpEraProbe,
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
protocolErrorFromReply,
|
|
59
59
|
} from './errors.js'
|
|
60
60
|
import { HttpSseTransport } from './http-sse.js'
|
|
61
|
+
import { MCP_SKILLS_EXTENSION } from './skills.js'
|
|
61
62
|
import { StdioTransport } from './stdio.js'
|
|
62
63
|
import { MCPSubscriptionResponseError, StreamableHttpTransport } from './streamable-http.js'
|
|
63
64
|
import {
|
|
@@ -1146,8 +1147,34 @@ export class MCPClient {
|
|
|
1146
1147
|
*/
|
|
1147
1148
|
private clientCapabilities(): MCPClientCapabilities {
|
|
1148
1149
|
const base = this.config.capabilities ?? {}
|
|
1149
|
-
|
|
1150
|
-
|
|
1150
|
+
const tasks = this.declaresTasks()
|
|
1151
|
+
const skills = this.declaresSkills()
|
|
1152
|
+
if (!tasks && !skills) return base
|
|
1153
|
+
return {
|
|
1154
|
+
...base,
|
|
1155
|
+
extensions: {
|
|
1156
|
+
...base.extensions,
|
|
1157
|
+
...(tasks ? { [MCP_TASKS_EXTENSION]: {} } : {}),
|
|
1158
|
+
...(skills ? { [MCP_SKILLS_EXTENSION]: {} } : {}),
|
|
1159
|
+
},
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Does this connection take part in the skills extension?
|
|
1165
|
+
*
|
|
1166
|
+
* Only when the host asked for it ({@link MCPClientConfig.skills}, off by
|
|
1167
|
+
* default), on a 2026-07-28 connection, and when the server advertised
|
|
1168
|
+
* `io.modelcontextprotocol/skills` in `server/discover`. A legacy
|
|
1169
|
+
* connection never does: the extension is declared per request, and the
|
|
1170
|
+
* older handshake has no place to learn the server's side first.
|
|
1171
|
+
*/
|
|
1172
|
+
declaresSkills(): boolean {
|
|
1173
|
+
return (
|
|
1174
|
+
this.config.skills === true &&
|
|
1175
|
+
this.era?.kind === 'modern' &&
|
|
1176
|
+
this.serverCapabilities?.extensions?.[MCP_SKILLS_EXTENSION] !== undefined
|
|
1177
|
+
)
|
|
1151
1178
|
}
|
|
1152
1179
|
|
|
1153
1180
|
/**
|
|
@@ -1341,6 +1368,48 @@ export class MCPClient {
|
|
|
1341
1368
|
return await this.listAllPages('resources/list', 'resources', options)
|
|
1342
1369
|
}
|
|
1343
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* One page of the skills a server offers (`skills/list`).
|
|
1373
|
+
*
|
|
1374
|
+
* Resolves `undefined` without sending anything unless
|
|
1375
|
+
* {@link declaresSkills}. Answers are not cached: a skill listing is
|
|
1376
|
+
* re-read when the host asks, and a stale one would offer a skill the
|
|
1377
|
+
* server withdrew. A server that does not know the method rejects with
|
|
1378
|
+
* `MCPProtocolError` `-32601`; {@link isMethodNotFoundError} says so.
|
|
1379
|
+
* Entries are returned unchecked: `validateMcpSkillEntry` is the gate.
|
|
1380
|
+
*/
|
|
1381
|
+
async listSkillPage(
|
|
1382
|
+
cursor?: string,
|
|
1383
|
+
options?: MCPRequestOptions,
|
|
1384
|
+
): Promise<{ skills: unknown[]; nextCursor?: string } | undefined> {
|
|
1385
|
+
this.requireConnected()
|
|
1386
|
+
if (!this.declaresSkills()) return undefined
|
|
1387
|
+
const result = (await this.requestWithSessionRecovery(
|
|
1388
|
+
'skills/list',
|
|
1389
|
+
cursor === undefined ? {} : { cursor },
|
|
1390
|
+
options,
|
|
1391
|
+
)) as { skills?: unknown; nextCursor?: unknown } | null
|
|
1392
|
+
return {
|
|
1393
|
+
skills: Array.isArray(result?.skills) ? (result.skills as unknown[]) : [],
|
|
1394
|
+
...(typeof result?.nextCursor === 'string' && result.nextCursor.length > 0
|
|
1395
|
+
? { nextCursor: result.nextCursor }
|
|
1396
|
+
: {}),
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* One skill by address (`skills/get`), or `undefined` when the server has
|
|
1402
|
+
* none there or this connection does not take part in the extension.
|
|
1403
|
+
*/
|
|
1404
|
+
async getSkill(uri: string, options?: MCPRequestOptions): Promise<unknown | undefined> {
|
|
1405
|
+
this.requireConnected()
|
|
1406
|
+
if (!this.declaresSkills()) return undefined
|
|
1407
|
+
const result = (await this.requestWithSessionRecovery('skills/get', { uri }, options)) as {
|
|
1408
|
+
skill?: unknown
|
|
1409
|
+
} | null
|
|
1410
|
+
return result?.skill ?? undefined
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1344
1413
|
async readResource(uri: string, options?: MCPRequestOptions): Promise<MCPContentBlock[]> {
|
|
1345
1414
|
this.requireConnected()
|
|
1346
1415
|
const result = (await this.cachedRequest('resources/read', { uri }, options)) as {
|
|
@@ -114,6 +114,20 @@ export function isHeaderMismatchError(error: unknown): error is MCPProtocolError
|
|
|
114
114
|
return error instanceof MCPProtocolError && error.code === HEADER_MISMATCH_CODE
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* A server answered that it has no such method (`-32601`), as a JSON-RPC
|
|
119
|
+
* error or as the `404` with a `-32601` body a modern HTTP server uses.
|
|
120
|
+
* For a method an extension adds, this means "the server does not offer
|
|
121
|
+
* it", not a fault.
|
|
122
|
+
*/
|
|
123
|
+
export function isMethodNotFoundError(error: unknown): boolean {
|
|
124
|
+
if (error instanceof MCPProtocolError) return error.code === -32601
|
|
125
|
+
if (error instanceof MCPHttpStatusError) {
|
|
126
|
+
return error.status === 404 && /-32601/.test(error.bodyText)
|
|
127
|
+
}
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
130
|
+
|
|
117
131
|
/**
|
|
118
132
|
* A server answered that the resource, prompt or tool a request named does
|
|
119
133
|
* not exist — the current spec's `-32002`, or the older `-32602` a
|