11import { z } from "zod"
22
3+ import { globalSettingsSchema } from "./global-settings.js"
4+
5+ /**
6+ * CloudUserInfo
7+ */
8+
39export interface CloudUserInfo {
410 name ?: string
511 email ?: string
612 picture ?: string
713}
814
915/**
10- * Organization Allow List
16+ * OrganizationAllowList
1117 */
1218
1319export const organizationAllowListSchema = z . object ( {
@@ -22,33 +28,79 @@ export const organizationAllowListSchema = z.object({
2228
2329export type OrganizationAllowList = z . infer < typeof organizationAllowListSchema >
2430
25- export const ORGANIZATION_ALLOW_ALL : OrganizationAllowList = {
26- allowAll : true ,
27- providers : { } ,
28- } as const
31+ /**
32+ * OrganizationDefaultSettings
33+ */
34+
35+ export const organizationDefaultSettingsSchema = globalSettingsSchema
36+ . pick ( {
37+ enableCheckpoints : true ,
38+ fuzzyMatchThreshold : true ,
39+ maxOpenTabsContext : true ,
40+ maxReadFileLine : true ,
41+ maxWorkspaceFiles : true ,
42+ showRooIgnoredFiles : true ,
43+ terminalCommandDelay : true ,
44+ terminalCompressProgressBar : true ,
45+ terminalOutputLineLimit : true ,
46+ terminalShellIntegrationDisabled : true ,
47+ terminalShellIntegrationTimeout : true ,
48+ terminalZshClearEolMark : true ,
49+ } )
50+ // Add stronger validations for some fields.
51+ . merge (
52+ z . object ( {
53+ maxOpenTabsContext : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
54+ maxReadFileLine : z . number ( ) . int ( ) . gte ( - 1 ) . optional ( ) ,
55+ maxWorkspaceFiles : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
56+ terminalCommandDelay : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
57+ terminalOutputLineLimit : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
58+ terminalShellIntegrationTimeout : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
59+ } ) ,
60+ )
61+
62+ export type OrganizationDefaultSettings = z . infer < typeof organizationDefaultSettingsSchema >
63+
64+ /**
65+ * OrganizationCloudSettings
66+ */
67+
68+ export const organizationCloudSettingsSchema = z . object ( {
69+ recordTaskMessages : z . boolean ( ) . optional ( ) ,
70+ enableTaskSharing : z . boolean ( ) . optional ( ) ,
71+ taskShareExpirationDays : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
72+ } )
73+
74+ export type OrganizationCloudSettings = z . infer < typeof organizationCloudSettingsSchema >
2975
3076/**
3177 * Organization Settings
3278 */
3379
3480export const organizationSettingsSchema = z . object ( {
3581 version : z . number ( ) ,
36- defaultSettings : z
37- . object ( {
38- enableCheckpoints : z . boolean ( ) . optional ( ) ,
39- maxOpenTabsContext : z . number ( ) . optional ( ) ,
40- maxWorkspaceFiles : z . number ( ) . optional ( ) ,
41- showRooIgnoredFiles : z . boolean ( ) . optional ( ) ,
42- maxReadFileLine : z . number ( ) . optional ( ) ,
43- fuzzyMatchThreshold : z . number ( ) . optional ( ) ,
44- } )
45- . optional ( ) ,
46- cloudSettings : z
47- . object ( {
48- recordTaskMessages : z . boolean ( ) . optional ( ) ,
49- } )
50- . optional ( ) ,
82+ cloudSettings : organizationCloudSettingsSchema . optional ( ) ,
83+ defaultSettings : organizationDefaultSettingsSchema ,
5184 allowList : organizationAllowListSchema ,
5285} )
5386
5487export type OrganizationSettings = z . infer < typeof organizationSettingsSchema >
88+
89+ /**
90+ * Constants
91+ */
92+
93+ export const ORGANIZATION_ALLOW_ALL : OrganizationAllowList = {
94+ allowAll : true ,
95+ providers : { } ,
96+ } as const
97+
98+ export const ORGANIZATION_DEFAULT : OrganizationSettings = {
99+ version : 0 ,
100+ cloudSettings : {
101+ enableTaskSharing : true ,
102+ taskShareExpirationDays : 30 ,
103+ } ,
104+ defaultSettings : { } ,
105+ allowList : ORGANIZATION_ALLOW_ALL ,
106+ } as const
0 commit comments