@sema-agent/core 7.72.0 → 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 +319 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- 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 +1 -0
- 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.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/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -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.js +7 -1
- 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/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +30 -22
- 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/governance-codes.d.ts +7 -1
- package/dist/core/governance-codes.js +13 -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/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 +21 -6
- package/dist/core/mode-policy.js +15 -6
- 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-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/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 +21 -5
- 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/leg-frame.js +3 -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 +21 -16
- package/dist/core/runner/person-path-rows.js +80 -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 +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-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +12 -1
- 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-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 +36 -27
- 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 +5 -2
- package/dist/core/runner/resume-apply.js +11 -5
- 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/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +3 -0
- 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 +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/secret-env.d.ts +53 -37
- package/dist/core/secret-env.js +44 -47
- 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/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 +10 -3
- package/dist/core/task-notification.d.ts +96 -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 +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-mount-facts.d.ts +1 -1
- package/dist/core/tool-mount-facts.js +1 -0
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +6 -0
- 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 +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-spec.d.ts +9 -2
- 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.js +3 -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/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/index.d.ts +18 -7
- package/dist/index.js +13 -4
- 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 -55
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- 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/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/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-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +96 -14
- 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 +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +131 -1
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -4,7 +4,7 @@ import { admittedProviderMessage } from "../../brain/provider-message.js";
|
|
|
4
4
|
import { isProviderCondition, isProviderConditionSource } from "../../brain/provider-dialect.js";
|
|
5
5
|
import { admittedRequestRoute } from "../../brain/request-route.js";
|
|
6
6
|
import { REFUSED_REQUEST_PARTS } from "../terminal-cause.js";
|
|
7
|
-
import { readMember } from "../thrown-value.js";
|
|
7
|
+
import { readMember, thrownText } from "../thrown-value.js";
|
|
8
8
|
import { egressText } from "../untrusted-egress.js";
|
|
9
9
|
import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
|
|
10
10
|
import { isSensitiveRecordKey, REDACTION_MARKS } from "@sema-agent/primitives";
|
|
@@ -251,6 +251,21 @@ export function thrownFailureOf(err, text) {
|
|
|
251
251
|
const detail = codedFailureDetailOf(coded.code, coded.link);
|
|
252
252
|
return { code: coded.code, message, ...(detail !== undefined ? { detail } : {}) };
|
|
253
253
|
}
|
|
254
|
+
export function failedPreRunResult(err, spec) {
|
|
255
|
+
const { code, message, detail } = thrownFailureOf(err, thrownText(err));
|
|
256
|
+
const specTaskId = readMember(spec, "taskId");
|
|
257
|
+
const specSessionId = readMember(spec, "sessionId");
|
|
258
|
+
return {
|
|
259
|
+
taskId: typeof specTaskId === "string" && specTaskId.length > 0 ? specTaskId : "unknown",
|
|
260
|
+
sessionId: typeof specSessionId === "string" && specSessionId.length > 0 ? specSessionId : "unknown",
|
|
261
|
+
terminal: { kind: "failed", ...(code !== undefined ? { code } : {}), message, ...(detail !== undefined ? { detail } : {}) },
|
|
262
|
+
result: "",
|
|
263
|
+
resultEntryIds: [],
|
|
264
|
+
intake: { committed: false },
|
|
265
|
+
continuesFrom: { none: "unsettled" },
|
|
266
|
+
stats: { turns: 0, tokens: 0, toolCalls: 0, cachedTokens: 0, costMicroUsd: 0, usageMissing: true },
|
|
267
|
+
};
|
|
268
|
+
}
|
|
254
269
|
export function completedTerminalOf(final) {
|
|
255
270
|
const finishReasonUnknown = readMember(final, "finishReasonUnknown");
|
|
256
271
|
if (typeof finishReasonUnknown === "string" && isProviderEchoShape(finishReasonUnknown))
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* (`EffectivePermissionRules.unreadableRows`), as the run's readers judge them. A row whose identity read stands in the read's rules as
|
|
4
4
|
* written (`as_read`): these readers pass it by. A row whose identity did not read stands at its strictest reading over the calls it may
|
|
5
5
|
* reach — the partition's own failure law, scoped to the row (a call it reaches in its scope takes the answer a call takes while a
|
|
6
|
-
* partition cannot be read; a row reaching every call makes every path check that is no call refuse
|
|
6
|
+
* partition cannot be read; a row reaching every call in its scope makes every path check that is no call refuse — the scope first, by
|
|
7
|
+
* {@link unreadableRowsInScope}, for every reader).
|
|
7
8
|
*/
|
|
8
9
|
import type { EffectivePermissionRules } from "../permission-rule-provider.js";
|
|
9
10
|
import { type ScopeRootIdentity } from "../permission-rule-model.js";
|
|
@@ -68,6 +68,9 @@ export interface RunnerDeps {
|
|
|
68
68
|
/** The deployment's Brain; every engine read of it goes through the model lane (`brain/model-lane.ts`), which walks a catalog
|
|
69
69
|
* entry's `Model.fallbacks` chain on this same Brain and passes any other request straight through. */
|
|
70
70
|
brain: Brain;
|
|
71
|
+
/** Deployment-declared host process identity (`{ instanceId, startedAt }`, epoch ms), projected frozen onto `WiringManifest.host`
|
|
72
|
+
* on both static and effective halves iff declared; refused (`config.invalid_argument`) when malformed; out of `configFingerprint` and `swapDeps`. */
|
|
73
|
+
host?: import("./host-instance.js").HostInstanceDeclaration;
|
|
71
74
|
/** Catalog used to resolve string ModelRefs to Model objects; its door (`new Runner` / `swapDeps`) also resolves each entry's
|
|
72
75
|
* `fallbacks` words over it (`config.model_fallback_invalid` on a bad chain). */
|
|
73
76
|
models?: Record<string, Model>;
|
|
@@ -154,13 +157,13 @@ export interface RunnerDeps {
|
|
|
154
157
|
*/
|
|
155
158
|
hands?: HandsBandOptions;
|
|
156
159
|
/**
|
|
157
|
-
* design/199 件B — DEPLOYMENT-layer ADDITIONS to the
|
|
160
|
+
* design/199 件B / #4800 — DEPLOYMENT-layer ADDITIONS to the sensitive-path deny set
|
|
158
161
|
* ({@link import("../tools/fs/read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}); see
|
|
159
|
-
* {@link TaskSpec.readDenyPatterns} for the judged surfaces
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* #245 revision of D-4), not a
|
|
163
|
-
* prepare (#123).
|
|
162
|
+
* {@link TaskSpec.readDenyPatterns} for the judged surfaces and the shell's reach: reads and writes both, while
|
|
163
|
+
* built-in tiers stay read-only and pair with the write-protection table. Add-only on THIS seat: unions with the
|
|
164
|
+
* active built-ins and any task-layer additions, and `[]` ≡ absent — narrowing the built-in set is the sibling
|
|
165
|
+
* knobs' job ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude}, #245 revision of D-4), not a
|
|
166
|
+
* replacement escape hatch here. Bad entry shapes refuse loudly at prepare (#123).
|
|
164
167
|
*/
|
|
165
168
|
readDenyPatterns?: readonly import("../tools/fs/read-deny.js").ReadDenyEntry[];
|
|
166
169
|
/**
|
|
@@ -1329,10 +1332,10 @@ export interface RunnerDeps {
|
|
|
1329
1332
|
* deployment wires the factory.
|
|
1330
1333
|
*/
|
|
1331
1334
|
executionEnvFactory?: import("./remote-env.js").ExecutionEnvFactory;
|
|
1332
|
-
/** Whether `executionEnvFactory` answers purpose `"read_changes"` (
|
|
1333
|
-
* writes nothing). Absent / `false` ⇒ never
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1335
|
+
/** Whether `executionEnvFactory` answers purpose `"read_changes"` (read-only readings outside a run — `Runner.readSessionChanges`,
|
|
1336
|
+
* `Runner.previewInstructions`: attaches or throws `env.purpose_unsupported`; mints and writes nothing). Absent / `false` ⇒ never
|
|
1337
|
+
* asked for it, and no static `executionEnv` stands in: those out-of-run reads have no hands for the working tree. A Runner with no
|
|
1338
|
+
* factory ignores the value; a non-boolean is refused at construction (`config.invalid_argument`). */
|
|
1336
1339
|
executionEnvFactoryHonorsReadChanges?: boolean;
|
|
1337
1340
|
/**
|
|
1338
1341
|
* Containment root for the file tools (design/44 §4 invariant 7): every path must resolve within it, else the tool rejects
|
|
@@ -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,12 +65,16 @@ 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[];
|
|
@@ -230,9 +239,10 @@ export interface PeerHeldEnvDeclaration {
|
|
|
230
239
|
};
|
|
231
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
|
|
232
241
|
* another entry in this process names the variable (the narrowest, and the reading before this declaration existed).
|
|
233
|
-
* `{ isolationScope }` — to the
|
|
234
|
-
*
|
|
235
|
-
*
|
|
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
|
|
236
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
|
|
237
247
|
* says the entry's name to every session. */
|
|
238
248
|
readonly namedTo?: PeerHeldEnvAudience;
|
|
@@ -247,14 +257,13 @@ export interface PeerHeldEnvReceipt {
|
|
|
247
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
|
|
248
258
|
* name was taken in. Empty when all were. */
|
|
249
259
|
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". */
|
|
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. */
|
|
258
267
|
readonly heldLate: readonly string[];
|
|
259
268
|
}
|
|
260
269
|
/**
|
|
@@ -281,7 +290,7 @@ export interface PeerHeldEnvReceipt {
|
|
|
281
290
|
*
|
|
282
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
|
|
283
292
|
* 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
|
|
293
|
+
* what it started with, so a declaration made after such a child started may be late for it — {@link PeerHeldEnvReceipt.heldLate}
|
|
285
294
|
* names what may be. Per THREAD, as {@link declareWithheldEnv}: a host that composes a child's environment in a worker declares there too.
|
|
286
295
|
*
|
|
287
296
|
* The two declarations, side by side: {@link declareWithheldEnv} — the engine's own credentials (names and values): withheld under EVERY
|
|
@@ -357,14 +366,14 @@ export declare function credentialHeaderValues(headers: Readonly<Record<string,
|
|
|
357
366
|
/** Test seam: never called by production code (a host re-declares `{ names: [], values: [] }`; what the engine took in stays). */
|
|
358
367
|
export declare function __resetWithheldEnv(): void;
|
|
359
368
|
/**
|
|
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},
|
|
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},
|
|
362
371
|
* {@link holdOwnCredentialValues}). The arms: `"scrub"` (and absent) is this process's environment through
|
|
363
|
-
* {@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
|
|
364
373
|
* namespace (the namespace rule, {@link isNamespaceCredentialName}, and none of the scrub's other rules); a `string[]` is exactly the
|
|
365
374
|
* 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
|
-
*
|
|
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`).
|
|
368
377
|
*
|
|
369
378
|
* A policy {@link inheritEnvPolicyProblem} refuses throws that reason HERE, at every spawn, read against the
|
|
370
379
|
* 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 +382,13 @@ export declare function __resetWithheldEnv(): void;
|
|
|
373
382
|
* ask first, so a host that declared before building them hears it at start-up.
|
|
374
383
|
*/
|
|
375
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;
|
|
376
392
|
/** What a child spawned on this host starts with ({@link hostChildEnv}), and the inherited entries it does not receive:
|
|
377
393
|
* the inheritance's findings less every name the composed environment sets (a grant's entry is the host's, never a loss). */
|
|
378
394
|
export interface HostChildEnv {
|
|
@@ -385,7 +401,7 @@ export interface HostChildInheritance {
|
|
|
385
401
|
/** How much of the base a child inherits — the {@link InheritEnvPolicy} (absent: `"scrub"`). */
|
|
386
402
|
readonly policy?: InheritEnvPolicy | undefined;
|
|
387
403
|
/** 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
|
|
404
|
+
* the base — read by the same arm and the same own-credentials judgment as every other inherited entry (by name and
|
|
389
405
|
* by value), its withheld entries accounted with `layer: "settingsEnv"`. A name it sets wins over this process's
|
|
390
406
|
* variable of that name (compared as the platform compares names, the value under the spelling the process has);
|
|
391
407
|
* an `undefined` value unsets it. A grant laid after the inherited part wins over it. Absent: the base is this
|
|
@@ -429,8 +445,8 @@ export declare function declaredInheritEntry(value: unknown): {
|
|
|
429
445
|
/** Test seam: never called by production code. */
|
|
430
446
|
export declare function __resetSecretEnvScrubNoticeAnnouncement(): void;
|
|
431
447
|
/** 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
|
-
*
|
|
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
|
|
434
450
|
* it). The rest the policy withheld: an allow list naming them hands them on, and so does `"all"` — except the names of the
|
|
435
451
|
* engine's own namespace ({@link isNamespaceCredentialName}), which `"all"` withholds too. */
|
|
436
452
|
export declare function withheldEnvNames(findings: readonly SecretEnvFinding[]): {
|
|
@@ -473,12 +489,12 @@ export interface WithheldEnvRemedy {
|
|
|
473
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
|
|
474
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
|
|
475
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
|
|
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}).
|
|
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}).
|
|
478
494
|
*/
|
|
479
495
|
export declare function withheldEnvUserNotice(withheld: readonly SecretEnvFinding[] | "unknown", at: {
|
|
480
496
|
sessionId: string;
|
|
481
497
|
runId?: string | undefined;
|
|
482
498
|
sourceSessionId?: string | undefined;
|
|
483
499
|
agentId?: string | undefined;
|
|
484
|
-
}, 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) {
|
|
@@ -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
|
];
|
|
@@ -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. */
|