@code-yeongyu/senpi-agent-core 2026.11.3-2 → 2026.11.4-2
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/dist/agent-loop.js +7 -47
- package/dist/conformance/index.d.ts +37 -0
- package/dist/conformance/index.js +25 -0
- package/dist/conformance/loop-core-manifest.d.ts +1 -1
- package/dist/conformance/loop-core-manifest.js +1 -0
- package/dist/conformance/registry.js +31 -1
- package/dist/execution/canonical-json.d.ts +3 -0
- package/dist/execution/canonical-json.js +12 -0
- package/dist/execution/coordinator-codec.d.ts +5 -0
- package/dist/execution/coordinator-codec.js +104 -0
- package/dist/execution/coordinator-consent.d.ts +29 -0
- package/dist/execution/coordinator-consent.js +63 -0
- package/dist/execution/coordinator-plan.d.ts +33 -0
- package/dist/execution/coordinator-plan.js +106 -0
- package/dist/execution/coordinator-sequential.d.ts +15 -0
- package/dist/execution/coordinator-sequential.js +34 -0
- package/dist/execution/coordinator-types.d.ts +161 -0
- package/dist/execution/coordinator-types.js +2 -0
- package/dist/execution/coordinator.d.ts +27 -0
- package/dist/execution/coordinator.js +164 -0
- package/dist/execution/device-files-node.d.ts +8 -0
- package/dist/execution/device-files-node.js +112 -0
- package/dist/execution/device-files.d.ts +80 -0
- package/dist/execution/device-files.js +87 -0
- package/dist/execution/grant-verify.d.ts +70 -0
- package/dist/execution/grant-verify.js +87 -0
- package/dist/execution/ledger.d.ts +2 -0
- package/dist/execution/ledger.js +1 -0
- package/dist/execution/nested-codec.d.ts +5 -0
- package/dist/execution/nested-codec.js +41 -0
- package/dist/execution/nested-types.d.ts +92 -0
- package/dist/execution/nested-types.js +3 -0
- package/dist/execution/nested.d.ts +48 -0
- package/dist/execution/nested.js +206 -0
- package/dist/execution/plane-model.d.ts +33 -0
- package/dist/execution/plane-model.js +80 -0
- package/dist/execution/plane.d.ts +72 -0
- package/dist/execution/plane.js +172 -0
- package/dist/execution/remote-device-files.d.ts +12 -0
- package/dist/execution/remote-device-files.js +84 -0
- package/dist/execution/remote-executor.d.ts +74 -0
- package/dist/execution/remote-executor.js +193 -0
- package/dist/execution/remote-file-call.d.ts +14 -0
- package/dist/execution/remote-file-call.js +30 -0
- package/dist/execution/remote-hand-ledger.d.ts +40 -0
- package/dist/execution/remote-hand-ledger.js +137 -0
- package/dist/execution/remote-link.d.ts +36 -0
- package/dist/execution/remote-link.js +117 -0
- package/dist/execution/remote-protocol.d.ts +104 -0
- package/dist/execution/remote-protocol.js +104 -0
- package/dist/execution/remote-tool-host.d.ts +37 -0
- package/dist/execution/remote-tool-host.js +114 -0
- package/dist/execution/scope-lifecycle.d.ts +81 -0
- package/dist/execution/scope-lifecycle.js +173 -0
- package/dist/execution/testing/batch-cases.d.ts +6 -0
- package/dist/execution/testing/batch-cases.js +210 -0
- package/dist/execution/testing/batch-executor.d.ts +34 -0
- package/dist/execution/testing/batch-executor.js +170 -0
- package/dist/execution/testing/batch-harness.d.ts +58 -0
- package/dist/execution/testing/batch-harness.js +286 -0
- package/dist/execution/testing/batch-registry.d.ts +3 -0
- package/dist/execution/testing/batch-registry.js +30 -0
- package/dist/execution/testing/cancel-cases.d.ts +8 -0
- package/dist/execution/testing/cancel-cases.js +64 -0
- package/dist/execution/testing/consent-cases.d.ts +14 -0
- package/dist/execution/testing/consent-cases.js +66 -0
- package/dist/execution/testing/fault-hand-cases.d.ts +6 -0
- package/dist/execution/testing/fault-hand-cases.js +70 -0
- package/dist/execution/testing/hand-harness.d.ts +48 -0
- package/dist/execution/testing/hand-harness.js +136 -0
- package/dist/execution/testing/kill-batch.d.ts +12 -0
- package/dist/execution/testing/kill-batch.js +70 -0
- package/dist/execution/testing/kill-hand.d.ts +16 -0
- package/dist/execution/testing/kill-hand.js +75 -0
- package/dist/execution/testing/kill-nest.d.ts +6 -0
- package/dist/execution/testing/kill-nest.js +55 -0
- package/dist/execution/testing/kill-wakex.d.ts +6 -0
- package/dist/execution/testing/kill-wakex.js +81 -0
- package/dist/execution/testing/lifecycle-cases.d.ts +9 -0
- package/dist/execution/testing/lifecycle-cases.js +60 -0
- package/dist/execution/testing/lifecycle-registry.d.ts +3 -0
- package/dist/execution/testing/lifecycle-registry.js +19 -0
- package/dist/execution/testing/multi-hand-cases.d.ts +6 -0
- package/dist/execution/testing/multi-hand-cases.js +44 -0
- package/dist/execution/testing/multi-lifecycle-cases.d.ts +4 -0
- package/dist/execution/testing/multi-lifecycle-cases.js +34 -0
- package/dist/execution/testing/multi-seq-cases.d.ts +4 -0
- package/dist/execution/testing/multi-seq-cases.js +46 -0
- package/dist/execution/testing/nest-cases.d.ts +39 -0
- package/dist/execution/testing/nest-cases.js +181 -0
- package/dist/execution/testing/nest-registry.d.ts +3 -0
- package/dist/execution/testing/nest-registry.js +27 -0
- package/dist/execution/testing/scope-cases.d.ts +6 -0
- package/dist/execution/testing/scope-cases.js +49 -0
- package/dist/execution/testing/seq-cases.d.ts +6 -0
- package/dist/execution/testing/seq-cases.js +71 -0
- package/dist/execution/testing/seq-registry.d.ts +3 -0
- package/dist/execution/testing/seq-registry.js +32 -0
- package/dist/execution/testing/wake-exec-cases.d.ts +20 -0
- package/dist/execution/testing/wake-exec-cases.js +147 -0
- package/dist/execution/testing/wake-registry.d.ts +3 -0
- package/dist/execution/testing/wake-registry.js +26 -0
- package/dist/execution/tool-host.d.ts +10 -2
- package/dist/execution/tool-outcome-events.d.ts +11 -0
- package/dist/execution/tool-outcome-events.js +47 -0
- package/dist/execution/wake-inbox.d.ts +25 -0
- package/dist/execution/wake-inbox.js +85 -0
- package/dist/execution/wake-outbox.d.ts +30 -0
- package/dist/execution/wake-outbox.js +87 -0
- package/dist/execution/wake-types.d.ts +45 -0
- package/dist/execution/wake-types.js +3 -0
- package/dist/harness/env/nodejs.js +4 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +19 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.js +1 -0
- package/dist/transport/testing/multi-cases.js +8 -8
- package/package.json +3 -3
package/dist/agent-loop.js
CHANGED
|
@@ -10,6 +10,7 @@ import { getDefaultStreamFn, withEmptyAssistantRecovery } from "./stream-fn.js";
|
|
|
10
10
|
import { createTransportLiveness, StreamKeepAliveTimeoutError } from "./stream-keepalive.js";
|
|
11
11
|
import { prepareAgentToolCallArguments } from "./tool-arguments.js";
|
|
12
12
|
import { resolveCallTool, withToolNameCorrection } from "./tool-name-alias.js";
|
|
13
|
+
import { createErrorToolResult, createToolResultMessage, emitToolExecutionEnd, emitToolExecutionUpdate, emitToolResultMessage, shouldTerminateToolBatch, } from "./execution/tool-outcome-events.js";
|
|
13
14
|
/**
|
|
14
15
|
* Start an agent loop with a new prompt message.
|
|
15
16
|
* The prompt is added to the context and events are emitted for it.
|
|
@@ -946,7 +947,12 @@ async function executeToolCalls(currentContext, assistantMessage, config, signal
|
|
|
946
947
|
scope: config.executionScope ?? { id: crypto.randomUUID(), root: "" },
|
|
947
948
|
calls: toolCalls,
|
|
948
949
|
mode: config.toolExecution ?? "parallel",
|
|
949
|
-
}, {
|
|
950
|
+
}, {
|
|
951
|
+
signal,
|
|
952
|
+
emit,
|
|
953
|
+
recordWitness: config.onExecutionPipeline,
|
|
954
|
+
local: { context: currentContext, assistantMessage },
|
|
955
|
+
});
|
|
950
956
|
}
|
|
951
957
|
async function executeToolCallsSequential(currentContext, assistantMessage, toolCalls, config, signal, emit) {
|
|
952
958
|
const finalizedCalls = [];
|
|
@@ -1070,9 +1076,6 @@ async function runPreparedToolCall(currentContext, assistantMessage, preparation
|
|
|
1070
1076
|
function isSequentialToolCall(currentContext, toolCall) {
|
|
1071
1077
|
return currentContext.tools?.find((tool) => tool.name === toolCall.name)?.executionMode === "sequential";
|
|
1072
1078
|
}
|
|
1073
|
-
function shouldTerminateToolBatch(finalizedCalls) {
|
|
1074
|
-
return finalizedCalls.length > 0 && finalizedCalls.every((finalized) => finalized.result.terminate === true);
|
|
1075
|
-
}
|
|
1076
1079
|
export { prepareAgentToolCallArguments };
|
|
1077
1080
|
export function prepareAgentToolCall(tool, toolCall) {
|
|
1078
1081
|
const preparedToolCall = prepareAgentToolCallArguments(tool, toolCall);
|
|
@@ -1181,15 +1184,6 @@ function abortReleasePromise(signal) {
|
|
|
1181
1184
|
signal.addEventListener("abort", () => resolve(ABORTED), { once: true });
|
|
1182
1185
|
});
|
|
1183
1186
|
}
|
|
1184
|
-
function emitToolExecutionUpdate(toolCall, emit) {
|
|
1185
|
-
return (partialResult) => emit({
|
|
1186
|
-
type: "tool_execution_update",
|
|
1187
|
-
toolCallId: toolCall.id,
|
|
1188
|
-
toolName: toolCall.name,
|
|
1189
|
-
args: toolCall.arguments,
|
|
1190
|
-
partialResult,
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
1187
|
/**
|
|
1194
1188
|
* Run one tool call through the same steps as a model-issued call: argument preparation, schema
|
|
1195
1189
|
* validation, `beforeToolCall`, execution, and `afterToolCall`. Emits no events and adds no
|
|
@@ -1286,38 +1280,4 @@ async function finalizeExecutedToolCall(currentContext, assistantMessage, prepar
|
|
|
1286
1280
|
isError,
|
|
1287
1281
|
};
|
|
1288
1282
|
}
|
|
1289
|
-
function createErrorToolResult(message) {
|
|
1290
|
-
return {
|
|
1291
|
-
content: [{ type: "text", text: message }],
|
|
1292
|
-
details: {},
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
async function emitToolExecutionEnd(finalized, emit) {
|
|
1296
|
-
await emit({
|
|
1297
|
-
type: "tool_execution_end",
|
|
1298
|
-
toolCallId: finalized.toolCall.id,
|
|
1299
|
-
toolName: finalized.toolCall.name,
|
|
1300
|
-
result: finalized.result,
|
|
1301
|
-
isError: finalized.isError,
|
|
1302
|
-
});
|
|
1303
|
-
}
|
|
1304
|
-
function createToolResultMessage(finalized) {
|
|
1305
|
-
return {
|
|
1306
|
-
role: "toolResult",
|
|
1307
|
-
toolCallId: finalized.toolCall.id,
|
|
1308
|
-
toolName: finalized.toolCall.name,
|
|
1309
|
-
// Untyped tools (JS extensions) can return results without content; normalize
|
|
1310
|
-
// so the null never enters session history or provider payloads.
|
|
1311
|
-
content: finalized.result.content ?? [],
|
|
1312
|
-
details: finalized.result.details,
|
|
1313
|
-
usage: finalized.result.usage,
|
|
1314
|
-
...(finalized.result.addedToolNames?.length ? { addedToolNames: finalized.result.addedToolNames } : {}),
|
|
1315
|
-
isError: finalized.isError,
|
|
1316
|
-
timestamp: Date.now(),
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
async function emitToolResultMessage(toolResultMessage, emit) {
|
|
1320
|
-
await emit({ type: "message_start", message: toolResultMessage });
|
|
1321
|
-
await emit({ type: "message_end", message: toolResultMessage });
|
|
1322
|
-
}
|
|
1323
1283
|
//# sourceMappingURL=agent-loop.js.map
|
|
@@ -44,5 +44,42 @@ export type { ExecutionLedger } from "../execution/ledger.ts";
|
|
|
44
44
|
export type { ExecutionAdmission, ExecutionCommand, ExecutionEntry, ExecutionEvent, ExecutionKey, ExecutionOutcome, ExecutionProgress, FrozenCall, LedgerReply, } from "../execution/ledger-types.ts";
|
|
45
45
|
export { LEDGER_CASES } from "../execution/testing/ledger-cases.ts";
|
|
46
46
|
export { KILL_LEDGER_CASES, KILL_LEDGER_DECLARATIONS } from "../execution/testing/kill-ledger.ts";
|
|
47
|
+
export { FAULT_HAND_CASES } from "../execution/testing/fault-hand-cases.ts";
|
|
48
|
+
export type { HandCaseAdapters } from "../execution/testing/hand-harness.ts";
|
|
49
|
+
export type { KillHandDeclaration } from "../execution/testing/kill-hand.ts";
|
|
50
|
+
export { KILL_HAND_CASES, KILL_HAND_DECLARATIONS } from "../execution/testing/kill-hand.ts";
|
|
51
|
+
export { MULTI_HAND_CASES } from "../execution/testing/multi-hand-cases.ts";
|
|
47
52
|
export type { KillLedgerDeclaration } from "../execution/testing/kill-ledger.ts";
|
|
53
|
+
export type { BatchCoordinator, BatchCoordinatorOptions } from "../execution/coordinator.ts";
|
|
54
|
+
export { BatchManifestConflictError, createBatchCoordinator } from "../execution/coordinator.ts";
|
|
55
|
+
export { interruptedReplayText } from "../execution/coordinator-plan.ts";
|
|
56
|
+
export type { BatchCallPlan, BatchDecision, BatchExecutor, BatchManifest, BatchPlan, BatchRecord, BatchResult, CallOutcome, ExecutionRef, ManifestCall, PrepareReply, PrepareRequest, SettleReply, } from "../execution/coordinator-types.ts";
|
|
57
|
+
export { BATCH_CASES } from "../execution/testing/batch-cases.ts";
|
|
58
|
+
export type { SequentialCoordinator } from "../execution/coordinator-sequential.ts";
|
|
59
|
+
export { createSequentialCoordinator } from "../execution/coordinator-sequential.ts";
|
|
60
|
+
export { MULTI_SEQ_CASES } from "../execution/testing/multi-seq-cases.ts";
|
|
61
|
+
export { SEQ_CASES } from "../execution/testing/seq-cases.ts";
|
|
62
|
+
export { CONSENT_CASES } from "../execution/testing/consent-cases.ts";
|
|
63
|
+
export type { NestedAdmissionControl, NestedAdmissionOptions } from "../execution/nested.ts";
|
|
64
|
+
export { createNestedAdmission } from "../execution/nested.ts";
|
|
65
|
+
export { NEST_CASES } from "../execution/testing/nest-cases.ts";
|
|
66
|
+
export { CANCEL_CASES } from "../execution/testing/cancel-cases.ts";
|
|
67
|
+
export { KILL_NEST_CASES } from "../execution/testing/kill-nest.ts";
|
|
68
|
+
export type { WakeInbox, WakeInboxOptions } from "../execution/wake-inbox.ts";
|
|
69
|
+
export { createWakeInbox } from "../execution/wake-inbox.ts";
|
|
70
|
+
export type { WakeOutbox, WakeOutboxOptions } from "../execution/wake-outbox.ts";
|
|
71
|
+
export { createWakeOutbox } from "../execution/wake-outbox.ts";
|
|
72
|
+
export type { WakeEvent, WakeReceipt } from "../execution/wake-types.ts";
|
|
73
|
+
export { WAKE_RETENTION_MS } from "../execution/wake-types.ts";
|
|
74
|
+
export { WAKE_EXEC_CASES } from "../execution/testing/wake-exec-cases.ts";
|
|
75
|
+
export { KILL_WAKEX_CASES } from "../execution/testing/kill-wakex.ts";
|
|
76
|
+
export type { ScopeBinding, ScopeLifecycle, ScopeLifecycleOptions, ScopeRecord } from "../execution/scope-lifecycle.ts";
|
|
77
|
+
export { createScopeLifecycle } from "../execution/scope-lifecycle.ts";
|
|
78
|
+
export { LIFECYCLE_CASES } from "../execution/testing/lifecycle-cases.ts";
|
|
79
|
+
export { SCOPE_CASES } from "../execution/testing/scope-cases.ts";
|
|
80
|
+
export { MULTI_LIFECYCLE_CASES } from "../execution/testing/multi-lifecycle-cases.ts";
|
|
81
|
+
export type { BatchCaseAdapters, BatchExecutorConformanceAdapter, ExecutorOpenOptions, PausePoint, } from "../execution/testing/batch-executor.ts";
|
|
82
|
+
export { referenceBatchExecutor } from "../execution/testing/batch-executor.ts";
|
|
83
|
+
export type { KillBatchDeclaration } from "../execution/testing/kill-batch.ts";
|
|
84
|
+
export { KILL_BATCH_CASES, KILL_BATCH_DECLARATIONS } from "../execution/testing/kill-batch.ts";
|
|
48
85
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -23,4 +23,29 @@ export { TransportClosedError } from "../transport/transport.js";
|
|
|
23
23
|
export { createExecutionLedger } from "../execution/ledger.js";
|
|
24
24
|
export { LEDGER_CASES } from "../execution/testing/ledger-cases.js";
|
|
25
25
|
export { KILL_LEDGER_CASES, KILL_LEDGER_DECLARATIONS } from "../execution/testing/kill-ledger.js";
|
|
26
|
+
export { FAULT_HAND_CASES } from "../execution/testing/fault-hand-cases.js";
|
|
27
|
+
export { KILL_HAND_CASES, KILL_HAND_DECLARATIONS } from "../execution/testing/kill-hand.js";
|
|
28
|
+
export { MULTI_HAND_CASES } from "../execution/testing/multi-hand-cases.js";
|
|
29
|
+
export { BatchManifestConflictError, createBatchCoordinator } from "../execution/coordinator.js";
|
|
30
|
+
export { interruptedReplayText } from "../execution/coordinator-plan.js";
|
|
31
|
+
export { BATCH_CASES } from "../execution/testing/batch-cases.js";
|
|
32
|
+
export { createSequentialCoordinator } from "../execution/coordinator-sequential.js";
|
|
33
|
+
export { MULTI_SEQ_CASES } from "../execution/testing/multi-seq-cases.js";
|
|
34
|
+
export { SEQ_CASES } from "../execution/testing/seq-cases.js";
|
|
35
|
+
export { CONSENT_CASES } from "../execution/testing/consent-cases.js";
|
|
36
|
+
export { createNestedAdmission } from "../execution/nested.js";
|
|
37
|
+
export { NEST_CASES } from "../execution/testing/nest-cases.js";
|
|
38
|
+
export { CANCEL_CASES } from "../execution/testing/cancel-cases.js";
|
|
39
|
+
export { KILL_NEST_CASES } from "../execution/testing/kill-nest.js";
|
|
40
|
+
export { createWakeInbox } from "../execution/wake-inbox.js";
|
|
41
|
+
export { createWakeOutbox } from "../execution/wake-outbox.js";
|
|
42
|
+
export { WAKE_RETENTION_MS } from "../execution/wake-types.js";
|
|
43
|
+
export { WAKE_EXEC_CASES } from "../execution/testing/wake-exec-cases.js";
|
|
44
|
+
export { KILL_WAKEX_CASES } from "../execution/testing/kill-wakex.js";
|
|
45
|
+
export { createScopeLifecycle } from "../execution/scope-lifecycle.js";
|
|
46
|
+
export { LIFECYCLE_CASES } from "../execution/testing/lifecycle-cases.js";
|
|
47
|
+
export { SCOPE_CASES } from "../execution/testing/scope-cases.js";
|
|
48
|
+
export { MULTI_LIFECYCLE_CASES } from "../execution/testing/multi-lifecycle-cases.js";
|
|
49
|
+
export { referenceBatchExecutor } from "../execution/testing/batch-executor.js";
|
|
50
|
+
export { KILL_BATCH_CASES, KILL_BATCH_DECLARATIONS } from "../execution/testing/kill-batch.js";
|
|
26
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Host adapters, carriers, persistence implementations and the Node harness stay outside.
|
|
5
5
|
* Extend this closure when adding loop modules; never add a host implementation to it.
|
|
6
6
|
*/
|
|
7
|
-
export declare const LOOP_CORE_MODULES: readonly ["agent.ts", "agent-loop.ts", "assistant-terminal-state.ts", "empty-assistant-recovery.ts", "internal-events.ts", "local-failure.ts", "response-timing.ts", "stream-fn.ts", "stream-keepalive.ts", "tool-arguments.ts", "tool-name-alias.ts", "types.ts", "durable/store.ts", "execution/tool-host.ts", "durable/store-admission.ts", "durable/wake-host.ts", "transport/transport.ts"];
|
|
7
|
+
export declare const LOOP_CORE_MODULES: readonly ["agent.ts", "agent-loop.ts", "assistant-terminal-state.ts", "empty-assistant-recovery.ts", "internal-events.ts", "local-failure.ts", "response-timing.ts", "stream-fn.ts", "stream-keepalive.ts", "tool-arguments.ts", "tool-name-alias.ts", "types.ts", "durable/store.ts", "execution/tool-host.ts", "execution/tool-outcome-events.ts", "durable/store-admission.ts", "durable/wake-host.ts", "transport/transport.ts"];
|
|
8
8
|
/**
|
|
9
9
|
* Existing portable model/message utilities and schema types, not provider runtimes.
|
|
10
10
|
* Exact specifiers deliberately exclude compat, OAuth, SDKs and host-specific subpaths.
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { KILL_HAND_DECLARATIONS } from "../execution/testing/kill-hand.js";
|
|
2
|
+
import { BATCH_REGISTRY } from "../execution/testing/batch-registry.js";
|
|
1
3
|
import { LEDGER_REGISTRY } from "../execution/testing/ledger-registry.js";
|
|
4
|
+
import { LIFECYCLE_REGISTRY } from "../execution/testing/lifecycle-registry.js";
|
|
5
|
+
import { NEST_REGISTRY } from "../execution/testing/nest-registry.js";
|
|
6
|
+
import { WAKE_EXEC_REGISTRY } from "../execution/testing/wake-registry.js";
|
|
7
|
+
import { SEQ_REGISTRY } from "../execution/testing/seq-registry.js";
|
|
2
8
|
export const ADAPTER_KINDS = ["store", "wake", "transport", "executor", "host"];
|
|
3
9
|
/**
|
|
4
10
|
* Every case of the durable-core conformance suite (packages/agent/docs/durable-core-adr.md). A change that adds cases
|
|
@@ -27,6 +33,24 @@ const wakeCase = (id, impl, expected) => ({
|
|
|
27
33
|
adapters: ["store", "wake"],
|
|
28
34
|
expected,
|
|
29
35
|
});
|
|
36
|
+
const HAND_INTRO = "#5482";
|
|
37
|
+
const handCase = (id, impl, expected) => ({
|
|
38
|
+
id,
|
|
39
|
+
impl,
|
|
40
|
+
intro: HAND_INTRO,
|
|
41
|
+
adapters: ["store", "transport", "executor"],
|
|
42
|
+
expected,
|
|
43
|
+
});
|
|
44
|
+
const KILL_HAND_IMPL = "packages/agent/src/execution/testing/kill-hand.ts";
|
|
45
|
+
const MULTI_HAND_IMPL = "packages/agent/src/execution/testing/multi-hand-cases.ts";
|
|
46
|
+
const FAULT_HAND_IMPL = "packages/agent/src/execution/testing/fault-hand-cases.ts";
|
|
47
|
+
const HAND_REGISTRY = [
|
|
48
|
+
...KILL_HAND_DECLARATIONS.map(({ id, expected }) => handCase(id, KILL_HAND_IMPL, expected)),
|
|
49
|
+
handCase("MULTI-HAND-01", MULTI_HAND_IMPL, "N scopes batch at once on one hand; each scope's calls start in lane order"),
|
|
50
|
+
handCase("MULTI-KILL-01", MULTI_HAND_IMPL, "cross-machine: a hand killed with several scopes in flight; each ends hand_restarted, uncertain, never rerun"),
|
|
51
|
+
...["slow", "lossy", "laggy", "flap", "drop-reattach"].map((profile, index) => handCase(`FAULT-HAND-0${index + 1}`, FAULT_HAND_IMPL, `${profile} profile: every call settles with its unfaulted result, runs once, per-scope order kept`)),
|
|
52
|
+
handCase("FAULT-HAND-MULTI-01", FAULT_HAND_IMPL, "hand unreachable past the resume window: dependent calls pause, then each scope resumes exactly once"),
|
|
53
|
+
];
|
|
30
54
|
const storeCase = (id, impl, expected) => ({
|
|
31
55
|
id,
|
|
32
56
|
impl,
|
|
@@ -36,6 +60,11 @@ const storeCase = (id, impl, expected) => ({
|
|
|
36
60
|
});
|
|
37
61
|
export const CONFORMANCE_REGISTRY = [
|
|
38
62
|
...LEDGER_REGISTRY,
|
|
63
|
+
...BATCH_REGISTRY,
|
|
64
|
+
...SEQ_REGISTRY,
|
|
65
|
+
...NEST_REGISTRY,
|
|
66
|
+
...WAKE_EXEC_REGISTRY,
|
|
67
|
+
...LIFECYCLE_REGISTRY,
|
|
39
68
|
storeCase("STORE-01", STORE_CASES_IMPL, "a commit adopts once, after its batch is durable; every instance sees each batch whole"),
|
|
40
69
|
storeCase("STORE-02", STORE_CASES_IMPL, "a cut at every write point of a commit leaves nothing of it durable, with no adopt and no seq burned"),
|
|
41
70
|
storeCase("STORE-03", STORE_CASES_IMPL, "concurrent admissions run one at a time in admission order; a refused mutation releases the line"),
|
|
@@ -67,11 +96,12 @@ export const CONFORMANCE_REGISTRY = [
|
|
|
67
96
|
transportCase("TRANSPORT-03", TRANSPORT_CASES_IMPL, "backpressure: a stalled receiver bounds its lane's senders; sends resolve in order once it drains"),
|
|
68
97
|
transportCase("MULTI-LANE-01", MULTI_CASES_IMPL, "N scopes over one transport keep per-scope order and interleave"),
|
|
69
98
|
transportCase("MULTI-FAIR-01", MULTI_CASES_IMPL, "a stalled or long lane in A does not starve B: B is delivered within a bounded number of A's frames"),
|
|
70
|
-
transportCase("MULTI-FAIR-
|
|
99
|
+
transportCase("MULTI-FAIR-03", MULTI_CASES_IMPL, "a frame lost on one lane is resent on that lane's own deadline: another lane's ACK progress never postpones it"),
|
|
71
100
|
faultCase(1, "slow"),
|
|
72
101
|
faultCase(2, "lossy"),
|
|
73
102
|
faultCase(3, "laggy"),
|
|
74
103
|
faultCase(4, "flap"),
|
|
75
104
|
faultCase(5, "drop-reattach"),
|
|
105
|
+
...HAND_REGISTRY,
|
|
76
106
|
];
|
|
77
107
|
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** JSON with object keys sorted, so two values with the same fields compare equal whatever their key order. */
|
|
2
|
+
export function canonicalJson(value) {
|
|
3
|
+
if (Array.isArray(value))
|
|
4
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
5
|
+
if (value !== null && typeof value === "object")
|
|
6
|
+
return `{${Object.keys(value)
|
|
7
|
+
.sort()
|
|
8
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
9
|
+
.join(",")}}`;
|
|
10
|
+
return JSON.stringify(value);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=canonical-json.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StoreValue } from "../durable/store.ts";
|
|
2
|
+
import type { BatchRecord } from "./coordinator-types.ts";
|
|
3
|
+
/** Stored JSON crosses its schema boundary once, on read. A corrupt record must never look like a missing batch. */
|
|
4
|
+
export declare function decodeBatchRecord(value: StoreValue): BatchRecord;
|
|
5
|
+
//# sourceMappingURL=coordinator-codec.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
function object(value) {
|
|
2
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
function strings(value, keys) {
|
|
5
|
+
return keys.every((key) => typeof value[key] === "string");
|
|
6
|
+
}
|
|
7
|
+
function numbers(value, keys) {
|
|
8
|
+
return keys.every((key) => typeof value[key] === "number" && Number.isFinite(value[key]));
|
|
9
|
+
}
|
|
10
|
+
function terminal(value) {
|
|
11
|
+
if (!object(value) || typeof value.hooksRan !== "boolean" || typeof value.uncertain !== "boolean")
|
|
12
|
+
return false;
|
|
13
|
+
return value.reason === "result" || value.reason === "blocked"
|
|
14
|
+
? value.value !== undefined
|
|
15
|
+
: ["cancelled", "lease_expired", "hand_restarted", "uncertain"].includes(String(value.reason));
|
|
16
|
+
}
|
|
17
|
+
function manifestCall(value) {
|
|
18
|
+
return (object(value) &&
|
|
19
|
+
strings(value, ["executionId", "executor", "name", "requestDigest"]) &&
|
|
20
|
+
numbers(value, ["sourceIndex", "wave"]) &&
|
|
21
|
+
typeof value.sequential === "boolean" &&
|
|
22
|
+
value.args !== undefined &&
|
|
23
|
+
Array.isArray(value.dependsOn) &&
|
|
24
|
+
value.dependsOn.every((dependency) => typeof dependency === "number"));
|
|
25
|
+
}
|
|
26
|
+
function manifest(value) {
|
|
27
|
+
return (object(value) &&
|
|
28
|
+
strings(value, ["batchId", "scope", "workspace", "issuer", "manifestDigest"]) &&
|
|
29
|
+
numbers(value, ["generation", "admittedAt", "leaseUntil"]) &&
|
|
30
|
+
Array.isArray(value.calls) &&
|
|
31
|
+
value.calls.every(manifestCall));
|
|
32
|
+
}
|
|
33
|
+
function prepareReply(value) {
|
|
34
|
+
if (!object(value))
|
|
35
|
+
return false;
|
|
36
|
+
switch (value.kind) {
|
|
37
|
+
case "prepared":
|
|
38
|
+
case "prepared_awaiting_consent":
|
|
39
|
+
return typeof value.frozenDigest === "string";
|
|
40
|
+
case "blocked":
|
|
41
|
+
return value.result !== undefined;
|
|
42
|
+
case "batch_abort":
|
|
43
|
+
return true;
|
|
44
|
+
case "settled":
|
|
45
|
+
return terminal(value.outcome);
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function callOutcome(value) {
|
|
51
|
+
if (!object(value))
|
|
52
|
+
return false;
|
|
53
|
+
switch (value.kind) {
|
|
54
|
+
case "result":
|
|
55
|
+
return value.value !== undefined;
|
|
56
|
+
case "blocked":
|
|
57
|
+
return value.result !== undefined;
|
|
58
|
+
case "not_run":
|
|
59
|
+
return value.cause === "batch_abort" || value.cause === "interrupted_preparation";
|
|
60
|
+
case "interrupted":
|
|
61
|
+
return typeof value.reason === "string" && typeof value.uncertain === "boolean";
|
|
62
|
+
default:
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function consentRecord(value) {
|
|
67
|
+
return (object(value) &&
|
|
68
|
+
(value.gate === "raw" || value.gate === "frozen") &&
|
|
69
|
+
typeof value.digest === "string" &&
|
|
70
|
+
(value.answer === "approved" || value.answer === "denied" || value.answer === "expired"));
|
|
71
|
+
}
|
|
72
|
+
function record(value) {
|
|
73
|
+
if (!object(value) || !manifest(value.manifest))
|
|
74
|
+
return false;
|
|
75
|
+
const size = value.manifest.calls.length;
|
|
76
|
+
const { prepares, released, outcomes, decision, consents } = value;
|
|
77
|
+
return ((consents === undefined ||
|
|
78
|
+
(Array.isArray(consents) &&
|
|
79
|
+
consents.length === size &&
|
|
80
|
+
consents.every((entry) => entry === null || consentRecord(entry)))) &&
|
|
81
|
+
(decision === null || decision === "RELEASE" || decision === "ABORT") &&
|
|
82
|
+
Array.isArray(prepares) &&
|
|
83
|
+
prepares.length === size &&
|
|
84
|
+
prepares.every((reply) => reply === null || prepareReply(reply)) &&
|
|
85
|
+
Array.isArray(released) &&
|
|
86
|
+
released.length === size &&
|
|
87
|
+
released.every((mark) => typeof mark === "boolean") &&
|
|
88
|
+
Array.isArray(outcomes) &&
|
|
89
|
+
outcomes.length === size &&
|
|
90
|
+
outcomes.every((outcome) => outcome === null || callOutcome(outcome)));
|
|
91
|
+
}
|
|
92
|
+
class BatchRecordCorruptError extends Error {
|
|
93
|
+
constructor() {
|
|
94
|
+
super("invalid durable batch record");
|
|
95
|
+
this.name = "BatchRecordCorruptError";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Stored JSON crosses its schema boundary once, on read. A corrupt record must never look like a missing batch. */
|
|
99
|
+
export function decodeBatchRecord(value) {
|
|
100
|
+
if (!record(value))
|
|
101
|
+
throw new BatchRecordCorruptError();
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=coordinator-codec.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BatchConsent, BatchExecutor, ConsentRecord, ExecutionRef, ManifestCall, PrepareReply } from "./coordinator-types.ts";
|
|
2
|
+
/** What a call needs from the consent port, and how an answer is recorded before the step it decides. */
|
|
3
|
+
export interface ConsentStep {
|
|
4
|
+
readonly consent: BatchConsent;
|
|
5
|
+
readonly executor: BatchExecutor;
|
|
6
|
+
readonly ref: ExecutionRef;
|
|
7
|
+
readonly call: ManifestCall;
|
|
8
|
+
readonly leaseUntil: number;
|
|
9
|
+
/** The call's answered consent, if one is durable. */
|
|
10
|
+
readonly recorded: ConsentRecord | null;
|
|
11
|
+
readonly record: (answer: ConsentRecord) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gate A, before preparation: a raw call that needs consent is prepared only after an approval of its request digest,
|
|
15
|
+
* which the executor then treats as authorized. A refusal ran nothing, so it is a blocked per-call result.
|
|
16
|
+
*/
|
|
17
|
+
export declare function gateRawCall(step: ConsentStep): Promise<{
|
|
18
|
+
readonly blocked: PrepareReply;
|
|
19
|
+
} | {
|
|
20
|
+
readonly authorizedDigest?: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Gate B, after preparation: the approval binds the frozen digest and the executor releases without rerunning hooks.
|
|
24
|
+
* A denial is a blocked per-call result; an expiry (or an approval the lease already outran) settles the call
|
|
25
|
+
* `lease_expired` at the endpoint, which ABORTs the batch's unreleased calls. Nothing is ever prepared again: no
|
|
26
|
+
* automatic successor.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveFrozenConsent(step: ConsentStep, frozenDigest: string): Promise<PrepareReply>;
|
|
29
|
+
//# sourceMappingURL=coordinator-consent.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const denied = (gate, answer) => ({
|
|
2
|
+
kind: "blocked",
|
|
3
|
+
result: { reason: "consent_denied", gate, answer },
|
|
4
|
+
});
|
|
5
|
+
/** The executor no longer knows a call it prepared (design 5.6.2 "a lost prepared execution"): uncertain, never rerun. */
|
|
6
|
+
const lost = { reason: "uncertain", hooksRan: true, uncertain: true };
|
|
7
|
+
/**
|
|
8
|
+
* The approver reports the lease ran out while the call awaited Gate B. Nothing is sent to the executor: its own lease
|
|
9
|
+
* clock settles the call `lease_expired` (an abort would record `cancelled` while its clock is behind the brain's).
|
|
10
|
+
*/
|
|
11
|
+
const expired = { reason: "lease_expired", hooksRan: true, uncertain: true };
|
|
12
|
+
async function answer(step, gate, digest) {
|
|
13
|
+
const { recorded } = step;
|
|
14
|
+
if (recorded !== null && recorded.gate === gate && recorded.digest === digest)
|
|
15
|
+
return recorded.answer;
|
|
16
|
+
const given = await step.consent.approve({
|
|
17
|
+
...step.ref,
|
|
18
|
+
gate,
|
|
19
|
+
digest,
|
|
20
|
+
name: step.call.name,
|
|
21
|
+
leaseUntil: step.leaseUntil,
|
|
22
|
+
});
|
|
23
|
+
await step.record({ gate, digest, answer: given });
|
|
24
|
+
return given;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gate A, before preparation: a raw call that needs consent is prepared only after an approval of its request digest,
|
|
28
|
+
* which the executor then treats as authorized. A refusal ran nothing, so it is a blocked per-call result.
|
|
29
|
+
*/
|
|
30
|
+
export async function gateRawCall(step) {
|
|
31
|
+
const { call } = step;
|
|
32
|
+
if (!step.consent.needsConsent({ name: call.name, args: call.args }))
|
|
33
|
+
return {};
|
|
34
|
+
const given = await answer(step, "raw", call.requestDigest);
|
|
35
|
+
return given === "approved" ? { authorizedDigest: call.requestDigest } : { blocked: denied("raw", given) };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gate B, after preparation: the approval binds the frozen digest and the executor releases without rerunning hooks.
|
|
39
|
+
* A denial is a blocked per-call result; an expiry (or an approval the lease already outran) settles the call
|
|
40
|
+
* `lease_expired` at the endpoint, which ABORTs the batch's unreleased calls. Nothing is ever prepared again: no
|
|
41
|
+
* automatic successor.
|
|
42
|
+
*/
|
|
43
|
+
export async function resolveFrozenConsent(step, frozenDigest) {
|
|
44
|
+
const given = await answer(step, "frozen", frozenDigest);
|
|
45
|
+
if (given === "denied") {
|
|
46
|
+
await step.executor.abort(step.ref);
|
|
47
|
+
return denied("frozen", given);
|
|
48
|
+
}
|
|
49
|
+
if (given === "expired")
|
|
50
|
+
return { kind: "settled", outcome: expired };
|
|
51
|
+
const reply = await consentOn(step.executor, step.ref, frozenDigest);
|
|
52
|
+
if (reply.kind === "prepared")
|
|
53
|
+
return { kind: "prepared", frozenDigest };
|
|
54
|
+
if (reply.kind === "unknown_execution")
|
|
55
|
+
return { kind: "settled", outcome: lost };
|
|
56
|
+
return { kind: "settled", outcome: reply.outcome };
|
|
57
|
+
}
|
|
58
|
+
function consentOn(executor, ref, frozenDigest) {
|
|
59
|
+
if (executor.consent === undefined)
|
|
60
|
+
throw new Error(`executor answered prepared_awaiting_consent for ${ref.executionId} but cannot take consent`);
|
|
61
|
+
return executor.consent(ref, frozenDigest);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=coordinator-consent.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BatchManifest, BatchPlan, CallOutcome, PrepareReply, SettleReply } from "./coordinator-types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Release dependencies exactly as today's scheduler assigns them (agent-loop.ts, executeToolCallsParallel): a
|
|
4
|
+
* sequential call waits for the previous sequential call and every parallel call since; a parallel call waits for the
|
|
5
|
+
* previous sequential call only.
|
|
6
|
+
*/
|
|
7
|
+
export declare function batchDependencies(calls: readonly {
|
|
8
|
+
readonly sequential: boolean;
|
|
9
|
+
}[]): {
|
|
10
|
+
readonly dependsOn: number[];
|
|
11
|
+
readonly wave: number;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function buildBatchManifest(issuer: string, plan: BatchPlan): Promise<BatchManifest>;
|
|
14
|
+
/**
|
|
15
|
+
* A reply after which no later call is prepared and the decision is ABORT. A raw `settled` outcome other than a result
|
|
16
|
+
* fails closed, `blocked` included: the ledger stores a blocked call and a preflight abort under the same reason, and
|
|
17
|
+
* an executor that stopped a preparation itself answers `blocked` or `batch_abort` instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function abortCause(reply: PrepareReply): "batch_abort" | "interrupted_preparation" | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `index` and everything it transitively depends on have final outcomes. A call that settled at preparation
|
|
22
|
+
* still finishes only after its own dependencies, as today's scheduler awaits them before every call's outcome.
|
|
23
|
+
*/
|
|
24
|
+
export declare function finished(calls: readonly {
|
|
25
|
+
readonly dependsOn: readonly number[];
|
|
26
|
+
}[], outcomes: readonly unknown[], index: number): boolean;
|
|
27
|
+
export declare function settledOutcome(reply: SettleReply): CallOutcome;
|
|
28
|
+
/**
|
|
29
|
+
* What the model is shown for a call whose run was cut short, so a replay equals today's (plan X12, K4): today's
|
|
30
|
+
* pair-repair placeholder, never a rerun. Undefined for a call that settled, was blocked, or was aborted by a hook.
|
|
31
|
+
*/
|
|
32
|
+
export declare function interruptedReplayText(outcome: CallOutcome): string | undefined;
|
|
33
|
+
//# sourceMappingURL=coordinator-plan.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { TOOL_RESULT_PLACEHOLDER } from "@earendil-works/pi-ai";
|
|
2
|
+
/**
|
|
3
|
+
* Release dependencies exactly as today's scheduler assigns them (agent-loop.ts, executeToolCallsParallel): a
|
|
4
|
+
* sequential call waits for the previous sequential call and every parallel call since; a parallel call waits for the
|
|
5
|
+
* previous sequential call only.
|
|
6
|
+
*/
|
|
7
|
+
export function batchDependencies(calls) {
|
|
8
|
+
const result = [];
|
|
9
|
+
let previousSequential;
|
|
10
|
+
let parallelSince = [];
|
|
11
|
+
for (const [index, call] of calls.entries()) {
|
|
12
|
+
const anchor = previousSequential === undefined ? [] : [previousSequential];
|
|
13
|
+
const dependsOn = call.sequential ? [...anchor, ...parallelSince] : anchor;
|
|
14
|
+
const wave = Math.max(-1, ...dependsOn.map((dependency) => result[dependency]?.wave ?? -1)) + 1;
|
|
15
|
+
result.push({ dependsOn, wave });
|
|
16
|
+
if (call.sequential) {
|
|
17
|
+
previousSequential = index;
|
|
18
|
+
parallelSince = [];
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
parallelSince.push(index);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function canonical(value) {
|
|
26
|
+
if (Array.isArray(value))
|
|
27
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
28
|
+
if (value !== null && typeof value === "object") {
|
|
29
|
+
const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
30
|
+
return `{${entries.map(([key, inner]) => `${JSON.stringify(key)}:${canonical(inner)}`).join(",")}}`;
|
|
31
|
+
}
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
}
|
|
34
|
+
async function digest(value) {
|
|
35
|
+
const bytes = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonical(value)));
|
|
36
|
+
return Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
37
|
+
}
|
|
38
|
+
export async function buildBatchManifest(issuer, plan) {
|
|
39
|
+
const dependencies = batchDependencies(plan.calls);
|
|
40
|
+
const calls = [];
|
|
41
|
+
for (const [sourceIndex, call] of plan.calls.entries()) {
|
|
42
|
+
const placement = dependencies[sourceIndex] ?? { dependsOn: [], wave: 0 };
|
|
43
|
+
calls.push({
|
|
44
|
+
...call,
|
|
45
|
+
sourceIndex,
|
|
46
|
+
dependsOn: placement.dependsOn,
|
|
47
|
+
wave: placement.wave,
|
|
48
|
+
requestDigest: await digest({ name: call.name, args: call.args }),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const { calls: _calls, ...header } = plan;
|
|
52
|
+
return { ...header, issuer, calls, manifestDigest: await digest({ ...header, issuer, calls }) };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A reply after which no later call is prepared and the decision is ABORT. A raw `settled` outcome other than a result
|
|
56
|
+
* fails closed, `blocked` included: the ledger stores a blocked call and a preflight abort under the same reason, and
|
|
57
|
+
* an executor that stopped a preparation itself answers `blocked` or `batch_abort` instead.
|
|
58
|
+
*/
|
|
59
|
+
export function abortCause(reply) {
|
|
60
|
+
if (reply.kind === "batch_abort")
|
|
61
|
+
return "batch_abort";
|
|
62
|
+
if (reply.kind === "settled" && reply.outcome.reason !== "result")
|
|
63
|
+
return "interrupted_preparation";
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether `index` and everything it transitively depends on have final outcomes. A call that settled at preparation
|
|
68
|
+
* still finishes only after its own dependencies, as today's scheduler awaits them before every call's outcome.
|
|
69
|
+
*/
|
|
70
|
+
export function finished(calls, outcomes, index) {
|
|
71
|
+
const done = new Map();
|
|
72
|
+
const visit = (at) => {
|
|
73
|
+
const known = done.get(at);
|
|
74
|
+
if (known !== undefined)
|
|
75
|
+
return known;
|
|
76
|
+
const result = outcomes[at] !== null && (calls[at]?.dependsOn ?? []).every((dependency) => visit(dependency));
|
|
77
|
+
done.set(at, result);
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
return visit(index);
|
|
81
|
+
}
|
|
82
|
+
export function settledOutcome(reply) {
|
|
83
|
+
if (reply.kind === "unknown_execution")
|
|
84
|
+
return { kind: "interrupted", reason: "unknown_execution", uncertain: true };
|
|
85
|
+
const { outcome } = reply;
|
|
86
|
+
switch (outcome.reason) {
|
|
87
|
+
case "result":
|
|
88
|
+
return { kind: "result", value: outcome.value };
|
|
89
|
+
case "blocked":
|
|
90
|
+
return { kind: "blocked", result: outcome.value };
|
|
91
|
+
default:
|
|
92
|
+
return { kind: "interrupted", reason: outcome.reason, uncertain: outcome.uncertain };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* What the model is shown for a call whose run was cut short, so a replay equals today's (plan X12, K4): today's
|
|
97
|
+
* pair-repair placeholder, never a rerun. Undefined for a call that settled, was blocked, or was aborted by a hook.
|
|
98
|
+
*/
|
|
99
|
+
export function interruptedReplayText(outcome) {
|
|
100
|
+
if (outcome.kind === "interrupted")
|
|
101
|
+
return TOOL_RESULT_PLACEHOLDER;
|
|
102
|
+
if (outcome.kind === "not_run" && outcome.cause === "interrupted_preparation")
|
|
103
|
+
return TOOL_RESULT_PLACEHOLDER;
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=coordinator-plan.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BatchCoordinator } from "./coordinator.ts";
|
|
2
|
+
import type { BatchPlan, BatchResult } from "./coordinator-types.ts";
|
|
3
|
+
/** `toolExecution: "sequential"` on the coordinator (design 5.6.1 scheduler modes, S11). */
|
|
4
|
+
export interface SequentialCoordinator {
|
|
5
|
+
/**
|
|
6
|
+
* Runs each call as its own one-call batch, in source order: a call is prepared and run to its final outcome before
|
|
7
|
+
* the next is prepared, as today's sequential scheduler interleaves them. The one-call batches are durable, so running
|
|
8
|
+
* the same plan again after a crash returns the finished calls' stored outcomes and resumes the one in flight. A
|
|
9
|
+
* call whose batch ABORTs (its preparation was stopped) ends the run: the calls after it are never prepared and are
|
|
10
|
+
* reported `not_run`.
|
|
11
|
+
*/
|
|
12
|
+
run(plan: BatchPlan): Promise<BatchResult>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSequentialCoordinator(coordinator: BatchCoordinator): SequentialCoordinator;
|
|
15
|
+
//# sourceMappingURL=coordinator-sequential.d.ts.map
|