@sema-agent/core 7.60.0 → 7.62.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 +917 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +71 -12
- package/dist/agents/cascade.js +61 -21
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +49 -10
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +36 -41
- package/dist/agents/subagent.js +245 -200
- package/dist/agents/suspend-guard.d.ts +47 -16
- package/dist/agents/suspend-guard.js +13 -4
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +41 -30
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-requirements.d.ts +33 -5
- package/dist/core/checkpoint-requirements.js +18 -5
- package/dist/core/checkpoint-row-verdict.d.ts +99 -0
- package/dist/core/checkpoint-row-verdict.js +225 -0
- package/dist/core/checkpoint-store.d.ts +107 -738
- package/dist/core/checkpoint-store.js +45 -143
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +68 -21
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +10 -0
- package/dist/core/frame-settlement.js +6 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +4 -3
- package/dist/core/gate-lanes.js +7 -4
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +14 -4
- package/dist/core/governance-codes.js +19 -4
- package/dist/core/hooks.d.ts +25 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +47 -7
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +4 -3
- package/dist/core/locked-config.js +5 -3
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +225 -46
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +6 -49
- package/dist/core/mcp.js +115 -111
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +8 -6
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +94 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +14 -3
- package/dist/core/mods/kernel/events.js +18 -15
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +118 -0
- package/dist/core/mods/session-append.js +318 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +138 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +88 -21
- package/dist/core/mods/stations.js +149 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +68 -2
- package/dist/core/own-property-receipt.js +45 -2
- package/dist/core/park-selfcheck.js +4 -2
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -3
- package/dist/core/runner/assemble-result.js +12 -7
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/compact-session.js +18 -3
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +2 -2
- package/dist/core/runner/contracts.d.ts +116 -34
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.d.ts +15 -0
- package/dist/core/runner/person-path-rows.js +27 -4
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +19 -21
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
- package/dist/core/runner/prepare-hands-readface.js +32 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
- package/dist/core/runner/prepare-inherited-gate.js +10 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +61 -30
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +8 -6
- package/dist/core/runner/resume-admission.js +23 -6
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +14 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +2 -0
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +6 -2
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +64 -36
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +12 -9
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +34 -18
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +33 -17
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +16 -7
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -2
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +8 -2
- package/dist/core/runner/turn-attachments.js +2 -2
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +26 -27
- package/dist/core/secret-env.d.ts +19 -16
- package/dist/core/secret-env.js +45 -27
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +3 -1
- package/dist/core/session-store.js +10 -8
- package/dist/core/session.d.ts +16 -5
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/session-store-contract.js +22 -8
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
- package/dist/core/task-event.d.ts +24 -9
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +89 -14
- package/dist/core/task-registry-agent.d.ts +32 -50
- package/dist/core/task-registry-agent.js +36 -56
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +22 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +5 -21
- package/dist/core/task-registry.d.ts +32 -62
- package/dist/core/task-registry.js +30 -110
- package/dist/core/task-result.d.ts +29 -12
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +11 -11
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +36 -6
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +2 -5
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.js +3 -2
- package/dist/core/tool-face.d.ts +8 -5
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +109 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +23 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +26 -21
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
- package/dist/engine/execution-env/node-execution-env.js +221 -22
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +52 -7
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +29 -18
- package/dist/index.js +19 -11
- package/dist/internal/harness-types.d.ts +2 -0
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +14 -17
- package/dist/orchestration/run-workflow-tool.js +43 -50
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +7 -0
- package/dist/orchestration/workflow.js +10 -12
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +13 -9
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +7 -12
- package/dist/stores/file/index.js +25 -12
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.js +3 -2
- package/dist/stores/file/session-store.d.ts +26 -7
- package/dist/stores/file/session-store.js +59 -35
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +7 -7
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/removal-targets.js +2 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-argv.d.ts +4 -2
- package/dist/tools/fs/shell-read-argv.js +14 -3
- package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
- package/dist/tools/fs/shell-read-bindings.js +148 -68
- package/dist/tools/fs/shell-read-check.js +20 -4
- package/dist/tools/fs/shell-read-establish.js +25 -9
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +8 -0
- package/dist/tools/fs/shell-read-plan.js +47 -30
- package/dist/tools/fs/shell-read-start.d.ts +66 -13
- package/dist/tools/fs/shell-read-start.js +89 -17
- package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
- package/dist/tools/fs/shell-read-workdir.js +31 -8
- package/dist/tools/monitor.d.ts +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +112 -42
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -8,6 +8,8 @@ import { directoryPinOf } from "./dual-root.js";
|
|
|
8
8
|
import { landingPathOf } from "./layout.js";
|
|
9
9
|
import { egressText } from "../untrusted-egress.js";
|
|
10
10
|
import { REDACTION_MARKS } from "../redaction-marks.js";
|
|
11
|
+
const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
|
|
12
|
+
"and entries deleted on one side since the last round come back from the other side";
|
|
11
13
|
const REFUSAL_ROWS = {
|
|
12
14
|
scope: {
|
|
13
15
|
why: "a cursor is the baseline of one (scope, peer) partition",
|
|
@@ -18,8 +20,17 @@ const REFUSAL_ROWS = {
|
|
|
18
20
|
outs: (want) => [
|
|
19
21
|
"re-bind — run this layer over a transport that reaches the peer the cursor was taken against, or, " +
|
|
20
22
|
`only when this transport reaches that same peer under a new identity, set the cursor's peer to ${quoted(want)}`,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
DROP_THE_CURSOR,
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
incarnation: {
|
|
27
|
+
why: "the peer holds another state than the one the baseline was taken against and refused the round before writing, so nothing " +
|
|
28
|
+
"was written on either side — run on that baseline, an entry the peer lacks would land here as a delete and an older copy as a rollback",
|
|
29
|
+
outs: (want) => [
|
|
30
|
+
"re-bind — run this layer against the state the baseline was taken against, or, only when the cursor carries no incarnation " +
|
|
31
|
+
`(it was written before cursors carried one) and this peer holds that same state, set the cursor's peerIncarnation to ${quoted(want)}; ` +
|
|
32
|
+
"a cursor that carries another incarnation is never re-bound to this one",
|
|
33
|
+
DROP_THE_CURSOR,
|
|
23
34
|
],
|
|
24
35
|
},
|
|
25
36
|
store: {
|
|
@@ -50,7 +61,7 @@ function syncRefusal(on, head, want) {
|
|
|
50
61
|
}
|
|
51
62
|
else {
|
|
52
63
|
e.code = "config.memory_sync_cursor_mismatch";
|
|
53
|
-
e.detail = Object.freeze({ axis: on.axis, found: on.found });
|
|
64
|
+
e.detail = Object.freeze({ axis: on.axis, found: on.found, want: carriesCredential(want) ? REDACTION_MARKS.credentials : want });
|
|
54
65
|
}
|
|
55
66
|
e.outs = outs;
|
|
56
67
|
MINTED_REFUSALS.add(e);
|
|
@@ -69,18 +80,23 @@ function syncStoreOf(backend) {
|
|
|
69
80
|
const root = landingPathOf(pin);
|
|
70
81
|
return { root, identity: `file:${root}` };
|
|
71
82
|
}
|
|
83
|
+
function cursorRefusal(axis, got, want) {
|
|
84
|
+
const found = got === undefined ? "absent" : "other";
|
|
85
|
+
const head = found === "absent" ? `cursor has no ${axis} binding` : `cursor is for ${axis} ${quoted(got)}`;
|
|
86
|
+
return syncRefusal({ axis, found }, `${head}; this round's ${axis} is ${quoted(want)}`, want);
|
|
87
|
+
}
|
|
72
88
|
function refuseForeignCursor(cursor, scope, peer, store) {
|
|
73
89
|
const axis = [["scope", cursor.scope, scope], ["peer", cursor.peer, peer], ["store", cursor.store, store]];
|
|
74
90
|
for (const [name, got, want] of axis) {
|
|
75
|
-
if (got
|
|
76
|
-
|
|
77
|
-
const found = got === undefined ? "absent" : "other";
|
|
78
|
-
const head = found === "absent" ? `cursor has no ${name} binding` : `cursor is for ${name} ${quoted(got)}`;
|
|
79
|
-
throw syncRefusal({ axis: name, found }, `${head}; this round's ${name} is ${quoted(want)}`, want);
|
|
91
|
+
if (got !== want)
|
|
92
|
+
throw cursorRefusal(name, got, want);
|
|
80
93
|
}
|
|
81
94
|
}
|
|
95
|
+
function servesClaim(claim, baselineEmpty, incarnation) {
|
|
96
|
+
return claim !== undefined ? claim === incarnation : baselineEmpty;
|
|
97
|
+
}
|
|
82
98
|
function memorySyncPath(scope) {
|
|
83
|
-
return `/
|
|
99
|
+
return `/v2/memory/sync/${encodeURIComponent(scope)}`;
|
|
84
100
|
}
|
|
85
101
|
function baselineStub(id, rev, scope) {
|
|
86
102
|
return { id, rev, scope, slug: `sync-baseline-stub/${id}`, frontmatter: {}, body: "" };
|
|
@@ -93,9 +109,26 @@ function quoted(v) {
|
|
|
93
109
|
return JSON.stringify(typeof v);
|
|
94
110
|
return carriesCredential(v) ? REDACTION_MARKS.credentials : JSON.stringify(v);
|
|
95
111
|
}
|
|
112
|
+
const isAsciiLetter = (c) => (c >= 65 && c <= 90) || (c >= 97 && c <= 122);
|
|
113
|
+
const isSchemeChar = (c) => isAsciiLetter(c) || (c >= 48 && c <= 57) || c === 43 || c === 45 || c === 46;
|
|
114
|
+
const SPECIAL_SCHEMES = new Set(["ftp", "file", "http", "https", "ws", "wss"]);
|
|
96
115
|
export function carriesCredential(peer) {
|
|
97
116
|
if (egressText("same-principal", peer) !== peer)
|
|
98
117
|
return true;
|
|
118
|
+
for (let mark = peer.indexOf("://"); mark !== -1; mark = peer.indexOf("://", mark + 3)) {
|
|
119
|
+
let from = mark;
|
|
120
|
+
while (from > 0 && isSchemeChar(peer.charCodeAt(from - 1)))
|
|
121
|
+
from--;
|
|
122
|
+
while (from < mark && !isAsciiLetter(peer.charCodeAt(from)))
|
|
123
|
+
from++;
|
|
124
|
+
if (from === mark)
|
|
125
|
+
continue;
|
|
126
|
+
const rest = peer.slice(mark + 3);
|
|
127
|
+
const end = rest.search(SPECIAL_SCHEMES.has(peer.slice(from, mark).toLowerCase()) ? /[\s/\\?#]/ : /[\s/?#]/);
|
|
128
|
+
const authority = end === -1 ? rest : rest.slice(0, end);
|
|
129
|
+
if (authority.lastIndexOf("@") > 0)
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
99
132
|
try {
|
|
100
133
|
const url = new URL(peer);
|
|
101
134
|
return url.username !== "" || url.password !== "";
|
|
@@ -104,13 +137,24 @@ export function carriesCredential(peer) {
|
|
|
104
137
|
return false;
|
|
105
138
|
}
|
|
106
139
|
}
|
|
107
|
-
|
|
140
|
+
const isIncarnation = (v) => namesSomething(v) && !carriesCredential(v);
|
|
141
|
+
function parseMemorySyncResponse(raw, scope, peer, claim, baselineEmpty) {
|
|
108
142
|
const fail = (why) => {
|
|
109
143
|
throw new Error(egressText("same-principal", `memory sync: transport response is not a valid sync response (${why})`));
|
|
110
144
|
};
|
|
111
145
|
if (!isRecord(raw))
|
|
112
146
|
fail("body must be a JSON object { applied, conflicts, serverEntries, serverDeletes, cursor }");
|
|
113
147
|
const b = raw;
|
|
148
|
+
if (Object.prototype.hasOwnProperty.call(b, "refused")) {
|
|
149
|
+
if (b["refused"] !== "baseline_incarnation")
|
|
150
|
+
fail(`refused must be "baseline_incarnation" — the one refusal a peer answers a sync with`);
|
|
151
|
+
const incarnation = b["incarnation"];
|
|
152
|
+
if (!isIncarnation(incarnation))
|
|
153
|
+
fail("a refusal's incarnation must be a non-empty string that holds no credential");
|
|
154
|
+
if (servesClaim(claim, baselineEmpty, incarnation))
|
|
155
|
+
fail(`the peer refused a sync its incarnation ${quoted(incarnation)} serves`);
|
|
156
|
+
throw cursorRefusal("incarnation", claim, incarnation);
|
|
157
|
+
}
|
|
114
158
|
const applied = [];
|
|
115
159
|
if (!Array.isArray(b["applied"]))
|
|
116
160
|
fail("applied must be an array");
|
|
@@ -266,10 +310,18 @@ function parseMemorySyncResponse(raw, scope, peer) {
|
|
|
266
310
|
}
|
|
267
311
|
const cur = b["cursor"];
|
|
268
312
|
if (!isRecord(cur))
|
|
269
|
-
fail("cursor must be an object { peer, baseRevs, updatedAtMs }");
|
|
313
|
+
fail("cursor must be an object { peer, incarnation, baseRevs, updatedAtMs }");
|
|
270
314
|
const curRec = cur;
|
|
271
315
|
if (curRec["peer"] !== peer)
|
|
272
316
|
fail(`cursor.peer ${quoted(curRec["peer"])} does not match the requested peer ${quoted(peer)}`);
|
|
317
|
+
const incarnation = curRec["incarnation"];
|
|
318
|
+
if (!isIncarnation(incarnation))
|
|
319
|
+
fail("cursor.incarnation must be a non-empty string that holds no credential — the incarnation of the state that answered");
|
|
320
|
+
if (!servesClaim(claim, baselineEmpty, incarnation)) {
|
|
321
|
+
fail(claim !== undefined
|
|
322
|
+
? `cursor.incarnation ${quoted(incarnation)} does not match the requested peerIncarnation ${quoted(claim)}`
|
|
323
|
+
: `the request carried a non-empty baseline and no peerIncarnation, which a peer answers only by refusing it — not with a result under ${quoted(incarnation)}`);
|
|
324
|
+
}
|
|
273
325
|
if (!isRecord(curRec["baseRevs"]))
|
|
274
326
|
fail("cursor.baseRevs must be an object mapping id → rev");
|
|
275
327
|
const baseRevs = {};
|
|
@@ -289,7 +341,7 @@ function parseMemorySyncResponse(raw, scope, peer) {
|
|
|
289
341
|
conflicts,
|
|
290
342
|
serverEntries,
|
|
291
343
|
serverDeletes,
|
|
292
|
-
cursor: { peer, baseRevs, updatedAtMs: updatedAtMs },
|
|
344
|
+
cursor: { peer, incarnation: incarnation, baseRevs, updatedAtMs: updatedAtMs },
|
|
293
345
|
...(pullTruncatedRaw === true ? { pullTruncated: true } : {}),
|
|
294
346
|
};
|
|
295
347
|
}
|
|
@@ -307,6 +359,11 @@ export async function syncMemoryScope(opts) {
|
|
|
307
359
|
const { root: storeRoot, identity: store } = syncStoreOf(backend);
|
|
308
360
|
if (cursor !== undefined)
|
|
309
361
|
refuseForeignCursor(cursor, scope, peer, store);
|
|
362
|
+
const claimed = cursor === undefined ? undefined : cursor.peerIncarnation;
|
|
363
|
+
if (claimed !== undefined && !isIncarnation(claimed)) {
|
|
364
|
+
throw new Error(`memory sync: cursor.peerIncarnation must be a non-empty string that holds no credential when present — it is the incarnation a peer answered a sync with, carried back verbatim`);
|
|
365
|
+
}
|
|
366
|
+
const claim = claimed;
|
|
310
367
|
for (const [name, v] of [["maxPushEntries", opts.maxPushEntries], ["maxPullEntries", opts.maxPullEntries], ["maxEntryBytes", opts.maxEntryBytes]]) {
|
|
311
368
|
if (v !== undefined && (!Number.isSafeInteger(v) || v < 1)) {
|
|
312
369
|
throw new Error(`memory sync: ${name} must be a positive integer (>= 1) when set, got ${String(v)}`);
|
|
@@ -348,12 +405,13 @@ export async function syncMemoryScope(opts) {
|
|
|
348
405
|
}
|
|
349
406
|
const request = {
|
|
350
407
|
peer,
|
|
408
|
+
...(claim !== undefined ? { peerIncarnation: claim } : {}),
|
|
351
409
|
baseRevs,
|
|
352
410
|
entries: pushEntries,
|
|
353
411
|
deletes: plan.deleteRemote.map((d) => d.id),
|
|
354
412
|
...(opts.maxPullEntries !== undefined ? { pull: { limit: opts.maxPullEntries } } : {}),
|
|
355
413
|
};
|
|
356
|
-
const resp = parseMemorySyncResponse(await transport.post(memorySyncPath(scope), request), scope, peer);
|
|
414
|
+
const resp = parseMemorySyncResponse(await transport.post(memorySyncPath(scope), request), scope, peer, claim, Object.keys(baseRevs).length === 0);
|
|
357
415
|
const conflicts = [...pushGateConflicts, ...resp.conflicts.map((c) => ({ side: "server", ...c }))];
|
|
358
416
|
const rejected = new Set();
|
|
359
417
|
const localIds = new Set(local.map((e) => e.id));
|
|
@@ -482,7 +540,7 @@ export async function syncMemoryScope(opts) {
|
|
|
482
540
|
nextBaseRevs[op.id] = landedRev;
|
|
483
541
|
}
|
|
484
542
|
}
|
|
485
|
-
nextCursor = { scope, peer, store, baseRevs: nextBaseRevs, updatedAtMs: now() };
|
|
543
|
+
nextCursor = { scope, peer, peerIncarnation: resp.cursor.incarnation, store, baseRevs: nextBaseRevs, updatedAtMs: now() };
|
|
486
544
|
}
|
|
487
545
|
return {
|
|
488
546
|
ok: cursorAdvanced && conflicts.length === 0,
|
|
@@ -22,11 +22,14 @@ export type MemorySyncLayerReport = {
|
|
|
22
22
|
} | {
|
|
23
23
|
readonly outcome: "refused";
|
|
24
24
|
readonly code: "config.memory_sync_cursor_mismatch" | "config.memory_sync_store";
|
|
25
|
-
/** Present on a cursor refusal: the axis it was refused on
|
|
26
|
-
* (`absent`) or another one (`other`)
|
|
25
|
+
/** Present on a cursor refusal: the axis it was refused on, whether the cursor carried no binding there
|
|
26
|
+
* (`absent`) or another one (`other`), and this call's value on it (`want`: the scope, the transport's peer,
|
|
27
|
+
* the local store's identity, or the incarnation of the peer state that answered — as the sentence shows it: one
|
|
28
|
+
* that holds a credential is the credentials mark alone). */
|
|
27
29
|
readonly detail?: {
|
|
28
|
-
readonly axis: "scope" | "peer" | "store";
|
|
30
|
+
readonly axis: "scope" | "peer" | "store" | "incarnation";
|
|
29
31
|
readonly found: "absent" | "other";
|
|
32
|
+
readonly want: string;
|
|
30
33
|
};
|
|
31
34
|
/** The two ways out the sentence names — both the host's to take, the engine takes neither. */
|
|
32
35
|
readonly outs: readonly [string, string];
|
|
@@ -90,7 +93,7 @@ export declare function memorySyncReportOf(round: {
|
|
|
90
93
|
})): MemorySyncRoundReport;
|
|
91
94
|
/**
|
|
92
95
|
* What of a session's memory does not travel with it: every scope of the report's read set that did not arrive whole,
|
|
93
|
-
* once, with why — `refused` (the sync, or its layer, was refused
|
|
96
|
+
* once, with why — `refused` (the sync, or its layer's last call, was refused and wrote nothing on either side), `failed`, `incomplete`,
|
|
94
97
|
* `not_replicated` (no layer was run for it), or `not_read_at_destination` (its layer synced, and the destination's
|
|
95
98
|
* read set, when given, does not hold it). A scope absent from the result travelled. Keys are compared as written. A
|
|
96
99
|
* report that is not one this engine's `memorySyncReportOf` could have minted (a layer with no scope, outside the read
|
|
@@ -11,13 +11,21 @@ export interface MemorySyncCursor {
|
|
|
11
11
|
/** The identity of the PEER the baseline was taken against (`MemorySyncTransport.peer`); a round over
|
|
12
12
|
* another peer refuses the cursor. One cursor per peer. */
|
|
13
13
|
peer: string;
|
|
14
|
+
/** WHICH STATE of that peer the baseline was taken against: the opaque incarnation the peer answered the last
|
|
15
|
+
* completed sync with (`MemorySyncResponseBody.cursor.incarnation`). Every later sync carries it back as its
|
|
16
|
+
* claim (`MemorySyncRequestBody.peerIncarnation`), and the peer — the side holding that state — compares the claim
|
|
17
|
+
* with its own before it writes anything, refusing when they differ or when the baseline is not empty and no
|
|
18
|
+
* claim is made (a cursor written before cursors carried this member). The same address can answer from another
|
|
19
|
+
* state (a rebuilt or restored center): the address says where the sync goes, this says which state answers it.
|
|
20
|
+
* Persist it verbatim; the engine never mints, derives or compares it. */
|
|
21
|
+
peerIncarnation: string;
|
|
14
22
|
/** The LOCAL store the baseline was taken against (minted by `memorySyncStoreOf`, sync-client.ts).
|
|
15
23
|
* A sync over any other store refuses the cursor: the baseline describes another store's
|
|
16
24
|
* entries, and an id it holds that this store lacks would be pushed as a delete. Persist it
|
|
17
25
|
* verbatim with the rest of the cursor; the host rebinds it (this member set to the new store's
|
|
18
26
|
* identity) only when the new store holds the entries the baseline was taken over. */
|
|
19
27
|
store: string;
|
|
20
|
-
/** id → rev at the last completed sync
|
|
28
|
+
/** id → rev at the last completed sync with this peer (in the state {@link peerIncarnation} names). */
|
|
21
29
|
baseRevs: Record<string, string>;
|
|
22
30
|
/** Caller-injected clock (never Date.now inside the engine — clock-injection precedent). */
|
|
23
31
|
updatedAtMs: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* design/81 Slice 5 — the shared distance primitives for the consolidation `searchScored` retrieval, extracted
|
|
3
3
|
* BYTE-IDENTICAL from the original PgMemoryStore implementation so the File (portable/TOC) and Pg (native/TOB)
|
|
4
|
-
* backends rank on ONE source of truth and can't drift. The
|
|
4
|
+
* backends rank on ONE source of truth and can't drift. The consolidation
|
|
5
5
|
* band `{0.05, 0.3}` is defined on this cosine-distance scale; the lexical `1 - Jaccard ∈ [0,1] ⊂ [0,2]` is the
|
|
6
6
|
* same-zero-point stand-in used when no embedding vector is present (fail-open per row).
|
|
7
7
|
*
|
package/dist/core/memory.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ScoredMemory {
|
|
|
16
16
|
/** design/84 Seam B (前置 BLOCKER): true when this note was CREATED by a consolidation ADD (not the
|
|
17
17
|
* `remember` tool / a caller). Periodic/incremental consolidation EXCLUDES these from its candidate set so
|
|
18
18
|
* it never re-consolidates its own output (infinite re-merge). Stores that don't track it leave it absent
|
|
19
|
-
* (treated as not-generated — back-compat, RL-1654-
|
|
19
|
+
* (treated as not-generated — back-compat, RL-1654-store-family: the inline task-end path already excludes this-task notes by id). */
|
|
20
20
|
consolidationGenerated?: boolean;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -86,7 +86,7 @@ export interface MemoryStore {
|
|
|
86
86
|
*/
|
|
87
87
|
searchScored?(scope: string, query: string, limit?: number): Promise<ScoredMemory[]> | ScoredMemory[];
|
|
88
88
|
/** The vector-ranking rung this store achieves (design/81 Slice 5). Absent ⇒ treated as `"lexical"`
|
|
89
|
-
* (back-compat, RL-1654-
|
|
89
|
+
* (back-compat, RL-1654-store-family). A runtime observable — a deployment reads it to decide index/metrics, NOT to decide
|
|
90
90
|
* whether to inject an embedder (injection is config-driven; this is the RESULT). See {@link MemoryVectorMode}. */
|
|
91
91
|
readonly vectorMode?: MemoryVectorMode;
|
|
92
92
|
/** Optional: replace a note's text by id (consolidation UPDATE). The id stays stable. Must be safe
|
|
@@ -125,8 +125,8 @@ export interface MemoryStore {
|
|
|
125
125
|
*/
|
|
126
126
|
appendPromotable?(scope: string, note: StructuredNoteInput, utilityVerdict: unknown): Promise<string> | string;
|
|
127
127
|
/**
|
|
128
|
-
* **INTERNAL consolidation-only door** for the design/84 Seam B marker.
|
|
129
|
-
* it
|
|
128
|
+
* **INTERNAL consolidation-only door** for the design/84 Seam B marker. A consolidation pass (and ONLY
|
|
129
|
+
* it; none ships in the package any more) calls this to materialize a merged "add" decision tagged
|
|
130
130
|
* `consolidationGenerated:true`, so a later periodic/incremental pass EXCLUDES its own output from the
|
|
131
131
|
* candidate set (no infinite re-merge). It is the COUNTERPART to the {@link guardedMemoryStore} boundary
|
|
132
132
|
* defense: the public {@link appendStructured} STRIPS a caller-supplied `consolidationGenerated` (an
|
|
@@ -146,13 +146,13 @@ export interface MemoryStore {
|
|
|
146
146
|
* reference stores it is a note **id** (uuidv7 — lexicographically time-sortable), so "after the cursor"
|
|
147
147
|
* is a simple string `>` comparison. Returns `undefined` when no pass has run yet (⇒ the WHOLE scope is
|
|
148
148
|
* pending — the first pass sweeps it all). PAIR with {@link setConsolidationCursor}: a store implements
|
|
149
|
-
* BOTH or NEITHER ({@link supportsPeriodicConsolidation});
|
|
150
|
-
*
|
|
149
|
+
* BOTH or NEITHER ({@link supportsPeriodicConsolidation}); the package no longer ships the pass that read it
|
|
150
|
+
* (the store family that keeps it is on RL-1654-store-family).
|
|
151
151
|
*/
|
|
152
152
|
getConsolidationCursor?(scope: string): Promise<string | undefined> | string | undefined;
|
|
153
153
|
/**
|
|
154
154
|
* design/84 Seam B — persist the periodic/incremental consolidation cursor for `scope` (decision 3). Called
|
|
155
|
-
* by
|
|
155
|
+
* by a consolidation pass ONLY after it succeeds in full, advancing the cursor to the max ordering
|
|
156
156
|
* marker the pass observed (seen note ids ∪ added ids). Must be durable (a later pass reads it back). PAIR
|
|
157
157
|
* with {@link getConsolidationCursor}.
|
|
158
158
|
*/
|
|
@@ -183,7 +183,7 @@ export interface StructuredNoteInput {
|
|
|
183
183
|
outcomeStats?: unknown;
|
|
184
184
|
/**
|
|
185
185
|
* design/84 Seam B (前置 BLOCKER): mark a note as CREATED BY A CONSOLIDATION ADD. Set ONLY by
|
|
186
|
-
*
|
|
186
|
+
* a consolidation pass (none ships in the package any more) when it materializes a merged
|
|
187
187
|
* "add" decision — never by the `remember` tool or a normal caller. A store persists it (and surfaces it on
|
|
188
188
|
* {@link ScoredMemory}/{@link MemoryNoteHeader}) so periodic/incremental consolidation can EXCLUDE these
|
|
189
189
|
* notes from its candidate set and not re-consolidate its own output forever. It does NOT affect the
|
|
@@ -245,7 +245,7 @@ export type PeriodicConsolidationCapableStore = MemoryStore & Required<Pick<Memo
|
|
|
245
245
|
/**
|
|
246
246
|
* True when a store implements the design/84 Seam B cursor PAIR
|
|
247
247
|
* ({@link MemoryStore.getConsolidationCursor}/{@link MemoryStore.setConsolidationCursor}). Periodic/incremental
|
|
248
|
-
* consolidation (
|
|
248
|
+
* consolidation (a pass the package no longer ships) GATES on this: a store missing
|
|
249
249
|
* either method makes a periodic pass a safe **NO-OP** (never a silent full re-consolidation of the whole
|
|
250
250
|
* scope, which would re-merge already-consolidated notes forever). Both-or-neither — a store implementing
|
|
251
251
|
* only one is treated as unsupported. Independent of {@link supportsConsolidation} (the id-addressable trio),
|
|
@@ -437,7 +437,7 @@ export declare function expandLexicalTerms(term: string): string[];
|
|
|
437
437
|
* Matching rule: tokenize `text` on word boundaries, then for each whitespace-separated `query` term the
|
|
438
438
|
* text must match AT LEAST ONE of that term's {@link expandLexicalTerms} variants (OR within a term), and
|
|
439
439
|
* EVERY query term must match (AND across terms). The ORIGINAL query term keeps its pre-Slice-2b SUBSTRING
|
|
440
|
-
* semantics (back-compat, RL-1654-
|
|
440
|
+
* semantics (back-compat, RL-1654-store-family); the EXPANDED synonym/stem variants are matched on WORD BOUNDARIES (set membership
|
|
441
441
|
* over the text's token set) so a short injected synonym like "key"/"db" cannot substring-match an unrelated
|
|
442
442
|
* word ("keyboard"/"double"). An empty/whitespace-only query never matches.
|
|
443
443
|
*/
|
|
@@ -166,15 +166,15 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
|
|
|
166
166
|
readonly decision?: string;
|
|
167
167
|
} | undefined): PermissionMode | undefined;
|
|
168
168
|
/**
|
|
169
|
-
* The permission MODE's door —
|
|
170
|
-
* absence (a mode a caller believes it declared must not silently run as another): a
|
|
171
|
-
* (`config.spec_retired_key` — `autoModeRequested` / `approverPosture` are one key now); a `permissionMode` outside
|
|
169
|
+
* The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
|
|
170
|
+
* absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
|
|
172
171
|
* the closed set (`config.permission_mode_invalid`); a `shellGate` value other than the floor word `"always"`
|
|
173
|
-
* (`config.shell_gate_value_retired` — `"off"` / `"classify"` were a doctrine the mode arbitration replaced).
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
172
|
+
* (`config.shell_gate_value_retired` — `"off"` / `"classify"` were a doctrine the mode arbitration replaced). A RETIRED
|
|
173
|
+
* mode key (`autoModeRequested` / `approverPosture` — one key now) is refused by the spec's one read (`readCallerSpec`,
|
|
174
|
+
* `config.spec_retired_key`), before this door. The value it screened is the value it RETURNS — the mode seat reads this
|
|
175
|
+
* snapshot, never the spec again. The ONE function both entrances call: prepare (the run's read of its spec, before the
|
|
176
|
+
* config doors rebind it, in its pre-first-await stretch) and the resume ladder's admission rung (the re-supplied
|
|
177
|
+
* config's read, before the claim) — a resume prepare would refuse is refused before it consumes the row.
|
|
178
178
|
*/
|
|
179
179
|
export declare function refusePermissionModeDoors(spec: Pick<TaskSpec, "permissionMode" | "shellGate">): PermissionMode | undefined;
|
|
180
180
|
/** The resume's ONE refusal channel for a door prepare would refuse at: runs `screen` (prepare's own function, which throws prepare's sentence and code) and
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createFsWriteGatePolicy } from "./fs-write-gate-policy.js";
|
|
2
2
|
import { isProtectedWrite } from "./tool-registry.js";
|
|
3
3
|
import { answeredFor } from "./tool-policy.js";
|
|
4
|
+
import { attest } from "./engine-attestation.js";
|
|
4
5
|
import { rosterEntryNamed, toolCallFaceOf } from "./tool-roster.js";
|
|
5
6
|
import { wireOf } from "./tool-name-readings.js";
|
|
6
7
|
import { clampPermissionMode, isPermissionMode, PERMISSION_MODES } from "./ask-origin.js";
|
|
7
8
|
import { argvOf, lexShellText } from "../shell/lex.js";
|
|
8
9
|
import { COMMAND_RULE_TOOL } from "./permission-rule-model.js";
|
|
9
10
|
import { createSafeNotifier } from "./safe-notify.js";
|
|
10
|
-
import {
|
|
11
|
-
import { CheckpointError, isCheckpointConfigRefusalCode } from "./checkpoint-store.js";
|
|
11
|
+
import { CheckpointError, isCheckpointConfigRefusalCode } from "./checkpoint-features.js";
|
|
12
12
|
export const PERMISSION_MODE_FOLD_REASONS = Object.freeze(["operator_deny", "face_absent", "inherited_ceiling"]);
|
|
13
13
|
export const ACCEPT_EDITS_FILE_COMMANDS = Object.freeze(["mkdir", "touch", "rm", "rmdir", "mv", "cp", "sed"]);
|
|
14
14
|
const MODE_POLICY_TABLE = {
|
|
@@ -74,13 +74,16 @@ export function modeQuestionReaches(mode, roster, toolName, seat) {
|
|
|
74
74
|
const call = { toolName, args: {}, toolCallId: "", ...(face !== undefined ? { face } : {}) };
|
|
75
75
|
return policy.writeGate === "plan" ? planRefusesWrite(call, roster) : isProtectedWrite(call);
|
|
76
76
|
}
|
|
77
|
-
const planAsk = (message
|
|
77
|
+
const planAsk = (message, call, generic) => {
|
|
78
|
+
const asked = { action: "ask", message, decisionReason: "mode" };
|
|
79
|
+
return generic ? attest(asked, call, { genericQuestion: message }) : asked;
|
|
80
|
+
};
|
|
78
81
|
export function createModeGatePolicy(modeRef, seats) {
|
|
79
82
|
const askGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask" });
|
|
80
83
|
const acceptSeat = seats.acceptDirs;
|
|
81
84
|
const acceptDirs = typeof acceptSeat === "function" ? acceptSeat : acceptSeat !== undefined && acceptSeat.length > 0 ? [...acceptSeat] : [seats.rootPath];
|
|
82
85
|
const acceptRootGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, acceptDirs, defaultWrite: "ask" });
|
|
83
|
-
const planGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask", defaultAsk: (path, note) => planAsk(`Cannot write to ${path} while in plan mode.${note ?? ""}
|
|
86
|
+
const planGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask", defaultAsk: (path, note, call) => planAsk(`Cannot write to ${path} while in plan mode.${note ?? ""}`, call, note === undefined) });
|
|
84
87
|
return {
|
|
85
88
|
async check(req, signal) {
|
|
86
89
|
const gate = modePolicyOf(modeRef.current).writeGate;
|
|
@@ -90,7 +93,7 @@ export function createModeGatePolicy(modeRef, seats) {
|
|
|
90
93
|
if (!planRefusesWrite(req, seats.roster?.current, seats.readOnlyDeclared))
|
|
91
94
|
return { action: "allow" };
|
|
92
95
|
if (!isProtectedWrite(req))
|
|
93
|
-
return planAsk(`Cannot call ${req.toolName} while in plan mode
|
|
96
|
+
return planAsk(`Cannot call ${req.toolName} while in plan mode.`, req, true);
|
|
94
97
|
return planGate.check(req, signal);
|
|
95
98
|
}
|
|
96
99
|
return (gate === "ask" ? askGate : acceptRootGate).check(req, signal);
|
|
@@ -104,7 +107,6 @@ export function modeRequestAfterResume(seat, recorded, outcome) {
|
|
|
104
107
|
return seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
|
|
105
108
|
}
|
|
106
109
|
export function refusePermissionModeDoors(spec) {
|
|
107
|
-
assertNoRetiredKeys(spec, RETIRED_TASK_SPEC_KEYS, "TaskSpec");
|
|
108
110
|
const mode = spec.permissionMode;
|
|
109
111
|
if (mode !== undefined && !isPermissionMode(mode)) {
|
|
110
112
|
const e = new Error(`permissionMode must be one of ${PERMISSION_MODES.map((w) => JSON.stringify(w)).join(", ")} when present (got ${JSON.stringify(mode)}) — omit it for the default mode; an unrecognized word is refused rather than read as any mode.`);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { type ModCallEntry } from "./kernel/index.js";
|
|
1
2
|
import type { HookInvocationIdentity } from "../hooks.js";
|
|
2
3
|
import type { PermissionMode } from "../ask-origin.js";
|
|
3
4
|
import { type LegModBus } from "./stations.js";
|
|
5
|
+
import { type ToolCallEntryInput } from "./tool-call.js";
|
|
4
6
|
/** One agent type as the model is offered it. */
|
|
5
7
|
export interface OfferedAgent {
|
|
6
8
|
readonly name: string;
|
|
@@ -8,15 +10,19 @@ export interface OfferedAgent {
|
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* The offered set — the ONE reading of "which agent types is the model offered": each type the chain does not answer
|
|
11
|
-
* `{ isOffered: false }`, in the order given.
|
|
12
|
-
* itself could not raise offers the type (an observation of the offer is never what hides it).
|
|
13
|
+
* `{ isOffered: false }`, in the order given. A seat nothing hears ({@link seatHears}), no dispatch: the types as given.
|
|
14
|
+
* A dispatch the engine itself could not raise offers the type (an observation of the offer is never what hides it).
|
|
13
15
|
*/
|
|
14
|
-
export declare function offeredAgents<A extends OfferedAgent>(
|
|
16
|
+
export declare function offeredAgents<A extends OfferedAgent>(seat: {
|
|
17
|
+
readonly bus: LegModBus;
|
|
18
|
+
} | undefined, agents: readonly A[], signal: AbortSignal | undefined): Promise<readonly A[]>;
|
|
15
19
|
/** A rendered agent listing read through the offered set: the same listing when every type is offered, else a copy with the
|
|
16
20
|
* types the chain hid left out — what a listing frame renders, commits and mirrors. */
|
|
17
21
|
export declare function offeredAgentListing<L extends {
|
|
18
22
|
readonly entries: readonly OfferedAgent[];
|
|
19
|
-
}>(
|
|
23
|
+
}>(seat: {
|
|
24
|
+
readonly bus: LegModBus;
|
|
25
|
+
} | undefined, listing: L | undefined, signal: AbortSignal | undefined): Promise<L | undefined>;
|
|
20
26
|
/** What the delegation decided about the subagent it is about to start, as `agent.spawn` names it. */
|
|
21
27
|
export interface AgentSpawnFacts {
|
|
22
28
|
/** The delegation call this spawn belongs to. */
|
|
@@ -45,6 +51,17 @@ export type AgentSpawnVerdict = {
|
|
|
45
51
|
readonly by: string;
|
|
46
52
|
readonly reason: string;
|
|
47
53
|
};
|
|
54
|
+
/** The model a started subagent is named by: the one the delegation settled, `inherit` when the child's own prepare decides —
|
|
55
|
+
* what `agent.spawn`'s bottom comes up as and what `$.agent.spawn` answers. */
|
|
56
|
+
export declare function spawnedModel(model: string | undefined): string;
|
|
57
|
+
/** The extension's own spawn a delegation call is ({@link AgentStations.extensionSpawn}): who asked, and the one write of "started". */
|
|
58
|
+
export interface ExtensionSpawn {
|
|
59
|
+
/** The registration that called `$.agent.spawn`. */
|
|
60
|
+
readonly by: string;
|
|
61
|
+
/** The subagent was let run under `agentId` — its registry task id, which is its leg's task id and so its events' `agentId`;
|
|
62
|
+
* `model` is the one the delegation settled (`undefined` ⇒ the child's prepare decides). Written once. */
|
|
63
|
+
launched(agentId: string, model: string | undefined): void;
|
|
64
|
+
}
|
|
48
65
|
/** The delegating leg's two agent stations, as its delegation tools read them (a Runner-filled seat, never a model argument). */
|
|
49
66
|
export interface AgentStations {
|
|
50
67
|
/** Whether a handler hangs on the event — a caller with nothing to raise reads none (no await on its path). */
|
|
@@ -53,6 +70,10 @@ export interface AgentStations {
|
|
|
53
70
|
offered<A extends OfferedAgent>(agents: readonly A[], signal: AbortSignal | undefined): Promise<readonly A[]>;
|
|
54
71
|
/** Raise `agent.spawn` (no handler ⇒ nothing raised: the subagent may start). */
|
|
55
72
|
spawn(facts: AgentSpawnFacts, signal: AbortSignal | undefined): Promise<AgentSpawnVerdict>;
|
|
73
|
+
/** The extension's own call (`$.agent.spawn`) the delegation call `toolCallId` is, on this leg — undefined for any other call
|
|
74
|
+
* (the model's, or a tool's an extension called with `$.tool.call` that runs the delegation in its body). The one reading of
|
|
75
|
+
* "an extension asked for this spawn": read once per call. */
|
|
76
|
+
extensionSpawn(toolCallId: string | undefined): ExtensionSpawn | undefined;
|
|
56
77
|
}
|
|
57
78
|
export interface AgentStationsInput {
|
|
58
79
|
readonly bus: LegModBus;
|
|
@@ -63,3 +84,17 @@ export interface AgentStationsInput {
|
|
|
63
84
|
}
|
|
64
85
|
/** The leg's agent stations over its bus. */
|
|
65
86
|
export declare function createAgentStations(input: AgentStationsInput): AgentStations;
|
|
87
|
+
/** What `$.agent.spawn`'s host entry runs a spawn on: the leg's harness (the loop's pipeline under the running prompt), the
|
|
88
|
+
* names its live roster mounts, and the tools as the caller handed them (a delegation tool is known by its `execute`). */
|
|
89
|
+
export interface AgentSpawnEntryInput extends Pick<ToolCallEntryInput, "bus" | "harness" | "specOf"> {
|
|
90
|
+
/** The names the leg's live roster mounts. */
|
|
91
|
+
readonly mounted: () => readonly string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `$.agent.spawn`'s host entry (see the module header): the leg's one delegation tool, run through the loop's per-call pipeline as
|
|
95
|
+
* the caller's call. It answers off the call's record: started ⇒ `{ model, agentId }` (whatever the post-execution stations did to
|
|
96
|
+
* the result); not started and refused or failed ⇒ `{ deny: <the result's text> }`; not started with no error (an extension answered
|
|
97
|
+
* the call in place of its body) ⇒ `{ model }`, no `agentId`. It throws on an empty prompt, and when the leg mounts no delegation
|
|
98
|
+
* tool or more than one (it names them; it never picks).
|
|
99
|
+
*/
|
|
100
|
+
export declare function createAgentSpawnEntry(input: AgentSpawnEntryInput): ModCallEntry;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { ENGINE_ORIGIN } from "./kernel/index.js";
|
|
2
3
|
import { isPlainRecord } from "./kernel/receive.js";
|
|
3
4
|
import { NEXT_IN_FLIGHT } from "./kernel/site-rules.js";
|
|
4
5
|
import { describeThrown } from "../tool-policy.js";
|
|
5
6
|
import { extensionWords } from "../untrusted-egress.js";
|
|
6
|
-
import {
|
|
7
|
+
import { declaredDelegationNameOf } from "../delegation-name.js";
|
|
8
|
+
import { failedHandlerClause, seatHears } from "./stations.js";
|
|
9
|
+
import { agentIdOf } from "../leg-identity.js";
|
|
10
|
+
import { extensionCallOf, noteExtensionCallLaunched, runExtensionCall } from "./extension-call.js";
|
|
11
|
+
import { resultText } from "./tool-call.js";
|
|
7
12
|
const ENGINE_PROVIDER = Object.freeze({ plugin: ENGINE_ORIGIN.plugin, tier: ENGINE_ORIGIN.tier });
|
|
8
13
|
const OFFERED = Object.freeze({ isOffered: true });
|
|
9
14
|
function offerAnswer(answer) {
|
|
@@ -11,14 +16,14 @@ function offerAnswer(answer) {
|
|
|
11
16
|
return "agent.offer takes next(e) or { isOffered: <boolean> }";
|
|
12
17
|
return undefined;
|
|
13
18
|
}
|
|
14
|
-
export async function offeredAgents(
|
|
15
|
-
if (
|
|
19
|
+
export async function offeredAgents(seat, agents, signal) {
|
|
20
|
+
if (agents.length === 0 || !seatHears(seat, "agent.offer"))
|
|
16
21
|
return agents;
|
|
17
22
|
const out = [];
|
|
18
23
|
for (const a of agents) {
|
|
19
24
|
let outcome;
|
|
20
25
|
try {
|
|
21
|
-
outcome = await bus.dispatch("agent.offer", { agent: a.name, description: a.description, provider: ENGINE_PROVIDER }, { bottom: () => OFFERED, checkAnswer: offerAnswer, ...(signal !== undefined ? { signal } : {}) });
|
|
26
|
+
outcome = await seat.bus.dispatch("agent.offer", { agent: a.name, description: a.description, provider: ENGINE_PROVIDER }, { bottom: () => OFFERED, checkAnswer: offerAnswer, ...(signal !== undefined ? { signal } : {}) });
|
|
22
27
|
}
|
|
23
28
|
catch {
|
|
24
29
|
out.push(a);
|
|
@@ -30,22 +35,31 @@ export async function offeredAgents(bus, agents, signal) {
|
|
|
30
35
|
}
|
|
31
36
|
return out;
|
|
32
37
|
}
|
|
33
|
-
export async function offeredAgentListing(
|
|
38
|
+
export async function offeredAgentListing(seat, listing, signal) {
|
|
34
39
|
if (listing === undefined)
|
|
35
40
|
return undefined;
|
|
36
|
-
const entries = await offeredAgents(
|
|
41
|
+
const entries = await offeredAgents(seat, listing.entries, signal);
|
|
37
42
|
return entries === listing.entries || entries.length === listing.entries.length ? listing : { ...listing, entries };
|
|
38
43
|
}
|
|
44
|
+
export function spawnedModel(model) {
|
|
45
|
+
return model ?? "inherit";
|
|
46
|
+
}
|
|
39
47
|
const GO = Object.freeze({ go: true });
|
|
40
48
|
const FORM = "agent.spawn takes next(e) or { deny: <reason> } (every member is pinned: a spawn is refused, never rewritten)";
|
|
41
49
|
const denyOf = (a) => isPlainRecord(a) && Object.keys(a).length === 1 && typeof a["deny"] === "string" && a["deny"] !== "" ? a["deny"] : undefined;
|
|
42
50
|
const RANKS = Object.freeze({ of: (a) => (denyOf(a) !== undefined ? 1 : 0), top: 1 });
|
|
43
51
|
export function createAgentStations(input) {
|
|
44
52
|
return {
|
|
45
|
-
listens: (event) => input
|
|
46
|
-
offered: (agents, signal) => offeredAgents(input
|
|
53
|
+
listens: (event) => seatHears(input, event),
|
|
54
|
+
offered: (agents, signal) => offeredAgents(input, agents, signal),
|
|
55
|
+
extensionSpawn: (toolCallId) => {
|
|
56
|
+
const call = toolCallId !== undefined ? extensionCallOf(input.bus, toolCallId) : undefined;
|
|
57
|
+
if (call === undefined || call.door !== "agent.spawn" || toolCallId === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
return { by: call.caller.origin.plugin, launched: (agentId, model) => noteExtensionCallLaunched(input.bus, toolCallId, { agentId, model: spawnedModel(model) }) };
|
|
60
|
+
},
|
|
47
61
|
spawn: async (facts, signal) => {
|
|
48
|
-
if (!input
|
|
62
|
+
if (!seatHears(input, "agent.spawn"))
|
|
49
63
|
return GO;
|
|
50
64
|
const parentAgentId = agentIdOf(input.identity);
|
|
51
65
|
const permissionMode = input.permissionMode();
|
|
@@ -67,7 +81,7 @@ export function createAgentStations(input) {
|
|
|
67
81
|
...(facts.cwd !== undefined ? { cwd: facts.cwd } : {}),
|
|
68
82
|
...(facts.workflow === true ? { workflow: true } : {}),
|
|
69
83
|
};
|
|
70
|
-
const started = Object.freeze({ model: facts.model
|
|
84
|
+
const started = Object.freeze({ model: spawnedModel(facts.model) });
|
|
71
85
|
const checkAnswer = (a, _e, _by, below, ran) => {
|
|
72
86
|
if (a === started)
|
|
73
87
|
return undefined;
|
|
@@ -103,3 +117,38 @@ export function createAgentStations(input) {
|
|
|
103
117
|
},
|
|
104
118
|
};
|
|
105
119
|
}
|
|
120
|
+
const DESCRIPTION_WORDS = 5;
|
|
121
|
+
function delegationInput(args, prompt) {
|
|
122
|
+
return {
|
|
123
|
+
prompt,
|
|
124
|
+
description: args["description"] ?? prompt.split(/\s+/).slice(0, DESCRIPTION_WORDS).join(" "),
|
|
125
|
+
run_in_background: true,
|
|
126
|
+
...(args["model"] !== undefined ? { model: args["model"] } : {}),
|
|
127
|
+
...(args["subagentType"] !== undefined ? { subagent_type: args["subagentType"] } : {}),
|
|
128
|
+
...(args["name"] !== undefined ? { name: args["name"] } : {}),
|
|
129
|
+
...(args["cwd"] !== undefined ? { cwd: args["cwd"] } : {}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export function createAgentSpawnEntry(input) {
|
|
133
|
+
return async (args, ctx) => {
|
|
134
|
+
const by = ctx.origin.plugin;
|
|
135
|
+
const prompt = args["prompt"];
|
|
136
|
+
if (typeof prompt !== "string" || prompt.trim() === "")
|
|
137
|
+
throw new TypeError(`${by}: $.agent.spawn takes { prompt, ... } (a non-empty prompt)`);
|
|
138
|
+
const tools = input.mounted().filter((name) => declaredDelegationNameOf(input.specOf(name)) !== undefined);
|
|
139
|
+
const tool = tools[0];
|
|
140
|
+
if (tool === undefined)
|
|
141
|
+
throw new TypeError(`${by}: $.agent.spawn: this run mounts no delegation tool`);
|
|
142
|
+
if (tools.length > 1)
|
|
143
|
+
throw new TypeError(`${by}: $.agent.spawn: this run mounts ${tools.length} delegation tools (${tools.map((n) => `"${extensionWords(n, 80)}"`).join(", ")}) and a spawn names none of them`);
|
|
144
|
+
const toolCallId = `ext-${randomUUID()}`;
|
|
145
|
+
return runExtensionCall(input.bus, toolCallId, "agent.spawn", ctx, async (call) => {
|
|
146
|
+
const finalized = await input.harness.callTool({ type: "toolCall", id: toolCallId, name: tool, arguments: delegationInput(args, prompt) }, ctx.signal, () => undefined);
|
|
147
|
+
if (call.launched !== undefined)
|
|
148
|
+
return Object.freeze({ model: call.launched.model, agentId: call.launched.agentId });
|
|
149
|
+
if (call.denied || finalized.isError)
|
|
150
|
+
return Object.freeze({ deny: resultText(finalized.result.content) || "no subagent was started" });
|
|
151
|
+
return Object.freeze({ model: spawnedModel(typeof args["model"] === "string" ? args["model"] : undefined) });
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* registration form types a handler by it. Its keys are the event table's `classic.*` rows that carry a station — the key
|
|
5
5
|
* set is held to that table.
|
|
6
6
|
*/
|
|
7
|
-
import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
7
|
+
import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, SessionEndEvent, SessionStartEvent, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
8
8
|
import type { MappedOn, ModRegistration } from "./kernel/index.js";
|
|
9
9
|
import type { EngineDollar } from "./dollar.js";
|
|
10
10
|
/** The answer of an event whose station reads none (an observation event): a chain handler passes `next(e)`'s on. */
|
|
@@ -31,6 +31,14 @@ export type ClassicEventMap = {
|
|
|
31
31
|
readonly e: UserPromptSubmitEvent;
|
|
32
32
|
readonly answer: UserPromptSubmitResult;
|
|
33
33
|
};
|
|
34
|
+
readonly "classic.SessionStart": {
|
|
35
|
+
readonly e: SessionStartEvent;
|
|
36
|
+
readonly answer: ObservedAnswer;
|
|
37
|
+
};
|
|
38
|
+
readonly "classic.SessionEnd": {
|
|
39
|
+
readonly e: SessionEndEvent;
|
|
40
|
+
readonly answer: ObservedAnswer;
|
|
41
|
+
};
|
|
34
42
|
readonly "classic.SubagentStart": {
|
|
35
43
|
readonly e: SubagentStartEvent;
|
|
36
44
|
readonly answer: SubagentStartResult;
|