glimmervoid 0.38.2 → 0.40.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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/glimmervoid.js +33 -42
  3. package/dist/chunks/{adapters-CAHxZYT3.js → adapters-B6tbX3Aj.js} +27 -14
  4. package/dist/chunks/{adapters-DDjC7_vG.js → adapters-CXQfLoyj.js} +1 -1
  5. package/dist/chunks/agent-api-cli-BBech5lF.js +1 -0
  6. package/dist/chunks/{agent-api-cli-B5Tm0wXO.js → agent-api-cli-BNHJTmNW.js} +44 -77
  7. package/dist/chunks/agent-api-core-DDrJQEdE.js +304 -0
  8. package/dist/chunks/{agent-setup-cli-DmMfCw5O.js → agent-setup-cli-CeBBwKuL.js} +2 -2
  9. package/dist/chunks/config-store-BZpN2djp.js +1 -0
  10. package/dist/chunks/{config-store-BUNZs4j7.js → config-store-DqMScSdg.js} +82 -268
  11. package/dist/chunks/contracts-CloExMlS.js +680 -0
  12. package/dist/chunks/{contracts-HVCEJfxs.js → control-messages-DpBaniJi.js} +1275 -1021
  13. package/dist/chunks/{git-version-rWZjF2Px.js → git-version-CJQMfxtZ.js} +2 -2
  14. package/dist/chunks/{grok-B6bsCgdd.js → grok-BLzhApwT.js} +7 -8
  15. package/dist/chunks/{guardrails-deps-Cb-ki4EU.js → guardrails-deps-CLxK4J-g.js} +1 -1
  16. package/dist/chunks/{json-file-CIJf0Cel.js → json-file-DFCTvPjj.js} +3 -7
  17. package/dist/chunks/{main-BNSbP-Yk.js → main-DDU8IvFD.js} +28791 -31978
  18. package/dist/chunks/{pair-cli-DNp8i5L4.js → pair-cli-CsOVTQGJ.js} +2 -2
  19. package/dist/chunks/{remote-config-C_s2pnLC.js → remote-config-HlABuLTp.js} +2 -2
  20. package/dist/chunks/{session-BlT68ppa.js → session-BwB43SCa.js} +119 -71
  21. package/dist/chunks/{session-routes-CT1JrjoT.js → session-routes-DNJzsckH.js} +25 -10
  22. package/dist/chunks/{settings-cli-BbzxCyG5.js → settings-cli-DkkbK-dj.js} +30 -156
  23. package/dist/chunks/settings-readout-core-DrXT4aWm.js +201 -0
  24. package/dist/chunks/{ssh-sign-cli-C74BGTQS.js → ssh-sign-cli-CYeKRevK.js} +2 -2
  25. package/dist/client/assets/index-BK9jLR47.js +148 -0
  26. package/dist/client/assets/index-CU_uqJmi.css +2 -0
  27. package/dist/client/assets/xterm-kR64YvZ-.js +79 -0
  28. package/dist/client/assets/zod-BRLv4KqJ.js +55 -0
  29. package/dist/client/index.html +7 -3
  30. package/dist/scripts/postinstall-path-check.js +21 -3
  31. package/dist/server/index.js +1 -1
  32. package/package.json +3 -4
  33. package/dist/chunks/agent-api-cli-BDu1CxZf.js +0 -1
  34. package/dist/chunks/agent-api-core-B_mUSenR.js +0 -341
  35. package/dist/chunks/browser-config-BrBT8269.js +0 -762
  36. package/dist/chunks/config-CjawSOBk.js +0 -219
  37. package/dist/chunks/config-store-MAVQhGMh.js +0 -1
  38. package/dist/chunks/factory-D7ryES9n.js +0 -240
  39. package/dist/chunks/knowledge-graph-cli-ByUJoKw_.js +0 -1354
  40. package/dist/client/assets/index-B5uVtedd.css +0 -1
  41. package/dist/client/assets/index-b13-NGGS.js +0 -275
@@ -0,0 +1,680 @@
1
+ import { Bt as repoParts, F as TaskTitle, nt as SessionPrLinks } from "./session-BwB43SCa.js";
2
+ import { B as POSTHOG_FIX_TIMEOUT_RANGE, D as BRANCH_GC_INTERVAL_MS_RANGE, F as MEMORY_RESERVE_MB_RANGE, G as POSTHOG_RECURRENCE_WINDOW_RANGE, H as POSTHOG_INVESTIGATION_TIMEOUT_RANGE, J as POSTHOG_TRAFFIC_MIN_USERS_RANGE, K as POSTHOG_TRAFFIC_BASELINE_RANGE, L as PORT_RANGE, O as BRANCH_GC_STALE_DAYS_RANGE, P as KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE, Q as TASK_TITLE_TIMEOUT_RANGE, R as POSITIVE_NUMBER_RANGE, T as WorkflowsSettingsUpdate, U as POSTHOG_MAX_CONCURRENT_RANGE, V as POSTHOG_INTERVAL_RANGE, W as POSTHOG_MIN_USERS_RANGE, X as POSTHOG_TRANSIENT_RECURRENCE_RANGE, Y as POSTHOG_TRAFFIC_MULTIPLIER_RANGE, Z as REPLAY_BUFFER_KB_RANGE, at as VISIONS_DISPATCH_TIMEOUT_RANGE, ct as VISIONS_QUIET_MS_RANGE, et as USAGE_INTEGER_RANGES, it as VISIONS_COOLDOWN_MS_RANGE, k as CHANGE_MAP_NARRATOR_TIMEOUT_RANGE, ot as VISIONS_INTENT_THREAD_TTL_MS_RANGE, q as POSTHOG_TRAFFIC_COOLDOWN_RANGE, rt as VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE, st as VISIONS_MAX_PER_HOUR_RANGE, w as WorkflowsSettings, z as POSTHOG_ESCALATION_RANGE } from "./control-messages-DpBaniJi.js";
3
+ import { n as isRecord } from "./coerce-NSst8oRP.js";
4
+ import path from "node:path";
5
+ import { z } from "zod";
6
+ //#region shared/contracts/config-numbers-core.ts
7
+ var POSTHOG_WHOLE_NUMBER_ROUNDING = {
8
+ maxConcurrentInvestigations: Math.ceil,
9
+ minUsersToInvestigate: Math.ceil,
10
+ userEscalationThreshold: Math.ceil,
11
+ trafficSpikeMinUsers: Math.ceil,
12
+ trafficSpikeBaselineDays: Math.floor
13
+ };
14
+ var LEGACY_INTEGER_FIELDS = [
15
+ {
16
+ path: [
17
+ "visions",
18
+ "dispatch",
19
+ "quietMs"
20
+ ],
21
+ min: 1,
22
+ round: Math.floor
23
+ },
24
+ {
25
+ path: [
26
+ "visions",
27
+ "dispatch",
28
+ "cooldownMs"
29
+ ],
30
+ min: 1,
31
+ round: Math.floor
32
+ },
33
+ {
34
+ path: [
35
+ "visions",
36
+ "dispatch",
37
+ "maxPerHour"
38
+ ],
39
+ min: 1,
40
+ round: Math.floor
41
+ },
42
+ {
43
+ path: [
44
+ "visions",
45
+ "dispatch",
46
+ "activityMaxPerHour"
47
+ ],
48
+ min: 0,
49
+ round: Math.floor
50
+ },
51
+ {
52
+ path: [
53
+ "visions",
54
+ "dispatch",
55
+ "dispatchTimeoutSeconds"
56
+ ],
57
+ min: 1,
58
+ round: Math.floor
59
+ },
60
+ {
61
+ path: [
62
+ "visions",
63
+ "intent",
64
+ "threadTtlMs"
65
+ ],
66
+ min: 1,
67
+ round: Math.floor
68
+ },
69
+ ...Object.entries(POSTHOG_WHOLE_NUMBER_ROUNDING).map(([key, round]) => ({
70
+ path: ["posthog", key],
71
+ min: 1,
72
+ round
73
+ }))
74
+ ];
75
+ function normalizeIntegerField(config, path, min, round) {
76
+ let target = config;
77
+ for (const segment of path.slice(0, -1)) {
78
+ const block = target[segment];
79
+ if (!isRecord(block)) return;
80
+ target[segment] = { ...block };
81
+ target = target[segment];
82
+ }
83
+ const key = path.at(-1);
84
+ const value = target[key];
85
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return;
86
+ if (Number.isInteger(value)) return;
87
+ target[key] = Math.min(Number.MAX_SAFE_INTEGER, Math.max(min, round(value)));
88
+ }
89
+ function normalizeLegacyConfigNumbers(candidate) {
90
+ const normalized = { ...candidate };
91
+ const replayBufferKB = candidate.replayBufferKB;
92
+ 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));
93
+ for (const { path, min, round } of LEGACY_INTEGER_FIELDS) normalizeIntegerField(normalized, path, min, round);
94
+ return normalized;
95
+ }
96
+ //#endregion
97
+ //#region shared/usage-config.ts
98
+ var USAGE_COST_MODES = Object.freeze([
99
+ "auto",
100
+ "calculate",
101
+ "display"
102
+ ]);
103
+ var USAGE_VENDOR_KEYS = Object.freeze(["codex", "grok"]);
104
+ var USAGE_BUDGET_KEYS = Object.freeze(["dailyUsd", "monthlyUsd"]);
105
+ //#endregion
106
+ //#region shared/contracts/browser-config.ts
107
+ var optionalBoolean = (field) => z.boolean({ error: `${field} must be a boolean` }).optional();
108
+ var optionalString = (field, trim = false) => {
109
+ const schema = z.string({ error: `${field} must be a string` });
110
+ return (trim ? schema.transform((value) => value.trim()) : schema).optional();
111
+ };
112
+ var numberRangeLabel = (range) => {
113
+ if (range.label) return range.label;
114
+ if (range.max != null) return `between ${range.min} and ${range.max}`;
115
+ if (range.exclusiveMin) return `greater than ${range.min}`;
116
+ return `at least ${range.min}`;
117
+ };
118
+ 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();
119
+ var optionalWholeNumber = (field, range) => optionalNumber(field, range).unwrap().int({ error: `${field} must be a whole number ${numberRangeLabel(range)}` }).optional();
120
+ 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();
121
+ var optionalObject = (field, shape) => z.object(shape, { error: `${field} must be an object` }).nullable().optional();
122
+ var optionalLooseObject = (field) => z.object({}, { error: `${field} must be an object` }).passthrough().nullable().optional();
123
+ var CHANGE_MAP_NARRATOR_ENGINES = Object.freeze(["claude", "codex"]);
124
+ var UPDATE_CHANNELS = Object.freeze(["release", "main"]);
125
+ var POST_TURN_CHECK_MODES = Object.freeze(["report", "fix"]);
126
+ var ChangeMapSettings = optionalObject("changeMap", { narrator: optionalObject("changeMap.narrator", {
127
+ enabled: optionalBoolean("changeMap.narrator.enabled"),
128
+ engine: z.enum(CHANGE_MAP_NARRATOR_ENGINES, { error: `changeMap.narrator.engine must be one of ${CHANGE_MAP_NARRATOR_ENGINES.join(", ")}` }).optional(),
129
+ model: optionalString("changeMap.narrator.model", true),
130
+ timeoutSeconds: optionalInteger("changeMap.narrator.timeoutSeconds", CHANGE_MAP_NARRATOR_TIMEOUT_RANGE)
131
+ }) });
132
+ var TaskTitleSettings = z.object({ refiner: z.object({
133
+ enabled: optionalBoolean("taskTitle.refiner.enabled"),
134
+ model: optionalString("taskTitle.refiner.model", true),
135
+ minIntervalSeconds: optionalNumber("taskTitle.refiner.minIntervalSeconds", { min: 0 }),
136
+ timeoutSeconds: optionalNumber("taskTitle.refiner.timeoutSeconds", TASK_TITLE_TIMEOUT_RANGE)
137
+ }, { error: "taskTitle.refiner must be an object" }).nullable().optional() }, { error: "taskTitle must be an object" }).nullable().optional();
138
+ var BRANCH_GC_SETTINGS_SHAPE = {
139
+ enabled: optionalBoolean("branchGc.enabled"),
140
+ worktrees: optionalBoolean("branchGc.worktrees"),
141
+ prefixes: z.array(z.string({ error: "branchGc.prefixes must be an array of strings" }).min(1, { error: "branchGc.prefixes entries must be non-empty strings" }), { error: "branchGc.prefixes must be an array of strings" }).optional(),
142
+ dryRun: optionalBoolean("branchGc.dryRun"),
143
+ staleDays: optionalNumber("branchGc.staleDays", BRANCH_GC_STALE_DAYS_RANGE),
144
+ deleteUnmerged: optionalBoolean("branchGc.deleteUnmerged"),
145
+ intervalMs: optionalNumber("branchGc.intervalMs", BRANCH_GC_INTERVAL_MS_RANGE)
146
+ };
147
+ var BranchGcFileSettings = z.object(BRANCH_GC_SETTINGS_SHAPE, { error: "branchGc must be an object" });
148
+ var BranchGcSettings = optionalObject("branchGc", BRANCH_GC_SETTINGS_SHAPE);
149
+ var BranchGcControlSettings = BranchGcFileSettings.omit({
150
+ prefixes: true,
151
+ dryRun: true,
152
+ worktrees: true
153
+ }).nullable().optional();
154
+ Object.freeze(["enabled", "deleteUnmerged"]);
155
+ Object.freeze(["staleDays", "intervalMs"]);
156
+ var PostTurnChecksSettings = optionalObject("postTurnChecks", { mode: z.enum(POST_TURN_CHECK_MODES, { error: "postTurnChecks.mode must be one of report, fix" }).optional() });
157
+ var VisionsSettings = optionalObject("visions", {
158
+ enabled: optionalBoolean("visions.enabled"),
159
+ autoFix: optionalBoolean("visions.autoFix"),
160
+ projects: z.array(z.string({ error: "visions.projects must be an array of strings" }), { error: "visions.projects must be an array of strings" }).optional(),
161
+ dispatch: optionalObject("visions.dispatch", {
162
+ enabled: optionalBoolean("visions.dispatch.enabled"),
163
+ model: optionalString("visions.dispatch.model", true),
164
+ quietMs: optionalWholeNumber("visions.dispatch.quietMs", VISIONS_QUIET_MS_RANGE),
165
+ cooldownMs: optionalWholeNumber("visions.dispatch.cooldownMs", VISIONS_COOLDOWN_MS_RANGE),
166
+ maxPerHour: optionalWholeNumber("visions.dispatch.maxPerHour", VISIONS_MAX_PER_HOUR_RANGE),
167
+ activityMaxPerHour: optionalWholeNumber("visions.dispatch.activityMaxPerHour", VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE),
168
+ dispatchTimeoutSeconds: optionalWholeNumber("visions.dispatch.dispatchTimeoutSeconds", VISIONS_DISPATCH_TIMEOUT_RANGE)
169
+ }),
170
+ intent: optionalObject("visions.intent", { threadTtlMs: optionalWholeNumber("visions.intent.threadTtlMs", VISIONS_INTENT_THREAD_TTL_MS_RANGE) })
171
+ });
172
+ 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();
173
+ var TeamReviewSettings = optionalObject("teamReview", {
174
+ enabled: optionalBoolean("teamReview.enabled"),
175
+ autoRebaseMyPrs: optionalBoolean("teamReview.autoRebaseMyPrs"),
176
+ keepMergeableEnabled: optionalBoolean("teamReview.keepMergeableEnabled"),
177
+ mergeQueueEnabled: optionalBoolean("teamReview.mergeQueueEnabled"),
178
+ keepMergeableTimeoutMinutes: optionalInteger("teamReview.keepMergeableTimeoutMinutes", KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE),
179
+ org: optionalString("teamReview.org", true),
180
+ team: optionalString("teamReview.team", true),
181
+ skill: optionalString("teamReview.skill", true),
182
+ reReviewAfterHours: optionalNumber("teamReview.reReviewAfterHours"),
183
+ skipIdleAfterDays: optionalNumber("teamReview.skipIdleAfterDays")
184
+ });
185
+ var BenchmarksSettings = optionalObject("benchmarks", { enabled: optionalBoolean("benchmarks.enabled") });
186
+ var CoherenceSettings = optionalObject("coherence", { enabled: optionalBoolean("coherence.enabled") });
187
+ var posthogNumberRanges = {
188
+ intervalMinutes: POSTHOG_INTERVAL_RANGE,
189
+ maxConcurrentInvestigations: POSTHOG_MAX_CONCURRENT_RANGE,
190
+ investigationTimeoutSeconds: POSTHOG_INVESTIGATION_TIMEOUT_RANGE,
191
+ fixTimeoutSeconds: POSTHOG_FIX_TIMEOUT_RANGE,
192
+ minUsersToInvestigate: POSTHOG_MIN_USERS_RANGE,
193
+ userEscalationThreshold: POSTHOG_ESCALATION_RANGE,
194
+ recurrenceWindowDays: POSTHOG_RECURRENCE_WINDOW_RANGE,
195
+ transientRecurrenceLimit: POSTHOG_TRANSIENT_RECURRENCE_RANGE,
196
+ trafficSpikeMultiplier: POSTHOG_TRAFFIC_MULTIPLIER_RANGE,
197
+ trafficSpikeMinUsers: POSTHOG_TRAFFIC_MIN_USERS_RANGE,
198
+ trafficSpikeCooldownMinutes: POSTHOG_TRAFFIC_COOLDOWN_RANGE,
199
+ trafficSpikeBaselineDays: POSTHOG_TRAFFIC_BASELINE_RANGE
200
+ };
201
+ var PosthogSettings = optionalObject("posthog", {
202
+ enabled: optionalBoolean("posthog.enabled"),
203
+ recurrenceDedupe: optionalBoolean("posthog.recurrenceDedupe"),
204
+ trafficSpikeEnabled: optionalBoolean("posthog.trafficSpikeEnabled"),
205
+ autoFix: optionalBoolean("posthog.autoFix"),
206
+ host: optionalString("posthog.host", true).refine((value) => value == null || !value || /^https?:\/\//i.test(value), { message: "posthog.host must be an http(s) URL" }),
207
+ apiKey: optionalString("posthog.apiKey", true),
208
+ repoPath: optionalString("posthog.repoPath", true),
209
+ 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(),
210
+ projectMap: z.record(z.string(), z.unknown(), { error: "posthog.projectMap must be an object" }).optional(),
211
+ ...Object.fromEntries(Object.entries(posthogNumberRanges).map(([key, range]) => [key, Object.hasOwn(POSTHOG_WHOLE_NUMBER_ROUNDING, key) ? optionalWholeNumber(`posthog.${key}`, range) : optionalNumber(`posthog.${key}`, range)]))
212
+ });
213
+ var usageCostModeMessage = `usage.costMode must be one of ${USAGE_COST_MODES.join(", ")}`;
214
+ var usageVendorShape = Object.fromEntries(USAGE_VENDOR_KEYS.map((key) => [key, optionalBoolean(`usage.vendors.${key}`)]));
215
+ var usageBudgetShape = Object.fromEntries(USAGE_BUDGET_KEYS.map((key) => [key, z.number({ error: `usage.budget.${key} must be a positive number or null` }).positive({ error: `usage.budget.${key} must be a positive number or null` }).nullable().optional()]));
216
+ var createUsageSettings = (isAbsolutePath) => optionalObject("usage", {
217
+ enabled: optionalBoolean("usage.enabled"),
218
+ fetchPricing: optionalBoolean("usage.fetchPricing"),
219
+ planLimits: optionalBoolean("usage.planLimits"),
220
+ rtkSavings: optionalBoolean("usage.rtkSavings"),
221
+ scanIntervalMinutes: optionalInteger("usage.scanIntervalMinutes", USAGE_INTEGER_RANGES.scanIntervalMinutes),
222
+ retainDays: optionalInteger("usage.retainDays", USAGE_INTEGER_RANGES.retainDays),
223
+ warehouseRetainDays: optionalInteger("usage.warehouseRetainDays", USAGE_INTEGER_RANGES.warehouseRetainDays),
224
+ sessionBlockHours: optionalInteger("usage.sessionBlockHours", USAGE_INTEGER_RANGES.sessionBlockHours),
225
+ costMode: z.enum(USAGE_COST_MODES, { error: usageCostModeMessage }).optional(),
226
+ vendors: optionalObject("usage.vendors", usageVendorShape),
227
+ budget: optionalObject("usage.budget", usageBudgetShape),
228
+ extraProjectsDirs: z.array(z.string({ error: "usage.extraProjectsDirs must be an array of absolute paths" }), { error: "usage.extraProjectsDirs must be an array of absolute paths" }).transform((directories) => directories.map((directory) => directory.trim())).refine((directories) => directories.every((directory) => directory && isAbsolutePath(directory)), { message: "usage.extraProjectsDirs entries must be absolute paths" }).optional()
229
+ });
230
+ var TelegramSettings = optionalObject("telegram", {
231
+ botToken: optionalString("telegram.botToken", true),
232
+ chatId: optionalString("telegram.chatId", true)
233
+ });
234
+ var IngestSettings = z.object({ enabled: optionalBoolean("ingest.enabled") }, { error: "ingest must be an object" }).passthrough().optional();
235
+ var TraceSettings = z.object({ enabled: optionalBoolean("trace.enabled") }, { error: "trace must be an object" }).optional();
236
+ var PlanReviewSettings = z.object({ enabled: optionalBoolean("planReview.enabled") }, { error: "planReview must be an object" }).optional();
237
+ var optionalPathList = (field) => z.array(z.string({ error: `${field} must be an array of paths` }).trim().min(1, { error: `${field} must be an array of paths` }), { error: `${field} must be an array of paths` }).optional();
238
+ var guardrailsShape = {
239
+ unguardedRepos: optionalPathList("guardrails.unguardedRepos"),
240
+ blockedPaths: optionalPathList("guardrails.blockedPaths"),
241
+ unreadablePaths: optionalPathList("guardrails.unreadablePaths")
242
+ };
243
+ var isHomeRelativePath = (entry) => entry === "~" || entry.startsWith("~/") || entry.startsWith("~\\");
244
+ var createGuardrailsSettings = (isAbsolutePath) => z.object({
245
+ ...guardrailsShape,
246
+ blockedPaths: z.array(z.string({ error: "guardrails.blockedPaths must be an array of paths" }).trim().min(1, { error: "guardrails.blockedPaths must be an array of paths" }).refine((entry) => isHomeRelativePath(entry) || isAbsolutePath(entry), { message: "guardrails.blockedPaths entries must be absolute paths or start with ~/" }), { error: "guardrails.blockedPaths must be an array of paths" }).optional()
247
+ }, { error: "guardrails must be an object" }).strict().optional();
248
+ var GuardrailsFileSettings = z.object(guardrailsShape, { error: "guardrails must be an object" }).passthrough().optional();
249
+ var telemetryShape = { enabled: optionalBoolean("telemetry.enabled") };
250
+ var TelemetrySettings = z.object(telemetryShape, { error: "telemetry must be an object" }).strict().optional();
251
+ var TelemetryFileSettings = z.object(telemetryShape, { error: "telemetry must be an object" }).passthrough().optional();
252
+ var createBrowserConfigShape = (isAbsolutePath) => ({
253
+ port: z.number().int().min(PORT_RANGE.min).max(PORT_RANGE.max).optional(),
254
+ notifyDebounceMs: z.number().finite().nonnegative().optional(),
255
+ phoneEscalationMs: z.number().finite().nonnegative().optional(),
256
+ replayBufferKB: optionalWholeNumber("replayBufferKB", REPLAY_BUFFER_KB_RANGE),
257
+ sessionMemoryReserveMB: optionalWholeNumber("sessionMemoryReserveMB", MEMORY_RESERVE_MB_RANGE),
258
+ cursorBlink: optionalBoolean("cursorBlink"),
259
+ debugMode: optionalBoolean("debugMode"),
260
+ conversationView: optionalBoolean("conversationView"),
261
+ streamerMode: optionalBoolean("streamerMode"),
262
+ zenView: optionalBoolean("zenView"),
263
+ detectBackgroundAgents: optionalBoolean("detectBackgroundAgents"),
264
+ recordSignals: optionalBoolean("recordSignals"),
265
+ rtk: optionalBoolean("rtk"),
266
+ saneYolo: optionalBoolean("saneYolo"),
267
+ skipPermissionsByDefault: optionalBoolean("skipPermissionsByDefault"),
268
+ checkForUpdates: optionalBoolean("checkForUpdates"),
269
+ updateChannel: z.enum(UPDATE_CHANNELS, { error: "updateChannel must be one of release, main" }).optional(),
270
+ autoResume: optionalBoolean("autoResume"),
271
+ telegramNotifications: optionalBoolean("telegramNotifications"),
272
+ integrationBranch: optionalString("integrationBranch").nullable(),
273
+ worktreeRoot: optionalString("worktreeRoot"),
274
+ worktreeShare: z.array(z.string()).optional(),
275
+ repoRoots: z.array(z.string()).optional(),
276
+ changeMap: ChangeMapSettings,
277
+ taskTitle: TaskTitleSettings,
278
+ branchGc: BranchGcSettings,
279
+ postTurnChecks: PostTurnChecksSettings,
280
+ visions: VisionsSettings,
281
+ github: GithubSettings,
282
+ teamReview: TeamReviewSettings,
283
+ benchmarks: BenchmarksSettings,
284
+ coherence: CoherenceSettings,
285
+ posthog: PosthogSettings,
286
+ usage: createUsageSettings(isAbsolutePath),
287
+ telegram: TelegramSettings,
288
+ ingest: IngestSettings,
289
+ guardrails: createGuardrailsSettings(isAbsolutePath),
290
+ telemetry: TelemetrySettings,
291
+ workflows: WorkflowsSettings.nullable().optional()
292
+ });
293
+ var createBrowserConfig = (isAbsolutePath) => z.object(createBrowserConfigShape(isAbsolutePath));
294
+ //#endregion
295
+ //#region shared/contracts/config.ts
296
+ var BrowserConfig = createBrowserConfig(path.isAbsolute);
297
+ var BROWSER_CONFIG_SHAPE = BrowserConfig.shape;
298
+ var ConfigUpdate = z.object({
299
+ ...BROWSER_CONFIG_SHAPE,
300
+ notifyDebounceMs: z.number({ error: "notifyDebounceMs must be a positive number" }).finite().positive({ error: "notifyDebounceMs must be a positive number" }).optional(),
301
+ phoneEscalationMs: z.number({ error: "phoneEscalationMs must be a positive number" }).finite().positive({ error: "phoneEscalationMs must be a positive number" }).optional(),
302
+ branchGc: BranchGcControlSettings,
303
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
304
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
305
+ worktreeRerere: optionalBoolean("worktreeRerere"),
306
+ workflows: WorkflowsSettingsUpdate.optional()
307
+ }).omit({
308
+ port: true,
309
+ worktreeShare: true
310
+ }).strict();
311
+ var AGENT_ID_RE = /^[a-z][a-z0-9-]{1,31}$/;
312
+ var BUILTIN_AGENT_IDS = Object.freeze([
313
+ "claude-code",
314
+ "codex",
315
+ "grok"
316
+ ]);
317
+ var AGENT_ID_SHAPE_MESSAGE = "an agent id of 2 to 32 characters of lowercase letters, digits and dashes, starting with a letter";
318
+ var AGENT_COMMAND_BASENAME_RE = /^[A-Za-z0-9._+-]+$/;
319
+ var AGENT_COMMAND_ABSOLUTE_RE = /^(?:\/|[A-Za-z]:[\\/])[A-Za-z0-9._+\-\\/]*[A-Za-z0-9._+-]$/;
320
+ var AGENT_COMMAND_SHAPE_MESSAGE = "a bare command name or an absolute path, built only from letters, digits, dot, underscore, plus, dash and path separators";
321
+ function isSpawnableCommand(command) {
322
+ if (AGENT_COMMAND_BASENAME_RE.test(command)) return true;
323
+ return AGENT_COMMAND_ABSOLUTE_RE.test(command);
324
+ }
325
+ var GIT_BRANCH_FORBIDDEN_PUNCTUATION_RE = /[~^:?*[\\]/;
326
+ var GIT_BRANCH_FORBIDDEN_SEQUENCES = [
327
+ "..",
328
+ "@{",
329
+ "//"
330
+ ];
331
+ function isControlOrSpaceCharacter(character) {
332
+ const codePoint = character.charCodeAt(0);
333
+ return codePoint <= 32 || codePoint === 127;
334
+ }
335
+ function isGitBranchName(name) {
336
+ if (name === "" || name === "@" || name === "HEAD") return false;
337
+ if (name.startsWith("-") || name.startsWith("/") || name.endsWith("/") || name.endsWith(".")) return false;
338
+ if (GIT_BRANCH_FORBIDDEN_SEQUENCES.some((sequence) => name.includes(sequence))) return false;
339
+ if (GIT_BRANCH_FORBIDDEN_PUNCTUATION_RE.test(name) || [...name].some(isControlOrSpaceCharacter)) return false;
340
+ return name.split("/").every((component) => !component.startsWith(".") && !component.endsWith(".lock"));
341
+ }
342
+ var CustomAgentDeclaration = z.object({
343
+ id: z.string({ error: "customAgents[].id must be a string" }).regex(AGENT_ID_RE, { error: `customAgents[].id must be ${AGENT_ID_SHAPE_MESSAGE}` }),
344
+ label: z.string({ error: "customAgents[].label must be a string" }).min(1, { error: "customAgents[].label must not be empty" }).max(60, { error: "customAgents[].label must be at most 60 characters" }),
345
+ command: z.string({ error: "customAgents[].command must be a string" }).min(1, { error: "customAgents[].command must not be empty" }).refine((command) => command.trim().length > 0, { error: "customAgents[].command must not be blank" }).refine(isSpawnableCommand, { error: `customAgents[].command must be ${AGENT_COMMAND_SHAPE_MESSAGE}` }),
346
+ args: z.array(z.string({ error: "customAgents[].args must be an array of strings" }), { error: "customAgents[].args must be an array of strings" }).default([]),
347
+ idleTitle: z.string({ error: "customAgents[].idleTitle must be a string" }).optional(),
348
+ busyTitle: z.string({ error: "customAgents[].busyTitle must be a string" }).optional()
349
+ }).strict();
350
+ var CustomAgentDeclarations = z.array(CustomAgentDeclaration, { error: "customAgents must be an array" }).superRefine((declarations, ctx) => {
351
+ const claimedIds = new Set(BUILTIN_AGENT_IDS);
352
+ for (const [index, declaration] of declarations.entries()) {
353
+ if (!claimedIds.has(declaration.id)) {
354
+ claimedIds.add(declaration.id);
355
+ continue;
356
+ }
357
+ const message = BUILTIN_AGENT_IDS.some((builtinAgentId) => builtinAgentId === declaration.id) ? `customAgents[${index}].id "${declaration.id}" collides with the builtin agent of the same id` : `customAgents[${index}].id "${declaration.id}" is declared more than once`;
358
+ ctx.addIssue({
359
+ code: "custom",
360
+ path: [index, "id"],
361
+ message
362
+ });
363
+ }
364
+ });
365
+ var TaskTitleSources = z.object({
366
+ customTitle: TaskTitle.nullable().optional(),
367
+ pendingPromptTitle: TaskTitle.nullable().optional(),
368
+ refinedTitle: TaskTitle.nullable().optional(),
369
+ aiTitle: TaskTitle.nullable().optional(),
370
+ oscTitle: TaskTitle.nullable().optional(),
371
+ promptTitle: TaskTitle.nullable().optional()
372
+ }).strict();
373
+ var TASK_TITLE_SOURCE_PRIORITY = [
374
+ "customTitle",
375
+ "pendingPromptTitle",
376
+ "refinedTitle",
377
+ "aiTitle",
378
+ "oscTitle",
379
+ "promptTitle"
380
+ ];
381
+ var PersistedTaskTitle = z.object({
382
+ taskTitle: TaskTitle.min(1),
383
+ isCustom: z.boolean(),
384
+ sources: TaskTitleSources
385
+ }).strict().refine(({ taskTitle, isCustom, sources }) => {
386
+ const source = TASK_TITLE_SOURCE_PRIORITY.find((candidate) => sources[candidate]?.trim());
387
+ if (!source) return false;
388
+ return sources[source]?.replace(/\s+/g, " ").trim() === taskTitle && isCustom === (source === "customTitle");
389
+ });
390
+ var ProjectConfig = z.object({
391
+ id: z.string().optional(),
392
+ name: z.string().optional(),
393
+ customTitle: TaskTitle.optional(),
394
+ taskTitleState: PersistedTaskTitle.optional().catch(void 0),
395
+ prLinks: SessionPrLinks.optional().catch(void 0),
396
+ path: z.string(),
397
+ repos: z.array(z.string()).min(2).optional(),
398
+ baseBranch: z.string().refine(isGitBranchName, { error: "projects[].baseBranch must be a git branch name" }).optional(),
399
+ agent: z.string({ error: "projects[].agent must be a string" }).regex(AGENT_ID_RE, { error: `projects[].agent must be ${AGENT_ID_SHAPE_MESSAGE}` }).optional(),
400
+ codexBypassHookTrust: z.boolean().optional(),
401
+ conversationView: z.boolean({ error: "projects[].conversationView must be a boolean" }).optional(),
402
+ dangerouslySkipPermissions: z.boolean({ error: "projects[].dangerouslySkipPermissions must be a boolean" }).optional(),
403
+ unguarded: z.boolean({ error: "projects[].unguarded must be a boolean" }).optional()
404
+ }).passthrough();
405
+ var FILE_CONFIG_SHAPE = {
406
+ ...BROWSER_CONFIG_SHAPE,
407
+ changeMap: ChangeMapSettings,
408
+ branchGc: optionalLooseObject("branchGc"),
409
+ coder: z.object({ appSlug: z.string().optional() }).loose().optional(),
410
+ visions: optionalLooseObject("visions"),
411
+ github: GithubSettings,
412
+ teamReview: optionalLooseObject("teamReview"),
413
+ benchmarks: optionalLooseObject("benchmarks"),
414
+ coherence: optionalLooseObject("coherence"),
415
+ posthog: optionalLooseObject("posthog"),
416
+ usage: optionalLooseObject("usage"),
417
+ telegram: optionalLooseObject("telegram"),
418
+ ingest: optionalLooseObject("ingest"),
419
+ workflows: optionalLooseObject("workflows"),
420
+ guardrails: GuardrailsFileSettings,
421
+ telemetry: TelemetryFileSettings,
422
+ trace: TraceSettings,
423
+ planReview: PlanReviewSettings,
424
+ customAgents: CustomAgentDeclarations.optional()
425
+ };
426
+ var Config = z.object({
427
+ ...FILE_CONFIG_SHAPE,
428
+ detectScheduledWakeups: optionalBoolean("detectScheduledWakeups"),
429
+ worktreeAutoRebase: optionalBoolean("worktreeAutoRebase"),
430
+ worktreeSyncOnStart: optionalBoolean("worktreeSyncOnStart"),
431
+ worktreeRerere: optionalBoolean("worktreeRerere"),
432
+ postTurnChecks: z.record(z.string(), z.unknown()).optional(),
433
+ hooks: z.unknown().optional(),
434
+ remote: z.object({
435
+ enabled: z.boolean().optional(),
436
+ port: z.number().int().min(1).max(65535).nullable().optional(),
437
+ publicHost: z.string().optional(),
438
+ allowedOrigins: z.array(z.string()).optional(),
439
+ ownerLogin: z.string().optional()
440
+ }).passthrough().optional(),
441
+ projects: z.array(ProjectConfig)
442
+ }).passthrough().superRefine((config, ctx) => {
443
+ if (!Array.isArray(config.projects)) return;
444
+ const declaredAgentIds = new Set(BUILTIN_AGENT_IDS);
445
+ for (const declaration of config.customAgents ?? []) declaredAgentIds.add(declaration.id);
446
+ for (const [index, project] of config.projects.entries()) {
447
+ const agent = project?.agent;
448
+ if (typeof agent !== "string" || !AGENT_ID_RE.test(agent)) continue;
449
+ if (declaredAgentIds.has(agent)) continue;
450
+ ctx.addIssue({
451
+ code: "custom",
452
+ path: [
453
+ "projects",
454
+ index,
455
+ "agent"
456
+ ],
457
+ message: `projects[${index}].agent "${agent}" names no known agent; declare it under customAgents or use one of ${[...declaredAgentIds].join(", ")}`
458
+ });
459
+ }
460
+ });
461
+ var CONFIG_BLOCK_KEYS = Object.freeze([
462
+ "changeMap",
463
+ "taskTitle",
464
+ "branchGc",
465
+ "postTurnChecks",
466
+ "visions",
467
+ "github",
468
+ "teamReview",
469
+ "benchmarks",
470
+ "coherence",
471
+ "posthog",
472
+ "usage",
473
+ "telegram",
474
+ "ingest",
475
+ "guardrails",
476
+ "telemetry",
477
+ "workflows",
478
+ "coder"
479
+ ]);
480
+ var CONFIG_SCALAR_KEYS = Object.freeze(Object.keys(BROWSER_CONFIG_SHAPE).filter((key) => {
481
+ if (CONFIG_BLOCK_KEYS.includes(key)) return false;
482
+ return key !== "port" && key !== "repoRoots" && key !== "worktreeShare";
483
+ }));
484
+ var RUNTIME_CONFIG_SCALAR_KEYS = Object.freeze([
485
+ ...CONFIG_SCALAR_KEYS,
486
+ "worktreeAutoRebase",
487
+ "worktreeSyncOnStart",
488
+ "worktreeRerere"
489
+ ]);
490
+ Object.freeze([
491
+ "detectScheduledWakeups",
492
+ "worktreeAutoRebase",
493
+ "worktreeSyncOnStart",
494
+ "worktreeRerere",
495
+ "hooks",
496
+ "remote",
497
+ "projects"
498
+ ]);
499
+ function configIssueMessage(error) {
500
+ return error.issues[0]?.message || "settings are invalid";
501
+ }
502
+ //#endregion
503
+ //#region shared/contracts/telemetry.ts
504
+ var TELEMETRY_ADAPTERS = Object.freeze([...BUILTIN_AGENT_IDS, "custom"]);
505
+ var SESSION_EXIT_KINDS = Object.freeze([
506
+ "clean",
507
+ "error",
508
+ "signal",
509
+ "no_output"
510
+ ]);
511
+ var nonNegativeInteger = z.number().int().nonnegative();
512
+ var boundedText = z.string().max(512);
513
+ var AppStartedProperties = z.object({}).strict();
514
+ var AppActiveProperties = z.object({ active_session_count: nonNegativeInteger }).strict();
515
+ var SessionStartedProperties = z.object({ adapter: z.enum(TELEMETRY_ADAPTERS) }).strict();
516
+ var SessionEndedProperties = z.object({
517
+ adapter: z.enum(TELEMETRY_ADAPTERS),
518
+ exit_kind: z.enum(SESSION_EXIT_KINDS),
519
+ duration_seconds: nonNegativeInteger
520
+ }).strict();
521
+ var ExceptionFrame = z.object({
522
+ platform: z.enum(["node:javascript", "web:javascript"]),
523
+ function: boundedText,
524
+ filename: boundedText,
525
+ lineno: nonNegativeInteger,
526
+ colno: nonNegativeInteger,
527
+ in_app: z.boolean()
528
+ }).strict();
529
+ var ExceptionProperties = z.object({
530
+ $exception_list: z.array(z.object({
531
+ type: boundedText,
532
+ value: boundedText,
533
+ mechanism: z.object({
534
+ handled: z.boolean(),
535
+ synthetic: z.boolean(),
536
+ type: z.literal("generic")
537
+ }).strict(),
538
+ stacktrace: z.object({
539
+ type: z.literal("raw"),
540
+ frames: z.array(ExceptionFrame).max(64)
541
+ }).strict()
542
+ }).strict()).length(1),
543
+ $exception_level: z.enum(["error", "fatal"])
544
+ }).strict();
545
+ var AiGenerationProperties = z.object({
546
+ $ai_trace_id: z.string().regex(/^[0-9a-f]{64}$/),
547
+ $ai_provider: z.string().max(64),
548
+ $ai_model: z.string().max(128),
549
+ $ai_input_tokens: nonNegativeInteger,
550
+ $ai_output_tokens: nonNegativeInteger,
551
+ $ai_cache_read_input_tokens: nonNegativeInteger.optional(),
552
+ $ai_cache_creation_input_tokens: nonNegativeInteger.optional(),
553
+ $ai_total_cost_usd: z.number().finite().nonnegative().optional(),
554
+ agent_adapter: z.enum(TELEMETRY_ADAPTERS)
555
+ }).strict();
556
+ var TELEMETRY_EVENT_SCHEMAS = Object.freeze({
557
+ app_started: AppStartedProperties,
558
+ app_active: AppActiveProperties,
559
+ session_started: SessionStartedProperties,
560
+ session_ended: SessionEndedProperties,
561
+ $exception: ExceptionProperties,
562
+ $ai_generation: AiGenerationProperties
563
+ });
564
+ Object.freeze([
565
+ {
566
+ name: "app_started",
567
+ description: "The server started listening."
568
+ },
569
+ {
570
+ name: "app_active",
571
+ description: "Once a day while the server runs, with how many sessions are live."
572
+ },
573
+ {
574
+ name: "session_started",
575
+ description: "A session spawned, with which kind of agent (any custom agent counts as `custom`)."
576
+ },
577
+ {
578
+ name: "session_ended",
579
+ description: "A session exited: how it exited and how long it ran, in whole seconds."
580
+ },
581
+ {
582
+ name: "$exception",
583
+ 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."
584
+ },
585
+ {
586
+ name: "$ai_generation",
587
+ 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."
588
+ }
589
+ ]);
590
+ Object.freeze([
591
+ "app_version",
592
+ "os_platform",
593
+ "node_major",
594
+ "install_flavor",
595
+ "is_bundled",
596
+ "is_dev_install"
597
+ ]);
598
+ Object.freeze(["$release_id"]);
599
+ var TELEMETRY_KILL_SWITCH_FLAG = "telemetry-enabled";
600
+ var FeatureFlagsResponse = z.object({
601
+ flags: z.object({ [TELEMETRY_KILL_SWITCH_FLAG]: z.object({ enabled: z.boolean() }).passthrough().optional() }).passthrough(),
602
+ errorsWhileComputingFlags: z.boolean().optional()
603
+ }).passthrough();
604
+ var PendingCrashReport = z.object({
605
+ timestamp: z.string(),
606
+ properties: ExceptionProperties
607
+ }).strict();
608
+ var TelemetryState = z.object({
609
+ installId: z.uuid(),
610
+ noticeShownAt: z.string().nullable().optional(),
611
+ remoteDisabled: z.boolean().optional()
612
+ });
613
+ var viewerCols = z.number().int().min(1).max(500);
614
+ var viewerRows = z.number().int().min(1).max(200);
615
+ var DataClientMessage = z.discriminatedUnion("type", [
616
+ z.object({
617
+ type: z.literal("input"),
618
+ data: z.string()
619
+ }),
620
+ z.object({
621
+ type: z.literal("claim"),
622
+ cols: viewerCols,
623
+ rows: viewerRows
624
+ }),
625
+ z.object({ type: z.literal("unview") })
626
+ ]);
627
+ z.object({
628
+ type: z.literal("pty-size"),
629
+ cols: viewerCols,
630
+ rows: viewerRows,
631
+ seq: z.number().int().nonnegative()
632
+ });
633
+ var DATA_ATTACH_HISTORY_PARAM = "history";
634
+ var DEEP_HISTORY_SCROLLBACK_LINES = 5e3;
635
+ var DataAttachHistory = z.enum(["screen", "deep"]);
636
+ function decodeJson(raw) {
637
+ try {
638
+ return JSON.parse(raw);
639
+ } catch {
640
+ return null;
641
+ }
642
+ }
643
+ function parseDataClientMessage(raw) {
644
+ const parsed = DataClientMessage.safeParse(decodeJson(raw));
645
+ if (!parsed.success) return null;
646
+ return parsed.data;
647
+ }
648
+ function parseDataAttachHistory(rawUrl) {
649
+ if (typeof rawUrl !== "string") return "screen";
650
+ const queryAt = rawUrl.indexOf("?");
651
+ if (queryAt === -1) return "screen";
652
+ const query = new URLSearchParams(rawUrl.slice(queryAt + 1).split("#")[0]);
653
+ const parsed = DataAttachHistory.safeParse(query.get(DATA_ATTACH_HISTORY_PARAM));
654
+ if (!parsed.success) return "screen";
655
+ return parsed.data;
656
+ }
657
+ //#endregion
658
+ //#region shared/contracts/hooks.ts
659
+ var HTTP_URL_RE = /^https?:\/\/\S+$/i;
660
+ var HookPayload = z.record(z.string(), z.unknown());
661
+ var HookEnvelope = z.object({
662
+ glimmervoidId: z.string().min(1),
663
+ event: z.string().min(1),
664
+ token: z.string().nullable().optional(),
665
+ payload: HookPayload
666
+ });
667
+ z.object({
668
+ id: z.string().min(1),
669
+ name: z.string().min(1),
670
+ event: z.string().min(1),
671
+ matcher: z.string().optional(),
672
+ type: z.enum(["command", "http"]),
673
+ command: z.string().optional(),
674
+ url: z.string().optional(),
675
+ timeout: z.number().int().positive().optional(),
676
+ enabled: z.boolean(),
677
+ projects: z.array(z.string()).optional()
678
+ }).passthrough();
679
+ //#endregion
680
+ export { UPDATE_CHANNELS as C, normalizeLegacyConfigNumbers as E, POST_TURN_CHECK_MODES as S, USAGE_VENDOR_KEYS as T, RUNTIME_CONFIG_SCALAR_KEYS as _, parseDataClientMessage as a, BranchGcFileSettings as b, TELEMETRY_EVENT_SCHEMAS as c, AGENT_ID_SHAPE_MESSAGE as d, BUILTIN_AGENT_IDS as f, PersistedTaskTitle as g, ConfigUpdate as h, parseDataAttachHistory as i, TELEMETRY_KILL_SWITCH_FLAG as l, Config as m, HookEnvelope as n, FeatureFlagsResponse as o, BrowserConfig as p, DEEP_HISTORY_SCROLLBACK_LINES as r, PendingCrashReport as s, HTTP_URL_RE as t, TelemetryState as u, TASK_TITLE_SOURCE_PRIORITY as v, USAGE_COST_MODES as w, CHANGE_MAP_NARRATOR_ENGINES as x, configIssueMessage as y };