@rowan-agent/agent 0.4.11 → 0.5.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/README.md +25 -21
- package/dist/index.d.ts +207 -273
- package/dist/index.js +2292 -1725
- package/package.json +1 -1
- package/dist/chunk-2FIII4GP.js +0 -142
- package/dist/chunk-FTIS43EE.js +0 -504
- package/dist/loader-HCYCHPGT.js +0 -13
- package/dist/path-XORRK2EC.js +0 -28
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _rowan_agent_models from '@rowan-agent/models';
|
|
2
|
-
import { LlmRequest, LlmResponse, LlmModelRef, LlmModelUsage,
|
|
2
|
+
import { LlmRequest, LlmResponse, LlmModelRef, LlmModelUsage, AgentMessage, ContentBlock, ToolCall, ToolResult, Outcome, ProviderConfig, Skill as Skill$1, StreamFn, AgentEventListener, Protocol, ModelCost, AgentEvent, LlmMessage } from '@rowan-agent/models';
|
|
3
3
|
export { AgentEvent, AgentEventListener, AgentMessage, LlmModelRef, Outcome, Skill, StreamFn, ToolResult, createDispatchStream, registerBuiltInApiProviders } from '@rowan-agent/models';
|
|
4
4
|
import Type from 'typebox';
|
|
5
5
|
|
|
@@ -23,119 +23,6 @@ type ModelTranscript = {
|
|
|
23
23
|
response: LlmResponse;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
type BeforePhaseHook = (phaseId: string, input: PhaseContext) => Promise<BeforePhaseHookResult>;
|
|
27
|
-
type AfterPhaseHook = (phaseId: string, output: PhaseOutput) => Promise<AfterPhaseHookResult>;
|
|
28
|
-
type BeforePromptHook = (phaseId: string, input: PhaseContext) => Promise<PhaseContext>;
|
|
29
|
-
type LoopMetrics = {
|
|
30
|
-
/** Number of phase iterations executed. */
|
|
31
|
-
iterations: number;
|
|
32
|
-
/** Phase transition history. */
|
|
33
|
-
phaseTransitions: Array<{
|
|
34
|
-
from: string;
|
|
35
|
-
to: string;
|
|
36
|
-
ts: string;
|
|
37
|
-
}>;
|
|
38
|
-
/** Number of times compaction was triggered. */
|
|
39
|
-
compactionCount: number;
|
|
40
|
-
/** Number of retry attempts due to transient errors. */
|
|
41
|
-
retryCount: number;
|
|
42
|
-
/** Loop start timestamp. */
|
|
43
|
-
startedAt: string;
|
|
44
|
-
/** Loop start time as epoch ms (for duration calculation). */
|
|
45
|
-
startedAtMs: number;
|
|
46
|
-
/** Loop end timestamp (set on completion). */
|
|
47
|
-
endedAt?: string;
|
|
48
|
-
/** Total wall-clock duration in ms. */
|
|
49
|
-
durationMs?: number;
|
|
50
|
-
};
|
|
51
|
-
type SessionState = {
|
|
52
|
-
currentPhase: string;
|
|
53
|
-
attempt: number;
|
|
54
|
-
metrics: LoopMetrics;
|
|
55
|
-
status: "idle" | "running" | "completed" | "aborted" | "failed";
|
|
56
|
-
};
|
|
57
|
-
type AgentConfig = {
|
|
58
|
-
context: AgentContext;
|
|
59
|
-
sessionId?: string;
|
|
60
|
-
model: LlmModelRef;
|
|
61
|
-
stream: StreamFn;
|
|
62
|
-
signal?: AbortSignal;
|
|
63
|
-
emit?: AgentEventListener;
|
|
64
|
-
phases?: PhaseRegistry;
|
|
65
|
-
runtime?: AgentRuntimePort;
|
|
66
|
-
beforeToolCall?: BeforeToolCall;
|
|
67
|
-
afterToolCall?: AfterToolCall;
|
|
68
|
-
beforePhase?: BeforePhaseHook;
|
|
69
|
-
afterPhase?: AfterPhaseHook;
|
|
70
|
-
beforePrompt?: BeforePromptHook;
|
|
71
|
-
maxAttempts?: number;
|
|
72
|
-
onModelTranscript?: (transcript: ModelTranscript, meta: {
|
|
73
|
-
phase: string;
|
|
74
|
-
model: LlmModelRef;
|
|
75
|
-
}) => Promise<void>;
|
|
76
|
-
onMessage?: (message: AgentMessage) => Promise<void>;
|
|
77
|
-
onOutcome?: (outcome: Outcome) => Promise<void>;
|
|
78
|
-
sessionState?: SessionState;
|
|
79
|
-
};
|
|
80
|
-
type ToolRunnerInput = {
|
|
81
|
-
config: AgentConfig;
|
|
82
|
-
toolCall: ToolCall;
|
|
83
|
-
};
|
|
84
|
-
type ToolRunner = (input: ToolRunnerInput) => Promise<ToolResult>;
|
|
85
|
-
type AgentRuntimePort = {
|
|
86
|
-
tools?: ToolRunner;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
type ToolContext = Pick<AgentContext, "skills"> & {
|
|
90
|
-
toolCallId: string;
|
|
91
|
-
};
|
|
92
|
-
type ToolExecutionMode = "sequential" | "parallel";
|
|
93
|
-
type Tool<TArgs = unknown> = {
|
|
94
|
-
name: string;
|
|
95
|
-
description: string;
|
|
96
|
-
parameters: Type.TSchema;
|
|
97
|
-
/** One-line snippet shown in the system prompt tool list. */
|
|
98
|
-
promptSnippet?: string;
|
|
99
|
-
/** Additional guidelines appended to the system prompt when this tool is active. */
|
|
100
|
-
promptGuidelines?: string[];
|
|
101
|
-
/** Whether this tool can run concurrently with others. Default: "parallel". */
|
|
102
|
-
executionMode?: ToolExecutionMode;
|
|
103
|
-
execute(args: TArgs, context: ToolContext, signal?: AbortSignal): Promise<ToolResult>;
|
|
104
|
-
};
|
|
105
|
-
/** Context snapshot passed into the low-level agent loop. */
|
|
106
|
-
type AgentContext = {
|
|
107
|
-
/** System prompt included with the request. */
|
|
108
|
-
systemPrompt: string;
|
|
109
|
-
/** Transcript visible to the model. */
|
|
110
|
-
messages: AgentMessage[];
|
|
111
|
-
/** Tools available for this run. */
|
|
112
|
-
tools: Tool[];
|
|
113
|
-
/** Skills available for this run. */
|
|
114
|
-
skills: Skill$1[];
|
|
115
|
-
};
|
|
116
|
-
type BeforeToolCall = (input: {
|
|
117
|
-
tool: Tool;
|
|
118
|
-
args: unknown;
|
|
119
|
-
}) => Promise<{
|
|
120
|
-
allow: true;
|
|
121
|
-
} | {
|
|
122
|
-
allow: false;
|
|
123
|
-
reason: string;
|
|
124
|
-
}>;
|
|
125
|
-
type AfterToolCall = (input: {
|
|
126
|
-
tool: Tool;
|
|
127
|
-
result: ToolResult;
|
|
128
|
-
}) => Promise<ToolResult>;
|
|
129
|
-
type RunResult = {
|
|
130
|
-
sessionId: string;
|
|
131
|
-
messages: AgentMessage[];
|
|
132
|
-
outcome: Outcome;
|
|
133
|
-
metrics: LoopMetrics;
|
|
134
|
-
};
|
|
135
|
-
type Unsubscribe = () => void;
|
|
136
|
-
declare function createMessage(role: AgentMessage["role"], content: AgentMessage["content"], metadata?: Record<string, unknown>): AgentMessage;
|
|
137
|
-
declare function messageContentText(content: AgentMessage["content"]): string;
|
|
138
|
-
|
|
139
26
|
type ModelInvokeOutput = {
|
|
140
27
|
text: string;
|
|
141
28
|
contentBlocks: ContentBlock[];
|
|
@@ -159,89 +46,6 @@ type PhaseExecution = {
|
|
|
159
46
|
executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
|
|
160
47
|
};
|
|
161
48
|
|
|
162
|
-
/** Unified phase output — model decides routing via route. */
|
|
163
|
-
type PhaseOutput = {
|
|
164
|
-
message: string;
|
|
165
|
-
/** Route to next phase, or "continue" to re-execute current phase, or "stop" to end */
|
|
166
|
-
route: string;
|
|
167
|
-
/** Phase name that produced this output */
|
|
168
|
-
phase?: string;
|
|
169
|
-
/** Tool calls from the model invocation (used by framework for route extraction) */
|
|
170
|
-
toolCalls?: Array<{
|
|
171
|
-
id: string;
|
|
172
|
-
name: string;
|
|
173
|
-
args: unknown;
|
|
174
|
-
}>;
|
|
175
|
-
/** Route reason extracted from route tool call (for hooks to inspect) */
|
|
176
|
-
routeReason?: string;
|
|
177
|
-
/** Structured data from this phase, passed to the next phase */
|
|
178
|
-
payload?: unknown;
|
|
179
|
-
};
|
|
180
|
-
/** Phase machine state — tracks position and inter-phase data */
|
|
181
|
-
interface PhaseState {
|
|
182
|
-
current: string;
|
|
183
|
-
available: string[];
|
|
184
|
-
iterations: number;
|
|
185
|
-
payload?: unknown;
|
|
186
|
-
}
|
|
187
|
-
/** Everything a phase needs to execute */
|
|
188
|
-
interface PhaseContext {
|
|
189
|
-
systemPrompt: string;
|
|
190
|
-
messages: AgentMessage[];
|
|
191
|
-
/** Phase-filtered tools */
|
|
192
|
-
tools: Tool[];
|
|
193
|
-
/** Phase-filtered skills */
|
|
194
|
-
skills: Skill$1[];
|
|
195
|
-
/** Phase machine state */
|
|
196
|
-
state: PhaseState;
|
|
197
|
-
/** Additional guideline bullets appended to the system prompt */
|
|
198
|
-
promptGuidelines?: string[];
|
|
199
|
-
/** Text to append after the system prompt */
|
|
200
|
-
appendSystemPrompt?: string;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Loaded Phase object
|
|
204
|
-
*/
|
|
205
|
-
interface Phase {
|
|
206
|
-
/** Unique identifier */
|
|
207
|
-
id: string;
|
|
208
|
-
/** Display name */
|
|
209
|
-
name: string;
|
|
210
|
-
/** Description */
|
|
211
|
-
description: string;
|
|
212
|
-
/** Restricted tools (undefined = all tools available) */
|
|
213
|
-
tools?: string[];
|
|
214
|
-
/** Restricted skills (undefined = all skills available) */
|
|
215
|
-
skills?: string[];
|
|
216
|
-
/** Forced next phase */
|
|
217
|
-
target?: string;
|
|
218
|
-
/** Expected input fields (key → description) */
|
|
219
|
-
input?: Record<string, string>;
|
|
220
|
-
/** If true, phase gets a fresh context when executed in parallel */
|
|
221
|
-
isolated?: boolean;
|
|
222
|
-
/** Path to PHASE.md file */
|
|
223
|
-
filePath: string;
|
|
224
|
-
/** Phase directory path */
|
|
225
|
-
baseDir: string;
|
|
226
|
-
/** PHASE.md body content */
|
|
227
|
-
content: string;
|
|
228
|
-
/** Model override for this phase (resolved from frontmatter) */
|
|
229
|
-
model?: LlmModelRef;
|
|
230
|
-
/** ExtensionAPI factory function (default export pattern) */
|
|
231
|
-
factory?: (api: ExtensionAPI) => Promise<void>;
|
|
232
|
-
/** Legacy run function */
|
|
233
|
-
run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Phase registry containing all loaded phases
|
|
237
|
-
*/
|
|
238
|
-
interface PhaseRegistry {
|
|
239
|
-
/** Map of phase id to Phase object */
|
|
240
|
-
phases: Map<string, Phase>;
|
|
241
|
-
/** Entry phase id (null if no phases defined) */
|
|
242
|
-
entryPhaseId: string | null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
49
|
/**
|
|
246
50
|
* Extension types — simplified for the new hook-based system.
|
|
247
51
|
*/
|
|
@@ -387,10 +191,8 @@ type HandlerFn = (...args: unknown[]) => Promise<unknown>;
|
|
|
387
191
|
* Tracks what each extension registered for attribution and cleanup.
|
|
388
192
|
*/
|
|
389
193
|
interface Extension {
|
|
390
|
-
/** Extension path (may be synthetic like `<
|
|
194
|
+
/** Extension path (may be synthetic like `<inline>`) */
|
|
391
195
|
path: string;
|
|
392
|
-
/** Resolved absolute path */
|
|
393
|
-
resolvedPath: string;
|
|
394
196
|
/** Source info for error messages */
|
|
395
197
|
sourceInfo: SourceInfo;
|
|
396
198
|
/** Event handlers registered by this extension */
|
|
@@ -403,7 +205,7 @@ interface Extension {
|
|
|
403
205
|
/**
|
|
404
206
|
* Create an Extension object with empty collections.
|
|
405
207
|
*/
|
|
406
|
-
declare function createExtension(extensionPath: string,
|
|
208
|
+
declare function createExtension(extensionPath: string, sourceInfo: SourceInfo): Extension;
|
|
407
209
|
/**
|
|
408
210
|
* Shared runtime state created by loader, used during registration and runtime.
|
|
409
211
|
* All ExtensionAPI instances reference this shared state.
|
|
@@ -459,7 +261,6 @@ type LoadExtensionsResult = {
|
|
|
459
261
|
*/
|
|
460
262
|
interface LoadedExtension {
|
|
461
263
|
path: string;
|
|
462
|
-
resolvedPath: string;
|
|
463
264
|
name: string;
|
|
464
265
|
factory: ExtensionFactory;
|
|
465
266
|
manifest?: ExtensionManifest;
|
|
@@ -1342,48 +1143,203 @@ declare class ExtensionRunner {
|
|
|
1342
1143
|
}
|
|
1343
1144
|
declare function createExtensionRunner(options?: ExtensionRunnerOptions): ExtensionRunner;
|
|
1344
1145
|
|
|
1146
|
+
type LoopMetrics = {
|
|
1147
|
+
/** Number of phase iterations executed. */
|
|
1148
|
+
iterations: number;
|
|
1149
|
+
/** Phase transition history. */
|
|
1150
|
+
phaseTransitions: Array<{
|
|
1151
|
+
from: string;
|
|
1152
|
+
to: string;
|
|
1153
|
+
ts: string;
|
|
1154
|
+
}>;
|
|
1155
|
+
/** Number of times compaction was triggered. */
|
|
1156
|
+
compactionCount: number;
|
|
1157
|
+
/** Number of retry attempts due to transient errors. */
|
|
1158
|
+
retryCount: number;
|
|
1159
|
+
/** Loop start timestamp. */
|
|
1160
|
+
startedAt: string;
|
|
1161
|
+
/** Loop start time as epoch ms (for duration calculation). */
|
|
1162
|
+
startedAtMs: number;
|
|
1163
|
+
/** Loop end timestamp (set on completion). */
|
|
1164
|
+
endedAt?: string;
|
|
1165
|
+
/** Total wall-clock duration in ms. */
|
|
1166
|
+
durationMs?: number;
|
|
1167
|
+
};
|
|
1168
|
+
type SessionState = {
|
|
1169
|
+
currentPhase: string;
|
|
1170
|
+
attempt: number;
|
|
1171
|
+
metrics: LoopMetrics;
|
|
1172
|
+
status: "idle" | "running" | "completed" | "aborted" | "failed";
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
type ToolContext = Pick<AgentContext, "skills"> & {
|
|
1176
|
+
toolCallId: string;
|
|
1177
|
+
};
|
|
1178
|
+
type ToolExecutionMode = "sequential" | "parallel";
|
|
1179
|
+
type Tool<TArgs = unknown> = {
|
|
1180
|
+
name: string;
|
|
1181
|
+
description: string;
|
|
1182
|
+
parameters: Type.TSchema;
|
|
1183
|
+
/** One-line snippet shown in the system prompt tool list. */
|
|
1184
|
+
promptSnippet?: string;
|
|
1185
|
+
/** Additional guidelines appended to the system prompt when this tool is active. */
|
|
1186
|
+
promptGuidelines?: string[];
|
|
1187
|
+
/** Whether this tool can run concurrently with others. Default: "parallel". */
|
|
1188
|
+
executionMode?: ToolExecutionMode;
|
|
1189
|
+
execute(args: TArgs, context: ToolContext, signal?: AbortSignal): Promise<ToolResult>;
|
|
1190
|
+
};
|
|
1191
|
+
/** Context snapshot passed into the low-level agent loop. */
|
|
1192
|
+
type AgentContext = {
|
|
1193
|
+
/** System prompt included with the request. */
|
|
1194
|
+
systemPrompt: string;
|
|
1195
|
+
/** Transcript visible to the model. */
|
|
1196
|
+
messages: AgentMessage[];
|
|
1197
|
+
/** Tools available for this run. */
|
|
1198
|
+
tools: Tool[];
|
|
1199
|
+
/** Skills available for this run. */
|
|
1200
|
+
skills: Skill$1[];
|
|
1201
|
+
/** Custom phases for this run. Agent normalizes this with the built-in default phase. */
|
|
1202
|
+
phases?: PhaseRegistry;
|
|
1203
|
+
};
|
|
1204
|
+
type BeforeToolCall = (input: {
|
|
1205
|
+
tool: Tool;
|
|
1206
|
+
args: unknown;
|
|
1207
|
+
}) => Promise<{
|
|
1208
|
+
allow: true;
|
|
1209
|
+
} | {
|
|
1210
|
+
allow: false;
|
|
1211
|
+
reason: string;
|
|
1212
|
+
}>;
|
|
1213
|
+
type AfterToolCall = (input: {
|
|
1214
|
+
tool: Tool;
|
|
1215
|
+
result: ToolResult;
|
|
1216
|
+
}) => Promise<ToolResult>;
|
|
1217
|
+
type RunResult = {
|
|
1218
|
+
sessionId: string;
|
|
1219
|
+
messages: AgentMessage[];
|
|
1220
|
+
outcome: Outcome;
|
|
1221
|
+
metrics: LoopMetrics;
|
|
1222
|
+
};
|
|
1223
|
+
type Unsubscribe = () => void;
|
|
1224
|
+
declare function createMessage(role: AgentMessage["role"], content: AgentMessage["content"], metadata?: Record<string, unknown>): AgentMessage;
|
|
1225
|
+
declare function messageContentText(content: AgentMessage["content"]): string;
|
|
1226
|
+
|
|
1227
|
+
/** Unified phase output — model decides routing via route. */
|
|
1228
|
+
type PhaseOutput = {
|
|
1229
|
+
message: string;
|
|
1230
|
+
/** Route to next phase, or "continue" to re-execute current phase, or "stop" to end */
|
|
1231
|
+
route: string;
|
|
1232
|
+
/** Phase name that produced this output */
|
|
1233
|
+
phase?: string;
|
|
1234
|
+
/** Tool calls from the model invocation (used by framework for route extraction) */
|
|
1235
|
+
toolCalls?: Array<{
|
|
1236
|
+
id: string;
|
|
1237
|
+
name: string;
|
|
1238
|
+
args: unknown;
|
|
1239
|
+
}>;
|
|
1240
|
+
/** Route reason extracted from route tool call (for hooks to inspect) */
|
|
1241
|
+
routeReason?: string;
|
|
1242
|
+
/** Structured data from this phase, passed to the next phase */
|
|
1243
|
+
payload?: unknown;
|
|
1244
|
+
};
|
|
1245
|
+
/** Phase machine state — tracks position and inter-phase data */
|
|
1246
|
+
interface PhaseState {
|
|
1247
|
+
current: string;
|
|
1248
|
+
available: string[];
|
|
1249
|
+
iterations: number;
|
|
1250
|
+
payload?: unknown;
|
|
1251
|
+
}
|
|
1252
|
+
/** Everything a phase needs to execute */
|
|
1253
|
+
interface PhaseContext {
|
|
1254
|
+
systemPrompt: string;
|
|
1255
|
+
messages: AgentMessage[];
|
|
1256
|
+
/** Phase-filtered tools */
|
|
1257
|
+
tools: Tool[];
|
|
1258
|
+
/** Phase-filtered skills */
|
|
1259
|
+
skills: Skill$1[];
|
|
1260
|
+
/** Phase machine state */
|
|
1261
|
+
state: PhaseState;
|
|
1262
|
+
/** Additional guideline bullets appended to the system prompt */
|
|
1263
|
+
promptGuidelines?: string[];
|
|
1264
|
+
/** Text to append after the system prompt */
|
|
1265
|
+
appendSystemPrompt?: string;
|
|
1266
|
+
}
|
|
1345
1267
|
/**
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
* Uses the new LoadedExtension type that works with ExtensionRunner.
|
|
1268
|
+
* Loaded Phase object
|
|
1349
1269
|
*/
|
|
1350
|
-
|
|
1270
|
+
interface Phase {
|
|
1271
|
+
/** Unique identifier */
|
|
1272
|
+
id: string;
|
|
1273
|
+
/** Display name */
|
|
1274
|
+
name: string;
|
|
1275
|
+
/** Description */
|
|
1276
|
+
description: string;
|
|
1277
|
+
/** Restricted tools (undefined = all tools available) */
|
|
1278
|
+
tools?: string[];
|
|
1279
|
+
/** Restricted skills (undefined = all skills available) */
|
|
1280
|
+
skills?: string[];
|
|
1281
|
+
/** Forced next phase */
|
|
1282
|
+
target?: string;
|
|
1283
|
+
/** Expected input fields (key → description) */
|
|
1284
|
+
input?: Record<string, string>;
|
|
1285
|
+
/** If true, phase gets a fresh context when executed in parallel */
|
|
1286
|
+
isolated?: boolean;
|
|
1287
|
+
/** Path to PHASE.md file */
|
|
1288
|
+
filePath: string;
|
|
1289
|
+
/** Phase directory path */
|
|
1290
|
+
baseDir: string;
|
|
1291
|
+
/** PHASE.md body content */
|
|
1292
|
+
content: string;
|
|
1293
|
+
/** Model override for this phase (resolved from frontmatter) */
|
|
1294
|
+
model?: LlmModelRef;
|
|
1295
|
+
/** ExtensionAPI factory function (default export pattern) */
|
|
1296
|
+
factory?: (api: ExtensionAPI) => Promise<void>;
|
|
1297
|
+
/** Legacy run function */
|
|
1298
|
+
run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
|
|
1299
|
+
}
|
|
1351
1300
|
/**
|
|
1352
|
-
*
|
|
1301
|
+
* Phase registry containing all loaded phases
|
|
1353
1302
|
*/
|
|
1354
|
-
|
|
1303
|
+
interface PhaseRegistry {
|
|
1304
|
+
/** Map of phase id to Phase object */
|
|
1305
|
+
phases: Map<string, Phase>;
|
|
1306
|
+
/** Entry phase id (null until Agent applies its default phase) */
|
|
1307
|
+
entryPhaseId: string | null;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
type WorkspacePaths = {
|
|
1311
|
+
cwd: string;
|
|
1312
|
+
rowanDir: string;
|
|
1313
|
+
};
|
|
1314
|
+
type ResolveWorkspaceOptions = {
|
|
1315
|
+
cwd?: string;
|
|
1316
|
+
env?: NodeJS.ProcessEnv;
|
|
1317
|
+
homeDir?: string;
|
|
1318
|
+
rowanDir?: string;
|
|
1319
|
+
};
|
|
1320
|
+
declare function resolveWorkspacePaths(options?: ResolveWorkspaceOptions): WorkspacePaths;
|
|
1321
|
+
declare function resolveInWorkspace(path: string, rootOrPaths: string | Pick<WorkspacePaths, "cwd">): string;
|
|
1322
|
+
|
|
1323
|
+
type PhaseLoadTarget = string | Pick<WorkspacePaths, "rowanDir">;
|
|
1355
1324
|
/**
|
|
1356
|
-
* Load
|
|
1325
|
+
* Load a single phase from a PHASE.md file or phase directory.
|
|
1326
|
+
*
|
|
1327
|
+
* If a directory is provided, the loader reads its PHASE.md.
|
|
1357
1328
|
*/
|
|
1358
|
-
declare function
|
|
1359
|
-
|
|
1360
|
-
errors: Array<{
|
|
1361
|
-
path: string;
|
|
1362
|
-
error: string;
|
|
1363
|
-
}>;
|
|
1364
|
-
}>;
|
|
1329
|
+
declare function loadPhase(targetPath: string): Promise<Phase>;
|
|
1330
|
+
declare function loadPhases(targetPath: PhaseLoadTarget): Promise<PhaseRegistry>;
|
|
1365
1331
|
/**
|
|
1366
|
-
*
|
|
1332
|
+
* Re-read all file-based phases from disk and update the registry in place.
|
|
1333
|
+
* Extension-registered phases (with empty filePath) are preserved as-is.
|
|
1367
1334
|
*/
|
|
1368
|
-
declare function
|
|
1369
|
-
extensions: LoadedExtension[];
|
|
1370
|
-
errors: Array<{
|
|
1371
|
-
path: string;
|
|
1372
|
-
error: string;
|
|
1373
|
-
}>;
|
|
1374
|
-
}>;
|
|
1335
|
+
declare function reloadPhases(registry: PhaseRegistry): Promise<void>;
|
|
1375
1336
|
|
|
1376
|
-
type ExtensionRunnerRef = {
|
|
1377
|
-
current?: ExtensionRunner;
|
|
1378
|
-
};
|
|
1379
1337
|
type AgentOptions = {
|
|
1380
1338
|
context: AgentContext;
|
|
1381
1339
|
model: LlmModelRef;
|
|
1382
1340
|
stream: StreamFn;
|
|
1383
1341
|
cwd?: string;
|
|
1384
|
-
|
|
1385
|
-
phases?: PhaseRegistry;
|
|
1386
|
-
extensionRunnerRef?: ExtensionRunnerRef;
|
|
1342
|
+
extensions?: LoadedExtension[];
|
|
1387
1343
|
sessionId?: string;
|
|
1388
1344
|
maxAttempts?: number;
|
|
1389
1345
|
beforeToolCall?: BeforeToolCall;
|
|
@@ -1395,7 +1351,7 @@ type AgentOptions = {
|
|
|
1395
1351
|
model: LlmModelRef;
|
|
1396
1352
|
}) => Promise<void>;
|
|
1397
1353
|
};
|
|
1398
|
-
type RunOptions = Partial<
|
|
1354
|
+
type RunOptions = Partial<AgentOptions>;
|
|
1399
1355
|
type AgentStatus = {
|
|
1400
1356
|
sessionId?: string;
|
|
1401
1357
|
context: AgentContext;
|
|
@@ -1412,6 +1368,12 @@ declare class Agent {
|
|
|
1412
1368
|
private readonly pendingListenerTasks;
|
|
1413
1369
|
private readonly listenerErrors;
|
|
1414
1370
|
private activeRun?;
|
|
1371
|
+
private extensionRunner?;
|
|
1372
|
+
private loadedExtensions?;
|
|
1373
|
+
private loadedExtensionsCwd?;
|
|
1374
|
+
static loadSkills(targetPath: string): Promise<AgentContext["skills"]>;
|
|
1375
|
+
static loadPhases(targetPath: Parameters<typeof loadPhases>[0]): Promise<PhaseRegistry>;
|
|
1376
|
+
static loadExtensions(targetPath: string): Promise<LoadExtensionsResult>;
|
|
1415
1377
|
constructor(options: AgentOptions);
|
|
1416
1378
|
subscribe(listener: AgentEventListener): Unsubscribe;
|
|
1417
1379
|
private emitToListeners;
|
|
@@ -1443,16 +1405,9 @@ declare class Agent {
|
|
|
1443
1405
|
*/
|
|
1444
1406
|
private handleBeforePrompt;
|
|
1445
1407
|
private handleRunFailure;
|
|
1446
|
-
/**
|
|
1447
|
-
* Discover and load phases and skills from the workspace.
|
|
1448
|
-
*
|
|
1449
|
-
* - Auto-discovers file-based phases from .rowan/phases/
|
|
1450
|
-
* - Auto-discovers skills from .rowan/skills/
|
|
1451
|
-
* - Merges with CLI-provided phases and skills
|
|
1452
|
-
*/
|
|
1453
|
-
private discoverResources;
|
|
1454
1408
|
private runWithLifecycle;
|
|
1455
1409
|
private finishRun;
|
|
1410
|
+
private loadExtensions;
|
|
1456
1411
|
run(config?: RunOptions): Promise<RunResult>;
|
|
1457
1412
|
abort(reason?: string): void;
|
|
1458
1413
|
/**
|
|
@@ -1688,28 +1643,6 @@ type CoreToolContext = {
|
|
|
1688
1643
|
};
|
|
1689
1644
|
declare function createCoreTools(input?: CoreToolContext): Tool[];
|
|
1690
1645
|
|
|
1691
|
-
type RuntimeMode = "source" | "binary";
|
|
1692
|
-
type WorkspacePaths = {
|
|
1693
|
-
mode: RuntimeMode;
|
|
1694
|
-
cwd: string;
|
|
1695
|
-
rowanDir: string;
|
|
1696
|
-
};
|
|
1697
|
-
type ResolveWorkspaceOptions = {
|
|
1698
|
-
cwd?: string;
|
|
1699
|
-
env?: NodeJS.ProcessEnv;
|
|
1700
|
-
execPath?: string;
|
|
1701
|
-
entrypoint?: string;
|
|
1702
|
-
homeDir?: string;
|
|
1703
|
-
mode?: RuntimeMode;
|
|
1704
|
-
rowanDir?: string;
|
|
1705
|
-
};
|
|
1706
|
-
declare function resolveWorkspacePaths(options?: ResolveWorkspaceOptions): WorkspacePaths;
|
|
1707
|
-
declare function resolveInWorkspace(path: string, rootOrPaths: string | Pick<WorkspacePaths, "cwd">): string;
|
|
1708
|
-
|
|
1709
|
-
declare function resolveSkillPath(input: string, workspace?: WorkspacePaths): string;
|
|
1710
|
-
declare function loadSkill(path: string, workspace?: WorkspacePaths): Promise<Skill$1>;
|
|
1711
|
-
declare function loadSkills(workspace?: WorkspacePaths, paths?: string[]): Promise<Skill$1[]>;
|
|
1712
|
-
|
|
1713
1646
|
type ModelConfigFromFile = {
|
|
1714
1647
|
id: string;
|
|
1715
1648
|
name?: string;
|
|
@@ -1776,17 +1709,18 @@ declare class AgentEventStream extends EventStream<AgentEvent, AgentMessage[]> {
|
|
|
1776
1709
|
constructor();
|
|
1777
1710
|
}
|
|
1778
1711
|
|
|
1779
|
-
/**
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1712
|
+
/** Error thrown when the model returns an empty response (no text, no tool calls). */
|
|
1713
|
+
declare class EmptyResponseError extends Error {
|
|
1714
|
+
readonly code = "empty_response";
|
|
1715
|
+
constructor(message?: string);
|
|
1716
|
+
}
|
|
1717
|
+
/** Error thrown when a routed phase needs a route tool call but the model did not emit one. */
|
|
1718
|
+
declare class MissingRouteToolCallError extends Error {
|
|
1719
|
+
readonly code = "missing_route_tool_call";
|
|
1720
|
+
readonly phase: string;
|
|
1721
|
+
readonly toolCallNames: string[];
|
|
1722
|
+
constructor(phase: string, toolCallNames: string[]);
|
|
1723
|
+
}
|
|
1790
1724
|
|
|
1791
1725
|
interface SystemPromptOptions {
|
|
1792
1726
|
/** Base system prompt. */
|
|
@@ -1841,4 +1775,4 @@ declare function buildModelRequest(input: ModelRequestInput, options?: {
|
|
|
1841
1775
|
model?: LlmModelRef;
|
|
1842
1776
|
}): LlmRequest;
|
|
1843
1777
|
|
|
1844
|
-
export { type AbortEvent, type AfterPhaseEvent, type AfterPhaseHookResult, type AfterPhaseResult, type AfterToolCallEvent, type AfterToolCallResult, Agent, type AgentConfigFile, type AgentContext, type AgentEndEvent, AgentEventStream, type AgentOptions, type AgentStartEvent, type AgentStatus, type BeforePhaseEvent, type BeforePhaseHookResult, type BeforePhaseResult, type BeforePromptEvent, type BeforePromptResult, type BeforeToolCallEvent, type BeforeToolCallResult, type EventBus, EventStream, type ExecOptions, type ExecResult, type ExecutionTurn, type Extension, type ExtensionAPI, type ExtensionContext, type ExtensionError, type ExtensionErrorListener, type ExtensionFactory, type ExtensionManifest, type ExtensionPackageManifest, ExtensionRunner, type ExtensionRunnerOptions, type
|
|
1778
|
+
export { type AbortEvent, type AfterPhaseEvent, type AfterPhaseHookResult, type AfterPhaseResult, type AfterToolCallEvent, type AfterToolCallResult, Agent, type AgentConfigFile, type AgentContext, type AgentEndEvent, AgentEventStream, type AgentOptions, type AgentStartEvent, type AgentStatus, type BeforePhaseEvent, type BeforePhaseHookResult, type BeforePhaseResult, type BeforePromptEvent, type BeforePromptResult, type BeforeToolCallEvent, type BeforeToolCallResult, EmptyResponseError, type EventBus, EventStream, type ExecOptions, type ExecResult, type ExecutionTurn, type Extension, type ExtensionAPI, type ExtensionContext, type ExtensionError, type ExtensionErrorListener, type ExtensionFactory, type ExtensionManifest, type ExtensionPackageManifest, ExtensionRunner, type ExtensionRunnerOptions, type ExtensionRuntime, type ExtensionUtils, HookError, type HookEvent, type HookEventType, type HookHandler, type HookResultMap, HooksManager, type LoadExtensionsResult, type LoadedExtension, LocalJsonlSessionManager, type LoopMetrics, type MessageEndEvent, type MessageStartEvent, type MessageUpdateEvent, MissingRouteToolCallError, type ModelConfigFromFile, type ModelTranscript, type Phase, type PhaseContext, type PhaseDefinition, type PhaseExecution, type PhaseOutput, type PhaseRegistration, type PhaseRegistry, type PhaseRun, type PhaseState, type ProviderConfigFromFile, type QueueUpdateEvent, type RegisteredPhase, type RegisteredTool, type RunOptions, type RunResult, type SavePointEvent, type Session, type SessionListItem, type SettledEvent, type SourceInfo, type Tool, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionResult, type ToolExecutionStartEvent, type ToolExecutionUpdateEvent, type TurnEndEvent, type TurnStartEvent, type WorkspacePaths, appendUserTurn, buildModelRequest, buildSystemPrompt, conversationMessages, createCoreTools, createEventBus, createExtension, createExtensionAPI, createExtensionRunner, createExtensionRuntime, createId, createMessage, createSession, createSourceInfo, createTimestamp, getGlobalHooks, interpolateEnvVars, latestUserInput, loadConfigFile, loadPhase, loadPhases, messageContentText, parseModelRef, registerConfigModels, reloadPhases, resetGlobalHooks, resolveDefaultModel, resolveInWorkspace, resolveWorkspacePaths, serializeSkills };
|