@exaudeus/workrail 0.11.0 → 0.12.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 (57) hide show
  1. package/dist/config/feature-flags.js +1 -1
  2. package/dist/di/container.js +72 -0
  3. package/dist/di/tokens.d.ts +13 -0
  4. package/dist/di/tokens.js +13 -0
  5. package/dist/manifest.json +109 -93
  6. package/dist/mcp/error-mapper.d.ts +3 -8
  7. package/dist/mcp/error-mapper.js +41 -19
  8. package/dist/mcp/handlers/session.js +25 -11
  9. package/dist/mcp/handlers/v2-execution-helpers.d.ts +99 -0
  10. package/dist/mcp/handlers/v2-execution-helpers.js +249 -0
  11. package/dist/mcp/handlers/v2-execution.d.ts +4 -0
  12. package/dist/mcp/handlers/v2-execution.js +1061 -0
  13. package/dist/mcp/handlers/v2-workflow.js +7 -7
  14. package/dist/mcp/handlers/workflow.js +21 -12
  15. package/dist/mcp/index.d.ts +1 -1
  16. package/dist/mcp/index.js +4 -1
  17. package/dist/mcp/output-schemas.d.ts +411 -4
  18. package/dist/mcp/output-schemas.js +57 -1
  19. package/dist/mcp/server.d.ts +1 -1
  20. package/dist/mcp/server.js +57 -31
  21. package/dist/mcp/tool-descriptions.js +17 -0
  22. package/dist/mcp/tools.js +12 -0
  23. package/dist/mcp/types/tool-description-types.d.ts +1 -1
  24. package/dist/mcp/types/tool-description-types.js +2 -0
  25. package/dist/mcp/types.d.ts +38 -3
  26. package/dist/mcp/types.js +32 -3
  27. package/dist/mcp/v2/tool-registry.js +16 -1
  28. package/dist/mcp/v2/tools.d.ts +45 -0
  29. package/dist/mcp/v2/tools.js +21 -1
  30. package/dist/mcp/validation/workflow-next-prevalidate.d.ts +2 -3
  31. package/dist/mcp/validation/workflow-next-prevalidate.js +38 -27
  32. package/dist/v2/durable-core/ids/index.d.ts +2 -0
  33. package/dist/v2/durable-core/ids/index.js +4 -0
  34. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +100 -6
  35. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +18 -3
  36. package/dist/v2/durable-core/schemas/session/events.d.ts +80 -50
  37. package/dist/v2/durable-core/schemas/session/events.js +27 -9
  38. package/dist/v2/durable-core/schemas/session/manifest.d.ts +2 -2
  39. package/dist/v2/durable-core/tokens/index.d.ts +2 -0
  40. package/dist/v2/durable-core/tokens/index.js +4 -1
  41. package/dist/v2/durable-core/tokens/payloads.d.ts +4 -4
  42. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +3 -3
  43. package/dist/v2/infra/local/pinned-workflow-store/index.js +1 -1
  44. package/dist/v2/infra/local/session-lock/index.js +1 -1
  45. package/dist/v2/infra/local/session-store/index.d.ts +0 -1
  46. package/dist/v2/infra/local/session-store/index.js +348 -280
  47. package/dist/v2/ports/pinned-workflow-store.port.d.ts +3 -3
  48. package/dist/v2/ports/session-event-log-store.port.d.ts +1 -1
  49. package/dist/v2/ports/session-lock.port.d.ts +1 -1
  50. package/dist/v2/read-only/v1-to-v2-shim.d.ts +6 -1
  51. package/dist/v2/read-only/v1-to-v2-shim.js +16 -4
  52. package/dist/v2/usecases/execution-session-gate.d.ts +3 -2
  53. package/dist/v2/usecases/execution-session-gate.js +98 -101
  54. package/package.json +2 -1
  55. package/workflows/coding-task-workflow-agentic.json +326 -69
  56. package/workflows/design-thinking-workflow-autonomous.agentic.json +1 -1
  57. package/workflows/design-thinking-workflow.json +1 -1
@@ -35,7 +35,7 @@ async function handleV2ListWorkflows(_input, ctx) {
35
35
  kind: 'workflow',
36
36
  };
37
37
  }
38
- const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2CompiledSnapshotV1)(wf);
38
+ const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2PreviewSnapshot)(wf);
39
39
  const hashRes = (0, hashing_js_1.workflowHashForCompiledSnapshot)(snapshot, crypto);
40
40
  if (hashRes.isErr()) {
41
41
  return {
@@ -68,29 +68,29 @@ async function handleV2ListWorkflows(_input, ctx) {
68
68
  }
69
69
  catch (err) {
70
70
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
71
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
71
+ return mapped;
72
72
  }
73
73
  }
74
74
  async function handleV2InspectWorkflow(input, ctx) {
75
75
  try {
76
76
  const workflow = await withTimeout(ctx.workflowService.getWorkflowById(input.workflowId), TIMEOUT_MS, 'inspect_workflow');
77
77
  if (!workflow) {
78
- return (0, types_js_1.error)('NOT_FOUND', `Workflow not found: ${input.workflowId}`);
78
+ return (0, types_js_1.errNotRetryable)('NOT_FOUND', `Workflow not found: ${input.workflowId}`);
79
79
  }
80
80
  const crypto = new index_js_1.NodeCryptoV2();
81
81
  const dataDir = new index_js_2.LocalDataDirV2(process.env);
82
82
  const pinnedStore = new index_js_3.LocalPinnedWorkflowStoreV2(dataDir);
83
- const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2CompiledSnapshotV1)(workflow);
83
+ const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2PreviewSnapshot)(workflow);
84
84
  const hashRes = (0, hashing_js_1.workflowHashForCompiledSnapshot)(snapshot, crypto);
85
85
  if (hashRes.isErr()) {
86
- return (0, types_js_1.error)('INTERNAL_ERROR', hashRes.error.message);
86
+ return (0, types_js_1.errNotRetryable)('INTERNAL_ERROR', hashRes.error.message);
87
87
  }
88
88
  const workflowHash = hashRes.value;
89
89
  const existing = await pinnedStore.get(workflowHash).match((v) => v, () => null);
90
90
  if (!existing) {
91
91
  const wrote = await pinnedStore.put(workflowHash, snapshot).match(() => ({ ok: true }), (e) => ({ ok: false, error: e }));
92
92
  if (!wrote.ok) {
93
- return (0, types_js_1.error)('INTERNAL_ERROR', wrote.error.message);
93
+ return (0, types_js_1.errNotRetryable)('INTERNAL_ERROR', wrote.error.message);
94
94
  }
95
95
  }
96
96
  const compiled = (await pinnedStore.get(workflowHash).match((v) => v, () => null)) ?? snapshot;
@@ -107,6 +107,6 @@ async function handleV2InspectWorkflow(input, ctx) {
107
107
  }
108
108
  catch (err) {
109
109
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
110
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
110
+ return mapped;
111
111
  }
112
112
  }
@@ -58,7 +58,7 @@ async function handleWorkflowList(_input, ctx) {
58
58
  }
59
59
  catch (err) {
60
60
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
61
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
61
+ return mapped;
62
62
  }
63
63
  }
64
64
  async function handleWorkflowGet(input, ctx) {
@@ -68,18 +68,22 @@ async function handleWorkflowGet(input, ctx) {
68
68
  const result = await withTimeout(getWorkflowUseCase(input.id, input.mode), TIMEOUT_MS, 'workflow_get');
69
69
  if (result.isErr()) {
70
70
  const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
71
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
71
+ return mapped;
72
72
  }
73
73
  const payload = output_schemas_js_1.WorkflowGetOutputSchema.parse({ workflow: result.value });
74
74
  return (0, types_js_1.success)(payload);
75
75
  }
76
76
  catch (err) {
77
- const message = err instanceof Error ? err.message : String(err);
78
- if (message.includes('timed out')) {
79
- return (0, types_js_1.error)('TIMEOUT', message);
77
+ if (err instanceof Error && err.name === 'TimeoutError') {
78
+ return {
79
+ type: 'error',
80
+ code: 'TIMEOUT',
81
+ message: err.message,
82
+ retry: { kind: 'retryable_immediate' },
83
+ };
80
84
  }
81
85
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
82
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
86
+ return mapped;
83
87
  }
84
88
  }
85
89
  async function handleWorkflowNext(input, ctx) {
@@ -94,7 +98,7 @@ async function handleWorkflowNext(input, ctx) {
94
98
  `returned=${result.isOk() ? 'ok' : 'err'}`);
95
99
  if (result.isErr()) {
96
100
  const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
97
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
101
+ return mapped;
98
102
  }
99
103
  const payload = output_schemas_js_1.WorkflowNextOutputSchema.parse(result.value);
100
104
  return (0, types_js_1.success)(payload);
@@ -103,11 +107,16 @@ async function handleWorkflowNext(input, ctx) {
103
107
  const elapsed = Date.now() - startTime;
104
108
  const message = err instanceof Error ? err.message : String(err);
105
109
  console.error(`[workflow_next] Failed after ${elapsed}ms: ${message}`);
106
- if (message.includes('timed out')) {
107
- return (0, types_js_1.error)('TIMEOUT', message);
110
+ if (err instanceof Error && err.name === 'TimeoutError') {
111
+ return {
112
+ type: 'error',
113
+ code: 'TIMEOUT',
114
+ message: err.message,
115
+ retry: { kind: 'retryable_immediate' },
116
+ };
108
117
  }
109
118
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
110
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
119
+ return mapped;
111
120
  }
112
121
  }
113
122
  async function handleWorkflowValidateJson(input, ctx) {
@@ -121,7 +130,7 @@ async function handleWorkflowValidateJson(input, ctx) {
121
130
  }
122
131
  catch (err) {
123
132
  const mapped = (0, error_mapper_js_1.mapUnknownErrorToToolError)(err);
124
- return (0, types_js_1.error)(mapped.code, mapped.message, mapped.suggestion);
133
+ return mapped;
125
134
  }
126
135
  }
127
136
  async function handleWorkflowGetSchema(_input, ctx) {
@@ -162,6 +171,6 @@ async function handleWorkflowGetSchema(_input, ctx) {
162
171
  }
163
172
  catch (err) {
164
173
  const message = err instanceof Error ? err.message : String(err);
165
- return (0, types_js_1.error)('INTERNAL_ERROR', message, 'Ensure the workflow schema file exists at spec/workflow.schema.json');
174
+ return (0, types_js_1.errNotRetryable)('INTERNAL_ERROR', message, { suggestion: 'Ensure the workflow schema file exists at spec/workflow.schema.json' });
166
175
  }
167
176
  }
@@ -1,5 +1,5 @@
1
1
  export type { ErrorCode, ToolSuccess, ToolError, ToolResult, ToolContext, ToolHandler, } from './types.js';
2
- export { success, error, } from './types.js';
2
+ export { success, error, errNotRetryable, errRetryAfterMs, errRetryImmediate, } from './types.js';
3
3
  export type { ToolAnnotations, ToolDefinition, ToolConfig, ToolBuilder, } from './tool-factory.js';
4
4
  export { createToolFactory } from './tool-factory.js';
5
5
  export type { DescriptionMode, WorkflowToolName, ToolDescriptionMap, DescriptionsByMode, } from './types/tool-description-types.js';
package/dist/mcp/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zodToJsonSchema = exports.startServer = exports.createToolContext = exports.handleOpenDashboard = exports.handleReadSession = exports.handleUpdateSession = exports.handleCreateSession = exports.handleWorkflowGetSchema = exports.handleWorkflowValidateJson = exports.handleWorkflowNext = exports.handleWorkflowGet = exports.handleWorkflowList = exports.sessionTools = exports.openDashboardTool = exports.readSessionTool = exports.updateSessionTool = exports.createSessionTool = exports.OpenDashboardInput = exports.ReadSessionInput = exports.UpdateSessionInput = exports.CreateSessionInput = exports.WORKFLOW_TOOL_TITLES = exports.WORKFLOW_TOOL_ANNOTATIONS = exports.WorkflowGetSchemaInput = exports.WorkflowValidateJsonInput = exports.WorkflowNextInput = exports.WorkflowGetInput = exports.WorkflowListInput = exports.DESCRIPTIONS = exports.StaticToolDescriptionProvider = exports.ToolDescriptionProvider = exports.isWorkflowToolName = exports.isDescriptionMode = exports.WORKFLOW_TOOL_NAMES = exports.DESCRIPTION_MODES = exports.createToolFactory = exports.error = exports.success = void 0;
3
+ exports.zodToJsonSchema = exports.startServer = exports.createToolContext = exports.handleOpenDashboard = exports.handleReadSession = exports.handleUpdateSession = exports.handleCreateSession = exports.handleWorkflowGetSchema = exports.handleWorkflowValidateJson = exports.handleWorkflowNext = exports.handleWorkflowGet = exports.handleWorkflowList = exports.sessionTools = exports.openDashboardTool = exports.readSessionTool = exports.updateSessionTool = exports.createSessionTool = exports.OpenDashboardInput = exports.ReadSessionInput = exports.UpdateSessionInput = exports.CreateSessionInput = exports.WORKFLOW_TOOL_TITLES = exports.WORKFLOW_TOOL_ANNOTATIONS = exports.WorkflowGetSchemaInput = exports.WorkflowValidateJsonInput = exports.WorkflowNextInput = exports.WorkflowGetInput = exports.WorkflowListInput = exports.DESCRIPTIONS = exports.StaticToolDescriptionProvider = exports.ToolDescriptionProvider = exports.isWorkflowToolName = exports.isDescriptionMode = exports.WORKFLOW_TOOL_NAMES = exports.DESCRIPTION_MODES = exports.createToolFactory = exports.errRetryImmediate = exports.errRetryAfterMs = exports.errNotRetryable = exports.error = exports.success = void 0;
4
4
  var types_js_1 = require("./types.js");
5
5
  Object.defineProperty(exports, "success", { enumerable: true, get: function () { return types_js_1.success; } });
6
6
  Object.defineProperty(exports, "error", { enumerable: true, get: function () { return types_js_1.error; } });
7
+ Object.defineProperty(exports, "errNotRetryable", { enumerable: true, get: function () { return types_js_1.errNotRetryable; } });
8
+ Object.defineProperty(exports, "errRetryAfterMs", { enumerable: true, get: function () { return types_js_1.errRetryAfterMs; } });
9
+ Object.defineProperty(exports, "errRetryImmediate", { enumerable: true, get: function () { return types_js_1.errRetryImmediate; } });
7
10
  var tool_factory_js_1 = require("./tool-factory.js");
8
11
  Object.defineProperty(exports, "createToolFactory", { enumerable: true, get: function () { return tool_factory_js_1.createToolFactory; } });
9
12
  var tool_description_types_js_1 = require("./types/tool-description-types.js");
@@ -63,13 +63,13 @@ export declare const WorkflowNextOutputSchema: z.ZodObject<{
63
63
  next: z.ZodNullable<z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>>;
64
64
  isComplete: z.ZodBoolean;
65
65
  }, "strip", z.ZodTypeAny, {
66
+ isComplete: boolean;
66
67
  state: import("../domain/execution/state.js").ExecutionState;
67
68
  next: JsonValue;
68
- isComplete: boolean;
69
69
  }, {
70
+ isComplete: boolean;
70
71
  state: import("../domain/execution/state.js").ExecutionState;
71
72
  next: JsonValue;
72
- isComplete: boolean;
73
73
  }>;
74
74
  export declare const WorkflowValidateJsonOutputSchema: z.ZodObject<{
75
75
  valid: z.ZodBoolean;
@@ -223,15 +223,422 @@ export declare const V2WorkflowInspectOutputSchema: z.ZodObject<{
223
223
  compiled: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
224
224
  }, "strip", z.ZodTypeAny, {
225
225
  workflowId: string;
226
- mode: "metadata" | "preview";
227
226
  workflowHash: string;
227
+ mode: "metadata" | "preview";
228
228
  compiled: JsonValue;
229
229
  }, {
230
230
  workflowId: string;
231
- mode: "metadata" | "preview";
232
231
  workflowHash: string;
232
+ mode: "metadata" | "preview";
233
233
  compiled: JsonValue;
234
234
  }>;
235
+ export declare const V2PendingStepSchema: z.ZodObject<{
236
+ stepId: z.ZodString;
237
+ title: z.ZodString;
238
+ prompt: z.ZodString;
239
+ }, "strip", z.ZodTypeAny, {
240
+ title: string;
241
+ prompt: string;
242
+ stepId: string;
243
+ }, {
244
+ title: string;
245
+ prompt: string;
246
+ stepId: string;
247
+ }>;
248
+ export declare const V2BlockerReportSchema: z.ZodObject<{
249
+ blockers: z.ZodArray<z.ZodObject<{
250
+ code: z.ZodEnum<["USER_ONLY_DEPENDENCY", "MISSING_REQUIRED_OUTPUT", "INVALID_REQUIRED_OUTPUT", "REQUIRED_CAPABILITY_UNKNOWN", "REQUIRED_CAPABILITY_UNAVAILABLE", "INVARIANT_VIOLATION", "STORAGE_CORRUPTION_DETECTED"]>;
251
+ pointer: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
252
+ kind: z.ZodLiteral<"context_key">;
253
+ key: z.ZodString;
254
+ }, "strip", z.ZodTypeAny, {
255
+ key: string;
256
+ kind: "context_key";
257
+ }, {
258
+ key: string;
259
+ kind: "context_key";
260
+ }>, z.ZodObject<{
261
+ kind: z.ZodLiteral<"output_contract">;
262
+ contractRef: z.ZodString;
263
+ }, "strip", z.ZodTypeAny, {
264
+ kind: "output_contract";
265
+ contractRef: string;
266
+ }, {
267
+ kind: "output_contract";
268
+ contractRef: string;
269
+ }>, z.ZodObject<{
270
+ kind: z.ZodLiteral<"capability">;
271
+ capability: z.ZodEnum<["delegation", "web_browsing"]>;
272
+ }, "strip", z.ZodTypeAny, {
273
+ kind: "capability";
274
+ capability: "delegation" | "web_browsing";
275
+ }, {
276
+ kind: "capability";
277
+ capability: "delegation" | "web_browsing";
278
+ }>, z.ZodObject<{
279
+ kind: z.ZodLiteral<"workflow_step">;
280
+ stepId: z.ZodString;
281
+ }, "strip", z.ZodTypeAny, {
282
+ kind: "workflow_step";
283
+ stepId: string;
284
+ }, {
285
+ kind: "workflow_step";
286
+ stepId: string;
287
+ }>]>;
288
+ message: z.ZodString;
289
+ suggestedFix: z.ZodOptional<z.ZodString>;
290
+ }, "strip", z.ZodTypeAny, {
291
+ message: string;
292
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
293
+ pointer: {
294
+ key: string;
295
+ kind: "context_key";
296
+ } | {
297
+ kind: "output_contract";
298
+ contractRef: string;
299
+ } | {
300
+ kind: "capability";
301
+ capability: "delegation" | "web_browsing";
302
+ } | {
303
+ kind: "workflow_step";
304
+ stepId: string;
305
+ };
306
+ suggestedFix?: string | undefined;
307
+ }, {
308
+ message: string;
309
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
310
+ pointer: {
311
+ key: string;
312
+ kind: "context_key";
313
+ } | {
314
+ kind: "output_contract";
315
+ contractRef: string;
316
+ } | {
317
+ kind: "capability";
318
+ capability: "delegation" | "web_browsing";
319
+ } | {
320
+ kind: "workflow_step";
321
+ stepId: string;
322
+ };
323
+ suggestedFix?: string | undefined;
324
+ }>, "many">;
325
+ }, "strip", z.ZodTypeAny, {
326
+ blockers: {
327
+ message: string;
328
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
329
+ pointer: {
330
+ key: string;
331
+ kind: "context_key";
332
+ } | {
333
+ kind: "output_contract";
334
+ contractRef: string;
335
+ } | {
336
+ kind: "capability";
337
+ capability: "delegation" | "web_browsing";
338
+ } | {
339
+ kind: "workflow_step";
340
+ stepId: string;
341
+ };
342
+ suggestedFix?: string | undefined;
343
+ }[];
344
+ }, {
345
+ blockers: {
346
+ message: string;
347
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
348
+ pointer: {
349
+ key: string;
350
+ kind: "context_key";
351
+ } | {
352
+ kind: "output_contract";
353
+ contractRef: string;
354
+ } | {
355
+ kind: "capability";
356
+ capability: "delegation" | "web_browsing";
357
+ } | {
358
+ kind: "workflow_step";
359
+ stepId: string;
360
+ };
361
+ suggestedFix?: string | undefined;
362
+ }[];
363
+ }>;
364
+ export declare const V2ContinueWorkflowOutputSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
365
+ kind: z.ZodLiteral<"ok">;
366
+ stateToken: z.ZodString;
367
+ ackToken: z.ZodString;
368
+ checkpointToken: z.ZodString;
369
+ isComplete: z.ZodBoolean;
370
+ pending: z.ZodNullable<z.ZodObject<{
371
+ stepId: z.ZodString;
372
+ title: z.ZodString;
373
+ prompt: z.ZodString;
374
+ }, "strip", z.ZodTypeAny, {
375
+ title: string;
376
+ prompt: string;
377
+ stepId: string;
378
+ }, {
379
+ title: string;
380
+ prompt: string;
381
+ stepId: string;
382
+ }>>;
383
+ }, "strip", z.ZodTypeAny, {
384
+ kind: "ok";
385
+ pending: {
386
+ title: string;
387
+ prompt: string;
388
+ stepId: string;
389
+ } | null;
390
+ isComplete: boolean;
391
+ stateToken: string;
392
+ ackToken: string;
393
+ checkpointToken: string;
394
+ }, {
395
+ kind: "ok";
396
+ pending: {
397
+ title: string;
398
+ prompt: string;
399
+ stepId: string;
400
+ } | null;
401
+ isComplete: boolean;
402
+ stateToken: string;
403
+ ackToken: string;
404
+ checkpointToken: string;
405
+ }>, z.ZodObject<{
406
+ kind: z.ZodLiteral<"blocked">;
407
+ stateToken: z.ZodString;
408
+ ackToken: z.ZodString;
409
+ checkpointToken: z.ZodString;
410
+ isComplete: z.ZodBoolean;
411
+ pending: z.ZodNullable<z.ZodObject<{
412
+ stepId: z.ZodString;
413
+ title: z.ZodString;
414
+ prompt: z.ZodString;
415
+ }, "strip", z.ZodTypeAny, {
416
+ title: string;
417
+ prompt: string;
418
+ stepId: string;
419
+ }, {
420
+ title: string;
421
+ prompt: string;
422
+ stepId: string;
423
+ }>>;
424
+ blockers: z.ZodObject<{
425
+ blockers: z.ZodArray<z.ZodObject<{
426
+ code: z.ZodEnum<["USER_ONLY_DEPENDENCY", "MISSING_REQUIRED_OUTPUT", "INVALID_REQUIRED_OUTPUT", "REQUIRED_CAPABILITY_UNKNOWN", "REQUIRED_CAPABILITY_UNAVAILABLE", "INVARIANT_VIOLATION", "STORAGE_CORRUPTION_DETECTED"]>;
427
+ pointer: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
428
+ kind: z.ZodLiteral<"context_key">;
429
+ key: z.ZodString;
430
+ }, "strip", z.ZodTypeAny, {
431
+ key: string;
432
+ kind: "context_key";
433
+ }, {
434
+ key: string;
435
+ kind: "context_key";
436
+ }>, z.ZodObject<{
437
+ kind: z.ZodLiteral<"output_contract">;
438
+ contractRef: z.ZodString;
439
+ }, "strip", z.ZodTypeAny, {
440
+ kind: "output_contract";
441
+ contractRef: string;
442
+ }, {
443
+ kind: "output_contract";
444
+ contractRef: string;
445
+ }>, z.ZodObject<{
446
+ kind: z.ZodLiteral<"capability">;
447
+ capability: z.ZodEnum<["delegation", "web_browsing"]>;
448
+ }, "strip", z.ZodTypeAny, {
449
+ kind: "capability";
450
+ capability: "delegation" | "web_browsing";
451
+ }, {
452
+ kind: "capability";
453
+ capability: "delegation" | "web_browsing";
454
+ }>, z.ZodObject<{
455
+ kind: z.ZodLiteral<"workflow_step">;
456
+ stepId: z.ZodString;
457
+ }, "strip", z.ZodTypeAny, {
458
+ kind: "workflow_step";
459
+ stepId: string;
460
+ }, {
461
+ kind: "workflow_step";
462
+ stepId: string;
463
+ }>]>;
464
+ message: z.ZodString;
465
+ suggestedFix: z.ZodOptional<z.ZodString>;
466
+ }, "strip", z.ZodTypeAny, {
467
+ message: string;
468
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
469
+ pointer: {
470
+ key: string;
471
+ kind: "context_key";
472
+ } | {
473
+ kind: "output_contract";
474
+ contractRef: string;
475
+ } | {
476
+ kind: "capability";
477
+ capability: "delegation" | "web_browsing";
478
+ } | {
479
+ kind: "workflow_step";
480
+ stepId: string;
481
+ };
482
+ suggestedFix?: string | undefined;
483
+ }, {
484
+ message: string;
485
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
486
+ pointer: {
487
+ key: string;
488
+ kind: "context_key";
489
+ } | {
490
+ kind: "output_contract";
491
+ contractRef: string;
492
+ } | {
493
+ kind: "capability";
494
+ capability: "delegation" | "web_browsing";
495
+ } | {
496
+ kind: "workflow_step";
497
+ stepId: string;
498
+ };
499
+ suggestedFix?: string | undefined;
500
+ }>, "many">;
501
+ }, "strip", z.ZodTypeAny, {
502
+ blockers: {
503
+ message: string;
504
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
505
+ pointer: {
506
+ key: string;
507
+ kind: "context_key";
508
+ } | {
509
+ kind: "output_contract";
510
+ contractRef: string;
511
+ } | {
512
+ kind: "capability";
513
+ capability: "delegation" | "web_browsing";
514
+ } | {
515
+ kind: "workflow_step";
516
+ stepId: string;
517
+ };
518
+ suggestedFix?: string | undefined;
519
+ }[];
520
+ }, {
521
+ blockers: {
522
+ message: string;
523
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
524
+ pointer: {
525
+ key: string;
526
+ kind: "context_key";
527
+ } | {
528
+ kind: "output_contract";
529
+ contractRef: string;
530
+ } | {
531
+ kind: "capability";
532
+ capability: "delegation" | "web_browsing";
533
+ } | {
534
+ kind: "workflow_step";
535
+ stepId: string;
536
+ };
537
+ suggestedFix?: string | undefined;
538
+ }[];
539
+ }>;
540
+ }, "strip", z.ZodTypeAny, {
541
+ kind: "blocked";
542
+ pending: {
543
+ title: string;
544
+ prompt: string;
545
+ stepId: string;
546
+ } | null;
547
+ blockers: {
548
+ blockers: {
549
+ message: string;
550
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
551
+ pointer: {
552
+ key: string;
553
+ kind: "context_key";
554
+ } | {
555
+ kind: "output_contract";
556
+ contractRef: string;
557
+ } | {
558
+ kind: "capability";
559
+ capability: "delegation" | "web_browsing";
560
+ } | {
561
+ kind: "workflow_step";
562
+ stepId: string;
563
+ };
564
+ suggestedFix?: string | undefined;
565
+ }[];
566
+ };
567
+ isComplete: boolean;
568
+ stateToken: string;
569
+ ackToken: string;
570
+ checkpointToken: string;
571
+ }, {
572
+ kind: "blocked";
573
+ pending: {
574
+ title: string;
575
+ prompt: string;
576
+ stepId: string;
577
+ } | null;
578
+ blockers: {
579
+ blockers: {
580
+ message: string;
581
+ code: "USER_ONLY_DEPENDENCY" | "MISSING_REQUIRED_OUTPUT" | "INVALID_REQUIRED_OUTPUT" | "REQUIRED_CAPABILITY_UNKNOWN" | "REQUIRED_CAPABILITY_UNAVAILABLE" | "INVARIANT_VIOLATION" | "STORAGE_CORRUPTION_DETECTED";
582
+ pointer: {
583
+ key: string;
584
+ kind: "context_key";
585
+ } | {
586
+ kind: "output_contract";
587
+ contractRef: string;
588
+ } | {
589
+ kind: "capability";
590
+ capability: "delegation" | "web_browsing";
591
+ } | {
592
+ kind: "workflow_step";
593
+ stepId: string;
594
+ };
595
+ suggestedFix?: string | undefined;
596
+ }[];
597
+ };
598
+ isComplete: boolean;
599
+ stateToken: string;
600
+ ackToken: string;
601
+ checkpointToken: string;
602
+ }>]>;
603
+ export declare const V2StartWorkflowOutputSchema: z.ZodObject<{
604
+ stateToken: z.ZodString;
605
+ ackToken: z.ZodString;
606
+ checkpointToken: z.ZodString;
607
+ isComplete: z.ZodBoolean;
608
+ pending: z.ZodNullable<z.ZodObject<{
609
+ stepId: z.ZodString;
610
+ title: z.ZodString;
611
+ prompt: z.ZodString;
612
+ }, "strip", z.ZodTypeAny, {
613
+ title: string;
614
+ prompt: string;
615
+ stepId: string;
616
+ }, {
617
+ title: string;
618
+ prompt: string;
619
+ stepId: string;
620
+ }>>;
621
+ }, "strip", z.ZodTypeAny, {
622
+ pending: {
623
+ title: string;
624
+ prompt: string;
625
+ stepId: string;
626
+ } | null;
627
+ isComplete: boolean;
628
+ stateToken: string;
629
+ ackToken: string;
630
+ checkpointToken: string;
631
+ }, {
632
+ pending: {
633
+ title: string;
634
+ prompt: string;
635
+ stepId: string;
636
+ } | null;
637
+ isComplete: boolean;
638
+ stateToken: string;
639
+ ackToken: string;
640
+ checkpointToken: string;
641
+ }>;
235
642
  export declare const CreateSessionOutputSchema: z.ZodObject<{
236
643
  sessionId: z.ZodString;
237
644
  workflowId: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpenDashboardOutputSchema = exports.ReadSessionSchemaOutputSchema = exports.ReadSessionOutputSchema = exports.UpdateSessionOutputSchema = exports.CreateSessionOutputSchema = exports.V2WorkflowInspectOutputSchema = exports.V2WorkflowListOutputSchema = exports.V2WorkflowListItemSchema = exports.WorkflowGetSchemaOutputSchema = exports.WorkflowValidateJsonOutputSchema = exports.WorkflowNextOutputSchema = exports.WorkflowGetOutputSchema = exports.WorkflowListOutputSchema = exports.WorkflowSummarySchema = exports.JsonValueSchema = void 0;
3
+ exports.OpenDashboardOutputSchema = exports.ReadSessionSchemaOutputSchema = exports.ReadSessionOutputSchema = exports.UpdateSessionOutputSchema = exports.CreateSessionOutputSchema = exports.V2StartWorkflowOutputSchema = exports.V2ContinueWorkflowOutputSchema = exports.V2BlockerReportSchema = exports.V2PendingStepSchema = exports.V2WorkflowInspectOutputSchema = exports.V2WorkflowListOutputSchema = exports.V2WorkflowListItemSchema = exports.WorkflowGetSchemaOutputSchema = exports.WorkflowValidateJsonOutputSchema = exports.WorkflowNextOutputSchema = exports.WorkflowGetOutputSchema = exports.WorkflowListOutputSchema = exports.WorkflowSummarySchema = exports.JsonValueSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const state_js_1 = require("../domain/execution/state.js");
6
6
  const JsonPrimitiveSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]);
@@ -62,6 +62,62 @@ exports.V2WorkflowInspectOutputSchema = zod_1.z.object({
62
62
  mode: zod_1.z.enum(['metadata', 'preview']),
63
63
  compiled: exports.JsonValueSchema,
64
64
  });
65
+ exports.V2PendingStepSchema = zod_1.z.object({
66
+ stepId: zod_1.z.string().min(1),
67
+ title: zod_1.z.string().min(1),
68
+ prompt: zod_1.z.string().min(1),
69
+ });
70
+ const V2BlockerPointerSchema = zod_1.z.discriminatedUnion('kind', [
71
+ zod_1.z.object({ kind: zod_1.z.literal('context_key'), key: zod_1.z.string().min(1) }),
72
+ zod_1.z.object({ kind: zod_1.z.literal('output_contract'), contractRef: zod_1.z.string().min(1) }),
73
+ zod_1.z.object({ kind: zod_1.z.literal('capability'), capability: zod_1.z.enum(['delegation', 'web_browsing']) }),
74
+ zod_1.z.object({ kind: zod_1.z.literal('workflow_step'), stepId: zod_1.z.string().min(1) }),
75
+ ]);
76
+ const V2BlockerSchema = zod_1.z.object({
77
+ code: zod_1.z.enum([
78
+ 'USER_ONLY_DEPENDENCY',
79
+ 'MISSING_REQUIRED_OUTPUT',
80
+ 'INVALID_REQUIRED_OUTPUT',
81
+ 'REQUIRED_CAPABILITY_UNKNOWN',
82
+ 'REQUIRED_CAPABILITY_UNAVAILABLE',
83
+ 'INVARIANT_VIOLATION',
84
+ 'STORAGE_CORRUPTION_DETECTED',
85
+ ]),
86
+ pointer: V2BlockerPointerSchema,
87
+ message: zod_1.z.string().min(1).max(512),
88
+ suggestedFix: zod_1.z.string().min(1).max(1024).optional(),
89
+ });
90
+ exports.V2BlockerReportSchema = zod_1.z.object({
91
+ blockers: zod_1.z.array(V2BlockerSchema).min(1).max(10),
92
+ });
93
+ const V2ContinueWorkflowOkSchema = zod_1.z.object({
94
+ kind: zod_1.z.literal('ok'),
95
+ stateToken: zod_1.z.string().min(1),
96
+ ackToken: zod_1.z.string().min(1),
97
+ checkpointToken: zod_1.z.string().min(1),
98
+ isComplete: zod_1.z.boolean(),
99
+ pending: exports.V2PendingStepSchema.nullable(),
100
+ });
101
+ const V2ContinueWorkflowBlockedSchema = zod_1.z.object({
102
+ kind: zod_1.z.literal('blocked'),
103
+ stateToken: zod_1.z.string().min(1),
104
+ ackToken: zod_1.z.string().min(1),
105
+ checkpointToken: zod_1.z.string().min(1),
106
+ isComplete: zod_1.z.boolean(),
107
+ pending: exports.V2PendingStepSchema.nullable(),
108
+ blockers: exports.V2BlockerReportSchema,
109
+ });
110
+ exports.V2ContinueWorkflowOutputSchema = zod_1.z.discriminatedUnion('kind', [
111
+ V2ContinueWorkflowOkSchema,
112
+ V2ContinueWorkflowBlockedSchema,
113
+ ]);
114
+ exports.V2StartWorkflowOutputSchema = zod_1.z.object({
115
+ stateToken: zod_1.z.string().min(1),
116
+ ackToken: zod_1.z.string().min(1),
117
+ checkpointToken: zod_1.z.string().min(1),
118
+ isComplete: zod_1.z.boolean(),
119
+ pending: exports.V2PendingStepSchema.nullable(),
120
+ });
65
121
  exports.CreateSessionOutputSchema = zod_1.z.object({
66
122
  sessionId: zod_1.z.string().min(1),
67
123
  workflowId: zod_1.z.string().min(1),
@@ -1,3 +1,3 @@
1
1
  import type { ToolContext } from './types.js';
2
- export declare function createToolContext(): ToolContext;
2
+ export declare function createToolContext(): Promise<ToolContext>;
3
3
  export declare function startServer(): Promise<void>;