@clemrig/flow 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/app/run.js +5 -1
- package/dist/app/run.js.map +1 -1
- package/dist/app/runs.d.ts +1 -1
- package/dist/app/runs.js +4 -5
- package/dist/app/runs.js.map +1 -1
- package/dist/engine/metrics.d.ts +17 -10
- package/dist/engine/metrics.js +29 -15
- package/dist/engine/metrics.js.map +1 -1
- package/dist/engine/profiles.d.ts +44 -11
- package/dist/engine/profiles.js +78 -78
- package/dist/engine/profiles.js.map +1 -1
- package/dist/engine/types.d.ts +10 -1
- package/dist/engine/workflow.d.ts +8 -3
- package/dist/engine/workflow.js +58 -3
- package/dist/engine/workflow.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/system/process.d.ts +28 -6
- package/dist/system/process.js +24 -5
- package/dist/system/process.js.map +1 -1
- package/dist/system/runtimes/adapter.d.ts +21 -11
- package/dist/system/runtimes/adapter.js.map +1 -1
- package/dist/system/runtimes/agent-runtime.d.ts +3 -1
- package/dist/system/runtimes/agent-runtime.js +76 -87
- package/dist/system/runtimes/agent-runtime.js.map +1 -1
- package/dist/system/runtimes/claude-code.d.ts +5 -4
- package/dist/system/runtimes/claude-code.js +39 -84
- package/dist/system/runtimes/claude-code.js.map +1 -1
- package/dist/system/runtimes/codex.d.ts +11 -0
- package/dist/system/runtimes/codex.js +253 -0
- package/dist/system/runtimes/codex.js.map +1 -0
- package/dist/system/runtimes/inspect.js +7 -5
- package/dist/system/runtimes/inspect.js.map +1 -1
- package/dist/system/runtimes/pi.d.ts +3 -1
- package/dist/system/runtimes/pi.js +22 -10
- package/dist/system/runtimes/pi.js.map +1 -1
- package/dist/system/runtimes/registry.d.ts +3 -2
- package/dist/system/runtimes/registry.js +6 -1
- package/dist/system/runtimes/registry.js.map +1 -1
- package/dist/system/store.js +6 -2
- package/dist/system/store.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type { RunState, Workflow, WorkflowDefinition } from "./types.js";
|
|
1
|
+
import type { AgentStage, RunState, Workflow, WorkflowDefinition } from "./types.js";
|
|
2
2
|
/** True for a workflow returned by `defineWorkflow`. */
|
|
3
3
|
export declare function isWorkflow(value: unknown): value is Workflow;
|
|
4
|
+
/**
|
|
5
|
+
* Why a budget cannot apply to these agent stages: some run on a runtime that
|
|
6
|
+
* announces no cost, so the budget could never be checked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function budgetRefusal(agents: Record<string, Pick<AgentStage, "profile">>): string | undefined;
|
|
4
9
|
/** By default a run shows its validated data, never raw agent output. */
|
|
5
10
|
export declare function presentData(state: Readonly<RunState>): string[];
|
|
6
11
|
/**
|
|
7
|
-
* Validates a workflow when it is declared: graph, retry maximums, loops,
|
|
8
|
-
* stages and inputs. Agent profiles are returned with their defaults applied.
|
|
12
|
+
* Validates a workflow when it is declared: graph, retry maximums, loops, steps,
|
|
13
|
+
* agent stages and inputs. Agent profiles are returned with their defaults applied.
|
|
9
14
|
*/
|
|
10
15
|
export declare function defineWorkflow(definition: WorkflowDefinition): Workflow;
|
|
11
16
|
/** A problem of a run's input: an unknown field, or an invalid or missing one, by its path. */
|
package/dist/engine/workflow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { profileSchema } from "./profiles.js";
|
|
2
|
+
import { announcesCost, profileSchema, runtimeLabels } from "./profiles.js";
|
|
3
3
|
/** Workflow and prompt names name files and directories. */
|
|
4
4
|
const FILE_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;
|
|
5
5
|
/** A session name is a segment of session file names: it starts and ends alphanumeric. */
|
|
@@ -107,6 +107,57 @@ function agentProblems(definition, agents) {
|
|
|
107
107
|
}
|
|
108
108
|
return problems;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Why a budget cannot apply to these agent stages: some run on a runtime that
|
|
112
|
+
* announces no cost, so the budget could never be checked.
|
|
113
|
+
*/
|
|
114
|
+
export function budgetRefusal(agents) {
|
|
115
|
+
const unpriced = Object.entries(agents).filter(([, { profile }]) => !announcesCost[profile.runtime]);
|
|
116
|
+
if (!unpriced.length)
|
|
117
|
+
return undefined;
|
|
118
|
+
const runtimes = [
|
|
119
|
+
...new Set(unpriced.map(([, { profile }]) => runtimeLabels[profile.runtime])),
|
|
120
|
+
];
|
|
121
|
+
return `maxCostUsd cannot be checked: ${runtimes.join(", ")} announces no cost (stages ${unpriced.map(([stage]) => stage).join(", ")})`;
|
|
122
|
+
}
|
|
123
|
+
/** Steps, when declared, hold each stage exactly once. */
|
|
124
|
+
function stepProblems({ steps, nodes }) {
|
|
125
|
+
if (steps === undefined)
|
|
126
|
+
return [];
|
|
127
|
+
if (!Array.isArray(steps) || steps.length === 0)
|
|
128
|
+
return ["steps must list at least one step"];
|
|
129
|
+
const problems = [];
|
|
130
|
+
const names = new Set();
|
|
131
|
+
const owner = new Map();
|
|
132
|
+
for (const [index, declared] of steps.entries()) {
|
|
133
|
+
// factory.ts runs without a type check: a step may be anything.
|
|
134
|
+
const { name, stages } = (declared ?? {});
|
|
135
|
+
// An unnamed step is named by its position.
|
|
136
|
+
const step = typeof name === "string" && name ? name : `#${index + 1}`;
|
|
137
|
+
if (step !== name)
|
|
138
|
+
problems.push(`steps: step ${step} has no name`);
|
|
139
|
+
else if (names.has(name))
|
|
140
|
+
problems.push(`steps: duplicate step ${name}`);
|
|
141
|
+
names.add(step);
|
|
142
|
+
if (!Array.isArray(stages) || stages.length === 0) {
|
|
143
|
+
problems.push(`steps: step ${step} has no stage`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
for (const stage of stages) {
|
|
147
|
+
if (!Object.hasOwn(nodes, stage))
|
|
148
|
+
problems.push(`steps: step ${step} names unknown stage ${stage}`);
|
|
149
|
+
const first = owner.get(stage);
|
|
150
|
+
if (first !== undefined)
|
|
151
|
+
problems.push(`steps: stage ${stage} is in steps ${first} and ${step}`);
|
|
152
|
+
else
|
|
153
|
+
owner.set(stage, step);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const stage of Object.keys(nodes))
|
|
157
|
+
if (!owner.has(stage))
|
|
158
|
+
problems.push(`steps: stage ${stage} is in no step`);
|
|
159
|
+
return problems;
|
|
160
|
+
}
|
|
110
161
|
function inputProblems(input) {
|
|
111
162
|
if (input === undefined || input instanceof z.ZodObject)
|
|
112
163
|
return [];
|
|
@@ -117,8 +168,8 @@ export function presentData(state) {
|
|
|
117
168
|
return [JSON.stringify(state.data, null, 2)];
|
|
118
169
|
}
|
|
119
170
|
/**
|
|
120
|
-
* Validates a workflow when it is declared: graph, retry maximums, loops,
|
|
121
|
-
* stages and inputs. Agent profiles are returned with their defaults applied.
|
|
171
|
+
* Validates a workflow when it is declared: graph, retry maximums, loops, steps,
|
|
172
|
+
* agent stages and inputs. Agent profiles are returned with their defaults applied.
|
|
122
173
|
*/
|
|
123
174
|
export function defineWorkflow(definition) {
|
|
124
175
|
if (!FILE_NAME.test(definition.name))
|
|
@@ -135,9 +186,13 @@ export function defineWorkflow(definition) {
|
|
|
135
186
|
`maxCostUsd must be a positive number of USD, got ${String(maxCostUsd)}`,
|
|
136
187
|
]),
|
|
137
188
|
...graphProblems(definition),
|
|
189
|
+
...stepProblems(definition),
|
|
138
190
|
...agentProblems(definition, agents),
|
|
139
191
|
...inputProblems(definition.input),
|
|
140
192
|
];
|
|
193
|
+
const unbudgetable = maxCostUsd === undefined ? undefined : budgetRefusal(agents);
|
|
194
|
+
if (unbudgetable)
|
|
195
|
+
problems.push(unbudgetable);
|
|
141
196
|
if (problems.length)
|
|
142
197
|
throw new Error(`Invalid workflow ${definition.name}: ${problems.join("; ")}`);
|
|
143
198
|
const workflow = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","s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;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACvC,MAAM,IAAI,iBAAiB,CACzB,QAAQ,CAAC,IAAI,EACb,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAkB,EAAE,CACpD,KAAK,CAAC,IAAI,KAAK,mBAAmB;QAChC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACvB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACjD,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;QACL,CAAC,CAAC;YACE;gBACE,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBACvC,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;SACF,CACN,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export { type RunHooks, type RunSetup, type StartedRun, startRun, } from "./app/
|
|
|
8
8
|
export { type Correction, listRuns, loadRun, loadRunEvents, presentResult, type RunEntry, summarizeCorrections, summarizeRun, } from "./app/runs.js";
|
|
9
9
|
export { type AgentUsage, elapsedMs, type TokenCounts, } from "./engine/metrics.js";
|
|
10
10
|
export { agent, type Check, code, END, gate, node, pick, retry, schemaGate, step, } from "./engine/primitives.js";
|
|
11
|
-
export { type AgentProfile, type Runtime, runtimeLabels, } from "./engine/profiles.js";
|
|
12
|
-
export type { AgentActivity, AgentStage, Log, RunEvent, RunState, Stage, StageContext, StageEvent, StageResult, Workflow, WorkflowDefinition, } from "./engine/types.js";
|
|
11
|
+
export { type AgentProfile, type AgentSettings, profileProblems, type Runtime, runtimeLabels, } from "./engine/profiles.js";
|
|
12
|
+
export type { AgentActivity, AgentStage, Log, RunEvent, RunState, Stage, StageContext, StageEvent, StageResult, Workflow, WorkflowDefinition, WorkflowStep, } from "./engine/types.js";
|
|
13
13
|
export { defineWorkflow, type InputProblem, InvalidInputError, isWorkflow, parseInput, } from "./engine/workflow.js";
|
|
14
|
-
export { killChildProcesses, ProcessInterruptedError, runProcess, } from "./system/process.js";
|
|
14
|
+
export { killChildProcesses, ProcessInterruptedError, ProcessTimeoutError, runProcess, } from "./system/process.js";
|
|
15
15
|
export { type AgentProblem, inspectNode, inspectRuntimes, type RuntimeStatus, } from "./system/runtimes/inspect.js";
|
|
16
16
|
export { defaultRunsDir, UnknownRunError } from "./system/store.js";
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,9 @@ export { startRun, } from "./app/run.js";
|
|
|
8
8
|
export { listRuns, loadRun, loadRunEvents, presentResult, summarizeCorrections, summarizeRun, } from "./app/runs.js";
|
|
9
9
|
export { elapsedMs, } from "./engine/metrics.js";
|
|
10
10
|
export { agent, code, END, gate, node, pick, retry, schemaGate, step, } from "./engine/primitives.js";
|
|
11
|
-
export { runtimeLabels, } from "./engine/profiles.js";
|
|
11
|
+
export { profileProblems, runtimeLabels, } from "./engine/profiles.js";
|
|
12
12
|
export { defineWorkflow, InvalidInputError, isWorkflow, parseInput, } from "./engine/workflow.js";
|
|
13
|
-
export { killChildProcesses, ProcessInterruptedError, runProcess, } from "./system/process.js";
|
|
13
|
+
export { killChildProcesses, ProcessInterruptedError, ProcessTimeoutError, runProcess, } from "./system/process.js";
|
|
14
14
|
export { inspectNode, inspectRuntimes, } from "./system/runtimes/inspect.js";
|
|
15
15
|
export { defaultRunsDir, UnknownRunError } from "./system/store.js";
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/system/process.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export declare class ProcessStartError extends Error {
|
|
|
4
4
|
export declare class ProcessInterruptedError extends Error {
|
|
5
5
|
constructor(signal: NodeJS.Signals, executable: string);
|
|
6
6
|
}
|
|
7
|
+
/** A command stopped at its timeout, with the end of what it wrote until then. */
|
|
8
|
+
export declare class ProcessTimeoutError extends Error {
|
|
9
|
+
stdout: string;
|
|
10
|
+
stderr: string;
|
|
11
|
+
constructor(timeoutMs: number, executable: string);
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
* Calls `handler` when a SIGINT or SIGTERM interrupts the running children, as
|
|
9
15
|
* long as it is registered; returns its removal. It attaches no listener itself.
|
|
@@ -14,14 +20,30 @@ export declare function whenInterrupted(handler: (signal: NodeJS.Signals) => voi
|
|
|
14
20
|
* every run, at once: for a program about to quit.
|
|
15
21
|
*/
|
|
16
22
|
export declare function killChildProcesses(): void;
|
|
17
|
-
|
|
18
|
-
* Runs an executable without a shell. A failure terminates the entire child group
|
|
19
|
-
* and settles only after the child closes and the TERM→KILL grace period finishes.
|
|
20
|
-
*/
|
|
21
|
-
export declare function runProcess(command: string[], cwd: string, timeoutMs: number, onLine?: (line: string) => void, stdin?: string): Promise<{
|
|
23
|
+
export interface ProcessResult {
|
|
22
24
|
exitCode: number;
|
|
23
25
|
stdout: string;
|
|
24
26
|
stderr: string;
|
|
25
27
|
stdoutTruncated: boolean;
|
|
26
28
|
stderrTruncated: boolean;
|
|
27
|
-
}
|
|
29
|
+
}
|
|
30
|
+
export interface ProcessOptions {
|
|
31
|
+
cwd: string;
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
/** Each line of standard output, as it comes. */
|
|
34
|
+
onLine?: (line: string) => void;
|
|
35
|
+
stdin?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The signal the program handles to stop cleanly, its own children included,
|
|
38
|
+
* sent to its group before SIGKILL; SIGTERM by default.
|
|
39
|
+
*/
|
|
40
|
+
stopSignal?: NodeJS.Signals;
|
|
41
|
+
}
|
|
42
|
+
/** `runCommand` with its arguments in order: the form workflows use. */
|
|
43
|
+
export declare function runProcess(command: string[], cwd: string, timeoutMs: number, onLine?: (line: string) => void, stdin?: string): Promise<ProcessResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Runs an executable without a shell, in its own process group. A failure
|
|
46
|
+
* terminates the entire group, with the program's stop signal then SIGKILL, and
|
|
47
|
+
* settles only after the child closes and the grace period finishes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runCommand(command: string[], options: ProcessOptions): Promise<ProcessResult>;
|
package/dist/system/process.js
CHANGED
|
@@ -14,6 +14,15 @@ export class ProcessInterruptedError extends Error {
|
|
|
14
14
|
this.name = "ProcessInterruptedError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/** A command stopped at its timeout, with the end of what it wrote until then. */
|
|
18
|
+
export class ProcessTimeoutError extends Error {
|
|
19
|
+
stdout = "";
|
|
20
|
+
stderr = "";
|
|
21
|
+
constructor(timeoutMs, executable) {
|
|
22
|
+
super(`Process timed out after ${timeoutMs}ms: ${executable}`);
|
|
23
|
+
this.name = "ProcessTimeoutError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
17
26
|
class BoundedCapture {
|
|
18
27
|
#chunks = [];
|
|
19
28
|
#length = 0;
|
|
@@ -120,11 +129,17 @@ export function killChildProcesses() {
|
|
|
120
129
|
for (const child of running.keys())
|
|
121
130
|
signalGroup(child, "SIGKILL");
|
|
122
131
|
}
|
|
132
|
+
/** `runCommand` with its arguments in order: the form workflows use. */
|
|
133
|
+
export async function runProcess(command, cwd, timeoutMs, onLine, stdin) {
|
|
134
|
+
return runCommand(command, { cwd, timeoutMs, onLine, stdin });
|
|
135
|
+
}
|
|
123
136
|
/**
|
|
124
|
-
* Runs an executable without a shell
|
|
125
|
-
*
|
|
137
|
+
* Runs an executable without a shell, in its own process group. A failure
|
|
138
|
+
* terminates the entire group, with the program's stop signal then SIGKILL, and
|
|
139
|
+
* settles only after the child closes and the grace period finishes.
|
|
126
140
|
*/
|
|
127
|
-
export async function
|
|
141
|
+
export async function runCommand(command, options) {
|
|
142
|
+
const { cwd, timeoutMs, onLine, stdin, stopSignal = "SIGTERM" } = options;
|
|
128
143
|
if (command.length === 0 || !command[0])
|
|
129
144
|
throw new Error("Process command must include an executable");
|
|
130
145
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
@@ -161,6 +176,10 @@ export async function runProcess(command, cwd, timeoutMs, onLine, stdin) {
|
|
|
161
176
|
settled = true;
|
|
162
177
|
cleanup();
|
|
163
178
|
if (failure) {
|
|
179
|
+
if (failure instanceof ProcessTimeoutError) {
|
|
180
|
+
failure.stdout = stdout.text();
|
|
181
|
+
failure.stderr = stderr.text();
|
|
182
|
+
}
|
|
164
183
|
reject(failure);
|
|
165
184
|
return;
|
|
166
185
|
}
|
|
@@ -184,11 +203,11 @@ export async function runProcess(command, cwd, timeoutMs, onLine, stdin) {
|
|
|
184
203
|
if (terminating)
|
|
185
204
|
return;
|
|
186
205
|
terminating = true;
|
|
187
|
-
signalGroup(child,
|
|
206
|
+
signalGroup(child, stopSignal);
|
|
188
207
|
killTimer = setTimeout(sendKill, KILL_GRACE_MS);
|
|
189
208
|
};
|
|
190
209
|
const timeout = setTimeout(() => {
|
|
191
|
-
requestTermination(new
|
|
210
|
+
requestTermination(new ProcessTimeoutError(timeoutMs, executable));
|
|
192
211
|
}, timeoutMs);
|
|
193
212
|
timeout.unref();
|
|
194
213
|
track(child, onParentSignal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/system/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,C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EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACnC,WAAW,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC;gBACrC,kBAAkB,CAChB,IAAI,KAAK,CAAC,gCAAgC,UAAU,SAAS,CAAC,CAC/D,CAAC;YACJ,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7C,IAAI,OAAO,CAAC,MAAM,GAAG,cAAc;oBACjC,kBAAkB,CAChB,IAAI,KAAK,CACP,gCAAgC,cAAc,aAAa,CAC5D,CACF,CAAC;qBACC,CAAC;oBACJ,IAAI,CAAC;wBACH,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;oBACtD,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,kBAAkB,CAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { AgentUsage, TokenCounts } from "../../engine/metrics.js";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export type ProfileOf<R extends Runtime> = Extract<ResolvedProfile, {
|
|
6
|
-
runtime: R;
|
|
7
|
-
}>;
|
|
3
|
+
import type { ProfileOf, Runtime } from "../../engine/profiles.js";
|
|
4
|
+
export type { ProfileOf } from "../../engine/profiles.js";
|
|
8
5
|
/** One agent call, as a runtime prepares it. */
|
|
9
6
|
export interface RuntimeCall<R extends Runtime> {
|
|
10
7
|
profile: ProfileOf<R>;
|
|
@@ -39,7 +36,7 @@ export type RuntimeEvent = {
|
|
|
39
36
|
scope: "response" | "session";
|
|
40
37
|
usage: AgentUsage | undefined;
|
|
41
38
|
}
|
|
42
|
-
/**
|
|
39
|
+
/** Something the runtime reported that does not stop the call. */
|
|
43
40
|
| {
|
|
44
41
|
type: "warning";
|
|
45
42
|
message: string;
|
|
@@ -65,6 +62,14 @@ export interface Connection {
|
|
|
65
62
|
connected: boolean;
|
|
66
63
|
detail: string;
|
|
67
64
|
}
|
|
65
|
+
/** The command that reports a connection, and how to read its output. */
|
|
66
|
+
export interface ConnectionCheck {
|
|
67
|
+
args: string[];
|
|
68
|
+
read(output: {
|
|
69
|
+
stdout: string;
|
|
70
|
+
stderr: string;
|
|
71
|
+
}): Connection;
|
|
72
|
+
}
|
|
68
73
|
/** What the engine needs from an agent runtime. */
|
|
69
74
|
export interface RuntimeAdapter<R extends Runtime> {
|
|
70
75
|
name: R;
|
|
@@ -74,13 +79,18 @@ export interface RuntimeAdapter<R extends Runtime> {
|
|
|
74
79
|
executable: string;
|
|
75
80
|
/** The oldest version validated by a real call; `--version` prints it first. */
|
|
76
81
|
minimumVersion: string;
|
|
77
|
-
/** The
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
/** The signal on which the runtime stops cleanly, its commands included. */
|
|
83
|
+
stopSignal: NodeJS.Signals;
|
|
84
|
+
/**
|
|
85
|
+
* How a profile's connection is known without a provider request: the command
|
|
86
|
+
* that reports it and how to read its output, or the connection itself when the
|
|
87
|
+
* environment names it.
|
|
88
|
+
*/
|
|
89
|
+
connection(profile: ProfileOf<R>): ConnectionCheck | Connection;
|
|
82
90
|
/** The model a call is recorded with. */
|
|
83
91
|
model(profile: ProfileOf<R>): string;
|
|
92
|
+
/** The profile with its relative paths resolved in the configuration directory; as declared without any. */
|
|
93
|
+
resolvePaths?(profile: ProfileOf<R>, configDir: string): ProfileOf<R>;
|
|
84
94
|
start(call: RuntimeCall<R>): Promise<RuntimeProcess>;
|
|
85
95
|
}
|
|
86
96
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/system/runtimes/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/system/runtimes/adapter.ts"],"names":[],"mappings":"AAsFA;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,KAAa,EACb,MAAoB,EACpB,KAAc;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACvC,MAAM,IAAI,GACR,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC5B,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG;QAClB,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;SAC/B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;SACtE,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,0BAA0B,IAAI,UAAU,MAAM,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type UsageReport } from "../../engine/metrics.js";
|
|
2
|
-
import { type Runtime } from "../../engine/profiles.js";
|
|
2
|
+
import { type AgentSettings, type Runtime } from "../../engine/profiles.js";
|
|
3
3
|
import type { AgentPort, AgentRequest, RecordActivity } from "../../engine/types.js";
|
|
4
4
|
import type { RuntimeAdapter, RuntimeCall } from "./adapter.js";
|
|
5
5
|
export interface CallOptions {
|
|
@@ -21,6 +21,8 @@ export interface CallOptions {
|
|
|
21
21
|
export declare function runCall<R extends Runtime>(adapter: RuntimeAdapter<R>, call: RuntimeCall<R> & {
|
|
22
22
|
context: unknown;
|
|
23
23
|
schema: Record<string, unknown>;
|
|
24
|
+
/** Recorded when the call starts. */
|
|
25
|
+
settings: AgentSettings;
|
|
24
26
|
}, options: CallOptions): Promise<unknown>;
|
|
25
27
|
export interface AgentRuntimeOptions extends Pick<CallOptions, "onUsage"> {
|
|
26
28
|
/** The directory agents work in. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { join } from "node:path";
|
|
3
3
|
import { sumUsage, } from "../../engine/metrics.js";
|
|
4
|
-
import { resolveProfile, } from "../../engine/profiles.js";
|
|
5
|
-
import { ProcessStartError,
|
|
4
|
+
import { agentSettings, resolveProfile, } from "../../engine/profiles.js";
|
|
5
|
+
import { ProcessStartError, runCommand } from "../process.js";
|
|
6
6
|
import { agentPrompt, parseAgentJson } from "./protocol.js";
|
|
7
7
|
import { runtimes } from "./registry.js";
|
|
8
8
|
/** The figures announced for the call: its session's total, or the sum of its responses. */
|
|
@@ -33,6 +33,7 @@ export async function runCall(adapter, call, options) {
|
|
|
33
33
|
runtime: adapter.name,
|
|
34
34
|
model: adapter.model(call.profile),
|
|
35
35
|
session: call.session,
|
|
36
|
+
settings: call.settings,
|
|
36
37
|
});
|
|
37
38
|
const reports = [];
|
|
38
39
|
const tools = new Map();
|
|
@@ -40,62 +41,68 @@ export async function runCall(adapter, call, options) {
|
|
|
40
41
|
let running = true;
|
|
41
42
|
let succeeded = false;
|
|
42
43
|
try {
|
|
43
|
-
const exit = await
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
const exit = await runCommand([options.executable ?? adapter.executable, ...started.args], {
|
|
45
|
+
cwd: options.dir,
|
|
46
|
+
timeoutMs: call.profile.timeoutMs,
|
|
47
|
+
stdin: request,
|
|
48
|
+
stopSignal: adapter.stopSignal,
|
|
49
|
+
onLine: (line) => {
|
|
50
|
+
if (!line)
|
|
51
|
+
return;
|
|
52
|
+
let event;
|
|
53
|
+
try {
|
|
54
|
+
event = JSON.parse(line);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new Error(`${label} emitted invalid JSONL output`);
|
|
58
|
+
}
|
|
59
|
+
for (const item of started.read(event))
|
|
60
|
+
switch (item.type) {
|
|
61
|
+
case "tool": {
|
|
62
|
+
const { id, name, status } = item;
|
|
63
|
+
if (status === "started") {
|
|
64
|
+
tools.set(id, Date.now());
|
|
65
|
+
record?.({ kind: "tool", id, name, status });
|
|
66
|
+
}
|
|
67
|
+
else
|
|
68
|
+
record?.({
|
|
69
|
+
kind: "tool",
|
|
70
|
+
id,
|
|
71
|
+
name,
|
|
72
|
+
status,
|
|
73
|
+
durationMs: Date.now() - (tools.get(id) ?? Date.now()),
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
60
76
|
}
|
|
61
|
-
|
|
62
|
-
record?.({
|
|
63
|
-
kind: "tool",
|
|
64
|
-
id,
|
|
65
|
-
name,
|
|
66
|
-
status,
|
|
67
|
-
durationMs: Date.now() - (tools.get(id) ?? Date.now()),
|
|
68
|
-
});
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "response":
|
|
72
|
-
record?.({
|
|
73
|
-
kind: "response",
|
|
74
|
-
tokens: item.tokens,
|
|
75
|
-
provisional: true,
|
|
76
|
-
});
|
|
77
|
-
break;
|
|
78
|
-
case "usage":
|
|
79
|
-
reports.push({ session, scope: item.scope, usage: item.usage });
|
|
80
|
-
if (item.scope === "response" && item.usage) {
|
|
81
|
-
const { costUsd, ...tokens } = item.usage;
|
|
77
|
+
case "response":
|
|
82
78
|
record?.({
|
|
83
79
|
kind: "response",
|
|
84
|
-
tokens,
|
|
85
|
-
|
|
86
|
-
provisional: false,
|
|
80
|
+
tokens: item.tokens,
|
|
81
|
+
provisional: true,
|
|
87
82
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
break;
|
|
84
|
+
case "usage":
|
|
85
|
+
reports.push({ session, scope: item.scope, usage: item.usage });
|
|
86
|
+
if (item.scope === "response" && item.usage) {
|
|
87
|
+
const { costUsd, ...tokens } = item.usage;
|
|
88
|
+
record?.({
|
|
89
|
+
kind: "response",
|
|
90
|
+
tokens,
|
|
91
|
+
costUsd,
|
|
92
|
+
provisional: false,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "warning":
|
|
97
|
+
record?.({ kind: "warning", message: item.message });
|
|
98
|
+
break;
|
|
99
|
+
case "failure":
|
|
100
|
+
throw new Error(item.message);
|
|
101
|
+
case "result":
|
|
102
|
+
text = item.text;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
99
106
|
if (exit.exitCode !== 0)
|
|
100
107
|
throw new Error(`${label} exited with code ${exit.exitCode}: ${exit.stderr.trim() || "no error output"}`);
|
|
101
108
|
if (text === undefined)
|
|
@@ -127,25 +134,6 @@ export async function runCall(adapter, call, options) {
|
|
|
127
134
|
return text;
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
|
-
/** Relative skill, extension and MCP command paths belong to `configDir`; a bare command stays a PATH lookup. */
|
|
131
|
-
function resolvePaths(profile, configDir) {
|
|
132
|
-
if (profile.runtime === "pi")
|
|
133
|
-
return {
|
|
134
|
-
...profile,
|
|
135
|
-
skills: profile.skills.map((path) => resolve(configDir, path)),
|
|
136
|
-
extensions: profile.extensions.map((path) => resolve(configDir, path)),
|
|
137
|
-
};
|
|
138
|
-
const command = (value) => value.includes("/") && !isAbsolute(value)
|
|
139
|
-
? resolve(configDir, value)
|
|
140
|
-
: value;
|
|
141
|
-
return {
|
|
142
|
-
...profile,
|
|
143
|
-
mcpServers: Object.fromEntries(Object.entries(profile.mcpServers).map(([name, server]) => [
|
|
144
|
-
name,
|
|
145
|
-
{ ...server, command: command(server.command) },
|
|
146
|
-
])),
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
137
|
/** Validates each request's profile, then runs it on the runtime the profile selects, with its named prompt. */
|
|
150
138
|
export class AgentRuntime {
|
|
151
139
|
#options;
|
|
@@ -159,26 +147,27 @@ export class AgentRuntime {
|
|
|
159
147
|
: undefined;
|
|
160
148
|
if (systemPrompt === undefined)
|
|
161
149
|
throw new Error(`No prompt loaded: ${request.prompt}`);
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
onUsage,
|
|
168
|
-
};
|
|
169
|
-
const call = {
|
|
150
|
+
const declared = resolveProfile(request.profile);
|
|
151
|
+
// The registry pairs each runtime with its adapter: the profile selects one of the same runtime.
|
|
152
|
+
const adapter = runtimes[declared.runtime];
|
|
153
|
+
return runCall(adapter, {
|
|
154
|
+
profile: adapter.resolvePaths?.(declared, configDir) ?? declared,
|
|
170
155
|
systemPrompt,
|
|
171
156
|
session: request.session,
|
|
172
157
|
sessions: {
|
|
173
158
|
runId: run.id,
|
|
174
|
-
directory: join(run.directory,
|
|
159
|
+
directory: join(run.directory, declared.runtime),
|
|
175
160
|
},
|
|
176
161
|
context: request.context,
|
|
177
162
|
schema: request.schema,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
163
|
+
// Paths as the workflow declares them, not as resolved on this machine.
|
|
164
|
+
settings: agentSettings(declared),
|
|
165
|
+
}, {
|
|
166
|
+
dir,
|
|
167
|
+
executable: executables?.[declared.runtime],
|
|
168
|
+
record,
|
|
169
|
+
onUsage,
|
|
170
|
+
});
|
|
182
171
|
}
|
|
183
172
|
}
|
|
184
173
|
//# sourceMappingURL=agent-runtime.js.map
|