@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/runtime/jobs/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/runtime/jobs/registry.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +1,37 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import { SANDBOX_KILL_GRACE_MS } from '../../constants/sandbox/index.js';
|
|
3
2
|
import { killTree } from '../../process/kill-tree.js';
|
|
4
|
-
import {
|
|
3
|
+
import { describeSpawnFailure, spawnHostShell } from '../../tools/command-shell.js';
|
|
5
4
|
import { scrubInheritedEnv } from '../../tools/env-scrub.js';
|
|
6
|
-
import {
|
|
5
|
+
import { createHostOutputDecoder } from '../../tools/host-output.js';
|
|
6
|
+
import { subscribeToAbort } from '../../utils/abort.js';
|
|
7
7
|
const DEFAULT_MAX_JOBS_PER_OWNER = 8;
|
|
8
8
|
const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
9
|
+
const MAX_CHANNEL_CHUNKS = 4096;
|
|
10
|
+
const MAX_WAIT_RESULT_BYTES = 32 * 1024;
|
|
11
|
+
const MAX_OUTPUT_WAIT_MS = 60 * 60 * 1000;
|
|
12
|
+
/** Starting another observer would exceed its owner's or registry's bound. */
|
|
13
|
+
export class BackgroundJobOutputWaitLimitError extends Error {
|
|
14
|
+
details;
|
|
15
|
+
constructor(details) {
|
|
16
|
+
super(`Background output wait limit ${details.limit} reached for ${details.scope}; finish or cancel an existing wait first.`);
|
|
17
|
+
this.details = details;
|
|
18
|
+
this.name = 'BackgroundJobOutputWaitLimitError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Start at a complete UTF-8 code point when a byte cap or cursor bisects one. */
|
|
22
|
+
function utf8Start(bytes, start) {
|
|
23
|
+
let at = start;
|
|
24
|
+
while (at < bytes.length && ((bytes[at] ?? 0) & 0xc0) === 0x80)
|
|
25
|
+
at++;
|
|
26
|
+
return at;
|
|
27
|
+
}
|
|
28
|
+
function outputTail(text, maxBytes) {
|
|
29
|
+
const bytes = Buffer.from(text);
|
|
30
|
+
if (bytes.length <= maxBytes)
|
|
31
|
+
return { text, omitted: 0 };
|
|
32
|
+
const start = utf8Start(bytes, bytes.length - maxBytes);
|
|
33
|
+
return { text: bytes.subarray(start).toString('utf8'), omitted: start };
|
|
34
|
+
}
|
|
9
35
|
/** A start that would exceed a declared bound. */
|
|
10
36
|
export class BackgroundJobLimitError extends Error {
|
|
11
37
|
details;
|
|
@@ -42,6 +68,8 @@ export class BackgroundJobRegistry {
|
|
|
42
68
|
jobs = new Map();
|
|
43
69
|
counter = 0;
|
|
44
70
|
exitListeners = new Set();
|
|
71
|
+
outputWaiters = 0;
|
|
72
|
+
outputWaitersByOwner = new Map();
|
|
45
73
|
/**
|
|
46
74
|
* Be told when a job ends, whoever owns it. A job outlives the call that
|
|
47
75
|
* started it, so the one thing the model could not do was learn that it
|
|
@@ -64,8 +92,45 @@ export class BackgroundJobRegistry {
|
|
|
64
92
|
}
|
|
65
93
|
}
|
|
66
94
|
}
|
|
95
|
+
/** A failed remote stop never releases ownership or announces a terminal job. */
|
|
96
|
+
confirmTermination(entry) {
|
|
97
|
+
if (entry.terminationAttempt)
|
|
98
|
+
return entry.terminationAttempt;
|
|
99
|
+
const terminate = entry.terminateProcess;
|
|
100
|
+
if (!terminate)
|
|
101
|
+
return Promise.reject(new Error('The process has no confirmed termination API'));
|
|
102
|
+
const attempt = Promise.resolve()
|
|
103
|
+
.then(() => terminate('SIGTERM'))
|
|
104
|
+
.then(() => {
|
|
105
|
+
const { recoveryRequired: _recovery, stopError: _error, ...record } = entry.record;
|
|
106
|
+
entry.record = record;
|
|
107
|
+
if (entry.closedResult)
|
|
108
|
+
entry.finalize?.(entry.closedResult.code, entry.closedResult.signal);
|
|
109
|
+
})
|
|
110
|
+
.catch((error) => {
|
|
111
|
+
entry.record = {
|
|
112
|
+
...entry.record,
|
|
113
|
+
recoveryRequired: true,
|
|
114
|
+
stopError: 'The process provider could not confirm the owned job stopped; retry termination or recover its environment.',
|
|
115
|
+
};
|
|
116
|
+
for (const observer of entry.outputObservers)
|
|
117
|
+
observer();
|
|
118
|
+
throw error;
|
|
119
|
+
})
|
|
120
|
+
.finally(() => {
|
|
121
|
+
entry.terminationAttempt = undefined;
|
|
122
|
+
});
|
|
123
|
+
entry.terminationAttempt = attempt;
|
|
124
|
+
return attempt;
|
|
125
|
+
}
|
|
67
126
|
constructor(config = {}) {
|
|
68
127
|
this.config = config;
|
|
128
|
+
for (const key of ['maxOutputWaiters', 'maxOutputWaitersPerOwner']) {
|
|
129
|
+
const value = config[key];
|
|
130
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 1)) {
|
|
131
|
+
throw new RangeError(`${key} must be a positive safe integer.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
69
134
|
}
|
|
70
135
|
get maxJobs() {
|
|
71
136
|
return this.config.maxJobsPerOwner ?? DEFAULT_MAX_JOBS_PER_OWNER;
|
|
@@ -94,19 +159,19 @@ export class BackgroundJobRegistry {
|
|
|
94
159
|
// decided should see them. A background job outlives the call that
|
|
95
160
|
// started it, which makes the leak longer-lived, not smaller.
|
|
96
161
|
const inherited = scrubInheritedEnv();
|
|
97
|
-
// The same
|
|
98
|
-
// rules' reading of the line holds for the job too
|
|
99
|
-
|
|
162
|
+
// The same spawn as a foreground `bash` call, so the permission
|
|
163
|
+
// rules' reading of the line holds for the job too, and so the two
|
|
164
|
+
// cannot disagree about how a shell is started on a given platform.
|
|
100
165
|
const started = params.spawn
|
|
101
166
|
? params.spawn()
|
|
102
167
|
: {
|
|
103
|
-
child:
|
|
168
|
+
child: spawnHostShell(params.command, {
|
|
104
169
|
cwd: params.workingDirectory,
|
|
105
|
-
env:
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
// wrapping shell. See
|
|
109
|
-
|
|
170
|
+
env: { ...inherited.env, ...params.env },
|
|
171
|
+
// `detached` makes the child the leader of its own process group
|
|
172
|
+
// off Windows, which is what `killTree` needs to reach the command
|
|
173
|
+
// and everything it forks rather than only the wrapping shell. See
|
|
174
|
+
// `process/kill-tree.ts`.
|
|
110
175
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
111
176
|
}),
|
|
112
177
|
};
|
|
@@ -114,8 +179,22 @@ export class BackgroundJobRegistry {
|
|
|
114
179
|
// Started, not adopted: this process stays the parent for the job's
|
|
115
180
|
// whole life. `unref` would let Node exit with the job still running,
|
|
116
181
|
// which is the orphan this registry exists to prevent.
|
|
117
|
-
|
|
118
|
-
|
|
182
|
+
// Raw bytes, decoded here: a Windows console writes its OEM code page.
|
|
183
|
+
// A process a sandbox started runs a Linux guest, so it is UTF-8.
|
|
184
|
+
const decoders = {
|
|
185
|
+
stdout: createHostOutputDecoder(params.spawn ? { platform: 'linux' } : {}),
|
|
186
|
+
stderr: createHostOutputDecoder(params.spawn ? { platform: 'linux' } : {}),
|
|
187
|
+
};
|
|
188
|
+
let startError;
|
|
189
|
+
let settleStarted;
|
|
190
|
+
const startedPromise = new Promise((resolve) => {
|
|
191
|
+
settleStarted = () => resolve(startError === undefined ? {} : { error: startError });
|
|
192
|
+
});
|
|
193
|
+
// A process the host's own spawner started is the host's to vouch for:
|
|
194
|
+
// it may be remote, and need not emit `spawn` at all.
|
|
195
|
+
if (params.spawn || child.pid !== undefined)
|
|
196
|
+
settleStarted();
|
|
197
|
+
let finalizeEntry;
|
|
119
198
|
const entry = {
|
|
120
199
|
record: {
|
|
121
200
|
id,
|
|
@@ -126,36 +205,62 @@ export class BackgroundJobRegistry {
|
|
|
126
205
|
},
|
|
127
206
|
child,
|
|
128
207
|
...(started.kill ? { killProcess: started.kill.bind(started) } : {}),
|
|
208
|
+
...(started.terminate ? { terminateProcess: started.terminate.bind(started) } : {}),
|
|
129
209
|
buffer: '',
|
|
130
210
|
produced: 0,
|
|
211
|
+
outputChunks: [],
|
|
212
|
+
outputObservers: new Set(),
|
|
213
|
+
started: startedPromise,
|
|
131
214
|
exit: new Promise((resolve) => {
|
|
132
215
|
let spawned = child.pid !== undefined;
|
|
133
216
|
let failedToSpawn = false;
|
|
217
|
+
let finalized = false;
|
|
134
218
|
const finalize = (code, signal) => {
|
|
219
|
+
if (finalized)
|
|
220
|
+
return;
|
|
221
|
+
finalized = true;
|
|
135
222
|
entry.record = {
|
|
136
223
|
...entry.record,
|
|
137
224
|
// A job killed by this registry says `killed`, not
|
|
138
225
|
// `exited` with a signal a reader has to interpret. The
|
|
139
226
|
// two are different answers to "why did my job stop".
|
|
140
|
-
status: entry.record.status === 'killed' ? 'killed' : 'exited',
|
|
227
|
+
status: entry.killRequested || entry.record.status === 'killed' ? 'killed' : 'exited',
|
|
141
228
|
exitedAt: Date.now(),
|
|
142
229
|
...(code === null ? {} : { exitCode: code }),
|
|
143
230
|
...(signal ? { signal } : {}),
|
|
144
231
|
};
|
|
145
232
|
resolve();
|
|
233
|
+
for (const observer of entry.outputObservers)
|
|
234
|
+
observer();
|
|
146
235
|
this.announceExit(entry.record);
|
|
147
236
|
};
|
|
237
|
+
finalizeEntry = finalize;
|
|
148
238
|
child.once('spawn', () => {
|
|
149
239
|
spawned = true;
|
|
240
|
+
settleStarted();
|
|
150
241
|
});
|
|
151
|
-
child.on('error', () => {
|
|
242
|
+
child.on('error', (error) => {
|
|
152
243
|
// A failed spawn emits both `error` and `close`. Waiting for
|
|
153
244
|
// `close` also covers errors on an already-running process
|
|
154
245
|
// (such as a failed kill) without announcing a false exit.
|
|
155
|
-
if (
|
|
156
|
-
|
|
246
|
+
if (spawned)
|
|
247
|
+
return;
|
|
248
|
+
failedToSpawn = true;
|
|
249
|
+
startError ??= describeSpawnFailure(error, params.workingDirectory);
|
|
250
|
+
settleStarted();
|
|
157
251
|
});
|
|
158
252
|
child.once('close', (code, signal) => {
|
|
253
|
+
for (const stream of ['stdout', 'stderr']) {
|
|
254
|
+
const rest = decoders[stream].end();
|
|
255
|
+
if (rest)
|
|
256
|
+
append(rest, stream);
|
|
257
|
+
}
|
|
258
|
+
if (failedToSpawn && startError !== undefined) {
|
|
259
|
+
// In the output too, so a caller that only reads output (or
|
|
260
|
+
// redirects it, as a model does) still learns why it is empty.
|
|
261
|
+
append(`${startError}\n`, 'stderr');
|
|
262
|
+
entry.record = { ...entry.record, error: startError };
|
|
263
|
+
}
|
|
159
264
|
// The job is the process GROUP, not the shell. A command that
|
|
160
265
|
// backgrounds its real work (`server &`) exits the shell at
|
|
161
266
|
// once and leaves the server as the group's survivor; calling
|
|
@@ -166,6 +271,14 @@ export class BackgroundJobRegistry {
|
|
|
166
271
|
// alive, and ends — with the shell's exit code — when the
|
|
167
272
|
// group is empty.
|
|
168
273
|
const exitCode = failedToSpawn ? null : code;
|
|
274
|
+
if (entry.terminateProcess) {
|
|
275
|
+
entry.closedResult = { code: exitCode, signal };
|
|
276
|
+
void this.confirmTermination(entry).catch(() => {
|
|
277
|
+
// The retained running record exposes recoveryRequired. A
|
|
278
|
+
// later kill retries instead of forgetting the guest tree.
|
|
279
|
+
});
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
169
282
|
if (entry.record.status !== 'killed' && groupAlive(child.pid)) {
|
|
170
283
|
const poll = setInterval(() => {
|
|
171
284
|
if (groupAlive(child.pid))
|
|
@@ -180,27 +293,56 @@ export class BackgroundJobRegistry {
|
|
|
180
293
|
});
|
|
181
294
|
}),
|
|
182
295
|
};
|
|
183
|
-
|
|
184
|
-
|
|
296
|
+
entry.finalize = finalizeEntry;
|
|
297
|
+
const append = (text, stream) => {
|
|
298
|
+
const chunk = { stream, offset: entry.produced, bytes: Buffer.from(text) };
|
|
299
|
+
if (chunk.bytes.length === 0)
|
|
300
|
+
return;
|
|
301
|
+
entry.produced += chunk.bytes.length;
|
|
185
302
|
entry.buffer += text;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
303
|
+
entry.buffer = outputTail(entry.buffer, this.maxBytes).text;
|
|
304
|
+
entry.outputChunks.push(chunk);
|
|
305
|
+
const retainedStart = entry.produced - Buffer.byteLength(entry.buffer);
|
|
306
|
+
while (entry.outputChunks.length > MAX_CHANNEL_CHUNKS ||
|
|
307
|
+
(entry.outputChunks[0] &&
|
|
308
|
+
entry.outputChunks[0].offset + entry.outputChunks[0].bytes.length <= retainedStart)) {
|
|
309
|
+
entry.outputChunks.shift();
|
|
310
|
+
}
|
|
311
|
+
const first = entry.outputChunks[0];
|
|
312
|
+
if (first && first.offset < retainedStart) {
|
|
313
|
+
const skip = utf8Start(first.bytes, retainedStart - first.offset);
|
|
314
|
+
entry.outputChunks[0] = {
|
|
315
|
+
...first,
|
|
316
|
+
offset: first.offset + skip,
|
|
317
|
+
bytes: Buffer.from(first.bytes.subarray(skip)),
|
|
318
|
+
};
|
|
197
319
|
}
|
|
320
|
+
// Deliver the actual chunk even when its beginning has already fallen
|
|
321
|
+
// outside retention: an active observer must not miss a fast producer.
|
|
322
|
+
for (const observer of entry.outputObservers)
|
|
323
|
+
observer(chunk);
|
|
324
|
+
};
|
|
325
|
+
const onData = (stream) => (data) => {
|
|
326
|
+
const text = typeof data === 'string' ? data : decoders[stream].write(data);
|
|
327
|
+
if (text)
|
|
328
|
+
append(text, stream);
|
|
198
329
|
};
|
|
199
|
-
child.stdout?.on('data', (
|
|
200
|
-
child.stderr?.on('data', (
|
|
330
|
+
child.stdout?.on('data', onData('stdout'));
|
|
331
|
+
child.stderr?.on('data', onData('stderr'));
|
|
201
332
|
this.jobs.set(id, entry);
|
|
202
333
|
return entry.record;
|
|
203
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Resolves once the job's process exists, or once it could not be
|
|
337
|
+
* created (`error` then says why). Lets a caller report a start that
|
|
338
|
+
* failed in the same reply that would otherwise say "started".
|
|
339
|
+
*/
|
|
340
|
+
awaitStarted(id) {
|
|
341
|
+
const entry = this.jobs.get(id);
|
|
342
|
+
if (!entry)
|
|
343
|
+
throw new UnknownBackgroundJobError({ id });
|
|
344
|
+
return entry.started;
|
|
345
|
+
}
|
|
204
346
|
/** The record, or throw for an id this registry does not know. */
|
|
205
347
|
get(id) {
|
|
206
348
|
const entry = this.jobs.get(id);
|
|
@@ -227,10 +369,187 @@ export class BackgroundJobRegistry {
|
|
|
227
369
|
throw new UnknownBackgroundJobError({ id });
|
|
228
370
|
if (entry.record.status !== 'running')
|
|
229
371
|
return Promise.resolve(entry.record);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
372
|
+
if (!opts.signal) {
|
|
373
|
+
// Keep the original promise path for callers without cancellation.
|
|
374
|
+
return entry.exit.then(() => entry.record);
|
|
375
|
+
}
|
|
376
|
+
const signal = opts.signal;
|
|
377
|
+
if (signal.aborted)
|
|
378
|
+
return Promise.reject(signal.reason);
|
|
379
|
+
// A Promise.race against entry.exit leaves a continuation on that
|
|
380
|
+
// never-ending promise after cancellation. An exit listener can instead
|
|
381
|
+
// be removed as soon as this particular wait is abandoned.
|
|
382
|
+
return new Promise((resolve, reject) => {
|
|
383
|
+
let disposeAbort = () => { };
|
|
384
|
+
const unsubscribe = this.onExit((job) => {
|
|
385
|
+
if (job.id !== id)
|
|
386
|
+
return;
|
|
387
|
+
unsubscribe();
|
|
388
|
+
disposeAbort();
|
|
389
|
+
resolve(job);
|
|
390
|
+
});
|
|
391
|
+
disposeAbort = subscribeToAbort(signal, () => {
|
|
392
|
+
unsubscribe();
|
|
393
|
+
disposeAbort();
|
|
394
|
+
reject(signal.reason);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Observe a literal in one pipe, including retained output after the cursor.
|
|
400
|
+
* A marker is evidence of output, not exit intent or service health. Every
|
|
401
|
+
* observer is independent and bounded; cancellation never stops the job.
|
|
402
|
+
*/
|
|
403
|
+
waitForOutput(id, opts) {
|
|
404
|
+
const entry = this.jobs.get(id);
|
|
405
|
+
if (!entry)
|
|
406
|
+
throw new UnknownBackgroundJobError({ id });
|
|
407
|
+
// Capture the admitted condition and clocks once; a caller retaining its
|
|
408
|
+
// mutable options object cannot alter a bound after validation.
|
|
409
|
+
const { literal: literalText, stream: requestedStream, fromOffset, timeoutMs, idleTimeoutMs, signal, } = opts;
|
|
410
|
+
if (typeof literalText !== 'string' ||
|
|
411
|
+
literalText.length === 0 ||
|
|
412
|
+
Buffer.byteLength(literalText) > 4096 ||
|
|
413
|
+
Buffer.from(literalText).toString('utf8') !== literalText) {
|
|
414
|
+
throw new RangeError('Output literal must be non-empty valid UTF-8, at most 4096 bytes.');
|
|
415
|
+
}
|
|
416
|
+
const stream = requestedStream ?? 'either';
|
|
417
|
+
if (!['stdout', 'stderr', 'either'].includes(stream))
|
|
418
|
+
throw new RangeError('Unknown output stream.');
|
|
419
|
+
for (const [name, value] of [
|
|
420
|
+
['timeoutMs', timeoutMs],
|
|
421
|
+
['idleTimeoutMs', idleTimeoutMs],
|
|
422
|
+
]) {
|
|
423
|
+
if ((name === 'timeoutMs' || value !== undefined) &&
|
|
424
|
+
(value === undefined ||
|
|
425
|
+
!Number.isSafeInteger(value) ||
|
|
426
|
+
value < 1 ||
|
|
427
|
+
value > MAX_OUTPUT_WAIT_MS)) {
|
|
428
|
+
throw new RangeError(`${name} must be an integer from 1 through ${MAX_OUTPUT_WAIT_MS}.`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const from = fromOffset ?? 0;
|
|
432
|
+
if (!Number.isSafeInteger(from) || from < 0 || from > entry.produced) {
|
|
433
|
+
throw new RangeError('fromOffset must be an observed, nonnegative output byte cursor.');
|
|
434
|
+
}
|
|
435
|
+
const literal = Buffer.from(literalText);
|
|
436
|
+
const suffix = { stdout: Buffer.alloc(0), stderr: Buffer.alloc(0) };
|
|
437
|
+
const match = (chunk) => {
|
|
438
|
+
if ((stream !== 'either' && stream !== chunk.stream) ||
|
|
439
|
+
chunk.offset + chunk.bytes.length <= from)
|
|
440
|
+
return;
|
|
441
|
+
const skip = utf8Start(chunk.bytes, Math.max(0, from - chunk.offset));
|
|
442
|
+
const bytes = Buffer.concat([suffix[chunk.stream], chunk.bytes.subarray(skip)]);
|
|
443
|
+
const found = bytes.indexOf(literal) !== -1;
|
|
444
|
+
// Only the bytes that can prefix a future match survive each chunk.
|
|
445
|
+
// Copy so a tiny suffix never retains a large producer buffer.
|
|
446
|
+
suffix[chunk.stream] = Buffer.from(bytes.subarray(Math.max(0, bytes.length - literal.length + 1)));
|
|
447
|
+
return found ? chunk.stream : undefined;
|
|
448
|
+
};
|
|
449
|
+
let output = '';
|
|
450
|
+
let cursor = from;
|
|
451
|
+
let droppedBytes = 0;
|
|
452
|
+
let omittedOutputBytes = 0;
|
|
453
|
+
const read = () => {
|
|
454
|
+
const observed = this.read(id, { fromOffset: cursor });
|
|
455
|
+
cursor = observed.nextOffset;
|
|
456
|
+
droppedBytes += observed.droppedBytes;
|
|
457
|
+
const tail = outputTail(output + observed.chunk, MAX_WAIT_RESULT_BYTES);
|
|
458
|
+
output = tail.text;
|
|
459
|
+
omittedOutputBytes += tail.omitted;
|
|
460
|
+
};
|
|
461
|
+
read();
|
|
462
|
+
const retainedStart = entry.produced - Buffer.byteLength(entry.buffer);
|
|
463
|
+
const searchableStart = entry.outputChunks[0]?.offset ?? entry.produced;
|
|
464
|
+
const unsearchedBytes = Math.max(0, searchableStart - Math.max(from, retainedStart));
|
|
465
|
+
const progress = () => ({
|
|
466
|
+
status: entry.record.status,
|
|
467
|
+
...(entry.record.exitCode === undefined ? {} : { exitCode: entry.record.exitCode }),
|
|
468
|
+
...(entry.record.error === undefined ? {} : { error: entry.record.error }),
|
|
469
|
+
output,
|
|
470
|
+
nextOffset: cursor,
|
|
471
|
+
droppedBytes,
|
|
472
|
+
unsearchedBytes,
|
|
473
|
+
omittedOutputBytes,
|
|
474
|
+
});
|
|
475
|
+
if (signal?.aborted)
|
|
476
|
+
return Promise.resolve({ ...progress(), kind: 'aborted' });
|
|
477
|
+
// Check synchronously before subscribing. No process event can intervene
|
|
478
|
+
// in this call stack, so even a marker printed before activation is seen.
|
|
479
|
+
for (const chunk of entry.outputChunks) {
|
|
480
|
+
const matchedStream = match(chunk);
|
|
481
|
+
if (matchedStream)
|
|
482
|
+
return Promise.resolve({ ...progress(), kind: 'matched', matchedStream });
|
|
483
|
+
}
|
|
484
|
+
if (entry.record.status !== 'running') {
|
|
485
|
+
return Promise.resolve({
|
|
486
|
+
...progress(),
|
|
487
|
+
kind: entry.record.status === 'killed' ? 'stopped' : 'exited',
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
const owner = entry.record.owner;
|
|
491
|
+
const ownerCount = this.outputWaitersByOwner.get(owner) ?? 0;
|
|
492
|
+
const ownerLimit = this.config.maxOutputWaitersPerOwner ?? 32;
|
|
493
|
+
const globalLimit = this.config.maxOutputWaiters ?? 256;
|
|
494
|
+
if (ownerCount >= ownerLimit)
|
|
495
|
+
throw new BackgroundJobOutputWaitLimitError({ owner, limit: ownerLimit, scope: 'owner' });
|
|
496
|
+
if (this.outputWaiters >= globalLimit)
|
|
497
|
+
throw new BackgroundJobOutputWaitLimitError({ owner, limit: globalLimit, scope: 'registry' });
|
|
498
|
+
this.outputWaiters++;
|
|
499
|
+
this.outputWaitersByOwner.set(owner, ownerCount + 1);
|
|
500
|
+
return new Promise((resolve) => {
|
|
501
|
+
const startedAt = Date.now();
|
|
502
|
+
let settled = false;
|
|
503
|
+
let disposeAbort = () => { };
|
|
504
|
+
let idleTimer;
|
|
505
|
+
const finish = (result) => {
|
|
506
|
+
if (settled)
|
|
507
|
+
return;
|
|
508
|
+
settled = true;
|
|
509
|
+
entry.outputObservers.delete(observe);
|
|
510
|
+
clearTimeout(wallTimer);
|
|
511
|
+
clearTimeout(idleTimer);
|
|
512
|
+
disposeAbort();
|
|
513
|
+
this.outputWaiters--;
|
|
514
|
+
const remaining = (this.outputWaitersByOwner.get(owner) ?? 1) - 1;
|
|
515
|
+
if (remaining === 0)
|
|
516
|
+
this.outputWaitersByOwner.delete(owner);
|
|
517
|
+
else
|
|
518
|
+
this.outputWaitersByOwner.set(owner, remaining);
|
|
519
|
+
resolve(result);
|
|
520
|
+
};
|
|
521
|
+
const timeout = (cause) => {
|
|
522
|
+
read();
|
|
523
|
+
finish({ ...progress(), kind: 'timeout', cause, elapsedMs: Date.now() - startedAt });
|
|
524
|
+
};
|
|
525
|
+
const resetIdle = () => {
|
|
526
|
+
if (idleTimeoutMs === undefined)
|
|
527
|
+
return;
|
|
528
|
+
clearTimeout(idleTimer);
|
|
529
|
+
idleTimer = setTimeout(() => timeout('idle'), idleTimeoutMs);
|
|
530
|
+
idleTimer.unref?.();
|
|
531
|
+
};
|
|
532
|
+
const observe = (chunk) => {
|
|
533
|
+
read();
|
|
534
|
+
const matchedStream = chunk ? match(chunk) : undefined;
|
|
535
|
+
if (matchedStream)
|
|
536
|
+
finish({ ...progress(), kind: 'matched', matchedStream });
|
|
537
|
+
else if (entry.record.status !== 'running') {
|
|
538
|
+
finish({ ...progress(), kind: entry.record.status === 'killed' ? 'stopped' : 'exited' });
|
|
539
|
+
}
|
|
540
|
+
else if (chunk)
|
|
541
|
+
resetIdle();
|
|
542
|
+
};
|
|
543
|
+
entry.outputObservers.add(observe);
|
|
544
|
+
const wallTimer = setTimeout(() => timeout('wall'), timeoutMs);
|
|
545
|
+
wallTimer.unref?.();
|
|
546
|
+
resetIdle();
|
|
547
|
+
if (signal)
|
|
548
|
+
disposeAbort = subscribeToAbort(signal, () => {
|
|
549
|
+
read();
|
|
550
|
+
finish({ ...progress(), kind: 'aborted' });
|
|
551
|
+
});
|
|
552
|
+
});
|
|
234
553
|
}
|
|
235
554
|
/**
|
|
236
555
|
* Output since `fromOffset`, with what the cap dropped stated.
|
|
@@ -249,13 +568,16 @@ export class BackgroundJobRegistry {
|
|
|
249
568
|
// the gap is reported rather than closed over.
|
|
250
569
|
const effective = Math.max(from, bufferStart);
|
|
251
570
|
const skip = Math.max(0, effective - bufferStart);
|
|
252
|
-
const
|
|
571
|
+
const bytes = Buffer.from(entry.buffer);
|
|
572
|
+
const aligned = utf8Start(bytes, skip);
|
|
573
|
+
const chunk = bytes.subarray(aligned).toString('utf8');
|
|
253
574
|
return {
|
|
254
575
|
chunk,
|
|
255
576
|
nextOffset: entry.produced,
|
|
256
|
-
droppedBytes: Math.max(0, effective - from),
|
|
577
|
+
droppedBytes: Math.max(0, effective - from) + Math.max(0, aligned - skip),
|
|
257
578
|
status: entry.record.status,
|
|
258
579
|
...(entry.record.exitCode === undefined ? {} : { exitCode: entry.record.exitCode }),
|
|
580
|
+
...(entry.record.error === undefined ? {} : { error: entry.record.error }),
|
|
259
581
|
};
|
|
260
582
|
}
|
|
261
583
|
/** SIGTERM the tree, then SIGKILL after the shared grace period. */
|
|
@@ -265,10 +587,18 @@ export class BackgroundJobRegistry {
|
|
|
265
587
|
throw new UnknownBackgroundJobError({ id });
|
|
266
588
|
if (entry.record.status !== 'running')
|
|
267
589
|
return entry.record;
|
|
590
|
+
if (entry.terminateProcess) {
|
|
591
|
+
entry.killRequested = true;
|
|
592
|
+
await this.confirmTermination(entry);
|
|
593
|
+
await entry.exit;
|
|
594
|
+
return entry.record;
|
|
595
|
+
}
|
|
268
596
|
// Marked before the signal, so the `close` handler that follows can
|
|
269
597
|
// tell a kill from an ordinary exit. Set it after and the race decides
|
|
270
598
|
// which of two different answers a reader gets.
|
|
271
599
|
entry.record = { ...entry.record, status: 'killed' };
|
|
600
|
+
for (const observer of entry.outputObservers)
|
|
601
|
+
observer();
|
|
272
602
|
const signal = (sig) => entry.killProcess ? entry.killProcess(sig) : killTree(entry.child, sig);
|
|
273
603
|
signal('SIGTERM');
|
|
274
604
|
const grace = setTimeout(() => signal('SIGKILL'), SANDBOX_KILL_GRACE_MS);
|
|
@@ -345,6 +675,10 @@ export function bindOwner(registry, owner, defaults = {}) {
|
|
|
345
675
|
});
|
|
346
676
|
},
|
|
347
677
|
get: (id) => mine(id),
|
|
678
|
+
awaitStarted: (id) => {
|
|
679
|
+
mine(id);
|
|
680
|
+
return registry.awaitStarted(id);
|
|
681
|
+
},
|
|
348
682
|
read: (id, opts) => {
|
|
349
683
|
mine(id);
|
|
350
684
|
return registry.read(id, opts ?? {});
|
|
@@ -353,6 +687,10 @@ export function bindOwner(registry, owner, defaults = {}) {
|
|
|
353
687
|
mine(id);
|
|
354
688
|
return registry.waitForExit(id, opts ?? {});
|
|
355
689
|
},
|
|
690
|
+
waitForOutput: (id, opts) => {
|
|
691
|
+
mine(id);
|
|
692
|
+
return registry.waitForOutput(id, opts);
|
|
693
|
+
},
|
|
356
694
|
...(defaults.onAwaited
|
|
357
695
|
? {
|
|
358
696
|
markAwaited: (id) => {
|