@sema-agent/core 7.69.0 → 7.69.1
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 +583 -0
- package/dist/agents/repair-loop.js +6 -14
- package/dist/agents/subagent.js +2 -1
- package/dist/agents/verify.d.ts +1 -1
- package/dist/agents/verify.js +7 -1
- package/dist/brain/reasoning-request.d.ts +7 -0
- package/dist/brain/reasoning-request.js +6 -0
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/allow-entry.d.ts +5 -5
- package/dist/core/allow-entry.js +12 -6
- package/dist/core/ask-headline.d.ts +2 -2
- package/dist/core/ask-origin.d.ts +31 -31
- package/dist/core/ask-origin.js +20 -13
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +44 -62
- package/dist/core/auto-compaction.js +44 -103
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +11 -5
- package/dist/core/checkpoint-features.d.ts +1 -1
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-row-verdict.js +3 -0
- package/dist/core/checkpoint-store.d.ts +13 -2
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +24 -0
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +2 -0
- package/dist/core/context-edit.d.ts +32 -17
- package/dist/core/context-edit.js +28 -0
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/engine-attestation.d.ts +16 -0
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +14 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +18 -7
- package/dist/core/engine-version.js +1 -1
- package/dist/core/gate-outcome.d.ts +29 -2
- package/dist/core/gate-outcome.js +6 -0
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.js +9 -8
- package/dist/core/governance-codes.d.ts +9 -2
- package/dist/core/governance-codes.js +9 -0
- package/dist/core/locked-config.js +7 -3
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +108 -46
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +20 -3
- package/dist/core/memory-engine/layout.js +39 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/mods/session-compact.js +3 -3
- package/dist/core/mods/stations.d.ts +2 -0
- package/dist/core/mods/stations.js +2 -1
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +3 -0
- package/dist/core/peer-seat.js +3 -0
- package/dist/core/permission-rule-model.js +3 -2
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/runner/assemble-result.d.ts +5 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/compact-session.js +14 -9
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/continuation-gate.js +2 -1
- package/dist/core/runner/continues-from.d.ts +1 -1
- package/dist/core/runner/continues-from.js +1 -1
- package/dist/core/runner/contracts.d.ts +83 -31
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/derived-route-fallback.d.ts +2 -12
- package/dist/core/runner/derived-route-fallback.js +0 -6
- package/dist/core/runner/gate-exit.d.ts +2 -1
- package/dist/core/runner/gate-exit.js +4 -2
- package/dist/core/runner/git-status-frame.d.ts +2 -2
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +29 -2
- package/dist/core/runner/leg-receipt.js +37 -6
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +16 -2
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-advisor.d.ts +2 -0
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +3 -0
- package/dist/core/runner/prepare-artifact.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -8
- package/dist/core/runner/prepare-config-doors.js +15 -12
- package/dist/core/runner/prepare-context-lane.d.ts +25 -6
- package/dist/core/runner/prepare-context-lane.js +82 -27
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
- package/dist/core/runner/prepare-gate-stations.js +2 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
- package/dist/core/runner/prepare-hands-readface.js +41 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +51 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
- package/dist/core/runner/prepare-policy-chain.js +13 -2
- package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
- package/dist/core/runner/prepare-prompt-assembly.js +10 -4
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
- package/dist/core/runner/prepare-prompt-inputs.js +6 -7
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
- package/dist/core/runner/prepare-suspend-saga.js +3 -2
- package/dist/core/runner/prepare-task.js +59 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
- package/dist/core/runner/prepare-turn-wiring.js +8 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -1
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/role-resolution-table.d.ts +15 -10
- package/dist/core/runner/role-resolution-table.js +4 -5
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
- package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
- package/dist/core/runner/run-compaction-machinery.js +3 -39
- package/dist/core/runner/run-harness-handlers.js +4 -17
- package/dist/core/runner/run-identity-wiring.js +4 -1
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +34 -18
- package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
- package/dist/core/runner/run-settle-and-teardown.js +14 -22
- package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +5 -88
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +56 -26
- package/dist/core/runner/runtask.js +7 -7
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +3 -3
- package/dist/core/runner/side-call-account.d.ts +9 -1
- package/dist/core/runner/side-call-account.js +15 -4
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-table-view.d.ts +5 -9
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/write-protection-station.d.ts +5 -2
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +25 -27
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +47 -11
- package/dist/core/secret-env.js +65 -4
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.js +10 -9
- package/dist/core/shell-read-silence.d.ts +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/task-event.d.ts +32 -10
- package/dist/core/task-intake.d.ts +5 -3
- package/dist/core/task-intake.js +6 -2
- package/dist/core/task-result.d.ts +39 -0
- package/dist/core/task-spec-members.d.ts +3 -0
- package/dist/core/task-spec-members.js +2 -2
- package/dist/core/task-spec.d.ts +37 -20
- package/dist/core/tool-policy.d.ts +30 -18
- package/dist/core/tool-policy.js +44 -32
- package/dist/core/tool-roster.d.ts +21 -7
- package/dist/core/tool-roster.js +34 -6
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +27 -0
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/unc-spelling.d.ts +31 -0
- package/dist/core/unc-spelling.js +51 -0
- package/dist/core/wiring-manifest.d.ts +30 -3
- package/dist/core/wiring-manifest.js +10 -0
- package/dist/core/workflow-run-store-contract.js +22 -0
- package/dist/core/workflow-run-store.d.ts +17 -13
- package/dist/core/workflow-run-store.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +48 -98
- package/dist/engine/compaction/compaction.js +136 -216
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.js +17 -6
- package/dist/engine/harness/agent-harness.d.ts +19 -5
- package/dist/engine/harness/agent-harness.js +18 -7
- package/dist/engine/harness/types.d.ts +5 -7
- package/dist/engine/loop/agent-loop.d.ts +14 -1
- package/dist/engine/loop/agent-loop.js +31 -11
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
- package/dist/orchestration/workflow-park-adoption.js +195 -45
- package/dist/orchestration/workflow-types.d.ts +20 -0
- package/dist/orchestration/workflow-types.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -2
- package/dist/orchestration/workflow.js +10 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/events.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/catalog/sections.js +8 -0
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
- package/dist/prompt-assembly/turn-snapshot.js +6 -18
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +9 -0
- package/dist/prompts/default.js +4 -0
- package/dist/shell/lex.d.ts +75 -11
- package/dist/shell/lex.js +340 -76
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +19 -9
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +4 -4
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pdf.js +12 -4
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +160 -61
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +28 -5
- package/dist/tools/fs/safety.js +72 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +3 -0
- package/dist/tools/fs/shell-read-check.js +22 -4
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +32 -14
- package/dist/tools/fs/shell-read-judge.js +13 -5
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +8 -2
- package/dist/tools/fs/shell-read-plan.js +36 -22
- package/dist/tools/fs/shell-read-sourced.js +12 -4
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/scheduler-tools.d.ts +7 -17
- package/dist/tools/scheduler-tools.js +9 -85
- package/dist/tools/worktree.js +5 -4
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +47 -1
- package/wire-changes/core-stores-sql@7.68.6.json +39 -0
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.68.6.json +125 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.68.6.json +39 -0
- package/wire-changes/mods-kernel@7.69.1.json +39 -0
- package/wire-changes/primitives@7.68.6.json +39 -0
- package/wire-changes/primitives@7.69.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.6.json +39 -0
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
package/dist/tools/fs/safety.js
CHANGED
|
@@ -6,7 +6,7 @@ import { skipsRootsContainment } from "./containment-face.js";
|
|
|
6
6
|
import { sliceHeadSafe } from "../../core/surrogate-safe-slice.js";
|
|
7
7
|
import { fileArgPath, pathTargetValue, protectivePathTargetOf } from "../../core/tool-registry.js";
|
|
8
8
|
import { readPath } from "../../core/effective-path-target.js";
|
|
9
|
-
import { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isUncSpelling, isWinFormPath, nativeSepOf, normalizeAbsPathLexically, pathFamilyOf, rejoinMissingTail, stripWin32ExtendedPrefix, WIN_RESERVED_RE, } from "../../core/unc-spelling.js";
|
|
9
|
+
import { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isUncSpelling, isWinFormPath, nativeSepOf, normalizeAbsPathLexically, pathFamilyOf, rejoinMissingTail, stripWin32ExtendedPrefix, win32NamespacePrefixFolded, WIN_RESERVED_RE, } from "../../core/unc-spelling.js";
|
|
10
10
|
export { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isWinFormPath, normalizeAbsPathLexically, pathFamilyOf };
|
|
11
11
|
import { withGateTimeout, DEFAULT_GATE_AWAIT_TIMEOUT_MS } from "../../core/gate-bounded-await.js";
|
|
12
12
|
import { thrownText } from "../../core/thrown-value.js";
|
|
@@ -44,8 +44,35 @@ export function namesStandardInput(path) {
|
|
|
44
44
|
return k === "/dev/stdin" || k === "/dev/fd/0" || (k.startsWith("/proc/") && k.endsWith("/fd/0"));
|
|
45
45
|
}
|
|
46
46
|
const PROC_SENSITIVE_SUFFIXES = ["/environ", "/cmdline", "/auxv", "/maps", "/mem", "/stat"];
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const PROC_PROCESS_DIR = /^\/(?:proc\/(?:\d+|self|thread-self)|dev\/fd)\//;
|
|
48
|
+
export function isProcSensitiveFile(key) {
|
|
49
|
+
return PROC_PROCESS_DIR.test(key) && PROC_SENSITIVE_SUFFIXES.some((suf) => key.endsWith(suf));
|
|
50
|
+
}
|
|
51
|
+
const PROC_SENSITIVE_ROOT = /^\/(?:proc(?:\/(?:\d+|self|thread-self)(?:\/task(?:\/\d+)?)?)?)?$/;
|
|
52
|
+
export function holdsProcSensitiveFile(dir) {
|
|
53
|
+
return PROC_SENSITIVE_ROOT.test(dir);
|
|
54
|
+
}
|
|
55
|
+
const PROC_ROOT_LINK = /^\/proc\/(?:self|thread-self)\/root(?=\/|$)/;
|
|
56
|
+
const OWN_WORKDIR_LINK = /^\/proc\/(?:self|thread-self)\/cwd(?:\/(.*))?$/;
|
|
57
|
+
export function ownProcessSpelling(spelled) {
|
|
58
|
+
const { p, jumped } = behindOwnRootLinks(spelled);
|
|
59
|
+
const workdir = OWN_WORKDIR_LINK.exec(p);
|
|
60
|
+
if (workdir !== null)
|
|
61
|
+
return workdir[1] === undefined ? "." : `./${workdir[1]}`;
|
|
62
|
+
return jumped ? p : undefined;
|
|
63
|
+
}
|
|
64
|
+
function behindOwnRootLinks(spelled) {
|
|
65
|
+
let p = spelled.replace(/\/+/g, "/").replace(/\/\.(?=\/|$)/g, "");
|
|
66
|
+
let jumped = false;
|
|
67
|
+
while (PROC_ROOT_LINK.test(p))
|
|
68
|
+
[p, jumped] = [p.replace(PROC_ROOT_LINK, "") || "/", true];
|
|
69
|
+
return { p, jumped };
|
|
70
|
+
}
|
|
71
|
+
const OWN_PROCESS_LINK = /^\/(?:proc\/(?:self|thread-self)\/(?:task\/[^/]+\/(?:cwd|root|fd\/[^/]+)|fd\/[^/]+)|dev\/fd\/[^/]+)(?=\/|$)/;
|
|
72
|
+
export function belowOwnProcessLink(spelled, walks = false) {
|
|
73
|
+
const { p } = behindOwnRootLinks(spelled);
|
|
74
|
+
const link = OWN_PROCESS_LINK.exec(p);
|
|
75
|
+
return link !== null && (walks || /^\/[^/]/.test(p.slice(link[0].length)));
|
|
49
76
|
}
|
|
50
77
|
export function expandHomeTilde(p, home) {
|
|
51
78
|
if (p === "~")
|
|
@@ -228,8 +255,8 @@ export const WIN32_NAMESPACE_REFUSAL_TEXT = {
|
|
|
228
255
|
drive_relative: "is drive-relative (a drive letter with no separator after the colon), a location no tree can locate",
|
|
229
256
|
};
|
|
230
257
|
export function win32NamespaceScreen(spelled, family) {
|
|
231
|
-
if (family === "win"
|
|
232
|
-
spelled = spelled
|
|
258
|
+
if (family === "win")
|
|
259
|
+
spelled = win32NamespacePrefixFolded(spelled);
|
|
233
260
|
if (isWin32DeviceNamespacePath(spelled))
|
|
234
261
|
return { ok: false, refuse: "device_namespace" };
|
|
235
262
|
const mapped = stripWin32ExtendedPrefix(spelled);
|
|
@@ -321,8 +348,45 @@ export function carriesDotSegment(spelled, family) {
|
|
|
321
348
|
export function clipSpelling(spelled) {
|
|
322
349
|
return spelled.length > 512 ? `${spelled.slice(0, 512)}…` : spelled;
|
|
323
350
|
}
|
|
351
|
+
export function shellDriveSpellingOf(family, spelled) {
|
|
352
|
+
const lead = /^\/*/.exec(spelled)[0].length;
|
|
353
|
+
if (family !== "win" || lead === 0 || lead === 2 || spelled[lead] === "\\")
|
|
354
|
+
return undefined;
|
|
355
|
+
const folded = [];
|
|
356
|
+
const kept = [];
|
|
357
|
+
let leftTheDrive = false;
|
|
358
|
+
for (const seg of spelled.slice(lead).split(/[\\/]+/)) {
|
|
359
|
+
if (seg === "" || seg === ".")
|
|
360
|
+
continue;
|
|
361
|
+
kept.push(seg);
|
|
362
|
+
if (seg !== "..")
|
|
363
|
+
folded.push(seg);
|
|
364
|
+
else if (folded.length <= 1)
|
|
365
|
+
(leftTheDrive = true), folded.pop();
|
|
366
|
+
else
|
|
367
|
+
folded.pop();
|
|
368
|
+
}
|
|
369
|
+
const read = leftTheDrive ? folded : kept;
|
|
370
|
+
const drive = read[0];
|
|
371
|
+
return drive !== undefined && /^[A-Za-z]$/.test(drive) ? `${drive.toUpperCase()}:\\${read.slice(1).join("\\")}` : undefined;
|
|
372
|
+
}
|
|
373
|
+
export function shellAnchoredSpellingOf(family, anchored) {
|
|
374
|
+
const m = family === "win" ? /^([A-Za-z]):[\\/]([\s\S]*)$/.exec(anchored) : null;
|
|
375
|
+
if (m === null)
|
|
376
|
+
return undefined;
|
|
377
|
+
let depth = 0;
|
|
378
|
+
for (const seg of m[2].split(/[\\/]+/)) {
|
|
379
|
+
if (seg === "" || seg === ".")
|
|
380
|
+
continue;
|
|
381
|
+
if (seg !== "..")
|
|
382
|
+
depth++;
|
|
383
|
+
else if (--depth < 0)
|
|
384
|
+
return shellDriveSpellingOf(family, `/${m[1]}/${m[2]}`);
|
|
385
|
+
}
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
324
388
|
export function isShellRootedSpellingUnmapped(family, spelled) {
|
|
325
|
-
return family === "win" && (spelled.startsWith("/") || spelled.startsWith("\\"));
|
|
389
|
+
return family === "win" && (spelled.startsWith("/") || spelled.startsWith("\\")) && shellDriveSpellingOf(family, spelled) === undefined;
|
|
326
390
|
}
|
|
327
391
|
export function nativeUncSpellingOf(family, spelled) {
|
|
328
392
|
return family === "win" && isUncSpelling(spelled) ? `\\\\${spelled.slice(2).replace(/\//g, "\\")}` : spelled;
|
|
@@ -366,7 +430,7 @@ function within(rootCanonical, p) {
|
|
|
366
430
|
return true;
|
|
367
431
|
return pN.identity.startsWith(rootN.identity.endsWith(SEP) ? rootN.identity : rootN.identity + SEP);
|
|
368
432
|
}
|
|
369
|
-
export async function resolveKey(env, rootCanonical, path, signal, baseCwd, additionalRoots, exactFileReadExemption, readDeny, containmentFace) {
|
|
433
|
+
export async function resolveKey(env, rootCanonical, path, signal, baseCwd, additionalRoots, exactFileReadExemption, readDeny, containmentFace, outsideRemedy) {
|
|
370
434
|
const views = await readPath(env, path, baseCwd ?? rootCanonical, { root: rootCanonical, ...(baseCwd !== undefined ? { cwd: baseCwd } : {}) }, { intent: "resolve", views: readDeny !== undefined ? "chain" : "canonical" }, signal);
|
|
371
435
|
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.` };
|
|
372
436
|
if (!canon.ok)
|
|
@@ -421,7 +485,7 @@ export async function resolveKey(env, rootCanonical, path, signal, baseCwd, addi
|
|
|
421
485
|
ok: false,
|
|
422
486
|
violation: {
|
|
423
487
|
code: "path_not_in_root",
|
|
424
|
-
message: `path "${path}" ${key !== path ? `(canonical target: "${key}") ` : ""}resolves outside the allowed root${roots.length > 1 ? "s" : ""} (${roots.join(", ")}); access denied. ${PATH_NOT_IN_ROOT_ESCAPE_HINT}`,
|
|
488
|
+
message: `path "${path}" ${key !== path ? `(canonical target: "${key}") ` : ""}resolves outside the allowed root${roots.length > 1 ? "s" : ""} (${roots.join(", ")}); access denied. ${outsideRemedy ?? PATH_NOT_IN_ROOT_ESCAPE_HINT}`,
|
|
425
489
|
target: key,
|
|
426
490
|
roots,
|
|
427
491
|
},
|
|
@@ -564,9 +564,15 @@ export declare class BindingThread {
|
|
|
564
564
|
* (more questions, never fewer). */
|
|
565
565
|
private unreadableBy;
|
|
566
566
|
/** May segment `x` run before segment `e` runs (`x` being `e`: before a later run of it): `x` comes first in the text,
|
|
567
|
-
* `e` stands in a function body (the body runs at its call, after any segment, and may run again), or
|
|
568
|
-
*
|
|
567
|
+
* `e` stands in a function body (the body runs at its call, after any segment, and may run again), or `e` stands in a
|
|
568
|
+
* loop's body and `x` in that loop — its body (a later beat runs `x` again first) or its `done` (the loop's redirections
|
|
569
|
+
* are expanded before its first beat). */
|
|
569
570
|
private mayRunBefore;
|
|
571
|
+
/** Where each name is first bound, and where every name first is ({@link bindsBefore}). */
|
|
572
|
+
private firstBound?;
|
|
573
|
+
/** Does a segment that may run before segment `e` ({@link mayRunBefore}) bind the name — or every name (an `eval`, a call, a
|
|
574
|
+
* command the text does not settle)? The one order every reader that asks "may the text have rebound this name here" reads. */
|
|
575
|
+
bindsBefore(name: string, e: number): boolean;
|
|
570
576
|
/** Did the body certainly declare this name `local` before segment `at`: an earlier segment of the body, run on its own
|
|
571
577
|
* (no `&&` / `||`, no pipeline member or background job), in a block still open at `at`, whose declaration the walk
|
|
572
578
|
* APPLIED as certain — the shell ran its word as the builtin: no function of that name standing, no launcher, path or
|
|
@@ -544,6 +544,13 @@ function floorCombos(word, table, kept) {
|
|
|
544
544
|
let pastBound = false;
|
|
545
545
|
const own = [];
|
|
546
546
|
const transformed = word.pieces.some(transformsValue);
|
|
547
|
+
const ofName = (name, whole) => {
|
|
548
|
+
const state = table.stateOf(name);
|
|
549
|
+
const known = state !== "unknown" && whole ? state : undefined;
|
|
550
|
+
const floor = known === undefined ? table.floorOf(name) : NO_FLOOR;
|
|
551
|
+
pastBound ||= floor.pastBound;
|
|
552
|
+
return known !== undefined ? known.map(floorOf) : [...floor.values.filter((o) => o.held !== true), ...floor.values.filter((o) => o.held === true).slice(0, kept)];
|
|
553
|
+
};
|
|
547
554
|
for (const p of word.pieces) {
|
|
548
555
|
const e = p.expansion;
|
|
549
556
|
let options = [];
|
|
@@ -552,11 +559,10 @@ function floorCombos(word, table, kept) {
|
|
|
552
559
|
options = [{ spelled: p.literal }];
|
|
553
560
|
}
|
|
554
561
|
else if (e.kind === "parameter" && e.name !== undefined) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
options = known !== undefined ? known.map(floorOf) : [...floor.values.filter((o) => o.held !== true), ...floor.values.filter((o) => o.held === true).slice(0, kept)];
|
|
562
|
+
options = ofName(e.name, e.body === undefined || e.body === e.name);
|
|
563
|
+
}
|
|
564
|
+
else if (e.kind === "tilde") {
|
|
565
|
+
options = e.body === "~" ? ofName("HOME", true) : [{ spelled: e.body ?? "~" }];
|
|
560
566
|
}
|
|
561
567
|
if (transformed)
|
|
562
568
|
own.push(...options.map((o) => ({ ...o, piece: true })));
|
|
@@ -1551,7 +1557,20 @@ export class BindingThread {
|
|
|
1551
1557
|
mayRunBefore(x, e) {
|
|
1552
1558
|
if (x < e)
|
|
1553
1559
|
return true;
|
|
1554
|
-
return this.blocks[e].body !== undefined || [...this.loops].some(([head, end]) => head <= e &&
|
|
1560
|
+
return this.blocks[e].body !== undefined || [...this.loops].some(([head, end]) => head <= e && e < end && x <= end);
|
|
1561
|
+
}
|
|
1562
|
+
firstBound;
|
|
1563
|
+
bindsBefore(name, e) {
|
|
1564
|
+
const binds = (x) => x.all === "unknown" || x.bindings.some((b) => b.name === name);
|
|
1565
|
+
this.firstBound ??= { all: this.named.findIndex((x) => x.all === "unknown"), names: this.named.reduce((m, x, at) => { for (const b of x.bindings)
|
|
1566
|
+
if (!m.has(b.name))
|
|
1567
|
+
m.set(b.name, at); return m; }, new Map()) };
|
|
1568
|
+
const first = Math.min(...[this.firstBound.all, this.firstBound.names.get(name) ?? -1].filter((at) => at >= 0));
|
|
1569
|
+
if (!Number.isFinite(first))
|
|
1570
|
+
return false;
|
|
1571
|
+
if (first < e)
|
|
1572
|
+
return true;
|
|
1573
|
+
return this.blocks[e].body !== undefined || [...this.loops].some(([head, end]) => head <= e && e < end && this.named.slice(head, end + 1).some(binds));
|
|
1555
1574
|
}
|
|
1556
1575
|
declaredLocal(name, at, body) {
|
|
1557
1576
|
return this.localDeclarations.some((d) => d.body === body.id && d.name === name && d.at < at && this.heldThrough(d, at));
|
|
@@ -222,6 +222,9 @@ export interface ShellReadStationOptions {
|
|
|
222
222
|
* place to hear it. A deny refusal passes the literals its sentence quotes (`echoed`, the same mint as the sentence). The
|
|
223
223
|
* Runner's; absent outside one. */
|
|
224
224
|
readonly onAdmissionRefused?: (toolCallId: string, echoed?: readonly RefusalEcho[]) => void;
|
|
225
|
+
/** `false` ⇔ the leg grants no read root mid-run (it refuses reads outside its declared directories): the station's
|
|
226
|
+
* questions name no directory to add — a card offering one would offer what nothing grants. Absent ⇒ offered. */
|
|
227
|
+
readonly offersReadRootGrant?: false;
|
|
225
228
|
}
|
|
226
229
|
/** What a consumer hands {@link judgeShellRead}: the command as written, the environment whose filesystem
|
|
227
230
|
* answers where its words land (symlinks resolved, patterns expanded — a `NodeExecutionEnv` over a real
|
|
@@ -2,7 +2,7 @@ import { observeEnvironment } from "./shell-read-environment.js";
|
|
|
2
2
|
import { errorResult } from "../../core/tools.js";
|
|
3
3
|
import { BASH_READONLY_CONFINEMENT_NOTE, targetUnavailableCard, targetUnavailableSentence } from "./fs-shared.js";
|
|
4
4
|
import { envErrorDetail } from "./env-error-detail.js";
|
|
5
|
-
import { isAbsoluteForFamily, normalizeAbsPathLexically, pathFamilyOf, violationDetails, withinAnyRoot } from "./safety.js";
|
|
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
7
|
import { NOT_AUTO_ALLOWED, declinedProgramSentence } from "./bash-program-position.js";
|
|
8
8
|
import { bashClassifyDefaultAllow } from "./bash-readonly-classifier.js";
|
|
@@ -219,6 +219,12 @@ export function readStationMemberOf(call, members) {
|
|
|
219
219
|
return seatOf("fold.readStation", members, call);
|
|
220
220
|
}
|
|
221
221
|
const ADMISSION_MAX = 1024;
|
|
222
|
+
function withoutGrantOffer(v) {
|
|
223
|
+
if (v.disposition === "vouch" || v.readRootCandidate === undefined)
|
|
224
|
+
return v;
|
|
225
|
+
const { readRootCandidate: _offered, ...question } = v;
|
|
226
|
+
return question;
|
|
227
|
+
}
|
|
222
228
|
function shellCommandOf(args) {
|
|
223
229
|
const command = args?.command;
|
|
224
230
|
return typeof command === "string" ? command : undefined;
|
|
@@ -303,6 +309,17 @@ function refusalOf(tool, fold, boundary, paths) {
|
|
|
303
309
|
if (fold.finding === "target_unavailable")
|
|
304
310
|
return { sentence: targetUnavailableSentence(tool, fold.cause ?? envErrorDetail(undefined)), details: targetUnavailableCard() };
|
|
305
311
|
const w = fold.witness;
|
|
312
|
+
if (fold.finding === "deny_hit" && w?.processPrivate !== undefined) {
|
|
313
|
+
const spelled = w.read.candidate.spelled;
|
|
314
|
+
const matched = w.processPrivate.matchedView;
|
|
315
|
+
const walk = !isProcSensitiveFile(matched);
|
|
316
|
+
const named = normalizeAbsPathLexically(spelled);
|
|
317
|
+
const via = (walk ? holdsProcSensitiveFile(named) : isProcSensitiveFile(named)) ? undefined : matched;
|
|
318
|
+
const at = `"${fitMiddle(spelled, READ_DENY_SENTENCE_PART_MAX)}" ${via !== undefined ? `(canonical target: "${fitMiddle(via, READ_DENY_SENTENCE_PART_MAX)}") ` : ""}`;
|
|
319
|
+
const what = walk ? `searching below ${at}is refused: that tree holds processes' private state under /proc` : `reading ${at}is refused: it is a process's private state under /proc`;
|
|
320
|
+
const sentence = `Error (${tool}): ${what} (a process directory's environ, cmdline, auxv, maps, mem or stat — its environment, command line, auxiliary vector, memory map, memory and status figures), and the file read tools refuse ${walk ? "those files" : "the same file"}. This holds in every permission mode, and no approval or setting lifts it. The command was not run, and nothing was read.`;
|
|
321
|
+
return { sentence, echoed: [{ kind: "path", value: spelled, ...(via !== undefined ? { canonical: via } : {}) }] };
|
|
322
|
+
}
|
|
306
323
|
if (fold.finding === "deny_hit" && w?.deny !== undefined) {
|
|
307
324
|
const target = w.read.target ?? w.deny.matchedView;
|
|
308
325
|
const write = w.deny.face === "write";
|
|
@@ -340,7 +357,7 @@ const DENY_REFUSAL_NOTE = "The command was not run, and nothing was read. Paths
|
|
|
340
357
|
`a deny rule covers that folder. ${DENY_OUTLET}`;
|
|
341
358
|
function verdictOf(tool, seat, fold, judged, boundary) {
|
|
342
359
|
const redirectsOnly = fold.finding === "outside_roots" && fold.unestablished !== true && outsideFindingsAreRedirections(judged);
|
|
343
|
-
const disposition = decideShellRead(fold.finding, seat, { redirectsOnly, narrowedReadFace: fold.
|
|
360
|
+
const disposition = decideShellRead(fold.finding, seat, { redirectsOnly, narrowedReadFace: fold.outsideOrUnresolved === true && boundary.face !== "open" });
|
|
344
361
|
if (disposition === "vouch")
|
|
345
362
|
return { disposition, finding: "none" };
|
|
346
363
|
const paths = outsidePathsOf(judged);
|
|
@@ -499,9 +516,10 @@ export function createShellReadStation(opts) {
|
|
|
499
516
|
const run = await runShellReadStation(call.toolName, command, boundary, seat, readers, establisherFor(boundary.roots), opts.env, signal);
|
|
500
517
|
if (run.verdict.disposition !== "refuse" && callOpts.toolCallId !== undefined)
|
|
501
518
|
remember(callOpts.toolCallId, { toolName: member, boundary: run.boundary, established: run.established, command });
|
|
519
|
+
const verdict = opts.offersReadRootGrant === false ? withoutGrantOffer(run.verdict) : run.verdict;
|
|
502
520
|
if (boundary.unreadPartitions !== true)
|
|
503
|
-
return
|
|
504
|
-
return
|
|
521
|
+
return verdict;
|
|
522
|
+
return verdict.disposition === "vouch" ? unansweredOver(call.toolName, seat, "the rules this check stands on could not all be read", boundary, { rowsUnread: true }) : { ...verdict, rowsUnread: true };
|
|
505
523
|
})();
|
|
506
524
|
},
|
|
507
525
|
unanswered(call, cause) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { canonicalRootsOnce, isAbsence, observeEnvironment } from "./shell-read-environment.js";
|
|
2
|
-
import { anchorSpelling, normalizeAbsPathLexically, pathFamilyOf } from "./safety.js";
|
|
2
|
+
import { anchorSpelling, belowOwnProcessLink, normalizeAbsPathLexically, ownProcessSpelling, pathFamilyOf } from "./safety.js";
|
|
3
3
|
import { boundaryIsTheSandbox } from "../../core/remote-env.js";
|
|
4
|
-
import { resolveOperandSpellings } from "./bash-readonly-classifier.js";
|
|
4
|
+
import { resolveOperandSpellings, tildeNamesAnAccount } from "./bash-readonly-classifier.js";
|
|
5
5
|
import { judgedCandidatesOf, sedBackupNames } from "./shell-read-write-targets.js";
|
|
6
6
|
import { movedReads, withHomeViews } from "./shell-read-identity.js";
|
|
7
7
|
import { passesUnasked } from "./shell-read-device.js";
|
|
@@ -96,15 +96,28 @@ function basesFor(candidate, boundary) {
|
|
|
96
96
|
const bases = candidate.bases.length > 0 ? candidate.bases : [boundary.cwd ?? boundary.roots[0] ?? ""];
|
|
97
97
|
return candidate.repositoryTop !== undefined ? everyAncestor(bases) : bases;
|
|
98
98
|
}
|
|
99
|
+
const UNPLACED_WHY = { moved_through_own_cwd: "is read from a directory the command moved to through its own working directory link (/proc/self/cwd), which is not placed here", below_own_link: "goes on below a link of the program that reads it (a descriptor, /proc/self/fd/<n> or /dev/fd/<n>, or a thread's working directory, root or descriptor under /proc/self/task/<tid>), which leads wherever that program holds it: where it lands is not placed here" };
|
|
100
|
+
function placeOperand(base, spelled, homeDir, walks = false) {
|
|
101
|
+
const ownBase = base === "" ? undefined : ownProcessSpelling(base);
|
|
102
|
+
if (ownBase?.startsWith(".") === true)
|
|
103
|
+
return { unplaced: "moved_through_own_cwd", views: [resolveOperandSpellings(base, spelled, homeDir)?.folded ?? base] };
|
|
104
|
+
const at = (ownBase ?? base) === "" ? undefined : (ownBase ?? base);
|
|
105
|
+
const word = resolveOperandSpellings(at, spelled, homeDir);
|
|
106
|
+
const own = word === undefined ? undefined : ownProcessSpelling(word.spelled ?? word.folded);
|
|
107
|
+
const placed = own === undefined ? word : resolveOperandSpellings(at, own, homeDir);
|
|
108
|
+
if (placed !== undefined && belowOwnProcessLink(placed.spelled ?? placed.folded, walks))
|
|
109
|
+
return { unplaced: "below_own_link", views: [...new Set([placed.folded, ...(own !== undefined ? [word.folded] : [])])] };
|
|
110
|
+
return placed === undefined ? undefined : { word: placed, ...(own !== undefined ? { asWritten: word.folded } : {}) };
|
|
111
|
+
}
|
|
99
112
|
function placedSpellings(spelled, bases, homeDir) {
|
|
100
113
|
const out = [];
|
|
101
114
|
for (const base of bases) {
|
|
102
|
-
const at =
|
|
103
|
-
if (at === undefined)
|
|
115
|
+
const at = placeOperand(base, spelled, homeDir);
|
|
116
|
+
if (at === undefined || "unplaced" in at)
|
|
104
117
|
continue;
|
|
105
|
-
out.push(at.folded);
|
|
106
|
-
if (at.spelled !== undefined)
|
|
107
|
-
out.push(at.spelled);
|
|
118
|
+
out.push(at.word.folded);
|
|
119
|
+
if (at.word.spelled !== undefined)
|
|
120
|
+
out.push(at.word.spelled);
|
|
108
121
|
}
|
|
109
122
|
return out;
|
|
110
123
|
}
|
|
@@ -120,22 +133,27 @@ function lexicalReadsOf(candidate, boundary, placed) {
|
|
|
120
133
|
}
|
|
121
134
|
if (rewritten !== undefined)
|
|
122
135
|
return [{ candidate, established: "unestablishable", spellings: [...new Set([candidate.spelled, ...placedSpellings(candidate.spelled, bases, boundary.homeDir)])], cause: rewritten }];
|
|
136
|
+
const accountHome = candidate.face !== "write" && tildeNamesAnAccount(candidate.spelled) ? { unresolved: true } : {};
|
|
123
137
|
const out = [];
|
|
124
138
|
const seen = new Set();
|
|
125
139
|
for (const base of bases) {
|
|
126
|
-
const
|
|
127
|
-
|
|
140
|
+
const at = placeOperand(base, candidate.spelled, boundary.homeDir, candidate.provenance === "traversal_root");
|
|
141
|
+
const why = at !== undefined && "unplaced" in at ? at : undefined;
|
|
142
|
+
const placed = at !== undefined && !("unplaced" in at) ? at : undefined;
|
|
143
|
+
if (placed === undefined || placed.word.standIn === true) {
|
|
128
144
|
const key = `?${candidate.spelled}`;
|
|
129
145
|
if (!seen.has(key)) {
|
|
130
146
|
seen.add(key);
|
|
131
|
-
out.push({ candidate, established: "unestablishable", spellings: [candidate.spelled], cause: `"${candidate.raw}" cannot be placed against ${base === "" ? "no working directory" : `"${base}"`}
|
|
147
|
+
out.push({ candidate, established: "unestablishable", spellings: [...new Set([candidate.spelled, ...(why?.views ?? [])])], cause: why !== undefined ? `"${candidate.raw}" ${UNPLACED_WHY[why.unplaced]}` : `"${candidate.raw}" cannot be placed against ${base === "" ? "no working directory" : `"${base}"`}`, ...accountHome });
|
|
132
148
|
}
|
|
133
|
-
|
|
149
|
+
if (placed === undefined)
|
|
150
|
+
continue;
|
|
134
151
|
}
|
|
152
|
+
const sp = placed.word;
|
|
135
153
|
if (seen.has(sp.folded))
|
|
136
154
|
continue;
|
|
137
155
|
seen.add(sp.folded);
|
|
138
|
-
out.push({ candidate, established: "lexical", target: sp.folded, spellings: sp.spelled !== undefined ? [sp.folded, sp.spelled] : [sp.folded] });
|
|
156
|
+
out.push({ candidate, established: "lexical", target: sp.folded, spellings: sp.spelled !== undefined ? [sp.folded, sp.spelled] : [sp.folded], ...(placed.asWritten !== undefined ? { ancestorViews: [placed.asWritten] } : {}) });
|
|
139
157
|
}
|
|
140
158
|
return out;
|
|
141
159
|
}
|
|
@@ -276,6 +294,8 @@ function establishLegOver(seen, readRoots) {
|
|
|
276
294
|
};
|
|
277
295
|
const parentOf = (canonical) => normalizeAbsPathLexically(`${canonical}/..`);
|
|
278
296
|
const resolve = async (p, signal, writeTarget = false, linkHops = WRITE_LINK_HOPS) => {
|
|
297
|
+
if (ownProcessSpelling(p)?.startsWith(".") === true || belowOwnProcessLink(p))
|
|
298
|
+
return { value: p, exact: false };
|
|
279
299
|
const parts = p.split(SEP);
|
|
280
300
|
const first = parts.findIndex((seg) => seg === "..");
|
|
281
301
|
if (first < 0)
|
|
@@ -352,16 +372,18 @@ function establishLegOver(seen, readRoots) {
|
|
|
352
372
|
for (const dir of frontier) {
|
|
353
373
|
if (++dirsUsed > MAX_GLOB_DIRS)
|
|
354
374
|
return bounded(`"${p}" expands over more than ${MAX_GLOB_DIRS} directories, too many to enumerate to verify`);
|
|
375
|
+
if (belowOwnProcessLink(dir, true))
|
|
376
|
+
return { unverifiable: `"${dir}" is a link of the program that reads it (or below one), so what "${seg}" would expand to cannot be verified here` };
|
|
355
377
|
const canonDir = await resolve(dir, signal);
|
|
356
378
|
if (canonDir !== undefined && canonDir.missing === true)
|
|
357
379
|
continue;
|
|
358
380
|
if (canonDir !== undefined && !canonDir.exact)
|
|
359
|
-
return { unverifiable: `"${dir}" cannot be resolved to verify what "${seg}" would expand to
|
|
381
|
+
return { unverifiable: `"${dir}" cannot be resolved to verify what "${seg}" would expand to`, unresolved: true };
|
|
360
382
|
const listed = await env.listDir(canonDir?.value ?? dir, signal);
|
|
361
383
|
if (!listed.ok) {
|
|
362
384
|
if (isAbsence(listed.error.code))
|
|
363
385
|
continue;
|
|
364
|
-
return { unverifiable: `"${dir}" cannot be enumerated to verify what "${seg}" would expand to (${listed.error.code})
|
|
386
|
+
return { unverifiable: `"${dir}" cannot be enumerated to verify what "${seg}" would expand to (${listed.error.code})`, unresolved: true };
|
|
365
387
|
}
|
|
366
388
|
if (seg.startsWith(".")) {
|
|
367
389
|
for (const dot of [".", ".."])
|
|
@@ -403,7 +425,7 @@ function establishLegOver(seen, readRoots) {
|
|
|
403
425
|
return { value: joinUnder(parent.value, leaf), exact: parent.exact, ...(parent.missing !== undefined ? { missing: parent.missing } : {}) };
|
|
404
426
|
};
|
|
405
427
|
const canonicalReadOf = async (candidate, spelling, spellings, established, origin, canonicalKnown, signal, seat = "landing") => {
|
|
406
|
-
const real = canonicalKnown !== undefined ? { value: canonicalKnown, exact: true } : seat === "entry" ? await entryOf(spelling, signal) : await resolve(spelling, signal, candidate.face === "write");
|
|
428
|
+
const real = canonicalKnown !== undefined ? { value: canonicalKnown, exact: true } : candidate.provenance === "traversal_root" && belowOwnProcessLink(spelling, true) ? { value: spelling, exact: false } : seat === "entry" ? await entryOf(spelling, signal) : await resolve(spelling, signal, candidate.face === "write");
|
|
407
429
|
if (real === undefined) {
|
|
408
430
|
if (resolverIsAuthoritative)
|
|
409
431
|
return { candidate, established: "unestablishable", spellings, ...(origin !== undefined ? { origin } : {}), cause: `"${spelling}" cannot be resolved to verify where it reads`, unresolved: true };
|
|
@@ -418,10 +440,10 @@ function establishLegOver(seen, readRoots) {
|
|
|
418
440
|
const followedName = async (spelled, base, homeDir, signal) => {
|
|
419
441
|
let name = spelled;
|
|
420
442
|
for (let hop = 0; hop <= WRITE_LINK_HOPS; hop++) {
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
443
|
+
const placed = placeOperand(base, name, homeDir);
|
|
444
|
+
if (placed === undefined || "unplaced" in placed || placed.word.standIn === true)
|
|
423
445
|
return undefined;
|
|
424
|
-
const walked =
|
|
446
|
+
const walked = placed.word.spelled ?? placed.word.folded;
|
|
425
447
|
if (TRAILING_SEP.test(walked))
|
|
426
448
|
return name;
|
|
427
449
|
const parts = walked.split(SEP);
|
|
@@ -460,11 +482,12 @@ function establishLegOver(seen, readRoots) {
|
|
|
460
482
|
continue;
|
|
461
483
|
}
|
|
462
484
|
for (const backup of sedBackupNames(name, suffix)) {
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
485
|
+
const placed = placeOperand(base, backup, boundary.homeDir);
|
|
486
|
+
if (placed === undefined || "unplaced" in placed || placed.word.standIn === true) {
|
|
465
487
|
out.push(...unfollowed(`"${backup}" cannot be placed against "${base}"`));
|
|
466
488
|
continue;
|
|
467
489
|
}
|
|
490
|
+
const at = placed.word;
|
|
468
491
|
const spellings = at.spelled !== undefined ? [at.folded, at.spelled] : [at.folded];
|
|
469
492
|
const derived = name !== operand.spelled ? { derivedSpellings: spellings } : {};
|
|
470
493
|
for (const seat of j.seats ?? ["landing"])
|
|
@@ -547,32 +570,39 @@ function establishLegOver(seen, readRoots) {
|
|
|
547
570
|
out.push(writtenAt(lexical, writtenSeats, writtenSeats.written.includes("landing") ? "landing" : "entry"));
|
|
548
571
|
continue;
|
|
549
572
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
573
|
+
try {
|
|
574
|
+
const folded = lexical.target;
|
|
575
|
+
const spellings = lexical.spellings;
|
|
576
|
+
const walked = spellings.find((s) => s !== folded) ?? folded;
|
|
577
|
+
const viewed = (r) => (lexical.ancestorViews === undefined ? r : { ...r, ancestorViews: lexical.ancestorViews });
|
|
578
|
+
if (candidate.expands === "glob") {
|
|
579
|
+
let matched = false;
|
|
580
|
+
for (const p of candidate.pattern === undefined ? spellings : lexicalReadsOf({ ...candidate, spelled: candidate.pattern }, boundary, placed)[i]?.spellings ?? spellings) {
|
|
581
|
+
const expanded = await expandGlobCandidate(p, roots, signal);
|
|
582
|
+
if (expanded !== undefined && "unverifiable" in expanded) {
|
|
583
|
+
out.push(viewed({ candidate, established: "unestablishable", spellings, origin: folded, cause: expanded.unverifiable, ...(expanded.unresolved === true ? { unresolved: true } : {}) }));
|
|
584
|
+
matched = true;
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (expanded !== undefined && expanded.paths.length > 0) {
|
|
588
|
+
matched = true;
|
|
589
|
+
for (const t of expanded.paths)
|
|
590
|
+
for (const read of await atSeats(t, [t, folded], "expansion", folded, expanded.canonical.get(t)))
|
|
591
|
+
await land(viewed(read));
|
|
592
|
+
}
|
|
567
593
|
}
|
|
594
|
+
if (!matched || candidate.pattern !== undefined)
|
|
595
|
+
for (const read of await atSeats(walked, spellings, "canonical", undefined, undefined))
|
|
596
|
+
await land(viewed(read));
|
|
597
|
+
continue;
|
|
568
598
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
599
|
+
for (const read of await atSeats(walked, spellings, "canonical", undefined, undefined))
|
|
600
|
+
await land(viewed(read));
|
|
601
|
+
}
|
|
602
|
+
catch (e) {
|
|
603
|
+
if (resolveOperandSpellings(readRoots[0], candidate.spelled, boundary.homeDir)?.standIn !== true || signal?.aborted === true)
|
|
604
|
+
throw e;
|
|
573
605
|
}
|
|
574
|
-
for (const read of await atSeats(walked, spellings, "canonical", undefined, undefined))
|
|
575
|
-
await land(read);
|
|
576
606
|
}
|
|
577
607
|
}
|
|
578
608
|
return out;
|
|
@@ -70,7 +70,9 @@ export declare function dispositionOfCell(cell: ShellReadCell, context?: ShellRe
|
|
|
70
70
|
* THE decision table — total over findings × seats; no cell is n/a. Row by row:
|
|
71
71
|
* · `deny_hit` — refused on every seat, for a spelling the station can establish: a deny row is a floor
|
|
72
72
|
* no root grant and no approval moves. A spelling the station cannot establish is not a deny hit (it is
|
|
73
|
-
* the `unestablishable` row) — the floor holds what it can place, and says so rather than guessing.
|
|
73
|
+
* the `unestablishable` row) — the floor holds what it can place, and says so rather than guessing. A read
|
|
74
|
+
* of a process-private /proc file, or a tree walk rooted where such files are, is this row too, on no deny row
|
|
75
|
+
* ({@link ReadFinding.processPrivate}).
|
|
74
76
|
* · `outside_roots` — asked where a person can be asked (the full shell), refused where none can (the
|
|
75
77
|
* read-only face has no approval channel; a rewrite that leaves the roots after approval was seen by
|
|
76
78
|
* nobody). The full shell's ask is MANDATED, except for a command whose every containment finding is an OUTPUT
|
|
@@ -81,13 +83,20 @@ export declare function dispositionOfCell(cell: ShellReadCell, context?: ShellRe
|
|
|
81
83
|
* rules, @18567915). A command that also reads outside the roots, or writes a program operand there (`tee`, `cp`, …),
|
|
82
84
|
* keeps the mandate.
|
|
83
85
|
* · `unestablishable` — the floor could not say where the command reads, so it is not vouched anywhere: asked
|
|
84
|
-
* where a person can be asked (the full shell), refused where none can be asked.
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
86
|
+
* where a person can be asked (the full shell), refused where none can be asked. One line divides the full shell's cell. A
|
|
87
|
+
* read whose path the station does not SEE — the path is only a value or program text (a variable whose value the text does
|
|
88
|
+
* not hold, a substitution's output, an interpreter's inline program, a lost working directory, a re-entered shell), or sits
|
|
89
|
+
* in text the lexer does not read — and a written target alone are the ORDINARY ask on either read face: the reference
|
|
90
|
+
* implementation's plain permission ask (CC
|
|
89
91
|
* 2.1.296 `sR` (cli296.js:242691) @13116941, reason `other`), which a whole-tool allow (`N9` (cli296.js:249675) @18717070), bypass (`$pn` (cli296.js:249675) @18716980)
|
|
90
|
-
* and the auto-mode classifier release and a prefix allow does not
|
|
92
|
+
* and the auto-mode classifier release and a prefix allow does not: the engine does not know where such a command reads,
|
|
93
|
+
* which is no finding that it reads outside. The cell's NARROWED reading (the `roots` face, the engine default: the
|
|
94
|
+
* deployment asked to be asked) — the MANDATED ask no automatic lane answers — is for a read the station can ASK THE
|
|
95
|
+
* ENVIRONMENT about: the path is a word of the command and where it lands the environment answers — a word placed outside the
|
|
96
|
+
* roots, kept even where the fold does not let it win (in a re-entered or printed text), and a placed word whose landing the
|
|
97
|
+
* environment left unresolved ({@link EstablishedRead.unresolved}: a lookup that could not resolve it, or a `~user` word,
|
|
98
|
+
* which only the account database answers), the environment's answer missing as it is for `unanswered`
|
|
99
|
+
* ({@link ShellReadFold.outsideOrUnresolved}).
|
|
91
100
|
* · `declined` — the one deliberate fail-open of this table: the scan could not read the program bash
|
|
92
101
|
* will run, or the operands arrive on a stream. On the full shell it is an ORDINARY ask — an answerer
|
|
93
102
|
* may settle it, and an out-of-root read hidden inside such a command is then not asked again. The
|
|
@@ -177,8 +186,9 @@ export type RowDisposition<F extends ShellReadFinding> = CellWords<(typeof SHELL
|
|
|
177
186
|
export interface ShellReadCellContext {
|
|
178
187
|
/** Every containment finding is an output redirection outside the write roots (a cell's `redirect` reading). Absent ⇒ no. */
|
|
179
188
|
readonly redirectsOnly?: boolean;
|
|
180
|
-
/** The question was raised under a NARROWED (`roots`) read face
|
|
181
|
-
*
|
|
189
|
+
/** The question was raised under a NARROWED (`roots`) read face about a command holding a word placed outside the roots or a
|
|
190
|
+
* read the environment left unresolved ({@link ShellReadFold.outsideOrUnresolved}); `false` for the open face and for a
|
|
191
|
+
* command whose unplaced words are the text's own or written targets alone. Absent ⇒ narrowed, the engine default. */
|
|
182
192
|
readonly narrowedReadFace?: boolean;
|
|
183
193
|
}
|
|
184
194
|
/** Every disposition the table gives `finding` — on any seat, under any form of the question; empty for a word outside
|
|
@@ -283,7 +293,8 @@ export interface EstablishedRead {
|
|
|
283
293
|
/** Why the candidate could not be established. */
|
|
284
294
|
readonly cause?: string;
|
|
285
295
|
/** The candidate's spelling WAS placed and the environment could not resolve where it leads (the whole chain unanswered by
|
|
286
|
-
* a resolver that declares itself authoritative,
|
|
296
|
+
* a resolver that declares itself authoritative, a component it could not follow, or the directory a pattern expands in that
|
|
297
|
+
* it could not resolve or list; for a READ, also a `~user` word, which only the account database places) — the reading's
|
|
287
298
|
* `target_unresolved` fact, as opposed to a text the station cannot read (a rewritten word, an unsettled working
|
|
288
299
|
* directory). Present only on an `unestablishable` read. (That the environment gave no answer is the establishment's
|
|
289
300
|
* `incomplete`, which makes the command `unanswered` whether or not a candidate carries this mark.) */
|
|
@@ -310,6 +321,11 @@ export interface ReadFinding {
|
|
|
310
321
|
readonly face?: "write";
|
|
311
322
|
readonly readRow?: true;
|
|
312
323
|
};
|
|
324
|
+
/** A `deny_hit` on no row: the read's target is a process-private /proc file (`isProcSensitiveFile`, safety.ts — the set the
|
|
325
|
+
* file read tools refuse), or a tree walk's root holds such files (`holdsProcSensitiveFile`); the view it was matched on. */
|
|
326
|
+
readonly processPrivate?: {
|
|
327
|
+
readonly matchedView: string;
|
|
328
|
+
};
|
|
313
329
|
readonly containment: "inside" | "outside" | "open" | "unknown";
|
|
314
330
|
}
|
|
315
331
|
/**
|
|
@@ -414,10 +430,12 @@ export interface ShellReadFold {
|
|
|
414
430
|
readonly cause?: string;
|
|
415
431
|
/** Some read of the text could not be established (an `unestablishable`, `unanswered` or `declined` finding anywhere, winning or not). */
|
|
416
432
|
readonly unestablished?: true;
|
|
417
|
-
/** Some
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
|
|
433
|
+
/** Some word anywhere — in a re-entered or printed text too, which vouch for nothing but still name what they name — is one the
|
|
434
|
+
* station PLACED outside the roots, or a READ whose landing the ENVIRONMENT could not resolve ({@link EstablishedRead.unresolved},
|
|
435
|
+
* a `~user` word among them). A path the station does not see — a value, program text, text the lexer does not read (a
|
|
436
|
+
* rewritten word, a substitution, a lost working directory, a re-entered shell text, a parameter's default text) — is
|
|
437
|
+
* neither. The cell of the row reads it with the read face in force ({@link decideShellRead}). */
|
|
438
|
+
readonly outsideOrUnresolved?: true;
|
|
421
439
|
}
|
|
422
440
|
/**
|
|
423
441
|
* Fold a judged plan to ONE finding by {@link SHELL_READ_FINDING_RANK}, over every segment and every nested
|