@exaudeus/workrail 1.13.1 → 1.14.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 (32) hide show
  1. package/dist/application/services/enhanced-loop-validator.d.ts +1 -0
  2. package/dist/application/services/enhanced-loop-validator.js +38 -7
  3. package/dist/application/use-cases/validate-workflow-json.js +2 -2
  4. package/dist/infrastructure/session/HttpServer.d.ts +3 -0
  5. package/dist/infrastructure/session/HttpServer.js +12 -7
  6. package/dist/manifest.json +72 -48
  7. package/dist/mcp/handlers/v2-advance-core/outcome-success.js +3 -0
  8. package/dist/mcp/handlers/v2-error-mapping.d.ts +3 -0
  9. package/dist/mcp/handlers/v2-error-mapping.js +2 -0
  10. package/dist/mcp/handlers/v2-execution/continue-advance.js +7 -0
  11. package/dist/mcp/handlers/v2-execution/start.d.ts +0 -1
  12. package/dist/mcp/handlers/v2-execution/start.js +1 -24
  13. package/dist/mcp/handlers/workflow.js +3 -2
  14. package/dist/mcp/server.js +12 -0
  15. package/dist/mcp/v2/tools.d.ts +0 -3
  16. package/dist/mcp/v2/tools.js +0 -1
  17. package/dist/v2/infra/local/directory-listing/index.d.ts +2 -1
  18. package/dist/v2/infra/local/directory-listing/index.js +8 -0
  19. package/dist/v2/infra/local/fs/index.d.ts +2 -1
  20. package/dist/v2/infra/local/fs/index.js +24 -0
  21. package/dist/v2/infra/local/session-summary-provider/index.js +1 -1
  22. package/dist/v2/ports/directory-listing.port.d.ts +5 -0
  23. package/dist/v2/ports/fs.port.d.ts +5 -0
  24. package/dist/v2/usecases/console-routes.d.ts +3 -0
  25. package/dist/v2/usecases/console-routes.js +49 -0
  26. package/dist/v2/usecases/console-service.d.ts +22 -0
  27. package/dist/v2/usecases/console-service.js +164 -0
  28. package/dist/v2/usecases/console-types.d.ts +49 -0
  29. package/dist/v2/usecases/console-types.js +2 -0
  30. package/dist/v2/usecases/enumerate-sessions.d.ts +4 -0
  31. package/dist/v2/usecases/enumerate-sessions.js +13 -0
  32. package/package.json +5 -2
@@ -13,6 +13,7 @@ export declare class EnhancedLoopValidator {
13
13
  validateLoopStep(step: LoopStepDefinition): EnhancedValidationResult;
14
14
  private getLoopBodySteps;
15
15
  private validateConditionalLogic;
16
+ private getPromptText;
16
17
  private validatePromptLength;
17
18
  private validateTemplateVariables;
18
19
  private getKnownLoopVariables;
@@ -55,10 +55,40 @@ let EnhancedLoopValidator = class EnhancedLoopValidator {
55
55
  }
56
56
  }
57
57
  }
58
+ getPromptText(step) {
59
+ if (step.prompt)
60
+ return step.prompt;
61
+ if (!step.promptBlocks)
62
+ return undefined;
63
+ const parts = [];
64
+ const b = step.promptBlocks;
65
+ if (typeof b.goal === 'string')
66
+ parts.push(b.goal);
67
+ if (Array.isArray(b.constraints)) {
68
+ for (const c of b.constraints) {
69
+ if (typeof c === 'string')
70
+ parts.push(c);
71
+ }
72
+ }
73
+ if (Array.isArray(b.procedure)) {
74
+ for (const p of b.procedure) {
75
+ if (typeof p === 'string')
76
+ parts.push(p);
77
+ }
78
+ }
79
+ if (Array.isArray(b.verify)) {
80
+ for (const v of b.verify) {
81
+ if (typeof v === 'string')
82
+ parts.push(v);
83
+ }
84
+ }
85
+ return parts.length > 0 ? parts.join('\n') : undefined;
86
+ }
58
87
  validatePromptLength(step, warnings, suggestions) {
59
- if (!step.prompt)
88
+ const promptText = this.getPromptText(step);
89
+ if (!promptText)
60
90
  return;
61
- const promptLength = step.prompt.length;
91
+ const promptLength = promptText.length;
62
92
  if (promptLength > this.PROMPT_ERROR_THRESHOLD) {
63
93
  warnings.push(`Step '${step.id}' has a very long prompt (${promptLength} characters). This may cause issues.`);
64
94
  suggestions.push(`Consider splitting this into multiple steps or moving content to the guidance section.`);
@@ -67,7 +97,7 @@ let EnhancedLoopValidator = class EnhancedLoopValidator {
67
97
  warnings.push(`Step '${step.id}' has a long prompt (${promptLength} characters).`);
68
98
  suggestions.push(`For better maintainability, consider breaking this into smaller, focused steps.`);
69
99
  }
70
- const conditionalMatches = step.prompt.match(/\{\{[^}]*\?[^}]*\}\}/g);
100
+ const conditionalMatches = step.prompt?.match(/\{\{[^}]*\?[^}]*\}\}/g);
71
101
  if (conditionalMatches) {
72
102
  let totalConditionalContent = 0;
73
103
  for (const match of conditionalMatches) {
@@ -115,15 +145,16 @@ let EnhancedLoopValidator = class EnhancedLoopValidator {
115
145
  const bodySteps = this.getLoopBodySteps(step);
116
146
  if (step.loop.type === 'for' && bodySteps.length > 0) {
117
147
  const firstStep = bodySteps[0];
118
- if (firstStep.prompt?.includes('analysis') ||
148
+ const firstPrompt = this.getPromptText(firstStep);
149
+ if (firstPrompt?.includes('analysis') ||
119
150
  firstStep.title?.toLowerCase().includes('analysis') ||
120
- firstStep.prompt?.includes('Step 1') ||
121
- firstStep.prompt?.includes('Structure')) {
151
+ firstPrompt?.includes('Step 1') ||
152
+ firstPrompt?.includes('Structure')) {
122
153
  info.push('Progressive analysis pattern detected.');
123
154
  suggestions.push('Consider using the multi-step pattern with separate steps and runCondition for clearer structure.');
124
155
  }
125
156
  }
126
- if (bodySteps.some(s => s.prompt?.includes('===') && s.prompt?.includes('?'))) {
157
+ if (bodySteps.some(s => { const p = this.getPromptText(s); return p?.includes('===') && p?.includes('?'); })) {
127
158
  info.push('Multi-conditional loop pattern detected.');
128
159
  suggestions.push('For loops with multiple conditional paths, the separate steps pattern is more maintainable than inline conditionals.');
129
160
  }
@@ -67,10 +67,10 @@ function generateSuggestions(errors) {
67
67
  suggestions.push('Use semantic versioning format (e.g., "0.0.1", "1.0.0").');
68
68
  }
69
69
  if (errorText.includes('steps')) {
70
- suggestions.push('Ensure the workflow has at least one step with id, title, and prompt fields.');
70
+ suggestions.push('Ensure the workflow has at least one step with id, title, and either prompt or promptBlocks.');
71
71
  }
72
72
  if (errorText.includes('step')) {
73
- suggestions.push('Check that all steps have required fields: id, title, and prompt.');
73
+ suggestions.push('Check that all steps have required fields: id, title, and either prompt or promptBlocks.');
74
74
  }
75
75
  if (errorText.includes('pattern')) {
76
76
  suggestions.push('Review the workflow schema documentation for correct field formats.');
@@ -1,3 +1,4 @@
1
+ import { Application } from 'express';
1
2
  import { SessionManager } from './SessionManager.js';
2
3
  import type { ProcessLifecyclePolicy } from '../../runtime/process-lifecycle-policy.js';
3
4
  import type { ProcessSignals } from '../../runtime/ports/process-signals.js';
@@ -48,6 +49,8 @@ export declare class HttpServer {
48
49
  private printBanner;
49
50
  openDashboard(sessionId?: string): Promise<string>;
50
51
  stop(): Promise<void>;
52
+ mountRoutes(installer: (app: Application) => void): void;
53
+ finalize(): void;
51
54
  getBaseUrl(): string;
52
55
  getPort(): number;
53
56
  private quickCleanup;
@@ -337,13 +337,6 @@ let HttpServer = class HttpServer {
337
337
  port: this.port
338
338
  });
339
339
  });
340
- this.app.use((req, res) => {
341
- res.status(404).json({
342
- success: false,
343
- error: 'Not found',
344
- path: req.path
345
- });
346
- });
347
340
  }
348
341
  async start() {
349
342
  await this.quickCleanup();
@@ -646,6 +639,18 @@ let HttpServer = class HttpServer {
646
639
  this.isPrimary = false;
647
640
  }
648
641
  }
642
+ mountRoutes(installer) {
643
+ installer(this.app);
644
+ }
645
+ finalize() {
646
+ this.app.use((req, res) => {
647
+ res.status(404).json({
648
+ success: false,
649
+ error: 'Not found',
650
+ path: req.path,
651
+ });
652
+ });
653
+ }
649
654
  getBaseUrl() {
650
655
  return this.baseUrl;
651
656
  }
@@ -66,12 +66,12 @@
66
66
  "bytes": 6252
67
67
  },
68
68
  "application/services/enhanced-loop-validator.d.ts": {
69
- "sha256": "042456f4080212c16acaee730bec5cf3342173f3307f405f85a9dbdaa410797f",
70
- "bytes": 774
69
+ "sha256": "bef909cb861b88beda04b44110f8abb18181bb82be22bfbde5fe819a66654d52",
70
+ "bytes": 801
71
71
  },
72
72
  "application/services/enhanced-loop-validator.js": {
73
- "sha256": "0af041281661c46cee1c63eebe36ee20d12b9fefc1f95e6baed9d959ae012b6a",
74
- "bytes": 7980
73
+ "sha256": "148e75778723842874037c1d0c4fc3ab737787ddb9e3c78c5386cd49abfd065e",
74
+ "bytes": 9020
75
75
  },
76
76
  "application/services/output-normalizer.d.ts": {
77
77
  "sha256": "35bd9e50e984132f83dac874f90c2a4e9e8223202c6832426654232c5d7e2236",
@@ -166,8 +166,8 @@
166
166
  "bytes": 345
167
167
  },
168
168
  "application/use-cases/validate-workflow-json.js": {
169
- "sha256": "e5f0bfe7dfd8118a23f0690578159e8e591452a5635d77d5d0244685da07b9c2",
170
- "bytes": 3651
169
+ "sha256": "87caff4501c5ee59ce73fc37762eeedc1e00253c7bf7f432349288e07810293f",
170
+ "bytes": 3690
171
171
  },
172
172
  "application/validation.d.ts": {
173
173
  "sha256": "2b44ccd1db66c81d8d5306e4b3453b50c27bb5c2c4bec85191b325c339d188cc",
@@ -442,12 +442,12 @@
442
442
  "bytes": 818
443
443
  },
444
444
  "infrastructure/session/HttpServer.d.ts": {
445
- "sha256": "0e4a40f22a66ab4f1a41aad2899d5ce89ca12e1b52598eb82b105ec8ecf37592",
446
- "bytes": 1852
445
+ "sha256": "986dd1ed28ec846d432af0bacd01980aca162c18c383aa77698d47a79cf1fdab",
446
+ "bytes": 1975
447
447
  },
448
448
  "infrastructure/session/HttpServer.js": {
449
- "sha256": "76508602e5d7ee9337ff64c7dffa5153347ef754e1252d191b4ee6243ea24f1b",
450
- "bytes": 32446
449
+ "sha256": "1be0cec5c7bd1204f86f77fe01985ed4906fa2432b22a44b7b01b3aa179a4803",
450
+ "bytes": 32534
451
451
  },
452
452
  "infrastructure/session/SessionDataNormalizer.d.ts": {
453
453
  "sha256": "c89bb5e00d7d01fb4aa6d0095602541de53c425c6b99b67fa8367eb29cb63e9e",
@@ -646,8 +646,8 @@
646
646
  "bytes": 936
647
647
  },
648
648
  "mcp/handlers/v2-advance-core/outcome-success.js": {
649
- "sha256": "e08268f3b8fd11213e67052721e231a6e055daa1dd4f729784f6ed3b20ddddb4",
650
- "bytes": 5961
649
+ "sha256": "b0e2f52b8843b067b1ca1c3aa6e797d3b6ad7bf175c46b1f036e70fc2174f992",
650
+ "bytes": 6129
651
651
  },
652
652
  "mcp/handlers/v2-advance-events.d.ts": {
653
653
  "sha256": "02cdb52a2c16dd619645b5496caf0880e57937bf21ea9efe44e6cd195cd43b94",
@@ -674,12 +674,12 @@
674
674
  "bytes": 7199
675
675
  },
676
676
  "mcp/handlers/v2-error-mapping.d.ts": {
677
- "sha256": "bbaf580dfc22ca6b5ef1d57036fb549c640d6f37bd7d525f1a805b4d14c4d75c",
678
- "bytes": 1711
677
+ "sha256": "1cf58654dd6f70a0e35b75435c835a410658a2c7220d1b86561124476c8742fa",
678
+ "bytes": 1798
679
679
  },
680
680
  "mcp/handlers/v2-error-mapping.js": {
681
- "sha256": "95dff130804524a007e1071784c20897ba6af1cc04fb2a636741e261fa22c3f8",
682
- "bytes": 10388
681
+ "sha256": "f63c6711fdd05cf89d7da5f1441a17efa540b2f4985f85759c7f740a6cf2e854",
682
+ "bytes": 10664
683
683
  },
684
684
  "mcp/handlers/v2-execution-helpers.d.ts": {
685
685
  "sha256": "1e52f266e991a9447d1254bf047f6a09062b038ed3363a3818d1f5c91eed2fc8",
@@ -710,8 +710,8 @@
710
710
  "bytes": 1830
711
711
  },
712
712
  "mcp/handlers/v2-execution/continue-advance.js": {
713
- "sha256": "bfbc14690fe08f51c5e1e2124e5561e9a093806e511803d68e4a2d22b5918919",
714
- "bytes": 7927
713
+ "sha256": "864b892e6e69afbe300dbc748d0b6f3476d299b5cbaea36b5197748f9972611b",
714
+ "bytes": 8332
715
715
  },
716
716
  "mcp/handlers/v2-execution/continue-rehydrate.d.ts": {
717
717
  "sha256": "af7475b7effe57f18fa8379bfd128d17afb2d27fe1c058c6f2ee8f5b2632e3d0",
@@ -738,12 +738,12 @@
738
738
  "bytes": 11969
739
739
  },
740
740
  "mcp/handlers/v2-execution/start.d.ts": {
741
- "sha256": "59de3fb71608b19e6a81a63ff3c74f9be92b90c8e07817e9248e3ee7e4654367",
742
- "bytes": 2789
741
+ "sha256": "333f9f36756d2ce55249c6af45198a17b51aa9c6448e063f7621fcd61879f2bf",
742
+ "bytes": 2684
743
743
  },
744
744
  "mcp/handlers/v2-execution/start.js": {
745
- "sha256": "aeee2ba6b1cc0d461d2421eed0f99ca22f4006baa7f5663cc28855d00c950d87",
746
- "bytes": 15015
745
+ "sha256": "4e21cd7739860fbb2349fdde6e83225001dd06345acfdd66607f733901c20cdd",
746
+ "bytes": 14067
747
747
  },
748
748
  "mcp/handlers/v2-resume.d.ts": {
749
749
  "sha256": "d88f6c35bcaf946666c837b72fda3702a2ebab5e478eb90f7b4b672a0e5fa24f",
@@ -790,8 +790,8 @@
790
790
  "bytes": 1748
791
791
  },
792
792
  "mcp/handlers/workflow.js": {
793
- "sha256": "a813ad7b201475a4362560b2ae2fbdc679ff416a92a4a5ab5dded4350e692daa",
794
- "bytes": 8068
793
+ "sha256": "c95bbef83298b7d518e5e587147bdf83546bba77d3ef026c3598e8b0c6168004",
794
+ "bytes": 8233
795
795
  },
796
796
  "mcp/index.d.ts": {
797
797
  "sha256": "525b4247cf90ba3af66769462bcfaab5dbf38ee8c49d2a9ceec1e4b38e33511b",
@@ -814,8 +814,8 @@
814
814
  "bytes": 168
815
815
  },
816
816
  "mcp/server.js": {
817
- "sha256": "fd9e264c759db2d5446d88eafce14ec27ce9b73756e62ef10351b2fca52c7c7c",
818
- "bytes": 11892
817
+ "sha256": "c29e4ad8a9ed43304654f59725a7dd50a6fe5cd4cde9e7db2678ae9a7ccd0557",
818
+ "bytes": 12643
819
819
  },
820
820
  "mcp/tool-description-provider.d.ts": {
821
821
  "sha256": "1d46abc3112e11b68e57197e846f5708293ec9b2281fa71a9124ee2aad71e41b",
@@ -890,12 +890,12 @@
890
890
  "bytes": 3119
891
891
  },
892
892
  "mcp/v2/tools.d.ts": {
893
- "sha256": "567938a5c153159b7792600cbe2326ce446a28f46d5f49e34dc1663cf826427e",
894
- "bytes": 6737
893
+ "sha256": "f789303c98e8b3d53c9b8c22b0cf99548c54907cfde3c5c67ca4036fab7d156c",
894
+ "bytes": 6567
895
895
  },
896
896
  "mcp/v2/tools.js": {
897
- "sha256": "49d00fe392c526ce5f7e287ba98180cc82574b0c85ff0b550f3f01a216ac5dbf",
898
- "bytes": 7938
897
+ "sha256": "0d55830445ed414f31f52fc2775ea631fe1cb3f91b04e4dda33850dd2d8572cd",
898
+ "bytes": 7506
899
899
  },
900
900
  "mcp/validation/bounded-json.d.ts": {
901
901
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -1802,20 +1802,20 @@
1802
1802
  "bytes": 3036
1803
1803
  },
1804
1804
  "v2/infra/local/directory-listing/index.d.ts": {
1805
- "sha256": "dbf0a610bf4871eec89cc39f218ebb5267c695ccd8524613868abf5aa79d8d4a",
1806
- "bytes": 447
1805
+ "sha256": "3139014cb738db3b0f10beca01a3a4a35b9ab8e72c8889b3bbff204fdbcb6b6c",
1806
+ "bytes": 557
1807
1807
  },
1808
1808
  "v2/infra/local/directory-listing/index.js": {
1809
- "sha256": "1930cb982b9034f46751a000011ea069b6e03becd898973afad4b74e6ebc1759",
1810
- "bytes": 566
1809
+ "sha256": "f3ed94836fa657dc34692378635efa12a5446e5f63c07637b3476a872e5064b1",
1810
+ "bytes": 844
1811
1811
  },
1812
1812
  "v2/infra/local/fs/index.d.ts": {
1813
- "sha256": "fe3f06badea2d62e9ade3954f716d0b7aa4778c4d49e5fb9f6f58db6d2e9429a",
1814
- "bytes": 1323
1813
+ "sha256": "dcfe3510dc6a8d92ededdb9c1376702dc88455ccb189eb7dc3ba2721b6b43d38",
1814
+ "bytes": 1437
1815
1815
  },
1816
1816
  "v2/infra/local/fs/index.js": {
1817
- "sha256": "05fcd1345b3f003c19a13ee8db4ef657f23815c253e4fa36fa4bd7092f0a0b68",
1818
- "bytes": 7179
1817
+ "sha256": "6d898cf90fd022530fb4ee4c03e0127955895d9da0f4ef52d85d8843803466df",
1818
+ "bytes": 8262
1819
1819
  },
1820
1820
  "v2/infra/local/hmac-sha256/index.d.ts": {
1821
1821
  "sha256": "dda3865510dfaf2f13947410d998da6ffecc9a2e728b3574f81e69d5db859815",
@@ -1878,8 +1878,8 @@
1878
1878
  "bytes": 1004
1879
1879
  },
1880
1880
  "v2/infra/local/session-summary-provider/index.js": {
1881
- "sha256": "a38c877faddb8e14bf1c30e173e4299af5edb4a1f8fb4b036732c6ba6f11ca6f",
1882
- "bytes": 5933
1881
+ "sha256": "1d8a543361c582f6e089f63f24318ff7caf97a78659ecdc5b89152b78d18c6aa",
1882
+ "bytes": 5942
1883
1883
  },
1884
1884
  "v2/infra/local/sha256/index.d.ts": {
1885
1885
  "sha256": "8a727b7e54a38275ca6f9f1b8730f97cfc0a212df035df1bdc58e716e6824230",
@@ -1954,16 +1954,16 @@
1954
1954
  "bytes": 77
1955
1955
  },
1956
1956
  "v2/ports/directory-listing.port.d.ts": {
1957
- "sha256": "3184229b7793bbd3100611c6308d33a96145c4dc63ba451d8c29ff507084e7b4",
1958
- "bytes": 207
1957
+ "sha256": "d707e849df351d2cf619942771b68dfeaa14095618ed3f3109e71da4d5f8d0fa",
1958
+ "bytes": 394
1959
1959
  },
1960
1960
  "v2/ports/directory-listing.port.js": {
1961
1961
  "sha256": "d43aa81f5bc89faa359e0f97c814ba25155591ff078fbb9bfd40f8c7c9683230",
1962
1962
  "bytes": 77
1963
1963
  },
1964
1964
  "v2/ports/fs.port.d.ts": {
1965
- "sha256": "7b0d36b7a1abbf6f3f7279a122fe623bfa5d8b18f9a600c191d536c0e93204f7",
1966
- "bytes": 1991
1965
+ "sha256": "49b481e09333784c5bbb95293a0cc1833ed5fe498aa3a52e86fad076fefe08d9",
1966
+ "bytes": 2182
1967
1967
  },
1968
1968
  "v2/ports/fs.port.js": {
1969
1969
  "sha256": "d43aa81f5bc89faa359e0f97c814ba25155591ff078fbb9bfd40f8c7c9683230",
@@ -2177,13 +2177,37 @@
2177
2177
  "sha256": "36a9c3f0faf71c49fc9624f41c26c452e276f4ac15190f2d22d89a003a2bb099",
2178
2178
  "bytes": 2678
2179
2179
  },
2180
+ "v2/usecases/console-routes.d.ts": {
2181
+ "sha256": "ccdf824d2c7872b3d588994ebefa15a7771de5ad1abefeb602528b4ca232ae62",
2182
+ "bytes": 204
2183
+ },
2184
+ "v2/usecases/console-routes.js": {
2185
+ "sha256": "d437f8fee37c016533e78259a1f5ce14017a746371c0c77e9519d445f784c988",
2186
+ "bytes": 2192
2187
+ },
2188
+ "v2/usecases/console-service.d.ts": {
2189
+ "sha256": "787b1e01e7e30354f56203822142e825069bd42fba476797df6672c96dd5b555",
2190
+ "bytes": 1083
2191
+ },
2192
+ "v2/usecases/console-service.js": {
2193
+ "sha256": "e3df9ceaf0fcca2e55f7625f4610a053629b360638f469446ab8f576d32be8a9",
2194
+ "bytes": 7183
2195
+ },
2196
+ "v2/usecases/console-types.d.ts": {
2197
+ "sha256": "84c4c839b5285f5a29d85b7b4188e7948f92be1f34e44618cc0c9c85a1c11a18",
2198
+ "bytes": 1799
2199
+ },
2200
+ "v2/usecases/console-types.js": {
2201
+ "sha256": "d43aa81f5bc89faa359e0f97c814ba25155591ff078fbb9bfd40f8c7c9683230",
2202
+ "bytes": 77
2203
+ },
2180
2204
  "v2/usecases/enumerate-sessions.d.ts": {
2181
- "sha256": "6043d64b45360dfc6a15b822d9f013a0832127596706bf81569dfce256236d2d",
2182
- "bytes": 499
2205
+ "sha256": "46da8960bdeb154f79dee443425260f3ce18c50a0db01e7ab60700432d864857",
2206
+ "bytes": 699
2183
2207
  },
2184
2208
  "v2/usecases/enumerate-sessions.js": {
2185
- "sha256": "99e135a7c7411ce850c9dd89963ef6a05d3488078d6c6b2c540cb2d2043a2e89",
2186
- "bytes": 526
2209
+ "sha256": "4ae73f47c1e8ebea0d9a48dc786e5e4d0442a38827c427378712e9d198410ae2",
2210
+ "bytes": 1050
2187
2211
  },
2188
2212
  "v2/usecases/execution-session-gate.d.ts": {
2189
2213
  "sha256": "339c4a8e02a77416e725e063a57d39a20788244498ae2c7a31dc48d111af6280",
@@ -44,6 +44,9 @@ function buildSuccessOutcome(args) {
44
44
  });
45
45
  const nextRes = interpreter.next(compiledWf.value, advanced.value, v.mergedContext, artifactsForEval);
46
46
  if (nextRes.isErr()) {
47
+ if (nextRes.error._tag === 'MissingContext') {
48
+ return errAsync({ kind: 'advance_next_missing_context', message: nextRes.error.message });
49
+ }
47
50
  return errAsync({ kind: 'advance_next_failed', message: nextRes.error.message });
48
51
  }
49
52
  const out = nextRes.value;
@@ -12,6 +12,9 @@ export type InternalError = {
12
12
  } | {
13
13
  readonly kind: 'advance_next_failed';
14
14
  readonly message: string;
15
+ } | {
16
+ readonly kind: 'advance_next_missing_context';
17
+ readonly message: string;
15
18
  } | {
16
19
  readonly kind: 'missing_node_or_run';
17
20
  } | {
@@ -122,6 +122,8 @@ function mapInternalErrorToToolError(e) {
122
122
  return internalError('WorkRail could not record the workflow advancement. This is not caused by your input.', (0, v2_execution_helpers_js_1.internalSuggestion)('Retry the call.', 'WorkRail could not record the advancement.'));
123
123
  case 'advance_next_failed':
124
124
  return internalError('WorkRail could not compute the next workflow step. This is not caused by your input.', (0, v2_execution_helpers_js_1.internalSuggestion)('Retry the call.', 'WorkRail could not compute the next step.'));
125
+ case 'advance_next_missing_context':
126
+ return (0, types_js_1.errNotRetryable)('PRECONDITION_FAILED', e.message, { suggestion: 'Set the required context variable in the `context` field of your continue_workflow output. The variable must be a JSON array.' });
125
127
  default:
126
128
  const _exhaustive = e;
127
129
  return internalError('WorkRail encountered an unexpected error. This is not caused by your input.', (0, v2_execution_helpers_js_1.internalSuggestion)('Retry the call.', 'WorkRail has an internal error.'));
@@ -120,6 +120,13 @@ function handleAdvanceIntent(args) {
120
120
  }))
121
121
  .mapErr((cause) => {
122
122
  if ((0, v2_error_mapping_js_1.isInternalError)(cause)) {
123
+ if (cause.kind === 'advance_next_missing_context') {
124
+ return {
125
+ kind: 'precondition_failed',
126
+ message: cause.message,
127
+ suggestion: 'Set the required context variable in the `context` field of your continue_workflow output. The variable must be a JSON array.',
128
+ };
129
+ }
123
130
  return {
124
131
  kind: 'invariant_violation',
125
132
  message: `Advance failed due to internal error: ${cause.kind}`,
@@ -31,7 +31,6 @@ export declare function buildInitialEvents(args: {
31
31
  readonly workflowSourceKind: 'bundled' | 'user' | 'project' | 'remote' | 'plugin';
32
32
  readonly workflowSourceRef: string;
33
33
  readonly snapshotRef: import('../../../v2/durable-core/ids/index.js').SnapshotRef;
34
- readonly context: import('../../../v2/durable-core/canonical/json-types.js').JsonObject | undefined;
35
34
  readonly observations: readonly ObservationEventData[];
36
35
  readonly idFactory: {
37
36
  readonly mintEventId: () => string;
@@ -20,7 +20,6 @@ const v2_workspace_resolution_js_1 = require("../v2-workspace-resolution.js");
20
20
  const v2_token_ops_js_1 = require("../v2-token-ops.js");
21
21
  const v2_state_conversion_js_1 = require("../v2-state-conversion.js");
22
22
  const v2_execution_helpers_js_2 = require("../v2-execution-helpers.js");
23
- const v2_context_budget_js_1 = require("../v2-context-budget.js");
24
23
  const constants_js_1 = require("../../../v2/durable-core/constants.js");
25
24
  const index_js_2 = require("./index.js");
26
25
  function loadAndPinWorkflow(args) {
@@ -69,7 +68,7 @@ function loadAndPinWorkflow(args) {
69
68
  });
70
69
  }
71
70
  function buildInitialEvents(args) {
72
- const { sessionId, runId, nodeId, workflowId, workflowHash, workflowSourceKind, workflowSourceRef, snapshotRef, context, observations, idFactory, } = args;
71
+ const { sessionId, runId, nodeId, workflowId, workflowHash, workflowSourceKind, workflowSourceRef, snapshotRef, observations, idFactory, } = args;
73
72
  const evtSessionCreated = idFactory.mintEventId();
74
73
  const evtRunStarted = idFactory.mintEventId();
75
74
  const evtNodeCreated = idFactory.mintEventId();
@@ -138,24 +137,6 @@ function buildInitialEvents(args) {
138
137
  },
139
138
  ];
140
139
  const mutableEvents = [...baseEvents];
141
- if (context) {
142
- const evtContextSet = idFactory.mintEventId();
143
- const contextId = idFactory.mintEventId();
144
- mutableEvents.push({
145
- v: 1,
146
- eventId: evtContextSet,
147
- eventIndex: mutableEvents.length,
148
- sessionId,
149
- kind: constants_js_1.EVENT_KIND.CONTEXT_SET,
150
- dedupeKey: `context_set:${sessionId}:${runId}:${contextId}`,
151
- scope: { runId },
152
- data: {
153
- contextId,
154
- context: context,
155
- source: 'initial',
156
- },
157
- });
158
- }
159
140
  for (const obs of observations) {
160
141
  const obsEventId = idFactory.mintEventId();
161
142
  mutableEvents.push({
@@ -220,9 +201,6 @@ function mintStartTokens(args) {
220
201
  }
221
202
  function executeStartWorkflow(input, ctx) {
222
203
  const { gate, sessionStore, snapshotStore, pinnedStore, crypto, tokenCodecPorts, idFactory } = ctx.v2;
223
- const ctxCheck = (0, v2_context_budget_js_1.checkContextBudget)({ tool: 'start_workflow', context: input.context });
224
- if (!ctxCheck.ok)
225
- return (0, neverthrow_1.errAsync)({ kind: 'validation_failed', failure: ctxCheck.error });
226
204
  return loadAndPinWorkflow({
227
205
  workflowId: input.workflowId,
228
206
  workflowService: ctx.workflowService,
@@ -270,7 +248,6 @@ function executeStartWorkflow(input, ctx) {
270
248
  workflowSourceKind: (0, v2_state_conversion_js_1.mapWorkflowSourceKind)(workflow.source.kind),
271
249
  workflowSourceRef,
272
250
  snapshotRef,
273
- context: input.context,
274
251
  observations,
275
252
  idFactory,
276
253
  });
@@ -153,8 +153,9 @@ async function handleWorkflowGetSchema(_input, ctx) {
153
153
  stepStructure: {
154
154
  id: 'string (required): Unique step identifier',
155
155
  title: 'string (required): Human-readable step title',
156
- prompt: 'string (required): Instructions for the step',
157
- agentRole: 'string (required): Role description for the agent',
156
+ prompt: 'string (optional): Instructions for the step (use prompt OR promptBlocks)',
157
+ promptBlocks: 'object (optional): Structured prompt blocks (goal, constraints, procedure, outputRequired, verify)',
158
+ agentRole: 'string (optional): Role description for the agent',
158
159
  validationCriteria: 'array (optional): Validation rules for step output',
159
160
  },
160
161
  },
@@ -137,6 +137,18 @@ function toMcpTool(tool) {
137
137
  async function startServer() {
138
138
  await (0, container_js_1.bootstrap)({ runtimeMode: { kind: 'production' } });
139
139
  const ctx = await createToolContext();
140
+ if (ctx.v2 && ctx.httpServer && ctx.v2.dataDir && ctx.v2.directoryListing) {
141
+ const { ConsoleService } = await Promise.resolve().then(() => __importStar(require('../v2/usecases/console-service.js')));
142
+ const { mountConsoleRoutes } = await Promise.resolve().then(() => __importStar(require('../v2/usecases/console-routes.js')));
143
+ const consoleService = new ConsoleService({
144
+ directoryListing: ctx.v2.directoryListing,
145
+ dataDir: ctx.v2.dataDir,
146
+ sessionStore: ctx.v2.sessionStore,
147
+ });
148
+ ctx.httpServer.mountRoutes((app) => mountConsoleRoutes(app, consoleService));
149
+ console.error('[Console] v2 Console API routes mounted at /api/v2/');
150
+ }
151
+ ctx.httpServer?.finalize();
140
152
  const descriptionProvider = container_js_1.container.resolve(tokens_js_1.DI.Mcp.DescriptionProvider);
141
153
  const buildTool = (0, tool_factory_js_1.createToolFactory)(descriptionProvider);
142
154
  const workflowEdition = (0, workflow_tool_edition_selector_js_1.selectWorkflowToolEdition)(ctx.featureFlags, buildTool);
@@ -15,15 +15,12 @@ export declare const V2InspectWorkflowInput: z.ZodObject<{
15
15
  export type V2InspectWorkflowInput = z.infer<typeof V2InspectWorkflowInput>;
16
16
  export declare const V2StartWorkflowInput: z.ZodObject<{
17
17
  workflowId: z.ZodString;
18
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
19
18
  workspacePath: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
20
19
  }, "strip", z.ZodTypeAny, {
21
20
  workflowId: string;
22
- context?: Record<string, unknown> | undefined;
23
21
  workspacePath?: string | undefined;
24
22
  }, {
25
23
  workflowId: string;
26
- context?: Record<string, unknown> | undefined;
27
24
  workspacePath?: string | undefined;
28
25
  }>;
29
26
  export type V2StartWorkflowInput = z.infer<typeof V2StartWorkflowInput>;
@@ -9,7 +9,6 @@ exports.V2InspectWorkflowInput = zod_1.z.object({
9
9
  });
10
10
  exports.V2StartWorkflowInput = zod_1.z.object({
11
11
  workflowId: zod_1.z.string().min(1).regex(/^[A-Za-z0-9_-]+$/, 'Workflow ID must contain only letters, numbers, hyphens, and underscores').describe('The workflow ID to start'),
12
- context: zod_1.z.record(zod_1.z.unknown()).optional().describe('Structured context for this workflow — must be a JSON OBJECT with string keys, NOT a string. For design/analysis workflows: {"problem":"describe the problem","constraints":"...","goals":"..."}. For coding workflows: {"ticketId":"ACEI-1234","branch":"main"}. WorkRail injects these into step prompts. Pass once at start; re-pass only values that have CHANGED.'),
13
12
  workspacePath: zod_1.z.string()
14
13
  .refine((p) => p.startsWith('/'), 'workspacePath must be an absolute path (starting with /)')
15
14
  .optional()
@@ -1,8 +1,9 @@
1
1
  import type { ResultAsync } from 'neverthrow';
2
2
  import type { FsError, DirectoryListingOpsPortV2 } from '../../../ports/fs.port.js';
3
- import type { DirectoryListingPortV2 } from '../../../ports/directory-listing.port.js';
3
+ import type { DirectoryListingPortV2, DirEntryWithMtime } from '../../../ports/directory-listing.port.js';
4
4
  export declare class LocalDirectoryListingV2 implements DirectoryListingPortV2 {
5
5
  private readonly fs;
6
6
  constructor(fs: DirectoryListingOpsPortV2);
7
7
  readdir(dirPath: string): ResultAsync<readonly string[], FsError>;
8
+ readdirWithMtime(dirPath: string): ResultAsync<readonly DirEntryWithMtime[], FsError>;
8
9
  }
@@ -14,5 +14,13 @@ class LocalDirectoryListingV2 {
14
14
  return (0, neverthrow_1.errAsync)(e);
15
15
  });
16
16
  }
17
+ readdirWithMtime(dirPath) {
18
+ return this.fs.readdirWithMtime(dirPath).orElse((e) => {
19
+ if (e.code === 'FS_NOT_FOUND') {
20
+ return (0, neverthrow_1.okAsync)([]);
21
+ }
22
+ return (0, neverthrow_1.errAsync)(e);
23
+ });
24
+ }
17
25
  }
18
26
  exports.LocalDirectoryListingV2 = LocalDirectoryListingV2;
@@ -1,5 +1,5 @@
1
1
  import type { ResultAsync } from 'neverthrow';
2
- import type { FileSystemPortV2, FsError } from '../../../ports/fs.port.js';
2
+ import type { FileSystemPortV2, FsError, FsDirEntryWithMtime } from '../../../ports/fs.port.js';
3
3
  export declare class NodeFileSystemV2 implements FileSystemPortV2 {
4
4
  mkdirp(dirPath: string): ResultAsync<void, FsError>;
5
5
  readFileUtf8(filePath: string): ResultAsync<string, FsError>;
@@ -24,4 +24,5 @@ export declare class NodeFileSystemV2 implements FileSystemPortV2 {
24
24
  readonly sizeBytes: number;
25
25
  }, FsError>;
26
26
  readdir(dirPath: string): ResultAsync<readonly string[], FsError>;
27
+ readdirWithMtime(dirPath: string): ResultAsync<readonly FsDirEntryWithMtime[], FsError>;
27
28
  }
@@ -38,6 +38,7 @@ const fs = __importStar(require("fs/promises"));
38
38
  const fsCb = __importStar(require("fs"));
39
39
  const fs_1 = require("fs");
40
40
  const neverthrow_1 = require("neverthrow");
41
+ const path = __importStar(require("path"));
41
42
  function nodeErrorCode(e) {
42
43
  if (typeof e !== 'object' || e === null)
43
44
  return undefined;
@@ -162,5 +163,28 @@ class NodeFileSystemV2 {
162
163
  readdir(dirPath) {
163
164
  return neverthrow_1.ResultAsync.fromPromise(fs.readdir(dirPath), (e) => mapFsError(e, dirPath));
164
165
  }
166
+ readdirWithMtime(dirPath) {
167
+ return neverthrow_1.ResultAsync.fromPromise((async () => {
168
+ const entries = await fs.readdir(dirPath);
169
+ const withMtime = [];
170
+ let skipped = 0;
171
+ for (const name of entries) {
172
+ try {
173
+ const stats = await fs.stat(path.join(dirPath, name));
174
+ withMtime.push({ name, mtimeMs: stats.mtimeMs });
175
+ }
176
+ catch (e) {
177
+ const code = nodeErrorCode(e);
178
+ skipped++;
179
+ console.error(`[workrail:session-enum] Skipping ${name}: stat failed (${code ?? 'unknown'}: ${e instanceof Error ? e.message : String(e)})`);
180
+ continue;
181
+ }
182
+ }
183
+ if (skipped > 0) {
184
+ console.error(`[workrail:session-enum] Enumerated ${withMtime.length} sessions, skipped ${skipped} (stat failures)`);
185
+ }
186
+ return withMtime;
187
+ })(), (e) => mapFsError(e, dirPath));
188
+ }
165
189
  }
166
190
  exports.NodeFileSystemV2 = NodeFileSystemV2;
@@ -21,7 +21,7 @@ class LocalSessionSummaryProviderV2 {
21
21
  this.ports = ports;
22
22
  }
23
23
  loadHealthySummaries() {
24
- return (0, enumerate_sessions_js_1.enumerateSessions)({
24
+ return (0, enumerate_sessions_js_1.enumerateSessionsByRecency)({
25
25
  directoryListing: this.ports.directoryListing,
26
26
  dataDir: this.ports.dataDir,
27
27
  })
@@ -1,5 +1,10 @@
1
1
  import type { ResultAsync } from 'neverthrow';
2
2
  import type { FsError } from './fs.port.js';
3
+ export interface DirEntryWithMtime {
4
+ readonly name: string;
5
+ readonly mtimeMs: number;
6
+ }
3
7
  export interface DirectoryListingPortV2 {
4
8
  readdir(dirPath: string): ResultAsync<readonly string[], FsError>;
9
+ readdirWithMtime(dirPath: string): ResultAsync<readonly DirEntryWithMtime[], FsError>;
5
10
  }
@@ -45,8 +45,13 @@ export interface FileManipulationPortV2 {
45
45
  unlink(filePath: string): ResultAsync<void, FsError>;
46
46
  writeFileBytes(filePath: string, bytes: Uint8Array): ResultAsync<void, FsError>;
47
47
  }
48
+ export interface FsDirEntryWithMtime {
49
+ readonly name: string;
50
+ readonly mtimeMs: number;
51
+ }
48
52
  export interface DirectoryListingOpsPortV2 {
49
53
  readdir(dirPath: string): ResultAsync<readonly string[], FsError>;
54
+ readdirWithMtime(dirPath: string): ResultAsync<readonly FsDirEntryWithMtime[], FsError>;
50
55
  }
51
56
  export interface CrashSafeFileOpsPortV2 extends DirectoryOpsPortV2, FileReadPortV2, FileDescriptorPortV2, FileManipulationPortV2, DirectoryListingOpsPortV2 {
52
57
  }
@@ -0,0 +1,3 @@
1
+ import type { Application } from 'express';
2
+ import type { ConsoleService } from './console-service.js';
3
+ export declare function mountConsoleRoutes(app: Application, consoleService: ConsoleService): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mountConsoleRoutes = mountConsoleRoutes;
7
+ const express_1 = __importDefault(require("express"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ function resolveConsoleDist() {
11
+ const fromDist = path_1.default.join(__dirname, '../../../console/dist');
12
+ if (fs_1.default.existsSync(fromDist))
13
+ return fromDist;
14
+ const fromSrc = path_1.default.join(__dirname, '../../../console/dist');
15
+ if (fs_1.default.existsSync(fromSrc))
16
+ return fromSrc;
17
+ return null;
18
+ }
19
+ function mountConsoleRoutes(app, consoleService) {
20
+ app.get('/api/v2/sessions', async (_req, res) => {
21
+ const result = await consoleService.getSessionList();
22
+ result.match((data) => res.json({ success: true, data }), (error) => res.status(500).json({ success: false, error: error.message }));
23
+ });
24
+ app.get('/api/v2/sessions/:sessionId', async (req, res) => {
25
+ const { sessionId } = req.params;
26
+ const result = await consoleService.getSessionDetail(sessionId);
27
+ result.match((data) => res.json({ success: true, data }), (error) => {
28
+ const status = error.code === 'SESSION_LOAD_FAILED' ? 404 : 500;
29
+ res.status(status).json({ success: false, error: error.message });
30
+ });
31
+ });
32
+ const consoleDist = resolveConsoleDist();
33
+ if (consoleDist) {
34
+ app.use('/console', express_1.default.static(consoleDist));
35
+ app.get('/console/*', (_req, res) => {
36
+ res.sendFile(path_1.default.join(consoleDist, 'index.html'));
37
+ });
38
+ console.error(`[Console] UI serving from ${consoleDist}`);
39
+ }
40
+ else {
41
+ app.get('/console', (_req, res) => {
42
+ res.status(503).json({
43
+ error: 'Console not built',
44
+ message: 'Run "cd console && npm run build" to build the Console UI.',
45
+ });
46
+ });
47
+ console.error('[Console] UI not found (run: cd console && npm run build)');
48
+ }
49
+ }
@@ -0,0 +1,22 @@
1
+ import type { ResultAsync } from 'neverthrow';
2
+ import type { DirectoryListingPortV2 } from '../ports/directory-listing.port.js';
3
+ import type { DataDirPortV2 } from '../ports/data-dir.port.js';
4
+ import type { SessionEventLogReadonlyStorePortV2 } from '../ports/session-event-log-store.port.js';
5
+ import type { ConsoleSessionListResponse, ConsoleSessionDetail } from './console-types.js';
6
+ export interface ConsoleServicePorts {
7
+ readonly directoryListing: DirectoryListingPortV2;
8
+ readonly dataDir: DataDirPortV2;
9
+ readonly sessionStore: SessionEventLogReadonlyStorePortV2;
10
+ }
11
+ export declare class ConsoleService {
12
+ private readonly ports;
13
+ constructor(ports: ConsoleServicePorts);
14
+ getSessionList(): ResultAsync<ConsoleSessionListResponse, ConsoleServiceError>;
15
+ getSessionDetail(sessionIdStr: string): ResultAsync<ConsoleSessionDetail, ConsoleServiceError>;
16
+ private collectSessionSummaries;
17
+ private loadSessionSummary;
18
+ }
19
+ export interface ConsoleServiceError {
20
+ readonly code: 'ENUMERATION_FAILED' | 'SESSION_LOAD_FAILED';
21
+ readonly message: string;
22
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleService = void 0;
4
+ const neverthrow_1 = require("neverthrow");
5
+ const enumerate_sessions_js_1 = require("./enumerate-sessions.js");
6
+ const session_health_js_1 = require("../projections/session-health.js");
7
+ const run_dag_js_1 = require("../projections/run-dag.js");
8
+ const run_status_signals_js_1 = require("../projections/run-status-signals.js");
9
+ const gaps_js_1 = require("../projections/gaps.js");
10
+ const node_outputs_js_1 = require("../projections/node-outputs.js");
11
+ const constants_js_1 = require("../durable-core/constants.js");
12
+ const index_js_1 = require("../durable-core/ids/index.js");
13
+ const MAX_SESSIONS_TO_SCAN = 50;
14
+ class ConsoleService {
15
+ constructor(ports) {
16
+ this.ports = ports;
17
+ }
18
+ getSessionList() {
19
+ return (0, enumerate_sessions_js_1.enumerateSessions)({
20
+ directoryListing: this.ports.directoryListing,
21
+ dataDir: this.ports.dataDir,
22
+ })
23
+ .mapErr((fsErr) => ({
24
+ code: 'ENUMERATION_FAILED',
25
+ message: `Failed to enumerate sessions: ${fsErr.message}`,
26
+ }))
27
+ .andThen((sessionIds) => this.collectSessionSummaries(sessionIds.slice(0, MAX_SESSIONS_TO_SCAN)));
28
+ }
29
+ getSessionDetail(sessionIdStr) {
30
+ const sessionId = (0, index_js_1.asSessionId)(sessionIdStr);
31
+ return this.ports.sessionStore
32
+ .load(sessionId)
33
+ .mapErr((storeErr) => ({
34
+ code: 'SESSION_LOAD_FAILED',
35
+ message: `Failed to load session ${sessionIdStr}: ${storeErr.message}`,
36
+ }))
37
+ .map((truth) => projectSessionDetail(sessionId, truth));
38
+ }
39
+ collectSessionSummaries(sessionIds) {
40
+ return sessionIds.reduce((acc, sessionId) => acc.andThen((summaries) => this.loadSessionSummary(sessionId).map((summary) => summary !== null ? [...summaries, summary] : summaries)), (0, neverthrow_1.okAsync)([])).map((sessions) => ({ sessions, totalCount: sessions.length }));
41
+ }
42
+ loadSessionSummary(sessionId) {
43
+ return this.ports.sessionStore
44
+ .load(sessionId)
45
+ .map((truth) => projectSessionSummary(sessionId, truth))
46
+ .orElse(() => (0, neverthrow_1.okAsync)(null));
47
+ }
48
+ }
49
+ exports.ConsoleService = ConsoleService;
50
+ function projectSessionSummary(sessionId, truth) {
51
+ const { events } = truth;
52
+ const health = (0, session_health_js_1.projectSessionHealthV2)(truth);
53
+ if (health.isErr())
54
+ return null;
55
+ const sessionHealth = health.value.kind === 'healthy' ? 'healthy' : 'corrupt';
56
+ const dagRes = (0, run_dag_js_1.projectRunDagV2)(events);
57
+ if (dagRes.isErr())
58
+ return null;
59
+ const dag = dagRes.value;
60
+ const statusRes = (0, run_status_signals_js_1.projectRunStatusSignalsV2)(events);
61
+ const gapsRes = (0, gaps_js_1.projectGapsV2)(events);
62
+ const runs = Object.values(dag.runsById);
63
+ const run = runs[0];
64
+ if (!run) {
65
+ return {
66
+ sessionId,
67
+ workflowId: null,
68
+ workflowHash: null,
69
+ runId: null,
70
+ status: 'in_progress',
71
+ health: sessionHealth,
72
+ nodeCount: 0,
73
+ edgeCount: 0,
74
+ tipCount: 0,
75
+ hasUnresolvedGaps: false,
76
+ recapSnippet: null,
77
+ };
78
+ }
79
+ const workflow = run.workflow;
80
+ const workflowId = workflow.kind === 'with_workflow' ? workflow.workflowId : null;
81
+ const workflowHash = workflow.kind === 'with_workflow' ? workflow.workflowHash : null;
82
+ const statusSignals = statusRes.isOk() ? statusRes.value.byRunId[run.runId] : undefined;
83
+ const status = deriveRunStatus(statusSignals?.isBlocked ?? false, statusSignals?.hasUnresolvedCriticalGaps ?? false);
84
+ const hasUnresolvedGaps = gapsRes.isOk()
85
+ ? Object.keys(gapsRes.value.unresolvedCriticalByRunId).length > 0
86
+ : false;
87
+ const outputsRes = (0, node_outputs_js_1.projectNodeOutputsV2)(events);
88
+ let recapSnippet = null;
89
+ if (outputsRes.isOk() && run.preferredTipNodeId) {
90
+ const tipOutputs = outputsRes.value.nodesById[run.preferredTipNodeId];
91
+ if (tipOutputs) {
92
+ const recaps = tipOutputs.currentByChannel[constants_js_1.OUTPUT_CHANNEL.RECAP];
93
+ const latest = recaps?.at(-1);
94
+ if (latest && latest.payload.payloadKind === constants_js_1.PAYLOAD_KIND.NOTES) {
95
+ recapSnippet = latest.payload.notesMarkdown;
96
+ }
97
+ }
98
+ }
99
+ return {
100
+ sessionId,
101
+ workflowId,
102
+ workflowHash,
103
+ runId: run.runId,
104
+ status,
105
+ health: sessionHealth,
106
+ nodeCount: Object.keys(run.nodesById).length,
107
+ edgeCount: run.edges.length,
108
+ tipCount: run.tipNodeIds.length,
109
+ hasUnresolvedGaps,
110
+ recapSnippet,
111
+ };
112
+ }
113
+ function projectSessionDetail(sessionId, truth) {
114
+ const { events } = truth;
115
+ const health = (0, session_health_js_1.projectSessionHealthV2)(truth);
116
+ const sessionHealth = health.isOk() && health.value.kind === 'healthy' ? 'healthy' : 'corrupt';
117
+ const dagRes = (0, run_dag_js_1.projectRunDagV2)(events);
118
+ if (dagRes.isErr()) {
119
+ return { sessionId, health: sessionHealth, runs: [] };
120
+ }
121
+ const statusRes = (0, run_status_signals_js_1.projectRunStatusSignalsV2)(events);
122
+ const gapsRes = (0, gaps_js_1.projectGapsV2)(events);
123
+ const runs = Object.values(dagRes.value.runsById).map((run) => {
124
+ const statusSignals = statusRes.isOk() ? statusRes.value.byRunId[run.runId] : undefined;
125
+ const status = deriveRunStatus(statusSignals?.isBlocked ?? false, statusSignals?.hasUnresolvedCriticalGaps ?? false);
126
+ const tipSet = new Set(run.tipNodeIds);
127
+ const nodes = Object.values(run.nodesById).map((node) => ({
128
+ nodeId: node.nodeId,
129
+ nodeKind: node.nodeKind,
130
+ parentNodeId: node.parentNodeId,
131
+ createdAtEventIndex: node.createdAtEventIndex,
132
+ isPreferredTip: node.nodeId === run.preferredTipNodeId,
133
+ isTip: tipSet.has(node.nodeId),
134
+ }));
135
+ const edges = run.edges.map((edge) => ({
136
+ edgeKind: edge.edgeKind,
137
+ fromNodeId: edge.fromNodeId,
138
+ toNodeId: edge.toNodeId,
139
+ createdAtEventIndex: edge.createdAtEventIndex,
140
+ }));
141
+ const workflow = run.workflow;
142
+ return {
143
+ runId: run.runId,
144
+ workflowId: workflow.kind === 'with_workflow' ? workflow.workflowId : null,
145
+ workflowHash: workflow.kind === 'with_workflow' ? workflow.workflowHash : null,
146
+ preferredTipNodeId: run.preferredTipNodeId,
147
+ nodes,
148
+ edges,
149
+ tipNodeIds: [...run.tipNodeIds],
150
+ status,
151
+ hasUnresolvedCriticalGaps: gapsRes.isOk()
152
+ ? (gapsRes.value.unresolvedCriticalByRunId[run.runId]?.length ?? 0) > 0
153
+ : false,
154
+ };
155
+ });
156
+ return { sessionId, health: sessionHealth, runs };
157
+ }
158
+ function deriveRunStatus(isBlocked, hasUnresolvedCriticalGaps) {
159
+ if (isBlocked)
160
+ return 'blocked';
161
+ if (hasUnresolvedCriticalGaps)
162
+ return 'complete_with_gaps';
163
+ return 'in_progress';
164
+ }
@@ -0,0 +1,49 @@
1
+ export type ConsoleRunStatus = 'in_progress' | 'complete' | 'complete_with_gaps' | 'blocked';
2
+ export type ConsoleSessionHealth = 'healthy' | 'corrupt';
3
+ export interface ConsoleSessionSummary {
4
+ readonly sessionId: string;
5
+ readonly workflowId: string | null;
6
+ readonly workflowHash: string | null;
7
+ readonly runId: string | null;
8
+ readonly status: ConsoleRunStatus;
9
+ readonly health: ConsoleSessionHealth;
10
+ readonly nodeCount: number;
11
+ readonly edgeCount: number;
12
+ readonly tipCount: number;
13
+ readonly hasUnresolvedGaps: boolean;
14
+ readonly recapSnippet: string | null;
15
+ }
16
+ export interface ConsoleSessionListResponse {
17
+ readonly sessions: readonly ConsoleSessionSummary[];
18
+ readonly totalCount: number;
19
+ }
20
+ export interface ConsoleDagNode {
21
+ readonly nodeId: string;
22
+ readonly nodeKind: 'step' | 'checkpoint' | 'blocked_attempt';
23
+ readonly parentNodeId: string | null;
24
+ readonly createdAtEventIndex: number;
25
+ readonly isPreferredTip: boolean;
26
+ readonly isTip: boolean;
27
+ }
28
+ export interface ConsoleDagEdge {
29
+ readonly edgeKind: 'acked_step' | 'checkpoint';
30
+ readonly fromNodeId: string;
31
+ readonly toNodeId: string;
32
+ readonly createdAtEventIndex: number;
33
+ }
34
+ export interface ConsoleDagRun {
35
+ readonly runId: string;
36
+ readonly workflowId: string | null;
37
+ readonly workflowHash: string | null;
38
+ readonly preferredTipNodeId: string | null;
39
+ readonly nodes: readonly ConsoleDagNode[];
40
+ readonly edges: readonly ConsoleDagEdge[];
41
+ readonly tipNodeIds: readonly string[];
42
+ readonly status: ConsoleRunStatus;
43
+ readonly hasUnresolvedCriticalGaps: boolean;
44
+ }
45
+ export interface ConsoleSessionDetail {
46
+ readonly sessionId: string;
47
+ readonly health: ConsoleSessionHealth;
48
+ readonly runs: readonly ConsoleDagRun[];
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,3 +7,7 @@ export declare function enumerateSessions(ports: {
7
7
  readonly directoryListing: DirectoryListingPortV2;
8
8
  readonly dataDir: DataDirPortV2;
9
9
  }): ResultAsync<readonly SessionId[], FsError>;
10
+ export declare function enumerateSessionsByRecency(ports: {
11
+ readonly directoryListing: DirectoryListingPortV2;
12
+ readonly dataDir: DataDirPortV2;
13
+ }): ResultAsync<readonly SessionId[], FsError>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enumerateSessions = enumerateSessions;
4
+ exports.enumerateSessionsByRecency = enumerateSessionsByRecency;
4
5
  const index_js_1 = require("../durable-core/ids/index.js");
5
6
  const SESSION_DIR_PATTERN = /^sess_[a-zA-Z0-9_]+$/;
6
7
  function enumerateSessions(ports) {
@@ -11,3 +12,15 @@ function enumerateSessions(ports) {
11
12
  .sort()
12
13
  .map((entry) => (0, index_js_1.asSessionId)(entry)));
13
14
  }
15
+ function enumerateSessionsByRecency(ports) {
16
+ return ports.directoryListing
17
+ .readdirWithMtime(ports.dataDir.sessionsDir())
18
+ .map((entries) => entries
19
+ .filter((entry) => SESSION_DIR_PATTERN.test(entry.name))
20
+ .sort((a, b) => {
21
+ if (a.mtimeMs !== b.mtimeMs)
22
+ return b.mtimeMs - a.mtimeMs;
23
+ return a.name.localeCompare(b.name);
24
+ })
25
+ .map((entry) => (0, index_js_1.asSessionId)(entry.name)));
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "Step-by-step workflow enforcement for AI agents via MCP",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,10 @@
21
21
  "web"
22
22
  ],
23
23
  "scripts": {
24
- "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});\" && tsc -p tsconfig.build.json",
24
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});\" && tsc -p tsconfig.build.json && npm run console:build",
25
+ "console:build": "cd console && npm install && npm run build",
26
+ "console:dev": "cd console && npm run dev",
27
+ "build:all": "npm run build",
25
28
  "docs:workflows": "node scripts/generate-workflow-docs.js",
26
29
  "generate:locks": "npx ts-node scripts/generate-lock-coverage.ts && npx ts-node scripts/generate-lock-coverage.ts --json",
27
30
  "verify:generated": "npm run generate:locks && git diff --exit-code -- docs/generated/v2-lock-coverage.json docs/generated/v2-lock-coverage.md docs/generated/v2-lock-closure-plan.md",