Commit 4845c12
feat(cli): make the AI service opt-in via a declared dependency (Community-Edition support) (#2311)
* feat(cli): make the AI service opt-in via a declared dependency (+ honor config.tiers)
The CLI auto-registered the headless AIServicePlugin whenever the `ai` tier was
enabled (default) and @objectstack/service-ai was merely *resolvable*. In a
workspace/monorepo the package is hoist-resolvable even when an app doesn't
declare it, so every app got the AI service — discovery reported services.ai
available and the agent runtime served any metadata-defined agents — including
Community-Edition apps that ship no AI.
Make the DECLARED dependency the AI edition boundary: auto-register AIService
only when the host app declares @objectstack/service-ai OR
@objectstack/service-ai-studio (Studio attaches its personas via the base
service's `ai:ready` hook, so declaring Studio implies the base — load it even
when only Studio is in the deps). A CE app that declares neither gets no AI
service, no agents, and services.ai { enabled:false, status:'unavailable' } in
discovery — so the MIT console hides its AI surface — while MCP and every other
capability are unaffected.
Also honor `config.tiers`: ObjectStackDefinitionSchema gains a `tiers` field so
defineStack stops stripping it. `config.tiers` (e.g. a list without `ai`) now
actually overrides the `--preset` default — previously silently dropped by schema
validation, which made the `--preset` help text inaccurate. A second, in-place
lever to disable AI without touching dependencies.
Declare @objectstack/service-ai in the showcase and crm examples (they ship AI
agents) so they keep AI.
Verified e2e in an isolated build:
- app WITHOUT service-ai/studio → discovery AI unavailable, /api/v1/ai/agents
404, AIService not loaded; MCP server still starts + serves (401 auth-gate).
- app declaring service-ai (or studio-only) → services.ai available + agents served.
- config.tiers without `ai` → AIService not loaded even when service-ai IS declared.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(runtime): align stale api-key Bearer test with core's behavior
runtime/security/api-key.ts re-exports @objectstack/core's extractApiKey, which
accepts a Bearer token carrying the `osk_` api-key prefix (for remote MCP
clients — core's own test covers this). This duplicate test in runtime predated
that behavior and asserted the old "Bearer is never an api-key" rule, so it
failed whenever runtime's tests run.
It was latent on main: turbo only runs runtime's tests when runtime or a
dependency changes, and main's recent commits didn't. This PR's
@objectstack/spec change makes spec "changed", so every spec-dependent package's
tests now run — surfacing the pre-existing failure. Align the assertion with
core + the implementation (extractApiKey is re-exported, so they must agree).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent ffa0aca commit 4845c12
7 files changed
Lines changed: 79 additions & 3 deletions
File tree
- .changeset
- examples
- app-crm
- app-showcase
- packages
- cli/src/commands
- runtime/src/security
- spec/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1416 | 1416 | | |
1417 | 1417 | | |
1418 | 1418 | | |
1419 | | - | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
1420 | 1449 | | |
1421 | 1450 | | |
1422 | 1451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
361 | 368 | | |
362 | 369 | | |
363 | 370 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments