@happyvertical/smrt-template-sveltekit 0.60.18 → 0.61.0
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
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SMRT Objects Index
|
|
3
3
|
*
|
|
4
|
-
* Export
|
|
5
|
-
*
|
|
4
|
+
* Export your s-m-r-t objects from this file; they are registered and exposed
|
|
5
|
+
* through REST, CLI and MCP automatically. A new app ships with none. To add
|
|
6
|
+
* your first, copy the Note example from `examples/notes` (see the README),
|
|
7
|
+
* then export it here:
|
|
8
|
+
*
|
|
9
|
+
* export { Note, NoteCollection } from './Note.js';
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
|
-
export {
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup registrations for the inference and prompt settings sections:
|
|
3
|
+
* the `inference` preference kind, and the permissions their writes check.
|
|
4
|
+
* Imported by `./smrt` BEFORE the runtime exists, because the runtime's init
|
|
5
|
+
* seeds the owner and admin roles over the registered permission catalog, so
|
|
6
|
+
* the local owner gets `inference.customize` and `prompts.customize` on the
|
|
7
|
+
* next start. Registration describes a permission; it never grants one.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
INFERENCE_PERMISSION_DEFINITIONS,
|
|
12
|
+
inferencePreferenceKind,
|
|
13
|
+
} from '@happyvertical/smrt-inference/server';
|
|
14
|
+
import { registerPreferenceKind } from '@happyvertical/smrt-preferences';
|
|
15
|
+
import { registerPermissionDefinitions } from '@happyvertical/smrt-users';
|
|
16
|
+
|
|
17
|
+
/** Authorizes changing prompt text for the app and its tenants. */
|
|
18
|
+
export const PROMPTS_CUSTOMIZE_PERMISSION = 'prompts.customize';
|
|
19
|
+
|
|
20
|
+
registerPreferenceKind(inferencePreferenceKind, { replace: true });
|
|
21
|
+
registerPermissionDefinitions([
|
|
22
|
+
...INFERENCE_PERMISSION_DEFINITIONS,
|
|
23
|
+
{
|
|
24
|
+
slug: PROMPTS_CUSTOMIZE_PERMISSION,
|
|
25
|
+
category: 'prompts',
|
|
26
|
+
name: 'Customize Prompts',
|
|
27
|
+
description: 'Change the prompt text this app and its tenants use',
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server side of the inference and prompt settings sections: who may read
|
|
3
|
+
* and write, and the services behind `InferenceSettingsPanel` and
|
|
4
|
+
* `PromptSettingsPanel`. The panels decide nothing; every decision is here.
|
|
5
|
+
*
|
|
6
|
+
* This is a single-owner local app: the signed-in owner holds the
|
|
7
|
+
* `inference.customize` and `prompts.customize` permissions (the owner role
|
|
8
|
+
* is seeded over the permission catalog `./settings-registry` extends), so
|
|
9
|
+
* the owner edits app-wide settings. A member without them reads the
|
|
10
|
+
* settings and every write fails closed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createInferenceSettingsController,
|
|
15
|
+
createInferenceSettingsHost,
|
|
16
|
+
type InferenceSettingsController,
|
|
17
|
+
inferenceSettingsFailure,
|
|
18
|
+
} from '@happyvertical/smrt-inference/server';
|
|
19
|
+
import { createPreferenceStore } from '@happyvertical/smrt-preferences';
|
|
20
|
+
import { PromptSettingsService } from '@happyvertical/smrt-prompts';
|
|
21
|
+
import { PROMPTS_CUSTOMIZE_PERMISSION } from './settings-registry';
|
|
22
|
+
import { runtime } from './smrt';
|
|
23
|
+
|
|
24
|
+
export { PROMPTS_CUSTOMIZE_PERMISSION };
|
|
25
|
+
|
|
26
|
+
export { requireSettingsSession, readPayload } from '@happyvertical/smrt-template-sveltekit/host/settings';
|
|
27
|
+
import type { SettingsSession } from '@happyvertical/smrt-template-sveltekit/host/settings';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Secrets, the user resolver and the settings service, from smrt-inference's
|
|
31
|
+
* host. `SMRT_SECRET_MASTER_KEY` wins where it is set (servers); otherwise
|
|
32
|
+
* the local runtime creates the master key on first run and keeps it in its
|
|
33
|
+
* vault key store, so the owner never types or sees it
|
|
34
|
+
* (`runtime.secretMasterKey()` is `null` on deployed profiles, which need the
|
|
35
|
+
* variable). Nothing touches the database until first use: it resolves after
|
|
36
|
+
* `src/hooks.server.ts` imports this module.
|
|
37
|
+
*/
|
|
38
|
+
const inference = createInferenceSettingsHost({
|
|
39
|
+
database: () => runtime.database(),
|
|
40
|
+
masterKeyProvider: () => runtime.secretMasterKey(),
|
|
41
|
+
overrides: () => runtime.classOptions('InferenceOverride'),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Stored API keys, tier bindings, aliases and fusions apply to every
|
|
46
|
+
* inference call in this process (the signed-in user's key, then the
|
|
47
|
+
* tenant's, then the stored tier bindings, then config).
|
|
48
|
+
* `registerUserInferenceResolver` keeps the chain validation outermost.
|
|
49
|
+
*/
|
|
50
|
+
export function installInferenceOverrides(): void {
|
|
51
|
+
inference.install();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let controller: InferenceSettingsController | undefined;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* What the Inference page loads and saves, shared with the app shell
|
|
58
|
+
* (smrt-inference's controller). The session's `can()` is this app's own
|
|
59
|
+
* check: its permission snapshot.
|
|
60
|
+
*/
|
|
61
|
+
export function inferenceSettingsController(): InferenceSettingsController {
|
|
62
|
+
controller ??= createInferenceSettingsController({
|
|
63
|
+
host: inference,
|
|
64
|
+
preferenceStore: async () =>
|
|
65
|
+
createPreferenceStore({ db: await runtime.database() }),
|
|
66
|
+
});
|
|
67
|
+
return controller;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Prompt settings reads, plus writes for a session that may customize. */
|
|
71
|
+
export function promptSettingsService(
|
|
72
|
+
session: SettingsSession,
|
|
73
|
+
): Promise<PromptSettingsService> {
|
|
74
|
+
return PromptSettingsService.create(
|
|
75
|
+
runtime.classOptions('PromptOverride'),
|
|
76
|
+
{
|
|
77
|
+
authorize: (request) =>
|
|
78
|
+
session.can(PROMPTS_CUSTOMIZE_PERMISSION) &&
|
|
79
|
+
(request.scopeType === 'app' ||
|
|
80
|
+
request.scopeId === session.tenantId),
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** A `{ error }` body for a failed write: the message names no key or secret. */
|
|
86
|
+
export function settingsFailure(cause: unknown): { status: number; error: string } {
|
|
87
|
+
if ((cause as { name?: string })?.name === 'PromptOverrideAuthorizationError') {
|
|
88
|
+
return { status: 403, error: 'You are not allowed to change this setting.' };
|
|
89
|
+
}
|
|
90
|
+
return inferenceSettingsFailure(cause);
|
|
91
|
+
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { createSmrtSvelteKitRuntime } from '@happyvertical/smrt-app-runtime/sveltekit';
|
|
18
|
+
import './settings-registry';
|
|
18
19
|
|
|
19
20
|
export const runtime = createSmrtSvelteKitRuntime({
|
|
20
21
|
// Deployed profiles prove authentication, asset, and secret readiness
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { postSetting, type SettingOutcome } from '@happyvertical/smrt-template-sveltekit/host/sveltekit-client';
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sign out through the runtime's same-origin `POST /sign-out` route, then
|
|
5
|
-
* refresh the session-derived layout data and return home. A failed request
|
|
6
|
-
* (403, 5xx) throws instead of pretending the session ended: the user stays
|
|
7
|
-
* signed in and the error names the status.
|
|
8
|
-
*/
|
|
9
|
-
export async function signOut(): Promise<void> {
|
|
10
|
-
const response = await fetch('/sign-out', {
|
|
11
|
-
method: 'POST',
|
|
12
|
-
credentials: 'same-origin',
|
|
13
|
-
});
|
|
14
|
-
if (!response.ok) {
|
|
15
|
-
throw new Error(`Sign-out failed with status ${response.status}`);
|
|
16
|
-
}
|
|
17
|
-
await invalidateAll();
|
|
18
|
-
await goto('/');
|
|
19
|
-
}
|
|
1
|
+
export { signOut } from '@happyvertical/smrt-template-sveltekit/host/sveltekit-client';
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
// Add application routes here. Generated REST routes live under /api and do
|
|
12
12
|
// not automatically imply a human-facing page.
|
|
13
13
|
const nav: ShellNavItem[] = [
|
|
14
|
-
{ href: '/', label: '
|
|
15
|
-
{ href: '/settings', label: 'Settings', icon: 'settings', description: 'Workspace layout and shortcuts' },
|
|
14
|
+
{ href: '/settings', label: 'Settings', icon: 'settings', description: 'Appearance, account and layout' },
|
|
16
15
|
];
|
|
17
16
|
|
|
18
17
|
// Generated read-only WebMCP tools, only in browsers that expose WebMCP.
|
|
@@ -1,142 +1,34 @@
|
|
|
1
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
2
|
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
3
|
</script>
|
|
43
4
|
|
|
44
5
|
<svelte:head>
|
|
45
|
-
<title>
|
|
6
|
+
<title>Home</title>
|
|
46
7
|
</svelte:head>
|
|
47
8
|
|
|
48
|
-
<main class="
|
|
49
|
-
<h1>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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="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}
|
|
9
|
+
<main class="smrt-template-home__root">
|
|
10
|
+
<h1>Home</h1>
|
|
11
|
+
<EmptyState
|
|
12
|
+
title="Nothing here yet"
|
|
13
|
+
description="Add your first object in src/lib/objects, then build pages for it here."
|
|
14
|
+
/>
|
|
112
15
|
</main>
|
|
113
16
|
|
|
114
17
|
<style>
|
|
115
|
-
|
|
116
|
-
.page {
|
|
117
|
-
display: grid;
|
|
118
|
-
gap: var(--smrt-spacing-6);
|
|
119
|
-
width: min(100%, 48rem);
|
|
120
|
-
margin-inline: auto;
|
|
121
|
-
padding: var(--smrt-spacing-6) var(--smrt-spacing-4);
|
|
122
|
-
}
|
|
18
|
+
@layer smrt.reset, smrt.structure, smrt.theme;
|
|
123
19
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
20
|
+
@layer smrt.structure {
|
|
21
|
+
.smrt-template-home__root {
|
|
22
|
+
width: min(100%, 48rem);
|
|
23
|
+
margin-inline: auto;
|
|
24
|
+
padding: var(--smrt-spacing-6) var(--smrt-spacing-4);
|
|
25
|
+
}
|
|
26
|
+
h1 {
|
|
27
|
+
margin: 0 0 var(--smrt-spacing-4);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
131
30
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
p {
|
|
135
|
-
margin: 0;
|
|
136
|
-
}
|
|
31
|
+
@layer smrt.theme {
|
|
32
|
+
}
|
|
137
33
|
|
|
138
|
-
h2 {
|
|
139
|
-
font: var(--smrt-typography-title-medium);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
34
|
</style>
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ShellSettingsPage } from '@happyvertical/smrt-svelte/app';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// Host sections, each its own route under /settings.
|
|
5
|
+
const extraSections = [
|
|
6
|
+
{
|
|
7
|
+
id: 'inference',
|
|
8
|
+
label: 'Inference',
|
|
9
|
+
description: 'Provider, model tiers, aliases, fusions and usage.',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: 'prompts',
|
|
13
|
+
label: 'Prompts',
|
|
14
|
+
description: 'Review and override the prompt text the app uses.',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
4
17
|
</script>
|
|
5
18
|
|
|
6
19
|
<svelte:head>
|
|
7
20
|
<title>Settings · s-m-r-t app</title>
|
|
8
21
|
</svelte:head>
|
|
9
22
|
|
|
10
|
-
<!--
|
|
11
|
-
<ShellSettingsPage
|
|
23
|
+
<!-- The section menu; each section is its own page under /settings. -->
|
|
24
|
+
<ShellSettingsPage basePath="/settings" {extraSections} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { page } from '$app/state';
|
|
3
|
+
import {
|
|
4
|
+
ShellSettingsPage,
|
|
5
|
+
type ShellSettingsSection,
|
|
6
|
+
} from '@happyvertical/smrt-svelte/app';
|
|
7
|
+
import { signOut } from '$lib/sign-out';
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<svelte:head>
|
|
11
|
+
<title>Settings · s-m-r-t app</title>
|
|
12
|
+
</svelte:head>
|
|
13
|
+
|
|
14
|
+
<!-- One built-in section (appearance, account, layout, shortcuts); the param matcher guarantees it. -->
|
|
15
|
+
<ShellSettingsPage
|
|
16
|
+
basePath="/settings"
|
|
17
|
+
section={page.params.section as ShellSettingsSection}
|
|
18
|
+
onSignOut={signOut}
|
|
19
|
+
/>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { fail } from '@sveltejs/kit';
|
|
2
|
+
import {
|
|
3
|
+
PROMPTS_CUSTOMIZE_PERMISSION,
|
|
4
|
+
promptSettingsService,
|
|
5
|
+
requireSettingsSession,
|
|
6
|
+
settingsFailure,
|
|
7
|
+
} from '$lib/server/settings';
|
|
8
|
+
import type { Actions, PageServerLoad } from './$types';
|
|
9
|
+
|
|
10
|
+
export const load: PageServerLoad = async ({ locals, depends }) => {
|
|
11
|
+
depends('smrt:prompt-settings');
|
|
12
|
+
const session = requireSettingsSession(locals);
|
|
13
|
+
const settings = await promptSettingsService(session);
|
|
14
|
+
return {
|
|
15
|
+
tenantId: session.tenantId,
|
|
16
|
+
// The owner edits both the app-wide text and this workspace's override.
|
|
17
|
+
canEdit: session.can(PROMPTS_CUSTOMIZE_PERMISSION),
|
|
18
|
+
prompts: await settings.listPromptSettings({ tenantId: session.tenantId }),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const actions: Actions = {
|
|
23
|
+
savePrompt: async ({ request, locals }) => {
|
|
24
|
+
const session = requireSettingsSession(locals);
|
|
25
|
+
const form = await request.formData();
|
|
26
|
+
const key = String(form.get('key') ?? '');
|
|
27
|
+
const settings = await promptSettingsService(session);
|
|
28
|
+
// A checked box overrides with the text; an unchecked one reverts.
|
|
29
|
+
const value = (override: string, template: string) =>
|
|
30
|
+
form.has(override) ? String(form.get(template) ?? '') : null;
|
|
31
|
+
try {
|
|
32
|
+
await settings.setTenantPromptOverride(
|
|
33
|
+
key,
|
|
34
|
+
session.tenantId,
|
|
35
|
+
value('tenantOverride', 'tenantTemplate'),
|
|
36
|
+
);
|
|
37
|
+
// The app column is posted only when the panel rendered it editable.
|
|
38
|
+
if (form.has('appTemplate') || form.has('appOverride')) {
|
|
39
|
+
await settings.setAppPromptOverride(
|
|
40
|
+
key,
|
|
41
|
+
value('appOverride', 'appTemplate'),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
} catch (cause) {
|
|
45
|
+
const failure = settingsFailure(cause);
|
|
46
|
+
return fail(failure.status, { error: failure.error });
|
|
47
|
+
}
|
|
48
|
+
return { message: 'Prompt overrides saved.' };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ShellSettingsPage } from '@happyvertical/smrt-svelte/app';
|
|
3
|
+
import { PromptSettingsPanel } from '@happyvertical/smrt-prompts/svelte';
|
|
4
|
+
import type { PageProps } from './$types';
|
|
5
|
+
|
|
6
|
+
let { data, form }: PageProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<svelte:head>
|
|
10
|
+
<title>Prompts · Settings · s-m-r-t app</title>
|
|
11
|
+
</svelte:head>
|
|
12
|
+
|
|
13
|
+
<ShellSettingsPage basePath="/settings" title="Prompts">
|
|
14
|
+
<!-- Each row is a plain form posting to ?/savePrompt, so saving works
|
|
15
|
+
without client code; the page reloads with the stored text. -->
|
|
16
|
+
<PromptSettingsPanel
|
|
17
|
+
prompts={data.prompts}
|
|
18
|
+
contextKey={data.tenantId}
|
|
19
|
+
tenantLabel="This workspace"
|
|
20
|
+
showApp={data.canEdit}
|
|
21
|
+
appEditable={data.canEdit}
|
|
22
|
+
appLabel="All workspaces"
|
|
23
|
+
busy={!data.canEdit}
|
|
24
|
+
formAction="?/savePrompt"
|
|
25
|
+
message={form && 'message' in form ? form.message : null}
|
|
26
|
+
error={form && 'error' in form ? form.error : null}
|
|
27
|
+
/>
|
|
28
|
+
</ShellSettingsPage>
|
package/template.config.js
CHANGED
|
@@ -19,23 +19,28 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
// Dependencies to add to generated project
|
|
21
21
|
dependencies: {
|
|
22
|
-
'@happyvertical/smrt-app-runtime': '^0.
|
|
23
|
-
'@happyvertical/smrt-config': '^0.
|
|
24
|
-
'@happyvertical/smrt-core': '^0.
|
|
25
|
-
'@happyvertical/smrt-
|
|
26
|
-
'@happyvertical/smrt-
|
|
27
|
-
'@happyvertical/smrt-
|
|
28
|
-
'@happyvertical/smrt-
|
|
29
|
-
'@happyvertical/smrt-
|
|
30
|
-
'@happyvertical/smrt-
|
|
31
|
-
'@happyvertical/smrt-
|
|
32
|
-
'@happyvertical/smrt-
|
|
22
|
+
'@happyvertical/smrt-app-runtime': '^0.61.0',
|
|
23
|
+
'@happyvertical/smrt-config': '^0.61.0',
|
|
24
|
+
'@happyvertical/smrt-core': '^0.61.0',
|
|
25
|
+
'@happyvertical/smrt-inference': '^0.61.0',
|
|
26
|
+
'@happyvertical/smrt-jobs': '^0.61.0',
|
|
27
|
+
'@happyvertical/smrt-preferences': '^0.61.0',
|
|
28
|
+
'@happyvertical/smrt-profiles': '^0.61.0',
|
|
29
|
+
'@happyvertical/smrt-prompts': '^0.61.0',
|
|
30
|
+
'@happyvertical/smrt-reports': '^0.61.0',
|
|
31
|
+
'@happyvertical/smrt-secrets': '^0.61.0',
|
|
32
|
+
'@happyvertical/smrt-svelte': '^0.61.0',
|
|
33
|
+
'@happyvertical/smrt-template-sveltekit': '^0.61.0',
|
|
34
|
+
'@happyvertical/smrt-tenancy': '^0.61.0',
|
|
35
|
+
'@happyvertical/smrt-ui': '^0.61.0',
|
|
36
|
+
'@happyvertical/smrt-users': '^0.61.0',
|
|
37
|
+
'@happyvertical/smrt-web': '^0.61.0',
|
|
33
38
|
'@happyvertical/sql': '^0.89.12',
|
|
34
39
|
'@modelcontextprotocol/server': '^2.3.1',
|
|
35
40
|
},
|
|
36
41
|
|
|
37
42
|
devDependencies: {
|
|
38
|
-
'@happyvertical/smrt-cli': '^0.
|
|
43
|
+
'@happyvertical/smrt-cli': '^0.61.0',
|
|
39
44
|
'@sveltejs/adapter-node': '^5.5.7',
|
|
40
45
|
'@sveltejs/kit': '2.70.3',
|
|
41
46
|
'@sveltejs/vite-plugin-svelte': '^7.3.0',
|
|
File without changes
|
|
File without changes
|