@kingsoftcloud/agentkit-harness-core 0.0.14 → 0.0.15

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.
Files changed (46) hide show
  1. package/dist/approval-outcome.d.mts +7 -0
  2. package/dist/approval-outcome.mjs +8 -0
  3. package/dist/background-notification.mjs +3 -2
  4. package/dist/child-contract.d.mts +2 -0
  5. package/dist/child-control.d.mts +4 -0
  6. package/dist/child-control.mjs +15 -2
  7. package/dist/child-runtime.mjs +11 -1
  8. package/dist/configuration.d.mts +2 -0
  9. package/dist/configuration.mjs +7 -4
  10. package/dist/context-planning.mjs +2 -2
  11. package/dist/contracts.d.mts +13 -7
  12. package/dist/contracts.mjs +1 -1
  13. package/dist/index.d.mts +1 -0
  14. package/dist/index.mjs +1 -0
  15. package/dist/kernel.d.mts +1 -0
  16. package/dist/kernel.mjs +41 -5
  17. package/dist/machine.mjs +40 -22
  18. package/dist/model-failure.d.mts +13 -1
  19. package/dist/model-failure.mjs +29 -2
  20. package/dist/model-json.mjs +21 -12
  21. package/dist/output-recovery.mjs +6 -2
  22. package/dist/response-continuation.d.mts +4 -0
  23. package/dist/response-continuation.mjs +9 -1
  24. package/dist/store.mjs +2 -1
  25. package/dist/tool-discovery.d.mts +8 -0
  26. package/dist/tool-discovery.mjs +44 -0
  27. package/dist/transitions.mjs +21 -2
  28. package/package.json +1 -1
  29. package/src/approval-outcome.mts +12 -0
  30. package/src/background-notification.mts +3 -2
  31. package/src/child-contract.mts +2 -0
  32. package/src/child-control.mts +16 -2
  33. package/src/child-runtime.mts +7 -1
  34. package/src/configuration.mts +9 -4
  35. package/src/context-planning.mts +2 -2
  36. package/src/contracts.mts +14 -8
  37. package/src/index.mts +1 -0
  38. package/src/kernel.mts +38 -5
  39. package/src/machine.mts +41 -22
  40. package/src/model-failure.mts +40 -3
  41. package/src/model-json.mts +20 -9
  42. package/src/output-recovery.mts +6 -2
  43. package/src/response-continuation.mts +11 -1
  44. package/src/store.mts +2 -1
  45. package/src/tool-discovery.mts +37 -0
  46. package/src/transitions.mts +19 -2
@@ -6,18 +6,26 @@ export function parseModelJson(text) { return decodeJson(text, false, 256); }
6
6
  export function parseNativeJson(text) { return decodeJson(text, true, 1024); }
7
7
  function decodeJson(text, plainObjects, maxDepth) {
8
8
  let position = 0;
9
- function space() { while (/[\u0009\u000a\u000d\u0020]/.test(text[position] ?? '\0'))
10
- position++; }
11
- function string() {
12
- const start = position++;
9
+ // The strict structural decoder still owns duplicate keys, exact integers
10
+ // and depth. Scan text spans in the engine rather than visiting each code
11
+ // unit in JS: persisted code/log strings dominate long-session reads.
12
+ const stringToken = /"[^"\\]*(?:\\[\s\S][^"\\]*)*"/y;
13
+ const numberToken = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;
14
+ function space() {
13
15
  while (position < text.length) {
14
- const character = text[position++];
15
- if (character === '\\')
16
- position++;
17
- else if (character === '"')
18
- return JSON.parse(text.slice(start, position));
16
+ const code = text.charCodeAt(position);
17
+ if (code !== 9 && code !== 10 && code !== 13 && code !== 32)
18
+ break;
19
+ position++;
19
20
  }
20
- invariant(false, 'invalid_model_json');
21
+ }
22
+ function string() {
23
+ stringToken.lastIndex = position;
24
+ const token = stringToken.exec(text);
25
+ invariant(token, 'invalid_model_json');
26
+ position = stringToken.lastIndex;
27
+ // Native decoding validates escapes and rejects raw control characters.
28
+ return JSON.parse(token[0]);
21
29
  }
22
30
  function value(depth) {
23
31
  invariant(depth <= maxDepth, 'model_json_nesting_exceeded');
@@ -74,9 +82,10 @@ function decodeJson(text, plainObjects, maxDepth) {
74
82
  return result;
75
83
  }
76
84
  }
77
- const number = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(text.slice(position));
85
+ numberToken.lastIndex = position;
86
+ const number = numberToken.exec(text);
78
87
  invariant(number, 'invalid_model_json');
79
- position += number[0].length;
88
+ position = numberToken.lastIndex;
80
89
  const lexeme = number[0], result = Number(lexeme);
81
90
  if (!/[.eE]/.test(lexeme) && !Number.isSafeInteger(result)) {
82
91
  // Python's JSON decoder uses arbitrary precision int, with its default
@@ -1,9 +1,13 @@
1
- import { responseContinuationPairs, responseContinuationPending, joinResponseContinuation } from './response-continuation.mjs';
1
+ import { responseBoundaryRecovery, responseContinuationPairs, responseContinuationPending, joinResponseContinuation } from './response-continuation.mjs';
2
2
  import { canonical, copy, invariant } from './values.mjs';
3
3
  import { contextMessageRef } from './context-planning.mjs';
4
4
  /** Select from actual admission after the completed model claim, never the catalog. */
5
5
  export function outputRecoveryMode(snapshot, config, toolsAvailable, result) {
6
- if (config.outputRecoveryPolicy === 'response-boundary/v2' && config.contract.finalOutputFormat === 'text') {
6
+ if (responseBoundaryRecovery(config) && config.contract.finalOutputFormat === 'text') {
7
+ // A provider length boundary identifies truncated text, not task completion.
8
+ // Preserve explicit sealed delivery, otherwise retain the admitted tools.
9
+ if (config.outputRecoveryPolicy === 'response-boundary/v3')
10
+ return responseContinuationPending(snapshot, config) || !toolsAvailable ? 'suffix' : 'task_resume';
7
11
  if (responseContinuationPending(snapshot, config)
8
12
  || result?.textCommitVersion === 'provider-finished-text/v1' && result.outputBoundary === 'assistant-text/v1')
9
13
  return 'suffix';
@@ -1,4 +1,8 @@
1
1
  import type { Message, RunConfiguration, RunSnapshot } from './contracts.mjs';
2
+ /** The output recovery strategy is versioned separately from the sealed v2
3
+ * text-fragment protocol. A v3 task may still own an explicit suffix chain. */
4
+ export declare function responseBoundaryRecovery(config: Pick<RunConfiguration, 'outputRecoveryPolicy'>): boolean;
5
+ export declare function responseScopedOutputRestarts(config: Pick<RunConfiguration, 'outputRestartPolicy'>): boolean;
2
6
  export declare function responseContinuationPairs(messages: Message[], digest?: (value: unknown) => string): [number, number][];
3
7
  /** This only narrows admission. Digest validation is required for assembly. */
4
8
  export declare function responseContinuationPending(snapshot: RunSnapshot, config: RunConfiguration): boolean;
@@ -1,3 +1,11 @@
1
+ /** The output recovery strategy is versioned separately from the sealed v2
2
+ * text-fragment protocol. A v3 task may still own an explicit suffix chain. */
3
+ export function responseBoundaryRecovery(config) {
4
+ return config.outputRecoveryPolicy === 'response-boundary/v2' || config.outputRecoveryPolicy === 'response-boundary/v3';
5
+ }
6
+ export function responseScopedOutputRestarts(config) {
7
+ return config.outputRestartPolicy === 'per-response/v1' || config.outputRestartPolicy === 'per-response/v2';
8
+ }
1
9
  /** Journaled Host controls may be staged between response fragments. Actual
2
10
  * user input, tool observations and new assistant messages end the chain. */
3
11
  function hostControl(message) {
@@ -26,7 +34,7 @@ export function responseContinuationPairs(messages, digest) {
26
34
  }
27
35
  /** This only narrows admission. Digest validation is required for assembly. */
28
36
  export function responseContinuationPending(snapshot, config) {
29
- return config.outputRecoveryPolicy === 'response-boundary/v2' && responseContinuationPairs(snapshot.messages).length > 0;
37
+ return responseBoundaryRecovery(config) && responseContinuationPairs(snapshot.messages).length > 0;
30
38
  }
31
39
  /** The v2 wire contract permits replay of exactly the unfinished final line.
32
40
  * No complete line, fuzzy match, arbitrary suffix or raw receipt is removed. */
package/dist/store.mjs CHANGED
@@ -358,7 +358,8 @@ export class TransactionalRunStore {
358
358
  const command = parent.commands.find(row => !row.consumed && row.command.commandId === batch.consumedCommandId)?.command;
359
359
  invariant(command, 'child_control_command_missing');
360
360
  validateChildControlDelivery(parent, childRecord, command, delivery);
361
- invariant(batch.events.some(event => event.kind === (command.kind === 'message_child' ? 'child.input_queued' : 'child.cancel_requested')
361
+ invariant(batch.events.some(event => event.kind === (command.kind === 'message_child' ? 'child.input_queued'
362
+ : command.kind === 'resume_child' ? 'child.resume_requested' : 'child.cancel_requested')
362
363
  && event.payload.commandId === command.commandId && event.payload.childRunId === target.runId), 'child_control_event_missing');
363
364
  invariant(!previous || canonical(previous.command) === canonical(delivery.command), 'command_replay_conflict');
364
365
  return { records: [updated.record, previous ? childRecord : { ...childRecord,
@@ -12,6 +12,14 @@ export declare function discoveryModelTools(snapshot: RunSnapshot, config: RunCo
12
12
  /** Resolve before permission, grouping, budgets and durable operation identity use the target. */
13
13
  export declare function resolveDiscoveredCalls(snapshot: RunSnapshot, config: RunConfiguration, calls: ToolCall[]): ToolCall[];
14
14
  export declare function discoveredCallExposed(snapshot: RunSnapshot, config: RunConfiguration, call: ToolCall): boolean;
15
+ /** Exact, scoped names are sufficient evidence to discover a definition, not to
16
+ * authorize its proposed operation. Promote only newly exposed schemas, bounded
17
+ * like a search result. The next model request must resubmit through the normal
18
+ * schema/permission/approval path. Omission preserves historical admission. */
19
+ export declare function discoverRejectedCalls(snapshot: RunSnapshot, config: RunConfiguration, calls: ToolCall[], tools: ToolDefinition[]): {
20
+ state: NonNullable<RunSnapshot['toolDiscovery']>;
21
+ names: string[];
22
+ } | null;
15
23
  /** Describe a rejected model call using only the current, scoped execution
16
24
  * catalog. Discovery is a suggested next call, never authority to dispatch the
17
25
  * rejected operation. Historical events and frozen tool definitions stay intact. */
@@ -24,6 +24,8 @@ export function toolDiscoveryDefinitions() {
24
24
  }
25
25
  export function validateToolDiscovery(config) {
26
26
  invariant(config.toolDiscoveryPolicy === undefined || config.toolDiscoveryPolicy === TOOL_DISCOVERY_POLICY, 'invalid_tool_discovery_policy');
27
+ invariant(config.toolAdmissionPolicy === undefined || config.toolAdmissionPolicy === 'discover-before-retry/v1'
28
+ && config.toolDiscoveryPolicy === TOOL_DISCOVERY_POLICY, 'invalid_tool_admission_policy');
27
29
  invariant(config.profile.providerToolSearchPolicy === undefined || config.profile.providerToolSearchPolicy === 'local-only/v1'
28
30
  || config.profile.providerToolSearchPolicy === 'anthropic-deferred/v1'
29
31
  && config.profile.providerFamily === 'anthropic-messages' && config.toolDiscoveryPolicy === TOOL_DISCOVERY_POLICY, 'invalid_provider_tool_search_policy');
@@ -133,6 +135,48 @@ export function discoveredCallExposed(snapshot, config, call) {
133
135
  || config.profile.providerToolSearchPolicy === 'anthropic-deferred/v1'
134
136
  && snapshot.toolDiscovery?.discovered.includes(call.name) === true;
135
137
  }
138
+ /** Exact, scoped names are sufficient evidence to discover a definition, not to
139
+ * authorize its proposed operation. Promote only newly exposed schemas, bounded
140
+ * like a search result. The next model request must resubmit through the normal
141
+ * schema/permission/approval path. Omission preserves historical admission. */
142
+ export function discoverRejectedCalls(snapshot, config, calls, tools) {
143
+ if (config.toolAdmissionPolicy !== 'discover-before-retry/v1' || !snapshot.toolDiscovery)
144
+ return null;
145
+ const wrapper = tools.find(tool => tool.name === DEFERRED_TOOL_CALL);
146
+ const names = [], definitions = [];
147
+ for (const call of calls) {
148
+ if (call.wireArgumentsInvalid || call.modelCallWrapper)
149
+ continue;
150
+ const wrapped = call.name === DEFERRED_TOOL_CALL;
151
+ if (wrapped && (!wrapper || toolInputRejection(wrapper, call)))
152
+ continue;
153
+ if (!wrapped && discoveredCallExposed(snapshot, config, call))
154
+ continue;
155
+ const name = wrapped ? String(call.arguments.name) : call.name;
156
+ if (names.includes(name) || snapshot.toolDiscovery.promoted.includes(name)
157
+ || wrapped && snapshot.toolDiscovery.discovered.includes(name))
158
+ continue;
159
+ const target = tools.find(tool => tool.name === name && tool.discovery?.deferred
160
+ && (config.contract.allowedToolNames === null || config.contract.allowedToolNames.includes(name)));
161
+ if (!target)
162
+ continue;
163
+ const entry = { name, description: target.description, parameters: copy(target.parameters) };
164
+ // Keep metadata discovery finite and no larger than the existing search
165
+ // model-view envelope. Oversized schemas must use the explicit search path.
166
+ const bytes = new TextEncoder().encode(canonical({ content: canonical({ definitions: [...definitions, entry] }),
167
+ media: [], additionalContexts: [] })).length;
168
+ if (bytes + 32 > config.limits.maxToolResultBytes)
169
+ continue;
170
+ names.push(name);
171
+ definitions.push(entry);
172
+ if (names.length === 20)
173
+ break;
174
+ }
175
+ return names.length ? { names, state: {
176
+ discovered: [...new Set([...snapshot.toolDiscovery.discovered, ...names])],
177
+ promoted: [...snapshot.toolDiscovery.promoted, ...names],
178
+ } } : null;
179
+ }
136
180
  /** Describe a rejected model call using only the current, scoped execution
137
181
  * catalog. Discovery is a suggested next call, never authority to dispatch the
138
182
  * rejected operation. Historical events and frozen tool definitions stay intact. */
@@ -4,6 +4,7 @@ import { admitSteering } from './task-contract.mjs';
4
4
  import { admitChildPromotion, unsettledChildren } from './child-runtime.mjs';
5
5
  import { guidanceReason } from './guidance.mjs';
6
6
  import { bindOperatorInput } from './anthropic-context.mjs';
7
+ import { APPROVAL_OUTCOME_POLICY, normalizeHostApprovalOutcome, approvalOutcomePauseReason } from './approval-outcome.mjs';
7
8
  export function transition(snapshot, changes, facts = [], options = {}) {
8
9
  invariant(!terminal(snapshot.phase), 'terminal_immutable');
9
10
  const pendingGuidanceIds = changes.pendingGuidanceIds ?? snapshot.pendingGuidanceIds;
@@ -149,19 +150,37 @@ export function reduceCommand(snapshot, command, pending = null, bindings = {})
149
150
  reason = 'not_paused';
150
151
  else
151
152
  changes = { phase: snapshot.resumePhase ?? 'preparing_context', resumePhase: null,
152
- ...(['provider_unavailable', 'context_summary_unavailable'].includes(snapshot.reason ?? '') ? { reason: null } : {}) };
153
+ ...(snapshot.reason === 'output_budget_exhausted' && bindings.configuration?.outputRestartPolicy === 'per-response/v2'
154
+ ? { reason: null, continuations: 0, outputRestarts: 0 } : {}),
155
+ ...(bindings.configuration?.approvalOutcomePolicy === APPROVAL_OUTCOME_POLICY
156
+ && ['approval_rejected', 'approval_cancelled', 'approval_unavailable'].includes(snapshot.reason ?? '') ? { reason: null } : {}),
157
+ ...(['provider_unavailable', 'context_summary_unavailable', 'child_paused'].includes(snapshot.reason ?? '') ? { reason: null } : {}) };
153
158
  break;
154
159
  case 'submit_interaction': {
155
160
  const pending = snapshot.pendingInteraction;
161
+ const hasOutcome = Object.hasOwn(command.payload, 'approvalOutcome');
162
+ const approvalOutcome = normalizeHostApprovalOutcome(command.payload.approvalOutcome);
156
163
  if (snapshot.phase !== 'awaiting_interaction' || !pending || command.payload.interactionId !== pending.interactionId
157
164
  || command.payload.decision !== 'allow' && command.payload.decision !== 'deny')
158
165
  reason = 'interaction_mismatch';
166
+ else if (hasOutcome && (bindings.configuration?.approvalOutcomePolicy !== APPROVAL_OUTCOME_POLICY
167
+ || approvalOutcome !== command.payload.approvalOutcome
168
+ || (approvalOutcome === 'allowed-once') !== (command.payload.decision === 'allow')))
169
+ reason = 'interaction_outcome_mismatch';
159
170
  else {
160
171
  changes = { phase: snapshot.childApproval ? snapshot.resumePhase ?? 'preparing_context' : 'executing_tools',
161
172
  ...(snapshot.childApproval ? { resumePhase: null, childLifecycleCursor: null } : {}), pendingInteraction: null,
162
173
  interaction: pending.approvalPolicy === 'durable-preflight/v1' ? null : { interactionId: pending.hostInteractionId, callId: pending.callId, decision: command.payload.decision,
174
+ ...(hasOutcome ? { approvalOutcome } : {}),
163
175
  ...(snapshot.planMode && typeof command.payload.feedback === 'string' ? { feedback: command.payload.feedback } : {}) } };
164
- facts.push({ kind: 'approval.resolved', payload: { interactionId: pending.interactionId, callId: pending.callId, decision: command.payload.decision } });
176
+ // One human answer pauses the interactive owner once. Its children
177
+ // receive the same denied decision after that owner is explicitly
178
+ // resumed; no second pause or implicit tool permission is introduced.
179
+ const pauseReason = hasOutcome && !bindings.configuration?.childOwnerBinding ? approvalOutcomePauseReason(approvalOutcome) : null;
180
+ if (pauseReason)
181
+ Object.assign(changes, { resumePhase: changes.phase, phase: 'paused', reason: pauseReason, outcome: null });
182
+ facts.push({ kind: 'approval.resolved', payload: { interactionId: pending.interactionId, callId: pending.callId, decision: command.payload.decision,
183
+ ...(hasOutcome ? { approvalOutcome } : {}) } });
165
184
  }
166
185
  break;
167
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingsoftcloud/agentkit-harness-core",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Host-independent Native Harness contracts, transitions and durable execution.",
@@ -0,0 +1,12 @@
1
+ /** Host answers are not interchangeable. Unknown answers never grant access.
2
+ * Session permissions are a separate scoped Host authority, not an outcome a
3
+ * model or tool may claim in this vocabulary. */
4
+ export type HostApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';
5
+ export const APPROVAL_OUTCOME_POLICY = 'owner-outcome/v1' as const;
6
+ export function normalizeHostApprovalOutcome(value: unknown): HostApprovalOutcome {
7
+ return value === 'allowed-once' || value === 'rejected' || value === 'cancelled' ? value : 'unavailable';
8
+ }
9
+ export function approvalOutcomePauseReason(value: HostApprovalOutcome): string | null {
10
+ return value === 'rejected' ? 'approval_rejected' : value === 'cancelled' ? 'approval_cancelled'
11
+ : value === 'unavailable' ? 'approval_unavailable' : null;
12
+ }
@@ -5,6 +5,7 @@ import { backgroundCommandObservation, backgroundCommandRef } from './background
5
5
  import { initialSnapshot, configure } from './configuration.mjs';
6
6
  import { projectSessionHistory } from './history.mjs';
7
7
  import { canonical, copy, invariant, NativeError, isNativeError, scopeKey } from './values.mjs';
8
+ import { responseScopedOutputRestarts } from './response-continuation.mjs';
8
9
 
9
10
  export const BACKGROUND_NOTIFICATION_ADMISSION = 'agentkit.background-notification-admission/v1' as const;
10
11
  type Digest = (value: unknown) => string;
@@ -161,12 +162,12 @@ export async function admitBackgroundNotification({ store, scope, sourceRunId, t
161
162
  invariant((limits.maxModelCalls === null || limits.maxModelCalls > 0) && (limits.maxWallMs === null || limits.maxWallMs > 0),
162
163
  'background_notification_budget_exhausted');
163
164
  limits.maxRepairs = Math.max(0, limits.maxRepairs - used.repairs);
164
- if (source.configuration.outputRestartPolicy !== 'per-response/v1')
165
+ if (!responseScopedOutputRestarts(source.configuration))
165
166
  limits.maxOutputRestarts = Math.max(0, limits.maxOutputRestarts - used.outputRestarts);
166
167
  limits.maxRecoveryRetries = Math.max(0, limits.maxRecoveryRetries - used.recovery);
167
168
  const contract = copy(head.taskContract ?? parent.configuration.contract);
168
169
  const configuration = configure({ ...copy(source.configuration), contract, limits, inputMessages: null,
169
- profile: { ...source.configuration.profile, maxContinuations: source.configuration.outputRestartPolicy === 'per-response/v1'
170
+ profile: { ...source.configuration.profile, maxContinuations: responseScopedOutputRestarts(source.configuration)
170
171
  ? source.configuration.profile.maxContinuations : Math.max(0, source.configuration.profile.maxContinuations - used.continuations) } });
171
172
  const snapshot = initialSnapshot({ scope: fixedScope, runId, sessionId: source.snapshot.sessionId,
172
173
  turnId: runId, buildId: source.snapshot.buildId, parentRunId: head.runId, taskChainId: source.snapshot.taskChainId }, configuration, digest(configuration));
@@ -40,6 +40,8 @@ export interface ChildTaskControlState {
40
40
  childRunId: string; sessionId: string; role: string; phase: string;
41
41
  goalRevision: number;
42
42
  delivery: 'foreground' | 'background'; canPromote: boolean; canCancel: boolean; canSendInput: boolean;
43
+ /** Explicit Host control, not a model tool or implicit side effect of guidance. */
44
+ canResume?: boolean;
43
45
  }
44
46
  export interface ChildControlTarget {
45
47
  scope: RunScope; runId: string; configurationDigest: string; parentOperationKey: string; parentToolCallId: string;
@@ -4,16 +4,26 @@ import { terminal } from './contracts.mjs';
4
4
  import { CHILD_OWNER_CONTRACT } from './child-contract.mjs';
5
5
  import { canonical, copy, invariant } from './values.mjs';
6
6
 
7
+ /** An explicit control resumes a known pause, not an uncertain effect. This
8
+ * applies to output, provider and context pauses without changing their
9
+ * frozen policies, total budgets or required permission decisions. */
10
+ export function childResumeAllowed(snapshot: RunSnapshot): boolean {
11
+ return snapshot.phase === 'paused' && snapshot.pendingIntent === null
12
+ && snapshot.toolReconciliation == null && snapshot.resumePhase !== 'awaiting_reconciliation'
13
+ && !['effect_outcome_unknown', 'recovery_retry_exhausted', 'browser_session_unavailable'].includes(snapshot.reason ?? '');
14
+ }
15
+
7
16
  export function childControlDelivery(parent: RunSnapshot, command: RunCommand, target: ChildControlTarget): ChildControlDelivery {
8
17
  const send = command.kind === 'message_child', input = command.payload;
9
- invariant(['message_child', 'cancel_child'].includes(command.kind)
18
+ invariant(['message_child', 'cancel_child', 'resume_child'].includes(command.kind)
10
19
  && typeof input.childRunId === 'string' && input.childRunId.trim() && input.childRunId.length <= 256
11
20
  && Object.keys(input).every(key => (send ? ['childRunId', 'text', 'expectedGoalRevision'] : ['childRunId']).includes(key))
12
21
  && (!send || typeof input.text === 'string' && input.text.trim() && input.text.length <= 32768
13
22
  && Number.isSafeInteger(input.expectedGoalRevision) && (input.expectedGoalRevision as number) >= 0), 'invalid_child_control');
14
23
  return { target: copy(target), command: {
15
24
  commandId: `child-control:${canonical([parent.scope, parent.runId, command.commandId])}`,
16
- kind: send ? 'guide' : 'cancel', payload: send ? { text: input.text!, expectedGoalRevision: input.expectedGoalRevision! } : {},
25
+ kind: send ? 'guide' : command.kind === 'resume_child' ? 'resume' : 'cancel',
26
+ payload: send ? { text: input.text!, expectedGoalRevision: input.expectedGoalRevision! } : {},
17
27
  } };
18
28
  }
19
29
 
@@ -52,6 +62,10 @@ export function validateChildControlDelivery(parent: StoredRun, child: StoredRun
52
62
  'child_control_result_unknown');
53
63
  const preempts = (record: StoredRun, kinds: string[]) => record.commands.some(row => !row.consumed && kinds.includes(row.command.kind));
54
64
  invariant(!preempts(parent, ['cancel', 'policy_revoked', 'steer']), 'parent_control_preempts_child_control');
65
+ if (command.kind === 'resume_child') {
66
+ invariant(childResumeAllowed(c)
67
+ && !preempts(child, ['cancel', 'policy_revoked', 'steer', 'resume']), 'child_control_unavailable');
68
+ }
55
69
  if (command.kind === 'message_child') {
56
70
  invariant(!preempts(child, ['cancel', 'policy_revoked', 'steer']), 'child_control_preempts_input');
57
71
  invariant(command.payload.expectedGoalRevision === c.goalRevision, 'stale_child_goal_revision');
@@ -132,7 +132,7 @@ export function reduceChildLifecycle(snapshot: RunSnapshot, config: RunConfigura
132
132
  const owned = request.reservations.find(item => item.childRunId === child.runId);
133
133
  invariant(owned && owned.parentOperationKey === child.operationKey && owned.parentToolCallId === child.callId
134
134
  && child.reservedModelCalls === owned.maxModelCalls && child.reservedToolCalls === owned.maxToolCalls
135
- && ['prepared', 'running', 'awaiting_interaction', 'completed', 'failed', 'canceled', 'interrupted'].includes(child.state)
135
+ && ['prepared', 'running', 'paused', 'awaiting_interaction', 'completed', 'failed', 'canceled', 'interrupted'].includes(child.state)
136
136
  && (settled.includes(child.runId) ? ['completed', 'failed', 'canceled'].includes(child.state)
137
137
  : !['completed', 'failed', 'canceled'].includes(child.state))
138
138
  && child.usage.modelCalls <= owned.maxModelCalls && child.usage.toolCalls <= owned.maxToolCalls
@@ -152,6 +152,12 @@ export function reduceChildLifecycle(snapshot: RunSnapshot, config: RunConfigura
152
152
  updated.pendingInteraction = { interactionId: `${request.operationKey}:approval`, hostInteractionId: `native-child-${digest(approval)}`,
153
153
  callId: approval.toolCall.callId, operationKey: request.operationKey };
154
154
  updated.interaction = null;
155
+ } else if (!result.errorCode && request.action === 'wait' && result.children?.some(child => child.state === 'paused'
156
+ && pending.includes(child.runId) && (!request.waitForChildRunIds || request.waitForChildRunIds.includes(child.runId)))) {
157
+ // A joined child can still own valid results and an unspent reservation.
158
+ // Preserve that original run until an explicit control resumes or cancels
159
+ // it. Background polls do not block the parent's independent work.
160
+ updated.resumePhase = updated.phase; updated.phase = 'paused'; updated.reason = 'child_paused'; updated.outcome = null;
155
161
  } else if (result.errorCode || !observationOnly && request.action !== 'poll'
156
162
  && pending.some(id => !request.waitForChildRunIds || request.waitForChildRunIds.includes(id))) {
157
163
  updated.phase = 'finalizing'; updated.candidate = null; updated.verification = null;
@@ -37,9 +37,11 @@ export interface ConfigurationInput {
37
37
  sourceReadPolicy?: RunConfiguration['sourceReadPolicy'];
38
38
  outputRecoveryPolicy?: RunConfiguration['outputRecoveryPolicy'];
39
39
  outputRestartPolicy?: RunConfiguration['outputRestartPolicy'];
40
+ approvalOutcomePolicy?: RunConfiguration['approvalOutcomePolicy'];
40
41
  providerRecoveryPolicy?: RunConfiguration['providerRecoveryPolicy'];
41
42
  toolErrorRecoveryPolicy?: RunConfiguration['toolErrorRecoveryPolicy'];
42
43
  toolDiscoveryPolicy?: RunConfiguration['toolDiscoveryPolicy'];
44
+ toolAdmissionPolicy?: RunConfiguration['toolAdmissionPolicy'];
43
45
  todoPolicy?: RunConfiguration['todoPolicy'];
44
46
  toolExecutionPolicy?: RunConfiguration['toolExecutionPolicy'];
45
47
  childTaskPolicy?: RunConfiguration['childTaskPolicy'];
@@ -98,9 +100,11 @@ export function configure(input: ConfigurationInput): RunConfiguration {
98
100
  ...(input.sourceReadPolicy === undefined ? {} : { sourceReadPolicy: input.sourceReadPolicy }),
99
101
  ...(input.outputRecoveryPolicy === undefined ? {} : { outputRecoveryPolicy: input.outputRecoveryPolicy }),
100
102
  ...(input.outputRestartPolicy === undefined ? {} : { outputRestartPolicy: input.outputRestartPolicy }),
103
+ ...(input.approvalOutcomePolicy === undefined ? {} : { approvalOutcomePolicy: input.approvalOutcomePolicy }),
101
104
  ...(input.providerRecoveryPolicy === undefined ? {} : { providerRecoveryPolicy: input.providerRecoveryPolicy }),
102
105
  ...(input.toolErrorRecoveryPolicy === undefined ? {} : { toolErrorRecoveryPolicy: input.toolErrorRecoveryPolicy }),
103
106
  ...(input.toolDiscoveryPolicy === undefined ? {} : { toolDiscoveryPolicy: input.toolDiscoveryPolicy }),
107
+ ...(input.toolAdmissionPolicy === undefined ? {} : { toolAdmissionPolicy: input.toolAdmissionPolicy }),
104
108
  ...(input.todoPolicy === undefined ? {} : { todoPolicy: input.todoPolicy }),
105
109
  ...(input.toolExecutionPolicy === undefined ? {} : { toolExecutionPolicy: input.toolExecutionPolicy }),
106
110
  ...(input.childTaskPolicy === undefined ? {} : { childTaskPolicy: input.childTaskPolicy }),
@@ -155,9 +159,10 @@ export function configure(input: ConfigurationInput): RunConfiguration {
155
159
  && typeof config.hostRecoveryBinding === 'object' && !Array.isArray(config.hostRecoveryBinding), 'invalid_host_recovery_binding');
156
160
  invariant(config.guidancePolicy == null || config.guidancePolicy === 'boundary-guide/v1', 'invalid_guidance_policy');
157
161
  invariant(config.inputPolicy === undefined || config.inputPolicy === 'before-first-model/v1', 'invalid_input_policy');
158
- invariant(config.outputRecoveryPolicy == null || ['task-or-delivery/v1', 'response-boundary/v2'].includes(config.outputRecoveryPolicy), 'invalid_output_recovery_policy');
159
- invariant(config.outputRestartPolicy === undefined || config.outputRestartPolicy === 'per-response/v1'
160
- && config.outputRecoveryPolicy === 'response-boundary/v2', 'invalid_output_restart_policy');
162
+ invariant(config.outputRecoveryPolicy == null || ['task-or-delivery/v1', 'response-boundary/v2', 'response-boundary/v3'].includes(config.outputRecoveryPolicy), 'invalid_output_recovery_policy');
163
+ invariant(config.outputRestartPolicy === undefined || ['per-response/v1', 'per-response/v2'].includes(config.outputRestartPolicy)
164
+ && ['response-boundary/v2', 'response-boundary/v3'].includes(config.outputRecoveryPolicy ?? ''), 'invalid_output_restart_policy');
165
+ invariant(config.approvalOutcomePolicy === undefined || config.approvalOutcomePolicy === 'owner-outcome/v1', 'invalid_approval_outcome_policy');
161
166
  invariant(config.providerRecoveryPolicy == null || config.providerRecoveryPolicy === 'provider-recovery/v2', 'invalid_provider_recovery_policy');
162
167
  invariant(config.toolExecutionPolicy === undefined || config.toolExecutionPolicy === 'owner-execution/v1', 'invalid_tool_execution_policy');
163
168
  invariant(config.toolErrorRecoveryPolicy == null || ['diagnose-before-repeat/v1', 'diagnose-before-repeat/v2'].includes(config.toolErrorRecoveryPolicy), 'invalid_tool_error_recovery_policy');
@@ -244,7 +249,7 @@ export function configure(input: ConfigurationInput): RunConfiguration {
244
249
  const policy = profile.providerCompatibilityPolicy;
245
250
  invariant(policy !== null && typeof policy === 'object' && !Array.isArray(policy)
246
251
  && Object.keys(policy).every(key => ['contract', 'rule'].includes(key))
247
- && ['provider-compat/v1', 'provider-compat/v2', 'provider-compat/v3'].includes(policy.contract)
252
+ && ['provider-compat/v1', 'provider-compat/v2', 'provider-compat/v3', 'provider-compat/v4'].includes(policy.contract)
248
253
  && ['auto', 'permissive', 'openai', 'strict-openai', 'cerebras', 'groq', 'deepseek',
249
254
  'zai', 'kspmas-gateway', 'moonshot', 'mimo'].includes(policy.rule), 'invalid_provider_compatibility_policy');
250
255
  }
@@ -11,7 +11,7 @@ import { sourceWorkingSetGroup } from './source-working-set-group.mjs';
11
11
  import { sourceReuseProjector } from './context-source-reuse.mjs';
12
12
  import { defaultToolPruningThreshold, projectOldToolResults, toolPruningIdleElapsed } from './context-microcompact.mjs';
13
13
  import { summaryContinuityInstructions, validSummaryContinuity } from './summary-continuity.mjs';
14
- import { responseContinuationPairs } from './response-continuation.mjs';
14
+ import { responseBoundaryRecovery, responseContinuationPairs } from './response-continuation.mjs';
15
15
  import { verificationModelView } from './model-surface.mjs';
16
16
  import { currentInstructionContribution } from './context-contributions.mjs';
17
17
 
@@ -118,7 +118,7 @@ function groupsOf(messages: Message[], indexes: number[]): number[][] {
118
118
  }
119
119
  function mandatoryIndexes(snapshot: RunSnapshot, groups: number[][], config: RunConfiguration): Set<number> {
120
120
  const mandatory = new Set<number>(), messages = snapshot.messages;
121
- if (config.outputRecoveryPolicy === 'response-boundary/v2')
121
+ if (responseBoundaryRecovery(config))
122
122
  for (const pair of responseContinuationPairs(messages)) for (const index of pair) mandatory.add(index);
123
123
  // The next inference must observe the just-completed batch, but that must
124
124
  // not exempt all older history from its soft budget on every tool turn.
package/src/contracts.mts CHANGED
@@ -105,7 +105,7 @@ export interface ModelProfile {
105
105
  /** Absent on older Runs; projection policy is frozen at admission. */
106
106
  inlineReasoningPolicy?: { contract: 'profiled-content/v1' | 'profiled-content/v2'; rule: 'auto' | 'permissive' | 'openai'
107
107
  | 'strict-openai' | 'cerebras' | 'groq' | 'deepseek' | 'zai' | 'kspmas-gateway' | 'moonshot' | 'mimo' };
108
- providerCompatibilityPolicy?: { contract: 'provider-compat/v1' | 'provider-compat/v2' | 'provider-compat/v3'; rule: NonNullable<ModelProfile['inlineReasoningPolicy']>['rule'] };
108
+ providerCompatibilityPolicy?: { contract: 'provider-compat/v1' | 'provider-compat/v2' | 'provider-compat/v3' | 'provider-compat/v4'; rule: NonNullable<ModelProfile['inlineReasoningPolicy']>['rule'] };
109
109
  streaming?: boolean; outputTokenParameter?: 'max_tokens' | 'max_completion_tokens';
110
110
  streamTimeoutPolicy?: 'idle/v1'; providerThinkingDisplay?: boolean;
111
111
  /** Absent on historical Runs, whose OpenAI usage reports required equality. */
@@ -290,6 +290,8 @@ export interface RunConfiguration {
290
290
  planModeInitialActive?: boolean;
291
291
  childPlanPolicy?: 'inherit-plan/v1';
292
292
  toolDiscoveryPolicy?: 'local-tool-search/v1';
293
+ /** A premature call may load an already authorized schema, but never dispatch its operation. */
294
+ toolAdmissionPolicy?: 'discover-before-retry/v1';
293
295
  artifactPolicy?: 'runtime-artifacts/v1' | null;
294
296
  /** The execution owner must prepare Host context before the first inference. */
295
297
  inputPolicy?: 'before-first-model/v1';
@@ -307,10 +309,14 @@ export interface RunConfiguration {
307
309
  stopHookContinuationLimit: number; delegationDepth: number;
308
310
  modelRecoveryPolicy: 'manual' | 'pure-inference/v1';
309
311
  guidancePolicy?: 'boundary-guide/v1' | null;
310
- outputRecoveryPolicy?: 'task-or-delivery/v1' | 'response-boundary/v2' | null;
311
- /** Restart allowance belongs to one interrupted response chain. Legacy Runs
312
- * without this policy retain their original run-wide accounting. */
313
- outputRestartPolicy?: 'per-response/v1';
312
+ outputRecoveryPolicy?: 'task-or-delivery/v1' | 'response-boundary/v2' | 'response-boundary/v3' | null;
313
+ /** Restart allowance belongs to one interrupted response chain. v2 pauses
314
+ * exhausted chains for explicit resume instead of terminating the Run.
315
+ * Legacy Runs retain their frozen accounting and exhaustion behavior. */
316
+ outputRestartPolicy?: 'per-response/v1' | 'per-response/v2';
317
+ /** The interactive owner preserves typed Host outcomes and pauses on a
318
+ * non-grant. Children retain the outcome without duplicating that pause. */
319
+ approvalOutcomePolicy?: 'owner-outcome/v1';
314
320
  /** v2 counts consecutive provider failures and pauses (resumable) instead of failing when they run out. */
315
321
  providerRecoveryPolicy?: 'provider-recovery/v2' | null;
316
322
  /** v2 admits a ten-inference diagnostic allowance unless explicitly configured.
@@ -417,7 +423,7 @@ export interface CompletionCandidate {
417
423
  }
418
424
  export interface ChildState {
419
425
  runId: string; sessionId: string; operationKey: string; callId: string;
420
- state: 'prepared' | 'running' | 'awaiting_interaction' | 'completed' | 'failed' | 'canceled' | 'interrupted';
426
+ state: 'prepared' | 'running' | 'paused' | 'awaiting_interaction' | 'completed' | 'failed' | 'canceled' | 'interrupted';
421
427
  reservedModelCalls: number | null; reservedToolCalls: number | null; usage: Usage;
422
428
  notified: boolean; metadata: ObjectValue;
423
429
  }
@@ -527,7 +533,7 @@ export type EffectKind = 'workspace' | 'model' | 'tool' | 'verify' | 'context' |
527
533
  export interface EffectIntent { operationKey: string; kind: EffectKind; payload: ObjectValue; status: 'prepared' | 'running'; claimedAtMs?: number; claimedFence?: number }
528
534
  export interface EffectReceipt { operationKey: string; status: 'committed' | 'failed' | 'uncertain' | 'not_dispatched'; result: ObjectValue }
529
535
  export type CommandKind = 'cancel' | 'policy_revoked' | 'pause' | 'resume' | 'submit_interaction'
530
- | 'reconcile_tool' | 'repair_workspace' | 'steer' | 'guide' | 'promote_child' | 'message_child' | 'cancel_child';
536
+ | 'reconcile_tool' | 'repair_workspace' | 'steer' | 'guide' | 'promote_child' | 'message_child' | 'cancel_child' | 'resume_child';
531
537
  export interface RunCommand { commandId: string; kind: CommandKind; payload: ObjectValue }
532
538
  export interface CommandReceipt { commandId: string; status: 'accepted' | 'duplicate' | 'rejected'; reason: string | null }
533
539
  export interface Lease { owner: string; fence: number; expiresAt: number }
@@ -736,5 +742,5 @@ export const terminal = (phase: Phase): boolean => ['completed', 'failed', 'canc
736
742
  export const emptyUsage = (): Usage => ({ inputTokens: 0, outputTokens: 0, modelCalls: 0, toolCalls: 0, cost: 0 });
737
743
  export const commandPriority: Record<CommandKind, number> = {
738
744
  cancel: 100, policy_revoked: 95, submit_interaction: 90, cancel_child: 85,
739
- pause: 80, resume: 80, reconcile_tool: 75, repair_workspace: 75, promote_child: 70, message_child: 70, steer: 60, guide: 60,
745
+ pause: 80, resume: 80, reconcile_tool: 75, repair_workspace: 75, promote_child: 70, message_child: 70, resume_child: 70, steer: 60, guide: 60,
740
746
  };
package/src/index.mts CHANGED
@@ -49,6 +49,7 @@ export * from './child-budget.mjs';
49
49
  export * from './child-contract.mjs';
50
50
  export * from './child-runtime.mjs';
51
51
  export * from './child-control.mjs';
52
+ export * from './approval-outcome.mjs';
52
53
  export * from './guidance.mjs';
53
54
  export * from './tool-receipt.mjs';
54
55
  export * from './output-recovery.mjs';
package/src/kernel.mts CHANGED
@@ -155,7 +155,7 @@ export class NativeKernel {
155
155
  if (result.status !== 'rejected' && ['cancel', 'policy_revoked'].includes(command.kind)) {
156
156
  this.active.get(runKey(scope, runId))?.abort(new NativeError('command_interrupt'));
157
157
  }
158
- if (result.status === 'accepted' && ['pause', 'promote_child', 'message_child', 'cancel_child'].includes(command.kind)) {
158
+ if (result.status === 'accepted' && ['pause', 'promote_child', 'message_child', 'cancel_child', 'resume_child'].includes(command.kind)) {
159
159
  const observer = this.childObservers.get(runKey(scope, runId));
160
160
  if (observer && (command.kind !== 'pause' || observer.canPause)) observer.controller.abort(
161
161
  new NativeError(command.kind === 'pause' ? 'child_observation_paused' : 'child_observation_promoted'));
@@ -180,6 +180,9 @@ export class NativeKernel {
180
180
  cancelChild(scope: RunScope, runId: string, childRunId: string, commandId: string) {
181
181
  return this.submitChildControl(scope, runId, { commandId, kind: 'cancel_child', payload: { childRunId } });
182
182
  }
183
+ resumeChild(scope: RunScope, runId: string, childRunId: string, commandId: string) {
184
+ return this.submitChildControl(scope, runId, { commandId, kind: 'resume_child', payload: { childRunId } });
185
+ }
183
186
  private submitChildControl(scope: RunScope, runId: string, command: RunCommand) {
184
187
  const record = this.store.load(scope, runId), send = command.kind === 'message_child';
185
188
  // Stable retries retain the original target, even after it becomes terminal.
@@ -190,7 +193,7 @@ export class NativeKernel {
190
193
  invariant(target, 'child_control_not_owned');
191
194
  childControlDelivery(record.snapshot, command, target);
192
195
  const task = this.childTaskStates(record.snapshot).find(task => task.childRunId === target.runId);
193
- invariant(task && (send ? task.canSendInput : task.canCancel), 'child_control_unavailable');
196
+ invariant(task && (send ? task.canSendInput : command.kind === 'resume_child' ? task.canResume === true : task.canCancel), 'child_control_unavailable');
194
197
  return this.submit(scope, runId, command);
195
198
  }
196
199
  private childTaskStates(snapshot: RunSnapshot): ChildTaskControlState[] {
@@ -199,6 +202,7 @@ export class NativeKernel {
199
202
  return copy(this.ports.children?.tasks?.({ scope: copy(snapshot.scope), runId: snapshot.runId, sessionId: snapshot.sessionId,
200
203
  turnId: snapshot.turnId, buildId: snapshot.buildId, parentRunId: snapshot.parentRunId, taskChainId: snapshot.taskChainId }) ?? [])
201
204
  .map(task => ({ ...task, canCancel: task.canCancel && controls,
205
+ ...(task.canResume === undefined ? {} : { canResume: task.canResume && controls }),
202
206
  canSendInput: task.canSendInput && controls && config.childInputPolicy === 'owned-child-input/v1' }));
203
207
  }
204
208
  private async consumeChildControl(snapshot: RunSnapshot, config: RunConfiguration, command: RunCommand, lease: Lease): Promise<void> {
@@ -210,9 +214,13 @@ export class NativeKernel {
210
214
  const target = port.controlTarget(snapshot, id);
211
215
  invariant(target, 'child_control_not_owned');
212
216
  const delivery = childControlDelivery(snapshot, command, target), changes: Partial<RunSnapshot> = { childLifecycleCursor: null };
213
- const facts: { kind: string; payload: ObjectValue }[] = [{ kind: send ? 'child.input_queued' : 'child.cancel_requested',
217
+ const facts: { kind: string; payload: ObjectValue }[] = [{ kind: send ? 'child.input_queued'
218
+ : command.kind === 'resume_child' ? 'child.resume_requested' : 'child.cancel_requested',
214
219
  payload: { childRunId: id, commandId: command.commandId } }];
215
- if (!send && snapshot.childApproval?.childRunId === id) {
220
+ if (['resume_child', 'cancel_child'].includes(command.kind) && snapshot.phase === 'paused' && snapshot.reason === 'child_paused') {
221
+ Object.assign(changes, { phase: snapshot.resumePhase ?? 'preparing_context', resumePhase: null, reason: null });
222
+ }
223
+ if (command.kind === 'cancel_child' && snapshot.childApproval?.childRunId === id) {
216
224
  facts.push({ kind: 'approval.resolved', payload: { interactionId: snapshot.pendingInteraction?.interactionId ?? '',
217
225
  callId: snapshot.childApproval.toolCall.callId, decision: 'canceled', reason: 'child_cancel_requested' } });
218
226
  Object.assign(changes, { childApproval: null, pendingInteraction: null, interaction: null,
@@ -283,6 +291,8 @@ export class NativeKernel {
283
291
  } catch (error) { leaseError = error; controller.abort(new NativeError('lease_lost')); }
284
292
  }, Math.max(10, Math.floor(initial.configuration.limits.leaseMs / 3)));
285
293
  let deliveredRevision = -1;
294
+ let recoveredChildControls = false;
295
+ const wokenChildControls = new Set<string>();
286
296
  let browserChecked = !(initial.snapshot.browserSessionRefs?.length || initial.snapshot.lastBrowserObservation);
287
297
  try {
288
298
  while (true) {
@@ -311,8 +321,9 @@ export class NativeKernel {
311
321
  : prepareToolReceipt(this.store.load(scope, runId), command));
312
322
  continue;
313
323
  }
314
- if (['message_child', 'cancel_child'].includes(command.kind)) {
324
+ if (['message_child', 'cancel_child', 'resume_child'].includes(command.kind)) {
315
325
  await this.consumeChildControl(snapshot, config, command, lease);
326
+ wokenChildControls.add(command.commandId);
316
327
  continue;
317
328
  }
318
329
  const intent = record.pendingIntent;
@@ -332,6 +343,28 @@ export class NativeKernel {
332
343
  }
333
344
  continue;
334
345
  }
346
+ if (!recoveredChildControls) {
347
+ recoveredChildControls = true;
348
+ // The pair transaction may have committed immediately before a
349
+ // process died, leaving a paused child with an existing resume inbox
350
+ // entry but no wake. Recover notification, never re-enqueue a command
351
+ // or infer permission from a child's phase. The owner authenticates
352
+ // the exact inbox entry before it can drive the original child.
353
+ const children = this.ports.children;
354
+ if (config.childLifecyclePolicy === 'owned-background/v2' && snapshot.childRunIds.length
355
+ && snapshot.phase !== 'finalizing' && !snapshot.childTerminalPhase
356
+ && children?.controlTarget && children.wakeControl) {
357
+ const saved = this.store.load(scope, runId);
358
+ const delivered = new Set(saved.events.filter(event => event.kind === 'child.resume_requested')
359
+ .map(event => event.payload.commandId));
360
+ for (const row of saved.commands) if (row.consumed && row.command.kind === 'resume_child'
361
+ && delivered.has(row.command.commandId) && !wokenChildControls.has(row.command.commandId)) {
362
+ const target = children.controlTarget(snapshot, String(row.command.payload.childRunId));
363
+ if (target) await children.wakeControl(snapshot, childControlDelivery(snapshot, row.command, target));
364
+ }
365
+ if (controller.signal.aborted || this.drivingCommands(this.drivingState(scope, runId)).length) continue;
366
+ }
367
+ }
335
368
  if (!browserChecked) {
336
369
  const pending = record.pendingIntent;
337
370
  // Resource loss must not conceal an already claimed effect. Classify