@dougbots/avenor-core 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +46 -32
- package/dist/index.js +99 -47
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,14 +24,16 @@ interface HistoryResult<TEvent = Event> {
|
|
|
24
24
|
events: TEvent[];
|
|
25
25
|
latest_seq?: number;
|
|
26
26
|
}
|
|
27
|
+
type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
27
28
|
interface SpawnParams {
|
|
28
|
-
agent
|
|
29
|
+
agent?: string;
|
|
29
30
|
prompt_file?: string;
|
|
30
31
|
prompt?: string;
|
|
31
32
|
dir?: string;
|
|
32
33
|
label?: string;
|
|
33
34
|
timeout?: number;
|
|
34
35
|
model?: string;
|
|
36
|
+
thinking?: ThinkingLevel;
|
|
35
37
|
agent_profile?: string;
|
|
36
38
|
backend?: string;
|
|
37
39
|
server_url?: string;
|
|
@@ -44,6 +46,7 @@ interface SpawnParams {
|
|
|
44
46
|
declare class Client {
|
|
45
47
|
private socket;
|
|
46
48
|
private rl;
|
|
49
|
+
private closed;
|
|
47
50
|
private nextID;
|
|
48
51
|
private pending;
|
|
49
52
|
private started;
|
|
@@ -72,6 +75,7 @@ declare class Client {
|
|
|
72
75
|
prompt(runtimeId: string, text: string): Promise<void>;
|
|
73
76
|
interruptAndPrompt(runtimeId: string, text: string, keepQueue?: boolean): Promise<void>;
|
|
74
77
|
cancel(runtimeId?: string): Promise<void>;
|
|
78
|
+
isClosed(): boolean;
|
|
75
79
|
close(): void;
|
|
76
80
|
}
|
|
77
81
|
declare function dial(socketPath: string, opts?: {
|
|
@@ -241,6 +245,7 @@ interface RunInfo {
|
|
|
241
245
|
agentProfile?: string;
|
|
242
246
|
backend?: string;
|
|
243
247
|
model?: string;
|
|
248
|
+
thinking?: ThinkingLevel;
|
|
244
249
|
dir?: string;
|
|
245
250
|
brokerUrl?: string;
|
|
246
251
|
parentToken?: string;
|
|
@@ -253,6 +258,7 @@ interface SupervisorOptions {
|
|
|
253
258
|
declare function findAvenorBinary(): string;
|
|
254
259
|
declare class Supervisor {
|
|
255
260
|
private static instance;
|
|
261
|
+
private static starting;
|
|
256
262
|
private static cleanupRegistered;
|
|
257
263
|
private static registerCleanup;
|
|
258
264
|
private client;
|
|
@@ -265,6 +271,7 @@ declare class Supervisor {
|
|
|
265
271
|
private callTimeoutMs;
|
|
266
272
|
private constructor();
|
|
267
273
|
static get(opts?: SupervisorOptions): Promise<Supervisor>;
|
|
274
|
+
private static start;
|
|
268
275
|
private startProcess;
|
|
269
276
|
get supervisorId(): string;
|
|
270
277
|
static isCurrentInstance(supervisorId: string): boolean;
|
|
@@ -281,13 +288,14 @@ declare function socketsRoot(): string;
|
|
|
281
288
|
//#endregion
|
|
282
289
|
//#region src/tools/spawn.d.ts
|
|
283
290
|
declare function spawnTool(args: {
|
|
284
|
-
agent
|
|
291
|
+
agent?: string;
|
|
285
292
|
prompt?: string;
|
|
286
293
|
promptFile?: string;
|
|
287
294
|
label?: string;
|
|
288
295
|
dir?: string;
|
|
289
296
|
timeout?: string;
|
|
290
297
|
model?: string;
|
|
298
|
+
thinking?: ThinkingLevel;
|
|
291
299
|
agentProfile?: string;
|
|
292
300
|
backend?: string;
|
|
293
301
|
serverUrl?: string;
|
|
@@ -305,6 +313,11 @@ declare function spawnTool(args: {
|
|
|
305
313
|
//#endregion
|
|
306
314
|
//#region src/tools/status.d.ts
|
|
307
315
|
type StatusView = 'lifecycle' | 'full';
|
|
316
|
+
interface StatusToolArgs {
|
|
317
|
+
runId?: string;
|
|
318
|
+
supervisorId?: string;
|
|
319
|
+
view?: StatusView;
|
|
320
|
+
}
|
|
308
321
|
interface StatusResult {
|
|
309
322
|
run_id: string;
|
|
310
323
|
label: string;
|
|
@@ -337,13 +350,33 @@ interface StatusResult {
|
|
|
337
350
|
final_output?: string;
|
|
338
351
|
final_output_truncated?: boolean;
|
|
339
352
|
}
|
|
340
|
-
declare
|
|
341
|
-
|
|
353
|
+
declare const statusTool: (args: StatusToolArgs) => Promise<StatusResult | StatusResult[]>;
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/tools/events.d.ts
|
|
356
|
+
interface EventsToolArgs {
|
|
357
|
+
runId: string;
|
|
358
|
+
types?: string[];
|
|
359
|
+
limit?: number;
|
|
342
360
|
supervisorId?: string;
|
|
343
|
-
|
|
344
|
-
}
|
|
361
|
+
after_seq?: number;
|
|
362
|
+
}
|
|
363
|
+
interface EventsToolResult {
|
|
364
|
+
events: Array<{
|
|
365
|
+
event?: string;
|
|
366
|
+
type?: string;
|
|
367
|
+
ts?: number;
|
|
368
|
+
[key: string]: unknown;
|
|
369
|
+
}>;
|
|
370
|
+
}
|
|
371
|
+
declare const eventsTool: (args: EventsToolArgs) => Promise<EventsToolResult>;
|
|
345
372
|
//#endregion
|
|
346
373
|
//#region src/tools/inspect.d.ts
|
|
374
|
+
interface InspectToolArgs {
|
|
375
|
+
runId: string;
|
|
376
|
+
supervisorId?: string;
|
|
377
|
+
limit?: number;
|
|
378
|
+
after_seq?: number;
|
|
379
|
+
}
|
|
347
380
|
interface InspectResult {
|
|
348
381
|
run_id: string;
|
|
349
382
|
label: string;
|
|
@@ -356,12 +389,7 @@ interface InspectResult {
|
|
|
356
389
|
pending_permission?: RunSnapshot['pending_permission'];
|
|
357
390
|
final_output?: string;
|
|
358
391
|
}
|
|
359
|
-
declare
|
|
360
|
-
runId: string;
|
|
361
|
-
supervisorId?: string;
|
|
362
|
-
limit?: number;
|
|
363
|
-
after_seq?: number;
|
|
364
|
-
}): Promise<InspectResult>;
|
|
392
|
+
declare const inspectTool: (args: InspectToolArgs) => Promise<InspectResult>;
|
|
365
393
|
//#endregion
|
|
366
394
|
//#region src/tools/result.d.ts
|
|
367
395
|
interface ResultResult {
|
|
@@ -399,31 +427,17 @@ declare function answerPermissionTool(args: {
|
|
|
399
427
|
}>;
|
|
400
428
|
//#endregion
|
|
401
429
|
//#region src/tools/follow-up.d.ts
|
|
402
|
-
|
|
430
|
+
interface FollowUpToolArgs {
|
|
403
431
|
runId: string;
|
|
404
432
|
message: string;
|
|
405
433
|
label?: string;
|
|
406
434
|
supervisorId?: string;
|
|
407
|
-
}
|
|
435
|
+
}
|
|
436
|
+
interface FollowUpToolResult {
|
|
408
437
|
run_id: string;
|
|
409
438
|
label: string;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
//#region src/tools/events.d.ts
|
|
413
|
-
declare function eventsTool(args: {
|
|
414
|
-
runId: string;
|
|
415
|
-
types?: string[];
|
|
416
|
-
limit?: number;
|
|
417
|
-
supervisorId?: string;
|
|
418
|
-
after_seq?: number;
|
|
419
|
-
}): Promise<{
|
|
420
|
-
events: Array<{
|
|
421
|
-
event?: string;
|
|
422
|
-
type?: string;
|
|
423
|
-
ts?: number;
|
|
424
|
-
[key: string]: unknown;
|
|
425
|
-
}>;
|
|
426
|
-
}>;
|
|
439
|
+
}
|
|
440
|
+
declare const followUpTool: (args: FollowUpToolArgs) => Promise<FollowUpToolResult>;
|
|
427
441
|
//#endregion
|
|
428
442
|
//#region src/tools/shutdown.d.ts
|
|
429
443
|
declare function shutdownTool(args: {
|
|
@@ -434,4 +448,4 @@ declare function shutdownTool(args: {
|
|
|
434
448
|
cleaned_up: string[];
|
|
435
449
|
}>;
|
|
436
450
|
//#endregion
|
|
437
|
-
export { type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type HistoryOptions, type HistoryResult, type InspectResult, type NormalizedRunEvent, type ObserveRunOptions, type ResultResult, type ResultToolArgs, type RunChunkRole, type RunIdentity, type RunInfo, type RunObserver, type RunObserverClient, type RunPermissionOption, type RunPermissionSummary, RunReducer, type RunReducerLimits, type RunSnapshot, type RunSnapshotSeed, type RunToolState, type RunToolSummary, type RunTranscriptEntry, type SpawnParams, type StatusResult, type StatusView, type SubscribeOptions, Supervisor, type SupervisorOptions, answerPermissionTool, createRunSnapshot, dial, eventsTool, extractEventText, findAvenorBinary, followUpTool, getInstallDir, getVersion, inspectTool, installerBinaryPath, normalizeRunEvent, observeRun, reduceRunSnapshot, resultTool, shutdownTool, socketsRoot, spawnTool, statusTool };
|
|
451
|
+
export { type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type HistoryOptions, type HistoryResult, type InspectResult, type NormalizedRunEvent, type ObserveRunOptions, type ResultResult, type ResultToolArgs, type RunChunkRole, type RunIdentity, type RunInfo, type RunObserver, type RunObserverClient, type RunPermissionOption, type RunPermissionSummary, RunReducer, type RunReducerLimits, type RunSnapshot, type RunSnapshotSeed, type RunToolState, type RunToolSummary, type RunTranscriptEntry, type SpawnParams, type StatusResult, type StatusView, type SubscribeOptions, Supervisor, type SupervisorOptions, type ThinkingLevel, answerPermissionTool, createRunSnapshot, dial, eventsTool, extractEventText, findAvenorBinary, followUpTool, getInstallDir, getVersion, inspectTool, installerBinaryPath, normalizeRunEvent, observeRun, reduceRunSnapshot, resultTool, shutdownTool, socketsRoot, spawnTool, statusTool };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function removeResolver(resolvers, target) {
|
|
|
26
26
|
var Client = class {
|
|
27
27
|
socket;
|
|
28
28
|
rl;
|
|
29
|
+
closed = false;
|
|
29
30
|
nextID = 0;
|
|
30
31
|
pending = /* @__PURE__ */ new Map();
|
|
31
32
|
started = false;
|
|
@@ -44,11 +45,15 @@ var Client = class {
|
|
|
44
45
|
});
|
|
45
46
|
this.callTimeout = opts?.callTimeoutMs ?? 3e4;
|
|
46
47
|
this.socket.on("error", (err) => {
|
|
48
|
+
this.closed = true;
|
|
47
49
|
this.pushEvent({
|
|
48
50
|
event: "protocol-error",
|
|
49
51
|
message: err.message
|
|
50
52
|
});
|
|
51
53
|
});
|
|
54
|
+
this.socket.on("close", () => {
|
|
55
|
+
this.closed = true;
|
|
56
|
+
});
|
|
52
57
|
}
|
|
53
58
|
startReadLoop() {
|
|
54
59
|
if (this.started) return;
|
|
@@ -85,6 +90,7 @@ var Client = class {
|
|
|
85
90
|
}
|
|
86
91
|
});
|
|
87
92
|
this.rl.on("close", () => {
|
|
93
|
+
this.closed = true;
|
|
88
94
|
for (const [, pc] of this.pending) {
|
|
89
95
|
clearTimeout(pc.timer);
|
|
90
96
|
pc.reject(/* @__PURE__ */ new Error("read response: connection closed"));
|
|
@@ -116,6 +122,7 @@ var Client = class {
|
|
|
116
122
|
else this.dropped++;
|
|
117
123
|
}
|
|
118
124
|
async call(method, params) {
|
|
125
|
+
if (this.isClosed()) throw new Error("control socket is closed");
|
|
119
126
|
this.startReadLoop();
|
|
120
127
|
const id = ++this.nextID;
|
|
121
128
|
const req = {
|
|
@@ -137,6 +144,7 @@ var Client = class {
|
|
|
137
144
|
});
|
|
138
145
|
this.socket.write(data, (err) => {
|
|
139
146
|
if (err) {
|
|
147
|
+
this.closed = true;
|
|
140
148
|
clearTimeout(timer);
|
|
141
149
|
this.pending.delete(id);
|
|
142
150
|
reject(/* @__PURE__ */ new Error(`write request: ${err.message}`));
|
|
@@ -272,7 +280,11 @@ var Client = class {
|
|
|
272
280
|
const params = runtimeId ? { runtime_id: runtimeId } : void 0;
|
|
273
281
|
await this.call("cancel", params);
|
|
274
282
|
}
|
|
283
|
+
isClosed() {
|
|
284
|
+
return this.closed || this.socket.destroyed || this.socket.writableEnded;
|
|
285
|
+
}
|
|
275
286
|
close() {
|
|
287
|
+
this.closed = true;
|
|
276
288
|
this.rl.close();
|
|
277
289
|
this.socket.destroy();
|
|
278
290
|
}
|
|
@@ -1118,6 +1130,7 @@ function findAvenorBinary() {
|
|
|
1118
1130
|
}
|
|
1119
1131
|
var Supervisor = class Supervisor {
|
|
1120
1132
|
static instance = null;
|
|
1133
|
+
static starting = null;
|
|
1121
1134
|
static cleanupRegistered = false;
|
|
1122
1135
|
static registerCleanup() {
|
|
1123
1136
|
if (Supervisor.cleanupRegistered) return;
|
|
@@ -1148,8 +1161,25 @@ var Supervisor = class Supervisor {
|
|
|
1148
1161
|
this.socketPath = socketPath;
|
|
1149
1162
|
this.callTimeoutMs = opts?.callTimeoutMs ?? 3e4;
|
|
1150
1163
|
}
|
|
1151
|
-
static
|
|
1152
|
-
|
|
1164
|
+
static get(opts) {
|
|
1165
|
+
const current = Supervisor.instance;
|
|
1166
|
+
if (current && !current.crashed) {
|
|
1167
|
+
if (current.client && !current.client.isClosed()) return Promise.resolve(current);
|
|
1168
|
+
current.crashed = true;
|
|
1169
|
+
current.crashCode = 0;
|
|
1170
|
+
current.client?.close();
|
|
1171
|
+
current.client = null;
|
|
1172
|
+
}
|
|
1173
|
+
if (Supervisor.starting) return Supervisor.starting;
|
|
1174
|
+
const starting = Supervisor.start(opts);
|
|
1175
|
+
Supervisor.starting = starting;
|
|
1176
|
+
const clearStarting = () => {
|
|
1177
|
+
if (Supervisor.starting === starting) Supervisor.starting = null;
|
|
1178
|
+
};
|
|
1179
|
+
starting.then(clearStarting, clearStarting);
|
|
1180
|
+
return starting;
|
|
1181
|
+
}
|
|
1182
|
+
static async start(opts) {
|
|
1153
1183
|
Supervisor.registerCleanup();
|
|
1154
1184
|
const binaryPath = opts?.binaryPath ?? findAvenorBinary();
|
|
1155
1185
|
const socketDir = socketsRoot();
|
|
@@ -1205,15 +1235,13 @@ var Supervisor = class Supervisor {
|
|
|
1205
1235
|
reject(/* @__PURE__ */ new Error(`avenor exited with code ${code}${signal ? " signal " + signal : ""} during startup`));
|
|
1206
1236
|
return;
|
|
1207
1237
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
this.client = null;
|
|
1216
|
-
}
|
|
1238
|
+
this.crashed = true;
|
|
1239
|
+
this.crashCode = code ?? -1;
|
|
1240
|
+
if (this.client) {
|
|
1241
|
+
try {
|
|
1242
|
+
this.client.close();
|
|
1243
|
+
} catch {}
|
|
1244
|
+
this.client = null;
|
|
1217
1245
|
}
|
|
1218
1246
|
});
|
|
1219
1247
|
this.childProcess.on("error", (err) => {
|
|
@@ -1251,8 +1279,17 @@ var Supervisor = class Supervisor {
|
|
|
1251
1279
|
return Supervisor.instance;
|
|
1252
1280
|
}
|
|
1253
1281
|
getClient() {
|
|
1254
|
-
if (this.crashed)
|
|
1282
|
+
if (this.crashed) {
|
|
1283
|
+
const state = this.crashCode === 0 ? "exited" : "crashed";
|
|
1284
|
+
throw new Error(`avenor supervisor ${state} (exit code ${this.crashCode}). Call avenor_shutdown to clean up and retry.`);
|
|
1285
|
+
}
|
|
1255
1286
|
if (!this.client) throw new Error("supervisor not started");
|
|
1287
|
+
if (this.client.isClosed()) {
|
|
1288
|
+
this.crashed = true;
|
|
1289
|
+
this.crashCode = 0;
|
|
1290
|
+
this.client = null;
|
|
1291
|
+
throw new Error("avenor supervisor connection closed");
|
|
1292
|
+
}
|
|
1256
1293
|
return this.client;
|
|
1257
1294
|
}
|
|
1258
1295
|
async spawn(params, runId = crypto.randomUUID()) {
|
|
@@ -1276,6 +1313,7 @@ var Supervisor = class Supervisor {
|
|
|
1276
1313
|
agentProfile: spawnParams.agent_profile,
|
|
1277
1314
|
backend: spawnParams.backend,
|
|
1278
1315
|
model: spawnParams.model,
|
|
1316
|
+
thinking: spawnParams.thinking,
|
|
1279
1317
|
dir: spawnParams.dir,
|
|
1280
1318
|
brokerUrl: result.broker_url,
|
|
1281
1319
|
parentToken: result.parent_token,
|
|
@@ -1354,25 +1392,29 @@ async function getSupervisorClient(supervisorId) {
|
|
|
1354
1392
|
async function spawnTool(args) {
|
|
1355
1393
|
const runId = crypto.randomUUID();
|
|
1356
1394
|
const label = args.label ?? runId;
|
|
1395
|
+
const baseParams = {
|
|
1396
|
+
prompt: args.prompt,
|
|
1397
|
+
prompt_file: args.promptFile,
|
|
1398
|
+
label,
|
|
1399
|
+
dir: args.dir,
|
|
1400
|
+
timeout: args.timeout !== void 0 ? validateTimeout(args.timeout) : void 0,
|
|
1401
|
+
model: args.model,
|
|
1402
|
+
agent_profile: args.agentProfile,
|
|
1403
|
+
backend: args.backend,
|
|
1404
|
+
server_url: args.serverUrl,
|
|
1405
|
+
session_id: args.sessionId,
|
|
1406
|
+
parent_run_id: args.parent_run_id
|
|
1407
|
+
};
|
|
1408
|
+
if (args.agent) baseParams.agent = args.agent;
|
|
1409
|
+
if (args.thinking !== void 0) baseParams.thinking = args.thinking;
|
|
1357
1410
|
if (args.supervisorId) {
|
|
1358
1411
|
const { client, isSingleton, supervisorId } = await getSupervisorClient(args.supervisorId);
|
|
1359
1412
|
const { sentinelPath, eventLogPath } = ensureRunPaths(runId);
|
|
1360
1413
|
try {
|
|
1361
1414
|
const result = await client.spawn({
|
|
1362
|
-
|
|
1363
|
-
prompt: args.prompt,
|
|
1364
|
-
prompt_file: args.promptFile,
|
|
1365
|
-
label,
|
|
1366
|
-
dir: args.dir,
|
|
1367
|
-
timeout: args.timeout !== void 0 ? validateTimeout(args.timeout) : void 0,
|
|
1368
|
-
model: args.model,
|
|
1369
|
-
agent_profile: args.agentProfile,
|
|
1370
|
-
backend: args.backend,
|
|
1371
|
-
server_url: args.serverUrl,
|
|
1372
|
-
session_id: args.sessionId,
|
|
1415
|
+
...baseParams,
|
|
1373
1416
|
sentinel_file: sentinelPath,
|
|
1374
|
-
on_event: eventLogPath
|
|
1375
|
-
parent_run_id: args.parent_run_id
|
|
1417
|
+
on_event: eventLogPath
|
|
1376
1418
|
});
|
|
1377
1419
|
return {
|
|
1378
1420
|
run_id: result.runtime_id ?? runId,
|
|
@@ -1387,20 +1429,7 @@ async function spawnTool(args) {
|
|
|
1387
1429
|
}
|
|
1388
1430
|
}
|
|
1389
1431
|
const sup = await Supervisor.get();
|
|
1390
|
-
const runInfo = await sup.spawn(
|
|
1391
|
-
agent: args.agent,
|
|
1392
|
-
prompt: args.prompt,
|
|
1393
|
-
prompt_file: args.promptFile,
|
|
1394
|
-
label,
|
|
1395
|
-
dir: args.dir,
|
|
1396
|
-
timeout: args.timeout !== void 0 ? validateTimeout(args.timeout) : void 0,
|
|
1397
|
-
model: args.model,
|
|
1398
|
-
agent_profile: args.agentProfile,
|
|
1399
|
-
backend: args.backend,
|
|
1400
|
-
server_url: args.serverUrl,
|
|
1401
|
-
session_id: args.sessionId,
|
|
1402
|
-
parent_run_id: args.parent_run_id
|
|
1403
|
-
}, runId);
|
|
1432
|
+
const runInfo = await sup.spawn(baseParams, runId);
|
|
1404
1433
|
return {
|
|
1405
1434
|
run_id: runInfo.runId,
|
|
1406
1435
|
label: runInfo.label,
|
|
@@ -1564,7 +1593,7 @@ async function queryLiveStatus(client, runtimeId) {
|
|
|
1564
1593
|
return null;
|
|
1565
1594
|
}
|
|
1566
1595
|
}
|
|
1567
|
-
async function
|
|
1596
|
+
async function executeStatusTool(args, getSupervisorClient) {
|
|
1568
1597
|
if (args.supervisorId) {
|
|
1569
1598
|
const { client, isSingleton, sup } = await getSupervisorClient(args.supervisorId);
|
|
1570
1599
|
try {
|
|
@@ -1638,6 +1667,10 @@ async function statusTool(args) {
|
|
|
1638
1667
|
}
|
|
1639
1668
|
return results;
|
|
1640
1669
|
}
|
|
1670
|
+
function createStatusTool(getSupervisorClient) {
|
|
1671
|
+
return (args) => executeStatusTool(args, getSupervisorClient);
|
|
1672
|
+
}
|
|
1673
|
+
const statusTool = createStatusTool(getSupervisorClient);
|
|
1641
1674
|
//#endregion
|
|
1642
1675
|
//#region src/tools/events.ts
|
|
1643
1676
|
const MAX_EVENT_LIMIT = 1e3;
|
|
@@ -1717,7 +1750,7 @@ async function readNdjsonEvents(filePath, args) {
|
|
|
1717
1750
|
}
|
|
1718
1751
|
return events;
|
|
1719
1752
|
}
|
|
1720
|
-
async function resolveRun(args) {
|
|
1753
|
+
async function resolveRun(args, getSupervisorClient) {
|
|
1721
1754
|
if (args.supervisorId) {
|
|
1722
1755
|
const { client, isSingleton, sup } = await getSupervisorClient(args.supervisorId);
|
|
1723
1756
|
const runInfo = isSingleton && sup ? findRunByLabel$2(sup, args.runId) : void 0;
|
|
@@ -1788,9 +1821,9 @@ async function resolveRun(args) {
|
|
|
1788
1821
|
eventLogPath
|
|
1789
1822
|
};
|
|
1790
1823
|
}
|
|
1791
|
-
async function
|
|
1824
|
+
async function executeEventsTool(args, getSupervisorClient) {
|
|
1792
1825
|
const limit = normalizeLimit(args.limit);
|
|
1793
|
-
const resolved = await resolveRun(args);
|
|
1826
|
+
const resolved = await resolveRun(args, getSupervisorClient);
|
|
1794
1827
|
try {
|
|
1795
1828
|
const failures = [];
|
|
1796
1829
|
if (resolved.eventLogPath) try {
|
|
@@ -1818,21 +1851,25 @@ async function eventsTool(args) {
|
|
|
1818
1851
|
if (!resolved.isSingleton) resolved.client.close();
|
|
1819
1852
|
}
|
|
1820
1853
|
}
|
|
1854
|
+
function createEventsTool(getSupervisorClient) {
|
|
1855
|
+
return (args) => executeEventsTool(args, getSupervisorClient);
|
|
1856
|
+
}
|
|
1857
|
+
const eventsTool = createEventsTool(getSupervisorClient);
|
|
1821
1858
|
//#endregion
|
|
1822
1859
|
//#region src/tools/inspect.ts
|
|
1823
1860
|
function publicSnapshot(snapshot) {
|
|
1824
1861
|
const { _seen_seq_by_scope: _seen, _recent_legacy_keys: _recent, _last_semantic_fingerprint: _fingerprint, _last_source_event: _source, ...rest } = snapshot;
|
|
1825
1862
|
return rest;
|
|
1826
1863
|
}
|
|
1827
|
-
async function
|
|
1828
|
-
const rawStatus = await
|
|
1864
|
+
async function executeInspectTool(args, deps) {
|
|
1865
|
+
const rawStatus = await deps.status({
|
|
1829
1866
|
runId: args.runId,
|
|
1830
1867
|
supervisorId: args.supervisorId
|
|
1831
1868
|
});
|
|
1832
1869
|
const status = Array.isArray(rawStatus) ? rawStatus[0] : rawStatus;
|
|
1833
1870
|
if (!status) throw new Error(`run not found: ${args.runId}`);
|
|
1834
1871
|
const reducer = new RunReducer();
|
|
1835
|
-
const { events } = await
|
|
1872
|
+
const { events } = await deps.events({
|
|
1836
1873
|
runId: args.runId,
|
|
1837
1874
|
supervisorId: args.supervisorId,
|
|
1838
1875
|
limit: args.limit,
|
|
@@ -1875,6 +1912,13 @@ async function inspectTool(args) {
|
|
|
1875
1912
|
final_output: clean.final_output
|
|
1876
1913
|
};
|
|
1877
1914
|
}
|
|
1915
|
+
function createInspectTool(deps) {
|
|
1916
|
+
return (args) => executeInspectTool(args, deps);
|
|
1917
|
+
}
|
|
1918
|
+
const inspectTool = createInspectTool({
|
|
1919
|
+
status: statusTool,
|
|
1920
|
+
events: eventsTool
|
|
1921
|
+
});
|
|
1878
1922
|
//#endregion
|
|
1879
1923
|
//#region src/tools/result.ts
|
|
1880
1924
|
const DEFAULT_POLL_INTERVAL_MS = 1e3;
|
|
@@ -2057,7 +2101,7 @@ async function parseSentinel(filePath) {
|
|
|
2057
2101
|
return null;
|
|
2058
2102
|
}
|
|
2059
2103
|
}
|
|
2060
|
-
async function
|
|
2104
|
+
async function executeFollowUpTool(args, getSupervisorClient) {
|
|
2061
2105
|
if (args.supervisorId) {
|
|
2062
2106
|
const { client, isSingleton, sup } = await getSupervisorClient(args.supervisorId);
|
|
2063
2107
|
try {
|
|
@@ -2074,6 +2118,7 @@ async function followUpTool(args) {
|
|
|
2074
2118
|
const agent = requireResumableAgent(liveStatus?.agent ?? runInfo?.agent);
|
|
2075
2119
|
const backend = liveStatus?.backend ?? runInfo?.backend;
|
|
2076
2120
|
const model = liveStatus?.model ?? runInfo?.model;
|
|
2121
|
+
const thinking = liveStatus?.thinking ?? runInfo?.thinking;
|
|
2077
2122
|
const dir = liveStatus?.dir ?? runInfo?.dir;
|
|
2078
2123
|
const agentProfile = liveStatus?.agent_profile ?? runInfo?.agentProfile;
|
|
2079
2124
|
const autoApprove = resolveAutoApprove(liveStatus, runInfo);
|
|
@@ -2090,6 +2135,7 @@ async function followUpTool(args) {
|
|
|
2090
2135
|
};
|
|
2091
2136
|
if (backend) spawnParams.backend = backend;
|
|
2092
2137
|
if (model) spawnParams.model = model;
|
|
2138
|
+
if (thinking) spawnParams.thinking = thinking;
|
|
2093
2139
|
if (dir) spawnParams.dir = dir;
|
|
2094
2140
|
if (agentProfile) spawnParams.agent_profile = agentProfile;
|
|
2095
2141
|
if (autoApprove === true) spawnParams.auto_approve = true;
|
|
@@ -2114,6 +2160,7 @@ async function followUpTool(args) {
|
|
|
2114
2160
|
const agent = requireResumableAgent(liveStatus?.agent ?? runInfo.agent);
|
|
2115
2161
|
const backend = liveStatus?.backend ?? runInfo.backend;
|
|
2116
2162
|
const model = liveStatus?.model ?? runInfo.model;
|
|
2163
|
+
const thinking = liveStatus?.thinking ?? runInfo.thinking;
|
|
2117
2164
|
const dir = liveStatus?.dir ?? runInfo.dir;
|
|
2118
2165
|
const agentProfile = liveStatus?.agent_profile ?? runInfo.agentProfile;
|
|
2119
2166
|
const autoApprove = resolveAutoApprove(liveStatus, runInfo);
|
|
@@ -2122,6 +2169,7 @@ async function followUpTool(args) {
|
|
|
2122
2169
|
agent,
|
|
2123
2170
|
backend,
|
|
2124
2171
|
model,
|
|
2172
|
+
thinking,
|
|
2125
2173
|
dir,
|
|
2126
2174
|
agent_profile: agentProfile,
|
|
2127
2175
|
prompt: args.message,
|
|
@@ -2134,6 +2182,10 @@ async function followUpTool(args) {
|
|
|
2134
2182
|
label: followUpRun.label
|
|
2135
2183
|
};
|
|
2136
2184
|
}
|
|
2185
|
+
function createFollowUpTool(getSupervisorClient) {
|
|
2186
|
+
return (args) => executeFollowUpTool(args, getSupervisorClient);
|
|
2187
|
+
}
|
|
2188
|
+
const followUpTool = createFollowUpTool(getSupervisorClient);
|
|
2137
2189
|
//#endregion
|
|
2138
2190
|
//#region src/tools/shutdown.ts
|
|
2139
2191
|
async function shutdownTool(args) {
|