@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
|
@@ -14,8 +14,11 @@ import { type CwdRef } from "./fs-shared.js";
|
|
|
14
14
|
* Absent hook ⇒ byte-identical behavior.
|
|
15
15
|
*/
|
|
16
16
|
export type { BeforeWriteRequest, BeforeWriteResult, BeforeWriteHook, TrackEditRequest, TrackEditResult, TrackFileEditHook } from "../../core/types.js";
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** A write tool's primary containment root: fixed, or a getter over the leg's live write location (read once per call, so an
|
|
18
|
+
* EnterWorktree switch moves where the next write may land). Canonical in both forms. */
|
|
19
|
+
export type WriteRootSeat = string | (() => string);
|
|
20
|
+
export declare function createEditFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
21
|
+
export declare function createWriteFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
19
22
|
/**
|
|
20
23
|
* design v1.163 — NotebookEdit: replace/insert/delete a single cell in a .ipynb. CC-parity tool over the SAME hand-band
|
|
21
24
|
* safety skeleton as Edit/Write (resolveKey containment → requireRead read-before-edit → checkStale content-hash
|
|
@@ -23,4 +26,4 @@ export declare function createWriteFileTool(env: ExecutionEnv, state: ReadFileSt
|
|
|
23
26
|
* .ipynb as the cell projection but records read state (hash/totalLines) in the RAW notebook-text
|
|
24
27
|
* coordinate — that raw-coordinate read record is what this tool's freshness check depends on.
|
|
25
28
|
*/
|
|
26
|
-
export declare function createNotebookEditTool(env: ExecutionEnv, state: ReadFileState, rootCanonical:
|
|
29
|
+
export declare function createNotebookEditTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: WriteRootSeat, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook, trackEdit?: TrackFileEditHook, onEdited?: FileEditedHook, writeFace?: () => ContainmentFace, writeDeny?: WriteDenyMatcher): AgentTool;
|
|
@@ -89,6 +89,7 @@ async function gateToolWrite(hook, tool, path, key, content) {
|
|
|
89
89
|
return `Error (${tool}): write rejected by the write gate (${res.code}): ${clipHookText(res.reason)}`;
|
|
90
90
|
return undefined;
|
|
91
91
|
}
|
|
92
|
+
const rootOf = (seat) => (typeof seat === "function" ? seat() : seat);
|
|
92
93
|
export function createEditFileTool(env, state, rootCanonical, cwdRef, additionalRoots, beforeWrite, trackEdit, onEdited, writeFace, writeDeny) {
|
|
93
94
|
return defineTool({
|
|
94
95
|
name: "Edit",
|
|
@@ -114,7 +115,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
114
115
|
const path = fileArgPath(args);
|
|
115
116
|
if (path === undefined)
|
|
116
117
|
return { ok: true };
|
|
117
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
118
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
118
119
|
if (!r.ok)
|
|
119
120
|
return { ok: true };
|
|
120
121
|
if (a.old_string === a.new_string)
|
|
@@ -152,7 +153,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
152
153
|
const path = fileArgPath(args);
|
|
153
154
|
if (path === undefined)
|
|
154
155
|
return errorResult(`Error (Edit): file_path is required.`);
|
|
155
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
156
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
156
157
|
if (!r.ok)
|
|
157
158
|
return errorResult(violationText("Edit", r.violation), violationDetails(r.violation));
|
|
158
159
|
if (!batch && a.old_string === a.new_string) {
|
|
@@ -190,7 +191,7 @@ export function createEditFileTool(env, state, rootCanonical, cwdRef, additional
|
|
|
190
191
|
details: { type: "create", filePath: path, content: created },
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
|
-
return errorResult(`Error (Edit): ${await enoentMessage(env, r.key, cwdRef?.current ?? rootCanonical, ctx.signal)}`);
|
|
194
|
+
return errorResult(`Error (Edit): ${await enoentMessage(env, r.key, cwdRef?.current ?? rootOf(rootCanonical), ctx.signal)}`);
|
|
194
195
|
}
|
|
195
196
|
const editInfo = await env.fileInfo(r.key, ctx.signal);
|
|
196
197
|
if (editInfo.ok && editInfo.value.size > MAX_EDIT_BYTES) {
|
|
@@ -346,7 +347,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
346
347
|
return { ok: true };
|
|
347
348
|
if (ipynbRedirect("Write", path))
|
|
348
349
|
return { ok: true };
|
|
349
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
350
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
350
351
|
if (!r.ok)
|
|
351
352
|
return { ok: true };
|
|
352
353
|
const exists = await env.exists(r.key, ctx.signal);
|
|
@@ -365,7 +366,7 @@ export function createWriteFileTool(env, state, rootCanonical, cwdRef, additiona
|
|
|
365
366
|
const ipynb = ipynbRedirect("Write", path);
|
|
366
367
|
if (ipynb)
|
|
367
368
|
return errorResult(ipynb);
|
|
368
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
369
|
+
const r = await resolveKey(env, rootOf(rootCanonical), path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
369
370
|
if (!r.ok)
|
|
370
371
|
return errorResult(violationText("Write", r.violation), violationDetails(r.violation));
|
|
371
372
|
const exists = await env.exists(r.key, ctx.signal);
|
|
@@ -462,7 +463,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
462
463
|
return { ok: false, code: "invalid", message: NOTEBOOK_CELL_TYPE_REQUIRED_MESSAGE };
|
|
463
464
|
if (mode !== "insert" && !a.cell_id)
|
|
464
465
|
return { ok: false, code: "invalid", message: NOTEBOOK_CELL_ID_REQUIRED_MESSAGE };
|
|
465
|
-
const r = await resolveKey(env, rootCanonical, a.notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
466
|
+
const r = await resolveKey(env, rootOf(rootCanonical), a.notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
466
467
|
if (!r.ok)
|
|
467
468
|
return { ok: true };
|
|
468
469
|
const notRead = requireRead(state, r.key);
|
|
@@ -482,7 +483,7 @@ export function createNotebookEditTool(env, state, rootCanonical, cwdRef, additi
|
|
|
482
483
|
return errorResult(NOTEBOOK_CELL_TYPE_REQUIRED_MESSAGE);
|
|
483
484
|
if (mode !== "insert" && !cell_id)
|
|
484
485
|
return errorResult(NOTEBOOK_CELL_ID_REQUIRED_MESSAGE);
|
|
485
|
-
const r = await resolveKey(env, rootCanonical, notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
486
|
+
const r = await resolveKey(env, rootOf(rootCanonical), notebook_path, ctx.signal, cwdRef?.current, additionalRoots, undefined, seatForCall(writeDeny, ctx.toolCallId), writeFace?.());
|
|
486
487
|
if (!r.ok)
|
|
487
488
|
return errorResult(violationText("NotebookEdit", r.violation), violationDetails(r.violation));
|
|
488
489
|
const notRead = requireRead(state, r.key);
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export interface HandsToolkitOptions {
|
|
|
26
26
|
* `bash_readonly` IS constrained by them (that face refuses a read outside the roots), so widening
|
|
27
27
|
* here widens what the read-only band may read. */
|
|
28
28
|
additionalRoots?: readonly string[];
|
|
29
|
+
/** The WRITE tools' primary root (edit_file / write_file / notebook_edit), read per call: the leg's write location, which
|
|
30
|
+
* moves with an EnterWorktree switch while the read tools keep `rootCanonical`. Absent ⇒ `rootCanonical` (one root). */
|
|
31
|
+
writeRoot?: () => string;
|
|
29
32
|
/** The read-boundary whitelist: extra allowed containment roots for the READ faces only —
|
|
30
33
|
* read_file/grep/glob/repo_map and `bash_readonly` admit them; edit_file/write_file/notebook_edit
|
|
31
34
|
* and the full `bash`'s disclosure roots deliberately do NOT (widening reads must never silently
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { BASH_CLASSIFY_EXTRA_ALLOW, bashClassifyDefaultAllow } from "./bash-read
|
|
|
17
17
|
import { checkedReadDenyHomes, compileReadDeny, compileWriteDeny, readDenyBuiltinConfigOf, readDenyRowAnchor } from "./read-deny.js";
|
|
18
18
|
import { withGateTimeout } from "../../core/gate-bounded-await.js";
|
|
19
19
|
import { carriedReadFaceOf, carryHomeViews, homeViewsAt, placeReadDenyAtHome, placementViewsOf, readDenyPlacedLater, sayPlacementLost } from "./read-deny-home.js";
|
|
20
|
+
import { readFloorSeat } from "./read-floor.js";
|
|
20
21
|
import { deploymentFaceClampNotice, resolveContainmentFace } from "./containment-face.js";
|
|
21
22
|
export * from "./containment-face.js";
|
|
22
23
|
import {} from "./fs-shared.js";
|
|
@@ -43,6 +44,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
43
44
|
? undefined
|
|
44
45
|
: (canonicalKey, c) => readAdmission?.(c.toolCallId, canonicalKey) === true || (bgOutput?.(canonicalKey, c) ?? false);
|
|
45
46
|
const { readDeny, writeDeny, afterPlacement } = carriedFace !== undefined ? { readDeny: carriedFace.readDeny, writeDeny: carriedFace.writeDeny, afterPlacement: (tool) => tool } : bandOwnTables(env, opts);
|
|
47
|
+
const readFloor = readFloorSeat(readDeny);
|
|
46
48
|
const readFace = resolveContainmentFace({
|
|
47
49
|
kind: "read",
|
|
48
50
|
depsFace: opts.readFace,
|
|
@@ -81,16 +83,17 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
81
83
|
afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.readImageDownsampler, opts.pdfModelCapabilities, bgOutputReadExemption, readDeny, readFace, opts.reminderMark, opts.reminderDisclosureCounts, reader)),
|
|
82
84
|
];
|
|
83
85
|
if (handsWriteHalfMounts({ readOnly })) {
|
|
84
|
-
tools.push(createEditFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createWriteFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createNotebookEditTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
86
|
+
tools.push(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny), createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
85
87
|
}
|
|
86
88
|
tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)));
|
|
87
89
|
if (includeShell) {
|
|
88
|
-
tools.push(readOnly
|
|
90
|
+
tools.push(afterPlacement(readOnly
|
|
89
91
|
? createBashReadonlyTool(env, rootCanonical, new Set(bashReadonlyAllow ?? BASH_READONLY_DEFAULT_ALLOW), {
|
|
90
92
|
...(opts.bashDefaultTimeoutMs !== undefined ? { bashDefaultTimeoutMs: opts.bashDefaultTimeoutMs } : {}),
|
|
91
93
|
...(opts.bashMaxTimeoutMs !== undefined ? { bashMaxTimeoutMs: opts.bashMaxTimeoutMs } : {}),
|
|
92
94
|
...(opts.onNotice !== undefined ? { onNotice: opts.onNotice } : {}),
|
|
93
95
|
...(opts.shellReadAdmission !== undefined ? { shellReadAdmission: opts.shellReadAdmission } : {}),
|
|
96
|
+
...(readFloor !== undefined ? { readFloor } : {}),
|
|
94
97
|
...(opts.onToolProgress !== undefined ? { onToolProgress: opts.onToolProgress } : {}),
|
|
95
98
|
})
|
|
96
99
|
: createBashTool(env, rootCanonical, commitCoAuthor, cwdRef, {
|
|
@@ -107,12 +110,13 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
107
110
|
...(opts.oneShot !== undefined ? { oneShot: opts.oneShot } : {}),
|
|
108
111
|
...(additionalRoots !== undefined ? { additionalRoots } : {}),
|
|
109
112
|
...(opts.shellReadAdmission !== undefined ? { shellReadAdmission: opts.shellReadAdmission } : {}),
|
|
113
|
+
...(readFloor !== undefined ? { readFloor } : {}),
|
|
110
114
|
...(opts.bashDefaultTimeoutMs !== undefined ? { bashDefaultTimeoutMs: opts.bashDefaultTimeoutMs } : {}),
|
|
111
115
|
...(opts.bashMaxTimeoutMs !== undefined ? { bashMaxTimeoutMs: opts.bashMaxTimeoutMs } : {}),
|
|
112
116
|
...(opts.onNotice !== undefined ? { onNotice: opts.onNotice } : {}),
|
|
113
117
|
...(opts.monitorToolActive !== undefined ? { monitorToolActive: opts.monitorToolActive } : {}),
|
|
114
118
|
...(opts.reminderMark !== undefined ? { reminderMark: opts.reminderMark } : {}),
|
|
115
|
-
}));
|
|
119
|
+
})));
|
|
116
120
|
if (!readOnly && mountBackgroundTaskTools && hasBackgroundShell(env)) {
|
|
117
121
|
const sessionAxis = opts.sessionId !== undefined ? { sessionId: opts.sessionId } : {};
|
|
118
122
|
tools.push(opts.taskRegistry
|
|
@@ -422,6 +422,9 @@ export interface ProgramRow {
|
|
|
422
422
|
readonly movesBase?: "stack";
|
|
423
423
|
/** A shell block word at the program position: it names no command of its own. */
|
|
424
424
|
readonly syntax?: "block";
|
|
425
|
+
/** What it writes to its standard output, read off its operands ({@link printedText}): `words` = its operands joined
|
|
426
|
+
* by a space (`echo`), `format` = its one operand as a format (`printf`). */
|
|
427
|
+
readonly prints?: "words" | "format";
|
|
425
428
|
/** Git-style subcommands: the word after the program's own options names one, and the words after it are read by
|
|
426
429
|
* ITS grammar, operands and traversal ({@link subcommandOf}). */
|
|
427
430
|
readonly subcommands?: Readonly<Record<string, Subcommand>>;
|
|
@@ -875,6 +878,16 @@ export declare function readProgramTextLanguage(row: ProgramRow | undefined): st
|
|
|
875
878
|
/** The program text of an invocation of a row whose first positional is program text, under EACH implementation's
|
|
876
879
|
* grammar (no text says which one runs, so a reader combines the readings). */
|
|
877
880
|
export declare function programTextReadings(row: ProgramRow, args: readonly string[]): ProgramTextReading[];
|
|
881
|
+
/**
|
|
882
|
+
* The text a printer row ({@link ProgramRow.prints}) writes to its standard output, read off its argv (the program word
|
|
883
|
+
* excluded; `undefined` = a word whose value the command does not spell). `undefined` wherever the words do not spell the
|
|
884
|
+
* text: such a word, an option the row does not explain, an escape the program may interpret (a backslash: `echo -e`, an
|
|
885
|
+
* `echo` that reads escapes by default, every `printf` format), a format with a directive (`%`), a format behind an
|
|
886
|
+
* option (`printf -v NAME` writes a variable, not the output), or a row that prints nothing it is handed. What the printer
|
|
887
|
+
* is where the command runs (a function or an alias of its name, a trap around it)
|
|
888
|
+
* is not read here: the one reader of this text uses it to refuse, never to clear (`ShellReadSegment.printed`).
|
|
889
|
+
*/
|
|
890
|
+
export declare function printedText(row: ProgramRow | undefined, args: readonly (string | undefined)[]): string | undefined;
|
|
878
891
|
/**
|
|
879
892
|
* The subcommand an argv (the program word excluded) names, and the row it is read by: the first word past the
|
|
880
893
|
* program's own options, which are read EXACTLY by the row's grammar — an option the row does not declare may take the
|
|
@@ -1331,6 +1331,21 @@ function programTextUnder(g, args) {
|
|
|
1331
1331
|
const script = supplied ? scripts.join("\n") : firstOperand;
|
|
1332
1332
|
return script === undefined ? "none" : { text: script };
|
|
1333
1333
|
}
|
|
1334
|
+
export function printedText(row, args) {
|
|
1335
|
+
const words = args.filter((a) => a !== undefined);
|
|
1336
|
+
if (row?.prints === undefined || words.length !== args.length)
|
|
1337
|
+
return undefined;
|
|
1338
|
+
const events = readArgRoles(row, words);
|
|
1339
|
+
const from = events.find((e) => e.kind === "operand" || e.kind === "dash-word-operand")?.at ?? words.length;
|
|
1340
|
+
if (events.some((e) => e.at < from && e.kind === "option" && e.reading === "speculative"))
|
|
1341
|
+
return undefined;
|
|
1342
|
+
const printed = words.slice(from);
|
|
1343
|
+
if (printed.some((w) => w.includes("\\")))
|
|
1344
|
+
return undefined;
|
|
1345
|
+
if (row.prints === "words")
|
|
1346
|
+
return printed.join(" ");
|
|
1347
|
+
return from === 0 && printed.length === 1 && !printed[0].includes("%") ? printed[0] : undefined;
|
|
1348
|
+
}
|
|
1334
1349
|
function exactSpec(g, tok) {
|
|
1335
1350
|
if (tok.startsWith("--"))
|
|
1336
1351
|
return tok.includes("=") ? undefined : g.long[tok.slice(2)];
|
|
@@ -585,7 +585,7 @@ const git = {
|
|
|
585
585
|
const noPath = (key, rest, extra = {}) => ({ key, grammars: [], operands: { rest }, witness: BINARY, ...extra });
|
|
586
586
|
const BUILTIN_ONLY = { declared: "a shell builtin with no binary of its own on every host: its words are read by the shell" };
|
|
587
587
|
const noPathRows = [
|
|
588
|
-
noPath("pwd", LABEL, { builtin: "inert" }), noPath("echo", LABEL, { builtin: "inert", grammars: [grammar(switches("neE"), {}, { afterFirstOperand: "operands" })] }), noPath("printf", LABEL, { grammars: [grammar({ v: val(BINDS_NAME) })] }), noPath("whoami", LABEL), noPath("uname", LABEL),
|
|
588
|
+
noPath("pwd", LABEL, { builtin: "inert" }), noPath("echo", LABEL, { builtin: "inert", grammars: [grammar(switches("neE"), {}, { afterFirstOperand: "operands" })], prints: "words" }), noPath("printf", LABEL, { grammars: [grammar({ v: val(BINDS_NAME) })], prints: "format" }), noPath("whoami", LABEL), noPath("uname", LABEL),
|
|
589
589
|
noPath("which", LABEL), noPath("basename", LABEL), noPath("dirname", LABEL),
|
|
590
590
|
{ key: "tr", grammars: [], operands: { rest: LABEL, stdinBelow: "always" }, witness: BINARY },
|
|
591
591
|
noPath("cal", COUNT), noPath("uptime", LABEL), noPath("id", LABEL), noPath("groups", LABEL), noPath("nproc", LABEL), noPath("locale", LABEL),
|
|
@@ -12,9 +12,10 @@ import { type PathGuardFold, type PathGuardRow, type PathRowsHit, type TargetVie
|
|
|
12
12
|
* absolute path (a path that is not absolute is not placed, and the row does not judge it).
|
|
13
13
|
* String shorthand ≡ `{ pattern }`. Matching is ASCII-case-insensitive by default (a case-insensitive
|
|
14
14
|
* filesystem serves `.SSH` and `.ssh` as the same directory); `caseSensitive: true` opts a single
|
|
15
|
-
* entry out.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* entry out. Names are compared in canonical composition (NFC) whatever the case setting — `ü` as one code point and `u` plus a
|
|
16
|
+
* combining diaeresis are one name, as on a filesystem that compares names by canonical equivalence; a compatibility form
|
|
17
|
+
* (a ligature) is another name. Volume-level case semantics are NOT modeled (v1 residual, shared with the write guard; the
|
|
18
|
+
* canonical view — realpath returns the on-disk spelling — covers half of it).
|
|
18
19
|
*/
|
|
19
20
|
export type ReadDenyEntry = string | {
|
|
20
21
|
pattern: string;
|
|
@@ -422,11 +423,13 @@ export declare const READ_FACE_DEFAULT_DENY_ENTRIES: readonly ReadDenyEntry[];
|
|
|
422
423
|
* themselves, `ß` stays `ß`). Both sides of a comparison go through it.
|
|
423
424
|
*/
|
|
424
425
|
export declare function ignoreCaseFold(s: string): string;
|
|
425
|
-
/** How a compiled pattern compares: `none` byte for byte; `ascii` and `unicode`
|
|
426
|
-
* the pattern's side at compile, the segments' side by whoever tests (once per path:
|
|
426
|
+
/** How a compiled pattern compares, both sides composed ({@link composed}), then: `none` byte for byte; `ascii` and `unicode`
|
|
427
|
+
* through the case fold of that name — the pattern's side at compile, the segments' side by whoever tests (once per path:
|
|
428
|
+
* {@link segmentReadingsOf}). */
|
|
427
429
|
export type SegmentFold = "none" | "ascii" | "unicode";
|
|
428
430
|
/** The function that folds a string as each fold folds — the one place that says which function that is (the pattern at compile,
|
|
429
|
-
* a path's segments in the readings, an anchor's segments all read it, at the time they fold)
|
|
431
|
+
* a path's segments in the readings, an anchor's segments all read it, at the time they fold): composition first, in every
|
|
432
|
+
* fold, then the fold's own case mapping. */
|
|
430
433
|
export declare const SEGMENT_FOLDS: Record<SegmentFold, (s: string) => string>;
|
|
431
434
|
/** One compiled segment of a pattern: `*` stands for any run of characters but a separator, every other character for itself. */
|
|
432
435
|
export interface SegmentMatcher {
|
|
@@ -454,11 +457,11 @@ export interface CompiledSegmentPattern {
|
|
|
454
457
|
unplacedHome?: true;
|
|
455
458
|
}
|
|
456
459
|
/**
|
|
457
|
-
* Compile one segment-glob pattern (shared engine). `fold
|
|
458
|
-
* · "none" —
|
|
460
|
+
* Compile one segment-glob pattern (shared engine). `fold` (every fold first composes the name, {@link composed}):
|
|
461
|
+
* · "none" — exact segments, case included;
|
|
459
462
|
* · "ascii" — ASCII-case-insensitive (deny-set contract);
|
|
460
|
-
* · "unicode" — the fold a RegExp `i` flag applies, {@link ignoreCaseFold} (the write guard's
|
|
461
|
-
*
|
|
463
|
+
* · "unicode" — the fold a RegExp `i` flag applies, {@link ignoreCaseFold}, over the composed name (the write guard's
|
|
464
|
+
* historical host-keyed case behavior; NOT used by the deny set).
|
|
462
465
|
* The pattern is folded here, once; the segments a row is tested on are folded by whoever tests, once per path
|
|
463
466
|
* ({@link segmentReadingsOf}) — never once per row per test.
|
|
464
467
|
* Returns null when the pattern reduces to zero segments — the CALLER owns its loud path (the two
|
|
@@ -337,16 +337,35 @@ export function ignoreCaseFold(s) {
|
|
|
337
337
|
}
|
|
338
338
|
return out;
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
function composed(s) {
|
|
341
|
+
return /[^\x00-\x7f]/.test(s) ? s.normalize("NFC") : s;
|
|
342
|
+
}
|
|
343
|
+
export const SEGMENT_FOLDS = {
|
|
344
|
+
none: composed,
|
|
345
|
+
ascii: (s) => asciiLower(composed(s)),
|
|
346
|
+
unicode: (s) => ignoreCaseFold(composed(s)),
|
|
347
|
+
};
|
|
341
348
|
function foldSegments(fold, segs) {
|
|
342
349
|
return segs.map((s) => SEGMENT_FOLDS[fold](s));
|
|
343
350
|
}
|
|
351
|
+
const SPELLED_FOLDS = { none: (s) => s, ascii: asciiLower, unicode: ignoreCaseFold };
|
|
352
|
+
function readingsOfViews(fold, views) {
|
|
353
|
+
const out = [];
|
|
354
|
+
for (const segs of views) {
|
|
355
|
+
const twin = foldSegments(fold, segs);
|
|
356
|
+
out.push(twin);
|
|
357
|
+
const spelled = segs.map((s) => SPELLED_FOLDS[fold](s));
|
|
358
|
+
if (spelled.some((s, i) => s !== twin[i]))
|
|
359
|
+
out.push(spelled);
|
|
360
|
+
}
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
344
363
|
function foldedViewsOf(views) {
|
|
345
364
|
const memo = new Map();
|
|
346
365
|
return (fold) => {
|
|
347
366
|
let folded = memo.get(fold);
|
|
348
367
|
if (folded === undefined)
|
|
349
|
-
memo.set(fold, (folded =
|
|
368
|
+
memo.set(fold, (folded = readingsOfViews(fold, views)));
|
|
350
369
|
return folded;
|
|
351
370
|
};
|
|
352
371
|
}
|
|
@@ -376,12 +395,13 @@ function segmentReadingsOf(path, aliasResolved) {
|
|
|
376
395
|
const known = SEGMENT_READINGS.get(key);
|
|
377
396
|
if (known !== undefined)
|
|
378
397
|
return known;
|
|
379
|
-
const
|
|
398
|
+
const spelledViews = segmentViewsOf(path, aliasResolved ? { aliasResolved } : undefined);
|
|
399
|
+
const views = readingsOfViews("none", spelledViews);
|
|
380
400
|
let folded;
|
|
381
401
|
const readings = {
|
|
382
402
|
views,
|
|
383
|
-
lowered:
|
|
384
|
-
folded: () => (folded ??=
|
|
403
|
+
lowered: readingsOfViews("ascii", spelledViews),
|
|
404
|
+
folded: () => (folded ??= readingsOfViews("unicode", spelledViews)),
|
|
385
405
|
rooted: isAbsoluteForFamily("own", path),
|
|
386
406
|
};
|
|
387
407
|
if (SEGMENT_READINGS.size >= 512)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The byte floor's one adapter: the read-deny table a call judges with, as the {@link ReadFloor} its command
|
|
3
|
+
* start carries to the environment the command runs in.
|
|
4
|
+
*
|
|
5
|
+
* One table, two readers. The shell read station judges what a command NAMES (its operands, its expansions, a
|
|
6
|
+
* recursive read's root — never the tree below a root, the zero-friction reading); the environment judges what a process
|
|
7
|
+
* OPENS. Both read the same rows through the same judgment: this module derives nothing — the rows are the ones the
|
|
8
|
+
* engine's refusals cite (`readDenySeat`) and the judgment is the table's own `matchPath`, read off the table the call
|
|
9
|
+
* is pinned to (`seatForCall`). A floor never loosens the station: what the station refuses never starts.
|
|
10
|
+
*/
|
|
11
|
+
import type { ReadFloor } from "../../internal/harness-types.js";
|
|
12
|
+
import { type ReadDenyMatcher } from "./read-deny.js";
|
|
13
|
+
/** The floor ONE call's command start carries, read off the table that call judges with — `undefined` when the table
|
|
14
|
+
* holds no row (an empty table keeps nothing, and the start then carries no floor: the options are the ones a start
|
|
15
|
+
* took before the floor existed). */
|
|
16
|
+
export type ReadFloorSeat = (toolCallId: string | undefined) => ReadFloor | undefined;
|
|
17
|
+
/** The seat over a face's deny table (the run's, or a library-direct band's own); `undefined` for no table. Built once per
|
|
18
|
+
* mount; each call reads its own pinned table through it. */
|
|
19
|
+
export declare function readFloorSeat(table: ReadDenyMatcher | undefined): ReadFloorSeat | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readDenySeat, seatForCall } from "./read-deny.js";
|
|
2
|
+
import { isAbsoluteForFamily } from "./safety.js";
|
|
3
|
+
export function readFloorSeat(table) {
|
|
4
|
+
if (table === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
return (toolCallId) => readFloorOf(seatForCall(table, toolCallId));
|
|
7
|
+
}
|
|
8
|
+
function readFloorOf(table) {
|
|
9
|
+
const rows = Object.freeze([...readDenySeat(table).denyEntries]);
|
|
10
|
+
if (rows.length === 0)
|
|
11
|
+
return undefined;
|
|
12
|
+
const denies = (absolutePath) => {
|
|
13
|
+
if (typeof absolutePath !== "string" || !isAbsoluteForFamily("own", absolutePath))
|
|
14
|
+
return rows[0];
|
|
15
|
+
try {
|
|
16
|
+
return table.matchPath(absolutePath)?.pattern ?? null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return rows[0];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return Object.freeze({ rows, denies });
|
|
23
|
+
}
|
package/dist/tools/fs/safety.js
CHANGED
|
@@ -444,7 +444,7 @@ function within(rootCanonical, p) {
|
|
|
444
444
|
}
|
|
445
445
|
export async function resolveKey(env, rootCanonical, path, signal, baseCwd, additionalRoots, exactFileReadExemption, readDeny, containmentFace) {
|
|
446
446
|
const views = await readPath(env, path, baseCwd ?? rootCanonical, { root: rootCanonical, ...(baseCwd !== undefined ? { cwd: baseCwd } : {}) }, { intent: "resolve", views: readDeny !== undefined ? "chain" : "canonical" }, signal);
|
|
447
|
-
const canon = views.canonical ??
|
|
447
|
+
const canon = views.canonical ?? { ok: false, message: `cannot resolve path "${clipSpelling(path)}": ${views.lexical?.kind === "unreadable" ? views.lexical.reason : "the environment was not asked where it lands"}; refused.` };
|
|
448
448
|
if (!canon.ok)
|
|
449
449
|
return { ok: false, violation: { code: "invalid", message: canon.message } };
|
|
450
450
|
const key = canon.key;
|
|
@@ -545,6 +545,10 @@ async function probeRealTarget(env, path, target, family, signal) {
|
|
|
545
545
|
if (!newPath.ok) {
|
|
546
546
|
return { ok: false, message: newPath.message, unresolvedSymlink: true };
|
|
547
547
|
}
|
|
548
|
+
if ("reprobe" in newPath) {
|
|
549
|
+
abs = newPath.reprobe;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
548
552
|
return { ok: true, key: newPath.key };
|
|
549
553
|
}
|
|
550
554
|
const canon = await env.canonicalPath(abs, signal);
|
|
@@ -559,6 +563,10 @@ async function probeRealTarget(env, path, target, family, signal) {
|
|
|
559
563
|
if (!viaAncestors.ok) {
|
|
560
564
|
return { ok: false, message: viaAncestors.message, unresolvedSymlink: true };
|
|
561
565
|
}
|
|
566
|
+
if ("reprobe" in viaAncestors) {
|
|
567
|
+
abs = viaAncestors.reprobe;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
562
570
|
return { ok: true, key: viaAncestors.key };
|
|
563
571
|
}
|
|
564
572
|
if (!env.readLink) {
|
|
@@ -584,7 +592,7 @@ async function probeRealTarget(env, path, target, family, signal) {
|
|
|
584
592
|
}
|
|
585
593
|
abs = reabs.value;
|
|
586
594
|
}
|
|
587
|
-
return { ok: false, message: `
|
|
595
|
+
return { ok: false, message: `resolving "${path}" exceeded the hop cap (links followed, or a \`..\` back into an existing directory re-probed); target unresolved`, unresolvedSymlink: true };
|
|
588
596
|
}
|
|
589
597
|
function parentDir(abs) {
|
|
590
598
|
const i = lastSepIndex(abs);
|
|
@@ -623,15 +631,39 @@ async function canonicalizeNewPath(env, abs, family, signal, opts) {
|
|
|
623
631
|
if (!canon.ok) {
|
|
624
632
|
return { ok: false, message: `cannot canonicalize existing ancestor "${candidate}": ${canon.error.message}` };
|
|
625
633
|
}
|
|
626
|
-
|
|
627
|
-
const canonSep = nativeSepOf(canon.value);
|
|
628
|
-
if (tailSegments.length === 0)
|
|
629
|
-
return { ok: true, key: canon.value };
|
|
630
|
-
return { ok: true, key: [canon.value.replace(family === "win" ? /[\\/]+$/ : /\/+$/, ""), ...tailSegments].join(canonSep) };
|
|
634
|
+
return { ok: true, ...rejoinMissingTail(canon.value, tail.reverse(), family) };
|
|
631
635
|
}
|
|
632
636
|
tail.push(parts.pop());
|
|
633
637
|
}
|
|
634
|
-
|
|
638
|
+
const share = family === "win" && isUncSpelling(abs) ? tail.pop() : undefined;
|
|
639
|
+
return { ok: true, ...rejoinMissingTail(`${[...parts, ...(share !== undefined ? [share] : [])].join(sep)}${sep}`, tail.reverse(), family) };
|
|
640
|
+
}
|
|
641
|
+
function rejoinMissingTail(canonical, tail, family) {
|
|
642
|
+
const trimmed = (at) => at.replace(family === "win" ? /[\\/]+$/ : /\/+$/, "");
|
|
643
|
+
let at = canonical;
|
|
644
|
+
const names = [];
|
|
645
|
+
for (let i = 0; i < tail.length; i++) {
|
|
646
|
+
const seg = tail[i];
|
|
647
|
+
if (seg === "" || seg === ".")
|
|
648
|
+
continue;
|
|
649
|
+
if (seg !== "..")
|
|
650
|
+
names.push(seg);
|
|
651
|
+
else if (names.length > 1)
|
|
652
|
+
names.pop();
|
|
653
|
+
else {
|
|
654
|
+
if (names.length === 1)
|
|
655
|
+
names.pop();
|
|
656
|
+
else {
|
|
657
|
+
const up = normalizeAbsPathLexically(`${at}/..`);
|
|
658
|
+
if (up !== normalizeAbsPathLexically(at))
|
|
659
|
+
at = up;
|
|
660
|
+
}
|
|
661
|
+
const rest = tail.slice(i + 1);
|
|
662
|
+
if (rest.some((s) => s !== "" && s !== "."))
|
|
663
|
+
return { reprobe: [trimmed(at), ...rest].join(nativeSepOf(at)) };
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return { key: names.length === 0 ? at : [trimmed(at), ...names].join(nativeSepOf(at)) };
|
|
635
667
|
}
|
|
636
668
|
export function violationText(toolName, v) {
|
|
637
669
|
return `Error (${toolName}): ${v.message}`;
|
package/dist/tools/fs/search.js
CHANGED
|
@@ -40,25 +40,6 @@ const TYPE_GLOBS = {
|
|
|
40
40
|
css: "*.{css,scss,less}",
|
|
41
41
|
};
|
|
42
42
|
const basename = (p) => p.slice(Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\")) + 1);
|
|
43
|
-
function collapseDotSegments(p) {
|
|
44
|
-
const win = isWinFormPath(p);
|
|
45
|
-
const lead = (win ? /^[\\/]*/ : /^\/*/).exec(p)?.[0] ?? "";
|
|
46
|
-
const sep = win ? "\\" : "/";
|
|
47
|
-
const parts = p.slice(lead.length).split(win ? /[\\/]+/ : /\/+/);
|
|
48
|
-
const floor = !win ? 0 : lead.length >= 2 ? 2 : /^[A-Za-z]:$/.test(parts[0] ?? "") ? 1 : 0;
|
|
49
|
-
const kept = [];
|
|
50
|
-
for (const part of parts) {
|
|
51
|
-
if (part === "" || part === ".")
|
|
52
|
-
continue;
|
|
53
|
-
if (part === "..") {
|
|
54
|
-
if (kept.length > floor)
|
|
55
|
-
kept.pop();
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
kept.push(part);
|
|
59
|
-
}
|
|
60
|
-
return kept.length === 0 ? "" : lead + kept.join(sep);
|
|
61
|
-
}
|
|
62
43
|
const NO_MATCHES = "No matches.";
|
|
63
44
|
const GREP_LINE_CLIP = 500;
|
|
64
45
|
function clipLine(line) {
|
|
@@ -813,18 +794,19 @@ export async function jsGrepDetailed(env, root, p, signal, guards, deny, denyOut
|
|
|
813
794
|
const mode = p.output_mode ?? "files_with_matches";
|
|
814
795
|
const rel = (abs) => (abs.startsWith(rootPrefix) ? abs.slice(rootPrefix.length) : abs);
|
|
815
796
|
const startWin = isWinFormPath(start);
|
|
816
|
-
const
|
|
817
|
-
const
|
|
797
|
+
const trailingSeparators = startWin ? /[\\/]+$/ : /\/+$/;
|
|
798
|
+
const anchor = start.replace(trailingSeparators, "");
|
|
799
|
+
const targetSpell = p.path ? p.path.replace(trailingSeparators, "") : "";
|
|
818
800
|
const isBoundary = (c) => c === "/" || (startWin && c === "\\");
|
|
819
801
|
const relOut = (abs) => {
|
|
820
802
|
if (!p.path) {
|
|
821
803
|
const r = rel(abs);
|
|
822
804
|
return r === abs ? r : `./${r}`;
|
|
823
805
|
}
|
|
824
|
-
if (abs ===
|
|
806
|
+
if (abs === start || abs === anchor)
|
|
825
807
|
return targetSpell;
|
|
826
|
-
if (abs.startsWith(
|
|
827
|
-
return targetSpell + abs.slice(
|
|
808
|
+
if (abs.startsWith(anchor) && isBoundary(abs[anchor.length]))
|
|
809
|
+
return targetSpell + abs.slice(anchor.length);
|
|
828
810
|
return rel(abs);
|
|
829
811
|
};
|
|
830
812
|
if (p.glob) {
|
|
@@ -105,8 +105,15 @@ export interface ShellReadVerdictFacts {
|
|
|
105
105
|
readonly writesPlaced?: true;
|
|
106
106
|
/** A FACT beside the disposition: a write target this command names lands on the write-protection table — judged by
|
|
107
107
|
* the table's own judge, as a write tool's target is — so the command's ask carries that table's class, whichever
|
|
108
|
-
* mode reads it. Absent ⇒ no target the station established is covered (or no judge is mounted).
|
|
108
|
+
* mode reads it. Absent ⇒ no target the station established is covered (or no judge is mounted). Said of a target whose
|
|
109
|
+
* TEXT names the row (the table's spelling view of one of its spellings); a covered target whose text names none is the
|
|
110
|
+
* member below — one target, one of the two. */
|
|
109
111
|
readonly writeProtected?: true;
|
|
112
|
+
/** A FACT beside the disposition: a write target this command names meets the write-protection table only where it resolves
|
|
113
|
+
* on disk (its real target, a link on the way) — none of the target's spellings names a row — so the command's ask carries
|
|
114
|
+
* that reading's class, which the auto-mode classifier does not answer. Beside `writeProtected` when another target's text
|
|
115
|
+
* names a row. Absent ⇒ no such target (or no judge is mounted). */
|
|
116
|
+
readonly writeProtectedOnDisk?: true;
|
|
110
117
|
/** A FACT beside the disposition: a target this command's program WRITES was placed and the environment could not say
|
|
111
118
|
* where it leads ({@link EstablishedRead.unresolved}) — the reading's `target_unresolved` fact, the same one a write
|
|
112
119
|
* tool's unresolved target states, so the command's ask carries that class (no automatic lane answers it; the shell face
|
|
@@ -254,7 +261,7 @@ export interface ShellReadJudgment {
|
|
|
254
261
|
* holding a command, an environment and a boundary gets the decision the gate would reach for them.
|
|
255
262
|
*
|
|
256
263
|
* An ENVIRONMENT question, not a text question: a symlink that leaves the roots, a pattern that expands
|
|
257
|
-
* onto a deny row, a traversal root that
|
|
264
|
+
* onto a deny row, a traversal root that lands elsewhere than it is spelled are answered by `env`, not guessed from the
|
|
258
265
|
* spelling. {@link judgeShellReadLexically} is the no-environment reading and not a substitute — it is
|
|
259
266
|
* LAXER where only a filesystem sees the escape (an in-root symlink pointing out vouches) and answers a
|
|
260
267
|
* pattern on its spelling alone, so the two diverge in both directions.
|