@linnlabs/linnkit 0.35.1 → 0.36.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 +9 -0
- package/dist/cli.cjs +13 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +13 -3
- package/dist/cli.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 +32 -32
- package/dist/contracts/audit.d.ts +32 -32
- package/dist/contracts/contextPolicy.d.cts +36 -36
- package/dist/contracts/contextPolicy.d.ts +36 -36
- package/dist/contracts/events.d.cts +1114 -1114
- package/dist/contracts/events.d.ts +1114 -1114
- 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 +46 -46
- package/dist/contracts/token-accounting.d.ts +46 -46
- package/dist/index.cjs +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +13 -3
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +13 -3
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/events/agentEvents.d.cts +172 -172
- package/dist/runtime-kernel/events/agentEvents.d.ts +172 -172
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +3 -1
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +3 -1
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +2 -2
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +2 -2
- package/dist/runtime-kernel.cjs +13 -3
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +13 -3
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +13 -3
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +13 -3
- package/dist/testkit.js.map +1 -1
- package/docs/integration/run-supervisor.md +2 -0
- package/package.json +2 -2
|
@@ -134,7 +134,7 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
|
|
|
134
134
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
135
135
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
136
136
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
137
|
-
pause(runId: RunId, reason?: string): Promise<void>;
|
|
137
|
+
pause(runId: RunId, reason?: string, expectedExecutionId?: ExecutionId): Promise<void>;
|
|
138
138
|
resumePausedRun(input: {
|
|
139
139
|
readonly runId: RunId;
|
|
140
140
|
readonly expectedUpdatedAt: number;
|
|
@@ -154,6 +154,8 @@ interface DefaultRunSupervisorOptions<TRequest extends RunRequestSnapshot = RunR
|
|
|
154
154
|
runIdFactory?: () => RunId;
|
|
155
155
|
now?: () => number;
|
|
156
156
|
maxActiveRuns?: number;
|
|
157
|
+
/** 原子 checkpoint Host 在持久提交后自行写等待态,不能由未提交的实时事件提前写入。 */
|
|
158
|
+
awaitingUserStateOwner?: 'supervisor' | 'host';
|
|
157
159
|
/** 仅识别具有 Host 恢复输入的 run;不在启动时执行它。旧 run 默认仍 abandoned。 */
|
|
158
160
|
canRestoreRun?: (record: RunRecord) => Promise<boolean>;
|
|
159
161
|
}
|
|
@@ -134,7 +134,7 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
|
|
|
134
134
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
135
135
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
136
136
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
137
|
-
pause(runId: RunId, reason?: string): Promise<void>;
|
|
137
|
+
pause(runId: RunId, reason?: string, expectedExecutionId?: ExecutionId): Promise<void>;
|
|
138
138
|
resumePausedRun(input: {
|
|
139
139
|
readonly runId: RunId;
|
|
140
140
|
readonly expectedUpdatedAt: number;
|
|
@@ -154,6 +154,8 @@ interface DefaultRunSupervisorOptions<TRequest extends RunRequestSnapshot = RunR
|
|
|
154
154
|
runIdFactory?: () => RunId;
|
|
155
155
|
now?: () => number;
|
|
156
156
|
maxActiveRuns?: number;
|
|
157
|
+
/** 原子 checkpoint Host 在持久提交后自行写等待态,不能由未提交的实时事件提前写入。 */
|
|
158
|
+
awaitingUserStateOwner?: 'supervisor' | 'host';
|
|
157
159
|
/** 仅识别具有 Host 恢复输入的 run;不在启动时执行它。旧 run 默认仍 abandoned。 */
|
|
158
160
|
canRestoreRun?: (record: RunRecord) => Promise<boolean>;
|
|
159
161
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventBus } from '../execution/event-bus.cjs';
|
|
2
|
-
import { RunId } from '../../contracts/identity/definitions.cjs';
|
|
2
|
+
import { RunId, ExecutionId } 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
5
|
export { RunExecutionContext, RunExecutorPort, RunResumeActivation, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.cjs';
|
|
@@ -44,7 +44,7 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
44
44
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
45
45
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
46
46
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
47
|
-
pause(runId: RunId, reason?: string): Promise<void>;
|
|
47
|
+
pause(runId: RunId, reason?: string, expectedExecutionId?: ExecutionId): Promise<void>;
|
|
48
48
|
resumePausedRun(input: Parameters<RunSupervisor<TRequest>['resumePausedRun']>[0]): Promise<RunHandle<TRequest>>;
|
|
49
49
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
50
50
|
runTree(_rootRunId: RunId): Promise<never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventBus } from '../execution/event-bus.js';
|
|
2
|
-
import { RunId } from '../../contracts/identity/definitions.js';
|
|
2
|
+
import { RunId, ExecutionId } 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
5
|
export { RunExecutionContext, RunExecutorPort, RunResumeActivation, RunTerminalError, RunTerminalEvent, RunTerminalStatus } from './definitions/runSupervisorContracts.js';
|
|
@@ -44,7 +44,7 @@ declare class DefaultRunSupervisor<TRequest extends RunRequestSnapshot = RunRequ
|
|
|
44
44
|
findByConversation(conversationId: string, opts?: FindRunsByConversationOptions): Promise<RunSnapshot[]>;
|
|
45
45
|
drain(opts?: RunWaitForTerminalOptions): Promise<RunOutcome[]>;
|
|
46
46
|
recoverOnBoot(reason?: string): Promise<RunOutcome[]>;
|
|
47
|
-
pause(runId: RunId, reason?: string): Promise<void>;
|
|
47
|
+
pause(runId: RunId, reason?: string, expectedExecutionId?: ExecutionId): Promise<void>;
|
|
48
48
|
resumePausedRun(input: Parameters<RunSupervisor<TRequest>['resumePausedRun']>[0]): Promise<RunHandle<TRequest>>;
|
|
49
49
|
claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
|
|
50
50
|
runTree(_rootRunId: RunId): Promise<never>;
|
package/dist/runtime-kernel.cjs
CHANGED
|
@@ -13307,7 +13307,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
13307
13307
|
const onClose = () => {
|
|
13308
13308
|
dispose();
|
|
13309
13309
|
};
|
|
13310
|
-
eventBus.on("event", onEvent);
|
|
13310
|
+
if (options.stateOwner !== "host") eventBus.on("event", onEvent);
|
|
13311
13311
|
eventBus.on("close", onClose);
|
|
13312
13312
|
return dispose;
|
|
13313
13313
|
}
|
|
@@ -13783,6 +13783,7 @@ var DefaultRunSupervisor = class {
|
|
|
13783
13783
|
this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
|
|
13784
13784
|
this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
|
|
13785
13785
|
this.awaitingUserWatcher = createAwaitingUserWatcher({
|
|
13786
|
+
stateOwner: options.awaitingUserStateOwner,
|
|
13786
13787
|
markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
|
|
13787
13788
|
onDisposed: (runId) => {
|
|
13788
13789
|
this.eventWatchDisposers.delete(runId);
|
|
@@ -13979,8 +13980,17 @@ var DefaultRunSupervisor = class {
|
|
|
13979
13980
|
canRestoreRun: this.canRestoreRun
|
|
13980
13981
|
});
|
|
13981
13982
|
}
|
|
13982
|
-
async pause(runId, reason) {
|
|
13983
|
-
await this.withRunControlLock(runId, () =>
|
|
13983
|
+
async pause(runId, reason, expectedExecutionId) {
|
|
13984
|
+
await this.withRunControlLock(runId, async () => {
|
|
13985
|
+
const handle = this.getHandle(runId);
|
|
13986
|
+
if (expectedExecutionId !== void 0) {
|
|
13987
|
+
const record = await this.registryStore.load(runId);
|
|
13988
|
+
if (record?.metadata?.executionId !== expectedExecutionId) {
|
|
13989
|
+
throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
|
|
13990
|
+
}
|
|
13991
|
+
}
|
|
13992
|
+
await handle.pause(reason);
|
|
13993
|
+
});
|
|
13984
13994
|
}
|
|
13985
13995
|
async resumePausedRun(input) {
|
|
13986
13996
|
return this.withRunControlLock(input.runId, async () => {
|