@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.
Files changed (80) hide show
  1. package/AGENTS.md +68 -51
  2. package/README.md +25 -10
  3. package/agents/cookbook-design-runs.md +164 -0
  4. package/agents/cookbook-host.md +724 -0
  5. package/agents/onboarding.md +116 -0
  6. package/agents/plugin-mode.md +152 -0
  7. package/cookbook-template/.pnpmfile.cjs +5 -0
  8. package/cookbook-template/src/hooks.server.ts +3 -0
  9. package/cookbook-template/src/lib/server/cookbook.ts +21 -0
  10. package/cookbook-template/src/lib/server/smrt.ts +11 -0
  11. package/cookbook-template/src/routes/+layout.server.ts +24 -0
  12. package/cookbook-template/src/routes/+layout.svelte +47 -0
  13. package/cookbook-template/src/routes/+page.server.ts +15 -0
  14. package/cookbook-template/src/routes/+page.svelte +12 -0
  15. package/cookbook-template/src/routes/api/_runtime/owner-link/+server.ts +2 -0
  16. package/cookbook-template/src/routes/api/assistant/[...path]/+server.ts +2 -0
  17. package/cookbook-template/src/routes/api/connect-ai/+server.ts +2 -0
  18. package/cookbook-template/src/routes/api/cookbook/prebuilt/+server.ts +3 -0
  19. package/cookbook-template/src/routes/api/cookbook/preferences/+server.ts +45 -0
  20. package/cookbook-template/src/routes/api/onboarding/+server.ts +3 -0
  21. package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.server.ts +1 -0
  22. package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.svelte +7 -0
  23. package/cookbook-template/src/routes/mcp/+server.ts +2 -0
  24. package/cookbook-template/src/routes/onboarding/+page.server.ts +13 -0
  25. package/cookbook-template/src/routes/onboarding/+page.svelte +28 -0
  26. package/cookbook-template/src/routes/s/[slug]/+page.server.ts +10 -0
  27. package/cookbook-template/src/routes/s/[slug]/+page.svelte +6 -0
  28. package/cookbook-template/src/routes/settings/+page.server.ts +22 -0
  29. package/cookbook-template/src/routes/settings/+page.svelte +49 -0
  30. package/cookbook-template/src/routes/settings/inference/+page.server.ts +6 -0
  31. package/cookbook-template/src/routes/settings/inference/+page.svelte +14 -0
  32. package/cookbook-template/vite.config.ts +4 -0
  33. package/dist/host/client.d.ts +8 -0
  34. package/dist/host/client.js +66 -0
  35. package/dist/host/design-runs.d.ts +72 -0
  36. package/dist/host/design-runs.js +763 -0
  37. package/dist/host/generate.d.ts +49 -0
  38. package/dist/host/generate.js +266 -0
  39. package/dist/host/onboarding.d.ts +26 -0
  40. package/dist/host/onboarding.js +247 -0
  41. package/dist/host/plugin-mode.d.ts +55 -0
  42. package/dist/host/plugin-mode.js +184 -0
  43. package/dist/host/preferences.d.ts +40 -0
  44. package/dist/host/preferences.js +163 -0
  45. package/dist/host/server.d.ts +283 -0
  46. package/dist/host/server.js +2400 -0
  47. package/dist/host/settings.d.ts +57 -0
  48. package/dist/host/settings.js +130 -0
  49. package/dist/host/state.d.ts +26 -0
  50. package/dist/host/state.js +149 -0
  51. package/dist/host/sveltekit-client.d.ts +22 -0
  52. package/dist/host/sveltekit-client.js +53 -0
  53. package/dist/smrt-knowledge.okf.md +105 -0
  54. package/examples/notes/src/routes/notes/+page.svelte +145 -0
  55. package/host/CookbookModelPage.svelte +78 -0
  56. package/host/InferenceSettingsPage.svelte +103 -0
  57. package/mcp-apps-template/package.dependencies.json +2 -2
  58. package/package.json +102 -24
  59. package/template/README.md +24 -11
  60. package/template/package.json +17 -12
  61. package/template/smrt.config.ts +4 -0
  62. package/template/src/hooks.server.ts +5 -0
  63. package/template/src/lib/objects/index.ts +7 -3
  64. package/template/src/lib/server/settings-registry.ts +29 -0
  65. package/template/src/lib/server/settings.ts +91 -0
  66. package/template/src/lib/server/smrt.ts +1 -0
  67. package/template/src/lib/settings-client.ts +1 -0
  68. package/template/src/lib/sign-out.ts +1 -19
  69. package/template/src/params/settingsSection.ts +4 -0
  70. package/template/src/routes/+layout.svelte +1 -2
  71. package/template/src/routes/+page.svelte +20 -128
  72. package/template/src/routes/settings/+page.svelte +16 -3
  73. package/template/src/routes/settings/[section=settingsSection]/+page.svelte +19 -0
  74. package/template/src/routes/settings/inference/+page.server.ts +3 -0
  75. package/template/src/routes/settings/inference/+page.svelte +6 -0
  76. package/template/src/routes/settings/prompts/+page.server.ts +50 -0
  77. package/template/src/routes/settings/prompts/+page.svelte +28 -0
  78. package/template.config.js +17 -12
  79. /package/{template → examples/notes}/src/lib/objects/Note.ts +0 -0
  80. /package/{template/src/routes → examples/notes/src/routes/notes}/+page.server.ts +0 -0
@@ -0,0 +1,57 @@
1
+ /** The existing template inference page, exposed as a controller-bound host mount. */
2
+ import type { InferenceSettingsController } from '@happyvertical/smrt-inference/server';
3
+ import type { Actions } from '@sveltejs/kit';
4
+ import type { createCookbookHost } from './server.js';
5
+ export interface SettingsSession {
6
+ tenantId: string;
7
+ userId: string;
8
+ can(permission: string): boolean;
9
+ }
10
+ export declare const requireSettingsSession: (input: unknown) => SettingsSession;
11
+ export declare function readPayload<T>(request: Request): Promise<T>;
12
+ export declare function createInferenceSettingsPage(controller: InferenceSettingsController, workProfiles?: ReturnType<typeof createCookbookHost>['workProfiles']): {
13
+ load: ({ locals, url, depends }: import("@sveltejs/kit").ServerLoadEvent<Record<string, string>, Record<string, any>, string | null>) => Promise<{
14
+ workProfiles?: {
15
+ resolved: {
16
+ unavailable: boolean;
17
+ name: import("@happyvertical/smrt-inference").WorkProfileName;
18
+ engine: import("@happyvertical/smrt-inference").InferenceEngineId;
19
+ model?: string;
20
+ effort: import("@happyvertical/smrt-inference").WorkReasoningEffort;
21
+ tier: "best" | "good" | "cheap";
22
+ budgets: import("@happyvertical/smrt-inference").WorkProfileBudgets;
23
+ autoEscalate: boolean;
24
+ previewBeforeApply: boolean;
25
+ modelSelection?: {
26
+ kind: "strongest" | "custom" | "configured" | "fallback";
27
+ requestedModel?: string;
28
+ resolvedModel?: string;
29
+ };
30
+ }[];
31
+ editable: boolean;
32
+ chatgptSignedIn: boolean;
33
+ settings: import("@happyvertical/smrt-preferences").WorkProfilePreferences;
34
+ revision: string | null;
35
+ issues: import("@happyvertical/smrt-preferences").PreferenceIssue[];
36
+ } | undefined;
37
+ tenantId: string;
38
+ canEdit: boolean;
39
+ canPersonalize: boolean;
40
+ defaults: {
41
+ keySet: boolean;
42
+ mode?: import("@happyvertical/smrt-inference/server").InferenceMode;
43
+ provider?: string;
44
+ baseUrl?: string;
45
+ model?: string;
46
+ defaultTier?: import("@happyvertical/smrt-core").InferenceTier;
47
+ };
48
+ providers: import("@happyvertical/smrt-inference/server").InferenceProviderOption[];
49
+ tiers: import("@happyvertical/smrt-inference/server").InferenceTierSettingsRow[];
50
+ defaultTier: import("@happyvertical/smrt-inference/server").InferenceDefaultTierSetting;
51
+ aliases: import("@happyvertical/smrt-inference/server").InferenceAliasSetting[];
52
+ fusions: import("@happyvertical/smrt-inference/server").InferenceFusionSetting[];
53
+ transcripts: import("@happyvertical/smrt-inference/server").InferenceTranscriptSettings;
54
+ usage: import("@happyvertical/smrt-core").AiUsageReport | null;
55
+ }>;
56
+ actions: Actions;
57
+ };
@@ -0,0 +1,130 @@
1
+ /** The existing template inference page, exposed as a controller-bound host mount. */
2
+ import { error, fail } from '@sveltejs/kit';
3
+ export const requireSettingsSession = (input) => {
4
+ const locals = input;
5
+ if (!locals.user?.id || !locals.tenantId)
6
+ error(401, 'Sign in required');
7
+ const permissions = new Set(locals.permissions ?? []);
8
+ return {
9
+ tenantId: locals.tenantId,
10
+ userId: locals.user.id,
11
+ can: (permission) => permissions.has(permission),
12
+ };
13
+ };
14
+ export async function readPayload(request) {
15
+ const raw = (await request.formData()).get('payload');
16
+ if (typeof raw !== 'string')
17
+ error(400, 'Missing payload');
18
+ try {
19
+ return JSON.parse(raw);
20
+ }
21
+ catch {
22
+ error(400, 'Invalid payload');
23
+ }
24
+ }
25
+ export function createInferenceSettingsPage(controller, workProfiles) {
26
+ const inferenceSettingsController = () => controller;
27
+ /** An outcome from the controller as the page's action result. */
28
+ function result(outcome) {
29
+ if (outcome.ok)
30
+ return outcome;
31
+ return fail(outcome.status, { error: outcome.error });
32
+ }
33
+ const load = (async ({ locals, url, depends }) => {
34
+ depends('smrt:inference-settings');
35
+ const session = requireSettingsSession(locals);
36
+ // No key is ever sent to the browser, only whether one is stored.
37
+ return {
38
+ ...(await inferenceSettingsController().load(session, url.searchParams.get('by'))),
39
+ ...(workProfiles
40
+ ? {
41
+ workProfiles: await workProfiles.read({ locals, url }),
42
+ }
43
+ : {}),
44
+ };
45
+ });
46
+ const actions = {
47
+ saveWorkProfiles: async (event) => {
48
+ if (!workProfiles)
49
+ error(404, 'Unavailable');
50
+ const payload = await readPayload(event.request);
51
+ const outcome = await workProfiles.write(event, payload);
52
+ return outcome.ok
53
+ ? outcome
54
+ : fail(outcome.reason === 'conflict' ? 409 : 400, {
55
+ error: 'The change was refused.',
56
+ });
57
+ },
58
+ resetWorkProfiles: async (event) => {
59
+ if (!workProfiles)
60
+ error(404, 'Unavailable');
61
+ const payload = await readPayload(event.request);
62
+ const outcome = await workProfiles.reset(event, payload.revision);
63
+ return outcome.ok
64
+ ? outcome
65
+ : fail(outcome.reason === 'conflict' ? 409 : 400, {
66
+ error: 'The change was refused.',
67
+ });
68
+ },
69
+ saveDefaults: async ({ request, locals }) => {
70
+ const session = requireSettingsSession(locals);
71
+ const change = await readPayload(request);
72
+ return result(await inferenceSettingsController().saveDefaults(session, change));
73
+ },
74
+ // Owner only: refused before the body is read; the key is stored through
75
+ // the user resolver (as the `inference.provider-config` secret) and never
76
+ // comes back to the browser.
77
+ saveKey: async ({ request, locals }) => {
78
+ const session = requireSettingsSession(locals);
79
+ const controller = inferenceSettingsController();
80
+ if (!controller.canCustomize(session)) {
81
+ return fail(403, {
82
+ error: 'You are not allowed to change this setting.',
83
+ });
84
+ }
85
+ const change = await readPayload(request);
86
+ return result(await controller.saveKey(session, change));
87
+ },
88
+ saveTier: async ({ request, locals }) => {
89
+ const session = requireSettingsSession(locals);
90
+ const change = await readPayload(request);
91
+ return result(await inferenceSettingsController().saveTier(session, change));
92
+ },
93
+ saveDefaultTier: async ({ request, locals }) => {
94
+ const session = requireSettingsSession(locals);
95
+ const change = await readPayload(request);
96
+ return result(await inferenceSettingsController().saveDefaultTier(session, change));
97
+ },
98
+ saveAlias: async ({ request, locals }) => {
99
+ const session = requireSettingsSession(locals);
100
+ const change = await readPayload(request);
101
+ return result(await inferenceSettingsController().saveAlias(session, change));
102
+ },
103
+ saveFusion: async ({ request, locals }) => {
104
+ const session = requireSettingsSession(locals);
105
+ const change = await readPayload(request);
106
+ return result(await inferenceSettingsController().saveFusion(session, change));
107
+ },
108
+ saveTranscripts: async ({ request, locals }) => {
109
+ const session = requireSettingsSession(locals);
110
+ const change = await readPayload(request);
111
+ return result(await inferenceSettingsController().saveTranscripts(session, change));
112
+ },
113
+ // Probes return a key-free result; they write nothing.
114
+ testConnection: async ({ request, locals }) => {
115
+ const session = requireSettingsSession(locals);
116
+ const input = await readPayload(request);
117
+ return result(await inferenceSettingsController().testConnection(session, input));
118
+ },
119
+ testCandidate: async ({ request, locals }) => {
120
+ const session = requireSettingsSession(locals);
121
+ const candidate = await readPayload(request);
122
+ return result(await inferenceSettingsController().testCandidate(session, candidate));
123
+ },
124
+ discoverModels: async ({ locals }) => {
125
+ const session = requireSettingsSession(locals);
126
+ return inferenceSettingsController().discoverModels(session);
127
+ },
128
+ };
129
+ return { load, actions };
130
+ }
@@ -0,0 +1,26 @@
1
+ import { type CookbookEngine } from '@happyvertical/smrt-core/cookbook/engine';
2
+ import type { CookbookToolOptions } from '@happyvertical/smrt-core/cookbook/tools';
3
+ import type { InferenceEngineId } from '@happyvertical/smrt-inference/server';
4
+ import type { Cookbook } from '@happyvertical/smrt-types';
5
+ import type { DatabaseInterface } from '@happyvertical/sql';
6
+ /** Host system schema only; application models still require ordinary migrations. */
7
+ export declare function createCookbookHostState(db: DatabaseInterface, catalog: CookbookToolOptions['catalog'], cookbook: Cookbook): Promise<{
8
+ refresh: (tenantId: string) => Promise<void>;
9
+ enabledModelUnion(historyFor?: (tenantId: string) => Promise<Cookbook | undefined>): Promise<string[]>;
10
+ publishModels(tenantId: string, document: Cookbook, revision: number): Promise<void>;
11
+ engineFor: ({ tenantId }: {
12
+ tenantId?: string | null;
13
+ }) => CookbookEngine | undefined;
14
+ commit(change: Parameters<CookbookToolOptions["commit"]>[0]): Promise<void>;
15
+ audit(event: Parameters<CookbookToolOptions["audit"]>[0]): Promise<void>;
16
+ /** Persistent fallback memo; identity and connection generation are host-bound. */
17
+ fallbackStore(tenantId: string): {
18
+ read(ownerId: string, engine: string, requested: string, connection: string): Promise<any>;
19
+ write(ownerId: string, engine: string, requested: string, connection: string, model: string): Promise<void>;
20
+ };
21
+ engineGeneration(tenantId: string, userId: string): Promise<any>;
22
+ engine(tenantId: string, userId: string): Promise<InferenceEngineId | null>;
23
+ select(tenantId: string, userId: string, engine: InferenceEngineId): Promise<void>;
24
+ embed(tenantId: string, userId: string): Promise<boolean>;
25
+ setEmbed(tenantId: string, userId: string, embed: boolean): Promise<void>;
26
+ }>;
@@ -0,0 +1,149 @@
1
+ /** Local host persistence. Cookbook publication and its audit share one SQLite transaction. */
2
+ import { randomUUID } from 'node:crypto';
3
+ import { coveredModels, createCookbookEngine, } from '@happyvertical/smrt-core/cookbook/engine';
4
+ import { notifyRuntimeExposureChanged } from '@happyvertical/smrt-core/runtime-exposure';
5
+ const TABLE = '_smrt_cookbook_host';
6
+ const AUDIT = '_smrt_cookbook_host_audit';
7
+ /** Host system schema only; application models still require ordinary migrations. */
8
+ export async function createCookbookHostState(db, catalog, cookbook) {
9
+ await db.query(`CREATE TABLE IF NOT EXISTS ${TABLE} (tenant_id TEXT NOT NULL, user_id TEXT NOT NULL, state TEXT NOT NULL, PRIMARY KEY (tenant_id, user_id))`);
10
+ await db.query(`CREATE TABLE IF NOT EXISTS ${AUDIT} (id INTEGER PRIMARY KEY AUTOINCREMENT, tenant_id TEXT NOT NULL, event TEXT NOT NULL)`);
11
+ const engines = new Map();
12
+ const initial = createCookbookEngine({ catalog, cookbook }).state();
13
+ const audit = async (event, tenantId, executor = db) => {
14
+ await executor.query(`INSERT INTO ${AUDIT} (tenant_id, event) VALUES (?, ?)`, tenantId, JSON.stringify(event));
15
+ };
16
+ async function refresh(tenantId) {
17
+ try {
18
+ await db.query(`INSERT INTO ${TABLE} (tenant_id, user_id, state) VALUES (?, '', ?) ON CONFLICT DO NOTHING`, tenantId, JSON.stringify(initial));
19
+ const row = (await db.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ''`, tenantId)).rows[0];
20
+ if (!row)
21
+ throw new Error('Cookbook state unavailable');
22
+ const saved = JSON.parse(String(row.state));
23
+ if (JSON.stringify(engines.get(tenantId)?.state()) !== JSON.stringify(saved)) {
24
+ engines.set(tenantId, createCookbookEngine({ catalog, state: saved }));
25
+ notifyRuntimeExposureChanged();
26
+ }
27
+ }
28
+ catch (error) {
29
+ engines.delete(tenantId);
30
+ notifyRuntimeExposureChanged();
31
+ throw error;
32
+ }
33
+ }
34
+ return {
35
+ refresh,
36
+ async enabledModelUnion(historyFor) {
37
+ const rows = (await db.query(`SELECT tenant_id, state FROM ${TABLE} WHERE user_id = ''`)).rows;
38
+ const documents = rows.length
39
+ ? await Promise.all(rows.map(async (r) => (await historyFor?.(String(r.tenant_id))) ??
40
+ JSON.parse(String(r.state)).cookbook))
41
+ : [cookbook];
42
+ return [
43
+ ...new Set(documents.flatMap((doc) => {
44
+ const custom = new Set(Object.keys(doc.models?.lists ?? {}).map((name) => `${doc.models.packageName}:${name}`));
45
+ return [...coveredModels(catalog, doc)].filter((id) => !custom.has(id));
46
+ })),
47
+ ];
48
+ },
49
+ async publishModels(tenantId, document, revision) {
50
+ const before = engines.get(tenantId)?.state();
51
+ if (!before)
52
+ throw new Error('Cookbook unavailable');
53
+ const changed = JSON.stringify(before.cookbook) !== JSON.stringify(document);
54
+ const nextRevision = Math.max(before.revision + (changed ? 1 : 0), revision);
55
+ if (!changed && before.revision === nextRevision)
56
+ return;
57
+ const after = createCookbookEngine({
58
+ catalog,
59
+ cookbook: document,
60
+ }).state();
61
+ after.revision = nextRevision;
62
+ await this.commit({
63
+ context: { surface: 'assistant', tenantId },
64
+ before,
65
+ after,
66
+ audit: {
67
+ context: { surface: 'assistant', tenantId },
68
+ tool: 'cookbook.apply',
69
+ outcome: 'changed',
70
+ summary: 'Published app model definitions.',
71
+ },
72
+ });
73
+ },
74
+ engineFor: ({ tenantId }) => tenantId ? engines.get(tenantId) : undefined,
75
+ async commit(change) {
76
+ const tenantId = change.context.tenantId;
77
+ if (!tenantId || !db.transaction)
78
+ throw new Error('Local cookbook needs a tenant and SQLite transactions');
79
+ await db.transaction(async (tx) => {
80
+ const row = (await tx.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ''`, tenantId)).rows[0];
81
+ // Hydration can add required recipe dependencies from the current catalog.
82
+ // Compare logical snapshots, then CAS against the exact bytes observed.
83
+ const raw = row && String(row.state);
84
+ if (!raw ||
85
+ JSON.stringify(createCookbookEngine({
86
+ catalog,
87
+ state: JSON.parse(raw),
88
+ }).state()) !== JSON.stringify(change.before))
89
+ throw new Error('Cookbook changed; refresh and try again');
90
+ const changed = await tx.query(`UPDATE ${TABLE} SET state = ? WHERE tenant_id = ? AND user_id = '' AND state = ? RETURNING tenant_id`, JSON.stringify(change.after), tenantId, raw);
91
+ if (changed.rows.length !== 1)
92
+ throw new Error('Cookbook changed; refresh and try again');
93
+ await audit(change.audit, tenantId, tx);
94
+ });
95
+ await refresh(tenantId);
96
+ },
97
+ async audit(event) {
98
+ if (event.context.tenantId)
99
+ await audit(event, event.context.tenantId);
100
+ },
101
+ /** Persistent fallback memo; identity and connection generation are host-bound. */
102
+ fallbackStore(tenantId) {
103
+ const key = (ownerId, engine, requested, connection) => `work-model:${JSON.stringify([ownerId, engine, requested, connection])}`;
104
+ return {
105
+ async read(ownerId, engine, requested, connection) {
106
+ const row = (await db.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ?`, tenantId, key(ownerId, engine, requested, connection))).rows[0];
107
+ if (!row)
108
+ return undefined;
109
+ const saved = JSON.parse(String(row.state));
110
+ return typeof saved.model === 'string' ? saved.model : undefined;
111
+ },
112
+ async write(ownerId, engine, requested, connection, model) {
113
+ await db.query(`INSERT INTO ${TABLE} (tenant_id, user_id, state) VALUES (?, ?, ?) ON CONFLICT(tenant_id,user_id) DO UPDATE SET state = excluded.state`, tenantId, key(ownerId, engine, requested, connection), JSON.stringify({ model }));
114
+ },
115
+ };
116
+ },
117
+ async engineGeneration(tenantId, userId) {
118
+ const row = (await db.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ?`, tenantId, userId)).rows[0];
119
+ return row
120
+ ? (JSON.parse(String(row.state)).generation ?? 'initial')
121
+ : 'initial';
122
+ },
123
+ async engine(tenantId, userId) {
124
+ const row = (await db.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ?`, tenantId, userId)).rows[0];
125
+ if (!row)
126
+ return null;
127
+ const saved = JSON.parse(String(row.state));
128
+ if (saved.engine === undefined)
129
+ return null;
130
+ if (!['api', 'chatgpt', 'claude-code', 'codex'].includes(saved.engine))
131
+ throw new Error('Invalid saved engine');
132
+ return saved.engine;
133
+ },
134
+ async select(tenantId, userId, engine) {
135
+ if (!userId ||
136
+ !['api', 'chatgpt', 'claude-code', 'codex'].includes(engine))
137
+ throw new Error('Invalid engine');
138
+ await db.query(`INSERT INTO ${TABLE} (tenant_id, user_id, state) VALUES (?, ?, ?) ON CONFLICT(tenant_id, user_id) DO UPDATE SET state = json_set(${TABLE}.state, '$.engine', json_extract(excluded.state, '$.engine'))`, tenantId, userId, JSON.stringify({ engine, generation: randomUUID() }));
139
+ },
140
+ async embed(tenantId, userId) {
141
+ const row = (await db.query(`SELECT state FROM ${TABLE} WHERE tenant_id = ? AND user_id = ?`, tenantId, userId)).rows[0];
142
+ const value = row ? JSON.parse(String(row.state)).embed : false;
143
+ return value === true || value === 1;
144
+ },
145
+ async setEmbed(tenantId, userId, embed) {
146
+ await db.query(`INSERT INTO ${TABLE} (tenant_id, user_id, state) VALUES (?, ?, ?) ON CONFLICT(tenant_id, user_id) DO UPDATE SET state = json_set(${TABLE}.state, '$.embed', json_extract(excluded.state, '$.embed'))`, tenantId, userId, JSON.stringify({ embed }));
147
+ },
148
+ };
149
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Sign out through the runtime's same-origin `POST /sign-out` route, then
3
+ * refresh the session-derived layout data and return home. A failed request
4
+ * (403, 5xx) throws instead of pretending the session ended: the user stays
5
+ * signed in and the error names the status.
6
+ */
7
+ export declare function signOut(): Promise<void>;
8
+ export interface SettingOutcome {
9
+ ok: boolean;
10
+ /** The action's success data (probe results, discovery). */
11
+ data?: Record<string, unknown>;
12
+ /** A message safe to show: server failures name no key or secret. */
13
+ error?: string;
14
+ }
15
+ /**
16
+ * Post a settings change to the current page's form action as JSON in a
17
+ * `payload` field and report the outcome. A saved change reloads the page
18
+ * data, so the panel shows what the server stored.
19
+ */
20
+ export declare function postSetting(action: string, payload: unknown, options?: {
21
+ reload?: boolean;
22
+ }): Promise<SettingOutcome>;
@@ -0,0 +1,53 @@
1
+ import { goto, invalidateAll } from '$app/navigation';
2
+ /**
3
+ * Sign out through the runtime's same-origin `POST /sign-out` route, then
4
+ * refresh the session-derived layout data and return home. A failed request
5
+ * (403, 5xx) throws instead of pretending the session ended: the user stays
6
+ * signed in and the error names the status.
7
+ */
8
+ export async function signOut() {
9
+ const response = await fetch('/sign-out', {
10
+ method: 'POST',
11
+ credentials: 'same-origin',
12
+ });
13
+ if (!response.ok) {
14
+ throw new Error(`Sign-out failed with status ${response.status}`);
15
+ }
16
+ await invalidateAll();
17
+ await goto('/');
18
+ }
19
+ import { deserialize } from '$app/forms';
20
+ /**
21
+ * Post a settings change to the current page's form action as JSON in a
22
+ * `payload` field and report the outcome. A saved change reloads the page
23
+ * data, so the panel shows what the server stored.
24
+ */
25
+ export async function postSetting(action, payload, options = {}) {
26
+ const body = new FormData();
27
+ body.set('payload', JSON.stringify(payload));
28
+ const response = await fetch(`?/${action}`, {
29
+ method: 'POST',
30
+ body,
31
+ headers: { 'x-sveltekit-action': 'true' },
32
+ });
33
+ const result = deserialize(await response.text());
34
+ if (result.type === 'success') {
35
+ if (options.reload !== false)
36
+ await invalidateAll();
37
+ return { ok: true, data: result.data };
38
+ }
39
+ if (result.type === 'failure') {
40
+ return {
41
+ ok: false,
42
+ error: String(result.data?.error ??
43
+ 'The change was refused.'),
44
+ };
45
+ }
46
+ return {
47
+ ok: false,
48
+ error: result.type === 'error'
49
+ ? result.error?.message ||
50
+ 'The change failed.'
51
+ : 'The change failed.',
52
+ };
53
+ }
@@ -0,0 +1,105 @@
1
+ ---
2
+ type: "Component"
3
+ title: "@happyvertical/smrt-template-sveltekit"
4
+ description: "Minimal SvelteKit project template with s-m-r-t framework integration"
5
+ status: "stable"
6
+ generated:
7
+ by: "smrt/scripts/generate-knowledge-okf.ts"
8
+ at: "2026-11-13T18:39:16Z"
9
+ audience: "internal"
10
+ evidence_level: "source-inspected"
11
+ source_revision: "sha256:88fb150d9a1cce3485fec1af3e5c4c5f3c90b9efbe845151f9badefa1be3c73e"
12
+ sources:
13
+ - id: "manifest"
14
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/template-sveltekit/package.json"
15
+ title: "@happyvertical/smrt-template-sveltekit package manifest"
16
+ - id: "agents"
17
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/template-sveltekit/AGENTS.md"
18
+ title: "@happyvertical/smrt-template-sveltekit packages/template-sveltekit/AGENTS.md"
19
+ - id: "agents-2"
20
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/template-sveltekit/agents/cookbook-host.md"
21
+ title: "@happyvertical/smrt-template-sveltekit packages/template-sveltekit/agents/cookbook-host.md"
22
+ ---
23
+
24
+ # @happyvertical/smrt-template-sveltekit
25
+
26
+ ## Package
27
+
28
+ - Directory: `packages/template-sveltekit`
29
+ - Private: no
30
+ - Object source: `scanner`
31
+ - Evidence level: `source-inspected`
32
+
33
+ ## Documentation
34
+
35
+ - `packages/template-sveltekit/AGENTS.md`
36
+ - `packages/template-sveltekit/agents/cookbook-host.md`
37
+
38
+ ## Framework dependencies
39
+
40
+ - [smrt-agents](/components/smrt-agents.md)
41
+ - [smrt-app-cli](/components/smrt-app-cli.md)
42
+ - [smrt-app-mcp](/components/smrt-app-mcp.md)
43
+ - [smrt-app-runtime](/components/smrt-app-runtime.md)
44
+ - [smrt-assets](/components/smrt-assets.md)
45
+ - [smrt-chat](/components/smrt-chat.md)
46
+ - [smrt-cli](/components/smrt-cli.md)
47
+ - [smrt-commerce](/components/smrt-commerce.md)
48
+ - [smrt-config](/components/smrt-config.md)
49
+ - [smrt-core](/components/smrt-core.md)
50
+ - [smrt-desktop](/components/smrt-desktop.md)
51
+ - [smrt-events](/components/smrt-events.md)
52
+ - [smrt-inference](/components/smrt-inference.md)
53
+ - [smrt-inventory](/components/smrt-inventory.md)
54
+ - [smrt-jobs](/components/smrt-jobs.md)
55
+ - [smrt-mcp-openai](/components/smrt-mcp-openai.md)
56
+ - [smrt-playbooks](/components/smrt-playbooks.md)
57
+ - [smrt-preferences](/components/smrt-preferences.md)
58
+ - [smrt-profiles](/components/smrt-profiles.md)
59
+ - [smrt-prompts](/components/smrt-prompts.md)
60
+ - [smrt-reports](/components/smrt-reports.md)
61
+ - [smrt-scanner](/components/smrt-scanner.md)
62
+ - [smrt-secrets](/components/smrt-secrets.md)
63
+ - [smrt-svelte](/components/smrt-svelte.md)
64
+ - [smrt-tenancy](/components/smrt-tenancy.md)
65
+ - [smrt-types](/components/smrt-types.md)
66
+ - [smrt-ui](/components/smrt-ui.md)
67
+ - [smrt-users](/components/smrt-users.md)
68
+ - [smrt-web](/components/smrt-web.md)
69
+
70
+ ## SDK dependencies
71
+
72
+ - `@happyvertical/sql`
73
+
74
+ ## Exports
75
+
76
+ - `.`
77
+ - `./host/CookbookModelPage.svelte`
78
+ - `./host/InferenceSettingsPage.svelte`
79
+ - `./host/client`
80
+ - `./host/generate`
81
+ - `./host/plugin-mode`
82
+ - `./host/preferences`
83
+ - `./host/server`
84
+ - `./host/settings`
85
+ - `./host/sveltekit-client`
86
+ - `./template.config.js`
87
+ - `./template/*`
88
+
89
+ ## Models
90
+
91
+ - `Note` (collection `notes`, extends `SmrtObject`)
92
+ - `ReferenceWorkItem` (collection `referenceworkitems`, extends `SmrtObject`)
93
+ - `ReferenceWorkItemAsset` (collection `referenceworkitemassets`, extends `SmrtObject`)
94
+
95
+ ## MCP tools
96
+
97
+ - `archive_referenceworkitems`: archive on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
98
+ - `create_referenceworkitems`: create on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
99
+ - `delete_referenceworkitems`: delete on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
100
+ - `get_notes`: get on `@happyvertical/smrt-template-sveltekit:Note`
101
+ - `get_referenceworkitems`: get on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
102
+ - `list_notes`: list on `@happyvertical/smrt-template-sveltekit:Note`
103
+ - `list_referenceworkitems`: list on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
104
+ - `prepareForReview_referenceworkitems`: prepareForReview on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`
105
+ - `update_referenceworkitems`: update on `@happyvertical/smrt-template-sveltekit:ReferenceWorkItem`