@exaudeus/workrail 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/application/services/output-normalizer.d.ts +9 -0
  2. package/dist/application/services/output-normalizer.js +38 -0
  3. package/dist/manifest.json +150 -30
  4. package/dist/mcp/handler-factory.d.ts +7 -0
  5. package/dist/mcp/handler-factory.js +70 -0
  6. package/dist/mcp/handlers/v2-execution.js +329 -65
  7. package/dist/mcp/output-schemas.d.ts +242 -18
  8. package/dist/mcp/output-schemas.js +83 -7
  9. package/dist/mcp/server.js +21 -127
  10. package/dist/mcp/tool-descriptions.js +126 -18
  11. package/dist/mcp/types/workflow-tool-edition.d.ts +28 -0
  12. package/dist/mcp/types/workflow-tool-edition.js +10 -0
  13. package/dist/mcp/v1/tool-registry.d.ts +8 -0
  14. package/dist/mcp/v1/tool-registry.js +49 -0
  15. package/dist/mcp/v2/tool-registry.d.ts +2 -5
  16. package/dist/mcp/v2/tool-registry.js +33 -32
  17. package/dist/mcp/v2/tools.js +6 -6
  18. package/dist/mcp/workflow-tool-edition-selector.d.ts +4 -0
  19. package/dist/mcp/workflow-tool-edition-selector.js +13 -0
  20. package/dist/v2/durable-core/constants.d.ts +1 -0
  21. package/dist/v2/durable-core/constants.js +2 -1
  22. package/dist/v2/durable-core/domain/ack-advance-append-plan.d.ts +14 -7
  23. package/dist/v2/durable-core/domain/ack-advance-append-plan.js +78 -23
  24. package/dist/v2/durable-core/domain/blocking-decision.d.ts +32 -0
  25. package/dist/v2/durable-core/domain/blocking-decision.js +41 -0
  26. package/dist/v2/durable-core/domain/context-merge.d.ts +8 -0
  27. package/dist/v2/durable-core/domain/context-merge.js +40 -0
  28. package/dist/v2/durable-core/domain/function-definition-expander.d.ts +14 -0
  29. package/dist/v2/durable-core/domain/function-definition-expander.js +66 -0
  30. package/dist/v2/durable-core/domain/gap-builder.d.ts +19 -0
  31. package/dist/v2/durable-core/domain/gap-builder.js +24 -0
  32. package/dist/v2/durable-core/domain/prompt-renderer.d.ts +24 -0
  33. package/dist/v2/durable-core/domain/prompt-renderer.js +167 -0
  34. package/dist/v2/durable-core/domain/reason-model.d.ts +94 -0
  35. package/dist/v2/durable-core/domain/reason-model.js +228 -0
  36. package/dist/v2/durable-core/domain/recap-recovery.d.ts +24 -0
  37. package/dist/v2/durable-core/domain/recap-recovery.js +71 -0
  38. package/dist/v2/durable-core/domain/validation-criteria-validator.d.ts +8 -0
  39. package/dist/v2/durable-core/domain/validation-criteria-validator.js +16 -0
  40. package/dist/v2/durable-core/domain/validation-requirements-extractor.d.ts +2 -0
  41. package/dist/v2/durable-core/domain/validation-requirements-extractor.js +58 -0
  42. package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +206 -0
  43. package/dist/v2/durable-core/schemas/session/events.d.ts +58 -0
  44. package/dist/v2/durable-core/schemas/session/events.js +9 -0
  45. package/dist/v2/projections/run-context.d.ts +22 -0
  46. package/dist/v2/projections/run-context.js +33 -0
  47. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ export type NormalizedAgentOutput = string & {
2
+ readonly __brand: 'NormalizedAgentOutput';
3
+ };
4
+ export declare class OutputNormalizer {
5
+ normalize(raw: string): NormalizedAgentOutput;
6
+ private stripBackticks;
7
+ private stripCodeFences;
8
+ private normalizeWhitespace;
9
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OutputNormalizer = void 0;
10
+ const tsyringe_1 = require("tsyringe");
11
+ let OutputNormalizer = class OutputNormalizer {
12
+ normalize(raw) {
13
+ const step1 = this.stripCodeFences(raw);
14
+ const step2 = this.stripBackticks(step1);
15
+ const step3 = this.normalizeWhitespace(step2);
16
+ return step3;
17
+ }
18
+ stripBackticks(text) {
19
+ return text.replace(/`([^`]*)`/g, '$1');
20
+ }
21
+ stripCodeFences(text) {
22
+ let result = text.replace(/```[^\n]*\n([\s\S]*?)\n```/g, '$1');
23
+ result = result.replace(/```([^\n`]+)```/g, '$1');
24
+ return result;
25
+ }
26
+ normalizeWhitespace(text) {
27
+ return text
28
+ .replace(/\r\n/g, '\n')
29
+ .replace(/\r/g, '\n')
30
+ .replace(/[ \t]+/g, ' ')
31
+ .replace(/\n{3,}/g, '\n\n')
32
+ .trim();
33
+ }
34
+ };
35
+ exports.OutputNormalizer = OutputNormalizer;
36
+ exports.OutputNormalizer = OutputNormalizer = __decorate([
37
+ (0, tsyringe_1.singleton)()
38
+ ], OutputNormalizer);
@@ -17,6 +17,14 @@
17
17
  "sha256": "0af041281661c46cee1c63eebe36ee20d12b9fefc1f95e6baed9d959ae012b6a",
18
18
  "bytes": 7980
19
19
  },
20
+ "application/services/output-normalizer.d.ts": {
21
+ "sha256": "35bd9e50e984132f83dac874f90c2a4e9e8223202c6832426654232c5d7e2236",
22
+ "bytes": 280
23
+ },
24
+ "application/services/output-normalizer.js": {
25
+ "sha256": "0706997dcc1f7937a879b0bd3ac60f64f7edecb38dc5af88dfc439693d0cb8c7",
26
+ "bytes": 1632
27
+ },
20
28
  "application/services/step-output-decoder.d.ts": {
21
29
  "sha256": "fc6b8b60976844b7b30c874c3679f6bb6fe1ca5303e8ee411376e13e982d48c3",
22
30
  "bytes": 300
@@ -513,6 +521,14 @@
513
521
  "sha256": "1437bf9380090920512565c0d685a268af29d8b7e747eff62904e1090e69c854",
514
522
  "bytes": 3735
515
523
  },
524
+ "mcp/handler-factory.d.ts": {
525
+ "sha256": "fad8fff32776b2fe7182708ce0e821c2434fdfce7191390bb9cfaf16a7d31a60",
526
+ "bytes": 796
527
+ },
528
+ "mcp/handler-factory.js": {
529
+ "sha256": "cfdb8853f1e1a9529899852e4e25b027779647f1f94d3db931f4439052a0b607",
530
+ "bytes": 2875
531
+ },
516
532
  "mcp/handlers/session.d.ts": {
517
533
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
518
534
  "bytes": 1394
@@ -534,8 +550,8 @@
534
550
  "bytes": 399
535
551
  },
536
552
  "mcp/handlers/v2-execution.js": {
537
- "sha256": "7986a364a35276b4cc8c11e253c88e3bc0bfd86821747562d49829e843343c32",
538
- "bytes": 55235
553
+ "sha256": "56666820ef1211bf36efa258ea93e797de8c88431f01bf59e22c299172253006",
554
+ "bytes": 69447
539
555
  },
540
556
  "mcp/handlers/v2-workflow.d.ts": {
541
557
  "sha256": "9fbd4d44854e2060c54982b21e72c608970bb2bd107bb15a8388b26c6b492e55",
@@ -562,20 +578,20 @@
562
578
  "bytes": 7535
563
579
  },
564
580
  "mcp/output-schemas.d.ts": {
565
- "sha256": "974e6c2b71403f95363963508bb6cddabf6a6beafc54f19bde40a0c071aa34a3",
566
- "bytes": 25545
581
+ "sha256": "8361d3ad621448397ade687b9d5228eda487e76d7786b3c661a485805faf169c",
582
+ "bytes": 36039
567
583
  },
568
584
  "mcp/output-schemas.js": {
569
- "sha256": "9307eb4c2c4b54bcc8d604c81e6328a0149ea1936c81cece5c80505875de3f69",
570
- "bytes": 6947
585
+ "sha256": "9205bc8beb92795a03c25f2e655f6b7888fa091df45e04f286e5b4edc4f09b24",
586
+ "bytes": 9657
571
587
  },
572
588
  "mcp/server.d.ts": {
573
589
  "sha256": "bec49b8d07e189a53db7100d2f0e1e84ffe03150f04e1b06908ee3282982b4a2",
574
590
  "bytes": 168
575
591
  },
576
592
  "mcp/server.js": {
577
- "sha256": "e80a4709f72acfd96a277bad98b59bfa112e209e92b679531753e1b829e7524c",
578
- "bytes": 14549
593
+ "sha256": "59de84ffe2f110bbfd94e74d9eebfc19b91428577cf49a6aa9b701bf787a8423",
594
+ "bytes": 9778
579
595
  },
580
596
  "mcp/tool-description-provider.d.ts": {
581
597
  "sha256": "1d46abc3112e11b68e57197e846f5708293ec9b2281fa71a9124ee2aad71e41b",
@@ -590,8 +606,8 @@
590
606
  "bytes": 132
591
607
  },
592
608
  "mcp/tool-descriptions.js": {
593
- "sha256": "c8150119782dadd286e8430e9377b0b727891c414be2396e314423713939d6eb",
594
- "bytes": 7980
609
+ "sha256": "9c5e3b3b8fb06ddc2c27b0ecf26f70f0b5a6121ea7de91fe185c7ace57753503",
610
+ "bytes": 13658
595
611
  },
596
612
  "mcp/tool-factory.d.ts": {
597
613
  "sha256": "0fe3c6b863b2d7aef0c3d659ff54f3a9ee8a0a3c2005b6565d2f8ad517bc7211",
@@ -625,21 +641,37 @@
625
641
  "sha256": "a1c1fdd901bf6a074d9a48cef09e0020c59d9838bfb8754ed2aaf9c23191a533",
626
642
  "bytes": 750
627
643
  },
644
+ "mcp/types/workflow-tool-edition.d.ts": {
645
+ "sha256": "7407d318a9f0cc7d6dc81d7cb003e474b3a31a52bf3e600e07ee94f556e2555a",
646
+ "bytes": 1470
647
+ },
648
+ "mcp/types/workflow-tool-edition.js": {
649
+ "sha256": "2dfd26acd3da2c249b728e7fc48c7eab3dc675f786e7689dbdeec53c25589369",
650
+ "bytes": 283
651
+ },
652
+ "mcp/v1/tool-registry.d.ts": {
653
+ "sha256": "9320a6ea5ca6c6a42d3a6131b124b6941bb5cfccdae28461317e99ebb250b2e3",
654
+ "bytes": 408
655
+ },
656
+ "mcp/v1/tool-registry.js": {
657
+ "sha256": "e81dbbcf86f0f8c88edad0b27d78bc93acebd83e52f919cdf69f9c7906233bfc",
658
+ "bytes": 2674
659
+ },
628
660
  "mcp/v2/tool-registry.d.ts": {
629
- "sha256": "e97ae56ce8bc994fb33d130e4dfec6fb65d34dc15b6f828fc36010197da6bdbe",
630
- "bytes": 479
661
+ "sha256": "d4d4927728c3cab1c014661d499dd0119538371bc6c5e821a4cd31df7abebedf",
662
+ "bytes": 408
631
663
  },
632
664
  "mcp/v2/tool-registry.js": {
633
- "sha256": "33bf91363777bbb14d985978e0b056c67a6f7574dd3e8b572603a1b1db457237",
634
- "bytes": 2001
665
+ "sha256": "8c94984fed94f049daeb01559a2490b7db6fedac2544b3e7e50a60b8c7dfa561",
666
+ "bytes": 2121
635
667
  },
636
668
  "mcp/v2/tools.d.ts": {
637
669
  "sha256": "0ef14d1e8e375a17ff7f1edc26ded4a636207c6f9f998136d5910f7f86537602",
638
670
  "bytes": 2579
639
671
  },
640
672
  "mcp/v2/tools.js": {
641
- "sha256": "4b0d5d1c019d3f747b0f4211a606d1aba4944f9e570ae9fecc6831987a6cc16f",
642
- "bytes": 2537
673
+ "sha256": "c989b086779b0a65460a84647f3e8d0998c196b18f4c55beee6fa927a3531d42",
674
+ "bytes": 3686
643
675
  },
644
676
  "mcp/validation/bounded-json.d.ts": {
645
677
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -705,6 +737,14 @@
705
737
  "sha256": "537c7fd9068f45d5aee4a90e834a27e8bb1ee7fe2c6df860964c125e2979d86e",
706
738
  "bytes": 3670
707
739
  },
740
+ "mcp/workflow-tool-edition-selector.d.ts": {
741
+ "sha256": "75194908a89aaf7dc48fb661aea099827e7032ec76daf8f2de91bd59d46764ef",
742
+ "bytes": 328
743
+ },
744
+ "mcp/workflow-tool-edition-selector.js": {
745
+ "sha256": "08870a96c6f32c09e617f43f6eb83593c15007fe39241d498bd9bbbd420101fc",
746
+ "bytes": 635
747
+ },
708
748
  "mcp/zod-to-json-schema.d.ts": {
709
749
  "sha256": "c80cfa6980a88c823ac47d04706b2223a351de3f4c76ee778f81ad3dda2c766b",
710
750
  "bytes": 456
@@ -954,20 +994,52 @@
954
994
  "bytes": 447
955
995
  },
956
996
  "v2/durable-core/constants.d.ts": {
957
- "sha256": "4efb63cb3d6f1464030004cbc7b8d607d2db9be5b98f8f7e9398059a5afe1c91",
958
- "bytes": 830
997
+ "sha256": "cbe7837e0e05aee5050937774a5831c20e946b2c6b69a82e4f41bfc857319092",
998
+ "bytes": 882
959
999
  },
960
1000
  "v2/durable-core/constants.js": {
961
- "sha256": "3cd2a8376bf7c1dc65a7975da9cf31fb6aebd99b2846e094ec1583e23919bb21",
962
- "bytes": 1292
1001
+ "sha256": "f6f4ce3ac866aedca00015577c8865191cc8f1510ea64005bcbcca2a971686dc",
1002
+ "bytes": 1363
963
1003
  },
964
1004
  "v2/durable-core/domain/ack-advance-append-plan.d.ts": {
965
- "sha256": "d74117de64a0484a387fbbe7e129c4e40ab998f799d7664a3667de1c04a23921",
966
- "bytes": 1185
1005
+ "sha256": "8eef66853e8966c87181d0bc18428b55eb3ccde04c985fc3b16204ec303a47bf",
1006
+ "bytes": 1481
967
1007
  },
968
1008
  "v2/durable-core/domain/ack-advance-append-plan.js": {
969
- "sha256": "a4377231f5024e47a4b839ef3ea33711b5b876eef9c12a1c432628421cfebd87",
970
- "bytes": 3448
1009
+ "sha256": "c50899e954f65e275023710c4b2c2789992899136baf17b05ebc2a8944456ad4",
1010
+ "bytes": 5915
1011
+ },
1012
+ "v2/durable-core/domain/blocking-decision.d.ts": {
1013
+ "sha256": "6540ff9a947ad8a661984732c465f7051db8960acbda55c9aa17cbf0bbf3950d",
1014
+ "bytes": 1148
1015
+ },
1016
+ "v2/durable-core/domain/blocking-decision.js": {
1017
+ "sha256": "f3c86be68aaa045c57c942459031a72df2b2d514e32a57905c1a57f8374e947f",
1018
+ "bytes": 1718
1019
+ },
1020
+ "v2/durable-core/domain/context-merge.d.ts": {
1021
+ "sha256": "e3068d49237d2ae351cf88c6829bf612dc7ced6f726b618e7f8aeb7462d34256",
1022
+ "bytes": 381
1023
+ },
1024
+ "v2/durable-core/domain/context-merge.js": {
1025
+ "sha256": "3015757f6e3d909ee6cefd5734ce62b81f1716779c640f71e0e86a925bbc7345",
1026
+ "bytes": 1734
1027
+ },
1028
+ "v2/durable-core/domain/function-definition-expander.d.ts": {
1029
+ "sha256": "2720e7c4dfbd9ec0cdf75eb4384fdbea18d4430aeae7f13d9215f0e5e4980468",
1030
+ "bytes": 687
1031
+ },
1032
+ "v2/durable-core/domain/function-definition-expander.js": {
1033
+ "sha256": "c4f00bece7b2327f379ef7e1527429ef9b0f39a171b76181cf9adeede12ed48e",
1034
+ "bytes": 2617
1035
+ },
1036
+ "v2/durable-core/domain/gap-builder.d.ts": {
1037
+ "sha256": "e8069d47eb586d7f9e986df487d0e8ee7affbfbc60ebff5df437fb7bd647c952",
1038
+ "bytes": 620
1039
+ },
1040
+ "v2/durable-core/domain/gap-builder.js": {
1041
+ "sha256": "7d7869dad8d681ef15d1d302e9ed49be2286f807d9cf8163e7c3396ed5df83ce",
1042
+ "bytes": 833
971
1043
  },
972
1044
  "v2/durable-core/domain/loop-runtime.d.ts": {
973
1045
  "sha256": "ee4f8857d72bf0066bccc351a4e8fd8e4800f3d540e9851bb4978179b8ebfc04",
@@ -993,6 +1065,46 @@
993
1065
  "sha256": "ae16a0df03c3dec30e9ffca0066b6148568966f6660a3c660f82853e077a0cbd",
994
1066
  "bytes": 817
995
1067
  },
1068
+ "v2/durable-core/domain/prompt-renderer.d.ts": {
1069
+ "sha256": "dd9854d489a03ac57975dd1ecee6e73a4bcc8b78e61c5cd5b394307aab708a7b",
1070
+ "bytes": 935
1071
+ },
1072
+ "v2/durable-core/domain/prompt-renderer.js": {
1073
+ "sha256": "26d85771bab5f7901bf2a219f5f3f1a435f2429d46cb4fd2cd45feeb7b788721",
1074
+ "bytes": 6958
1075
+ },
1076
+ "v2/durable-core/domain/reason-model.d.ts": {
1077
+ "sha256": "7921e626f60b767007069a9c898aab1c6fdd15a0aae7c0506ed76b44634029eb",
1078
+ "bytes": 3501
1079
+ },
1080
+ "v2/durable-core/domain/reason-model.js": {
1081
+ "sha256": "8da32d4d699d050e599192991279124d89ba046ad08ea5960827a4437ae0ee88",
1082
+ "bytes": 10134
1083
+ },
1084
+ "v2/durable-core/domain/recap-recovery.d.ts": {
1085
+ "sha256": "82e7b20a22d409f729ccf79d345c00a7e27f1898a465dfca4cd789ff7766a3d6",
1086
+ "bytes": 983
1087
+ },
1088
+ "v2/durable-core/domain/recap-recovery.js": {
1089
+ "sha256": "d0145878abcf5b71fa1fdf87faacb7dee861217450947b6420422c1371d36fad",
1090
+ "bytes": 2879
1091
+ },
1092
+ "v2/durable-core/domain/validation-criteria-validator.d.ts": {
1093
+ "sha256": "2bdd2e9d3c0feb6c68fe0e032a3eecfd8ede2924349c1c43714783847518fd48",
1094
+ "bytes": 499
1095
+ },
1096
+ "v2/durable-core/domain/validation-criteria-validator.js": {
1097
+ "sha256": "95ab18d560424dd01df1b7696a8f1344f41d658d3bc6a91eb4b72fca15d8ba4b",
1098
+ "bytes": 732
1099
+ },
1100
+ "v2/durable-core/domain/validation-requirements-extractor.d.ts": {
1101
+ "sha256": "b1fc2178fc7cbea52fe32400c186c6a9c40622c148a788379e89e9b44c4838f1",
1102
+ "bytes": 188
1103
+ },
1104
+ "v2/durable-core/domain/validation-requirements-extractor.js": {
1105
+ "sha256": "dc37e599678b4a7faf88759bd9e7a1b9622b98656dfe4731ddda74e48436857e",
1106
+ "bytes": 1880
1107
+ },
996
1108
  "v2/durable-core/encoding/base32-lower.d.ts": {
997
1109
  "sha256": "1ae6d44917eaf2119286705dcc7240b9bcf7c5e965b780ce52aa17f3b893ad4f",
998
1110
  "bytes": 252
@@ -1074,8 +1186,8 @@
1074
1186
  "bytes": 2983
1075
1187
  },
1076
1188
  "v2/durable-core/schemas/export-bundle/index.d.ts": {
1077
- "sha256": "bbfe3948fc95992051ad3eaec4e9adbaa3c3f20cd8d8307edee37aab07123ca7",
1078
- "bytes": 268219
1189
+ "sha256": "05558aff367c80b2943487629cf90b66137694deadc40c069e7c600dd90b1e9e",
1190
+ "bytes": 273987
1079
1191
  },
1080
1192
  "v2/durable-core/schemas/export-bundle/index.js": {
1081
1193
  "sha256": "387b1444f81eb951ab3b66874b1e7407d41345ee60ef4e6dd43f8b4d84d97343",
@@ -1106,12 +1218,12 @@
1106
1218
  "bytes": 521
1107
1219
  },
1108
1220
  "v2/durable-core/schemas/session/events.d.ts": {
1109
- "sha256": "0df1c3728cece2a3100b59a8b8eda790e47561d6196988b566a5d14a32cd782e",
1110
- "bytes": 67557
1221
+ "sha256": "8d14048819d1d25195bf122f161e0a2995112aa90ec57ab2e409051ba98d9969",
1222
+ "bytes": 68920
1111
1223
  },
1112
1224
  "v2/durable-core/schemas/session/events.js": {
1113
- "sha256": "68e29429a82e6bb3154724526f4698f1359351534e980e22750e0e9be80cf52d",
1114
- "bytes": 17432
1225
+ "sha256": "4d717269b0234be99d10d081f39516f3cde48f216fff68fdd749e83c919427e7",
1226
+ "bytes": 17807
1115
1227
  },
1116
1228
  "v2/durable-core/schemas/session/index.d.ts": {
1117
1229
  "sha256": "f4f500d33d212760f480d91fafd4474f7b12f9239a6c5e9c2d80d0fe96207b65",
@@ -1497,6 +1609,14 @@
1497
1609
  "sha256": "2f769d3bf9c4bf45c95c793785c45df8803f52731b4ffaf57bef73df279da397",
1498
1610
  "bytes": 2212
1499
1611
  },
1612
+ "v2/projections/run-context.d.ts": {
1613
+ "sha256": "7bdc4b2bacfb4b42005b7a83d7ddaf8a8d414bed90b948c02dbeeacd741b31cc",
1614
+ "bytes": 909
1615
+ },
1616
+ "v2/projections/run-context.js": {
1617
+ "sha256": "41429486096e791e7ee3c806a3432421179c9a1a0972380e7e89d584bab733d7",
1618
+ "bytes": 1339
1619
+ },
1500
1620
  "v2/projections/run-dag.d.ts": {
1501
1621
  "sha256": "0594d5038cbe0fe88fd6cc037f32a3e88c04660c167757e870e0a2d51e7159a7",
1502
1622
  "bytes": 1516
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { ToolContext, ToolResult } from './types.js';
3
+ import type { PreValidateResult } from './validation/workflow-next-prevalidate.js';
4
+ import type { WrappedToolHandler, McpCallToolResult } from './types/workflow-tool-edition.js';
5
+ export declare function toMcpResult<T>(result: ToolResult<T>): McpCallToolResult;
6
+ export declare function createHandler<TInput extends z.ZodType, TOutput>(schema: TInput, handler: (input: z.infer<TInput>, ctx: ToolContext) => Promise<ToolResult<TOutput>>): WrappedToolHandler;
7
+ export declare function createValidatingHandler<TInput extends z.ZodType, TOutput>(schema: TInput, preValidate: (args: unknown) => PreValidateResult, handler: (input: z.infer<TInput>, ctx: ToolContext) => Promise<ToolResult<TOutput>>): WrappedToolHandler;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toMcpResult = toMcpResult;
4
+ exports.createHandler = createHandler;
5
+ exports.createValidatingHandler = createValidatingHandler;
6
+ const types_js_1 = require("./types.js");
7
+ const index_js_1 = require("./validation/index.js");
8
+ const bounded_json_js_1 = require("./validation/bounded-json.js");
9
+ function toMcpResult(result) {
10
+ switch (result.type) {
11
+ case 'success':
12
+ return {
13
+ content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
14
+ };
15
+ case 'error':
16
+ return {
17
+ content: [{
18
+ type: 'text',
19
+ text: JSON.stringify({
20
+ code: result.code,
21
+ message: result.message,
22
+ retry: result.retry,
23
+ ...(result.details !== undefined ? { details: result.details } : {}),
24
+ }, null, 2),
25
+ }],
26
+ isError: true,
27
+ };
28
+ }
29
+ }
30
+ function createHandler(schema, handler) {
31
+ return async (args, ctx) => {
32
+ const parseResult = schema.safeParse(args);
33
+ if (!parseResult.success) {
34
+ const suggestionResult = (0, index_js_1.generateSuggestions)(args, schema, index_js_1.DEFAULT_SUGGESTION_CONFIG);
35
+ const suggestionDetails = (0, index_js_1.formatSuggestionDetails)(suggestionResult);
36
+ return toMcpResult((0, types_js_1.errNotRetryable)('VALIDATION_ERROR', 'Invalid input', {
37
+ validationErrors: parseResult.error.errors.map(e => ({
38
+ path: e.path.join('.'),
39
+ message: e.message,
40
+ })),
41
+ ...suggestionDetails,
42
+ }));
43
+ }
44
+ return toMcpResult(await handler(parseResult.data, ctx));
45
+ };
46
+ }
47
+ function createValidatingHandler(schema, preValidate, handler) {
48
+ return async (args, ctx) => {
49
+ const pre = preValidate(args);
50
+ if (!pre.ok) {
51
+ const error = pre.error;
52
+ const details = error.details && typeof error.details === 'object' ? error.details : {};
53
+ const correctTemplate = details.correctTemplate;
54
+ if (correctTemplate !== undefined) {
55
+ const boundedTemplate = (0, bounded_json_js_1.toBoundedJsonValue)(correctTemplate, 512);
56
+ const boundedDetails = {
57
+ ...details,
58
+ correctTemplate: boundedTemplate,
59
+ };
60
+ const boundedError = {
61
+ ...error,
62
+ details: boundedDetails,
63
+ };
64
+ return toMcpResult(boundedError);
65
+ }
66
+ return toMcpResult(error);
67
+ }
68
+ return createHandler(schema, handler)(args, ctx);
69
+ };
70
+ }