@exaudeus/workrail 3.5.0 → 3.6.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 (44) hide show
  1. package/dist/application/services/validation-engine.js +50 -0
  2. package/dist/config/feature-flags.js +8 -0
  3. package/dist/engine/engine-factory.js +4 -2
  4. package/dist/manifest.json +100 -52
  5. package/dist/mcp/handler-factory.js +21 -4
  6. package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +6 -1
  7. package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +22 -4
  8. package/dist/mcp/handlers/v2-execution/index.d.ts +6 -1
  9. package/dist/mcp/handlers/v2-execution/index.js +13 -3
  10. package/dist/mcp/handlers/v2-execution/start.d.ts +9 -1
  11. package/dist/mcp/handlers/v2-execution/start.js +74 -36
  12. package/dist/mcp/handlers/v2-execution-helpers.d.ts +2 -0
  13. package/dist/mcp/handlers/v2-execution-helpers.js +2 -0
  14. package/dist/mcp/handlers/v2-reference-resolver.d.ts +14 -0
  15. package/dist/mcp/handlers/v2-reference-resolver.js +112 -0
  16. package/dist/mcp/handlers/v2-resolve-refs-envelope.d.ts +5 -0
  17. package/dist/mcp/handlers/v2-resolve-refs-envelope.js +17 -0
  18. package/dist/mcp/handlers/v2-workflow.js +2 -0
  19. package/dist/mcp/output-schemas.d.ts +38 -0
  20. package/dist/mcp/output-schemas.js +8 -0
  21. package/dist/mcp/render-envelope.d.ts +21 -0
  22. package/dist/mcp/render-envelope.js +59 -0
  23. package/dist/mcp/response-supplements.d.ts +17 -0
  24. package/dist/mcp/response-supplements.js +58 -0
  25. package/dist/mcp/step-content-envelope.d.ts +32 -0
  26. package/dist/mcp/step-content-envelope.js +13 -0
  27. package/dist/mcp/v2-response-formatter.d.ts +11 -1
  28. package/dist/mcp/v2-response-formatter.js +168 -1
  29. package/dist/mcp/workflow-protocol-contracts.js +9 -7
  30. package/dist/types/workflow-definition.d.ts +16 -0
  31. package/dist/types/workflow-definition.js +1 -0
  32. package/dist/utils/condition-evaluator.d.ts +1 -0
  33. package/dist/utils/condition-evaluator.js +7 -0
  34. package/dist/v2/durable-core/domain/context-template-resolver.d.ts +2 -0
  35. package/dist/v2/durable-core/domain/context-template-resolver.js +26 -0
  36. package/dist/v2/durable-core/domain/prompt-renderer.d.ts +2 -0
  37. package/dist/v2/durable-core/domain/prompt-renderer.js +93 -15
  38. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +256 -0
  39. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +30 -0
  40. package/package.json +4 -1
  41. package/spec/authoring-spec.provenance.json +77 -0
  42. package/spec/authoring-spec.schema.json +370 -0
  43. package/workflows/coding-task-workflow-agentic.lean.v2.json +132 -30
  44. package/workflows/workflow-for-workflows.json +27 -1
@@ -562,6 +562,33 @@ let ValidationEngine = ValidationEngine_1 = class ValidationEngine {
562
562
  }
563
563
  }
564
564
  }
565
+ if (workflow.definition.references !== undefined) {
566
+ const seenRefIds = new Set();
567
+ for (const ref of workflow.definition.references) {
568
+ if (!ref.id || typeof ref.id !== 'string') {
569
+ issues.push(`Workflow reference has missing or empty id`);
570
+ }
571
+ else {
572
+ if (seenRefIds.has(ref.id)) {
573
+ issues.push(`Workflow reference has duplicate id '${ref.id}'`);
574
+ suggestions.push('Each workflow reference id must be unique');
575
+ }
576
+ seenRefIds.add(ref.id);
577
+ }
578
+ if (!ref.title || typeof ref.title !== 'string') {
579
+ issues.push(`Workflow reference '${ref.id ?? '(unknown)'}' has missing or empty title`);
580
+ }
581
+ if (!ref.source || typeof ref.source !== 'string') {
582
+ issues.push(`Workflow reference '${ref.id ?? '(unknown)'}' has missing or empty source`);
583
+ }
584
+ if (!ref.purpose || typeof ref.purpose !== 'string') {
585
+ issues.push(`Workflow reference '${ref.id ?? '(unknown)'}' has missing or empty purpose`);
586
+ }
587
+ if (typeof ref.authoritative !== 'boolean') {
588
+ issues.push(`Workflow reference '${ref.id ?? '(unknown)'}' has missing or non-boolean authoritative field`);
589
+ }
590
+ }
591
+ }
565
592
  const stepIds = new Set();
566
593
  for (const step of workflow.definition.steps) {
567
594
  if (stepIds.has(step.id)) {
@@ -602,6 +629,29 @@ let ValidationEngine = ValidationEngine_1 = class ValidationEngine {
602
629
  issues.push(`Step '${step.id}' declares multiple prompt sources (prompt, promptBlocks, templateCall) — use exactly one`);
603
630
  }
604
631
  this.collectQuotedJsonValidationMessageWarnings(step, `Step '${step.id}'`, warnings);
632
+ const typedStepForFragments = step;
633
+ if (typedStepForFragments.promptFragments !== undefined) {
634
+ const seenFragmentIds = new Set();
635
+ for (const fragment of typedStepForFragments.promptFragments) {
636
+ if (!fragment.id || typeof fragment.id !== 'string') {
637
+ issues.push(`Step '${step.id}': promptFragment has missing or empty id`);
638
+ }
639
+ else {
640
+ if (seenFragmentIds.has(fragment.id)) {
641
+ issues.push(`Step '${step.id}': promptFragments has duplicate id '${fragment.id}'`);
642
+ suggestions.push('Each promptFragment id must be unique within a step');
643
+ }
644
+ seenFragmentIds.add(fragment.id);
645
+ }
646
+ if (!fragment.text || typeof fragment.text !== 'string') {
647
+ issues.push(`Step '${step.id}': promptFragment '${fragment.id ?? '(unknown)'}' has missing or empty text`);
648
+ }
649
+ else if (/\{\{wr\./i.test(fragment.text)) {
650
+ issues.push(`Step '${step.id}': promptFragment '${fragment.id}' text contains '{{wr.*}}' token — fragments are raw text and do not support token resolution`);
651
+ suggestions.push('Move {{wr.*}} tokens to the step prompt or promptBlocks where they are resolved at compile time');
652
+ }
653
+ }
654
+ }
605
655
  const callValidation = this.validateStepFunctionCalls(step, workflow.definition.functionDefinitions || []);
606
656
  if (!callValidation.valid) {
607
657
  issues.push(...callValidation.issues.map(i => `Step '${step.id}': ${i}`));
@@ -69,6 +69,14 @@ exports.FEATURE_FLAG_DEFINITIONS = [
69
69
  since: '0.9.0',
70
70
  stable: true,
71
71
  },
72
+ {
73
+ key: 'cleanResponseFormat',
74
+ envVar: 'WORKRAIL_CLEAN_RESPONSE_FORMAT',
75
+ defaultValue: false,
76
+ description: 'Use clean response format that removes system scaffolding from step prompts to improve agent authority perception',
77
+ since: '0.11.0',
78
+ stable: false,
79
+ },
72
80
  ];
73
81
  function parseBoolean(value, defaultValue) {
74
82
  if (value === undefined) {
@@ -52,6 +52,8 @@ function mapStartError(e) {
52
52
  return { kind: 'storage_error', message: e.cause.message, code: e.cause.code };
53
53
  case 'session_append_failed':
54
54
  return { kind: 'session_error', message: e.cause.message, code: e.cause.code };
55
+ case 'reference_resolution_failed':
56
+ return { kind: 'internal_error', message: 'WorkRail could not resolve workflow references.' };
55
57
  }
56
58
  }
57
59
  function mapContinueError(e) {
@@ -242,7 +244,7 @@ async function createWorkRailEngine(config = {}) {
242
244
  if (result.isErr()) {
243
245
  return (0, types_js_1.engineErr)(mapStartError(result.error));
244
246
  }
245
- return (0, types_js_1.engineOk)(mapStartOutput(result.value));
247
+ return (0, types_js_1.engineOk)(mapStartOutput(result.value.response));
246
248
  },
247
249
  async continueWorkflow(stateToken, ackToken, output, context) {
248
250
  const intent = ackToken ? 'advance' : 'rehydrate';
@@ -261,7 +263,7 @@ async function createWorkRailEngine(config = {}) {
261
263
  if (result.isErr()) {
262
264
  return (0, types_js_1.engineErr)(mapContinueError(result.error));
263
265
  }
264
- return (0, types_js_1.engineOk)(mapContinueOutput(result.value));
266
+ return (0, types_js_1.engineOk)(mapContinueOutput(result.value.response));
265
267
  },
266
268
  async checkpointWorkflow(checkpointToken) {
267
269
  const result = await (0, v2_checkpoint_js_1.executeCheckpoint)({ checkpointToken: (0, types_js_1.unwrapToken)(checkpointToken) }, v2Ctx);
@@ -126,8 +126,8 @@
126
126
  "bytes": 2122
127
127
  },
128
128
  "application/services/validation-engine.js": {
129
- "sha256": "efbe402b22980383558863abf61bec728604ad81d07d9d48d0a6f52e69fafa3b",
130
- "bytes": 37800
129
+ "sha256": "05edc2d65f29fcdbb0a87738ee575dae06423dbb044d7af6bac56d7dba7dbede",
130
+ "bytes": 40905
131
131
  },
132
132
  "application/services/workflow-compiler.d.ts": {
133
133
  "sha256": "f51443e1c3e8e079a972dd032e8de3bcde7b82d891e9a3621a6357cc4fc0e30d",
@@ -358,8 +358,8 @@
358
358
  "bytes": 1512
359
359
  },
360
360
  "config/feature-flags.js": {
361
- "sha256": "ce45dded930747e989783df453bfea0458f87bf790c8be4a1b0bd9ceac9ac2a5",
362
- "bytes": 7374
361
+ "sha256": "70f945ac04d894134f762f6a6dac856d04583ecb71dad98cc3806641a366cafd",
362
+ "bytes": 7688
363
363
  },
364
364
  "core/error-handler.d.ts": {
365
365
  "sha256": "80451f12ac8e185133ec3dc4c57285491a785f27525ed21e729db1da3f61010d",
@@ -438,8 +438,8 @@
438
438
  "bytes": 213
439
439
  },
440
440
  "engine/engine-factory.js": {
441
- "sha256": "a189ecc0d6c06da36f472c62647f59de05b244e00073d67e7f0965b3537b6ff8",
442
- "bytes": 13489
441
+ "sha256": "07d88be2ab8488615871ae363b9db4fc23caebba8231c8c2aaa2f97da2b18fdd",
442
+ "bytes": 13658
443
443
  },
444
444
  "engine/index.d.ts": {
445
445
  "sha256": "91e12882c565e96a9809fdf43a0dc0a77fdffdfd562aaf43d2e86e6590ed0b16",
@@ -670,8 +670,8 @@
670
670
  "bytes": 883
671
671
  },
672
672
  "mcp/handler-factory.js": {
673
- "sha256": "fc4c13d109dcfbe4ea3b5a9d4118edf7f736c8e8c1a50d6087289c76c3286dfb",
674
- "bytes": 4369
673
+ "sha256": "1216fe5e913c832242b3c9c2d9954441300b08660db59fe9deac8a4b7dc583db",
674
+ "bytes": 5310
675
675
  },
676
676
  "mcp/handlers/session.d.ts": {
677
677
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
@@ -778,12 +778,12 @@
778
778
  "bytes": 10680
779
779
  },
780
780
  "mcp/handlers/v2-execution-helpers.d.ts": {
781
- "sha256": "06c8820bb6667d30374733c10e537680ff63acfffa3fc29d7b454f08c6d6918c",
782
- "bytes": 5383
781
+ "sha256": "bf374e9b9cd8bf05947d72f3ee100871fe825773e50ff48452f51ed51ff1ec3c",
782
+ "bytes": 5439
783
783
  },
784
784
  "mcp/handlers/v2-execution-helpers.js": {
785
- "sha256": "569d7cfe3e3476aea113aa922c9299311e33a2f22952accbc589b98eabd94cf9",
786
- "bytes": 19071
785
+ "sha256": "149aa6e6e643b6f42683d1d1b97ab5dbeade356edb7f6139fef1b64c8937867b",
786
+ "bytes": 19388
787
787
  },
788
788
  "mcp/handlers/v2-execution.d.ts": {
789
789
  "sha256": "f76cd1bb6a6e25c5a37a1f5b01b1046f4afd41162b620f3be3861509e1fcd1d3",
@@ -810,20 +810,20 @@
810
810
  "bytes": 8269
811
811
  },
812
812
  "mcp/handlers/v2-execution/continue-rehydrate.d.ts": {
813
- "sha256": "38c3381de5ae15769d356d21196948a8e1e371e2d062aaacd5c89c10b52a142a",
814
- "bytes": 1559
813
+ "sha256": "f689b374ba48ffda4533e519608acb03c792f8c509c5b5da03c6a5a23729bee9",
814
+ "bytes": 1763
815
815
  },
816
816
  "mcp/handlers/v2-execution/continue-rehydrate.js": {
817
- "sha256": "e6525294ee20b4a4ec53cadf8fe6c567a64a082987143bb4695bcdc6615e160a",
818
- "bytes": 9574
817
+ "sha256": "4d92f0eed365ca1e8f4076d75bee9511ff45a580a393576bbcce4a46951b3d47",
818
+ "bytes": 10365
819
819
  },
820
820
  "mcp/handlers/v2-execution/index.d.ts": {
821
- "sha256": "e60e1e0c65e51d101fb06248e882494e6df52762e1d68f5de7081c1cf1ec8bc5",
822
- "bytes": 1226
821
+ "sha256": "2fcb7d3c059a4c79ca66ef0f0b28a0d45dc0e327b45c9ec183a1d1aea78d08d4",
822
+ "bytes": 1437
823
823
  },
824
824
  "mcp/handlers/v2-execution/index.js": {
825
- "sha256": "b5f67907b27594cb18482e494caaffa89c62bbc7304e5ce6582cb90329286ac6",
826
- "bytes": 6731
825
+ "sha256": "adb91a7f6ca0a8cbe07c32908019b012dc72365da900dda13cbbec2e76ee22e6",
826
+ "bytes": 7239
827
827
  },
828
828
  "mcp/handlers/v2-execution/replay.d.ts": {
829
829
  "sha256": "bbf97633d7e47af3574a9690a1976bb474ca49cecc08af1d5c07e90f9868036d",
@@ -834,12 +834,28 @@
834
834
  "bytes": 8654
835
835
  },
836
836
  "mcp/handlers/v2-execution/start.d.ts": {
837
- "sha256": "6847beabf35eb4c8780a649c99f4f60047c34e7ce7d8295c528d72f0f7d35f2d",
838
- "bytes": 3036
837
+ "sha256": "14e91fa5531c3bbc05fd96157633d7de7cb4ccb8b85dfaad9c077afbe440a145",
838
+ "bytes": 3422
839
839
  },
840
840
  "mcp/handlers/v2-execution/start.js": {
841
- "sha256": "4f52d3b4dea3e1bdfcdb1057cb925de6293d938a4f1bddc396dc982bebab5ff6",
842
- "bytes": 15841
841
+ "sha256": "593edf798bb1d2d0011ec81e4f170e4f4003b978cd9900fd785b583d15cd1085",
842
+ "bytes": 18014
843
+ },
844
+ "mcp/handlers/v2-reference-resolver.d.ts": {
845
+ "sha256": "0b1d2640306b6a0c1067ca66bb20e6ec35d291b33dc328a78d5bfa8006394234",
846
+ "bytes": 756
847
+ },
848
+ "mcp/handlers/v2-reference-resolver.js": {
849
+ "sha256": "5aeabc5d2a078446458d51918f86019895562a1cf7eef99cba19863c6b63d36c",
850
+ "bytes": 4619
851
+ },
852
+ "mcp/handlers/v2-resolve-refs-envelope.d.ts": {
853
+ "sha256": "daa88ef4cc5ed12cec550b0b6975ede225a6278ca9c2328c755048210ff518bb",
854
+ "bytes": 471
855
+ },
856
+ "mcp/handlers/v2-resolve-refs-envelope.js": {
857
+ "sha256": "abcd80dd947bef61bfc068027a0ef1af3a3e13bd67aa3bc410efe66670dbdb50",
858
+ "bytes": 917
843
859
  },
844
860
  "mcp/handlers/v2-resume.d.ts": {
845
861
  "sha256": "d88f6c35bcaf946666c837b72fda3702a2ebab5e478eb90f7b4b672a0e5fa24f",
@@ -870,8 +886,8 @@
870
886
  "bytes": 396
871
887
  },
872
888
  "mcp/handlers/v2-workflow.js": {
873
- "sha256": "e869550933484b473ee51e4f66b29324c17213b87f3fc8bbb3e098ffc00d6f88",
874
- "bytes": 7034
889
+ "sha256": "d305d516bd450d409b8658857f7713cfa74299f9ccf85e103057f684fcd7008a",
890
+ "bytes": 7185
875
891
  },
876
892
  "mcp/handlers/v2-workspace-resolution.d.ts": {
877
893
  "sha256": "dd4de57b4918ebe749cf8c1df70c02bf1effc50932634bae60db53c9a157e872",
@@ -898,12 +914,28 @@
898
914
  "bytes": 7991
899
915
  },
900
916
  "mcp/output-schemas.d.ts": {
901
- "sha256": "bb39f2c47db899f5e55da46f268423c20ded9c6ebce7f35aef14c4359f056e2b",
902
- "bytes": 50378
917
+ "sha256": "450ac819bddaf668eb662b8327591df72b68d553fb16a7bd7797fadc68b8b8c8",
918
+ "bytes": 51526
903
919
  },
904
920
  "mcp/output-schemas.js": {
905
- "sha256": "7a2fa7e0ec17a713314c19fa17edfe56cf8c3882a2046d12ad6d38a68eb5d2e7",
906
- "bytes": 12703
921
+ "sha256": "73c8cd97868afd6f6e6f3deac1a3aabc38384f82c532be91bd5ea6ad2f744a49",
922
+ "bytes": 13044
923
+ },
924
+ "mcp/render-envelope.d.ts": {
925
+ "sha256": "22e83e1aba52968a7136cf289125a217b5f462a5a66a1eebe4669006e3326fdb",
926
+ "bytes": 1224
927
+ },
928
+ "mcp/render-envelope.js": {
929
+ "sha256": "137fa6d6a31c86ab27ac8f924493be3e587e96ee0ff35428382c114caa596eca",
930
+ "bytes": 2403
931
+ },
932
+ "mcp/response-supplements.d.ts": {
933
+ "sha256": "f6b811998ebfe61d77d207caf8d4443f3c4274fea6435121ed7631fffa92642c",
934
+ "bytes": 626
935
+ },
936
+ "mcp/response-supplements.js": {
937
+ "sha256": "674f63b6fed305148e429d3221a4693902f383c31b83c177e401935ebdcdc2ec",
938
+ "bytes": 2473
907
939
  },
908
940
  "mcp/server.d.ts": {
909
941
  "sha256": "3260bb40e88c3eca469940f3d7e20f6442c267ea7a189984d5c569924c9e1ef0",
@@ -913,6 +945,14 @@
913
945
  "sha256": "1e5faf28495dff31b83b9f86ba07e05e14fb88c757f4e9e3460235f92c0602ab",
914
946
  "bytes": 11642
915
947
  },
948
+ "mcp/step-content-envelope.d.ts": {
949
+ "sha256": "19bd63c4d4de1d5d93393d346625d28ffd1bebdc320d4ba4e694cb740ec97d3b",
950
+ "bytes": 1171
951
+ },
952
+ "mcp/step-content-envelope.js": {
953
+ "sha256": "7e203c40878c2c1c8ece561a0c0f8d1471edb3c1da42a0a2841854116f3a353d",
954
+ "bytes": 483
955
+ },
916
956
  "mcp/tool-description-provider.d.ts": {
917
957
  "sha256": "1d46abc3112e11b68e57197e846f5708293ec9b2281fa71a9124ee2aad71e41b",
918
958
  "bytes": 755
@@ -1018,12 +1058,12 @@
1018
1058
  "bytes": 2674
1019
1059
  },
1020
1060
  "mcp/v2-response-formatter.d.ts": {
1021
- "sha256": "51d09b828d7dcfa1c82607d4f27030c8913b2c7502ee2fb65c0cfc7618916701",
1022
- "bytes": 81
1061
+ "sha256": "b0dfb56016eabbc61fdb9d1f668d35c3fba7e8060b70be5aa74356ae0334ff0e",
1062
+ "bytes": 438
1023
1063
  },
1024
1064
  "mcp/v2-response-formatter.js": {
1025
- "sha256": "8696b360c0b6a586d3118e7009c76ec2c06812940950d75f2a06c2528a673bde",
1026
- "bytes": 7854
1065
+ "sha256": "76615380b865b264d8c124231bae44d285ae738a17dc3b7b2ff5906c08eee646",
1066
+ "bytes": 14437
1027
1067
  },
1028
1068
  "mcp/v2/tool-registry.d.ts": {
1029
1069
  "sha256": "d4d4927728c3cab1c014661d499dd0119538371bc6c5e821a4cd31df7abebedf",
@@ -1110,8 +1150,8 @@
1110
1150
  "bytes": 1863
1111
1151
  },
1112
1152
  "mcp/workflow-protocol-contracts.js": {
1113
- "sha256": "8bc9e73b604471bf60de9499c708d7393a82f97917390acc3c14456d9534a77d",
1114
- "bytes": 11646
1153
+ "sha256": "715cf1dfa780a62b5b5dc08a3da9cbba3d444dc75c1d68db0b5c2ede804c5bd3",
1154
+ "bytes": 12840
1115
1155
  },
1116
1156
  "mcp/workflow-tool-edition-selector.d.ts": {
1117
1157
  "sha256": "75194908a89aaf7dc48fb661aea099827e7032ec76daf8f2de91bd59d46764ef",
@@ -1266,12 +1306,12 @@
1266
1306
  "bytes": 395
1267
1307
  },
1268
1308
  "types/workflow-definition.d.ts": {
1269
- "sha256": "1a76d084ea7af32c95c2858e8b42fd48002194657a30fe32c446094b42b074a9",
1270
- "bytes": 4284
1309
+ "sha256": "0ef5f195dfb9783cf0fa73ee9a7523efd56816f6174a530cc24c3cb6468e5ce0",
1310
+ "bytes": 4823
1271
1311
  },
1272
1312
  "types/workflow-definition.js": {
1273
- "sha256": "de2b3366741898bd187ea6ad5064e131beec33213a8c1d2c8182496880250d79",
1274
- "bytes": 1863
1313
+ "sha256": "1099b87129abeb986e19d5ec03006eaa83cbed9ab902e2b4401363a9e04b42dc",
1314
+ "bytes": 1995
1275
1315
  },
1276
1316
  "types/workflow-source.d.ts": {
1277
1317
  "sha256": "ee439c36ac3002780837ff393120d08a1c21ef2641421cdf72f0e1449d0211eb",
@@ -1298,12 +1338,12 @@
1298
1338
  "bytes": 6700
1299
1339
  },
1300
1340
  "utils/condition-evaluator.d.ts": {
1301
- "sha256": "e758a7deefc801e0499ea1696da0ac92bdcc8babf08438b189471193cba61672",
1302
- "bytes": 566
1341
+ "sha256": "ba0a7fbb2c9a2f5b52bfe8578507f13d304266c02ac8b4d7a21a52741dec975f",
1342
+ "bytes": 586
1303
1343
  },
1304
1344
  "utils/condition-evaluator.js": {
1305
- "sha256": "e8425e1db73699b67b6f8df890764113e1d5ed08a39f303c3ca25f6701a79525",
1306
- "bytes": 5302
1345
+ "sha256": "5ea160466959f432576ee55f63d6ef81be977251264855bb9b2f1463209369ba",
1346
+ "bytes": 5570
1307
1347
  },
1308
1348
  "utils/context-size.d.ts": {
1309
1349
  "sha256": "52cbcff69a237491228b075cb5e052567cbe4e9e405475d92a1d0a49f662a75b",
@@ -1449,6 +1489,14 @@
1449
1489
  "sha256": "3015757f6e3d909ee6cefd5734ce62b81f1716779c640f71e0e86a925bbc7345",
1450
1490
  "bytes": 1734
1451
1491
  },
1492
+ "v2/durable-core/domain/context-template-resolver.d.ts": {
1493
+ "sha256": "fe5df7658a41186ff7abb390815c2d961fb07fec76774e544f153f43614d7f4c",
1494
+ "bytes": 161
1495
+ },
1496
+ "v2/durable-core/domain/context-template-resolver.js": {
1497
+ "sha256": "3e46f8c05304a53bcde9799837b21b855c983c5cc33a75d5ef074e019f26059f",
1498
+ "bytes": 990
1499
+ },
1452
1500
  "v2/durable-core/domain/decision-trace-builder.d.ts": {
1453
1501
  "sha256": "bcc7892a25099be88ca92770d98f2e7e232eef007ff8f48001aefe9c08ee876c",
1454
1502
  "bytes": 1742
@@ -1514,12 +1562,12 @@
1514
1562
  "bytes": 942
1515
1563
  },
1516
1564
  "v2/durable-core/domain/prompt-renderer.d.ts": {
1517
- "sha256": "6bbafe042ad3e6be2043f8d79ffbf4b3e800dbc862427b41e02e7986357a9df5",
1518
- "bytes": 968
1565
+ "sha256": "0acacb335ea0101f9df823c0513690796edea08f77dc6aef18c6d1988c3cfa48",
1566
+ "bytes": 1175
1519
1567
  },
1520
1568
  "v2/durable-core/domain/prompt-renderer.js": {
1521
- "sha256": "43a0bce6e074755b5385723f956ce670736d216e8ab47fcbc02bfa3d162dbc3f",
1522
- "bytes": 14004
1569
+ "sha256": "2ac48cd9cdcecd19bec6bec710e6f45437f68a62df6fac60ce3eff1cdb821b32",
1570
+ "bytes": 18266
1523
1571
  },
1524
1572
  "v2/durable-core/domain/reason-model.d.ts": {
1525
1573
  "sha256": "650fcb2d9969a4e6123cccbd4913f4d57aeab21a19bb907aa1e11f95e5a95089",
@@ -1714,12 +1762,12 @@
1714
1762
  "bytes": 2115
1715
1763
  },
1716
1764
  "v2/durable-core/schemas/compiled-workflow/index.d.ts": {
1717
- "sha256": "513623689776543a66cf002353b5e8f2fe5b12b3f7df7a45eb8891de09989a66",
1718
- "bytes": 4415
1765
+ "sha256": "e7adc0105bce4f60f4fc3ecfa158dd623ce09e78fe75ec90d5718197a3f7a301",
1766
+ "bytes": 11821
1719
1767
  },
1720
1768
  "v2/durable-core/schemas/compiled-workflow/index.js": {
1721
- "sha256": "9530bc6dd70cbfa4c1bfdcf1e9061ff28d83135ec36733ebcccf0c6d5d8559ee",
1722
- "bytes": 1483
1769
+ "sha256": "67e9ccfbcf6e07d804fe925c6a8b67e5624d655f9564eec44658cb07f38a6486",
1770
+ "bytes": 2750
1723
1771
  },
1724
1772
  "v2/durable-core/schemas/execution-snapshot/blocked-snapshot.d.ts": {
1725
1773
  "sha256": "278fa4bf5b42f7560382bd821ec706151bba0ab8fc7a17118dfcd02824757625",
@@ -8,18 +8,35 @@ const index_js_1 = require("./validation/index.js");
8
8
  const bounded_json_js_1 = require("./validation/bounded-json.js");
9
9
  const v2_execution_helpers_js_1 = require("./handlers/v2-execution-helpers.js");
10
10
  const v2_response_formatter_js_1 = require("./v2-response-formatter.js");
11
+ const render_envelope_js_1 = require("./render-envelope.js");
11
12
  const jsonResponsesOverride = process.env.WORKRAIL_JSON_RESPONSES === 'true';
12
13
  function toMcpResult(result) {
13
14
  switch (result.type) {
14
15
  case 'success': {
15
16
  if (!jsonResponsesOverride) {
16
- const nl = (0, v2_response_formatter_js_1.formatV2ExecutionResponse)(result.data);
17
- if (nl !== null) {
18
- return { content: [{ type: 'text', text: nl }] };
17
+ const formatted = (0, v2_response_formatter_js_1.formatV2ExecutionResponse)(result.data);
18
+ if (formatted !== null) {
19
+ const content = [{ type: 'text', text: formatted.primary }];
20
+ if (formatted.references != null) {
21
+ content.push({ type: 'text', text: formatted.references.text });
22
+ }
23
+ for (const supplement of formatted.supplements ?? []) {
24
+ content.push({ type: 'text', text: supplement.text });
25
+ }
26
+ return { content };
19
27
  }
20
28
  }
29
+ const envelope = (0, render_envelope_js_1.getV2ExecutionRenderEnvelope)(result.data);
30
+ const responseBody = envelope != null ? envelope.response : result.data;
31
+ const refs = envelope?.contentEnvelope?.references;
32
+ const jsonPayload = (refs != null && refs.length > 0)
33
+ ? { ...responseBody, references: refs }
34
+ : responseBody;
21
35
  return {
22
- content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
36
+ content: [{
37
+ type: 'text',
38
+ text: JSON.stringify(jsonPayload, null, 2),
39
+ }],
23
40
  };
24
41
  }
25
42
  case 'error':
@@ -6,6 +6,11 @@ import type { TokenCodecPorts } from '../../../v2/durable-core/tokens/token-code
6
6
  import { ResultAsync as RA } from 'neverthrow';
7
7
  import { type ContinueWorkflowError } from '../v2-execution-helpers.js';
8
8
  import * as z from 'zod';
9
+ import { type StepContentEnvelope } from '../../step-content-envelope.js';
10
+ export interface RehydrateResult {
11
+ readonly response: z.infer<typeof V2ContinueWorkflowOutputSchema>;
12
+ readonly contentEnvelope?: StepContentEnvelope;
13
+ }
9
14
  export declare function handleRehydrateIntent(args: {
10
15
  readonly input: V2ContinueWorkflowInput;
11
16
  readonly sessionId: SessionId;
@@ -22,4 +27,4 @@ export declare function handleRehydrateIntent(args: {
22
27
  readonly aliasStore: import('../../../v2/ports/token-alias-store.port.js').TokenAliasStorePortV2;
23
28
  readonly entropy: import('../../../v2/ports/random-entropy.port.js').RandomEntropyPortV2;
24
29
  readonly resolvedRootUris?: readonly string[];
25
- }): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
30
+ }): RA<RehydrateResult, ContinueWorkflowError>;
@@ -18,6 +18,7 @@ const v2_token_ops_js_1 = require("../v2-token-ops.js");
18
18
  const v2_state_conversion_js_1 = require("../v2-state-conversion.js");
19
19
  const constants_js_1 = require("../../../v2/durable-core/constants.js");
20
20
  const index_js_2 = require("./index.js");
21
+ const step_content_envelope_js_1 = require("../../step-content-envelope.js");
21
22
  function handleRehydrateIntent(args) {
22
23
  const { input, sessionId, runId, nodeId, workflowHashRef, truth, tokenCodecPorts, pinnedStore, snapshotStore, idFactory, aliasStore, entropy, resolvedRootUris } = args;
23
24
  const runStarted = truth.events.find((e) => e.kind === constants_js_1.EVENT_KIND.RUN_STARTED && e.scope.runId === String(runId));
@@ -92,7 +93,7 @@ function handleRehydrateIntent(args) {
92
93
  if (!pending) {
93
94
  const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId });
94
95
  const nextIntent = (0, v2_state_conversion_js_1.deriveNextIntent)({ rehydrateOnly: true, isComplete, pending: null });
95
- return (0, neverthrow_1.okAsync)(output_schemas_js_1.V2ContinueWorkflowOutputSchema.parse({
96
+ const parsed = output_schemas_js_1.V2ContinueWorkflowOutputSchema.parse({
96
97
  kind: 'ok',
97
98
  isComplete,
98
99
  pending: null,
@@ -100,7 +101,8 @@ function handleRehydrateIntent(args) {
100
101
  nextIntent,
101
102
  nextCall: null,
102
103
  ...(driftWarnings.length > 0 ? { warnings: driftWarnings } : {}),
103
- }));
104
+ });
105
+ return (0, neverthrow_1.okAsync)({ response: parsed });
104
106
  }
105
107
  const attemptId = (0, v2_token_ops_js_1.newAttemptId)(idFactory);
106
108
  const entryBase = {
@@ -132,7 +134,11 @@ function handleRehydrateIntent(args) {
132
134
  const meta = metaRes.value;
133
135
  const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId });
134
136
  const nextIntent = (0, v2_state_conversion_js_1.deriveNextIntent)({ rehydrateOnly: true, isComplete, pending: meta });
135
- return (0, neverthrow_1.okAsync)(output_schemas_js_1.V2ContinueWorkflowOutputSchema.parse({
137
+ const contentEnvelope = (0, step_content_envelope_js_1.buildStepContentEnvelope)({
138
+ meta,
139
+ references: pinned.resolvedReferences ?? buildPinnedReferencesFallback(pinned.definition.references ?? []),
140
+ });
141
+ const parsed = output_schemas_js_1.V2ContinueWorkflowOutputSchema.parse({
136
142
  kind: 'ok',
137
143
  continueToken: continueTokenValue,
138
144
  checkpointToken: checkpointTokenValue,
@@ -142,11 +148,23 @@ function handleRehydrateIntent(args) {
142
148
  nextIntent,
143
149
  nextCall: (0, index_js_2.buildNextCall)({ continueToken: continueTokenValue, isComplete, pending: meta }),
144
150
  ...(driftWarnings.length > 0 ? { warnings: driftWarnings } : {}),
145
- }));
151
+ });
152
+ return (0, neverthrow_1.okAsync)({ response: parsed, contentEnvelope });
146
153
  });
147
154
  });
148
155
  });
149
156
  }
157
+ function buildPinnedReferencesFallback(refs) {
158
+ return refs.map((ref) => ({
159
+ id: ref.id,
160
+ title: ref.title,
161
+ source: ref.source,
162
+ purpose: ref.purpose,
163
+ authoritative: ref.authoritative,
164
+ resolveFrom: (ref.resolveFrom ?? 'workspace'),
165
+ status: 'pinned',
166
+ }));
167
+ }
150
168
  function detectBindingDriftForSnapshot(pinned, workflowId, baseDir) {
151
169
  const pinnedOverrides = pinned.pinnedOverrides ?? pinned.resolvedBindings;
152
170
  if (!pinnedOverrides || Object.keys(pinnedOverrides).length === 0)
@@ -4,6 +4,11 @@ import { V2ContinueWorkflowOutputSchema } from '../../output-schemas.js';
4
4
  import { ResultAsync as RA } from 'neverthrow';
5
5
  import { type ContinueWorkflowError } from '../v2-execution-helpers.js';
6
6
  import * as z from 'zod';
7
+ import type { StepContentEnvelope } from '../../step-content-envelope.js';
8
+ interface ContinueWorkflowResult {
9
+ readonly response: z.infer<typeof V2ContinueWorkflowOutputSchema>;
10
+ readonly contentEnvelope?: StepContentEnvelope;
11
+ }
7
12
  type NextCallTemplate = {
8
13
  readonly tool: 'continue_workflow';
9
14
  readonly params: {
@@ -20,5 +25,5 @@ export declare function buildNextCall(args: {
20
25
  }): NextCallTemplate | null;
21
26
  export declare function handleV2StartWorkflow(input: V2StartWorkflowInput, ctx: ToolContext): Promise<ToolResult<unknown>>;
22
27
  export declare function handleV2ContinueWorkflow(input: V2ContinueWorkflowInput, ctx: ToolContext): Promise<ToolResult<unknown>>;
23
- export declare function executeContinueWorkflow(input: V2ContinueWorkflowInput, ctx: V2ToolContext): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
28
+ export declare function executeContinueWorkflow(input: V2ContinueWorkflowInput, ctx: V2ToolContext): RA<ContinueWorkflowResult, ContinueWorkflowError>;
24
29
  export {};
@@ -15,6 +15,7 @@ const v2_context_budget_js_1 = require("../v2-context-budget.js");
15
15
  const start_js_1 = require("./start.js");
16
16
  const continue_rehydrate_js_1 = require("./continue-rehydrate.js");
17
17
  const continue_advance_js_1 = require("./continue-advance.js");
18
+ const render_envelope_js_1 = require("../../render-envelope.js");
18
19
  function buildNextCall(args) {
19
20
  if (args.isComplete && !args.pending)
20
21
  return null;
@@ -30,13 +31,21 @@ async function handleV2StartWorkflow(input, ctx) {
30
31
  const guard = (0, types_js_1.requireV2Context)(ctx);
31
32
  if (!guard.ok)
32
33
  return guard.error;
33
- return (0, start_js_1.executeStartWorkflow)(input, guard.ctx).match((payload) => (0, types_js_1.success)(payload), (e) => (0, v2_execution_helpers_js_1.mapStartWorkflowErrorToToolError)(e));
34
+ return (0, start_js_1.executeStartWorkflow)(input, guard.ctx).match((result) => (0, types_js_1.success)((0, render_envelope_js_1.attachV2ExecutionRenderMetadata)({
35
+ response: result.response,
36
+ lifecycle: 'start',
37
+ contentEnvelope: result.contentEnvelope,
38
+ })), (e) => (0, v2_execution_helpers_js_1.mapStartWorkflowErrorToToolError)(e));
34
39
  }
35
40
  async function handleV2ContinueWorkflow(input, ctx) {
36
41
  const guard = (0, types_js_1.requireV2Context)(ctx);
37
42
  if (!guard.ok)
38
43
  return guard.error;
39
- return executeContinueWorkflow(input, guard.ctx).match((payload) => (0, types_js_1.success)(payload), (e) => (0, v2_execution_helpers_js_1.mapContinueWorkflowErrorToToolError)(e));
44
+ return executeContinueWorkflow(input, guard.ctx).match((result) => (0, types_js_1.success)((0, render_envelope_js_1.attachV2ExecutionRenderMetadata)({
45
+ response: result.response,
46
+ lifecycle: input.intent === 'rehydrate' ? 'rehydrate' : 'advance',
47
+ contentEnvelope: result.contentEnvelope,
48
+ })), (e) => (0, v2_execution_helpers_js_1.mapContinueWorkflowErrorToToolError)(e));
40
49
  }
41
50
  function classifyToken(raw) {
42
51
  if (raw.startsWith('st_') || raw.startsWith('st1'))
@@ -127,7 +136,8 @@ function executeContinueWorkflow(input, ctx) {
127
136
  sha256,
128
137
  aliasStore: tokenAliasStore,
129
138
  entropy,
130
- }));
139
+ }))
140
+ .map((response) => ({ response }));
131
141
  });
132
142
  }
133
143
  }
@@ -10,12 +10,19 @@ import { type ValidationPipelineDepsPhase1a } from '../../../application/service
10
10
  import { type ObservationEventData } from '../../../v2/durable-core/domain/observation-builder.js';
11
11
  import { type StartWorkflowError } from '../v2-execution-helpers.js';
12
12
  import * as z from 'zod';
13
+ import { type StepContentEnvelope, type ResolvedReference } from '../../step-content-envelope.js';
14
+ export interface StartWorkflowResult {
15
+ readonly response: z.infer<typeof V2StartWorkflowOutputSchema>;
16
+ readonly contentEnvelope: StepContentEnvelope;
17
+ }
13
18
  export declare function loadAndPinWorkflow(args: {
14
19
  readonly workflowId: string;
15
20
  readonly workflowReader: Pick<import('../../../types/storage.js').IWorkflowReader, 'getWorkflowById'>;
16
21
  readonly crypto: Sha256PortV2;
17
22
  readonly pinnedStore: import('../../../v2/ports/pinned-workflow-store.port.js').PinnedWorkflowStorePortV2;
18
23
  readonly validationPipelineDeps: ValidationPipelineDepsPhase1a;
24
+ readonly workspacePath?: string;
25
+ readonly resolvedRootUris?: readonly string[];
19
26
  }): RA<{
20
27
  readonly workflow: import('../../../types/workflow.js').Workflow;
21
28
  readonly workflowHash: WorkflowHash;
@@ -23,6 +30,7 @@ export declare function loadAndPinWorkflow(args: {
23
30
  readonly firstStep: {
24
31
  readonly id: string;
25
32
  };
33
+ readonly resolvedReferences: readonly ResolvedReference[];
26
34
  }, StartWorkflowError>;
27
35
  export declare function buildInitialEvents(args: {
28
36
  readonly sessionId: SessionId;
@@ -51,4 +59,4 @@ export declare function mintStartTokens(args: {
51
59
  readonly continueToken: string;
52
60
  readonly checkpointToken: string;
53
61
  }, StartWorkflowError>;
54
- export declare function executeStartWorkflow(input: import('../../v2/tools.js').V2StartWorkflowInput, ctx: V2ToolContext): RA<z.infer<typeof V2StartWorkflowOutputSchema>, StartWorkflowError>;
62
+ export declare function executeStartWorkflow(input: import('../../v2/tools.js').V2StartWorkflowInput, ctx: V2ToolContext): RA<StartWorkflowResult, StartWorkflowError>;