kantban-cli 0.1.14 → 0.1.16

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