@exaudeus/workrail 1.5.1 → 1.5.2

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/workflow-compiler.js +14 -2
  2. package/dist/infrastructure/session/HttpServer.js +7 -2
  3. package/dist/infrastructure/session/SessionManager.d.ts +12 -4
  4. package/dist/infrastructure/session/SessionManager.js +30 -15
  5. package/dist/manifest.json +74 -74
  6. package/dist/mcp/error-mapper.d.ts +1 -1
  7. package/dist/mcp/error-mapper.js +12 -8
  8. package/dist/mcp/handler-factory.js +8 -1
  9. package/dist/mcp/handlers/session.js +36 -58
  10. package/dist/mcp/handlers/v2-advance-core/index.js +27 -8
  11. package/dist/mcp/handlers/v2-checkpoint.js +6 -10
  12. package/dist/mcp/handlers/v2-error-mapping.d.ts +3 -3
  13. package/dist/mcp/handlers/v2-error-mapping.js +31 -27
  14. package/dist/mcp/handlers/v2-execution/continue-advance.js +3 -6
  15. package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +0 -1
  16. package/dist/mcp/handlers/v2-execution/index.d.ts +9 -1
  17. package/dist/mcp/handlers/v2-execution/index.js +8 -19
  18. package/dist/mcp/handlers/v2-execution/replay.js +2 -4
  19. package/dist/mcp/handlers/v2-execution/start.d.ts +2 -2
  20. package/dist/mcp/handlers/v2-execution/start.js +0 -19
  21. package/dist/mcp/handlers/v2-execution-helpers.d.ts +3 -2
  22. package/dist/mcp/handlers/v2-execution-helpers.js +34 -59
  23. package/dist/mcp/handlers/v2-workflow.js +13 -18
  24. package/dist/mcp/output-schemas.d.ts +197 -34
  25. package/dist/mcp/output-schemas.js +12 -5
  26. package/dist/mcp/tool-descriptions.js +22 -16
  27. package/dist/mcp/types.d.ts +10 -0
  28. package/dist/mcp/types.js +10 -0
  29. package/dist/mcp/v2/tools.d.ts +45 -7
  30. package/dist/mcp/v2/tools.js +7 -3
  31. package/dist/types/workflow-definition.d.ts +3 -2
  32. package/dist/v2/durable-core/canonical/jcs.js +8 -1
  33. package/dist/v2/durable-core/domain/ack-advance-append-plan.d.ts +1 -10
  34. package/dist/v2/durable-core/domain/ack-advance-append-plan.js +8 -28
  35. package/dist/v2/durable-core/domain/blocked-node-builder.js +1 -1
  36. package/dist/v2/durable-core/schemas/artifacts/loop-control.d.ts +6 -6
  37. package/dist/v2/durable-core/schemas/execution-snapshot/blocked-snapshot.d.ts +4 -4
  38. package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.d.ts +116 -116
  39. package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +184 -184
  40. package/dist/v2/durable-core/schemas/session/dag-topology.d.ts +2 -2
  41. package/dist/v2/durable-core/schemas/session/events.d.ts +20 -20
  42. package/package.json +1 -1
  43. package/workflows/coding-task-workflow-agentic.json +0 -9
  44. package/workflows/workflow-for-workflows.json +18 -5
@@ -22,6 +22,13 @@ let WorkflowCompiler = class WorkflowCompiler {
22
22
  }
23
23
  stepById.set(step.id, step);
24
24
  }
25
+ for (const step of steps) {
26
+ const contractRef = step.outputContract?.contractRef;
27
+ if (contractRef && !(0, index_1.isValidContractRef)(contractRef)) {
28
+ return (0, neverthrow_1.err)(error_1.Err.invalidState(`Step '${step.id}' declares unknown outputContract.contractRef '${contractRef}'. ` +
29
+ `Known contracts: ${index_1.LOOP_CONTROL_CONTRACT_REF}`));
30
+ }
31
+ }
25
32
  const compiledLoops = new Map();
26
33
  const loopBodyStepIds = new Set();
27
34
  for (const step of steps) {
@@ -33,6 +40,11 @@ let WorkflowCompiler = class WorkflowCompiler {
33
40
  return (0, neverthrow_1.err)(bodyResolved.error);
34
41
  for (const bodyStep of bodyResolved.value) {
35
42
  loopBodyStepIds.add(bodyStep.id);
43
+ const ref = bodyStep.outputContract?.contractRef;
44
+ if (ref && !(0, index_1.isValidContractRef)(ref)) {
45
+ return (0, neverthrow_1.err)(error_1.Err.invalidState(`Loop body step '${bodyStep.id}' in loop '${loop.id}' declares unknown outputContract.contractRef '${ref}'. ` +
46
+ `Known contracts: ${index_1.LOOP_CONTROL_CONTRACT_REF}`));
47
+ }
36
48
  }
37
49
  const conditionSource = this.deriveConditionSource(loop, bodyResolved.value);
38
50
  compiledLoops.set(loop.id, {
@@ -56,8 +68,8 @@ let WorkflowCompiler = class WorkflowCompiler {
56
68
  if (loop.loop.conditionSource) {
57
69
  return loop.loop.conditionSource;
58
70
  }
59
- const hasLoopControlContract = bodySteps.some((s) => s.outputContract?.contractRef === index_1.LOOP_CONTROL_CONTRACT_REF);
60
- if (hasLoopControlContract) {
71
+ const loopControlStep = bodySteps.find((s) => s.outputContract?.contractRef === index_1.LOOP_CONTROL_CONTRACT_REF);
72
+ if (loopControlStep) {
61
73
  return {
62
74
  kind: 'artifact_contract',
63
75
  contractRef: index_1.LOOP_CONTROL_CONTRACT_REF,
@@ -283,7 +283,12 @@ let HttpServer = class HttpServer {
283
283
  this.app.delete('/api/sessions/:workflow/:id', async (req, res) => {
284
284
  try {
285
285
  const { workflow, id } = req.params;
286
- await this.sessionManager.deleteSession(workflow, id);
286
+ const result = await this.sessionManager.deleteSession(workflow, id);
287
+ if (result.isErr()) {
288
+ const status = result.error.code === 'SESSION_NOT_FOUND' ? 404 : 500;
289
+ res.status(status).json({ success: false, error: result.error.message });
290
+ return;
291
+ }
287
292
  res.json({
288
293
  success: true,
289
294
  message: `Session ${workflow}/${id} deleted successfully`
@@ -291,7 +296,7 @@ let HttpServer = class HttpServer {
291
296
  }
292
297
  catch (error) {
293
298
  console.error('[HttpServer] Delete session error:', error);
294
- res.status(error.message?.includes('not found') ? 404 : 500).json({
299
+ res.status(500).json({
295
300
  success: false,
296
301
  error: error.message || 'Failed to delete session'
297
302
  });
@@ -1,6 +1,14 @@
1
1
  import { EventEmitter } from 'events';
2
+ import { type Result } from 'neverthrow';
2
3
  import { SessionDataNormalizer } from './SessionDataNormalizer';
3
4
  import { SessionDataValidator } from './SessionDataValidator';
5
+ export type SessionManagerError = {
6
+ readonly code: 'SESSION_NOT_FOUND';
7
+ readonly message: string;
8
+ } | {
9
+ readonly code: 'IO_ERROR';
10
+ readonly message: string;
11
+ };
4
12
  export interface Session {
5
13
  id: string;
6
14
  workflowId: string;
@@ -30,10 +38,10 @@ export declare class SessionManager extends EventEmitter {
30
38
  private findGitRepoRoot;
31
39
  private getProjectRoot;
32
40
  getSessionPath(workflowId: string, sessionId: string): string;
33
- createSession(workflowId: string, sessionId: string, initialData?: Record<string, any>): Promise<Session>;
34
- updateSession(workflowId: string, sessionId: string, updates: Record<string, any>): Promise<Session>;
35
- readSession(workflowId: string, sessionId: string, queryPath?: string): Promise<any>;
36
- deleteSession(workflowId: string, sessionId: string): Promise<void>;
41
+ createSession(workflowId: string, sessionId: string, initialData?: Record<string, any>): Promise<Result<Session, SessionManagerError>>;
42
+ updateSession(workflowId: string, sessionId: string, updates: Record<string, any>): Promise<Result<Session, SessionManagerError>>;
43
+ readSession(workflowId: string, sessionId: string, queryPath?: string): Promise<Result<unknown, SessionManagerError>>;
44
+ deleteSession(workflowId: string, sessionId: string): Promise<Result<void, SessionManagerError>>;
37
45
  deleteSessions(sessions: Array<{
38
46
  workflowId: string;
39
47
  sessionId: string;
@@ -24,6 +24,7 @@ const child_process_1 = require("child_process");
24
24
  const os_1 = __importDefault(require("os"));
25
25
  const events_1 = require("events");
26
26
  const tsyringe_1 = require("tsyringe");
27
+ const neverthrow_1 = require("neverthrow");
27
28
  const tokens_js_1 = require("../../di/tokens.js");
28
29
  const SessionDataNormalizer_1 = require("./SessionDataNormalizer");
29
30
  const SessionDataValidator_1 = require("./SessionDataValidator");
@@ -76,7 +77,12 @@ let SessionManager = class SessionManager extends events_1.EventEmitter {
76
77
  }
77
78
  async createSession(workflowId, sessionId, initialData = {}) {
78
79
  const sessionPath = this.getSessionPath(workflowId, sessionId);
79
- await promises_1.default.mkdir(path_1.default.dirname(sessionPath), { recursive: true });
80
+ try {
81
+ await promises_1.default.mkdir(path_1.default.dirname(sessionPath), { recursive: true });
82
+ }
83
+ catch (e) {
84
+ return (0, neverthrow_1.err)({ code: 'IO_ERROR', message: `Failed to create session directory: ${e instanceof Error ? e.message : String(e)}` });
85
+ }
80
86
  const session = {
81
87
  id: sessionId,
82
88
  workflowId,
@@ -86,15 +92,20 @@ let SessionManager = class SessionManager extends events_1.EventEmitter {
86
92
  updatedAt: new Date().toISOString(),
87
93
  data: initialData
88
94
  };
89
- await this.atomicWrite(sessionPath, session);
95
+ try {
96
+ await this.atomicWrite(sessionPath, session);
97
+ }
98
+ catch (e) {
99
+ return (0, neverthrow_1.err)({ code: 'IO_ERROR', message: `Failed to write session: ${e instanceof Error ? e.message : String(e)}` });
100
+ }
90
101
  await this.updateProjectMetadata();
91
- return session;
102
+ return (0, neverthrow_1.ok)(session);
92
103
  }
93
104
  async updateSession(workflowId, sessionId, updates) {
94
105
  const sessionPath = this.getSessionPath(workflowId, sessionId);
95
106
  const session = await this.getSession(workflowId, sessionId);
96
107
  if (!session) {
97
- throw new Error(`Session not found: ${workflowId}/${sessionId}`);
108
+ return (0, neverthrow_1.err)({ code: 'SESSION_NOT_FOUND', message: `Session not found: ${workflowId}/${sessionId}` });
98
109
  }
99
110
  const mergedData = this.deepMerge(session.data, updates);
100
111
  const normalizedData = this.normalizer.normalize(workflowId, mergedData);
@@ -104,36 +115,40 @@ let SessionManager = class SessionManager extends events_1.EventEmitter {
104
115
  }
105
116
  session.data = normalizedData;
106
117
  session.updatedAt = new Date().toISOString();
107
- await this.atomicWrite(sessionPath, session);
108
- return session;
118
+ try {
119
+ await this.atomicWrite(sessionPath, session);
120
+ }
121
+ catch (e) {
122
+ return (0, neverthrow_1.err)({ code: 'IO_ERROR', message: `Failed to write session: ${e instanceof Error ? e.message : String(e)}` });
123
+ }
124
+ return (0, neverthrow_1.ok)(session);
109
125
  }
110
126
  async readSession(workflowId, sessionId, queryPath) {
111
127
  const session = await this.getSession(workflowId, sessionId);
112
128
  if (!session) {
113
- throw new Error(`Session not found: ${workflowId}/${sessionId}`);
129
+ return (0, neverthrow_1.err)({ code: 'SESSION_NOT_FOUND', message: `Session not found: ${workflowId}/${sessionId}` });
114
130
  }
115
131
  if (!queryPath) {
116
- return session.data;
132
+ return (0, neverthrow_1.ok)(session.data);
117
133
  }
118
- return this.getPath(session.data, queryPath);
134
+ return (0, neverthrow_1.ok)(this.getPath(session.data, queryPath));
119
135
  }
120
136
  async deleteSession(workflowId, sessionId) {
121
137
  const sessionPath = this.getSessionPath(workflowId, sessionId);
122
138
  const exists = await promises_1.default.access(sessionPath).then(() => true).catch(() => false);
123
139
  if (!exists) {
124
- throw new Error(`Session not found: ${workflowId}/${sessionId}`);
140
+ return (0, neverthrow_1.err)({ code: 'SESSION_NOT_FOUND', message: `Session not found: ${workflowId}/${sessionId}` });
125
141
  }
126
142
  this.unwatchSession(workflowId, sessionId);
127
143
  await promises_1.default.unlink(sessionPath);
128
144
  await this.updateProjectMetadata();
145
+ return (0, neverthrow_1.ok)(undefined);
129
146
  }
130
147
  async deleteSessions(sessions) {
131
148
  for (const { workflowId, sessionId } of sessions) {
132
- try {
133
- await this.deleteSession(workflowId, sessionId);
134
- }
135
- catch (error) {
136
- console.error(`Failed to delete ${workflowId}/${sessionId}:`, error);
149
+ const res = await this.deleteSession(workflowId, sessionId);
150
+ if (res.isErr()) {
151
+ console.error(`Failed to delete ${workflowId}/${sessionId}:`, res.error.message);
137
152
  }
138
153
  }
139
154
  }
@@ -46,8 +46,8 @@
46
46
  "bytes": 990
47
47
  },
48
48
  "application/services/workflow-compiler.js": {
49
- "sha256": "1df9fc317ad765d011a57b7995351e6a308f26d7cac17bb91f42a351b1cabc2c",
50
- "bytes": 4703
49
+ "sha256": "f865278e4242867dfd9b679e489d8f2de89f46b578f586a80fc5490ab6c65cdb",
50
+ "bytes": 5550
51
51
  },
52
52
  "application/services/workflow-interpreter.d.ts": {
53
53
  "sha256": "56b5b5ad06d42096deba9f0abe7642c18a355a1e598749aab1730df4e9847674",
@@ -390,8 +390,8 @@
390
390
  "bytes": 1852
391
391
  },
392
392
  "infrastructure/session/HttpServer.js": {
393
- "sha256": "451db710b31e8de848f95383ca6964de2edc3c79063cb464d7b2de1e855c4c01",
394
- "bytes": 32208
393
+ "sha256": "76508602e5d7ee9337ff64c7dffa5153347ef754e1252d191b4ee6243ea24f1b",
394
+ "bytes": 32446
395
395
  },
396
396
  "infrastructure/session/SessionDataNormalizer.d.ts": {
397
397
  "sha256": "c89bb5e00d7d01fb4aa6d0095602541de53c425c6b99b67fa8367eb29cb63e9e",
@@ -410,12 +410,12 @@
410
410
  "bytes": 11512
411
411
  },
412
412
  "infrastructure/session/SessionManager.d.ts": {
413
- "sha256": "05632114129307891d08ca0a8ca2273732cfe29c0cefd8dcfca9a295b1f62345",
414
- "bytes": 2186
413
+ "sha256": "b3a3b4b6b44425204a6a20928132978f998219f99dab70491c017fae10c7d479",
414
+ "bytes": 2524
415
415
  },
416
416
  "infrastructure/session/SessionManager.js": {
417
- "sha256": "764033447b9ca2cb5d0eb91143b906519bee012f98ff2141b1e9bfc4d7c5d070",
418
- "bytes": 20154
417
+ "sha256": "7044259c881b35c72ccbfece31be867eb5315df1384417924ac49d4cee11aee6",
418
+ "bytes": 21110
419
419
  },
420
420
  "infrastructure/session/index.d.ts": {
421
421
  "sha256": "52957847da70fcece6a553334bd899efd8ede55cc31f3aa5eb5e3d4bb70e3862",
@@ -514,28 +514,28 @@
514
514
  "bytes": 476
515
515
  },
516
516
  "mcp/error-mapper.d.ts": {
517
- "sha256": "9ed8afa42fd432ab9bdf781c90ec157eb51ef03e2b17afbb74ad54b91e5bae8a",
518
- "bytes": 267
517
+ "sha256": "c6e9db65c565063726442b73a4a0cf1a1c07d54c778a85cf0122c4c04ea6a5a9",
518
+ "bytes": 268
519
519
  },
520
520
  "mcp/error-mapper.js": {
521
- "sha256": "1437bf9380090920512565c0d685a268af29d8b7e747eff62904e1090e69c854",
522
- "bytes": 3735
521
+ "sha256": "582411de477df432854cf31ded65b80f1d9f5673d0e06cc7660ac25aa834b736",
522
+ "bytes": 3982
523
523
  },
524
524
  "mcp/handler-factory.d.ts": {
525
525
  "sha256": "fad8fff32776b2fe7182708ce0e821c2434fdfce7191390bb9cfaf16a7d31a60",
526
526
  "bytes": 796
527
527
  },
528
528
  "mcp/handler-factory.js": {
529
- "sha256": "cfdb8853f1e1a9529899852e4e25b027779647f1f94d3db931f4439052a0b607",
530
- "bytes": 2875
529
+ "sha256": "fca1b2d87d7d0961bc0c3ec337d5c18ffe8a379964af3836b1ac532bab1195ea",
530
+ "bytes": 3382
531
531
  },
532
532
  "mcp/handlers/session.d.ts": {
533
533
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
534
534
  "bytes": 1394
535
535
  },
536
536
  "mcp/handlers/session.js": {
537
- "sha256": "4955f0b09766426318f5d21ab3bd8967b11666830000504e44ef3b94beb526ee",
538
- "bytes": 6622
537
+ "sha256": "83c9585400cc7c20cac3691b8771b9ce8cdc508ba7f5d083a96f7ed975aabc05",
538
+ "bytes": 5967
539
539
  },
540
540
  "mcp/handlers/shared/with-timeout.d.ts": {
541
541
  "sha256": "31ca3db008cb5cd439e0d1132bc4b29be0900c403c452931e3a24a50e45beb54",
@@ -566,8 +566,8 @@
566
566
  "bytes": 3500
567
567
  },
568
568
  "mcp/handlers/v2-advance-core/index.js": {
569
- "sha256": "5ead85dbaf573011568ec1dc826be97c482b43a70a6a7ed724cd767e9a9deeb4",
570
- "bytes": 5487
569
+ "sha256": "056de2680358ac496e82619a921a9f6403e51e2f8f1e4fdf0e7acd0da1136bab",
570
+ "bytes": 6974
571
571
  },
572
572
  "mcp/handlers/v2-advance-core/input-validation.d.ts": {
573
573
  "sha256": "a7b5d0e80eaea2cc500cd576bd1ae25d1c5521dcef76011bd052bf6cf6cf574b",
@@ -606,8 +606,8 @@
606
606
  "bytes": 259
607
607
  },
608
608
  "mcp/handlers/v2-checkpoint.js": {
609
- "sha256": "db8702a5d6ccd6103780dea96d9983e3c17ef74cb63cdbdac97fff77091a39e1",
610
- "bytes": 9289
609
+ "sha256": "24b7aaf920fd2c5e4ec801ab9c0f3f7d93aa8280c05b851f12e57343d352a4ec",
610
+ "bytes": 9196
611
611
  },
612
612
  "mcp/handlers/v2-context-budget.d.ts": {
613
613
  "sha256": "cbad1741a183d52c9cbe558be2e09f776843d1f3ec8cd28d6d0d230668e4298c",
@@ -618,20 +618,20 @@
618
618
  "bytes": 7173
619
619
  },
620
620
  "mcp/handlers/v2-error-mapping.d.ts": {
621
- "sha256": "b0f426e2ea4c25caa19fb72ea8c5c65590be01da6bb6678b1236b4333c66ad09",
622
- "bytes": 1707
621
+ "sha256": "bbaf580dfc22ca6b5ef1d57036fb549c640d6f37bd7d525f1a805b4d14c4d75c",
622
+ "bytes": 1711
623
623
  },
624
624
  "mcp/handlers/v2-error-mapping.js": {
625
- "sha256": "f0b848f39c69128504cca4c157d44ae8e79b68edd4624ee12e1bce657237b1f8",
626
- "bytes": 6808
625
+ "sha256": "95dff130804524a007e1071784c20897ba6af1cc04fb2a636741e261fa22c3f8",
626
+ "bytes": 10388
627
627
  },
628
628
  "mcp/handlers/v2-execution-helpers.d.ts": {
629
- "sha256": "9ff56752113e6ed25c672b813810cc14ed6d28831863804897d886e64d81d33a",
630
- "bytes": 5616
629
+ "sha256": "1e52f266e991a9447d1254bf047f6a09062b038ed3363a3818d1f5c91eed2fc8",
630
+ "bytes": 5712
631
631
  },
632
632
  "mcp/handlers/v2-execution-helpers.js": {
633
- "sha256": "980637d9955bcecb0c056e3eab76aba18d1956a72b52229c8a82149675f1e9e6",
634
- "bytes": 16266
633
+ "sha256": "9ac62b0d64ea10a89b18e79a01b1f5b05d35e40eddcb7a9f93a3bcbe737e85b3",
634
+ "bytes": 18751
635
635
  },
636
636
  "mcp/handlers/v2-execution.d.ts": {
637
637
  "sha256": "f76cd1bb6a6e25c5a37a1f5b01b1046f4afd41162b620f3be3861509e1fcd1d3",
@@ -654,40 +654,40 @@
654
654
  "bytes": 1830
655
655
  },
656
656
  "mcp/handlers/v2-execution/continue-advance.js": {
657
- "sha256": "259e2b631c585b171d84c3b235e87621889eb9b213f0d28bbc5f7f6019d7673d",
658
- "bytes": 8251
657
+ "sha256": "bfbc14690fe08f51c5e1e2124e5561e9a093806e511803d68e4a2d22b5918919",
658
+ "bytes": 7927
659
659
  },
660
660
  "mcp/handlers/v2-execution/continue-rehydrate.d.ts": {
661
661
  "sha256": "af7475b7effe57f18fa8379bfd128d17afb2d27fe1c058c6f2ee8f5b2632e3d0",
662
662
  "bytes": 1312
663
663
  },
664
664
  "mcp/handlers/v2-execution/continue-rehydrate.js": {
665
- "sha256": "52de5f0dd7b366a36b68b487119a43dc6c5581c5d4ea5304cc6530052a334973",
666
- "bytes": 8675
665
+ "sha256": "b77850715f6d4300a5b9b7b86063a02eed0e63410bdf6b1572bdae3d40b8a32f",
666
+ "bytes": 8585
667
667
  },
668
668
  "mcp/handlers/v2-execution/index.d.ts": {
669
- "sha256": "b6ed1b40a7bfd7ea01aa20d9f20defa9394cfda03aff3554da308fdfd5ab3397",
670
- "bytes": 950
669
+ "sha256": "481d74c4ab444964ac9c71e0348da91abd642352a6fc1c69cff70e300d76881e",
670
+ "bytes": 1185
671
671
  },
672
672
  "mcp/handlers/v2-execution/index.js": {
673
- "sha256": "5ef4e95b9789a6f0f2085417c34186902f576393baa4ab35b20833e1d261d366",
674
- "bytes": 5303
673
+ "sha256": "bc131f6e61d85dd46cf500dab4b6a5865180186f2361205d108e57d05e29ebfe",
674
+ "bytes": 4716
675
675
  },
676
676
  "mcp/handlers/v2-execution/replay.d.ts": {
677
677
  "sha256": "7a8a9c7993a86fae086510c63e70eb4556aff9af978ac5e10733358698e14097",
678
678
  "bytes": 2869
679
679
  },
680
680
  "mcp/handlers/v2-execution/replay.js": {
681
- "sha256": "9d22e419d84f0961cdeb1ca076ab66c7a0e619043f2b560d4b6581b70054df29",
682
- "bytes": 12181
681
+ "sha256": "49b84755c42e40b23a0434cc97f0b4abeff4e46ae6a85c4b0363bd39018c7ea1",
682
+ "bytes": 11969
683
683
  },
684
684
  "mcp/handlers/v2-execution/start.d.ts": {
685
- "sha256": "ab18fa2d8382e31bab816ddc981f721b76a592dadd724756d27cdd71286eb0d8",
686
- "bytes": 2785
685
+ "sha256": "59de3fb71608b19e6a81a63ff3c74f9be92b90c8e07817e9248e3ee7e4654367",
686
+ "bytes": 2789
687
687
  },
688
688
  "mcp/handlers/v2-execution/start.js": {
689
- "sha256": "667ba0dec1154018b15f64a9b3be19815457bab674014e0879e772e523be4df9",
690
- "bytes": 15986
689
+ "sha256": "6d6763c4cae68d573d228826af6826e830ce70d016772c74d4780207807b1928",
690
+ "bytes": 15078
691
691
  },
692
692
  "mcp/handlers/v2-resume.d.ts": {
693
693
  "sha256": "d88f6c35bcaf946666c837b72fda3702a2ebab5e478eb90f7b4b672a0e5fa24f",
@@ -718,8 +718,8 @@
718
718
  "bytes": 397
719
719
  },
720
720
  "mcp/handlers/v2-workflow.js": {
721
- "sha256": "ca2c4a36299d425e788eef4af042099eef7bf62d0ff8fc2a7308723a9a99f205",
722
- "bytes": 5522
721
+ "sha256": "bed0ffc401958c14343158e142e4be344bad49cabc95f99a811d872bc76989a7",
722
+ "bytes": 6027
723
723
  },
724
724
  "mcp/handlers/workflow.d.ts": {
725
725
  "sha256": "050565039a20af3f7fc8311337ff4547438ecc59433e5744aacce8f203326774",
@@ -738,12 +738,12 @@
738
738
  "bytes": 7535
739
739
  },
740
740
  "mcp/output-schemas.d.ts": {
741
- "sha256": "f18366a180449212d9a2b280dc9706f4f96a77ccead38bf11035c3859121fd84",
742
- "bytes": 45137
741
+ "sha256": "85bc8019547bbee11374a09344489f9dd99703782e5f3822497193b09dbfba1f",
742
+ "bytes": 49826
743
743
  },
744
744
  "mcp/output-schemas.js": {
745
- "sha256": "e7aeb43d06950e4a9ed1fa4ecd56418dc7eb32f54453634701b5dc39456eb3e8",
746
- "bytes": 11565
745
+ "sha256": "05fe0824c55da5fdadfc92a0bcaaf95f998ba3fbaedae5a27370ceba53e3dc6e",
746
+ "bytes": 12015
747
747
  },
748
748
  "mcp/server.d.ts": {
749
749
  "sha256": "bec49b8d07e189a53db7100d2f0e1e84ffe03150f04e1b06908ee3282982b4a2",
@@ -766,8 +766,8 @@
766
766
  "bytes": 132
767
767
  },
768
768
  "mcp/tool-descriptions.js": {
769
- "sha256": "76d25a3a2bba38227ad199c4d1240769b6b14411ebecf965e9e00eaac2f2e01c",
770
- "bytes": 16389
769
+ "sha256": "a14ecf27cea136307d6016862f6897d1ba776f51f713e8c9cc65281f4ab7be4e",
770
+ "bytes": 16654
771
771
  },
772
772
  "mcp/tool-factory.d.ts": {
773
773
  "sha256": "0fe3c6b863b2d7aef0c3d659ff54f3a9ee8a0a3c2005b6565d2f8ad517bc7211",
@@ -786,12 +786,12 @@
786
786
  "bytes": 8360
787
787
  },
788
788
  "mcp/types.d.ts": {
789
- "sha256": "564136878ad3e71300d5e82913590b1f43d3dfbafab36479c9a590853cd07a0a",
790
- "bytes": 4050
789
+ "sha256": "ce700982b88189f08c466384b4357b3345ec0ccb6842ff97a0831c2281185c6c",
790
+ "bytes": 4284
791
791
  },
792
792
  "mcp/types.js": {
793
- "sha256": "0c12576fd0053115ff096fe26b38f77f1e830b7ec4781aaf94564827c4c9e81a",
794
- "bytes": 1253
793
+ "sha256": "d10c4070e4c3454d80f0fa9cdc0e978c69c53c13fd09baa8710fcd802fed8926",
794
+ "bytes": 1608
795
795
  },
796
796
  "mcp/types/tool-description-types.d.ts": {
797
797
  "sha256": "80984afa5283a0d651ff22c0c9b2d3ff14c85087aeaf735d306ae291d8cdfe4d",
@@ -826,12 +826,12 @@
826
826
  "bytes": 3078
827
827
  },
828
828
  "mcp/v2/tools.d.ts": {
829
- "sha256": "5da50237fcbce6240737441d134c8070256a23649b387d5c3438b41b2705905e",
830
- "bytes": 4156
829
+ "sha256": "a6fc8e1feb02807a4f7984dcd00358081a4b63b6b9ec9b88bb2bff833c280322",
830
+ "bytes": 5172
831
831
  },
832
832
  "mcp/v2/tools.js": {
833
- "sha256": "5c9b958f1a9eb609557ed5867fc9ea131a2a0a4aaf52ff05a38246dffe2b359d",
834
- "bytes": 6435
833
+ "sha256": "7460146a5d0d3a0f67d4d42e512d467455169d22bb99f69ad812848da862b8a4",
834
+ "bytes": 6721
835
835
  },
836
836
  "mcp/validation/bounded-json.d.ts": {
837
837
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -1042,8 +1042,8 @@
1042
1042
  "bytes": 395
1043
1043
  },
1044
1044
  "types/workflow-definition.d.ts": {
1045
- "sha256": "323b388a894c39a1718743a92aee3e2ff941a48325e352f2df690bf93a3e018b",
1046
- "bytes": 3463
1045
+ "sha256": "719bd8abe73b4377ba9a23c60d9fbdef170b193b8a3c46d6ddc6bc49cb65e8d2",
1046
+ "bytes": 3576
1047
1047
  },
1048
1048
  "types/workflow-definition.js": {
1049
1049
  "sha256": "e269d62f27b7f37f870183d6b77800b7aa1e22dabc894374bab8f34db049a55b",
@@ -1126,8 +1126,8 @@
1126
1126
  "bytes": 465
1127
1127
  },
1128
1128
  "v2/durable-core/canonical/jcs.js": {
1129
- "sha256": "0611bbe61a30d96c2d18d166383eb9ecd49ede0d66814fcb65ebf2df40eaa23c",
1130
- "bytes": 2338
1129
+ "sha256": "31dd493338681e305793ceaf4f7de58d60818310b9f3ddff72637c5120ecd9fa",
1130
+ "bytes": 2517
1131
1131
  },
1132
1132
  "v2/durable-core/canonical/json-types.d.ts": {
1133
1133
  "sha256": "6267cfbe4798d6117ed30ef69365e28d85fb6ba1464c1c8313db83a7bf56a4fc",
@@ -1162,12 +1162,12 @@
1162
1162
  "bytes": 3453
1163
1163
  },
1164
1164
  "v2/durable-core/domain/ack-advance-append-plan.d.ts": {
1165
- "sha256": "957549bbdeec71cc36fee8e39ed3aca33c6e8110856d43f16ec3f4e4cfb28325",
1166
- "bytes": 1745
1165
+ "sha256": "2e802606656a0c1938192e5533aa46c74bc42789b5c315c79f6de4850017b30e",
1166
+ "bytes": 1533
1167
1167
  },
1168
1168
  "v2/durable-core/domain/ack-advance-append-plan.js": {
1169
- "sha256": "362bff69902fe67393c64001c175c7f38560277132320cfcc5d711f08b2d5920",
1170
- "bytes": 7853
1169
+ "sha256": "ae08bded7edd323b817711946dd27a9ba51047ef41248ad10e098d69d5c3015d",
1170
+ "bytes": 6839
1171
1171
  },
1172
1172
  "v2/durable-core/domain/artifact-contract-validator.d.ts": {
1173
1173
  "sha256": "262d667fb49fc68a5a6db9f60d4a50c15b9e45ba9ef5980d5b2036a29582eac8",
@@ -1182,8 +1182,8 @@
1182
1182
  "bytes": 880
1183
1183
  },
1184
1184
  "v2/durable-core/domain/blocked-node-builder.js": {
1185
- "sha256": "e07b0fee68be1b9ce653f990cbe0dfde767765915c093a540a53448ceb0aa3fd",
1186
- "bytes": 4011
1185
+ "sha256": "3bd568ec217fb79e8e7ebfd5b7a8474a81f06caf58aceccad9ce3c46c9a06fec",
1186
+ "bytes": 4008
1187
1187
  },
1188
1188
  "v2/durable-core/domain/blocking-decision.d.ts": {
1189
1189
  "sha256": "dd32c4354dd710f94629833e91c5f83cd316212116d63fac1305d7336d4ce353",
@@ -1466,7 +1466,7 @@
1466
1466
  "bytes": 1728
1467
1467
  },
1468
1468
  "v2/durable-core/schemas/artifacts/loop-control.d.ts": {
1469
- "sha256": "0da9cbedb121753826c6e3f157a4feff1895fcc60b67527e484882ac37ce3eaa",
1469
+ "sha256": "2575028ca2f52f4562857edd76696f6a6cd57f7aaa916346b00c76f62fdec498",
1470
1470
  "bytes": 2743
1471
1471
  },
1472
1472
  "v2/durable-core/schemas/artifacts/loop-control.js": {
@@ -1482,7 +1482,7 @@
1482
1482
  "bytes": 1350
1483
1483
  },
1484
1484
  "v2/durable-core/schemas/execution-snapshot/blocked-snapshot.d.ts": {
1485
- "sha256": "63e6bdb43c77740935fb8bf49dfd96d5d783a01ae5ce61c0d0f9d61df8e838f6",
1485
+ "sha256": "62fbdd2d901f8338942908bbdef575f871279501ba76b819a7750fe38c1f7976",
1486
1486
  "bytes": 23179
1487
1487
  },
1488
1488
  "v2/durable-core/schemas/execution-snapshot/blocked-snapshot.js": {
@@ -1490,7 +1490,7 @@
1490
1490
  "bytes": 4364
1491
1491
  },
1492
1492
  "v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.d.ts": {
1493
- "sha256": "1515649328e6a00fe00053b7fc5aaa5a6dfa325e8c1ea54e99cd44fc54c73280",
1493
+ "sha256": "675f92a72f254f6e737fe86e4fb8e8ab75405507ea5e691fa78c9cf487552b20",
1494
1494
  "bytes": 186498
1495
1495
  },
1496
1496
  "v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.js": {
@@ -1514,7 +1514,7 @@
1514
1514
  "bytes": 2983
1515
1515
  },
1516
1516
  "v2/durable-core/schemas/export-bundle/index.d.ts": {
1517
- "sha256": "856a1e4bcaa17ceb03bdd227b6007fac5221bd7063e0cd83a4eaddb43b1d3523",
1517
+ "sha256": "3b922ab53a8cf1c5cc0968f1409aae87b5782b01ab19f74fcb25fef9286cc36a",
1518
1518
  "bytes": 466802
1519
1519
  },
1520
1520
  "v2/durable-core/schemas/export-bundle/index.js": {
@@ -1562,7 +1562,7 @@
1562
1562
  "bytes": 3396
1563
1563
  },
1564
1564
  "v2/durable-core/schemas/session/dag-topology.d.ts": {
1565
- "sha256": "c8affdc4152be2a6f27b8a1dd06b9262d93b69e345aa82e694a425c76a7b2d45",
1565
+ "sha256": "67fc952e5af8f364764996c62a685bf9db8e7d73727f639cbf87cb1b4f5d8dd6",
1566
1566
  "bytes": 3018
1567
1567
  },
1568
1568
  "v2/durable-core/schemas/session/dag-topology.js": {
@@ -1570,7 +1570,7 @@
1570
1570
  "bytes": 2138
1571
1571
  },
1572
1572
  "v2/durable-core/schemas/session/events.d.ts": {
1573
- "sha256": "004bbfe44da4ec264aea85d68f3a078d11d805f3507a6fce07b4092cb44a1a70",
1573
+ "sha256": "d3d4d17bf02181c51655c1c4835e2d4945c4f2903e89991b911bc3f445220b86",
1574
1574
  "bytes": 72218
1575
1575
  },
1576
1576
  "v2/durable-core/schemas/session/events.js": {
@@ -1,4 +1,4 @@
1
1
  import type { DomainError } from '../domain/execution/error.js';
2
2
  import type { ToolError } from './types.js';
3
3
  export declare function mapDomainErrorToToolError(err: DomainError): ToolError;
4
- export declare function mapUnknownErrorToToolError(err: unknown): ToolError;
4
+ export declare function mapUnknownErrorToToolError(_err: unknown): ToolError;
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapDomainErrorToToolError = mapDomainErrorToToolError;
4
4
  exports.mapUnknownErrorToToolError = mapUnknownErrorToToolError;
5
5
  const bounded_json_js_1 = require("./validation/bounded-json.js");
6
- function assertNever(x) {
6
+ const v2_execution_helpers_js_1 = require("./handlers/v2-execution-helpers.js");
7
+ function assertNever(_x) {
7
8
  return {
8
9
  type: 'error',
9
10
  code: 'INTERNAL_ERROR',
10
- message: `Unhandled DomainError variant: ${JSON.stringify(x)}`,
11
+ message: 'WorkRail encountered an unexpected error. This is not caused by your input.',
11
12
  retry: { kind: 'not_retryable' },
12
- details: { invariantViolation: 'exhaustiveness_check_failed' },
13
+ details: { suggestion: (0, v2_execution_helpers_js_1.internalSuggestion)('', 'WorkRail has an internal error.') },
13
14
  };
14
15
  }
15
16
  function mapDomainErrorToToolError(err) {
@@ -80,9 +81,12 @@ function mapDomainErrorToToolError(err) {
80
81
  return assertNever(err);
81
82
  }
82
83
  }
83
- function mapUnknownErrorToToolError(err) {
84
- if (err instanceof Error) {
85
- return { type: 'error', code: 'INTERNAL_ERROR', message: err.message, retry: { kind: 'not_retryable' } };
86
- }
87
- return { type: 'error', code: 'INTERNAL_ERROR', message: String(err), retry: { kind: 'not_retryable' } };
84
+ function mapUnknownErrorToToolError(_err) {
85
+ return {
86
+ type: 'error',
87
+ code: 'INTERNAL_ERROR',
88
+ message: 'WorkRail encountered an unexpected error. This is not caused by your input.',
89
+ retry: { kind: 'not_retryable' },
90
+ details: { suggestion: (0, v2_execution_helpers_js_1.internalSuggestion)('Retry the call.', 'WorkRail has an internal error.') },
91
+ };
88
92
  }
@@ -6,6 +6,7 @@ exports.createValidatingHandler = createValidatingHandler;
6
6
  const types_js_1 = require("./types.js");
7
7
  const index_js_1 = require("./validation/index.js");
8
8
  const bounded_json_js_1 = require("./validation/bounded-json.js");
9
+ const v2_execution_helpers_js_1 = require("./handlers/v2-execution-helpers.js");
9
10
  function toMcpResult(result) {
10
11
  switch (result.type) {
11
12
  case 'success':
@@ -41,7 +42,13 @@ function createHandler(schema, handler) {
41
42
  ...suggestionDetails,
42
43
  }));
43
44
  }
44
- return toMcpResult(await handler(parseResult.data, ctx));
45
+ try {
46
+ return toMcpResult(await handler(parseResult.data, ctx));
47
+ }
48
+ catch (err) {
49
+ console.error('[WorkRail] Unhandled exception in tool handler:', err);
50
+ return toMcpResult((0, types_js_1.errNotRetryable)('INTERNAL_ERROR', 'WorkRail encountered an unexpected error. This is not caused by your input.', { suggestion: (0, v2_execution_helpers_js_1.internalSuggestion)('Retry the call.', 'WorkRail has an internal error.') }));
51
+ }
45
52
  };
46
53
  }
47
54
  function createValidatingHandler(schema, preValidate, handler) {