@sema-agent/core 7.47.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 +472 -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 +39 -32
- 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 +95 -66
- 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-server-spec.d.ts +1 -1
- 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/park-commit.d.ts +1 -1
- 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/safety-axis-vocab.d.ts +1 -1
- package/dist/core/safety-merge-corpus.d.ts +1 -1
- 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-policy-store.d.ts +6 -3
- package/dist/core/session-policy-store.js +28 -10
- 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/shell-wrapper-table.d.ts +2 -2
- package/dist/core/shell-wrapper-table.js +1 -1
- 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 +35 -10
- package/dist/core/tool-name-aliases.js +15 -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 -381
- 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 +191 -119
- package/dist/prompt-assembly/types.d.ts +1 -1
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/shell/lex.d.ts +0 -21
- package/dist/shell/lex.js +278 -70
- 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 +17 -3
- package/dist/tools/fs/bash-program-position.js +25 -10
- 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 +3 -2
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/program-read-model.d.ts +99 -23
- package/dist/tools/fs/program-read-model.js +129 -55
- package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
- package/dist/tools/fs/program-read-model.rows.js +18 -10
- package/dist/tools/fs/read-deny-home.d.ts +35 -30
- package/dist/tools/fs/read-deny-home.js +45 -38
- package/dist/tools/fs/read-deny.d.ts +35 -27
- package/dist/tools/fs/read-deny.js +126 -92
- package/dist/tools/fs/removal-targets.d.ts +56 -23
- package/dist/tools/fs/removal-targets.js +74 -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.d.ts +4 -7
- package/dist/tools/fs/shell-read-argv.js +6 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +203 -46
- package/dist/tools/fs/shell-read-bindings.js +488 -144
- 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 +9 -10
- 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 +13 -20
- package/dist/tools/fs/shell-read-plan.js +200 -194
- package/dist/tools/fs/shell-read-start.d.ts +80 -0
- package/dist/tools/fs/shell-read-start.js +99 -0
- package/dist/tools/fs/shell-read-word.d.ts +35 -6
- package/dist/tools/fs/shell-read-word.js +89 -9
- 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 +26 -26
- package/dist/tools/fs/shell-reentry-text.js +31 -34
- 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.48.0.json +252 -0
- 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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { sliceHeadSafe, sliceTailSafe } from "../../core/surrogate-safe-slice.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isAbsoluteForFamily, normalizeAbsPathLexically, pathFamilyOf, pathIdentityOf, spellingOfIdentity } from "./safety.js";
|
|
3
3
|
import { PROBE_REASON_MAX } from "../../core/untrusted-text.js";
|
|
4
|
+
import { validatePath } from "../../core/effective-path-target.js";
|
|
5
|
+
import { judgePathRows } from "../../core/path-guard-rows.js";
|
|
4
6
|
export const READ_DENY_HOME_WORD = "~";
|
|
5
7
|
export function readDenyPatternRun(pattern) {
|
|
6
8
|
const segments = pattern.split("/").filter(Boolean);
|
|
@@ -15,28 +17,12 @@ export const DENY_FACES = Object.freeze(["read", "write"]);
|
|
|
15
17
|
const REACHED = { reach: "reached" };
|
|
16
18
|
const NOT_REACHED = { reach: "not_reached" };
|
|
17
19
|
const reachOf = (row, spelled) => row.reach?.(spelled) ?? (row.reaches(spelled) ? REACHED : NOT_REACHED);
|
|
18
|
-
export function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return { row };
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
let held;
|
|
28
|
-
for (const row of rows) {
|
|
29
|
-
if (views.unreadable !== undefined)
|
|
30
|
-
held ??= { row, unreadable: views.unreadable };
|
|
31
|
-
for (const view of views.spellings) {
|
|
32
|
-
const r = reachOf(row, view);
|
|
33
|
-
if (r.reach === "reached")
|
|
34
|
-
return { row, view };
|
|
35
|
-
if (r.reach === "unreadable")
|
|
36
|
-
held ??= { row, unreadable: r.reason };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return held;
|
|
20
|
+
export function judgeRuleRows(rows, views, direction) {
|
|
21
|
+
const hit = judgePathRows(rows.map(ruleGuard), views, direction);
|
|
22
|
+
return hit === undefined ? undefined : { ...hit, row: hit.row.rule };
|
|
23
|
+
}
|
|
24
|
+
function ruleGuard(rule) {
|
|
25
|
+
return { rule, reach: (view) => reachOf(rule, view.path) };
|
|
40
26
|
}
|
|
41
27
|
export function ruleHeadParts(rows) {
|
|
42
28
|
const out = new Set();
|
|
@@ -130,34 +116,42 @@ function rowLedTo(row, head, at) {
|
|
|
130
116
|
: {}),
|
|
131
117
|
};
|
|
132
118
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
export function ruleGuardRow(rule) {
|
|
120
|
+
return { rule, name: rule.rule, grammar: { kind: "rule", rule: rule.rule }, polarity: "deny", faces: rule.faces, placement: "anywhere", fold: "exact", exemptible: false, origin: "rule", reach: (view) => reachOf(rule, view.path) };
|
|
121
|
+
}
|
|
122
|
+
export function segmentGuardRow(pat, columns) {
|
|
123
|
+
const placement = pat.anchors === undefined ? "anywhere" : pat.rootedOnly !== true ? "home" : pat.anchors.length === 1 && pat.anchors[0].length === 0 ? "rooted" : { below: `/${(pat.anchors[0] ?? []).join("/")}` };
|
|
124
|
+
return {
|
|
125
|
+
name: pat.raw,
|
|
126
|
+
grammar: { kind: "segment-glob", run: pat.raw },
|
|
127
|
+
placement,
|
|
128
|
+
...columns,
|
|
129
|
+
reach: (view) => (segmentRowMeets(pat, segmentReadingsOf(view.path, view.aliasResolved === true)) ? REACHED : NOT_REACHED),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function denyTableHit(rows, views) {
|
|
133
|
+
const hit = judgePathRows(rows, views, "tighten");
|
|
134
|
+
if (hit === undefined)
|
|
135
|
+
return null;
|
|
136
|
+
const view = hit.view ?? views.views[0]?.path;
|
|
137
|
+
return { pattern: hit.row.name, ...(view !== undefined ? { matchedView: view } : {}) };
|
|
138
|
+
}
|
|
139
|
+
function denyTargetViews(canonicalKey, lexicalView, opts) {
|
|
140
|
+
const views = [{ path: canonicalKey, kind: "canonical", ...(opts?.aliasResolved === true ? { aliasResolved: true } : {}) }];
|
|
141
|
+
if (lexicalView !== undefined)
|
|
142
|
+
views.push({ path: lexicalView, kind: "lexical" });
|
|
143
|
+
for (const hop of opts?.hops ?? [])
|
|
144
|
+
views.push({ path: hop, kind: "hop" });
|
|
145
|
+
return { views };
|
|
136
146
|
}
|
|
137
147
|
export function compileWriteDeny(rules = []) {
|
|
138
148
|
const ruleRows = rules.filter((r) => r.faces.includes("write"));
|
|
149
|
+
const rows = ruleRows.map(ruleGuardRow);
|
|
139
150
|
const matchPath = (path) => {
|
|
140
|
-
const hit =
|
|
141
|
-
return hit ===
|
|
151
|
+
const hit = denyTableHit(rows, { views: [{ path, kind: "lexical" }] });
|
|
152
|
+
return hit === null ? null : { pattern: hit.pattern };
|
|
142
153
|
};
|
|
143
|
-
return { face: "write", ruleRows, matchPath, matchTarget: (canonicalKey, lexicalView, opts) =>
|
|
144
|
-
}
|
|
145
|
-
function matchTargetOver(segmentPath, ruleRows, face, canonicalKey, lexicalView, opts) {
|
|
146
|
-
const canonical = segmentPath(canonicalKey, opts);
|
|
147
|
-
if (canonical !== null)
|
|
148
|
-
return { ...canonical, matchedView: canonicalKey };
|
|
149
|
-
if (lexicalView !== undefined) {
|
|
150
|
-
const lexical = segmentPath(lexicalView);
|
|
151
|
-
if (lexical !== null)
|
|
152
|
-
return { ...lexical, matchedView: lexicalView };
|
|
153
|
-
}
|
|
154
|
-
for (const hop of opts?.hops ?? []) {
|
|
155
|
-
const viaHop = segmentPath(hop);
|
|
156
|
-
if (viaHop !== null)
|
|
157
|
-
return { ...viaHop, matchedView: hop };
|
|
158
|
-
}
|
|
159
|
-
const hit = ruleRowsHit(ruleRows, face, [canonicalKey, ...(lexicalView !== undefined ? [lexicalView] : []), ...(opts?.hops ?? [])]);
|
|
160
|
-
return hit === undefined ? null : { pattern: hit.row.rule, matchedView: hit.view ?? canonicalKey };
|
|
154
|
+
return { face: "write", ruleRows, matchPath, matchTarget: (canonicalKey, lexicalView, opts) => denyTableHit(rows, denyTargetViews(canonicalKey, lexicalView, opts)) };
|
|
161
155
|
}
|
|
162
156
|
export function readDenySeat(matcher) {
|
|
163
157
|
const entries = [...(matcher?.entries ?? []).map((e) => e.pattern), ...(matcher?.ruleRows ?? []).map((r) => r.rule)];
|
|
@@ -320,28 +314,43 @@ export function compileSegmentPattern(raw, fold) {
|
|
|
320
314
|
return { raw, segments, foldAscii: fold === "ascii" };
|
|
321
315
|
}
|
|
322
316
|
export function matchSegmentPatterns(path, compiled, opts) {
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
317
|
+
const readings = segmentReadingsOf(path, opts?.aliasResolved === true);
|
|
318
|
+
for (const pat of compiled)
|
|
319
|
+
if (segmentRowMeets(pat, readings))
|
|
320
|
+
return pat.raw;
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
const SEGMENT_READINGS = new Map();
|
|
324
|
+
function segmentReadingsOf(path, aliasResolved) {
|
|
325
|
+
const key = `${aliasResolved ? "1" : "0"}${path}`;
|
|
326
|
+
const known = SEGMENT_READINGS.get(key);
|
|
327
|
+
if (known !== undefined)
|
|
328
|
+
return known;
|
|
329
|
+
const views = segmentViewsOf(path, aliasResolved ? { aliasResolved } : undefined);
|
|
330
|
+
const readings = { views, lowered: views.map((v) => v.map(asciiLower)), rooted: isAbsoluteForFamily("own", path) };
|
|
331
|
+
if (SEGMENT_READINGS.size >= 512)
|
|
332
|
+
SEGMENT_READINGS.clear();
|
|
333
|
+
SEGMENT_READINGS.set(key, readings);
|
|
334
|
+
return readings;
|
|
335
|
+
}
|
|
336
|
+
function segmentRowMeets(pat, readings) {
|
|
337
|
+
const n = pat.segments.length;
|
|
338
|
+
const views = pat.foldAscii ? readings.lowered : readings.views;
|
|
339
|
+
for (const segs of views) {
|
|
340
|
+
const runAt = (i) => i + n <= segs.length && pat.segments.every((re, j) => re.test(segs[i + j] ?? ""));
|
|
341
|
+
if (pat.anchors !== undefined && readings.rooted) {
|
|
342
|
+
for (const anchor of pat.anchors)
|
|
343
|
+
if (anchor.every((a, j) => segs[j] === a) && runAt(anchor.length))
|
|
344
|
+
return true;
|
|
345
|
+
continue;
|
|
342
346
|
}
|
|
347
|
+
if (pat.rootedOnly === true)
|
|
348
|
+
continue;
|
|
349
|
+
for (let i = 0; i + n <= segs.length; i++)
|
|
350
|
+
if (runAt(i))
|
|
351
|
+
return true;
|
|
343
352
|
}
|
|
344
|
-
return
|
|
353
|
+
return false;
|
|
345
354
|
}
|
|
346
355
|
function segmentViewsOf(path, opts) {
|
|
347
356
|
const literalSegs = path.split(/[\\/]/).filter(Boolean);
|
|
@@ -386,7 +395,7 @@ function rowMeetsPath(pat, segs, rooted) {
|
|
|
386
395
|
return false;
|
|
387
396
|
}
|
|
388
397
|
function rowAtOrBelowOf(rows, path) {
|
|
389
|
-
const rooted =
|
|
398
|
+
const rooted = isAbsoluteForFamily("own", path);
|
|
390
399
|
const views = segmentViewsOf(path);
|
|
391
400
|
for (const pat of rows) {
|
|
392
401
|
for (const view of views)
|
|
@@ -401,6 +410,15 @@ function homeAnchorSegments(home) {
|
|
|
401
410
|
function rgGlobEscape(pattern) {
|
|
402
411
|
return pattern.replace(/[?[\]{}]/g, (c) => `[${c}]`);
|
|
403
412
|
}
|
|
413
|
+
export function readDenyEntryProblem(entry, layer) {
|
|
414
|
+
try {
|
|
415
|
+
normalizeEntry(entry, layer);
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
418
|
+
catch (e) {
|
|
419
|
+
return e.message;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
404
422
|
function normalizeEntry(entry, layer) {
|
|
405
423
|
const shape = typeof entry === "string" ? { pattern: entry, caseSensitive: false } : entry;
|
|
406
424
|
if (typeof shape !== "object" || shape === null || typeof shape.pattern !== "string") {
|
|
@@ -418,7 +436,14 @@ function normalizeEntry(entry, layer) {
|
|
|
418
436
|
throw new Error(`readDenyPatterns (${layer}): pattern ${JSON.stringify(shape.pattern)} contains no path segments${homeAnchored ? " below the home word" : ""} and would ${homeAnchored ? "name the whole home directory" : "deny nothing"}. ` +
|
|
419
437
|
`Patterns are "/"-separated runs of path SEGMENTS (e.g. ".ssh", ".config/gcloud", "id_rsa*", "~/.sema/settings.json"); remove the entry or spell the segments.`);
|
|
420
438
|
}
|
|
421
|
-
return { pattern:
|
|
439
|
+
return { pattern: canonicalReadDenyPattern(shape.pattern), caseSensitive: shape.caseSensitive === true };
|
|
440
|
+
}
|
|
441
|
+
function canonicalReadDenyPattern(pattern) {
|
|
442
|
+
const joined = pattern.split("/").filter(Boolean).join("/");
|
|
443
|
+
return pattern.startsWith("/") && !readDenyPatternRun(joined).homeAnchored ? `/${joined}` : joined;
|
|
444
|
+
}
|
|
445
|
+
export function isRootedReadDenyPattern(canonical) {
|
|
446
|
+
return canonical.startsWith("/");
|
|
422
447
|
}
|
|
423
448
|
export function persistedReadDenyEntryProblem(e) {
|
|
424
449
|
if (typeof e !== "object" || e === null)
|
|
@@ -434,12 +459,12 @@ export function persistedReadDenyEntryProblem(e) {
|
|
|
434
459
|
const segments = pattern.split("/").filter(Boolean);
|
|
435
460
|
if (readDenyPatternRun(segments.join("/")).run.length === 0)
|
|
436
461
|
return "pattern has no path segments";
|
|
437
|
-
if (
|
|
462
|
+
if (canonicalReadDenyPattern(pattern) !== pattern)
|
|
438
463
|
return "pattern is not in canonical a/b form";
|
|
439
464
|
return null;
|
|
440
465
|
}
|
|
441
466
|
export function checkedReadDenyHomes(homes, seat = "readDenyHomes") {
|
|
442
|
-
if (!Array.isArray(homes) || !homes.every((h) =>
|
|
467
|
+
if (!Array.isArray(homes) || !homes.every((h) => validatePath(h, { intent: "validate-coordinate" }) !== undefined)) {
|
|
443
468
|
let shown;
|
|
444
469
|
try {
|
|
445
470
|
shown = JSON.stringify(homes) ?? String(homes);
|
|
@@ -462,10 +487,19 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
462
487
|
seen.add(key);
|
|
463
488
|
normalized.push(e);
|
|
464
489
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
push(
|
|
490
|
+
const columns = new Map();
|
|
491
|
+
for (const row of resolveReadDenyBuiltins(builtin)) {
|
|
492
|
+
const e = normalizeEntry(row.pattern, "built-in");
|
|
493
|
+
push(e);
|
|
494
|
+
if (!columns.has(e.pattern))
|
|
495
|
+
columns.set(e.pattern, { origin: "builtin", tier: row.tier });
|
|
496
|
+
}
|
|
497
|
+
for (const entry of additions) {
|
|
498
|
+
const e = normalizeEntry(entry, layer);
|
|
499
|
+
push(e);
|
|
500
|
+
if (!columns.has(e.pattern))
|
|
501
|
+
columns.set(e.pattern, { origin: "addition" });
|
|
502
|
+
}
|
|
469
503
|
const homeSegments = [...new Set(checkedReadDenyHomes(homes))].map(homeAnchorSegments);
|
|
470
504
|
const compiled = normalized.map((e) => {
|
|
471
505
|
const { homeAnchored, run } = readDenyPatternRun(e.pattern);
|
|
@@ -473,6 +507,8 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
473
507
|
const c = compileSegmentPattern(run, fold);
|
|
474
508
|
if (c === null)
|
|
475
509
|
throw new Error(`readDenyPatterns: pattern ${JSON.stringify(e.pattern)} compiled to zero segments.`);
|
|
510
|
+
if (isRootedReadDenyPattern(e.pattern))
|
|
511
|
+
return { ...c, raw: e.pattern, anchors: [[]], rootedOnly: true };
|
|
476
512
|
if (!homeAnchored || homeSegments.length === 0)
|
|
477
513
|
return { ...c, raw: e.pattern };
|
|
478
514
|
return { ...c, raw: e.pattern, anchors: homeSegments.map((segs) => (fold === "ascii" ? segs.map(asciiLower) : segs)) };
|
|
@@ -483,7 +519,7 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
483
519
|
normalized.forEach((e, i) => {
|
|
484
520
|
const locations = linked.get(e.pattern);
|
|
485
521
|
const { homeAnchored, run } = readDenyPatternRun(e.pattern);
|
|
486
|
-
if (locations === undefined || !homeAnchored)
|
|
522
|
+
if (locations === undefined || !(homeAnchored || isRootedReadDenyPattern(e.pattern)))
|
|
487
523
|
return;
|
|
488
524
|
const c = compiled[i];
|
|
489
525
|
const rest = c.segments.slice(readDenyRunHead(run));
|
|
@@ -493,40 +529,38 @@ export function compileReadDeny(additions = [], layer = "additions", builtin, ru
|
|
|
493
529
|
}
|
|
494
530
|
});
|
|
495
531
|
const judged = linkedPlacements.length === 0 ? compiled : [...compiled, ...linkedPlacements];
|
|
532
|
+
const segmentRows = judged.map((c) => {
|
|
533
|
+
const col = columns.get(c.raw);
|
|
534
|
+
return segmentGuardRow(c, { faces: ["read"], polarity: "deny", exemptible: false, fold: c.foldAscii ? "ascii" : "exact", origin: col?.origin ?? "addition", ...(col?.tier !== undefined ? { tier: col.tier } : {}) });
|
|
535
|
+
});
|
|
536
|
+
const tableRows = [...segmentRows, ...ruleRows.map(ruleGuardRow)];
|
|
496
537
|
const rgExclusionGlobs = [];
|
|
497
538
|
const rgProbeGlobs = [];
|
|
498
|
-
|
|
499
|
-
if (
|
|
500
|
-
|
|
501
|
-
const flag =
|
|
502
|
-
const g = rgGlobEscape(readDenyPatternRun(
|
|
539
|
+
for (const row of segmentRows) {
|
|
540
|
+
if (row.placement !== "anywhere" || !row.faces.includes("read") || row.grammar.kind !== "segment-glob")
|
|
541
|
+
continue;
|
|
542
|
+
const flag = row.fold === "exact" ? "--glob" : "--iglob";
|
|
543
|
+
const g = rgGlobEscape(readDenyPatternRun(row.grammar.run).run);
|
|
503
544
|
rgExclusionGlobs.push({ flag, glob: `!**/${g}` }, { flag, glob: `!**/${g}/**` });
|
|
504
545
|
rgProbeGlobs.push({ flag, glob: `**/${g}` }, { flag, glob: `**/${g}/**` });
|
|
505
|
-
}
|
|
546
|
+
}
|
|
506
547
|
const placed = judged.filter((c) => c.anchors !== undefined);
|
|
507
|
-
const unexcludableUnder = (scope) => placed.length > 0 && (!
|
|
548
|
+
const unexcludableUnder = (scope) => placed.length > 0 && (!isAbsoluteForFamily("own", scope) || rowAtOrBelowOf(placed, normalizeAbsPathLexically(scope)) !== null);
|
|
508
549
|
const rowAtOrBelow = (path) => {
|
|
509
550
|
const hit = rowAtOrBelowOf(judged, path);
|
|
510
551
|
if (hit !== null)
|
|
511
552
|
return { pattern: hit };
|
|
512
553
|
return ruleRows.length === 0 ? null : { pattern: ruleRows[0].rule };
|
|
513
554
|
};
|
|
514
|
-
const segmentPath = (path, opts) => {
|
|
515
|
-
const hit = matchSegmentPatterns(path, judged, opts);
|
|
516
|
-
return hit === null ? null : { pattern: hit };
|
|
517
|
-
};
|
|
518
555
|
const matchPath = (path, opts) => {
|
|
519
|
-
const hit =
|
|
520
|
-
|
|
521
|
-
return hit;
|
|
522
|
-
const rule = ruleRows.length === 0 || opts?.walked === true ? undefined : ruleRowsHit(ruleRows, "read", [path]);
|
|
523
|
-
return rule === undefined ? null : { pattern: rule.row.rule };
|
|
556
|
+
const hit = denyTableHit(opts?.walked === true ? segmentRows : tableRows, { views: [{ path, kind: "lexical", ...(opts?.aliasResolved === true ? { aliasResolved: true } : {}) }] });
|
|
557
|
+
return hit === null ? null : { pattern: hit.pattern };
|
|
524
558
|
};
|
|
525
559
|
return {
|
|
526
560
|
entries: normalized,
|
|
527
561
|
...(ruleRows.length > 0 ? { ruleRows } : {}),
|
|
528
562
|
matchPath,
|
|
529
|
-
matchTarget: (canonicalKey, lexicalView, opts) =>
|
|
563
|
+
matchTarget: (canonicalKey, lexicalView, opts) => denyTableHit(tableRows, denyTargetViews(canonicalKey, lexicalView, opts)),
|
|
530
564
|
rgExclusionGlobs,
|
|
531
565
|
rgProbeGlobs,
|
|
532
566
|
unexcludableUnder,
|
|
@@ -5,17 +5,15 @@ import type { ToolCallRequest } from "../../core/tool-policy.js";
|
|
|
5
5
|
* recursive option (removing an empty home or the task root is still removing it). */
|
|
6
6
|
export declare const SHELL_REMOVAL_COMMANDS: readonly ["rm", "rmdir"];
|
|
7
7
|
export type ShellRemovalCommand = (typeof SHELL_REMOVAL_COMMANDS)[number];
|
|
8
|
-
/** What makes a removal target dangerous, in the order a card names it.
|
|
9
|
-
|
|
10
|
-
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level" | "runtime_script";
|
|
8
|
+
/** What makes a removal target dangerous, in the order a card names it. */
|
|
9
|
+
export type DangerousRemovalKind = "filesystem_root" | "home" | "workspace" | "top_level";
|
|
11
10
|
/** The protected locations a removal is judged against. `homes`: the environment's declared home and every other spelling
|
|
12
11
|
* of it (its canonical one); `workspace`: the task root, the working directory, the additional working directories. */
|
|
13
12
|
export interface RemovalSeat {
|
|
14
13
|
readonly homes: readonly string[];
|
|
15
14
|
readonly workspace: readonly string[];
|
|
16
15
|
}
|
|
17
|
-
/** One dangerous removal a command makes: the program
|
|
18
|
-
* to), the operand as written, the target as established (the script word as written, for `runtime_script`). */
|
|
16
|
+
/** One dangerous removal a command makes: the removal program, the operand as written, the target as established. */
|
|
19
17
|
export interface DangerousRemoval {
|
|
20
18
|
readonly kind: DangerousRemovalKind;
|
|
21
19
|
readonly program: string;
|
|
@@ -30,33 +28,64 @@ export interface DangerousRemoval {
|
|
|
30
28
|
* directory (one segment below the root). `undefined` for a relative path or any other target.
|
|
31
29
|
*/
|
|
32
30
|
export declare function dangerousRemovalOf(path: string, seat: RemovalSeat): DangerousRemovalKind | undefined;
|
|
33
|
-
/** What one removal finding asks: a protected location (`dangerous_delete`
|
|
34
|
-
*
|
|
31
|
+
/** What one removal finding asks: a protected location (`dangerous_delete`; `untrackedFrom` — the segment the working
|
|
32
|
+
* directory stops being tracked at, where the target is relative and was judged where the text stood then); a recursive
|
|
33
|
+
* forced removal whose target the
|
|
34
|
+
* guard cannot verify (`unverifiable_delete`) — an operand the shell rewrites from a value the plan does not settle
|
|
35
|
+
* (`rewritten`), the operands of a removal its argv stream fills in (`stream`), or an operand relative to the directory a
|
|
36
|
+
* launcher option moved the removal into (`relocated`); or a shell handed text the engine cannot read
|
|
37
|
+
* (`unverifiable_shell_text`) — a text a program produces (`produced`: what a pipe or a `<(…)` carries, an argv a stream
|
|
38
|
+
* fills in, a substitution), or a text nobody read (`unread`: one the lexer could not read at all, {@link unreadPlan}, or a
|
|
39
|
+
* segment whose program the walk could not name, {@link programUnread}). */
|
|
35
40
|
export type RemovalFinding = (DangerousRemoval & {
|
|
36
41
|
readonly guard: "dangerous_delete";
|
|
42
|
+
readonly untrackedFrom?: string;
|
|
37
43
|
}) | {
|
|
38
44
|
readonly guard: "unverifiable_delete";
|
|
39
45
|
readonly program: string;
|
|
40
46
|
readonly operand: string;
|
|
41
|
-
readonly
|
|
47
|
+
readonly source: "rewritten" | "stream" | "relocated";
|
|
48
|
+
} | {
|
|
49
|
+
readonly guard: "unverifiable_shell_text";
|
|
50
|
+
readonly program: string;
|
|
51
|
+
readonly text: string;
|
|
52
|
+
readonly source: "produced" | "unread";
|
|
42
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* The names a removal target may be built on and still be verified: a root the SHELL provides, never one a command's
|
|
56
|
+
* output fed — `rm -rf "$TMPDIR"/<literal path below it>` is not asked about. `TMPDIR` is the reference's carve-out (its
|
|
57
|
+
* rule exempts "a well-known-safe temp pattern"); `HOME` is sema's (a registered divergence, looser than the reference,
|
|
58
|
+
* whose rule names `$HOME` as the blast radius: it is a root the shell provides too). A declared home is read by the
|
|
59
|
+
* value table itself — `$HOME` is then its value, and the target is judged where it lands; `PWD` is no root of this kind:
|
|
60
|
+
* its value is where the working-directory thread says the command stands.
|
|
61
|
+
*/
|
|
62
|
+
export declare const KNOWN_SAFE_ROOTS: readonly string[];
|
|
43
63
|
/**
|
|
44
64
|
* The removal findings of an established plan — ONE walk, nested plans included (a `bash -c` / `sh -c` text, a substitution
|
|
45
65
|
* body), two words. For every `rm` / `rmdir` segment, each of its OPERANDS (every write target that is not one of its
|
|
46
66
|
* option words: a word some implementation's reading of the program's row writes, {@link writeReadings}) as the plan
|
|
47
67
|
* established it on the WRITE face (the entry the program unlinks, and the deny-floor shadow of a home word the plan did
|
|
48
|
-
* not place) is judged by {@link dangerousRemovalOf}
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* of
|
|
68
|
+
* not place) is judged by {@link dangerousRemovalOf}. In a recursive forced removal ({@link recursiveForce}), an operand
|
|
69
|
+
* the shell rewrites from a value the plan's table does not settle — a name with no value here or one set in a form the
|
|
70
|
+
* table cannot read, a substitution, a parameter operator, a positional parameter — is an unverifiable target, save a
|
|
71
|
+
* literal path below a known-safe root the shell still provides there ({@link belowKnownSafeRoot}); so are the operands
|
|
72
|
+
* of a removal its argv stream fills in (`… | xargs rm -rf`), and an operand the plan cannot place — in a removal a
|
|
73
|
+
* launcher moved into another base, or in text such a removal hands a shell (`env -C <dir> rm -rf build`). A relative
|
|
74
|
+
* operand past a directory move the working-directory thread cannot follow is judged where the text stood when it lost
|
|
75
|
+
* track (the reference resolves it against the original working directory: KL-1403-b), and a card it earns says so. A `read` fills its name from the input: a value
|
|
76
|
+
* the table does not settle (stricter than the reference, whose rule counts `read VAR` as an in-window assignment). A
|
|
77
|
+
* name the table settles is its value, so `D=./build; rm -rf "$D/../build"` is judged
|
|
78
|
+
* where it lands, as `rm -rf ./build` is. A shell handed a text the engine cannot read — one a program produces
|
|
79
|
+
* ({@link runtimeScriptOf}), or one nobody read ({@link unreadPlan}, {@link programUnread}) — is an unreadable text of its
|
|
80
|
+
* own. The read-face copy of an operand is not judged: it follows a link the removal does not follow.
|
|
53
81
|
*/
|
|
54
|
-
export declare function removalFindingsOf(established: EstablishedPlan, seat: RemovalSeat): RemovalFinding[];
|
|
55
|
-
/** Does
|
|
56
|
-
*
|
|
82
|
+
export declare function removalFindingsOf(established: EstablishedPlan, seat: RemovalSeat, safeRoots?: readonly string[], enclosingRelocated?: boolean): RemovalFinding[];
|
|
83
|
+
/** Does this plan (nested plans included) run a removal program, hand a shell a script built when it runs, or hold text
|
|
84
|
+
* nobody could read ({@link unreadPlan}, {@link programUnread})? The guard establishes nothing for a command that does none. */
|
|
57
85
|
export declare function planRunsRemoval(plan: EstablishedPlan["plan"]): boolean;
|
|
58
86
|
/** What the removal guard asks for one command: the guard word and its sentence's account — the first protected location
|
|
59
|
-
* (the program, the location, the target), else the first
|
|
87
|
+
* (the program, the location, the target), else the first target the guard cannot verify, else the first shell text the
|
|
88
|
+
* engine cannot read; `undefined` when none. */
|
|
60
89
|
export interface RemovalVerdict {
|
|
61
90
|
readonly guard: RemovalFinding["guard"];
|
|
62
91
|
readonly text: string;
|
|
@@ -72,12 +101,16 @@ export interface RemovalGuardSeat {
|
|
|
72
101
|
readonly additionalRoots?: () => readonly string[];
|
|
73
102
|
}
|
|
74
103
|
/**
|
|
75
|
-
* The
|
|
76
|
-
* removal program
|
|
77
|
-
* the
|
|
78
|
-
*
|
|
79
|
-
*
|
|
104
|
+
* The removal guard's READING of one command — undefined when no segment of it (nested shell text included) runs a
|
|
105
|
+
* removal program or hands a shell a script built when it runs, and every text in it was read, so a command that removes
|
|
106
|
+
* nothing costs the gate no suspension (a text the lexer could not read is not one: bash may run the lines before its
|
|
107
|
+
* syntax error, and the guard reads no prefix of it). Otherwise `judge` establishes the plan the read
|
|
108
|
+
* station plans (the same planner, the same value table, the same write-target reading) lexically against the request's
|
|
109
|
+
* `cwd` and the seat's home, and — where an environment is seated — through its resolver too, and returns what either
|
|
110
|
+
* establishment finds ({@link removalFindingsOf}: the protected-location word first, then the unverifiable target, then the
|
|
111
|
+
* unreadable text).
|
|
112
|
+
* `safeRoots`: the known-safe roots ({@link KNOWN_SAFE_ROOTS}, with a deployment's own added by the policy).
|
|
80
113
|
*/
|
|
81
|
-
export declare function removalReadingOf(command: string, req: Pick<ToolCallRequest, "cwd" | "root">, seat: RemovalGuardSeat | undefined): {
|
|
114
|
+
export declare function removalReadingOf(command: string, req: Pick<ToolCallRequest, "cwd" | "root">, seat: RemovalGuardSeat | undefined, safeRoots?: readonly string[]): {
|
|
82
115
|
judge(signal?: AbortSignal): Promise<RemovalVerdict | undefined>;
|
|
83
116
|
} | undefined;
|