@acpus/runtime 0.1.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/artifacts.d.ts +30 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +97 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/client.d.ts +54 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +159 -0
- package/dist/client.js.map +1 -0
- package/dist/evaluator.d.ts +37 -0
- package/dist/evaluator.d.ts.map +1 -0
- package/dist/evaluator.js +101 -0
- package/dist/evaluator.js.map +1 -0
- package/dist/executors/agent.d.ts +74 -0
- package/dist/executors/agent.d.ts.map +1 -0
- package/dist/executors/agent.js +401 -0
- package/dist/executors/agent.js.map +1 -0
- package/dist/executors/mock-program.d.ts +24 -0
- package/dist/executors/mock-program.d.ts.map +1 -0
- package/dist/executors/mock-program.js +79 -0
- package/dist/executors/mock-program.js.map +1 -0
- package/dist/executors/program.d.ts +21 -0
- package/dist/executors/program.d.ts.map +1 -0
- package/dist/executors/program.js +178 -0
- package/dist/executors/program.js.map +1 -0
- package/dist/executors/types.d.ts +26 -0
- package/dist/executors/types.d.ts.map +1 -0
- package/dist/executors/types.js +2 -0
- package/dist/executors/types.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter.d.ts +186 -0
- package/dist/interpreter.d.ts.map +1 -0
- package/dist/interpreter.js +1500 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/keys.d.ts +36 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +59 -0
- package/dist/keys.js.map +1 -0
- package/dist/state-machine.d.ts +27 -0
- package/dist/state-machine.d.ts.map +1 -0
- package/dist/state-machine.js +87 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/store.d.ts +46 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +260 -0
- package/dist/store.js.map +1 -0
- package/dist/supervisor-app.d.ts +27 -0
- package/dist/supervisor-app.d.ts.map +1 -0
- package/dist/supervisor-app.js +548 -0
- package/dist/supervisor-app.js.map +1 -0
- package/dist/supervisor-discovery.d.ts +17 -0
- package/dist/supervisor-discovery.d.ts.map +1 -0
- package/dist/supervisor-discovery.js +186 -0
- package/dist/supervisor-discovery.js.map +1 -0
- package/dist/supervisor-entry.d.ts +11 -0
- package/dist/supervisor-entry.d.ts.map +1 -0
- package/dist/supervisor-entry.js +50 -0
- package/dist/supervisor-entry.js.map +1 -0
- package/dist/supervisor-lock.d.ts +26 -0
- package/dist/supervisor-lock.d.ts.map +1 -0
- package/dist/supervisor-lock.js +49 -0
- package/dist/supervisor-lock.js.map +1 -0
- package/dist/supervisor-runner.d.ts +11 -0
- package/dist/supervisor-runner.d.ts.map +1 -0
- package/dist/supervisor-runner.js +128 -0
- package/dist/supervisor-runner.js.map +1 -0
- package/dist/types.d.ts +230 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate-input.d.ts +27 -0
- package/dist/validate-input.d.ts.map +1 -0
- package/dist/validate-input.js +56 -0
- package/dist/validate-input.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { Ajv } from "ajv";
|
|
5
|
+
import { parseDurationMs } from "@acpus/core";
|
|
6
|
+
import { ExpressionEvaluator } from "../evaluator.js";
|
|
7
|
+
/**
|
|
8
|
+
* Real program executor using execa for subprocess management.
|
|
9
|
+
* Handles cmd template resolution, capture config, timeout, and abort signal.
|
|
10
|
+
*
|
|
11
|
+
* A non-zero exit code is treated as step data (the node completes and exposes
|
|
12
|
+
* exit_code). Only non-recoverable conditions — timeout, signal kill, spawn
|
|
13
|
+
* failure, or capture parse failure — fail the node via `failureKind`.
|
|
14
|
+
*/
|
|
15
|
+
export class ProgramExecutor {
|
|
16
|
+
evaluator;
|
|
17
|
+
ajv = new Ajv({ allErrors: true, strict: false });
|
|
18
|
+
constructor(evaluator) {
|
|
19
|
+
this.evaluator = evaluator ?? new ExpressionEvaluator();
|
|
20
|
+
}
|
|
21
|
+
async execute({ node, context, signal }) {
|
|
22
|
+
const cmdTemplate = node.metadata.cmd;
|
|
23
|
+
const timeoutRaw = node.metadata.timeout;
|
|
24
|
+
const capture = node.metadata.capture;
|
|
25
|
+
// Resolve cmd template
|
|
26
|
+
const cmd = this.resolveCmd(cmdTemplate, context);
|
|
27
|
+
if (signal.aborted) {
|
|
28
|
+
return { partial: true, error: "Aborted before execution" };
|
|
29
|
+
}
|
|
30
|
+
const shell = typeof cmd === "string";
|
|
31
|
+
const args = Array.isArray(cmd) ? cmd.slice(1) : [];
|
|
32
|
+
const command = Array.isArray(cmd) ? cmd[0] : cmd;
|
|
33
|
+
// Numeric timeout is milliseconds directly; string timeout is a duration.
|
|
34
|
+
const timeoutMs = typeof timeoutRaw === "number" && timeoutRaw > 0
|
|
35
|
+
? timeoutRaw
|
|
36
|
+
: typeof timeoutRaw === "string"
|
|
37
|
+
? parseDurationMs(timeoutRaw) || undefined
|
|
38
|
+
: undefined;
|
|
39
|
+
// Evaluate env templates. A bad expression (e.g. referencing an unknown step)
|
|
40
|
+
// is a user-facing error, not a spawn failure — catch and report clearly.
|
|
41
|
+
let env;
|
|
42
|
+
try {
|
|
43
|
+
env = { ...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== undefined)), ...this.evaluateEnv(node.metadata.env, context) };
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
failureKind: "capture",
|
|
48
|
+
error: `Failed to evaluate env template: ${error instanceof Error ? error.message : String(error)}`,
|
|
49
|
+
stdout: "",
|
|
50
|
+
stderr: ""
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
let result;
|
|
54
|
+
try {
|
|
55
|
+
result = await execa(command, args, {
|
|
56
|
+
shell,
|
|
57
|
+
reject: false,
|
|
58
|
+
timeout: timeoutMs && timeoutMs > 0 ? timeoutMs : 0,
|
|
59
|
+
killSignal: "SIGKILL",
|
|
60
|
+
cancelSignal: signal,
|
|
61
|
+
env,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
// Spawn-level failure (e.g. command not found) — non-recoverable.
|
|
66
|
+
return {
|
|
67
|
+
failureKind: "spawn",
|
|
68
|
+
error: error instanceof Error ? error.message : String(error),
|
|
69
|
+
stdout: "",
|
|
70
|
+
stderr: error instanceof Error ? error.message : String(error)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const stdout = result.stdout ?? "";
|
|
74
|
+
const stderr = result.stderr ?? "";
|
|
75
|
+
// Operator abort (pause/cancel) → partial.
|
|
76
|
+
if (result.isCanceled) {
|
|
77
|
+
return { partial: true, output: stdout, stdout, stderr, error: "Aborted during execution" };
|
|
78
|
+
}
|
|
79
|
+
// Timeout → non-recoverable.
|
|
80
|
+
if (result.timedOut) {
|
|
81
|
+
return { failureKind: "timeout", error: `Process timed out after ${timeoutMs}ms`, stdout, stderr };
|
|
82
|
+
}
|
|
83
|
+
// Killed by signal (SIGKILL etc.) → non-recoverable.
|
|
84
|
+
if (result.isTerminated || (result.signal !== undefined && result.signal !== null)) {
|
|
85
|
+
return { failureKind: "killed", error: `Process killed by signal ${result.signal}`, stdout, stderr };
|
|
86
|
+
}
|
|
87
|
+
// Spawn failure (e.g. command not found) — execa with reject:false reports
|
|
88
|
+
// `failed` with no exit code rather than throwing.
|
|
89
|
+
if (result.failed && (result.exitCode === undefined || result.exitCode === null)) {
|
|
90
|
+
return {
|
|
91
|
+
failureKind: "spawn",
|
|
92
|
+
error: result.shortMessage || result.message || "Failed to spawn process",
|
|
93
|
+
stdout,
|
|
94
|
+
stderr
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const exitCode = result.exitCode ?? 0;
|
|
98
|
+
// Handle capture config.
|
|
99
|
+
let output;
|
|
100
|
+
if (capture) {
|
|
101
|
+
const from = capture.from;
|
|
102
|
+
const parse = capture.parse;
|
|
103
|
+
let raw;
|
|
104
|
+
if (from === "file") {
|
|
105
|
+
const filePath = resolve(process.cwd(), capture.path);
|
|
106
|
+
try {
|
|
107
|
+
raw = readFileSync(filePath, "utf8");
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return {
|
|
111
|
+
failureKind: "capture",
|
|
112
|
+
error: `Failed to read capture file '${capture.path}': ${error instanceof Error ? error.message : String(error)}`,
|
|
113
|
+
exitCode,
|
|
114
|
+
stdout,
|
|
115
|
+
stderr
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
raw = stdout;
|
|
121
|
+
}
|
|
122
|
+
if (parse === "json") {
|
|
123
|
+
try {
|
|
124
|
+
output = JSON.parse(raw);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return { failureKind: "capture", error: "Failed to parse captured output as JSON", exitCode, stdout, stderr };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
output = raw;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
output = stdout || undefined;
|
|
136
|
+
}
|
|
137
|
+
// Validate output against schema when declared (mirrors agent schema validation).
|
|
138
|
+
const outputSchema = node.metadata.output;
|
|
139
|
+
if (outputSchema && output !== undefined) {
|
|
140
|
+
const validate = this.ajv.compile(outputSchema);
|
|
141
|
+
if (!validate(output)) {
|
|
142
|
+
return {
|
|
143
|
+
failureKind: "schema",
|
|
144
|
+
error: `Output validation failed: ${this.ajv.errorsText(validate.errors)}`,
|
|
145
|
+
exitCode,
|
|
146
|
+
stdout,
|
|
147
|
+
stderr
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { exitCode, output, stdout, stderr };
|
|
152
|
+
}
|
|
153
|
+
resolveCmd(cmd, context) {
|
|
154
|
+
if (Array.isArray(cmd)) {
|
|
155
|
+
return cmd.map((c) => {
|
|
156
|
+
if (typeof c === "string") {
|
|
157
|
+
return this.evaluator.evaluateTemplate(c, context);
|
|
158
|
+
}
|
|
159
|
+
return String(c);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (typeof cmd === "string") {
|
|
163
|
+
return this.evaluator.evaluateTemplate(cmd, context);
|
|
164
|
+
}
|
|
165
|
+
return String(cmd);
|
|
166
|
+
}
|
|
167
|
+
/** Evaluate template expressions in env values; non-strings are stringified. */
|
|
168
|
+
evaluateEnv(env, context) {
|
|
169
|
+
if (!env)
|
|
170
|
+
return {};
|
|
171
|
+
const out = {};
|
|
172
|
+
for (const [k, v] of Object.entries(env)) {
|
|
173
|
+
out[k] = typeof v === "string" ? this.evaluator.evaluateTemplate(v, context) : String(v);
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/executors/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IACT,SAAS,CAAsB;IAC/B,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI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ACvC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ExpressionContext, ExecutorResult } from "../types.js";
|
|
2
|
+
import type { IrNode } from "@acpus/core";
|
|
3
|
+
/**
|
|
4
|
+
* A single execution request handed to an executor. Carries the resolved
|
|
5
|
+
* `nodeKey` (stable node identity, used e.g. to derive an acpx session name)
|
|
6
|
+
* and a `continuation` flag distinguishing a fresh turn from an existing-session turn.
|
|
7
|
+
*/
|
|
8
|
+
export interface ExecutionRequest {
|
|
9
|
+
node: IrNode;
|
|
10
|
+
context: ExpressionContext;
|
|
11
|
+
signal: AbortSignal;
|
|
12
|
+
/** Resolved node key (includes loop/fanout/lane/subworkflow dimensions). */
|
|
13
|
+
nodeKey: string;
|
|
14
|
+
/** Fully prepared prompt/request text for this executor call. */
|
|
15
|
+
prompt?: string;
|
|
16
|
+
/** True when continuing a previously paused node (continuation prompt). */
|
|
17
|
+
continuation?: boolean;
|
|
18
|
+
/** True when this is a parse/schema auto-retry iteration (continuation prompt + schema section). */
|
|
19
|
+
retry?: boolean;
|
|
20
|
+
/** Called with raw stdout/stderr chunks while the executor is still running. */
|
|
21
|
+
onStream?: (stream: "stdout" | "stderr", chunk: string) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface ExecutorAdapter {
|
|
24
|
+
execute(request: ExecutionRequest): Promise<ExecutorResult>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/executors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oGAAoG;IACpG,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/executors/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { NodeState, RunStatus, NodeKeyDynamic, NodeExecutionState, RunState, ExpressionContext, ExecutorResult, ArtifactRef, InterpreterOptions, RunOptions, SupervisorConfig, SupervisorMetadata, SupervisorHealth, StartRunRequest, RunSummary, RunCleanItem, RunCleanResult, ReplayResult, ReplayMismatch, NodeDynamicContext } from "./types.js";
|
|
2
|
+
export type { ExecutorAdapter, ExecutionRequest } from "./executors/types.js";
|
|
3
|
+
export { resolveNodeKey, encodeNodeKeyForFs, encodeNodeKeyForDir } from "./keys.js";
|
|
4
|
+
export { ExpressionEvaluator } from "./evaluator.js";
|
|
5
|
+
export { RunStore } from "./store.js";
|
|
6
|
+
export { canTransition, transition, isTerminal, createInitialNodeState, resetFailedForRetry, resetRunningForCrashRecovery, resetAwaitingForCrashRecovery } from "./state-machine.js";
|
|
7
|
+
export { ArtifactStore } from "./artifacts.js";
|
|
8
|
+
export { WorkflowInterpreter } from "./interpreter.js";
|
|
9
|
+
export { InputValidationFailure, validateInput } from "./validate-input.js";
|
|
10
|
+
export type { InputValidationError } from "./types.js";
|
|
11
|
+
export { MockProgramExecutor } from "./executors/mock-program.js";
|
|
12
|
+
export { ProgramExecutor } from "./executors/program.js";
|
|
13
|
+
export { AgentExecutor } from "./executors/agent.js";
|
|
14
|
+
export { createSupervisorApp } from "./supervisor-app.js";
|
|
15
|
+
export { startRunSupervisor } from "./supervisor-runner.js";
|
|
16
|
+
export { ensureWorkspaceSupervisor } from "./supervisor-discovery.js";
|
|
17
|
+
export { RunSupervisorClient } from "./client.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAGrL,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC5E,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ─── Keys ────────────────────────────────────────────────────────
|
|
2
|
+
export { resolveNodeKey, encodeNodeKeyForFs, encodeNodeKeyForDir } from "./keys.js";
|
|
3
|
+
// ─── Evaluator ───────────────────────────────────────────────────
|
|
4
|
+
export { ExpressionEvaluator } from "./evaluator.js";
|
|
5
|
+
// ─── Store ───────────────────────────────────────────────────────
|
|
6
|
+
export { RunStore } from "./store.js";
|
|
7
|
+
// ─── State Machine ───────────────────────────────────────────────
|
|
8
|
+
export { canTransition, transition, isTerminal, createInitialNodeState, resetFailedForRetry, resetRunningForCrashRecovery, resetAwaitingForCrashRecovery } from "./state-machine.js";
|
|
9
|
+
// ─── Artifacts ───────────────────────────────────────────────────
|
|
10
|
+
export { ArtifactStore } from "./artifacts.js";
|
|
11
|
+
// ─── Interpreter ─────────────────────────────────────────────────
|
|
12
|
+
export { WorkflowInterpreter } from "./interpreter.js";
|
|
13
|
+
// ─── Input Validation ────────────────────────────────────────────
|
|
14
|
+
export { InputValidationFailure, validateInput } from "./validate-input.js";
|
|
15
|
+
// ─── Executors ───────────────────────────────────────────────────
|
|
16
|
+
export { MockProgramExecutor } from "./executors/mock-program.js";
|
|
17
|
+
export { ProgramExecutor } from "./executors/program.js";
|
|
18
|
+
export { AgentExecutor } from "./executors/agent.js";
|
|
19
|
+
// ─── Supervisor ──────────────────────────────────────────────────
|
|
20
|
+
export { createSupervisorApp } from "./supervisor-app.js";
|
|
21
|
+
export { startRunSupervisor } from "./supervisor-runner.js";
|
|
22
|
+
export { ensureWorkspaceSupervisor } from "./supervisor-discovery.js";
|
|
23
|
+
// ─── Client ──────────────────────────────────────────────────────
|
|
24
|
+
export { RunSupervisorClient } from "./client.js";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2BA,oEAAoE;AACpE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEpF,oEAAoE;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,oEAAoE;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,oEAAoE;AACpE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAErL,oEAAoE;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,oEAAoE;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,oEAAoE;AACpE,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG5E,oEAAoE;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,oEAAoE;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,oEAAoE;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { AcpusIr } from "@acpus/core";
|
|
2
|
+
import type { InterpreterOptions, RunOptions } from "./types.js";
|
|
3
|
+
import { RunStore } from "./store.js";
|
|
4
|
+
import type { ExecutorAdapter } from "./executors/types.js";
|
|
5
|
+
import type { ReplayResult } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* The core IR interpreter that drives state transitions, orchestrates
|
|
8
|
+
* execution, and persists state.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WorkflowInterpreter {
|
|
11
|
+
private readonly store;
|
|
12
|
+
private readonly evaluator;
|
|
13
|
+
private readonly agentExecutor;
|
|
14
|
+
private readonly programExecutor;
|
|
15
|
+
private readonly artifactStore;
|
|
16
|
+
private readonly maxConcurrency;
|
|
17
|
+
private readonly allowedSourceRoots;
|
|
18
|
+
private readonly sleep;
|
|
19
|
+
/** Active abort controllers keyed by "runId:nodeKey" for pause/cancel support */
|
|
20
|
+
private readonly abortControllers;
|
|
21
|
+
/** Intent of an in-flight abort keyed by "runId:nodeKey" (pause vs cancel). */
|
|
22
|
+
private readonly abortIntents;
|
|
23
|
+
/** Pending human-decision resolvers for Approval Gates awaiting a signal,
|
|
24
|
+
* keyed by "runId:nodeKey". An entry exists only while a node is `awaiting`. */
|
|
25
|
+
private readonly approvalResolvers;
|
|
26
|
+
/** Absolute paths of subworkflow specs currently on the execution stack (cycle guard). */
|
|
27
|
+
private readonly subworkflowStack;
|
|
28
|
+
/** Scheduling guards for Run-level pause/cancel, keyed by runId.
|
|
29
|
+
* Per-runId to prevent leakage across runs sharing the same interpreter. */
|
|
30
|
+
private readonly schedulingPaused;
|
|
31
|
+
private readonly schedulingCancelled;
|
|
32
|
+
constructor(store: RunStore, agentExecutor: ExecutorAdapter, programExecutor: ExecutorAdapter, options?: InterpreterOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Start a new workflow run to completion (init + execute). Convenience for
|
|
35
|
+
* callers that want to await the terminal state.
|
|
36
|
+
*/
|
|
37
|
+
start(ir: AcpusIr, opts: RunOptions): Promise<import("./types.js").RunState>;
|
|
38
|
+
/**
|
|
39
|
+
* Initialize a run (freeze IR + input, write running meta) and return the
|
|
40
|
+
* initial running state synchronously, without executing nodes.
|
|
41
|
+
*/
|
|
42
|
+
initRun(ir: AcpusIr, opts: RunOptions): import("./types.js").RunState;
|
|
43
|
+
/**
|
|
44
|
+
* Execute a previously-initialized run to its terminal state.
|
|
45
|
+
*/
|
|
46
|
+
runToCompletion(ir: AcpusIr, opts: RunOptions, runId: string): Promise<import("./types.js").RunState>;
|
|
47
|
+
/**
|
|
48
|
+
* Reset any nodes persisted as `running` (or `awaiting`) back to `pending`
|
|
49
|
+
* (crash recovery). Safe to call when adopting a Run after a supervisor
|
|
50
|
+
* restart: in-memory abort controllers and approval resolvers are gone, so a
|
|
51
|
+
* node marked `running`/`awaiting` on disk has no live execution and must be
|
|
52
|
+
* re-runnable. An `awaiting` Approval Gate re-registers its resolver and waits
|
|
53
|
+
* for a fresh human decision on re-execution.
|
|
54
|
+
*/
|
|
55
|
+
recoverStaleNodes(runId: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Deterministically replay a persisted Run and verify its reconstructed
|
|
58
|
+
* Node topology.
|
|
59
|
+
*
|
|
60
|
+
* Re-walks the frozen IR snapshot (never the mutable YAML), feeding recorded
|
|
61
|
+
* per-node outputs back into the expression context so control-flow decisions
|
|
62
|
+
* (switch branches, loop rounds, fanout lanes) are re-derived. No agents or
|
|
63
|
+
* programs are executed, no disk writes occur, and the walk is pinned to the
|
|
64
|
+
* recorded runId + a frozen clock for self-determinism. The set of node keys
|
|
65
|
+
* the re-walk reaches is compared against what was persisted; per-node
|
|
66
|
+
* terminal-state and output equivalence are out of scope for this milestone.
|
|
67
|
+
*/
|
|
68
|
+
replay(runId: string): ReplayResult;
|
|
69
|
+
/**
|
|
70
|
+
* Read-only re-walk used by {@link replay}. Mirrors the control-flow dispatch
|
|
71
|
+
* of executeNode but never executes leaves: it replays recorded outputs into
|
|
72
|
+
* the context and records the reconstructed node key → state. Concurrent
|
|
73
|
+
* containers (parallel/fanout) descend only into the lanes/branches that were
|
|
74
|
+
* actually recorded (racy joins do not run every branch).
|
|
75
|
+
*/
|
|
76
|
+
private replayNode;
|
|
77
|
+
/** Pause one running node as part of a Run-level pause operation. */
|
|
78
|
+
private pauseRunningNode;
|
|
79
|
+
/** Cancel one materialized node as part of Run-level cancel or fail-fast. */
|
|
80
|
+
private cancelMaterializedNode;
|
|
81
|
+
/** Resolve the operator intent for an in-flight abort; defaults to paused. */
|
|
82
|
+
private abortIntent;
|
|
83
|
+
/** True if the node has been persisted as terminal `cancelled` (e.g. by
|
|
84
|
+
* fail-fast). Used to avoid clobbering it when a still-running leaf later
|
|
85
|
+
* resolves/rejects. */
|
|
86
|
+
private readAbortedStateOnDisk;
|
|
87
|
+
private isStaleAttemptOnDisk;
|
|
88
|
+
private syncInFrameAttemptFromDisk;
|
|
89
|
+
/**
|
|
90
|
+
* Retry a failed executable Node. This is a local repair operation for the
|
|
91
|
+
* target executable only; Run-level retry remains the operation that restores
|
|
92
|
+
* Workflow progress from failed composite ancestors.
|
|
93
|
+
*/
|
|
94
|
+
retryNode(runId: string, nodeKey: string): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Pause an entire Run. Validates Run is `running`, sets scheduling guard,
|
|
97
|
+
* pauses all running nodes, and updates Run metadata to `paused`.
|
|
98
|
+
*/
|
|
99
|
+
pauseRun(runId: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Cancel an entire Run. Validates Run is `running` or `paused`, sets
|
|
102
|
+
* scheduling guard, cancels running nodes, marks pending nodes as cancelled,
|
|
103
|
+
* and updates Run metadata to `cancelled`.
|
|
104
|
+
*/
|
|
105
|
+
cancelRun(runId: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* Resume an entire paused Run. Validates Run is `paused`, clears scheduling
|
|
108
|
+
* guards, recovers stale nodes, and re-executes from root.
|
|
109
|
+
*/
|
|
110
|
+
resumeRun(runId: string): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Retry a failed Run. Validates Run is `failed`, resets failed materialized
|
|
113
|
+
* nodes to pending (preserving completed), clears scheduling guards, and
|
|
114
|
+
* re-executes from root. Same Run ID, no new Run.
|
|
115
|
+
*/
|
|
116
|
+
retryRun(runId: string): void;
|
|
117
|
+
private executeNode;
|
|
118
|
+
private executePipeline;
|
|
119
|
+
private executeAgent;
|
|
120
|
+
private executeProgram;
|
|
121
|
+
/** Write stdout.log/stderr.log artifacts; returns their URIs. */
|
|
122
|
+
private writeProgramArtifacts;
|
|
123
|
+
/** Write per-attempt agent response/protocol artifacts; returns their URIs. */
|
|
124
|
+
private writeAgentArtifacts;
|
|
125
|
+
/** Pre-create live Agent attempt artifacts and return their refs immediately. */
|
|
126
|
+
private startAgentAttemptArtifacts;
|
|
127
|
+
private appendAgentTranscript;
|
|
128
|
+
private publishRunningAgentAttempt;
|
|
129
|
+
private agentAttemptPrefix;
|
|
130
|
+
private executeParallel;
|
|
131
|
+
/**
|
|
132
|
+
* Cancel still-running/pending/awaiting descendant nodes of a failed
|
|
133
|
+
* composite (parallel or fanout), scoped to the given dynamic context. A
|
|
134
|
+
* descendant must (a) be one of the composite's descendant IR node ids and
|
|
135
|
+
* (b) share every dynamic dimension (item/lane/round) the composite already
|
|
136
|
+
* carries — so concurrent sibling fanout lanes outside this scope are not
|
|
137
|
+
* affected.
|
|
138
|
+
*
|
|
139
|
+
* NOTE: pass the composite's OWN dynamic. For a parallel this scopes to the
|
|
140
|
+
* current lane (item/lane present). For a fanout, the dynamic does NOT yet
|
|
141
|
+
* carry this fanout's lane (lanes are introduced for its children), so the
|
|
142
|
+
* scope spans ALL of the fanout's lanes — exactly the fail-fast intent.
|
|
143
|
+
*/
|
|
144
|
+
private descendantsInScope;
|
|
145
|
+
/**
|
|
146
|
+
* Cancel still-running/pending descendant nodes of a failed composite
|
|
147
|
+
* (parallel `join: all`, or fanout `join: all` fail-fast).
|
|
148
|
+
*/
|
|
149
|
+
private cancelDescendantsInScope;
|
|
150
|
+
private executeFanout;
|
|
151
|
+
/**
|
|
152
|
+
* Resolve fanout lanes per the wait strategy. Lanes never reject on normal
|
|
153
|
+
* failure (captured as LaneResult); only NodeAbortedError rejects, which we
|
|
154
|
+
* let propagate. Losing/excess lanes are silently consumed.
|
|
155
|
+
*/
|
|
156
|
+
private waitForFanout;
|
|
157
|
+
private executeSwitch;
|
|
158
|
+
private executeLoop;
|
|
159
|
+
private executeGuard;
|
|
160
|
+
private executeApproval;
|
|
161
|
+
/**
|
|
162
|
+
* Submit a human decision to an Approval Gate that is currently `awaiting`.
|
|
163
|
+
* Resolves the in-memory promise registered by executeApproval, which lets
|
|
164
|
+
* executeNode transition the node `awaiting → completed` with the decision
|
|
165
|
+
* output. Throws if the node is not awaiting a decision (no live resolver).
|
|
166
|
+
*/
|
|
167
|
+
submitApproval(runId: string, nodeKey: string, approved: boolean): void;
|
|
168
|
+
private executeSubworkflow;
|
|
169
|
+
private assertAllowedSourcePath;
|
|
170
|
+
/** Evaluate a subworkflow input value, preserving native type for single expressions. */
|
|
171
|
+
private evaluateInputValue;
|
|
172
|
+
private buildContext;
|
|
173
|
+
private populateStepOutputs;
|
|
174
|
+
/** Extract the parent dynamic value-context (fanout item / loop round) from a context, if any. */
|
|
175
|
+
private captureDynamicContext;
|
|
176
|
+
/** Merge a persisted dynamic value-context back into a rebuilt context (retry/continuation). */
|
|
177
|
+
private restoreDynamicContext;
|
|
178
|
+
private findNodeByKey;
|
|
179
|
+
/** Extract the step ID from a resolved node key. The ID is the last path segment before dynamic dims. */
|
|
180
|
+
private extractNodeIdFromKey;
|
|
181
|
+
private findNodeById;
|
|
182
|
+
private extractItemId;
|
|
183
|
+
}
|
|
184
|
+
/** Generate a locally sortable run ID: yyyyMMddHHmmss + 20 uppercase hex chars. */
|
|
185
|
+
export declare function generateRunId(now?: Date): string;
|
|
186
|
+
//# sourceMappingURL=interpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../src/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA2B,MAAM,aAAa,CAAC;AAIpE,OAAO,KAAK,EAAqB,kBAAkB,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAiC,YAAY,EAAkB,MAAM,YAAY,CAAC;AAoD9F;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAkB;IAChD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,C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