@barnum/barnum 0.0.0-main-bbc76251 → 0.0.0-main-9a5106ee
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/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/dist/index.d.ts +1 -1
- package/dist/run.d.ts +7 -1
- package/dist/run.js +16 -12
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/run.ts +27 -17
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TaggedUnion, OptionDef, ResultDef } from "./ast.js";
|
|
|
2
2
|
export * from "./ast.js";
|
|
3
3
|
export { constant, identity, drop, tag, merge, flatten, extractField, extractIndex, pick, dropResult, withResource, augment, tap, range, Option, Result, } from "./builtins.js";
|
|
4
4
|
export * from "./handler.js";
|
|
5
|
-
export { runPipeline } from "./run.js";
|
|
5
|
+
export { runPipeline, type RunPipelineOptions, type LogLevel } from "./run.js";
|
|
6
6
|
export { zodToCheckedJsonSchema } from "./schema.js";
|
|
7
7
|
export type Option<T> = TaggedUnion<OptionDef<T>>;
|
|
8
8
|
export type Result<TValue, TError> = TaggedUnion<ResultDef<TValue, TError>>;
|
package/dist/run.d.ts
CHANGED
|
@@ -3,5 +3,11 @@
|
|
|
3
3
|
* script, then spawns the workflow as a subprocess.
|
|
4
4
|
*/
|
|
5
5
|
import type { Action, ExtractOutput } from "./ast.js";
|
|
6
|
+
/** Log verbosity for the barnum engine runtime. Passed to the CLI's `--log-level`. */
|
|
7
|
+
export type LogLevel = "off" | "error" | "warn" | "info" | "debug" | "trace";
|
|
8
|
+
export interface RunPipelineOptions {
|
|
9
|
+
/** Engine log verbosity. Default: "off" (only handler stderr is visible). */
|
|
10
|
+
logLevel?: LogLevel;
|
|
11
|
+
}
|
|
6
12
|
/** Run a pipeline to completion. Returns the workflow's final output value. */
|
|
7
|
-
export declare function runPipeline<TPipeline extends Action>(pipeline: TPipeline, input?: unknown): Promise<ExtractOutput<TPipeline>>;
|
|
13
|
+
export declare function runPipeline<TPipeline extends Action>(pipeline: TPipeline, input?: unknown, options?: RunPipelineOptions): Promise<ExtractOutput<TPipeline>>;
|
package/dist/run.js
CHANGED
|
@@ -88,14 +88,14 @@ function buildBinary() {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
/** Run a pipeline to completion. Returns the workflow's final output value. */
|
|
91
|
-
export function runPipeline(pipeline, input) {
|
|
91
|
+
export function runPipeline(pipeline, input, options) {
|
|
92
92
|
const workflow = input === undefined
|
|
93
93
|
? pipeline
|
|
94
94
|
: chain(constant(input), pipeline);
|
|
95
|
-
return spawnBarnum({ workflow });
|
|
95
|
+
return spawnBarnum({ workflow }, options?.logLevel);
|
|
96
96
|
}
|
|
97
97
|
/** Spawn the barnum CLI with the given config. Returns the parsed final value from stdout. */
|
|
98
|
-
function spawnBarnum(config) {
|
|
98
|
+
function spawnBarnum(config, logLevel) {
|
|
99
99
|
const binaryResolution = resolveBinary();
|
|
100
100
|
if (binaryResolution.kind === "Local") {
|
|
101
101
|
buildBinary();
|
|
@@ -103,16 +103,20 @@ function spawnBarnum(config) {
|
|
|
103
103
|
const executor = resolveExecutor();
|
|
104
104
|
const worker = resolveWorker();
|
|
105
105
|
const configJson = JSON.stringify(config);
|
|
106
|
+
const cliArgs = [
|
|
107
|
+
"run",
|
|
108
|
+
"--config",
|
|
109
|
+
configJson,
|
|
110
|
+
"--executor",
|
|
111
|
+
executor,
|
|
112
|
+
"--worker",
|
|
113
|
+
worker,
|
|
114
|
+
];
|
|
115
|
+
if (logLevel) {
|
|
116
|
+
cliArgs.push("--log-level", logLevel);
|
|
117
|
+
}
|
|
106
118
|
return new Promise((resolve, reject) => {
|
|
107
|
-
const child = nodeSpawn(binaryResolution.path,
|
|
108
|
-
"run",
|
|
109
|
-
"--config",
|
|
110
|
-
configJson,
|
|
111
|
-
"--executor",
|
|
112
|
-
executor,
|
|
113
|
-
"--worker",
|
|
114
|
-
worker,
|
|
115
|
-
], {
|
|
119
|
+
const child = nodeSpawn(binaryResolution.path, cliArgs, {
|
|
116
120
|
stdio: ["inherit", "pipe", "inherit"],
|
|
117
121
|
});
|
|
118
122
|
const stdoutChunks = [];
|
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-9a5106ee",
|
|
4
4
|
"description": "Barnum workflow engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.7.0",
|
|
52
52
|
"vitest": "^3.0.0"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
54
|
+
"peerDependencies": {
|
|
55
55
|
"zod": "^4.3.6"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export {
|
|
|
20
20
|
Result,
|
|
21
21
|
} from "./builtins.js";
|
|
22
22
|
export * from "./handler.js";
|
|
23
|
-
export { runPipeline } from "./run.js";
|
|
23
|
+
export { runPipeline, type RunPipelineOptions, type LogLevel } from "./run.js";
|
|
24
24
|
export { zodToCheckedJsonSchema } from "./schema.js";
|
|
25
25
|
|
|
26
26
|
// Declaration merge: the explicit value exports of Option/Result from builtins
|
package/src/run.ts
CHANGED
|
@@ -12,6 +12,14 @@ import type { Action, Config, ExtractOutput, Pipeable } from "./ast.js";
|
|
|
12
12
|
import { chain } from "./chain.js";
|
|
13
13
|
import { constant } from "./builtins.js";
|
|
14
14
|
|
|
15
|
+
/** Log verbosity for the barnum engine runtime. Passed to the CLI's `--log-level`. */
|
|
16
|
+
export type LogLevel = "off" | "error" | "warn" | "info" | "debug" | "trace";
|
|
17
|
+
|
|
18
|
+
export interface RunPipelineOptions {
|
|
19
|
+
/** Engine log verbosity. Default: "off" (only handler stderr is visible). */
|
|
20
|
+
logLevel?: LogLevel;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
const __dirname = import.meta.dirname;
|
|
16
24
|
|
|
17
25
|
/** Resolve the TypeScript executor. Uses bun if the workflow was launched with bun, otherwise tsx. */
|
|
@@ -114,16 +122,17 @@ function buildBinary(): void {
|
|
|
114
122
|
export function runPipeline<TPipeline extends Action>(
|
|
115
123
|
pipeline: TPipeline,
|
|
116
124
|
input?: unknown,
|
|
125
|
+
options?: RunPipelineOptions,
|
|
117
126
|
): Promise<ExtractOutput<TPipeline>> {
|
|
118
127
|
const workflow =
|
|
119
128
|
input === undefined
|
|
120
129
|
? pipeline
|
|
121
130
|
: (chain(constant(input) as Pipeable, pipeline as Pipeable) as Action);
|
|
122
|
-
return spawnBarnum({ workflow });
|
|
131
|
+
return spawnBarnum({ workflow }, options?.logLevel);
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
/** Spawn the barnum CLI with the given config. Returns the parsed final value from stdout. */
|
|
126
|
-
function spawnBarnum<TOut>(config: Config): Promise<TOut> {
|
|
135
|
+
function spawnBarnum<TOut>(config: Config, logLevel?: LogLevel): Promise<TOut> {
|
|
127
136
|
const binaryResolution = resolveBinary();
|
|
128
137
|
if (binaryResolution.kind === "Local") {
|
|
129
138
|
buildBinary();
|
|
@@ -132,22 +141,23 @@ function spawnBarnum<TOut>(config: Config): Promise<TOut> {
|
|
|
132
141
|
const worker = resolveWorker();
|
|
133
142
|
const configJson = JSON.stringify(config);
|
|
134
143
|
|
|
144
|
+
const cliArgs = [
|
|
145
|
+
"run",
|
|
146
|
+
"--config",
|
|
147
|
+
configJson,
|
|
148
|
+
"--executor",
|
|
149
|
+
executor,
|
|
150
|
+
"--worker",
|
|
151
|
+
worker,
|
|
152
|
+
];
|
|
153
|
+
if (logLevel) {
|
|
154
|
+
cliArgs.push("--log-level", logLevel);
|
|
155
|
+
}
|
|
156
|
+
|
|
135
157
|
return new Promise<TOut>((resolve, reject) => {
|
|
136
|
-
const child = nodeSpawn(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"run",
|
|
140
|
-
"--config",
|
|
141
|
-
configJson,
|
|
142
|
-
"--executor",
|
|
143
|
-
executor,
|
|
144
|
-
"--worker",
|
|
145
|
-
worker,
|
|
146
|
-
],
|
|
147
|
-
{
|
|
148
|
-
stdio: ["inherit", "pipe", "inherit"],
|
|
149
|
-
},
|
|
150
|
-
);
|
|
158
|
+
const child = nodeSpawn(binaryResolution.path, cliArgs, {
|
|
159
|
+
stdio: ["inherit", "pipe", "inherit"],
|
|
160
|
+
});
|
|
151
161
|
|
|
152
162
|
const stdoutChunks: Buffer[] = [];
|
|
153
163
|
|