@happyvertical/smrt-template-sveltekit 0.60.18 → 0.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +68 -51
- package/README.md +25 -10
- package/agents/cookbook-design-runs.md +164 -0
- package/agents/cookbook-host.md +724 -0
- package/agents/onboarding.md +116 -0
- package/agents/plugin-mode.md +152 -0
- package/cookbook-template/.pnpmfile.cjs +5 -0
- package/cookbook-template/src/hooks.server.ts +3 -0
- package/cookbook-template/src/lib/server/cookbook.ts +21 -0
- package/cookbook-template/src/lib/server/smrt.ts +11 -0
- package/cookbook-template/src/routes/+layout.server.ts +24 -0
- package/cookbook-template/src/routes/+layout.svelte +47 -0
- package/cookbook-template/src/routes/+page.server.ts +15 -0
- package/cookbook-template/src/routes/+page.svelte +12 -0
- package/cookbook-template/src/routes/api/_runtime/owner-link/+server.ts +2 -0
- package/cookbook-template/src/routes/api/assistant/[...path]/+server.ts +2 -0
- package/cookbook-template/src/routes/api/connect-ai/+server.ts +2 -0
- package/cookbook-template/src/routes/api/cookbook/prebuilt/+server.ts +3 -0
- package/cookbook-template/src/routes/api/cookbook/preferences/+server.ts +45 -0
- package/cookbook-template/src/routes/api/onboarding/+server.ts +3 -0
- package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.server.ts +1 -0
- package/cookbook-template/src/routes/m/[pkg]/[model]/[[key]]/+page.svelte +7 -0
- package/cookbook-template/src/routes/mcp/+server.ts +2 -0
- package/cookbook-template/src/routes/onboarding/+page.server.ts +13 -0
- package/cookbook-template/src/routes/onboarding/+page.svelte +28 -0
- package/cookbook-template/src/routes/s/[slug]/+page.server.ts +10 -0
- package/cookbook-template/src/routes/s/[slug]/+page.svelte +6 -0
- package/cookbook-template/src/routes/settings/+page.server.ts +22 -0
- package/cookbook-template/src/routes/settings/+page.svelte +49 -0
- package/cookbook-template/src/routes/settings/inference/+page.server.ts +6 -0
- package/cookbook-template/src/routes/settings/inference/+page.svelte +14 -0
- package/cookbook-template/vite.config.ts +4 -0
- package/dist/host/client.d.ts +8 -0
- package/dist/host/client.js +66 -0
- package/dist/host/design-runs.d.ts +72 -0
- package/dist/host/design-runs.js +763 -0
- package/dist/host/generate.d.ts +49 -0
- package/dist/host/generate.js +266 -0
- package/dist/host/onboarding.d.ts +26 -0
- package/dist/host/onboarding.js +247 -0
- package/dist/host/plugin-mode.d.ts +55 -0
- package/dist/host/plugin-mode.js +184 -0
- package/dist/host/preferences.d.ts +40 -0
- package/dist/host/preferences.js +163 -0
- package/dist/host/server.d.ts +283 -0
- package/dist/host/server.js +2400 -0
- package/dist/host/settings.d.ts +57 -0
- package/dist/host/settings.js +130 -0
- package/dist/host/state.d.ts +26 -0
- package/dist/host/state.js +149 -0
- package/dist/host/sveltekit-client.d.ts +22 -0
- package/dist/host/sveltekit-client.js +53 -0
- package/dist/smrt-knowledge.okf.md +105 -0
- package/examples/notes/src/routes/notes/+page.svelte +145 -0
- package/host/CookbookModelPage.svelte +78 -0
- package/host/InferenceSettingsPage.svelte +103 -0
- package/mcp-apps-template/package.dependencies.json +2 -2
- package/package.json +102 -24
- package/template/README.md +24 -11
- package/template/package.json +17 -12
- package/template/smrt.config.ts +4 -0
- package/template/src/hooks.server.ts +5 -0
- package/template/src/lib/objects/index.ts +7 -3
- package/template/src/lib/server/settings-registry.ts +29 -0
- package/template/src/lib/server/settings.ts +91 -0
- package/template/src/lib/server/smrt.ts +1 -0
- package/template/src/lib/settings-client.ts +1 -0
- package/template/src/lib/sign-out.ts +1 -19
- package/template/src/params/settingsSection.ts +4 -0
- package/template/src/routes/+layout.svelte +1 -2
- package/template/src/routes/+page.svelte +20 -128
- package/template/src/routes/settings/+page.svelte +16 -3
- package/template/src/routes/settings/[section=settingsSection]/+page.svelte +19 -0
- package/template/src/routes/settings/inference/+page.server.ts +3 -0
- package/template/src/routes/settings/inference/+page.svelte +6 -0
- package/template/src/routes/settings/prompts/+page.server.ts +50 -0
- package/template/src/routes/settings/prompts/+page.svelte +28 -0
- package/template.config.js +17 -12
- /package/{template → examples/notes}/src/lib/objects/Note.ts +0 -0
- /package/{template/src/routes → examples/notes/src/routes/notes}/+page.server.ts +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { enhance } from '$app/forms';
|
|
3
|
+
import { invalidate } from '$app/navigation';
|
|
4
|
+
import { Form, FormGroup, Input, Textarea } from '@happyvertical/smrt-ui/forms';
|
|
5
|
+
import { EmptyState } from '@happyvertical/smrt-ui/layout';
|
|
6
|
+
import { Button, Card } from '@happyvertical/smrt-ui/ui';
|
|
7
|
+
import type { SubmitFunction } from '@sveltejs/kit';
|
|
8
|
+
import { fromAction } from 'svelte/attachments';
|
|
9
|
+
import type { PageProps } from './$types';
|
|
10
|
+
|
|
11
|
+
let { data, form }: PageProps = $props();
|
|
12
|
+
let creating = $state(false);
|
|
13
|
+
let title = $state('');
|
|
14
|
+
let body = $state('');
|
|
15
|
+
let composing = $state(false);
|
|
16
|
+
|
|
17
|
+
// The form shows once the owner has notes, or after "Start your first note".
|
|
18
|
+
const showForm = $derived(
|
|
19
|
+
data.canCreate && (data.notes.length > 0 || composing),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Match `enhance`'s generics: a SubmitFunction with SvelteKit's default
|
|
23
|
+
// `Record<string, any>` params is not assignable to the action's argument.
|
|
24
|
+
const submit: SubmitFunction<
|
|
25
|
+
Record<string, unknown> | undefined,
|
|
26
|
+
Record<string, unknown> | undefined
|
|
27
|
+
> = () => {
|
|
28
|
+
creating = true;
|
|
29
|
+
return async ({ result, update }) => {
|
|
30
|
+
try {
|
|
31
|
+
await update({ invalidateAll: false, reset: false });
|
|
32
|
+
if (result.type === 'success') {
|
|
33
|
+
title = '';
|
|
34
|
+
body = '';
|
|
35
|
+
await invalidate('smrt:notes');
|
|
36
|
+
}
|
|
37
|
+
} finally {
|
|
38
|
+
creating = false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<svelte:head>
|
|
45
|
+
<title>Notes</title>
|
|
46
|
+
</svelte:head>
|
|
47
|
+
|
|
48
|
+
<main class="smrt-notes-page__root">
|
|
49
|
+
<h1>Notes</h1>
|
|
50
|
+
|
|
51
|
+
{#if data.loadError}
|
|
52
|
+
<Card>
|
|
53
|
+
<p role="alert">{data.loadError}</p>
|
|
54
|
+
<p>Run <code>pnpm db:migrate</code> after changing object fields.</p>
|
|
55
|
+
</Card>
|
|
56
|
+
{:else if data.accessMessage}
|
|
57
|
+
<Card>
|
|
58
|
+
<p>{data.accessMessage}</p>
|
|
59
|
+
{#if !data.authenticated}
|
|
60
|
+
<Button href="/setup">Set up this app</Button>
|
|
61
|
+
{/if}
|
|
62
|
+
</Card>
|
|
63
|
+
{:else}
|
|
64
|
+
{#if showForm}
|
|
65
|
+
<Card>
|
|
66
|
+
<Form
|
|
67
|
+
method="POST"
|
|
68
|
+
action="?/create"
|
|
69
|
+
preventDefault={false}
|
|
70
|
+
{@attach fromAction(enhance, () => submit)}
|
|
71
|
+
>
|
|
72
|
+
<FormGroup label="Title" required>
|
|
73
|
+
<Input name="title" bind:value={title} required />
|
|
74
|
+
</FormGroup>
|
|
75
|
+
<FormGroup label="Body">
|
|
76
|
+
<Textarea name="body" bind:value={body} rows={4} />
|
|
77
|
+
</FormGroup>
|
|
78
|
+
{#if form?.error}<p role="alert">{form.error}</p>{/if}
|
|
79
|
+
<div>
|
|
80
|
+
<Button type="submit" loading={creating} disabled={creating}>
|
|
81
|
+
Add note
|
|
82
|
+
</Button>
|
|
83
|
+
</div>
|
|
84
|
+
</Form>
|
|
85
|
+
</Card>
|
|
86
|
+
{/if}
|
|
87
|
+
|
|
88
|
+
{#if data.notes.length === 0}
|
|
89
|
+
<EmptyState
|
|
90
|
+
title="Start your first note"
|
|
91
|
+
description={data.canCreate
|
|
92
|
+
? 'Notes you add show up here for everyone in this workspace.'
|
|
93
|
+
: 'Notes will show up here once someone adds them.'}
|
|
94
|
+
actionLabel={data.canCreate && !composing ? 'New note' : undefined}
|
|
95
|
+
onaction={() => {
|
|
96
|
+
composing = true;
|
|
97
|
+
}}
|
|
98
|
+
/>
|
|
99
|
+
{:else}
|
|
100
|
+
<ul class="smrt-notes-page__notes">
|
|
101
|
+
{#each data.notes as note (note.id)}
|
|
102
|
+
<li>
|
|
103
|
+
<Card>
|
|
104
|
+
<h2>{note.title}</h2>
|
|
105
|
+
{#if note.body}<p>{note.body}</p>{/if}
|
|
106
|
+
</Card>
|
|
107
|
+
</li>
|
|
108
|
+
{/each}
|
|
109
|
+
</ul>
|
|
110
|
+
{/if}
|
|
111
|
+
{/if}
|
|
112
|
+
</main>
|
|
113
|
+
|
|
114
|
+
<style>
|
|
115
|
+
@layer smrt.reset, smrt.structure, smrt.theme;
|
|
116
|
+
|
|
117
|
+
@layer smrt.structure {
|
|
118
|
+
.smrt-notes-page__root {
|
|
119
|
+
display: grid;
|
|
120
|
+
gap: var(--smrt-spacing-6);
|
|
121
|
+
width: min(100%, 48rem);
|
|
122
|
+
margin-inline: auto;
|
|
123
|
+
padding: var(--smrt-spacing-6) var(--smrt-spacing-4);
|
|
124
|
+
}
|
|
125
|
+
.smrt-notes-page__notes {
|
|
126
|
+
display: grid;
|
|
127
|
+
gap: var(--smrt-spacing-3);
|
|
128
|
+
margin: 0;
|
|
129
|
+
padding: 0;
|
|
130
|
+
list-style: none;
|
|
131
|
+
}
|
|
132
|
+
h1,
|
|
133
|
+
h2,
|
|
134
|
+
p {
|
|
135
|
+
margin: 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@layer smrt.theme {
|
|
140
|
+
h2 {
|
|
141
|
+
font: var(--smrt-typography-title-medium-font);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
</style>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts" generics="Definitions extends object">
|
|
2
|
+
import type { ScreenCollectionDefinition } from '@happyvertical/smrt-svelte/screens';
|
|
3
|
+
import {
|
|
4
|
+
createRecipeScreenReferences,
|
|
5
|
+
createRecipeScreenEntry as entryRecords,
|
|
6
|
+
RecipeScreens,
|
|
7
|
+
} from '@happyvertical/smrt-svelte/screens';
|
|
8
|
+
import type { loadCookbookModelPage } from '@happyvertical/smrt-template-sveltekit/host/server';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
data: Awaited<ReturnType<typeof loadCookbookModelPage>> & {
|
|
12
|
+
dynamicDefinitions: Array<ScreenCollectionDefinition & { name: string }>;
|
|
13
|
+
enabledModels: string[];
|
|
14
|
+
};
|
|
15
|
+
collectionDefinitions: Definitions & {
|
|
16
|
+
[Key in keyof Definitions]: ScreenCollectionDefinition;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
let { data, collectionDefinitions }: Props = $props();
|
|
20
|
+
|
|
21
|
+
// The generated web definition of the entry's model and a source over its
|
|
22
|
+
// `/api/<collection>` routes. `@smrt/web` covers the cookbook's package models,
|
|
23
|
+
// which the `smrt()` preset hosts; a model the API does not expose has no
|
|
24
|
+
// definition and gets the notice below.
|
|
25
|
+
const definitions = $derived.by(() => {
|
|
26
|
+
const merged: Record<string, ScreenCollectionDefinition> = Object.fromEntries(
|
|
27
|
+
Object.entries(collectionDefinitions) as Array<
|
|
28
|
+
[string, ScreenCollectionDefinition]
|
|
29
|
+
>,
|
|
30
|
+
);
|
|
31
|
+
for (const definition of data.dynamicDefinitions)
|
|
32
|
+
merged[definition.name] = definition;
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
Object.entries(merged).filter(([, definition]) =>
|
|
35
|
+
data.enabledModels.includes(definition.objectRef),
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
const records = $derived(entryRecords(definitions, data.entry));
|
|
40
|
+
const references = $derived(
|
|
41
|
+
createRecipeScreenReferences(definitions, {
|
|
42
|
+
hrefFor: (definition, id) =>
|
|
43
|
+
data.referenceHrefs[definition.objectRef]
|
|
44
|
+
? `${data.referenceHrefs[definition.objectRef]}?record=${encodeURIComponent(id)}`
|
|
45
|
+
: undefined,
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<svelte:head><title>{data.entry.label}</title></svelte:head>
|
|
51
|
+
|
|
52
|
+
<main data-smrt-component="CookbookModelPage">
|
|
53
|
+
{#if records}
|
|
54
|
+
{#key data.entry.id}
|
|
55
|
+
<RecipeScreens definition={records.definition} source={records.source} entryId={data.entry.id} title={data.entry.label} {definitions} {references} view={data.recordId ? 'view' : 'list'} recordId={data.recordId} />
|
|
56
|
+
{/key}
|
|
57
|
+
{:else}
|
|
58
|
+
<h1>{data.entry.label}</h1>
|
|
59
|
+
<p>
|
|
60
|
+
{data.entry.className} is not exposed over this app's API, so there
|
|
61
|
+
are no record screens for it.
|
|
62
|
+
</p>
|
|
63
|
+
{/if}
|
|
64
|
+
</main>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
@layer smrt.reset, smrt.structure, smrt.theme;
|
|
68
|
+
|
|
69
|
+
@layer smrt.structure {
|
|
70
|
+
main {
|
|
71
|
+
padding: var(--smrt-spacing-6);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@layer smrt.theme {
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InferenceSettingsPageData } from '@happyvertical/smrt-inference/server';
|
|
3
|
+
import { InferenceSettingsPanel } from '@happyvertical/smrt-inference/svelte';
|
|
4
|
+
import { ShellSettingsPage } from '@happyvertical/smrt-svelte/app';
|
|
5
|
+
import { WorkProfileSettings } from '@happyvertical/smrt-svelte/settings';
|
|
6
|
+
import type { createCookbookHost } from '@happyvertical/smrt-template-sveltekit/host/server';
|
|
7
|
+
import { postSetting } from '@happyvertical/smrt-template-sveltekit/host/sveltekit-client';
|
|
8
|
+
import { goto } from '$app/navigation';
|
|
9
|
+
import { page } from '$app/state';
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
data,
|
|
13
|
+
}: {
|
|
14
|
+
data: InferenceSettingsPageData & {
|
|
15
|
+
workProfiles?: Awaited<
|
|
16
|
+
ReturnType<ReturnType<typeof createCookbookHost>['workProfiles']['read']>
|
|
17
|
+
>;
|
|
18
|
+
};
|
|
19
|
+
} = $props();
|
|
20
|
+
|
|
21
|
+
let busy = $state(false);
|
|
22
|
+
let message = $state<string | null>(null);
|
|
23
|
+
let error = $state<string | null>(null);
|
|
24
|
+
let discovered = $state<
|
|
25
|
+
{ service: string; baseUrl: string; models: string[] }[]
|
|
26
|
+
>([]);
|
|
27
|
+
|
|
28
|
+
// Run one save: busy while pending, then the outcome as a flash.
|
|
29
|
+
async function save(action: string, payload: unknown): Promise<void> {
|
|
30
|
+
busy = true;
|
|
31
|
+
message = error = null;
|
|
32
|
+
const outcome = await postSetting(action, payload);
|
|
33
|
+
busy = false;
|
|
34
|
+
if (outcome.ok) message = 'Saved.';
|
|
35
|
+
else error = outcome.error ?? 'The change was refused.';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A probe returns a result instead of saving anything.
|
|
39
|
+
async function probe(action: string, payload: unknown) {
|
|
40
|
+
const outcome = await postSetting(action, payload, { reload: false });
|
|
41
|
+
if (!outcome.ok || !outcome.data?.result) {
|
|
42
|
+
return { reachable: false, detail: outcome.error ?? 'The probe failed.' };
|
|
43
|
+
}
|
|
44
|
+
return outcome.data.result as {
|
|
45
|
+
reachable: boolean;
|
|
46
|
+
detail: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function discover(): Promise<void> {
|
|
51
|
+
const outcome = await postSetting('discoverModels', {}, { reload: false });
|
|
52
|
+
discovered = (outcome.data?.discovered as typeof discovered) ?? [];
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<svelte:head>
|
|
57
|
+
<title>Assistant · Settings</title>
|
|
58
|
+
</svelte:head>
|
|
59
|
+
|
|
60
|
+
<ShellSettingsPage basePath="/settings" title="Assistant">
|
|
61
|
+
<!-- The owner edits the whole app (app scope); a member without the
|
|
62
|
+
permission reads it, and the server refuses their writes. -->
|
|
63
|
+
{#if data.workProfiles}
|
|
64
|
+
<WorkProfileSettings settings={data.workProfiles.settings} resolved={data.workProfiles.resolved} editable={data.workProfiles.editable} chatgptSignedIn={data.workProfiles.chatgptSignedIn}
|
|
65
|
+
onsave={async (settings, confirmation) => { const result = await postSetting('saveWorkProfiles', { settings, ...confirmation, revision: data.workProfiles?.revision }); if (!result.ok) throw new Error('Save refused'); }}
|
|
66
|
+
onreset={async () => { const result = await postSetting('resetWorkProfiles', { revision: data.workProfiles?.revision }); if (!result.ok) throw new Error('Reset refused'); }} />
|
|
67
|
+
{/if}
|
|
68
|
+
<InferenceSettingsPanel
|
|
69
|
+
defaults={data.defaults}
|
|
70
|
+
providers={data.providers}
|
|
71
|
+
discoveredModels={discovered}
|
|
72
|
+
tiers={data.tiers}
|
|
73
|
+
defaultTier={data.defaultTier}
|
|
74
|
+
aliases={data.aliases}
|
|
75
|
+
fusions={data.fusions}
|
|
76
|
+
usage={data.usage}
|
|
77
|
+
transcripts={data.transcripts}
|
|
78
|
+
appEditable={data.canEdit}
|
|
79
|
+
scope="app"
|
|
80
|
+
contextKey={data.tenantId}
|
|
81
|
+
{busy}
|
|
82
|
+
{message}
|
|
83
|
+
{error}
|
|
84
|
+
onSaveDefaults={(change) => save('saveDefaults', change)}
|
|
85
|
+
onSaveKey={data.canEdit ? (change) => save('saveKey', change) : undefined}
|
|
86
|
+
onTestConnection={(request) => probe('testConnection', request)}
|
|
87
|
+
onDiscoverModels={discover}
|
|
88
|
+
onSaveTier={(change) => save('saveTier', change)}
|
|
89
|
+
onSaveDefaultTier={(change) => save('saveDefaultTier', change)}
|
|
90
|
+
onSaveAlias={(change) => save('saveAlias', change)}
|
|
91
|
+
onTestCandidate={(candidate) => probe('testCandidate', candidate)}
|
|
92
|
+
onSaveFusion={(change) => save('saveFusion', change)}
|
|
93
|
+
onSaveTranscripts={data.canEdit
|
|
94
|
+
? (change) => save('saveTranscripts', change)
|
|
95
|
+
: undefined}
|
|
96
|
+
onUsageGroupBy={(by) =>
|
|
97
|
+
goto(`${page.url.pathname}?by=${by.join(',')}`, {
|
|
98
|
+
keepFocus: true,
|
|
99
|
+
noScroll: true,
|
|
100
|
+
replaceState: true,
|
|
101
|
+
})}
|
|
102
|
+
/>
|
|
103
|
+
</ShellSettingsPage>
|
package/package.json
CHANGED
|
@@ -1,13 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-template-sveltekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"description": "Minimal SvelteKit project template with s-m-r-t framework integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
9
9
|
"./template.config.js": "./template.config.js",
|
|
10
|
-
"./template/*": "./template/*"
|
|
10
|
+
"./template/*": "./template/*",
|
|
11
|
+
"./host/server": {
|
|
12
|
+
"types": "./dist/host/server.d.ts",
|
|
13
|
+
"import": "./dist/host/server.js",
|
|
14
|
+
"default": "./dist/host/server.js"
|
|
15
|
+
},
|
|
16
|
+
"./host/client": {
|
|
17
|
+
"types": "./dist/host/client.d.ts",
|
|
18
|
+
"import": "./dist/host/client.js",
|
|
19
|
+
"default": "./dist/host/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./host/generate": {
|
|
22
|
+
"types": "./dist/host/generate.d.ts",
|
|
23
|
+
"import": "./dist/host/generate.js",
|
|
24
|
+
"default": "./dist/host/generate.js"
|
|
25
|
+
},
|
|
26
|
+
"./host/preferences": {
|
|
27
|
+
"types": "./dist/host/preferences.d.ts",
|
|
28
|
+
"import": "./dist/host/preferences.js",
|
|
29
|
+
"default": "./dist/host/preferences.js"
|
|
30
|
+
},
|
|
31
|
+
"./host/settings": {
|
|
32
|
+
"types": "./dist/host/settings.d.ts",
|
|
33
|
+
"import": "./dist/host/settings.js",
|
|
34
|
+
"default": "./dist/host/settings.js"
|
|
35
|
+
},
|
|
36
|
+
"./host/sveltekit-client": {
|
|
37
|
+
"types": "./dist/host/sveltekit-client.d.ts",
|
|
38
|
+
"import": "./dist/host/sveltekit-client.js",
|
|
39
|
+
"default": "./dist/host/sveltekit-client.js"
|
|
40
|
+
},
|
|
41
|
+
"./host/InferenceSettingsPage.svelte": {
|
|
42
|
+
"svelte": "./host/InferenceSettingsPage.svelte",
|
|
43
|
+
"default": "./host/InferenceSettingsPage.svelte"
|
|
44
|
+
},
|
|
45
|
+
"./host/CookbookModelPage.svelte": {
|
|
46
|
+
"svelte": "./host/CookbookModelPage.svelte",
|
|
47
|
+
"default": "./host/CookbookModelPage.svelte"
|
|
48
|
+
},
|
|
49
|
+
"./host/plugin-mode": {
|
|
50
|
+
"types": "./dist/host/plugin-mode.d.ts",
|
|
51
|
+
"import": "./dist/host/plugin-mode.js",
|
|
52
|
+
"default": "./dist/host/plugin-mode.js"
|
|
53
|
+
}
|
|
11
54
|
},
|
|
12
55
|
"smrt": {
|
|
13
56
|
"resourceExports": [
|
|
@@ -20,8 +63,14 @@
|
|
|
20
63
|
"index.js",
|
|
21
64
|
"template.config.js",
|
|
22
65
|
"template",
|
|
66
|
+
"examples",
|
|
23
67
|
"AGENTS.md",
|
|
24
|
-
"mcp-apps-template"
|
|
68
|
+
"mcp-apps-template",
|
|
69
|
+
"dist",
|
|
70
|
+
"agents",
|
|
71
|
+
"host/InferenceSettingsPage.svelte",
|
|
72
|
+
"host/CookbookModelPage.svelte",
|
|
73
|
+
"cookbook-template"
|
|
25
74
|
],
|
|
26
75
|
"keywords": [
|
|
27
76
|
"smrt",
|
|
@@ -37,26 +86,45 @@
|
|
|
37
86
|
"directory": "packages/template-sveltekit"
|
|
38
87
|
},
|
|
39
88
|
"peerDependencies": {
|
|
40
|
-
"@happyvertical/smrt-core": "0.
|
|
89
|
+
"@happyvertical/smrt-core": "0.61.1",
|
|
90
|
+
"@happyvertical/smrt-agents": "0.61.1",
|
|
91
|
+
"@happyvertical/smrt-app-runtime": "0.61.1",
|
|
92
|
+
"@happyvertical/smrt-app-mcp": "0.61.1",
|
|
93
|
+
"@happyvertical/smrt-chat": "0.61.1",
|
|
94
|
+
"@happyvertical/smrt-inference": "0.61.1",
|
|
95
|
+
"@happyvertical/smrt-preferences": "0.61.1",
|
|
96
|
+
"@happyvertical/smrt-svelte": "0.61.1",
|
|
97
|
+
"@happyvertical/smrt-tenancy": "0.61.1",
|
|
98
|
+
"@happyvertical/smrt-types": "0.61.1",
|
|
99
|
+
"@happyvertical/smrt-ui": "0.61.1",
|
|
100
|
+
"@happyvertical/smrt-users": "0.61.1",
|
|
101
|
+
"@sveltejs/kit": "^2.70.3",
|
|
102
|
+
"svelte": "^5.57.1",
|
|
103
|
+
"@happyvertical/sql": ">=0.89.12",
|
|
104
|
+
"@happyvertical/smrt-jobs": "0.61.1"
|
|
41
105
|
},
|
|
42
106
|
"devDependencies": {
|
|
43
|
-
"@happyvertical/smrt-app-cli": "0.
|
|
44
|
-
"@happyvertical/smrt-app-mcp": "0.
|
|
45
|
-
"@happyvertical/smrt-app-runtime": "0.
|
|
46
|
-
"@happyvertical/smrt-assets": "0.
|
|
47
|
-
"@happyvertical/smrt-chat": "0.
|
|
48
|
-
"@happyvertical/smrt-cli": "0.
|
|
49
|
-
"@happyvertical/smrt-config": "0.
|
|
50
|
-
"@happyvertical/smrt-
|
|
51
|
-
"@happyvertical/smrt-
|
|
52
|
-
"@happyvertical/smrt-
|
|
53
|
-
"@happyvertical/smrt-
|
|
54
|
-
"@happyvertical/smrt-
|
|
55
|
-
"@happyvertical/smrt-
|
|
56
|
-
"@happyvertical/smrt-
|
|
57
|
-
"@happyvertical/smrt-
|
|
58
|
-
"@happyvertical/smrt-
|
|
59
|
-
"@happyvertical/smrt-
|
|
107
|
+
"@happyvertical/smrt-app-cli": "0.61.1",
|
|
108
|
+
"@happyvertical/smrt-app-mcp": "0.61.1",
|
|
109
|
+
"@happyvertical/smrt-app-runtime": "0.61.1",
|
|
110
|
+
"@happyvertical/smrt-assets": "0.61.1",
|
|
111
|
+
"@happyvertical/smrt-chat": "0.61.1",
|
|
112
|
+
"@happyvertical/smrt-cli": "0.61.1",
|
|
113
|
+
"@happyvertical/smrt-config": "0.61.1",
|
|
114
|
+
"@happyvertical/smrt-inference": "0.61.1",
|
|
115
|
+
"@happyvertical/smrt-jobs": "0.61.1",
|
|
116
|
+
"@happyvertical/smrt-mcp-openai": "0.61.1",
|
|
117
|
+
"@happyvertical/smrt-playbooks": "0.61.1",
|
|
118
|
+
"@happyvertical/smrt-preferences": "0.61.1",
|
|
119
|
+
"@happyvertical/smrt-profiles": "0.61.1",
|
|
120
|
+
"@happyvertical/smrt-prompts": "0.61.1",
|
|
121
|
+
"@happyvertical/smrt-scanner": "0.61.1",
|
|
122
|
+
"@happyvertical/smrt-secrets": "0.61.1",
|
|
123
|
+
"@happyvertical/smrt-svelte": "0.61.1",
|
|
124
|
+
"@happyvertical/smrt-tenancy": "0.61.1",
|
|
125
|
+
"@happyvertical/smrt-ui": "0.61.1",
|
|
126
|
+
"@happyvertical/smrt-users": "0.61.1",
|
|
127
|
+
"@happyvertical/smrt-web": "0.61.1",
|
|
60
128
|
"@happyvertical/sql": "^0.89.12",
|
|
61
129
|
"@modelcontextprotocol/client": "2.3.1",
|
|
62
130
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
@@ -70,19 +138,29 @@
|
|
|
70
138
|
"typescript": "6.0.3",
|
|
71
139
|
"vite": "8.1.6",
|
|
72
140
|
"vitest": "4.1.10",
|
|
73
|
-
"@happyvertical/smrt-reports": "0.
|
|
141
|
+
"@happyvertical/smrt-reports": "0.61.1",
|
|
142
|
+
"@happyvertical/smrt-agents": "0.61.1",
|
|
143
|
+
"@happyvertical/smrt-types": "0.61.1",
|
|
144
|
+
"@happyvertical/smrt-commerce": "0.61.1",
|
|
145
|
+
"@happyvertical/smrt-events": "0.61.1",
|
|
146
|
+
"@happyvertical/smrt-inventory": "0.61.1"
|
|
74
147
|
},
|
|
75
148
|
"publishConfig": {
|
|
76
149
|
"registry": "https://registry.npmjs.org",
|
|
77
150
|
"access": "public"
|
|
78
151
|
},
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"@happyvertical/smrt-app-cli": "0.61.1",
|
|
154
|
+
"@happyvertical/smrt-desktop": "0.61.1",
|
|
155
|
+
"ajv": "^8.20.0"
|
|
156
|
+
},
|
|
79
157
|
"scripts": {
|
|
80
|
-
"build": "pnpm run typecheck && node --check index.js",
|
|
158
|
+
"build": "tsc -p tsconfig.host.json && pnpm run typecheck && node --check index.js",
|
|
81
159
|
"test": "vitest run",
|
|
82
160
|
"test:e2e": "pnpm exec playwright test --config playwright.config.ts",
|
|
83
161
|
"test:m5": "node ../../scripts/run-with-ci-postgres.mjs -- node e2e/support/gate.mjs",
|
|
84
162
|
"test:postgres": "node ../../scripts/run-with-ci-postgres.mjs -- pnpm exec vitest run --no-file-parallelism __tests__/*.postgres.optional.test.ts",
|
|
85
163
|
"test:watch": "vitest",
|
|
86
|
-
"typecheck": "tsc --noEmit -p tsconfig.fixture.json"
|
|
164
|
+
"typecheck": "tsc --noEmit -p tsconfig.fixture.json && tsc --noEmit -p tsconfig.host.json"
|
|
87
165
|
}
|
|
88
166
|
}
|
package/template/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# s-m-r-t SvelteKit starter
|
|
2
2
|
|
|
3
3
|
This is the small, ground-up starting point for s-m-r-t. It contains
|
|
4
|
-
|
|
5
|
-
managed-cloud environments. It does not provision
|
|
4
|
+
no example object, an empty home page, and a profile-aware operational surface
|
|
5
|
+
for local, self-hosted, and managed-cloud environments. It does not provision
|
|
6
|
+
external providers.
|
|
6
7
|
|
|
7
8
|
## 1. Install and run
|
|
8
9
|
|
|
@@ -69,9 +70,20 @@ objects.
|
|
|
69
70
|
|
|
70
71
|
## 3. Define the first object
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
A new app registers no object, so nothing is migrated and the home page is an
|
|
74
|
+
empty state. To add your first one, create `src/lib/objects/Note.ts` (the Note
|
|
75
|
+
example below; the repository keeps it with a ready-made `/notes` page in
|
|
76
|
+
`packages/template-sveltekit/examples/notes`), then export it from
|
|
77
|
+
`src/lib/objects/index.ts`:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
export { Note, NoteCollection } from './Note.js';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Add a nav entry for your page in `src/routes/+layout.svelte`, then run
|
|
84
|
+
`pnpm db:migrate`. The Note example exposes the same CRUD action set to REST,
|
|
85
|
+
MCP, WebMCP definitions, and the CLI, while limiting writable REST fields and
|
|
86
|
+
opting into tenant scoping:
|
|
75
87
|
|
|
76
88
|
```ts
|
|
77
89
|
import {
|
|
@@ -106,7 +118,7 @@ export class NoteCollection extends SmrtCollection<Note> {
|
|
|
106
118
|
ObjectRegistry.registerCollection('Note', NoteCollection);
|
|
107
119
|
```
|
|
108
120
|
|
|
109
|
-
Add
|
|
121
|
+
Add further classes beside it and export each from
|
|
110
122
|
`src/lib/objects/index.ts`. Keep relationship decorators next to `@smrt()`.
|
|
111
123
|
Use `@foreignKey(Target)` for same-package relationships and
|
|
112
124
|
`@crossPackageRef()` for relationships to another package. Keep the explicit
|
|
@@ -181,8 +193,8 @@ These are separate records with separate responsibilities:
|
|
|
181
193
|
- Session binds the authenticated user to an active tenant and publishes the
|
|
182
194
|
resolved permission set for the request.
|
|
183
195
|
|
|
184
|
-
CRUD permissions are manifest-derived: `notes.read`, `notes.create`,
|
|
185
|
-
`notes.update`, and `notes.delete
|
|
196
|
+
CRUD permissions are manifest-derived (for the Note example: `notes.read`, `notes.create`,
|
|
197
|
+
`notes.update`, and `notes.delete`). Provisioning code should sync the catalog
|
|
186
198
|
and seed roles after the database migration:
|
|
187
199
|
|
|
188
200
|
```ts
|
|
@@ -255,7 +267,8 @@ include malformed manifest content.
|
|
|
255
267
|
|
|
256
268
|
The option stages `src/routes/api/mcp/+server.ts`, one
|
|
257
269
|
`mountMcpAppRoute({ runtime, ... })` call from
|
|
258
|
-
`@happyvertical/smrt-app-mcp/sveltekit` that publishes
|
|
270
|
+
`@happyvertical/smrt-app-mcp/sveltekit` that publishes your model (the overlay
|
|
271
|
+
names `Note`; replace it with your own object) to
|
|
259
272
|
principals holding `notes.read` (the signed session's permissions locally),
|
|
260
273
|
refuses browser requests from a foreign `Origin`, and serves a bounded static
|
|
261
274
|
resource with a restrictive CSP and the optional OpenAI display metadata. It
|
|
@@ -272,7 +285,7 @@ request nor grants tenant or workflow authority. Register `.app.json` only
|
|
|
272
285
|
after the host creates an eligible server ID; do not copy runtime extension
|
|
273
286
|
metadata into the portable manifest.
|
|
274
287
|
|
|
275
|
-
|
|
288
|
+
Once the Note example is added, its configuration generates:
|
|
276
289
|
|
|
277
290
|
- REST: `GET`/`POST /api/notes` and
|
|
278
291
|
`GET`/`PUT`/`DELETE /api/notes/[id]`.
|
|
@@ -285,7 +298,7 @@ Inspect the registered objects and use the example CLI:
|
|
|
285
298
|
|
|
286
299
|
```bash
|
|
287
300
|
pnpm smrt objects
|
|
288
|
-
pnpm smrt schema Note
|
|
301
|
+
pnpm smrt schema Note # once the Note example is added
|
|
289
302
|
```
|
|
290
303
|
|
|
291
304
|
The CLI's manifest-only `objects` and `schema` commands work directly in this
|
package/template/package.json
CHANGED
|
@@ -41,21 +41,26 @@
|
|
|
41
41
|
"svelte-check": "^4.7.6",
|
|
42
42
|
"typescript": "6.0.3",
|
|
43
43
|
"vite": "8.3.3",
|
|
44
|
-
"@happyvertical/smrt-cli": "^0.
|
|
44
|
+
"@happyvertical/smrt-cli": "^0.61.1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@happyvertical/smrt-app-runtime": "^0.
|
|
48
|
-
"@happyvertical/smrt-config": "^0.
|
|
49
|
-
"@happyvertical/smrt-core": "^0.
|
|
50
|
-
"@happyvertical/smrt-
|
|
51
|
-
"@happyvertical/smrt-
|
|
52
|
-
"@happyvertical/smrt-
|
|
53
|
-
"@happyvertical/smrt-
|
|
54
|
-
"@happyvertical/smrt-
|
|
55
|
-
"@happyvertical/smrt-
|
|
56
|
-
"@happyvertical/smrt-
|
|
47
|
+
"@happyvertical/smrt-app-runtime": "^0.61.1",
|
|
48
|
+
"@happyvertical/smrt-config": "^0.61.1",
|
|
49
|
+
"@happyvertical/smrt-core": "^0.61.1",
|
|
50
|
+
"@happyvertical/smrt-inference": "^0.61.1",
|
|
51
|
+
"@happyvertical/smrt-jobs": "^0.61.1",
|
|
52
|
+
"@happyvertical/smrt-preferences": "^0.61.1",
|
|
53
|
+
"@happyvertical/smrt-profiles": "^0.61.1",
|
|
54
|
+
"@happyvertical/smrt-prompts": "^0.61.1",
|
|
55
|
+
"@happyvertical/smrt-svelte": "^0.61.1",
|
|
56
|
+
"@happyvertical/smrt-tenancy": "^0.61.1",
|
|
57
|
+
"@happyvertical/smrt-ui": "^0.61.1",
|
|
58
|
+
"@happyvertical/smrt-users": "^0.61.1",
|
|
59
|
+
"@happyvertical/smrt-web": "^0.61.1",
|
|
57
60
|
"@happyvertical/sql": "^0.89.12",
|
|
58
61
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
59
|
-
"@happyvertical/smrt-reports": "^0.
|
|
62
|
+
"@happyvertical/smrt-reports": "^0.61.1",
|
|
63
|
+
"@happyvertical/smrt-secrets": "^0.61.1",
|
|
64
|
+
"@happyvertical/smrt-template-sveltekit": "^0.61.1"
|
|
60
65
|
}
|
|
61
66
|
}
|
package/template/smrt.config.ts
CHANGED
|
@@ -23,9 +23,13 @@ export default {
|
|
|
23
23
|
consumer: {
|
|
24
24
|
packages: [
|
|
25
25
|
'@happyvertical/smrt-profiles',
|
|
26
|
+
'@happyvertical/smrt-preferences',
|
|
27
|
+
'@happyvertical/smrt-inference',
|
|
28
|
+
'@happyvertical/smrt-prompts',
|
|
26
29
|
'@happyvertical/smrt-tenancy',
|
|
27
30
|
'@happyvertical/smrt-users',
|
|
28
31
|
'@happyvertical/smrt-reports',
|
|
32
|
+
'@happyvertical/smrt-secrets',
|
|
29
33
|
],
|
|
30
34
|
},
|
|
31
35
|
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* Configure the runtime in `$lib/server/smrt`.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { installInferenceOverrides } from '$lib/server/settings';
|
|
13
14
|
import { runtime } from '$lib/server/smrt';
|
|
14
15
|
|
|
15
16
|
export const { handle, init } = runtime;
|
|
17
|
+
|
|
18
|
+
// Tier bindings, aliases and fusions saved on the Inference settings page
|
|
19
|
+
// apply to every inference call (lazy: the database resolves in `init`).
|
|
20
|
+
installInferenceOverrides();
|