@sema-agent/core 7.70.0 → 7.71.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 +728 -0
- package/dist/agents/agent-transcript-tool.js +43 -19
- package/dist/agents/inherited-tool-pool.d.ts +5 -1
- package/dist/agents/inherited-tool-pool.js +6 -0
- package/dist/agents/retain-ledger.js +2 -0
- package/dist/agents/send-message-tool.d.ts +12 -1
- package/dist/agents/send-message-tool.js +47 -9
- package/dist/agents/subagent.js +31 -10
- package/dist/agents/tool-filter.js +1 -2
- package/dist/agents/verify.js +13 -2
- package/dist/agents/yield-adoption.js +11 -1
- package/dist/brain/claude-model-id.d.ts +11 -0
- package/dist/brain/claude-model-id.js +3 -1
- package/dist/config/catalog.js +10 -1
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/allow-entry.js +1 -2
- package/dist/core/ask-origin.d.ts +55 -21
- package/dist/core/ask-origin.js +19 -11
- package/dist/core/ask-question.d.ts +4 -7
- package/dist/core/ask-question.js +2 -4
- package/dist/core/ask-unresolvable-notice.d.ts +17 -3
- package/dist/core/ask-unresolvable-notice.js +18 -4
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +2 -0
- package/dist/core/auto-compaction.d.ts +14 -4
- package/dist/core/auto-compaction.js +3 -2
- package/dist/core/auto-strip.js +2 -0
- package/dist/core/caller-text.d.ts +2 -33
- package/dist/core/caller-text.js +2 -23
- package/dist/core/caller-tool-name.js +1 -2
- package/dist/core/canonical-json.d.ts +9 -0
- package/dist/core/canonical-json.js +6 -0
- package/dist/core/checkpoint-features.d.ts +43 -80
- package/dist/core/checkpoint-features.js +10 -20
- package/dist/core/checkpoint-generation.d.ts +89 -19
- package/dist/core/checkpoint-generation.js +89 -14
- package/dist/core/checkpoint-queries.d.ts +95 -15
- package/dist/core/checkpoint-queries.js +108 -7
- package/dist/core/checkpoint-rekey.d.ts +2 -1
- package/dist/core/checkpoint-rekey.js +2 -2
- package/dist/core/checkpoint-requirements.d.ts +7 -6
- package/dist/core/checkpoint-requirements.js +2 -5
- package/dist/core/checkpoint-row-verdict.d.ts +3 -4
- package/dist/core/checkpoint-row-verdict.js +20 -41
- package/dist/core/checkpoint-store.d.ts +65 -41
- package/dist/core/checkpoint-store.js +28 -14
- package/dist/core/command-sandbox.d.ts +5 -3
- package/dist/core/command-sandbox.js +17 -9
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/declaration-words.d.ts +2 -1
- package/dist/core/declaration-words.js +13 -2
- package/dist/core/effective-path-target.d.ts +23 -0
- package/dist/core/effective-path-target.js +15 -1
- package/dist/core/engine-attestation.d.ts +5 -1
- package/dist/core/engine-attestation.js +1 -0
- package/dist/core/engine-capabilities.d.ts +14 -9
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +62 -32
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +1 -1
- package/dist/core/entries-not-applied.js +1 -0
- package/dist/core/file-history-store.d.ts +95 -11
- package/dist/core/file-history-store.js +117 -19
- package/dist/core/gate-fold.js +13 -7
- package/dist/core/gate-lanes.js +9 -9
- package/dist/core/governance-codes.d.ts +56 -7
- package/dist/core/governance-codes.js +105 -7
- package/dist/core/grant-holder.d.ts +53 -0
- package/dist/core/grant-holder.js +80 -0
- package/dist/core/hooks.d.ts +7 -3
- package/dist/core/hooks.js +2 -2
- package/dist/core/locked-config.d.ts +7 -1
- package/dist/core/locked-config.js +9 -2
- package/dist/core/mcp-call-meta.d.ts +52 -7
- package/dist/core/mcp-call-meta.js +21 -2
- package/dist/core/mcp-host-read.d.ts +1 -1
- package/dist/core/mcp-server-spec.d.ts +18 -0
- package/dist/core/mcp-server-spec.js +1 -0
- package/dist/core/mcp.js +2 -2
- package/dist/core/member-outcome.d.ts +22 -1
- package/dist/core/member-outcome.js +18 -6
- package/dist/core/memory-engine/delegation-settlement.js +5 -5
- package/dist/core/memory-engine/engine.js +19 -19
- package/dist/core/memory-engine/file-backend.d.ts +7 -2
- package/dist/core/memory-engine/file-backend.js +14 -12
- package/dist/core/memory-engine/frontmatter.js +1 -1
- package/dist/core/memory-engine/index.d.ts +1 -0
- package/dist/core/memory-engine/index.js +1 -0
- package/dist/core/memory-engine/layout.d.ts +34 -9
- package/dist/core/memory-engine/layout.js +36 -19
- package/dist/core/memory-engine/memory-deployment.js +8 -8
- package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
- package/dist/core/memory-engine/mount-failed-notice.js +5 -2
- package/dist/core/mode-policy.d.ts +5 -0
- package/dist/core/mode-policy.js +6 -0
- package/dist/core/mods/host.d.ts +2 -1
- package/dist/core/mods/host.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -2
- package/dist/core/mods/kernel/registration.js +19 -3
- package/dist/core/mods/package.d.ts +12 -1
- package/dist/core/mods/package.js +36 -9
- package/dist/core/mods/stations.d.ts +7 -1
- package/dist/core/mods/stations.js +17 -3
- package/dist/core/mods/teammate-stations.d.ts +4 -1
- package/dist/core/mods/teammate-stations.js +1 -1
- package/dist/core/native-signal.d.ts +13 -0
- package/dist/core/native-signal.js +18 -0
- package/dist/core/park-resumability.d.ts +16 -14
- package/dist/core/park-resumability.js +9 -4
- package/dist/core/path-rule-binding.js +1 -1
- package/dist/core/permission-rule-model.d.ts +11 -5
- package/dist/core/permission-rule-model.js +5 -3
- package/dist/core/permission-rule-org.js +1 -1
- package/dist/core/permission-rule-provider.d.ts +5 -1
- package/dist/core/permission-rule-provider.js +6 -1
- package/dist/core/permission-rule-session.d.ts +35 -5
- package/dist/core/permission-rule-session.js +32 -1
- package/dist/core/permission-rule-store.d.ts +5 -1
- package/dist/core/permission-rule-store.js +28 -5
- package/dist/core/permission-rules.d.ts +2 -2
- package/dist/core/permission-rules.js +2 -3
- package/dist/core/principal-name.d.ts +12 -0
- package/dist/core/principal-name.js +6 -2
- package/dist/core/read-root-grant-screen.d.ts +7 -6
- package/dist/core/read-root-grant-screen.js +7 -8
- package/dist/core/remote-env.d.ts +42 -8
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +19 -4
- package/dist/core/resume-startup-cause.js +25 -6
- package/dist/core/rewind-conversation.d.ts +4 -0
- package/dist/core/rewrite-rejudge.d.ts +9 -1
- package/dist/core/rewrite-rejudge.js +11 -1
- package/dist/core/rule-offer-read.js +3 -2
- package/dist/core/runner/assemble-result.d.ts +21 -11
- package/dist/core/runner/assemble-result.js +24 -4
- package/dist/core/runner/boundary-reminders.d.ts +104 -0
- package/dist/core/runner/boundary-reminders.js +108 -0
- package/dist/core/runner/branch-writeback.d.ts +21 -7
- package/dist/core/runner/branch-writeback.js +44 -6
- package/dist/core/runner/command-sandbox-frame.js +2 -1
- package/dist/core/runner/compact-session.js +11 -4
- package/dist/core/runner/constraint-layers.d.ts +24 -5
- package/dist/core/runner/constraint-layers.js +21 -2
- package/dist/core/runner/continuation-gate.js +3 -1
- package/dist/core/runner/contracts.d.ts +83 -13
- package/dist/core/runner/cross-boundary-lane.js +2 -1
- package/dist/core/runner/delegation-owner.d.ts +246 -45
- package/dist/core/runner/delegation-owner.js +237 -63
- package/dist/core/runner/expire-settle.d.ts +17 -0
- package/dist/core/runner/expire-settle.js +8 -2
- package/dist/core/runner/file-history-request.d.ts +4 -3
- package/dist/core/runner/file-history-request.js +4 -1
- package/dist/core/runner/file-history-restore.d.ts +11 -3
- package/dist/core/runner/file-history-restore.js +11 -3
- package/dist/core/runner/gate-exit.d.ts +22 -1
- package/dist/core/runner/gate-exit.js +12 -14
- package/dist/core/runner/nested-memory-content.js +1 -1
- package/dist/core/runner/nested-memory-lane.d.ts +10 -2
- package/dist/core/runner/nested-memory-lane.js +29 -8
- package/dist/core/runner/own-model-money-door.d.ts +13 -0
- package/dist/core/runner/own-model-money-door.js +17 -0
- package/dist/core/runner/park-commit.d.ts +4 -2
- package/dist/core/runner/park-commit.js +2 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
- package/dist/core/runner/permission-rule-lanes.js +7 -0
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +8 -2
- package/dist/core/runner/placement-fence.js +8 -3
- package/dist/core/runner/policy-throw.d.ts +3 -2
- package/dist/core/runner/policy-throw.js +2 -2
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
- package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
- package/dist/core/runner/prepare-artifact.d.ts +14 -1
- package/dist/core/runner/prepare-artifact.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
- package/dist/core/runner/prepare-ask-lane.js +14 -5
- package/dist/core/runner/prepare-boundary-parks.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +9 -4
- package/dist/core/runner/prepare-config-doors.js +25 -8
- package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
- package/dist/core/runner/prepare-defer-classify.js +6 -6
- package/dist/core/runner/prepare-execution-env.d.ts +4 -1
- package/dist/core/runner/prepare-execution-env.js +8 -3
- package/dist/core/runner/prepare-file-history.d.ts +26 -0
- package/dist/core/runner/prepare-file-history.js +15 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
- package/dist/core/runner/prepare-inherited-gate.js +9 -2
- package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.js +8 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
- package/dist/core/runner/prepare-policy-chain.js +18 -7
- package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
- package/dist/core/runner/prepare-prompt-assembly.js +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
- package/dist/core/runner/prepare-suspend-saga.js +19 -5
- package/dist/core/runner/prepare-task.d.ts +2 -5
- package/dist/core/runner/prepare-task.js +71 -26
- package/dist/core/runner/prepare-turn-wiring.js +7 -5
- package/dist/core/runner/prepare-workspace-restore.js +59 -28
- package/dist/core/runner/read-root-grant.d.ts +1 -0
- package/dist/core/runner/read-root-grant.js +1 -2
- package/dist/core/runner/resume-admission.d.ts +3 -0
- package/dist/core/runner/resume-admission.js +6 -4
- package/dist/core/runner/resume-apply.js +7 -5
- package/dist/core/runner/resume-claim.d.ts +2 -2
- package/dist/core/runner/resume-claim.js +4 -4
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-policy-outcome.js +6 -4
- package/dist/core/runner/resume-preflight.d.ts +3 -0
- package/dist/core/runner/resume-preflight.js +10 -3
- package/dist/core/runner/rewind-conversation.js +11 -4
- package/dist/core/runner/rewind-files.js +29 -14
- package/dist/core/runner/rewind-outcome.d.ts +27 -0
- package/dist/core/runner/rewind-outcome.js +14 -0
- package/dist/core/runner/run-attachment-seats.js +2 -1
- package/dist/core/runner/run-clock-and-content.js +2 -0
- package/dist/core/runner/run-identity-wiring.js +2 -0
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
- package/dist/core/runner/run-settle-and-teardown.js +52 -40
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +5 -4
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +3 -3
- package/dist/core/runner/run-turn-boundary.js +7 -0
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +18 -9
- package/dist/core/runner/session-call-grant-station.d.ts +64 -0
- package/dist/core/runner/session-call-grant-station.js +119 -0
- package/dist/core/runner/session-file-state-replay.js +2 -2
- package/dist/core/runner/session-prompt-seats.d.ts +95 -0
- package/dist/core/runner/session-prompt-seats.js +62 -0
- package/dist/core/runner/session-rule-policy.js +1 -1
- package/dist/core/runner/session-write-ledger.d.ts +8 -0
- package/dist/core/runner/session-write-ledger.js +16 -0
- package/dist/core/runner/side-call-account.js +5 -1
- package/dist/core/runner/stop-tail-notice.d.ts +7 -0
- package/dist/core/runner/stop-tail-notice.js +23 -8
- package/dist/core/runner/stream-reap.js +4 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
- package/dist/core/runner/stream-settle-backstop.js +17 -18
- package/dist/core/runner/terminal-account.js +17 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +1 -1
- package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.js +12 -7
- package/dist/core/runner/turn-attachments.d.ts +22 -1
- package/dist/core/runner/turn-attachments.js +20 -3
- package/dist/core/runner-deps.d.ts +6 -2
- package/dist/core/secret-env.d.ts +26 -6
- package/dist/core/secret-env.js +6 -6
- package/dist/core/session-call-grant-screen.d.ts +58 -0
- package/dist/core/session-call-grant-screen.js +18 -0
- package/dist/core/session-call-grant.d.ts +93 -0
- package/dist/core/session-call-grant.js +524 -0
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +8 -3
- package/dist/core/session-policy-store.d.ts +14 -0
- package/dist/core/session-policy-store.js +16 -2
- package/dist/core/session-store.d.ts +18 -1
- package/dist/core/session-store.js +20 -4
- package/dist/core/session.d.ts +36 -4
- package/dist/core/shared-artifact-reads.d.ts +93 -0
- package/dist/core/shared-artifact-reads.js +94 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/skills-directory.d.ts +9 -45
- package/dist/core/skills-directory.js +9 -722
- package/dist/core/spend-account.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
- package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
- package/dist/core/store-contracts/file-history-store-contract.js +62 -2
- package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
- package/dist/core/store-contracts/grant-fixture.js +84 -0
- package/dist/core/store-contracts/session-repo-contract.js +18 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
- package/dist/core/store-contracts/session-store-contract.js +211 -2
- package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
- package/dist/core/suspend-lane-reasons.d.ts +13 -0
- package/dist/core/suspend-lane-reasons.js +5 -0
- package/dist/core/synthetic-read-verdict.d.ts +5 -3
- package/dist/core/synthetic-read-verdict.js +1 -1
- package/dist/core/task-limits.d.ts +15 -0
- package/dist/core/task-notification.d.ts +33 -7
- package/dist/core/task-notification.js +34 -9
- package/dist/core/task-registry-agent.d.ts +1 -1
- package/dist/core/task-registry-agent.js +18 -7
- package/dist/core/task-registry-shared.d.ts +29 -4
- package/dist/core/task-registry-shared.js +7 -0
- package/dist/core/task-registry.d.ts +21 -1
- package/dist/core/task-registry.js +36 -9
- package/dist/core/task-result.d.ts +55 -1
- package/dist/core/task-spec.d.ts +17 -3
- package/dist/core/terminal-cause.d.ts +68 -5
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.js +2 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-list-grammar.d.ts +0 -47
- package/dist/core/tool-list-grammar.js +1 -75
- package/dist/core/tool-model-gate.d.ts +7 -11
- package/dist/core/tool-model-gate.js +5 -8
- package/dist/core/tool-name-aliases.js +2 -3
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +46 -4
- package/dist/core/tool-policy.js +47 -18
- package/dist/core/tool-result-store.d.ts +0 -24
- package/dist/core/tool-result-store.js +1 -36
- package/dist/core/tool-spec.d.ts +8 -4
- package/dist/core/untrusted-egress.js +2 -2
- package/dist/core/untrusted-text.d.ts +8 -0
- package/dist/core/untrusted-text.js +14 -0
- package/dist/core/user-attachment.d.ts +16 -1
- package/dist/core/user-attachment.js +42 -18
- package/dist/core/wiring-manifest.d.ts +4 -9
- package/dist/core/wiring-manifest.js +1 -1
- package/dist/core/workflow-journal-store.d.ts +55 -8
- package/dist/core/workflow-journal-store.js +34 -10
- package/dist/core/workflow-run-store-contract.js +56 -1
- package/dist/core/workflow-run-store.d.ts +43 -19
- package/dist/core/workflow-run-store.js +17 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +4 -0
- package/dist/engine/harness/agent-harness.d.ts +10 -5
- package/dist/engine/harness/agent-harness.js +12 -4
- package/dist/engine/harness/types.d.ts +18 -0
- package/dist/engine/llm/tool-turns.d.ts +1 -1
- package/dist/engine/llm/types.d.ts +5 -4
- package/dist/engine/session/memory-repo.d.ts +15 -3
- package/dist/engine/session/memory-repo.js +21 -3
- package/dist/engine/session/memory-storage.d.ts +5 -0
- package/dist/engine/session/memory-storage.js +8 -3
- package/dist/engine/session/repo-utils.d.ts +9 -0
- package/dist/engine/session/repo-utils.js +14 -0
- package/dist/engine/session/storage-base.d.ts +20 -7
- package/dist/engine/session/storage-base.js +13 -1
- package/dist/index.d.ts +37 -19
- package/dist/index.js +30 -15
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +13 -1
- package/dist/orchestration/run-workflow-tool.js +101 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
- package/dist/orchestration/workflow-park-adoption.js +588 -323
- package/dist/orchestration/workflow-tree-id.d.ts +66 -0
- package/dist/orchestration/workflow-tree-id.js +66 -0
- package/dist/orchestration/workflow-types.d.ts +90 -11
- package/dist/orchestration/workflow-types.js +10 -1
- package/dist/orchestration/workflow.d.ts +30 -4
- package/dist/orchestration/workflow.js +424 -114
- package/dist/prompt-assembly/catalog/constitution.js +5 -1
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
- package/dist/prompt-assembly/catalog/environment.js +2 -2
- package/dist/prompt-assembly/catalog/events.d.ts +16 -0
- package/dist/prompt-assembly/catalog/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/catalog/sections.js +3 -14
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
- package/dist/prompt-assembly/tool-catalog.js +21 -7
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +4 -1
- package/dist/prompts/default.js +6 -0
- package/dist/stores/file/checkpoint-store.d.ts +11 -10
- package/dist/stores/file/checkpoint-store.js +36 -10
- package/dist/stores/file/file-history-store.d.ts +6 -0
- package/dist/stores/file/file-history-store.js +21 -4
- package/dist/stores/file/fs-atomic.d.ts +1 -1
- package/dist/stores/file/index.d.ts +14 -4
- package/dist/stores/file/index.js +21 -5
- package/dist/stores/file/process-anchor.d.ts +9 -1
- package/dist/stores/file/session-policy-store.js +2 -17
- package/dist/stores/file/session-store.d.ts +27 -0
- package/dist/stores/file/session-store.js +81 -9
- package/dist/stores/file/workflow-journal-store.d.ts +14 -4
- package/dist/stores/file/workflow-journal-store.js +32 -24
- package/dist/stores/file/workflow-run-store.d.ts +15 -4
- package/dist/stores/file/workflow-run-store.js +76 -0
- package/dist/tools/artifact/artifact-tool.d.ts +10 -3
- package/dist/tools/artifact/artifact-tool.js +16 -1
- package/dist/tools/fs/bash-program-position.d.ts +10 -4
- package/dist/tools/fs/bash-program-position.js +11 -8
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
- package/dist/tools/fs/bash-readonly-classifier.js +9 -2
- package/dist/tools/fs/find-actions.d.ts +30 -16
- package/dist/tools/fs/find-actions.js +272 -19
- package/dist/tools/fs/fs-bash.js +8 -5
- package/dist/tools/fs/fs-shared.d.ts +0 -29
- package/dist/tools/fs/fs-shared.js +0 -5
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/read-deny.d.ts +6 -1
- package/dist/tools/fs/read-deny.js +6 -1
- package/dist/tools/fs/read-floor.d.ts +6 -0
- package/dist/tools/fs/read-floor.js +5 -1
- package/dist/tools/fs/removal-actions.d.ts +43 -0
- package/dist/tools/fs/removal-actions.js +25 -0
- package/dist/tools/fs/removal-targets.d.ts +2 -21
- package/dist/tools/fs/removal-targets.js +2 -3
- package/dist/tools/fs/safety.d.ts +37 -1
- package/dist/tools/fs/safety.js +52 -0
- package/dist/tools/fs/shell-climb.d.ts +46 -0
- package/dist/tools/fs/shell-climb.js +79 -0
- package/dist/tools/fs/shell-read-check.js +47 -19
- package/dist/tools/fs/shell-read-establish.js +36 -22
- package/dist/tools/fs/shell-read-judge.d.ts +10 -2
- package/dist/tools/fs/shell-read-judge.js +4 -4
- package/dist/tools/fs/shell-read-plan.d.ts +3 -0
- package/dist/tools/fs/shell-read-plan.js +1 -1
- package/dist/tools/fs/shell-read-workdir.js +3 -2
- package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
- package/dist/tools/fs/shell-read-write-targets.js +3 -0
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +169 -15
- package/wire-changes/core-stores-sql@7.71.0.json +40 -0
- package/wire-changes/core@7.71.0.json +5827 -0
- package/wire-changes/mods-kernel@7.71.0.json +52 -0
- package/wire-changes/primitives@7.71.0.json +473 -0
- package/wire-changes/wiki-gate@7.71.0.json +40 -0
- package/dist/core/frontmatter-fence.d.ts +0 -10
- package/dist/core/frontmatter-fence.js +0 -6
- package/dist/core/permission-rule-syntax.d.ts +0 -46
- package/dist/core/permission-rule-syntax.js +0 -52
|
@@ -305,7 +305,8 @@ export declare const READ_ROW_WRITE_SCOPE = "A read deny row holds on writes too
|
|
|
305
305
|
* A face prefixes its own `Error (<tool>): ` and may append its own closing clause; the finding itself is
|
|
306
306
|
* never re-spelled. One variant, by the row's family and not by the face alone: a write refused by a `Read(…)` row
|
|
307
307
|
* ({@link WriteDenyMatcher.guardsReads}) says the path's reads are denied, where a row of the write face alone says the
|
|
308
|
-
* write list.
|
|
308
|
+
* write list. And one by the target's relation to the row: a recursive read's root that HOLDS a row's location
|
|
309
|
+
* ({@link ReadDenyFinding.under}) is said to hold it — the search below it is refused — never to match it.
|
|
309
310
|
*/
|
|
310
311
|
export declare function readDenySentence(finding: ReadDenyFinding): string;
|
|
311
312
|
/** One deny finding: what the sentence of {@link readDenyRefusal} says and the list of literals it quotes are both read off it. */
|
|
@@ -321,6 +322,10 @@ export interface ReadDenyFinding {
|
|
|
321
322
|
* `Read(…)` rule, not a rule about writing. The sentence then says the path's reads are denied, which is why it is not
|
|
322
323
|
* written, instead of calling a read row a write deny row. */
|
|
323
324
|
readonly readRow?: true;
|
|
325
|
+
/** The target is a recursive read's ROOT and the row lies below it: the root holds the row's location, judged on locations
|
|
326
|
+
* alone. The sentence then says the search below the folder is refused for a location it holds, and that no file need be
|
|
327
|
+
* there — naming a row as what "the target matches" would send the reader looking for a file that may not exist. */
|
|
328
|
+
readonly under?: true;
|
|
324
329
|
}
|
|
325
330
|
/**
|
|
326
331
|
* The deny finding minted ONCE as both of its faces: the sentence ({@link readDenySentence}) and the literals that sentence
|
|
@@ -196,7 +196,8 @@ export function readDenyRefusal(finding) {
|
|
|
196
196
|
const write = finding.face === "write";
|
|
197
197
|
const canonicalNote = finding.canonical !== undefined && finding.canonical !== finding.target ? `(canonical target: "${fitMiddle(finding.canonical, READ_DENY_SENTENCE_PART_MAX)}") ` : "";
|
|
198
198
|
const lexicalHit = finding.matchedView !== undefined && finding.matchedView !== (finding.canonical ?? finding.target);
|
|
199
|
-
const
|
|
199
|
+
const under = finding.under === true && !write;
|
|
200
|
+
const frame = `${finding.action ?? (under ? "searching below" : write ? "writing" : "reading")} "${fitMiddle(finding.target, READ_DENY_SENTENCE_PART_MAX)}" ${canonicalNote}is refused:`;
|
|
200
201
|
const pattern = fitMiddle(finding.pattern, READ_DENY_SENTENCE_PART_MAX);
|
|
201
202
|
const echoed = Object.freeze([
|
|
202
203
|
Object.freeze({ kind: "path", value: finding.target, ...(finding.canonical !== undefined && finding.canonical !== finding.target ? { canonical: finding.canonical } : {}) }),
|
|
@@ -207,6 +208,10 @@ export function readDenyRefusal(finding) {
|
|
|
207
208
|
const reaches = lexicalHit ? `the path passes through "${fitMiddle(finding.matchedView, READ_DENY_SENTENCE_PART_MAX)}", which the read deny row "${pattern}" denies reading` : `the target is a path the read deny row "${pattern}" denies reading`;
|
|
208
209
|
return { sentence: `${frame} ${reaches} — a path whose reads are denied is not written either. ${READ_ROW_WRITE_SCOPE}`, echoed };
|
|
209
210
|
}
|
|
211
|
+
if (under) {
|
|
212
|
+
const holder = lexicalHit ? `the requested path's spelling ("${fitMiddle(finding.matchedView, READ_DENY_SENTENCE_PART_MAX)}")` : "that path";
|
|
213
|
+
return { sentence: `${frame} ${holder} holds a location on ${sensitivePathDenyList(pattern)} — locations are checked, not which files exist, so no such file need be there. ${SENSITIVE_PATH_DENY_SCOPE}`, echoed };
|
|
214
|
+
}
|
|
210
215
|
const judged = lexicalHit ? `the requested path's spelling ("${fitMiddle(finding.matchedView, READ_DENY_SENTENCE_PART_MAX)}") matches` : "the target matches";
|
|
211
216
|
return { sentence: `${frame} ${judged} ${sensitivePathDenyList(pattern, write ? "write" : "read")}. ${write ? WRITE_DENY_SCOPE : SENSITIVE_PATH_DENY_SCOPE}`, echoed };
|
|
212
217
|
}
|
|
@@ -38,6 +38,12 @@ export declare function screenReadDenyFloorRequired(value: unknown, seat: string
|
|
|
38
38
|
* (its audience row is `user`), and the prepare refusal when the deployment requires the floor — one fact, one word, two
|
|
39
39
|
* loudness dialects. */
|
|
40
40
|
export declare const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
|
|
41
|
+
/** The person's notice of {@link READ_DENY_FLOOR_UNKEPT}: what is not protected on this environment (a command that names a listed
|
|
42
|
+
* file is still refused; a recursive read below a folder is not held to the list), and the way a deployment protects it without
|
|
43
|
+
* refusing every run here as requiring the floor would (the row count rides `detail.rowCount`) — the way this host has: on macOS
|
|
44
|
+
* the engine's own OS confinement keeps the floor (`readFloorConfinement: "os"`, which applies on macOS only); elsewhere only an
|
|
45
|
+
* execution environment that keeps it does, so no Mac road is named there. */
|
|
46
|
+
export declare function readDenyFloorUnkeptNotice(platform?: NodeJS.Platform): string;
|
|
41
47
|
/**
|
|
42
48
|
* The floor requirement's refusal, as ONE function of three facts: the environment the table's commands start in, whether the
|
|
43
49
|
* deployment requires the floor, and how many rows the table holds. A refusal (code {@link READ_DENY_FLOOR_UNKEPT}) when the
|
|
@@ -236,6 +236,10 @@ export function screenReadDenyFloorRequired(value, seat) {
|
|
|
236
236
|
throw e;
|
|
237
237
|
}
|
|
238
238
|
export const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
|
|
239
|
+
export function readDenyFloorUnkeptNotice(platform = process.platform) {
|
|
240
|
+
const way = platform === "darwin" ? "the deployment can run commands under this Mac's OS confinement where it applies, which keeps the floor" : "the deployment can run commands in an execution environment that keeps the floor";
|
|
241
|
+
return `Files on the read-deny list are not fully protected from commands here: this environment does not keep the byte floor, so a recursive read can still open them. To protect them, ${way}.`;
|
|
242
|
+
}
|
|
239
243
|
export function readDenyFloorRefusal(facts) {
|
|
240
244
|
if (!facts.required || facts.rows === 0 || keepsReadFloor(facts.env))
|
|
241
245
|
return undefined;
|
|
@@ -257,7 +261,7 @@ export function judgeReadFloorKept(j) {
|
|
|
257
261
|
return false;
|
|
258
262
|
deliverEngineNotice(j.onNotice, {
|
|
259
263
|
code: READ_DENY_FLOOR_UNKEPT,
|
|
260
|
-
message:
|
|
264
|
+
message: readDenyFloorUnkeptNotice(),
|
|
261
265
|
detail: { rowCount, ...(j.attribution?.sessionId !== undefined ? { sessionId: j.attribution.sessionId } : {}), ...(j.attribution?.runId !== undefined ? { runId: j.attribution.runId } : {}) },
|
|
262
266
|
}, undefined, j.told);
|
|
263
267
|
return true;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The REMOVAL ACTIONS — ONE closed table, per program row: how its argv removes, read by both faces a removal meets: the removal
|
|
3
|
+
* guard (`removal-targets.ts`: does it remove a protected location) and the write face (`shell-read-write-targets.ts`: where does
|
|
4
|
+
* what it removes land — inside the write roots or not). `operands`: it removes its operands (`rm`, `rmdir`, with or without a
|
|
5
|
+
* recursive option — removing an empty home or the task root is still removing it; the reference implementation's
|
|
6
|
+
* dangerous-removal arm reads these two). `walk`: where its `-delete` is written it removes entries below each starting point,
|
|
7
|
+
* the starting point included where nothing is left in it ({@link walkRemovalStarts}); the removal guard asks where the
|
|
8
|
+
* `-delete` reaches EVERY entry there — no test in front of it narrows it (`find … -delete`, `find-actions.ts`: the line `rm`
|
|
9
|
+
* draws, `rm -rf ./*` and not `rm -rf ./build/*`). A command a program HANDS ON is a command of its own and is judged by this
|
|
10
|
+
* same table on both faces: `find`'s `-exec` family (the planner reads each as a nested command line, `{}` standing for the
|
|
11
|
+
* entries the action reaches) and `xargs` (a launcher: the program it runs is the segment's own program).
|
|
12
|
+
*/
|
|
13
|
+
import { type FindWord } from "./find-actions.js";
|
|
14
|
+
import { type ProgramRow } from "./program-read-model.js";
|
|
15
|
+
import type { ReadCandidate, ShellReadSegment } from "./shell-read-plan.js";
|
|
16
|
+
export declare const SHELL_REMOVAL_ACTIONS: Readonly<{
|
|
17
|
+
readonly rm: "operands";
|
|
18
|
+
readonly rmdir: "operands";
|
|
19
|
+
readonly find: "walk";
|
|
20
|
+
}>;
|
|
21
|
+
type RemovalActionTable = typeof SHELL_REMOVAL_ACTIONS;
|
|
22
|
+
export type ShellRemovalCommand = {
|
|
23
|
+
readonly [K in keyof RemovalActionTable]: RemovalActionTable[K] extends "operands" ? K : never;
|
|
24
|
+
}[keyof RemovalActionTable];
|
|
25
|
+
/** The table's row for a program row's key (`undefined`: the program removes nothing by this table). */
|
|
26
|
+
export declare const removalActionOf: (key: string) => RemovalActionTable[keyof RemovalActionTable] | undefined;
|
|
27
|
+
/** The programs that remove their OPERANDS (the table's `operands` rows). */
|
|
28
|
+
export declare const SHELL_REMOVAL_COMMANDS: readonly ShellRemovalCommand[];
|
|
29
|
+
/**
|
|
30
|
+
* The starting points a `walk` row's argv (the words after the program word) removes in: where a `-delete` is written, each
|
|
31
|
+
* starting point the command names (`[]`: it names none — the walk starts where the program stands); `undefined` where the row is
|
|
32
|
+
* no walk, no `-delete` is written, or the starting points are read from a file (none of them is in the command).
|
|
33
|
+
*/
|
|
34
|
+
export declare function walkRemovalStarts(row: ProgramRow, words: readonly FindWord[]): readonly FindWord[] | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The WRITE targets of a removal walk on the write face ({@link walkRemovalStarts} of the segment's program): each starting point
|
|
37
|
+
* it removes in, as the plan placed its word (an operand, BSD's `-f PATH`, a word of a program the deployment did not list), or —
|
|
38
|
+
* where it names none — the directory the program
|
|
39
|
+
* starts in. The write face writes each where it lands and at its entry: the walk removes below the place a link there leads to
|
|
40
|
+
* where `-H` / `-L` follow it, and the link itself where they do not.
|
|
41
|
+
*/
|
|
42
|
+
export declare function walkRemovalTargetsOf(segment: ShellReadSegment): ReadCandidate[];
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { findActionsOf, findWordOf } from "./find-actions.js";
|
|
2
|
+
import { programRow } from "./program-read-model.js";
|
|
3
|
+
import { readProgramPosition } from "./bash-program-position.js";
|
|
4
|
+
export const SHELL_REMOVAL_ACTIONS = Object.freeze({ rm: "operands", rmdir: "operands", find: "walk" });
|
|
5
|
+
export const removalActionOf = (key) => (Object.hasOwn(SHELL_REMOVAL_ACTIONS, key) ? SHELL_REMOVAL_ACTIONS[key] : undefined);
|
|
6
|
+
export const SHELL_REMOVAL_COMMANDS = Object.freeze(Object.keys(SHELL_REMOVAL_ACTIONS).filter((k) => removalActionOf(k) === "operands"));
|
|
7
|
+
export function walkRemovalStarts(row, words) {
|
|
8
|
+
if (removalActionOf(row.key) !== "walk")
|
|
9
|
+
return undefined;
|
|
10
|
+
const actions = findActionsOf(row, words);
|
|
11
|
+
return actions.deletes && !actions.startsFromFile ? actions.starts.map((k) => words[k]) : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function walkRemovalTargetsOf(segment) {
|
|
14
|
+
const pos = readProgramPosition(segment.argv).program;
|
|
15
|
+
const row = segment.verb === undefined || pos === undefined ? undefined : programRow(segment.verb.basename);
|
|
16
|
+
if (row === undefined || pos === undefined)
|
|
17
|
+
return [];
|
|
18
|
+
const starts = walkRemovalStarts(row, segment.argv.slice(pos.index + 1).map(findWordOf));
|
|
19
|
+
if (starts === undefined)
|
|
20
|
+
return [];
|
|
21
|
+
if (starts.length === 0)
|
|
22
|
+
return segment.programStart !== undefined ? [segment.programStart] : [];
|
|
23
|
+
const raws = new Set(starts.map((w) => w.raw));
|
|
24
|
+
return segment.reads.filter((c) => (c.provenance === "operand" || c.provenance === "option_value" || c.provenance === "unlisted_word") && raws.has(c.raw));
|
|
25
|
+
}
|
|
@@ -3,26 +3,8 @@ import { type EstablishedPlan } from "./shell-read-establish.js";
|
|
|
3
3
|
import { type ProgramPositionRefusal } from "./bash-program-position.js";
|
|
4
4
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
5
5
|
import type { ToolCallRequest } from "../../core/tool-policy.js";
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
* `rmdir`, with or without a recursive option — removing an empty home or the task root is still removing it; the reference
|
|
9
|
-
* implementation's dangerous-removal arm reads these two). `walk`: it removes every entry below a starting point when its
|
|
10
|
-
* `-delete` reaches every entry there — no test in front of it narrows it (`find … -delete`, `find-actions.ts`: the line `rm`
|
|
11
|
-
* draws, `rm -rf ./*` and not `rm -rf ./build/*`). A command a program HANDS ON is a command of its own and is judged by this
|
|
12
|
-
* same table and walk: `find`'s `-exec` family (the planner reads each as a nested command line, `{}` standing for the entries
|
|
13
|
-
* the action reaches) and `xargs` (a launcher: the program it runs is the segment's own program).
|
|
14
|
-
*/
|
|
15
|
-
export declare const SHELL_REMOVAL_ACTIONS: Readonly<{
|
|
16
|
-
readonly rm: "operands";
|
|
17
|
-
readonly rmdir: "operands";
|
|
18
|
-
readonly find: "walk";
|
|
19
|
-
}>;
|
|
20
|
-
type RemovalActionTable = typeof SHELL_REMOVAL_ACTIONS;
|
|
21
|
-
export type ShellRemovalCommand = {
|
|
22
|
-
readonly [K in keyof RemovalActionTable]: RemovalActionTable[K] extends "operands" ? K : never;
|
|
23
|
-
}[keyof RemovalActionTable];
|
|
24
|
-
/** The programs that remove their OPERANDS (the table's `operands` rows). */
|
|
25
|
-
export declare const SHELL_REMOVAL_COMMANDS: readonly ShellRemovalCommand[];
|
|
6
|
+
/** The removal actions (`removal-actions.ts`: the one table both faces a removal meets read). */
|
|
7
|
+
export { SHELL_REMOVAL_ACTIONS, SHELL_REMOVAL_COMMANDS, type ShellRemovalCommand } from "./removal-actions.js";
|
|
26
8
|
/** What makes a removal target dangerous, in the order a card names it. */
|
|
27
9
|
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level" | "mounted_drive";
|
|
28
10
|
/** The protected locations a removal is judged against, each at its spelling and at the location the environment answers
|
|
@@ -175,4 +157,3 @@ export interface RemovalGuardSeat {
|
|
|
175
157
|
export declare function removalReadingOf(command: string, req: Pick<ToolCallRequest, "cwd" | "root">, seat: RemovalGuardSeat | undefined, safeRoots?: readonly string[]): {
|
|
176
158
|
judge(signal?: AbortSignal): Promise<RemovalVerdict | undefined>;
|
|
177
159
|
} | undefined;
|
|
178
|
-
export {};
|
|
@@ -11,9 +11,8 @@ import { programArgs } from "./shell-read-write-targets.js";
|
|
|
11
11
|
import { declaresOption, implementationsOf, programRow, rowRefusesArgv, runsShellText, selectedOptions, writeReadings } from "./program-read-model.js";
|
|
12
12
|
import { inlineUntrusted } from "../../core/untrusted-text.js";
|
|
13
13
|
import { certainlyRunOn, deletesEverythingFrom, findActionsOf, findDirsDown, findHandedCommands, findStartsOf, findWordOf } from "./find-actions.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const SHELL_REMOVAL_COMMANDS = Object.freeze(Object.keys(SHELL_REMOVAL_ACTIONS).filter((k) => actionOf(k) === "operands"));
|
|
14
|
+
import { removalActionOf as actionOf, SHELL_REMOVAL_COMMANDS } from "./removal-actions.js";
|
|
15
|
+
export { SHELL_REMOVAL_ACTIONS, SHELL_REMOVAL_COMMANDS } from "./removal-actions.js";
|
|
17
16
|
const REMOVAL_COMMAND_SET = new Set(SHELL_REMOVAL_COMMANDS);
|
|
18
17
|
function removalSeatAt(seat, plan, segment, apart) {
|
|
19
18
|
const started = seat.startedIn ?? [];
|
|
@@ -319,11 +319,47 @@ export declare function clipSpelling(spelled: string): string;
|
|
|
319
319
|
* {@link shellAnchoredSpellingOf}), the tracked working directory the shell reports, and {@link isShellRootedSpellingUnmapped}.
|
|
320
320
|
*/
|
|
321
321
|
export declare function shellDriveSpellingOf(family: PathFamily | undefined, spelled: string): string | undefined;
|
|
322
|
+
/** The SHELL's drive spelling (`/x/…`, read as {@link shellDriveSpellingOf} reads its lead) as the drive path it walks, every
|
|
323
|
+
* `..` KEPT as written — whether one climbs above the drive's root is the walk's to find (a link on the way decides it), and a
|
|
324
|
+
* reader that folds reads it as any drive path the shell anchored ({@link shellAnchoredSpellingOf}). `undefined` where the
|
|
325
|
+
* first segment is no drive letter, and on any tree that is not win. */
|
|
326
|
+
export declare function shellDrivePathOf(family: PathFamily | undefined, spelled: string): string | undefined;
|
|
327
|
+
/**
|
|
328
|
+
* A ROOTED spelling on a win tree that the shell may read as a drive path although it is not the shell's drive spelling — the
|
|
329
|
+
* drive path it then names and whose walk it is (`walk`): `/cygdrive/x/…` (the Cygwin drive prefix, walked by the shell as its
|
|
330
|
+
* drive spelling is, `..` kept; Git Bash's mount table sets that prefix to `/`, so whether the shell still answers `/cygdrive` is
|
|
331
|
+
* the shell's) and a single-backslash-rooted `\…` (Win32's current-drive form: the root of `base`'s drive or share, walked as
|
|
332
|
+
* Win32 walks it — a `..` there stays at that root). Either may instead be a path of the emulation's own tree, which no reader
|
|
333
|
+
* here places: the drive path is a place the word MAY lead (a stand-in), read where a reading tightens. `undefined` for every
|
|
334
|
+
* other spelling, a base that is not a qualified win path, and any tree that is not win.
|
|
335
|
+
*/
|
|
336
|
+
export declare function shellDriveAliasOf(family: PathFamily | undefined, spelled: string, base: string): {
|
|
337
|
+
readonly path: string;
|
|
338
|
+
readonly walk: "shell" | "win32";
|
|
339
|
+
} | undefined;
|
|
340
|
+
/** The places a drive-relative spelling (`C:rest`, no separator after the colon) may be read from where `base` — the shell's
|
|
341
|
+
* working directory — is on that drive: `rest` relative to `base` (Win32's working directory of the process's current drive)
|
|
342
|
+
* and relative to the drive's root (the reading where the shell keeps no working directory per drive) — which of the two the
|
|
343
|
+
* shell takes is its own, so both are candidates, each `[base, rest]` (`rest` `.` for a bare `C:`). `undefined` for every
|
|
344
|
+
* other spelling, for a drive other than `base`'s (whose working directory only that process knows), and on any tree that is
|
|
345
|
+
* not win. */
|
|
346
|
+
export declare function driveRelativeReadingsOf(family: PathFamily | undefined, base: string, spelled: string): ReadonlyArray<readonly [string, string]> | undefined;
|
|
347
|
+
/** Does the shell's walk of a drive path it anchored ({@link shellAnchoredSpellingOf}) climb above the drive's root — a `..`
|
|
348
|
+
* counted on the text past the drive's own segments? There the shell stands in the emulation's root, not at the drive's
|
|
349
|
+
* root a Win32 fold clamps it to. `false` for any other spelling and on any tree that is not win. */
|
|
350
|
+
export declare function shellWalkLeavesDrive(family: PathFamily | undefined, anchored: string): boolean;
|
|
351
|
+
/** Where the shell's walk goes on from a spelling of the emulation's own tree (`/…`, reached by a `..` above a drive's root):
|
|
352
|
+
* the drive paths it names where the walk enters a drive — a `..` at `/` stays there; the drive's own `..` KEPT for the walk (a
|
|
353
|
+
* link below decides where they lead: `/d/deep/../../x` is walked through `D:\deep`) and folded as the shell folds a `/`-rooted
|
|
354
|
+
* path ({@link shellDriveSpellingOf}: `/d/deep/../../x` is `/x` there, `/etc/../c/x` is `C:\x`) — which of the two the shell
|
|
355
|
+
* takes is its own, so each is a landing; none where the walk stays in that tree. */
|
|
356
|
+
export declare function shellRootedLandingsOf(emulation: string): readonly string[];
|
|
322
357
|
/** A drive path the SHELL anchored itself — a relative operand joined to its working directory, a `~` word to its home — is
|
|
323
358
|
* walked in that shell's namespace: where a `..` climbs above the drive's root it reaches the emulation's root, so the path is
|
|
324
359
|
* read as {@link shellDriveSpellingOf} reads `/x/…` (`C:\proj\..\..\d\f` ⇒ `D:\f`, not the Win32 clamp's `C:\d\f`). `undefined`
|
|
325
360
|
* where no `..` climbs above the drive's root, where the climb lands in the emulation's own tree (`C:\proj\..\..\etc` is `/etc`
|
|
326
|
-
* there, a place only that shell knows — the
|
|
361
|
+
* there, a place only that shell knows — the shell operand resolver reads the clamp as a stand-in there), and for any other
|
|
362
|
+
* spelling or family. */
|
|
327
363
|
export declare function shellAnchoredSpellingOf(family: PathFamily | undefined, anchored: string): string | undefined;
|
|
328
364
|
/** A ROOTED (not qualified) spelling handed to the SHELL on a win tree (`/etc`, `/cygdrive/d/x`, `\\x`) that is not the
|
|
329
365
|
* shell's drive spelling ({@link shellDriveSpellingOf}) is the shell's to map — the win32 adapter runs Git Bash, where
|
package/dist/tools/fs/safety.js
CHANGED
|
@@ -377,6 +377,58 @@ export function shellDriveSpellingOf(family, spelled) {
|
|
|
377
377
|
const drive = read[0];
|
|
378
378
|
return drive !== undefined && /^[A-Za-z]$/.test(drive) ? `${drive.toUpperCase()}:\\${read.slice(1).join("\\")}` : undefined;
|
|
379
379
|
}
|
|
380
|
+
export function shellDrivePathOf(family, spelled) {
|
|
381
|
+
const lead = /^\/*/.exec(spelled)[0].length;
|
|
382
|
+
if (family !== "win" || lead === 0 || lead === 2 || spelled[lead] === "\\")
|
|
383
|
+
return undefined;
|
|
384
|
+
const segs = spelled.slice(lead).split(/[\\/]+/).filter((seg) => seg !== "" && seg !== ".");
|
|
385
|
+
const drive = segs[0];
|
|
386
|
+
return drive !== undefined && /^[A-Za-z]$/.test(drive) ? `${drive.toUpperCase()}:\\${segs.slice(1).join("\\")}` : undefined;
|
|
387
|
+
}
|
|
388
|
+
export function shellDriveAliasOf(family, spelled, base) {
|
|
389
|
+
if (family !== "win")
|
|
390
|
+
return undefined;
|
|
391
|
+
const cygdrive = /^\/+cygdrive[\\/]+([A-Za-z])(?=[\\/]|$)([\s\S]*)$/i.exec(spelled);
|
|
392
|
+
if (cygdrive !== null && !spelled.startsWith("//")) {
|
|
393
|
+
const path = shellDrivePathOf("win", `/${cygdrive[1]}${cygdrive[2]}`);
|
|
394
|
+
return path === undefined ? undefined : { path, walk: "shell" };
|
|
395
|
+
}
|
|
396
|
+
if (/^\\(?!\\)/.test(spelled) && isAbsoluteForFamily("win", base))
|
|
397
|
+
return { path: joinForFamily("win", base, spelled), walk: "win32" };
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
export function driveRelativeReadingsOf(family, base, spelled) {
|
|
401
|
+
const m = family === "win" ? /^([A-Za-z]):(?![\\/])([\s\S]*)$/.exec(spelled) : null;
|
|
402
|
+
const drive = /^([A-Za-z]):[\\/]/.exec(base)?.[1];
|
|
403
|
+
if (m === null || drive === undefined || drive.toLowerCase() !== m[1].toLowerCase())
|
|
404
|
+
return undefined;
|
|
405
|
+
const rest = m[2] === "" ? "." : m[2].startsWith("~") ? `./${m[2]}` : m[2];
|
|
406
|
+
return [[base, rest], [`${drive}:\\`, rest]];
|
|
407
|
+
}
|
|
408
|
+
export function shellWalkLeavesDrive(family, anchored) {
|
|
409
|
+
const m = family === "win" ? /^[A-Za-z]:[\\/]([\s\S]*)$/.exec(anchored) : null;
|
|
410
|
+
if (m === null)
|
|
411
|
+
return false;
|
|
412
|
+
let depth = 0;
|
|
413
|
+
for (const seg of m[1].split(/[\\/]+/)) {
|
|
414
|
+
if (seg === "" || seg === ".")
|
|
415
|
+
continue;
|
|
416
|
+
if (seg !== "..")
|
|
417
|
+
depth++;
|
|
418
|
+
else if (--depth < 0)
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
export function shellRootedLandingsOf(emulation) {
|
|
424
|
+
const segs = emulation.split(/[\\/]+/).filter((seg) => seg !== "" && seg !== ".");
|
|
425
|
+
while (segs[0] === "..")
|
|
426
|
+
segs.shift();
|
|
427
|
+
if (segs.length === 0)
|
|
428
|
+
return [];
|
|
429
|
+
const rooted = `/${segs.join("/")}`;
|
|
430
|
+
return [...new Set([shellDrivePathOf("win", rooted), shellDriveSpellingOf("win", rooted)].filter((s) => s !== undefined))];
|
|
431
|
+
}
|
|
380
432
|
export function shellAnchoredSpellingOf(family, anchored) {
|
|
381
433
|
const m = family === "win" ? /^([A-Za-z]):[\\/]([\s\S]*)$/.exec(anchored) : null;
|
|
382
434
|
if (m === null)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE SHELL'S OWN READINGS OF A PATH ON A WIN TREE — the places Git Bash (the win32 adapter's shell, the MSYS line) may take a
|
|
3
|
+
* spelling to that a Win32 reading does not: a `..` taken at a drive's root reaches the emulation's root `/` (where the next
|
|
4
|
+
* one-letter segment is a drive again) instead of staying at the drive's root; a logical `cd` that climbs above a drive's root
|
|
5
|
+
* stands there; a drive-relative `C:rest` may be read below the working directory or below the drive's root. Each reading only
|
|
6
|
+
* ADDS a place a word may lead — the readings the station had stay — and on a POSIX tree none applies. The walk that resolves
|
|
7
|
+
* links lives in the establishment (shell-read-establish.ts): it notes a climb where it takes one ({@link noteClimb}) and hands
|
|
8
|
+
* its own `resolve` to the readers here, which never read the filesystem themselves.
|
|
9
|
+
*/
|
|
10
|
+
import { type PathFamily } from "./safety.js";
|
|
11
|
+
import type { EstablishedRead } from "./shell-read-judge.js";
|
|
12
|
+
/** One walk of the establishment: where `p` lands (`undefined`: unanswered), noting the shell's climbs it takes in `climbs`. */
|
|
13
|
+
export type ClimbWalk = (p: string, climbs: string[]) => Promise<{
|
|
14
|
+
readonly value: string;
|
|
15
|
+
readonly exact: boolean;
|
|
16
|
+
readonly missing?: boolean;
|
|
17
|
+
} | undefined>;
|
|
18
|
+
/** Where ONE spelling is read from at one base: the base itself — or, for a drive-relative spelling on the base's drive, each
|
|
19
|
+
* place the shell may read it from ({@link driveRelativeReadingsOf}: the base and the drive's root, the rest below each). */
|
|
20
|
+
export declare function readingsAt(base: string, spelled: string): ReadonlyArray<readonly [string, string]>;
|
|
21
|
+
/** At a `..` the walk takes from `at` (the canonical place it stands), with `rest` the segments after it: where `at` is a drive's
|
|
22
|
+
* root on a win tree, note the shell's reading of the step — the emulation's root `/` and the rest from there — in `climbs`
|
|
23
|
+
* (once). `true` when a climb was noted: every further `..` of the same run reaches the same `/`, and the walk notes none. */
|
|
24
|
+
export declare function noteClimb(family: PathFamily, at: string, rest: readonly string[], climbs: string[]): boolean;
|
|
25
|
+
/** The drive paths the noted climbs (`climbs`, growing as `each` walks them) lead to, each handed to `each` once
|
|
26
|
+
* ({@link shellRootedLandingsOf}; a climb that stays in the emulation's own tree leads to none). Past {@link CLIMB_LANDINGS_MAX}
|
|
27
|
+
* the rest is not followed and `bounded` records it (the judgment is then incomplete, never silently short). */
|
|
28
|
+
export declare function landingsOf(climbs: string[], each: (landing: string) => Promise<void>, bounded: (detail: string) => unknown): Promise<void>;
|
|
29
|
+
/** A climb's landing that reaches a target already held: one read, the landing's spellings and hops it does not hold yet added
|
|
30
|
+
* for the deny judge (`kept`: the read that stays, by the seats' one rule). */
|
|
31
|
+
export declare function withClimbedViews(kept: EstablishedRead, other: EstablishedRead): EstablishedRead;
|
|
32
|
+
/** A pattern whose walk climbs above a drive's root is expanded where the shell's climb leads too: `patterns` and the landings. */
|
|
33
|
+
export declare function withClimbedPatterns(family: PathFamily, patterns: readonly string[], walk: ClimbWalk, bounded: (detail: string) => unknown, signal?: AbortSignal): Promise<string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* A word the text could not place past a move it could not follow is judged where the text stood when it lost track — its
|
|
36
|
+
* floor spellings, each `..` kept. Where such a spelling's walk climbs above a drive's root, the shell's landing (a move through
|
|
37
|
+
* a link to a drive's root and up leaves the shell in the emulation's root) and where it resolves are views of the word too.
|
|
38
|
+
*/
|
|
39
|
+
export declare function withFloorClimbs(family: PathFamily, read: EstablishedRead, walk: ClimbWalk, bounded: (detail: string) => unknown, signal?: AbortSignal): Promise<EstablishedRead>;
|
|
40
|
+
/** Where a logical move from `base` to `target` stands: where the target placed as an operand is. A stand-in is no place — a
|
|
41
|
+
* target whose walk climbs above a drive's root into the emulation's own tree (`cd /c/..`, `cd ../..` from `C:\proj`) is one,
|
|
42
|
+
* so the walk loses track there, as at `cd /` (where Git Bash stands then is design ticket #5314's). A place the walk itself
|
|
43
|
+
* holds (`cd -`, `cd "$PWD"`) whose spelling climbs above a drive's root ({@link shellWalkLeavesDrive}) keeps that climb as
|
|
44
|
+
* spelled (`C:\..`); a target the command TYPED as a qualified Win32 path (`typed`) is Windows's to fold and keeps the fold.
|
|
45
|
+
* `undefined`: no place. */
|
|
46
|
+
export declare function movedTo(base: string, target: string, homeDir: string | undefined, typed: boolean): string | undefined;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { driveRelativeReadingsOf, isAbsoluteForFamily, isIdentityDir, isUncIdentity, pathFamilyOf, pathIdentityOf, shellRootedLandingsOf, shellWalkLeavesDrive } from "./safety.js";
|
|
2
|
+
import { resolveOperandSpellings } from "./bash-readonly-classifier.js";
|
|
3
|
+
const CLIMB_LANDINGS_MAX = 16;
|
|
4
|
+
const PARENT_STEP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
5
|
+
export function readingsAt(base, spelled) {
|
|
6
|
+
return (base === "" ? undefined : driveRelativeReadingsOf(pathFamilyOf({ root: base }), base, spelled)) ?? [[base, spelled]];
|
|
7
|
+
}
|
|
8
|
+
export function noteClimb(family, at, rest, climbs) {
|
|
9
|
+
const id = family === "win" ? pathIdentityOf(at, "win") : undefined;
|
|
10
|
+
if (id === undefined || !id.ok || isUncIdentity(id.identity) || isIdentityDir(id.identity, "win"))
|
|
11
|
+
return false;
|
|
12
|
+
const emulation = `/${rest.join("/")}`;
|
|
13
|
+
if (!climbs.includes(emulation))
|
|
14
|
+
climbs.push(emulation);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
export async function landingsOf(climbs, each, bounded) {
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
for (let k = 0; k < climbs.length; k++) {
|
|
20
|
+
if (k >= CLIMB_LANDINGS_MAX)
|
|
21
|
+
return void bounded(`a path climbs above a drive's root more than ${CLIMB_LANDINGS_MAX} times, too many readings to follow to verify where it leads`);
|
|
22
|
+
for (const landing of shellRootedLandingsOf(climbs[k])) {
|
|
23
|
+
if (seen.has(landing))
|
|
24
|
+
continue;
|
|
25
|
+
seen.add(landing);
|
|
26
|
+
await each(landing);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function withClimbedViews(kept, other) {
|
|
31
|
+
const spellings = other.spellings.filter((s) => !kept.spellings.includes(s));
|
|
32
|
+
const hops = (other.hops ?? []).filter((h) => !(kept.hops ?? []).includes(h));
|
|
33
|
+
return spellings.length === 0 && hops.length === 0 ? kept : { ...kept, spellings: [...kept.spellings, ...spellings], ...(hops.length > 0 ? { hops: [...(kept.hops ?? []), ...hops] } : {}) };
|
|
34
|
+
}
|
|
35
|
+
async function climbsOf(family, spellings, walk, signal) {
|
|
36
|
+
const climbs = [];
|
|
37
|
+
if (family !== "win")
|
|
38
|
+
return climbs;
|
|
39
|
+
try {
|
|
40
|
+
for (const s of spellings)
|
|
41
|
+
if (isAbsoluteForFamily("win", s) && PARENT_STEP.test(s))
|
|
42
|
+
await walk(s, climbs);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (signal?.aborted === true)
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
return climbs;
|
|
49
|
+
}
|
|
50
|
+
export async function withClimbedPatterns(family, patterns, walk, bounded, signal) {
|
|
51
|
+
const out = [...patterns];
|
|
52
|
+
await landingsOf(await climbsOf(family, patterns, walk, signal), async (landing) => void out.push(landing), bounded);
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
export async function withFloorClimbs(family, read, walk, bounded, signal) {
|
|
56
|
+
if (family !== "win" || read.established !== "unestablishable" || read.candidate.bases !== "unmodelled")
|
|
57
|
+
return read;
|
|
58
|
+
const climbs = await climbsOf(family, read.spellings, walk, signal);
|
|
59
|
+
const added = [];
|
|
60
|
+
try {
|
|
61
|
+
await landingsOf(climbs, async (landing) => {
|
|
62
|
+
const real = await walk(landing, climbs);
|
|
63
|
+
added.push(landing, ...(real !== undefined && (real.exact || real.missing === true) ? [real.value] : []));
|
|
64
|
+
}, bounded);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (signal?.aborted === true)
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
const views = [...new Set(added)].filter((c) => !read.spellings.includes(c));
|
|
71
|
+
return views.length === 0 ? read : { ...read, spellings: [...read.spellings, ...views] };
|
|
72
|
+
}
|
|
73
|
+
export function movedTo(base, target, homeDir, typed) {
|
|
74
|
+
const at = resolveOperandSpellings(base, target, homeDir);
|
|
75
|
+
if (at === undefined || at.standIn === true)
|
|
76
|
+
return undefined;
|
|
77
|
+
const family = at.spelled === undefined ? undefined : pathFamilyOf({ root: at.spelled });
|
|
78
|
+
return at.spelled !== undefined && !(typed && isAbsoluteForFamily(family ?? "own", target)) && shellWalkLeavesDrive(family, at.spelled) ? at.spelled : at.folded;
|
|
79
|
+
}
|
|
@@ -4,7 +4,8 @@ import { BASH_READONLY_CONFINEMENT_NOTE, targetUnavailableCard, targetUnavailabl
|
|
|
4
4
|
import { envErrorDetail } from "./env-error-detail.js";
|
|
5
5
|
import { holdsProcSensitiveFile, isAbsoluteForFamily, isProcSensitiveFile, normalizeAbsPathLexically, pathFamilyOf, violationDetails, withinAnyRoot } from "./safety.js";
|
|
6
6
|
import { checkedReadDenyHomes, fitMiddle, READ_DENY_SENTENCE_PART_MAX, readDenyRefusal } from "./read-deny.js";
|
|
7
|
-
import {
|
|
7
|
+
import { INLINE_TRUNCATION_MARK_CODEPOINTS, inlineUntrusted, PROBE_REASON_MAX } from "../../core/untrusted-text.js";
|
|
8
|
+
import { NOT_AUTO_ALLOWED, declinedProgramReason } from "./bash-program-position.js";
|
|
8
9
|
import { bashClassifyDefaultAllow } from "./bash-readonly-classifier.js";
|
|
9
10
|
import { planShellReads } from "./shell-read-plan.js";
|
|
10
11
|
import { createShellReadEstablisher, establishShellReadsLexically } from "./shell-read-establish.js";
|
|
@@ -247,6 +248,12 @@ function shellCommandOf(args) {
|
|
|
247
248
|
}
|
|
248
249
|
const ACCOUNT_PART_MAX = READ_DENY_SENTENCE_PART_MAX;
|
|
249
250
|
const CAUSE_SPELLING_MAX = 64;
|
|
251
|
+
const QUOTED_SEGMENT_MIN = 24;
|
|
252
|
+
const ACCOUNT_PATH_MAX = 44;
|
|
253
|
+
function unplacedReadReach(unchecked) {
|
|
254
|
+
return unchecked === "deny_list" ? "the read station cannot check what it reads against the read deny list" : "it may read files outside this session's folders";
|
|
255
|
+
}
|
|
256
|
+
const NOT_AUTO_ALLOWED_AFTER_REACH = "— it is not allowed through automatically";
|
|
250
257
|
function fitCause(cause) {
|
|
251
258
|
return cause.replace(/^"([^"]*)"/, (_m, spelling) => `"${fitMiddle(spelling, CAUSE_SPELLING_MAX)}"`);
|
|
252
259
|
}
|
|
@@ -258,37 +265,55 @@ function reenteredPrograms(fold) {
|
|
|
258
265
|
const quoted = names.map((n) => `"${fitMiddle(n, CAUSE_SPELLING_MAX)}"`);
|
|
259
266
|
return quoted.length === 0 ? "the program it runs" : quoted.length === 1 ? quoted[0] : `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}`;
|
|
260
267
|
}
|
|
261
|
-
function findingAccount(fold, boundary) {
|
|
268
|
+
function findingAccount(fold, boundary, card) {
|
|
262
269
|
const w = fold.witness;
|
|
263
270
|
const face = faceOf(fold);
|
|
264
271
|
const { verb } = shellReadFaceWords(face);
|
|
265
272
|
const writes = w !== undefined && face === "write";
|
|
266
273
|
const roots = writes ? (boundary.writeRoots ?? []) : boundary.roots;
|
|
267
|
-
const
|
|
274
|
+
const fit = (s, max) => (card ? fitMiddle(s, max) : s);
|
|
275
|
+
const causeOf = (c) => (card ? fitCause(c) : c);
|
|
276
|
+
const allowed = fit(roots.length > 0 ? roots.join(", ") : "(none)", ACCOUNT_PART_MAX);
|
|
277
|
+
const reach = `, so ${unplacedReadReach(boundary.face === "open" ? "deny_list" : "roots")}`;
|
|
278
|
+
const unplaced = (account) => `${account}${reach} ${NOT_AUTO_ALLOWED_AFTER_REACH}`;
|
|
279
|
+
const pathOf = (p) => fit(p, ACCOUNT_PATH_MAX);
|
|
280
|
+
const quotedBefore = (text, rest) => {
|
|
281
|
+
const written = text.trim();
|
|
282
|
+
if (!card)
|
|
283
|
+
return `"${written}"${rest}`;
|
|
284
|
+
const room = Math.max(QUOTED_SEGMENT_MIN, PROBE_REASON_MAX - [...rest].length - [...reach].length - 2 - 2 * INLINE_TRUNCATION_MARK_CODEPOINTS);
|
|
285
|
+
const held = inlineUntrusted(written, Number.MAX_SAFE_INTEGER);
|
|
286
|
+
return [...held].length <= room ? `"${written}"${rest}` : `"${fitMiddle(held, room)}"${rest}`;
|
|
287
|
+
};
|
|
268
288
|
switch (fold.finding) {
|
|
269
|
-
case "outside_roots":
|
|
270
|
-
|
|
289
|
+
case "outside_roots": {
|
|
290
|
+
const target = `"${pathOf(w?.read.target ?? "?")}"`;
|
|
291
|
+
const linked = w !== undefined && (w.read.hops?.length ?? 0) > 0 && w.read.target !== undefined && !w.read.spellings.includes(w.read.target) ? `"${pathOf(w.read.candidate.spelled)}" leads through a link to ${target}, which` : target;
|
|
292
|
+
return `${verb} outside the allowed directories for this session: ${linked} is not under ${allowed} ${NOT_AUTO_ALLOWED}`;
|
|
293
|
+
}
|
|
271
294
|
case "unestablishable":
|
|
272
295
|
case "unanswered":
|
|
296
|
+
if (w?.denyRowUnasked === true && w.read.cause !== undefined)
|
|
297
|
+
return `what this command ${verb} could not be checked against the deny list: ${causeOf(w.read.cause)} ${NOT_AUTO_ALLOWED_AFTER_REACH}`;
|
|
273
298
|
if (writes && boundary.writeRoots === undefined)
|
|
274
|
-
return `this command ${verb} "${
|
|
299
|
+
return `this command ${verb} "${fit(w.read.target ?? w.read.candidate.spelled, ACCOUNT_PART_MAX)}", and this session declares no directories it may write ${NOT_AUTO_ALLOWED}`;
|
|
275
300
|
if (writes)
|
|
276
|
-
return `where this command ${verb} could not be established${w.read.cause !== undefined ? `: ${
|
|
301
|
+
return `where this command ${verb} could not be established${w.read.cause !== undefined ? `: ${causeOf(w.read.cause)}` : ""}, so it cannot be confirmed to write only inside the allowed directories for this session (${allowed}) ${NOT_AUTO_ALLOWED}`;
|
|
277
302
|
if (w?.read.cause !== undefined)
|
|
278
|
-
return `where this command ${verb} could not be established: ${
|
|
303
|
+
return unplaced(`where this command ${verb} could not be established: ${causeOf(w.read.cause)}`);
|
|
279
304
|
if (fold.cause !== undefined)
|
|
280
|
-
return `where this command ${verb} could not be established: ${
|
|
305
|
+
return unplaced(`where this command ${verb} could not be established: ${causeOf(fold.cause)}`);
|
|
281
306
|
if (fold.declined?.baseMove !== undefined)
|
|
282
|
-
return
|
|
307
|
+
return unplaced(quotedBefore(fold.declined.text, " moves the working directory somewhere this command's text does not settle"));
|
|
283
308
|
if (fold.declined?.unreadProgramText !== undefined)
|
|
284
|
-
return
|
|
309
|
+
return unplaced(quotedBefore(fold.declined.text, `: ${fold.declined.unreadProgramText}`));
|
|
285
310
|
if (fold.declined !== undefined)
|
|
286
|
-
return `the text given to ${reenteredPrograms(fold)} — as an argument, on standard input, or in the file it names — runs as shell text this station does not parse
|
|
287
|
-
return `where this command ${verb} could not be established
|
|
311
|
+
return unplaced(`the text given to ${reenteredPrograms(fold)} — as an argument, on standard input, or in the file it names — runs as shell text this station does not parse`);
|
|
312
|
+
return unplaced(`where this command ${verb} could not be established`);
|
|
288
313
|
case "declined":
|
|
289
|
-
return fold.declined !== undefined ?
|
|
314
|
+
return unplaced(fold.declined !== undefined ? declinedProgramReason(fold.declined.text, quotedBefore) : "the station could not read which program runs");
|
|
290
315
|
case "identity_changed":
|
|
291
|
-
return `"${
|
|
316
|
+
return `"${fit(w?.read.candidate.raw ?? "?", ACCOUNT_PART_MAX)}" resolves to "${fit(w?.read.target ?? "?", ACCOUNT_PART_MAX)}" now, not where it resolved when this call was judged`;
|
|
292
317
|
case "deny_hit":
|
|
293
318
|
case "target_unavailable":
|
|
294
319
|
case "none":
|
|
@@ -339,12 +364,13 @@ function refusalOf(tool, fold, boundary, paths) {
|
|
|
339
364
|
if (fold.finding === "deny_hit" && w?.deny !== undefined) {
|
|
340
365
|
const target = w.read.target ?? w.deny.matchedView;
|
|
341
366
|
const write = w.deny.face === "write";
|
|
342
|
-
const
|
|
367
|
+
const under = !write && w.deny.under === true;
|
|
368
|
+
const { sentence: core, echoed } = readDenyRefusal({ target, pattern: w.deny.pattern, matchedView: w.deny.matchedView, ...(write ? { face: "write" } : {}), ...(w.deny.readRow === true ? { readRow: true } : {}), ...(under ? { under: true } : {}) });
|
|
343
369
|
const through = deniedThrough(w.read, boundary);
|
|
344
|
-
const sentence = `Error (${tool}): ${core} ${write ? writeDenyRefusalNote() : DENY_REFUSAL_NOTE}${through !== undefined ? ` ${DENIED_THROUGH_NOTE[through]}` : ""}`;
|
|
370
|
+
const sentence = `Error (${tool}): ${core} ${write ? writeDenyRefusalNote() : under ? DENY_UNDER_REFUSAL_NOTE : DENY_REFUSAL_NOTE}${through !== undefined ? ` ${DENIED_THROUGH_NOTE[through]}` : ""}`;
|
|
345
371
|
return { sentence, echoed, ...(write ? {} : { details: violationDetails({ code: "read_path_denied", message: sentence, target, pattern: w.deny.pattern }) }) };
|
|
346
372
|
}
|
|
347
|
-
const account = findingAccount(fold, boundary);
|
|
373
|
+
const account = findingAccount(fold, boundary, false);
|
|
348
374
|
const sentence = `Error (${tool}): ${account}. ${BASH_READONLY_CONFINEMENT_NOTE}`;
|
|
349
375
|
return { sentence, details: findingDetails(fold.finding, paths) };
|
|
350
376
|
}
|
|
@@ -371,6 +397,8 @@ function writeDenyRefusalNote() {
|
|
|
371
397
|
const DENY_REFUSAL_NOTE = "The command was not run, and nothing was read. Paths a command names are checked against this list, as written and " +
|
|
372
398
|
"where they lead; a file it reaches without naming it, for example inside a folder it searches, is checked only where " +
|
|
373
399
|
`a deny rule covers that folder. ${DENY_OUTLET}`;
|
|
400
|
+
const DENY_UNDER_REFUSAL_NOTE = "The command was not run, and nothing was read. A search of a folder that holds none of the list's locations, or of files " +
|
|
401
|
+
`named one by one, is judged on its own. ${DENY_OUTLET}`;
|
|
374
402
|
function verdictOf(tool, seat, fold, judged, boundary) {
|
|
375
403
|
const redirectsOnly = fold.finding === "outside_roots" && fold.unestablished !== true && outsideFindingsAreRedirections(judged);
|
|
376
404
|
const disposition = decideShellRead(fold.finding, seat, { redirectsOnly, narrowedReadFace: fold.outsideOrUnresolved === true && boundary.face !== "open" });
|
|
@@ -393,7 +421,7 @@ function verdictOf(tool, seat, fold, judged, boundary) {
|
|
|
393
421
|
...by,
|
|
394
422
|
...writes,
|
|
395
423
|
...unestablished,
|
|
396
|
-
sentence: findingAccount(fold, boundary),
|
|
424
|
+
sentence: findingAccount(fold, boundary, true),
|
|
397
425
|
...((disposition === "mandated" && containment) || (disposition === "ordinary" && fold.finding === "unestablishable") ? { details: findingDetails(fold.finding, paths) } : {}),
|
|
398
426
|
...(grant !== undefined ? { readRootCandidate: { dir: grant.dir, ...(grant.covers !== undefined ? { covers: grant.covers } : {}), clearsThisAsk: true } } : {}),
|
|
399
427
|
};
|