@sweny-ai/core 0.1.162 → 0.1.163

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.
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ export { EVALUATOR_KINDS, EVAL_POLICIES, REQUIRES_ON_FAIL, NODE_ON_FAIL, MCP_TRA
27
27
  export { consoleLogger } from "./types.js";
28
28
  // Executor
29
29
  export { execute, RouteEvaluationError } from "./executor.js";
30
+ // Decision models, shadow mode (#357)
31
+ export { systemOneProvider, DecideError, gateVerdict, DECIDER_MIN_CONFIDENCE, DECIDER_MIN_MARGIN } from "./decider.js";
30
32
  // Least-privilege nodes and safe outputs (#365)
31
33
  export { BudgetGuard, describeOverrun, minLimits, toLimits } from "./budget.js";
32
34
  export { resolveNodePermissions, buildNodePolicy } from "./node-policy.js";
package/dist/schema.d.ts CHANGED
@@ -619,6 +619,7 @@ export declare const evaluatorZ: z.ZodEffects<z.ZodObject<{
619
619
  }, "strict", z.ZodTypeAny, {
620
620
  name: string;
621
621
  kind: "function" | "value" | "judge";
622
+ model?: string | undefined;
622
623
  rule?: {
623
624
  any_tool_called?: string[] | undefined;
624
625
  all_tools_called?: string[] | undefined;
@@ -633,10 +634,10 @@ export declare const evaluatorZ: z.ZodEffects<z.ZodObject<{
633
634
  } | undefined;
634
635
  rubric?: string | undefined;
635
636
  pass_when?: string | undefined;
636
- model?: string | undefined;
637
637
  }, {
638
638
  name: string;
639
639
  kind: "function" | "value" | "judge";
640
+ model?: string | undefined;
640
641
  rule?: {
641
642
  any_tool_called?: string[] | undefined;
642
643
  all_tools_called?: string[] | undefined;
@@ -651,10 +652,10 @@ export declare const evaluatorZ: z.ZodEffects<z.ZodObject<{
651
652
  } | undefined;
652
653
  rubric?: string | undefined;
653
654
  pass_when?: string | undefined;
654
- model?: string | undefined;
655
655
  }>, {
656
656
  name: string;
657
657
  kind: "function" | "value" | "judge";
658
+ model?: string | undefined;
658
659
  rule?: {
659
660
  any_tool_called?: string[] | undefined;
660
661
  all_tools_called?: string[] | undefined;
@@ -669,10 +670,10 @@ export declare const evaluatorZ: z.ZodEffects<z.ZodObject<{
669
670
  } | undefined;
670
671
  rubric?: string | undefined;
671
672
  pass_when?: string | undefined;
672
- model?: string | undefined;
673
673
  }, {
674
674
  name: string;
675
675
  kind: "function" | "value" | "judge";
676
+ model?: string | undefined;
676
677
  rule?: {
677
678
  any_tool_called?: string[] | undefined;
678
679
  all_tools_called?: string[] | undefined;
@@ -687,7 +688,6 @@ export declare const evaluatorZ: z.ZodEffects<z.ZodObject<{
687
688
  } | undefined;
688
689
  rubric?: string | undefined;
689
690
  pass_when?: string | undefined;
690
- model?: string | undefined;
691
691
  }>;
692
692
  export declare const nodeRequiresZ: z.ZodEffects<z.ZodObject<{
693
693
  output_required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -869,6 +869,55 @@ export declare const budgetZ: z.ZodEffects<z.ZodObject<{
869
869
  tokens?: number | undefined;
870
870
  cost_usd?: number | undefined;
871
871
  }>;
872
+ /**
873
+ * Decision model for route choices (#357). `shadow` needs a provider; the
874
+ * state only ever goes to that `base_url`, there is no fallback. The key is
875
+ * named by env var, never inlined.
876
+ */
877
+ export declare const deciderZ: z.ZodEffects<z.ZodObject<{
878
+ mode: z.ZodEnum<["off", "shadow"]>;
879
+ provider: z.ZodOptional<z.ZodObject<{
880
+ base_url: z.ZodString;
881
+ model: z.ZodString;
882
+ api_key_env: z.ZodOptional<z.ZodString>;
883
+ }, "strict", z.ZodTypeAny, {
884
+ model: string;
885
+ base_url: string;
886
+ api_key_env?: string | undefined;
887
+ }, {
888
+ model: string;
889
+ base_url: string;
890
+ api_key_env?: string | undefined;
891
+ }>>;
892
+ }, "strict", z.ZodTypeAny, {
893
+ mode: "off" | "shadow";
894
+ provider?: {
895
+ model: string;
896
+ base_url: string;
897
+ api_key_env?: string | undefined;
898
+ } | undefined;
899
+ }, {
900
+ mode: "off" | "shadow";
901
+ provider?: {
902
+ model: string;
903
+ base_url: string;
904
+ api_key_env?: string | undefined;
905
+ } | undefined;
906
+ }>, {
907
+ mode: "off" | "shadow";
908
+ provider?: {
909
+ model: string;
910
+ base_url: string;
911
+ api_key_env?: string | undefined;
912
+ } | undefined;
913
+ }, {
914
+ mode: "off" | "shadow";
915
+ provider?: {
916
+ model: string;
917
+ base_url: string;
918
+ api_key_env?: string | undefined;
919
+ } | undefined;
920
+ }>;
872
921
  /** One typed write intent a node may emit (#365). */
873
922
  export declare const safeOutputDeclarationZ: z.ZodObject<{
874
923
  type: z.ZodEnum<["comment", "issue", "pr", "label", "issue_state"]>;
@@ -1275,6 +1324,7 @@ export declare const nodeZ: z.ZodObject<{
1275
1324
  }, "strict", z.ZodTypeAny, {
1276
1325
  name: string;
1277
1326
  kind: "function" | "value" | "judge";
1327
+ model?: string | undefined;
1278
1328
  rule?: {
1279
1329
  any_tool_called?: string[] | undefined;
1280
1330
  all_tools_called?: string[] | undefined;
@@ -1289,10 +1339,10 @@ export declare const nodeZ: z.ZodObject<{
1289
1339
  } | undefined;
1290
1340
  rubric?: string | undefined;
1291
1341
  pass_when?: string | undefined;
1292
- model?: string | undefined;
1293
1342
  }, {
1294
1343
  name: string;
1295
1344
  kind: "function" | "value" | "judge";
1345
+ model?: string | undefined;
1296
1346
  rule?: {
1297
1347
  any_tool_called?: string[] | undefined;
1298
1348
  all_tools_called?: string[] | undefined;
@@ -1307,10 +1357,10 @@ export declare const nodeZ: z.ZodObject<{
1307
1357
  } | undefined;
1308
1358
  rubric?: string | undefined;
1309
1359
  pass_when?: string | undefined;
1310
- model?: string | undefined;
1311
1360
  }>, {
1312
1361
  name: string;
1313
1362
  kind: "function" | "value" | "judge";
1363
+ model?: string | undefined;
1314
1364
  rule?: {
1315
1365
  any_tool_called?: string[] | undefined;
1316
1366
  all_tools_called?: string[] | undefined;
@@ -1325,10 +1375,10 @@ export declare const nodeZ: z.ZodObject<{
1325
1375
  } | undefined;
1326
1376
  rubric?: string | undefined;
1327
1377
  pass_when?: string | undefined;
1328
- model?: string | undefined;
1329
1378
  }, {
1330
1379
  name: string;
1331
1380
  kind: "function" | "value" | "judge";
1381
+ model?: string | undefined;
1332
1382
  rule?: {
1333
1383
  any_tool_called?: string[] | undefined;
1334
1384
  all_tools_called?: string[] | undefined;
@@ -1343,7 +1393,6 @@ export declare const nodeZ: z.ZodObject<{
1343
1393
  } | undefined;
1344
1394
  rubric?: string | undefined;
1345
1395
  pass_when?: string | undefined;
1346
- model?: string | undefined;
1347
1396
  }>, "many">>;
1348
1397
  eval_policy: z.ZodOptional<z.ZodEnum<["all_pass", "any_pass", "weighted"]>>;
1349
1398
  judge_model: z.ZodOptional<z.ZodString>;
@@ -1455,12 +1504,12 @@ export declare const nodeZ: z.ZodObject<{
1455
1504
  type?: string | undefined;
1456
1505
  };
1457
1506
  skills: string[];
1507
+ model?: string | undefined;
1458
1508
  output?: Record<string, unknown> | undefined;
1459
1509
  tools?: {
1460
1510
  deny?: string[] | undefined;
1461
1511
  allow?: string[] | undefined;
1462
1512
  } | undefined;
1463
- model?: string | undefined;
1464
1513
  on_fail?: "halt" | "continue" | undefined;
1465
1514
  max_turns?: number | undefined;
1466
1515
  budget?: {
@@ -1526,6 +1575,7 @@ export declare const nodeZ: z.ZodObject<{
1526
1575
  eval?: {
1527
1576
  name: string;
1528
1577
  kind: "function" | "value" | "judge";
1578
+ model?: string | undefined;
1529
1579
  rule?: {
1530
1580
  any_tool_called?: string[] | undefined;
1531
1581
  all_tools_called?: string[] | undefined;
@@ -1540,7 +1590,6 @@ export declare const nodeZ: z.ZodObject<{
1540
1590
  } | undefined;
1541
1591
  rubric?: string | undefined;
1542
1592
  pass_when?: string | undefined;
1543
- model?: string | undefined;
1544
1593
  }[] | undefined;
1545
1594
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
1546
1595
  judge_model?: string | undefined;
@@ -1572,12 +1621,12 @@ export declare const nodeZ: z.ZodObject<{
1572
1621
  url: string;
1573
1622
  type?: string | undefined;
1574
1623
  };
1624
+ model?: string | undefined;
1575
1625
  output?: Record<string, unknown> | undefined;
1576
1626
  tools?: {
1577
1627
  deny?: string[] | undefined;
1578
1628
  allow?: string[] | undefined;
1579
1629
  } | undefined;
1580
- model?: string | undefined;
1581
1630
  on_fail?: "halt" | "continue" | undefined;
1582
1631
  skills?: string[] | undefined;
1583
1632
  max_turns?: number | undefined;
@@ -1644,6 +1693,7 @@ export declare const nodeZ: z.ZodObject<{
1644
1693
  eval?: {
1645
1694
  name: string;
1646
1695
  kind: "function" | "value" | "judge";
1696
+ model?: string | undefined;
1647
1697
  rule?: {
1648
1698
  any_tool_called?: string[] | undefined;
1649
1699
  all_tools_called?: string[] | undefined;
@@ -1658,7 +1708,6 @@ export declare const nodeZ: z.ZodObject<{
1658
1708
  } | undefined;
1659
1709
  rubric?: string | undefined;
1660
1710
  pass_when?: string | undefined;
1661
- model?: string | undefined;
1662
1711
  }[] | undefined;
1663
1712
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
1664
1713
  judge_model?: string | undefined;
@@ -2068,6 +2117,7 @@ export declare const workflowZ: z.ZodObject<{
2068
2117
  }, "strict", z.ZodTypeAny, {
2069
2118
  name: string;
2070
2119
  kind: "function" | "value" | "judge";
2120
+ model?: string | undefined;
2071
2121
  rule?: {
2072
2122
  any_tool_called?: string[] | undefined;
2073
2123
  all_tools_called?: string[] | undefined;
@@ -2082,10 +2132,10 @@ export declare const workflowZ: z.ZodObject<{
2082
2132
  } | undefined;
2083
2133
  rubric?: string | undefined;
2084
2134
  pass_when?: string | undefined;
2085
- model?: string | undefined;
2086
2135
  }, {
2087
2136
  name: string;
2088
2137
  kind: "function" | "value" | "judge";
2138
+ model?: string | undefined;
2089
2139
  rule?: {
2090
2140
  any_tool_called?: string[] | undefined;
2091
2141
  all_tools_called?: string[] | undefined;
@@ -2100,10 +2150,10 @@ export declare const workflowZ: z.ZodObject<{
2100
2150
  } | undefined;
2101
2151
  rubric?: string | undefined;
2102
2152
  pass_when?: string | undefined;
2103
- model?: string | undefined;
2104
2153
  }>, {
2105
2154
  name: string;
2106
2155
  kind: "function" | "value" | "judge";
2156
+ model?: string | undefined;
2107
2157
  rule?: {
2108
2158
  any_tool_called?: string[] | undefined;
2109
2159
  all_tools_called?: string[] | undefined;
@@ -2118,10 +2168,10 @@ export declare const workflowZ: z.ZodObject<{
2118
2168
  } | undefined;
2119
2169
  rubric?: string | undefined;
2120
2170
  pass_when?: string | undefined;
2121
- model?: string | undefined;
2122
2171
  }, {
2123
2172
  name: string;
2124
2173
  kind: "function" | "value" | "judge";
2174
+ model?: string | undefined;
2125
2175
  rule?: {
2126
2176
  any_tool_called?: string[] | undefined;
2127
2177
  all_tools_called?: string[] | undefined;
@@ -2136,7 +2186,6 @@ export declare const workflowZ: z.ZodObject<{
2136
2186
  } | undefined;
2137
2187
  rubric?: string | undefined;
2138
2188
  pass_when?: string | undefined;
2139
- model?: string | undefined;
2140
2189
  }>, "many">>;
2141
2190
  eval_policy: z.ZodOptional<z.ZodEnum<["all_pass", "any_pass", "weighted"]>>;
2142
2191
  judge_model: z.ZodOptional<z.ZodString>;
@@ -2248,12 +2297,12 @@ export declare const workflowZ: z.ZodObject<{
2248
2297
  type?: string | undefined;
2249
2298
  };
2250
2299
  skills: string[];
2300
+ model?: string | undefined;
2251
2301
  output?: Record<string, unknown> | undefined;
2252
2302
  tools?: {
2253
2303
  deny?: string[] | undefined;
2254
2304
  allow?: string[] | undefined;
2255
2305
  } | undefined;
2256
- model?: string | undefined;
2257
2306
  on_fail?: "halt" | "continue" | undefined;
2258
2307
  max_turns?: number | undefined;
2259
2308
  budget?: {
@@ -2319,6 +2368,7 @@ export declare const workflowZ: z.ZodObject<{
2319
2368
  eval?: {
2320
2369
  name: string;
2321
2370
  kind: "function" | "value" | "judge";
2371
+ model?: string | undefined;
2322
2372
  rule?: {
2323
2373
  any_tool_called?: string[] | undefined;
2324
2374
  all_tools_called?: string[] | undefined;
@@ -2333,7 +2383,6 @@ export declare const workflowZ: z.ZodObject<{
2333
2383
  } | undefined;
2334
2384
  rubric?: string | undefined;
2335
2385
  pass_when?: string | undefined;
2336
- model?: string | undefined;
2337
2386
  }[] | undefined;
2338
2387
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
2339
2388
  judge_model?: string | undefined;
@@ -2365,12 +2414,12 @@ export declare const workflowZ: z.ZodObject<{
2365
2414
  url: string;
2366
2415
  type?: string | undefined;
2367
2416
  };
2417
+ model?: string | undefined;
2368
2418
  output?: Record<string, unknown> | undefined;
2369
2419
  tools?: {
2370
2420
  deny?: string[] | undefined;
2371
2421
  allow?: string[] | undefined;
2372
2422
  } | undefined;
2373
- model?: string | undefined;
2374
2423
  on_fail?: "halt" | "continue" | undefined;
2375
2424
  skills?: string[] | undefined;
2376
2425
  max_turns?: number | undefined;
@@ -2437,6 +2486,7 @@ export declare const workflowZ: z.ZodObject<{
2437
2486
  eval?: {
2438
2487
  name: string;
2439
2488
  kind: "function" | "value" | "judge";
2489
+ model?: string | undefined;
2440
2490
  rule?: {
2441
2491
  any_tool_called?: string[] | undefined;
2442
2492
  all_tools_called?: string[] | undefined;
@@ -2451,7 +2501,6 @@ export declare const workflowZ: z.ZodObject<{
2451
2501
  } | undefined;
2452
2502
  rubric?: string | undefined;
2453
2503
  pass_when?: string | undefined;
2454
- model?: string | undefined;
2455
2504
  }[] | undefined;
2456
2505
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
2457
2506
  judge_model?: string | undefined;
@@ -2653,6 +2702,50 @@ export declare const workflowZ: z.ZodObject<{
2653
2702
  tokens?: number | undefined;
2654
2703
  cost_usd?: number | undefined;
2655
2704
  }>>;
2705
+ decider: z.ZodOptional<z.ZodEffects<z.ZodObject<{
2706
+ mode: z.ZodEnum<["off", "shadow"]>;
2707
+ provider: z.ZodOptional<z.ZodObject<{
2708
+ base_url: z.ZodString;
2709
+ model: z.ZodString;
2710
+ api_key_env: z.ZodOptional<z.ZodString>;
2711
+ }, "strict", z.ZodTypeAny, {
2712
+ model: string;
2713
+ base_url: string;
2714
+ api_key_env?: string | undefined;
2715
+ }, {
2716
+ model: string;
2717
+ base_url: string;
2718
+ api_key_env?: string | undefined;
2719
+ }>>;
2720
+ }, "strict", z.ZodTypeAny, {
2721
+ mode: "off" | "shadow";
2722
+ provider?: {
2723
+ model: string;
2724
+ base_url: string;
2725
+ api_key_env?: string | undefined;
2726
+ } | undefined;
2727
+ }, {
2728
+ mode: "off" | "shadow";
2729
+ provider?: {
2730
+ model: string;
2731
+ base_url: string;
2732
+ api_key_env?: string | undefined;
2733
+ } | undefined;
2734
+ }>, {
2735
+ mode: "off" | "shadow";
2736
+ provider?: {
2737
+ model: string;
2738
+ base_url: string;
2739
+ api_key_env?: string | undefined;
2740
+ } | undefined;
2741
+ }, {
2742
+ mode: "off" | "shadow";
2743
+ provider?: {
2744
+ model: string;
2745
+ base_url: string;
2746
+ api_key_env?: string | undefined;
2747
+ } | undefined;
2748
+ }>>;
2656
2749
  context_mode: z.ZodOptional<z.ZodEnum<["bounded", "full"]>>;
2657
2750
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
2658
2751
  type: z.ZodEnum<["string", "number", "boolean", "string[]"]>;
@@ -2756,12 +2849,12 @@ export declare const workflowZ: z.ZodObject<{
2756
2849
  type?: string | undefined;
2757
2850
  };
2758
2851
  skills: string[];
2852
+ model?: string | undefined;
2759
2853
  output?: Record<string, unknown> | undefined;
2760
2854
  tools?: {
2761
2855
  deny?: string[] | undefined;
2762
2856
  allow?: string[] | undefined;
2763
2857
  } | undefined;
2764
- model?: string | undefined;
2765
2858
  on_fail?: "halt" | "continue" | undefined;
2766
2859
  max_turns?: number | undefined;
2767
2860
  budget?: {
@@ -2827,6 +2920,7 @@ export declare const workflowZ: z.ZodObject<{
2827
2920
  eval?: {
2828
2921
  name: string;
2829
2922
  kind: "function" | "value" | "judge";
2923
+ model?: string | undefined;
2830
2924
  rule?: {
2831
2925
  any_tool_called?: string[] | undefined;
2832
2926
  all_tools_called?: string[] | undefined;
@@ -2841,7 +2935,6 @@ export declare const workflowZ: z.ZodObject<{
2841
2935
  } | undefined;
2842
2936
  rubric?: string | undefined;
2843
2937
  pass_when?: string | undefined;
2844
- model?: string | undefined;
2845
2938
  }[] | undefined;
2846
2939
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
2847
2940
  judge_model?: string | undefined;
@@ -2903,6 +2996,14 @@ export declare const workflowZ: z.ZodObject<{
2903
2996
  spec_version?: string | undefined;
2904
2997
  workflow_type?: "pr_review" | "e2e_test" | "content_generation" | "monitor" | "data_sync" | "generic" | undefined;
2905
2998
  judge_budget?: number | undefined;
2999
+ decider?: {
3000
+ mode: "off" | "shadow";
3001
+ provider?: {
3002
+ model: string;
3003
+ base_url: string;
3004
+ api_key_env?: string | undefined;
3005
+ } | undefined;
3006
+ } | undefined;
2906
3007
  context_mode?: "full" | "bounded" | undefined;
2907
3008
  inputs?: Record<string, {
2908
3009
  type: "string" | "number" | "boolean" | "string[]";
@@ -2932,12 +3033,12 @@ export declare const workflowZ: z.ZodObject<{
2932
3033
  url: string;
2933
3034
  type?: string | undefined;
2934
3035
  };
3036
+ model?: string | undefined;
2935
3037
  output?: Record<string, unknown> | undefined;
2936
3038
  tools?: {
2937
3039
  deny?: string[] | undefined;
2938
3040
  allow?: string[] | undefined;
2939
3041
  } | undefined;
2940
- model?: string | undefined;
2941
3042
  on_fail?: "halt" | "continue" | undefined;
2942
3043
  skills?: string[] | undefined;
2943
3044
  max_turns?: number | undefined;
@@ -3004,6 +3105,7 @@ export declare const workflowZ: z.ZodObject<{
3004
3105
  eval?: {
3005
3106
  name: string;
3006
3107
  kind: "function" | "value" | "judge";
3108
+ model?: string | undefined;
3007
3109
  rule?: {
3008
3110
  any_tool_called?: string[] | undefined;
3009
3111
  all_tools_called?: string[] | undefined;
@@ -3018,7 +3120,6 @@ export declare const workflowZ: z.ZodObject<{
3018
3120
  } | undefined;
3019
3121
  rubric?: string | undefined;
3020
3122
  pass_when?: string | undefined;
3021
- model?: string | undefined;
3022
3123
  }[] | undefined;
3023
3124
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
3024
3125
  judge_model?: string | undefined;
@@ -3094,6 +3195,14 @@ export declare const workflowZ: z.ZodObject<{
3094
3195
  spec_version?: string | undefined;
3095
3196
  workflow_type?: "pr_review" | "e2e_test" | "content_generation" | "monitor" | "data_sync" | "generic" | undefined;
3096
3197
  judge_budget?: number | undefined;
3198
+ decider?: {
3199
+ mode: "off" | "shadow";
3200
+ provider?: {
3201
+ model: string;
3202
+ base_url: string;
3203
+ api_key_env?: string | undefined;
3204
+ } | undefined;
3205
+ } | undefined;
3097
3206
  context_mode?: "full" | "bounded" | undefined;
3098
3207
  inputs?: Record<string, {
3099
3208
  type: "string" | "number" | "boolean" | "string[]";
@@ -3152,12 +3261,12 @@ export declare function parseWorkflow(raw: unknown): {
3152
3261
  type?: string | undefined;
3153
3262
  };
3154
3263
  skills: string[];
3264
+ model?: string | undefined;
3155
3265
  output?: Record<string, unknown> | undefined;
3156
3266
  tools?: {
3157
3267
  deny?: string[] | undefined;
3158
3268
  allow?: string[] | undefined;
3159
3269
  } | undefined;
3160
- model?: string | undefined;
3161
3270
  on_fail?: "halt" | "continue" | undefined;
3162
3271
  max_turns?: number | undefined;
3163
3272
  budget?: {
@@ -3223,6 +3332,7 @@ export declare function parseWorkflow(raw: unknown): {
3223
3332
  eval?: {
3224
3333
  name: string;
3225
3334
  kind: "function" | "value" | "judge";
3335
+ model?: string | undefined;
3226
3336
  rule?: {
3227
3337
  any_tool_called?: string[] | undefined;
3228
3338
  all_tools_called?: string[] | undefined;
@@ -3237,7 +3347,6 @@ export declare function parseWorkflow(raw: unknown): {
3237
3347
  } | undefined;
3238
3348
  rubric?: string | undefined;
3239
3349
  pass_when?: string | undefined;
3240
- model?: string | undefined;
3241
3350
  }[] | undefined;
3242
3351
  eval_policy?: "all_pass" | "any_pass" | "weighted" | undefined;
3243
3352
  judge_model?: string | undefined;
@@ -3299,6 +3408,14 @@ export declare function parseWorkflow(raw: unknown): {
3299
3408
  spec_version?: string | undefined;
3300
3409
  workflow_type?: "pr_review" | "e2e_test" | "content_generation" | "monitor" | "data_sync" | "generic" | undefined;
3301
3410
  judge_budget?: number | undefined;
3411
+ decider?: {
3412
+ mode: "off" | "shadow";
3413
+ provider?: {
3414
+ model: string;
3415
+ base_url: string;
3416
+ api_key_env?: string | undefined;
3417
+ } | undefined;
3418
+ } | undefined;
3302
3419
  context_mode?: "full" | "bounded" | undefined;
3303
3420
  inputs?: Record<string, {
3304
3421
  type: "string" | "number" | "boolean" | "string[]";
@@ -3595,6 +3712,49 @@ export declare const workflowJsonSchema: {
3595
3712
  };
3596
3713
  };
3597
3714
  };
3715
+ readonly Decider: {
3716
+ readonly type: "object";
3717
+ readonly required: readonly ["mode"];
3718
+ readonly additionalProperties: false;
3719
+ readonly description: "Decision model for route choices. 'shadow' asks it alongside the agent and logs whether they agree; the route is always the agent's. The workflow state goes only to provider.base_url, with no fallback.";
3720
+ readonly properties: {
3721
+ readonly mode: {
3722
+ readonly type: "string";
3723
+ readonly enum: readonly ["off", "shadow"];
3724
+ };
3725
+ readonly provider: {
3726
+ readonly type: "object";
3727
+ readonly required: readonly ["base_url", "model"];
3728
+ readonly additionalProperties: false;
3729
+ readonly properties: {
3730
+ readonly base_url: {
3731
+ readonly type: "string";
3732
+ readonly format: "uri";
3733
+ readonly description: "Server root serving POST /v1/systemone (Ollama or TypeSafe Jev).";
3734
+ };
3735
+ readonly model: {
3736
+ readonly type: "string";
3737
+ readonly minLength: 1;
3738
+ };
3739
+ readonly api_key_env: {
3740
+ readonly type: "string";
3741
+ readonly minLength: 1;
3742
+ readonly description: "Env var holding the bearer key.";
3743
+ };
3744
+ };
3745
+ };
3746
+ };
3747
+ readonly if: {
3748
+ readonly properties: {
3749
+ readonly mode: {
3750
+ readonly const: "shadow";
3751
+ };
3752
+ };
3753
+ };
3754
+ readonly then: {
3755
+ readonly required: readonly ["provider"];
3756
+ };
3757
+ };
3598
3758
  readonly SafeOutput: {
3599
3759
  readonly type: "object";
3600
3760
  readonly required: readonly ["type"];
@@ -3780,6 +3940,10 @@ export declare const workflowJsonSchema: {
3780
3940
  readonly $ref: "#/$defs/Budget";
3781
3941
  readonly description: "Spend ceiling for the whole run and for every node. A node's own budget may only narrow it. The CLI's --max-tokens and --max-cost tighten it further.";
3782
3942
  };
3943
+ readonly decider: {
3944
+ readonly $ref: "#/$defs/Decider";
3945
+ readonly description: "Decision model for route choices (shadow mode only). Default: off.";
3946
+ };
3783
3947
  readonly context_mode: {
3784
3948
  readonly type: "string";
3785
3949
  readonly enum: readonly ["bounded", "full"];
package/dist/schema.js CHANGED
@@ -278,6 +278,27 @@ export const budgetZ = z
278
278
  .refine((b) => b.tokens !== undefined || b.cost_usd !== undefined, {
279
279
  message: "budget must declare at least one of tokens, cost_usd",
280
280
  });
281
+ /**
282
+ * Decision model for route choices (#357). `shadow` needs a provider; the
283
+ * state only ever goes to that `base_url`, there is no fallback. The key is
284
+ * named by env var, never inlined.
285
+ */
286
+ export const deciderZ = z
287
+ .object({
288
+ mode: z.enum(["off", "shadow"]),
289
+ provider: z
290
+ .object({
291
+ base_url: z.string().url(),
292
+ model: z.string().min(1),
293
+ api_key_env: z.string().min(1).optional(),
294
+ })
295
+ .strict()
296
+ .optional(),
297
+ })
298
+ .strict()
299
+ .refine((d) => d.mode === "off" || d.provider !== undefined, {
300
+ message: "decider.provider is required when mode is shadow",
301
+ });
281
302
  /** One typed write intent a node may emit (#365). */
282
303
  export const safeOutputDeclarationZ = z
283
304
  .object({
@@ -377,6 +398,7 @@ export const workflowZ = z.object({
377
398
  model: z.string().min(1).optional(),
378
399
  judge_budget: z.number().int().min(0).optional(),
379
400
  budget: budgetZ.optional(),
401
+ decider: deciderZ.optional(),
380
402
  context_mode: z.enum(CONTEXT_MODES).optional(),
381
403
  inputs: workflowInputsZ.optional(),
382
404
  permissions: nodePermissionsZ.optional(),
@@ -961,6 +983,31 @@ export const workflowJsonSchema = {
961
983
  cost_usd: { type: "number", exclusiveMinimum: 0, description: "Max reported cost in USD." },
962
984
  },
963
985
  },
986
+ Decider: {
987
+ type: "object",
988
+ required: ["mode"],
989
+ additionalProperties: false,
990
+ description: "Decision model for route choices. 'shadow' asks it alongside the agent and logs whether they agree; the route is always the agent's. The workflow state goes only to provider.base_url, with no fallback.",
991
+ properties: {
992
+ mode: { type: "string", enum: ["off", "shadow"] },
993
+ provider: {
994
+ type: "object",
995
+ required: ["base_url", "model"],
996
+ additionalProperties: false,
997
+ properties: {
998
+ base_url: {
999
+ type: "string",
1000
+ format: "uri",
1001
+ description: "Server root serving POST /v1/systemone (Ollama or TypeSafe Jev).",
1002
+ },
1003
+ model: { type: "string", minLength: 1 },
1004
+ api_key_env: { type: "string", minLength: 1, description: "Env var holding the bearer key." },
1005
+ },
1006
+ },
1007
+ },
1008
+ if: { properties: { mode: { const: "shadow" } } },
1009
+ then: { required: ["provider"] },
1010
+ },
964
1011
  SafeOutput: {
965
1012
  type: "object",
966
1013
  required: ["type"],
@@ -1110,6 +1157,10 @@ export const workflowJsonSchema = {
1110
1157
  $ref: "#/$defs/Budget",
1111
1158
  description: "Spend ceiling for the whole run and for every node. A node's own budget may only narrow it. The CLI's --max-tokens and --max-cost tighten it further.",
1112
1159
  },
1160
+ decider: {
1161
+ $ref: "#/$defs/Decider",
1162
+ description: "Decision model for route choices (shadow mode only). Default: off.",
1163
+ },
1113
1164
  context_mode: {
1114
1165
  type: "string",
1115
1166
  enum: [...CONTEXT_MODES],
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ export { WORKFLOW_INPUT_TYPES } from "./inputs.js";
4
4
  import type { Source as _Source, ResolvedSource as _ResolvedSource } from "./sources.js";
5
5
  import type { ToolClass } from "./harness/types.js";
6
6
  import type { Budget, BudgetOverrun } from "./budget.js";
7
+ import type { DeciderConfig, DeciderRecord } from "./decider.js";
7
8
  export type JSONSchema = Record<string, unknown>;
8
9
  /** Context passed to tool handlers at execution time */
9
10
  export interface ToolContext {
@@ -551,6 +552,11 @@ export interface Workflow {
551
552
  * `budget` may only narrow it. The CLI's `--max-tokens` / `--max-cost` tighten it.
552
553
  */
553
554
  budget?: Budget;
555
+ /**
556
+ * Decision model for route choices (#357). `shadow` asks it alongside the
557
+ * agent and logs agreement; the route is always the agent's. Default: off.
558
+ */
559
+ decider?: DeciderConfig;
554
560
  /**
555
561
  * What prior results a node's prompt receives (#337). `bounded` (default):
556
562
  * only nodes it can depend on (graph ancestors, nodes named by `requires`
@@ -765,6 +771,8 @@ export interface ExecutionTrace {
765
771
  edges: TraceEdge[];
766
772
  /** Resolved sources keyed by field path (e.g. "nodes.gather.instruction") */
767
773
  sources: Record<string, _ResolvedSource>;
774
+ /** Shadow-mode decider records, one per route decision (#357). Metadata only. Absent when the decider is off. */
775
+ decisions?: DeciderRecord[];
768
776
  }
769
777
  /** Result of execute() — final node results + full execution trace */
770
778
  export interface ExecutionResult {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweny-ai/core",
3
- "version": "0.1.162",
3
+ "version": "0.1.163",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sweny": "./dist/cli/main.js"