@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- 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/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- 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 +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- 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 +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- 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/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -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/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-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/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/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 +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- 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 +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- 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 +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- 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/permission-rules.js +4 -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/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- 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/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -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 +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- 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-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- 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 +42 -30
- 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 +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- 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/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -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 +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- 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/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- 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.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -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 +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- 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 +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- 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.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- 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 +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- 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-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.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/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- 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 +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- 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 +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.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.
|
|
@@ -39,10 +43,11 @@ export declare function isNamespaceCredentialName(name: string): boolean;
|
|
|
39
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
|
|
40
44
|
* entry's exemptions ({@link isExemptEnvName}): a caller holding a value that is no environment variable asks this. */
|
|
41
45
|
export declare function looksLikeCredentialValue(value: string): boolean;
|
|
42
|
-
/** Which rule withheld an entry: one of the scrub's rules (the `"all"` policy
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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. */
|
|
46
51
|
export type SecretEnvFindingKind = "exact-name" | "name-rule" | "namespace-rule" | "prefix-rule" | "value-rule" | "peer-held" | "own-credential";
|
|
47
52
|
/** One env entry withheld (deleted) from a child's environment: its name — never its value, so the record is
|
|
48
53
|
* loggable —, the rule that withheld it, how strong that claim is, and the minting module. */
|
|
@@ -60,15 +65,21 @@ export interface SecretEnvFinding {
|
|
|
60
65
|
* entry's exemptions ({@link isExemptEnvName}): a caller holding a key that is no environment variable (a member of a
|
|
61
66
|
* record) asks this, and an exempt name is no exception there. */
|
|
62
67
|
export declare function isSensitiveName(key: string): boolean;
|
|
63
|
-
/** Does
|
|
64
|
-
*
|
|
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). */
|
|
65
74
|
export declare function isSecretEnvKey(key: string, value?: string): boolean;
|
|
66
|
-
/** The `"scrub"` policy
|
|
67
|
-
* an optional caller-owned collector: each withheld entry is
|
|
68
|
-
* 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. */
|
|
69
78
|
export declare function scrubSecretEnv(env: NodeJS.ProcessEnv, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
|
|
70
79
|
/** How much of this process's environment a child spawned on this host inherits — the `inheritEnv` value. */
|
|
71
80
|
export type InheritEnvPolicy = "all" | "scrub" | string[];
|
|
81
|
+
/** {@link envNameKey} on a named platform — the one fold, for a reader that judges another platform's environment. */
|
|
82
|
+
export declare function envNameKeyOn(name: string, platform: NodeJS.Platform): string;
|
|
72
83
|
/** What {@link declareWithheldEnv} takes: the engine's own credentials in this process's environment. */
|
|
73
84
|
export interface WithheldEnvDeclaration {
|
|
74
85
|
/** Names of variables that are the engine's own credentials: never inherited, and an allow list naming one is refused. */
|
|
@@ -230,9 +241,10 @@ export interface PeerHeldEnvDeclaration {
|
|
|
230
241
|
};
|
|
231
242
|
/** 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
|
|
232
243
|
* another entry in this process names the variable (the narrowest, and the reading before this declaration existed).
|
|
233
|
-
* `{ isolationScope }` — to the
|
|
234
|
-
*
|
|
235
|
-
*
|
|
244
|
+
* `{ isolationScope }` — to the legs whose isolation scope (`TaskSpec.isolationScope`, else `TaskSpec.principal`) is this one; a leg
|
|
245
|
+
* 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
|
|
246
|
+
* 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
|
|
247
|
+
* delegation tool starts does); a delegated leg with no tree domain, or outside it, never is. `"every_leg"` — to every leg
|
|
236
248
|
* of this thread: ONLY for an entry of the deployment itself, never one of a principal's — in a deployment of several principals it
|
|
237
249
|
* says the entry's name to every session. */
|
|
238
250
|
readonly namedTo?: PeerHeldEnvAudience;
|
|
@@ -247,14 +259,13 @@ export interface PeerHeldEnvReceipt {
|
|
|
247
259
|
/** 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
|
|
248
260
|
* name was taken in. Empty when all were. */
|
|
249
261
|
readonly notTaken: readonly PeerHeldEnvNameNotTaken[];
|
|
250
|
-
/** The names this call took in that the table did not hold before, that this process's environment holds now,
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* it lists every name newly taken in that this process's environment holds: it says only "may still be in a child already started". */
|
|
262
|
+
/** The names this call took in that the table did not hold before, that this process's environment holds now, once the engine has
|
|
263
|
+
* spawned a child under the scrub in this thread: a shell child of `NodeExecutionEnv` (a command — which may be adopted as a
|
|
264
|
+
* background shell — or a background shell) or a language server of `NodeLspManager`, from its spawn call on, whether or not the spawn
|
|
265
|
+
* 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
|
|
266
|
+
* 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
|
|
267
|
+
* 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
|
|
268
|
+
* 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. */
|
|
258
269
|
readonly heldLate: readonly string[];
|
|
259
270
|
}
|
|
260
271
|
/**
|
|
@@ -281,7 +292,7 @@ export interface PeerHeldEnvReceipt {
|
|
|
281
292
|
*
|
|
282
293
|
* 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
|
|
283
294
|
* configuration change (only what is new takes effect). A child's environment is composed when it starts: a child already running keeps
|
|
284
|
-
* what it started with, so a declaration made after a
|
|
295
|
+
* what it started with, so a declaration made after such a child started may be late for it — {@link PeerHeldEnvReceipt.heldLate}
|
|
285
296
|
* names what may be. Per THREAD, as {@link declareWithheldEnv}: a host that composes a child's environment in a worker declares there too.
|
|
286
297
|
*
|
|
287
298
|
* The two declarations, side by side: {@link declareWithheldEnv} — the engine's own credentials (names and values): withheld under EVERY
|
|
@@ -357,14 +368,14 @@ export declare function credentialHeaderValues(headers: Readonly<Record<string,
|
|
|
357
368
|
/** Test seam: never called by production code (a host re-declares `{ names: [], values: [] }`; what the engine took in stays). */
|
|
358
369
|
export declare function __resetWithheldEnv(): void;
|
|
359
370
|
/**
|
|
360
|
-
* THE environment a child spawned ON THIS HOST inherits: the policy's arm,
|
|
361
|
-
* declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
|
|
371
|
+
* THE environment a child spawned ON THIS HOST inherits: the policy's arm, which under every policy withholds the engine's own
|
|
372
|
+
* credentials — a declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
|
|
362
373
|
* {@link holdOwnCredentialValues}). The arms: `"scrub"` (and absent) is this process's environment through
|
|
363
|
-
* {@link scrubSecretEnv}
|
|
374
|
+
* {@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
|
|
364
375
|
* namespace (the namespace rule, {@link isNamespaceCredentialName}, and none of the scrub's other rules); a `string[]` is exactly the
|
|
365
376
|
* named variables that are set, as written — a strict allow list, so a name it leaves out (`PATH` included) is not
|
|
366
|
-
* inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld
|
|
367
|
-
*
|
|
377
|
+
* inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld, one each, under the first rule
|
|
378
|
+
* that answers ({@link judgeInheritedEntries}: a shape rule, else `own-credential`, else `peer-held`).
|
|
368
379
|
*
|
|
369
380
|
* A policy {@link inheritEnvPolicyProblem} refuses throws that reason HERE, at every spawn, read against the
|
|
370
381
|
* declaration as it stands: a value that is no policy at all (never read as the scrub), and an allow list naming a
|
|
@@ -373,6 +384,13 @@ export declare function __resetWithheldEnv(): void;
|
|
|
373
384
|
* ask first, so a host that declared before building them hears it at start-up.
|
|
374
385
|
*/
|
|
375
386
|
export declare function inheritedHostEnv(policy: InheritEnvPolicy | undefined, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
|
|
387
|
+
/** Record that the engine spawned a child — a shell child (a command, which may be adopted as a background shell; a background shell)
|
|
388
|
+
* or a language server — with an environment composed under `policy`: the question {@link PeerHeldEnvReceipt.heldLate} asks ("may a
|
|
389
|
+
* child already started hold this name"). Only ever set: a child that has closed may have left a service holding the same environment
|
|
390
|
+
* 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
|
|
391
|
+
* policy handed it every variable a later declaration holds). Called by the site that spawned it, right after the spawn call — the
|
|
392
|
+
* environment is the child's from that call on, whether or not the spawn later fails. Not part of the package entry. */
|
|
393
|
+
export declare function noteChildSpawned(policy: InheritEnvPolicy | undefined): void;
|
|
376
394
|
/** What a child spawned on this host starts with ({@link hostChildEnv}), and the inherited entries it does not receive:
|
|
377
395
|
* the inheritance's findings less every name the composed environment sets (a grant's entry is the host's, never a loss). */
|
|
378
396
|
export interface HostChildEnv {
|
|
@@ -385,13 +403,18 @@ export interface HostChildInheritance {
|
|
|
385
403
|
/** How much of the base a child inherits — the {@link InheritEnvPolicy} (absent: `"scrub"`). */
|
|
386
404
|
readonly policy?: InheritEnvPolicy | undefined;
|
|
387
405
|
/** The settings file's `env` block: laid over this process's environment BEFORE the policy reads it, so it is part of
|
|
388
|
-
* the base — read by the same arm and the same own-credentials
|
|
406
|
+
* the base — read by the same arm and the same own-credentials judgment as every other inherited entry (by name and
|
|
389
407
|
* by value), its withheld entries accounted with `layer: "settingsEnv"`. A name it sets wins over this process's
|
|
390
408
|
* variable of that name (compared as the platform compares names, the value under the spelling the process has);
|
|
391
409
|
* an `undefined` value unsets it. A grant laid after the inherited part wins over it. Absent: the base is this
|
|
392
410
|
* process's environment, exactly. Read once, as a grant is read; a bad one is refused as a bad grant is. */
|
|
393
411
|
readonly settingsEnv?: Readonly<NodeJS.ProcessEnv> | undefined;
|
|
394
412
|
}
|
|
413
|
+
type EnvEntries = readonly (readonly [string, string | undefined])[];
|
|
414
|
+
/** Why one environment layer — a grant (`label` = `env grant <n>`) or the settings layer (`settingsEnv`) — is not an
|
|
415
|
+
* object of variable names to strings, or its entries: read once, as a spread reads it (own enumerable entries). A bad
|
|
416
|
+
* name is not repeated and no value is: either may hold a credential. */
|
|
417
|
+
export declare function readEnvLayer(layer: unknown, label: string): EnvEntries | string;
|
|
395
418
|
/** Why {@link hostChildEnv} would refuse these inputs, or `undefined` — the same judgment. It takes the table (or a bare policy), so
|
|
396
419
|
* `{}` reads as `scrub`; to judge one policy value alone — a configuration field — use {@link inheritEnvPolicyProblem}. It answers a
|
|
397
420
|
* sentence for every input the judgment can read; a caller's own getter or list element that reads once and throws on a later read
|
|
@@ -429,8 +452,8 @@ export declare function declaredInheritEntry(value: unknown): {
|
|
|
429
452
|
/** Test seam: never called by production code. */
|
|
430
453
|
export declare function __resetSecretEnvScrubNoticeAnnouncement(): void;
|
|
431
454
|
/** What both disclosures say about one set of findings: every withheld name, and those that are the engine's own
|
|
432
|
-
* credentials — withheld under every policy —
|
|
433
|
-
*
|
|
455
|
+
* credentials — withheld under every policy — whatever kind a finding says ({@link ownCredentialJudge}, the
|
|
456
|
+
* composition's own judgment, over the entry's value in this process's environment: every finding names an entry of
|
|
434
457
|
* it). The rest the policy withheld: an allow list naming them hands them on, and so does `"all"` — except the names of the
|
|
435
458
|
* engine's own namespace ({@link isNamespaceCredentialName}), which `"all"` withholds too. */
|
|
436
459
|
export declare function withheldEnvNames(findings: readonly SecretEnvFinding[]): {
|
|
@@ -473,12 +496,13 @@ export interface WithheldEnvRemedy {
|
|
|
473
496
|
* and the one thing to do if a command needs a withheld variable (the engine's own credentials: nothing hands them on; a name
|
|
474
497
|
* 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
|
|
475
498
|
* 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
|
|
476
|
-
* variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope
|
|
477
|
-
* {@link peerHeldHalf}).
|
|
499
|
+
* variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope`, read
|
|
500
|
+
* against `deliveredScope`, the scope of the root a delegated leg's notice is delivered to ({@link noticeReaderScope}) — {@link peerHeldHalf}).
|
|
478
501
|
*/
|
|
479
502
|
export declare function withheldEnvUserNotice(withheld: readonly SecretEnvFinding[] | "unknown", at: {
|
|
480
503
|
sessionId: string;
|
|
481
504
|
runId?: string | undefined;
|
|
482
505
|
sourceSessionId?: string | undefined;
|
|
483
506
|
agentId?: string | undefined;
|
|
484
|
-
}, mine?: PeerEntriesTaken, isolationScope?: string): EngineNotice | undefined;
|
|
507
|
+
}, mine?: PeerEntriesTaken, isolationScope?: string, deliveredScope?: string): EngineNotice | undefined;
|
|
508
|
+
export {};
|
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) {
|
|
@@ -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
|
|
@@ -141,7 +152,10 @@ function withholdEntries(env, judge, findings) {
|
|
|
141
152
|
return Object.fromEntries(kept);
|
|
142
153
|
}
|
|
143
154
|
function envNameKey(name) {
|
|
144
|
-
return process.platform
|
|
155
|
+
return envNameKeyOn(name, process.platform);
|
|
156
|
+
}
|
|
157
|
+
export function envNameKeyOn(name, platform) {
|
|
158
|
+
return platform === "win32" ? name.toUpperCase() : name;
|
|
145
159
|
}
|
|
146
160
|
const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
147
161
|
function isDeclarableVariableName(k) {
|
|
@@ -196,7 +210,7 @@ const peerHeldAudiencesOf = () => {
|
|
|
196
210
|
const slot = Reflect.get(globalThis, PEER_HELD_AUDIENCES);
|
|
197
211
|
if (typeof slot === "object" && slot !== null && slot.named instanceof Map)
|
|
198
212
|
return slot;
|
|
199
|
-
const fresh = { named: new Map()
|
|
213
|
+
const fresh = { named: new Map() };
|
|
200
214
|
Reflect.set(globalThis, PEER_HELD_AUDIENCES, fresh);
|
|
201
215
|
return fresh;
|
|
202
216
|
};
|
|
@@ -219,7 +233,7 @@ const CANNOT_BE_WITHHELD = "which a child is handed from this process's environm
|
|
|
219
233
|
function runtimeSuppliedHolderOf(value, supplied = suppliedInProcess()) {
|
|
220
234
|
return Object.keys(supplied).find((k) => supplied[k] === value);
|
|
221
235
|
}
|
|
222
|
-
const suppliedIn = (env) =>
|
|
236
|
+
const suppliedIn = (env) => namedIn(runtimeSuppliedEnv(), env);
|
|
223
237
|
const suppliedInProcess = () => suppliedIn(process.env);
|
|
224
238
|
const PLACEHOLDER_KEY_WORDS = new Set([...ENV_VALUES.flagWords, ...ENV_VALUES.placeholderWords]);
|
|
225
239
|
export function isOneCharacterRepeated(text) {
|
|
@@ -449,7 +463,7 @@ export function declarePeerHeldEnv(declaration) {
|
|
|
449
463
|
continue;
|
|
450
464
|
}
|
|
451
465
|
const { key, isNew } = admitted;
|
|
452
|
-
if (isNew && audiences.
|
|
466
|
+
if (isNew && audiences.childSpawned === true && Object.hasOwn(process.env, spellingIn(process.env, name)) && !heldLate.includes(name))
|
|
453
467
|
heldLate.push(name);
|
|
454
468
|
if (read.audience !== undefined) {
|
|
455
469
|
let entries = audiences.named.get(key);
|
|
@@ -551,7 +565,7 @@ function sayNotTaken(value, why, onNotice) {
|
|
|
551
565
|
export function __resetWithheldEnv() {
|
|
552
566
|
Reflect.set(globalThis, WITHHELD_ENV, { names: NOTHING_NAMED, declared: new Map(), held: new Map() });
|
|
553
567
|
Reflect.set(globalThis, PEER_HELD_ENV, new Map());
|
|
554
|
-
Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map()
|
|
568
|
+
Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map() });
|
|
555
569
|
intakeSaid.clear();
|
|
556
570
|
}
|
|
557
571
|
function ownCredentialJudge() {
|
|
@@ -561,20 +575,6 @@ function ownCredentialJudge() {
|
|
|
561
575
|
const own = new Set(table.names.map(envNameKey));
|
|
562
576
|
return (key, value) => own.has(envNameKey(key)) || (typeof value === "string" && (indexHas(table.declared, value) || indexHas(table.held, value)));
|
|
563
577
|
}
|
|
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
578
|
function policyShapeProblem(value) {
|
|
579
579
|
if (value === undefined || value === "all" || value === "scrub")
|
|
580
580
|
return undefined;
|
|
@@ -601,21 +601,18 @@ function inheritedOver(policy, settings, findings) {
|
|
|
601
601
|
base = Object.fromEntries([...layered.values()].filter((entry) => entry[1] !== undefined));
|
|
602
602
|
}
|
|
603
603
|
const found = [];
|
|
604
|
-
const inherited =
|
|
604
|
+
const inherited = policyArm(policy, base, found);
|
|
605
605
|
for (const f of found)
|
|
606
606
|
findings?.push(settingsNames.has(envNameKey(f.key)) ? { ...f, layer: "settingsEnv" } : f);
|
|
607
607
|
return inherited;
|
|
608
608
|
}
|
|
609
609
|
export function inheritedHostEnv(policy, findings) {
|
|
610
|
-
|
|
611
|
-
const inherited = inheritedOver(policy, undefined, findings);
|
|
612
|
-
if (underScrub)
|
|
613
|
-
noteScrubComposed();
|
|
614
|
-
return inherited;
|
|
610
|
+
return inheritedOver(policy, undefined, findings);
|
|
615
611
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
612
|
+
export function noteChildSpawned(policy) {
|
|
613
|
+
if (policy === "all" || Array.isArray(policy))
|
|
614
|
+
return;
|
|
615
|
+
peerHeldAudiencesOf().childSpawned = true;
|
|
619
616
|
}
|
|
620
617
|
const HOST_CHILD_INHERITANCE_KEYS = optionKeys()({ policy: 0, settingsEnv: 0 });
|
|
621
618
|
function layInto(entries, layer) {
|
|
@@ -623,7 +620,7 @@ function layInto(entries, layer) {
|
|
|
623
620
|
entries.set(envNameKey(name), [entries.get(envNameKey(name))?.[0] ?? name, value]);
|
|
624
621
|
}
|
|
625
622
|
const unkeptCharacter = (text) => (text.includes("\0") ? "a NUL" : UNPAIRED_SURROGATE_RE.test(text) ? "an unpaired surrogate" : undefined);
|
|
626
|
-
function readEnvLayer(layer, label) {
|
|
623
|
+
export function readEnvLayer(layer, label) {
|
|
627
624
|
try {
|
|
628
625
|
if (typeof layer !== "object" || layer === null || Array.isArray(layer))
|
|
629
626
|
return `${label} must be an object of variable names to strings (got ${kindOf(layer)})`;
|
|
@@ -664,7 +661,7 @@ function readInheritance(inherit) {
|
|
|
664
661
|
}
|
|
665
662
|
return { policy: table.policy, settings: table.settingsEnv === undefined ? undefined : readEnvLayer(table.settingsEnv, "settingsEnv") };
|
|
666
663
|
}
|
|
667
|
-
function composeHostChildEnv(inherit, grants
|
|
664
|
+
function composeHostChildEnv(inherit, grants) {
|
|
668
665
|
const read = readInheritance(inherit);
|
|
669
666
|
if (typeof read === "string")
|
|
670
667
|
return read;
|
|
@@ -681,7 +678,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
|
|
|
681
678
|
return read.settings;
|
|
682
679
|
const findings = [];
|
|
683
680
|
const entries = new Map();
|
|
684
|
-
const underScrub = forChild && isScrubPolicy(read.policy);
|
|
685
681
|
for (const entry of Object.entries(inheritedOver(read.policy, read.settings, findings)))
|
|
686
682
|
entries.set(envNameKey(entry[0]), entry);
|
|
687
683
|
for (let i = 0; i < grants.length; i++) {
|
|
@@ -693,8 +689,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
|
|
|
693
689
|
layInto(entries, layer);
|
|
694
690
|
}
|
|
695
691
|
const env = Object.fromEntries(entries.values());
|
|
696
|
-
if (underScrub)
|
|
697
|
-
noteScrubComposed();
|
|
698
692
|
return { env, withheld: findings.filter((f) => entries.get(envNameKey(f.key))?.[1] === undefined) };
|
|
699
693
|
}
|
|
700
694
|
export function hostChildEnvProblem(inherit, ...grants) {
|
|
@@ -702,21 +696,21 @@ export function hostChildEnvProblem(inherit, ...grants) {
|
|
|
702
696
|
return typeof composed === "string" ? composed : undefined;
|
|
703
697
|
}
|
|
704
698
|
export function hostChildEnv(inherit, ...grants) {
|
|
705
|
-
const composed = composeHostChildEnv(inherit, grants
|
|
699
|
+
const composed = composeHostChildEnv(inherit, grants);
|
|
706
700
|
if (typeof composed === "string")
|
|
707
701
|
throw new Error(composed);
|
|
708
702
|
return composed;
|
|
709
703
|
}
|
|
710
704
|
function policyArm(policy, base, findings) {
|
|
711
705
|
if (policy === "all")
|
|
712
|
-
return withholdEntries(base,
|
|
713
|
-
if (!Array.isArray(policy))
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
706
|
+
return withholdEntries(base, policy, findings);
|
|
707
|
+
if (!Array.isArray(policy))
|
|
708
|
+
return scrubSecretEnv(base, findings);
|
|
709
|
+
return withholdEntries(namedIn(policy, base), policy, findings);
|
|
710
|
+
}
|
|
711
|
+
function namedIn(names, base) {
|
|
718
712
|
const arm = [];
|
|
719
|
-
for (const k of
|
|
713
|
+
for (const k of names) {
|
|
720
714
|
const name = spellingIn(base, k);
|
|
721
715
|
const value = Object.hasOwn(base, name) ? base[name] : undefined;
|
|
722
716
|
if (value !== undefined)
|
|
@@ -785,9 +779,15 @@ function peerHeldHalf(peers, mine, isolationScope) {
|
|
|
785
779
|
`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
780
|
`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
781
|
}
|
|
788
|
-
|
|
782
|
+
function noticeReaderScope(delegated, isolationScope, deliveredScope) {
|
|
783
|
+
if (!delegated)
|
|
784
|
+
return isolationScope;
|
|
785
|
+
return deliveredScope !== ANONYMOUS_SCOPE && isolationScope !== undefined && isolationScope === deliveredScope ? isolationScope : undefined;
|
|
786
|
+
}
|
|
787
|
+
export function withheldEnvUserNotice(withheld, at, mine, isolationScope, deliveredScope) {
|
|
789
788
|
const route = { sessionId: at.sessionId, ...(at.sourceSessionId !== undefined ? { sourceSessionId: at.sourceSessionId } : {}), ...(at.agentId !== undefined ? { agentId: at.agentId } : {}), ...(at.runId !== undefined ? { runId: at.runId } : {}) };
|
|
790
789
|
const delegated = at.sourceSessionId !== undefined;
|
|
790
|
+
const readerScope = noticeReaderScope(delegated, isolationScope, deliveredScope);
|
|
791
791
|
const shell = delegated ? "the tool shell of a delegated agent in this session" : "the tool shell in this session";
|
|
792
792
|
const subject = delegated ? "A delegated agent's tool shell in this session" : "The tool shell in this session";
|
|
793
793
|
if (withheld === "unknown") {
|
|
@@ -809,7 +809,7 @@ export function withheldEnvUserNotice(withheld, at, mine, isolationScope) {
|
|
|
809
809
|
const needs = (list) => (list.length === 1 ? "it" : "one of them");
|
|
810
810
|
const halves = [
|
|
811
811
|
...(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,
|
|
812
|
+
...(peers.length > 0 ? [peerHeldHalf(peers, mine, readerScope)] : []),
|
|
813
813
|
...(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
814
|
...(ownCredentials.length > 0 ? [`${ownCredentials.join(", ")} — ${OWN_CREDENTIAL}(s), never handed on, whatever the run's environment inheritance says`] : []),
|
|
815
815
|
];
|
|
@@ -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";
|