@barnum/barnum 0.0.0-main-5a6a8bee → 0.0.0-main-630ee5dd
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/actions/run-handler.ts +1 -0
- package/artifacts/linux-arm64/barnum +0 -0
- package/artifacts/linux-x64/barnum +0 -0
- package/artifacts/macos-arm64/barnum +0 -0
- package/artifacts/macos-x64/barnum +0 -0
- package/artifacts/win-x64/barnum.exe +0 -0
- package/barnum-cli-schema.zod.ts +2 -1
- package/barnum-config-schema.json +29 -0
- package/barnum-config-schema.zod.ts +6 -0
- package/cli.cjs +9 -5
- package/package.json +3 -2
- package/run.ts +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Placeholder: will be implemented by ADD_RUN_HANDLER refactor.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/barnum-cli-schema.zod.ts
CHANGED
|
@@ -28,11 +28,12 @@ const Command = z.discriminatedUnion("kind", [
|
|
|
28
28
|
z.object({
|
|
29
29
|
config: z.string().nullable().optional().describe("Config (JSON string or path to file). Required unless `--resume-from` is used."),
|
|
30
30
|
entrypointValue: z.string().nullable().optional().describe("Initial value for the entrypoint step (JSON string or path to file). Only valid when config has an `entrypoint`. Defaults to `{}` if not provided."),
|
|
31
|
-
executor: z.string().
|
|
31
|
+
executor: z.string().describe("Executor command for TypeScript handlers, injected by cli.cjs and run.ts."),
|
|
32
32
|
initialState: z.string().nullable().optional().describe("Initial tasks (JSON string or path to file). Required if config has no `entrypoint`. Cannot be used with `--entrypoint-value`."),
|
|
33
33
|
kind: z.literal("Run"),
|
|
34
34
|
logFile: z.string().nullable().optional().describe("Log file path (logs emitted in addition to stderr)"),
|
|
35
35
|
resumeFrom: z.string().nullable().optional().describe("Resume from a previous state log file. Incompatible with `--config`, `--initial-state`, and `--entrypoint-value`."),
|
|
36
|
+
runHandlerPath: z.string().describe("Path to run-handler.ts, injected by cli.cjs and run.ts."),
|
|
36
37
|
stateLog: z.string().nullable().optional().describe("State log file path (NDJSON file for persistence/resume)"),
|
|
37
38
|
wake: z.string().nullable().optional().describe("Wake script to call before starting"),
|
|
38
39
|
}).describe("Run the task queue"),
|
|
@@ -62,6 +62,35 @@
|
|
|
62
62
|
"type": "string"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"description": "Run a TypeScript handler.",
|
|
68
|
+
"type": "object",
|
|
69
|
+
"required": [
|
|
70
|
+
"kind",
|
|
71
|
+
"path"
|
|
72
|
+
],
|
|
73
|
+
"properties": {
|
|
74
|
+
"exportedAs": {
|
|
75
|
+
"description": "Named export to invoke from the handler module.",
|
|
76
|
+
"default": "default",
|
|
77
|
+
"type": "string"
|
|
78
|
+
},
|
|
79
|
+
"kind": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"enum": [
|
|
82
|
+
"TypeScript"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"path": {
|
|
86
|
+
"description": "Path to the handler file (absolute — JS layer resolves before passing to Rust).",
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"stepConfig": {
|
|
90
|
+
"description": "Step configuration passed through to the handler. Rust stores this as-is and includes it in the envelope.",
|
|
91
|
+
"default": null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
65
94
|
}
|
|
66
95
|
]
|
|
67
96
|
},
|
|
@@ -5,6 +5,12 @@ const ActionKind = z.discriminatedUnion("kind", [
|
|
|
5
5
|
kind: z.literal("Bash"),
|
|
6
6
|
script: z.string().describe("Shell script to execute.\n\n**Input (stdin):** JSON object: `{\"kind\": \"<step name>\", \"value\": <payload>}`. Use `jq '.value'` to extract the payload, or `jq -r '.value.fieldName'` for a specific field.\n\n**Output (stdout):** JSON array of follow-up tasks to spawn: `[{\"kind\": \"NextStep\", \"value\": {...}}, ...]`. Each `kind` must be a step name listed in this step's `next` array. Return `[]` to spawn no follow-ups."),
|
|
7
7
|
}).describe("Run a shell command."),
|
|
8
|
+
z.object({
|
|
9
|
+
exportedAs: z.string().optional().default("default").describe("Named export to invoke from the handler module."),
|
|
10
|
+
kind: z.literal("TypeScript"),
|
|
11
|
+
path: z.string().describe("Path to the handler file (absolute — JS layer resolves before passing to Rust)."),
|
|
12
|
+
stepConfig: z.any().optional().default(null).describe("Step configuration passed through to the handler. Rust stores this as-is and includes it in the envelope."),
|
|
13
|
+
}).describe("Run a TypeScript handler."),
|
|
8
14
|
]).describe("How a step processes tasks.");
|
|
9
15
|
|
|
10
16
|
const FinallyHook = z.discriminatedUnion("kind", [
|
package/cli.cjs
CHANGED
|
@@ -23,14 +23,18 @@ if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// --executor
|
|
26
|
+
// --executor and --run-handler-path are internal. Error if the user passed them directly.
|
|
27
27
|
var userArgs = process.argv.slice(2);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
var internalFlags = ['--executor', '--run-handler-path'];
|
|
29
|
+
for (var flag of internalFlags) {
|
|
30
|
+
if (userArgs.includes(flag)) {
|
|
31
|
+
console.error('Error: ' + flag + ' is an internal flag and cannot be passed directly.');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
var executorPath = path.resolve(__dirname, 'actions', 'executor.ts');
|
|
37
|
+
var runHandlerPath = path.resolve(__dirname, 'actions', 'run-handler.ts');
|
|
34
38
|
|
|
35
39
|
function resolveExecutorCommand() {
|
|
36
40
|
if (typeof Bun !== 'undefined') {
|
|
@@ -43,7 +47,7 @@ function resolveExecutorCommand() {
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
var executor = resolveExecutorCommand();
|
|
46
|
-
var args = userArgs.concat('--executor', executor);
|
|
50
|
+
var args = userArgs.concat('--executor', executor, '--run-handler-path', runHandlerPath);
|
|
47
51
|
|
|
48
52
|
try {
|
|
49
53
|
chmodSync(bin, 0o755);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barnum/barnum",
|
|
3
|
-
"version": "0.0.0-main-
|
|
3
|
+
"version": "0.0.0-main-630ee5dd",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Barnum CLI - workflow engine for agents.",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"barnum-config-schema.json",
|
|
40
40
|
"barnum-config-schema.zod.ts",
|
|
41
41
|
"barnum-cli-schema.zod.ts",
|
|
42
|
-
"run.ts"
|
|
42
|
+
"run.ts",
|
|
43
|
+
"actions/**/*.ts"
|
|
43
44
|
],
|
|
44
45
|
"scripts": {
|
|
45
46
|
"typecheck": "tsc --noEmit"
|
package/run.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { spawn, type ChildProcess } from "node:child_process";
|
|
2
2
|
import { chmodSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
4
6
|
import { configSchema } from "./barnum-config-schema.zod.js";
|
|
5
7
|
import type { z } from "zod";
|
|
6
8
|
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
10
|
const require = createRequire(import.meta.url);
|
|
8
11
|
const binaryPath: string = process.env.BARNUM ?? require("./index.cjs");
|
|
9
12
|
|
|
13
|
+
function resolveExecutor(): string {
|
|
14
|
+
// @ts-expect-error Bun global
|
|
15
|
+
if (typeof Bun !== "undefined") {
|
|
16
|
+
return process.execPath;
|
|
17
|
+
}
|
|
18
|
+
// Resolve tsx from the calling script's node_modules
|
|
19
|
+
const callerRequire = createRequire(process.argv[1] || import.meta.url);
|
|
20
|
+
const tsxPath = callerRequire.resolve("tsx/cli");
|
|
21
|
+
return `node ${tsxPath}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const runHandlerPath = resolve(__dirname, "actions", "run-handler.ts");
|
|
25
|
+
|
|
10
26
|
function spawnBarnum(args: string[], cwd?: string): ChildProcess {
|
|
11
27
|
try {
|
|
12
28
|
chmodSync(binaryPath, 0o755);
|
|
@@ -44,6 +60,8 @@ export class BarnumConfig {
|
|
|
44
60
|
if (opts?.logFile) args.push("--log-file", opts.logFile);
|
|
45
61
|
if (opts?.stateLog) args.push("--state-log", opts.stateLog);
|
|
46
62
|
if (opts?.wake) args.push("--wake", opts.wake);
|
|
63
|
+
args.push("--executor", resolveExecutor());
|
|
64
|
+
args.push("--run-handler-path", runHandlerPath);
|
|
47
65
|
return spawnBarnum(args, opts?.cwd);
|
|
48
66
|
}
|
|
49
67
|
}
|