@linnlabs/linnkit 0.32.3 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/dist/cli.cjs +458 -70
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +458 -70
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +55 -0
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +55 -0
- package/dist/context-manager.js.map +1 -1
- package/dist/contracts/agentSpec.d.cts +30 -30
- package/dist/contracts/agentSpec.d.ts +30 -30
- package/dist/contracts/audit.d.cts +24 -24
- package/dist/contracts/audit.d.ts +24 -24
- package/dist/contracts/contextPolicy.d.cts +36 -36
- package/dist/contracts/contextPolicy.d.ts +36 -36
- package/dist/contracts/events.d.cts +1083 -1083
- package/dist/contracts/events.d.ts +1083 -1083
- package/dist/contracts/execution.d.cts +8 -8
- package/dist/contracts/execution.d.ts +8 -8
- package/dist/contracts/messages.d.cts +1178 -1178
- package/dist/contracts/messages.d.ts +1178 -1178
- package/dist/contracts/provider-continuation.d.cts +28 -28
- package/dist/contracts/provider-continuation.d.ts +28 -28
- package/dist/contracts/sse.d.cts +899 -899
- package/dist/contracts/sse.d.ts +899 -899
- package/dist/contracts/sub-run-trace-payload.d.cts +26 -26
- package/dist/contracts/sub-run-trace-payload.d.ts +26 -26
- package/dist/contracts/token-accounting.d.cts +30 -30
- package/dist/contracts/token-accounting.d.ts +30 -30
- package/dist/index.cjs +538 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +538 -94
- package/dist/index.js.map +1 -1
- package/dist/quickstart/toolRuntime.d.cts +1 -1
- package/dist/quickstart/toolRuntime.d.ts +1 -1
- package/dist/quickstart/types.d.cts +1 -1
- package/dist/quickstart/types.d.ts +1 -1
- package/dist/quickstart.cjs +458 -70
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +458 -70
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +11 -0
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +11 -0
- package/dist/runtime-kernel/events/agentEvents.d.cts +172 -172
- package/dist/runtime-kernel/events/agentEvents.d.ts +172 -172
- package/dist/runtime-kernel/execution/eventBusEventPersistence.d.cts +15 -1
- package/dist/runtime-kernel/execution/eventBusEventPersistence.d.ts +15 -1
- package/dist/runtime-kernel/graph-engine/definitions/runContinuation.d.cts +34 -0
- package/dist/runtime-kernel/graph-engine/definitions/runContinuation.d.ts +34 -0
- package/dist/runtime-kernel/graph-engine/engine.d.cts +13 -2
- package/dist/runtime-kernel/graph-engine/engine.d.ts +13 -2
- package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.cts +6 -0
- package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.ts +6 -0
- package/dist/runtime-kernel/graph-engine/index.d.cts +3 -1
- package/dist/runtime-kernel/graph-engine/index.d.ts +3 -1
- package/dist/runtime-kernel/graph-engine/types.d.cts +8 -0
- package/dist/runtime-kernel/graph-engine/types.d.ts +8 -0
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +35 -6
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +35 -6
- package/dist/runtime-kernel/run-supervisor/index.d.cts +1 -1
- package/dist/runtime-kernel/run-supervisor/index.d.ts +1 -1
- package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.cts +1 -0
- package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.ts +1 -0
- package/dist/runtime-kernel/run-supervisor/runHandle.d.cts +9 -5
- package/dist/runtime-kernel/run-supervisor/runHandle.d.ts +9 -5
- package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.cts +2 -0
- package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.ts +2 -0
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +9 -2
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +9 -2
- package/dist/runtime-kernel.cjs +535 -91
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +3 -1
- package/dist/runtime-kernel.d.ts +3 -1
- package/dist/runtime-kernel.js +532 -92
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +535 -91
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +535 -91
- package/dist/testkit.js.map +1 -1
- package/docs/integration/child-runs.md +12 -0
- package/docs/integration/persistence.md +24 -0
- package/docs/integration/run-supervisor.md +15 -2
- package/package.json +2 -2
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { RoutedRuntimeEvent, RuntimeEvent } from '../../contracts/events.cjs';
|
|
2
|
-
import { EventStore } from '../graph-engine/event-store/base.cjs';
|
|
2
|
+
import { EventStore, PersistedEvent } from '../graph-engine/event-store/base.cjs';
|
|
3
|
+
import { EngineState } from '../graph-engine/types.cjs';
|
|
3
4
|
import { EventBus } from './event-bus.cjs';
|
|
4
5
|
|
|
5
6
|
interface EventBusEventPersistenceOptions {
|
|
6
7
|
eventBus: EventBus;
|
|
7
8
|
eventStore: EventStore;
|
|
8
9
|
nextEventStoreId: () => string;
|
|
10
|
+
/** 同一 SQLite 等短事务内提交已接纳事实与断点,并校验 activation 写入权。 */
|
|
11
|
+
checkpointWriter?: (input: {
|
|
12
|
+
readonly checkpointKey: string;
|
|
13
|
+
readonly checkpoint: EngineState;
|
|
14
|
+
readonly events: readonly PersistedEvent[];
|
|
15
|
+
}) => Promise<void>;
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* EventBus durable consumer:按发布顺序串行写入事实,并在 run 进入终态前传播首个失败。
|
|
@@ -17,7 +24,13 @@ declare class EventBusEventPersistence {
|
|
|
17
24
|
private writeTail;
|
|
18
25
|
private firstWriteError;
|
|
19
26
|
private connected;
|
|
27
|
+
private checkpointWritesActive;
|
|
28
|
+
private checkpointEvents;
|
|
20
29
|
constructor(options: EventBusEventPersistenceOptions);
|
|
30
|
+
/** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
|
|
31
|
+
commitCheckpoint(checkpointKey: string, checkpoint: EngineState): Promise<void>;
|
|
32
|
+
/** 离开 Graph 后,未提交的 attempt 事实作废;随后 settlement metrics 走普通写入。 */
|
|
33
|
+
finishCheckpointWrites(): void;
|
|
21
34
|
connect(): void;
|
|
22
35
|
drain(): Promise<void>;
|
|
23
36
|
/**
|
|
@@ -33,6 +46,7 @@ declare class EventBusEventPersistence {
|
|
|
33
46
|
acknowledgePersisted(events: readonly RuntimeEvent[]): void;
|
|
34
47
|
private readonly onEvent;
|
|
35
48
|
private scheduleWrite;
|
|
49
|
+
private enqueueWrite;
|
|
36
50
|
private readonly disconnect;
|
|
37
51
|
}
|
|
38
52
|
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { RoutedRuntimeEvent, RuntimeEvent } from '../../contracts/events.js';
|
|
2
|
-
import { EventStore } from '../graph-engine/event-store/base.js';
|
|
2
|
+
import { EventStore, PersistedEvent } from '../graph-engine/event-store/base.js';
|
|
3
|
+
import { EngineState } from '../graph-engine/types.js';
|
|
3
4
|
import { EventBus } from './event-bus.js';
|
|
4
5
|
|
|
5
6
|
interface EventBusEventPersistenceOptions {
|
|
6
7
|
eventBus: EventBus;
|
|
7
8
|
eventStore: EventStore;
|
|
8
9
|
nextEventStoreId: () => string;
|
|
10
|
+
/** 同一 SQLite 等短事务内提交已接纳事实与断点,并校验 activation 写入权。 */
|
|
11
|
+
checkpointWriter?: (input: {
|
|
12
|
+
readonly checkpointKey: string;
|
|
13
|
+
readonly checkpoint: EngineState;
|
|
14
|
+
readonly events: readonly PersistedEvent[];
|
|
15
|
+
}) => Promise<void>;
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* EventBus durable consumer:按发布顺序串行写入事实,并在 run 进入终态前传播首个失败。
|
|
@@ -17,7 +24,13 @@ declare class EventBusEventPersistence {
|
|
|
17
24
|
private writeTail;
|
|
18
25
|
private firstWriteError;
|
|
19
26
|
private connected;
|
|
27
|
+
private checkpointWritesActive;
|
|
28
|
+
private checkpointEvents;
|
|
20
29
|
constructor(options: EventBusEventPersistenceOptions);
|
|
30
|
+
/** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
|
|
31
|
+
commitCheckpoint(checkpointKey: string, checkpoint: EngineState): Promise<void>;
|
|
32
|
+
/** 离开 Graph 后,未提交的 attempt 事实作废;随后 settlement metrics 走普通写入。 */
|
|
33
|
+
finishCheckpointWrites(): void;
|
|
21
34
|
connect(): void;
|
|
22
35
|
drain(): Promise<void>;
|
|
23
36
|
/**
|
|
@@ -33,6 +46,7 @@ declare class EventBusEventPersistence {
|
|
|
33
46
|
acknowledgePersisted(events: readonly RuntimeEvent[]): void;
|
|
34
47
|
private readonly onEvent;
|
|
35
48
|
private scheduleWrite;
|
|
49
|
+
private enqueueWrite;
|
|
36
50
|
private readonly disconnect;
|
|
37
51
|
}
|
|
38
52
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StandardToolCall, EngineState } from '../types.cjs';
|
|
2
|
+
import { ToolExecutionContext } from '../../tools/toolExecutionContext.cjs';
|
|
3
|
+
import { ToolExecutionResult } from '../../tools/ports.cjs';
|
|
4
|
+
|
|
5
|
+
/** Host 在同一次提交中持久化已接纳事实与断点;不得跨 Provider / tool 调用持有事务。 */
|
|
6
|
+
interface ExecutionCheckpointPort {
|
|
7
|
+
commit(checkpointKey: string, checkpoint: EngineState): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
type ToolRecoveryDecision = {
|
|
10
|
+
readonly kind: 'retry';
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'settled';
|
|
13
|
+
readonly result: ToolExecutionResult;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'blocked';
|
|
16
|
+
readonly reason: string;
|
|
17
|
+
};
|
|
18
|
+
/** 只有工具 owner 能证明未决外部动作的结果;参数相同不构成完成证据。 */
|
|
19
|
+
interface ToolRecoveryPort {
|
|
20
|
+
reconcile(call: StandardToolCall, context: ToolExecutionContext): Promise<ToolRecoveryDecision>;
|
|
21
|
+
}
|
|
22
|
+
declare class RunRecoveryBlockedError extends Error {
|
|
23
|
+
readonly code = "RUN_RECOVERY_BLOCKED";
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/** 可恢复中断与永久取消使用不同 signal reason,不为暂停补造工具失败终态。 */
|
|
27
|
+
declare class RunPauseRequested extends Error {
|
|
28
|
+
readonly code = "RUN_PAUSE_REQUESTED";
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
declare function isRunPauseSignal(signal: AbortSignal | undefined): boolean;
|
|
32
|
+
|
|
33
|
+
export { RunPauseRequested, RunRecoveryBlockedError, isRunPauseSignal };
|
|
34
|
+
export type { ExecutionCheckpointPort, ToolRecoveryDecision, ToolRecoveryPort };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StandardToolCall, EngineState } from '../types.js';
|
|
2
|
+
import { ToolExecutionContext } from '../../tools/toolExecutionContext.js';
|
|
3
|
+
import { ToolExecutionResult } from '../../tools/ports.js';
|
|
4
|
+
|
|
5
|
+
/** Host 在同一次提交中持久化已接纳事实与断点;不得跨 Provider / tool 调用持有事务。 */
|
|
6
|
+
interface ExecutionCheckpointPort {
|
|
7
|
+
commit(checkpointKey: string, checkpoint: EngineState): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
type ToolRecoveryDecision = {
|
|
10
|
+
readonly kind: 'retry';
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'settled';
|
|
13
|
+
readonly result: ToolExecutionResult;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'blocked';
|
|
16
|
+
readonly reason: string;
|
|
17
|
+
};
|
|
18
|
+
/** 只有工具 owner 能证明未决外部动作的结果;参数相同不构成完成证据。 */
|
|
19
|
+
interface ToolRecoveryPort {
|
|
20
|
+
reconcile(call: StandardToolCall, context: ToolExecutionContext): Promise<ToolRecoveryDecision>;
|
|
21
|
+
}
|
|
22
|
+
declare class RunRecoveryBlockedError extends Error {
|
|
23
|
+
readonly code = "RUN_RECOVERY_BLOCKED";
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/** 可恢复中断与永久取消使用不同 signal reason,不为暂停补造工具失败终态。 */
|
|
27
|
+
declare class RunPauseRequested extends Error {
|
|
28
|
+
readonly code = "RUN_PAUSE_REQUESTED";
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
declare function isRunPauseSignal(signal: AbortSignal | undefined): boolean;
|
|
32
|
+
|
|
33
|
+
export { RunPauseRequested, RunRecoveryBlockedError, isRunPauseSignal };
|
|
34
|
+
export type { ExecutionCheckpointPort, ToolRecoveryDecision, ToolRecoveryPort };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TelemetryPort } from '../telemetry/telemetryPort.cjs';
|
|
2
2
|
import { Checkpointer } from './checkpointer/base.cjs';
|
|
3
|
-
import { GraphNode, EngineState } from './types.cjs';
|
|
3
|
+
import { EngineLocalState, GraphNode, EngineState } from './types.cjs';
|
|
4
4
|
import { RoutedRuntimeEvent } from '../../contracts/events.cjs';
|
|
5
|
+
import { ExecutionCheckpointPort } from './definitions/runContinuation.cjs';
|
|
5
6
|
|
|
6
7
|
type GraphRunResult = {
|
|
7
8
|
events: RoutedRuntimeEvent[];
|
|
@@ -22,12 +23,18 @@ interface GraphSessionExecutionOptions {
|
|
|
22
23
|
}
|
|
23
24
|
interface GraphExecutorConfig {
|
|
24
25
|
maxSteps?: number;
|
|
26
|
+
executionCheckpointPort?: ExecutionCheckpointPort;
|
|
25
27
|
/**
|
|
26
28
|
* 可选:宿主提供的 TelemetryPort 实现。
|
|
27
29
|
* 不传时使用 noopTelemetry(observability 默认关闭,零业务影响)。
|
|
28
30
|
*/
|
|
29
31
|
telemetryPort?: TelemetryPort;
|
|
30
32
|
}
|
|
33
|
+
interface GraphContinuationInput {
|
|
34
|
+
readonly expectedRevision: number;
|
|
35
|
+
/** 只能重建运行能力,不能覆盖持久请求、历史、模型或预算。 */
|
|
36
|
+
readonly capabilities: Pick<EngineLocalState, 'signal' | 'toolContext' | 'runtimeEventSink' | 'runtimeEventCommitPort' | 'runtimeFailureFactSink' | 'summarizationCallbacks' | 'toolRecoveryPort'>;
|
|
37
|
+
}
|
|
31
38
|
declare class GraphExecutor {
|
|
32
39
|
private readonly checkpointer;
|
|
33
40
|
private nodes;
|
|
@@ -35,6 +42,7 @@ declare class GraphExecutor {
|
|
|
35
42
|
private checkpointQueues;
|
|
36
43
|
private readonly config;
|
|
37
44
|
private readonly telemetryPort;
|
|
45
|
+
private readonly executionCheckpointPort?;
|
|
38
46
|
constructor(checkpointer: Checkpointer, config?: GraphExecutorConfig);
|
|
39
47
|
registerNode(node: GraphNode): void;
|
|
40
48
|
peekCheckpoint(checkpointKey: string): Promise<EngineState | null>;
|
|
@@ -46,6 +54,8 @@ declare class GraphExecutor {
|
|
|
46
54
|
* 需要组合 prime/runUntilYield,也就不会在两步之间被另一个 run 覆盖。
|
|
47
55
|
*/
|
|
48
56
|
startSession(checkpointKey: string, local: Record<string, unknown>, nodeId?: string, options?: GraphSessionExecutionOptions): Promise<GraphRunResult>;
|
|
57
|
+
/** 从原提交边界继续,和提交 HITL response 的 resumeSession 是不同控制操作。 */
|
|
58
|
+
continueSession(checkpointKey: string, input: GraphContinuationInput): Promise<GraphRunResult>;
|
|
49
59
|
/** 同一个 run 从已持久化 wait_user checkpoint 继续执行。 */
|
|
50
60
|
resumeSession(checkpointKey: string, input: GraphResumeSessionInput): Promise<GraphRunResult>;
|
|
51
61
|
clearCheckpoint(checkpointKey: string): Promise<void>;
|
|
@@ -56,9 +66,10 @@ declare class GraphExecutor {
|
|
|
56
66
|
private runUntilYieldQueued;
|
|
57
67
|
private loadInitialState;
|
|
58
68
|
private saveCheckpoint;
|
|
69
|
+
private commitCheckpoint;
|
|
59
70
|
private saveCheckpointAndBuildResult;
|
|
60
71
|
private runUntilYieldInternal;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
export { GraphExecutor };
|
|
64
|
-
export type { GraphExecutorConfig, GraphResumeSessionInput, GraphSessionExecutionOptions };
|
|
75
|
+
export type { GraphContinuationInput, GraphExecutorConfig, GraphResumeSessionInput, GraphSessionExecutionOptions };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TelemetryPort } from '../telemetry/telemetryPort.js';
|
|
2
2
|
import { Checkpointer } from './checkpointer/base.js';
|
|
3
|
-
import { GraphNode, EngineState } from './types.js';
|
|
3
|
+
import { EngineLocalState, GraphNode, EngineState } from './types.js';
|
|
4
4
|
import { RoutedRuntimeEvent } from '../../contracts/events.js';
|
|
5
|
+
import { ExecutionCheckpointPort } from './definitions/runContinuation.js';
|
|
5
6
|
|
|
6
7
|
type GraphRunResult = {
|
|
7
8
|
events: RoutedRuntimeEvent[];
|
|
@@ -22,12 +23,18 @@ interface GraphSessionExecutionOptions {
|
|
|
22
23
|
}
|
|
23
24
|
interface GraphExecutorConfig {
|
|
24
25
|
maxSteps?: number;
|
|
26
|
+
executionCheckpointPort?: ExecutionCheckpointPort;
|
|
25
27
|
/**
|
|
26
28
|
* 可选:宿主提供的 TelemetryPort 实现。
|
|
27
29
|
* 不传时使用 noopTelemetry(observability 默认关闭,零业务影响)。
|
|
28
30
|
*/
|
|
29
31
|
telemetryPort?: TelemetryPort;
|
|
30
32
|
}
|
|
33
|
+
interface GraphContinuationInput {
|
|
34
|
+
readonly expectedRevision: number;
|
|
35
|
+
/** 只能重建运行能力,不能覆盖持久请求、历史、模型或预算。 */
|
|
36
|
+
readonly capabilities: Pick<EngineLocalState, 'signal' | 'toolContext' | 'runtimeEventSink' | 'runtimeEventCommitPort' | 'runtimeFailureFactSink' | 'summarizationCallbacks' | 'toolRecoveryPort'>;
|
|
37
|
+
}
|
|
31
38
|
declare class GraphExecutor {
|
|
32
39
|
private readonly checkpointer;
|
|
33
40
|
private nodes;
|
|
@@ -35,6 +42,7 @@ declare class GraphExecutor {
|
|
|
35
42
|
private checkpointQueues;
|
|
36
43
|
private readonly config;
|
|
37
44
|
private readonly telemetryPort;
|
|
45
|
+
private readonly executionCheckpointPort?;
|
|
38
46
|
constructor(checkpointer: Checkpointer, config?: GraphExecutorConfig);
|
|
39
47
|
registerNode(node: GraphNode): void;
|
|
40
48
|
peekCheckpoint(checkpointKey: string): Promise<EngineState | null>;
|
|
@@ -46,6 +54,8 @@ declare class GraphExecutor {
|
|
|
46
54
|
* 需要组合 prime/runUntilYield,也就不会在两步之间被另一个 run 覆盖。
|
|
47
55
|
*/
|
|
48
56
|
startSession(checkpointKey: string, local: Record<string, unknown>, nodeId?: string, options?: GraphSessionExecutionOptions): Promise<GraphRunResult>;
|
|
57
|
+
/** 从原提交边界继续,和提交 HITL response 的 resumeSession 是不同控制操作。 */
|
|
58
|
+
continueSession(checkpointKey: string, input: GraphContinuationInput): Promise<GraphRunResult>;
|
|
49
59
|
/** 同一个 run 从已持久化 wait_user checkpoint 继续执行。 */
|
|
50
60
|
resumeSession(checkpointKey: string, input: GraphResumeSessionInput): Promise<GraphRunResult>;
|
|
51
61
|
clearCheckpoint(checkpointKey: string): Promise<void>;
|
|
@@ -56,9 +66,10 @@ declare class GraphExecutor {
|
|
|
56
66
|
private runUntilYieldQueued;
|
|
57
67
|
private loadInitialState;
|
|
58
68
|
private saveCheckpoint;
|
|
69
|
+
private commitCheckpoint;
|
|
59
70
|
private saveCheckpointAndBuildResult;
|
|
60
71
|
private runUntilYieldInternal;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
export { GraphExecutor };
|
|
64
|
-
export type { GraphExecutorConfig, GraphResumeSessionInput, GraphSessionExecutionOptions };
|
|
75
|
+
export type { GraphContinuationInput, GraphExecutorConfig, GraphResumeSessionInput, GraphSessionExecutionOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GraphExecutor } from './engine.cjs';
|
|
1
|
+
export { GraphContinuationInput, GraphExecutor } from './engine.cjs';
|
|
2
2
|
export { GraphAgentExecutor, GraphAgentExecutorDependencies } from './executor.cjs';
|
|
3
3
|
export { LlmNode } from './nodes/llmNode.cjs';
|
|
4
4
|
export { ToolNode } from './nodes/toolNode.cjs';
|
|
@@ -13,6 +13,8 @@ export { EffectivePromptBudget, ResolveEffectivePromptBudgetInput, resolveEffect
|
|
|
13
13
|
export { PrimaryPromptCapacityAdmission, evaluatePrimaryPromptCapacity } from './functions/evaluatePrimaryPromptCapacity.cjs';
|
|
14
14
|
export { PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, PrimaryPromptCapacityErrorMetadata } from './definitions/primaryPromptCapacityError.cjs';
|
|
15
15
|
export { readCheckpointContextUsage } from './functions/engineStateSnapshot.cjs';
|
|
16
|
+
export { parseEngineCheckpoint } from './functions/parseEngineCheckpoint.cjs';
|
|
16
17
|
export { isRuntimeFailureFact } from './functions/runtimeFailureFact.cjs';
|
|
17
18
|
export { ENGINE_STATE_SCHEMA_VERSION, EngineState, ExecutorLlmInvocationKind, ExecutorLocalPatch, ExecutorLocalState, GraphNode, RuntimeEventCommitPort, RuntimeEventSink, RuntimeFailureFact, RuntimeFailureFactSink, ToolBatchCompletionMode } from './types.cjs';
|
|
19
|
+
export { ExecutionCheckpointPort, RunPauseRequested, RunRecoveryBlockedError, ToolRecoveryDecision, ToolRecoveryPort, isRunPauseSignal } from './definitions/runContinuation.cjs';
|
|
18
20
|
export { GraphContextCompactionCandidate, GraphExecutorContextApplyInput, GraphExecutorContextApplyOutput, GraphExecutorContextBuildInput, GraphExecutorContextBuildOutput, GraphExecutorContextBuilder, GraphExecutorOutputProcessor } from './executorContextBuilder.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GraphExecutor } from './engine.js';
|
|
1
|
+
export { GraphContinuationInput, GraphExecutor } from './engine.js';
|
|
2
2
|
export { GraphAgentExecutor, GraphAgentExecutorDependencies } from './executor.js';
|
|
3
3
|
export { LlmNode } from './nodes/llmNode.js';
|
|
4
4
|
export { ToolNode } from './nodes/toolNode.js';
|
|
@@ -13,6 +13,8 @@ export { EffectivePromptBudget, ResolveEffectivePromptBudgetInput, resolveEffect
|
|
|
13
13
|
export { PrimaryPromptCapacityAdmission, evaluatePrimaryPromptCapacity } from './functions/evaluatePrimaryPromptCapacity.js';
|
|
14
14
|
export { PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, PrimaryPromptCapacityErrorMetadata } from './definitions/primaryPromptCapacityError.js';
|
|
15
15
|
export { readCheckpointContextUsage } from './functions/engineStateSnapshot.js';
|
|
16
|
+
export { parseEngineCheckpoint } from './functions/parseEngineCheckpoint.js';
|
|
16
17
|
export { isRuntimeFailureFact } from './functions/runtimeFailureFact.js';
|
|
17
18
|
export { ENGINE_STATE_SCHEMA_VERSION, EngineState, ExecutorLlmInvocationKind, ExecutorLocalPatch, ExecutorLocalState, GraphNode, RuntimeEventCommitPort, RuntimeEventSink, RuntimeFailureFact, RuntimeFailureFactSink, ToolBatchCompletionMode } from './types.js';
|
|
19
|
+
export { ExecutionCheckpointPort, RunPauseRequested, RunRecoveryBlockedError, ToolRecoveryDecision, ToolRecoveryPort, isRunPauseSignal } from './definitions/runContinuation.js';
|
|
18
20
|
export { GraphContextCompactionCandidate, GraphExecutorContextApplyInput, GraphExecutorContextApplyOutput, GraphExecutorContextBuildInput, GraphExecutorContextBuildOutput, GraphExecutorContextBuilder, GraphExecutorOutputProcessor } from './executorContextBuilder.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ToolExecutionContext } from '../tools/toolExecutionContext.cjs';
|
|
2
|
+
import { ToolRecoveryPort } from './definitions/runContinuation.cjs';
|
|
2
3
|
import { RunId, ToolCallId } from '../../contracts/identity/definitions.cjs';
|
|
3
4
|
import { AgentSpecSystemReminderPolicy, AgentSpecToolObservationGovernancePolicy } from '../../contracts/contextPolicy.cjs';
|
|
4
5
|
import { RuntimeEvent, RoutedRuntimeEvent } from '../../contracts/events.cjs';
|
|
@@ -81,6 +82,11 @@ interface EngineLocalState extends Record<string, unknown> {
|
|
|
81
82
|
runtimeEventSink?: RuntimeEventSink;
|
|
82
83
|
/** 在 fan-out 前请求 Host 持久化单个 durable fact。 */
|
|
83
84
|
runtimeEventCommitPort?: RuntimeEventCommitPort;
|
|
85
|
+
/** Graph 注入的短提交边界,ToolNode 每个 call 前后复用;不序列化能力。 */
|
|
86
|
+
commitExecutionBoundary?: (state: EngineState) => Promise<void>;
|
|
87
|
+
toolRecoveryPort?: ToolRecoveryPort;
|
|
88
|
+
/** 意图已提交但结果未提交的原始 call;重启时必须经过工具 owner 对账。 */
|
|
89
|
+
executingToolCallId?: ToolCallId;
|
|
84
90
|
runtimeFailureFactSink?: RuntimeFailureFactSink;
|
|
85
91
|
summarizationCallbacks?: SummarizationCallbacks;
|
|
86
92
|
/** 最近一次成功完成的 LLM Prompt 占用;可序列化并随 checkpoint 保留。 */
|
|
@@ -107,6 +113,8 @@ type RuntimeFailureFactSink = (event: RuntimeFailureFact) => void;
|
|
|
107
113
|
declare const ENGINE_STATE_SCHEMA_VERSION = 1;
|
|
108
114
|
interface EngineState {
|
|
109
115
|
nodeId: string;
|
|
116
|
+
/** 仅在配置 ExecutionCheckpointPort 后启用;yielded 不得重新执行最终节点。 */
|
|
117
|
+
executionStatus?: 'ready' | 'executing' | 'yielded' | 'awaiting_user';
|
|
110
118
|
/**
|
|
111
119
|
* 当前 checkpoint 的单调版本。
|
|
112
120
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ToolExecutionContext } from '../tools/toolExecutionContext.js';
|
|
2
|
+
import { ToolRecoveryPort } from './definitions/runContinuation.js';
|
|
2
3
|
import { RunId, ToolCallId } from '../../contracts/identity/definitions.js';
|
|
3
4
|
import { AgentSpecSystemReminderPolicy, AgentSpecToolObservationGovernancePolicy } from '../../contracts/contextPolicy.js';
|
|
4
5
|
import { RuntimeEvent, RoutedRuntimeEvent } from '../../contracts/events.js';
|
|
@@ -81,6 +82,11 @@ interface EngineLocalState extends Record<string, unknown> {
|
|
|
81
82
|
runtimeEventSink?: RuntimeEventSink;
|
|
82
83
|
/** 在 fan-out 前请求 Host 持久化单个 durable fact。 */
|
|
83
84
|
runtimeEventCommitPort?: RuntimeEventCommitPort;
|
|
85
|
+
/** Graph 注入的短提交边界,ToolNode 每个 call 前后复用;不序列化能力。 */
|
|
86
|
+
commitExecutionBoundary?: (state: EngineState) => Promise<void>;
|
|
87
|
+
toolRecoveryPort?: ToolRecoveryPort;
|
|
88
|
+
/** 意图已提交但结果未提交的原始 call;重启时必须经过工具 owner 对账。 */
|
|
89
|
+
executingToolCallId?: ToolCallId;
|
|
84
90
|
runtimeFailureFactSink?: RuntimeFailureFactSink;
|
|
85
91
|
summarizationCallbacks?: SummarizationCallbacks;
|
|
86
92
|
/** 最近一次成功完成的 LLM Prompt 占用;可序列化并随 checkpoint 保留。 */
|
|
@@ -107,6 +113,8 @@ type RuntimeFailureFactSink = (event: RuntimeFailureFact) => void;
|
|
|
107
113
|
declare const ENGINE_STATE_SCHEMA_VERSION = 1;
|
|
108
114
|
interface EngineState {
|
|
109
115
|
nodeId: string;
|
|
116
|
+
/** 仅在配置 ExecutionCheckpointPort 后启用;yielded 不得重新执行最终节点。 */
|
|
117
|
+
executionStatus?: 'ready' | 'executing' | 'yielded' | 'awaiting_user';
|
|
110
118
|
/**
|
|
111
119
|
* 当前 checkpoint 的单调版本。
|
|
112
120
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunId,
|
|
1
|
+
import { RunId, ExecutionId, ToolCallId } from '../../../contracts/identity/definitions.cjs';
|
|
2
2
|
import { AgentSpec } from '../../../contracts/agentSpec.cjs';
|
|
3
3
|
import { RuntimeEvent } from '../../../contracts/events.cjs';
|
|
4
4
|
import { AuditPort } from '../../../ports/audit.cjs';
|
|
@@ -51,11 +51,16 @@ interface RunResumeClaim<TRequest extends RunRequestSnapshot = RunRequestSnapsho
|
|
|
51
51
|
readonly runId: RunId;
|
|
52
52
|
readonly handle: RunHandle<TRequest>;
|
|
53
53
|
/** 同一逻辑 run 的新 execution 身份必须与 claim 激活原子写入。 */
|
|
54
|
-
activate(execution?:
|
|
55
|
-
readonly executionId: ExecutionId;
|
|
56
|
-
}): Promise<RunHandle<TRequest>>;
|
|
54
|
+
activate(execution?: RunResumeActivation): Promise<RunHandle<TRequest>>;
|
|
57
55
|
release(): Promise<void>;
|
|
58
56
|
}
|
|
57
|
+
interface RunResumeActivation {
|
|
58
|
+
readonly executionId: ExecutionId;
|
|
59
|
+
/** 持久响应引用仅供 Host 重启后接续已提交的原交互,不是新的用户输入。 */
|
|
60
|
+
readonly inputEventIds?: readonly string[];
|
|
61
|
+
/** 将 interaction 激活和响应事实放进同一事务;必须核对 previous。 */
|
|
62
|
+
readonly admissionCommit?: (previous: RunRecord, next: RunRecord) => Promise<void>;
|
|
63
|
+
}
|
|
59
64
|
interface RunExecutionContext<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
60
65
|
runId: RunId;
|
|
61
66
|
parentRunId?: RunId;
|
|
@@ -79,6 +84,17 @@ interface RunRegistrationSpec<TRequest extends RunRequestSnapshot = RunRequestSn
|
|
|
79
84
|
runId?: RunId;
|
|
80
85
|
/** 同一 supervisor 内,活跃 run 不得共享同一个业务并发 key。 */
|
|
81
86
|
concurrencyKey?: string;
|
|
87
|
+
/** 替代已收口的暂停运行;必须通过 admissionCommit 原子提交旧终态、新身份和 Host 输入。 */
|
|
88
|
+
replacesPausedRun?: {
|
|
89
|
+
runId: RunId;
|
|
90
|
+
expectedUpdatedAt: number;
|
|
91
|
+
expectedExecutionId: ExecutionId;
|
|
92
|
+
};
|
|
93
|
+
/** Host 必须在一个持久事务中写入 record 及其必要输入;不能在提交后再抛错误。 */
|
|
94
|
+
admissionCommit?: (record: RunRecord, replacement?: {
|
|
95
|
+
previous: RunRecord;
|
|
96
|
+
next: RunRecord;
|
|
97
|
+
}) => Promise<void>;
|
|
82
98
|
parentRunId?: RunId;
|
|
83
99
|
parentSignal?: AbortSignal;
|
|
84
100
|
conversationId: string;
|
|
@@ -96,6 +112,10 @@ interface RunRegistrationSpec<TRequest extends RunRequestSnapshot = RunRequestSn
|
|
|
96
112
|
}
|
|
97
113
|
interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
98
114
|
registerRun(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
115
|
+
/** Host 已校验 durable descriptor 后重建能力;不注册新 run、不覆盖持久身份。 */
|
|
116
|
+
restoreRun(spec: RunRegistrationSpec<TRequest> & {
|
|
117
|
+
runId: RunId;
|
|
118
|
+
}): Promise<RunHandle<TRequest>>;
|
|
99
119
|
spawnDetached(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
100
120
|
observeRun(runId: RunId, filter?: RunObserveFilter): AsyncIterable<RuntimeEvent>;
|
|
101
121
|
cancel(runId: RunId, opts: CancelOpts): Promise<void>;
|
|
@@ -114,7 +134,14 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
|
|
|
114
134
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
115
135
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
116
136
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
117
|
-
pause(runId: RunId, reason?: string): Promise<
|
|
137
|
+
pause(runId: RunId, reason?: string): Promise<void>;
|
|
138
|
+
resumePausedRun(input: {
|
|
139
|
+
readonly runId: RunId;
|
|
140
|
+
readonly expectedUpdatedAt: number;
|
|
141
|
+
readonly expectedExecutionId?: ExecutionId;
|
|
142
|
+
readonly eventBus: EventBus;
|
|
143
|
+
readonly executionId: ExecutionId;
|
|
144
|
+
}): Promise<RunHandle<TRequest>>;
|
|
118
145
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
119
146
|
runTree(rootRunId: RunId): Promise<never>;
|
|
120
147
|
handleFailure(runId: RunId, error: unknown): Promise<never>;
|
|
@@ -126,6 +153,8 @@ interface DefaultRunSupervisorOptions<TRequest extends RunRequestSnapshot = RunR
|
|
|
126
153
|
runIdFactory?: () => RunId;
|
|
127
154
|
now?: () => number;
|
|
128
155
|
maxActiveRuns?: number;
|
|
156
|
+
/** 仅识别具有 Host 恢复输入的 run;不在启动时执行它。旧 run 默认仍 abandoned。 */
|
|
157
|
+
canRestoreRun?: (record: RunRecord) => Promise<boolean>;
|
|
129
158
|
}
|
|
130
159
|
|
|
131
|
-
export type { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions };
|
|
160
|
+
export type { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeActivation, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunId,
|
|
1
|
+
import { RunId, ExecutionId, ToolCallId } from '../../../contracts/identity/definitions.js';
|
|
2
2
|
import { AgentSpec } from '../../../contracts/agentSpec.js';
|
|
3
3
|
import { RuntimeEvent } from '../../../contracts/events.js';
|
|
4
4
|
import { AuditPort } from '../../../ports/audit.js';
|
|
@@ -51,11 +51,16 @@ interface RunResumeClaim<TRequest extends RunRequestSnapshot = RunRequestSnapsho
|
|
|
51
51
|
readonly runId: RunId;
|
|
52
52
|
readonly handle: RunHandle<TRequest>;
|
|
53
53
|
/** 同一逻辑 run 的新 execution 身份必须与 claim 激活原子写入。 */
|
|
54
|
-
activate(execution?:
|
|
55
|
-
readonly executionId: ExecutionId;
|
|
56
|
-
}): Promise<RunHandle<TRequest>>;
|
|
54
|
+
activate(execution?: RunResumeActivation): Promise<RunHandle<TRequest>>;
|
|
57
55
|
release(): Promise<void>;
|
|
58
56
|
}
|
|
57
|
+
interface RunResumeActivation {
|
|
58
|
+
readonly executionId: ExecutionId;
|
|
59
|
+
/** 持久响应引用仅供 Host 重启后接续已提交的原交互,不是新的用户输入。 */
|
|
60
|
+
readonly inputEventIds?: readonly string[];
|
|
61
|
+
/** 将 interaction 激活和响应事实放进同一事务;必须核对 previous。 */
|
|
62
|
+
readonly admissionCommit?: (previous: RunRecord, next: RunRecord) => Promise<void>;
|
|
63
|
+
}
|
|
59
64
|
interface RunExecutionContext<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
60
65
|
runId: RunId;
|
|
61
66
|
parentRunId?: RunId;
|
|
@@ -79,6 +84,17 @@ interface RunRegistrationSpec<TRequest extends RunRequestSnapshot = RunRequestSn
|
|
|
79
84
|
runId?: RunId;
|
|
80
85
|
/** 同一 supervisor 内,活跃 run 不得共享同一个业务并发 key。 */
|
|
81
86
|
concurrencyKey?: string;
|
|
87
|
+
/** 替代已收口的暂停运行;必须通过 admissionCommit 原子提交旧终态、新身份和 Host 输入。 */
|
|
88
|
+
replacesPausedRun?: {
|
|
89
|
+
runId: RunId;
|
|
90
|
+
expectedUpdatedAt: number;
|
|
91
|
+
expectedExecutionId: ExecutionId;
|
|
92
|
+
};
|
|
93
|
+
/** Host 必须在一个持久事务中写入 record 及其必要输入;不能在提交后再抛错误。 */
|
|
94
|
+
admissionCommit?: (record: RunRecord, replacement?: {
|
|
95
|
+
previous: RunRecord;
|
|
96
|
+
next: RunRecord;
|
|
97
|
+
}) => Promise<void>;
|
|
82
98
|
parentRunId?: RunId;
|
|
83
99
|
parentSignal?: AbortSignal;
|
|
84
100
|
conversationId: string;
|
|
@@ -96,6 +112,10 @@ interface RunRegistrationSpec<TRequest extends RunRequestSnapshot = RunRequestSn
|
|
|
96
112
|
}
|
|
97
113
|
interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
98
114
|
registerRun(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
115
|
+
/** Host 已校验 durable descriptor 后重建能力;不注册新 run、不覆盖持久身份。 */
|
|
116
|
+
restoreRun(spec: RunRegistrationSpec<TRequest> & {
|
|
117
|
+
runId: RunId;
|
|
118
|
+
}): Promise<RunHandle<TRequest>>;
|
|
99
119
|
spawnDetached(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
100
120
|
observeRun(runId: RunId, filter?: RunObserveFilter): AsyncIterable<RuntimeEvent>;
|
|
101
121
|
cancel(runId: RunId, opts: CancelOpts): Promise<void>;
|
|
@@ -114,7 +134,14 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
|
|
|
114
134
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
115
135
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
116
136
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
117
|
-
pause(runId: RunId, reason?: string): Promise<
|
|
137
|
+
pause(runId: RunId, reason?: string): Promise<void>;
|
|
138
|
+
resumePausedRun(input: {
|
|
139
|
+
readonly runId: RunId;
|
|
140
|
+
readonly expectedUpdatedAt: number;
|
|
141
|
+
readonly expectedExecutionId?: ExecutionId;
|
|
142
|
+
readonly eventBus: EventBus;
|
|
143
|
+
readonly executionId: ExecutionId;
|
|
144
|
+
}): Promise<RunHandle<TRequest>>;
|
|
118
145
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
119
146
|
runTree(rootRunId: RunId): Promise<never>;
|
|
120
147
|
handleFailure(runId: RunId, error: unknown): Promise<never>;
|
|
@@ -126,6 +153,8 @@ interface DefaultRunSupervisorOptions<TRequest extends RunRequestSnapshot = RunR
|
|
|
126
153
|
runIdFactory?: () => RunId;
|
|
127
154
|
now?: () => number;
|
|
128
155
|
maxActiveRuns?: number;
|
|
156
|
+
/** 仅识别具有 Host 恢复输入的 run;不在启动时执行它。旧 run 默认仍 abandoned。 */
|
|
157
|
+
canRestoreRun?: (record: RunRecord) => Promise<boolean>;
|
|
129
158
|
}
|
|
130
159
|
|
|
131
|
-
export type { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions };
|
|
160
|
+
export type { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeActivation, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions };
|
|
@@ -3,4 +3,4 @@ export { CancelOpts, DefaultRunHandle, DefaultRunHandleOptions, RunAwaitingUserP
|
|
|
3
3
|
export { DefaultRunSupervisor } from './runSupervisor.cjs';
|
|
4
4
|
export { NotImplementedError, RunAlreadyRegisteredError, RunConcurrencyKeyOccupiedError, RunConcurrencyLimitExceededError, RunNotFoundError } from './runErrors.cjs';
|
|
5
5
|
export { ListRunsFilter, RunRecord, RunRegistryStore, RunStatus } from './runRegistryStorePort.cjs';
|
|
6
|
-
export { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions } from './definitions/runSupervisorContracts.cjs';
|
|
6
|
+
export { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeActivation, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions } from './definitions/runSupervisorContracts.cjs';
|
|
@@ -3,4 +3,4 @@ export { CancelOpts, DefaultRunHandle, DefaultRunHandleOptions, RunAwaitingUserP
|
|
|
3
3
|
export { DefaultRunSupervisor } from './runSupervisor.js';
|
|
4
4
|
export { NotImplementedError, RunAlreadyRegisteredError, RunConcurrencyKeyOccupiedError, RunConcurrencyLimitExceededError, RunNotFoundError } from './runErrors.js';
|
|
5
5
|
export { ListRunsFilter, RunRecord, RunRegistryStore, RunStatus } from './runRegistryStorePort.js';
|
|
6
|
-
export { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions } from './definitions/runSupervisorContracts.js';
|
|
6
|
+
export { DefaultRunSupervisorOptions, FindActiveByConversationOptions, FindRunsByConversationOptions, RunExecutionContext, RunExecutorPort, RunOutcome, RunRegistrationSpec, RunResumeActivation, RunResumeClaim, RunResumeInteraction, RunSnapshot, RunSupervisor, RunTerminalError, RunTerminalEvent, RunTerminalStatus, RunWaitForTerminalOptions } from './definitions/runSupervisorContracts.js';
|
|
@@ -3,6 +3,7 @@ import { RunId } from '../../contracts/identity/definitions.cjs';
|
|
|
3
3
|
|
|
4
4
|
declare class MemoryRunRegistryStore implements RunRegistryStore {
|
|
5
5
|
private readonly store;
|
|
6
|
+
compareAndSwap(previous: RunRecord, next: RunRecord): Promise<boolean>;
|
|
6
7
|
save(record: RunRecord): Promise<void>;
|
|
7
8
|
load(runId: RunId): Promise<RunRecord | null>;
|
|
8
9
|
list(filter?: ListRunsFilter): Promise<{
|
|
@@ -3,6 +3,7 @@ import { RunId } from '../../contracts/identity/definitions.js';
|
|
|
3
3
|
|
|
4
4
|
declare class MemoryRunRegistryStore implements RunRegistryStore {
|
|
5
5
|
private readonly store;
|
|
6
|
+
compareAndSwap(previous: RunRecord, next: RunRecord): Promise<boolean>;
|
|
6
7
|
save(record: RunRecord): Promise<void>;
|
|
7
8
|
load(runId: RunId): Promise<RunRecord | null>;
|
|
8
9
|
list(filter?: ListRunsFilter): Promise<{
|
|
@@ -84,8 +84,10 @@ interface RunHandle<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
|
84
84
|
markAwaitingUser(patch?: RunAwaitingUserPatch): Promise<void>;
|
|
85
85
|
markCompleted(patch?: RunLifecyclePatch): Promise<void>;
|
|
86
86
|
markFailed(error: RunFailureInfo, patch?: RunLifecyclePatch): Promise<void>;
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
/** 写暂停意图后中断当前 attempt;pausedAt 未设置表示执行尚在收口。 */
|
|
88
|
+
pause(reason?: string): Promise<void>;
|
|
89
|
+
/** Host 在 checkpoint 提交和当前 attempt 收口之后确认可继续。 */
|
|
90
|
+
markPaused(patch?: RunAwaitingUserPatch): Promise<void>;
|
|
89
91
|
}
|
|
90
92
|
interface DefaultRunHandleOptions<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
91
93
|
runRecord: RunRecord;
|
|
@@ -111,6 +113,7 @@ declare class DefaultRunHandle<TRequest extends RunRequestSnapshot = RunRequestS
|
|
|
111
113
|
readonly parentRunId?: RunId;
|
|
112
114
|
private runRecord;
|
|
113
115
|
private abortController;
|
|
116
|
+
private executionId;
|
|
114
117
|
private readonly agentSpecSnapshot;
|
|
115
118
|
private readonly requestSnapshot;
|
|
116
119
|
private transportEventBus;
|
|
@@ -127,7 +130,7 @@ declare class DefaultRunHandle<TRequest extends RunRequestSnapshot = RunRequestS
|
|
|
127
130
|
* awaiting_user 之后的 resume 是同一逻辑 run 的新 execution。
|
|
128
131
|
* 必须切换取消控制器,避免旧 transport 的迟到 abort 污染新 execution。
|
|
129
132
|
*/
|
|
130
|
-
replaceExecutionAbortController(controller: AbortController): void;
|
|
133
|
+
replaceExecutionAbortController(controller: AbortController, executionId?: string): void;
|
|
131
134
|
spec(): Promise<AgentSpec>;
|
|
132
135
|
request(): Promise<TRequest>;
|
|
133
136
|
attachTransportEventBus(eventBus: EventBus): void;
|
|
@@ -139,10 +142,11 @@ declare class DefaultRunHandle<TRequest extends RunRequestSnapshot = RunRequestS
|
|
|
139
142
|
markAwaitingUser(patch?: RunAwaitingUserPatch): Promise<void>;
|
|
140
143
|
markCompleted(patch?: RunLifecyclePatch): Promise<void>;
|
|
141
144
|
markFailed(error: RunFailureInfo, patch?: RunLifecyclePatch): Promise<void>;
|
|
142
|
-
pause(
|
|
143
|
-
|
|
145
|
+
pause(reason?: string): Promise<void>;
|
|
146
|
+
markPaused(patch?: RunAwaitingUserPatch): Promise<void>;
|
|
144
147
|
private saveLifecycleStatus;
|
|
145
148
|
private readonly forwardTransportEvent;
|
|
149
|
+
private assertExecutionOwner;
|
|
146
150
|
private readonly forwardTransportError;
|
|
147
151
|
private readonly detachClosedTransport;
|
|
148
152
|
private attachTransportBridge;
|