@exaudeus/workrail 1.13.2 → 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.
@@ -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
  }
@@ -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",
@@ -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",
@@ -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",
@@ -2177,6 +2177,30 @@
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
2205
  "sha256": "46da8960bdeb154f79dee443425260f3ce18c50a0db01e7ab60700432d864857",
2182
2206
  "bytes": 699
@@ -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
  });
@@ -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()
@@ -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 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "1.13.2",
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",