@exaudeus/workrail 3.7.1 → 3.7.3

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.
@@ -240,7 +240,8 @@ async function createWorkRailEngine(config = {}) {
240
240
  engineActive = true;
241
241
  const engine = {
242
242
  async startWorkflow(workflowId) {
243
- const result = await (0, start_js_1.executeStartWorkflow)({ workflowId }, v2Ctx);
243
+ const workspacePath = process.cwd();
244
+ const result = await (0, start_js_1.executeStartWorkflow)({ workflowId, workspacePath }, v2Ctx);
244
245
  if (result.isErr()) {
245
246
  return (0, types_js_1.engineErr)(mapStartError(result.error));
246
247
  }
@@ -248,9 +249,11 @@ async function createWorkRailEngine(config = {}) {
248
249
  },
249
250
  async continueWorkflow(stateToken, ackToken, output, context) {
250
251
  const intent = ackToken ? 'advance' : 'rehydrate';
252
+ const workspacePath = process.cwd();
251
253
  const input = {
252
254
  continueToken: (0, types_js_1.unwrapToken)(stateToken),
253
255
  intent: intent,
256
+ ...(intent === 'rehydrate' ? { workspacePath } : {}),
254
257
  ...(output ? {
255
258
  output: {
256
259
  notesMarkdown: output.notesMarkdown,
@@ -438,8 +438,8 @@
438
438
  "bytes": 213
439
439
  },
440
440
  "engine/engine-factory.js": {
441
- "sha256": "07d88be2ab8488615871ae363b9db4fc23caebba8231c8c2aaa2f97da2b18fdd",
442
- "bytes": 13658
441
+ "sha256": "5461827b470642059198115f5248e97463db9bfb012f63971a4c7f69acda5b7c",
442
+ "bytes": 13841
443
443
  },
444
444
  "engine/index.d.ts": {
445
445
  "sha256": "91e12882c565e96a9809fdf43a0dc0a77fdffdfd562aaf43d2e86e6590ed0b16",
@@ -670,8 +670,8 @@
670
670
  "bytes": 883
671
671
  },
672
672
  "mcp/handler-factory.js": {
673
- "sha256": "1216fe5e913c832242b3c9c2d9954441300b08660db59fe9deac8a4b7dc583db",
674
- "bytes": 5310
673
+ "sha256": "6eb67d1501582d1cfcf777d7d930a6cf3cb32ccbd450c7083133745ef27d2661",
674
+ "bytes": 5381
675
675
  },
676
676
  "mcp/handlers/session.d.ts": {
677
677
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
@@ -838,8 +838,8 @@
838
838
  "bytes": 3422
839
839
  },
840
840
  "mcp/handlers/v2-execution/start.js": {
841
- "sha256": "593edf798bb1d2d0011ec81e4f170e4f4003b978cd9900fd785b583d15cd1085",
842
- "bytes": 18014
841
+ "sha256": "e572eb50c6a0a30aa138620f32b04702727f07ce2570c29022d1027981c4bcef",
842
+ "bytes": 18496
843
843
  },
844
844
  "mcp/handlers/v2-reference-resolver.d.ts": {
845
845
  "sha256": "0b1d2640306b6a0c1067ca66bb20e6ec35d291b33dc328a78d5bfa8006394234",
@@ -862,8 +862,8 @@
862
862
  "bytes": 471
863
863
  },
864
864
  "mcp/handlers/v2-resume.js": {
865
- "sha256": "726f92eb12aa0b28fafc4ceef354500dac7c4f18b85c4fe02a7997f869fe533f",
866
- "bytes": 3612
865
+ "sha256": "536ba5db0c8fedf8a55c63a59eae4da5ad1cc793e4abf137a5ac9536e6514f68",
866
+ "bytes": 4140
867
867
  },
868
868
  "mcp/handlers/v2-state-conversion.d.ts": {
869
869
  "sha256": "94bd06904ef58dd210ff17ffb75c2492beea8937eb06d99749e5d860c0e0d96b",
@@ -914,12 +914,12 @@
914
914
  "bytes": 7991
915
915
  },
916
916
  "mcp/output-schemas.d.ts": {
917
- "sha256": "450ac819bddaf668eb662b8327591df72b68d553fb16a7bd7797fadc68b8b8c8",
918
- "bytes": 51526
917
+ "sha256": "191d696fd1c8d7dc8f1908c903f84117ceaed6c0aa323fb7606dd3566d739689",
918
+ "bytes": 53246
919
919
  },
920
920
  "mcp/output-schemas.js": {
921
- "sha256": "73c8cd97868afd6f6e6f3deac1a3aabc38384f82c532be91bd5ea6ad2f744a49",
922
- "bytes": 13044
921
+ "sha256": "28aa9b75ef6c21522b458bd4d05c55e28673510356f8f7e56eb1304544d35132",
922
+ "bytes": 14384
923
923
  },
924
924
  "mcp/render-envelope.d.ts": {
925
925
  "sha256": "22e83e1aba52968a7136cf289125a217b5f462a5a66a1eebe4669006e3326fdb",
@@ -942,8 +942,8 @@
942
942
  "bytes": 960
943
943
  },
944
944
  "mcp/server.js": {
945
- "sha256": "1e5faf28495dff31b83b9f86ba07e05e14fb88c757f4e9e3460235f92c0602ab",
946
- "bytes": 11642
945
+ "sha256": "9689ba068eaac9f36f328fa5429b5abe84bb8bd0062f0a59b60dc361dea09cd2",
946
+ "bytes": 11677
947
947
  },
948
948
  "mcp/step-content-envelope.d.ts": {
949
949
  "sha256": "19bd63c4d4de1d5d93393d346625d28ffd1bebdc320d4ba4e694cb740ec97d3b",
@@ -1058,12 +1058,12 @@
1058
1058
  "bytes": 2674
1059
1059
  },
1060
1060
  "mcp/v2-response-formatter.d.ts": {
1061
- "sha256": "b0dfb56016eabbc61fdb9d1f668d35c3fba7e8060b70be5aa74356ae0334ff0e",
1062
- "bytes": 438
1061
+ "sha256": "3dd2bb5beef01afc8dca6b3df8bfd52283dc4393c5d85d2906a56bf4ae9806c9",
1062
+ "bytes": 527
1063
1063
  },
1064
1064
  "mcp/v2-response-formatter.js": {
1065
- "sha256": "76615380b865b264d8c124231bae44d285ae738a17dc3b7b2ff5906c08eee646",
1066
- "bytes": 14437
1065
+ "sha256": "308cc7c1fedd491f5d38607869d4b4e1196bfcf450835a53d52154827b323e23",
1066
+ "bytes": 22402
1067
1067
  },
1068
1068
  "mcp/v2/tool-registry.d.ts": {
1069
1069
  "sha256": "d4d4927728c3cab1c014661d499dd0119538371bc6c5e821a4cd31df7abebedf",
@@ -1074,12 +1074,12 @@
1074
1074
  "bytes": 3276
1075
1075
  },
1076
1076
  "mcp/v2/tools.d.ts": {
1077
- "sha256": "8802e914f1eae0cfcd5b9b7838d00a3a87c8416c1ade1fce1ee57e7744bf64b9",
1078
- "bytes": 7010
1077
+ "sha256": "93f1eac69e9d2be8ca354d714fbc64e3cea0e235e6669847677071d83a66450f",
1078
+ "bytes": 7288
1079
1079
  },
1080
1080
  "mcp/v2/tools.js": {
1081
- "sha256": "a275de4ce4ccf31d429ce2c32f86169485676aad6f41cfe9babc3f00df2495a1",
1082
- "bytes": 8838
1081
+ "sha256": "2b5d12d4de385ca8c530532d12467f113d58a09a808fe075896d2b1c0caa52ae",
1082
+ "bytes": 10071
1083
1083
  },
1084
1084
  "mcp/validation/bounded-json.d.ts": {
1085
1085
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -1150,8 +1150,8 @@
1150
1150
  "bytes": 1863
1151
1151
  },
1152
1152
  "mcp/workflow-protocol-contracts.js": {
1153
- "sha256": "715cf1dfa780a62b5b5dc08a3da9cbba3d444dc75c1d68db0b5c2ede804c5bd3",
1154
- "bytes": 12840
1153
+ "sha256": "250fb814372bbf75a4cff9adc2d257da4cf0f4f480dac263860e74ebdd405246",
1154
+ "bytes": 13981
1155
1155
  },
1156
1156
  "mcp/workflow-tool-edition-selector.d.ts": {
1157
1157
  "sha256": "75194908a89aaf7dc48fb661aea099827e7032ec76daf8f2de91bd59d46764ef",
@@ -1802,7 +1802,7 @@
1802
1802
  "bytes": 3397
1803
1803
  },
1804
1804
  "v2/durable-core/schemas/export-bundle/index.d.ts": {
1805
- "sha256": "a0c0c9c904b11e79f403bec154e118583709d1440916b7e30b1f3101b87acbf2",
1805
+ "sha256": "6521642cefd019f75dba36890b71c20c5508e04baef584a09557a4b98f894321",
1806
1806
  "bytes": 479848
1807
1807
  },
1808
1808
  "v2/durable-core/schemas/export-bundle/index.js": {
@@ -1882,7 +1882,7 @@
1882
1882
  "bytes": 715
1883
1883
  },
1884
1884
  "v2/durable-core/schemas/session/manifest.d.ts": {
1885
- "sha256": "3eff60c200f81c87bb0e0946ba23000bc30fdd98678d316e5a401c189612408b",
1885
+ "sha256": "82840f71d8cde0d10834fe411c9ea494e043af93637c4ffb9c14fdf27bbb1b8c",
1886
1886
  "bytes": 1594
1887
1887
  },
1888
1888
  "v2/durable-core/schemas/session/manifest.js": {
@@ -1938,7 +1938,7 @@
1938
1938
  "bytes": 4205
1939
1939
  },
1940
1940
  "v2/durable-core/tokens/payloads.d.ts": {
1941
- "sha256": "f0428631b6addaa4c842a1abb4d9e4b1f26cb647b6f42a99060114ccb64eab28",
1941
+ "sha256": "4b84627aeee7c8f6d4c142e9ffb3511674d74d012601731d81193dfd6b95ba1c",
1942
1942
  "bytes": 6921
1943
1943
  },
1944
1944
  "v2/durable-core/tokens/payloads.js": {
@@ -2114,12 +2114,12 @@
2114
2114
  "bytes": 28456
2115
2115
  },
2116
2116
  "v2/infra/local/session-summary-provider/index.d.ts": {
2117
- "sha256": "59db8bf5e38f983eedd21ff902a24324f7bedbb5f3eade1e4b0d5742b28447c2",
2118
- "bytes": 1004
2117
+ "sha256": "291d1303ef9f1ee0889830c5b42964a2d9b8c7d27b36a9b55d710ca5950c32ca",
2118
+ "bytes": 1136
2119
2119
  },
2120
2120
  "v2/infra/local/session-summary-provider/index.js": {
2121
- "sha256": "1d8a543361c582f6e089f63f24318ff7caf97a78659ecdc5b89152b78d18c6aa",
2122
- "bytes": 5942
2121
+ "sha256": "504d432a35b3ceb75697c00b5db1576570b38c1415304f903ba77d0dfed04ce7",
2122
+ "bytes": 10452
2123
2123
  },
2124
2124
  "v2/infra/local/sha256/index.d.ts": {
2125
2125
  "sha256": "8a727b7e54a38275ca6f9f1b8730f97cfc0a212df035df1bdc58e716e6824230",
@@ -2166,8 +2166,8 @@
2166
2166
  "bytes": 537
2167
2167
  },
2168
2168
  "v2/infra/local/workspace-anchor/index.js": {
2169
- "sha256": "a0fe032a9205606c6d592221f1300a3113c7d0cb3e126e458fef3dc8fa6e823c",
2170
- "bytes": 2272
2169
+ "sha256": "d76172ecbe3457760abc0b6f0032eb4089758fb3c9ed473ba0f134ac57d37c1a",
2170
+ "bytes": 2993
2171
2171
  },
2172
2172
  "v2/ports/base32.port.d.ts": {
2173
2173
  "sha256": "64aa2f2003a552917cbf71474472fc5e4afffaa29577204bbcbe5ffa989ceb82",
@@ -2386,12 +2386,12 @@
2386
2386
  "bytes": 732
2387
2387
  },
2388
2388
  "v2/projections/resume-ranking.d.ts": {
2389
- "sha256": "ff128aa669f995b350a1e4ee8da6f0321f999d492e23975816d3f70caefa4dbb",
2390
- "bytes": 2595
2389
+ "sha256": "b1d9e7d6fb3e59ced42f7c2e5fd9d8f9a18308aa6f4411a8aabf5dc174aa8dad",
2390
+ "bytes": 3960
2391
2391
  },
2392
2392
  "v2/projections/resume-ranking.js": {
2393
- "sha256": "381dbac1868bc88bdfa3e3c13da94b1392ba3858f2bc86cc3c4331e919aac899",
2394
- "bytes": 4300
2393
+ "sha256": "1b256c992ded9ec52150b229799716d118ca2a3659a0cc523e727cde2ebf7b0c",
2394
+ "bytes": 13660
2395
2395
  },
2396
2396
  "v2/projections/run-context.d.ts": {
2397
2397
  "sha256": "a4d57470a435ac9860f60b3244d1b828853995027cd510d8da42762d21b2a687",
@@ -2458,12 +2458,12 @@
2458
2458
  "bytes": 77
2459
2459
  },
2460
2460
  "v2/usecases/enumerate-sessions.d.ts": {
2461
- "sha256": "46da8960bdeb154f79dee443425260f3ce18c50a0db01e7ab60700432d864857",
2462
- "bytes": 699
2461
+ "sha256": "230eda9e0f377741cb9018edba4b8c26cecde9439e2db68b249b0cab3e9e50aa",
2462
+ "bytes": 809
2463
2463
  },
2464
2464
  "v2/usecases/enumerate-sessions.js": {
2465
- "sha256": "4ae73f47c1e8ebea0d9a48dc786e5e4d0442a38827c427378712e9d198410ae2",
2466
- "bytes": 1050
2465
+ "sha256": "7fd54b65e914487ea0cfbc60e7059aa1134b3f9850ae2af0fdba340f9aa0b282",
2466
+ "bytes": 1091
2467
2467
  },
2468
2468
  "v2/usecases/execution-session-gate.d.ts": {
2469
2469
  "sha256": "339c4a8e02a77416e725e063a57d39a20788244498ae2c7a31dc48d111af6280",
@@ -14,7 +14,7 @@ function toMcpResult(result) {
14
14
  switch (result.type) {
15
15
  case 'success': {
16
16
  if (!jsonResponsesOverride) {
17
- const formatted = (0, v2_response_formatter_js_1.formatV2ExecutionResponse)(result.data);
17
+ const formatted = (0, v2_response_formatter_js_1.formatV2ExecutionResponse)(result.data) ?? (0, v2_response_formatter_js_1.formatV2ResumeResponse)(result.data);
18
18
  if (formatted !== null) {
19
19
  const content = [{ type: 'text', text: formatted.primary }];
20
20
  if (formatted.references != null) {
@@ -212,15 +212,24 @@ function mintStartTokens(args) {
212
212
  }
213
213
  function executeStartWorkflow(input, ctx) {
214
214
  const { gate, sessionStore, snapshotStore, pinnedStore, crypto, tokenCodecPorts, idFactory, validationPipelineDeps, tokenAliasStore, entropy } = ctx.v2;
215
- const workflowReader = (0, request_workflow_reader_js_1.hasRequestWorkspaceSignal)({
215
+ const shouldUseRequestReader = ctx.featureFlags != null && (0, request_workflow_reader_js_1.hasRequestWorkspaceSignal)({
216
216
  workspacePath: input.workspacePath,
217
217
  resolvedRootUris: ctx.v2.resolvedRootUris,
218
- })
219
- ? (0, request_workflow_reader_js_1.createWorkflowReaderForRequest)({
220
- featureFlags: ctx.featureFlags,
221
- workspacePath: input.workspacePath,
222
- resolvedRootUris: ctx.v2.resolvedRootUris,
223
- })
218
+ });
219
+ const workflowReader = shouldUseRequestReader
220
+ ? {
221
+ getWorkflowById: async (workflowId) => {
222
+ const requestReader = (0, request_workflow_reader_js_1.createWorkflowReaderForRequest)({
223
+ featureFlags: ctx.featureFlags,
224
+ workspacePath: input.workspacePath,
225
+ resolvedRootUris: ctx.v2.resolvedRootUris,
226
+ });
227
+ const requestResult = await requestReader.getWorkflowById(workflowId);
228
+ if (requestResult != null)
229
+ return requestResult;
230
+ return ctx.workflowService.getWorkflowById(workflowId);
231
+ },
232
+ }
224
233
  : ctx.workflowService;
225
234
  return loadAndPinWorkflow({
226
235
  workflowId: input.workflowId,
@@ -24,7 +24,11 @@ async function handleV2ResumeSession(input, ctx) {
24
24
  const query = {
25
25
  gitHeadSha: input.gitHeadSha ?? anchorValue(anchors, 'git_head_sha'),
26
26
  gitBranch: input.gitBranch ?? anchorValue(anchors, 'git_branch'),
27
+ repoRootHash: anchorValue(anchors, 'repo_root_hash'),
28
+ sameWorkspaceOnly: input.sameWorkspaceOnly,
27
29
  freeTextQuery: input.query,
30
+ runId: input.runId,
31
+ sessionId: input.sessionId,
28
32
  };
29
33
  const resumeResult = await (0, resume_session_js_1.resumeSession)(query, v2.sessionSummaryProvider);
30
34
  if (resumeResult.isErr()) {
@@ -72,9 +76,16 @@ function mintCandidateTokens(candidates, ports) {
72
76
  sessionId: candidate.sessionId,
73
77
  runId: candidate.runId,
74
78
  workflowId: candidate.workflowId,
79
+ sessionTitle: candidate.sessionTitle,
80
+ gitBranch: candidate.gitBranch,
75
81
  resumeToken: resumeTokenRes.value,
76
82
  snippet: candidate.snippet,
77
83
  whyMatched: [...candidate.whyMatched],
84
+ confidence: candidate.confidence,
85
+ matchExplanation: candidate.matchExplanation,
86
+ pendingStepId: candidate.pendingStepId,
87
+ isComplete: candidate.isComplete,
88
+ lastModifiedMs: candidate.lastModifiedMs,
78
89
  nextCall: {
79
90
  tool: 'continue_workflow',
80
91
  params: { continueToken: resumeTokenRes.value, intent: 'rehydrate' },
@@ -1160,9 +1160,16 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1160
1160
  sessionId: z.ZodString;
1161
1161
  runId: z.ZodString;
1162
1162
  workflowId: z.ZodString;
1163
+ sessionTitle: z.ZodNullable<z.ZodString>;
1164
+ gitBranch: z.ZodNullable<z.ZodString>;
1163
1165
  resumeToken: z.ZodString;
1164
1166
  snippet: z.ZodString;
1165
- whyMatched: z.ZodArray<z.ZodEnum<["matched_head_sha", "matched_branch", "matched_notes", "matched_workflow_id", "recency_fallback"]>, "many">;
1167
+ confidence: z.ZodEnum<["strong", "medium", "weak"]>;
1168
+ matchExplanation: z.ZodString;
1169
+ pendingStepId: z.ZodNullable<z.ZodString>;
1170
+ isComplete: z.ZodBoolean;
1171
+ lastModifiedMs: z.ZodNullable<z.ZodNumber>;
1172
+ whyMatched: z.ZodArray<z.ZodEnum<["matched_exact_id", "matched_notes", "matched_notes_partial", "matched_workflow_id", "matched_head_sha", "matched_branch", "matched_repo_root", "recency_fallback"]>, "many">;
1166
1173
  nextCall: z.ZodObject<{
1167
1174
  tool: z.ZodLiteral<"continue_workflow">;
1168
1175
  params: z.ZodObject<{
@@ -1189,9 +1196,12 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1189
1196
  tool: "continue_workflow";
1190
1197
  }>;
1191
1198
  }, "strip", z.ZodTypeAny, {
1199
+ confidence: "strong" | "weak" | "medium";
1192
1200
  workflowId: string;
1193
- sessionId: string;
1194
1201
  runId: string;
1202
+ sessionId: string;
1203
+ gitBranch: string | null;
1204
+ isComplete: boolean;
1195
1205
  nextCall: {
1196
1206
  params: {
1197
1207
  continueToken: string;
@@ -1199,13 +1209,20 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1199
1209
  };
1200
1210
  tool: "continue_workflow";
1201
1211
  };
1212
+ sessionTitle: string | null;
1202
1213
  resumeToken: string;
1203
1214
  snippet: string;
1204
- whyMatched: ("matched_head_sha" | "matched_branch" | "matched_notes" | "matched_workflow_id" | "recency_fallback")[];
1215
+ matchExplanation: string;
1216
+ pendingStepId: string | null;
1217
+ lastModifiedMs: number | null;
1218
+ whyMatched: ("matched_exact_id" | "matched_notes" | "matched_notes_partial" | "matched_workflow_id" | "matched_head_sha" | "matched_branch" | "matched_repo_root" | "recency_fallback")[];
1205
1219
  }, {
1220
+ confidence: "strong" | "weak" | "medium";
1206
1221
  workflowId: string;
1207
- sessionId: string;
1208
1222
  runId: string;
1223
+ sessionId: string;
1224
+ gitBranch: string | null;
1225
+ isComplete: boolean;
1209
1226
  nextCall: {
1210
1227
  params: {
1211
1228
  continueToken: string;
@@ -1213,16 +1230,23 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1213
1230
  };
1214
1231
  tool: "continue_workflow";
1215
1232
  };
1233
+ sessionTitle: string | null;
1216
1234
  resumeToken: string;
1217
1235
  snippet: string;
1218
- whyMatched: ("matched_head_sha" | "matched_branch" | "matched_notes" | "matched_workflow_id" | "recency_fallback")[];
1236
+ matchExplanation: string;
1237
+ pendingStepId: string | null;
1238
+ lastModifiedMs: number | null;
1239
+ whyMatched: ("matched_exact_id" | "matched_notes" | "matched_notes_partial" | "matched_workflow_id" | "matched_head_sha" | "matched_branch" | "matched_repo_root" | "recency_fallback")[];
1219
1240
  }>, "many">;
1220
1241
  totalEligible: z.ZodNumber;
1221
1242
  }, "strip", z.ZodTypeAny, {
1222
1243
  candidates: {
1244
+ confidence: "strong" | "weak" | "medium";
1223
1245
  workflowId: string;
1224
- sessionId: string;
1225
1246
  runId: string;
1247
+ sessionId: string;
1248
+ gitBranch: string | null;
1249
+ isComplete: boolean;
1226
1250
  nextCall: {
1227
1251
  params: {
1228
1252
  continueToken: string;
@@ -1230,16 +1254,23 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1230
1254
  };
1231
1255
  tool: "continue_workflow";
1232
1256
  };
1257
+ sessionTitle: string | null;
1233
1258
  resumeToken: string;
1234
1259
  snippet: string;
1235
- whyMatched: ("matched_head_sha" | "matched_branch" | "matched_notes" | "matched_workflow_id" | "recency_fallback")[];
1260
+ matchExplanation: string;
1261
+ pendingStepId: string | null;
1262
+ lastModifiedMs: number | null;
1263
+ whyMatched: ("matched_exact_id" | "matched_notes" | "matched_notes_partial" | "matched_workflow_id" | "matched_head_sha" | "matched_branch" | "matched_repo_root" | "recency_fallback")[];
1236
1264
  }[];
1237
1265
  totalEligible: number;
1238
1266
  }, {
1239
1267
  candidates: {
1268
+ confidence: "strong" | "weak" | "medium";
1240
1269
  workflowId: string;
1241
- sessionId: string;
1242
1270
  runId: string;
1271
+ sessionId: string;
1272
+ gitBranch: string | null;
1273
+ isComplete: boolean;
1243
1274
  nextCall: {
1244
1275
  params: {
1245
1276
  continueToken: string;
@@ -1247,9 +1278,13 @@ export declare const V2ResumeSessionOutputSchema: z.ZodObject<{
1247
1278
  };
1248
1279
  tool: "continue_workflow";
1249
1280
  };
1281
+ sessionTitle: string | null;
1250
1282
  resumeToken: string;
1251
1283
  snippet: string;
1252
- whyMatched: ("matched_head_sha" | "matched_branch" | "matched_notes" | "matched_workflow_id" | "recency_fallback")[];
1284
+ matchExplanation: string;
1285
+ pendingStepId: string | null;
1286
+ lastModifiedMs: number | null;
1287
+ whyMatched: ("matched_exact_id" | "matched_notes" | "matched_notes_partial" | "matched_workflow_id" | "matched_head_sha" | "matched_branch" | "matched_repo_root" | "recency_fallback")[];
1253
1288
  }[];
1254
1289
  totalEligible: number;
1255
1290
  }>;
@@ -242,16 +242,29 @@ exports.V2ResumeSessionOutputSchema = zod_1.z.object({
242
242
  sessionId: zod_1.z.string().min(1),
243
243
  runId: zod_1.z.string().min(1),
244
244
  workflowId: zod_1.z.string().min(1),
245
+ sessionTitle: zod_1.z.string().nullable().describe('Human-readable task/session title derived from persisted workflow context or early recap text.'),
246
+ gitBranch: zod_1.z.string().nullable().describe('Git branch associated with the session, if available.'),
245
247
  resumeToken: zod_1.z.string().regex(token_patterns_js_1.STATE_TOKEN_PATTERN, 'Invalid resumeToken format'),
246
248
  snippet: zod_1.z.string().max(1024),
249
+ confidence: zod_1.z.enum(['strong', 'medium', 'weak']).describe('Coarse confidence band for how likely this candidate is the intended session.'),
250
+ matchExplanation: zod_1.z.string().min(1).describe('Short natural-language explanation of why this candidate ranked here.'),
251
+ pendingStepId: zod_1.z.string().nullable().describe('The current pending step ID (e.g. "phase-3-implement") if the workflow is in progress. ' +
252
+ 'Null if the workflow is complete or the step could not be determined.'),
253
+ isComplete: zod_1.z.boolean().describe('Whether the workflow run has completed. Completed sessions are deprioritized in ranking.'),
254
+ lastModifiedMs: zod_1.z.number().nullable().describe('Filesystem modification time (epoch ms) of the session. Null if unavailable.'),
247
255
  whyMatched: zod_1.z.array(zod_1.z.enum([
248
- 'matched_head_sha',
249
- 'matched_branch',
256
+ 'matched_exact_id',
250
257
  'matched_notes',
258
+ 'matched_notes_partial',
251
259
  'matched_workflow_id',
260
+ 'matched_head_sha',
261
+ 'matched_branch',
262
+ 'matched_repo_root',
252
263
  'recency_fallback',
253
264
  ])).describe('Match signals explaining why this candidate was ranked. ' +
254
- 'matched_head_sha/branch/notes/workflow_id = strong signal. ' +
265
+ 'matched_exact_id and matched_notes are strongest. ' +
266
+ 'matched_notes_partial/matched_workflow_id are moderate text signals. ' +
267
+ 'matched_repo_root/head_sha/branch are workspace-context signals. ' +
255
268
  'recency_fallback = no strong signal; inspect the snippet before resuming.'),
256
269
  nextCall: exports.V2ResumeNextCallSchema,
257
270
  })).max(5),
@@ -129,6 +129,7 @@ async function createToolContext() {
129
129
  directoryListing,
130
130
  dataDir,
131
131
  sessionStore,
132
+ snapshotStore,
132
133
  }),
133
134
  };
134
135
  console.error('[FeatureFlags] v2 tools enabled');
@@ -24,13 +24,13 @@ export declare const V2InspectWorkflowInput: z.ZodObject<{
24
24
  export type V2InspectWorkflowInput = z.infer<typeof V2InspectWorkflowInput>;
25
25
  export declare const V2StartWorkflowInput: z.ZodObject<{
26
26
  workflowId: z.ZodString;
27
- workspacePath: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
27
+ workspacePath: z.ZodEffects<z.ZodString, string, string>;
28
28
  }, "strip", z.ZodTypeAny, {
29
29
  workflowId: string;
30
- workspacePath?: string | undefined;
30
+ workspacePath: string;
31
31
  }, {
32
32
  workflowId: string;
33
- workspacePath?: string | undefined;
33
+ workspacePath: string;
34
34
  }>;
35
35
  export type V2StartWorkflowInput = z.infer<typeof V2StartWorkflowInput>;
36
36
  export declare const V2ContinueWorkflowInputShape: z.ZodObject<{
@@ -147,19 +147,28 @@ export declare const V2ContinueWorkflowInput: z.ZodEffects<z.ZodEffects<z.ZodObj
147
147
  export type V2ContinueWorkflowInput = z.infer<typeof V2ContinueWorkflowInput>;
148
148
  export declare const V2ResumeSessionInput: z.ZodObject<{
149
149
  query: z.ZodOptional<z.ZodString>;
150
+ runId: z.ZodOptional<z.ZodString>;
151
+ sessionId: z.ZodOptional<z.ZodString>;
150
152
  gitBranch: z.ZodOptional<z.ZodString>;
151
153
  gitHeadSha: z.ZodOptional<z.ZodString>;
152
- workspacePath: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
154
+ workspacePath: z.ZodEffects<z.ZodString, string, string>;
155
+ sameWorkspaceOnly: z.ZodOptional<z.ZodBoolean>;
153
156
  }, "strict", z.ZodTypeAny, {
154
- workspacePath?: string | undefined;
157
+ workspacePath: string;
155
158
  query?: string | undefined;
159
+ runId?: string | undefined;
160
+ sessionId?: string | undefined;
156
161
  gitBranch?: string | undefined;
157
162
  gitHeadSha?: string | undefined;
163
+ sameWorkspaceOnly?: boolean | undefined;
158
164
  }, {
159
- workspacePath?: string | undefined;
165
+ workspacePath: string;
160
166
  query?: string | undefined;
167
+ runId?: string | undefined;
168
+ sessionId?: string | undefined;
161
169
  gitBranch?: string | undefined;
162
170
  gitHeadSha?: string | undefined;
171
+ sameWorkspaceOnly?: boolean | undefined;
163
172
  }>;
164
173
  export type V2ResumeSessionInput = z.infer<typeof V2ResumeSessionInput>;
165
174
  export declare const V2CheckpointWorkflowInput: z.ZodObject<{
@@ -1,26 +1,33 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.V2_TOOL_ANNOTATIONS = exports.V2_TOOL_TITLES = exports.V2CheckpointWorkflowInput = exports.V2ResumeSessionInput = exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape = exports.V2StartWorkflowInput = exports.V2InspectWorkflowInput = exports.V2ListWorkflowsInput = void 0;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const zod_1 = require("zod");
5
9
  const workflow_protocol_contracts_js_1 = require("../workflow-protocol-contracts.js");
10
+ function isAbsoluteWorkspacePath(p) {
11
+ return path_1.default.isAbsolute(p);
12
+ }
6
13
  const workspacePathField = zod_1.z.string()
7
- .refine((p) => p.startsWith('/'), 'workspacePath must be an absolute path (starting with /)')
8
- .optional()
14
+ .refine((p) => isAbsoluteWorkspacePath(p), 'workspacePath must be an absolute path')
9
15
  .describe('Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). Used to resolve project-scoped workflow variants against the correct workspace. If omitted, WorkRail uses MCP roots when available, then falls back to the server process directory.');
16
+ const optionalWorkspacePathField = workspacePathField.optional();
10
17
  exports.V2ListWorkflowsInput = zod_1.z.object({
11
- workspacePath: workspacePathField,
18
+ workspacePath: optionalWorkspacePathField,
12
19
  });
13
20
  exports.V2InspectWorkflowInput = zod_1.z.object({
14
21
  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 inspect'),
15
22
  mode: zod_1.z.enum(['metadata', 'preview']).default('preview').describe('Detail level: metadata (name and description only) or preview (full step-by-step breakdown, default)'),
16
- workspacePath: workspacePathField,
23
+ workspacePath: optionalWorkspacePathField,
17
24
  });
18
25
  exports.V2StartWorkflowInput = zod_1.z.object({
19
26
  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'),
20
- workspacePath: workspacePathField.describe('Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). Used to resolve the correct project-scoped workflow variant and to anchor this session to your workspace for future resume_session discovery. Pass this on every start_workflow call. If omitted, WorkRail uses MCP roots when available, then falls back to the server process directory.'),
27
+ workspacePath: workspacePathField.describe('Required. Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). WorkRail uses this to resolve the correct project-scoped workflow variant and to anchor the session to the correct repo for future resume_session discovery. Shared MCP servers cannot infer this safely.'),
21
28
  });
22
29
  exports.V2ContinueWorkflowInputShape = zod_1.z.object({
23
- workspacePath: workspacePathField,
30
+ workspacePath: optionalWorkspacePathField,
24
31
  continueToken: zod_1.z.string().min(1).describe('The token for your next continue_workflow call. Two valid token kinds: ' +
25
32
  '(1) A continueToken (ct_...) from start_workflow or a previous continue_workflow — carries session identity AND advance authority. ' +
26
33
  '(2) A resumeToken (st_...) from resume_session or checkpoint_workflow — carries session identity only; valid for intent: "rehydrate", not "advance". ' +
@@ -69,6 +76,13 @@ exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape
69
76
  'Rehydration is read-only state recovery — it does not accept output.',
70
77
  });
71
78
  }
79
+ if (data.intent === 'rehydrate' && data.workspacePath === undefined) {
80
+ ctx.addIssue({
81
+ code: zod_1.z.ZodIssueCode.custom,
82
+ path: ['workspacePath'],
83
+ message: 'workspacePath is required for rehydration. Shared WorkRail servers cannot safely infer your current workspace, so pass the absolute "Workspace:" path from your system parameters.',
84
+ });
85
+ }
72
86
  })
73
87
  .transform((data) => {
74
88
  const normalized = workflow_protocol_contracts_js_1.CONTINUE_WORKFLOW_PROTOCOL.aliasMap
@@ -85,13 +99,17 @@ exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape
85
99
  });
86
100
  exports.V2ResumeSessionInput = zod_1.z.object({
87
101
  query: zod_1.z.string().min(1).max(256).optional().describe('Free text search to find a relevant session. Matches against recap notes and workflow IDs. ' +
102
+ 'Tip: use the user\'s exact words (e.g. "mr ownership", "ACEI-1234"). ' +
88
103
  'Without query, only git-context matching runs — the semantic (notes) tier is skipped.'),
104
+ runId: zod_1.z.string().regex(/^run_[a-z0-9]+$/).optional().describe('Exact run ID to find (e.g. "run_tbi2ag7njfjgc2aitt4qg5eaiq"). ' +
105
+ 'When provided, the matching session is returned as the sole top-priority candidate.'),
106
+ sessionId: zod_1.z.string().regex(/^sess_[a-zA-Z0-9_]+$/).optional().describe('Exact session ID to find (e.g. "sess_s5o2ieem4mwypoqnn6ztzyyag4"). ' +
107
+ 'When provided, the matching session is returned as the sole top-priority candidate.'),
89
108
  gitBranch: zod_1.z.string().max(256).optional().describe('Git branch name to match against session observations. Overrides auto-detected branch.'),
90
109
  gitHeadSha: zod_1.z.string().regex(/^[0-9a-f]{40}$/).optional().describe('Git HEAD SHA to match against session observations. Overrides auto-detected HEAD.'),
91
- workspacePath: zod_1.z.string()
92
- .refine((p) => p.startsWith('/'), 'workspacePath must be an absolute path (starting with /)')
93
- .optional()
94
- .describe('Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). Used to resolve your git branch and HEAD SHA for workspace-aware session matching. Pass the same path used in the original start_workflow call. If omitted, WorkRail uses the server process directory which may not match your workspace.'),
110
+ workspacePath: workspacePathField.describe('Required. Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). WorkRail uses this to identify the current repo and resume the correct session on shared MCP servers.'),
111
+ sameWorkspaceOnly: zod_1.z.boolean().optional().describe('If true, only sessions from the same repo/workspace are considered when repo_root_hash is available. ' +
112
+ 'Use this when the user clearly means "resume work from this repo only".'),
95
113
  }).strict();
96
114
  exports.V2CheckpointWorkflowInput = zod_1.z.object({
97
115
  checkpointToken: zod_1.z.string().min(1).describe('The checkpoint token from the most recent start_workflow or continue_workflow response. ' +
@@ -9,3 +9,4 @@ export interface FormattedResponse {
9
9
  readonly supplements?: readonly FormattedSupplement[];
10
10
  }
11
11
  export declare function formatV2ExecutionResponse(data: unknown): FormattedResponse | null;
12
+ export declare function formatV2ResumeResponse(data: unknown): FormattedResponse | null;