@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BackgroundJobRegistryRef } from '../../types/tool/index.js'
|
|
2
|
+
import { subscribeToAbort } from '../../utils/abort.js'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Waiting on a background job, bounded by two different questions — the
|
|
@@ -42,6 +43,8 @@ interface JobWaitProgress {
|
|
|
42
43
|
readonly output: string
|
|
43
44
|
readonly nextOffset: number
|
|
44
45
|
readonly droppedBytes: number
|
|
46
|
+
/** Earlier bytes omitted from this wait's own bounded output, separately from registry loss. */
|
|
47
|
+
readonly omittedOutputBytes: number
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
export type JobWaitOutcome =
|
|
@@ -49,6 +52,8 @@ export type JobWaitOutcome =
|
|
|
49
52
|
readonly kind: 'exited'
|
|
50
53
|
readonly status: string
|
|
51
54
|
readonly exitCode?: number
|
|
55
|
+
/** Why the command never started, when it could not. */
|
|
56
|
+
readonly error?: string
|
|
52
57
|
} & JobWaitProgress)
|
|
53
58
|
| ({
|
|
54
59
|
readonly kind: 'timeout'
|
|
@@ -67,12 +72,27 @@ export type JobWaitOutcome =
|
|
|
67
72
|
*/
|
|
68
73
|
const POLL_INTERVAL_MS = 1_000
|
|
69
74
|
|
|
75
|
+
/** Leave room for the status and recovery instructions inside the tool-result budget. */
|
|
76
|
+
const MAX_WAIT_OUTPUT_BYTES = 32 * 1024
|
|
77
|
+
|
|
78
|
+
function boundedTail(value: string): { output: string; omittedBytes: number } {
|
|
79
|
+
const bytes = Buffer.from(value, 'utf8')
|
|
80
|
+
if (bytes.length <= MAX_WAIT_OUTPUT_BYTES) return { output: value, omittedBytes: 0 }
|
|
81
|
+
let start = bytes.length - MAX_WAIT_OUTPUT_BYTES
|
|
82
|
+
// The cap is in bytes, but the displayed tail must begin at a UTF-8 character.
|
|
83
|
+
while (start < bytes.length && ((bytes[start] ?? 0) & 0xc0) === 0x80) start++
|
|
84
|
+
return {
|
|
85
|
+
output: bytes.subarray(start).toString('utf8'),
|
|
86
|
+
omittedBytes: start,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
/**
|
|
71
|
-
* Await a job under both bounds,
|
|
91
|
+
* Await a job under both bounds, retaining a bounded tail as it goes.
|
|
72
92
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
93
|
+
* A completed or timed-out wait returns the bytes it observed up to its
|
|
94
|
+
* absolute cursor. If the displayed tail could not hold all of them, its
|
|
95
|
+
* omitted-byte count keeps that gap visible to the caller.
|
|
76
96
|
*/
|
|
77
97
|
export async function waitForJobWithBounds(
|
|
78
98
|
jobs: Pick<BackgroundJobRegistryRef, 'read' | 'waitForExit'>,
|
|
@@ -90,8 +110,16 @@ export async function waitForJobWithBounds(
|
|
|
90
110
|
let cursor = options.fromOffset ?? 0
|
|
91
111
|
let output = ''
|
|
92
112
|
let droppedBytes = 0
|
|
113
|
+
let omittedOutputBytes = 0
|
|
93
114
|
let settled = false
|
|
94
115
|
let poll: ReturnType<typeof setInterval> | undefined
|
|
116
|
+
// Each bounded wait owns its exit subscription. A timeout must release that
|
|
117
|
+
// subscription even when the job itself runs forever.
|
|
118
|
+
const waitAbort = new AbortController()
|
|
119
|
+
const forwardAbort = (): void => waitAbort.abort(options.signal?.reason)
|
|
120
|
+
let disposeCallerAbort = () => {}
|
|
121
|
+
if (options.signal?.aborted) forwardAbort()
|
|
122
|
+
else if (options.signal) disposeCallerAbort = subscribeToAbort(options.signal, forwardAbort)
|
|
95
123
|
|
|
96
124
|
/** Read whatever is new since `cursor`, and count it as progress if it is. */
|
|
97
125
|
const drain = (): void => {
|
|
@@ -99,11 +127,15 @@ export async function waitForJobWithBounds(
|
|
|
99
127
|
if (chunk.droppedBytes > 0) droppedBytes += chunk.droppedBytes
|
|
100
128
|
if (chunk.nextOffset > cursor) lastProgressAt = now()
|
|
101
129
|
cursor = chunk.nextOffset
|
|
102
|
-
if (chunk.chunk)
|
|
130
|
+
if (chunk.chunk) {
|
|
131
|
+
const bounded = boundedTail(output + chunk.chunk)
|
|
132
|
+
output = bounded.output
|
|
133
|
+
omittedOutputBytes += bounded.omittedBytes
|
|
134
|
+
}
|
|
103
135
|
}
|
|
104
136
|
|
|
105
137
|
try {
|
|
106
|
-
const exited = waitForExit(id, { signal:
|
|
138
|
+
const exited = waitForExit(id, { signal: waitAbort.signal }).then((job): JobWaitOutcome => {
|
|
107
139
|
// One last read: the job can exit between ticks, and the bytes
|
|
108
140
|
// it wrote in its final moment are exactly the ones a caller
|
|
109
141
|
// most wants — the error, the summary line, the exit trace.
|
|
@@ -112,9 +144,11 @@ export async function waitForJobWithBounds(
|
|
|
112
144
|
kind: 'exited',
|
|
113
145
|
status: job.status,
|
|
114
146
|
...(job.exitCode === undefined ? {} : { exitCode: job.exitCode }),
|
|
147
|
+
...(job.error === undefined ? {} : { error: job.error }),
|
|
115
148
|
output,
|
|
116
149
|
nextOffset: cursor,
|
|
117
150
|
droppedBytes,
|
|
151
|
+
omittedOutputBytes,
|
|
118
152
|
}
|
|
119
153
|
})
|
|
120
154
|
|
|
@@ -136,6 +170,7 @@ export async function waitForJobWithBounds(
|
|
|
136
170
|
output,
|
|
137
171
|
nextOffset: cursor,
|
|
138
172
|
droppedBytes,
|
|
173
|
+
omittedOutputBytes,
|
|
139
174
|
})
|
|
140
175
|
return
|
|
141
176
|
}
|
|
@@ -150,6 +185,7 @@ export async function waitForJobWithBounds(
|
|
|
150
185
|
output,
|
|
151
186
|
nextOffset: cursor,
|
|
152
187
|
droppedBytes,
|
|
188
|
+
omittedOutputBytes,
|
|
153
189
|
})
|
|
154
190
|
}
|
|
155
191
|
}
|
|
@@ -165,6 +201,8 @@ export async function waitForJobWithBounds(
|
|
|
165
201
|
} finally {
|
|
166
202
|
settled = true
|
|
167
203
|
if (poll !== undefined) clearInterval(poll)
|
|
204
|
+
disposeCallerAbort()
|
|
205
|
+
waitAbort.abort(new Error('Job wait finished'))
|
|
168
206
|
}
|
|
169
207
|
}
|
|
170
208
|
|
|
@@ -174,7 +212,7 @@ export function describeJobWaitTimeout(
|
|
|
174
212
|
outcome: Extract<JobWaitOutcome, { kind: 'timeout' }>,
|
|
175
213
|
): string {
|
|
176
214
|
const seconds = Math.round(outcome.elapsedMs / 1000)
|
|
177
|
-
const resume = `call wait_for_job
|
|
215
|
+
const resume = `call wait_for_job or job read with from_offset ${outcome.nextOffset} to see only what comes next`
|
|
178
216
|
if (outcome.cause === 'idle') {
|
|
179
217
|
return `Job ${id} went quiet: no new output for a while, after ${seconds}s. It has not been stopped and may still be working — ${resume}.`
|
|
180
218
|
}
|
|
@@ -33,34 +33,69 @@ const DEFAULT_IDLE_TIMEOUT_MS = readPositiveIntEnv('NAMZU_JOB_WAIT_IDLE_MS', 2 *
|
|
|
33
33
|
*/
|
|
34
34
|
const MAX_WAIT_MS = readPositiveIntEnv('NAMZU_JOB_WAIT_MAX_MS', 60 * 60 * 1000)
|
|
35
35
|
|
|
36
|
-
const inputSchema = z
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
const inputSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
id: z.string().describe('The job id, as returned by bash with run_in_background.'),
|
|
39
|
+
output_contains: z
|
|
40
|
+
.string()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(4096)
|
|
43
|
+
.refine(
|
|
44
|
+
(value) =>
|
|
45
|
+
Buffer.byteLength(value) <= 4096 && Buffer.from(value).toString('utf8') === value,
|
|
46
|
+
'Use a non-empty UTF-8 literal of at most 4096 bytes.',
|
|
47
|
+
)
|
|
48
|
+
.optional()
|
|
49
|
+
.describe(
|
|
50
|
+
'Wait for this exact literal in output rather than for exit. This observes a marker; it does not prove service health or keep the turn open until the job exits.',
|
|
51
|
+
),
|
|
52
|
+
output_stream: z
|
|
53
|
+
.enum(['stdout', 'stderr', 'either'])
|
|
54
|
+
.optional()
|
|
55
|
+
.describe(
|
|
56
|
+
'Pipe to inspect with output_contains. Default either; stdout and stderr are never joined for a match.',
|
|
57
|
+
),
|
|
58
|
+
from_offset: z
|
|
59
|
+
.number()
|
|
60
|
+
.int()
|
|
61
|
+
.nonnegative()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Resume after a previous wait: pass its next_offset to receive only new output.'),
|
|
64
|
+
timeout_ms: z
|
|
65
|
+
.number()
|
|
66
|
+
.int()
|
|
67
|
+
.positive()
|
|
68
|
+
.max(MAX_WAIT_MS)
|
|
69
|
+
.optional()
|
|
70
|
+
.describe(
|
|
71
|
+
`Give up after this long even if the job keeps producing output, in milliseconds. Default: ${DEFAULT_TIMEOUT_MS}, maximum: ${MAX_WAIT_MS}. The job is never stopped by this running out.`,
|
|
72
|
+
),
|
|
73
|
+
idle_timeout_ms: z
|
|
74
|
+
.number()
|
|
75
|
+
.int()
|
|
76
|
+
.positive()
|
|
77
|
+
.max(MAX_WAIT_MS)
|
|
78
|
+
.optional()
|
|
79
|
+
.describe(
|
|
80
|
+
`Give up if the job produces no new output for this long, in milliseconds. Default: ${DEFAULT_IDLE_TIMEOUT_MS}. Resets on every new byte of output, so a job that is still working is not cut off; only real silence ends the wait early.`,
|
|
81
|
+
),
|
|
82
|
+
})
|
|
83
|
+
.superRefine((input, ctx) => {
|
|
84
|
+
if (input.output_stream !== undefined && input.output_contains === undefined) {
|
|
85
|
+
ctx.addIssue({
|
|
86
|
+
code: 'custom',
|
|
87
|
+
path: ['output_stream'],
|
|
88
|
+
message: 'output_stream requires output_contains.',
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
})
|
|
57
92
|
|
|
58
93
|
type WaitForJobInput = z.infer<typeof inputSchema>
|
|
59
94
|
|
|
60
95
|
export const WaitForJobTool = defineTool({
|
|
61
96
|
name: 'wait_for_job',
|
|
62
97
|
description:
|
|
63
|
-
'
|
|
98
|
+
'Wait for an owned background job to exit, or set output_contains to observe an exact output marker while it stays running. Use one wait instead of polling job read. Output markers do not prove service health or completion and never express intent to wait until exit. A bounded wait returns output and next_offset without stopping the job; pass that cursor as from_offset to exclude earlier output.',
|
|
64
99
|
inputSchema,
|
|
65
100
|
category: 'shell',
|
|
66
101
|
permissions: ['shell_execute'],
|
|
@@ -82,7 +117,7 @@ export const WaitForJobTool = defineTool({
|
|
|
82
117
|
return {
|
|
83
118
|
kind: 'generic',
|
|
84
119
|
presentation: 'activity',
|
|
85
|
-
label:
|
|
120
|
+
label: `${input.output_contains === undefined ? 'Wait for background job' : 'Wait for job output'} · ${input.id ?? '(missing id)'}`,
|
|
86
121
|
}
|
|
87
122
|
},
|
|
88
123
|
|
|
@@ -106,6 +141,83 @@ export const WaitForJobTool = defineTool({
|
|
|
106
141
|
}
|
|
107
142
|
}
|
|
108
143
|
|
|
144
|
+
if (input.output_stream !== undefined && input.output_contains === undefined) {
|
|
145
|
+
return { success: false, output: '', error: 'output_stream requires output_contains.' }
|
|
146
|
+
}
|
|
147
|
+
if (input.output_contains !== undefined) {
|
|
148
|
+
if (!jobs.waitForOutput) {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
output: '',
|
|
152
|
+
error:
|
|
153
|
+
'This host cannot observe output readiness. It must implement backgroundJobs.waitForOutput; no exit wait was started.',
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const outcome = await jobs.waitForOutput(input.id, {
|
|
158
|
+
literal: input.output_contains,
|
|
159
|
+
stream: input.output_stream ?? 'either',
|
|
160
|
+
timeoutMs: input.timeout_ms ?? DEFAULT_TIMEOUT_MS,
|
|
161
|
+
idleTimeoutMs: input.idle_timeout_ms ?? DEFAULT_IDLE_TIMEOUT_MS,
|
|
162
|
+
...(input.from_offset === undefined ? {} : { fromOffset: input.from_offset }),
|
|
163
|
+
signal: context.abortSignal,
|
|
164
|
+
})
|
|
165
|
+
const notices = [
|
|
166
|
+
...(outcome.droppedBytes > 0
|
|
167
|
+
? [`[${outcome.droppedBytes} bytes unavailable before the retained output]`]
|
|
168
|
+
: []),
|
|
169
|
+
...(outcome.unsearchedBytes > 0
|
|
170
|
+
? [
|
|
171
|
+
`[${outcome.unsearchedBytes} retained bytes could not be searched because the channel history cap discarded them]`,
|
|
172
|
+
]
|
|
173
|
+
: []),
|
|
174
|
+
...(outcome.omittedOutputBytes > 0
|
|
175
|
+
? [`[${outcome.omittedOutputBytes} earlier bytes omitted from this bounded result]`]
|
|
176
|
+
: []),
|
|
177
|
+
]
|
|
178
|
+
const status =
|
|
179
|
+
outcome.error !== undefined
|
|
180
|
+
? `failed to start: ${outcome.error}`
|
|
181
|
+
: outcome.exitCode === undefined
|
|
182
|
+
? outcome.status
|
|
183
|
+
: `${outcome.status} with code ${outcome.exitCode}`
|
|
184
|
+
const reason =
|
|
185
|
+
outcome.kind === 'matched'
|
|
186
|
+
? `Output marker observed on ${outcome.matchedStream}. This is output evidence, not a health check or completion claim.`
|
|
187
|
+
: outcome.kind === 'exited'
|
|
188
|
+
? 'Job exited before the marker was observed.'
|
|
189
|
+
: outcome.kind === 'stopped'
|
|
190
|
+
? 'Job stop was requested before the marker was observed; shutdown may still be completing.'
|
|
191
|
+
: outcome.kind === 'aborted'
|
|
192
|
+
? 'Output observation was cancelled; this wait did not stop the job.'
|
|
193
|
+
: `Output marker was not observed before the ${outcome.cause} timeout (${outcome.elapsedMs} ms); this wait did not stop the job.`
|
|
194
|
+
return {
|
|
195
|
+
success: outcome.kind !== 'aborted',
|
|
196
|
+
output: `${reason}\n\n${notices.length > 0 ? `${notices.join('\n')}\n` : ''}${outcome.output || '(no new output)'}\n\n[job ${input.id} is ${status}; next_offset ${outcome.nextOffset}]`,
|
|
197
|
+
data: {
|
|
198
|
+
jobId: input.id,
|
|
199
|
+
outcome: outcome.kind,
|
|
200
|
+
status: outcome.status,
|
|
201
|
+
nextOffset: outcome.nextOffset,
|
|
202
|
+
droppedBytes: outcome.droppedBytes,
|
|
203
|
+
unsearchedBytes: outcome.unsearchedBytes,
|
|
204
|
+
omittedOutputBytes: outcome.omittedOutputBytes,
|
|
205
|
+
...(outcome.kind === 'matched' ? { matchedStream: outcome.matchedStream } : {}),
|
|
206
|
+
...(outcome.kind === 'timeout' ? { timedOut: outcome.cause } : {}),
|
|
207
|
+
...(outcome.kind === 'aborted' ? { abandoned: true } : {}),
|
|
208
|
+
...(outcome.exitCode === undefined ? {} : { exitCode: outcome.exitCode }),
|
|
209
|
+
...(outcome.error === undefined ? {} : { error: outcome.error }),
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
} catch (err) {
|
|
213
|
+
return {
|
|
214
|
+
success: false,
|
|
215
|
+
output: '',
|
|
216
|
+
error: err instanceof Error ? err.message : String(err),
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
109
221
|
if (!jobs.waitForExit) {
|
|
110
222
|
return {
|
|
111
223
|
success: false,
|
|
@@ -128,6 +240,7 @@ export const WaitForJobTool = defineTool({
|
|
|
128
240
|
outcome = await waitForJobWithBounds(jobs, input.id, {
|
|
129
241
|
wallMs: input.timeout_ms ?? DEFAULT_TIMEOUT_MS,
|
|
130
242
|
idleMs: input.idle_timeout_ms ?? DEFAULT_IDLE_TIMEOUT_MS,
|
|
243
|
+
...(input.from_offset === undefined ? {} : { fromOffset: input.from_offset }),
|
|
131
244
|
signal: context.abortSignal,
|
|
132
245
|
})
|
|
133
246
|
} catch {
|
|
@@ -144,40 +257,50 @@ export const WaitForJobTool = defineTool({
|
|
|
144
257
|
}
|
|
145
258
|
}
|
|
146
259
|
|
|
260
|
+
const notices = [
|
|
261
|
+
...(outcome.droppedBytes > 0
|
|
262
|
+
? [`[${outcome.droppedBytes} bytes were dropped by the job's output retention cap]`]
|
|
263
|
+
: []),
|
|
264
|
+
...(outcome.omittedOutputBytes > 0
|
|
265
|
+
? [`[${outcome.omittedOutputBytes} earlier bytes omitted from this bounded wait result]`]
|
|
266
|
+
: []),
|
|
267
|
+
]
|
|
268
|
+
const observed = `${notices.length > 0 ? `${notices.join('\n')}\n` : ''}${outcome.output || '(no new output)'}`
|
|
269
|
+
|
|
147
270
|
if (outcome.kind === 'timeout') {
|
|
148
271
|
return {
|
|
149
|
-
|
|
150
|
-
|
|
272
|
+
// The wait observed a bound, not a failed command. A tool error
|
|
273
|
+
// would also be promoted as a durable failure by the turn's memory.
|
|
274
|
+
success: true,
|
|
275
|
+
output: `${describeJobWaitTimeout(input.id, outcome)}\n\n${observed}\n\n[next_offset ${outcome.nextOffset}]`,
|
|
151
276
|
data: {
|
|
152
277
|
jobId: input.id,
|
|
153
278
|
timedOut: outcome.cause,
|
|
154
279
|
nextOffset: outcome.nextOffset,
|
|
155
280
|
droppedBytes: outcome.droppedBytes,
|
|
281
|
+
omittedOutputBytes: outcome.omittedOutputBytes,
|
|
156
282
|
},
|
|
157
283
|
}
|
|
158
284
|
}
|
|
159
285
|
|
|
160
|
-
// The dropped count is stated, never absorbed — same rule `job read`
|
|
161
|
-
// follows, for the same reason: a job whose middle vanished quietly
|
|
162
|
-
// reads as a complete result that happens to be short.
|
|
163
|
-
const notice =
|
|
164
|
-
outcome.droppedBytes > 0
|
|
165
|
-
? `[${outcome.droppedBytes} bytes were dropped before this point — the job produced output faster than the retention cap holds]\n`
|
|
166
|
-
: ''
|
|
167
286
|
const status =
|
|
168
|
-
outcome.
|
|
169
|
-
? outcome.
|
|
170
|
-
:
|
|
287
|
+
outcome.error !== undefined
|
|
288
|
+
? `failed to start: ${outcome.error}`
|
|
289
|
+
: outcome.exitCode === undefined
|
|
290
|
+
? outcome.status
|
|
291
|
+
: `${outcome.status} with code ${outcome.exitCode}`
|
|
171
292
|
|
|
172
293
|
return {
|
|
173
294
|
success: true,
|
|
174
|
-
output: `${
|
|
295
|
+
output: `${observed}\n\n[job ${input.id} is ${status}; next_offset ${outcome.nextOffset}]`,
|
|
175
296
|
data: {
|
|
176
297
|
jobId: input.id,
|
|
177
298
|
status: outcome.status,
|
|
178
299
|
nextOffset: outcome.nextOffset,
|
|
179
300
|
droppedBytes: outcome.droppedBytes,
|
|
301
|
+
omittedOutputBytes: outcome.omittedOutputBytes,
|
|
180
302
|
...(outcome.exitCode === undefined ? {} : { exitCode: outcome.exitCode }),
|
|
303
|
+
...(outcome.error === undefined ? {} : { error: outcome.error }),
|
|
181
304
|
},
|
|
182
305
|
}
|
|
183
306
|
},
|
|
@@ -2,6 +2,7 @@ import { mkdir, readFile } from 'node:fs/promises'
|
|
|
2
2
|
import { dirname } from 'node:path'
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
import type { ToolContext, ToolResult } from '../../types/tool/index.js'
|
|
5
|
+
import type { ToolFacts } from '../../types/tool/presentation.js'
|
|
5
6
|
import { defineTool } from '../defineTool.js'
|
|
6
7
|
import { resolveWithinAnyReal, toolRoots } from '../paths.js'
|
|
7
8
|
import { atomicWriteFile } from './atomic-write-file.js'
|
|
@@ -196,13 +197,14 @@ export const WriteFileTool = defineTool({
|
|
|
196
197
|
function enforceReadBeforeOverwrite(
|
|
197
198
|
context: ToolContext,
|
|
198
199
|
key: string,
|
|
199
|
-
): { success: false; output: ''; error: string } | null {
|
|
200
|
+
): { success: false; output: ''; error: string; facts?: ToolFacts } | null {
|
|
200
201
|
if (!context.fileReadTracker) return null
|
|
201
202
|
if (context.fileReadTracker.hasRead(key)) return null
|
|
202
203
|
return {
|
|
203
204
|
success: false,
|
|
204
205
|
output: '',
|
|
205
206
|
error: `${key} already exists. Use the \`read\` tool on it first in this conversation, then call \`write\` again — or prefer \`edit\` for a targeted change.`,
|
|
207
|
+
facts: { kind: 'failure', reason: 'already_exists', subject: key },
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
|
|
@@ -210,7 +212,7 @@ function enforceFreshOverwrite(
|
|
|
210
212
|
context: ToolContext,
|
|
211
213
|
key: string,
|
|
212
214
|
currentContent: string,
|
|
213
|
-
): { success: false; output: ''; error: string } | null {
|
|
215
|
+
): { success: false; output: ''; error: string; facts?: ToolFacts } | null {
|
|
214
216
|
const unread = enforceReadBeforeOverwrite(context, key)
|
|
215
217
|
if (unread) return unread
|
|
216
218
|
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
* `NAMZU_BASH_SHELL=/bin/sh` restores the old shell exactly.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
import {
|
|
37
|
+
import { type ChildProcess, type SpawnOptions, spawn as nodeSpawn } from 'node:child_process'
|
|
38
|
+
import { constants, accessSync, existsSync } from 'node:fs'
|
|
38
39
|
import { delimiter, isAbsolute, join } from 'node:path'
|
|
39
40
|
|
|
40
41
|
import type { ShellDialect } from '../types/tool/index.js'
|
|
@@ -67,12 +68,19 @@ export function findCommandShell(probe: CommandShellProbe): CommandShell {
|
|
|
67
68
|
if (override !== undefined && override !== '') {
|
|
68
69
|
// Read as bash only when it is bash; anything else gets the reading
|
|
69
70
|
// that holds for every POSIX shell.
|
|
70
|
-
const name =
|
|
71
|
+
const name =
|
|
72
|
+
probe.platform === 'win32'
|
|
73
|
+
? override
|
|
74
|
+
.split(/[\\/]/)
|
|
75
|
+
.at(-1)
|
|
76
|
+
?.toLowerCase()
|
|
77
|
+
.replace(/\.exe$/, '')
|
|
78
|
+
: override.slice(override.lastIndexOf('/') + 1)
|
|
71
79
|
return { path: override, dialect: name === 'bash' ? 'bash' : 'sh', source: 'override' }
|
|
72
80
|
}
|
|
73
81
|
// Windows keeps Node's platform shell. Looking `bash` up on its PATH can
|
|
74
82
|
// find WSL's launcher, which runs the command in another system.
|
|
75
|
-
if (probe.platform === 'win32') return { path: undefined, dialect: '
|
|
83
|
+
if (probe.platform === 'win32') return { path: undefined, dialect: 'cmd', source: 'platform' }
|
|
76
84
|
for (const directory of (probe.env.PATH ?? '').split(delimiter)) {
|
|
77
85
|
if (directory === '' || !directory.startsWith('/')) continue
|
|
78
86
|
const candidate = join(directory, 'bash')
|
|
@@ -94,7 +102,7 @@ export function findCommandShell(probe: CommandShellProbe): CommandShell {
|
|
|
94
102
|
export function findCommandShellForDialect(
|
|
95
103
|
dialect: 'bash' | 'sh',
|
|
96
104
|
probe: CommandShellProbe,
|
|
97
|
-
): CommandShell | undefined {
|
|
105
|
+
): (CommandShell & { readonly dialect: 'bash' | 'sh' }) | undefined {
|
|
98
106
|
if (probe.platform === 'win32') return undefined
|
|
99
107
|
const override = probe.env.NAMZU_BASH_SHELL
|
|
100
108
|
if (override) {
|
|
@@ -142,7 +150,9 @@ export function hostCommandShell(): CommandShell {
|
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
/** Re-check the requested executable each time a job is confirmed or fired. */
|
|
145
|
-
export function installedCommandShellForDialect(
|
|
153
|
+
export function installedCommandShellForDialect(
|
|
154
|
+
dialect: 'bash' | 'sh',
|
|
155
|
+
): (CommandShell & { readonly dialect: 'bash' | 'sh' }) | undefined {
|
|
146
156
|
return findCommandShellForDialect(dialect, {
|
|
147
157
|
env: process.env,
|
|
148
158
|
platform: process.platform,
|
|
@@ -173,6 +183,123 @@ export function hostShellSpawn(
|
|
|
173
183
|
return { file: shell.path, args: ['-c', command], env: withoutBashStartup(env) }
|
|
174
184
|
}
|
|
175
185
|
|
|
186
|
+
/** Why a command could not be started, in the words a model or operator reads. */
|
|
187
|
+
export function describeSpawnFailure(error: unknown, cwd?: string): string {
|
|
188
|
+
// Node reports a missing working directory as ENOENT on the shell's own
|
|
189
|
+
// path ("spawn C:\Windows\system32\cmd.exe ENOENT"), which sends the reader
|
|
190
|
+
// looking for a missing shell. Say what is actually missing.
|
|
191
|
+
if (
|
|
192
|
+
cwd !== undefined &&
|
|
193
|
+
(error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT' &&
|
|
194
|
+
!existsSync(cwd)
|
|
195
|
+
) {
|
|
196
|
+
return `Could not start the command: the working directory does not exist: ${cwd}`
|
|
197
|
+
}
|
|
198
|
+
const detail = error instanceof Error ? error.message : String(error)
|
|
199
|
+
return `Could not start the command: ${detail}`
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Environment variable that carries the command line into the inner cmd. */
|
|
203
|
+
const WINDOWS_COMMAND_VARIABLE = 'NAMZU_HOST_COMMAND'
|
|
204
|
+
const WINDOWS_SHELL_VARIABLE = 'NAMZU_HOST_COMSPEC'
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The spawn for one command line under cmd on Windows: the outer cmd's file,
|
|
208
|
+
* its arguments and the environment that carries the command.
|
|
209
|
+
*
|
|
210
|
+
* A bare `cmd /d /s /c <command>` converts the command line to the console's
|
|
211
|
+
* OEM code page before it runs anything, so letters that page lacks arrive
|
|
212
|
+
* as their nearest ASCII look-alike (g-breve as `g`, s-cedilla as `s` on
|
|
213
|
+
* CP850) and are gone before the command writes a byte. `chcp` inside the
|
|
214
|
+
* same line is too late: the line is already converted. So the outer cmd
|
|
215
|
+
* only switches the console to UTF-8 and starts a second cmd, and the
|
|
216
|
+
* command travels in the environment, which is Unicode and never converted.
|
|
217
|
+
* The outer cmd reads it with delayed expansion (`!NAME!`), which happens
|
|
218
|
+
* after its line is parsed, so quotes, `&`, `|` and `>` in the command are
|
|
219
|
+
* inert there and reach the second cmd as the line it was given: quoting,
|
|
220
|
+
* `%` and redirection mean what they meant before, and its exit code is the
|
|
221
|
+
* command's. Neither cmd is looked up on PATH, so a `cmd.exe` in the
|
|
222
|
+
* working directory is never picked up.
|
|
223
|
+
*/
|
|
224
|
+
function windowsCmdSpawn(
|
|
225
|
+
command: string,
|
|
226
|
+
env: NodeJS.ProcessEnv,
|
|
227
|
+
): {
|
|
228
|
+
readonly file: string
|
|
229
|
+
readonly args: readonly string[]
|
|
230
|
+
readonly env: NodeJS.ProcessEnv
|
|
231
|
+
} {
|
|
232
|
+
const lookup = (name: string): string | undefined => {
|
|
233
|
+
const key = Object.keys(env).find((k) => k.toLowerCase() === name.toLowerCase())
|
|
234
|
+
return key === undefined ? undefined : env[key]
|
|
235
|
+
}
|
|
236
|
+
const comspec =
|
|
237
|
+
lookup('ComSpec') ??
|
|
238
|
+
`${lookup('SystemRoot') ?? process.env.SystemRoot ?? 'C:\\Windows'}\\System32\\cmd.exe`
|
|
239
|
+
return {
|
|
240
|
+
file: comspec,
|
|
241
|
+
// Passed verbatim: Node must not re-quote the line, whose outer quotes
|
|
242
|
+
// `/s` strips.
|
|
243
|
+
args: [
|
|
244
|
+
'/d',
|
|
245
|
+
'/v:on',
|
|
246
|
+
'/s',
|
|
247
|
+
'/c',
|
|
248
|
+
`"chcp 65001>nul & "!${WINDOWS_SHELL_VARIABLE}!" /d /s /c "!${WINDOWS_COMMAND_VARIABLE}!""`,
|
|
249
|
+
],
|
|
250
|
+
env: { ...env, [WINDOWS_SHELL_VARIABLE]: comspec, [WINDOWS_COMMAND_VARIABLE]: command },
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Start one command on the host, in the shell {@link hostCommandShell} chose.
|
|
256
|
+
*
|
|
257
|
+
* The ONE place that knows what Windows needs: with no shell path (cmd), Node
|
|
258
|
+
* itself must run the line (`cmd.exe /d /s /c`, see `windowsCmdSpawn`);
|
|
259
|
+
* everywhere else it is `<shell> -c <command>`. The foreground `bash` tool,
|
|
260
|
+
* the background job registry and plugin hooks all spawn through here, so
|
|
261
|
+
* they cannot diverge: the registry once spawned `/bin/sh` on Windows while
|
|
262
|
+
* the foreground tool did not, and every background job died at once with no
|
|
263
|
+
* message.
|
|
264
|
+
*
|
|
265
|
+
* - On Windows the line runs under UTF-8 (see `windowsCmdSpawn`).
|
|
266
|
+
* - `detached` (own process group, for `killTree`) is POSIX only; on Windows
|
|
267
|
+
* it opens a new console window instead.
|
|
268
|
+
* - `windowsHide` keeps a GUI host from flashing a console per command.
|
|
269
|
+
*/
|
|
270
|
+
export function spawnHostShell(
|
|
271
|
+
command: string,
|
|
272
|
+
options: {
|
|
273
|
+
readonly cwd: string
|
|
274
|
+
readonly env: NodeJS.ProcessEnv
|
|
275
|
+
readonly stdio?: SpawnOptions['stdio']
|
|
276
|
+
/** Default: true off Windows. */
|
|
277
|
+
readonly detached?: boolean
|
|
278
|
+
readonly shell?: CommandShell
|
|
279
|
+
/** For tests: the platform the options are shaped for. */
|
|
280
|
+
readonly platform?: NodeJS.Platform
|
|
281
|
+
/** For tests: the spawn that runs it. */
|
|
282
|
+
readonly spawnImpl?: typeof nodeSpawn
|
|
283
|
+
},
|
|
284
|
+
): ChildProcess {
|
|
285
|
+
const spawnFn = options.spawnImpl ?? nodeSpawn
|
|
286
|
+
const resolved = hostShellSpawn(command, options.env, options.shell)
|
|
287
|
+
const common: SpawnOptions = {
|
|
288
|
+
cwd: options.cwd,
|
|
289
|
+
env: resolved.env,
|
|
290
|
+
detached: options.detached ?? (options.platform ?? process.platform) !== 'win32',
|
|
291
|
+
windowsHide: true,
|
|
292
|
+
...(options.stdio === undefined ? {} : { stdio: options.stdio }),
|
|
293
|
+
}
|
|
294
|
+
if (resolved.file !== undefined) return spawnFn(resolved.file, [...resolved.args], common)
|
|
295
|
+
const windows = windowsCmdSpawn(command, resolved.env)
|
|
296
|
+
return spawnFn(windows.file, [...windows.args], {
|
|
297
|
+
...common,
|
|
298
|
+
env: windows.env,
|
|
299
|
+
windowsVerbatimArguments: true,
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
|
|
176
303
|
export function withoutBashStartup<T extends Readonly<Record<string, string | undefined>>>(
|
|
177
304
|
env: T,
|
|
178
305
|
): T {
|
|
@@ -21,26 +21,16 @@ import type { TaskLaunchedCallback } from './index.js'
|
|
|
21
21
|
* subagent tool calls are isolated — only the summary surfaces to
|
|
22
22
|
* the parent.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* as its own `tool_result`, exactly like this tool; `continue_task` and
|
|
30
|
-
* `cancel_task` are still defined in `./index.ts` but are deliberately not
|
|
31
|
-
* registered, because a blocking launch leaves every worker terminal by the
|
|
32
|
-
* time a later turn learns its id. So a reader following the old advice was
|
|
33
|
-
* choosing between two tools on a distinction that no longer existed.
|
|
24
|
+
* `create_task` also returns the worker result inline by default. When a
|
|
25
|
+
* CompletionInbox is supplied it can instead launch in the background;
|
|
26
|
+
* `wait_for_task`, `continue_task` and `cancel_task` let the supervisor join,
|
|
27
|
+
* steer or stop its own launched work. Linked planning tasks and approved
|
|
28
|
+
* plan steps settle from the worker's actual outcome on either launch path.
|
|
34
29
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* dependencies are wired. That is the supervisor's toolkit.
|
|
40
|
-
* - This builds one tool and nothing else, for an agent whose only delegation
|
|
41
|
-
* need is "hand this to a specialist". `terminal: true` additionally lets a
|
|
42
|
-
* pure router settle on the specialist's answer instead of spending a turn
|
|
43
|
-
* at full parent context to paraphrase it.
|
|
30
|
+
* `create_task` arrives with the coordinator toolkit, including task listing
|
|
31
|
+
* and optional plan approval/question tools. This builds one delegation tool.
|
|
32
|
+
* `terminal: true` additionally lets a pure router settle on the specialist's
|
|
33
|
+
* answer instead of spending a turn restating it.
|
|
44
34
|
*
|
|
45
35
|
* Neither is legacy. Pick by how much of the coordinator surface you want.
|
|
46
36
|
*/
|