fascicle 0.12.1 → 0.12.3

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 (47) hide show
  1. package/CHANGELOG.md +79 -33
  2. package/README.md +13 -13
  3. package/dist/{adapters-hmnJOOgf.js → adapters-CutexJd3.js} +12 -12
  4. package/dist/adapters-CutexJd3.js.map +1 -0
  5. package/dist/adapters.d.ts +10 -10
  6. package/dist/adapters.js +1 -1
  7. package/dist/agents.d.ts +13 -3
  8. package/dist/agents.js +12 -5
  9. package/dist/agents.js.map +1 -1
  10. package/dist/{core-DDRhHu5P.js → core-DdJEhyQc.js} +122 -488
  11. package/dist/core-DdJEhyQc.js.map +1 -0
  12. package/dist/{engine-b4ZH8esY.js → engine-J4lIxpw5.js} +40 -357
  13. package/dist/engine-J4lIxpw5.js.map +1 -0
  14. package/dist/index.d.ts +85 -25
  15. package/dist/index.js +402 -48
  16. package/dist/index.js.map +1 -1
  17. package/dist/{invoke-CyKNhvBw.js → invoke-CH_eJZeS.js} +8 -8
  18. package/dist/{invoke-CyKNhvBw.js.map → invoke-CH_eJZeS.js.map} +1 -1
  19. package/dist/leading_system-BUCT-PwD.js +330 -0
  20. package/dist/leading_system-BUCT-PwD.js.map +1 -0
  21. package/dist/mcp.d.ts +5 -5
  22. package/dist/mcp.js +10 -9
  23. package/dist/mcp.js.map +1 -1
  24. package/dist/otel.d.ts +1 -1
  25. package/dist/otel.js +4 -4
  26. package/dist/otel.js.map +1 -1
  27. package/dist/stdio.d.ts +2 -2
  28. package/dist/stdio.js +2 -2
  29. package/dist/testing.d.ts +1 -1
  30. package/dist/testing.js +3 -2
  31. package/dist/testing.js.map +1 -1
  32. package/dist/{trajectory-cSLNlHzh.d.ts → trajectory-ByoOQZ6T.d.ts} +10 -10
  33. package/dist/trajectory-D1eq9eue.js +81 -0
  34. package/dist/trajectory-D1eq9eue.js.map +1 -0
  35. package/dist/{types-BCtKsxrX.d.ts → types-BK0UW28o.d.ts} +3 -3
  36. package/dist/{types-BqUY6nRX.d.ts → types-DBpU27sQ.d.ts} +7 -2
  37. package/dist/{types-CXBB4aIM.d.ts → types-DU6cvoA4.d.ts} +3 -3
  38. package/dist/ui.d.ts +1 -1
  39. package/dist/ui.js +1 -1
  40. package/dist/ui.js.map +1 -1
  41. package/dist/viewer.d.ts +8 -8
  42. package/dist/viewer.js +16 -15
  43. package/dist/viewer.js.map +1 -1
  44. package/package.json +5 -4
  45. package/dist/adapters-hmnJOOgf.js.map +0 -1
  46. package/dist/core-DDRhHu5P.js.map +0 -1
  47. package/dist/engine-b4ZH8esY.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,9 +1,370 @@
1
- import { A as describe, B as flow_schema_default, D as branch, E as map, F as describe_cycle_error, I as error_path, L as resume_validation_error, M as step, N as run, O as parallel, P as aborted_error, R as suspended_error, S as retry, T as pipe, _ as checkpoint, a as is_span_end_event, b as timeout, c as STEP_KINDS, d as scope, f as stash, i as is_run_end_event, j as is_step, k as sequence, l as is_step_kind, m as suspend, n as is_custom_trajectory_event, o as is_span_start_event, p as use, r as is_emit_event, s as parse_trajectory_event, t as is_checkpoint_event, u as chain, v as compose, x as fallback, y as loop, z as timeout_error } from "./core-DDRhHu5P.js";
2
- import { _ as schema_validation_error, a as claude_cli_error, c as incomplete_generation_error, d as provider_auth_error, f as provider_capability_error, g as rate_limit_error, h as provider_required_error, l as model_required_error, m as provider_not_configured_error, o as engine_config_error, p as provider_error, r as default_normalize_usage, s as engine_disposed_error, t as create_engine, u as on_chunk_error, v as tool_approval_denied_error, y as tool_error } from "./engine-b4ZH8esY.js";
3
- import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-hmnJOOgf.js";
1
+ import { A as error_path, C as step, D as run, E as suggest_step_id, M as suspended_error, N as timeout_error, O as aborted_error, P as resolve_display_name, S as is_step, T as is_valid_step_id, _ as map, a as suspend, b as sequence, c as checkpoint, d as timeout, f as fallback, g as pipe, i as use, j as resume_validation_error, k as describe_cycle_error, l as compose, n as scope, p as retry, r as stash, t as chain, u as loop, v as branch, w as assert_valid_step_id, x as describe, y as parallel } from "./core-DdJEhyQc.js";
2
+ import { t as create_engine } from "./engine-J4lIxpw5.js";
3
+ import { a as is_span_end_event, i as is_run_end_event, n as is_custom_trajectory_event, o as is_span_start_event, r as is_emit_event, s as parse_trajectory_event, t as is_checkpoint_event } from "./trajectory-D1eq9eue.js";
4
+ import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-CutexJd3.js";
5
+ import { _ as provider_required_error, b as tool_approval_denied_error, c as engine_config_error, d as model_required_error, f as on_chunk_error, g as provider_not_configured_error, h as provider_error, l as engine_disposed_error, m as provider_capability_error, n as default_normalize_usage, p as provider_auth_error, s as claude_cli_error, u as incomplete_generation_error, v as rate_limit_error, x as tool_error, y as schema_validation_error } from "./leading_system-BUCT-PwD.js";
4
6
  import { createHash } from "node:crypto";
5
7
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
6
8
  import { dirname, join } from "node:path";
9
+ //#region src/core/flow-schema.json
10
+ var flow_schema_default = {
11
+ $schema: "https://json-schema.org/draft/2020-12/schema",
12
+ $id: "https://robmclarty.dev/schemas/flow-schema.json",
13
+ title: "fascicle Flow DSL",
14
+ description: "YAML/JSON representation of a composition tree. Documentation-only in v1. See spec.md §5.17.",
15
+ type: "array",
16
+ items: { "$ref": "#/$defs/compose_entry" },
17
+ $defs: {
18
+ "compose_entry": {
19
+ "type": "object",
20
+ "required": ["compose"],
21
+ "properties": { "compose": { "type": "string" } },
22
+ "allOf": [{ "$ref": "#/$defs/node" }]
23
+ },
24
+ "node": {
25
+ "type": "object",
26
+ "anyOf": [
27
+ { "required": ["step"] },
28
+ { "required": ["sequence"] },
29
+ { "required": ["parallel"] },
30
+ { "required": ["branch"] },
31
+ { "required": ["map"] },
32
+ { "required": ["pipe"] },
33
+ { "required": ["retry"] },
34
+ { "required": ["fallback"] },
35
+ { "required": ["timeout"] },
36
+ { "required": ["loop"] },
37
+ { "required": ["compose_node"] },
38
+ { "required": ["adversarial"] },
39
+ { "required": ["ensemble"] },
40
+ { "required": ["tournament"] },
41
+ { "required": ["consensus"] },
42
+ { "required": ["checkpoint"] },
43
+ { "required": ["suspend"] },
44
+ { "required": ["scope"] },
45
+ { "required": ["chain"] },
46
+ { "required": ["ref"] }
47
+ ],
48
+ "properties": {
49
+ "step": { "$ref": "#/$defs/step_config" },
50
+ "sequence": { "$ref": "#/$defs/sequence_config" },
51
+ "parallel": { "$ref": "#/$defs/parallel_config" },
52
+ "branch": { "$ref": "#/$defs/branch_config" },
53
+ "map": { "$ref": "#/$defs/map_config" },
54
+ "pipe": { "$ref": "#/$defs/pipe_config" },
55
+ "retry": { "$ref": "#/$defs/retry_config" },
56
+ "fallback": { "$ref": "#/$defs/fallback_config" },
57
+ "timeout": { "$ref": "#/$defs/timeout_config" },
58
+ "loop": { "$ref": "#/$defs/loop_config" },
59
+ "compose_node": { "$ref": "#/$defs/compose_node_config" },
60
+ "adversarial": { "$ref": "#/$defs/adversarial_config" },
61
+ "ensemble": { "$ref": "#/$defs/ensemble_config" },
62
+ "tournament": { "$ref": "#/$defs/tournament_config" },
63
+ "consensus": { "$ref": "#/$defs/consensus_config" },
64
+ "checkpoint": { "$ref": "#/$defs/checkpoint_config" },
65
+ "suspend": { "$ref": "#/$defs/suspend_config" },
66
+ "scope": { "$ref": "#/$defs/scope_config" },
67
+ "chain": { "$ref": "#/$defs/chain_config" },
68
+ "ref": { "type": "string" }
69
+ }
70
+ },
71
+ "step_config": {
72
+ "type": "object",
73
+ "required": ["fn"],
74
+ "properties": {
75
+ "id": { "type": "string" },
76
+ "fn": { "type": "string" }
77
+ }
78
+ },
79
+ "sequence_config": {
80
+ "type": "array",
81
+ "items": { "$ref": "#/$defs/node" }
82
+ },
83
+ "parallel_config": {
84
+ "type": "object",
85
+ "additionalProperties": { "$ref": "#/$defs/node" }
86
+ },
87
+ "branch_config": {
88
+ "type": "object",
89
+ "required": [
90
+ "when",
91
+ "then",
92
+ "otherwise"
93
+ ],
94
+ "properties": {
95
+ "when": { "type": "string" },
96
+ "then": { "$ref": "#/$defs/node" },
97
+ "otherwise": { "$ref": "#/$defs/node" }
98
+ }
99
+ },
100
+ "map_config": {
101
+ "type": "object",
102
+ "required": ["items", "do"],
103
+ "properties": {
104
+ "items": { "type": "string" },
105
+ "do": { "$ref": "#/$defs/node" },
106
+ "concurrency": {
107
+ "type": "integer",
108
+ "minimum": 1
109
+ }
110
+ }
111
+ },
112
+ "pipe_config": {
113
+ "type": "object",
114
+ "required": ["of", "fn"],
115
+ "properties": {
116
+ "of": { "$ref": "#/$defs/node" },
117
+ "fn": { "type": "string" }
118
+ }
119
+ },
120
+ "retry_config": {
121
+ "type": "object",
122
+ "required": ["do", "max_attempts"],
123
+ "properties": {
124
+ "do": { "$ref": "#/$defs/node" },
125
+ "max_attempts": {
126
+ "type": "integer",
127
+ "minimum": 1
128
+ },
129
+ "backoff_ms": {
130
+ "type": "integer",
131
+ "minimum": 0
132
+ }
133
+ }
134
+ },
135
+ "fallback_config": {
136
+ "type": "object",
137
+ "required": ["primary", "backup"],
138
+ "properties": {
139
+ "primary": { "$ref": "#/$defs/node" },
140
+ "backup": { "$ref": "#/$defs/node" }
141
+ }
142
+ },
143
+ "timeout_config": {
144
+ "type": "object",
145
+ "required": ["do", "ms"],
146
+ "properties": {
147
+ "do": { "$ref": "#/$defs/node" },
148
+ "ms": {
149
+ "type": "integer",
150
+ "minimum": 1
151
+ }
152
+ }
153
+ },
154
+ "compose_node_config": {
155
+ "type": "object",
156
+ "required": ["name", "do"],
157
+ "properties": {
158
+ "name": {
159
+ "type": "string",
160
+ "minLength": 1
161
+ },
162
+ "do": { "$ref": "#/$defs/node" }
163
+ }
164
+ },
165
+ "loop_config": {
166
+ "type": "object",
167
+ "required": ["body", "max_rounds"],
168
+ "properties": {
169
+ "name": {
170
+ "type": "string",
171
+ "minLength": 1
172
+ },
173
+ "init": { "type": "string" },
174
+ "body": { "$ref": "#/$defs/node" },
175
+ "guard": { "$ref": "#/$defs/node" },
176
+ "finish": { "type": "string" },
177
+ "max_rounds": {
178
+ "type": "integer",
179
+ "minimum": 1
180
+ }
181
+ }
182
+ },
183
+ "adversarial_config": {
184
+ "type": "object",
185
+ "required": [
186
+ "build",
187
+ "critique",
188
+ "accept",
189
+ "max_rounds"
190
+ ],
191
+ "properties": {
192
+ "build": { "$ref": "#/$defs/node" },
193
+ "critique": { "$ref": "#/$defs/node" },
194
+ "accept": { "type": "string" },
195
+ "max_rounds": {
196
+ "type": "integer",
197
+ "minimum": 1
198
+ }
199
+ }
200
+ },
201
+ "ensemble_config": {
202
+ "type": "object",
203
+ "required": ["members", "score"],
204
+ "properties": {
205
+ "members": {
206
+ "type": "object",
207
+ "additionalProperties": { "$ref": "#/$defs/node" }
208
+ },
209
+ "score": { "type": "string" },
210
+ "select": {
211
+ "type": "string",
212
+ "enum": ["max", "min"]
213
+ }
214
+ }
215
+ },
216
+ "tournament_config": {
217
+ "type": "object",
218
+ "required": ["members", "compare"],
219
+ "properties": {
220
+ "members": {
221
+ "type": "object",
222
+ "additionalProperties": { "$ref": "#/$defs/node" }
223
+ },
224
+ "compare": { "type": "string" }
225
+ }
226
+ },
227
+ "consensus_config": {
228
+ "type": "object",
229
+ "required": [
230
+ "members",
231
+ "agree",
232
+ "max_rounds"
233
+ ],
234
+ "properties": {
235
+ "members": {
236
+ "type": "object",
237
+ "additionalProperties": { "$ref": "#/$defs/node" }
238
+ },
239
+ "agree": { "type": "string" },
240
+ "max_rounds": {
241
+ "type": "integer",
242
+ "minimum": 1
243
+ }
244
+ }
245
+ },
246
+ "checkpoint_config": {
247
+ "type": "object",
248
+ "required": ["do", "key"],
249
+ "properties": {
250
+ "do": { "$ref": "#/$defs/node" },
251
+ "key": { "type": "string" }
252
+ }
253
+ },
254
+ "suspend_config": {
255
+ "type": "object",
256
+ "required": [
257
+ "id",
258
+ "on",
259
+ "resume_schema",
260
+ "combine"
261
+ ],
262
+ "properties": {
263
+ "id": { "type": "string" },
264
+ "on": { "type": "string" },
265
+ "resume_schema": { "type": "string" },
266
+ "combine": { "type": "string" }
267
+ }
268
+ },
269
+ "scope_config": {
270
+ "type": "array",
271
+ "items": { "$ref": "#/$defs/scope_entry" }
272
+ },
273
+ "scope_entry": {
274
+ "type": "object",
275
+ "oneOf": [{
276
+ "type": "object",
277
+ "required": ["stash", "do"],
278
+ "properties": {
279
+ "stash": { "type": "string" },
280
+ "do": { "$ref": "#/$defs/node" }
281
+ }
282
+ }, {
283
+ "type": "object",
284
+ "required": ["use", "do"],
285
+ "properties": {
286
+ "use": {
287
+ "type": "array",
288
+ "items": { "type": "string" }
289
+ },
290
+ "do": { "$ref": "#/$defs/node" }
291
+ }
292
+ }]
293
+ },
294
+ "chain_config": {
295
+ "type": "object",
296
+ "required": ["steps", "output"],
297
+ "properties": {
298
+ "input": { "type": "string" },
299
+ "steps": {
300
+ "type": "array",
301
+ "items": { "$ref": "#/$defs/chain_entry" }
302
+ },
303
+ "output": { "type": "string" }
304
+ }
305
+ },
306
+ "chain_entry": {
307
+ "type": "object",
308
+ "oneOf": [{
309
+ "type": "object",
310
+ "required": ["step", "fn"],
311
+ "properties": {
312
+ "step": { "type": "string" },
313
+ "fn": { "type": "string" }
314
+ }
315
+ }, {
316
+ "type": "object",
317
+ "required": ["stage"],
318
+ "properties": {
319
+ "stage": { "type": "string" },
320
+ "project": { "type": "string" }
321
+ }
322
+ }]
323
+ }
324
+ }
325
+ };
326
+ //#endregion
327
+ //#region src/core/step_kinds.ts
328
+ /**
329
+ * Closed registry of every `Step.kind` produced by the composition layer.
330
+ *
331
+ * Studio (and any other consumer that needs to enumerate primitives: palette,
332
+ * docs, code generation) can rely on this being the exhaustive set. New
333
+ * primitives must add their kind here. `step_kinds.test.ts` pins the list
334
+ * against the kinds core actually constructs, and
335
+ * `composites/__tests__/coverage.test.ts` covers the four composite kinds
336
+ * whose factories live outside core.
337
+ */
338
+ const STEP_KINDS = [
339
+ "step",
340
+ "sequence",
341
+ "parallel",
342
+ "branch",
343
+ "map",
344
+ "pipe",
345
+ "retry",
346
+ "fallback",
347
+ "timeout",
348
+ "loop",
349
+ "compose",
350
+ "adversarial",
351
+ "ensemble",
352
+ "tournament",
353
+ "consensus",
354
+ "checkpoint",
355
+ "suspend",
356
+ "scope",
357
+ "stash",
358
+ "use",
359
+ "chain"
360
+ ];
361
+ /**
362
+ * Check whether a value is one of the registered `Step.kind` strings.
363
+ */
364
+ function is_step_kind(value) {
365
+ return typeof value === "string" && STEP_KINDS.includes(value);
366
+ }
367
+ //#endregion
7
368
  //#region src/composites/adversarial.ts
8
369
  /**
9
370
  * adversarial: build-and-critique loop.
@@ -38,7 +399,7 @@ function build_input_from_state(s) {
38
399
  * notes when available), critiques it, then checks `accept(critique_result)`.
39
400
  * Returns `{ candidate, converged, rounds }`. Does not throw on
40
401
  * non-convergence; `converged: false` reports it instead. `project` maps
41
- * that envelope into the step's output (e.g. `(r) => r.candidate`); omitted,
402
+ * that envelope into the step's output (for example, `(r) => r.candidate`); omitted,
42
403
  * the envelope itself is the output.
43
404
  *
44
405
  * Implemented as a `compose`d `loop` whose body builds a new candidate and
@@ -49,7 +410,7 @@ function build_input_from_state(s) {
49
410
  function adversarial(config) {
50
411
  const { build, critique, accept, max_rounds } = config;
51
412
  const project = config.project ?? ((r) => r);
52
- const inner = loop({
413
+ return compose(loop({
53
414
  init: (input) => ({ input }),
54
415
  body: scope([
55
416
  stash("state", step("snapshot", (s) => s)),
@@ -90,8 +451,7 @@ function adversarial(config) {
90
451
  });
91
452
  },
92
453
  max_rounds
93
- });
94
- return compose(config.name ?? "adversarial", inner);
454
+ }), { name: config.name ?? "adversarial" });
95
455
  }
96
456
  //#endregion
97
457
  //#region src/composites/consensus.ts
@@ -106,7 +466,7 @@ function adversarial(config) {
106
466
  * Otherwise re-runs all members up to `max_rounds` times and returns the
107
467
  * last results with `converged: false` if no agreement is reached.
108
468
  * `project` maps the `{ result, converged }` envelope into the step's output
109
- * (e.g. `(r) => r.converged`); omitted, the envelope itself is the output.
469
+ * (for example, `(r) => r.converged`); omitted, the envelope itself is the output.
110
470
  *
111
471
  * Implemented as a `compose`d `loop` whose body runs `parallel(members)` and
112
472
  * whose guard evaluates `agree`. State carries the original input alongside
@@ -116,7 +476,7 @@ function consensus(config) {
116
476
  const { members, agree, max_rounds } = config;
117
477
  const project = config.project ?? ((r) => r);
118
478
  const round_step = parallel(members);
119
- const inner = loop({
479
+ return compose(loop({
120
480
  init: (input) => ({
121
481
  input,
122
482
  results: {}
@@ -141,8 +501,7 @@ function consensus(config) {
141
501
  converged
142
502
  }),
143
503
  max_rounds
144
- });
145
- return compose(config.name ?? "consensus", inner);
504
+ }), { name: config.name ?? "consensus" });
146
505
  }
147
506
  //#endregion
148
507
  //#region src/composites/ensemble.ts
@@ -156,7 +515,7 @@ function consensus(config) {
156
515
  * `select` picks the highest (`'max'`, the default) or lowest (`'min'`)
157
516
  * score. Tie-breaking is "any tied result is acceptable": the first member
158
517
  * (in `members` key order) holding the best score wins. `project` maps the
159
- * `{ winner, scores }` envelope into the step's output (e.g. `(r) =>
518
+ * `{ winner, scores }` envelope into the step's output (for example, `(r) =>
160
519
  * r.winner`); omitted, the envelope itself is the output.
161
520
  *
162
521
  * Implemented as a `compose`d `sequence` of `parallel(members)` followed by
@@ -168,7 +527,7 @@ function ensemble(config) {
168
527
  const score_fn = config.score;
169
528
  const keys = Object.keys(config.members);
170
529
  const project = config.project ?? ((r) => r);
171
- const inner = sequence([parallel(config.members), step("pick_winner", async (results) => {
530
+ return compose(sequence([parallel(config.members), step("pick_winner", async (results) => {
172
531
  const scores = {};
173
532
  for (const k of keys) {
174
533
  const value = results[k];
@@ -197,8 +556,7 @@ function ensemble(config) {
197
556
  winner,
198
557
  scores
199
558
  });
200
- })]);
201
- return compose(config.name ?? "ensemble", inner);
559
+ })]), { name: config.name ?? "ensemble" });
202
560
  }
203
561
  //#endregion
204
562
  //#region src/composites/ensemble_step.ts
@@ -211,16 +569,16 @@ const ITEM_KEY = "__ensemble_step_item";
211
569
  * Builds a Step that runs every member concurrently, scores each result via
212
570
  * a scoring `Step`, and returns the best-ranking winner.
213
571
  *
214
- * Sibling of `ensemble` for the case where scoring is itself a `Step` (e.g.
215
- * a separate model call, a sub-flow, anything that wants its own trajectory
216
- * span and abort routing). The `score` step is dispatched once per member
217
- * result; `rank_by` projects a number out of the structured scored output;
572
+ * Sibling of `ensemble` for the case where scoring is itself a `Step` (for
573
+ * example, a separate model call, a sub-flow, anything that wants its own
574
+ * trajectory span and abort routing). The `score` step is dispatched once per
575
+ * member result; `rank_by` projects a number out of the structured scored output;
218
576
  * `select` picks the highest (`'max'`, default) or lowest (`'min'`) rank.
219
577
  *
220
578
  * The result carries `winner_scored`, the structured output from the round's
221
579
  * scoring run preserved verbatim, so callers never pay to re-score the
222
580
  * winner. `scored` holds the structured score for every member. `project`
223
- * maps that envelope into the step's output (e.g. `(r) => r.winner`);
581
+ * maps that envelope into the step's output (for example, `(r) => r.winner`);
224
582
  * omitted, the envelope itself is the output.
225
583
  *
226
584
  * Implemented as a `compose`d `scope` over (`stash(parallel(members))` ->
@@ -283,13 +641,12 @@ function ensemble_step(config) {
283
641
  scored
284
642
  });
285
643
  });
286
- const inner = scope([
644
+ return compose(scope([
287
645
  stash(RESULTS_KEY, fan_out),
288
646
  to_pairs,
289
647
  score_each,
290
648
  pick
291
- ]);
292
- return compose(config.name ?? "ensemble_step", inner);
649
+ ]), { name: config.name ?? "ensemble_step" });
293
650
  }
294
651
  //#endregion
295
652
  //#region src/composites/gate.ts
@@ -372,7 +729,7 @@ function bind_store(persisted, store) {
372
729
  * how the decision stays signal-only.
373
730
  */
374
731
  function gate(inner, config) {
375
- if (inner.anonymous === true) throw new Error("gate requires a named inner step; got anonymous");
732
+ if (inner.anonymous === true) throw new Error("gate requires a named inner step, got anonymous — give the inner step an id with step('id', fn)");
376
733
  const { id, store, format } = config;
377
734
  const checkpointed = checkpoint(inner, { key: `gate:${id}` });
378
735
  const persisted = store === void 0 ? checkpointed : bind_store(checkpointed, store);
@@ -385,12 +742,11 @@ function gate(inner, config) {
385
742
  resume_schema: approval_schema,
386
743
  combine: () => restore
387
744
  });
388
- const body = scope([
745
+ return compose(scope([
389
746
  stash("result", persisted),
390
747
  step("project_payload", (result) => format === void 0 ? result : format(result)),
391
748
  approval
392
- ]);
393
- return compose(config.name ?? "gate", body);
749
+ ]), { name: config.name ?? "gate" });
394
750
  }
395
751
  //#endregion
396
752
  //#region src/composites/improve.ts
@@ -415,7 +771,7 @@ const PRIOR_KEY = "__improve_prior";
415
771
  * next round's input. Plateau detection stops the loop early when no
416
772
  * progress has been made for `patience` rounds; an optional wall-clock
417
773
  * budget caps total runtime. `project` maps the result envelope into the
418
- * step's output (e.g. `(r) => r.best.content`); omitted, the envelope
774
+ * step's output (for example, `(r) => r.best.content`); omitted, the envelope
419
775
  * itself is the output.
420
776
  *
421
777
  * Implemented as a `compose`d `scope` of (seed) -> (init state) -> (loop) ->
@@ -519,7 +875,7 @@ function improve(config) {
519
875
  lessons: next_lessons
520
876
  };
521
877
  });
522
- const inner = scope([
878
+ return compose(scope([
523
879
  seed,
524
880
  init_state,
525
881
  loop({
@@ -571,8 +927,7 @@ function improve(config) {
571
927
  });
572
928
  return project(result);
573
929
  })
574
- ]);
575
- return compose(config.name ?? "improve", inner);
930
+ ]), { name: config.name ?? "improve" });
576
931
  }
577
932
  //#endregion
578
933
  //#region src/composites/learn.ts
@@ -739,13 +1094,12 @@ function learn(config) {
739
1094
  run_ids: meta.run_ids
740
1095
  };
741
1096
  });
742
- const inner = scope([
1097
+ return compose(scope([
743
1098
  stash(META_KEY, compute_meta),
744
1099
  build_input,
745
1100
  analyzer,
746
1101
  wrap_result
747
- ]);
748
- return compose(config.name ?? "learn", inner);
1102
+ ]), { name: config.name ?? "learn" });
749
1103
  }
750
1104
  //#endregion
751
1105
  //#region src/composites/tournament.ts
@@ -768,7 +1122,7 @@ function learn(config) {
768
1122
  * All members run concurrently via `parallel`; the bracket step then reduces
769
1123
  * survivors round by round with `compare`, recording every match. Requires at
770
1124
  * least one member so a winner always exists. `project` maps the `{ winner,
771
- * bracket }` envelope into the step's output (e.g. `(r) => r.winner`);
1125
+ * bracket }` envelope into the step's output (for example, `(r) => r.winner`);
772
1126
  * omitted, the envelope itself is the output.
773
1127
  */
774
1128
  function tournament(config) {
@@ -776,7 +1130,7 @@ function tournament(config) {
776
1130
  const keys = Object.keys(config.members);
777
1131
  const project = config.project ?? ((r) => r);
778
1132
  if (keys.length === 0) throw new Error("tournament: at least one member required");
779
- const inner = sequence([parallel(config.members), step("bracket", async (results) => {
1133
+ return compose(sequence([parallel(config.members), step("bracket", async (results) => {
780
1134
  let current = [...keys];
781
1135
  const bracket = [];
782
1136
  let round = 0;
@@ -788,8 +1142,7 @@ function tournament(config) {
788
1142
  winner: winner_of(current, results),
789
1143
  bracket
790
1144
  });
791
- })]);
792
- return compose(config.name ?? "tournament", inner);
1145
+ })]), { name: config.name ?? "tournament" });
793
1146
  }
794
1147
  /**
795
1148
  * Plays one bracket round: pairs survivors two at a time, comparing each pair
@@ -1157,13 +1510,11 @@ function resolve_concurrency(value, n_cases) {
1157
1510
  return Math.max(1, Math.floor(value));
1158
1511
  }
1159
1512
  /**
1160
- * Picks a human-readable name for the report: the flow's `display_name`
1161
- * config when set, else its step id or kind.
1513
+ * Picks a human-readable name for the report, resolving the display channels
1514
+ * the same way spans and `describe` do, then falling back to identity.
1162
1515
  */
1163
1516
  function describe_flow_name(flow) {
1164
- const display = flow.config?.["display_name"];
1165
- if (typeof display === "string" && display.length > 0) return display;
1166
- return flow.id ?? flow.kind ?? "flow";
1517
+ return resolve_display_name(flow, flow.id ?? flow.kind ?? "flow");
1167
1518
  }
1168
1519
  /**
1169
1520
  * Short random base36 suffix to keep default run ids unique across
@@ -1276,11 +1627,11 @@ function judge_llm(config) {
1276
1627
  };
1277
1628
  const build_prompt = step("judge_llm_build_prompt", (args) => render_prompt(config.rubric, scale, args));
1278
1629
  const parse = step("judge_llm_parse", (reply) => parse_score(reply, scale));
1279
- return compose("judge_llm", sequence([
1630
+ return compose(sequence([
1280
1631
  build_prompt,
1281
1632
  config.model,
1282
1633
  parse
1283
- ]));
1634
+ ]), { name: "judge_llm" });
1284
1635
  }
1285
1636
  /**
1286
1637
  * Renders the evaluator prompt: rubric, required JSON reply shape with the
@@ -1600,13 +1951,16 @@ function stable_signature(input) {
1600
1951
  }
1601
1952
  let model_call_counter = 0;
1602
1953
  /**
1603
- * Build the default step id: `model_call:<hash>:<n>`. The instance counter
1954
+ * Build the default step id: `model_call_<hash>_<n>`. The instance counter
1604
1955
  * keeps two leaves built from identical configs distinguishable in describe
1605
1956
  * and the trajectory; the hash still identifies the call's shape.
1957
+ *
1958
+ * Underscore-separated rather than colon-separated because every id in the
1959
+ * system is identifier-shaped, generated ones included.
1606
1960
  */
1607
1961
  function next_auto_id(input) {
1608
1962
  model_call_counter += 1;
1609
- return `model_call:${stable_signature(input)}:${model_call_counter}`;
1963
+ return `model_call_${stable_signature(input)}_${model_call_counter}`;
1610
1964
  }
1611
1965
  /**
1612
1966
  * Copy `value` onto `target[key]` only when it is defined, so an absent optional
@@ -1773,6 +2127,6 @@ function forward_standard_env() {
1773
2127
  return out;
1774
2128
  }
1775
2129
  //#endregion
1776
- export { STEP_KINDS, aborted_error, adversarial, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, compose, consensus, create_engine, default_normalize_usage, describe, describe_cycle_error, engine_config_error, engine_disposed_error, ensemble, ensemble_step, error_path, fallback, flow_schema_default as flow_schema, forward_standard_env, gate, improve, incomplete_generation_error, is_checkpoint_event, is_custom_trajectory_event, is_emit_event, is_run_end_event, is_span_end_event, is_span_start_event, is_step, is_step_kind, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_required_error, model_step, normalize_score, on_chunk_error, parallel, parse_trajectory_event, pipe, provider_auth_error, provider_capability_error, provider_error, provider_not_configured_error, provider_required_error, rate_limit_error, read_baseline, regression_compare, resume_validation_error, retry, run, schema_validation_error, scope, sequence, stash, step, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
2130
+ export { STEP_KINDS, aborted_error, adversarial, assert_valid_step_id, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, compose, consensus, create_engine, default_normalize_usage, describe, describe_cycle_error, engine_config_error, engine_disposed_error, ensemble, ensemble_step, error_path, fallback, flow_schema_default as flow_schema, forward_standard_env, gate, improve, incomplete_generation_error, is_checkpoint_event, is_custom_trajectory_event, is_emit_event, is_run_end_event, is_span_end_event, is_span_start_event, is_step, is_step_kind, is_valid_step_id, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_required_error, model_step, normalize_score, on_chunk_error, parallel, parse_trajectory_event, pipe, provider_auth_error, provider_capability_error, provider_error, provider_not_configured_error, provider_required_error, rate_limit_error, read_baseline, regression_compare, resolve_display_name, resume_validation_error, retry, run, schema_validation_error, scope, sequence, stash, step, suggest_step_id, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
1777
2131
 
1778
2132
  //# sourceMappingURL=index.js.map