@parcha/agentrun-dsl 0.1.0-beta.11 → 0.1.0-beta.111

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.
Files changed (93) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +154 -15
  3. package/dist/author-references.d.ts +8 -0
  4. package/dist/author-references.js +8 -0
  5. package/dist/author.d.ts +13 -5
  6. package/dist/author.js +26 -14
  7. package/dist/authoring.js +5 -4
  8. package/dist/cli.js +19 -13
  9. package/dist/decision-provider.d.ts +166 -0
  10. package/dist/decision-provider.js +238 -0
  11. package/dist/decision-receipts.d.ts +159 -0
  12. package/dist/decision-receipts.js +93 -0
  13. package/dist/dry-run.d.ts +41 -1
  14. package/dist/dry-run.js +158 -27
  15. package/dist/evidence.d.ts +19 -0
  16. package/dist/evidence.js +63 -0
  17. package/dist/graph.d.ts +169 -0
  18. package/dist/graph.js +433 -0
  19. package/dist/index.d.ts +19 -10
  20. package/dist/index.js +16 -8
  21. package/dist/inspection.d.ts +5 -0
  22. package/dist/inspection.js +14 -1
  23. package/dist/job.d.ts +14 -0
  24. package/dist/job.js +5 -0
  25. package/dist/pattern-screen.d.ts +14 -0
  26. package/dist/pattern-screen.js +451 -0
  27. package/dist/predicates.d.ts +29 -0
  28. package/dist/predicates.js +62 -3
  29. package/dist/record.d.ts +4 -0
  30. package/dist/record.js +6 -0
  31. package/dist/recovery/binding.d.ts +10 -0
  32. package/dist/recovery/binding.js +44 -0
  33. package/dist/recovery/call-key.d.ts +9 -0
  34. package/dist/recovery/call-key.js +17 -0
  35. package/dist/recovery/canonical-hash.d.ts +7 -0
  36. package/dist/recovery/canonical-hash.js +22 -0
  37. package/dist/recovery/driver.d.ts +241 -0
  38. package/dist/recovery/driver.js +1333 -0
  39. package/dist/recovery/errors.d.ts +31 -0
  40. package/dist/recovery/errors.js +51 -0
  41. package/dist/recovery/execution-path.d.ts +53 -0
  42. package/dist/recovery/execution-path.js +167 -0
  43. package/dist/recovery/file-store.d.ts +7 -0
  44. package/dist/recovery/file-store.js +131 -0
  45. package/dist/recovery/frozen-snapshot.d.ts +274 -0
  46. package/dist/recovery/frozen-snapshot.js +187 -0
  47. package/dist/recovery/handoff-receipts.d.ts +7 -0
  48. package/dist/recovery/handoff-receipts.js +11 -0
  49. package/dist/recovery/index.d.ts +14 -0
  50. package/dist/recovery/index.js +13 -0
  51. package/dist/recovery/item-state.d.ts +48 -0
  52. package/dist/recovery/item-state.js +89 -0
  53. package/dist/recovery/journal.d.ts +28 -0
  54. package/dist/recovery/journal.js +139 -0
  55. package/dist/recovery/memory-store.d.ts +4 -0
  56. package/dist/recovery/memory-store.js +20 -0
  57. package/dist/recovery/store.d.ts +105 -0
  58. package/dist/recovery/store.js +6 -0
  59. package/dist/recovery/testing/conformance.d.ts +4 -0
  60. package/dist/recovery/testing/conformance.js +268 -0
  61. package/dist/recovery/testing/crash-points.d.ts +18 -0
  62. package/dist/recovery/testing/crash-points.js +43 -0
  63. package/dist/recovery/testing/crash-sweep.d.ts +65 -0
  64. package/dist/recovery/testing/crash-sweep.js +146 -0
  65. package/dist/recovery/testing/index.d.ts +3 -0
  66. package/dist/recovery/testing/index.js +4 -0
  67. package/dist/recovery/testing/preload.d.ts +1 -0
  68. package/dist/recovery/testing/preload.js +3 -0
  69. package/dist/recovery/transport-facts.d.ts +23 -0
  70. package/dist/recovery/transport-facts.js +46 -0
  71. package/dist/recovery/with-recovery.d.ts +50 -0
  72. package/dist/recovery/with-recovery.js +144 -0
  73. package/dist/submit-envelope.d.ts +9 -0
  74. package/dist/submit-envelope.js +44 -0
  75. package/dist/system-one.d.ts +37 -2
  76. package/dist/system-one.js +112 -18
  77. package/dist/testing/decision-provider.d.ts +32 -0
  78. package/dist/testing/decision-provider.js +183 -0
  79. package/dist/testing/index.d.ts +1 -0
  80. package/dist/testing/index.js +2 -0
  81. package/dist/vocabulary.d.ts +11 -3
  82. package/dist/vocabulary.js +19 -9
  83. package/dist/workflow-shape.d.ts +7 -0
  84. package/dist/workflow-shape.js +116 -70
  85. package/dist/workflow.d.ts +194 -16
  86. package/dist/workflow.js +1309 -452
  87. package/dist/zod-json-contract.js +6 -8
  88. package/package.json +27 -4
  89. package/schema/workflow.schema.json +366 -1
  90. package/skills/author/SKILL.md +6 -1
  91. package/skills/author/references/jev-decisions.md +50 -5
  92. package/skills/author/references/language.md +19 -14
  93. package/skills/author/references/sdk-authoring.md +2 -0
@@ -8,33 +8,33 @@ Deliver the complete JSON document the way your host asks; never deliver prose,
8
8
  ## Document
9
9
 
10
10
  A workflow is {"v":2,"name","schemas","input"?,"output","root"}.
11
- - `schemas` maps ids to inline JSON Schema objects. Every schema id a node, `input` or `output` names must exist there. Inside a schema, reference a catalog schema or an inline definition only as {"$ref":"#/definitions/<id>"}.
11
+ - `schemas` maps ids to inline JSON Schema objects. Every schema id a node, `input` or `output` names must exist there. Inside a schema, reference a catalog schema or an inline definition only as {"$ref":"#/definitions/<id>"}. A `pattern` must not backtrack exponentially: no repeat or optional part inside a repeat that can match the same text (`(a+)+`, `(a?a?)+`, `(\w+\s?)*`), no unbounded repeat of alternatives that start alike (`(a|ab)*`), no backreference; validation refuses one.
12
12
  - The input contract: the run starts from the input object and nothing else. `input.schemaId`, when present, is enforced before the first node. A node may read only input keys and keys an earlier node wrote.
13
13
  - `output.schemaId` validates the final value; `output.path` selects it from state and must name an input key or a key an earlier node wrote.
14
14
  - State is one object. Each step writes its result under one key: its `as`, or, for an agent, decide, extract or code node without `as`, its label. A report writes `report_markdown`. A code node without `as` that returns an object merges that object's top-level fields instead.
15
- - Keys that begin with `$` are engine-owned: `$host` (host state), `<as>$answers` (raw judge answers and confidences) and `<as>$verify` (verifier results). Read them; never write one. No `as` may begin with `$`, and neither may the label of an agent, decide, extract or code node without `as`.
16
- - `{dot.path}` placeholders are replaced from state in `state` maps (including `verify.state` and `ask.state`), call `args`, `input`, `env` and `produces`, a child workflow's `input`, and `escalate.summary`; `pick` and `sift` `describe` templates also see `{item...}`. A placeholder that is the whole string keeps its value's type. Every key a state map, call or child input interpolates must be produced upstream. `instructions`, `code` and `command` are literal and never interpolated.
15
+ - Keys that hold a `$` are engine-owned: `$host` (host state), `<as>$answers` (raw judge answers and confidences) and `<as>$verify` (verifier results). Read them; never write one. No `as` may hold a `$`, and neither may the label of an agent, decide, extract or code node without `as`.
16
+ - `{dot.path}` placeholders are replaced from state in `state` maps (including `verify.state` and `ask.state`), call `args`, `input`, `env` and `produces`, a child workflow's `input`, and `escalate.summary`; `pick` and `sift` `describe` templates also see `{item...}`. A placeholder that is the whole string keeps its value's type. Every key a state map, call or child input interpolates must be produced upstream, except through a whole-string placeholder marked optional, such as `"{draft?}"`: it is null while its path is absent (a loop's first pass, before the step that writes it ran), and the path's value once present. Only a whole string may be marked. `instructions`, `code` and `command` are literal and never interpolated.
17
17
 
18
18
  ## Node kinds
19
19
 
20
20
  This is the complete set. Each kind accepts exactly these fields; any other field is an error.
21
21
  - `chain`: `steps`
22
22
  - `code`: `label`, `code`, `as`
23
- - `agent`: `label`, `state`, `instructions`, `sopSection`, `out`, `as`, `requires`, `tools`, `effort`, `thinking`, `verify`, `tier`, `budget_usd`, `context`
23
+ - `agent`: `label`, `state`, `instructions`, `sopSection`, `out`, `as`, `requires`, `tools`, `effort`, `thinking`, `verify`, `tier`, `budget_usd`, `max_turns`, `context`
24
24
  - `decide`: `label`, `state`, `instructions`, `sopSection`, `out`, `as`, `requires`, `tools`, `effort`, `thinking`, `verify`, `tier`
25
25
  - `extract`: `label`, `state`, `instructions`, `sopSection`, `out`, `as`, `requires`, `tools`, `effort`, `thinking`, `verify`, `tier`
26
26
  - `report`: `label`, `state`, `instructions`, `sopSection`, `requires`, `tools`, `effort`, `thinking`
27
27
  - `artifact`: `label`, `state`, `type`, `path`, `instructions`, `sopSection`, `requires`, `tools`, `effort`, `thinking`
28
- - `map`: `label`, `itemsPath`, `body`, `as`, `resultPath`, `maxConcurrency`
28
+ - `map`: `label`, `itemsPath`, `body`, `as`, `resultPath`, `maxConcurrency`, `onItemFailure`, `failedAs`
29
29
  - `parallel`: `label`, `branches`
30
30
  - `loop`: `label`, `body`, `until`, `maxIters`, `expect_iters`
31
31
  - `escalate`: `label`, `when`, `kind`, `stage`, `summary`
32
32
  - `call`: `label`, `via`, `tool`, `args`, `code`, `input`, `command`, `env`, `where`, `out`, `as`, `produces`, `deadline_s`, `retry`, `poll`, `requires`
33
33
  - `workflow`: `label`, `workflow`, `input`, `out`, `as`
34
- - `judge`: `label`, `state`, `out`, `as`, `requires`
35
- - `pick`: `label`, `itemsPath`, `describe`, `instructions`, `state`, `allowNone`, `as`, `requires`
36
- - `sift`: `label`, `itemsPath`, `describe`, `state`, `out`, `as`, `keep`, `requires`
37
- - `route`: `label`, `state`, `instructions`, `branches`, `unsure`, `valuePath`, `otherwise`, `as`, `requires`
34
+ - `judge`: `label`, `state`, `out`, `as`, `requires`, `provider`, `model`, `evidence`, `timeoutMs`, `images`
35
+ - `pick`: `label`, `itemsPath`, `describe`, `instructions`, `state`, `allowNone`, `as`, `requires`, `provider`, `model`, `evidence`, `timeoutMs`, `images`
36
+ - `sift`: `label`, `itemsPath`, `describe`, `state`, `out`, `as`, `keep`, `requires`, `provider`, `model`, `evidence`, `timeoutMs`, `images`
37
+ - `route`: `label`, `state`, `instructions`, `branches`, `unsure`, `valuePath`, `otherwise`, `as`, `requires`, `provider`, `model`, `evidence`, `timeoutMs`, `images`
38
38
 
39
39
  Every kind also accepts `metadata`, an object the host owns and the engine never reads; set only the keys the host addendum names.
40
40
 
@@ -51,8 +51,8 @@ Their fields:
51
51
  - `out` names the schema the submission must satisfy; the value lands at `as`.
52
52
  - `requires` lists state paths that must hold evidence before the node runs, each produced upstream: missing values, null, blank strings, empty arrays and empty objects stop the run; `false` and `0` pass.
53
53
  - `tools` names tools the host offers. `[]` means no tools; omitting `tools` offers every tool the host allows. Never name a tool the host did not offer.
54
- - `effort` is minimal|low|medium|high; `thinking` is low|medium|high (never off); `tier` is fast|default|strong. They are requests to the host: resource ceilings are the host's.
55
- - An `agent` node may carry `budget_usd`, the most it asks to spend in dollars (above 0), which the host caps by what it has left, and `context`, fresh|fork: `fresh` (the default) sees only its instructions and state; `fork` asks the host to start it from the caller's transcript, which a host refuses where it has none.
54
+ - `effort` is minimal|low|medium|high; `thinking` is low|medium|high (never off); `tier` is fast|default|strong. They are requests to the host: resource ceilings are the host's. A node that names no `thinking` thinks at medium, unless its host sets another level.
55
+ - An `agent` node may carry `budget_usd`, the most it asks to spend in dollars (above 0), which the host caps by what it has left; `max_turns`, a positive integer, the most turns it asks its host for per attempt, which the host applies within its own cap and refuses above it (the engine enforces nothing, and naming it changes the workflow's digest); and `context`, fresh|fork: `fresh` (the default) sees only its instructions and state; `fork` asks the host to start it from the caller's transcript, which a host refuses where it has none.
56
56
  - `sopSection` names one heading of the host's SOP, or a list of them, as the exact text after "## ". The node receives those sections verbatim.
57
57
  - `verify` reviews a submission before it is accepted: {"out": a question schema with at least one boolean question, "state"?, "maxDrives"?: an integer >= 1 (default 2, no maximum), "override"?: {"below": a number in (0, 1), default 0.3}}. A boolean question named after a submission field doubts that field when its yes-probability is below `override.below`; any other boolean question is a requirement met at 0.5. A rejected submission returns to the same session with the reasons.
58
58
  - When the workflow has a report, no decide or extract `out` schema carries `report_markdown`.
@@ -72,11 +72,13 @@ Typed questions answered by the host's judge in one request each: no tools, no s
72
72
  - `sift`: `itemsPath`, `out` (a question schema asked of every item; the host splits the items across requests when they exceed its limits) and `as`. `keep` {path: a question id or <id>.confidence, never a choice, gte?} keeps passing items, in order, at `<as>.items`.
73
73
  - `route` runs one of 2 or more named `branches`. Jev chooses: a non-empty `state` map, `instructions` (the one question) and up to 240 branches, each {criteria?, body}; `unsure` {branch, gte: a number in (0, 1]} takes that branch when the choice's confidence is below `gte`. Or the workflow already holds the choice: `valuePath` names the state string that is the branch, each branch is {body}, no question is asked, and `otherwise` (a branch) takes a missing or unknown name, which otherwise fails; a non-string fails. `as` records the choice.
74
74
  - A decoded boolean is true at yes-probability 0.5. To hold a different threshold, read `<as>$answers.answers.<id>.noul` in a code node.
75
+ - `images` {token: reference} sends images with a decision (judge, pick, sift, a route Jev chooses, ask). Each token, such as "<page1>", must appear literally in the node's `state` or in a question's text; each reference is written as a state value is, such as "{item.pages.0.image}", and must resolve to an image path the host can read. Only a provider that takes image input answers such a node. Pass images by reference, never their bytes in state.
76
+ - Inside a `map` with `onItemFailure` `collect`, a decision whose provider fails (rate limit, HTTP error, invalid answer, timeout) fails that item, and one sent whose outcome was lost, or one the provider refused, ends the item as a row marked `needs_review`; the other items go on.
75
77
 
76
78
  ### Control nodes
77
79
 
78
80
  - `chain`: non-empty `steps`, run in order.
79
- - `map`: `itemsPath` (an upstream list), `body` and `as`. The body sees `item` and `item_index`; `maxConcurrency` is a positive integer (default 4); `resultPath` selects one path from each completed item's state.
81
+ - `map`: `itemsPath` (an upstream list), `body` and `as`. The body sees `item` and `item_index`; `maxConcurrency` is a positive integer (default 4); `resultPath` selects one path from each completed item's state. Without `resultPath`, and with no `as` in the body, each item's result is its whole state, the mapped list included: set `resultPath` (or an `as` in the body) for a large map; the validator warns. A map takes at most 10,000 items, and items × the state's JSON size at most 256 Mi characters (each item runs on its own copy of the state); past either it fails before any item runs. `onItemFailure` is `stop` (default: the first failing item stops the map and the run) or `collect`. With `collect`, an item whose node fails (a call that failed after its retries, an agent that delivered no record, output that does not match its schema, a failed check) ends as {item_index, label, code, message} in the list at `failedAs`, the other items finish, and `as` stays aligned with the items: `as[i]` is item i's result, or `null` when item i failed. Filter the nulls explicitly if only successes are wanted. Gate on `failedAs` with `escalate` or a code node; never let failures pass silently. A crash, a cancel, an `escalate` inside the item or an effect whose outcome is unknown is never collected.
80
82
  - `parallel`: at least two `branches`, each starting from the state before the parallel node. Branches write disjoint keys and never read a sibling's writes.
81
83
  - `loop`: `body`, `until` (a predicate) and an integer `maxIters` of at least 1 (no maximum), optionally an integer `expect_iters` of at least 1 (priced passes). At the bound the state passes through with `until` unmet; follow the loop with an escalate or gate on that condition.
82
84
  - `escalate`: `when` (a predicate), and non-empty `kind`, `stage` and `summary`. When the predicate holds the run stops without output and returns the escalation with its interpolated summary.
@@ -92,7 +94,7 @@ Typed questions answered by the host's judge in one request each: no tools, no s
92
94
 
93
95
  ## Predicates
94
96
 
95
- `loop.until` and `escalate.when` take one of these; `poll` takes only the first 8. Each path or key reads a state value an input or an earlier node produced.
97
+ `loop.until` and `escalate.when` take one of these; `poll` takes only the first 11. Each path or key reads a state value an input or an earlier node produced.
96
98
  A predicate is one JSON object that names itself in its `predicate` field beside its own fields, for example `{"predicate": "field_true", "path": "review.approved"}`.
97
99
  - `field_equals` {path, value}: holds when the value at `path` equals `value` (a string, number or boolean)
98
100
  - `field_true` {path}: holds when the value at `path` is `true`
@@ -102,7 +104,10 @@ A predicate is one JSON object that names itself in its `predicate` field beside
102
104
  - `lt` {path, n}: holds when the finite number at `path` is below `n`
103
105
  - `empty` {path}: holds when the value at `path` is an empty array, an empty string, null or absent
104
106
  - `no_new_items` {key}: takes `key`, not `path`; holds when that state key is an empty array or falsy
105
- - `ask` {instructions, state, criteria, gte}: a yes/no question for the host's judge: `instructions` is the question, `state` what it sees (default: the whole state), `criteria` optional {true, false} descriptions; holds when the yes-probability is at least `gte` (in (0.5, 1], default 0.6)
107
+ - `field_type` {path, type}: holds when the value at `path` is of `type`, one of number, string, boolean, array, object, null; a number only when finite, and an absent value is of no type
108
+ - `quote_missing` {path, field, pages}: the quote check, in code: holds when a quote at `path` (a string, or a list of them; with `field`, a list of records each holding its quote at `field`) is in none of the pages at `pages` (state paths holding what this run's call steps fetched; every string under each is page text). Both sides are compared lowercased, with curly quotes straight, dashes as "-" and whitespace runs as one space, then once more as their letters and digits alone; a quote under 8 characters is not checked. `{"predicate": "quote_missing", "path": "answer.evidence", "field": "quote", "pages": ["page"]}` on an escalate hands back an answer quoting text no fetched page holds. Check quotes with it, never with a judge or an `ask`
109
+ - `not` {of}: holds when `of`, one mechanical predicate (never `ask`), does not; `{"predicate": "not", "of": {"predicate": "field_type", "path": "score", "type": "number"}}` holds when score is absent or not a finite number
110
+ - `ask` {instructions, state, criteria, gte, provider, model, evidence, timeoutMs, images}: a yes/no question for the host's judge: `instructions` is the question, `state` what it sees (default: the whole state), `criteria` optional {true, false} descriptions; holds when the yes-probability is at least `gte` (in (0.5, 1], default 0.6)
106
111
 
107
112
  ## Authority
108
113
 
@@ -7,3 +7,5 @@ The session's system text is the [language reference](language.md) followed by t
7
7
  With `rubricSections`, every generated LLM node must reference every supplied section, including child workflows. This conservative author policy rejects Jev nodes, semantic `ask` predicates, and `verify` clauses until the host has a separately reviewed question contract. Execution must receive the same authoritative SOP text. A schema field named `node`, `verify`, or `predicate` is ordinary data, not a judgment clause.
8
8
 
9
9
  Host-owned acceptance callbacks and fixtures remain outside generated workflows. Do not edit them to obtain a pass. Structural acceptance alone does not establish behavior. Keep request text, rubric text, candidates, and reviews in storage appropriate for their contents.
10
+
11
+ A host that ships a workflow with the input it runs on exports a `Job` (`{ workflow, input, files? }`, files as bytes by path); `defineJob(job)` returns its argument and keeps the workflow's literal type, so `export const workflow = {...} as const satisfies Workflow` and `export default defineJob({ workflow, input })` compile together.