pi-subagents 0.84.0 → 0.86.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/CHANGELOG.md +83 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-JG4QKI5M.js → chunk-2IYBCYFU.js} +214 -97
- package/bundle/{chunk-V2BZYLEP.js → chunk-374MZFF4.js} +7 -2
- package/bundle/{chunk-4E7BKDTX.js → chunk-3RKFH2UZ.js} +11 -156
- package/bundle/{chunk-F4ASL6OV.js → chunk-5H4BICQZ.js} +1 -1
- package/bundle/{chunk-PALJGGYC.js → chunk-6VD7BGIC.js} +6 -3
- package/bundle/{chunk-C5P5CHYK.js → chunk-77ASNIEM.js} +1 -1
- package/bundle/{chunk-XDQORLZ5.js → chunk-7ADDXUGF.js} +15 -6
- package/bundle/{chunk-PV63UFUR.js → chunk-7QA7ZA46.js} +183 -28
- package/bundle/{chunk-NKQ6JNAS.js → chunk-7ZUFN6ME.js} +2 -1
- package/bundle/{chunk-SSG7IEP5.js → chunk-A637IMAO.js} +2 -2
- package/bundle/{chunk-L3WFKBEI.js → chunk-BGXEAYUM.js} +247 -153
- package/bundle/{chunk-J5YL7LYR.js → chunk-BU6PFPVX.js} +59 -27
- package/bundle/{chunk-DZDETGRJ.js → chunk-BWC2LVII.js} +259 -216
- package/bundle/{chunk-CGN2TVE7.js → chunk-GJGTMLPE.js} +322 -18
- package/bundle/{chunk-D3JAFGMO.js → chunk-GRJHIXYF.js} +1 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-LFDBD4PW.js → chunk-LGINOOY5.js} +2 -2
- package/bundle/{chunk-G2Z6ZH26.js → chunk-NAFLUJ26.js} +1 -1
- package/bundle/{chunk-235AWJUQ.js → chunk-O3YH7XIY.js} +324 -111
- package/bundle/{chunk-2DHZTCOL.js → chunk-PYOAIN3V.js} +2 -2
- package/bundle/{chunk-LNRJCP2Y.js → chunk-QGO6HXHG.js} +417 -242
- package/bundle/{chunk-VQVVHSY6.js → chunk-QM3JGE4W.js} +22 -11
- package/bundle/{chunk-2S4K53MV.js → chunk-S2Q75LP3.js} +1 -1
- package/bundle/{chunk-NENDSQUY.js → chunk-UR7OW5S7.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-WN2E5XHN.js} +135 -77
- package/bundle/{chunk-2D52JFLF.js → chunk-YK3QYNLE.js} +41 -117
- package/bundle/{chunk-7BWGNDNK.js → chunk-ZJJCPV3L.js} +190 -1177
- package/bundle/chunk-ZPY5QZCS.js +1067 -0
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +23 -2
- package/docs/configuration.md +4 -4
- package/docs/extension-api.md +16 -1
- package/docs/tool-reference.md +2 -0
- package/docs/workflows.md +30 -2
- package/package.json +1 -1
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +5 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +35 -12
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -9
- package/src/runs/background/async-execution.js +62 -27
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +15 -12
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- package/src/runs/shared/acceptance.js +69 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +85 -59
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +161 -66
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -12,7 +12,7 @@ import { isReusableWorkflowStopCause, WORKFLOW_STOP_CAUSE_OWNER_EXITED } from ".
|
|
|
12
12
|
/** A run may be resumed again after at most this many resumes that followed Pi exits (auto-resume only). */
|
|
13
13
|
const MAX_WORKFLOW_RESUME_ATTEMPTS = 3;
|
|
14
14
|
export function workflowResumeRefusal(code, reason, runId) {
|
|
15
|
-
const byHand = code === "launch-missing" || code === "launch-invalid" || code === "structured" || code === "digest" || code === "authority"
|
|
15
|
+
const byHand = code === "launch-missing" || code === "launch-invalid" || code === "structured" || code === "internal" || code === "digest" || code === "authority"
|
|
16
16
|
? relaunchByHandText(runId)
|
|
17
17
|
: code === "capacity" || code === "attempts" || code === "launch-failed" ? resumeByHandText(runId) : "";
|
|
18
18
|
return { code, reason, byHand };
|
|
@@ -51,10 +51,15 @@ export function prepareWorkflowResume(input) {
|
|
|
51
51
|
const { asyncDirRoot, sourceRunId, trigger } = input;
|
|
52
52
|
const refuse = (code, reason) => ({ ok: false, ...workflowResumeRefusal(code, reason, sourceRunId) });
|
|
53
53
|
const sourceAsyncDir = path.join(asyncDirRoot, sourceRunId);
|
|
54
|
+
// What is relaunched, by whom and under which ceiling comes only from the parent-owned launch
|
|
55
|
+
// record: a run behind a runner launcher can rewrite every file in its own run directory.
|
|
56
|
+
const read = readWorkflowLaunchRecord(asyncDirRoot, sourceRunId);
|
|
57
|
+
if (!read.ok)
|
|
58
|
+
return read.missing ? refuse("launch-missing", "launch.json is missing (the run started before launches were saved outside its run directory)") : refuse("launch-invalid", `launch.json is invalid: ${read.error}`);
|
|
59
|
+
const record = read.record;
|
|
54
60
|
// Only the session that owns the run (itself or one it replaced) may resume it, and nothing is
|
|
55
61
|
// written into another session's run, so this comes before the reconcile.
|
|
56
|
-
|
|
57
|
-
if (stored && !ownsRun(input.currentSessionId, stored.sessionId))
|
|
62
|
+
if (!ownsRun(input.currentSessionId, record.sessionId))
|
|
58
63
|
return refuse("not-owned", "it was started in another session; reopen that session to resume it");
|
|
59
64
|
// Session start has already reconciled this session's runs; a resume by id may come later.
|
|
60
65
|
if (trigger === "manual")
|
|
@@ -66,12 +71,10 @@ export function prepareWorkflowResume(input) {
|
|
|
66
71
|
const attempt = (status.workflow?.resumeOrigin?.attempt ?? 0) + (status.workflow?.stopCause === WORKFLOW_STOP_CAUSE_OWNER_EXITED ? 1 : 0);
|
|
67
72
|
if (trigger === "auto" && attempt > MAX_WORKFLOW_RESUME_ATTEMPTS)
|
|
68
73
|
return refuse("attempts", `${MAX_WORKFLOW_RESUME_ATTEMPTS} resumes already followed Pi exits`);
|
|
69
|
-
const read = readWorkflowLaunchRecord(sourceAsyncDir);
|
|
70
|
-
if (!read.ok)
|
|
71
|
-
return read.missing ? refuse("launch-missing", "launch.json is missing (the run started before launches were saved)") : refuse("launch-invalid", `launch.json is invalid: ${read.error}`);
|
|
72
|
-
const record = read.record;
|
|
73
74
|
if (record.source === "structured")
|
|
74
75
|
return refuse("structured", "launched from tasks/chain");
|
|
76
|
+
if (record.source === "internal")
|
|
77
|
+
return refuse("internal", "launched by a schedule or prompt-template delegation");
|
|
75
78
|
if (record.source === "script" && (typeof record.params.workflowScript !== "string" || workflowScriptDigest(record.params.workflowScript) !== record.scriptDigest)) {
|
|
76
79
|
return refuse("launch-invalid", "launch.json is invalid: its script does not match its scriptDigest");
|
|
77
80
|
}
|
|
@@ -97,7 +100,7 @@ export function prepareWorkflowResume(input) {
|
|
|
97
100
|
...record.params,
|
|
98
101
|
async: true,
|
|
99
102
|
reuseFrom: sourceRunId,
|
|
100
|
-
...(
|
|
103
|
+
...(record.admissionCapabilityCeiling ? { capabilityCeiling: record.admissionCapabilityCeiling } : {}),
|
|
101
104
|
},
|
|
102
105
|
expectedScriptDigest: record.scriptDigest,
|
|
103
106
|
resumeOrigin: { sourceRunId, attempt },
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import { Worker } from "node:worker_threads";
|
|
4
|
+
export declare class WorkflowScriptProcess extends EventEmitter {
|
|
5
|
+
readonly child: ChildProcess;
|
|
6
|
+
private exitCode;
|
|
7
|
+
private stopping;
|
|
8
|
+
private stderr;
|
|
9
|
+
constructor(acornPath: string);
|
|
10
|
+
postMessage(message: unknown): void;
|
|
11
|
+
terminate(): Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createWorkflowScriptWorker(acornPath: string): Worker | WorkflowScriptProcess;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { Worker } from "node:worker_threads";
|
|
7
|
+
const WORKFLOW_WORKER_URL = new URL("../../workflow-script-worker.cjs", import.meta.url);
|
|
8
|
+
const WORKFLOW_PROCESS_URL = new URL("../../workflow-script-process.cjs", import.meta.url);
|
|
9
|
+
export class WorkflowScriptProcess extends EventEmitter {
|
|
10
|
+
child;
|
|
11
|
+
exitCode;
|
|
12
|
+
stopping = false;
|
|
13
|
+
stderr = "";
|
|
14
|
+
constructor(acornPath) {
|
|
15
|
+
super();
|
|
16
|
+
const acorn = realpathSync(acornPath);
|
|
17
|
+
this.child = fork(WORKFLOW_PROCESS_URL, [acorn], {
|
|
18
|
+
// Under --permission, Node lets worker threads read everything under the process cwd, so the cwd must
|
|
19
|
+
// hold only public files: acorn's own directory. It also never holds a caller's cwd open on Windows.
|
|
20
|
+
cwd: dirname(acorn),
|
|
21
|
+
// No inherited execArgv or NODE_OPTIONS. Only the supervisor may create a worker.
|
|
22
|
+
execArgv: [
|
|
23
|
+
"--permission", "--allow-worker",
|
|
24
|
+
`--allow-fs-read=${realpathSync(fileURLToPath(WORKFLOW_PROCESS_URL))}`,
|
|
25
|
+
`--allow-fs-read=${realpathSync(fileURLToPath(WORKFLOW_WORKER_URL))}`,
|
|
26
|
+
`--allow-fs-read=${acorn}`,
|
|
27
|
+
],
|
|
28
|
+
env: process.platform === "win32" && process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {},
|
|
29
|
+
stdio: ["ignore", "ignore", "pipe", "ipc"],
|
|
30
|
+
});
|
|
31
|
+
this.child.stderr.on("data", (chunk) => { this.stderr = (this.stderr + chunk.toString("utf8")).slice(-4096); });
|
|
32
|
+
this.child.on("error", (error) => this.emit("error", error));
|
|
33
|
+
this.child.on("message", (json) => {
|
|
34
|
+
if (this.stopping)
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
if (typeof json !== "string")
|
|
38
|
+
throw new Error("Workflow process sent a non-string IPC message.");
|
|
39
|
+
const message = JSON.parse(json);
|
|
40
|
+
if (!message || typeof message !== "object" || Array.isArray(message))
|
|
41
|
+
throw new Error("Workflow process sent an invalid IPC message.");
|
|
42
|
+
this.emit("message", message);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this.emit("error", error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
this.child.on("exit", (code) => {
|
|
49
|
+
this.exitCode = code ?? 1;
|
|
50
|
+
this.child.stderr.destroy();
|
|
51
|
+
if (!this.stopping && code !== 0 && this.stderr.trim())
|
|
52
|
+
this.emit("error", new Error(this.stderr.trim()));
|
|
53
|
+
this.emit("exit", this.exitCode);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
postMessage(message) {
|
|
57
|
+
if (this.stopping || !this.child.connected)
|
|
58
|
+
return;
|
|
59
|
+
this.child.send(JSON.stringify(message), (error) => {
|
|
60
|
+
if (error && !this.stopping)
|
|
61
|
+
this.emit("error", error);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async terminate() {
|
|
65
|
+
if (this.exitCode !== undefined)
|
|
66
|
+
return this.exitCode;
|
|
67
|
+
this.stopping = true;
|
|
68
|
+
return await new Promise((resolve) => {
|
|
69
|
+
this.once("exit", resolve);
|
|
70
|
+
this.child.kill("SIGKILL");
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function createWorkflowScriptWorker(acornPath) {
|
|
75
|
+
// Bun has no permission model. Keep its existing file worker; do not claim process isolation there.
|
|
76
|
+
return typeof process.versions.bun === "string"
|
|
77
|
+
? new Worker(WORKFLOW_WORKER_URL, { workerData: { acornPath } })
|
|
78
|
+
: new WorkflowScriptProcess(acornPath);
|
|
79
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { Worker } = require("node:worker_threads");
|
|
4
|
+
const { join } = require("node:path");
|
|
5
|
+
|
|
6
|
+
// Windows process creation adds a standard environment even when fork receives an empty one.
|
|
7
|
+
for (const key of Object.keys(process.env)) {
|
|
8
|
+
if (process.platform !== "win32" || key.toLowerCase() !== "systemroot") delete process.env[key];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Keep IPC on this thread: a busy workflow must not prevent parent-disconnect cleanup.
|
|
12
|
+
// The script thread has no worker permission; filesystem grants are inherited from the process.
|
|
13
|
+
const worker = new Worker(join(__dirname, "workflow-script-worker.cjs"), {
|
|
14
|
+
workerData: { acornPath: process.argv[2] },
|
|
15
|
+
execArgv: process.execArgv.filter((arg) => arg !== "--allow-worker"),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function fail(error) {
|
|
19
|
+
if (!process.connected) return process.exit(1);
|
|
20
|
+
process.send(JSON.stringify({ type: "error", errorKind: "runtime", error: String(error?.message ?? error) }), () => process.exit(1));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.on("disconnect", () => process.exit(0));
|
|
24
|
+
process.on("message", (json) => {
|
|
25
|
+
try {
|
|
26
|
+
if (typeof json !== "string") throw new Error("Workflow process received a non-string IPC message.");
|
|
27
|
+
worker.postMessage(JSON.parse(json));
|
|
28
|
+
} catch (error) { fail(error); }
|
|
29
|
+
});
|
|
30
|
+
worker.on("message", (message) => {
|
|
31
|
+
try {
|
|
32
|
+
process.send(JSON.stringify(message), (error) => { if (error) process.exit(1); });
|
|
33
|
+
} catch (error) { fail(error); }
|
|
34
|
+
});
|
|
35
|
+
worker.on("error", fail);
|
|
36
|
+
worker.on("exit", (code) => fail(new Error(`Workflow script thread exited before returning a result (code ${code}).`)));
|
|
@@ -703,7 +703,10 @@ function describeGateAcceptanceConflict(gate, acceptance) {
|
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
function validateRunCall(key, params, label, fingerprints) {
|
|
706
|
-
if (typeof key !== "string" || !runKeyPattern.test(key))
|
|
706
|
+
if (typeof key !== "string" || !runKeyPattern.test(key)) {
|
|
707
|
+
const problem = key === undefined ? " has no key" : typeof key === "string" ? " has an invalid key '" + (key.length > 80 ? key.slice(0, 80) + "..." : key) + "'" : " has a key of type " + (key === null ? "null" : typeof key);
|
|
708
|
+
throw new Error(label + problem + "; keys must be 1-128 characters using letters, numbers, '.', '_' or '-', and start with a letter or number.");
|
|
709
|
+
}
|
|
707
710
|
if (hostKeys.has(key)) throw new Error("Workflow key '" + key + "' is already used by runs.host.");
|
|
708
711
|
if (!params || typeof params !== "object" || Array.isArray(params)) throw new Error(label + " requires a params object.");
|
|
709
712
|
if (Object.prototype.hasOwnProperty.call(params, "action") || Object.prototype.hasOwnProperty.call(params, "workflowScript") || Object.prototype.hasOwnProperty.call(params, "globalConcurrencyLimit") || Object.prototype.hasOwnProperty.call(params, "maxSubagentSpawnsPerRun") || Object.prototype.hasOwnProperty.call(params, "tasks") || Object.prototype.hasOwnProperty.call(params, "chain") || Object.prototype.hasOwnProperty.call(params, "parallel") || Object.prototype.hasOwnProperty.call(params, "concurrency") || Object.prototype.hasOwnProperty.call(params, "chainDir")) {
|