@happyvertical/smrt-template-sveltekit 0.53.3 → 0.54.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 +60 -27
- package/README.md +23 -16
- package/mcp-apps-template/package.dependencies.json +2 -2
- package/mcp-apps-template/src/routes/.well-known/oauth-protected-resource/api/mcp/+server.ts +10 -6
- package/mcp-apps-template/src/routes/api/mcp/+server.ts +68 -12
- package/package.json +19 -15
- package/template/AGENTS.md +20 -5
- package/template/Dockerfile +0 -1
- package/template/INSTALL_PROMPT.md +2 -2
- package/template/README.md +86 -40
- package/template/compose.yaml +2 -2
- package/template/package.json +28 -27
- package/template/smrt.config.ts +16 -34
- package/template/src/app.d.ts +4 -11
- package/template/src/hooks.server.ts +10 -51
- package/template/src/lib/server/smrt.ts +22 -98
- package/template/src/routes/+layout.server.ts +4 -12
- package/template/src/routes/+layout.svelte +27 -99
- package/template/src/routes/+page.server.ts +4 -4
- package/template/src/routes/api/_runtime/diagnostics/+server.ts +17 -3
- package/template/src/routes/api/_runtime/health/+server.ts +4 -28
- package/template/src/routes/settings/+page.svelte +3 -34
- package/template/src/routes/setup/+page.server.ts +7 -94
- package/template/src/routes/setup/+page.svelte +3 -23
- package/template/vite.config.ts +5 -43
- package/template.config.js +11 -11
- package/mcp-apps-template/src/lib/McpAppsBridge.svelte +0 -37
- package/mcp-apps-template/src/lib/server/mcp-hosted-principal.ts +0 -12
- package/mcp-apps-template/src/lib/server/mcp-hosted.ts +0 -28
- package/mcp-apps-template/src/lib/server/mcp.ts +0 -85
- package/template/scripts/smrt-app.mjs +0 -885
- package/template/scripts/smrt-mcp-apps.mjs +0 -18
- package/template/scripts/smrt-operation-lock.mjs +0 -102
- package/template/scripts/smrt-portability-assets.mjs +0 -707
- package/template/scripts/smrt-portability.mjs +0 -470
- package/template/scripts/smrt-prepare-migration.mjs +0 -93
- package/template/scripts/smrt-process.mjs +0 -82
- package/template/scripts/smrt-provider-readiness.mjs +0 -33
- package/template/scripts/smrt-runtime-identity.mjs +0 -245
- package/template/scripts/smrt-vite.mjs +0 -45
- package/template/scripts/smrt-web.mjs +0 -10
- package/template/scripts/smrt-worker.mjs +0 -100
- package/template/scripts/smrt-writer-lease.mjs +0 -199
- package/template/src/lib/RuntimeDiagnosticsWebMcp.svelte +0 -11
- package/template/src/lib/runtime-diagnostics-webmcp.ts +0 -108
- package/template/src/lib/server/application-runtime.ts +0 -262
- package/template/src/lib/server/runtime-diagnostics.ts +0 -114
- package/template/src/lib/server/tenancy.ts +0 -114
- package/template/src/smrt-webmcp.d.ts +0 -6
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createMcpAppServer,
|
|
3
|
-
type McpAppPrincipal,
|
|
4
|
-
type McpWorkflowToolDefinition,
|
|
5
|
-
} from '@happyvertical/smrt-app-mcp';
|
|
6
|
-
import { openAiDisplayMetadata, withOpenAiEntrypoints } from '@happyvertical/smrt-mcp-openai';
|
|
7
|
-
import { getApplicationDatabaseConfig } from './application-runtime.js';
|
|
8
|
-
|
|
9
|
-
const ITEM_RESOURCE_URI = 'ui://smrt-app/v1/items.html';
|
|
10
|
-
const itemResourceHtml = `<!doctype html><html lang="en"><head><title>Items</title></head><body><main tabindex="-1"><h1>Items</h1><p>Use the host controls to review your authorized items.</p></main></body></html>`;
|
|
11
|
-
|
|
12
|
-
const itemsOverview: McpWorkflowToolDefinition = withOpenAiEntrypoints(
|
|
13
|
-
{
|
|
14
|
-
name: 'items_overview',
|
|
15
|
-
description: 'Open the authorized item overview.',
|
|
16
|
-
title: 'Items',
|
|
17
|
-
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
18
|
-
outputSchema: {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: { state: { type: 'string' } },
|
|
21
|
-
required: ['state'],
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
},
|
|
24
|
-
effect: 'read',
|
|
25
|
-
idempotent: true,
|
|
26
|
-
openWorld: false,
|
|
27
|
-
ui: { resourceUri: ITEM_RESOURCE_URI },
|
|
28
|
-
async execute() {
|
|
29
|
-
return {
|
|
30
|
-
content: [{ type: 'text', text: 'Item overview is ready.' }],
|
|
31
|
-
structuredContent: { state: 'ready' },
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
['global'],
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The session hook resolves membership and permissions for every request. This
|
|
40
|
-
* adapter only projects that trusted, request-local result; headers and route
|
|
41
|
-
* arguments are never identity inputs.
|
|
42
|
-
*/
|
|
43
|
-
export function resolveMcpPrincipal(event: {
|
|
44
|
-
locals?: Record<string, unknown>;
|
|
45
|
-
}): McpAppPrincipal | null {
|
|
46
|
-
const user = event.locals?.user as { id?: unknown } | undefined;
|
|
47
|
-
const tenantId = event.locals?.tenantId;
|
|
48
|
-
const permissions = event.locals?.permissions;
|
|
49
|
-
if (typeof user?.id !== 'string' || typeof tenantId !== 'string') return null;
|
|
50
|
-
if (!Array.isArray(permissions) || !permissions.every((value) => typeof value === 'string'))
|
|
51
|
-
return null;
|
|
52
|
-
return {
|
|
53
|
-
id: user.id,
|
|
54
|
-
tenantId,
|
|
55
|
-
kind: 'human',
|
|
56
|
-
scopes: [...permissions].sort(),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const mcpServer = createMcpAppServer({
|
|
61
|
-
smrtOptions: () => ({ db: getApplicationDatabaseConfig() }),
|
|
62
|
-
serverInfo: { name: 'smrt-app', version: '0.1.0' },
|
|
63
|
-
allowedClassNames: ['Item'],
|
|
64
|
-
workflowTools: [itemsOverview],
|
|
65
|
-
resources: [
|
|
66
|
-
{
|
|
67
|
-
uri: ITEM_RESOURCE_URI,
|
|
68
|
-
version: 'v1',
|
|
69
|
-
name: 'Items',
|
|
70
|
-
html: itemResourceHtml,
|
|
71
|
-
csp: {},
|
|
72
|
-
metadata: openAiDisplayMetadata({ availableDisplayModes: ['inline'] }),
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
toolPolicy: ({ principal }) =>
|
|
76
|
-
principal?.kind === 'human' &&
|
|
77
|
-
typeof principal.id === 'string' &&
|
|
78
|
-
typeof principal.tenantId === 'string' &&
|
|
79
|
-
principal.scopes?.includes('items.read') === true,
|
|
80
|
-
resourcePolicy: ({ principal }) =>
|
|
81
|
-
principal?.kind === 'human' &&
|
|
82
|
-
typeof principal.id === 'string' &&
|
|
83
|
-
typeof principal.tenantId === 'string' &&
|
|
84
|
-
principal.scopes?.includes('items.read') === true,
|
|
85
|
-
});
|