@skaile/forge-layer-core 1.0.1 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @skaile/forge-layer-core
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7367ff9: Owners decide whether people may run the assistant on their own model: the settings scope `assistant-policy` (`ownModels`, default on, in Settings › Agents in the assistant's card; `ownModelsAllowed()`). Off, Profil shows no mode or key fields, just "The assistant uses the app's model", `assistant.account.update` refuses mode `byok` and own-key changes (403; removing a stored key still works) and stored keys are ignored, not deleted. New `personalModel(userId)` gives the person's provider, model, base URL and key when they chose "Own key" and the app allows it, so the SKAILE agent can run on it; `byokLanguageModel` builds on it and refuses while own models are off. `effectiveAssistantMode` now picks `skaile` whenever it is available to the person (with their own key under "Own key"), else `byok`. `assistant.account.get` reports `ownModels`. Profil names the modes "App's model" and "Own key", and offers "Own key" when either the SKAILE or the chat engine is installed. The Settings › Agents assistant card renders the form of every scope its parts name.
8
+
9
+ ## 1.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 12d3556: Hidden fallback model for the operator: set `NUXT_AI_FALLBACK_BASE_URL` (OpenAI-compatible, default `https://openrouter.ai/api/v1`), `NUXT_AI_FALLBACK_API_KEY` and `NUXT_AI_FALLBACK_MODEL` and every `chat` and `decision` model role that resolves its model in the app answers with it when nothing else does: after the assigned model and, for chat roles, the `NUXT_AI_*` environment model, and also when the assignment is not usable (bad selector, missing or refused key). When an assigned or environment model fails before any output (an error from the provider, a stream that fails before it starts), the call runs once more on the fallback; a stream that already started and an aborted call are not retried. The fallback stays on the server: `ai.status` and the Settings pages show it as "App default model" (`source: 'fallback'`, `selector: 'app/fallback'`), also to owners, never its model, URL or key; its key cannot be referenced by a provider entry or set with `ai.env.update`. Roles registered with `sdkModel: false` (the workspace agent) are unchanged, and so is `NUXT_AI_BASE_URL`/`NUXT_AI_API_KEY`/`NUXT_AI_MODEL`.
14
+
15
+ When the fallback stands in for an assignment that is not usable, `ai.status` gives owners a new `warning` (what is wrong with the assignment, and that the app's default model answers); everyone else gets `warning: null`. `AiRoleStatus` shows it as a warning line.
16
+ - 12d3556: New app config option `forgeCore.palettes` (default `true`). An app with a theme of its own sets it to `false`, and Settings > Profile no longer offers the forge palette picker.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [dc30563]
21
+ - Updated dependencies [acac8b8]
22
+ - @skaile/forge-app-actions@0.6.6
23
+ - @skaile/forge-settings@2.3.0
24
+
3
25
  ## 1.0.1
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -54,6 +54,44 @@ is the person record. On boot the server seeds the first owner from `APP_OWNER_E
54
54
  `NUXT_AUTH_RP_NAME` say otherwise (set origin and id behind a proxy). Challenges live in process memory for five
55
55
  minutes, so several web replicas need sticky sessions.
56
56
 
57
+ ## AI models
58
+
59
+ A model role (`registerModelRole`, `resolveRoleModel` in `server/utils/ai/roles.ts`) answers with, in this order:
60
+
61
+ 1. the model an owner assigned in Settings › Harness (`<provider>/<model>` of the provider registry in
62
+ `AI_PROVIDERS_DIR`, default `.data/ai`; keys `AI_PROVIDER_<NAME>` or `NUXT_AI_API_KEY`),
63
+ 2. for a `chat` role without an assignment, the environment: `NUXT_AI_BASE_URL` (OpenAI-compatible, default
64
+ OpenRouter), `NUXT_AI_API_KEY`, `NUXT_AI_MODEL`; shown as `env:<model>`,
65
+ 3. the operator's hidden fallback: `NUXT_AI_FALLBACK_BASE_URL` (OpenAI-compatible, default
66
+ `https://openrouter.ai/api/v1`), `NUXT_AI_FALLBACK_API_KEY`, `NUXT_AI_FALLBACK_MODEL`. It also answers when an
67
+ assignment is not usable, for `decision` roles too, and it takes over a call to the assigned or environment model
68
+ that fails before any output (not after a stream started, never on abort).
69
+
70
+ The fallback stays on the server: `ai.status` and the Settings pages show it only as "App default model"
71
+ (`source: 'fallback'`, `selector: 'app/fallback'`), owners included. Its key is outside the registry's credential
72
+ policy, so no provider entry can reference it and no key list shows it. A role registered with `sdkModel: false` (a
73
+ runner resolves the model itself, like the workspace agent) gets it as `source: 'fallback'` without call-time
74
+ failover; the runner builds its config from `NUXT_AI_FALLBACK_*` itself. When the fallback stands in for a broken
75
+ assignment, `ai.status` gives owners (only them) a `warning` with the assignment's problem; the role stays available.
76
+
77
+ ## The assistant's model
78
+
79
+ The app has one assistant, the SKAILE workspace agent (`skaile` engine, from layer-workspace-agent). It runs on the
80
+ app's model (the `assistant` role above) unless the person uses their own:
81
+
82
+ - **Own models** (settings scope `assistant-policy`, field `ownModels`, default on; `server/utils/assistant/policy.ts`,
83
+ `ownModelsAllowed()`): owners switch it in Settings › Agents, in the assistant's card. On, each person may pick
84
+ "Own key" (mode `byok`) in Settings › Profile and store provider, model and key (sealed under `NUXT_APP_SECRET`).
85
+ Off, nobody can pick it (`assistant.account.update` answers 403; `clearKey` still works), stored keys are kept but
86
+ ignored, and Profile shows one line: the assistant uses the app's model.
87
+ - `personalModel(userId)` (`server/utils/assistant/account.ts`): the person's provider, model, absolute base URL and
88
+ unsealed key when own models are allowed, they chose `byok` and stored all of it, else `null`. The SKAILE engine
89
+ runs on it; `byokLanguageModel(userId)` builds the plain chat engine's model (layer-chat) and refuses while own
90
+ models are off.
91
+ - `effectiveAssistantMode(principal)` (`server/utils/assistant/engines.ts`), the engine a new conversation uses:
92
+ `skaile` whenever it is available to the person (with their own key when they chose `byok`), else `byok` (the plain
93
+ chat, only the open page) when own models are allowed and the person can use it, else `null`.
94
+
57
95
  ## Importing core server code
58
96
 
59
97
  Other layers and the app's CLI and tests import through the package's `exports`, never `~~/server/...`:
package/app/app.config.ts CHANGED
@@ -9,6 +9,9 @@ export default defineAppConfig({
9
9
  /** Single texts replaced, per locale, keys namespaced by layer: `{ de: { 'core.login.submit': 'Los' } }`.
10
10
  * Keys: each layer's `en` catalog (core: `shared/i18n/core.en.ts`). */
11
11
  messages: {} as Partial<Record<ForgeLocale, Record<string, string>>>,
12
+ /** Whether Settings › Profile offers the forge palettes. An app with a theme of its own (it sets `data-palette`
13
+ * to its own id, as `templates/mobile` does) turns the picker off: `forgeCore: { palettes: false }`. */
14
+ palettes: true as boolean,
12
15
  },
13
16
  appShell: {
14
17
  // The sidebar: the app's own pages, the ones people work in every day. The app and each layer
@@ -5,17 +5,24 @@ import type { AiRoleStatusView } from '../types/ai'
5
5
  * What `ai.status` says about one model role. Full (an agent's card in
6
6
  * Settings › Agents): the model that answers, why the role is unavailable and
7
7
  * its extra checks (a CLI on PATH, a definition file). `compact` (under the
8
- * role's picker in Settings › Harness): only the environment fallback in use
9
- * or the reason the role cannot answer.
8
+ * role's picker in Settings › Harness): only a fallback in use (the
9
+ * environment's or the app's default model) or the reason the role cannot answer.
10
10
  */
11
11
  const props = defineProps<{ status: AiRoleStatusView; compact?: boolean }>()
12
12
  const { t } = useCoreI18n()
13
13
 
14
- const fromEnv = computed(() => props.status.model?.source === 'env')
14
+ const source = computed(() => props.status.model?.source)
15
+ const fromEnv = computed(() => source.value === 'env')
16
+ // The app's default model is hidden: its label is a fixed text, never a model id.
17
+ const appDefault = computed(() => source.value === 'fallback')
15
18
  // The env fallback's label is `env:<model id>`; the suffix says where it comes from.
16
19
  const modelName = computed(() =>
17
20
  fromEnv.value ? props.status.model?.label.replace(/^env:/, '') : props.status.model?.label,
18
21
  )
22
+ // Compact: "Unassigned: uses …", unless an assignment exists and the default model stands in for it.
23
+ const prefix = computed(() =>
24
+ props.compact && !props.status.assigned ? t('core.aiStatus.fallback') : t('core.aiStatus.model'),
25
+ )
19
26
  </script>
20
27
 
21
28
  <template>
@@ -24,12 +31,19 @@ const modelName = computed(() =>
24
31
  :data-testid="`ai-role-status-${status.id}`"
25
32
  >
26
33
  <p
27
- v-if="status.model && (!compact || fromEnv)"
34
+ v-if="status.model && (!compact || fromEnv || appDefault)"
28
35
  class="text-muted [overflow-wrap:anywhere]"
29
36
  :data-testid="`ai-role-model-${status.id}`"
30
37
  >
31
- {{ compact ? t('core.aiStatus.fallback') : t('core.aiStatus.model') }}
32
- <code class="font-mono text-default">{{ modelName }}</code>
38
+ {{ prefix }}
39
+ <span
40
+ v-if="appDefault"
41
+ class="text-default"
42
+ >{{ modelName }}</span>
43
+ <code
44
+ v-else
45
+ class="font-mono text-default"
46
+ >{{ modelName }}</code>
33
47
  <template v-if="fromEnv">
34
48
  {{ t('core.aiStatus.fromEnv') }}
35
49
  </template>
@@ -45,6 +59,17 @@ const modelName = computed(() =>
45
59
  />
46
60
  <span class="min-w-0 [overflow-wrap:anywhere]">{{ status.reason }}</span>
47
61
  </p>
62
+ <p
63
+ v-if="status.warning"
64
+ class="flex items-start gap-1.5 text-warning"
65
+ :data-testid="`ai-role-warning-${status.id}`"
66
+ >
67
+ <UIcon
68
+ name="i-tabler-alert-triangle"
69
+ class="mt-0.5 size-3.5 shrink-0"
70
+ />
71
+ <span class="min-w-0 [overflow-wrap:anywhere]">{{ status.warning }}</span>
72
+ </p>
48
73
  <ul
49
74
  v-if="!compact && status.checks.length"
50
75
  class="flex flex-col gap-1"
@@ -3,11 +3,13 @@ import * as z from 'zod'
3
3
 
4
4
  /**
5
5
  * Settings › Profile › Assistant: how the app's assistant works for the signed-in person
6
- * (`assistant.account.get` / `assistant.account.update`). Mode `skaile` runs it with SKAILE on
7
- * the server, with full access to the app and the person's rights; mode `byok` ("Own key") runs
8
- * it on the person's own provider key and lets it see only the record of the open page. One
9
- * form, one explicit Save (EDIT-2); the key is write-only: the page only learns whether one is
10
- * saved (`hasKey`) and removes it through `clearKey`.
6
+ * (`assistant.account.get` / `assistant.account.update`). Whether people may pick their own model
7
+ * is the owner's call (`assistant-policy.ownModels`, Settings › Agents). Allowed: mode `skaile`
8
+ * ("App's model") runs the SKAILE agent on the app's model; mode `byok` ("Own key") runs the same
9
+ * agent on the person's provider, model and key, or, without SKAILE in the app, the plain chat
10
+ * that sees only the record of the open page. Not allowed: one line says the assistant uses the
11
+ * app's model, and a saved key can still be removed. One form, one explicit Save (EDIT-2); the key
12
+ * is write-only: the page only learns whether one is saved (`hasKey`) and removes it through `clearKey`.
11
13
  */
12
14
 
13
15
  const actions = useActions()
@@ -76,19 +78,32 @@ useLeaveGuard(dirty)
76
78
  const missing = computed(() => missingFields(schema.value, state, labels.value))
77
79
  const form = useTemplateRef('form')
78
80
 
79
- // A mode that is not installed cannot be chosen; "Own key" stays choosable without a key,
80
- // because this form is where the key is entered (so its reason, which points here, is not repeated).
81
- const modeItems = computed(() =>
82
- (account.value?.modes ?? []).map(({ mode, available, installed, reason }) => {
81
+ // "App's model" needs the SKAILE engine. "Own key" runs on the SKAILE engine or, without it, on the plain chat
82
+ // engine, so it is offered when either is installed, and it stays choosable without a key, because this form is
83
+ // where the key is entered (so its reason, which points here, is not repeated).
84
+ const modeItems = computed(() => {
85
+ const modes = account.value?.modes ?? []
86
+ const skaile = modes.find(entry => entry.mode === 'skaile')
87
+ const byokInstalled = Boolean(skaile?.installed || modes.find(entry => entry.mode === 'byok')?.installed)
88
+ return modes.map(({ mode, available, installed, reason }) => {
89
+ if (mode === 'byok')
90
+ return {
91
+ value: mode,
92
+ label: t('core.assistant.mode.byok'),
93
+ description: byokInstalled
94
+ ? t(skaile?.installed ? 'core.assistant.modeHint.byok' : 'core.assistant.modeHint.byokChat')
95
+ : `${t('core.assistant.modeHint.byok')} ${t('core.assistant.notInstalled')}`,
96
+ disabled: !byokInstalled,
97
+ }
83
98
  const hint = t(`core.assistant.modeHint.${mode}`)
84
99
  return {
85
100
  value: mode,
86
101
  label: t(`core.assistant.mode.${mode}`),
87
- description: available || !reason || mode === 'byok' ? hint : `${hint} ${reason}`,
88
- disabled: !installed || (!available && mode !== 'byok'),
102
+ description: available || !reason ? hint : `${hint} ${reason}`,
103
+ disabled: !installed || !available,
89
104
  }
90
- }),
91
- )
105
+ })
106
+ })
92
107
  const presetItems = computed(() =>
93
108
  PRESETS.map(({ value, label }) => ({
94
109
  value,
@@ -178,7 +193,17 @@ async function removeKey() {
178
193
  @submit="onSave"
179
194
  @error="focusFirstError"
180
195
  >
181
- <UFormField name="mode">
196
+ <p
197
+ v-if="!account.ownModels"
198
+ class="text-sm text-muted"
199
+ data-testid="assistant-app-model-only"
200
+ >
201
+ {{ t('core.assistant.appModelOnly') }}
202
+ </p>
203
+ <UFormField
204
+ v-else
205
+ name="mode"
206
+ >
182
207
  <URadioGroup
183
208
  v-model="state.mode"
184
209
  :items="modeItems"
@@ -188,7 +213,7 @@ async function removeKey() {
188
213
  />
189
214
  </UFormField>
190
215
 
191
- <template v-if="state.mode === 'byok'">
216
+ <template v-if="account.ownModels && state.mode === 'byok'">
192
217
  <UFormField
193
218
  name="preset"
194
219
  :label="labels.preset"
@@ -271,6 +296,7 @@ async function removeKey() {
271
296
  </div>
272
297
 
273
298
  <SettingsSave
299
+ v-if="account?.ownModels"
274
300
  :dirty="dirty"
275
301
  :loading="saving"
276
302
  :missing="missing"
@@ -1,5 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { defineComponent, h } from 'vue'
3
+ // From `#components`, so an app's own `SettingsScopeForm` replaces the layer's here too.
4
+ import { SettingsScopeForm } from '#components'
3
5
  import type { AppShellSettingsSection } from '../../types/app-shell'
4
6
 
5
7
  /**
@@ -7,11 +9,15 @@ import type { AppShellSettingsSection } from '../../types/app-shell'
7
9
  * with this route): its model's status and checks, its settings and its own
8
10
  * content. The app has one assistant: every section of role or scope
9
11
  * `assistant` (the chat layer's settings, the SKAILE runs and tokens) is drawn
10
- * as one card, titled with the assistant's name. Models are chosen in
11
- * Settings › Harness. Owners edit; everyone else reads.
12
+ * as one card, titled with the assistant's name, with the form of every scope
13
+ * its parts name. The core's `assistant-policy` scope (whether people may use
14
+ * their own models) joins that card whenever there is one, so no layer has to
15
+ * contribute it. Models are chosen in Settings › Harness. Owners edit;
16
+ * everyone else reads.
12
17
  */
13
18
  const ROUTE = '/settings/agents'
14
19
  const ASSISTANT = 'assistant'
20
+ const ASSISTANT_POLICY = 'assistant-policy'
15
21
 
16
22
  const { t } = useCoreI18n()
17
23
  useHead({ title: () => t('core.agents.title') })
@@ -28,13 +34,37 @@ const onPage = computed(() =>
28
34
  )
29
35
  const isAssistant = (section: AppShellSettingsSection) => section.role === ASSISTANT || section.scope === ASSISTANT
30
36
  const assistantParts = computed(() => onPage.value.filter(isAssistant))
31
- // The parts' own components, one after another; its own computed, so a new name does not remount them.
37
+ // Every scope of the parts once, in their order, then the policy; the first is the card's own form.
38
+ const assistantScopes = computed(() => [
39
+ ...new Set([...assistantParts.value.flatMap(part => (part.scope ? [part.scope] : [])), ASSISTANT_POLICY]),
40
+ ])
41
+
42
+ // Unsaved state per form on the page (one card's form under its role or scope, further scope forms under their
43
+ // scope), so the leave guard asks once for all of them.
44
+ const sectionDirty = reactive<Record<string, boolean>>({})
45
+ useLeaveGuard(computed(() => Object.values(sectionDirty).some(Boolean)))
46
+
47
+ // The forms of the further scopes, then the parts' own components, one after another; its own computed, so a new
48
+ // name does not remount them.
32
49
  const assistantComponent = computed(() => {
50
+ const moreScopes = assistantScopes.value.slice(1)
33
51
  const components = assistantParts.value.flatMap(part => (part.component ? [part.component] : []))
34
- if (components.length < 2) return components[0]
52
+ if (moreScopes.length === 0 && components.length < 2) return components[0]
35
53
  return defineComponent({
36
54
  name: 'AssistantSectionParts',
37
- setup: () => () => components.map(component => h(component)),
55
+ setup: () => () => [
56
+ ...moreScopes.map(scope =>
57
+ h(SettingsScopeForm, {
58
+ key: scope,
59
+ scope,
60
+ readOnly: !canEdit.value,
61
+ onDirty: (value: boolean) => {
62
+ sectionDirty[scope] = value
63
+ },
64
+ }),
65
+ ),
66
+ ...components.map(component => h(component)),
67
+ ],
38
68
  })
39
69
  })
40
70
 
@@ -46,7 +76,7 @@ const sections = computed<AppShellSettingsSection[]>(() => {
46
76
  title: account.value?.name ?? parts[0]!.title,
47
77
  order: parts[0]!.order,
48
78
  role: parts.find(part => part.role)?.role,
49
- scope: parts.find(part => part.scope)?.scope,
79
+ scope: assistantScopes.value[0],
50
80
  component: assistantComponent.value,
51
81
  }
52
82
  return [assistant, ...onPage.value.filter(section => !isAssistant(section))].sort((a, b) => a.order - b.order)
@@ -54,9 +84,6 @@ const sections = computed<AppShellSettingsSection[]>(() => {
54
84
 
55
85
  const { data: status } = await useAsyncData('ai:status', () => actions.call('ai.status', {}))
56
86
  const statusOf = (roleId?: string) => (roleId ? status.value?.roles.find(role => role.id === roleId) : undefined)
57
-
58
- const sectionDirty = reactive<Record<string, boolean>>({})
59
- useLeaveGuard(computed(() => Object.values(sectionDirty).some(Boolean)))
60
87
  </script>
61
88
 
62
89
  <template>
@@ -6,6 +6,9 @@ const toast = useToast()
6
6
  const { t } = useCoreI18n()
7
7
  const { data: me } = await useMe()
8
8
  const { setColorMode, modes, palette, isDark } = useAppearance()
9
+ // Off in an app with a theme of its own (`appConfig.forgeCore.palettes: false`).
10
+ const appConfig = useAppConfig()
11
+ const showPalettes = computed(() => appConfig.forgeCore?.palettes !== false)
9
12
 
10
13
  const modeItems = computed(() => modes.map(({ value, label, icon }) => ({ value, label, icon })))
11
14
 
@@ -69,7 +72,10 @@ const accountLine = computed(() =>
69
72
  variant="card"
70
73
  :legend="t('core.profile.mode')"
71
74
  />
72
- <div class="flex flex-col gap-2">
75
+ <div
76
+ v-if="showPalettes"
77
+ class="flex flex-col gap-2"
78
+ >
73
79
  <p class="text-sm font-medium text-highlighted">
74
80
  {{ t('core.profile.palette') }}
75
81
  </p>
package/app/types/ai.ts CHANGED
@@ -3,6 +3,11 @@ export interface AiRoleStatusView {
3
3
  id: string
4
4
  available: boolean
5
5
  reason: string | null
6
- model: { selector: string; label: string; source: 'registry' | 'env' } | null
6
+ /** The assigned `<provider>/<model>`, `null` without one (absent where the caller does not pass it). */
7
+ assigned?: string | null
8
+ /** Owners only: the assigned model is not usable and the app's default model answers instead; `null` otherwise. */
9
+ warning?: string | null
10
+ /** `source: 'fallback'` is the app's hidden default model: `label` is a fixed text, never its model id. */
11
+ model: { selector: string; label: string; source: 'registry' | 'env' | 'fallback' } | null
7
12
  checks: { id: string; label: string; ok: boolean; detail?: string }[]
8
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skaile/forge-layer-core",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Nuxt layer every app built on forge-template-app (and forge-template-mobile) stands on: sign-in, principals and API tokens, settings, the server-action catalogue with /api/actions and /mcp, the data model, AI model roles and providers, the assistant's account, engines and definition, the database with its core migrations, and the generic settings and form UI.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -64,10 +64,10 @@
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@nuxt/ui": "^4.11.1",
67
- "@skaile/forge-app-actions": "^0.6.4",
67
+ "@skaile/forge-app-actions": "^0.6.6",
68
68
  "@skaile/forge-brand": "^0.5.0",
69
69
  "@skaile/forge-data": "^0.2.1",
70
- "@skaile/forge-settings": "^2.2.0",
70
+ "@skaile/forge-settings": "^2.3.0",
71
71
  "@skaile/workspaces": "^10.3.0",
72
72
  "@vueuse/core": "^15.0.0",
73
73
  "ai": "^7.0.0",
@@ -69,7 +69,7 @@ export const aiActions = [
69
69
  kind: 'query',
70
70
  audience: ['user'],
71
71
  description:
72
- "Per model role the app offers (e.g. the in-app assistant, the workspace agent): which model is assigned, which model answers right now (registry selector or the NUXT_AI_* environment fallback), whether the role is available and, if not, why, plus the role's extra checks. Readable by every signed-in person; never contains a key. Only owners get the details of a check (paths, URLs); everyone else gets its label and result.",
72
+ "Per model role the app offers (e.g. the in-app assistant, the workspace agent): which model is assigned, which model answers right now (registry selector, the NUXT_AI_* environment fallback, or the app's default model, shown only as source 'fallback' with selector 'app/fallback'), whether the role is available and, if not, why, plus the role's extra checks. warning (owners only, else null): the assigned model is not usable and the app's default model answers instead. Readable by every signed-in person; never contains a key. Only owners get the details of a check (paths, URLs); everyone else gets its label and result.",
73
73
  input: z.object({}).strict(),
74
74
  authorize: (_input, ctx) => {
75
75
  if (ctx.principal.kind !== 'user')
@@ -108,6 +108,13 @@ export const aiActions = [
108
108
  // Available = a model answers and every extra check of the role passes.
109
109
  available: !!resolved.model && !failed,
110
110
  reason: resolved.reason ?? failure ?? null,
111
+ // Owners only: the assignment is broken and the app's default model answers in its place.
112
+ warning:
113
+ owner && resolved.model?.assignmentFailure
114
+ ? useForgeServerI18n(coreMessages).t('core.aiStatus.assignmentBroken', {
115
+ reason: resolved.model.assignmentFailure,
116
+ })
117
+ : null,
111
118
  checks: owner ? checks : checks.map(({ detail: _detail, ...check }) => check),
112
119
  }
113
120
  }),
@@ -4,17 +4,24 @@ import type { AssistantAccount } from '../assistant/account'
4
4
  import { BYOK_PRESETS, getAssistantAccount, updateAssistantAccount } from '../assistant/account'
5
5
  import { ASSISTANT_MODES, assistantModes, effectiveAssistantMode } from '../assistant/engines'
6
6
  import { assistantName } from '../assistant/name'
7
+ // Importing the policy declares its scope, so `settings.get`/`settings.update` know "assistant-policy".
8
+ import { ownModelsAllowed } from '../assistant/policy'
9
+ import { useCoreServerI18n } from '../i18n'
7
10
  import type { Principal } from '../principal'
8
11
  import { defineAppAction } from './define'
9
12
 
10
- /** What both actions answer: the account without its key, plus the modes and the one a new conversation uses. */
13
+ /**
14
+ * What both actions answer: the account without its key, the modes, the engine a new conversation
15
+ * uses, and whether the app lets people choose their own model (`ownModels`).
16
+ */
11
17
  async function accountView(principal: Principal, account: AssistantAccount) {
12
- const [name, modes, effectiveMode] = await Promise.all([
18
+ const [name, modes, effectiveMode, ownModels] = await Promise.all([
13
19
  assistantName(),
14
20
  assistantModes(principal),
15
21
  effectiveAssistantMode(principal),
22
+ ownModelsAllowed(),
16
23
  ])
17
- return { name, mode: account.mode, effectiveMode, modes, byok: account.byok }
24
+ return { name, mode: account.mode, effectiveMode, modes, byok: account.byok, ownModels }
18
25
  }
19
26
 
20
27
  export const assistantActions = [
@@ -23,7 +30,7 @@ export const assistantActions = [
23
30
  kind: 'query',
24
31
  audience: ['user'],
25
32
  description:
26
- "Your assistant account: the assistant's name, the mode you chose (skaile, byok or null = not chosen), the mode new conversations use, every mode with whether it is installed and available to you, and your own-key provider, model and base URL (whether a key is stored, never the key).",
33
+ "Your assistant account: the assistant's name, the mode you chose (skaile = the app's model, byok = your own key, null = not chosen), the engine new conversations use, every engine with whether it is installed and available to you, whether the app allows own models (ownModels), and your own-key provider, model and base URL (whether a key is stored, never the key).",
27
34
  input: z.object({}).strict(),
28
35
  authorize: (_input, ctx) => {
29
36
  if (ctx.principal.kind === 'system')
@@ -39,7 +46,7 @@ export const assistantActions = [
39
46
  idempotent: true,
40
47
  audience: ['user'],
41
48
  description:
42
- 'Change your assistant account: mode (skaile, byok, or null to let the app pick), your own-key provider, model, base URL (openai-compatible only) and key, or clearKey to remove the stored key. Changing provider or base URL without a new key removes the stored key. Returns the account like assistant.account.get.',
49
+ "Change your assistant account: mode (skaile = the app's model, byok = your own key, or null to let the app pick), your own-key provider, model, base URL (openai-compatible only) and key, or clearKey to remove the stored key. Mode byok and own-key changes are refused while the app does not allow own models (ownModels in assistant.account.get); clearKey always works. Changing provider or base URL without a new key removes the stored key. Returns the account like assistant.account.get.",
43
50
  input: z
44
51
  .object({
45
52
  mode: z.enum(ASSISTANT_MODES).nullable().optional().describe('skaile, byok, or null to let the app pick'),
@@ -65,9 +72,13 @@ export const assistantActions = [
65
72
  throw createError({ statusCode: 403, statusMessage: 'The system principal has no assistant account' })
66
73
  },
67
74
  run: async (input, ctx) => {
75
+ if ((input.mode === 'byok' || input.byok) && !(await ownModelsAllowed()))
76
+ throw createError({ statusCode: 403, statusMessage: useCoreServerI18n().t('core.assistant.ownModelsOff') })
68
77
  if (input.mode) {
69
- const chosen = (await assistantModes(ctx.principal)).find(entry => entry.mode === input.mode)
70
- if (!chosen?.installed)
78
+ const modes = await assistantModes(ctx.principal)
79
+ const installed = (mode: string) => modes.some(entry => entry.mode === mode && entry.installed)
80
+ // An own key runs the SKAILE agent, so `byok` needs either engine; the plain chat engine is only its fallback.
81
+ if (!(installed(input.mode) || (input.mode === 'byok' && installed('skaile'))))
71
82
  throw createError({
72
83
  statusCode: 400,
73
84
  statusMessage: `The assistant mode ${input.mode} is not installed in this app`,
@@ -7,7 +7,8 @@ import {
7
7
  resolveModelRole,
8
8
  STANDARD_MODEL_ROLES,
9
9
  } from '@skaile/forge-settings/server'
10
- import type { LanguageModel } from 'ai'
10
+ import type { LanguageModel, LanguageModelMiddleware } from 'ai'
11
+ import { wrapLanguageModel } from 'ai'
11
12
  import { coreMessages } from '../../../shared/messages'
12
13
  import { useForgeServerI18n } from '../i18n'
13
14
  import { getSettings } from '../settings'
@@ -126,11 +127,14 @@ export class RoleNotConfigured extends Error {
126
127
 
127
128
  export interface ResolvedRoleModel {
128
129
  roleId: string
129
- /** `<provider>/<model>` of the registry; for the environment fallback `app/<NUXT_AI_MODEL>`. */
130
+ /** `<provider>/<model>` of the registry; for the environment fallback `app/<NUXT_AI_MODEL>`; for the hidden fallback always `app/fallback`. */
130
131
  selector: string
131
- /** Where the model comes from: the assignment in the provider registry, or the `NUXT_AI_*` environment. */
132
- source: 'registry' | 'env'
133
- /** What answers, for people: the registry selector or `env:<model>`. */
132
+ /**
133
+ * Where the model comes from: the assignment in the provider registry, the `NUXT_AI_*` environment, or the
134
+ * operator's hidden fallback (`NUXT_AI_FALLBACK_*`), whose model, URL and key never leave the server.
135
+ */
136
+ source: 'registry' | 'env' | 'fallback'
137
+ /** What answers, for people: the registry selector, `env:<model>`, or for the hidden fallback a fixed text ("App default model"). */
134
138
  label: string
135
139
  /** The AI SDK model, already resolved (credentials checked). */
136
140
  languageModel: () => LanguageModel
@@ -138,6 +142,11 @@ export interface ResolvedRoleModel {
138
142
  registry?: MergedAIProviderRegistry
139
143
  /** `source: 'registry'` only: the secrets of that entry as child-process environment variables. Server side only; never serialise it. */
140
144
  credentialEnv?: Record<string, string>
145
+ /**
146
+ * `source: 'fallback'` only: why the assigned model is not usable (the `RoleNotConfigured` reason), when the
147
+ * fallback stands in for an assignment. Names the assignment, never the fallback.
148
+ */
149
+ assignmentFailure?: string
141
150
  }
142
151
 
143
152
  const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1'
@@ -231,30 +240,123 @@ function resolveFromEnv(role: ModelRoleDefinition, env: Env): ResolvedRoleModel
231
240
  }
232
241
  }
233
242
 
243
+ /**
244
+ * The operator's hidden fallback: OpenAI-compatible like {@link resolveFromEnv}, from `NUXT_AI_FALLBACK_BASE_URL`
245
+ * (default OpenRouter), `NUXT_AI_FALLBACK_API_KEY` and `NUXT_AI_FALLBACK_MODEL`, or `null`. Hidden: its selector
246
+ * and label are fixed, so no model id, URL, provider name or key reaches a person. Its key is outside
247
+ * {@link PROVIDER_POLICY}, so no registry entry can reference it and no key listing shows it.
248
+ */
249
+ function resolveHiddenFallback(role: ModelRoleDefinition, env: Env): ResolvedRoleModel | null {
250
+ const baseUrl = env.NUXT_AI_FALLBACK_BASE_URL?.trim() ?? ''
251
+ const apiKey = env.NUXT_AI_FALLBACK_API_KEY?.trim() ?? ''
252
+ const modelId = env.NUXT_AI_FALLBACK_MODEL?.trim() ?? ''
253
+ if (!modelId || (!apiKey && !baseUrl)) return null
254
+ const provider = createOpenAICompatible({
255
+ name: 'app-fallback',
256
+ baseURL: baseUrl || OPENROUTER_BASE_URL,
257
+ ...(apiKey ? { apiKey } : {}),
258
+ })
259
+ const model = provider.chatModel(modelId)
260
+ return {
261
+ roleId: role.id,
262
+ selector: FALLBACK_SELECTOR,
263
+ source: 'fallback',
264
+ label: useForgeServerI18n(coreMessages).t('core.aiStatus.appDefault'),
265
+ languageModel: () => model,
266
+ }
267
+ }
268
+
269
+ /** The selector `ai.status` shows for the hidden fallback; never the real model. */
270
+ export const FALLBACK_SELECTOR = 'app/fallback'
271
+
272
+ function fallbackUsed(roleId: string, why: string): void {
273
+ // Never the fallback's model id, URL or key: the log says only that it answered.
274
+ console.warn(`[ai] model role "${roleId}": ${why}; fallback model used`)
275
+ }
276
+
277
+ function isAbort(error: unknown, signal: AbortSignal | undefined): boolean {
278
+ return signal?.aborted === true || (error instanceof Error && error.name === 'AbortError')
279
+ }
280
+
281
+ /**
282
+ * The primary model with the hidden fallback as its runtime backup: a call that fails before any output
283
+ * (`doGenerate` throws, `doStream` throws before it returns the stream) runs once more on the fallback. An
284
+ * error inside a stream that already started is not retried, and neither is an abort.
285
+ */
286
+ function withFailover(roleId: string, primary: LanguageModel, fallback: LanguageModel): LanguageModel {
287
+ if (typeof primary === 'string' || typeof fallback === 'string') return primary
288
+ const backup = wrapLanguageModel({ model: fallback, middleware: [] })
289
+ const middleware: LanguageModelMiddleware = {
290
+ wrapGenerate: async ({ doGenerate, params }) => {
291
+ try {
292
+ return await doGenerate()
293
+ } catch (error) {
294
+ if (isAbort(error, params.abortSignal)) throw error
295
+ fallbackUsed(roleId, 'the model failed')
296
+ return backup.doGenerate(params)
297
+ }
298
+ },
299
+ wrapStream: async ({ doStream, params }) => {
300
+ try {
301
+ return await doStream()
302
+ } catch (error) {
303
+ if (isAbort(error, params.abortSignal)) throw error
304
+ fallbackUsed(roleId, 'the model failed')
305
+ return backup.doStream(params)
306
+ }
307
+ },
308
+ }
309
+ return wrapLanguageModel({ model: primary, middleware })
310
+ }
311
+
312
+ /** `primary` whose `languageModel()` fails over to `fallback` at call time. */
313
+ function backedBy(roleId: string, primary: ResolvedRoleModel, fallback: ResolvedRoleModel): ResolvedRoleModel {
314
+ let wrapped: LanguageModel | undefined
315
+ return {
316
+ ...primary,
317
+ languageModel: () => (wrapped ??= withFailover(roleId, primary.languageModel(), fallback.languageModel())),
318
+ }
319
+ }
320
+
234
321
  /**
235
322
  * The model that serves `roleId` right now: the registry selector assigned in
236
323
  * Settings › Harness; without one, for a `chat` role the `NUXT_AI_*` environment
237
324
  * (so a fresh clone with only `.env` still answers). `env` is where `NUXT_AI_*`
238
325
  * and `AI_PROVIDERS_DIR` are read (default `process.env`).
239
326
  *
327
+ * The operator's hidden fallback (`NUXT_AI_FALLBACK_*`) comes last: it answers when neither the assignment nor
328
+ * the environment gives a usable model (also when the assignment is broken). For a role that resolves an AI SDK
329
+ * model in this process it also backs the primary model up at call time. A runner role (`sdkModel: false`) gets
330
+ * it as `source: 'fallback'` without an SDK model: the runner builds its own config from `NUXT_AI_FALLBACK_*`
331
+ * (`@skaile/forge-layer-workspace-agent`), so the fallback stays on the server there too.
332
+ *
240
333
  * Only language-model roles (`chat`, `decision`) resolve here; the standard
241
334
  * `image`, `tts` and `stt` roles get their resolver together with a consumer.
242
335
  * @throws {RoleNotConfigured} the role is unknown, disabled or has no usable model.
243
336
  */
244
337
  export async function resolveRoleModel(roleId: string, options: { env?: Env } = {}): Promise<ResolvedRoleModel> {
245
338
  const env = options.env ?? process.env
246
- const role = registry.get(roleId)?.definition
339
+ const registered = registry.get(roleId)
340
+ const role = registered?.definition
247
341
  const { t } = useForgeServerI18n(coreMessages)
248
- if (!role || !role.enabled) throw new RoleNotConfigured(roleId, t('core.aiStatus.unknownRole', { role: roleId }))
342
+ if (!role?.enabled) throw new RoleNotConfigured(roleId, t('core.aiStatus.unknownRole', { role: roleId }))
249
343
  if (role.kind !== 'chat' && role.kind !== 'decision') {
250
344
  throw new RoleNotConfigured(roleId, t('core.aiStatus.noConsumer', { label: role.label, kind: role.kind }))
251
345
  }
346
+ const sdk = registered?.sdkModel ?? true
347
+ const fallback = resolveHiddenFallback(role, env)
252
348
  const assignment = (await getSettings(aiSettings)).models[roleId]?.trim()
253
- if (assignment) return resolveAssigned(role, assignment, env)
254
- if (role.kind === 'chat') {
255
- const fromEnv = resolveFromEnv(role, env)
256
- if (fromEnv) return fromEnv
257
- throw new RoleNotConfigured(roleId, t('core.aiStatus.noModelEnv', { label: role.label }))
349
+ let primary: ResolvedRoleModel | null = null
350
+ try {
351
+ if (assignment) primary = await resolveAssigned(role, assignment, env)
352
+ else if (role.kind === 'chat') primary = resolveFromEnv(role, env)
353
+ } catch (error) {
354
+ if (!(error instanceof RoleNotConfigured) || !fallback) throw error
355
+ fallbackUsed(roleId, 'the assigned model is not usable')
356
+ return { ...fallback, assignmentFailure: error.reason }
258
357
  }
358
+ if (primary) return fallback && sdk ? backedBy(roleId, primary, fallback) : primary
359
+ if (fallback) return fallback
360
+ if (role.kind === 'chat') throw new RoleNotConfigured(roleId, t('core.aiStatus.noModelEnv', { label: role.label }))
259
361
  throw new RoleNotConfigured(roleId, t('core.aiStatus.noModel', { label: role.label }))
260
362
  }
@@ -8,6 +8,7 @@ import { assistantAccounts } from '../../db/schema'
8
8
  import { useDb } from '../db'
9
9
  import { useCoreServerI18n } from '../i18n'
10
10
  import type { AssistantMode } from './engines'
11
+ import { ownModelsAllowed } from './policy'
11
12
 
12
13
  /**
13
14
  * A person's assistant account (Settings › Profile): the mode they chose and,
@@ -20,8 +21,9 @@ export type ByokPreset = 'anthropic' | 'openai' | 'openrouter' | 'openai-compati
20
21
 
21
22
  export const BYOK_PRESETS: readonly ByokPreset[] = ['anthropic', 'openai', 'openrouter', 'openai-compatible']
22
23
 
23
- /** Base URL of the presets that speak the OpenAI chat API; `openai-compatible` brings its own. */
24
+ /** Base URL of each preset; `openai-compatible` brings its own. */
24
25
  const PRESET_BASE_URLS: Partial<Record<ByokPreset, string>> = {
26
+ anthropic: 'https://api.anthropic.com',
25
27
  openai: 'https://api.openai.com/v1',
26
28
  openrouter: 'https://openrouter.ai/api/v1',
27
29
  }
@@ -32,6 +34,17 @@ export interface AssistantAccount {
32
34
  byok: { preset: ByokPreset | null; model: string | null; baseUrl: string | null; hasKey: boolean }
33
35
  }
34
36
 
37
+ /** A person's own model, ready to call. Server only: it carries the unsealed key. */
38
+ export interface PersonalModel {
39
+ preset: ByokPreset
40
+ /** Provider model id as the person typed it. */
41
+ model: string
42
+ /** Absolute base URL of the provider's API (the preset's, or the person's for `openai-compatible`). */
43
+ baseUrl: string
44
+ /** Unsealed key. Never log, return or persist it. */
45
+ apiKey: string
46
+ }
47
+
35
48
  /** The person cannot use `byok` yet; `reason` says what to set in Settings › Profile and never carries a key. */
36
49
  export class AssistantNotConfigured extends Error {
37
50
  constructor(
@@ -134,13 +147,18 @@ export async function updateAssistantAccount(
134
147
  return toAccount(row)
135
148
  }
136
149
 
137
- /** The person's own model for `byok`, built per call so a changed account needs no restart. */
138
- export async function byokLanguageModel(userId: string): Promise<LanguageModel> {
139
- const row = await accountRow(userId)
150
+ /**
151
+ * The stored own model, whatever mode the person chose. Throws AssistantNotConfigured naming what is
152
+ * missing, so the `byok` engine can tell the person what to set.
153
+ */
154
+ function storedModel(row: typeof assistantAccounts.$inferSelect | undefined): PersonalModel {
140
155
  const preset = row?.byokPreset
141
156
  if (!preset || !row.byokModel)
142
157
  throw new AssistantNotConfigured('Choose a provider and model for your own key in Settings › Profile.')
143
158
  if (!row.byokKeySealed) throw new AssistantNotConfigured('Enter your API key in Settings › Profile.')
159
+ const baseUrl = PRESET_BASE_URLS[preset] ?? row.byokBaseUrl
160
+ if (!baseUrl)
161
+ throw new AssistantNotConfigured('Enter the base URL of your OpenAI-compatible provider in Settings › Profile.')
144
162
  let apiKey: string
145
163
  try {
146
164
  apiKey = unseal(row.byokKeySealed)
@@ -150,9 +168,35 @@ export async function byokLanguageModel(userId: string): Promise<LanguageModel>
150
168
  { cause: error },
151
169
  )
152
170
  }
153
- if (preset === 'anthropic') return createAnthropic({ apiKey })(row.byokModel)
154
- const baseURL = PRESET_BASE_URLS[preset] ?? row.byokBaseUrl
155
- if (!baseURL)
156
- throw new AssistantNotConfigured('Enter the base URL of your OpenAI-compatible provider in Settings › Profile.')
157
- return createOpenAICompatible({ name: `byok-${preset}`, baseURL, apiKey }).chatModel(row.byokModel)
171
+ return { preset, model: row.byokModel, baseUrl, apiKey }
172
+ }
173
+
174
+ /**
175
+ * The person's own model when it should be used: the app allows own models (`assistant-policy`), the
176
+ * person chose mode `byok`, and preset, model and key are stored. `null` otherwise, so the caller runs
177
+ * on the app's model. Read per call, so a changed account or policy needs no restart.
178
+ * @throws AssistantNotConfigured when the stored key cannot be unsealed (its reason is for people).
179
+ */
180
+ export async function personalModel(userId: string): Promise<PersonalModel | null> {
181
+ if (!(await ownModelsAllowed())) return null
182
+ const row = await accountRow(userId)
183
+ if (row?.mode !== 'byok' || !row.byokPreset || !row.byokModel || !row.byokKeySealed) return null
184
+ if (row.byokPreset === 'openai-compatible' && !row.byokBaseUrl) return null
185
+ return storedModel(row)
186
+ }
187
+
188
+ /**
189
+ * The person's own model for the plain chat engine (`byok`), built per call so a changed account needs
190
+ * no restart. Unlike {@link personalModel} it does not ask for mode `byok`: the chat engine only runs
191
+ * when the SKAILE engine cannot, and then any stored key serves.
192
+ * @throws AssistantNotConfigured when own models are switched off or the account lacks a part.
193
+ */
194
+ export async function byokLanguageModel(userId: string): Promise<LanguageModel> {
195
+ if (!(await ownModelsAllowed()))
196
+ throw new AssistantNotConfigured(useCoreServerI18n().t('core.assistant.ownModelsOff'))
197
+ const own = storedModel(await accountRow(userId))
198
+ if (own.preset === 'anthropic') return createAnthropic({ apiKey: own.apiKey })(own.model)
199
+ return createOpenAICompatible({ name: `byok-${own.preset}`, baseURL: own.baseUrl, apiKey: own.apiKey }).chatModel(
200
+ own.model,
201
+ )
158
202
  }
@@ -1,15 +1,17 @@
1
1
  import { coreMessages } from '../../../shared/messages'
2
2
  import { useForgeServerI18n } from '../i18n'
3
3
  import type { Principal } from '../principal'
4
- import { getAssistantAccount } from './account'
4
+ import { ownModelsAllowed } from './policy'
5
5
 
6
6
  /**
7
- * The app has one assistant that runs on the server in one of two modes,
8
- * chosen per person (Settings › Profile, `assistant.account.update`):
9
- * `skaile` (a `skaile serve` process per person, full access with the
10
- * person's rights) or `byok` (the AI SDK with the person's own key, the
11
- * current document only). The layer that implements a mode registers its
12
- * engine from a server plugin; a mode no layer registers is not installed.
7
+ * The app has one assistant, the SKAILE workspace agent (`skaile`: a
8
+ * `skaile serve` process per person, full access with the person's rights).
9
+ * It runs on the app's model, or on the person's own model when the app
10
+ * allows own models (`assistant-policy`) and they chose mode `byok` in
11
+ * Settings › Profile. Only when the SKAILE engine cannot run does an own key
12
+ * fall back to the plain chat engine (`byok`: the AI SDK, the open page only).
13
+ * The layer that implements an engine registers it from a server plugin; an
14
+ * engine no layer registers is not installed.
13
15
  */
14
16
 
15
17
  export type AssistantMode = 'skaile' | 'byok'
@@ -70,11 +72,15 @@ export async function assistantModes(
70
72
  )
71
73
  }
72
74
 
73
- /** The mode a new conversation of this person uses: the chosen one if available, else `skaile`, else `byok`, else `null` (nothing usable). */
75
+ /**
76
+ * The engine a new conversation of this person uses: `skaile` whenever it is available to them (with
77
+ * mode `byok` it runs on their own model), else `byok` when the app allows own models and the person
78
+ * can use it, else `null` (nothing usable).
79
+ */
74
80
  export async function effectiveAssistantMode(principal: Principal): Promise<AssistantMode | null> {
75
81
  const modes = await assistantModes(principal)
76
- const usable = (mode: AssistantMode | null) => modes.some(entry => entry.mode === mode && entry.available)
77
- const chosen = principal.kind === 'system' ? null : (await getAssistantAccount(principal.id)).mode
78
- if (chosen && usable(chosen)) return chosen
79
- return ASSISTANT_MODES.find(mode => usable(mode)) ?? null
82
+ const usable = (mode: AssistantMode) => modes.some(entry => entry.mode === mode && entry.available)
83
+ if (usable('skaile')) return 'skaile'
84
+ if (usable('byok') && (await ownModelsAllowed())) return 'byok'
85
+ return null
80
86
  }
@@ -0,0 +1,36 @@
1
+ import * as z from 'zod'
2
+ import { coreMessages } from '../../../shared/messages'
3
+ import { defineSettingsScope, getSettings } from '../settings'
4
+
5
+ /**
6
+ * The owner's rules for the app's one assistant (`settings.get`/`settings.update`
7
+ * with `scope: "assistant-policy"`, Settings › Agents in the assistant's card).
8
+ * `ownModels` decides whether people may run the assistant on their own
9
+ * provider, model and key (Settings › Profile, mode `byok`). Off: nobody can
10
+ * choose it, stored keys stay stored but are ignored, and everyone's
11
+ * assistant runs on the app's model.
12
+ */
13
+ export const assistantPolicy = defineSettingsScope(
14
+ 'assistant-policy',
15
+ z
16
+ .object({
17
+ ownModels: z
18
+ .boolean()
19
+ .describe(
20
+ "People may run the assistant on their own provider, model and key (Settings › Profile). Off: everyone uses the app's model",
21
+ ),
22
+ })
23
+ .strict(),
24
+ // On by default: what apps did before the switch existed.
25
+ { ownModels: true },
26
+ {
27
+ label: 'Assistant: models',
28
+ description: 'Which models people may run the assistant on',
29
+ i18n: { catalogs: coreMessages, prefix: 'core.settings.assistantPolicy' },
30
+ },
31
+ )
32
+
33
+ /** Whether people may run the assistant on their own model (`assistant-policy.ownModels`). */
34
+ export async function ownModelsAllowed(): Promise<boolean> {
35
+ return (await getSettings(assistantPolicy)).ownModels
36
+ }
@@ -84,6 +84,11 @@ export const de: CoreMessages = {
84
84
  'core.settings.app.timezone': 'IANA-Zeitzone für Datumsangaben und Übersichten, z. B. Europe/Berlin',
85
85
  'core.settings.app.appName.title': 'Name der App',
86
86
  'core.settings.app.timezone.title': 'Zeitzone',
87
+ 'core.settings.assistantPolicy.label': 'Assistent: Modelle',
88
+ 'core.settings.assistantPolicy.description': 'Auf welchen Modellen Personen den Assistenten nutzen dürfen',
89
+ 'core.settings.assistantPolicy.ownModels':
90
+ 'Personen können den Assistenten im Profil mit eigenem Anbieter, Modell und Schlüssel nutzen. Aus: alle nutzen das Modell der App.',
91
+ 'core.settings.assistantPolicy.ownModels.title': 'Eigene Modelle erlauben',
87
92
 
88
93
  'core.agents.title': 'Agenten',
89
94
  'core.agents.empty': 'Keine Agenten installiert',
@@ -103,6 +108,8 @@ export const de: CoreMessages = {
103
108
  'core.aiStatus.fallback': 'Nicht zugewiesen: nutzt',
104
109
  'core.aiStatus.model': 'Modell',
105
110
  'core.aiStatus.fromEnv': 'aus NUXT_AI_*',
111
+ 'core.aiStatus.appDefault': 'Standardmodell der App',
112
+ 'core.aiStatus.assignmentBroken': '{reason}. Solange antwortet das Standardmodell der App',
106
113
  'core.aiStatus.statusCheck': 'Statusprüfung',
107
114
  'core.aiStatus.askOwner': '{label} ist nicht eingerichtet. Frag einen Inhaber.',
108
115
  'core.aiStatus.unknownRole': 'Die Modellrolle „{role}“ gibt es in dieser App nicht, oder sie ist ausgeschaltet',
@@ -151,14 +158,18 @@ export const de: CoreMessages = {
151
158
  'core.assistant.defaultName': 'Assistent',
152
159
  'core.assistant.description': 'Wie {name} für dich arbeitet. Nur du siehst diese Einstellungen.',
153
160
  'core.assistant.fallbackName': 'der Assistent',
154
- 'core.assistant.mode': 'Modus',
155
- 'core.assistant.mode.skaile': 'SKAILE',
161
+ 'core.assistant.mode': 'Modell',
162
+ 'core.assistant.mode.skaile': 'Modell der App',
156
163
  'core.assistant.mode.byok': 'Eigener Schlüssel',
157
164
  'core.assistant.modeHint.skaile':
158
- 'Voller Zugriff auf die App, mit deinen Rechten. Vor dem Löschen fragt er dich im Posteingang.',
165
+ 'Läuft auf dem Modell, das die App stellt, mit vollem Zugriff auf die App und deinen Rechten. Vor dem Löschen fragt er dich im Posteingang.',
159
166
  'core.assistant.modeHint.byok':
167
+ 'Derselbe Assistent läuft mit deinem eigenen Anbieter, Modell und Schlüssel: dieselben Werkzeuge, deine Rechte.',
168
+ 'core.assistant.modeHint.byokChat':
160
169
  'Läuft mit deinem eigenen Anbieter-Schlüssel und sieht nur die Seite, die du offen hast.',
161
170
  'core.assistant.notInstalled': 'In dieser App nicht installiert.',
171
+ 'core.assistant.appModelOnly': 'Der Assistent nutzt das Modell der App.',
172
+ 'core.assistant.ownModelsOff': 'Eigene Modelle sind in dieser App ausgeschaltet.',
162
173
  'core.assistant.provider': 'Anbieter',
163
174
  'core.assistant.providerRequired': 'Wähle einen Anbieter',
164
175
  'core.assistant.openaiCompatible': 'OpenAI-kompatibel',
@@ -86,6 +86,11 @@ export const en = {
86
86
  'core.settings.app.timezone': 'IANA time zone for dates and digests, e.g. Europe/Berlin',
87
87
  'core.settings.app.appName.title': 'App name',
88
88
  'core.settings.app.timezone.title': 'Time zone',
89
+ 'core.settings.assistantPolicy.label': 'Assistant: models',
90
+ 'core.settings.assistantPolicy.description': 'Which models people may run the assistant on',
91
+ 'core.settings.assistantPolicy.ownModels':
92
+ "People can use the assistant with their own provider, model and key in their profile. Off: everyone uses the app's model.",
93
+ 'core.settings.assistantPolicy.ownModels.title': 'Allow own models',
89
94
 
90
95
  'core.agents.title': 'Agents',
91
96
  'core.agents.empty': 'No agents installed',
@@ -104,6 +109,8 @@ export const en = {
104
109
  'core.aiStatus.fallback': 'Unassigned: uses',
105
110
  'core.aiStatus.model': 'Model',
106
111
  'core.aiStatus.fromEnv': 'from NUXT_AI_*',
112
+ 'core.aiStatus.appDefault': 'App default model',
113
+ 'core.aiStatus.assignmentBroken': "{reason}; the app's default model answers instead",
107
114
  'core.aiStatus.statusCheck': 'Status check',
108
115
  'core.aiStatus.askOwner': '{label} is not set up; ask an owner',
109
116
  'core.aiStatus.unknownRole': 'The model role "{role}" does not exist or is switched off in this app',
@@ -152,12 +159,17 @@ export const en = {
152
159
  'core.assistant.defaultName': 'Assistant',
153
160
  'core.assistant.description': 'How {name} works for you. Only you see these settings.',
154
161
  'core.assistant.fallbackName': 'the assistant',
155
- 'core.assistant.mode': 'Mode',
156
- 'core.assistant.mode.skaile': 'SKAILE',
162
+ 'core.assistant.mode': 'Model',
163
+ 'core.assistant.mode.skaile': "App's model",
157
164
  'core.assistant.mode.byok': 'Own key',
158
- 'core.assistant.modeHint.skaile': 'Full access to the app, with your rights. Deleting asks you first in the Inbox.',
159
- 'core.assistant.modeHint.byok': 'Runs on your own provider key and sees only the page you have open.',
165
+ 'core.assistant.modeHint.skaile':
166
+ 'Runs on the model the app provides, with full access to the app and your rights. Deleting asks you first in the Inbox.',
167
+ 'core.assistant.modeHint.byok':
168
+ 'Runs the same assistant on your own provider, model and key: the same tools, your rights.',
169
+ 'core.assistant.modeHint.byokChat': 'Runs on your own provider key and sees only the page you have open.',
160
170
  'core.assistant.notInstalled': 'Not installed in this app.',
171
+ 'core.assistant.appModelOnly': "The assistant uses the app's model.",
172
+ 'core.assistant.ownModelsOff': 'Own models are switched off in this app.',
161
173
  'core.assistant.provider': 'Provider',
162
174
  'core.assistant.providerRequired': 'Pick a provider',
163
175
  'core.assistant.openaiCompatible': 'OpenAI-compatible',