@sema-agent/core 7.57.0 → 7.59.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 +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- 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 +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
package/dist/tools/worktree.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { defineTool, errorResult } from "../core/tools.js";
|
|
4
|
-
import { addWorktree, pruneWorktrees, WORKTREE_PARENT } from "../core/git-worktree-env.js";
|
|
4
|
+
import { addWorktree, managedWorktreeBaseOf, pruneWorktrees, removeManagedWorktree, worktreeNameProblem, WORKTREE_PARENT } from "../core/git-worktree-env.js";
|
|
5
5
|
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
6
6
|
import { thrownText } from "../core/thrown-value.js";
|
|
7
|
+
export function currentCheckoutOf(session, taskRoot) {
|
|
8
|
+
const dir = session?.current?.worktreeDir;
|
|
9
|
+
if (dir === undefined)
|
|
10
|
+
return taskRoot.canonical;
|
|
11
|
+
const spelled = taskRoot.spelled.endsWith("/") ? taskRoot.spelled.slice(0, -1) : taskRoot.spelled;
|
|
12
|
+
if (spelled !== taskRoot.canonical && (dir === spelled || dir.startsWith(`${spelled}/`)))
|
|
13
|
+
return taskRoot.canonical + dir.slice(spelled.length);
|
|
14
|
+
return dir;
|
|
15
|
+
}
|
|
16
|
+
export function writeLocationOf(taskRoot) {
|
|
17
|
+
const seat = {};
|
|
18
|
+
const writeLocation = () => currentCheckoutOf(seat, taskRoot);
|
|
19
|
+
const checkout = () => {
|
|
20
|
+
const views = [];
|
|
21
|
+
for (const [root, kind] of [[writeLocation(), "canonical"], [seat.current?.worktreeDir ?? taskRoot.spelled, "spelled"]]) {
|
|
22
|
+
const base = managedWorktreeBaseOf(root);
|
|
23
|
+
if (base !== undefined)
|
|
24
|
+
views.push({ root, base, kind });
|
|
25
|
+
}
|
|
26
|
+
return views.length > 0 ? views : undefined;
|
|
27
|
+
};
|
|
28
|
+
return { seat, writeLocation, checkout };
|
|
29
|
+
}
|
|
7
30
|
const ENTER_DESCRIPTION = "Use this tool ONLY when explicitly instructed to work in a worktree — either by the user directly, or by " +
|
|
8
31
|
"project instructions. This tool creates an isolated git worktree and switches the current session into it.\n" +
|
|
9
32
|
"\n" +
|
|
@@ -21,9 +44,9 @@ const ENTER_DESCRIPTION = "Use this tool ONLY when explicitly instructed to work
|
|
|
21
44
|
"\n" +
|
|
22
45
|
"## Behavior\n" +
|
|
23
46
|
"\n" +
|
|
24
|
-
`- Creates a
|
|
25
|
-
"session's working directory to it: subsequent Bash commands run there,
|
|
26
|
-
"Read/Edit/Write resolve against it.\n" +
|
|
47
|
+
`- Creates a new worktree under \`${WORKTREE_PARENT}/<name>/\` in the repository root on a new branch \`sema/<name>\` and ` +
|
|
48
|
+
"switches the session's working directory and write access to it: subsequent Bash commands run there, relative paths in " +
|
|
49
|
+
"Read/Edit/Write resolve against it, and file writes must land inside it (or in an additional working directory).\n" +
|
|
27
50
|
'- `baseRef` picks the starting point: `"fresh"` (default) starts from the default branch tip ' +
|
|
28
51
|
"(origin's default branch when a remote exists, else local main/master, else the current HEAD with " +
|
|
29
52
|
'an honest note); `"head"` starts from the current local HEAD (unpushed commits and current branch ' +
|
|
@@ -34,10 +57,13 @@ const ENTER_DESCRIPTION = "Use this tool ONLY when explicitly instructed to work
|
|
|
34
57
|
"- Pass `path` instead of `name` to switch the session into a worktree of this repository that already " +
|
|
35
58
|
"exists (it must appear in `git worktree list` and live under the task root). Switching with `path` also " +
|
|
36
59
|
"works while already in a worktree session — the previous worktree is left on disk, untouched, and only " +
|
|
37
|
-
"the new one is tracked for exit-time cleanup. ExitWorktree will not remove a worktree entered via `path
|
|
38
|
-
"-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
60
|
+
"the new one is tracked for exit-time cleanup. ExitWorktree will not remove a worktree entered via `path`. After a further " +
|
|
61
|
+
"switch, previously-visited worktrees are no longer writable — re-issue EnterWorktree with `path` to return to one.\n" +
|
|
62
|
+
"- While a worktree is active, the base checkout and every other worktree are outside the write roots: where writes are " +
|
|
63
|
+
"confined to the write roots, Edit/Write refuse them and a shell command writing there asks first. Reads still reach the " +
|
|
64
|
+
"whole task root. Use ExitWorktree to " +
|
|
65
|
+
"write the base checkout again. This is not a sandbox: a program run in the shell can still write anywhere the process " +
|
|
66
|
+
"can — do not rely on the worktree as an isolation boundary.\n" +
|
|
41
67
|
"- Requires a git repository — there is no VCS-agnostic fallback in this deployment.";
|
|
42
68
|
const EXIT_DESCRIPTION = "Exit a worktree session created by EnterWorktree and return the session to the original working directory.\n" +
|
|
43
69
|
"\n" +
|
|
@@ -117,7 +143,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
117
143
|
description: ENTER_DESCRIPTION,
|
|
118
144
|
parameters: Type.Object({
|
|
119
145
|
name: Type.Optional(Type.String({
|
|
120
|
-
description:
|
|
146
|
+
description: 'Optional name for a new worktree. Each "/"-separated segment may contain only letters, digits, dots, underscores, and dashes; max 64 chars total. A random name is generated if not provided. Mutually exclusive with `path`.',
|
|
121
147
|
})),
|
|
122
148
|
path: Type.Optional(Type.String({
|
|
123
149
|
description: "Path to an existing worktree of the current repository to switch into instead of creating a new one. Must appear in `git worktree list` for the current repo (and live under the task root). Mutually exclusive with `name`.",
|
|
@@ -182,7 +208,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
182
208
|
const fence = rootCanon.ok ? rootCanon.value : repoRoot;
|
|
183
209
|
if (target !== fence && !target.startsWith(fence.endsWith("/") ? fence : `${fence}/`)) {
|
|
184
210
|
return errorResult(`Error (EnterWorktree): the worktree ${target} lives outside the task root ${repoRoot}; ` +
|
|
185
|
-
"
|
|
211
|
+
"read containment stays anchored at the task root, so it cannot be entered from this session.");
|
|
186
212
|
}
|
|
187
213
|
const head = await env.exec("git rev-parse HEAD", { cwd: target });
|
|
188
214
|
if (!head.ok || head.value.exitCode !== 0) {
|
|
@@ -193,44 +219,50 @@ export function createWorktreeTools(env, opts) {
|
|
|
193
219
|
session.current = { worktreeDir: target, originalCwd, baseSha: head.value.stdout.trim(), entered: true };
|
|
194
220
|
cwdRef.current = target;
|
|
195
221
|
return {
|
|
196
|
-
content: `Switched into the existing worktree at ${target}${previous ? ` (the previous worktree at ${previous.worktreeDir} was left on disk, untouched)` : ""}. ` +
|
|
197
|
-
"The session's working directory
|
|
198
|
-
"operate there
|
|
199
|
-
"task root. ExitWorktree will restore the original directory but will NOT remove a
|
|
200
|
-
"entered via `path`.",
|
|
222
|
+
content: `Switched into the existing worktree at ${target}${previous ? ` (the previous worktree at ${previous.worktreeDir} was left on disk, untouched, and is no longer writable)` : ""}. ` +
|
|
223
|
+
"The session's working directory and write access are now this worktree — subsequent commands and relative paths " +
|
|
224
|
+
"operate there, and writes outside it (the base checkout included) are outside the write roots. Reads still reach " +
|
|
225
|
+
"the whole task root; this is not a sandbox. ExitWorktree will restore the original directory but will NOT remove a " +
|
|
226
|
+
"worktree entered via `path`.",
|
|
201
227
|
details: { type: "worktree", action: "enter", worktreeDir: target },
|
|
202
228
|
};
|
|
203
229
|
}
|
|
230
|
+
const nameProblem = name === undefined ? undefined : worktreeNameProblem(name);
|
|
231
|
+
if (nameProblem !== undefined)
|
|
232
|
+
return errorResult(`Error (EnterWorktree): ${nameProblem.slice(0, 300)}.`);
|
|
204
233
|
const base = await resolveBaseCommit(env, repoRoot, baseRef ?? "fresh");
|
|
205
234
|
if ("error" in base)
|
|
206
235
|
return errorResult(`Error (EnterWorktree): ${base.error}.`);
|
|
207
|
-
let
|
|
236
|
+
let created;
|
|
208
237
|
try {
|
|
209
|
-
|
|
238
|
+
created = await addWorktree(env, {
|
|
210
239
|
repoRoot,
|
|
211
|
-
sessionId:
|
|
240
|
+
sessionId: "worktree",
|
|
241
|
+
...(name !== undefined ? { name } : {}),
|
|
212
242
|
commit: base.sha,
|
|
213
243
|
rootEnvAt: (dir) => Object.create(env, {
|
|
214
244
|
cwd: { value: dir, configurable: true },
|
|
215
245
|
destroy: { value: undefined, writable: true, configurable: true },
|
|
216
246
|
}),
|
|
217
247
|
});
|
|
218
|
-
createdDir = worktreeDir;
|
|
219
248
|
}
|
|
220
249
|
catch (e) {
|
|
221
250
|
return errorResult(`Error (EnterWorktree): ${thrownText(e)}`);
|
|
222
251
|
}
|
|
252
|
+
const createdDir = created.worktreeDir;
|
|
223
253
|
session.current = {
|
|
224
254
|
worktreeDir: createdDir,
|
|
225
255
|
originalCwd: cwdRef.current,
|
|
226
256
|
baseSha: base.sha,
|
|
257
|
+
name: created.name,
|
|
258
|
+
branch: created.branch,
|
|
227
259
|
};
|
|
228
260
|
cwdRef.current = createdDir;
|
|
229
261
|
return {
|
|
230
|
-
content: `Created worktree at ${createdDir} (base: ${base.label}${base.note ?? ""}). ` +
|
|
231
|
-
"The session's working directory
|
|
232
|
-
"operate there
|
|
233
|
-
"
|
|
262
|
+
content: `Created worktree at ${createdDir} (base: ${base.label}${base.note ?? ""}) on branch ${created.branch}. ` +
|
|
263
|
+
"The session's working directory and write access are now the worktree — subsequent commands and relative paths " +
|
|
264
|
+
"operate there, and writes outside it (the base checkout included) are outside the write roots. Reads still reach " +
|
|
265
|
+
"the rest of the task root; this is not a sandbox. " +
|
|
234
266
|
"Use ExitWorktree to leave (an unchanged worktree is removed; a changed one is kept).",
|
|
235
267
|
details: { type: "worktree", action: "create", worktreeDir: createdDir, base: base.label },
|
|
236
268
|
};
|
|
@@ -253,7 +285,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
253
285
|
description: "true = remove the worktree even when it has uncommitted files or new commits, permanently discarding them. Default false: a changed worktree is kept and its changes listed. Cannot be combined with `keep: true`.",
|
|
254
286
|
})),
|
|
255
287
|
action: Type.Optional(Type.Union([Type.Literal("keep"), Type.Literal("remove")], {
|
|
256
|
-
description: '"keep" leaves the worktree on disk. "remove" takes the default removal path: an unchanged worktree is removed, a changed one is still KEPT unless `discard_changes: true`.
|
|
288
|
+
description: '"keep" leaves the worktree and its branch on disk. "remove" takes the default removal path: an unchanged worktree is removed, a changed one is still KEPT unless `discard_changes: true`. A removed worktree\'s branch is deleted with it only when it carries no commits beyond the base; a branch with commits is kept and named in the reply.',
|
|
257
289
|
})),
|
|
258
290
|
discard_changes: Type.Optional(Type.Boolean({
|
|
259
291
|
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.',
|
|
@@ -377,13 +409,9 @@ export function createWorktreeTools(env, opts) {
|
|
|
377
409
|
details: { type: "worktree", action: "exit", worktreeDir: active.worktreeDir, kept: true },
|
|
378
410
|
};
|
|
379
411
|
}
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
? undefined
|
|
384
|
-
: r.ok
|
|
385
|
-
? (r.value.stderr || r.value.stdout || `exit ${r.value.exitCode}`).trim()
|
|
386
|
-
: reasonOf(r.error), (e) => reasonOf(e));
|
|
412
|
+
const removal = await removeManagedWorktree(env, repoRoot, active.worktreeDir, active.branch !== undefined ? { name: active.branch, baseSha: active.baseSha } : undefined);
|
|
413
|
+
const removeFailure = removal.ok ? undefined : removal.detail.trim();
|
|
414
|
+
const branchNote = !removal.ok ? "" : removal.branchKept !== undefined ? ` Its branch was kept: ${removal.branchKept}.` : removal.branchDeleted !== undefined ? ` Its branch ${removal.branchDeleted} was deleted.` : "";
|
|
387
415
|
const pruned = await pruneWorktrees(env, repoRoot);
|
|
388
416
|
const stillThere = await env.exists(active.worktreeDir);
|
|
389
417
|
const removalNote = removeFailure !== undefined ? ` (the removal command reported: ${removeFailure})` : "";
|
|
@@ -412,7 +440,7 @@ export function createWorktreeTools(env, opts) {
|
|
|
412
440
|
}
|
|
413
441
|
return {
|
|
414
442
|
content: `Exited the worktree session; working directory restored to ${restoredTo}${restoreNote}. ` +
|
|
415
|
-
`The worktree at ${active.worktreeDir} ${stateClause} and was removed.${removalNote}${pruneNote}`,
|
|
443
|
+
`The worktree at ${active.worktreeDir} ${stateClause} and was removed.${removalNote}${pruneNote}${branchNote}`,
|
|
416
444
|
details: { type: "worktree", action: "exit", worktreeDir: active.worktreeDir, kept: false, ...pruneDetail },
|
|
417
445
|
};
|
|
418
446
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.59.0",
|
|
4
4
|
"description": "Stateless, task-oriented AI agent core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -50,11 +50,12 @@
|
|
|
50
50
|
"packages/*"
|
|
51
51
|
],
|
|
52
52
|
"scripts": {
|
|
53
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.build.json --emitDeclarationOnly --removeComments false",
|
|
53
|
+
"build": "node scripts/build-root-deps.mjs && rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.build.json --emitDeclarationOnly --removeComments false",
|
|
54
54
|
"typecheck": "tsc --noEmit && echo \"typecheck OK (tsc --noEmit clean)\"",
|
|
55
55
|
"pretest": "npm run gate:debts",
|
|
56
56
|
"test": "vitest run --exclude \"**/*.local.test.ts\"",
|
|
57
57
|
"test:watch": "vitest",
|
|
58
|
+
"test:affected": "node scripts/affected-tests.mjs",
|
|
58
59
|
"gate:skips": "vitest run --exclude \"**/node_modules/**\" --exclude \"**/*.local.test.ts\" --reporter=default --reporter=json --outputFile.json=.skip-report.json && node scripts/verify-skip-baseline.mjs --report .skip-report.json --full",
|
|
59
60
|
"gate:live": "node scripts/run-live-gate.mjs",
|
|
60
61
|
"smoke": "tsx src/examples/smoke.ts",
|
|
@@ -112,12 +113,14 @@
|
|
|
112
113
|
"gate:comment-ratio": "vitest run test/comment-ratio-ratchet.test.ts",
|
|
113
114
|
"gate:negative-controls": "vitest run test/gate-negative-controls.test.ts",
|
|
114
115
|
"gate:memory-ga": "node scripts/gate-memory-distillation-ga.mjs",
|
|
116
|
+
"gate:tmp-hygiene": "node scripts/verify-tmp-hygiene.mjs",
|
|
115
117
|
"gate:all": "node scripts/gate-all.mjs",
|
|
116
118
|
"release:preflight": "node scripts/release-preflight.mjs",
|
|
117
119
|
"car:gate": "node scripts/car-gate.mjs"
|
|
118
120
|
},
|
|
119
121
|
"dependencies": {
|
|
120
122
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
123
|
+
"@sema-agent/primitives": "7.59.0",
|
|
121
124
|
"typebox": "1.1.39",
|
|
122
125
|
"undici": "7.30.0"
|
|
123
126
|
},
|