kantban-cli 0.1.7 → 0.1.10

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 (75) hide show
  1. package/dist/chunk-ZCUIGFSP.js +4111 -0
  2. package/dist/chunk-ZCUIGFSP.js.map +1 -0
  3. package/dist/context-7YDNTI3P.js +30 -0
  4. package/dist/context-7YDNTI3P.js.map +1 -0
  5. package/dist/cron-OKQP6QDF.js +112 -0
  6. package/dist/cron-OKQP6QDF.js.map +1 -0
  7. package/dist/index.d.ts +0 -2
  8. package/dist/index.js +179 -44
  9. package/dist/index.js.map +1 -1
  10. package/dist/pipeline-HTGCXNPL.js +4049 -0
  11. package/dist/pipeline-HTGCXNPL.js.map +1 -0
  12. package/dist/pipeline-init-IGZZOOLK.js +103 -0
  13. package/dist/pipeline-init-IGZZOOLK.js.map +1 -0
  14. package/dist/status-4GFXMVIM.js +128 -0
  15. package/dist/status-4GFXMVIM.js.map +1 -0
  16. package/dist/work-2V33NZAT.js +81 -0
  17. package/dist/work-2V33NZAT.js.map +1 -0
  18. package/package.json +7 -4
  19. package/dist/client.d.ts +0 -35
  20. package/dist/client.d.ts.map +0 -1
  21. package/dist/client.js +0 -109
  22. package/dist/client.js.map +0 -1
  23. package/dist/commands/context.d.ts +0 -3
  24. package/dist/commands/context.d.ts.map +0 -1
  25. package/dist/commands/context.js +0 -27
  26. package/dist/commands/context.js.map +0 -1
  27. package/dist/commands/cron.d.ts +0 -3
  28. package/dist/commands/cron.d.ts.map +0 -1
  29. package/dist/commands/cron.js +0 -106
  30. package/dist/commands/cron.js.map +0 -1
  31. package/dist/commands/pipeline.d.ts +0 -4
  32. package/dist/commands/pipeline.d.ts.map +0 -1
  33. package/dist/commands/pipeline.js +0 -645
  34. package/dist/commands/pipeline.js.map +0 -1
  35. package/dist/commands/status.d.ts +0 -3
  36. package/dist/commands/status.d.ts.map +0 -1
  37. package/dist/commands/status.js +0 -135
  38. package/dist/commands/status.js.map +0 -1
  39. package/dist/commands/work.d.ts +0 -3
  40. package/dist/commands/work.d.ts.map +0 -1
  41. package/dist/commands/work.js +0 -76
  42. package/dist/commands/work.js.map +0 -1
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/lib/constraint-evaluator.d.ts +0 -40
  45. package/dist/lib/constraint-evaluator.d.ts.map +0 -1
  46. package/dist/lib/constraint-evaluator.js +0 -180
  47. package/dist/lib/constraint-evaluator.js.map +0 -1
  48. package/dist/lib/event-queue.d.ts +0 -28
  49. package/dist/lib/event-queue.d.ts.map +0 -1
  50. package/dist/lib/event-queue.js +0 -73
  51. package/dist/lib/event-queue.js.map +0 -1
  52. package/dist/lib/logger.d.ts +0 -20
  53. package/dist/lib/logger.d.ts.map +0 -1
  54. package/dist/lib/logger.js +0 -52
  55. package/dist/lib/logger.js.map +0 -1
  56. package/dist/lib/mcp-config.d.ts +0 -9
  57. package/dist/lib/mcp-config.d.ts.map +0 -1
  58. package/dist/lib/mcp-config.js +0 -51
  59. package/dist/lib/mcp-config.js.map +0 -1
  60. package/dist/lib/orchestrator.d.ts +0 -238
  61. package/dist/lib/orchestrator.d.ts.map +0 -1
  62. package/dist/lib/orchestrator.js +0 -616
  63. package/dist/lib/orchestrator.js.map +0 -1
  64. package/dist/lib/prompt-composer.d.ts +0 -102
  65. package/dist/lib/prompt-composer.d.ts.map +0 -1
  66. package/dist/lib/prompt-composer.js +0 -182
  67. package/dist/lib/prompt-composer.js.map +0 -1
  68. package/dist/lib/ralph-loop.d.ts +0 -49
  69. package/dist/lib/ralph-loop.d.ts.map +0 -1
  70. package/dist/lib/ralph-loop.js +0 -174
  71. package/dist/lib/ralph-loop.js.map +0 -1
  72. package/dist/lib/ws-client.d.ts +0 -31
  73. package/dist/lib/ws-client.d.ts.map +0 -1
  74. package/dist/lib/ws-client.js +0 -110
  75. package/dist/lib/ws-client.js.map +0 -1
@@ -0,0 +1,4111 @@
1
+ // src/lib/stuck-detector.ts
2
+ import { z } from "zod";
3
+
4
+ // src/lib/parse-utils.ts
5
+ function parseJsonFromLlmOutput(raw) {
6
+ try {
7
+ return JSON.parse(raw.trim());
8
+ } catch {
9
+ }
10
+ const fenceMatch = raw.match(/```(?:json)?\s*([\s\S]*?)```/i);
11
+ if (fenceMatch?.[1]) {
12
+ const fenced = fenceMatch[1].trim();
13
+ try {
14
+ return JSON.parse(fenced);
15
+ } catch {
16
+ }
17
+ }
18
+ for (let i = 0; i < raw.length; i++) {
19
+ if (raw[i] !== "{") continue;
20
+ let depth = 0;
21
+ let inString = false;
22
+ let escape = false;
23
+ for (let j = i; j < raw.length; j++) {
24
+ const ch = raw[j];
25
+ if (escape) {
26
+ escape = false;
27
+ continue;
28
+ }
29
+ if (ch === "\\" && inString) {
30
+ escape = true;
31
+ continue;
32
+ }
33
+ if (ch === '"') {
34
+ inString = !inString;
35
+ continue;
36
+ }
37
+ if (inString) continue;
38
+ if (ch === "{") depth++;
39
+ if (ch === "}") depth--;
40
+ if (depth === 0) {
41
+ const candidate = raw.slice(i, j + 1);
42
+ try {
43
+ return JSON.parse(candidate);
44
+ } catch {
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ throw new Error(`Invalid JSON in LLM output: ${raw.slice(0, 120)}`);
51
+ }
52
+
53
+ // src/lib/stuck-detector.ts
54
+ function shouldCheckStuckDetection(config, iteration) {
55
+ if (!config.enabled) return false;
56
+ const firstCheck = config.firstCheck ?? 3;
57
+ const interval = config.interval ?? 2;
58
+ if (interval <= 0) return iteration === firstCheck;
59
+ if (iteration < firstCheck) return false;
60
+ if (iteration === firstCheck) return true;
61
+ return (iteration - firstCheck) % interval === 0;
62
+ }
63
+ function composeStuckDetectionPrompt(input) {
64
+ const commentLines = input.recentComments.length > 0 ? input.recentComments.map((c) => ` [${c.author}] ${c.body.slice(0, 200)}`).join("\n") : " (no comments)";
65
+ return `You are a pipeline trajectory classifier. Analyze recent agent activity and classify the trajectory.
66
+
67
+ Ticket: #${String(input.ticketNumber)} "${input.ticketTitle}"
68
+ Column: ${input.columnName}
69
+ Iteration: ${String(input.iteration)} of ${String(input.maxIterations)}
70
+
71
+ Recent iteration comments:
72
+ ${commentLines}
73
+
74
+ Classify as one of:
75
+ - "progressing" \u2014 each iteration makes distinct forward progress (new code, new tests, new fields set)
76
+ - "spinning" \u2014 agent is active but repeating similar actions without advancing (same error, same approach retried, output duplicated)
77
+ - "blocked" \u2014 agent cannot make progress due to external dependency, missing information, or fundamental task issue
78
+
79
+ Respond with ONLY a JSON object:
80
+ {"status": "progressing|spinning|blocked", "confidence": 0.0-1.0, "evidence": "one sentence"}`;
81
+ }
82
+ var StuckDetectionResponseSchema = z.object({
83
+ status: z.enum(["progressing", "spinning", "blocked"]),
84
+ confidence: z.number().min(0).max(1),
85
+ evidence: z.string()
86
+ });
87
+ function parseStuckDetectionResponse(raw) {
88
+ let parsed;
89
+ try {
90
+ parsed = parseJsonFromLlmOutput(raw);
91
+ } catch (err) {
92
+ throw new Error(`StuckDetectionResponse: ${err instanceof Error ? err.message : String(err)}`);
93
+ }
94
+ if (parsed && typeof parsed === "object" && "confidence" in parsed) {
95
+ const p = parsed;
96
+ if (typeof p.confidence === "number") {
97
+ p.confidence = Math.min(1, Math.max(0, p.confidence));
98
+ }
99
+ }
100
+ const result = StuckDetectionResponseSchema.safeParse(parsed);
101
+ if (!result.success) {
102
+ throw new Error(`StuckDetectionResponse: validation failed \u2014 ${result.error.message}`);
103
+ }
104
+ return result.data;
105
+ }
106
+ function classifyTrajectory(snapshots) {
107
+ if (snapshots.length === 0) {
108
+ return { status: "progressing", evidence: "no data", confidence: 0.5 };
109
+ }
110
+ const recent = snapshots.slice(-3);
111
+ const deltas = recent.map((s) => s.delta_from_previous);
112
+ const meaningful = deltas.filter((d) => d !== "first_check");
113
+ if (meaningful.length === 0) {
114
+ return { status: "progressing", evidence: "only initial checks", confidence: 0.5 };
115
+ }
116
+ if (meaningful.every((d) => d === "same")) {
117
+ return { status: "spinning", evidence: "identical gate results", confidence: 1 };
118
+ }
119
+ if (meaningful.every((d) => d === "regressed" || d === "same")) {
120
+ return { status: "regressing", evidence: "gate results degrading", confidence: 1 };
121
+ }
122
+ if (meaningful.some((d) => d === "improved")) {
123
+ const lastMeaningful = meaningful[meaningful.length - 1];
124
+ if (lastMeaningful === "improved") {
125
+ return { status: "progressing", evidence: "gate results improving", confidence: 1 };
126
+ }
127
+ }
128
+ if (meaningful.some((d) => d === "improved") && meaningful.some((d) => d === "regressed")) {
129
+ return { status: "spinning", evidence: "oscillating gate results", confidence: 1 };
130
+ }
131
+ if (meaningful.some((d) => d === "improved")) {
132
+ return { status: "spinning", evidence: "stale improvement \u2014 no recent progress", confidence: 0.8 };
133
+ }
134
+ return { status: "spinning", evidence: "no improvement detected", confidence: 1 };
135
+ }
136
+
137
+ // src/lib/gate-config.ts
138
+ import { load, JSON_SCHEMA } from "js-yaml";
139
+
140
+ // ../types/dist/api-response.js
141
+ import { z as z2 } from "zod";
142
+ var ApiErrorSchema = z2.object({
143
+ success: z2.literal(false),
144
+ error: z2.object({ code: z2.string(), message: z2.string() })
145
+ });
146
+
147
+ // ../types/dist/common.js
148
+ import { z as z3 } from "zod";
149
+ var IdSchema = z3.string().uuid();
150
+ var SortOrderSchema = z3.enum(["asc", "desc"]);
151
+ var PaginationParamsSchema = z3.object({
152
+ page: z3.coerce.number().int().min(1).default(1),
153
+ limit: z3.coerce.number().int().min(1).max(100).default(20),
154
+ sort_by: z3.string().optional(),
155
+ sort_order: SortOrderSchema.default("asc")
156
+ });
157
+ var TimestampsSchema = z3.object({
158
+ created_at: z3.string().datetime({ offset: true }),
159
+ updated_at: z3.string().datetime({ offset: true })
160
+ });
161
+
162
+ // ../types/dist/user.schema.js
163
+ import { z as z4 } from "zod";
164
+ var UserProfileSchema = z4.object({
165
+ id: z4.string().uuid(),
166
+ display_name: z4.string().min(1),
167
+ avatar_url: z4.string().url().nullable(),
168
+ created_at: z4.string().datetime({ offset: true }),
169
+ updated_at: z4.string().datetime({ offset: true })
170
+ });
171
+ var CreateUserProfileSchema = z4.object({
172
+ display_name: z4.string().min(1),
173
+ avatar_url: z4.string().url().nullable().optional()
174
+ });
175
+ var UpdateUserProfileSchema = z4.object({
176
+ display_name: z4.string().min(1).optional(),
177
+ avatar_url: z4.string().url().nullable().optional()
178
+ });
179
+
180
+ // ../types/dist/project.schema.js
181
+ import { z as z5 } from "zod";
182
+
183
+ // ../types/dist/palette.js
184
+ var PALETTE_KEYS = [
185
+ "red-500",
186
+ "orange-500",
187
+ "amber-500",
188
+ "yellow-500",
189
+ "lime-500",
190
+ "green-500",
191
+ "emerald-500",
192
+ "teal-500",
193
+ "cyan-500",
194
+ "sky-500",
195
+ "blue-500",
196
+ "indigo-500",
197
+ "violet-500",
198
+ "purple-500",
199
+ "fuchsia-500",
200
+ "pink-500",
201
+ "rose-500",
202
+ "stone-500",
203
+ "zinc-500"
204
+ ];
205
+
206
+ // ../types/dist/project.schema.js
207
+ var ProjectRoleSchema = z5.enum(["owner", "admin", "editor", "viewer"]);
208
+ var ProjectSchema = z5.object({
209
+ id: z5.string().uuid(),
210
+ name: z5.string().min(1),
211
+ owner_id: z5.string().uuid(),
212
+ icon: z5.string().nullable().default(null),
213
+ color: z5.string().nullable().default(null),
214
+ ticket_prefix: z5.string().regex(/^[A-Z]{2,10}$/),
215
+ ticket_counter: z5.number().int().nonnegative(),
216
+ created_at: z5.string().datetime({ offset: true }),
217
+ updated_at: z5.string().datetime({ offset: true })
218
+ });
219
+ var ProjectWithRoleSchema = ProjectSchema.extend({
220
+ role: ProjectRoleSchema
221
+ });
222
+ var CreateProjectSchema = z5.object({
223
+ name: z5.string().trim().min(1).max(100),
224
+ ticket_prefix: z5.string().regex(/^[A-Z]{2,10}$/)
225
+ });
226
+ var IconSchema = z5.string().min(1).refine((val) => val.length <= 3 || val.includes("/") || val.includes("."), "Must be 1-3 character initials or a storage path");
227
+ var UpdateProjectSchema = z5.object({
228
+ name: z5.string().trim().min(1).max(100).optional(),
229
+ icon: IconSchema.nullable().optional(),
230
+ color: z5.enum(PALETTE_KEYS).nullable().optional(),
231
+ ticket_prefix: z5.string().regex(/^[A-Z]{2,10}$/).optional()
232
+ });
233
+ var DeleteProjectPreviewSchema = z5.object({
234
+ boards: z5.number().int().nonnegative(),
235
+ tickets: z5.number().int().nonnegative(),
236
+ documents: z5.number().int().nonnegative(),
237
+ doc_spaces: z5.number().int().nonnegative(),
238
+ fields: z5.number().int().nonnegative(),
239
+ members: z5.number().int().nonnegative(),
240
+ conversations: z5.number().int().nonnegative()
241
+ });
242
+
243
+ // ../types/dist/project-member.schema.js
244
+ import { z as z6 } from "zod";
245
+ var ProjectMemberSchema = z6.object({
246
+ id: z6.string().uuid(),
247
+ project_id: z6.string().uuid(),
248
+ user_id: z6.string().uuid(),
249
+ role: ProjectRoleSchema,
250
+ created_at: z6.string().datetime({ offset: true }),
251
+ updated_at: z6.string().datetime({ offset: true })
252
+ });
253
+ var ProjectMemberWithProfileSchema = ProjectMemberSchema.extend({
254
+ user: UserProfileSchema
255
+ });
256
+ var UpdateProjectMemberSchema = z6.object({
257
+ role: z6.enum(["admin", "editor", "viewer"])
258
+ });
259
+
260
+ // ../types/dist/project-invitation.schema.js
261
+ import { z as z7 } from "zod";
262
+ var InvitationStatusSchema = z7.enum(["pending", "accepted", "declined", "revoked"]);
263
+ var ProjectInvitationSchema = z7.object({
264
+ id: z7.string().uuid(),
265
+ project_id: z7.string().uuid(),
266
+ invited_by: z7.string().uuid(),
267
+ email: z7.string().email(),
268
+ role: z7.enum(["admin", "editor", "viewer"]),
269
+ token: z7.string(),
270
+ status: InvitationStatusSchema,
271
+ expires_at: z7.string().datetime({ offset: true }),
272
+ created_at: z7.string().datetime({ offset: true }),
273
+ updated_at: z7.string().datetime({ offset: true })
274
+ });
275
+ var ProjectInvitationWithInviterSchema = ProjectInvitationSchema.extend({
276
+ inviter: UserProfileSchema
277
+ });
278
+ var CreateProjectInvitationSchema = z7.object({
279
+ email: z7.string().email(),
280
+ role: z7.enum(["admin", "editor", "viewer"]).default("editor")
281
+ });
282
+
283
+ // ../types/dist/board.schema.js
284
+ import { z as z9 } from "zod";
285
+
286
+ // ../types/dist/board-member.schema.js
287
+ import { z as z8 } from "zod";
288
+ var BoardRoleSchema = z8.enum(["owner", "admin", "editor", "viewer"]);
289
+ var BoardMemberSchema = z8.object({
290
+ id: z8.string().uuid(),
291
+ board_id: z8.string().uuid(),
292
+ user_id: z8.string().uuid(),
293
+ role: BoardRoleSchema,
294
+ created_at: z8.string().datetime({ offset: true }),
295
+ updated_at: z8.string().datetime({ offset: true })
296
+ });
297
+ var BoardMemberWithProfileSchema = BoardMemberSchema.extend({
298
+ user: UserProfileSchema
299
+ });
300
+ var UpdateBoardMemberSchema = z8.object({
301
+ role: z8.enum(["admin", "editor", "viewer"])
302
+ });
303
+ var AddBoardMemberSchema = z8.object({
304
+ user_id: z8.string().uuid(),
305
+ role: z8.enum(["admin", "editor", "viewer"])
306
+ });
307
+
308
+ // ../types/dist/board.schema.js
309
+ var BoardVisibilitySchema = z9.enum(["public", "private"]);
310
+ var BoardSchema = z9.object({
311
+ id: z9.string().uuid(),
312
+ project_id: z9.string().uuid(),
313
+ name: z9.string().min(1),
314
+ visibility: BoardVisibilitySchema,
315
+ icon: z9.string().nullable().default(null),
316
+ color: z9.string().nullable().default(null),
317
+ circuit_breaker_threshold: z9.number().int().positive().nullable().default(null),
318
+ circuit_breaker_target_id: z9.string().uuid().nullable().default(null),
319
+ created_at: z9.string().datetime({ offset: true }),
320
+ updated_at: z9.string().datetime({ offset: true })
321
+ });
322
+ var BoardWithRoleSchema = BoardSchema.extend({
323
+ role: BoardRoleSchema
324
+ });
325
+ var CreateBoardSchema = z9.object({
326
+ name: z9.string().min(1).max(100),
327
+ create_default_columns: z9.boolean().optional().default(false),
328
+ visibility: BoardVisibilitySchema.optional().default("private")
329
+ });
330
+ var IconSchema2 = z9.string().min(1).refine((val) => val.length <= 3 || val.includes("/") || val.includes("."), "Must be 1-3 character initials or a storage path");
331
+ var UpdateBoardSchema = z9.object({
332
+ name: z9.string().min(1).max(100).optional(),
333
+ visibility: BoardVisibilitySchema.optional(),
334
+ icon: IconSchema2.nullable().optional(),
335
+ color: z9.enum(PALETTE_KEYS).nullable().optional(),
336
+ circuit_breaker_threshold: z9.number().int().positive().nullable().optional(),
337
+ circuit_breaker_target_id: z9.string().uuid().nullable().optional()
338
+ });
339
+ var TicketActionSchema = z9.enum(["move_to_backlog", "archive", "delete"]);
340
+ var DeleteBoardBodySchema = z9.object({
341
+ ticket_action: TicketActionSchema.default("move_to_backlog")
342
+ });
343
+ var DeleteBoardPreviewSchema = z9.object({
344
+ tickets: z9.number().int().nonnegative(),
345
+ columns: z9.number().int().nonnegative(),
346
+ transition_rules: z9.number().int().nonnegative()
347
+ });
348
+
349
+ // ../types/dist/column.schema.js
350
+ import { z as z10 } from "zod";
351
+ var ColumnTypeSchema = z10.enum(["start", "in_progress", "done", "default", "evaluator"]);
352
+ var ArchiveModeSchema = z10.enum(["off", "immediate", "delayed", "manual"]);
353
+ var ColumnSchema = z10.object({
354
+ id: z10.string().uuid(),
355
+ board_id: z10.string().uuid(),
356
+ name: z10.string().min(1),
357
+ color: z10.string(),
358
+ position: z10.number().int(),
359
+ description: z10.string().nullable(),
360
+ column_type: ColumnTypeSchema,
361
+ wip_limit: z10.number().int().nullable(),
362
+ default_assignee_id: z10.string().uuid().nullable(),
363
+ archive_mode: ArchiveModeSchema.default("off"),
364
+ archive_delay_hours: z10.number().positive().nullable().default(null),
365
+ archive_overflow_limit: z10.number().int().positive().nullable().default(null),
366
+ prompt_document_id: z10.string().uuid().nullable().default(null),
367
+ goal: z10.string().nullable().default(null),
368
+ agent_config: z10.record(z10.string(), z10.unknown()).nullable().default(null),
369
+ created_at: z10.string().datetime({ offset: true }),
370
+ updated_at: z10.string().datetime({ offset: true })
371
+ });
372
+ var CreateColumnSchema = z10.object({
373
+ name: z10.string().min(1).max(100),
374
+ color: z10.string().optional()
375
+ });
376
+ var UpdateColumnSchema = z10.object({
377
+ name: z10.string().min(1).max(100).optional(),
378
+ color: z10.string().optional(),
379
+ description: z10.string().nullable().optional(),
380
+ column_type: ColumnTypeSchema.optional(),
381
+ wip_limit: z10.number().int().nullable().optional(),
382
+ default_assignee_id: z10.string().uuid().nullable().optional(),
383
+ archive_mode: ArchiveModeSchema.optional(),
384
+ archive_delay_hours: z10.number().positive().nullable().optional(),
385
+ archive_overflow_limit: z10.number().int().positive().nullable().optional(),
386
+ prompt_document_id: z10.string().uuid().nullable().optional(),
387
+ goal: z10.string().max(1e3).nullable().optional(),
388
+ agent_config: z10.record(z10.string(), z10.unknown()).nullable().optional()
389
+ }).superRefine((data, ctx) => {
390
+ if (data.archive_mode === "delayed" && data.archive_delay_hours == null) {
391
+ ctx.addIssue({
392
+ code: z10.ZodIssueCode.custom,
393
+ message: "archive_delay_hours is required when archive_mode is delayed",
394
+ path: ["archive_delay_hours"]
395
+ });
396
+ }
397
+ });
398
+ var ReorderColumnsSchema = z10.array(z10.object({
399
+ id: z10.string().uuid(),
400
+ position: z10.number().int().nonnegative()
401
+ }));
402
+ var DeleteColumnBodySchema = z10.object({
403
+ ticket_action: TicketActionSchema.default("move_to_backlog")
404
+ });
405
+ var DeleteColumnPreviewSchema = z10.object({
406
+ tickets: z10.number().int().nonnegative(),
407
+ transition_rules_broken: z10.number().int().nonnegative(),
408
+ field_requirements_broken: z10.number().int().nonnegative()
409
+ });
410
+
411
+ // ../types/dist/ticket.schema.js
412
+ import { z as z11 } from "zod";
413
+ var TicketSchema = z11.object({
414
+ id: z11.string().uuid(),
415
+ board_id: z11.string().uuid().nullable(),
416
+ column_id: z11.string().uuid().nullable(),
417
+ project_id: z11.string().uuid(),
418
+ ticket_number: z11.number().int().positive(),
419
+ title: z11.string().min(1).max(500),
420
+ description: z11.string().max(1e4),
421
+ position: z11.number().int(),
422
+ assignee_id: z11.string().uuid().nullable(),
423
+ reporter_id: z11.string().uuid(),
424
+ custom_fields: z11.record(z11.string(), z11.unknown()).default({}),
425
+ created_at: z11.string().datetime({ offset: true }),
426
+ updated_at: z11.string().datetime({ offset: true }),
427
+ archived_at: z11.string().datetime({ offset: true }).nullable().default(null),
428
+ column_entered_at: z11.string().datetime({ offset: true }).nullable().default(null),
429
+ first_active_at: z11.string().datetime({ offset: true }).nullable().default(null),
430
+ done_at: z11.string().datetime({ offset: true }).nullable().default(null),
431
+ backward_transitions: z11.number().int().default(0),
432
+ parent_id: z11.string().uuid().nullable().default(null)
433
+ });
434
+ var TicketWithProfilesSchema = TicketSchema.extend({
435
+ assignee: UserProfileSchema.nullable(),
436
+ reporter: UserProfileSchema
437
+ });
438
+ var CreateTicketSchema = z11.object({
439
+ board_id: z11.string().uuid().nullable().optional().default(null),
440
+ column_id: z11.string().uuid().nullable().optional().default(null),
441
+ title: z11.string().min(1).max(500),
442
+ description: z11.string().max(1e4).optional(),
443
+ assignee_id: z11.string().uuid().nullable().optional(),
444
+ field_values: z11.record(z11.string(), z11.unknown()).optional(),
445
+ parent_id: z11.string().uuid().nullable().optional()
446
+ });
447
+ var UpdateTicketSchema = z11.object({
448
+ title: z11.string().min(1).max(500).optional(),
449
+ description: z11.string().max(1e4).optional(),
450
+ assignee_id: z11.string().uuid().nullable().optional(),
451
+ parent_id: z11.string().uuid().nullable().optional()
452
+ });
453
+ var MoveTicketSchema = z11.object({
454
+ column_id: z11.string().uuid().nullable(),
455
+ position: z11.number().int().nonnegative(),
456
+ handoff: z11.record(z11.string(), z11.unknown()).optional(),
457
+ force: z11.boolean().optional().default(false),
458
+ field_values: z11.record(z11.string(), z11.unknown()).optional().describe("Map of field name \u2192 value. Names are resolved to field IDs server-side.")
459
+ });
460
+ var MoveToBoardSchema = z11.object({
461
+ board_id: z11.string().uuid(),
462
+ column_id: z11.string().uuid()
463
+ });
464
+ var CreateBacklogTicketSchema = z11.object({
465
+ title: z11.string().min(1).max(500),
466
+ description: z11.string().max(1e4).optional(),
467
+ assignee_id: z11.string().uuid().nullable().optional()
468
+ });
469
+ var ReorderTicketsSchema = z11.array(z11.object({
470
+ id: z11.string().uuid(),
471
+ column_id: z11.string().uuid().nullable(),
472
+ position: z11.number().int().nonnegative()
473
+ }));
474
+ var DeleteTicketPreviewSchema = z11.object({
475
+ comments: z11.number().int().nonnegative(),
476
+ attachments: z11.number().int().nonnegative()
477
+ });
478
+
479
+ // ../types/dist/comment.schema.js
480
+ import { z as z12 } from "zod";
481
+ var CommentSchema = z12.object({
482
+ id: z12.string().uuid(),
483
+ ticket_id: z12.string().uuid(),
484
+ author_id: z12.string().uuid(),
485
+ body: z12.string().min(1),
486
+ created_at: z12.string().datetime({ offset: true }),
487
+ updated_at: z12.string().datetime({ offset: true }),
488
+ pinned: z12.boolean().default(false)
489
+ });
490
+ var CommentWithAuthorSchema = CommentSchema.extend({
491
+ author: UserProfileSchema
492
+ });
493
+ var CreateCommentSchema = z12.object({
494
+ body: z12.string().min(1).max(1e4)
495
+ });
496
+ var UpdateCommentSchema = z12.object({
497
+ body: z12.string().min(1).max(1e4).optional(),
498
+ pinned: z12.boolean().optional()
499
+ });
500
+
501
+ // ../types/dist/jobs.schema.js
502
+ import { z as z13 } from "zod";
503
+ var WelcomeEmailJobDataSchema = z13.object({
504
+ userId: z13.string().uuid(),
505
+ email: z13.string().email(),
506
+ displayName: z13.string()
507
+ });
508
+ var InvitationEmailJobDataSchema = z13.object({
509
+ email: z13.string().email(),
510
+ projectName: z13.string(),
511
+ token: z13.string(),
512
+ role: z13.string(),
513
+ invitedBy: z13.string().uuid()
514
+ });
515
+
516
+ // ../types/dist/upload.schema.js
517
+ import { z as z14 } from "zod";
518
+ var UploadResultSchema = z14.object({
519
+ path: z14.string(),
520
+ url: z14.string().url().nullable()
521
+ });
522
+
523
+ // ../types/dist/ticket-attachment.schema.js
524
+ import { z as z15 } from "zod";
525
+ var TicketAttachmentSchema = z15.object({
526
+ id: z15.string().uuid(),
527
+ ticket_id: z15.string().uuid(),
528
+ uploader_id: z15.string().uuid(),
529
+ storage_path: z15.string().min(1),
530
+ file_name: z15.string().min(1),
531
+ mime_type: z15.string().min(1),
532
+ file_size: z15.number().int().positive(),
533
+ created_at: z15.string().datetime({ offset: true })
534
+ });
535
+ var TicketAttachmentWithUrlSchema = TicketAttachmentSchema.extend({
536
+ url: z15.string()
537
+ });
538
+ var CreateTicketAttachmentSchema = z15.object({
539
+ storage_path: z15.string().min(1),
540
+ file_name: z15.string().min(1),
541
+ mime_type: z15.string().min(1),
542
+ file_size: z15.number().int().positive()
543
+ });
544
+
545
+ // ../types/dist/board-ws.schema.js
546
+ import { z as z23 } from "zod";
547
+
548
+ // ../types/dist/field-definition.schema.js
549
+ import { z as z16 } from "zod";
550
+ var FieldTypeSchema = z16.enum([
551
+ "short_text",
552
+ "long_text",
553
+ "rich_text",
554
+ "number",
555
+ "date",
556
+ "single_select",
557
+ "multi_select",
558
+ "checkbox",
559
+ "user",
560
+ "ticket_link",
561
+ "document_link",
562
+ "github_pr"
563
+ ]);
564
+ var CreateFieldTypeSchema = z16.enum([
565
+ "short_text",
566
+ "long_text",
567
+ "rich_text",
568
+ "number",
569
+ "date",
570
+ "single_select",
571
+ "multi_select",
572
+ "checkbox",
573
+ "user",
574
+ "document_link",
575
+ "github_pr"
576
+ ]);
577
+ var SelectOptionSchema = z16.object({
578
+ id: z16.string().uuid(),
579
+ label: z16.string().min(1).max(100),
580
+ color: z16.string()
581
+ });
582
+ var FieldConfigSchema = z16.object({
583
+ placeholder: z16.string().optional(),
584
+ max_length: z16.number().int().positive().optional(),
585
+ regex: z16.string().optional(),
586
+ min: z16.number().optional(),
587
+ max: z16.number().optional(),
588
+ decimals: z16.number().int().min(0).optional(),
589
+ unit: z16.string().optional(),
590
+ allow_past: z16.boolean().optional(),
591
+ allow_time: z16.boolean().optional(),
592
+ options: z16.array(SelectOptionSchema).optional(),
593
+ max_selections: z16.number().int().positive().optional(),
594
+ default_checked: z16.boolean().optional(),
595
+ scope: z16.enum(["board", "project"]).optional(),
596
+ show_checks: z16.boolean().optional(),
597
+ show_reviews: z16.boolean().optional()
598
+ }).default({});
599
+ var FieldDefinitionSchema = z16.object({
600
+ id: z16.string().uuid(),
601
+ project_id: z16.string().uuid(),
602
+ name: z16.string().min(1).max(100),
603
+ type: FieldTypeSchema,
604
+ config: FieldConfigSchema,
605
+ position: z16.number().int(),
606
+ created_at: z16.string().datetime({ offset: true }),
607
+ updated_at: z16.string().datetime({ offset: true })
608
+ });
609
+ var CreateFieldDefinitionSchema = z16.object({
610
+ name: z16.string().min(1).max(100),
611
+ type: FieldTypeSchema,
612
+ config: FieldConfigSchema.optional()
613
+ });
614
+ var UpdateFieldDefinitionSchema = z16.object({
615
+ name: z16.string().min(1).max(100).optional(),
616
+ config: FieldConfigSchema.optional(),
617
+ position: z16.number().int().optional()
618
+ });
619
+ var ReorderFieldDefinitionsSchema = z16.object({
620
+ items: z16.array(z16.object({
621
+ id: z16.string().uuid(),
622
+ position: z16.number().int()
623
+ }))
624
+ });
625
+ var DeleteFieldDefinitionPreviewSchema = z16.object({
626
+ tickets_affected: z16.number().int().nonnegative(),
627
+ field_values: z16.number().int().nonnegative(),
628
+ board_overrides: z16.number().int().nonnegative()
629
+ });
630
+
631
+ // ../types/dist/field-override.schema.js
632
+ import { z as z17 } from "zod";
633
+ var BoardFieldOverrideSchema = z17.object({
634
+ id: z17.string().uuid(),
635
+ board_id: z17.string().uuid(),
636
+ field_id: z17.string().uuid(),
637
+ is_enabled: z17.boolean(),
638
+ is_required: z17.boolean(),
639
+ show_on_card: z17.boolean(),
640
+ position: z17.number().int().nullable(),
641
+ default_value: z17.unknown().nullable(),
642
+ extra_options: z17.array(SelectOptionSchema).nullable(),
643
+ created_at: z17.string().datetime({ offset: true }),
644
+ updated_at: z17.string().datetime({ offset: true })
645
+ });
646
+ var UpsertFieldOverrideSchema = z17.object({
647
+ is_enabled: z17.boolean().optional(),
648
+ is_required: z17.boolean().optional(),
649
+ show_on_card: z17.boolean().optional(),
650
+ position: z17.number().int().nullable().optional(),
651
+ default_value: z17.unknown().nullable().optional(),
652
+ extra_options: z17.array(SelectOptionSchema).nullable().optional()
653
+ });
654
+ var MergedFieldSchema = FieldDefinitionSchema.extend({
655
+ is_enabled: z17.boolean().default(true),
656
+ is_required: z17.boolean().default(false),
657
+ show_on_card: z17.boolean().default(false),
658
+ effective_position: z17.number().int(),
659
+ default_value: z17.unknown().nullable().default(null),
660
+ extra_options: z17.array(SelectOptionSchema).default([]),
661
+ all_options: z17.array(SelectOptionSchema).default([])
662
+ });
663
+
664
+ // ../types/dist/transition-rule.schema.js
665
+ import { z as z18 } from "zod";
666
+ var TransitionRuleStatusSchema = z18.enum(["active", "broken"]);
667
+ var TransitionRuleSchema = z18.object({
668
+ id: z18.string().uuid(),
669
+ board_id: z18.string().uuid(),
670
+ from_column_id: z18.string().uuid().nullable(),
671
+ to_column_id: z18.string().uuid().nullable(),
672
+ from_tombstone_id: z18.string().uuid().nullable(),
673
+ to_tombstone_id: z18.string().uuid().nullable(),
674
+ status: TransitionRuleStatusSchema,
675
+ instruction: z18.string().nullable(),
676
+ created_at: z18.string().datetime({ offset: true }),
677
+ updated_at: z18.string().datetime({ offset: true })
678
+ });
679
+ var TransitionRuleWithTombstoneSchema = TransitionRuleSchema.extend({
680
+ from_tombstone_name: z18.string().nullable().default(null),
681
+ to_tombstone_name: z18.string().nullable().default(null)
682
+ });
683
+ var BulkUpsertTransitionRulesSchema = z18.object({
684
+ rules: z18.array(z18.object({
685
+ from_column_id: z18.string().uuid().nullable(),
686
+ to_column_id: z18.string().uuid(),
687
+ instruction: z18.string().nullable().optional()
688
+ }))
689
+ });
690
+
691
+ // ../types/dist/signal.schema.js
692
+ import { z as z19 } from "zod";
693
+ var SignalScopeTypeSchema = z19.enum(["project", "board", "column", "ticket"]);
694
+ var SignalSourceSchema = z19.enum(["human", "agent"]);
695
+ var SignalSchema = z19.object({
696
+ id: z19.string().uuid(),
697
+ project_id: z19.string().uuid(),
698
+ scope_type: SignalScopeTypeSchema,
699
+ scope_id: z19.string().uuid(),
700
+ content: z19.string().min(1),
701
+ source: SignalSourceSchema,
702
+ created_by: z19.string().uuid().nullable(),
703
+ session_id: z19.string().uuid().nullable(),
704
+ iteration: z19.number().int().nullable(),
705
+ created_at: z19.string().datetime({ offset: true }),
706
+ updated_at: z19.string().datetime({ offset: true })
707
+ });
708
+ var CreateSignalSchema = z19.object({
709
+ scopeType: SignalScopeTypeSchema,
710
+ scopeId: z19.string().uuid(),
711
+ content: z19.string().min(1).max(5e3)
712
+ });
713
+ var UpdateSignalSchema = z19.object({
714
+ content: z19.string().min(1).max(5e3)
715
+ });
716
+ var PromoteSignalSchema = z19.object({
717
+ newScopeType: SignalScopeTypeSchema,
718
+ newScopeId: z19.string().uuid()
719
+ });
720
+
721
+ // ../types/dist/pipeline-session.schema.js
722
+ import { z as z20 } from "zod";
723
+ var InvocationTypeSchema = z20.enum(["heavy", "light", "advisor", "stuck_detection", "orchestrator"]);
724
+ var ExitReasonSchema = z20.enum(["moved", "stalled", "error", "max_iterations", "stopped", "deleted"]);
725
+ var PipelineSessionSchema = z20.object({
726
+ id: z20.string().uuid(),
727
+ project_id: z20.string().uuid(),
728
+ board_id: z20.string().uuid(),
729
+ ticket_id: z20.string().uuid().nullable(),
730
+ column_id: z20.string().uuid().nullable(),
731
+ run_id: z20.string().min(1).max(128),
732
+ session_id: z20.string().min(1).max(128),
733
+ model: z20.string().min(1).max(100),
734
+ invocation_type: InvocationTypeSchema,
735
+ iteration: z20.number().int().nullable(),
736
+ tokens_in: z20.number().int().nonnegative(),
737
+ tokens_out: z20.number().int().nonnegative(),
738
+ tool_call_count: z20.number().int().nonnegative(),
739
+ duration_ms: z20.number().int().nonnegative(),
740
+ exit_reason: ExitReasonSchema.nullable(),
741
+ started_at: z20.string().datetime({ offset: true }),
742
+ ended_at: z20.string().datetime({ offset: true }).nullable(),
743
+ created_at: z20.string().datetime({ offset: true }),
744
+ updated_at: z20.string().datetime({ offset: true }).nullable()
745
+ });
746
+ var CreatePipelineSessionSchema = z20.object({
747
+ project_id: z20.string().uuid(),
748
+ board_id: z20.string().uuid(),
749
+ ticket_id: z20.string().uuid().nullable(),
750
+ column_id: z20.string().uuid().nullable(),
751
+ run_id: z20.string().min(1).max(128),
752
+ session_id: z20.string().min(1).max(128),
753
+ model: z20.string().min(1).max(100),
754
+ invocation_type: InvocationTypeSchema,
755
+ iteration: z20.number().int().nullable().optional(),
756
+ started_at: z20.string().datetime({ offset: true }).optional()
757
+ });
758
+ var UpdatePipelineSessionSchema = z20.object({
759
+ tokens_in: z20.number().int().nonnegative(),
760
+ tokens_out: z20.number().int().nonnegative(),
761
+ tool_call_count: z20.number().int().nonnegative(),
762
+ duration_ms: z20.number().int().nonnegative(),
763
+ exit_reason: ExitReasonSchema.nullable(),
764
+ ended_at: z20.string().datetime({ offset: true })
765
+ });
766
+ var PipelineSessionQuerySchema = z20.object({
767
+ ticketId: z20.string().uuid().optional(),
768
+ boardId: z20.string().uuid().optional(),
769
+ sessionId: z20.string().optional(),
770
+ limit: z20.coerce.number().int().min(1).max(100).optional().default(50),
771
+ cursor: z20.string().optional()
772
+ });
773
+
774
+ // ../types/dist/firing-constraint.schema.js
775
+ import { z as z21 } from "zod";
776
+ var FiringConstraintSubjectTypeSchema = z21.enum([
777
+ "column.ticket_count",
778
+ "column.active_loops",
779
+ "column.wip_remaining",
780
+ "column.last_fired_at",
781
+ "board.total_active_loops",
782
+ "board.circuit_breaker_count",
783
+ "backlog.ticket_count",
784
+ "ticket.field_value",
785
+ "time.hour"
786
+ ]);
787
+ var FiringConstraintOperatorSchema = z21.enum(["lt", "lte", "gt", "gte", "eq", "neq"]);
788
+ var FiringConstraintScopeSchema = z21.enum(["column", "ticket"]);
789
+ var FiringConstraintSchema = z21.object({
790
+ id: z21.string().uuid(),
791
+ project_id: z21.string().uuid(),
792
+ board_id: z21.string().uuid(),
793
+ column_id: z21.string().uuid().nullable(),
794
+ name: z21.string().min(1).max(200),
795
+ description: z21.string().nullable(),
796
+ enabled: z21.boolean(),
797
+ subject_type: FiringConstraintSubjectTypeSchema,
798
+ subject_ref: z21.string().nullable(),
799
+ subject_param: z21.string().nullable(),
800
+ operator: FiringConstraintOperatorSchema,
801
+ value: z21.union([z21.number(), z21.string(), z21.boolean()]),
802
+ scope: FiringConstraintScopeSchema,
803
+ notify: z21.boolean(),
804
+ position: z21.number().int(),
805
+ fail_open: z21.boolean(),
806
+ system: z21.boolean(),
807
+ created_at: z21.string().datetime({ offset: true }),
808
+ updated_at: z21.string().datetime({ offset: true })
809
+ });
810
+ var CreateFiringConstraintSchema = z21.object({
811
+ column_id: z21.string().uuid().nullable().optional(),
812
+ name: z21.string().min(1).max(200),
813
+ description: z21.string().nullable().optional(),
814
+ subject_type: FiringConstraintSubjectTypeSchema,
815
+ subject_ref: z21.string().nullable().optional(),
816
+ subject_param: z21.string().nullable().optional(),
817
+ operator: FiringConstraintOperatorSchema,
818
+ value: z21.union([z21.number(), z21.string(), z21.boolean()]),
819
+ scope: FiringConstraintScopeSchema.default("column"),
820
+ notify: z21.boolean().default(false),
821
+ enabled: z21.boolean().default(true),
822
+ fail_open: z21.boolean().default(false),
823
+ system: z21.boolean().default(false)
824
+ });
825
+ var UpdateFiringConstraintSchema = z21.object({
826
+ column_id: z21.string().uuid().nullable().optional(),
827
+ name: z21.string().min(1).max(200).optional(),
828
+ description: z21.string().nullable().optional(),
829
+ enabled: z21.boolean().optional(),
830
+ subject_type: FiringConstraintSubjectTypeSchema.optional(),
831
+ subject_ref: z21.string().nullable().optional(),
832
+ subject_param: z21.string().nullable().optional(),
833
+ operator: FiringConstraintOperatorSchema.optional(),
834
+ value: z21.union([z21.number(), z21.string(), z21.boolean()]).optional(),
835
+ scope: FiringConstraintScopeSchema.optional(),
836
+ notify: z21.boolean().optional(),
837
+ position: z21.number().int().optional(),
838
+ fail_open: z21.boolean().optional()
839
+ });
840
+ var EvaluateFiringConstraintResultSchema = z21.object({
841
+ constraint_id: z21.string().uuid(),
842
+ name: z21.string(),
843
+ column_id: z21.string().uuid().nullable(),
844
+ passed: z21.boolean(),
845
+ resolved_value: z21.union([z21.number(), z21.string(), z21.boolean()]).nullable(),
846
+ threshold: z21.object({
847
+ operator: z21.string(),
848
+ value: z21.union([z21.number(), z21.string(), z21.boolean()])
849
+ }),
850
+ error: z21.string().optional()
851
+ });
852
+ var EvaluateFiringConstraintsResponseSchema = z21.object({
853
+ board_id: z21.string().uuid(),
854
+ results: z21.array(EvaluateFiringConstraintResultSchema),
855
+ summary: z21.object({
856
+ total: z21.number().int(),
857
+ passed: z21.number().int(),
858
+ failed: z21.number().int(),
859
+ errors: z21.number().int()
860
+ })
861
+ });
862
+
863
+ // ../types/dist/pipeline-event.schema.js
864
+ import { z as z22 } from "zod";
865
+ var PipelineEventLayerSchema = z22.enum([
866
+ "gate",
867
+ "advisor",
868
+ "evaluator",
869
+ "constraint",
870
+ "cost",
871
+ "session",
872
+ "replanner"
873
+ ]);
874
+ var PipelineEventSeveritySchema = z22.enum(["info", "warning", "failure"]);
875
+ var PipelineEventSchema = z22.object({
876
+ id: z22.string().uuid(),
877
+ project_id: z22.string().uuid(),
878
+ board_id: z22.string().uuid(),
879
+ ticket_id: z22.string().uuid().nullable(),
880
+ column_id: z22.string().uuid().nullable(),
881
+ run_id: z22.string().nullable(),
882
+ session_id: z22.string().nullable(),
883
+ layer: PipelineEventLayerSchema,
884
+ event_type: z22.string().min(1).max(100),
885
+ severity: PipelineEventSeveritySchema,
886
+ summary: z22.string().min(1).max(1e3),
887
+ detail: z22.record(z22.unknown()).nullable(),
888
+ iteration: z22.number().int().nullable(),
889
+ created_at: z22.string().datetime({ offset: true })
890
+ });
891
+ var CreatePipelineEventSchema = z22.object({
892
+ board_id: z22.string().uuid(),
893
+ ticket_id: z22.string().uuid().nullable().optional(),
894
+ column_id: z22.string().uuid().nullable().optional(),
895
+ run_id: z22.string().nullable().optional(),
896
+ session_id: z22.string().nullable().optional(),
897
+ layer: PipelineEventLayerSchema,
898
+ event_type: z22.string().min(1).max(100),
899
+ severity: PipelineEventSeveritySchema,
900
+ summary: z22.string().min(1).max(1e3),
901
+ detail: z22.record(z22.unknown()).nullable().optional(),
902
+ iteration: z22.number().int().nullable().optional()
903
+ });
904
+ var CreatePipelineEventBatchSchema = z22.object({
905
+ events: z22.array(CreatePipelineEventSchema).min(1).max(100)
906
+ });
907
+ var PipelineEventsQuerySchema = z22.object({
908
+ boardId: z22.string().uuid(),
909
+ layer: z22.string().optional().transform((val) => {
910
+ if (!val)
911
+ return void 0;
912
+ const parts = val.split(",").map((s) => s.trim());
913
+ for (const p of parts) {
914
+ PipelineEventLayerSchema.parse(p);
915
+ }
916
+ return val;
917
+ }),
918
+ severity: z22.string().optional().transform((val) => {
919
+ if (!val)
920
+ return void 0;
921
+ const parts = val.split(",").map((s) => s.trim());
922
+ for (const p of parts) {
923
+ PipelineEventSeveritySchema.parse(p);
924
+ }
925
+ return val;
926
+ }),
927
+ ticketId: z22.string().uuid().optional(),
928
+ columnId: z22.string().uuid().optional(),
929
+ runId: z22.string().optional(),
930
+ since: z22.string().datetime({ offset: true }).optional(),
931
+ until: z22.string().datetime({ offset: true }).optional(),
932
+ cursor: z22.string().optional(),
933
+ limit: z22.coerce.number().int().min(1).max(200).default(50)
934
+ });
935
+ var LayerSummarySchema = z22.object({
936
+ gates: z22.object({
937
+ total: z22.number(),
938
+ passed: z22.number(),
939
+ failed: z22.number(),
940
+ top_failing_gate: z22.string().nullable(),
941
+ top_failing_count: z22.number()
942
+ }),
943
+ advisor: z22.object({
944
+ total: z22.number(),
945
+ by_action: z22.record(z22.number())
946
+ }),
947
+ evaluator: z22.object({
948
+ total: z22.number(),
949
+ approved: z22.number(),
950
+ rejected: z22.number(),
951
+ blocker_count: z22.number()
952
+ }),
953
+ constraints: z22.object({
954
+ total_evaluations: z22.number(),
955
+ currently_blocked: z22.number(),
956
+ top_blocking_name: z22.string().nullable(),
957
+ top_blocking_column: z22.string().nullable()
958
+ }),
959
+ cost: z22.object({
960
+ total_tokens_in: z22.number(),
961
+ total_tokens_out: z22.number(),
962
+ max_tokens: z22.number().nullable(),
963
+ top_ticket_id: z22.string().uuid().nullable(),
964
+ top_ticket_tokens: z22.number()
965
+ }),
966
+ truncated: z22.boolean()
967
+ });
968
+
969
+ // ../types/dist/board-ws.schema.js
970
+ var WsActorSchema = z23.object({
971
+ id: z23.string().uuid(),
972
+ displayName: z23.string()
973
+ }).nullable();
974
+ var WsBoardSubscribeSchema = z23.object({
975
+ type: z23.literal("board:subscribe"),
976
+ payload: z23.object({
977
+ boardId: z23.string().uuid(),
978
+ projectId: z23.string().uuid()
979
+ })
980
+ });
981
+ var WsBoardUnsubscribeSchema = z23.object({
982
+ type: z23.literal("board:unsubscribe"),
983
+ payload: z23.object({
984
+ boardId: z23.string().uuid()
985
+ })
986
+ });
987
+ var pipelineIdString = z23.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/);
988
+ var WsPipelineStreamClientSchema = z23.object({
989
+ type: z23.literal("pipeline:stream"),
990
+ payload: z23.object({
991
+ boardId: z23.string().uuid(),
992
+ ticketId: z23.string().uuid().nullable(),
993
+ columnId: z23.string().uuid().nullable(),
994
+ runId: pipelineIdString,
995
+ sessionId: pipelineIdString,
996
+ event: z23.record(z23.unknown())
997
+ })
998
+ });
999
+ var WsPipelineSessionStartClientSchema = z23.object({
1000
+ type: z23.literal("pipeline:session-start"),
1001
+ payload: z23.object({
1002
+ boardId: z23.string().uuid(),
1003
+ ticketId: z23.string().uuid().nullable(),
1004
+ columnId: z23.string().uuid().nullable(),
1005
+ runId: pipelineIdString,
1006
+ sessionId: pipelineIdString,
1007
+ model: z23.string(),
1008
+ invocationType: InvocationTypeSchema,
1009
+ iteration: z23.number().int().nullable()
1010
+ })
1011
+ });
1012
+ var WsPipelineSessionEndClientSchema = z23.object({
1013
+ type: z23.literal("pipeline:session-end"),
1014
+ payload: z23.object({
1015
+ boardId: z23.string().uuid(),
1016
+ runId: pipelineIdString,
1017
+ exitReason: ExitReasonSchema.nullable(),
1018
+ tokensIn: z23.number().int().nonnegative(),
1019
+ tokensOut: z23.number().int().nonnegative(),
1020
+ toolCallCount: z23.number().int().nonnegative(),
1021
+ durationMs: z23.number().int().nonnegative()
1022
+ })
1023
+ });
1024
+ var WsPipelineStoppedClientSchema = z23.object({
1025
+ type: z23.literal("pipeline:stopped"),
1026
+ payload: z23.object({
1027
+ boardId: z23.string().uuid()
1028
+ })
1029
+ });
1030
+ var WsBoardClientEvents = [
1031
+ WsBoardSubscribeSchema,
1032
+ WsBoardUnsubscribeSchema,
1033
+ WsPipelineStreamClientSchema,
1034
+ WsPipelineSessionStartClientSchema,
1035
+ WsPipelineSessionEndClientSchema,
1036
+ WsPipelineStoppedClientSchema
1037
+ ];
1038
+ var WsBoardUpdatedSchema = z23.object({
1039
+ type: z23.literal("board:updated"),
1040
+ payload: z23.object({
1041
+ board: BoardWithRoleSchema,
1042
+ actor: WsActorSchema
1043
+ })
1044
+ });
1045
+ var WsBoardDeletedSchema = z23.object({
1046
+ type: z23.literal("board:deleted"),
1047
+ payload: z23.object({
1048
+ boardId: z23.string().uuid(),
1049
+ actor: WsActorSchema
1050
+ })
1051
+ });
1052
+ var WsBoardSubscribedSchema = z23.object({
1053
+ type: z23.literal("board:subscribed"),
1054
+ payload: z23.object({
1055
+ boardId: z23.string().uuid()
1056
+ })
1057
+ });
1058
+ var WsBoardUnsubscribedSchema = z23.object({
1059
+ type: z23.literal("board:unsubscribed"),
1060
+ payload: z23.object({
1061
+ boardId: z23.string().uuid()
1062
+ })
1063
+ });
1064
+ var WsBoardAccessRevokedSchema = z23.object({
1065
+ type: z23.literal("board:access-revoked"),
1066
+ payload: z23.object({
1067
+ boardId: z23.string().uuid(),
1068
+ reason: z23.string()
1069
+ })
1070
+ });
1071
+ var WsColumnCreatedSchema = z23.object({
1072
+ type: z23.literal("column:created"),
1073
+ payload: z23.object({
1074
+ boardId: z23.string().uuid(),
1075
+ column: ColumnSchema,
1076
+ actor: WsActorSchema
1077
+ })
1078
+ });
1079
+ var WsColumnUpdatedSchema = z23.object({
1080
+ type: z23.literal("column:updated"),
1081
+ payload: z23.object({
1082
+ boardId: z23.string().uuid(),
1083
+ column: ColumnSchema,
1084
+ actor: WsActorSchema
1085
+ })
1086
+ });
1087
+ var WsColumnDeletedSchema = z23.object({
1088
+ type: z23.literal("column:deleted"),
1089
+ payload: z23.object({
1090
+ columnId: z23.string().uuid(),
1091
+ ticketAction: z23.enum(["delete", "archive", "move_to_backlog"]),
1092
+ ticketIds: z23.array(z23.string().uuid()),
1093
+ actor: WsActorSchema
1094
+ })
1095
+ });
1096
+ var WsColumnReorderedSchema = z23.object({
1097
+ type: z23.literal("column:reordered"),
1098
+ payload: z23.object({
1099
+ boardId: z23.string().uuid(),
1100
+ columns: z23.array(z23.object({ id: z23.string().uuid(), position: z23.number().int() })),
1101
+ actor: WsActorSchema
1102
+ })
1103
+ });
1104
+ var WsTicketCreatedSchema = z23.object({
1105
+ type: z23.literal("ticket:created"),
1106
+ payload: z23.object({
1107
+ boardId: z23.string().uuid(),
1108
+ columnId: z23.string().uuid().nullable(),
1109
+ ticket: TicketWithProfilesSchema,
1110
+ actor: WsActorSchema
1111
+ })
1112
+ });
1113
+ var WsTicketUpdatedSchema = z23.object({
1114
+ type: z23.literal("ticket:updated"),
1115
+ payload: z23.object({
1116
+ boardId: z23.string().uuid(),
1117
+ ticket: TicketWithProfilesSchema,
1118
+ actor: WsActorSchema
1119
+ })
1120
+ });
1121
+ var WsTicketDeletedSchema = z23.object({
1122
+ type: z23.literal("ticket:deleted"),
1123
+ payload: z23.object({
1124
+ boardId: z23.string().uuid(),
1125
+ ticketId: z23.string().uuid(),
1126
+ actor: WsActorSchema
1127
+ })
1128
+ });
1129
+ var WsTicketMovedSchema = z23.object({
1130
+ type: z23.literal("ticket:moved"),
1131
+ payload: z23.object({
1132
+ boardId: z23.string().uuid(),
1133
+ ticket: TicketWithProfilesSchema,
1134
+ fromColumnId: z23.string().uuid().nullable(),
1135
+ actor: WsActorSchema
1136
+ })
1137
+ });
1138
+ var WsTicketReorderedSchema = z23.object({
1139
+ type: z23.literal("ticket:reordered"),
1140
+ payload: z23.object({
1141
+ boardId: z23.string().uuid(),
1142
+ tickets: z23.array(z23.object({
1143
+ id: z23.string().uuid(),
1144
+ columnId: z23.string().uuid().nullable(),
1145
+ position: z23.number().int()
1146
+ })),
1147
+ actor: WsActorSchema
1148
+ })
1149
+ });
1150
+ var WsTicketArchivedSchema = z23.object({
1151
+ type: z23.literal("ticket:archived"),
1152
+ payload: z23.object({
1153
+ boardId: z23.string().uuid(),
1154
+ ticketId: z23.string().uuid(),
1155
+ archivedAt: z23.string().datetime({ offset: true }),
1156
+ actor: WsActorSchema
1157
+ })
1158
+ });
1159
+ var WsTicketUnarchivedSchema = z23.object({
1160
+ type: z23.literal("ticket:unarchived"),
1161
+ payload: z23.object({
1162
+ ticket: TicketWithProfilesSchema,
1163
+ actor: WsActorSchema
1164
+ })
1165
+ });
1166
+ var WsTicketBulkArchivedSchema = z23.object({
1167
+ type: z23.literal("ticket:bulk-archived"),
1168
+ payload: z23.object({
1169
+ columnId: z23.string().uuid(),
1170
+ ticketIds: z23.array(z23.string().uuid()),
1171
+ actor: WsActorSchema
1172
+ })
1173
+ });
1174
+ var WsCommentCreatedSchema = z23.object({
1175
+ type: z23.literal("comment:created"),
1176
+ payload: z23.object({
1177
+ boardId: z23.string().uuid(),
1178
+ ticketId: z23.string().uuid(),
1179
+ comment: CommentWithAuthorSchema,
1180
+ actor: WsActorSchema
1181
+ })
1182
+ });
1183
+ var WsCommentUpdatedSchema = z23.object({
1184
+ type: z23.literal("comment:updated"),
1185
+ payload: z23.object({
1186
+ boardId: z23.string().uuid(),
1187
+ ticketId: z23.string().uuid(),
1188
+ comment: CommentWithAuthorSchema,
1189
+ actor: WsActorSchema
1190
+ })
1191
+ });
1192
+ var WsCommentDeletedSchema = z23.object({
1193
+ type: z23.literal("comment:deleted"),
1194
+ payload: z23.object({
1195
+ boardId: z23.string().uuid(),
1196
+ ticketId: z23.string().uuid(),
1197
+ commentId: z23.string().uuid(),
1198
+ actor: WsActorSchema
1199
+ })
1200
+ });
1201
+ var WsAttachmentCreatedSchema = z23.object({
1202
+ type: z23.literal("attachment:created"),
1203
+ payload: z23.object({
1204
+ boardId: z23.string().uuid(),
1205
+ ticketId: z23.string().uuid(),
1206
+ attachment: TicketAttachmentWithUrlSchema,
1207
+ actor: WsActorSchema
1208
+ })
1209
+ });
1210
+ var WsAttachmentDeletedSchema = z23.object({
1211
+ type: z23.literal("attachment:deleted"),
1212
+ payload: z23.object({
1213
+ boardId: z23.string().uuid(),
1214
+ ticketId: z23.string().uuid(),
1215
+ attachmentId: z23.string().uuid(),
1216
+ actor: WsActorSchema
1217
+ })
1218
+ });
1219
+ var WsFieldValueUpdatedSchema = z23.object({
1220
+ type: z23.literal("field-value:updated"),
1221
+ payload: z23.object({
1222
+ ticketId: z23.string().uuid(),
1223
+ fieldId: z23.string().uuid(),
1224
+ value: z23.unknown(),
1225
+ customFields: z23.record(z23.string(), z23.unknown()),
1226
+ actor: WsActorSchema
1227
+ })
1228
+ });
1229
+ var WsFieldValueRemovedSchema = z23.object({
1230
+ type: z23.literal("field-value:removed"),
1231
+ payload: z23.object({
1232
+ ticketId: z23.string().uuid(),
1233
+ fieldId: z23.string().uuid(),
1234
+ customFields: z23.record(z23.string(), z23.unknown()),
1235
+ actor: WsActorSchema
1236
+ })
1237
+ });
1238
+ var WsFieldDefinitionCreatedSchema = z23.object({
1239
+ type: z23.literal("field-definition:created"),
1240
+ payload: z23.object({
1241
+ projectId: z23.string().uuid(),
1242
+ field: FieldDefinitionSchema,
1243
+ actor: WsActorSchema
1244
+ })
1245
+ });
1246
+ var WsFieldDefinitionUpdatedSchema = z23.object({
1247
+ type: z23.literal("field-definition:updated"),
1248
+ payload: z23.object({
1249
+ projectId: z23.string().uuid(),
1250
+ field: FieldDefinitionSchema,
1251
+ actor: WsActorSchema
1252
+ })
1253
+ });
1254
+ var WsFieldDefinitionDeletedSchema = z23.object({
1255
+ type: z23.literal("field-definition:deleted"),
1256
+ payload: z23.object({
1257
+ projectId: z23.string().uuid(),
1258
+ fieldId: z23.string().uuid(),
1259
+ actor: WsActorSchema
1260
+ })
1261
+ });
1262
+ var WsFieldDefinitionReorderedSchema = z23.object({
1263
+ type: z23.literal("field-definition:reordered"),
1264
+ payload: z23.object({
1265
+ projectId: z23.string().uuid(),
1266
+ fields: z23.array(z23.object({ id: z23.string().uuid(), position: z23.number().int() })),
1267
+ actor: WsActorSchema
1268
+ })
1269
+ });
1270
+ var WsFieldOverrideUpdatedSchema = z23.object({
1271
+ type: z23.literal("field-override:updated"),
1272
+ payload: z23.object({
1273
+ boardId: z23.string().uuid(),
1274
+ fieldOverride: BoardFieldOverrideSchema,
1275
+ actor: WsActorSchema
1276
+ })
1277
+ });
1278
+ var WsFieldOverrideDeletedSchema = z23.object({
1279
+ type: z23.literal("field-override:deleted"),
1280
+ payload: z23.object({
1281
+ boardId: z23.string().uuid(),
1282
+ fieldId: z23.string().uuid(),
1283
+ actor: WsActorSchema
1284
+ })
1285
+ });
1286
+ var WsTransitionRulesUpdatedSchema = z23.object({
1287
+ type: z23.literal("transition-rules:updated"),
1288
+ payload: z23.object({
1289
+ boardId: z23.string().uuid(),
1290
+ rules: z23.array(TransitionRuleSchema),
1291
+ actor: WsActorSchema
1292
+ })
1293
+ });
1294
+ var WsBoardMemberAddedSchema = z23.object({
1295
+ type: z23.literal("board-member:added"),
1296
+ payload: z23.object({
1297
+ boardId: z23.string().uuid(),
1298
+ member: BoardMemberWithProfileSchema,
1299
+ actor: WsActorSchema
1300
+ })
1301
+ });
1302
+ var WsBoardMemberUpdatedSchema = z23.object({
1303
+ type: z23.literal("board-member:updated"),
1304
+ payload: z23.object({
1305
+ boardId: z23.string().uuid(),
1306
+ member: BoardMemberWithProfileSchema,
1307
+ actor: WsActorSchema
1308
+ })
1309
+ });
1310
+ var WsBoardMemberRemovedSchema = z23.object({
1311
+ type: z23.literal("board-member:removed"),
1312
+ payload: z23.object({
1313
+ boardId: z23.string().uuid(),
1314
+ userId: z23.string().uuid(),
1315
+ actor: WsActorSchema
1316
+ })
1317
+ });
1318
+ var WsBacklogTicketAddedSchema = z23.object({
1319
+ type: z23.literal("backlog:ticket-added"),
1320
+ payload: z23.object({
1321
+ ticket: TicketWithProfilesSchema,
1322
+ actor: WsActorSchema
1323
+ })
1324
+ });
1325
+ var WsBacklogTicketRemovedSchema = z23.object({
1326
+ type: z23.literal("backlog:ticket-removed"),
1327
+ payload: z23.object({
1328
+ ticketId: z23.string().uuid(),
1329
+ actor: WsActorSchema
1330
+ })
1331
+ });
1332
+ var WsBacklogTicketUpdatedSchema = z23.object({
1333
+ type: z23.literal("backlog:ticket-updated"),
1334
+ payload: z23.object({
1335
+ ticket: TicketWithProfilesSchema,
1336
+ actor: WsActorSchema
1337
+ })
1338
+ });
1339
+ var WsBacklogTicketArchivedSchema = z23.object({
1340
+ type: z23.literal("backlog:ticket-archived"),
1341
+ payload: z23.object({
1342
+ ticketId: z23.string().uuid(),
1343
+ actor: WsActorSchema
1344
+ })
1345
+ });
1346
+ var WsBacklogTicketUnarchivedSchema = z23.object({
1347
+ type: z23.literal("backlog:ticket-unarchived"),
1348
+ payload: z23.object({
1349
+ ticket: TicketWithProfilesSchema,
1350
+ actor: WsActorSchema
1351
+ })
1352
+ });
1353
+ var WsBacklogTicketsAddedSchema = z23.object({
1354
+ type: z23.literal("backlog:tickets-added"),
1355
+ payload: z23.object({
1356
+ ticketIds: z23.array(z23.string().uuid()),
1357
+ projectId: z23.string().uuid()
1358
+ })
1359
+ });
1360
+ var WsBoardlistCreatedSchema = z23.object({
1361
+ type: z23.literal("boardlist:created"),
1362
+ payload: z23.object({
1363
+ projectId: z23.string().uuid(),
1364
+ board: BoardSchema,
1365
+ actor: WsActorSchema
1366
+ })
1367
+ });
1368
+ var WsBoardlistUpdatedSchema = z23.object({
1369
+ type: z23.literal("boardlist:updated"),
1370
+ payload: z23.object({
1371
+ projectId: z23.string().uuid(),
1372
+ board: BoardSchema.partial().extend({ id: z23.string().uuid() }),
1373
+ actor: WsActorSchema
1374
+ })
1375
+ });
1376
+ var WsBoardlistDeletedSchema = z23.object({
1377
+ type: z23.literal("boardlist:deleted"),
1378
+ payload: z23.object({
1379
+ projectId: z23.string().uuid(),
1380
+ boardId: z23.string().uuid(),
1381
+ actor: WsActorSchema
1382
+ })
1383
+ });
1384
+ var WsSignalCreatedSchema = z23.object({
1385
+ type: z23.literal("signal:created"),
1386
+ payload: z23.object({
1387
+ signal: SignalSchema,
1388
+ actor: WsActorSchema
1389
+ })
1390
+ });
1391
+ var WsSignalUpdatedSchema = z23.object({
1392
+ type: z23.literal("signal:updated"),
1393
+ payload: z23.object({
1394
+ signal: SignalSchema,
1395
+ actor: WsActorSchema
1396
+ })
1397
+ });
1398
+ var WsSignalDeletedSchema = z23.object({
1399
+ type: z23.literal("signal:deleted"),
1400
+ payload: z23.object({
1401
+ signalId: z23.string().uuid(),
1402
+ actor: WsActorSchema
1403
+ })
1404
+ });
1405
+ var WsSignalPromotedSchema = z23.object({
1406
+ type: z23.literal("signal:promoted"),
1407
+ payload: z23.object({
1408
+ signal: SignalSchema,
1409
+ actor: WsActorSchema
1410
+ })
1411
+ });
1412
+ var WsFiringConstraintCreatedSchema = z23.object({
1413
+ type: z23.literal("firing_constraint:created"),
1414
+ payload: z23.object({
1415
+ boardId: z23.string().uuid(),
1416
+ constraint: FiringConstraintSchema,
1417
+ actor: WsActorSchema
1418
+ })
1419
+ });
1420
+ var WsFiringConstraintUpdatedSchema = z23.object({
1421
+ type: z23.literal("firing_constraint:updated"),
1422
+ payload: z23.object({
1423
+ boardId: z23.string().uuid(),
1424
+ constraint: FiringConstraintSchema,
1425
+ actor: WsActorSchema
1426
+ })
1427
+ });
1428
+ var WsFiringConstraintDeletedSchema = z23.object({
1429
+ type: z23.literal("firing_constraint:deleted"),
1430
+ payload: z23.object({
1431
+ boardId: z23.string().uuid(),
1432
+ constraintId: z23.string().uuid(),
1433
+ actor: WsActorSchema
1434
+ })
1435
+ });
1436
+ var WsPipelineStreamSchema = z23.object({
1437
+ type: z23.literal("pipeline:stream"),
1438
+ payload: z23.object({
1439
+ boardId: z23.string().uuid(),
1440
+ ticketId: z23.string().uuid().nullable(),
1441
+ columnId: z23.string().uuid().nullable(),
1442
+ runId: pipelineIdString,
1443
+ sessionId: pipelineIdString,
1444
+ event: z23.record(z23.unknown())
1445
+ })
1446
+ });
1447
+ var WsPipelineSessionStartSchema = z23.object({
1448
+ type: z23.literal("pipeline:session-start"),
1449
+ payload: z23.object({
1450
+ boardId: z23.string().uuid(),
1451
+ ticketId: z23.string().uuid().nullable(),
1452
+ columnId: z23.string().uuid().nullable(),
1453
+ runId: pipelineIdString,
1454
+ sessionId: pipelineIdString,
1455
+ model: z23.string(),
1456
+ invocationType: InvocationTypeSchema,
1457
+ iteration: z23.number().int().nullable()
1458
+ })
1459
+ });
1460
+ var WsPipelineSessionEndSchema = z23.object({
1461
+ type: z23.literal("pipeline:session-end"),
1462
+ payload: z23.object({
1463
+ boardId: z23.string().uuid(),
1464
+ runId: pipelineIdString,
1465
+ exitReason: ExitReasonSchema.nullable(),
1466
+ tokensIn: z23.number().int().nonnegative(),
1467
+ tokensOut: z23.number().int().nonnegative(),
1468
+ toolCallCount: z23.number().int().nonnegative(),
1469
+ durationMs: z23.number().int().nonnegative()
1470
+ })
1471
+ });
1472
+ var WsPipelineStoppedSchema = z23.object({
1473
+ type: z23.literal("pipeline:stopped"),
1474
+ payload: z23.object({
1475
+ boardId: z23.string().uuid()
1476
+ })
1477
+ });
1478
+ var WsPipelineEventSchema = z23.object({
1479
+ type: z23.literal("pipeline:event"),
1480
+ payload: PipelineEventSchema
1481
+ });
1482
+ var WsBoardServerEvents = [
1483
+ WsBoardUpdatedSchema,
1484
+ WsBoardDeletedSchema,
1485
+ WsBoardSubscribedSchema,
1486
+ WsBoardUnsubscribedSchema,
1487
+ WsBoardAccessRevokedSchema,
1488
+ WsColumnCreatedSchema,
1489
+ WsColumnUpdatedSchema,
1490
+ WsColumnDeletedSchema,
1491
+ WsColumnReorderedSchema,
1492
+ WsTicketCreatedSchema,
1493
+ WsTicketUpdatedSchema,
1494
+ WsTicketDeletedSchema,
1495
+ WsTicketMovedSchema,
1496
+ WsTicketReorderedSchema,
1497
+ WsTicketArchivedSchema,
1498
+ WsTicketUnarchivedSchema,
1499
+ WsTicketBulkArchivedSchema,
1500
+ WsCommentCreatedSchema,
1501
+ WsCommentUpdatedSchema,
1502
+ WsCommentDeletedSchema,
1503
+ WsAttachmentCreatedSchema,
1504
+ WsAttachmentDeletedSchema,
1505
+ WsFieldValueUpdatedSchema,
1506
+ WsFieldValueRemovedSchema,
1507
+ WsFieldDefinitionCreatedSchema,
1508
+ WsFieldDefinitionUpdatedSchema,
1509
+ WsFieldDefinitionDeletedSchema,
1510
+ WsFieldDefinitionReorderedSchema,
1511
+ WsFieldOverrideUpdatedSchema,
1512
+ WsFieldOverrideDeletedSchema,
1513
+ WsTransitionRulesUpdatedSchema,
1514
+ WsBoardMemberAddedSchema,
1515
+ WsBoardMemberUpdatedSchema,
1516
+ WsBoardMemberRemovedSchema,
1517
+ WsBacklogTicketAddedSchema,
1518
+ WsBacklogTicketRemovedSchema,
1519
+ WsBacklogTicketUpdatedSchema,
1520
+ WsBacklogTicketArchivedSchema,
1521
+ WsBacklogTicketUnarchivedSchema,
1522
+ WsBacklogTicketsAddedSchema,
1523
+ WsBoardlistCreatedSchema,
1524
+ WsBoardlistUpdatedSchema,
1525
+ WsBoardlistDeletedSchema,
1526
+ WsSignalCreatedSchema,
1527
+ WsSignalUpdatedSchema,
1528
+ WsSignalDeletedSchema,
1529
+ WsSignalPromotedSchema,
1530
+ WsFiringConstraintCreatedSchema,
1531
+ WsFiringConstraintUpdatedSchema,
1532
+ WsFiringConstraintDeletedSchema,
1533
+ WsPipelineStreamSchema,
1534
+ WsPipelineSessionStartSchema,
1535
+ WsPipelineSessionEndSchema,
1536
+ WsPipelineStoppedSchema,
1537
+ WsPipelineEventSchema
1538
+ ];
1539
+
1540
+ // ../types/dist/chat.schema.js
1541
+ import { z as z25 } from "zod";
1542
+
1543
+ // ../types/dist/call.schema.js
1544
+ import { z as z24 } from "zod";
1545
+ var CallTypeSchema = z24.enum(["audio", "screen_share"]);
1546
+ var CallStatusSchema = z24.enum(["ringing", "active", "ended", "missed"]);
1547
+ var UserStatusSchema = z24.enum(["online", "away", "in_call", "dnd", "offline"]);
1548
+ var CallSessionSchema = z24.object({
1549
+ id: z24.string().uuid(),
1550
+ project_id: z24.string().uuid(),
1551
+ conversation_id: z24.string().uuid().nullable(),
1552
+ status: CallStatusSchema,
1553
+ created_by: z24.string().uuid(),
1554
+ livekit_room_name: z24.string(),
1555
+ started_at: z24.string().datetime({ offset: true }).nullable(),
1556
+ ended_at: z24.string().datetime({ offset: true }).nullable(),
1557
+ created_at: z24.string().datetime({ offset: true })
1558
+ });
1559
+ var CallParticipantSchema = z24.object({
1560
+ id: z24.string().uuid(),
1561
+ session_id: z24.string().uuid(),
1562
+ user_id: z24.string().uuid(),
1563
+ joined_at: z24.string().datetime({ offset: true }).nullable(),
1564
+ left_at: z24.string().datetime({ offset: true }).nullable()
1565
+ });
1566
+ var CallParticipantWithProfileSchema = CallParticipantSchema.extend({
1567
+ user: UserProfileSchema
1568
+ });
1569
+ var CallSessionWithParticipantsSchema = CallSessionSchema.extend({
1570
+ participants: z24.array(CallParticipantWithProfileSchema),
1571
+ creator: UserProfileSchema
1572
+ });
1573
+ var StartCallSchema = z24.object({
1574
+ conversationId: z24.string().uuid().optional(),
1575
+ participantIds: z24.array(z24.string().uuid()).min(1).max(4)
1576
+ });
1577
+ var JoinCallSchema = z24.object({
1578
+ sessionId: z24.string().uuid()
1579
+ });
1580
+ var CallTokenResponseSchema = z24.object({
1581
+ token: z24.string(),
1582
+ wsUrl: z24.string(),
1583
+ roomName: z24.string(),
1584
+ sessionId: z24.string().uuid()
1585
+ });
1586
+ var WsCallStartSchema = z24.object({
1587
+ type: z24.literal("call:start"),
1588
+ payload: StartCallSchema.extend({
1589
+ projectId: z24.string().uuid()
1590
+ })
1591
+ });
1592
+ var WsCallAcceptSchema = z24.object({
1593
+ type: z24.literal("call:accept"),
1594
+ payload: z24.object({ sessionId: z24.string().uuid() })
1595
+ });
1596
+ var WsCallDeclineSchema = z24.object({
1597
+ type: z24.literal("call:decline"),
1598
+ payload: z24.object({ sessionId: z24.string().uuid() })
1599
+ });
1600
+ var WsCallLeaveSchema = z24.object({
1601
+ type: z24.literal("call:leave"),
1602
+ payload: z24.object({ sessionId: z24.string().uuid() })
1603
+ });
1604
+ var WsCallEndSchema = z24.object({
1605
+ type: z24.literal("call:end"),
1606
+ payload: z24.object({ sessionId: z24.string().uuid() })
1607
+ });
1608
+ var WsStatusSetSchema = z24.object({
1609
+ type: z24.literal("status:set"),
1610
+ payload: z24.object({ status: z24.enum(["online", "away", "dnd"]) })
1611
+ });
1612
+ var WsServerCallRingSchema = z24.object({
1613
+ type: z24.literal("call:ring"),
1614
+ payload: z24.object({
1615
+ sessionId: z24.string().uuid(),
1616
+ projectId: z24.string().uuid(),
1617
+ conversationId: z24.string().uuid().nullable(),
1618
+ callerId: z24.string().uuid(),
1619
+ callerName: z24.string(),
1620
+ participantIds: z24.array(z24.string().uuid())
1621
+ })
1622
+ });
1623
+ var WsServerCallStartedSchema = z24.object({
1624
+ type: z24.literal("call:started"),
1625
+ payload: z24.object({
1626
+ sessionId: z24.string().uuid(),
1627
+ projectId: z24.string().uuid(),
1628
+ conversationId: z24.string().uuid().nullable()
1629
+ })
1630
+ });
1631
+ var WsServerCallParticipantJoinedSchema = z24.object({
1632
+ type: z24.literal("call:participant-joined"),
1633
+ payload: z24.object({
1634
+ sessionId: z24.string().uuid(),
1635
+ userId: z24.string().uuid(),
1636
+ displayName: z24.string()
1637
+ })
1638
+ });
1639
+ var WsServerCallParticipantLeftSchema = z24.object({
1640
+ type: z24.literal("call:participant-left"),
1641
+ payload: z24.object({
1642
+ sessionId: z24.string().uuid(),
1643
+ userId: z24.string().uuid()
1644
+ })
1645
+ });
1646
+ var WsServerCallEndedSchema = z24.object({
1647
+ type: z24.literal("call:ended"),
1648
+ payload: z24.object({
1649
+ sessionId: z24.string().uuid(),
1650
+ projectId: z24.string().uuid()
1651
+ })
1652
+ });
1653
+ var WsServerCallDeclinedSchema = z24.object({
1654
+ type: z24.literal("call:declined"),
1655
+ payload: z24.object({
1656
+ sessionId: z24.string().uuid(),
1657
+ userId: z24.string().uuid()
1658
+ })
1659
+ });
1660
+ var WsServerCallMissedSchema = z24.object({
1661
+ type: z24.literal("call:missed"),
1662
+ payload: z24.object({
1663
+ sessionId: z24.string().uuid(),
1664
+ projectId: z24.string().uuid(),
1665
+ callerId: z24.string().uuid(),
1666
+ callerName: z24.string()
1667
+ })
1668
+ });
1669
+ var WsServerStatusUpdateSchema = z24.object({
1670
+ type: z24.literal("status:update"),
1671
+ payload: z24.object({
1672
+ userId: z24.string().uuid(),
1673
+ status: UserStatusSchema
1674
+ })
1675
+ });
1676
+
1677
+ // ../types/dist/chat.schema.js
1678
+ var ChatConversationTypeSchema = z25.enum(["group", "direct"]);
1679
+ var PushPlatformSchema = z25.enum(["web", "ios", "android"]);
1680
+ var ChatConversationSchema = z25.object({
1681
+ id: z25.string().uuid(),
1682
+ project_id: z25.string().uuid(),
1683
+ type: ChatConversationTypeSchema,
1684
+ name: z25.string().nullable(),
1685
+ created_by: z25.string().uuid(),
1686
+ created_at: z25.string().datetime({ offset: true }),
1687
+ updated_at: z25.string().datetime({ offset: true })
1688
+ });
1689
+ var MessagePreviewSchema = z25.object({
1690
+ id: z25.string().uuid(),
1691
+ body: z25.string(),
1692
+ sender_id: z25.string().uuid(),
1693
+ created_at: z25.string().datetime({ offset: true })
1694
+ });
1695
+ var ChatConversationWithPreviewSchema = ChatConversationSchema.extend({
1696
+ lastMessage: MessagePreviewSchema.nullable(),
1697
+ unreadCount: z25.number().int().min(0),
1698
+ participants: z25.array(UserProfileSchema),
1699
+ projectName: z25.string(),
1700
+ muted_at: z25.string().datetime({ offset: true }).nullable(),
1701
+ pinned_at: z25.string().datetime({ offset: true }).nullable(),
1702
+ enter_sends_override: z25.boolean().nullable().default(null)
1703
+ });
1704
+ var ChatParticipantSchema = z25.object({
1705
+ id: z25.string().uuid(),
1706
+ conversation_id: z25.string().uuid(),
1707
+ user_id: z25.string().uuid(),
1708
+ joined_at: z25.string().datetime({ offset: true }),
1709
+ left_at: z25.string().datetime({ offset: true }).nullable(),
1710
+ deleted_at: z25.string().datetime({ offset: true }).nullable(),
1711
+ muted_at: z25.string().datetime({ offset: true }).nullable(),
1712
+ pinned_at: z25.string().datetime({ offset: true }).nullable(),
1713
+ enter_sends_override: z25.boolean().nullable().default(null)
1714
+ });
1715
+ var ChatParticipantWithProfileSchema = ChatParticipantSchema.extend({
1716
+ user: UserProfileSchema
1717
+ });
1718
+ var ChatMessageSchema = z25.object({
1719
+ id: z25.string().uuid(),
1720
+ conversation_id: z25.string().uuid(),
1721
+ sender_id: z25.string().uuid(),
1722
+ body: z25.string().min(1).max(4e3),
1723
+ attachment_url: z25.string().nullable(),
1724
+ attachment_type: z25.string().nullable(),
1725
+ mentions: z25.array(z25.string().uuid()),
1726
+ reply_to_id: z25.string().uuid().nullable().default(null),
1727
+ created_at: z25.string().datetime({ offset: true }),
1728
+ updated_at: z25.string().datetime({ offset: true }),
1729
+ deleted_at: z25.string().datetime({ offset: true }).nullable()
1730
+ });
1731
+ var ReplyPreviewSchema = z25.object({
1732
+ id: z25.string().uuid(),
1733
+ sender_id: z25.string().uuid(),
1734
+ sender_name: z25.string(),
1735
+ body: z25.string()
1736
+ });
1737
+ var ReactionAggregateSchema = z25.object({
1738
+ emoji: z25.string().min(1),
1739
+ count: z25.number().int().min(1),
1740
+ userIds: z25.array(z25.string().uuid())
1741
+ });
1742
+ var ChatMessageWithReactionsSchema = ChatMessageSchema.extend({
1743
+ sender: UserProfileSchema,
1744
+ reactions: z25.array(ReactionAggregateSchema),
1745
+ reply_to: ReplyPreviewSchema.nullable().default(null)
1746
+ });
1747
+ var ChatReactionSchema = z25.object({
1748
+ id: z25.string().uuid(),
1749
+ message_id: z25.string().uuid(),
1750
+ user_id: z25.string().uuid(),
1751
+ emoji: z25.string().min(1),
1752
+ created_at: z25.string().datetime({ offset: true })
1753
+ });
1754
+ var ChatReadCursorSchema = z25.object({
1755
+ id: z25.string().uuid(),
1756
+ conversation_id: z25.string().uuid(),
1757
+ user_id: z25.string().uuid(),
1758
+ last_read_message_id: z25.string().uuid(),
1759
+ last_read_at: z25.string().datetime({ offset: true })
1760
+ });
1761
+ var PushSubscriptionSchema = z25.object({
1762
+ id: z25.string().uuid(),
1763
+ user_id: z25.string().uuid(),
1764
+ platform: PushPlatformSchema,
1765
+ token: z25.string().min(1),
1766
+ created_at: z25.string().datetime({ offset: true }),
1767
+ updated_at: z25.string().datetime({ offset: true })
1768
+ });
1769
+ var NotificationPreferencesSchema = z25.object({
1770
+ id: z25.string(),
1771
+ user_id: z25.string().uuid(),
1772
+ push_enabled: z25.boolean(),
1773
+ push_dms: z25.boolean(),
1774
+ push_group: z25.boolean(),
1775
+ push_mentions: z25.boolean(),
1776
+ quiet_hours_start: z25.string().nullable(),
1777
+ quiet_hours_end: z25.string().nullable(),
1778
+ updated_at: z25.string().datetime({ offset: true }),
1779
+ chat_enter_sends: z25.boolean().default(true)
1780
+ });
1781
+ var CreateDMSchema = z25.object({
1782
+ type: z25.literal("direct"),
1783
+ participantId: z25.string().uuid()
1784
+ });
1785
+ var CreateGroupSchema = z25.object({
1786
+ type: z25.literal("group"),
1787
+ name: z25.string().min(1).max(50).refine((n) => n.toLowerCase() !== "general", { message: 'The name "general" is reserved' }),
1788
+ participantIds: z25.array(z25.string().uuid()).min(2)
1789
+ });
1790
+ var CreateConversationSchema = z25.discriminatedUnion("type", [
1791
+ CreateDMSchema,
1792
+ CreateGroupSchema
1793
+ ]);
1794
+ var SendMessageSchema = z25.object({
1795
+ conversationId: z25.string().uuid(),
1796
+ body: z25.string().max(4e3),
1797
+ attachmentUrl: z25.string().optional(),
1798
+ attachmentType: z25.string().optional(),
1799
+ mentions: z25.array(z25.string().uuid()).optional(),
1800
+ replyToId: z25.string().uuid().optional()
1801
+ }).refine((d) => d.body.length > 0 || !!d.attachmentUrl, { message: "Either body or attachmentUrl is required" });
1802
+ var UpdateMessageSchema = z25.object({
1803
+ messageId: z25.string().uuid(),
1804
+ body: z25.string().min(1).max(4e3)
1805
+ });
1806
+ var CreatePushSubscriptionSchema = z25.object({
1807
+ platform: PushPlatformSchema,
1808
+ token: z25.string().min(1)
1809
+ });
1810
+ var UpdateNotificationPreferencesSchema = z25.object({
1811
+ push_enabled: z25.boolean().optional(),
1812
+ push_dms: z25.boolean().optional(),
1813
+ push_group: z25.boolean().optional(),
1814
+ push_mentions: z25.boolean().optional(),
1815
+ quiet_hours_start: z25.string().nullable().optional(),
1816
+ quiet_hours_end: z25.string().nullable().optional(),
1817
+ chat_enter_sends: z25.boolean().optional()
1818
+ });
1819
+ var WsMessageSendSchema = z25.object({
1820
+ type: z25.literal("message:send"),
1821
+ payload: SendMessageSchema
1822
+ });
1823
+ var WsMessageEditSchema = z25.object({
1824
+ type: z25.literal("message:edit"),
1825
+ payload: UpdateMessageSchema
1826
+ });
1827
+ var WsMessageDeleteSchema = z25.object({
1828
+ type: z25.literal("message:delete"),
1829
+ payload: z25.object({ messageId: z25.string().uuid() })
1830
+ });
1831
+ var WsTypingStartSchema = z25.object({
1832
+ type: z25.literal("typing:start"),
1833
+ payload: z25.object({ conversationId: z25.string().uuid() })
1834
+ });
1835
+ var WsTypingStopSchema = z25.object({
1836
+ type: z25.literal("typing:stop"),
1837
+ payload: z25.object({ conversationId: z25.string().uuid() })
1838
+ });
1839
+ var WsReactionAddSchema = z25.object({
1840
+ type: z25.literal("reaction:add"),
1841
+ payload: z25.object({ messageId: z25.string().uuid(), emoji: z25.string().min(1) })
1842
+ });
1843
+ var WsReactionRemoveSchema = z25.object({
1844
+ type: z25.literal("reaction:remove"),
1845
+ payload: z25.object({ messageId: z25.string().uuid(), emoji: z25.string().min(1) })
1846
+ });
1847
+ var WsCursorUpdateSchema = z25.object({
1848
+ type: z25.literal("cursor:update"),
1849
+ payload: z25.object({
1850
+ conversationId: z25.string().uuid(),
1851
+ lastReadMessageId: z25.string().uuid()
1852
+ })
1853
+ });
1854
+ var WsPingSchema = z25.object({
1855
+ type: z25.literal("ping"),
1856
+ payload: z25.object({})
1857
+ });
1858
+ var WsChatClientEvents = [
1859
+ WsMessageSendSchema,
1860
+ WsMessageEditSchema,
1861
+ WsMessageDeleteSchema,
1862
+ WsTypingStartSchema,
1863
+ WsTypingStopSchema,
1864
+ WsReactionAddSchema,
1865
+ WsReactionRemoveSchema,
1866
+ WsCursorUpdateSchema,
1867
+ WsPingSchema,
1868
+ WsCallStartSchema,
1869
+ WsCallAcceptSchema,
1870
+ WsCallDeclineSchema,
1871
+ WsCallLeaveSchema,
1872
+ WsCallEndSchema,
1873
+ WsStatusSetSchema
1874
+ ];
1875
+ var WsClientEventSchema = z25.discriminatedUnion("type", [
1876
+ ...WsChatClientEvents,
1877
+ ...WsBoardClientEvents
1878
+ ]);
1879
+ var WsServerMessageNewSchema = z25.object({
1880
+ type: z25.literal("message:new"),
1881
+ payload: z25.object({ projectId: z25.string().uuid(), message: ChatMessageWithReactionsSchema })
1882
+ });
1883
+ var WsServerMessageUpdatedSchema = z25.object({
1884
+ type: z25.literal("message:updated"),
1885
+ payload: z25.object({ projectId: z25.string().uuid(), message: ChatMessageWithReactionsSchema })
1886
+ });
1887
+ var WsServerMessageDeletedSchema = z25.object({
1888
+ type: z25.literal("message:deleted"),
1889
+ payload: z25.object({ projectId: z25.string().uuid(), messageId: z25.string().uuid(), conversationId: z25.string().uuid() })
1890
+ });
1891
+ var WsServerTypingUpdateSchema = z25.object({
1892
+ type: z25.literal("typing:update"),
1893
+ payload: z25.object({
1894
+ projectId: z25.string().uuid(),
1895
+ conversationId: z25.string().uuid(),
1896
+ userId: z25.string().uuid(),
1897
+ isTyping: z25.boolean()
1898
+ })
1899
+ });
1900
+ var WsServerPresenceJoinSchema = z25.object({
1901
+ type: z25.literal("presence:join"),
1902
+ payload: z25.object({ userId: z25.string().uuid(), projectId: z25.string().uuid() })
1903
+ });
1904
+ var WsServerPresenceLeaveSchema = z25.object({
1905
+ type: z25.literal("presence:leave"),
1906
+ payload: z25.object({ userId: z25.string().uuid(), projectId: z25.string().uuid() })
1907
+ });
1908
+ var WsServerPresenceStateSchema = z25.object({
1909
+ type: z25.literal("presence:state"),
1910
+ payload: z25.object({
1911
+ online: z25.array(z25.string().uuid()),
1912
+ statuses: z25.record(z25.string(), UserStatusSchema).optional()
1913
+ })
1914
+ });
1915
+ var WsServerReactionAddedSchema = z25.object({
1916
+ type: z25.literal("reaction:added"),
1917
+ payload: z25.object({
1918
+ projectId: z25.string().uuid(),
1919
+ messageId: z25.string().uuid(),
1920
+ reaction: z25.object({
1921
+ userId: z25.string().uuid(),
1922
+ emoji: z25.string().min(1)
1923
+ })
1924
+ })
1925
+ });
1926
+ var WsServerReactionRemovedSchema = z25.object({
1927
+ type: z25.literal("reaction:removed"),
1928
+ payload: z25.object({
1929
+ projectId: z25.string().uuid(),
1930
+ messageId: z25.string().uuid(),
1931
+ userId: z25.string().uuid(),
1932
+ emoji: z25.string().min(1)
1933
+ })
1934
+ });
1935
+ var WsServerCursorUpdatedSchema = z25.object({
1936
+ type: z25.literal("cursor:updated"),
1937
+ payload: z25.object({
1938
+ projectId: z25.string().uuid(),
1939
+ conversationId: z25.string().uuid(),
1940
+ userId: z25.string().uuid(),
1941
+ lastReadMessageId: z25.string().uuid()
1942
+ })
1943
+ });
1944
+ var WsServerPongSchema = z25.object({
1945
+ type: z25.literal("pong"),
1946
+ payload: z25.object({})
1947
+ });
1948
+ var WsServerErrorSchema = z25.object({
1949
+ type: z25.literal("error"),
1950
+ payload: z25.object({ code: z25.string(), message: z25.string() })
1951
+ });
1952
+ var WsServerSubscriptionUpdateSchema = z25.object({
1953
+ type: z25.literal("subscription:update"),
1954
+ payload: z25.object({
1955
+ projectId: z25.string().uuid(),
1956
+ action: z25.enum(["added", "removed"]),
1957
+ project: z25.object({
1958
+ id: z25.string().uuid(),
1959
+ name: z25.string(),
1960
+ role: z25.string()
1961
+ }).optional()
1962
+ })
1963
+ });
1964
+ var WsServerConversationCreatedSchema = z25.object({
1965
+ type: z25.literal("conversation:created"),
1966
+ payload: z25.object({
1967
+ conversation: ChatConversationWithPreviewSchema
1968
+ })
1969
+ });
1970
+ var WsServerConversationUpdatedSchema = z25.object({
1971
+ type: z25.literal("conversation:updated"),
1972
+ payload: z25.object({
1973
+ conversationId: z25.string().uuid(),
1974
+ changes: z25.object({
1975
+ name: z25.string().optional(),
1976
+ participantsAdded: z25.array(z25.string().uuid()).optional(),
1977
+ participantsRemoved: z25.array(z25.string().uuid()).optional()
1978
+ })
1979
+ })
1980
+ });
1981
+ var WsServerConversationDeletedSchema = z25.object({
1982
+ type: z25.literal("conversation:deleted"),
1983
+ payload: z25.object({
1984
+ conversationId: z25.string().uuid(),
1985
+ projectId: z25.string().uuid()
1986
+ })
1987
+ });
1988
+ var WsServerUnreadSyncSchema = z25.object({
1989
+ type: z25.literal("unread:sync"),
1990
+ payload: z25.object({
1991
+ projects: z25.array(z25.object({ projectId: z25.string().uuid(), count: z25.number().int().min(0) })),
1992
+ conversations: z25.array(z25.object({ conversationId: z25.string().uuid(), count: z25.number().int().min(0) }))
1993
+ })
1994
+ });
1995
+ var WsServerDocumentCreatedSchema = z25.object({
1996
+ type: z25.literal("document:created"),
1997
+ payload: z25.object({
1998
+ projectId: z25.string().uuid(),
1999
+ spaceId: z25.string().uuid(),
2000
+ document: z25.object({ id: z25.string().uuid(), title: z25.string() })
2001
+ })
2002
+ });
2003
+ var WsServerDocumentUpdatedSchema = z25.object({
2004
+ type: z25.literal("document:updated"),
2005
+ payload: z25.object({
2006
+ projectId: z25.string().uuid(),
2007
+ spaceId: z25.string().uuid(),
2008
+ document: z25.object({ id: z25.string().uuid(), title: z25.string() })
2009
+ })
2010
+ });
2011
+ var WsServerDocumentDeletedSchema = z25.object({
2012
+ type: z25.literal("document:deleted"),
2013
+ payload: z25.object({
2014
+ projectId: z25.string().uuid(),
2015
+ spaceId: z25.string().uuid(),
2016
+ documentId: z25.string().uuid()
2017
+ })
2018
+ });
2019
+ var WsServerSpaceCreatedSchema = z25.object({
2020
+ type: z25.literal("space:created"),
2021
+ payload: z25.object({
2022
+ projectId: z25.string().uuid(),
2023
+ space: z25.object({ id: z25.string().uuid(), name: z25.string() })
2024
+ })
2025
+ });
2026
+ var WsServerSpaceUpdatedSchema = z25.object({
2027
+ type: z25.literal("space:updated"),
2028
+ payload: z25.object({
2029
+ projectId: z25.string().uuid(),
2030
+ space: z25.object({ id: z25.string().uuid(), name: z25.string() })
2031
+ })
2032
+ });
2033
+ var WsServerSpaceDeletedSchema = z25.object({
2034
+ type: z25.literal("space:deleted"),
2035
+ payload: z25.object({
2036
+ projectId: z25.string().uuid(),
2037
+ spaceId: z25.string().uuid()
2038
+ })
2039
+ });
2040
+ var WsChatServerEvents = [
2041
+ WsServerMessageNewSchema,
2042
+ WsServerMessageUpdatedSchema,
2043
+ WsServerMessageDeletedSchema,
2044
+ WsServerTypingUpdateSchema,
2045
+ WsServerPresenceJoinSchema,
2046
+ WsServerPresenceLeaveSchema,
2047
+ WsServerPresenceStateSchema,
2048
+ WsServerReactionAddedSchema,
2049
+ WsServerReactionRemovedSchema,
2050
+ WsServerCursorUpdatedSchema,
2051
+ WsServerPongSchema,
2052
+ WsServerErrorSchema,
2053
+ WsServerSubscriptionUpdateSchema,
2054
+ WsServerConversationCreatedSchema,
2055
+ WsServerConversationUpdatedSchema,
2056
+ WsServerConversationDeletedSchema,
2057
+ WsServerUnreadSyncSchema,
2058
+ WsServerDocumentCreatedSchema,
2059
+ WsServerDocumentUpdatedSchema,
2060
+ WsServerDocumentDeletedSchema,
2061
+ WsServerSpaceCreatedSchema,
2062
+ WsServerSpaceUpdatedSchema,
2063
+ WsServerSpaceDeletedSchema,
2064
+ WsServerCallRingSchema,
2065
+ WsServerCallStartedSchema,
2066
+ WsServerCallParticipantJoinedSchema,
2067
+ WsServerCallParticipantLeftSchema,
2068
+ WsServerCallEndedSchema,
2069
+ WsServerCallDeclinedSchema,
2070
+ WsServerCallMissedSchema,
2071
+ WsServerStatusUpdateSchema
2072
+ ];
2073
+ var WsServerEventSchema = z25.discriminatedUnion("type", [
2074
+ ...WsChatServerEvents,
2075
+ ...WsBoardServerEvents
2076
+ ]);
2077
+
2078
+ // ../types/dist/api-token.schema.js
2079
+ import { z as z26 } from "zod";
2080
+ var ApiTokenMetadataSchema = z26.object({
2081
+ id: z26.string().uuid(),
2082
+ name: z26.string().min(1),
2083
+ token_prefix: z26.string(),
2084
+ last_used_at: z26.string().datetime({ offset: true }).nullable(),
2085
+ created_at: z26.string().datetime({ offset: true })
2086
+ });
2087
+ var GenerateApiTokenResponseSchema = z26.object({
2088
+ id: z26.string().uuid(),
2089
+ name: z26.string().min(1),
2090
+ token_prefix: z26.string(),
2091
+ token: z26.string(),
2092
+ created_at: z26.string().datetime({ offset: true })
2093
+ });
2094
+ var CreateApiTokenBodySchema = z26.object({
2095
+ name: z26.string().min(1).max(100).optional().default("Claude Code")
2096
+ });
2097
+
2098
+ // ../types/dist/doc-space.schema.js
2099
+ import { z as z27 } from "zod";
2100
+ var DocSpaceSchema = z27.object({
2101
+ id: z27.string().uuid(),
2102
+ project_id: z27.string().uuid(),
2103
+ name: z27.string().min(1).max(100),
2104
+ prefix: z27.string().regex(/^[A-Z]{2,10}$/),
2105
+ doc_counter: z27.number().int().nonnegative(),
2106
+ created_at: z27.string().datetime({ offset: true }),
2107
+ updated_at: z27.string().datetime({ offset: true })
2108
+ });
2109
+ var DocSpaceWithCountSchema = DocSpaceSchema.extend({
2110
+ document_count: z27.number().int().nonnegative(),
2111
+ can_write: z27.boolean()
2112
+ });
2113
+ var CreateDocSpaceSchema = z27.object({
2114
+ name: z27.string().trim().min(1).max(100),
2115
+ prefix: z27.string().regex(/^[A-Z]{2,10}$/)
2116
+ });
2117
+ var UpdateDocSpaceSchema = z27.object({
2118
+ name: z27.string().trim().min(1).max(100).optional(),
2119
+ prefix: z27.string().regex(/^[A-Z]{2,10}$/).optional()
2120
+ });
2121
+ var DocumentActionSchema = z27.enum(["delete", "move"]);
2122
+ var DeleteDocSpaceBodySchema = z27.object({
2123
+ document_action: DocumentActionSchema.default("delete"),
2124
+ target_space_id: z27.string().uuid().optional()
2125
+ }).superRefine((data, ctx) => {
2126
+ if (data.document_action === "move" && !data.target_space_id) {
2127
+ ctx.addIssue({
2128
+ code: z27.ZodIssueCode.custom,
2129
+ message: "target_space_id is required when document_action is move",
2130
+ path: ["target_space_id"]
2131
+ });
2132
+ }
2133
+ });
2134
+ var DeleteDocSpacePreviewSchema = z27.object({
2135
+ documents: z27.number().int().nonnegative()
2136
+ });
2137
+
2138
+ // ../types/dist/document.schema.js
2139
+ import { z as z28 } from "zod";
2140
+ var DocumentSchema = z28.object({
2141
+ id: z28.string().uuid(),
2142
+ space_id: z28.string().uuid(),
2143
+ project_id: z28.string().uuid(),
2144
+ parent_id: z28.string().uuid().nullable(),
2145
+ doc_number: z28.number().int().positive(),
2146
+ title: z28.string().min(1).max(500),
2147
+ content: z28.string(),
2148
+ position: z28.number().int(),
2149
+ created_by: z28.string().uuid(),
2150
+ updated_by: z28.string().uuid(),
2151
+ created_at: z28.string().datetime({ offset: true }),
2152
+ updated_at: z28.string().datetime({ offset: true })
2153
+ });
2154
+ var DocumentWithProfilesSchema = DocumentSchema.extend({
2155
+ creator: UserProfileSchema,
2156
+ updater: UserProfileSchema
2157
+ });
2158
+ var DocumentTreeNodeSchema = DocumentSchema.extend({
2159
+ children: z28.lazy(() => DocumentTreeNodeSchema.array())
2160
+ });
2161
+ var CreateDocumentSchema = z28.object({
2162
+ title: z28.string().trim().min(1).max(500),
2163
+ content: z28.string().optional().default(""),
2164
+ parent_id: z28.string().uuid().nullable().optional().default(null)
2165
+ });
2166
+ var UpdateDocumentSchema = z28.object({
2167
+ title: z28.string().trim().min(1).max(500).optional(),
2168
+ content: z28.string().optional()
2169
+ });
2170
+ var MoveDocumentSchema = z28.object({
2171
+ parent_id: z28.string().uuid().nullable().optional(),
2172
+ position: z28.number().int().nonnegative().optional()
2173
+ });
2174
+ var DeleteDocumentPreviewSchema = z28.object({
2175
+ child_documents: z28.number().int().nonnegative()
2176
+ });
2177
+
2178
+ // ../types/dist/search.schema.js
2179
+ import { z as z29 } from "zod";
2180
+ var SearchResultTypeSchema = z29.enum(["ticket", "document", "message"]);
2181
+ var SearchResultSchema = z29.object({
2182
+ type: SearchResultTypeSchema,
2183
+ id: z29.string().uuid(),
2184
+ display_id: z29.string().nullable(),
2185
+ project_id: z29.string().uuid(),
2186
+ project_name: z29.string(),
2187
+ title: z29.string(),
2188
+ snippet: z29.string(),
2189
+ meta: z29.record(z29.string(), z29.unknown()).optional()
2190
+ });
2191
+ var SearchQuerySchema = z29.object({
2192
+ q: z29.string().min(2),
2193
+ type: SearchResultTypeSchema.optional(),
2194
+ project_id: z29.string().uuid().optional(),
2195
+ limit: z29.coerce.number().int().min(1).max(50).optional().default(20)
2196
+ });
2197
+ var SearchResponseSchema = z29.object({
2198
+ results: z29.array(SearchResultSchema),
2199
+ total: z29.number().int().nonnegative()
2200
+ });
2201
+ var MentionResultTypeSchema = z29.enum(["ticket", "document", "user"]);
2202
+ var MentionResultSchema = z29.object({
2203
+ type: MentionResultTypeSchema,
2204
+ id: z29.string().uuid(),
2205
+ displayId: z29.string(),
2206
+ title: z29.string(),
2207
+ avatarUrl: z29.string().optional()
2208
+ });
2209
+
2210
+ // ../types/dist/entity-reference.schema.js
2211
+ import { z as z30 } from "zod";
2212
+ var EntityReferenceSourceTypeSchema = z30.enum(["ticket", "document", "comment", "chat_message"]);
2213
+ var EntityReferenceTargetTypeSchema = z30.enum(["ticket", "document"]);
2214
+ var EntityReferenceSchema = z30.object({
2215
+ id: z30.string().uuid(),
2216
+ source_type: EntityReferenceSourceTypeSchema,
2217
+ source_id: z30.string().uuid(),
2218
+ target_type: EntityReferenceTargetTypeSchema,
2219
+ target_id: z30.string().uuid(),
2220
+ project_id: z30.string().uuid(),
2221
+ created_at: z30.string().datetime({ offset: true })
2222
+ });
2223
+ var BacklinkSchema = z30.object({
2224
+ source_type: EntityReferenceSourceTypeSchema,
2225
+ source_id: z30.string().uuid(),
2226
+ display_id: z30.string(),
2227
+ title: z30.string()
2228
+ });
2229
+ var BacklinksResponseSchema = z30.object({
2230
+ backlinks: z30.array(BacklinkSchema),
2231
+ total: z30.number().int().nonnegative()
2232
+ });
2233
+ var ResolveResultSchema = z30.object({
2234
+ type: EntityReferenceTargetTypeSchema,
2235
+ id: z30.string().uuid(),
2236
+ boardId: z30.string().uuid().optional(),
2237
+ spaceId: z30.string().uuid().optional()
2238
+ });
2239
+ var BatchResolveResponseSchema = z30.object({
2240
+ results: z30.record(z30.string(), ResolveResultSchema)
2241
+ });
2242
+
2243
+ // ../types/dist/notification.schema.js
2244
+ import { z as z31 } from "zod";
2245
+ var NotificationTypeSchema = z31.enum(["mention"]);
2246
+ var NotificationSchema = z31.object({
2247
+ id: z31.string().uuid(),
2248
+ project_id: z31.string().uuid(),
2249
+ user_id: z31.string().uuid(),
2250
+ actor_id: z31.string().uuid(),
2251
+ type: NotificationTypeSchema,
2252
+ source_type: z31.string(),
2253
+ source_id: z31.string().uuid(),
2254
+ display_id: z31.string(),
2255
+ title: z31.string(),
2256
+ read: z31.boolean(),
2257
+ created_at: z31.string().datetime({ offset: true })
2258
+ });
2259
+ var NotificationWithActorSchema = NotificationSchema.extend({
2260
+ actor: z31.object({
2261
+ id: z31.string().uuid(),
2262
+ display_name: z31.string(),
2263
+ avatar_url: z31.string().nullable()
2264
+ }).nullable()
2265
+ });
2266
+ var NotificationsResponseSchema = z31.object({
2267
+ notifications: z31.array(NotificationWithActorSchema),
2268
+ unread_count: z31.number().int().nonnegative()
2269
+ });
2270
+
2271
+ // ../types/dist/field-value.schema.js
2272
+ import { z as z32 } from "zod";
2273
+ var FieldValueSchema = z32.object({
2274
+ id: z32.string().uuid(),
2275
+ ticket_id: z32.string().uuid(),
2276
+ field_id: z32.string().uuid(),
2277
+ text_value: z32.string().nullable(),
2278
+ number_value: z32.number().nullable(),
2279
+ date_value: z32.string().nullable(),
2280
+ json_value: z32.unknown().nullable(),
2281
+ ref_user_id: z32.string().uuid().nullable(),
2282
+ ref_ticket_id: z32.string().uuid().nullable(),
2283
+ ref_document_id: z32.string().uuid().nullable(),
2284
+ created_at: z32.string().datetime({ offset: true }),
2285
+ updated_at: z32.string().datetime({ offset: true })
2286
+ });
2287
+ var FieldValueWithDefinitionSchema = FieldValueSchema.extend({
2288
+ field_name: z32.string(),
2289
+ field_type: z32.string()
2290
+ });
2291
+ var SetFieldValueSchema = z32.object({
2292
+ value: z32.unknown()
2293
+ });
2294
+ var BatchSetFieldValuesSchema = z32.object({
2295
+ values: z32.record(z32.string(), z32.unknown())
2296
+ });
2297
+
2298
+ // ../types/dist/transition-requirement.schema.js
2299
+ import { z as z33 } from "zod";
2300
+ var TransitionFieldRequirementSchema = z33.object({
2301
+ id: z33.string().uuid(),
2302
+ board_id: z33.string().uuid(),
2303
+ to_column_id: z33.string().uuid().nullable(),
2304
+ field_id: z33.string().uuid(),
2305
+ to_tombstone_id: z33.string().uuid().nullable(),
2306
+ status: TransitionRuleStatusSchema,
2307
+ instruction: z33.string().nullable(),
2308
+ created_at: z33.string().datetime({ offset: true }),
2309
+ updated_at: z33.string().datetime({ offset: true })
2310
+ });
2311
+ var TransitionFieldRequirementWithTombstoneSchema = TransitionFieldRequirementSchema.extend({
2312
+ to_tombstone_name: z33.string().nullable().default(null),
2313
+ field_name: z33.string().default(""),
2314
+ field_type: z33.string().default("")
2315
+ });
2316
+ var BulkUpsertTransitionRequirementsSchema = z33.object({
2317
+ requirements: z33.array(z33.object({
2318
+ to_column_id: z33.string().uuid(),
2319
+ field_id: z33.string().uuid(),
2320
+ instruction: z33.string().nullable().optional()
2321
+ }))
2322
+ });
2323
+
2324
+ // ../types/dist/transition-blocked.schema.js
2325
+ import { z as z34 } from "zod";
2326
+ var ColumnInfoSchema = z34.object({
2327
+ id: z34.string().uuid(),
2328
+ name: z34.string()
2329
+ });
2330
+ var WorkflowViolationSchema = z34.object({
2331
+ type: z34.literal("workflow"),
2332
+ message: z34.string(),
2333
+ from_column: ColumnInfoSchema,
2334
+ to_column: ColumnInfoSchema,
2335
+ allowed_targets: z34.array(ColumnInfoSchema)
2336
+ });
2337
+ var MissingFieldsViolationSchema = z34.object({
2338
+ type: z34.literal("missing_fields"),
2339
+ message: z34.string(),
2340
+ fields: z34.array(z34.object({
2341
+ field_id: z34.string().uuid(),
2342
+ name: z34.string(),
2343
+ type: z34.string(),
2344
+ config: z34.record(z34.string(), z34.unknown()).default({})
2345
+ }))
2346
+ });
2347
+ var UnresolvedDependenciesViolationSchema = z34.object({
2348
+ type: z34.literal("unresolved_dependencies"),
2349
+ message: z34.string(),
2350
+ blocking_tickets: z34.array(z34.object({
2351
+ id: z34.string().uuid(),
2352
+ ticket_number: z34.number().int(),
2353
+ title: z34.string(),
2354
+ column: z34.string()
2355
+ }))
2356
+ });
2357
+ var TransitionViolationSchema = z34.discriminatedUnion("type", [
2358
+ WorkflowViolationSchema,
2359
+ MissingFieldsViolationSchema,
2360
+ UnresolvedDependenciesViolationSchema
2361
+ ]);
2362
+ var TransitionBlockedErrorSchema = z34.object({
2363
+ success: z34.literal(false),
2364
+ error: z34.object({
2365
+ code: z34.literal("TRANSITION_BLOCKED"),
2366
+ violations: z34.array(TransitionViolationSchema)
2367
+ })
2368
+ });
2369
+
2370
+ // ../types/dist/ticket-link.schema.js
2371
+ import { z as z35 } from "zod";
2372
+ var TicketLinkTypeSchema = z35.enum(["blocks", "relates_to", "duplicates"]);
2373
+ var ResolvedWhenSchema = z35.discriminatedUnion("type", [
2374
+ z35.object({
2375
+ type: z35.literal("column"),
2376
+ column_ids: z35.array(z35.string().uuid()).min(1)
2377
+ }),
2378
+ z35.object({
2379
+ type: z35.literal("archived")
2380
+ }),
2381
+ z35.object({
2382
+ type: z35.literal("column_or_archived"),
2383
+ column_ids: z35.array(z35.string().uuid())
2384
+ })
2385
+ ]);
2386
+ var TicketLinkSchema = z35.object({
2387
+ id: z35.string().uuid(),
2388
+ source_id: z35.string().uuid(),
2389
+ target_id: z35.string().uuid(),
2390
+ link_type: TicketLinkTypeSchema,
2391
+ project_id: z35.string().uuid(),
2392
+ created_by: z35.string().uuid(),
2393
+ created_at: z35.string().datetime({ offset: true }),
2394
+ updated_at: z35.string().datetime({ offset: true }),
2395
+ resolved_at: z35.string().datetime({ offset: true }).nullable().optional(),
2396
+ resolved_by: z35.string().uuid().nullable().optional()
2397
+ });
2398
+ var TicketLinkWithDetailsSchema = TicketLinkSchema.extend({
2399
+ source: z35.object({
2400
+ id: z35.string().uuid(),
2401
+ ticket_number: z35.number().int(),
2402
+ title: z35.string(),
2403
+ column_name: z35.string().nullable()
2404
+ }),
2405
+ target: z35.object({
2406
+ id: z35.string().uuid(),
2407
+ ticket_number: z35.number().int(),
2408
+ title: z35.string(),
2409
+ column_name: z35.string().nullable()
2410
+ })
2411
+ });
2412
+ var CreateTicketLinkSchema = z35.object({
2413
+ source_ticket_id: z35.string().uuid(),
2414
+ target_ticket_id: z35.string().uuid(),
2415
+ link_type: TicketLinkTypeSchema
2416
+ });
2417
+ var DependencyRequirementSchema = z35.object({
2418
+ id: z35.string().uuid(),
2419
+ board_id: z35.string().uuid(),
2420
+ to_column_id: z35.string().uuid().nullable().optional(),
2421
+ to_tombstone_id: z35.string().uuid().nullable().optional(),
2422
+ instruction: z35.string().nullable().optional(),
2423
+ status: z35.enum(["active", "broken"]),
2424
+ resolved_when: ResolvedWhenSchema.nullable().optional(),
2425
+ created_at: z35.string().datetime({ offset: true }),
2426
+ updated_at: z35.string().datetime({ offset: true })
2427
+ });
2428
+
2429
+ // ../types/dist/column-tombstone.schema.js
2430
+ import { z as z36 } from "zod";
2431
+ var ColumnTombstoneSchema = z36.object({
2432
+ id: z36.string().uuid(),
2433
+ board_id: z36.string().uuid(),
2434
+ name: z36.string(),
2435
+ color: z36.string(),
2436
+ deleted_at: z36.string().datetime({ offset: true })
2437
+ });
2438
+
2439
+ // ../types/dist/gif.schema.js
2440
+ import { z as z37 } from "zod";
2441
+ var GifSchema = z37.object({
2442
+ id: z37.string(),
2443
+ title: z37.string(),
2444
+ url: z37.string().url(),
2445
+ preview_url: z37.string().url(),
2446
+ width: z37.number().int(),
2447
+ height: z37.number().int()
2448
+ });
2449
+ var GifSearchQuerySchema = z37.object({
2450
+ q: z37.string().min(1).max(100)
2451
+ });
2452
+ var GifResponseSchema = z37.object({
2453
+ gifs: z37.array(GifSchema)
2454
+ });
2455
+
2456
+ // ../types/dist/preferences.schema.js
2457
+ import { z as z38 } from "zod";
2458
+ var ThemePaletteSchema = z38.enum(["kantban", "seventies-coffee"]);
2459
+ var ThemeModeSchema = z38.enum(["light", "dark", "system"]);
2460
+ var UserPreferencesSchema = z38.object({
2461
+ user_id: z38.string().uuid(),
2462
+ theme_palette: ThemePaletteSchema,
2463
+ theme_mode: ThemeModeSchema
2464
+ });
2465
+ var UpdateUserPreferencesSchema = z38.object({
2466
+ theme_palette: ThemePaletteSchema.optional(),
2467
+ theme_mode: ThemeModeSchema.optional()
2468
+ });
2469
+
2470
+ // ../types/dist/activity.schema.js
2471
+ import { z as z39 } from "zod";
2472
+ var ActivityActionSchema = z39.enum([
2473
+ "ticket_created",
2474
+ "ticket_moved",
2475
+ "ticket_updated",
2476
+ "comment_added",
2477
+ "field_changed",
2478
+ "ticket_archived",
2479
+ "github_reference_created",
2480
+ "github_reference_updated",
2481
+ "template_executed",
2482
+ "sprint_closed",
2483
+ "signal_created",
2484
+ "document_updated",
2485
+ "board_updated",
2486
+ "column_updated",
2487
+ "signal_deleted",
2488
+ "transition_rule_changed",
2489
+ "firing_constraint_created",
2490
+ "firing_constraint_updated",
2491
+ "firing_constraint_deleted",
2492
+ "pipeline_session_completed"
2493
+ ]);
2494
+ var ActivityResourceTypeSchema = z39.enum([
2495
+ "ticket",
2496
+ "comment",
2497
+ "field_value",
2498
+ "board",
2499
+ "document",
2500
+ "ticket_reference",
2501
+ "pipeline_template",
2502
+ "signal",
2503
+ "column",
2504
+ "pipeline_session"
2505
+ ]);
2506
+ var ActivityLogSchema = z39.object({
2507
+ id: z39.string().uuid(),
2508
+ project_id: z39.string().uuid(),
2509
+ actor_id: z39.string().uuid(),
2510
+ action: ActivityActionSchema,
2511
+ resource_type: ActivityResourceTypeSchema,
2512
+ resource_id: z39.string().uuid(),
2513
+ board_id: z39.string().uuid().nullable().default(null),
2514
+ ticket_id: z39.string().uuid().nullable().default(null),
2515
+ metadata: z39.record(z39.string(), z39.unknown()).default({}),
2516
+ created_at: z39.string().datetime({ offset: true })
2517
+ });
2518
+ var ActivityFeedQuerySchema = z39.object({
2519
+ since: z39.string().datetime({ offset: true }).optional(),
2520
+ types: z39.string().optional(),
2521
+ via: z39.string().optional(),
2522
+ boardId: z39.string().uuid().optional(),
2523
+ ticketId: z39.string().uuid().optional(),
2524
+ columnId: z39.string().uuid().optional(),
2525
+ sessionId: z39.string().uuid().optional(),
2526
+ limit: z39.coerce.number().int().min(1).max(200).optional().default(20),
2527
+ cursor: z39.string().optional()
2528
+ });
2529
+
2530
+ // ../types/dist/ticket-metrics.schema.js
2531
+ import { z as z40 } from "zod";
2532
+ var TicketMetricsSchema = z40.object({
2533
+ ticket_id: z40.string().uuid(),
2534
+ board_id: z40.string().uuid(),
2535
+ project_id: z40.string().uuid(),
2536
+ created_at: z40.string().datetime({ offset: true }),
2537
+ first_active_at: z40.string().datetime({ offset: true }).nullable(),
2538
+ done_at: z40.string().datetime({ offset: true }),
2539
+ lead_time_hours: z40.number(),
2540
+ cycle_time_hours: z40.number().nullable(),
2541
+ column_transitions: z40.number().int(),
2542
+ backward_moves: z40.number().int(),
2543
+ assignee_changes: z40.number().int(),
2544
+ labels: z40.record(z40.string(), z40.unknown()).default({})
2545
+ });
2546
+
2547
+ // ../types/dist/daily-snapshot.schema.js
2548
+ import { z as z41 } from "zod";
2549
+ var DailySnapshotSchema = z41.object({
2550
+ id: z41.string().uuid(),
2551
+ project_id: z41.string().uuid(),
2552
+ board_id: z41.string().uuid(),
2553
+ snapshot_date: z41.string(),
2554
+ column_id: z41.string().uuid(),
2555
+ column_name: z41.string(),
2556
+ ticket_count: z41.number().int()
2557
+ });
2558
+
2559
+ // ../types/dist/compound.schema.js
2560
+ import { z as z42 } from "zod";
2561
+ var PlanItemSchema = z42.object({
2562
+ title: z42.string().min(1).max(500),
2563
+ description: z42.string().max(1e4).optional(),
2564
+ columnName: z42.string().optional(),
2565
+ fieldValues: z42.record(z42.string(), z42.unknown()).optional(),
2566
+ subtasks: z42.array(z42.object({
2567
+ title: z42.string().min(1).max(500),
2568
+ description: z42.string().max(1e4).optional()
2569
+ })).optional()
2570
+ });
2571
+ var PlanToTicketsBodySchema = z42.object({
2572
+ plan: z42.array(PlanItemSchema).min(1).max(50),
2573
+ dryRun: z42.boolean().optional().default(true)
2574
+ });
2575
+ var SuggestNextTaskQuerySchema = z42.object({
2576
+ boardId: z42.string().uuid().optional(),
2577
+ userId: z42.string().uuid().optional(),
2578
+ count: z42.coerce.number().optional().default(5)
2579
+ });
2580
+ var TaskScoreSchema = z42.object({
2581
+ ticketId: z42.string().uuid(),
2582
+ ticketNumber: z42.number(),
2583
+ title: z42.string(),
2584
+ score: z42.number(),
2585
+ breakdown: z42.record(z42.string(), z42.number()),
2586
+ reasoning: z42.string(),
2587
+ columnName: z42.string(),
2588
+ boardName: z42.string(),
2589
+ assigneeName: z42.string().nullable(),
2590
+ timeInColumn: z42.number(),
2591
+ timeUnit: z42.enum(["minutes", "hours", "days"]).default("days")
2592
+ });
2593
+ var StartWorkingBodySchema = z42.object({
2594
+ moveToColumn: z42.string().optional()
2595
+ });
2596
+ var CompleteTaskBodySchema = z42.object({
2597
+ moveToColumn: z42.string().optional(),
2598
+ completionComment: z42.string().max(1e4).optional(),
2599
+ suggestNext: z42.boolean().optional().default(true),
2600
+ handoff: z42.record(z42.string(), z42.unknown()).optional()
2601
+ });
2602
+ var BottleneckResultSchema = z42.object({
2603
+ wip_violations: z42.array(z42.object({
2604
+ column: z42.string(),
2605
+ limit: z42.number(),
2606
+ actual: z42.number(),
2607
+ tickets: z42.array(z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() }))
2608
+ })),
2609
+ stuck_tickets: z42.array(z42.object({
2610
+ ticket: z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() }),
2611
+ column: z42.string(),
2612
+ time_in_column: z42.number(),
2613
+ time_unit: z42.enum(["minutes", "hours", "days"]).default("days"),
2614
+ last_activity_at: z42.string().nullable()
2615
+ })),
2616
+ blocked_chains: z42.array(z42.object({
2617
+ blocking_ticket: z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() }),
2618
+ blocked_tickets: z42.array(z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() })),
2619
+ reason: z42.string()
2620
+ })),
2621
+ unassigned_active: z42.array(z42.object({
2622
+ ticket: z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() }),
2623
+ column: z42.string()
2624
+ })),
2625
+ suggestions: z42.array(z42.string()),
2626
+ circuit_breaker_proximity: z42.array(z42.object({
2627
+ ticket: z42.object({ id: z42.string(), title: z42.string(), ticket_number: z42.number() }),
2628
+ column: z42.string(),
2629
+ backward_transitions: z42.number(),
2630
+ threshold: z42.number()
2631
+ })).optional()
2632
+ });
2633
+ var TicketContextSchema = z42.object({
2634
+ ticket: z42.record(z42.string(), z42.unknown()),
2635
+ comments: z42.array(z42.record(z42.string(), z42.unknown())),
2636
+ field_values: z42.array(z42.record(z42.string(), z42.unknown())),
2637
+ linked_tickets: z42.array(z42.record(z42.string(), z42.unknown())),
2638
+ linked_documents: z42.array(z42.record(z42.string(), z42.unknown())),
2639
+ references: z42.array(z42.record(z42.string(), z42.unknown())),
2640
+ signals: z42.array(z42.record(z42.string(), z42.unknown())).optional(),
2641
+ transitions: z42.array(z42.record(z42.string(), z42.unknown())).optional()
2642
+ });
2643
+ var ChunkedSearchBodySchema = z42.object({
2644
+ query: z42.string().min(1),
2645
+ maxChunks: z42.number().optional().default(5)
2646
+ });
2647
+
2648
+ // ../types/dist/dashboard.schema.js
2649
+ import { z as z43 } from "zod";
2650
+ var DashboardBoardSummarySchema = z43.object({
2651
+ id: z43.string().uuid(),
2652
+ name: z43.string(),
2653
+ columns: z43.array(z43.object({
2654
+ id: z43.string().uuid(),
2655
+ name: z43.string(),
2656
+ ticket_count: z43.number(),
2657
+ wip_limit: z43.number().nullable()
2658
+ })),
2659
+ total_tickets: z43.number()
2660
+ });
2661
+ var DashboardProjectSchema = z43.object({
2662
+ id: z43.string().uuid(),
2663
+ name: z43.string(),
2664
+ ticket_prefix: z43.string(),
2665
+ boards: z43.array(DashboardBoardSummarySchema),
2666
+ my_tickets: z43.array(z43.object({
2667
+ id: z43.string().uuid(),
2668
+ ticket_number: z43.number(),
2669
+ title: z43.string(),
2670
+ board_name: z43.string(),
2671
+ column_name: z43.string().nullable(),
2672
+ time_in_column: z43.number().nullable(),
2673
+ time_unit: z43.enum(["minutes", "hours", "days"]).default("days")
2674
+ }))
2675
+ });
2676
+ var UserDashboardSchema = z43.object({
2677
+ projects: z43.array(DashboardProjectSchema),
2678
+ urgent: z43.array(z43.object({
2679
+ type: z43.string(),
2680
+ message: z43.string(),
2681
+ ticket_id: z43.string().uuid().optional(),
2682
+ board_id: z43.string().uuid().optional()
2683
+ }))
2684
+ });
2685
+
2686
+ // ../types/dist/github.schema.js
2687
+ import { z as z44 } from "zod";
2688
+ var GithubConnectionSchema = z44.object({
2689
+ id: z44.string().uuid(),
2690
+ user_id: z44.string().uuid(),
2691
+ github_user_id: z44.string(),
2692
+ github_username: z44.string(),
2693
+ scopes: z44.array(z44.string()),
2694
+ created_at: z44.string().datetime({ offset: true })
2695
+ });
2696
+ var ProjectGithubRepoSchema = z44.object({
2697
+ id: z44.string().uuid(),
2698
+ project_id: z44.string().uuid(),
2699
+ github_repo_owner: z44.string(),
2700
+ github_repo_name: z44.string(),
2701
+ github_repo_id: z44.number().int(),
2702
+ connected_by: z44.string().uuid(),
2703
+ webhook_id: z44.number().int().nullable(),
2704
+ created_at: z44.string().datetime({ offset: true }),
2705
+ updated_at: z44.string().datetime({ offset: true })
2706
+ });
2707
+ var ConnectGithubRepoBodySchema = z44.object({
2708
+ repo_owner: z44.string().min(1),
2709
+ repo_name: z44.string().min(1)
2710
+ });
2711
+
2712
+ // ../types/dist/ticket-reference.schema.js
2713
+ import { z as z45 } from "zod";
2714
+ var TicketReferenceProviderSchema = z45.enum(["github"]);
2715
+ var TicketReferenceTypeSchema = z45.enum(["pull_request", "branch", "commit"]);
2716
+ var TicketReferenceStatusSchema = z45.enum(["open", "closed", "merged", "draft", "active", "deleted", "none"]);
2717
+ var TicketReferenceLinkedBySchema = z45.enum(["convention", "manual"]);
2718
+ var TicketReferenceSchema = z45.object({
2719
+ id: z45.string().uuid(),
2720
+ ticket_id: z45.string().uuid(),
2721
+ project_id: z45.string().uuid(),
2722
+ provider: TicketReferenceProviderSchema,
2723
+ type: TicketReferenceTypeSchema,
2724
+ external_id: z45.string(),
2725
+ external_url: z45.string().url(),
2726
+ title: z45.string(),
2727
+ status: TicketReferenceStatusSchema,
2728
+ metadata: z45.record(z45.string(), z45.unknown()).default({}),
2729
+ linked_by: TicketReferenceLinkedBySchema,
2730
+ synced_at: z45.string().datetime({ offset: true }).nullable(),
2731
+ created_at: z45.string().datetime({ offset: true })
2732
+ });
2733
+ var LinkGithubReferenceBodySchema = z45.object({
2734
+ type: TicketReferenceTypeSchema,
2735
+ url: z45.string().url()
2736
+ });
2737
+
2738
+ // ../types/dist/analytics.schema.js
2739
+ import { z as z46 } from "zod";
2740
+ var AnalyticsQuerySchema = z46.object({
2741
+ boardId: z46.string().uuid().optional(),
2742
+ since: z46.string().datetime({ offset: true }).optional(),
2743
+ until: z46.string().datetime({ offset: true }).optional(),
2744
+ assigneeId: z46.string().uuid().optional(),
2745
+ resolution: z46.enum(["auto", "minutes", "hours", "days"]).optional().default("auto")
2746
+ });
2747
+ var VelocityQuerySchema = AnalyticsQuerySchema.extend({
2748
+ weeks: z46.coerce.number().int().min(1).max(52).optional().default(8)
2749
+ });
2750
+ var ForecastQuerySchema = z46.object({
2751
+ boardId: z46.string().uuid().optional(),
2752
+ remainingTickets: z46.coerce.number().int().min(0).optional(),
2753
+ targetDate: z46.string().date().optional()
2754
+ });
2755
+ var EstimationQuerySchema = z46.object({
2756
+ ticketId: z46.string().uuid()
2757
+ });
2758
+ var RetrospectiveQuerySchema = AnalyticsQuerySchema.extend({
2759
+ periodDays: z46.coerce.number().int().min(1).max(365).optional().default(14)
2760
+ });
2761
+ var VelocityWeekSchema = z46.object({
2762
+ week_start: z46.string(),
2763
+ completed: z46.number().int(),
2764
+ avg_cycle_time_value: z46.number().nullable()
2765
+ });
2766
+ var VelocityResponseSchema = z46.object({
2767
+ weeks: z46.array(VelocityWeekSchema),
2768
+ trend: z46.enum(["up", "down", "stable"]),
2769
+ avg_throughput: z46.number(),
2770
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2771
+ });
2772
+ var CycleTimeDataPointSchema = z46.object({
2773
+ ticket_id: z46.string().uuid(),
2774
+ ticket_number: z46.number().int().optional(),
2775
+ title: z46.string().optional(),
2776
+ done_at: z46.string(),
2777
+ cycle_time_value: z46.number()
2778
+ });
2779
+ var CycleTimeResponseSchema = z46.object({
2780
+ data_points: z46.array(CycleTimeDataPointSchema),
2781
+ percentiles: z46.object({
2782
+ p50: z46.number(),
2783
+ p85: z46.number(),
2784
+ p95: z46.number()
2785
+ }),
2786
+ avg_cycle_time_value: z46.number(),
2787
+ total_tickets: z46.number().int(),
2788
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2789
+ });
2790
+ var LeadTimeBucketSchema = z46.object({
2791
+ range_label: z46.string(),
2792
+ min_hours: z46.number(),
2793
+ max_hours: z46.number(),
2794
+ count: z46.number().int()
2795
+ });
2796
+ var LeadTimeResponseSchema = z46.object({
2797
+ buckets: z46.array(LeadTimeBucketSchema),
2798
+ percentiles: z46.object({
2799
+ p50: z46.number(),
2800
+ p85: z46.number(),
2801
+ p95: z46.number()
2802
+ }),
2803
+ avg_lead_time_value: z46.number(),
2804
+ total_tickets: z46.number().int(),
2805
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2806
+ });
2807
+ var CfdColumnDataSchema = z46.object({
2808
+ column_name: z46.string(),
2809
+ count: z46.number().int()
2810
+ });
2811
+ var CfdDateEntrySchema = z46.object({
2812
+ date: z46.string(),
2813
+ columns: z46.array(CfdColumnDataSchema)
2814
+ });
2815
+ var CfdResponseSchema = z46.object({
2816
+ entries: z46.array(CfdDateEntrySchema),
2817
+ column_names: z46.array(z46.string())
2818
+ });
2819
+ var ForecastProbabilitySchema = z46.object({
2820
+ confidence: z46.number(),
2821
+ date: z46.string(),
2822
+ weeks: z46.number()
2823
+ });
2824
+ var ForecastResponseSchema = z46.object({
2825
+ remaining_tickets: z46.number().int(),
2826
+ simulations: z46.number().int(),
2827
+ probabilities: z46.array(ForecastProbabilitySchema),
2828
+ target_date_probability: z46.number().nullable(),
2829
+ weekly_throughput_avg: z46.number(),
2830
+ weekly_throughput_stddev: z46.number(),
2831
+ data_weeks: z46.number().int()
2832
+ });
2833
+ var EstimationResponseSchema = z46.object({
2834
+ ticket_id: z46.string().uuid(),
2835
+ similar_count: z46.number().int(),
2836
+ cycle_time_estimate: z46.object({
2837
+ min: z46.number(),
2838
+ max: z46.number(),
2839
+ avg: z46.number(),
2840
+ median: z46.number(),
2841
+ p85: z46.number()
2842
+ }).nullable(),
2843
+ similar_tickets: z46.array(z46.object({
2844
+ ticket_id: z46.string().uuid(),
2845
+ title: z46.string(),
2846
+ cycle_time_value: z46.number(),
2847
+ keyword_overlap: z46.number().int()
2848
+ })),
2849
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2850
+ });
2851
+ var RetrospectiveInsightsSchema = z46.object({
2852
+ period_days: z46.number().int(),
2853
+ throughput: z46.object({
2854
+ created: z46.number().int(),
2855
+ completed: z46.number().int(),
2856
+ net: z46.number().int()
2857
+ }),
2858
+ bottlenecks: z46.object({
2859
+ high_backward_moves: z46.array(z46.object({
2860
+ ticket_id: z46.string().uuid(),
2861
+ backward_moves: z46.number().int()
2862
+ })),
2863
+ avg_backward_moves: z46.number()
2864
+ }),
2865
+ rework: z46.object({
2866
+ total_backward_moves: z46.number().int(),
2867
+ tickets_with_rework: z46.number().int()
2868
+ }),
2869
+ workload: z46.array(z46.object({
2870
+ assignee_id: z46.string().uuid(),
2871
+ completed: z46.number().int(),
2872
+ avg_cycle_time_value: z46.number().nullable()
2873
+ })),
2874
+ wip: z46.object({
2875
+ current_in_progress: z46.number().int()
2876
+ }),
2877
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2878
+ });
2879
+ var BoardAnalyticsSummarySchema = z46.object({
2880
+ velocity: VelocityResponseSchema,
2881
+ cycle_time: z46.object({
2882
+ avg_value: z46.number(),
2883
+ p85_value: z46.number(),
2884
+ total_completed: z46.number().int(),
2885
+ time_unit: z46.enum(["minutes", "hours", "days"]).default("days")
2886
+ }),
2887
+ wip: z46.object({
2888
+ current: z46.number().int(),
2889
+ limit: z46.number().int().nullable()
2890
+ })
2891
+ });
2892
+
2893
+ // ../types/dist/pipeline-template.schema.js
2894
+ import { z as z47 } from "zod";
2895
+ var PipelineTemplateStepSchema = z47.object({
2896
+ name: z47.string(),
2897
+ tool: z47.string(),
2898
+ description: z47.string(),
2899
+ params: z47.record(z47.string(), z47.unknown()),
2900
+ condition: z47.string().optional(),
2901
+ onError: z47.enum(["stop", "skip", "warn"])
2902
+ });
2903
+ var PipelineTemplateSchema = z47.object({
2904
+ id: z47.string().uuid(),
2905
+ project_id: z47.string().uuid().nullable(),
2906
+ name: z47.string(),
2907
+ display_name: z47.string(),
2908
+ description: z47.string(),
2909
+ steps: z47.array(PipelineTemplateStepSchema),
2910
+ parameters: z47.record(z47.string(), z47.unknown()).default({}),
2911
+ is_builtin: z47.boolean(),
2912
+ created_at: z47.string().datetime({ offset: true }),
2913
+ updated_at: z47.string().datetime({ offset: true })
2914
+ });
2915
+ var CreatePipelineTemplateBodySchema = z47.object({
2916
+ name: z47.string().min(1).max(100),
2917
+ display_name: z47.string().min(1).max(200),
2918
+ description: z47.string().max(2e3),
2919
+ steps: z47.array(PipelineTemplateStepSchema).min(1),
2920
+ parameters: z47.record(z47.string(), z47.unknown()).optional().default({})
2921
+ });
2922
+ var UpdatePipelineTemplateBodySchema = z47.object({
2923
+ name: z47.string().min(1).max(100).optional(),
2924
+ display_name: z47.string().min(1).max(200).optional(),
2925
+ description: z47.string().max(2e3).optional(),
2926
+ steps: z47.array(PipelineTemplateStepSchema).min(1).optional(),
2927
+ parameters: z47.record(z47.string(), z47.unknown()).optional()
2928
+ });
2929
+ var RunPipelineTemplateBodySchema = z47.object({
2930
+ parameters: z47.record(z47.string(), z47.unknown()).optional().default({}),
2931
+ dryRun: z47.boolean().optional().default(true)
2932
+ });
2933
+
2934
+ // ../types/dist/time-unit.js
2935
+ import { z as z48 } from "zod";
2936
+ var TimeUnitSchema = z48.enum(["minutes", "hours", "days"]);
2937
+
2938
+ // ../types/dist/pipeline-analytics.schema.js
2939
+ import { z as z49 } from "zod";
2940
+ var PeriodSchema = z49.object({
2941
+ since: z49.string(),
2942
+ until: z49.string()
2943
+ });
2944
+ var PipelineAnalyticsQuerySchema = z49.object({
2945
+ boardId: z49.string().uuid().optional(),
2946
+ since: z49.string().datetime({ offset: true }).optional(),
2947
+ until: z49.string().datetime({ offset: true }).optional()
2948
+ });
2949
+ var PipelineAnalyticsResolutionQuerySchema = PipelineAnalyticsQuerySchema.extend({
2950
+ resolution: z49.enum(["auto", "minutes", "hours", "days"]).optional()
2951
+ });
2952
+ var RunsQuerySchema = z49.object({
2953
+ boardId: z49.string().uuid().optional(),
2954
+ limit: z49.coerce.number().optional().default(10)
2955
+ });
2956
+ var SessionsQuerySchema = z49.object({
2957
+ boardId: z49.string().uuid().optional(),
2958
+ since: z49.string().datetime({ offset: true }).optional(),
2959
+ limit: z49.coerce.number().optional().default(20)
2960
+ });
2961
+ var AutonomyResponseSchema = z49.object({
2962
+ total_completed: z49.number(),
2963
+ fully_autonomous: z49.number(),
2964
+ human_assisted: z49.number(),
2965
+ human_only: z49.number(),
2966
+ autonomy_rate: z49.number(),
2967
+ period: PeriodSchema
2968
+ });
2969
+ var RunSchema = z49.object({
2970
+ started_at: z49.string(),
2971
+ ended_at: z49.string(),
2972
+ tickets_entered: z49.number(),
2973
+ tickets_completed: z49.number(),
2974
+ tickets_escalated: z49.number(),
2975
+ duration_minutes: z49.number()
2976
+ });
2977
+ var RunsResponseSchema = z49.object({
2978
+ runs: z49.array(RunSchema)
2979
+ });
2980
+ var SessionSchema = z49.object({
2981
+ session_id: z49.string(),
2982
+ started_at: z49.string(),
2983
+ last_activity_at: z49.string(),
2984
+ action_count: z49.number()
2985
+ });
2986
+ var SessionsResponseSchema = z49.object({
2987
+ sessions: z49.array(SessionSchema)
2988
+ });
2989
+ var ThroughputBucketSchema = z49.object({
2990
+ timestamp: z49.string(),
2991
+ autonomous: z49.number(),
2992
+ human_assisted: z49.number(),
2993
+ human_only: z49.number(),
2994
+ escalated: z49.number()
2995
+ });
2996
+ var ThroughputResponseSchema = z49.object({
2997
+ buckets: z49.array(ThroughputBucketSchema),
2998
+ time_unit: TimeUnitSchema,
2999
+ period: PeriodSchema
3000
+ });
3001
+
3002
+ // ../types/dist/ticket-transition.schema.js
3003
+ import { z as z50 } from "zod";
3004
+ var TransitionQuerySchema = z50.object({
3005
+ limit: z50.coerce.number().int().min(1).max(100).default(20)
3006
+ });
3007
+ var TicketTransitionSchema = z50.object({
3008
+ id: z50.string().uuid(),
3009
+ project_id: z50.string().uuid(),
3010
+ board_id: z50.string().uuid(),
3011
+ ticket_id: z50.string().uuid(),
3012
+ from_column: z50.string().uuid().nullable(),
3013
+ to_column: z50.string().uuid(),
3014
+ moved_by: z50.string().uuid().nullable(),
3015
+ handoff: z50.record(z50.string(), z50.unknown()).nullable().default(null),
3016
+ created_at: z50.string().datetime({ offset: true })
3017
+ });
3018
+ var TicketTransitionWithColumnsSchema = TicketTransitionSchema.extend({
3019
+ from_column_name: z50.string().nullable().optional(),
3020
+ to_column_name: z50.string().nullable().optional()
3021
+ });
3022
+
3023
+ // ../types/dist/pipeline-context.schema.js
3024
+ import { z as z51 } from "zod";
3025
+ var AdvisorConfigSchema = z51.object({
3026
+ enabled: z51.boolean(),
3027
+ max_invocations: z51.number().int().positive().optional(),
3028
+ model: z51.string().optional()
3029
+ });
3030
+ var ModelRoutingSchema = z51.object({
3031
+ initial: z51.string(),
3032
+ escalation: z51.array(z51.string()).min(1),
3033
+ escalate_after: z51.number().int().positive().optional()
3034
+ });
3035
+ var StuckDetectionConfigSchema = z51.object({
3036
+ enabled: z51.boolean(),
3037
+ first_check: z51.number().int().positive().optional(),
3038
+ interval: z51.number().int().positive().optional()
3039
+ });
3040
+ var AgentConfigSchema = z51.object({
3041
+ execution_mode: z51.enum(["kant_loop", "cron_poll", "manual"]).optional(),
3042
+ model_preference: z51.string().optional(),
3043
+ max_iterations: z51.number().int().positive().optional(),
3044
+ max_budget_usd: z51.number().positive().nullable().optional(),
3045
+ concurrency: z51.number().int().positive().optional(),
3046
+ gutter_threshold: z51.number().int().positive().optional(),
3047
+ poll_interval_seconds: z51.number().int().positive().optional(),
3048
+ worktree: z51.object({
3049
+ enabled: z51.boolean(),
3050
+ path_pattern: z51.string().optional(),
3051
+ // legacy — still accepted, ignored by orchestrator
3052
+ on_move: z51.enum(["keep", "merge", "cleanup"]).optional(),
3053
+ on_done: z51.enum(["pr", "merge", "cleanup"]).optional(),
3054
+ integration_branch: z51.string().optional()
3055
+ }).optional(),
3056
+ invocation_tier: z51.enum(["auto", "light", "heavy"]).optional(),
3057
+ run_memory: z51.boolean().optional(),
3058
+ lookahead_column_id: z51.string().uuid().optional(),
3059
+ advisor: AdvisorConfigSchema.optional(),
3060
+ checkpoint: z51.boolean().optional(),
3061
+ model_routing: ModelRoutingSchema.optional(),
3062
+ builtin_tools: z51.string().optional(),
3063
+ // Value for --tools flag: space-separated list, '' to strip all
3064
+ allowed_tools: z51.array(z51.string()).optional(),
3065
+ disallowed_tools: z51.array(z51.string()).optional(),
3066
+ stuck_detection: StuckDetectionConfigSchema.optional(),
3067
+ extensions: z51.record(z51.string(), z51.unknown()).optional()
3068
+ }).strict();
3069
+ var TicketFingerprintSchema = z51.object({
3070
+ column_id: z51.string().uuid().nullable(),
3071
+ updated_at: z51.string().datetime({ offset: true }),
3072
+ comment_count: z51.number(),
3073
+ signal_count: z51.number(),
3074
+ field_value_count: z51.number()
3075
+ });
3076
+ var DebtItemSchema = z51.object({
3077
+ type: z51.enum(["dropped_criterion", "missing_test", "missing_functionality", "unmet_requirement", "waived_gate"]),
3078
+ description: z51.string(),
3079
+ severity: z51.enum(["high", "medium", "low"]),
3080
+ source_column: z51.string().optional()
3081
+ });
3082
+ var LoopCheckpointSchema = z51.object({
3083
+ run_id: z51.string().uuid(),
3084
+ column_id: z51.string().uuid(),
3085
+ iteration: z51.number().int().nonnegative(),
3086
+ gutter_count: z51.number().int().nonnegative(),
3087
+ advisor_invocations: z51.number().int().nonnegative(),
3088
+ model_tier: z51.string(),
3089
+ last_fingerprint: TicketFingerprintSchema.optional(),
3090
+ worktree_name: z51.string().optional(),
3091
+ updated_at: z51.string().datetime({ offset: true })
3092
+ });
3093
+ var PipelineContextBoardScopeSchema = z51.object({
3094
+ scope: z51.literal("board"),
3095
+ board: z51.object({
3096
+ id: z51.string().uuid(),
3097
+ name: z51.string()
3098
+ }),
3099
+ backlog_ticket_count: z51.number().int(),
3100
+ columns: z51.array(z51.object({
3101
+ id: z51.string().uuid(),
3102
+ name: z51.string(),
3103
+ type: z51.string(),
3104
+ position: z51.number().int(),
3105
+ wip_limit: z51.number().int().nullable(),
3106
+ goal: z51.string().nullable().optional(),
3107
+ ticket_count: z51.number().int(),
3108
+ has_prompt: z51.boolean(),
3109
+ constraint_count: z51.number().int().nonnegative().optional()
3110
+ })),
3111
+ circuit_breaker: z51.object({
3112
+ threshold: z51.number().int().nullable(),
3113
+ target_column_id: z51.string().uuid().nullable()
3114
+ }).nullable(),
3115
+ tool_prefix: z51.string(),
3116
+ board_constraint_count: z51.number().int().nonnegative().optional()
3117
+ });
3118
+ var PipelineContextColumnScopeSchema = z51.object({
3119
+ scope: z51.literal("column"),
3120
+ column: z51.object({
3121
+ id: z51.string().uuid(),
3122
+ name: z51.string(),
3123
+ goal: z51.string().nullable().optional()
3124
+ }),
3125
+ prompt_document: z51.object({
3126
+ id: z51.string().uuid(),
3127
+ title: z51.string(),
3128
+ content: z51.string()
3129
+ }).nullable().optional(),
3130
+ agent_config: z51.record(z51.string(), z51.unknown()).nullable().optional(),
3131
+ tickets: z51.array(z51.object({
3132
+ id: z51.string().uuid(),
3133
+ ticket_number: z51.number().int(),
3134
+ title: z51.string(),
3135
+ assignee_name: z51.string().nullable(),
3136
+ backward_transitions: z51.number().int().optional()
3137
+ })),
3138
+ transition_rules: z51.string().nullable(),
3139
+ signals: z51.array(z51.string()),
3140
+ field_definitions: z51.array(z51.object({
3141
+ id: z51.string().uuid(),
3142
+ name: z51.string(),
3143
+ type: z51.string()
3144
+ })),
3145
+ tool_prefix: z51.string(),
3146
+ firing_constraints: z51.array(z51.object({
3147
+ id: z51.string().uuid(),
3148
+ name: z51.string(),
3149
+ enabled: z51.boolean(),
3150
+ subject_type: FiringConstraintSubjectTypeSchema,
3151
+ subject_ref: z51.string(),
3152
+ operator: FiringConstraintOperatorSchema,
3153
+ value: z51.unknown(),
3154
+ scope: z51.string(),
3155
+ notify: z51.boolean(),
3156
+ column_id: z51.string().uuid().nullable()
3157
+ })).optional()
3158
+ });
3159
+ var PipelineContextTicketScopeSchema = z51.object({
3160
+ scope: z51.literal("ticket"),
3161
+ ticket: z51.object({
3162
+ id: z51.string().uuid(),
3163
+ ticket_number: z51.number().int(),
3164
+ title: z51.string(),
3165
+ description: z51.string().nullable(),
3166
+ backward_transitions: z51.number().int(),
3167
+ assignee: z51.object({
3168
+ id: z51.string().uuid(),
3169
+ name: z51.string()
3170
+ }).nullable(),
3171
+ column: z51.object({
3172
+ id: z51.string().uuid(),
3173
+ name: z51.string(),
3174
+ type: z51.string()
3175
+ }).nullable()
3176
+ }),
3177
+ field_values: z51.array(z51.object({
3178
+ field_name: z51.string(),
3179
+ value: z51.unknown()
3180
+ })),
3181
+ transitions: z51.array(z51.object({
3182
+ from: z51.string().nullable(),
3183
+ to: z51.string(),
3184
+ handoff: z51.record(z51.string(), z51.unknown()).nullable(),
3185
+ timestamp: z51.string()
3186
+ })),
3187
+ comments: z51.array(z51.object({
3188
+ author: z51.string(),
3189
+ body: z51.string(),
3190
+ created_at: z51.string()
3191
+ })),
3192
+ ticket_links: z51.array(z51.object({
3193
+ direction: z51.enum(["outward", "inward"]),
3194
+ link_type: z51.enum(["blocks", "relates_to", "duplicates"]),
3195
+ ticket_id: z51.string().uuid(),
3196
+ ticket_number: z51.number().int(),
3197
+ title: z51.string(),
3198
+ column_name: z51.string().nullable(),
3199
+ resolved: z51.boolean()
3200
+ })),
3201
+ parent: z51.object({
3202
+ id: z51.string().uuid(),
3203
+ ticket_number: z51.number().int(),
3204
+ title: z51.string()
3205
+ }).nullable(),
3206
+ children: z51.array(z51.object({
3207
+ id: z51.string().uuid(),
3208
+ ticket_number: z51.number().int(),
3209
+ title: z51.string(),
3210
+ column_name: z51.string().nullable()
3211
+ })),
3212
+ signals: z51.array(z51.string()),
3213
+ linked_documents: z51.array(z51.object({
3214
+ id: z51.string().uuid(),
3215
+ title: z51.string(),
3216
+ content: z51.string().optional(),
3217
+ truncated: z51.boolean().optional()
3218
+ })),
3219
+ transition_rules: z51.string().nullable(),
3220
+ dependency_requirements: z51.string(),
3221
+ tool_prefix: z51.string()
3222
+ });
3223
+ var PipelineContextResponseSchema = z51.discriminatedUnion("scope", [
3224
+ PipelineContextBoardScopeSchema,
3225
+ PipelineContextColumnScopeSchema,
3226
+ PipelineContextTicketScopeSchema
3227
+ ]);
3228
+
3229
+ // ../types/dist/gate.schema.js
3230
+ import { z as z52 } from "zod";
3231
+ var GateResultSchema = z52.object({
3232
+ name: z52.string(),
3233
+ passed: z52.boolean(),
3234
+ required: z52.boolean(),
3235
+ duration_ms: z52.number().int().nonnegative(),
3236
+ output: z52.string().max(1048576),
3237
+ stderr: z52.string(),
3238
+ exit_code: z52.number().int().min(0).max(255),
3239
+ timed_out: z52.boolean()
3240
+ });
3241
+ var GateDeltaSchema = z52.enum(["improved", "same", "regressed", "first_check"]);
3242
+ var GateSnapshotSchema = z52.object({
3243
+ timestamp: z52.string().datetime({ offset: true }),
3244
+ iteration: z52.number().int().nonnegative(),
3245
+ results: z52.array(GateResultSchema),
3246
+ all_required_passed: z52.boolean(),
3247
+ delta_from_previous: GateDeltaSchema
3248
+ });
3249
+ var GateDefinitionSchema = z52.object({
3250
+ name: z52.string().min(1),
3251
+ run: z52.string().min(1),
3252
+ required: z52.boolean().default(true),
3253
+ timeout: z52.string().regex(/^\d+(s|m)$/, 'Must be format like "60s" or "5m"').optional()
3254
+ });
3255
+ var ColumnGateOverrideSchema = z52.object({
3256
+ extend: z52.boolean().default(true),
3257
+ gates: z52.array(GateDefinitionSchema).default([])
3258
+ });
3259
+ var BudgetConfigSchema = z52.object({
3260
+ max_input_tokens: z52.number().int().positive(),
3261
+ max_output_tokens: z52.number().int().positive(),
3262
+ warn_pct: z52.number().int().min(1).max(100).default(75)
3263
+ });
3264
+ var PricingEntrySchema = z52.object({
3265
+ input_per_mtok: z52.number().nonnegative(),
3266
+ output_per_mtok: z52.number().nonnegative()
3267
+ });
3268
+ var GateSettingsSchema = z52.object({
3269
+ cwd: z52.string().optional(),
3270
+ env: z52.record(z52.string(), z52.string()).optional(),
3271
+ total_timeout: z52.string().optional(),
3272
+ budget: BudgetConfigSchema.optional(),
3273
+ pricing: z52.record(z52.string(), PricingEntrySchema).optional()
3274
+ });
3275
+ var GateConfigSchema = z52.object({
3276
+ default: z52.array(GateDefinitionSchema),
3277
+ columns: z52.record(z52.string(), ColumnGateOverrideSchema).optional(),
3278
+ settings: GateSettingsSchema.optional()
3279
+ });
3280
+ var VerdictFindingSchema = z52.object({
3281
+ severity: z52.enum(["blocker", "warning", "nit"]),
3282
+ file: z52.string().optional(),
3283
+ line: z52.number().int().positive().optional(),
3284
+ description: z52.string()
3285
+ });
3286
+ var VerdictSchema = z52.object({
3287
+ decision: z52.enum(["approve", "reject"]),
3288
+ summary: z52.string(),
3289
+ findings: z52.array(VerdictFindingSchema)
3290
+ });
3291
+
3292
+ // src/lib/gate-config.ts
3293
+ var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
3294
+ var VALID_BRANCH_RE = /^[a-zA-Z0-9][a-zA-Z0-9._\-/]*$/;
3295
+ function assertNoPrototypePollutionKeys(value, depth = 0) {
3296
+ if (depth > 20 || value === null || typeof value !== "object") return;
3297
+ for (const key of Object.keys(value)) {
3298
+ if (DANGEROUS_KEYS.has(key)) {
3299
+ throw new Error(`Unsafe key "${key}" detected in YAML input`);
3300
+ }
3301
+ assertNoPrototypePollutionKeys(value[key], depth + 1);
3302
+ }
3303
+ }
3304
+ function parseGateConfig(yamlContent) {
3305
+ const raw = load(yamlContent, { schema: JSON_SCHEMA });
3306
+ assertNoPrototypePollutionKeys(raw);
3307
+ return GateConfigSchema.parse(raw);
3308
+ }
3309
+ function resolveGatesForColumn(config, columnName) {
3310
+ const lowerName = columnName.toLowerCase();
3311
+ const overrideKey = config.columns ? Object.keys(config.columns).find((k) => k.toLowerCase() === lowerName) : void 0;
3312
+ const override = overrideKey ? config.columns[overrideKey] : void 0;
3313
+ if (!override) {
3314
+ return [...config.default];
3315
+ }
3316
+ if (!override.extend) {
3317
+ if (override.gates.length === 0) {
3318
+ console.error(` [warn] Column "${columnName}" has extend:false with no gates \u2014 all gate enforcement disabled for this column`);
3319
+ }
3320
+ return [...override.gates];
3321
+ }
3322
+ const overrideNames = new Set(override.gates.map((g) => g.name));
3323
+ const merged = config.default.filter((g) => !overrideNames.has(g.name));
3324
+ return [...merged, ...override.gates];
3325
+ }
3326
+ var DEFAULT_TIMEOUT_MS = 6e4;
3327
+ function parseTimeout(timeout) {
3328
+ if (!timeout) return DEFAULT_TIMEOUT_MS;
3329
+ const match = timeout.match(/^(\d+)(s|m)$/);
3330
+ if (!match) return DEFAULT_TIMEOUT_MS;
3331
+ const value = parseInt(match[1], 10);
3332
+ if (value <= 0) return DEFAULT_TIMEOUT_MS;
3333
+ return match[2] === "m" ? value * 6e4 : value * 1e3;
3334
+ }
3335
+
3336
+ // src/lib/prompt-composer.ts
3337
+ var PROMPT_BUDGETS = {
3338
+ system_preamble: 800,
3339
+ gate_results: 500,
3340
+ column_prompt: Infinity,
3341
+ // NEVER truncated
3342
+ lookahead: 1e3,
3343
+ run_memory: 1e3,
3344
+ rejection: 500,
3345
+ ticket_details: 1500,
3346
+ comments: 2e3,
3347
+ transition_rules: 500,
3348
+ linked_documents: 2e3,
3349
+ metadata: 200
3350
+ };
3351
+ function estimateTokens(text) {
3352
+ return Math.ceil(text.length / 4);
3353
+ }
3354
+ function truncateToTokens(text, maxTokens) {
3355
+ if (maxTokens === Infinity) return text;
3356
+ const maxChars = maxTokens * 4;
3357
+ if (text.length <= maxChars) return text;
3358
+ return text.slice(0, maxChars) + "\n[...truncated]";
3359
+ }
3360
+ function windowComments(comments, maxTokens) {
3361
+ const pinned = comments.filter((c) => c.pinned);
3362
+ const unpinned = comments.filter((c) => !c.pinned);
3363
+ const recentFull = unpinned.slice(-3);
3364
+ const older = unpinned.slice(0, -3);
3365
+ const parts = [];
3366
+ for (const c of pinned) {
3367
+ parts.push(`[pinned] **${c.author}** (${c.created_at}):
3368
+ ${c.body}
3369
+ `);
3370
+ }
3371
+ for (const c of recentFull) {
3372
+ parts.push(`**${c.author}** (${c.created_at}):
3373
+ ${c.body}
3374
+ `);
3375
+ }
3376
+ for (const c of older) {
3377
+ const firstLine = c.body.split("\n")[0]?.slice(0, 100) ?? "";
3378
+ parts.push(`- ${c.author}: ${firstLine}`);
3379
+ }
3380
+ const joined = parts.join("\n");
3381
+ return truncateToTokens(joined, maxTokens);
3382
+ }
3383
+ function composePrompt(columnContext, ticketContext, meta) {
3384
+ const parts = [];
3385
+ if (!columnContext.prompt_document?.content) {
3386
+ throw new Error(
3387
+ `Column "${columnContext.column.name}" has no prompt document. Configure a prompt document for this column before running the pipeline.`
3388
+ );
3389
+ }
3390
+ const hasUnresolvedBlockers = ticketContext.ticket_links.some(
3391
+ (l) => l.direction === "inward" && l.link_type === "blocks" && !l.resolved
3392
+ );
3393
+ parts.push(`# Pipeline Agent Instructions
3394
+
3395
+ You are a pipeline automation agent processing ticket #${String(ticketContext.ticket.ticket_number)}: "${ticketContext.ticket.title}".
3396
+
3397
+ ## Your Goal
3398
+ Advance this ticket through the pipeline. Your success criteria:
3399
+ 1. Complete the work described in the ticket and column prompt below
3400
+ 2. Move the ticket to the next column using \`${ticketContext.tool_prefix}move_ticket\`
3401
+ 3. Or mark it complete using \`${ticketContext.tool_prefix}complete_task\`
3402
+
3403
+ ## Iteration ${meta.iteration} of ${meta.maxIterations}
3404
+ ${meta.iteration >= meta.maxIterations - 1 ? "**FINAL ITERATIONS** \u2014 prioritize moving the ticket NOW or it will be marked stalled." : `You have ${meta.maxIterations - meta.iteration} iterations remaining. Make meaningful progress each iteration.`}
3405
+ ${meta.gutterCount > 0 ? `
3406
+ ## Progress Warning
3407
+ No meaningful progress detected for ${meta.gutterCount} consecutive iteration(s).
3408
+ ${meta.gutterThreshold - meta.gutterCount} iteration(s) remain before this loop is terminated as stalled.
3409
+
3410
+ You MUST change approach. What you've been doing is not working. Consider:
3411
+ - Breaking the problem into smaller steps
3412
+ - Setting a field value to record partial progress
3413
+ - Creating a comment explaining what's blocking you
3414
+ - Asking for help via a signal
3415
+ ` : ""}
3416
+ ## Available Tools (prefix: ${ticketContext.tool_prefix})
3417
+ - **${ticketContext.tool_prefix}check_transition** \u2014 ALWAYS call this before moving. Returns allowed/blocked with recovery steps.
3418
+ Params: \`{ projectId, boardId, ticketId, targetColumnId }\`
3419
+ - **${ticketContext.tool_prefix}move_ticket** \u2014 Move ticket to a new column. Include handoff data for the next agent.
3420
+ Params: \`{ projectId, ticketId, column_id, handoff: { branch?, commit_sha?, build_status?, notes? } }\`
3421
+ - **${ticketContext.tool_prefix}complete_task** \u2014 Move to a done column with handoff data.
3422
+ Params: \`{ projectId, ticketId, handoff: { ... } }\`
3423
+ - **${ticketContext.tool_prefix}set_field_value** \u2014 Set a required field before moving (check transition rules).
3424
+ Params: \`{ projectId, ticketId, fieldId, value }\`
3425
+ - **${ticketContext.tool_prefix}create_signal** \u2014 Leave knowledge for future agents at any scope.
3426
+ - **${ticketContext.tool_prefix}create_comment** \u2014 Add progress notes to the ticket.
3427
+ - **${ticketContext.tool_prefix}append_run_memory** \u2014 Share discoveries with future agents.
3428
+ Params: \`{ section: 'conventions'|'interfaces'|'failures'|'decisions', content: string }\`
3429
+
3430
+ ## Iteration Summary
3431
+ If you made meaningful progress this iteration, create a comment using \`${ticketContext.tool_prefix}create_comment\` summarizing:
3432
+ - What you accomplished
3433
+ - What remains to be done
3434
+ - Any blockers or issues encountered
3435
+
3436
+ This comment is your handoff to the next iteration. Without it, the next iteration starts blind.
3437
+
3438
+ ## Critical Rules
3439
+ 1. **Always call ${ticketContext.tool_prefix}check_transition before ${ticketContext.tool_prefix}move_ticket** \u2014 moves that violate workflow rules will fail.
3440
+ 2. **If the ticket has UNRESOLVED blockers, do not attempt to move it.** Create a comment explaining you are waiting, then stop.
3441
+ 3. **Include handoff data** when moving \u2014 the next agent needs context (branch name, build status, etc.).
3442
+ 4. **If you cannot make progress**, create a comment explaining why and stop. Do not burn iterations.
3443
+ ${hasUnresolvedBlockers ? "\n**WARNING: This ticket has UNRESOLVED blockers. Do NOT attempt to move it. Document your status and stop.**\n" : ""}
3444
+ ---
3445
+ `);
3446
+ const worktreeConfig = columnContext.agent_config?.worktree;
3447
+ if (worktreeConfig?.enabled) {
3448
+ const integrationBranch = worktreeConfig.integration_branch ?? "main";
3449
+ if (!VALID_BRANCH_RE.test(integrationBranch)) {
3450
+ parts.push(`## Git Worktree
3451
+
3452
+ You are working in an isolated git worktree. Integration branch name is invalid \u2014 contact the pipeline operator.`);
3453
+ } else {
3454
+ parts.push(`## Git Worktree
3455
+
3456
+ You are working in an isolated git worktree. Before starting any code changes:
3457
+ 1. Merge \`${integrationBranch}\` into your current branch: \`git merge '${integrationBranch}'\`
3458
+ 2. Resolve any merge conflicts before proceeding with ticket work
3459
+ 3. Never rebase \u2014 always merge (rebase destroys traceability across the pipeline)
3460
+
3461
+ After completing your work, commit all changes to your worktree branch.
3462
+ `);
3463
+ }
3464
+ }
3465
+ if (ticketContext.signals.length > 0) {
3466
+ parts.push(`
3467
+ ## Signals (Guardrails)
3468
+ `);
3469
+ for (const s of ticketContext.signals) {
3470
+ parts.push(`- ${s}`);
3471
+ }
3472
+ }
3473
+ if (meta.gateResults && meta.gateResults.length > 0) {
3474
+ parts.push(`
3475
+ ## Previous Gate Results
3476
+ `);
3477
+ for (const r of meta.gateResults) {
3478
+ const status = r.passed ? "PASS" : "FAIL";
3479
+ const req = r.required ? "(required)" : "(advisory)";
3480
+ parts.push(`- **${r.name}** ${status} ${req} [${String(r.duration_ms)}ms]`);
3481
+ if (!r.passed && r.output) {
3482
+ parts.push(` \`\`\`
3483
+ ${truncateToTokens(r.output, 200)}
3484
+ \`\`\``);
3485
+ }
3486
+ }
3487
+ }
3488
+ if (meta.rejectionFindings) {
3489
+ parts.push(`
3490
+ ## Previous Rejection (fix these before resubmitting)
3491
+ `);
3492
+ parts.push(truncateToTokens(meta.rejectionFindings, PROMPT_BUDGETS.rejection));
3493
+ } else {
3494
+ const rejectionComment = ticketContext.comments.slice().reverse().find((c) => c.body.startsWith("QA REJECTION:") || c.body.startsWith("REJECTION:"));
3495
+ if (rejectionComment) {
3496
+ parts.push(`
3497
+ ## Previous Rejection (fix these before resubmitting)
3498
+ `);
3499
+ parts.push(truncateToTokens(rejectionComment.body, PROMPT_BUDGETS.rejection));
3500
+ }
3501
+ }
3502
+ if (columnContext.prompt_document?.content) {
3503
+ parts.push(columnContext.prompt_document.content);
3504
+ }
3505
+ if (meta.lookaheadDocument?.content) {
3506
+ parts.push(`
3507
+ ## Downstream Criteria (build to pass these)
3508
+ `);
3509
+ parts.push(`*From: ${meta.lookaheadDocument.title}*
3510
+ `);
3511
+ parts.push(truncateToTokens(meta.lookaheadDocument.content, PROMPT_BUDGETS.lookahead));
3512
+ }
3513
+ if (meta.runMemoryContent) {
3514
+ parts.push(`
3515
+ ## Run Memory
3516
+ `);
3517
+ parts.push(truncateToTokens(meta.runMemoryContent, PROMPT_BUDGETS.run_memory));
3518
+ parts.push(`
3519
+ You can contribute to run memory using ${ticketContext.tool_prefix}append_run_memory.`);
3520
+ }
3521
+ parts.push(`## Current Ticket
3522
+ `);
3523
+ parts.push(`**Title:** ${ticketContext.ticket.title}`);
3524
+ parts.push(`**Ticket ID:** ${ticketContext.ticket.id}`);
3525
+ parts.push(`**Ticket Number:** ${String(ticketContext.ticket.ticket_number)}`);
3526
+ if (ticketContext.ticket.description) {
3527
+ parts.push(`
3528
+ ${truncateToTokens(ticketContext.ticket.description, PROMPT_BUDGETS.ticket_details)}`);
3529
+ }
3530
+ if (ticketContext.ticket.assignee) {
3531
+ parts.push(`**Assignee:** ${ticketContext.ticket.assignee.name}`);
3532
+ }
3533
+ if (ticketContext.ticket.column) {
3534
+ parts.push(`**Current Column:** ${ticketContext.ticket.column.name} (${ticketContext.ticket.column.type})`);
3535
+ }
3536
+ if (ticketContext.ticket.backward_transitions > 0) {
3537
+ parts.push(`**Backward Transitions:** ${String(ticketContext.ticket.backward_transitions)}`);
3538
+ }
3539
+ if (ticketContext.field_values.length > 0) {
3540
+ parts.push(`
3541
+ ## Field Values
3542
+ `);
3543
+ for (const fv of ticketContext.field_values) {
3544
+ parts.push(`- **${fv.field_name}:** ${fv.value !== null ? JSON.stringify(fv.value) : "(not set)"}`);
3545
+ }
3546
+ }
3547
+ if (ticketContext.parent) {
3548
+ parts.push(`
3549
+ ## Parent Ticket
3550
+ `);
3551
+ parts.push(`- #${String(ticketContext.parent.ticket_number)}: ${ticketContext.parent.title}`);
3552
+ }
3553
+ if (ticketContext.children.length > 0) {
3554
+ parts.push(`
3555
+ ## Child Tickets
3556
+ `);
3557
+ for (const child of ticketContext.children) {
3558
+ parts.push(`- #${String(child.ticket_number)}: ${child.title}${child.column_name ? ` (${child.column_name})` : ""}`);
3559
+ }
3560
+ }
3561
+ if (ticketContext.transitions.length > 0) {
3562
+ parts.push(`
3563
+ ## Transition History
3564
+ `);
3565
+ let transitionTokens = 0;
3566
+ const TRANSITION_BUDGET = 1e3;
3567
+ for (const t of ticketContext.transitions) {
3568
+ let line = `- ${t.from ?? "Backlog"} \u2192 ${t.to}`;
3569
+ if (t.handoff) line += ` (handoff: ${JSON.stringify(t.handoff)})`;
3570
+ const lineTokens = estimateTokens(line);
3571
+ if (transitionTokens + lineTokens > TRANSITION_BUDGET) {
3572
+ parts.push(`- [...truncated \u2014 ${String(ticketContext.transitions.length)} total transitions]`);
3573
+ break;
3574
+ }
3575
+ parts.push(line);
3576
+ transitionTokens += lineTokens;
3577
+ }
3578
+ }
3579
+ if (ticketContext.ticket_links.length > 0) {
3580
+ parts.push(`
3581
+ ## Ticket Links
3582
+ `);
3583
+ const blockers = ticketContext.ticket_links.filter((l) => l.direction === "inward" && l.link_type === "blocks");
3584
+ const blocking = ticketContext.ticket_links.filter((l) => l.direction === "outward" && l.link_type === "blocks");
3585
+ const related = ticketContext.ticket_links.filter((l) => l.link_type === "relates_to");
3586
+ if (blockers.length > 0) {
3587
+ parts.push(`**Blocked by:**`);
3588
+ for (const l of blockers) {
3589
+ const status = l.resolved ? "(resolved)" : "UNRESOLVED";
3590
+ parts.push(`- #${String(l.ticket_number)}: ${l.title} [${l.column_name ?? "backlog"}] ${status}`);
3591
+ }
3592
+ }
3593
+ if (blocking.length > 0) {
3594
+ parts.push(`**Blocks:**`);
3595
+ for (const l of blocking) {
3596
+ parts.push(`- #${String(l.ticket_number)}: ${l.title} [${l.column_name ?? "backlog"}]`);
3597
+ }
3598
+ }
3599
+ if (related.length > 0) {
3600
+ parts.push(`**Related:**`);
3601
+ for (const l of related) {
3602
+ parts.push(`- #${String(l.ticket_number)}: ${l.title}`);
3603
+ }
3604
+ }
3605
+ }
3606
+ if (ticketContext.comments.length > 0) {
3607
+ parts.push(`
3608
+ ## Comments
3609
+ `);
3610
+ parts.push(windowComments(ticketContext.comments, PROMPT_BUDGETS.comments));
3611
+ }
3612
+ if (ticketContext.transition_rules) {
3613
+ parts.push(`
3614
+ ## Transition Rules
3615
+ `);
3616
+ parts.push(truncateToTokens(ticketContext.transition_rules, PROMPT_BUDGETS.transition_rules));
3617
+ }
3618
+ if (ticketContext.dependency_requirements && ticketContext.dependency_requirements !== "No dependency or field requirements configured.") {
3619
+ parts.push(`
3620
+ ## Dependency & Field Requirements
3621
+ `);
3622
+ parts.push(ticketContext.dependency_requirements);
3623
+ }
3624
+ if (ticketContext.linked_documents.length > 0) {
3625
+ parts.push(`
3626
+ ## Linked Documents
3627
+ `);
3628
+ let remainingTokens = PROMPT_BUDGETS.linked_documents;
3629
+ for (const doc of ticketContext.linked_documents) {
3630
+ if (doc.content) {
3631
+ const docHeader = `### ${doc.title}
3632
+ `;
3633
+ const headerTokens = estimateTokens(docHeader);
3634
+ const contentTokens = estimateTokens(doc.content);
3635
+ if (headerTokens + contentTokens <= remainingTokens) {
3636
+ parts.push(docHeader);
3637
+ parts.push(doc.content);
3638
+ remainingTokens -= headerTokens + contentTokens;
3639
+ } else if (remainingTokens > headerTokens + 50) {
3640
+ parts.push(docHeader);
3641
+ parts.push(truncateToTokens(doc.content, remainingTokens - headerTokens));
3642
+ remainingTokens = 0;
3643
+ } else {
3644
+ parts.push(`- ${doc.title} (truncated \u2014 token budget exceeded)`);
3645
+ remainingTokens = 0;
3646
+ }
3647
+ } else if (doc.truncated) {
3648
+ parts.push(`- ${doc.title} (document too large \u2014 read via kantban_get_document)`);
3649
+ }
3650
+ if (remainingTokens <= 0) break;
3651
+ }
3652
+ }
3653
+ parts.push(`
3654
+ ## Pipeline Metadata
3655
+ `);
3656
+ parts.push(`- Iteration: ${meta.iteration} / ${meta.maxIterations}`);
3657
+ parts.push(`- Project ID: ${meta.projectId}`);
3658
+ parts.push(`- Tool Prefix: ${ticketContext.tool_prefix}`);
3659
+ parts.push(`- Column: ${columnContext.column.name}`);
3660
+ parts.push(`- Goal: ${columnContext.column.goal ?? "No goal set"}`);
3661
+ return parts.join("\n");
3662
+ }
3663
+
3664
+ // src/lib/ralph-loop.ts
3665
+ var API_TIMEOUT_MS = 3e4;
3666
+ function withTimeout(promise, ms, label) {
3667
+ let timer;
3668
+ return Promise.race([
3669
+ promise.finally(() => clearTimeout(timer)),
3670
+ new Promise((_, reject) => {
3671
+ timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
3672
+ })
3673
+ ]);
3674
+ }
3675
+ var RalphLoop = class {
3676
+ ticketId;
3677
+ columnId;
3678
+ config;
3679
+ deps;
3680
+ stopped = false;
3681
+ currentIteration = 0;
3682
+ constructor(ticketId, columnId, config, deps) {
3683
+ this.ticketId = ticketId;
3684
+ this.columnId = columnId;
3685
+ this.config = config;
3686
+ this.deps = deps;
3687
+ }
3688
+ stop() {
3689
+ this.stopped = true;
3690
+ }
3691
+ get iteration() {
3692
+ return this.currentIteration;
3693
+ }
3694
+ looksLike404(err) {
3695
+ const statusCode = err?.statusCode ?? err?.status;
3696
+ if (statusCode === 404) return true;
3697
+ const message = err instanceof Error ? err.message : String(err);
3698
+ return message.includes("API error 404");
3699
+ }
3700
+ async run() {
3701
+ let gutterCount = this.config.startGutterCount ?? 0;
3702
+ let lastFingerprint = this.config.startFingerprint ?? null;
3703
+ const log = this.deps.log ?? (() => {
3704
+ });
3705
+ const resolvedModel = this.config.model ?? "default";
3706
+ const gateSnapshots = [];
3707
+ let cumulativeTokensIn = 0;
3708
+ let cumulativeTokensOut = 0;
3709
+ let cumulativeToolCalls = 0;
3710
+ let cumulativeDurationMs = 0;
3711
+ const withCosts = (r) => ({
3712
+ ...r,
3713
+ tokensIn: cumulativeTokensIn,
3714
+ tokensOut: cumulativeTokensOut,
3715
+ toolCallCount: cumulativeToolCalls,
3716
+ durationMs: cumulativeDurationMs
3717
+ });
3718
+ let lastOutput = "";
3719
+ const startIter = this.config.startIteration ?? 1;
3720
+ for (let i = startIter; i <= this.config.maxIterations; i++) {
3721
+ if (this.stopped) return withCosts({ reason: "stopped", iterations: i - 1, gutterCount, model: resolvedModel });
3722
+ this.currentIteration = i;
3723
+ log(`Iteration ${i}/${this.config.maxIterations} starting`);
3724
+ if (!lastFingerprint) {
3725
+ try {
3726
+ lastFingerprint = await withTimeout(
3727
+ this.deps.fetchFingerprint(this.ticketId),
3728
+ API_TIMEOUT_MS,
3729
+ "fetchFingerprint (baseline)"
3730
+ );
3731
+ } catch (err) {
3732
+ const message = err instanceof Error ? err.message : String(err);
3733
+ log(`Baseline fingerprint fetch failed: ${message}`);
3734
+ if (this.looksLike404(err)) {
3735
+ return withCosts({ reason: "deleted", iterations: i, gutterCount, model: resolvedModel });
3736
+ }
3737
+ return withCosts({ reason: "error", iterations: i, gutterCount, lastError: `Baseline fingerprint failed: ${message}`, model: resolvedModel });
3738
+ }
3739
+ }
3740
+ let ticketCtx;
3741
+ let columnCtx;
3742
+ try {
3743
+ [ticketCtx, columnCtx] = await Promise.all([
3744
+ withTimeout(this.deps.fetchTicketContext(this.ticketId), API_TIMEOUT_MS, "fetchTicketContext"),
3745
+ withTimeout(this.deps.fetchColumnContext(this.columnId), API_TIMEOUT_MS, "fetchColumnContext")
3746
+ ]);
3747
+ } catch (err) {
3748
+ const message = err instanceof Error ? err.message : String(err);
3749
+ log(`Context fetch failed: ${message}`);
3750
+ if (this.looksLike404(err)) {
3751
+ return withCosts({ reason: "deleted", iterations: i, gutterCount, model: resolvedModel });
3752
+ }
3753
+ return withCosts({ reason: "error", iterations: i, gutterCount, lastError: `Context fetch failed: ${message}`, model: resolvedModel });
3754
+ }
3755
+ if (ticketCtx.ticket.column && ticketCtx.ticket.column.id !== this.columnId) {
3756
+ log(`Ticket already in column ${ticketCtx.ticket.column.name}, not ${this.columnId} \u2014 exiting as moved`);
3757
+ return withCosts({ reason: "moved", iterations: i - 1, gutterCount, model: resolvedModel });
3758
+ }
3759
+ const runMemoryContent = this.deps.fetchRunMemoryContent ? await this.deps.fetchRunMemoryContent().catch(() => "") : void 0;
3760
+ const lookaheadDocument = this.deps.fetchLookaheadDocument ? await this.deps.fetchLookaheadDocument().catch(() => void 0) : void 0;
3761
+ let prompt;
3762
+ try {
3763
+ prompt = composePrompt(columnCtx, ticketCtx, {
3764
+ iteration: i,
3765
+ maxIterations: this.config.maxIterations,
3766
+ projectId: this.deps.projectId,
3767
+ gutterCount,
3768
+ gutterThreshold: this.config.gutterThreshold,
3769
+ runMemoryContent: runMemoryContent || void 0,
3770
+ lookaheadDocument
3771
+ });
3772
+ } catch (err) {
3773
+ const message = err instanceof Error ? err.message : String(err);
3774
+ log(`Prompt composition failed: ${message}`);
3775
+ return withCosts({ reason: "error", iterations: i, gutterCount, lastError: `Prompt composition failed: ${message}`, model: resolvedModel });
3776
+ }
3777
+ if (this.stopped) return withCosts({ reason: "stopped", iterations: i - 1, gutterCount, model: resolvedModel });
3778
+ log(`Invoking Claude (model=${this.config.model ?? "default"})`);
3779
+ const iterationRunId = `${this.config.runId ?? this.ticketId}-iter-${String(i)}`;
3780
+ const iterationStart = Date.now();
3781
+ this.deps.onSessionStart?.({
3782
+ runId: iterationRunId,
3783
+ model: this.config.model ?? "default",
3784
+ iteration: i
3785
+ });
3786
+ const streamContext = { runId: iterationRunId, ticketId: this.ticketId, columnId: this.columnId };
3787
+ const { exitCode, output, toolCallCount, tokensIn, tokensOut } = await this.deps.invokeClaudeP(prompt, {
3788
+ mcpConfigPath: this.deps.mcpConfigPath,
3789
+ model: this.config.model,
3790
+ maxBudgetUsd: this.config.maxBudgetUsd,
3791
+ worktree: this.config.worktreeName,
3792
+ onStreamEvent: (event) => this.deps.onStreamEvent?.(event, streamContext),
3793
+ // Tool scoping
3794
+ ...this.config.toolRestrictions && {
3795
+ tools: this.config.toolRestrictions.tools,
3796
+ allowedTools: this.config.toolRestrictions.allowedTools,
3797
+ disallowedTools: this.config.toolRestrictions.disallowedTools,
3798
+ includeMcpConfig: this.config.toolRestrictions.includeMcpConfig
3799
+ }
3800
+ });
3801
+ const iterationDurationMs = Date.now() - iterationStart;
3802
+ cumulativeTokensIn += tokensIn;
3803
+ cumulativeTokensOut += tokensOut;
3804
+ cumulativeToolCalls += toolCallCount;
3805
+ cumulativeDurationMs += iterationDurationMs;
3806
+ this.deps.onSessionEnd?.({
3807
+ runId: iterationRunId,
3808
+ exitCode,
3809
+ tokensIn,
3810
+ tokensOut,
3811
+ toolCallCount,
3812
+ durationMs: iterationDurationMs
3813
+ });
3814
+ if (exitCode !== 0) {
3815
+ const snippet = output.slice(-200);
3816
+ log(`Claude exited with code ${exitCode}: ${snippet}`);
3817
+ return withCosts({ reason: "error", iterations: i, gutterCount, lastError: `non-zero exit code: ${exitCode}. Last output: ${snippet}`, model: resolvedModel });
3818
+ }
3819
+ log(`Claude exited successfully`);
3820
+ lastOutput = output;
3821
+ let afterFp;
3822
+ try {
3823
+ const retryDelayMs = this.config.postMoveRetryDelayMs ?? 1500;
3824
+ afterFp = await withTimeout(
3825
+ this.deps.fetchFingerprint(this.ticketId),
3826
+ API_TIMEOUT_MS,
3827
+ "fetchFingerprint (post-iteration)"
3828
+ );
3829
+ if (afterFp.column_id === this.columnId) {
3830
+ for (let retry = 0; retry < 2; retry++) {
3831
+ await new Promise((r) => setTimeout(r, retryDelayMs));
3832
+ if (this.stopped) break;
3833
+ try {
3834
+ afterFp = await withTimeout(
3835
+ this.deps.fetchFingerprint(this.ticketId),
3836
+ API_TIMEOUT_MS,
3837
+ "fetchFingerprint (retry)"
3838
+ );
3839
+ } catch (err) {
3840
+ log(`Fingerprint retry ${retry + 1} failed: ${err instanceof Error ? err.message : String(err)} \u2014 using last good value`);
3841
+ break;
3842
+ }
3843
+ if (afterFp.column_id !== this.columnId) break;
3844
+ }
3845
+ }
3846
+ } catch (err) {
3847
+ const message = err instanceof Error ? err.message : String(err);
3848
+ log(`Post-iteration fingerprint failed: ${message}`);
3849
+ if (this.looksLike404(err)) {
3850
+ return withCosts({ reason: "deleted", iterations: i, gutterCount, model: resolvedModel });
3851
+ }
3852
+ return withCosts({ reason: "error", iterations: i, gutterCount, lastError: `Post-iteration fingerprint failed: ${message}`, model: resolvedModel });
3853
+ }
3854
+ if (afterFp.column_id !== this.columnId) {
3855
+ log(`Ticket moved to column ${afterFp.column_id ?? "null"}`);
3856
+ return withCosts({ reason: "moved", iterations: i, gutterCount, model: resolvedModel, output: lastOutput });
3857
+ }
3858
+ if (this.config.onPostIterationGates) {
3859
+ try {
3860
+ const snapshot = await this.config.onPostIterationGates(this.ticketId, i);
3861
+ gateSnapshots.push(snapshot);
3862
+ const fieldDelta = lastFingerprint ? afterFp.field_value_count !== lastFingerprint.field_value_count : false;
3863
+ switch (snapshot.delta_from_previous) {
3864
+ case "improved":
3865
+ if (gutterCount > 0) log(`Gate improvement detected \u2014 gutter counter reset`);
3866
+ gutterCount = 0;
3867
+ break;
3868
+ case "same":
3869
+ if (!fieldDelta) {
3870
+ gutterCount++;
3871
+ log(`No gate progress (gutter ${gutterCount}/${this.config.gutterThreshold})`);
3872
+ } else {
3873
+ log(`Gates unchanged but fields changed \u2014 not incrementing gutter`);
3874
+ }
3875
+ break;
3876
+ case "regressed":
3877
+ gutterCount += 2;
3878
+ log(`Gate regression detected (gutter ${gutterCount}/${this.config.gutterThreshold})`);
3879
+ break;
3880
+ case "first_check":
3881
+ break;
3882
+ }
3883
+ } catch (err) {
3884
+ const message = err instanceof Error ? err.message : String(err);
3885
+ log(`Post-iteration gate check failed (non-blocking): ${message}`);
3886
+ if (lastFingerprint && fingerprintsMatch(lastFingerprint, afterFp)) {
3887
+ gutterCount++;
3888
+ log(`No progress detected via fingerprint fallback (gutter ${gutterCount}/${this.config.gutterThreshold})`);
3889
+ } else {
3890
+ if (gutterCount > 0) log(`Progress detected \u2014 gutter counter reset`);
3891
+ gutterCount = 0;
3892
+ }
3893
+ }
3894
+ } else {
3895
+ if (lastFingerprint && fingerprintsMatch(lastFingerprint, afterFp)) {
3896
+ gutterCount++;
3897
+ log(`No progress detected (gutter ${gutterCount}/${this.config.gutterThreshold})`);
3898
+ } else {
3899
+ if (gutterCount > 0) log(`Progress detected \u2014 gutter counter reset`);
3900
+ gutterCount = 0;
3901
+ }
3902
+ }
3903
+ lastFingerprint = afterFp;
3904
+ if (this.config.stuckDetection && shouldCheckStuckDetection(this.config.stuckDetection, i)) {
3905
+ try {
3906
+ let sdStatus;
3907
+ let sdEvidence;
3908
+ let sdConfidence;
3909
+ if (gateSnapshots.length > 0) {
3910
+ const trajectory = classifyTrajectory(gateSnapshots);
3911
+ sdStatus = trajectory.status === "regressing" ? "spinning" : trajectory.status;
3912
+ sdEvidence = trajectory.evidence;
3913
+ sdConfidence = trajectory.confidence;
3914
+ log(`Gate-based stuck detection: ${sdStatus} (confidence=${String(sdConfidence)}) \u2014 ${sdEvidence}`);
3915
+ } else if (this.config.invokeStuckDetection) {
3916
+ const sdInput = {
3917
+ ticketNumber: ticketCtx.ticket.ticket_number,
3918
+ ticketTitle: ticketCtx.ticket.title,
3919
+ columnName: columnCtx.column.name,
3920
+ iteration: i,
3921
+ maxIterations: this.config.maxIterations,
3922
+ recentComments: ticketCtx.comments.slice(-3).map((c) => ({
3923
+ author: c.author,
3924
+ body: c.body
3925
+ }))
3926
+ };
3927
+ const sdResult = await this.config.invokeStuckDetection(sdInput);
3928
+ sdStatus = sdResult.status;
3929
+ sdEvidence = sdResult.evidence;
3930
+ sdConfidence = sdResult.confidence;
3931
+ log(`Stuck detection: ${sdStatus} (confidence=${String(sdConfidence)}) \u2014 ${sdEvidence}`);
3932
+ } else {
3933
+ sdStatus = "progressing";
3934
+ sdEvidence = "no detection method";
3935
+ sdConfidence = 0;
3936
+ }
3937
+ switch (sdStatus) {
3938
+ case "progressing":
3939
+ if (gutterCount > 0) {
3940
+ log(`Stuck detection override: resetting gutter counter (was ${String(gutterCount)})`);
3941
+ gutterCount = 0;
3942
+ }
3943
+ break;
3944
+ case "spinning":
3945
+ gutterCount += 2;
3946
+ log(`Stuck detection: spinning \u2014 gutter accelerated to ${String(gutterCount)}/${String(this.config.gutterThreshold)}`);
3947
+ break;
3948
+ case "blocked":
3949
+ log(`Stuck detection: blocked \u2014 exiting immediately`);
3950
+ return withCosts({
3951
+ reason: "stalled",
3952
+ iterations: i,
3953
+ gutterCount: this.config.gutterThreshold,
3954
+ model: resolvedModel,
3955
+ output: lastOutput,
3956
+ ...gateSnapshots.length > 0 && { finalGateSnapshot: gateSnapshots[gateSnapshots.length - 1] }
3957
+ });
3958
+ }
3959
+ } catch (err) {
3960
+ const message = err instanceof Error ? err.message : String(err);
3961
+ log(`Stuck detection failed (non-blocking): ${message}`);
3962
+ }
3963
+ }
3964
+ if (gutterCount >= this.config.gutterThreshold) {
3965
+ return withCosts({
3966
+ reason: "stalled",
3967
+ iterations: i,
3968
+ gutterCount,
3969
+ model: resolvedModel,
3970
+ output: lastOutput,
3971
+ ...gateSnapshots.length > 0 && { finalGateSnapshot: gateSnapshots[gateSnapshots.length - 1] }
3972
+ });
3973
+ }
3974
+ if (this.config.onCheckpoint) {
3975
+ try {
3976
+ await this.config.onCheckpoint(this.ticketId, {
3977
+ run_id: this.config.runId ?? "00000000-0000-0000-0000-000000000000",
3978
+ column_id: this.columnId,
3979
+ iteration: i,
3980
+ gutter_count: gutterCount,
3981
+ advisor_invocations: 0,
3982
+ // tracked by orchestrator, not loop
3983
+ model_tier: resolvedModel,
3984
+ last_fingerprint: afterFp,
3985
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
3986
+ worktree_name: this.config.worktreeName
3987
+ });
3988
+ } catch (err) {
3989
+ log(`Checkpoint write failed (non-blocking): ${err instanceof Error ? err.message : String(err)}`);
3990
+ }
3991
+ }
3992
+ }
3993
+ return withCosts({
3994
+ reason: "max_iterations",
3995
+ iterations: this.config.maxIterations,
3996
+ gutterCount,
3997
+ model: resolvedModel,
3998
+ output: lastOutput,
3999
+ ...gateSnapshots.length > 0 && { finalGateSnapshot: gateSnapshots[gateSnapshots.length - 1] }
4000
+ });
4001
+ }
4002
+ };
4003
+ function fingerprintsMatch(a, b) {
4004
+ return a.column_id === b.column_id && a.field_value_count === b.field_value_count && a.comment_count === b.comment_count;
4005
+ }
4006
+
4007
+ // src/lib/mcp-config.ts
4008
+ import { writeFileSync, unlinkSync, mkdirSync, existsSync, readdirSync } from "fs";
4009
+ import { join, dirname } from "path";
4010
+ import { fileURLToPath } from "url";
4011
+ import { homedir } from "os";
4012
+ var __filename = fileURLToPath(import.meta.url);
4013
+ var __dirname = dirname(__filename);
4014
+ function generateMcpConfig(apiUrl, apiToken, boardId) {
4015
+ const localMcpPath = join(__dirname, "..", "..", "..", "mcp", "dist", "index.js");
4016
+ const useLocal = existsSync(localMcpPath);
4017
+ const kantbanServer = useLocal ? {
4018
+ command: "node",
4019
+ args: [localMcpPath],
4020
+ env: {
4021
+ KANTBAN_API_TOKEN: apiToken,
4022
+ KANTBAN_API_URL: apiUrl
4023
+ }
4024
+ } : {
4025
+ command: "npx",
4026
+ args: ["-y", "kantban-mcp@latest"],
4027
+ env: {
4028
+ KANTBAN_API_TOKEN: apiToken,
4029
+ KANTBAN_API_URL: apiUrl
4030
+ }
4031
+ };
4032
+ const config = {
4033
+ mcpServers: {
4034
+ kantban: kantbanServer
4035
+ }
4036
+ };
4037
+ const dir = join(homedir(), ".kantban", "pipelines", boardId);
4038
+ mkdirSync(dir, { recursive: true, mode: 448 });
4039
+ const filePath = join(dir, "mcp-config.json");
4040
+ writeFileSync(filePath, JSON.stringify(config, null, 2), { mode: 384 });
4041
+ return filePath;
4042
+ }
4043
+ function cleanupMcpConfig(filePath) {
4044
+ try {
4045
+ if (existsSync(filePath)) {
4046
+ unlinkSync(filePath);
4047
+ }
4048
+ } catch {
4049
+ }
4050
+ }
4051
+ function generateGateProxyMcpConfig(apiUrl, apiToken, boardId, gateConfigPath, columnId, columnName, projectId) {
4052
+ const localMcpPath = join(__dirname, "..", "..", "..", "mcp", "dist", "index.js");
4053
+ const useLocal = existsSync(localMcpPath);
4054
+ const kantbanServer = useLocal ? { command: "node", args: [localMcpPath], env: { KANTBAN_API_TOKEN: apiToken, KANTBAN_API_URL: apiUrl } } : { command: "npx", args: ["-y", "kantban-mcp@latest"], env: { KANTBAN_API_TOKEN: apiToken, KANTBAN_API_URL: apiUrl } };
4055
+ const gateProxyPath = join(__dirname, "gate-proxy-server.js");
4056
+ const gateProxyServer = {
4057
+ command: "node",
4058
+ args: [gateProxyPath],
4059
+ env: {
4060
+ GATE_CONFIG_PATH: gateConfigPath,
4061
+ COLUMN_ID: columnId,
4062
+ COLUMN_NAME: columnName,
4063
+ PROJECT_ID: projectId,
4064
+ KANTBAN_API_TOKEN: apiToken,
4065
+ KANTBAN_API_URL: apiUrl
4066
+ }
4067
+ };
4068
+ const config = {
4069
+ mcpServers: {
4070
+ kantban: kantbanServer,
4071
+ "kantban-gates": gateProxyServer
4072
+ }
4073
+ };
4074
+ const dir = join(homedir(), ".kantban", "pipelines", boardId);
4075
+ mkdirSync(dir, { recursive: true, mode: 448 });
4076
+ const filePath = join(dir, `mcp-config-${columnId}.json`);
4077
+ writeFileSync(filePath, JSON.stringify(config, null, 2), { mode: 384 });
4078
+ return filePath;
4079
+ }
4080
+ function cleanupGateProxyConfigs(pipelineDir) {
4081
+ try {
4082
+ const files = readdirSync(pipelineDir);
4083
+ for (const f of files) {
4084
+ if (f.startsWith("mcp-config-") && f.endsWith(".json")) {
4085
+ try {
4086
+ unlinkSync(join(pipelineDir, f));
4087
+ } catch {
4088
+ }
4089
+ }
4090
+ }
4091
+ } catch {
4092
+ }
4093
+ }
4094
+
4095
+ export {
4096
+ parseJsonFromLlmOutput,
4097
+ composeStuckDetectionPrompt,
4098
+ parseStuckDetectionResponse,
4099
+ classifyTrajectory,
4100
+ LoopCheckpointSchema,
4101
+ VerdictSchema,
4102
+ parseGateConfig,
4103
+ resolveGatesForColumn,
4104
+ parseTimeout,
4105
+ RalphLoop,
4106
+ generateMcpConfig,
4107
+ cleanupMcpConfig,
4108
+ generateGateProxyMcpConfig,
4109
+ cleanupGateProxyConfigs
4110
+ };
4111
+ //# sourceMappingURL=chunk-ZCUIGFSP.js.map