@happyvertical/smrt-template-sveltekit 0.74.7 → 0.75.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 +22 -5
- package/README.md +49 -0
- package/agents/cookbook-host.md +10 -3
- package/cookbook-template/src/hooks.server.ts +4 -2
- package/cookbook-template/src/lib/server/cookbook.ts +1 -1
- package/cookbook-template/src/routes/+layout.server.ts +4 -2
- package/cookbook-template/src/routes/+layout.svelte +6 -0
- package/cookbook-template/src/routes/+page.server.ts +1 -1
- package/cookbook-template/src/routes/api/_runtime/owner-link/+server.ts +1 -1
- package/cookbook-template/src/routes/api/assistant/[...path]/+server.ts +1 -1
- package/cookbook-template/src/routes/api/connect-ai/+server.ts +1 -1
- package/cookbook-template/src/routes/api/cookbook/prebuilt/+server.ts +1 -1
- package/cookbook-template/src/routes/api/cookbook/preferences/+server.ts +1 -1
- package/cookbook-template/src/routes/api/onboarding/+server.ts +1 -1
- package/cookbook-template/src/routes/mcp/+server.ts +1 -1
- package/cookbook-template/src/routes/settings/+page.server.ts +1 -1
- package/cookbook-template/src/routes/settings/inference/+page.server.ts +1 -1
- package/cookbook-template/vite.config.ts +3 -1
- package/dist/host/server.d.ts +2 -1
- package/dist/host/server.js +18 -2
- package/dist/host/settings.d.ts +11 -0
- package/dist/host/settings.js +15 -0
- package/examples/notes/src/routes/notes/+page.server.ts +2 -2
- package/examples/notes/src/routes/notes/+page.svelte +1 -2
- package/host/InferenceSettingsPage.svelte +13 -2
- package/index.js +3 -3
- package/mcp-apps-template/package.dependencies.json +2 -2
- package/mcp-apps-template/src/routes/.well-known/oauth-protected-resource/api/mcp/+server.ts +1 -1
- package/mcp-apps-template/src/routes/api/mcp/+server.ts +2 -2
- package/package.json +50 -49
- package/template/README.md +38 -1
- package/template/gitignore.template +3 -0
- package/template/package.json +25 -19
- package/template/smrt.config.ts +1 -0
- package/template/src/app.d.ts +7 -1
- package/template/src/app.html +1 -1
- package/template/src/hooks.server.ts +6 -7
- package/template/src/lib/components/MaterializedReportDrilldown.svelte +1 -1
- package/template/src/lib/i18n/LanguageLayout.svelte +19 -0
- package/template/src/lib/i18n/LanguageSwitcher.svelte +17 -0
- package/template/src/lib/i18n/catalog.ts +27 -0
- package/template/src/lib/i18n/locale-tool.ts +19 -0
- package/template/src/lib/i18n/locales.ts +62 -0
- package/template/src/lib/i18n/messages.catalog.ts +39 -0
- package/template/src/lib/i18n/messages.ts +3 -0
- package/template/src/lib/i18n/shell-spanish.ts +173 -0
- package/template/src/lib/server/i18n.ts +48 -0
- package/template/src/lib/server/language-preference.ts +30 -0
- package/template/src/lib/server/languages.ts +67 -0
- package/template/src/lib/server/settings-registry.ts +2 -0
- package/template/src/params.ts +8 -0
- package/template/src/routes/+layout.server.ts +9 -5
- package/template/src/routes/+layout.svelte +10 -4
- package/template/src/routes/+page.svelte +7 -4
- package/template/src/routes/api/_reports/runtime/confirm/+server.ts +1 -1
- package/template/src/routes/api/_runtime/diagnostics/+server.ts +1 -1
- package/template/src/routes/api/_runtime/health/+server.ts +1 -1
- package/template/src/routes/api/languages/mcp/+server.ts +59 -0
- package/template/src/routes/api/settings/languages/+server.ts +32 -0
- package/template/src/routes/language/+server.ts +20 -0
- package/template/src/routes/reports/materialized/[id]/+page.server.ts +1 -1
- package/template/src/routes/reports/materialized/[id]/+page.svelte +2 -3
- package/template/src/routes/reports/materialized/[id]/drilldown/+server.ts +1 -1
- package/template/src/routes/settings/+page.svelte +11 -7
- package/template/src/routes/settings/[section=settingsSection]/+page.svelte +1 -1
- package/template/src/routes/settings/inference/+page.server.ts +1 -1
- package/template/src/routes/settings/languages/+page.server.ts +15 -0
- package/template/src/routes/settings/languages/+page.svelte +59 -0
- package/template/src/routes/settings/languages/+server.ts +20 -0
- package/template/src/routes/settings/prompts/+page.server.ts +1 -1
- package/template/src/routes/setup/+page.server.ts +2 -2
- package/template/src/routes/sign-out/+server.ts +1 -1
- package/template/tsconfig.json +3 -1
- package/template/vite.config.ts +3 -1
- package/template.config.js +21 -19
- package/template/src/params/settingsSection.ts +0 -4
- package/template/svelte.config.js +0 -16
package/AGENTS.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
(provider readiness via `createProviderReadinessProbe`), so the web process
|
|
34
34
|
never imports the CLI. The runtime takes the local writer lease by default,
|
|
35
35
|
the `smrt()` plugin injects the generated registration, and each generated
|
|
36
|
-
route embeds a prelude that imports
|
|
36
|
+
route embeds a prelude that imports `#lib/server/smrt` and resolves
|
|
37
37
|
collections through its exported `runtime.getCollection()` (#3416). A legacy
|
|
38
38
|
`getCollection`/`getSmrtConfig` export would take precedence (deprecated,
|
|
39
39
|
honoured for one release): never re-add one, a register import, guard, or
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
|
|
84
84
|
## Application patterns
|
|
85
85
|
|
|
86
|
-
- `src/hooks.server.ts`
|
|
86
|
+
- `src/hooks.server.ts` mounts the runtime's `init` and wraps its authorized
|
|
87
|
+
resolve callback with document attribute substitution after page loads. URL tenant
|
|
87
88
|
selection stays a separate candidate and only the verified session
|
|
88
89
|
establishes tenant context. Never turn an untrusted header into authority.
|
|
89
90
|
- Commerce is optional and never a template dependency.
|
|
@@ -114,7 +115,7 @@
|
|
|
114
115
|
page routes. Settings is a section menu: `/settings` lists the sections and
|
|
115
116
|
each is its own page (`/settings/[section=settingsSection]` for the built-in
|
|
116
117
|
Appearance, Account, Layout and Shortcuts, via the `isShellSettingsSection`
|
|
117
|
-
param matcher
|
|
118
|
+
param matcher in `src/params.ts` via Kit 3 `defineParams`; host sections get a static route beside it).
|
|
118
119
|
- Inference and Prompts are host sections (`/settings/inference`,
|
|
119
120
|
`/settings/prompts`) mounting `InferenceSettingsPanel` and
|
|
120
121
|
`PromptSettingsPanel`. `consumer.packages` lists their packages (smrt-inference,
|
|
@@ -127,6 +128,18 @@
|
|
|
127
128
|
with the app shell; the route is thin); `installInferenceOverrides` registers
|
|
128
129
|
the resolver. Owner-only `saveKey` stores keys via the controller;
|
|
129
130
|
`masterKeyProvider` is `runtime.secretMasterKey()` (local: created; env wins).
|
|
131
|
+
- Interface locales: `src/lib/i18n/messages.catalog.ts` is pure English/Spanish
|
|
132
|
+
starter data; `catalog.ts` explicitly composes every shipped package, including
|
|
133
|
+
lazy settings routes. The root server load explicitly tracks `lang` URL changes,
|
|
134
|
+
reads persisted public language policy, and selects
|
|
135
|
+
enabled URL → cookie → weighted browser → default locale, and fills document
|
|
136
|
+
`lang`/`dir` during SSR. Nonpage/API requests do not build snapshots; SvelteKit
|
|
137
|
+
data navigation invokes the tracked layout load. `/language` persists native POST switches in an HTTP-only
|
|
138
|
+
cookie. AppShell receives `data.i18n`; the root layout synchronizes document
|
|
139
|
+
attributes after navigation. `/settings/languages` mounts the languages package
|
|
140
|
+
panels with verified tenant scope; all app-scope inventory and mutations require
|
|
141
|
+
`runtime.hasApplicationPermission(sessionId, 'languages.customize_app')`, never
|
|
142
|
+
tenant-role authority. Workspace writes require `languages.customize`.
|
|
130
143
|
- Session user and sign-out: `+layout.server.ts` (`createSessionLayoutLoad()`)
|
|
131
144
|
returns `session.user` (`{ id, email, name? }` only, never the record or
|
|
132
145
|
tokens). The root layout passes it as AppShell `user` with `onSignOut` from
|
|
@@ -170,8 +183,8 @@
|
|
|
170
183
|
## Tests
|
|
171
184
|
|
|
172
185
|
Tests live in package-level `__tests__/`, never under `template/`. Vitest's
|
|
173
|
-
global setup creates a temporary
|
|
174
|
-
afterward; `copyTemplate()` filters
|
|
186
|
+
global setup creates a temporary `node_modules/$app/tsconfig.json` stub and removes it
|
|
187
|
+
afterward; `copyTemplate()` filters dependencies and build output as defense in depth.
|
|
175
188
|
|
|
176
189
|
`__tests__/support/` holds reusable, test-only helpers shared by the M5
|
|
177
190
|
runtime-profile proofs:
|
|
@@ -203,3 +216,7 @@ of the generated app with its own database, handlers and registrations. Rules
|
|
|
203
216
|
for the harness, `pnpm test:e2e`, `pnpm test:m5`, the per-part
|
|
204
217
|
`pnpm test:m5:part <id>` CI runs and the artifacts:
|
|
205
218
|
[agents/m5-browser-gate.md](agents/m5-browser-gate.md).
|
|
219
|
+
|
|
220
|
+
SvelteKit 3 configuration lives in `sveltekit({ adapter, preprocess, ... })` in
|
|
221
|
+
`vite.config.ts`; never ship `svelte.config.js`. Consumers use native `#lib`
|
|
222
|
+
subpath imports with file extensions and extend `$app/tsconfig`.
|
package/README.md
CHANGED
|
@@ -196,3 +196,52 @@ import fail closed while a writer is alive; logical export reads every model
|
|
|
196
196
|
table from one transaction snapshot and reports that uploaded assets are
|
|
197
197
|
excluded. The production image retains the generated manifest and operator CLI
|
|
198
198
|
required by doctor/export/import.
|
|
199
|
+
|
|
200
|
+
### Language API and MCP action parity
|
|
201
|
+
|
|
202
|
+
The settings page, `/api/settings/languages` and session-only
|
|
203
|
+
`/api/languages/mcp` use the languages package's shared strict operation executor.
|
|
204
|
+
The old `/settings/languages` JSON POST remains an alias (scope selected in its
|
|
205
|
+
URL). The explicit API takes scope in JSON, defaults GET inventory to tenant,
|
|
206
|
+
and rejects unknown/duplicate query options. GET requires `locale`.
|
|
207
|
+
|
|
208
|
+
| Action | HTTP | MCP tool |
|
|
209
|
+
| --- | --- | --- |
|
|
210
|
+
| Inventory, coverage, filters, effective preview and scope/locale selection | GET `/api/settings/languages?scope=tenant&locale=es` (optional search/packageName) | `languages_inventory` |
|
|
211
|
+
| Validate a draft's placeholders | POST operation `preview` | `languages_preview` |
|
|
212
|
+
| Save / reset / review override | POST operation `save` / `reset` / `review` | `languages_save` / `languages_reset` / `languages_review` |
|
|
213
|
+
| Default/enabled locales | POST operation `preferences` | `languages_preferences` |
|
|
214
|
+
| Exact-gap AI preview / enqueue / retry / progress | POST operation `fillPreview` / `fillEnqueue` / `fillRetry` / `fillProgress` | `languages_fill_preview` / `languages_fill_enqueue` / `languages_fill_retry` / `languages_fill_progress` |
|
|
215
|
+
| Persist active browser locale | POST `/language` (native form or strict JSON) | Remote MCP and root WebMCP `languages_locale_set` |
|
|
216
|
+
|
|
217
|
+
All POST API operations include `scope: 'tenant' | 'app'`. API callers use the
|
|
218
|
+
same-origin session. Remote MCP accepts only a verified human session cookie;
|
|
219
|
+
**any** Authorization header is rejected even with a valid cookie. It retains
|
|
220
|
+
the mount's default origin check and uses `legacy: 'stateless'` for client
|
|
221
|
+
initialize/list/call compatibility. `models: []` closes generated CRUD and
|
|
222
|
+
`requiredScopes: []` allows authenticated tool discovery only: the shared executor
|
|
223
|
+
still authorizes each invocation, requiring `languages.customize` for tenant
|
|
224
|
+
operations except inventory, and live `hasApplicationPermission(sessionId,
|
|
225
|
+
'languages.customize_app')` for every app operation. Tenant permission slugs
|
|
226
|
+
cannot grant application authority. Scope uses the verified active tenant,
|
|
227
|
+
review uses the session user, and AI source/glossary/job inputs are server bound.
|
|
228
|
+
Reset and external AI enqueue/retry advertise confirmation requirements; callers
|
|
229
|
+
supply `confirm: true` in MCP arguments. Revoked permission after discovery denies
|
|
230
|
+
execution. No real AI runs during tests.
|
|
231
|
+
|
|
232
|
+
`languages_locale_set` has an explicit root-owned write policy and is disposed
|
|
233
|
+
on layout teardown. It posts with same-origin credentials and reloads the safe
|
|
234
|
+
returned URL with `lang` removed. The HTTP-only SameSite cookie belongs to the
|
|
235
|
+
browser performing that POST; a remote HTTP client's cookies cannot change a
|
|
236
|
+
different browser's preference. Generated WebMCP stays read-only.
|
|
237
|
+
|
|
238
|
+
Remote `languages_locale_set` uses the same enabled-locale operation as `/language`,
|
|
239
|
+
sets this request client's HTTP-only cookie, and returns
|
|
240
|
+
`{ locale, preferenceTarget: 'request-client' }`. It needs no language management
|
|
241
|
+
permission. The session-only MCP transport still requires a verified session and
|
|
242
|
+
rejects Authorization headers. Set-Cookie is carried on the real MCP HTTP response.
|
|
243
|
+
The language MCP route opts into the public `awaitResponseCompletion` mount
|
|
244
|
+
option: its finite operation finishes before SvelteKit finalizes cookie headers
|
|
245
|
+
or releases the request context. Other MCP routes retain default streaming.
|
|
246
|
+
|
|
247
|
+
Existing applications: follow the [SvelteKit 3 migration guide](../../docs/content/sveltekit-3-migration.md) before upgrading.
|
package/agents/cookbook-host.md
CHANGED
|
@@ -42,8 +42,12 @@ remain subject to the packed runtime import and Svelte-condition checks.
|
|
|
42
42
|
`@happyvertical/smrt-template-sveltekit/host/server` exports
|
|
43
43
|
`createCookbookHost({ runtime, root?, title?, app?, assistant?, cli?, chatgpt? })`.
|
|
44
44
|
Construct it beside `createSmrtSvelteKitRuntime()` before startup. It registers
|
|
45
|
-
inference preferences/permissions before owner seeding. Export `host.handle`
|
|
46
|
-
`
|
|
45
|
+
inference preferences/permissions before owner seeding. Export `host.init` and wrap `host.handle` with the scaffold’s shared
|
|
46
|
+
`withLanguageDocument` hook. The cookbook root layout composes `host.load` with
|
|
47
|
+
`loadLanguageState`, retaining verified session/tenant authority, tracked locale
|
|
48
|
+
selection and the strict inherited language-settings contract. Both starter
|
|
49
|
+
layouts use the locale-only `LanguageLayout` context and pass the snapshot into
|
|
50
|
+
their AppShell; it adds no second app-state or WebMCP Provider. Mount these handlers:
|
|
47
51
|
|
|
48
52
|
| Route | Mount |
|
|
49
53
|
| --- | --- |
|
|
@@ -56,7 +60,10 @@ inference preferences/permissions before owner seeding. Export `host.handle` and
|
|
|
56
60
|
This composition supports the **local single-owner SQLite profile**. It refuses
|
|
57
61
|
other profiles at startup; it does not claim PostgreSQL, hosted credentials or
|
|
58
62
|
cross-process engine sessions. Ordinary app model migrations remain the runtime's
|
|
59
|
-
responsibility.
|
|
63
|
+
responsibility. The canonical fixed-graph activation bootstrap includes Languages
|
|
64
|
+
with the other always-on framework packages, so locale preferences, overrides
|
|
65
|
+
and mutation revisions exist before the first page. It retains `createSchema: false` and `prepareDatabase` → `ActivationCoordinator.boot()`; request handlers
|
|
66
|
+
never create those tables. Host system tables store versioned cookbook engine state, per-user
|
|
60
67
|
engine selection and audit. Cookbook CAS and its change audit commit in one
|
|
61
68
|
transaction before publishing an engine. Each authenticated request re-reads
|
|
62
69
|
persisted state and the existing tenant pre-built-components preference. An
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withLanguageDocument } from '#lib/server/i18n.js';
|
|
2
|
+
import { host } from '#lib/server/smrt.js';
|
|
2
3
|
|
|
3
|
-
export const {
|
|
4
|
+
export const { init } = host;
|
|
5
|
+
export const handle = withLanguageDocument(host.handle);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getPreferencePrincipal } from '@happyvertical/smrt-preferences';
|
|
2
2
|
import { loadCookbookApp } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
3
3
|
import { createCookbookPreferences } from '@happyvertical/smrt-template-sveltekit/host/preferences';
|
|
4
|
-
import { host, runtime } from '
|
|
4
|
+
import { host, runtime } from '#lib/server/smrt.js';
|
|
5
5
|
|
|
6
6
|
export type {
|
|
7
7
|
CookbookSaveResult,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { redirect } from '@sveltejs/kit';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { loadLanguageState } from '#lib/server/i18n.js';
|
|
3
|
+
import { loadCookbook } from '#lib/server/cookbook.js';
|
|
4
|
+
import { host } from '#lib/server/smrt.js';
|
|
4
5
|
import type { LayoutServerLoad } from './$types';
|
|
5
6
|
|
|
6
7
|
export const load: LayoutServerLoad = async (event) => {
|
|
@@ -13,6 +14,7 @@ export const load: LayoutServerLoad = async (event) => {
|
|
|
13
14
|
redirect(303, '/onboarding');
|
|
14
15
|
return {
|
|
15
16
|
...data,
|
|
17
|
+
...await loadLanguageState(event),
|
|
16
18
|
embed: event.url.searchParams.get('embed') === '1',
|
|
17
19
|
/** The project's cookbook and recipe catalog; `null` without a cookbook. */
|
|
18
20
|
cookbookApp: data.session.authenticated
|
|
@@ -5,6 +5,8 @@ import { signOut } from '@happyvertical/smrt-template-sveltekit/host/sveltekit-c
|
|
|
5
5
|
import type { Cookbook } from '@happyvertical/smrt-types';
|
|
6
6
|
import { invalidateAll } from '$app/navigation';
|
|
7
7
|
import { page } from '$app/state';
|
|
8
|
+
import LanguageLayout from '#lib/i18n/LanguageLayout.svelte';
|
|
9
|
+
import LanguageSwitcher from '#lib/i18n/LanguageSwitcher.svelte';
|
|
8
10
|
import type { LayoutProps } from './$types';
|
|
9
11
|
|
|
10
12
|
let { data, children }: LayoutProps = $props();
|
|
@@ -20,8 +22,10 @@ async function saveEdits(next: Cookbook) {
|
|
|
20
22
|
}
|
|
21
23
|
</script>
|
|
22
24
|
|
|
25
|
+
<LanguageLayout snapshot={data.i18n} direction={data.direction}>
|
|
23
26
|
{#if data.cookbookApp}
|
|
24
27
|
<CookbookApp
|
|
28
|
+
i18n={data.i18n}
|
|
25
29
|
cookbook={data.cookbookApp.cookbook}
|
|
26
30
|
catalog={data.cookbookApp.catalog}
|
|
27
31
|
href={(path: string) => path.replace(/(.)\/$/, '$1')}
|
|
@@ -42,6 +46,8 @@ async function saveEdits(next: Cookbook) {
|
|
|
42
46
|
oncookbookchange={data.session.authenticated ? saveEdits : undefined}
|
|
43
47
|
chrome={!page.route.id?.startsWith('/setup') && !page.route.id?.startsWith('/onboarding')}
|
|
44
48
|
>
|
|
49
|
+
<LanguageSwitcher snapshot={data.i18n} enabledLocales={data.languageConfiguration.enabledLocales} />
|
|
45
50
|
{@render children()}
|
|
46
51
|
</CookbookApp>
|
|
47
52
|
{/if}
|
|
53
|
+
</LanguageLayout>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error, redirect } from '@sveltejs/kit';
|
|
2
|
-
import { homePath } from '
|
|
2
|
+
import { homePath } from '#lib/server/cookbook.js';
|
|
3
3
|
import type { PageServerLoad } from './$types';
|
|
4
4
|
|
|
5
5
|
export const load: PageServerLoad = async ({ locals, parent }) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { host } from '
|
|
1
|
+
import { host } from '#lib/server/smrt.js';
|
|
2
2
|
export const GET = host.ownerLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { host } from '
|
|
1
|
+
import { host } from '#lib/server/smrt.js';
|
|
2
2
|
export const { GET, POST } = host.assistant;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { host } from '
|
|
1
|
+
import { host } from '#lib/server/smrt.js';
|
|
2
2
|
export const { GET, POST } = host.connectAi;
|
|
@@ -2,7 +2,7 @@ import { PreferenceAccessError } from '@happyvertical/smrt-preferences';
|
|
|
2
2
|
import { error, json } from '@sveltejs/kit';
|
|
3
3
|
|
|
4
4
|
import { hasCookbook } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
5
|
-
import { saveCookbookEdits } from '
|
|
5
|
+
import { saveCookbookEdits } from '#lib/server/cookbook.js';
|
|
6
6
|
import type { RequestHandler } from './$types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { host } from '
|
|
1
|
+
import { host } from '#lib/server/smrt.js';
|
|
2
2
|
export const POST = host.mcp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AssistantApprovalView } from '@happyvertical/smrt-chat/assistant-turn';
|
|
2
2
|
import { redirect } from '@sveltejs/kit';
|
|
3
|
-
import { host } from '
|
|
3
|
+
import { host } from '#lib/server/smrt.js';
|
|
4
4
|
import type { PageServerLoad } from './$types';
|
|
5
5
|
|
|
6
6
|
export const load: PageServerLoad = async (event) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInferenceSettingsPage } from '@happyvertical/smrt-template-sveltekit/host/settings';
|
|
2
|
-
import { host } from '
|
|
2
|
+
import { host } from '#lib/server/smrt.js';
|
|
3
3
|
export const { load, actions } = createInferenceSettingsPage(
|
|
4
4
|
host.inferenceSettings,
|
|
5
5
|
host.assistantSettings,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import adapter from '@sveltejs/adapter-node';
|
|
2
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
1
3
|
import { sveltekit } from '@sveltejs/kit/vite';
|
|
2
4
|
import { cookbookHostVite } from '@happyvertical/smrt-template-sveltekit/host/generate';
|
|
3
5
|
import { defineConfig, type UserConfig } from 'vite';
|
|
4
|
-
export default defineConfig(async (): Promise<UserConfig> => ({ plugins: [...await sveltekit(), ...await cookbookHostVite()] }));
|
|
6
|
+
export default defineConfig(async (): Promise<UserConfig> => ({ plugins: [...await sveltekit({ adapter: adapter(), preprocess: vitePreprocess() }), ...await cookbookHostVite()] }));
|
package/dist/host/server.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import { type AssistantSettings, type ChatGPTPlanConnection, createAgentCliServi
|
|
|
8
8
|
import { type CookbookAppData } from '@happyvertical/smrt-svelte/cookbook/server';
|
|
9
9
|
import type { OnboardingState } from '@happyvertical/smrt-svelte/onboarding';
|
|
10
10
|
import type { Cookbook } from '@happyvertical/smrt-types';
|
|
11
|
-
import type {
|
|
11
|
+
import type { RequestEvent, ServerLoad } from '@sveltejs/kit';
|
|
12
|
+
import type { Handle } from '@sveltejs/kit/hooks';
|
|
12
13
|
import { type PluginModeState } from './plugin-mode.js';
|
|
13
14
|
import { type WorkflowRunBudget } from './workflow-runs.js';
|
|
14
15
|
export interface CookbookHostOptions {
|
package/dist/host/server.js
CHANGED
|
@@ -19,7 +19,7 @@ import { resolveApiMethodExposure } from '@happyvertical/smrt-core/generators/cu
|
|
|
19
19
|
import { MCPGenerator, } from '@happyvertical/smrt-core/generators/mcp';
|
|
20
20
|
import { APIGenerator } from '@happyvertical/smrt-core/generators/rest';
|
|
21
21
|
import { createCookbookRuntimeExposure, filterRuntimeCookbookSnapshot, filterRuntimeExposure, isRuntimeModelEnabled, setRuntimeExposureGate, } from '@happyvertical/smrt-core/runtime-exposure';
|
|
22
|
-
import { createAgentCliService, createChatGPTPlanConnection, createInferenceSettingsController, createInferenceSettingsHost, engineTierModel, INFERENCE_PERMISSION_DEFINITIONS, inferencePreferenceKind, locateCli, nextEngineModel, resolveEngineEffort, tokenCredentials, } from '@happyvertical/smrt-inference/server';
|
|
22
|
+
import { createAgentCliService, createChatGPTPlanConnection, createInferenceHistoryMcpTools, createInferenceSettingsController, createInferenceSettingsHost, createInferenceTranscriptMcpTool, engineTierModel, INFERENCE_PERMISSION_DEFINITIONS, inferenceHistoryResponse, inferencePreferenceKind, inferenceTranscriptResponse, locateCli, nextEngineModel, resolveEngineEffort, tokenCredentials, } from '@happyvertical/smrt-inference/server';
|
|
23
23
|
import { TaskRunner } from '@happyvertical/smrt-jobs';
|
|
24
24
|
import { createAssistantSettingsPreference, createPrebuiltComponentsPreference, createPreferenceStore, getPreferencePrincipal, registerPreferenceKind, } from '@happyvertical/smrt-preferences';
|
|
25
25
|
import { mountConnectAiRoutes } from '@happyvertical/smrt-svelte/connect-ai/server';
|
|
@@ -30,6 +30,7 @@ import { PermissionResolver, RolePermissionCollection, registerPermissionDefinit
|
|
|
30
30
|
import { error, redirect } from '@sveltejs/kit';
|
|
31
31
|
import { createCookbookOnboarding } from './onboarding.js';
|
|
32
32
|
import { createPluginMode, PLUGIN_CLIENTS, PLUGIN_PERMISSION, } from './plugin-mode.js';
|
|
33
|
+
import { requireSettingsSession } from './settings.js';
|
|
33
34
|
import { createCookbookHostState } from './state.js';
|
|
34
35
|
import { COOKBOOK_CHANGE_WORKFLOW, createCookbookWorkflowRuns, isCookbookApplyStep, readInput as readWorkflowInput, WORKFLOW_RUN_BUDGET, } from './workflow-runs.js';
|
|
35
36
|
/**
|
|
@@ -119,7 +120,7 @@ export function createCookbookApplication(options) {
|
|
|
119
120
|
manifest: graph.manifest,
|
|
120
121
|
loaders: graph.loaders,
|
|
121
122
|
alwaysOn: graph.alwaysOn ??
|
|
122
|
-
Object.keys(graph.manifest.models).filter((id) => /^@happyvertical\/smrt-(users|profiles|tenancy|chat|approvals|preferences|inference|secrets|jobs):/.test(id)),
|
|
123
|
+
Object.keys(graph.manifest.models).filter((id) => /^@happyvertical\/smrt-(users|profiles|tenancy|chat|approvals|preferences|inference|secrets|jobs|languages):/.test(id)),
|
|
123
124
|
readEnabled: () => state.enabledModelUnion(async (tenantId) => (await (await createSqliteAppModelHistory({
|
|
124
125
|
db,
|
|
125
126
|
tenantId,
|
|
@@ -1647,6 +1648,16 @@ export function createCookbookHost(options) {
|
|
|
1647
1648
|
resolve: async (event, resolveOptions) => {
|
|
1648
1649
|
origin = event.url.origin;
|
|
1649
1650
|
const locals = event.locals;
|
|
1651
|
+
if (/^\/api\/inference\/(history|compare|transcripts)$/.test(event.url.pathname)) {
|
|
1652
|
+
const session = requireSettingsSession(locals);
|
|
1653
|
+
if (event.url.pathname.endsWith('/transcripts') &&
|
|
1654
|
+
event.request.method === 'GET') {
|
|
1655
|
+
if (!session.can('inference.customize'))
|
|
1656
|
+
return json({ error: 'Not allowed' }, 403);
|
|
1657
|
+
return inferenceTranscriptResponse(await runtime.database(), session, session.userId, event.request);
|
|
1658
|
+
}
|
|
1659
|
+
return inferenceHistoryResponse(inferenceSettings, session, event.request);
|
|
1660
|
+
}
|
|
1650
1661
|
if (locals.tenantId) {
|
|
1651
1662
|
await prepare(locals.tenantId);
|
|
1652
1663
|
const definition = publishedDefinitions
|
|
@@ -2354,6 +2365,11 @@ export function createCookbookHost(options) {
|
|
|
2354
2365
|
};
|
|
2355
2366
|
},
|
|
2356
2367
|
});
|
|
2368
|
+
if (!binding &&
|
|
2369
|
+
!pluginDelegated &&
|
|
2370
|
+
scope.has('inference.customize')) {
|
|
2371
|
+
workflows.push(...createInferenceHistoryMcpTools(inferenceSettings), createInferenceTranscriptMcpTool(() => runtime.database()));
|
|
2372
|
+
}
|
|
2357
2373
|
});
|
|
2358
2374
|
return mountMcpAppRoute({
|
|
2359
2375
|
runtime: { ...runtime, verifyLocalMcpToken: verifyPluginToken },
|
package/dist/host/settings.d.ts
CHANGED
|
@@ -37,3 +37,14 @@ export declare function createInferenceSettingsPage(controller: InferenceSetting
|
|
|
37
37
|
}>;
|
|
38
38
|
actions: Actions;
|
|
39
39
|
};
|
|
40
|
+
/** Both scaffold and cookbook host mount the same session-bound reads. */
|
|
41
|
+
export declare function createInferenceHistoryRoutes(controller: InferenceSettingsController, database: () => Promise<import('@happyvertical/sql').DatabaseInterface>): {
|
|
42
|
+
POST: (event: {
|
|
43
|
+
locals: unknown;
|
|
44
|
+
request: Request;
|
|
45
|
+
}) => Promise<Response>;
|
|
46
|
+
GET: (event: {
|
|
47
|
+
locals: unknown;
|
|
48
|
+
request: Request;
|
|
49
|
+
}) => Promise<Response>;
|
|
50
|
+
};
|
package/dist/host/settings.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** The existing template inference page, exposed as a controller-bound host mount. */
|
|
2
|
+
import { inferenceHistoryResponse, inferenceTranscriptResponse, } from '@happyvertical/smrt-inference/server';
|
|
2
3
|
import { error, fail } from '@sveltejs/kit';
|
|
3
4
|
export const requireSettingsSession = (input) => {
|
|
4
5
|
const locals = input;
|
|
@@ -131,3 +132,17 @@ export function createInferenceSettingsPage(controller, assistantSettings) {
|
|
|
131
132
|
};
|
|
132
133
|
return { load, actions };
|
|
133
134
|
}
|
|
135
|
+
/** Both scaffold and cookbook host mount the same session-bound reads. */
|
|
136
|
+
export function createInferenceHistoryRoutes(controller, database) {
|
|
137
|
+
return {
|
|
138
|
+
// biome-ignore lint/style/useNamingConvention: SvelteKit HTTP method name.
|
|
139
|
+
POST: (event) => inferenceHistoryResponse(controller, requireSettingsSession(event.locals), event.request),
|
|
140
|
+
// biome-ignore lint/style/useNamingConvention: SvelteKit HTTP method name.
|
|
141
|
+
GET: async (event) => {
|
|
142
|
+
const session = requireSettingsSession(event.locals);
|
|
143
|
+
if (!session.can('inference.customize'))
|
|
144
|
+
error(403, 'Not allowed');
|
|
145
|
+
return inferenceTranscriptResponse(await database(), session, session.userId, event.request);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assertOperationPermission } from '@happyvertical/smrt-users';
|
|
2
2
|
import { fail } from '@sveltejs/kit';
|
|
3
3
|
|
|
4
|
-
import type { Note } from '
|
|
5
|
-
import { runtime } from '
|
|
4
|
+
import type { Note } from '#lib/objects/Note.js';
|
|
5
|
+
import { runtime } from '#lib/server/smrt.js';
|
|
6
6
|
import type { Actions, PageServerLoad } from './$types';
|
|
7
7
|
|
|
8
8
|
const READ_PERMISSION = 'notes.read';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { enhance } from '$app/forms';
|
|
2
|
+
import { enhance, type SubmitFunction } from '$app/forms';
|
|
3
3
|
import { invalidate } from '$app/navigation';
|
|
4
4
|
import { Form, FormGroup, Input, Textarea } from '@happyvertical/smrt-ui/forms';
|
|
5
5
|
import { EmptyState } from '@happyvertical/smrt-ui/layout';
|
|
6
6
|
import { Button, Card } from '@happyvertical/smrt-ui/ui';
|
|
7
|
-
import type { SubmitFunction } from '@sveltejs/kit';
|
|
8
7
|
import { fromAction } from 'svelte/attachments';
|
|
9
8
|
import type { PageProps } from './$types';
|
|
10
9
|
|
|
@@ -70,6 +70,18 @@ async function discover(): Promise<void> {
|
|
|
70
70
|
aliases={data.aliases}
|
|
71
71
|
fusions={data.fusions}
|
|
72
72
|
usage={data.usage}
|
|
73
|
+
onHistory={data.canEdit ? async (request) => {
|
|
74
|
+
const response = await fetch('/api/inference/history', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(request) });
|
|
75
|
+
if (!response.ok) throw new Error('History unavailable');
|
|
76
|
+
return response.json();
|
|
77
|
+
} : undefined}
|
|
78
|
+
onCompare={data.canEdit ? async (request) => {
|
|
79
|
+
const response = await fetch('/api/inference/compare', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(request) });
|
|
80
|
+
if (!response.ok) throw new Error('Comparison unavailable');
|
|
81
|
+
return response.json();
|
|
82
|
+
} : undefined}
|
|
83
|
+
transcriptHref={(filters) => `/api/inference/transcripts?${new URLSearchParams(Object.entries(filters).filter((entry): entry is [string, string] => typeof entry[1] === 'string'))}`}
|
|
84
|
+
|
|
73
85
|
transcripts={data.transcripts}
|
|
74
86
|
appEditable={data.canEdit}
|
|
75
87
|
scope="app"
|
|
@@ -96,8 +108,7 @@ async function discover(): Promise<void> {
|
|
|
96
108
|
save('resetAssistant', { revision: data.assistant?.revision ?? null })}
|
|
97
109
|
onUsageGroupBy={(by) =>
|
|
98
110
|
goto(`${page.url.pathname}?by=${by.join(',')}`, {
|
|
99
|
-
|
|
100
|
-
noScroll: true,
|
|
111
|
+
reset: false,
|
|
101
112
|
replaceState: true,
|
|
102
113
|
})}
|
|
103
114
|
/>
|
package/index.js
CHANGED
|
@@ -22,10 +22,10 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
22
22
|
/**
|
|
23
23
|
* Paths inside `template/` that are not part of the scaffold output. These
|
|
24
24
|
* exist only to support test-time tooling at the monorepo level (e.g. the
|
|
25
|
-
*
|
|
25
|
+
* temporary `node_modules/$app/tsconfig.json` stub that lets the template's own
|
|
26
26
|
* tests typecheck without first running `svelte-kit sync`).
|
|
27
27
|
*/
|
|
28
|
-
const COPY_SKIP = new Set(['.svelte-kit', '__tests__', 'test', 'tests']);
|
|
28
|
+
const COPY_SKIP = new Set(['.svelte-kit', 'node_modules', '__tests__', 'test', 'tests']);
|
|
29
29
|
|
|
30
30
|
function pathEntryExists(path) {
|
|
31
31
|
try {
|
|
@@ -139,7 +139,7 @@ export const templateInfo = {
|
|
|
139
139
|
name: 'sveltekit',
|
|
140
140
|
description: 'Profile-aware installable SvelteKit project with s-m-r-t integration',
|
|
141
141
|
features: [
|
|
142
|
-
'SvelteKit
|
|
142
|
+
'SvelteKit 3.x with Svelte 5',
|
|
143
143
|
'Auto-generated REST API routes',
|
|
144
144
|
's-m-r-t CLI integration',
|
|
145
145
|
'TypeScript support',
|
package/mcp-apps-template/src/routes/.well-known/oauth-protected-resource/api/mcp/+server.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mountMcpProtectedResourceMetadataRoute } from '@happyvertical/smrt-app-mcp/sveltekit';
|
|
2
2
|
|
|
3
|
-
import { runtime } from '
|
|
3
|
+
import { runtime } from '#lib/server/smrt.js';
|
|
4
4
|
|
|
5
5
|
/** RFC 9728 metadata at exactly the URL hosted bearer challenges advertise (404 locally). */
|
|
6
6
|
export const GET = mountMcpProtectedResourceMetadataRoute({ runtime });
|
|
@@ -2,8 +2,8 @@ import type { McpWorkflowToolDefinition } from '@happyvertical/smrt-app-mcp';
|
|
|
2
2
|
import { mountMcpAppRoute } from '@happyvertical/smrt-app-mcp/sveltekit';
|
|
3
3
|
import { openAiDisplayMetadata, withOpenAiEntrypoints } from '@happyvertical/smrt-mcp-openai';
|
|
4
4
|
|
|
5
|
-
import { Note } from '
|
|
6
|
-
import { runtime } from '
|
|
5
|
+
import { Note } from '#lib/objects/Note.js';
|
|
6
|
+
import { runtime } from '#lib/server/smrt.js';
|
|
7
7
|
|
|
8
8
|
const NOTE_RESOURCE_URI = 'ui://smrt-app/v1/notes.html';
|
|
9
9
|
const noteResourceHtml = `<!doctype html><html lang="en"><head><title>Notes</title></head><body><main tabindex="-1"><h1>Notes</h1><p>Use the host controls to review your authorized notes.</p></main></body></html>`;
|