Repository navigation
Commit 5d37374
feat(service-settings): Setup → AI takes several providers, a model list each, one default and one structured-output model (#37696)
<!-- claude-projects-attribution: {"github_login":"hotlong"} -->
_Requested by **Jack** · [project
thread](https://claude.ai/code/project/chan_01EF41AQooqveF2DGD8nqPzS?thread=cmsg_01EF41AQooqveF2DGD8nqPzSH5VNV5CG7X8iMbPHYZ6PJm)_
Fixes #37683
## What changes
Setup → AI (`ai` settings namespace,
`packages/services/service-settings`) goes from "pick one provider" to
several providers at once. Only existing specifier kinds are used
(`select`, `toggle`, `text`, `textarea`, `password`, `action_button`);
no `packages/spec` change.
- **Providers on/off.** `provider` keeps its key and stored values and
becomes the **default provider**, always on. Every other provider gets a
`<provider>_enabled` toggle in the Providers section (hidden for the
default provider). Each provider section shows while it is the default
or turned on (`${data.provider === 'x' || data.x_enabled === true}`).
- **A model list per provider.** `<provider>_model` stays the provider's
first model; new `<provider>_models` (textarea) lists further ids, one
per line (a comma also separates). The gateway and Cloudflare lists keep
their `provider/model` pattern per id.
- **Keys unchanged.** One encrypted `password` field per provider, as
before; no read echoes a value (pinned at the route).
- **One default model, one structured-output model.** `default_model`
(one of the default provider's models; blank = its first model) and
`structured_output_provider` + `structured_output_model` (a separate
knob; blank provider = the default provider, blank model = that
provider's first model).
- **Save rule.** A write predicate on the model keys
(`registerAiModelRules`, registered by `SettingsServicePlugin` beside
the manifest) judges the state after the whole save and refuses with
`SETTINGS_VALIDATION` / `invalid_value`, `constraint.rule` naming the
rule: `default_model_not_listed`, `default_model_without_provider`,
`structured_output_provider_off`, `structured_output_model_not_listed`,
`structured_output_model_without_provider`. A breach is refused once, at
the first of its keys the save changes (the chosen model first), so a
save that drops the default model from its list is refused at that list.
Refusal copy is a module-local table in the eleven platform languages,
held by `settings-copy-locale.test.ts`.
- **Test connection per provider.** `test_<provider>` action buttons in
each section; the default handler is the `ai/test` form check run for
that provider (`aiProviderTestActionHandlers`, in the plugin's default
map). The cloud host registers the live handlers over them.
- **Reader for the runtime.** `resolveAiModelConfiguration(values)`
(exported with `parseAiModelList`, `aiModelRuleBreaches`,
`registerAiModelRules`, `AI_PROVIDERS`) returns the providers that are
on with their models, the default model and the structured-output model.
- **Hosted projection.** The new keys and the nine `test_<provider>`
actions join the `ai` hidden set in `cloud-managed-settings.ts`; the
served set is unchanged.
- Translations for every new group, key, help and action in all eleven
bundles; the `provider` group and label now read "Providers" / "Default
provider".
## Why
Phase 1 of objectstack-ai/cloud#5055 (「第一阶段先能把多个模型配置上」): a private
Enterprise deployment can configure several models and the runtime can
use them. No tiers, no sentinel values, no per-org keys. Fallback
happens only at configuration time (the save rule); the resolver hands
the runtime exactly the listed models.
### Legacy values
A deployment that stored `provider` + `<provider>_model` before this
reads unchanged, with no data rewrite: that provider on, that model its
only model and the default (pinned: stored `provider: deepseek` +
`deepseek_model` resolves to one provider, `deepseek-reasoner` default;
a provider left at the manifest model resolves to that model). The cloud
consumer (`packages/service-ai/src/plugin.ts` `buildAdapterFromValues`,
live `ai/test`) still reads `provider` + `<provider>_model` exactly as
before, so its boot behaviour does not move until its own card of
cloud#5055 adopts `resolveAiModelConfiguration` after a pin move.
### Premise check
Card premise re-run on `origin/main` 6d106a1: `git grep -n "key:
'provider'" --
packages/services/service-settings/src/manifests/ai.manifest.ts` → 1 hit
(`:51`). Holds.
Clause-②: yes (widening)
Metadata-protocol: added
## Verification
Local, `packages/services/service-settings` (deps built with `turbo run
build --filter='@objectstack/service-settings^...'`):
- `pnpm --filter @objectstack/service-settings typecheck` → clean
- `pnpm --filter @objectstack/service-settings test` → 77 files, 1538
tests passed
- New pins in `src/manifests/ai.manifest.test.ts` (13): two providers
with two models each validate and resolve; a default outside the enabled
models is refused with `constraint.rule: 'default_model_not_listed'`; a
later list change that drops the default is refused at that list;
structured-output provider off / model not listed refused; refusal in
the caller's language; legacy single-provider values read as one
provider with its model as default; no key value in the GET/PUT answers,
and the refusal is `400 SETTINGS_VALIDATION` at the route; each
provider's test handler checks that provider; the plugin registers the
rule on every model key and the per-provider handlers.
- `settings-visibility-declaration.pin.test.ts` corpus count 83 → 110
(27 new predicates: toggle, list and test button per provider), with the
reason in place.
- Derived gate families (`dispatch-gates.mjs --commands`): 72 derived,
70 run with exit 0, 2 NOT-MEASURED on their own prerequisite refusal
(exit 3: `check:dual-build-cjs-loads` needs the full workspace build;
`check-plugin-teardown-shape.mjs --self-test` did not reach its verdict
in this tree), both left to CI. `dispatch-gates --ran` reconciles 72/72.
- `eslint --no-inline-config` over the changed `.ts` files → clean.
- `overlap-check`: merges cleanly with `origin/main`; textual conflict
with #37668 (knowledge settings) only in the `visible` corpus count line
of `settings-visibility-declaration.pin.test.ts` (83 → 79 there, 83 →
110 here). Whichever lands second sets it to 106. Not a #5027 / #5024
PR.
## Acceptance notes
- The global "Test connection" (`ai/test`) still tests the default
provider; the per-provider buttons sit in each section.
- The console renders `textarea` with no pattern hint; a malformed list
id is refused at save with `invalid_format`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Q4EjjNppk7ewjwv9pfTYgc)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Q4EjjNppk7ewjwv9pfTYgc
<!-- signed: epic:#5055#1 · hotlong · session_01Q4EjjNppk7ewjwv9pfTYgc
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6b60f88 commit 5d37374
21 files changed
Lines changed: 1421 additions & 124 deletions
File tree
- .changeset
- packages/services/service-settings/src
- manifests
- translations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
93 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
192 | 206 | | |
193 | 207 | | |
194 | 208 | | |
| |||
0 commit comments