@happyvertical/smrt-template-sveltekit 0.60.18 → 0.61.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 +68 -51
- package/README.md +25 -10
- package/agents/cookbook-design-runs.md +164 -0
- package/agents/cookbook-host.md +724 -0
- package/agents/onboarding.md +116 -0
- package/agents/plugin-mode.md +152 -0
- package/cookbook-template/.pnpmfile.cjs +5 -0
- package/cookbook-template/src/hooks.server.ts +3 -0
- package/cookbook-template/src/lib/server/cookbook.ts +21 -0
- package/cookbook-template/src/lib/server/smrt.ts +11 -0
- package/cookbook-template/src/routes/+layout.server.ts +24 -0
- package/cookbook-template/src/routes/+layout.svelte +47 -0
- package/cookbook-template/src/routes/+page.server.ts +15 -0
- package/cookbook-template/src/routes/+page.svelte +12 -0
- package/cookbook-template/src/routes/api/_runtime/owner-link/+server.ts +2 -0
- package/cookbook-template/src/routes/api/assistant/[...path]/+server.ts +2 -0
- package/cookbook-template/src/routes/api/connect-ai/+server.ts +2 -0
- package/cookbook-template/src/routes/api/cookbook/prebuilt/+server.ts +3 -0
- package/cookbook-template/src/routes/api/cookbook/preferences/+server.ts +45 -0
- package/cookbook-template/src/routes/api/onboarding/+server.ts +3 -0
- package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.server.ts +1 -0
- package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.svelte +7 -0
- package/cookbook-template/src/routes/mcp/+server.ts +2 -0
- package/cookbook-template/src/routes/onboarding/+page.server.ts +13 -0
- package/cookbook-template/src/routes/onboarding/+page.svelte +28 -0
- package/cookbook-template/src/routes/s/[slug]/+page.server.ts +10 -0
- package/cookbook-template/src/routes/s/[slug]/+page.svelte +6 -0
- package/cookbook-template/src/routes/settings/+page.server.ts +22 -0
- package/cookbook-template/src/routes/settings/+page.svelte +49 -0
- package/cookbook-template/src/routes/settings/inference/+page.server.ts +6 -0
- package/cookbook-template/src/routes/settings/inference/+page.svelte +14 -0
- package/cookbook-template/vite.config.ts +4 -0
- package/dist/host/client.d.ts +8 -0
- package/dist/host/client.js +66 -0
- package/dist/host/design-runs.d.ts +72 -0
- package/dist/host/design-runs.js +763 -0
- package/dist/host/generate.d.ts +49 -0
- package/dist/host/generate.js +266 -0
- package/dist/host/onboarding.d.ts +26 -0
- package/dist/host/onboarding.js +247 -0
- package/dist/host/plugin-mode.d.ts +55 -0
- package/dist/host/plugin-mode.js +184 -0
- package/dist/host/preferences.d.ts +40 -0
- package/dist/host/preferences.js +163 -0
- package/dist/host/server.d.ts +283 -0
- package/dist/host/server.js +2400 -0
- package/dist/host/settings.d.ts +57 -0
- package/dist/host/settings.js +130 -0
- package/dist/host/state.d.ts +26 -0
- package/dist/host/state.js +149 -0
- package/dist/host/sveltekit-client.d.ts +22 -0
- package/dist/host/sveltekit-client.js +53 -0
- package/dist/smrt-knowledge.okf.md +105 -0
- package/examples/notes/src/routes/notes/+page.svelte +145 -0
- package/host/CookbookModelPage.svelte +78 -0
- package/host/InferenceSettingsPage.svelte +103 -0
- package/mcp-apps-template/package.dependencies.json +2 -2
- package/package.json +102 -24
- package/template/README.md +24 -11
- package/template/package.json +17 -12
- package/template/smrt.config.ts +4 -0
- package/template/src/hooks.server.ts +5 -0
- package/template/src/lib/objects/index.ts +7 -3
- package/template/src/lib/server/settings-registry.ts +29 -0
- package/template/src/lib/server/settings.ts +91 -0
- package/template/src/lib/server/smrt.ts +1 -0
- package/template/src/lib/settings-client.ts +1 -0
- package/template/src/lib/sign-out.ts +1 -19
- package/template/src/params/settingsSection.ts +4 -0
- package/template/src/routes/+layout.svelte +1 -2
- package/template/src/routes/+page.svelte +20 -128
- package/template/src/routes/settings/+page.svelte +16 -3
- package/template/src/routes/settings/[section=settingsSection]/+page.svelte +19 -0
- package/template/src/routes/settings/inference/+page.server.ts +3 -0
- package/template/src/routes/settings/inference/+page.svelte +6 -0
- package/template/src/routes/settings/prompts/+page.server.ts +50 -0
- package/template/src/routes/settings/prompts/+page.svelte +28 -0
- package/template.config.js +17 -12
- /package/{template → examples/notes}/src/lib/objects/Note.ts +0 -0
- /package/{template/src/routes → examples/notes/src/routes/notes}/+page.server.ts +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# First run
|
|
2
|
+
|
|
3
|
+
## Browser QA follow-up test design
|
|
4
|
+
|
|
5
|
+
| Behavior/invariant | Trigger and positive case | Failure/negative case | Actor, executor and runtime | Contract edge and validation |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| Review/decision is visible | Keyboard preview focuses and reveals review; apply reveals pending decision | Apply failure remains actionable, no success claim | Local owner, browser DOM; no SQL | Component regression and built-app keyboard proof |
|
|
8
|
+
| Single initial confirmation | Owner's server-stored unfinished first run and zero tenant list rows apply directly | Rows, restart, forged flags, changed preview or data arriving during activation retain/refuse approval shortcut | Owner/session ceiling; public collection counts on local SQLite; cookbook CAS | Core + real host regression; full package tests |
|
|
9
|
+
| Step navigation | One AI heading, visible step progress, back/keep-app controls | Pending writes cannot be abandoned | Authenticated browser; no SQL | Component tests and keyboard proof |
|
|
10
|
+
| Background | Full viewport in light/dark at desktop/phone widths | No differently colored area below short card | Browser theme tokens; no SQL | Built-app computed styles/screenshots |
|
|
11
|
+
| Settings | Visible explained switch and unsettled decisions | Completed/denied/failed outcomes never rendered here; failed save restores toggle | Owner, existing preference CAS and approval transport, SQLite | Component + product/browser tests |
|
|
12
|
+
| Introduction | Cookbook navigation order and labels, short supported help | No engine, unknown actions, technical model/tool vocabulary | Host-projected offerings; browser only | Host/component tests and built-app proof |
|
|
13
|
+
|
|
14
|
+
Reuse before edits: configured MCP reviewed core, smrt-svelte and template and
|
|
15
|
+
architecture context queried first-run emptiness, preview/focus, prebuilt settings,
|
|
16
|
+
owner decisions and introduction. Read the intent index; name/purpose `rg`
|
|
17
|
+
searched UI, Svelte, chat, core, preferences and template for step/progress,
|
|
18
|
+
focus/reveal, prebuilt toggles/settings, `isAppEmpty` and approval policies.
|
|
19
|
+
Extend existing onboarding/core contracts. New `PrebuiltComponentsSettings.svelte`
|
|
20
|
+
composes Toggle, Button, Card, existing approval card/transport and translated
|
|
21
|
+
messages; SettingsCatalog is a registry browser, not this preference editor.
|
|
22
|
+
Reuse Progress for the step indicator; native focus/instant scroll is needed for
|
|
23
|
+
headings (control `revealControl` always smooth-scrolls a form control).
|
|
24
|
+
|
|
25
|
+
Opt in with `createCookbookApplication({ onboarding: true, ... })`. Mount
|
|
26
|
+
`host.onboarding` as GET/POST `/api/onboarding`. The layout returns `onboarding`
|
|
27
|
+
and `assistantIntroduction`; an authenticated local owner sees the saved welcome,
|
|
28
|
+
AI, or template step until finished. A completed installation only enters the
|
|
29
|
+
picker again through the Settings confirmation. Completion remains durable while
|
|
30
|
+
that optional replacement is in progress.
|
|
31
|
+
|
|
32
|
+
`FirstRunOnboarding` from `smrt-svelte/onboarding` composes ConnectAi and chat's
|
|
33
|
+
existing owner approval card. Supply its authenticated clients and a completion
|
|
34
|
+
navigation callback. It owns no credential, cookbook mutation, or approval store.
|
|
35
|
+
API-key setup stays on the inference settings page; returning to onboarding
|
|
36
|
+
refreshes ConnectAi status. Step headings receive focus; controls use shared
|
|
37
|
+
primitives, translated messages and tokens; grids wrap on phones and use no motion.
|
|
38
|
+
|
|
39
|
+
An unconfigured host renders chat's `AiUnavailableNotice` with its existing
|
|
40
|
+
`unconfigured` reason and a Connect AI link. It does not mount AssistantDock,
|
|
41
|
+
its composer/polling, or the tool-derived greeting until an engine is connected.
|
|
42
|
+
Connected docks retain `aiSettingsHref` for a later unavailable response.
|
|
43
|
+
|
|
44
|
+
`host/onboarding.ts` persists owner/tenant progress using SQLite CAS in a separate
|
|
45
|
+
host system table. Its primary key is also the index for every query. Same-origin,
|
|
46
|
+
bounded JSON POST accepts only known actions and a current revision. Owner
|
|
47
|
+
membership is checked on every call; cookbook tool permissions are rechecked by
|
|
48
|
+
the canonical tool service. Preview labels come from the engine snapshot, including
|
|
49
|
+
layout overrides/hidden items. Apply regenerates the process-local preview token
|
|
50
|
+
and checks the original diff fingerprint/revision before applying. Unfinished first run counts the current cookbook list collections
|
|
51
|
+
through the tenant-scoped public collection API. With no rows, the explicit Use
|
|
52
|
+
confirmation applies directly; technical owner identity is not a person-facing
|
|
53
|
+
list. Populated apps and Settings restarts request a durable owner approval. Approval decisions use chat's existing route/continuation. A
|
|
54
|
+
successful terminal hold marks onboarding done on refresh, including after
|
|
55
|
+
restart. Failed/denied holds retain the step and require a fresh preview to retry.
|
|
56
|
+
No rows are deleted by template application; changed policies/navigation/recipes
|
|
57
|
+
are reviewed through the canonical preview, with owner approval for replacement.
|
|
58
|
+
|
|
59
|
+
## Test design
|
|
60
|
+
|
|
61
|
+
| Behavior / trigger | Positive | Failure | Actor/context | Executor/transaction | Runtime/edge | Level / command |
|
|
62
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
63
|
+
| Welcome/AI advance | Engine first; explicit skip | Wrong step, unknown action rejected | Authenticated local owner | SQLite scoped CAS | Node 26 / HTTP | Component + host / package test |
|
|
64
|
+
| Resume/complete | Recreate helper at each step; done stays done | Stale revision cannot overwrite progress | Owner and tenant identity | One UPDATE CAS; failed action saves nothing | SQLite / Fetch | Host / template test |
|
|
65
|
+
| Preview/apply | Cookbook labels, durable hold, success after restart | Changed preview, apply failure, denied hold retry | Live owner/tool permission | Core CAS/audit + runtime approval continuation | SQLite / cookbook tools | Host + core / package test |
|
|
66
|
+
| Transport security | Same-origin owner | Anonymous, other tenant/non-owner, foreign origin, malformed/oversized body | Session bound, no body identity | No mutation on refusal | Local SQLite only | Host / template test |
|
|
67
|
+
| Accessible UI | Keyboard focus, labelled buttons, axe; phone wrapping | Retry remains on step | Browser owner | No SQL in component | jsdom / fake clients | Component / Svelte test |
|
|
68
|
+
| Working app | Yoga sections, named customer, stub assistant reads | No-engine inline prompt | Auto-claimed local owner | Product SQLite and generated REST | adapter-node / stub model | Product first-run smoke |
|
|
69
|
+
|
|
70
|
+
## Reuse check
|
|
71
|
+
|
|
72
|
+
Configured smrt-dev-mcp `review_smrt_project` on core, smrt-svelte and template;
|
|
73
|
+
`build_context` queried durable first run, ConnectAi, template preview/apply,
|
|
74
|
+
approval and lazy activation. This server has context/model inventories but no
|
|
75
|
+
standalone component/intent/recipe search endpoint. Read the intent index and
|
|
76
|
+
searched names AND purposes with `rg` in smrt-ui, smrt-svelte, chat, core,
|
|
77
|
+
inference and template: onboarding/first-run/wizard, template/listTemplates,
|
|
78
|
+
preview/approval/resume, settings/engine selection and cookbook nav labels.
|
|
79
|
+
|
|
80
|
+
| New production file | Existing implementation reused / reason |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `host/onboarding.ts` | Composes core cookbook tools/engine snapshots, host SQLite and runtime owner approval continuation. OwnerSetupForm claims an owner; ConnectAi selects an engine; neither stores this first-run sequence. |
|
|
83
|
+
| `smrt-svelte/src/components/onboarding/FirstRunOnboarding.svelte` | ConnectAi, Button/Card/ConfirmDialog and AssistantApprovalCard; no duplicate wizard, engine form or authority. |
|
|
84
|
+
| `smrt-svelte/src/components/onboarding/OnboardingAssistant.svelte` | Existing AssistantDock/controller; adds a tool-derived first greeting and calm settings link. No new chat history or transport. |
|
|
85
|
+
| `smrt-svelte/src/components/onboarding/client.ts` | Follows ConnectAi's bounded same-origin route transport; this endpoint has different action/revision semantics. |
|
|
86
|
+
| `smrt-svelte/src/components/onboarding/types.ts` | Reuses AssistantApprovalView; defines only first-run progress/transport DTOs, not business models. |
|
|
87
|
+
| `smrt-svelte/src/components/onboarding/index.ts`, `i18n/strings.onboarding.ts` | Existing export and defineMessages catalog patterns. |
|
|
88
|
+
| `__tests__/onboarding.test.ts` | Reuses core's `getTestDatabase` and the existing host/ConnectAi request-fixture pattern. Its private event/read/change functions exercise this new revision-bound endpoint; no reusable first-run request fixture existed. |
|
|
89
|
+
| `smrt-svelte/src/components/onboarding/__tests__/FirstRunOnboarding.test.ts` | Reuses Testing Library, userEvent and UI's `expectNoA11yViolations`, as in ConnectAi tests. Its private fixture fakes the new first-run DTO/client plus the existing ConnectAi contract. |
|
|
90
|
+
| `smrt-svelte/src/components/onboarding/__tests__/OnboardingAssistant.test.ts` | Reuses cookbook's existing dock test fixture and actual AiUnavailableNotice; mocks only the dock to observe mount/transport behavior. |
|
|
91
|
+
|
|
92
|
+
Test-fixture searches used `rg` for `fixture`, `event`, `getTestDatabase` and
|
|
93
|
+
`expectNoA11yViolations` in the owning ConnectAi tests, cookbook host tests and
|
|
94
|
+
onboarding tests, alongside the first-run/approval searches above. These remain
|
|
95
|
+
test-local adapters rather than exported framework helpers.
|
|
96
|
+
|
|
97
|
+
Integration rebase `c8a329c455`: retain the host's public source-alias table and
|
|
98
|
+
Svelte runtime inference export; drop E2's duplicate generic alias commit.
|
|
99
|
+
Regenerate knowledge from the full build. The real host tests now recreate the
|
|
100
|
+
host between first-run apply and owner decision, prove Fresh closes REST/MCP and
|
|
101
|
+
navigation, and activate a template before exercising effective app Profile STI
|
|
102
|
+
creation, gated subtype refusal and Customer reference labels through REST.
|
|
103
|
+
Customer intentionally publishes read-only MCP; the test preserves that boundary.
|
|
104
|
+
The existing subclass, dispatcher and reference-picker implementations are reused.
|
|
105
|
+
The earlier rebase introduced no new production helper or component.
|
|
106
|
+
|
|
107
|
+
Browser QA #2 adds `PrebuiltComponentsSettings.svelte` in the owning Svelte
|
|
108
|
+
settings composition. It reuses Toggle/Button/Card and AssistantApprovalCard;
|
|
109
|
+
terminal outcomes stay in approval history. Its new test file uses existing
|
|
110
|
+
Testing Library/userEvent and UI axe helpers (searched those names in settings,
|
|
111
|
+
ConnectAi and onboarding tests). No new model, transport, store or test helper.
|
|
112
|
+
Preview and pending decisions receive native focus and instant scroll; step
|
|
113
|
+
progress uses UI Progress. ConnectAi accepts `headingId` to reuse its parent
|
|
114
|
+
heading. Greetings use the public pure workspace `applyShellLayout` projection
|
|
115
|
+
so lead lists follow the actual cookbook section ordering and wording, with
|
|
116
|
+
short sentences limited to offered actions. Backgrounds fill 100dvh with tokens.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Local plugin mode
|
|
2
|
+
|
|
3
|
+
Mount `GET`/`POST = host.pluginMode` at `/api/plugin-mode`. The endpoint is local
|
|
4
|
+
single-owner only: direct loopback peer, exact Host, first-class owner session,
|
|
5
|
+
no bearer, exact Origin for writes and bounded JSON. GET returns secret-free
|
|
6
|
+
`PluginModeState`. POST accepts `{action:'connect'|'revoke',client:'codex'|
|
|
7
|
+
'claude-code'|'claude-desktop'}` or `{action:'embed',enabled:boolean}`. The layout's
|
|
8
|
+
`embed` is persistent per owner and tenant; pass it to existing CookbookApp.
|
|
9
|
+
Engine selection and embed updates preserve each other in the existing host store.
|
|
10
|
+
|
|
11
|
+
Connect rotates one holder in app-runtime's existing token store. The one-time
|
|
12
|
+
bearer goes directly into `saveCliConfig`'s private atomic file under the app
|
|
13
|
+
state root; it never enters HTML, a setup snippet, argv or a repository. The
|
|
14
|
+
adjacent generated launcher contains public paths/options only and invokes the
|
|
15
|
+
existing desktop `runLauncher({credentialPath})`. That mode verifies the saved
|
|
16
|
+
token in the same installation; it cannot mint a replacement after revocation.
|
|
17
|
+
Origin discovery and the health probe follow the existing launcher contract.
|
|
18
|
+
Each harness has an independent holder. Last seen uses the token store's existing
|
|
19
|
+
hour-granularity renewable-token usage timestamp (not a claim of an open socket).
|
|
20
|
+
|
|
21
|
+
The single `app.plugin` delegation permission is registered before owner seeding.
|
|
22
|
+
Only a token issued with that sole scope opts into plugin projection; broad owner
|
|
23
|
+
tokens retain their existing MCP contract even after their live permissions shrink.
|
|
24
|
+
The host reads original scopes from the existing token record, and verifies the
|
|
25
|
+
exact sole active local owner before delegation or credential issuance.
|
|
26
|
+
It means the current app tool surface, including future owner-published lists;
|
|
27
|
+
it grants no unrelated admin operation. On *each* verification the host binds the
|
|
28
|
+
token owner, reloads cookbook/preferences, resolves live owner permissions, and
|
|
29
|
+
intersects them with the assistant manifest + recipe/app service offerings. The
|
|
30
|
+
MCP plugin projection reuses `manifestToolToAITool` and `invokeManifestTool` for
|
|
31
|
+
exact assistant schema/operation parity. Wire aliases use the existing snake-case
|
|
32
|
+
converter. Ordinary operation-scoped MCP tokens keep their generated MCP surface
|
|
33
|
+
and package restrictions. Plugin delegation is explicit consent to the in-app
|
|
34
|
+
assistant surface, not a widening of ordinary MCP tokens. The existing outcome reader is also a principal-bound assistant extra tool,
|
|
35
|
+
`app.approvals` / `owner_approval_outcome`, when this requester has a hold. Both
|
|
36
|
+
transports call the same continuation reader, rechecking the original tool scope.
|
|
37
|
+
`PluginModeState.tools` exposes the actual assistant definitions and source
|
|
38
|
+
metadata to the signed-in local owner for parity inspection; no token is exposed.
|
|
39
|
+
|
|
40
|
+
All destructive model calls use the existing continuation authority. Native
|
|
41
|
+
recipe/app tools retain executor consumption. The owner-assigned credential label
|
|
42
|
+
prefixes the approval summary; a caller's claimed MCP name never supplies identity.
|
|
43
|
+
Held results say where to approve and return `approvalId`/`owner_approval_outcome`.
|
|
44
|
+
Approval consumes once before dispatch; repeated decisions/outcome reads do not
|
|
45
|
+
replay. As elsewhere, a crash during effects remains executing/unknown and needs
|
|
46
|
+
reconciliation; no transactional exactly-once external-effect guarantee is claimed.
|
|
47
|
+
|
|
48
|
+
The existing stdio bridge polls stateless tools/list every two seconds and emits
|
|
49
|
+
`tools/list_changed` on complete descriptor changes, invalidation and recovery.
|
|
50
|
+
It follows pagination, re-resolves credentials every request, redacts upstream
|
|
51
|
+
errors and stops its timer on close. The HTTP host remains stateless and uses the
|
|
52
|
+
existing private, zero-TTL catalog cache option so every discovery checks live
|
|
53
|
+
permissions and owner status.
|
|
54
|
+
|
|
55
|
+
## Setup and packaged apps
|
|
56
|
+
|
|
57
|
+
`generateLocalMcpSetup` in app-cli renders a shell-quoted `claude mcp add`, JSON for
|
|
58
|
+
Claude Desktop/`.mcp.json`, and Codex TOML. Each contains only the running app's
|
|
59
|
+
Node executable and generated private launcher path. Settings must explain that
|
|
60
|
+
the app stays open and that destructive calls wait in its approvals list.
|
|
61
|
+
|
|
62
|
+
A normal packaged app must retain app-cli and desktop as production dependencies.
|
|
63
|
+
The host uses `../bridge/smrt-mcp-bridge.mjs` beside its packaged `app/` directory,
|
|
64
|
+
plus the running bundled Node, and resolves the installed desktop launcher module.
|
|
65
|
+
No PATH lookup, checkout or globally installed Node is required. Source hosts
|
|
66
|
+
fall back to the installed app-cli bridge. Replacing/moving the installation may
|
|
67
|
+
require generating setup again so absolute executable/module paths are refreshed.
|
|
68
|
+
|
|
69
|
+
ChatGPT remote connectors cannot reach a person's loopback listener. The repo's
|
|
70
|
+
MCP Apps/OpenAI packages are view and server adapters, not a local ChatGPT executor.
|
|
71
|
+
The manifest generator also supports desktop-only distribution, but this app has
|
|
72
|
+
no verified ChatGPT desktop integration; Settings states that limit instead of
|
|
73
|
+
issuing a non-working local URL. Official desktop submission requires separate
|
|
74
|
+
organization access/review, not just a localhost connector.
|
|
75
|
+
|
|
76
|
+
## Test design
|
|
77
|
+
|
|
78
|
+
All new execution is Node 26, in-process SQLite; subprocesses are the real local
|
|
79
|
+
stdio bridge, never a provider/model or container. Commands are package `pnpm test`
|
|
80
|
+
and `pnpm typecheck`; the product adds built-app QA with the same launcher.
|
|
81
|
+
|
|
82
|
+
| Behavior/invariant | Reachable positive | Failure control | Actor/context; executor/transaction | Contract edge; test level |
|
|
83
|
+
| --- | --- | --- | --- | --- |
|
|
84
|
+
| Setup/credentials | Generated commands launch real bridge; token stays private | Foreign origin/anonymous/non-loopback/bearer/invalid/oversized body refused | First-class owner; existing token rotation transaction + atomic CLI file | JSON/TOML/shell; host integration + app-cli unit |
|
|
85
|
+
| Delegation | Same assistant operations, current and newly added lists | Narrow scopes, revoked token, disabled recipe/preference | Live owner/tenant; request principal and canonical dispatcher | MCP SDK stdio + HTTP; integration |
|
|
86
|
+
| Live catalog | Recipe enable and custom list change discovery | Closed preference removes recipe/provider tools | Same principal; existing cookbook/editor CAS publication | list_changed; integration |
|
|
87
|
+
| Approval | Held delete then owner decision and repeated outcome | Duplicate decisions refuse; existing authority covers denied/expired/foreign requester | Saved ceiling/args, canonical ApprovalService CAS then effect | Existing owner HTTP + continuation; integration |
|
|
88
|
+
| Native destructive tools | Disable/template/remove retain canonical holds | No second consumption or model-supplied approval | Owner; existing native executor + continuation | Existing host tests plus plugin client integration |
|
|
89
|
+
| Embed | Save and layout returns embed; existing CookbookApp omits dock | Engine selection and other tenant/user retained | Owner; existing host row JSON update | Layout + component/browser evidence |
|
|
90
|
+
| Launcher | Reuses verified credential and current origin | Revoked/private-mode/symlink refusal, no remint | Local user; canonical store verify | Subprocess stdio; desktop tests |
|
|
91
|
+
|
|
92
|
+
## Reuse check
|
|
93
|
+
|
|
94
|
+
MCP `review_smrt_project` reviewed app-cli, app-runtime, desktop, template, core and
|
|
95
|
+
the product; `build_context` queried harness setup, tokens, settings, live tools and
|
|
96
|
+
continuations. The configured server exposes context/model inventory but no
|
|
97
|
+
separate component/recipe/intent search API. Read the intent index; `rg` searched
|
|
98
|
+
smrt-ui, smrt-svelte, chat, core and owning packages by name and purpose:
|
|
99
|
+
plugin/setup/connect/settings, credential/config/token/holder, launcher/stdio,
|
|
100
|
+
approval/continuation/outcome, embed/dock, list_changed/catalog/exposure.
|
|
101
|
+
|
|
102
|
+
New files: `host/plugin-mode.ts` composes saveCliConfig, generateLocalMcpSetup,
|
|
103
|
+
runLauncher, local token store and existing host persistence; no existing owner
|
|
104
|
+
settings composition generated these connections. Product `PluginModeSettings.svelte`
|
|
105
|
+
uses ShellSettingsPage's extension slot, shared Card/Button/Toggle/i18n and the
|
|
106
|
+
ConnectAi composition pattern; no existing component managed app MCP clients.
|
|
107
|
+
Product `/api/plugin-mode/+server.ts` is only a mount. `cookbookPluginMode.test.ts` reuses
|
|
108
|
+
runtime owner/session/SQLite, existing host fixture patterns, and SDK Client/
|
|
109
|
+
StdioClientTransport; its two noun models are test-only fixtures, not app models.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## Integration rebase
|
|
113
|
+
|
|
114
|
+
Rebased on `b018dca6a544e572c10a9541b290eff0110fa875`. Keep the integration
|
|
115
|
+
CLI continuation capture for thread and non-thread model holds; the plugin
|
|
116
|
+
adds its trusted client label and an internal projection marker to that binding.
|
|
117
|
+
It does not restore the old direct-authority thread branch. Scope opt-in still
|
|
118
|
+
uses original issued metadata; per-turn CLI tokens still use their actual offered
|
|
119
|
+
canonical operation intersection. Structured results and synchronous hold
|
|
120
|
+
publication remain intact. Onboarding alone can supply `initialSetup`; plugin
|
|
121
|
+
template apply retains its normal owner hold.
|
|
122
|
+
|
|
123
|
+
The three-launcher fixture compares every name, description and schema to the
|
|
124
|
+
shared catalog and captures a real in-app fake-model turn, including after the
|
|
125
|
+
outcome reader appears. It enables a recipe that was already an active hidden
|
|
126
|
+
prerequisite, checks list_changed, publishes a linked custom list through MCP,
|
|
127
|
+
and uses the existing screen reference adapter to find/read the named target
|
|
128
|
+
through the authenticated REST path. Same-name app replacement, STI creation
|
|
129
|
+
and inline contact projection are additionally checked in the real packaged app
|
|
130
|
+
and retained host/onboarding fixtures. The explicit Profile STI control now
|
|
131
|
+
places that list deliberately; default prerequisites stay hidden.
|
|
132
|
+
|
|
133
|
+
Codex plugin configuration/SDK transport success is not in-app engine readiness.
|
|
134
|
+
Native Codex 0.162.1 remains refused by inference's preflight policy; no code-host
|
|
135
|
+
flag, sandbox policy, model or billing fallback is changed. Product Settings
|
|
136
|
+
keeps the integration's shared PrebuiltComponentsSettings composition.
|
|
137
|
+
|
|
138
|
+
Reuse repeated MCP project reviews/context plus intent-index and name/purpose
|
|
139
|
+
searches for tool aliases, placements, summaries, native holds and scopes in
|
|
140
|
+
UI/Svelte/chat/core and the owning packages. `functionName` extends chat's
|
|
141
|
+
existing renderer/dispatch maps. The outcome tool moves the existing reader
|
|
142
|
+
behind the existing PrincipalTool seam; no new store or approval executor.
|
|
143
|
+
The reference case reuses createRecipeScreenReferences, screenReferenceTarget,
|
|
144
|
+
screenRecordLabel and APIGenerator. No new production file was introduced by
|
|
145
|
+
this follow-up. Generated lock/knowledge artifacts are regenerated, not merged.
|
|
146
|
+
|
|
147
|
+
API-profile custom methods additionally reuse core's `resolveApiMethodExposure`
|
|
148
|
+
with the effective model config. A permission-catalog method such as Customer's
|
|
149
|
+
internal `getProfileId` must not become an app tool when its owning API include
|
|
150
|
+
list excludes it. Standard principal-scoped CRUD and CLI's generated MCP policy
|
|
151
|
+
remain unchanged. The real Customer assistant regression and packaged catalog
|
|
152
|
+
assertion cover this boundary; there is no hand-written method-name blacklist.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getPreferencePrincipal } from '@happyvertical/smrt-preferences';
|
|
2
|
+
import { loadCookbookApp } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
3
|
+
import { createCookbookPreferences } from '@happyvertical/smrt-template-sveltekit/host/preferences';
|
|
4
|
+
import { host, runtime } from '$lib/server/smrt';
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
CookbookSaveResult,
|
|
8
|
+
CookbookScope,
|
|
9
|
+
CookbookSource,
|
|
10
|
+
} from '@happyvertical/smrt-template-sveltekit/host/preferences';
|
|
11
|
+
export { SHELL_SURFACE } from '@happyvertical/smrt-template-sveltekit/host/preferences';
|
|
12
|
+
export const { loadCookbook, saveCookbookEdits, homePath } =
|
|
13
|
+
createCookbookPreferences({
|
|
14
|
+
runtime,
|
|
15
|
+
app: async () => {
|
|
16
|
+
const principal = getPreferencePrincipal();
|
|
17
|
+
return principal
|
|
18
|
+
? host.cookbookApp(principal.tenantId)
|
|
19
|
+
: loadCookbookApp();
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCookbookApplication } from '@happyvertical/smrt-template-sveltekit/host/server';
|
|
2
|
+
import { activationLoaders, activationManifest } from './smrt-register';
|
|
3
|
+
import { name } from '../../../package.json';
|
|
4
|
+
import './settings-registry';
|
|
5
|
+
|
|
6
|
+
export const host = createCookbookApplication({
|
|
7
|
+
packageName: name,
|
|
8
|
+
onboarding: true,
|
|
9
|
+
lazyActivation: { manifest: activationManifest, loaders: activationLoaders, scope: name },
|
|
10
|
+
});
|
|
11
|
+
export const runtime = host.runtime;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { redirect } from '@sveltejs/kit';
|
|
2
|
+
import { loadCookbook } from '$lib/server/cookbook';
|
|
3
|
+
import { host } from '$lib/server/smrt';
|
|
4
|
+
import type { LayoutServerLoad } from './$types';
|
|
5
|
+
|
|
6
|
+
export const load: LayoutServerLoad = async (event) => {
|
|
7
|
+
const data = await host.load(event);
|
|
8
|
+
if (
|
|
9
|
+
data.onboarding &&
|
|
10
|
+
!data.onboarding.completed &&
|
|
11
|
+
!['/onboarding', '/settings/inference'].includes(event.url.pathname)
|
|
12
|
+
)
|
|
13
|
+
redirect(303, '/onboarding');
|
|
14
|
+
return {
|
|
15
|
+
...data,
|
|
16
|
+
embed: event.url.searchParams.get('embed') === '1',
|
|
17
|
+
/** The project's cookbook and recipe catalog; `null` without a cookbook. */
|
|
18
|
+
cookbookApp: data.session.authenticated
|
|
19
|
+
? await loadCookbook({
|
|
20
|
+
signedIn: true,
|
|
21
|
+
})
|
|
22
|
+
: data.cookbookApp,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CookbookApp } from '@happyvertical/smrt-svelte/cookbook';
|
|
3
|
+
import { createCookbookAssistant } from '@happyvertical/smrt-template-sveltekit/host/client';
|
|
4
|
+
import { signOut } from '@happyvertical/smrt-template-sveltekit/host/sveltekit-client';
|
|
5
|
+
import type { Cookbook } from '@happyvertical/smrt-types';
|
|
6
|
+
import { invalidateAll } from '$app/navigation';
|
|
7
|
+
import { page } from '$app/state';
|
|
8
|
+
import type { LayoutProps } from './$types';
|
|
9
|
+
|
|
10
|
+
let { data, children }: LayoutProps = $props();
|
|
11
|
+
const assistantBase = createCookbookAssistant({ onchange: invalidateAll });
|
|
12
|
+
const assistant = $derived({ ...assistantBase, introduction: data.assistantIntroduction });
|
|
13
|
+
async function saveEdits(next: Cookbook) {
|
|
14
|
+
const response = await fetch('/api/cookbook/preferences', {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: { 'content-type': 'application/json' },
|
|
17
|
+
body: JSON.stringify(next),
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) throw new Error('Could not save your layout preferences.');
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if data.cookbookApp}
|
|
24
|
+
<CookbookApp
|
|
25
|
+
cookbook={data.cookbookApp.cookbook}
|
|
26
|
+
catalog={data.cookbookApp.catalog}
|
|
27
|
+
href={(path: string) => path.replace(/(.)\/$/, '$1')}
|
|
28
|
+
title={data.cookbookApp.cookbook.name ?? 'My app'}
|
|
29
|
+
navMode="sections-with-items"
|
|
30
|
+
currentHref={page.url.pathname}
|
|
31
|
+
settingsHref="/settings"
|
|
32
|
+
user={data.session.user}
|
|
33
|
+
onSignOut={signOut}
|
|
34
|
+
accountMenu={{ theme: true }}
|
|
35
|
+
edgeToggles={{ left: true }}
|
|
36
|
+
config={{ left: { initial: 'expanded' } }}
|
|
37
|
+
assistant={data.session.authenticated ? assistant : undefined}
|
|
38
|
+
embed={data.embed}
|
|
39
|
+
phoneTabBar
|
|
40
|
+
runtimeDiagnostics={data.session.authenticated}
|
|
41
|
+
layoutEditing={data.session.authenticated}
|
|
42
|
+
oncookbookchange={data.session.authenticated ? saveEdits : undefined}
|
|
43
|
+
chrome={!page.route.id?.startsWith('/setup') && !page.route.id?.startsWith('/onboarding')}
|
|
44
|
+
>
|
|
45
|
+
{@render children()}
|
|
46
|
+
</CookbookApp>
|
|
47
|
+
{/if}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { error, redirect } from '@sveltejs/kit';
|
|
2
|
+
import { homePath } from '$lib/server/cookbook';
|
|
3
|
+
import type { PageServerLoad } from './$types';
|
|
4
|
+
|
|
5
|
+
export const load: PageServerLoad = async ({ locals, parent }) => {
|
|
6
|
+
if (!locals.user) redirect(303, '/setup');
|
|
7
|
+
const { cookbookApp } = await parent();
|
|
8
|
+
if (!cookbookApp) error(404, 'This app has no cookbook.');
|
|
9
|
+
if (
|
|
10
|
+
!cookbookApp.cookbook.recipes.length &&
|
|
11
|
+
!cookbookApp.cookbook.features.length
|
|
12
|
+
)
|
|
13
|
+
return { fresh: true };
|
|
14
|
+
redirect(303, homePath(cookbookApp));
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineMessages, useI18n } from '@happyvertical/smrt-ui/i18n';
|
|
3
|
+
import { EmptyState } from '@happyvertical/smrt-ui/layout';
|
|
4
|
+
|
|
5
|
+
const M = defineMessages({
|
|
6
|
+
'cookbook.fresh.title': 'What would you like to build?',
|
|
7
|
+
'cookbook.fresh.description':
|
|
8
|
+
'Tell your assistant about your work to add your first lists, or choose a template in Settings.',
|
|
9
|
+
});
|
|
10
|
+
const { t } = useI18n();
|
|
11
|
+
</script>
|
|
12
|
+
<EmptyState title={t(M['cookbook.fresh.title'])} description={t(M['cookbook.fresh.description'])} />
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PreferenceAccessError } from '@happyvertical/smrt-preferences';
|
|
2
|
+
import { error, json } from '@sveltejs/kit';
|
|
3
|
+
|
|
4
|
+
import { hasCookbook } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
5
|
+
import { saveCookbookEdits } from '$lib/server/cookbook';
|
|
6
|
+
import type { RequestHandler } from './$types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stores the layout and overview edits `CookbookApp` reports after an edit,
|
|
10
|
+
* as the signed-in person's preferences (or the organization default with
|
|
11
|
+
* `?scope=tenant`, which needs the customize permissions). The body is the
|
|
12
|
+
* cookbook the shell holds; only its `layout` and `overviews` are read, and
|
|
13
|
+
* each is validated before it is stored.
|
|
14
|
+
*/
|
|
15
|
+
export const POST: RequestHandler = async ({ request, locals, url }) => {
|
|
16
|
+
if (!locals.user) error(401, 'Sign in to save your layout.');
|
|
17
|
+
if (!(await hasCookbook())) error(404, 'This project has no cookbook.');
|
|
18
|
+
const scope = url.searchParams.get('scope') === 'tenant' ? 'tenant' : 'user';
|
|
19
|
+
let body: unknown;
|
|
20
|
+
try {
|
|
21
|
+
body = await request.json();
|
|
22
|
+
} catch {
|
|
23
|
+
error(400, 'The body must be the cookbook as JSON.');
|
|
24
|
+
}
|
|
25
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
26
|
+
error(400, 'The body must be the cookbook as JSON.');
|
|
27
|
+
}
|
|
28
|
+
let result: Awaited<ReturnType<typeof saveCookbookEdits>>;
|
|
29
|
+
try {
|
|
30
|
+
result = await saveCookbookEdits(body, scope);
|
|
31
|
+
} catch (cause) {
|
|
32
|
+
if (cause instanceof PreferenceAccessError) {
|
|
33
|
+
error(403, 'You may not change these preferences.');
|
|
34
|
+
}
|
|
35
|
+
throw cause;
|
|
36
|
+
}
|
|
37
|
+
if (result.ok) return json(result);
|
|
38
|
+
const status =
|
|
39
|
+
result.reason === 'not_allowed'
|
|
40
|
+
? 403
|
|
41
|
+
: result.reason === 'conflict'
|
|
42
|
+
? 409
|
|
43
|
+
: 400;
|
|
44
|
+
return json(result, { status });
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadCookbookModelPage as load } from '@happyvertical/smrt-template-sveltekit/host/server';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CookbookModelPage from '@happyvertical/smrt-template-sveltekit/host/CookbookModelPage.svelte';
|
|
3
|
+
import { collectionDefinitions } from '@smrt/web';
|
|
4
|
+
import type { PageProps } from './$types';
|
|
5
|
+
let { data }: PageProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
<CookbookModelPage {data} {collectionDefinitions} />
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { redirect } from '@sveltejs/kit';
|
|
2
|
+
import type { PageServerLoad } from './$types';
|
|
3
|
+
export const load: PageServerLoad = async ({ locals, parent, url }) => {
|
|
4
|
+
if (!locals.user) redirect(303, '/setup');
|
|
5
|
+
const data = await parent();
|
|
6
|
+
if (
|
|
7
|
+
data.onboarding?.completed &&
|
|
8
|
+
!data.onboarding.rerunning &&
|
|
9
|
+
url.searchParams.get('restart') !== '1'
|
|
10
|
+
)
|
|
11
|
+
redirect(303, '/');
|
|
12
|
+
return { onboarding: data.onboarding };
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createAssistantHttpTransport } from '@happyvertical/smrt-chat/svelte';
|
|
3
|
+
import { createConnectAiClient } from '@happyvertical/smrt-svelte/connect-ai';
|
|
4
|
+
import {
|
|
5
|
+
createOnboardingClient,
|
|
6
|
+
FirstRunOnboarding,
|
|
7
|
+
} from '@happyvertical/smrt-svelte/onboarding';
|
|
8
|
+
import { defineMessages, useI18n } from '@happyvertical/smrt-ui/i18n';
|
|
9
|
+
import { goto, invalidateAll } from '$app/navigation';
|
|
10
|
+
import type { PageProps } from './$types';
|
|
11
|
+
|
|
12
|
+
let { data }: PageProps = $props();
|
|
13
|
+
const M = defineMessages({
|
|
14
|
+
'cookbook.onboarding.title': 'Welcome',
|
|
15
|
+
'cookbook.onboarding.description':
|
|
16
|
+
'Your own app for the work and people that matter to you.',
|
|
17
|
+
});
|
|
18
|
+
const { t } = useI18n();
|
|
19
|
+
const client = createOnboardingClient({ endpoint: '/api/onboarding' });
|
|
20
|
+
const connectAi = createConnectAiClient({ endpoint: '/api/connect-ai' });
|
|
21
|
+
const approvalTransport = createAssistantHttpTransport({
|
|
22
|
+
endpoint: '/api/assistant',
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
<svelte:head><title>{t(M['cookbook.onboarding.title'])} · My app</title></svelte:head>
|
|
26
|
+
{#if data.onboarding}
|
|
27
|
+
<FirstRunOnboarding {client} {connectAi} {approvalTransport} initialState={data.onboarding} appName="My app" description={t(M['cookbook.onboarding.description'])} apiKeyHref="/settings/inference?returnTo=onboarding" oncomplete={async () => { await invalidateAll(); await goto('/'); }} />
|
|
28
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { hasCookbook } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
2
|
+
import { error, redirect } from '@sveltejs/kit';
|
|
3
|
+
import type { PageServerLoad } from './$types';
|
|
4
|
+
|
|
5
|
+
/** A section of the cookbook's navigation; the page itself is client-rendered. */
|
|
6
|
+
export const load: PageServerLoad = async ({ locals }) => {
|
|
7
|
+
if (!(await hasCookbook())) error(404, 'This app has no cookbook.');
|
|
8
|
+
if (!locals.user) redirect(303, '/setup');
|
|
9
|
+
return {};
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AssistantApprovalView } from '@happyvertical/smrt-chat/assistant-turn';
|
|
2
|
+
import { redirect } from '@sveltejs/kit';
|
|
3
|
+
import { host } from '$lib/server/smrt';
|
|
4
|
+
import type { PageServerLoad } from './$types';
|
|
5
|
+
|
|
6
|
+
export const load: PageServerLoad = async (event) => {
|
|
7
|
+
if (!event.locals.user) redirect(303, '/setup');
|
|
8
|
+
const response = await host.prebuilt(event);
|
|
9
|
+
if (!response.ok) throw new Error('Settings unavailable');
|
|
10
|
+
const approvals = await host.assistant.GET({
|
|
11
|
+
...event,
|
|
12
|
+
params: { ...event.params, path: 'approvals' },
|
|
13
|
+
});
|
|
14
|
+
if (!approvals.ok) throw new Error('Approvals unavailable');
|
|
15
|
+
return {
|
|
16
|
+
approvals: (await approvals.json()).approvals as AssistantApprovalView[],
|
|
17
|
+
prebuilt: (await response.json()) as {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
revision: string | null;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|