fascicle 0.15.0 → 0.16.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 (65) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +8 -8
  3. package/dist/acp.d.ts +9 -2
  4. package/dist/acp.js +1538 -1472
  5. package/dist/acp.js.map +1 -1
  6. package/dist/{adapters-DNnzeLxr.js → adapters-CDUzZlby.js} +35 -13
  7. package/dist/adapters-CDUzZlby.js.map +1 -0
  8. package/dist/adapters.d.ts +8 -1
  9. package/dist/adapters.js +1 -1
  10. package/dist/agents.d.ts +1 -1
  11. package/dist/agents.js +15 -8
  12. package/dist/agents.js.map +1 -1
  13. package/dist/bin/fascicle-viewer.js +4 -1
  14. package/dist/console-CdB4pcFO.js +37 -0
  15. package/dist/console-CdB4pcFO.js.map +1 -0
  16. package/dist/{core-CDrz0NM1.js → core-CErsxGF6.js} +246 -147
  17. package/dist/core-CErsxGF6.js.map +1 -0
  18. package/dist/diagram_bin.js +2 -2
  19. package/dist/diagram_bin.js.map +1 -1
  20. package/dist/{engine-ha9xmgwE.js → engine-CR8q2IqV.js} +173 -67
  21. package/dist/engine-CR8q2IqV.js.map +1 -0
  22. package/dist/index.d.ts +529 -73
  23. package/dist/index.js +440 -137
  24. package/dist/index.js.map +1 -1
  25. package/dist/{invoke-px31fffH.js → invoke-COaeZ-vy.js} +6 -5
  26. package/dist/invoke-COaeZ-vy.js.map +1 -0
  27. package/dist/{json_schema_to_standard-BTWD0J6p.js → json_schema_to_standard-C4F4lXHE.js} +9 -12
  28. package/dist/json_schema_to_standard-C4F4lXHE.js.map +1 -0
  29. package/dist/{leading_system-DfJLqpGi.js → leading_system-PoHzNHuV.js} +28 -8
  30. package/dist/leading_system-PoHzNHuV.js.map +1 -0
  31. package/dist/mcp.d.ts +3 -2
  32. package/dist/mcp.js +8 -4
  33. package/dist/mcp.js.map +1 -1
  34. package/dist/otel.js +10 -10
  35. package/dist/otel.js.map +1 -1
  36. package/dist/{search-CA_OqFeW.js → search-CpCJYMUm.js} +53 -6
  37. package/dist/search-CpCJYMUm.js.map +1 -0
  38. package/dist/search_worker.js +1 -1
  39. package/dist/stdio.js +7 -3
  40. package/dist/stdio.js.map +1 -1
  41. package/dist/testing.d.ts +1 -1
  42. package/dist/testing.js +3 -3
  43. package/dist/testing.js.map +1 -1
  44. package/dist/{trajectory-Bm-mOtqw.d.ts → trajectory-BKGNxi7u.d.ts} +10 -9
  45. package/dist/{trajectory-BI-mrVFT.js → trajectory-DeURWIhj.js} +6 -5
  46. package/dist/trajectory-DeURWIhj.js.map +1 -0
  47. package/dist/{types-De-TVQxS.d.ts → types-Sw0oHW-_.d.ts} +6 -7
  48. package/dist/ui.d.ts +2 -1
  49. package/dist/ui.js +8 -1
  50. package/dist/ui.js.map +1 -1
  51. package/dist/viewer-app/assets/index-BYF5Dp7d.js +2 -0
  52. package/dist/viewer-app/index.html +2 -1
  53. package/dist/viewer.d.ts +26 -12
  54. package/dist/viewer.js +282 -63
  55. package/dist/viewer.js.map +1 -1
  56. package/package.json +5 -5
  57. package/dist/adapters-DNnzeLxr.js.map +0 -1
  58. package/dist/core-CDrz0NM1.js.map +0 -1
  59. package/dist/engine-ha9xmgwE.js.map +0 -1
  60. package/dist/invoke-px31fffH.js.map +0 -1
  61. package/dist/json_schema_to_standard-BTWD0J6p.js.map +0 -1
  62. package/dist/leading_system-DfJLqpGi.js.map +0 -1
  63. package/dist/search-CA_OqFeW.js.map +0 -1
  64. package/dist/trajectory-BI-mrVFT.js.map +0 -1
  65. package/dist/viewer-app/assets/index-Fnh5HKSU.js +0 -2
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as FlowValue, c as Step, d as StepMetadata, f as StepOptions, h as TrajectoryLogger, i as FlowNode, l as StepFn, m as TrajectoryEvent, n as CheckpointStore, o as RunContext, p as StepOutput, r as CleanupFn, s as ScopedCheckpointStore, t as AnyStep, u as StepInput } from "./types-CPqLZOEr.js";
2
2
  import { n as SchemaIssue, r as ToolSchema, t as AnySchema } from "./types-BK0UW28o.js";
3
- import { _ as is_run_end_event, a as MapItemFailedEvent, b as is_step_replayed_event, c as RunEndStatus, d as StepReplayedEvent, f as TrajectoryParseResult, g as is_map_item_failed_event, h as is_emit_event, i as EmitEvent, l as SpanEndEvent, m as is_custom_trajectory_event, n as CheckpointStatus, o as ParsedTrajectoryEvent, p as is_checkpoint_event, r as CustomTrajectoryEvent, s as RunEndEvent, t as CheckpointEvent, u as SpanStartEvent, v as is_span_end_event, x as parse_trajectory_event, y as is_span_start_event } from "./trajectory-Bm-mOtqw.js";
4
- import { A as ToolCallRecord, B as ProviderAdapter, C as RetryPolicy, D as Tool, E as StreamChunk, F as UserContentPart, G as default_normalize_usage, H as ProviderFactory, I as AiSdkProviderAdapter, K as ClaudeCliProviderReported, L as EffortTranslation, M as TurnRequest, N as TurnResult, O as ToolApprovalHandler, P as UsageTotals, R as ExternalAgentAdapter, S as RetryFailureKind, T as StepTiming, U as ProviderTransport, V as ProviderCapability, W as RawProviderUsage, _ as PricingTable, a as Engine, b as ProviderOptions, c as FinishReason, d as GenerateTiming, f as Message, g as Pricing, h as PrepareStepResult, i as EffortLevel, j as ToolExecContext, k as ToolApprovalRequest, l as GenerateOptions, m as PrepareStepHook, n as AssistantContentPart, o as EngineConfig, p as PrepareStepContext, r as CostBreakdown, s as EngineDefaults, t as AiSdkTelemetrySettings, u as GenerateResult, v as ProviderConfigMap, w as StepRecord, x as ResolvedModel, y as ProviderInit, z as NativeProviderAdapter } from "./types-De-TVQxS.js";
3
+ import { _ as is_run_end_event, a as MapItemFailedEvent, b as is_step_replayed_event, c as RunEndStatus, d as StepReplayedEvent, f as TrajectoryParseResult, g as is_map_item_failed_event, h as is_emit_event, i as EmitEvent, l as SpanEndEvent, m as is_custom_trajectory_event, n as CheckpointStatus, o as ParsedTrajectoryEvent, p as is_checkpoint_event, r as CustomTrajectoryEvent, s as RunEndEvent, t as CheckpointEvent, u as SpanStartEvent, v as is_span_end_event, x as parse_trajectory_event, y as is_span_start_event } from "./trajectory-BKGNxi7u.js";
4
+ import { A as ToolApprovalHandler, B as ExternalAgentAdapter, C as ResolvedModel, D as StepTiming, E as StepRecord, F as TurnResult, G as ProviderTransport, H as ProviderAdapter, I as UsageTotals, J as ClaudeCliProviderReported, K as RawProviderUsage, L as UserContentPart, M as ToolCallRecord, N as ToolExecContext, O as StreamChunk, P as TurnRequest, R as AiSdkProviderAdapter, S as ProviderOptions, T as RetryPolicy, U as ProviderCapability, V as NativeProviderAdapter, W as ProviderFactory, _ as PrepareStepResult, a as CostBreakdown, b as ProviderConfigMap, c as EngineConfig, d as GenerateOptions, f as GenerateResult, g as PrepareStepHook, h as PrepareStepContext, i as BedrockCredentials, j as ToolApprovalRequest, k as Tool, l as EngineDefaults, m as Message, n as AssistantContentPart, o as EffortLevel, p as GenerateTiming, q as default_normalize_usage, r as BedrockCredentialProvider, s as Engine, t as AiSdkTelemetrySettings, u as FinishReason, v as Pricing, w as RetryFailureKind, x as ProviderInit, y as PricingTable, z as EffortTranslation } from "./types-Sw0oHW-_.js";
5
5
  //#region src/core/runner.d.ts
6
6
  type RunOptions = {
7
7
  readonly install_signal_handlers?: boolean;
@@ -552,6 +552,14 @@ type CheckpointConfig<i> = {
552
552
  readonly name?: string;
553
553
  readonly description?: string;
554
554
  readonly key: string | ((input: i) => string);
555
+ /**
556
+ * What a failed `store.set` does. `'record'` (the default) records a
557
+ * `write_error` event and returns the inner result. `'fail'` records the
558
+ * same event and then throws the store's error, which is what a step whose
559
+ * result a `suspend` hands to an approver wants, so the approval never
560
+ * refers to a result that the store didn't keep.
561
+ */
562
+ readonly on_write_error?: 'record' | 'fail';
555
563
  };
556
564
  /**
557
565
  * Wrap `inner` with persist-and-resume behavior keyed by `config.key`.
@@ -580,7 +588,8 @@ type SuspendConfig<i, o, resume> = {
580
588
  * First run fires the `on` side effect and throws `suspended_error`; a resume
581
589
  * run validates `resume_data[id]` against `resume_schema` and feeds it to
582
590
  * `combine`. The step's id is the user-supplied suspend id so resume data can
583
- * be addressed to it.
591
+ * be addressed to it, which is why it's held to the step id rule and throws
592
+ * a `TypeError` when it's built if it isn't an identifier.
584
593
  */
585
594
  export declare function suspend<i, o, resume>(config: SuspendConfig<i, o, resume>): Step<i, o>;
586
595
  //#endregion
@@ -753,14 +762,14 @@ export declare function is_step(value: unknown): value is AnyStep;
753
762
  /**
754
763
  * Closed registry of every `Step.kind` produced by the composition layer.
755
764
  *
756
- * Studio (and any other consumer that needs to enumerate primitives: palette,
757
- * docs, code generation) can rely on this being the exhaustive set. New
765
+ * The viewer (and any other consumer that needs to enumerate primitives:
766
+ * palette, docs, code generation) can rely on this being the exhaustive set. New
758
767
  * primitives must add their kind here. `step_kinds.test.ts` pins the list
759
- * against the kinds core actually constructs, and
760
- * `composites/__tests__/coverage.test.ts` covers the four composite kinds
761
- * whose factories live outside core.
768
+ * against the kinds core actually constructs, in both directions. The
769
+ * composites (`ensemble`, `tournament`, and the rest) add no kinds of their
770
+ * own: each builds a `compose` step that carries its name as the display name.
762
771
  */
763
- export declare const STEP_KINDS: readonly ['step', 'sequence', 'parallel', 'branch', 'map', 'pipe', 'retry', 'fallback', 'timeout', 'loop', 'compose', 'adversarial', 'ensemble', 'tournament', 'consensus', 'checkpoint', 'suspend', 'scope', 'stash', 'use', 'chain'];
772
+ export declare const STEP_KINDS: readonly ['step', 'sequence', 'parallel', 'branch', 'map', 'pipe', 'retry', 'fallback', 'timeout', 'loop', 'compose', 'checkpoint', 'suspend', 'scope', 'stash', 'use', 'chain'];
764
773
  type StepKind = (typeof STEP_KINDS)[number];
765
774
  /**
766
775
  * Check whether a value is one of the registered `Step.kind` strings.
@@ -848,6 +857,18 @@ export declare const flow_schema: {
848
857
  consensus: {
849
858
  $ref: string;
850
859
  };
860
+ ensemble_step: {
861
+ $ref: string;
862
+ };
863
+ gate: {
864
+ $ref: string;
865
+ };
866
+ improve: {
867
+ $ref: string;
868
+ };
869
+ learn: {
870
+ $ref: string;
871
+ };
851
872
  checkpoint: {
852
873
  $ref: string;
853
874
  };
@@ -875,8 +896,44 @@ export declare const flow_schema: {
875
896
  fn: {
876
897
  type: string;
877
898
  };
899
+ name: {
900
+ type: string;
901
+ };
902
+ description: {
903
+ type: string;
904
+ };
905
+ side_effect: {
906
+ type: string;
907
+ };
908
+ port_labels: {
909
+ type: string;
910
+ properties: {
911
+ in: {
912
+ type: string;
913
+ };
914
+ out: {
915
+ type: string;
916
+ };
917
+ };
918
+ };
919
+ arm: {
920
+ $ref: string;
921
+ };
878
922
  };
879
923
  };
924
+ arms: {
925
+ anyOf: ({
926
+ $ref: string;
927
+ type?: never;
928
+ items?: never;
929
+ } | {
930
+ $ref?: never;
931
+ type: string;
932
+ items: {
933
+ $ref: string;
934
+ };
935
+ })[];
936
+ };
880
937
  sequence_config: {
881
938
  type: string;
882
939
  items: {
@@ -893,6 +950,12 @@ export declare const flow_schema: {
893
950
  type: string;
894
951
  required: string[];
895
952
  properties: {
953
+ name: {
954
+ type: string;
955
+ };
956
+ description: {
957
+ type: string;
958
+ };
896
959
  when: {
897
960
  type: string;
898
961
  };
@@ -908,6 +971,12 @@ export declare const flow_schema: {
908
971
  type: string;
909
972
  required: string[];
910
973
  properties: {
974
+ name: {
975
+ type: string;
976
+ };
977
+ description: {
978
+ type: string;
979
+ };
911
980
  items: {
912
981
  type: string;
913
982
  };
@@ -927,6 +996,12 @@ export declare const flow_schema: {
927
996
  type: string;
928
997
  required: string[];
929
998
  properties: {
999
+ name: {
1000
+ type: string;
1001
+ };
1002
+ description: {
1003
+ type: string;
1004
+ };
930
1005
  of: {
931
1006
  $ref: string;
932
1007
  };
@@ -939,6 +1014,12 @@ export declare const flow_schema: {
939
1014
  type: string;
940
1015
  required: string[];
941
1016
  properties: {
1017
+ name: {
1018
+ type: string;
1019
+ };
1020
+ description: {
1021
+ type: string;
1022
+ };
942
1023
  do: {
943
1024
  $ref: string;
944
1025
  };
@@ -950,24 +1031,61 @@ export declare const flow_schema: {
950
1031
  type: string;
951
1032
  minimum: number;
952
1033
  };
1034
+ max_delay_ms: {
1035
+ type: string;
1036
+ minimum: number;
1037
+ };
1038
+ jitter: {
1039
+ type: string;
1040
+ };
1041
+ when: {
1042
+ type: string;
1043
+ };
1044
+ on_error: {
1045
+ type: string;
1046
+ };
1047
+ project: {
1048
+ type: string;
1049
+ };
953
1050
  };
954
1051
  };
955
1052
  fallback_config: {
956
1053
  type: string;
957
1054
  required: string[];
958
1055
  properties: {
1056
+ name: {
1057
+ type: string;
1058
+ };
1059
+ description: {
1060
+ type: string;
1061
+ };
959
1062
  primary: {
960
1063
  $ref: string;
961
1064
  };
962
1065
  backup: {
963
1066
  $ref: string;
964
1067
  };
1068
+ when: {
1069
+ type: string;
1070
+ };
1071
+ handoff: {
1072
+ type: string;
1073
+ };
1074
+ project: {
1075
+ type: string;
1076
+ };
965
1077
  };
966
1078
  };
967
1079
  timeout_config: {
968
1080
  type: string;
969
1081
  required: string[];
970
1082
  properties: {
1083
+ name: {
1084
+ type: string;
1085
+ };
1086
+ description: {
1087
+ type: string;
1088
+ };
971
1089
  do: {
972
1090
  $ref: string;
973
1091
  };
@@ -985,6 +1103,9 @@ export declare const flow_schema: {
985
1103
  type: string;
986
1104
  minLength: number;
987
1105
  };
1106
+ description: {
1107
+ type: string;
1108
+ };
988
1109
  do: {
989
1110
  $ref: string;
990
1111
  };
@@ -998,6 +1119,9 @@ export declare const flow_schema: {
998
1119
  type: string;
999
1120
  minLength: number;
1000
1121
  };
1122
+ description: {
1123
+ type: string;
1124
+ };
1001
1125
  init: {
1002
1126
  type: string;
1003
1127
  };
@@ -1005,7 +1129,13 @@ export declare const flow_schema: {
1005
1129
  $ref: string;
1006
1130
  };
1007
1131
  guard: {
1008
- $ref: string;
1132
+ anyOf: ({
1133
+ type?: never;
1134
+ $ref: string;
1135
+ } | {
1136
+ $ref?: never;
1137
+ type: string;
1138
+ })[];
1009
1139
  };
1010
1140
  finish: {
1011
1141
  type: string;
@@ -1020,6 +1150,12 @@ export declare const flow_schema: {
1020
1150
  type: string;
1021
1151
  required: string[];
1022
1152
  properties: {
1153
+ name: {
1154
+ type: string;
1155
+ };
1156
+ description: {
1157
+ type: string;
1158
+ };
1023
1159
  build: {
1024
1160
  $ref: string;
1025
1161
  };
@@ -1033,12 +1169,21 @@ export declare const flow_schema: {
1033
1169
  type: string;
1034
1170
  minimum: number;
1035
1171
  };
1172
+ project: {
1173
+ type: string;
1174
+ };
1036
1175
  };
1037
1176
  };
1038
1177
  ensemble_config: {
1039
1178
  type: string;
1040
1179
  required: string[];
1041
1180
  properties: {
1181
+ name: {
1182
+ type: string;
1183
+ };
1184
+ description: {
1185
+ type: string;
1186
+ };
1042
1187
  members: {
1043
1188
  type: string;
1044
1189
  additionalProperties: {
@@ -1052,12 +1197,21 @@ export declare const flow_schema: {
1052
1197
  type: string;
1053
1198
  enum: string[];
1054
1199
  };
1200
+ project: {
1201
+ type: string;
1202
+ };
1055
1203
  };
1056
1204
  };
1057
1205
  tournament_config: {
1058
1206
  type: string;
1059
1207
  required: string[];
1060
1208
  properties: {
1209
+ name: {
1210
+ type: string;
1211
+ };
1212
+ description: {
1213
+ type: string;
1214
+ };
1061
1215
  members: {
1062
1216
  type: string;
1063
1217
  additionalProperties: {
@@ -1067,12 +1221,21 @@ export declare const flow_schema: {
1067
1221
  compare: {
1068
1222
  type: string;
1069
1223
  };
1224
+ project: {
1225
+ type: string;
1226
+ };
1070
1227
  };
1071
1228
  };
1072
1229
  consensus_config: {
1073
1230
  type: string;
1074
1231
  required: string[];
1075
1232
  properties: {
1233
+ name: {
1234
+ type: string;
1235
+ };
1236
+ description: {
1237
+ type: string;
1238
+ };
1076
1239
  members: {
1077
1240
  type: string;
1078
1241
  additionalProperties: {
@@ -1086,18 +1249,227 @@ export declare const flow_schema: {
1086
1249
  type: string;
1087
1250
  minimum: number;
1088
1251
  };
1252
+ project: {
1253
+ type: string;
1254
+ };
1255
+ };
1256
+ };
1257
+ ensemble_step_config: {
1258
+ type: string;
1259
+ required: string[];
1260
+ properties: {
1261
+ name: {
1262
+ type: string;
1263
+ };
1264
+ description: {
1265
+ type: string;
1266
+ };
1267
+ members: {
1268
+ type: string;
1269
+ additionalProperties: {
1270
+ $ref: string;
1271
+ };
1272
+ };
1273
+ score: {
1274
+ $ref: string;
1275
+ };
1276
+ rank_by: {
1277
+ type: string;
1278
+ };
1279
+ select: {
1280
+ type: string;
1281
+ enum: string[];
1282
+ };
1283
+ project: {
1284
+ type: string;
1285
+ };
1286
+ };
1287
+ };
1288
+ gate_config: {
1289
+ type: string;
1290
+ required: string[];
1291
+ properties: {
1292
+ id: {
1293
+ type: string;
1294
+ };
1295
+ name: {
1296
+ type: string;
1297
+ };
1298
+ description: {
1299
+ type: string;
1300
+ };
1301
+ do: {
1302
+ $ref: string;
1303
+ };
1304
+ store: {
1305
+ type: string;
1306
+ };
1307
+ format: {
1308
+ type: string;
1309
+ };
1310
+ };
1311
+ };
1312
+ improve_config: {
1313
+ type: string;
1314
+ required: string[];
1315
+ properties: {
1316
+ name: {
1317
+ type: string;
1318
+ };
1319
+ description: {
1320
+ type: string;
1321
+ };
1322
+ seed: {
1323
+ $ref: string;
1324
+ };
1325
+ propose: {
1326
+ $ref: string;
1327
+ };
1328
+ score: {
1329
+ $ref: string;
1330
+ };
1331
+ budget: {
1332
+ $ref: string;
1333
+ };
1334
+ epsilon: {
1335
+ type: string;
1336
+ };
1337
+ proposers_per_round: {
1338
+ type: string;
1339
+ minimum: number;
1340
+ };
1341
+ lessons_capacity: {
1342
+ type: string;
1343
+ minimum: number;
1344
+ };
1345
+ project: {
1346
+ type: string;
1347
+ };
1348
+ };
1349
+ };
1350
+ improve_budget: {
1351
+ type: string;
1352
+ required: string[];
1353
+ properties: {
1354
+ max_rounds: {
1355
+ type: string;
1356
+ minimum: number;
1357
+ };
1358
+ max_wallclock_ms: {
1359
+ type: string;
1360
+ minimum: number;
1361
+ };
1362
+ patience: {
1363
+ type: string;
1364
+ minimum: number;
1365
+ };
1366
+ };
1367
+ };
1368
+ learn_config: {
1369
+ type: string;
1370
+ required: string[];
1371
+ properties: {
1372
+ name: {
1373
+ type: string;
1374
+ };
1375
+ description: {
1376
+ type: string;
1377
+ };
1378
+ flow: {
1379
+ $ref: string;
1380
+ };
1381
+ source: {
1382
+ $ref: string;
1383
+ };
1384
+ analyzer: {
1385
+ $ref: string;
1386
+ };
1387
+ filter: {
1388
+ type: string;
1389
+ };
1390
+ max_events: {
1391
+ type: string;
1392
+ minimum: number;
1393
+ };
1394
+ };
1395
+ };
1396
+ learn_source: {
1397
+ type: string;
1398
+ oneOf: {
1399
+ $ref: string;
1400
+ }[];
1401
+ };
1402
+ learn_events_source: {
1403
+ type: string;
1404
+ required: string[];
1405
+ properties: {
1406
+ kind: {
1407
+ type: string;
1408
+ enum: string[];
1409
+ };
1410
+ events: {
1411
+ type: string;
1412
+ items: {
1413
+ type: string;
1414
+ required: string[];
1415
+ properties: {
1416
+ kind: {
1417
+ type: string;
1418
+ };
1419
+ };
1420
+ };
1421
+ };
1422
+ };
1423
+ };
1424
+ learn_paths_source: {
1425
+ type: string;
1426
+ required: string[];
1427
+ properties: {
1428
+ kind: {
1429
+ type: string;
1430
+ enum: string[];
1431
+ };
1432
+ paths: {
1433
+ type: string;
1434
+ items: {
1435
+ type: string;
1436
+ };
1437
+ };
1438
+ };
1439
+ };
1440
+ learn_dir_source: {
1441
+ type: string;
1442
+ required: string[];
1443
+ properties: {
1444
+ kind: {
1445
+ type: string;
1446
+ enum: string[];
1447
+ };
1448
+ dir: {
1449
+ type: string;
1450
+ };
1089
1451
  };
1090
1452
  };
1091
1453
  checkpoint_config: {
1092
1454
  type: string;
1093
1455
  required: string[];
1094
1456
  properties: {
1457
+ name: {
1458
+ type: string;
1459
+ };
1460
+ description: {
1461
+ type: string;
1462
+ };
1095
1463
  do: {
1096
1464
  $ref: string;
1097
1465
  };
1098
1466
  key: {
1099
1467
  type: string;
1100
1468
  };
1469
+ on_write_error: {
1470
+ type: string;
1471
+ enum: string[];
1472
+ };
1101
1473
  };
1102
1474
  };
1103
1475
  suspend_config: {
@@ -1107,6 +1479,12 @@ export declare const flow_schema: {
1107
1479
  id: {
1108
1480
  type: string;
1109
1481
  };
1482
+ name: {
1483
+ type: string;
1484
+ };
1485
+ description: {
1486
+ type: string;
1487
+ };
1110
1488
  on: {
1111
1489
  type: string;
1112
1490
  };
@@ -1129,34 +1507,48 @@ export declare const flow_schema: {
1129
1507
  };
1130
1508
  scope_entry: {
1131
1509
  type: string;
1132
- oneOf: ({
1133
- type: string;
1134
- required: string[];
1135
- properties: {
1136
- stash: {
1137
- type: string;
1138
- };
1139
- do: {
1140
- $ref: string;
1141
- };
1142
- use?: never;
1510
+ oneOf: {
1511
+ $ref: string;
1512
+ }[];
1513
+ };
1514
+ stash_entry: {
1515
+ type: string;
1516
+ required: string[];
1517
+ properties: {
1518
+ name: {
1519
+ type: string;
1143
1520
  };
1144
- } | {
1145
- type: string;
1146
- required: string[];
1147
- properties: {
1148
- stash?: never;
1149
- use: {
1521
+ description: {
1522
+ type: string;
1523
+ };
1524
+ stash: {
1525
+ type: string;
1526
+ };
1527
+ do: {
1528
+ $ref: string;
1529
+ };
1530
+ };
1531
+ };
1532
+ use_entry: {
1533
+ type: string;
1534
+ required: string[];
1535
+ properties: {
1536
+ name: {
1537
+ type: string;
1538
+ };
1539
+ description: {
1540
+ type: string;
1541
+ };
1542
+ use: {
1543
+ type: string;
1544
+ items: {
1150
1545
  type: string;
1151
- items: {
1152
- type: string;
1153
- };
1154
- };
1155
- do: {
1156
- $ref: string;
1157
1546
  };
1158
1547
  };
1159
- })[];
1548
+ fn: {
1549
+ type: string;
1550
+ };
1551
+ };
1160
1552
  };
1161
1553
  chain_config: {
1162
1554
  type: string;
@@ -1178,33 +1570,63 @@ export declare const flow_schema: {
1178
1570
  };
1179
1571
  chain_entry: {
1180
1572
  type: string;
1181
- oneOf: ({
1182
- type: string;
1183
- required: string[];
1184
- properties: {
1185
- step: {
1186
- type: string;
1187
- };
1188
- fn: {
1189
- type: string;
1190
- };
1191
- stage?: never;
1192
- project?: never;
1573
+ oneOf: {
1574
+ $ref: string;
1575
+ }[];
1576
+ };
1577
+ chain_step_entry: {
1578
+ type: string;
1579
+ required: string[];
1580
+ properties: {
1581
+ name: {
1582
+ type: string;
1193
1583
  };
1194
- } | {
1195
- type: string;
1196
- required: string[];
1197
- properties: {
1198
- step?: never;
1199
- fn?: never;
1200
- stage: {
1201
- type: string;
1202
- };
1203
- project: {
1204
- type: string;
1205
- };
1584
+ description: {
1585
+ type: string;
1206
1586
  };
1207
- })[];
1587
+ step: {
1588
+ type: string;
1589
+ };
1590
+ fn: {
1591
+ type: string;
1592
+ };
1593
+ arm: {
1594
+ $ref: string;
1595
+ };
1596
+ };
1597
+ };
1598
+ chain_arm_entry: {
1599
+ type: string;
1600
+ required: string[];
1601
+ properties: {
1602
+ name: {
1603
+ type: string;
1604
+ };
1605
+ description: {
1606
+ type: string;
1607
+ };
1608
+ step: {
1609
+ type: string;
1610
+ };
1611
+ arm: {
1612
+ $ref: string;
1613
+ };
1614
+ select: {
1615
+ type: string;
1616
+ };
1617
+ };
1618
+ };
1619
+ chain_stage_entry: {
1620
+ type: string;
1621
+ required: string[];
1622
+ properties: {
1623
+ stage: {
1624
+ type: string;
1625
+ };
1626
+ project: {
1627
+ type: string;
1628
+ };
1629
+ };
1208
1630
  };
1209
1631
  };
1210
1632
  };
@@ -1219,6 +1641,18 @@ export declare const flow_schema: {
1219
1641
  */
1220
1642
  export declare function create_engine(config: EngineConfig): Engine;
1221
1643
  //#endregion
1644
+ //#region src/engine/define_tool.d.ts
1645
+ /**
1646
+ * Define a tool whose `execute` and `needs_approval` receive the input type
1647
+ * `input_schema` validates to, and return it as a plain `Tool` that any
1648
+ * `tools` list accepts. The widening is the one cast, and it is sound because
1649
+ * the tool loop validates every call's input against `input_schema` and
1650
+ * passes `execute` and `needs_approval` the validated value, never the raw
1651
+ * one; a call that fails validation goes back to the model as a tool error
1652
+ * and never reaches the tool. The spec comes back as the same object.
1653
+ */
1654
+ export declare function define_tool<i, o>(spec: Tool<i, o>): Tool;
1655
+ //#endregion
1222
1656
  //#region src/engine/throughput.d.ts
1223
1657
  type Throughput = {
1224
1658
  /** Output tokens per second over the measured window. Not rounded. */
@@ -1287,6 +1721,23 @@ export declare class provider_error extends Error {
1287
1721
  cause_kind?: 'provider_5xx' | 'network' | 'unknown';
1288
1722
  });
1289
1723
  }
1724
+ /**
1725
+ * Turn-timeout expiry. Thrown by the engine-owned retry_turn wrapper when a
1726
+ * single invoke_turn exceeds `turn_timeout_ms` before any chunk streamed.
1727
+ * Its `kind` is the RetryFailureKind wire value `'timeout'` (not the class
1728
+ * name) on purpose: that is the discriminant classify_retryable /
1729
+ * classify_provider_error already key on, so the shared classifier treats an
1730
+ * expiry as retryable without any timeout-specific branch. A mid-stream
1731
+ * expiry never reaches here; retry_turn converts it to a non-retryable
1732
+ * stream interruption first.
1733
+ */
1734
+ export declare class turn_timeout_error extends Error {
1735
+ readonly kind: 'timeout';
1736
+ readonly path?: ReadonlyArray<string>;
1737
+ readonly timeout_ms: number;
1738
+ readonly step_index: number | undefined;
1739
+ constructor(timeout_ms: number, step_index?: number);
1740
+ }
1290
1741
  export declare class schema_validation_error extends Error {
1291
1742
  readonly kind: 'schema_validation_error';
1292
1743
  readonly path?: ReadonlyArray<string>;
@@ -1371,7 +1822,7 @@ export declare class engine_disposed_error extends Error {
1371
1822
  readonly path?: ReadonlyArray<string>;
1372
1823
  constructor(message?: string);
1373
1824
  }
1374
- type ClaudeCliErrorReason = 'binary_not_found' | 'auth_missing' | 'auth_expired' | 'api_key_missing' | 'startup_timeout' | 'stall_timeout' | 'no_result_event' | 'result_error' | 'subprocess_exit' | 'sandbox_unavailable' | 'engine_disposed' | 'parse_error';
1825
+ type ClaudeCliErrorReason = 'binary_not_found' | 'startup_timeout' | 'stall_timeout' | 'no_result_event' | 'result_error' | 'subprocess_exit' | 'sandbox_unavailable';
1375
1826
  export declare class claude_cli_error extends Error {
1376
1827
  readonly kind: 'claude_cli_error';
1377
1828
  readonly path?: ReadonlyArray<string>;
@@ -1499,7 +1950,9 @@ type EnsembleResult<o> = {
1499
1950
  *
1500
1951
  * `select` picks the highest (`'max'`, the default) or lowest (`'min'`)
1501
1952
  * score. Tie-breaking is "any tied result is acceptable": the first member
1502
- * (in `members` key order) holding the best score wins. `project` maps the
1953
+ * (in `members` key order) holding the best score wins. A member that
1954
+ * returns `undefined` is scored like any other, and a NaN score stays in the
1955
+ * score map but never wins, so a field whose every score is NaN throws. `project` maps the
1503
1956
  * `{ winner, scores }` envelope into the step's output (for example, `(r) =>
1504
1957
  * r.winner`); omitted, the envelope itself is the output.
1505
1958
  *
@@ -1533,7 +1986,9 @@ type EnsembleStepResult<o, ranked> = {
1533
1986
  * example, a separate model call, a sub-flow, anything that wants its own
1534
1987
  * trajectory span and abort routing). The `score` step is dispatched once per
1535
1988
  * member result; `rank_by` projects a number out of the structured scored output;
1536
- * `select` picks the highest (`'max'`, default) or lowest (`'min'`) rank.
1989
+ * `select` picks the highest (`'max'`, default) or lowest (`'min'`) rank. A
1990
+ * member that returns `undefined` is scored like any other, and a NaN rank
1991
+ * never wins, so a field whose every rank is NaN throws.
1537
1992
  *
1538
1993
  * The result carries `winner_scored`, the structured output from the round's
1539
1994
  * scoring run preserved verbatim, so callers never pay to re-score the
@@ -1564,7 +2019,9 @@ type GateConfig<o> = {
1564
2019
  * unchanged; the decision itself is discarded. On a re-run against the same
1565
2020
  * store, the checkpoint absorbs the replay so `inner` never re-executes.
1566
2021
  * Throws at construction time when `inner` is anonymous, because the cached
1567
- * result must map back to a stable step.
2022
+ * result must map back to a stable step, and when `config.id` isn't an
2023
+ * identifier, which it checks under its own name before its `suspend` sees
2024
+ * the id.
1568
2025
  *
1569
2026
  * Implemented as a `compose`d `scope`: the checkpointed result is stashed,
1570
2027
  * projected into the approver's view, and handed to `suspend`; the suspend's
@@ -1644,7 +2101,7 @@ type ImproveResult<c> = {
1644
2101
  * itself is the output.
1645
2102
  *
1646
2103
  * Implemented as a `compose`d `scope` of (seed) -> (init state) -> (loop) ->
1647
- * (unwrap). The loop body is itself a small `scope` that snapshots prior
2104
+ * (record stop). The loop body is itself a small `scope` that snapshots prior
1648
2105
  * state, builds a round input, dispatches the proposers + scorer via
1649
2106
  * `ensemble_step`, and merges the outcome back into state via `use`.
1650
2107
  * State threading is the entire job.
@@ -1730,9 +2187,9 @@ export declare function tournament<i, o, projected = TournamentResult<o>>(config
1730
2187
  /**
1731
2188
  * Typed errors for the composites layer.
1732
2189
  *
1733
- * Listed alongside src/core/errors.ts, src/engine/errors.ts, and
1734
- * src/mcp/errors.ts in the `no-class` rule ignores: `instanceof` branching is
1735
- * how a caller tells a benched flow's usage error apart from a case failure.
2190
+ * Listed with the other modules' `errors.ts` files in the `no-class` rule
2191
+ * ignores: `instanceof` branching is how a caller tells a benched flow's usage
2192
+ * error apart from a case failure.
1736
2193
  */
1737
2194
  export declare class bench_suspend_error extends Error {
1738
2195
  readonly kind: 'bench_suspend_error';
@@ -1758,7 +2215,7 @@ type JudgeArgs<I, O> = {
1758
2215
  readonly meta?: Readonly<Record<string, unknown>>;
1759
2216
  };
1760
2217
  type Judge<I, O, S = Score> = Step<JudgeArgs<I, O>, S | undefined>;
1761
- type CaseResult<I = unknown, O = unknown, S = Score> = {
2218
+ type CaseResult<O = unknown, S = Score> = {
1762
2219
  readonly case_id: string;
1763
2220
  readonly ok: boolean;
1764
2221
  readonly output?: O;
@@ -1767,7 +2224,6 @@ type CaseResult<I = unknown, O = unknown, S = Score> = {
1767
2224
  readonly duration_ms: number;
1768
2225
  readonly cost_usd: number;
1769
2226
  readonly trajectory_path?: string;
1770
- readonly _input?: I;
1771
2227
  };
1772
2228
  type BenchSummary = {
1773
2229
  readonly pass_rate: number;
@@ -1776,10 +2232,10 @@ type BenchSummary = {
1776
2232
  readonly total_cost_usd: number;
1777
2233
  readonly mean_cost_usd: number;
1778
2234
  };
1779
- type BenchReport<I = unknown, O = unknown, S = Score> = {
2235
+ type BenchReport<O = unknown, S = Score> = {
1780
2236
  readonly flow_name: string;
1781
2237
  readonly run_id: string;
1782
- readonly cases: ReadonlyArray<CaseResult<I, O, S>>;
2238
+ readonly cases: ReadonlyArray<CaseResult<O, S>>;
1783
2239
  readonly summary: BenchSummary;
1784
2240
  };
1785
2241
  type BenchOptions = {
@@ -1817,7 +2273,7 @@ type BenchOptions = {
1817
2273
  * `suspended_error` from an approval gate rejects with `bench_suspend_error`:
1818
2274
  * `bench` has no resume path, so a suspend is a usage error, not a zero score.
1819
2275
  */
1820
- export declare function bench<I, O, S = Score>(flow: Step<I, O>, cases: ReadonlyArray<BenchCase<I>>, judges: Record<string, Judge<I, O, S>>, options?: BenchOptions): Promise<BenchReport<I, O, S>>;
2276
+ export declare function bench<I, O, S = Score>(flow: Step<I, O>, cases: ReadonlyArray<BenchCase<I>>, judges: Record<string, Judge<I, O, S>>, options?: BenchOptions): Promise<BenchReport<O, S>>;
1821
2277
  /**
1822
2278
  * Coerces a raw judge return value into a `Score`.
1823
2279
  *
@@ -2015,5 +2471,5 @@ export declare function model_step<T = string>(cfg: Omit<ModelCallConfig<T>, 'pr
2015
2471
  */
2016
2472
  export declare function forward_standard_env(): Record<string, string>;
2017
2473
  //#endregion
2018
- export { type AdversarialBuildInput, type AdversarialConfig, type AdversarialCritiqueResult, type AdversarialResult, type AiSdkProviderAdapter, type AiSdkTelemetrySettings, type AnySchema, type AnyStep, type AssistantContentPart, type BenchCase, type BenchOptions, type BenchReport, type BenchSummary, type BracketRecord, type BranchConfig, type Candidate, type CaseResult, type Chain, type ChainOpen, type ChainStepOptions, type CheckpointConfig, type CheckpointEvent, type CheckpointStatus, type CheckpointStore, type ClaudeCliErrorReason, type ClaudeCliProviderReported, type CleanupFn, type ComposeConfig, type ConsensusConfig, type ConsensusResult, type CostBreakdown, type CustomTrajectoryEvent, type DescribeOptions, type DiagramOptions, type DurableConfig, type DurableOutcome, type DurableRunOptions, type DurableRunState, type DurableRuns, type DurableStore, type EffortLevel, type EffortTranslation, type EmitEvent, type Engine, type EngineConfig, type EngineDefaults, type EnsembleConfig, type EnsembleResult, type EnsembleStepConfig, type EnsembleStepResult, type ExternalAgentAdapter, type FallbackOptions, type FallbackOutcome, type FallbackProjection, type FinishReason, type FlowNode, type FlowValue, type GateConfig, type GenerateOptions, type GenerateResult, type GenerateTiming, type HistoryEntry, type ImproveBudget, type ImproveConfig, type ImproveResult, type ImproveRoundInput, type Improvement, type Judge, type JudgeArgs, type JudgeLlmConfig, type JudgeWithFn, type LearnConfig, type LearnInput, type LearnResult, type Lesson, type LoopConfig, type LoopGuardPredicate, type LoopGuardResult, type LoopOutcome, type MapConfig, type MapItemFailedEvent, type MapSettleConfig, type Message, type ModelCallConfig, type ModelCallInput, type NativeProviderAdapter, type ParallelOptions, type ParsedTrajectoryEvent, type PerCaseDelta, type PipeOptions, type PrepareStepContext, type PrepareStepHook, type PrepareStepResult, type Pricing, type PricingTable, type ProviderAdapter, type ProviderCapability, type ProviderConfigMap, type ProviderFactory, type ProviderInit, type ProviderOptions, type ProviderTransport, type RawProviderUsage, type RegressionCompareOptions, type RegressionDelta, type RegressionReport, type ReplayHint, type ResolvedModel, type RetryConfig, type RetryFailureKind, type RetryOutcome, type RetryPolicy, type RetryProjection, type RunContext, type RunEndEvent, type RunEndStatus, type RunOptions, type RunOutcome, type SchemaIssue, type ScopeOptions, type ScopedCheckpointStore, type Score, type ScoredCandidate, type SequenceOptions, type Settled, type SettledError, type SpanEndEvent, type SpanStartEvent, type StashOptions, type Step, type StepFn, type StepInput, type StepKind, type StepMetadata, type StepOptions, type StepOutput, type StepRecord, type StepReplayedEvent, type StepTiming, type StreamChunk, type StreamingRunHandle, type SuspendConfig, type Throughput, type TimeoutOptions, type Tool, type ToolApprovalHandler, type ToolApprovalRequest, type ToolCallRecord, type ToolExecContext, type ToolSchema, type TournamentConfig, type TournamentResult, type TrajectoryEvent, type TrajectoryLogger, type TrajectoryParseResult, type TrajectorySource, type TurnRequest, type TurnResult, type UsageTotals, type UseOptions, type UserContentPart, default_normalize_usage, 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_replayed_event, parse_trajectory_event };
2474
+ export { type AdversarialBuildInput, type AdversarialConfig, type AdversarialCritiqueResult, type AdversarialResult, type AiSdkProviderAdapter, type AiSdkTelemetrySettings, type AnySchema, type AnyStep, type AssistantContentPart, type BedrockCredentialProvider, type BedrockCredentials, type BenchCase, type BenchOptions, type BenchReport, type BenchSummary, type BracketRecord, type BranchConfig, type Candidate, type CaseResult, type Chain, type ChainOpen, type ChainStepOptions, type CheckpointConfig, type CheckpointEvent, type CheckpointStatus, type CheckpointStore, type ClaudeCliErrorReason, type ClaudeCliProviderReported, type CleanupFn, type ComposeConfig, type ConsensusConfig, type ConsensusResult, type CostBreakdown, type CustomTrajectoryEvent, type DescribeOptions, type DiagramOptions, type DurableConfig, type DurableOutcome, type DurableRunOptions, type DurableRunState, type DurableRuns, type DurableStore, type EffortLevel, type EffortTranslation, type EmitEvent, type Engine, type EngineConfig, type EngineDefaults, type EnsembleConfig, type EnsembleResult, type EnsembleStepConfig, type EnsembleStepResult, type ExternalAgentAdapter, type FallbackOptions, type FallbackOutcome, type FallbackProjection, type FinishReason, type FlowNode, type FlowValue, type GateConfig, type GenerateOptions, type GenerateResult, type GenerateTiming, type HistoryEntry, type ImproveBudget, type ImproveConfig, type ImproveResult, type ImproveRoundInput, type Improvement, type Judge, type JudgeArgs, type JudgeLlmConfig, type JudgeWithFn, type LearnConfig, type LearnInput, type LearnResult, type Lesson, type LoopConfig, type LoopGuardPredicate, type LoopGuardResult, type LoopOutcome, type MapConfig, type MapItemFailedEvent, type MapSettleConfig, type Message, type ModelCallConfig, type ModelCallInput, type NativeProviderAdapter, type ParallelOptions, type ParsedTrajectoryEvent, type PerCaseDelta, type PipeOptions, type PrepareStepContext, type PrepareStepHook, type PrepareStepResult, type Pricing, type PricingTable, type ProviderAdapter, type ProviderCapability, type ProviderConfigMap, type ProviderFactory, type ProviderInit, type ProviderOptions, type ProviderTransport, type RawProviderUsage, type RegressionCompareOptions, type RegressionDelta, type RegressionReport, type ReplayHint, type ResolvedModel, type RetryConfig, type RetryFailureKind, type RetryOutcome, type RetryPolicy, type RetryProjection, type RunContext, type RunEndEvent, type RunEndStatus, type RunOptions, type RunOutcome, type SchemaIssue, type ScopeOptions, type ScopedCheckpointStore, type Score, type ScoredCandidate, type SequenceOptions, type Settled, type SettledError, type SpanEndEvent, type SpanStartEvent, type StashOptions, type Step, type StepFn, type StepInput, type StepKind, type StepMetadata, type StepOptions, type StepOutput, type StepRecord, type StepReplayedEvent, type StepTiming, type StreamChunk, type StreamingRunHandle, type SuspendConfig, type Throughput, type TimeoutOptions, type Tool, type ToolApprovalHandler, type ToolApprovalRequest, type ToolCallRecord, type ToolExecContext, type ToolSchema, type TournamentConfig, type TournamentResult, type TrajectoryEvent, type TrajectoryLogger, type TrajectoryParseResult, type TrajectorySource, type TurnRequest, type TurnResult, type UsageTotals, type UseOptions, type UserContentPart, default_normalize_usage, 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_replayed_event, parse_trajectory_event };
2019
2475
  //# sourceMappingURL=index.d.ts.map