@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
|
@@ -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;
|
|
@@ -277,8 +295,8 @@ export async function prepareMemory(input) {
|
|
|
277
295
|
...planeScopes(planes.personal, planes.writePlane === "personal" ? memorySpec.writeScope : null),
|
|
278
296
|
]
|
|
279
297
|
: planeScopes(memorySpec.scopes, memorySpec.writeScope)).map((scope) => ({ scope, origin: originOf(scope) }));
|
|
280
|
-
const pollutedOpts = (engine) => {
|
|
281
|
-
const rec = engine.sessionPollution(sessionId);
|
|
298
|
+
const pollutedOpts = async (engine) => {
|
|
299
|
+
const rec = await engine.sessionPollution(sessionId);
|
|
282
300
|
return rec !== undefined ? { polluted: { reason: rec.reason, ...(rec.cause !== undefined ? { cause: rec.cause } : {}) } } : {};
|
|
283
301
|
};
|
|
284
302
|
let writeEngine;
|
|
@@ -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 = [
|
|
@@ -421,7 +440,7 @@ export async function prepareMemory(input) {
|
|
|
421
440
|
harvestBoth = async (phase) => {
|
|
422
441
|
const writeFirst = writeIsPersonal ? [personalEngine, personalHandle] : [projectEngine, projectHandle];
|
|
423
442
|
const readOther = writeIsPersonal ? [projectEngine, projectHandle] : [personalEngine, personalHandle];
|
|
424
|
-
const writeReport = await writeFirst[0].harvest(writeFirst[1], { ...pollutedOpts(writeFirst[0]), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
443
|
+
const writeReport = await writeFirst[0].harvest(writeFirst[1], { ...(await pollutedOpts(writeFirst[0])), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
425
444
|
let readReport;
|
|
426
445
|
let readFailure;
|
|
427
446
|
try {
|
|
@@ -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));
|
|
@@ -447,7 +467,7 @@ export async function prepareMemory(input) {
|
|
|
447
467
|
writeEngine = personalEngine;
|
|
448
468
|
writeHandle = handle;
|
|
449
469
|
injectFn = () => personalEngine.inject(handle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark });
|
|
450
|
-
harvestBoth = async (phase) => personalEngine.harvest(handle, { ...pollutedOpts(personalEngine), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
470
|
+
harvestBoth = async (phase) => personalEngine.harvest(handle, { ...(await pollutedOpts(personalEngine)), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
451
471
|
toolPlanes = [
|
|
452
472
|
{
|
|
453
473
|
backend: retrievalBackend(personal.backend, adoptionRestricted || captureOptedOut || captureIndeterminate || memorySpec.writeScope === null),
|
|
@@ -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));
|
|
@@ -477,7 +498,7 @@ export async function prepareMemory(input) {
|
|
|
477
498
|
writeEngine = engine;
|
|
478
499
|
writeHandle = handle;
|
|
479
500
|
injectFn = () => engine.inject(handle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark });
|
|
480
|
-
harvestBoth = async (phase) => engine.harvest(handle, { ...pollutedOpts(engine), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
501
|
+
harvestBoth = async (phase) => engine.harvest(handle, { ...(await pollutedOpts(engine)), sessionId, ...(await admitNothingOptsNow()), phase });
|
|
481
502
|
toolPlanes = [
|
|
482
503
|
{
|
|
483
504
|
backend: retrievalBackend(backend, adoptionRestricted || captureOptedOut || captureIndeterminate || memorySpec.writeScope === null),
|
|
@@ -546,13 +567,13 @@ export async function prepareMemory(input) {
|
|
|
546
567
|
return writeEngine.gateWrite(writeHandle, w.key, w.content);
|
|
547
568
|
};
|
|
548
569
|
let pollutionAnnounced = false;
|
|
549
|
-
const announceHarvestContainment = (report) => {
|
|
570
|
+
const announceHarvestContainment = async (report) => {
|
|
550
571
|
const { count, moved, escalated } = pollutionContainmentCounts(report);
|
|
551
572
|
const indexOnly = input.memoryProvenance !== "off" && count === 0 && report.containment?.indexRolledBack === true;
|
|
552
573
|
if (count > 0 || indexOnly) {
|
|
553
574
|
let reason;
|
|
554
575
|
try {
|
|
555
|
-
reason = writeEngine.sessionPollution(sessionId)?.reason;
|
|
576
|
+
reason = (await writeEngine.sessionPollution(sessionId))?.reason;
|
|
556
577
|
}
|
|
557
578
|
catch {
|
|
558
579
|
}
|
|
@@ -580,7 +601,7 @@ export async function prepareMemory(input) {
|
|
|
580
601
|
const named = report.reportId !== undefined ? `${report.incident.kind}, report ${report.reportId}` : report.incident.kind;
|
|
581
602
|
deps.onError?.(new Error(`memory harvest refused (${named}): ${report.incident.detail}`), { phase: "memory", sessionId });
|
|
582
603
|
}
|
|
583
|
-
announceHarvestContainment(report);
|
|
604
|
+
await announceHarvestContainment(report);
|
|
584
605
|
try {
|
|
585
606
|
deps.onMemoryHarvestReport?.(report, { sessionId, phase });
|
|
586
607
|
}
|
|
@@ -698,7 +719,7 @@ export async function prepareMemory(input) {
|
|
|
698
719
|
execIsExternalContent: memorySpec.execIsExternalContent === true,
|
|
699
720
|
},
|
|
700
721
|
...(input.memoryProvenance !== "off"
|
|
701
|
-
? { settlement: { governance: writeEngine.governance,
|
|
722
|
+
? { settlement: { governance: writeEngine.governance, sessionId, provenance: "carry" } }
|
|
702
723
|
: {}),
|
|
703
724
|
...(input.memoryProvenance !== "off"
|
|
704
725
|
? {
|
|
@@ -18,7 +18,8 @@ import { emitTrace } from "../trace.js";
|
|
|
18
18
|
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
19
19
|
import { withArgsBinding } from "../skill-grant-binding.js";
|
|
20
20
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
21
|
-
import { delegationPoolReading, policyNameRefusal
|
|
21
|
+
import { delegationPoolReading, policyNameRefusal } from "./sub-agent-deny-lists.js";
|
|
22
|
+
import { POLICY_NAME_REFUSAL_CODE, retiredToolNameNotice } from "../retired-tool-name-account.js";
|
|
22
23
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
23
24
|
import { autoStrippedRule, cardDisclosureOf, classifiesAllShell, rootFacingToolNames } from "../allow-entry.js";
|
|
24
25
|
import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember, INHERITED_STATION_FACTS } from "../ask-origin.js";
|
|
@@ -48,6 +49,7 @@ export async function preparePolicyChain(input) {
|
|
|
48
49
|
const policy = lockedPreflight.toolPolicy;
|
|
49
50
|
const auditPolicyNames = (auditee, layer = "caller_policy") => {
|
|
50
51
|
const refused = [];
|
|
52
|
+
const retiredLeftOut = [];
|
|
51
53
|
const nameGroups = toolPolicyNameSets(auditee);
|
|
52
54
|
if (nameGroups.length > 0) {
|
|
53
55
|
const known = mountedToolNames(tools);
|
|
@@ -61,8 +63,9 @@ export async function preparePolicyChain(input) {
|
|
|
61
63
|
for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
|
|
62
64
|
for (const n of list ?? []) {
|
|
63
65
|
const verdict = judgeRuleToolName(n, known, kind);
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
+
const asksTwin = verdict.kind === "current" || (verdict.kind === "retired" && verdict.currentName === undefined && kind !== "allow");
|
|
67
|
+
const twin = asksTwin && layer !== "ancestor_session_rules" ? nearMissSpellingOf(n, rootFacing) : undefined;
|
|
68
|
+
const stale = twin !== undefined ? { kind: "case_twin", twin, carrier: known.has(twin) || callerNames.has(twin) ? "run" : pool.names.has(twin) ? "pool" : "catalog" } : verdict.kind !== "current" ? verdict : undefined;
|
|
66
69
|
if (stale?.kind === "retired" && kind === "allow") {
|
|
67
70
|
unmatched.add(`"${n}" (allow — a retired tool name: ${stale.guidance})`);
|
|
68
71
|
continue;
|
|
@@ -71,6 +74,10 @@ export async function preparePolicyChain(input) {
|
|
|
71
74
|
unmatched.add(`"${n}" (allow — ${stale.guidance}${stale.currentName !== undefined ? ` Write "${stale.currentName}".` : ""})`);
|
|
72
75
|
continue;
|
|
73
76
|
}
|
|
77
|
+
if (stale?.kind === "retired" && stale.currentName === undefined && kind !== "allow") {
|
|
78
|
+
retiredLeftOut.push({ field: kind, entry: n, layer, guidance: stale.guidance });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
74
81
|
if (stale !== undefined) {
|
|
75
82
|
const entry = `tool policy ${kind}-list entry "${n}"`;
|
|
76
83
|
let message;
|
|
@@ -105,6 +112,8 @@ export async function preparePolicyChain(input) {
|
|
|
105
112
|
}
|
|
106
113
|
if (refused[0] !== undefined)
|
|
107
114
|
throw policyNameRefusal(refused[0], refused.slice(1));
|
|
115
|
+
if (retiredLeftOut.length > 0)
|
|
116
|
+
deliverEngineNotice(deps.onNotice, retiredToolNameNotice(layer, retiredLeftOut, sessionId));
|
|
108
117
|
const dedupeKey = [...unmatched].sort().join("|");
|
|
109
118
|
const advised = advisedPolicyNames.get(deps) ?? new Set();
|
|
110
119
|
if (unmatched.size > 0 && !advised.has(dedupeKey)) {
|
|
@@ -5,7 +5,7 @@ import { hasConversationContent } from "../session.js";
|
|
|
5
5
|
import { createSharedMemoryTools } from "../shared-memory/tools.js";
|
|
6
6
|
import { SHARED_MEMORY_TOOL_NAMES } from "../shared-memory/types.js";
|
|
7
7
|
import { defineTool } from "../tools.js";
|
|
8
|
-
import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader } from "../skill-grant.js";
|
|
8
|
+
import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader, tellRetiredSkillDeny } from "../skill-grant.js";
|
|
9
9
|
import { allowedToolsNotGrantedNotice, classifiesAllShell, seedAllowEntryTables } from "../allow-entry.js";
|
|
10
10
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
11
11
|
import { announceMemoryNotMounted } from "./announce-once-ledger.js";
|
|
@@ -102,7 +102,7 @@ export async function prepareProjectContext(input) {
|
|
|
102
102
|
const mounted = () => mountedToolNames(tools);
|
|
103
103
|
skillGrants.bindMountedNames(mounted);
|
|
104
104
|
skillGrants.bindSkills(skillSpecs, SKILL_TOOL_NAME);
|
|
105
|
-
const inert = seedAllowEntryTables(allowedToolTables, { skillInert: seedSkillGrants(skillGrants, { skills: skillSpecs, userInvokedSkills: spec.userInvokedSkills, inherited: [...(internals?.inheritedSkillGrants ?? []), ...frozenSkillGrants] }), inherited: internals?.inheritedAllowedTools, request: allowedTools, deployment: deps.allowedTools }, mounted());
|
|
105
|
+
const inert = seedAllowEntryTables(allowedToolTables, { skillInert: tellRetiredSkillDeny(deps.onNotice, seedSkillGrants(skillGrants, { skills: skillSpecs, userInvokedSkills: spec.userInvokedSkills, inherited: [...(internals?.inheritedSkillGrants ?? []), ...frozenSkillGrants] }), sessionId, mounted()), inherited: internals?.inheritedAllowedTools, request: allowedTools, deployment: deps.allowedTools }, mounted());
|
|
106
106
|
if (inert.length > 0)
|
|
107
107
|
deliverEngineNotice(deps.onNotice, allowedToolsNotGrantedNotice(inert, sessionId));
|
|
108
108
|
if (skillSpecs.length > 0) {
|
|
@@ -8,10 +8,12 @@ export { DEFAULT_IRREVERSIBLE_SCOPE, checkpointScopeOf, placementValueOrAbsent }
|
|
|
8
8
|
export { mcpManifestEntries } from "./prepare-wiring-manifest.js";
|
|
9
9
|
export { __resetMaterializeEnvAnnouncements } from "./prepare-tool-disclosure-mount.js";
|
|
10
10
|
export { fileHistoryFilesystemIdentity, resolveFileHistoryScope } from "./prepare-file-history.js";
|
|
11
|
+
import { type NoticeDestinationJudge } from "../task-notification.js";
|
|
11
12
|
import type { RunnerSelfSeat } from "./contracts.js";
|
|
12
13
|
import type { Prepared, PrepareResume, PrepareTaskFn, RunInternals } from "./contracts.js";
|
|
13
14
|
export type { FileHistoryBoundarySeat, InheritedGate, Prepared, PreparedMicroCompact, PrepareResume, ResolvedWorkspace, RunInternals, UsageGovernance } from "./contracts.js";
|
|
14
15
|
import type { ExecutionEnv } from "../../internal/harness.js";
|
|
16
|
+
import type { PromptSubmitRef } from "../input-author.js";
|
|
15
17
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
16
18
|
/** Test seam (mirrors `__resetMaterializeEnvAnnouncements`): never called by production code.
|
|
17
19
|
* Re-arms BOTH arms (a WeakMap has no clear — it is re-minted). Deliberately UNLIKE the read-face
|
|
@@ -118,7 +120,13 @@ runIdSink?: {
|
|
|
118
120
|
/** The Runner's lock on this leg's session, handed only when the spec named none: taken the moment the store mints the id. */
|
|
119
121
|
holdSessionLock?: (sessionId: string) => Promise<void>,
|
|
120
122
|
/** This leg's view of the Runner's session write ledger (`session-write-ledger.ts`): the acquired storage writes through it. */
|
|
121
|
-
legWrites?: LegWrites
|
|
123
|
+
legWrites?: LegWrites,
|
|
124
|
+
/** The Runner's judge of where this leg's user-face notices go when they are routed to its tree's root (its in-process
|
|
125
|
+
* notification store's): absent when prepareTask runs outside a Runner, and then every notice is delivered. */
|
|
126
|
+
noticeDestinations?: NoticeDestinationJudge,
|
|
127
|
+
/** `$.prompt.submit`'s binding — the stream that runs this leg filled it with its own steer relay; the leg's facade entry reads
|
|
128
|
+
* it at call time. Absent when prepareTask runs outside a Runner's stream, and then every such call is dropped. */
|
|
129
|
+
promptSubmitRef?: PromptSubmitRef): Promise<Prepared>;
|
|
122
130
|
/** The entry IS the contract the notification lane's seat names ({@link PrepareTaskFn}, contracts.ts):
|
|
123
131
|
* a signature change reds HERE, at the declaration, as `false` failing the `true` bound. IDENTITY, not assignability:
|
|
124
132
|
* the parameter tuple (arity, optionality, each type) and the return type must be the SAME type in both directions —
|
|
@@ -108,6 +108,7 @@ import { createRowSeat, createSessionAppendEntry, promptCountOf } from "../mods/
|
|
|
108
108
|
import { createReceiveSeat } from "../mods/session-receive.js";
|
|
109
109
|
import { createCompactStation, createSessionCompactEntry } from "../mods/session-compact.js";
|
|
110
110
|
import { createSessionSendEntry, createSessionSendStation } from "../mods/session-send.js";
|
|
111
|
+
import { createPromptSubmitEntry } from "../mods/prompt-submit.js";
|
|
111
112
|
import { createAgentSpawnEntry, createAgentStations } from "../mods/agent-stations.js";
|
|
112
113
|
import { createMcpRequestMetaSeat } from "../mcp-call-meta.js";
|
|
113
114
|
import { deliverEngineNotice } from "../types.js";
|
|
@@ -304,7 +305,7 @@ function refuseRegistryScopeMismatch(spec, internals) {
|
|
|
304
305
|
function validateInputFaultNotice(onError, sessionId) {
|
|
305
306
|
return ({ toolName, toolCallId, error }) => onError?.(new Error(`tool input pre-validation (validateInput) threw for ${toolName} (call ${toolCallId}) — read as no verdict; the call proceeded to the gate: ${thrownText(error)}`), { phase: "hook", sessionId });
|
|
306
307
|
}
|
|
307
|
-
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites) {
|
|
308
|
+
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites, noticeDestinations, promptSubmitRef) {
|
|
308
309
|
const runId = uuidv7();
|
|
309
310
|
if (runIdSink !== undefined)
|
|
310
311
|
runIdSink.runId = runId;
|
|
@@ -368,7 +369,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
368
369
|
internals = restoreRowTaskId(internals, resume?.seed.rowTaskId);
|
|
369
370
|
const hostTaskId = legTaskIdOf(spec, internals, sessionId);
|
|
370
371
|
const askSource = mintAskSourceIdentity({ principal: spec.principal, sessionId, taskId: hostTaskId, isDelegatedChild: delegation.isDelegatedChild, internals });
|
|
371
|
-
const
|
|
372
|
+
const noticeRoute = noticeAddressOf(askSource, internals);
|
|
372
373
|
announceRoleSeatsDefaulted({ spec, deps, onceLedger, rootLeg: !delegation.isDelegatedChild, sessionId, runId });
|
|
373
374
|
const placementRootResolved = (internals = restorePlacementRoot(internals, resume?.seed.placementRootSessionId))?.placementRoot ?? internals?.rootSessionId ?? sessionId;
|
|
374
375
|
const compositionLegResolved = compositionLegRecord(internals?.compositionLeg ?? resume?.seed.compositionLeg);
|
|
@@ -728,7 +729,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
728
729
|
const { memoryBlock: memoryBlockWithProject, instructionSources, projectMemoryFact, projectInstructionContent, skillSpecs, skillSeatOf, skillsListing, sharedMemoryPairMounted, memoryEnginePairMounted } = projectContext;
|
|
729
730
|
const { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, dateAnchor, gitStatusRef } = await preparePromptInputs({ modBus: legMods.bus, spec, deps, contextOverlay: legContextOverlay(), failClosedReason: selfOrchestrationFailClosedReason(spec, deps), lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace: resolvedWriteFace?.inForce(), toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, taskRole: promptHost.role, mcp, roster, model, externalContentTargetActive, resume, handsEnabled, readFloor: runFloor, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical: (await readRoots.ready().then(readRoots)).filter((r) => !additionalRootsCanonical.includes(r)), sessionId, session, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}) });
|
|
730
731
|
const advisor = await prepareAdvisor({ spec, advisorTool: doors.advisorTool, deps, model, roster, selector: toolFaceSnapshot.selector, session, onceLedger, rootLeg: !delegation.isDelegatedChild, sessionId, runId, sideCallBookRef, lastSentRequest: () => lastBrainContextRef.current, brainCallGuardrailMs });
|
|
731
|
-
judgeRunToolLists({ spec, tools: roster.tools, declaredPeers: { mcp: lockedPreflight.mcp, a2a: a2a.statuses }, own: { allow: toolFaceLists.allow, exclude: toolFaceLists.exclude }, selector: toolFaceSnapshot.selector, legs: toolLegs, judgedUpstream: toolListsJudged !== undefined, toldUpstream: internals?.ownToolLists !== undefined && ownToolLists !== undefined && toolCeiling !== undefined, ownBy: ownToolLists, onceLedger, sessionId });
|
|
732
|
+
judgeRunToolLists({ spec, tools: roster.tools, declaredPeers: { mcp: lockedPreflight.mcp, a2a: a2a.statuses }, own: { allow: toolFaceLists.allow, exclude: toolFaceLists.exclude }, selector: toolFaceSnapshot.selector, legs: toolLegs, judgedUpstream: toolListsJudged !== undefined, toldUpstream: internals?.ownToolLists !== undefined && ownToolLists !== undefined && toolCeiling !== undefined, ownBy: ownToolLists, onceLedger, onNotice: deps.onNotice, sessionId });
|
|
732
733
|
const { deferred, memoryBlock, toolSearch: toolSearchPolicy } = prepareDeferClassify({ spec, deps, roster, toolFaceSnapshot, handsEnabled, fullShellReachable, promptTraits, model, mcp, a2a, sharedMemoryPairMounted, memoryEnginePairMounted, memoryBlock: memoryBlockWithProject, memoryRecallSegment, onceLedger, sessionId });
|
|
733
734
|
prepareMemoryEngineSession({ memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef });
|
|
734
735
|
const { systemPromptSeat, renderWithDate, systemBlocks, promptManifest, promptIdentity, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef } = await preparePromptAssembly({ session, deps, internals, resume, sugar: sugar.overlays, host: { ...(sugar.hostRole !== undefined ? { role: sugar.hostRole } : {}), ...(promptHost.form !== undefined ? { form: promptHost.form } : {}) }, binding: promptBinding, modBus: legMods.bus, signal: abortController.signal, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, tools, model, sessionId, onceLedger });
|
|
@@ -874,7 +875,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
874
875
|
const { suspendForResource, suspendForPlatformLimit, suspendForReview } = prepareBoundaryParks({ saga, spec, checkpointStore, checkpointScope, abortController, harness, session, sessions, sessionId, askSource, deps, priorLedger, maxSlices, maxSuspends, resourceTotal, priorSuspendCount, suspendChainBase, humanReviewRef, liveSpendRef, now, pausedRef, remoteEnvFailures, resourceSuspendEligible, durableSuspendInfraReady, suspendTargetGap });
|
|
875
876
|
const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, askSource, checkpointStore, checkpointScope, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots: legExemptRoots, offloadStore, suspendTargetGap, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef });
|
|
876
877
|
const seatInputsFor = skillGateWiring({ tools, skillToolName: SKILL_TOOL_NAME, seatOf: skillSeatOf, mode: () => permissionMode.current, lane: skillGrantLane, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.skill_allowed", version: 1, taskId: hostTaskId, ...info, entries: [...info.entries], ts: Date.now() })), allowEntries: { deploymentAllows: { ...allowEntryLanes.deployment, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "deployment", ...info, entries: [...info.entries], ts: Date.now() })) }, requestAllows: { ...allowEntryLanes.request, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "request", ...info, entries: [...info.entries], ts: Date.now() })) } } });
|
|
877
|
-
const { approvedCallScreen } = prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId,
|
|
878
|
+
const { approvedCallScreen } = prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedInstallations, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, noticeRoute, noticeDestinations, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatEffective(wiringManifest) }, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement });
|
|
878
879
|
const postureFrameRef = { report: (err) => deps.onError?.(err, { phase: "degraded", sessionId }) };
|
|
879
880
|
const frameReceipts = { pending: [], listingSnapshotOwed: false };
|
|
880
881
|
const { microCompact, charsPerToken } = prepareContextLane({ model, deps, announced: { announcedListingsRef, frameReceipts }, sessionId, runId, hostTaskId, offloadStore, toolRosterDeltas: rosterSeat, microCompactKnob, harness, batchHaltRef, gitStatusRef, postureFrameRef, requestLossyRef, trimPressureRef, contextOverlay: legContextOverlay, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}) });
|
|
@@ -893,7 +894,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
893
894
|
if (book === undefined)
|
|
894
895
|
throw new Error("a mod's $.model.complete was answered before the run body bound the leg's usage account, which it does before any tool call");
|
|
895
896
|
book("mod", answeredBy, reply);
|
|
896
|
-
}, toolCall: toolCallEntry, agentSpawn: createAgentSpawnEntry({ bus: legMods.bus, harness, mounted: () => (rosterSeat.current?.entries ?? []).map((e) => e.name), specOf: (name) => spec.tools?.find((s) => s.name === name) }), sessionAppend: createSessionAppendEntry({ seat: rowSeat, harness, agentId: agentIdOf(hookIdentity), now }), sessionSend: createSessionSendEntry({ toolCall: toolCallEntry, sendToolName: SEND_MESSAGE_TOOL_NAME, tools: () => [...activeTools] }), sessionCompact: createSessionCompactEntry(compactStation) }));
|
|
897
|
+
}, toolCall: toolCallEntry, agentSpawn: createAgentSpawnEntry({ bus: legMods.bus, harness, mounted: () => (rosterSeat.current?.entries ?? []).map((e) => e.name), specOf: (name) => spec.tools?.find((s) => s.name === name) }), sessionAppend: createSessionAppendEntry({ seat: rowSeat, harness, agentId: agentIdOf(hookIdentity), now }), sessionSend: createSessionSendEntry({ toolCall: toolCallEntry, sendToolName: SEND_MESSAGE_TOOL_NAME, tools: () => [...activeTools] }), sessionCompact: createSessionCompactEntry(compactStation), promptSubmit: createPromptSubmitEntry(promptSubmitRef) }));
|
|
897
898
|
return prepared;
|
|
898
899
|
}
|
|
899
900
|
catch (prepareErr) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bindPeerLaneDrain } from "../../agents/peer-session-drain.js";
|
|
1
|
+
import { bindPeerLaneDrain, peerDrainLanesOf } from "../../agents/peer-session-drain.js";
|
|
2
2
|
import { teamRoleOf } from "../../agents/team-role.js";
|
|
3
3
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
4
4
|
import { createHookEnvCapabilities, mintHookInvocationIdentity } from "../hooks.js";
|
|
@@ -242,10 +242,11 @@ export function prepareWiringManifest(input) {
|
|
|
242
242
|
});
|
|
243
243
|
peerLaneRefs.askEffective = askSeatEffective(wiringManifest);
|
|
244
244
|
peerLaneRefs.permissionMode = () => permissionMode.current;
|
|
245
|
-
const
|
|
246
|
-
|
|
245
|
+
const drainLanes = internals?.onTaskNotification !== undefined ? peerDrainLanesOf(deps, { sessionBox, hostTaskId, sessionId }) : undefined;
|
|
246
|
+
const sessionBoxBound = drainLanes?.sessionBox;
|
|
247
|
+
if (drainLanes !== undefined && internals?.onTaskNotification !== undefined) {
|
|
247
248
|
bindPeerLaneDrain(harness, {
|
|
248
|
-
deps,
|
|
249
|
+
deps, lanes: drainLanes,
|
|
249
250
|
address: sessionAddress,
|
|
250
251
|
sessions,
|
|
251
252
|
runId,
|
|
@@ -100,7 +100,7 @@ export async function generatePromptSuggestions(llm, transcript, count) {
|
|
|
100
100
|
systemPrompt: SUGGEST_SYSTEM_PROMPT,
|
|
101
101
|
messages: [{ role: "user", content: `Conversation transcript:\n\n${rendered}\n\nSuggest up to ${count} next prompts.`, timestamp: Date.now() }],
|
|
102
102
|
}, {
|
|
103
|
-
reasoning: llm.thinking
|
|
103
|
+
reasoning: llm.thinking,
|
|
104
104
|
signal: llm.signal,
|
|
105
105
|
apiKey: auth?.apiKey,
|
|
106
106
|
headers: auth?.headers,
|
|
@@ -90,8 +90,8 @@ export function runIdentityWiring(input) {
|
|
|
90
90
|
};
|
|
91
91
|
prepared.harness.onUserInputConsumed = (record) => {
|
|
92
92
|
const steer = record;
|
|
93
|
-
const
|
|
94
|
-
queue.push({ ...buildAppliedHumanInputEvent({ carrier: "steer", source: "steer", sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal }), eventId: uuidv7(), ...identity });
|
|
93
|
+
const accepted = announceAcceptance(steer);
|
|
94
|
+
queue.push({ ...buildAppliedHumanInputEvent({ carrier: "steer", source: "steer", sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal, ...accepted?.attribution }), eventId: uuidv7(), ...accepted?.identity });
|
|
95
95
|
};
|
|
96
96
|
prepared.harness.onFrameCommitted = (carrier, entryId) => {
|
|
97
97
|
if (carrier.kind === "attachment")
|
|
@@ -10,7 +10,7 @@ import { raiseSessionEnd, raiseSessionStart } from "../mods/lifecycle-stations.j
|
|
|
10
10
|
import { offeredAgentListing } from "../mods/agent-stations.js";
|
|
11
11
|
import { appendAdmittedRow } from "../row-admission.js";
|
|
12
12
|
import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
|
|
13
|
-
import {
|
|
13
|
+
import { isScreened, judgedAuthorOf, objectiveAuthorOf } from "../input-author.js";
|
|
14
14
|
import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
|
|
15
15
|
import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
|
|
16
16
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
|
|
@@ -327,14 +327,14 @@ export async function runLeg(input) {
|
|
|
327
327
|
let promptBlocked = false;
|
|
328
328
|
const author = objectiveAuthorOf(objectiveAuthor, (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId, classification: "input-author-unreadable" }));
|
|
329
329
|
const objectiveEvents = legEventsOf(prepared.hookIdentity);
|
|
330
|
-
if (
|
|
330
|
+
if (isScreened(author)) {
|
|
331
331
|
const screen = await screenUserPrompt(prepared.modBus, {
|
|
332
332
|
...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
|
|
333
333
|
prompt: spec.objective,
|
|
334
334
|
source: "objective",
|
|
335
335
|
...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
|
|
336
336
|
...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
|
|
337
|
-
}, prepared.abortController.signal);
|
|
337
|
+
}, prepared.abortController.signal, { author: judgedAuthorOf(author) });
|
|
338
338
|
if (screen?.kind === "answered" && screen.rewrittenBy !== undefined) {
|
|
339
339
|
projectedObjective = projectHumanInput({ text: screen.text, actor: objectiveActor, source: "objective" });
|
|
340
340
|
objectiveRewrittenBy = screen.rewrittenBy;
|
|
@@ -21,6 +21,9 @@ export interface RunNotificationLaneInput<R> {
|
|
|
21
21
|
holdSessionLock: ((sessionId: string) => Promise<void>) | undefined;
|
|
22
22
|
/** borrowed-mutable (the Runner's) — this leg's view of the session write ledger, handed to prepare; the stream layer closes it at the leg's end. */
|
|
23
23
|
legWrites: import("./session-write-ledger.js").LegWrites;
|
|
24
|
+
/** borrowed-readonly — `$.prompt.submit`'s binding the stream layer filled with its own relay, handed to prepare (whose facade reads
|
|
25
|
+
* it at call time); absent outside a Runner's stream. */
|
|
26
|
+
promptSubmitRef: import("../input-author.js").PromptSubmitRef | undefined;
|
|
24
27
|
/** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError` in the park closure — after the run, on a swapped
|
|
25
28
|
* catalog it is still the CURRENT sink; `models` and prepare's `deps` at the natural-snapshot pin); the one home of why it
|
|
26
29
|
* is a seat and not a captured object is {@link RunnerDepsSeat}. */
|
|
@@ -13,7 +13,7 @@ export function runNotificationLane(input) {
|
|
|
13
13
|
return obligations.run(() => runNotificationLaneAs(input, obligations));
|
|
14
14
|
}
|
|
15
15
|
async function runNotificationLaneAs(input, obligations) {
|
|
16
|
-
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, runner, self, sessions, sessionReadStates, sessionModeSeats, pendingSessionNotifications, prepareTask, next } = input;
|
|
16
|
+
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef, runner, self, sessions, sessionReadStates, sessionModeSeats, pendingSessionNotifications, prepareTask, next } = input;
|
|
17
17
|
const prepareResume = resume
|
|
18
18
|
? {
|
|
19
19
|
leafId: resume.cp.leafId,
|
|
@@ -152,7 +152,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
152
152
|
sessionReadStates,
|
|
153
153
|
sessionModeSeats,
|
|
154
154
|
onTaskNotification: laneSink,
|
|
155
|
-
}, self, taskIdRef, holdSessionLock, legWrites);
|
|
155
|
+
}, self, taskIdRef, holdSessionLock, legWrites, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery), promptSubmitRef);
|
|
156
156
|
pendingSessionNotifications.admit(sessionAddressOf(prepared), prepared.sessionBox);
|
|
157
157
|
const settling = pendingSessionNotifications.settleBoxDebts(sessionAddressOf(prepared), prepared.abortController.signal);
|
|
158
158
|
if (settling !== undefined)
|
|
@@ -282,6 +282,7 @@ export class Runner {
|
|
|
282
282
|
let reapHandle;
|
|
283
283
|
const acceptedSteerInputs = new Map();
|
|
284
284
|
const notifyRef = {};
|
|
285
|
+
const promptSubmitRef = {};
|
|
285
286
|
const captureOptOutRef = {};
|
|
286
287
|
const mcpRedialRef = {};
|
|
287
288
|
const manualCompactRef = { requested: false, waiters: [] };
|
|
@@ -349,6 +350,7 @@ export class Runner {
|
|
|
349
350
|
resume,
|
|
350
351
|
internals: { ...(internals ?? {}), detachHub, forwardScope: createForwardSinkScope(this.deps.onNotice), receivedPeers },
|
|
351
352
|
notifyRef,
|
|
353
|
+
promptSubmitRef,
|
|
352
354
|
captureOptOutRef,
|
|
353
355
|
mcpRedialRef,
|
|
354
356
|
entryActor,
|
|
@@ -382,7 +384,8 @@ export class Runner {
|
|
|
382
384
|
live, runner: this.depsSeat,
|
|
383
385
|
locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
|
|
384
386
|
});
|
|
385
|
-
const { steer, authoredSteer } = streamSteerVerb({ spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner: this.depsSeat });
|
|
387
|
+
const { steer, authoredSteer, inputWindow } = streamSteerVerb({ spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner: this.depsSeat });
|
|
388
|
+
promptSubmitRef.seat = Object.freeze({ relay: authoredSteer, inputWindow });
|
|
386
389
|
const { notify, optOutMemoryCapture, reconnectMcpServer, compact, detach, interrupt } = streamLifecycleVerbs({ live, ready, orTimeout, steeringError, notifyRef, captureOptOutRef, mcpRedialRef, manualCompactRef, detachHub });
|
|
387
390
|
const { halt, destroy } = streamHaltVerbs({ live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, run, reapSuspended, runner: this.depsSeat });
|
|
388
391
|
const { setPermissionMode } = streamModeVerb({ live, ready, orTimeout, steeringError });
|
|
@@ -411,9 +414,9 @@ export class Runner {
|
|
|
411
414
|
return stream;
|
|
412
415
|
}
|
|
413
416
|
runLocked(input) {
|
|
414
|
-
const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, resume, internals, notifyRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
|
|
417
|
+
const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, resume, internals, notifyRef, promptSubmitRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
|
|
415
418
|
return runNotificationLane({
|
|
416
|
-
spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites,
|
|
419
|
+
spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef,
|
|
417
420
|
runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, pendingSessionNotifications: this.pendingSessionNotifications,
|
|
418
421
|
prepareTask,
|
|
419
422
|
next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations }) => {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* nothing here reads host state. Named without the `run-` family prefix for that reason.
|
|
11
11
|
*/
|
|
12
12
|
import type { SteerReplayRefusalDetail } from "../steer-replay.js";
|
|
13
|
+
import type { HumanInputEvent } from "../task-event.js";
|
|
13
14
|
export declare function nextHumanInputSeq(key: object): number;
|
|
14
15
|
/** The identity keys a published `queued` frame carried beyond its own `eventId` (`parentToolCallId`, `sourceTaskId`): one fact, stated
|
|
15
16
|
* once by the frame's publisher and handed to whoever mints that input's other frames, so two frames of one input are never stamped
|
|
@@ -18,8 +19,16 @@ export type AcceptanceIdentity = {
|
|
|
18
19
|
parentToolCallId?: string;
|
|
19
20
|
sourceTaskId?: string;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
/** Who wrote the input, as its `queued` frame said it (`author` absent ⇒ the operator; `extension` beside an extension's) — the
|
|
23
|
+
* same one fact the input's `applied` frame repeats. */
|
|
24
|
+
export type AcceptanceAttribution = Pick<HumanInputEvent, "author" | "extension">;
|
|
25
|
+
/** What a published `queued` frame states once for the input's other frames: its event identity and its attribution. */
|
|
26
|
+
export interface Acceptance {
|
|
27
|
+
readonly identity: AcceptanceIdentity;
|
|
28
|
+
readonly attribution: AcceptanceAttribution;
|
|
29
|
+
}
|
|
30
|
+
export declare function armAcceptance(record: object, publish: () => Acceptance): void;
|
|
31
|
+
export declare function announceAcceptance(record: object): Acceptance | undefined;
|
|
23
32
|
/** The stream verbs' typed refusal: `cannot steer: <msg>`, `code` (`steering.not_running` by default), and the
|
|
24
33
|
* refusal's `detail` when the code carries one (`steering.duplicate_input_id` always does). */
|
|
25
34
|
export declare function steeringError(msg: string, code?: string, detail?: SteerReplayRefusalDetail): Error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AuthoredSteer } from "../input-author.js";
|
|
1
|
+
import { type AuthoredSteer, type InputWindow } from "../input-author.js";
|
|
2
2
|
import type { PushQueue } from "../push-queue.js";
|
|
3
3
|
import { type TaskEvent, type TaskSpec, type TaskStream } from "../types.js";
|
|
4
4
|
import type { LiveHandle, RunInternals, RunnerDepsSeat, TaskStreamLiveSeat } from "./contracts.js";
|
|
@@ -28,7 +28,10 @@ export interface StreamSteerVerbInput {
|
|
|
28
28
|
export interface StreamSteerVerbResult {
|
|
29
29
|
/** The stream's `steer` verb: every input it takes is the operator's. */
|
|
30
30
|
steer: TaskStream["steer"];
|
|
31
|
-
/** The same verb under an author the engine states (an observer's report) — registered on the stream
|
|
31
|
+
/** The same verb under an author the engine states (an observer's report, an extension's prompt) — registered on the stream
|
|
32
|
+
* object and handed to the leg's `$.prompt.submit` entry, never on the package face. */
|
|
32
33
|
authoredSteer: AuthoredSteer;
|
|
34
|
+
/** Where the leg's loop stands for an input, read now ({@link InputWindow}) — the fact the verb's birth-window poll waits out. */
|
|
35
|
+
inputWindow: () => InputWindow;
|
|
33
36
|
}
|
|
34
37
|
export declare function streamSteerVerb(input: StreamSteerVerbInput): StreamSteerVerbResult;
|