@sema-agent/core 7.73.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 +246 -0
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +4 -4
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +54 -4
- 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 +3 -3
- package/dist/brain/openai.js +1 -1
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +9 -7
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/allow-entry.js +1 -1
- 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/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +2 -2
- package/dist/core/checkpoint-store.d.ts +2 -0
- package/dist/core/checkpoint-store.js +8 -2
- 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/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +9 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +14 -9
- package/dist/core/engine-version.js +1 -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 +8 -2
- package/dist/core/governance-codes.js +9 -1
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +2 -0
- package/dist/core/mode-policy.d.ts +4 -0
- package/dist/core/mode-policy.js +18 -2
- 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/permission-rule-org.js +13 -3
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -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-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/runner/checkpoint-scope.d.ts +1 -0
- package/dist/core/runner/checkpoint-scope.js +4 -2
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +2 -0
- 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/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- 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/person-path-rows.d.ts +6 -0
- package/dist/core/runner/person-path-rows.js +13 -0
- package/dist/core/runner/prepare-config-doors.js +9 -5
- 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.js +3 -2
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-task.js +6 -3
- package/dist/core/runner/prepare-wiring-manifest.js +3 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- 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 +1 -1
- package/dist/core/runner/run-leg.js +2 -2
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +24 -1
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- 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/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +4 -0
- package/dist/core/secret-env.d.ts +8 -0
- package/dist/core/secret-env.js +5 -2
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/task-event.d.ts +4 -4
- package/dist/core/task-notification.js +6 -1
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry.d.ts +1 -0
- package/dist/core/task-registry.js +4 -3
- package/dist/core/task-result.d.ts +5 -3
- package/dist/core/task-spec-members.js +8 -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 +7 -3
- package/dist/core/tool-mount-facts.js +6 -2
- package/dist/core/tool-mount-plan.d.ts +1 -1
- package/dist/core/tool-mount-plan.js +4 -3
- package/dist/core/tool-result-store.d.ts +37 -1
- package/dist/core/tool-result-store.js +168 -23
- package/dist/core/trace.d.ts +3 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +225 -13
- package/dist/engine/harness/types.d.ts +25 -0
- package/dist/engine/llm/types.d.ts +8 -0
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -2
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +1 -1
- package/dist/orchestration/workflow.js +2 -2
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +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/fs-bash.js +13 -11
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.js +39 -9
- package/dist/tools/fs/shell-read-plan.d.ts +2 -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/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 +62 -3
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { classifyQuestionOutcome, isLiveQuestionFace } from "../ask-question.js";
|
|
1
|
+
import { classifyQuestionOutcome, isLiveQuestionFace, QUESTION_OUTCOME_FAULT_TEXT } from "../ask-question.js";
|
|
2
2
|
import { capturedJsonOf, editOfAnswer, exactBoundInputHashOf } from "../canonical-json.js";
|
|
3
3
|
import { bindingRefusalOf } from "../tool-policy.js";
|
|
4
4
|
import { CheckpointError, checkpointVersionOf, winnerFromOutcome } from "../checkpoint-store.js";
|
|
@@ -23,7 +23,10 @@ export function resumePolicyOutcome(input) {
|
|
|
23
23
|
if (suppliedAnswer !== undefined) {
|
|
24
24
|
const reading = classifyQuestionOutcome(suppliedAnswer);
|
|
25
25
|
if (reading.shape !== "answered") {
|
|
26
|
-
|
|
26
|
+
const why = reading.shape === "contradictory"
|
|
27
|
+
? QUESTION_OUTCOME_FAULT_TEXT[reading.fault]
|
|
28
|
+
: 'the value claims "unavailable", which is not an answer';
|
|
29
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume carried a content-ask \`answer\` that does not read as an answer (${why}) — ` +
|
|
27
30
|
"refusing pre-CAS rather than fabricating an empty human response; the checkpoint stays pending", { field: "answer" });
|
|
28
31
|
}
|
|
29
32
|
redeemedAnswer = reading.answer;
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* `classifier.role_defaulted`) are never named here.
|
|
12
12
|
*
|
|
13
13
|
* The word may be a TIER the deployment's tiers leave absent (nothing bound at that tier or below it, #2614): the same reading and the same
|
|
14
|
-
* chain, with `reason: "tier_unbound"` where a name the catalog does not hold says `"unknown_model_ref"` (the `summarize` line
|
|
15
|
-
*
|
|
16
|
-
* own model). A role whose own tier DEFAULT is absent while its seat names nothing is said nowhere — nothing was stated that went unmet; the
|
|
14
|
+
* chain, with `reason: "tier_unbound"` where a name the catalog does not hold says `"unknown_model_ref"` (the `summarize` line says "or the tier
|
|
15
|
+
* default for that role" only while that role's own tier default is bound, whatever the cause: with none declared or none bound there, the
|
|
16
|
+
* compaction pass is on the conversation's own model). A role whose own tier DEFAULT is absent while its seat names nothing is said nowhere — nothing was stated that went unmet; the
|
|
17
17
|
* walk goes on to the next role of its chain (`roleHop`, `src/core/roles.ts`).
|
|
18
18
|
*
|
|
19
19
|
* Root legs only: a delegated child inherits the deployment's maps and would repeat the parent's line once per spawn.
|
|
@@ -14,7 +14,7 @@ export function roleDefaultedNotice(u, ids) {
|
|
|
14
14
|
const shown = bindingShown(u.word);
|
|
15
15
|
const reason = u.cause === "tier_unbound" ? "tier_unbound" : "unknown_model_ref";
|
|
16
16
|
const absent = reason === "tier_unbound" ? absentTierReading(u.word) : undefined;
|
|
17
|
-
const standsIn = (STANDS_IN[u.role] ?? "its fallback chain decides") + (u.role === "summarize" &&
|
|
17
|
+
const standsIn = (STANDS_IN[u.role] ?? "its fallback chain decides") + (u.role === "summarize" && u.ownTierBound ? TIER_DEFAULT_STANDS_IN : "");
|
|
18
18
|
return {
|
|
19
19
|
code: "config.entries_not_applied",
|
|
20
20
|
message: absent !== undefined
|
|
@@ -7,7 +7,7 @@ import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
|
7
7
|
* told where the mode answers it unasked; the person is told by the run's row notice (`config.entries_not_applied`, kind `stored_rule_row`), not here. A read
|
|
8
8
|
* is told once the mode has settled ({@link PermissionModeController.whenArmed}) — the run's start read comes before the deployment's
|
|
9
9
|
* arming facts bind, and a mode the arming folds back (`auto` with no classifier wired, a relaxed mode the deployment denies) would read
|
|
10
|
-
* as itself then, the person
|
|
10
|
+
* as itself then, the person's sentence stating the wrong cost and the operator's line naming a mode the leg does not run under. A call's read finds the mode
|
|
11
11
|
* settled and tells at once. */
|
|
12
12
|
export declare function ruleStoreUnreadableNotice(onNotice: RunnerDeps["onNotice"], ids: {
|
|
13
13
|
readonly sessionId: string;
|
|
@@ -8,19 +8,19 @@ export function ruleStoreUnreadableNotice(onNotice, ids, record, modeSeat) {
|
|
|
8
8
|
const tell = (at, faults, rows) => {
|
|
9
9
|
const mode = modeSeat.observed;
|
|
10
10
|
const data = faults.map((f) => ({ sources: [...f.sources], reason: f.reason }));
|
|
11
|
-
|
|
11
|
+
const relaxed = modeAnswersUnasked(mode, "rule_unreadable");
|
|
12
|
+
if (relaxed) {
|
|
12
13
|
record.oncePerSession(announceDigest(RULE_STORE_UNREADABLE_RELAXED, `${mode}\n${rows !== undefined ? "rows\n" : ""}${ruleStoreFaultsKey(faults)}`), () => deliverEngineNotice(onNotice, {
|
|
13
14
|
code: RULE_STORE_UNREADABLE_RELAXED,
|
|
14
15
|
message: ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows),
|
|
15
16
|
detail: { at, mode, sessionId: ids.sessionId, runId: ids.runId, faults: data },
|
|
16
17
|
}));
|
|
17
|
-
return;
|
|
18
18
|
}
|
|
19
19
|
if (rows !== undefined)
|
|
20
20
|
return;
|
|
21
21
|
record.oncePerSession(announceDigest(RULE_STORE_UNAVAILABLE, ruleStoreFaultsKey(faults)), () => deliverEngineNotice(onNotice, {
|
|
22
22
|
code: RULE_STORE_UNAVAILABLE,
|
|
23
|
-
message: ruleStoreUnreadableNoticeSentence(at, faults),
|
|
23
|
+
message: ruleStoreUnreadableNoticeSentence(at, faults, relaxed ? mode : undefined),
|
|
24
24
|
detail: { at, sessionId: ids.sessionId, runId: ids.runId, faults: data },
|
|
25
25
|
}));
|
|
26
26
|
};
|
|
@@ -281,7 +281,7 @@ export function createHarnessHandlers(input) {
|
|
|
281
281
|
}, frames);
|
|
282
282
|
if (settled.gate?.disposition.kind === "denied")
|
|
283
283
|
noteExtensionCallDenied(prepared.modBus, event.toolCallId);
|
|
284
|
-
stampRowNotExecuted(event.result, settled
|
|
284
|
+
stampRowNotExecuted(event.result, settled);
|
|
285
285
|
emitTrace(rs.telemetry.tracer, () => ({
|
|
286
286
|
kind: "tool.call",
|
|
287
287
|
version: 1,
|
|
@@ -761,11 +761,11 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
761
761
|
announceToolCall(occurrences, callStart, { push: emit });
|
|
762
762
|
const decidedInput = frozenInputSnapshot(resolvedArgs);
|
|
763
763
|
occurrences.gateRound(pendingAction.toolCallId, decidedGate, decidedInput);
|
|
764
|
-
let notExecuted
|
|
764
|
+
let notExecuted;
|
|
765
765
|
const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
|
|
766
766
|
const settleEnd = async (isError, result, neverRan) => {
|
|
767
767
|
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef, verdicts: prepared.verdictLedger });
|
|
768
|
-
notExecuted = settled
|
|
768
|
+
notExecuted = settled;
|
|
769
769
|
const gate = settled.gate ?? decidedGate;
|
|
770
770
|
const word = await resume.recordExecutionOutcome(gate);
|
|
771
771
|
settleExecutionRecord(runner.deps.onNotice, word, { toolName: pendingAction.toolName, gate, sessionId: prepared.sessionId, runId: prepared.runId, scope: resume.cp.scope, identity: readGateIdentity(resume.cp.checkpointId, resume.cp.token) });
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
* `"unknown"` (or a read that throws) is a wiring fault: it is announced to the operator under the existing
|
|
24
24
|
* capability-shape code, once per run, and the person is told nothing — no reading defaults to `"unknown"`.
|
|
25
25
|
*
|
|
26
|
-
* The same seat relays the environment's
|
|
26
|
+
* The same seat relays the environment's two other disclosures about what its shell gets (`relayLateDeclaration`,
|
|
27
|
+
* `relayModelShellDropped`, below).
|
|
27
28
|
*/
|
|
28
29
|
import { type EngineNotice } from "../engine-notice.js";
|
|
29
30
|
import { type PeerEntriesTaken } from "../secret-env.js";
|
|
@@ -31,7 +32,7 @@ import type { ExecutionEnv } from "../../internal/harness.js";
|
|
|
31
32
|
import type { Prepared } from "./contracts.js";
|
|
32
33
|
export type WithheldShellEnvSeatInput = Pick<Prepared, "runId" | "sessionId" | "legNotice" | "toolRosterDeltas" | "announcedListingsRef" | "frameReceipts"> & {
|
|
33
34
|
readonly harness: {
|
|
34
|
-
readonly env: Pick<ExecutionEnv, "withheldEnv" | "lateDeclarationNotice">;
|
|
35
|
+
readonly env: Pick<ExecutionEnv, "withheldEnv" | "lateDeclarationNotice" | "modelShellDropped">;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
38
|
/** The seat, per run. `onToolStart` and `onToolEnd` never throw: a diagnostic may not be what fails a call. `peerEntries` = the (variable,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { shellStateEnvDroppedNotice } from "../model-shell.js";
|
|
2
3
|
import { withheldEnvUserNotice } from "../secret-env.js";
|
|
3
4
|
import { isEngineShellFace } from "../tool-catalog-entries.js";
|
|
4
5
|
import { toolCallFaceOf } from "../tool-roster.js";
|
|
@@ -18,6 +19,24 @@ function readWithheldEnv(env) {
|
|
|
18
19
|
return { malformed: "unreadable" };
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
function relayModelShellDropped(prepared, onNotice) {
|
|
23
|
+
const told = new WeakMap();
|
|
24
|
+
return () => {
|
|
25
|
+
try {
|
|
26
|
+
const record = prepared.harness.env.modelShellDropped;
|
|
27
|
+
const entries = readMember(record, "entries");
|
|
28
|
+
if (typeof record !== "object" || record === null || !Array.isArray(entries))
|
|
29
|
+
return;
|
|
30
|
+
const fresh = entries.slice(told.get(record) ?? 0);
|
|
31
|
+
if (fresh.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
told.set(record, entries.length);
|
|
34
|
+
deliverEngineNotice(onNotice, shellStateEnvDroppedNotice(fresh));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
21
40
|
function relayLateDeclaration(prepared, onNotice) {
|
|
22
41
|
let told = false;
|
|
23
42
|
return () => {
|
|
@@ -43,8 +62,12 @@ function relayLateDeclaration(prepared, onNotice) {
|
|
|
43
62
|
export function createWithheldShellEnvSeat(prepared, onNotice, peerEntries, isolationScope) {
|
|
44
63
|
let shapeFaultTold = false;
|
|
45
64
|
const relay = relayLateDeclaration(prepared, onNotice);
|
|
65
|
+
const relayDropped = relayModelShellDropped(prepared, onNotice);
|
|
46
66
|
return {
|
|
47
|
-
onToolEnd:
|
|
67
|
+
onToolEnd: () => {
|
|
68
|
+
relay();
|
|
69
|
+
relayDropped();
|
|
70
|
+
},
|
|
48
71
|
onToolStart(toolName) {
|
|
49
72
|
if (!isEngineShellFace(toolCallFaceOf(prepared.toolRosterDeltas.current, toolName)))
|
|
50
73
|
return;
|
|
@@ -95,8 +95,11 @@ const NEAR_MISS_EFFECT = {
|
|
|
95
95
|
allowed: "it admits nothing, so the tool it was written for is not granted",
|
|
96
96
|
denied: "it hides nothing, so the tool it was written for stays available to the agent",
|
|
97
97
|
};
|
|
98
|
-
function nearMissRefusal(where, side, flaw, code) {
|
|
99
|
-
|
|
98
|
+
function nearMissRefusal(where, side, flaw, code, poolUnlisted = false) {
|
|
99
|
+
const tail = poolUnlisted
|
|
100
|
+
? "Write the name as the tool is mounted — or, if the name is one a delegation tool's extraTools factory injects, declare it in that tool's extraToolNames so this run can list it."
|
|
101
|
+
: "Write the name as the tool is mounted.";
|
|
102
|
+
return refused(`${where} declares tool ${inertEntryPhrase(flaw)} in its ${LIST_WORD[side]}, a spelling that reaches no tool a run mounts — ${NEAR_MISS_EFFECT[side]}. ${tail}`, code, "near_miss");
|
|
100
103
|
}
|
|
101
104
|
function grammarSentence(where, side, entry, consequence) {
|
|
102
105
|
return `${where} declares tool ${inertEntryPhrase({ entry, reason: "grammar" })} in its ${LIST_WORD[side]}, a spelling no tool name can have — ${consequence} ${DENY_LIST_NAMES_ONLY}`;
|
|
@@ -152,7 +155,7 @@ const KEPT_ENTRY = {
|
|
|
152
155
|
};
|
|
153
156
|
const KEPT_ENTRY_UNLISTED_POOL = "so it is kept here: the pool this delegation tool hands its child cannot be listed, and the spawned child judges the entry against its own roster (another spelling of a tool it carries refuses the child before it starts; an exact name takes effect; a name nothing answers to there stays in force for a tool of that name mounted later)";
|
|
154
157
|
const PEER_WORD = { mcp: "MCP server", a2a: "A2A peer" };
|
|
155
|
-
function judgeToolNameList(where, side, value, universe, advise, code, retired, definition) {
|
|
158
|
+
function judgeToolNameList(where, side, value, universe, advise, code, retired, definition, hintUnlistedPool = false) {
|
|
156
159
|
const form = readToolNameListForm(where, side, ruleListUnderView(value, universe.retiredNames));
|
|
157
160
|
const refusing = definition === true ? form.flaws.find(isStructuralFlaw) : form.flaws[0];
|
|
158
161
|
if (refusing !== undefined)
|
|
@@ -177,7 +180,7 @@ function judgeToolNameList(where, side, value, universe, advise, code, retired,
|
|
|
177
180
|
const { inert } = compileAllowList([toolName], "deny", universe.known);
|
|
178
181
|
const flaw = inert[0] === undefined ? undefined : { ...inert[0], entry, ...(inert[0].reason === "near_miss" && inert[0].currentName !== undefined ? { carriedBy: universe.carrierOf(inert[0].currentName) } : {}) };
|
|
179
182
|
if (universe.complete && flaw?.currentName !== undefined)
|
|
180
|
-
throw nearMissRefusal(where, side, flaw, code);
|
|
183
|
+
throw nearMissRefusal(where, side, flaw, code, hintUnlistedPool);
|
|
181
184
|
if (toolName !== name) {
|
|
182
185
|
advise(new Error(`${where} declares ${renderListEntry(entry)} in its allowed tools: an allowed list names tools, not content, so this entry grants nothing — name the tool "${inlineUntrusted(toolName, 80)}" to grant it, or move the content rule to a denied list or a permission rule.`));
|
|
183
186
|
continue;
|
|
@@ -414,8 +417,9 @@ export function judgeRunToolLists(input) {
|
|
|
414
417
|
const silent = () => undefined;
|
|
415
418
|
const told = input.toldUpstream === true;
|
|
416
419
|
const ownAdvise = told ? silent : ownWhere === undefined ? adviseAuthor : advise;
|
|
420
|
+
const rootTaskLists = ownWhere === undefined && !input.legs.includes("delegated");
|
|
417
421
|
for (const [side, value] of own)
|
|
418
|
-
judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root, ownAdvise, "config.tool_face_control", told ? silent : retire);
|
|
422
|
+
judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root, ownAdvise, "config.tool_face_control", told ? silent : retire, undefined, rootTaskLists && !pool.complete);
|
|
419
423
|
}
|
|
420
424
|
if (definitionLayer !== undefined && definitionWhere !== undefined) {
|
|
421
425
|
judgeToolNameList(definitionWhere, "allowed", definitionLayer.allow, root, advise, "config.agent.unknown_tool", undefined, true);
|
|
@@ -99,7 +99,7 @@ export interface OccurrenceEnd {
|
|
|
99
99
|
/** See {@link toolEndBodyFrom}'s parameter of the same name. */
|
|
100
100
|
heldPark?: import("../agent-state.js").AgentPark;
|
|
101
101
|
}
|
|
102
|
-
/** What the end projection decided, for the readers that ride beside the frame (the trace row, the row's record, the rows' `notExecuted`). */
|
|
102
|
+
/** What the end projection decided, for the readers that ride beside the frame (the trace row, the row's record, the rows' `notExecuted` and `gate`). */
|
|
103
103
|
export interface SettledOccurrence extends Pick<OccurrenceEnd, "notExecuted"> {
|
|
104
104
|
/** The latest gate record — the call's disposition (absent when no gate exit saw it). */
|
|
105
105
|
gate?: GateOutcome;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `notExecuted` and `gate` — what the engine writes onto a persisted `toolResult` row for a call it has positive evidence never ran, in ONE place.
|
|
3
|
+
*
|
|
4
|
+
* The fact has one reading ({@link refusedBeforeRelease}, over the call's occurrence) and one return (`emitSettled`'s, beside the
|
|
5
|
+
* `tool_end` frame); every face that repeats it reads that return: the frame, the resumed leg's `toolResult` rows
|
|
6
|
+
* ({@link withRowNotExecuted}) and the live leg's ({@link stampRowNotExecuted}). `details.notExecuted` and `details.gate` on a
|
|
7
|
+
* persisted row are the ENGINE's keys: set from the settlement (`gate` as a structural copy of the end frame's verdict when
|
|
8
|
+
* `notExecuted` holds and the frame carried one) and dropped from whatever a tool wrote under either name ({@link rowDetailsOf}).
|
|
9
|
+
*
|
|
10
|
+
* A leaf: it reads the occurrence's type, the gate-outcome type and the guarded member readers, and writes nothing but the one result it is handed.
|
|
11
|
+
*/
|
|
12
|
+
import type { GateOutcome } from "../gate-outcome.js";
|
|
1
13
|
import type { ToolOccurrence } from "./tool-occurrence.js";
|
|
14
|
+
/** The end projection's row-facing settlement facts (`SettledOccurrence`'s `notExecuted` and `gate`). */
|
|
15
|
+
export interface RowEndFacts {
|
|
16
|
+
readonly notExecuted?: true;
|
|
17
|
+
readonly gate?: GateOutcome;
|
|
18
|
+
}
|
|
2
19
|
/** The engine's own judgment refused this call and it was never let go to an executor: the latest gate record is a
|
|
3
20
|
* refusal and the life never left `announced` — positive evidence the call did not run (a refusal recorded AFTER the
|
|
4
21
|
* release, by a station inside the execution, is not). A call whose start this stream never carried (a recovered
|
|
@@ -7,14 +24,16 @@ export declare function refusedBeforeRelease(occ: Pick<ToolOccurrence, "life" |
|
|
|
7
24
|
/** The one reading of the engine's positive evidence that a call never ran: refused before it was let go
|
|
8
25
|
* ({@link refusedBeforeRelease}), or answered in place of its body by an extension at `tool.call` (the body was never called). */
|
|
9
26
|
export declare function neverExecuted(occ: Pick<ToolOccurrence, "life" | "gateRounds" | "startEmitted" | "answeredInPlaceBy">): boolean;
|
|
10
|
-
/** `details` as a persisted `toolResult` row carries it: `notExecuted`
|
|
11
|
-
*
|
|
12
|
-
|
|
27
|
+
/** `details` as a persisted `toolResult` row carries it: `notExecuted` and `gate` are the ENGINE's keys —
|
|
28
|
+
* `notExecuted: true` when the settlement's fact holds, `gate` a structural copy of the end frame's verdict
|
|
29
|
+
* when both `notExecuted` and `gate` hold, and both absent otherwise, whatever a tool wrote under either name.
|
|
30
|
+
* Returns `details` itself unless a key has to move; never mutates it. */
|
|
31
|
+
export declare function rowDetailsOf(details: unknown, settled: RowEndFacts | undefined): unknown;
|
|
13
32
|
/** The persisted row's mark: the call this `toolResult` row closes never ran (the key {@link rowDetailsOf} writes). */
|
|
14
33
|
export declare function rowNotExecuted(details: unknown): boolean;
|
|
15
|
-
/** A row the resumed leg mints (`toolResultMsg`) with the settlement's
|
|
16
|
-
export declare function withRowNotExecuted<T extends object>(row: T,
|
|
17
|
-
/** Write the end projection's
|
|
34
|
+
/** A row the resumed leg mints (`toolResultMsg`) with the settlement's facts (`notExecuted`, `gate`) on it. */
|
|
35
|
+
export declare function withRowNotExecuted<T extends object>(row: T, settled: RowEndFacts | undefined): T;
|
|
36
|
+
/** Write the end projection's `notExecuted` and `gate` onto the result the live loop persists as the call's row: the loop builds that message
|
|
18
37
|
* from this very result right after the end event. The frame's card was projected from the previous `details` first and keeps its
|
|
19
|
-
* members (
|
|
20
|
-
export declare function stampRowNotExecuted(result: unknown,
|
|
38
|
+
* members (row marks are never part of a card). `Reflect.set`: a result that refuses the write keeps its row as it was. */
|
|
39
|
+
export declare function stampRowNotExecuted(result: unknown, settled: RowEndFacts | undefined): void;
|
|
@@ -5,13 +5,20 @@ export function refusedBeforeRelease(occ) {
|
|
|
5
5
|
export function neverExecuted(occ) {
|
|
6
6
|
return refusedBeforeRelease(occ) || occ.answeredInPlaceBy !== undefined;
|
|
7
7
|
}
|
|
8
|
-
export function rowDetailsOf(details,
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export function rowDetailsOf(details, settled) {
|
|
9
|
+
const notExecuted = settled?.notExecuted === true;
|
|
10
|
+
const gate = notExecuted ? settled.gate : undefined;
|
|
11
|
+
const carries = (() => {
|
|
12
|
+
try {
|
|
13
|
+
if (details === null || typeof details !== "object" || Array.isArray(details))
|
|
14
|
+
return false;
|
|
15
|
+
const keys = Object.keys(details);
|
|
16
|
+
return keys.includes("notExecuted") || keys.includes("gate");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
15
22
|
if (!notExecuted && !carries)
|
|
16
23
|
return details;
|
|
17
24
|
const bag = { ...readOwnMembers(details) };
|
|
@@ -19,6 +26,10 @@ export function rowDetailsOf(details, notExecuted) {
|
|
|
19
26
|
bag["notExecuted"] = true;
|
|
20
27
|
else
|
|
21
28
|
delete bag["notExecuted"];
|
|
29
|
+
if (gate !== undefined)
|
|
30
|
+
bag["gate"] = structuredClone(gate);
|
|
31
|
+
else
|
|
32
|
+
delete bag["gate"];
|
|
22
33
|
return bag;
|
|
23
34
|
}
|
|
24
35
|
export function rowNotExecuted(details) {
|
|
@@ -29,13 +40,13 @@ export function rowNotExecuted(details) {
|
|
|
29
40
|
return false;
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
|
-
export function withRowNotExecuted(row,
|
|
33
|
-
return notExecuted ? { ...row, details: rowDetailsOf(undefined,
|
|
43
|
+
export function withRowNotExecuted(row, settled) {
|
|
44
|
+
return settled?.notExecuted === true ? { ...row, details: rowDetailsOf(undefined, settled) } : row;
|
|
34
45
|
}
|
|
35
|
-
export function stampRowNotExecuted(result,
|
|
46
|
+
export function stampRowNotExecuted(result, settled) {
|
|
36
47
|
if (result === null || typeof result !== "object")
|
|
37
48
|
return;
|
|
38
|
-
const next = rowDetailsOf(result.details,
|
|
49
|
+
const next = rowDetailsOf(result.details, settled);
|
|
39
50
|
if (next !== result.details)
|
|
40
51
|
Reflect.set(result, "details", next);
|
|
41
52
|
}
|
|
@@ -54,7 +54,7 @@ export declare function legWriteProtectionTable(deps: Pick<RunnerDeps, "writePro
|
|
|
54
54
|
export declare function mountWriteProtection(input: {
|
|
55
55
|
/** borrowed-readonly — the deployment seats: the table (`writeProtectedPaths`; absent ⇒ the default
|
|
56
56
|
* table, `[]` ⇒ opted out) and the operator sink. */
|
|
57
|
-
deps: Pick<RunnerDeps, "writeProtectedPaths" | "onNotice">;
|
|
57
|
+
deps: Pick<RunnerDeps, "writeProtectedPaths" | "onNotice" | "deploymentShape">;
|
|
58
58
|
/** borrowed-readonly — the leg's configuration roots (`leg-caller-places.ts`, the leg's one mint: the deployment's root, the
|
|
59
59
|
* task's, a resumed row's) — the `.sema` rows are also placed below each. */
|
|
60
60
|
configRoots: readonly string[];
|
|
@@ -26,7 +26,7 @@ export function mountWriteProtection(input) {
|
|
|
26
26
|
message: `This run's write-protection judge did not get an answer from its execution environment for one lookup of a write's judgment ` +
|
|
27
27
|
`(${reason === ABSENCE_REASON.symlink ? "a symlink whose real target is unknowable" : "the environment refused, errored or did not answer in time"}: ${absence.cause}). ` +
|
|
28
28
|
`A write whose target's real destination (or link chain) could not be determined is refused where the table has rows — the ` +
|
|
29
|
-
`table cannot say it is not a protected path; a root whose key did not come back exempts and places nothing; guarded write rows ` +
|
|
29
|
+
`table cannot say it is not a protected path${input.deps.deploymentShape !== undefined ? " (a shell command's such write is a question instead, which bypassPermissions releases on this Runner, whose deployment declares its shape, where no deny row guards writes)" : ""}; a root whose key did not come back exempts and places nothing; guarded write rows ` +
|
|
30
30
|
`a deployment's policy did not return are held, so the writes they could guard are not placed. Every row a source that did ` +
|
|
31
31
|
`answer met stays met. An environment that cannot answer path questions is a deployment fact: fix the environment (or the ` +
|
|
32
32
|
`link) and the same writes are judged again. Announced once per leg per reason; later writes of the same shape are judged ` +
|
|
@@ -319,6 +319,9 @@ export interface RunnerDeps {
|
|
|
319
319
|
/** The deployment's cross-boundary posture, one of {@link import("./cross-boundary-taint.js").CROSS_BOUNDARY_POSTURES} (who is hurt when a tree that
|
|
320
320
|
* executes on a target device reaches past it). Absent reads `"single_user"`; any other value refuses the prepare, and a resume before its claim (`config.cross_boundary_posture`). */
|
|
321
321
|
crossBoundaryPosture?: "single_user" | "multi_tenant";
|
|
322
|
+
/** The deployment's declared shape ({@link import("./deployment-shape.js")} says what it vouches for and costs): ONLY a deployment with one owner declares it, and never a Runner that mixes in a tree another principal governs or members acting for another
|
|
323
|
+
* principal. Under `bypassPermissions` an unfinished read check is then released where what it did not see guards nothing (`confined: true`). Absent ⇒ nothing changes; a word outside the set, or the seat beside `crossBoundaryPosture: "multi_tenant"`, refuses `new Runner` (`config.deployment_shape`). */
|
|
324
|
+
deploymentShape?: import("./deployment-shape.js").DeploymentShape;
|
|
322
325
|
/**
|
|
323
326
|
* design/383 §2.1b — an optional host-supplied carrier for the session capture opt-out record
|
|
324
327
|
* (per memory plane, keyed by that plane's control dir). Absent = the `capture` objects of the engine's governance store (#3484: the File store over the plane's control dir, or the store the backend carries)
|
|
@@ -1277,6 +1280,7 @@ export interface RunnerDeps {
|
|
|
1277
1280
|
*/
|
|
1278
1281
|
onError?: (err: unknown, context: {
|
|
1279
1282
|
phase: "compaction" | "prompt-constitution" | "degraded" | "config" | "memory" | "mcp" | "a2a" | "interrupt-reconcile" | "suggestions" | "rewind" | "hook";
|
|
1283
|
+
/** The session the line is about; `""` when it belongs to none (a `CenterPromptSource` boot restore) — the absence of a session, as `sessionId: ""` reads everywhere. */
|
|
1280
1284
|
sessionId: string;
|
|
1281
1285
|
/**
|
|
1282
1286
|
* Machine-readable sub-classification when the site has one (a kebab-case word naming the arm) —
|
|
@@ -78,6 +78,8 @@ export declare function isSecretEnvKey(key: string, value?: string): boolean;
|
|
|
78
78
|
export declare function scrubSecretEnv(env: NodeJS.ProcessEnv, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
|
|
79
79
|
/** How much of this process's environment a child spawned on this host inherits — the `inheritEnv` value. */
|
|
80
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;
|
|
81
83
|
/** What {@link declareWithheldEnv} takes: the engine's own credentials in this process's environment. */
|
|
82
84
|
export interface WithheldEnvDeclaration {
|
|
83
85
|
/** Names of variables that are the engine's own credentials: never inherited, and an allow list naming one is refused. */
|
|
@@ -408,6 +410,11 @@ export interface HostChildInheritance {
|
|
|
408
410
|
* process's environment, exactly. Read once, as a grant is read; a bad one is refused as a bad grant is. */
|
|
409
411
|
readonly settingsEnv?: Readonly<NodeJS.ProcessEnv> | undefined;
|
|
410
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;
|
|
411
418
|
/** Why {@link hostChildEnv} would refuse these inputs, or `undefined` — the same judgment. It takes the table (or a bare policy), so
|
|
412
419
|
* `{}` reads as `scrub`; to judge one policy value alone — a configuration field — use {@link inheritEnvPolicyProblem}. It answers a
|
|
413
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
|
|
@@ -498,3 +505,4 @@ export declare function withheldEnvUserNotice(withheld: readonly SecretEnvFindin
|
|
|
498
505
|
sourceSessionId?: string | undefined;
|
|
499
506
|
agentId?: string | undefined;
|
|
500
507
|
}, mine?: PeerEntriesTaken, isolationScope?: string, deliveredScope?: string): EngineNotice | undefined;
|
|
508
|
+
export {};
|
package/dist/core/secret-env.js
CHANGED
|
@@ -152,7 +152,10 @@ function withholdEntries(env, policy, findings) {
|
|
|
152
152
|
return Object.fromEntries(kept);
|
|
153
153
|
}
|
|
154
154
|
function envNameKey(name) {
|
|
155
|
-
return process.platform
|
|
155
|
+
return envNameKeyOn(name, process.platform);
|
|
156
|
+
}
|
|
157
|
+
export function envNameKeyOn(name, platform) {
|
|
158
|
+
return platform === "win32" ? name.toUpperCase() : name;
|
|
156
159
|
}
|
|
157
160
|
const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
158
161
|
function isDeclarableVariableName(k) {
|
|
@@ -617,7 +620,7 @@ function layInto(entries, layer) {
|
|
|
617
620
|
entries.set(envNameKey(name), [entries.get(envNameKey(name))?.[0] ?? name, value]);
|
|
618
621
|
}
|
|
619
622
|
const unkeptCharacter = (text) => (text.includes("\0") ? "a NUL" : UNPAIRED_SURROGATE_RE.test(text) ? "an unpaired surrogate" : undefined);
|
|
620
|
-
function readEnvLayer(layer, label) {
|
|
623
|
+
export function readEnvLayer(layer, label) {
|
|
621
624
|
try {
|
|
622
625
|
if (typeof layer !== "object" || layer === null || Array.isArray(layer))
|
|
623
626
|
return `${label} must be an object of variable names to strings (got ${kindOf(layer)})`;
|
|
@@ -2,6 +2,8 @@ import type { ShellReadVerdict } from "../tools/fs/shell-read-check.js";
|
|
|
2
2
|
import { type ShellReadDisposition } from "../tools/fs/shell-read-judge.js";
|
|
3
3
|
import type { GatePass } from "./runner/gate-exit.js";
|
|
4
4
|
import type { PermissionResult } from "./tool-policy.js";
|
|
5
|
+
import type { ConfinedCall } from "./ask-origin.js";
|
|
6
|
+
import { type ShellCommandShape } from "./shell-run-candidates.js";
|
|
5
7
|
/** One station answer, received and read: what a reader acts on (`kind`) and the answer it acts on (`verdict` — the engine's own
|
|
6
8
|
* copy, received once). `unbelieved`: the station's answer was not received or contradicted its own finding, and `verdict` is the
|
|
7
9
|
* engine's refusal of it (its sentence names the station's words only where they are words of the closed sets — nothing a station
|
|
@@ -39,13 +41,49 @@ export declare function readStationAnswer(answer: ShellReadVerdict, call: Statio
|
|
|
39
41
|
* rule that could not be read (the rule lane's class); the finding `unanswered` is, unless rows are unread, the environment's silence —
|
|
40
42
|
* the station's check that did not finish (the guard `unfinished_check`, attested on the ask's record for `call` beside the guards it
|
|
41
43
|
* already carries) — and the marks only pick whose. Either is a question only a person answers (the real-approval bit, which each
|
|
42
|
-
* class explains); `probe` follows the finding.
|
|
44
|
+
* class explains); `probe` follows the finding. Whether a person was already required on the ask the check went silent over is the
|
|
45
|
+
* call's own fact (`pass.silencePersonRequired`), kept on the gate's pass and on no decision. No silence ⇒ `d` itself. */
|
|
43
46
|
export declare function silencedBy<D extends Extract<PermissionResult, {
|
|
44
47
|
action: "ask";
|
|
45
48
|
}>>(d: D, verdict: ShellReadVerdict, call: {
|
|
46
49
|
readonly toolCallId: string;
|
|
47
50
|
readonly toolName: string;
|
|
48
|
-
}): D;
|
|
51
|
+
}, pass?: Pick<GatePass, "silencePersonRequired">): D;
|
|
52
|
+
/** The deny rows ONE call may meet, as a confined Runner's mode point reads them: any row at all (`any`: either face, the built-in
|
|
53
|
+
* tiers among them) and a row that guards WRITES (`guardsWrites`: the write face's rows), on the table the call's judgment started
|
|
54
|
+
* with or on the one in force now (`person-path-rows.ts` `confinedDenyRowsOf`). */
|
|
55
|
+
export interface ConfinedDenyRows {
|
|
56
|
+
readonly any: boolean;
|
|
57
|
+
readonly guardsWrites: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** The gate's `confined` seat (`ToolGateInput.confined`) — PRESENT ⇔ the Runner declares its shape (`RunnerDeps.deploymentShape`). */
|
|
60
|
+
export interface ConfinedSeat {
|
|
61
|
+
/** The call's declared destination, on these arguments, stays on the leg's hands. */
|
|
62
|
+
readonly staysOnHands: (args: unknown) => boolean;
|
|
63
|
+
/** Asking for `bypassPermissions` now would run the leg under it (the leg's own mode fold). */
|
|
64
|
+
readonly bypassArmed: () => boolean;
|
|
65
|
+
/** The deny rows the call may meet. */
|
|
66
|
+
readonly denyRows: () => ConfinedDenyRows;
|
|
67
|
+
}
|
|
68
|
+
/** The allow layer's read-only reading of ONE shell call's arguments — its last member's (gate-lanes.ts) and a confined Runner's mode
|
|
69
|
+
* point's ({@link confinedCallOf}), one reading: the command under the command rule's primary parameter, read by the one lexer;
|
|
70
|
+
* read-only only where it is a string, not put in the background by the parameter (`run_in_background: true` is `cmd &`, a process
|
|
71
|
+
* that outlives the approval-time reading) and the read-only tables prove it at `cwd`. */
|
|
72
|
+
export declare function readOnlyShellCall(args: unknown, cwd: string | undefined): {
|
|
73
|
+
readonly readOnly: true;
|
|
74
|
+
readonly command: string;
|
|
75
|
+
readonly shape: ShellCommandShape;
|
|
76
|
+
} | {
|
|
77
|
+
readonly readOnly: false;
|
|
78
|
+
readonly shape?: ShellCommandShape;
|
|
79
|
+
};
|
|
80
|
+
/** What a confined Runner lends the mode point for one call ({@link ConfinedCall}) — nothing where the gate holds no seat (no shape
|
|
81
|
+
* declared): the silence's fact on the call's pass (none ⇒ a person required), the call's destination on the arguments that run,
|
|
82
|
+
* what the unfinished check left unseen (the gate put the station's fallback in its place ⇒ no row at all may stand; the station
|
|
83
|
+
* answered ⇒ no row that guards writes, or the command read-only at `cwd`), and the leg's mode fold for a bypass request. */
|
|
84
|
+
export declare function confinedCallOf(seat: ConfinedSeat | undefined, pass: Pick<GatePass, "silencePersonRequired" | "shellReadFallback">, args: unknown, cwd: string | undefined): {
|
|
85
|
+
readonly confined?: ConfinedCall;
|
|
86
|
+
};
|
|
49
87
|
/** The station's SILENCE ({@link readStationAnswer}), applied once, before any disposition arm: a station — a host-mounted one
|
|
50
88
|
* included — may spell `vouch`, `mandated` or `ordinary` beside it, and no word vouches for what nobody judged. A deny stands; an
|
|
51
89
|
* ask keeps its words and gains the silence's class; an allow becomes the silence's question (`ask.message`), one only a person
|
|
@@ -5,6 +5,10 @@ import { refusalEchoDefects } from "./refusal-echo.js";
|
|
|
5
5
|
import { egressThrownText } from "./untrusted-egress.js";
|
|
6
6
|
import { receive } from "./mods/kernel/receive.js";
|
|
7
7
|
import { attest, attestationOf } from "./engine-attestation.js";
|
|
8
|
+
import { readOnlyShellVerdict } from "./read-only-shell.js";
|
|
9
|
+
import { readShellCommand } from "./shell-run-candidates.js";
|
|
10
|
+
import { COMMAND_RULE_TOOL } from "./permission-rule-model.js";
|
|
11
|
+
import { catalogRuleFaceOf } from "./tool-registry.js";
|
|
8
12
|
const DISPOSITIONS = ["refuse", "mandated", "ordinary", "vouch"];
|
|
9
13
|
const MEMBER_KINDS = {
|
|
10
14
|
disposition: "word",
|
|
@@ -84,24 +88,39 @@ export function readStationAnswer(answer, call) {
|
|
|
84
88
|
call.report?.(new Error(`shell read station answered out of its contract for tool "${call.toolName}"${call.toolCallId !== undefined ? ` (toolCallId ${call.toolCallId})` : ""} — ${sentence}`));
|
|
85
89
|
return { kind: "refuse", verdict: { disposition: "refuse", finding: "none", sentence }, unbelieved: true };
|
|
86
90
|
}
|
|
87
|
-
export function silencedBy(d, verdict, call) {
|
|
91
|
+
export function silencedBy(d, verdict, call, pass) {
|
|
88
92
|
const environment = verdict.environmentSilent === true || (verdict.finding === "unanswered" && verdict.rowsUnread !== true);
|
|
89
93
|
if (!environment && verdict.rowsUnread !== true)
|
|
90
94
|
return d;
|
|
91
95
|
const rows = verdict.rowsUnread === true && d.ruleUnreadable === undefined ? { ruleUnreadable: "persisted_rows" } : {};
|
|
92
96
|
const out = { ...d, ...rows, requiresRealApproval: true };
|
|
93
97
|
const held = attestationOf(d, call)?.guards ?? [];
|
|
94
|
-
|
|
98
|
+
if (!environment || held.includes("unfinished_check"))
|
|
99
|
+
return out;
|
|
100
|
+
if (pass !== undefined)
|
|
101
|
+
pass.silencePersonRequired = d.requiresRealApproval === true;
|
|
102
|
+
return attest(out, call, { guards: [...held, "unfinished_check"] });
|
|
103
|
+
}
|
|
104
|
+
export function readOnlyShellCall(args, cwd) {
|
|
105
|
+
const record = typeof args === "object" && args !== null && !Array.isArray(args) ? args : undefined;
|
|
106
|
+
const command = record?.[catalogRuleFaceOf(COMMAND_RULE_TOOL)?.primaryParams[0] ?? "command"];
|
|
107
|
+
if (typeof command !== "string")
|
|
108
|
+
return { readOnly: false };
|
|
109
|
+
const shape = readShellCommand(command);
|
|
110
|
+
return record?.run_in_background !== true && readOnlyShellVerdict(command, { shape, cwd }).readOnly ? { readOnly: true, command, shape } : { readOnly: false, shape };
|
|
111
|
+
}
|
|
112
|
+
export function confinedCallOf(seat, pass, args, cwd) {
|
|
113
|
+
return seat === undefined ? {} : { confined: { personAlreadyRequired: () => pass.silencePersonRequired !== false, destinationOnHands: () => seat.staysOnHands(args), unseenGuardsNothing: () => ((rows) => (pass.shellReadFallback === true ? !rows.any : !rows.guardsWrites || readOnlyShellCall(args, cwd).readOnly))(seat.denyRows()), bypassArmed: seat.bypassArmed } };
|
|
95
114
|
}
|
|
96
115
|
export function applyUnansweredSilence(pass, verdict, ask) {
|
|
97
116
|
if (verdict.details !== undefined)
|
|
98
117
|
pass.shellReadDetails = verdict.details;
|
|
99
118
|
if (pass.decision.action === "ask") {
|
|
100
|
-
pass.decision = silencedBy(pass.decision, verdict, pass.req);
|
|
119
|
+
pass.decision = silencedBy(pass.decision, verdict, pass.req, pass);
|
|
101
120
|
return;
|
|
102
121
|
}
|
|
103
122
|
if (pass.decision.action !== "allow")
|
|
104
123
|
return;
|
|
105
|
-
pass.decision = silencedBy({ action: "ask", message: ask.message, decisionReason: "safety", ...(ask.account !== undefined ? { probeReason: ask.account } : {}) }, verdict, pass.req);
|
|
124
|
+
pass.decision = silencedBy({ action: "ask", message: ask.message, decisionReason: "safety", ...(ask.account !== undefined ? { probeReason: ask.account } : {}) }, verdict, pass.req, pass);
|
|
106
125
|
pass.tightenedBy = ask.tightenedBy;
|
|
107
126
|
}
|
|
@@ -179,10 +179,10 @@ export interface BrainStatus {
|
|
|
179
179
|
* `first_token` — the headers to the first content delta (a thinking delta counts); `next_token` — the silence after
|
|
180
180
|
* a content delta, until the next one. */
|
|
181
181
|
waitSegment?: "response_headers" | "first_token" | "next_token";
|
|
182
|
-
/** On every `waiting` frame (absent elsewhere): what the engine does if this wait reaches {@link timeoutMs}, judged
|
|
183
|
-
* the
|
|
184
|
-
*
|
|
185
|
-
*
|
|
182
|
+
/** On every `waiting` frame (absent elsewhere): what the engine does if this wait reaches {@link timeoutMs}, judged by the reading
|
|
183
|
+
* the cut itself acts on. `retry` — the attempt is cut and the engine tries again (the same request, or the request without the keys
|
|
184
|
+
* of a thinking tier the entry does not declare): a forecast, not a promise that a request goes out (it is judged for sending, and can
|
|
185
|
+
* be refused); `keep` — output arrived: the call ends with it, marked cut (`continuing`); `fail` — nothing more is tried: the call fails. */
|
|
186
186
|
atTimeout?: "retry" | "keep" | "fail";
|
|
187
187
|
/**
|
|
188
188
|
* On a retry-wait frame (`phase: "reconnecting"`, `errClass: "stall"`) for an attempt this process ended
|
|
@@ -13,6 +13,7 @@ import { codedRefusal } from "./thrown-value.js";
|
|
|
13
13
|
import { PEER_TASK_HANDLE_RE } from "./task-registry-shared.js";
|
|
14
14
|
import { A2A_WAITING_FOR } from "./a2a-task-state.js";
|
|
15
15
|
import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
|
|
16
|
+
import { waitForOffloadPuts } from "./tool-result-store.js";
|
|
16
17
|
export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
|
|
17
18
|
export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(["completed", "failed", "killed", "cancelled"]);
|
|
18
19
|
export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate", "refused"]);
|
|
@@ -246,7 +247,11 @@ export async function completionResultField(result, persist, record, notifier) {
|
|
|
246
247
|
}, "completionResultField.shortReportWrite");
|
|
247
248
|
return { text: report };
|
|
248
249
|
}
|
|
249
|
-
const
|
|
250
|
+
const waited = await waitForOffloadPuts([Promise.resolve(persist(report))]);
|
|
251
|
+
const first = waited.outcomes[0];
|
|
252
|
+
if (first.status === "rejected")
|
|
253
|
+
throw first.reason;
|
|
254
|
+
const artifact = first.status === "settled" ? first.value : { kind: "unconfirmed" };
|
|
250
255
|
if (artifact.kind === "stored")
|
|
251
256
|
record(artifact.ref);
|
|
252
257
|
return { text: `${report.slice(0, COMPLETION_REPORT_MAX)}\n[result truncated: ${report.length} chars total — ${cutReportReading(artifact)}]` };
|
|
@@ -244,6 +244,7 @@ export declare function reconcileParkedAgentsLane(core: DurableAgentCore, stores
|
|
|
244
244
|
}): Promise<{
|
|
245
245
|
failed: number;
|
|
246
246
|
rolledBack: number;
|
|
247
|
+
unreadable: number;
|
|
247
248
|
}>;
|
|
248
249
|
/**
|
|
249
250
|
* design/153 §7.2c (件3b) — the RESERVATION half of the parked-resume claim. Pure reservation
|
|
@@ -610,7 +610,7 @@ export async function reconcileParkedAgentsLane(core, stores, scope, now, opts)
|
|
|
610
610
|
...(opts?.staleClaimMaxAgeMs !== undefined ? { staleClaimMaxAgeMs: opts.staleClaimMaxAgeMs } : {}),
|
|
611
611
|
excludeHandles: liveHandles,
|
|
612
612
|
});
|
|
613
|
-
return { failed: storeHalf.failed + liveFailed, rolledBack: storeHalf.rolledBack };
|
|
613
|
+
return { failed: storeHalf.failed + liveFailed, rolledBack: storeHalf.rolledBack, unreadable: storeHalf.unreadable };
|
|
614
614
|
}
|
|
615
615
|
export async function claimParkedAgentLane(stores, handle, access) {
|
|
616
616
|
if (access.scope === undefined)
|