glimmervoid 0.29.1 → 0.31.0

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 (67) hide show
  1. package/README.md +8 -10
  2. package/dist/bin/glimmervoid.js +152 -53
  3. package/dist/chunks/{adapters-DIavI9-i.js → adapters-ClA_GbtA.js} +1 -1
  4. package/dist/chunks/{adapters-Dlvu1FVB.js → adapters-gn7ulNO4.js} +49 -20
  5. package/dist/chunks/agent-api-cli-DAA7Jx8N.js +135 -0
  6. package/dist/chunks/{agent-api-core-D6LHrpSL.js → agent-api-core-hVcT26JW.js} +10 -1
  7. package/dist/chunks/{agent-setup-cli-C1CQ8Nkk.js → agent-setup-cli-CiJSDWSo.js} +15 -30
  8. package/dist/chunks/backoff-DjVpfHk7.js +14 -0
  9. package/dist/chunks/child-process-safe-BKPZ-5qQ.js +2 -0
  10. package/dist/chunks/{child-process-safe-Cz22RwlG.js → child-process-safe-Ch-Zgxqs.js} +2 -2
  11. package/dist/chunks/coerce-NSst8oRP.js +32 -0
  12. package/dist/chunks/{contracts-JKChPhZ0.js → config-W1Sv-iPK.js} +380 -1682
  13. package/dist/chunks/{config-store-DtPUFVaO.js → config-store-BCy4FHNG.js} +595 -327
  14. package/dist/chunks/config-store-DbBp7LJZ.js +2 -0
  15. package/dist/chunks/contracts-3LkrilQX.js +2078 -0
  16. package/dist/chunks/{grok-COekzawt.js → grok-CXKeSt2z.js} +69 -36
  17. package/dist/chunks/hook-command-core-DclEoE9e.js +14 -0
  18. package/dist/chunks/{hook-relay-core-BHfYFnYV.js → hook-relay-core-DA_bz2KA.js} +10 -5
  19. package/dist/chunks/hook-tools-UX2fmt81.js +72 -0
  20. package/dist/chunks/{ingest-editor-core-BuI1gMF_.js → ingest-editor-core-vR6Wv6bP.js} +24 -13
  21. package/dist/chunks/json-core-dfa_7Fak.js +23 -0
  22. package/dist/chunks/json-file-oEH9vt-0.js +352 -0
  23. package/dist/chunks/knowledge-graph-cli-D2tt5hPn.js +1354 -0
  24. package/dist/chunks/{loopback-post-C7C22eYi.js → loopback-post-DepQfdcM.js} +40 -26
  25. package/dist/chunks/{main-BVDjy7vH.js → main-DyTCWIu2.js} +28881 -20693
  26. package/dist/chunks/{node-pty-preflight-CK1knGIR.js → node-pty-preflight-C8QIlrtU.js} +4 -6
  27. package/dist/chunks/{pair-cli-BQQnhkkc.js → pair-cli-BbCBfd6l.js} +4 -3
  28. package/dist/chunks/paths-CeJl2Vcg.js +55 -0
  29. package/dist/chunks/{remote-config-BHoDFCpo.js → remote-config-DKIH_VxM.js} +43 -43
  30. package/dist/chunks/rtk-hook-core-BmEz2aq9.js +131 -0
  31. package/dist/chunks/rtk-resolver-BGDzw5XK.js +21 -0
  32. package/dist/chunks/rtk-resolver-D4Nke1Fr.js +2 -0
  33. package/dist/chunks/{runtime-paths-CVvq20A4.js → runtime-paths-BPoxENmK.js} +28 -8
  34. package/dist/chunks/runtime-paths-DU5jBEEO.js +2 -0
  35. package/dist/chunks/{sandbox-deps-BwvbDBDl.js → sandbox-deps-BPKE-ylr.js} +16 -13
  36. package/dist/chunks/sandbox-proxy-core-hnQgKR0T.js +27 -0
  37. package/dist/chunks/{session-CJtOveHl.js → session-fc4pFbon.js} +10 -2
  38. package/dist/chunks/text-DoirglWV.js +21 -0
  39. package/dist/chunks/timer-deps-u2DAQLok.js +15 -0
  40. package/dist/chunks/{visions-cli-DUZnopGY.js → visions-cli-CT5rjiwf.js} +1 -1
  41. package/dist/chunks/{visions-setup-C_kJobsy.js → visions-setup-BmOkI-QE.js} +20 -357
  42. package/dist/client/assets/index-C6KD8lgZ.css +1 -0
  43. package/dist/client/assets/index-CThQEAEy.js +249 -0
  44. package/dist/client/fonts/CommitMono-OFL.txt +92 -0
  45. package/dist/client/fonts/commit-mono-400-italic.woff2 +0 -0
  46. package/dist/client/fonts/commit-mono-400-regular.woff2 +0 -0
  47. package/dist/client/fonts/commit-mono-700-italic.woff2 +0 -0
  48. package/dist/client/fonts/commit-mono-700-regular.woff2 +0 -0
  49. package/dist/client/index.html +7 -24
  50. package/dist/client/octicons-LICENSE.txt +21 -0
  51. package/dist/scripts/postinstall-path-check.js +1 -1
  52. package/dist/server/index.js +3 -3
  53. package/dist/session/command-hook-relay.js +1 -1
  54. package/dist/session/hook-relay.js +3 -3
  55. package/dist/session/{rtk-relay.js → hook-tool-relay.js} +32 -15
  56. package/dist/session/sandbox-open-launcher.js +79 -0
  57. package/dist/session/statusline-relay.js +8 -18
  58. package/dist/session/visions-relay.js +20 -11
  59. package/package.json +5 -1
  60. package/dist/chunks/agent-api-cli-ClOzm28U.js +0 -71
  61. package/dist/chunks/config-store-DtUGwi4-.js +0 -2
  62. package/dist/chunks/ingest-core-DWI1Mbu4.js +0 -342
  63. package/dist/chunks/rtk-hook-core-DRYrKwYP.js +0 -26
  64. package/dist/chunks/rtk-resolver-DDVVNRBT.js +0 -2
  65. package/dist/chunks/rtk-resolver-oGmO-ew7.js +0 -58
  66. package/dist/client/assets/index-BTwYgSAH.js +0 -248
  67. package/dist/client/assets/index-DgA708PE.css +0 -1
@@ -1,7 +1,153 @@
1
- import { d as SessionState, l as PendingWakeup, p as TaskTitle, s as PendingPromptDetail, u as SessionSnapshot } from "./session-CJtOveHl.js";
1
+ import { h as TaskTitle } from "./session-fc4pFbon.js";
2
+ import { n as isRecord } from "./coerce-NSst8oRP.js";
2
3
  import path from "node:path";
3
4
  import { z } from "zod";
5
+ //#region shared/contracts/coherence.ts
6
+ var CoherenceRisk = z.enum([
7
+ "low",
8
+ "medium",
9
+ "high",
10
+ "critical"
11
+ ]);
12
+ var CoherenceWorkState = z.enum([
13
+ "open",
14
+ "active",
15
+ "blocked",
16
+ "completed",
17
+ "cancelled"
18
+ ]);
19
+ var CoherenceReadiness = z.enum([
20
+ "ready",
21
+ "waiting",
22
+ "active",
23
+ "blocked",
24
+ "done"
25
+ ]);
26
+ var CoherenceWorkStats = z.looseObject({
27
+ total: z.number().int().nonnegative(),
28
+ roots: z.number().int().nonnegative(),
29
+ dependencies: z.number().int().nonnegative(),
30
+ states: z.looseObject({
31
+ open: z.number().int().nonnegative(),
32
+ active: z.number().int().nonnegative(),
33
+ blocked: z.number().int().nonnegative(),
34
+ completed: z.number().int().nonnegative(),
35
+ cancelled: z.number().int().nonnegative()
36
+ }),
37
+ readiness: z.looseObject({
38
+ ready: z.number().int().nonnegative(),
39
+ waiting: z.number().int().nonnegative(),
40
+ active: z.number().int().nonnegative(),
41
+ blocked: z.number().int().nonnegative(),
42
+ done: z.number().int().nonnegative()
43
+ }),
44
+ risks: z.looseObject({
45
+ low: z.number().int().nonnegative(),
46
+ medium: z.number().int().nonnegative(),
47
+ high: z.number().int().nonnegative(),
48
+ critical: z.number().int().nonnegative()
49
+ }),
50
+ graphProblems: z.number().int().nonnegative(),
51
+ scopeOverlaps: z.number().int().nonnegative(),
52
+ scopeConflicts: z.number().int().nonnegative(),
53
+ orphans: z.number().int().nonnegative(),
54
+ unsynthesizedChildren: z.number().int().nonnegative()
55
+ });
56
+ var CoherenceOrient = z.looseObject({
57
+ action: z.enum([
58
+ "steady",
59
+ "dispatch",
60
+ "continue",
61
+ "verify",
62
+ "synthesize",
63
+ "unblock",
64
+ "resolve-conflict",
65
+ "repair-navigation",
66
+ "refuse"
67
+ ]),
68
+ reasons: z.array(z.string()),
69
+ sources: z.array(z.looseObject({
70
+ name: z.string(),
71
+ ok: z.boolean(),
72
+ detail: z.string()
73
+ })),
74
+ work: z.looseObject({
75
+ stats: CoherenceWorkStats,
76
+ ready: z.array(z.string()),
77
+ active: z.array(z.string()),
78
+ blocked: z.array(z.string()),
79
+ completed: z.array(z.string()),
80
+ conflicts: z.array(z.looseObject({
81
+ left: z.string(),
82
+ right: z.string(),
83
+ scope: z.string()
84
+ })),
85
+ unsynthesized: z.array(z.unknown())
86
+ }).nullable(),
87
+ consequences: z.looseObject({ unverifiedCompletedWork: z.array(z.string()) }),
88
+ verification: z.looseObject({ state: z.string() })
89
+ });
90
+ var CoherenceWorkInspect = z.looseObject({
91
+ work: z.array(z.looseObject({
92
+ work: z.string(),
93
+ state: CoherenceWorkState,
94
+ readiness: CoherenceReadiness,
95
+ owner: z.looseObject({
96
+ session: z.string(),
97
+ agent: z.string()
98
+ }),
99
+ last: z.looseObject({
100
+ event: z.string(),
101
+ at: z.string(),
102
+ session: z.string()
103
+ }).nullable(),
104
+ opened: z.looseObject({
105
+ at: z.iso.datetime(),
106
+ objective: z.string(),
107
+ authority: z.looseObject({ boundary: z.string() }),
108
+ criteria: z.array(z.string()),
109
+ risk: CoherenceRisk,
110
+ parent: z.string().nullable(),
111
+ dependsOn: z.array(z.string()),
112
+ readScopes: z.array(z.string()),
113
+ writeScopes: z.array(z.string())
114
+ })
115
+ })),
116
+ scopeConflicts: z.array(z.looseObject({
117
+ left: z.string(),
118
+ right: z.string(),
119
+ leftScope: z.string(),
120
+ rightScope: z.string(),
121
+ status: z.string()
122
+ }))
123
+ });
124
+ var CoherenceWorkCreated = z.looseObject({
125
+ version: z.literal(1),
126
+ event: z.literal("opened"),
127
+ at: z.iso.datetime(),
128
+ session: z.literal("glimmervoid-factory"),
129
+ work: z.string().regex(/^wrk-[a-f0-9]{16}$/),
130
+ id: z.string().regex(/^wev-[a-f0-9]{16}$/),
131
+ parent: z.null(),
132
+ objective: z.string(),
133
+ criteria: z.array(z.string()),
134
+ risk: CoherenceRisk,
135
+ state: z.literal("open"),
136
+ authority: z.object({
137
+ kind: z.literal("user-directed"),
138
+ grantedBy: z.literal("operator"),
139
+ boundary: z.string()
140
+ }),
141
+ writeScopes: z.array(z.string())
142
+ });
143
+ var CoherenceTicketCreated = CoherenceWorkCreated.extend({ parent: z.string().regex(/^wrk-[a-f0-9]{16}$/) });
144
+ //#endregion
4
145
  //#region shared/settings-ranges.ts
146
+ var FACTORY_WATCH_WINDOW_RANGE = Object.freeze({
147
+ min: 1,
148
+ max: 1440
149
+ });
150
+ var FACTORY_MAX_LIVE_WORKERS_RANGE = Object.freeze({ min: 1 });
5
151
  var POSITIVE_NUMBER_RANGE = Object.freeze({
6
152
  min: 0,
7
153
  exclusiveMin: true,
@@ -101,6 +247,9 @@ var WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE = Object.freeze({
101
247
  max: 50
102
248
  });
103
249
  Object.freeze({
250
+ NON_NEGATIVE_NUMBER_RANGE,
251
+ FACTORY_MAX_LIVE_WORKERS_RANGE,
252
+ FACTORY_WATCH_WINDOW_RANGE,
104
253
  FLYING_ANIMALS_GAP_RANGE,
105
254
  FLYING_ANIMALS_DURATION_RANGE,
106
255
  FLYING_ANIMALS_SCALE_RANGE,
@@ -130,6 +279,97 @@ Object.freeze({
130
279
  WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE
131
280
  });
132
281
  //#endregion
282
+ //#region shared/contracts/config-numbers-core.ts
283
+ var POSTHOG_WHOLE_NUMBER_ROUNDING = {
284
+ maxConcurrentInvestigations: Math.ceil,
285
+ minUsersToInvestigate: Math.ceil,
286
+ userEscalationThreshold: Math.ceil,
287
+ trafficSpikeMinUsers: Math.ceil,
288
+ trafficSpikeBaselineDays: Math.floor
289
+ };
290
+ var LEGACY_INTEGER_FIELDS = [
291
+ {
292
+ path: [
293
+ "visions",
294
+ "dispatch",
295
+ "quietMs"
296
+ ],
297
+ min: 1,
298
+ round: Math.floor
299
+ },
300
+ {
301
+ path: [
302
+ "visions",
303
+ "dispatch",
304
+ "cooldownMs"
305
+ ],
306
+ min: 1,
307
+ round: Math.floor
308
+ },
309
+ {
310
+ path: [
311
+ "visions",
312
+ "dispatch",
313
+ "maxPerHour"
314
+ ],
315
+ min: 1,
316
+ round: Math.floor
317
+ },
318
+ {
319
+ path: [
320
+ "visions",
321
+ "dispatch",
322
+ "activityMaxPerHour"
323
+ ],
324
+ min: 0,
325
+ round: Math.floor
326
+ },
327
+ {
328
+ path: [
329
+ "visions",
330
+ "dispatch",
331
+ "dispatchTimeoutSeconds"
332
+ ],
333
+ min: 1,
334
+ round: Math.floor
335
+ },
336
+ {
337
+ path: [
338
+ "visions",
339
+ "intent",
340
+ "threadTtlMs"
341
+ ],
342
+ min: 1,
343
+ round: Math.floor
344
+ },
345
+ ...Object.entries(POSTHOG_WHOLE_NUMBER_ROUNDING).map(([key, round]) => ({
346
+ path: ["posthog", key],
347
+ min: 1,
348
+ round
349
+ }))
350
+ ];
351
+ function normalizeIntegerField(config, path, min, round) {
352
+ let target = config;
353
+ for (const segment of path.slice(0, -1)) {
354
+ const block = target[segment];
355
+ if (!isRecord(block)) return;
356
+ target[segment] = { ...block };
357
+ target = target[segment];
358
+ }
359
+ const key = path.at(-1);
360
+ const value = target[key];
361
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return;
362
+ if (Number.isInteger(value)) return;
363
+ target[key] = Math.min(Number.MAX_SAFE_INTEGER, Math.max(min, round(value)));
364
+ }
365
+ function normalizeLegacyConfigNumbers(candidate) {
366
+ const normalized = { ...candidate };
367
+ const replayBufferKB = candidate.replayBufferKB;
368
+ if (typeof replayBufferKB === "number" && Number.isFinite(replayBufferKB) && replayBufferKB >= 0 && replayBufferKB <= REPLAY_BUFFER_KB_RANGE.max) normalized.replayBufferKB = Math.max(REPLAY_BUFFER_KB_RANGE.min, Math.floor(replayBufferKB));
369
+ for (const { path, min, round } of LEGACY_INTEGER_FIELDS) normalizeIntegerField(normalized, path, min, round);
370
+ return normalized;
371
+ }
372
+ //#endregion
133
373
  //#region shared/usage-config.ts
134
374
  var USAGE_COST_MODES = Object.freeze([
135
375
  "auto",
@@ -151,15 +391,38 @@ var reviewsPollingShape = {
151
391
  isRefreshing: z.boolean().optional(),
152
392
  refreshNotice: z.string().nullable().optional()
153
393
  };
154
- var ReviewsRefreshRequest = z.object({ lane: z.enum(["my-prs", "team-review"]) });
394
+ var ReviewsRefreshRequest = z.object({ lane: z.enum([
395
+ "my-prs",
396
+ "team-review",
397
+ "issues"
398
+ ]) });
155
399
  var ReviewsRefreshResult = z.object({
156
400
  ok: z.boolean(),
157
401
  error: z.string().optional()
158
402
  });
159
403
  //#endregion
404
+ //#region shared/contracts/github-ids.ts
405
+ var GH_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
406
+ var REPO_SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/;
407
+ var NODE_ID_RE = /^[A-Za-z0-9_=-]+$/;
408
+ function repoParts(repo) {
409
+ const parts = repo.split("/");
410
+ if (parts.length !== 2 || !parts.every((part) => GH_SEGMENT.test(part))) return null;
411
+ return [parts[0], parts[1]];
412
+ }
413
+ var HEX_SHA_RE = /^[0-9a-f]{7,40}$/i;
414
+ var FULL_SHA_RE = /^[0-9a-f]{40}$/;
415
+ function shortSha(sha, { chars = 7, validate = false } = {}) {
416
+ if (typeof sha !== "string" || !sha) return "";
417
+ if (!validate) return sha.slice(0, chars);
418
+ const text = sha.trim();
419
+ if (!HEX_SHA_RE.test(text)) return "";
420
+ return text.slice(0, chars).toLowerCase();
421
+ }
422
+ //#endregion
160
423
  //#region shared/contracts/team-review.ts
161
- var CommitSha = z.string().regex(/^[0-9a-f]{40}$/);
162
- var repoSlug$1 = z.string().regex(/^[^/]+\/[^/]+$/);
424
+ var CommitSha = z.string().regex(FULL_SHA_RE);
425
+ var repoSlug = z.string().regex(/^[^/]+\/[^/]+$/);
163
426
  var SearchedPr = z.object({
164
427
  number: z.number().int().positive(),
165
428
  title: z.string(),
@@ -311,7 +574,7 @@ var PriorReview = z.object({
311
574
  comments: z.array(ReviewComment),
312
575
  wasPosted: z.boolean()
313
576
  });
314
- var ReviewThreadId = z.string().min(1).max(256).regex(/^[A-Za-z0-9_=-]+$/);
577
+ var ReviewThreadId = z.string().min(1).max(256).regex(NODE_ID_RE);
315
578
  var TeamReviewThreadResult = z.object({
316
579
  addressed: z.boolean(),
317
580
  reason: z.string().trim().min(1).max(4e3)
@@ -360,6 +623,10 @@ var TeamReviewThread = z.object({
360
623
  viewerCanResolve: z.boolean(),
361
624
  isNit: z.boolean(),
362
625
  url: z.string().url(),
626
+ viewerComment: z.string().max(1500).optional(),
627
+ lastReplyBody: z.string().max(1500).optional(),
628
+ viewerCommentTruncated: z.boolean().optional(),
629
+ lastReplyTruncated: z.boolean().optional(),
363
630
  lastReplyAuthor: z.string(),
364
631
  lastReplyAt: z.string().datetime(),
365
632
  judgement: TeamReviewThreadResult.extend({
@@ -395,7 +662,7 @@ var ViewerThreadTally = z.object({
395
662
  var ReviewDraft = z.object({
396
663
  ...reviewPriorityShape,
397
664
  key: z.string(),
398
- repo: repoSlug$1,
665
+ repo: repoSlug,
399
666
  number: z.number().int().positive(),
400
667
  title: z.string(),
401
668
  url: z.string(),
@@ -469,7 +736,7 @@ var QueuedReview = z.object({
469
736
  ...reviewPriorityShape,
470
737
  reviewDecision: GithubReviewDecision.nullable().optional(),
471
738
  key: z.string(),
472
- repo: repoSlug$1,
739
+ repo: repoSlug,
473
740
  number: z.number().int().positive(),
474
741
  title: z.string(),
475
742
  url: z.string(),
@@ -511,7 +778,7 @@ var InFlightReview = z.object({
511
778
  ...reviewPriorityShape,
512
779
  reviewDecision: GithubReviewDecision.nullable().optional(),
513
780
  key: z.string(),
514
- repo: repoSlug$1,
781
+ repo: repoSlug,
515
782
  number: z.number().int().positive(),
516
783
  title: z.string(),
517
784
  url: z.string(),
@@ -560,7 +827,7 @@ var MyPrStage = z.enum([
560
827
  "unknown"
561
828
  ]);
562
829
  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._-]*$/);
830
+ var repositoryName = z.string().regex(REPO_SLUG_RE);
564
831
  var pullRequestNumberText = z.string().regex(/^[1-9][0-9]*$/);
565
832
  var pullRequestKeyFormat = z.templateLiteral([
566
833
  repositoryName,
@@ -597,7 +864,8 @@ var MyPrKeepMergeableAttempt = z.strictObject({
597
864
  var MyPrKeepMergeableAttemptRecord = MyPrKeepMergeableAttempt.extend({
598
865
  key: pullRequestKey,
599
866
  headRefOid: CommitSha,
600
- baseRefOid: CommitSha
867
+ baseRefOid: CommitSha,
868
+ consecutiveAttempts: z.number().int().min(1).optional()
601
869
  });
602
870
  var MyPrsState = z.strictObject({
603
871
  keepMergeableKeys: z.array(pullRequestKey),
@@ -753,7 +1021,7 @@ var StatusContext = z.object({
753
1021
  });
754
1022
  var MyPrSearchNode = z.object({
755
1023
  __typename: z.literal("PullRequest"),
756
- id: z.string().regex(/^[A-Za-z0-9_=-]+$/),
1024
+ id: z.string().regex(NODE_ID_RE),
757
1025
  number: z.number().int().positive(),
758
1026
  title: z.string(),
759
1027
  url: z.url(),
@@ -891,7 +1159,6 @@ var WORKFLOW_ACTION_TYPES = Object.freeze([
891
1159
  var WORKFLOW_PROMPT_TEMPLATE_MAX_CHARACTERS = 2e4;
892
1160
  var WORKFLOW_COMMENT_BODY_MAX_CHARACTERS = 65536;
893
1161
  var RULE_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
894
- var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
895
1162
  var UNSAFE_LABEL_NAME = /[\x00-\x1f\x7f,]|^-/;
896
1163
  var integerInRange = (field, range) => {
897
1164
  const message = `${field} must be an integer between ${range.min} and ${range.max}`;
@@ -922,7 +1189,7 @@ var WorkflowAction = z.discriminatedUnion("type", [
922
1189
  var WorkflowFilters = z.strictObject({
923
1190
  mine: z.boolean({ error: "workflows.rules[].filters.mine must be a boolean" }).optional(),
924
1191
  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(),
1192
+ authors: nonEmptyList("workflows.rules[].filters.authors", z.string({ error: "workflows.rules[].filters.authors must hold GitHub logins" }).regex(GH_SEGMENT, { error: "workflows.rules[].filters.authors must hold GitHub logins" })).optional(),
926
1193
  labels: nonEmptyList("workflows.rules[].filters.labels", WorkflowLabelName).optional(),
927
1194
  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
1195
  }, { error: "workflows.rules[].filters must be an object" });
@@ -1030,16 +1297,29 @@ var numberRangeLabel = (range) => {
1030
1297
  return `at least ${range.min}`;
1031
1298
  };
1032
1299
  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();
1300
+ var optionalWholeNumber = (field, range) => optionalNumber(field, range).unwrap().int({ error: `${field} must be a whole number ${numberRangeLabel(range)}` }).optional();
1033
1301
  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
1302
  var optionalObject = (field, shape) => z.object(shape, { error: `${field} must be an object` }).nullable().optional();
1035
1303
  var optionalLooseObject = (field) => z.object({}, { error: `${field} must be an object` }).passthrough().nullable().optional();
1036
1304
  var CHANGE_MAP_NARRATOR_ENGINES = Object.freeze(["claude", "codex"]);
1305
+ var UPDATE_CHANNELS = Object.freeze(["release", "main"]);
1306
+ var POST_TURN_CHECK_MODES = Object.freeze(["report", "fix"]);
1037
1307
  var ChangeMapSettings = optionalObject("changeMap", { narrator: optionalObject("changeMap.narrator", {
1038
1308
  enabled: optionalBoolean("changeMap.narrator.enabled"),
1039
1309
  engine: z.enum(CHANGE_MAP_NARRATOR_ENGINES, { error: `changeMap.narrator.engine must be one of ${CHANGE_MAP_NARRATOR_ENGINES.join(", ")}` }).optional(),
1040
1310
  model: optionalString("changeMap.narrator.model", true),
1041
1311
  timeoutSeconds: optionalInteger("changeMap.narrator.timeoutSeconds", CHANGE_MAP_NARRATOR_TIMEOUT_RANGE)
1042
1312
  }) });
1313
+ var TaskTitleSettings = z.object({ refiner: z.object({
1314
+ enabled: optionalBoolean("taskTitle.refiner.enabled"),
1315
+ model: optionalString("taskTitle.refiner.model", true),
1316
+ minIntervalSeconds: optionalNumber("taskTitle.refiner.minIntervalSeconds", { min: 0 }),
1317
+ timeoutSeconds: optionalNumber("taskTitle.refiner.timeoutSeconds", {
1318
+ min: 0,
1319
+ exclusiveMin: true,
1320
+ max: 2147483647 / 1e3
1321
+ })
1322
+ }, { error: "taskTitle.refiner must be an object" }).nullable().optional() }, { error: "taskTitle must be an object" }).nullable().optional();
1043
1323
  var BRANCH_GC_SETTINGS_SHAPE = {
1044
1324
  enabled: optionalBoolean("branchGc.enabled"),
1045
1325
  worktrees: optionalBoolean("branchGc.worktrees"),
@@ -1058,7 +1338,7 @@ var BranchGcControlSettings = BranchGcFileSettings.omit({
1058
1338
  }).nullable().optional();
1059
1339
  var BRANCH_GC_CONTROL_BOOLEAN_KEYS = Object.freeze(["enabled", "deleteUnmerged"]);
1060
1340
  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() });
1341
+ var PostTurnChecksSettings = optionalObject("postTurnChecks", { mode: z.enum(POST_TURN_CHECK_MODES, { error: "postTurnChecks.mode must be one of report, fix" }).optional() });
1062
1342
  var VisionsSettings = optionalObject("visions", {
1063
1343
  enabled: optionalBoolean("visions.enabled"),
1064
1344
  autoFix: optionalBoolean("visions.autoFix"),
@@ -1066,14 +1346,15 @@ var VisionsSettings = optionalObject("visions", {
1066
1346
  dispatch: optionalObject("visions.dispatch", {
1067
1347
  enabled: optionalBoolean("visions.dispatch.enabled"),
1068
1348
  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)
1349
+ quietMs: optionalWholeNumber("visions.dispatch.quietMs", VISIONS_QUIET_MS_RANGE),
1350
+ cooldownMs: optionalWholeNumber("visions.dispatch.cooldownMs", VISIONS_COOLDOWN_MS_RANGE),
1351
+ maxPerHour: optionalWholeNumber("visions.dispatch.maxPerHour", VISIONS_MAX_PER_HOUR_RANGE),
1352
+ activityMaxPerHour: optionalWholeNumber("visions.dispatch.activityMaxPerHour", VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE),
1353
+ dispatchTimeoutSeconds: optionalWholeNumber("visions.dispatch.dispatchTimeoutSeconds", VISIONS_DISPATCH_TIMEOUT_RANGE)
1074
1354
  }),
1075
- intent: optionalObject("visions.intent", { threadTtlMs: optionalNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1355
+ intent: optionalObject("visions.intent", { threadTtlMs: optionalWholeNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
1076
1356
  });
1357
+ var GithubSettings = z.object({ teams: z.array(z.string({ error: "github.teams must be an array of org/slug strings" }).refine((team) => repoParts(team) !== null, { message: "github.teams entries must be org/slug with valid GitHub segments" }), { error: "github.teams must be an array of org/slug strings" }).optional() }, { error: "github must be an object" }).nullable().optional();
1077
1358
  var TeamReviewSettings = optionalObject("teamReview", {
1078
1359
  enabled: optionalBoolean("teamReview.enabled"),
1079
1360
  autoRebaseMyPrs: optionalBoolean("teamReview.autoRebaseMyPrs"),
@@ -1087,6 +1368,38 @@ var TeamReviewSettings = optionalObject("teamReview", {
1087
1368
  skipIdleAfterDays: optionalNumber("teamReview.skipIdleAfterDays")
1088
1369
  });
1089
1370
  var BenchmarksSettings = optionalObject("benchmarks", { enabled: optionalBoolean("benchmarks.enabled") });
1371
+ var DEFAULT_FACTORY_CHECKS = [
1372
+ "npm run typecheck",
1373
+ "npm run lint",
1374
+ "npm test"
1375
+ ];
1376
+ var DEFAULT_FACTORY_PROTECTED_PATHS = [
1377
+ "coherence.config.json",
1378
+ ".coherence/",
1379
+ "package.json",
1380
+ "package-lock.json",
1381
+ "**/AGENTS.md",
1382
+ "**/CLAUDE.md",
1383
+ "**/CLAUDE.local.md",
1384
+ ".claude/",
1385
+ ".github/"
1386
+ ];
1387
+ var FactorySettings = z.object({
1388
+ enabled: optionalBoolean("factory.enabled"),
1389
+ maxRisk: CoherenceRisk.optional(),
1390
+ maxLiveWorkers: z.number().int().min(FACTORY_MAX_LIVE_WORKERS_RANGE.min).optional(),
1391
+ checks: z.array(z.string().trim().min(1)).optional(),
1392
+ protectedPaths: z.array(z.string().trim().min(1)).optional(),
1393
+ reviewerModel: z.string().trim().min(1).nullable().optional(),
1394
+ watchWindowMinutes: z.number().int().min(FACTORY_WATCH_WINDOW_RANGE.min).max(FACTORY_WATCH_WINDOW_RANGE.max).optional(),
1395
+ watchProjects: z.array(z.object({
1396
+ project: z.string().trim().min(1),
1397
+ posthogProjectId: z.number().int().positive()
1398
+ })).optional(),
1399
+ dailyBudgetUsd: z.number().finite().nonnegative().nullable().optional(),
1400
+ verifierModel: z.string().trim().min(1).nullable().optional()
1401
+ }).nullable().optional();
1402
+ var KnowledgeGraphSettings = optionalObject("knowledgeGraph", { enabled: optionalBoolean("knowledgeGraph.enabled") });
1090
1403
  var posthogNumberRanges = {
1091
1404
  intervalMinutes: POSTHOG_INTERVAL_RANGE,
1092
1405
  maxConcurrentInvestigations: POSTHOG_MAX_CONCURRENT_RANGE,
@@ -1111,7 +1424,7 @@ var PosthogSettings = optionalObject("posthog", {
1111
1424
  repoPath: optionalString("posthog.repoPath", true),
1112
1425
  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
1426
  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)]))
1427
+ ...Object.fromEntries(Object.entries(posthogNumberRanges).map(([key, range]) => [key, Object.hasOwn(POSTHOG_WHOLE_NUMBER_ROUNDING, key) ? optionalWholeNumber(`posthog.${key}`, range) : optionalNumber(`posthog.${key}`, range)]))
1115
1428
  });
1116
1429
  var usageCostModeMessage = `usage.costMode must be one of ${USAGE_COST_MODES.join(", ")}`;
1117
1430
  var usageVendorShape = Object.fromEntries(USAGE_VENDOR_KEYS.map((key) => [key, optionalBoolean(`usage.vendors.${key}`)]));
@@ -1150,10 +1463,7 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1150
1463
  promptDetectionMs: z.number().finite().nonnegative().optional(),
1151
1464
  notifyDebounceMs: z.number().finite().nonnegative().optional(),
1152
1465
  phoneEscalationMs: z.number().finite().nonnegative().optional(),
1153
- replayBufferKB: optionalNumber("replayBufferKB", {
1154
- ...REPLAY_BUFFER_KB_RANGE,
1155
- min: 0
1156
- }),
1466
+ replayBufferKB: optionalWholeNumber("replayBufferKB", REPLAY_BUFFER_KB_RANGE),
1157
1467
  cursorBlink: optionalBoolean("cursorBlink"),
1158
1468
  debugMode: optionalBoolean("debugMode"),
1159
1469
  calmLayout: optionalBoolean("calmLayout"),
@@ -1161,9 +1471,10 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1161
1471
  recordSignals: optionalBoolean("recordSignals"),
1162
1472
  antiSlopPrompt: optionalBoolean("antiSlopPrompt"),
1163
1473
  rtk: optionalBoolean("rtk"),
1474
+ saneYolo: optionalBoolean("saneYolo"),
1164
1475
  skipPermissionsByDefault: optionalBoolean("skipPermissionsByDefault"),
1165
1476
  checkForUpdates: optionalBoolean("checkForUpdates"),
1166
- updateChannel: z.enum(["release", "main"], { error: "updateChannel must be one of release, main" }).optional(),
1477
+ updateChannel: z.enum(UPDATE_CHANNELS, { error: "updateChannel must be one of release, main" }).optional(),
1167
1478
  autoResume: optionalBoolean("autoResume"),
1168
1479
  telegramNotifications: optionalBoolean("telegramNotifications"),
1169
1480
  integrationBranch: optionalString("integrationBranch").nullable(),
@@ -1171,11 +1482,15 @@ var createBrowserConfigShape = (isAbsolutePath) => ({
1171
1482
  worktreeShare: z.array(z.string()).optional(),
1172
1483
  repoRoots: z.array(z.string()).optional(),
1173
1484
  changeMap: ChangeMapSettings,
1485
+ taskTitle: TaskTitleSettings,
1174
1486
  branchGc: BranchGcSettings,
1175
1487
  postTurnChecks: PostTurnChecksSettings,
1176
1488
  visions: VisionsSettings,
1489
+ github: GithubSettings,
1177
1490
  teamReview: TeamReviewSettings,
1178
1491
  benchmarks: BenchmarksSettings,
1492
+ factory: FactorySettings,
1493
+ knowledgeGraph: KnowledgeGraphSettings,
1179
1494
  posthog: PosthogSettings,
1180
1495
  usage: createUsageSettings(isAbsolutePath),
1181
1496
  telegram: TelegramSettings,
@@ -1196,7 +1511,6 @@ var ConfigUpdate = z.object({
1196
1511
  promptDetectionMs: z.number({ error: "promptDetectionMs must be a positive number" }).finite().positive({ error: "promptDetectionMs must be a positive number" }).optional(),
1197
1512
  notifyDebounceMs: z.number({ error: "notifyDebounceMs must be a positive number" }).finite().positive({ error: "notifyDebounceMs must be a positive number" }).optional(),
1198
1513
  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
1514
  branchGc: BranchGcControlSettings,
1201
1515
  worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
1202
1516
  worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
@@ -1243,10 +1557,36 @@ var CustomAgentDeclarations = z.array(CustomAgentDeclaration, { error: "customAg
1243
1557
  });
1244
1558
  }
1245
1559
  });
1560
+ var TaskTitleSources = z.object({
1561
+ customTitle: TaskTitle.nullable().optional(),
1562
+ pendingPromptTitle: TaskTitle.nullable().optional(),
1563
+ refinedTitle: TaskTitle.nullable().optional(),
1564
+ aiTitle: TaskTitle.nullable().optional(),
1565
+ oscTitle: TaskTitle.nullable().optional(),
1566
+ promptTitle: TaskTitle.nullable().optional()
1567
+ }).strict();
1568
+ var TASK_TITLE_SOURCE_PRIORITY = [
1569
+ "customTitle",
1570
+ "pendingPromptTitle",
1571
+ "refinedTitle",
1572
+ "aiTitle",
1573
+ "oscTitle",
1574
+ "promptTitle"
1575
+ ];
1576
+ var PersistedTaskTitle = z.object({
1577
+ taskTitle: TaskTitle.min(1),
1578
+ isCustom: z.boolean(),
1579
+ sources: TaskTitleSources
1580
+ }).strict().refine(({ taskTitle, isCustom, sources }) => {
1581
+ const source = TASK_TITLE_SOURCE_PRIORITY.find((candidate) => sources[candidate]?.trim());
1582
+ if (!source) return false;
1583
+ return sources[source]?.replace(/\s+/g, " ").trim() === taskTitle && isCustom === (source === "customTitle");
1584
+ });
1246
1585
  var ProjectConfig = z.object({
1247
1586
  id: z.string().optional(),
1248
1587
  name: z.string().optional(),
1249
1588
  customTitle: TaskTitle.optional(),
1589
+ taskTitleState: PersistedTaskTitle.optional().catch(void 0),
1250
1590
  path: z.string(),
1251
1591
  repos: z.array(z.string()).min(2).optional(),
1252
1592
  agent: z.string({ error: "projects[].agent must be a string" }).regex(AGENT_ID_RE, { error: `projects[].agent must be ${AGENT_ID_SHAPE_MESSAGE}` }).optional(),
@@ -1257,9 +1597,13 @@ var FILE_CONFIG_SHAPE = {
1257
1597
  ...BROWSER_CONFIG_SHAPE,
1258
1598
  changeMap: ChangeMapSettings,
1259
1599
  branchGc: optionalLooseObject("branchGc"),
1600
+ coder: z.object({ appSlug: z.string().optional() }).loose().optional(),
1260
1601
  visions: optionalLooseObject("visions"),
1602
+ github: GithubSettings,
1261
1603
  teamReview: optionalLooseObject("teamReview"),
1262
1604
  benchmarks: optionalLooseObject("benchmarks"),
1605
+ factory: FactorySettings,
1606
+ knowledgeGraph: optionalLooseObject("knowledgeGraph"),
1263
1607
  posthog: optionalLooseObject("posthog"),
1264
1608
  usage: optionalLooseObject("usage"),
1265
1609
  telegram: optionalLooseObject("telegram"),
@@ -1283,7 +1627,8 @@ var Config = z.object({
1283
1627
  enabled: z.boolean().optional(),
1284
1628
  port: z.number().int().min(1).max(65535).nullable().optional(),
1285
1629
  publicHost: z.string().optional(),
1286
- allowedOrigins: z.array(z.string()).optional()
1630
+ allowedOrigins: z.array(z.string()).optional(),
1631
+ ownerLogin: z.string().optional()
1287
1632
  }).passthrough().optional(),
1288
1633
  projects: z.array(ProjectConfig)
1289
1634
  }).passthrough().superRefine((config, ctx) => {
@@ -1305,21 +1650,25 @@ var Config = z.object({
1305
1650
  });
1306
1651
  }
1307
1652
  });
1308
- Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE));
1309
1653
  var CONFIG_BLOCK_KEYS = Object.freeze([
1310
1654
  "changeMap",
1655
+ "taskTitle",
1311
1656
  "branchGc",
1312
1657
  "postTurnChecks",
1313
1658
  "visions",
1659
+ "github",
1314
1660
  "teamReview",
1315
1661
  "benchmarks",
1662
+ "factory",
1663
+ "knowledgeGraph",
1316
1664
  "posthog",
1317
1665
  "usage",
1318
1666
  "telegram",
1319
1667
  "ingest",
1320
1668
  "agentApi",
1321
1669
  "telemetry",
1322
- "workflows"
1670
+ "workflows",
1671
+ "coder"
1323
1672
  ]);
1324
1673
  var CONFIG_SCALAR_KEYS = Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE).filter((key) => {
1325
1674
  if (CONFIG_BLOCK_KEYS.includes(key)) return false;
@@ -1344,1655 +1693,4 @@ function configIssueMessage(error) {
1344
1693
  return error.issues[0]?.message || "settings are invalid";
1345
1694
  }
1346
1695
  //#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 };
1696
+ export { TeamReviewCompareFiles as $, MyPrSearchResponse as A, CoherenceWorkInspect as At, PostingPlan as B, MyPrMergeMethod as C, KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE as Ct, MyPrMergeWhenReadyRequest as D, CoherenceRisk as Dt, MyPrMergeStateResponse as E, CoherenceReadiness as Et, CommitSha as F, ReviewDraft as G, QueuedReview as H, DECIDING_REVIEW_STATES as I, ReviewThreadId as J, ReviewFinding as K, FindingSeverity as L, MyPrThreadsResponse as M, MyPrsState as N, MyPrMergeWhenReadyResult as O, CoherenceTicketCreated as Ot, MyPrsStatus as P, TeamReviewActionResult as Q, GithubReviewDecision as R, MyPrKeepMergeableResult as S, normalizeLegacyConfigNumbers as St, MyPrMergeResult as T, CoherenceOrient as Tt, ReviewChecksState as U, PrDetail as V, ReviewComment as W, SearchedPr as X, ReviewVerdict as Y, TeamReviewActionRequest as Z, WorkflowSearchNode as _, ReviewsRefreshResult as _t, ConfigUpdate as a, TeamReviewThreadsRepository as at, MyPrAutoRebase as b, USAGE_COST_MODES as bt, TASK_TITLE_SOURCE_PRIORITY as c, hasStandingViewerApproval as ct, BRANCH_GC_CONTROL_NUMERIC_KEYS as d, shortSha as dt, TeamReviewResolveResponse as et, BranchGcFileSettings as f, GH_SEGMENT as ft, WorkflowLabelName as g, ReviewsRefreshRequest as gt, WorkflowCommentBody as h, repoParts as ht, Config as i, TeamReviewThreadResult as it, MyPrThreadNode as j, CoherenceWorkState as jt, MyPrSearchNode as k, CoherenceWorkCreated as kt, configIssueMessage as l, FULL_SHA_RE as lt, DEFAULT_FACTORY_PROTECTED_PATHS as m, REPO_SLUG_RE as mt, BUILTIN_AGENT_IDS as n, TeamReviewStatus as nt, PersistedTaskTitle as o, canApproveAfterComment as ot, DEFAULT_FACTORY_CHECKS as p, NODE_ID_RE as pt, ReviewResult as q, BrowserConfig as r, TeamReviewThreadCommentsResponse as rt, RUNTIME_CONFIG_SCALAR_KEYS as s, decisionAsIfApprovalRequired as st, AGENT_ID_SHAPE_MESSAGE as t, TeamReviewStateEntry as tt, BRANCH_GC_CONTROL_BOOLEAN_KEYS as u, HEX_SHA_RE as ut, WorkflowsSettings as v, reviewsPollingShape as vt, MyPrMergeRequest as w, USAGE_INTEGER_RANGES as wt, MyPrKeepMergeableRequest as x, USAGE_VENDOR_KEYS as xt, WorkflowsState as y, USAGE_BUDGET_KEYS as yt, GithubReviewState as z };