@sema-agent/core 7.65.0 → 7.66.1
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 +269 -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-session-drain.d.ts +51 -12
- package/dist/agents/peer-session-drain.js +44 -31
- 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 +79 -75
- 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/engine-notice.d.ts +3 -3
- package/dist/core/governance-codes.js +1 -0
- 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/memory-engine/consolidation.d.ts +23 -9
- package/dist/core/memory-engine/consolidation.js +30 -5
- package/dist/core/memory-engine/control-plane-adoption.d.ts +11 -10
- package/dist/core/memory-engine/control-plane-adoption.js +54 -29
- package/dist/core/memory-engine/delegation-settlement.d.ts +18 -12
- package/dist/core/memory-engine/delegation-settlement.js +36 -26
- package/dist/core/memory-engine/engine.d.ts +17 -6
- package/dist/core/memory-engine/engine.js +78 -35
- package/dist/core/memory-engine/file-backend.d.ts +4 -1
- package/dist/core/memory-engine/file-backend.js +5 -1
- 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 +57 -36
- package/dist/core/memory-engine/layout.js +109 -134
- package/dist/core/memory-engine/memory-backend-contract.js +7 -7
- package/dist/core/memory-engine/memory-deployment.d.ts +3 -2
- 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 +143 -55
- 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/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/compact-session.js +2 -1
- package/dist/core/runner/contracts.d.ts +1 -1
- 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-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.js +26 -5
- package/dist/core/runner/prepare-park-ask.d.ts +2 -0
- package/dist/core/runner/prepare-park-ask.js +3 -1
- package/dist/core/runner/prepare-policy-chain.js +2 -1
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-question-face.d.ts +2 -2
- package/dist/core/runner/prepare-task.d.ts +5 -1
- package/dist/core/runner/prepare-task.js +5 -4
- 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 -27
- package/dist/core/runner/sub-agent-deny-lists.js +22 -33
- package/dist/core/runner-deps.d.ts +4 -4
- 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/task-event.d.ts +14 -0
- package/dist/core/tool-policy.js +2 -3
- package/dist/core/tool-spec.d.ts +13 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +11 -5
- 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/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/shell/lex.d.ts +50 -15
- package/dist/shell/lex.js +43 -9
- 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 +13 -7
- package/wire-changes/core-stores-sql@7.66.0.json +30 -0
- package/wire-changes/core-stores-sql@7.66.1.json +30 -0
- package/wire-changes/core@7.66.0.json +1218 -0
- package/wire-changes/core@7.66.1.json +46 -0
- package/wire-changes/mods-kernel@7.66.0.json +65 -0
- package/wire-changes/mods-kernel@7.66.1.json +30 -0
- package/wire-changes/primitives@7.66.0.json +30 -0
- package/wire-changes/primitives@7.66.1.json +30 -0
|
@@ -12,7 +12,9 @@ import type { TaskSpec } from "../task-spec.js";
|
|
|
12
12
|
import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModEventName, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
|
|
13
13
|
import { type SourcedOverlay } from "../../prompt-assembly/overlay.js";
|
|
14
14
|
import type { BandId } from "../../prompt-assembly/catalog/schema.js";
|
|
15
|
-
import type { ModParticipant } from "./kernel/dispatch.js";
|
|
15
|
+
import type { ModFrame, ModParticipant } from "./kernel/dispatch.js";
|
|
16
|
+
import type { ModOrigin } from "./kernel/index.js";
|
|
17
|
+
import type { InputAuthor } from "../input-author.js";
|
|
16
18
|
import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView, type SessionUsage, type SessionVersion } from "./dollar.js";
|
|
17
19
|
import type { SkillSpec } from "../agent-definition.js";
|
|
18
20
|
import { type SkillScopes } from "./spec-seats.js";
|
|
@@ -46,8 +48,8 @@ export interface LegEvents {
|
|
|
46
48
|
* Both ends of a leg, from the delegation fact alone (a child resumed from its checkpoint keeps it): a delegated leg opens on
|
|
47
49
|
* `classic.SubagentStart` and ends on `classic.SubagentStop`, any other opens on nothing and ends on `classic.Stop`. Not the leg
|
|
48
50
|
* kind (a resumed leg's kind reads `"resume"` whoever it runs as), and not who wrote the objective: whether an input passes
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
+
* the prompt screen is the input's own fact, its author's row (`isScreened`, input-author.ts) — a delegator's words are judged
|
|
52
|
+
* at the delegator's gate (`classic.PreToolUse` on the delegating call), an operator's resume of a child is screened.
|
|
51
53
|
*/
|
|
52
54
|
export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined): LegEvents;
|
|
53
55
|
/**
|
|
@@ -164,6 +166,11 @@ export declare function classicEventBase(identity: HookInvocationIdentity | unde
|
|
|
164
166
|
* an observation must never change what it observes. The `e` is the event's own, as {@link ClassicEventMap} types it.
|
|
165
167
|
*/
|
|
166
168
|
export declare function observeClassic<K extends ClassicEventName>(bus: LegModBus, event: K, e: ClassicEventMap[K]["e"], signal: AbortSignal | undefined): Promise<void>;
|
|
169
|
+
/** The frames and origin a raise runs under (an extension's `$` call's), so the caller's own handlers stay out of it. */
|
|
170
|
+
export interface RaisedUnder {
|
|
171
|
+
readonly frames: readonly ModFrame[];
|
|
172
|
+
readonly origin: ModOrigin;
|
|
173
|
+
}
|
|
167
174
|
/**
|
|
168
175
|
* Raise a classic event whose answer the station reads: `undefined` when no handler hangs on it (the station
|
|
169
176
|
* runs as if the bus were not there), else the dispatch outcome. A rejection is an engine fault, never a
|
|
@@ -175,6 +182,7 @@ export declare function dispatchClassic<K extends ClassicEventName>(bus: LegModB
|
|
|
175
182
|
readonly checkAnswer?: ModAnswerCheck;
|
|
176
183
|
readonly ranks?: ModAnswerRanks;
|
|
177
184
|
readonly participant?: (p: ModParticipant) => boolean;
|
|
185
|
+
readonly raisedUnder?: RaisedUnder;
|
|
178
186
|
}): Promise<ModDispatchOutcome | undefined>;
|
|
179
187
|
/** The answer form of a classic event whose answer is an object of optional string members (`block`, `additionalContext`, …). */
|
|
180
188
|
export declare function stringMembersAnswer(event: string, members: readonly string[]): (answer: unknown) => string | undefined;
|
|
@@ -256,6 +264,12 @@ export declare function promptScreenDeclaredBy(registrations: readonly {
|
|
|
256
264
|
readonly events: readonly string[];
|
|
257
265
|
};
|
|
258
266
|
}[]): boolean;
|
|
267
|
+
/** A screened input as the screen raises it: its author as judged, and for an extension's prompt the caller and its `$` call. */
|
|
268
|
+
export interface PromptScreenInput {
|
|
269
|
+
readonly author: InputAuthor;
|
|
270
|
+
readonly extension?: string;
|
|
271
|
+
readonly raisedUnder?: RaisedUnder;
|
|
272
|
+
}
|
|
259
273
|
/**
|
|
260
274
|
* A prompt's screen at one of the four entrances (objective, live steer, a wake's message before its claim, a parked steer
|
|
261
275
|
* redelivered): `prompt.submit` over `e` with the prompt as `text`, its bottom raising `classic.UserPromptSubmit` on the text
|
|
@@ -263,8 +277,9 @@ export declare function promptScreenDeclaredBy(registrations: readonly {
|
|
|
263
277
|
* handler that throws, runs past its budget or breaks the site's contract ends the screen `failed`, and every entrance fails
|
|
264
278
|
* closed on it; a cancelled screen ends `aborted` at once; a dispatch the engine could not run is `failed` too. What the
|
|
265
279
|
* classic screen refused (its block, failure or cancel) is final — a `prompt.submit` handler above it does not undo it.
|
|
280
|
+
* `input` ({@link PromptScreenInput}) rides `prompt.submit`'s `e` (both stations raised under its `$` call, when it has one).
|
|
266
281
|
*/
|
|
267
|
-
export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
|
|
282
|
+
export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined, input?: PromptScreenInput): Promise<PromptScreen | undefined>;
|
|
268
283
|
/**
|
|
269
284
|
* Raise `classic.SubagentStart` as a delegated leg opens on its objective (undefined when no handler hangs on it): the
|
|
270
285
|
* context the chain answers. It never keeps the child from starting — a handler that fails is skipped and reported by
|
|
@@ -363,6 +378,8 @@ export interface LegFacadeSeats {
|
|
|
363
378
|
readonly sessionSend: ModCallEntry;
|
|
364
379
|
/** `$.session.compact`'s host entry (`createSessionCompactEntry`, `session-compact.ts`). */
|
|
365
380
|
readonly sessionCompact: ModCallEntry;
|
|
381
|
+
/** `$.prompt.submit`'s host entry (`createPromptSubmitEntry`, `prompt-submit.ts`). */
|
|
382
|
+
readonly promptSubmit: ModCallEntry;
|
|
366
383
|
}
|
|
367
384
|
/** The leg's admitted bus, its chain identity (the one its admission recorded, {@link chainOfBus}) and the binding of the
|
|
368
385
|
* facade its `$` reaches. `bus` is the leg bus every station raises on ({@link legBusOf}: an extension's own call's
|
|
@@ -441,6 +458,8 @@ export interface LegFacadeInput {
|
|
|
441
458
|
readonly sessionSend: ModCallEntry;
|
|
442
459
|
/** `$.session.compact`'s host entry, over the leg's compaction station. */
|
|
443
460
|
readonly sessionCompact: ModCallEntry;
|
|
461
|
+
/** `$.prompt.submit`'s host entry, over the leg's stream's steer relay. */
|
|
462
|
+
readonly promptSubmit: ModCallEntry;
|
|
444
463
|
}
|
|
445
464
|
/** The seat a leg reads its subagents' transcripts through: its task list, only the rows its own access reaches. Each row
|
|
446
465
|
* carries the store its child's session lives in, so no store of the leg's own is read. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
2
|
import { engineVersion } from "../version.js";
|
|
3
|
-
import { resolveModel } from "../roles.js";
|
|
3
|
+
import { resolveModel, resolveTaskModel } from "../roles.js";
|
|
4
4
|
import { brainToRuntime } from "../runtime.js";
|
|
5
5
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
6
6
|
import { extensionWords } from "../untrusted-egress.js";
|
|
@@ -138,6 +138,7 @@ export async function dispatchClassic(bus, event, e, options) {
|
|
|
138
138
|
const check = options.checkAnswer;
|
|
139
139
|
return await bus.dispatch(event, e, {
|
|
140
140
|
bottom: engineCore,
|
|
141
|
+
...(options.raisedUnder !== undefined ? { frames: options.raisedUnder.frames, origin: options.raisedUnder.origin } : {}),
|
|
141
142
|
...(options.participant !== undefined ? { participant: options.participant } : {}),
|
|
142
143
|
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
143
144
|
...(check !== undefined ? { checkAnswer: (a, ce, by, below, run) => (a === ENGINE_CORE_ANSWER ? undefined : check(a, ce, by, below, run)) } : {}),
|
|
@@ -259,10 +260,13 @@ function readSubmitAnswer(a) {
|
|
|
259
260
|
return { why: PROMPT_SUBMIT_FORM };
|
|
260
261
|
}
|
|
261
262
|
const PROMPT_SUBMIT_RANKS = Object.freeze({ of: (a) => (isPlainRecord(a) && Object.hasOwn(a, "drop") ? 1 : 0), top: 1 });
|
|
262
|
-
|
|
263
|
+
const OPERATOR_SCREEN = Object.freeze({ author: "operator" });
|
|
264
|
+
export async function screenUserPrompt(bus, e, signal, input = OPERATOR_SCREEN) {
|
|
263
265
|
if (!promptScreenHasHandlers(bus))
|
|
264
266
|
return undefined;
|
|
265
|
-
const { prompt, ...
|
|
267
|
+
const { prompt, ...classicFacts } = e;
|
|
268
|
+
const facts = { ...classicFacts, author: input.author, ...(input.extension !== undefined ? { extension: input.extension } : {}) };
|
|
269
|
+
const raisedUnder = input.raisedUnder;
|
|
266
270
|
const changes = textChanges(prompt);
|
|
267
271
|
const checkHandOn = (handed, by) => {
|
|
268
272
|
const t = handed["text"];
|
|
@@ -274,7 +278,7 @@ export async function screenUserPrompt(bus, e, signal) {
|
|
|
274
278
|
const seen = {};
|
|
275
279
|
const bottom = async (handed) => {
|
|
276
280
|
const text = handed["text"];
|
|
277
|
-
const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal);
|
|
281
|
+
const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal, raisedUnder);
|
|
278
282
|
if (classic !== undefined)
|
|
279
283
|
seen.classic = classic;
|
|
280
284
|
if (classic === undefined || (classic.kind === "answered" && !classic.block))
|
|
@@ -293,7 +297,7 @@ export async function screenUserPrompt(bus, e, signal) {
|
|
|
293
297
|
};
|
|
294
298
|
let outcome;
|
|
295
299
|
try {
|
|
296
|
-
outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}) });
|
|
300
|
+
outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}), ...(raisedUnder !== undefined ? { frames: raisedUnder.frames, origin: raisedUnder.origin } : {}) });
|
|
297
301
|
}
|
|
298
302
|
catch (err) {
|
|
299
303
|
return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screen: ${describeThrown(err)}`, skipped: [] };
|
|
@@ -314,11 +318,12 @@ export async function screenUserPrompt(bus, e, signal) {
|
|
|
314
318
|
return { kind: "answered", text: prompt, ...context };
|
|
315
319
|
return { kind: "answered", text: read.text, rewrittenBy: changes.rewrittenBy(), ...context };
|
|
316
320
|
}
|
|
317
|
-
async function screenClassicPrompt(bus, e, signal) {
|
|
321
|
+
async function screenClassicPrompt(bus, e, signal, raisedUnder) {
|
|
318
322
|
let outcome;
|
|
319
323
|
try {
|
|
320
324
|
outcome = await dispatchClassic(bus, "classic.UserPromptSubmit", e, {
|
|
321
325
|
...(signal !== undefined ? { signal } : {}),
|
|
326
|
+
...(raisedUnder !== undefined ? { raisedUnder } : {}),
|
|
322
327
|
checkAnswer: stringMembersAnswer("classic.UserPromptSubmit", ["block", "additionalContext"]),
|
|
323
328
|
ranks: USER_PROMPT_RANKS,
|
|
324
329
|
});
|
|
@@ -518,6 +523,7 @@ function lateView() {
|
|
|
518
523
|
"session.append": (args, ctx) => need("session.append").sessionAppend(args, ctx),
|
|
519
524
|
"session.send": (args, ctx) => need("session.send").sessionSend(args, ctx),
|
|
520
525
|
"session.compact": (args, ctx) => need("session.compact").sessionCompact(args, ctx),
|
|
526
|
+
"prompt.submit": (args, ctx) => need("prompt.submit").promptSubmit(args, ctx),
|
|
521
527
|
},
|
|
522
528
|
bind: (s) => {
|
|
523
529
|
seats = s;
|
|
@@ -580,7 +586,7 @@ export function legFacadeSeats(input) {
|
|
|
580
586
|
const model = request.model !== undefined ? resolveModel(request.model, input.deps.models) : input.model;
|
|
581
587
|
answeredBy.set(model.id, model);
|
|
582
588
|
const auth = await input.spec.getApiKeyAndHeaders?.(model);
|
|
583
|
-
const reply = await runtime.completeSimple(model, { ...request.context, messages: [...request.context.messages] }, { signal, maxTokens: request.maxTokens, ...(auth?.apiKey !== undefined ? { apiKey: auth.apiKey } : {}), ...(auth?.headers !== undefined ? { headers: auth.headers } : {}) });
|
|
589
|
+
const reply = await runtime.completeSimple(model, { ...request.context, messages: [...request.context.messages] }, { signal, maxTokens: request.maxTokens, reasoning: resolveTaskModel({ model }, {}).thinking, ...(auth?.apiKey !== undefined ? { apiKey: auth.apiKey } : {}), ...(auth?.headers !== undefined ? { headers: auth.headers } : {}) });
|
|
584
590
|
if (reply.stopReason === "error" || reply.stopReason === "aborted")
|
|
585
591
|
throw new Error(`model.complete: ${reply.errorMessage ?? reply.stopReason}`);
|
|
586
592
|
if (reply.usage !== undefined)
|
|
@@ -612,6 +618,7 @@ export function legFacadeSeats(input) {
|
|
|
612
618
|
sessionAppend: input.sessionAppend,
|
|
613
619
|
sessionSend: input.sessionSend,
|
|
614
620
|
sessionCompact: input.sessionCompact,
|
|
621
|
+
promptSubmit: input.promptSubmit,
|
|
615
622
|
};
|
|
616
623
|
}
|
|
617
624
|
export async function admitModChain(seats, onError) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RetiredToolNameAccount } from "./retired-tool-name-account.js";
|
|
2
|
+
/**
|
|
3
|
+
* The account of a restricting tool table the HOST owns and the engine never reads (`settings.permissions.neverAuto`): the entries of `table` that
|
|
4
|
+
* name a tool the engine retired with NO successor — read by the same reader and asked the same question as the engine's own tables
|
|
5
|
+
* (`compileAllowList` then `isRetiredLeftOut`: the name is retired with no `currentName`, and `roster` carries no other case of it) — in the same
|
|
6
|
+
* sentence and the same detail shape as the engine's retired-name notice, or `undefined` when there is none. Pure: it
|
|
7
|
+
* carries no code, no audience, no minter and no session — the host mints its own notice (the retired-name notice's code, minter the host) with
|
|
8
|
+
* `sessionId` added to `detail`, and decides what its table does with the entries (the engine's tables leave them out and go on). `roster` = the
|
|
9
|
+
* names the host knows are mounted (a tool mounted under a retired name is its own, not retired; a tool mounted under another case of it keeps the
|
|
10
|
+
* entry refused, as it does in the engine); `source` names the table in the sentence and in each entry's `source`. A renamed name (it has a
|
|
11
|
+
* successor), an unprefixed or unmintable one is NOT here: the host refuses those as the engine does. `deny` and `ask` read a name alike (both restrict).
|
|
12
|
+
* A table that is no object, a `field` outside `deny` / `ask`, a `source` that is not a non-blank string and `entries` that are no list are refused
|
|
13
|
+
* with a `TypeError` coded `config.invalid_argument` — no sentence is made from them; an entry that is no string reads as nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function retiredToolNameAccount(table: {
|
|
16
|
+
readonly field: "deny" | "ask";
|
|
17
|
+
readonly source: string;
|
|
18
|
+
readonly entries: readonly string[];
|
|
19
|
+
}, roster?: ReadonlySet<string>): RetiredToolNameAccount | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { compileAllowList, isRetiredLeftOut } from "./allow-entry.js";
|
|
2
|
+
import { accountOfRetired } from "./retired-tool-name-account.js";
|
|
3
|
+
const NO_ROSTER = new Set();
|
|
4
|
+
function shownValue(v) {
|
|
5
|
+
if (typeof v === "string")
|
|
6
|
+
return JSON.stringify(v.length > 40 ? `${v.slice(0, 40)}…` : v);
|
|
7
|
+
return v === null ? "null" : Array.isArray(v) ? "an array" : typeof v;
|
|
8
|
+
}
|
|
9
|
+
function refuseTable(problem) {
|
|
10
|
+
throw Object.assign(new TypeError(`retiredToolNameAccount: ${problem} — no account is made`), { code: "config.invalid_argument" });
|
|
11
|
+
}
|
|
12
|
+
export function retiredToolNameAccount(table, roster = NO_ROSTER) {
|
|
13
|
+
if (typeof table !== "object" || table === null)
|
|
14
|
+
return refuseTable(`the table is an object { field, source, entries }, not ${shownValue(table)}`);
|
|
15
|
+
const { field, source, entries } = table;
|
|
16
|
+
if (field !== "deny" && field !== "ask")
|
|
17
|
+
return refuseTable(`field ${shownValue(field)} is not a restricting list ("deny" or "ask")`);
|
|
18
|
+
if (typeof source !== "string" || source.trim() === "")
|
|
19
|
+
return refuseTable(`source ${shownValue(source)} names no table — it is the table's name in the sentence`);
|
|
20
|
+
if (!Array.isArray(entries))
|
|
21
|
+
return refuseTable(`entries are a list of tool names, not ${shownValue(entries)}`);
|
|
22
|
+
const retired = [];
|
|
23
|
+
for (const e of compileAllowList(entries, "deny", roster).inert) {
|
|
24
|
+
if (isRetiredLeftOut(e, roster) && e.guidance !== undefined)
|
|
25
|
+
retired.push({ field, entry: e.entry, layer: "host_table", guidance: e.guidance, source });
|
|
26
|
+
}
|
|
27
|
+
return retired.length === 0 ? undefined : accountOfRetired("host_table", retired);
|
|
28
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE account of the entries of a restricting tool table that name a tool the engine retired with NO successor to write
|
|
3
|
+
* (`TeamCreate`, `TaskOutput`, … — the retirement table's `removed` and `folded` lines, `RETIRED_TOOL_NAMES`): the sentence and the data
|
|
4
|
+
* of the retired-name notice (audience `user`; code {@link POLICY_NAME_REFUSAL_CODE}). Such a name reaches no tool in any roster, now or later, and never did anything a
|
|
5
|
+
* rewrite could restore, so every restricting table leaves the entry out, goes on, and says so ONCE in these words — the engine's own tables (a
|
|
6
|
+
* tool policy's `deny` / `ask`, a task's tool-name lists, a skill's `disallowed-tools`) through `retiredToolNameNotice`
|
|
7
|
+
* (`runner/sub-agent-deny-lists.ts`, the engine's mint), a table the host owns and the engine never reads through
|
|
8
|
+
* `retiredToolNameAccount` (`retired-host-table-account.ts`: the host mints its own notice from the pure account). This module holds the words and the
|
|
9
|
+
* data and reads no entry; the one reader and the one question (`compileAllowList`, then `isRetiredLeftOut`) are `allow-entry.ts`'s.
|
|
10
|
+
* A name the engine RENAMED (it has a successor the entry used to guard), an unprefixed namespace and an unmintable segment are not here:
|
|
11
|
+
* leaving such an entry out would widen the surface, so every table still refuses them.
|
|
12
|
+
*/
|
|
13
|
+
import type { EngineNotice } from "./engine-notice.js";
|
|
14
|
+
/** The code of the policy-name refusal and of the retired-name notice — the one spelling their mints and every problem they list carry. */
|
|
15
|
+
export declare const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
|
|
16
|
+
/** The tables the account is told for, by the words the trace already gives the first three: the run's own policy (`caller_policy`), the stored
|
|
17
|
+
* rules of its session, the rules an ancestor's session handed it; the lists the engine reads beside the policy — a task's tool-name lists
|
|
18
|
+
* (`task_selector`: `excludeTools`, a definition's or a delegation tool's `denyTools`) and a skill's `disallowed-tools` (`skill_table`); and
|
|
19
|
+
* `host_table`, a restricting table the HOST owns and the engine never reads (`settings.permissions.neverAuto`). */
|
|
20
|
+
export type PolicyNameLayer = "caller_policy" | "session_rules" | "ancestor_session_rules" | "task_selector" | "skill_table" | "host_table";
|
|
21
|
+
/** One entry of a restricting list (`deny` / `ask`) that names a tool the engine retired with no successor to write: the name matches nothing in
|
|
22
|
+
* any roster, so its table leaves the entry out and says so instead of refusing the run. `guidance` is the retirement table's own line for the
|
|
23
|
+
* name; `source` names the list when a layer holds more than one (a task's list, a skill, a host table), carried into the sentence and the detail. */
|
|
24
|
+
export interface RetiredPolicyEntry {
|
|
25
|
+
readonly field: "deny" | "ask";
|
|
26
|
+
readonly entry: string;
|
|
27
|
+
readonly layer: PolicyNameLayer;
|
|
28
|
+
readonly guidance: string;
|
|
29
|
+
readonly source?: string;
|
|
30
|
+
}
|
|
31
|
+
/** The words and the data of the account of a table's retired entries — everything of the notice but its code, its audience, its minter and the
|
|
32
|
+
* session it is told to. */
|
|
33
|
+
export interface RetiredToolNameAccount {
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly detail: {
|
|
36
|
+
readonly layer: PolicyNameLayer;
|
|
37
|
+
readonly entries: ReadonlyArray<{
|
|
38
|
+
field: "deny" | "ask";
|
|
39
|
+
entry: string;
|
|
40
|
+
layer: PolicyNameLayer;
|
|
41
|
+
guidance: string;
|
|
42
|
+
source?: string;
|
|
43
|
+
}>;
|
|
44
|
+
readonly total: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** How many entries one account lists; the rest are counted in `detail.total`. Entries are names from the retirement table (a name outside it is
|
|
48
|
+
* not retired), so each is short; the bound keeps the coded detail inside the terminal's element budget. */
|
|
49
|
+
export declare const RETIRED_NOTICE_ENTRIES_SHOWN = 32;
|
|
50
|
+
/** The sentence and the detail of `entries` (unique by (field, entry, source) in scan order, at most {@link RETIRED_NOTICE_ENTRIES_SHOWN} in the
|
|
51
|
+
* detail, `total` counts every one). */
|
|
52
|
+
export declare function accountOfRetired(layer: PolicyNameLayer, entries: readonly RetiredPolicyEntry[]): RetiredToolNameAccount;
|
|
53
|
+
/**
|
|
54
|
+
* The notice for the entries of one restricting table that name a retired tool (code {@link POLICY_NAME_REFUSAL_CODE}, audience `user` — the person who wrote
|
|
55
|
+
* the entry believes it guards a tool): the table left them out, they reach no tool in any roster, and the run goes on. Minted here and nowhere else
|
|
56
|
+
* by the engine. `detail: { layer, entries: [{ field, entry, layer, guidance, source? }], total, sessionId }` — `entries` are unique by (field, entry,
|
|
57
|
+
* source) in scan order, at most {@link RETIRED_NOTICE_ENTRIES_SHOWN}, `total` counts every one. The entries that name a tool the engine renamed
|
|
58
|
+
* are not here: their names have a successor, the entry guarded it, and every table still refuses them.
|
|
59
|
+
*/
|
|
60
|
+
export declare function retiredToolNameNotice(layer: PolicyNameLayer, entries: readonly RetiredPolicyEntry[], sessionId: string): EngineNotice;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
|
|
2
|
+
const LAYER_WORD = {
|
|
3
|
+
caller_policy: "the run's tool policy",
|
|
4
|
+
session_rules: "the session's stored permission rules",
|
|
5
|
+
ancestor_session_rules: "the stored permission rules of an ancestor session",
|
|
6
|
+
task_selector: "the run's tool-name lists",
|
|
7
|
+
skill_table: "a Skill's disallowed-tools",
|
|
8
|
+
host_table: "a restricting tool table of the host",
|
|
9
|
+
};
|
|
10
|
+
export const RETIRED_NOTICE_ENTRIES_SHOWN = 32;
|
|
11
|
+
export function accountOfRetired(layer, entries) {
|
|
12
|
+
const unique = [];
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
for (const e of entries) {
|
|
15
|
+
const key = `${e.field}\u0000${e.entry}\u0000${e.source ?? ""}`;
|
|
16
|
+
if (seen.has(key))
|
|
17
|
+
continue;
|
|
18
|
+
seen.add(key);
|
|
19
|
+
unique.push(e);
|
|
20
|
+
}
|
|
21
|
+
const one = unique.length === 1;
|
|
22
|
+
const shown = unique.slice(0, 5).map((e) => `${e.field}-list entry "${e.entry}"${e.source !== undefined ? ` of ${e.source}` : ""}`);
|
|
23
|
+
const more = unique.length > shown.length ? ` and ${unique.length - shown.length} more` : "";
|
|
24
|
+
return {
|
|
25
|
+
message: `${LAYER_WORD[layer]} holds ${shown.join(", ")}${more}, ${one ? "a RETIRED tool name" : "RETIRED tool names"} that ${one ? "reaches" : "reach"} no tool in this run's roster — ${one ? "it guards" : "they guard"} nothing, and the run goes on without ${one ? "it" : "them"}. Remove ${one ? "the entry" : "the entries"} from the list.`,
|
|
26
|
+
detail: { layer, entries: unique.slice(0, RETIRED_NOTICE_ENTRIES_SHOWN).map((e) => ({ field: e.field, entry: e.entry, layer: e.layer, guidance: e.guidance, ...(e.source !== undefined ? { source: e.source } : {}) })), total: unique.length },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function retiredToolNameNotice(layer, entries, sessionId) {
|
|
30
|
+
const account = accountOfRetired(layer, entries);
|
|
31
|
+
return { code: POLICY_NAME_REFUSAL_CODE, message: account.message, detail: { ...account.detail, sessionId } };
|
|
32
|
+
}
|
package/dist/core/roles.d.ts
CHANGED
|
@@ -197,7 +197,9 @@ export interface ResolvedRole {
|
|
|
197
197
|
* the deployment's per-model context-window overlay.
|
|
198
198
|
*/
|
|
199
199
|
modelRef: ModelRef;
|
|
200
|
-
/** The effective thinking level: explicit `spec.thinking` wins, else the role's default
|
|
200
|
+
/** The effective thinking level, the one reading of the chain: explicit `spec.thinking` wins, else the role's default,
|
|
201
|
+
* else the resolved model's own `Model.defaultThinking` ({@link thinkingOf}); absent ⇒ no tier is named anywhere, so the
|
|
202
|
+
* request writes no thinking key and the provider's default governs. */
|
|
201
203
|
thinking?: ThinkingLevel;
|
|
202
204
|
/** The requested role's role-base statement, if it made one (independent of model fallback): its word (the host role
|
|
203
205
|
* and the catalog variant it selects) and its text (which replaces that base) — the second source of the role-base
|
package/dist/core/roles.js
CHANGED
|
@@ -376,6 +376,9 @@ export function unheldChainRefusal(chain, models, roles) {
|
|
|
376
376
|
export function roleFallbackChain(role) {
|
|
377
377
|
return FALLBACK[role];
|
|
378
378
|
}
|
|
379
|
+
function thinkingOf(explicit, role, model) {
|
|
380
|
+
return explicit ?? role ?? model.defaultThinking;
|
|
381
|
+
}
|
|
379
382
|
function chainHead(spec, deps) {
|
|
380
383
|
const start = spec.modelRole === undefined ? "default" : spec.modelRole;
|
|
381
384
|
assertKnownRole(start, "modelRole");
|
|
@@ -394,7 +397,7 @@ export function resolveTaskModel(spec, deps) {
|
|
|
394
397
|
return {
|
|
395
398
|
model,
|
|
396
399
|
modelRef: typeof written === "string" ? written : model,
|
|
397
|
-
thinking: spec.thinking
|
|
400
|
+
thinking: thinkingOf(spec.thinking, startParts.thinking, model),
|
|
398
401
|
promptRole: startParts.promptRole,
|
|
399
402
|
systemPrompt: startParts.systemPrompt,
|
|
400
403
|
};
|
|
@@ -409,7 +412,7 @@ export function resolveTaskModel(spec, deps) {
|
|
|
409
412
|
const model = fromParts ?? roleTierModel(role, deps.models);
|
|
410
413
|
if (model) {
|
|
411
414
|
const modelRef = fromParts !== undefined ? (parts.model ?? model) : (ROLE_TIER_DEFAULTS[role] ?? model);
|
|
412
|
-
return { model, modelRef, thinking: spec.thinking
|
|
415
|
+
return { model, modelRef, thinking: thinkingOf(spec.thinking, parts.thinking, model), promptRole: startPromptRole, systemPrompt: startSystemPrompt };
|
|
413
416
|
}
|
|
414
417
|
}
|
|
415
418
|
if (firstUnheld !== undefined)
|
|
@@ -81,7 +81,7 @@ async function compactOnSession(req, deps, session, resolved, named, legMods) {
|
|
|
81
81
|
compactStation.bind({ bus: legMods.bus, identity: undefined, report: legMods.report });
|
|
82
82
|
const overlay = contextOverlayFor(deps.contextSettings, resolved.modelRef, deps);
|
|
83
83
|
const activeTools = compactionActivationSnapshot(branch);
|
|
84
|
-
const thinking = resolved.thinking
|
|
84
|
+
const thinking = resolved.thinking;
|
|
85
85
|
const comp = await compactStation.compact({
|
|
86
86
|
session,
|
|
87
87
|
admitRows: rowSeat.admitRows,
|
|
@@ -154,6 +154,7 @@ function bindSessionFacade(legMods, input) {
|
|
|
154
154
|
sessionAppend: () => unavailable("session.append"),
|
|
155
155
|
sessionSend: () => unavailable("session.send"),
|
|
156
156
|
sessionCompact: () => unavailable("session.compact"),
|
|
157
|
+
promptSubmit: () => unavailable("prompt.submit"),
|
|
157
158
|
});
|
|
158
159
|
legMods.bindFacade({
|
|
159
160
|
...seats,
|
|
@@ -3009,7 +3009,7 @@ export interface RunnerSelfSeat {
|
|
|
3009
3009
|
*/
|
|
3010
3010
|
export type PrepareTaskFn = (spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals, runnerSelf?: RunnerSelfSeat, runIdSink?: {
|
|
3011
3011
|
runId?: string;
|
|
3012
|
-
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites, noticeDestinations?: import("../task-notification.js").NoticeDestinationJudge) => Promise<Prepared>;
|
|
3012
|
+
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites, noticeDestinations?: import("../task-notification.js").NoticeDestinationJudge, promptSubmitRef?: import("../input-author.js").PromptSubmitRef) => Promise<Prepared>;
|
|
3013
3013
|
/** One leg's view of the Runner's session write ledger (`session-write-ledger.ts`): `issue` starts a write of the leg (`what` = the
|
|
3014
3014
|
* entry type, for a report) or refuses it once `close` ran — the leg's hold ended; a write still in flight is reported when it settles. */
|
|
3015
3015
|
export interface LegWrites {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DENIED_BY_MAY_ECHO, screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
2
|
-
import { askFaceOf, classifyAsk, headlessApprovalRemedy } from "../ask-origin.js";
|
|
2
|
+
import { askFaceOf, classifyAsk, headlessApprovalRemedy, unresolvedAskDenialMessage, unresolvedAskQuestionOf } from "../ask-origin.js";
|
|
3
3
|
import { wireOf } from "../tool-name-readings.js";
|
|
4
4
|
import { isProtectedWrite } from "../tool-registry.js";
|
|
5
5
|
import { attestationOf, decisionText, foldHookAsk, licenseCovers } from "../tool-policy.js";
|
|
@@ -220,6 +220,12 @@ function withParkFailureCause(reason, parkFailed, nobodyJudged) {
|
|
|
220
220
|
const note = `${reason} — note: a durable approval park was attempted for this call and could not be minted (${inlineUntrusted(parkFailed, PARK_FAILURE_CAUSE_MAX)})`;
|
|
221
221
|
return nobodyJudged ? `${note}; with nobody to judge the call, that is why it stopped — it can be issued again once its park can be minted.` : `${note}.`;
|
|
222
222
|
}
|
|
223
|
+
function parkFailedBase(text, toolName, cause, parkFailed) {
|
|
224
|
+
if (!parkFailed || (cause !== "no_approver_wired" && cause !== "approver_unavailable"))
|
|
225
|
+
return text;
|
|
226
|
+
const question = unresolvedAskQuestionOf(cause, toolName, text);
|
|
227
|
+
return question === undefined ? text : unresolvedAskDenialMessage(cause, toolName, question, true);
|
|
228
|
+
}
|
|
223
229
|
export function takeInheritedScreen(pass, read) {
|
|
224
230
|
if (read?.floated !== undefined)
|
|
225
231
|
pass.hookAsk = pass.hookAsk !== undefined ? foldHookAsk(pass.hookAsk, read.floated) : read.floated;
|
|
@@ -308,7 +314,8 @@ export async function exitGate(pass) {
|
|
|
308
314
|
const bindingRefusal = attestationOf(pass.decision, { toolCallId, toolName })?.bindingRefusal;
|
|
309
315
|
const headless = bindingRefusal !== undefined ? undefined : remedySeat !== undefined ? headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat: remedySeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}) }) : undefined;
|
|
310
316
|
const remedy = headless?.sentence;
|
|
311
|
-
const
|
|
317
|
+
const base = parkFailedBase(decisionText(pass.decision) ?? `tool "${toolName}" denied by policy`, toolName, unresolvable, pass.parkFailed !== undefined);
|
|
318
|
+
const denyReason = withParkFailureCause(`${base}${remedy !== undefined ? ` — ${remedy}` : ""}`, pass.parkFailed, unresolvable !== undefined);
|
|
312
319
|
if (unresolvable !== undefined) {
|
|
313
320
|
const cause = unresolvable;
|
|
314
321
|
const noticeRemedy = bindingRefusal ?? remedy;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { brainToRuntime } from "../runtime.js";
|
|
2
|
-
import { catalogOfDeps, roleModelIfSet, unheldChainRefusal } from "../roles.js";
|
|
2
|
+
import { catalogOfDeps, resolveTaskModel, roleModelIfSet, unheldChainRefusal } from "../roles.js";
|
|
3
3
|
import { isAliasModelId, openAiCompatChatSeat } from "../memory-engine/distiller.js";
|
|
4
4
|
import { runMemoryConsolidationDriver } from "../memory-engine/consolidation-driver.js";
|
|
5
5
|
import { recommendationUnconsumed } from "../memory-engine/consolidation.js";
|
|
@@ -42,7 +42,7 @@ export function resolveMemoryConsolidationDriver(deps) {
|
|
|
42
42
|
const runtime = brainToRuntime(deps.brain);
|
|
43
43
|
chat = async (req) => {
|
|
44
44
|
const auth = await deps.getApiKeyAndHeaders?.(resolved);
|
|
45
|
-
const message = await runtime.completeSimple(resolved, { systemPrompt: req.system, messages: [{ role: "user", content: req.user, timestamp: Date.now() }] }, { temperature: req.temperature, maxTokens: req.maxTokens, apiKey: auth?.apiKey, headers: auth?.headers });
|
|
45
|
+
const message = await runtime.completeSimple(resolved, { systemPrompt: req.system, messages: [{ role: "user", content: req.user, timestamp: Date.now() }] }, { temperature: req.temperature, maxTokens: req.maxTokens, reasoning: resolveTaskModel({ model: resolved }, {}).thinking, apiKey: auth?.apiKey, headers: auth?.headers });
|
|
46
46
|
if (message.stopReason === "error" || message.stopReason === "aborted") {
|
|
47
47
|
throw new Error(message.errorMessage ?? `model completion ${message.stopReason}`);
|
|
48
48
|
}
|
|
@@ -494,7 +494,7 @@ export function prepareConfigDoors(input) {
|
|
|
494
494
|
unknownClasses: gateDecision.unknownClasses,
|
|
495
495
|
discardedEnvRaw: gateDecision.discardedEnvRaw,
|
|
496
496
|
});
|
|
497
|
-
const thinking =
|
|
497
|
+
const thinking = resolvedRole.thinking;
|
|
498
498
|
const compModel = resolveCompactionModel(spec, deps, "TaskSpec.compactionModel");
|
|
499
499
|
return {
|
|
500
500
|
spec,
|
|
@@ -77,7 +77,7 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
77
77
|
/** borrowed-mutable — the lane's late-bound facts; the SendMessage mount hands the SAME object to its peer seats (identity is
|
|
78
78
|
* the contract: the wiring station fills `askEffective` later). Not written here. */
|
|
79
79
|
peerLaneRefs: PeerLaneRefs;
|
|
80
|
-
/** borrowed-readonly — the session-box drain's mount judgment (the `ReadInbox` door: a
|
|
80
|
+
/** borrowed-readonly — the session-box drain's mount judgment (with the principal inbox's consumer, the `ReadInbox` door: a drain bound on this leg). */ sessionBox?: import("../task-notification.js").SessionBoxBinding | undefined;
|
|
81
81
|
/** borrowed-mutable — the run's roster builder (`Prepared.tools` is its read face; the writer table is on that field).
|
|
82
82
|
* Writers here: the seven mounts (TaskStop, SendMessage, AgentTranscript, ListAgents, Monitor, the worktree
|
|
83
83
|
* pair, the offload reader), every one a `mount`. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAgentTranscriptTool, AGENT_TRANSCRIPT_TOOL_NAME } from "../../agents/agent-transcript-tool.js";
|
|
2
2
|
import { createSendMessageTool, SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
3
|
-
import { listAgentsMountable, mountListAgents,
|
|
3
|
+
import { listAgentsMountable, mountListAgents, peerDrainLanesOf, peerLaneSendMessageSeats } from "../../agents/peer-session-drain.js";
|
|
4
4
|
import { resolvePeerLaneConfig } from "../../agents/peer-admission.js";
|
|
5
5
|
import { createReadInboxTool, READ_INBOX_TOOL_NAME } from "../../agents/read-inbox-tool.js";
|
|
6
6
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
@@ -81,8 +81,10 @@ export function prepareDelegationSurface(input) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const drainLanes = internals?.onTaskNotification !== undefined ? peerDrainLanesOf(deps, { sessionBox, hostTaskId, sessionId }) : undefined;
|
|
85
|
+
if (drainLanes !== undefined && leaves({ name: READ_INBOX_TOOL_NAME }) && !(spec.tools ?? []).some((t) => t.name === READ_INBOX_TOOL_NAME)) {
|
|
86
|
+
const covers = drainLanes.principalInbox === undefined ? {} : { coversPrincipalInbox: drainLanes.principalInbox === "pullOnly" ? "pullOnly" : true };
|
|
87
|
+
roster.mount(firstPartyOffload(createReadInboxTool({ pull: () => peerLaneRefs.pull, ...covers })), { source: "builtin", mountedBy: "peerLane" });
|
|
86
88
|
}
|
|
87
89
|
const listAgents = (peerLaneActive || delegationSurfaceActive) && peerSendMessageBuiltIn && listAgentsMountable({ leaves, specTools: spec.tools ?? [] }) ? mountListAgents({ ...(peerLaneActive ? { peerDirectory: deps.peerDirectory } : {}), freshWindowMs: resolvePeerLaneConfig(deps.peerLane, deps.onNotice).listingFreshWindowMs, sessionId, scope: taskScope, hostTaskId, ...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}), ...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}), registry: defaultTaskRegistry, ...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}), ...(sendMessageTier !== undefined ? { continuationTier: sendMessageTier } : {}), ...(checkpointSeat !== undefined ? { readSeats: { checkpointSeat } } : {}), specTools: spec.tools ?? [] }) : undefined;
|
|
88
90
|
if (listAgents !== undefined)
|
|
@@ -9,6 +9,7 @@ import { declaresSubagentPlacement } from "../session.js";
|
|
|
9
9
|
import { performsIo } from "../remote-env.js";
|
|
10
10
|
import { durableMandateSourceOf } from "../tool-policy.js";
|
|
11
11
|
import { chainAnchorRecords } from "./child-tree.js";
|
|
12
|
+
import { defaultTaskRegistry } from "../task-registry.js";
|
|
12
13
|
import { deliverEngineNotice } from "../types.js";
|
|
13
14
|
import { PermissionModeController, autoModeFaceOf, modeRequestAfterResume } from "../mode-policy.js";
|
|
14
15
|
import { SessionModeSeats } from "./session-mode-seats.js";
|
|
@@ -250,6 +251,7 @@ export function prepareInheritedGate(input) {
|
|
|
250
251
|
...(spec.durableApproval !== undefined ? { durableApprovalForChildren: { ...spec.durableApproval } } : {}),
|
|
251
252
|
...(input.checkpointSeat !== undefined ? { checkpointStoreForChildren: input.checkpointSeat } : {}),
|
|
252
253
|
checkpointScopeForChildren: input.checkpointScope,
|
|
254
|
+
taskRegistry: defaultTaskRegistry,
|
|
253
255
|
taskId: hostTaskId,
|
|
254
256
|
...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}),
|
|
255
257
|
...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}),
|
|
@@ -1,21 +1,38 @@
|
|
|
1
|
-
import { isAbsolute, sep } from "node:path";
|
|
1
|
+
import { isAbsolute, resolve, sep } from "node:path";
|
|
2
2
|
import { deliverEngineNotice } from "../types.js";
|
|
3
3
|
import { admitMemoryScopes } from "../memory-admission.js";
|
|
4
4
|
import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir, deriveRepoKey, deriveRepoMemoryDir, effectiveControlRootOf, isContainedIn, lookupProjectIdHint, recordProjectIdHint, resolveMemoryEngineRoot, transferMemoryAnnouncements } from "../memory-engine/layout.js";
|
|
5
5
|
import { derivePersonalControlDir, derivePersonalMemoryDir, directoryPinOf, memoryPlaneStore, mergeHarvestReports, mergeInjections, needsDualRoots, parsedProjectPlane, scopePlanesOf } from "../memory-engine/dual-root.js";
|
|
6
6
|
import { memoryProjectScopeAbsentNotice, normalizeMemorySpec } from "../memory.js";
|
|
7
|
-
import { deriveSupersededSet, fileGovernanceStore } from "../memory-engine/consolidation.js";
|
|
7
|
+
import { deriveSupersededSet, fileGovernanceStore, fileSessionCaptureRecordStore, governanceStoreIsFileOver } from "../memory-engine/consolidation.js";
|
|
8
8
|
import { shadowNamesOf } from "../memory-engine/shadowing.js";
|
|
9
9
|
import { mintSystemReminder } from "../reminder-mint.js";
|
|
10
10
|
import { MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA, MEMORY_ANNOUNCEMENT_READONLY_CODA, MEMORY_CAPTURE_OPTOUT_NOTICE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MemoryEngine, entryFileHeadCarriesOrigin, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, memoryConsolidationRecommendedNotice, memoryHarvestConflictNotice, memoryHarvestQuarantinedNotice, memoryHarvestRefusedNotice, memoryHoldNotices, memoryRecallDisciplineSegment, memoryRestoreWithheldNotice, memorySessionPollutedNotice, memoryUnavailableNotice, pollutionContainmentCounts, } from "../memory-engine/engine.js";
|
|
11
11
|
import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersistedError } from "./memory-capture-optout.js";
|
|
12
|
-
import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
|
|
13
12
|
import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
|
|
14
13
|
import { createMemoryEngineTools } from "../memory-engine/tools.js";
|
|
15
14
|
import { assertScopeContractPlacement, parseScopeKey } from "../memory-engine/scope-contract.js";
|
|
16
15
|
import { writableRootOf } from "../memory-engine/types.js";
|
|
17
16
|
import { catalogText } from "../../prompt-assembly/catalog/index.js";
|
|
18
17
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
18
|
+
function heldCapturePlane(engine, backend) {
|
|
19
|
+
const carrier = backend.governance;
|
|
20
|
+
return { engine, fileCarried: carrier === undefined || governanceStoreIsFileOver(carrier, engine.controlPlaneRoot) };
|
|
21
|
+
}
|
|
22
|
+
async function readAncestorCaptureOptOut(ancestorDir, ancestorId, held, hostStore) {
|
|
23
|
+
const plane = held.find((p) => resolve(p.engine.controlPlaneRoot) === resolve(ancestorDir));
|
|
24
|
+
if (plane !== undefined) {
|
|
25
|
+
const read = await plane.engine.sessionCaptureOptOutOrFault(ancestorId);
|
|
26
|
+
if (read.record === undefined && read.fault)
|
|
27
|
+
throw new Error(`the capture opt-out record store of the plane at ${ancestorDir} is unreadable`);
|
|
28
|
+
return read.record;
|
|
29
|
+
}
|
|
30
|
+
if (hostStore !== undefined)
|
|
31
|
+
return await hostStore({ controlDir: ancestorDir }).read(ancestorId);
|
|
32
|
+
if (held.length > 0 && held.every((p) => p.fileCarried))
|
|
33
|
+
return await fileSessionCaptureRecordStore(ancestorDir).read(ancestorId);
|
|
34
|
+
throw new Error(`the capture opt-out record of a spawning session is kept in the control plane at ${ancestorDir}, which no carrier this run holds can read`);
|
|
35
|
+
}
|
|
19
36
|
let undeclaredCapturePostureAnnounced = false;
|
|
20
37
|
export async function prepareMemory(input) {
|
|
21
38
|
const { spec, deps, sessionId, taskRootPath, admissionCtx } = input;
|
|
@@ -175,6 +192,7 @@ export async function prepareMemory(input) {
|
|
|
175
192
|
};
|
|
176
193
|
const onEngineIncident = (err) => deps.onError?.(err, { phase: "memory", sessionId });
|
|
177
194
|
const adoptionRestricted = input.memoryPersistenceDeclared === false;
|
|
195
|
+
let capturePlanes = [];
|
|
178
196
|
const armCaptureOptOut = async (eng) => {
|
|
179
197
|
const standingRead = await eng.sessionCaptureOptOutOrFault(sessionId);
|
|
180
198
|
if (standingRead.fault) {
|
|
@@ -209,7 +227,7 @@ export async function prepareMemory(input) {
|
|
|
209
227
|
anyFault = true;
|
|
210
228
|
if (ancestorDir !== undefined && ancestorDir !== eng.controlPlaneRoot) {
|
|
211
229
|
try {
|
|
212
|
-
const crossPlane =
|
|
230
|
+
const crossPlane = await readAncestorCaptureOptOut(ancestorDir, ancestorId, capturePlanes, deps.memoryCaptureRecordStore);
|
|
213
231
|
if (crossPlane !== undefined) {
|
|
214
232
|
found = true;
|
|
215
233
|
break;
|
|
@@ -314,7 +332,7 @@ export async function prepareMemory(input) {
|
|
|
314
332
|
let crossPlane;
|
|
315
333
|
if (ancestorDir !== undefined && ancestorDir !== writeEngine.controlPlaneRoot) {
|
|
316
334
|
try {
|
|
317
|
-
crossPlane =
|
|
335
|
+
crossPlane = await readAncestorCaptureOptOut(ancestorDir, ancestorId, capturePlanes, deps.memoryCaptureRecordStore);
|
|
318
336
|
}
|
|
319
337
|
catch {
|
|
320
338
|
return { admitNothing: { reason: `harvest admitted nothing: a spawning session's capture record store is unreadable — the floor state is indeterminate and commits are suppressed fail-closed` } };
|
|
@@ -363,6 +381,7 @@ export async function prepareMemory(input) {
|
|
|
363
381
|
const personal = createPersonalEngine(personalBackendChosen);
|
|
364
382
|
const personalEngine = personal.engine;
|
|
365
383
|
const p = planes;
|
|
384
|
+
capturePlanes = [heldCapturePlane(projectEngine, backend), heldCapturePlane(personalEngine, personal.backend)];
|
|
366
385
|
await armCaptureOptOut(p.writePlane === "personal" ? personalEngine : projectEngine);
|
|
367
386
|
const writeIsPersonal = p.writePlane === "personal";
|
|
368
387
|
const mounts = [
|
|
@@ -439,6 +458,7 @@ export async function prepareMemory(input) {
|
|
|
439
458
|
else if (personalOnly) {
|
|
440
459
|
const personal = createPersonalEngine(memoryPlaneStore("personal", backend, engineRoot));
|
|
441
460
|
const personalEngine = personal.engine;
|
|
461
|
+
capturePlanes = [heldCapturePlane(personalEngine, personal.backend)];
|
|
442
462
|
await armCaptureOptOut(personalEngine);
|
|
443
463
|
const handle = await personalEngine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
|
|
444
464
|
openedLegs.push(() => personalEngine.endSessionLeg(handle, sessionId));
|
|
@@ -469,6 +489,7 @@ export async function prepareMemory(input) {
|
|
|
469
489
|
...captureStoreOpt(memoryDir, backend, projectControlDir), ...incarnationOpt,
|
|
470
490
|
...(input.deps.memoryConsolidation !== undefined ? { consolidation: input.deps.memoryConsolidation } : {}),
|
|
471
491
|
});
|
|
492
|
+
capturePlanes = [heldCapturePlane(engine, backend)];
|
|
472
493
|
await armCaptureOptOut(engine);
|
|
473
494
|
const handle = await engine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
|
|
474
495
|
openedLegs.push(() => engine.endSessionLeg(handle, sessionId));
|
|
@@ -64,6 +64,8 @@ export interface PrepareParkAskInput {
|
|
|
64
64
|
toolRosterDeltas: ToolRosterDeltaSeat;
|
|
65
65
|
/** borrowed-readonly — the wiring-manifest phase's park predicate (`parkLane.effective`): arms `suspendAsk`. */
|
|
66
66
|
parkLaneArmed: boolean;
|
|
67
|
+
/** borrowed-readonly — the question-face phase's `durableQuestionFace`: THE one judge of whether a question may park on this leg. */
|
|
68
|
+
durableQuestionFace: boolean;
|
|
67
69
|
/** borrowed-readonly — the question-face phase's routability predicate (the mounted question tool is the engine's own,
|
|
68
70
|
* resolved against the LIVE roster per call). */
|
|
69
71
|
contentAskRoutable: (toolCallId: string) => boolean;
|