@barnum/barnum 0.0.0-main-04a1bb17 → 0.2.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.
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "title": "ConfigFile",
4
- "description": "Top-level Barnum configuration file format.\n\nDefines a workflow as a directed graph of steps. Each step processes tasks and can spawn follow-up tasks on other steps.",
4
+ "description": "Top-level Barnum configuration file format.\n\nThis is the raw parsed format. Call `resolve()` to get the runtime `Config`.",
5
5
  "type": "object",
6
6
  "required": [
7
7
  "steps"
8
8
  ],
9
9
  "properties": {
10
10
  "$schema": {
11
- "description": "Optional JSON Schema URL for editor validation (e.g., `\"./node_modules/@barnum/barnum/barnum-config-schema.json\"`). Ignored at runtime.",
11
+ "description": "JSON Schema reference for editor validation (ignored at runtime).",
12
12
  "writeOnly": true,
13
13
  "type": [
14
14
  "string",
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "entrypoint": {
19
- "description": "Name of the step that starts the workflow. When set, the CLI accepts `--entrypoint-value` to provide the initial task value (defaults to `{}`). When omitted, `--initial-state` must provide explicit `[{\"kind\": \"StepName\", \"value\": ...}]` tasks.",
19
+ "description": "Entry point step name. If specified, the workflow starts with this step and `--entrypoint-value` can be used to provide the initial value (defaults to `{}`). If not specified, `--initial-state` must be provided on the command line.",
20
20
  "default": null,
21
21
  "type": [
22
22
  "string",
@@ -24,7 +24,7 @@
24
24
  ]
25
25
  },
26
26
  "options": {
27
- "description": "Global runtime options (timeout, retries, concurrency). Individual steps can override these via their own `options` field.",
27
+ "description": "Runtime options.",
28
28
  "default": {
29
29
  "max_concurrency": null,
30
30
  "max_retries": 0,
@@ -39,7 +39,7 @@
39
39
  ]
40
40
  },
41
41
  "steps": {
42
- "description": "The steps that make up this workflow. Each step defines how to process a task and which steps it can spawn follow-up tasks on.",
42
+ "description": "Step definitions forming the task queue.",
43
43
  "type": "array",
44
44
  "items": {
45
45
  "$ref": "#/definitions/StepFile"
@@ -49,18 +49,20 @@
49
49
  "additionalProperties": false,
50
50
  "definitions": {
51
51
  "ActionFile": {
52
- "description": "How a step processes tasks. Set `\"kind\": \"Pool\"` to send tasks to AI agents, or `\"kind\": \"Command\"` to run a local shell script.",
52
+ "description": "How a step processes tasks (config file format).",
53
53
  "oneOf": [
54
54
  {
55
- "description": "Send the task to the agent pool. An AI agent receives the task's `value` along with the `instructions` (markdown prompt) and produces a JSON array of follow-up tasks.",
55
+ "description": "Send to the agent pool for processing.",
56
56
  "type": "object",
57
57
  "required": [
58
- "instructions",
59
58
  "kind"
60
59
  ],
61
60
  "properties": {
62
61
  "instructions": {
63
- "description": "Markdown prompt shown to the agent processing this task. This is the core of what tells the agent what to do. Use `{\"inline\": \"...\"}` to write the markdown directly, or `{\"link\": \"path/to/file.md\"}` to reference an external file.",
62
+ "description": "Markdown instructions shown to agents.",
63
+ "default": {
64
+ "inline": ""
65
+ },
64
66
  "allOf": [
65
67
  {
66
68
  "$ref": "#/definitions/MaybeLinked_for_String"
@@ -76,7 +78,7 @@
76
78
  }
77
79
  },
78
80
  {
79
- "description": "Run a local shell command instead of sending to an agent. Use this for deterministic transformations, fan-out, or glue logic.",
81
+ "description": "Run a local command.",
80
82
  "type": "object",
81
83
  "required": [
82
84
  "kind",
@@ -90,32 +92,7 @@
90
92
  ]
91
93
  },
92
94
  "script": {
93
- "description": "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.",
94
- "type": "string"
95
- }
96
- }
97
- }
98
- ]
99
- },
100
- "FinallyHook": {
101
- "description": "Finally hook. Runs after a task and all its descendants complete.\n\nIn JSON: `{\"kind\": \"Command\", \"script\": \"./finally-hook.sh\"}`\n\n**stdin:** The task's original value payload as JSON. **stdout:** JSON array of follow-up tasks: `[{\"kind\": \"StepName\", \"value\": {...}}, ...]`. Return `[]` for no follow-ups.",
102
- "oneOf": [
103
- {
104
- "description": "Run a shell command as the finally hook.",
105
- "type": "object",
106
- "required": [
107
- "kind",
108
- "script"
109
- ],
110
- "properties": {
111
- "kind": {
112
- "type": "string",
113
- "enum": [
114
- "Command"
115
- ]
116
- },
117
- "script": {
118
- "description": "Shell script to execute. Receives the task's original value as JSON on stdin, must write a JSON array of follow-up tasks on stdout.",
95
+ "description": "Shell script to execute.\n\n**Input (stdin):** JSON object with the structure `{\"kind\": \"<step name>\", \"value\": <parameters>}`. Use `jq '.value'` to extract parameters or `jq -r '.value.fieldName'` for specific fields.\n\n**Output (stdout):** JSON array of next tasks, e.g. `[{\"kind\": \"NextStep\", \"value\": {...}}]`. Return `[]` to spawn no follow-up tasks.",
119
96
  "type": "string"
120
97
  }
121
98
  }
@@ -123,7 +100,7 @@
123
100
  ]
124
101
  },
125
102
  "MaybeLinked_for_String": {
126
- "description": "Content that can be inline or linked to a file.\n\nIn config files: - `{\"inline\": <value>}` → content provided directly in the config - `{\"link\": \"path\"}` → content loaded from a file (path relative to the config file)",
103
+ "description": "Content that can be inline or linked to a file.\n\nIn config files: - `{\"inline\": <value>}` → inline content - `{\"link\": \"path\"}` → link to file",
127
104
  "anyOf": [
128
105
  {
129
106
  "description": "Inline content.",
@@ -133,20 +110,20 @@
133
110
  ],
134
111
  "properties": {
135
112
  "inline": {
136
- "description": "The content value, provided directly in the config file.",
113
+ "description": "The inline content.",
137
114
  "type": "string"
138
115
  }
139
116
  }
140
117
  },
141
118
  {
142
- "description": "Link to a file whose contents will be loaded at runtime.",
119
+ "description": "Link to a file.",
143
120
  "type": "object",
144
121
  "required": [
145
122
  "link"
146
123
  ],
147
124
  "properties": {
148
125
  "link": {
149
- "description": "Relative path to the file (resolved relative to the config file's directory).",
126
+ "description": "Path to the file.",
150
127
  "type": "string"
151
128
  }
152
129
  }
@@ -154,7 +131,7 @@
154
131
  ]
155
132
  },
156
133
  "Options": {
157
- "description": "Global runtime options for task execution. All fields have sensible defaults.",
134
+ "description": "Runtime options for task execution.",
158
135
  "type": "object",
159
136
  "properties": {
160
137
  "max_concurrency": {
@@ -197,87 +174,42 @@
197
174
  },
198
175
  "additionalProperties": false
199
176
  },
200
- "PostHook": {
201
- "description": "Post-action hook. Inspects or modifies the action's outcome.\n\nIn JSON: `{\"kind\": \"Command\", \"script\": \"./post-hook.sh\"}`\n\n**stdin:** Tagged JSON describing the outcome (`\"kind\": \"Success\"`, `\"Timeout\"`, `\"Error\"`, or `\"PreHookError\"`). On success, includes an `input`, `output`, and `next` (follow-up tasks) field. **stdout:** Same tagged JSON, possibly modified (e.g., filtering `next`).",
202
- "oneOf": [
203
- {
204
- "description": "Run a shell command as the post hook.",
205
- "type": "object",
206
- "required": [
207
- "kind",
208
- "script"
209
- ],
210
- "properties": {
211
- "kind": {
212
- "type": "string",
213
- "enum": [
214
- "Command"
215
- ]
216
- },
217
- "script": {
218
- "description": "Shell script to execute. Receives the action outcome as JSON on stdin, must write the (possibly modified) outcome as JSON on stdout.",
219
- "type": "string"
220
- }
221
- }
222
- }
223
- ]
224
- },
225
- "PreHook": {
226
- "description": "Pre-action hook. Transforms the task value before the action runs.\n\nIn JSON: `{\"kind\": \"Command\", \"script\": \"./pre-hook.sh\"}`\n\n**stdin:** Task value payload (e.g., `{\"path\": \"/src\"}`). **stdout:** Modified value payload (same shape).",
227
- "oneOf": [
228
- {
229
- "description": "Run a shell command as the pre hook.",
230
- "type": "object",
231
- "required": [
232
- "kind",
233
- "script"
234
- ],
235
- "properties": {
236
- "kind": {
237
- "type": "string",
238
- "enum": [
239
- "Command"
240
- ]
241
- },
242
- "script": {
243
- "description": "Shell script to execute. Receives the task's value as JSON on stdin, must write the (possibly modified) value as JSON on stdout.",
244
- "type": "string"
245
- }
246
- }
247
- }
248
- ]
249
- },
250
177
  "SchemaRef": {
251
- "description": "A JSON Schema for validating task payloads. Can be provided inline or loaded from a file.\n\n- Inline: write the JSON Schema object directly, e.g. `{\"type\": \"object\", \"properties\": {...}}` - Linked: `{\"link\": \"path/to/schema.json\"}` to reference an external file (path relative to config file)",
178
+ "description": "Reference to a JSON Schema (inline or external file).\n\nIn config files: - `{\"link\": \"path\"}` link to schema file - Object inline JSON Schema",
252
179
  "anyOf": [
253
180
  {
254
- "description": "Reference to an external JSON Schema file. The path is relative to the config file's directory.",
181
+ "description": "Link to a JSON Schema file.",
255
182
  "type": "object",
256
183
  "required": [
257
184
  "link"
258
185
  ],
259
186
  "properties": {
260
187
  "link": {
261
- "description": "Relative path to the JSON Schema file (e.g., `\"schemas/task.json\"`).",
188
+ "description": "Path to the schema file.",
262
189
  "type": "string"
263
190
  }
264
191
  }
265
192
  },
266
193
  {
267
- "description": "Inline JSON Schema object (any valid JSON Schema)."
194
+ "description": "Inline JSON Schema."
268
195
  }
269
196
  ]
270
197
  },
271
198
  "StepFile": {
272
- "description": "A named step in the workflow. Steps are the nodes of the task graph.\n\nExecution order for each task: `pre` hook → `action` → `post` hook. The `finally` hook runs after the task **and all of its descendant tasks** complete.",
199
+ "description": "A step in the config file (may have unresolved references).",
273
200
  "type": "object",
274
201
  "required": [
275
- "action",
276
202
  "name"
277
203
  ],
278
204
  "properties": {
279
205
  "action": {
280
- "description": "How this step processes tasks — either send to the agent pool (`Pool`) or run a local shell command (`Command`).",
206
+ "description": "How to execute the step.",
207
+ "default": {
208
+ "instructions": {
209
+ "inline": ""
210
+ },
211
+ "kind": "Pool"
212
+ },
281
213
  "allOf": [
282
214
  {
283
215
  "$ref": "#/definitions/ActionFile"
@@ -285,23 +217,19 @@
285
217
  ]
286
218
  },
287
219
  "finally": {
288
- "description": "Shell script that runs after this task **and all tasks it spawned (recursively)** have completed.\n\n**stdin:** The task's original `value` payload as JSON (same as what the pre hook received — just the value, not the full task wrapper).\n\n**stdout:** A JSON array of follow-up tasks to spawn: `[{\"kind\": \"StepName\", \"value\": {...}}, ...]`. Each `kind` must be a valid step name. Return `[]` to spawn no follow-ups.\n\nUse this for cleanup, aggregation, or spawning a final summarization step after an entire subtree of work completes.",
220
+ "description": "Finally hook (runs after all children complete).",
289
221
  "default": null,
290
- "anyOf": [
291
- {
292
- "$ref": "#/definitions/FinallyHook"
293
- },
294
- {
295
- "type": "null"
296
- }
222
+ "type": [
223
+ "string",
224
+ "null"
297
225
  ]
298
226
  },
299
227
  "name": {
300
- "description": "Unique name for this step (e.g., `\"Analyze\"`, `\"Implement\"`, `\"Review\"`). This is the string used as `kind` when creating tasks: `{\"kind\": \"ThisStepName\", \"value\": {...}}`.",
228
+ "description": "Step name (e.g., `Analyze`, `Implement`).",
301
229
  "type": "string"
302
230
  },
303
231
  "next": {
304
- "description": "Step names this step is allowed to spawn follow-up tasks on. Each string must match the `name` of another step in this config. An empty array means this is a terminal step (no follow-ups).",
232
+ "description": "Valid next steps.",
305
233
  "default": [],
306
234
  "type": "array",
307
235
  "items": {
@@ -309,7 +237,7 @@
309
237
  }
310
238
  },
311
239
  "options": {
312
- "description": "Per-step options that override the global `options`. Only the fields you set here take effect; everything else falls through to the global defaults.",
240
+ "description": "Per-step options that override global options.",
313
241
  "default": {
314
242
  "max_retries": null,
315
243
  "retry_on_invalid_response": null,
@@ -323,31 +251,23 @@
323
251
  ]
324
252
  },
325
253
  "post": {
326
- "description": "Shell script that runs **after** the action completes (or fails).\n\n**stdin:** A tagged JSON object describing the outcome. The `kind` field indicates what happened:\n\n- `{\"kind\": \"Success\", \"input\": <value>, \"output\": <agent_output>, \"next\": [<tasks>]}` — Action succeeded. `next` contains the follow-up tasks to spawn. - `{\"kind\": \"Timeout\", \"input\": <value>}` — Action timed out. - `{\"kind\": \"Error\", \"input\": <value>, \"error\": \"<message>\"}` — Action failed. - `{\"kind\": \"PreHookError\", \"input\": <value>, \"error\": \"<message>\"}` — Pre hook failed.\n\n**stdout:** The same tagged JSON object, possibly modified. Typically you modify the `next` array in `Success` to filter, rewrite, or add follow-up tasks.",
254
+ "description": "Post-execution hook script.",
327
255
  "default": null,
328
- "anyOf": [
329
- {
330
- "$ref": "#/definitions/PostHook"
331
- },
332
- {
333
- "type": "null"
334
- }
256
+ "type": [
257
+ "string",
258
+ "null"
335
259
  ]
336
260
  },
337
261
  "pre": {
338
- "description": "Shell script that runs **before** the action.\n\n**stdin:** The task's `value` payload as JSON (e.g., `{\"path\": \"/src\"}`). This is just the value — not the full `{\"kind\": ..., \"value\": ...}` wrapper.\n\n**stdout:** The (possibly modified) value payload as JSON. Must be the same shape. The modified value is what the action receives.\n\nUse this to enrich or transform the task before the action sees it (e.g., adding timestamps, resolving paths, fetching metadata).",
262
+ "description": "Pre-execution hook script.",
339
263
  "default": null,
340
- "anyOf": [
341
- {
342
- "$ref": "#/definitions/PreHook"
343
- },
344
- {
345
- "type": "null"
346
- }
264
+ "type": [
265
+ "string",
266
+ "null"
347
267
  ]
348
268
  },
349
269
  "value_schema": {
350
- "description": "JSON Schema that validates the `value` payload for tasks on this step. When set, tasks whose `value` doesn't conform are rejected. When omitted, any JSON value is accepted.",
270
+ "description": "JSON Schema for validating the step's value payload. None means any JSON value is accepted.",
351
271
  "default": null,
352
272
  "anyOf": [
353
273
  {
@@ -362,11 +282,11 @@
362
282
  "additionalProperties": false
363
283
  },
364
284
  "StepOptions": {
365
- "description": "Per-step option overrides. Only set the fields you want to override; omitted fields inherit from the global `options`.",
285
+ "description": "Per-step options that override global defaults.",
366
286
  "type": "object",
367
287
  "properties": {
368
288
  "max_retries": {
369
- "description": "Maximum retries for tasks on this step (overrides global `max_retries`).",
289
+ "description": "Maximum retries for this step (overrides global).",
370
290
  "default": null,
371
291
  "type": [
372
292
  "integer",
@@ -376,7 +296,7 @@
376
296
  "minimum": 0.0
377
297
  },
378
298
  "retry_on_invalid_response": {
379
- "description": "Whether to retry when an agent returns an invalid response on this step (overrides global `retry_on_invalid_response`).",
299
+ "description": "Whether to retry on invalid response for this step (overrides global).",
380
300
  "default": null,
381
301
  "type": [
382
302
  "boolean",
@@ -384,7 +304,7 @@
384
304
  ]
385
305
  },
386
306
  "retry_on_timeout": {
387
- "description": "Whether to retry when an agent times out on this step (overrides global `retry_on_timeout`).",
307
+ "description": "Whether to retry on timeout for this step (overrides global).",
388
308
  "default": null,
389
309
  "type": [
390
310
  "boolean",
@@ -392,7 +312,7 @@
392
312
  ]
393
313
  },
394
314
  "timeout": {
395
- "description": "Timeout in seconds for tasks on this step (overrides global `timeout`).",
315
+ "description": "Timeout in seconds for this step (overrides global).",
396
316
  "default": null,
397
317
  "type": [
398
318
  "integer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barnum/barnum",
3
- "version": "0.0.0-main-04a1bb17",
3
+ "version": "0.2.0",
4
4
  "description": "Barnum CLI - workflow engine for agents.",
5
5
  "main": "index.js",
6
6
  "bin": {