@anvia/durable 0.0.0-bootstrap.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +161 -3
- package/dist/chunk-7WOOJGHA.js +499 -0
- package/dist/chunk-7WOOJGHA.js.map +1 -0
- package/dist/chunk-ETGANBD4.js +83 -0
- package/dist/chunk-ETGANBD4.js.map +1 -0
- package/dist/chunk-KIMHK6CE.js +353 -0
- package/dist/chunk-KIMHK6CE.js.map +1 -0
- package/dist/index.d.ts +182 -0
- package/dist/index.js +1930 -0
- package/dist/index.js.map +1 -0
- package/dist/maintenance.d.ts +10 -0
- package/dist/maintenance.js +119 -0
- package/dist/maintenance.js.map +1 -0
- package/dist/protocol.d.ts +37 -0
- package/dist/protocol.js +213 -0
- package/dist/protocol.js.map +1 -0
- package/dist/sqlite.d.ts +40 -0
- package/dist/sqlite.js +8 -0
- package/dist/sqlite.js.map +1 -0
- package/dist/task-protocol-Cewz7y6v.d.ts +38 -0
- package/dist/types-CBjKEKQ7.d.ts +396 -0
- package/package.json +50 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { D as DurableSnapshot, a as DurableEvent, b as DurableGraphSnapshot, c as DurableGraphEvent, d as DurableStore, R as RegisteredTask, e as DurableAgentRegistration, T as TaskRecord, f as DurableOperation, g as TaskGraphSnapshot, h as TaskEvent, i as DurableRuntimeOptions, j as DefinedTask, k as DurableRunScope, l as TaskListOptions, m as TaskPage, n as DurableSubmission, o as DurableSubmitOptions, p as DurableGraphSubmission, q as DurableGraphListOptions, r as DurableGraphPage, s as DurableListOptions, t as DurableRunPage, u as DurableMetrics, v as TaskDefinition } from './types-CBjKEKQ7.js';
|
|
2
|
+
export { w as DurableGraphNode, x as DurableGraphRecord, y as DurableLimits, z as DurableModelRetry, A as DurableRunRecord, B as DurableRunStatus, C as DurableRunSummary, E as DurableTask, F as DurableTaskWait, G as DurableTransaction, H as TaskContext, I as TaskOutcome, J as TaskTransaction, K as TaskTransition, L as TaskWait, M as ToolRecovery } from './types-CBjKEKQ7.js';
|
|
3
|
+
import { T as TaskSubmission } from './task-protocol-Cewz7y6v.js';
|
|
4
|
+
import { AgentOutcome } from '@anvia/core/agent';
|
|
5
|
+
import { AgentInteractionResponse } from '@anvia/core/agent/interactions';
|
|
6
|
+
import { ToolResultOutput, JsonValue } from '@anvia/core/completion';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
type DurableStreamOptions = {
|
|
10
|
+
after?: number;
|
|
11
|
+
abortSignal?: AbortSignal;
|
|
12
|
+
};
|
|
13
|
+
/** An identity and subscription handle. Closing a subscription never cancels execution. */
|
|
14
|
+
declare class DurableRun {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
private readonly runtime;
|
|
17
|
+
constructor(id: string, runtime: DurableRuntime);
|
|
18
|
+
snapshot(): Promise<DurableSnapshot>;
|
|
19
|
+
stream(options?: DurableStreamOptions): AsyncIterable<DurableEvent>;
|
|
20
|
+
result(options?: {
|
|
21
|
+
abortSignal?: AbortSignal;
|
|
22
|
+
}): Promise<AgentOutcome<unknown>>;
|
|
23
|
+
respond(interactionId: string, response: AgentInteractionResponse): Promise<void>;
|
|
24
|
+
resolveTool(operationId: string, output: ToolResultOutput): Promise<void>;
|
|
25
|
+
retry(): Promise<void>;
|
|
26
|
+
cancel(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A persisted static DAG. Each node is an ordinary durable agent run in an isolated session. */
|
|
30
|
+
declare class DurableTaskGraph {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
private readonly runtime;
|
|
33
|
+
constructor(id: string, runtime: DurableRuntime);
|
|
34
|
+
snapshot(): Promise<DurableGraphSnapshot>;
|
|
35
|
+
cancel(): Promise<void>;
|
|
36
|
+
stream(options?: DurableStreamOptions): AsyncIterable<DurableGraphEvent>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Owns phase invocations only; DurableRuntime owns the shared database lifecycle. */
|
|
40
|
+
declare class TaskScheduler {
|
|
41
|
+
private readonly store;
|
|
42
|
+
private readonly definitions;
|
|
43
|
+
private readonly capacity;
|
|
44
|
+
private readonly fatal;
|
|
45
|
+
private readonly agents;
|
|
46
|
+
private readonly agentActive;
|
|
47
|
+
private readonly syncAgents;
|
|
48
|
+
private readonly active;
|
|
49
|
+
private readonly deadlines;
|
|
50
|
+
private timer;
|
|
51
|
+
private closing;
|
|
52
|
+
constructor(store: DurableStore, definitions: ReadonlyMap<string, RegisteredTask>, capacity: number, fatal: (error: unknown) => void, agents: ReadonlyMap<string, DurableAgentRegistration>, agentActive: (id: string) => boolean, syncAgents: (root: string) => void);
|
|
53
|
+
get activeCount(): number;
|
|
54
|
+
agentChanged(id: string): void;
|
|
55
|
+
submit(name: string, version: number, input: unknown, sessionId: string, key: string): string;
|
|
56
|
+
resume(): void;
|
|
57
|
+
stop(reason: unknown): void;
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
snapshot(id: string): {
|
|
60
|
+
task: TaskRecord;
|
|
61
|
+
operations: DurableOperation[];
|
|
62
|
+
cursor: number;
|
|
63
|
+
};
|
|
64
|
+
graph(id: string): TaskGraphSnapshot;
|
|
65
|
+
cancel(id: string, expectedTreeIds?: readonly string[]): void;
|
|
66
|
+
signal(id: string, name: string, requestId: string, value: JsonValue): void;
|
|
67
|
+
retry(id: string): void;
|
|
68
|
+
resolveEffect(id: string, key: string, value: JsonValue): void;
|
|
69
|
+
private reconcile;
|
|
70
|
+
private pump;
|
|
71
|
+
private launch;
|
|
72
|
+
private execute;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Typed output is available for submitted definitions; reacquired IDs return JSON. */
|
|
76
|
+
declare class DurableTaskHandle<R = JsonValue> {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
private readonly scheduler;
|
|
79
|
+
private readonly store;
|
|
80
|
+
private readonly assertOpen;
|
|
81
|
+
constructor(id: string, scheduler: TaskScheduler, store: DurableStore, assertOpen: () => void);
|
|
82
|
+
snapshot(): Promise<{
|
|
83
|
+
task: TaskRecord;
|
|
84
|
+
operations: DurableOperation[];
|
|
85
|
+
cursor: number;
|
|
86
|
+
}>;
|
|
87
|
+
graph(): Promise<TaskGraphSnapshot>;
|
|
88
|
+
/** Optional identity fence for callers authorizing a captured ownership tree. */
|
|
89
|
+
cancel(options?: {
|
|
90
|
+
expectedTreeIds?: readonly string[];
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
retry(): Promise<void>;
|
|
93
|
+
resolveEffect(key: string, value: JsonValue): Promise<void>;
|
|
94
|
+
signal(name: string, requestId: string, value: JsonValue): Promise<void>;
|
|
95
|
+
result(options?: {
|
|
96
|
+
abortSignal?: AbortSignal;
|
|
97
|
+
}): Promise<R>;
|
|
98
|
+
/** Streams the entire owned tree, including children created after attachment. */
|
|
99
|
+
stream(options?: DurableStreamOptions): AsyncIterable<TaskEvent>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare class DurableRuntime {
|
|
103
|
+
private readonly maxConcurrentRuns;
|
|
104
|
+
private readonly onFatalError?;
|
|
105
|
+
private readonly agents;
|
|
106
|
+
private readonly active;
|
|
107
|
+
private closing;
|
|
108
|
+
private closed;
|
|
109
|
+
private readonly store;
|
|
110
|
+
private closePromise;
|
|
111
|
+
private failure;
|
|
112
|
+
private wakeTimer;
|
|
113
|
+
private readonly tasks;
|
|
114
|
+
private constructor();
|
|
115
|
+
static open(options: DurableRuntimeOptions): Promise<DurableRuntime>;
|
|
116
|
+
submitTask<I, S, R>(definition: DefinedTask<I, S, R>, input: {
|
|
117
|
+
sessionId: string;
|
|
118
|
+
requestId: string;
|
|
119
|
+
input: I;
|
|
120
|
+
}): Promise<DurableTaskHandle<R>>;
|
|
121
|
+
submitRegisteredTask(input: TaskSubmission): Promise<DurableTaskHandle>;
|
|
122
|
+
/** Owning scope for authorization without loading operation journals or graph results. */
|
|
123
|
+
runScope(runId: string): DurableRunScope;
|
|
124
|
+
getTask(id: string): Promise<DurableTaskHandle>;
|
|
125
|
+
listTasks(options?: TaskListOptions): Promise<TaskPage>;
|
|
126
|
+
taskGraph(id: string): Promise<TaskGraphSnapshot>;
|
|
127
|
+
submit(input: DurableSubmission, options?: DurableSubmitOptions): Promise<DurableRun>;
|
|
128
|
+
submitGraph(input: DurableGraphSubmission): Promise<DurableTaskGraph>;
|
|
129
|
+
getGraph(id: string): Promise<DurableTaskGraph>;
|
|
130
|
+
listGraphs(options?: DurableGraphListOptions): Promise<DurableGraphPage>;
|
|
131
|
+
graphSnapshot(id: string): DurableGraphSnapshot;
|
|
132
|
+
graphEvents(id: string, after: number): DurableEvent[];
|
|
133
|
+
cancelGraph(id: string): void;
|
|
134
|
+
listRuns(options?: DurableListOptions): Promise<DurableRunPage>;
|
|
135
|
+
getRun(id: string): Promise<DurableRun>;
|
|
136
|
+
/** Discover recoverable work. This does not wait for runs or approvals to finish. */
|
|
137
|
+
resume(): Promise<void>;
|
|
138
|
+
/** Abort in-flight attempts, retain checkpoints, and release ownership after callbacks settle. */
|
|
139
|
+
close(): Promise<void>;
|
|
140
|
+
snapshot(id: string): DurableSnapshot;
|
|
141
|
+
events(id: string, after: number): DurableEvent[];
|
|
142
|
+
respond(id: string, interactionId: string, value: AgentInteractionResponse): void;
|
|
143
|
+
resolveTool(id: string, operationId: string, output: ToolResultOutput): void;
|
|
144
|
+
retry(id: string): void;
|
|
145
|
+
cancel(id: string): void;
|
|
146
|
+
private pump;
|
|
147
|
+
private launch;
|
|
148
|
+
private execute;
|
|
149
|
+
metrics(): DurableMetrics;
|
|
150
|
+
/** Does not touch storage, so supervisors can inspect a failed owner. */
|
|
151
|
+
health(): {
|
|
152
|
+
status: "failed" | "closed" | "closing" | "ready";
|
|
153
|
+
ready: boolean;
|
|
154
|
+
activeRuns: number;
|
|
155
|
+
activeTasks: number;
|
|
156
|
+
};
|
|
157
|
+
private fail;
|
|
158
|
+
private assertOpen;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
declare function defineTask<I, S, R>(definition: TaskDefinition<I, S, R>): DefinedTask<I, S, R>;
|
|
162
|
+
|
|
163
|
+
declare class DurableRecoveryError extends Error {
|
|
164
|
+
readonly operationId?: string | undefined;
|
|
165
|
+
constructor(message: string, operationId?: string | undefined);
|
|
166
|
+
}
|
|
167
|
+
declare class DurableRunError extends Error {
|
|
168
|
+
readonly runId: string;
|
|
169
|
+
readonly status: "failed" | "cancelled";
|
|
170
|
+
constructor(runId: string, status: "failed" | "cancelled", message: string);
|
|
171
|
+
}
|
|
172
|
+
declare class DurableNotFoundError extends Error {
|
|
173
|
+
}
|
|
174
|
+
declare class DurableConflictError extends Error {
|
|
175
|
+
}
|
|
176
|
+
/** Fatal journal failure; application retries cannot repair a poisoned runtime. */
|
|
177
|
+
declare class DurableStorageError extends Error {
|
|
178
|
+
}
|
|
179
|
+
declare class DurableLimitError extends Error {
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { DefinedTask, DurableAgentRegistration, DurableConflictError, DurableEvent, DurableGraphEvent, DurableGraphListOptions, DurableGraphPage, DurableGraphSnapshot, DurableGraphSubmission, DurableLimitError, DurableListOptions, DurableMetrics, DurableNotFoundError, DurableOperation, DurableRecoveryError, DurableRun, DurableRunError, DurableRunPage, DurableRunScope, DurableRuntime, DurableRuntimeOptions, DurableSnapshot, DurableStorageError, DurableStore, type DurableStreamOptions, DurableSubmission, DurableSubmitOptions, DurableTaskGraph, DurableTaskHandle, RegisteredTask, TaskDefinition, TaskEvent, TaskGraphSnapshot, TaskListOptions, TaskPage, TaskRecord, defineTask };
|