@marcoscale98/pi-extensible-workflows 5.14.1-fork.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/CHANGELOG.md +536 -0
- package/README.md +64 -0
- package/dist/src/agent-execution.d.ts +338 -0
- package/dist/src/agent-execution.js +1633 -0
- package/dist/src/background-widget.d.ts +74 -0
- package/dist/src/background-widget.js +1340 -0
- package/dist/src/budget.d.ts +38 -0
- package/dist/src/budget.js +188 -0
- package/dist/src/changelog.d.ts +6 -0
- package/dist/src/changelog.js +112 -0
- package/dist/src/decoders.d.ts +96 -0
- package/dist/src/decoders.js +629 -0
- package/dist/src/execution.d.ts +19 -0
- package/dist/src/execution.js +749 -0
- package/dist/src/herdr.d.ts +53 -0
- package/dist/src/herdr.js +270 -0
- package/dist/src/host-delivery.d.ts +95 -0
- package/dist/src/host-delivery.js +376 -0
- package/dist/src/host-navigator.d.ts +83 -0
- package/dist/src/host-navigator.js +1087 -0
- package/dist/src/host-phases.d.ts +89 -0
- package/dist/src/host-phases.js +320 -0
- package/dist/src/host-recovery.d.ts +141 -0
- package/dist/src/host-recovery.js +356 -0
- package/dist/src/host-runtime.d.ts +78 -0
- package/dist/src/host-runtime.js +378 -0
- package/dist/src/host-view.d.ts +116 -0
- package/dist/src/host-view.js +868 -0
- package/dist/src/host.d.ts +40 -0
- package/dist/src/host.js +1641 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.js +13725 -0
- package/dist/src/index.js.map +6 -0
- package/dist/src/io.d.ts +14 -0
- package/dist/src/io.js +82 -0
- package/dist/src/package-identity.d.ts +4 -0
- package/dist/src/package-identity.js +6 -0
- package/dist/src/paths.d.ts +14 -0
- package/dist/src/paths.js +51 -0
- package/dist/src/persistence.d.ts +5 -0
- package/dist/src/persistence.js +5 -0
- package/dist/src/pi-runtime-adapter.d.ts +27 -0
- package/dist/src/pi-runtime-adapter.js +243 -0
- package/dist/src/pi-runtime-runner.d.ts +42 -0
- package/dist/src/pi-runtime-runner.js +505 -0
- package/dist/src/registry.d.ts +48 -0
- package/dist/src/registry.js +379 -0
- package/dist/src/retention.d.ts +17 -0
- package/dist/src/retention.js +195 -0
- package/dist/src/runtime/agent-runner.d.ts +143 -0
- package/dist/src/runtime/agent-runner.js +12 -0
- package/dist/src/runtime/index.d.ts +2 -0
- package/dist/src/runtime/index.js +2 -0
- package/dist/src/runtime/namespace.d.ts +14 -0
- package/dist/src/runtime/namespace.js +1 -0
- package/dist/src/runtime/workflow-result.d.ts +2 -0
- package/dist/src/runtime/workflow-result.js +6 -0
- package/dist/src/session-handoff.d.ts +2 -0
- package/dist/src/session-handoff.js +82 -0
- package/dist/src/session-lease.d.ts +12 -0
- package/dist/src/session-lease.js +180 -0
- package/dist/src/store.d.ts +95 -0
- package/dist/src/store.js +951 -0
- package/dist/src/subagent-manager-handle.d.ts +4 -0
- package/dist/src/subagent-manager-handle.js +6 -0
- package/dist/src/tool-timing.d.ts +12 -0
- package/dist/src/tool-timing.js +33 -0
- package/dist/src/trajectory-contracts.d.ts +8 -0
- package/dist/src/trajectory-contracts.js +9 -0
- package/dist/src/trajectory-host-handle.d.ts +12 -0
- package/dist/src/trajectory-host-handle.js +6 -0
- package/dist/src/trajectory.d.ts +128 -0
- package/dist/src/trajectory.js +594 -0
- package/dist/src/types.d.ts +960 -0
- package/dist/src/types.js +60 -0
- package/dist/src/utils.d.ts +57 -0
- package/dist/src/utils.js +225 -0
- package/dist/src/validation.d.ts +29 -0
- package/dist/src/validation.js +1100 -0
- package/dist/src/workflow-artifacts.d.ts +14 -0
- package/dist/src/workflow-artifacts.js +40 -0
- package/dist/starter/index.d.ts +1 -0
- package/dist/starter/index.js +103 -0
- package/dist/starter/index.js.map +6 -0
- package/dist/starter/review-loop.d.ts +72 -0
- package/dist/starter/review-loop.js +43 -0
- package/dist/starter/roles/developer.md +6 -0
- package/dist/starter/roles/oracle.md +18 -0
- package/dist/starter/roles/researcher.md +20 -0
- package/dist/starter/roles/reviewer.md +19 -0
- package/dist/starter/roles/scout.md +18 -0
- package/dist/subagents/index.d.ts +8 -0
- package/dist/subagents/index.js +8021 -0
- package/dist/subagents/index.js.map +6 -0
- package/dist/subagents/src/contracts.d.ts +173 -0
- package/dist/subagents/src/contracts.js +68 -0
- package/dist/subagents/src/decode.d.ts +15 -0
- package/dist/subagents/src/decode.js +182 -0
- package/dist/subagents/src/index.d.ts +12 -0
- package/dist/subagents/src/index.js +180 -0
- package/dist/subagents/src/manager.d.ts +3 -0
- package/dist/subagents/src/manager.js +1636 -0
- package/dist/subagents/src/navigator.d.ts +5 -0
- package/dist/subagents/src/navigator.js +627 -0
- package/dist/subagents/src/view.d.ts +70 -0
- package/dist/subagents/src/view.js +387 -0
- package/dist/subagents/src/worktree.d.ts +34 -0
- package/dist/subagents/src/worktree.js +68 -0
- package/dist/trajectory/assets/favicon.png +0 -0
- package/dist/trajectory/assets/index.html +772 -0
- package/dist/trajectory/assets/marked.min.js +6 -0
- package/dist/trajectory/assets/morphdom.min.js +1 -0
- package/dist/trajectory/index.d.ts +5 -0
- package/dist/trajectory/index.js +3459 -0
- package/dist/trajectory/index.js.map +6 -0
- package/dist/trajectory/src/assets/favicon.png +0 -0
- package/dist/trajectory/src/assets/index.html +772 -0
- package/dist/trajectory/src/assets/marked.min.js +6 -0
- package/dist/trajectory/src/assets/morphdom.min.js +1 -0
- package/dist/trajectory/src/export.d.ts +25 -0
- package/dist/trajectory/src/export.js +80 -0
- package/dist/trajectory/src/index.d.ts +26 -0
- package/dist/trajectory/src/index.js +732 -0
- package/dist/trajectory/src/server.d.ts +7 -0
- package/dist/trajectory/src/server.js +2534 -0
- package/dist/trajectory/src/server.js.map +6 -0
- package/examples/advanced-patterns/auto-model-router.mjs +78 -0
- package/examples/workflow-extension-template/README.md +37 -0
- package/examples/workflow-extension-template/extension.test.mjs +59 -0
- package/examples/workflow-extension-template/index.js +51 -0
- package/examples/workflow-extension-template/roles/reviewer.md +4 -0
- package/package.json +105 -0
- package/skills/pi-extensible-workflows/SKILL.md +160 -0
- package/src/agent-execution.ts +1533 -0
- package/src/background-widget.ts +1496 -0
- package/src/budget.ts +109 -0
- package/src/changelog.ts +114 -0
- package/src/decoders.ts +567 -0
- package/src/execution.ts +652 -0
- package/src/herdr.ts +240 -0
- package/src/host-delivery.ts +346 -0
- package/src/host-navigator.ts +871 -0
- package/src/host-phases.ts +264 -0
- package/src/host-recovery.ts +333 -0
- package/src/host-runtime.ts +373 -0
- package/src/host-view.ts +828 -0
- package/src/host.ts +1502 -0
- package/src/index.ts +29 -0
- package/src/io.ts +73 -0
- package/src/package-identity.ts +7 -0
- package/src/paths.ts +49 -0
- package/src/persistence.ts +11 -0
- package/src/pi-runtime-adapter.ts +247 -0
- package/src/pi-runtime-runner.ts +436 -0
- package/src/registry.ts +321 -0
- package/src/retention.ts +178 -0
- package/src/runtime/agent-runner.ts +158 -0
- package/src/runtime/index.ts +2 -0
- package/src/runtime/namespace.ts +16 -0
- package/src/runtime/workflow-result.ts +8 -0
- package/src/session-handoff.ts +78 -0
- package/src/session-lease.ts +125 -0
- package/src/store.ts +832 -0
- package/src/subagent-manager-handle.ts +8 -0
- package/src/tool-timing.ts +47 -0
- package/src/trajectory-contracts.ts +13 -0
- package/src/trajectory-host-handle.ts +16 -0
- package/src/trajectory.ts +543 -0
- package/src/types.ts +374 -0
- package/src/utils.ts +192 -0
- package/src/validation.ts +910 -0
- package/src/workflow-artifacts.ts +35 -0
- package/starter/index.ts +35 -0
- package/starter/prompts/council.md +16 -0
- package/starter/prompts/deep-research.md +16 -0
- package/starter/prompts/oracle.md +14 -0
- package/starter/prompts/parallel-review.md +22 -0
- package/starter/prompts/parallel-scout.md +16 -0
- package/starter/prompts/review-loop.md +14 -0
- package/starter/prompts/review.md +14 -0
- package/starter/prompts/scout.md +14 -0
- package/starter/review-loop.ts +73 -0
- package/starter/roles/developer.md +6 -0
- package/starter/roles/oracle.md +18 -0
- package/starter/roles/researcher.md +20 -0
- package/starter/roles/reviewer.md +19 -0
- package/starter/roles/scout.md +18 -0
- package/subagents/README.md +145 -0
- package/subagents/index.ts +8 -0
- package/subagents/src/contracts.ts +176 -0
- package/subagents/src/decode.ts +158 -0
- package/subagents/src/index.ts +194 -0
- package/subagents/src/manager.ts +1560 -0
- package/subagents/src/navigator.ts +488 -0
- package/subagents/src/view.ts +376 -0
- package/subagents/src/worktree.ts +99 -0
- package/trajectory/index.ts +5 -0
- package/trajectory/src/assets/favicon.png +0 -0
- package/trajectory/src/assets/index.html +772 -0
- package/trajectory/src/assets/marked.min.js +6 -0
- package/trajectory/src/assets/morphdom.min.js +1 -0
- package/trajectory/src/export.ts +85 -0
- package/trajectory/src/index.ts +604 -0
- package/trajectory/src/server.ts +447 -0
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
import type { CreateAgentSessionOptions, InlineExtension, SessionManager, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { Static, TSchema } from "typebox";
|
|
3
|
+
export declare const RUN_STATES: readonly ["queued", "running", "pausing", "paused", "awaiting_input", "completed", "failed", "stopped", "interrupted", "budget_exhausted"];
|
|
4
|
+
export declare const AGENT_STATES: readonly ["queued", "running", "waiting_for_child", "paused", "retrying", "completed", "failed", "cancelled"];
|
|
5
|
+
export type RunState = (typeof RUN_STATES)[number];
|
|
6
|
+
export type AgentState = (typeof AGENT_STATES)[number];
|
|
7
|
+
export type HardTerminalRunState = "completed" | "failed" | "stopped";
|
|
8
|
+
export declare const HARD_TERMINAL_RUN_STATES: ReadonlySet<RunState>;
|
|
9
|
+
export declare function isHardTerminalRunState(state: RunState): state is HardTerminalRunState;
|
|
10
|
+
export type ExternallyEndedRunState = "stopped" | "interrupted" | "budget_exhausted";
|
|
11
|
+
export declare function isExternallyEndedRunState(state: RunState): state is ExternallyEndedRunState;
|
|
12
|
+
export declare const SETTLED_AGENT_STATES: ReadonlySet<AgentState>;
|
|
13
|
+
export declare const WORKFLOW_CALL_KINDS: readonly ["agent", "parallel", "pipeline", "checkpoint", "phase", "withWorktree", "shell"];
|
|
14
|
+
export type WorkflowCallKind = (typeof WORKFLOW_CALL_KINDS)[number];
|
|
15
|
+
export declare const WORKFLOW_RUN_STARTED_EVENT = "workflow:run-started";
|
|
16
|
+
export declare const WORKFLOW_RUN_RESUMED_EVENT = "workflow:run-resumed";
|
|
17
|
+
export declare const WORKFLOW_RUN_STATE_CHANGED_EVENT = "workflow:run-state-changed";
|
|
18
|
+
export declare const WORKFLOW_RUN_COMPLETED_EVENT = "workflow:run-completed";
|
|
19
|
+
export declare const WORKFLOW_RUN_FAILED_EVENT = "workflow:run-failed";
|
|
20
|
+
export declare const WORKFLOW_AGENT_STATE_CHANGED_EVENT = "workflow:agent-state-changed";
|
|
21
|
+
export declare const WORKFLOW_PHASE_CHANGED_EVENT = "workflow:phase-changed";
|
|
22
|
+
export declare const WORKFLOW_CHECKPOINT_STATE_CHANGED_EVENT = "workflow:checkpoint-state-changed";
|
|
23
|
+
export declare const WORKFLOW_BUDGET_EVENT = "workflow:budget-event";
|
|
24
|
+
export declare const WORKFLOW_WORKTREE_CREATED_EVENT = "workflow:worktree-created";
|
|
25
|
+
export declare const WORKFLOW_BLOCKED_EVENT = "workflow:blocked";
|
|
26
|
+
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", "RUN_NOT_FOUND", "REGISTRY_FROZEN", "GLOBAL_COLLISION", "MISSING_WORKFLOW", "RPC_LIMIT_EXCEEDED", "SHELL_FAILED", "AGENT_TIMEOUT", "AGENT_FAILED", "AGENT_RESULT_COLLECTED", "RESULT_INVALID", "CANCELLED", "WORKER_UNRESPONSIVE", "WORKTREE_FAILED", "RESUME_INCOMPATIBLE", "BUDGET_EXHAUSTED", "INTERNAL_ERROR"];
|
|
27
|
+
export declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
28
|
+
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
29
|
+
export type WorkflowErrorCode = (typeof ERROR_CODES)[number];
|
|
30
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
31
|
+
[key: string]: JsonValue;
|
|
32
|
+
};
|
|
33
|
+
export type JsonSchema = {
|
|
34
|
+
[key: string]: JsonValue;
|
|
35
|
+
};
|
|
36
|
+
type WorkflowSchema = JsonSchema | TSchema;
|
|
37
|
+
export declare function roleNameOf(value: unknown): string | undefined;
|
|
38
|
+
export interface AgentOptions<Schema extends TSchema = never> {
|
|
39
|
+
label?: string;
|
|
40
|
+
model?: string;
|
|
41
|
+
tools?: string[];
|
|
42
|
+
skills?: string[];
|
|
43
|
+
extensions?: string[];
|
|
44
|
+
contextFiles?: ContextFileScope[];
|
|
45
|
+
role?: string;
|
|
46
|
+
outputSchema?: JsonSchema | Schema;
|
|
47
|
+
retries?: number;
|
|
48
|
+
timeoutMs?: number | null;
|
|
49
|
+
[key: string]: JsonValue | NoInfer<Schema>;
|
|
50
|
+
}
|
|
51
|
+
export type ParallelTasks = Record<string, () => JsonValue | Promise<JsonValue>>;
|
|
52
|
+
export type ParallelResult<Tasks extends ParallelTasks> = {
|
|
53
|
+
[Key in keyof Tasks]: Awaited<ReturnType<Tasks[Key]>>;
|
|
54
|
+
};
|
|
55
|
+
export type PipelineItems = Record<string, JsonValue>;
|
|
56
|
+
export type PipelineStage<Input extends JsonValue, Output extends JsonValue> = (value: Input) => Output | Promise<Output>;
|
|
57
|
+
export type PipelineStages<Input extends JsonValue, Output extends JsonValue> = Record<string, PipelineStage<Input, Output>>;
|
|
58
|
+
export type PipelineResult<Items extends PipelineItems, Output extends JsonValue> = {
|
|
59
|
+
[Key in keyof Items]: Output;
|
|
60
|
+
};
|
|
61
|
+
export interface ShellOptions {
|
|
62
|
+
timeoutMs?: number;
|
|
63
|
+
env?: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
export interface ShellResult {
|
|
66
|
+
exitCode: number | null;
|
|
67
|
+
stdout: string;
|
|
68
|
+
stderr: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const BUDGET_DIMENSIONS: readonly ["tokens", "costUsd", "durationMs", "agentLaunches"];
|
|
71
|
+
export type BudgetDimension = (typeof BUDGET_DIMENSIONS)[number];
|
|
72
|
+
export interface BudgetLimits {
|
|
73
|
+
soft?: number;
|
|
74
|
+
hard?: number;
|
|
75
|
+
}
|
|
76
|
+
export type WorkflowBudget = Partial<Record<BudgetDimension, BudgetLimits>>;
|
|
77
|
+
export type WorkflowBudgetPatch = Partial<Record<BudgetDimension, BudgetLimits | {
|
|
78
|
+
soft?: number | null;
|
|
79
|
+
hard?: number | null;
|
|
80
|
+
} | null>>;
|
|
81
|
+
export interface WorkflowBudgetUsage {
|
|
82
|
+
tokens: number;
|
|
83
|
+
costUsd: number;
|
|
84
|
+
durationMs: number;
|
|
85
|
+
agentLaunches: number;
|
|
86
|
+
}
|
|
87
|
+
export declare const BUDGET_EVENT_TYPES: readonly ["soft_crossed", "hard_overrun", "hard_exhausted", "adjustment_requested", "adjustment_approved", "adjustment_rejected"];
|
|
88
|
+
export type BudgetEventType = (typeof BUDGET_EVENT_TYPES)[number];
|
|
89
|
+
export interface BudgetEvent {
|
|
90
|
+
type: BudgetEventType;
|
|
91
|
+
budgetVersion: number;
|
|
92
|
+
dimensions: readonly BudgetDimension[];
|
|
93
|
+
usage: WorkflowBudgetUsage;
|
|
94
|
+
limits: WorkflowBudget;
|
|
95
|
+
at: number;
|
|
96
|
+
proposalId?: string;
|
|
97
|
+
previous?: WorkflowBudget;
|
|
98
|
+
proposed?: WorkflowBudget;
|
|
99
|
+
}
|
|
100
|
+
export interface BudgetApprovalRequest {
|
|
101
|
+
kind: "budget";
|
|
102
|
+
proposalId: string;
|
|
103
|
+
runId: string;
|
|
104
|
+
consumed: WorkflowBudgetUsage;
|
|
105
|
+
previous: WorkflowBudget;
|
|
106
|
+
proposed: WorkflowBudget;
|
|
107
|
+
budgetVersion: number;
|
|
108
|
+
foreground?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface WorkflowErrorShape {
|
|
111
|
+
code: WorkflowErrorCode;
|
|
112
|
+
message: string;
|
|
113
|
+
failedAt?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface WorkflowEventBase {
|
|
116
|
+
runId: string;
|
|
117
|
+
sessionId: string;
|
|
118
|
+
workflowName: string;
|
|
119
|
+
cwd: string;
|
|
120
|
+
runDirectory: string;
|
|
121
|
+
timestamp: number;
|
|
122
|
+
}
|
|
123
|
+
export type WorkflowRunStartedEvent = WorkflowEventBase;
|
|
124
|
+
export type WorkflowRunResumedEvent = WorkflowEventBase;
|
|
125
|
+
export interface WorkflowRunStateChangedEvent extends WorkflowEventBase {
|
|
126
|
+
previousState: RunState;
|
|
127
|
+
state: RunState;
|
|
128
|
+
reason?: string;
|
|
129
|
+
errorCode?: WorkflowErrorCode;
|
|
130
|
+
}
|
|
131
|
+
export interface WorkflowRunCompletedEvent extends WorkflowEventBase {
|
|
132
|
+
resultPath: string;
|
|
133
|
+
}
|
|
134
|
+
export interface WorkflowRunFailedEvent extends WorkflowEventBase {
|
|
135
|
+
error: WorkflowErrorShape;
|
|
136
|
+
}
|
|
137
|
+
export interface WorkflowAgentStateChangedEvent extends WorkflowEventBase {
|
|
138
|
+
agentId: string;
|
|
139
|
+
displayLabel: string;
|
|
140
|
+
role?: string;
|
|
141
|
+
structuralPath: readonly string[];
|
|
142
|
+
parentId?: string;
|
|
143
|
+
parentBreadcrumb?: string;
|
|
144
|
+
worktreeOwner?: string;
|
|
145
|
+
previousState?: AgentState;
|
|
146
|
+
state: AgentState;
|
|
147
|
+
attempt: number;
|
|
148
|
+
}
|
|
149
|
+
export interface WorkflowPhaseChangedEvent extends WorkflowEventBase {
|
|
150
|
+
previousPhase?: string;
|
|
151
|
+
phase: string;
|
|
152
|
+
}
|
|
153
|
+
export type WorkflowCheckpointState = "awaiting" | "approved" | "rejected";
|
|
154
|
+
export interface WorkflowCheckpointStateChangedEvent extends WorkflowEventBase {
|
|
155
|
+
name: string;
|
|
156
|
+
state: WorkflowCheckpointState;
|
|
157
|
+
}
|
|
158
|
+
export interface WorkflowBudgetEvent extends WorkflowEventBase {
|
|
159
|
+
type: BudgetEventType;
|
|
160
|
+
budgetVersion: number;
|
|
161
|
+
dimensions: readonly BudgetDimension[];
|
|
162
|
+
usage: WorkflowBudgetUsage;
|
|
163
|
+
limits: WorkflowBudget;
|
|
164
|
+
proposalId?: string;
|
|
165
|
+
previous?: WorkflowBudget;
|
|
166
|
+
proposed?: WorkflowBudget;
|
|
167
|
+
}
|
|
168
|
+
export interface ModelSpec {
|
|
169
|
+
provider: string;
|
|
170
|
+
model: string;
|
|
171
|
+
thinking?: ThinkingLevel;
|
|
172
|
+
}
|
|
173
|
+
export interface WorkflowModelAliasResolverContext {
|
|
174
|
+
cwd: string;
|
|
175
|
+
projectTrusted: boolean;
|
|
176
|
+
rootModel: ModelSpec;
|
|
177
|
+
knownModels: ReadonlySet<string>;
|
|
178
|
+
availableModels: ReadonlySet<string>;
|
|
179
|
+
signal: AbortSignal;
|
|
180
|
+
}
|
|
181
|
+
export interface WorkflowModelAlias {
|
|
182
|
+
resolve: (context: Readonly<WorkflowModelAliasResolverContext>) => string | Promise<string>;
|
|
183
|
+
}
|
|
184
|
+
export interface WorkflowMetadata {
|
|
185
|
+
name: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
}
|
|
188
|
+
export interface HerdrExtensionSettings {
|
|
189
|
+
enableFullyInspectableMode?: boolean;
|
|
190
|
+
}
|
|
191
|
+
export interface TrajectoryExtensionSettings {
|
|
192
|
+
port?: number;
|
|
193
|
+
themes?: boolean;
|
|
194
|
+
}
|
|
195
|
+
export interface WorkflowExtensionSettings {
|
|
196
|
+
readonly [namespace: string]: JsonValue;
|
|
197
|
+
readonly herdr?: Readonly<HerdrExtensionSettings>;
|
|
198
|
+
readonly trajectory?: Readonly<TrajectoryExtensionSettings>;
|
|
199
|
+
}
|
|
200
|
+
export type WorkflowExtensionSettingsSource = "global" | "project" | "role" | "effective";
|
|
201
|
+
export interface WorkflowExtensionSettingsValidatorContext {
|
|
202
|
+
source: WorkflowExtensionSettingsSource;
|
|
203
|
+
cwd: string;
|
|
204
|
+
projectTrusted: boolean;
|
|
205
|
+
settingsPath?: string;
|
|
206
|
+
role?: string;
|
|
207
|
+
}
|
|
208
|
+
export type WorkflowExtensionSettingsValidator = (settings: Readonly<WorkflowExtensionSettings>, context: Readonly<WorkflowExtensionSettingsValidatorContext>) => void;
|
|
209
|
+
export interface WorkflowSessionStartEvent {
|
|
210
|
+
type: "session_start";
|
|
211
|
+
reason: "startup" | "reload" | "new" | "resume" | "fork";
|
|
212
|
+
previousSessionFile?: string;
|
|
213
|
+
settings: Readonly<WorkflowExtensionSettings>;
|
|
214
|
+
}
|
|
215
|
+
export interface WorkflowRetentionSettings {
|
|
216
|
+
olderThanDays?: number;
|
|
217
|
+
maxTerminalRuns?: number;
|
|
218
|
+
}
|
|
219
|
+
export interface WorkflowSettings {
|
|
220
|
+
concurrency: number;
|
|
221
|
+
backgroundWidget?: boolean;
|
|
222
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
223
|
+
skills?: readonly string[];
|
|
224
|
+
extensions?: readonly string[];
|
|
225
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
226
|
+
tools?: readonly string[];
|
|
227
|
+
retention?: Readonly<WorkflowRetentionSettings>;
|
|
228
|
+
worktreePostCreateCommand?: readonly string[];
|
|
229
|
+
}
|
|
230
|
+
export type WorkflowSettingsOverrides = Partial<Omit<WorkflowSettings, "backgroundWidget">>;
|
|
231
|
+
export interface WorkflowSettingsSources {
|
|
232
|
+
concurrency: string;
|
|
233
|
+
modelAliases: string;
|
|
234
|
+
skills?: string;
|
|
235
|
+
extensions?: string;
|
|
236
|
+
tools?: string;
|
|
237
|
+
extensionSettings?: string;
|
|
238
|
+
retention?: string;
|
|
239
|
+
worktreePostCreateCommand?: string;
|
|
240
|
+
}
|
|
241
|
+
export interface WorkflowSettingsResolution {
|
|
242
|
+
globalSettingsPath: string;
|
|
243
|
+
projectSettingsPath: string;
|
|
244
|
+
projectTrusted: boolean;
|
|
245
|
+
global: Readonly<WorkflowSettings>;
|
|
246
|
+
project: Readonly<WorkflowSettingsOverrides>;
|
|
247
|
+
effective: Readonly<WorkflowSettings>;
|
|
248
|
+
sources: Readonly<WorkflowSettingsSources>;
|
|
249
|
+
}
|
|
250
|
+
export interface AgentResourceSelectors {
|
|
251
|
+
skills?: readonly string[];
|
|
252
|
+
extensions?: readonly string[];
|
|
253
|
+
tools?: readonly string[];
|
|
254
|
+
}
|
|
255
|
+
export interface AgentResourceSelectorSet {
|
|
256
|
+
skills: readonly string[];
|
|
257
|
+
extensions: readonly string[];
|
|
258
|
+
tools?: readonly string[];
|
|
259
|
+
}
|
|
260
|
+
export interface AgentResourceSelectorSources {
|
|
261
|
+
global: AgentResourceSelectors;
|
|
262
|
+
project: AgentResourceSelectors;
|
|
263
|
+
role?: AgentResourceSelectors;
|
|
264
|
+
call?: AgentResourceSelectors;
|
|
265
|
+
}
|
|
266
|
+
export declare const CONTEXT_FILE_SCOPES: readonly ["global", "project", "cwd"];
|
|
267
|
+
export type ContextFileScope = (typeof CONTEXT_FILE_SCOPES)[number];
|
|
268
|
+
export declare function isContextFileScope(value: unknown): value is ContextFileScope;
|
|
269
|
+
export interface AgentResourcePolicy {
|
|
270
|
+
globalSettingsPath: string;
|
|
271
|
+
projectSettingsPath: string;
|
|
272
|
+
projectTrusted: boolean;
|
|
273
|
+
global: AgentResourceSelectorSet;
|
|
274
|
+
project: AgentResourceSelectorSet;
|
|
275
|
+
effective: AgentResourceSelectorSet;
|
|
276
|
+
selectedSkills?: readonly string[];
|
|
277
|
+
selectedExtensions?: readonly string[];
|
|
278
|
+
selectedTools?: readonly string[];
|
|
279
|
+
unmatchedSkills: readonly string[];
|
|
280
|
+
unmatchedExtensions: readonly string[];
|
|
281
|
+
unmatchedTools?: readonly string[];
|
|
282
|
+
selectorSources: AgentResourceSelectorSources;
|
|
283
|
+
}
|
|
284
|
+
export interface AgentResourceInspection {
|
|
285
|
+
selectors: AgentResourceSelectorSet;
|
|
286
|
+
skills: readonly string[];
|
|
287
|
+
extensions: readonly string[];
|
|
288
|
+
tools: readonly string[];
|
|
289
|
+
unmatchedSkills: readonly string[];
|
|
290
|
+
unmatchedExtensions: readonly string[];
|
|
291
|
+
unmatchedTools: readonly string[];
|
|
292
|
+
selectorSources?: AgentResourceSelectorSources;
|
|
293
|
+
}
|
|
294
|
+
export interface ContextFile {
|
|
295
|
+
readonly path: string;
|
|
296
|
+
readonly content: string;
|
|
297
|
+
}
|
|
298
|
+
export interface AgentActivity {
|
|
299
|
+
kind: "reasoning" | "tool" | "text";
|
|
300
|
+
text: string;
|
|
301
|
+
}
|
|
302
|
+
export declare const WORKFLOW_AGENT_STALL_THRESHOLD_MS: number;
|
|
303
|
+
export interface AgentAccounting {
|
|
304
|
+
input: number;
|
|
305
|
+
output: number;
|
|
306
|
+
cacheRead: number;
|
|
307
|
+
cacheWrite: number;
|
|
308
|
+
cost: number;
|
|
309
|
+
}
|
|
310
|
+
export declare function zeroAccounting(): AgentAccounting;
|
|
311
|
+
export declare function addAccounting(left: AgentAccounting, right: AgentAccounting): AgentAccounting;
|
|
312
|
+
export declare function sumAccounting(values: Iterable<AgentAccounting>): AgentAccounting;
|
|
313
|
+
export interface AgentSetupSummary {
|
|
314
|
+
hookNames: readonly string[];
|
|
315
|
+
model: ModelSpec;
|
|
316
|
+
tools: readonly string[];
|
|
317
|
+
cwd: string;
|
|
318
|
+
resourceSelectors?: AgentResourceInspection;
|
|
319
|
+
}
|
|
320
|
+
export interface AgentAttemptError {
|
|
321
|
+
code: string;
|
|
322
|
+
message: string;
|
|
323
|
+
}
|
|
324
|
+
export interface AgentAttemptSummary {
|
|
325
|
+
attempt: number;
|
|
326
|
+
transport: string;
|
|
327
|
+
session?: WorkflowAgentSessionReference;
|
|
328
|
+
setup: AgentSetupSummary;
|
|
329
|
+
error?: AgentAttemptError;
|
|
330
|
+
accounting: AgentAccounting;
|
|
331
|
+
}
|
|
332
|
+
export interface WorkflowWorktreeCreatedEvent extends WorkflowEventBase {
|
|
333
|
+
owner: string;
|
|
334
|
+
branch: string;
|
|
335
|
+
path: string;
|
|
336
|
+
base: string;
|
|
337
|
+
}
|
|
338
|
+
export interface WorkflowWorktreeReference {
|
|
339
|
+
readonly path: string;
|
|
340
|
+
readonly branch: string;
|
|
341
|
+
}
|
|
342
|
+
export interface AgentRecord {
|
|
343
|
+
systemPrompt?: string;
|
|
344
|
+
prompt?: string;
|
|
345
|
+
id: string;
|
|
346
|
+
name: string;
|
|
347
|
+
label?: string;
|
|
348
|
+
path: string;
|
|
349
|
+
state: AgentState;
|
|
350
|
+
parentId?: string;
|
|
351
|
+
structuralPath?: readonly string[];
|
|
352
|
+
resultPath?: string;
|
|
353
|
+
parentBreadcrumb?: string;
|
|
354
|
+
worktreeOwner?: string;
|
|
355
|
+
handle?: string;
|
|
356
|
+
turn?: number;
|
|
357
|
+
continuity?: AgentContinuity;
|
|
358
|
+
role?: string;
|
|
359
|
+
requestedModel?: string;
|
|
360
|
+
model: ModelSpec;
|
|
361
|
+
tools: readonly string[];
|
|
362
|
+
toolDefinitions?: readonly {
|
|
363
|
+
readonly name: string;
|
|
364
|
+
readonly description: string;
|
|
365
|
+
}[];
|
|
366
|
+
attempts: number;
|
|
367
|
+
startedAt?: number;
|
|
368
|
+
durationMs?: number;
|
|
369
|
+
attemptDetails?: readonly AgentAttemptSummary[];
|
|
370
|
+
accounting?: AgentAccounting;
|
|
371
|
+
toolCalls?: readonly {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
state: "running" | "completed" | "failed";
|
|
375
|
+
}[];
|
|
376
|
+
activity?: AgentActivity | undefined;
|
|
377
|
+
lastEventAt?: number;
|
|
378
|
+
}
|
|
379
|
+
export type WorkflowDeliveryMode = "foreground" | "background";
|
|
380
|
+
export type WorkflowDeliveryStatus = "attached" | "pending" | "delivered";
|
|
381
|
+
export interface WorkflowRunDelivery {
|
|
382
|
+
mode: WorkflowDeliveryMode;
|
|
383
|
+
state: WorkflowDeliveryStatus;
|
|
384
|
+
toolCallId?: string;
|
|
385
|
+
}
|
|
386
|
+
export interface WorkflowRunEvent {
|
|
387
|
+
type: string;
|
|
388
|
+
message: string;
|
|
389
|
+
timestamp?: number;
|
|
390
|
+
}
|
|
391
|
+
export interface WorkflowRetryProvenance {
|
|
392
|
+
sourceRunId: string;
|
|
393
|
+
lineageRootRunId: string;
|
|
394
|
+
completedPaths: readonly string[];
|
|
395
|
+
incompletePaths: readonly string[];
|
|
396
|
+
namedWorktrees: readonly string[];
|
|
397
|
+
}
|
|
398
|
+
export interface WorkflowPhaseRecord {
|
|
399
|
+
phase: string;
|
|
400
|
+
afterAgent: number;
|
|
401
|
+
}
|
|
402
|
+
export interface WorkflowPhaseShellActivity {
|
|
403
|
+
phaseIndex: number;
|
|
404
|
+
active: number;
|
|
405
|
+
startedAt: number;
|
|
406
|
+
}
|
|
407
|
+
export interface RunRecord {
|
|
408
|
+
id: string;
|
|
409
|
+
workflowName: string;
|
|
410
|
+
cwd: string;
|
|
411
|
+
sessionId: string;
|
|
412
|
+
state: RunState;
|
|
413
|
+
agentSessions: readonly WorkflowAgentSessionReference[];
|
|
414
|
+
parentRunId?: string;
|
|
415
|
+
retry?: WorkflowRetryProvenance;
|
|
416
|
+
phase?: string;
|
|
417
|
+
phaseHistory?: readonly WorkflowPhaseRecord[];
|
|
418
|
+
phaseHistoryIndex?: number;
|
|
419
|
+
agents: readonly AgentRecord[];
|
|
420
|
+
activeShells?: number;
|
|
421
|
+
activeShellStartedAt?: number;
|
|
422
|
+
activeShellsByPhase?: readonly WorkflowPhaseShellActivity[];
|
|
423
|
+
error?: WorkflowErrorShape;
|
|
424
|
+
failedAt?: string;
|
|
425
|
+
budget?: WorkflowBudget;
|
|
426
|
+
budgetVersion?: number;
|
|
427
|
+
usage?: WorkflowBudgetUsage;
|
|
428
|
+
budgetEvents?: readonly BudgetEvent[];
|
|
429
|
+
events?: readonly WorkflowRunEvent[];
|
|
430
|
+
delivery?: WorkflowRunDelivery;
|
|
431
|
+
}
|
|
432
|
+
export declare const LAUNCH_SNAPSHOT_IDENTITY_VERSION = 5;
|
|
433
|
+
export type WorkflowLaunchMode = "foreground" | "background";
|
|
434
|
+
export interface AgentDefinition {
|
|
435
|
+
prompt?: string;
|
|
436
|
+
description?: string;
|
|
437
|
+
model?: string;
|
|
438
|
+
thinking?: NonNullable<ModelSpec["thinking"]>;
|
|
439
|
+
tools?: readonly string[];
|
|
440
|
+
skills?: readonly string[];
|
|
441
|
+
extensions?: readonly string[];
|
|
442
|
+
overrideSystemPrompt?: boolean;
|
|
443
|
+
contextFiles?: readonly ContextFileScope[];
|
|
444
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
445
|
+
}
|
|
446
|
+
export interface LaunchSnapshot {
|
|
447
|
+
identityVersion?: number;
|
|
448
|
+
launchMode?: WorkflowLaunchMode;
|
|
449
|
+
script: string;
|
|
450
|
+
args: JsonValue;
|
|
451
|
+
metadata: WorkflowMetadata;
|
|
452
|
+
settings: WorkflowSettings;
|
|
453
|
+
settingsSources?: WorkflowSettingsSources;
|
|
454
|
+
budget?: WorkflowBudget;
|
|
455
|
+
settingsPath?: string;
|
|
456
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
457
|
+
phases?: readonly string[];
|
|
458
|
+
models: readonly string[];
|
|
459
|
+
tools: readonly string[];
|
|
460
|
+
agentTypes: readonly string[];
|
|
461
|
+
roles?: Readonly<Record<string, AgentDefinition>>;
|
|
462
|
+
projectRoles?: readonly string[];
|
|
463
|
+
schemas: readonly JsonSchema[];
|
|
464
|
+
}
|
|
465
|
+
export interface PreflightCapabilities {
|
|
466
|
+
models: ReadonlySet<string>;
|
|
467
|
+
tools: ReadonlySet<string>;
|
|
468
|
+
agentTypes: ReadonlySet<string>;
|
|
469
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
470
|
+
knownModels?: ReadonlySet<string>;
|
|
471
|
+
settingsPath?: string;
|
|
472
|
+
skipModelAvailability?: boolean;
|
|
473
|
+
}
|
|
474
|
+
export interface PreflightResult {
|
|
475
|
+
metadata: WorkflowMetadata;
|
|
476
|
+
referenced: {
|
|
477
|
+
phases: readonly string[];
|
|
478
|
+
models: readonly string[];
|
|
479
|
+
tools: readonly string[];
|
|
480
|
+
agentTypes: readonly string[];
|
|
481
|
+
};
|
|
482
|
+
schemas: readonly JsonSchema[];
|
|
483
|
+
dynamicAgentRoles: boolean;
|
|
484
|
+
}
|
|
485
|
+
export interface WorkflowOrchestrationContext {
|
|
486
|
+
agent: {
|
|
487
|
+
<Schema extends TSchema>(prompt: string, options: Readonly<AgentOptions<Schema> & {
|
|
488
|
+
outputSchema: Schema;
|
|
489
|
+
}>): Promise<Static<Schema>>;
|
|
490
|
+
(prompt: string, options?: Readonly<AgentOptions>): Promise<JsonValue>;
|
|
491
|
+
};
|
|
492
|
+
shell: (command: string, options?: ShellOptions) => Promise<ShellResult>;
|
|
493
|
+
prompt: (template: string, values: Readonly<Record<string, JsonValue>>) => string;
|
|
494
|
+
parallel: <Tasks extends ParallelTasks>(operationName: string, tasks: Tasks) => Promise<ParallelResult<Tasks>>;
|
|
495
|
+
pipeline: <Items extends PipelineItems, Output extends JsonValue>(operationName: string, items: Items, stages: PipelineStages<Items[keyof Items], Output>) => Promise<PipelineResult<Items, Output>>;
|
|
496
|
+
withWorktree: <Result extends JsonValue>(name: string, callback: WorkflowWorktreeCallback<Result>) => Promise<Result>;
|
|
497
|
+
checkpoint: (input: CheckpointInput) => Promise<boolean>;
|
|
498
|
+
phase: (name: string) => void;
|
|
499
|
+
log: (message: string) => void;
|
|
500
|
+
}
|
|
501
|
+
export interface WorkflowRunContext {
|
|
502
|
+
cwd: string;
|
|
503
|
+
sessionId: string;
|
|
504
|
+
runId: string;
|
|
505
|
+
workflow: Readonly<WorkflowMetadata>;
|
|
506
|
+
args: JsonValue;
|
|
507
|
+
signal: AbortSignal;
|
|
508
|
+
}
|
|
509
|
+
export interface WorkflowFunctionContext extends WorkflowOrchestrationContext {
|
|
510
|
+
run: Readonly<WorkflowRunContext>;
|
|
511
|
+
settings: Readonly<WorkflowExtensionSettings>;
|
|
512
|
+
invoke: (name: string, input: Readonly<Record<string, JsonValue>>, label?: string) => Promise<JsonValue>;
|
|
513
|
+
}
|
|
514
|
+
export type WorkflowWorktreeCallback<Result extends JsonValue = JsonValue> = (reference: Readonly<WorkflowWorktreeReference>) => Result | Promise<Result>;
|
|
515
|
+
export interface WorkflowFunction {
|
|
516
|
+
description: string;
|
|
517
|
+
input: WorkflowSchema;
|
|
518
|
+
output: WorkflowSchema;
|
|
519
|
+
run(input: Readonly<Record<string, JsonValue>>, context: Readonly<WorkflowFunctionContext>): unknown;
|
|
520
|
+
}
|
|
521
|
+
type TypedWorkflowFunction<InputSchema extends TSchema, OutputSchema extends TSchema> = {
|
|
522
|
+
description: string;
|
|
523
|
+
input: InputSchema;
|
|
524
|
+
output: OutputSchema;
|
|
525
|
+
run: (input: Readonly<Static<NoInfer<InputSchema>>>, context: Readonly<WorkflowFunctionContext>) => Promise<Static<NoInfer<OutputSchema>>> | Static<NoInfer<OutputSchema>>;
|
|
526
|
+
};
|
|
527
|
+
type DefinedWorkflowFunction<InputSchema extends TSchema, OutputSchema extends TSchema, Run extends TypedWorkflowFunction<InputSchema, OutputSchema>["run"]> = Omit<TypedWorkflowFunction<InputSchema, OutputSchema>, "run"> & {
|
|
528
|
+
run: Run;
|
|
529
|
+
};
|
|
530
|
+
export declare function defineWorkflowFunction<InputSchema extends TSchema, OutputSchema extends TSchema, Run extends TypedWorkflowFunction<InputSchema, OutputSchema>["run"]>(workflowFunction: DefinedWorkflowFunction<InputSchema, OutputSchema, Run>): DefinedWorkflowFunction<InputSchema, OutputSchema, Run>;
|
|
531
|
+
export interface WorkflowAgentSessionReference {
|
|
532
|
+
readonly transport: string;
|
|
533
|
+
readonly sessionId: string;
|
|
534
|
+
readonly locator?: JsonValue;
|
|
535
|
+
}
|
|
536
|
+
export interface WorkflowAgentSessionStats {
|
|
537
|
+
readonly tokens: {
|
|
538
|
+
readonly input: number;
|
|
539
|
+
readonly output: number;
|
|
540
|
+
readonly cacheRead: number;
|
|
541
|
+
readonly cacheWrite: number;
|
|
542
|
+
readonly total: number;
|
|
543
|
+
};
|
|
544
|
+
readonly cost: number;
|
|
545
|
+
}
|
|
546
|
+
export interface WorkflowAgentMessage {
|
|
547
|
+
readonly role: string;
|
|
548
|
+
readonly content?: unknown;
|
|
549
|
+
readonly stopReason?: string;
|
|
550
|
+
readonly errorMessage?: string;
|
|
551
|
+
readonly usage?: {
|
|
552
|
+
readonly input: number;
|
|
553
|
+
readonly output: number;
|
|
554
|
+
readonly cacheRead: number;
|
|
555
|
+
readonly cacheWrite: number;
|
|
556
|
+
readonly cost: {
|
|
557
|
+
readonly total: number;
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
export interface WorkflowAgentSessionState {
|
|
562
|
+
readonly model: ModelSpec;
|
|
563
|
+
readonly thinking?: ModelSpec["thinking"];
|
|
564
|
+
readonly tools: readonly string[];
|
|
565
|
+
readonly systemPrompt?: string;
|
|
566
|
+
}
|
|
567
|
+
export interface WorkflowAgentSessionEvent {
|
|
568
|
+
readonly type: string;
|
|
569
|
+
readonly state?: Readonly<WorkflowAgentSessionState>;
|
|
570
|
+
readonly message?: WorkflowAgentMessage;
|
|
571
|
+
readonly assistantMessageEvent?: {
|
|
572
|
+
readonly type: string;
|
|
573
|
+
readonly delta?: string;
|
|
574
|
+
};
|
|
575
|
+
readonly toolCallId?: string;
|
|
576
|
+
readonly toolName?: string;
|
|
577
|
+
readonly isError?: boolean;
|
|
578
|
+
}
|
|
579
|
+
export type LiveSessionHandoffState = "local-running" | "handoff-pending" | "herdr-running" | "returning-local" | "completed";
|
|
580
|
+
export interface LiveSessionHandoff {
|
|
581
|
+
readonly state: LiveSessionHandoffState;
|
|
582
|
+
readonly transferred: boolean;
|
|
583
|
+
observe(event: WorkflowAgentSessionEvent): void;
|
|
584
|
+
request(launch: () => Promise<void>): Promise<void>;
|
|
585
|
+
waitForTakeover(): Promise<void>;
|
|
586
|
+
takeover(): void;
|
|
587
|
+
waitForResume(): Promise<void>;
|
|
588
|
+
release(reason?: string): void;
|
|
589
|
+
}
|
|
590
|
+
export interface WorkflowAgentTurnResult {
|
|
591
|
+
readonly assistant?: WorkflowAgentMessage;
|
|
592
|
+
}
|
|
593
|
+
export interface WorkflowAgentSession {
|
|
594
|
+
readonly reference: WorkflowAgentSessionReference;
|
|
595
|
+
getState(): Readonly<WorkflowAgentSessionState>;
|
|
596
|
+
getSessionStats(): WorkflowAgentSessionStats;
|
|
597
|
+
getLastAssistant(): WorkflowAgentMessage | undefined;
|
|
598
|
+
subscribe(listener: (event: WorkflowAgentSessionEvent) => void): () => void;
|
|
599
|
+
subscribeAsync?(listener: (event: WorkflowAgentSessionEvent) => void | Promise<void>): () => void;
|
|
600
|
+
prompt(text: string): Promise<WorkflowAgentTurnResult>;
|
|
601
|
+
steer(text: string): Promise<void>;
|
|
602
|
+
abort(): Promise<void>;
|
|
603
|
+
suspendForHandoff?(): Promise<void>;
|
|
604
|
+
resumeFromHandoff?(): Promise<void>;
|
|
605
|
+
dispose(): Promise<void>;
|
|
606
|
+
getResourceInspection?(): {
|
|
607
|
+
readonly skills: readonly string[];
|
|
608
|
+
readonly extensions: readonly string[];
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
type SessionTools = NonNullable<CreateAgentSessionOptions["tools"]>;
|
|
612
|
+
type SessionCustomTools = NonNullable<CreateAgentSessionOptions["customTools"]>;
|
|
613
|
+
export interface SessionInput {
|
|
614
|
+
cwd: string;
|
|
615
|
+
model: ModelSpec;
|
|
616
|
+
tools: SessionTools;
|
|
617
|
+
sessionLabel: string;
|
|
618
|
+
sessionPath?: string;
|
|
619
|
+
sessionManager?: SessionManager;
|
|
620
|
+
agentDir?: string;
|
|
621
|
+
customTools?: SessionCustomTools;
|
|
622
|
+
resultTool?: ToolDefinition;
|
|
623
|
+
systemPrompt?: string;
|
|
624
|
+
systemPromptAppend?: string;
|
|
625
|
+
extensionFactories?: InlineExtension[];
|
|
626
|
+
additionalSkillPaths?: readonly string[];
|
|
627
|
+
contextFiles?: readonly ContextFileScope[];
|
|
628
|
+
resourcePolicy?: AgentResourcePolicy;
|
|
629
|
+
readonly settings?: Readonly<WorkflowExtensionSettings>;
|
|
630
|
+
options?: AgentOptions;
|
|
631
|
+
}
|
|
632
|
+
export interface PiRuntimeLaunchInfo {
|
|
633
|
+
readonly executable: string;
|
|
634
|
+
readonly entrypoint?: string;
|
|
635
|
+
}
|
|
636
|
+
export interface PreparedAgentSession {
|
|
637
|
+
readonly cwd: string;
|
|
638
|
+
readonly model: ModelSpec;
|
|
639
|
+
readonly tools: readonly string[];
|
|
640
|
+
readonly sessionLabel: string;
|
|
641
|
+
readonly sessionPath?: string;
|
|
642
|
+
readonly initialPrompt?: string;
|
|
643
|
+
readonly agentDir?: string;
|
|
644
|
+
readonly customTools?: readonly ToolDefinition[];
|
|
645
|
+
readonly resultTool?: ToolDefinition;
|
|
646
|
+
readonly options?: Readonly<Record<string, JsonValue>>;
|
|
647
|
+
readonly piRuntime?: Readonly<PiRuntimeLaunchInfo>;
|
|
648
|
+
readonly piRuntimeError?: string;
|
|
649
|
+
readonly systemPrompt?: string;
|
|
650
|
+
readonly systemPromptPath?: string;
|
|
651
|
+
readonly systemPromptAppend?: string;
|
|
652
|
+
readonly extensionFactories?: readonly InlineExtension[];
|
|
653
|
+
readonly additionalSkillPaths?: readonly string[];
|
|
654
|
+
readonly contextFiles?: readonly ContextFileScope[];
|
|
655
|
+
readonly resourcePolicy?: Readonly<AgentResourcePolicy>;
|
|
656
|
+
readonly settings?: Readonly<WorkflowExtensionSettings>;
|
|
657
|
+
}
|
|
658
|
+
export type AgentInspectionMode = "execution" | "inspection";
|
|
659
|
+
export interface AgentTransportContext {
|
|
660
|
+
readonly run: Readonly<WorkflowRunContext>;
|
|
661
|
+
readonly identity: Readonly<AgentIdentity>;
|
|
662
|
+
readonly attempt: number;
|
|
663
|
+
readonly signal: AbortSignal;
|
|
664
|
+
readonly tuiIndex?: number;
|
|
665
|
+
readonly tuiLabel?: string;
|
|
666
|
+
readonly settings: Readonly<WorkflowExtensionSettings>;
|
|
667
|
+
}
|
|
668
|
+
export interface AgentTransport {
|
|
669
|
+
readonly id: string;
|
|
670
|
+
createSession(prepared: Readonly<PreparedAgentSession>, context: Readonly<AgentTransportContext>): Promise<WorkflowAgentSession>;
|
|
671
|
+
}
|
|
672
|
+
export interface AgentSetup {
|
|
673
|
+
prompt: string;
|
|
674
|
+
options: AgentOptions;
|
|
675
|
+
sessionInput: SessionInput;
|
|
676
|
+
prepared: Readonly<PreparedAgentSession>;
|
|
677
|
+
transport: AgentTransport;
|
|
678
|
+
}
|
|
679
|
+
export interface AgentSetupContext {
|
|
680
|
+
readonly run: Readonly<WorkflowRunContext>;
|
|
681
|
+
readonly identity: Readonly<AgentIdentity>;
|
|
682
|
+
readonly attempt: number;
|
|
683
|
+
readonly signal: AbortSignal;
|
|
684
|
+
readonly tuiIndex?: number;
|
|
685
|
+
readonly tuiLabel?: string;
|
|
686
|
+
readonly mode?: AgentInspectionMode;
|
|
687
|
+
readonly settings: Readonly<WorkflowExtensionSettings>;
|
|
688
|
+
}
|
|
689
|
+
export interface AgentSetupHook {
|
|
690
|
+
priority?: number;
|
|
691
|
+
setup: (agent: AgentSetup, context: Readonly<AgentSetupContext>) => void | Promise<void>;
|
|
692
|
+
}
|
|
693
|
+
export interface RegisteredAgentSetupHook {
|
|
694
|
+
name: string;
|
|
695
|
+
priority: number;
|
|
696
|
+
setup: AgentSetupHook["setup"];
|
|
697
|
+
}
|
|
698
|
+
export interface WorkflowExtensionMetadata {
|
|
699
|
+
version: string;
|
|
700
|
+
headline: string;
|
|
701
|
+
}
|
|
702
|
+
export interface WorkflowFunctionSource {
|
|
703
|
+
readonly module: string;
|
|
704
|
+
readonly export: string;
|
|
705
|
+
readonly dependencies: readonly string[];
|
|
706
|
+
}
|
|
707
|
+
export interface WorkflowRoleDirectoryRegistration {
|
|
708
|
+
path: string;
|
|
709
|
+
extension: WorkflowExtensionMetadata;
|
|
710
|
+
readonly builtin?: true;
|
|
711
|
+
}
|
|
712
|
+
export interface AgentAttemptActionUi {
|
|
713
|
+
notify(message: string, level?: "info" | "warning" | "error"): void;
|
|
714
|
+
confirm(title: string, message: string): Promise<boolean>;
|
|
715
|
+
select(title: string, options: readonly string[]): Promise<string | undefined>;
|
|
716
|
+
input(title: string, placeholder?: string): Promise<string | undefined>;
|
|
717
|
+
setWorkingMessage?(message?: string): void;
|
|
718
|
+
}
|
|
719
|
+
export interface StandaloneAgentRecord {
|
|
720
|
+
readonly id: string;
|
|
721
|
+
readonly name: string;
|
|
722
|
+
readonly label?: string;
|
|
723
|
+
readonly state: "running" | "completed" | "failed" | "stopped";
|
|
724
|
+
readonly structuralPath?: readonly string[];
|
|
725
|
+
}
|
|
726
|
+
export interface StandaloneAgentAttemptActionContext {
|
|
727
|
+
readonly agent: Readonly<StandaloneAgentRecord>;
|
|
728
|
+
readonly attempt: Readonly<AgentAttemptSummary>;
|
|
729
|
+
readonly session?: WorkflowAgentSessionReference;
|
|
730
|
+
readonly liveSession?: WorkflowAgentSession;
|
|
731
|
+
readonly prepared?: Readonly<PreparedAgentSession>;
|
|
732
|
+
readonly handoff?: LiveSessionHandoff;
|
|
733
|
+
readonly signal: AbortSignal;
|
|
734
|
+
readonly ui: Readonly<AgentAttemptActionUi>;
|
|
735
|
+
}
|
|
736
|
+
export interface AgentAttemptActionContext {
|
|
737
|
+
readonly run: Readonly<RunRecord>;
|
|
738
|
+
readonly agent: Readonly<AgentRecord>;
|
|
739
|
+
readonly attempt: Readonly<AgentAttemptSummary>;
|
|
740
|
+
readonly session?: WorkflowAgentSessionReference;
|
|
741
|
+
readonly liveSession?: WorkflowAgentSession;
|
|
742
|
+
readonly prepared?: Readonly<PreparedAgentSession>;
|
|
743
|
+
readonly handoff?: LiveSessionHandoff;
|
|
744
|
+
readonly signal: AbortSignal;
|
|
745
|
+
readonly ui: Readonly<AgentAttemptActionUi>;
|
|
746
|
+
}
|
|
747
|
+
export interface AgentAttemptAction {
|
|
748
|
+
readonly label: string;
|
|
749
|
+
visible(context: Readonly<AgentAttemptActionContext>): boolean;
|
|
750
|
+
run(context: Readonly<AgentAttemptActionContext>): void | Promise<void>;
|
|
751
|
+
visibleStandalone?(context: Readonly<StandaloneAgentAttemptActionContext>): boolean;
|
|
752
|
+
runStandalone?(context: Readonly<StandaloneAgentAttemptActionContext>): void | Promise<void>;
|
|
753
|
+
}
|
|
754
|
+
export interface WorkflowExtension extends WorkflowExtensionMetadata {
|
|
755
|
+
description?: string;
|
|
756
|
+
source?: string;
|
|
757
|
+
dependencies?: readonly string[];
|
|
758
|
+
validateSettings?: WorkflowExtensionSettingsValidator;
|
|
759
|
+
functions?: Readonly<Record<string, WorkflowFunction>>;
|
|
760
|
+
modelAliases?: Readonly<Record<string, WorkflowModelAlias>>;
|
|
761
|
+
agentSetupHooks?: Readonly<Record<string, AgentSetupHook>>;
|
|
762
|
+
agentAttemptActions?: Readonly<Record<string, AgentAttemptAction>>;
|
|
763
|
+
roleDirectories?: readonly (string | URL)[];
|
|
764
|
+
}
|
|
765
|
+
export interface WorkflowJournal {
|
|
766
|
+
get(path: string): JsonValue | undefined;
|
|
767
|
+
put(path: string, value: JsonValue): void;
|
|
768
|
+
}
|
|
769
|
+
export declare class WorkflowError extends Error {
|
|
770
|
+
readonly code: WorkflowErrorCode;
|
|
771
|
+
constructor(code: WorkflowErrorCode, message: string);
|
|
772
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
773
|
+
}
|
|
774
|
+
export interface WorkflowFailureAgent {
|
|
775
|
+
id: string;
|
|
776
|
+
label?: string;
|
|
777
|
+
role?: string;
|
|
778
|
+
structuralPath: readonly string[];
|
|
779
|
+
attempt: number;
|
|
780
|
+
transport?: string;
|
|
781
|
+
session?: WorkflowAgentSessionReference;
|
|
782
|
+
}
|
|
783
|
+
export interface WorkflowSiblingAgent {
|
|
784
|
+
id: string;
|
|
785
|
+
label?: string;
|
|
786
|
+
role?: string;
|
|
787
|
+
structuralPath: readonly string[];
|
|
788
|
+
}
|
|
789
|
+
export interface WorkflowFailureDiagnostics {
|
|
790
|
+
runId: string;
|
|
791
|
+
workflowName: string;
|
|
792
|
+
state: RunState;
|
|
793
|
+
failedAt: string | null;
|
|
794
|
+
error: WorkflowErrorShape;
|
|
795
|
+
failedAgent?: WorkflowFailureAgent;
|
|
796
|
+
completedSiblingAgents?: readonly WorkflowSiblingAgent[];
|
|
797
|
+
completedSiblingPaths: readonly (readonly string[])[];
|
|
798
|
+
retry?: {
|
|
799
|
+
sourceRunId: string;
|
|
800
|
+
action: string;
|
|
801
|
+
completedPaths: readonly string[];
|
|
802
|
+
incompletePaths: readonly string[];
|
|
803
|
+
namedWorktrees: readonly string[];
|
|
804
|
+
warning: string;
|
|
805
|
+
};
|
|
806
|
+
artifacts: {
|
|
807
|
+
runDirectory: string;
|
|
808
|
+
statePath: string;
|
|
809
|
+
journalPath: string;
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
export interface CheckpointInput {
|
|
813
|
+
name: string;
|
|
814
|
+
prompt: string;
|
|
815
|
+
context: JsonValue;
|
|
816
|
+
}
|
|
817
|
+
export interface FunctionIdentity {
|
|
818
|
+
path: string;
|
|
819
|
+
structuralPath: readonly string[];
|
|
820
|
+
occurrence: number;
|
|
821
|
+
worktreeOwner?: string;
|
|
822
|
+
}
|
|
823
|
+
export type AgentContinuity = "fresh" | "continued";
|
|
824
|
+
export interface AgentIdentity {
|
|
825
|
+
structuralPath: readonly string[];
|
|
826
|
+
callSite: string;
|
|
827
|
+
occurrence: number;
|
|
828
|
+
parentBreadcrumb?: string;
|
|
829
|
+
worktreeOwner?: string;
|
|
830
|
+
handle?: string;
|
|
831
|
+
turn?: number;
|
|
832
|
+
}
|
|
833
|
+
export interface ShellIdentity {
|
|
834
|
+
structuralPath: readonly string[];
|
|
835
|
+
callSite: string;
|
|
836
|
+
occurrence: number;
|
|
837
|
+
worktreeOwner?: string;
|
|
838
|
+
}
|
|
839
|
+
export interface WorkflowBridge {
|
|
840
|
+
agent?: (prompt: string, options: Readonly<Record<string, JsonValue>>, signal: AbortSignal, identity: AgentIdentity) => Promise<JsonValue>;
|
|
841
|
+
shell?: (command: string, options: ShellOptions, signal: AbortSignal, identity: ShellIdentity) => Promise<ShellResult>;
|
|
842
|
+
checkpoint?: (input: Readonly<Record<string, JsonValue>>, signal: AbortSignal) => boolean | Promise<boolean>;
|
|
843
|
+
function?: (name: string, input: Readonly<Record<string, JsonValue>>, signal: AbortSignal, identity: FunctionIdentity) => Promise<JsonValue>;
|
|
844
|
+
worktree?: (owner: string, signal: AbortSignal) => Promise<Readonly<WorkflowWorktreeReference>>;
|
|
845
|
+
functions?: Readonly<Record<string, {
|
|
846
|
+
name: string;
|
|
847
|
+
}>>;
|
|
848
|
+
phase?: (name: string) => void | Promise<void>;
|
|
849
|
+
log?: (message: string) => void | Promise<void>;
|
|
850
|
+
}
|
|
851
|
+
export interface WorkflowExecution {
|
|
852
|
+
result: Promise<JsonValue>;
|
|
853
|
+
cancel: () => void;
|
|
854
|
+
}
|
|
855
|
+
export interface StaticWorkflowScope {
|
|
856
|
+
kind: "parallel" | "pipeline";
|
|
857
|
+
name: string | null;
|
|
858
|
+
key: string | null;
|
|
859
|
+
}
|
|
860
|
+
export type StaticWorkflowExecution = "parallel" | "sequential";
|
|
861
|
+
export interface StaticWorkflowCall {
|
|
862
|
+
kind: WorkflowCallKind;
|
|
863
|
+
start: number;
|
|
864
|
+
end: number;
|
|
865
|
+
name: string | null;
|
|
866
|
+
prompt: string | null;
|
|
867
|
+
model: string | null;
|
|
868
|
+
label?: string | null;
|
|
869
|
+
role: string | null;
|
|
870
|
+
retries?: number | null;
|
|
871
|
+
outputSchema?: JsonSchema | null;
|
|
872
|
+
options?: Readonly<Record<string, JsonValue>> | null;
|
|
873
|
+
optionKeys?: readonly string[];
|
|
874
|
+
execution?: StaticWorkflowExecution;
|
|
875
|
+
structure?: readonly StaticWorkflowScope[];
|
|
876
|
+
}
|
|
877
|
+
export interface WorkflowCatalogFunction {
|
|
878
|
+
name: string;
|
|
879
|
+
version: string;
|
|
880
|
+
headline: string;
|
|
881
|
+
description: string;
|
|
882
|
+
input: JsonSchema;
|
|
883
|
+
output: JsonSchema;
|
|
884
|
+
}
|
|
885
|
+
export interface WorkflowCatalogModelAlias {
|
|
886
|
+
name: string;
|
|
887
|
+
kind: "static" | "dynamic";
|
|
888
|
+
provenance: string;
|
|
889
|
+
version?: string;
|
|
890
|
+
headline?: string;
|
|
891
|
+
}
|
|
892
|
+
export interface WorkflowCatalogSettings {
|
|
893
|
+
concurrency: number;
|
|
894
|
+
backgroundWidget: boolean;
|
|
895
|
+
modelAliases: Readonly<Record<string, string>>;
|
|
896
|
+
skills: readonly string[];
|
|
897
|
+
extensions: readonly string[];
|
|
898
|
+
tools: readonly string[];
|
|
899
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
900
|
+
worktreePostCreateCommand?: readonly string[];
|
|
901
|
+
globalSettingsPath: string;
|
|
902
|
+
projectSettingsPath: string;
|
|
903
|
+
projectTrusted: boolean;
|
|
904
|
+
sources: WorkflowSettingsSources;
|
|
905
|
+
}
|
|
906
|
+
export interface WorkflowCatalogContext {
|
|
907
|
+
cwd: string;
|
|
908
|
+
projectTrusted: boolean;
|
|
909
|
+
globalSettingsPath?: string;
|
|
910
|
+
}
|
|
911
|
+
export interface WorkflowCatalog {
|
|
912
|
+
functions: readonly WorkflowCatalogFunction[];
|
|
913
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
914
|
+
modelAliasEntries?: readonly WorkflowCatalogModelAlias[];
|
|
915
|
+
settings?: WorkflowCatalogSettings;
|
|
916
|
+
}
|
|
917
|
+
export interface WorkflowCatalogIndexFunction {
|
|
918
|
+
name: string;
|
|
919
|
+
description: string;
|
|
920
|
+
input: JsonSchema;
|
|
921
|
+
}
|
|
922
|
+
export interface WorkflowCatalogIndex {
|
|
923
|
+
functions: readonly WorkflowCatalogIndexFunction[];
|
|
924
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
925
|
+
modelAliasEntries?: readonly WorkflowCatalogModelAlias[];
|
|
926
|
+
settings?: WorkflowCatalogSettings;
|
|
927
|
+
}
|
|
928
|
+
export interface WorkflowCatalogError {
|
|
929
|
+
error: {
|
|
930
|
+
code: "NOT_FOUND";
|
|
931
|
+
name: string;
|
|
932
|
+
message: string;
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
export interface WorkflowValidationParameters {
|
|
936
|
+
name: string;
|
|
937
|
+
description?: string;
|
|
938
|
+
script?: string;
|
|
939
|
+
scriptPath?: string;
|
|
940
|
+
args?: unknown;
|
|
941
|
+
}
|
|
942
|
+
export interface WorkflowValidationContext {
|
|
943
|
+
cwd: string;
|
|
944
|
+
projectTrusted: boolean;
|
|
945
|
+
availableModels: ReadonlySet<string>;
|
|
946
|
+
rootTools: ReadonlySet<string>;
|
|
947
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
948
|
+
knownModels?: ReadonlySet<string>;
|
|
949
|
+
settingsPath?: string;
|
|
950
|
+
agentDir?: string;
|
|
951
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
952
|
+
}
|
|
953
|
+
export interface ValidatedWorkflowLaunch {
|
|
954
|
+
script: string;
|
|
955
|
+
checked: PreflightResult;
|
|
956
|
+
agentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
957
|
+
projectAgentDefinitions: Readonly<Record<string, AgentDefinition>>;
|
|
958
|
+
roleNames: readonly string[];
|
|
959
|
+
}
|
|
960
|
+
export {};
|