@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
package/AGENTS.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# template-sveltekit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It is the ground-up alternative to `smrt-start`.
|
|
3
|
+
`smrt gnode create --template=sveltekit` scaffold; an alternative to `smrt-start`.
|
|
5
4
|
|
|
6
5
|
## Exports
|
|
7
6
|
|
|
7
|
+
- [Cookbook host](agents/cookbook-host.md).
|
|
8
|
+
|
|
8
9
|
- `getTemplatePath()` returns the template directory.
|
|
9
10
|
- `copyTemplate(destination, options)` copies authored files, substitutes the
|
|
10
|
-
|
|
11
|
-
- `templateInfo` describes the SvelteKit, SQLite,
|
|
12
|
-
|
|
11
|
+
package name, and skips `.svelte-kit` and test-fixture directories.
|
|
12
|
+
- `templateInfo` describes the template's SvelteKit, SQLite, session, tenancy
|
|
13
|
+
and permission foundation.
|
|
13
14
|
|
|
14
15
|
## Current generated-project contract
|
|
15
16
|
|
|
@@ -17,15 +18,15 @@ It is the ground-up alternative to `smrt-start`.
|
|
|
17
18
|
(contract v1, `@happyvertical/smrt-config/deployment`). It is the source of
|
|
18
19
|
`charts/smrt-app/fixtures/starter.json`: after changing its services or
|
|
19
20
|
annotations run `node scripts/compose-contract-fixture.mjs --write` and
|
|
20
|
-
commit the fixture; `
|
|
21
|
+
commit the fixture; `compose-contract.test.mjs` fails on drift.
|
|
21
22
|
|
|
22
23
|
- Node `>=26.0.0`; pnpm `11.25.0` via `packageManager` and `engines`. Node 25+
|
|
23
|
-
images ship no Corepack
|
|
24
|
+
images ship no Corepack; the Dockerfile installs a pinned copy.
|
|
24
25
|
- `runtime.profile` is the canonical infrastructure selector. Generated apps
|
|
25
|
-
expose deterministic `app:*` operations and keep runtime state
|
|
26
|
+
expose deterministic `app:*` operations and keep runtime state out of source.
|
|
26
27
|
- Every lifecycle script is a `smrt app <operation>` one-liner
|
|
27
28
|
(`packages/cli/agents/app-commands.md`); the template ships no `scripts/`.
|
|
28
|
-
Never reintroduce copied operator scripts
|
|
29
|
+
Never reintroduce copied operator scripts; fix the CLI command.
|
|
29
30
|
- Server composition is `createSmrtSvelteKitRuntime()` from
|
|
30
31
|
`@happyvertical/smrt-app-runtime/sveltekit`, built once in
|
|
31
32
|
`src/lib/server/smrt.ts`, which holds only `runtime` and its options
|
|
@@ -37,41 +38,38 @@ It is the ground-up alternative to `smrt-start`.
|
|
|
37
38
|
`getCollection`/`getSmrtConfig` export would take precedence (deprecated,
|
|
38
39
|
honoured for one release): never re-add one, a register import, guard, or
|
|
39
40
|
manifest hydration.
|
|
40
|
-
Health, diagnostics, layout session
|
|
41
|
-
|
|
42
|
-
- The production baseline uses adapter-node with separate web, task-worker, and
|
|
41
|
+
Health, diagnostics, layout session and owner setup routes mount its handlers.
|
|
42
|
+
- The production baseline uses adapter-node with separate web, task-worker and
|
|
43
43
|
schedule-worker processes. Workers import the build-compiled
|
|
44
44
|
`.smrt/runtime/register.js` (#3117) before creating runners so app-defined
|
|
45
|
-
jobs resolve the app's own objects.
|
|
46
|
-
and operator CLI
|
|
47
|
-
- Deployed authentication, asset
|
|
48
|
-
|
|
49
|
-
- Every supported local web writer (`app:start` or `pnpm dev`)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
jobs resolve the app's own objects. The runtime image retains the generated
|
|
46
|
+
manifest and operator CLI that `app:doctor`, `app:export` and `app:import` need.
|
|
47
|
+
- Deployed authentication, asset and secret readiness is delegated to installed
|
|
48
|
+
provider-owned probe modules; never replace it with truthy flags.
|
|
49
|
+
- Every supported local web writer (`app:start` or `pnpm dev`) acquires the
|
|
50
|
+
same external writer lease. Logical imports and filesystem backups fail
|
|
51
|
+
closed while any writer is alive; logical exports take one database
|
|
52
|
+
transaction snapshot and include filesystem assets referenced by exported
|
|
53
|
+
asset rows in a digest-verified, provider-neutral manifest. Imports stage and
|
|
54
|
+
verify those assets before committing rows. Direct production startup must
|
|
55
|
+
set an explicit loopback `HOST`.
|
|
56
56
|
- Local `app:start` proves readiness against the loopback-only identity fields
|
|
57
57
|
on the runtime health route using the canonical application ID, random
|
|
58
58
|
process instance, and secret-safe runtime configuration identity; a
|
|
59
59
|
different or stale server is never accepted as this app. Deployed health
|
|
60
60
|
responses expose only generic status and profile.
|
|
61
61
|
- Directly used `@happyvertical/smrt-*` packages share one current release range.
|
|
62
|
-
- `@happyvertical/smrt-cli` is a direct dev dependency because every
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
- `@happyvertical/smrt-cli` is a direct dev dependency because every lifecycle
|
|
63
|
+
script runs its binary; the runtime image keeps dev dependencies for workers
|
|
64
|
+
and operator commands. `@happyvertical/smrt-web` is included because the root
|
|
65
65
|
Provider wires the generated read-only WebMCP definitions for every page.
|
|
66
66
|
- The generated MCP server resolves its imports from the scaffolded app, not
|
|
67
|
-
|
|
68
|
-
`@modelcontextprotocol/server` (
|
|
69
|
-
`@happyvertical/smrt-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
CLI's or core's transitive dependencies to the app root — its strict layout
|
|
74
|
-
does not (#2297).
|
|
67
|
+
the CLI, so every specifier `generate-mcp` emits must be declared here:
|
|
68
|
+
`@modelcontextprotocol/server` (and `/stdio`), `@happyvertical/smrt-core` and
|
|
69
|
+
`@happyvertical/smrt-config` always, plus `@happyvertical/smrt-jobs` and
|
|
70
|
+
`@happyvertical/smrt-tenancy` for the default worker and tenant surfaces.
|
|
71
|
+
pnpm's strict layout does not expose the CLI's or core's transitive
|
|
72
|
+
dependencies to the app root (#2297).
|
|
75
73
|
- `vite.config.ts` is `[sveltekit(), smrt()]`. The preset consumes exactly the
|
|
76
74
|
packages in `smrt.config.ts` `consumer.packages` (profiles, tenancy, users, reports),
|
|
77
75
|
scans `src/lib/objects`, and generates Vite virtual definitions, SvelteKit
|
|
@@ -92,34 +90,53 @@ It is the ground-up alternative to `smrt-start`.
|
|
|
92
90
|
`src/lib/server/commerce.ts` (`bootstrapCommerceTenant`) calls
|
|
93
91
|
`ensureCommerceTenant()` only when the app has installed
|
|
94
92
|
`@happyvertical/smrt-commerce` (resolved from its own `node_modules`, with a
|
|
95
|
-
variable import specifier), passing `smrt.cookbook.json` when present.
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
variable import specifier), passing `smrt.cookbook.json` when present. `/setup`
|
|
94
|
+
runs it from `onOwnerClaimed`, after the claim created the tenant, and logs a
|
|
95
|
+
failure because the runtime ignores hook errors. Any other
|
|
98
96
|
tenant-creation path an app adds should call it too (#4009).
|
|
99
97
|
- App code uses `runtime.getCollection()`/`runtime.classOptions()`, which are
|
|
100
98
|
request-scoped (RLS transaction) and must never be retained.
|
|
101
|
-
-
|
|
102
|
-
`
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
- A new app registers no object and opens on an empty home page (no Note, no
|
|
100
|
+
`notes.*` permissions, no migration). The Note example lives outside the
|
|
101
|
+
generated app in `examples/notes/` (an `src/`-shaped tree: the object and a
|
|
102
|
+
`/notes` page) and is not built or registered by default; it demonstrates
|
|
103
|
+
required tenant scope, a REST writable allowlist, shared CRUD action
|
|
104
|
+
metadata, and the explicit collection registration generated CLI/MCP runtime
|
|
105
|
+
commands need. Never move it back under `template/`; tests get it from the
|
|
106
|
+
reference fixture (`copyRuntimeProfileReference()`).
|
|
107
|
+
- The example page loads data in `+page.server.ts`; loads declare
|
|
105
108
|
`depends('smrt:notes')`, mutations call `invalidate('smrt:notes')`, and
|
|
106
109
|
hand-written writes call `assertOperationPermission()` with the session's
|
|
107
110
|
exact permission snapshot.
|
|
108
111
|
- The root layout is `AppShell` from `@happyvertical/smrt-svelte/app` with a
|
|
109
112
|
small explicit `nav`; `/setup` and `/settings` mount that package's
|
|
110
113
|
`OwnerSetupForm` and `ShellSettingsPage`. Generated REST routes do not imply
|
|
111
|
-
page routes.
|
|
114
|
+
page routes. Settings is a section menu: `/settings` lists the sections and
|
|
115
|
+
each is its own page (`/settings/[section=settingsSection]` for the built-in
|
|
116
|
+
Appearance, Account, Layout and Shortcuts, via the `isShellSettingsSection`
|
|
117
|
+
param matcher; host sections get a static route beside it).
|
|
118
|
+
- Inference and Prompts are host sections (`/settings/inference`,
|
|
119
|
+
`/settings/prompts`) mounting `InferenceSettingsPanel` and
|
|
120
|
+
`PromptSettingsPanel`. `consumer.packages` lists their packages (smrt-inference,
|
|
121
|
+
-prompts, -preferences, -secrets) so their tables exist on first start.
|
|
122
|
+
`settings-registry.ts` (imported by `smrt.ts` first) registers the
|
|
123
|
+
`inference` preference kind and the `inference.*` / `prompts.customize`
|
|
124
|
+
permissions the owner role is seeded with. `settings.ts` holds the session
|
|
125
|
+
(writes need the permission in its snapshot) and builds smrt-inference's
|
|
126
|
+
`createInferenceSettingsHost` and `createInferenceSettingsController` (shared
|
|
127
|
+
with the app shell; the route is thin); `installInferenceOverrides` registers
|
|
128
|
+
the resolver. Owner-only `saveKey` stores keys via the controller;
|
|
129
|
+
`masterKeyProvider` is `runtime.secretMasterKey()` (local: created; env wins).
|
|
112
130
|
- Session user and sign-out: `+layout.server.ts` (`createSessionLayoutLoad()`)
|
|
113
131
|
returns `session.user` (`{ id, email, name? }` only, never the record or
|
|
114
|
-
tokens). The root layout passes it as AppShell `user`
|
|
115
|
-
`
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
- The Notes page is built from smrt-ui primitives only (`Button`, `Card`,
|
|
132
|
+
tokens). The root layout passes it as AppShell `user` with `onSignOut` from
|
|
133
|
+
`src/lib/sign-out.ts` (same-origin `POST /sign-out`, then `invalidateAll()`
|
|
134
|
+
and `goto('/')`); the settings page passes the same helper.
|
|
135
|
+
`src/routes/sign-out/+server.ts` mounts `createSignOutHandler(runtime)` (POST
|
|
136
|
+
only; same-origin only; 204, or 303 to `/` for an HTML form post). The layout
|
|
137
|
+
enables `phoneTabBar` and sets `chrome={!page.route.id?.startsWith('/setup')}`
|
|
138
|
+
so `/setup` renders only the chrome-free `OwnerSetupForm` card.
|
|
139
|
+
- The example Notes page is built from smrt-ui primitives only (`Button`, `Card`,
|
|
123
140
|
`Form`, `FormGroup`, `Input`, `Textarea`, `EmptyState`): no raw `<form>`,
|
|
124
141
|
`<input>`, or `<button>`, token spacing, and a "Start your first note" empty
|
|
125
142
|
state. The root layout passes only live AppShell props (no `subtitle`,
|
package/README.md
CHANGED
|
@@ -69,14 +69,29 @@ lifecycle script is `smrt app <operation>`.
|
|
|
69
69
|
|
|
70
70
|
## 3. Define the first object
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
constructor keeps generated CLI/MCP runtime commands constructible. Its
|
|
75
|
-
`@smrt()` configuration exposes CRUD to REST, MCP, WebMCP definitions, and CLI
|
|
76
|
-
while using an API writable allowlist.
|
|
72
|
+
A new app ships with no object: `src/lib/objects/index.ts` is an empty barrel,
|
|
73
|
+
the home page is an empty state, and nothing is registered or migrated.
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
`
|
|
75
|
+
The Note example is kept outside the template, in `examples/notes/`, as an
|
|
76
|
+
`src/`-shaped tree you can copy into a generated app:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cp -r packages/template-sveltekit/examples/notes/src/. my-app/src/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
It adds `src/lib/objects/Note.ts` (a required-tenant object with title and body
|
|
83
|
+
fields, a small explicit `NoteCollection` that keeps generated CLI/MCP runtime
|
|
84
|
+
commands constructible, and an `@smrt()` configuration that exposes CRUD to
|
|
85
|
+
REST, MCP, WebMCP definitions, and CLI with an API writable allowlist) and a
|
|
86
|
+
`/notes` page. Then:
|
|
87
|
+
|
|
88
|
+
1. Export it in `src/lib/objects/index.ts`:
|
|
89
|
+
`export { Note, NoteCollection } from './Note.js';`
|
|
90
|
+
2. Link `/notes` from the `nav` array in `src/routes/+layout.svelte`.
|
|
91
|
+
3. Run `pnpm db:migrate`.
|
|
92
|
+
|
|
93
|
+
Add your own objects the same way. `vite.config.ts` already scans
|
|
94
|
+
`src/lib/objects`.
|
|
80
95
|
|
|
81
96
|
## 4. Initialize or migrate the database
|
|
82
97
|
|
|
@@ -114,13 +129,13 @@ identity, Profile is person-facing metadata, Membership joins a User to a
|
|
|
114
129
|
Tenant and Role, Role maps to Permission records, and Session publishes the
|
|
115
130
|
resolved permission snapshot.
|
|
116
131
|
|
|
117
|
-
The
|
|
132
|
+
The example page's form action calls `assertOperationPermission()` with that exact
|
|
118
133
|
snapshot. Provider-specific login and provisioning remain app-owned extension
|
|
119
134
|
points.
|
|
120
135
|
|
|
121
136
|
## 7. Load data into a SvelteKit page
|
|
122
137
|
|
|
123
|
-
The
|
|
138
|
+
The example `/notes` page loads Note rows in `+page.server.ts`, returns plain serialized
|
|
124
139
|
data, and declares `depends('smrt:notes')`. The Svelte 5 page reads hydrated
|
|
125
140
|
`$props()` data and calls `invalidate('smrt:notes')` after a successful form
|
|
126
141
|
mutation. It does not fetch initial data in `onMount` or `$effect`.
|
|
@@ -133,7 +148,7 @@ declared dev dependency:
|
|
|
133
148
|
|
|
134
149
|
```bash
|
|
135
150
|
pnpm smrt objects
|
|
136
|
-
pnpm smrt schema
|
|
151
|
+
pnpm smrt schema <YourObject>
|
|
137
152
|
pnpm smrt generate-mcp --no-config --no-readme
|
|
138
153
|
```
|
|
139
154
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Cookbook design runs
|
|
2
|
+
|
|
3
|
+
`host/design-runs.ts` composes inference's `createDesignRunDriver`,
|
|
4
|
+
`createDesignRunStore` and registered `DesignRunRecord.execute` with jobs'
|
|
5
|
+
`SmrtJobCollection` and the host's existing `TaskRunner`. It installs one executor
|
|
6
|
+
per database. Runtime migrations create the checkpoint and job tables; the
|
|
7
|
+
factory does not create schema. Dispose the executor after stopping the runner.
|
|
8
|
+
Jobs use one attempt: domain checkpoints own resume, so a stopped old invocation
|
|
9
|
+
cannot automatically reclaim its job while an external promise is still settling.
|
|
10
|
+
|
|
11
|
+
The authenticated host binds `forOwner(ownerId, tenantId)` from the live session.
|
|
12
|
+
`start` commits the checkpoint and job admission in one transaction before any
|
|
13
|
+
model executes. `status`, `latest(threadId)`, `stop` and `resume` keep the same
|
|
14
|
+
owner and tenant binding after a restart. `latest` considers the newest 100 owner
|
|
15
|
+
runs. Resume rejects while the prior job still runs, avoiding a dedupe race with
|
|
16
|
+
its terminal write; retry once the current pass has stopped.
|
|
17
|
+
|
|
18
|
+
The pinned design profile, original authenticated permission ceiling and
|
|
19
|
+
thread/request text are durable inputs, never a credential or captured Request.
|
|
20
|
+
Live permissions are intersected with that ceiling for every pass, so restart
|
|
21
|
+
cannot expand authority. Each pass reauthorizes the owner. A real
|
|
22
|
+
TaskRunner context and live job claim are required for execution, and checkpoint
|
|
23
|
+
writes recheck that claim. Request disconnects have no signal connection to the
|
|
24
|
+
worker. Stop aborts the local pass cooperatively and preserves its durable
|
|
25
|
+
checkpoint. Once the original model/check promise actually settles, a worker-only
|
|
26
|
+
transaction releases the stopped lease. Its no-op conditional update locks the
|
|
27
|
+
captured job, worker and attempt before the checkpoint CAS; a recovered or later
|
|
28
|
+
claim cannot release that lease. A cooperative Stop can resume immediately after
|
|
29
|
+
settlement, even with a long call deadline. An external engine that ignores
|
|
30
|
+
cancellation keeps its lease until actual settlement or the lease deadline; a new
|
|
31
|
+
process recovers through jobs' worker-liveness contract.
|
|
32
|
+
|
|
33
|
+
New runs pin `cookbook-design/v5/<maximum>`. Their first real pass proposes the
|
|
34
|
+
change. With no raw owner `design.budgets.passes` property, a ready proposal of
|
|
35
|
+
small changes on one existing list may finish after that pass's normal mechanical
|
|
36
|
+
check and native Apply. Additive scalar/choice/money fields, field rename/hide and
|
|
37
|
+
list display-label rename are eligible; money's paired currency column remains
|
|
38
|
+
one logical field. Relationship fields, multiple resolved lists, removal and
|
|
39
|
+
restructuring expand to the configured maximum. Existing schemas, permissions,
|
|
40
|
+
revision checks and approvals remain authoritative; eligibility grants no access.
|
|
41
|
+
|
|
42
|
+
When the normal service catalog offers `app.describe`, one ordinary read pins
|
|
43
|
+
its revision and bounded canonical list IDs, labels and aliases solely for
|
|
44
|
+
classification. If that read is not offered (for example, a recipe-only host
|
|
45
|
+
without an app editor), classification is absent and the full path remains
|
|
46
|
+
available. No permission or app-editor requirement is added to admission; owner
|
|
47
|
+
and thread authorization remain mandatory. Current-revision reads for actual
|
|
48
|
+
Apply/recovery remain strict. Exact unambiguous descriptor
|
|
49
|
+
matches and sequential list-label renames establish same-list identity. Unknown
|
|
50
|
+
or ambiguous references expand rather than guessing. A proved pre-effect core
|
|
51
|
+
collision or clarification expands the remaining work; after any receipt/hold,
|
|
52
|
+
or an uncertain thrown failure, the host never starts another planning pass.
|
|
53
|
+
Explicit raw pass counts (including four) remain fixed; untouched defaults,
|
|
54
|
+
unrelated edits and Reset `{}` stay adaptive. The private descriptor/fixed-count
|
|
55
|
+
pins cannot be supplied by HTTP/tool metadata. No new preference is introduced.
|
|
56
|
+
|
|
57
|
+
Ajv validates every engine result and repair against the pinned schema, including
|
|
58
|
+
separate raw `summary` and untrusted `personSummary` fields. The host keeps their
|
|
59
|
+
raw values privately and publishes fixed safe person notes. An early completion
|
|
60
|
+
retains its actual checked index, outputs, attempts and consumed usage; no skipped
|
|
61
|
+
pass receives fabricated metadata. Public progress starts with one planned pass
|
|
62
|
+
and expands only when more work is needed. Native holds, Stop/Resume and real
|
|
63
|
+
replacement job claims replay that same proposal/action identity without another
|
|
64
|
+
model call. Pinned v3/v4 contracts and their original pass ordering remain intact;
|
|
65
|
+
the narrow historical v2 migration still targets v3, never v5.
|
|
66
|
+
|
|
67
|
+
Their operation schema is a `oneOf`
|
|
68
|
+
of the current core cookbook structural tool names and input schemas, resolved
|
|
69
|
+
under the live owner. Approval ids are excluded from proposal arguments. The
|
|
70
|
+
model sees those exact schemas as proposal data while its callable tools remain
|
|
71
|
+
read-only; unknown tool names, MCP wire names and extra arguments enter the same
|
|
72
|
+
bounded schema repair path without effects. Persisted v1 runs retain their
|
|
73
|
+
original schema and review-pending semantics; their completed outputs are never
|
|
74
|
+
reinterpreted as valid actions.
|
|
75
|
+
|
|
76
|
+
Authenticated same-origin `POST /api/assistant/design-runs` admits a design job
|
|
77
|
+
directly using exactly `{ threadId, content }`. It reuses chat's own thread-read
|
|
78
|
+
handler to check session ownership, then resolves the design profile and
|
|
79
|
+
permission ceiling on the server. It accepts no identity, engine, profile or
|
|
80
|
+
action-key overrides and performs no preliminary model turn.
|
|
81
|
+
|
|
82
|
+
The server's pass executor uses its existing authenticated assistant route and
|
|
83
|
+
engine adapters with job-bound limits. Design passes offer only read/proposal
|
|
84
|
+
tools: replay and schema repair cannot repeat mutation effects. The run produces
|
|
85
|
+
a concrete proposal (`operations: [{ tool, args }]`) in the original thread.
|
|
86
|
+
A ready durable proposal is applied by its deterministic check through the
|
|
87
|
+
existing core cookbook service. The host supplies an application/run/action
|
|
88
|
+
identity; an action's index is stable and core pins its exact arguments. Preview
|
|
89
|
+
creates a native durable owner hold in the existing thread approval UI. Its
|
|
90
|
+
ordinary decision route executes the held action with current owner permissions
|
|
91
|
+
intersected with the original ceiling, then queues the same final check. That
|
|
92
|
+
check recovers the exact core result before advancing to `done`; it never makes
|
|
93
|
+
another model call. With preview off, additive changes apply directly and still
|
|
94
|
+
enter change history. Destructive changes always retain native owner approval.
|
|
95
|
+
An unready final durable proposal terminates as failed with the host's plain note that
|
|
96
|
+
no changes were applied and more information is needed. It creates no approval
|
|
97
|
+
hold or history entry. Historical v1/v2 review semantics are preserved. The
|
|
98
|
+
profile grants no authority. The model
|
|
99
|
+
never applies effects as part of a replayable schema pass. Deterministic Fresh,
|
|
100
|
+
template application and Start over keep their established policy; only actual
|
|
101
|
+
assistant work starts a design job.
|
|
102
|
+
|
|
103
|
+
Stop also pauses new effects from an existing native hold. The ordinary owner
|
|
104
|
+
decision can still record approval while stopped, returning its normal approved
|
|
105
|
+
state without consuming or executing it. Explicit Resume applies that same hold
|
|
106
|
+
once and completes the run. Denial remains a durable terminal decision. Stop
|
|
107
|
+
does not reverse an effect already recorded in change history.
|
|
108
|
+
|
|
109
|
+
Explicit owner Resume can migrate a completed v2 `app.addField` review proposal
|
|
110
|
+
to v3's final check without repeating its model passes. This narrow adapter pins
|
|
111
|
+
the core argument schema from committed `d3b879bef0` using core's exported
|
|
112
|
+
`stableStringify`; other v2 operations require a fresh run. Migration requires
|
|
113
|
+
a ready nonempty proposal valid against the current supported core schemas, its
|
|
114
|
+
original permission ceiling, live thread ownership and application revision, and
|
|
115
|
+
no job or execution lease. One
|
|
116
|
+
transaction compares the exact old payload, revision and scoped identity before
|
|
117
|
+
changing the definition; attempts, outputs, usage and run id are preserved. A
|
|
118
|
+
proposal/schema fingerprint prevents later drift. Durable runs persist their own
|
|
119
|
+
schema pin, preserve it through every check and validate it before native
|
|
120
|
+
continuation effects. V1 and unready v2 outputs are never migrated. HTTP cannot
|
|
121
|
+
select a definition, action or profile.
|
|
122
|
+
|
|
123
|
+
Crash recovery preserves the persisted final-check lease. The old job must first
|
|
124
|
+
be terminally recovered by TaskRunner's worker-liveness sweep, with an
|
|
125
|
+
authoritative `stale-recovery` outcome for that exact job/attempt. Owner Resume
|
|
126
|
+
then atomically admits a new existing job against the unchanged checkpoint. Its
|
|
127
|
+
real replacement claim authorizes check replay and core returns the exact
|
|
128
|
+
committed action result. Generic failed jobs and a live original worker do not
|
|
129
|
+
qualify; no lease is cleared to bypass ownership.
|
|
130
|
+
|
|
131
|
+
Inference reserves unknown usage conservatively, accumulates time/tokens across
|
|
132
|
+
passes and preserves usage on resume. The host's `readResource` callback is
|
|
133
|
+
owner-bound and paged; missing resource support fails closed.
|
|
134
|
+
|
|
135
|
+
## Reuse audit
|
|
136
|
+
|
|
137
|
+
Before adding the adapter, read `docs/knowledge/intents/index.md`, invoked MCP
|
|
138
|
+
`review_smrt_project` for template-sveltekit and `build_context` for durable
|
|
139
|
+
cookbook design composition, and searched smrt-ui, smrt-svelte, chat, core, jobs
|
|
140
|
+
and inference by name and purpose (`DesignRun`, durable passes, schema validation,
|
|
141
|
+
`runAssistantTurn`, engine adapters, job admission). Existing inference
|
|
142
|
+
checkpoints/driver and jobs runner own persistence and execution; the host owns
|
|
143
|
+
only its cookbook passes and authenticated callback composition. Core already
|
|
144
|
+
owns Ajv as a direct dependency; this package declares its own direct dependency
|
|
145
|
+
for its host validation rather than reaching through core's dependency tree.
|
|
146
|
+
|
|
147
|
+
`__tests__/cookbookDesignRuns.test.ts` uses in-process SQLite and the real
|
|
148
|
+
TaskRunner. It verifies admission before execution, owner isolation, stopped-run
|
|
149
|
+
resume after replacing the host, active Stop with preserved usage and permission
|
|
150
|
+
ceiling, immediate resume of a cooperatively settled pass with a 30-minute lease,
|
|
151
|
+
uncooperative execution retaining its reservation, late release refused after a
|
|
152
|
+
job claim changes, three ordered checked passes, schema repair and
|
|
153
|
+
unknown-usage cumulative budget exhaustion/resume, and durable final-check
|
|
154
|
+
replay. Its 22 tests include narrow historical schema drift, live
|
|
155
|
+
revision/permission rejection and concurrent migration. The real host suite
|
|
156
|
+
verifies default native preview and the
|
|
157
|
+
existing approval POST, direct preview-off history, destructive approval,
|
|
158
|
+
denial, approval deferred by Stop, schema repair without effects and scoped
|
|
159
|
+
history projection. Its
|
|
160
|
+
file-backed SQLite crash scenario suspends the completion checkpoint after a
|
|
161
|
+
real core mutation, simulates worker death with public liveness retirement,
|
|
162
|
+
observes TaskRunner's real orphan outcome and recovers the exact result under a
|
|
163
|
+
replacement job claim without clearing the persisted lease or calling a model
|
|
164
|
+
again. No external engines or containers are involved.
|