@barnum/barnum 0.0.0-main-20fffb47 → 0.0.0-main-eb8c5afe

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
@@ -52,7 +52,7 @@
52
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.",
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 the task to the agent pool for processing.",
56
56
  "type": "object",
57
57
  "required": [
58
58
  "instructions",
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  {
79
- "description": "Run a local shell command instead of sending to an agent. Use this for deterministic transformations, fan-out, or glue logic.",
79
+ "description": "Run a local shell command.",
80
80
  "type": "object",
81
81
  "required": [
82
82
  "kind",
@@ -115,7 +115,7 @@
115
115
  ]
116
116
  },
117
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.",
118
+ "description": "Shell script to execute.",
119
119
  "type": "string"
120
120
  }
121
121
  }
@@ -211,71 +211,29 @@
211
211
  },
212
212
  "additionalProperties": false
213
213
  },
214
- "PostHook": {
215
- "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`).",
216
- "oneOf": [
217
- {
218
- "description": "Run a shell command as the post hook.",
219
- "type": "object",
220
- "required": [
221
- "kind",
222
- "script"
223
- ],
224
- "properties": {
225
- "kind": {
226
- "type": "string",
227
- "enum": [
228
- "Command"
229
- ]
230
- },
231
- "script": {
232
- "description": "Shell script to execute. Receives the action outcome as JSON on stdin, must write the (possibly modified) outcome as JSON on stdout.",
233
- "type": "string"
234
- }
235
- }
236
- }
237
- ]
238
- },
239
- "PreHook": {
240
- "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).",
241
- "oneOf": [
242
- {
243
- "description": "Run a shell command as the pre hook.",
244
- "type": "object",
245
- "required": [
246
- "kind",
247
- "script"
248
- ],
249
- "properties": {
250
- "kind": {
251
- "type": "string",
252
- "enum": [
253
- "Command"
254
- ]
255
- },
256
- "script": {
257
- "description": "Shell script to execute. Receives the task's value as JSON on stdin, must write the (possibly modified) value as JSON on stdout.",
258
- "type": "string"
259
- }
260
- }
214
+ "SchemaLink": {
215
+ "description": "Reference to an external JSON Schema file.",
216
+ "type": "object",
217
+ "required": [
218
+ "link"
219
+ ],
220
+ "properties": {
221
+ "link": {
222
+ "description": "Relative path to the JSON Schema file (e.g., `\"schemas/task.json\"`).",
223
+ "type": "string"
261
224
  }
262
- ]
225
+ }
263
226
  },
264
227
  "SchemaRef": {
265
228
  "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 load from a file (path relative to config file)",
266
229
  "anyOf": [
267
230
  {
268
231
  "description": "Reference to an external JSON Schema file. The path is relative to the config file's directory.",
269
- "type": "object",
270
- "required": [
271
- "link"
272
- ],
273
- "properties": {
274
- "link": {
275
- "description": "Relative path to the JSON Schema file (e.g., `\"schemas/task.json\"`).",
276
- "type": "string"
232
+ "allOf": [
233
+ {
234
+ "$ref": "#/definitions/SchemaLink"
277
235
  }
278
- }
236
+ ]
279
237
  },
280
238
  {
281
239
  "description": "Inline JSON Schema object (any valid JSON Schema)."
@@ -283,7 +241,7 @@
283
241
  ]
284
242
  },
285
243
  "StepFile": {
286
- "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.",
244
+ "description": "A named step in the workflow. Steps are the nodes of the task graph.\n\nThe `finally` hook runs after the task **and all of its descendant tasks** complete.",
287
245
  "type": "object",
288
246
  "required": [
289
247
  "action",
@@ -336,30 +294,6 @@
336
294
  }
337
295
  ]
338
296
  },
339
- "post": {
340
- "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.",
341
- "default": null,
342
- "anyOf": [
343
- {
344
- "$ref": "#/definitions/PostHook"
345
- },
346
- {
347
- "type": "null"
348
- }
349
- ]
350
- },
351
- "pre": {
352
- "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).",
353
- "default": null,
354
- "anyOf": [
355
- {
356
- "$ref": "#/definitions/PreHook"
357
- },
358
- {
359
- "type": "null"
360
- }
361
- ]
362
- },
363
297
  "value_schema": {
364
298
  "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.",
365
299
  "default": null,
@@ -15,17 +15,17 @@ const ActionFile = z.discriminatedUnion("kind", [
15
15
  z.object({
16
16
  instructions: MaybeLinked_for_String.describe("Markdown prompt shown to the agent processing this task. This is the core of what tells the agent what to do. Use `{\"kind\": \"Inline\", \"value\": \"...\"}` to write the markdown directly, or `{\"kind\": \"Link\", \"path\": \"path/to/file.md\"}` to reference an external file."),
17
17
  kind: z.literal("Pool"),
18
- }).describe("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."),
18
+ }).describe("Send the task to the agent pool for processing."),
19
19
  z.object({
20
20
  kind: z.literal("Command"),
21
21
  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."),
22
- }).describe("Run a local shell command instead of sending to an agent. Use this for deterministic transformations, fan-out, or glue logic."),
22
+ }).describe("Run a local shell command."),
23
23
  ]).describe("How a step processes tasks. Set `\"kind\": \"Pool\"` to send tasks to AI agents, or `\"kind\": \"Command\"` to run a local shell script.");
24
24
 
25
25
  const FinallyHook = z.discriminatedUnion("kind", [
26
26
  z.object({
27
27
  kind: z.literal("Command"),
28
- script: z.string().describe("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."),
28
+ script: z.string().describe("Shell script to execute."),
29
29
  }).describe("Run a shell command as the finally hook."),
30
30
  ]).describe("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.");
31
31
 
@@ -37,24 +37,12 @@ const Options = z.object({
37
37
  timeout: z.number().int().nonnegative().nullable().optional().default(null).describe("Timeout in seconds for each task (None = no timeout)."),
38
38
  }).strict().describe("Global runtime options for task execution. All fields have sensible defaults.");
39
39
 
40
- const PostHook = z.discriminatedUnion("kind", [
41
- z.object({
42
- kind: z.literal("Command"),
43
- script: z.string().describe("Shell script to execute. Receives the action outcome as JSON on stdin, must write the (possibly modified) outcome as JSON on stdout."),
44
- }).describe("Run a shell command as the post hook."),
45
- ]).describe("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`).");
46
-
47
- const PreHook = z.discriminatedUnion("kind", [
48
- z.object({
49
- kind: z.literal("Command"),
50
- script: z.string().describe("Shell script to execute. Receives the task's value as JSON on stdin, must write the (possibly modified) value as JSON on stdout."),
51
- }).describe("Run a shell command as the pre hook."),
52
- ]).describe("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).");
40
+ const SchemaLink = z.object({
41
+ link: z.string().describe("Relative path to the JSON Schema file (e.g., `\"schemas/task.json\"`)."),
42
+ }).describe("Reference to an external JSON Schema file.");
53
43
 
54
44
  const SchemaRef = z.union([
55
- z.object({
56
- link: z.string().describe("Relative path to the JSON Schema file (e.g., `\"schemas/task.json\"`)."),
57
- }).describe("Reference to an external JSON Schema file. The path is relative to the config file's directory."),
45
+ SchemaLink.describe("Reference to an external JSON Schema file. The path is relative to the config file's directory."),
58
46
  z.any().describe("Inline JSON Schema object (any valid JSON Schema)."),
59
47
  ]).describe("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 load from a file (path relative to config file)");
60
48
 
@@ -71,10 +59,8 @@ const StepFile = z.object({
71
59
  name: z.string().describe("Unique name for this step (e.g., `\"Analyze\"`, `\"Implement\"`, `\"Review\"`). This is the string used as `kind` when creating tasks: `{\"kind\": \"ThisStepName\", \"value\": {...}}`."),
72
60
  next: z.array(z.string()).optional().default([]).describe("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)."),
73
61
  options: StepOptions.optional().default({"max_retries": null, "retry_on_invalid_response": null, "retry_on_timeout": null, "timeout": null}).describe("Per-step options that override the global `options`. Only the fields you set here take effect; everything else falls through to the global defaults."),
74
- post: PostHook.nullable().optional().default(null).describe("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."),
75
- pre: PreHook.nullable().optional().default(null).describe("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)."),
76
62
  value_schema: SchemaRef.nullable().optional().default(null).describe("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."),
77
- }).strict().describe("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.");
63
+ }).strict().describe("A named step in the workflow. Steps are the nodes of the task graph.\n\nThe `finally` hook runs after the task **and all of its descendant tasks** complete.");
78
64
 
79
65
  export const configFileSchema = z.object({
80
66
  "$schema": z.string().nullable().optional().describe("Optional JSON Schema URL for editor validation (e.g., `\"./node_modules/@barnum/barnum/barnum-config-schema.json\"`). Ignored at runtime."),
@@ -88,8 +74,7 @@ export type MaybeLinked_for_String = z.infer<typeof MaybeLinked_for_String>;
88
74
  export type ActionFile = z.infer<typeof ActionFile>;
89
75
  export type FinallyHook = z.infer<typeof FinallyHook>;
90
76
  export type Options = z.infer<typeof Options>;
91
- export type PostHook = z.infer<typeof PostHook>;
92
- export type PreHook = z.infer<typeof PreHook>;
77
+ export type SchemaLink = z.infer<typeof SchemaLink>;
93
78
  export type SchemaRef = z.infer<typeof SchemaRef>;
94
79
  export type StepOptions = z.infer<typeof StepOptions>;
95
80
  export type StepFile = z.infer<typeof StepFile>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barnum/barnum",
3
- "version": "0.0.0-main-20fffb47",
3
+ "version": "0.0.0-main-eb8c5afe",
4
4
  "type": "module",
5
5
  "description": "Barnum CLI - workflow engine for agents.",
6
6
  "main": "index.ts",