@namzu/sdk 48.3.1 → 50.0.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 +542 -0
- package/README.md +137 -125
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +1 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/examples/SupervisorAgent.js +1 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +2 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +1 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +16 -1
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +8 -2
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js +1 -0
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +25 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +205 -21
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/bridge/acp/tasks.d.ts +5 -0
- package/dist/bridge/acp/tasks.d.ts.map +1 -0
- package/dist/bridge/acp/tasks.js +19 -0
- package/dist/bridge/acp/tasks.js.map +1 -0
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +148 -13
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/config/registry.d.ts +2 -0
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +23 -3
- package/dist/config/registry.js.map +1 -1
- package/dist/config/runtime.d.ts +31 -31
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +11 -4
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +6 -3
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/discovery.d.ts +9 -5
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +16 -8
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/mcp-toolset.d.ts +3 -0
- package/dist/connector/mcp/mcp-toolset.d.ts.map +1 -1
- package/dist/connector/mcp/mcp-toolset.js +20 -2
- package/dist/connector/mcp/mcp-toolset.js.map +1 -1
- package/dist/connector/mcp/reconnect.d.ts +2 -0
- package/dist/connector/mcp/reconnect.d.ts.map +1 -1
- package/dist/connector/mcp/reconnect.js +36 -5
- package/dist/connector/mcp/reconnect.js.map +1 -1
- package/dist/constants/acp/index.d.ts +3 -0
- package/dist/constants/acp/index.d.ts.map +1 -1
- package/dist/constants/acp/index.js +3 -0
- package/dist/constants/acp/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +80 -80
- package/dist/contracts/schemas.d.ts +2 -2
- package/dist/contracts/session/schemas.d.ts +10 -10
- package/dist/manager/agent/lifecycle.d.ts +11 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +178 -3
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/plan/lifecycle.d.ts +7 -8
- package/dist/manager/plan/lifecycle.d.ts.map +1 -1
- package/dist/manager/plan/lifecycle.js +7 -8
- package/dist/manager/plan/lifecycle.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +8 -8
- package/dist/manager/resident/learning-cycle.d.ts +2 -2
- package/dist/manager/resident/learning-observation.d.ts +12 -12
- package/dist/manager/resident/learning.d.ts +82 -82
- package/dist/manager/resident/outbox.d.ts +8 -8
- package/dist/manager/resident/proposal.d.ts +2 -2
- package/dist/manager/resident/store.d.ts +10 -10
- package/dist/manager/session/attribution.d.ts +1 -0
- package/dist/manager/session/attribution.d.ts.map +1 -1
- package/dist/manager/session/attribution.js +9 -1
- package/dist/manager/session/attribution.js.map +1 -1
- package/dist/manager/session/streamed-message-identity.d.ts +6 -0
- package/dist/manager/session/streamed-message-identity.d.ts.map +1 -0
- package/dist/manager/session/streamed-message-identity.js +14 -0
- package/dist/manager/session/streamed-message-identity.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +4 -3
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/pals/activity/causality.d.ts +23 -0
- package/dist/pals/activity/causality.d.ts.map +1 -0
- package/dist/pals/activity/causality.js +205 -0
- package/dist/pals/activity/causality.js.map +1 -0
- package/dist/pals/activity/projection.d.ts +5 -0
- package/dist/pals/activity/projection.d.ts.map +1 -0
- package/dist/pals/activity/projection.js +79 -0
- package/dist/pals/activity/projection.js.map +1 -0
- package/dist/pals/activity/source.d.ts +16 -0
- package/dist/pals/activity/source.d.ts.map +1 -0
- package/dist/pals/activity/source.js +235 -0
- package/dist/pals/activity/source.js.map +1 -0
- package/dist/pals/activity/subscription-policy.d.ts +38 -0
- package/dist/pals/activity/subscription-policy.d.ts.map +1 -0
- package/dist/pals/activity/subscription-policy.js +183 -0
- package/dist/pals/activity/subscription-policy.js.map +1 -0
- package/dist/pals/activity/subscription-schema.d.ts +353 -0
- package/dist/pals/activity/subscription-schema.d.ts.map +1 -0
- package/dist/pals/activity/subscription-schema.js +24 -0
- package/dist/pals/activity/subscription-schema.js.map +1 -0
- package/dist/pals/activity/subscription-store.d.ts +25 -0
- package/dist/pals/activity/subscription-store.d.ts.map +1 -0
- package/dist/pals/activity/subscription-store.js +152 -0
- package/dist/pals/activity/subscription-store.js.map +1 -0
- package/dist/pals/activity/subscription-types.d.ts +42 -0
- package/dist/pals/activity/subscription-types.d.ts.map +1 -0
- package/dist/pals/activity/subscription-types.js +2 -0
- package/dist/pals/activity/subscription-types.js.map +1 -0
- package/dist/pals/activity/subscriptions.d.ts +32 -0
- package/dist/pals/activity/subscriptions.d.ts.map +1 -0
- package/dist/pals/activity/subscriptions.js +151 -0
- package/dist/pals/activity/subscriptions.js.map +1 -0
- package/dist/pals/activity/types.d.ts +77 -0
- package/dist/pals/activity/types.d.ts.map +1 -0
- package/dist/pals/activity/types.js +2 -0
- package/dist/pals/activity/types.js.map +1 -0
- package/dist/pals/channels/ingress.d.ts +9 -0
- package/dist/pals/channels/ingress.d.ts.map +1 -0
- package/dist/pals/channels/ingress.js +131 -0
- package/dist/pals/channels/ingress.js.map +1 -0
- package/dist/pals/channels/routes.d.ts +20 -0
- package/dist/pals/channels/routes.d.ts.map +1 -0
- package/dist/pals/channels/routes.js +111 -0
- package/dist/pals/channels/routes.js.map +1 -0
- package/dist/pals/channels/routing.d.ts +37 -0
- package/dist/pals/channels/routing.d.ts.map +1 -0
- package/dist/pals/channels/routing.js +150 -0
- package/dist/pals/channels/routing.js.map +1 -0
- package/dist/pals/channels/schema.d.ts +234 -0
- package/dist/pals/channels/schema.d.ts.map +1 -0
- package/dist/pals/channels/schema.js +94 -0
- package/dist/pals/channels/schema.js.map +1 -0
- package/dist/pals/channels/types.d.ts +115 -0
- package/dist/pals/channels/types.d.ts.map +1 -0
- package/dist/pals/channels/types.js +2 -0
- package/dist/pals/channels/types.js.map +1 -0
- package/dist/pals/communication/broker.d.ts +8 -0
- package/dist/pals/communication/broker.d.ts.map +1 -0
- package/dist/pals/communication/broker.js +121 -0
- package/dist/pals/communication/broker.js.map +1 -0
- package/dist/pals/communication/dispatch.d.ts +4 -0
- package/dist/pals/communication/dispatch.d.ts.map +1 -0
- package/dist/pals/communication/dispatch.js +57 -0
- package/dist/pals/communication/dispatch.js.map +1 -0
- package/dist/pals/communication/inbound.d.ts +9 -0
- package/dist/pals/communication/inbound.d.ts.map +1 -0
- package/dist/pals/communication/inbound.js +155 -0
- package/dist/pals/communication/inbound.js.map +1 -0
- package/dist/pals/communication/ingress-dispatch.d.ts +5 -0
- package/dist/pals/communication/ingress-dispatch.d.ts.map +1 -0
- package/dist/pals/communication/ingress-dispatch.js +51 -0
- package/dist/pals/communication/ingress-dispatch.js.map +1 -0
- package/dist/pals/communication/ingress-inbound.d.ts +9 -0
- package/dist/pals/communication/ingress-inbound.d.ts.map +1 -0
- package/dist/pals/communication/ingress-inbound.js +222 -0
- package/dist/pals/communication/ingress-inbound.js.map +1 -0
- package/dist/pals/communication/ingress-schema.d.ts +7829 -0
- package/dist/pals/communication/ingress-schema.d.ts.map +1 -0
- package/dist/pals/communication/ingress-schema.js +479 -0
- package/dist/pals/communication/ingress-schema.js.map +1 -0
- package/dist/pals/communication/ingress-types.d.ts +187 -0
- package/dist/pals/communication/ingress-types.d.ts.map +1 -0
- package/dist/pals/communication/ingress-types.js +73 -0
- package/dist/pals/communication/ingress-types.js.map +1 -0
- package/dist/pals/communication/operator.d.ts +75 -0
- package/dist/pals/communication/operator.d.ts.map +1 -0
- package/dist/pals/communication/operator.js +217 -0
- package/dist/pals/communication/operator.js.map +1 -0
- package/dist/pals/communication/policy.d.ts +41 -0
- package/dist/pals/communication/policy.d.ts.map +1 -0
- package/dist/pals/communication/policy.js +138 -0
- package/dist/pals/communication/policy.js.map +1 -0
- package/dist/pals/communication/schema.d.ts +2000 -0
- package/dist/pals/communication/schema.d.ts.map +1 -0
- package/dist/pals/communication/schema.js +170 -0
- package/dist/pals/communication/schema.js.map +1 -0
- package/dist/pals/communication/store.d.ts +61 -0
- package/dist/pals/communication/store.d.ts.map +1 -0
- package/dist/pals/communication/store.js +450 -0
- package/dist/pals/communication/store.js.map +1 -0
- package/dist/pals/communication/tools.d.ts +23 -0
- package/dist/pals/communication/tools.d.ts.map +1 -0
- package/dist/pals/communication/tools.js +107 -0
- package/dist/pals/communication/tools.js.map +1 -0
- package/dist/pals/communication/types.d.ts +168 -0
- package/dist/pals/communication/types.d.ts.map +1 -0
- package/dist/pals/communication/types.js +24 -0
- package/dist/pals/communication/types.js.map +1 -0
- package/dist/pals/communication/verify.d.ts +22 -0
- package/dist/pals/communication/verify.d.ts.map +1 -0
- package/dist/pals/communication/verify.js +142 -0
- package/dist/pals/communication/verify.js.map +1 -0
- package/dist/pals/lifecycle.d.ts +37 -0
- package/dist/pals/lifecycle.d.ts.map +1 -0
- package/dist/pals/lifecycle.js +22 -0
- package/dist/pals/lifecycle.js.map +1 -0
- package/dist/pals/prompt.d.ts +30 -0
- package/dist/pals/prompt.d.ts.map +1 -0
- package/dist/pals/prompt.js +65 -0
- package/dist/pals/prompt.js.map +1 -0
- package/dist/pals/reference-images.d.ts +44 -0
- package/dist/pals/reference-images.d.ts.map +1 -0
- package/dist/pals/reference-images.js +248 -0
- package/dist/pals/reference-images.js.map +1 -0
- package/dist/pals/runtime.d.ts +46 -0
- package/dist/pals/runtime.d.ts.map +1 -0
- package/dist/pals/runtime.js +624 -0
- package/dist/pals/runtime.js.map +1 -0
- package/dist/pals/store.d.ts +26 -0
- package/dist/pals/store.d.ts.map +1 -0
- package/dist/pals/store.js +334 -0
- package/dist/pals/store.js.map +1 -0
- package/dist/pals/types.d.ts +145 -0
- package/dist/pals/types.d.ts.map +1 -0
- package/dist/pals/types.js +2 -0
- package/dist/pals/types.js.map +1 -0
- package/dist/peers/envelope.js +1 -1
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/protocol.d.ts +83 -83
- package/dist/peers/record.d.ts +10 -10
- package/dist/plugin/lifecycle.d.ts +14 -10
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +178 -41
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +7 -2
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +9 -1
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/prompt/resident-learning.js +2 -2
- package/dist/prompt/resident-learning.js.map +1 -1
- package/dist/prompt/resident-step.d.ts +2 -2
- package/dist/prompt/resident-step.js +4 -4
- package/dist/prompt/resident-step.js.map +1 -1
- package/dist/provider/errors.d.ts +19 -0
- package/dist/provider/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +123 -2
- package/dist/provider/errors.js.map +1 -1
- package/dist/public-runtime.d.ts +43 -15
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +37 -9
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +8 -3
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +8 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +27 -7
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/presentation.d.ts +1 -0
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +9 -7
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/registry/tool/screen.d.ts.map +1 -1
- package/dist/registry/tool/screen.js +33 -2
- package/dist/registry/tool/screen.js.map +1 -1
- package/dist/runtime/harness-session/index.d.ts +5 -0
- package/dist/runtime/harness-session/index.d.ts.map +1 -0
- package/dist/runtime/harness-session/index.js +928 -0
- package/dist/runtime/harness-session/index.js.map +1 -0
- package/dist/runtime/harness-session/journal.d.ts +37 -0
- package/dist/runtime/harness-session/journal.d.ts.map +1 -0
- package/dist/runtime/harness-session/journal.js +177 -0
- package/dist/runtime/harness-session/journal.js.map +1 -0
- package/dist/runtime/harness-session/saved-view.d.ts +8 -0
- package/dist/runtime/harness-session/saved-view.d.ts.map +1 -0
- package/dist/runtime/harness-session/saved-view.js +112 -0
- package/dist/runtime/harness-session/saved-view.js.map +1 -0
- package/dist/runtime/jobs/awaited-jobs.d.ts +2 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.js +2 -1
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +56 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +377 -39
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/abandon-turn.d.ts +12 -1
- package/dist/runtime/query/abandon-turn.d.ts.map +1 -1
- package/dist/runtime/query/abandon-turn.js +3 -1
- package/dist/runtime/query/abandon-turn.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts +4 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +10 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/durable-inbound.d.ts +5 -0
- package/dist/runtime/query/durable-inbound.d.ts.map +1 -0
- package/dist/runtime/query/durable-inbound.js +89 -0
- package/dist/runtime/query/durable-inbound.js.map +1 -0
- package/dist/runtime/query/events.d.ts +4 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +22 -5
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +5 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +85 -13
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +41 -18
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +227 -114
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +41 -5
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +18 -6
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +176 -75
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts +9 -5
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +63 -6
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +8 -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/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +106 -17
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts +2 -0
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +5 -1
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/observation-context.d.ts +2 -2
- package/dist/runtime/query/observation-context.d.ts.map +1 -1
- package/dist/runtime/query/observation-context.js +20 -13
- package/dist/runtime/query/observation-context.js.map +1 -1
- package/dist/runtime/query/prepare-turn.js +2 -2
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/prompt-cache.d.ts +1 -0
- package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
- package/dist/runtime/query/prompt-cache.js +2 -0
- package/dist/runtime/query/prompt-cache.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts +2 -0
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +23 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/repeat-call.d.ts +12 -3
- package/dist/runtime/query/repeat-call.d.ts.map +1 -1
- package/dist/runtime/query/repeat-call.js +33 -10
- package/dist/runtime/query/repeat-call.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +5 -6
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +30 -3
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/resume-session.js +1 -1
- package/dist/runtime/query/resume-session.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +8 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +6 -0
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/saved-presentation.d.ts +13 -0
- package/dist/runtime/query/saved-presentation.d.ts.map +1 -0
- package/dist/runtime/query/saved-presentation.js +63 -0
- package/dist/runtime/query/saved-presentation.js.map +1 -0
- package/dist/runtime/query/steering.d.ts +6 -9
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/tool-executions.d.ts +7 -3
- package/dist/runtime/query/tool-executions.d.ts.map +1 -1
- package/dist/runtime/query/tool-executions.js +89 -9
- package/dist/runtime/query/tool-executions.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +3 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +25 -1
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +102 -8
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +5 -0
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -0
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/summary/materialize.d.ts +10 -6
- package/dist/session/summary/materialize.d.ts.map +1 -1
- package/dist/session/summary/materialize.js +41 -8
- package/dist/session/summary/materialize.js.map +1 -1
- package/dist/store/budget/ledger.d.ts +9 -0
- package/dist/store/budget/ledger.d.ts.map +1 -1
- package/dist/store/budget/ledger.js +58 -6
- package/dist/store/budget/ledger.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +12 -12
- package/dist/store/evidence/source-text.d.ts +4 -4
- package/dist/store/index.d.ts +1 -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/memory/disk.d.ts +7 -2
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +58 -5
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/index.d.ts +9 -0
- package/dist/store/memory/index.d.ts.map +1 -1
- package/dist/store/memory/index.js +43 -5
- package/dist/store/memory/index.js.map +1 -1
- package/dist/store/memory/markdown.d.ts +7 -2
- package/dist/store/memory/markdown.d.ts.map +1 -1
- package/dist/store/memory/markdown.js +33 -0
- package/dist/store/memory/markdown.js.map +1 -1
- package/dist/store/memory/memory.d.ts +7 -2
- package/dist/store/memory/memory.d.ts.map +1 -1
- package/dist/store/memory/memory.js +34 -0
- package/dist/store/memory/memory.js.map +1 -1
- package/dist/store/memory/revision.d.ts +16 -0
- package/dist/store/memory/revision.d.ts.map +1 -0
- package/dist/store/memory/revision.js +144 -0
- package/dist/store/memory/revision.js.map +1 -0
- package/dist/store/session/disk.d.ts +9 -4
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +57 -11
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/memory.d.ts +5 -3
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +24 -7
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/session-log/core.d.ts +26 -6
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +61 -8
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/store/session-log/disk.d.ts +2 -2
- package/dist/store/session-log/disk.d.ts.map +1 -1
- package/dist/store/session-log/disk.js +1 -0
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/fold.d.ts +7 -0
- package/dist/store/session-log/fold.d.ts.map +1 -1
- package/dist/store/session-log/fold.js +21 -0
- package/dist/store/session-log/fold.js.map +1 -1
- package/dist/store/session-log/index.d.ts +5 -3
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +3 -1
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/store/session-log/memory.d.ts +1 -1
- package/dist/store/session-log/memory.d.ts.map +1 -1
- package/dist/store/session-log/memory.js +1 -0
- package/dist/store/session-log/memory.js.map +1 -1
- package/dist/store/session-log/spill.d.ts +10 -3
- package/dist/store/session-log/spill.d.ts.map +1 -1
- package/dist/store/session-log/spill.js +70 -5
- package/dist/store/session-log/spill.js.map +1 -1
- package/dist/store/session-log/structured-result.d.ts +21 -0
- package/dist/store/session-log/structured-result.d.ts.map +1 -0
- package/dist/store/session-log/structured-result.js +67 -0
- package/dist/store/session-log/structured-result.js.map +1 -0
- package/dist/store/task/disk.d.ts +11 -0
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +41 -2
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/task/memory.d.ts.map +1 -1
- package/dist/store/task/memory.js +15 -3
- package/dist/store/task/memory.js.map +1 -1
- package/dist/tools/admit-facts.d.ts +13 -0
- package/dist/tools/admit-facts.d.ts.map +1 -0
- package/dist/tools/admit-facts.js +142 -0
- package/dist/tools/admit-facts.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +4 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +108 -22
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.d.ts +10 -10
- package/dist/tools/builtins/computer-use.d.ts +90 -90
- package/dist/tools/builtins/edit.d.ts +17 -0
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +34 -0
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +13 -0
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +12 -0
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +14 -0
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +2 -0
- 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/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/lsp.d.ts +2 -2
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +49 -0
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/view-image.d.ts +24 -0
- package/dist/tools/builtins/view-image.d.ts.map +1 -0
- package/dist/tools/builtins/view-image.js +385 -0
- package/dist/tools/builtins/view-image.js.map +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts +8 -4
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.js +43 -8
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts +3 -0
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +127 -15
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +1 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +37 -2
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +100 -3
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +9 -19
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +127 -67
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts +2 -0
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.js +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/failure-facts.d.ts +8 -0
- package/dist/tools/failure-facts.d.ts.map +1 -0
- package/dist/tools/failure-facts.js +24 -0
- package/dist/tools/failure-facts.js.map +1 -0
- package/dist/tools/host-output.d.ts +24 -0
- package/dist/tools/host-output.d.ts.map +1 -0
- package/dist/tools/host-output.js +117 -0
- package/dist/tools/host-output.js.map +1 -0
- package/dist/tools/memory/delete.d.ts.map +1 -1
- package/dist/tools/memory/delete.js +38 -3
- package/dist/tools/memory/delete.js.map +1 -1
- package/dist/tools/memory/read.d.ts.map +1 -1
- package/dist/tools/memory/read.js +38 -2
- package/dist/tools/memory/read.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +38 -7
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts.map +1 -1
- package/dist/tools/memory/update.js +30 -3
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/oem-code-pages.d.ts +8 -0
- package/dist/tools/oem-code-pages.d.ts.map +1 -0
- package/dist/tools/oem-code-pages.js +23 -0
- package/dist/tools/oem-code-pages.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +35 -6
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +23 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +14 -6
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/present.d.ts.map +1 -1
- package/dist/tools/task/present.js +26 -6
- package/dist/tools/task/present.js.map +1 -1
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +12 -5
- package/dist/tools/task/update.js.map +1 -1
- package/dist/tools/text-window.d.ts +19 -0
- package/dist/tools/text-window.d.ts.map +1 -0
- package/dist/tools/text-window.js +83 -0
- package/dist/tools/text-window.js.map +1 -0
- package/dist/toolsets/manager.d.ts +24 -0
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +105 -2
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/memory-recall.d.ts +2 -0
- package/dist/turn/memory-recall.d.ts.map +1 -1
- package/dist/turn/memory-recall.js +3 -1
- package/dist/turn/memory-recall.js.map +1 -1
- package/dist/types/acp/index.d.ts +137 -1
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +3 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +8 -23
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +10 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +4 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +30 -30
- package/dist/types/connector/mcp.d.ts +7 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/catalog.d.ts.map +1 -1
- package/dist/types/errors/catalog.js +4 -2
- package/dist/types/errors/catalog.js.map +1 -1
- package/dist/types/harness/schema.d.ts +354 -0
- package/dist/types/harness/schema.d.ts.map +1 -0
- package/dist/types/harness/schema.js +203 -0
- package/dist/types/harness/schema.js.map +1 -0
- package/dist/types/harness/session.d.ts +278 -0
- package/dist/types/harness/session.d.ts.map +1 -0
- package/dist/types/harness/session.js +2 -0
- package/dist/types/harness/session.js.map +1 -0
- package/dist/types/hitl/index.d.ts +12 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/job/index.d.ts +47 -0
- package/dist/types/job/index.d.ts.map +1 -0
- package/dist/types/job/index.js +2 -0
- package/dist/types/job/index.js.map +1 -0
- package/dist/types/memory/index.d.ts +29 -0
- package/dist/types/memory/index.d.ts.map +1 -1
- package/dist/types/memory/index.js +6 -0
- package/dist/types/memory/index.js.map +1 -1
- package/dist/types/message/inbound-delivery.d.ts +44 -0
- package/dist/types/message/inbound-delivery.d.ts.map +1 -0
- package/dist/types/message/inbound-delivery.js +14 -0
- package/dist/types/message/inbound-delivery.js.map +1 -0
- package/dist/types/message/index.d.ts +4 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +5 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +18 -8
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +5 -2
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +39 -2
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/checkpoint.d.ts +24 -17
- package/dist/types/session/checkpoint.d.ts.map +1 -1
- package/dist/types/session/checkpoint.js +1 -0
- package/dist/types/session/checkpoint.js.map +1 -1
- package/dist/types/session/events.d.ts +23 -1
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +1514 -565
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +89 -1
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/step.d.ts +2 -0
- package/dist/types/session/step.d.ts.map +1 -1
- package/dist/types/session/step.js.map +1 -1
- package/dist/types/session/store.d.ts +19 -10
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/session/tool-execution.d.ts +6 -0
- package/dist/types/session/tool-execution.d.ts.map +1 -1
- package/dist/types/structured-output/index.d.ts +12 -2
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/summary/ref.d.ts +3 -1
- package/dist/types/summary/ref.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +32 -4
- 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 +106 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/json-snapshot.d.ts +6 -2
- package/dist/utils/json-snapshot.d.ts.map +1 -1
- package/dist/utils/json-snapshot.js +19 -9
- package/dist/utils/json-snapshot.js.map +1 -1
- package/dist/utils/structured-result-json.d.ts +5 -0
- package/dist/utils/structured-result-json.d.ts.map +1 -0
- package/dist/utils/structured-result-json.js +10 -0
- package/dist/utils/structured-result-json.js.map +1 -0
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +1 -0
- package/src/agents/examples/SupervisorAgent.ts +1 -0
- package/src/agents/runAgent.ts +3 -0
- package/src/authorization/shell-lexer.ts +16 -1
- package/src/bridge/acp/permission.ts +17 -3
- package/src/bridge/acp/server.ts +271 -25
- package/src/bridge/acp/tasks.ts +23 -0
- package/src/bridge/acp/update.ts +167 -13
- package/src/config/registry.ts +24 -3
- package/src/connector/mcp/adapter.ts +16 -4
- package/src/connector/mcp/client.ts +6 -2
- package/src/connector/mcp/discovery.ts +29 -8
- package/src/connector/mcp/mcp-toolset.ts +25 -4
- package/src/connector/mcp/reconnect.ts +34 -4
- package/src/constants/acp/index.ts +4 -0
- package/src/manager/agent/lifecycle.ts +230 -3
- package/src/manager/plan/lifecycle.ts +11 -9
- package/src/manager/session/attribution.ts +12 -2
- package/src/manager/session/streamed-message-identity.ts +21 -0
- package/src/manager/session/turn-recorder.ts +4 -3
- package/src/pals/activity/causality.ts +261 -0
- package/src/pals/activity/projection.ts +89 -0
- package/src/pals/activity/source.ts +240 -0
- package/src/pals/activity/subscription-policy.ts +230 -0
- package/src/pals/activity/subscription-schema.ts +27 -0
- package/src/pals/activity/subscription-store.ts +172 -0
- package/src/pals/activity/subscription-types.ts +48 -0
- package/src/pals/activity/subscriptions.ts +209 -0
- package/src/pals/activity/types.ts +108 -0
- package/src/pals/channels/ingress.ts +153 -0
- package/src/pals/channels/routes.ts +118 -0
- package/src/pals/channels/routing.ts +197 -0
- package/src/pals/channels/schema.ts +108 -0
- package/src/pals/channels/types.ts +156 -0
- package/src/pals/communication/broker.ts +131 -0
- package/src/pals/communication/dispatch.ts +66 -0
- package/src/pals/communication/inbound.ts +193 -0
- package/src/pals/communication/ingress-dispatch.ts +63 -0
- package/src/pals/communication/ingress-inbound.ts +269 -0
- package/src/pals/communication/ingress-schema.ts +526 -0
- package/src/pals/communication/ingress-types.ts +336 -0
- package/src/pals/communication/operator.ts +315 -0
- package/src/pals/communication/policy.ts +174 -0
- package/src/pals/communication/schema.ts +173 -0
- package/src/pals/communication/store.ts +577 -0
- package/src/pals/communication/tools.ts +139 -0
- package/src/pals/communication/types.ts +227 -0
- package/src/pals/communication/verify.ts +220 -0
- package/src/pals/lifecycle.ts +54 -0
- package/src/pals/prompt.ts +101 -0
- package/src/pals/reference-images.ts +322 -0
- package/src/pals/runtime.ts +670 -0
- package/src/pals/store.ts +369 -0
- package/src/pals/types.ts +157 -0
- package/src/peers/envelope.ts +1 -1
- package/src/plugin/lifecycle.ts +217 -46
- package/src/plugin/shell-hook.ts +8 -2
- package/src/process/kill-tree.ts +10 -1
- package/src/prompt/resident-learning.ts +2 -2
- package/src/prompt/resident-step.ts +4 -4
- package/src/provider/errors.ts +135 -2
- package/src/public-runtime.ts +119 -12
- package/src/public-tools.ts +13 -1
- package/src/public-types.ts +69 -7
- package/src/registry/tool/presentation.ts +9 -4
- package/src/registry/tool/screen.ts +34 -2
- package/src/runtime/harness-session/index.ts +1125 -0
- package/src/runtime/harness-session/journal.ts +209 -0
- package/src/runtime/harness-session/saved-view.ts +122 -0
- package/src/runtime/jobs/awaited-jobs.ts +2 -1
- package/src/runtime/jobs/registry.ts +423 -50
- package/src/runtime/query/abandon-turn.ts +18 -2
- package/src/runtime/query/checkpoint.ts +11 -0
- package/src/runtime/query/durable-inbound.ts +101 -0
- package/src/runtime/query/events.ts +22 -5
- package/src/runtime/query/executor/tool-call-admission.ts +125 -32
- package/src/runtime/query/executor.ts +316 -130
- package/src/runtime/query/index.ts +48 -5
- package/src/runtime/query/iteration/index.ts +253 -114
- package/src/runtime/query/iteration/outstanding-work.ts +57 -7
- package/src/runtime/query/iteration/phases/context.ts +8 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +124 -22
- package/src/runtime/query/iteration/step-shaping.ts +9 -1
- package/src/runtime/query/observation-context.ts +22 -16
- package/src/runtime/query/prepare-turn.ts +2 -2
- package/src/runtime/query/prompt-cache.ts +3 -0
- package/src/runtime/query/prompt.ts +32 -1
- package/src/runtime/query/repeat-call.ts +40 -10
- package/src/runtime/query/resume-pending.ts +60 -7
- package/src/runtime/query/resume-session.ts +1 -1
- package/src/runtime/query/review-policy.ts +23 -2
- package/src/runtime/query/saved-presentation.ts +70 -0
- package/src/runtime/query/steering.ts +6 -9
- package/src/runtime/query/tool-executions.ts +108 -9
- package/src/runtime/query/tooling.ts +6 -1
- package/src/scheduler/completion-inbox.ts +108 -7
- package/src/scheduler/delegating.ts +5 -0
- package/src/scheduler/local.ts +2 -0
- package/src/session/summary/materialize.ts +51 -9
- package/src/store/budget/ledger.ts +60 -5
- package/src/store/index.ts +1 -0
- package/src/store/memory/disk.ts +82 -7
- package/src/store/memory/index.ts +66 -7
- package/src/store/memory/markdown.ts +54 -2
- package/src/store/memory/memory.ts +52 -2
- package/src/store/memory/revision.ts +158 -0
- package/src/store/session/disk.ts +77 -10
- package/src/store/session/memory.ts +32 -7
- package/src/store/session-log/core.ts +118 -11
- package/src/store/session-log/disk.ts +9 -2
- package/src/store/session-log/fold.ts +22 -0
- package/src/store/session-log/index.ts +5 -0
- package/src/store/session-log/memory.ts +2 -1
- package/src/store/session-log/spill.ts +89 -6
- package/src/store/session-log/structured-result.ts +96 -0
- package/src/store/task/disk.ts +46 -2
- package/src/store/task/memory.ts +13 -3
- package/src/tools/admit-facts.ts +145 -0
- package/src/tools/builtins/bash.ts +132 -24
- package/src/tools/builtins/edit.ts +42 -0
- package/src/tools/builtins/file-write-result.ts +14 -0
- package/src/tools/builtins/glob.ts +12 -0
- package/src/tools/builtins/grep.ts +14 -0
- package/src/tools/builtins/index.ts +2 -0
- package/src/tools/builtins/job.ts +4 -1
- package/src/tools/builtins/read-file.ts +57 -0
- package/src/tools/builtins/view-image.ts +409 -0
- package/src/tools/builtins/wait-for-job-bounds.ts +45 -7
- package/src/tools/builtins/wait-for-job.ts +159 -36
- package/src/tools/builtins/write-file.ts +4 -2
- package/src/tools/command-shell.ts +132 -5
- package/src/tools/coordinator/agent.ts +9 -19
- package/src/tools/coordinator/index.ts +150 -75
- package/src/tools/coordinator/wait-with-idle-bound.ts +3 -1
- package/src/tools/defineTool.ts +4 -0
- package/src/tools/failure-facts.ts +24 -0
- package/src/tools/host-output.ts +136 -0
- package/src/tools/memory/delete.ts +33 -3
- package/src/tools/memory/read.ts +35 -2
- package/src/tools/memory/search.ts +38 -7
- package/src/tools/memory/update.ts +28 -3
- package/src/tools/oem-code-pages.ts +22 -0
- package/src/tools/schedules/schedule-tool.ts +38 -5
- package/src/tools/schedules/types.ts +23 -3
- package/src/tools/task/list.ts +15 -7
- package/src/tools/task/present.ts +37 -7
- package/src/tools/task/update.ts +12 -5
- package/src/tools/text-window.ts +87 -0
- package/src/toolsets/manager.ts +132 -2
- package/src/turn/memory-recall.ts +5 -1
- package/src/types/acp/index.ts +150 -4
- package/src/types/agent/base.ts +3 -0
- package/src/types/agent/manager.ts +8 -23
- package/src/types/agent/scheduler.ts +10 -1
- package/src/types/agent/task.ts +4 -0
- package/src/types/connector/mcp.ts +7 -0
- package/src/types/errors/catalog.ts +4 -2
- package/src/types/harness/schema.ts +203 -0
- package/src/types/harness/session.ts +306 -0
- package/src/types/hitl/index.ts +17 -1
- package/src/types/job/index.ts +42 -0
- package/src/types/memory/index.ts +43 -0
- package/src/types/message/inbound-delivery.ts +63 -0
- package/src/types/message/index.ts +8 -1
- package/src/types/plugin/index.ts +11 -6
- package/src/types/sandbox/index.ts +46 -0
- package/src/types/session/checkpoint.ts +4 -1
- package/src/types/session/events.ts +23 -1
- package/src/types/session/records.ts +114 -2
- package/src/types/session/step.ts +2 -0
- package/src/types/session/store.ts +23 -9
- package/src/types/session/tool-execution.ts +6 -0
- package/src/types/structured-output/index.ts +13 -2
- package/src/types/summary/ref.ts +3 -1
- package/src/types/tool/index.ts +39 -5
- package/src/types/tool/presentation.ts +121 -0
- package/src/utils/json-snapshot.ts +26 -9
- package/src/utils/structured-result-json.ts +10 -0
|
@@ -3,7 +3,8 @@ import type { PlanManager } from '../../manager/plan/lifecycle.js'
|
|
|
3
3
|
import type { PendingAnswers, QuestionParkRecorder } from '../../runtime/query/question-park.js'
|
|
4
4
|
import type { CompletionInbox } from '../../scheduler/completion-inbox.js'
|
|
5
5
|
import type { AgentRuntimeContext } from '../../types/agent/base.js'
|
|
6
|
-
import type { TaskScheduler } from '../../types/agent/scheduler.js'
|
|
6
|
+
import type { TaskHandle, TaskScheduler } from '../../types/agent/scheduler.js'
|
|
7
|
+
import { isTerminalAgentTaskState } from '../../types/agent/task.js'
|
|
7
8
|
import type { ResumeHandler } from '../../types/hitl/index.js'
|
|
8
9
|
import type { SessionId, TaskId, TurnId } from '../../types/ids/index.js'
|
|
9
10
|
import type { TaskStore } from '../../types/task/index.js'
|
|
@@ -402,6 +403,29 @@ function delegatedAnswer(
|
|
|
402
403
|
return result?.result
|
|
403
404
|
}
|
|
404
405
|
|
|
406
|
+
/** Keep an empty answer from hiding the worker's error on any result path. */
|
|
407
|
+
function delegatedResultText(completed: Pick<TaskHandle, 'state' | 'result'>): {
|
|
408
|
+
resultText: string
|
|
409
|
+
outputText: string
|
|
410
|
+
} {
|
|
411
|
+
const success = taskSucceeded(completed)
|
|
412
|
+
const answer = delegatedAnswer(completed.result)
|
|
413
|
+
const lastError = completed.result?.lastError
|
|
414
|
+
const outcomeText = `Task finished with outcome: ${failureLabel(completed)}`
|
|
415
|
+
const resultText =
|
|
416
|
+
(answer?.trim() ? answer : lastError) ||
|
|
417
|
+
(success ? `Task finished with state: ${completed.state}` : outcomeText)
|
|
418
|
+
const outputText =
|
|
419
|
+
success || resultText === outcomeText
|
|
420
|
+
? resultText
|
|
421
|
+
: [
|
|
422
|
+
outcomeText,
|
|
423
|
+
...(lastError && lastError !== resultText ? [`Error: ${lastError}`] : []),
|
|
424
|
+
resultText,
|
|
425
|
+
].join('\n')
|
|
426
|
+
return { resultText, outputText }
|
|
427
|
+
}
|
|
428
|
+
|
|
405
429
|
export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefinition[] {
|
|
406
430
|
const {
|
|
407
431
|
gateway,
|
|
@@ -451,6 +475,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
451
475
|
* here. That is the same rule, not an exception to it.
|
|
452
476
|
*/
|
|
453
477
|
const launchedHere = new Set<TaskId>()
|
|
478
|
+
const trackedCompletions = new Map<TaskId, Promise<TaskHandle>>()
|
|
454
479
|
void opts.onTaskLaunched
|
|
455
480
|
|
|
456
481
|
const agentIdEnum = delegateSchema(agentIds)
|
|
@@ -573,10 +598,12 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
573
598
|
// could report `failed` or stay `executing` forever but never
|
|
574
599
|
// `completed`.
|
|
575
600
|
const planStepId = plan_step_id
|
|
576
|
-
const
|
|
601
|
+
const planManager = planStepId ? getPlanManager?.() : undefined
|
|
602
|
+
const planId = planManager?.active?.id
|
|
577
603
|
const reportStep = (status: 'running' | 'completed' | 'failed', error?: string): void => {
|
|
578
|
-
|
|
579
|
-
|
|
604
|
+
// A replacement plan may reuse step ids; it is not this worker's plan.
|
|
605
|
+
if (!planStepId || !planId || planManager?.active?.id !== planId) return
|
|
606
|
+
planManager.updateStepStatus(planStepId, status, error)
|
|
580
607
|
}
|
|
581
608
|
reportStep('running')
|
|
582
609
|
|
|
@@ -599,49 +626,6 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
599
626
|
}
|
|
600
627
|
}
|
|
601
628
|
|
|
602
|
-
const handle = await gateway.createTask({
|
|
603
|
-
agentId: agent_id,
|
|
604
|
-
prompt,
|
|
605
|
-
workingDirectory: cwd,
|
|
606
|
-
runtimeContext: opts.runtimeContext,
|
|
607
|
-
...(planStepId ? { planStepId } : {}),
|
|
608
|
-
...(planId ? { planId } : {}),
|
|
609
|
-
// Hang the child session off THIS tool's span, so the delegation
|
|
610
|
-
// shows up inside the turn that asked for it.
|
|
611
|
-
...(_context.parentSpan ? { parentSpan: _context.parentSpan } : {}),
|
|
612
|
-
// Same as the `Agent` tool: a delegate inherits the environment
|
|
613
|
-
// its parent was given, or it runs against different services
|
|
614
|
-
// than the turn that asked for the work — and the turn's screens,
|
|
615
|
-
// for the same reason: the child's executor installs the shipped
|
|
616
|
-
// default unless the spawn says otherwise, so a parent that
|
|
617
|
-
// turned them off had that decision revert behind every
|
|
618
|
-
// delegation. One merged `configOverrides`, because a second
|
|
619
|
-
// spread of the key would replace this one.
|
|
620
|
-
...(Object.keys(_context.env ?? {}).length > 0 || _context.toolResultGuardrails
|
|
621
|
-
? {
|
|
622
|
-
configOverrides: {
|
|
623
|
-
...(_context.env && Object.keys(_context.env).length > 0
|
|
624
|
-
? { env: _context.env }
|
|
625
|
-
: {}),
|
|
626
|
-
...(_context.toolResultGuardrails
|
|
627
|
-
? { toolResultGuardrails: _context.toolResultGuardrails }
|
|
628
|
-
: {}),
|
|
629
|
-
},
|
|
630
|
-
}
|
|
631
|
-
: {}),
|
|
632
|
-
})
|
|
633
|
-
|
|
634
|
-
// Whose task this is. The inbox ignores completions for anything it
|
|
635
|
-
// was not told about, because `onTaskCompleted` is a broadcast and a
|
|
636
|
-
// gateway shared between two supervisors would otherwise hand each
|
|
637
|
-
// of them the other's worker output. Said on BOTH paths: the
|
|
638
|
-
// blocking one needs it too, because the case the inbox exists for
|
|
639
|
-
// is exactly the blocking launch whose wait was abandoned.
|
|
640
|
-
completionInbox?.launched(handle.taskId)
|
|
641
|
-
|
|
642
|
-
// ...and whose it is for the READ side too. See `launchedHere`.
|
|
643
|
-
launchedHere.add(handle.taskId)
|
|
644
|
-
|
|
645
629
|
// A background launch asked for with nowhere to deliver it is
|
|
646
630
|
// REFUSED, not quietly turned into a blocking one.
|
|
647
631
|
//
|
|
@@ -677,6 +661,111 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
677
661
|
}
|
|
678
662
|
}
|
|
679
663
|
|
|
664
|
+
let handle: TaskHandle
|
|
665
|
+
try {
|
|
666
|
+
handle = await gateway.createTask({
|
|
667
|
+
agentId: agent_id,
|
|
668
|
+
prompt,
|
|
669
|
+
workingDirectory: cwd,
|
|
670
|
+
runtimeContext: opts.runtimeContext,
|
|
671
|
+
...(planStepId ? { planStepId } : {}),
|
|
672
|
+
...(planId ? { planId } : {}),
|
|
673
|
+
// Hang the child session off THIS tool's span, so the delegation
|
|
674
|
+
// shows up inside the turn that asked for it.
|
|
675
|
+
...(_context.parentSpan ? { parentSpan: _context.parentSpan } : {}),
|
|
676
|
+
// Same as the `Agent` tool: a delegate inherits the environment
|
|
677
|
+
// its parent was given, or it runs against different services
|
|
678
|
+
// than the turn that asked for the work — and the turn's screens,
|
|
679
|
+
// for the same reason: the child's executor installs the shipped
|
|
680
|
+
// default unless the spawn says otherwise, so a parent that
|
|
681
|
+
// turned them off had that decision revert behind every
|
|
682
|
+
// delegation. One merged `configOverrides`, because a second
|
|
683
|
+
// spread of the key would replace this one.
|
|
684
|
+
...(Object.keys(_context.env ?? {}).length > 0 || _context.toolResultGuardrails
|
|
685
|
+
? {
|
|
686
|
+
configOverrides: {
|
|
687
|
+
...(_context.env && Object.keys(_context.env).length > 0
|
|
688
|
+
? { env: _context.env }
|
|
689
|
+
: {}),
|
|
690
|
+
...(_context.toolResultGuardrails
|
|
691
|
+
? { toolResultGuardrails: _context.toolResultGuardrails }
|
|
692
|
+
: {}),
|
|
693
|
+
},
|
|
694
|
+
}
|
|
695
|
+
: {}),
|
|
696
|
+
})
|
|
697
|
+
} catch (launchError) {
|
|
698
|
+
// No handle means admission failed from this caller's perspective.
|
|
699
|
+
// A host scheduler may have dispatched before losing its response;
|
|
700
|
+
// neither a missing worker nor a safe retry is established here.
|
|
701
|
+
const failure = `Delegation admission failed: ${toErrorMessage(launchError)}. No task handle was returned; the worker dispatch outcome is not established.`
|
|
702
|
+
reportStep('failed', failure)
|
|
703
|
+
if (resolvedPlanTaskId && taskStore) {
|
|
704
|
+
try {
|
|
705
|
+
const updated = await taskStore.update(asTaskId(resolvedPlanTaskId), {
|
|
706
|
+
status: 'failed',
|
|
707
|
+
description: failure,
|
|
708
|
+
})
|
|
709
|
+
if (!updated)
|
|
710
|
+
throw new Error(
|
|
711
|
+
`Planning task ${resolvedPlanTaskId} disappeared during failed admission`,
|
|
712
|
+
)
|
|
713
|
+
} catch (trackingError) {
|
|
714
|
+
throw new AggregateError(
|
|
715
|
+
[launchError, trackingError],
|
|
716
|
+
`${failure} Planning settlement failed: ${toErrorMessage(trackingError)}`,
|
|
717
|
+
{ cause: launchError },
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
throw launchError
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// Whose task this is. The inbox ignores completions for anything it
|
|
725
|
+
// was not told about, because `onTaskCompleted` is a broadcast and a
|
|
726
|
+
// gateway shared between two supervisors would otherwise hand each
|
|
727
|
+
// of them the other's worker output. Said on BOTH paths: the
|
|
728
|
+
// blocking one needs it too, because the case the inbox exists for
|
|
729
|
+
// is exactly the blocking launch whose wait was abandoned.
|
|
730
|
+
completionInbox?.launched(handle.taskId)
|
|
731
|
+
|
|
732
|
+
// ...and whose it is for the READ side too. See `launchedHere`.
|
|
733
|
+
launchedHere.add(handle.taskId)
|
|
734
|
+
|
|
735
|
+
// Own one completion for both delivery paths. Neither a background
|
|
736
|
+
// return nor an abandoned bounded wait discards these tracking writes.
|
|
737
|
+
if ((resolvedPlanTaskId && taskStore) || (planStepId && planId)) {
|
|
738
|
+
// A fast worker may already be terminal and forgotten by the gateway.
|
|
739
|
+
// The returned handle is the exact outcome; do not fetch it again.
|
|
740
|
+
const workerCompletion = isTerminalAgentTaskState(handle.state)
|
|
741
|
+
? Promise.resolve(handle)
|
|
742
|
+
: gateway.waitForTask(handle.taskId)
|
|
743
|
+
const completion = workerCompletion.then(async (completed) => {
|
|
744
|
+
const success = taskSucceeded(completed)
|
|
745
|
+
const { outputText } = delegatedResultText(completed)
|
|
746
|
+
if (resolvedPlanTaskId && taskStore) {
|
|
747
|
+
const updated = await taskStore.update(asTaskId(resolvedPlanTaskId), {
|
|
748
|
+
status: success ? 'completed' : 'failed',
|
|
749
|
+
description: success ? undefined : `Failed: ${outputText.substring(0, 200)}`,
|
|
750
|
+
})
|
|
751
|
+
if (!updated)
|
|
752
|
+
throw new Error(
|
|
753
|
+
`Planning task ${resolvedPlanTaskId} disappeared before worker settlement`,
|
|
754
|
+
)
|
|
755
|
+
}
|
|
756
|
+
reportStep(
|
|
757
|
+
success ? 'completed' : 'failed',
|
|
758
|
+
success ? undefined : outputText.slice(0, 200),
|
|
759
|
+
)
|
|
760
|
+
return completed
|
|
761
|
+
})
|
|
762
|
+
trackedCompletions.set(handle.taskId, completion)
|
|
763
|
+
completionInbox?.deferDelivery(
|
|
764
|
+
handle.taskId,
|
|
765
|
+
completion.then(() => {}),
|
|
766
|
+
)
|
|
767
|
+
}
|
|
768
|
+
|
|
680
769
|
if (background) {
|
|
681
770
|
// Tell the inbox to hold the turn open for this. Without it the
|
|
682
771
|
// supervisor could launch a worker, answer, and settle the turn
|
|
@@ -716,6 +805,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
716
805
|
const outcome = await waitForTaskWithBounds(gateway, handle.taskId, {
|
|
717
806
|
wallMs: DELEGATION_TIMEOUT_MS,
|
|
718
807
|
idleMs: DELEGATION_IDLE_MS,
|
|
808
|
+
completion: trackedCompletions.get(handle.taskId),
|
|
719
809
|
})
|
|
720
810
|
if (outcome.kind === 'timeout') {
|
|
721
811
|
return {
|
|
@@ -752,27 +842,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
752
842
|
// `isError: false`, while writing the plan task closed as though
|
|
753
843
|
// the work had been done.
|
|
754
844
|
const success = taskSucceeded(completed)
|
|
755
|
-
const resultText =
|
|
756
|
-
delegatedAnswer(completed.result) ??
|
|
757
|
-
completed.result?.lastError ??
|
|
758
|
-
`Task finished with state: ${failureLabel(completed)}`
|
|
759
|
-
|
|
760
|
-
if (resolvedPlanTaskId && taskStore) {
|
|
761
|
-
// The status carries the outcome now, rather than `completed`
|
|
762
|
-
// with the failure written into prose. A reader scanning
|
|
763
|
-
// statuses saw work that had been done; only a reader of every
|
|
764
|
-
// description saw otherwise — and a dependent unit had no way
|
|
765
|
-
// to tell at all.
|
|
766
|
-
await taskStore.update(asTaskId(resolvedPlanTaskId), {
|
|
767
|
-
status: success ? 'completed' : 'failed',
|
|
768
|
-
description: success ? undefined : `Failed: ${resultText.substring(0, 200)}`,
|
|
769
|
-
})
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// The step reports the same outcome, from the same two authorities.
|
|
773
|
-
// This is the only point in a delegated launch where the answer is
|
|
774
|
-
// actually known.
|
|
775
|
-
reportStep(success ? 'completed' : 'failed', success ? undefined : resultText.slice(0, 200))
|
|
845
|
+
const { resultText, outputText } = delegatedResultText(completed)
|
|
776
846
|
|
|
777
847
|
return {
|
|
778
848
|
success,
|
|
@@ -797,7 +867,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
797
867
|
attributes: { agent: agent_id, task: handle.taskId },
|
|
798
868
|
provenance: `This is the output of the delegated agent "${agent_id}", not this agent's own work.`,
|
|
799
869
|
},
|
|
800
|
-
|
|
870
|
+
outputText,
|
|
801
871
|
),
|
|
802
872
|
data: {
|
|
803
873
|
task_id: handle.taskId,
|
|
@@ -870,6 +940,7 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
870
940
|
const outcome = await waitForTaskWithBounds(gateway, taskId, {
|
|
871
941
|
wallMs: DELEGATION_TIMEOUT_MS,
|
|
872
942
|
idleMs: DELEGATION_IDLE_MS,
|
|
943
|
+
completion: trackedCompletions.get(taskId),
|
|
873
944
|
})
|
|
874
945
|
if (outcome.kind === 'timeout') {
|
|
875
946
|
return {
|
|
@@ -888,11 +959,11 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
888
959
|
}
|
|
889
960
|
completionInbox?.claim(taskId)
|
|
890
961
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
962
|
+
// Finishing the invocation does not prove the worker succeeded. Use
|
|
963
|
+
// the same two-authority check as the call that launched this task.
|
|
964
|
+
const success = taskSucceeded(completed)
|
|
965
|
+
const lastError = completed.result?.lastError
|
|
966
|
+
const { resultText, outputText } = delegatedResultText(completed)
|
|
896
967
|
return {
|
|
897
968
|
success,
|
|
898
969
|
output: wrapUntrusted(
|
|
@@ -901,12 +972,16 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
901
972
|
attributes: { agent: completed.agentId, task: completed.taskId },
|
|
902
973
|
provenance: `This is the output of the delegated agent "${completed.agentId}", not this agent's own work.`,
|
|
903
974
|
},
|
|
904
|
-
|
|
975
|
+
outputText,
|
|
905
976
|
),
|
|
906
977
|
data: {
|
|
907
978
|
task_id,
|
|
908
979
|
agent_id: completed.agentId,
|
|
909
980
|
state: completed.state,
|
|
981
|
+
...(completed.result?.status === undefined
|
|
982
|
+
? {}
|
|
983
|
+
: { turn_status: completed.result.status }),
|
|
984
|
+
...(lastError === undefined || lastError === null ? {} : { last_error: lastError }),
|
|
910
985
|
result: resultText,
|
|
911
986
|
},
|
|
912
987
|
}
|
|
@@ -47,6 +47,8 @@ export interface WaitBounds {
|
|
|
47
47
|
* Omit to bound by the turn clock alone.
|
|
48
48
|
*/
|
|
49
49
|
readonly idleMs?: number
|
|
50
|
+
/** Reuse the launch's completion, including its tracking settlement. */
|
|
51
|
+
readonly completion?: Promise<TaskHandle>
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -77,7 +79,7 @@ export async function waitForTaskWithBounds(
|
|
|
77
79
|
const idleBoundArmed = detach !== undefined && bounds.idleMs !== undefined
|
|
78
80
|
|
|
79
81
|
try {
|
|
80
|
-
const completion = gateway.waitForTask(taskId).then(
|
|
82
|
+
const completion = (bounds.completion ?? gateway.waitForTask(taskId)).then(
|
|
81
83
|
(handle): WaitOutcome => ({ kind: 'completed', handle }),
|
|
82
84
|
// A gateway that rejects has answered the question; let it through
|
|
83
85
|
// rather than reporting a timeout that did not happen.
|
package/src/tools/defineTool.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
} from '../types/tool/index.js'
|
|
8
8
|
import type { ToolPresentation } from '../types/tool/presentation.js'
|
|
9
9
|
import { toErrorMessage } from '../utils/error.js'
|
|
10
|
+
import { failureFactsFromError } from './failure-facts.js'
|
|
10
11
|
|
|
11
12
|
export interface DefineToolOptions<S extends z.ZodType> {
|
|
12
13
|
name: string
|
|
@@ -183,10 +184,13 @@ export function defineTool<S extends z.ZodType>(
|
|
|
183
184
|
return await options.execute(input, context)
|
|
184
185
|
} catch (err) {
|
|
185
186
|
const message = toErrorMessage(err)
|
|
187
|
+
const facts = failureFactsFromError(err)
|
|
186
188
|
return {
|
|
187
189
|
success: false,
|
|
188
190
|
output: '',
|
|
189
191
|
error: `${options.name} failed: ${message}`,
|
|
192
|
+
// The kind of failure, from the error's own code, for the person's view.
|
|
193
|
+
...(facts ? { facts } : {}),
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ToolFacts } from '../types/tool/presentation.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The kind of failure a thrown filesystem error is, as typed facts for the
|
|
5
|
+
* person's view. Read from the error's `code` and `path`, which Node sets
|
|
6
|
+
* structurally, and never from its message.
|
|
7
|
+
*/
|
|
8
|
+
export function failureFactsFromError(err: unknown): ToolFacts | undefined {
|
|
9
|
+
if (!err || typeof err !== 'object') return undefined
|
|
10
|
+
const { code, path } = err as { code?: unknown; path?: unknown }
|
|
11
|
+
const subject = typeof path === 'string' ? path : undefined
|
|
12
|
+
const reason =
|
|
13
|
+
code === 'ENOENT'
|
|
14
|
+
? 'not_found'
|
|
15
|
+
: code === 'EACCES' || code === 'EPERM'
|
|
16
|
+
? 'permission_denied'
|
|
17
|
+
: code === 'EISDIR' || code === 'ENOTDIR'
|
|
18
|
+
? 'not_a_file'
|
|
19
|
+
: code === 'EEXIST'
|
|
20
|
+
? 'already_exists'
|
|
21
|
+
: undefined
|
|
22
|
+
if (!reason) return undefined
|
|
23
|
+
return { kind: 'failure', reason, ...(subject ? { subject } : {}) }
|
|
24
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { StringDecoder } from 'node:string_decoder'
|
|
3
|
+
|
|
4
|
+
import { OEM_UPPER_HALF } from './oem-code-pages.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Decodes the bytes a host command writes.
|
|
8
|
+
*
|
|
9
|
+
* Off Windows that is UTF-8. On Windows, cmd and console programs write the
|
|
10
|
+
* console's OEM code page (850 on Western installs, 857 on Turkish ones), not
|
|
11
|
+
* UTF-8, so a strict UTF-8 decode turns `ç` into U+FFFD. PowerShell and Node
|
|
12
|
+
* children do write UTF-8. So a stream starts as strict UTF-8 and falls back
|
|
13
|
+
* to the code page for good the first time it holds bytes that are not UTF-8.
|
|
14
|
+
*/
|
|
15
|
+
export interface HostOutputDecoder {
|
|
16
|
+
write(chunk: Buffer): string
|
|
17
|
+
end(): string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HostOutputDecoderOptions {
|
|
21
|
+
readonly platform?: NodeJS.Platform
|
|
22
|
+
/** Windows only: the OEM code page. Default: probed once with `chcp`. */
|
|
23
|
+
readonly codePage?: number | undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let probedCodePage: number | null | undefined
|
|
27
|
+
|
|
28
|
+
/** The console's active code page on Windows, probed once; null when unknown. */
|
|
29
|
+
export function probeOemCodePage(): number | null {
|
|
30
|
+
if (probedCodePage !== undefined) return probedCodePage
|
|
31
|
+
try {
|
|
32
|
+
const out = execFileSync('cmd.exe', ['/d', '/s', '/c', 'chcp'], {
|
|
33
|
+
encoding: 'latin1',
|
|
34
|
+
windowsHide: true,
|
|
35
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
36
|
+
timeout: 5000,
|
|
37
|
+
})
|
|
38
|
+
const match = /(\d{3,5})\s*$/.exec(out.trim())
|
|
39
|
+
probedCodePage = match ? Number(match[1]) : null
|
|
40
|
+
} catch {
|
|
41
|
+
probedCodePage = null
|
|
42
|
+
}
|
|
43
|
+
return probedCodePage
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A decoder for one non-UTF-8 console code page, or undefined when none is known. */
|
|
47
|
+
function legacyDecoder(codePage: number | undefined): HostOutputDecoder | undefined {
|
|
48
|
+
if (codePage === undefined || codePage === 65001) return undefined
|
|
49
|
+
const table = OEM_UPPER_HALF[codePage]
|
|
50
|
+
if (table !== undefined) {
|
|
51
|
+
// Single-byte: no state between chunks.
|
|
52
|
+
return {
|
|
53
|
+
write(chunk) {
|
|
54
|
+
let text = ''
|
|
55
|
+
for (const byte of chunk)
|
|
56
|
+
text += byte < 0x80 ? String.fromCharCode(byte) : table[byte - 0x80]
|
|
57
|
+
return text
|
|
58
|
+
},
|
|
59
|
+
end: () => '',
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// The WHATWG labels Node knows: Windows ANSI pages and IBM866.
|
|
63
|
+
const label =
|
|
64
|
+
codePage >= 1250 && codePage <= 1258
|
|
65
|
+
? `windows-${codePage}`
|
|
66
|
+
: codePage === 866
|
|
67
|
+
? 'ibm866'
|
|
68
|
+
: undefined
|
|
69
|
+
if (label === undefined) return undefined
|
|
70
|
+
try {
|
|
71
|
+
const decoder = new TextDecoder(label)
|
|
72
|
+
return {
|
|
73
|
+
write: (chunk) => decoder.decode(chunk, { stream: true }),
|
|
74
|
+
end: () => decoder.decode(),
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
return undefined
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The trailing bytes of `bytes` that start a UTF-8 character it does not finish. */
|
|
82
|
+
function incompleteUtf8Tail(bytes: Buffer): Buffer {
|
|
83
|
+
for (let back = 1; back <= Math.min(3, bytes.length); back++) {
|
|
84
|
+
const byte = bytes[bytes.length - back] as number
|
|
85
|
+
if ((byte & 0xc0) === 0x80) continue
|
|
86
|
+
const needed = byte >= 0xf0 ? 4 : byte >= 0xe0 ? 3 : byte >= 0xc0 ? 2 : 1
|
|
87
|
+
return needed > back ? bytes.subarray(bytes.length - back) : Buffer.alloc(0)
|
|
88
|
+
}
|
|
89
|
+
return Buffer.alloc(0)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function createHostOutputDecoder(options: HostOutputDecoderOptions = {}): HostOutputDecoder {
|
|
93
|
+
const platform = options.platform ?? process.platform
|
|
94
|
+
if (platform !== 'win32') return new StringDecoder('utf8')
|
|
95
|
+
const legacy = legacyDecoder(
|
|
96
|
+
'codePage' in options ? options.codePage : (probeOemCodePage() ?? undefined),
|
|
97
|
+
)
|
|
98
|
+
if (legacy === undefined) return new StringDecoder('utf8')
|
|
99
|
+
let utf8: InstanceType<typeof TextDecoder> | undefined = new TextDecoder('utf-8', { fatal: true })
|
|
100
|
+
// The bytes of a character cut by the last chunk, which the UTF-8 decoder
|
|
101
|
+
// holds internally and cannot hand back when the stream turns out not to
|
|
102
|
+
// be UTF-8: the legacy decoder must start from them, not lose them.
|
|
103
|
+
let tail: Buffer = Buffer.alloc(0)
|
|
104
|
+
return {
|
|
105
|
+
write(chunk) {
|
|
106
|
+
if (utf8 !== undefined) {
|
|
107
|
+
try {
|
|
108
|
+
const text = utf8.decode(chunk, { stream: true })
|
|
109
|
+
tail = incompleteUtf8Tail(chunk.length >= 3 ? chunk : Buffer.concat([tail, chunk]))
|
|
110
|
+
return text
|
|
111
|
+
} catch {
|
|
112
|
+
utf8 = undefined
|
|
113
|
+
return legacy.write(Buffer.concat([tail, chunk]))
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return legacy.write(chunk)
|
|
117
|
+
},
|
|
118
|
+
end() {
|
|
119
|
+
if (utf8 !== undefined) {
|
|
120
|
+
try {
|
|
121
|
+
return utf8.decode()
|
|
122
|
+
} catch {
|
|
123
|
+
utf8 = undefined
|
|
124
|
+
return legacy.write(tail) + legacy.end()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return legacy.end()
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Decode a whole captured buffer. */
|
|
133
|
+
export function decodeHostOutput(bytes: Buffer, options: HostOutputDecoderOptions = {}): string {
|
|
134
|
+
const decoder = createHostOutputDecoder(options)
|
|
135
|
+
return decoder.write(bytes) + decoder.end()
|
|
136
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
+
import { MemoryRevisionConflictError } from '../../store/memory/revision.js'
|
|
2
3
|
import type { MemoryStore } from '../../types/memory/index.js'
|
|
4
|
+
import { hasConditionalMemoryWrites } from '../../types/memory/index.js'
|
|
3
5
|
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
4
6
|
import { asMemoryId } from '../../utils/id.js'
|
|
5
7
|
import { defineTool } from '../defineTool.js'
|
|
@@ -8,17 +10,45 @@ export function buildDeleteMemoryTool(store: MemoryStore): ToolDefinition {
|
|
|
8
10
|
return defineTool({
|
|
9
11
|
name: 'delete_memory',
|
|
10
12
|
description:
|
|
11
|
-
'Permanently delete a stored memory by ID. Use update_memory with status archived when the record should remain available for inspection. Deletion does not erase past conversation transcripts.',
|
|
13
|
+
'Permanently delete a stored memory by ID. Use update_memory with status archived when the record should remain available for inspection. Deletion does not erase past conversation transcripts. Pass the revision from read_memory when available to refuse a stale deletion.',
|
|
12
14
|
inputSchema: z.object({
|
|
13
15
|
id: z.string().describe('Memory ID to permanently delete'),
|
|
16
|
+
revision: z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Opaque revision from read_memory; refuse deletion if the record changed'),
|
|
14
21
|
}),
|
|
15
22
|
category: 'custom',
|
|
16
23
|
permissions: [],
|
|
17
24
|
readOnly: false,
|
|
18
25
|
destructive: true,
|
|
19
26
|
concurrencySafe: true,
|
|
20
|
-
async execute({ id }) {
|
|
21
|
-
|
|
27
|
+
async execute({ id, revision }) {
|
|
28
|
+
if (revision !== undefined && !hasConditionalMemoryWrites(store)) {
|
|
29
|
+
return {
|
|
30
|
+
success: false,
|
|
31
|
+
output: 'This memory store does not support revision-checked deletion.',
|
|
32
|
+
error: 'Conditional memory deletion unavailable',
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let removed: boolean
|
|
36
|
+
try {
|
|
37
|
+
if (revision === undefined) {
|
|
38
|
+
removed = await store.delete(asMemoryId(id))
|
|
39
|
+
} else if (hasConditionalMemoryWrites(store)) {
|
|
40
|
+
await store.deleteIfRevision(asMemoryId(id), revision)
|
|
41
|
+
removed = true
|
|
42
|
+
} else throw new Error('Conditional memory support changed during the deletion.')
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (!(error instanceof MemoryRevisionConflictError)) throw error
|
|
45
|
+
return {
|
|
46
|
+
success: false,
|
|
47
|
+
output: error.message,
|
|
48
|
+
error: 'Memory changed since read',
|
|
49
|
+
data: { reason: 'revision_conflict' },
|
|
50
|
+
}
|
|
51
|
+
}
|
|
22
52
|
return {
|
|
23
53
|
success: removed,
|
|
24
54
|
output: removed ? `Memory deleted: ${id}.` : `Memory ${id} not found.`,
|
package/src/tools/memory/read.ts
CHANGED
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
describeMemoryAge,
|
|
5
5
|
memoryLinkNames,
|
|
6
6
|
} from '../../store/memory/links.js'
|
|
7
|
+
import { MemoryRevisionUnavailableError } from '../../store/memory/revision.js'
|
|
7
8
|
import type { MemoryId } from '../../types/ids/index.js'
|
|
8
9
|
import type { MemoryContent, MemoryIndexEntry, MemoryStore } from '../../types/memory/index.js'
|
|
10
|
+
import { hasConditionalMemoryWrites } from '../../types/memory/index.js'
|
|
9
11
|
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
10
12
|
import { defineTool } from '../defineTool.js'
|
|
11
13
|
import { allMemoryEntries, resolveMemoryReference } from './resolve.js'
|
|
@@ -43,7 +45,22 @@ export function buildReadMemoryTool(store: MemoryStore): ToolDefinition {
|
|
|
43
45
|
|
|
44
46
|
let entry: MemoryIndexEntry | undefined
|
|
45
47
|
let content: MemoryContent | undefined
|
|
46
|
-
|
|
48
|
+
let revision: string | undefined
|
|
49
|
+
if (hasConditionalMemoryWrites(store)) {
|
|
50
|
+
try {
|
|
51
|
+
const record = await store.getVersionedRecord(memoryId)
|
|
52
|
+
entry = record?.entry
|
|
53
|
+
content = record?.content
|
|
54
|
+
revision = record?.revision
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (!(error instanceof MemoryRevisionUnavailableError)) throw error
|
|
57
|
+
// Legacy in-memory records may hold cloneable host objects with
|
|
58
|
+
// inaccessible bytes. Read them without claiming CAS support.
|
|
59
|
+
const record = await store.getRecord?.(memoryId)
|
|
60
|
+
entry = record?.entry
|
|
61
|
+
content = record?.content ?? (await store.get(memoryId))
|
|
62
|
+
}
|
|
63
|
+
} else if (store.getRecord) {
|
|
47
64
|
const record = await store.getRecord(memoryId)
|
|
48
65
|
entry = record?.entry
|
|
49
66
|
content = record?.content
|
|
@@ -92,9 +109,24 @@ export function buildReadMemoryTool(store: MemoryStore): ToolDefinition {
|
|
|
92
109
|
// A JSON body stays exactly the stored text, parseable as it was
|
|
93
110
|
// before these notes existed; its age and links are in `data`.
|
|
94
111
|
const annotate = notes.length > 0 && content.format !== 'json'
|
|
112
|
+
const output = annotate ? `${content.content}\n\n---\n${notes.join('\n')}` : content.content
|
|
95
113
|
return {
|
|
96
114
|
success: true,
|
|
97
|
-
output
|
|
115
|
+
output,
|
|
116
|
+
// The executor sends output or content to the model, not data. Keep
|
|
117
|
+
// output byte-compatible (including JSON) while exposing the token
|
|
118
|
+
// in a separate model-visible text block.
|
|
119
|
+
...(revision !== undefined
|
|
120
|
+
? {
|
|
121
|
+
content: [
|
|
122
|
+
{ type: 'text' as const, text: output },
|
|
123
|
+
{
|
|
124
|
+
type: 'text' as const,
|
|
125
|
+
text: `Memory revision: ${revision}. Pass it as revision to update_memory or delete_memory to reject stale changes.`,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
}
|
|
129
|
+
: {}),
|
|
98
130
|
data: {
|
|
99
131
|
id: content.id,
|
|
100
132
|
format: content.format,
|
|
@@ -102,6 +134,7 @@ export function buildReadMemoryTool(store: MemoryStore): ToolDefinition {
|
|
|
102
134
|
...(entry?.name !== undefined ? { name: entry.name } : {}),
|
|
103
135
|
...(entry?.type !== undefined ? { type: entry.type } : {}),
|
|
104
136
|
...(entry ? { updatedAt: entry.updatedAt } : {}),
|
|
137
|
+
...(revision !== undefined ? { revision } : {}),
|
|
105
138
|
...(resolved.length > 0 ? { links: resolved } : {}),
|
|
106
139
|
},
|
|
107
140
|
}
|