@sema-agent/core 7.48.0 → 7.49.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 +418 -0
- package/README.md +2 -2
- package/dist/agents/cascade.d.ts +2 -5
- package/dist/agents/child-failure.d.ts +20 -0
- package/dist/agents/child-failure.js +28 -0
- package/dist/agents/cross-session-ref.d.ts +11 -3
- package/dist/agents/cross-session-ref.js +6 -0
- package/dist/agents/cumulative-stats.d.ts +12 -15
- package/dist/agents/cumulative-stats.js +1 -1
- package/dist/agents/extra-tool-names.js +1 -1
- package/dist/agents/inherited-tool-pool.d.ts +17 -13
- package/dist/agents/inherited-tool-pool.js +4 -3
- package/dist/agents/peer-session-drain.d.ts +3 -2
- package/dist/agents/peer-session-drain.js +5 -4
- package/dist/agents/send-message-tool.js +2 -9
- package/dist/agents/subagent.d.ts +10 -29
- package/dist/agents/subagent.js +65 -53
- package/dist/agents/suspend-guard.d.ts +1 -1
- package/dist/agents/tool-filter.d.ts +76 -65
- package/dist/agents/tool-filter.js +122 -92
- package/dist/agents/verify.d.ts +4 -7
- package/dist/agents/verify.js +6 -7
- package/dist/bench/metrics.d.ts +1 -2
- package/dist/brain/anthropic.js +133 -79
- package/dist/brain/errors.d.ts +53 -6
- package/dist/brain/errors.js +22 -2
- package/dist/brain/input-too-long.d.ts +40 -19
- package/dist/brain/input-too-long.js +3 -16
- package/dist/brain/open-responses.js +19 -10
- package/dist/brain/openai.js +123 -32
- package/dist/brain/provider-dialect.d.ts +214 -0
- package/dist/brain/provider-dialect.js +186 -0
- package/dist/brain/request-params.d.ts +27 -8
- package/dist/brain/request-params.js +7 -12
- package/dist/brain/request-route.d.ts +84 -0
- package/dist/brain/request-route.js +41 -0
- package/dist/brain/retry.d.ts +8 -0
- package/dist/brain/retry.js +10 -4
- package/dist/brain/route-adjudicator.d.ts +7 -0
- package/dist/brain/route-adjudicator.js +5 -1
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +11 -0
- package/dist/brain/stream-engine.d.ts +52 -1
- package/dist/brain/stream-engine.js +81 -24
- package/dist/brain/stream-shared.d.ts +57 -11
- package/dist/brain/stream-shared.js +28 -2
- package/dist/core/a2a.d.ts +1 -0
- package/dist/core/agent-config-dir.js +3 -2
- package/dist/core/allow-entry.d.ts +21 -12
- package/dist/core/allow-entry.js +38 -31
- package/dist/core/arg-summary.d.ts +17 -24
- package/dist/core/arg-summary.js +169 -68
- package/dist/core/ask-origin.d.ts +42 -24
- package/dist/core/ask-origin.js +18 -13
- package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
- package/dist/core/auto-mode-prompt-assets.js +1 -1
- package/dist/core/auto-mode-prompt.d.ts +11 -1
- package/dist/core/auto-mode-prompt.js +13 -10
- package/dist/core/auto-mode-rebuild.d.ts +7 -0
- package/dist/core/auto-mode-rebuild.js +4 -1
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.js +2 -1
- package/dist/core/checkpoint-requirements.d.ts +892 -0
- package/dist/core/checkpoint-requirements.js +333 -0
- package/dist/core/checkpoint-store.d.ts +94 -65
- package/dist/core/checkpoint-store.js +14 -26
- package/dist/core/child-clamp-seats.d.ts +228 -69
- package/dist/core/child-clamp-seats.js +211 -17
- package/dist/core/classifier-unavailable-arm.d.ts +5 -1
- package/dist/core/classifier-unavailable-arm.js +3 -3
- package/dist/core/compliance.d.ts +3 -0
- package/dist/core/compliance.js +9 -4
- package/dist/core/credential-vocabulary.d.ts +140 -0
- package/dist/core/credential-vocabulary.js +131 -0
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/effective-path-target.d.ts +73 -16
- package/dist/core/effective-path-target.js +63 -33
- package/dist/core/engine-notice.d.ts +32 -7
- package/dist/core/file-history-store.js +2 -2
- package/dist/core/fs-write-gate-policy.d.ts +4 -0
- package/dist/core/fs-write-gate-policy.js +22 -5
- package/dist/core/gate-bounded-await.d.ts +28 -13
- package/dist/core/gate-bounded-await.js +41 -4
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -25
- package/dist/core/gate-lanes.js +16 -15
- package/dist/core/gate-outcome.d.ts +20 -5
- package/dist/core/gate-outcome.js +5 -0
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +14 -3
- package/dist/core/hooks.d.ts +4 -0
- package/dist/core/locked-config.d.ts +8 -0
- package/dist/core/locked-config.js +14 -2
- package/dist/core/lsp.js +3 -5
- package/dist/core/mailbox-store.d.ts +3 -4
- package/dist/core/mcp-connection-pool.d.ts +75 -0
- package/dist/core/mcp-connection-pool.js +128 -0
- package/dist/core/mcp-failure.d.ts +2 -1
- package/dist/core/mcp-failure.js +13 -2
- package/dist/core/mcp.d.ts +4 -0
- package/dist/core/mcp.js +70 -43
- package/dist/core/memory-engine/content-origin.js +2 -14
- package/dist/core/memory-engine/engine.d.ts +32 -22
- package/dist/core/memory-engine/engine.js +103 -55
- package/dist/core/memory-engine/file-backend.d.ts +13 -30
- package/dist/core/memory-engine/file-backend.js +37 -252
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.d.ts +139 -9
- package/dist/core/memory-engine/layout.js +350 -7
- package/dist/core/memory-engine/scope-contract.d.ts +10 -0
- package/dist/core/memory-engine/scope-contract.js +8 -0
- package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
- package/dist/core/memory-engine/session-incarnation.js +5 -2
- package/dist/core/memory-engine/types.d.ts +10 -1
- package/dist/core/memory.js +5 -17
- package/dist/core/model-seat.d.ts +4 -4
- package/dist/core/model-seat.js +1 -1
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +19 -0
- package/dist/core/namespaced-rule-name.d.ts +29 -0
- package/dist/core/namespaced-rule-name.js +52 -0
- package/dist/core/park-selfcheck.d.ts +1 -1
- package/dist/core/park-selfcheck.js +16 -6
- package/dist/core/path-guard-rows.d.ts +99 -0
- package/dist/core/path-guard-rows.js +45 -0
- package/dist/core/path-identity.d.ts +22 -16
- package/dist/core/path-identity.js +10 -10
- package/dist/core/path-rule-binding.d.ts +2 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/pause-registry.d.ts +16 -2
- package/dist/core/pause-registry.js +6 -0
- package/dist/core/permission-rule-consent.js +0 -7
- package/dist/core/permission-rule-model.d.ts +68 -24
- package/dist/core/permission-rule-model.js +105 -24
- package/dist/core/permission-rule-store.js +2 -2
- package/dist/core/permission-rules.d.ts +3 -30
- package/dist/core/permission-rules.js +4 -54
- package/dist/core/read-root-candidate.d.ts +1 -3
- package/dist/core/read-root-candidate.js +4 -15
- package/dist/core/real-approval.d.ts +4 -3
- package/dist/core/retired-keys.d.ts +13 -0
- package/dist/core/retired-keys.js +14 -0
- package/dist/core/roles.d.ts +2 -3
- package/dist/core/roles.js +15 -6
- package/dist/core/runner/assemble-result.d.ts +0 -7
- package/dist/core/runner/assemble-result.js +19 -31
- package/dist/core/runner/caller-roster.d.ts +78 -0
- package/dist/core/runner/caller-roster.js +219 -0
- package/dist/core/runner/checkpoint-scope.d.ts +16 -16
- package/dist/core/runner/checkpoint-scope.js +2 -2
- package/dist/core/runner/child-tree.js +2 -2
- package/dist/core/runner/contracts.d.ts +68 -35
- package/dist/core/runner/decide-continuation.d.ts +51 -3
- package/dist/core/runner/decide-continuation.js +76 -21
- package/dist/core/runner/denial-limit-arms.d.ts +17 -5
- package/dist/core/runner/denial-limit-arms.js +11 -9
- package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
- package/dist/core/runner/extra-body-dropped-seat.js +22 -0
- package/dist/core/runner/finish-reason-seat.d.ts +9 -0
- package/dist/core/runner/finish-reason-seat.js +40 -0
- package/dist/core/runner/gate-exit.d.ts +44 -32
- package/dist/core/runner/gate-exit.js +112 -25
- package/dist/core/runner/inherited-ask-grants.js +6 -4
- package/dist/core/runner/mcp-redial.d.ts +3 -3
- package/dist/core/runner/mcp-redial.js +3 -4
- package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
- package/dist/core/runner/permission-rule-lanes.js +5 -4
- package/dist/core/runner/prepare-artifact.d.ts +4 -0
- package/dist/core/runner/prepare-artifact.js +2 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
- package/dist/core/runner/prepare-ask-lane.js +12 -6
- package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
- package/dist/core/runner/prepare-boundary-parks.js +4 -7
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
- package/dist/core/runner/prepare-config-doors.d.ts +9 -9
- package/dist/core/runner/prepare-config-doors.js +10 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
- package/dist/core/runner/prepare-defer-classify.js +5 -3
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-delegation-surface.js +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
- package/dist/core/runner/prepare-gate-stations.js +9 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
- package/dist/core/runner/prepare-hands-readface.js +7 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
- package/dist/core/runner/prepare-inherited-gate.js +14 -15
- package/dist/core/runner/prepare-listings.d.ts +7 -24
- package/dist/core/runner/prepare-listings.js +4 -5
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
- package/dist/core/runner/prepare-memory-engine-session.js +4 -3
- package/dist/core/runner/prepare-memory.d.ts +6 -0
- package/dist/core/runner/prepare-memory.js +13 -13
- package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
- package/dist/core/runner/prepare-offload-wrappers.js +3 -3
- package/dist/core/runner/prepare-park-ask.d.ts +7 -8
- package/dist/core/runner/prepare-park-ask.js +17 -10
- package/dist/core/runner/prepare-policy-chain.js +24 -44
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -4
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
- package/dist/core/runner/prepare-protocol-tools.js +3 -4
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -1
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
- package/dist/core/runner/prepare-safety-scan.js +1 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
- package/dist/core/runner/prepare-suspend-saga.js +28 -12
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +67 -56
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
- package/dist/core/runner/prepare-wiring-manifest.js +5 -8
- package/dist/core/runner/resume-apply.js +7 -14
- package/dist/core/runner/resume-checkpoint-screen.js +11 -4
- package/dist/core/runner/resume-internals-and-config.js +2 -2
- package/dist/core/runner/resume-policy-outcome.js +5 -32
- package/dist/core/runner/resume-review-outcome.js +4 -1
- package/dist/core/runner/retired-runner-deps.d.ts +6 -0
- package/dist/core/runner/retired-runner-deps.js +10 -1
- package/dist/core/runner/run-brain-sinks.d.ts +4 -0
- package/dist/core/runner/run-brain-sinks.js +5 -2
- package/dist/core/runner/run-harness-handlers.js +27 -34
- package/dist/core/runner/run-leg.d.ts +0 -2
- package/dist/core/runner/run-leg.js +32 -33
- package/dist/core/runner/run-terminal-adoption.js +4 -3
- package/dist/core/runner/runtask.js +8 -8
- package/dist/core/runner/session-rule-policy.js +5 -5
- package/dist/core/runner/stream-settle-backstop.js +7 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
- package/dist/core/runner/sub-agent-deny-lists.js +111 -80
- package/dist/core/runner/terminal-account.d.ts +48 -0
- package/dist/core/runner/terminal-account.js +186 -0
- package/dist/core/runner/tool-end-body.d.ts +54 -17
- package/dist/core/runner/tool-end-body.js +27 -2
- package/dist/core/runner/tool-face-overlay.d.ts +3 -1
- package/dist/core/runner/tool-face-overlay.js +6 -4
- package/dist/core/runner/tool-occurrence.d.ts +106 -0
- package/dist/core/runner/tool-occurrence.js +123 -0
- package/dist/core/runner/tool-progress-lane.d.ts +16 -8
- package/dist/core/runner/tool-progress-lane.js +25 -34
- package/dist/core/runner/turn-attachments.d.ts +1 -1
- package/dist/core/runner/write-protection-station.d.ts +21 -9
- package/dist/core/runner/write-protection-station.js +20 -17
- package/dist/core/runner-deps.d.ts +12 -22
- package/dist/core/secret-env.d.ts +16 -5
- package/dist/core/secret-env.js +23 -63
- package/dist/core/sensitive-path-policy.d.ts +19 -18
- package/dist/core/sensitive-path-policy.js +73 -49
- package/dist/core/session-reconcile.d.ts +3 -0
- package/dist/core/session-reconcile.js +5 -4
- package/dist/core/session-store.d.ts +5 -0
- package/dist/core/session-store.js +12 -0
- package/dist/core/session.d.ts +13 -0
- package/dist/core/shared-memory/normalize.d.ts +17 -4
- package/dist/core/shared-memory/normalize.js +7 -7
- package/dist/core/shell-lexer.js +5 -4
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.js +2 -2
- package/dist/core/task-event.d.ts +59 -5
- package/dist/core/task-result.d.ts +1 -1
- package/dist/core/task-spec.d.ts +42 -9
- package/dist/core/terminal-cause.d.ts +94 -11
- package/dist/core/tighten-task-spec.d.ts +5 -4
- package/dist/core/tighten-task-spec.js +20 -25
- package/dist/core/tool-catalog-entries.d.ts +5 -7
- package/dist/core/tool-catalog-entries.js +14 -15
- package/dist/core/tool-face.d.ts +47 -0
- package/dist/core/tool-face.js +5 -0
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +26 -2
- package/dist/core/tool-name-aliases.js +13 -0
- package/dist/core/tool-name-list.d.ts +30 -0
- package/dist/core/tool-name-list.js +55 -0
- package/dist/core/tool-name-readings.d.ts +1 -9
- package/dist/core/tool-name-readings.js +1 -3
- package/dist/core/tool-policy.d.ts +195 -85
- package/dist/core/tool-policy.js +165 -380
- package/dist/core/tool-registry.d.ts +44 -1
- package/dist/core/tool-registry.js +26 -0
- package/dist/core/tool-roster.d.ts +19 -1
- package/dist/core/tool-roster.js +21 -2
- package/dist/core/tool-spec-members.d.ts +45 -0
- package/dist/core/tool-spec-members.js +169 -0
- package/dist/core/tool-spec.d.ts +46 -8
- package/dist/core/tools.d.ts +6 -2
- package/dist/core/tools.js +8 -4
- package/dist/core/untrusted-egress.js +29 -26
- package/dist/core/untrusted-text.d.ts +13 -10
- package/dist/core/untrusted-text.js +6 -44
- package/dist/core/workflow-journal-store.d.ts +4 -1
- package/dist/core/write-protect.d.ts +65 -29
- package/dist/core/write-protect.js +235 -177
- package/dist/engine/compaction/compaction.d.ts +2 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
- package/dist/engine/execution-env/node-execution-env.js +16 -38
- package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
- package/dist/engine/execution-env/symlink-chain.js +32 -0
- package/dist/engine/harness/types.d.ts +7 -0
- package/dist/engine/llm/tool-turns.d.ts +3 -0
- package/dist/engine/llm/tool-turns.js +1 -0
- package/dist/engine/llm/types.d.ts +59 -23
- package/dist/engine/loop/agent-loop.js +16 -2
- package/dist/engine/session/memory-repo.js +11 -3
- package/dist/engine/session/repo-utils.d.ts +8 -0
- package/dist/engine/session/repo-utils.js +13 -0
- package/dist/index.d.ts +20 -23
- package/dist/index.js +17 -20
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.js +1 -1
- package/dist/orchestration/run-spec.js +3 -3
- package/dist/orchestration/run-workflow-tool.d.ts +16 -35
- package/dist/orchestration/run-workflow-tool.js +38 -78
- package/dist/orchestration/workflow-governance.d.ts +21 -25
- package/dist/orchestration/workflow-governance.js +38 -78
- package/dist/orchestration/workflow-primitives.d.ts +7 -22
- package/dist/orchestration/workflow-primitives.js +5 -12
- package/dist/orchestration/workflow-types.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +61 -11
- package/dist/orchestration/workflow.js +189 -117
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/shell/lex.d.ts +0 -21
- package/dist/shell/lex.js +250 -68
- package/dist/shell/shell-words.d.ts +35 -0
- package/dist/shell/shell-words.js +65 -0
- package/dist/stores/file/checkpoint-store.d.ts +5 -5
- package/dist/stores/file/checkpoint-store.js +5 -2
- package/dist/stores/file/index.d.ts +0 -8
- package/dist/stores/file/index.js +0 -12
- package/dist/stores/file/session-store.d.ts +3 -0
- package/dist/stores/file/session-store.js +44 -19
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/fs/bash-program-position.d.ts +10 -3
- package/dist/tools/fs/bash-program-position.js +21 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +8 -7
- package/dist/tools/fs/containment-face.d.ts +4 -0
- package/dist/tools/fs/containment-face.js +3 -0
- package/dist/tools/fs/fs-shared.d.ts +10 -0
- package/dist/tools/fs/fs-shared.js +18 -0
- package/dist/tools/fs/fs-write.js +4 -2
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/program-read-model.d.ts +39 -18
- package/dist/tools/fs/program-read-model.js +29 -19
- package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
- package/dist/tools/fs/program-read-model.rows.js +5 -5
- package/dist/tools/fs/read-deny-home.d.ts +33 -47
- package/dist/tools/fs/read-deny-home.js +35 -49
- package/dist/tools/fs/read-deny.d.ts +23 -22
- package/dist/tools/fs/read-deny.js +114 -89
- package/dist/tools/fs/removal-targets.d.ts +56 -23
- package/dist/tools/fs/removal-targets.js +65 -87
- package/dist/tools/fs/safety.d.ts +29 -22
- package/dist/tools/fs/safety.js +17 -11
- package/dist/tools/fs/search.js +10 -8
- package/dist/tools/fs/shell-read-argv.js +1 -1
- package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
- package/dist/tools/fs/shell-read-bindings.js +324 -86
- package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
- package/dist/tools/fs/shell-read-builtins.js +43 -0
- package/dist/tools/fs/shell-read-check.d.ts +15 -1
- package/dist/tools/fs/shell-read-check.js +51 -42
- package/dist/tools/fs/shell-read-establish.js +6 -6
- package/dist/tools/fs/shell-read-functions.d.ts +22 -0
- package/dist/tools/fs/shell-read-functions.js +29 -0
- package/dist/tools/fs/shell-read-judge.d.ts +48 -18
- package/dist/tools/fs/shell-read-judge.js +33 -4
- package/dist/tools/fs/shell-read-plan.d.ts +12 -6
- package/dist/tools/fs/shell-read-plan.js +118 -113
- package/dist/tools/fs/shell-read-start.d.ts +29 -6
- package/dist/tools/fs/shell-read-start.js +16 -9
- package/dist/tools/fs/shell-read-word.js +4 -0
- package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
- package/dist/tools/fs/shell-read-workdir.js +281 -0
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
- package/dist/tools/fs/shell-read-write-targets.js +14 -5
- package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
- package/dist/tools/fs/shell-reentry-text.js +3 -11
- package/dist/tools/task-list.d.ts +1 -2
- package/dist/tools/web.js +1 -1
- package/package.json +4 -1
- package/test/export-surface.snapshot.json +107 -143
- package/wire-changes/core@7.49.0.json +4765 -0
- package/dist/agents/teacher.d.ts +0 -159
- package/dist/agents/teacher.js +0 -577
- package/dist/agents/team.d.ts +0 -226
- package/dist/agents/team.js +0 -257
- package/dist/core/strategy-store.d.ts +0 -238
- package/dist/core/strategy-store.js +0 -253
- package/dist/orchestration/builtin-workflows.d.ts +0 -133
- package/dist/orchestration/builtin-workflows.js +0 -159
- package/dist/scenarios/env.d.ts +0 -40
- package/dist/scenarios/env.js +0 -39
- package/dist/scenarios/scenario-registry.d.ts +0 -110
- package/dist/scenarios/scenario-registry.js +0 -140
- package/dist/scenarios/teacher-quickstart.d.ts +0 -40
- package/dist/scenarios/teacher-quickstart.js +0 -12
- package/dist/stores/cc/lockfile.d.ts +0 -10
- package/dist/stores/cc/lockfile.js +0 -98
- package/dist/stores/cc/mailbox-store.d.ts +0 -20
- package/dist/stores/cc/mailbox-store.js +0 -255
- package/dist/stores/cc/roster-adapter.d.ts +0 -12
- package/dist/stores/cc/roster-adapter.js +0 -117
- package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
- package/dist/stores/cc/sidecar-transcript.js +0 -264
- package/dist/stores/cc/task-list-store.d.ts +0 -2
- package/dist/stores/cc/task-list-store.js +0 -125
- package/dist/stores/file/strategy-store.d.ts +0 -97
- package/dist/stores/file/strategy-store.js +0 -341
package/dist/shell/lex.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ONE shell lexer: one walk over a bash command mints a structure of words made of PIECES, and every other
|
|
3
|
-
* spelling a reader consumes — `raw`, `folded`, the quoted spans, the expansion list, the assignment fact, the
|
|
4
|
-
* reason a value cannot be read off the text — is a view of that structure. Dialect: bash (the execution
|
|
5
|
-
* environment's last-resort `sh` reads `$'…'`, `+=`, a subscript, `<<<`, `<(…)` and `&>` differently; see
|
|
6
|
-
* {@link bashOnlyConstructsOf}).
|
|
7
|
-
*
|
|
8
|
-
* ONE walk, ONE reading: every construct bash reads is RECORDED — a redirection, a substitution, an escape, a
|
|
9
|
-
* comment, a line break, a backgrounding `&` — never refused here. Which of them a face refuses is that face's
|
|
10
|
-
* predicate over the result (the classify faces' residual predicate in the read-only classifier); the lexer has
|
|
11
|
-
* no modes. Bash's own word rules hold throughout: an unquoted word-start `#` begins a comment, and only a blank
|
|
12
|
-
* (space or tab) bounds a word — a non-breaking space or a vertical tab is a word character.
|
|
13
|
-
*
|
|
14
|
-
* A command bash cannot parse is a {@link LexParseFailure}, never a guessed reading: an unterminated quote,
|
|
15
|
-
* substitution, subscript or here-document yields NO segments. A word bash reads but whose VALUE the text does not
|
|
16
|
-
* contain carries {@link LexedWord.unresolved}; the word is still delimited and its neighbours still read.
|
|
17
|
-
*
|
|
18
|
-
* Line continuations. Bash removes a `\<newline>` pair before it recognises anything — except inside single quotes,
|
|
19
|
-
* a comment and a QUOTED here-document body. Every lookahead below reads the next LOGICAL character past any
|
|
20
|
-
* continuation, so a pair can stand inside a construct's spelling and never inside the three places bash keeps it.
|
|
21
|
-
*/
|
|
22
1
|
/** The dialect this lexer reads. The execution environment falls back to `sh` when no bash is found; a reader on
|
|
23
2
|
* that path must degrade every word carrying a {@link BashOnlyConstruct} to the conservative reading. */
|
|
24
3
|
export declare const SHELL_LEX_DIALECT = "bash";
|
package/dist/shell/lex.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { shellWordsOf } from "./shell-words.js";
|
|
1
2
|
export const SHELL_LEX_DIALECT = "bash";
|
|
2
3
|
export const QUOTE_KINDS = Object.freeze(["'", '"', "$'", '$"', "\\"]);
|
|
3
4
|
export const EXPANSION_KINDS = Object.freeze(["parameter", "command", "process", "arithmetic", "tilde", "brace", "glob"]);
|
|
@@ -67,9 +68,14 @@ export const ANSI_C_ESCAPES = {
|
|
|
67
68
|
"?": "?",
|
|
68
69
|
};
|
|
69
70
|
export const SUBSTITUTION_PLACEHOLDER = " subst";
|
|
70
|
-
export const SHELL_CONTROL_PREFIXES =
|
|
71
|
+
export const SHELL_CONTROL_PREFIXES = shellWordsOf("control_prefix");
|
|
71
72
|
const COMPOUND_OPERAND_COMMANDS = new Set(["alias", "declare", "eval", "export", "let", "local", "readonly", "typeset"]);
|
|
72
|
-
const GROUP_WORDS =
|
|
73
|
+
const GROUP_WORDS = shellWordsOf("group");
|
|
74
|
+
const DEFINITION_WORDS = shellWordsOf("definition");
|
|
75
|
+
const BACKGROUND_WORDS = shellWordsOf("background");
|
|
76
|
+
const COMPOUND_OPEN_WORDS = shellWordsOf("compound_open");
|
|
77
|
+
const CASE_ARM_WORDS = shellWordsOf("case_arms");
|
|
78
|
+
const TIMER_WORDS = shellWordsOf("timer");
|
|
73
79
|
export function dollarOpensQuote(text, at) {
|
|
74
80
|
const next = text[at + 1];
|
|
75
81
|
if (next !== "'" && next !== '"')
|
|
@@ -134,19 +140,149 @@ function past(text, j) {
|
|
|
134
140
|
k += 2;
|
|
135
141
|
return k;
|
|
136
142
|
}
|
|
137
|
-
function
|
|
143
|
+
function heredocHeaderOf(word, dash) {
|
|
144
|
+
if (word.folded === "" || /[$`]/.test(word.raw))
|
|
145
|
+
return undefined;
|
|
146
|
+
return { delimiter: word.folded, quoted: /["'\\]/.test(word.raw), dash };
|
|
147
|
+
}
|
|
148
|
+
function heredocBodies(text, from, headers, inSubstitution) {
|
|
149
|
+
const bodies = [];
|
|
150
|
+
let p = from;
|
|
151
|
+
for (const h of headers) {
|
|
152
|
+
const lines = [];
|
|
153
|
+
for (;;) {
|
|
154
|
+
if (p > text.length)
|
|
155
|
+
return "unterminated";
|
|
156
|
+
let nl = text.indexOf("\n", p);
|
|
157
|
+
let line = nl < 0 ? text.slice(p) : text.slice(p, nl);
|
|
158
|
+
if (!h.quoted) {
|
|
159
|
+
while (nl >= 0 && /(?<!\\)(?:\\\\)*\\$/.test(line)) {
|
|
160
|
+
const after = text.indexOf("\n", nl + 1);
|
|
161
|
+
line = line.slice(0, -1) + (after < 0 ? text.slice(nl + 1) : text.slice(nl + 1, after));
|
|
162
|
+
nl = after;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const compared = h.dash ? line.replace(/^\t+/, "") : line;
|
|
166
|
+
if (compared === h.delimiter) {
|
|
167
|
+
p = nl < 0 ? text.length + 1 : nl + 1;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
if (inSubstitution && compared.startsWith(h.delimiter))
|
|
171
|
+
return "ambiguous";
|
|
172
|
+
if (nl < 0)
|
|
173
|
+
return "unterminated";
|
|
174
|
+
lines.push(line);
|
|
175
|
+
p = nl + 1;
|
|
176
|
+
}
|
|
177
|
+
bodies.push(lines.join("\n"));
|
|
178
|
+
}
|
|
179
|
+
return { bodies, resume: Math.min(p, text.length) };
|
|
180
|
+
}
|
|
181
|
+
function heredocHeaderAt(text, from, dash, op) {
|
|
182
|
+
let j = from;
|
|
183
|
+
while (text[j] === " " || text[j] === "\t" || (text[j] === "\\" && text[j + 1] === "\n"))
|
|
184
|
+
j += text[j] === "\\" ? 2 : 1;
|
|
185
|
+
const start = j;
|
|
186
|
+
let quote;
|
|
187
|
+
for (; j < text.length; j++) {
|
|
188
|
+
const c = text[j];
|
|
189
|
+
if (c === "$" || c === "`")
|
|
190
|
+
return fail("heredoc_delimiter_expands", start);
|
|
191
|
+
if (quote === "'") {
|
|
192
|
+
if (c === "'")
|
|
193
|
+
quote = undefined;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (quote === '"') {
|
|
197
|
+
if (c === "\\")
|
|
198
|
+
j++;
|
|
199
|
+
else if (c === '"')
|
|
200
|
+
quote = undefined;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (c === "\\") {
|
|
204
|
+
j++;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (c === "'" || c === '"') {
|
|
208
|
+
quote = c;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (/[ \t\n;&|()<>]/.test(c))
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
if (quote !== undefined)
|
|
215
|
+
return "unterminated";
|
|
216
|
+
const raw = text.slice(start, Math.min(j, text.length));
|
|
217
|
+
if (raw === "" || raw.startsWith("#"))
|
|
218
|
+
return fail("heredoc_without_delimiter", op);
|
|
219
|
+
if (/[~[]/.test(raw))
|
|
220
|
+
return "undelimited";
|
|
221
|
+
const lexed = scan(raw, true);
|
|
222
|
+
const tokens = "command" in lexed && lexed.command.segments.length === 1 ? lexed.command.segments[0].tokens : [];
|
|
223
|
+
const word = tokens.length === 1 ? tokens[0] : undefined;
|
|
224
|
+
if (word?.kind !== "word")
|
|
225
|
+
return "undelimited";
|
|
226
|
+
const header = heredocHeaderOf(word, dash);
|
|
227
|
+
return header === undefined ? fail("heredoc_delimiter_expands", start) : { ...header, end: j };
|
|
228
|
+
}
|
|
229
|
+
const BASH_READING = { heredoc: true, startComment: true };
|
|
230
|
+
const BASH32_READINGS = [{ heredoc: false, startComment: true }, { heredoc: false, startComment: false }];
|
|
231
|
+
const BODY_NESTING_MAX = 64;
|
|
232
|
+
function walkBody(text, open, reading, inDouble, level = 0) {
|
|
233
|
+
if (level > BODY_NESTING_MAX)
|
|
234
|
+
return "undelimited";
|
|
138
235
|
let depth = 0;
|
|
139
236
|
let quoted;
|
|
140
237
|
let wordStart = true;
|
|
141
238
|
let word = "";
|
|
239
|
+
let heredoc = false;
|
|
240
|
+
const owed = [];
|
|
241
|
+
const nested = (at, dq) => {
|
|
242
|
+
const inner = walkBody(text, at, reading, dq, level + 1);
|
|
243
|
+
if (typeof inner === "object" && "end" in inner) {
|
|
244
|
+
heredoc ||= inner.heredoc;
|
|
245
|
+
return inner.end - 1;
|
|
246
|
+
}
|
|
247
|
+
return inner;
|
|
248
|
+
};
|
|
142
249
|
for (let j = open; j < text.length; j++) {
|
|
143
250
|
const c = text[j];
|
|
144
|
-
if (quoted
|
|
145
|
-
if (c === "
|
|
251
|
+
if (quoted === "'") {
|
|
252
|
+
if (c === "'")
|
|
253
|
+
quoted = undefined;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (quoted === '"') {
|
|
257
|
+
if (c === "\\") {
|
|
146
258
|
j++;
|
|
147
|
-
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (c === '"') {
|
|
148
262
|
quoted = undefined;
|
|
149
|
-
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (c === "`") {
|
|
266
|
+
const tick = backtickBody(text, j);
|
|
267
|
+
if (tick === undefined)
|
|
268
|
+
return "unterminated";
|
|
269
|
+
j = tick.close;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const k = past(text, j + 1);
|
|
273
|
+
if (c === "$" && text[k] === "(") {
|
|
274
|
+
const r = nested(k, true);
|
|
275
|
+
if (typeof r !== "number")
|
|
276
|
+
return r;
|
|
277
|
+
j = r;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (c === "$" && text[k] === "{") {
|
|
281
|
+
const close = braceExpansionEnd(text, k);
|
|
282
|
+
if (close === undefined)
|
|
283
|
+
return "unterminated";
|
|
284
|
+
j = close - 1;
|
|
285
|
+
}
|
|
150
286
|
continue;
|
|
151
287
|
}
|
|
152
288
|
if (c === "\\") {
|
|
@@ -162,9 +298,8 @@ function parenBodyEnd(text, open) {
|
|
|
162
298
|
if (c === "#" && wordStart) {
|
|
163
299
|
const nl = text.indexOf("\n", j);
|
|
164
300
|
if (nl < 0)
|
|
165
|
-
return
|
|
166
|
-
j = nl;
|
|
167
|
-
wordStart = true;
|
|
301
|
+
return "unterminated";
|
|
302
|
+
j = nl - 1;
|
|
168
303
|
word = "";
|
|
169
304
|
continue;
|
|
170
305
|
}
|
|
@@ -174,34 +309,107 @@ function parenBodyEnd(text, open) {
|
|
|
174
309
|
word = "";
|
|
175
310
|
continue;
|
|
176
311
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const close =
|
|
312
|
+
const k = past(text, j + 1);
|
|
313
|
+
if (c === "$" && text[k] === "'") {
|
|
314
|
+
const close = ansiCQuoteClose(text, k);
|
|
180
315
|
if (close === undefined)
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
316
|
+
return "unterminated";
|
|
317
|
+
j = close;
|
|
318
|
+
wordStart = false;
|
|
319
|
+
word = "";
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (c === "`") {
|
|
323
|
+
const tick = backtickBody(text, j);
|
|
324
|
+
if (tick === undefined)
|
|
325
|
+
return "unterminated";
|
|
326
|
+
j = tick.close;
|
|
327
|
+
wordStart = false;
|
|
328
|
+
word = "`";
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (reading.heredoc && c === "<" && text[k] === "<") {
|
|
332
|
+
const third = past(text, k + 1);
|
|
333
|
+
if (text[third] === "<") {
|
|
334
|
+
j = third;
|
|
335
|
+
wordStart = false;
|
|
336
|
+
word = "";
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const dash = text[third] === "-";
|
|
340
|
+
const header = heredocHeaderAt(text, dash ? third + 1 : third, dash, j);
|
|
341
|
+
if (typeof header !== "object" || !("delimiter" in header))
|
|
342
|
+
return header;
|
|
343
|
+
owed.push(header);
|
|
344
|
+
heredoc = true;
|
|
345
|
+
j = header.end - 1;
|
|
346
|
+
wordStart = false;
|
|
347
|
+
word = "";
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if ((c === "$" || c === "<" || c === ">") && text[k] === "(") {
|
|
351
|
+
const r = nested(k, false);
|
|
352
|
+
if (typeof r !== "number")
|
|
353
|
+
return r;
|
|
354
|
+
j = r;
|
|
355
|
+
wordStart = false;
|
|
356
|
+
word = "$";
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (reading.heredoc && c === "$" && text[k] === "{") {
|
|
360
|
+
const close = braceExpansionEnd(text, k);
|
|
361
|
+
if (close === undefined)
|
|
362
|
+
return "unterminated";
|
|
363
|
+
if (UNREADABLE_EXPANSION_TEXT.test(text.slice(k + 1, close - 1)))
|
|
364
|
+
return "undelimited";
|
|
184
365
|
j = close - 1;
|
|
185
366
|
wordStart = false;
|
|
186
367
|
word = "";
|
|
187
368
|
continue;
|
|
188
369
|
}
|
|
189
|
-
if (c === "
|
|
190
|
-
|
|
370
|
+
if (c === "\n" && owed.length > 0) {
|
|
371
|
+
const read = heredocBodies(text, j + 1, owed, true);
|
|
372
|
+
if (read === "unterminated")
|
|
373
|
+
return fail("unterminated_heredoc", j + 1);
|
|
374
|
+
if (read === "ambiguous")
|
|
375
|
+
return "undelimited";
|
|
376
|
+
owed.length = 0;
|
|
377
|
+
j = read.resume - 1;
|
|
378
|
+
wordStart = true;
|
|
379
|
+
word = "";
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
191
382
|
if (c === "(")
|
|
192
383
|
depth++;
|
|
193
384
|
else if (c === ")") {
|
|
194
385
|
depth--;
|
|
195
386
|
if (depth === 0)
|
|
196
|
-
return j + 1;
|
|
387
|
+
return owed.length > 0 ? "undelimited" : { end: j + 1, heredoc };
|
|
388
|
+
}
|
|
389
|
+
if (!reading.heredoc) {
|
|
390
|
+
wordStart = j === open ? reading.startComment && !inDouble && level === 0 : c === " " || c === "\t" || c === "\n";
|
|
391
|
+
continue;
|
|
197
392
|
}
|
|
198
393
|
const boundary = /[\s;|&()]/.test(c);
|
|
199
|
-
if (boundary && word
|
|
200
|
-
return "
|
|
394
|
+
if (boundary && CASE_ARM_WORDS.has(word))
|
|
395
|
+
return "undelimited";
|
|
201
396
|
word = boundary ? "" : word + c;
|
|
202
397
|
wordStart = boundary;
|
|
203
398
|
}
|
|
204
|
-
return
|
|
399
|
+
return "unterminated";
|
|
400
|
+
}
|
|
401
|
+
function substitutionBodyEnd(text, open, inDouble) {
|
|
402
|
+
const read = walkBody(text, open, BASH_READING, inDouble);
|
|
403
|
+
if (typeof read !== "object" || !("end" in read))
|
|
404
|
+
return read;
|
|
405
|
+
if (!read.heredoc)
|
|
406
|
+
return read.end;
|
|
407
|
+
for (const reading of BASH32_READINGS) {
|
|
408
|
+
const counted = walkBody(text, open, reading, inDouble);
|
|
409
|
+
if (counted !== "unterminated" && !(typeof counted === "object" && "end" in counted && counted.end === read.end))
|
|
410
|
+
return "undelimited";
|
|
411
|
+
}
|
|
412
|
+
return read.end;
|
|
205
413
|
}
|
|
206
414
|
function braceExpansionEnd(text, open) {
|
|
207
415
|
let quoted;
|
|
@@ -310,7 +518,7 @@ export function substitutionsInHeredocBody(body) {
|
|
|
310
518
|
continue;
|
|
311
519
|
}
|
|
312
520
|
if (ch === "$" && body[i + 1] === "(") {
|
|
313
|
-
const end =
|
|
521
|
+
const end = substitutionBodyEnd(body, i + 1, true);
|
|
314
522
|
if (typeof end !== "number")
|
|
315
523
|
return undefined;
|
|
316
524
|
out.push({ body: body.slice(i + 2, end - 1), kind: body[i + 2] === "(" ? "arithmetic" : "command" });
|
|
@@ -786,13 +994,13 @@ function scan(source, connectorsAreText) {
|
|
|
786
994
|
const at = w.at;
|
|
787
995
|
w = new WordBuilder();
|
|
788
996
|
if (pendingHeredoc !== undefined) {
|
|
789
|
-
const header = pendingHeredoc;
|
|
997
|
+
const header = heredocHeaderOf(word, pendingHeredoc.dash);
|
|
790
998
|
pendingHeredoc = undefined;
|
|
791
|
-
if (
|
|
999
|
+
if (header === undefined)
|
|
792
1000
|
return fail("heredoc_delimiter_expands", at);
|
|
793
|
-
const token = { kind: "heredoc", delimiter:
|
|
1001
|
+
const token = { kind: "heredoc", delimiter: header.delimiter, quoted: header.quoted, body: "" };
|
|
794
1002
|
current().tokens.push(token);
|
|
795
|
-
pendingHeredocs.push({
|
|
1003
|
+
pendingHeredocs.push({ ...header, token });
|
|
796
1004
|
if (acceptable) {
|
|
797
1005
|
if (assignmentSeen)
|
|
798
1006
|
subscriptsClosed = true;
|
|
@@ -824,17 +1032,17 @@ function scan(source, connectorsAreText) {
|
|
|
824
1032
|
resetPosition();
|
|
825
1033
|
return undefined;
|
|
826
1034
|
}
|
|
827
|
-
if (acceptable && bare && word.folded
|
|
1035
|
+
if (acceptable && bare && DEFINITION_WORDS.has(word.folded)) {
|
|
828
1036
|
acceptable = false;
|
|
829
1037
|
definitionName = true;
|
|
830
1038
|
return undefined;
|
|
831
1039
|
}
|
|
832
1040
|
if (acceptable && bare && (SHELL_CONTROL_PREFIXES.has(word.folded) || GROUP_WORDS.has(word.folded))) {
|
|
833
|
-
timeGrammar = word.folded
|
|
1041
|
+
timeGrammar = TIMER_WORDS.has(word.folded) ? "opt" : undefined;
|
|
834
1042
|
coprocWord = undefined;
|
|
835
1043
|
return undefined;
|
|
836
1044
|
}
|
|
837
|
-
if (acceptable && bare && word.folded
|
|
1045
|
+
if (acceptable && bare && BACKGROUND_WORDS.has(word.folded)) {
|
|
838
1046
|
coprocWord = "head";
|
|
839
1047
|
return undefined;
|
|
840
1048
|
}
|
|
@@ -854,7 +1062,7 @@ function scan(source, connectorsAreText) {
|
|
|
854
1062
|
}
|
|
855
1063
|
if (acceptable && coprocWord !== "name")
|
|
856
1064
|
commandWord = bare ? word.folded : undefined;
|
|
857
|
-
if (coprocWord === "head") {
|
|
1065
|
+
if (coprocWord === "head" && !(bare && COMPOUND_OPEN_WORDS.has(word.folded))) {
|
|
858
1066
|
coprocWord = "name";
|
|
859
1067
|
return undefined;
|
|
860
1068
|
}
|
|
@@ -873,34 +1081,12 @@ function scan(source, connectorsAreText) {
|
|
|
873
1081
|
return undefined;
|
|
874
1082
|
};
|
|
875
1083
|
const readHeredocBodies = (from) => {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
if (p > source.length)
|
|
881
|
-
return fail("unterminated_heredoc", from);
|
|
882
|
-
let nl = source.indexOf("\n", p);
|
|
883
|
-
let line = nl < 0 ? source.slice(p) : source.slice(p, nl);
|
|
884
|
-
if (!h.quoted) {
|
|
885
|
-
while (nl >= 0 && /(?<!\\)(?:\\\\)*\\$/.test(line)) {
|
|
886
|
-
const after = source.indexOf("\n", nl + 1);
|
|
887
|
-
line = line.slice(0, -1) + (after < 0 ? source.slice(nl + 1) : source.slice(nl + 1, after));
|
|
888
|
-
nl = after;
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
if ((h.dash ? line.replace(/^\t+/, "") : line) === h.delimiter) {
|
|
892
|
-
p = nl < 0 ? source.length + 1 : nl + 1;
|
|
893
|
-
break;
|
|
894
|
-
}
|
|
895
|
-
if (nl < 0)
|
|
896
|
-
return fail("unterminated_heredoc", from);
|
|
897
|
-
lines.push(line);
|
|
898
|
-
p = nl + 1;
|
|
899
|
-
}
|
|
900
|
-
h.token.body = lines.join("\n");
|
|
901
|
-
}
|
|
1084
|
+
const read = heredocBodies(source, from, pendingHeredocs, false);
|
|
1085
|
+
if (typeof read !== "object")
|
|
1086
|
+
return fail("unterminated_heredoc", from);
|
|
1087
|
+
pendingHeredocs.forEach((h, k) => { h.token.body = read.bodies[k]; });
|
|
902
1088
|
pendingHeredocs.length = 0;
|
|
903
|
-
return
|
|
1089
|
+
return read.resume;
|
|
904
1090
|
};
|
|
905
1091
|
for (let i = 0; i < source.length; i++) {
|
|
906
1092
|
if (!inSingle) {
|
|
@@ -1032,11 +1218,9 @@ function scan(source, connectorsAreText) {
|
|
|
1032
1218
|
}
|
|
1033
1219
|
if (ch === "$" && source[n1] === "(") {
|
|
1034
1220
|
const arithmetic = source[next(n1)] === "(";
|
|
1035
|
-
const end =
|
|
1036
|
-
if (end
|
|
1037
|
-
return fail("unterminated_command_substitution", i);
|
|
1038
|
-
if (end === "unreadable")
|
|
1039
|
-
return fail("undelimited_substitution", i);
|
|
1221
|
+
const end = substitutionBodyEnd(source, n1, inDouble);
|
|
1222
|
+
if (typeof end !== "number")
|
|
1223
|
+
return end === "unterminated" ? fail("unterminated_command_substitution", i) : end === "undelimited" ? fail("undelimited_substitution", i) : end;
|
|
1040
1224
|
substitution(i, end, source.slice(n1 + 1, end - 1), arithmetic ? "arithmetic" : "command");
|
|
1041
1225
|
i = end - 1;
|
|
1042
1226
|
continue;
|
|
@@ -1068,11 +1252,9 @@ function scan(source, connectorsAreText) {
|
|
|
1068
1252
|
continue;
|
|
1069
1253
|
}
|
|
1070
1254
|
if ((ch === "<" || ch === ">") && source[n1] === "(") {
|
|
1071
|
-
const end =
|
|
1072
|
-
if (end
|
|
1073
|
-
return fail("unterminated_process_substitution", i);
|
|
1074
|
-
if (end === "unreadable")
|
|
1075
|
-
return fail("undelimited_substitution", i);
|
|
1255
|
+
const end = substitutionBodyEnd(source, n1, false);
|
|
1256
|
+
if (typeof end !== "number")
|
|
1257
|
+
return end === "unterminated" ? fail("unterminated_process_substitution", i) : end === "undelimited" ? fail("undelimited_substitution", i) : end;
|
|
1076
1258
|
substitution(i, end, source.slice(n1 + 1, end - 1), "process");
|
|
1077
1259
|
i = end - 1;
|
|
1078
1260
|
continue;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE table of the words bash's grammar owns — and the builtins that move the working directory — with the part each plays for a reader.
|
|
3
|
+
*
|
|
4
|
+
* "Which word is syntax" is one fact about bash. Every reader that acts on it — the lexer's position walk, the program
|
|
5
|
+
* model, the read plan, the binding walk, the tightening reader, the read-only classifier, the rule model — asks it of
|
|
6
|
+
* THIS table through {@link shellWordsOf} instead of keeping a set of its own. A role is one question a reader asks of
|
|
7
|
+
* a word; a word a reader must know is a row here carrying that role. Adding a keyword is one row.
|
|
8
|
+
*
|
|
9
|
+
* The table holds every SET of words. A reader that tests the spelling of ONE word on its own (the conditional's `[[`
|
|
10
|
+
* and `]]`, the `in` of a loop header, the `for NAME in …; do …; done` shape the poll classifier matches) holds no set
|
|
11
|
+
* and compares it. A test reads the source tree for a second set of the table's words, and for a chain of comparisons
|
|
12
|
+
* that spells one.
|
|
13
|
+
*
|
|
14
|
+
* Measured with `compgen -k`: bash 3.2.57 and 5.3 list the same 21 words, and 5.3 adds `coproc`. The structural roles
|
|
15
|
+
* `control_prefix`, `group` and `block` partition exactly those 22 (3.2 reads `coproc` as a command name; the
|
|
16
|
+
* position walk reads it as syntax all the same — the side that judges more). `((` and `))` are no reserved words:
|
|
17
|
+
* they are the arithmetic command's tokens, kept for the one role that refuses every word which cannot name a program.
|
|
18
|
+
*
|
|
19
|
+
* The table also owns the four builtins that carry the shell's WORKING DIRECTORY — `cd`, `pushd`, `popd`, `dirs` — because
|
|
20
|
+
* "which word moves where a command stands" is the same kind of fact (they are no reserved words, so the structural
|
|
21
|
+
* roles above do not touch them): the working-directory thread reads where a move leads, the rule model asks whether a
|
|
22
|
+
* segment moved the cursor, and the program model's stack rows derive from the same roles. A move word is a row here;
|
|
23
|
+
* none of those readers spells the set. (Which programs the read-only classifier admits is another fact — the reference's
|
|
24
|
+
* read-only command set — and is not a role of this table.)
|
|
25
|
+
*
|
|
26
|
+
* Pure data and a pure projection: this module imports nothing.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SHELL_WORD_ROLES: readonly ["control_prefix", "group", "block", "compound_open", "loop_list_head", "loop_iterates", "loop_condition", "loop_end", "definition", "background", "case_arms", "timer", "scope_open", "scope_close", "scope_switch", "stripped_prefix", "stripped_standalone", "opaque", "rule_reserved", "base_mover", "stack_mover", "stack_editor"];
|
|
29
|
+
export type ShellWordRole = (typeof SHELL_WORD_ROLES)[number];
|
|
30
|
+
/** Every word that plays `role`. The same set object on every call: a projection is a view, not a copy to edit. */
|
|
31
|
+
export declare function shellWordsOf(role: ShellWordRole): ReadonlySet<string>;
|
|
32
|
+
/** The roles one word plays, in {@link SHELL_WORD_ROLES} order; empty for a word the table does not own. */
|
|
33
|
+
export declare function shellWordRolesOf(word: string): readonly ShellWordRole[];
|
|
34
|
+
/** Every word the table owns, in row order. */
|
|
35
|
+
export declare function shellWordTable(): readonly string[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const SHELL_WORD_ROLES = Object.freeze([
|
|
2
|
+
"control_prefix",
|
|
3
|
+
"group",
|
|
4
|
+
"block",
|
|
5
|
+
"compound_open",
|
|
6
|
+
"loop_list_head",
|
|
7
|
+
"loop_iterates",
|
|
8
|
+
"loop_condition",
|
|
9
|
+
"loop_end",
|
|
10
|
+
"definition",
|
|
11
|
+
"background",
|
|
12
|
+
"case_arms",
|
|
13
|
+
"timer",
|
|
14
|
+
"scope_open",
|
|
15
|
+
"scope_close",
|
|
16
|
+
"scope_switch",
|
|
17
|
+
"stripped_prefix",
|
|
18
|
+
"stripped_standalone",
|
|
19
|
+
"opaque",
|
|
20
|
+
"rule_reserved",
|
|
21
|
+
"base_mover",
|
|
22
|
+
"stack_mover",
|
|
23
|
+
"stack_editor",
|
|
24
|
+
]);
|
|
25
|
+
const ROWS = [
|
|
26
|
+
["!", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
27
|
+
["if", "control_prefix", "compound_open", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
28
|
+
["then", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
29
|
+
["elif", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved"],
|
|
30
|
+
["else", "control_prefix", "scope_switch", "stripped_prefix", "rule_reserved"],
|
|
31
|
+
["while", "control_prefix", "compound_open", "loop_condition", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
32
|
+
["until", "control_prefix", "compound_open", "loop_condition", "scope_open", "stripped_prefix", "rule_reserved"],
|
|
33
|
+
["do", "control_prefix", "stripped_prefix", "rule_reserved"],
|
|
34
|
+
["time", "control_prefix", "timer", "rule_reserved"],
|
|
35
|
+
["{", "group", "compound_open", "scope_open", "stripped_standalone", "rule_reserved"],
|
|
36
|
+
["}", "group", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
37
|
+
["for", "block", "compound_open", "loop_list_head", "loop_iterates", "scope_open", "opaque", "rule_reserved"],
|
|
38
|
+
["select", "block", "compound_open", "loop_list_head", "scope_open", "opaque", "rule_reserved"],
|
|
39
|
+
["case", "block", "compound_open", "case_arms", "scope_open", "opaque", "rule_reserved"],
|
|
40
|
+
["esac", "block", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
41
|
+
["fi", "block", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
42
|
+
["done", "block", "loop_end", "scope_close", "stripped_standalone", "rule_reserved"],
|
|
43
|
+
["function", "block", "definition", "opaque", "rule_reserved"],
|
|
44
|
+
["coproc", "block", "background", "opaque", "rule_reserved"],
|
|
45
|
+
["]]", "block", "stripped_standalone", "rule_reserved"],
|
|
46
|
+
["in", "block", "opaque", "rule_reserved"],
|
|
47
|
+
["[[", "block", "compound_open", "rule_reserved"],
|
|
48
|
+
["((", "rule_reserved"],
|
|
49
|
+
["))", "rule_reserved"],
|
|
50
|
+
["cd", "base_mover"],
|
|
51
|
+
["pushd", "base_mover", "stack_mover"],
|
|
52
|
+
["popd", "base_mover", "stack_mover"],
|
|
53
|
+
["dirs", "stack_editor"],
|
|
54
|
+
];
|
|
55
|
+
const PROJECTIONS = new Map(SHELL_WORD_ROLES.map((role) => [role, new Set(ROWS.filter(([, ...roles]) => roles.includes(role)).map(([word]) => word))]));
|
|
56
|
+
export function shellWordsOf(role) {
|
|
57
|
+
return PROJECTIONS.get(role);
|
|
58
|
+
}
|
|
59
|
+
export function shellWordRolesOf(word) {
|
|
60
|
+
const row = ROWS.find(([w]) => w === word);
|
|
61
|
+
return row === undefined ? [] : SHELL_WORD_ROLES.filter((role) => row.includes(role));
|
|
62
|
+
}
|
|
63
|
+
export function shellWordTable() {
|
|
64
|
+
return ROWS.map(([word]) => word);
|
|
65
|
+
}
|
|
@@ -20,11 +20,11 @@ export declare class FileCheckpointStore implements CheckpointStore {
|
|
|
20
20
|
* directory's writer fence and refuses a second OS process by name (see the class header). Serving
|
|
21
21
|
* many writers at once remains Pg/TiDB's job — this refuses the second one, it does not coordinate it. */
|
|
22
22
|
readonly durability: "durable";
|
|
23
|
-
/** Honest declaration on the fidelity axis: the ledger is JSONL, so what
|
|
24
|
-
*
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
/** Honest declaration on the fidelity axis: the ledger is JSONL, so what this backend holds is the JSON
|
|
24
|
+
* PROJECTION of the row — a `Date` reads as its ISO string, a `Map`/`Set` as `{}`, `NaN` as `null`, an
|
|
25
|
+
* `undefined`-valued key not at all — before a restart and after it alike (the live map is filled from the
|
|
26
|
+
* same JSON reading as the ledger line); the declaration is what makes the loss visible to the mint BEFORE the
|
|
27
|
+
* row is filed. */
|
|
28
28
|
readonly fidelity: "json";
|
|
29
29
|
/** F-012 L2: `reopen` here is a real resolved→pending CAS journaled to the ledger — declared, not sniffed. */
|
|
30
30
|
readonly redecision: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
3
3
|
import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "../../core/checkpoint-execution-record.js";
|
|
4
|
-
import { appendPendingSteer, CheckpointError, checkpointOccMatches, checkpointRowMatches, summarizeCheckpoint, validatePendingSteer, winnerFromOutcome, } from "../../core/checkpoint-store.js";
|
|
4
|
+
import { appendPendingSteer, CheckpointError, checkpointOccMatches, checkpointRowMatches, encodeAtFidelity, summarizeCheckpoint, validatePendingSteer, winnerFromOutcome, } from "../../core/checkpoint-store.js";
|
|
5
5
|
import { SharedLedgerTable } from "./shared-ledger.js";
|
|
6
6
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
7
7
|
const CHECKPOINT_LEDGER_EVENT_REGISTRY = {
|
|
@@ -109,7 +109,10 @@ export class FileCheckpointStore {
|
|
|
109
109
|
return this.ledger.withLock(token, fn);
|
|
110
110
|
}
|
|
111
111
|
commit(ev, fsync) {
|
|
112
|
-
this.
|
|
112
|
+
const held = encodeAtFidelity(this.fidelity, ev);
|
|
113
|
+
if (!held.ok)
|
|
114
|
+
throw held.cause;
|
|
115
|
+
this.ledger.commit(held.value, fsync, this.compactEvery);
|
|
113
116
|
}
|
|
114
117
|
async put(token, cp) {
|
|
115
118
|
return this.withLock(token, () => {
|
|
@@ -8,7 +8,6 @@ import { type FileSessionPolicyStoreOptions } from "./session-policy-store.js";
|
|
|
8
8
|
import { type FileFileHistoryStoreOptions } from "./file-history-store.js";
|
|
9
9
|
import type { CorruptReadInfo } from "./corrupt-read-sink.js";
|
|
10
10
|
import type { FileHistoryStore } from "../../core/file-history-store.js";
|
|
11
|
-
import type { StrategyStore } from "../../core/strategy-store.js";
|
|
12
11
|
import type { BackgroundAgentStore } from "../../core/background-agent-store.js";
|
|
13
12
|
import type { MailboxStore } from "../../core/mailbox-store.js";
|
|
14
13
|
import type { RosterStore } from "../../agents/roster-store.js";
|
|
@@ -23,7 +22,6 @@ export { FileSessionPolicyStore, type FileSessionPolicyStoreOptions, type Sessio
|
|
|
23
22
|
export { FileFileHistoryStore, type FileFileHistoryStoreOptions } from "./file-history-store.js";
|
|
24
23
|
export { FileWorkflowJournalStore, MAX_JOURNAL_RESULT_BYTES, oversizeJournalResult } from "./workflow-journal-store.js";
|
|
25
24
|
export { FileUsageWindowStore, type FileUsageWindowStoreOptions } from "./usage-window-store.js";
|
|
26
|
-
export { FileStrategyStore, type FileStrategyStoreOptions } from "./strategy-store.js";
|
|
27
25
|
export { resolveDataRoot, sanitizeScope, sanitizePathComponent, createFileConsolidationLock } from "./fs-atomic.js";
|
|
28
26
|
export { FileStoreLockError, type FileStoreLockErrorCode } from "./fs-atomic.js";
|
|
29
27
|
export { atomicWriteFile, writeThenLink, ensureDir, readJsonlRecords, AppendLog } from "./fs-atomic.js";
|
|
@@ -152,12 +150,6 @@ export declare class FileStorageBackend {
|
|
|
152
150
|
/** design/151 §7 S3c — the durable SendMessage mailbox (tier-3 parking lane), same data root.
|
|
153
151
|
* Wire into `RunnerDeps.mailboxStore` (single-instance pairing, same as above). */
|
|
154
152
|
readonly mailboxStore: MailboxStore;
|
|
155
|
-
/** File-backed teacher-mode strategy repository (`root/strategies`) — pass as
|
|
156
|
-
* `TeacherConfig.strategyStore` (with a `scope`) so escalation strategies survive a restart;
|
|
157
|
-
* the in-memory default forgets everything each process, which zeroes the cross-session reuse
|
|
158
|
-
* the repository exists for. Aggregated here so the TOC full-persistence assembly stays one
|
|
159
|
-
* constructor (the same half-wiring hazard as the delegation trio). */
|
|
160
|
-
readonly strategyStore: StrategyStore;
|
|
161
153
|
/** design/147 S1c — the durable name→agent roster (layer 0.5 resolution), `root/roster.json`.
|
|
162
154
|
* Wire into `RunnerDeps.rosterStore` so name-addressing survives a restart alongside the rows. */
|
|
163
155
|
readonly rosterStore: RosterStore;
|