taskflow-core 0.1.8 → 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.
Files changed (115) hide show
  1. package/README.md +80 -25
  2. package/dist/deterministic.d.ts +8 -0
  3. package/dist/deterministic.d.ts.map +1 -1
  4. package/dist/deterministic.js +23 -1
  5. package/dist/deterministic.js.map +1 -1
  6. package/dist/exec/driver.d.ts +47 -0
  7. package/dist/exec/driver.d.ts.map +1 -0
  8. package/dist/exec/driver.js +397 -0
  9. package/dist/exec/driver.js.map +1 -0
  10. package/dist/exec/events.d.ts +76 -0
  11. package/dist/exec/events.d.ts.map +1 -0
  12. package/dist/exec/events.js +108 -0
  13. package/dist/exec/events.js.map +1 -0
  14. package/dist/exec/fold.d.ts +45 -0
  15. package/dist/exec/fold.d.ts.map +1 -0
  16. package/dist/exec/fold.js +122 -0
  17. package/dist/exec/fold.js.map +1 -0
  18. package/dist/exec/index.d.ts +17 -0
  19. package/dist/exec/index.d.ts.map +1 -0
  20. package/dist/exec/index.js +17 -0
  21. package/dist/exec/index.js.map +1 -0
  22. package/dist/exec/kernel-policy.d.ts +35 -0
  23. package/dist/exec/kernel-policy.d.ts.map +1 -0
  24. package/dist/exec/kernel-policy.js +184 -0
  25. package/dist/exec/kernel-policy.js.map +1 -0
  26. package/dist/exec/step-kinds.d.ts +41 -0
  27. package/dist/exec/step-kinds.d.ts.map +1 -0
  28. package/dist/exec/step-kinds.js +574 -0
  29. package/dist/exec/step-kinds.js.map +1 -0
  30. package/dist/exec/step.d.ts +93 -0
  31. package/dist/exec/step.d.ts.map +1 -0
  32. package/dist/exec/step.js +436 -0
  33. package/dist/exec/step.js.map +1 -0
  34. package/dist/flowir/canonical-hash.d.ts +101 -0
  35. package/dist/flowir/canonical-hash.d.ts.map +1 -0
  36. package/dist/flowir/canonical-hash.js +219 -0
  37. package/dist/flowir/canonical-hash.js.map +1 -0
  38. package/dist/flowir/compile.d.ts +49 -0
  39. package/dist/flowir/compile.d.ts.map +1 -0
  40. package/dist/flowir/compile.js +219 -0
  41. package/dist/flowir/compile.js.map +1 -0
  42. package/dist/flowir/cond.d.ts +76 -0
  43. package/dist/flowir/cond.d.ts.map +1 -0
  44. package/dist/flowir/cond.js +214 -0
  45. package/dist/flowir/cond.js.map +1 -0
  46. package/dist/flowir/index.d.ts +20 -23
  47. package/dist/flowir/index.d.ts.map +1 -1
  48. package/dist/flowir/index.js +47 -35
  49. package/dist/flowir/index.js.map +1 -1
  50. package/dist/flowir/meta.d.ts +4 -4
  51. package/dist/flowir/meta.d.ts.map +1 -1
  52. package/dist/flowir/phasefp.d.ts.map +1 -1
  53. package/dist/flowir/phasefp.js +13 -1
  54. package/dist/flowir/phasefp.js.map +1 -1
  55. package/dist/flowir/schema.d.ts +260 -0
  56. package/dist/flowir/schema.d.ts.map +1 -0
  57. package/dist/flowir/schema.js +234 -0
  58. package/dist/flowir/schema.js.map +1 -0
  59. package/dist/flowir/translate.d.ts.map +1 -1
  60. package/dist/flowir/translate.js +3 -0
  61. package/dist/flowir/translate.js.map +1 -1
  62. package/dist/host/runner-types.d.ts +3 -0
  63. package/dist/host/runner-types.d.ts.map +1 -1
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +2 -0
  67. package/dist/index.js.map +1 -1
  68. package/dist/rates.d.ts +121 -0
  69. package/dist/rates.d.ts.map +1 -0
  70. package/dist/rates.js +187 -0
  71. package/dist/rates.js.map +1 -0
  72. package/dist/replay.d.ts +43 -50
  73. package/dist/replay.d.ts.map +1 -1
  74. package/dist/replay.js +629 -19
  75. package/dist/replay.js.map +1 -1
  76. package/dist/runner-core.d.ts +24 -0
  77. package/dist/runner-core.d.ts.map +1 -1
  78. package/dist/runner-core.js +225 -32
  79. package/dist/runner-core.js.map +1 -1
  80. package/dist/runtime/phases/approval.d.ts +23 -0
  81. package/dist/runtime/phases/approval.d.ts.map +1 -0
  82. package/dist/runtime/phases/approval.js +38 -0
  83. package/dist/runtime/phases/approval.js.map +1 -0
  84. package/dist/runtime/phases/expand.d.ts +29 -0
  85. package/dist/runtime/phases/expand.d.ts.map +1 -0
  86. package/dist/runtime/phases/expand.js +126 -0
  87. package/dist/runtime/phases/expand.js.map +1 -0
  88. package/dist/runtime/phases/parallel.d.ts +26 -0
  89. package/dist/runtime/phases/parallel.d.ts.map +1 -0
  90. package/dist/runtime/phases/parallel.js +15 -0
  91. package/dist/runtime/phases/parallel.js.map +1 -0
  92. package/dist/runtime/phases/race.d.ts +31 -0
  93. package/dist/runtime/phases/race.d.ts.map +1 -0
  94. package/dist/runtime/phases/race.js +220 -0
  95. package/dist/runtime/phases/race.js.map +1 -0
  96. package/dist/runtime/phases/script.d.ts +38 -0
  97. package/dist/runtime/phases/script.d.ts.map +1 -0
  98. package/dist/runtime/phases/script.js +139 -0
  99. package/dist/runtime/phases/script.js.map +1 -0
  100. package/dist/runtime.d.ts +29 -16
  101. package/dist/runtime.d.ts.map +1 -1
  102. package/dist/runtime.js +554 -292
  103. package/dist/runtime.js.map +1 -1
  104. package/dist/schema.d.ts +36 -4
  105. package/dist/schema.d.ts.map +1 -1
  106. package/dist/schema.js +86 -10
  107. package/dist/schema.js.map +1 -1
  108. package/dist/store.d.ts +6 -0
  109. package/dist/store.d.ts.map +1 -1
  110. package/dist/store.js.map +1 -1
  111. package/dist/trace.d.ts +4 -1
  112. package/dist/trace.d.ts.map +1 -1
  113. package/dist/trace.js +33 -26
  114. package/dist/trace.js.map +1 -1
  115. package/package.json +5 -4
@@ -0,0 +1,260 @@
1
+ /**
2
+ * # Canonical FlowIR type contract
3
+ *
4
+ * This module formalizes the **canonical FlowIR** (Flow Intermediate
5
+ * Representation) type contract for the overstory-convergence roadmap. It is a
6
+ * **superset** of the implicit shape that `./translate.ts` already produces
7
+ * (mirrored structurally in `./meta.ts`): every `FlowIR`/`FlowIRNode` emitted
8
+ * by `translateTaskflow` satisfies the types defined here, and these types add
9
+ * the missing formalization — a closed `FlowIRNodeKind` literal union, an
10
+ * explicit `FlowIREdge` model, structural `FlowIRBudget`/`FlowIRMeta`, and
11
+ * optional lightweight TypeBox guards.
12
+ *
13
+ * **Provenance & ownership (Q2=B, Q5=own):** this is pi-taskflow's *own* type
14
+ * contract — not vendored from overstory. `flowir/compile.ts` (batch 2 of the
15
+ * roadmap) will emit this canonical shape; the event-sourced kernel executes
16
+ * it. `translate.ts`'s 1:1 projection is a *read-only stub* that already
17
+ * conforms to this contract today, so formalizing here is purely additive —
18
+ * it must not break `translate.ts`, `meta.ts`, `hash.ts`, or any barrel.
19
+ *
20
+ * **Compatibility note:** the canonical `FlowIRNode.kind` is the closed
21
+ * `FlowIRNodeKind` literal union (the closed set of native phase kinds = `PHASE_TYPES`), whereas
22
+ * `meta.ts`'s `FlowIRNode.kind` is `string` (a 1:1 projection). Every value
23
+ * `translate.ts` produces for `kind` (`phase.type ?? "agent"`) is a member of
24
+ * `FlowIRNodeKind`, so the canonical type is a strict refinement that
25
+ * subsumes the stub output. Code that needs the looser projection can keep
26
+ * using `meta.ts`; code that wants the closed contract imports from here.
27
+ *
28
+ * **Purity:** zero runtime deps beyond `typebox`. No IO, no Date, no
29
+ * randomness. Guards are pure functions over plain JSON values.
30
+ *
31
+ * @see docs/internal/overstory-convergence-roadmap.md §3 (M1), §6 (compile seam)
32
+ * @see docs/internal/rfc-flowir-compilation.md
33
+ */
34
+ import { Type } from "typebox";
35
+ import { type PhaseType } from "../schema.ts";
36
+ /**
37
+ * The closed set of pi-taskflow phase kinds, derived 1:1 from the exported
38
+ * {@link PHASE_TYPES} in `../schema.ts` (single source of truth). This is the
39
+ * canonical `FlowIRNode.kind` vocabulary. `translate.ts` sets
40
+ * `kind = phase.type ?? "agent"`, so every node it emits is a member of this
41
+ * union. Adding a phase kind requires updating `PHASE_TYPES` only — FlowIR
42
+ * follows automatically.
43
+ *
44
+ * | kind | purpose |
45
+ * |-------------|----------------------------------------------------------|
46
+ * | `agent` | single subagent call |
47
+ * | `parallel` | static concurrent branches |
48
+ * | `map` | dynamic fan-out over an array (one subagent per item) |
49
+ * | `gate` | quality gate — can halt the flow on VERDICT: BLOCK |
50
+ * | `reduce` | aggregate multiple upstream outputs into one |
51
+ * | `approval` | human-in-the-loop pause (approve/reject/edit) |
52
+ * | `flow` | run a saved sub-taskflow as a single phase |
53
+ * | `loop` | repeat body until condition, convergence, or max iters |
54
+ * | `tournament`| N competing variants + judge picks best / aggregates |
55
+ * | `script` | run a shell command (no LLM, zero tokens) |
56
+ */
57
+ export declare const FlowIRNodeKind: Type.TUnsafe<"agent" | "approval" | "expand" | "flow" | "gate" | "loop" | "map" | "parallel" | "race" | "reduce" | "script" | "tournament">;
58
+ /** @see PHASE_TYPES — same closed set as the DSL. */
59
+ export type FlowIRNodeKind = PhaseType;
60
+ /**
61
+ * A single canonical FlowIR node — one per pi-taskflow phase.
62
+ *
63
+ * This is a **superset** of the node shape `translate.ts` emits. The stub
64
+ * attaches exactly `{ id, kind, inject, emits, when? }`; this contract
65
+ * additionally formalizes the optional fields a genuine compiler (batch 2,
66
+ * `flowir/compile.ts`) and the event-sourced kernel will populate:
67
+ *
68
+ * - `task` — the resolved (interpolated) task prompt, when materialized.
69
+ * - `condRef` — a reference to a compiled condition descriptor (the lowered
70
+ * form of `when`; see `flowir/cond.ts`). Absent on the stub,
71
+ * which passes `when` through verbatim.
72
+ * - `deps` — explicit `dependsOn` edges carried onto the node (the stub
73
+ * folds these into `inject`; a compiler may keep them
74
+ * separate for the edge model).
75
+ * - `join` — join mode (`"all"` default, or `"any"` for OR-join).
76
+ * - `timeout` — per-call ms cap (agent-running phases).
77
+ * - `payload` — stable, hash-addressed DSL payload fields not otherwise
78
+ * represented above (for example branch bodies, script command,
79
+ * map source, flow/expand definitions, output contracts).
80
+ *
81
+ * All added fields are **optional** so the stub's minimal output remains valid.
82
+ */
83
+ export interface FlowIRNode {
84
+ /** Unique phase identifier (referenced via `{steps.<id>.output}`). */
85
+ id: string;
86
+ /** The native phase kind — a member of {@link FlowIRNodeKind}. */
87
+ kind: FlowIRNodeKind;
88
+ /**
89
+ * Synthesized declared reads: the upstream step ids whose outputs this
90
+ * node injects. In the stub this is `{steps.X}` refs ∪ `dependsOn`
91
+ * (minus self); a genuine compiler lowers this to overstory's inject
92
+ * model.
93
+ */
94
+ inject: string[];
95
+ /** What this node emits — currently `[id]` (1:1 projection). */
96
+ emits: string[];
97
+ /** Raw `when` guard passthrough (stub: not rewritten to IR conditions). */
98
+ when?: string;
99
+ /** Resolved (interpolated) task prompt, when materialized by a compiler. */
100
+ task?: string;
101
+ /** Reference to a compiled condition descriptor (lowered `when`). */
102
+ condRef?: string;
103
+ /** Explicit `dependsOn` edges carried onto the node (optional). */
104
+ deps?: string[];
105
+ /** Join mode: `"all"` (default AND-join) or `"any"` (OR-join). */
106
+ join?: "all" | "any";
107
+ /** Per-subagent-call ms cap (agent-running phases). */
108
+ timeout?: number;
109
+ /** Runtime-affecting DSL payload not otherwise modeled by the core node fields. */
110
+ payload?: Record<string, unknown>;
111
+ }
112
+ /**
113
+ * A directed edge in the FlowIR DAG. `from` is the upstream (producer) node
114
+ * id; `to` is the downstream (consumer) node id. The stub projection encodes
115
+ * edges implicitly via `FlowIRNode.inject` (and `dependsOn`); a genuine
116
+ * compiler may emit an explicit `edges` list for graph consumers (renderers,
117
+ * topo sorters). When present, `edges` must be consistent with `inject`.
118
+ */
119
+ export interface FlowIREdge {
120
+ /** Upstream (producer) node id. */
121
+ from: string;
122
+ /** Downstream (consumer) node id. */
123
+ to: string;
124
+ }
125
+ /**
126
+ * Run-wide observed-usage stop-loss. Once reported usage exceeds it, no new
127
+ * model call is admitted and remaining phases are skipped; a call already in
128
+ * flight may overshoot the threshold. Ordinary budgeted DAG layers and
129
+ * map/parallel/tournament fan-out use serial admission, limiting new-call
130
+ * overshoot to one call. A `race` necessarily admits competing branches
131
+ * together, so all already-active race branches may contribute overshoot.
132
+ * Structurally identical to the DSL `Budget` (schema.ts); mirrored
133
+ * here so the FlowIR contract is self-contained and doesn't leak DSL types to
134
+ * pure IR consumers (the event-sourced kernel).
135
+ */
136
+ export interface FlowIRBudget {
137
+ /** Stop admitting calls once observed accumulated cost exceeds this many USD. */
138
+ maxUSD?: number;
139
+ /** Stop admitting calls once observed accumulated input+output tokens exceed this. */
140
+ maxTokens?: number;
141
+ }
142
+ /**
143
+ * Optional flow-level metadata attached to a compiled FlowIR. Populated by a
144
+ * genuine compiler; absent on the stub (which carries metadata in
145
+ * `TaskflowIRMeta`, not on the IR itself). Kept loose (`Record<string,
146
+ * unknown>`) so the contract is forward-compatible without churn.
147
+ */
148
+ export interface FlowIRMeta {
149
+ /** Origin tool/host (e.g. `"pi"`, `"codex"`). */
150
+ source?: string;
151
+ /** Schema version of the IR emitter. */
152
+ irVersion?: number;
153
+ /** Free-form compiler diagnostics / annotations. */
154
+ annotations?: Record<string, unknown>;
155
+ [key: string]: unknown;
156
+ }
157
+ /**
158
+ * The canonical compiled FlowIR. A **superset** of `meta.ts`'s `FlowIR`:
159
+ * - `version` is formalized (maps to the DSL `Taskflow.version`).
160
+ * - `edges` is the optional explicit edge model (absent on the stub).
161
+ * - `meta` is the optional flow-level metadata (absent on the stub).
162
+ *
163
+ * Every `FlowIR` produced by `translateTaskflow` — `{ name, nodes, args?,
164
+ * budget?, concurrency? }` — satisfies this contract (the added fields are all
165
+ * optional). `compile.ts` (batch 2) emits the full canonical form.
166
+ */
167
+ export interface FlowIR {
168
+ /** Workflow name (the DSL `Taskflow.name`). */
169
+ name: string;
170
+ /** DSL schema version (maps to `Taskflow.version`, default 1). */
171
+ version?: number;
172
+ /** The flat list of IR nodes (one per phase). */
173
+ nodes: FlowIRNode[];
174
+ /** Optional explicit edge list (consistent with `inject`). */
175
+ edges?: FlowIREdge[];
176
+ /** Declared invocation arguments (DSL `Taskflow.args`). */
177
+ args?: Record<string, unknown>;
178
+ /** Run-wide observed-usage stop-loss; an in-flight call may overshoot. */
179
+ budget?: FlowIRBudget;
180
+ /** Default max concurrent subagents. */
181
+ concurrency?: number;
182
+ /** Optional flow-level metadata (compiler-populated). */
183
+ meta?: FlowIRMeta;
184
+ }
185
+ /**
186
+ * TypeBox schema mirroring {@link FlowIRNode}. Used by the structural guards
187
+ * below. Kept in sync by construction (the `Static` of this schema *is*
188
+ * `FlowIRNode`); if the interface above drifts, this schema must be updated to
189
+ * match.
190
+ */
191
+ export declare const FlowIRNodeSchema: Type.TObject<{
192
+ id: Type.TString;
193
+ kind: Type.TUnsafe<"agent" | "approval" | "expand" | "flow" | "gate" | "loop" | "map" | "parallel" | "race" | "reduce" | "script" | "tournament">;
194
+ inject: Type.TArray<Type.TString>;
195
+ emits: Type.TArray<Type.TString>;
196
+ when: Type.TOptional<Type.TString>;
197
+ task: Type.TOptional<Type.TString>;
198
+ condRef: Type.TOptional<Type.TString>;
199
+ deps: Type.TOptional<Type.TArray<Type.TString>>;
200
+ join: Type.TOptional<Type.TUnion<[Type.TLiteral<"all">, Type.TLiteral<"any">]>>;
201
+ timeout: Type.TOptional<Type.TNumber>;
202
+ payload: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
203
+ }>;
204
+ /**
205
+ * TypeBox schema mirroring {@link FlowIREdge}.
206
+ */
207
+ export declare const FlowIREdgeSchema: Type.TObject<{
208
+ from: Type.TString;
209
+ to: Type.TString;
210
+ }>;
211
+ /**
212
+ * TypeBox schema mirroring {@link FlowIR}.
213
+ */
214
+ export declare const FlowIRSchema: Type.TObject<{
215
+ name: Type.TString;
216
+ version: Type.TOptional<Type.TNumber>;
217
+ nodes: Type.TArray<Type.TObject<{
218
+ id: Type.TString;
219
+ kind: Type.TUnsafe<"agent" | "approval" | "expand" | "flow" | "gate" | "loop" | "map" | "parallel" | "race" | "reduce" | "script" | "tournament">;
220
+ inject: Type.TArray<Type.TString>;
221
+ emits: Type.TArray<Type.TString>;
222
+ when: Type.TOptional<Type.TString>;
223
+ task: Type.TOptional<Type.TString>;
224
+ condRef: Type.TOptional<Type.TString>;
225
+ deps: Type.TOptional<Type.TArray<Type.TString>>;
226
+ join: Type.TOptional<Type.TUnion<[Type.TLiteral<"all">, Type.TLiteral<"any">]>>;
227
+ timeout: Type.TOptional<Type.TNumber>;
228
+ payload: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
229
+ }>>;
230
+ edges: Type.TOptional<Type.TArray<Type.TObject<{
231
+ from: Type.TString;
232
+ to: Type.TString;
233
+ }>>>;
234
+ args: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
235
+ budget: Type.TOptional<Type.TObject<{
236
+ maxUSD: Type.TOptional<Type.TNumber>;
237
+ maxTokens: Type.TOptional<Type.TNumber>;
238
+ }>>;
239
+ concurrency: Type.TOptional<Type.TNumber>;
240
+ meta: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
241
+ }>;
242
+ /**
243
+ * Narrow an `unknown` value to a {@link FlowIRNode}. Pure, synchronous,
244
+ * fail-closed: returns `false` for anything that is not a plain object with
245
+ * a string `id`, a valid `kind`, and string-array `inject`/`emits`. Does not
246
+ * throw. This is a *structural* check (not a deep TypeBox decode) so it stays
247
+ * cheap and dependency-light; use {@link assertFlowIR} for full validation.
248
+ */
249
+ export declare function isFlowIRNode(value: unknown): value is FlowIRNode;
250
+ /**
251
+ * Assert that a value is a well-formed {@link FlowIR}. Throws a descriptive
252
+ * `Error` (not an `AssertionError`) on the first structural violation —
253
+ * fail-closed, so a malformed IR can never silently reach the kernel. Uses
254
+ * the lightweight structural checks (no external validator); for full schema
255
+ * decoding, decode `FlowIRSchema` with a TypeBox-compatible checker.
256
+ *
257
+ * @throws {Error} if `value` is not a valid `FlowIR`.
258
+ */
259
+ export declare function assertFlowIR(value: unknown): asserts value is FlowIR;
260
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/flowir/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA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AiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAMD;;;;;;;;;GASG;AACH,MAAM,WAAW,MAAM;IACtB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,IAAI,CAAC,EAAE,UAAU,CAAC;CAClB;AAMD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAmB5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;EAM5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBxB,CAAC;AASF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAiBhE;AAQD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAoEpE"}
@@ -0,0 +1,234 @@
1
+ /**
2
+ * # Canonical FlowIR type contract
3
+ *
4
+ * This module formalizes the **canonical FlowIR** (Flow Intermediate
5
+ * Representation) type contract for the overstory-convergence roadmap. It is a
6
+ * **superset** of the implicit shape that `./translate.ts` already produces
7
+ * (mirrored structurally in `./meta.ts`): every `FlowIR`/`FlowIRNode` emitted
8
+ * by `translateTaskflow` satisfies the types defined here, and these types add
9
+ * the missing formalization — a closed `FlowIRNodeKind` literal union, an
10
+ * explicit `FlowIREdge` model, structural `FlowIRBudget`/`FlowIRMeta`, and
11
+ * optional lightweight TypeBox guards.
12
+ *
13
+ * **Provenance & ownership (Q2=B, Q5=own):** this is pi-taskflow's *own* type
14
+ * contract — not vendored from overstory. `flowir/compile.ts` (batch 2 of the
15
+ * roadmap) will emit this canonical shape; the event-sourced kernel executes
16
+ * it. `translate.ts`'s 1:1 projection is a *read-only stub* that already
17
+ * conforms to this contract today, so formalizing here is purely additive —
18
+ * it must not break `translate.ts`, `meta.ts`, `hash.ts`, or any barrel.
19
+ *
20
+ * **Compatibility note:** the canonical `FlowIRNode.kind` is the closed
21
+ * `FlowIRNodeKind` literal union (the closed set of native phase kinds = `PHASE_TYPES`), whereas
22
+ * `meta.ts`'s `FlowIRNode.kind` is `string` (a 1:1 projection). Every value
23
+ * `translate.ts` produces for `kind` (`phase.type ?? "agent"`) is a member of
24
+ * `FlowIRNodeKind`, so the canonical type is a strict refinement that
25
+ * subsumes the stub output. Code that needs the looser projection can keep
26
+ * using `meta.ts`; code that wants the closed contract imports from here.
27
+ *
28
+ * **Purity:** zero runtime deps beyond `typebox`. No IO, no Date, no
29
+ * randomness. Guards are pure functions over plain JSON values.
30
+ *
31
+ * @see docs/internal/overstory-convergence-roadmap.md §3 (M1), §6 (compile seam)
32
+ * @see docs/internal/rfc-flowir-compilation.md
33
+ */
34
+ import { Type } from "typebox";
35
+ import { StringEnum } from "../typebox-helpers.js";
36
+ import { PHASE_TYPES } from "../schema.js";
37
+ // ---------------------------------------------------------------------------
38
+ // FlowIRNodeKind — closed literal union = PHASE_TYPES (currently 12 kinds)
39
+ // ---------------------------------------------------------------------------
40
+ /**
41
+ * The closed set of pi-taskflow phase kinds, derived 1:1 from the exported
42
+ * {@link PHASE_TYPES} in `../schema.ts` (single source of truth). This is the
43
+ * canonical `FlowIRNode.kind` vocabulary. `translate.ts` sets
44
+ * `kind = phase.type ?? "agent"`, so every node it emits is a member of this
45
+ * union. Adding a phase kind requires updating `PHASE_TYPES` only — FlowIR
46
+ * follows automatically.
47
+ *
48
+ * | kind | purpose |
49
+ * |-------------|----------------------------------------------------------|
50
+ * | `agent` | single subagent call |
51
+ * | `parallel` | static concurrent branches |
52
+ * | `map` | dynamic fan-out over an array (one subagent per item) |
53
+ * | `gate` | quality gate — can halt the flow on VERDICT: BLOCK |
54
+ * | `reduce` | aggregate multiple upstream outputs into one |
55
+ * | `approval` | human-in-the-loop pause (approve/reject/edit) |
56
+ * | `flow` | run a saved sub-taskflow as a single phase |
57
+ * | `loop` | repeat body until condition, convergence, or max iters |
58
+ * | `tournament`| N competing variants + judge picks best / aggregates |
59
+ * | `script` | run a shell command (no LLM, zero tokens) |
60
+ */
61
+ export const FlowIRNodeKind = StringEnum(PHASE_TYPES, {
62
+ description: "Native phase kinds — 1:1 projection of PHASE_TYPES (agent…script, race, expand, …)",
63
+ });
64
+ // ---------------------------------------------------------------------------
65
+ // TypeBox schemas (for runtime validation / structural guards)
66
+ // ---------------------------------------------------------------------------
67
+ /**
68
+ * TypeBox schema mirroring {@link FlowIRNode}. Used by the structural guards
69
+ * below. Kept in sync by construction (the `Static` of this schema *is*
70
+ * `FlowIRNode`); if the interface above drifts, this schema must be updated to
71
+ * match.
72
+ */
73
+ export const FlowIRNodeSchema = Type.Object({
74
+ id: Type.String({ description: "Unique phase identifier" }),
75
+ kind: FlowIRNodeKind,
76
+ inject: Type.Array(Type.String(), { description: "Declared reads (upstream step ids)" }),
77
+ emits: Type.Array(Type.String(), { description: "What this node emits (currently [id])" }),
78
+ when: Type.Optional(Type.String({ description: "Raw when guard passthrough" })),
79
+ task: Type.Optional(Type.String({ description: "Resolved task prompt" })),
80
+ condRef: Type.Optional(Type.String({ description: "Reference to a compiled condition descriptor" })),
81
+ deps: Type.Optional(Type.Array(Type.String(), { description: "Explicit dependsOn edges" })),
82
+ join: Type.Optional(Type.Union([Type.Literal("all"), Type.Literal("any")], { description: "Join mode" })),
83
+ timeout: Type.Optional(Type.Number({ description: "Per-call ms cap" })),
84
+ payload: Type.Optional(Type.Record(Type.String(), Type.Unknown(), {
85
+ description: "Runtime-affecting DSL payload not otherwise modeled by the core node fields",
86
+ })),
87
+ }, { additionalProperties: false });
88
+ /**
89
+ * TypeBox schema mirroring {@link FlowIREdge}.
90
+ */
91
+ export const FlowIREdgeSchema = Type.Object({
92
+ from: Type.String({ description: "Upstream (producer) node id" }),
93
+ to: Type.String({ description: "Downstream (consumer) node id" }),
94
+ }, { additionalProperties: false });
95
+ /**
96
+ * TypeBox schema mirroring {@link FlowIR}.
97
+ */
98
+ export const FlowIRSchema = Type.Object({
99
+ name: Type.String({ minLength: 1, description: "Workflow name" }),
100
+ version: Type.Optional(Type.Number({ description: "DSL schema version" })),
101
+ nodes: Type.Array(FlowIRNodeSchema, { minItems: 1, description: "IR nodes (one per phase)" }),
102
+ edges: Type.Optional(Type.Array(FlowIREdgeSchema, { description: "Explicit edge list" })),
103
+ args: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Declared invocation arguments" })),
104
+ budget: Type.Optional(Type.Object({
105
+ maxUSD: Type.Optional(Type.Number()),
106
+ maxTokens: Type.Optional(Type.Number()),
107
+ }, { additionalProperties: false })),
108
+ concurrency: Type.Optional(Type.Number({ description: "Default max concurrent subagents" })),
109
+ meta: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Flow-level metadata" })),
110
+ }, { additionalProperties: false });
111
+ // ---------------------------------------------------------------------------
112
+ // Structural guards — pure, zero-dep (beyond typebox), fail-closed
113
+ // ---------------------------------------------------------------------------
114
+ /** The 10 valid phase kinds, for O(1) membership checks without TypeBox. */
115
+ const VALID_KINDS = new Set(PHASE_TYPES);
116
+ /**
117
+ * Narrow an `unknown` value to a {@link FlowIRNode}. Pure, synchronous,
118
+ * fail-closed: returns `false` for anything that is not a plain object with
119
+ * a string `id`, a valid `kind`, and string-array `inject`/`emits`. Does not
120
+ * throw. This is a *structural* check (not a deep TypeBox decode) so it stays
121
+ * cheap and dependency-light; use {@link assertFlowIR} for full validation.
122
+ */
123
+ export function isFlowIRNode(value) {
124
+ if (typeof value !== "object" || value === null || Array.isArray(value))
125
+ return false;
126
+ const n = value;
127
+ if (typeof n.id !== "string" || n.id.length === 0)
128
+ return false;
129
+ if (typeof n.kind !== "string" || !VALID_KINDS.has(n.kind))
130
+ return false;
131
+ if (!isStringArray(n.inject))
132
+ return false;
133
+ if (!isStringArray(n.emits))
134
+ return false;
135
+ if (n.when !== undefined && typeof n.when !== "string")
136
+ return false;
137
+ if (n.task !== undefined && typeof n.task !== "string")
138
+ return false;
139
+ if (n.condRef !== undefined && typeof n.condRef !== "string")
140
+ return false;
141
+ if (n.deps !== undefined && !isStringArray(n.deps))
142
+ return false;
143
+ if (n.join !== undefined && n.join !== "all" && n.join !== "any")
144
+ return false;
145
+ if (n.timeout !== undefined && typeof n.timeout !== "number")
146
+ return false;
147
+ if (n.payload !== undefined && (typeof n.payload !== "object" || n.payload === null || Array.isArray(n.payload))) {
148
+ return false;
149
+ }
150
+ return true;
151
+ }
152
+ /** Type guard for a `string[]`. */
153
+ function isStringArray(v) {
154
+ if (!Array.isArray(v))
155
+ return false;
156
+ return v.every((x) => typeof x === "string");
157
+ }
158
+ /**
159
+ * Assert that a value is a well-formed {@link FlowIR}. Throws a descriptive
160
+ * `Error` (not an `AssertionError`) on the first structural violation —
161
+ * fail-closed, so a malformed IR can never silently reach the kernel. Uses
162
+ * the lightweight structural checks (no external validator); for full schema
163
+ * decoding, decode `FlowIRSchema` with a TypeBox-compatible checker.
164
+ *
165
+ * @throws {Error} if `value` is not a valid `FlowIR`.
166
+ */
167
+ export function assertFlowIR(value) {
168
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
169
+ throw new Error(`FlowIR: expected an object, got ${typeof value}`);
170
+ }
171
+ const ir = value;
172
+ if (typeof ir.name !== "string" || ir.name.length === 0) {
173
+ throw new Error(`FlowIR: 'name' must be a non-empty string`);
174
+ }
175
+ if (ir.version !== undefined && typeof ir.version !== "number") {
176
+ throw new Error(`FlowIR: 'version' must be a number if present`);
177
+ }
178
+ if (!Array.isArray(ir.nodes) || ir.nodes.length === 0) {
179
+ throw new Error(`FlowIR: 'nodes' must be a non-empty array`);
180
+ }
181
+ const seenIds = new Set();
182
+ for (let i = 0; i < ir.nodes.length; i++) {
183
+ const node = ir.nodes[i];
184
+ if (!isFlowIRNode(node)) {
185
+ throw new Error(`FlowIR: nodes[${i}] is not a valid FlowIRNode (id=${String(node?.id)})`);
186
+ }
187
+ if (seenIds.has(node.id)) {
188
+ throw new Error(`FlowIR: duplicate node id '${node.id}'`);
189
+ }
190
+ seenIds.add(node.id);
191
+ }
192
+ if (ir.edges !== undefined) {
193
+ if (!Array.isArray(ir.edges)) {
194
+ throw new Error(`FlowIR: 'edges' must be an array if present`);
195
+ }
196
+ for (let i = 0; i < ir.edges.length; i++) {
197
+ const e = ir.edges[i];
198
+ if (typeof e !== "object" ||
199
+ e === null ||
200
+ typeof e.from !== "string" ||
201
+ typeof e.to !== "string") {
202
+ throw new Error(`FlowIR: edges[${i}] must be { from: string, to: string }`);
203
+ }
204
+ if (!seenIds.has(e.from)) {
205
+ throw new Error(`FlowIR: edges[${i}].from references unknown node '${e.from}'`);
206
+ }
207
+ if (!seenIds.has(e.to)) {
208
+ throw new Error(`FlowIR: edges[${i}].to references unknown node '${e.to}'`);
209
+ }
210
+ }
211
+ }
212
+ if (ir.budget !== undefined) {
213
+ if (typeof ir.budget !== "object" || ir.budget === null || Array.isArray(ir.budget)) {
214
+ throw new Error(`FlowIR: 'budget' must be an object if present`);
215
+ }
216
+ const b = ir.budget;
217
+ if (b.maxUSD !== undefined && typeof b.maxUSD !== "number") {
218
+ throw new Error(`FlowIR: 'budget.maxUSD' must be a number if present`);
219
+ }
220
+ if (b.maxTokens !== undefined && typeof b.maxTokens !== "number") {
221
+ throw new Error(`FlowIR: 'budget.maxTokens' must be a number if present`);
222
+ }
223
+ }
224
+ if (ir.concurrency !== undefined && typeof ir.concurrency !== "number") {
225
+ throw new Error(`FlowIR: 'concurrency' must be a number if present`);
226
+ }
227
+ if (ir.args !== undefined && (typeof ir.args !== "object" || ir.args === null || Array.isArray(ir.args))) {
228
+ throw new Error(`FlowIR: 'args' must be an object if present`);
229
+ }
230
+ if (ir.meta !== undefined && (typeof ir.meta !== "object" || ir.meta === null || Array.isArray(ir.meta))) {
231
+ throw new Error(`FlowIR: 'meta' must be an object if present`);
232
+ }
233
+ }
234
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/flowir/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAkB,MAAM,cAAc,CAAC;AAE3D,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,EAAE;IACrD,WAAW,EAAE,oFAAoF;CACjG,CAAC,CAAC;AA0JH,8EAA8E;AAC9E,+DAA+D;AAC/D,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAC1C;IACC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IAC3D,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,C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ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EAEd,MAAM,EAEN,cAAc,EACd,MAAM,WAAW,CAAC;AAoEnB;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,CAoEA"}
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/flowir/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EAEd,MAAM,EAEN,cAAc,EACd,MAAM,WAAW,CAAC;AAuEnB;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,CAoEA"}
@@ -67,6 +67,9 @@ const SIDECAR_PHASE_FIELDS = [
67
67
  "score",
68
68
  "cache",
69
69
  "shareContext",
70
+ "cancelLosers",
71
+ "expandMode",
72
+ "maxNodes",
70
73
  ];
71
74
  /** Build the per-phase sidecar record (verbatim copy of non-IR fields). */
72
75
  function sidecarForPhase(phase) {
@@ -1 +1 @@
1
- {"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/flowir/translate.ts"],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AO,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,UAAU;iBAC/D,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,yEAAyE;YACzE,4DAA4D;QAC7D,CAAC;QAED,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAEjD,OAAO;YACN,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;YAC3B,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YACzB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,IAAI,EAAE,KAAK,CAAC,IAAI;SACK,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,GAAW;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,WAAW,EAAE,GAAG,CAAC,WAAW;KAC5B,CAAC;IAEF,MAAM,IAAI,GAAmB;QAC5B,cAAc,EAAE,GAAG,CAAC,IAAI;QACxB,YAAY;QACZ,OAAO,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;KAClC,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AACzD,CAAC"}
@@ -96,6 +96,9 @@ export interface RunOptions {
96
96
  * instead, so the engine's retry and fail-soft logic can act on it.
97
97
  */
98
98
  export interface SubagentRunner<TAgent = unknown> {
99
+ /** Whether this host reports authoritative token/cost usage. `unavailable`
100
+ * makes runtime budget declarations fail closed at every execution boundary. */
101
+ readonly usageAccounting?: "available" | "tokens-only" | "unavailable";
99
102
  runTask(defaultCwd: string, agents: TAgent[], agentName: string, task: string, opts: RunOptions, globalThinking?: string): Promise<RunResult>;
100
103
  }
101
104
  //# sourceMappingURL=runner-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner-types.d.ts","sourceRoot":"","sources":["../../src/host/runner-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AACD,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACrB;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;yEACqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,yDAAyD;AACzD,MAAM,WAAW,UAAU;IAC1B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;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,aAAa,GAAG,aAAa,CAAC;IACvE,OAAO,CACN,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,cAAc,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,SAAS,CAAC,CAAC;CACtB"}
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from "./cache.ts";
20
20
  export * from "./interpolate.ts";
21
21
  export * from "./verify.ts";
22
22
  export * from "./usage.ts";
23
+ export * from "./rates.ts";
23
24
  export * from "./stale.ts";
24
25
  export * from "./workspace.ts";
25
26
  export * from "./context-store.ts";
@@ -35,4 +36,5 @@ export * from "./flowir/index.ts";
35
36
  export * from "./trace.ts";
36
37
  export * from "./deterministic.ts";
37
38
  export * from "./replay.ts";
39
+ export * from "./exec/index.ts";
38
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAK7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAK7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export * from "./cache.js";
20
20
  export * from "./interpolate.js";
21
21
  export * from "./verify.js";
22
22
  export * from "./usage.js";
23
+ export * from "./rates.js";
23
24
  export * from "./stale.js";
24
25
  export * from "./workspace.js";
25
26
  export * from "./context-store.js";
@@ -39,4 +40,5 @@ export * from "./flowir/index.js";
39
40
  export * from "./trace.js";
40
41
  export * from "./deterministic.js";
41
42
  export * from "./replay.js";
43
+ export * from "./exec/index.js";
42
44
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,mCAAmC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AA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