@sema-agent/core 7.64.0 → 7.66.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 +571 -0
- package/dist/agents/delegation-registry-seat.d.ts +15 -0
- package/dist/agents/delegation-registry-seat.js +13 -0
- package/dist/agents/org-delivery-gate.d.ts +8 -1
- package/dist/agents/org-delivery-gate.js +9 -3
- package/dist/agents/peer-held-queue.js +1 -1
- package/dist/agents/peer-idle.js +1 -1
- package/dist/agents/peer-session-drain.d.ts +51 -12
- package/dist/agents/peer-session-drain.js +47 -34
- package/dist/agents/read-inbox-tool.d.ts +6 -2
- package/dist/agents/read-inbox-tool.js +18 -5
- package/dist/agents/subagent.d.ts +3 -1
- package/dist/agents/subagent.js +84 -77
- package/dist/brain/reasoning.d.ts +2 -0
- package/dist/brain/reasoning.js +1 -0
- package/dist/core/allow-entry.d.ts +9 -0
- package/dist/core/allow-entry.js +7 -1
- package/dist/core/ask-origin.d.ts +23 -3
- package/dist/core/ask-origin.js +11 -1
- package/dist/core/auto-promote.d.ts +3 -2
- package/dist/core/background-agent-store.d.ts +7 -0
- package/dist/core/checkpoint-store.d.ts +2 -3
- package/dist/core/context-settings.d.ts +1 -2
- package/dist/core/context-settings.js +1 -1
- package/dist/core/engine-attestation.d.ts +2 -2
- package/dist/core/engine-notice.d.ts +13 -1
- package/dist/core/engine-notice.js +3 -1
- package/dist/core/file-history-store.d.ts +2 -2
- package/dist/core/file-history-store.js +0 -4
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +6 -4
- package/dist/core/governance-codes.js +5 -3
- package/dist/core/human-input-projection.d.ts +9 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/input-author.d.ts +66 -6
- package/dist/core/input-author.js +21 -3
- package/dist/core/leg-identity.d.ts +18 -2
- package/dist/core/leg-identity.js +5 -7
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +30 -10
- package/dist/core/memory-engine/consolidation.js +41 -6
- package/dist/core/memory-engine/control-objects.d.ts +36 -3
- package/dist/core/memory-engine/control-objects.js +134 -12
- package/dist/core/memory-engine/control-plane-adoption.d.ts +13 -9
- package/dist/core/memory-engine/control-plane-adoption.js +58 -31
- package/dist/core/memory-engine/delegation-settlement.d.ts +75 -52
- package/dist/core/memory-engine/delegation-settlement.js +211 -228
- package/dist/core/memory-engine/dual-root.d.ts +3 -2
- package/dist/core/memory-engine/dual-root.js +5 -1
- package/dist/core/memory-engine/engine.d.ts +33 -16
- package/dist/core/memory-engine/engine.js +213 -177
- package/dist/core/memory-engine/file-backend.d.ts +21 -12
- package/dist/core/memory-engine/file-backend.js +58 -104
- package/dist/core/memory-engine/index.d.ts +2 -2
- package/dist/core/memory-engine/index.js +2 -2
- package/dist/core/memory-engine/layout.d.ts +184 -83
- package/dist/core/memory-engine/layout.js +267 -172
- package/dist/core/memory-engine/memory-age.d.ts +12 -0
- package/dist/core/memory-engine/memory-age.js +17 -0
- package/dist/core/memory-engine/memory-backend-contract.js +12 -11
- package/dist/core/memory-engine/memory-deployment.d.ts +4 -3
- package/dist/core/memory-engine/memory-deployment.js +6 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +43 -15
- package/dist/core/memory-engine/origin-clearance.js +142 -58
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +7 -7
- package/dist/core/memory-engine/types.d.ts +16 -10
- package/dist/core/memory-vector.d.ts +6 -14
- package/dist/core/memory.d.ts +0 -462
- package/dist/core/memory.js +0 -333
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +5 -0
- package/dist/core/mods/dollar.d.ts +12 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -1
- package/dist/core/mods/kernel/dispatch.js +5 -2
- package/dist/core/mods/kernel/events.d.ts +3 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/prompt-submit.d.ts +4 -0
- package/dist/core/mods/prompt-submit.js +24 -0
- package/dist/core/mods/stations.d.ts +23 -4
- package/dist/core/mods/stations.js +14 -7
- package/dist/core/permission-rule-consent.d.ts +49 -18
- package/dist/core/permission-rule-consent.js +59 -38
- package/dist/core/permission-rule-store.d.ts +24 -14
- package/dist/core/retention.d.ts +2 -7
- package/dist/core/retention.js +0 -1
- package/dist/core/retired-host-table-account.d.ts +19 -0
- package/dist/core/retired-host-table-account.js +28 -0
- package/dist/core/retired-tool-name-account.d.ts +60 -0
- package/dist/core/retired-tool-name-account.js +32 -0
- package/dist/core/roles.d.ts +3 -1
- package/dist/core/roles.js +5 -2
- package/dist/core/runner/classifier-ladder.d.ts +3 -1
- package/dist/core/runner/classifier-ladder.js +2 -2
- package/dist/core/runner/compact-session.js +2 -1
- package/dist/core/runner/contracts.d.ts +9 -9
- package/dist/core/runner/delegation-owner.d.ts +0 -8
- package/dist/core/runner/delegation-owner.js +1 -3
- package/dist/core/runner/gate-exit.js +9 -2
- package/dist/core/runner/memory-consolidation-driver.js +2 -2
- package/dist/core/runner/prepare-config-doors.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-delegation-surface.js +5 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -5
- package/dist/core/runner/prepare-gate-stations.js +13 -5
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.js +35 -14
- package/dist/core/runner/prepare-policy-chain.js +12 -3
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-task.d.ts +9 -1
- package/dist/core/runner/prepare-task.js +6 -5
- package/dist/core/runner/prepare-wiring-manifest.js +5 -4
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/run-identity-wiring.js +2 -2
- package/dist/core/runner/run-leg.js +3 -3
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/runtask.js +6 -3
- package/dist/core/runner/steer-admission.d.ts +11 -2
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +67 -14
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -8
- package/dist/core/runner/sub-agent-deny-lists.js +22 -8
- package/dist/core/runner-deps.d.ts +4 -4
- package/dist/core/secret-env.d.ts +2 -2
- package/dist/core/secret-env.js +6 -20
- package/dist/core/session-store.d.ts +6 -6
- package/dist/core/session-store.js +3 -3
- package/dist/core/shell-run-candidates.js +3 -3
- package/dist/core/side-query.js +1 -1
- package/dist/core/skill-grant.d.ts +7 -0
- package/dist/core/skill-grant.js +14 -5
- package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +14 -0
- package/dist/core/task-notification.d.ts +35 -8
- package/dist/core/task-notification.js +31 -13
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +4 -0
- package/dist/core/tool-errors.d.ts +3 -3
- package/dist/core/tool-policy.js +2 -3
- package/dist/core/tool-spec.d.ts +20 -10
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +11 -5
- package/dist/core/write-protect.d.ts +16 -0
- package/dist/core/write-protect.js +10 -0
- package/dist/engine/harness/agent-harness.d.ts +19 -11
- package/dist/engine/harness/agent-harness.js +7 -4
- package/dist/engine/llm/types.d.ts +22 -10
- package/dist/engine/session/repo-utils.d.ts +14 -4
- package/dist/engine/session/repo-utils.js +5 -4
- package/dist/index.d.ts +10 -8
- package/dist/index.js +9 -7
- package/dist/prompts/default.d.ts +1 -2
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/shell/lex.d.ts +50 -15
- package/dist/shell/lex.js +43 -9
- package/dist/stores/file/adoption/adopt.d.ts +1 -1
- package/dist/stores/file/index.d.ts +1 -15
- package/dist/stores/file/index.js +1 -15
- package/dist/stores/file/permission-rule-store.d.ts +12 -1
- package/dist/stores/file/permission-rule-store.js +31 -4
- package/dist/stores/file/session-store.js +1 -1
- package/dist/tools/fs/fs-bash.js +3 -3
- package/dist/tools/fs/removal-targets.d.ts +8 -2
- package/dist/tools/fs/removal-targets.js +31 -4
- package/dist/tools/fs/shell-read-argv.js +7 -1
- package/dist/tools/fs/shell-read-bindings.d.ts +21 -5
- package/dist/tools/fs/shell-read-bindings.js +130 -44
- package/dist/tools/fs/shell-read-plan.js +95 -29
- package/dist/tools/fs/shell-read-sourced.d.ts +25 -0
- package/dist/tools/fs/shell-read-sourced.js +119 -0
- package/dist/tools/fs/shell-read-word.d.ts +2 -2
- package/dist/tools/fs/shell-read-word.js +4 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +19 -3
- package/dist/tools/fs/shell-read-workdir.js +60 -15
- package/dist/tools/fs/shell-reentry-text.d.ts +10 -2
- package/dist/tools/fs/shell-reentry-text.js +11 -4
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +21 -79
- package/wire-changes/core-stores-sql@7.65.0.json +30 -0
- package/wire-changes/core-stores-sql@7.66.0.json +30 -0
- package/wire-changes/core@7.65.0.json +1650 -0
- package/wire-changes/core@7.66.0.json +1218 -0
- package/wire-changes/mods-kernel@7.65.0.json +30 -0
- package/wire-changes/mods-kernel@7.66.0.json +65 -0
- package/wire-changes/primitives@7.65.0.json +337 -0
- package/wire-changes/primitives@7.66.0.json +30 -0
- package/dist/core/memory-recall.d.ts +0 -208
- package/dist/core/memory-recall.js +0 -136
- package/dist/stores/file/memory-store.d.ts +0 -124
- package/dist/stores/file/memory-store.js +0 -353
|
@@ -3,8 +3,8 @@ import { snapshotActorAssertion } from "../../internal/llm.js";
|
|
|
3
3
|
import { MAX_STEER_INPUT_ID_CHARS } from "../checkpoint-store.js";
|
|
4
4
|
import { formatHookFeedback } from "../hooks.js";
|
|
5
5
|
import { classicEventBase, failedHandlerClause, legNoticeTaskId, screenUserPrompt } from "../mods/stations.js";
|
|
6
|
-
import { countsAsOperator } from "../input-author.js";
|
|
7
|
-
import { buildHumanInputEvent, frameMidTurnUserInput, projectHumanInput } from "../human-input-projection.js";
|
|
6
|
+
import { countsAsOperator, inputFrameOf, isScreened } from "../input-author.js";
|
|
7
|
+
import { buildHumanInputEvent, frameExtensionInput, frameMidTurnUserInput, projectHumanInput } from "../human-input-projection.js";
|
|
8
8
|
import { injectionLaneOf, isSystemInjectionPriority, steerPriorityOf, SYSTEM_INJECTION_PRIORITIES } from "../task-notification.js";
|
|
9
9
|
import { deliverEngineNotice } from "../types.js";
|
|
10
10
|
import { inlineUntrusted, sanitizeUntrustedText, sentinelTagRefusal } from "../untrusted-text.js";
|
|
@@ -13,7 +13,7 @@ import { steerReplayRefusal } from "../steer-replay.js";
|
|
|
13
13
|
export function streamSteerVerb(input) {
|
|
14
14
|
const { spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner } = input;
|
|
15
15
|
let steerChain = Promise.resolve();
|
|
16
|
-
const steerAs = async (author, text, options) => {
|
|
16
|
+
const steerAs = async (author, text, options, call) => {
|
|
17
17
|
if (options?.userAttachments !== undefined) {
|
|
18
18
|
throw steeringError("a steer carries no attachments — declare them in TaskSpec.userAttachments on the next objective", "steering.invalid_content");
|
|
19
19
|
}
|
|
@@ -37,7 +37,17 @@ export function streamSteerVerb(input) {
|
|
|
37
37
|
const priority = steerPriorityOf({ priority: priorityIn });
|
|
38
38
|
const actorIn = options?.actor;
|
|
39
39
|
const actor = actorIn === undefined ? undefined : snapshotActorAssertion(actorIn);
|
|
40
|
-
const
|
|
40
|
+
const frameFor = (t, reminderMark) => {
|
|
41
|
+
const projected = projectHumanInput({ text: t, actor, source: "steer" });
|
|
42
|
+
switch (inputFrameOf(author)) {
|
|
43
|
+
case "person":
|
|
44
|
+
return trusted ? formatHookFeedback(projected, reminderMark) : frameMidTurnUserInput(projected);
|
|
45
|
+
case "extension":
|
|
46
|
+
return frameExtensionInput(call?.extension, projected);
|
|
47
|
+
case "verbatim":
|
|
48
|
+
return projected;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
41
51
|
const effectiveInputId = typeof inputId === "string" ? inputId : uuidv7();
|
|
42
52
|
const parkRecord = {
|
|
43
53
|
text,
|
|
@@ -49,6 +59,10 @@ export function streamSteerVerb(input) {
|
|
|
49
59
|
let payload;
|
|
50
60
|
let mintsAFrame;
|
|
51
61
|
let rewrittenBy;
|
|
62
|
+
const attribution = {
|
|
63
|
+
...(author !== "operator" ? { author } : {}),
|
|
64
|
+
...(call !== undefined ? { extension: call.extension } : {}),
|
|
65
|
+
};
|
|
52
66
|
const publishQueued = (h) => {
|
|
53
67
|
const identity = internals?.parentToolCallId !== undefined ? { parentToolCallId: internals.parentToolCallId, sourceTaskId: h.hookIdentity.taskId } : {};
|
|
54
68
|
queue.push({
|
|
@@ -62,11 +76,12 @@ export function streamSteerVerb(input) {
|
|
|
62
76
|
...(actor?.issuer !== undefined ? { issuer: actor.issuer } : {}),
|
|
63
77
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
64
78
|
...(rewrittenBy !== undefined ? { rewrittenBy } : {}),
|
|
79
|
+
...attribution,
|
|
65
80
|
}),
|
|
66
81
|
eventId: uuidv7(),
|
|
67
82
|
...identity,
|
|
68
83
|
});
|
|
69
|
-
return identity;
|
|
84
|
+
return { identity, attribution };
|
|
70
85
|
};
|
|
71
86
|
const noteAccepted = () => {
|
|
72
87
|
if (!mintsAFrame)
|
|
@@ -75,13 +90,14 @@ export function streamSteerVerb(input) {
|
|
|
75
90
|
acceptedSteerInputs.set(inputId, parkRecord);
|
|
76
91
|
announceAcceptance(parkRecord);
|
|
77
92
|
};
|
|
93
|
+
let entered = text;
|
|
78
94
|
const deliver = async () => {
|
|
79
95
|
if (live.resultValue)
|
|
80
96
|
throw steeringError("the task has already finished");
|
|
81
97
|
const h = live.handle ?? (await orTimeout(ready));
|
|
82
98
|
if (!h)
|
|
83
99
|
throw steeringError("the task is not running");
|
|
84
|
-
payload =
|
|
100
|
+
payload = frameFor(text, h.reminderMark);
|
|
85
101
|
mintsAFrame = payload.trim().length !== 0;
|
|
86
102
|
if (typeof inputId === "string") {
|
|
87
103
|
const prior = acceptedSteerInputs.get(inputId);
|
|
@@ -91,19 +107,22 @@ export function streamSteerVerb(input) {
|
|
|
91
107
|
const refusal = steerReplayRefusal(prior, parkRecord, { seat: "accepted" });
|
|
92
108
|
if (refusal !== undefined)
|
|
93
109
|
throw steeringError(refusal.message, "steering.duplicate_input_id", refusal.detail);
|
|
94
|
-
return;
|
|
110
|
+
return { entered };
|
|
95
111
|
}
|
|
96
112
|
}
|
|
97
113
|
if (live.resultValue !== undefined || h.loop.ended)
|
|
98
114
|
throw steeringError("the task is no longer running");
|
|
99
|
-
if (
|
|
115
|
+
if (!countsAsOperator(author) && h.harness.engineInjectionsHeld?.() === true) {
|
|
116
|
+
throw steeringError("the run stopped on the person's own refusal and they have not spoken since — an input that is not theirs does not restart it");
|
|
117
|
+
}
|
|
118
|
+
if (mintsAFrame && isScreened(author)) {
|
|
100
119
|
const screen = await screenUserPrompt(h.modBus, {
|
|
101
120
|
...classicEventBase(h.hookIdentity, h.permissionMode.observed),
|
|
102
121
|
prompt: text,
|
|
103
122
|
source: "steer",
|
|
104
123
|
inputId: effectiveInputId,
|
|
105
124
|
...(actor !== undefined ? { actor: snapshotActorAssertion(actor) } : {}),
|
|
106
|
-
}, h.abortController.signal);
|
|
125
|
+
}, call?.signal !== undefined ? AbortSignal.any([h.abortController.signal, call.signal]) : h.abortController.signal, { author, ...(call !== undefined ? { extension: call.extension, raisedUnder: { frames: call.frames, origin: call.origin } } : {}) });
|
|
107
126
|
if (screen?.kind === "aborted") {
|
|
108
127
|
throw steeringError(`the task was cancelled while the deployment's userPromptSubmit hook was still screening this steering input; the input was NOT accepted (fail-closed)`, "steering.blocked_by_hook");
|
|
109
128
|
}
|
|
@@ -114,8 +133,8 @@ export function streamSteerVerb(input) {
|
|
|
114
133
|
throw steeringError(`the deployment's userPromptSubmit hook blocked this steering input: ${inlineUntrusted(screen.block)}`, "steering.blocked_by_hook");
|
|
115
134
|
}
|
|
116
135
|
if (screen?.kind === "answered" && screen.rewrittenBy !== undefined) {
|
|
117
|
-
|
|
118
|
-
payload =
|
|
136
|
+
entered = screen.text;
|
|
137
|
+
payload = frameFor(screen.text, h.reminderMark);
|
|
119
138
|
mintsAFrame = payload.trim().length !== 0;
|
|
120
139
|
rewrittenBy = screen.rewrittenBy;
|
|
121
140
|
}
|
|
@@ -124,6 +143,8 @@ export function streamSteerVerb(input) {
|
|
|
124
143
|
}
|
|
125
144
|
}
|
|
126
145
|
const injectFramed = async () => {
|
|
146
|
+
if (call?.signal?.aborted === true)
|
|
147
|
+
throw steeringError("the extension's call was cancelled before the input was taken");
|
|
127
148
|
const noteOptions = { provenance: "engine-note", author, parkRecord, ...(actor !== undefined ? { actor } : {}) };
|
|
128
149
|
if (mintsAFrame)
|
|
129
150
|
armAcceptance(parkRecord, () => publishQueued(h));
|
|
@@ -152,7 +173,7 @@ export function streamSteerVerb(input) {
|
|
|
152
173
|
};
|
|
153
174
|
try {
|
|
154
175
|
await injectFramed();
|
|
155
|
-
return;
|
|
176
|
+
return { entered };
|
|
156
177
|
}
|
|
157
178
|
catch (e) {
|
|
158
179
|
if (!(e instanceof Error && e.code === "invalid_state"))
|
|
@@ -162,7 +183,7 @@ export function streamSteerVerb(input) {
|
|
|
162
183
|
while (live.resultValue === undefined && !h.loop.ended && Date.now() < birthDeadline) {
|
|
163
184
|
try {
|
|
164
185
|
await injectFramed();
|
|
165
|
-
return;
|
|
186
|
+
return { entered };
|
|
166
187
|
}
|
|
167
188
|
catch (e2) {
|
|
168
189
|
if (!(e2 instanceof Error && e2.code === "invalid_state"))
|
|
@@ -176,5 +197,37 @@ export function streamSteerVerb(input) {
|
|
|
176
197
|
steerChain = p.then(() => undefined, () => undefined);
|
|
177
198
|
return p;
|
|
178
199
|
};
|
|
179
|
-
|
|
200
|
+
const authoredSteer = async (author, text, call) => {
|
|
201
|
+
try {
|
|
202
|
+
return await steerAs(author, text, call !== undefined ? { priority: call.priority } : undefined, call);
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
if (isSteeringRefusal(e))
|
|
206
|
+
return { drop: e.message };
|
|
207
|
+
throw e;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const inputWindow = () => {
|
|
211
|
+
if (live.resultValue !== undefined)
|
|
212
|
+
return "over";
|
|
213
|
+
const h = live.handle;
|
|
214
|
+
if (h === undefined)
|
|
215
|
+
return "before";
|
|
216
|
+
if (h.loop.ended)
|
|
217
|
+
return "over";
|
|
218
|
+
return h.harness.takingInput ? "open" : "before";
|
|
219
|
+
};
|
|
220
|
+
return {
|
|
221
|
+
steer: async (text, options) => {
|
|
222
|
+
await steerAs("operator", text, options);
|
|
223
|
+
},
|
|
224
|
+
authoredSteer,
|
|
225
|
+
inputWindow,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function isSteeringRefusal(e) {
|
|
229
|
+
if (!(e instanceof Error))
|
|
230
|
+
return false;
|
|
231
|
+
const code = e.code;
|
|
232
|
+
return typeof code === "string" && code.startsWith("steering.");
|
|
180
233
|
}
|
|
@@ -35,12 +35,15 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import type { AgentTool } from "../../internal/harness.js";
|
|
37
37
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
38
|
+
import { type EngineNotice } from "../engine-notice.js";
|
|
38
39
|
import { type ProtocolId } from "../protocol-table.js";
|
|
40
|
+
import { POLICY_NAME_REFUSAL_CODE, type PolicyNameLayer } from "../retired-tool-name-account.js";
|
|
39
41
|
import type { ToolLegKind, ToolSelector, ToolSelectorLayer } from "../tool-face.js";
|
|
40
42
|
import { type ConstraintChainEntry } from "../tool-policy.js";
|
|
41
43
|
import type { TaskSpec } from "../types.js";
|
|
42
44
|
import type { CheckpointErrorReason } from "../checkpoint-store.js";
|
|
43
|
-
import type {
|
|
45
|
+
import type { RunInternals } from "./contracts.js";
|
|
46
|
+
import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
44
47
|
/** What the delegation tools a run mounts hand their children (the pools of {@link delegationPoolReading}). */
|
|
45
48
|
interface DelegationPoolReading {
|
|
46
49
|
readonly tools: NonNullable<TaskSpec["tools"]>;
|
|
@@ -79,11 +82,6 @@ export declare function delegationPoolReading(callerTools: NonNullable<TaskSpec[
|
|
|
79
82
|
* ({@link CheckpointErrorReason}): a list the row recorded that is not a list / has a member that is not a string / has a spelling no tool name can have / is not in the
|
|
80
83
|
* spelling a row records, a record that is not one, a renamed delegation mount, an occupied table of declared names. */
|
|
81
84
|
export type PersistedToolFaceReason = Extract<CheckpointErrorReason, "not_a_list" | "not_a_string" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied">;
|
|
82
|
-
/** The code of the policy-name refusal — the one spelling its mint and every problem it lists carry. */
|
|
83
|
-
export declare const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
|
|
84
|
-
/** The layers the prepare-time policy-name audit reads, by the words the trace already gives the first: the run's own policy
|
|
85
|
-
* (`caller_policy`), the stored rules of its session, and the rules an ancestor's session handed it. */
|
|
86
|
-
export type PolicyNameLayer = "caller_policy" | "session_rules" | "ancestor_session_rules";
|
|
87
85
|
/** One entry the policy-name audit refuses, in the shape the entry problems of a rejection body are minted in (code · field ·
|
|
88
86
|
* entry · reason, the engine entry reading's words) plus the layer it sits in: `field` is the policy list (`deny` / `ask` /
|
|
89
87
|
* `allow`), `reason` the name judgment's verdict word (`near_miss` for another spelling of a carried name). */
|
|
@@ -203,8 +201,10 @@ export interface RunToolListsInput {
|
|
|
203
201
|
* (`RunInternals.ownToolLists`); absent ⇒ the run's own `TaskSpec` seats. Its sentence is {@link delegationListWhere}; its tool name is
|
|
204
202
|
* a name of the leg's lineage, so the run's own lists are asked of a universe that carries it. */
|
|
205
203
|
ownBy: RunInternals["ownToolLists"];
|
|
206
|
-
/** borrowed-readonly — the once-per-session ledger whose operator sink carries the
|
|
207
|
-
onceLedger: Pick<
|
|
204
|
+
/** borrowed-readonly — the once-per-session ledger whose operator sink carries the advisories and whose verb tells the retired-name notice once. */
|
|
205
|
+
onceLedger: Pick<AnnounceOnceLedger, "onError" | "oncePerSession">;
|
|
206
|
+
/** borrowed-readonly — the deployment's notice sink (`RunnerDeps.onNotice`): the retired-name notice goes there. */
|
|
207
|
+
onNotice?: ((notice: EngineNotice) => void) | undefined;
|
|
208
208
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
209
209
|
sessionId: string;
|
|
210
210
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { compileToolSelector, valveLeaves, deniedProtocolTools, delegationListWhere, isCanonicalToolName, isToolSelectorLayer, listReaches, notAListSentence, toolListsDigest, notAStringSentence, readAllowedToolList, readDeniedEntry, readDeniedToolList } from "../../agents/tool-filter.js";
|
|
2
2
|
import { readToolNameList, valueTypeLabel } from "../tool-name-list.js";
|
|
3
|
-
import { compileAllowList, inertEntryPhrase, renderListEntry, rootFacingToolNames } from "../allow-entry.js";
|
|
3
|
+
import { compileAllowList, inertEntryPhrase, isRetiredLeftOut, renderListEntry, rootFacingToolNames } from "../allow-entry.js";
|
|
4
4
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
5
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
5
6
|
import { ENGINE_TOOLS } from "../tool-catalog-entries.js";
|
|
6
7
|
import { callerToolNameProblem } from "../caller-tool-name.js";
|
|
7
8
|
import { mintNamespacePrefix } from "../protocol-naming.js";
|
|
8
9
|
import { PROTOCOL_TABLE, protocolOf } from "../protocol-table.js";
|
|
9
10
|
import { grantWildcardRefusalOf, mountedToolNames, splitNamespacedName } from "../tool-name-aliases.js";
|
|
11
|
+
import { POLICY_NAME_REFUSAL_CODE, retiredToolNameNotice } from "../retired-tool-name-account.js";
|
|
10
12
|
import { projectionToolNames } from "../tool-policy.js";
|
|
11
13
|
import { declaredDelegationNameOf } from "../delegation-name.js";
|
|
14
|
+
import { announceDigest } from "./announce-once-ledger.js";
|
|
12
15
|
export function renamedDelegationMountSentence(...rosters) {
|
|
13
16
|
for (const tools of rosters) {
|
|
14
17
|
if (!Array.isArray(tools))
|
|
@@ -74,7 +77,6 @@ function refused(message, code, reason) {
|
|
|
74
77
|
e.detail = { reason };
|
|
75
78
|
return e;
|
|
76
79
|
}
|
|
77
|
-
export const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
|
|
78
80
|
const POLICY_NAME_PROBLEMS_SHOWN = 32;
|
|
79
81
|
const POLICY_NAME_ENTRY_CHARS = 128;
|
|
80
82
|
export function policyNameRefusal(first, more) {
|
|
@@ -116,7 +118,7 @@ const KEPT_ENTRY = {
|
|
|
116
118
|
};
|
|
117
119
|
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)";
|
|
118
120
|
const PEER_WORD = { mcp: "MCP server", a2a: "A2A peer" };
|
|
119
|
-
function judgeToolNameList(where, side, value, universe, advise, code) {
|
|
121
|
+
function judgeToolNameList(where, side, value, universe, advise, code, retired) {
|
|
120
122
|
for (const { entry, name: toolName, content: written } of readableToolNameList(where, side, value, code)) {
|
|
121
123
|
if (toolName === "*" && !written)
|
|
122
124
|
continue;
|
|
@@ -143,6 +145,10 @@ function judgeToolNameList(where, side, value, universe, advise, code) {
|
|
|
143
145
|
advise(new Error(`${where} declares ${renderListEntry(entry)} in its denied tools: this list reads tool names, not content, so the whole tool "${inlineUntrusted(name, 80)}" is denied. ${DENY_LIST_NAMES_ONLY}`));
|
|
144
146
|
continue;
|
|
145
147
|
}
|
|
148
|
+
if (retired !== undefined && side === "denied" && universe.complete && flaw !== undefined && isRetiredLeftOut(flaw, universe.known) && flaw.guidance !== undefined) {
|
|
149
|
+
retired({ field: "deny", entry: inlineUntrusted(entry, 120), layer: "task_selector", guidance: flaw.guidance, source: inlineUntrusted(where, 160) });
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
146
152
|
const phrase = flaw !== undefined ? inertEntryPhrase(flaw) : renderListEntry(entry);
|
|
147
153
|
const undeclared = split !== undefined && split.peer !== "" && !split.peer.includes("*") && !universe.peers.has(mintNamespacePrefix(split.ns, split.peer));
|
|
148
154
|
const why = undeclared ? `no ${PEER_WORD[split.ns.id]} named "${inlineUntrusted(split.peer, 80)}" is declared for this task` : universe.complete ? "no tool of this task answers to that name" : "no tool this run can list answers to that name";
|
|
@@ -275,6 +281,8 @@ export function boundOwnToolLists(record, own) {
|
|
|
275
281
|
}
|
|
276
282
|
export function judgeRunToolLists(input) {
|
|
277
283
|
const { spec, tools, onceLedger, sessionId } = input;
|
|
284
|
+
const retiredLeftOut = [];
|
|
285
|
+
const retire = (entry) => void retiredLeftOut.push(entry);
|
|
278
286
|
const advise = (err) => {
|
|
279
287
|
try {
|
|
280
288
|
onceLedger.onError(err, { phase: "config", sessionId });
|
|
@@ -302,15 +310,16 @@ export function judgeRunToolLists(input) {
|
|
|
302
310
|
if (!input.judgedUpstream) {
|
|
303
311
|
const root = rootFacingUniverse(input.ownBy !== undefined ? new Set([...mounted, input.ownBy.toolName]) : mounted, pool, withOwnServers(definitionServers));
|
|
304
312
|
const own = [["allowed", input.own.allow], ["denied", input.own.exclude]];
|
|
305
|
-
const
|
|
313
|
+
const silent = () => undefined;
|
|
314
|
+
const told = input.toldUpstream === true;
|
|
306
315
|
for (const [side, value] of own)
|
|
307
|
-
judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root,
|
|
316
|
+
judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root, told ? silent : advise, "config.tool_face_control", told ? silent : retire);
|
|
308
317
|
}
|
|
309
318
|
const childUniverses = (servers) => pool.tools.length > 0 ? pool.tools.map((t) => childFacingUniverse(poolOf([t]), withOwnServers(servers))) : [childFacingUniverse(poolOf([]), withOwnServers(servers))];
|
|
310
319
|
for (const def of spec.agents ?? []) {
|
|
311
320
|
for (const universe of childUniverses(def.mcp)) {
|
|
312
321
|
judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "allowed", def.allowTools, universe, advise, "config.agent.unknown_tool");
|
|
313
|
-
judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "denied", def.denyTools, universe, advise, "config.agent.unknown_tool");
|
|
322
|
+
judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "denied", def.denyTools, universe, advise, "config.agent.unknown_tool", retire);
|
|
314
323
|
}
|
|
315
324
|
}
|
|
316
325
|
const replaced = new Set((spec.agents ?? []).map((d) => d.name));
|
|
@@ -321,11 +330,16 @@ export function judgeRunToolLists(input) {
|
|
|
321
330
|
const faceWhere = delegationListWhere(t.name, face.name);
|
|
322
331
|
const faceUniverse = childFacingUniverse(poolOf([t]), withOwnServers(face.servers));
|
|
323
332
|
judgeToolNameList(faceWhere, "allowed", face.allowTools, faceUniverse, advise, "config.agent.unknown_tool");
|
|
324
|
-
judgeToolNameList(faceWhere, "denied", face.denyTools, faceUniverse, advise, "config.agent.unknown_tool");
|
|
333
|
+
judgeToolNameList(faceWhere, "denied", face.denyTools, faceUniverse, advise, "config.agent.unknown_tool", retire);
|
|
325
334
|
}
|
|
326
335
|
}
|
|
327
336
|
judgeToolNameList(delegationListWhere(t.name, undefined), "allowed", t.agentToolLevelAllowTools, universe, advise, "config.agent.unknown_tool");
|
|
328
|
-
judgeToolNameList(delegationListWhere(t.name, undefined), "denied", t.agentToolLevelDenyTools, universe, advise, "config.agent.unknown_tool");
|
|
337
|
+
judgeToolNameList(delegationListWhere(t.name, undefined), "denied", t.agentToolLevelDenyTools, universe, advise, "config.agent.unknown_tool", retire);
|
|
338
|
+
}
|
|
339
|
+
if (retiredLeftOut.length > 0) {
|
|
340
|
+
const notice = retiredToolNameNotice("task_selector", retiredLeftOut, sessionId);
|
|
341
|
+
const whole = [...new Set(retiredLeftOut.map((e) => `${e.field}\u0000${e.entry}\u0000${e.source ?? ""}`))].sort();
|
|
342
|
+
onceLedger.oncePerSession(announceDigest(`${POLICY_NAME_REFUSAL_CODE}:task_selector`, JSON.stringify(whole)), () => deliverEngineNotice(input.onNotice, notice));
|
|
329
343
|
}
|
|
330
344
|
}
|
|
331
345
|
export function judgeHostToolCeiling(layers, agent, above = []) {
|
|
@@ -354,7 +354,7 @@ export interface RunnerDeps {
|
|
|
354
354
|
crossBoundaryPosture?: "single_user" | "multi_tenant";
|
|
355
355
|
/**
|
|
356
356
|
* design/383 §2.1b — an optional host-supplied carrier for the session capture opt-out record
|
|
357
|
-
* (per memory plane, keyed by that plane's control dir). Absent = the
|
|
357
|
+
* (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)
|
|
358
358
|
* (single-process/single-host deployments: byte-identical behavior). A deployment whose control
|
|
359
359
|
* plane does not survive into resume replicas (the stateless multi-replica server form) supplies
|
|
360
360
|
* a durable store here; see {@link import("./memory-engine/layout.js").SessionCaptureRecordStore}
|
|
@@ -991,9 +991,9 @@ export interface RunnerDeps {
|
|
|
991
991
|
* WHO consumes this deployment's principal inbox (`principal.inbox`, where the
|
|
992
992
|
* organization's delivery gate appends cross-principal letters; the mailbox contract's fourth chain).
|
|
993
993
|
* Absent = no consumer, no lane (byte for byte as before); a deployment that mounts a gate DECLARES
|
|
994
|
-
* `{ assistant: "<agent handle>" }` (the
|
|
995
|
-
*
|
|
996
|
-
* letter's own field in the box, so every terminal reads the same one). Letters are judged on the principal's
|
|
994
|
+
* `{ assistant: "<agent handle>" }` (the only consumer; no terminal leg touches the box; an agent handle is `a` and 6–32 lower-case
|
|
995
|
+
* hex digits, the shape the task registry mints) or `"terminals"` (each terminal drains the box as a second lane; a held letter's
|
|
996
|
+
* decision is the letter's own field in the box, so every terminal reads the same one). Letters are judged on the principal's
|
|
997
997
|
* `crossSessionInbound` layers (managed, user), held when unset. ANY other value fails the prepare of a leg
|
|
998
998
|
* that drains a session box with `config.principal_inbox_consumer_invalid` (`detail.reason: "malformed"`).
|
|
999
999
|
*/
|
|
@@ -23,8 +23,8 @@ import { type RedactionConfidence, type RedactionSource } from "@sema-agent/prim
|
|
|
23
23
|
import { type EngineNotice } from "./engine-notice.js";
|
|
24
24
|
/** Does a value carry a credential? A URL userinfo (after every `scheme://`, and a leading `//`) with a password or a
|
|
25
25
|
* token-like user; a scheme-less `user:password@host`; a credential assignment; a webhook URL; a Sonar login; a
|
|
26
|
-
* private-key header; an `Authorization` header, `token …`, `Bearer …` or `Basic …` with credential-shaped content
|
|
27
|
-
* Reads the first {@link VALUE_SCAN_LIMIT} code units. The value half of the judgment, exported apart from the env
|
|
26
|
+
* private-key header; an `Authorization` header, `token …`, `Bearer …` or `Basic …` with credential-shaped content (the
|
|
27
|
+
* 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
|
|
28
28
|
* entry's exemptions ({@link isExemptEnvName}): a caller holding a value that is no environment variable asks this. */
|
|
29
29
|
export declare function looksLikeCredentialValue(value: string): boolean;
|
|
30
30
|
/** Which rule withheld an entry: one of the scrub's rules, or `own-credential` — the entry is one of the engine's own
|
package/dist/core/secret-env.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { types } from "node:util";
|
|
3
|
-
import { CREDENTIAL_MIN_CHARS, envNameView, isSensitiveHeaderName, splitCamelCase } from "@sema-agent/primitives";
|
|
3
|
+
import { CREDENTIAL_MIN_CHARS, envNameView, envValueView, isSensitiveHeaderName, splitCamelCase } from "@sema-agent/primitives";
|
|
4
4
|
import { DEFAULT_INHERITED_ENV_VARS } from "@modelcontextprotocol/client/stdio";
|
|
5
5
|
import { deliverEngineNotice } from "./engine-notice.js";
|
|
6
6
|
import { optionKeys, receiveMembers } from "./own-property-receipt.js";
|
|
@@ -10,6 +10,7 @@ function isExemptEnvName(name) {
|
|
|
10
10
|
return GIT_CONFIG_ENV_RE.test(name) || PROXY_ENV_RE.test(name);
|
|
11
11
|
}
|
|
12
12
|
const ENV_NAMES = envNameView();
|
|
13
|
+
const ENV_VALUES = envValueView();
|
|
13
14
|
const OTEL_ENV_RE = /^(?:INPUT_)?OTEL_/i;
|
|
14
15
|
const SEMA_NAMESPACE_SECRET_RE = ENV_NAMES.anySegmentUnder("SEMA_");
|
|
15
16
|
const BUNDLER_SETTINGS = ["BUILD", "LOCAL", "MIRROR", "PATH", "WITH", "WITHOUT", "CACHE", "DISABLE", "IGNORE", "ONLY"];
|
|
@@ -33,7 +34,7 @@ function nameIsCredentialShaped(name) {
|
|
|
33
34
|
}
|
|
34
35
|
const VALUE_SCAN_LIMIT = 8192;
|
|
35
36
|
function looksLikeToken(user) {
|
|
36
|
-
return
|
|
37
|
+
return ENV_VALUES.tokenHead.test(user) || (user.length >= 20 && /[0-9]/.test(user) && /[a-z]/i.test(user));
|
|
37
38
|
}
|
|
38
39
|
const HOST_RE = /^(?:localhost|[a-z0-9_-]+(?:\.[a-z0-9_-]+)*\.(?=[a-z0-9-]*[a-z])[a-z0-9-]+|[a-z0-9_.-]+(?=:\d+(?:[/?#]|$))|\d{1,3}(?:\.\d{1,3}){3}|\[[0-9a-f:.]+\])(?::\d+)?(?:[/?#]|$)/i;
|
|
39
40
|
const HOSTLIKE_RE = /^(?:(?=[a-z0-9._-]*[a-z])[a-z0-9._-]+|\d{1,3}(?:\.\d{1,3}){3}|\[[0-9a-f:.]+\])(?::\d+)?(?:[/?#]|$)/i;
|
|
@@ -69,14 +70,6 @@ function carriesSchemelessUserinfo(text) {
|
|
|
69
70
|
const at = text.lastIndexOf("@", text.search(/\s|$/));
|
|
70
71
|
return !isHostPortPathBeforeAt(text.slice(0, at), text.slice(at + 1)) && !/^(?:mailto|sips?|xmpp|im|acct):/i.test(text);
|
|
71
72
|
}
|
|
72
|
-
const FLAG_WORDS = ["true", "false", "none", "null", "yes", "no", "on", "off", "enabled", "disabled", "required", "optional"];
|
|
73
|
-
const CREDENTIAL_ASSIGNMENT_RE = new RegExp(String.raw `(?:(?:^|[;&?#,{]|\/:)\s*|\s)["']?(?!-*jobserver-auth\s*[=:])(?:[a-z0-9_.-]{0,64}(?:password|passwd|pwd|secret|token|(?:account|access|api|private|subscription)[-_]?key|signature|sig|credential)|[a-z0-9_.-]{0,63}[_.-]auth)["']?\s*[=:]\s*["']?(?!(?:${FLAG_WORDS.join("|")})(?:$|[;&,\s"']))[^;&,\s"']+`, "i");
|
|
74
|
-
const WEBHOOK_URL_RE = /https:\/\/(?:hooks\.slack\.com\/(?:services|workflows|triggers)\/|(?:ptb\.|canary\.)?discord(?:app)?\.com\/api\/webhooks\/\d+\/|[\w.-]+\.webhook\.office\.com\/webhookb2\/)[\w\/@.~-]{16,}/i;
|
|
75
|
-
const SONAR_LOGIN_RE = new RegExp(String.raw `["']?sonar\.login["']?\s*[:=]\s*["']?[^\s"',}]{${CREDENTIAL_MIN_CHARS},}`);
|
|
76
|
-
const PRIVATE_KEY_HEADER_RE = /-----BEGIN [A-Z ]*PRIVATE KEY(?: BLOCK)?-----/;
|
|
77
|
-
const AUTHORIZATION_HEADER_RE = new RegExp(String.raw `\bauthorization\s*[:=]\s*["']?[a-z][a-z0-9_-]*\s+[A-Za-z0-9._~+\/=-]{${CREDENTIAL_MIN_CHARS},}`, "i");
|
|
78
|
-
const TOKEN_WORD_RE = /\b(?:[Tt]oken|TOKEN)\s+(?=[A-Za-z0-9_~+=-]*[0-9])(?=[A-Za-z0-9_~+=-]*[A-Z])(?=([A-Za-z0-9_~+=-]{20,}))\1(?![\/.])/;
|
|
79
|
-
const BEARER_BASIC_RE = new RegExp(String.raw `\b(?:Bearer|Basic)\s+(?=[A-Za-z._~+\/=-]*[0-9]|(?:[A-Za-z0-9._~+\/=-]*?[a-z][A-Z](?![a-z])){2}|[A-Za-z0-9.-]*[_~+\/=])[A-Za-z0-9._~+\/=-]{${CREDENTIAL_MIN_CHARS},}`);
|
|
80
73
|
export function looksLikeCredentialValue(value) {
|
|
81
74
|
const text = value.length > VALUE_SCAN_LIMIT ? value.slice(0, VALUE_SCAN_LIMIT) : value;
|
|
82
75
|
for (let at = text.indexOf("://"); at !== -1; at = text.indexOf("://", at + 3)) {
|
|
@@ -85,14 +78,7 @@ export function looksLikeCredentialValue(value) {
|
|
|
85
78
|
}
|
|
86
79
|
if (text.startsWith("//") && authorityCarriesCredential(text.slice(2)))
|
|
87
80
|
return true;
|
|
88
|
-
return
|
|
89
|
-
CREDENTIAL_ASSIGNMENT_RE.test(text) ||
|
|
90
|
-
WEBHOOK_URL_RE.test(text) ||
|
|
91
|
-
SONAR_LOGIN_RE.test(text) ||
|
|
92
|
-
PRIVATE_KEY_HEADER_RE.test(text) ||
|
|
93
|
-
AUTHORIZATION_HEADER_RE.test(text) ||
|
|
94
|
-
TOKEN_WORD_RE.test(text) ||
|
|
95
|
-
BEARER_BASIC_RE.test(text));
|
|
81
|
+
return carriesSchemelessUserinfo(text) || ENV_VALUES.forms.some((form) => form.re.test(text));
|
|
96
82
|
}
|
|
97
83
|
const OWN_CREDENTIAL = "the engine's own service credential";
|
|
98
84
|
const SECRET_ENV_KIND_CONFIDENCE = {
|
|
@@ -197,7 +183,7 @@ function runtimeSuppliedHolderOf(value) {
|
|
|
197
183
|
const supplied = policyArm([...runtimeSuppliedEnv()]);
|
|
198
184
|
return Object.keys(supplied).find((k) => supplied[k] === value);
|
|
199
185
|
}
|
|
200
|
-
const PLACEHOLDER_KEY_WORDS = new Set([...
|
|
186
|
+
const PLACEHOLDER_KEY_WORDS = new Set([...ENV_VALUES.flagWords, "undefined", "placeholder", "lm-studio", "not-needed", "sk-no-key-required"]);
|
|
201
187
|
const ONE_REPEATED_CHARACTER_RE = /^(\S)\1{2,}$/u;
|
|
202
188
|
export function isBlankCredential(value) {
|
|
203
189
|
return value.trim() === "";
|
|
@@ -210,7 +196,7 @@ function notACredentialReason(value) {
|
|
|
210
196
|
return `a string of fewer than ${CREDENTIAL_MIN_CHARS} characters, which names no secret`;
|
|
211
197
|
if (PLACEHOLDER_KEY_WORDS.has(text.toLowerCase()))
|
|
212
198
|
return "a flag or placeholder word, which names no secret";
|
|
213
|
-
if (ONE_REPEATED_CHARACTER_RE.test(text.replace(
|
|
199
|
+
if (ONE_REPEATED_CHARACTER_RE.test(text.replace(ENV_VALUES.tokenHead, "")))
|
|
214
200
|
return "one character repeated, which names no secret";
|
|
215
201
|
return undefined;
|
|
216
202
|
}
|
|
@@ -182,12 +182,12 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
182
182
|
placement?: SessionPlacement;
|
|
183
183
|
}): Promise<AcquiredSession>;
|
|
184
184
|
/** The one judgement of "does this cached view still stand for this row": `shown` is the view's session metadata and `row` the row as
|
|
185
|
-
* a read of it answered (a listed row, or the repo's head; `undefined` = no row, or no read of one). A row naming
|
|
186
|
-
*
|
|
187
|
-
* the owner is recorded once, by the write that creates the row, so another owner's row is another row
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* the
|
|
185
|
+
* a read of it answered (a listed row, or the repo's head; `undefined` = no row, or no read of one). A row naming another occupant
|
|
186
|
+
* (`compareOccupants` — the same token, or no token on either side, is one occupant) does not stand for it; neither does a row
|
|
187
|
+
* naming a different owner — the owner is recorded once, by the write that creates the row, so another owner's row is another row
|
|
188
|
+
* whatever it names; any other row does. With no row to judge (unknown) the answer is the repo's: over one with a head read the row
|
|
189
|
+
* can always be read again, so the view is dropped and the id resolved from the row; over one with no head read the cached view is
|
|
190
|
+
* the only evidence of the occupant, and it stands. */
|
|
191
191
|
private viewStandsFor;
|
|
192
192
|
/** Whether a cached view is still the occupant the row holds ({@link viewStandsFor}, over the row's head read in one read) and still
|
|
193
193
|
* the log it holds — the row's leaf is the view's: a log replaced under the same occupant (a cross-backend move's commit, through
|
|
@@ -139,11 +139,11 @@ export class TtlSessionStore {
|
|
|
139
139
|
}
|
|
140
140
|
viewStandsFor(shown, row) {
|
|
141
141
|
const verdict = compareOccupants(shown, row);
|
|
142
|
-
if (verdict
|
|
143
|
-
return
|
|
142
|
+
if (verdict === "different")
|
|
143
|
+
return false;
|
|
144
144
|
if (row !== undefined && (shown.owner ?? null) !== (row.owner ?? null))
|
|
145
145
|
return false;
|
|
146
|
-
return this.repoHead === undefined;
|
|
146
|
+
return verdict === "same" || this.repoHead === undefined;
|
|
147
147
|
}
|
|
148
148
|
async standingRow(sessionId, cached) {
|
|
149
149
|
if (this.repoHead === undefined)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arithmeticTextIsPlain,
|
|
1
|
+
import { arithmeticTextIsPlain, heredocBodyHidesRun, lexShell, namesRedirectDescriptor, PARSE_FAILURE_SENTENCE, wordHidesRun, } from "../shell/lex.js";
|
|
2
2
|
import { shellWordsOf } from "../shell/shell-words.js";
|
|
3
3
|
import { isLauncherAssignmentOperand } from "../tools/fs/bash-program-position.js";
|
|
4
4
|
import { extglobOpenerIn } from "../tools/fs/bash-readonly-classifier.js";
|
|
@@ -50,7 +50,7 @@ function wordOf(w) {
|
|
|
50
50
|
}
|
|
51
51
|
const literalIn = (w, set) => w !== undefined && w.expands === false && set.has(w.text);
|
|
52
52
|
const bareAssignment = (w) => lexedWordOf(w)?.assignment?.bare === true;
|
|
53
|
-
const hidesRun =
|
|
53
|
+
const hidesRun = wordHidesRun;
|
|
54
54
|
const CASE_ARM_UNREAD = "a `case` arm terminator outside a `case` this lane reads";
|
|
55
55
|
const EXTGLOB_UNREAD = "an extended pattern (`?(…)` `*(…)` `+(…)` `@(…)` `!(…)`) is one this reader does not expand";
|
|
56
56
|
export function readShellCommand(source) {
|
|
@@ -122,7 +122,7 @@ export function readShellCommand(source) {
|
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
if (t.kind === "word") {
|
|
125
|
-
if (!namesRedirectDescriptor(
|
|
125
|
+
if (!namesRedirectDescriptor(tokens[i + 1]))
|
|
126
126
|
seg.words.push(word(t));
|
|
127
127
|
return;
|
|
128
128
|
}
|
package/dist/core/side-query.js
CHANGED
|
@@ -58,7 +58,7 @@ export async function runSideQuery(spec, deps) {
|
|
|
58
58
|
? { tools: spec.tools.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })) }
|
|
59
59
|
: {}),
|
|
60
60
|
};
|
|
61
|
-
const thinking = resolved.thinking
|
|
61
|
+
const thinking = resolved.thinking;
|
|
62
62
|
const auth = await spec.getApiKeyAndHeaders?.(resolved.model);
|
|
63
63
|
const options = {
|
|
64
64
|
...(spec.signal !== undefined ? { signal: spec.signal } : {}),
|
|
@@ -3,6 +3,7 @@ import type { PermissionMode } from "./ask-origin.js";
|
|
|
3
3
|
import { type PermissionSeatInputs, type PermissionSeatReading } from "./mode-policy.js";
|
|
4
4
|
import type { AgentTool } from "../internal/harness-types.js";
|
|
5
5
|
import { type SkillGrantBindingMembers } from "./skill-grant-binding.js";
|
|
6
|
+
import { type EngineNotice } from "./engine-notice.js";
|
|
6
7
|
import { type AllowEntryGateSeats, type AllowEntryInert, type AllowEntryJudgeContext, type CompiledAllowEntry } from "./allow-entry.js";
|
|
7
8
|
/** Who wrote a row: the `Skill` tool on a successful activation, prepare for a skill the person invoked by name, or a
|
|
8
9
|
* delegated child's seed from its parent. */
|
|
@@ -120,6 +121,12 @@ export interface SkillGrantHit {
|
|
|
120
121
|
}
|
|
121
122
|
/** The refusal a deny hit writes: a deny row's, or an activation's whose deny entries read as nothing. */
|
|
122
123
|
export declare function skillDenyDecision(hit: SkillGrantHit): PermissionResult;
|
|
124
|
+
/**
|
|
125
|
+
* Tell the entries of a skill's `disallowed-tools` that name a tool the engine retired with no successor — the half of the inert reading a
|
|
126
|
+
* skill's activation does NOT refuse on (see {@link unreadDenyOf}) — as ONE retired-name notice (layer `skill_table`, each entry's `source`
|
|
127
|
+
* the skill), and answer `inert` without them: they are no line of the "grants or refuses nothing" notice. Nothing to tell ⇒ `inert` as given.
|
|
128
|
+
*/
|
|
129
|
+
export declare function tellRetiredSkillDeny(onNotice: ((notice: EngineNotice) => void) | undefined, inert: readonly SkillInertEntry[], sessionId: string, roster: ReadonlySet<string>): readonly SkillInertEntry[];
|
|
123
130
|
/** The run's deny rows over `req` through `lane` — the refusal they write, or undefined (no lane, no row). The one
|
|
124
131
|
* reading the gate's regular decision, its approved-edit round and the resumed execution boundary share. */
|
|
125
132
|
export declare function skillRowRefusal(lane: Pick<SkillGrantLane, "denying"> | undefined, req: ToolCallRequest): PermissionResult | undefined;
|
package/dist/core/skill-grant.js
CHANGED
|
@@ -5,8 +5,10 @@ import { inlineUntrusted } from "./untrusted-text.js";
|
|
|
5
5
|
import { boundInputHashOf } from "./canonical-json.js";
|
|
6
6
|
import { NOT_BINDABLE } from "./skill-grant-binding.js";
|
|
7
7
|
import { readToolNameList } from "./tool-name-list.js";
|
|
8
|
+
import { deliverEngineNotice } from "./engine-notice.js";
|
|
9
|
+
import { retiredToolNameNotice } from "./retired-tool-name-account.js";
|
|
8
10
|
import { closestName } from "./closest-name.js";
|
|
9
|
-
import { allowingRows, strippedInAuto, compileAllowList, readRuleEntry, inertEntryPhrase, judgeAllowEntries, nonListValueLabel, renderListEntry, spelledListEntry } from "./allow-entry.js";
|
|
11
|
+
import { allowingRows, strippedInAuto, compileAllowList, isRetiredLeftOut, readRuleEntry, inertEntryPhrase, judgeAllowEntries, nonListValueLabel, renderListEntry, spelledListEntry } from "./allow-entry.js";
|
|
10
12
|
export const SKILL_GRANT_ORIGINS = Object.freeze(["model", "user", "inherited"]);
|
|
11
13
|
const FROZEN_SKILL_GRANT_ORIGINS = new Set(["model", "inherited"]);
|
|
12
14
|
export function skillNamedBy(args, skills) {
|
|
@@ -121,8 +123,15 @@ export function skillDenyDecision(hit) {
|
|
|
121
123
|
decisionReason: "skill",
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
|
-
function unreadDenyOf(inert) {
|
|
125
|
-
return inert.filter((i) => i.list === "disallowed-tools");
|
|
126
|
+
function unreadDenyOf(inert, roster) {
|
|
127
|
+
return inert.filter((i) => i.list === "disallowed-tools" && !isRetiredLeftOut(i, roster));
|
|
128
|
+
}
|
|
129
|
+
export function tellRetiredSkillDeny(onNotice, inert, sessionId, roster) {
|
|
130
|
+
const retired = inert.filter((i) => i.list === "disallowed-tools" && isRetiredLeftOut(i, roster));
|
|
131
|
+
if (retired.length === 0)
|
|
132
|
+
return inert;
|
|
133
|
+
deliverEngineNotice(onNotice, retiredToolNameNotice("skill_table", retired.map((e) => ({ field: "deny", entry: inlineUntrusted(e.entry, 120), layer: "skill_table", guidance: e.guidance ?? "", source: `Skill ${inlineUntrusted(e.skill, 80)}` })), sessionId));
|
|
134
|
+
return inert.filter((i) => !retired.includes(i));
|
|
126
135
|
}
|
|
127
136
|
export function skillRowRefusal(lane, req) {
|
|
128
137
|
const hit = lane?.denying(req);
|
|
@@ -220,7 +229,7 @@ export class SkillGrantTable {
|
|
|
220
229
|
}
|
|
221
230
|
activate(skill, origin) {
|
|
222
231
|
const { rows, inert } = compileSkillGrant(skill, origin, this.mountedNames());
|
|
223
|
-
const unreadDeny = unreadDenyOf(inert);
|
|
232
|
+
const unreadDeny = unreadDenyOf(inert, this.mountedNames());
|
|
224
233
|
if (unreadDeny.length > 0)
|
|
225
234
|
throw skillDenyUnreadable(skill.name, unreadDeny, "activation");
|
|
226
235
|
for (const row of rows)
|
|
@@ -260,7 +269,7 @@ export class SkillGrantTable {
|
|
|
260
269
|
if (at === undefined || !isSkillActivationCall(req, at.skills, at.skillToolName))
|
|
261
270
|
return undefined;
|
|
262
271
|
const skill = skillNamedBy(req.args, at.skills);
|
|
263
|
-
const unread = skill === undefined ? [] : unreadDenyOf(compileSkillGrant(skill, "model", this.mountedNames()).inert);
|
|
272
|
+
const unread = skill === undefined ? [] : unreadDenyOf(compileSkillGrant(skill, "model", this.mountedNames()).inert, this.mountedNames());
|
|
264
273
|
return skill === undefined || unread.length === 0 ? undefined : { skill: skill.name, entries: unread.map((i) => i.entry), readsAsNothing: unread };
|
|
265
274
|
}
|
|
266
275
|
}
|
|
@@ -99,6 +99,19 @@ export async function backgroundAgentStoreContract(mk, runAssertion) {
|
|
|
99
99
|
assert.deepEqual(after.policyFloor, before.policyFloor, `a CAS update must carry the floor it did not change (${handle})`);
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
+
run("the root anchor's occupant round-trips beside the anchor — ABSENT stays absent, a CAS carries it", async (make) => {
|
|
103
|
+
const store = make();
|
|
104
|
+
await store.put(record({ handle: "a1", rootSessionId: "sess-root", rootSessionIncarnation: "occ-root-1" }));
|
|
105
|
+
const withOccupant = await held(store, "a1");
|
|
106
|
+
assert.equal(withOccupant.rootSessionId, "sess-root");
|
|
107
|
+
assert.equal(withOccupant.rootSessionIncarnation, "occ-root-1");
|
|
108
|
+
await store.put(record({ handle: "a2", rootSessionId: "sess-root" }));
|
|
109
|
+
const without = await held(store, "a2");
|
|
110
|
+
assert.equal(without.rootSessionIncarnation, undefined, "a row that records no root occupant must not read back with one");
|
|
111
|
+
const after = { ...withOccupant, status: "completed", settledAt: 2_000 };
|
|
112
|
+
assert.equal(await store.update("a1", S, after, { rev: withOccupant.rev }), true);
|
|
113
|
+
assert.equal((await held(store, "a1")).rootSessionIncarnation, "occ-root-1", "a CAS update must carry the root occupant it did not change");
|
|
114
|
+
});
|
|
102
115
|
run("put refuses a scopeless row (a row with no tenant partition would be world-readable)", async (make) => {
|
|
103
116
|
const store = make();
|
|
104
117
|
await assert.rejects(store.put(record({ scope: "" })), "an empty scope must be refused loudly, not stored");
|
|
@@ -1061,6 +1061,13 @@ export type TaskEvent = ({
|
|
|
1061
1061
|
* rides the account the screening entrance mints — the `"applied"` frame of an objective, a parked steer or a wake's
|
|
1062
1062
|
* message, the `"queued"` frame of a live steer. Absent ⇒ the text went as it came. */
|
|
1063
1063
|
rewrittenBy?: readonly string[];
|
|
1064
|
+
/** Who wrote THIS input, when it is not the operator ({@link import("./input-author.js").InputAuthor}): `"extension"` for an
|
|
1065
|
+
* extension's prompt (`$.prompt.submit`), `"observer"` for an observer's report relayed to the child it watches. Rides
|
|
1066
|
+
* both frames of a live steer's account (`"queued"`, `"applied"`). Absent ⇒ the operator (a person, or the host relaying
|
|
1067
|
+
* one) — every input of the public verbs. Render a non-operator input as its author's, never as the person's. */
|
|
1068
|
+
author?: Exclude<import("./input-author.js").InputAuthor, "operator">;
|
|
1069
|
+
/** The calling registration's name, beside `author: "extension"` (and only there). */
|
|
1070
|
+
extension?: string;
|
|
1064
1071
|
} & TaskEventIdentity) | ({
|
|
1065
1072
|
/**
|
|
1066
1073
|
* design/99 §E3/§E10 — a live BRAIN-LAYER status the brain would otherwise absorb
|
|
@@ -1382,6 +1389,13 @@ export interface HumanInputAttachment {
|
|
|
1382
1389
|
readonly kind?: UserAttachmentKind;
|
|
1383
1390
|
readonly outcome: UserAttachmentOutcome;
|
|
1384
1391
|
readonly label: string;
|
|
1392
|
+
/** The extension of the leg that refused this attachment at its `prompt.mention` station, by its registration name — the same author
|
|
1393
|
+
* type {@link ExtensionRequester} and {@link RewriteAuthor} record elsewhere. Present only on a `not_attached` attachment whose refusal
|
|
1394
|
+
* the dispatch names: an extension's `{ deny }` / `{ type: null }` answer, or an extension whose handler failed (threw, ran past its
|
|
1395
|
+
* budget, answered what the station refuses). Absent on every attachment that reached the model, and when no extension is to be named:
|
|
1396
|
+
* a read rule's refusal, the run's cancel, the engine's own fault, and a bad spelling handed down the chain (which handler handed it
|
|
1397
|
+
* is not said). A display and audit fact; it decides nothing. */
|
|
1398
|
+
readonly declinedBy?: ExtensionRequester;
|
|
1385
1399
|
}
|
|
1386
1400
|
/**
|
|
1387
1401
|
* Outcome of a manual {@link TaskStream.compact} request (the enum names align with
|