@exaudeus/workrail 1.7.0 → 1.7.1

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.
@@ -526,8 +526,8 @@
526
526
  "bytes": 796
527
527
  },
528
528
  "mcp/handler-factory.js": {
529
- "sha256": "fca1b2d87d7d0961bc0c3ec337d5c18ffe8a379964af3836b1ac532bab1195ea",
530
- "bytes": 3382
529
+ "sha256": "711bdf8bd71eaf2ad2a6b6b1bf84db004030e06223ce52075e01470a3bffd88d",
530
+ "bytes": 3805
531
531
  },
532
532
  "mcp/handlers/session.d.ts": {
533
533
  "sha256": "38926e69a0e4935d1dbcdc53848be9fff0e4d8f96827883da3216f217918fa82",
@@ -838,8 +838,8 @@
838
838
  "bytes": 5486
839
839
  },
840
840
  "mcp/v2/tools.js": {
841
- "sha256": "0d26b75a7e038f494570f5fdc1d624f5bb28bfa7e368ea4d3259ae27dc889301",
842
- "bytes": 7748
841
+ "sha256": "5af4e1a5a3a6c43df6db4ea40eb6d12fd0757af94f4e3e80d9f875ecf0181544",
842
+ "bytes": 7812
843
843
  },
844
844
  "mcp/validation/bounded-json.d.ts": {
845
845
  "sha256": "82203ac6123d5c6989606c3b5405aaea99ab829c8958835f9ae3ba45b8bc8fd5",
@@ -850,12 +850,12 @@
850
850
  "bytes": 834
851
851
  },
852
852
  "mcp/validation/index.d.ts": {
853
- "sha256": "3e3f12357fd8214470d111454e4002338e5eb93329b5a3758664db51e44c12ec",
854
- "bytes": 944
853
+ "sha256": "2e1bf908d402aa27f939aa1ee8dd78e38ccd6f0d6f5c19e6c18c93807e8fffce",
854
+ "bytes": 1036
855
855
  },
856
856
  "mcp/validation/index.js": {
857
- "sha256": "dccd3a2dc7e486afd27ee44f77303486f60cc840563821b97ac341f9cad6650c",
858
- "bytes": 4445
857
+ "sha256": "5ab761835388b0dd353293312899ded3433fe69121b38317f6ddf3ab2a6587dc",
858
+ "bytes": 4664
859
859
  },
860
860
  "mcp/validation/schema-introspection.d.ts": {
861
861
  "sha256": "7e0262e76234dd37079156027e95a30987b8949351f3e9ec0fd7b2be093a159d",
@@ -882,12 +882,12 @@
882
882
  "bytes": 592
883
883
  },
884
884
  "mcp/validation/suggestion-generator.d.ts": {
885
- "sha256": "491d983f4a03516fc0ba09ff40da2c859ec600f29a41093b0359ba549c7882cc",
886
- "bytes": 450
885
+ "sha256": "159bde7596e7459f6025e152a24f1ab850d5cbd2bf55461036a05709dc5dbaa1",
886
+ "bytes": 731
887
887
  },
888
888
  "mcp/validation/suggestion-generator.js": {
889
- "sha256": "e952a4d3cb569222cde1bd01dd9d5be887ee394ba007478bbb446fa177172859",
890
- "bytes": 4075
889
+ "sha256": "e4988260027f7c17398da69a7b1b8dcbb266f1b42100c63723a6d99426a0802e",
890
+ "bytes": 5250
891
891
  },
892
892
  "mcp/validation/suggestion-types.d.ts": {
893
893
  "sha256": "b93ae2e42f4b24789dcbe19db31a41af9534ad0dca85635339c2a10db42e298b",
@@ -34,12 +34,16 @@ function createHandler(schema, handler) {
34
34
  if (!parseResult.success) {
35
35
  const suggestionResult = (0, index_js_1.generateSuggestions)(args, schema, index_js_1.DEFAULT_SUGGESTION_CONFIG);
36
36
  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 patchedDetails = patchedTemplate !== suggestionDetails.correctTemplate
39
+ ? { ...suggestionDetails, correctTemplate: patchedTemplate }
40
+ : suggestionDetails;
37
41
  return toMcpResult((0, types_js_1.errNotRetryable)('VALIDATION_ERROR', 'Invalid input', {
38
42
  validationErrors: parseResult.error.errors.map(e => ({
39
43
  path: e.path.join('.'),
40
44
  message: e.message,
41
45
  })),
42
- ...suggestionDetails,
46
+ ...patchedDetails,
43
47
  }));
44
48
  }
45
49
  try {
@@ -9,7 +9,7 @@ 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('External facts influencing execution (ticketId, branch, constraints). Pass once at start to establish baseline. WorkRail auto-loads context on subsequent continue_workflow calls. Only pass context again if facts have CHANGED (e.g., user provided new information). Do NOT re-pass unchanged values.'),
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
13
  workspacePath: zod_1.z.string()
14
14
  .refine((p) => p.startsWith('/'), 'workspacePath must be an absolute path (starting with /)')
15
15
  .optional()
@@ -4,4 +4,5 @@ export type { SuggestionConfig } from './suggestion-config.js';
4
4
  export { DEFAULT_SUGGESTION_CONFIG, MINIMAL_SUGGESTION_CONFIG } from './suggestion-config.js';
5
5
  export { levenshteinDistance, computeSimilarity, computeSimilarityIgnoreCase, findClosestMatch, findAllMatches, type ClosestMatch, } from './string-similarity.js';
6
6
  export { extractExpectedKeys, extractRequiredKeys, findUnknownKeys, findMissingRequiredKeys, generateExampleValue, generateTemplate, extractEnumValues, } from './schema-introspection.js';
7
- export { generateSuggestions, formatSuggestionDetails, hasSuggestions, } from './suggestion-generator.js';
7
+ export { generateSuggestions, formatSuggestionDetails, hasSuggestions, patchTemplateForFailedOptionals, } from './suggestion-generator.js';
8
+ export type { ZodIssue } from './suggestion-generator.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasSuggestions = exports.formatSuggestionDetails = exports.generateSuggestions = exports.extractEnumValues = exports.generateTemplate = exports.generateExampleValue = exports.findMissingRequiredKeys = exports.findUnknownKeys = exports.extractRequiredKeys = exports.extractExpectedKeys = exports.findAllMatches = exports.findClosestMatch = exports.computeSimilarityIgnoreCase = exports.computeSimilarity = exports.levenshteinDistance = exports.MINIMAL_SUGGESTION_CONFIG = exports.DEFAULT_SUGGESTION_CONFIG = exports.isInvalidEnumSuggestion = exports.isMissingRequiredSuggestion = exports.isUnknownKeySuggestion = exports.EMPTY_SUGGESTION_RESULT = exports.similarity = void 0;
3
+ exports.patchTemplateForFailedOptionals = exports.hasSuggestions = exports.formatSuggestionDetails = exports.generateSuggestions = exports.extractEnumValues = exports.generateTemplate = exports.generateExampleValue = exports.findMissingRequiredKeys = exports.findUnknownKeys = exports.extractRequiredKeys = exports.extractExpectedKeys = exports.findAllMatches = exports.findClosestMatch = exports.computeSimilarityIgnoreCase = exports.computeSimilarity = exports.levenshteinDistance = exports.MINIMAL_SUGGESTION_CONFIG = exports.DEFAULT_SUGGESTION_CONFIG = exports.isInvalidEnumSuggestion = exports.isMissingRequiredSuggestion = exports.isUnknownKeySuggestion = exports.EMPTY_SUGGESTION_RESULT = exports.similarity = void 0;
4
4
  var suggestion_types_js_1 = require("./suggestion-types.js");
5
5
  Object.defineProperty(exports, "similarity", { enumerable: true, get: function () { return suggestion_types_js_1.similarity; } });
6
6
  Object.defineProperty(exports, "EMPTY_SUGGESTION_RESULT", { enumerable: true, get: function () { return suggestion_types_js_1.EMPTY_SUGGESTION_RESULT; } });
@@ -28,3 +28,4 @@ var suggestion_generator_js_1 = require("./suggestion-generator.js");
28
28
  Object.defineProperty(exports, "generateSuggestions", { enumerable: true, get: function () { return suggestion_generator_js_1.generateSuggestions; } });
29
29
  Object.defineProperty(exports, "formatSuggestionDetails", { enumerable: true, get: function () { return suggestion_generator_js_1.formatSuggestionDetails; } });
30
30
  Object.defineProperty(exports, "hasSuggestions", { enumerable: true, get: function () { return suggestion_generator_js_1.hasSuggestions; } });
31
+ Object.defineProperty(exports, "patchTemplateForFailedOptionals", { enumerable: true, get: function () { return suggestion_generator_js_1.patchTemplateForFailedOptionals; } });
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import type { SuggestionConfig } from './suggestion-config.js';
3
3
  import type { SuggestionResult } from './suggestion-types.js';
4
+ export type { ZodIssue } from 'zod';
4
5
  export declare function generateSuggestions(args: unknown, schema: z.ZodType, config: SuggestionConfig): SuggestionResult;
5
6
  export declare function formatSuggestionDetails(result: SuggestionResult): Record<string, unknown>;
6
7
  export declare function hasSuggestions(result: SuggestionResult): boolean;
8
+ export declare function patchTemplateForFailedOptionals(correctTemplate: Readonly<Record<string, unknown>> | null, args: unknown, zodErrors: readonly z.ZodIssue[], schema: z.ZodType, maxDepth: number): Readonly<Record<string, unknown>> | null;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSuggestions = generateSuggestions;
4
4
  exports.formatSuggestionDetails = formatSuggestionDetails;
5
5
  exports.hasSuggestions = hasSuggestions;
6
+ exports.patchTemplateForFailedOptionals = patchTemplateForFailedOptionals;
6
7
  const zod_1 = require("zod");
7
8
  const suggestion_types_js_1 = require("./suggestion-types.js");
8
9
  const string_similarity_js_1 = require("./string-similarity.js");
@@ -99,3 +100,32 @@ function formatSuggestionDetails(result) {
99
100
  function hasSuggestions(result) {
100
101
  return result.suggestions.length > 0 || result.correctTemplate !== null;
101
102
  }
103
+ function patchTemplateForFailedOptionals(correctTemplate, args, zodErrors, schema, maxDepth) {
104
+ if (correctTemplate === null)
105
+ return null;
106
+ if (!(schema instanceof zod_1.z.ZodObject))
107
+ return correctTemplate;
108
+ if (args === null || typeof args !== 'object' || Array.isArray(args))
109
+ return correctTemplate;
110
+ const argsObj = args;
111
+ const shape = schema._def.shape();
112
+ const patched = { ...correctTemplate };
113
+ let changed = false;
114
+ for (const error of zodErrors) {
115
+ if (error.path.length !== 1)
116
+ continue;
117
+ const field = error.path[0];
118
+ if (!(field in argsObj))
119
+ continue;
120
+ if (!(field in shape))
121
+ continue;
122
+ if (field in patched)
123
+ continue;
124
+ const fieldSchema = shape[field];
125
+ if (!(fieldSchema instanceof zod_1.z.ZodOptional))
126
+ continue;
127
+ patched[field] = (0, schema_introspection_js_1.generateExampleValue)(fieldSchema._def.innerType, 0, maxDepth);
128
+ changed = true;
129
+ }
130
+ return changed ? Object.freeze(patched) : correctTemplate;
131
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Step-by-step workflow enforcement for AI agents via MCP",
5
5
  "license": "MIT",
6
6
  "repository": {