Skip to content

Commit 1384077

Browse files
Telemetry refactor (#4021)
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent 1e5bf74 commit 1384077

29 files changed

+2428
-1602
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { z } from "zod"
2+
3+
/**
4+
* CodebaseIndexConfig
5+
*/
6+
7+
export const codebaseIndexConfigSchema = z.object({
8+
codebaseIndexEnabled: z.boolean().optional(),
9+
codebaseIndexQdrantUrl: z.string().optional(),
10+
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama"]).optional(),
11+
codebaseIndexEmbedderBaseUrl: z.string().optional(),
12+
codebaseIndexEmbedderModelId: z.string().optional(),
13+
})
14+
15+
export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>
16+
17+
/**
18+
* CodebaseIndexModels
19+
*/
20+
21+
export const codebaseIndexModelsSchema = z.object({
22+
openai: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
23+
ollama: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
24+
})
25+
26+
export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
27+
28+
/**
29+
* CdebaseIndexProvider
30+
*/
31+
32+
export const codebaseIndexProviderSchema = z.object({
33+
codeIndexOpenAiKey: z.string().optional(),
34+
codeIndexQdrantApiKey: z.string().optional(),
35+
})
36+
37+
export type CodebaseIndexProvider = z.infer<typeof codebaseIndexProviderSchema>

packages/types/src/experiment.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { z } from "zod"
2+
3+
import type { Keys, Equals, AssertEqual } from "./type-fu.js"
4+
5+
/**
6+
* ExperimentId
7+
*/
8+
9+
export const experimentIds = ["autoCondenseContext", "powerSteering"] as const
10+
11+
export const experimentIdsSchema = z.enum(experimentIds)
12+
13+
export type ExperimentId = z.infer<typeof experimentIdsSchema>
14+
15+
/**
16+
* Experiments
17+
*/
18+
19+
export const experimentsSchema = z.object({
20+
autoCondenseContext: z.boolean(),
21+
powerSteering: z.boolean(),
22+
})
23+
24+
export type Experiments = z.infer<typeof experimentsSchema>
25+
26+
type _AssertExperiments = AssertEqual<Equals<ExperimentId, Keys<Experiments>>>
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
import { z } from "zod"
2+
3+
import type { Keys } from "./type-fu.js"
4+
import {
5+
type ProviderSettings,
6+
PROVIDER_SETTINGS_KEYS,
7+
providerSettingsEntrySchema,
8+
providerSettingsSchema,
9+
} from "./provider-settings.js"
10+
import { historyItemSchema } from "./history.js"
11+
import { codebaseIndexModelsSchema, codebaseIndexConfigSchema } from "./codebase-index.js"
12+
import { experimentsSchema } from "./experiment.js"
13+
import { telemetrySettingsSchema } from "./telemetry.js"
14+
import { modeConfigSchema } from "./mode.js"
15+
import { customModePromptsSchema, customSupportPromptsSchema } from "./mode.js"
16+
import { languagesSchema } from "./vscode.js"
17+
18+
/**
19+
* GlobalSettings
20+
*/
21+
22+
export const globalSettingsSchema = z.object({
23+
currentApiConfigName: z.string().optional(),
24+
listApiConfigMeta: z.array(providerSettingsEntrySchema).optional(),
25+
pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(),
26+
27+
lastShownAnnouncementId: z.string().optional(),
28+
customInstructions: z.string().optional(),
29+
taskHistory: z.array(historyItemSchema).optional(),
30+
31+
condensingApiConfigId: z.string().optional(),
32+
customCondensingPrompt: z.string().optional(),
33+
34+
autoApprovalEnabled: z.boolean().optional(),
35+
alwaysAllowReadOnly: z.boolean().optional(),
36+
alwaysAllowReadOnlyOutsideWorkspace: z.boolean().optional(),
37+
codebaseIndexModels: codebaseIndexModelsSchema.optional(),
38+
codebaseIndexConfig: codebaseIndexConfigSchema.optional(),
39+
alwaysAllowWrite: z.boolean().optional(),
40+
alwaysAllowWriteOutsideWorkspace: z.boolean().optional(),
41+
writeDelayMs: z.number().optional(),
42+
alwaysAllowBrowser: z.boolean().optional(),
43+
alwaysApproveResubmit: z.boolean().optional(),
44+
requestDelaySeconds: z.number().optional(),
45+
alwaysAllowMcp: z.boolean().optional(),
46+
alwaysAllowModeSwitch: z.boolean().optional(),
47+
alwaysAllowSubtasks: z.boolean().optional(),
48+
alwaysAllowExecute: z.boolean().optional(),
49+
allowedCommands: z.array(z.string()).optional(),
50+
allowedMaxRequests: z.number().nullish(),
51+
autoCondenseContextPercent: z.number().optional(),
52+
53+
browserToolEnabled: z.boolean().optional(),
54+
browserViewportSize: z.string().optional(),
55+
screenshotQuality: z.number().optional(),
56+
remoteBrowserEnabled: z.boolean().optional(),
57+
remoteBrowserHost: z.string().optional(),
58+
cachedChromeHostUrl: z.string().optional(),
59+
60+
enableCheckpoints: z.boolean().optional(),
61+
62+
ttsEnabled: z.boolean().optional(),
63+
ttsSpeed: z.number().optional(),
64+
soundEnabled: z.boolean().optional(),
65+
soundVolume: z.number().optional(),
66+
67+
maxOpenTabsContext: z.number().optional(),
68+
maxWorkspaceFiles: z.number().optional(),
69+
showRooIgnoredFiles: z.boolean().optional(),
70+
maxReadFileLine: z.number().optional(),
71+
72+
terminalOutputLineLimit: z.number().optional(),
73+
terminalShellIntegrationTimeout: z.number().optional(),
74+
terminalShellIntegrationDisabled: z.boolean().optional(),
75+
terminalCommandDelay: z.number().optional(),
76+
terminalPowershellCounter: z.boolean().optional(),
77+
terminalZshClearEolMark: z.boolean().optional(),
78+
terminalZshOhMy: z.boolean().optional(),
79+
terminalZshP10k: z.boolean().optional(),
80+
terminalZdotdir: z.boolean().optional(),
81+
terminalCompressProgressBar: z.boolean().optional(),
82+
83+
rateLimitSeconds: z.number().optional(),
84+
diffEnabled: z.boolean().optional(),
85+
fuzzyMatchThreshold: z.number().optional(),
86+
experiments: experimentsSchema.optional(),
87+
88+
language: languagesSchema.optional(),
89+
90+
telemetrySetting: telemetrySettingsSchema.optional(),
91+
92+
mcpEnabled: z.boolean().optional(),
93+
enableMcpServerCreation: z.boolean().optional(),
94+
95+
mode: z.string().optional(),
96+
modeApiConfigs: z.record(z.string(), z.string()).optional(),
97+
customModes: z.array(modeConfigSchema).optional(),
98+
customModePrompts: customModePromptsSchema.optional(),
99+
customSupportPrompts: customSupportPromptsSchema.optional(),
100+
enhancementApiConfigId: z.string().optional(),
101+
historyPreviewCollapsed: z.boolean().optional(),
102+
})
103+
104+
export type GlobalSettings = z.infer<typeof globalSettingsSchema>
105+
106+
type GlobalSettingsRecord = Record<Keys<GlobalSettings>, undefined>
107+
108+
const globalSettingsRecord: GlobalSettingsRecord = {
109+
codebaseIndexModels: undefined,
110+
codebaseIndexConfig: undefined,
111+
currentApiConfigName: undefined,
112+
listApiConfigMeta: undefined,
113+
pinnedApiConfigs: undefined,
114+
115+
lastShownAnnouncementId: undefined,
116+
customInstructions: undefined,
117+
taskHistory: undefined,
118+
119+
condensingApiConfigId: undefined,
120+
customCondensingPrompt: undefined,
121+
122+
autoApprovalEnabled: undefined,
123+
alwaysAllowReadOnly: undefined,
124+
alwaysAllowReadOnlyOutsideWorkspace: undefined,
125+
alwaysAllowWrite: undefined,
126+
alwaysAllowWriteOutsideWorkspace: undefined,
127+
writeDelayMs: undefined,
128+
alwaysAllowBrowser: undefined,
129+
alwaysApproveResubmit: undefined,
130+
requestDelaySeconds: undefined,
131+
alwaysAllowMcp: undefined,
132+
alwaysAllowModeSwitch: undefined,
133+
alwaysAllowSubtasks: undefined,
134+
alwaysAllowExecute: undefined,
135+
allowedCommands: undefined,
136+
allowedMaxRequests: undefined,
137+
autoCondenseContextPercent: undefined,
138+
139+
browserToolEnabled: undefined,
140+
browserViewportSize: undefined,
141+
screenshotQuality: undefined,
142+
remoteBrowserEnabled: undefined,
143+
remoteBrowserHost: undefined,
144+
145+
enableCheckpoints: undefined,
146+
147+
ttsEnabled: undefined,
148+
ttsSpeed: undefined,
149+
soundEnabled: undefined,
150+
soundVolume: undefined,
151+
152+
maxOpenTabsContext: undefined,
153+
maxWorkspaceFiles: undefined,
154+
showRooIgnoredFiles: undefined,
155+
maxReadFileLine: undefined,
156+
157+
terminalOutputLineLimit: undefined,
158+
terminalShellIntegrationTimeout: undefined,
159+
terminalShellIntegrationDisabled: undefined,
160+
terminalCommandDelay: undefined,
161+
terminalPowershellCounter: undefined,
162+
terminalZshClearEolMark: undefined,
163+
terminalZshOhMy: undefined,
164+
terminalZshP10k: undefined,
165+
terminalZdotdir: undefined,
166+
terminalCompressProgressBar: undefined,
167+
168+
rateLimitSeconds: undefined,
169+
diffEnabled: undefined,
170+
fuzzyMatchThreshold: undefined,
171+
experiments: undefined,
172+
173+
language: undefined,
174+
175+
telemetrySetting: undefined,
176+
177+
mcpEnabled: undefined,
178+
enableMcpServerCreation: undefined,
179+
180+
mode: undefined,
181+
modeApiConfigs: undefined,
182+
customModes: undefined,
183+
customModePrompts: undefined,
184+
customSupportPrompts: undefined,
185+
enhancementApiConfigId: undefined,
186+
cachedChromeHostUrl: undefined,
187+
historyPreviewCollapsed: undefined,
188+
}
189+
190+
export const GLOBAL_SETTINGS_KEYS = Object.keys(globalSettingsRecord) as Keys<GlobalSettings>[]
191+
192+
/**
193+
* RooCodeSettings
194+
*/
195+
196+
export const rooCodeSettingsSchema = providerSettingsSchema.merge(globalSettingsSchema)
197+
198+
export type RooCodeSettings = GlobalSettings & ProviderSettings
199+
200+
/**
201+
* SecretState
202+
*/
203+
204+
export type SecretState = Pick<
205+
ProviderSettings,
206+
| "apiKey"
207+
| "glamaApiKey"
208+
| "openRouterApiKey"
209+
| "awsAccessKey"
210+
| "awsSecretKey"
211+
| "awsSessionToken"
212+
| "openAiApiKey"
213+
| "geminiApiKey"
214+
| "openAiNativeApiKey"
215+
| "deepSeekApiKey"
216+
| "mistralApiKey"
217+
| "unboundApiKey"
218+
| "requestyApiKey"
219+
| "xaiApiKey"
220+
| "groqApiKey"
221+
| "chutesApiKey"
222+
| "litellmApiKey"
223+
| "codeIndexOpenAiKey"
224+
| "codeIndexQdrantApiKey"
225+
>
226+
227+
export type CodeIndexSecrets = "codeIndexOpenAiKey" | "codeIndexQdrantApiKey"
228+
229+
type SecretStateRecord = Record<Keys<SecretState>, undefined>
230+
231+
const secretStateRecord: SecretStateRecord = {
232+
apiKey: undefined,
233+
glamaApiKey: undefined,
234+
openRouterApiKey: undefined,
235+
awsAccessKey: undefined,
236+
awsSecretKey: undefined,
237+
awsSessionToken: undefined,
238+
openAiApiKey: undefined,
239+
geminiApiKey: undefined,
240+
openAiNativeApiKey: undefined,
241+
deepSeekApiKey: undefined,
242+
mistralApiKey: undefined,
243+
unboundApiKey: undefined,
244+
requestyApiKey: undefined,
245+
xaiApiKey: undefined,
246+
groqApiKey: undefined,
247+
chutesApiKey: undefined,
248+
litellmApiKey: undefined,
249+
codeIndexOpenAiKey: undefined,
250+
codeIndexQdrantApiKey: undefined,
251+
}
252+
253+
export const SECRET_STATE_KEYS = Object.keys(secretStateRecord) as Keys<SecretState>[]
254+
255+
export const isSecretStateKey = (key: string): key is Keys<SecretState> =>
256+
SECRET_STATE_KEYS.includes(key as Keys<SecretState>)
257+
258+
/**
259+
* GlobalState
260+
*/
261+
262+
export type GlobalState = Omit<RooCodeSettings, Keys<SecretState>>
263+
264+
export const GLOBAL_STATE_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_KEYS].filter(
265+
(key: Keys<RooCodeSettings>) => !SECRET_STATE_KEYS.includes(key as Keys<SecretState>),
266+
) as Keys<GlobalState>[]
267+
268+
export const isGlobalStateKey = (key: string): key is Keys<GlobalState> =>
269+
GLOBAL_STATE_KEYS.includes(key as Keys<GlobalState>)

packages/types/src/history.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { z } from "zod"
2+
3+
/**
4+
* HistoryItem
5+
*/
6+
7+
export const historyItemSchema = z.object({
8+
id: z.string(),
9+
number: z.number(),
10+
ts: z.number(),
11+
task: z.string(),
12+
tokensIn: z.number(),
13+
tokensOut: z.number(),
14+
cacheWrites: z.number().optional(),
15+
cacheReads: z.number().optional(),
16+
totalCost: z.number(),
17+
size: z.number().optional(),
18+
workspace: z.string().optional(),
19+
})
20+
21+
export type HistoryItem = z.infer<typeof historyItemSchema>

packages/types/src/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
export * from "./types.js"
21
export * from "./api.js"
2+
export * from "./codebase-index.js"
3+
export * from "./experiment.js"
4+
export * from "./global-settings.js"
5+
export * from "./history.js"
6+
export * from "./ipc.js"
7+
export * from "./message.js"
8+
export * from "./mode.js"
9+
export * from "./model.js"
10+
export * from "./provider-settings.js"
11+
export * from "./telemetry.js"
12+
export * from "./terminal.js"
13+
export * from "./tool.js"
14+
export * from "./type-fu.js"
15+
export * from "./vscode.js"

0 commit comments

Comments
 (0)