@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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { literalTildeSpelling } from "../../shell/lex.js";
|
|
2
|
+
import { programBasename } from "./bash-program-position.js";
|
|
3
|
+
import { launcherOptionPathRole, launcherOptionStep, programRow, readOptionRole } from "./program-read-model.js";
|
|
4
|
+
import { chdirFrom } from "./shell-read-object-path.js";
|
|
5
|
+
import { anchorSpelling, pathFamilyOf } from "./safety.js";
|
|
1
6
|
const NO_NAMES = new Set();
|
|
2
7
|
export function heldAt(table, bound = NO_NAMES) {
|
|
3
8
|
return { start: (key) => table.stateOf(key), bound };
|
|
@@ -62,27 +67,94 @@ export function stdinFeeds(segments, start, piped) {
|
|
|
62
67
|
};
|
|
63
68
|
return fedAt;
|
|
64
69
|
}
|
|
65
|
-
export function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
export function nestedStartOf(cwd) {
|
|
71
|
+
return anchorSpelling(pathFamilyOf({ cwd }), cwd, "\u0000");
|
|
72
|
+
}
|
|
73
|
+
export function walkFromStart(base) {
|
|
74
|
+
const at = base.search(/[\\/]\u0000(?:[\\/]|$)/);
|
|
75
|
+
return at < 0 ? undefined : base.slice(at + 3);
|
|
76
|
+
}
|
|
77
|
+
const settledWord = (r) => r.expands === false && (r.values?.length ?? 1) <= 1 && r.homeFloor === undefined && r.word.pieces.every((q) => q.literal !== undefined || q.expansion !== undefined);
|
|
78
|
+
export function launchedInOf(pos, toks) {
|
|
79
|
+
if (pos.baseMovedAt.length === 0)
|
|
80
|
+
return undefined;
|
|
81
|
+
const dirs = [];
|
|
82
|
+
let owner;
|
|
83
|
+
for (const at of pos.baseMovedAt) {
|
|
84
|
+
const l = pos.launchers.filter((x) => x.index < at).at(-1);
|
|
85
|
+
const row = programRow(programBasename(l.name));
|
|
86
|
+
const w = toks[at].folded;
|
|
87
|
+
const step = launcherOptionStep(row, w);
|
|
88
|
+
const own = step === 2 ? undefined : readOptionRole(row, w);
|
|
89
|
+
const role = step === 2 ? launcherOptionPathRole(row, w) : own?.form === "attached" ? own.role : undefined;
|
|
90
|
+
if (role?.kind !== "path" || role.base !== "working-directory")
|
|
91
|
+
return "unmodelled";
|
|
92
|
+
const word = toks[step === 2 ? at + 1 : at];
|
|
93
|
+
const twoWays = own?.form === "attached" && own.spec?.arity === "attached" && own.value.startsWith("=");
|
|
94
|
+
const value = step === 2 ? word.folded : own?.form === "attached" && !twoWays ? literalTildeSpelling(own.value) : undefined;
|
|
95
|
+
const dir = value !== undefined && value !== "" && settledWord(word) ? value : null;
|
|
96
|
+
if (l.index === owner)
|
|
97
|
+
dirs[dirs.length - 1] = dir;
|
|
98
|
+
else
|
|
99
|
+
dirs.push(dir);
|
|
100
|
+
owner = l.index;
|
|
101
|
+
}
|
|
102
|
+
return dirs.every((d) => d !== null) ? dirs : "unmodelled";
|
|
103
|
+
}
|
|
104
|
+
export function launchedAt(launchedIn, bases, floor, homeDir) {
|
|
105
|
+
if (launchedIn === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
const here = bases !== "unmodelled" ? bases : floor;
|
|
108
|
+
let to = launchedIn === "unmodelled" ? "unmodelled" : bases;
|
|
109
|
+
let toFloor = here;
|
|
110
|
+
for (const dir of launchedIn === "unmodelled" ? [] : launchedIn) {
|
|
111
|
+
if (to !== "unmodelled") {
|
|
112
|
+
const next = chdirFrom(to, dir, homeDir);
|
|
113
|
+
if (next === undefined)
|
|
114
|
+
to = "unmodelled";
|
|
115
|
+
else
|
|
116
|
+
toFloor = to = next;
|
|
117
|
+
}
|
|
118
|
+
else if (toFloor !== undefined)
|
|
119
|
+
toFloor = chdirFrom(toFloor, dir, homeDir) ?? toFloor;
|
|
120
|
+
}
|
|
121
|
+
const words = [...new Set([...(here ?? []), ...(toFloor ?? [])])];
|
|
122
|
+
return { to, ...(toFloor !== undefined && toFloor.length > 0 ? { floor: toFloor } : {}), ...(words.length > 0 ? { words } : {}) };
|
|
123
|
+
}
|
|
124
|
+
export function rebasePlan(plan, to, floor) {
|
|
125
|
+
const key = JSON.stringify([to, floor]);
|
|
126
|
+
const known = REBASED.get(plan)?.get(key);
|
|
127
|
+
if (known !== undefined)
|
|
128
|
+
return known;
|
|
129
|
+
const out = rebasedOnto(plan, to, floor);
|
|
130
|
+
REBASED.set(plan, (REBASED.get(plan) ?? new Map()).set(key, out));
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
const REBASED = new WeakMap();
|
|
134
|
+
function rebasedOnto(plan, to, floor) {
|
|
135
|
+
const placed = (into, b) => {
|
|
136
|
+
const rest = walkFromStart(b);
|
|
137
|
+
if (rest === undefined)
|
|
138
|
+
return [b];
|
|
139
|
+
return (into ?? []).map((t) => (rest === "" ? t : anchorSpelling(pathFamilyOf({ cwd: t }), t, rest)));
|
|
75
140
|
};
|
|
76
|
-
const moveBase = (b) => (to === "unmodelled" ? [] :
|
|
141
|
+
const moveBase = (b) => (to === "unmodelled" ? [] : placed(to, b));
|
|
77
142
|
const floorAt = to === "unmodelled" ? floor : to;
|
|
78
|
-
const
|
|
143
|
+
const floorsOf = (bases, into) => {
|
|
144
|
+
const floors = [...new Set(bases.flatMap((b) => placed(into, b)))];
|
|
145
|
+
return floors.length > 0 ? { floorBases: floors } : {};
|
|
146
|
+
};
|
|
79
147
|
const moveCandidate = (c) => {
|
|
80
|
-
if (c.bases === "unmodelled")
|
|
81
|
-
|
|
148
|
+
if (c.bases === "unmodelled") {
|
|
149
|
+
if (c.floorBases === undefined)
|
|
150
|
+
return c;
|
|
151
|
+
const { floorBases: _, ...rest } = c;
|
|
152
|
+
return { ...rest, ...floorsOf(c.floorBases, floorAt) };
|
|
153
|
+
}
|
|
82
154
|
if (c.bases.length === 0)
|
|
83
155
|
return c;
|
|
84
156
|
if (to === "unmodelled")
|
|
85
|
-
return
|
|
157
|
+
return { ...c, bases: "unmodelled", ...floorsOf(c.bases, floor) };
|
|
86
158
|
return { ...c, bases: [...new Set(c.bases.flatMap(moveBase))] };
|
|
87
159
|
};
|
|
88
160
|
return {
|
|
@@ -93,8 +165,8 @@ export function rebasePlan(plan, from, to, floor) {
|
|
|
93
165
|
redirects: s.redirects.map((r) => (r.target === undefined ? r : { ...r, target: moveCandidate(r.target) })),
|
|
94
166
|
...(s.baseMove !== undefined ? { baseMove: { target: typeof s.baseMove.target === "string" ? s.baseMove.target : moveCandidate(s.baseMove.target) } } : {}),
|
|
95
167
|
bases: s.bases === "unmodelled" || to === "unmodelled" ? "unmodelled" : [...new Set(s.bases.flatMap(moveBase))],
|
|
96
|
-
nested: s.nested.map((n) => rebasePlan(n,
|
|
97
|
-
...(s.printed !== undefined ? { printed: s.printed.map((n) => rebasePlan(n,
|
|
168
|
+
nested: s.nested.map((n) => rebasePlan(n, to, floor)),
|
|
169
|
+
...(s.printed !== undefined ? { printed: s.printed.map((n) => rebasePlan(n, to, floor)) } : {}),
|
|
98
170
|
})),
|
|
99
171
|
};
|
|
100
172
|
}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* `popd` with the stack the text pushed, and a literal `eval` text read as the text it is, in this shell. Any other text
|
|
7
7
|
* that may move the base where the plan cannot follow it (`source`, a non-literal `eval`, a computed program word, a
|
|
8
8
|
* call into a function body or a code body that may move, an option the stack reading does not follow) LOSES it: what
|
|
9
|
-
* stands after it cannot be placed.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* stands after it cannot be placed. The moves are a candidate SET — a move may fail: the unmoved place stays a candidate
|
|
10
|
+
* unless an `&&` run proves the move ran. A move reaches a later segment where a binding of the same segment would: the
|
|
11
|
+
* binding thread's one visibility rule (`BindingThread.reaches`) — a move inside a `( … )` group, a pipeline member that
|
|
12
|
+
* is not the last, a background job or a function body is no move for a segment outside it ({@link WorkdirScope}).
|
|
12
13
|
*/
|
|
13
14
|
import type { Bare } from "./shell-read-argv.js";
|
|
14
15
|
import type { BindingTable, WorkingDirectoryState } from "./shell-read-bindings.js";
|
|
@@ -51,6 +52,7 @@ export interface WorkdirContext {
|
|
|
51
52
|
readonly evalEnd: (text: string, from: BaseCandidate, table: BindingTable) => {
|
|
52
53
|
readonly end: readonly BaseCandidate[] | "unmodelled";
|
|
53
54
|
readonly physical: boolean;
|
|
55
|
+
readonly reached: ReadonlySet<string>;
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
/** One segment's move as the walk applies it: the shift, whether an `&&` run proves it ran, the first segment of the
|
|
@@ -67,8 +69,6 @@ export interface CommandTable extends BindingTable {
|
|
|
67
69
|
readonly commandSets: ReadonlySet<string>;
|
|
68
70
|
}
|
|
69
71
|
export declare class WorkdirThread {
|
|
70
|
-
/** The start is where the shell stands (not a placeholder a nested plan is re-based from): `PWD` reads it. */
|
|
71
|
-
private readonly readable;
|
|
72
72
|
private candidates;
|
|
73
73
|
private lostAt;
|
|
74
74
|
/** The reachable bases at the moment the walk lost track — the deny floor of a word it cannot place. */
|
|
@@ -78,13 +78,14 @@ export declare class WorkdirThread {
|
|
|
78
78
|
private physical;
|
|
79
79
|
/** The last segment whose move was applied or lost track ({@link WorkingDirectoryState.movedAt}). */
|
|
80
80
|
private movedAt;
|
|
81
|
+
/** The start is a place the shell stands in — no placeholder start, no base walked from one (an `eval` text a nested text runs): `PWD` reads it. */ private readonly readable;
|
|
81
82
|
constructor(start: readonly BaseCandidate[] | readonly string[] | "unmodelled",
|
|
82
|
-
/** The start is where the shell stands (not a placeholder a nested plan is re-based from): `PWD` reads it. */
|
|
83
|
-
readable: boolean,
|
|
84
83
|
/** The physical mode may already be on where the text starts (an `eval` text run in a shell that set it). */
|
|
85
84
|
startsPhysical?: boolean);
|
|
86
85
|
get lost(): boolean;
|
|
86
|
+
/** The deny floor of the words the walk could not place: a closed scope that lost track keeps its floor for its words. */
|
|
87
87
|
get floorBases(): readonly string[] | undefined;
|
|
88
|
+
private closedFloors;
|
|
88
89
|
/** The candidates a reader whose `&&` run starts at `andRunStart` may stand in. */
|
|
89
90
|
reachable(andRunStart: number): readonly BaseCandidate[];
|
|
90
91
|
/** Where the text ends: every candidate, or `unmodelled`. */
|
|
@@ -95,7 +96,18 @@ export declare class WorkdirThread {
|
|
|
95
96
|
setPhysical(): void;
|
|
96
97
|
/** Where the text ends the physical mode may be on (an `eval` text hands it back to the shell that ran it). */
|
|
97
98
|
get mayBePhysical(): boolean;
|
|
98
|
-
/**
|
|
99
|
+
/** What the walk holds before a segment that runs apart from the shell after it ({@link WorkdirScope}). */
|
|
100
|
+
snapshot(): WorkdirScope;
|
|
101
|
+
/** A scope closed: what its moves did never reached the shell outside it — the walk holds again what it held before them.
|
|
102
|
+
* The places they went stay a deny floor of a walk that later loses track ({@link scopeReached}). */
|
|
103
|
+
restore(s: WorkdirScope): void;
|
|
104
|
+
/** Places a closed scope's moves went (a function body run at a call goes there, `eval`'s text closed one): as a binding's
|
|
105
|
+
* deny floor stays wherever the binding may have run, they join the deny floor where the walk loses track. */
|
|
106
|
+
private scopeReached;
|
|
107
|
+
get reached(): ReadonlySet<string>;
|
|
108
|
+
reach(bases: Iterable<string>): void;
|
|
109
|
+
/** Stop placing anything from segment `at` on: the reachable bases (and a target's floor spellings, the places a closed
|
|
110
|
+
* scope went) become the deny floor. */
|
|
99
111
|
lose(at: number, reachable: readonly BaseCandidate[], floorTargets?: readonly string[]): void;
|
|
100
112
|
/** Apply segment `si`'s move. */
|
|
101
113
|
shift(si: number, at: ShiftAt, ctx: WorkdirContext): void;
|
|
@@ -103,6 +115,15 @@ export declare class WorkdirThread {
|
|
|
103
115
|
* each with the `PWD`, `OLDPWD` and stack the move leaves — or `lost`. */
|
|
104
116
|
private movedFrom;
|
|
105
117
|
}
|
|
118
|
+
/** The walk's state before a segment's moves, where the segment runs apart from the shell after it (a `( … )` group, a
|
|
119
|
+
* pipeline member that is not the last, a background job, a function body): handed back where the scope closes. */
|
|
120
|
+
export interface WorkdirScope {
|
|
121
|
+
readonly candidates: readonly BaseCandidate[];
|
|
122
|
+
readonly lost: boolean;
|
|
123
|
+
readonly floors: readonly string[] | undefined;
|
|
124
|
+
readonly physical: boolean;
|
|
125
|
+
readonly movedAt: number;
|
|
126
|
+
}
|
|
106
127
|
/** Does bash search `CDPATH` for this `cd` target: not an absolute one, not `.` / `..`, not one starting `./` / `../`? */
|
|
107
128
|
export declare function searchesCdPath(dir: string): boolean;
|
|
108
129
|
/** The base shift of a `cd` / `pushd` / `popd` / `dirs` segment, read off its arguments as the program receives them (and
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import { argvOf, lexShell } from "../../shell/lex.js";
|
|
2
2
|
import { shellWordsOf } from "../../shell/shell-words.js";
|
|
3
|
-
import { resolveOperandLexically } from "./bash-readonly-classifier.js";
|
|
3
|
+
import { resolveOperandLexically, resolveOperandSpellings } from "./bash-readonly-classifier.js";
|
|
4
4
|
import { readProgramPosition } from "./bash-program-position.js";
|
|
5
5
|
import { valueOf } from "./shell-read-bindings.js";
|
|
6
6
|
import { evalDefinedFunctions, functionCallOf } from "./shell-read-functions.js";
|
|
7
7
|
import { codeBodies } from "./shell-reentry-text.js";
|
|
8
8
|
import { isAbsoluteForFamily } from "./safety.js";
|
|
9
|
+
import { walkFromStart } from "./shell-read-start.js";
|
|
9
10
|
const TEXT_RUNNING_PROGRAMS = new Set(["eval", "source", "."]);
|
|
10
11
|
const BASE_CANDIDATE_MAX = 256;
|
|
11
12
|
const tableSays = (name, at, ctx) => ctx.textBinds(name) || at.table.commandSets.has(name);
|
|
12
13
|
export class WorkdirThread {
|
|
13
|
-
readable;
|
|
14
14
|
candidates;
|
|
15
15
|
lostAt = false;
|
|
16
16
|
floors;
|
|
17
17
|
physical;
|
|
18
18
|
movedAt = -1;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
readable;
|
|
20
|
+
constructor(start, startsPhysical = false) {
|
|
21
21
|
this.physical = startsPhysical;
|
|
22
22
|
this.lostAt = start === "unmodelled";
|
|
23
|
-
this.
|
|
23
|
+
this.readable = start === "unmodelled" || start.every((c) => walkFromStart(typeof c === "string" ? c : c.base) === undefined);
|
|
24
|
+
this.candidates = start === "unmodelled" ? [] : start.map((c) => (typeof c === "string" ? { base: c, skippedCd: -1, ...(this.readable && isAbsoluteForFamily("own", c) ? { pwd: c } : {}), dirStack: [] } : { ...c, skippedCd: -1 }));
|
|
24
25
|
}
|
|
25
26
|
get lost() {
|
|
26
27
|
return this.lostAt;
|
|
27
28
|
}
|
|
28
29
|
get floorBases() {
|
|
29
|
-
return this.floors;
|
|
30
|
+
return this.closedFloors.length === 0 ? this.floors : [...new Set([...(this.floors ?? []), ...this.closedFloors])];
|
|
30
31
|
}
|
|
32
|
+
closedFloors = [];
|
|
31
33
|
reachable(andRunStart) {
|
|
32
34
|
return this.candidates.filter((c) => c.skippedCd < andRunStart);
|
|
33
35
|
}
|
|
@@ -56,10 +58,30 @@ export class WorkdirThread {
|
|
|
56
58
|
get mayBePhysical() {
|
|
57
59
|
return this.physical;
|
|
58
60
|
}
|
|
61
|
+
snapshot() {
|
|
62
|
+
return { candidates: this.candidates, lost: this.lostAt, floors: this.floors, physical: this.physical, movedAt: this.movedAt };
|
|
63
|
+
}
|
|
64
|
+
restore(s) {
|
|
65
|
+
this.reach(this.lostAt ? (this.floors ?? []) : this.candidates.map((c) => c.base));
|
|
66
|
+
if (this.lostAt && this.floors !== undefined)
|
|
67
|
+
this.closedFloors = [...this.closedFloors, ...this.floors];
|
|
68
|
+
this.candidates = s.candidates;
|
|
69
|
+
this.lostAt = s.lost;
|
|
70
|
+
this.floors = s.floors;
|
|
71
|
+
this.physical = s.physical;
|
|
72
|
+
this.movedAt = s.movedAt;
|
|
73
|
+
}
|
|
74
|
+
scopeReached = new Set();
|
|
75
|
+
get reached() {
|
|
76
|
+
return this.scopeReached;
|
|
77
|
+
}
|
|
78
|
+
reach(bases) {
|
|
79
|
+
this.scopeReached = new Set([...this.scopeReached, ...bases]);
|
|
80
|
+
}
|
|
59
81
|
lose(at, reachable, floorTargets = []) {
|
|
60
82
|
this.movedAt = Math.max(this.movedAt, at);
|
|
61
83
|
this.lostAt = true;
|
|
62
|
-
this.floors ??= [...new Set([...reachable.map((c) => c.base), ...floorTargets])];
|
|
84
|
+
this.floors ??= [...new Set([...reachable.map((c) => c.base), ...floorTargets, ...this.scopeReached])];
|
|
63
85
|
}
|
|
64
86
|
shift(si, at, ctx) {
|
|
65
87
|
if (this.lostAt) {
|
|
@@ -106,6 +128,7 @@ export class WorkdirThread {
|
|
|
106
128
|
const ran = ctx.evalEnd(s.text, c, at.table);
|
|
107
129
|
if (ran.physical)
|
|
108
130
|
this.physical = true;
|
|
131
|
+
this.reach(ran.reached);
|
|
109
132
|
return ran.end === "unmodelled" ? "lost" : ran.end.map((e) => (this.physical ? withoutPwd(e) : e));
|
|
110
133
|
}
|
|
111
134
|
const old = tableSays("PWD", at, ctx) ? {} : c.pwd !== undefined ? { old: c.pwd } : {};
|
|
@@ -143,7 +166,7 @@ function floorOf(s, reachable, ctx) {
|
|
|
143
166
|
if (typeof s.target === "string")
|
|
144
167
|
return [];
|
|
145
168
|
const target = s.target;
|
|
146
|
-
return [...(target.floorSpelled !== undefined ? [target.floorSpelled] : []), ...(target.expands === false ? reachable.flatMap((c) =>
|
|
169
|
+
return [...(target.floorSpelled !== undefined ? [target.floorSpelled] : []), ...(target.expands === false ? reachable.flatMap((c) => { const at = resolveOperandSpellings(c.base, target.spelled, ctx.homeDir); return at === undefined ? [] : [at.spelled ?? at.folded]; }) : [])];
|
|
147
170
|
}
|
|
148
171
|
function targetsOf(target, c, at, ctx) {
|
|
149
172
|
if (target === "home")
|
package/dist/tools/monitor.d.ts
CHANGED
|
@@ -42,9 +42,11 @@
|
|
|
42
42
|
import type { AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
43
43
|
import { type MonitorTimers, type TaskRegistry } from "../core/task-registry.js";
|
|
44
44
|
import { type TaskNotificationPayload } from "../core/task-notification.js";
|
|
45
|
-
import type { ToolResultStore } from "../core/tool-result-store.js";
|
|
46
45
|
import type { ShellReadAdmission } from "./fs/shell-read-check.js";
|
|
47
46
|
import type { ReadFloorSeat } from "./fs/read-floor.js";
|
|
47
|
+
/** The refusal a watch gets where no event or completion would come back from it (no completion sink for the call, no
|
|
48
|
+
* mount sink): nothing is spawned. */
|
|
49
|
+
export declare const MONITOR_NO_COMPLETION_CHANNEL = "Error (Monitor): a watch is not available here \u2014 no event or final notification would come back from one on this mount. Run the command in the foreground (with a timeout) instead.";
|
|
48
50
|
export interface MonitorToolOptions {
|
|
49
51
|
registry: TaskRegistry;
|
|
50
52
|
/** Fallbacks when the runtime ctx carries no identity (direct mounts) — same posture as createBashTool. */
|
|
@@ -53,8 +55,8 @@ export interface MonitorToolOptions {
|
|
|
53
55
|
/** design/129: the session id — a `persistent` monitor registers session-scoped under it (outlives the
|
|
54
56
|
* turn; reaped by the deployment's session release via `reapSessionBackground`). */
|
|
55
57
|
sessionId?: string;
|
|
56
|
-
/** The notification sink (the run-local task-notification lane).
|
|
57
|
-
*
|
|
58
|
+
/** The notification sink (the run-local task-notification lane). A call carrying its run's lane delivers there
|
|
59
|
+
* instead; with neither, the watch is refused before anything is spawned (nothing it saw would reach the model). */
|
|
58
60
|
onTaskNotification?: (n: TaskNotificationPayload, opts?: {
|
|
59
61
|
priority?: "now" | "next" | "later";
|
|
60
62
|
}) => void;
|
|
@@ -67,10 +69,9 @@ export interface MonitorToolOptions {
|
|
|
67
69
|
/** Test/deployment knobs (defaults: 200ms window, 50 batches/min). */
|
|
68
70
|
batchWindowMs?: number;
|
|
69
71
|
maxBatchesPerMinute?: number;
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
toolResultStore?: ToolResultStore;
|
|
72
|
+
/** This run is a one-shot submission (`TaskSpec.oneShot`): its ending does not wait for the watch, and the
|
|
73
|
+
* receipt says so with the one process-lane sentence a background command's receipt carries. */
|
|
74
|
+
oneShot?: boolean;
|
|
74
75
|
/** The gate's shell read station's pre-spawn ADMISSION — the SAME option `createBashTool` takes: this face
|
|
75
76
|
* spawns a shell command too, so what it runs is what the station judged, re-established before the watch
|
|
76
77
|
* spawns. Absent ⇒ no station judged this mount; nothing is re-established. */
|
package/dist/tools/monitor.js
CHANGED
|
@@ -2,10 +2,12 @@ import { Type } from "typebox";
|
|
|
2
2
|
import { defineTool, errorResult } from "../core/tools.js";
|
|
3
3
|
import { createBackgroundOutputFile, envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../core/background-shell.js";
|
|
4
4
|
import { MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, } from "../core/task-registry.js";
|
|
5
|
-
import { resolveCompletionSink } from "../core/task-notification.js";
|
|
5
|
+
import { admitsBackgroundLaunch, resolveCompletionSink } from "../core/task-notification.js";
|
|
6
6
|
import { toolFace } from "../core/tool-catalog-entries.js";
|
|
7
|
+
import { ONE_SHOT_BACKGROUND_COMMAND_NOTE } from "./fs/fs-bash-background-text.js";
|
|
7
8
|
import { isDeadCwd, diagnoseDeadCwd } from "./fs/dead-cwd.js";
|
|
8
9
|
import { thrownText } from "../core/thrown-value.js";
|
|
10
|
+
export const MONITOR_NO_COMPLETION_CHANNEL = "Error (Monitor): a watch is not available here — no event or final notification would come back from one on this mount. Run the command in the foreground (with a timeout) instead.";
|
|
9
11
|
const MONITOR_DESCRIPTION = "Run a shell command in the background and watch its stdout as a stream of events.\n" +
|
|
10
12
|
"\n" +
|
|
11
13
|
"- Each line the command writes to stdout becomes a notification event delivered to you between turns; " +
|
|
@@ -67,6 +69,9 @@ export function createMonitorTool(env, opts) {
|
|
|
67
69
|
if (!hasBackgroundShell(env)) {
|
|
68
70
|
return errorResult("Error (Monitor): this environment does not support background processes.");
|
|
69
71
|
}
|
|
72
|
+
const onNotify = resolveCompletionSink(ctx.onTaskNotification, opts.onTaskNotification);
|
|
73
|
+
if (!admitsBackgroundLaunch(onNotify))
|
|
74
|
+
return errorResult(MONITOR_NO_COMPLETION_CHANNEL);
|
|
70
75
|
const isPersistent = persistent === true;
|
|
71
76
|
const timeoutMs = Math.min(MONITOR_MAX_TIMEOUT_MS, Math.max(1, Math.floor(timeout_ms ?? MONITOR_DEFAULT_TIMEOUT_MS)));
|
|
72
77
|
const spawnTimeoutSec = isPersistent ? undefined : Math.ceil(timeoutMs / 1000) + 5;
|
|
@@ -91,7 +96,6 @@ export function createMonitorTool(env, opts) {
|
|
|
91
96
|
const sessionScoped = isPersistent && opts.sessionId !== undefined;
|
|
92
97
|
const owner = sessionScoped ? opts.sessionId : (ctx.taskId ?? opts.owner);
|
|
93
98
|
const scope = ctx.principal ?? opts.scope;
|
|
94
|
-
const onNotify = resolveCompletionSink(ctx.onTaskNotification, opts.onTaskNotification);
|
|
95
99
|
const outputFile = await createBackgroundOutputFile(env, "monitor-task-");
|
|
96
100
|
let taskId;
|
|
97
101
|
try {
|
|
@@ -108,12 +112,11 @@ export function createMonitorTool(env, opts) {
|
|
|
108
112
|
...(sessionScoped ? { sessionScoped: true } : {}),
|
|
109
113
|
...(isPersistent ? {} : { timeoutMs }),
|
|
110
114
|
...(opts.retainBackgroundProcesses !== undefined ? { retainBackgroundProcesses: opts.retainBackgroundProcesses } : {}),
|
|
111
|
-
|
|
115
|
+
onEvent: (n) => onNotify(n, { priority: "next" }),
|
|
112
116
|
...(opts.timers !== undefined ? { timers: opts.timers } : {}),
|
|
113
117
|
...(opts.batchWindowMs !== undefined ? { batchWindowMs: opts.batchWindowMs } : {}),
|
|
114
118
|
...(opts.maxBatchesPerMinute !== undefined ? { maxBatchesPerMinute: opts.maxBatchesPerMinute } : {}),
|
|
115
119
|
...(opts.sessionId !== undefined ? { sessionId: opts.sessionId } : {}),
|
|
116
|
-
...(opts.toolResultStore !== undefined ? { toolResultStore: opts.toolResultStore } : {}),
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
catch (e) {
|
|
@@ -166,12 +169,11 @@ export function createMonitorTool(env, opts) {
|
|
|
166
169
|
const fileClause = outputFile !== undefined
|
|
167
170
|
? `Output file: ${outputFile} (stdout and stderr are appended there — Read it any time).`
|
|
168
171
|
: "No output file could be created for this watch.";
|
|
169
|
-
const content =
|
|
170
|
-
|
|
171
|
-
`~200ms are batched)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
`${fileClause} Stop it with TaskStop("${taskId}"). ${lifetime}`;
|
|
172
|
+
const content = `Monitoring in background; task_id=${taskId}. Each stdout line becomes a notification event (lines within ` +
|
|
173
|
+
(opts.oneShot === true
|
|
174
|
+
? `~200ms are batched). ${ONE_SHOT_BACKGROUND_COMMAND_NOTE} `
|
|
175
|
+
: `~200ms are batched); you'll get a final notification with the exit code when it ends — do not poll. `) +
|
|
176
|
+
`${lifetime} ${fileClause} TaskStop("${taskId}") stops the watch.`;
|
|
175
177
|
return {
|
|
176
178
|
content,
|
|
177
179
|
details: {
|
package/dist/tools/worktree.d.ts
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* `CheckpointState.activeWorktree` (+ the cwd into `handsCwd`); resume re-seeds both, so
|
|
46
46
|
* Enter→suspend→resume→Exit behaves exactly like an unsuspended session.
|
|
47
47
|
*/
|
|
48
|
-
import type { ActiveWorktreeSession, AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
48
|
+
import type { ActiveWorktreeSession, AgentTool, ExecutionEnv, ReadFloor } from "../internal/harness-types.js";
|
|
49
49
|
import type { ManagedCheckoutView } from "../core/write-protect.js";
|
|
50
50
|
import type { CwdRef } from "./fs/index.js";
|
|
51
51
|
/** the ACTIVE worktree session, ALL-SERIALIZABLE (plain strings, no closures):
|
|
@@ -111,6 +111,10 @@ export interface WorktreeToolsOptions {
|
|
|
111
111
|
* the durable checkpoint and re-seeds it on resume). Omitted ⇒ a private per-mount ref (same live
|
|
112
112
|
* behavior, minus durable-suspend survival — prepare-task always passes one). */
|
|
113
113
|
session?: WorktreeSessionRef;
|
|
114
|
+
/** The byte floor's seat (`ExecutionEnvExecOptions.readFloor`): every git command a call starts carries the floor of the
|
|
115
|
+
* table that call judges with, read as the call begins. Absent ⇒ the starts carry none (a host mount that holds no
|
|
116
|
+
* run's table); the Runner always passes the run's. */
|
|
117
|
+
readFloor?: (toolCallId: string | undefined) => ReadFloor | undefined;
|
|
114
118
|
}
|
|
115
119
|
/**
|
|
116
120
|
* Build the EnterWorktree/ExitWorktree pair. One session-state closure per mount (= per task): the
|
package/dist/tools/worktree.js
CHANGED
|
@@ -105,16 +105,16 @@ function reasonOf(e) {
|
|
|
105
105
|
}
|
|
106
106
|
return thrownText(e);
|
|
107
107
|
}
|
|
108
|
-
async function resolveBaseCommit(env, repoRoot, baseRef) {
|
|
108
|
+
async function resolveBaseCommit(env, repoRoot, baseRef, readFloor) {
|
|
109
109
|
const rev = async (ref) => {
|
|
110
|
-
const r = await env.exec(`git rev-parse --verify --quiet ${shq(`${ref}^{commit}`)}`, { cwd: repoRoot });
|
|
110
|
+
const r = await env.exec(`git rev-parse --verify --quiet ${shq(`${ref}^{commit}`)}`, { cwd: repoRoot, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
111
111
|
return r.ok && r.value.exitCode === 0 ? r.value.stdout.trim() : undefined;
|
|
112
112
|
};
|
|
113
113
|
if (baseRef === "head") {
|
|
114
114
|
const sha = await rev("HEAD");
|
|
115
115
|
return sha ? { sha, label: "HEAD" } : { error: "cannot resolve HEAD (empty repository with no commits?)" };
|
|
116
116
|
}
|
|
117
|
-
const sym = await env.exec("git symbolic-ref --quiet refs/remotes/origin/HEAD", { cwd: repoRoot });
|
|
117
|
+
const sym = await env.exec("git symbolic-ref --quiet refs/remotes/origin/HEAD", { cwd: repoRoot, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
118
118
|
if (sym.ok && sym.value.exitCode === 0) {
|
|
119
119
|
const branch = sym.value.stdout.trim().replace(/^refs\/remotes\//, "");
|
|
120
120
|
if (branch) {
|
|
@@ -152,7 +152,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
152
152
|
description: '"fresh" (default) bases the worktree on the default branch tip (origin default branch, else local main/master, else the current HEAD with a note); "head" bases it on the current local HEAD (unpushed commits present).',
|
|
153
153
|
})),
|
|
154
154
|
}),
|
|
155
|
-
execute: async (args) => {
|
|
155
|
+
execute: async (args, ctx) => {
|
|
156
156
|
const { name, path, baseRef } = args;
|
|
157
157
|
if (path !== undefined && name !== undefined) {
|
|
158
158
|
return errorResult("Error (EnterWorktree): `name` and `path` are mutually exclusive — `path` enters an existing worktree, `name` creates a new one.");
|
|
@@ -173,9 +173,10 @@ export function createWorktreeTools(env, opts) {
|
|
|
173
173
|
return errorResult("Error (EnterWorktree): an ExitWorktree call on this session is already in progress — wait for it to finish " +
|
|
174
174
|
"before entering another worktree.");
|
|
175
175
|
}
|
|
176
|
+
const readFloor = opts.readFloor?.(ctx.toolCallId);
|
|
176
177
|
session.entering = true;
|
|
177
178
|
try {
|
|
178
|
-
const probe = await env.exec("git rev-parse --is-inside-work-tree", { cwd: repoRoot });
|
|
179
|
+
const probe = await env.exec("git rev-parse --is-inside-work-tree", { cwd: repoRoot, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
179
180
|
if (!probe.ok || probe.value.exitCode !== 0) {
|
|
180
181
|
const detail = probe.ok ? (probe.value.stderr || probe.value.stdout).trim().split("\n")[0] : thrownText(probe.error);
|
|
181
182
|
return errorResult(`Error (EnterWorktree): the working directory ${repoRoot} is not a git repository` +
|
|
@@ -184,12 +185,12 @@ export function createWorktreeTools(env, opts) {
|
|
|
184
185
|
}
|
|
185
186
|
if (path !== undefined) {
|
|
186
187
|
const candidate = resolve(cwdRef.current, path);
|
|
187
|
-
const top = await env.exec("git rev-parse --show-toplevel", { cwd: candidate });
|
|
188
|
+
const top = await env.exec("git rev-parse --show-toplevel", { cwd: candidate, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
188
189
|
if (!top.ok || top.value.exitCode !== 0) {
|
|
189
190
|
return errorResult(`Error (EnterWorktree): ${candidate} is not an accessible git worktree (cannot resolve its top-level directory).`);
|
|
190
191
|
}
|
|
191
192
|
const target = top.value.stdout.trim();
|
|
192
|
-
const list = await env.exec("git worktree list --porcelain", { cwd: repoRoot });
|
|
193
|
+
const list = await env.exec("git worktree list --porcelain", { cwd: repoRoot, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
193
194
|
if (!list.ok || list.value.exitCode !== 0) {
|
|
194
195
|
return errorResult("Error (EnterWorktree): could not read `git worktree list` for this repository.");
|
|
195
196
|
}
|
|
@@ -210,7 +211,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
210
211
|
return errorResult(`Error (EnterWorktree): the worktree ${target} lives outside the task root ${repoRoot}; ` +
|
|
211
212
|
"read containment stays anchored at the task root, so it cannot be entered from this session.");
|
|
212
213
|
}
|
|
213
|
-
const head = await env.exec("git rev-parse HEAD", { cwd: target });
|
|
214
|
+
const head = await env.exec("git rev-parse HEAD", { cwd: target, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
214
215
|
if (!head.ok || head.value.exitCode !== 0) {
|
|
215
216
|
return errorResult(`Error (EnterWorktree): cannot resolve HEAD of the worktree ${target}.`);
|
|
216
217
|
}
|
|
@@ -230,7 +231,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
230
231
|
const nameProblem = name === undefined ? undefined : worktreeNameProblem(name);
|
|
231
232
|
if (nameProblem !== undefined)
|
|
232
233
|
return errorResult(`Error (EnterWorktree): ${nameProblem.slice(0, 300)}.`);
|
|
233
|
-
const base = await resolveBaseCommit(env, repoRoot, baseRef ?? "fresh");
|
|
234
|
+
const base = await resolveBaseCommit(env, repoRoot, baseRef ?? "fresh", readFloor);
|
|
234
235
|
if ("error" in base)
|
|
235
236
|
return errorResult(`Error (EnterWorktree): ${base.error}.`);
|
|
236
237
|
let created;
|
|
@@ -240,6 +241,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
240
241
|
sessionId: "worktree",
|
|
241
242
|
...(name !== undefined ? { name } : {}),
|
|
242
243
|
commit: base.sha,
|
|
244
|
+
readFloor: () => readFloor,
|
|
243
245
|
rootEnvAt: (dir) => Object.create(env, {
|
|
244
246
|
cwd: { value: dir, configurable: true },
|
|
245
247
|
destroy: { value: undefined, writable: true, configurable: true },
|
|
@@ -291,7 +293,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
291
293
|
description: 'Set true to remove the worktree even when it has uncommitted files or unmerged commits — they are permanently discarded. Without it a changed worktree is KEPT (the exit still completes and the reply lists the changes plus this escape), never refused.',
|
|
292
294
|
})),
|
|
293
295
|
}),
|
|
294
|
-
execute: async (args) => {
|
|
296
|
+
execute: async (args, ctx) => {
|
|
295
297
|
const raw = args;
|
|
296
298
|
const keep = raw.keep ?? (raw.action === "keep" ? true : undefined);
|
|
297
299
|
const discardChanges = raw.discardChanges ?? raw.discard_changes;
|
|
@@ -308,9 +310,10 @@ export function createWorktreeTools(env, opts) {
|
|
|
308
310
|
"Running a second exit now would race the same removal.");
|
|
309
311
|
}
|
|
310
312
|
const active = session.current;
|
|
313
|
+
const readFloor = opts.readFloor?.(ctx.toolCallId);
|
|
311
314
|
session.exiting = true;
|
|
312
315
|
try {
|
|
313
|
-
const outcome = await runExit(active, { keep, discardChanges, wantsRemove });
|
|
316
|
+
const outcome = await runExit(active, { keep, discardChanges, wantsRemove, readFloor });
|
|
314
317
|
session.current = undefined;
|
|
315
318
|
return outcome;
|
|
316
319
|
}
|
|
@@ -324,7 +327,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
324
327
|
},
|
|
325
328
|
});
|
|
326
329
|
async function runExit(active, opts2) {
|
|
327
|
-
const { keep, discardChanges, wantsRemove } = opts2;
|
|
330
|
+
const { keep, discardChanges, wantsRemove, readFloor } = opts2;
|
|
328
331
|
let restoredTo = active.originalCwd;
|
|
329
332
|
let restoreNote = "";
|
|
330
333
|
const origThere = await env.exists(active.originalCwd);
|
|
@@ -362,7 +365,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
362
365
|
}
|
|
363
366
|
const wtThere = await env.exists(active.worktreeDir);
|
|
364
367
|
if (wtThere.ok && !wtThere.value) {
|
|
365
|
-
const pruned = await pruneWorktrees(env, repoRoot);
|
|
368
|
+
const pruned = await pruneWorktrees(env, repoRoot, readFloor);
|
|
366
369
|
return {
|
|
367
370
|
content: `Exited the worktree session; working directory restored to ${restoredTo}${restoreNote}. ` +
|
|
368
371
|
`The worktree at ${active.worktreeDir} was already gone from disk (removed externally, not by this ` +
|
|
@@ -381,10 +384,10 @@ export function createWorktreeTools(env, opts) {
|
|
|
381
384
|
}
|
|
382
385
|
let changed = true;
|
|
383
386
|
let changeDetail = "could not verify the worktree state — keeping it to be safe";
|
|
384
|
-
const status = await env.exec("git status --porcelain", { cwd: active.worktreeDir });
|
|
387
|
+
const status = await env.exec("git status --porcelain", { cwd: active.worktreeDir, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
385
388
|
if (status.ok && status.value.exitCode === 0) {
|
|
386
389
|
const dirtyFiles = status.value.stdout.split("\n").filter((l) => l.trim() !== "").length;
|
|
387
|
-
const ahead = await env.exec(`git rev-list --count ${shq(`${active.baseSha}..HEAD`)}`, { cwd: active.worktreeDir });
|
|
390
|
+
const ahead = await env.exec(`git rev-list --count ${shq(`${active.baseSha}..HEAD`)}`, { cwd: active.worktreeDir, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
388
391
|
const commits = ahead.ok && ahead.value.exitCode === 0 ? parseInt(ahead.value.stdout.trim(), 10) || 0 : -1;
|
|
389
392
|
if (commits >= 0) {
|
|
390
393
|
changed = dirtyFiles > 0 || commits > 0;
|
|
@@ -409,10 +412,10 @@ export function createWorktreeTools(env, opts) {
|
|
|
409
412
|
details: { type: "worktree", action: "exit", worktreeDir: active.worktreeDir, kept: true },
|
|
410
413
|
};
|
|
411
414
|
}
|
|
412
|
-
const removal = await removeManagedWorktree(env, repoRoot, active.worktreeDir, active.branch !== undefined ? { name: active.branch, baseSha: active.baseSha } : undefined);
|
|
415
|
+
const removal = await removeManagedWorktree(env, repoRoot, active.worktreeDir, active.branch !== undefined ? { name: active.branch, baseSha: active.baseSha } : undefined, () => readFloor);
|
|
413
416
|
const removeFailure = removal.ok ? undefined : removal.detail.trim();
|
|
414
417
|
const branchNote = !removal.ok ? "" : removal.branchKept !== undefined ? ` Its branch was kept: ${removal.branchKept}.` : removal.branchDeleted !== undefined ? ` Its branch ${removal.branchDeleted} was deleted.` : "";
|
|
415
|
-
const pruned = await pruneWorktrees(env, repoRoot);
|
|
418
|
+
const pruned = await pruneWorktrees(env, repoRoot, readFloor);
|
|
416
419
|
const stillThere = await env.exists(active.worktreeDir);
|
|
417
420
|
const removalNote = removeFailure !== undefined ? ` (the removal command reported: ${removeFailure})` : "";
|
|
418
421
|
const pruneNote = pruned.ok ? "" : ` (stale git worktree metadata could NOT be pruned: ${pruned.detail} — run \`git worktree prune\` in ${repoRoot})`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.62.0",
|
|
4
4
|
"description": "Stateless, task-oriented AI agent core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"gate:field-liveness": "node scripts/verify-field-liveness.mjs",
|
|
75
75
|
"gate:debts": "node scripts/verify-debts.mjs",
|
|
76
76
|
"handoff:diff": "node scripts/dist-handoff-diff.mjs",
|
|
77
|
+
"dist:slip": "node scripts/release/dist-slip.mjs",
|
|
77
78
|
"post-ship": "node scripts/post-ship.mjs",
|
|
78
79
|
"gate:debts:rc": "node scripts/verify-debts.mjs --rc-gate",
|
|
79
80
|
"gate:anchor-claims": "node scripts/verify-anchor-claims.mjs",
|
|
@@ -121,8 +122,9 @@
|
|
|
121
122
|
"car:gate": "node scripts/car-gate.mjs"
|
|
122
123
|
},
|
|
123
124
|
"dependencies": {
|
|
124
|
-
"@modelcontextprotocol/
|
|
125
|
-
"@
|
|
125
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
126
|
+
"@modelcontextprotocol/core": "2.4.0",
|
|
127
|
+
"@sema-agent/primitives": "7.62.0",
|
|
126
128
|
"typebox": "1.1.39",
|
|
127
129
|
"undici": "7.30.0"
|
|
128
130
|
},
|
|
@@ -130,6 +132,7 @@
|
|
|
130
132
|
"sharp": "^0.35.0"
|
|
131
133
|
},
|
|
132
134
|
"devDependencies": {
|
|
135
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
133
136
|
"@types/node": "22.10.2",
|
|
134
137
|
"@types/pg": "^8.20.0",
|
|
135
138
|
"pg": "^8.22.0",
|