@namzu/sdk 49.0.0 → 50.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +541 -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/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/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/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/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/provider/strict-schema.d.ts +28 -0
- package/dist/provider/strict-schema.d.ts.map +1 -1
- package/dist/provider/strict-schema.js +86 -0
- package/dist/provider/strict-schema.js.map +1 -1
- package/dist/public-runtime.d.ts +42 -14
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +36 -8
- 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/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 +351 -34
- 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 +3 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +21 -4
- 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 +144 -67
- 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 +61 -6
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +99 -16
- package/dist/runtime/query/iteration/phases/tool-review.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/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 +46 -1
- 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 +2 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.js +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts +2 -0
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +104 -6
- 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/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 +11 -0
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +45 -1
- package/dist/toolsets/manager.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/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 +6 -6
- 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/connector/mcp/adapter.ts +16 -4
- package/src/connector/mcp/client.ts +6 -2
- 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/shell-hook.ts +8 -2
- package/src/process/kill-tree.ts +10 -1
- package/src/provider/errors.ts +135 -2
- package/src/provider/strict-schema.ts +90 -0
- package/src/public-runtime.ts +118 -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/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 +397 -41
- 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 +24 -4
- package/src/runtime/query/iteration/index.ts +218 -104
- package/src/runtime/query/iteration/outstanding-work.ts +55 -7
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +118 -21
- 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/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 +54 -1
- 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 +3 -0
- package/src/tools/builtins/wait-for-job.ts +141 -32
- 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/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 +58 -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/message/inbound-delivery.ts +63 -0
- package/src/types/message/index.ts +8 -1
- 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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { defineTool } from '../../tools/defineTool.js'
|
|
3
|
+
import type { ToolContext, ToolDefinition } from '../../types/tool/index.js'
|
|
4
|
+
import { addressSchema, hash, intentSchema, sourceSchema } from './schema.js'
|
|
5
|
+
import type { PalMessageSender, PalMessageSenderContext } from './types.js'
|
|
6
|
+
|
|
7
|
+
/** Only discovery information explicitly approved for the executing Pal. */
|
|
8
|
+
export interface PalMessagingRecipient {
|
|
9
|
+
readonly palId: string
|
|
10
|
+
readonly name: string
|
|
11
|
+
readonly description?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PalMessagingToolsOptions {
|
|
15
|
+
/** Created by the host from the same captured source; never selected by the model. */
|
|
16
|
+
readonly sender: PalMessageSender
|
|
17
|
+
readonly source: PalMessageSenderContext
|
|
18
|
+
/** Required live admission check, including current pause/retirement and execution scope. */
|
|
19
|
+
readonly assertCurrentAdmission: (context: ToolContext) => void | Promise<void>
|
|
20
|
+
/** Required current visibility policy. No Pal-store or directory-listing fallback exists. */
|
|
21
|
+
readonly listAuthorizedPals: (
|
|
22
|
+
context: ToolContext,
|
|
23
|
+
) => readonly PalMessagingRecipient[] | Promise<readonly PalMessagingRecipient[]>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const sendSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
palId: addressSchema.shape.palId.describe('Recipient Pal ID.'),
|
|
29
|
+
body: intentSchema.shape.body.describe('The explicit message to send.'),
|
|
30
|
+
replyTo: intentSchema.shape.replyTo
|
|
31
|
+
.unwrap()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('An observed incoming Pal message ID, when replying in its conversation.'),
|
|
34
|
+
})
|
|
35
|
+
.strict()
|
|
36
|
+
const listSchema = z.object({}).strict()
|
|
37
|
+
const recipientSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
palId: addressSchema.shape.palId,
|
|
40
|
+
name: z.string().min(1),
|
|
41
|
+
description: z.string().optional(),
|
|
42
|
+
})
|
|
43
|
+
.strict()
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Host-installed tools over an explicitly authorized sender and discovery view.
|
|
47
|
+
* Sending commits an acceptance receipt; it never waits for a recipient turn.
|
|
48
|
+
*/
|
|
49
|
+
export function createPalMessagingTools(options: PalMessagingToolsOptions): ToolDefinition[] {
|
|
50
|
+
if (
|
|
51
|
+
typeof options.sender?.send !== 'function' ||
|
|
52
|
+
typeof options.assertCurrentAdmission !== 'function' ||
|
|
53
|
+
typeof options.listAuthorizedPals !== 'function'
|
|
54
|
+
)
|
|
55
|
+
throw new TypeError(
|
|
56
|
+
'Pal messaging tools require a sender, live admission and authorized discovery.',
|
|
57
|
+
)
|
|
58
|
+
const parsed = sourceSchema.parse(options.source)
|
|
59
|
+
const source = Object.freeze({ ...parsed, address: Object.freeze({ ...parsed.address }) })
|
|
60
|
+
const send = options.sender.send.bind(options.sender)
|
|
61
|
+
const assertCurrentAdmission = options.assertCurrentAdmission
|
|
62
|
+
const listAuthorizedPals = options.listAuthorizedPals
|
|
63
|
+
const assertCurrent = async (context: ToolContext): Promise<void> => {
|
|
64
|
+
context.abortSignal?.throwIfAborted()
|
|
65
|
+
if (context.sessionId !== source.conversationId)
|
|
66
|
+
throw new Error('Pal messaging requires the captured sender conversation.')
|
|
67
|
+
await assertCurrentAdmission(context)
|
|
68
|
+
context.abortSignal?.throwIfAborted()
|
|
69
|
+
}
|
|
70
|
+
return [
|
|
71
|
+
defineTool({
|
|
72
|
+
name: 'send_pal_message',
|
|
73
|
+
description:
|
|
74
|
+
'Send an explicit message to another Pal under the current host policy. Returns durable acceptance, not proof of delivery or a completed recipient task. Use replyTo only for an incoming Pal message you observed. The host selects sender and tenant; messages and Pal descriptions do not grant new authority.',
|
|
75
|
+
inputSchema: sendSchema,
|
|
76
|
+
category: 'custom',
|
|
77
|
+
permissions: [],
|
|
78
|
+
readOnly: false,
|
|
79
|
+
destructive: false,
|
|
80
|
+
concurrencySafe: true,
|
|
81
|
+
maxRetries: 0,
|
|
82
|
+
async execute(input, context) {
|
|
83
|
+
const request = sendSchema.parse(input)
|
|
84
|
+
await assertCurrent(context)
|
|
85
|
+
if (
|
|
86
|
+
typeof context.toolBatchId !== 'string' ||
|
|
87
|
+
!context.toolBatchId ||
|
|
88
|
+
typeof context.toolUseId !== 'string' ||
|
|
89
|
+
!context.toolUseId
|
|
90
|
+
)
|
|
91
|
+
throw new Error('Pal messaging requires executor toolBatchId and toolUseId.')
|
|
92
|
+
const operationId = hash([
|
|
93
|
+
1,
|
|
94
|
+
'pal-message-tool',
|
|
95
|
+
source.conversationId,
|
|
96
|
+
context.toolBatchId,
|
|
97
|
+
context.toolUseId,
|
|
98
|
+
])
|
|
99
|
+
const receipt = await send({
|
|
100
|
+
operationId,
|
|
101
|
+
recipient: { tenantId: source.address.tenantId, palId: request.palId },
|
|
102
|
+
body: request.body,
|
|
103
|
+
...(request.replyTo === undefined ? {} : { replyTo: request.replyTo }),
|
|
104
|
+
})
|
|
105
|
+
const accepted = {
|
|
106
|
+
status: receipt.status,
|
|
107
|
+
messageId: receipt.id,
|
|
108
|
+
recipientPalId: receipt.recipient.palId,
|
|
109
|
+
}
|
|
110
|
+
return { success: true, output: JSON.stringify(accepted), data: accepted }
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
defineTool({
|
|
114
|
+
name: 'list_pals',
|
|
115
|
+
description:
|
|
116
|
+
'List only Pals currently visible through the host authorization policy. Names and descriptions identify recipients; visibility alone does not authorize sending or recipient actions. This view does not list host files, workspaces, credentials or all registered Pals.',
|
|
117
|
+
inputSchema: listSchema,
|
|
118
|
+
category: 'custom',
|
|
119
|
+
permissions: [],
|
|
120
|
+
readOnly: true,
|
|
121
|
+
destructive: false,
|
|
122
|
+
concurrencySafe: true,
|
|
123
|
+
async execute(input, context) {
|
|
124
|
+
listSchema.parse(input)
|
|
125
|
+
await assertCurrent(context)
|
|
126
|
+
const visible = await listAuthorizedPals(context)
|
|
127
|
+
await assertCurrent(context)
|
|
128
|
+
const pals = visible.map((pal) =>
|
|
129
|
+
recipientSchema.parse({
|
|
130
|
+
palId: pal.palId,
|
|
131
|
+
name: pal.name,
|
|
132
|
+
...(pal.description === undefined ? {} : { description: pal.description }),
|
|
133
|
+
}),
|
|
134
|
+
)
|
|
135
|
+
return { success: true, output: JSON.stringify({ pals }), data: { pals } }
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
]
|
|
139
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { SessionLog } from '../../store/session-log/core.js'
|
|
2
|
+
import type { ProjectId, SessionId, TenantId, TurnId } from '../../types/ids/index.js'
|
|
3
|
+
import type {
|
|
4
|
+
DurableInboundSource,
|
|
5
|
+
InboundDeliveryReceipt,
|
|
6
|
+
InboundDeliveryRef,
|
|
7
|
+
} from '../../types/message/inbound-delivery.js'
|
|
8
|
+
import type { PalDefinition, PalStore } from '../types.js'
|
|
9
|
+
|
|
10
|
+
export interface PalAddress {
|
|
11
|
+
readonly tenantId: TenantId
|
|
12
|
+
readonly palId: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** One sender conversation opens a distinct, authorized recipient conversation. */
|
|
16
|
+
export interface PalRouteKey {
|
|
17
|
+
readonly v: 1
|
|
18
|
+
readonly kind: 'pal'
|
|
19
|
+
readonly sender: PalAddress
|
|
20
|
+
readonly senderConversationId: SessionId
|
|
21
|
+
readonly recipient: PalAddress
|
|
22
|
+
readonly dialogKey: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PalRouteBinding {
|
|
26
|
+
readonly id: string
|
|
27
|
+
readonly key: PalRouteKey
|
|
28
|
+
readonly sessionId: SessionId
|
|
29
|
+
readonly profileRevision: number
|
|
30
|
+
readonly revision: number
|
|
31
|
+
readonly phase: 'reserved' | 'active'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PalMessageSenderContext {
|
|
35
|
+
readonly address: PalAddress
|
|
36
|
+
readonly conversationId: SessionId
|
|
37
|
+
readonly profileRevision: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** An audit reference, never a bearer credential or continuing grant. */
|
|
41
|
+
export interface PalMessageGrant {
|
|
42
|
+
readonly id: string
|
|
43
|
+
readonly revision: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface PalMessageIntent {
|
|
47
|
+
readonly id: string
|
|
48
|
+
readonly digest: string
|
|
49
|
+
readonly operationId: string
|
|
50
|
+
readonly source: PalMessageSenderContext
|
|
51
|
+
readonly recipient: PalAddress
|
|
52
|
+
readonly routeKey: PalRouteKey
|
|
53
|
+
readonly body: string
|
|
54
|
+
readonly replyTo: string | null
|
|
55
|
+
readonly grant: PalMessageGrant
|
|
56
|
+
readonly createdAt: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface PalDeliveryClaim {
|
|
60
|
+
readonly id: string
|
|
61
|
+
readonly sessionId: SessionId
|
|
62
|
+
readonly turnId: TurnId
|
|
63
|
+
readonly generation: number
|
|
64
|
+
/** Exact rendered context retained for recovery, including its delimiter nonce. */
|
|
65
|
+
readonly content: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PalInboxMessage extends PalMessageIntent {
|
|
69
|
+
readonly ordinal: number
|
|
70
|
+
readonly routeId: string
|
|
71
|
+
readonly phase: 'pending' | 'claimed' | 'recorded'
|
|
72
|
+
readonly claim: PalDeliveryClaim | null
|
|
73
|
+
readonly receipt: InboundDeliveryReceipt | null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface PalMessageReceipt {
|
|
77
|
+
readonly id: string
|
|
78
|
+
readonly digest: string
|
|
79
|
+
readonly recipient: PalAddress
|
|
80
|
+
readonly routeId: string
|
|
81
|
+
readonly sessionId: SessionId
|
|
82
|
+
readonly ordinal: number
|
|
83
|
+
readonly status: 'accepted'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface PalCommunicationSnapshot {
|
|
87
|
+
readonly recipient: PalAddress
|
|
88
|
+
readonly revision: number
|
|
89
|
+
readonly routes: readonly PalRouteBinding[]
|
|
90
|
+
readonly messages: readonly PalInboxMessage[]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** These methods are a trusted host/store port, never model-visible evidence tools. */
|
|
94
|
+
export interface PalCommunicationStore {
|
|
95
|
+
read(recipient: PalAddress): Promise<PalCommunicationSnapshot | null>
|
|
96
|
+
accept(
|
|
97
|
+
intent: PalMessageIntent,
|
|
98
|
+
recipientRevision: number,
|
|
99
|
+
conversationId?: SessionId,
|
|
100
|
+
): Promise<PalMessageReceipt>
|
|
101
|
+
route(key: PalRouteKey): Promise<PalRouteBinding | null>
|
|
102
|
+
activate(binding: PalRouteBinding, context: PalVerificationContext): Promise<PalRouteBinding>
|
|
103
|
+
claim(
|
|
104
|
+
binding: PalRouteBinding,
|
|
105
|
+
request: {
|
|
106
|
+
readonly turnId: TurnId
|
|
107
|
+
readonly generation: number
|
|
108
|
+
readonly content: (message: PalInboxMessage) => string
|
|
109
|
+
},
|
|
110
|
+
): Promise<PalInboxMessage | null>
|
|
111
|
+
recorded(
|
|
112
|
+
message: PalInboxMessage,
|
|
113
|
+
receipt: InboundDeliveryReceipt,
|
|
114
|
+
context: PalVerificationContext,
|
|
115
|
+
): Promise<PalInboxMessage>
|
|
116
|
+
/** Only a trusted verifier that has fenced the prior writer may invoke this. */
|
|
117
|
+
releaseUnrecorded(
|
|
118
|
+
message: PalInboxMessage,
|
|
119
|
+
context: PalVerificationContext,
|
|
120
|
+
): Promise<PalInboxMessage>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A host ensures the exact pinned Pal root claim; opening does not repair a foreign log. */
|
|
124
|
+
export interface PalConversationAccess {
|
|
125
|
+
readonly log: SessionLog
|
|
126
|
+
readonly projectId: ProjectId
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface PalVerificationContext {
|
|
130
|
+
readonly binding: PalRouteBinding
|
|
131
|
+
readonly access: PalConversationAccess
|
|
132
|
+
readonly definition: PalDefinition
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface PalMessageHostPort {
|
|
136
|
+
ensureConversation(binding: PalRouteBinding, signal: AbortSignal): Promise<void>
|
|
137
|
+
openConversation(binding: PalRouteBinding, signal: AbortSignal): Promise<PalConversationAccess>
|
|
138
|
+
/** Hint only; failure cannot revoke a committed acceptance receipt. */
|
|
139
|
+
notify?(recipient: PalAddress): void | Promise<void>
|
|
140
|
+
wait?(binding: PalRouteBinding, signal: AbortSignal): Promise<void>
|
|
141
|
+
/** Host owns normal query execution and real Pal/computer admission. */
|
|
142
|
+
runConversation(
|
|
143
|
+
binding: PalRouteBinding,
|
|
144
|
+
source: DurableInboundSource,
|
|
145
|
+
signal: AbortSignal,
|
|
146
|
+
): Promise<void>
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type PalMessageAuthorization =
|
|
150
|
+
| { readonly allow: true; readonly grant: PalMessageGrant }
|
|
151
|
+
| { readonly allow: false; readonly reason: string }
|
|
152
|
+
|
|
153
|
+
export interface PalAuthorizationRequest {
|
|
154
|
+
readonly phase: 'send' | 'deliver' | 'wake'
|
|
155
|
+
readonly source: PalMessageSenderContext
|
|
156
|
+
readonly recipient: PalAddress
|
|
157
|
+
readonly routeKey: PalRouteKey
|
|
158
|
+
readonly body: string
|
|
159
|
+
readonly replyTo: string | null
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface PalMessageBrokerOptions {
|
|
163
|
+
readonly store: PalCommunicationStore
|
|
164
|
+
readonly pals: PalStore
|
|
165
|
+
/** Required current sender disclosure AND recipient receive policy. No permissive default. */
|
|
166
|
+
readonly authorize: (request: PalAuthorizationRequest) => Promise<PalMessageAuthorization>
|
|
167
|
+
readonly host?: PalMessageHostPort
|
|
168
|
+
readonly now?: () => number
|
|
169
|
+
readonly onNotificationError?: (
|
|
170
|
+
error: unknown,
|
|
171
|
+
receipt: PalMessageReceipt,
|
|
172
|
+
) => void | Promise<void>
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface PalMessageSender {
|
|
176
|
+
/** Stable captured tool-call/outbox identity; retries must retain it. */
|
|
177
|
+
send(input: {
|
|
178
|
+
readonly operationId: string
|
|
179
|
+
readonly recipient: PalAddress
|
|
180
|
+
readonly body: string
|
|
181
|
+
readonly dialogKey?: string
|
|
182
|
+
readonly replyTo?: string
|
|
183
|
+
}): Promise<PalMessageReceipt>
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type PalDispatchOutcome =
|
|
187
|
+
| { readonly status: 'idle'; readonly reason: 'empty' | 'unresolved' }
|
|
188
|
+
| { readonly status: 'blocked'; readonly reason: string }
|
|
189
|
+
| { readonly status: 'ran'; readonly binding: PalRouteBinding }
|
|
190
|
+
|
|
191
|
+
export interface PalInboxSourceOptions {
|
|
192
|
+
readonly store: PalCommunicationStore
|
|
193
|
+
readonly pals: PalStore
|
|
194
|
+
readonly binding: PalRouteBinding
|
|
195
|
+
readonly host: PalMessageHostPort
|
|
196
|
+
readonly authorize: PalMessageBrokerOptions['authorize']
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export const PAL_MESSAGE_NAMESPACE = 'namzu-pal-message/1'
|
|
200
|
+
|
|
201
|
+
export function palMessageRef(message: Pick<PalInboxMessage, 'id' | 'digest'>): InboundDeliveryRef {
|
|
202
|
+
return { namespace: PAL_MESSAGE_NAMESPACE, id: message.id, digest: message.digest }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function authorizationRequest(
|
|
206
|
+
message: PalMessageIntent,
|
|
207
|
+
phase: PalAuthorizationRequest['phase'],
|
|
208
|
+
): PalAuthorizationRequest {
|
|
209
|
+
return {
|
|
210
|
+
phase,
|
|
211
|
+
source: message.source,
|
|
212
|
+
recipient: message.recipient,
|
|
213
|
+
routeKey: message.routeKey,
|
|
214
|
+
body: message.body,
|
|
215
|
+
replyTo: message.replyTo,
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function sameAddress(one: PalAddress, two: PalAddress): boolean {
|
|
220
|
+
return one.tenantId === two.tenantId && one.palId === two.palId
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function currentRecipient(pals: PalStore, binding: PalRouteBinding): PalDefinition {
|
|
224
|
+
const pal = pals.get(binding.key.recipient.palId)
|
|
225
|
+
if (!pal || pal.paused) throw new Error('Recipient Pal is paused or unavailable.')
|
|
226
|
+
return pals.getRevision(pal.id, binding.profileRevision)
|
|
227
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util'
|
|
2
|
+
import type { SessionLogEntry } from '../../store/session-log/chain.js'
|
|
3
|
+
import type { SessionLogRead } from '../../store/session-log/core.js'
|
|
4
|
+
import type { InboundDeliveryReceipt } from '../../types/message/inbound-delivery.js'
|
|
5
|
+
import type { UserMessage } from '../../types/message/index.js'
|
|
6
|
+
import {
|
|
7
|
+
checkedIngressIntent,
|
|
8
|
+
ingressBindingSchema,
|
|
9
|
+
ingressInboxSchema,
|
|
10
|
+
ingressReceiptSchema,
|
|
11
|
+
ingressRouteId,
|
|
12
|
+
} from './ingress-schema.js'
|
|
13
|
+
import {
|
|
14
|
+
type PalIngressInboxMessage,
|
|
15
|
+
type PalIngressVerificationContext,
|
|
16
|
+
ingressMessageRef,
|
|
17
|
+
ingressRuntimeContextKind,
|
|
18
|
+
} from './ingress-types.js'
|
|
19
|
+
import { freezeCommunicationValue } from './schema.js'
|
|
20
|
+
import type { PalInboxMessage, PalVerificationContext } from './types.js'
|
|
21
|
+
|
|
22
|
+
function capturedContext(input: PalIngressVerificationContext): PalIngressVerificationContext {
|
|
23
|
+
return {
|
|
24
|
+
binding: freezeCommunicationValue(ingressBindingSchema.parse(input.binding)),
|
|
25
|
+
definition: { ...input.definition },
|
|
26
|
+
access: { ...input.access },
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Read original records, never compacted model history or model-supplied evidence. */
|
|
31
|
+
export async function verifyIngressConversation(
|
|
32
|
+
inputContext: PalIngressVerificationContext,
|
|
33
|
+
through?: InboundDeliveryReceipt['through'],
|
|
34
|
+
): Promise<SessionLogRead> {
|
|
35
|
+
const context = capturedContext(inputContext)
|
|
36
|
+
const { binding, access, definition } = context
|
|
37
|
+
if (
|
|
38
|
+
access.log.sessionId !== binding.sessionId ||
|
|
39
|
+
definition.id !== binding.key.recipient.palId ||
|
|
40
|
+
definition.revision !== binding.profileRevision
|
|
41
|
+
)
|
|
42
|
+
throw new Error('Foreign Pal conversation access.')
|
|
43
|
+
const read = await access.log.readAll({
|
|
44
|
+
mode: 'strict',
|
|
45
|
+
...(through ? { expectHead: through.pointer } : {}),
|
|
46
|
+
})
|
|
47
|
+
if (!read.intact || read.tornBytes !== 0)
|
|
48
|
+
throw new Error('Pal conversation has incomplete delivery evidence.')
|
|
49
|
+
if (through) {
|
|
50
|
+
const covered = read.entries.find((entry) => entry.record.seq === through.pointer.seq)
|
|
51
|
+
if (
|
|
52
|
+
!covered ||
|
|
53
|
+
covered.record.gen !== through.gen ||
|
|
54
|
+
through.bytes !== through.pointer.offset + through.pointer.length
|
|
55
|
+
)
|
|
56
|
+
throw new Error('Delivery receipt does not name the actual verified log head.')
|
|
57
|
+
}
|
|
58
|
+
const first = read.entries[0]?.record
|
|
59
|
+
if (
|
|
60
|
+
first?.type !== 'session_started' ||
|
|
61
|
+
first.parent ||
|
|
62
|
+
first.forkedFrom ||
|
|
63
|
+
first.sessionId !== binding.sessionId ||
|
|
64
|
+
first.projectId !== access.projectId ||
|
|
65
|
+
first.tenantId !== binding.key.recipient.tenantId ||
|
|
66
|
+
first.cwd !== definition.workspace ||
|
|
67
|
+
first.origin?.protocol !== 'desktop' ||
|
|
68
|
+
first.origin.externalSessionId !==
|
|
69
|
+
JSON.stringify(['namzu-pal', definition.id, definition.revision, binding.sessionId])
|
|
70
|
+
)
|
|
71
|
+
throw new Error('Conversation is not claimed by the exact Pal and profile revision.')
|
|
72
|
+
return read
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function checkedDelivery(
|
|
76
|
+
input: PalIngressInboxMessage,
|
|
77
|
+
context: PalIngressVerificationContext,
|
|
78
|
+
): PalIngressInboxMessage {
|
|
79
|
+
const message = ingressInboxSchema.parse(input) as PalIngressInboxMessage
|
|
80
|
+
const raw = { ...message } as Record<string, unknown>
|
|
81
|
+
for (const key of ['ordinal', 'routeId', 'phase', 'claim', 'receipt']) delete raw[key]
|
|
82
|
+
checkedIngressIntent(raw)
|
|
83
|
+
if (
|
|
84
|
+
message.routeId !== ingressRouteId(message.routeKey) ||
|
|
85
|
+
context.binding.id !== ingressRouteId(context.binding.key) ||
|
|
86
|
+
context.binding.id !== message.routeId ||
|
|
87
|
+
!isDeepStrictEqual(context.binding.key, message.routeKey) ||
|
|
88
|
+
!message.claim ||
|
|
89
|
+
message.claim.sessionId !== context.binding.sessionId
|
|
90
|
+
)
|
|
91
|
+
throw new Error('Foreign delivery route or claim.')
|
|
92
|
+
return message
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function matches(
|
|
96
|
+
entry: SessionLogEntry,
|
|
97
|
+
message: PalIngressInboxMessage,
|
|
98
|
+
context: PalIngressVerificationContext,
|
|
99
|
+
): Promise<boolean> {
|
|
100
|
+
const record = entry.record
|
|
101
|
+
if (
|
|
102
|
+
!message.claim ||
|
|
103
|
+
record.type !== 'message' ||
|
|
104
|
+
record.role !== 'user' ||
|
|
105
|
+
record.turnId !== message.claim.turnId ||
|
|
106
|
+
record.gen !== message.claim.generation
|
|
107
|
+
)
|
|
108
|
+
return false
|
|
109
|
+
const content = (
|
|
110
|
+
record.spill ? JSON.parse(await context.access.log.readSpill(record.spill)) : record.content
|
|
111
|
+
) as Partial<UserMessage> & { source?: unknown }
|
|
112
|
+
if (
|
|
113
|
+
!content ||
|
|
114
|
+
content.role !== 'user' ||
|
|
115
|
+
content.content !== message.claim.content ||
|
|
116
|
+
!content.source ||
|
|
117
|
+
typeof content.source !== 'object'
|
|
118
|
+
)
|
|
119
|
+
return false
|
|
120
|
+
const source = content.source as {
|
|
121
|
+
type?: unknown
|
|
122
|
+
kind?: unknown
|
|
123
|
+
deliveryRef?: unknown
|
|
124
|
+
}
|
|
125
|
+
return (
|
|
126
|
+
source.type === 'runtime-context' &&
|
|
127
|
+
source.kind === ingressRuntimeContextKind(message) &&
|
|
128
|
+
isDeepStrictEqual(source.deliveryRef, ingressMessageRef(message))
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function findRecordedIngressMessage(
|
|
133
|
+
inputMessage: PalIngressInboxMessage,
|
|
134
|
+
inputContext: PalIngressVerificationContext,
|
|
135
|
+
through?: InboundDeliveryReceipt['through'],
|
|
136
|
+
): Promise<{ read: SessionLogRead; entry: SessionLogEntry | null }> {
|
|
137
|
+
const context = capturedContext(inputContext)
|
|
138
|
+
const message = checkedDelivery(inputMessage, context)
|
|
139
|
+
const read = await verifyIngressConversation(context, through)
|
|
140
|
+
let found: SessionLogEntry | null = null
|
|
141
|
+
for (const entry of read.entries) {
|
|
142
|
+
if (!(await matches(entry, message, context))) continue
|
|
143
|
+
if (found) throw new Error('Pal delivery appears more than once in the conversation log.')
|
|
144
|
+
found = entry
|
|
145
|
+
}
|
|
146
|
+
return { read, entry: found }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function verifyIngressRecorded(
|
|
150
|
+
inputMessage: PalIngressInboxMessage,
|
|
151
|
+
inputReceipt: InboundDeliveryReceipt,
|
|
152
|
+
inputContext: PalIngressVerificationContext,
|
|
153
|
+
): Promise<void> {
|
|
154
|
+
const context = capturedContext(inputContext)
|
|
155
|
+
const message = checkedDelivery(inputMessage, context)
|
|
156
|
+
const receipt = ingressReceiptSchema.parse(inputReceipt)
|
|
157
|
+
if (
|
|
158
|
+
!message.claim ||
|
|
159
|
+
context.binding.id !== message.routeId ||
|
|
160
|
+
!isDeepStrictEqual(context.binding.key, message.routeKey) ||
|
|
161
|
+
!isDeepStrictEqual(receipt.ref, ingressMessageRef(message)) ||
|
|
162
|
+
receipt.claimId !== message.claim.id ||
|
|
163
|
+
receipt.sessionId !== message.claim.sessionId ||
|
|
164
|
+
receipt.turnId !== message.claim.turnId ||
|
|
165
|
+
receipt.through.gen < message.claim.generation
|
|
166
|
+
)
|
|
167
|
+
throw new Error('Foreign delivery route or receipt.')
|
|
168
|
+
const { entry } = await findRecordedIngressMessage(message, context, receipt.through)
|
|
169
|
+
if (
|
|
170
|
+
!entry ||
|
|
171
|
+
entry.record.type !== 'message' ||
|
|
172
|
+
entry.record.messageId !== receipt.messageId ||
|
|
173
|
+
entry.record.seq > receipt.through.pointer.seq
|
|
174
|
+
)
|
|
175
|
+
throw new Error('No matching recorded message covers this Pal delivery receipt.')
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function verifyIngressUnrecorded(
|
|
179
|
+
inputMessage: PalIngressInboxMessage,
|
|
180
|
+
inputContext: PalIngressVerificationContext,
|
|
181
|
+
): Promise<void> {
|
|
182
|
+
const context = capturedContext(inputContext)
|
|
183
|
+
const message = checkedDelivery(inputMessage, context)
|
|
184
|
+
if (!message.claim || context.binding.id !== message.routeId)
|
|
185
|
+
throw new Error('Foreign delivery route.')
|
|
186
|
+
const { entry } = await findRecordedIngressMessage(message, context)
|
|
187
|
+
if (entry) throw new Error('Recorded delivery cannot be released for retry.')
|
|
188
|
+
const lease = await context.access.log.lease()
|
|
189
|
+
const active = await context.access.log.activeTurn()
|
|
190
|
+
if (!lease || lease.fence <= message.claim.generation || active !== null)
|
|
191
|
+
throw new Error('Unrecorded delivery has no proof of a fenced and stopped writer.')
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Legacy Pal-only verification retains its existing signatures. */
|
|
195
|
+
export function verifyConversation(
|
|
196
|
+
context: PalVerificationContext,
|
|
197
|
+
through?: InboundDeliveryReceipt['through'],
|
|
198
|
+
): Promise<SessionLogRead> {
|
|
199
|
+
return verifyIngressConversation(context, through)
|
|
200
|
+
}
|
|
201
|
+
export function findRecordedMessage(
|
|
202
|
+
message: PalInboxMessage,
|
|
203
|
+
context: PalVerificationContext,
|
|
204
|
+
through?: InboundDeliveryReceipt['through'],
|
|
205
|
+
): Promise<{ read: SessionLogRead; entry: SessionLogEntry | null }> {
|
|
206
|
+
return findRecordedIngressMessage(message, context, through)
|
|
207
|
+
}
|
|
208
|
+
export function verifyRecorded(
|
|
209
|
+
message: PalInboxMessage,
|
|
210
|
+
receipt: InboundDeliveryReceipt,
|
|
211
|
+
context: PalVerificationContext,
|
|
212
|
+
): Promise<void> {
|
|
213
|
+
return verifyIngressRecorded(message, receipt, context)
|
|
214
|
+
}
|
|
215
|
+
export function verifyUnrecorded(
|
|
216
|
+
message: PalInboxMessage,
|
|
217
|
+
context: PalVerificationContext,
|
|
218
|
+
): Promise<void> {
|
|
219
|
+
return verifyIngressUnrecorded(message, context)
|
|
220
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Live host facts only: no replay cursor, computer lease, private body or error text. */
|
|
2
|
+
export type PalLifecycleEvent =
|
|
3
|
+
| { readonly type: 'computer.starting'; readonly palId: string }
|
|
4
|
+
| {
|
|
5
|
+
readonly type: 'computer.ready'
|
|
6
|
+
readonly palId: string
|
|
7
|
+
readonly generation: number
|
|
8
|
+
}
|
|
9
|
+
| {
|
|
10
|
+
readonly type: 'computer.stopping' | 'computer.stopped' | 'computer.stop-failed'
|
|
11
|
+
readonly palId: string
|
|
12
|
+
/** Omitted when releasing an invalid rejected lease, never an accepted generation. */
|
|
13
|
+
readonly generation?: number
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
readonly type: 'computer.start-failed'
|
|
17
|
+
readonly palId: string
|
|
18
|
+
readonly reason: 'unavailable' | 'cleanup-required'
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
readonly type: 'admission.acquired'
|
|
22
|
+
readonly palId: string
|
|
23
|
+
readonly generation: number
|
|
24
|
+
readonly conversationId: string
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
readonly type: 'admission.released'
|
|
28
|
+
readonly palId: string
|
|
29
|
+
readonly generation: number
|
|
30
|
+
readonly conversationId: string
|
|
31
|
+
readonly reason: 'released' | 'closed'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type PalLifecycleListener = (event: PalLifecycleEvent) => void | Promise<void>
|
|
35
|
+
|
|
36
|
+
/** Observer failures cannot backpressure or change computer/controller ownership. */
|
|
37
|
+
export class PalLifecycleEmitter {
|
|
38
|
+
private readonly listeners = new Set<PalLifecycleListener>()
|
|
39
|
+
on(listener: PalLifecycleListener): () => void {
|
|
40
|
+
if (typeof listener !== 'function') throw new TypeError('A Pal lifecycle listener is required.')
|
|
41
|
+
this.listeners.add(listener)
|
|
42
|
+
return () => {
|
|
43
|
+
this.listeners.delete(listener)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
emit(event: PalLifecycleEvent): void {
|
|
47
|
+
const captured = Object.freeze({ ...event })
|
|
48
|
+
for (const listener of [...this.listeners]) {
|
|
49
|
+
try {
|
|
50
|
+
void Promise.resolve(listener(captured)).catch(() => {})
|
|
51
|
+
} catch {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|