pi-extensible-workflows 1.0.1 → 3.0.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/README.md +9 -2
- package/dist/src/agent-execution.d.ts +13 -14
- package/dist/src/agent-execution.js +110 -197
- package/dist/src/budget.d.ts +38 -0
- package/dist/src/budget.js +160 -0
- package/dist/src/cli.d.ts +9 -0
- package/dist/src/cli.js +536 -6
- package/dist/src/doctor.d.ts +4 -4
- package/dist/src/doctor.js +9 -29
- package/dist/src/execution.d.ts +17 -0
- package/dist/src/execution.js +630 -0
- package/dist/src/herdr.d.ts +12 -0
- package/dist/src/herdr.js +74 -0
- package/dist/src/host.d.ts +62 -0
- package/dist/src/host.js +2696 -0
- package/dist/src/index.d.ts +11 -557
- package/dist/src/index.js +8 -3974
- package/dist/src/persistence.d.ts +32 -19
- package/dist/src/persistence.js +310 -70
- package/dist/src/registry.d.ts +31 -0
- package/dist/src/registry.js +169 -0
- package/dist/src/session-inspector.d.ts +1 -0
- package/dist/src/session-inspector.js +4 -1
- package/dist/src/types.d.ts +565 -0
- package/dist/src/types.js +27 -0
- package/dist/src/utils.d.ts +26 -0
- package/dist/src/utils.js +128 -0
- package/dist/src/validation.d.ts +24 -0
- package/dist/src/validation.js +740 -0
- package/dist/src/workflow-evals.js +2 -1
- package/package.json +4 -3
- package/skills/pi-extensible-workflows/SKILL.md +52 -67
- package/src/agent-execution.ts +84 -147
- package/src/budget.ts +75 -0
- package/src/cli.ts +427 -6
- package/src/doctor.ts +13 -32
- package/src/execution.ts +540 -0
- package/src/herdr.ts +73 -0
- package/src/host.ts +2265 -0
- package/src/index.ts +11 -3453
- package/src/persistence.ts +255 -47
- package/src/registry.ts +157 -0
- package/src/session-inspector.ts +5 -1
- package/src/types.ts +113 -0
- package/src/utils.ts +108 -0
- package/src/validation.ts +616 -0
- package/src/workflow-evals.ts +2 -1
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
export declare const RUN_STATES: readonly ["queued", "running", "pausing", "paused", "awaiting_input", "completed", "failed", "stopped", "interrupted", "budget_exhausted"];
|
|
2
|
+
export declare const AGENT_STATES: readonly ["queued", "running", "waiting_for_child", "paused", "retrying", "completed", "failed", "cancelled"];
|
|
3
|
+
export declare const WORKFLOW_CALL_KINDS: readonly ["agent", "parallel", "pipeline", "checkpoint", "phase", "withWorktree", "shell"];
|
|
4
|
+
export type WorkflowCallKind = (typeof WORKFLOW_CALL_KINDS)[number];
|
|
5
|
+
export declare const WORKFLOW_RUN_STARTED_EVENT = "workflow:run-started";
|
|
6
|
+
export declare const WORKFLOW_RUN_RESUMED_EVENT = "workflow:run-resumed";
|
|
7
|
+
export declare const WORKFLOW_RUN_STATE_CHANGED_EVENT = "workflow:run-state-changed";
|
|
8
|
+
export declare const WORKFLOW_RUN_COMPLETED_EVENT = "workflow:run-completed";
|
|
9
|
+
export declare const WORKFLOW_RUN_FAILED_EVENT = "workflow:run-failed";
|
|
10
|
+
export declare const WORKFLOW_AGENT_STATE_CHANGED_EVENT = "workflow:agent-state-changed";
|
|
11
|
+
export declare const WORKFLOW_PHASE_CHANGED_EVENT = "workflow:phase-changed";
|
|
12
|
+
export declare const WORKFLOW_CHECKPOINT_STATE_CHANGED_EVENT = "workflow:checkpoint-state-changed";
|
|
13
|
+
export declare const WORKFLOW_BUDGET_EVENT = "workflow:budget-event";
|
|
14
|
+
export declare const WORKFLOW_WORKTREE_CREATED_EVENT = "workflow:worktree-created";
|
|
15
|
+
export declare const ERROR_CODES: readonly ["CONFIG_ERROR", "INVALID_SETTINGS", "INVALID_SYNTAX", "INVALID_METADATA", "DUPLICATE_NAME", "INVALID_SCHEMA", "UNKNOWN_MODEL", "UNKNOWN_TOOL", "UNKNOWN_AGENT_TYPE", "RUN_OWNED", "REGISTRY_FROZEN", "GLOBAL_COLLISION", "MISSING_WORKFLOW", "RPC_LIMIT_EXCEEDED", "SHELL_FAILED", "AGENT_TIMEOUT", "AGENT_FAILED", "RESULT_INVALID", "CANCELLED", "WORKER_UNRESPONSIVE", "WORKTREE_FAILED", "RESUME_INCOMPATIBLE", "BUDGET_EXHAUSTED", "INTERNAL_ERROR"];
|
|
16
|
+
export type RunState = (typeof RUN_STATES)[number];
|
|
17
|
+
export type AgentState = (typeof AGENT_STATES)[number];
|
|
18
|
+
export type WorkflowErrorCode = (typeof ERROR_CODES)[number];
|
|
19
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
20
|
+
[key: string]: JsonValue;
|
|
21
|
+
};
|
|
22
|
+
export type JsonSchema = {
|
|
23
|
+
[key: string]: JsonValue;
|
|
24
|
+
};
|
|
25
|
+
export interface AgentOptions {
|
|
26
|
+
label?: string;
|
|
27
|
+
model?: string;
|
|
28
|
+
thinking?: NonNullable<ModelSpec["thinking"]>;
|
|
29
|
+
tools?: string[];
|
|
30
|
+
role?: string;
|
|
31
|
+
outputSchema?: JsonSchema;
|
|
32
|
+
retries?: number;
|
|
33
|
+
timeoutMs?: number | null;
|
|
34
|
+
[key: string]: JsonValue;
|
|
35
|
+
}
|
|
36
|
+
export interface ShellOptions {
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
export interface ShellResult {
|
|
41
|
+
exitCode: number | null;
|
|
42
|
+
stdout: string;
|
|
43
|
+
stderr: string;
|
|
44
|
+
}
|
|
45
|
+
export type BudgetDimension = "tokens" | "costUsd" | "durationMs" | "agentLaunches";
|
|
46
|
+
export interface BudgetLimits {
|
|
47
|
+
soft?: number;
|
|
48
|
+
hard?: number;
|
|
49
|
+
}
|
|
50
|
+
export type WorkflowBudget = Partial<Record<BudgetDimension, BudgetLimits>>;
|
|
51
|
+
export type WorkflowBudgetPatch = Partial<Record<BudgetDimension, BudgetLimits | {
|
|
52
|
+
soft?: number | null;
|
|
53
|
+
hard?: number | null;
|
|
54
|
+
} | null>>;
|
|
55
|
+
export interface WorkflowBudgetUsage {
|
|
56
|
+
tokens: number;
|
|
57
|
+
costUsd: number;
|
|
58
|
+
durationMs: number;
|
|
59
|
+
agentLaunches: number;
|
|
60
|
+
}
|
|
61
|
+
export type BudgetEventType = "soft_crossed" | "hard_overrun" | "hard_exhausted" | "adjustment_requested" | "adjustment_approved" | "adjustment_rejected";
|
|
62
|
+
export interface BudgetEvent {
|
|
63
|
+
type: BudgetEventType;
|
|
64
|
+
budgetVersion: number;
|
|
65
|
+
dimensions: readonly BudgetDimension[];
|
|
66
|
+
usage: WorkflowBudgetUsage;
|
|
67
|
+
limits: WorkflowBudget;
|
|
68
|
+
at: number;
|
|
69
|
+
proposalId?: string;
|
|
70
|
+
previous?: WorkflowBudget;
|
|
71
|
+
proposed?: WorkflowBudget;
|
|
72
|
+
}
|
|
73
|
+
export interface BudgetApprovalRequest {
|
|
74
|
+
kind: "budget";
|
|
75
|
+
proposalId: string;
|
|
76
|
+
runId: string;
|
|
77
|
+
consumed: WorkflowBudgetUsage;
|
|
78
|
+
previous: WorkflowBudget;
|
|
79
|
+
proposed: WorkflowBudget;
|
|
80
|
+
budgetVersion: number;
|
|
81
|
+
}
|
|
82
|
+
export interface WorkflowErrorShape {
|
|
83
|
+
code: WorkflowErrorCode;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
export interface WorkflowEventBase {
|
|
87
|
+
runId: string;
|
|
88
|
+
sessionId: string;
|
|
89
|
+
workflowName: string;
|
|
90
|
+
cwd: string;
|
|
91
|
+
runDirectory: string;
|
|
92
|
+
timestamp: number;
|
|
93
|
+
}
|
|
94
|
+
export type WorkflowRunStartedEvent = WorkflowEventBase;
|
|
95
|
+
export type WorkflowRunResumedEvent = WorkflowEventBase;
|
|
96
|
+
export interface WorkflowRunStateChangedEvent extends WorkflowEventBase {
|
|
97
|
+
previousState: RunState;
|
|
98
|
+
state: RunState;
|
|
99
|
+
reason?: string;
|
|
100
|
+
errorCode?: WorkflowErrorCode;
|
|
101
|
+
}
|
|
102
|
+
export interface WorkflowRunCompletedEvent extends WorkflowEventBase {
|
|
103
|
+
resultPath: string;
|
|
104
|
+
}
|
|
105
|
+
export interface WorkflowRunFailedEvent extends WorkflowEventBase {
|
|
106
|
+
error: WorkflowErrorShape;
|
|
107
|
+
}
|
|
108
|
+
export interface WorkflowAgentStateChangedEvent extends WorkflowEventBase {
|
|
109
|
+
agentId: string;
|
|
110
|
+
displayLabel: string;
|
|
111
|
+
role?: string;
|
|
112
|
+
structuralPath: readonly string[];
|
|
113
|
+
parentId?: string;
|
|
114
|
+
parentBreadcrumb?: string;
|
|
115
|
+
worktreeOwner?: string;
|
|
116
|
+
previousState?: AgentState;
|
|
117
|
+
state: AgentState;
|
|
118
|
+
attempt: number;
|
|
119
|
+
}
|
|
120
|
+
export interface WorkflowPhaseChangedEvent extends WorkflowEventBase {
|
|
121
|
+
previousPhase?: string;
|
|
122
|
+
phase: string;
|
|
123
|
+
}
|
|
124
|
+
export type WorkflowCheckpointState = "awaiting" | "approved" | "rejected";
|
|
125
|
+
export interface WorkflowCheckpointStateChangedEvent extends WorkflowEventBase {
|
|
126
|
+
name: string;
|
|
127
|
+
state: WorkflowCheckpointState;
|
|
128
|
+
}
|
|
129
|
+
export interface WorkflowBudgetEvent extends WorkflowEventBase {
|
|
130
|
+
type: BudgetEventType;
|
|
131
|
+
budgetVersion: number;
|
|
132
|
+
dimensions: readonly BudgetDimension[];
|
|
133
|
+
usage: WorkflowBudgetUsage;
|
|
134
|
+
limits: WorkflowBudget;
|
|
135
|
+
proposalId?: string;
|
|
136
|
+
previous?: WorkflowBudget;
|
|
137
|
+
proposed?: WorkflowBudget;
|
|
138
|
+
}
|
|
139
|
+
export interface ModelSpec {
|
|
140
|
+
provider: string;
|
|
141
|
+
model: string;
|
|
142
|
+
thinking?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
143
|
+
}
|
|
144
|
+
export interface WorkflowMetadata {
|
|
145
|
+
name: string;
|
|
146
|
+
description?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface WorkflowSettings {
|
|
149
|
+
concurrency: number;
|
|
150
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
151
|
+
disabledAgentResources?: Readonly<AgentResourceExclusions>;
|
|
152
|
+
}
|
|
153
|
+
export interface AgentResourceExclusions {
|
|
154
|
+
skills: readonly string[];
|
|
155
|
+
extensions: readonly string[];
|
|
156
|
+
}
|
|
157
|
+
export interface AgentResourcePolicy {
|
|
158
|
+
globalSettingsPath: string;
|
|
159
|
+
projectSettingsPath: string;
|
|
160
|
+
projectTrusted: boolean;
|
|
161
|
+
global: AgentResourceExclusions;
|
|
162
|
+
project: AgentResourceExclusions;
|
|
163
|
+
effective: AgentResourceExclusions;
|
|
164
|
+
unmatchedSkills: string[];
|
|
165
|
+
unmatchedExtensions: string[];
|
|
166
|
+
}
|
|
167
|
+
export interface AgentActivity {
|
|
168
|
+
kind: "reasoning" | "tool" | "text";
|
|
169
|
+
text: string;
|
|
170
|
+
}
|
|
171
|
+
export interface AgentAccounting {
|
|
172
|
+
input: number;
|
|
173
|
+
output: number;
|
|
174
|
+
cacheRead: number;
|
|
175
|
+
cacheWrite: number;
|
|
176
|
+
cost: number;
|
|
177
|
+
}
|
|
178
|
+
export interface AgentSetupSummary {
|
|
179
|
+
hookNames: readonly string[];
|
|
180
|
+
model: ModelSpec;
|
|
181
|
+
tools: readonly string[];
|
|
182
|
+
cwd: string;
|
|
183
|
+
disabledAgentResources?: {
|
|
184
|
+
skills: readonly string[];
|
|
185
|
+
extensions: readonly string[];
|
|
186
|
+
unmatchedSkills: readonly string[];
|
|
187
|
+
unmatchedExtensions: readonly string[];
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface AgentAttemptSummary {
|
|
191
|
+
attempt: number;
|
|
192
|
+
sessionId: string;
|
|
193
|
+
sessionFile: string;
|
|
194
|
+
error?: {
|
|
195
|
+
code: string;
|
|
196
|
+
message: string;
|
|
197
|
+
};
|
|
198
|
+
accounting: {
|
|
199
|
+
input: number;
|
|
200
|
+
output: number;
|
|
201
|
+
cacheRead: number;
|
|
202
|
+
cacheWrite: number;
|
|
203
|
+
cost: number;
|
|
204
|
+
};
|
|
205
|
+
setup?: AgentSetupSummary;
|
|
206
|
+
}
|
|
207
|
+
export interface WorkflowWorktreeCreatedEvent extends WorkflowEventBase {
|
|
208
|
+
owner: string;
|
|
209
|
+
branch: string;
|
|
210
|
+
path: string;
|
|
211
|
+
base: string;
|
|
212
|
+
}
|
|
213
|
+
export interface WorkflowWorktreeReference {
|
|
214
|
+
readonly path: string;
|
|
215
|
+
readonly branch: string;
|
|
216
|
+
}
|
|
217
|
+
export interface AgentRecord {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
label?: string;
|
|
221
|
+
path: string;
|
|
222
|
+
state: AgentState;
|
|
223
|
+
parentId?: string;
|
|
224
|
+
structuralPath?: readonly string[];
|
|
225
|
+
parentBreadcrumb?: string;
|
|
226
|
+
worktreeOwner?: string;
|
|
227
|
+
role?: string;
|
|
228
|
+
requestedModel?: string;
|
|
229
|
+
model: ModelSpec;
|
|
230
|
+
tools: readonly string[];
|
|
231
|
+
attempts: number;
|
|
232
|
+
attemptDetails?: readonly AgentAttemptSummary[];
|
|
233
|
+
accounting?: {
|
|
234
|
+
input: number;
|
|
235
|
+
output: number;
|
|
236
|
+
cacheRead: number;
|
|
237
|
+
cacheWrite: number;
|
|
238
|
+
cost: number;
|
|
239
|
+
};
|
|
240
|
+
toolCalls?: readonly {
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
state: "running" | "completed" | "failed";
|
|
244
|
+
}[];
|
|
245
|
+
activity?: AgentActivity | undefined;
|
|
246
|
+
}
|
|
247
|
+
export interface WorkflowRunEvent {
|
|
248
|
+
type: string;
|
|
249
|
+
message: string;
|
|
250
|
+
}
|
|
251
|
+
export interface WorkflowRetryProvenance {
|
|
252
|
+
sourceRunId: string;
|
|
253
|
+
lineageRootRunId: string;
|
|
254
|
+
completedPaths: readonly string[];
|
|
255
|
+
incompletePaths: readonly string[];
|
|
256
|
+
namedWorktrees: readonly string[];
|
|
257
|
+
}
|
|
258
|
+
export interface WorkflowPhaseRecord {
|
|
259
|
+
phase: string;
|
|
260
|
+
afterAgent: number;
|
|
261
|
+
}
|
|
262
|
+
export interface RunRecord {
|
|
263
|
+
id: string;
|
|
264
|
+
workflowName: string;
|
|
265
|
+
cwd: string;
|
|
266
|
+
sessionId: string;
|
|
267
|
+
state: RunState;
|
|
268
|
+
parentRunId?: string;
|
|
269
|
+
retry?: WorkflowRetryProvenance;
|
|
270
|
+
phase?: string;
|
|
271
|
+
phaseHistory?: readonly WorkflowPhaseRecord[];
|
|
272
|
+
agents: readonly AgentRecord[];
|
|
273
|
+
error?: WorkflowErrorShape;
|
|
274
|
+
budget?: WorkflowBudget;
|
|
275
|
+
budgetVersion?: number;
|
|
276
|
+
usage?: WorkflowBudgetUsage;
|
|
277
|
+
budgetEvents?: readonly BudgetEvent[];
|
|
278
|
+
events?: readonly WorkflowRunEvent[];
|
|
279
|
+
}
|
|
280
|
+
export declare const LAUNCH_SNAPSHOT_IDENTITY_VERSION = 5;
|
|
281
|
+
export interface AgentDefinition {
|
|
282
|
+
prompt?: string;
|
|
283
|
+
description?: string;
|
|
284
|
+
model?: string;
|
|
285
|
+
thinking?: NonNullable<ModelSpec["thinking"]>;
|
|
286
|
+
tools?: readonly string[];
|
|
287
|
+
disabledAgentResources?: AgentResourceExclusions;
|
|
288
|
+
}
|
|
289
|
+
export interface LaunchSnapshot {
|
|
290
|
+
identityVersion?: number;
|
|
291
|
+
launchKind?: "inline" | "function";
|
|
292
|
+
functionName?: string;
|
|
293
|
+
script: string;
|
|
294
|
+
args: JsonValue;
|
|
295
|
+
metadata: WorkflowMetadata;
|
|
296
|
+
settings: WorkflowSettings;
|
|
297
|
+
budget?: WorkflowBudget;
|
|
298
|
+
settingsPath?: string;
|
|
299
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
300
|
+
models: readonly string[];
|
|
301
|
+
tools: readonly string[];
|
|
302
|
+
agentTypes: readonly string[];
|
|
303
|
+
roles?: Readonly<Record<string, AgentDefinition>>;
|
|
304
|
+
projectRoles?: readonly string[];
|
|
305
|
+
schemas: readonly JsonSchema[];
|
|
306
|
+
}
|
|
307
|
+
export interface PreflightCapabilities {
|
|
308
|
+
models: ReadonlySet<string>;
|
|
309
|
+
tools: ReadonlySet<string>;
|
|
310
|
+
agentTypes: ReadonlySet<string>;
|
|
311
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
312
|
+
knownModels?: ReadonlySet<string>;
|
|
313
|
+
settingsPath?: string;
|
|
314
|
+
skipModelAvailability?: boolean;
|
|
315
|
+
}
|
|
316
|
+
export interface PreflightResult {
|
|
317
|
+
metadata: WorkflowMetadata;
|
|
318
|
+
referenced: {
|
|
319
|
+
phases: readonly string[];
|
|
320
|
+
models: readonly string[];
|
|
321
|
+
tools: readonly string[];
|
|
322
|
+
agentTypes: readonly string[];
|
|
323
|
+
};
|
|
324
|
+
schemas: readonly JsonSchema[];
|
|
325
|
+
dynamicAgentRoles: boolean;
|
|
326
|
+
}
|
|
327
|
+
export interface WorkflowOrchestrationContext {
|
|
328
|
+
agent: (prompt: string, options?: Readonly<AgentOptions>) => Promise<JsonValue>;
|
|
329
|
+
shell: (command: string, options?: ShellOptions) => Promise<ShellResult>;
|
|
330
|
+
prompt: (template: string, values: Readonly<Record<string, JsonValue>>) => string;
|
|
331
|
+
parallel: (...args: readonly unknown[]) => Promise<JsonValue>;
|
|
332
|
+
pipeline: (...args: readonly unknown[]) => Promise<JsonValue>;
|
|
333
|
+
withWorktree: (name: string, callback: WorkflowWorktreeCallback) => Promise<JsonValue>;
|
|
334
|
+
checkpoint: (...args: readonly unknown[]) => Promise<boolean>;
|
|
335
|
+
phase: (name: string) => void;
|
|
336
|
+
log: (message: string) => void;
|
|
337
|
+
}
|
|
338
|
+
export interface WorkflowRunContext {
|
|
339
|
+
cwd: string;
|
|
340
|
+
sessionId: string;
|
|
341
|
+
runId: string;
|
|
342
|
+
workflow: Readonly<WorkflowMetadata>;
|
|
343
|
+
args: JsonValue;
|
|
344
|
+
signal: AbortSignal;
|
|
345
|
+
}
|
|
346
|
+
export interface WorkflowFunctionContext extends WorkflowOrchestrationContext {
|
|
347
|
+
run: Readonly<WorkflowRunContext>;
|
|
348
|
+
invoke: (name: string, input: Readonly<Record<string, JsonValue>>) => Promise<JsonValue>;
|
|
349
|
+
}
|
|
350
|
+
export type WorkflowWorktreeCallback = (reference: Readonly<WorkflowWorktreeReference>) => JsonValue | Promise<JsonValue>;
|
|
351
|
+
export interface WorkflowFunction {
|
|
352
|
+
description: string;
|
|
353
|
+
input: JsonSchema;
|
|
354
|
+
output: JsonSchema;
|
|
355
|
+
run: (input: Readonly<Record<string, JsonValue>>, context: Readonly<WorkflowFunctionContext>) => Promise<JsonValue> | JsonValue;
|
|
356
|
+
}
|
|
357
|
+
export interface WorkflowVariable {
|
|
358
|
+
description: string;
|
|
359
|
+
schema: JsonSchema;
|
|
360
|
+
resolve: (run: Readonly<WorkflowRunContext>) => Promise<JsonValue> | JsonValue;
|
|
361
|
+
}
|
|
362
|
+
export interface AgentSetup {
|
|
363
|
+
prompt: string;
|
|
364
|
+
options: Record<string, JsonValue>;
|
|
365
|
+
sessionInput: {
|
|
366
|
+
extensionFactories?: unknown[];
|
|
367
|
+
[key: string]: unknown;
|
|
368
|
+
};
|
|
369
|
+
createSession: unknown;
|
|
370
|
+
}
|
|
371
|
+
export interface AgentSetupContext {
|
|
372
|
+
readonly run: Readonly<WorkflowRunContext>;
|
|
373
|
+
readonly identity: Readonly<AgentIdentity>;
|
|
374
|
+
readonly attempt: number;
|
|
375
|
+
readonly signal: AbortSignal;
|
|
376
|
+
}
|
|
377
|
+
export interface AgentSetupHook {
|
|
378
|
+
priority?: number;
|
|
379
|
+
setup: (agent: AgentSetup, context: Readonly<AgentSetupContext>) => void | Promise<void>;
|
|
380
|
+
}
|
|
381
|
+
export interface RegisteredAgentSetupHook {
|
|
382
|
+
name: string;
|
|
383
|
+
priority: number;
|
|
384
|
+
setup: AgentSetupHook["setup"];
|
|
385
|
+
}
|
|
386
|
+
export interface WorkflowExtension {
|
|
387
|
+
version: string;
|
|
388
|
+
headline: string;
|
|
389
|
+
description: string;
|
|
390
|
+
functions?: Readonly<Record<string, WorkflowFunction>>;
|
|
391
|
+
variables?: Readonly<Record<string, WorkflowVariable>>;
|
|
392
|
+
agentSetupHooks?: Readonly<Record<string, AgentSetupHook>>;
|
|
393
|
+
}
|
|
394
|
+
export interface WorkflowJournal {
|
|
395
|
+
get(path: string): JsonValue | undefined;
|
|
396
|
+
put(path: string, value: JsonValue): void;
|
|
397
|
+
}
|
|
398
|
+
export declare class WorkflowError extends Error {
|
|
399
|
+
readonly code: WorkflowErrorCode;
|
|
400
|
+
constructor(code: WorkflowErrorCode, message: string);
|
|
401
|
+
}
|
|
402
|
+
export interface WorkflowFailureAgent {
|
|
403
|
+
id: string;
|
|
404
|
+
label?: string;
|
|
405
|
+
role?: string;
|
|
406
|
+
structuralPath: readonly string[];
|
|
407
|
+
attempt: number;
|
|
408
|
+
sessionId?: string;
|
|
409
|
+
sessionFile?: string;
|
|
410
|
+
}
|
|
411
|
+
export interface WorkflowSiblingAgent {
|
|
412
|
+
id: string;
|
|
413
|
+
label?: string;
|
|
414
|
+
role?: string;
|
|
415
|
+
structuralPath: readonly string[];
|
|
416
|
+
}
|
|
417
|
+
export interface WorkflowFailureDiagnostics {
|
|
418
|
+
runId: string;
|
|
419
|
+
workflowName: string;
|
|
420
|
+
state: RunState;
|
|
421
|
+
failedAt: string | null;
|
|
422
|
+
error: WorkflowErrorShape;
|
|
423
|
+
failedAgent?: WorkflowFailureAgent;
|
|
424
|
+
completedSiblingAgents?: readonly WorkflowSiblingAgent[];
|
|
425
|
+
completedSiblingPaths: readonly (readonly string[])[];
|
|
426
|
+
retry?: {
|
|
427
|
+
sourceRunId: string;
|
|
428
|
+
action: string;
|
|
429
|
+
completedPaths: readonly string[];
|
|
430
|
+
incompletePaths: readonly string[];
|
|
431
|
+
namedWorktrees: readonly string[];
|
|
432
|
+
warning: string;
|
|
433
|
+
};
|
|
434
|
+
artifacts: {
|
|
435
|
+
runDirectory: string;
|
|
436
|
+
statePath: string;
|
|
437
|
+
journalPath: string;
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
export interface CheckpointInput {
|
|
441
|
+
name: string;
|
|
442
|
+
prompt: string;
|
|
443
|
+
context: JsonValue;
|
|
444
|
+
}
|
|
445
|
+
export interface AgentIdentity {
|
|
446
|
+
structuralPath: readonly string[];
|
|
447
|
+
callSite: string;
|
|
448
|
+
occurrence: number;
|
|
449
|
+
parentBreadcrumb?: string;
|
|
450
|
+
worktreeOwner?: string;
|
|
451
|
+
}
|
|
452
|
+
export interface ShellIdentity {
|
|
453
|
+
structuralPath: readonly string[];
|
|
454
|
+
callSite: string;
|
|
455
|
+
occurrence: number;
|
|
456
|
+
worktreeOwner?: string;
|
|
457
|
+
}
|
|
458
|
+
export interface WorkflowBridge {
|
|
459
|
+
agent?: (prompt: string, options: Readonly<Record<string, JsonValue>>, signal: AbortSignal, identity: AgentIdentity) => Promise<JsonValue>;
|
|
460
|
+
shell?: (command: string, options: ShellOptions, signal: AbortSignal, identity: ShellIdentity) => Promise<ShellResult>;
|
|
461
|
+
checkpoint?: (input: Readonly<Record<string, JsonValue>>, signal: AbortSignal) => boolean | Promise<boolean>;
|
|
462
|
+
function?: (name: string, input: Readonly<Record<string, JsonValue>>, path: string, signal: AbortSignal, worktreeOwner?: string, structuralPath?: readonly string[]) => Promise<JsonValue>;
|
|
463
|
+
worktree?: (owner: string, signal: AbortSignal) => Promise<Readonly<WorkflowWorktreeReference>>;
|
|
464
|
+
functions?: Readonly<Record<string, {
|
|
465
|
+
name: string;
|
|
466
|
+
}>>;
|
|
467
|
+
variables?: Readonly<Record<string, JsonValue>>;
|
|
468
|
+
phase?: (name: string) => void | Promise<void>;
|
|
469
|
+
log?: (message: string) => void | Promise<void>;
|
|
470
|
+
}
|
|
471
|
+
export interface WorkflowExecution {
|
|
472
|
+
result: Promise<JsonValue>;
|
|
473
|
+
cancel: () => void;
|
|
474
|
+
}
|
|
475
|
+
export interface StaticWorkflowScope {
|
|
476
|
+
kind: "parallel" | "pipeline";
|
|
477
|
+
name: string | null;
|
|
478
|
+
key: string | null;
|
|
479
|
+
}
|
|
480
|
+
export type StaticWorkflowExecution = "parallel" | "sequential";
|
|
481
|
+
export interface StaticWorkflowCall {
|
|
482
|
+
kind: WorkflowCallKind;
|
|
483
|
+
start: number;
|
|
484
|
+
end: number;
|
|
485
|
+
name: string | null;
|
|
486
|
+
prompt: string | null;
|
|
487
|
+
model: string | null;
|
|
488
|
+
label?: string | null;
|
|
489
|
+
role: string | null;
|
|
490
|
+
retries?: number | null;
|
|
491
|
+
outputSchema?: JsonSchema | null;
|
|
492
|
+
options?: Readonly<Record<string, JsonValue>> | null;
|
|
493
|
+
optionKeys?: readonly string[];
|
|
494
|
+
execution?: StaticWorkflowExecution;
|
|
495
|
+
structure?: readonly StaticWorkflowScope[];
|
|
496
|
+
}
|
|
497
|
+
export interface WorkflowCatalogFunction {
|
|
498
|
+
name: string;
|
|
499
|
+
version: string;
|
|
500
|
+
headline: string;
|
|
501
|
+
extensionDescription: string;
|
|
502
|
+
description: string;
|
|
503
|
+
input: JsonSchema;
|
|
504
|
+
output: JsonSchema;
|
|
505
|
+
}
|
|
506
|
+
export interface WorkflowCatalogVariable {
|
|
507
|
+
name: string;
|
|
508
|
+
version: string;
|
|
509
|
+
headline: string;
|
|
510
|
+
extensionDescription: string;
|
|
511
|
+
description: string;
|
|
512
|
+
schema: JsonSchema;
|
|
513
|
+
}
|
|
514
|
+
export interface WorkflowCatalog {
|
|
515
|
+
functions: readonly WorkflowCatalogFunction[];
|
|
516
|
+
variables: readonly WorkflowCatalogVariable[];
|
|
517
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
518
|
+
}
|
|
519
|
+
export interface WorkflowCatalogIndexFunction {
|
|
520
|
+
name: string;
|
|
521
|
+
description: string;
|
|
522
|
+
input: JsonSchema;
|
|
523
|
+
}
|
|
524
|
+
export interface WorkflowCatalogIndexVariable {
|
|
525
|
+
name: string;
|
|
526
|
+
description: string;
|
|
527
|
+
schema: JsonSchema;
|
|
528
|
+
}
|
|
529
|
+
export interface WorkflowCatalogIndex {
|
|
530
|
+
functions: readonly WorkflowCatalogIndexFunction[];
|
|
531
|
+
variables: readonly WorkflowCatalogIndexVariable[];
|
|
532
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
533
|
+
}
|
|
534
|
+
export interface WorkflowCatalogError {
|
|
535
|
+
error: {
|
|
536
|
+
code: "NOT_FOUND";
|
|
537
|
+
name: string;
|
|
538
|
+
message: string;
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
export interface WorkflowValidationParameters {
|
|
542
|
+
name?: string;
|
|
543
|
+
description?: string;
|
|
544
|
+
script?: string;
|
|
545
|
+
workflow?: string;
|
|
546
|
+
args?: unknown;
|
|
547
|
+
}
|
|
548
|
+
export interface WorkflowValidationContext {
|
|
549
|
+
cwd: string;
|
|
550
|
+
projectTrusted: boolean;
|
|
551
|
+
availableModels: ReadonlySet<string>;
|
|
552
|
+
rootTools: ReadonlySet<string>;
|
|
553
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
554
|
+
knownModels?: ReadonlySet<string>;
|
|
555
|
+
settingsPath?: string;
|
|
556
|
+
agentDir?: string;
|
|
557
|
+
}
|
|
558
|
+
export interface ValidatedWorkflowLaunch {
|
|
559
|
+
script: string;
|
|
560
|
+
checked: PreflightResult;
|
|
561
|
+
agentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
562
|
+
projectAgentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
563
|
+
roleNames: readonly string[];
|
|
564
|
+
functionName?: string;
|
|
565
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const RUN_STATES = ["queued", "running", "pausing", "paused", "awaiting_input", "completed", "failed", "stopped", "interrupted", "budget_exhausted"];
|
|
2
|
+
export const AGENT_STATES = ["queued", "running", "waiting_for_child", "paused", "retrying", "completed", "failed", "cancelled"];
|
|
3
|
+
export const WORKFLOW_CALL_KINDS = ["agent", "parallel", "pipeline", "checkpoint", "phase", "withWorktree", "shell"];
|
|
4
|
+
export const WORKFLOW_RUN_STARTED_EVENT = "workflow:run-started";
|
|
5
|
+
export const WORKFLOW_RUN_RESUMED_EVENT = "workflow:run-resumed";
|
|
6
|
+
export const WORKFLOW_RUN_STATE_CHANGED_EVENT = "workflow:run-state-changed";
|
|
7
|
+
export const WORKFLOW_RUN_COMPLETED_EVENT = "workflow:run-completed";
|
|
8
|
+
export const WORKFLOW_RUN_FAILED_EVENT = "workflow:run-failed";
|
|
9
|
+
export const WORKFLOW_AGENT_STATE_CHANGED_EVENT = "workflow:agent-state-changed";
|
|
10
|
+
export const WORKFLOW_PHASE_CHANGED_EVENT = "workflow:phase-changed";
|
|
11
|
+
export const WORKFLOW_CHECKPOINT_STATE_CHANGED_EVENT = "workflow:checkpoint-state-changed";
|
|
12
|
+
export const WORKFLOW_BUDGET_EVENT = "workflow:budget-event";
|
|
13
|
+
export const WORKFLOW_WORKTREE_CREATED_EVENT = "workflow:worktree-created";
|
|
14
|
+
export const ERROR_CODES = [
|
|
15
|
+
"CONFIG_ERROR", "INVALID_SETTINGS", "INVALID_SYNTAX", "INVALID_METADATA", "DUPLICATE_NAME", "INVALID_SCHEMA", "UNKNOWN_MODEL", "UNKNOWN_TOOL", "UNKNOWN_AGENT_TYPE",
|
|
16
|
+
"RUN_OWNED", "REGISTRY_FROZEN", "GLOBAL_COLLISION", "MISSING_WORKFLOW", "RPC_LIMIT_EXCEEDED", "SHELL_FAILED", "AGENT_TIMEOUT", "AGENT_FAILED", "RESULT_INVALID",
|
|
17
|
+
"CANCELLED", "WORKER_UNRESPONSIVE", "WORKTREE_FAILED", "RESUME_INCOMPATIBLE", "BUDGET_EXHAUSTED", "INTERNAL_ERROR",
|
|
18
|
+
];
|
|
19
|
+
export const LAUNCH_SNAPSHOT_IDENTITY_VERSION = 5;
|
|
20
|
+
export class WorkflowError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(code, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.name = "WorkflowError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WorkflowError, type AgentResourceExclusions, type JsonValue, type ModelSpec, type WorkflowErrorCode } from "./types.js";
|
|
2
|
+
export declare function object(value: unknown): value is Record<string, unknown>;
|
|
3
|
+
export { object as isObject };
|
|
4
|
+
export declare function jsonValue(value: unknown, seen?: Set<object>): value is JsonValue;
|
|
5
|
+
export declare function jsonObject(value: unknown): value is Record<string, JsonValue>;
|
|
6
|
+
export declare function positiveInteger(value: unknown): value is number;
|
|
7
|
+
export declare function deepFreeze<T>(value: T): T;
|
|
8
|
+
export declare function errorText(error: unknown): string;
|
|
9
|
+
export declare function errorCode(error: unknown): WorkflowErrorCode | undefined;
|
|
10
|
+
export declare function markWorkflowAuthored(error: WorkflowError, authored?: boolean): WorkflowError;
|
|
11
|
+
export declare function isWorkflowAuthored(error: unknown): boolean;
|
|
12
|
+
export declare function asWorkflowError(error: unknown): WorkflowError;
|
|
13
|
+
export declare function fail(code: WorkflowErrorCode, message: string): never;
|
|
14
|
+
export declare function parseThinking(value: unknown): ModelSpec["thinking"] | undefined;
|
|
15
|
+
export declare function parseModelReference(value: string): ModelSpec;
|
|
16
|
+
export declare function modelAliasName(value: string, aliases: Readonly<Record<string, string>>): string | undefined;
|
|
17
|
+
export declare function validateModelAliases(value: unknown, settingsPath?: string): Readonly<Record<string, string>>;
|
|
18
|
+
export declare function unknownModel(value: string, target: string | undefined, settingsPath?: string): never;
|
|
19
|
+
export declare function resolveModelReference(value: string, aliases?: Readonly<Record<string, string>>, knownModels?: ReadonlySet<string>, settingsPath?: string): ModelSpec;
|
|
20
|
+
export declare function modelCapability(value: string | ModelSpec, aliases?: Readonly<Record<string, string>>, knownModels?: ReadonlySet<string>, settingsPath?: string): string;
|
|
21
|
+
export declare function aliasDrift(previous: Readonly<Record<string, string>>, current: Readonly<Record<string, string>>): string[];
|
|
22
|
+
export declare function mergeAgentResourceExclusions(...values: (AgentResourceExclusions | undefined)[]): AgentResourceExclusions;
|
|
23
|
+
export declare function createLaunchSnapshot(input: Omit<import("./types.js").LaunchSnapshot, "identityVersion"> & {
|
|
24
|
+
identityVersion?: number;
|
|
25
|
+
}): Readonly<import("./types.js").LaunchSnapshot>;
|
|
26
|
+
export declare function loadLaunchSnapshot(input: import("./types.js").LaunchSnapshot): Readonly<import("./types.js").LaunchSnapshot>;
|