fascicle 0.12.13 → 0.13.1

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 (49) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/adapters-DNnzeLxr.js +447 -0
  3. package/dist/adapters-DNnzeLxr.js.map +1 -0
  4. package/dist/adapters.d.ts +54 -9
  5. package/dist/adapters.js +1 -1
  6. package/dist/agents.d.ts +12 -9
  7. package/dist/agents.js +1 -1
  8. package/dist/{core-BVCVUMmH.js → core-DK7g1Z40.js} +887 -74
  9. package/dist/core-DK7g1Z40.js.map +1 -0
  10. package/dist/diagram_bin.d.ts +1 -2
  11. package/dist/diagram_bin.js +5 -2
  12. package/dist/diagram_bin.js.map +1 -1
  13. package/dist/{engine-Ct4LBzb9.js → engine-BOGuc0X2.js} +366 -36
  14. package/dist/engine-BOGuc0X2.js.map +1 -0
  15. package/dist/index.d.ts +342 -180
  16. package/dist/index.js +149 -123
  17. package/dist/index.js.map +1 -1
  18. package/dist/{invoke-BcPDqE5C.js → invoke-Beef3R3X.js} +3 -3
  19. package/dist/{invoke-BcPDqE5C.js.map → invoke-Beef3R3X.js.map} +1 -1
  20. package/dist/mcp.d.ts +8 -9
  21. package/dist/mcp.js +1 -1
  22. package/dist/otel.d.ts +3 -4
  23. package/dist/stdio.d.ts +4 -5
  24. package/dist/stdio.js +2 -2
  25. package/dist/testing.d.ts +46 -10
  26. package/dist/testing.js +540 -4
  27. package/dist/testing.js.map +1 -1
  28. package/dist/{trajectory-D1eq9eue.js → trajectory-BI-mrVFT.js} +25 -2
  29. package/dist/trajectory-BI-mrVFT.js.map +1 -0
  30. package/dist/{trajectory-ByoOQZ6T.d.ts → trajectory-Bm-mOtqw.d.ts} +34 -3
  31. package/dist/{types-BasW4Wwb.d.ts → types-CPqLZOEr.d.ts} +40 -2
  32. package/dist/{types-bEpfDrys.d.ts → types-CZ83Q5nm.d.ts} +12 -7
  33. package/dist/ui.d.ts +11 -10
  34. package/dist/ui.js +3 -2
  35. package/dist/ui.js.map +1 -1
  36. package/dist/viewer-app/assets/index-DXsB0byD.js +2 -0
  37. package/dist/viewer-app/index.html +1 -1
  38. package/dist/viewer.d.ts +7 -8
  39. package/dist/viewer.js +2 -2
  40. package/dist/viewer.js.map +1 -1
  41. package/package.json +28 -28
  42. package/dist/adapters-CutexJd3.js +0 -270
  43. package/dist/adapters-CutexJd3.js.map +0 -1
  44. package/dist/core-BVCVUMmH.js.map +0 -1
  45. package/dist/engine-Ct4LBzb9.js.map +0 -1
  46. package/dist/leading_system-CfOIc5fi.js +0 -330
  47. package/dist/leading_system-CfOIc5fi.js.map +0 -1
  48. package/dist/trajectory-D1eq9eue.js.map +0 -1
  49. package/dist/viewer-app/assets/index-BBEYkjnQ.js +0 -2
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
- import { A as error_path, C as is_valid_step_id, D as is_step, E as describe, F as is_step_kind, I as resolve_display_name, M as suspended_error, N as timeout_error, O as aborted_error, P as STEP_KINDS, S as assert_valid_step_id, T as run, _ 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 suggest_step_id, x as step, y as parallel } from "./core-BVCVUMmH.js";
2
- import { t as create_engine } from "./engine-Ct4LBzb9.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-CfOIc5fi.js";
1
+ import { A as describe_cycle_error, C as is_valid_step_id, D as describe, E as run, F as suspended_error, I as timeout_error, L as STEP_KINDS, M as flow_changed_error, N as resume_validation_error, O as is_step, P as run_not_found_error, R as is_step_kind, S as assert_valid_step_id, T as durable, _ 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 error_path, k as aborted_error, l as compose, n as scope, p as retry, r as stash, t as chain, u as loop, v as branch, w as suggest_step_id, x as step, y as parallel, z as resolve_display_name } from "./core-DK7g1Z40.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-BOGuc0X2.js";
3
+ import { a as is_run_end_event, c as is_step_replayed_event, i as is_map_item_failed_event, l as parse_trajectory_event, n as is_custom_trajectory_event, o as is_span_end_event, r as is_emit_event, s as is_span_start_event, t as is_checkpoint_event } from "./trajectory-BI-mrVFT.js";
4
+ import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-DNnzeLxr.js";
6
5
  import { createHash } from "node:crypto";
7
6
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
8
7
  import { dirname, join } from "node:path";
@@ -106,7 +105,8 @@ var flow_schema_default = {
106
105
  "concurrency": {
107
106
  "type": "integer",
108
107
  "minimum": 1
109
- }
108
+ },
109
+ "settle": { "type": "boolean" }
110
110
  }
111
111
  },
112
112
  "pipe_config": {
@@ -263,7 +263,8 @@ var flow_schema_default = {
263
263
  "id": { "type": "string" },
264
264
  "on": { "type": "string" },
265
265
  "resume_schema": { "type": "string" },
266
- "combine": { "type": "string" }
266
+ "combine": { "type": "string" },
267
+ "deadline_ms": { "type": "number" }
267
268
  }
268
269
  },
269
270
  "scope_config": {
@@ -369,38 +370,40 @@ function build_input_from_state(s) {
369
370
  function adversarial(config) {
370
371
  const { build, critique, accept, max_rounds } = config;
371
372
  const project = config.project ?? ((r) => r);
372
- return compose(loop({
373
+ const body = scope([
374
+ stash("state", step("snapshot", (s) => s)),
375
+ step("to_build_input", (s) => build_input_from_state(s)),
376
+ build,
377
+ use(["state"], (vars, candidate) => {
378
+ return {
379
+ ...vars["state"],
380
+ candidate
381
+ };
382
+ })
383
+ ]);
384
+ const guard = scope([
385
+ stash("state", step("snapshot", (s) => s)),
386
+ step("extract_candidate", (s) => {
387
+ if (s.candidate === void 0) throw new Error("adversarial: guard reached without a candidate");
388
+ return s.candidate;
389
+ }),
390
+ critique,
391
+ use(["state"], (vars, critique_result) => {
392
+ const prior = vars["state"];
393
+ return {
394
+ stop: accept(critique_result),
395
+ state: {
396
+ ...prior,
397
+ last_critique: critique_result,
398
+ critique_notes: critique_result.notes
399
+ }
400
+ };
401
+ })
402
+ ]);
403
+ const inner = loop({
373
404
  init: (input) => ({ input }),
374
- body: scope([
375
- stash("state", step("snapshot", (s) => s)),
376
- step("to_build_input", (s) => build_input_from_state(s)),
377
- build,
378
- use(["state"], (vars, candidate) => {
379
- return {
380
- ...vars["state"],
381
- candidate
382
- };
383
- })
384
- ]),
385
- guard: scope([
386
- stash("state", step("snapshot", (s) => s)),
387
- step("extract_candidate", (s) => {
388
- if (s.candidate === void 0) throw new Error("adversarial: guard reached without a candidate");
389
- return s.candidate;
390
- }),
391
- critique,
392
- use(["state"], (vars, critique_result) => {
393
- const prior = vars["state"];
394
- return {
395
- stop: accept(critique_result),
396
- state: {
397
- ...prior,
398
- last_critique: critique_result,
399
- critique_notes: critique_result.notes
400
- }
401
- };
402
- })
403
- ]),
405
+ body,
406
+ guard,
404
407
  finish: (s, { converged, rounds }) => {
405
408
  if (s.candidate === void 0) throw new Error("adversarial: finished without a candidate");
406
409
  return project({
@@ -410,7 +413,8 @@ function adversarial(config) {
410
413
  });
411
414
  },
412
415
  max_rounds
413
- }), {
416
+ });
417
+ return compose(inner, {
414
418
  name: config.name ?? "adversarial",
415
419
  description: config.description
416
420
  });
@@ -438,32 +442,35 @@ function consensus(config) {
438
442
  const { members, agree, max_rounds } = config;
439
443
  const project = config.project ?? ((r) => r);
440
444
  const round_step = parallel(members);
441
- return compose(loop({
445
+ const body = scope([
446
+ stash("state", step("snapshot", (s) => s)),
447
+ step("extract_input", (s) => s.input),
448
+ round_step,
449
+ use(["state"], (vars, results) => {
450
+ return {
451
+ ...vars["state"],
452
+ results
453
+ };
454
+ })
455
+ ]);
456
+ const guard = step("agree", (s) => ({
457
+ stop: agree(s.results),
458
+ state: s
459
+ }));
460
+ const inner = loop({
442
461
  init: (input) => ({
443
462
  input,
444
463
  results: {}
445
464
  }),
446
- body: scope([
447
- stash("state", step("snapshot", (s) => s)),
448
- step("extract_input", (s) => s.input),
449
- round_step,
450
- use(["state"], (vars, results) => {
451
- return {
452
- ...vars["state"],
453
- results
454
- };
455
- })
456
- ]),
457
- guard: step("agree", (s) => ({
458
- stop: agree(s.results),
459
- state: s
460
- })),
465
+ body,
466
+ guard,
461
467
  finish: (s, { converged }) => project({
462
468
  result: s.results,
463
469
  converged
464
470
  }),
465
471
  max_rounds
466
- }), {
472
+ });
473
+ return compose(inner, {
467
474
  name: config.name ?? "consensus",
468
475
  description: config.description
469
476
  });
@@ -492,7 +499,8 @@ function ensemble(config) {
492
499
  const score_fn = config.score;
493
500
  const keys = Object.keys(config.members);
494
501
  const project = config.project ?? ((r) => r);
495
- return compose(sequence([parallel(config.members), step("pick_winner", async (results) => {
502
+ const fan_out = parallel(config.members);
503
+ const pick = step("pick_winner", async (results) => {
496
504
  const scores = {};
497
505
  for (const k of keys) {
498
506
  const value = results[k];
@@ -521,7 +529,9 @@ function ensemble(config) {
521
529
  winner,
522
530
  scores
523
531
  });
524
- })]), {
532
+ });
533
+ const inner = sequence([fan_out, pick]);
534
+ return compose(inner, {
525
535
  name: config.name ?? "ensemble",
526
536
  description: config.description
527
537
  });
@@ -609,12 +619,13 @@ function ensemble_step(config) {
609
619
  scored
610
620
  });
611
621
  });
612
- return compose(scope([
622
+ const inner = scope([
613
623
  stash(RESULTS_KEY, fan_out),
614
624
  to_pairs,
615
625
  score_each,
616
626
  pick
617
- ]), {
627
+ ]);
628
+ return compose(inner, {
618
629
  name: config.name ?? "ensemble_step",
619
630
  description: config.description
620
631
  });
@@ -713,11 +724,12 @@ function gate(inner, config) {
713
724
  resume_schema: approval_schema,
714
725
  combine: () => restore
715
726
  });
716
- return compose(scope([
727
+ const body = scope([
717
728
  stash("result", persisted),
718
729
  step("project_payload", (result) => format === void 0 ? result : format(result)),
719
730
  approval
720
- ]), {
731
+ ]);
732
+ return compose(body, {
721
733
  name: config.name ?? "gate",
722
734
  description: config.description
723
735
  });
@@ -849,59 +861,64 @@ function improve(config) {
849
861
  lessons: next_lessons
850
862
  };
851
863
  });
852
- return compose(scope([
864
+ const body = scope([
865
+ stash(PRIOR_KEY, step("improve_snapshot", (s) => s)),
866
+ to_round_input,
867
+ round_ensemble,
868
+ project_round,
869
+ merge_outcome
870
+ ]);
871
+ const guard = step("improve_guard", (s) => {
872
+ if (s.rounds_since_progress >= patience) return {
873
+ stop: true,
874
+ state: {
875
+ ...s,
876
+ stopped_by: "plateau"
877
+ }
878
+ };
879
+ if (max_wallclock_ms !== void 0 && Date.now() - s.started_at_ms >= max_wallclock_ms) return {
880
+ stop: true,
881
+ state: {
882
+ ...s,
883
+ stopped_by: "budget"
884
+ }
885
+ };
886
+ return {
887
+ stop: false,
888
+ state: s
889
+ };
890
+ });
891
+ const round_loop = loop({
892
+ init: (s) => s,
893
+ body,
894
+ guard,
895
+ finish: (s) => ({
896
+ best: {
897
+ content: s.parent,
898
+ score: s.parent_score
899
+ },
900
+ rounds_used: s.round,
901
+ stopped_by: s.stopped_by ?? "budget",
902
+ history: s.history
903
+ }),
904
+ max_rounds
905
+ });
906
+ const record_stop = step("improve_stop", (result, ctx) => {
907
+ ctx.trajectory.record({
908
+ kind: "improve.stop",
909
+ stopped_by: result.stopped_by,
910
+ rounds_used: result.rounds_used,
911
+ final_score: result.best.score
912
+ });
913
+ return project(result);
914
+ });
915
+ const inner = scope([
853
916
  seed,
854
917
  init_state,
855
- loop({
856
- init: (s) => s,
857
- body: scope([
858
- stash(PRIOR_KEY, step("improve_snapshot", (s) => s)),
859
- to_round_input,
860
- round_ensemble,
861
- project_round,
862
- merge_outcome
863
- ]),
864
- guard: step("improve_guard", (s) => {
865
- if (s.rounds_since_progress >= patience) return {
866
- stop: true,
867
- state: {
868
- ...s,
869
- stopped_by: "plateau"
870
- }
871
- };
872
- if (max_wallclock_ms !== void 0 && Date.now() - s.started_at_ms >= max_wallclock_ms) return {
873
- stop: true,
874
- state: {
875
- ...s,
876
- stopped_by: "budget"
877
- }
878
- };
879
- return {
880
- stop: false,
881
- state: s
882
- };
883
- }),
884
- finish: (s) => ({
885
- best: {
886
- content: s.parent,
887
- score: s.parent_score
888
- },
889
- rounds_used: s.round,
890
- stopped_by: s.stopped_by ?? "budget",
891
- history: s.history
892
- }),
893
- max_rounds
894
- }),
895
- step("improve_stop", (result, ctx) => {
896
- ctx.trajectory.record({
897
- kind: "improve.stop",
898
- stopped_by: result.stopped_by,
899
- rounds_used: result.rounds_used,
900
- final_score: result.best.score
901
- });
902
- return project(result);
903
- })
904
- ]), {
918
+ round_loop,
919
+ record_stop
920
+ ]);
921
+ return compose(inner, {
905
922
  name: config.name ?? "improve",
906
923
  description: config.description
907
924
  });
@@ -1071,12 +1088,13 @@ function learn(config) {
1071
1088
  run_ids: meta.run_ids
1072
1089
  };
1073
1090
  });
1074
- return compose(scope([
1091
+ const inner = scope([
1075
1092
  stash(META_KEY, compute_meta),
1076
1093
  build_input,
1077
1094
  analyzer,
1078
1095
  wrap_result
1079
- ]), {
1096
+ ]);
1097
+ return compose(inner, {
1080
1098
  name: config.name ?? "learn",
1081
1099
  description: config.description
1082
1100
  });
@@ -1110,7 +1128,8 @@ function tournament(config) {
1110
1128
  const keys = Object.keys(config.members);
1111
1129
  const project = config.project ?? ((r) => r);
1112
1130
  if (keys.length === 0) throw new Error("tournament: at least one member required");
1113
- return compose(sequence([parallel(config.members), step("bracket", async (results) => {
1131
+ const fan_out = parallel(config.members);
1132
+ const bracket_step = step("bracket", async (results) => {
1114
1133
  let current = [...keys];
1115
1134
  const bracket = [];
1116
1135
  let round = 0;
@@ -1122,7 +1141,9 @@ function tournament(config) {
1122
1141
  winner: winner_of(current, results),
1123
1142
  bracket
1124
1143
  });
1125
- })]), {
1144
+ });
1145
+ const inner = sequence([fan_out, bracket_step]);
1146
+ return compose(inner, {
1126
1147
  name: config.name ?? "tournament",
1127
1148
  description: config.description
1128
1149
  });
@@ -1610,11 +1631,12 @@ function judge_llm(config) {
1610
1631
  };
1611
1632
  const build_prompt = step("judge_llm_build_prompt", (args) => render_prompt(config.rubric, scale, args));
1612
1633
  const parse = step("judge_llm_parse", (reply) => parse_score(reply, scale));
1613
- return compose(sequence([
1634
+ const inner = sequence([
1614
1635
  build_prompt,
1615
1636
  config.model,
1616
1637
  parse
1617
- ]), { name: "judge_llm" });
1638
+ ]);
1639
+ return compose(inner, { name: "judge_llm" });
1618
1640
  }
1619
1641
  /**
1620
1642
  * Renders the evaluator prompt: rubric, required JSON reply shape with the
@@ -2027,13 +2049,17 @@ function assign_if_present(target, key, value) {
2027
2049
  }
2028
2050
  /**
2029
2051
  * The step fields that say what a model_call is, apart from its config: it is
2030
- * anonymous when its id was generated, and it carries `meta.description` when
2031
- * `cfg` gives one.
2052
+ * anonymous when its id was generated, it carries `meta.description` when
2053
+ * `cfg` gives one, and it is always a `side_effect`, because every run of it
2054
+ * bills the provider again.
2032
2055
  */
2033
2056
  function identity_fields(cfg) {
2034
2057
  return {
2035
2058
  ...cfg.id === void 0 ? { anonymous: true } : {},
2036
- ...cfg.description === void 0 ? {} : { meta: { description: cfg.description } }
2059
+ meta: {
2060
+ ...cfg.description === void 0 ? {} : { description: cfg.description },
2061
+ side_effect: true
2062
+ }
2037
2063
  };
2038
2064
  }
2039
2065
  /**
@@ -2199,6 +2225,6 @@ function forward_standard_env() {
2199
2225
  return out;
2200
2226
  }
2201
2227
  //#endregion
2202
- export { STEP_KINDS, aborted_error, adversarial, assert_valid_step_id, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, claude_cli_reported, 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, throughput, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
2228
+ export { STEP_KINDS, aborted_error, adversarial, assert_valid_step_id, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, claude_cli_reported, compose, consensus, create_engine, default_normalize_usage, describe, describe_cycle_error, durable, engine_config_error, engine_disposed_error, ensemble, ensemble_step, error_path, fallback, flow_changed_error, 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_map_item_failed_event, is_run_end_event, is_span_end_event, is_span_start_event, is_step, is_step_kind, is_step_replayed_event, 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, run_not_found_error, schema_validation_error, scope, sequence, stash, step, suggest_step_id, suspend, suspended_error, throughput, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
2203
2229
 
2204
2230
  //# sourceMappingURL=index.js.map