@hunterzhu/pulse-runtime 0.1.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/dist/context/builder.d.ts +68 -0
- package/dist/context/builder.js +127 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/context/merger.d.ts +25 -0
- package/dist/context/merger.js +125 -0
- package/dist/core/actions.d.ts +1 -0
- package/dist/core/actions.js +1 -0
- package/dist/core/errors.d.ts +8 -0
- package/dist/core/errors.js +36 -0
- package/dist/core/events.d.ts +10 -0
- package/dist/core/events.js +24 -0
- package/dist/core/factory.d.ts +35 -0
- package/dist/core/factory.js +27 -0
- package/dist/core/inbox.d.ts +119 -0
- package/dist/core/inbox.js +217 -0
- package/dist/core/mutations.d.ts +80 -0
- package/dist/core/mutations.js +127 -0
- package/dist/core/records.d.ts +1 -0
- package/dist/core/records.js +1 -0
- package/dist/core/types.d.ts +615 -0
- package/dist/core/types.js +109 -0
- package/dist/dependencies/graph.d.ts +25 -0
- package/dist/dependencies/graph.js +92 -0
- package/dist/dependencies/index.d.ts +1 -0
- package/dist/dependencies/index.js +1 -0
- package/dist/dsl/context-proxy.d.ts +20 -0
- package/dist/dsl/context-proxy.js +64 -0
- package/dist/dsl/index.d.ts +4 -0
- package/dist/dsl/index.js +4 -0
- package/dist/dsl/program.d.ts +314 -0
- package/dist/dsl/program.js +756 -0
- package/dist/dsl/session.d.ts +45 -0
- package/dist/dsl/session.js +93 -0
- package/dist/dsl/templates-index.d.ts +1 -0
- package/dist/dsl/templates-index.js +1 -0
- package/dist/dsl/templates.d.ts +85 -0
- package/dist/dsl/templates.js +110 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +15 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.js +2 -0
- package/dist/lifecycle/scopes.d.ts +38 -0
- package/dist/lifecycle/scopes.js +50 -0
- package/dist/lifecycle/watchdog.d.ts +16 -0
- package/dist/lifecycle/watchdog.js +66 -0
- package/dist/models/actions.d.ts +10 -0
- package/dist/models/actions.js +68 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +2 -0
- package/dist/models/router.d.ts +187 -0
- package/dist/models/router.js +353 -0
- package/dist/scheduler/clock.d.ts +45 -0
- package/dist/scheduler/clock.js +92 -0
- package/dist/scheduler/decision.d.ts +72 -0
- package/dist/scheduler/decision.js +63 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +6 -0
- package/dist/scheduler/locks.d.ts +18 -0
- package/dist/scheduler/locks.js +106 -0
- package/dist/scheduler/ready-queue.d.ts +32 -0
- package/dist/scheduler/ready-queue.js +40 -0
- package/dist/scheduler/runtime.d.ts +486 -0
- package/dist/scheduler/runtime.js +3445 -0
- package/dist/scheduler/telemetry.d.ts +111 -0
- package/dist/scheduler/telemetry.js +177 -0
- package/dist/scheduler/worker.d.ts +158 -0
- package/dist/scheduler/worker.js +744 -0
- package/dist/storage/artifacts.d.ts +17 -0
- package/dist/storage/artifacts.js +90 -0
- package/dist/storage/findings.d.ts +12 -0
- package/dist/storage/findings.js +70 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/memory.d.ts +11 -0
- package/dist/storage/memory.js +21 -0
- package/dist/storage/mutation-log.d.ts +41 -0
- package/dist/storage/mutation-log.js +140 -0
- package/dist/storage/outbox.d.ts +30 -0
- package/dist/storage/outbox.js +59 -0
- package/dist/storage/persistence.d.ts +183 -0
- package/dist/storage/persistence.js +999 -0
- package/dist/storage/policy.d.ts +80 -0
- package/dist/storage/policy.js +268 -0
- package/dist/storage/session.d.ts +140 -0
- package/dist/storage/session.js +447 -0
- package/dist/tools/registry.d.ts +125 -0
- package/dist/tools/registry.js +308 -0
- package/dist/transitions/index.d.ts +2 -0
- package/dist/transitions/index.js +1 -0
- package/dist/transitions/validate.d.ts +4 -0
- package/dist/transitions/validate.js +1118 -0
- package/package.json +21 -0
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
2
|
+
[key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
export type LaneId = string;
|
|
5
|
+
export type AgentId = string;
|
|
6
|
+
export type EffectId = string;
|
|
7
|
+
export type WaitId = string;
|
|
8
|
+
export type ResultRef = string;
|
|
9
|
+
export type ArtifactRef = string;
|
|
10
|
+
export type FindingRef = ResultRef;
|
|
11
|
+
export type DataRef = {
|
|
12
|
+
kind: 'result';
|
|
13
|
+
ref: ResultRef;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'artifact';
|
|
16
|
+
ref: ArtifactRef;
|
|
17
|
+
};
|
|
18
|
+
export type ProvenanceRef = string | DataRef;
|
|
19
|
+
export declare function provenanceRefId(ref: ProvenanceRef): string;
|
|
20
|
+
export declare function provenanceRefKind(ref: ProvenanceRef): 'legacy' | DataRef['kind'];
|
|
21
|
+
export type ContextVersion = number;
|
|
22
|
+
export type PrivacyLabel = 'public' | 'cloud_allowed' | 'local_only';
|
|
23
|
+
export type SideEffectPolicy = 'none' | 'read' | 'write' | 'external';
|
|
24
|
+
export type ForkAffinityMode = 'off' | 'advise' | 'coalesce';
|
|
25
|
+
export type LaneStatus = 'ready' | 'running' | 'waiting' | 'closing' | 'cancelling' | 'succeeded' | 'failed' | 'cancelled';
|
|
26
|
+
export type EffectState = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'retry_wait' | 'reconcile_required';
|
|
27
|
+
export type ConcurrencyClass = 'llm' | 'tool' | 'agent' | 'none';
|
|
28
|
+
export type OutcomeStatus = 'succeeded' | 'failed' | 'cancelled';
|
|
29
|
+
export interface ResourceLockSpec {
|
|
30
|
+
resource: string;
|
|
31
|
+
mode: 'shared' | 'exclusive';
|
|
32
|
+
}
|
|
33
|
+
export interface PrivacyTaint {
|
|
34
|
+
path: string[];
|
|
35
|
+
privacy: PrivacyLabel;
|
|
36
|
+
}
|
|
37
|
+
export interface PrivacyMetadata {
|
|
38
|
+
privacy: PrivacyLabel;
|
|
39
|
+
privacyTaints?: PrivacyTaint[];
|
|
40
|
+
}
|
|
41
|
+
export interface RuntimeError {
|
|
42
|
+
code: string;
|
|
43
|
+
message: string;
|
|
44
|
+
/** Explicitly prevents or permits automatic retry when the failure is settled by an Effect host. */
|
|
45
|
+
retryable?: boolean;
|
|
46
|
+
details?: JsonValue;
|
|
47
|
+
}
|
|
48
|
+
export interface Outcome {
|
|
49
|
+
status: OutcomeStatus;
|
|
50
|
+
resultRef?: ResultRef;
|
|
51
|
+
result?: JsonValue;
|
|
52
|
+
rejectedOutputRefs?: ResultRef[];
|
|
53
|
+
error?: RuntimeError;
|
|
54
|
+
reason?: string;
|
|
55
|
+
unresolvedEffectIds?: EffectId[];
|
|
56
|
+
}
|
|
57
|
+
export interface ResumePoint {
|
|
58
|
+
programId: string;
|
|
59
|
+
programVersion: string;
|
|
60
|
+
step: string;
|
|
61
|
+
locals: JsonValue;
|
|
62
|
+
}
|
|
63
|
+
export interface HistoryRecord {
|
|
64
|
+
seq: number;
|
|
65
|
+
effectId?: EffectId;
|
|
66
|
+
instruction: string;
|
|
67
|
+
resultRefs: ResultRef[];
|
|
68
|
+
resultSelection?: Array<{
|
|
69
|
+
ref: ResultRef;
|
|
70
|
+
rule: string;
|
|
71
|
+
hash: string;
|
|
72
|
+
}>;
|
|
73
|
+
result?: ResultRef;
|
|
74
|
+
findings?: FindingRef[];
|
|
75
|
+
output: JsonValue;
|
|
76
|
+
privacy: PrivacyLabel;
|
|
77
|
+
privacyTaints?: PrivacyTaint[];
|
|
78
|
+
}
|
|
79
|
+
export interface LaneContext {
|
|
80
|
+
version: ContextVersion;
|
|
81
|
+
history: HistoryRecord[];
|
|
82
|
+
state: JsonValue;
|
|
83
|
+
privacy?: PrivacyLabel;
|
|
84
|
+
privacyTaints?: PrivacyTaint[];
|
|
85
|
+
}
|
|
86
|
+
export interface ProgressWatchdogState {
|
|
87
|
+
window: string[];
|
|
88
|
+
actionSignatures?: string[];
|
|
89
|
+
progressKeys?: string[];
|
|
90
|
+
noProgressCount: number;
|
|
91
|
+
interventionLevel: 0 | 1 | 2 | 3;
|
|
92
|
+
lastFingerprint?: string;
|
|
93
|
+
lastReason?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface HistoryPressure {
|
|
96
|
+
historyTokens: number;
|
|
97
|
+
softTokens: number;
|
|
98
|
+
hardTokens: number;
|
|
99
|
+
}
|
|
100
|
+
export interface AgentRecord {
|
|
101
|
+
id: AgentId;
|
|
102
|
+
rootLaneId: LaneId;
|
|
103
|
+
goal?: string;
|
|
104
|
+
state?: 'created' | 'running' | 'cancelling' | 'succeeded' | 'failed' | 'cancelled';
|
|
105
|
+
policyId?: string;
|
|
106
|
+
limitsId?: string;
|
|
107
|
+
deadlineAt?: number;
|
|
108
|
+
globalVersions: Map<ContextVersion, JsonValue>;
|
|
109
|
+
globalPrivacy?: Map<ContextVersion, PrivacyMetadata>;
|
|
110
|
+
latestGlobalVersion: ContextVersion;
|
|
111
|
+
maxActiveLanes: number;
|
|
112
|
+
parentAgentId?: AgentId;
|
|
113
|
+
depth?: number;
|
|
114
|
+
detached?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export interface LaneRecord {
|
|
117
|
+
id: LaneId;
|
|
118
|
+
agentId: AgentId;
|
|
119
|
+
ownerLaneId?: LaneId;
|
|
120
|
+
status: LaneStatus;
|
|
121
|
+
version: number;
|
|
122
|
+
goal: string;
|
|
123
|
+
resume: ResumePoint;
|
|
124
|
+
series?: SeriesLaneSpec;
|
|
125
|
+
pendingResumeInput?: ResumeInput;
|
|
126
|
+
/** Control proposals that arrived while another ResumeInput occupied the slot. */
|
|
127
|
+
pendingControlProposals?: ControlProposal[];
|
|
128
|
+
contextSnapshotVersion: ContextVersion;
|
|
129
|
+
context: LaneContext;
|
|
130
|
+
visibleResultRefs?: Set<ResultRef>;
|
|
131
|
+
activeWaitId?: WaitId;
|
|
132
|
+
children: Set<LaneId>;
|
|
133
|
+
priority: number;
|
|
134
|
+
inheritedFloor?: number;
|
|
135
|
+
enqueueSeq: number;
|
|
136
|
+
readySince: number;
|
|
137
|
+
ownedEffectIds: Set<EffectId>;
|
|
138
|
+
closingResult?: {
|
|
139
|
+
value: JsonValue;
|
|
140
|
+
privacy: PrivacyLabel;
|
|
141
|
+
privacyTaints?: PrivacyTaint[];
|
|
142
|
+
derivedFrom?: ProvenanceRef[];
|
|
143
|
+
};
|
|
144
|
+
failure?: {
|
|
145
|
+
error: RuntimeError;
|
|
146
|
+
privacy: PrivacyLabel;
|
|
147
|
+
derivedFrom?: ProvenanceRef[];
|
|
148
|
+
};
|
|
149
|
+
cancelReason?: string;
|
|
150
|
+
resultRef?: ResultRef;
|
|
151
|
+
consecutiveControlErrors?: number;
|
|
152
|
+
pendingOutcome?: Outcome;
|
|
153
|
+
unresolvedEffectIds?: EffectId[];
|
|
154
|
+
progressWatchdog?: ProgressWatchdogState;
|
|
155
|
+
historyPressure?: HistoryPressure;
|
|
156
|
+
}
|
|
157
|
+
export interface EffectRecord {
|
|
158
|
+
id: EffectId;
|
|
159
|
+
agentId: AgentId;
|
|
160
|
+
ownerLaneId: LaneId;
|
|
161
|
+
key: string;
|
|
162
|
+
kind: 'llm' | 'tool' | 'human' | 'agent' | 'timer';
|
|
163
|
+
concurrencyClass: ConcurrencyClass;
|
|
164
|
+
input: JsonValue;
|
|
165
|
+
derivedFrom?: ProvenanceRef[];
|
|
166
|
+
state: EffectState;
|
|
167
|
+
attemptId: string;
|
|
168
|
+
attemptNo: number;
|
|
169
|
+
executionState: 'local' | 'running' | 'succeeded' | 'failed' | 'remote_unknown' | 'local_closed' | 'settled';
|
|
170
|
+
sideEffectState: 'none' | 'applied' | 'known' | 'unknown';
|
|
171
|
+
executionRef?: JsonValue;
|
|
172
|
+
attempts?: AttemptRecord[];
|
|
173
|
+
cancelRequested?: {
|
|
174
|
+
reason: string;
|
|
175
|
+
at: number;
|
|
176
|
+
};
|
|
177
|
+
schedulePriority?: number;
|
|
178
|
+
inheritedFloor?: number;
|
|
179
|
+
deadlineAt?: number;
|
|
180
|
+
cancelGraceMs?: number;
|
|
181
|
+
attemptTimeoutMs?: number;
|
|
182
|
+
idempotencyKey?: string;
|
|
183
|
+
sideEffectPolicy?: SideEffectPolicy;
|
|
184
|
+
toolVersion?: string;
|
|
185
|
+
retryPolicy?: {
|
|
186
|
+
maxAttempts: number;
|
|
187
|
+
initialBackoffMs: number;
|
|
188
|
+
maxBackoffMs: number;
|
|
189
|
+
jitter: boolean;
|
|
190
|
+
};
|
|
191
|
+
duplicateExecutionPolicy?: 'allow' | 'forbid';
|
|
192
|
+
maxUnknownAttempts?: number;
|
|
193
|
+
retryAt?: number;
|
|
194
|
+
preparation?: {
|
|
195
|
+
state: 'idle' | 'preparing' | 'prepared' | 'stale';
|
|
196
|
+
generation: number;
|
|
197
|
+
projectionRef?: string;
|
|
198
|
+
};
|
|
199
|
+
outcome?: Outcome;
|
|
200
|
+
toolCallId?: string;
|
|
201
|
+
llmEffectId?: EffectId;
|
|
202
|
+
childAgentId?: AgentId;
|
|
203
|
+
locks?: ResourceLockSpec[];
|
|
204
|
+
}
|
|
205
|
+
export interface AttemptRecord {
|
|
206
|
+
id: string;
|
|
207
|
+
effectId: EffectId;
|
|
208
|
+
modelId?: string;
|
|
209
|
+
providerId?: string;
|
|
210
|
+
executionState: EffectRecord['executionState'];
|
|
211
|
+
sideEffectState: EffectRecord['sideEffectState'];
|
|
212
|
+
startedAt?: number;
|
|
213
|
+
settledAt?: number;
|
|
214
|
+
error?: RuntimeError;
|
|
215
|
+
remoteStatusRef?: JsonValue;
|
|
216
|
+
sideEffectRef?: JsonValue;
|
|
217
|
+
}
|
|
218
|
+
export interface ResultRecord {
|
|
219
|
+
id: ResultRef;
|
|
220
|
+
effectId?: EffectId;
|
|
221
|
+
/** Stable producer identity used by DSL metadata and audit tooling. */
|
|
222
|
+
producer?: TargetRef;
|
|
223
|
+
kind?: 'result' | 'finding' | 'rejected_output';
|
|
224
|
+
statement?: string;
|
|
225
|
+
evidenceRefs?: DataRef[];
|
|
226
|
+
value?: JsonValue;
|
|
227
|
+
storageState?: 'memory' | 'persisted';
|
|
228
|
+
pinCount?: number;
|
|
229
|
+
privacy: PrivacyLabel;
|
|
230
|
+
privacyTaints?: PrivacyTaint[];
|
|
231
|
+
derivedFrom: ProvenanceRef[];
|
|
232
|
+
summary?: JsonValue;
|
|
233
|
+
sizeBytes?: number;
|
|
234
|
+
contentHash?: string;
|
|
235
|
+
normalized?: JsonValue;
|
|
236
|
+
downgrade?: {
|
|
237
|
+
sourceRefs: ProvenanceRef[];
|
|
238
|
+
targetPrivacy: 'cloud_allowed';
|
|
239
|
+
method: 'human_approval' | 'sanitizer';
|
|
240
|
+
approvalRef?: string;
|
|
241
|
+
sanitizerId?: string;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export interface FindingRecord extends ResultRecord {
|
|
245
|
+
kind: 'finding';
|
|
246
|
+
statement: string;
|
|
247
|
+
evidenceRefs: DataRef[];
|
|
248
|
+
agentId: AgentId;
|
|
249
|
+
laneId: LaneId;
|
|
250
|
+
}
|
|
251
|
+
export interface ArtifactRecord {
|
|
252
|
+
ref: ArtifactRef;
|
|
253
|
+
agentId?: AgentId;
|
|
254
|
+
mediaType: string;
|
|
255
|
+
sizeBytes: number;
|
|
256
|
+
contentHash: string;
|
|
257
|
+
contentBase64: string;
|
|
258
|
+
privacy: PrivacyLabel;
|
|
259
|
+
privacyTaints?: PrivacyTaint[];
|
|
260
|
+
derivedFrom?: ProvenanceRef[];
|
|
261
|
+
storageState: 'memory' | 'persisted';
|
|
262
|
+
pinCount: number;
|
|
263
|
+
}
|
|
264
|
+
export interface DependencySpec {
|
|
265
|
+
key: string;
|
|
266
|
+
target: TargetRef | LocalRef;
|
|
267
|
+
condition: 'success' | 'settled';
|
|
268
|
+
}
|
|
269
|
+
export interface WaitSpec {
|
|
270
|
+
dependencies: DependencySpec[];
|
|
271
|
+
mode: 'all' | 'any' | 'quorum';
|
|
272
|
+
quorum?: number;
|
|
273
|
+
onUnsatisfied: 'fail_lane' | 'resume_with_error';
|
|
274
|
+
onCancelled?: 'unsatisfied' | 'ignore';
|
|
275
|
+
reason: 'startup' | 'effect' | 'dependency' | 'join' | 'timer';
|
|
276
|
+
deadlineAt?: number;
|
|
277
|
+
}
|
|
278
|
+
export interface WaitRecord {
|
|
279
|
+
id: WaitId;
|
|
280
|
+
laneId: LaneId;
|
|
281
|
+
spec: WaitSpec;
|
|
282
|
+
state: 'pending' | 'satisfied' | 'unsatisfied';
|
|
283
|
+
resolution?: WaitResolution;
|
|
284
|
+
}
|
|
285
|
+
export type TargetRef = {
|
|
286
|
+
kind: 'lane' | 'effect';
|
|
287
|
+
id: string;
|
|
288
|
+
};
|
|
289
|
+
export type LocalRef = {
|
|
290
|
+
local: string;
|
|
291
|
+
};
|
|
292
|
+
export type DependencyObservation = {
|
|
293
|
+
state: 'pending';
|
|
294
|
+
target: TargetRef;
|
|
295
|
+
} | {
|
|
296
|
+
state: 'settled';
|
|
297
|
+
target: TargetRef;
|
|
298
|
+
outcome: Outcome;
|
|
299
|
+
} | {
|
|
300
|
+
state: 'ignored';
|
|
301
|
+
target: TargetRef;
|
|
302
|
+
outcome: Outcome;
|
|
303
|
+
};
|
|
304
|
+
export interface WaitResolution {
|
|
305
|
+
waitId: WaitId;
|
|
306
|
+
status: 'satisfied' | 'unsatisfied';
|
|
307
|
+
dependencies: Record<string, DependencyObservation>;
|
|
308
|
+
error?: RuntimeError;
|
|
309
|
+
}
|
|
310
|
+
export type ControlProposal = {
|
|
311
|
+
type: 'cancel_lane';
|
|
312
|
+
laneId: LaneId;
|
|
313
|
+
reason: string;
|
|
314
|
+
fromLaneId: LaneId;
|
|
315
|
+
};
|
|
316
|
+
export type ResumeInput = {
|
|
317
|
+
type: 'wait';
|
|
318
|
+
resolution: WaitResolution;
|
|
319
|
+
} | {
|
|
320
|
+
type: 'submitted';
|
|
321
|
+
targets: Record<string, TargetRef>;
|
|
322
|
+
} | {
|
|
323
|
+
type: 'control_error';
|
|
324
|
+
error: RuntimeError;
|
|
325
|
+
original?: ResumeInput;
|
|
326
|
+
} | {
|
|
327
|
+
type: 'control_proposal';
|
|
328
|
+
proposals: ControlProposal[];
|
|
329
|
+
};
|
|
330
|
+
export declare function enqueueControlProposal(lane: LaneRecord, proposal: ControlProposal): void;
|
|
331
|
+
/** Replace the resume slot. Existing control_proposal inputs are parked, then promoted if the slot ends up empty. */
|
|
332
|
+
export declare function replaceResumeInput(lane: LaneRecord, input: ResumeInput | undefined): void;
|
|
333
|
+
export interface EffectSubmission {
|
|
334
|
+
key: string;
|
|
335
|
+
kind: EffectRecord['kind'];
|
|
336
|
+
concurrencyClass: ConcurrencyClass;
|
|
337
|
+
input: JsonValue;
|
|
338
|
+
derivedFrom?: ProvenanceRef[];
|
|
339
|
+
wait?: boolean;
|
|
340
|
+
privacy?: PrivacyLabel;
|
|
341
|
+
priority?: number;
|
|
342
|
+
deadlineAt?: number;
|
|
343
|
+
cancelGraceMs?: number;
|
|
344
|
+
attemptTimeoutMs?: number;
|
|
345
|
+
idempotencyKey?: string;
|
|
346
|
+
sideEffectPolicy?: SideEffectPolicy;
|
|
347
|
+
toolVersion?: string;
|
|
348
|
+
retryPolicy?: {
|
|
349
|
+
maxAttempts: number;
|
|
350
|
+
initialBackoffMs: number;
|
|
351
|
+
maxBackoffMs: number;
|
|
352
|
+
jitter: boolean;
|
|
353
|
+
};
|
|
354
|
+
duplicateExecutionPolicy?: 'allow' | 'forbid';
|
|
355
|
+
maxUnknownAttempts?: number;
|
|
356
|
+
toolCallId?: string;
|
|
357
|
+
llmEffectId?: EffectId;
|
|
358
|
+
locks?: ResourceLockSpec[];
|
|
359
|
+
}
|
|
360
|
+
export interface ForkLaneSpec {
|
|
361
|
+
key: string;
|
|
362
|
+
goal: string;
|
|
363
|
+
program: ResumePoint;
|
|
364
|
+
priority?: number;
|
|
365
|
+
contextVersion?: 'parent' | 'latest' | ContextVersion;
|
|
366
|
+
affinityKey?: string;
|
|
367
|
+
resources?: ResourceLockSpec[];
|
|
368
|
+
inputResultRefs?: ResultRef[];
|
|
369
|
+
toolSetId?: string;
|
|
370
|
+
workspacePath?: string;
|
|
371
|
+
dependsOn?: Array<{
|
|
372
|
+
key: string;
|
|
373
|
+
target: TargetRef | LocalRef;
|
|
374
|
+
condition: 'success' | 'settled';
|
|
375
|
+
}>;
|
|
376
|
+
series?: SeriesLaneSpec;
|
|
377
|
+
}
|
|
378
|
+
export interface SeriesLaneSpec {
|
|
379
|
+
member: ResumePoint;
|
|
380
|
+
keys: string[];
|
|
381
|
+
goals?: Record<string, string>;
|
|
382
|
+
members?: Record<string, {
|
|
383
|
+
dependsOn: Array<{
|
|
384
|
+
key: string;
|
|
385
|
+
condition: 'success' | 'settled';
|
|
386
|
+
}>;
|
|
387
|
+
}>;
|
|
388
|
+
onMemberFailure?: 'continue' | 'abort';
|
|
389
|
+
}
|
|
390
|
+
export interface RuntimeActionBase {
|
|
391
|
+
type: string;
|
|
392
|
+
}
|
|
393
|
+
export interface SubmitEffectsAction extends RuntimeActionBase {
|
|
394
|
+
type: 'submit_effects';
|
|
395
|
+
effects: EffectSubmission[];
|
|
396
|
+
wait?: {
|
|
397
|
+
onUnsatisfied: 'fail_lane' | 'resume_with_error';
|
|
398
|
+
onCancelled?: 'unsatisfied' | 'ignore';
|
|
399
|
+
reason?: WaitSpec['reason'];
|
|
400
|
+
deadlineAt?: number;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
export interface WaitAction extends RuntimeActionBase {
|
|
404
|
+
type: 'wait';
|
|
405
|
+
spec: WaitSpec;
|
|
406
|
+
}
|
|
407
|
+
export interface ForkAction extends RuntimeActionBase {
|
|
408
|
+
type: 'fork';
|
|
409
|
+
lanes: ForkLaneSpec[];
|
|
410
|
+
affinityAck?: boolean;
|
|
411
|
+
joinAliases?: Record<string, string>;
|
|
412
|
+
join?: {
|
|
413
|
+
condition: 'success' | 'settled';
|
|
414
|
+
mode?: WaitSpec['mode'];
|
|
415
|
+
quorum?: number;
|
|
416
|
+
deadlineAt?: number;
|
|
417
|
+
onUnsatisfied: 'fail_lane' | 'resume_with_error';
|
|
418
|
+
onCancelled?: 'unsatisfied' | 'ignore';
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
export interface CancelLaneAction extends RuntimeActionBase {
|
|
422
|
+
type: 'cancel_lane';
|
|
423
|
+
laneId: LaneId;
|
|
424
|
+
reason: 'SUPERSEDED' | 'USER_REQUESTED' | 'POLICY';
|
|
425
|
+
}
|
|
426
|
+
export interface ProposeCancelAction extends RuntimeActionBase {
|
|
427
|
+
type: 'propose_cancel';
|
|
428
|
+
laneId: LaneId;
|
|
429
|
+
reason: 'SUPERSEDED' | 'POLICY';
|
|
430
|
+
}
|
|
431
|
+
export interface CompleteAction extends RuntimeActionBase {
|
|
432
|
+
type: 'complete';
|
|
433
|
+
result: JsonValue;
|
|
434
|
+
privacy?: PrivacyLabel;
|
|
435
|
+
privacyTaints?: PrivacyTaint[];
|
|
436
|
+
derivedFrom?: ProvenanceRef[];
|
|
437
|
+
children?: 'reject_if_active' | 'cancel' | 'await';
|
|
438
|
+
}
|
|
439
|
+
export interface FailAction extends RuntimeActionBase {
|
|
440
|
+
type: 'fail';
|
|
441
|
+
error: RuntimeError;
|
|
442
|
+
privacy?: PrivacyLabel;
|
|
443
|
+
derivedFrom?: ProvenanceRef[];
|
|
444
|
+
}
|
|
445
|
+
export interface AdoptContextAction extends RuntimeActionBase {
|
|
446
|
+
type: 'adopt_context';
|
|
447
|
+
version: ContextVersion | 'latest';
|
|
448
|
+
}
|
|
449
|
+
export interface DowngradePrivacyAction extends RuntimeActionBase {
|
|
450
|
+
type: 'downgrade_privacy';
|
|
451
|
+
sourceRefs: ProvenanceRef[];
|
|
452
|
+
outputRef: ResultRef;
|
|
453
|
+
value: JsonValue;
|
|
454
|
+
targetPrivacy: 'cloud_allowed';
|
|
455
|
+
method: 'human_approval' | 'sanitizer';
|
|
456
|
+
approvalRef?: string;
|
|
457
|
+
sanitizerId?: string;
|
|
458
|
+
summary?: JsonValue;
|
|
459
|
+
}
|
|
460
|
+
export type RuntimeAction = SubmitEffectsAction | WaitAction | ForkAction | CancelLaneAction | ProposeCancelAction | CompleteAction | FailAction | AdoptContextAction | DowngradePrivacyAction;
|
|
461
|
+
export interface ContextOp {
|
|
462
|
+
op: 'set' | 'append' | 'remove' | 'compact_history';
|
|
463
|
+
path?: string[];
|
|
464
|
+
value?: JsonValue;
|
|
465
|
+
upToSeq?: number;
|
|
466
|
+
summary?: JsonValue;
|
|
467
|
+
summaryRef?: ResultRef;
|
|
468
|
+
}
|
|
469
|
+
export interface ContextDelta {
|
|
470
|
+
target: 'global' | 'lane';
|
|
471
|
+
baseVersion: ContextVersion;
|
|
472
|
+
sourceLaneId?: LaneId;
|
|
473
|
+
ops: ContextOp[];
|
|
474
|
+
privacy?: PrivacyLabel;
|
|
475
|
+
privacyTaints?: PrivacyTaint[];
|
|
476
|
+
derivedFrom?: ProvenanceRef[];
|
|
477
|
+
proposal?: boolean;
|
|
478
|
+
}
|
|
479
|
+
export interface MergeProposal {
|
|
480
|
+
id: string;
|
|
481
|
+
agentId: AgentId;
|
|
482
|
+
sourceLaneId: LaneId;
|
|
483
|
+
baseGlobalVersion: ContextVersion;
|
|
484
|
+
delta: ContextDelta;
|
|
485
|
+
createdAt: number;
|
|
486
|
+
}
|
|
487
|
+
export interface LaneStepOutput {
|
|
488
|
+
contextDelta?: ContextDelta;
|
|
489
|
+
adoptCommittedContext?: boolean;
|
|
490
|
+
actions: RuntimeAction[];
|
|
491
|
+
next: ResumePoint;
|
|
492
|
+
locals?: JsonValue;
|
|
493
|
+
}
|
|
494
|
+
export interface LLMContextSpec {
|
|
495
|
+
globalSnapshotVersion: ContextVersion;
|
|
496
|
+
laneSnapshotVersion: ContextVersion;
|
|
497
|
+
resultRefs: ResultRef[];
|
|
498
|
+
artifactRefs?: ArtifactRef[];
|
|
499
|
+
eventIds: string[];
|
|
500
|
+
toolSetId: string;
|
|
501
|
+
instruction: string;
|
|
502
|
+
privacy: PrivacyLabel;
|
|
503
|
+
privacyRefs: ProvenanceRef[];
|
|
504
|
+
privacyTaints?: PrivacyTaint[];
|
|
505
|
+
}
|
|
506
|
+
export interface LLMRequestProjection {
|
|
507
|
+
contextSpec: LLMContextSpec;
|
|
508
|
+
blocks: Array<{
|
|
509
|
+
kind: 'system' | 'policy' | 'tools' | 'global' | 'history' | 'lane' | 'events' | 'results' | 'artifacts' | 'instruction';
|
|
510
|
+
content: JsonValue;
|
|
511
|
+
}>;
|
|
512
|
+
prefixHash: string;
|
|
513
|
+
projectionHash: string;
|
|
514
|
+
builderVersion: string;
|
|
515
|
+
policyVersion: string;
|
|
516
|
+
toolSetVersion: string;
|
|
517
|
+
privacy: PrivacyLabel;
|
|
518
|
+
privacyRefs: ProvenanceRef[];
|
|
519
|
+
privacyTaints?: PrivacyTaint[];
|
|
520
|
+
}
|
|
521
|
+
export interface RuntimeEvent {
|
|
522
|
+
id: string;
|
|
523
|
+
schemaVersion: number;
|
|
524
|
+
sessionId: string;
|
|
525
|
+
seq: number;
|
|
526
|
+
timestamp: number;
|
|
527
|
+
type: string;
|
|
528
|
+
txId?: string;
|
|
529
|
+
agentId?: AgentId;
|
|
530
|
+
laneId?: LaneId;
|
|
531
|
+
effectId?: EffectId;
|
|
532
|
+
attemptId?: string;
|
|
533
|
+
causationId?: string;
|
|
534
|
+
payload: JsonValue;
|
|
535
|
+
data?: JsonValue;
|
|
536
|
+
}
|
|
537
|
+
export interface RuntimeEventInput {
|
|
538
|
+
id?: string;
|
|
539
|
+
schemaVersion?: number;
|
|
540
|
+
sessionId?: string;
|
|
541
|
+
type: string;
|
|
542
|
+
timestamp?: number;
|
|
543
|
+
txId?: string;
|
|
544
|
+
agentId?: AgentId;
|
|
545
|
+
laneId?: LaneId;
|
|
546
|
+
effectId?: EffectId;
|
|
547
|
+
attemptId?: string;
|
|
548
|
+
causationId?: string;
|
|
549
|
+
payload?: JsonValue;
|
|
550
|
+
data?: JsonValue;
|
|
551
|
+
}
|
|
552
|
+
export interface RuntimeState {
|
|
553
|
+
now: number;
|
|
554
|
+
agents: Map<AgentId, AgentRecord>;
|
|
555
|
+
lanes: Map<LaneId, LaneRecord>;
|
|
556
|
+
effects: Map<EffectId, EffectRecord>;
|
|
557
|
+
waits: Map<WaitId, WaitRecord>;
|
|
558
|
+
results: Map<ResultRef, ResultRecord>;
|
|
559
|
+
artifacts: Map<ArtifactRef, ArtifactRecord>;
|
|
560
|
+
toolCallCorrelations: Map<string, ToolCallCorrelation>;
|
|
561
|
+
mergeProposals: Map<string, MergeProposal>;
|
|
562
|
+
events: RuntimeEvent[];
|
|
563
|
+
eventsCompactedThrough?: number;
|
|
564
|
+
nextIds: {
|
|
565
|
+
agent: number;
|
|
566
|
+
lane: number;
|
|
567
|
+
effect: number;
|
|
568
|
+
wait: number;
|
|
569
|
+
result: number;
|
|
570
|
+
artifact: number;
|
|
571
|
+
proposal: number;
|
|
572
|
+
event: number;
|
|
573
|
+
};
|
|
574
|
+
maxTotalLanes: number;
|
|
575
|
+
maxQueuedEffects: number;
|
|
576
|
+
maxRunning: Record<ConcurrencyClass, number>;
|
|
577
|
+
forkAffinity: ForkAffinityMode;
|
|
578
|
+
historySoftTokens: number;
|
|
579
|
+
historyHardTokens: number;
|
|
580
|
+
maxResultSummaryBytes: number;
|
|
581
|
+
trustedSanitizerIds: Set<string>;
|
|
582
|
+
}
|
|
583
|
+
export interface ContextSnapshotRef {
|
|
584
|
+
kind: 'global' | 'lane';
|
|
585
|
+
agentId?: AgentId;
|
|
586
|
+
laneId?: LaneId;
|
|
587
|
+
version: ContextVersion;
|
|
588
|
+
}
|
|
589
|
+
export declare function globalContextRef(agentId: AgentId, version: ContextVersion): string;
|
|
590
|
+
export declare function laneContextRef(laneId: LaneId, version: ContextVersion): string;
|
|
591
|
+
export declare function parseContextSnapshotRef(ref: string): ContextSnapshotRef | undefined;
|
|
592
|
+
export declare function privacyForContextSnapshot(state: RuntimeState, lane: LaneRecord, ref: string): PrivacyMetadata | undefined;
|
|
593
|
+
export declare function privacyMetadataForDerivedRef(state: RuntimeState, lane: LaneRecord, ref: ProvenanceRef): PrivacyMetadata | undefined;
|
|
594
|
+
export declare function privacyTaintsForDerivedRefs(state: RuntimeState, lane: LaneRecord, refs: readonly ProvenanceRef[]): PrivacyTaint[];
|
|
595
|
+
export interface ToolCallCorrelation {
|
|
596
|
+
toolCallId: string;
|
|
597
|
+
llmEffectId: EffectId;
|
|
598
|
+
toolEffectId: EffectId;
|
|
599
|
+
resultRef?: ResultRef;
|
|
600
|
+
}
|
|
601
|
+
export declare function createRuntimeState(maxTotalLanes?: number, options?: {
|
|
602
|
+
maxQueuedEffects?: number;
|
|
603
|
+
maxRunning?: Partial<Record<ConcurrencyClass, number>>;
|
|
604
|
+
forkAffinity?: ForkAffinityMode;
|
|
605
|
+
historySoftTokens?: number;
|
|
606
|
+
historyHardTokens?: number;
|
|
607
|
+
maxResultSummaryBytes?: number;
|
|
608
|
+
trustedSanitizerIds?: Iterable<string>;
|
|
609
|
+
}): RuntimeState;
|
|
610
|
+
export declare function privacyRank(label: PrivacyLabel): number;
|
|
611
|
+
export declare function strictestPrivacy(labels: PrivacyLabel[]): PrivacyLabel;
|
|
612
|
+
export declare function isSideEffectful(policy: SideEffectPolicy | undefined): boolean;
|
|
613
|
+
export declare function privacyTaintPrivacy(taints: readonly PrivacyTaint[] | undefined): PrivacyLabel;
|
|
614
|
+
export declare function effectivePrivacy(base: PrivacyLabel, taints: readonly PrivacyTaint[] | undefined): PrivacyLabel;
|
|
615
|
+
export declare function validatePrivacyTaints(value: readonly PrivacyTaint[] | undefined): string | undefined;
|