@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
|
@@ -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;
|
|
@@ -35,6 +35,8 @@ type RunRecord = {
|
|
|
35
35
|
metadata?: Record<string, unknown>;
|
|
36
36
|
};
|
|
37
37
|
interface RunRegistryStore {
|
|
38
|
+
/** 仅当整条 previous 仍是当前记录时原子替换;恢复 Host 必须实现。 */
|
|
39
|
+
compareAndSwap?(previous: RunRecord, next: RunRecord): Promise<boolean>;
|
|
38
40
|
save(record: RunRecord): Promise<void>;
|
|
39
41
|
load(runId: RunId): Promise<RunRecord | null>;
|
|
40
42
|
list(filter?: ListRunsFilter): Promise<{
|
|
@@ -35,6 +35,8 @@ type RunRecord = {
|
|
|
35
35
|
metadata?: Record<string, unknown>;
|
|
36
36
|
};
|
|
37
37
|
interface RunRegistryStore {
|
|
38
|
+
/** 仅当整条 previous 仍是当前记录时原子替换;恢复 Host 必须实现。 */
|
|
39
|
+
compareAndSwap?(previous: RunRecord, next: RunRecord): Promise<boolean>;
|
|
38
40
|
save(record: RunRecord): Promise<void>;
|
|
39
41
|
load(runId: RunId): Promise<RunRecord | null>;
|
|
40
42
|
list(filter?: ListRunsFilter): Promise<{
|
|
@@ -2,7 +2,7 @@ import { EventBus } from '../execution/event-bus.cjs';
|
|
|
2
2
|
import { RunId } from '../../contracts/identity/definitions.cjs';
|
|
3
3
|
import { RuntimeEvent } from '../../contracts/events.cjs';
|
|
4
4
|
import { RunSupervisor, DefaultRunSupervisorOptions, RunRegistrationSpec, RunWaitForTerminalOptions, RunOutcome, FindActiveByConversationOptions, RunSnapshot, FindRunsByConversationOptions, RunResumeInteraction, RunResumeClaim } from './definitions/runSupervisorContracts.cjs';
|
|
5
|
-
export { RunExecutionContext, RunExecutorPort, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.cjs';
|
|
5
|
+
export { RunExecutionContext, RunExecutorPort, RunResumeActivation, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.cjs';
|
|
6
6
|
import { RunRequestSnapshot, RunHandle, RunObserveFilter, CancelOpts, RunAwaitingUserPatch, RunMeta } from './runHandle.cjs';
|
|
7
7
|
import { ListRunsFilter } from './runRegistryStorePort.cjs';
|
|
8
8
|
|
|
@@ -22,8 +22,14 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
22
22
|
private readonly inFlight;
|
|
23
23
|
private readonly eventWatchDisposers;
|
|
24
24
|
private readonly controlOperations;
|
|
25
|
+
private readonly canRestoreRun?;
|
|
25
26
|
constructor(options: DefaultRunSupervisorOptions<TRequest>);
|
|
26
27
|
registerRun(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
28
|
+
private registerPausedReplacement;
|
|
29
|
+
restoreRun(spec: RunRegistrationSpec<TRequest> & {
|
|
30
|
+
runId: RunId;
|
|
31
|
+
}): Promise<RunHandle<TRequest>>;
|
|
32
|
+
private attachRun;
|
|
27
33
|
spawnDetached(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
28
34
|
observeRun(runId: RunId, filter?: RunObserveFilter): AsyncIterable<RuntimeEvent>;
|
|
29
35
|
cancel(runId: RunId, opts: CancelOpts): Promise<void>;
|
|
@@ -38,7 +44,8 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
38
44
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
39
45
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
40
46
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
41
|
-
pause(
|
|
47
|
+
pause(runId: RunId, reason?: string): Promise<void>;
|
|
48
|
+
resumePausedRun(input: Parameters<RunSupervisor<TRequest>['resumePausedRun']>[0]): Promise<RunHandle<TRequest>>;
|
|
42
49
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
43
50
|
runTree(_rootRunId: RunId): Promise<never>;
|
|
44
51
|
handleFailure(_runId: RunId, _error: unknown): Promise<never>;
|
|
@@ -2,7 +2,7 @@ import { EventBus } from '../execution/event-bus.js';
|
|
|
2
2
|
import { RunId } from '../../contracts/identity/definitions.js';
|
|
3
3
|
import { RuntimeEvent } from '../../contracts/events.js';
|
|
4
4
|
import { RunSupervisor, DefaultRunSupervisorOptions, RunRegistrationSpec, RunWaitForTerminalOptions, RunOutcome, FindActiveByConversationOptions, RunSnapshot, FindRunsByConversationOptions, RunResumeInteraction, RunResumeClaim } from './definitions/runSupervisorContracts.js';
|
|
5
|
-
export { RunExecutionContext, RunExecutorPort, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.js';
|
|
5
|
+
export { RunExecutionContext, RunExecutorPort, RunResumeActivation, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.js';
|
|
6
6
|
import { RunRequestSnapshot, RunHandle, RunObserveFilter, CancelOpts, RunAwaitingUserPatch, RunMeta } from './runHandle.js';
|
|
7
7
|
import { ListRunsFilter } from './runRegistryStorePort.js';
|
|
8
8
|
|
|
@@ -22,8 +22,14 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
22
22
|
private readonly inFlight;
|
|
23
23
|
private readonly eventWatchDisposers;
|
|
24
24
|
private readonly controlOperations;
|
|
25
|
+
private readonly canRestoreRun?;
|
|
25
26
|
constructor(options: DefaultRunSupervisorOptions<TRequest>);
|
|
26
27
|
registerRun(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
28
|
+
private registerPausedReplacement;
|
|
29
|
+
restoreRun(spec: RunRegistrationSpec<TRequest> & {
|
|
30
|
+
runId: RunId;
|
|
31
|
+
}): Promise<RunHandle<TRequest>>;
|
|
32
|
+
private attachRun;
|
|
27
33
|
spawnDetached(spec: RunRegistrationSpec<TRequest>): Promise<RunHandle<TRequest>>;
|
|
28
34
|
observeRun(runId: RunId, filter?: RunObserveFilter): AsyncIterable<RuntimeEvent>;
|
|
29
35
|
cancel(runId: RunId, opts: CancelOpts): Promise<void>;
|
|
@@ -38,7 +44,8 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
38
44
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
39
45
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
40
46
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
41
|
-
pause(
|
|
47
|
+
pause(runId: RunId, reason?: string): Promise<void>;
|
|
48
|
+
resumePausedRun(input: Parameters<RunSupervisor<TRequest>['resumePausedRun']>[0]): Promise<RunHandle<TRequest>>;
|
|
42
49
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
43
50
|
runTree(_rootRunId: RunId): Promise<never>;
|
|
44
51
|
handleFailure(_runId: RunId, _error: unknown): Promise<never>;
|