@sema-agent/core 7.61.0 → 7.63.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 +840 -0
- package/dist/agents/cascade.d.ts +11 -3
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-session-drain.js +13 -3
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.d.ts +6 -1
- package/dist/agents/subagent.js +143 -58
- package/dist/agents/suspend-guard.d.ts +38 -16
- package/dist/agents/suspend-guard.js +9 -4
- package/dist/agents/verify.js +4 -3
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-queries.d.ts +47 -4
- package/dist/core/checkpoint-queries.js +36 -16
- package/dist/core/checkpoint-requirements.d.ts +12 -5
- package/dist/core/checkpoint-requirements.js +11 -5
- package/dist/core/checkpoint-row-verdict.d.ts +110 -0
- package/dist/core/checkpoint-row-verdict.js +245 -0
- package/dist/core/checkpoint-store.d.ts +76 -753
- package/dist/core/checkpoint-store.js +83 -144
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/engine-attestation.d.ts +1 -1
- package/dist/core/engine-notice.d.ts +38 -7
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/gate-fold.js +2 -2
- package/dist/core/git-worktree-env.d.ts +62 -3
- package/dist/core/git-worktree-env.js +91 -30
- package/dist/core/governance-codes.d.ts +9 -3
- package/dist/core/governance-codes.js +16 -3
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +1 -1
- package/dist/core/locked-config.d.ts +2 -2
- package/dist/core/mcp-host-seat.js +6 -1
- package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +73 -10
- package/dist/core/memory-engine/consolidation.js +167 -11
- package/dist/core/memory-engine/data-plane.d.ts +8 -4
- package/dist/core/memory-engine/data-plane.js +11 -6
- package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
- package/dist/core/memory-engine/delegation-settlement.js +53 -59
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +9 -5
- package/dist/core/memory-engine/engine.d.ts +98 -35
- package/dist/core/memory-engine/engine.js +477 -380
- package/dist/core/memory-engine/entry-scan.d.ts +8 -0
- package/dist/core/memory-engine/entry-scan.js +3 -0
- package/dist/core/memory-engine/file-backend.d.ts +29 -3
- package/dist/core/memory-engine/file-backend.js +66 -35
- package/dist/core/memory-engine/index.d.ts +7 -7
- package/dist/core/memory-engine/index.js +6 -6
- package/dist/core/memory-engine/landing-admission.d.ts +5 -3
- package/dist/core/memory-engine/landing-admission.js +3 -3
- package/dist/core/memory-engine/layout.d.ts +121 -45
- package/dist/core/memory-engine/layout.js +252 -102
- package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
- package/dist/core/memory-engine/memory-backend-contract.js +320 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
- package/dist/core/memory-engine/memory-deployment.js +26 -12
- package/dist/core/memory-engine/scope-contract.d.ts +52 -11
- package/dist/core/memory-engine/scope-contract.js +68 -19
- package/dist/core/memory-engine/session-write-home.d.ts +3 -1
- package/dist/core/memory-engine/session-write-home.js +1 -1
- package/dist/core/memory-engine/sync-client.d.ts +3 -1
- package/dist/core/memory-engine/sync-client.js +7 -0
- package/dist/core/memory-engine/sync-report.d.ts +3 -2
- package/dist/core/memory-engine/sync-report.js +6 -2
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +10 -10
- package/dist/core/memory-engine/types.d.ts +118 -19
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +1 -1
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +32 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +13 -10
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +4 -1
- package/dist/core/mods/session-append.js +7 -0
- package/dist/core/mods/session-receive.js +12 -15
- package/dist/core/mods/stations.d.ts +70 -6
- package/dist/core/mods/stations.js +144 -1
- package/dist/core/own-property-receipt.d.ts +7 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/park-selfcheck.js +2 -2
- package/dist/core/pause-registry.d.ts +2 -0
- package/dist/core/pause-registry.js +3 -0
- package/dist/core/permission-rule-consent.d.ts +10 -3
- package/dist/core/permission-rule-consent.js +37 -24
- package/dist/core/permission-rule-store.d.ts +35 -1
- package/dist/core/permission-rule-store.js +27 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/compact-session.js +5 -2
- package/dist/core/runner/contracts.d.ts +36 -17
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/gate-exit.js +2 -2
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
- package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +2 -1
- package/dist/core/runner/permission-rule-lanes.js +2 -2
- package/dist/core/runner/person-path-rows.d.ts +23 -3
- package/dist/core/runner/person-path-rows.js +31 -4
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +3 -4
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
- package/dist/core/runner/prepare-hands-readface.js +32 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
- package/dist/core/runner/prepare-memory-engine-session.js +4 -4
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +28 -20
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-task.js +22 -16
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +3 -3
- package/dist/core/runner/resume-admission.js +6 -3
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +11 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +4 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +3 -2
- package/dist/core/runner/run-leg.js +25 -8
- package/dist/core/runner/run-settle-and-teardown.js +6 -4
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-turn-boundary.js +7 -4
- package/dist/core/runner/runtask.js +6 -6
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-steer-verb.js +8 -0
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/turn-attachments.d.ts +5 -0
- package/dist/core/runner/turn-attachments.js +1 -1
- package/dist/core/runner-deps.d.ts +8 -4
- package/dist/core/secret-env.d.ts +9 -6
- package/dist/core/secret-env.js +41 -22
- package/dist/core/session-checkout.d.ts +108 -0
- package/dist/core/session-checkout.js +485 -0
- package/dist/core/session-store.d.ts +13 -5
- package/dist/core/session-store.js +28 -4
- package/dist/core/session.d.ts +29 -5
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
- package/dist/core/store-contracts/session-store-contract.js +61 -8
- package/dist/core/task-event.d.ts +28 -1
- package/dist/core/task-notification.d.ts +9 -1
- package/dist/core/task-notification.js +8 -1
- package/dist/core/task-registry-agent.d.ts +40 -8
- package/dist/core/task-registry-agent.js +57 -24
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry-workflow.js +4 -3
- package/dist/core/task-registry.d.ts +27 -10
- package/dist/core/task-registry.js +19 -13
- package/dist/core/task-result.d.ts +5 -5
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +21 -1
- package/dist/core/terminal-cause.d.ts +6 -6
- package/dist/core/tool-face.d.ts +6 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-policy.d.ts +16 -13
- package/dist/core/tool-policy.js +11 -10
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +12 -5
- package/dist/engine/harness/types.d.ts +77 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.d.ts +24 -1
- package/dist/engine/session/session.js +46 -2
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/index.d.ts +16 -12
- package/dist/index.js +11 -8
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/orchestration/run-workflow-tool.d.ts +7 -1
- package/dist/orchestration/run-workflow-tool.js +28 -11
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -8
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +7 -6
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +2 -9
- package/dist/stores/file/index.js +2 -4
- package/dist/stores/file/session-store.d.ts +13 -7
- package/dist/stores/file/session-store.js +42 -18
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +10 -10
- package/dist/tools/fs/program-read-model.d.ts +34 -10
- package/dist/tools/fs/program-read-model.js +37 -7
- package/dist/tools/fs/program-read-model.rows.js +13 -2
- package/dist/tools/fs/read-deny.d.ts +13 -1
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/removal-targets.js +5 -5
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +1 -1
- package/dist/tools/fs/shell-read-argv.d.ts +11 -2
- package/dist/tools/fs/shell-read-argv.js +45 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
- package/dist/tools/fs/shell-read-bindings.js +153 -69
- package/dist/tools/fs/shell-read-brace.d.ts +18 -0
- package/dist/tools/fs/shell-read-brace.js +79 -0
- package/dist/tools/fs/shell-read-check.js +29 -11
- package/dist/tools/fs/shell-read-establish.js +43 -22
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-judge.d.ts +11 -0
- package/dist/tools/fs/shell-read-judge.js +3 -3
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +18 -0
- package/dist/tools/fs/shell-read-plan.js +217 -104
- package/dist/tools/fs/shell-read-start.d.ts +76 -13
- package/dist/tools/fs/shell-read-start.js +97 -17
- package/dist/tools/fs/shell-read-word.d.ts +10 -0
- package/dist/tools/fs/shell-read-word.js +9 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +54 -14
- package/dist/tools/fs/shell-read-workdir.js +103 -19
- package/dist/tools/fs/shell-read-write-targets.js +13 -8
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +7 -35
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +93 -43
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/credential-vocabulary.d.ts +0 -176
- package/dist/core/credential-vocabulary.js +0 -190
- package/dist/core/redaction-passes.d.ts +0 -82
- package/dist/core/redaction-passes.js +0 -377
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -35,6 +35,8 @@ const file = (language) => ({ kind: "program-file", language });
|
|
|
35
35
|
const WALKS = { walks: true };
|
|
36
36
|
const REBASES = { rebases: true };
|
|
37
37
|
const SWITCH = { arity: 0 };
|
|
38
|
+
const SWITCH_NONE = { arity: 0, effect: "none" };
|
|
39
|
+
const SWITCH_WRITES = { arity: 0, effect: "writes" };
|
|
38
40
|
const QUERY = { arity: 0, mode: "queries" };
|
|
39
41
|
const val = (value, extra = {}) => ({ arity: 1, ...(value !== undefined ? { value } : {}), ...extra });
|
|
40
42
|
const optional = (value) => ({ arity: "attached", ...(value !== undefined ? { value } : {}) });
|
|
@@ -312,7 +314,7 @@ function interpreterGrammar(language, g) {
|
|
|
312
314
|
}
|
|
313
315
|
const interpreter = (key, language, g, program, stdinWhenUnnamed, extra = {}, departures) => ({
|
|
314
316
|
key,
|
|
315
|
-
|
|
317
|
+
spellings: ["versioned"],
|
|
316
318
|
grammars: departures === undefined ? [interpreterGrammar(language, g)] : implementations(interpreterGrammar(language, g), departures.gnu, departures.bsd),
|
|
317
319
|
...(program === "none" ? {} : { operands: { positional: program === "file" ? [file(language)] : program === "text" ? [text(language)] : [undefined, text(language)] } }),
|
|
318
320
|
delivery: { stdinWhenUnnamed },
|
|
@@ -656,6 +658,10 @@ const writerRows = [
|
|
|
656
658
|
{ key: "tee", grammars: [], operands: { rest: WRITE_THROUGH, dash: "file" }, witness: BINARY },
|
|
657
659
|
{ key: "cp", grammars: copyGrammars(true, COPY_DESTINATION), operands: { rest: COPY_SOURCE, last: COPY_DESTINATION, dash: "file" }, witness: BINARY },
|
|
658
660
|
{ key: "mv", grammars: copyGrammars(false, MOVE_DESTINATION), operands: { rest: MOVE_SOURCE, last: MOVE_DESTINATION, dash: "file" }, witness: BINARY },
|
|
661
|
+
{ key: "truncate", grammars: implementations(grammar({ c: SWITCH_NONE, o: SWITCH_NONE, r: val(READ, { effect: "none" }), s: val(LABEL, { effect: "none" }) }, { "no-create": SWITCH_NONE, "io-blocks": SWITCH_NONE, reference: val(READ, { effect: "none" }), size: val(LABEL, { effect: "none" }), ...BANNERS }), { afterFirstOperand: "options" }, { lacks: ["-o", "--no-create", "--io-blocks", "--reference", "--size", "--help", "--version"], afterFirstOperand: "operands" }), operands: { rest: WRITE, dash: "file" }, witness: BINARY },
|
|
662
|
+
{ key: "dd", grammars: implementations(grammar({}, { ...BANNERS }), {}, { lacks: ["--help", "--version"] }), operands: { keyed: { if: READ, of: WRITE_THROUGH } }, witness: BINARY },
|
|
663
|
+
{ key: "install", grammars: implementations(grammar({ b: SWITCH_WRITES, c: SWITCH_NONE, C: SWITCH_NONE, d: SWITCH_WRITES, D: SWITCH_NONE, g: val(LABEL, { effect: "none" }), m: val(LABEL, { effect: "none" }), o: val(LABEL, { effect: "none" }), p: SWITCH_NONE, s: SWITCH, v: SWITCH_NONE, t: val(MOVE_DESTINATION, { fillsLast: true }), S: val(LABEL, { effect: "writes" }), T: SWITCH_NONE }, { backup: { arity: "attached", value: LABEL, effect: "writes" }, compare: SWITCH_NONE, directory: SWITCH_WRITES, group: val(LABEL, { effect: "none" }), mode: val(LABEL, { effect: "none" }), owner: val(LABEL, { effect: "none" }), "preserve-timestamps": SWITCH_NONE, strip: SWITCH, suffix: val(LABEL, { effect: "writes" }), "target-directory": val(MOVE_DESTINATION, { fillsLast: true }), "no-target-directory": SWITCH_NONE, verbose: SWITCH_NONE, ...BANNERS }), { afterFirstOperand: "options" }, { lacks: ["-t", "--backup", "--compare", "--directory", "--group", "--mode", "--owner", "--preserve-timestamps", "--strip", "--suffix", "--target-directory", "--no-target-directory", "--verbose", "--help", "--version"], reads: { "-S": SWITCH_NONE, "-T": val(LABEL, { effect: "none" }), "-D": val(LABEL, { effect: "none" }) }, afterFirstOperand: "operands" }), operands: { rest: READ, last: MOVE_DESTINATION, dash: "file" }, witness: BINARY },
|
|
664
|
+
{ key: "ln", grammars: implementations(grammar({ b: SWITCH_WRITES, d: SWITCH_NONE, F: SWITCH, f: SWITCH_NONE, i: SWITCH_NONE, L: SWITCH_NONE, n: SWITCH_NONE, P: SWITCH_NONE, r: SWITCH_NONE, s: SWITCH_NONE, v: SWITCH_NONE, h: SWITCH_NONE, w: SWITCH_NONE, t: val(MOVE_DESTINATION, { fillsLast: true }), S: val(LABEL, { effect: "writes" }), T: SWITCH_NONE }, { backup: { arity: "attached", value: LABEL, effect: "writes" }, directory: SWITCH_NONE, force: SWITCH_NONE, interactive: SWITCH_NONE, logical: SWITCH_NONE, "no-dereference": SWITCH_NONE, physical: SWITCH_NONE, relative: SWITCH_NONE, symbolic: SWITCH_NONE, suffix: val(LABEL, { effect: "writes" }), "target-directory": val(MOVE_DESTINATION, { fillsLast: true }), "no-target-directory": SWITCH_NONE, verbose: SWITCH_NONE, ...BANNERS }), { lacks: ["-h", "-w"], afterFirstOperand: "options" }, { lacks: ["-b", "-d", "-r", "-t", "-S", "-T", "--backup", "--directory", "--force", "--interactive", "--logical", "--no-dereference", "--physical", "--relative", "--symbolic", "--suffix", "--target-directory", "--no-target-directory", "--verbose", "--help", "--version"], afterFirstOperand: "operands" }), operands: { rest: NAMES, last: MOVE_DESTINATION, loneOperand: "into-working-directory", dash: "file" }, witness: BINARY },
|
|
659
665
|
];
|
|
660
666
|
const stdinReaders = [
|
|
661
667
|
{ key: "cat", grammars: [], operands: { stdinBelow: 1 }, witness: BINARY },
|
|
@@ -665,6 +671,11 @@ const stdinReaders = [
|
|
|
665
671
|
const SYNTAX = { declared: "shell syntax, not a program: read by the lexer" };
|
|
666
672
|
const block = (key, g = []) => ({ key, grammars: g, syntax: "block", witness: SYNTAX });
|
|
667
673
|
const BLOCK_GRAMMARS = { "[[": [grammar({ v: val(BINDS_NAME) })] };
|
|
674
|
+
const GNU_COREUTILS = new Set([
|
|
675
|
+
"[", "basename", "cat", "chroot", "comm", "cp", "cut", "date", "dd", "dirname", "du", "echo", "env", "expr", "false", "groups", "head", "id", "install", "ln", "ls", "mkdir", "mv",
|
|
676
|
+
"nice", "nohup", "nproc", "printf", "pwd", "rm", "rmdir", "seq", "sleep", "stdbuf", "tail", "tee", "test", "timeout", "touch", "tr", "true", "truncate", "uname", "wc", "whoami",
|
|
677
|
+
]);
|
|
678
|
+
const spelledByGnuBuilds = (row) => (GNU_COREUTILS.has(row.key) ? { ...row, spellings: [...(row.spellings ?? []), "gnu-prefixed"] } : row);
|
|
668
679
|
export const PROGRAM_ROWS = [
|
|
669
680
|
head, tail, cut, grepRow("grep"), grepRow("egrep"), grepRow("fgrep"), diff, cmp, sed, date, tar, find, curl,
|
|
670
681
|
ls, namesWalker("du"), rg, namesWalker("tree"), ag, ack,
|
|
@@ -710,4 +721,4 @@ export const PROGRAM_ROWS = [
|
|
|
710
721
|
shellRow("fc", "history", BUILTIN_ONLY, [grammar({ ...switches("nr"), s: { arity: 0, effect: "executes" }, ...switches("l", { mode: "banner" }), e: val(COMMAND, { executesWhenValue: "-" }) }, {}, { afterFirstOperand: "operands" })]),
|
|
711
722
|
...codeBodyRows,
|
|
712
723
|
...[...shellWordsOf("block")].map((k) => block(k, BLOCK_GRAMMARS[k])),
|
|
713
|
-
];
|
|
724
|
+
].map(spelledByGnuBuilds);
|
|
@@ -167,6 +167,10 @@ export interface WriteDenyMatcher {
|
|
|
167
167
|
}): ReadDenyHit | null;
|
|
168
168
|
/** The table ONE call judges with ({@link ReadDenyMatcher.forCall}). */
|
|
169
169
|
forCall?(toolCallId: string | undefined): WriteDenyMatcher;
|
|
170
|
+
/** Is the row a hit named (its rule text) a row that guards the READ face too — a `Read(…)` rule on the write face, whose
|
|
171
|
+
* paths are not written because their reads are denied — rather than a row of the write face alone? The refusal's sentence
|
|
172
|
+
* says which of the two refused ({@link readDenySentence}'s `readRow`). Absent ⇒ no row of this table guards reads. */
|
|
173
|
+
guardsReads?(pattern: string): boolean;
|
|
170
174
|
}
|
|
171
175
|
/** Compile the write face over the rule rows (the rows not on it are dropped here, once). */
|
|
172
176
|
export declare function compileWriteDeny(rules?: readonly PathRuleDenyRow[]): WriteDenyMatcher;
|
|
@@ -288,6 +292,8 @@ export declare function sensitivePathDenyList(pattern: string | readonly string[
|
|
|
288
292
|
export declare const SENSITIVE_PATH_DENY_SCOPE = "This list guards credential-class paths and applies regardless of the containment roots.";
|
|
289
293
|
/** The write face's reach, in the same place of the sentence: a write deny row holds under every root and every mode. */
|
|
290
294
|
export declare const WRITE_DENY_SCOPE = "A write deny row holds regardless of the containment roots and of the permission mode.";
|
|
295
|
+
/** The same place, for a write refused by a row of the READ face (a `Read(…)` rule): it holds on writes as it holds on reads. */
|
|
296
|
+
export declare const READ_ROW_WRITE_SCOPE = "A read deny row holds on writes too, regardless of the containment roots and of the permission mode.";
|
|
291
297
|
/**
|
|
292
298
|
* THE deny refusal sentence — five segments, one mint, every read face: the ACTION, the ABSOLUTE target as the
|
|
293
299
|
* caller spelled it (with its canonical target in parentheses when the two differ), the DISPOSITION (a deny row is
|
|
@@ -296,7 +302,9 @@ export declare const WRITE_DENY_SCOPE = "A write deny row holds regardless of th
|
|
|
296
302
|
* when that is the requested SPELLING rather than the target — under a symlink or case alias the two strings
|
|
297
303
|
* differ, only one matches, and naming the other sends the reader chasing a path the pattern does not match.
|
|
298
304
|
* A face prefixes its own `Error (<tool>): ` and may append its own closing clause; the finding itself is
|
|
299
|
-
* never re-spelled.
|
|
305
|
+
* never re-spelled. One variant, by the row's family and not by the face alone: a write refused by a `Read(…)` row
|
|
306
|
+
* ({@link WriteDenyMatcher.guardsReads}) says the path's reads are denied, where a row of the write face alone says the
|
|
307
|
+
* write list.
|
|
300
308
|
*/
|
|
301
309
|
export declare function readDenySentence(finding: {
|
|
302
310
|
readonly action?: string;
|
|
@@ -306,6 +314,10 @@ export declare function readDenySentence(finding: {
|
|
|
306
314
|
readonly matchedView?: string;
|
|
307
315
|
/** The table face that refused (default `read`): a write-face hit names the write list and its reach, and writes. */
|
|
308
316
|
readonly face?: DenyFace;
|
|
317
|
+
/** On the write face: the row that refused is a row of the READ face too ({@link WriteDenyMatcher.guardsReads}) — a
|
|
318
|
+
* `Read(…)` rule, not a rule about writing. The sentence then says the path's reads are denied, which is why it is not
|
|
319
|
+
* written, instead of calling a read row a write deny row. */
|
|
320
|
+
readonly readRow?: true;
|
|
309
321
|
}): string;
|
|
310
322
|
/** The per-part budget of the deny sentence — the gate's own card-account cap, not a second number. */
|
|
311
323
|
export declare const READ_DENY_SENTENCE_PART_MAX = 200;
|
|
@@ -150,12 +150,13 @@ function denyTargetViews(canonicalKey, lexicalView, opts) {
|
|
|
150
150
|
}
|
|
151
151
|
export function compileWriteDeny(rules = []) {
|
|
152
152
|
const ruleRows = rules.filter((r) => r.faces.includes("write"));
|
|
153
|
+
const readRows = new Set(ruleRows.filter((r) => r.faces.includes("read")).map((r) => r.rule));
|
|
153
154
|
const rows = ruleRows.map(ruleGuardRow);
|
|
154
155
|
const matchPath = (path) => {
|
|
155
156
|
const hit = denyTableHit(rows, { views: [{ path, kind: "lexical" }] });
|
|
156
157
|
return hit === null ? null : { pattern: hit.pattern };
|
|
157
158
|
};
|
|
158
|
-
return { face: "write", ruleRows, matchPath, matchTarget: (canonicalKey, lexicalView, opts) => denyTableHit(rows, denyTargetViews(canonicalKey, lexicalView, opts)) };
|
|
159
|
+
return { face: "write", ruleRows, matchPath, matchTarget: (canonicalKey, lexicalView, opts) => denyTableHit(rows, denyTargetViews(canonicalKey, lexicalView, opts)), guardsReads: (pattern) => readRows.has(pattern) };
|
|
159
160
|
}
|
|
160
161
|
export function seatForCall(seat, toolCallId) {
|
|
161
162
|
const forCall = seat?.forCall;
|
|
@@ -185,12 +186,19 @@ export function sensitivePathDenyList(pattern, face = "read") {
|
|
|
185
186
|
}
|
|
186
187
|
export const SENSITIVE_PATH_DENY_SCOPE = "This list guards credential-class paths and applies regardless of the containment roots.";
|
|
187
188
|
export const WRITE_DENY_SCOPE = "A write deny row holds regardless of the containment roots and of the permission mode.";
|
|
189
|
+
export const READ_ROW_WRITE_SCOPE = "A read deny row holds on writes too, regardless of the containment roots and of the permission mode.";
|
|
188
190
|
export function readDenySentence(finding) {
|
|
189
191
|
const write = finding.face === "write";
|
|
190
192
|
const canonicalNote = finding.canonical !== undefined && finding.canonical !== finding.target ? `(canonical target: "${fitMiddle(finding.canonical, READ_DENY_SENTENCE_PART_MAX)}") ` : "";
|
|
191
193
|
const lexicalHit = finding.matchedView !== undefined && finding.matchedView !== (finding.canonical ?? finding.target);
|
|
194
|
+
const frame = `${finding.action ?? (write ? "writing" : "reading")} "${fitMiddle(finding.target, READ_DENY_SENTENCE_PART_MAX)}" ${canonicalNote}is refused:`;
|
|
195
|
+
const pattern = fitMiddle(finding.pattern, READ_DENY_SENTENCE_PART_MAX);
|
|
196
|
+
if (write && finding.readRow === true) {
|
|
197
|
+
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`;
|
|
198
|
+
return `${frame} ${reaches} — a path whose reads are denied is not written either. ${READ_ROW_WRITE_SCOPE}`;
|
|
199
|
+
}
|
|
192
200
|
const judged = lexicalHit ? `the requested path's spelling ("${fitMiddle(finding.matchedView, READ_DENY_SENTENCE_PART_MAX)}") matches` : "the target matches";
|
|
193
|
-
return `${
|
|
201
|
+
return `${frame} ${judged} ${sensitivePathDenyList(pattern, write ? "write" : "read")}. ${write ? WRITE_DENY_SCOPE : SENSITIVE_PATH_DENY_SCOPE}`;
|
|
194
202
|
}
|
|
195
203
|
export const READ_DENY_SENTENCE_PART_MAX = PROBE_REASON_MAX;
|
|
196
204
|
export function fitMiddle(s, budget) {
|
|
@@ -105,10 +105,10 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
105
105
|
const removed = new Set(writeReadings(row, spelled).flatMap((r) => r.written.map((w) => w.at)));
|
|
106
106
|
const options = new Set(args.filter((_, at) => !removed.has(at)).map((w) => w.raw));
|
|
107
107
|
const forced = selectsOptions(row, spelled, received.shellChooses, TRAVERSAL, FORCED);
|
|
108
|
-
const rm =
|
|
108
|
+
const rm = row.key === "rm" || !named ? { recursive: selectsOptions(row, spelled, received.shellChooses, TRAVERSAL) } : undefined;
|
|
109
109
|
if (forced && segment.reentry === "argv")
|
|
110
110
|
out.push({ guard: "unverifiable_delete", program: removal.program, operand: segment.text.trim(), source: "stream" });
|
|
111
|
-
const relocated = enclosingRelocated || readProgramPosition(segment.argv).
|
|
111
|
+
const relocated = enclosingRelocated || readProgramPosition(segment.argv).baseMovedAt.length > 0;
|
|
112
112
|
for (const read of established.reads.get(segment) ?? []) {
|
|
113
113
|
if ((named && read.candidate.face !== "write") || read.candidate.provenance === "program_path" || options.has(read.candidate.raw))
|
|
114
114
|
continue;
|
|
@@ -133,7 +133,7 @@ export function removalFindingsOf(established, seat, safeRoots = KNOWN_SAFE_ROOT
|
|
|
133
133
|
out.push({ guard: "unverifiable_shell_text", program, text: script, source: "produced" });
|
|
134
134
|
if (programUnread(segment))
|
|
135
135
|
out.push({ guard: "unverifiable_shell_text", program: segment.launcherChain[0] ?? segment.text.trim(), text: segment.text.trim(), source: "position" });
|
|
136
|
-
const handedRelocated = enclosingRelocated || readProgramPosition(segment.argv).
|
|
136
|
+
const handedRelocated = enclosingRelocated || readProgramPosition(segment.argv).baseMovedAt.length > 0;
|
|
137
137
|
for (const nested of segment.nested) {
|
|
138
138
|
if (unreadPlan(nested)) {
|
|
139
139
|
out.push({ guard: "unverifiable_shell_text", program: program ?? segment.text.trim(), text: segment.text.trim(), source: "unread" });
|
|
@@ -181,8 +181,8 @@ const programNameUnsettled = (s) => s.verb !== undefined && s.reads.some((c) =>
|
|
|
181
181
|
const RM_REMOVAL_ROW = programRow("rm");
|
|
182
182
|
function removalProgramOf(s) {
|
|
183
183
|
const basename = s.verb?.basename;
|
|
184
|
-
const row = basename !== undefined
|
|
185
|
-
if (row !== undefined)
|
|
184
|
+
const row = basename !== undefined ? programRow(basename) : undefined;
|
|
185
|
+
if (row !== undefined && REMOVAL_COMMAND_SET.has(row.key))
|
|
186
186
|
return { program: basename, row, named: true };
|
|
187
187
|
return programNameUnsettled(s) && RM_REMOVAL_ROW !== undefined ? { program: s.verb.name, row: RM_REMOVAL_ROW, named: false } : undefined;
|
|
188
188
|
}
|
|
@@ -447,6 +447,8 @@ export declare function resolveKey(env: ExecutionEnv, rootCanonical: string, pat
|
|
|
447
447
|
pattern: string;
|
|
448
448
|
matchedView?: string;
|
|
449
449
|
} | null;
|
|
450
|
+
/** The write face's {@link import("./read-deny.js").WriteDenyMatcher.guardsReads}: the row a hit named also guards reads. */
|
|
451
|
+
guardsReads?(pattern: string): boolean;
|
|
450
452
|
}, containmentFace?: "open" | "roots"): Promise<{
|
|
451
453
|
ok: true;
|
|
452
454
|
key: string;
|
package/dist/tools/fs/safety.js
CHANGED
|
@@ -470,7 +470,7 @@ export async function resolveKey(env, rootCanonical, path, signal, baseCwd, addi
|
|
|
470
470
|
ok: false,
|
|
471
471
|
violation: {
|
|
472
472
|
code: write ? "write_path_denied" : "read_path_denied",
|
|
473
|
-
message: readDenySentence({ target: path, canonical: key, pattern: hit.pattern, ...(hit.matchedView !== undefined ? { matchedView: hit.matchedView } : {}), ...(write ? { face: "write" } : {}) }),
|
|
473
|
+
message: readDenySentence({ target: path, canonical: key, pattern: hit.pattern, ...(hit.matchedView !== undefined ? { matchedView: hit.matchedView } : {}), ...(write ? { face: "write", ...(readDeny.guardsReads?.(hit.pattern) === true ? { readRow: true } : {}) } : {}) }),
|
|
474
474
|
target: key,
|
|
475
475
|
pattern: hit.pattern,
|
|
476
476
|
},
|
|
@@ -10,10 +10,12 @@ import { type Read } from "./shell-read-word.js";
|
|
|
10
10
|
import { type BindingTable, type FloorValue } from "./shell-read-bindings.js";
|
|
11
11
|
import { subcommandOf, type ArgRole, type ProgramRow } from "./program-read-model.js";
|
|
12
12
|
import type { ReadCandidate, ReadCandidateProvenance } from "./shell-read-plan.js";
|
|
13
|
+
import { type ObjectPathRepository } from "./shell-read-object-path.js";
|
|
13
14
|
/** A candidate before the threading fills its bases. `floors`: the spellings its word's names left for the deny judge
|
|
14
|
-
* alone (a word whose names are unknown here). */
|
|
15
|
+
* alone (a word whose names are unknown here); `repository`: an object path's, what the program's options say of it. */
|
|
15
16
|
export type Bare = Omit<ReadCandidate, "bases"> & {
|
|
16
17
|
readonly floors?: readonly FloorValue[];
|
|
18
|
+
readonly repository?: ObjectPathRepository;
|
|
17
19
|
};
|
|
18
20
|
/** What reading a segment's words found beside its candidates. */
|
|
19
21
|
export interface WordContext {
|
|
@@ -60,8 +62,15 @@ export declare function roleReads(r: Read, provenance: ReadCandidateProvenance,
|
|
|
60
62
|
* NAME held>` + value, so the whole value is not in the text — but the text it appends IS, and an unset or empty
|
|
61
63
|
* NAME makes it the whole value, so it is a candidate too. A value that is a substitution is the nested plan
|
|
62
64
|
* its body already is, never a candidate of its own text (its placeholder is not a path).
|
|
65
|
+
*
|
|
66
|
+
* WHEN the shell expands the value is `expanded`: an ARGUMENT's (a program's, a launcher's or a declaration builtin's
|
|
67
|
+
* `NAME=value` word) is expanded with every other word of the command line, before anything of it runs — through the names
|
|
68
|
+
* the line holds (the table), as {@link readsOf} reads every word: `T=x; dd of="$T"` hands `dd` the value `x`. The shell's
|
|
69
|
+
* OWN assignments expand left to right, each after the ones before it took effect (`A=x B="$A" cmd` binds `B` to `x`) —
|
|
70
|
+
* what the names at the segment's start do not hold — so their value is read as written: `"shell"` (a prefix of a command,
|
|
71
|
+
* or a word in front of where a program would be), `"statement"` (a segment of assignments alone, which BINDS).
|
|
63
72
|
*/
|
|
64
|
-
export declare function pushAssignment(reads: Bare[], w: LexedWord, provenance: ReadCandidateProvenance): void;
|
|
73
|
+
export declare function pushAssignment(reads: Bare[], w: LexedWord, provenance: ReadCandidateProvenance, expanded: BindingTable | "shell" | "statement"): void;
|
|
65
74
|
/** Every word of a segment whose program's grammar this parser does not model, from `from` onward: option
|
|
66
75
|
* payloads and path-shaped option words included, the launcher chain's own words excluded, a program declared
|
|
67
76
|
* to open no path operand handing only the environment words in front of it. A program with NO row is read the
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { literalTildeSpelling } from "../../shell/lex.js";
|
|
2
|
-
import { expandsOf, partPattern, readOfText, rewritten } from "./shell-read-word.js";
|
|
3
|
-
import { arithmeticSubstitutions } from "./shell-read-bindings.js";
|
|
2
|
+
import { expandsOf, globMark, partPattern, readOfText, receivedWordOf, rewritten, spellingOf } from "./shell-read-word.js";
|
|
3
|
+
import { arithmeticSubstitutions, bindsArrayElement, judgedSpellingOf, wordValues } from "./shell-read-bindings.js";
|
|
4
4
|
import { argvProgramOf, attachedOptionPayloads, isPathShapedToken } from "./bash-readonly-classifier.js";
|
|
5
5
|
import { assignmentArgumentsAreNotPaths, deliversOperands, evaluatesOperands, messageWords, moduleTailOf, objectPathsOf, opensNoOperand, programRow, programTextMayOpen, programTextOpensOf, readArgs, readOptionSlot, selectsContentsTraversal, slotValueCandidates, subcommandOf, valuesAreLiteral, walksCwdWithoutOperand, wordsReadBySomeImplementations, } from "./program-read-model.js";
|
|
6
|
+
import { objectPathRepositoryOf } from "./shell-read-object-path.js";
|
|
7
|
+
function inRepository(reads, from, row, globals) {
|
|
8
|
+
let repository;
|
|
9
|
+
for (let i = from; i < reads.length; i++)
|
|
10
|
+
if (reads[i].provenance === "object_path")
|
|
11
|
+
reads[i] = { ...reads[i], repository: (repository ??= objectPathRepositoryOf(row, globals)) };
|
|
12
|
+
}
|
|
6
13
|
export function pathSubcommandOf(row, args) {
|
|
7
14
|
const sub = subcommandOf(row, args);
|
|
8
15
|
return sub !== undefined && (sub.row.operands !== undefined || sub.row.traversal !== undefined) ? sub : undefined;
|
|
@@ -162,30 +169,35 @@ function programTextReads(r, provenance, text, language, ctx) {
|
|
|
162
169
|
ctx.programText ??= programTextSentence(language);
|
|
163
170
|
return [{ ...bare(r, provenance, text), denyOnly: true }];
|
|
164
171
|
}
|
|
165
|
-
export function pushAssignment(reads, w, provenance) {
|
|
172
|
+
export function pushAssignment(reads, w, provenance, expanded) {
|
|
166
173
|
const a = w.assignment;
|
|
167
|
-
if (a === undefined || a.form === "compound")
|
|
174
|
+
if (a === undefined || a.form === "compound" || (expanded === "statement" && bindsArrayElement(a)))
|
|
168
175
|
return;
|
|
169
176
|
const expandsTilde = a.value.expansions.some((p) => p.expansion?.kind === "tilde");
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
const held = typeof expanded === "object" && !expandsTilde ? wordValues(a.value, expanded, true) : undefined;
|
|
178
|
+
const texts = Array.isArray(held) ? held.map((v) => ({ value: spellingOf(v), expands: globMark(v.glob === true), pattern: judgedSpellingOf(v) })) : undefined;
|
|
179
|
+
for (const t of texts ?? [{ value: expandsTilde ? a.value.folded : literalTildeSpelling(a.value.folded), expands: expandsOf(w), pattern: undefined }]) {
|
|
180
|
+
const value = t.value;
|
|
181
|
+
const settled = a.op === "=" && !expandsTilde;
|
|
182
|
+
const named = value === "" || (a.op === "+=" ? expandsTilde : !settled) ? undefined : value;
|
|
183
|
+
if (value === "" && settled)
|
|
184
|
+
continue;
|
|
185
|
+
const v = { spelled: value, raw: a.bare ? a.value.raw : w.raw, provenance };
|
|
186
|
+
const unsettled = provenance !== "env_assignment" ? { ...v, expands: "unresolvable" } : v.spelled.startsWith("~") && !v.spelled.includes(":") ? { ...v, expands: expandsOf(a.value) } : undefined;
|
|
187
|
+
if (!settled && unsettled !== undefined)
|
|
188
|
+
reads.push(unsettled);
|
|
189
|
+
const substitutes = texts === undefined && a.value.expansions.some((p) => p.expansion?.kind === "command" || p.expansion?.kind === "process" || p.expansion?.kind === "arithmetic");
|
|
190
|
+
const pattern = named === undefined ? undefined : texts !== undefined ? t.pattern : partPattern({ folded: w.folded, ...(w.judged !== undefined ? { pattern: w.judged } : {}) }, named);
|
|
191
|
+
if (named !== undefined && !substitutes)
|
|
192
|
+
reads.push({ spelled: named, raw: w.raw, provenance, expands: t.expands, ...(pattern !== undefined ? { pattern } : {}) });
|
|
193
|
+
const list = texts === undefined ? a.value.folded : value;
|
|
194
|
+
if (list.includes(":"))
|
|
195
|
+
for (const m of list.split(":"))
|
|
196
|
+
if (m !== "") {
|
|
197
|
+
const r = readOfText(m);
|
|
198
|
+
reads.push({ spelled: r.folded, raw: r.raw, provenance, expands: r.expands, denyOnly: true });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
189
201
|
}
|
|
190
202
|
export function unlistedWords(reads, toks, from, launcherIndices, provenance, ctx, program) {
|
|
191
203
|
const argv = program !== undefined ? { program: program.basename, from: program.index } : argvProgramOf(toks.map((r) => r.word));
|
|
@@ -217,9 +229,9 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
|
|
|
217
229
|
expanding.add(j);
|
|
218
230
|
reads.push(bare(toks[j], j === argvStart ? "program_path" : provenance));
|
|
219
231
|
if (j < argvStart)
|
|
220
|
-
pushAssignment(reads, toks[j].word, "env_assignment");
|
|
232
|
+
pushAssignment(reads, toks[j].word, "env_assignment", ctx.table);
|
|
221
233
|
else if (j > argvStart && !declaredNotPaths)
|
|
222
|
-
pushAssignment(reads, toks[j].word, provenance);
|
|
234
|
+
pushAssignment(reads, toks[j].word, provenance, ctx.table);
|
|
223
235
|
}
|
|
224
236
|
const gathered = new RootsGathered();
|
|
225
237
|
let base = new OperandBase();
|
|
@@ -250,7 +262,7 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
|
|
|
250
262
|
continue;
|
|
251
263
|
}
|
|
252
264
|
reads.push(bare(r, provenance));
|
|
253
|
-
pushAssignment(reads, r
|
|
265
|
+
pushAssignment(reads, receivedWordOf(r), "env_assignment", ctx.table);
|
|
254
266
|
}
|
|
255
267
|
}
|
|
256
268
|
else if (!noPathOperands) {
|
|
@@ -266,7 +278,7 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
|
|
|
266
278
|
else {
|
|
267
279
|
reads.push(bare(programWord, "program_path"));
|
|
268
280
|
if (!declaredNotPaths)
|
|
269
|
-
pushAssignment(reads, programWord
|
|
281
|
+
pushAssignment(reads, receivedWordOf(programWord), provenance, ctx.table);
|
|
270
282
|
}
|
|
271
283
|
}
|
|
272
284
|
}
|
|
@@ -300,7 +312,9 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
|
|
|
300
312
|
gathered.restart();
|
|
301
313
|
base = new OperandBase();
|
|
302
314
|
unsettledAt.length = 0;
|
|
315
|
+
const subFrom = reads.length;
|
|
303
316
|
walk(sub.row, walkFrom, toks.length, true);
|
|
317
|
+
inRepository(reads, subFrom, slotRow, toks.slice(argvStart + 1, argvStart + 1 + sub.at));
|
|
304
318
|
}
|
|
305
319
|
else
|
|
306
320
|
walk(slotRow, argvStart + 1, toks.length, "program-text");
|
|
@@ -371,7 +385,7 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
|
|
|
371
385
|
speculate(start, r.word.assignment !== undefined ? "whole" : "containment");
|
|
372
386
|
const values = reads.length;
|
|
373
387
|
if (!declaredNotPaths && e.slot === undefined)
|
|
374
|
-
pushAssignment(reads, r
|
|
388
|
+
pushAssignment(reads, receivedWordOf(r), provenance, ctx.table);
|
|
375
389
|
speculate(values, "containment");
|
|
376
390
|
return;
|
|
377
391
|
}
|
|
@@ -413,7 +427,9 @@ export function listedVerbCandidates(name, argReads, reads, ctx) {
|
|
|
413
427
|
const tail = moduleTailOf(row, args);
|
|
414
428
|
if (sub !== undefined) {
|
|
415
429
|
walkListed(row, argReads, 0, sub.at, expanding, reads, ctx, false);
|
|
430
|
+
const from = reads.length;
|
|
416
431
|
walkListed(sub.row, argReads, sub.at + 1, argReads.length, expanding, reads, ctx, sub.relocated);
|
|
432
|
+
inRepository(reads, from, row, argReads.slice(0, sub.at));
|
|
417
433
|
}
|
|
418
434
|
else
|
|
419
435
|
walkListed(row, argReads, 0, tail !== undefined ? tail.from : argReads.length, expanding, reads, ctx, false);
|
|
@@ -506,7 +522,7 @@ function walkListed(row, argReads, first, last, expanding, reads, ctx, relocated
|
|
|
506
522
|
if (slice[e.at].expands !== false)
|
|
507
523
|
unsettledAt.push({ at: e.at, folded: t });
|
|
508
524
|
if (row?.operands?.assignmentArguments !== "not-paths")
|
|
509
|
-
pushAssignment(reads, slice[e.at]
|
|
525
|
+
pushAssignment(reads, receivedWordOf(slice[e.at]), "operand", ctx.table);
|
|
510
526
|
break;
|
|
511
527
|
}
|
|
512
528
|
}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* The shell's own variables (the ones bash sets, holds read-only or evaluates itself) are never bound from text.
|
|
28
28
|
*/
|
|
29
29
|
import { type LexedRedirect, type LexedSegment, type LexedToken, type LexedWord } from "../../shell/lex.js";
|
|
30
|
+
import { readProgramPosition } from "./bash-program-position.js";
|
|
30
31
|
import { type DeclaredAttribute } from "./program-read-model.js";
|
|
31
32
|
import { type BuiltinState } from "./shell-read-builtins.js";
|
|
32
33
|
/** A value a name may hold — the text the program receives ({@link spelled}: what a shell re-parsing it reads), literal
|
|
@@ -181,14 +182,16 @@ export interface SegmentShape {
|
|
|
181
182
|
}
|
|
182
183
|
/** The argv projection of a lexed segment: structure that names nothing that runs here is dropped — a subshell
|
|
183
184
|
* parenthesis, a bare `{` / `}`, a function definition's head (`NAME ()`, and `function NAME [()]` with a name of
|
|
184
|
-
* any spelling, {@link dropDefinitionHeads}), a `case`
|
|
185
|
+
* any spelling, {@link dropDefinitionHeads}), a `case` command's own words ({@link caseWordsOf}), and the block words
|
|
185
186
|
* at the head. */
|
|
186
187
|
export interface ProjectedSegment extends SegmentShape {
|
|
187
188
|
readonly argv: readonly LexedWord[];
|
|
188
189
|
readonly redirects: readonly LexedRedirect[];
|
|
189
190
|
readonly grouped: boolean;
|
|
190
191
|
}
|
|
191
|
-
|
|
192
|
+
/** The argv projection of every segment of one text ({@link projectSegment}): a `case` command's own words are read across
|
|
193
|
+
* the segments ({@link caseWordsOf}). */
|
|
194
|
+
export declare function projectSegments(segments: readonly LexedSegment[]): ProjectedSegment[];
|
|
192
195
|
/** A function definition's head names nothing that runs here and is dropped from a segment's tokens, in place:
|
|
193
196
|
* `NAME ( )` ({@link isDefinitionName}), and `function NAME [( )]` — a bare `function` at command position, a name of any
|
|
194
197
|
* spelling. The lexer puts the body's compound command back at command position after the head, so a definition
|
|
@@ -240,6 +243,16 @@ export declare function loopListHeadAt(argv: readonly LexedWord[]): number | und
|
|
|
240
243
|
* ({@link BuiltinState}) — `disabled`: the word finds no command and binds nothing, `maybe`: as a function that may stand.
|
|
241
244
|
*/
|
|
242
245
|
export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader, shadow?: "named" | "maybe", availability?: (builtin: string) => BuiltinState): BindingEffect;
|
|
246
|
+
/** Does this assignment store ARRAY ELEMENTS — a compound value `(…)`, or a subscripted name `a[k]=v`? Bash never exports
|
|
247
|
+
* an array (an element assigned to an exported scalar makes it an array, gone from every child's environment): what it
|
|
248
|
+
* stores reaches a program only through a word that reads an element — the element floor it leaves here ({@link
|
|
249
|
+
* arrayElementFloor}) — never through an environment. One predicate for both spellings. Where the shell may NOT bind the
|
|
250
|
+
* word (a prefix, a launcher's or a declaration builtin's operand) it is handed on as written: the read plan keeps that
|
|
251
|
+
* word's text a candidate. */
|
|
252
|
+
export declare function bindsArrayElement(a: Pick<NonNullable<LexedWord["assignment"]>, "form" | "subscript">): boolean;
|
|
253
|
+
/** Do a segment's leading assignment words stand alone — the shell itself binds them — rather than prefix a command whose
|
|
254
|
+
* environment they are? The binding rule and the read plan's environment candidates ask the same question. */
|
|
255
|
+
export declare function assignsAsStatement(pos: ReturnType<typeof readProgramPosition>): boolean;
|
|
243
256
|
/**
|
|
244
257
|
* The names an ARITHMETIC text may assign: every identifier in a text that carries an assignment operator (`=` that is no
|
|
245
258
|
* comparison, `+=` and its kin, `++`, `--`) — read whole, not parsed: a name only compared there is made unknown too.
|
|
@@ -425,8 +438,13 @@ export declare class BindingThread {
|
|
|
425
438
|
* scope, so it can). What a reader in ANOTHER body loses ({@link unreadableBy}); a call to the body changes it unless a
|
|
426
439
|
* declaration the body certainly ran covers the name ({@link functionBound}). */
|
|
427
440
|
private bodyBinding;
|
|
441
|
+
/** Does what segment `at` does to this shell — a binding it makes where it stands, a move of the working directory —
|
|
442
|
+
* reach a reader at segment `j` (`j` absent: the text's end)? The one visibility rule ({@link visible}). */
|
|
443
|
+
reaches(at: number, j?: number): boolean;
|
|
428
444
|
/** Does segment `at` stand in a function body (it runs at a call, not here)? */
|
|
429
445
|
inFunctionBody(at: number): boolean;
|
|
446
|
+
/** The innermost function body segment `at` stands in, as an id one body's segments share (`undefined`: none). */
|
|
447
|
+
bodyOf(at: number): number | undefined;
|
|
430
448
|
/** Does segment `at` run in a subshell (a `( … )` group, a pipeline member that is not the last, a background job) or a
|
|
431
449
|
* function body — whatever it changes, the shell that runs the next segment may not see? */
|
|
432
450
|
runsApart(at: number): boolean;
|