@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- 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.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -10,15 +10,19 @@
|
|
|
10
10
|
* {@link isNamespaceCredentialName} — the engine's own slots are no one else's to hand on), a list is exactly the names it
|
|
11
11
|
* lists. Whatever the policy, an entry that is one of the engine's own credentials is never inherited:
|
|
12
12
|
* its name is one the deployment declared, or its value equals a credential value the deployment declared or the
|
|
13
|
-
* engine holds ({@link declareWithheldEnv}, {@link holdOwnCredentialValues}). One judgment per variable
|
|
14
|
-
*
|
|
13
|
+
* engine holds ({@link declareWithheldEnv}, {@link holdOwnCredentialValues}). One judgment per variable and policy
|
|
14
|
+
* ({@link judgeInheritedEntries}) — the first rule that answers:
|
|
15
|
+
* 1. exempt — git's environment config and the proxy variables, handed on as written by the shape rules ({@link isExemptEnvName});
|
|
15
16
|
* 2. `exact-name` — a known credential name (the vocabulary's exact env names);
|
|
16
17
|
* 3. `prefix-rule` — the OpenTelemetry settings ({@link OTEL_ENV_RE});
|
|
17
18
|
* 4. `namespace-rule` — a credential word as any segment of a name in the engine's own `SEMA_` namespace;
|
|
18
19
|
* 5. `name-rule` — a credential-shaped name ({@link nameIsCredentialShaped}) off the vocabulary's non-secret exact names;
|
|
19
|
-
* 6. `value-rule` — a value that carries a credential ({@link looksLikeCredentialValue})
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* 6. `value-rule` — a value that carries a credential ({@link looksLikeCredentialValue});
|
|
21
|
+
* 7. `own-credential` — one of the engine's own credentials: no policy hands it on;
|
|
22
|
+
* 8. `peer-held` — a variable held for a protocol peer.
|
|
23
|
+
* Rules 1–6 are the shape rules ({@link classifySecretEnvEntry}): 2–5 its name half ({@link isSensitiveName}), 6 its value half, 1 the
|
|
24
|
+
* env-entry exemption read before both. The scrub reads 1–8; `"all"` reads 4 and 7; a list reads 7. {@link isSecretEnvKey} and
|
|
25
|
+
* {@link scrubSecretEnv} — what a host asks — answer with the scrub's judgment the composition reads, over the tables as they stand. The exempt families, the
|
|
22
26
|
* credential names, the name shape and the value predicate follow the reference implementation's subprocess-env scrub
|
|
23
27
|
* as written, three ways stricter: plural `TOKENS` is a credential word unless a count word touches it, the GitHub
|
|
24
28
|
* token names are not held back from the name shape, and the name shape always runs.
|
|
@@ -26,16 +30,24 @@
|
|
|
26
30
|
import { type RedactionConfidence, type RedactionSource } from "@sema-agent/primitives";
|
|
27
31
|
import { type EngineNotice } from "./engine-notice.js";
|
|
28
32
|
import type { ToolAxesSurface } from "./mcp-server-spec.js";
|
|
33
|
+
/** THE namespace rule: is `name` a credential slot of the engine's own namespace? A name there with a credential word in any
|
|
34
|
+
* segment (`SEMA_MODEL_KEY_<entry>`, `SEMA_WEBSEARCH_KEY_<provider>`) is the engine's own credential by construction, read only
|
|
35
|
+
* inside this process, so neither `"scrub"` nor `"all"` hands it to a child (an allow list naming it does: that is the host's
|
|
36
|
+
* own statement). It judges by segment, so a path or count setting with a credential word in its name is caught too (KL-1099a).
|
|
37
|
+
* Read by the name judgment ({@link sensitiveNameKind}, the `"scrub"` policy) and by the `"all"` policy's arm ({@link policyArm}),
|
|
38
|
+
* and exported from the package root: a host judging a name it hands a child itself asks the question the `"all"` arm asks. */
|
|
39
|
+
export declare function isNamespaceCredentialName(name: string): boolean;
|
|
29
40
|
/** Does a value carry a credential? A URL userinfo (after every `scheme://`, and a leading `//`) with a password or a
|
|
30
41
|
* token-like user; a userinfo with no `//` in front of it the vocabulary reads; a credential assignment; a webhook URL; a Sonar login; a
|
|
31
42
|
* private-key header; an `Authorization` header, `token …`, `Bearer …` or `Basic …` with credential-shaped content (the
|
|
32
43
|
* value forms are the vocabulary's rows, {@link ENV_VALUES}). Reads the first {@link VALUE_SCAN_LIMIT} code units. The value half of the judgment, exported apart from the env
|
|
33
44
|
* entry's exemptions ({@link isExemptEnvName}): a caller holding a value that is no environment variable asks this. */
|
|
34
45
|
export declare function looksLikeCredentialValue(value: string): boolean;
|
|
35
|
-
/** Which rule withheld an entry: one of the scrub's rules (the `"all"` policy
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
46
|
+
/** Which rule withheld an entry — the first that answers ({@link judgeInheritedEntries}): one of the scrub's shape rules (the `"all"` policy
|
|
47
|
+
* withholds under `namespace-rule` alone); `own-credential` — the entry is one of the engine's own credentials (its name is declared, or
|
|
48
|
+
* its value equals a declared or engine-held credential value: {@link declareWithheldEnv}), which every policy withholds; or `peer-held` —
|
|
49
|
+
* a variable a protocol peer's credential reference names, a token the engine holds for that peer ({@link holdPeerHeldNames}), which the
|
|
50
|
+
* `"scrub"` policy withholds by name, and which is `own-credential` when it is also one of the engine's own. */
|
|
39
51
|
export type SecretEnvFindingKind = "exact-name" | "name-rule" | "namespace-rule" | "prefix-rule" | "value-rule" | "peer-held" | "own-credential";
|
|
40
52
|
/** One env entry withheld (deleted) from a child's environment: its name — never its value, so the record is
|
|
41
53
|
* loggable —, the rule that withheld it, how strong that claim is, and the minting module. */
|
|
@@ -53,12 +65,16 @@ export interface SecretEnvFinding {
|
|
|
53
65
|
* entry's exemptions ({@link isExemptEnvName}): a caller holding a key that is no environment variable (a member of a
|
|
54
66
|
* record) asks this, and an exempt name is no exception there. */
|
|
55
67
|
export declare function isSensitiveName(key: string): boolean;
|
|
56
|
-
/** Does
|
|
57
|
-
*
|
|
68
|
+
/** Does an entry carry a credential by its look alone (the shape rules, no table)? The question a protocol peer's seat answer is read
|
|
69
|
+
* by (`peer-seat.ts`: which of its environment members' values are credentials the engine takes in); not part of the package entry. */
|
|
70
|
+
export declare function entryLooksLikeCredential(name: string, value: string | undefined): boolean;
|
|
71
|
+
/** Does the `"scrub"` policy withhold `key`? The scrub's judgment ({@link judgeInheritedEntries}) over the tables as they stand — what a
|
|
72
|
+
* child composed now under the scrub loses: with `value`, exactly the answer {@link scrubSecretEnv} gives for that entry; without it,
|
|
73
|
+
* the answer for its name alone (the value rule and an own credential's value then have nothing to read). */
|
|
58
74
|
export declare function isSecretEnvKey(key: string, value?: string): boolean;
|
|
59
|
-
/** The `"scrub"` policy
|
|
60
|
-
* an optional caller-owned collector: each withheld entry is
|
|
61
|
-
* present in the result. `env` itself is not modified. */
|
|
75
|
+
/** The `"scrub"` policy over `env`: `env` without every entry {@link isSecretEnvKey} withholds, the rest as written — the arm a child
|
|
76
|
+
* composed under the scrub reads ({@link inheritedHostEnv}). `findings` is an optional caller-owned collector: each withheld entry is
|
|
77
|
+
* pushed onto it (name, rule, confidence), none of them present in the result. `env` itself is not modified. */
|
|
62
78
|
export declare function scrubSecretEnv(env: NodeJS.ProcessEnv, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
|
|
63
79
|
/** How much of this process's environment a child spawned on this host inherits — the `inheritEnv` value. */
|
|
64
80
|
export type InheritEnvPolicy = "all" | "scrub" | string[];
|
|
@@ -223,9 +239,10 @@ export interface PeerHeldEnvDeclaration {
|
|
|
223
239
|
};
|
|
224
240
|
/** To whom a person's notice that one of these variables was held back names this entry. Absent — to no one: every leg's notice says
|
|
225
241
|
* another entry in this process names the variable (the narrowest, and the reading before this declaration existed).
|
|
226
|
-
* `{ isolationScope }` — to the
|
|
227
|
-
*
|
|
228
|
-
*
|
|
242
|
+
* `{ isolationScope }` — to the legs whose isolation scope (`TaskSpec.isolationScope`, else `TaskSpec.principal`) is this one; a leg
|
|
243
|
+
* that names neither is in no scope and is never named to (a scope declared as `"default"` included). A delegated leg's notice is read
|
|
244
|
+
* at its tree's root, so it is named to only while it works in its delegation tree's domain (the one the root works in — a child the
|
|
245
|
+
* delegation tool starts does); a delegated leg with no tree domain, or outside it, never is. `"every_leg"` — to every leg
|
|
229
246
|
* of this thread: ONLY for an entry of the deployment itself, never one of a principal's — in a deployment of several principals it
|
|
230
247
|
* says the entry's name to every session. */
|
|
231
248
|
readonly namedTo?: PeerHeldEnvAudience;
|
|
@@ -240,14 +257,13 @@ export interface PeerHeldEnvReceipt {
|
|
|
240
257
|
/** The names not taken in, in the order given, each with its reason ({@link PEER_HELD_ENV_NOT_TAKEN_REASONS}). Not a refusal: every other
|
|
241
258
|
* name was taken in. Empty when all were. */
|
|
242
259
|
readonly notTaken: readonly PeerHeldEnvNameNotTaken[];
|
|
243
|
-
/** The names this call took in that the table did not hold before, that this process's environment holds now,
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* it lists every name newly taken in that this process's environment holds: it says only "may still be in a child already started". */
|
|
260
|
+
/** The names this call took in that the table did not hold before, that this process's environment holds now, once the engine has
|
|
261
|
+
* spawned a child under the scrub in this thread: a shell child of `NodeExecutionEnv` (a command — which may be adopted as a
|
|
262
|
+
* background shell — or a background shell) or a language server of `NodeLspManager`, from its spawn call on, whether or not the spawn
|
|
263
|
+
* later failed. Only ever true from then: such a child keeps the environment it started with, and one that has ended may have left a
|
|
264
|
+
* service holding it, so it says only "may still be in a child already started". A child under `"all"` or a list was handed these
|
|
265
|
+
* variables by its policy anyway; a read or a host's composition of an environment, a Runner built and the engine's own probes spawn
|
|
266
|
+
* no such child: none of them makes a name late. A child a host spawns itself is the host's to know about. Empty otherwise. */
|
|
251
267
|
readonly heldLate: readonly string[];
|
|
252
268
|
}
|
|
253
269
|
/**
|
|
@@ -274,7 +290,7 @@ export interface PeerHeldEnvReceipt {
|
|
|
274
290
|
*
|
|
275
291
|
* WHEN: at start-up, before the first child is spawned — it needs no Runner, and the table is made at its first use — and again at each
|
|
276
292
|
* configuration change (only what is new takes effect). A child's environment is composed when it starts: a child already running keeps
|
|
277
|
-
* what it started with, so a declaration made after a
|
|
293
|
+
* what it started with, so a declaration made after such a child started may be late for it — {@link PeerHeldEnvReceipt.heldLate}
|
|
278
294
|
* names what may be. Per THREAD, as {@link declareWithheldEnv}: a host that composes a child's environment in a worker declares there too.
|
|
279
295
|
*
|
|
280
296
|
* The two declarations, side by side: {@link declareWithheldEnv} — the engine's own credentials (names and values): withheld under EVERY
|
|
@@ -350,14 +366,14 @@ export declare function credentialHeaderValues(headers: Readonly<Record<string,
|
|
|
350
366
|
/** Test seam: never called by production code (a host re-declares `{ names: [], values: [] }`; what the engine took in stays). */
|
|
351
367
|
export declare function __resetWithheldEnv(): void;
|
|
352
368
|
/**
|
|
353
|
-
* THE environment a child spawned ON THIS HOST inherits: the policy's arm,
|
|
354
|
-
* declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
|
|
369
|
+
* THE environment a child spawned ON THIS HOST inherits: the policy's arm, which under every policy withholds the engine's own
|
|
370
|
+
* credentials — a declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
|
|
355
371
|
* {@link holdOwnCredentialValues}). The arms: `"scrub"` (and absent) is this process's environment through
|
|
356
|
-
* {@link scrubSecretEnv}
|
|
372
|
+
* {@link scrubSecretEnv} (the shape rules and the variables the engine holds for a protocol peer, {@link holdPeerHeldNames}, by name); `"all"` is this process's environment as written, less the credential names of the engine's own
|
|
357
373
|
* namespace (the namespace rule, {@link isNamespaceCredentialName}, and none of the scrub's other rules); a `string[]` is exactly the
|
|
358
374
|
* named variables that are set, as written — a strict allow list, so a name it leaves out (`PATH` included) is not
|
|
359
|
-
* inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld
|
|
360
|
-
*
|
|
375
|
+
* inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld, one each, under the first rule
|
|
376
|
+
* that answers ({@link judgeInheritedEntries}: a shape rule, else `own-credential`, else `peer-held`).
|
|
361
377
|
*
|
|
362
378
|
* A policy {@link inheritEnvPolicyProblem} refuses throws that reason HERE, at every spawn, read against the
|
|
363
379
|
* declaration as it stands: a value that is no policy at all (never read as the scrub), and an allow list naming a
|
|
@@ -366,6 +382,13 @@ export declare function __resetWithheldEnv(): void;
|
|
|
366
382
|
* ask first, so a host that declared before building them hears it at start-up.
|
|
367
383
|
*/
|
|
368
384
|
export declare function inheritedHostEnv(policy: InheritEnvPolicy | undefined, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
|
|
385
|
+
/** Record that the engine spawned a child — a shell child (a command, which may be adopted as a background shell; a background shell)
|
|
386
|
+
* or a language server — with an environment composed under `policy`: the question {@link PeerHeldEnvReceipt.heldLate} asks ("may a
|
|
387
|
+
* child already started hold this name"). Only ever set: a child that has closed may have left a service holding the same environment
|
|
388
|
+
* behind (a background shell that starts a daemon and exits), so no end is read. A child under `"all"` or a list records nothing (its
|
|
389
|
+
* policy handed it every variable a later declaration holds). Called by the site that spawned it, right after the spawn call — the
|
|
390
|
+
* environment is the child's from that call on, whether or not the spawn later fails. Not part of the package entry. */
|
|
391
|
+
export declare function noteChildSpawned(policy: InheritEnvPolicy | undefined): void;
|
|
369
392
|
/** What a child spawned on this host starts with ({@link hostChildEnv}), and the inherited entries it does not receive:
|
|
370
393
|
* the inheritance's findings less every name the composed environment sets (a grant's entry is the host's, never a loss). */
|
|
371
394
|
export interface HostChildEnv {
|
|
@@ -378,7 +401,7 @@ export interface HostChildInheritance {
|
|
|
378
401
|
/** How much of the base a child inherits — the {@link InheritEnvPolicy} (absent: `"scrub"`). */
|
|
379
402
|
readonly policy?: InheritEnvPolicy | undefined;
|
|
380
403
|
/** The settings file's `env` block: laid over this process's environment BEFORE the policy reads it, so it is part of
|
|
381
|
-
* the base — read by the same arm and the same own-credentials
|
|
404
|
+
* the base — read by the same arm and the same own-credentials judgment as every other inherited entry (by name and
|
|
382
405
|
* by value), its withheld entries accounted with `layer: "settingsEnv"`. A name it sets wins over this process's
|
|
383
406
|
* variable of that name (compared as the platform compares names, the value under the spelling the process has);
|
|
384
407
|
* an `undefined` value unsets it. A grant laid after the inherited part wins over it. Absent: the base is this
|
|
@@ -422,8 +445,8 @@ export declare function declaredInheritEntry(value: unknown): {
|
|
|
422
445
|
/** Test seam: never called by production code. */
|
|
423
446
|
export declare function __resetSecretEnvScrubNoticeAnnouncement(): void;
|
|
424
447
|
/** What both disclosures say about one set of findings: every withheld name, and those that are the engine's own
|
|
425
|
-
* credentials — withheld under every policy —
|
|
426
|
-
*
|
|
448
|
+
* credentials — withheld under every policy — whatever kind a finding says ({@link ownCredentialJudge}, the
|
|
449
|
+
* composition's own judgment, over the entry's value in this process's environment: every finding names an entry of
|
|
427
450
|
* it). The rest the policy withheld: an allow list naming them hands them on, and so does `"all"` — except the names of the
|
|
428
451
|
* engine's own namespace ({@link isNamespaceCredentialName}), which `"all"` withholds too. */
|
|
429
452
|
export declare function withheldEnvNames(findings: readonly SecretEnvFinding[]): {
|
|
@@ -466,12 +489,12 @@ export interface WithheldEnvRemedy {
|
|
|
466
489
|
* and the one thing to do if a command needs a withheld variable (the engine's own credentials: nothing hands them on; a name
|
|
467
490
|
* the namespace rule caught: a list naming it, or the host's explicit grant, does, and the sentence says `"all"` does not; a name a
|
|
468
491
|
* protocol peer's credential reference named: the entry that names it is the reason, named when the leg whose shell this is took in that
|
|
469
|
-
* variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope
|
|
470
|
-
* {@link peerHeldHalf}).
|
|
492
|
+
* variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope`, read
|
|
493
|
+
* against `deliveredScope`, the scope of the root a delegated leg's notice is delivered to ({@link noticeReaderScope}) — {@link peerHeldHalf}).
|
|
471
494
|
*/
|
|
472
495
|
export declare function withheldEnvUserNotice(withheld: readonly SecretEnvFinding[] | "unknown", at: {
|
|
473
496
|
sessionId: string;
|
|
474
497
|
runId?: string | undefined;
|
|
475
498
|
sourceSessionId?: string | undefined;
|
|
476
499
|
agentId?: string | undefined;
|
|
477
|
-
}, mine?: PeerEntriesTaken, isolationScope?: string): EngineNotice | undefined;
|
|
500
|
+
}, mine?: PeerEntriesTaken, isolationScope?: string, deliveredScope?: string): EngineNotice | undefined;
|
package/dist/core/secret-env.js
CHANGED
|
@@ -9,6 +9,7 @@ import { describeRejectedValue } from "./tool-search-setting.js";
|
|
|
9
9
|
import { authSchemeCredentials } from "./protocol-http-auth.js";
|
|
10
10
|
import { declarationSubject, isToolAxesSurface, toolAxesSurfaceList } from "./declaration-words.js";
|
|
11
11
|
import { principalNameOf } from "./principal-name.js";
|
|
12
|
+
import { ANONYMOUS_SCOPE } from "./isolation-scope.js";
|
|
12
13
|
const GIT_CONFIG_ENV_RE = /^GIT_CONFIG_(?:COUNT|PARAMETERS|(?:KEY|VALUE)_[0-9]+)$/;
|
|
13
14
|
const PROXY_ENV_RE = /^(?:(?:https?|ftp|all|no)_proxy|npm_config_(?:https?_)?proxy|npm_config_noproxy|yarn_proxy|(?:yarn|global_agent|docker|claude_code)_(?:https?|no)_proxy|cloudsdk_proxy_[a-z]+|electron_get_use_proxy)$/i;
|
|
14
15
|
function isExemptEnvName(name) {
|
|
@@ -18,7 +19,7 @@ const ENV_NAMES = envNameView();
|
|
|
18
19
|
const ENV_VALUES = envValueView();
|
|
19
20
|
const OTEL_ENV_RE = /^(?:INPUT_)?OTEL_/i;
|
|
20
21
|
const SEMA_NAMESPACE_SECRET_RE = ENV_NAMES.anySegmentUnder("SEMA_");
|
|
21
|
-
function isNamespaceCredentialName(name) {
|
|
22
|
+
export function isNamespaceCredentialName(name) {
|
|
22
23
|
return SEMA_NAMESPACE_SECRET_RE.test(name);
|
|
23
24
|
}
|
|
24
25
|
const BUNDLER_SETTINGS = ["BUILD", "LOCAL", "MIRROR", "PATH", "WITH", "WITHOUT", "CACHE", "DISABLE", "IGNORE", "ONLY"];
|
|
@@ -122,17 +123,27 @@ function classifySecretEnvEntry(name, value) {
|
|
|
122
123
|
return named;
|
|
123
124
|
return value !== undefined && looksLikeCredentialValue(typeof value === "string" ? value : String(value)) ? "value-rule" : undefined;
|
|
124
125
|
}
|
|
126
|
+
export function entryLooksLikeCredential(name, value) {
|
|
127
|
+
return classifySecretEnvEntry(name, value) !== undefined;
|
|
128
|
+
}
|
|
129
|
+
function judgeInheritedEntries(policy, entries) {
|
|
130
|
+
const shaped = entries.map(([name, value]) => (policy === "all" ? (isNamespaceCredentialName(name) ? "namespace-rule" : undefined) : Array.isArray(policy) ? undefined : classifySecretEnvEntry(name, value)));
|
|
131
|
+
const isOwn = ownCredentialJudge();
|
|
132
|
+
const peerHeld = policy === "all" || Array.isArray(policy) ? undefined : peerHeldOf();
|
|
133
|
+
return entries.map(([name, value], i) => shaped[i] ?? (isOwn !== undefined && isOwn(name, value) ? "own-credential" : peerHeld?.has(envNameKey(name)) === true ? "peer-held" : undefined));
|
|
134
|
+
}
|
|
125
135
|
export function isSecretEnvKey(key, value) {
|
|
126
|
-
return
|
|
136
|
+
return judgeInheritedEntries("scrub", [[key, value]])[0] !== undefined;
|
|
127
137
|
}
|
|
128
138
|
export function scrubSecretEnv(env, findings) {
|
|
129
|
-
return withholdEntries(env,
|
|
139
|
+
return withholdEntries(env, "scrub", findings);
|
|
130
140
|
}
|
|
131
|
-
function withholdEntries(env,
|
|
141
|
+
function withholdEntries(env, policy, findings) {
|
|
142
|
+
const entries = Object.keys(env).map((key) => [key, env[key]]);
|
|
143
|
+
const kinds = judgeInheritedEntries(policy, entries);
|
|
132
144
|
const kept = [];
|
|
133
|
-
for (const key of
|
|
134
|
-
const
|
|
135
|
-
const kind = judge(key, value);
|
|
145
|
+
for (const [i, [key, value]] of entries.entries()) {
|
|
146
|
+
const kind = kinds[i];
|
|
136
147
|
if (kind === undefined)
|
|
137
148
|
kept.push([key, value]);
|
|
138
149
|
else
|
|
@@ -196,7 +207,7 @@ const peerHeldAudiencesOf = () => {
|
|
|
196
207
|
const slot = Reflect.get(globalThis, PEER_HELD_AUDIENCES);
|
|
197
208
|
if (typeof slot === "object" && slot !== null && slot.named instanceof Map)
|
|
198
209
|
return slot;
|
|
199
|
-
const fresh = { named: new Map()
|
|
210
|
+
const fresh = { named: new Map() };
|
|
200
211
|
Reflect.set(globalThis, PEER_HELD_AUDIENCES, fresh);
|
|
201
212
|
return fresh;
|
|
202
213
|
};
|
|
@@ -219,7 +230,7 @@ const CANNOT_BE_WITHHELD = "which a child is handed from this process's environm
|
|
|
219
230
|
function runtimeSuppliedHolderOf(value, supplied = suppliedInProcess()) {
|
|
220
231
|
return Object.keys(supplied).find((k) => supplied[k] === value);
|
|
221
232
|
}
|
|
222
|
-
const suppliedIn = (env) =>
|
|
233
|
+
const suppliedIn = (env) => namedIn(runtimeSuppliedEnv(), env);
|
|
223
234
|
const suppliedInProcess = () => suppliedIn(process.env);
|
|
224
235
|
const PLACEHOLDER_KEY_WORDS = new Set([...ENV_VALUES.flagWords, ...ENV_VALUES.placeholderWords]);
|
|
225
236
|
export function isOneCharacterRepeated(text) {
|
|
@@ -449,7 +460,7 @@ export function declarePeerHeldEnv(declaration) {
|
|
|
449
460
|
continue;
|
|
450
461
|
}
|
|
451
462
|
const { key, isNew } = admitted;
|
|
452
|
-
if (isNew && audiences.
|
|
463
|
+
if (isNew && audiences.childSpawned === true && Object.hasOwn(process.env, spellingIn(process.env, name)) && !heldLate.includes(name))
|
|
453
464
|
heldLate.push(name);
|
|
454
465
|
if (read.audience !== undefined) {
|
|
455
466
|
let entries = audiences.named.get(key);
|
|
@@ -551,7 +562,7 @@ function sayNotTaken(value, why, onNotice) {
|
|
|
551
562
|
export function __resetWithheldEnv() {
|
|
552
563
|
Reflect.set(globalThis, WITHHELD_ENV, { names: NOTHING_NAMED, declared: new Map(), held: new Map() });
|
|
553
564
|
Reflect.set(globalThis, PEER_HELD_ENV, new Map());
|
|
554
|
-
Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map()
|
|
565
|
+
Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map() });
|
|
555
566
|
intakeSaid.clear();
|
|
556
567
|
}
|
|
557
568
|
function ownCredentialJudge() {
|
|
@@ -561,20 +572,6 @@ function ownCredentialJudge() {
|
|
|
561
572
|
const own = new Set(table.names.map(envNameKey));
|
|
562
573
|
return (key, value) => own.has(envNameKey(key)) || (typeof value === "string" && (indexHas(table.declared, value) || indexHas(table.held, value)));
|
|
563
574
|
}
|
|
564
|
-
function withholdOwnCredentials(inherited, findings) {
|
|
565
|
-
const isOwn = ownCredentialJudge();
|
|
566
|
-
if (isOwn === undefined)
|
|
567
|
-
return inherited;
|
|
568
|
-
const kept = [];
|
|
569
|
-
for (const key of Object.keys(inherited)) {
|
|
570
|
-
const value = inherited[key];
|
|
571
|
-
if (!isOwn(key, value))
|
|
572
|
-
kept.push([key, value]);
|
|
573
|
-
else
|
|
574
|
-
findings?.push({ key, kind: "own-credential", confidence: SECRET_ENV_KIND_CONFIDENCE["own-credential"], source: "secret-env" });
|
|
575
|
-
}
|
|
576
|
-
return Object.fromEntries(kept);
|
|
577
|
-
}
|
|
578
575
|
function policyShapeProblem(value) {
|
|
579
576
|
if (value === undefined || value === "all" || value === "scrub")
|
|
580
577
|
return undefined;
|
|
@@ -601,21 +598,18 @@ function inheritedOver(policy, settings, findings) {
|
|
|
601
598
|
base = Object.fromEntries([...layered.values()].filter((entry) => entry[1] !== undefined));
|
|
602
599
|
}
|
|
603
600
|
const found = [];
|
|
604
|
-
const inherited =
|
|
601
|
+
const inherited = policyArm(policy, base, found);
|
|
605
602
|
for (const f of found)
|
|
606
603
|
findings?.push(settingsNames.has(envNameKey(f.key)) ? { ...f, layer: "settingsEnv" } : f);
|
|
607
604
|
return inherited;
|
|
608
605
|
}
|
|
609
606
|
export function inheritedHostEnv(policy, findings) {
|
|
610
|
-
|
|
611
|
-
const inherited = inheritedOver(policy, undefined, findings);
|
|
612
|
-
if (underScrub)
|
|
613
|
-
noteScrubComposed();
|
|
614
|
-
return inherited;
|
|
607
|
+
return inheritedOver(policy, undefined, findings);
|
|
615
608
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
609
|
+
export function noteChildSpawned(policy) {
|
|
610
|
+
if (policy === "all" || Array.isArray(policy))
|
|
611
|
+
return;
|
|
612
|
+
peerHeldAudiencesOf().childSpawned = true;
|
|
619
613
|
}
|
|
620
614
|
const HOST_CHILD_INHERITANCE_KEYS = optionKeys()({ policy: 0, settingsEnv: 0 });
|
|
621
615
|
function layInto(entries, layer) {
|
|
@@ -664,7 +658,7 @@ function readInheritance(inherit) {
|
|
|
664
658
|
}
|
|
665
659
|
return { policy: table.policy, settings: table.settingsEnv === undefined ? undefined : readEnvLayer(table.settingsEnv, "settingsEnv") };
|
|
666
660
|
}
|
|
667
|
-
function composeHostChildEnv(inherit, grants
|
|
661
|
+
function composeHostChildEnv(inherit, grants) {
|
|
668
662
|
const read = readInheritance(inherit);
|
|
669
663
|
if (typeof read === "string")
|
|
670
664
|
return read;
|
|
@@ -681,7 +675,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
|
|
|
681
675
|
return read.settings;
|
|
682
676
|
const findings = [];
|
|
683
677
|
const entries = new Map();
|
|
684
|
-
const underScrub = forChild && isScrubPolicy(read.policy);
|
|
685
678
|
for (const entry of Object.entries(inheritedOver(read.policy, read.settings, findings)))
|
|
686
679
|
entries.set(envNameKey(entry[0]), entry);
|
|
687
680
|
for (let i = 0; i < grants.length; i++) {
|
|
@@ -693,8 +686,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
|
|
|
693
686
|
layInto(entries, layer);
|
|
694
687
|
}
|
|
695
688
|
const env = Object.fromEntries(entries.values());
|
|
696
|
-
if (underScrub)
|
|
697
|
-
noteScrubComposed();
|
|
698
689
|
return { env, withheld: findings.filter((f) => entries.get(envNameKey(f.key))?.[1] === undefined) };
|
|
699
690
|
}
|
|
700
691
|
export function hostChildEnvProblem(inherit, ...grants) {
|
|
@@ -702,21 +693,21 @@ export function hostChildEnvProblem(inherit, ...grants) {
|
|
|
702
693
|
return typeof composed === "string" ? composed : undefined;
|
|
703
694
|
}
|
|
704
695
|
export function hostChildEnv(inherit, ...grants) {
|
|
705
|
-
const composed = composeHostChildEnv(inherit, grants
|
|
696
|
+
const composed = composeHostChildEnv(inherit, grants);
|
|
706
697
|
if (typeof composed === "string")
|
|
707
698
|
throw new Error(composed);
|
|
708
699
|
return composed;
|
|
709
700
|
}
|
|
710
701
|
function policyArm(policy, base, findings) {
|
|
711
702
|
if (policy === "all")
|
|
712
|
-
return withholdEntries(base,
|
|
713
|
-
if (!Array.isArray(policy))
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
703
|
+
return withholdEntries(base, policy, findings);
|
|
704
|
+
if (!Array.isArray(policy))
|
|
705
|
+
return scrubSecretEnv(base, findings);
|
|
706
|
+
return withholdEntries(namedIn(policy, base), policy, findings);
|
|
707
|
+
}
|
|
708
|
+
function namedIn(names, base) {
|
|
718
709
|
const arm = [];
|
|
719
|
-
for (const k of
|
|
710
|
+
for (const k of names) {
|
|
720
711
|
const name = spellingIn(base, k);
|
|
721
712
|
const value = Object.hasOwn(base, name) ? base[name] : undefined;
|
|
722
713
|
if (value !== undefined)
|
|
@@ -785,9 +776,15 @@ function peerHeldHalf(peers, mine, isolationScope) {
|
|
|
785
776
|
`through the shell's own environment or the environment of a single execution; letting the run inherit all of them hands it on as well, but once the engine has started connecting to that peer ` +
|
|
786
777
|
`neither that nor a list is sure to, since a credential value the engine took in for it is held back whatever the run inherits)`);
|
|
787
778
|
}
|
|
788
|
-
|
|
779
|
+
function noticeReaderScope(delegated, isolationScope, deliveredScope) {
|
|
780
|
+
if (!delegated)
|
|
781
|
+
return isolationScope;
|
|
782
|
+
return deliveredScope !== ANONYMOUS_SCOPE && isolationScope !== undefined && isolationScope === deliveredScope ? isolationScope : undefined;
|
|
783
|
+
}
|
|
784
|
+
export function withheldEnvUserNotice(withheld, at, mine, isolationScope, deliveredScope) {
|
|
789
785
|
const route = { sessionId: at.sessionId, ...(at.sourceSessionId !== undefined ? { sourceSessionId: at.sourceSessionId } : {}), ...(at.agentId !== undefined ? { agentId: at.agentId } : {}), ...(at.runId !== undefined ? { runId: at.runId } : {}) };
|
|
790
786
|
const delegated = at.sourceSessionId !== undefined;
|
|
787
|
+
const readerScope = noticeReaderScope(delegated, isolationScope, deliveredScope);
|
|
791
788
|
const shell = delegated ? "the tool shell of a delegated agent in this session" : "the tool shell in this session";
|
|
792
789
|
const subject = delegated ? "A delegated agent's tool shell in this session" : "The tool shell in this session";
|
|
793
790
|
if (withheld === "unknown") {
|
|
@@ -809,7 +806,7 @@ export function withheldEnvUserNotice(withheld, at, mine, isolationScope) {
|
|
|
809
806
|
const needs = (list) => (list.length === 1 ? "it" : "one of them");
|
|
810
807
|
const halves = [
|
|
811
808
|
...(others.length > 0 ? [`${others.join(", ")} — held back because ${others.length === 1 ? "it looks like a credential" : "they look like credentials"} (if a command needs ${needs(others)}, name it among the variables the run inherits, or let the run inherit all of them)`] : []),
|
|
812
|
-
...(peers.length > 0 ? [peerHeldHalf(peers, mine,
|
|
809
|
+
...(peers.length > 0 ? [peerHeldHalf(peers, mine, readerScope)] : []),
|
|
813
810
|
...(slots.length > 0 ? [`${slots.join(", ")} — held back because ${slots.length === 1 ? "it is named" : "they are named"} like the engine's own credential slots (if a command needs ${needs(slots)}, name it among the variables the run inherits, or have the host hand it to the shell explicitly, through the shell's own environment or the environment of a single execution — letting the run inherit everything does not hand ${slots.length === 1 ? "it" : "them"} on)`] : []),
|
|
814
811
|
...(ownCredentials.length > 0 ? [`${ownCredentials.join(", ")} — ${OWN_CREDENTIAL}(s), never handed on, whatever the run's environment inheritance says`] : []),
|
|
815
812
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { dataRootSpelling } from "./data-root.js";
|
|
4
|
-
import { anchorSpelling, canonicalizeTarget, expandHomeTilde, isAbsoluteForFamily, isWinFormPath, pathFamilyOf,
|
|
4
|
+
import { anchorSpelling, canonicalizeTarget, expandHomeTilde, isAbsoluteForFamily, isWinFormPath, pathFamilyOf, targetPathsOf } from "../tools/fs/safety.js";
|
|
5
5
|
import { spelledExemptionOf } from "./write-protect.js";
|
|
6
6
|
import { compileSegmentPattern, READ_FACE_BUILTIN_DENY_TABLE, readDenyPatternRun, SEGMENT_FOLDS, segmentGuardRow } from "../tools/fs/read-deny.js";
|
|
7
7
|
import { guardHitReachClause, guardHitVia, judgePathRows, spelledViews } from "./path-guard-rows.js";
|
|
@@ -205,9 +205,16 @@ export function createSensitivePathPolicy(opts) {
|
|
|
205
205
|
if (guardedByName !== undefined ? !heldBy("policy.sensitivePathGuardedByName", guardedByName, req) : !isProtectedWrite(req))
|
|
206
206
|
return { action: "allow" };
|
|
207
207
|
const protective = protectivePathTargetOf(req);
|
|
208
|
-
const path
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
for (const path of targetPathsOf(req, protective)) {
|
|
209
|
+
const refused = await judgeOne(req, protective, path, signal);
|
|
210
|
+
if (refused !== undefined)
|
|
211
|
+
return refused;
|
|
212
|
+
}
|
|
213
|
+
return { action: "allow" };
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
async function judgeOne(req, protective, path, signal) {
|
|
217
|
+
{
|
|
211
218
|
const judged = await judgeTarget(path, family(req.cwd), pathTargetBaseOf(protective, { root: opts.rootPath, cwd: req.cwd }), req.exemptRoots ?? unstampedRoots, signal);
|
|
212
219
|
if (judged.kind === "unresolved") {
|
|
213
220
|
return { action: "deny", message: `write to "${path}" is refused (target_unresolved): where it leads on disk could not be determined, so the sensitive-path list cannot tell whether it is a guarded path — ${judged.cause}`, decisionReason: "safety" };
|
|
@@ -222,7 +229,7 @@ export function createSensitivePathPolicy(opts) {
|
|
|
222
229
|
decisionReason: "safety",
|
|
223
230
|
};
|
|
224
231
|
}
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
}
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
228
235
|
}
|
|
@@ -54,6 +54,9 @@ export interface WorktreeCapability {
|
|
|
54
54
|
readonly detail?: string;
|
|
55
55
|
}
|
|
56
56
|
export type { ReleasedTree } from "./git-worktree-env.js";
|
|
57
|
+
/** The one reader of a session's checkout record, the one this module's doors read (#4898: a host reads it too). */
|
|
58
|
+
export { readSessionCheckout, type SessionCheckoutRead } from "../engine/session/session.js";
|
|
59
|
+
export type { SessionCheckoutRecord } from "../internal/harness-types.js";
|
|
57
60
|
/**
|
|
58
61
|
* THE shape judge of `TaskSpec.workspace` — `undefined` for an absent declaration, else the normalized declaration the record
|
|
59
62
|
* stores and every later leg is compared on. Read once as data ({@link DECLARATION_DATA}), then judged on that copy. Refused
|
|
@@ -21,6 +21,7 @@ export const WORKTREE_INCAPABLE_REASONS = Object.freeze([
|
|
|
21
21
|
"parent_not_writable",
|
|
22
22
|
"name_in_use",
|
|
23
23
|
]);
|
|
24
|
+
export { readSessionCheckout } from "../engine/session/session.js";
|
|
24
25
|
const refusal = (code, message) => Object.assign(new Error(message), { code });
|
|
25
26
|
const invalid = (problem) => refusal("config.session_workspace_invalid", `TaskSpec.workspace ${problem}`);
|
|
26
27
|
const FULL_SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo, type SessionRowExpectation } from "../internal/harness.js";
|
|
1
|
+
import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo, type SessionRowExpectation, type SessionRowRead } from "../internal/harness.js";
|
|
2
2
|
import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionLogTransfer, type SessionPlacement, type SessionStore, type SessionStoreHooks, type SessionStoreSummary } from "./session.js";
|
|
3
3
|
import type { StoreDurability } from "./checkpoint-store.js";
|
|
4
4
|
import { type StoreHolderFence } from "./checkpoint-generation.js";
|
|
@@ -157,6 +157,9 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
157
157
|
/** The repo's head read as this store's own decisions read the row through it (the cache check, the existence check), held
|
|
158
158
|
* privately so the store's reading of its rows is the repo's whatever a host does with the face. */
|
|
159
159
|
private readonly repoHead?;
|
|
160
|
+
/** The row read ({@link SessionStore.readRow}): the repo's own, verbatim — no sweep, no activity, nothing cached. Present only when the
|
|
161
|
+
* repo has a head read and a row read. */
|
|
162
|
+
readonly readRow?: (sessionId: string) => Promise<SessionRowRead | undefined>;
|
|
160
163
|
/** The storage half of a cross-backend move ({@link SessionStore.logTransfer}), over the repo's row read and its conditional import:
|
|
161
164
|
* present only when the repo has both and a head read. A staging lives in this process; a commit holds the id as a release does, and
|
|
162
165
|
* the import it ends with is conditional on the row the commit read. */
|
|
@@ -166,7 +169,9 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
166
169
|
* deletion is judged on the head, never on the log). A repo with the first two and not the third is said once
|
|
167
170
|
* (`config.session_delete_withheld`). */
|
|
168
171
|
readonly delete?: (sessionId: string, guard: {
|
|
169
|
-
owner: string | null;
|
|
172
|
+
readonly owner: string | null;
|
|
173
|
+
} | {
|
|
174
|
+
readonly row: NonNullable<SessionRowExpectation["row"]>;
|
|
170
175
|
}) => Promise<boolean>;
|
|
171
176
|
/** The operator's removal of a row whose head cannot be read ({@link SessionStore.deleteUnreadable}): present only when the repo has a
|
|
172
177
|
* head read and its own unreadable-row removal ({@link SessionRepo.deleteUnreadable}), which re-reads the head in the step that removes. */
|
|
@@ -330,10 +335,11 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
330
335
|
*/
|
|
331
336
|
private deleteUnreadableRow;
|
|
332
337
|
/**
|
|
333
|
-
* The owner-guarded delete ({@link SessionStore.delete}), holding the id as a release does: the row's head decides — no row,
|
|
334
|
-
* owner other than `guard.owner` (null-safe),
|
|
335
|
-
*
|
|
336
|
-
*
|
|
338
|
+
* The owner-guarded delete ({@link SessionStore.delete}), holding the id as a release does: the row's head decides — no row, an
|
|
339
|
+
* owner other than `guard.owner` (null-safe), or, for the occupant form, a head `sessionRowMatches` does not take for `guard.row`,
|
|
340
|
+
* deletes nothing — and a placed row (read off the header alone) is left to `release` (the joint reap). The log is never read, so a
|
|
341
|
+
* log whose open is refused `corrupt_session` is deleted like any other row. A deleted row leaves no cached view and no pin: the id
|
|
342
|
+
* answers nothing afterwards, and a later create under it is a new occupant.
|
|
337
343
|
*/
|
|
338
344
|
private deleteOwned;
|
|
339
345
|
/** The row's metadata as the repo holds it, its placement included; `undefined` = no row. A read fault rejects. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, recordedOwnerName, sessionLogMarkOf, uuidv7, } from "../internal/harness.js";
|
|
1
|
+
import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, recordedOwnerName, sessionLogMarkOf, sessionRowMatches, uuidv7, } from "../internal/harness.js";
|
|
2
2
|
import { isSessionConflict, readSessionListQuery, readUnreadableDeleteId, rowUnreadableAt } from "./session.js";
|
|
3
3
|
import { readHolderJudge } from "./checkpoint-generation.js";
|
|
4
4
|
import { readRetentionDeclaration } from "./retention.js";
|
|
@@ -9,6 +9,7 @@ import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
|
9
9
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
10
10
|
import { readIntegerOption, TIMER_DELAY_MS } from "./integer-option.js";
|
|
11
11
|
import { repoLogTransfer } from "./session-log-transfer.js";
|
|
12
|
+
import { readOccupantExpectation } from "./runner/session-verb-doors.js";
|
|
12
13
|
import { deliverEngineNotice } from "./engine-notice.js";
|
|
13
14
|
let ownerDeleteWithheldSaid = false;
|
|
14
15
|
export function __resetSessionDeleteWithheldNotice() {
|
|
@@ -46,6 +47,7 @@ export class TtlSessionStore {
|
|
|
46
47
|
listPlaced;
|
|
47
48
|
headOf;
|
|
48
49
|
repoHead;
|
|
50
|
+
readRow;
|
|
49
51
|
logTransfer;
|
|
50
52
|
delete;
|
|
51
53
|
deleteUnreadable;
|
|
@@ -96,6 +98,8 @@ export class TtlSessionStore {
|
|
|
96
98
|
this.repoHead = repoHead;
|
|
97
99
|
this.headOf = repoHead;
|
|
98
100
|
const { readRow, importEntries, deleteUnreadable, placementOf, recordOwner } = this.repo;
|
|
101
|
+
if (typeof readRow === "function")
|
|
102
|
+
this.readRow = (sessionId) => readRow.call(this.repo, sessionId);
|
|
99
103
|
if (typeof recordOwner === "function") {
|
|
100
104
|
this.recordOwner = async (sessionId, owner, expect) => {
|
|
101
105
|
const name = recordedOwnerName(owner);
|
|
@@ -454,11 +458,11 @@ export class TtlSessionStore {
|
|
|
454
458
|
});
|
|
455
459
|
}
|
|
456
460
|
async deleteOwned(sessionId, guard, readHead, readHeaderPlacement) {
|
|
457
|
-
const
|
|
461
|
+
const wants = readDeleteGuard(guard);
|
|
458
462
|
return this.holdingId(sessionId, async () => {
|
|
459
463
|
this.entries.delete(sessionId);
|
|
460
464
|
const head = await readHead(sessionId);
|
|
461
|
-
if (head === undefined || head
|
|
465
|
+
if (head === undefined || !wants(head))
|
|
462
466
|
return false;
|
|
463
467
|
if ((await readHeaderPlacement(sessionId)) !== undefined)
|
|
464
468
|
return false;
|
|
@@ -640,14 +644,30 @@ function readStoreHooks(hooks) {
|
|
|
640
644
|
}
|
|
641
645
|
function readDeleteGuard(guard) {
|
|
642
646
|
if (typeof guard !== "object" || guard === null)
|
|
643
|
-
throw new TypeError(`SessionStore.delete: the guard must be an object { owner }, got ${guard === null ? "null" : typeof guard}`);
|
|
647
|
+
throw new TypeError(`SessionStore.delete: the guard must be an object { owner } or { row: { owner, incarnation } }, got ${guard === null ? "null" : typeof guard}`);
|
|
648
|
+
let hasRow;
|
|
649
|
+
try {
|
|
650
|
+
hasRow = "row" in guard;
|
|
651
|
+
}
|
|
652
|
+
catch {
|
|
653
|
+
hasRow = true;
|
|
654
|
+
}
|
|
655
|
+
if (hasRow) {
|
|
656
|
+
const occupant = readOccupantExpectation(guard, (what) => {
|
|
657
|
+
throw new TypeError(`SessionStore.delete: the guard's ${what}`);
|
|
658
|
+
});
|
|
659
|
+
return (head) => sessionRowMatches(occupant, head, occupantBindsNoLog);
|
|
660
|
+
}
|
|
644
661
|
const owner = readMember(guard, "owner");
|
|
645
662
|
if (owner === null)
|
|
646
|
-
return null;
|
|
663
|
+
return (head) => head.owner === null;
|
|
647
664
|
const name = recordedPrincipalNameOf(owner);
|
|
648
665
|
if (name === undefined)
|
|
649
666
|
throw new TypeError(`SessionStore.delete: guard.owner must be null (anonymous) or the owner name a session row holds — ${RECORDED_PRINCIPAL_NAME_SPELLING} — got ${principalNameFault(owner)}`);
|
|
650
|
-
return name;
|
|
667
|
+
return (head) => head.owner === name;
|
|
668
|
+
}
|
|
669
|
+
function occupantBindsNoLog() {
|
|
670
|
+
throw new TypeError("SessionStore.delete: an occupant guard binds no log");
|
|
651
671
|
}
|
|
652
672
|
function isNotFound(err) {
|
|
653
673
|
return readMember(err, "code") === "not_found";
|