@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,338 @@
|
|
|
1
|
+
import { DefaultResourceLoader, ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ExtensionContext, ModelRegistry, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
type HerdrModelContext = {
|
|
4
|
+
readonly model: ExtensionContext["model"];
|
|
5
|
+
readonly modelRegistry: ModelRegistry | undefined;
|
|
6
|
+
};
|
|
7
|
+
type AgentMessage = {
|
|
8
|
+
role: string;
|
|
9
|
+
content?: unknown;
|
|
10
|
+
stopReason?: string;
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
usage?: {
|
|
13
|
+
input: number;
|
|
14
|
+
output: number;
|
|
15
|
+
cacheRead: number;
|
|
16
|
+
cacheWrite: number;
|
|
17
|
+
cost: {
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export interface PiSession {
|
|
23
|
+
readonly sessionId: string;
|
|
24
|
+
readonly sessionFile: string | undefined;
|
|
25
|
+
readonly messages: readonly AgentMessage[];
|
|
26
|
+
getSessionStats(): {
|
|
27
|
+
tokens: {
|
|
28
|
+
input: number;
|
|
29
|
+
output: number;
|
|
30
|
+
cacheRead: number;
|
|
31
|
+
cacheWrite: number;
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
cost: number;
|
|
35
|
+
};
|
|
36
|
+
readonly systemPrompt?: string;
|
|
37
|
+
readonly model?: {
|
|
38
|
+
provider: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
readonly herdrModelContext?: HerdrModelContext;
|
|
43
|
+
readonly thinkingLevel?: string;
|
|
44
|
+
readonly agent?: {
|
|
45
|
+
state: {
|
|
46
|
+
tools: readonly {
|
|
47
|
+
name: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
subscribe?(listener: (event: unknown) => void | Promise<void>): () => void;
|
|
51
|
+
};
|
|
52
|
+
readonly herdrResourcePaths?: {
|
|
53
|
+
extensions: readonly string[];
|
|
54
|
+
skills: readonly string[];
|
|
55
|
+
};
|
|
56
|
+
readonly herdrContextFiles?: readonly import("./types.js").ContextFile[];
|
|
57
|
+
preparePrompt(text: string): Promise<PiPromptInspection>;
|
|
58
|
+
getResourceInspection(): PiResourceInspection;
|
|
59
|
+
subscribe?(listener: (event: unknown) => void): () => void;
|
|
60
|
+
prompt(text: string): Promise<void>;
|
|
61
|
+
steer?(text: string): Promise<void>;
|
|
62
|
+
abort?(): Promise<void>;
|
|
63
|
+
dispose(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
export interface PiPromptInspection {
|
|
66
|
+
readonly prompt: string;
|
|
67
|
+
readonly expandedPrompt: string;
|
|
68
|
+
readonly systemPrompt: string;
|
|
69
|
+
readonly messages: readonly unknown[];
|
|
70
|
+
readonly systemPromptOptions: unknown;
|
|
71
|
+
readonly inputHandled: boolean;
|
|
72
|
+
readonly diagnostics: readonly {
|
|
73
|
+
type: "error";
|
|
74
|
+
message: string;
|
|
75
|
+
source?: string;
|
|
76
|
+
}[];
|
|
77
|
+
}
|
|
78
|
+
export interface PiResourceInspection {
|
|
79
|
+
readonly extensions: readonly string[];
|
|
80
|
+
readonly skills: readonly string[];
|
|
81
|
+
readonly diagnostics: readonly {
|
|
82
|
+
type: "warning" | "error" | "collision";
|
|
83
|
+
message: string;
|
|
84
|
+
source?: string;
|
|
85
|
+
}[];
|
|
86
|
+
readonly systemPromptSource?: string;
|
|
87
|
+
}
|
|
88
|
+
import type { AgentAccounting, AgentActivity, AgentContinuity, AgentIdentity, AgentResourcePolicy, AgentResourceSelectors, AgentSetup, AgentSetupSummary, AgentTransport, AgentTransportContext, ContextFileScope, JsonSchema, JsonValue, LiveSessionHandoff, ModelSpec, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentSession, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowExtensionSettings, WorkflowExtensionSettingsValidatorContext, WorkflowRunContext } from "./types.js";
|
|
89
|
+
import { type AgentDefinition, type AgentState } from "./types.js";
|
|
90
|
+
import type { RunStore } from "./persistence.js";
|
|
91
|
+
type AgentExecutionRunStore = Pick<RunStore, "recordSystemPrompt" | "validateWorktree" | "worktree" | "snapshotWorktree">;
|
|
92
|
+
export type { AgentAccounting, AgentActivity, AgentInspectionMode, AgentSetup, AgentSetupContext, AgentSetupHook, AgentTransport, AgentTransportContext, PiRuntimeLaunchInfo, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentMessage, WorkflowAgentSession, WorkflowAgentSessionEvent, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowAgentSessionStats, WorkflowAgentTurnResult } from "./types.js";
|
|
93
|
+
export interface AgentBudgetHooks {
|
|
94
|
+
beforeAttempt(): void;
|
|
95
|
+
beforeTurn(): void;
|
|
96
|
+
afterTurn(accounting: AgentAccounting, final: boolean): void;
|
|
97
|
+
instruction(): string | undefined;
|
|
98
|
+
}
|
|
99
|
+
export type { AgentDefinition } from "./types.js";
|
|
100
|
+
export interface AgentProviderFailure {
|
|
101
|
+
label: string;
|
|
102
|
+
provider: string;
|
|
103
|
+
model: string;
|
|
104
|
+
error: string;
|
|
105
|
+
}
|
|
106
|
+
export type AgentProviderRecovery = "retry" | "abort" | {
|
|
107
|
+
model: string;
|
|
108
|
+
};
|
|
109
|
+
export interface AgentExecutionOptions {
|
|
110
|
+
label: string;
|
|
111
|
+
workflowName: string;
|
|
112
|
+
tuiIndex?: number;
|
|
113
|
+
tuiLabel?: string;
|
|
114
|
+
phase?: string;
|
|
115
|
+
parent?: string;
|
|
116
|
+
model?: string;
|
|
117
|
+
onProgress?: (progress: AgentProgress) => void | Promise<void>;
|
|
118
|
+
onAttempt?: (attempt: AgentAttempt) => void | Promise<void>;
|
|
119
|
+
providerErrorRecovery?: (failure: AgentProviderFailure) => Promise<AgentProviderRecovery>;
|
|
120
|
+
modelOverride?: ModelSpec;
|
|
121
|
+
tools?: readonly string[];
|
|
122
|
+
skills?: readonly string[];
|
|
123
|
+
extensions?: readonly string[];
|
|
124
|
+
effectiveTools?: readonly string[];
|
|
125
|
+
role?: string;
|
|
126
|
+
contextFiles?: readonly ContextFileScope[];
|
|
127
|
+
schema?: JsonSchema;
|
|
128
|
+
retries?: number;
|
|
129
|
+
timeoutMs?: number | null;
|
|
130
|
+
retryState?: string;
|
|
131
|
+
worktreeOwner?: string;
|
|
132
|
+
cwd?: string;
|
|
133
|
+
sessionPath?: string;
|
|
134
|
+
budget?: AgentBudgetHooks;
|
|
135
|
+
agentOptions?: Readonly<Record<string, JsonValue>>;
|
|
136
|
+
agentIdentity?: AgentIdentity;
|
|
137
|
+
inheritedExtensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
138
|
+
agentNodeId?: string;
|
|
139
|
+
}
|
|
140
|
+
export interface AgentExecutionRoot {
|
|
141
|
+
cwd: string;
|
|
142
|
+
model: ModelSpec;
|
|
143
|
+
tools: ReadonlySet<string>;
|
|
144
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings> | undefined;
|
|
145
|
+
validateExtensionSettings?: (settings: Readonly<WorkflowExtensionSettings> | undefined, context: WorkflowExtensionSettingsValidatorContext) => void;
|
|
146
|
+
onAgentSettings?: (agentNodeId: string, settings: Readonly<WorkflowExtensionSettings>) => void;
|
|
147
|
+
resourceSelectors?: AgentResourceSelectors;
|
|
148
|
+
agentDefinitions?: Readonly<Record<string, AgentDefinition>>;
|
|
149
|
+
agentDir?: string;
|
|
150
|
+
additionalSkillPaths?: readonly string[];
|
|
151
|
+
availableModels?: ReadonlySet<string>;
|
|
152
|
+
knownModels?: ReadonlySet<string>;
|
|
153
|
+
modelAliases?: Readonly<Record<string, string>>;
|
|
154
|
+
blockedAliases?: ReadonlySet<string>;
|
|
155
|
+
blockedAliasTargets?: Readonly<Record<string, string>>;
|
|
156
|
+
settingsPath?: string;
|
|
157
|
+
extensionSettingsPath?: string;
|
|
158
|
+
runStore?: AgentExecutionRunStore;
|
|
159
|
+
providerPause?: () => Promise<void>;
|
|
160
|
+
agentSetupHooks?: readonly RegisteredAgentSetupHook[];
|
|
161
|
+
agentResourcePolicy?: () => AgentResourcePolicy | Promise<AgentResourcePolicy>;
|
|
162
|
+
runContext?: Readonly<WorkflowRunContext>;
|
|
163
|
+
onResourceWarning?: (message: string) => void;
|
|
164
|
+
}
|
|
165
|
+
export interface AgentToolCallProgress {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
state: "running" | "completed" | "failed";
|
|
169
|
+
}
|
|
170
|
+
export interface AgentProgress {
|
|
171
|
+
accounting: AgentAccounting;
|
|
172
|
+
toolCalls: readonly AgentToolCallProgress[];
|
|
173
|
+
state?: WorkflowAgentSessionState;
|
|
174
|
+
activity?: AgentActivity;
|
|
175
|
+
lastEventAt?: number;
|
|
176
|
+
persist: boolean;
|
|
177
|
+
}
|
|
178
|
+
export interface AgentAttempt {
|
|
179
|
+
attempt: number;
|
|
180
|
+
transport: string;
|
|
181
|
+
session?: WorkflowAgentSessionReference;
|
|
182
|
+
liveSession?: WorkflowAgentSession;
|
|
183
|
+
prepared?: Readonly<PreparedAgentSession>;
|
|
184
|
+
handoff?: LiveSessionHandoff;
|
|
185
|
+
result?: JsonValue;
|
|
186
|
+
error?: {
|
|
187
|
+
code: string;
|
|
188
|
+
message: string;
|
|
189
|
+
};
|
|
190
|
+
accounting: AgentAccounting;
|
|
191
|
+
setup: AgentSetupSummary;
|
|
192
|
+
}
|
|
193
|
+
export interface AgentExecutionResult {
|
|
194
|
+
value: JsonValue;
|
|
195
|
+
attempts: readonly AgentAttempt[];
|
|
196
|
+
cwd: string;
|
|
197
|
+
}
|
|
198
|
+
export declare function createLocalPiSession(input: SessionInput): Promise<PiSession>;
|
|
199
|
+
/**
|
|
200
|
+
* Hands the runtime the providers that extensions registered while loading.
|
|
201
|
+
*
|
|
202
|
+
* An extension that adds models (a proxy front-end, a gateway) registers them
|
|
203
|
+
* from its factory, and the loader parks those registrations on the extension
|
|
204
|
+
* runtime rather than applying them. Pi's own session assembly drains that
|
|
205
|
+
* queue; a workflow agent builds its runtime here by hand, so without this the
|
|
206
|
+
* models an extension provides stay unknown and every agent asking for one
|
|
207
|
+
* fails with UNKNOWN_MODEL.
|
|
208
|
+
*/
|
|
209
|
+
export declare function flushExtensionProviders(resourceLoader: DefaultResourceLoader, modelRuntime: ModelRuntime): string[];
|
|
210
|
+
export declare function createLocalWorkflowAgentSession(prepared: Readonly<PreparedAgentSession>, context: Readonly<AgentTransportContext>): Promise<WorkflowAgentSession>;
|
|
211
|
+
export declare const localAgentTransport: AgentTransport;
|
|
212
|
+
export type PreparedAgentSetup = {
|
|
213
|
+
setup: AgentSetup;
|
|
214
|
+
summary: AgentSetupSummary;
|
|
215
|
+
failure?: {
|
|
216
|
+
error: unknown;
|
|
217
|
+
hook?: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export declare function prepareAgentSetupForInspection(root: AgentExecutionRoot, task: string, options: AgentExecutionOptions, transport: AgentTransport): Promise<PreparedAgentSetup>;
|
|
221
|
+
export declare function getAgentAttempts(error: unknown): readonly AgentAttempt[] | undefined;
|
|
222
|
+
export declare class WorkflowAgentExecutor {
|
|
223
|
+
private readonly root;
|
|
224
|
+
private readonly transport;
|
|
225
|
+
private readonly warnedRoleTools;
|
|
226
|
+
constructor(root: AgentExecutionRoot, transport?: AgentTransport);
|
|
227
|
+
setRunContext(runContext: Readonly<WorkflowRunContext>): void;
|
|
228
|
+
resolve(options: AgentExecutionOptions, inheritedTools?: readonly string[]): {
|
|
229
|
+
model: ModelSpec;
|
|
230
|
+
requestedModel?: string;
|
|
231
|
+
tools: readonly string[];
|
|
232
|
+
systemPrompt?: string;
|
|
233
|
+
systemPromptAppend: string;
|
|
234
|
+
contextFiles?: readonly ContextFileScope[];
|
|
235
|
+
};
|
|
236
|
+
execute(task: string, options: AgentExecutionOptions, signal?: AbortSignal, customTools?: readonly ToolDefinition[], setSteer?: (handler: (message: string) => void | Promise<void>) => void, beforeRetry?: () => void): Promise<AgentExecutionResult>;
|
|
237
|
+
}
|
|
238
|
+
export interface ScheduledAgentOptions {
|
|
239
|
+
label: string;
|
|
240
|
+
requestedLabel?: string;
|
|
241
|
+
parentBreadcrumb?: string;
|
|
242
|
+
cwd: string;
|
|
243
|
+
tools: readonly string[];
|
|
244
|
+
skills?: readonly string[];
|
|
245
|
+
extensions?: readonly string[];
|
|
246
|
+
worktreeOwner?: string;
|
|
247
|
+
model?: string;
|
|
248
|
+
role?: string;
|
|
249
|
+
contextFiles?: readonly ContextFileScope[];
|
|
250
|
+
schema?: JsonSchema;
|
|
251
|
+
retries?: number;
|
|
252
|
+
timeoutMs?: number | null;
|
|
253
|
+
sessionPath?: string;
|
|
254
|
+
continuity?: AgentContinuity;
|
|
255
|
+
agentOptions?: Readonly<Record<string, JsonValue>>;
|
|
256
|
+
agentIdentity?: AgentIdentity;
|
|
257
|
+
extensionSettings?: Readonly<WorkflowExtensionSettings>;
|
|
258
|
+
}
|
|
259
|
+
export type ScheduledAgentResult = {
|
|
260
|
+
id: string;
|
|
261
|
+
ok: true;
|
|
262
|
+
value: JsonValue;
|
|
263
|
+
} | {
|
|
264
|
+
id: string;
|
|
265
|
+
ok: false;
|
|
266
|
+
error: {
|
|
267
|
+
code: string;
|
|
268
|
+
message: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
export interface ScheduledAgentInput {
|
|
272
|
+
id: string;
|
|
273
|
+
runId: string;
|
|
274
|
+
tuiIndex: number;
|
|
275
|
+
parentId?: string;
|
|
276
|
+
prompt: string;
|
|
277
|
+
options: Readonly<ScheduledAgentOptions>;
|
|
278
|
+
signal: AbortSignal;
|
|
279
|
+
setSteer: (handler: (message: string) => void | Promise<void>) => void;
|
|
280
|
+
}
|
|
281
|
+
export type ScheduledAgentRunner = (input: ScheduledAgentInput) => Promise<JsonValue>;
|
|
282
|
+
type ScheduledNode = {
|
|
283
|
+
id: string;
|
|
284
|
+
runId: string;
|
|
285
|
+
parentId?: string;
|
|
286
|
+
prompt?: string;
|
|
287
|
+
options: Readonly<ScheduledAgentOptions>;
|
|
288
|
+
children: Set<string>;
|
|
289
|
+
collected: boolean;
|
|
290
|
+
resultQueue: Promise<void>;
|
|
291
|
+
collecting: boolean;
|
|
292
|
+
state: AgentState;
|
|
293
|
+
controller: AbortController;
|
|
294
|
+
promise: Promise<ScheduledAgentResult> | undefined;
|
|
295
|
+
resolve: ((result: ScheduledAgentResult) => void) | undefined;
|
|
296
|
+
completion: Promise<void>;
|
|
297
|
+
resolveCompletion: () => void;
|
|
298
|
+
task: () => Promise<void>;
|
|
299
|
+
restored: boolean;
|
|
300
|
+
steer?: (message: string) => void | Promise<void>;
|
|
301
|
+
};
|
|
302
|
+
export type OwnershipRecord = {
|
|
303
|
+
id: string;
|
|
304
|
+
parentId?: string;
|
|
305
|
+
prompt?: string;
|
|
306
|
+
label: string;
|
|
307
|
+
state: ScheduledNode["state"];
|
|
308
|
+
options: Readonly<ScheduledAgentOptions>;
|
|
309
|
+
};
|
|
310
|
+
type OwnershipWriter = (runId: string, ownership: readonly OwnershipRecord[]) => void | Promise<void>;
|
|
311
|
+
export declare class FairAgentScheduler {
|
|
312
|
+
#private;
|
|
313
|
+
private readonly runner;
|
|
314
|
+
readonly sessionLimit: number;
|
|
315
|
+
private readonly writeOwnership?;
|
|
316
|
+
constructor(runner: ScheduledAgentRunner, sessionLimit?: number, writeOwnership?: OwnershipWriter | undefined);
|
|
317
|
+
addRun(runId: string, limit?: number, beforeLaunch?: () => void, extensionSettings?: Readonly<WorkflowExtensionSettings>): void;
|
|
318
|
+
updateRunLimit(runId: string, limit: number): void;
|
|
319
|
+
setRunExtensionSettings(runId: string, settings: Readonly<WorkflowExtensionSettings> | undefined): void;
|
|
320
|
+
setExtensionSettings(agentId: string, settings: Readonly<WorkflowExtensionSettings>): void;
|
|
321
|
+
spawn(runId: string, prompt: string, options: ScheduledAgentOptions, parentId?: string): {
|
|
322
|
+
id: string;
|
|
323
|
+
result: Promise<ScheduledAgentResult>;
|
|
324
|
+
};
|
|
325
|
+
result(parentId: string, childId: string): Promise<ScheduledAgentResult>;
|
|
326
|
+
steer(parentId: string, childId: string, message: string): Promise<void>;
|
|
327
|
+
cancel(id: string): void;
|
|
328
|
+
releaseResult(id: string): void;
|
|
329
|
+
cancelChildren(id: string): void;
|
|
330
|
+
retry(id: string): void;
|
|
331
|
+
attemptStarted(id: string): void;
|
|
332
|
+
cancelRun(runId: string): Promise<void>;
|
|
333
|
+
removeRun(runId: string): void;
|
|
334
|
+
toolsFor(parentId: string, resolveTools?: (role: string | undefined, tools: readonly string[] | undefined, model: string | undefined, inheritedTools: readonly string[], skills: readonly string[] | undefined, extensions: readonly string[] | undefined) => readonly string[]): ToolDefinition[];
|
|
335
|
+
snapshot(): readonly OwnershipRecord[];
|
|
336
|
+
restoreRun(runId: string, limit: number, ownership: readonly OwnershipRecord[], beforeLaunch?: () => void, extensionSettings?: Readonly<WorkflowExtensionSettings>): void;
|
|
337
|
+
flush(runId?: string): Promise<void>;
|
|
338
|
+
}
|