@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
|
@@ -6,6 +6,7 @@ import { resolveCheckpointStore } from "./checkpoint-store.js";
|
|
|
6
6
|
import { isLiveQuestionFace } from "./ask-question.js";
|
|
7
7
|
import { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
|
|
8
8
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
9
|
+
import { RUN_ORIGINS } from "./run-origin.js";
|
|
9
10
|
export const APPROVAL_REACH = Object.freeze(["none"]);
|
|
10
11
|
const APPROVAL_REACH_SET = new Set(APPROVAL_REACH);
|
|
11
12
|
export function isApprovalReach(v) {
|
|
@@ -161,8 +162,8 @@ function readSessionRulesFact(fact) {
|
|
|
161
162
|
return { childrenReadLive: fact };
|
|
162
163
|
}
|
|
163
164
|
export function deriveWiringManifest(facts) {
|
|
164
|
-
if (facts.half === "static" && facts.leg !== undefined) {
|
|
165
|
-
throw new Error("a static wiring manifest has no leg — leg identity is an effective-half fact");
|
|
165
|
+
if (facts.half === "static" && (facts.leg !== undefined || facts.runOrigin !== undefined)) {
|
|
166
|
+
throw new Error("a static wiring manifest has no leg — leg identity (its kind and its run origin) is an effective-half fact");
|
|
166
167
|
}
|
|
167
168
|
if (facts.half === "effective" && facts.leg === undefined) {
|
|
168
169
|
throw new Error("an effective wiring manifest requires its leg kind");
|
|
@@ -179,7 +180,7 @@ export function deriveWiringManifest(facts) {
|
|
|
179
180
|
: "absent";
|
|
180
181
|
const manifest = {
|
|
181
182
|
schemaVersion: 1,
|
|
182
|
-
...(facts.leg !== undefined ? { leg: { kind: facts.leg } } : {}),
|
|
183
|
+
...(facts.leg !== undefined ? { leg: { kind: facts.leg, ...(facts.runOrigin !== undefined ? { runOrigin: readWordFact(facts.runOrigin, RUN_ORIGINS, "run origin") } : {}) } } : {}),
|
|
183
184
|
ask: {
|
|
184
185
|
form: facts.askForm,
|
|
185
186
|
...(facts.askProvenance !== undefined ? { provenance: facts.askProvenance } : {}),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHERE A LEG STANDS, as one value: the ONE projection of it ({@link workspaceSnapshotOf}) and the ONE seat
|
|
3
|
+
* that announces it on the `workspace_changed` frame ({@link createWorkspaceFrameSeat}).
|
|
4
|
+
*
|
|
5
|
+
* The seat sends the leg-start snapshot when the leg binds its sink, and afterwards a frame only when the snapshot's digest
|
|
6
|
+
* differs from the last frame it sent — the digest is the snapshot's canonical JSON, so every member the projection carries
|
|
7
|
+
* takes part in the comparison with no second list to keep in step. The fixed members (root, project, remote) are leg
|
|
8
|
+
* facts handed in at prepare; the two live ones are read off the leg's own seats at each observation (the tracked cwd, the
|
|
9
|
+
* active EnterWorktree switch), never copied.
|
|
10
|
+
*/
|
|
11
|
+
import type { ActiveWorktreeSession } from "../internal/harness-types.js";
|
|
12
|
+
import type { SessionProject } from "./memory-engine/scope-contract.js";
|
|
13
|
+
import type { TaskEvent, TaskEventIdentity } from "./task-event.js";
|
|
14
|
+
/** The frame's value — derived from the `workspace_changed` arm of the event union (one source; never a hand-copied shape). */
|
|
15
|
+
export type WorkspaceSnapshot = Omit<Extract<TaskEvent, {
|
|
16
|
+
type: "workspace_changed";
|
|
17
|
+
}>, "type" | keyof TaskEventIdentity>;
|
|
18
|
+
/** What a leg's snapshot is projected from. */
|
|
19
|
+
export interface WorkspaceFacts {
|
|
20
|
+
/** The leg's task root as its root receiving point settled it (`resolveTaskRootCanonical`). */
|
|
21
|
+
readonly root: string;
|
|
22
|
+
/** The leg's tracked logical cwd — present only where a real shell is mounted; absent ⇒ the cwd is `root`. */
|
|
23
|
+
readonly cwdRef?: {
|
|
24
|
+
readonly current: string;
|
|
25
|
+
};
|
|
26
|
+
/** The leg's EnterWorktree seat — present only where the worktree tools are mounted. */
|
|
27
|
+
readonly worktreeSessionRef?: {
|
|
28
|
+
readonly current?: ActiveWorktreeSession;
|
|
29
|
+
};
|
|
30
|
+
/** The leg's project verdict (`resolveSessionProject`); absent ⇒ the leg has no project identity. */
|
|
31
|
+
readonly project?: SessionProject;
|
|
32
|
+
/** The leg's one remoteness reading (the restore phase's, the same value `ResolvedWorkspace.remote` carries). */
|
|
33
|
+
readonly remote: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** The ONE mint of the `workspace_changed` value. */
|
|
36
|
+
export declare function workspaceSnapshotOf(facts: WorkspaceFacts): WorkspaceSnapshot;
|
|
37
|
+
/** The leg's frame seat (held on `Prepared`): the run binds its sink once, and observes after every tool that may have moved the leg. */
|
|
38
|
+
export interface WorkspaceFrameSeat {
|
|
39
|
+
/** Bind this leg's frame sink and send the leg-start snapshot through it. The first binding wins; a later one is ignored. */
|
|
40
|
+
subscribe(push: (snapshot: WorkspaceSnapshot) => void): void;
|
|
41
|
+
/** Re-project, and send iff the snapshot differs from the last one sent. Nothing is sent before the sink is bound. */
|
|
42
|
+
observe(): void;
|
|
43
|
+
}
|
|
44
|
+
export declare function createWorkspaceFrameSeat(facts: WorkspaceFacts): WorkspaceFrameSeat;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { canonicalJsonStringify } from "./canonical-json.js";
|
|
2
|
+
export function workspaceSnapshotOf(facts) {
|
|
3
|
+
const active = facts.worktreeSessionRef?.current;
|
|
4
|
+
return {
|
|
5
|
+
cwd: facts.cwdRef?.current ?? facts.root,
|
|
6
|
+
root: facts.root,
|
|
7
|
+
...(active !== undefined ? { entered: { dir: active.worktreeDir, ...(active.entered === true ? { byPath: true } : {}) } } : {}),
|
|
8
|
+
...(facts.project !== undefined ? { project: { id: facts.project.id, source: facts.project.source } } : {}),
|
|
9
|
+
remote: facts.remote,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function createWorkspaceFrameSeat(facts) {
|
|
13
|
+
let push;
|
|
14
|
+
let lastSent;
|
|
15
|
+
const send = () => {
|
|
16
|
+
if (push === undefined)
|
|
17
|
+
return;
|
|
18
|
+
const snapshot = workspaceSnapshotOf(facts);
|
|
19
|
+
const digest = canonicalJsonStringify(snapshot);
|
|
20
|
+
if (digest === lastSent)
|
|
21
|
+
return;
|
|
22
|
+
lastSent = digest;
|
|
23
|
+
push(snapshot);
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
subscribe(sink) {
|
|
27
|
+
if (push !== undefined)
|
|
28
|
+
return;
|
|
29
|
+
push = sink;
|
|
30
|
+
send();
|
|
31
|
+
},
|
|
32
|
+
observe: send,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExecutionEnv } from "../internal/harness-types.js";
|
|
2
2
|
import type { ObservedFilesystem } from "../tools/fs/shell-read-environment.js";
|
|
3
3
|
import type { PermissionResult } from "./tool-policy.js";
|
|
4
|
+
import { type GuardHitVia } from "./path-guard-rows.js";
|
|
4
5
|
import { type ToolCallLike } from "./tool-registry.js";
|
|
5
6
|
/**
|
|
6
7
|
* How one table row matches the judged path:
|
|
@@ -106,7 +107,7 @@ export type WriteProtectionVerdict = {
|
|
|
106
107
|
} | {
|
|
107
108
|
readonly kind: "hit";
|
|
108
109
|
readonly hit: WriteProtectedHit;
|
|
109
|
-
readonly via:
|
|
110
|
+
readonly via: GuardHitVia;
|
|
110
111
|
} | {
|
|
111
112
|
readonly kind: "unresolvable";
|
|
112
113
|
readonly cause: string;
|
|
@@ -206,6 +207,27 @@ export interface WriteProtectionCompileOptions {
|
|
|
206
207
|
* cannot answer path questions), and its consumer announces once per leg rather than once per write.
|
|
207
208
|
*/
|
|
208
209
|
readonly onViewAbsent?: (absence: WriteProtectionViewAbsence) => void;
|
|
210
|
+
/**
|
|
211
|
+
* The leg's CURRENT write location when it is a managed worktree — read once per judgment; `undefined` while the leg writes
|
|
212
|
+
* a directory that is not one. Each entry is one spelling of that tree: its `root` (`<base>/.sema/worktrees/<slug>`) and the
|
|
213
|
+
* `base` checkout it was minted under; `kind: "canonical"` is the tree's canonical identity, `kind: "spelled"` the spelling
|
|
214
|
+
* the leg's cwd and spellings carry it under (the task root as given, which may reach it through an alias).
|
|
215
|
+
*
|
|
216
|
+
* THE CURRENT-TREE READING (the reference implementation's `.claude/worktrees` exemption, narrowed to the one tree this leg
|
|
217
|
+
* writes): every view of a target that lies inside the tree is judged as the SAME relative path in `base` — only the managed
|
|
218
|
+
* prefix is removed, so the base checkout's own ancestry is judged as ever, a tree's own `.sema/settings.json` or `.git` is
|
|
219
|
+
* judged as the base checkout's, and an ordinary file of the tree meets no `.sema` row. A view outside the tree (a sibling
|
|
220
|
+
* tree, any other path) is judged as it stands. Narrow by construction, because this reading exempts: containment is
|
|
221
|
+
* byte-exact (no case fold), the canonical view is compared with the canonical identity alone, and a remainder that carries a
|
|
222
|
+
* `.` or `..` segment is judged as it stands (where it lands is not decided here).
|
|
223
|
+
*/
|
|
224
|
+
readonly checkoutOf?: () => ReadonlyArray<ManagedCheckoutView> | undefined;
|
|
225
|
+
}
|
|
226
|
+
/** One spelling of the leg's current managed tree ({@link WriteProtectionCompileOptions.checkoutOf}). */
|
|
227
|
+
export interface ManagedCheckoutView {
|
|
228
|
+
readonly root: string;
|
|
229
|
+
readonly base: string;
|
|
230
|
+
readonly kind: "canonical" | "spelled";
|
|
209
231
|
}
|
|
210
232
|
/**
|
|
211
233
|
* Compile the write-protection judge for a deployment configuration. Returns `undefined` when the
|
|
@@ -223,6 +245,12 @@ export declare function compileWriteProtection(entries?: readonly WriteProtected
|
|
|
223
245
|
* ask carries that table's class) or a deployment's guarded write row (`ToolPolicy.writeGuardRows`: the target is not
|
|
224
246
|
* placed). */
|
|
225
247
|
export type WriteTargetCoverage = "protected" | "guarded";
|
|
248
|
+
/** One file of the engine's own the table does not demote: its declared spelling and the canonical key the run admitted it
|
|
249
|
+
* under (the session plan file, `TaskSpec.planFile`, as the advertised-writable seat holds it). ENGINE-INTERNAL. */
|
|
250
|
+
export interface ExemptFile {
|
|
251
|
+
readonly spelled: string;
|
|
252
|
+
readonly key: string;
|
|
253
|
+
}
|
|
226
254
|
/** The leg's write judgment, compiled once ({@link compileLegWriteJudgment}). ENGINE-INTERNAL (not re-exported from
|
|
227
255
|
* `src/index.ts`). */
|
|
228
256
|
export interface LegWriteJudgment {
|
|
@@ -236,6 +264,7 @@ export interface LegWriteJudgment {
|
|
|
236
264
|
readonly fs: ObservedFilesystem;
|
|
237
265
|
readonly signal?: AbortSignal;
|
|
238
266
|
readonly canonical?: true;
|
|
267
|
+
readonly spellingOnly?: true;
|
|
239
268
|
}) => Promise<WriteTargetCoverage | undefined>) | undefined;
|
|
240
269
|
}
|
|
241
270
|
/**
|
|
@@ -246,6 +275,7 @@ export interface LegWriteJudgment {
|
|
|
246
275
|
*/
|
|
247
276
|
export declare function compileLegWriteJudgment(entries: readonly WriteProtectedEntry[], opts: Omit<WriteProtectionCompileOptions, "dataRoot"> & {
|
|
248
277
|
readonly exemptRoots: readonly string[];
|
|
278
|
+
readonly exemptFiles?: readonly ExemptFile[];
|
|
249
279
|
readonly guardRows?: import("./tool-policy.js").ToolPolicy["writeGuardRows"];
|
|
250
280
|
}): LegWriteJudgment;
|
|
251
281
|
/**
|
|
@@ -254,8 +284,11 @@ export declare function compileLegWriteJudgment(entries: readonly WriteProtected
|
|
|
254
284
|
* · `hit` ⇒ `ask` (`safety`; no `requiresRealApproval` — one explicit look, clearable by an approver, a
|
|
255
285
|
* blanket `onAsk:"allow"`, the classifier or a matching persisted rule). The matched row NAME goes on the
|
|
256
286
|
* message (table names are deployment-validated vocabulary); the model-authored target path deliberately
|
|
257
|
-
* does not — `message` is the classifier's `askMessage`, and the approval card already shows the args.
|
|
258
|
-
*
|
|
287
|
+
* does not — `message` is the classifier's `askMessage`, and the approval card already shows the args. ONE
|
|
288
|
+
* sentence for every view: the row first, then — when the reading that met it is not the spelling — the one reach
|
|
289
|
+
* clause every guard's sentence uses ({@link guardHitReachClause}); a hit through the real target and a hit through a
|
|
290
|
+
* hop of the link chain are one fact to the classifier and the approver, so they read one sentence. The spelling
|
|
291
|
+
* view's sentence is the historical one byte for byte.
|
|
259
292
|
* · `unresolvable` ⇒ `deny` (`safety`; reason word `target_unresolved` on the sentence): where the write lands could not be
|
|
260
293
|
* determined, so this table cannot say it is not a protected path — refused in every permission mode (a refusal, not a
|
|
261
294
|
* question a mode releases), the reference's write check form ("where it leads on disk could not be determined").
|
|
@@ -270,6 +303,13 @@ export declare function writeProtectionTightenDecision(toolName: string, verdict
|
|
|
270
303
|
* it took no part.
|
|
271
304
|
*/
|
|
272
305
|
export declare function writeProtectionMandated(verdict: WriteProtectionVerdict): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* WHICH of the two table classes a verdict's hit is — the one reading of `via` as the class fact, beside the mandate predicate:
|
|
308
|
+
* `spelling` ⇒ the path as written names the row (`write_protection`); `target` / `chain` ⇒ the row is met only where the path
|
|
309
|
+
* resolves on disk (`write_protection_on_disk`) — the judge reads the spelling first and answers there on a hit, so a resolved
|
|
310
|
+
* reading is the answer only for a spelling that names no row. `undefined` for a verdict that is not a hit.
|
|
311
|
+
*/
|
|
312
|
+
export declare function writeProtectionReachOf(verdict: WriteProtectionVerdict): "spelling" | "on_disk" | undefined;
|
|
273
313
|
/**
|
|
274
314
|
* The ENGINE-FILLED gate input (`ToolGateInput.writeProtectionCheck`). Returns `null` SYNCHRONOUSLY when the
|
|
275
315
|
* call is not this layer's business — not a covered write, or no resolvable target string — and otherwise
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { anchorSpelling, canonicalizeTarget, isAbsoluteForFamily, isWinFormPath, writeTargetPath, isUncPath, pathFamilyOf } from "../tools/fs/safety.js";
|
|
2
|
-
import { judgePathRows } from "./path-guard-rows.js";
|
|
1
|
+
import { anchorSpelling, canonicalizeTarget, isAbsoluteForFamily, isWinFormPath, normalizeAbsPathLexically, writeTargetPath, isUncPath, pathFamilyOf } from "../tools/fs/safety.js";
|
|
2
|
+
import { checkoutReadingOf, guardHitReachClause, guardHitVia, judgePathRows } from "./path-guard-rows.js";
|
|
3
3
|
import { protectivePathTargetOf } from "./tool-registry.js";
|
|
4
4
|
import { pathTargetBaseOf } from "./effective-path-target.js";
|
|
5
5
|
import { canonicalDataRootKeys, dataRootSpellings, relativeUnderRoot } from "./sensitive-path-policy.js";
|
|
@@ -207,6 +207,22 @@ export function spelledExemptionOf(dataRootPaths) {
|
|
|
207
207
|
return (spelling) => relativeUnderDataRoot(spelling, roots);
|
|
208
208
|
}
|
|
209
209
|
export const WRITE_PROTECTION_TARGET_VIEWS = Object.freeze(["spelling-only", "target"]);
|
|
210
|
+
function judgedInCheckout(path, checkout, kind) {
|
|
211
|
+
const reading = checkoutReadingOf(kind);
|
|
212
|
+
for (const c of checkout ?? []) {
|
|
213
|
+
if (reading === "canonical-only" && c.kind !== "canonical")
|
|
214
|
+
continue;
|
|
215
|
+
const rel = relativeUnderRoot(path, c.root);
|
|
216
|
+
if (rel === null)
|
|
217
|
+
continue;
|
|
218
|
+
if (rel.split("/").some((s) => s === "." || s === ".."))
|
|
219
|
+
return path;
|
|
220
|
+
if (rel === "")
|
|
221
|
+
return c.base;
|
|
222
|
+
return c.base.endsWith("/") ? `${c.base}${rel}` : `${c.base}/${rel}`;
|
|
223
|
+
}
|
|
224
|
+
return path;
|
|
225
|
+
}
|
|
210
226
|
export function compileWriteProtection(entries, opts) {
|
|
211
227
|
const rows = resolveWriteProtectedTable(entries);
|
|
212
228
|
if (rows.length === 0)
|
|
@@ -223,6 +239,10 @@ export function compileLegWriteJudgment(entries, opts) {
|
|
|
223
239
|
judgeWriteTarget: rows.length === 0 && guardRows === undefined
|
|
224
240
|
? undefined
|
|
225
241
|
: async (target, judgeOpts) => {
|
|
242
|
+
if (judgeOpts.spellingOnly === true) {
|
|
243
|
+
const spelled = await compiled.judgment(target, {}, undefined);
|
|
244
|
+
return spelled !== undefined && spelled.unreadable === undefined && TABLE_ROWS.has(spelled.row) ? "protected" : undefined;
|
|
245
|
+
}
|
|
226
246
|
const hit = await compiled.judgment(target, { ...(judgeOpts.signal !== undefined ? { signal: judgeOpts.signal } : {}), ...(judgeOpts.canonical === true ? { canonical: true } : {}) }, judgeOpts.fs, guardRows);
|
|
227
247
|
return hit === undefined ? undefined : hit.unreadable === undefined && TABLE_ROWS.has(hit.row) ? "protected" : "guarded";
|
|
228
248
|
},
|
|
@@ -234,6 +254,8 @@ function heldRows(cause) {
|
|
|
234
254
|
}
|
|
235
255
|
function compileWriteJudgment(rows, origin, opts) {
|
|
236
256
|
const dataRootPaths = opts.exemptRoots;
|
|
257
|
+
const exemptFileKeys = (opts.exemptFiles ?? []).map((f) => f.key);
|
|
258
|
+
const exemptFileSpellings = new Set((opts.exemptFiles ?? []).flatMap((f) => [normalizeAbsPathLexically(f.spelled), normalizeAbsPathLexically(f.key)]));
|
|
237
259
|
const spelledRemainder = spelledExemptionOf(dataRootPaths);
|
|
238
260
|
const readingMemo = new Map();
|
|
239
261
|
const readingsOf = (spelling) => {
|
|
@@ -275,9 +297,10 @@ function compileWriteJudgment(rows, origin, opts) {
|
|
|
275
297
|
return readingsOf(view.path).some((segs) => roots.some((root) => atConfigRoot(segs, root.map(foldWriteProtectSegment), tail))) ? REACHED : NOT_REACHED;
|
|
276
298
|
}, { below: opts?.agentConfigDir ?? "" }));
|
|
277
299
|
const tableAt = (canonicalRoots) => (configTails.length === 0 ? tableRows : [...tableRows, ...configRowsAt(canonicalRoots)]);
|
|
278
|
-
const spelledView = (spelled, kind) => {
|
|
279
|
-
const
|
|
280
|
-
|
|
300
|
+
const spelledView = (spelled, kind, checkout) => {
|
|
301
|
+
const judgedPath = judgedInCheckout(spelled, checkout, kind);
|
|
302
|
+
const remainder = spelledRemainder(judgedPath);
|
|
303
|
+
return { path: judgedPath, kind, ...(remainder !== null ? { exemptRemainder: remainder } : {}) };
|
|
281
304
|
};
|
|
282
305
|
const anchoredSpelling = (path, cwd) => {
|
|
283
306
|
const base = typeof cwd === "string" && cwd.length > 0 ? cwd : undefined;
|
|
@@ -307,9 +330,11 @@ function compileWriteJudgment(rows, origin, opts) {
|
|
|
307
330
|
})();
|
|
308
331
|
const givenKey = ctx.canonical === true && env !== undefined;
|
|
309
332
|
const base = ctx.base ?? ctx.cwd ?? rootPath;
|
|
310
|
-
const
|
|
333
|
+
const checkout = opts.checkoutOf?.();
|
|
334
|
+
const lexical = givenKey ? undefined : spelledView(anchoredSpelling(path, ctx.base ?? ctx.cwd), "lexical", checkout);
|
|
311
335
|
const bySpelling = lexical === undefined ? undefined : judgePathRows([...tableAt([]), ...extra], { views: [lexical] }, "tighten");
|
|
312
|
-
|
|
336
|
+
const namesExemptFile = lexical !== undefined && env !== undefined && exemptFileSpellings.has(normalizeAbsPathLexically(lexical.path));
|
|
337
|
+
if (bySpelling !== undefined && bySpelling.unreadable === undefined && TABLE_ROWS.has(bySpelling.row) && !namesExemptFile)
|
|
313
338
|
return bySpelling;
|
|
314
339
|
if (env === undefined)
|
|
315
340
|
return bySpelling;
|
|
@@ -338,11 +363,13 @@ function compileWriteJudgment(rows, origin, opts) {
|
|
|
338
363
|
const canonicalRoots = canonKey === undefined || configTails.length === 0 || opts?.agentConfigDir === undefined ? [] : (await canonicalDataRootKeys(env, [opts.agentConfigDir], ctx.signal, rootLookupFailed)).map(agentConfigDirSegments);
|
|
339
364
|
const table = [...tableAt(canonicalRoots), ...extra];
|
|
340
365
|
const aliased = canonAliased ? { aliasResolved: true } : {};
|
|
341
|
-
const views = [...(lexical !== undefined ? [{ ...lexical, ...aliased }] : []), ...(canonKey !== undefined ? [{ path: canonKey, kind: "canonical", ...aliased }] : [])];
|
|
366
|
+
const views = [...(lexical !== undefined ? [{ ...lexical, ...aliased }] : []), ...(canonKey !== undefined ? [{ path: judgedInCheckout(canonKey, checkout, "canonical"), kind: "canonical", ...aliased }] : [])];
|
|
342
367
|
const identity = {};
|
|
343
368
|
const identityRemainder = () => (identity.asked ??= (async () => {
|
|
344
369
|
if (canonKey === undefined)
|
|
345
370
|
return undefined;
|
|
371
|
+
if (exemptFileKeys.includes(canonKey))
|
|
372
|
+
return "";
|
|
346
373
|
for (const rootKey of await canonicalDataRootKeys(env, dataRootPaths, ctx.signal, rootLookupFailed)) {
|
|
347
374
|
const relative = relativeUnderRoot(canonKey, rootKey);
|
|
348
375
|
if (relative !== null)
|
|
@@ -377,7 +404,7 @@ function compileWriteJudgment(rows, origin, opts) {
|
|
|
377
404
|
targetUnread ??= chain.value.cause;
|
|
378
405
|
}
|
|
379
406
|
for (const hop of chainHopsOrNone(chain.value))
|
|
380
|
-
views.push(spelledView(hop, "hop"));
|
|
407
|
+
views.push(spelledView(hop, "hop", checkout));
|
|
381
408
|
}
|
|
382
409
|
return judged();
|
|
383
410
|
};
|
|
@@ -385,7 +412,7 @@ function compileWriteJudgment(rows, origin, opts) {
|
|
|
385
412
|
rows,
|
|
386
413
|
targetView: opts?.env === undefined ? "spelling-only" : "target",
|
|
387
414
|
matchPath(path, cwd) {
|
|
388
|
-
const hit = judgePathRows(tableAt([]), { views: [spelledView(anchoredSpelling(path, cwd), "lexical")] }, "tighten");
|
|
415
|
+
const hit = judgePathRows(tableAt([]), { views: [spelledView(anchoredSpelling(path, cwd), "lexical", opts.checkoutOf?.())] }, "tighten");
|
|
389
416
|
return hit === undefined ? null : { name: hit.row.name, kind: hit.row.kind };
|
|
390
417
|
},
|
|
391
418
|
async judge(path, ctx = {}) {
|
|
@@ -417,7 +444,7 @@ function atConfigRoot(segs, root, tail) {
|
|
|
417
444
|
return segs.length >= root.length + tail.length && root.every((a, i) => segs[i] === a) && tail.every((t, i) => segs[root.length + i] === t);
|
|
418
445
|
}
|
|
419
446
|
function verdictOf(hit) {
|
|
420
|
-
return { kind: "hit", hit: { name: hit.row.name, kind: hit.row.kind }, via: hit.viewKind
|
|
447
|
+
return { kind: "hit", hit: { name: hit.row.name, kind: hit.row.kind }, via: guardHitVia(hit.viewKind) };
|
|
421
448
|
}
|
|
422
449
|
export function writeProtectionTightenDecision(toolName, verdict) {
|
|
423
450
|
if (verdict.kind === "clear")
|
|
@@ -429,19 +456,19 @@ export function writeProtectionTightenDecision(toolName, verdict) {
|
|
|
429
456
|
decisionReason: "safety",
|
|
430
457
|
};
|
|
431
458
|
}
|
|
459
|
+
const reach = guardHitReachClause(verdict.via);
|
|
432
460
|
return {
|
|
433
461
|
action: "ask",
|
|
434
|
-
message: verdict.
|
|
435
|
-
? `tool "${toolName}" writes to a write-protected path — its real target resolves onto table entry "${verdict.hit.name}" — explicit approval required`
|
|
436
|
-
: verdict.via === "chain"
|
|
437
|
-
? `tool "${toolName}" writes to a write-protected path — its symlink chain passes through table entry "${verdict.hit.name}" — explicit approval required`
|
|
438
|
-
: `tool "${toolName}" writes to a write-protected path (table entry "${verdict.hit.name}") — explicit approval required`,
|
|
462
|
+
message: `tool "${toolName}" writes to a write-protected path (table entry "${verdict.hit.name}")${reach !== undefined ? ` — ${reach}` : ""} — explicit approval required`,
|
|
439
463
|
decisionReason: "safety",
|
|
440
464
|
};
|
|
441
465
|
}
|
|
442
466
|
export function writeProtectionMandated(verdict) {
|
|
443
467
|
return verdict.kind === "hit";
|
|
444
468
|
}
|
|
469
|
+
export function writeProtectionReachOf(verdict) {
|
|
470
|
+
return verdict.kind !== "hit" ? undefined : verdict.via === "spelling" ? "spelling" : "on_disk";
|
|
471
|
+
}
|
|
445
472
|
export function createWriteProtectionCheck(entries, opts) {
|
|
446
473
|
const matcher = compileWriteProtection(entries, opts);
|
|
447
474
|
return matcher === undefined ? undefined : writeProtectionMountOver(matcher, opts?.rootPath);
|
|
@@ -583,10 +583,36 @@ function createSummarizationOptions(model, maxTokens, apiKey, headers, signal, t
|
|
|
583
583
|
return options;
|
|
584
584
|
}
|
|
585
585
|
async function completeSummarization(model, context, options, streamFn, runtime) {
|
|
586
|
-
|
|
587
|
-
|
|
586
|
+
const call = async () => streamFn ? (await streamFn(model, context, options)).result() : await resolveAgentCoreCompleteFn(runtime)(model, context, options);
|
|
587
|
+
const signal = options.signal;
|
|
588
|
+
if (signal === undefined)
|
|
589
|
+
return await call();
|
|
590
|
+
if (signal.aborted)
|
|
591
|
+
return summaryCallAborted(model);
|
|
592
|
+
let release = () => undefined;
|
|
593
|
+
const cut = new Promise((resolve) => {
|
|
594
|
+
const onAbort = () => resolve(summaryCallAborted(model));
|
|
595
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
596
|
+
release = () => signal.removeEventListener("abort", onAbort);
|
|
597
|
+
});
|
|
598
|
+
try {
|
|
599
|
+
return await Promise.race([cut, call()]);
|
|
600
|
+
}
|
|
601
|
+
finally {
|
|
602
|
+
release();
|
|
588
603
|
}
|
|
589
|
-
|
|
604
|
+
}
|
|
605
|
+
function summaryCallAborted(model) {
|
|
606
|
+
return {
|
|
607
|
+
role: "assistant",
|
|
608
|
+
content: [],
|
|
609
|
+
api: model.api,
|
|
610
|
+
provider: model.provider,
|
|
611
|
+
model: model.id,
|
|
612
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
|
|
613
|
+
stopReason: "aborted",
|
|
614
|
+
timestamp: Date.now(),
|
|
615
|
+
};
|
|
590
616
|
}
|
|
591
617
|
const SUMMARY_REASONING_FLOOR = 2048;
|
|
592
618
|
const SUMMARY_MAX_ESCALATIONS = 2;
|
|
@@ -93,8 +93,8 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
|
|
|
93
93
|
get withheldEnv(): readonly SecretEnvFinding[];
|
|
94
94
|
/** The environment the next shell child would receive, for a READ (the scrub seat is the reader's collector or a
|
|
95
95
|
* no-op: a read announces nothing). `undefined` when no child would be spawned at all — the policy is refused against
|
|
96
|
-
* the own credentials declared since construction, and every spawn throws that reason — so
|
|
97
|
-
* gets none", never a throw. */
|
|
96
|
+
* the own credentials declared since construction, or `shellEnv` is no grant, and every spawn throws that reason — so
|
|
97
|
+
* a reader sees "the child gets none", never a throw. Composed once: the refusal is the composition's own. */
|
|
98
98
|
private childEnvForRead;
|
|
99
99
|
private shellPath?;
|
|
100
100
|
private shellEnv?;
|
|
@@ -118,7 +118,8 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
|
|
|
118
118
|
shellEnv?: NodeJS.ProcessEnv;
|
|
119
119
|
/** VENDORED EDIT (D1, security): how much of `process.env` the shell child inherits. Default `"scrub"` =
|
|
120
120
|
* fail-closed (drop secret-pattern keys, keep PATH/build/locale). `"all"` = full inherit (trusted env);
|
|
121
|
-
* `string[]` = strict allowlist. `shellEnv`/per-exec `env` always pass through
|
|
121
|
+
* `string[]` = strict allowlist. `shellEnv`/per-exec `env` always pass through (`hostChildEnv`'s grants: one that is
|
|
122
|
+
* not a map of variable names to strings throws here and at the spawn). Any other value — an unknown
|
|
122
123
|
* word, a non-string, a list entry that is not a variable name — throws here (`inheritEnvPolicyProblem`'s
|
|
123
124
|
* reason), the same judgment the oracle gate's `inheritEnv` meets. Whatever the policy, the deployment's own
|
|
124
125
|
* credentials (`declareWithheldEnv`: by name, and by a value equal to a declared or engine-held credential value)
|
|
@@ -3,20 +3,22 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { closeSync, constants, createReadStream, mkdtempSync, openSync, readSync, rmSync, statSync, truncateSync, unlinkSync } from "node:fs";
|
|
4
4
|
import { access, appendFile, lstat, mkdir, mkdtemp, open, readdir, readFile, readlink, rename, rm, stat, unlink, writeFile, } from "node:fs/promises";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
|
-
import { isAbsolute, join,
|
|
6
|
+
import { dirname, isAbsolute, join, sep } from "node:path";
|
|
7
7
|
import { createInterface } from "node:readline";
|
|
8
8
|
import { ExecutionError, err, FileError, ok, toError, } from "../harness/types.js";
|
|
9
9
|
import { killProcessTree, shutdownDebug } from "./kill-tree.js";
|
|
10
|
-
import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub,
|
|
10
|
+
import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub, hostChildEnv, hostChildEnvProblem, inheritedHostEnv } from "../../core/secret-env.js";
|
|
11
11
|
import { physicalPathOfAsync } from "../../core/physical-path.js";
|
|
12
12
|
import { posixModeBitsMeaningful } from "../../core/posix-mode-face.js";
|
|
13
|
-
import { walkSymlinkChain } from "./symlink-chain.js";
|
|
13
|
+
import { anchorAtLinkDir, walkSymlinkChain } from "./symlink-chain.js";
|
|
14
14
|
import { RollingTailBuffer, markTruncated, newStreamCursorState, sliceStreamIncrement, } from "../../core/exec-output-tail.js";
|
|
15
15
|
import { BackgroundShellError } from "../../core/background-shell.js";
|
|
16
16
|
import { SchedulerError } from "../../core/scheduler.js";
|
|
17
17
|
const MAX_TIMER_TIMEOUT_MS = 2_147_000_000;
|
|
18
18
|
function resolvePath(cwd, path) {
|
|
19
|
-
|
|
19
|
+
if (isAbsolute(path))
|
|
20
|
+
return path;
|
|
21
|
+
return anchorAtLinkDir(isAbsolute(cwd) ? cwd : anchorAtLinkDir(process.cwd(), cwd, sep), path, sep);
|
|
20
22
|
}
|
|
21
23
|
export function resolveExecTimeoutMs(timeoutSeconds) {
|
|
22
24
|
if (typeof timeoutSeconds !== "number" ||
|
|
@@ -246,9 +248,7 @@ export function __resetSecretScrubAnnouncement() {
|
|
|
246
248
|
__resetSecretEnvScrubNoticeAnnouncement();
|
|
247
249
|
}
|
|
248
250
|
function getShellEnv(inheritEnv, baseEnv, extraEnv, onScrub, onNotice) {
|
|
249
|
-
const
|
|
250
|
-
const inherited = inheritedHostEnv(inheritEnv, scrubbed);
|
|
251
|
-
const findings = scrubbed.filter((f) => baseEnv?.[f.key] === undefined && extraEnv?.[f.key] === undefined);
|
|
251
|
+
const { env, withheld: findings } = hostChildEnv(inheritEnv, baseEnv, extraEnv);
|
|
252
252
|
if (findings.length > 0) {
|
|
253
253
|
if (typeof onScrub === "function") {
|
|
254
254
|
try {
|
|
@@ -273,11 +273,7 @@ function getShellEnv(inheritEnv, baseEnv, extraEnv, onScrub, onNotice) {
|
|
|
273
273
|
announceSecretEnvScrub(onNotice, findings);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
return
|
|
277
|
-
...inherited,
|
|
278
|
-
...baseEnv,
|
|
279
|
-
...extraEnv,
|
|
280
|
-
};
|
|
276
|
+
return env;
|
|
281
277
|
}
|
|
282
278
|
const EXIT_SETTLE_DRAIN_MS = 500;
|
|
283
279
|
const EXEC_SPOOL_PUMP_MS = 200;
|
|
@@ -331,9 +327,12 @@ export class NodeExecutionEnv {
|
|
|
331
327
|
return withheld;
|
|
332
328
|
}
|
|
333
329
|
childEnvForRead(collect = () => { }) {
|
|
334
|
-
|
|
330
|
+
try {
|
|
331
|
+
return getShellEnv(this.inheritEnv, this.shellEnv, undefined, collect);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
335
334
|
return undefined;
|
|
336
|
-
|
|
335
|
+
}
|
|
337
336
|
}
|
|
338
337
|
shellPath;
|
|
339
338
|
shellEnv;
|
|
@@ -351,7 +350,7 @@ export class NodeExecutionEnv {
|
|
|
351
350
|
this.cwd = options.cwd;
|
|
352
351
|
this.shellPath = options.shellPath;
|
|
353
352
|
this.shellEnv = options.shellEnv;
|
|
354
|
-
const inheritEnvProblem =
|
|
353
|
+
const inheritEnvProblem = hostChildEnvProblem(options.inheritEnv, options.shellEnv);
|
|
355
354
|
if (inheritEnvProblem !== undefined)
|
|
356
355
|
throw new Error(`NodeExecutionEnv: ${inheritEnvProblem}`);
|
|
357
356
|
this.inheritEnv = Array.isArray(options.inheritEnv) ? [...options.inheritEnv] : (options.inheritEnv ?? "scrub");
|
|
@@ -396,7 +395,9 @@ export class NodeExecutionEnv {
|
|
|
396
395
|
return ok(resolvePath(this.cwd, path));
|
|
397
396
|
}
|
|
398
397
|
async joinPath(parts) {
|
|
399
|
-
|
|
398
|
+
const leading = sep === "\\" ? /^[\\/]+/ : /^\/+/;
|
|
399
|
+
const named = parts.map((part, i) => (i === 0 ? part : part.replace(leading, ""))).filter((part) => part !== "");
|
|
400
|
+
return ok(named.length === 0 ? "." : named.reduce((at, part) => anchorAtLinkDir(at, part, sep)));
|
|
400
401
|
}
|
|
401
402
|
async exec(command, options) {
|
|
402
403
|
if (options?.abortSignal?.aborted) {
|
|
@@ -831,7 +832,7 @@ export class NodeExecutionEnv {
|
|
|
831
832
|
return aborted;
|
|
832
833
|
}
|
|
833
834
|
try {
|
|
834
|
-
await mkdir(
|
|
835
|
+
await mkdir(dirname(resolved), { recursive: true });
|
|
835
836
|
}
|
|
836
837
|
catch (error) {
|
|
837
838
|
return err(toFileError(error, resolved));
|
|
@@ -854,8 +855,8 @@ export class NodeExecutionEnv {
|
|
|
854
855
|
let hop;
|
|
855
856
|
try {
|
|
856
857
|
const link = await readlink(resolved);
|
|
857
|
-
const parentReal = await physicalPathOfAsync(
|
|
858
|
-
hop = isAbsolute(link) ? link :
|
|
858
|
+
const parentReal = await physicalPathOfAsync(dirname(resolved)).catch(() => dirname(resolved));
|
|
859
|
+
hop = isAbsolute(link) ? link : anchorAtLinkDir(parentReal, link, sep);
|
|
859
860
|
}
|
|
860
861
|
catch {
|
|
861
862
|
hop = undefined;
|
|
@@ -956,7 +957,7 @@ export class NodeExecutionEnv {
|
|
|
956
957
|
return aborted;
|
|
957
958
|
}
|
|
958
959
|
try {
|
|
959
|
-
await mkdir(
|
|
960
|
+
await mkdir(dirname(resolved), { recursive: true });
|
|
960
961
|
}
|
|
961
962
|
catch (error) {
|
|
962
963
|
return err(toFileError(error, resolved));
|
|
@@ -979,7 +980,7 @@ export class NodeExecutionEnv {
|
|
|
979
980
|
async appendFile(path, content) {
|
|
980
981
|
const resolved = resolvePath(this.cwd, path);
|
|
981
982
|
try {
|
|
982
|
-
await mkdir(
|
|
983
|
+
await mkdir(dirname(resolved), { recursive: true });
|
|
983
984
|
await appendFile(resolved, content);
|
|
984
985
|
return ok(undefined);
|
|
985
986
|
}
|
|
@@ -1036,7 +1037,7 @@ export class NodeExecutionEnv {
|
|
|
1036
1037
|
if (loopAbort) {
|
|
1037
1038
|
return loopAbort;
|
|
1038
1039
|
}
|
|
1039
|
-
const entryPath =
|
|
1040
|
+
const entryPath = anchorAtLinkDir(resolved, entry.name, sep);
|
|
1040
1041
|
try {
|
|
1041
1042
|
const info = fileInfoFromStats(entryPath, await lstat(entryPath));
|
|
1042
1043
|
if (info.ok) {
|
|
@@ -1152,7 +1153,7 @@ export class NodeExecutionEnv {
|
|
|
1152
1153
|
const loopAbort = abortResult(abortSignal, resolved);
|
|
1153
1154
|
if (loopAbort)
|
|
1154
1155
|
return loopAbort;
|
|
1155
|
-
const info = fileInfoFromStats(
|
|
1156
|
+
const info = fileInfoFromStats(anchorAtLinkDir(resolved, entry.name, sep), await lstat(anchorAtLinkDir(listed, entry.name, sep)));
|
|
1156
1157
|
if (info.ok)
|
|
1157
1158
|
infos.push(info.value);
|
|
1158
1159
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type FileError, type Result, type SymlinkChain } from "../harness/types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Anchor a RELATIVE
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Anchor a RELATIVE spelling at a directory, UNFOLDED, with exactly one separator between the two — the one anchor of
|
|
4
|
+
* this environment: a symlink target at its link's own directory (the walk below), a path at the environment's `cwd`
|
|
5
|
+
* and a name under the directory that holds it (`NodeExecutionEnv`'s every member). A root directory (`/`, `C:\`,
|
|
6
|
+
* `\\host\share\`) already ends in its own separator, and a second one mints a spelling (`//private/tmp`) that no
|
|
7
|
+
* guarded row matches; `path.resolve`/`join` would fix the separator and fold `..`, which no reader of a path may do —
|
|
8
|
+
* a `..` is the filesystem's to resolve. `separator` is the one the caller's `dirname` writes (a pure function of its
|
|
9
|
+
* inputs); a backslash terminates only where it IS a separator — on a POSIX tree `/a/b\` is an ordinary name.
|
|
8
10
|
*/
|
|
9
11
|
export declare function anchorAtLinkDir(linkDir: string, target: string, separator: string): string;
|
|
10
12
|
/** The walk's bound (the reference CLI's own); the terminal canonicalizer refuses at 16, so this only bounds what is REPORTED. */
|