@parcha/agentrun-dsl 0.1.0-beta.33 → 0.1.0-beta.330

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 (67) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +10 -4
  3. package/dist/author-references.d.ts +2 -2
  4. package/dist/author-references.js +2 -2
  5. package/dist/author.d.ts +0 -2
  6. package/dist/author.js +7 -6
  7. package/dist/authoring.js +3 -2
  8. package/dist/cli.js +2 -1
  9. package/dist/code-exec.d.ts +19 -0
  10. package/dist/code-exec.js +54 -5
  11. package/dist/decision-provider.d.ts +11 -2
  12. package/dist/decision-provider.js +9 -3
  13. package/dist/decision-receipts.d.ts +19 -3
  14. package/dist/dry-run.d.ts +31 -1
  15. package/dist/dry-run.js +103 -14
  16. package/dist/edit.d.ts +158 -0
  17. package/dist/edit.js +1486 -0
  18. package/dist/evidence.js +2 -1
  19. package/dist/index.d.ts +10 -8
  20. package/dist/index.js +12 -8
  21. package/dist/pattern-screen.d.ts +14 -0
  22. package/dist/pattern-screen.js +451 -0
  23. package/dist/pointer-warning.d.ts +14 -0
  24. package/dist/pointer-warning.js +22 -0
  25. package/dist/predicates.d.ts +23 -3
  26. package/dist/predicates.js +48 -6
  27. package/dist/record.d.ts +4 -0
  28. package/dist/record.js +6 -0
  29. package/dist/recovery/binding.js +2 -1
  30. package/dist/recovery/call-key.d.ts +0 -4
  31. package/dist/recovery/call-key.js +0 -7
  32. package/dist/recovery/driver.d.ts +9 -14
  33. package/dist/recovery/driver.js +29 -26
  34. package/dist/recovery/frozen-snapshot.js +8 -8
  35. package/dist/recovery/handoff-receipts.d.ts +0 -35
  36. package/dist/recovery/handoff-receipts.js +2 -44
  37. package/dist/recovery/index.d.ts +2 -7
  38. package/dist/recovery/index.js +2 -6
  39. package/dist/recovery/item-state.d.ts +2 -1
  40. package/dist/recovery/item-state.js +7 -13
  41. package/dist/recovery/with-recovery.js +4 -2
  42. package/dist/submit-envelope.d.ts +1 -1
  43. package/dist/submit-envelope.js +11 -7
  44. package/dist/system-one.d.ts +0 -4
  45. package/dist/system-one.js +7 -8
  46. package/dist/vocabulary.d.ts +7 -2
  47. package/dist/vocabulary.js +7 -1
  48. package/dist/workflow-shape.js +4 -2
  49. package/dist/workflow.d.ts +58 -13
  50. package/dist/workflow.js +399 -180
  51. package/dist/zod-json-contract.js +6 -8
  52. package/package.json +18 -2
  53. package/schema/workflow.schema.json +93 -0
  54. package/skills/author/references/jev-decisions.md +10 -5
  55. package/skills/author/references/language.md +5 -4
  56. package/dist/recovery/effect-failure.d.ts +0 -34
  57. package/dist/recovery/effect-failure.js +0 -62
  58. package/dist/recovery/handoff-block.d.ts +0 -36
  59. package/dist/recovery/handoff-block.js +0 -148
  60. package/dist/recovery/handoff-digest.d.ts +0 -58
  61. package/dist/recovery/handoff-digest.js +0 -195
  62. package/dist/recovery/handoff-files.d.ts +0 -54
  63. package/dist/recovery/handoff-files.js +0 -162
  64. package/dist/recovery/handoff-redact.d.ts +0 -12
  65. package/dist/recovery/handoff-redact.js +0 -44
  66. package/dist/recovery/handoff.d.ts +0 -44
  67. package/dist/recovery/handoff.js +0 -46
package/dist/edit.d.ts ADDED
@@ -0,0 +1,158 @@
1
+ /** A workflow document as JSON: an object whose `root` is a node. */
2
+ export type WorkflowDocument = Record<string, unknown>;
3
+ /** A node as JSON: an object whose `node` is its kind. */
4
+ export type WorkflowNodeJson = Record<string, unknown>;
5
+ /** Where a child sits under its parent node: the pointer segments from the parent to it. A chain's `steps` and a
6
+ * parallel's `branches` hold many, by index; a map's or a loop's `body`, a route branch's `branches/<name>/body` (the
7
+ * name pointer-escaped, as in a graph path) and a child workflow's `workflow/root` hold one. The document holds its
8
+ * root at `root`, under the parent path `""`. */
9
+ export type Slot = "root" | "steps" | "branches" | "body" | "workflow/root" | `branches/${string}/body`;
10
+ /** What an operation returns: the next document and what happened to the nodes of the one it was given. */
11
+ export type EditResult = {
12
+ doc: WorkflowDocument;
13
+ /** Each node whose path changed, from its path before to its path after, in the input's document order. */
14
+ moved: Map<string, string>;
15
+ /** The paths, in the result, of the nodes the input did not have. */
16
+ added: string[];
17
+ /** The paths, in the input, of the nodes the result does not have. */
18
+ removed: string[];
19
+ /** The paths, in the result, of the nodes that were kept with their own fields changed. */
20
+ changed: string[];
21
+ };
22
+ /** What rename returns: an EditResult, and the code and shell sources in scope that mention the old key. */
23
+ export type RenameResult = EditResult & {
24
+ mentions: string[];
25
+ };
26
+ /** What duplicate returns: an EditResult, and the paths, in the result, of the copy's code and shell sources that
27
+ * mention a key the copy writes under a fresh name, by its old name. */
28
+ export type DuplicateResult = EditResult & {
29
+ mentions: string[];
30
+ };
31
+ /** Every code an EditError carries. */
32
+ export declare const EDIT_ERROR_CODES: readonly ["DOCUMENT_INVALID", "PATH_NOT_FOUND", "SLOT_INVALID", "INDEX_OUT_OF_RANGE", "NODE_INVALID", "FIELD_INVALID", "NAME_INVALID", "NAME_TAKEN", "NAME_SHARED", "BRANCH_NOT_FOUND", "BRANCH_TAKEN", "BRANCH_IN_USE", "MOVE_INTO_SELF", "WRAP_INVALID", "UNWRAP_INVALID", "STRUCTURE_INVALID", "SCHEMA_NOT_FOUND", "SCHEMA_IN_USE", "SCHEMA_INVALID"];
33
+ export type EditErrorCode = typeof EDIT_ERROR_CODES[number];
34
+ /** The one error the operations throw. `path` is the node it is about, in the input document where that node existed
35
+ * there; `related` names other nodes the error is about: the one holding a taken name, the other writers of a key. */
36
+ export declare class EditError extends Error {
37
+ readonly code: EditErrorCode;
38
+ readonly path: string;
39
+ readonly related: readonly string[];
40
+ constructor(code: EditErrorCode, path: string, message: string, related?: readonly string[]);
41
+ }
42
+ /** The placeholder a required field takes in a new node: a value insert accepts and the validator flags until someone
43
+ * fills it in (an empty text, an empty state map, a predicate with no name, a deadline of 0 seconds), or, for a loop's
44
+ * `maxIters`, the smallest bound. placeholderNode and wrap fill fields from it. */
45
+ export declare const FIELD_PLACEHOLDERS: Readonly<Record<string, unknown>>;
46
+ /** The fields setField writes on this node: its kind's (and its route form's) own fields, without `node` and the child
47
+ * slots. A property panel lists these. */
48
+ export declare function editableFields(node: WorkflowNodeJson): string[];
49
+ /** The fields the schema requires of this node's kind (and its route form), `node` included. */
50
+ export declare function requiredFields(node: WorkflowNodeJson): string[];
51
+ /** Where the node at `path` sits: its parent's path, the slot it is in, and its index there (0 in a slot that holds one
52
+ * node). Undefined when no node sits there. */
53
+ export declare function locate(doc: WorkflowDocument, path: string): {
54
+ parentPath: string;
55
+ slot: Slot;
56
+ index: number;
57
+ } | undefined;
58
+ /** Put `node` (copied) into `slot` of the node at `parentPath`, at `index`. In a chain's steps or a parallel's branches
59
+ * the index is a position, 0 to the count. A slot that holds one node takes index 0 when empty; when it holds a node,
60
+ * 0 puts the new one first and 1 puts it last, in a new chain of the two. */
61
+ export declare function insert(doc: WorkflowDocument, parentPath: string, slot: Slot, index: number, node: WorkflowNodeJson): EditResult;
62
+ /** Take out the node at `path`, and everything inside it. */
63
+ export declare function remove(doc: WorkflowDocument, path: string): EditResult;
64
+ /** Move the node at `fromPath` into `slot` of the node at `toParentPath`, at `index`, counted in the document as given:
65
+ * the drop point a canvas shows. A node never moves inside itself. */
66
+ export declare function move(doc: WorkflowDocument, fromPath: string, toParentPath: string, slot: Slot, index: number): EditResult;
67
+ /** Put a copy of the node at `path` right after it: the next step or branch, or, in a slot that holds one node, the
68
+ * second step of a new chain. Every node of the copy gets a fresh label, every key it writes a fresh name, and its own
69
+ * references follow its keys; the copy's code and shell sources that mention an old key are listed in `mentions`. */
70
+ export declare function duplicate(doc: WorkflowDocument, path: string): DuplicateResult;
71
+ /** The containers wrap makes. */
72
+ export type WrapKind = "map" | "loop" | "route" | "parallel" | "chain";
73
+ /** Put the nodes at `paths` (one node, or consecutive steps or branches of one container, in any order) into a new
74
+ * container of `kind`, where the first of them was. A map's, loop's or route's body is the one node or a chain of
75
+ * them; a parallel takes each as a branch. The new container's fields are placeholders the validator flags. */
76
+ export declare function wrap(doc: WorkflowDocument, paths: readonly string[], kind: WrapKind): EditResult;
77
+ /** Put the children of the container at `path` where it was: a chain's steps or a parallel's branches, the body of a
78
+ * map or a loop, or the body of the route branch `branch` names. Into a chain they are spliced; a parallel's branches
79
+ * join an enclosing parallel; a slot that holds one node takes one child, or a chain of a parallel's branches. */
80
+ export declare function unwrap(doc: WorkflowDocument, path: string, branch?: string): EditResult;
81
+ /** Add a branch to the parallel or route at `path`: `node` (copied) last among a parallel's branches, or as the body of
82
+ * a new route branch `name`, after the others. */
83
+ export declare function addBranch(doc: WorkflowDocument, path: string, node: WorkflowNodeJson, name?: string): EditResult;
84
+ /** Take out a branch of the parallel or route at `path`: a parallel's by its index, a route's by its name. */
85
+ export declare function removeBranch(doc: WorkflowDocument, path: string, branch: string | number): EditResult;
86
+ /** Rename branch `from` of the route at `path` to `to`, in its place among the others; `otherwise` and `unsure` follow. */
87
+ export declare function renameBranch(doc: WorkflowDocument, path: string, from: string, to: string): EditResult;
88
+ /** Write `value` (copied) at the field of the node at `path`, in its place; `undefined` removes an optional field. */
89
+ export declare function setField(doc: WorkflowDocument, path: string, field: string, value: unknown): EditResult;
90
+ /** Rename the label of the node at `path`. When the label is the key the node writes (an agent, decide, extract or code
91
+ * node with no `as`), every reference in scope follows it, and the code and shell sources in scope that mention the old
92
+ * key are listed in `mentions`, unchanged: a code node's own code included, when it names the key. */
93
+ export declare function rename(doc: WorkflowDocument, path: string, name: string): RenameResult;
94
+ /** Which key renameKey renames: the node's `as` (the default), or a map's `failedAs`. */
95
+ export type RenameKeyOptions = {
96
+ field?: "as" | "failedAs";
97
+ };
98
+ /** Rename the state key the node at `path` writes: its `as` when it has one, else its label when the label is the key
99
+ * (an agent, decide, extract or code node with no `as`, where this is `rename`); or, with `field: "failedAs"`, the key a
100
+ * map writes its failed items under. Every reference in scope follows it, `<key>$answers` and `<key>$verify` included,
101
+ * and the code and shell sources in scope that mention the old key are listed in `mentions`, unchanged. */
102
+ export declare function renameKey(doc: WorkflowDocument, path: string, name: string, options?: RenameKeyOptions): RenameResult;
103
+ /** Write `criteria`, the text Jev reads to choose it, on branch `branch` of the judged route at `path`, in its place;
104
+ * `undefined` removes it. A route by value matches its branches by name and takes no criteria. */
105
+ export declare function setBranchCriteria(doc: WorkflowDocument, path: string, branch: string, criteria: string | undefined): EditResult;
106
+ /** The JSON Pointers of the values that name schema `id` of a scope ("" for the document, or a workflow node's path
107
+ * for its child's schemas): the workflow's `input.schemaId` and `output.schemaId`, a `$ref` from another of its
108
+ * schemas, and the `out` and `verify.out` of its nodes (a workflow node's `out` names its parent's schema). */
109
+ export declare function schemaUsers(doc: WorkflowDocument, id: string, scope?: string): string[];
110
+ /** Write `schema` (copied) as schema `id` of a scope ("" for the document, or a workflow node's path for its child), in
111
+ * its place when it exists; `undefined` removes it, unless something still names it (`schemaUsers`). */
112
+ export declare function setSchema(doc: WorkflowDocument, id: string, schema: Record<string, unknown> | undefined, scope?: string): EditResult;
113
+ /** Write the document's own `input` or `output` (copied): `{ schemaId }`, naming one of its schemas, and for the output
114
+ * an optional `path`, the state path its value is read from when the run ends. `undefined` removes the input; a workflow
115
+ * always has its output. Whether the schema exists and something sets the path is the validator's call. */
116
+ export declare function setWorkflowField(doc: WorkflowDocument, field: "input" | "output", value: Record<string, unknown> | undefined): EditResult;
117
+ /** A name a node may read, and what gives it: the path of the node that writes it, "input" (the workflow's input, or a
118
+ * child's), or "engine" (a map body's `item` and `item_index`). */
119
+ export type NameInScope = {
120
+ name: string;
121
+ from: string;
122
+ };
123
+ /** The names the node at `path` may read, each with what gives it, by the scope rules rename carries a key along: its
124
+ * workflow's input keys, a map body's `item` and `item_index`, and the keys (with their `<key>$answers` and
125
+ * `<key>$verify`) of each node whose write it runs after and sees. With `field`, the names that one field of the node
126
+ * reads, where it sees more than the rest: a map's `resultPath` its body's keys and item, a loop's `until` its body's
127
+ * keys, `verify` the node's own `as` and `submission`, a pick's or sift's `describe` its own `item` and `item_index`,
128
+ * and a workflow node's `workflow` (its child's `output.path`) the child's state. */
129
+ export declare function namesInScope(doc: WorkflowDocument, path: string, field?: string): NameInScope[];
130
+ /** The names the document's `output.path` may read, each with what gives it, as namesInScope gives a node's: its input
131
+ * keys, and the keys (with their `<key>$answers` and `<key>$verify`) of each node whose write is in the state when the
132
+ * run ends, which no key written in a map's body or a child workflow is. A terminal's fixed key is one: a report's, or
133
+ * a prose artifact's (which runs as a report), `report_markdown`, and a file artifact's `artifact`. */
134
+ export declare function outputNames(doc: WorkflowDocument): NameInScope[];
135
+ /** A reference a node makes: the JSON Pointer of the value it sits in, the name it reads (the head of its path), and
136
+ * `optional` for a whole-string placeholder marked `?` (`"{plan?}"`), which the engine fills with null while unset. */
137
+ export type NodeRead = {
138
+ pointer: string;
139
+ name: string;
140
+ optional?: true;
141
+ };
142
+ /** Each `{placeholder}` and state path the node at `path` reads, in its fields' order: the references rename carries,
143
+ * found by the same walk. A workflow node's include its child's `output.path`, which reads the child's state. */
144
+ export declare function readsOf(doc: WorkflowDocument, path: string): NodeRead[];
145
+ /** The `{placeholder` open at `offset` in `text`: the index of its `{` and the name typed after it up to the cursor, by
146
+ * the placeholder grammar (letters, digits, "_", "." and "$"; a reference may start with `state.`). Undefined when no
147
+ * placeholder's name holds the cursor. The placeholder may already be closed after it. */
148
+ export declare function openPlaceholderAt(text: string, offset: number): {
149
+ start: number;
150
+ prefix: string;
151
+ } | undefined;
152
+ /** `base`, or its stem (`base` without a `_<n>` ending) with the smallest `_<n>` from 2, so that no label, key,
153
+ * reference, input key or word of code of any scope of the document holds it (a child workflow's that holds no node
154
+ * yet among them), nor an engine key or a name `Object.prototype` has. `base` is a state key name. */
155
+ export declare function freshName(doc: WorkflowDocument, base: string): string;
156
+ /** The smallest node of `kind` for `doc`: its required fields in the schema's order, a fresh name as its label (and its
157
+ * `as`, where it needs one), and each other field's placeholder. A container is made by wrapping nodes that exist. */
158
+ export declare function placeholderNode(doc: WorkflowDocument, kind: string): WorkflowNodeJson;