@exaudeus/workrail 1.7.2 → 1.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.
@@ -522,12 +522,12 @@
522
522
  "bytes": 3982
523
523
  },
524
524
  "mcp/handler-factory.d.ts": {
525
- "sha256": "fad8fff32776b2fe7182708ce0e821c2434fdfce7191390bb9cfaf16a7d31a60",
526
- "bytes": 796
525
+ "sha256": "27ee92b476ca59ed6daca56b228b27bc4c84a061106fa61f2554bba98703ba28",
526
+ "bytes": 838
527
527
  },
528
528
  "mcp/handler-factory.js": {
529
- "sha256": "711bdf8bd71eaf2ad2a6b6b1bf84db004030e06223ce52075e01470a3bffd88d",
530
- "bytes": 3805
529
+ "sha256": "8cc0d3e1a7871048b9033a90fb63b3dfd91148c16d22ac5336a767ed2d04a10b",
530
+ "bytes": 3907
531
531
  },
532
532
  "mcp/handlers/session.d.ts": {
533
533
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
@@ -830,16 +830,16 @@
830
830
  "bytes": 408
831
831
  },
832
832
  "mcp/v2/tool-registry.js": {
833
- "sha256": "4b192604ddafd986416865041db7e395d205da6fa1d398bec07646900f6ce28c",
834
- "bytes": 3078
833
+ "sha256": "82539ddccffd58e3dee09b6ee859721fe69da024f55f25b3ee1113d48363d4e4",
834
+ "bytes": 3119
835
835
  },
836
836
  "mcp/v2/tools.d.ts": {
837
- "sha256": "8d37b32d7a00d534b2ecbdc71018e3849714531ec3021862427494be85909eab",
838
- "bytes": 5486
837
+ "sha256": "567938a5c153159b7792600cbe2326ce446a28f46d5f49e34dc1663cf826427e",
838
+ "bytes": 6737
839
839
  },
840
840
  "mcp/v2/tools.js": {
841
- "sha256": "5af4e1a5a3a6c43df6db4ea40eb6d12fd0757af94f4e3e80d9f875ecf0181544",
842
- "bytes": 7812
841
+ "sha256": "49d00fe392c526ce5f7e287ba98180cc82574b0c85ff0b550f3f01a216ac5dbf",
842
+ "bytes": 7938
843
843
  },
844
844
  "mcp/validation/bounded-json.d.ts": {
845
845
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -858,12 +858,12 @@
858
858
  "bytes": 4664
859
859
  },
860
860
  "mcp/validation/schema-introspection.d.ts": {
861
- "sha256": "7e0262e76234dd37079156027e95a30987b8949351f3e9ec0fd7b2be093a159d",
862
- "bytes": 713
861
+ "sha256": "48b0f5c762bbfb82014b4424c65a5006e19fe871cc86a6ece4fe41c1110cc45f",
862
+ "bytes": 767
863
863
  },
864
864
  "mcp/validation/schema-introspection.js": {
865
- "sha256": "850c09a3c01a5f22440ebc34236c393f3b428748210f5277258a9905cb847d71",
866
- "bytes": 5293
865
+ "sha256": "03cc06529e37525264064a0d9c05dfa9cc17eb9043dcbf559c1b0a62fbd08081",
866
+ "bytes": 5448
867
867
  },
868
868
  "mcp/validation/string-similarity.d.ts": {
869
869
  "sha256": "4326210a768a526336b54d4ea20a128a939d92f53e8b2a5a33da06b5372d196a",
@@ -874,20 +874,20 @@
874
874
  "bytes": 2627
875
875
  },
876
876
  "mcp/validation/suggestion-config.d.ts": {
877
- "sha256": "70b8395db74ec18bb1ef2309dd16516345b75839d2793bf9c5bfbd1e1d1baa0e",
878
- "bytes": 388
877
+ "sha256": "ce63e2e63cfc316579d5f269210a60913beead0a131acb0cec8ad228ea81888f",
878
+ "bytes": 437
879
879
  },
880
880
  "mcp/validation/suggestion-config.js": {
881
- "sha256": "efda43e48812979d0ddae2abe23809b6b5a3e5b955e74ca5a67716933e468db4",
882
- "bytes": 592
881
+ "sha256": "907d37fdb1058491d27739f14b32a0371b79d892f5c193503d0c9e34833c444b",
882
+ "bytes": 667
883
883
  },
884
884
  "mcp/validation/suggestion-generator.d.ts": {
885
885
  "sha256": "159bde7596e7459f6025e152a24f1ab850d5cbd2bf55461036a05709dc5dbaa1",
886
886
  "bytes": 731
887
887
  },
888
888
  "mcp/validation/suggestion-generator.js": {
889
- "sha256": "e4988260027f7c17398da69a7b1b8dcbb266f1b42100c63723a6d99426a0802e",
890
- "bytes": 5250
889
+ "sha256": "e4e6740c4010b550de89ae97d50b9e66eebb8d34de13c33a62a6988c34264e79",
890
+ "bytes": 5284
891
891
  },
892
892
  "mcp/validation/suggestion-types.d.ts": {
893
893
  "sha256": "b93ae2e42f4b24789dcbe19db31a41af9534ad0dca85635339c2a10db42e298b",
@@ -3,5 +3,5 @@ import type { ToolContext, ToolResult } from './types.js';
3
3
  import type { PreValidateResult } from './validation/workflow-next-prevalidate.js';
4
4
  import type { WrappedToolHandler, McpCallToolResult } from './types/workflow-tool-edition.js';
5
5
  export declare function toMcpResult<T>(result: ToolResult<T>): McpCallToolResult;
6
- export declare function createHandler<TInput extends z.ZodType, TOutput>(schema: TInput, handler: (input: z.infer<TInput>, ctx: ToolContext) => Promise<ToolResult<TOutput>>): WrappedToolHandler;
6
+ export declare function createHandler<TInput extends z.ZodType, TOutput>(schema: TInput, handler: (input: z.infer<TInput>, ctx: ToolContext) => Promise<ToolResult<TOutput>>, shapeSchema?: z.ZodObject<z.ZodRawShape>): WrappedToolHandler;
7
7
  export declare function createValidatingHandler<TInput extends z.ZodType, TOutput>(schema: TInput, preValidate: (args: unknown) => PreValidateResult, handler: (input: z.infer<TInput>, ctx: ToolContext) => Promise<ToolResult<TOutput>>): WrappedToolHandler;
@@ -28,13 +28,14 @@ function toMcpResult(result) {
28
28
  };
29
29
  }
30
30
  }
31
- function createHandler(schema, handler) {
31
+ function createHandler(schema, handler, shapeSchema) {
32
32
  return async (args, ctx) => {
33
33
  const parseResult = schema.safeParse(args);
34
34
  if (!parseResult.success) {
35
- const suggestionResult = (0, index_js_1.generateSuggestions)(args, schema, index_js_1.DEFAULT_SUGGESTION_CONFIG);
35
+ const introspectionSchema = shapeSchema ?? schema;
36
+ const suggestionResult = (0, index_js_1.generateSuggestions)(args, introspectionSchema, index_js_1.DEFAULT_SUGGESTION_CONFIG);
36
37
  const suggestionDetails = (0, index_js_1.formatSuggestionDetails)(suggestionResult);
37
- const patchedTemplate = (0, index_js_1.patchTemplateForFailedOptionals)(suggestionDetails.correctTemplate ?? null, args, parseResult.error.errors, schema, index_js_1.DEFAULT_SUGGESTION_CONFIG.maxTemplateDepth);
38
+ const patchedTemplate = (0, index_js_1.patchTemplateForFailedOptionals)(suggestionDetails.correctTemplate ?? null, args, parseResult.error.errors, introspectionSchema, index_js_1.DEFAULT_SUGGESTION_CONFIG.maxTemplateDepth);
38
39
  const patchedDetails = patchedTemplate !== suggestionDetails.correctTemplate
39
40
  ? { ...suggestionDetails, correctTemplate: patchedTemplate }
40
41
  : suggestionDetails;
@@ -50,7 +50,7 @@ function buildV2ToolRegistry(buildTool) {
50
50
  list_workflows: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ListWorkflowsInput, v2_workflow_js_1.handleV2ListWorkflows),
51
51
  inspect_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2InspectWorkflowInput, v2_workflow_js_1.handleV2InspectWorkflow),
52
52
  start_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2StartWorkflowInput, v2_execution_js_1.handleV2StartWorkflow),
53
- continue_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ContinueWorkflowInput, v2_execution_js_1.handleV2ContinueWorkflow),
53
+ continue_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ContinueWorkflowInput, v2_execution_js_1.handleV2ContinueWorkflow, tools_js_1.V2ContinueWorkflowInputShape),
54
54
  checkpoint_workflow: (0, handler_factory_js_1.createHandler)(tools_js_1.V2CheckpointWorkflowInput, v2_checkpoint_js_1.handleV2CheckpointWorkflow),
55
55
  resume_session: (0, handler_factory_js_1.createHandler)(tools_js_1.V2ResumeSessionInput, v2_resume_js_1.handleV2ResumeSession),
56
56
  };
@@ -27,6 +27,40 @@ export declare const V2StartWorkflowInput: z.ZodObject<{
27
27
  workspacePath?: string | undefined;
28
28
  }>;
29
29
  export type V2StartWorkflowInput = z.infer<typeof V2StartWorkflowInput>;
30
+ export declare const V2ContinueWorkflowInputShape: z.ZodObject<{
31
+ intent: z.ZodOptional<z.ZodEnum<["advance", "rehydrate"]>>;
32
+ stateToken: z.ZodString;
33
+ ackToken: z.ZodOptional<z.ZodString>;
34
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
+ output: z.ZodOptional<z.ZodObject<{
36
+ notesMarkdown: z.ZodOptional<z.ZodString>;
37
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ notesMarkdown?: string | undefined;
40
+ artifacts?: unknown[] | undefined;
41
+ }, {
42
+ notesMarkdown?: string | undefined;
43
+ artifacts?: unknown[] | undefined;
44
+ }>>;
45
+ }, "strict", z.ZodTypeAny, {
46
+ stateToken: string;
47
+ context?: Record<string, unknown> | undefined;
48
+ output?: {
49
+ notesMarkdown?: string | undefined;
50
+ artifacts?: unknown[] | undefined;
51
+ } | undefined;
52
+ intent?: "advance" | "rehydrate" | undefined;
53
+ ackToken?: string | undefined;
54
+ }, {
55
+ stateToken: string;
56
+ context?: Record<string, unknown> | undefined;
57
+ output?: {
58
+ notesMarkdown?: string | undefined;
59
+ artifacts?: unknown[] | undefined;
60
+ } | undefined;
61
+ intent?: "advance" | "rehydrate" | undefined;
62
+ ackToken?: string | undefined;
63
+ }>;
30
64
  export declare const V2ContinueWorkflowInput: z.ZodPipeline<z.ZodEffects<z.ZodObject<{
31
65
  intent: z.ZodOptional<z.ZodEnum<["advance", "rehydrate"]>>;
32
66
  stateToken: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.V2_TOOL_ANNOTATIONS = exports.V2_TOOL_TITLES = exports.V2CheckpointWorkflowInput = exports.V2ResumeSessionInput = exports.V2ContinueWorkflowInput = exports.V2StartWorkflowInput = exports.V2InspectWorkflowInput = exports.V2ListWorkflowsInput = void 0;
3
+ exports.V2_TOOL_ANNOTATIONS = exports.V2_TOOL_TITLES = exports.V2CheckpointWorkflowInput = exports.V2ResumeSessionInput = exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape = exports.V2StartWorkflowInput = exports.V2InspectWorkflowInput = exports.V2ListWorkflowsInput = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.V2ListWorkflowsInput = zod_1.z.object({});
6
6
  exports.V2InspectWorkflowInput = zod_1.z.object({
@@ -15,7 +15,7 @@ exports.V2StartWorkflowInput = zod_1.z.object({
15
15
  .optional()
16
16
  .describe('Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). Used to anchor this session to your workspace for future resume_session discovery. Pass this on every start_workflow call. If omitted, WorkRail uses the server process directory which may not match your workspace.'),
17
17
  });
18
- exports.V2ContinueWorkflowInput = zod_1.z.object({
18
+ exports.V2ContinueWorkflowInputShape = zod_1.z.object({
19
19
  intent: zod_1.z.enum(['advance', 'rehydrate']).optional().describe('What you want to do. Auto-inferred from ackToken if omitted: ' +
20
20
  'ackToken present → "advance", ackToken absent → "rehydrate". ' +
21
21
  '"advance": I completed the current step — requires ackToken. ' +
@@ -30,10 +30,13 @@ exports.V2ContinueWorkflowInput = zod_1.z.object({
30
30
  })
31
31
  .optional()
32
32
  .describe('Durable output to attach to the current node. Only valid when intent is "advance".'),
33
- }).strict().transform((data) => {
33
+ }).strict();
34
+ exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape
35
+ .transform((data) => {
34
36
  const intent = data.intent ?? (data.ackToken ? 'advance' : 'rehydrate');
35
37
  return { ...data, intent };
36
- }).pipe(zod_1.z.custom().superRefine((data, ctx) => {
38
+ })
39
+ .pipe(zod_1.z.custom().superRefine((data, ctx) => {
37
40
  if (data.intent === 'advance' && !data.ackToken) {
38
41
  ctx.addIssue({
39
42
  code: zod_1.z.ZodIssueCode.custom,
@@ -3,6 +3,6 @@ export declare function extractExpectedKeys(schema: z.ZodType): readonly string[
3
3
  export declare function extractRequiredKeys(schema: z.ZodType): readonly string[];
4
4
  export declare function findUnknownKeys(args: unknown, schema: z.ZodType): readonly string[];
5
5
  export declare function findMissingRequiredKeys(args: unknown, schema: z.ZodType): readonly string[];
6
- export declare function generateExampleValue(schema: z.ZodType, depth?: number, maxDepth?: number): unknown;
7
- export declare function generateTemplate(schema: z.ZodType, maxDepth?: number): Readonly<Record<string, unknown>> | null;
6
+ export declare function generateExampleValue(schema: z.ZodType, depth?: number, maxDepth?: number, includeOptional?: boolean): unknown;
7
+ export declare function generateTemplate(schema: z.ZodType, maxDepth?: number, includeOptional?: boolean): Readonly<Record<string, unknown>> | null;
8
8
  export declare function extractEnumValues(schema: z.ZodType, path: string): readonly string[];
@@ -44,7 +44,7 @@ function findMissingRequiredKeys(args, schema) {
44
44
  const requiredKeys = extractRequiredKeys(schema);
45
45
  return requiredKeys.filter(key => !providedKeys.has(key));
46
46
  }
47
- function generateExampleValue(schema, depth = 0, maxDepth = 3) {
47
+ function generateExampleValue(schema, depth = 0, maxDepth = 3, includeOptional = false) {
48
48
  if (depth > maxDepth) {
49
49
  return '...';
50
50
  }
@@ -52,23 +52,23 @@ function generateExampleValue(schema, depth = 0, maxDepth = 3) {
52
52
  return schema._def.defaultValue();
53
53
  }
54
54
  if (schema instanceof zod_1.z.ZodOptional) {
55
- return generateExampleValue(schema._def.innerType, depth, maxDepth);
55
+ return generateExampleValue(schema._def.innerType, depth, maxDepth, includeOptional);
56
56
  }
57
57
  if (schema instanceof zod_1.z.ZodObject) {
58
58
  const shape = schema._def.shape();
59
59
  const result = {};
60
60
  for (const [key, value] of Object.entries(shape)) {
61
61
  const field = value;
62
- if (field instanceof zod_1.z.ZodOptional)
62
+ if (!includeOptional && field instanceof zod_1.z.ZodOptional)
63
63
  continue;
64
- result[key] = generateExampleValue(field, depth + 1, maxDepth);
64
+ result[key] = generateExampleValue(field, depth + 1, maxDepth, includeOptional);
65
65
  }
66
66
  return result;
67
67
  }
68
68
  if (schema instanceof zod_1.z.ZodDiscriminatedUnion) {
69
69
  const options = schema._def.options;
70
70
  if (options.length > 0) {
71
- return generateExampleValue(options[0], depth + 1, maxDepth);
71
+ return generateExampleValue(options[0], depth + 1, maxDepth, includeOptional);
72
72
  }
73
73
  return {};
74
74
  }
@@ -105,15 +105,15 @@ function generateExampleValue(schema, depth = 0, maxDepth = 3) {
105
105
  return '<any>';
106
106
  }
107
107
  if (schema instanceof zod_1.z.ZodEffects) {
108
- return generateExampleValue(schema._def.schema, depth, maxDepth);
108
+ return generateExampleValue(schema._def.schema, depth, maxDepth, includeOptional);
109
109
  }
110
110
  return '<unknown>';
111
111
  }
112
- function generateTemplate(schema, maxDepth = 3) {
112
+ function generateTemplate(schema, maxDepth = 3, includeOptional = false) {
113
113
  if (!(schema instanceof zod_1.z.ZodObject)) {
114
114
  return null;
115
115
  }
116
- const example = generateExampleValue(schema, 0, maxDepth);
116
+ const example = generateExampleValue(schema, 0, maxDepth, includeOptional);
117
117
  if (typeof example === 'object' && example !== null) {
118
118
  return example;
119
119
  }
@@ -4,6 +4,7 @@ export interface SuggestionConfig {
4
4
  readonly maxSuggestions: number;
5
5
  readonly includeTemplate: boolean;
6
6
  readonly maxTemplateDepth: number;
7
+ readonly includeOptionalInTemplate: boolean;
7
8
  }
8
9
  export declare const DEFAULT_SUGGESTION_CONFIG: SuggestionConfig;
9
10
  export declare const MINIMAL_SUGGESTION_CONFIG: SuggestionConfig;
@@ -7,10 +7,12 @@ exports.DEFAULT_SUGGESTION_CONFIG = {
7
7
  maxSuggestions: 3,
8
8
  includeTemplate: true,
9
9
  maxTemplateDepth: 3,
10
+ includeOptionalInTemplate: true,
10
11
  };
11
12
  exports.MINIMAL_SUGGESTION_CONFIG = {
12
13
  similarityThreshold: (0, suggestion_types_js_1.similarity)(0.7),
13
14
  maxSuggestions: 1,
14
15
  includeTemplate: false,
15
16
  maxTemplateDepth: 1,
17
+ includeOptionalInTemplate: false,
16
18
  };
@@ -56,7 +56,7 @@ function generateSuggestions(args, schema, config) {
56
56
  return suggestion_types_js_1.EMPTY_SUGGESTION_RESULT;
57
57
  }
58
58
  const correctTemplate = config.includeTemplate
59
- ? (0, schema_introspection_js_1.generateTemplate)(schema, config.maxTemplateDepth)
59
+ ? (0, schema_introspection_js_1.generateTemplate)(schema, config.maxTemplateDepth, config.includeOptionalInTemplate)
60
60
  : null;
61
61
  return {
62
62
  suggestions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Step-by-step workflow enforcement for AI agents via MCP",
5
5
  "license": "MIT",
6
6
  "repository": {