glimmervoid 0.0.0-stage → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +197 -2
  3. package/dist/bin/glimmervoid.js +259 -0
  4. package/dist/chunks/adapters-DIavI9-i.js +2 -0
  5. package/dist/chunks/adapters-Dlvu1FVB.js +566 -0
  6. package/dist/chunks/agent-api-cli-ClOzm28U.js +71 -0
  7. package/dist/chunks/agent-api-core-D6LHrpSL.js +103 -0
  8. package/dist/chunks/agent-setup-cli-C1CQ8Nkk.js +137 -0
  9. package/dist/chunks/ascii-figure-core-pDAwtlKO.js +45 -0
  10. package/dist/chunks/child-process-safe-Cz22RwlG.js +69 -0
  11. package/dist/chunks/config-path-core-DFt-TemS.js +38 -0
  12. package/dist/chunks/config-store-DtPUFVaO.js +1400 -0
  13. package/dist/chunks/config-store-DtUGwi4-.js +2 -0
  14. package/dist/chunks/contracts-JKChPhZ0.js +2998 -0
  15. package/dist/chunks/grok-COekzawt.js +407 -0
  16. package/dist/chunks/hook-relay-core-BHfYFnYV.js +88 -0
  17. package/dist/chunks/ingest-core-DWI1Mbu4.js +342 -0
  18. package/dist/chunks/ingest-editor-core-BuI1gMF_.js +445 -0
  19. package/dist/chunks/loopback-post-C7C22eYi.js +79 -0
  20. package/dist/chunks/main-BVDjy7vH.js +42740 -0
  21. package/dist/chunks/node-pty-preflight-CK1knGIR.js +162 -0
  22. package/dist/chunks/pair-cli-BQQnhkkc.js +110 -0
  23. package/dist/chunks/path-doctor-C23VAqeu.js +63 -0
  24. package/dist/chunks/refocus-core-BKQKllq7.js +38 -0
  25. package/dist/chunks/relay-stdin-CpHvLu6M.js +20 -0
  26. package/dist/chunks/remote-config-BHoDFCpo.js +521 -0
  27. package/dist/chunks/rtk-hook-core-DRYrKwYP.js +26 -0
  28. package/dist/chunks/rtk-resolver-DDVVNRBT.js +2 -0
  29. package/dist/chunks/rtk-resolver-oGmO-ew7.js +58 -0
  30. package/dist/chunks/runtime-paths-CVvq20A4.js +51 -0
  31. package/dist/chunks/sandbox-deps-BwvbDBDl.js +67 -0
  32. package/dist/chunks/session-CJtOveHl.js +162 -0
  33. package/dist/chunks/spawn-command-Cc40FiZI.js +134 -0
  34. package/dist/chunks/visions-cli-DUZnopGY.js +98 -0
  35. package/dist/chunks/visions-setup-C_kJobsy.js +1753 -0
  36. package/dist/client/assets/favicon-CKygeLwW.svg +7 -0
  37. package/dist/client/assets/index-BTwYgSAH.js +248 -0
  38. package/dist/client/assets/index-DgA708PE.css +1 -0
  39. package/dist/client/index.html +108 -0
  40. package/dist/package.json +3 -0
  41. package/dist/scripts/postinstall-path-check.js +36 -0
  42. package/dist/server/index.js +92 -0
  43. package/dist/session/command-hook-relay.js +16 -0
  44. package/dist/session/hook-relay.js +24 -0
  45. package/dist/session/rtk-relay.js +90 -0
  46. package/dist/session/statusline-relay.js +82 -0
  47. package/dist/session/visions-relay.js +627 -0
  48. package/dist/tools/vscode-visions/extension.js +289 -0
  49. package/dist/tools/vscode-visions/lsp-convert.js +80 -0
  50. package/dist/tools/vscode-visions/package.json +32 -0
  51. package/dist/tools/vscode-visions/visions-lsp-core.js +112 -0
  52. package/package.json +95 -4
  53. package/scripts/postinstall.mjs +4 -0
  54. package/scripts/prepare-build.js +38 -0
  55. package/scripts/recover-handoff.mjs +82 -0
@@ -0,0 +1,2998 @@
1
+ import { d as SessionState, l as PendingWakeup, p as TaskTitle, s as PendingPromptDetail, u as SessionSnapshot } from "./session-CJtOveHl.js";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ //#region shared/settings-ranges.ts
5
+ var POSITIVE_NUMBER_RANGE = Object.freeze({
6
+ min: 0,
7
+ exclusiveMin: true,
8
+ label: "a positive number"
9
+ });
10
+ var NON_NEGATIVE_NUMBER_RANGE = Object.freeze({
11
+ min: 0,
12
+ label: "zero or more"
13
+ });
14
+ var FLYING_ANIMALS_GAP_RANGE = Object.freeze({
15
+ min: 0,
16
+ max: 300
17
+ });
18
+ var FLYING_ANIMALS_DURATION_RANGE = Object.freeze({
19
+ min: 1,
20
+ max: 60
21
+ });
22
+ var FLYING_ANIMALS_SCALE_RANGE = Object.freeze({
23
+ min: .5,
24
+ max: 2
25
+ });
26
+ var REPLAY_BUFFER_KB_RANGE = Object.freeze({
27
+ min: 64,
28
+ max: 16384
29
+ });
30
+ var BRANCH_GC_STALE_DAYS_RANGE = POSITIVE_NUMBER_RANGE;
31
+ var BRANCH_GC_INTERVAL_MS_RANGE = POSITIVE_NUMBER_RANGE;
32
+ var VISIONS_QUIET_MS_RANGE = POSITIVE_NUMBER_RANGE;
33
+ var VISIONS_COOLDOWN_MS_RANGE = POSITIVE_NUMBER_RANGE;
34
+ var VISIONS_MAX_PER_HOUR_RANGE = POSITIVE_NUMBER_RANGE;
35
+ var VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE = NON_NEGATIVE_NUMBER_RANGE;
36
+ var VISIONS_DISPATCH_TIMEOUT_RANGE = POSITIVE_NUMBER_RANGE;
37
+ var VISIONS_INTENT_THREAD_TTL_MS_RANGE = POSITIVE_NUMBER_RANGE;
38
+ var POSTHOG_INTERVAL_RANGE = POSITIVE_NUMBER_RANGE;
39
+ var POSTHOG_MAX_CONCURRENT_RANGE = POSITIVE_NUMBER_RANGE;
40
+ var POSTHOG_INVESTIGATION_TIMEOUT_RANGE = POSITIVE_NUMBER_RANGE;
41
+ var POSTHOG_MIN_USERS_RANGE = POSITIVE_NUMBER_RANGE;
42
+ var POSTHOG_ESCALATION_RANGE = POSITIVE_NUMBER_RANGE;
43
+ var POSTHOG_RECURRENCE_WINDOW_RANGE = POSITIVE_NUMBER_RANGE;
44
+ var POSTHOG_TRANSIENT_RECURRENCE_RANGE = POSITIVE_NUMBER_RANGE;
45
+ var POSTHOG_FIX_TIMEOUT_RANGE = Object.freeze({
46
+ min: 60,
47
+ max: 21600,
48
+ label: "between 60 and 21600"
49
+ });
50
+ var POSTHOG_TRAFFIC_MULTIPLIER_RANGE = Object.freeze({
51
+ min: 1,
52
+ label: "at least 1"
53
+ });
54
+ var POSTHOG_TRAFFIC_MIN_USERS_RANGE = Object.freeze({
55
+ min: 1,
56
+ label: "at least 1"
57
+ });
58
+ var POSTHOG_TRAFFIC_COOLDOWN_RANGE = NON_NEGATIVE_NUMBER_RANGE;
59
+ var POSTHOG_TRAFFIC_BASELINE_RANGE = Object.freeze({
60
+ min: 1,
61
+ max: 30,
62
+ label: "between 1 and 30"
63
+ });
64
+ var USAGE_SCAN_INTERVAL_RANGE = Object.freeze({
65
+ min: 1,
66
+ max: 1440
67
+ });
68
+ var USAGE_RETAIN_DAYS_RANGE = Object.freeze({
69
+ min: 1,
70
+ max: 3650
71
+ });
72
+ var USAGE_WAREHOUSE_RETAIN_DAYS_RANGE = Object.freeze({
73
+ min: 30,
74
+ max: 3650
75
+ });
76
+ var USAGE_SESSION_BLOCK_HOURS_RANGE = Object.freeze({
77
+ min: 1,
78
+ max: 24
79
+ });
80
+ var USAGE_BUDGET_RANGE = POSITIVE_NUMBER_RANGE;
81
+ var USAGE_INTEGER_RANGES = Object.freeze({
82
+ scanIntervalMinutes: USAGE_SCAN_INTERVAL_RANGE,
83
+ retainDays: USAGE_RETAIN_DAYS_RANGE,
84
+ warehouseRetainDays: USAGE_WAREHOUSE_RETAIN_DAYS_RANGE,
85
+ sessionBlockHours: USAGE_SESSION_BLOCK_HOURS_RANGE
86
+ });
87
+ var CHANGE_MAP_NARRATOR_TIMEOUT_RANGE = Object.freeze({
88
+ min: 15,
89
+ max: 600
90
+ });
91
+ var KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE = Object.freeze({
92
+ min: 5,
93
+ max: 120
94
+ });
95
+ var WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE = Object.freeze({
96
+ min: 1,
97
+ max: 5
98
+ });
99
+ var WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE = Object.freeze({
100
+ min: 1,
101
+ max: 50
102
+ });
103
+ Object.freeze({
104
+ FLYING_ANIMALS_GAP_RANGE,
105
+ FLYING_ANIMALS_DURATION_RANGE,
106
+ FLYING_ANIMALS_SCALE_RANGE,
107
+ CHANGE_MAP_NARRATOR_TIMEOUT_RANGE,
108
+ KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE,
109
+ POSTHOG_ESCALATION_RANGE,
110
+ POSTHOG_FIX_TIMEOUT_RANGE,
111
+ POSTHOG_INTERVAL_RANGE,
112
+ POSTHOG_INVESTIGATION_TIMEOUT_RANGE,
113
+ POSTHOG_MAX_CONCURRENT_RANGE,
114
+ POSTHOG_MIN_USERS_RANGE,
115
+ POSTHOG_TRAFFIC_BASELINE_RANGE,
116
+ POSTHOG_TRAFFIC_COOLDOWN_RANGE,
117
+ POSTHOG_TRAFFIC_MIN_USERS_RANGE,
118
+ POSTHOG_TRAFFIC_MULTIPLIER_RANGE,
119
+ REPLAY_BUFFER_KB_RANGE,
120
+ USAGE_BUDGET_RANGE,
121
+ USAGE_RETAIN_DAYS_RANGE,
122
+ USAGE_SCAN_INTERVAL_RANGE,
123
+ VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE,
124
+ VISIONS_COOLDOWN_MS_RANGE,
125
+ VISIONS_DISPATCH_TIMEOUT_RANGE,
126
+ VISIONS_INTENT_THREAD_TTL_MS_RANGE,
127
+ VISIONS_MAX_PER_HOUR_RANGE,
128
+ VISIONS_QUIET_MS_RANGE,
129
+ WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE,
130
+ WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE
131
+ });
132
+ //#endregion
133
+ //#region shared/usage-config.ts
134
+ var USAGE_COST_MODES = Object.freeze([
135
+ "auto",
136
+ "calculate",
137
+ "display"
138
+ ]);
139
+ var USAGE_VENDOR_KEYS = Object.freeze(["codex", "grok"]);
140
+ var USAGE_BUDGET_KEYS = Object.freeze(["dailyUsd", "monthlyUsd"]);
141
+ //#endregion
142
+ //#region shared/contracts/reviews.ts
143
+ var ReviewsRetry = z.object({
144
+ attempt: z.number().int().positive(),
145
+ limit: z.number().int().positive()
146
+ }).refine((retry) => retry.attempt <= retry.limit);
147
+ var reviewsPollingShape = {
148
+ error: z.string().nullable().optional(),
149
+ nextAttemptAt: z.number().finite().nonnegative().nullable().optional(),
150
+ retry: ReviewsRetry.nullable().optional(),
151
+ isRefreshing: z.boolean().optional(),
152
+ refreshNotice: z.string().nullable().optional()
153
+ };
154
+ var ReviewsRefreshRequest = z.object({ lane: z.enum(["my-prs", "team-review"]) });
155
+ var ReviewsRefreshResult = z.object({
156
+ ok: z.boolean(),
157
+ error: z.string().optional()
158
+ });
159
+ //#endregion
160
+ //#region shared/contracts/team-review.ts
161
+ var CommitSha = z.string().regex(/^[0-9a-f]{40}$/);
162
+ var repoSlug$1 = z.string().regex(/^[^/]+\/[^/]+$/);
163
+ var SearchedPr = z.object({
164
+ number: z.number().int().positive(),
165
+ title: z.string(),
166
+ html_url: z.string(),
167
+ draft: z.boolean().optional(),
168
+ created_at: z.string().optional(),
169
+ updated_at: z.string().optional(),
170
+ repository_url: z.string(),
171
+ user: z.object({
172
+ login: z.string(),
173
+ type: z.enum(["User", "Bot"])
174
+ }).passthrough(),
175
+ pull_request: z.object({}).passthrough()
176
+ }).passthrough();
177
+ var PrDetail = z.object({
178
+ number: z.number().int().positive(),
179
+ title: z.string(),
180
+ body: z.string(),
181
+ url: z.string(),
182
+ author: z.object({
183
+ login: z.string(),
184
+ is_bot: z.boolean().optional()
185
+ }).passthrough(),
186
+ isDraft: z.boolean(),
187
+ isCrossRepository: z.boolean(),
188
+ baseRefName: z.string(),
189
+ baseRefOid: CommitSha,
190
+ headRefOid: CommitSha,
191
+ additions: z.number().int().nonnegative(),
192
+ deletions: z.number().int().nonnegative(),
193
+ files: z.array(z.object({
194
+ path: z.string(),
195
+ additions: z.number().int().nonnegative(),
196
+ deletions: z.number().int().nonnegative()
197
+ }).passthrough())
198
+ }).passthrough();
199
+ var ReviewComment = z.object({
200
+ path: z.string(),
201
+ line: z.number().int().positive(),
202
+ side: z.enum(["RIGHT", "LEFT"]).default("RIGHT"),
203
+ body: z.string()
204
+ });
205
+ var LEGACY_VERDICTS = Object.freeze({
206
+ STAMP: "APPROVE",
207
+ COMMENT: "APPROVE WITH NITS",
208
+ NEEDS_YOU: "REQUEST CHANGES"
209
+ });
210
+ var ReviewVerdict = z.enum([
211
+ "APPROVE",
212
+ "APPROVE WITH NITS",
213
+ "REQUEST CHANGES",
214
+ "BLOCKED"
215
+ ]);
216
+ var storedVerdict = z.preprocess((verdict) => typeof verdict === "string" && Object.hasOwn(LEGACY_VERDICTS, verdict) ? LEGACY_VERDICTS[verdict] : verdict, ReviewVerdict);
217
+ var FindingSeverity = z.enum([
218
+ "CRITICAL",
219
+ "HIGH",
220
+ "MEDIUM",
221
+ "LOW"
222
+ ]);
223
+ var DraftComment = ReviewComment.extend({ severity: FindingSeverity.optional() });
224
+ var ReviewFinding = z.object({
225
+ path: z.string().min(1),
226
+ line: z.number().int().positive().nullable(),
227
+ side: z.enum(["RIGHT", "LEFT"]),
228
+ severity: FindingSeverity,
229
+ reviewer: z.string().min(1),
230
+ disposition: z.enum([
231
+ "ACTIONABLE",
232
+ "NIT",
233
+ "AMBIGUOUS"
234
+ ]).nullable(),
235
+ body: z.string().min(1)
236
+ });
237
+ var ReviewAssessment = z.object({
238
+ goal: z.string().default(""),
239
+ change: z.string(),
240
+ checked: z.array(z.string()),
241
+ gaps: z.array(z.string())
242
+ });
243
+ var ReviewResult = z.object({
244
+ verdict: ReviewVerdict,
245
+ head: CommitSha,
246
+ summary: z.string(),
247
+ assessment: ReviewAssessment.nullable(),
248
+ findings: z.array(ReviewFinding)
249
+ });
250
+ var PostingPlan = z.object({
251
+ body: z.string(),
252
+ commit_id: CommitSha,
253
+ comments: z.array(z.object({
254
+ path: z.string().min(1),
255
+ line: z.number().int().positive(),
256
+ side: z.enum(["RIGHT", "LEFT"]).default("RIGHT"),
257
+ body: z.string().min(1)
258
+ }))
259
+ });
260
+ var PostedReviewEvent = z.enum(["APPROVE", "COMMENT"]);
261
+ var GithubReviewState = z.enum([
262
+ "APPROVED",
263
+ "CHANGES_REQUESTED",
264
+ "COMMENTED"
265
+ ]);
266
+ var DECIDING_REVIEW_STATES = /* @__PURE__ */ new Set(["APPROVED", "CHANGES_REQUESTED"]);
267
+ var GithubReviewDecision = z.enum([
268
+ "APPROVED",
269
+ "CHANGES_REQUESTED",
270
+ "REVIEW_REQUIRED"
271
+ ]);
272
+ var ReviewChecksState = z.enum([
273
+ "SUCCESS",
274
+ "FAILURE",
275
+ "PENDING",
276
+ "ERROR",
277
+ "EXPECTED"
278
+ ]);
279
+ var reviewPriorityShape = {
280
+ requestSource: z.enum(["direct", "team"]).default("team"),
281
+ isDraft: z.boolean().optional(),
282
+ checksState: ReviewChecksState.nullable().optional()
283
+ };
284
+ var GithubReview = z.object({
285
+ login: z.string().min(1),
286
+ state: GithubReviewState,
287
+ commit: CommitSha.nullable(),
288
+ isViewer: z.boolean(),
289
+ submittedAt: z.string().nullable().optional()
290
+ });
291
+ function decisionAsIfApprovalRequired(githubDecision, opinionatedWriterReviewStates) {
292
+ if (githubDecision) return githubDecision;
293
+ if (opinionatedWriterReviewStates.includes("CHANGES_REQUESTED")) return "CHANGES_REQUESTED";
294
+ if (opinionatedWriterReviewStates.includes("APPROVED")) return "APPROVED";
295
+ return "REVIEW_REQUIRED";
296
+ }
297
+ function hasStandingViewerApproval(draft) {
298
+ if (draft.reviewDecision !== "APPROVED") return false;
299
+ if (draft.requeuedHead !== void 0 && draft.requeuedHead === (draft.liveHead ?? draft.reviewedHead)) return false;
300
+ return (draft.githubReviews ?? []).some((review) => review.isViewer && review.state === "APPROVED");
301
+ }
302
+ z.object({
303
+ head: CommitSha,
304
+ reviews: z.array(GithubReview)
305
+ });
306
+ var PriorReview = z.object({
307
+ head: CommitSha,
308
+ verdict: ReviewVerdict,
309
+ summary: z.string(),
310
+ body: z.string(),
311
+ comments: z.array(ReviewComment),
312
+ wasPosted: z.boolean()
313
+ });
314
+ var ReviewThreadId = z.string().min(1).max(256).regex(/^[A-Za-z0-9_=-]+$/);
315
+ var TeamReviewThreadResult = z.object({
316
+ addressed: z.boolean(),
317
+ reason: z.string().trim().min(1).max(4e3)
318
+ }).strict();
319
+ var TeamReviewThreadNode = z.object({
320
+ id: ReviewThreadId,
321
+ path: z.string(),
322
+ line: z.number().int().positive().nullable(),
323
+ isResolved: z.boolean(),
324
+ viewerCanResolve: z.boolean(),
325
+ comments: z.object({
326
+ pageInfo: z.object({
327
+ hasNextPage: z.boolean(),
328
+ endCursor: z.string().nullable().optional()
329
+ }),
330
+ nodes: z.array(z.object({
331
+ body: z.string(),
332
+ author: z.object({ login: z.string() }).nullable(),
333
+ viewerDidAuthor: z.boolean(),
334
+ createdAt: z.string().datetime(),
335
+ url: z.string().url(),
336
+ originalCommit: z.object({ oid: CommitSha }).nullable()
337
+ }))
338
+ })
339
+ });
340
+ var TeamReviewThreadCommentsResponse = z.object({ data: z.object({ node: z.object({ comments: TeamReviewThreadNode.shape.comments }).nullable() }).nullable() });
341
+ var TeamReviewThreadsRepository = z.object({ pullRequest: z.object({ reviewThreads: z.object({
342
+ pageInfo: z.object({
343
+ hasNextPage: z.boolean(),
344
+ endCursor: z.string().nullable().optional()
345
+ }),
346
+ nodes: z.array(TeamReviewThreadNode)
347
+ }) }).nullable() });
348
+ var TeamReviewResolveResponse = z.object({
349
+ data: z.object({ resolveReviewThread: z.object({ thread: z.object({
350
+ id: ReviewThreadId,
351
+ isResolved: z.literal(true)
352
+ }) }) }).nullable(),
353
+ errors: z.array(z.unknown()).optional()
354
+ });
355
+ var TeamReviewThread = z.object({
356
+ id: ReviewThreadId,
357
+ path: z.string(),
358
+ line: z.number().int().positive().nullable(),
359
+ isResolved: z.boolean(),
360
+ viewerCanResolve: z.boolean(),
361
+ isNit: z.boolean(),
362
+ url: z.string().url(),
363
+ lastReplyAuthor: z.string(),
364
+ lastReplyAt: z.string().datetime(),
365
+ judgement: TeamReviewThreadResult.extend({
366
+ head: CommitSha,
367
+ judgedAt: z.number().finite(),
368
+ lastReplyAt: z.string().datetime()
369
+ }).optional(),
370
+ resolveError: z.string().optional(),
371
+ resolveAttemptReplyAt: z.string().optional(),
372
+ judgeAttempt: z.object({
373
+ head: CommitSha,
374
+ lastReplyAt: z.string(),
375
+ retryAt: z.number().finite()
376
+ }).optional(),
377
+ unjudgeable: z.object({
378
+ head: CommitSha,
379
+ lastReplyAt: z.string(),
380
+ reason: z.string().min(1)
381
+ }).optional()
382
+ });
383
+ var TeamReviewCompareFiles = z.object({
384
+ merge_base_commit: z.object({ sha: CommitSha }),
385
+ files: z.array(z.object({
386
+ filename: z.string(),
387
+ previous_filename: z.string().optional(),
388
+ patch: z.string().optional()
389
+ })).max(300)
390
+ });
391
+ var ViewerThreadTally = z.object({
392
+ total: z.number().int().nonnegative(),
393
+ resolved: z.number().int().nonnegative()
394
+ });
395
+ var ReviewDraft = z.object({
396
+ ...reviewPriorityShape,
397
+ key: z.string(),
398
+ repo: repoSlug$1,
399
+ number: z.number().int().positive(),
400
+ title: z.string(),
401
+ url: z.string(),
402
+ author: z.string(),
403
+ tier: z.enum(["stamp", "full"]),
404
+ reasons: z.array(z.string()),
405
+ reviewedHead: CommitSha,
406
+ verdict: storedVerdict,
407
+ summary: z.string(),
408
+ assessment: ReviewAssessment.optional(),
409
+ body: z.string(),
410
+ comments: z.array(DraftComment),
411
+ status: z.enum([
412
+ "ready",
413
+ "stale",
414
+ "posted",
415
+ "discarded",
416
+ "error"
417
+ ]),
418
+ error: z.string().optional(),
419
+ threads: z.array(TeamReviewThread).optional(),
420
+ viewerThreads: ViewerThreadTally.optional(),
421
+ githubReviews: z.array(GithubReview).optional(),
422
+ reviewDecision: GithubReviewDecision.nullable().optional(),
423
+ liveHead: CommitSha.optional(),
424
+ prCreatedAt: z.string().optional(),
425
+ reviewedAt: z.number().finite().optional(),
426
+ postedAt: z.number().finite().optional(),
427
+ postedEvent: PostedReviewEvent.optional(),
428
+ priorReviewedHead: CommitSha.optional(),
429
+ requeuedHead: CommitSha.optional()
430
+ });
431
+ function canApproveAfterComment(draft) {
432
+ return draft.status === "posted" && draft.postedEvent === "COMMENT";
433
+ }
434
+ var TeamReviewAction = z.enum([
435
+ "approve",
436
+ "approve-only",
437
+ "comment",
438
+ "discard",
439
+ "requeue",
440
+ "resolve-thread"
441
+ ]);
442
+ var TeamReviewActionRequest = z.object({
443
+ key: z.string().min(1),
444
+ head: CommitSha,
445
+ action: TeamReviewAction,
446
+ threadId: ReviewThreadId.optional(),
447
+ body: z.string(),
448
+ comments: z.array(ReviewComment)
449
+ }).refine((request) => request.action !== "resolve-thread" || request.threadId !== void 0, {
450
+ message: "resolve-thread requires threadId",
451
+ path: ["threadId"]
452
+ });
453
+ var TeamReviewActionResult = z.object({
454
+ key: z.string(),
455
+ ok: z.boolean(),
456
+ error: z.string().optional(),
457
+ warning: z.string().optional()
458
+ });
459
+ var ResumableReview = z.object({
460
+ sessionId: z.string().min(1),
461
+ workDir: z.string().min(1),
462
+ worktreePath: z.string().min(1),
463
+ head: CommitSha,
464
+ deadlineAt: z.number(),
465
+ remainingAwakeMs: z.number().nonnegative().optional(),
466
+ savedAt: z.number()
467
+ });
468
+ var QueuedReview = z.object({
469
+ ...reviewPriorityShape,
470
+ reviewDecision: GithubReviewDecision.nullable().optional(),
471
+ key: z.string(),
472
+ repo: repoSlug$1,
473
+ number: z.number().int().positive(),
474
+ title: z.string(),
475
+ url: z.string(),
476
+ author: z.string(),
477
+ prCreatedAt: z.string().optional()
478
+ });
479
+ var TeamReviewStateEntry = z.object({
480
+ draft: ReviewDraft.nullable(),
481
+ reviewedHead: CommitSha.nullable(),
482
+ inFlight: z.boolean(),
483
+ skipReason: z.string().nullable(),
484
+ handReview: QueuedReview.optional(),
485
+ reviewAttempts: z.number().int().nonnegative().default(0),
486
+ resumable: ResumableReview.nullable().optional(),
487
+ reviewedAt: z.number().optional(),
488
+ threads: z.array(TeamReviewThread).optional(),
489
+ viewerThreads: ViewerThreadTally.optional(),
490
+ autoResolvedThreadIds: z.array(ReviewThreadId).optional(),
491
+ githubReviews: z.array(GithubReview).optional(),
492
+ reviewDecision: GithubReviewDecision.nullable().optional(),
493
+ liveHead: CommitSha.optional(),
494
+ requeuedHead: CommitSha.optional(),
495
+ priorReview: PriorReview.optional(),
496
+ discardedReviewHead: CommitSha.optional(),
497
+ updatedAt: z.number().finite()
498
+ });
499
+ z.record(z.string(), TeamReviewStateEntry);
500
+ var ReviewProgressPhase = z.enum([
501
+ "preparing",
502
+ "checkout",
503
+ "reviewing"
504
+ ]);
505
+ var ReviewProgressStep = z.object({
506
+ at: z.number().finite(),
507
+ tool: z.string(),
508
+ detail: z.string()
509
+ });
510
+ var InFlightReview = z.object({
511
+ ...reviewPriorityShape,
512
+ reviewDecision: GithubReviewDecision.nullable().optional(),
513
+ key: z.string(),
514
+ repo: repoSlug$1,
515
+ number: z.number().int().positive(),
516
+ title: z.string(),
517
+ url: z.string(),
518
+ author: z.string(),
519
+ tier: z.enum(["stamp", "full"]),
520
+ reasons: z.array(z.string()),
521
+ head: CommitSha,
522
+ phase: ReviewProgressPhase,
523
+ startedAt: z.number().finite(),
524
+ deadlineAt: z.number().finite().nullable(),
525
+ toolCalls: z.number().int().nonnegative(),
526
+ recentSteps: z.array(ReviewProgressStep),
527
+ prCreatedAt: z.string().optional(),
528
+ priorReviewedHead: CommitSha.optional()
529
+ });
530
+ var TeamReviewStatus = z.object({
531
+ ...reviewsPollingShape,
532
+ type: z.literal("team-review-status"),
533
+ ts: z.number().finite(),
534
+ configured: z.boolean(),
535
+ reason: z.string().nullable().optional(),
536
+ drafts: z.array(ReviewDraft),
537
+ inFlight: z.array(InFlightReview),
538
+ queued: z.array(QueuedReview).default([]),
539
+ handReview: z.array(QueuedReview).default([]),
540
+ team: z.object({
541
+ org: z.string(),
542
+ slug: z.string(),
543
+ name: z.string(),
544
+ avatarUrl: z.string()
545
+ }).nullable().optional()
546
+ }).passthrough();
547
+ //#endregion
548
+ //#region shared/contracts/my-prs.ts
549
+ var MyPrStage = z.enum([
550
+ "merged",
551
+ "draft",
552
+ "conflicts",
553
+ "behind",
554
+ "checks-failing",
555
+ "changes-requested",
556
+ "unresolved-threads",
557
+ "checks-pending",
558
+ "needs-approval",
559
+ "ready",
560
+ "unknown"
561
+ ]);
562
+ var nonnegativeInteger$1 = z.number().int().nonnegative();
563
+ var repositoryName = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/);
564
+ var pullRequestNumberText = z.string().regex(/^[1-9][0-9]*$/);
565
+ var pullRequestKeyFormat = z.templateLiteral([
566
+ repositoryName,
567
+ "#",
568
+ pullRequestNumberText
569
+ ]);
570
+ var keepMergeableAttemptKeyFormat = z.templateLiteral([
571
+ pullRequestKeyFormat,
572
+ "@",
573
+ CommitSha
574
+ ]);
575
+ var pullRequestKey = z.string().refine((value) => pullRequestKeyFormat.safeParse(value).success);
576
+ var keepMergeableAttemptKey = z.string().refine((value) => keepMergeableAttemptKeyFormat.safeParse(value).success);
577
+ z.discriminatedUnion("outcome", [z.strictObject({ outcome: z.literal("pushed") }), z.strictObject({
578
+ outcome: z.enum([
579
+ "no-change",
580
+ "failed",
581
+ "stopped",
582
+ "timed-out"
583
+ ]),
584
+ reason: z.string().min(1)
585
+ })]);
586
+ var MyPrKeepMergeableAttempt = z.strictObject({
587
+ outcome: z.enum([
588
+ "pushed",
589
+ "no-change",
590
+ "failed",
591
+ "stopped",
592
+ "timed-out"
593
+ ]),
594
+ reason: z.string().min(1).optional(),
595
+ at: z.number().finite()
596
+ });
597
+ var MyPrKeepMergeableAttemptRecord = MyPrKeepMergeableAttempt.extend({
598
+ key: pullRequestKey,
599
+ headRefOid: CommitSha,
600
+ baseRefOid: CommitSha
601
+ });
602
+ var MyPrsState = z.strictObject({
603
+ keepMergeableKeys: z.array(pullRequestKey),
604
+ keepMergeableAttemptKeys: z.array(keepMergeableAttemptKey),
605
+ keepMergeableAttempts: z.array(MyPrKeepMergeableAttemptRecord).default([]),
606
+ mergeQueueKeys: z.array(pullRequestKey).default([]),
607
+ keepMergeablePushedHeadKeys: z.array(keepMergeableAttemptKey).default([])
608
+ });
609
+ var MyPrKeepMergeableRequest = z.object({
610
+ repo: repositoryName,
611
+ number: z.number().int().positive(),
612
+ keepMergeable: z.boolean()
613
+ });
614
+ var MyPrToggleResult = z.object({
615
+ key: z.string(),
616
+ ok: z.boolean(),
617
+ error: z.string().optional()
618
+ });
619
+ var MyPrKeepMergeableResult = MyPrToggleResult;
620
+ var MyPrMergeWhenReadyRequest = z.object({
621
+ repo: repositoryName,
622
+ number: z.number().int().positive(),
623
+ mergeWhenReady: z.boolean()
624
+ });
625
+ var MyPrMergeWhenReadyResult = MyPrToggleResult;
626
+ var MyPrMergeMethod = z.enum([
627
+ "MERGE",
628
+ "SQUASH",
629
+ "REBASE"
630
+ ]);
631
+ var MyPrThread = z.object({
632
+ path: z.string(),
633
+ line: z.number().int().positive().nullable(),
634
+ isOutdated: z.boolean(),
635
+ url: z.url(),
636
+ author: z.string().nullable(),
637
+ excerpt: z.string(),
638
+ commentCount: z.number().int().positive(),
639
+ lastAuthor: z.string().nullable(),
640
+ lastActivityAt: z.string()
641
+ });
642
+ var MyPrReview = z.object({
643
+ reviewer: z.string().nullable(),
644
+ state: z.string(),
645
+ submittedAt: z.string().nullable()
646
+ });
647
+ var MyPrAutoRebase = z.object({
648
+ outcome: z.enum(["rebased", "failed"]),
649
+ at: z.number().finite(),
650
+ message: z.string()
651
+ });
652
+ var MyPr = z.object({
653
+ key: z.string(),
654
+ repo: repositoryName,
655
+ number: z.number().int().positive(),
656
+ title: z.string(),
657
+ url: z.url(),
658
+ isDraft: z.boolean(),
659
+ state: z.enum([
660
+ "OPEN",
661
+ "MERGED",
662
+ "CLOSED"
663
+ ]),
664
+ createdAt: z.string(),
665
+ mergedAt: z.string().nullable(),
666
+ updatedAt: z.string(),
667
+ baseRefName: z.string(),
668
+ baseRefOid: CommitSha,
669
+ headRefName: z.string().min(1),
670
+ isCrossRepository: z.boolean(),
671
+ headRefOid: CommitSha,
672
+ isInMergeQueue: z.boolean(),
673
+ mergeMethod: MyPrMergeMethod,
674
+ mergeable: z.enum([
675
+ "MERGEABLE",
676
+ "CONFLICTING",
677
+ "UNKNOWN"
678
+ ]),
679
+ mergeStateStatus: z.string(),
680
+ reviewDecision: z.enum([
681
+ "APPROVED",
682
+ "CHANGES_REQUESTED",
683
+ "REVIEW_REQUIRED"
684
+ ]).nullable(),
685
+ checks: z.object({
686
+ state: z.enum([
687
+ "SUCCESS",
688
+ "FAILURE",
689
+ "PENDING",
690
+ "ERROR",
691
+ "EXPECTED"
692
+ ]).nullable(),
693
+ failing: z.array(z.string()),
694
+ pendingCount: nonnegativeInteger$1
695
+ }),
696
+ unresolvedThreads: nonnegativeInteger$1,
697
+ threads: z.array(MyPrThread),
698
+ behindBy: nonnegativeInteger$1.nullable(),
699
+ reviewRequests: z.array(z.object({
700
+ name: z.string(),
701
+ isTeam: z.boolean(),
702
+ avatarUrl: z.string().nullable()
703
+ })),
704
+ approvals: nonnegativeInteger$1,
705
+ reviews: z.array(MyPrReview),
706
+ stage: MyPrStage,
707
+ autoRebase: MyPrAutoRebase.optional(),
708
+ keepMergeable: z.boolean().optional(),
709
+ keepMergeableAttempt: MyPrKeepMergeableAttempt.optional(),
710
+ isKeepMergeableFixInFlight: z.boolean().optional(),
711
+ mergeQueuePosition: z.number().int().positive().nullable().optional(),
712
+ isMergeQueueHeldForRepairPush: z.boolean().optional()
713
+ }).refine((pr) => pr.key === `${pr.repo}#${pr.number}`);
714
+ var MyPrsStatus = z.object({
715
+ ...reviewsPollingShape,
716
+ type: z.literal("my-prs-status"),
717
+ ts: z.number().finite(),
718
+ configured: z.boolean(),
719
+ reason: z.string().nullable().optional(),
720
+ viewer: z.string().nullable(),
721
+ prs: z.array(MyPr),
722
+ truncatedNote: z.string().nullable().optional(),
723
+ isKeepMergeableEnabled: z.boolean().optional(),
724
+ isMergeQueueEnabled: z.boolean().optional()
725
+ }).passthrough();
726
+ var MyPrMergeRequest = z.object({
727
+ repo: repositoryName,
728
+ number: z.number().int().positive(),
729
+ headRefOid: CommitSha
730
+ });
731
+ var MyPrMergeKind = z.enum([
732
+ "merged",
733
+ "queued",
734
+ "auto-merge",
735
+ "unconfirmed"
736
+ ]);
737
+ var MyPrMergeResult = z.object({
738
+ key: z.string(),
739
+ ok: z.boolean(),
740
+ kind: MyPrMergeKind.optional(),
741
+ error: z.string().optional()
742
+ });
743
+ var CheckRun = z.object({
744
+ __typename: z.literal("CheckRun"),
745
+ name: z.string(),
746
+ conclusion: z.string().nullable(),
747
+ status: z.string()
748
+ });
749
+ var StatusContext = z.object({
750
+ __typename: z.literal("StatusContext"),
751
+ context: z.string(),
752
+ state: z.string()
753
+ });
754
+ var MyPrSearchNode = z.object({
755
+ __typename: z.literal("PullRequest"),
756
+ id: z.string().regex(/^[A-Za-z0-9_=-]+$/),
757
+ number: z.number().int().positive(),
758
+ title: z.string(),
759
+ url: z.url(),
760
+ isDraft: z.boolean(),
761
+ state: z.enum([
762
+ "OPEN",
763
+ "MERGED",
764
+ "CLOSED"
765
+ ]),
766
+ createdAt: z.string(),
767
+ mergedAt: z.string().nullable(),
768
+ updatedAt: z.string(),
769
+ baseRefName: z.string(),
770
+ baseRefOid: CommitSha,
771
+ headRefName: z.string().min(1),
772
+ isCrossRepository: z.boolean(),
773
+ headRefOid: CommitSha,
774
+ isInMergeQueue: z.boolean(),
775
+ mergeable: z.enum([
776
+ "MERGEABLE",
777
+ "CONFLICTING",
778
+ "UNKNOWN"
779
+ ]),
780
+ mergeStateStatus: z.string(),
781
+ reviewDecision: z.enum([
782
+ "APPROVED",
783
+ "CHANGES_REQUESTED",
784
+ "REVIEW_REQUIRED"
785
+ ]).nullable(),
786
+ repository: z.object({
787
+ nameWithOwner: repositoryName,
788
+ viewerDefaultMergeMethod: MyPrMergeMethod
789
+ }),
790
+ commits: z.object({ nodes: z.array(z.object({ commit: z.object({ statusCheckRollup: z.object({
791
+ state: z.enum([
792
+ "SUCCESS",
793
+ "FAILURE",
794
+ "PENDING",
795
+ "ERROR",
796
+ "EXPECTED"
797
+ ]).nullable(),
798
+ contexts: z.object({ nodes: z.array(z.union([CheckRun, StatusContext])) })
799
+ }).nullable() }) })) }),
800
+ reviewThreads: z.object({
801
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
802
+ nodes: z.array(z.object({ isResolved: z.boolean() }))
803
+ }),
804
+ reviewRequests: z.object({ nodes: z.array(z.object({ requestedReviewer: z.discriminatedUnion("__typename", [
805
+ z.object({
806
+ __typename: z.literal("User"),
807
+ login: z.string()
808
+ }),
809
+ z.object({
810
+ __typename: z.literal("Team"),
811
+ slug: z.string(),
812
+ avatarUrl: z.string().nullable(),
813
+ organization: z.object({ login: z.string() })
814
+ }),
815
+ z.object({ __typename: z.enum(["Bot", "Mannequin"]) })
816
+ ]).nullable() })) }),
817
+ latestOpinionatedReviews: z.object({ nodes: z.array(z.object({ state: z.string() })) }),
818
+ latestReviews: z.object({ nodes: z.array(z.object({
819
+ state: z.string(),
820
+ submittedAt: z.string().nullable(),
821
+ author: z.object({ login: z.string() }).nullable()
822
+ })) })
823
+ });
824
+ var ThreadCommentAuthor = z.object({ login: z.string() }).nullable();
825
+ var MyPrThreadNode = z.object({
826
+ isResolved: z.boolean(),
827
+ isOutdated: z.boolean(),
828
+ path: z.string(),
829
+ line: z.number().int().positive().nullable(),
830
+ firstComment: z.object({
831
+ totalCount: nonnegativeInteger$1,
832
+ nodes: z.array(z.object({
833
+ author: ThreadCommentAuthor,
834
+ bodyText: z.string(),
835
+ url: z.url(),
836
+ createdAt: z.string()
837
+ }))
838
+ }),
839
+ lastComment: z.object({ nodes: z.array(z.object({
840
+ author: ThreadCommentAuthor,
841
+ createdAt: z.string()
842
+ })) })
843
+ });
844
+ var MyPrThreadsResponse = z.object({
845
+ data: z.object({ repository: z.object({ pullRequest: z.object({ reviewThreads: z.object({
846
+ pageInfo: z.object({
847
+ hasNextPage: z.boolean(),
848
+ endCursor: z.string().nullable()
849
+ }),
850
+ nodes: z.array(z.unknown())
851
+ }) }).nullable() }).nullable() }),
852
+ errors: z.array(z.unknown()).optional()
853
+ });
854
+ var MyPrMergeStateResponse = z.object({
855
+ data: z.object({ repository: z.object({ pullRequest: z.object({
856
+ state: z.string(),
857
+ isInMergeQueue: z.boolean(),
858
+ autoMergeRequest: z.object({ enabledAt: z.string().nullable() }).nullable()
859
+ }).nullable() }).nullable() }),
860
+ errors: z.array(z.unknown()).optional()
861
+ });
862
+ var MyPrSearchResponse = z.object({
863
+ data: z.object({
864
+ open: z.object({
865
+ issueCount: nonnegativeInteger$1,
866
+ nodes: z.array(z.unknown())
867
+ }),
868
+ merged: z.object({
869
+ issueCount: nonnegativeInteger$1,
870
+ nodes: z.array(z.unknown())
871
+ })
872
+ }),
873
+ errors: z.array(z.unknown()).optional()
874
+ });
875
+ //#endregion
876
+ //#region shared/contracts/workflows.ts
877
+ var WORKFLOW_TRIGGERS = Object.freeze([
878
+ "opened",
879
+ "checks-failed",
880
+ "review-requested",
881
+ "approved",
882
+ "commented",
883
+ "merged"
884
+ ]);
885
+ var WORKFLOW_ACTION_TYPES = Object.freeze([
886
+ "notify",
887
+ "spawn",
888
+ "label",
889
+ "comment"
890
+ ]);
891
+ var WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS = 2e4;
892
+ var WORKFLOW_COMMENT_BODY_MAX_CHARACTERS = 65536;
893
+ var RULE_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
894
+ var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
895
+ var UNSAFE_LABEL_NAME = /[\x00-\x1f\x7f,]|^-/;
896
+ var integerInRange = (field, range) => {
897
+ const message = `${field} must be an integer between ${range.min} and ${range.max}`;
898
+ return z.number({ error: message }).int({ error: message }).min(range.min, { error: message }).max(range.max, { error: message });
899
+ };
900
+ var workflowsEnabled = z.boolean({ error: "workflows.enabled must be a boolean" });
901
+ var workflowsMaxConcurrentSessions = integerInRange("workflows.maxConcurrentSessions", WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE);
902
+ var workflowsMaxActionsPerPoll = integerInRange("workflows.maxActionsPerPoll", WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE);
903
+ var nonEmptyList = (field, item) => z.array(item, { error: `${field} must be an array` }).min(1, { error: `${field} must list at least one entry when present` });
904
+ var WorkflowLabelName = z.string({ error: "a workflow label name must be a string" }).trim().min(1, { error: "a workflow label name must not be empty" }).max(50, { error: `a workflow label name must be at most 50 characters` }).refine((name) => !UNSAFE_LABEL_NAME.test(name), { error: "a workflow label name must not start with a dash or hold a comma or control character" });
905
+ var WorkflowCommentBody = z.string({ error: "a workflow comment body must be a string" }).min(1, { error: "a workflow comment body must not be empty" }).max(WORKFLOW_COMMENT_BODY_MAX_CHARACTERS, { error: `a workflow comment body must be at most ${WORKFLOW_COMMENT_BODY_MAX_CHARACTERS} characters` }).refine((body) => body.trim().length > 0, { error: "a workflow comment body must not be blank" });
906
+ var WorkflowTrigger = z.enum(WORKFLOW_TRIGGERS, { error: `workflows.rules[].trigger must be one of ${WORKFLOW_TRIGGERS.join(", ")}` });
907
+ var WorkflowAction = z.discriminatedUnion("type", [
908
+ z.strictObject({ type: z.literal("notify") }),
909
+ z.strictObject({
910
+ type: z.literal("spawn"),
911
+ promptTemplate: z.string({ error: "a spawn action needs a promptTemplate string" }).min(1, { error: "a spawn action promptTemplate must not be empty" }).max(WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS, { error: `a spawn action promptTemplate must be at most ${WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS} characters` }).refine((template) => template.trim().length > 0, { error: "a spawn action promptTemplate must not be blank" })
912
+ }),
913
+ z.strictObject({
914
+ type: z.literal("label"),
915
+ name: WorkflowLabelName
916
+ }),
917
+ z.strictObject({
918
+ type: z.literal("comment"),
919
+ body: WorkflowCommentBody
920
+ })
921
+ ], { error: `workflows.rules[].actions[].type must be one of ${WORKFLOW_ACTION_TYPES.join(", ")}` });
922
+ var WorkflowFilters = z.strictObject({
923
+ mine: z.boolean({ error: "workflows.rules[].filters.mine must be a boolean" }).optional(),
924
+ teamReviewRequested: z.boolean({ error: "workflows.rules[].filters.teamReviewRequested must be a boolean" }).optional(),
925
+ authors: nonEmptyList("workflows.rules[].filters.authors", z.string({ error: "workflows.rules[].filters.authors must hold GitHub logins" }).regex(GITHUB_LOGIN, { error: "workflows.rules[].filters.authors must hold GitHub logins" })).optional(),
926
+ labels: nonEmptyList("workflows.rules[].filters.labels", WorkflowLabelName).optional(),
927
+ baseBranches: nonEmptyList("workflows.rules[].filters.baseBranches", z.string({ error: "workflows.rules[].filters.baseBranches must hold branch names" }).min(1, { error: "workflows.rules[].filters.baseBranches must hold branch names" })).optional()
928
+ }, { error: "workflows.rules[].filters must be an object" });
929
+ var WorkflowRuleId = z.string({ error: "workflows.rules[].id must be a string" }).regex(RULE_ID, { error: "workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit" });
930
+ var WorkflowRuleEnabled = z.boolean({ error: "workflows.rules[].enabled must be a boolean" });
931
+ var WorkflowRule = z.strictObject({
932
+ id: WorkflowRuleId,
933
+ name: z.string({ error: "workflows.rules[].name must be a string" }).trim().min(1, { error: "workflows.rules[].name must not be empty" }).max(80, { error: "workflows.rules[].name must be at most 80 characters" }),
934
+ enabled: WorkflowRuleEnabled.default(false),
935
+ repos: nonEmptyList("workflows.rules[].repos", repositoryName),
936
+ filters: WorkflowFilters.default({}),
937
+ trigger: WorkflowTrigger,
938
+ actions: nonEmptyList("workflows.rules[].actions", WorkflowAction)
939
+ }, { error: "workflows.rules[] must be an object" });
940
+ var WorkflowsSettings = z.strictObject({
941
+ enabled: workflowsEnabled.default(true),
942
+ maxConcurrentSessions: workflowsMaxConcurrentSessions.default(2),
943
+ maxActionsPerPoll: workflowsMaxActionsPerPoll.default(20),
944
+ rules: z.array(WorkflowRule, { error: "workflows.rules must be an array" }).default([])
945
+ }, { error: "workflows must be an object" }).superRefine((settings, ctx) => {
946
+ const claimedIds = /* @__PURE__ */ new Set();
947
+ for (const [index, rule] of settings.rules.entries()) {
948
+ if (!claimedIds.has(rule.id)) {
949
+ claimedIds.add(rule.id);
950
+ continue;
951
+ }
952
+ ctx.addIssue({
953
+ code: "custom",
954
+ path: [
955
+ "rules",
956
+ index,
957
+ "id"
958
+ ],
959
+ message: `workflows.rules[${index}].id "${rule.id}" is declared more than once`
960
+ });
961
+ }
962
+ });
963
+ var WorkflowRuleToggle = z.strictObject({
964
+ id: WorkflowRuleId,
965
+ enabled: WorkflowRuleEnabled
966
+ }, { error: "a dashboard update of workflows.rules[] carries only id and enabled" });
967
+ var WorkflowsSettingsUpdate = z.strictObject({
968
+ enabled: workflowsEnabled.optional(),
969
+ maxConcurrentSessions: workflowsMaxConcurrentSessions.optional(),
970
+ maxActionsPerPoll: workflowsMaxActionsPerPoll.optional(),
971
+ rules: z.array(WorkflowRuleToggle, { error: "workflows.rules must be an array" }).optional()
972
+ }, { error: "a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles" });
973
+ var nonnegativeInteger = z.number().int().nonnegative();
974
+ var checksState = z.enum([
975
+ "SUCCESS",
976
+ "FAILURE",
977
+ "PENDING",
978
+ "ERROR",
979
+ "EXPECTED"
980
+ ]).nullable();
981
+ var WorkflowSearchNode = MyPrSearchNode.extend({
982
+ author: z.object({ login: z.string() }).nullable(),
983
+ labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }),
984
+ comments: z.object({ totalCount: nonnegativeInteger })
985
+ });
986
+ var WorkflowPr = z.strictObject({
987
+ repo: repositoryName,
988
+ number: z.number().int().positive(),
989
+ title: z.string(),
990
+ url: z.url(),
991
+ author: z.string().nullable(),
992
+ state: z.enum([
993
+ "OPEN",
994
+ "MERGED",
995
+ "CLOSED"
996
+ ]),
997
+ createdAt: z.string(),
998
+ mergedAt: z.string().nullable(),
999
+ isDraft: z.boolean(),
1000
+ isCrossRepository: z.boolean(),
1001
+ baseRefName: z.string(),
1002
+ headRefName: z.string().min(1),
1003
+ headRefOid: CommitSha,
1004
+ labels: z.array(z.string()),
1005
+ commentCount: nonnegativeInteger,
1006
+ reviewRequests: z.array(z.string()),
1007
+ checksState,
1008
+ reviewDecision: z.enum([
1009
+ "APPROVED",
1010
+ "CHANGES_REQUESTED",
1011
+ "REVIEW_REQUIRED"
1012
+ ]).nullable()
1013
+ });
1014
+ var WorkflowRepoSnapshot = z.strictObject({
1015
+ polledAtMs: nonnegativeInteger,
1016
+ prs: z.array(WorkflowPr)
1017
+ });
1018
+ var WorkflowsState = z.strictObject({ repos: z.record(z.string().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/), WorkflowRepoSnapshot) });
1019
+ //#endregion
1020
+ //#region shared/contracts/browser-config.ts
1021
+ var optionalBoolean = (field) => z.boolean({ error: `${field} must be a boolean` }).optional();
1022
+ var optionalString = (field, trim = false) => {
1023
+ const schema = z.string({ error: `${field} must be a string` });
1024
+ return (trim ? schema.transform((value) => value.trim()) : schema).optional();
1025
+ };
1026
+ var numberRangeLabel = (range) => {
1027
+ if (range.label) return range.label;
1028
+ if (range.max != null) return `between ${range.min} and ${range.max}`;
1029
+ if (range.exclusiveMin) return `greater than ${range.min}`;
1030
+ return `at least ${range.min}`;
1031
+ };
1032
+ var optionalNumber = (field, range = POSITIVE_NUMBER_RANGE) => z.number({ error: `${field} must be ${numberRangeLabel(range)}` }).finite().refine((value) => !range.exclusiveMin || value > range.min, { message: `${field} must be ${numberRangeLabel(range)}` }).refine((value) => range.exclusiveMin || value >= range.min, { message: `${field} must be ${numberRangeLabel(range)}` }).refine((value) => range.max == null || value <= range.max, { message: `${field} must be ${numberRangeLabel(range)}` }).optional();
1033
+ var optionalInteger = (field, range) => z.number({ error: `${field} must be an integer between ${range.min} and ${range.max}` }).int({ error: `${field} must be an integer between ${range.min} and ${range.max}` }).min(range.min, { error: `${field} must be an integer between ${range.min} and ${range.max}` }).max(range.max, { error: `${field} must be an integer between ${range.min} and ${range.max}` }).optional();
1034
+ var optionalObject = (field, shape) => z.object(shape, { error: `${field} must be an object` }).nullable().optional();
1035
+ var optionalLooseObject = (field) => z.object({}, { error: `${field} must be an object` }).passthrough().nullable().optional();
1036
+ var CHANGE_MAP_NARRATOR_ENGINES = Object.freeze(["claude", "codex"]);
1037
+ var ChangeMapSettings = optionalObject("changeMap", { narrator: optionalObject("changeMap.narrator", {
1038
+ enabled: optionalBoolean("changeMap.narrator.enabled"),
1039
+ engine: z.enum(CHANGE_MAP_NARRATOR_ENGINES, { error: `changeMap.narrator.engine must be one of ${CHANGE_MAP_NARRATOR_ENGINES.join(", ")}` }).optional(),
1040
+ model: optionalString("changeMap.narrator.model", true),
1041
+ timeoutSeconds: optionalInteger("changeMap.narrator.timeoutSeconds", CHANGE_MAP_NARRATOR_TIMEOUT_RANGE)
1042
+ }) });
1043
+ var BRANCH_GC_SETTINGS_SHAPE = {
1044
+ enabled: optionalBoolean("branchGc.enabled"),
1045
+ worktrees: optionalBoolean("branchGc.worktrees"),
1046
+ prefixes: z.array(z.string({ error: "branchGc.prefixes must be an array of strings" }).min(1, { error: "branchGc.prefixes entries must be non-empty strings" }), { error: "branchGc.prefixes must be an array of strings" }).optional(),
1047
+ dryRun: optionalBoolean("branchGc.dryRun"),
1048
+ staleDays: optionalNumber("branchGc.staleDays", BRANCH_GC_STALE_DAYS_RANGE),
1049
+ deleteUnmerged: optionalBoolean("branchGc.deleteUnmerged"),
1050
+ intervalMs: optionalNumber("branchGc.intervalMs", BRANCH_GC_INTERVAL_MS_RANGE)
1051
+ };
1052
+ var BranchGcFileSettings = z.object(BRANCH_GC_SETTINGS_SHAPE, { error: "branchGc must be an object" });
1053
+ var BranchGcSettings = optionalObject("branchGc", BRANCH_GC_SETTINGS_SHAPE);
1054
+ var BranchGcControlSettings = BranchGcFileSettings.omit({
1055
+ prefixes: true,
1056
+ dryRun: true,
1057
+ worktrees: true
1058
+ }).nullable().optional();
1059
+ var BRANCH_GC_CONTROL_BOOLEAN_KEYS = Object.freeze(["enabled", "deleteUnmerged"]);
1060
+ var BRANCH_GC_CONTROL_NUMERIC_KEYS = Object.freeze(["staleDays", "intervalMs"]);
1061
+ var PostTurnChecksSettings = optionalObject("postTurnChecks", { mode: z.enum(["report", "fix"], { error: "postTurnChecks.mode must be one of report, fix" }).optional() });
1062
+ var VisionsSettings = optionalObject("visions", {
1063
+ enabled: optionalBoolean("visions.enabled"),
1064
+ autoFix: optionalBoolean("visions.autoFix"),
1065
+ projects: z.array(z.string({ error: "visions.projects must be an array of strings" }), { error: "visions.projects must be an array of strings" }).optional(),
1066
+ dispatch: optionalObject("visions.dispatch", {
1067
+ enabled: optionalBoolean("visions.dispatch.enabled"),
1068
+ model: optionalString("visions.dispatch.model", true),
1069
+ quietMs: optionalNumber("visions.dispatch.quietMs", VISIONS_QUIET_MS_RANGE),
1070
+ cooldownMs: optionalNumber("visions.dispatch.cooldownMs", VISIONS_COOLDOWN_MS_RANGE),
1071
+ maxPerHour: optionalNumber("visions.dispatch.maxPerHour", VISIONS_MAX_PER_HOUR_RANGE),
1072
+ activityMaxPerHour: optionalNumber("visions.dispatch.activityMaxPerHour", VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE),
1073
+ dispatchTimeoutSeconds: optionalNumber("visions.dispatch.dispatchTimeoutSeconds", VISIONS_DISPATCH_TIMEOUT_RANGE)
1074
+ }),
1075
+ intent: optionalObject("visions.intent", { threadTtlMs: optionalNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1076
+ });
1077
+ var TeamReviewSettings = optionalObject("teamReview", {
1078
+ enabled: optionalBoolean("teamReview.enabled"),
1079
+ autoRebaseMyPrs: optionalBoolean("teamReview.autoRebaseMyPrs"),
1080
+ keepMergeableEnabled: optionalBoolean("teamReview.keepMergeableEnabled"),
1081
+ mergeQueueEnabled: optionalBoolean("teamReview.mergeQueueEnabled"),
1082
+ keepMergeableTimeoutMinutes: optionalInteger("teamReview.keepMergeableTimeoutMinutes", KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE),
1083
+ org: optionalString("teamReview.org", true),
1084
+ team: optionalString("teamReview.team", true),
1085
+ skill: optionalString("teamReview.skill", true),
1086
+ reReviewAfterHours: optionalNumber("teamReview.reReviewAfterHours"),
1087
+ skipIdleAfterDays: optionalNumber("teamReview.skipIdleAfterDays")
1088
+ });
1089
+ var BenchmarksSettings = optionalObject("benchmarks", { enabled: optionalBoolean("benchmarks.enabled") });
1090
+ var posthogNumberRanges = {
1091
+ intervalMinutes: POSTHOG_INTERVAL_RANGE,
1092
+ maxConcurrentInvestigations: POSTHOG_MAX_CONCURRENT_RANGE,
1093
+ investigationTimeoutSeconds: POSTHOG_INVESTIGATION_TIMEOUT_RANGE,
1094
+ fixTimeoutSeconds: POSTHOG_FIX_TIMEOUT_RANGE,
1095
+ minUsersToInvestigate: POSTHOG_MIN_USERS_RANGE,
1096
+ userEscalationThreshold: POSTHOG_ESCALATION_RANGE,
1097
+ recurrenceWindowDays: POSTHOG_RECURRENCE_WINDOW_RANGE,
1098
+ transientRecurrenceLimit: POSTHOG_TRANSIENT_RECURRENCE_RANGE,
1099
+ trafficSpikeMultiplier: POSTHOG_TRAFFIC_MULTIPLIER_RANGE,
1100
+ trafficSpikeMinUsers: POSTHOG_TRAFFIC_MIN_USERS_RANGE,
1101
+ trafficSpikeCooldownMinutes: POSTHOG_TRAFFIC_COOLDOWN_RANGE,
1102
+ trafficSpikeBaselineDays: POSTHOG_TRAFFIC_BASELINE_RANGE
1103
+ };
1104
+ var PosthogSettings = optionalObject("posthog", {
1105
+ enabled: optionalBoolean("posthog.enabled"),
1106
+ recurrenceDedupe: optionalBoolean("posthog.recurrenceDedupe"),
1107
+ trafficSpikeEnabled: optionalBoolean("posthog.trafficSpikeEnabled"),
1108
+ autoFix: optionalBoolean("posthog.autoFix"),
1109
+ host: optionalString("posthog.host", true).refine((value) => value == null || !value || /^https?:\/\//i.test(value), { message: "posthog.host must be an http(s) URL" }),
1110
+ apiKey: optionalString("posthog.apiKey", true),
1111
+ repoPath: optionalString("posthog.repoPath", true),
1112
+ projects: z.union([z.literal("all"), z.array(z.number({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).int({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).positive({ error: "posthog.projects must be \"all\" or an array of positive integer project ids" }), { error: "posthog.projects must be \"all\" or an array of positive integer project ids" })], { error: "posthog.projects must be \"all\" or an array of positive integer project ids" }).optional(),
1113
+ projectMap: z.record(z.string(), z.unknown(), { error: "posthog.projectMap must be an object" }).optional(),
1114
+ ...Object.fromEntries(Object.entries(posthogNumberRanges).map(([key, range]) => [key, optionalNumber(`posthog.${key}`, range)]))
1115
+ });
1116
+ var usageCostModeMessage = `usage.costMode must be one of ${USAGE_COST_MODES.join(", ")}`;
1117
+ var usageVendorShape = Object.fromEntries(USAGE_VENDOR_KEYS.map((key) => [key, optionalBoolean(`usage.vendors.${key}`)]));
1118
+ var usageBudgetShape = Object.fromEntries(USAGE_BUDGET_KEYS.map((key) => [key, z.number({ error: `usage.budget.${key} must be a positive number or null` }).positive({ error: `usage.budget.${key} must be a positive number or null` }).nullable().optional()]));
1119
+ var createUsageSettings = (isAbsolutePath) => optionalObject("usage", {
1120
+ enabled: optionalBoolean("usage.enabled"),
1121
+ fetchPricing: optionalBoolean("usage.fetchPricing"),
1122
+ planLimits: optionalBoolean("usage.planLimits"),
1123
+ rtkSavings: optionalBoolean("usage.rtkSavings"),
1124
+ scanIntervalMinutes: optionalInteger("usage.scanIntervalMinutes", USAGE_INTEGER_RANGES.scanIntervalMinutes),
1125
+ retainDays: optionalInteger("usage.retainDays", USAGE_INTEGER_RANGES.retainDays),
1126
+ warehouseRetainDays: optionalInteger("usage.warehouseRetainDays", USAGE_INTEGER_RANGES.warehouseRetainDays),
1127
+ sessionBlockHours: optionalInteger("usage.sessionBlockHours", USAGE_INTEGER_RANGES.sessionBlockHours),
1128
+ costMode: z.enum(USAGE_COST_MODES, { error: usageCostModeMessage }).optional(),
1129
+ vendors: optionalObject("usage.vendors", usageVendorShape),
1130
+ budget: optionalObject("usage.budget", usageBudgetShape),
1131
+ extraProjectsDirs: z.array(z.string({ error: "usage.extraProjectsDirs must be an array of absolute paths" }), { error: "usage.extraProjectsDirs must be an array of absolute paths" }).transform((directories) => directories.map((directory) => directory.trim())).refine((directories) => directories.every((directory) => directory && isAbsolutePath(directory)), { message: "usage.extraProjectsDirs entries must be absolute paths" }).optional()
1132
+ });
1133
+ var TelegramSettings = optionalObject("telegram", {
1134
+ botToken: optionalString("telegram.botToken", true),
1135
+ chatId: optionalString("telegram.chatId", true)
1136
+ });
1137
+ var IngestSettings = z.object({ enabled: optionalBoolean("ingest.enabled") }, { error: "ingest must be an object" }).passthrough().optional();
1138
+ var TraceSettings = z.object({ enabled: optionalBoolean("trace.enabled") }, { error: "trace must be an object" }).optional();
1139
+ var PlanReviewSettings = z.object({ enabled: optionalBoolean("planReview.enabled") }, { error: "planReview must be an object" }).optional();
1140
+ var agentApiShape = { enabled: optionalBoolean("agentApi.enabled") };
1141
+ var AgentApiSettings = z.object(agentApiShape, { error: "agentApi must be an object" }).strict().optional();
1142
+ var AgentApiFileSettings = z.object(agentApiShape, { error: "agentApi must be an object" }).passthrough().optional();
1143
+ var telemetryShape = { enabled: optionalBoolean("telemetry.enabled") };
1144
+ var TelemetrySettings = z.object(telemetryShape, { error: "telemetry must be an object" }).strict().optional();
1145
+ var TelemetryFileSettings = z.object(telemetryShape, { error: "telemetry must be an object" }).passthrough().optional();
1146
+ var createBrowserConfigShape = (isAbsolutePath) => ({
1147
+ port: z.number().int().min(0).max(65535).optional(),
1148
+ autoRecoverSeconds: z.number().finite().nonnegative().optional(),
1149
+ inputGraceSeconds: z.number().finite().nonnegative().optional(),
1150
+ promptDetectionMs: z.number().finite().nonnegative().optional(),
1151
+ notifyDebounceMs: z.number().finite().nonnegative().optional(),
1152
+ phoneEscalationMs: z.number().finite().nonnegative().optional(),
1153
+ replayBufferKB: optionalNumber("replayBufferKB", {
1154
+ ...REPLAY_BUFFER_KB_RANGE,
1155
+ min: 0
1156
+ }),
1157
+ cursorBlink: optionalBoolean("cursorBlink"),
1158
+ debugMode: optionalBoolean("debugMode"),
1159
+ calmLayout: optionalBoolean("calmLayout"),
1160
+ detectBackgroundAgents: optionalBoolean("detectBackgroundAgents"),
1161
+ recordSignals: optionalBoolean("recordSignals"),
1162
+ antiSlopPrompt: optionalBoolean("antiSlopPrompt"),
1163
+ rtk: optionalBoolean("rtk"),
1164
+ skipPermissionsByDefault: optionalBoolean("skipPermissionsByDefault"),
1165
+ checkForUpdates: optionalBoolean("checkForUpdates"),
1166
+ updateChannel: z.enum(["release", "main"], { error: "updateChannel must be one of release, main" }).optional(),
1167
+ autoResume: optionalBoolean("autoResume"),
1168
+ telegramNotifications: optionalBoolean("telegramNotifications"),
1169
+ integrationBranch: optionalString("integrationBranch").nullable(),
1170
+ worktreeRoot: optionalString("worktreeRoot"),
1171
+ worktreeShare: z.array(z.string()).optional(),
1172
+ repoRoots: z.array(z.string()).optional(),
1173
+ changeMap: ChangeMapSettings,
1174
+ branchGc: BranchGcSettings,
1175
+ postTurnChecks: PostTurnChecksSettings,
1176
+ visions: VisionsSettings,
1177
+ teamReview: TeamReviewSettings,
1178
+ benchmarks: BenchmarksSettings,
1179
+ posthog: PosthogSettings,
1180
+ usage: createUsageSettings(isAbsolutePath),
1181
+ telegram: TelegramSettings,
1182
+ ingest: IngestSettings,
1183
+ agentApi: AgentApiSettings,
1184
+ telemetry: TelemetrySettings,
1185
+ workflows: WorkflowsSettings.nullable().optional()
1186
+ });
1187
+ var createBrowserConfig = (isAbsolutePath) => z.object(createBrowserConfigShape(isAbsolutePath));
1188
+ //#endregion
1189
+ //#region shared/contracts/config.ts
1190
+ var BrowserConfig = createBrowserConfig(path.isAbsolute);
1191
+ var BROWSER_CONFIG_SHAPE = BrowserConfig.shape;
1192
+ var ConfigUpdate = z.object({
1193
+ ...BROWSER_CONFIG_SHAPE,
1194
+ autoRecoverSeconds: z.number({ error: "autoRecoverSeconds must be a positive number" }).finite().positive({ error: "autoRecoverSeconds must be a positive number" }).optional(),
1195
+ inputGraceSeconds: z.number({ error: "inputGraceSeconds must be a positive number" }).finite().positive({ error: "inputGraceSeconds must be a positive number" }).optional(),
1196
+ promptDetectionMs: z.number({ error: "promptDetectionMs must be a positive number" }).finite().positive({ error: "promptDetectionMs must be a positive number" }).optional(),
1197
+ notifyDebounceMs: z.number({ error: "notifyDebounceMs must be a positive number" }).finite().positive({ error: "notifyDebounceMs must be a positive number" }).optional(),
1198
+ phoneEscalationMs: z.number({ error: "phoneEscalationMs must be a positive number" }).finite().positive({ error: "phoneEscalationMs must be a positive number" }).optional(),
1199
+ replayBufferKB: optionalNumber("replayBufferKB", REPLAY_BUFFER_KB_RANGE),
1200
+ branchGc: BranchGcControlSettings,
1201
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1202
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
1203
+ worktreeRerere: optionalBoolean("worktreeRerere"),
1204
+ workflows: WorkflowsSettingsUpdate.optional()
1205
+ }).omit({
1206
+ port: true,
1207
+ worktreeShare: true
1208
+ }).strict();
1209
+ var AGENT_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
1210
+ var BUILTIN_AGENT_IDS = Object.freeze([
1211
+ "claude-code",
1212
+ "codex",
1213
+ "grok"
1214
+ ]);
1215
+ var AGENT_ID_SHAPE_MESSAGE = "an agent id of 2 to 32 characters of lowercase letters, digits and dashes, starting with a letter";
1216
+ var AGENT_COMMAND_BASENAME_RE = /^[A-Za-z0-9._+-]+$/;
1217
+ var AGENT_COMMAND_ABSOLUTE_RE = /^(?:\/|[A-Za-z]:[\\/])[A-Za-z0-9._+\-\\/]*[A-Za-z0-9._+-]$/;
1218
+ var AGENT_COMMAND_SHAPE_MESSAGE = "a bare command name or an absolute path, built only from letters, digits, dot, underscore, plus, dash and path separators";
1219
+ function isSpawnableCommand(command) {
1220
+ if (AGENT_COMMAND_BASENAME_RE.test(command)) return true;
1221
+ return AGENT_COMMAND_ABSOLUTE_RE.test(command);
1222
+ }
1223
+ var CustomAgentDeclaration = z.object({
1224
+ id: z.string({ error: "customAgents[].id must be a string" }).regex(AGENT_ID_RE, { error: `customAgents[].id must be ${AGENT_ID_SHAPE_MESSAGE}` }),
1225
+ label: z.string({ error: "customAgents[].label must be a string" }).min(1, { error: "customAgents[].label must not be empty" }).max(60, { error: "customAgents[].label must be at most 60 characters" }),
1226
+ command: z.string({ error: "customAgents[].command must be a string" }).min(1, { error: "customAgents[].command must not be empty" }).refine((command) => command.trim().length > 0, { error: "customAgents[].command must not be blank" }).refine(isSpawnableCommand, { error: `customAgents[].command must be ${AGENT_COMMAND_SHAPE_MESSAGE}` }),
1227
+ args: z.array(z.string({ error: "customAgents[].args must be an array of strings" }), { error: "customAgents[].args must be an array of strings" }).default([]),
1228
+ idleTitle: z.string({ error: "customAgents[].idleTitle must be a string" }).optional(),
1229
+ busyTitle: z.string({ error: "customAgents[].busyTitle must be a string" }).optional()
1230
+ }).strict();
1231
+ var CustomAgentDeclarations = z.array(CustomAgentDeclaration, { error: "customAgents must be an array" }).superRefine((declarations, ctx) => {
1232
+ const claimedIds = new Set(BUILTIN_AGENT_IDS);
1233
+ for (const [index, declaration] of declarations.entries()) {
1234
+ if (!claimedIds.has(declaration.id)) {
1235
+ claimedIds.add(declaration.id);
1236
+ continue;
1237
+ }
1238
+ const message = BUILTIN_AGENT_IDS.some((builtinAgentId) => builtinAgentId === declaration.id) ? `customAgents[${index}].id "${declaration.id}" collides with the builtin agent of the same id` : `customAgents[${index}].id "${declaration.id}" is declared more than once`;
1239
+ ctx.addIssue({
1240
+ code: "custom",
1241
+ path: [index, "id"],
1242
+ message
1243
+ });
1244
+ }
1245
+ });
1246
+ var ProjectConfig = z.object({
1247
+ id: z.string().optional(),
1248
+ name: z.string().optional(),
1249
+ customTitle: TaskTitle.optional(),
1250
+ path: z.string(),
1251
+ repos: z.array(z.string()).min(2).optional(),
1252
+ agent: z.string({ error: "projects[].agent must be a string" }).regex(AGENT_ID_RE, { error: `projects[].agent must be ${AGENT_ID_SHAPE_MESSAGE}` }).optional(),
1253
+ codexBypassHookTrust: z.boolean().optional(),
1254
+ dangerouslySkipPermissions: z.boolean({ error: "projects[].dangerouslySkipPermissions must be a boolean" }).optional()
1255
+ }).passthrough();
1256
+ var FILE_CONFIG_SHAPE = {
1257
+ ...BROWSER_CONFIG_SHAPE,
1258
+ changeMap: ChangeMapSettings,
1259
+ branchGc: optionalLooseObject("branchGc"),
1260
+ visions: optionalLooseObject("visions"),
1261
+ teamReview: optionalLooseObject("teamReview"),
1262
+ benchmarks: optionalLooseObject("benchmarks"),
1263
+ posthog: optionalLooseObject("posthog"),
1264
+ usage: optionalLooseObject("usage"),
1265
+ telegram: optionalLooseObject("telegram"),
1266
+ ingest: optionalLooseObject("ingest"),
1267
+ workflows: optionalLooseObject("workflows"),
1268
+ agentApi: AgentApiFileSettings,
1269
+ telemetry: TelemetryFileSettings,
1270
+ trace: TraceSettings,
1271
+ planReview: PlanReviewSettings,
1272
+ customAgents: CustomAgentDeclarations.optional()
1273
+ };
1274
+ var Config = z.object({
1275
+ ...FILE_CONFIG_SHAPE,
1276
+ detectScheduledWakeups: optionalBoolean("detectScheduledWakeups"),
1277
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1278
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
1279
+ worktreeRerere: optionalBoolean("worktreeRerere"),
1280
+ postTurnChecks: z.record(z.string(), z.unknown()).optional(),
1281
+ hooks: z.unknown().optional(),
1282
+ remote: z.object({
1283
+ enabled: z.boolean().optional(),
1284
+ port: z.number().int().min(1).max(65535).nullable().optional(),
1285
+ publicHost: z.string().optional(),
1286
+ allowedOrigins: z.array(z.string()).optional()
1287
+ }).passthrough().optional(),
1288
+ projects: z.array(ProjectConfig)
1289
+ }).passthrough().superRefine((config, ctx) => {
1290
+ if (!Array.isArray(config.projects)) return;
1291
+ const declaredAgentIds = new Set(BUILTIN_AGENT_IDS);
1292
+ for (const declaration of config.customAgents ?? []) declaredAgentIds.add(declaration.id);
1293
+ for (const [index, project] of config.projects.entries()) {
1294
+ const agent = project?.agent;
1295
+ if (typeof agent !== "string" || !AGENT_ID_RE.test(agent)) continue;
1296
+ if (declaredAgentIds.has(agent)) continue;
1297
+ ctx.addIssue({
1298
+ code: "custom",
1299
+ path: [
1300
+ "projects",
1301
+ index,
1302
+ "agent"
1303
+ ],
1304
+ message: `projects[${index}].agent "${agent}" names no known agent; declare it under customAgents or use one of ${[...declaredAgentIds].join(", ")}`
1305
+ });
1306
+ }
1307
+ });
1308
+ Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE));
1309
+ var CONFIG_BLOCK_KEYS = Object.freeze([
1310
+ "changeMap",
1311
+ "branchGc",
1312
+ "postTurnChecks",
1313
+ "visions",
1314
+ "teamReview",
1315
+ "benchmarks",
1316
+ "posthog",
1317
+ "usage",
1318
+ "telegram",
1319
+ "ingest",
1320
+ "agentApi",
1321
+ "telemetry",
1322
+ "workflows"
1323
+ ]);
1324
+ var CONFIG_SCALAR_KEYS = Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE).filter((key) => {
1325
+ if (CONFIG_BLOCK_KEYS.includes(key)) return false;
1326
+ return key !== "port" && key !== "repoRoots" && key !== "worktreeShare";
1327
+ }));
1328
+ var RUNTIME_CONFIG_SCALAR_KEYS = Object.freeze([
1329
+ ...CONFIG_SCALAR_KEYS,
1330
+ "worktreeAutoRebase",
1331
+ "worktreeSyncOnStart",
1332
+ "worktreeRerere"
1333
+ ]);
1334
+ Object.freeze([
1335
+ "detectScheduledWakeups",
1336
+ "worktreeAutoRebase",
1337
+ "worktreeSyncOnStart",
1338
+ "worktreeRerere",
1339
+ "hooks",
1340
+ "remote",
1341
+ "projects"
1342
+ ]);
1343
+ function configIssueMessage(error) {
1344
+ return error.issues[0]?.message || "settings are invalid";
1345
+ }
1346
+ //#endregion
1347
+ //#region shared/contracts/telemetry.ts
1348
+ var TELEMETRY_ADAPTERS = Object.freeze([...BUILTIN_AGENT_IDS, "custom"]);
1349
+ var SESSION_EXIT_KINDS = Object.freeze([
1350
+ "clean",
1351
+ "error",
1352
+ "signal",
1353
+ "no_output"
1354
+ ]);
1355
+ var nonNegativeInteger = z.number().int().nonnegative();
1356
+ var boundedText = z.string().max(512);
1357
+ var AppStartedProperties = z.object({}).strict();
1358
+ var AppActiveProperties = z.object({ active_session_count: nonNegativeInteger }).strict();
1359
+ var SessionStartedProperties = z.object({ adapter: z.enum(TELEMETRY_ADAPTERS) }).strict();
1360
+ var SessionEndedProperties = z.object({
1361
+ adapter: z.enum(TELEMETRY_ADAPTERS),
1362
+ exit_kind: z.enum(SESSION_EXIT_KINDS),
1363
+ duration_seconds: nonNegativeInteger
1364
+ }).strict();
1365
+ var ExceptionFrame = z.object({
1366
+ platform: z.enum(["node:javascript", "web:javascript"]),
1367
+ function: boundedText,
1368
+ filename: boundedText,
1369
+ lineno: nonNegativeInteger,
1370
+ colno: nonNegativeInteger,
1371
+ in_app: z.boolean()
1372
+ }).strict();
1373
+ var ExceptionProperties = z.object({
1374
+ $exception_list: z.array(z.object({
1375
+ type: boundedText,
1376
+ value: boundedText,
1377
+ mechanism: z.object({
1378
+ handled: z.boolean(),
1379
+ synthetic: z.boolean(),
1380
+ type: z.literal("generic")
1381
+ }).strict(),
1382
+ stacktrace: z.object({
1383
+ type: z.literal("raw"),
1384
+ frames: z.array(ExceptionFrame).max(64)
1385
+ }).strict()
1386
+ }).strict()).length(1),
1387
+ $exception_level: z.enum(["error", "fatal"])
1388
+ }).strict();
1389
+ var AiGenerationProperties = z.object({
1390
+ $ai_trace_id: z.string().regex(/^[0-9a-f]{64}$/),
1391
+ $ai_provider: z.string().max(64),
1392
+ $ai_model: z.string().max(128),
1393
+ $ai_input_tokens: nonNegativeInteger,
1394
+ $ai_output_tokens: nonNegativeInteger,
1395
+ $ai_cache_read_input_tokens: nonNegativeInteger.optional(),
1396
+ $ai_cache_creation_input_tokens: nonNegativeInteger.optional(),
1397
+ $ai_total_cost_usd: z.number().finite().nonnegative().optional(),
1398
+ agent_adapter: z.enum(TELEMETRY_ADAPTERS)
1399
+ }).strict();
1400
+ var TELEMETRY_EVENT_SCHEMAS = Object.freeze({
1401
+ app_started: AppStartedProperties,
1402
+ app_active: AppActiveProperties,
1403
+ session_started: SessionStartedProperties,
1404
+ session_ended: SessionEndedProperties,
1405
+ $exception: ExceptionProperties,
1406
+ $ai_generation: AiGenerationProperties
1407
+ });
1408
+ Object.freeze([
1409
+ {
1410
+ name: "app_started",
1411
+ description: "The server started listening."
1412
+ },
1413
+ {
1414
+ name: "app_active",
1415
+ description: "Once a day while the server runs, with how many sessions are live."
1416
+ },
1417
+ {
1418
+ name: "session_started",
1419
+ description: "A session spawned, with which kind of agent (any custom agent counts as `custom`)."
1420
+ },
1421
+ {
1422
+ name: "session_ended",
1423
+ description: "A session exited: how it exited and how long it ran, in whole seconds."
1424
+ },
1425
+ {
1426
+ name: "$exception",
1427
+ description: "An error in the server or the dashboard: its type, an error code when it has one, and stack frames with file paths cut to the package or URL path. Never the error message. Each distinct error is sent once per run, and a crash is sent on the next start."
1428
+ },
1429
+ {
1430
+ name: "$ai_generation",
1431
+ description: "Per agent session and model, after each usage scan, for usage recorded in the last 24 hours: token counts, the model name and estimated cost, under a one-way hash of the session. A model name outside the shipped pricing table is sent as unknown. No prompts or output."
1432
+ }
1433
+ ]);
1434
+ Object.freeze([
1435
+ "app_version",
1436
+ "os_platform",
1437
+ "node_major",
1438
+ "install_flavor",
1439
+ "is_bundled",
1440
+ "is_dev_install"
1441
+ ]);
1442
+ Object.freeze(["$release_id"]);
1443
+ var TELEMETRY_KILL_SWITCH_FLAG = "telemetry-enabled";
1444
+ var FeatureFlagsResponse = z.object({
1445
+ flags: z.object({ [TELEMETRY_KILL_SWITCH_FLAG]: z.object({ enabled: z.boolean() }).passthrough().optional() }).passthrough(),
1446
+ errorsWhileComputingFlags: z.boolean().optional()
1447
+ }).passthrough();
1448
+ var PendingCrashReport = z.object({
1449
+ timestamp: z.string(),
1450
+ properties: ExceptionProperties
1451
+ }).strict();
1452
+ var TelemetryState = z.object({
1453
+ installId: z.uuid(),
1454
+ noticeShownAt: z.string().nullable().optional(),
1455
+ remoteDisabled: z.boolean().optional()
1456
+ });
1457
+ //#endregion
1458
+ //#region shared/contracts/benchmark.ts
1459
+ var BENCHMARK_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
1460
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
1461
+ var repoSlug = z.string().regex(/^[^/\s]+\/[^/\s]+$/);
1462
+ var timestamp$1 = z.number().finite();
1463
+ var nonEmptyText = z.string().min(1);
1464
+ var BENCHMARK_INJECTED_ENV_NAMES = Object.freeze(["CLAUDE_CODE_OAUTH_TOKEN"]);
1465
+ Object.freeze(["human", "bot"]);
1466
+ var BenchmarkId = z.string().regex(BENCHMARK_ID_RE);
1467
+ function hasUniqueIds(entries) {
1468
+ return new Set(entries.map((entry) => entry.id)).size === entries.length;
1469
+ }
1470
+ var BenchmarkCaseSource = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("manual") }), z.strictObject({
1471
+ kind: z.literal("github-merged-prs"),
1472
+ repo: repoSlug,
1473
+ minBodies: z.number().int().min(1),
1474
+ limit: z.number().int().min(1).max(500)
1475
+ })]);
1476
+ var BenchmarkWorkspace = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("none") }), z.strictObject({ kind: z.literal("pr-checkout") })]);
1477
+ var BenchmarkSubjectOutput = z.enum(["review-findings", "json"]);
1478
+ var BenchmarkSubject = z.strictObject({
1479
+ promptTemplate: nonEmptyText,
1480
+ output: BenchmarkSubjectOutput,
1481
+ timeoutSeconds: z.number().int().min(30).max(14400)
1482
+ });
1483
+ var BenchmarkArm = z.strictObject({
1484
+ id: BenchmarkId,
1485
+ env: z.record(z.string().regex(ENV_NAME_RE), z.string()).refine((env) => BENCHMARK_INJECTED_ENV_NAMES.every((name) => !Object.hasOwn(env, name)), { message: `arm env must not set ${BENCHMARK_INJECTED_ENV_NAMES.join(", ")}; Glimmervoid injects it per cell` }).optional(),
1486
+ extraArgs: z.array(z.string()).optional(),
1487
+ setup: z.strictObject({ command: z.array(nonEmptyText).min(1) }).optional()
1488
+ });
1489
+ var BenchmarkScorer = z.discriminatedUnion("kind", [z.strictObject({
1490
+ kind: z.literal("llm-judge-match"),
1491
+ model: nonEmptyText
1492
+ })]);
1493
+ var BenchmarkSuite = z.strictObject({
1494
+ id: BenchmarkId,
1495
+ title: nonEmptyText,
1496
+ caseSource: BenchmarkCaseSource,
1497
+ workspace: BenchmarkWorkspace,
1498
+ subject: BenchmarkSubject,
1499
+ arms: z.array(BenchmarkArm).min(2).refine(hasUniqueIds, { message: "arm ids must be unique" }),
1500
+ baselineArm: BenchmarkId,
1501
+ trials: z.number().int().min(1).max(20),
1502
+ scorer: BenchmarkScorer
1503
+ }).refine((suite) => suite.arms.some((arm) => arm.id === suite.baselineArm), {
1504
+ message: "baselineArm must name one of the arms",
1505
+ path: ["baselineArm"]
1506
+ });
1507
+ var BenchmarkReference = z.strictObject({
1508
+ id: BenchmarkId,
1509
+ text: nonEmptyText,
1510
+ tags: z.array(BenchmarkId),
1511
+ path: nonEmptyText.optional(),
1512
+ line: z.number().int().positive().optional()
1513
+ });
1514
+ var BenchmarkCaseOrigin = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("manual") }), z.strictObject({
1515
+ kind: z.literal("github-pr"),
1516
+ repo: repoSlug,
1517
+ number: z.number().int().positive(),
1518
+ url: nonEmptyText,
1519
+ minedAt: timestamp$1
1520
+ })]);
1521
+ var BenchmarkCase = z.strictObject({
1522
+ id: BenchmarkId,
1523
+ input: z.record(z.string(), z.unknown()),
1524
+ references: z.array(BenchmarkReference).min(1).refine(hasUniqueIds, { message: "reference ids must be unique" }),
1525
+ source: BenchmarkCaseOrigin
1526
+ });
1527
+ var PrCheckoutCaseInput = z.object({
1528
+ repo: repoSlug,
1529
+ number: z.number().int().positive(),
1530
+ reviewedSha: CommitSha,
1531
+ baseSha: CommitSha,
1532
+ changedFiles: z.array(nonEmptyText)
1533
+ });
1534
+ var BenchmarkMatchVerdict = z.enum([
1535
+ "found",
1536
+ "partial",
1537
+ "missed"
1538
+ ]);
1539
+ var BenchmarkJudgement = z.strictObject({
1540
+ referenceId: BenchmarkId,
1541
+ verdict: BenchmarkMatchVerdict,
1542
+ findingIndexes: z.array(z.number().int().nonnegative())
1543
+ });
1544
+ var BenchmarkCellStatus = z.enum([
1545
+ "scored",
1546
+ "invalid",
1547
+ "error"
1548
+ ]);
1549
+ var BenchmarkCellResult = z.strictObject({
1550
+ caseId: BenchmarkId,
1551
+ armId: BenchmarkId,
1552
+ trial: z.number().int().min(1),
1553
+ status: BenchmarkCellStatus,
1554
+ startedAt: timestamp$1,
1555
+ finishedAt: timestamp$1,
1556
+ degradedReasons: z.array(nonEmptyText),
1557
+ findingCount: z.number().int().nonnegative(),
1558
+ judgements: z.array(BenchmarkJudgement),
1559
+ costUsd: z.number().finite().nonnegative().nullable(),
1560
+ error: nonEmptyText.nullable()
1561
+ });
1562
+ var BenchmarkRunStatus = z.enum([
1563
+ "running",
1564
+ "completed",
1565
+ "interrupted",
1566
+ "failed"
1567
+ ]);
1568
+ var BenchmarkRun = z.strictObject({
1569
+ id: BenchmarkId,
1570
+ suiteId: BenchmarkId,
1571
+ status: BenchmarkRunStatus,
1572
+ startedAt: timestamp$1,
1573
+ finishedAt: timestamp$1.nullable(),
1574
+ error: nonEmptyText.nullable(),
1575
+ cells: z.array(BenchmarkCellResult)
1576
+ });
1577
+ var nullableRatio = z.number().min(0).max(1).nullable();
1578
+ var BenchmarkArmScore = z.strictObject({
1579
+ trials: z.number().int().nonnegative(),
1580
+ recall: nullableRatio,
1581
+ recallByTag: z.record(BenchmarkId, nullableRatio),
1582
+ degraded: z.number().int().nonnegative(),
1583
+ invalid: z.number().int().nonnegative(),
1584
+ costUsd: z.number().finite().nonnegative().nullable()
1585
+ });
1586
+ var BenchmarkReportRow = z.strictObject({
1587
+ caseId: BenchmarkId,
1588
+ arms: z.record(BenchmarkId, BenchmarkArmScore),
1589
+ deltaVsBaseline: z.record(BenchmarkId, z.number().min(-1).max(1).nullable())
1590
+ });
1591
+ var BenchmarkReport = z.strictObject({
1592
+ runId: BenchmarkId,
1593
+ suiteId: BenchmarkId,
1594
+ status: BenchmarkRunStatus,
1595
+ baselineArm: BenchmarkId,
1596
+ armIds: z.array(BenchmarkId),
1597
+ rows: z.array(BenchmarkReportRow),
1598
+ totals: z.record(BenchmarkId, BenchmarkArmScore)
1599
+ });
1600
+ var BenchmarkAction = z.enum([
1601
+ "mine",
1602
+ "run",
1603
+ "cancel"
1604
+ ]);
1605
+ var BenchmarkActionRequest = z.object({
1606
+ suiteId: BenchmarkId,
1607
+ action: BenchmarkAction
1608
+ });
1609
+ var BenchmarkActionResult = z.object({
1610
+ suiteId: BenchmarkId,
1611
+ action: BenchmarkAction,
1612
+ ok: z.boolean(),
1613
+ error: z.string().optional(),
1614
+ runId: BenchmarkId.optional()
1615
+ });
1616
+ var BenchmarkCellPhase = z.enum([
1617
+ "setup",
1618
+ "preflight",
1619
+ "workspace",
1620
+ "subject",
1621
+ "judge"
1622
+ ]);
1623
+ var BenchmarkInFlightCell = z.object({
1624
+ suiteId: BenchmarkId,
1625
+ runId: BenchmarkId,
1626
+ caseId: BenchmarkId.nullable(),
1627
+ armId: BenchmarkId,
1628
+ trial: z.number().int().min(1),
1629
+ phase: BenchmarkCellPhase,
1630
+ cellIndex: z.number().int().nonnegative(),
1631
+ cellCount: z.number().int().positive(),
1632
+ startedAt: timestamp$1
1633
+ });
1634
+ var BenchmarkSuiteSummary = z.object({
1635
+ id: BenchmarkId,
1636
+ title: z.string(),
1637
+ error: z.string().nullable(),
1638
+ caseCount: z.number().int().nonnegative(),
1639
+ candidateCount: z.number().int().nonnegative(),
1640
+ armIds: z.array(BenchmarkId),
1641
+ baselineArm: BenchmarkId.nullable(),
1642
+ latestReport: BenchmarkReport.nullable()
1643
+ });
1644
+ var BenchmarkStatus = z.object({
1645
+ type: z.literal("benchmark-status"),
1646
+ ts: timestamp$1,
1647
+ configured: z.boolean(),
1648
+ reason: z.string().nullable(),
1649
+ suites: z.array(BenchmarkSuiteSummary),
1650
+ inFlight: BenchmarkInFlightCell.nullable()
1651
+ }).passthrough();
1652
+ var githubAuthor = z.object({
1653
+ __typename: z.string(),
1654
+ login: z.string()
1655
+ }).nullable();
1656
+ var MergedPrListing = z.object({
1657
+ number: z.number().int().positive(),
1658
+ title: z.string(),
1659
+ url: nonEmptyText,
1660
+ mergedAt: z.string().nullable(),
1661
+ reviewThreads: z.object({ totalCount: z.number().int().nonnegative() }),
1662
+ reviews: z.object({ totalCount: z.number().int().nonnegative() })
1663
+ });
1664
+ var MinedReviewThread = z.object({
1665
+ path: z.string(),
1666
+ line: z.number().int().positive().nullable(),
1667
+ originalLine: z.number().int().positive().nullable(),
1668
+ comments: z.object({ nodes: z.array(z.object({
1669
+ databaseId: z.number().int().positive(),
1670
+ author: githubAuthor,
1671
+ body: z.string(),
1672
+ createdAt: z.string(),
1673
+ originalCommit: z.object({ oid: CommitSha }).nullable()
1674
+ })) })
1675
+ });
1676
+ var MinedReview = z.object({
1677
+ databaseId: z.number().int().positive(),
1678
+ author: githubAuthor,
1679
+ body: z.string(),
1680
+ submittedAt: z.string().nullable(),
1681
+ commit: z.object({ oid: CommitSha }).nullable()
1682
+ });
1683
+ var MinedBaseEvent = z.discriminatedUnion("__typename", [z.object({
1684
+ __typename: z.literal("BaseRefChangedEvent"),
1685
+ createdAt: z.string()
1686
+ }), z.object({
1687
+ __typename: z.literal("BaseRefForcePushedEvent"),
1688
+ createdAt: z.string(),
1689
+ beforeCommit: z.object({ oid: CommitSha }).nullable()
1690
+ })]);
1691
+ var MinedPrReviewData = z.object({
1692
+ author: githubAuthor,
1693
+ baseRefOid: CommitSha,
1694
+ reviewThreads: z.object({
1695
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1696
+ nodes: z.array(MinedReviewThread)
1697
+ }),
1698
+ reviews: z.object({
1699
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1700
+ nodes: z.array(MinedReview)
1701
+ }),
1702
+ timelineItems: z.object({
1703
+ pageInfo: z.object({ hasNextPage: z.boolean() }),
1704
+ nodes: z.array(MinedBaseEvent)
1705
+ })
1706
+ });
1707
+ var CommitComparison = z.object({
1708
+ mergeBaseSha: CommitSha,
1709
+ changedFiles: z.array(nonEmptyText),
1710
+ isFileListComplete: z.boolean()
1711
+ });
1712
+ Object.freeze([
1713
+ "file",
1714
+ "subsystem",
1715
+ "co-change",
1716
+ "hotspot",
1717
+ "blast",
1718
+ "untested",
1719
+ "collision",
1720
+ "link"
1721
+ ]);
1722
+ function changeMapFactId(kind, repoName, ...parts) {
1723
+ return [
1724
+ kind,
1725
+ repoName,
1726
+ ...parts
1727
+ ].join(":");
1728
+ }
1729
+ var factId = z.string().min(1);
1730
+ var repoPath = z.string().min(1);
1731
+ var count = z.number().int().nonnegative();
1732
+ var cappedPaths = z.array(repoPath).max(20);
1733
+ var ChangedFileStatus = z.enum([
1734
+ "added",
1735
+ "modified",
1736
+ "deleted",
1737
+ "renamed",
1738
+ "untracked"
1739
+ ]);
1740
+ var ChangedFile = z.strictObject({
1741
+ factId,
1742
+ path: repoPath,
1743
+ previousPath: repoPath.optional(),
1744
+ status: ChangedFileStatus,
1745
+ isCommitted: z.boolean()
1746
+ });
1747
+ var SubsystemFact = z.strictObject({
1748
+ factId,
1749
+ agentsPath: repoPath,
1750
+ title: z.string(),
1751
+ paths: z.array(repoPath).min(1)
1752
+ });
1753
+ var CoChangeGap = z.strictObject({
1754
+ factId,
1755
+ path: repoPath,
1756
+ partner: repoPath,
1757
+ support: count,
1758
+ confidence: z.number().min(0).max(1)
1759
+ });
1760
+ var HotspotFact = z.strictObject({
1761
+ factId,
1762
+ path: repoPath,
1763
+ commitCount: count,
1764
+ fixCommitCount: count
1765
+ });
1766
+ var BlastRadiusFact = z.strictObject({
1767
+ factId,
1768
+ path: repoPath,
1769
+ directDependents: cappedPaths,
1770
+ directDependentCount: count,
1771
+ transitiveDependentCount: count,
1772
+ dependentTests: cappedPaths,
1773
+ dependentTestCount: count
1774
+ });
1775
+ var UntestedFileFact = z.strictObject({
1776
+ factId,
1777
+ path: repoPath
1778
+ });
1779
+ var CollisionFact = z.strictObject({
1780
+ factId,
1781
+ path: repoPath,
1782
+ otherSessionId: z.string().min(1),
1783
+ otherSessionName: z.string()
1784
+ });
1785
+ var CrossRepoLink = z.strictObject({
1786
+ factId,
1787
+ providerRepo: z.string().min(1),
1788
+ packageName: z.string().min(1),
1789
+ packageDir: z.string(),
1790
+ consumerManifest: repoPath,
1791
+ versionSpec: z.string(),
1792
+ isLocalLink: z.boolean(),
1793
+ providerChangedPathCount: count,
1794
+ importers: cappedPaths,
1795
+ importerCount: count,
1796
+ changedImporterCount: count
1797
+ });
1798
+ var RepoChangeMap = z.strictObject({
1799
+ name: z.string().min(1),
1800
+ root: z.string().min(1),
1801
+ sessionPathPrefix: z.string(),
1802
+ base: z.string().nullable(),
1803
+ files: z.array(ChangedFile),
1804
+ subsystems: z.array(SubsystemFact),
1805
+ coChangeGaps: z.array(CoChangeGap),
1806
+ hotspots: z.array(HotspotFact),
1807
+ blastRadius: z.array(BlastRadiusFact),
1808
+ untestedFiles: z.array(UntestedFileFact),
1809
+ collisions: z.array(CollisionFact),
1810
+ links: z.array(CrossRepoLink),
1811
+ error: z.string().nullable()
1812
+ });
1813
+ var NarrativeClaim = z.strictObject({
1814
+ text: z.string().min(1).max(600),
1815
+ factIds: z.array(factId).min(1)
1816
+ });
1817
+ var ChangeNarrative = z.strictObject({
1818
+ factsHash: z.string().min(1),
1819
+ model: z.string().nullable(),
1820
+ claims: z.array(NarrativeClaim).max(12)
1821
+ });
1822
+ var NarratorState = z.enum([
1823
+ "disabled",
1824
+ "pending",
1825
+ "ready",
1826
+ "failed"
1827
+ ]);
1828
+ var ChangeMap = z.strictObject({
1829
+ sessionId: z.string().min(1),
1830
+ sig: z.string().nullable(),
1831
+ generatedAt: z.number().finite(),
1832
+ repos: z.array(RepoChangeMap),
1833
+ narrative: ChangeNarrative.nullable(),
1834
+ narratorState: NarratorState,
1835
+ error: z.string().min(1).optional()
1836
+ });
1837
+ var PLAN_FEEDBACK_MAX_CHARS = 2e4;
1838
+ var PLAN_COMMENT_MAX_CHARS = 4e3;
1839
+ var PLAN_BODY_CAP_BYTES = 524288;
1840
+ var PLAN_HOOK_OUTPUT_MAX_CHARS = 1e4;
1841
+ var PLAN_HOOK_EVENT = "permissionrequest-plan";
1842
+ var PLAN_RESULT_HOOK_EVENT = "posttooluse-plan";
1843
+ var PLAN_TOOL_NAME = "ExitPlanMode";
1844
+ var HEADING_SCAN_MAX_CHARS = 4096;
1845
+ var ATX_HEADING = /^ {0,3}#{1,6}[ \t]+(.*)$/;
1846
+ function capPlanTitle(text) {
1847
+ const trimmed = text.trim();
1848
+ if (trimmed.length <= 120) return trimmed;
1849
+ return trimmed.slice(0, 120);
1850
+ }
1851
+ function withoutClosingHeadingMarks(text) {
1852
+ const trimmed = text.trimEnd();
1853
+ let textEnd = trimmed.length;
1854
+ while (textEnd > 0 && trimmed[textEnd - 1] === "#") textEnd--;
1855
+ if (textEnd === trimmed.length || textEnd === 0) return trimmed;
1856
+ const charBeforeMarks = trimmed[textEnd - 1];
1857
+ if (charBeforeMarks !== " " && charBeforeMarks !== " ") return trimmed;
1858
+ return trimmed.slice(0, textEnd).trimEnd();
1859
+ }
1860
+ function headingTitle(line) {
1861
+ const heading = ATX_HEADING.exec(line.slice(0, HEADING_SCAN_MAX_CHARS));
1862
+ if (!heading) return "";
1863
+ return withoutClosingHeadingMarks(heading[1]);
1864
+ }
1865
+ function planTitle(plan) {
1866
+ const lines = typeof plan === "string" ? plan.split(/\r?\n/) : [];
1867
+ for (const line of lines) {
1868
+ const title = headingTitle(line);
1869
+ if (title.length > 0) return capPlanTitle(title);
1870
+ }
1871
+ return capPlanTitle(lines.find((line) => line.trim().length > 0) ?? "");
1872
+ }
1873
+ var ExitPlanModeInput = z.object({
1874
+ plan: z.string().min(1),
1875
+ planFilePath: z.string().min(1),
1876
+ agent_id: z.string().min(1).optional(),
1877
+ agent_type: z.string().min(1).optional()
1878
+ }).passthrough();
1879
+ var ExitPlanModeHookPayload = z.object({
1880
+ tool_name: z.literal(PLAN_TOOL_NAME),
1881
+ tool_input: ExitPlanModeInput,
1882
+ agent_id: z.string().min(1).optional(),
1883
+ agent_type: z.string().min(1).optional()
1884
+ }).passthrough();
1885
+ var ExitPlanModeRequest = z.object({
1886
+ plan: z.string(),
1887
+ planFilePath: z.string(),
1888
+ agentId: z.string().nullable(),
1889
+ agentType: z.string().nullable()
1890
+ });
1891
+ function parseExitPlanModeHookPayload(body) {
1892
+ const parsed = ExitPlanModeHookPayload.safeParse(body);
1893
+ if (!parsed.success) return null;
1894
+ const input = parsed.data.tool_input;
1895
+ return {
1896
+ plan: input.plan,
1897
+ planFilePath: input.planFilePath,
1898
+ agentId: parsed.data.agent_id ?? input.agent_id ?? null,
1899
+ agentType: parsed.data.agent_type ?? input.agent_type ?? null
1900
+ };
1901
+ }
1902
+ var PlanRevision = ExitPlanModeRequest.extend({
1903
+ sessionId: z.string().min(1),
1904
+ revision: z.number().int().positive(),
1905
+ receivedAt: z.number().finite()
1906
+ });
1907
+ var PLAN_REVIEW_STATE_VALUES = Object.freeze([
1908
+ "open",
1909
+ "released",
1910
+ "decided",
1911
+ "closed"
1912
+ ]);
1913
+ var PlanReviewStateValue = z.enum(PLAN_REVIEW_STATE_VALUES);
1914
+ var PLAN_DECISION_KINDS = Object.freeze([
1915
+ "approve",
1916
+ "approve-accept-edits",
1917
+ "revise",
1918
+ "terminal"
1919
+ ]);
1920
+ var PlanDecisionKind = z.enum(PLAN_DECISION_KINDS);
1921
+ var PlanSectionComment = z.object({
1922
+ heading: z.string().max(PLAN_COMMENT_MAX_CHARS).nullable(),
1923
+ comment: z.string().min(1).max(PLAN_COMMENT_MAX_CHARS)
1924
+ });
1925
+ var PlanDecision = z.object({
1926
+ id: z.string().min(1),
1927
+ agentId: z.string().nullable(),
1928
+ revision: z.number().int().positive(),
1929
+ decision: PlanDecisionKind,
1930
+ feedback: z.string().max(PLAN_FEEDBACK_MAX_CHARS).optional(),
1931
+ comments: z.array(PlanSectionComment).max(40).optional(),
1932
+ plan: z.string().min(1).max(PLAN_BODY_CAP_BYTES).optional()
1933
+ });
1934
+ var PlanRevisionSummary = z.object({
1935
+ revision: z.number().int().positive(),
1936
+ receivedAt: z.number().finite(),
1937
+ chars: z.number().int().nonnegative(),
1938
+ title: z.string()
1939
+ });
1940
+ var PlanReviewOpenRevision = z.object({
1941
+ revision: z.number().int().positive(),
1942
+ since: z.number().finite()
1943
+ });
1944
+ var PlanReview = z.object({
1945
+ agentId: z.string().nullable(),
1946
+ agentType: z.string().nullable(),
1947
+ revisions: z.array(PlanRevisionSummary),
1948
+ state: PlanReviewStateValue,
1949
+ openRevision: PlanReviewOpenRevision.nullable(),
1950
+ approvedRevision: z.number().int().positive().nullable(),
1951
+ lastDecision: PlanDecisionKind.nullable()
1952
+ });
1953
+ z.object({ reviews: z.array(PlanReview) });
1954
+ var PlanRevisionBody = z.object({
1955
+ agentId: z.string().nullable(),
1956
+ revision: z.number().int().nonnegative(),
1957
+ plan: z.string(),
1958
+ planFilePath: z.string(),
1959
+ receivedAt: z.number().finite()
1960
+ });
1961
+ var PlanChangedPush = z.object({
1962
+ id: z.string(),
1963
+ agentId: z.string().nullable(),
1964
+ agentType: z.string().nullable(),
1965
+ revision: z.number().int().positive(),
1966
+ receivedAt: z.number().finite(),
1967
+ state: PlanReviewStateValue,
1968
+ lastDecision: PlanDecisionKind.nullable(),
1969
+ approvedRevision: z.number().int().positive().nullable(),
1970
+ chars: z.number().int().nonnegative(),
1971
+ title: z.string(),
1972
+ hasPlan: z.boolean()
1973
+ });
1974
+ var PlanDraftPush = z.object({
1975
+ id: z.string(),
1976
+ agentId: z.string().nullable(),
1977
+ planFilePath: z.string(),
1978
+ changedAt: z.number().finite()
1979
+ });
1980
+ var PlanResponseFrame = z.object({
1981
+ id: z.string(),
1982
+ reviews: z.array(PlanReview),
1983
+ body: PlanRevisionBody.nullable()
1984
+ });
1985
+ //#endregion
1986
+ //#region shared/contracts/trace.ts
1987
+ var MAX_RAW_LINE_CHARS = 4e3;
1988
+ var TraceRecordBase = z.object({
1989
+ ts: z.number().finite(),
1990
+ uuid: z.string().nullable(),
1991
+ parentUuid: z.string().nullable(),
1992
+ vendorSessionId: z.string().min(1),
1993
+ agentId: z.string().min(1).optional(),
1994
+ agentType: z.string().min(1).optional(),
1995
+ transcriptOffset: z.number().int().nonnegative().optional(),
1996
+ truncated: z.boolean().optional()
1997
+ });
1998
+ var TraceRecord = z.discriminatedUnion("kind", [
1999
+ TraceRecordBase.extend({
2000
+ kind: z.literal("prompt"),
2001
+ text: z.string()
2002
+ }),
2003
+ TraceRecordBase.extend({
2004
+ kind: z.literal("expansion"),
2005
+ text: z.string(),
2006
+ toolUseId: z.string().min(1).optional()
2007
+ }),
2008
+ TraceRecordBase.extend({
2009
+ kind: z.literal("thinking"),
2010
+ text: z.string()
2011
+ }),
2012
+ TraceRecordBase.extend({
2013
+ kind: z.literal("assistant"),
2014
+ text: z.string()
2015
+ }),
2016
+ TraceRecordBase.extend({
2017
+ kind: z.literal("tool_call"),
2018
+ toolUseId: z.string().min(1),
2019
+ name: z.string().min(1),
2020
+ input: z.unknown()
2021
+ }),
2022
+ TraceRecordBase.extend({
2023
+ kind: z.literal("tool_result"),
2024
+ toolUseId: z.string().min(1),
2025
+ content: z.string(),
2026
+ isError: z.boolean(),
2027
+ truncated: z.boolean()
2028
+ }),
2029
+ TraceRecordBase.extend({
2030
+ kind: z.literal("session"),
2031
+ vendor: z.string().min(1),
2032
+ transcriptPath: z.string().min(1),
2033
+ reason: z.string().min(1).optional()
2034
+ }),
2035
+ TraceRecordBase.extend({
2036
+ kind: z.literal("notice"),
2037
+ text: z.string().max(MAX_RAW_LINE_CHARS)
2038
+ }),
2039
+ TraceRecordBase.extend({
2040
+ kind: z.literal("raw"),
2041
+ line: z.string().max(MAX_RAW_LINE_CHARS)
2042
+ })
2043
+ ]);
2044
+ var TraceCheckpoint = z.object({
2045
+ transcriptPath: z.string().min(1),
2046
+ vendorSessionId: z.string().min(1),
2047
+ offset: z.number().int().nonnegative(),
2048
+ ingestedSubagentPaths: z.array(z.string().min(1)),
2049
+ offsetByTranscriptPath: z.record(z.string().min(1), z.number().int().nonnegative()).default({}),
2050
+ subagentOffsetByPath: z.record(z.string().min(1), z.number().int().nonnegative()).default({})
2051
+ });
2052
+ //#endregion
2053
+ //#region shared/contracts/update-journal.ts
2054
+ var UpdateChannel = z.enum(["release", "main"]);
2055
+ var UpdateRunState = z.enum([
2056
+ "idle",
2057
+ "running",
2058
+ "staged",
2059
+ "succeeded",
2060
+ "failed",
2061
+ "discarded",
2062
+ "interrupted"
2063
+ ]);
2064
+ var UpdateStepId = z.enum([
2065
+ "fetch",
2066
+ "stage",
2067
+ "install",
2068
+ "link-deps",
2069
+ "build"
2070
+ ]);
2071
+ var UpdateStepStatus = z.enum([
2072
+ "pending",
2073
+ "running",
2074
+ "succeeded",
2075
+ "failed"
2076
+ ]);
2077
+ var UpdateJournalStep = z.object({
2078
+ id: UpdateStepId,
2079
+ status: UpdateStepStatus,
2080
+ startedAt: z.number().finite().nullable(),
2081
+ finishedAt: z.number().finite().nullable(),
2082
+ outputTail: z.array(z.string())
2083
+ }).strict();
2084
+ var UpdateJournal = z.object({
2085
+ state: UpdateRunState,
2086
+ fromSha: z.string().nullable(),
2087
+ toSha: z.string().nullable(),
2088
+ toVersion: z.string().nullable(),
2089
+ channel: UpdateChannel,
2090
+ steps: z.array(UpdateJournalStep),
2091
+ activeStep: UpdateStepId.nullable(),
2092
+ reason: z.string().nullable(),
2093
+ startedAt: z.number().finite().nullable(),
2094
+ finishedAt: z.number().finite().nullable(),
2095
+ failedAtHandOff: z.boolean().optional()
2096
+ }).strict();
2097
+ var UpdateJournalSummary = UpdateJournal.pick({
2098
+ state: true,
2099
+ activeStep: true,
2100
+ reason: true,
2101
+ startedAt: true,
2102
+ finishedAt: true
2103
+ });
2104
+ //#endregion
2105
+ //#region shared/contracts/control-messages.ts
2106
+ var requestId = z.string().nullable().optional();
2107
+ var sessionId = z.string();
2108
+ function loose(type, shape) {
2109
+ return z.looseObject({
2110
+ type: z.literal(type),
2111
+ ...shape
2112
+ });
2113
+ }
2114
+ function openObject(shape = {}) {
2115
+ return z.looseObject(shape);
2116
+ }
2117
+ var nullableString = z.string().nullable();
2118
+ var timestamp = z.number().finite();
2119
+ var optionalTimestamp = timestamp.optional();
2120
+ var optionalError = nullableString.optional();
2121
+ var opaqueObject = openObject();
2122
+ var opaqueArray = z.array(z.unknown());
2123
+ var planRevisionNumber = z.number().int().positive();
2124
+ var trailSteps = z.array(openObject({
2125
+ at: timestamp,
2126
+ tool: z.string(),
2127
+ detail: z.string()
2128
+ }));
2129
+ z.object({
2130
+ id: z.string(),
2131
+ label: z.string(),
2132
+ command: z.string(),
2133
+ args: z.array(z.string()),
2134
+ resolvable: z.boolean().nullable()
2135
+ }).strict();
2136
+ var SessionCardFields = z.object({
2137
+ id: sessionId,
2138
+ session: z.string(),
2139
+ taskTitle: TaskTitle.nullable().optional(),
2140
+ taskTitleIsCustom: z.boolean().optional(),
2141
+ path: z.string(),
2142
+ agent: z.string(),
2143
+ state: SessionState,
2144
+ stateSince: timestamp,
2145
+ skipPerms: z.boolean(),
2146
+ worktree: z.boolean(),
2147
+ workspace: z.boolean().optional(),
2148
+ resumeSessionId: nullableString,
2149
+ ephemeral: z.boolean().optional()
2150
+ });
2151
+ var githubIssueRow = z.object({
2152
+ number: z.number().int().positive(),
2153
+ title: z.string(),
2154
+ labels: z.array(z.object({
2155
+ name: z.string(),
2156
+ color: z.string()
2157
+ }).passthrough()),
2158
+ url: z.string(),
2159
+ updatedAt: z.string()
2160
+ }).passthrough();
2161
+ var IssuesReportPush = z.object({
2162
+ ts: timestamp,
2163
+ projectId: z.string(),
2164
+ issues: z.array(githubIssueRow),
2165
+ error: optionalError
2166
+ });
2167
+ var DIFF_ANNOTATION_NOTE_MAX_CHARS = 1e3;
2168
+ var DIFF_ANNOTATION_PATH_RE = new RegExp(`^[^${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}-${String.fromCharCode(159)}]+$`);
2169
+ var DiffAnnotation = z.strictObject({
2170
+ section: z.enum(["committed", "uncommitted"]),
2171
+ path: z.string().min(1).max(400).regex(DIFF_ANNOTATION_PATH_RE),
2172
+ line: z.number().int().positive(),
2173
+ side: z.enum(["old", "new"]),
2174
+ note: z.string().min(1).max(DIFF_ANNOTATION_NOTE_MAX_CHARS)
2175
+ });
2176
+ var CONTROL_FRAME_MAX_BYTES = 4096 + 2 * (PLAN_BODY_CAP_BYTES + PLAN_FEEDBACK_MAX_CHARS + 80 * PLAN_COMMENT_MAX_CHARS);
2177
+ var UpdateApplyRefusal = z.object({
2178
+ reason: z.string(),
2179
+ message: z.string()
2180
+ });
2181
+ var InstallFlavor = z.enum([
2182
+ "npm-global",
2183
+ "npx",
2184
+ "clone",
2185
+ "unknown"
2186
+ ]);
2187
+ var updateStatusShape = {
2188
+ updateAvailable: z.boolean(),
2189
+ current: nullableString,
2190
+ latest: nullableString,
2191
+ currentSha: nullableString,
2192
+ latestSha: nullableString,
2193
+ releaseUrl: nullableString,
2194
+ command: z.string(),
2195
+ flavor: InstallFlavor,
2196
+ platform: z.string(),
2197
+ installedBranch: nullableString,
2198
+ upstream: nullableString,
2199
+ isTreeClean: z.boolean().nullable(),
2200
+ lastCheckAt: timestamp,
2201
+ channel: UpdateChannel,
2202
+ behindCount: z.number().int().nonnegative().nullable(),
2203
+ reason: nullableString,
2204
+ journalSummary: UpdateJournalSummary.nullable(),
2205
+ applyRefusal: UpdateApplyRefusal.nullable()
2206
+ };
2207
+ z.object(updateStatusShape);
2208
+ Object.freeze([
2209
+ "add-session",
2210
+ "list-conversations",
2211
+ "resume-conversation",
2212
+ "remove-session",
2213
+ "rename-session",
2214
+ "set-session-title",
2215
+ "reorder-sessions",
2216
+ "ping",
2217
+ "get-settings",
2218
+ "update-settings",
2219
+ "scan-repo-roots",
2220
+ "list-agents",
2221
+ "get-posthog-report",
2222
+ "posthog-open-session",
2223
+ "request-issues",
2224
+ "open-issue-session",
2225
+ "posthog-issue-action",
2226
+ "team-review-action",
2227
+ "benchmark-action",
2228
+ "my-pr-merge",
2229
+ "my-pr-keep-mergeable",
2230
+ "my-pr-merge-when-ready",
2231
+ "reviews-refresh",
2232
+ "posthog-archive-investigation",
2233
+ "request-usage-report",
2234
+ "request-hooks-report",
2235
+ "save-hook",
2236
+ "delete-hook",
2237
+ "kill",
2238
+ "start-session",
2239
+ "restart",
2240
+ "force-restart",
2241
+ "dismiss",
2242
+ "sleep",
2243
+ "wake",
2244
+ "merge-session",
2245
+ "finish-session",
2246
+ "merge-continue-session",
2247
+ "discard-session-worktree",
2248
+ "resolve-session-merge",
2249
+ "request-session-diff",
2250
+ "request-change-map",
2251
+ "send-diff-annotations",
2252
+ "request-branch-sync",
2253
+ "resync-branch",
2254
+ "debug-state",
2255
+ "session-trace",
2256
+ "session-plan",
2257
+ "plan-decision",
2258
+ "shutdown",
2259
+ "restart-server",
2260
+ "focus-change",
2261
+ "request-health-snapshot",
2262
+ "update-check",
2263
+ "update-apply",
2264
+ "client-error"
2265
+ ]);
2266
+ var ClientErrorReport = z.object({
2267
+ name: z.string().max(128),
2268
+ stack: z.string().max(8192)
2269
+ }).strict();
2270
+ var idOnlyClientTypes = [
2271
+ "remove-session",
2272
+ "kill",
2273
+ "start-session",
2274
+ "restart",
2275
+ "force-restart",
2276
+ "dismiss",
2277
+ "sleep",
2278
+ "wake",
2279
+ "merge-session",
2280
+ "finish-session",
2281
+ "merge-continue-session",
2282
+ "discard-session-worktree",
2283
+ "resolve-session-merge",
2284
+ "request-session-diff",
2285
+ "request-change-map",
2286
+ "request-branch-sync",
2287
+ "resync-branch",
2288
+ "debug-state"
2289
+ ];
2290
+ function idOnlyClientVariant(type) {
2291
+ return loose(type, {
2292
+ id: sessionId,
2293
+ force: z.unknown().optional()
2294
+ });
2295
+ }
2296
+ var idOnlyClientVariants = idOnlyClientTypes.map(idOnlyClientVariant);
2297
+ var clientVariants = [
2298
+ loose("add-session", {
2299
+ name: z.string(),
2300
+ path: z.string(),
2301
+ repos: z.array(z.string()).optional(),
2302
+ agent: z.string().optional(),
2303
+ dangerouslySkipPermissions: z.boolean().optional()
2304
+ }),
2305
+ loose("list-conversations", {
2306
+ id: sessionId,
2307
+ requestId
2308
+ }),
2309
+ loose("resume-conversation", {
2310
+ id: sessionId,
2311
+ conversationId: z.string()
2312
+ }),
2313
+ loose("rename-session", {
2314
+ id: sessionId,
2315
+ newName: z.string()
2316
+ }),
2317
+ loose("set-session-title", {
2318
+ id: sessionId,
2319
+ title: TaskTitle
2320
+ }),
2321
+ loose("reorder-sessions", { order: z.array(sessionId) }),
2322
+ loose("ping", { requestId }),
2323
+ loose("get-settings", { requestId }),
2324
+ loose("update-settings", {
2325
+ settings: z.record(z.string(), z.unknown()),
2326
+ requestId
2327
+ }),
2328
+ loose("scan-repo-roots", { requestId }),
2329
+ loose("list-agents", { requestId }),
2330
+ loose("get-posthog-report", {
2331
+ issueId: z.union([z.string(), z.number()]),
2332
+ requestId
2333
+ }),
2334
+ loose("posthog-open-session", {
2335
+ projectId: z.union([z.string(), z.number()]),
2336
+ issueId: z.union([z.string(), z.number()]),
2337
+ requestId
2338
+ }),
2339
+ loose("request-issues", {
2340
+ requestId,
2341
+ projectId: z.string()
2342
+ }),
2343
+ loose("open-issue-session", {
2344
+ requestId,
2345
+ projectId: z.string(),
2346
+ issueNumber: z.number().int().positive()
2347
+ }),
2348
+ loose("posthog-issue-action", {
2349
+ projectId: z.union([z.string(), z.number()]),
2350
+ issueId: z.union([z.string(), z.number()]),
2351
+ action: z.string(),
2352
+ requestId
2353
+ }),
2354
+ loose("team-review-action", {
2355
+ ...TeamReviewActionRequest.shape,
2356
+ requestId
2357
+ }),
2358
+ loose("benchmark-action", {
2359
+ ...BenchmarkActionRequest.shape,
2360
+ requestId
2361
+ }),
2362
+ loose("my-pr-merge", {
2363
+ ...MyPrMergeRequest.shape,
2364
+ requestId
2365
+ }),
2366
+ loose("my-pr-keep-mergeable", {
2367
+ ...MyPrKeepMergeableRequest.shape,
2368
+ requestId
2369
+ }),
2370
+ loose("my-pr-merge-when-ready", {
2371
+ ...MyPrMergeWhenReadyRequest.shape,
2372
+ requestId
2373
+ }),
2374
+ loose("reviews-refresh", {
2375
+ ...ReviewsRefreshRequest.shape,
2376
+ requestId
2377
+ }),
2378
+ loose("posthog-archive-investigation", {
2379
+ id: z.unknown().optional(),
2380
+ requestId
2381
+ }),
2382
+ loose("request-usage-report", {
2383
+ requestId,
2384
+ days: z.unknown().optional(),
2385
+ force: z.unknown().optional()
2386
+ }),
2387
+ loose("request-hooks-report", { requestId }),
2388
+ loose("send-diff-annotations", {
2389
+ id: sessionId,
2390
+ annotations: z.array(DiffAnnotation).min(1).max(50),
2391
+ requestId
2392
+ }),
2393
+ loose("save-hook", {
2394
+ hook: z.record(z.string(), z.unknown()),
2395
+ requestId
2396
+ }),
2397
+ loose("delete-hook", {
2398
+ id: z.string(),
2399
+ requestId
2400
+ }),
2401
+ loose("shutdown"),
2402
+ loose("restart-server"),
2403
+ loose("focus-change", { focused: z.boolean() }),
2404
+ loose("request-health-snapshot"),
2405
+ loose("update-check"),
2406
+ loose("update-apply", {
2407
+ restartWhenStaged: z.boolean().optional(),
2408
+ confirmedSessionIds: z.array(z.string().min(1)).max(1e3).optional()
2409
+ }),
2410
+ loose("session-trace", {
2411
+ id: sessionId,
2412
+ after: z.number().int().nonnegative().default(0),
2413
+ endingAt: z.union([z.number().int().nonnegative(), z.literal("tail")]).optional()
2414
+ }),
2415
+ loose("session-plan", {
2416
+ id: sessionId,
2417
+ agentId: nullableString,
2418
+ revision: planRevisionNumber.optional(),
2419
+ draft: z.boolean().optional()
2420
+ }),
2421
+ loose("plan-decision", PlanDecision.shape),
2422
+ loose("client-error", ClientErrorReport.shape),
2423
+ ...idOnlyClientVariants
2424
+ ];
2425
+ var ClientMessage = z.discriminatedUnion("type", clientVariants);
2426
+ Object.freeze([
2427
+ "snapshot",
2428
+ "hooks-report",
2429
+ "save-hook-result",
2430
+ "delete-hook-result",
2431
+ "hooks-updated",
2432
+ "state-change",
2433
+ "session-added",
2434
+ "session-removed",
2435
+ "session-renamed",
2436
+ "session-title",
2437
+ "session-modified",
2438
+ "session-git",
2439
+ "session-agents",
2440
+ "session-wakeup",
2441
+ "session-prompt",
2442
+ "session-sleep",
2443
+ "session-wake",
2444
+ "session-merge-status",
2445
+ "session-worktree-blocked",
2446
+ "session-worktree-warning",
2447
+ "session-worktree-ready",
2448
+ "session-diff",
2449
+ "change-map",
2450
+ "send-diff-annotations-result",
2451
+ "branch-sync-status",
2452
+ "session-changed",
2453
+ "post-turn-result",
2454
+ "debug-state-response",
2455
+ "session-trace-response",
2456
+ "session-trace-changed",
2457
+ "session-plan-changed",
2458
+ "session-plan-draft",
2459
+ "session-plan-response",
2460
+ "notify",
2461
+ "update-status",
2462
+ "update-progress",
2463
+ "error",
2464
+ "session-error",
2465
+ "settings",
2466
+ "settings-error",
2467
+ "settings-updated",
2468
+ "pong",
2469
+ "agents-listed",
2470
+ "repo-roots-scanned",
2471
+ "conversations",
2472
+ "resume-conversation-ack",
2473
+ "health-snapshot",
2474
+ "posthog-status",
2475
+ "posthog-investigation-activity",
2476
+ "posthog-investigation-finished",
2477
+ "posthog-report",
2478
+ "posthog-open-session-result",
2479
+ "issues-report",
2480
+ "open-issue-session-result",
2481
+ "posthog-issue-action-result",
2482
+ "team-review-action-result",
2483
+ "benchmark-action-result",
2484
+ "my-pr-merge-result",
2485
+ "my-pr-keep-mergeable-result",
2486
+ "my-pr-merge-when-ready-result",
2487
+ "reviews-refresh-result",
2488
+ "posthog-archive-investigation-result",
2489
+ "team-review-status",
2490
+ "benchmark-status",
2491
+ "my-prs-status",
2492
+ "branch-gc-status",
2493
+ "usage-sessions",
2494
+ "usage-report",
2495
+ "plan-limits",
2496
+ "usage-budget-alert",
2497
+ "visions-findings",
2498
+ "visions-comments",
2499
+ "visions-hand",
2500
+ "visions-intent",
2501
+ "visions-fix",
2502
+ "visions-snapshot",
2503
+ "ingest-activity",
2504
+ "ingest-snapshot",
2505
+ "client-trust",
2506
+ "sessions-reordered",
2507
+ "shutting-down",
2508
+ "restarting"
2509
+ ]);
2510
+ var serverVariants = [
2511
+ loose("snapshot", {
2512
+ sessions: z.array(SessionSnapshot),
2513
+ serverBuild: nullableString
2514
+ }),
2515
+ loose("hooks-report", {
2516
+ requestId,
2517
+ ts: optionalTimestamp,
2518
+ hooks: z.array(opaqueObject).optional(),
2519
+ builtin: z.array(opaqueObject).optional(),
2520
+ events: z.array(openObject({
2521
+ name: z.string(),
2522
+ matcher: nullableString,
2523
+ description: z.string(),
2524
+ http: z.boolean().optional()
2525
+ })).optional(),
2526
+ projects: z.array(openObject({
2527
+ id: z.string(),
2528
+ name: z.string(),
2529
+ agent: z.string()
2530
+ })).optional(),
2531
+ limits: openObject({ maxTimeoutSec: z.number().int().positive() }).optional(),
2532
+ error: optionalError
2533
+ }),
2534
+ loose("save-hook-result", {
2535
+ requestId,
2536
+ ok: z.boolean(),
2537
+ error: optionalError,
2538
+ hook: opaqueObject.optional()
2539
+ }),
2540
+ loose("delete-hook-result", {
2541
+ requestId,
2542
+ ok: z.boolean(),
2543
+ error: optionalError,
2544
+ id: z.string().optional()
2545
+ }),
2546
+ loose("hooks-updated", { count: z.number().int().nonnegative() }),
2547
+ loose("state-change", {
2548
+ id: sessionId,
2549
+ session: z.string(),
2550
+ from: SessionState,
2551
+ to: SessionState,
2552
+ event: z.string(),
2553
+ timestamp,
2554
+ skipPerms: z.boolean().optional(),
2555
+ hasEndedTurn: z.boolean().optional()
2556
+ }),
2557
+ loose("session-added", SessionCardFields.shape),
2558
+ loose("session-modified", SessionCardFields.shape),
2559
+ loose("session-removed", {
2560
+ id: sessionId,
2561
+ session: z.string()
2562
+ }),
2563
+ loose("session-renamed", {
2564
+ id: sessionId,
2565
+ oldName: z.string(),
2566
+ newName: z.string()
2567
+ }),
2568
+ loose("session-title", {
2569
+ id: sessionId,
2570
+ taskTitle: TaskTitle.nullable(),
2571
+ isCustom: z.boolean()
2572
+ }),
2573
+ loose("session-git", {
2574
+ id: sessionId,
2575
+ worktree: z.boolean()
2576
+ }),
2577
+ loose("session-agents", {
2578
+ id: sessionId,
2579
+ activeAgents: z.number().int().nonnegative(),
2580
+ awaitingBackgroundTasks: z.boolean(),
2581
+ timestamp
2582
+ }),
2583
+ loose("session-wakeup", {
2584
+ id: sessionId,
2585
+ pendingWakeup: PendingWakeup.nullable(),
2586
+ timestamp
2587
+ }),
2588
+ loose("session-prompt", {
2589
+ id: sessionId,
2590
+ pendingPromptKind: nullableString,
2591
+ pendingPromptDetail: PendingPromptDetail.nullable().optional(),
2592
+ timestamp
2593
+ }),
2594
+ loose("session-sleep"),
2595
+ loose("session-wake"),
2596
+ loose("session-merge-status", {
2597
+ id: sessionId,
2598
+ mergeStatus: z.string(),
2599
+ reason: nullableString,
2600
+ parked: z.boolean(),
2601
+ timestamp
2602
+ }),
2603
+ loose("session-worktree-blocked", {
2604
+ id: sessionId,
2605
+ session: z.string(),
2606
+ branch: nullableString,
2607
+ notice: nullableString,
2608
+ timestamp
2609
+ }),
2610
+ loose("session-worktree-warning", {
2611
+ id: sessionId,
2612
+ session: z.string(),
2613
+ branch: nullableString,
2614
+ notice: nullableString,
2615
+ timestamp
2616
+ }),
2617
+ loose("session-worktree-ready", {
2618
+ id: sessionId,
2619
+ session: z.string(),
2620
+ branch: nullableString,
2621
+ base: nullableString,
2622
+ timestamp
2623
+ }),
2624
+ loose("session-diff", {
2625
+ id: sessionId,
2626
+ committed: openObject({
2627
+ stat: z.string(),
2628
+ diff: z.string()
2629
+ }),
2630
+ uncommitted: openObject({
2631
+ stat: z.string(),
2632
+ diff: z.string()
2633
+ }),
2634
+ hasCommits: z.boolean()
2635
+ }),
2636
+ loose("change-map", {
2637
+ id: sessionId,
2638
+ map: ChangeMap
2639
+ }),
2640
+ loose("send-diff-annotations-result", {
2641
+ requestId,
2642
+ ok: z.boolean(),
2643
+ error: optionalError,
2644
+ pending: z.boolean().optional()
2645
+ }),
2646
+ loose("branch-sync-status", {
2647
+ id: sessionId,
2648
+ branch: nullableString,
2649
+ upstream: nullableString,
2650
+ state: z.string(),
2651
+ ahead: z.number().int().nonnegative(),
2652
+ behind: z.number().int().nonnegative(),
2653
+ fetched: z.boolean().nullable(),
2654
+ action: z.string().optional(),
2655
+ error: optionalError
2656
+ }),
2657
+ loose("session-changed", { id: sessionId }),
2658
+ loose("post-turn-result", {
2659
+ id: sessionId,
2660
+ mode: z.string(),
2661
+ skipped: nullableString,
2662
+ filesFixed: z.number().int().nonnegative(),
2663
+ findings: z.array(openObject({
2664
+ file: z.string(),
2665
+ rule: z.string(),
2666
+ count: z.number().int().nonnegative()
2667
+ })),
2668
+ timestamp
2669
+ }),
2670
+ loose("debug-state-response", {
2671
+ id: sessionId,
2672
+ payload: opaqueObject
2673
+ }),
2674
+ loose("session-trace-response", {
2675
+ id: sessionId,
2676
+ records: z.array(TraceRecord),
2677
+ start: z.number().int().nonnegative(),
2678
+ next: z.number().int().nonnegative(),
2679
+ reset: z.boolean(),
2680
+ path: z.string()
2681
+ }),
2682
+ loose("session-trace-changed", { id: sessionId }),
2683
+ loose("session-plan-changed", PlanChangedPush.shape),
2684
+ loose("session-plan-draft", PlanDraftPush.shape),
2685
+ loose("session-plan-response", PlanResponseFrame.shape),
2686
+ loose("notify", {
2687
+ session: z.string(),
2688
+ category: z.string(),
2689
+ message: z.string(),
2690
+ escalationCount: z.number().int().nonnegative(),
2691
+ kind: z.literal("plan").optional()
2692
+ }),
2693
+ loose("update-status", updateStatusShape),
2694
+ loose("update-progress", { journal: UpdateJournal }),
2695
+ loose("error", {
2696
+ id: sessionId.optional(),
2697
+ message: z.string(),
2698
+ requestId,
2699
+ scope: z.string().optional()
2700
+ }),
2701
+ loose("session-error", {
2702
+ id: sessionId.optional(),
2703
+ session: z.string(),
2704
+ message: z.string(),
2705
+ scope: z.string().optional()
2706
+ }),
2707
+ loose("settings", {
2708
+ settings: opaqueObject,
2709
+ requestId
2710
+ }),
2711
+ loose("settings-error", {
2712
+ message: z.string(),
2713
+ requestId
2714
+ }),
2715
+ loose("settings-updated", {
2716
+ settings: opaqueObject,
2717
+ requestId
2718
+ }),
2719
+ loose("pong", { requestId }),
2720
+ loose("agents-listed", {
2721
+ requestId,
2722
+ agents: z.array(openObject({
2723
+ id: z.string(),
2724
+ label: z.string(),
2725
+ resolvable: z.boolean()
2726
+ }))
2727
+ }),
2728
+ loose("repo-roots-scanned", {
2729
+ requestId,
2730
+ directories: z.array(openObject({
2731
+ root: z.string(),
2732
+ projects: z.array(openObject({
2733
+ name: z.string(),
2734
+ path: z.string()
2735
+ }))
2736
+ })),
2737
+ error: z.string().optional()
2738
+ }),
2739
+ loose("conversations", {
2740
+ requestId,
2741
+ id: nullableString,
2742
+ current: nullableString.optional(),
2743
+ conversations: z.array(openObject({
2744
+ id: z.string(),
2745
+ title: z.string(),
2746
+ cwd: z.string(),
2747
+ worktreePath: z.string(),
2748
+ worktreeName: z.string(),
2749
+ gitBranch: nullableString,
2750
+ mtime: timestamp
2751
+ })),
2752
+ error: z.string().optional()
2753
+ }),
2754
+ loose("resume-conversation-ack", {
2755
+ id: sessionId.optional(),
2756
+ resumeSessionId: nullableString.optional(),
2757
+ ok: z.boolean(),
2758
+ error: z.string().optional(),
2759
+ requestId
2760
+ }),
2761
+ loose("health-snapshot", { stats: opaqueObject }),
2762
+ loose("posthog-status", {
2763
+ ts: timestamp,
2764
+ intervalMinutes: z.number(),
2765
+ projects: z.array(opaqueObject),
2766
+ investigations: z.array(opaqueObject)
2767
+ }),
2768
+ loose("posthog-investigation-activity", {
2769
+ projectId: z.union([z.string(), z.number()]),
2770
+ issueId: z.string(),
2771
+ inFlight: z.literal(true),
2772
+ startedAt: timestamp.nullable(),
2773
+ trail: trailSteps
2774
+ }),
2775
+ loose("posthog-investigation-finished", {
2776
+ projectId: z.union([z.string(), z.number()]),
2777
+ issueId: z.string(),
2778
+ verdict: z.string(),
2779
+ summaryLine: nullableString,
2780
+ startedAt: timestamp.nullable(),
2781
+ trail: trailSteps
2782
+ }),
2783
+ loose("posthog-report", {
2784
+ requestId,
2785
+ ok: z.boolean(),
2786
+ found: z.boolean(),
2787
+ issueId: nullableString,
2788
+ format: z.string().optional(),
2789
+ content: z.string().optional(),
2790
+ message: z.string().optional(),
2791
+ error: z.string().optional()
2792
+ }),
2793
+ loose("posthog-open-session-result", {
2794
+ requestId,
2795
+ ok: z.boolean(),
2796
+ error: optionalError,
2797
+ sessionId: z.string().optional(),
2798
+ sessionName: z.string().optional(),
2799
+ pending: z.boolean().optional()
2800
+ }),
2801
+ loose("issues-report", {
2802
+ requestId,
2803
+ ...IssuesReportPush.shape
2804
+ }),
2805
+ loose("open-issue-session-result", {
2806
+ requestId,
2807
+ ok: z.boolean(),
2808
+ error: optionalError,
2809
+ sessionId: z.string().optional(),
2810
+ sessionName: z.string().optional(),
2811
+ pending: z.boolean().optional()
2812
+ }),
2813
+ loose("posthog-issue-action-result", {
2814
+ requestId,
2815
+ ok: z.boolean(),
2816
+ error: optionalError,
2817
+ status: nullableString.optional()
2818
+ }),
2819
+ loose("team-review-action-result", {
2820
+ ...TeamReviewActionResult.shape,
2821
+ requestId
2822
+ }),
2823
+ loose("benchmark-action-result", {
2824
+ ...BenchmarkActionResult.shape,
2825
+ requestId
2826
+ }),
2827
+ loose("my-pr-merge-result", {
2828
+ ...MyPrMergeResult.shape,
2829
+ requestId
2830
+ }),
2831
+ loose("my-pr-keep-mergeable-result", {
2832
+ ...MyPrKeepMergeableResult.shape,
2833
+ requestId
2834
+ }),
2835
+ loose("my-pr-merge-when-ready-result", {
2836
+ ...MyPrMergeWhenReadyResult.shape,
2837
+ requestId
2838
+ }),
2839
+ loose("reviews-refresh-result", {
2840
+ ...ReviewsRefreshResult.shape,
2841
+ requestId
2842
+ }),
2843
+ loose("posthog-archive-investigation-result", {
2844
+ requestId,
2845
+ ok: z.boolean(),
2846
+ error: optionalError
2847
+ }),
2848
+ TeamReviewStatus,
2849
+ BenchmarkStatus,
2850
+ MyPrsStatus,
2851
+ loose("branch-gc-status"),
2852
+ loose("usage-sessions", {
2853
+ ts: timestamp,
2854
+ pricingSource: nullableString,
2855
+ sessions: z.array(openObject({
2856
+ id: sessionId,
2857
+ tokens: z.number(),
2858
+ costUSD: z.number(),
2859
+ officialCostUSD: z.number().nullable().optional()
2860
+ }))
2861
+ }),
2862
+ loose("usage-report", {
2863
+ requestId,
2864
+ ts: optionalTimestamp,
2865
+ tz: z.string().optional(),
2866
+ blockHours: z.number().optional(),
2867
+ totals: opaqueObject.optional(),
2868
+ daily: opaqueArray.optional(),
2869
+ models: opaqueArray.optional(),
2870
+ sessions: opaqueArray.optional(),
2871
+ blocks: opaqueArray.optional(),
2872
+ activeBlock: z.unknown().nullable().optional(),
2873
+ anomaly: z.unknown().nullable().optional(),
2874
+ byLane: z.unknown().optional(),
2875
+ planWindowLanes: z.unknown().nullable().optional(),
2876
+ budget: z.unknown().optional(),
2877
+ savings: z.unknown().optional(),
2878
+ tokenLimit: z.unknown().nullable().optional(),
2879
+ pricing: opaqueObject.optional(),
2880
+ scan: opaqueObject.optional(),
2881
+ warning: optionalError,
2882
+ error: optionalError
2883
+ }),
2884
+ loose("plan-limits", {
2885
+ ts: timestamp,
2886
+ fiveHour: z.unknown().nullable(),
2887
+ sevenDay: z.unknown().nullable(),
2888
+ source: z.string()
2889
+ }),
2890
+ loose("usage-budget-alert", {
2891
+ scope: z.string(),
2892
+ periodKey: z.string(),
2893
+ threshold: z.number(),
2894
+ text: z.string(),
2895
+ ts: timestamp
2896
+ }),
2897
+ loose("visions-findings", {
2898
+ uri: z.string(),
2899
+ diagnostics: opaqueArray,
2900
+ ts: timestamp
2901
+ }),
2902
+ loose("visions-comments", {
2903
+ uri: z.string(),
2904
+ comments: opaqueArray,
2905
+ ts: timestamp
2906
+ }),
2907
+ loose("visions-hand", {
2908
+ uri: z.string(),
2909
+ hand: nullableString,
2910
+ ts: timestamp
2911
+ }),
2912
+ loose("visions-intent", {
2913
+ projectId: nullableString,
2914
+ intent: opaqueObject,
2915
+ ts: timestamp
2916
+ }),
2917
+ loose("visions-fix", {
2918
+ uri: z.string(),
2919
+ fix: opaqueObject,
2920
+ ts: timestamp
2921
+ }),
2922
+ loose("visions-snapshot", {
2923
+ documents: z.array(opaqueObject),
2924
+ intent: opaqueObject,
2925
+ fixes: z.array(opaqueObject),
2926
+ ts: timestamp
2927
+ }),
2928
+ loose("ingest-activity", {
2929
+ events: z.array(opaqueObject),
2930
+ overflow: z.number().int().nonnegative(),
2931
+ ts: timestamp
2932
+ }),
2933
+ loose("ingest-snapshot", {
2934
+ events: z.array(opaqueObject),
2935
+ sources: z.unknown(),
2936
+ ts: timestamp
2937
+ }),
2938
+ loose("client-trust", { trust: z.enum(["local", "remote"]) }),
2939
+ loose("sessions-reordered", { order: z.array(sessionId) }),
2940
+ loose("shutting-down"),
2941
+ loose("restarting")
2942
+ ];
2943
+ z.discriminatedUnion("type", serverVariants);
2944
+ var viewerCols = z.number().int().min(1).max(500);
2945
+ var viewerRows = z.number().int().min(1).max(200);
2946
+ var DataClientMessage = z.discriminatedUnion("type", [
2947
+ z.object({
2948
+ type: z.literal("input"),
2949
+ data: z.string()
2950
+ }),
2951
+ z.object({
2952
+ type: z.literal("claim"),
2953
+ cols: viewerCols,
2954
+ rows: viewerRows
2955
+ }),
2956
+ z.object({ type: z.literal("unview") })
2957
+ ]);
2958
+ z.object({
2959
+ type: z.literal("pty-size"),
2960
+ cols: viewerCols,
2961
+ rows: viewerRows,
2962
+ seq: z.number().int().nonnegative()
2963
+ });
2964
+ function decodeJson(raw) {
2965
+ try {
2966
+ return JSON.parse(raw);
2967
+ } catch {
2968
+ return null;
2969
+ }
2970
+ }
2971
+ function parseDataClientMessage(raw) {
2972
+ const parsed = DataClientMessage.safeParse(decodeJson(raw));
2973
+ if (!parsed.success) return null;
2974
+ return parsed.data;
2975
+ }
2976
+ //#endregion
2977
+ //#region shared/contracts/hooks.ts
2978
+ var HookPayload = z.record(z.string(), z.unknown());
2979
+ var HookEnvelope = z.object({
2980
+ glimmervoidId: z.string().min(1),
2981
+ event: z.string().min(1),
2982
+ token: z.string().nullable().optional(),
2983
+ payload: HookPayload
2984
+ });
2985
+ z.object({
2986
+ id: z.string().min(1),
2987
+ name: z.string().min(1),
2988
+ event: z.string().min(1),
2989
+ matcher: z.string().optional(),
2990
+ type: z.enum(["command", "http"]),
2991
+ command: z.string().optional(),
2992
+ url: z.string().optional(),
2993
+ timeout: z.number().int().positive().optional(),
2994
+ enabled: z.boolean(),
2995
+ projects: z.array(z.string()).optional()
2996
+ }).passthrough();
2997
+ //#endregion
2998
+ export { MyPrKeepMergeableRequest as $, POSTHOG_TRAFFIC_MULTIPLIER_RANGE as $t, MergedPrListing as A, TeamReviewStatus as At, BrowserConfig as B, BRANCH_GC_INTERVAL_MS_RANGE as Bt, BenchmarkCase as C, ReviewThreadId as Ct, BenchmarkStatus as D, TeamReviewCompareFiles as Dt, BenchmarkRun as E, TeamReviewActionRequest as Et, TELEMETRY_EVENT_SCHEMAS as F, decisionAsIfApprovalRequired as Ft, BRANCH_GC_CONTROL_BOOLEAN_KEYS as G, POSTHOG_INTERVAL_RANGE as Gt, ConfigUpdate as H, KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE as Ht, TELEMETRY_KILL_SWITCH_FLAG as I, hasStandingViewerApproval as It, WorkflowCommentBody as J, POSTHOG_MIN_USERS_RANGE as Jt, BRANCH_GC_CONTROL_NUMERIC_KEYS as K, POSTHOG_INVESTIGATION_TIMEOUT_RANGE as Kt, TelemetryState as L, USAGE_BUDGET_KEYS as Lt, PrCheckoutCaseInput as M, TeamReviewThreadResult as Mt, FeatureFlagsResponse as N, TeamReviewThreadsRepository as Nt, BenchmarkSuite as O, TeamReviewResolveResponse as Ot, PendingCrashReport as P, canApproveAfterComment as Pt, WorkflowsState as Q, POSTHOG_TRAFFIC_MIN_USERS_RANGE as Qt, AGENT_ID_SHAPE_MESSAGE as R, USAGE_COST_MODES as Rt, BenchmarkActionRequest as S, ReviewResult as St, BenchmarkJudgement as T, SearchedPr as Tt, RUNTIME_CONFIG_SCALAR_KEYS as U, POSTHOG_ESCALATION_RANGE as Ut, Config as V, BRANCH_GC_STALE_DAYS_RANGE as Vt, configIssueMessage as W, POSTHOG_FIX_TIMEOUT_RANGE as Wt, WorkflowSearchNode as X, POSTHOG_TRAFFIC_BASELINE_RANGE as Xt, WorkflowLabelName as Y, POSTHOG_RECURRENCE_WINDOW_RANGE as Yt, WorkflowsSettings as Z, POSTHOG_TRAFFIC_COOLDOWN_RANGE as Zt, PlanRevision as _, QueuedReview as _t, DIFF_ANNOTATION_NOTE_MAX_CHARS as a, VISIONS_INTENT_THREAD_TTL_MS_RANGE as an, MyPrSearchResponse as at, ChangeMap as b, ReviewDraft as bt, MAX_RAW_LINE_CHARS as c, MyPrsState as ct, PLAN_BODY_CAP_BYTES as d, DECIDING_REVIEW_STATES as dt, POSTHOG_TRANSIENT_RECURRENCE_RANGE as en, MyPrMergeMethod as et, PLAN_HOOK_EVENT as f, FindingSeverity as ft, PlanDecision as g, PrDetail as gt, PLAN_TOOL_NAME as h, PostingPlan as ht, ClientMessage as i, VISIONS_DISPATCH_TIMEOUT_RANGE as in, MyPrSearchNode as it, MinedPrReviewData as j, TeamReviewThreadCommentsResponse as jt, CommitComparison as k, TeamReviewStateEntry as kt, TraceCheckpoint as l, MyPrsStatus as lt, PLAN_RESULT_HOOK_EVENT as m, GithubReviewState as mt, parseDataClientMessage as n, VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE as nn, MyPrMergeStateResponse as nt, InstallFlavor as o, VISIONS_MAX_PER_HOUR_RANGE as on, MyPrThreadNode as ot, PLAN_HOOK_OUTPUT_MAX_CHARS as p, GithubReviewDecision as pt, BranchGcFileSettings as q, POSTHOG_MAX_CONCURRENT_RANGE as qt, CONTROL_FRAME_MAX_BYTES as r, VISIONS_COOLDOWN_MS_RANGE as rn, MyPrMergeWhenReadyRequest as rt, UpdateJournal as s, VISIONS_QUIET_MS_RANGE as sn, MyPrThreadsResponse as st, HookEnvelope as t, USAGE_INTEGER_RANGES as tn, MyPrMergeRequest as tt, TraceRecord as u, CommitSha as ut, parseExitPlanModeHookPayload as v, ReviewChecksState as vt, BenchmarkId as w, ReviewVerdict as wt, changeMapFactId as x, ReviewFinding as xt, planTitle as y, ReviewComment as yt, BUILTIN_AGENT_IDS as z, USAGE_VENDOR_KEYS as zt };