pi-extensible-workflows 1.0.0 → 2.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 +7 -2
- package/dist/src/agent-execution.d.ts +13 -0
- package/dist/src/agent-execution.js +177 -40
- package/dist/src/ambient-workflow-evals.js +14 -33
- package/dist/src/cli.d.ts +9 -0
- package/dist/src/cli.js +530 -6
- package/dist/src/doctor.d.ts +4 -4
- package/dist/src/doctor.js +9 -31
- package/dist/src/herdr.d.ts +12 -0
- package/dist/src/herdr.js +74 -0
- package/dist/src/index.d.ts +107 -27
- package/dist/src/index.js +838 -322
- package/dist/src/persistence.d.ts +28 -0
- package/dist/src/persistence.js +213 -16
- package/dist/src/session-inspector.d.ts +1 -0
- package/dist/src/session-inspector.js +3 -0
- package/dist/src/workflow-evals.d.ts +1 -0
- package/dist/src/workflow-evals.js +25 -26
- package/package.json +8 -4
- package/skills/pi-extensible-workflows/SKILL.md +48 -60
- package/src/agent-execution.ts +140 -27
- package/src/ambient-workflow-evals.ts +18 -28
- package/src/cli.ts +418 -6
- package/src/doctor.ts +13 -35
- package/src/herdr.ts +73 -0
- package/src/index.ts +734 -266
- package/src/persistence.ts +192 -16
- package/src/session-inspector.ts +4 -0
- package/src/workflow-evals.ts +15 -17
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type HerdrPaneAction = "inspect" | "transcript" | "fork";
|
|
2
|
+
export interface HerdrPaneRequest {
|
|
3
|
+
action: HerdrPaneAction;
|
|
4
|
+
cwd: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
original?: string;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type HerdrCommandRunner = (args: readonly string[]) => Promise<string>;
|
|
10
|
+
export declare function herdrPaneId(env?: NodeJS.ProcessEnv): string | undefined;
|
|
11
|
+
export declare function herdrPaneCommand(request: HerdrPaneRequest): string;
|
|
12
|
+
export declare function openHerdrPane(request: HerdrPaneRequest, runner?: HerdrCommandRunner): Promise<string>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
const runHerdr = (args) => new Promise((resolve, reject) => {
|
|
4
|
+
execFile("herdr", [...args], { encoding: "utf8", maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
5
|
+
if (error) {
|
|
6
|
+
reject(new Error(error.message));
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
resolve(stdout);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
export function herdrPaneId(env = process.env) {
|
|
13
|
+
if (env.HERDR_ENV !== "1")
|
|
14
|
+
return undefined;
|
|
15
|
+
const paneId = env.HERDR_PANE_ID?.trim();
|
|
16
|
+
return paneId || undefined;
|
|
17
|
+
}
|
|
18
|
+
function shellQuote(value) { return `'${value.replace(/'/g, `'\\''`)}'`; }
|
|
19
|
+
function json(value) { return JSON.parse(value); }
|
|
20
|
+
function record(value) { return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined; }
|
|
21
|
+
function paneLayout(value, targetPane) {
|
|
22
|
+
const root = record(value);
|
|
23
|
+
const result = record(root?.result);
|
|
24
|
+
const layout = record(result?.layout);
|
|
25
|
+
const rawPanes = layout?.panes;
|
|
26
|
+
if (!Array.isArray(rawPanes))
|
|
27
|
+
throw new Error("Herdr returned an invalid pane layout.");
|
|
28
|
+
const panes = rawPanes;
|
|
29
|
+
const pane = panes.find((candidate) => record(candidate)?.pane_id === targetPane);
|
|
30
|
+
const rect = record(record(pane)?.rect);
|
|
31
|
+
const width = rect?.width;
|
|
32
|
+
const height = rect?.height;
|
|
33
|
+
if (width === undefined || height === undefined || typeof width !== "number" || typeof height !== "number")
|
|
34
|
+
throw new Error("Herdr returned an invalid target pane geometry.");
|
|
35
|
+
return { width, height };
|
|
36
|
+
}
|
|
37
|
+
function splitPaneId(value) {
|
|
38
|
+
const pane = record(record(record(value)?.result)?.pane);
|
|
39
|
+
const paneId = pane?.pane_id;
|
|
40
|
+
if (typeof paneId !== "string" || !paneId)
|
|
41
|
+
throw new Error("Herdr returned an invalid created pane ID.");
|
|
42
|
+
return paneId;
|
|
43
|
+
}
|
|
44
|
+
function commandFor(request) {
|
|
45
|
+
const cliPath = fileURLToPath(new URL("./cli.js", import.meta.resolve("pi-extensible-workflows")));
|
|
46
|
+
const environment = ["PI_CODING_AGENT_DIR", "PI_CODING_AGENT_SESSION_DIR"].flatMap((name) => process.env[name] === undefined ? [] : [`${name}=${shellQuote(process.env[name] ?? "")}`]);
|
|
47
|
+
const command = request.action === "inspect"
|
|
48
|
+
? [shellQuote(process.execPath), shellQuote(cliPath), "inspect", shellQuote(request.sessionId ?? "")]
|
|
49
|
+
: request.action === "transcript"
|
|
50
|
+
? [shellQuote(process.execPath), shellQuote(cliPath), "transcript", shellQuote(request.original ?? "")]
|
|
51
|
+
: ["pi", "--fork", shellQuote(request.original ?? ""), ...(request.readOnly ? ["--tools", shellQuote("read,grep,find,ls")] : [])];
|
|
52
|
+
return `cd ${shellQuote(request.cwd)} && ${environment.length ? `${environment.join(" ")} ` : ""}${command.join(" ")}`;
|
|
53
|
+
}
|
|
54
|
+
export function herdrPaneCommand(request) { return commandFor(request); }
|
|
55
|
+
export async function openHerdrPane(request, runner = runHerdr) {
|
|
56
|
+
const targetPane = herdrPaneId();
|
|
57
|
+
if (!targetPane)
|
|
58
|
+
throw new Error("Pane actions require a Herdr-managed session with HERDR_PANE_ID.");
|
|
59
|
+
if (!request.cwd)
|
|
60
|
+
throw new Error("Pane actions require a working directory.");
|
|
61
|
+
if ((request.action === "inspect" && !request.sessionId) || (request.action !== "inspect" && !request.original))
|
|
62
|
+
throw new Error("Pane action is missing its session source.");
|
|
63
|
+
const layout = paneLayout(json(await runner(["pane", "layout", "--pane", targetPane])), targetPane);
|
|
64
|
+
const direction = layout.width > layout.height ? "right" : "down";
|
|
65
|
+
const paneId = splitPaneId(json(await runner(["pane", "split", targetPane, "--direction", direction, "--no-focus"])));
|
|
66
|
+
try {
|
|
67
|
+
await runner(["pane", "run", paneId, commandFor(request)]);
|
|
68
|
+
return paneId;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
await runner(["pane", "close", paneId]).catch(() => undefined);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { RunStore } from "./persistence.js";
|
|
|
5
5
|
import type { AwaitingCheckpoint, PersistedRun, WorktreeReference } from "./persistence.js";
|
|
6
6
|
export declare const RUN_STATES: readonly ["queued", "running", "pausing", "paused", "awaiting_input", "completed", "failed", "stopped", "interrupted", "budget_exhausted"];
|
|
7
7
|
export declare const AGENT_STATES: readonly ["queued", "running", "waiting_for_child", "paused", "retrying", "completed", "failed", "cancelled"];
|
|
8
|
-
export declare const
|
|
9
|
-
export
|
|
8
|
+
export declare const WORKFLOW_CALL_KINDS: readonly ["agent", "conversation", "parallel", "pipeline", "checkpoint", "phase", "withWorktree", "shell"];
|
|
9
|
+
export type WorkflowCallKind = (typeof WORKFLOW_CALL_KINDS)[number];
|
|
10
10
|
export declare const WORKFLOW_RUN_STARTED_EVENT = "workflow:run-started";
|
|
11
11
|
export declare const WORKFLOW_RUN_RESUMED_EVENT = "workflow:run-resumed";
|
|
12
12
|
export declare const WORKFLOW_RUN_STATE_CHANGED_EVENT = "workflow:run-state-changed";
|
|
@@ -17,7 +17,7 @@ export declare const WORKFLOW_PHASE_CHANGED_EVENT = "workflow:phase-changed";
|
|
|
17
17
|
export declare const WORKFLOW_CHECKPOINT_STATE_CHANGED_EVENT = "workflow:checkpoint-state-changed";
|
|
18
18
|
export declare const WORKFLOW_BUDGET_EVENT = "workflow:budget-event";
|
|
19
19
|
export declare const WORKFLOW_WORKTREE_CREATED_EVENT = "workflow:worktree-created";
|
|
20
|
-
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", "AGENT_TIMEOUT", "AGENT_FAILED", "RESULT_INVALID", "CANCELLED", "WORKER_UNRESPONSIVE", "WORKTREE_FAILED", "RESUME_INCOMPATIBLE", "BUDGET_EXHAUSTED", "INTERNAL_ERROR"];
|
|
20
|
+
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"];
|
|
21
21
|
export type RunState = (typeof RUN_STATES)[number];
|
|
22
22
|
export type AgentState = (typeof AGENT_STATES)[number];
|
|
23
23
|
export type WorkflowErrorCode = (typeof ERROR_CODES)[number];
|
|
@@ -27,6 +27,15 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
|
27
27
|
export type JsonSchema = {
|
|
28
28
|
[key: string]: JsonValue;
|
|
29
29
|
};
|
|
30
|
+
export interface ShellOptions {
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
env?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export interface ShellResult {
|
|
35
|
+
exitCode: number | null;
|
|
36
|
+
stdout: string;
|
|
37
|
+
stderr: string;
|
|
38
|
+
}
|
|
30
39
|
export type BudgetDimension = "tokens" | "costUsd" | "durationMs" | "agentLaunches";
|
|
31
40
|
export interface BudgetLimits {
|
|
32
41
|
soft?: number;
|
|
@@ -184,6 +193,10 @@ export interface WorkflowWorktreeCreatedEvent extends WorkflowEventBase {
|
|
|
184
193
|
path: string;
|
|
185
194
|
base: string;
|
|
186
195
|
}
|
|
196
|
+
export interface WorkflowWorktreeReference {
|
|
197
|
+
readonly path: string;
|
|
198
|
+
readonly branch: string;
|
|
199
|
+
}
|
|
187
200
|
export interface AgentRecord {
|
|
188
201
|
id: string;
|
|
189
202
|
name: string;
|
|
@@ -215,7 +228,7 @@ export interface AgentRecord {
|
|
|
215
228
|
activity?: AgentActivity | undefined;
|
|
216
229
|
}
|
|
217
230
|
export interface WorkflowRunEvent {
|
|
218
|
-
type:
|
|
231
|
+
type: string;
|
|
219
232
|
message: string;
|
|
220
233
|
}
|
|
221
234
|
export interface RunRecord {
|
|
@@ -224,6 +237,7 @@ export interface RunRecord {
|
|
|
224
237
|
cwd: string;
|
|
225
238
|
sessionId: string;
|
|
226
239
|
state: RunState;
|
|
240
|
+
parentRunId?: string;
|
|
227
241
|
phase?: string;
|
|
228
242
|
agents: readonly AgentRecord[];
|
|
229
243
|
error?: WorkflowErrorShape;
|
|
@@ -233,9 +247,11 @@ export interface RunRecord {
|
|
|
233
247
|
budgetEvents?: readonly BudgetEvent[];
|
|
234
248
|
events?: readonly WorkflowRunEvent[];
|
|
235
249
|
}
|
|
236
|
-
export declare const LAUNCH_SNAPSHOT_IDENTITY_VERSION =
|
|
250
|
+
export declare const LAUNCH_SNAPSHOT_IDENTITY_VERSION = 4;
|
|
237
251
|
export interface LaunchSnapshot {
|
|
238
252
|
identityVersion?: number;
|
|
253
|
+
launchKind?: "inline" | "function";
|
|
254
|
+
functionName?: string;
|
|
239
255
|
script: string;
|
|
240
256
|
args: JsonValue;
|
|
241
257
|
metadata: WorkflowMetadata;
|
|
@@ -272,10 +288,14 @@ export interface PreflightResult {
|
|
|
272
288
|
}
|
|
273
289
|
export interface WorkflowOrchestrationContext {
|
|
274
290
|
agent: (...args: readonly unknown[]) => Promise<JsonValue>;
|
|
291
|
+
shell: (command: string, options?: ShellOptions) => Promise<ShellResult>;
|
|
275
292
|
prompt: (template: string, values: Readonly<Record<string, JsonValue>>) => string;
|
|
276
293
|
parallel: (...args: readonly unknown[]) => Promise<JsonValue>;
|
|
277
294
|
pipeline: (...args: readonly unknown[]) => Promise<JsonValue>;
|
|
278
|
-
withWorktree:
|
|
295
|
+
withWorktree: {
|
|
296
|
+
(callback: WorkflowWorktreeCallback): Promise<JsonValue>;
|
|
297
|
+
(name: string, callback: WorkflowWorktreeCallback): Promise<JsonValue>;
|
|
298
|
+
};
|
|
279
299
|
checkpoint: (...args: readonly unknown[]) => Promise<boolean>;
|
|
280
300
|
phase: (name: string) => void;
|
|
281
301
|
log: (message: string) => void;
|
|
@@ -290,7 +310,9 @@ export interface WorkflowRunContext {
|
|
|
290
310
|
}
|
|
291
311
|
export interface WorkflowFunctionContext extends WorkflowOrchestrationContext {
|
|
292
312
|
run: Readonly<WorkflowRunContext>;
|
|
313
|
+
invoke: (name: string, input: Readonly<Record<string, JsonValue>>) => Promise<JsonValue>;
|
|
293
314
|
}
|
|
315
|
+
export type WorkflowWorktreeCallback = (reference: Readonly<WorkflowWorktreeReference>) => JsonValue | Promise<JsonValue>;
|
|
294
316
|
export interface WorkflowFunction {
|
|
295
317
|
description: string;
|
|
296
318
|
input: JsonSchema;
|
|
@@ -302,17 +324,12 @@ export interface WorkflowVariable {
|
|
|
302
324
|
schema: JsonSchema;
|
|
303
325
|
resolve: (run: Readonly<WorkflowRunContext>) => Promise<JsonValue> | JsonValue;
|
|
304
326
|
}
|
|
305
|
-
export interface WorkflowScriptDefinition {
|
|
306
|
-
description: string;
|
|
307
|
-
script: string;
|
|
308
|
-
}
|
|
309
327
|
export interface WorkflowExtension {
|
|
310
328
|
version: string;
|
|
311
329
|
headline: string;
|
|
312
330
|
description: string;
|
|
313
331
|
functions?: Readonly<Record<string, WorkflowFunction>>;
|
|
314
332
|
variables?: Readonly<Record<string, WorkflowVariable>>;
|
|
315
|
-
workflows?: Readonly<Record<string, WorkflowScriptDefinition>>;
|
|
316
333
|
agentSetupHooks?: Readonly<Record<string, AgentSetupHook>>;
|
|
317
334
|
}
|
|
318
335
|
export interface WorkflowJournal {
|
|
@@ -323,6 +340,36 @@ export declare class WorkflowError extends Error {
|
|
|
323
340
|
readonly code: WorkflowErrorCode;
|
|
324
341
|
constructor(code: WorkflowErrorCode, message: string);
|
|
325
342
|
}
|
|
343
|
+
export interface WorkflowFailureAgent {
|
|
344
|
+
id: string;
|
|
345
|
+
label?: string;
|
|
346
|
+
role?: string;
|
|
347
|
+
structuralPath: readonly string[];
|
|
348
|
+
attempt: number;
|
|
349
|
+
sessionId?: string;
|
|
350
|
+
sessionFile?: string;
|
|
351
|
+
}
|
|
352
|
+
export interface WorkflowSiblingAgent {
|
|
353
|
+
id: string;
|
|
354
|
+
label?: string;
|
|
355
|
+
role?: string;
|
|
356
|
+
structuralPath: readonly string[];
|
|
357
|
+
}
|
|
358
|
+
export interface WorkflowFailureDiagnostics {
|
|
359
|
+
runId: string;
|
|
360
|
+
workflowName: string;
|
|
361
|
+
state: RunState;
|
|
362
|
+
failedAt: string | null;
|
|
363
|
+
error: WorkflowErrorShape;
|
|
364
|
+
failedAgent?: WorkflowFailureAgent;
|
|
365
|
+
completedSiblingAgents?: readonly WorkflowSiblingAgent[];
|
|
366
|
+
completedSiblingPaths: readonly (readonly string[])[];
|
|
367
|
+
artifacts: {
|
|
368
|
+
runDirectory: string;
|
|
369
|
+
statePath: string;
|
|
370
|
+
journalPath: string;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
326
373
|
export declare function formatWorkflowFailure(error: unknown): string;
|
|
327
374
|
export declare class RunLifecycle {
|
|
328
375
|
#private;
|
|
@@ -339,6 +386,8 @@ export declare class RunLifecycle {
|
|
|
339
386
|
terminal(state: "completed" | "failed" | "stopped" | "interrupted" | "budget_exhausted", reason?: string): Promise<void>;
|
|
340
387
|
}
|
|
341
388
|
export declare const DEFAULT_SETTINGS: Readonly<WorkflowSettings>;
|
|
389
|
+
declare function object(value: unknown): value is Record<string, unknown>;
|
|
390
|
+
export { object as isObject };
|
|
342
391
|
export declare function validateBudget(value: unknown): WorkflowBudget | undefined;
|
|
343
392
|
export declare function validateBudgetPatch(value: unknown): WorkflowBudgetPatch;
|
|
344
393
|
export declare class WorkflowBudgetRuntime {
|
|
@@ -395,7 +444,7 @@ export interface StaticWorkflowScope {
|
|
|
395
444
|
key: string | null;
|
|
396
445
|
}
|
|
397
446
|
export interface StaticWorkflowCall {
|
|
398
|
-
kind:
|
|
447
|
+
kind: WorkflowCallKind;
|
|
399
448
|
start: number;
|
|
400
449
|
end: number;
|
|
401
450
|
name: string | null;
|
|
@@ -428,27 +477,43 @@ export interface WorkflowCatalogVariable {
|
|
|
428
477
|
description: string;
|
|
429
478
|
schema: JsonSchema;
|
|
430
479
|
}
|
|
431
|
-
export interface WorkflowCatalogWorkflow {
|
|
432
|
-
name: string;
|
|
433
|
-
version: string;
|
|
434
|
-
headline: string;
|
|
435
|
-
extensionDescription: string;
|
|
436
|
-
description: string;
|
|
437
|
-
}
|
|
438
480
|
export interface WorkflowCatalog {
|
|
439
481
|
functions: readonly WorkflowCatalogFunction[];
|
|
440
482
|
variables: readonly WorkflowCatalogVariable[];
|
|
441
|
-
workflows: readonly WorkflowCatalogWorkflow[];
|
|
442
483
|
modelAliases?: Readonly<Record<string, string>>;
|
|
443
484
|
}
|
|
485
|
+
export interface WorkflowCatalogIndexFunction {
|
|
486
|
+
name: string;
|
|
487
|
+
description: string;
|
|
488
|
+
input: JsonSchema;
|
|
489
|
+
}
|
|
490
|
+
export interface WorkflowCatalogIndexVariable {
|
|
491
|
+
name: string;
|
|
492
|
+
description: string;
|
|
493
|
+
schema: JsonSchema;
|
|
494
|
+
}
|
|
495
|
+
export interface WorkflowCatalogIndex {
|
|
496
|
+
functions: readonly WorkflowCatalogIndexFunction[];
|
|
497
|
+
variables: readonly WorkflowCatalogIndexVariable[];
|
|
498
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
499
|
+
}
|
|
500
|
+
export interface WorkflowCatalogError {
|
|
501
|
+
error: {
|
|
502
|
+
code: "NOT_FOUND";
|
|
503
|
+
name: string;
|
|
504
|
+
message: string;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
444
507
|
export declare class WorkflowRegistry {
|
|
445
508
|
#private;
|
|
446
509
|
get frozen(): boolean;
|
|
447
510
|
freeze(): void;
|
|
448
511
|
register(extension: WorkflowExtension): void;
|
|
449
|
-
|
|
450
|
-
|
|
512
|
+
function(name: string): WorkflowFunction;
|
|
513
|
+
functions(): Readonly<Record<string, WorkflowFunction>>;
|
|
451
514
|
catalog(): WorkflowCatalog;
|
|
515
|
+
catalogIndex(): WorkflowCatalogIndex;
|
|
516
|
+
catalogDetail(name: string): WorkflowCatalogFunction | WorkflowCatalogVariable | WorkflowCatalogError;
|
|
452
517
|
globals(): Readonly<Record<string, {
|
|
453
518
|
name: string;
|
|
454
519
|
}>>;
|
|
@@ -461,7 +526,9 @@ export declare class WorkflowRegistry {
|
|
|
461
526
|
}
|
|
462
527
|
export declare function registerWorkflowExtension(extension: WorkflowExtension): void;
|
|
463
528
|
export declare function workflowCatalog(): WorkflowCatalog;
|
|
464
|
-
export declare function
|
|
529
|
+
export declare function workflowCatalogIndex(): WorkflowCatalogIndex;
|
|
530
|
+
export declare function workflowCatalogDetail(name: string): WorkflowCatalogFunction | WorkflowCatalogVariable | WorkflowCatalogError;
|
|
531
|
+
export declare function registeredWorkflowFunctions(): Readonly<Record<string, WorkflowFunction>>;
|
|
465
532
|
export declare function formatWorkflowPreview(args: {
|
|
466
533
|
script?: unknown;
|
|
467
534
|
workflow?: unknown;
|
|
@@ -470,7 +537,7 @@ export declare function formatWorkflowPreview(args: {
|
|
|
470
537
|
}): string;
|
|
471
538
|
export declare const WORKFLOW_TOOL_LABEL = "Workflow";
|
|
472
539
|
export declare const WORKFLOW_TOOL_DESCRIPTION = "Run a deterministic JavaScript workflow";
|
|
473
|
-
export declare const WORKFLOW_TOOL_PROMPT_SNIPPET = "Run a deterministic, resumable JavaScript workflow that orchestrates subagents. Inline scripts require a name; registered
|
|
540
|
+
export declare const WORKFLOW_TOOL_PROMPT_SNIPPET = "Run a deterministic, resumable JavaScript workflow that orchestrates subagents. Inline scripts require a name; registered functions use their function name. Runs in the background by default; completion arrives as a follow-up message. Foreground results include the completed run ID, and parentRunId reuses matching named worktrees from a terminal run.";
|
|
474
541
|
export declare const WORKFLOW_TOOL_PARAMETERS: Type.TObject<{
|
|
475
542
|
name: Type.TOptional<Type.TString>;
|
|
476
543
|
description: Type.TOptional<Type.TString>;
|
|
@@ -480,6 +547,7 @@ export declare const WORKFLOW_TOOL_PARAMETERS: Type.TObject<{
|
|
|
480
547
|
foreground: Type.TOptional<Type.TBoolean>;
|
|
481
548
|
concurrency: Type.TOptional<Type.TInteger>;
|
|
482
549
|
budget: Type.TOptional<Type.TUnknown>;
|
|
550
|
+
parentRunId: Type.TOptional<Type.TString>;
|
|
483
551
|
}>;
|
|
484
552
|
export declare function preflight(script: string, capabilities: PreflightCapabilities, schemas?: readonly unknown[], metadata?: WorkflowMetadata): PreflightResult;
|
|
485
553
|
export interface WorkflowValidationParameters {
|
|
@@ -487,6 +555,7 @@ export interface WorkflowValidationParameters {
|
|
|
487
555
|
description?: string;
|
|
488
556
|
script?: string;
|
|
489
557
|
workflow?: string;
|
|
558
|
+
args?: unknown;
|
|
490
559
|
}
|
|
491
560
|
export interface WorkflowValidationContext {
|
|
492
561
|
cwd: string;
|
|
@@ -496,6 +565,7 @@ export interface WorkflowValidationContext {
|
|
|
496
565
|
modelAliases?: Readonly<Record<string, string>>;
|
|
497
566
|
knownModels?: ReadonlySet<string>;
|
|
498
567
|
settingsPath?: string;
|
|
568
|
+
agentDir?: string;
|
|
499
569
|
}
|
|
500
570
|
export interface ValidatedWorkflowLaunch {
|
|
501
571
|
script: string;
|
|
@@ -503,6 +573,7 @@ export interface ValidatedWorkflowLaunch {
|
|
|
503
573
|
agentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
504
574
|
projectAgentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
505
575
|
roleNames: readonly string[];
|
|
576
|
+
functionName?: string;
|
|
506
577
|
}
|
|
507
578
|
export declare function validateWorkflowLaunch(params: WorkflowValidationParameters, context: WorkflowValidationContext): ValidatedWorkflowLaunch;
|
|
508
579
|
type LaunchSnapshotInput = Omit<LaunchSnapshot, "identityVersion"> & {
|
|
@@ -523,10 +594,18 @@ export interface AgentIdentity {
|
|
|
523
594
|
turn: number;
|
|
524
595
|
};
|
|
525
596
|
}
|
|
597
|
+
export interface ShellIdentity {
|
|
598
|
+
structuralPath: readonly string[];
|
|
599
|
+
callSite: string;
|
|
600
|
+
occurrence: number;
|
|
601
|
+
worktreeOwner?: string;
|
|
602
|
+
}
|
|
526
603
|
export interface WorkflowBridge {
|
|
527
604
|
agent?: (prompt: string, options: Readonly<Record<string, JsonValue>>, signal: AbortSignal, identity: AgentIdentity) => Promise<JsonValue>;
|
|
605
|
+
shell?: (command: string, options: ShellOptions, signal: AbortSignal, identity: ShellIdentity) => Promise<ShellResult>;
|
|
528
606
|
checkpoint?: (input: Readonly<Record<string, JsonValue>>, signal: AbortSignal) => boolean | Promise<boolean>;
|
|
529
607
|
function?: (name: string, input: Readonly<Record<string, JsonValue>>, path: string, signal: AbortSignal, worktreeOwner?: string, structuralPath?: readonly string[]) => Promise<JsonValue>;
|
|
608
|
+
worktree?: (owner: string, signal: AbortSignal) => Promise<Readonly<WorkflowWorktreeReference>>;
|
|
530
609
|
functions?: Readonly<Record<string, {
|
|
531
610
|
name: string;
|
|
532
611
|
}>>;
|
|
@@ -548,10 +627,11 @@ export declare function formatNavigatorRun(loaded: {
|
|
|
548
627
|
run: PersistedRun;
|
|
549
628
|
snapshot: Readonly<LaunchSnapshot>;
|
|
550
629
|
}, checkpoints: readonly AwaitingCheckpoint[], _worktrees: readonly WorktreeReference[]): string;
|
|
551
|
-
export
|
|
630
|
+
export declare function formatWorkflowFailureDiagnostics(diagnostic: WorkflowFailureDiagnostics): string;
|
|
631
|
+
export default function workflowExtension(pi: ExtensionAPI, home?: string, clipboard?: typeof copyToClipboard, createSession?: SessionFactory, agentDir?: string): void;
|
|
552
632
|
export { acquireSessionLease, projectStorageKey, RunStore, runsDirectory, SessionLease, structuralPath } from "./persistence.js";
|
|
553
633
|
export type { AwaitingCheckpoint, CompletedOperation, ConversationHead, NativeSessionReference, PendingWorkflowDecision, PersistedConversation, PersistedOwnershipNode, PersistedRun, WorktreeReference } from "./persistence.js";
|
|
554
634
|
export { FairAgentScheduler, WorkflowAgentExecutor } from "./agent-execution.js";
|
|
555
|
-
export type { AgentAccounting, AgentAttempt, AgentBudgetHooks, AgentDefinition, AgentExecutionOptions, AgentExecutionResult, AgentExecutionRoot, AgentProgress, AgentSetup, AgentSetupContext, AgentSetupHook, AgentToolCallProgress, RegisteredAgentSetupHook, SessionInput } from "./agent-execution.js";
|
|
635
|
+
export type { AgentAccounting, AgentAttempt, AgentBudgetHooks, AgentDefinition, AgentExecutionOptions, AgentExecutionResult, AgentExecutionRoot, AgentProgress, AgentProviderFailure, AgentProviderRecovery, AgentSetup, AgentSetupContext, AgentSetupHook, AgentToolCallProgress, RegisteredAgentSetupHook, SessionInput } from "./agent-execution.js";
|
|
556
636
|
export { doctor, doctorExitCode, formatDoctorReport } from "./doctor.js";
|
|
557
|
-
export type { DoctorDiagnostic, DoctorOptions, DoctorPiState, DoctorReport, DoctorRole, DoctorSeverity, DoctorTrust
|
|
637
|
+
export type { DoctorDiagnostic, DoctorFunction, DoctorOptions, DoctorPiState, DoctorReport, DoctorRole, DoctorSeverity, DoctorTrust } from "./doctor.js";
|