@happyvertical/smrt-preferences 0.61.6 → 0.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/agents/preference-kinds.md +21 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -151
- package/dist/index.js.map +1 -1
- package/dist/kinds/assistant-settings.d.ts +38 -0
- package/dist/kinds/assistant-settings.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +7 -7
- package/dist/smrt-knowledge.okf.md +2 -2
- package/package.json +8 -8
- package/dist/kinds/work-profiles.d.ts +0 -26
- package/dist/kinds/work-profiles.d.ts.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -31,7 +31,7 @@ Svelte-free entries (`./overview/server`, `./workspace/server`).
|
|
|
31
31
|
| `src/kinds/overview.ts`, `src/overview.ts` | The `overview` kind and `createOverviewStore` (`load`, `save`, `reset`, `loadPage`, `loadWidget`, `withTenantDefaults`) |
|
|
32
32
|
| `src/kinds/shell-layout.ts` | The `shell-layout` kind and `createShellSettingsPreferences` (the server half of a `ShellSettingsAdapter`) |
|
|
33
33
|
| `src/kinds/prebuilt-components.ts` | Tenant-wide pre-built components toggle, owner facade and exposure invalidation |
|
|
34
|
-
| `src/kinds/
|
|
34
|
+
| `src/kinds/assistant-settings.ts` | Owner assistant settings (workflow handoff, preview, removal approval, local AI protection) and revision-safe reset |
|
|
35
35
|
| `src/kinds/builtin.ts` | Registers the built-in kinds (imported by the entry and the store) |
|
|
36
36
|
| `src/context.ts` | The ambient principal and `PreferenceAccessError` |
|
|
37
37
|
| `src/permissions.ts` | `overviews.customize` / `overviews.personalize`, `shell.customize` / `shell.personalize` |
|
|
@@ -103,22 +103,24 @@ adapter from this model package root: even a metadata import makes its
|
|
|
103
103
|
`node:crypto` dependency reachable to browser bundlers. The preferences suite
|
|
104
104
|
reuses bundle-gate's browser build and ownership attribution to guard this edge.
|
|
105
105
|
|
|
106
|
-
## Assistant
|
|
107
|
-
|
|
108
|
-
`
|
|
109
|
-
`
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
## Assistant settings
|
|
107
|
+
|
|
108
|
+
`createAssistantSettingsPreference({store,isOwner})` owns the tenant-wide
|
|
109
|
+
`assistant-settings` / `assistant` kind (#5005): `escalateToWorkflow`,
|
|
110
|
+
`previewBeforeApply`, `requireRemovalApproval` and `protectLocalCli`, each a
|
|
111
|
+
boolean, absent meaning on. Inference owns the names and defaults
|
|
112
|
+
(`AssistantSettings`); this package imports only the type (a value import of
|
|
113
|
+
inference's root would register its executor) and mirrors the key list.
|
|
114
|
+
`write(settings,revision)` and `reset(revision)` both check the live owner plus
|
|
115
|
+
`inference.customize`, and retain store CAS. User-tier rows and unknown keys are
|
|
116
|
+
refused. Turning protection off requires the facade's explicit
|
|
117
|
+
`confirmUnprotectedCli` acknowledgement unless already off. Hosts must require
|
|
118
|
+
an owner browser session, not just a scoped API principal, and must not register
|
|
119
|
+
preference mutation as an assistant tool. Which model answers is the tier
|
|
120
|
+
binding's choice, never a preference here.
|
|
121
|
+
|
|
122
|
+
The removed `work-profiles` kind is not registered and saved rows of it are
|
|
123
|
+
dropped, never converted: reads are per kind, so such a row is never read, and a
|
|
124
|
+
store call that names the kind is refused with `UnknownPreferenceKindError`.
|
|
125
|
+
The kinds suite seeds one with raw SQL and proves other kinds still load, save
|
|
126
|
+
and list.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
import './__smrt-register__.js';
|
|
13
13
|
import './kinds/builtin.js';
|
|
14
14
|
export { getPreferencePrincipal, PreferenceAccessError, type PreferencePrincipal, } from './context.js';
|
|
15
|
+
export { ASSISTANT_SETTINGS_PREFERENCE_KIND, assistantSettingsPreferenceKind, createAssistantSettingsPreference, } from './kinds/assistant-settings.js';
|
|
15
16
|
export { ensureBuiltinPreferenceKinds } from './kinds/builtin.js';
|
|
16
17
|
export { OVERVIEW_PREFERENCE_KIND, type OverviewKindOptions, overviewPreferenceKind, withTenantDefaults, } from './kinds/overview.js';
|
|
17
18
|
export { createPrebuiltComponentsPreference, PREBUILT_COMPONENTS_PREFERENCE_KIND, } from './kinds/prebuilt-components.js';
|
|
18
19
|
export { createShellSettingsPreferences, SHELL_LAYOUT_PREFERENCE_KIND, type ShellSettingsPreferenceRead, type ShellSettingsPreferences, type ShellSettingsPreferenceWriteOptions, shellLayoutPreferenceKind, } from './kinds/shell-layout.js';
|
|
19
|
-
export { createWorkProfilesPreference, WORK_PROFILES_PREFERENCE_KIND, type WorkProfilePreferences, workProfilesPreferenceKind, } from './kinds/work-profiles.js';
|
|
20
20
|
export { getPreferenceKind, listPreferenceKinds, PREFERENCE_KIND_PATTERN, PREFERENCE_SCOPES, PREFERENCE_SURFACE_PATTERN, type PreferenceIssue, type PreferenceKindDefinition, type PreferenceScope, type PreferenceValidateContext, type PreferenceValidation, registerPreferenceKind, requirePreferenceKind, UnknownPreferenceKindError, } from './kinds.js';
|
|
21
21
|
export { TENANT_SCOPE_KEY, UiPreferenceRecord, } from './models/UiPreferenceRecord.js';
|
|
22
22
|
export { createOverviewStore, type OverviewPageOptions, type OverviewResetInput, type OverviewResetResult, type OverviewSaveInput, type OverviewSaveResult, type OverviewState, type OverviewStore, type OverviewStoreOptions, type OverviewTierState, type OverviewWidgetResult, type OverviewWriteFailure, } from './overview.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,mCAAmC,EACxC,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kCAAkC,EAClC,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,mCAAmC,EACxC,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,qCAAqC,EACrC,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,GAC5B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { GlobalInterceptors, ObjectRegistry, RuntimeError, SmrtCollection, SmrtObject, crossPackageRef, field, resolveGetStringFilter, smrt } from "@happyvertical/smrt-core";
|
|
2
2
|
import { COOKBOOK_TOOL_NAMES } from "@happyvertical/smrt-core/cookbook";
|
|
3
3
|
import { assertOperationPermission, checkOperationPermission, getCurrentSessionPermissionContext, registerPermissionDefinitions } from "@happyvertical/smrt-users";
|
|
4
|
+
import { TenantIsolationError, TenantScoped, getCurrentTenant, isSuperAdminBypass, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
4
5
|
import { checkOverviewOverride, diffOverview, loadOverview, optionsEqual, parseOverviewDocument, resolveOverview, sanitizeOverview } from "@happyvertical/smrt-svelte/overview/server";
|
|
5
6
|
import { notifyRuntimeExposureChanged } from "@happyvertical/smrt-core/runtime-exposure";
|
|
6
|
-
import { TenantIsolationError, TenantScoped, getCurrentTenant, isSuperAdminBypass, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
7
7
|
import { mergeShellSettingsDelta, sanitizeShellSettingsDelta } from "@happyvertical/smrt-svelte/workspace/server";
|
|
8
8
|
//#region src/__smrt-register__.ts
|
|
9
|
-
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-preferences","packageVersion":"0.61.6","objects":{"@happyvertical/smrt-preferences:UiPreferenceRecordCollection":{"name":"uipreferencerecordcollection","className":"UiPreferenceRecordCollection","qualifiedName":"@happyvertical/smrt-preferences:UiPreferenceRecordCollection","collection":"uipreferencerecords","description":"Reads of UiPreferenceRecord. Not decorated: the model has no generated surface, so a decorated collection would only add a second manifest schema for the same table.","filePath":"src/collections/UiPreferenceRecordCollection.ts","packageName":"@happyvertical/smrt-preferences","fields":{},"methods":{"findTier":{"name":"findTier","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"kind","type":"string","optional":false},{"name":"surfaceId","type":"string","optional":false},{"name":"scope","type":"PreferenceScope","optional":false},{"name":"userId","type":"string","optional":true}],"returnType":"Promise<UiPreferenceRecord | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_ui_preferences","api":{"include":[]},"mcp":{"include":[]},"cli":false},"extends":"SmrtCollection","extendsTypeArg":"UiPreferenceRecord","exportName":"UiPreferenceRecordCollection","collectionExportName":"UiPreferenceRecordCollectionCollection","collectionOf":"@happyvertical/smrt-preferences:UiPreferenceRecord","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_ui_preferences","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_ui_preferences\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT '',\\n \\"surface_id\\" TEXT NOT NULL DEFAULT '',\\n \\"scope_type\\" TEXT NOT NULL DEFAULT 'tenant',\\n \\"user_id\\" UUID,\\n \\"scope_key\\" TEXT NOT NULL,\\n \\"payload_json\\" TEXT NOT NULL,\\n \\"format_version\\" INTEGER,\\n \\"updated_by\\" UUID\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":""},"surface_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"scope_type":{"type":"TEXT","notNull":true,"unique":false,"default":"tenant"},"user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"scope_key":{"type":"TEXT","notNull":true,"unique":false},"payload_json":{"type":"TEXT","notNull":true,"unique":false},"format_version":{"type":"INTEGER","notNull":false,"unique":false},"updated_by":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_ui_preferences_tenant_id_kind_idx","columns":["tenant_id","kind","surface_id","scope_type","scope_key"],"unique":true},{"name":"_smrt_ui_preferences_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_ui_preferences_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_ui_preferences_user_id_idx","columns":["user_id"]},{"name":"_smrt_ui_preferences_updated_by_idx","columns":["updated_by"]}],"version":"7db98e07"},"importPath":"@happyvertical/smrt-preferences"},"@happyvertical/smrt-preferences:UiPreferenceRecord":{"name":"uipreferencerecord","className":"UiPreferenceRecord","qualifiedName":"@happyvertical/smrt-preferences:UiPreferenceRecord","collection":"uipreferencerecords","description":"One stored user-interface preference (#3727): the canonical payload of a registered preference kind (overview, shell-layout, ...) for one surface at one tier of one tenant.","filePath":"src/models/UiPreferenceRecord.ts","packageName":"@happyvertical/smrt-preferences","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"kind":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"identity"},"required":true,"default":""},"surfaceId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"identity"},"required":true,"default":""},"scopeType":{"type":"text","_meta":{"__statedOptions":["required","default"],"required":true},"required":true,"default":"tenant"},"userId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-users:User"},"scopeKey":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"payloadJson":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"system-table"},"required":true},"formatVersion":{"type":"integer","_meta":{"__statedOptions":[]},"required":false},"updatedBy":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-users:User"}},"methods":{"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getPayload":{"name":"getPayload","async":false,"parameters":[],"returnType":"unknown","isStatic":false,"isPublic":true},"setPayload":{"name":"setPayload","async":false,"parameters":[{"name":"value","type":"unknown","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"DeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_ui_preferences","conflictColumns":["tenant_id","kind","surface_id","scope_type","scope_key"],"api":{"include":[]},"cli":false,"mcp":{"include":[]},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"UiPreferenceRecord","collectionExportName":"UiPreferenceRecordCollection","validationRules":[{"field":"kind","rule":"required","fieldType":"text"},{"field":"surfaceId","rule":"required","fieldType":"text"},{"field":"scopeType","rule":"required","fieldType":"text"},{"field":"scopeKey","rule":"required","fieldType":"text"},{"field":"payloadJson","rule":"required","fieldType":"text"}],"schema":{"tableName":"_smrt_ui_preferences","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_ui_preferences\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT '',\\n \\"surface_id\\" TEXT NOT NULL DEFAULT '',\\n \\"scope_type\\" TEXT NOT NULL DEFAULT 'tenant',\\n \\"user_id\\" UUID,\\n \\"scope_key\\" TEXT NOT NULL,\\n \\"payload_json\\" TEXT NOT NULL,\\n \\"format_version\\" INTEGER,\\n \\"updated_by\\" UUID\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":""},"surface_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"scope_type":{"type":"TEXT","notNull":true,"unique":false,"default":"tenant"},"user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"scope_key":{"type":"TEXT","notNull":true,"unique":false},"payload_json":{"type":"TEXT","notNull":true,"unique":false},"format_version":{"type":"INTEGER","notNull":false,"unique":false},"updated_by":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_ui_preferences_tenant_id_kind_idx","columns":["tenant_id","kind","surface_id","scope_type","scope_key"],"unique":true},{"name":"_smrt_ui_preferences_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_ui_preferences_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_ui_preferences_user_id_idx","columns":["user_id"]},{"name":"_smrt_ui_preferences_updated_by_idx","columns":["updated_by"]}],"version":"7db98e07"},"importPath":"@happyvertical/smrt-preferences"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-inference","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3617","#3624","#3626","#3627"],"via":["@happyvertical/smrt-profiles","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"]},"stampsConstructors":true}`));
|
|
9
|
+
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-preferences","packageVersion":"0.62.1","objects":{"@happyvertical/smrt-preferences:UiPreferenceRecordCollection":{"name":"uipreferencerecordcollection","className":"UiPreferenceRecordCollection","qualifiedName":"@happyvertical/smrt-preferences:UiPreferenceRecordCollection","collection":"uipreferencerecords","description":"Reads of UiPreferenceRecord. Not decorated: the model has no generated surface, so a decorated collection would only add a second manifest schema for the same table.","filePath":"src/collections/UiPreferenceRecordCollection.ts","packageName":"@happyvertical/smrt-preferences","fields":{},"methods":{"findTier":{"name":"findTier","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"kind","type":"string","optional":false},{"name":"surfaceId","type":"string","optional":false},{"name":"scope","type":"PreferenceScope","optional":false},{"name":"userId","type":"string","optional":true}],"returnType":"Promise<UiPreferenceRecord | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_ui_preferences","api":{"include":[]},"mcp":{"include":[]},"cli":false},"extends":"SmrtCollection","extendsTypeArg":"UiPreferenceRecord","exportName":"UiPreferenceRecordCollection","collectionExportName":"UiPreferenceRecordCollectionCollection","collectionOf":"@happyvertical/smrt-preferences:UiPreferenceRecord","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_ui_preferences","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_ui_preferences\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT '',\\n \\"surface_id\\" TEXT NOT NULL DEFAULT '',\\n \\"scope_type\\" TEXT NOT NULL DEFAULT 'tenant',\\n \\"user_id\\" UUID,\\n \\"scope_key\\" TEXT NOT NULL,\\n \\"payload_json\\" TEXT NOT NULL,\\n \\"format_version\\" INTEGER,\\n \\"updated_by\\" UUID\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":""},"surface_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"scope_type":{"type":"TEXT","notNull":true,"unique":false,"default":"tenant"},"user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"scope_key":{"type":"TEXT","notNull":true,"unique":false},"payload_json":{"type":"TEXT","notNull":true,"unique":false},"format_version":{"type":"INTEGER","notNull":false,"unique":false},"updated_by":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_ui_preferences_tenant_id_kind_idx","columns":["tenant_id","kind","surface_id","scope_type","scope_key"],"unique":true},{"name":"_smrt_ui_preferences_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_ui_preferences_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_ui_preferences_user_id_idx","columns":["user_id"]},{"name":"_smrt_ui_preferences_updated_by_idx","columns":["updated_by"]}],"version":"7db98e07"},"importPath":"@happyvertical/smrt-preferences"},"@happyvertical/smrt-preferences:UiPreferenceRecord":{"name":"uipreferencerecord","className":"UiPreferenceRecord","qualifiedName":"@happyvertical/smrt-preferences:UiPreferenceRecord","collection":"uipreferencerecords","description":"One stored user-interface preference (#3727): the canonical payload of a registered preference kind (overview, shell-layout, ...) for one surface at one tier of one tenant.","filePath":"src/models/UiPreferenceRecord.ts","packageName":"@happyvertical/smrt-preferences","fields":{"tenantId":{"type":"text","_meta":{"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false},"__statedOptions":["sqlType","requiredFor","__tenancy"],"sqlType":"UUID","requiredFor":"tenant-scope"},"required":true},"kind":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"identity"},"required":true,"default":""},"surfaceId":{"type":"text","_meta":{"__statedOptions":["required","requiredFor","default"],"required":true,"requiredFor":"identity"},"required":true,"default":""},"scopeType":{"type":"text","_meta":{"__statedOptions":["required","default"],"required":true},"required":true,"default":"tenant"},"userId":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-users:User"},"scopeKey":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"identity"},"required":true},"payloadJson":{"type":"text","_meta":{"__statedOptions":["required","requiredFor"],"required":true,"requiredFor":"system-table"},"required":true},"formatVersion":{"type":"integer","_meta":{"__statedOptions":[]},"required":false},"updatedBy":{"type":"crossPackageRef","_meta":{"__statedOptions":["nullable","related","required"],"nullable":true,"required":false},"required":false,"related":"@happyvertical/smrt-users:User"}},"methods":{"loadFromId":{"name":"loadFromId","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"loadFromSlug":{"name":"loadFromSlug","async":true,"parameters":[],"returnType":"Promise<void>","isStatic":false,"isPublic":true},"getPayload":{"name":"getPayload","async":false,"parameters":[],"returnType":"unknown","isStatic":false,"isPublic":true},"setPayload":{"name":"setPayload","async":false,"parameters":[{"name":"value","type":"unknown","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"delete":{"name":"delete","async":true,"parameters":[{"name":"options","type":"DeleteOptions","optional":true}],"returnType":"Promise<void>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_ui_preferences","conflictColumns":["tenant_id","kind","surface_id","scope_type","scope_key"],"api":{"include":[]},"cli":false,"mcp":{"include":[]},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"UiPreferenceRecord","collectionExportName":"UiPreferenceRecordCollection","validationRules":[{"field":"kind","rule":"required","fieldType":"text"},{"field":"surfaceId","rule":"required","fieldType":"text"},{"field":"scopeType","rule":"required","fieldType":"text"},{"field":"scopeKey","rule":"required","fieldType":"text"},{"field":"payloadJson","rule":"required","fieldType":"text"}],"schema":{"tableName":"_smrt_ui_preferences","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_ui_preferences\\" (\\n \\"_sync_origin_device_id\\" TEXT,\\n \\"_sync_revision\\" INTEGER,\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"kind\\" TEXT NOT NULL DEFAULT '',\\n \\"surface_id\\" TEXT NOT NULL DEFAULT '',\\n \\"scope_type\\" TEXT NOT NULL DEFAULT 'tenant',\\n \\"user_id\\" UUID,\\n \\"scope_key\\" TEXT NOT NULL,\\n \\"payload_json\\" TEXT NOT NULL,\\n \\"format_version\\" INTEGER,\\n \\"updated_by\\" UUID\\n);","columns":{"_sync_origin_device_id":{"type":"TEXT"},"_sync_revision":{"type":"INTEGER"},"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"kind":{"type":"TEXT","notNull":true,"unique":false,"default":""},"surface_id":{"type":"TEXT","notNull":true,"unique":false,"default":""},"scope_type":{"type":"TEXT","notNull":true,"unique":false,"default":"tenant"},"user_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"scope_key":{"type":"TEXT","notNull":true,"unique":false},"payload_json":{"type":"TEXT","notNull":true,"unique":false},"format_version":{"type":"INTEGER","notNull":false,"unique":false},"updated_by":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_ui_preferences_tenant_id_kind_idx","columns":["tenant_id","kind","surface_id","scope_type","scope_key"],"unique":true},{"name":"_smrt_ui_preferences_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_ui_preferences_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_ui_preferences_user_id_idx","columns":["user_id"]},{"name":"_smrt_ui_preferences_updated_by_idx","columns":["updated_by"]}],"version":"7db98e07"},"importPath":"@happyvertical/smrt-preferences"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-inference","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3617","#3624","#3626","#3627"],"via":["@happyvertical/smrt-profiles","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"]},"stampsConstructors":true}`));
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/permissions.ts
|
|
12
12
|
var CUSTOMIZE_OVERVIEW_PERMISSION = "overviews.customize";
|
|
@@ -101,6 +101,122 @@ function listPreferenceKinds() {
|
|
|
101
101
|
return [...kinds.keys()];
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
|
+
//#region src/context.ts
|
|
105
|
+
function getPreferencePrincipal() {
|
|
106
|
+
const tenant = getCurrentTenant();
|
|
107
|
+
if (tenant?.tenantId) return {
|
|
108
|
+
tenantId: tenant.tenantId,
|
|
109
|
+
userId: tenant.userId,
|
|
110
|
+
permissions: tenant.permissions,
|
|
111
|
+
superAdminBypass: isSuperAdminBypass(),
|
|
112
|
+
fromTenancy: true
|
|
113
|
+
};
|
|
114
|
+
const session = getCurrentSessionPermissionContext();
|
|
115
|
+
if (!session?.tenantId) return void 0;
|
|
116
|
+
return {
|
|
117
|
+
tenantId: session.tenantId,
|
|
118
|
+
userId: session.userId ?? void 0,
|
|
119
|
+
permissions: session.permissionSet,
|
|
120
|
+
superAdminBypass: session.superAdminBypass,
|
|
121
|
+
fromTenancy: false
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
var PreferenceAccessError = class extends TenantIsolationError {
|
|
125
|
+
status = 403;
|
|
126
|
+
publicMessage;
|
|
127
|
+
constructor(message) {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = "PreferenceAccessError";
|
|
130
|
+
this.publicMessage = message;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
function requirePreferencePrincipal() {
|
|
134
|
+
const principal = getPreferencePrincipal();
|
|
135
|
+
if (!principal) throw new PreferenceAccessError("User-interface preferences need an authenticated tenant context");
|
|
136
|
+
return principal;
|
|
137
|
+
}
|
|
138
|
+
async function withPrincipal(principal, fn) {
|
|
139
|
+
if (principal.fromTenancy) return fn();
|
|
140
|
+
return withTenant({
|
|
141
|
+
tenantId: principal.tenantId,
|
|
142
|
+
userId: principal.userId,
|
|
143
|
+
permissions: new Set(principal.permissions)
|
|
144
|
+
}, fn);
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/kinds/assistant-settings.ts
|
|
148
|
+
var ASSISTANT_SETTINGS_PREFERENCE_KIND = "assistant-settings";
|
|
149
|
+
var SURFACE$1 = "assistant";
|
|
150
|
+
var KEYS = [
|
|
151
|
+
"escalateToWorkflow",
|
|
152
|
+
"previewBeforeApply",
|
|
153
|
+
"requireRemovalApproval",
|
|
154
|
+
"protectLocalCli"
|
|
155
|
+
];
|
|
156
|
+
function isAssistantSettings(value) {
|
|
157
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(([key, setting]) => KEYS.includes(key) && typeof setting === "boolean");
|
|
158
|
+
}
|
|
159
|
+
var assistantSettingsPreferenceKind = {
|
|
160
|
+
kind: ASSISTANT_SETTINGS_PREFERENCE_KIND,
|
|
161
|
+
formatVersion: 1,
|
|
162
|
+
permissions: {
|
|
163
|
+
tenant: "inference.customize",
|
|
164
|
+
user: "inference.customize"
|
|
165
|
+
},
|
|
166
|
+
validate(payload, context) {
|
|
167
|
+
return context.scope === "tenant" && (payload === null || isAssistantSettings(payload)) ? {
|
|
168
|
+
ok: true,
|
|
169
|
+
canonical: payload,
|
|
170
|
+
issues: []
|
|
171
|
+
} : {
|
|
172
|
+
ok: false,
|
|
173
|
+
canonical: null,
|
|
174
|
+
issues: [{
|
|
175
|
+
path: null,
|
|
176
|
+
code: "invalid_assistant_settings",
|
|
177
|
+
message: "Assistant settings hold only the workflow handoff, preview, removal approval and local AI protection switches."
|
|
178
|
+
}]
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
function createAssistantSettingsPreference(options) {
|
|
183
|
+
async function owner() {
|
|
184
|
+
if (!await options.isOwner(requirePreferencePrincipal())) throw new PreferenceAccessError("Only the owner can change the assistant settings");
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
async read() {
|
|
188
|
+
const state = await options.store.load(ASSISTANT_SETTINGS_PREFERENCE_KIND, SURFACE$1);
|
|
189
|
+
return {
|
|
190
|
+
settings: state.tenant.payload ?? {},
|
|
191
|
+
revision: state.tenant.revision,
|
|
192
|
+
issues: state.issues
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
/**
|
|
196
|
+
* Turning local AI protection off needs `confirmUnprotectedCli` unless
|
|
197
|
+
* it is already off.
|
|
198
|
+
*/
|
|
199
|
+
async write(settings, revision, confirmation) {
|
|
200
|
+
await owner();
|
|
201
|
+
if (settings?.protectLocalCli === false && confirmation?.confirmUnprotectedCli !== true) {
|
|
202
|
+
if ((await this.read()).settings.protectLocalCli !== false) throw new PreferenceAccessError("Confirm that chat can run commands and change files on this computer");
|
|
203
|
+
}
|
|
204
|
+
return options.store.save(ASSISTANT_SETTINGS_PREFERENCE_KIND, SURFACE$1, {
|
|
205
|
+
scope: "tenant",
|
|
206
|
+
payload: settings,
|
|
207
|
+
revision
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async reset(revision) {
|
|
211
|
+
await owner();
|
|
212
|
+
return options.store.reset(ASSISTANT_SETTINGS_PREFERENCE_KIND, SURFACE$1, {
|
|
213
|
+
scope: "tenant",
|
|
214
|
+
revision
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
104
220
|
//#region src/kinds/overview.ts
|
|
105
221
|
var OVERVIEW_PREFERENCE_KIND = "overview";
|
|
106
222
|
function withTenantDefaults(definition, document) {
|
|
@@ -179,52 +295,9 @@ var overviewPreferenceKind = {
|
|
|
179
295
|
}
|
|
180
296
|
};
|
|
181
297
|
//#endregion
|
|
182
|
-
//#region src/context.ts
|
|
183
|
-
function getPreferencePrincipal() {
|
|
184
|
-
const tenant = getCurrentTenant();
|
|
185
|
-
if (tenant?.tenantId) return {
|
|
186
|
-
tenantId: tenant.tenantId,
|
|
187
|
-
userId: tenant.userId,
|
|
188
|
-
permissions: tenant.permissions,
|
|
189
|
-
superAdminBypass: isSuperAdminBypass(),
|
|
190
|
-
fromTenancy: true
|
|
191
|
-
};
|
|
192
|
-
const session = getCurrentSessionPermissionContext();
|
|
193
|
-
if (!session?.tenantId) return void 0;
|
|
194
|
-
return {
|
|
195
|
-
tenantId: session.tenantId,
|
|
196
|
-
userId: session.userId ?? void 0,
|
|
197
|
-
permissions: session.permissionSet,
|
|
198
|
-
superAdminBypass: session.superAdminBypass,
|
|
199
|
-
fromTenancy: false
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
var PreferenceAccessError = class extends TenantIsolationError {
|
|
203
|
-
status = 403;
|
|
204
|
-
publicMessage;
|
|
205
|
-
constructor(message) {
|
|
206
|
-
super(message);
|
|
207
|
-
this.name = "PreferenceAccessError";
|
|
208
|
-
this.publicMessage = message;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
function requirePreferencePrincipal() {
|
|
212
|
-
const principal = getPreferencePrincipal();
|
|
213
|
-
if (!principal) throw new PreferenceAccessError("User-interface preferences need an authenticated tenant context");
|
|
214
|
-
return principal;
|
|
215
|
-
}
|
|
216
|
-
async function withPrincipal(principal, fn) {
|
|
217
|
-
if (principal.fromTenancy) return fn();
|
|
218
|
-
return withTenant({
|
|
219
|
-
tenantId: principal.tenantId,
|
|
220
|
-
userId: principal.userId,
|
|
221
|
-
permissions: new Set(principal.permissions)
|
|
222
|
-
}, fn);
|
|
223
|
-
}
|
|
224
|
-
//#endregion
|
|
225
298
|
//#region src/kinds/prebuilt-components.ts
|
|
226
299
|
var PREBUILT_COMPONENTS_PREFERENCE_KIND = "pre-built-components";
|
|
227
|
-
var SURFACE
|
|
300
|
+
var SURFACE = "app";
|
|
228
301
|
var prebuiltComponentsPreferenceKind = {
|
|
229
302
|
kind: PREBUILT_COMPONENTS_PREFERENCE_KIND,
|
|
230
303
|
formatVersion: 1,
|
|
@@ -257,7 +330,7 @@ function createPrebuiltComponentsPreference(options) {
|
|
|
257
330
|
async function read() {
|
|
258
331
|
const principal = requirePreferencePrincipal();
|
|
259
332
|
try {
|
|
260
|
-
const state = await options.store.load(PREBUILT_COMPONENTS_PREFERENCE_KIND, SURFACE
|
|
333
|
+
const state = await options.store.load(PREBUILT_COMPONENTS_PREFERENCE_KIND, SURFACE);
|
|
261
334
|
const value = state.issues.length === 0 && state.tenant.payload?.enabled !== false;
|
|
262
335
|
publish(principal.tenantId, value);
|
|
263
336
|
return {
|
|
@@ -277,7 +350,7 @@ function createPrebuiltComponentsPreference(options) {
|
|
|
277
350
|
async write(value, revision) {
|
|
278
351
|
const principal = requirePreferencePrincipal();
|
|
279
352
|
if (!await options.isOwner(principal)) throw new PreferenceAccessError("Only the owner can change pre-built components");
|
|
280
|
-
const result = await options.store.save(PREBUILT_COMPONENTS_PREFERENCE_KIND, SURFACE
|
|
353
|
+
const result = await options.store.save(PREBUILT_COMPONENTS_PREFERENCE_KIND, SURFACE, {
|
|
281
354
|
scope: "tenant",
|
|
282
355
|
payload: { enabled: value },
|
|
283
356
|
revision
|
|
@@ -361,111 +434,10 @@ function createShellSettingsPreferences(store) {
|
|
|
361
434
|
};
|
|
362
435
|
}
|
|
363
436
|
//#endregion
|
|
364
|
-
//#region src/kinds/work-profiles.ts
|
|
365
|
-
var WORK_PROFILES_PREFERENCE_KIND = "work-profiles";
|
|
366
|
-
var SURFACE = "assistant";
|
|
367
|
-
var profiles = /* @__PURE__ */ new Set([
|
|
368
|
-
"design",
|
|
369
|
-
"assist",
|
|
370
|
-
"background"
|
|
371
|
-
]);
|
|
372
|
-
var engines = /* @__PURE__ */ new Set([
|
|
373
|
-
"claude-code",
|
|
374
|
-
"codex",
|
|
375
|
-
"chatgpt",
|
|
376
|
-
"api"
|
|
377
|
-
]);
|
|
378
|
-
var budgets = /* @__PURE__ */ new Set([
|
|
379
|
-
"maxSteps",
|
|
380
|
-
"maxTokens",
|
|
381
|
-
"maxTurnTokens",
|
|
382
|
-
"requestTimeoutMs",
|
|
383
|
-
"turnTimeoutMs",
|
|
384
|
-
"maxRunTokens",
|
|
385
|
-
"runTimeoutMs",
|
|
386
|
-
"passes",
|
|
387
|
-
"repairRetries",
|
|
388
|
-
"toolResultChars"
|
|
389
|
-
]);
|
|
390
|
-
var record = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
391
|
-
function validSettings(value) {
|
|
392
|
-
if (!record(value)) return false;
|
|
393
|
-
return Object.entries(value).every(([key, v]) => {
|
|
394
|
-
if (key === "engine") return typeof v === "string" && engines.has(v);
|
|
395
|
-
if (key === "model") return typeof v === "string" && v.length > 0 && v.length <= 200 && !v.startsWith("-") && !/\s/.test(v) && [...v].every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
396
|
-
if (key === "effort") return typeof v === "string" && [
|
|
397
|
-
"low",
|
|
398
|
-
"medium",
|
|
399
|
-
"high",
|
|
400
|
-
"xhigh",
|
|
401
|
-
"max"
|
|
402
|
-
].includes(v);
|
|
403
|
-
if (key === "autoEscalate" || key === "previewBeforeApply") return typeof v === "boolean";
|
|
404
|
-
if (key === "budgets") return record(v) && Object.entries(v).every(([k, n]) => budgets.has(k) && Number.isSafeInteger(n) && n >= (k === "repairRetries" ? 0 : 1));
|
|
405
|
-
return false;
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
var workProfilesPreferenceKind = {
|
|
409
|
-
kind: WORK_PROFILES_PREFERENCE_KIND,
|
|
410
|
-
formatVersion: 1,
|
|
411
|
-
permissions: {
|
|
412
|
-
tenant: "inference.customize",
|
|
413
|
-
user: "inference.customize"
|
|
414
|
-
},
|
|
415
|
-
validate(payload, context) {
|
|
416
|
-
return context.scope === "tenant" && (payload === null || record(payload) && Object.entries(payload).every(([name, value]) => name === "safety" ? record(value) && Object.entries(value).every(([key, v]) => ["requireRemovalApproval", "protectLocalCli"].includes(key) && typeof v === "boolean") : profiles.has(name) && validSettings(value))) ? {
|
|
417
|
-
ok: true,
|
|
418
|
-
canonical: payload,
|
|
419
|
-
issues: []
|
|
420
|
-
} : {
|
|
421
|
-
ok: false,
|
|
422
|
-
canonical: null,
|
|
423
|
-
issues: [{
|
|
424
|
-
path: null,
|
|
425
|
-
code: "invalid_work_profiles",
|
|
426
|
-
message: "Work profiles must contain only supported engine, model, effort, budget, escalation and preview settings."
|
|
427
|
-
}]
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
function createWorkProfilesPreference(options) {
|
|
432
|
-
async function owner() {
|
|
433
|
-
if (!await options.isOwner(requirePreferencePrincipal())) throw new PreferenceAccessError("Only the owner can change assistant quality");
|
|
434
|
-
}
|
|
435
|
-
return {
|
|
436
|
-
async read() {
|
|
437
|
-
const state = await options.store.load(WORK_PROFILES_PREFERENCE_KIND, SURFACE);
|
|
438
|
-
return {
|
|
439
|
-
settings: state.tenant.payload ?? {},
|
|
440
|
-
revision: state.tenant.revision,
|
|
441
|
-
issues: state.issues
|
|
442
|
-
};
|
|
443
|
-
},
|
|
444
|
-
async write(settings, revision, confirmation) {
|
|
445
|
-
await owner();
|
|
446
|
-
if (settings?.safety?.protectLocalCli === false && confirmation?.confirmUnprotectedCli !== true) {
|
|
447
|
-
if ((await this.read()).settings.safety?.protectLocalCli !== false) throw new PreferenceAccessError("Confirm that chat can run commands and change files on this computer");
|
|
448
|
-
}
|
|
449
|
-
return options.store.save(WORK_PROFILES_PREFERENCE_KIND, SURFACE, {
|
|
450
|
-
scope: "tenant",
|
|
451
|
-
payload: settings,
|
|
452
|
-
revision
|
|
453
|
-
});
|
|
454
|
-
},
|
|
455
|
-
async reset(revision) {
|
|
456
|
-
await owner();
|
|
457
|
-
return options.store.reset(WORK_PROFILES_PREFERENCE_KIND, SURFACE, {
|
|
458
|
-
scope: "tenant",
|
|
459
|
-
revision
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
//#endregion
|
|
465
437
|
//#region src/kinds/builtin.ts
|
|
466
438
|
function ensureBuiltinPreferenceKinds() {
|
|
467
439
|
for (const kind of [
|
|
468
|
-
|
|
440
|
+
assistantSettingsPreferenceKind,
|
|
469
441
|
overviewPreferenceKind,
|
|
470
442
|
shellLayoutPreferenceKind,
|
|
471
443
|
prebuiltComponentsPreferenceKind
|
|
@@ -1177,6 +1149,6 @@ function createOverviewStore(options) {
|
|
|
1177
1149
|
return store;
|
|
1178
1150
|
}
|
|
1179
1151
|
//#endregion
|
|
1180
|
-
export { CUSTOMIZE_OVERVIEW_PERMISSION, CUSTOMIZE_SHELL_PERMISSION, OVERVIEW_PREFERENCE_KIND, PERSONALIZE_OVERVIEW_PERMISSION, PERSONALIZE_SHELL_PERMISSION, PREBUILT_COMPONENTS_PREFERENCE_KIND, PREFERENCE_KIND_PATTERN, PREFERENCE_PERMISSION_DEFINITIONS, PREFERENCE_SCOPES, PREFERENCE_SURFACE_PATTERN, PreferenceAccessError, SHELL_LAYOUT_PREFERENCE_KIND, TENANT_SCOPE_KEY, UiPreferenceRecord, UnknownPreferenceKindError,
|
|
1152
|
+
export { ASSISTANT_SETTINGS_PREFERENCE_KIND, CUSTOMIZE_OVERVIEW_PERMISSION, CUSTOMIZE_SHELL_PERMISSION, OVERVIEW_PREFERENCE_KIND, PERSONALIZE_OVERVIEW_PERMISSION, PERSONALIZE_SHELL_PERMISSION, PREBUILT_COMPONENTS_PREFERENCE_KIND, PREFERENCE_KIND_PATTERN, PREFERENCE_PERMISSION_DEFINITIONS, PREFERENCE_SCOPES, PREFERENCE_SURFACE_PATTERN, PreferenceAccessError, SHELL_LAYOUT_PREFERENCE_KIND, TENANT_SCOPE_KEY, UiPreferenceRecord, UnknownPreferenceKindError, assistantSettingsPreferenceKind, createAssistantSettingsPreference, createOverviewStore, createPrebuiltComponentsPreference, createPreferenceStore, createShellSettingsPreferences, ensureBuiltinPreferenceKinds, ensurePreferencePermissionsRegistered, getPreferenceKind, getPreferencePrincipal, listPreferenceKinds, overviewPreferenceKind, registerPreferenceKind, requirePreferenceKind, shellLayoutPreferenceKind, splitPermissionSlug, withTenantDefaults };
|
|
1181
1153
|
|
|
1182
1154
|
//# sourceMappingURL=index.js.map
|