cyrus-edge-worker 0.2.5 → 0.2.7

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 (59) hide show
  1. package/dist/AgentSessionManager.d.ts +42 -5
  2. package/dist/AgentSessionManager.d.ts.map +1 -1
  3. package/dist/AgentSessionManager.js +143 -16
  4. package/dist/AgentSessionManager.js.map +1 -1
  5. package/dist/AskUserQuestionHandler.d.ts +96 -0
  6. package/dist/AskUserQuestionHandler.d.ts.map +1 -0
  7. package/dist/AskUserQuestionHandler.js +203 -0
  8. package/dist/AskUserQuestionHandler.js.map +1 -0
  9. package/dist/EdgeWorker.d.ts +72 -11
  10. package/dist/EdgeWorker.d.ts.map +1 -1
  11. package/dist/EdgeWorker.js +469 -124
  12. package/dist/EdgeWorker.js.map +1 -1
  13. package/dist/GitService.d.ts +34 -0
  14. package/dist/GitService.d.ts.map +1 -0
  15. package/dist/GitService.js +347 -0
  16. package/dist/GitService.js.map +1 -0
  17. package/dist/SharedApplicationServer.d.ts +2 -1
  18. package/dist/SharedApplicationServer.d.ts.map +1 -1
  19. package/dist/SharedApplicationServer.js +5 -3
  20. package/dist/SharedApplicationServer.js.map +1 -1
  21. package/dist/index.d.ts +5 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/procedures/{ProcedureRouter.d.ts → ProcedureAnalyzer.d.ts} +11 -11
  26. package/dist/procedures/ProcedureAnalyzer.d.ts.map +1 -0
  27. package/dist/procedures/{ProcedureRouter.js → ProcedureAnalyzer.js} +21 -14
  28. package/dist/procedures/ProcedureAnalyzer.js.map +1 -0
  29. package/dist/procedures/index.d.ts +2 -2
  30. package/dist/procedures/index.d.ts.map +1 -1
  31. package/dist/procedures/index.js +2 -2
  32. package/dist/procedures/index.js.map +1 -1
  33. package/dist/procedures/registry.d.ts +20 -1
  34. package/dist/procedures/registry.d.ts.map +1 -1
  35. package/dist/procedures/registry.js +26 -1
  36. package/dist/procedures/registry.js.map +1 -1
  37. package/dist/procedures/types.d.ts +29 -5
  38. package/dist/procedures/types.d.ts.map +1 -1
  39. package/dist/procedures/types.js +1 -1
  40. package/dist/prompts/subroutines/user-testing-summary.md +87 -0
  41. package/dist/prompts/subroutines/user-testing.md +48 -0
  42. package/dist/prompts/subroutines/validation-fixer.md +56 -0
  43. package/dist/prompts/subroutines/verifications.md +51 -24
  44. package/dist/validation/ValidationLoopController.d.ts +54 -0
  45. package/dist/validation/ValidationLoopController.d.ts.map +1 -0
  46. package/dist/validation/ValidationLoopController.js +242 -0
  47. package/dist/validation/ValidationLoopController.js.map +1 -0
  48. package/dist/validation/index.d.ts +7 -0
  49. package/dist/validation/index.d.ts.map +1 -0
  50. package/dist/validation/index.js +7 -0
  51. package/dist/validation/index.js.map +1 -0
  52. package/dist/validation/types.d.ts +90 -0
  53. package/dist/validation/types.d.ts.map +1 -0
  54. package/dist/validation/types.js +33 -0
  55. package/dist/validation/types.js.map +1 -0
  56. package/package.json +10 -8
  57. package/prompts/graphite-orchestrator.md +360 -0
  58. package/dist/procedures/ProcedureRouter.d.ts.map +0 -1
  59. package/dist/procedures/ProcedureRouter.js.map +0 -1
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ValidationLoopController - Orchestrates the validation loop with retry logic
3
+ *
4
+ * This controller manages the validation loop that runs verifications and fixes
5
+ * up to a configurable maximum number of iterations.
6
+ */
7
+ import type { ValidationFixerContext, ValidationLoopConfig, ValidationLoopState, ValidationResult } from "./types.js";
8
+ import { VALIDATION_RESULT_SCHEMA } from "./types.js";
9
+ /**
10
+ * Parse a validation result from an agent's response
11
+ *
12
+ * Supports multiple formats:
13
+ * 1. Native structured output (message.structured_output) - validated with Zod
14
+ * 2. JSON in response text - validated with Zod
15
+ * 3. Fallback prompt engineering extraction (for Gemini and other runners)
16
+ */
17
+ export declare function parseValidationResult(response: string | undefined, structuredOutput?: unknown): ValidationResult;
18
+ /**
19
+ * Get the JSON schema for validation results
20
+ */
21
+ export declare function getValidationResultSchema(): typeof VALIDATION_RESULT_SCHEMA;
22
+ /**
23
+ * Load the validation-fixer prompt template
24
+ */
25
+ export declare function loadValidationFixerPrompt(): string;
26
+ /**
27
+ * Render the validation-fixer prompt with context
28
+ */
29
+ export declare function renderValidationFixerPrompt(context: ValidationFixerContext): string;
30
+ /**
31
+ * Create initial validation loop state
32
+ */
33
+ export declare function createInitialState(): ValidationLoopState;
34
+ /**
35
+ * Record a validation attempt and determine next action
36
+ */
37
+ export declare function recordAttempt(state: ValidationLoopState, result: ValidationResult, config?: ValidationLoopConfig): ValidationLoopState;
38
+ /**
39
+ * Get the fixer context for the current state
40
+ */
41
+ export declare function getFixerContext(state: ValidationLoopState, config?: ValidationLoopConfig): ValidationFixerContext | null;
42
+ /**
43
+ * Check if the validation loop should continue
44
+ */
45
+ export declare function shouldContinueLoop(state: ValidationLoopState): boolean;
46
+ /**
47
+ * Check if we should proceed to the next subroutine after validation
48
+ */
49
+ export declare function shouldProceedAfterValidation(state: ValidationLoopState, config?: ValidationLoopConfig): boolean;
50
+ /**
51
+ * Get a summary of the validation loop execution
52
+ */
53
+ export declare function getValidationSummary(state: ValidationLoopState): string;
54
+ //# sourceMappingURL=ValidationLoopController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationLoopController.d.ts","sourceRoot":"","sources":["../../src/validation/ValidationLoopController.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACX,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEN,wBAAwB,EAExB,MAAM,YAAY,CAAC;AAMpB;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,gBAAgB,CAAC,EAAE,OAAO,GACxB,gBAAgB,CAqGlB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,wBAAwB,CAE3E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CASlD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,sBAAsB,GAC7B,MAAM,CA4BR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAOxD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,MAAM,GAAE,oBAAqD,GAC3D,mBAAmB,CAmCrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,mBAAmB,EAC1B,MAAM,GAAE,oBAAqD,GAC3D,sBAAsB,GAAG,IAAI,CAmB/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAEtE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,mBAAmB,EAC1B,MAAM,GAAE,oBAAqD,GAC3D,OAAO,CAWT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAcvE"}
@@ -0,0 +1,242 @@
1
+ /**
2
+ * ValidationLoopController - Orchestrates the validation loop with retry logic
3
+ *
4
+ * This controller manages the validation loop that runs verifications and fixes
5
+ * up to a configurable maximum number of iterations.
6
+ */
7
+ import { readFileSync } from "node:fs";
8
+ import { dirname, join } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ import { DEFAULT_VALIDATION_LOOP_CONFIG, VALIDATION_RESULT_SCHEMA, ValidationResultSchema, } from "./types.js";
11
+ // Get __dirname equivalent for ESM
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+ /**
15
+ * Parse a validation result from an agent's response
16
+ *
17
+ * Supports multiple formats:
18
+ * 1. Native structured output (message.structured_output) - validated with Zod
19
+ * 2. JSON in response text - validated with Zod
20
+ * 3. Fallback prompt engineering extraction (for Gemini and other runners)
21
+ */
22
+ export function parseValidationResult(response, structuredOutput) {
23
+ // 1. Try native structured output first (Claude SDK) - validate with Zod
24
+ if (structuredOutput && typeof structuredOutput === "object") {
25
+ const parsed = ValidationResultSchema.safeParse(structuredOutput);
26
+ if (parsed.success) {
27
+ return parsed.data;
28
+ }
29
+ // Log validation error for debugging but continue to fallback methods
30
+ console.debug("[parseValidationResult] Structured output validation failed:", parsed.error.message);
31
+ }
32
+ // 2. Try to parse JSON from response - validate with Zod
33
+ if (response) {
34
+ // Try to extract JSON from markdown code blocks
35
+ const jsonMatch = response.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
36
+ const jsonString = jsonMatch
37
+ ? (jsonMatch[1] ?? "").trim()
38
+ : response.trim();
39
+ try {
40
+ const jsonParsed = JSON.parse(jsonString);
41
+ const zodParsed = ValidationResultSchema.safeParse(jsonParsed);
42
+ if (zodParsed.success) {
43
+ return zodParsed.data;
44
+ }
45
+ }
46
+ catch {
47
+ // JSON parsing failed, continue to fallback
48
+ }
49
+ // 3. Fallback: try to infer from response text (for Gemini and other runners)
50
+ const lowerResponse = response.toLowerCase();
51
+ // Check for explicit pass/fail indicators
52
+ if (lowerResponse.includes('"pass": true') ||
53
+ lowerResponse.includes('"pass":true') ||
54
+ lowerResponse.includes("pass: true")) {
55
+ // Extract reason if possible
56
+ const reasonMatch = response.match(/"reason"\s*:\s*"([^"]+)"|reason:\s*["']?([^"'\n]+)/i);
57
+ return {
58
+ pass: true,
59
+ reason: reasonMatch
60
+ ? (reasonMatch[1] ?? reasonMatch[2] ?? "Verifications passed")
61
+ : "Verifications passed",
62
+ };
63
+ }
64
+ if (lowerResponse.includes('"pass": false') ||
65
+ lowerResponse.includes('"pass":false') ||
66
+ lowerResponse.includes("pass: false")) {
67
+ const reasonMatch = response.match(/"reason"\s*:\s*"([^"]+)"|reason:\s*["']?([^"'\n]+)/i);
68
+ return {
69
+ pass: false,
70
+ reason: reasonMatch
71
+ ? (reasonMatch[1] ?? reasonMatch[2] ?? "Verifications failed")
72
+ : "Verifications failed",
73
+ };
74
+ }
75
+ // Last resort: look for success/failure indicators in natural language
76
+ if (lowerResponse.includes("all verifications passed") ||
77
+ lowerResponse.includes("all tests pass") ||
78
+ lowerResponse.includes("verifications successful")) {
79
+ return {
80
+ pass: true,
81
+ reason: response.substring(0, 200),
82
+ };
83
+ }
84
+ if (lowerResponse.includes("verification failed") ||
85
+ lowerResponse.includes("tests failed") ||
86
+ lowerResponse.includes("error") ||
87
+ lowerResponse.includes("failure")) {
88
+ return {
89
+ pass: false,
90
+ reason: response.substring(0, 500),
91
+ };
92
+ }
93
+ }
94
+ // Default: assume failure if we can't parse
95
+ return {
96
+ pass: false,
97
+ reason: response
98
+ ? `Could not parse validation result: ${response.substring(0, 200)}`
99
+ : "No response received from validation",
100
+ };
101
+ }
102
+ /**
103
+ * Get the JSON schema for validation results
104
+ */
105
+ export function getValidationResultSchema() {
106
+ return VALIDATION_RESULT_SCHEMA;
107
+ }
108
+ /**
109
+ * Load the validation-fixer prompt template
110
+ */
111
+ export function loadValidationFixerPrompt() {
112
+ const promptPath = join(__dirname, "..", "prompts", "subroutines", "validation-fixer.md");
113
+ return readFileSync(promptPath, "utf-8");
114
+ }
115
+ /**
116
+ * Render the validation-fixer prompt with context
117
+ */
118
+ export function renderValidationFixerPrompt(context) {
119
+ let template = loadValidationFixerPrompt();
120
+ // Replace template variables
121
+ template = template.replace("{{FAILURE_REASON}}", context.failureReason);
122
+ template = template.replace("{{ITERATION}}", String(context.iteration));
123
+ template = template.replace("{{MAX_ITERATIONS}}", String(context.maxIterations));
124
+ // Handle previous attempts section
125
+ if (context.previousAttempts.length > 0) {
126
+ const attemptsText = context.previousAttempts
127
+ .map((attempt) => `- Attempt ${attempt.iteration}: ${attempt.reason}`)
128
+ .join("\n");
129
+ template = template.replace("{{#if PREVIOUS_ATTEMPTS}}", "");
130
+ template = template.replace("{{/if}}", "");
131
+ template = template.replace("{{PREVIOUS_ATTEMPTS}}", attemptsText);
132
+ }
133
+ else {
134
+ // Remove the conditional block if no previous attempts
135
+ template = template.replace(/{{#if PREVIOUS_ATTEMPTS}}[\s\S]*?{{\/if}}/g, "");
136
+ }
137
+ return template;
138
+ }
139
+ /**
140
+ * Create initial validation loop state
141
+ */
142
+ export function createInitialState() {
143
+ return {
144
+ iteration: 0,
145
+ attempts: [],
146
+ completed: false,
147
+ outcome: "in_progress",
148
+ };
149
+ }
150
+ /**
151
+ * Record a validation attempt and determine next action
152
+ */
153
+ export function recordAttempt(state, result, config = DEFAULT_VALIDATION_LOOP_CONFIG) {
154
+ const newIteration = state.iteration + 1;
155
+ const newAttempts = [
156
+ ...state.attempts,
157
+ {
158
+ iteration: newIteration,
159
+ result,
160
+ timestamp: Date.now(),
161
+ },
162
+ ];
163
+ if (result.pass) {
164
+ return {
165
+ iteration: newIteration,
166
+ attempts: newAttempts,
167
+ completed: true,
168
+ outcome: "passed",
169
+ };
170
+ }
171
+ if (newIteration >= config.maxIterations) {
172
+ return {
173
+ iteration: newIteration,
174
+ attempts: newAttempts,
175
+ completed: true,
176
+ outcome: "failed_max_retries",
177
+ };
178
+ }
179
+ return {
180
+ iteration: newIteration,
181
+ attempts: newAttempts,
182
+ completed: false,
183
+ outcome: "in_progress",
184
+ };
185
+ }
186
+ /**
187
+ * Get the fixer context for the current state
188
+ */
189
+ export function getFixerContext(state, config = DEFAULT_VALIDATION_LOOP_CONFIG) {
190
+ if (state.completed || state.attempts.length === 0) {
191
+ return null;
192
+ }
193
+ const lastAttempt = state.attempts[state.attempts.length - 1];
194
+ if (!lastAttempt) {
195
+ return null;
196
+ }
197
+ return {
198
+ failureReason: lastAttempt.result.reason,
199
+ iteration: state.iteration,
200
+ maxIterations: config.maxIterations,
201
+ previousAttempts: state.attempts.slice(0, -1).map((a) => ({
202
+ iteration: a.iteration,
203
+ reason: a.result.reason,
204
+ })),
205
+ };
206
+ }
207
+ /**
208
+ * Check if the validation loop should continue
209
+ */
210
+ export function shouldContinueLoop(state) {
211
+ return !state.completed && state.outcome === "in_progress";
212
+ }
213
+ /**
214
+ * Check if we should proceed to the next subroutine after validation
215
+ */
216
+ export function shouldProceedAfterValidation(state, config = DEFAULT_VALIDATION_LOOP_CONFIG) {
217
+ if (state.outcome === "passed") {
218
+ return true;
219
+ }
220
+ if (state.outcome === "failed_max_retries") {
221
+ return config.continueOnMaxRetries;
222
+ }
223
+ // Still in progress - shouldn't call this
224
+ return false;
225
+ }
226
+ /**
227
+ * Get a summary of the validation loop execution
228
+ */
229
+ export function getValidationSummary(state) {
230
+ if (state.outcome === "passed") {
231
+ const lastAttempt = state.attempts[state.attempts.length - 1];
232
+ return `Validation passed after ${state.iteration} attempt(s): ${lastAttempt?.result.reason ?? "unknown"}`;
233
+ }
234
+ if (state.outcome === "failed_max_retries") {
235
+ const reasons = state.attempts
236
+ .map((a) => `Attempt ${a.iteration}: ${a.result.reason}`)
237
+ .join("\n");
238
+ return `Validation failed after ${state.iteration} attempts:\n${reasons}`;
239
+ }
240
+ return `Validation in progress: ${state.iteration} attempt(s) so far`;
241
+ }
242
+ //# sourceMappingURL=ValidationLoopController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationLoopController.js","sourceRoot":"","sources":["../../src/validation/ValidationLoopController.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,OAAO,EACN,8BAA8B,EAC9B,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,YAAY,CAAC;AAEpB,mCAAmC;AACnC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;;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CAAC;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,oBAAoB,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC,oBAAoB,CAAC;IACpC,CAAC;IAED,0CAA0C;IAC1C,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA0B;IAC9D,IAAI,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9D,OAAO,2BAA2B,KAAK,CAAC,SAAS,gBAAgB,WAAW,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;IAC5G,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,oBAAoB,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ;aAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;aACxD,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO,2BAA2B,KAAK,CAAC,SAAS,eAAe,OAAO,EAAE,CAAC;IAC3E,CAAC;IAED,OAAO,2BAA2B,KAAK,CAAC,SAAS,oBAAoB,CAAC;AACvE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Validation loop module - provides functionality for running verification
3
+ * subroutines with retry logic and structured outputs
4
+ */
5
+ export { DEFAULT_VALIDATION_LOOP_CONFIG, VALIDATION_RESULT_SCHEMA, type ValidationFixerContext, type ValidationLoopConfig, type ValidationLoopState, type ValidationResult, ValidationResultSchema, } from "./types.js";
6
+ export { createInitialState, getFixerContext, getValidationResultSchema, getValidationSummary, loadValidationFixerPrompt, parseValidationResult, recordAttempt, renderValidationFixerPrompt, shouldContinueLoop, shouldProceedAfterValidation, } from "./ValidationLoopController.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,8BAA8B,EAC9B,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,sBAAsB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Validation loop module - provides functionality for running verification
3
+ * subroutines with retry logic and structured outputs
4
+ */
5
+ export { DEFAULT_VALIDATION_LOOP_CONFIG, VALIDATION_RESULT_SCHEMA, ValidationResultSchema, } from "./types.js";
6
+ export { createInitialState, getFixerContext, getValidationResultSchema, getValidationSummary, loadValidationFixerPrompt, parseValidationResult, recordAttempt, renderValidationFixerPrompt, shouldContinueLoop, shouldProceedAfterValidation, } from "./ValidationLoopController.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,8BAA8B,EAC9B,wBAAwB,EAKxB,sBAAsB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Types for the validation loop system
3
+ */
4
+ import { z } from "zod";
5
+ /**
6
+ * Zod schema for ValidationResult - the single source of truth
7
+ * Used with Claude SDK structured outputs
8
+ */
9
+ export declare const ValidationResultSchema: z.ZodObject<{
10
+ /** Whether all verifications passed */
11
+ pass: z.ZodBoolean;
12
+ /** Summary of validation results or failure reasons */
13
+ reason: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ pass: boolean;
16
+ reason: string;
17
+ }, {
18
+ pass: boolean;
19
+ reason: string;
20
+ }>;
21
+ /**
22
+ * TypeScript type inferred from the Zod schema
23
+ */
24
+ export type ValidationResult = z.infer<typeof ValidationResultSchema>;
25
+ /**
26
+ * JSON Schema for ValidationResult - converted from Zod schema
27
+ * Used with Claude SDK structured outputs
28
+ */
29
+ export declare const VALIDATION_RESULT_SCHEMA: {
30
+ type: "object";
31
+ properties: {
32
+ pass: {
33
+ type: "boolean";
34
+ description: string;
35
+ };
36
+ reason: {
37
+ type: "string";
38
+ description: string;
39
+ };
40
+ };
41
+ required: ["pass", "reason"];
42
+ additionalProperties: false;
43
+ };
44
+ /**
45
+ * Configuration for the validation loop
46
+ */
47
+ export interface ValidationLoopConfig {
48
+ /** Maximum number of validation attempts (default: 4) */
49
+ maxIterations: number;
50
+ /** Whether to continue to next subroutine even if validation fails after all retries */
51
+ continueOnMaxRetries: boolean;
52
+ }
53
+ /**
54
+ * Default validation loop configuration
55
+ */
56
+ export declare const DEFAULT_VALIDATION_LOOP_CONFIG: ValidationLoopConfig;
57
+ /**
58
+ * State tracking for a validation loop execution
59
+ */
60
+ export interface ValidationLoopState {
61
+ /** Current iteration (1-based) */
62
+ iteration: number;
63
+ /** Results from each validation attempt */
64
+ attempts: Array<{
65
+ iteration: number;
66
+ result: ValidationResult;
67
+ timestamp: number;
68
+ }>;
69
+ /** Whether the loop has completed (either passed or exhausted retries) */
70
+ completed: boolean;
71
+ /** Final outcome */
72
+ outcome: "passed" | "failed_max_retries" | "in_progress";
73
+ }
74
+ /**
75
+ * Context passed to the validation-fixer subroutine
76
+ */
77
+ export interface ValidationFixerContext {
78
+ /** The failure reason from the previous validation attempt */
79
+ failureReason: string;
80
+ /** Current iteration number */
81
+ iteration: number;
82
+ /** Maximum iterations allowed */
83
+ maxIterations: number;
84
+ /** Previous attempt results for context */
85
+ previousAttempts: Array<{
86
+ iteration: number;
87
+ reason: string;
88
+ }>;
89
+ }
90
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validation/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,sBAAsB;IAClC,uCAAuC;;IAEvC,uDAAuD;;;;;;;;EAMtD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAMhC;IACJ,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE;QACX,IAAI,EAAE;YAAE,IAAI,EAAE,SAAS,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/C,MAAM,EAAE;YAAE,IAAI,EAAE,QAAQ,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KAChD,CAAC;IACF,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7B,oBAAoB,EAAE,KAAK,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,oBAAoB,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,oBAG5C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,EAAE,KAAK,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,gBAAgB,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,OAAO,EAAE,QAAQ,GAAG,oBAAoB,GAAG,aAAa,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,gBAAgB,EAAE,KAAK,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACH"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Types for the validation loop system
3
+ */
4
+ import { z } from "zod";
5
+ import { zodToJsonSchema } from "zod-to-json-schema";
6
+ /**
7
+ * Zod schema for ValidationResult - the single source of truth
8
+ * Used with Claude SDK structured outputs
9
+ */
10
+ export const ValidationResultSchema = z.object({
11
+ /** Whether all verifications passed */
12
+ pass: z.boolean().describe("Whether all verifications passed"),
13
+ /** Summary of validation results or failure reasons */
14
+ reason: z
15
+ .string()
16
+ .describe("Summary of validation results (e.g., '47 tests passing, linting clean, types valid') or failure reasons (e.g., 'TypeScript error in src/foo.ts:42 - Property x does not exist on type Y')"),
17
+ });
18
+ /**
19
+ * JSON Schema for ValidationResult - converted from Zod schema
20
+ * Used with Claude SDK structured outputs
21
+ */
22
+ export const VALIDATION_RESULT_SCHEMA = zodToJsonSchema(ValidationResultSchema, {
23
+ $refStrategy: "none",
24
+ target: "jsonSchema7",
25
+ });
26
+ /**
27
+ * Default validation loop configuration
28
+ */
29
+ export const DEFAULT_VALIDATION_LOOP_CONFIG = {
30
+ maxIterations: 4,
31
+ continueOnMaxRetries: true,
32
+ };
33
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/validation/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,uCAAuC;IACvC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC9D,uDAAuD;IACvD,MAAM,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACR,2LAA2L,CAC3L;CACF,CAAC,CAAC;AAOH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CACtD,sBAAsB,EACtB;IACC,YAAY,EAAE,MAAM;IACpB,MAAM,EAAE,aAAa;CACrB,CASD,CAAC;AAYF;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IACnE,aAAa,EAAE,CAAC;IAChB,oBAAoB,EAAE,IAAI;CAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyrus-edge-worker",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Unified edge worker for processing Linear issues with Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,13 +18,15 @@
18
18
  "chokidar": "^4.0.3",
19
19
  "fastify": "^5.2.0",
20
20
  "file-type": "^18.7.0",
21
- "cyrus-claude-runner": "0.2.5",
22
- "cyrus-cloudflare-tunnel-client": "0.2.5",
23
- "cyrus-core": "0.2.5",
24
- "cyrus-config-updater": "0.2.5",
25
- "cyrus-gemini-runner": "0.2.5",
26
- "cyrus-simple-agent-runner": "0.2.5",
27
- "cyrus-linear-event-transport": "0.2.5"
21
+ "zod": "3.24.1",
22
+ "zod-to-json-schema": "3.24.1",
23
+ "cyrus-cloudflare-tunnel-client": "0.2.7",
24
+ "cyrus-claude-runner": "0.2.7",
25
+ "cyrus-core": "0.2.7",
26
+ "cyrus-config-updater": "0.2.7",
27
+ "cyrus-gemini-runner": "0.2.7",
28
+ "cyrus-linear-event-transport": "0.2.7",
29
+ "cyrus-simple-agent-runner": "0.2.7"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@types/node": "^20.0.0",