@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
|
@@ -30,7 +30,7 @@ const wordlessDemand = (toolName) => {
|
|
|
30
30
|
throw new Error(`a real-approval demand for "${toolName}" reached the park with no origin word — the origin stamp precedes every park`);
|
|
31
31
|
};
|
|
32
32
|
export function prepareParkAsk(input) {
|
|
33
|
-
const { askLane, saga, spec, deps, sessionId, askSource, checkpointStore, checkpointScope, toolRosterDeltas, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots, offloadStore, suspendTargetGap, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef } = input;
|
|
33
|
+
const { askLane, saga, spec, deps, sessionId, askSource, checkpointStore, checkpointScope, toolRosterDeltas, parkLaneArmed, durableQuestionFace, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots, offloadStore, suspendTargetGap, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef } = input;
|
|
34
34
|
if (askLane === undefined || saga === undefined)
|
|
35
35
|
return { parkAsk: undefined };
|
|
36
36
|
const { composedCallSignal, approvalPreviewOf } = askLane;
|
|
@@ -114,6 +114,8 @@ export function prepareParkAsk(input) {
|
|
|
114
114
|
const suspendAsk = parkLaneArmed && checkpointStore !== undefined
|
|
115
115
|
? async (req, postHookArgs, safety, liveFaceUnavailable, realApproval, allowRuleShadowed, askDecisionReason, probeReason, probeCause, segmentCoverage, matchedAskRule, probeMandated, carry) => {
|
|
116
116
|
const contentAsk = isEngineQuestionFace(req.face);
|
|
117
|
+
if (contentAsk && !durableQuestionFace)
|
|
118
|
+
return undefined;
|
|
117
119
|
const syncFirstEligible = contentAsk ? contentAskRoutable(req.toolCallId) : isLiveApproverSeat(onAsk);
|
|
118
120
|
if (syncFirstEligible &&
|
|
119
121
|
runtimeCaps?.forceDurableGate !== true &&
|
|
@@ -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";
|
|
@@ -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) {
|
|
@@ -91,8 +91,8 @@ export interface PrepareQuestionFaceResult {
|
|
|
91
91
|
deliveryId: string;
|
|
92
92
|
toolCallId: string;
|
|
93
93
|
}>;
|
|
94
|
-
/** owned — whether a durable delivery face exists (store wired ∧ (durableApproval ∨ forceDurableGate));
|
|
95
|
-
* the
|
|
94
|
+
/** owned — whether a durable delivery face exists (store wired ∧ (durableApproval ∨ forceDurableGate)); the manifest's
|
|
95
|
+
* composition-lie detector and the park closure's content-ask decline (a question parks only where it holds) reuse this exact value. */
|
|
96
96
|
durableQuestionFace: boolean;
|
|
97
97
|
/** owned — the face the tool was mounted with: the gate-bound answer for THIS call id if one exists (one-shot),
|
|
98
98
|
* else the live face itself; the raw frozen seat when no live face exists. */
|
|
@@ -13,6 +13,7 @@ import type { RunnerSelfSeat } from "./contracts.js";
|
|
|
13
13
|
import type { Prepared, PrepareResume, PrepareTaskFn, RunInternals } from "./contracts.js";
|
|
14
14
|
export type { FileHistoryBoundarySeat, InheritedGate, Prepared, PreparedMicroCompact, PrepareResume, ResolvedWorkspace, RunInternals, UsageGovernance } from "./contracts.js";
|
|
15
15
|
import type { ExecutionEnv } from "../../internal/harness.js";
|
|
16
|
+
import type { PromptSubmitRef } from "../input-author.js";
|
|
16
17
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
17
18
|
/** Test seam (mirrors `__resetMaterializeEnvAnnouncements`): never called by production code.
|
|
18
19
|
* Re-arms BOTH arms (a WeakMap has no clear — it is re-minted). Deliberately UNLIKE the read-face
|
|
@@ -122,7 +123,10 @@ holdSessionLock?: (sessionId: string) => Promise<void>,
|
|
|
122
123
|
legWrites?: LegWrites,
|
|
123
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
|
|
124
125
|
* notification store's): absent when prepareTask runs outside a Runner, and then every notice is delivered. */
|
|
125
|
-
noticeDestinations?: NoticeDestinationJudge
|
|
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>;
|
|
126
130
|
/** The entry IS the contract the notification lane's seat names ({@link PrepareTaskFn}, contracts.ts):
|
|
127
131
|
* a signature change reds HERE, at the declaration, as `false` failing the `true` bound. IDENTITY, not assignability:
|
|
128
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, noticeDestinations) {
|
|
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;
|
|
@@ -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 });
|
|
@@ -872,7 +873,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
872
873
|
const inheritedAnchorRecords = chainAnchorRecords(chainTop, inheritedParentConstraints ?? []);
|
|
873
874
|
const { saga } = prepareSuspendSaga({ gateMachineryActive, crossBoundary, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection: () => legMods.skillScopes.frozen(), reminderMark, handsCwdRef, handsRoot: attachmentRootCanonical, handsHome: attachmentRootCanonical !== undefined ? legAnchors.home : undefined, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors: chainTop !== legAnchors ? inheritedAnchorRecords.pathRuleAnchors : undefined, inheritedPathRuleInstallations: inheritedAnchorRecords.pathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, compositionLegResolved, checkpointScope, runOrigin: doors.runOrigin, toolCeiling: toolCeilingRead, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv });
|
|
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
|
-
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
|
+
const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, askSource, checkpointStore, checkpointScope, toolRosterDeltas: rosterSeat, parkLaneArmed, durableQuestionFace, 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
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 }) };
|
|
@@ -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, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery));
|
|
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;
|
|
@@ -3,8 +3,8 @@ import { snapshotActorAssertion } from "../../internal/llm.js";
|
|
|
3
3
|
import { MAX_STEER_INPUT_ID_CHARS } from "../checkpoint-store.js";
|
|
4
4
|
import { formatHookFeedback } from "../hooks.js";
|
|
5
5
|
import { classicEventBase, failedHandlerClause, legNoticeTaskId, screenUserPrompt } from "../mods/stations.js";
|
|
6
|
-
import { countsAsOperator } from "../input-author.js";
|
|
7
|
-
import { buildHumanInputEvent, frameMidTurnUserInput, projectHumanInput } from "../human-input-projection.js";
|
|
6
|
+
import { countsAsOperator, inputFrameOf, isScreened } from "../input-author.js";
|
|
7
|
+
import { buildHumanInputEvent, frameExtensionInput, frameMidTurnUserInput, projectHumanInput } from "../human-input-projection.js";
|
|
8
8
|
import { injectionLaneOf, isSystemInjectionPriority, steerPriorityOf, SYSTEM_INJECTION_PRIORITIES } from "../task-notification.js";
|
|
9
9
|
import { deliverEngineNotice } from "../types.js";
|
|
10
10
|
import { inlineUntrusted, sanitizeUntrustedText, sentinelTagRefusal } from "../untrusted-text.js";
|
|
@@ -13,7 +13,7 @@ import { steerReplayRefusal } from "../steer-replay.js";
|
|
|
13
13
|
export function streamSteerVerb(input) {
|
|
14
14
|
const { spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner } = input;
|
|
15
15
|
let steerChain = Promise.resolve();
|
|
16
|
-
const steerAs = async (author, text, options) => {
|
|
16
|
+
const steerAs = async (author, text, options, call) => {
|
|
17
17
|
if (options?.userAttachments !== undefined) {
|
|
18
18
|
throw steeringError("a steer carries no attachments — declare them in TaskSpec.userAttachments on the next objective", "steering.invalid_content");
|
|
19
19
|
}
|
|
@@ -37,7 +37,17 @@ export function streamSteerVerb(input) {
|
|
|
37
37
|
const priority = steerPriorityOf({ priority: priorityIn });
|
|
38
38
|
const actorIn = options?.actor;
|
|
39
39
|
const actor = actorIn === undefined ? undefined : snapshotActorAssertion(actorIn);
|
|
40
|
-
const
|
|
40
|
+
const frameFor = (t, reminderMark) => {
|
|
41
|
+
const projected = projectHumanInput({ text: t, actor, source: "steer" });
|
|
42
|
+
switch (inputFrameOf(author)) {
|
|
43
|
+
case "person":
|
|
44
|
+
return trusted ? formatHookFeedback(projected, reminderMark) : frameMidTurnUserInput(projected);
|
|
45
|
+
case "extension":
|
|
46
|
+
return frameExtensionInput(call?.extension, projected);
|
|
47
|
+
case "verbatim":
|
|
48
|
+
return projected;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
41
51
|
const effectiveInputId = typeof inputId === "string" ? inputId : uuidv7();
|
|
42
52
|
const parkRecord = {
|
|
43
53
|
text,
|
|
@@ -49,6 +59,10 @@ export function streamSteerVerb(input) {
|
|
|
49
59
|
let payload;
|
|
50
60
|
let mintsAFrame;
|
|
51
61
|
let rewrittenBy;
|
|
62
|
+
const attribution = {
|
|
63
|
+
...(author !== "operator" ? { author } : {}),
|
|
64
|
+
...(call !== undefined ? { extension: call.extension } : {}),
|
|
65
|
+
};
|
|
52
66
|
const publishQueued = (h) => {
|
|
53
67
|
const identity = internals?.parentToolCallId !== undefined ? { parentToolCallId: internals.parentToolCallId, sourceTaskId: h.hookIdentity.taskId } : {};
|
|
54
68
|
queue.push({
|
|
@@ -62,11 +76,12 @@ export function streamSteerVerb(input) {
|
|
|
62
76
|
...(actor?.issuer !== undefined ? { issuer: actor.issuer } : {}),
|
|
63
77
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
64
78
|
...(rewrittenBy !== undefined ? { rewrittenBy } : {}),
|
|
79
|
+
...attribution,
|
|
65
80
|
}),
|
|
66
81
|
eventId: uuidv7(),
|
|
67
82
|
...identity,
|
|
68
83
|
});
|
|
69
|
-
return identity;
|
|
84
|
+
return { identity, attribution };
|
|
70
85
|
};
|
|
71
86
|
const noteAccepted = () => {
|
|
72
87
|
if (!mintsAFrame)
|
|
@@ -75,13 +90,14 @@ export function streamSteerVerb(input) {
|
|
|
75
90
|
acceptedSteerInputs.set(inputId, parkRecord);
|
|
76
91
|
announceAcceptance(parkRecord);
|
|
77
92
|
};
|
|
93
|
+
let entered = text;
|
|
78
94
|
const deliver = async () => {
|
|
79
95
|
if (live.resultValue)
|
|
80
96
|
throw steeringError("the task has already finished");
|
|
81
97
|
const h = live.handle ?? (await orTimeout(ready));
|
|
82
98
|
if (!h)
|
|
83
99
|
throw steeringError("the task is not running");
|
|
84
|
-
payload =
|
|
100
|
+
payload = frameFor(text, h.reminderMark);
|
|
85
101
|
mintsAFrame = payload.trim().length !== 0;
|
|
86
102
|
if (typeof inputId === "string") {
|
|
87
103
|
const prior = acceptedSteerInputs.get(inputId);
|
|
@@ -91,19 +107,22 @@ export function streamSteerVerb(input) {
|
|
|
91
107
|
const refusal = steerReplayRefusal(prior, parkRecord, { seat: "accepted" });
|
|
92
108
|
if (refusal !== undefined)
|
|
93
109
|
throw steeringError(refusal.message, "steering.duplicate_input_id", refusal.detail);
|
|
94
|
-
return;
|
|
110
|
+
return { entered };
|
|
95
111
|
}
|
|
96
112
|
}
|
|
97
113
|
if (live.resultValue !== undefined || h.loop.ended)
|
|
98
114
|
throw steeringError("the task is no longer running");
|
|
99
|
-
if (
|
|
115
|
+
if (!countsAsOperator(author) && h.harness.engineInjectionsHeld?.() === true) {
|
|
116
|
+
throw steeringError("the run stopped on the person's own refusal and they have not spoken since — an input that is not theirs does not restart it");
|
|
117
|
+
}
|
|
118
|
+
if (mintsAFrame && isScreened(author)) {
|
|
100
119
|
const screen = await screenUserPrompt(h.modBus, {
|
|
101
120
|
...classicEventBase(h.hookIdentity, h.permissionMode.observed),
|
|
102
121
|
prompt: text,
|
|
103
122
|
source: "steer",
|
|
104
123
|
inputId: effectiveInputId,
|
|
105
124
|
...(actor !== undefined ? { actor: snapshotActorAssertion(actor) } : {}),
|
|
106
|
-
}, h.abortController.signal);
|
|
125
|
+
}, call?.signal !== undefined ? AbortSignal.any([h.abortController.signal, call.signal]) : h.abortController.signal, { author, ...(call !== undefined ? { extension: call.extension, raisedUnder: { frames: call.frames, origin: call.origin } } : {}) });
|
|
107
126
|
if (screen?.kind === "aborted") {
|
|
108
127
|
throw steeringError(`the task was cancelled while the deployment's userPromptSubmit hook was still screening this steering input; the input was NOT accepted (fail-closed)`, "steering.blocked_by_hook");
|
|
109
128
|
}
|
|
@@ -114,8 +133,8 @@ export function streamSteerVerb(input) {
|
|
|
114
133
|
throw steeringError(`the deployment's userPromptSubmit hook blocked this steering input: ${inlineUntrusted(screen.block)}`, "steering.blocked_by_hook");
|
|
115
134
|
}
|
|
116
135
|
if (screen?.kind === "answered" && screen.rewrittenBy !== undefined) {
|
|
117
|
-
|
|
118
|
-
payload =
|
|
136
|
+
entered = screen.text;
|
|
137
|
+
payload = frameFor(screen.text, h.reminderMark);
|
|
119
138
|
mintsAFrame = payload.trim().length !== 0;
|
|
120
139
|
rewrittenBy = screen.rewrittenBy;
|
|
121
140
|
}
|
|
@@ -124,6 +143,8 @@ export function streamSteerVerb(input) {
|
|
|
124
143
|
}
|
|
125
144
|
}
|
|
126
145
|
const injectFramed = async () => {
|
|
146
|
+
if (call?.signal?.aborted === true)
|
|
147
|
+
throw steeringError("the extension's call was cancelled before the input was taken");
|
|
127
148
|
const noteOptions = { provenance: "engine-note", author, parkRecord, ...(actor !== undefined ? { actor } : {}) };
|
|
128
149
|
if (mintsAFrame)
|
|
129
150
|
armAcceptance(parkRecord, () => publishQueued(h));
|
|
@@ -152,7 +173,7 @@ export function streamSteerVerb(input) {
|
|
|
152
173
|
};
|
|
153
174
|
try {
|
|
154
175
|
await injectFramed();
|
|
155
|
-
return;
|
|
176
|
+
return { entered };
|
|
156
177
|
}
|
|
157
178
|
catch (e) {
|
|
158
179
|
if (!(e instanceof Error && e.code === "invalid_state"))
|
|
@@ -162,7 +183,7 @@ export function streamSteerVerb(input) {
|
|
|
162
183
|
while (live.resultValue === undefined && !h.loop.ended && Date.now() < birthDeadline) {
|
|
163
184
|
try {
|
|
164
185
|
await injectFramed();
|
|
165
|
-
return;
|
|
186
|
+
return { entered };
|
|
166
187
|
}
|
|
167
188
|
catch (e2) {
|
|
168
189
|
if (!(e2 instanceof Error && e2.code === "invalid_state"))
|
|
@@ -176,5 +197,37 @@ export function streamSteerVerb(input) {
|
|
|
176
197
|
steerChain = p.then(() => undefined, () => undefined);
|
|
177
198
|
return p;
|
|
178
199
|
};
|
|
179
|
-
|
|
200
|
+
const authoredSteer = async (author, text, call) => {
|
|
201
|
+
try {
|
|
202
|
+
return await steerAs(author, text, call !== undefined ? { priority: call.priority } : undefined, call);
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
if (isSteeringRefusal(e))
|
|
206
|
+
return { drop: e.message };
|
|
207
|
+
throw e;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const inputWindow = () => {
|
|
211
|
+
if (live.resultValue !== undefined)
|
|
212
|
+
return "over";
|
|
213
|
+
const h = live.handle;
|
|
214
|
+
if (h === undefined)
|
|
215
|
+
return "before";
|
|
216
|
+
if (h.loop.ended)
|
|
217
|
+
return "over";
|
|
218
|
+
return h.harness.takingInput ? "open" : "before";
|
|
219
|
+
};
|
|
220
|
+
return {
|
|
221
|
+
steer: async (text, options) => {
|
|
222
|
+
await steerAs("operator", text, options);
|
|
223
|
+
},
|
|
224
|
+
authoredSteer,
|
|
225
|
+
inputWindow,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function isSteeringRefusal(e) {
|
|
229
|
+
if (!(e instanceof Error))
|
|
230
|
+
return false;
|
|
231
|
+
const code = e.code;
|
|
232
|
+
return typeof code === "string" && code.startsWith("steering.");
|
|
180
233
|
}
|
|
@@ -35,13 +35,15 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import type { AgentTool } from "../../internal/harness.js";
|
|
37
37
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
38
|
-
import type
|
|
38
|
+
import { type EngineNotice } from "../engine-notice.js";
|
|
39
39
|
import { type ProtocolId } from "../protocol-table.js";
|
|
40
|
+
import { POLICY_NAME_REFUSAL_CODE, type PolicyNameLayer } from "../retired-tool-name-account.js";
|
|
40
41
|
import type { ToolLegKind, ToolSelector, ToolSelectorLayer } from "../tool-face.js";
|
|
41
42
|
import { type ConstraintChainEntry } from "../tool-policy.js";
|
|
42
43
|
import type { TaskSpec } from "../types.js";
|
|
43
44
|
import type { CheckpointErrorReason } from "../checkpoint-store.js";
|
|
44
|
-
import type {
|
|
45
|
+
import type { RunInternals } from "./contracts.js";
|
|
46
|
+
import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
45
47
|
/** What the delegation tools a run mounts hand their children (the pools of {@link delegationPoolReading}). */
|
|
46
48
|
interface DelegationPoolReading {
|
|
47
49
|
readonly tools: NonNullable<TaskSpec["tools"]>;
|
|
@@ -80,11 +82,6 @@ export declare function delegationPoolReading(callerTools: NonNullable<TaskSpec[
|
|
|
80
82
|
* ({@link CheckpointErrorReason}): a list the row recorded that is not a list / has a member that is not a string / has a spelling no tool name can have / is not in the
|
|
81
83
|
* spelling a row records, a record that is not one, a renamed delegation mount, an occupied table of declared names. */
|
|
82
84
|
export type PersistedToolFaceReason = Extract<CheckpointErrorReason, "not_a_list" | "not_a_string" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied">;
|
|
83
|
-
/** The code of the policy-name refusal — the one spelling its mint and every problem it lists carry. */
|
|
84
|
-
export declare const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
|
|
85
|
-
/** The layers the prepare-time policy-name audit reads, by the words the trace already gives the first: the run's own policy
|
|
86
|
-
* (`caller_policy`), the stored rules of its session, and the rules an ancestor's session handed it. */
|
|
87
|
-
export type PolicyNameLayer = "caller_policy" | "session_rules" | "ancestor_session_rules";
|
|
88
85
|
/** One entry the policy-name audit refuses, in the shape the entry problems of a rejection body are minted in (code · field ·
|
|
89
86
|
* entry · reason, the engine entry reading's words) plus the layer it sits in: `field` is the policy list (`deny` / `ask` /
|
|
90
87
|
* `allow`), `reason` the name judgment's verdict word (`near_miss` for another spelling of a carried name). */
|
|
@@ -104,24 +101,6 @@ export interface PolicyNameFinding {
|
|
|
104
101
|
* the first entry's, `detail.problems` lists the refused entries of the layer in scan order (within the bounds above), `detail.total`
|
|
105
102
|
* counts every one. */
|
|
106
103
|
export declare function policyNameRefusal(first: PolicyNameFinding, more: readonly PolicyNameFinding[]): Error;
|
|
107
|
-
/** One entry of a restricting policy list (`deny` / `ask`) that names a tool the engine retired with no successor to write: the name
|
|
108
|
-
* matches nothing in any roster, so the audit leaves the entry out and says so ({@link retiredToolNameNotice}) instead of refusing
|
|
109
|
-
* the run. `guidance` is the retirement table's own line for the name. */
|
|
110
|
-
export interface RetiredPolicyEntry {
|
|
111
|
-
readonly field: "deny" | "ask";
|
|
112
|
-
readonly entry: string;
|
|
113
|
-
readonly layer: PolicyNameLayer;
|
|
114
|
-
readonly guidance: string;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The notice for the entries of one policy layer's deny or ask list that name a retired tool (`config.legacy_tool_name`, audience
|
|
118
|
-
* `user` — the person who wrote the entry believes it guards a tool): the audit left them out, they reach no tool in any roster, and the
|
|
119
|
-
* run goes on. One notice per audited layer per prepared task, minted here and nowhere else. `detail: { layer, entries: [{ field,
|
|
120
|
-
* entry, layer, guidance }], total, sessionId }` — `entries` are unique by (field, entry) in scan order, at most
|
|
121
|
-
* {@link RETIRED_NOTICE_ENTRIES_SHOWN}, `total` counts every one. The entries that name a tool the engine renamed are not here: their
|
|
122
|
-
* names have a successor, the entry guarded it, and the audit still refuses them.
|
|
123
|
-
*/
|
|
124
|
-
export declare function retiredToolNameNotice(layer: PolicyNameLayer, entries: readonly RetiredPolicyEntry[], sessionId: string): EngineNotice;
|
|
125
104
|
/**
|
|
126
105
|
* The names a definition's denied-tools entries stand for, for a lane that has neither a roster nor a notice sink at the point
|
|
127
106
|
* it builds its own policy (a workflow leg's agentType): each entry is read by the one reading, so `Tool(content)` denies the
|
|
@@ -222,8 +201,10 @@ export interface RunToolListsInput {
|
|
|
222
201
|
* (`RunInternals.ownToolLists`); absent ⇒ the run's own `TaskSpec` seats. Its sentence is {@link delegationListWhere}; its tool name is
|
|
223
202
|
* a name of the leg's lineage, so the run's own lists are asked of a universe that carries it. */
|
|
224
203
|
ownBy: RunInternals["ownToolLists"];
|
|
225
|
-
/** borrowed-readonly — the once-per-session ledger whose operator sink carries the
|
|
226
|
-
onceLedger: Pick<
|
|
204
|
+
/** borrowed-readonly — the once-per-session ledger whose operator sink carries the advisories and whose verb tells the retired-name notice once. */
|
|
205
|
+
onceLedger: Pick<AnnounceOnceLedger, "onError" | "oncePerSession">;
|
|
206
|
+
/** borrowed-readonly — the deployment's notice sink (`RunnerDeps.onNotice`): the retired-name notice goes there. */
|
|
207
|
+
onNotice?: ((notice: EngineNotice) => void) | undefined;
|
|
227
208
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
228
209
|
sessionId: string;
|
|
229
210
|
}
|