capable-kit 0.0.1-alpha.7 → 0.1.0-alpha.10
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/CHANGELOG.md +214 -0
- package/README.md +6 -0
- package/dist/ai-sdk.d.mts +3 -3
- package/dist/ai-sdk.mjs +9 -7
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +2 -2
- package/dist/bin.mjs +12 -9
- package/dist/bin.mjs.map +1 -1
- package/dist/cli.d.mts +9 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +82 -5
- package/dist/eve.mjs +364 -23
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-Dbc4g9WM.d.mts → index-1A44jLuE.d.mts} +54 -16
- package/dist/{index-DwXlaTXI.d.mts → index-CHuCLJIs.d.mts} +20 -4
- package/dist/{index-D2CRRUzH.d.mts → index-D-NV4PiU.d.mts} +6 -5
- package/dist/{index-Be8-UVBC.d.mts → index-WiBWfyTn.d.mts} +66 -27
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/mcp.d.mts +40 -5
- package/dist/mcp.mjs +1 -1
- package/dist/mount-BmLHp349.mjs +235 -0
- package/dist/mount-BmLHp349.mjs.map +1 -0
- package/dist/react-query.d.mts +2 -2
- package/dist/react-query.mjs +1 -1
- package/dist/react-query.mjs.map +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +8 -8
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-Db6-XSnU.mjs → src-3LE9S4QE.mjs} +67 -38
- package/dist/src-3LE9S4QE.mjs.map +1 -0
- package/dist/{src-DdV82An-.mjs → src-B2WeUwUT.mjs} +69 -34
- package/dist/src-B2WeUwUT.mjs.map +1 -0
- package/dist/{src-CDxL6w3d.mjs → src-C5jGDnuu.mjs} +9 -6
- package/dist/src-C5jGDnuu.mjs.map +1 -0
- package/dist/src-DePlcG_t.mjs +787 -0
- package/dist/src-DePlcG_t.mjs.map +1 -0
- package/dist/{src-BF70JLxI.mjs → src-_6OmFRYa.mjs} +185 -38
- package/dist/src-_6OmFRYa.mjs.map +1 -0
- package/dist/{subscription-Bq792Ad2.d.mts → subscription-DPdwovhw.d.mts} +2 -2
- package/dist/swr.d.mts +2 -2
- package/dist/swr.mjs +1 -1
- package/dist/swr.mjs.map +1 -1
- package/docs/CONTEXT.md +42 -21
- package/docs/README.md +3 -0
- package/docs/internal/README.md +3 -0
- package/docs/internal/adr/0001-capability-is-the-semantic-boundary.md +1 -1
- package/docs/internal/adr/0002-version-the-capable-value-codec.md +24 -0
- package/docs/internal/adr/0003-capability-reference-customization.md +68 -0
- package/docs/internal/architecture.md +64 -19
- package/docs/internal/capability-first-model.md +127 -18
- package/docs/internal/eve-recovery-validation.md +86 -0
- package/docs/internal/feedback/v-ray/README.md +258 -0
- package/docs/internal/feedback/v-ray/inference.mjs +43 -0
- package/docs/internal/feedback/v-ray/reproduce.mjs +36 -0
- package/docs/internal/implementation-friction.md +481 -1
- package/docs/internal/releases.md +79 -0
- package/docs/site/capable-orpc-and-trpc.mdx +5 -5
- package/docs/site/concepts/apps.mdx +17 -8
- package/docs/site/concepts/architecture.mdx +10 -2
- package/docs/site/concepts/capabilities.mdx +41 -4
- package/docs/site/concepts/errors.mdx +11 -1
- package/docs/site/concepts/presentations.mdx +20 -0
- package/docs/site/hosting/any-fetch-host.mdx +2 -2
- package/docs/site/hosting/next-js.mdx +38 -4
- package/docs/site/hosting/standalone-server.mdx +2 -2
- package/docs/site/introduction.mdx +9 -6
- package/docs/site/patterns/composition.mdx +159 -11
- package/docs/site/patterns/remote-apps.mdx +68 -10
- package/docs/site/patterns/subscriptions.mdx +79 -32
- package/docs/site/quickstart.mdx +19 -14
- package/docs/site/reference/packages-and-entry-points.mdx +52 -5
- package/docs/site/reference/surface-metadata.mdx +7 -2
- package/docs/site/reference/the-cap-cli.mdx +2 -2
- package/docs/site/surfaces/ai-sdk.mdx +3 -3
- package/docs/site/surfaces/cli.mdx +47 -3
- package/docs/site/surfaces/eve.mdx +67 -20
- package/docs/site/surfaces/mcp.mdx +73 -5
- package/docs/site/surfaces/react-query.mdx +3 -3
- package/docs/site/surfaces/swr.mdx +3 -3
- package/docs/site/surfaces/typescript.mdx +8 -8
- package/docs/site/surfaces.mdx +1 -1
- package/package-docs.mjs +3 -0
- package/package.json +11 -11
- package/src/bin.ts +0 -0
- package/src/index.test.ts +2 -1
- package/src/index.ts +6 -1
- package/src/mcp.ts +4 -0
- package/src/package.test.ts +9 -0
- package/dist/mount-xvMsjz1B.mjs +0 -178
- package/dist/mount-xvMsjz1B.mjs.map +0 -1
- package/dist/src-BF70JLxI.mjs.map +0 -1
- package/dist/src-C2MGIlT0.mjs +0 -464
- package/dist/src-C2MGIlT0.mjs.map +0 -1
- package/dist/src-CDxL6w3d.mjs.map +0 -1
- package/dist/src-Db6-XSnU.mjs.map +0 -1
- package/dist/src-DdV82An-.mjs.map +0 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { y as renderPresentationMarkdown } from "./src-B2WeUwUT.mjs";
|
|
2
|
+
import { a as getCapabilityNavigationMeta, c as TransportError, d as getAppRuntime, h as flattenManifestCapabilities, i as getCapabilityDisplay, l as createApp, n as selectApp } from "./src-DePlcG_t.mjs";
|
|
3
|
+
import { Server, createMcpHandler } from "@modelcontextprotocol/server";
|
|
4
|
+
//#region packages/mcp/src/index.ts
|
|
5
|
+
async function createMcp(app) {
|
|
6
|
+
const runtime = getAppRuntime(app);
|
|
7
|
+
const tools = flattenManifestCapabilities((await runtime.manifest()).capabilities).map((capability) => ({
|
|
8
|
+
...capability,
|
|
9
|
+
...getCapabilityDisplay(capability)
|
|
10
|
+
})).filter((capability) => {
|
|
11
|
+
const meta = capability.meta.mcp;
|
|
12
|
+
if (meta === false) return false;
|
|
13
|
+
if (capability.execution !== "events") return true;
|
|
14
|
+
if (meta !== void 0) throw new Error(`Event Capability "${capability.id}" cannot be exposed as an MCP tool`);
|
|
15
|
+
return false;
|
|
16
|
+
}).map((capability) => {
|
|
17
|
+
const meta = readMcpMeta(capability);
|
|
18
|
+
const navigation = getCapabilityNavigationMeta(capability, "mcp");
|
|
19
|
+
const name = navigation === false ? void 0 : navigation?.name;
|
|
20
|
+
return Object.freeze({
|
|
21
|
+
name: name ?? capability.path.join("__"),
|
|
22
|
+
...capability.title ? { title: capability.title } : {},
|
|
23
|
+
...capability.description ? { description: capability.description } : {},
|
|
24
|
+
...meta?.icons ? { icons: meta.icons } : {},
|
|
25
|
+
inputSchema: capability.input ?? {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
},
|
|
30
|
+
...capability.output ? { outputSchema: capability.output } : {},
|
|
31
|
+
_meta: { "dev.capable/capabilityId": capability.id },
|
|
32
|
+
annotations: {
|
|
33
|
+
readOnlyHint: capability.effect === "read",
|
|
34
|
+
destructiveHint: capability.effect === "destructive",
|
|
35
|
+
...meta?.idempotentHint !== void 0 ? { idempotentHint: meta.idempotentHint } : {},
|
|
36
|
+
...meta?.openWorldHint !== void 0 ? { openWorldHint: meta.openWorldHint } : {}
|
|
37
|
+
},
|
|
38
|
+
call(input, options) {
|
|
39
|
+
return runtime.call({
|
|
40
|
+
id: capability.id,
|
|
41
|
+
input,
|
|
42
|
+
presentation: true,
|
|
43
|
+
...options?.signal ? { signal: options.signal } : {}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const names = /* @__PURE__ */ new Set();
|
|
49
|
+
for (const tool of tools) {
|
|
50
|
+
if (names.has(tool.name)) throw new Error(`Duplicate MCP tool name "${tool.name}"`);
|
|
51
|
+
names.add(tool.name);
|
|
52
|
+
}
|
|
53
|
+
return tools;
|
|
54
|
+
}
|
|
55
|
+
function readMcpMeta(capability) {
|
|
56
|
+
const value = capability.meta.mcp;
|
|
57
|
+
if (value === void 0) return void 0;
|
|
58
|
+
if (!isRecord(value)) return invalidMcpMeta(capability, "must be an object");
|
|
59
|
+
if (value.name !== void 0 && typeof value.name !== "string") return invalidMcpMeta(capability, "name must be a string");
|
|
60
|
+
if (value.idempotentHint !== void 0 && typeof value.idempotentHint !== "boolean") return invalidMcpMeta(capability, "idempotentHint must be a boolean");
|
|
61
|
+
if (value.openWorldHint !== void 0 && typeof value.openWorldHint !== "boolean") return invalidMcpMeta(capability, "openWorldHint must be a boolean");
|
|
62
|
+
if (value.icons !== void 0 && (!Array.isArray(value.icons) || !value.icons.every(isMcpIcon))) return invalidMcpMeta(capability, "icons must be MCP icon descriptors");
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function isMcpIcon(value) {
|
|
66
|
+
if (!isRecord(value) || typeof value.src !== "string") return false;
|
|
67
|
+
if (value.mimeType !== void 0 && typeof value.mimeType !== "string") return false;
|
|
68
|
+
if (value.sizes !== void 0 && (!Array.isArray(value.sizes) || !value.sizes.every((size) => typeof size === "string"))) return false;
|
|
69
|
+
return value.theme === void 0 || value.theme === "light" || value.theme === "dark";
|
|
70
|
+
}
|
|
71
|
+
function isRecord(value) {
|
|
72
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
73
|
+
}
|
|
74
|
+
function invalidMcpMeta(capability, reason) {
|
|
75
|
+
throw new Error(`Capability "${capability.id}" has invalid MCP metadata: ${reason}`);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region packages/mcp/src/presentation.ts
|
|
79
|
+
function toMcpContent(presentation, output) {
|
|
80
|
+
if (!presentation?.length) return [{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: stringify(output)
|
|
83
|
+
}];
|
|
84
|
+
const content = [];
|
|
85
|
+
for (const part of presentation) {
|
|
86
|
+
if (part.type === "markdown") {
|
|
87
|
+
content.push({
|
|
88
|
+
type: "text",
|
|
89
|
+
text: renderPresentationMarkdown(part)
|
|
90
|
+
});
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (part.type === "table") {
|
|
94
|
+
content.push({
|
|
95
|
+
type: "text",
|
|
96
|
+
text: renderPresentationMarkdown(part)
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (part.type === "image") {
|
|
101
|
+
content.push({
|
|
102
|
+
type: "text",
|
|
103
|
+
text: `[Image: ${part.alt}]`
|
|
104
|
+
}, {
|
|
105
|
+
type: "image",
|
|
106
|
+
data: part.base64,
|
|
107
|
+
mimeType: part.mimeType
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
content.push({
|
|
112
|
+
type: "resource_link",
|
|
113
|
+
uri: part.url,
|
|
114
|
+
name: part.name,
|
|
115
|
+
...part.description ? { description: part.description } : {},
|
|
116
|
+
...part.mimeType ? { mimeType: part.mimeType } : {},
|
|
117
|
+
...part.size === void 0 ? {} : { size: part.size }
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return content;
|
|
121
|
+
}
|
|
122
|
+
function stringify(value) {
|
|
123
|
+
return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region packages/mcp/src/mount.ts
|
|
127
|
+
function mcp(options = {}) {
|
|
128
|
+
validateCacheHint(options.cache?.discovery, "discovery");
|
|
129
|
+
validateCacheHint(options.cache?.tools, "tools");
|
|
130
|
+
const path = normalizePath(options.path ?? "/mcp");
|
|
131
|
+
return {
|
|
132
|
+
kind: "capable.server.mount",
|
|
133
|
+
compile(app, context, onError) {
|
|
134
|
+
const description = options.description ?? app.description;
|
|
135
|
+
const handler = createMcpHandler(async ({ requestInfo }) => {
|
|
136
|
+
try {
|
|
137
|
+
if (!requestInfo) throw new Error("The MCP HTTP handler requires request information");
|
|
138
|
+
const executable = createApp(app, context ? { context: () => context({ request: requestInfo }) } : void 0);
|
|
139
|
+
return createMcpServer(await createMcp(options.selection ? selectApp(executable, options.selection) : executable), {
|
|
140
|
+
name: options.name ?? app.name ?? "capable",
|
|
141
|
+
version: options.version ?? app.version ?? "0.0.0",
|
|
142
|
+
...options.title !== void 0 ? { title: options.title } : {},
|
|
143
|
+
...description !== void 0 ? { description } : {},
|
|
144
|
+
...options.websiteUrl !== void 0 ? { websiteUrl: options.websiteUrl } : {},
|
|
145
|
+
...options.icons !== void 0 ? { icons: toProtocolIcons(options.icons) } : {}
|
|
146
|
+
}, options);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
onError?.(error);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}, { legacy: "stateless" });
|
|
152
|
+
return {
|
|
153
|
+
name: "mcp",
|
|
154
|
+
async fetch(request) {
|
|
155
|
+
if (new URL(request.url).pathname !== path) return void 0;
|
|
156
|
+
return handler.fetch(request);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function createMcpServer(tools, info, options) {
|
|
163
|
+
const server = new Server(info, {
|
|
164
|
+
capabilities: { tools: {} },
|
|
165
|
+
...options.instructions !== void 0 ? { instructions: options.instructions } : {},
|
|
166
|
+
...options.cache !== void 0 ? { cacheHints: {
|
|
167
|
+
...options.cache.discovery !== void 0 ? { "server/discover": options.cache.discovery } : {},
|
|
168
|
+
...options.cache.tools !== void 0 ? { "tools/list": options.cache.tools } : {}
|
|
169
|
+
} } : {}
|
|
170
|
+
});
|
|
171
|
+
server.setRequestHandler("tools/list", () => ({ tools: tools.map(toProtocolTool) }));
|
|
172
|
+
server.setRequestHandler("tools/call", async (request, context) => {
|
|
173
|
+
const tool = tools.find(({ name }) => name === request.params.name);
|
|
174
|
+
if (!tool) return toolError(`Unknown tool "${request.params.name}"`);
|
|
175
|
+
try {
|
|
176
|
+
const result = await tool.call(request.params.arguments ?? {}, { signal: context.mcpReq.signal });
|
|
177
|
+
return server.projectCallToolResult({
|
|
178
|
+
content: toMcpContent(result.presentation, result.output),
|
|
179
|
+
structuredContent: result.output
|
|
180
|
+
}, tool.outputSchema);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (!(error instanceof TransportError)) throw error;
|
|
183
|
+
return toolError(error.message, {
|
|
184
|
+
code: error.code,
|
|
185
|
+
status: error.status,
|
|
186
|
+
data: error.data
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return server;
|
|
191
|
+
}
|
|
192
|
+
function toProtocolTool(tool) {
|
|
193
|
+
return {
|
|
194
|
+
name: tool.name,
|
|
195
|
+
...tool.title ? { title: tool.title } : {},
|
|
196
|
+
...tool.description ? { description: tool.description } : {},
|
|
197
|
+
...tool.icons ? { icons: toProtocolIcons(tool.icons) } : {},
|
|
198
|
+
inputSchema: tool.inputSchema,
|
|
199
|
+
...tool.outputSchema ? { outputSchema: tool.outputSchema } : {},
|
|
200
|
+
_meta: tool._meta,
|
|
201
|
+
annotations: tool.annotations
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function toProtocolIcons(icons) {
|
|
205
|
+
return icons.map((icon) => ({
|
|
206
|
+
src: icon.src,
|
|
207
|
+
...icon.mimeType !== void 0 ? { mimeType: icon.mimeType } : {},
|
|
208
|
+
...icon.sizes !== void 0 ? { sizes: [...icon.sizes] } : {},
|
|
209
|
+
...icon.theme !== void 0 ? { theme: icon.theme } : {}
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
function toolError(message, details) {
|
|
213
|
+
return {
|
|
214
|
+
isError: true,
|
|
215
|
+
content: [{
|
|
216
|
+
type: "text",
|
|
217
|
+
text: details ? JSON.stringify({
|
|
218
|
+
message,
|
|
219
|
+
...details
|
|
220
|
+
}) : message
|
|
221
|
+
}]
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function normalizePath(value) {
|
|
225
|
+
return `/${value.split("/").filter(Boolean).join("/")}`;
|
|
226
|
+
}
|
|
227
|
+
function validateCacheHint(hint, field) {
|
|
228
|
+
if (!hint) return;
|
|
229
|
+
if (hint.ttlMs !== void 0 && (!Number.isSafeInteger(hint.ttlMs) || hint.ttlMs < 0)) throw new RangeError(`MCP ${field} cache ttlMs must be a non-negative safe integer`);
|
|
230
|
+
if (hint.cacheScope !== void 0 && hint.cacheScope !== "public" && hint.cacheScope !== "private") throw new RangeError(`MCP ${field} cache cacheScope must be "public" or "private"`);
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
export { createMcp as n, mcp as t };
|
|
234
|
+
|
|
235
|
+
//# sourceMappingURL=mount-BmLHp349.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-BmLHp349.mjs","names":[],"sources":["../../mcp/src/index.ts","../../mcp/src/presentation.ts","../../mcp/src/mount.ts"],"sourcesContent":["import type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n getAppRuntime,\n getCapabilityDisplay,\n getCapabilityNavigationMeta,\n flattenManifestCapabilities,\n type AnyApp,\n type JsonSchema,\n type ManifestCapability,\n type CapabilityResult,\n} from \"@capable/app\";\n\nexport type McpCapabilityMeta =\n | false\n | {\n readonly name?: string;\n readonly icons?: readonly McpIcon[];\n readonly idempotentHint?: boolean;\n readonly openWorldHint?: boolean;\n };\n\ndeclare global {\n interface CapableCustomizationMeta {\n readonly mcp?: McpCapabilityMeta;\n }\n}\n\nexport type McpIcon = {\n readonly src: string;\n readonly mimeType?: string;\n readonly sizes?: readonly string[];\n readonly theme?: \"light\" | \"dark\";\n};\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly mcp?: McpCapabilityMeta;\n }\n}\n\nexport type McpTool = {\n readonly name: string;\n readonly title?: string;\n readonly description?: string;\n readonly icons?: readonly McpIcon[];\n readonly inputSchema: JsonSchema;\n readonly outputSchema?: JsonSchema;\n readonly _meta: {\n readonly \"dev.capable/capabilityId\": string;\n };\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: boolean;\n readonly idempotentHint?: boolean;\n readonly openWorldHint?: boolean;\n };\n call(\n input: unknown,\n options?: { readonly signal?: AbortSignal },\n ): Promise<CapabilityResult>;\n};\n\nexport async function createMcp(\n app: AnyApp,\n): Promise<readonly McpTool[]> {\n const runtime = getAppRuntime(app);\n const manifest = await runtime.manifest();\n const tools = flattenManifestCapabilities(manifest.capabilities)\n .map((capability) => ({ ...capability, ...getCapabilityDisplay(capability) }))\n .filter((capability) => {\n const meta = capability.meta.mcp;\n if (meta === false) return false;\n if (capability.execution !== \"events\") return true;\n if (meta !== undefined) {\n throw new Error(\n `Event Capability \"${capability.id}\" cannot be exposed as an MCP tool`,\n );\n }\n return false;\n })\n .map((capability) => {\n const meta = readMcpMeta(capability);\n const navigation = getCapabilityNavigationMeta(capability, \"mcp\");\n const name = navigation === false ? undefined : navigation?.name;\n return Object.freeze({\n name: name ?? capability.path.join(\"__\"),\n ...(capability.title ? { title: capability.title } : {}),\n ...(capability.description ? { description: capability.description } : {}),\n ...(meta?.icons ? { icons: meta.icons } : {}),\n inputSchema: capability.input ?? {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n ...(capability.output\n ? { outputSchema: capability.output }\n : {}),\n _meta: {\n \"dev.capable/capabilityId\": capability.id,\n },\n annotations: {\n readOnlyHint: capability.effect === \"read\",\n destructiveHint: capability.effect === \"destructive\",\n ...(meta?.idempotentHint !== undefined\n ? { idempotentHint: meta.idempotentHint }\n : {}),\n ...(meta?.openWorldHint !== undefined\n ? { openWorldHint: meta.openWorldHint }\n : {}),\n },\n call(input: unknown, options?: { readonly signal?: AbortSignal }) {\n return runtime.call({\n id: capability.id,\n input,\n presentation: true,\n ...(options?.signal ? { signal: options.signal } : {}),\n });\n },\n });\n });\n const names = new Set<string>();\n for (const tool of tools) {\n if (names.has(tool.name)) {\n throw new Error(`Duplicate MCP tool name \"${tool.name}\"`);\n }\n names.add(tool.name);\n }\n return tools;\n}\n\nfunction readMcpMeta(\n capability: ManifestCapability,\n): Exclude<McpCapabilityMeta, false> | undefined {\n const value = capability.meta.mcp;\n if (value === undefined) return undefined;\n if (!isRecord(value)) return invalidMcpMeta(capability, \"must be an object\");\n if (value.name !== undefined && typeof value.name !== \"string\") {\n return invalidMcpMeta(capability, \"name must be a string\");\n }\n if (\n value.idempotentHint !== undefined &&\n typeof value.idempotentHint !== \"boolean\"\n ) {\n return invalidMcpMeta(capability, \"idempotentHint must be a boolean\");\n }\n if (\n value.openWorldHint !== undefined &&\n typeof value.openWorldHint !== \"boolean\"\n ) {\n return invalidMcpMeta(capability, \"openWorldHint must be a boolean\");\n }\n if (\n value.icons !== undefined &&\n (!Array.isArray(value.icons) || !value.icons.every(isMcpIcon))\n ) {\n return invalidMcpMeta(capability, \"icons must be MCP icon descriptors\");\n }\n return value as Exclude<McpCapabilityMeta, false>;\n}\n\nfunction isMcpIcon(value: unknown): value is McpIcon {\n if (!isRecord(value) || typeof value.src !== \"string\") return false;\n if (value.mimeType !== undefined && typeof value.mimeType !== \"string\") {\n return false;\n }\n if (\n value.sizes !== undefined &&\n (!Array.isArray(value.sizes) ||\n !value.sizes.every((size) => typeof size === \"string\"))\n ) {\n return false;\n }\n return value.theme === undefined || value.theme === \"light\" ||\n value.theme === \"dark\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction invalidMcpMeta(\n capability: ManifestCapability,\n reason: string,\n): never {\n throw new Error(\n `Capability \"${capability.id}\" has invalid MCP metadata: ${reason}`,\n );\n}\n","import {\n renderPresentationMarkdown,\n type PresentationPart,\n} from \"@capable/core\";\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n\nexport function toMcpContent(\n presentation: readonly PresentationPart[] | undefined,\n output: unknown,\n): CallToolResult[\"content\"] {\n if (!presentation?.length) {\n return [{ type: \"text\", text: stringify(output) }];\n }\n const content: CallToolResult[\"content\"] = [];\n for (const part of presentation) {\n if (part.type === \"markdown\") {\n content.push({ type: \"text\", text: renderPresentationMarkdown(part) });\n continue;\n }\n if (part.type === \"table\") {\n content.push({\n type: \"text\",\n text: renderPresentationMarkdown(part),\n });\n continue;\n }\n if (part.type === \"image\") {\n content.push(\n { type: \"text\", text: `[Image: ${part.alt}]` },\n {\n type: \"image\",\n data: part.base64,\n mimeType: part.mimeType,\n },\n );\n continue;\n }\n content.push({\n type: \"resource_link\",\n uri: part.url,\n name: part.name,\n ...(part.description ? { description: part.description } : {}),\n ...(part.mimeType ? { mimeType: part.mimeType } : {}),\n ...(part.size === undefined ? {} : { size: part.size }),\n });\n }\n return content;\n}\n\nfunction stringify(value: unknown): string {\n return typeof value === \"string\"\n ? value\n : JSON.stringify(value) ?? String(value);\n}\n","import type { ServerMount } from \"@capable/server\";\nimport {\n createApp,\n selectApp,\n TransportError,\n type ApplicationSelection,\n} from \"@capable/app\";\nimport {\n createMcpHandler,\n Server,\n type CallToolResult,\n type Icon,\n type Implementation,\n type Tool,\n} from \"@modelcontextprotocol/server\";\nimport {\n createMcp,\n type McpIcon,\n type McpTool,\n} from \"./index.ts\";\nimport { toMcpContent } from \"./presentation.ts\";\n\nexport type McpCacheHint = {\n readonly ttlMs?: number;\n readonly cacheScope?: \"public\" | \"private\";\n};\n\nexport type McpMountOptions = {\n readonly path?: string;\n readonly name?: string;\n readonly version?: string;\n readonly title?: string;\n readonly description?: string;\n readonly websiteUrl?: string;\n readonly icons?: readonly McpIcon[];\n readonly instructions?: string;\n readonly selection?: ApplicationSelection;\n readonly cache?: {\n readonly discovery?: McpCacheHint;\n readonly tools?: McpCacheHint;\n };\n};\n\nexport function mcp<TContext = any>(\n options: McpMountOptions = {},\n): ServerMount<TContext> {\n validateCacheHint(options.cache?.discovery, \"discovery\");\n validateCacheHint(options.cache?.tools, \"tools\");\n const path = normalizePath(options.path ?? \"/mcp\");\n return {\n kind: \"capable.server.mount\",\n compile(app, context, onError) {\n const description = options.description ?? app.description;\n const handler = createMcpHandler(async ({ requestInfo }) => {\n try {\n if (!requestInfo) {\n throw new Error(\n \"The MCP HTTP handler requires request information\",\n );\n }\n const executable = createApp(\n app,\n context\n ? { context: () => context({ request: requestInfo }) }\n : undefined as never,\n );\n const exposed = options.selection\n ? selectApp(executable, options.selection)\n : executable;\n const tools = await createMcp(exposed);\n return createMcpServer(tools, {\n name: options.name ?? app.name ?? \"capable\",\n version: options.version ?? app.version ?? \"0.0.0\",\n ...(options.title !== undefined ? { title: options.title } : {}),\n ...(description !== undefined\n ? { description }\n : {}),\n ...(options.websiteUrl !== undefined\n ? { websiteUrl: options.websiteUrl }\n : {}),\n ...(options.icons !== undefined\n ? { icons: toProtocolIcons(options.icons) }\n : {}),\n }, options);\n } catch (error) {\n onError?.(error);\n throw error;\n }\n }, {\n legacy: \"stateless\",\n });\n return {\n name: \"mcp\",\n async fetch(request) {\n if (new URL(request.url).pathname !== path) return undefined;\n return handler.fetch(request);\n },\n };\n },\n };\n}\n\nfunction createMcpServer(\n tools: readonly McpTool[],\n info: Implementation,\n options: Pick<McpMountOptions, \"instructions\" | \"cache\">,\n): Server {\n const server = new Server(info, {\n capabilities: { tools: {} },\n ...(options.instructions !== undefined\n ? { instructions: options.instructions }\n : {}),\n ...(options.cache !== undefined\n ? {\n cacheHints: {\n ...(options.cache.discovery !== undefined\n ? { \"server/discover\": options.cache.discovery }\n : {}),\n ...(options.cache.tools !== undefined\n ? { \"tools/list\": options.cache.tools }\n : {}),\n },\n }\n : {}),\n });\n server.setRequestHandler(\"tools/list\", () => ({\n tools: tools.map(toProtocolTool),\n }));\n server.setRequestHandler(\"tools/call\", async (request, context) => {\n const tool = tools.find(({ name }) => name === request.params.name);\n if (!tool) {\n return toolError(`Unknown tool \"${request.params.name}\"`);\n }\n try {\n const result = await tool.call(request.params.arguments ?? {}, {\n signal: context.mcpReq.signal,\n });\n return server.projectCallToolResult({\n content: toMcpContent(result.presentation, result.output),\n structuredContent: result.output,\n } satisfies CallToolResult, tool.outputSchema);\n } catch (error) {\n if (!(error instanceof TransportError)) throw error;\n return toolError(error.message, {\n code: error.code,\n status: error.status,\n data: error.data,\n });\n }\n });\n return server;\n}\n\nfunction toProtocolTool(tool: McpTool): Tool {\n return {\n name: tool.name,\n ...(tool.title ? { title: tool.title } : {}),\n ...(tool.description ? { description: tool.description } : {}),\n ...(tool.icons ? { icons: toProtocolIcons(tool.icons) } : {}),\n inputSchema: tool.inputSchema as Tool[\"inputSchema\"],\n ...(tool.outputSchema\n ? { outputSchema: tool.outputSchema as Tool[\"outputSchema\"] }\n : {}),\n _meta: tool._meta,\n annotations: tool.annotations,\n };\n}\n\nfunction toProtocolIcons(icons: readonly McpIcon[]): Icon[] {\n return icons.map((icon) => ({\n src: icon.src,\n ...(icon.mimeType !== undefined ? { mimeType: icon.mimeType } : {}),\n ...(icon.sizes !== undefined ? { sizes: [...icon.sizes] } : {}),\n ...(icon.theme !== undefined ? { theme: icon.theme } : {}),\n }));\n}\n\nfunction toolError(\n message: string,\n details?: Record<string, unknown>,\n): CallToolResult {\n return {\n isError: true,\n content: [{\n type: \"text\",\n text: details ? JSON.stringify({ message, ...details }) : message,\n }],\n };\n}\n\nfunction normalizePath(value: string): string {\n return `/${value.split(\"/\").filter(Boolean).join(\"/\")}`;\n}\n\nfunction validateCacheHint(\n hint: McpCacheHint | undefined,\n field: \"discovery\" | \"tools\",\n): void {\n if (!hint) return;\n if (\n hint.ttlMs !== undefined &&\n (!Number.isSafeInteger(hint.ttlMs) || hint.ttlMs < 0)\n ) {\n throw new RangeError(\n `MCP ${field} cache ttlMs must be a non-negative safe integer`,\n );\n }\n if (\n hint.cacheScope !== undefined &&\n hint.cacheScope !== \"public\" &&\n hint.cacheScope !== \"private\"\n ) {\n throw new RangeError(\n `MCP ${field} cache cacheScope must be \"public\" or \"private\"`,\n );\n }\n}\n"],"mappings":";;;;AA8DA,eAAsB,UACpB,KAC6B;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.mjs";
|
|
2
2
|
import { QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
3
3
|
//#region packages/react-query/src/index.d.ts
|
|
4
4
|
type CapabilityCall = (...args: any[]) => Promise<any>;
|
|
@@ -24,7 +24,7 @@ type ReactQueryLiveCapability<TCall extends CapabilityCall> = ReactQueryCapabili
|
|
|
24
24
|
readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
type ReactQueryNode<TValue> = TValue extends CapabilityCall ?
|
|
27
|
+
type ReactQueryNode<TValue> = TValue extends CapabilityCall ? AppCapabilityIsLive<TValue> extends true ? ReactQueryLiveCapability<TValue> : ReactQueryCapability<TValue> : TValue extends object ? { readonly [TKey in Extract<keyof TValue, string> as TValue[TKey] extends AppCapabilityReference ? TValue[TKey] extends CapabilityCall ? TKey : never : TKey]: ReactQueryNode<TValue[TKey]>; } : never;
|
|
28
28
|
type ReactQueryApp<TApp extends object> = ReactQueryNode<TApp>;
|
|
29
29
|
declare function createReactQuery<const TApp extends object>(app: TApp, options?: {
|
|
30
30
|
readonly keyPrefix?: QueryKey;
|
package/dist/react-query.mjs
CHANGED
package/dist/react-query.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.mjs","names":[],"sources":["../../react-query/src/index.ts"],"sourcesContent":["import {\n subscribe,\n type
|
|
1
|
+
{"version":3,"file":"react-query.mjs","names":[],"sources":["../../react-query/src/index.ts"],"sourcesContent":["import {\n subscribe,\n type AppCapabilityIsLive,\n type AppCapabilityReference,\n} from \"@capable/app\";\nimport {\n experimental_streamedQuery,\n type QueryFunction,\n type QueryKey,\n type UseMutationOptions,\n type UseQueryOptions,\n} from \"@tanstack/react-query\";\n\ntype CapabilityCall = (...args: any[]) => Promise<any>;\n\nconst subscribeCall = subscribe as unknown as (\n capabilityCall: CapabilityCall,\n input: unknown,\n options: { readonly signal: AbortSignal },\n) => AsyncIterableIterator<unknown>;\n\ntype CapabilityInput<TCall extends CapabilityCall> =\n Exclude<Parameters<TCall>[0], undefined>;\n\ntype CapabilityVariables<TCall extends CapabilityCall> =\n undefined extends Parameters<TCall>[0]\n ? void\n : Parameters<TCall>[0];\n\ntype CapabilityOutput<TCall extends CapabilityCall> =\n Awaited<ReturnType<TCall>>;\n\nexport type CapabilityQueryOptions<\n TCall extends CapabilityCall,\n TData = CapabilityOutput<TCall>,\n> = Omit<\n UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n >,\n \"queryKey\" | \"queryFn\"\n>;\n\nexport type CapabilityMutationOptions<\n TCall extends CapabilityCall,\n TOnMutateResult = unknown,\n> = Omit<\n UseMutationOptions<\n CapabilityOutput<TCall>,\n Error,\n CapabilityVariables<TCall>,\n TOnMutateResult\n >,\n \"mutationKey\" | \"mutationFn\"\n>;\n\nexport type ReactQueryCapability<TCall extends CapabilityCall> = {\n queryKey(input?: CapabilityInput<TCall>): QueryKey;\n queryOptions<TData = CapabilityOutput<TCall>>(\n input: CapabilityInput<TCall>,\n options?: CapabilityQueryOptions<TCall, TData>,\n ): UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n > & {\n readonly queryKey: QueryKey;\n readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;\n };\n mutationOptions<TOnMutateResult = unknown>(\n options?: CapabilityMutationOptions<TCall, TOnMutateResult>,\n ): UseMutationOptions<\n CapabilityOutput<TCall>,\n Error,\n CapabilityVariables<TCall>,\n TOnMutateResult\n > & {\n readonly mutationKey: QueryKey;\n readonly mutationFn: (\n variables: CapabilityVariables<TCall>,\n ) => Promise<CapabilityOutput<TCall>>;\n };\n};\n\nexport type ReactQueryLiveCapability<TCall extends CapabilityCall> =\n ReactQueryCapability<TCall> & {\n liveQueryOptions<TData = CapabilityOutput<TCall>>(\n input: CapabilityInput<TCall>,\n options?: CapabilityQueryOptions<TCall, TData>,\n ): UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n > & {\n readonly queryKey: QueryKey;\n readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;\n };\n };\n\ntype ReactQueryNode<TValue> =\n TValue extends CapabilityCall\n ? AppCapabilityIsLive<TValue> extends true\n ? ReactQueryLiveCapability<TValue>\n : ReactQueryCapability<TValue>\n : TValue extends object\n ? {\n readonly [TKey in Extract<keyof TValue, string> as\n TValue[TKey] extends AppCapabilityReference\n ? TValue[TKey] extends CapabilityCall ? TKey : never\n : TKey]: ReactQueryNode<TValue[TKey]>;\n }\n : never;\n\nexport type ReactQueryApp<TApp extends object> = ReactQueryNode<TApp>;\n\nexport function createReactQuery<const TApp extends object>(\n app: TApp,\n options: {\n readonly keyPrefix?: QueryKey;\n } = {},\n): ReactQueryApp<TApp> {\n const keyPrefix = Object.freeze([...(options.keyPrefix ?? [\"capable\"])]);\n\n const callableAt = (path: readonly string[]): CapabilityCall => {\n let current: unknown = app;\n for (const segment of path) {\n current = (current as Record<string, unknown>)[segment];\n }\n return current as CapabilityCall;\n };\n\n const capabilityKey = (\n path: readonly string[],\n input?: unknown,\n ): QueryKey => Object.freeze([\n ...keyPrefix,\n ...path,\n ...(input === undefined ? [] : [input]),\n ]);\n\n const proxy = (path: readonly string[]): unknown =>\n new Proxy({}, {\n get(_target, key) {\n if (key === \"then\") return undefined;\n if (key === \"queryKey\") {\n return (input?: unknown) => capabilityKey(path, input);\n }\n if (key === \"queryOptions\") {\n return (\n input: unknown,\n queryOptions: Record<string, unknown> = {},\n ) => ({\n ...queryOptions,\n queryKey: capabilityKey(path, input),\n queryFn: ({ signal }: { readonly signal: AbortSignal }) =>\n callableAt(path)(input, { signal }),\n });\n }\n if (key === \"liveQueryOptions\") {\n return (\n input: unknown,\n queryOptions: Record<string, unknown> = {},\n ) => ({\n ...queryOptions,\n queryKey: capabilityKey(path, input),\n queryFn: experimental_streamedQuery<unknown, unknown>({\n streamFn: ({ signal }) =>\n subscribeCall(callableAt(path), input, { signal }),\n reducer: (_current, output) => output,\n initialValue: undefined,\n }) as QueryFunction<unknown, QueryKey>,\n });\n }\n if (key === \"mutationOptions\") {\n return (\n mutationOptions: Record<string, unknown> = {},\n ) => ({\n ...mutationOptions,\n mutationKey: capabilityKey(path),\n mutationFn: (input?: unknown) =>\n callableAt(path)(input ?? {}),\n });\n }\n if (typeof key !== \"string\") return undefined;\n return proxy([...path, key]);\n },\n });\n\n return proxy([]) as ReactQueryApp<TApp>;\n}\n"],"mappings":";;;AAeA,MAAM,gBAAgB;AAwGtB,SAAgB,iBACd,KACA,UAEI,CAAC,GACgB;CACrB,MAAM,YAAY,OAAO,OAAO,CAAC,GAAI,QAAQ,aAAa,CAAC,SAAS,CAAE,CAAC;CAEvE,MAAM,cAAc,SAA4C;EAC9D,IAAI,UAAmB;EACvB,KAAK,MAAM,WAAW,MACpB,UAAW,QAAoC;EAEjD,OAAO;CACT;CAEA,MAAM,iBACJ,MACA,UACa,OAAO,OAAO;EAC3B,GAAG;EACH,GAAG;EACH,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;CACvC,CAAC;CAED,MAAM,SAAS,SACb,IAAI,MAAM,CAAC,GAAG,EACZ,IAAI,SAAS,KAAK;EAChB,IAAI,QAAQ,QAAQ,OAAO,KAAA;EAC3B,IAAI,QAAQ,YACV,QAAQ,UAAoB,cAAc,MAAM,KAAK;EAEvD,IAAI,QAAQ,gBACV,QACE,OACA,eAAwC,CAAC,OACrC;GACJ,GAAG;GACH,UAAU,cAAc,MAAM,KAAK;GACnC,UAAU,EAAE,aACV,WAAW,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;EACtC;EAEF,IAAI,QAAQ,oBACV,QACE,OACA,eAAwC,CAAC,OACrC;GACJ,GAAG;GACH,UAAU,cAAc,MAAM,KAAK;GACnC,SAAS,2BAA6C;IACpD,WAAW,EAAE,aACX,cAAc,WAAW,IAAI,GAAG,OAAO,EAAE,OAAO,CAAC;IACnD,UAAU,UAAU,WAAW;IAC/B,cAAc,KAAA;GAChB,CAAC;EACH;EAEF,IAAI,QAAQ,mBACV,QACE,kBAA2C,CAAC,OACxC;GACJ,GAAG;GACH,aAAa,cAAc,IAAI;GAC/B,aAAa,UACX,WAAW,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;EAChC;EAEF,IAAI,OAAO,QAAQ,UAAU,OAAO,KAAA;EACpC,OAAO,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC;CAC7B,EACF,CAAC;CAEH,OAAO,MAAM,CAAC,CAAC;AACjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CapableServer } from "./index-
|
|
1
|
+
import { t as CapableServer } from "./index-D-NV4PiU.mjs";
|
|
2
2
|
//#region packages/nitro-host/src/runtime-support.d.ts
|
|
3
3
|
type CapableNitroEntryOptions = {
|
|
4
4
|
/** The default export of the project's `capable.app.*`. */
|
package/dist/runtime-support.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createHttpHandler } from "./src-
|
|
2
|
-
import { t as mcp } from "./mount-
|
|
3
|
-
import { n as http, r as protocol, t as createServer } from "./src-
|
|
1
|
+
import { t as createHttpHandler } from "./src-_6OmFRYa.mjs";
|
|
2
|
+
import { t as mcp } from "./mount-BmLHp349.mjs";
|
|
3
|
+
import { n as http, r as protocol, t as createServer } from "./src-C5jGDnuu.mjs";
|
|
4
4
|
//#region packages/nitro-host/src/dev-index.ts
|
|
5
5
|
function devIndex() {
|
|
6
6
|
return {
|
|
@@ -99,7 +99,7 @@ function renderDevIndex(app) {
|
|
|
99
99
|
|
|
100
100
|
<section class="protocols" aria-label="Application surfaces">
|
|
101
101
|
${protocolLink("OpenAPI", "/openapi.json", true)}
|
|
102
|
-
${protocolLink("Manifest", "/
|
|
102
|
+
${protocolLink("Manifest", "/~capable/manifest", true)}
|
|
103
103
|
${protocolLink("MCP", "/mcp", false)}
|
|
104
104
|
</section>
|
|
105
105
|
|
|
@@ -116,7 +116,7 @@ function renderDevIndex(app) {
|
|
|
116
116
|
|
|
117
117
|
<footer class="shell">
|
|
118
118
|
<span>Generated from the application definition</span>
|
|
119
|
-
<a href="/
|
|
119
|
+
<a href="/~capable/manifest">Application manifest <span aria-hidden="true">→</span></a>
|
|
120
120
|
</footer>
|
|
121
121
|
<script>${script}<\/script>
|
|
122
122
|
</body>
|
|
@@ -358,9 +358,9 @@ function renderProductionSplash(app) {
|
|
|
358
358
|
<span class="endpoint-name">OpenAPI</span>
|
|
359
359
|
<code class="endpoint-path">/openapi.json</code>
|
|
360
360
|
</a>
|
|
361
|
-
<a href="/
|
|
361
|
+
<a href="/~capable/manifest">
|
|
362
362
|
<span class="endpoint-name">Manifest</span>
|
|
363
|
-
<code class="endpoint-path"
|
|
363
|
+
<code class="endpoint-path">/~capable/manifest</code>
|
|
364
364
|
</a>
|
|
365
365
|
<div class="endpoint">
|
|
366
366
|
<span class="endpoint-name">MCP</span>
|
|
@@ -562,7 +562,7 @@ function createCapableNitroEntry(options) {
|
|
|
562
562
|
] });
|
|
563
563
|
return options.dev ? server : withProductionMetadataCache(server);
|
|
564
564
|
}
|
|
565
|
-
const productionMetadataPaths = /* @__PURE__ */ new Set(["/
|
|
565
|
+
const productionMetadataPaths = /* @__PURE__ */ new Set(["/~capable/manifest", "/openapi.json"]);
|
|
566
566
|
function withProductionMetadataCache(server) {
|
|
567
567
|
return { async fetch(request) {
|
|
568
568
|
const response = await server.fetch(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-support.mjs","names":["escapeHtml","styles"],"sources":["../../nitro-host/src/dev-index.ts","../../nitro-host/src/production-splash.ts","../../nitro-host/src/runtime-support.ts"],"sourcesContent":["import type {\n AppDefinition,\n LocatedCapability,\n} from \"@capable/core\";\nimport { createHttpHandler } from \"@capable/fetch\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nexport function devIndex(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderDevIndex(app);\n return {\n name: \"dev-index\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return new Response(html, {\n headers: { \"content-type\": \"text/html; charset=utf-8\" },\n });\n },\n };\n },\n };\n}\n\nexport function withDevIndex(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const index = devIndex().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await index.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderDevIndex(app: AppDefinition<any, any>): string {\n const routes = createHttpHandler(app).routes;\n const routeByCapability = new Map(\n routes.map((route) => [route.capability.capability, route]),\n );\n const capabilityCount = app.locatedCapabilities.length;\n const firstCommand = app.locatedCapabilities\n .map((entry) => cliCommand(entry))\n .find((command): command is string => command !== undefined);\n const capabilities = app.locatedCapabilities.map((entry) => {\n const capability = entry.capability;\n const route = routeByCapability.get(capability);\n const command = cliCommand(entry);\n const canOpen = route?.method === \"GET\" && capability.input === undefined;\n const badges = [\n capability.toPresentation ? \"Presentation\" : undefined,\n capability.deprecated ? \"Deprecated\" : undefined,\n ].filter(Boolean) as string[];\n\n return `\n <article class=\"capability\">\n <div class=\"capability-head\">\n <div class=\"capability-title\">\n <h3>${escapeHtml(capability.title ?? entry.path.at(-1)!)}</h3>\n <span class=\"effect ${escapeHtml(capability.effect ?? \"unspecified\")}\">${escapeHtml(capability.effect ?? \"unspecified\")}</span>\n ${badges.map((badge) => `<span class=\"badge\">${escapeHtml(badge)}</span>`).join(\"\")}\n </div>\n ${canOpen\n ? `<a class=\"open\" href=\"${escapeHtml(route.path)}\">Open <span aria-hidden=\"true\">↗</span></a>`\n : \"\"}\n </div>\n ${capability.description\n ? `<p class=\"capability-description\">${escapeHtml(capability.description)}</p>`\n : \"\"}\n ${command ? command_(command) : \"\"}\n <div class=\"identity\">\n <span class=\"method\">${escapeHtml(route?.method ?? \"OP\")}</span>\n ${[\n route?.path ?? entry.path.join(\".\"),\n entry.path.join(\".\"),\n capability.id,\n ]\n .filter((value, index, all) => all.indexOf(value) === index)\n .map((value) => `<code>${escapeHtml(value)}</code>`)\n .join(`<span class=\"identity-sep\" aria-hidden=\"true\">·</span>`)}\n </div>\n </article>`;\n }).join(\"\");\n\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <header class=\"topbar\">\n <div class=\"shell nav\">\n <a class=\"brand\" href=\"/\" aria-label=\"Capable development home\">\n <span class=\"brand-mark\" aria-hidden=\"true\">C</span>\n <span>Capable</span>\n </a>\n <span class=\"environment\"><span aria-hidden=\"true\"></span>Development</span>\n </div>\n </header>\n\n <main class=\"shell\">\n <section class=\"hero\">\n <div class=\"title-row\">\n <h1>${escapeHtml(app.name)}</h1>\n <span class=\"version\">v${escapeHtml(app.version)}</span>\n </div>\n <p>${escapeHtml(app.description ?? \"A capability application powered by Capable.\")}</p>\n </section>\n\n <section class=\"cli\" aria-label=\"Command line\">\n <div class=\"cli-copy\">\n <h2>Run it from your terminal</h2>\n <p>Every capability below is already a command. No client, no URL, no code generation.</p>\n </div>\n <div class=\"cli-commands\">\n ${command_(\"--help\", \"List every command\")}\n ${firstCommand ? command_(firstCommand, \"Call a capability\") : \"\"}\n </div>\n </section>\n\n <section class=\"protocols\" aria-label=\"Application surfaces\">\n ${protocolLink(\"OpenAPI\", \"/openapi.json\", true)}\n ${protocolLink(\"Manifest\", \"/_capable/manifest\", true)}\n ${protocolLink(\"MCP\", \"/mcp\", false)}\n </section>\n\n <section class=\"capabilities-section\">\n <div class=\"section-heading\">\n <h2>Capabilities</h2>\n <span class=\"count\">${capabilityCount}</span>\n </div>\n <div class=\"capabilities\">\n ${capabilities || `<div class=\"empty\">No capabilities have been defined yet.</div>`}\n </div>\n </section>\n </main>\n\n <footer class=\"shell\">\n <span>Generated from the application definition</span>\n <a href=\"/_capable/manifest\">Application manifest <span aria-hidden=\"true\">→</span></a>\n </footer>\n <script>${script}</script>\n </body>\n</html>`;\n}\n\n/** A copyable `cap cli` invocation. Paths are relative, so no URL is needed. */\nfunction command_(command: string, label?: string): string {\n const full = `cap cli ${command}`;\n return `<div class=\"command\">\n ${label ? `<span class=\"command-label\">${escapeHtml(label)}</span>` : \"\"}\n <div class=\"command-line\">\n <span class=\"prompt\" aria-hidden=\"true\">$</span>\n <code>${escapeHtml(full)}</code>\n <button type=\"button\" class=\"copy\" data-copy=\"${escapeHtml(full)}\" aria-label=\"Copy command\">Copy</button>\n </div>\n </div>`;\n}\n\nfunction cliCommand(entry: LocatedCapability): string | undefined {\n const capabilityMeta = entry.capability.meta.cli as\n | false\n | {\n readonly name?: string;\n readonly command?: readonly string[];\n readonly positional?: readonly string[];\n }\n | undefined;\n if (capabilityMeta === false) return undefined;\n\n const command = [...entry.path];\n for (let index = 0; index < entry.groups.length; index++) {\n const groupMeta = entry.groups[index]?.meta.cli as\n | { readonly name?: string }\n | undefined;\n const groupPath = entry.groupPaths[index];\n if (groupMeta?.name && groupPath) {\n command[groupPath.length - 1] = groupMeta.name;\n }\n }\n if (capabilityMeta?.command) {\n command.splice(0, command.length, ...capabilityMeta.command);\n } else if (capabilityMeta?.name) {\n command[command.length - 1] = capabilityMeta.name;\n }\n return [...command, ...(capabilityMeta?.positional ?? []).map((name) =>\n `<${name}>`\n )].join(\" \");\n}\n\nfunction protocolLink(name: string, path: string, navigable: boolean): string {\n const content = `\n <span>${escapeHtml(name)}</span>\n <code>${escapeHtml(path)}</code>\n <span class=\"protocol-arrow\" aria-hidden=\"true\">${navigable ? \"↗\" : \"●\"}</span>`;\n return navigable\n ? `<a class=\"protocol\" href=\"${escapeHtml(path)}\">${content}</a>`\n : `<div class=\"protocol protocol-static\">${content}</div>`;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light;\n --background: #fff;\n --foreground: #0a0a0a;\n --secondary: #666;\n --muted: #8f8f8f;\n --border: #ebebeb;\n --border-strong: #dcdcdc;\n --subtle: #fafafa;\n --hover: #f5f5f5;\n --mark-bg: #0a0a0a;\n --mark-fg: #fff;\n --accent: #0070f3;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n color-scheme: dark;\n --background: #000;\n --foreground: #ededed;\n --secondary: #a1a1a1;\n --muted: #737373;\n --border: #1f1f1f;\n --border-strong: #2e2e2e;\n --subtle: #0a0a0a;\n --hover: #141414;\n --mark-bg: #ededed;\n --mark-fg: #000;\n --accent: #3291ff;\n }\n }\n * { box-sizing: border-box; }\n body {\n margin: 0;\n min-height: 100vh;\n background: var(--background);\n color: var(--foreground);\n font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Inter, sans-serif;\n -webkit-font-smoothing: antialiased;\n }\n a { color: inherit; text-decoration: none; }\n code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }\n h1, h2, h3, p { margin: 0; }\n .shell { width: min(880px, calc(100% - 48px)); margin: 0 auto; }\n\n .topbar { position: sticky; top: 0; z-index: 10; height: 60px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: saturate(180%) blur(12px); }\n .nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }\n .brand { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .brand-mark { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: var(--mark-bg); color: var(--mark-fg); font-size: 12px; font-weight: 700; }\n .environment { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 12px; }\n .environment > span { width: 6px; height: 6px; border-radius: 999px; background: #45a557; box-shadow: 0 0 0 3px color-mix(in srgb, #45a557 16%, transparent); }\n\n .hero { padding: 72px 0 40px; }\n .title-row { display: flex; align-items: baseline; gap: 12px; }\n h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -.045em; line-height: 1.1; }\n .version { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }\n .hero > p { max-width: 600px; margin-top: 14px; color: var(--secondary); font-size: 16px; line-height: 1.6; }\n\n .cli { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--subtle); }\n .cli-copy h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }\n .cli-copy p { margin-top: 6px; color: var(--secondary); font-size: 13px; line-height: 1.6; }\n .cli-commands { display: grid; gap: 10px; }\n\n .command { display: grid; gap: 6px; min-width: 0; }\n .command-label { color: var(--muted); font-size: 11px; letter-spacing: .02em; }\n .command-line { display: flex; align-items: center; gap: 9px; padding: 9px 9px 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--background); }\n .prompt { color: var(--muted); user-select: none; }\n .command-line code { flex: 1; overflow-x: auto; color: var(--foreground); font-size: 12.5px; white-space: nowrap; scrollbar-width: none; }\n .command-line code::-webkit-scrollbar { display: none; }\n .copy { flex: none; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; transition: color 120ms ease, background 120ms ease; }\n .copy:hover { background: var(--hover); color: var(--foreground); }\n .copy[data-copied=\"true\"] { color: #45a557; }\n\n .protocols { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }\n .protocol { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 7px; padding: 16px 18px; border-right: 1px solid var(--border); transition: background 120ms ease; }\n .protocol:last-child { border-right: 0; }\n a.protocol:hover { background: var(--hover); }\n .protocol > span:first-child { font-size: 13px; font-weight: 550; }\n .protocol code { overflow: hidden; color: var(--secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n .protocol-arrow { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: 11px; }\n .protocol-static .protocol-arrow { color: #45a557; font-size: 8px; }\n\n .capabilities-section { padding: 64px 0 40px; }\n .section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }\n h2 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }\n .count, .badge, .effect { border: 1px solid var(--border); border-radius: 999px; color: var(--secondary); font-size: 11px; line-height: 1; }\n .count { padding: 5px 8px; font-variant-numeric: tabular-nums; }\n .capabilities { display: grid; gap: 10px; }\n .capability { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 120ms ease; }\n .capability:hover { border-color: var(--border-strong); }\n .capability-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }\n .capability-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }\n h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .effect, .badge { padding: 4px 7px; text-transform: capitalize; }\n .effect.read { color: #27833d; border-color: color-mix(in srgb, #27833d 28%, transparent); }\n .effect.write { color: #a16207; border-color: color-mix(in srgb, #a16207 28%, transparent); }\n .effect.destructive { color: #c03a36; border-color: color-mix(in srgb, #c03a36 28%, transparent); }\n .open { flex: none; color: var(--secondary); font-size: 12px; white-space: nowrap; }\n .open:hover { color: var(--foreground); }\n .capability-description { max-width: 640px; margin-top: -4px; color: var(--secondary); line-height: 1.55; }\n .identity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }\n .identity code { color: var(--secondary); }\n .method { color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 650; }\n .identity-sep { color: var(--border-strong); }\n .empty { padding: 40px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--secondary); text-align: center; }\n\n footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }\n footer a:hover { color: var(--foreground); }\n\n @media (max-width: 720px) {\n .shell { width: min(100% - 32px, 880px); }\n .hero { padding: 48px 0 32px; }\n .title-row { align-items: flex-start; flex-direction: column; gap: 8px; }\n .cli { grid-template-columns: 1fr; gap: 18px; }\n .protocols { grid-template-columns: 1fr; }\n .protocol { border-right: 0; border-bottom: 1px solid var(--border); }\n .protocol:last-child { border-bottom: 0; }\n .capabilities-section { padding-top: 48px; }\n .capability-head { align-items: flex-start; flex-direction: column; gap: 10px; }\n footer { align-items: flex-start; flex-direction: column; }\n }\n`;\n\nconst script = String.raw`\n document.addEventListener(\"click\", (event) => {\n const button = event.target.closest(\"button.copy\");\n if (!button) return;\n navigator.clipboard?.writeText(button.dataset.copy ?? \"\").then(() => {\n button.textContent = \"Copied\";\n button.dataset.copied = \"true\";\n setTimeout(() => {\n button.textContent = \"Copy\";\n delete button.dataset.copied;\n }, 1400);\n });\n });\n`;\n","import type { AppDefinition } from \"@capable/core\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nconst DEPLOYMENT_URL_PLACEHOLDER = \"{{DEPLOYMENT_URL}}\";\n\nexport function productionSplash(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderProductionSplash(app);\n return {\n name: \"production-splash\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return productionSplashResponse(html, request);\n },\n };\n },\n };\n}\n\nexport function withProductionSplash(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const splash = productionSplash().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await splash.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderProductionSplash(app: AppDefinition<any, any>): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <meta name=\"robots\" content=\"noindex\">\n <meta name=\"referrer\" content=\"no-referrer\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <main>\n <section class=\"card\" aria-label=\"Deployment status\">\n <header>\n <h1>${escapeHtml(app.name)}</h1>\n <p class=\"status\">\n <span class=\"status-state\"><span class=\"status-dot\" aria-hidden=\"true\"></span>Ready</span>\n <span class=\"status-separator\" aria-hidden=\"true\">·</span>\n <span>Production</span>\n </p>\n </header>\n <div class=\"command\" role=\"group\" aria-label=\"Inspect from your terminal\">\n <div class=\"command-line\">\n <span class=\"command-prompt\" aria-hidden=\"true\">$</span>\n <code>capable cli --app ${DEPLOYMENT_URL_PLACEHOLDER} --help</code>\n </div>\n </div>\n <section class=\"endpoints\" aria-label=\"Deployment endpoints\">\n <a href=\"/openapi.json\">\n <span class=\"endpoint-name\">OpenAPI</span>\n <code class=\"endpoint-path\">/openapi.json</code>\n </a>\n <a href=\"/_capable/manifest\">\n <span class=\"endpoint-name\">Manifest</span>\n <code class=\"endpoint-path\">/_capable/manifest</code>\n </a>\n <div class=\"endpoint\">\n <span class=\"endpoint-name\">MCP</span>\n <code class=\"endpoint-path\">/mcp</code>\n </div>\n </section>\n </section>\n </main>\n </body>\n</html>`;\n}\n\nfunction productionSplashResponse(html: string, request: Request): Response {\n return new Response(\n html.replace(\n DEPLOYMENT_URL_PLACEHOLDER,\n () => escapeHtml(resolveDeploymentUrl(request)),\n ),\n {\n headers: {\n \"cache-control\": \"no-store\",\n \"content-security-policy\":\n \"default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'\",\n \"content-type\": \"text/html; charset=utf-8\",\n \"referrer-policy\": \"no-referrer\",\n \"x-content-type-options\": \"nosniff\",\n \"x-robots-tag\": \"noindex\",\n },\n },\n );\n}\n\nfunction resolveDeploymentUrl(request: Request): string {\n const url = new URL(request.url);\n const host = firstForwardedValue(request.headers.get(\"x-forwarded-host\")) ??\n request.headers.get(\"host\") ??\n url.host;\n const protocol =\n firstForwardedValue(request.headers.get(\"x-forwarded-proto\")) ??\n url.protocol.slice(0, -1);\n return `${protocol}://${host}`;\n}\n\nfunction firstForwardedValue(value: string | null): string | undefined {\n const first = value?.split(\",\")[0]?.trim();\n return first || undefined;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light dark;\n --background: #ffffff;\n --foreground: #0a0a0a;\n --muted: #575757;\n --faint: #737373;\n --border: rgba(0, 0, 0, .1);\n --surface: #fafafa;\n --accent: #087a4f;\n --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mono: ui-monospace, \"SF Mono\", Menlo, Monaco, Consolas, monospace;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n --background: #0a0a0a;\n --foreground: #ededed;\n --muted: #a1a1a1;\n --faint: #8a8a8a;\n --border: rgba(255, 255, 255, .12);\n --surface: #131313;\n --accent: #3ecf8e;\n }\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; }\n body {\n min-height: 100vh;\n min-height: 100dvh;\n display: grid;\n place-items: center;\n padding: 2rem;\n background: var(--background);\n color: var(--foreground);\n font: 15px/1.55 var(--sans);\n font-feature-settings: \"cv11\", \"ss01\";\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n }\n main {\n width: min(100%, 27rem);\n }\n .card { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }\n header { display: flex; flex-direction: column; gap: .5rem; }\n h1 {\n margin: 0;\n overflow-wrap: anywhere;\n font-size: 1.25rem;\n font-weight: 600;\n letter-spacing: -.021em;\n line-height: 1.3;\n }\n .status {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: .25rem .5rem;\n margin: 0;\n color: var(--muted);\n font-size: .875rem;\n line-height: 1.5;\n }\n .status-state {\n display: inline-flex;\n align-items: center;\n gap: .5rem;\n color: var(--accent);\n font-weight: 500;\n line-height: inherit;\n }\n .status-dot {\n width: 6px;\n height: 6px;\n flex: none;\n border-radius: 50%;\n background: currentColor;\n }\n .status-separator { color: var(--faint); }\n .command {\n display: flex;\n flex-direction: column;\n gap: .5rem;\n padding: 1rem 1.0625rem;\n border: 1px solid var(--border);\n border-radius: .5rem;\n background: var(--surface);\n }\n .command-line {\n display: flex;\n align-items: center;\n gap: .5rem;\n min-width: 0;\n }\n .command-prompt { color: var(--faint); user-select: none; }\n code {\n color: var(--foreground);\n font: .8125rem/1.6 var(--mono);\n font-feature-settings: \"zero\", \"ss01\";\n overflow-wrap: anywhere;\n }\n .endpoints {\n display: flex;\n flex-direction: column;\n border-top: 1px solid var(--border);\n }\n .endpoints a, .endpoint {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 1rem;\n padding: .6875rem .125rem;\n border-bottom: 1px solid var(--border);\n color: var(--foreground);\n font-size: .8125rem;\n }\n .endpoints a {\n text-decoration: none;\n }\n .endpoint-name {\n font-weight: 500;\n }\n .endpoint-path {\n color: var(--faint);\n font-size: .75rem;\n text-align: right;\n transition: color .15s ease;\n }\n .endpoints a:hover .endpoint-path { color: var(--foreground); }\n .endpoints a:focus-visible {\n border-radius: 3px;\n outline: 2px solid var(--foreground);\n outline-offset: 2px;\n }\n @media (max-width: 30rem) {\n body { align-items: start; padding: 3rem 1.5rem 2rem; }\n }\n @media (prefers-reduced-motion: reduce) {\n * { transition: none !important; }\n }\n`;\n","import { mcp } from \"@capable/mcp/mount\";\nimport {\n protocol,\n createServer,\n http,\n type CapableServer,\n} from \"@capable/server\";\nimport type { AppDefinition } from \"@capable/core\";\nimport { devIndex, withDevIndex } from \"./dev-index.ts\";\nimport {\n productionSplash,\n withProductionSplash,\n} from \"./production-splash.ts\";\n\nexport type CapableNitroEntryOptions = {\n /** The default export of the project's `capable.app.*`. */\n readonly definition: unknown;\n /** The default export of `capable.server.*`, when the project has one. */\n readonly server?: { readonly fetch: (request: Request) => unknown } | undefined;\n readonly dev: boolean;\n};\n\n/**\n * Build the server Nitro hosts. The generated entry in the project supplies the\n * project's own modules, so nothing here depends on how they were resolved.\n */\nexport function createCapableNitroEntry(\n options: CapableNitroEntryOptions,\n): CapableServer {\n const definition = options.definition as AppDefinition<any, undefined>;\n if (options.server) {\n return options.dev\n ? withDevIndex(options.server as never, definition)\n : withProductionSplash(options.server as never, definition);\n }\n const server = createServer(definition, {\n mounts: options.dev\n ? [devIndex(), protocol(), http(), mcp()]\n : [productionSplash(), protocol(), http(), mcp()],\n });\n return options.dev ? server : withProductionMetadataCache(server);\n}\n\nconst productionMetadataPaths = new Set([\n \"/_capable/manifest\",\n \"/openapi.json\",\n]);\n\nfunction withProductionMetadataCache(server: {\n readonly fetch: (request: Request) => Promise<Response>;\n}) {\n return {\n async fetch(request: Request): Promise<Response> {\n const response = await server.fetch(request);\n if (\n request.method === \"GET\" &&\n response.ok &&\n productionMetadataPaths.has(new URL(request.url).pathname)\n ) {\n response.headers.set(\n \"cache-control\",\n \"public, max-age=0, must-revalidate\",\n );\n response.headers.set(\n \"vercel-cdn-cache-control\",\n \"public, max-age=31536000\",\n );\n }\n return response;\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,WAA6B;CAC3C,OAAO;EACL,MAAM;EACN,QAAQ,KAAK;GACX,MAAM,OAAO,eAAe,GAAG;GAC/B,OAAO;IACL,MAAM;IACN,MAAM,SAAS;KACb,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;KAC/B,IAAI,QAAQ,WAAW,SAAS,IAAI,aAAa,KAC/C;KAEF,OAAO,IAAI,SAAS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M,QAAQ,aAAa,eAAe;EAC/C,KAAK;EACL,KAAK;EACL,KAAK;EACL,MAAK;EACL,KAAK;CACP,EAAA,CAAG,UAAW;AAChB;AAEA,MAAM,SAAS,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5GzB,SAAgB,wBACd,SACe;CACf,MAAM,aAAa,QAAQ;CAC3B,IAAI,QAAQ,QACV,OAAO,QAAQ,MACX,aAAa,QAAQ,QAAiB,UAAU,IAChD,qBAAqB,QAAQ,QAAiB,UAAU;CAE9D,MAAM,SAAS,aAAa,YAAY,EACtC,QAAQ,QAAQ,MACZ;EAAC,SAAS;EAAG,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,IACtC;EAAC,iBAAiB;EAAG,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,EACpD,CAAC;CACD,OAAO,QAAQ,MAAM,SAAS,4BAA4B,MAAM;AAClE;AAEA,MAAM,0CAA0B,IAAI,IAAI,CACtC,sBACA,eACF,CAAC;AAED,SAAS,4BAA4B,QAElC;CACD,OAAO,EACL,MAAM,MAAM,SAAqC;EAC/C,MAAM,WAAW,MAAM,OAAO,MAAM,OAAO;EAC3C,IACE,QAAQ,WAAW,SACnB,SAAS,MACT,wBAAwB,IAAI,IAAI,IAAI,QAAQ,GAAG,CAAC,CAAC,QAAQ,GACzD;GACA,SAAS,QAAQ,IACf,iBACA,oCACF;GACA,SAAS,QAAQ,IACf,4BACA,0BACF;EACF;EACA,OAAO;CACT,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"runtime-support.mjs","names":["escapeHtml","styles"],"sources":["../../nitro-host/src/dev-index.ts","../../nitro-host/src/production-splash.ts","../../nitro-host/src/runtime-support.ts"],"sourcesContent":["import type {\n AppDefinition,\n LocatedCapability,\n} from \"@capable/core\";\nimport { createHttpHandler } from \"@capable/fetch\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nexport function devIndex(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderDevIndex(app);\n return {\n name: \"dev-index\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return new Response(html, {\n headers: { \"content-type\": \"text/html; charset=utf-8\" },\n });\n },\n };\n },\n };\n}\n\nexport function withDevIndex(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const index = devIndex().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await index.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderDevIndex(app: AppDefinition<any, any>): string {\n const routes = createHttpHandler(app).routes;\n const routeByCapability = new Map(\n routes.map((route) => [route.capability.capability, route]),\n );\n const capabilityCount = app.locatedCapabilities.length;\n const firstCommand = app.locatedCapabilities\n .map((entry) => cliCommand(entry))\n .find((command): command is string => command !== undefined);\n const capabilities = app.locatedCapabilities.map((entry) => {\n const capability = entry.capability;\n const route = routeByCapability.get(capability);\n const command = cliCommand(entry);\n const canOpen = route?.method === \"GET\" && capability.input === undefined;\n const badges = [\n capability.toPresentation ? \"Presentation\" : undefined,\n capability.deprecated ? \"Deprecated\" : undefined,\n ].filter(Boolean) as string[];\n\n return `\n <article class=\"capability\">\n <div class=\"capability-head\">\n <div class=\"capability-title\">\n <h3>${escapeHtml(capability.title ?? entry.path.at(-1)!)}</h3>\n <span class=\"effect ${escapeHtml(capability.effect ?? \"unspecified\")}\">${escapeHtml(capability.effect ?? \"unspecified\")}</span>\n ${badges.map((badge) => `<span class=\"badge\">${escapeHtml(badge)}</span>`).join(\"\")}\n </div>\n ${canOpen\n ? `<a class=\"open\" href=\"${escapeHtml(route.path)}\">Open <span aria-hidden=\"true\">↗</span></a>`\n : \"\"}\n </div>\n ${capability.description\n ? `<p class=\"capability-description\">${escapeHtml(capability.description)}</p>`\n : \"\"}\n ${command ? command_(command) : \"\"}\n <div class=\"identity\">\n <span class=\"method\">${escapeHtml(route?.method ?? \"OP\")}</span>\n ${[\n route?.path ?? entry.path.join(\".\"),\n entry.path.join(\".\"),\n capability.id,\n ]\n .filter((value, index, all) => all.indexOf(value) === index)\n .map((value) => `<code>${escapeHtml(value)}</code>`)\n .join(`<span class=\"identity-sep\" aria-hidden=\"true\">·</span>`)}\n </div>\n </article>`;\n }).join(\"\");\n\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <header class=\"topbar\">\n <div class=\"shell nav\">\n <a class=\"brand\" href=\"/\" aria-label=\"Capable development home\">\n <span class=\"brand-mark\" aria-hidden=\"true\">C</span>\n <span>Capable</span>\n </a>\n <span class=\"environment\"><span aria-hidden=\"true\"></span>Development</span>\n </div>\n </header>\n\n <main class=\"shell\">\n <section class=\"hero\">\n <div class=\"title-row\">\n <h1>${escapeHtml(app.name)}</h1>\n <span class=\"version\">v${escapeHtml(app.version)}</span>\n </div>\n <p>${escapeHtml(app.description ?? \"A capability application powered by Capable.\")}</p>\n </section>\n\n <section class=\"cli\" aria-label=\"Command line\">\n <div class=\"cli-copy\">\n <h2>Run it from your terminal</h2>\n <p>Every capability below is already a command. No client, no URL, no code generation.</p>\n </div>\n <div class=\"cli-commands\">\n ${command_(\"--help\", \"List every command\")}\n ${firstCommand ? command_(firstCommand, \"Call a capability\") : \"\"}\n </div>\n </section>\n\n <section class=\"protocols\" aria-label=\"Application surfaces\">\n ${protocolLink(\"OpenAPI\", \"/openapi.json\", true)}\n ${protocolLink(\"Manifest\", \"/~capable/manifest\", true)}\n ${protocolLink(\"MCP\", \"/mcp\", false)}\n </section>\n\n <section class=\"capabilities-section\">\n <div class=\"section-heading\">\n <h2>Capabilities</h2>\n <span class=\"count\">${capabilityCount}</span>\n </div>\n <div class=\"capabilities\">\n ${capabilities || `<div class=\"empty\">No capabilities have been defined yet.</div>`}\n </div>\n </section>\n </main>\n\n <footer class=\"shell\">\n <span>Generated from the application definition</span>\n <a href=\"/~capable/manifest\">Application manifest <span aria-hidden=\"true\">→</span></a>\n </footer>\n <script>${script}</script>\n </body>\n</html>`;\n}\n\n/** A copyable `cap cli` invocation. Paths are relative, so no URL is needed. */\nfunction command_(command: string, label?: string): string {\n const full = `cap cli ${command}`;\n return `<div class=\"command\">\n ${label ? `<span class=\"command-label\">${escapeHtml(label)}</span>` : \"\"}\n <div class=\"command-line\">\n <span class=\"prompt\" aria-hidden=\"true\">$</span>\n <code>${escapeHtml(full)}</code>\n <button type=\"button\" class=\"copy\" data-copy=\"${escapeHtml(full)}\" aria-label=\"Copy command\">Copy</button>\n </div>\n </div>`;\n}\n\nfunction cliCommand(entry: LocatedCapability): string | undefined {\n const capabilityMeta = entry.capability.meta.cli as\n | false\n | {\n readonly name?: string;\n readonly command?: readonly string[];\n readonly positional?: readonly string[];\n }\n | undefined;\n if (capabilityMeta === false) return undefined;\n\n const command = [...entry.path];\n for (let index = 0; index < entry.groups.length; index++) {\n const groupMeta = entry.groups[index]?.meta.cli as\n | { readonly name?: string }\n | undefined;\n const groupPath = entry.groupPaths[index];\n if (groupMeta?.name && groupPath) {\n command[groupPath.length - 1] = groupMeta.name;\n }\n }\n if (capabilityMeta?.command) {\n command.splice(0, command.length, ...capabilityMeta.command);\n } else if (capabilityMeta?.name) {\n command[command.length - 1] = capabilityMeta.name;\n }\n return [...command, ...(capabilityMeta?.positional ?? []).map((name) =>\n `<${name}>`\n )].join(\" \");\n}\n\nfunction protocolLink(name: string, path: string, navigable: boolean): string {\n const content = `\n <span>${escapeHtml(name)}</span>\n <code>${escapeHtml(path)}</code>\n <span class=\"protocol-arrow\" aria-hidden=\"true\">${navigable ? \"↗\" : \"●\"}</span>`;\n return navigable\n ? `<a class=\"protocol\" href=\"${escapeHtml(path)}\">${content}</a>`\n : `<div class=\"protocol protocol-static\">${content}</div>`;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light;\n --background: #fff;\n --foreground: #0a0a0a;\n --secondary: #666;\n --muted: #8f8f8f;\n --border: #ebebeb;\n --border-strong: #dcdcdc;\n --subtle: #fafafa;\n --hover: #f5f5f5;\n --mark-bg: #0a0a0a;\n --mark-fg: #fff;\n --accent: #0070f3;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n color-scheme: dark;\n --background: #000;\n --foreground: #ededed;\n --secondary: #a1a1a1;\n --muted: #737373;\n --border: #1f1f1f;\n --border-strong: #2e2e2e;\n --subtle: #0a0a0a;\n --hover: #141414;\n --mark-bg: #ededed;\n --mark-fg: #000;\n --accent: #3291ff;\n }\n }\n * { box-sizing: border-box; }\n body {\n margin: 0;\n min-height: 100vh;\n background: var(--background);\n color: var(--foreground);\n font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Inter, sans-serif;\n -webkit-font-smoothing: antialiased;\n }\n a { color: inherit; text-decoration: none; }\n code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }\n h1, h2, h3, p { margin: 0; }\n .shell { width: min(880px, calc(100% - 48px)); margin: 0 auto; }\n\n .topbar { position: sticky; top: 0; z-index: 10; height: 60px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: saturate(180%) blur(12px); }\n .nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }\n .brand { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .brand-mark { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: var(--mark-bg); color: var(--mark-fg); font-size: 12px; font-weight: 700; }\n .environment { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 12px; }\n .environment > span { width: 6px; height: 6px; border-radius: 999px; background: #45a557; box-shadow: 0 0 0 3px color-mix(in srgb, #45a557 16%, transparent); }\n\n .hero { padding: 72px 0 40px; }\n .title-row { display: flex; align-items: baseline; gap: 12px; }\n h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -.045em; line-height: 1.1; }\n .version { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }\n .hero > p { max-width: 600px; margin-top: 14px; color: var(--secondary); font-size: 16px; line-height: 1.6; }\n\n .cli { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--subtle); }\n .cli-copy h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }\n .cli-copy p { margin-top: 6px; color: var(--secondary); font-size: 13px; line-height: 1.6; }\n .cli-commands { display: grid; gap: 10px; }\n\n .command { display: grid; gap: 6px; min-width: 0; }\n .command-label { color: var(--muted); font-size: 11px; letter-spacing: .02em; }\n .command-line { display: flex; align-items: center; gap: 9px; padding: 9px 9px 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--background); }\n .prompt { color: var(--muted); user-select: none; }\n .command-line code { flex: 1; overflow-x: auto; color: var(--foreground); font-size: 12.5px; white-space: nowrap; scrollbar-width: none; }\n .command-line code::-webkit-scrollbar { display: none; }\n .copy { flex: none; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; transition: color 120ms ease, background 120ms ease; }\n .copy:hover { background: var(--hover); color: var(--foreground); }\n .copy[data-copied=\"true\"] { color: #45a557; }\n\n .protocols { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }\n .protocol { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 7px; padding: 16px 18px; border-right: 1px solid var(--border); transition: background 120ms ease; }\n .protocol:last-child { border-right: 0; }\n a.protocol:hover { background: var(--hover); }\n .protocol > span:first-child { font-size: 13px; font-weight: 550; }\n .protocol code { overflow: hidden; color: var(--secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n .protocol-arrow { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: 11px; }\n .protocol-static .protocol-arrow { color: #45a557; font-size: 8px; }\n\n .capabilities-section { padding: 64px 0 40px; }\n .section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }\n h2 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }\n .count, .badge, .effect { border: 1px solid var(--border); border-radius: 999px; color: var(--secondary); font-size: 11px; line-height: 1; }\n .count { padding: 5px 8px; font-variant-numeric: tabular-nums; }\n .capabilities { display: grid; gap: 10px; }\n .capability { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 120ms ease; }\n .capability:hover { border-color: var(--border-strong); }\n .capability-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }\n .capability-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }\n h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }\n .effect, .badge { padding: 4px 7px; text-transform: capitalize; }\n .effect.read { color: #27833d; border-color: color-mix(in srgb, #27833d 28%, transparent); }\n .effect.write { color: #a16207; border-color: color-mix(in srgb, #a16207 28%, transparent); }\n .effect.destructive { color: #c03a36; border-color: color-mix(in srgb, #c03a36 28%, transparent); }\n .open { flex: none; color: var(--secondary); font-size: 12px; white-space: nowrap; }\n .open:hover { color: var(--foreground); }\n .capability-description { max-width: 640px; margin-top: -4px; color: var(--secondary); line-height: 1.55; }\n .identity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }\n .identity code { color: var(--secondary); }\n .method { color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; font-weight: 650; }\n .identity-sep { color: var(--border-strong); }\n .empty { padding: 40px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--secondary); text-align: center; }\n\n footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }\n footer a:hover { color: var(--foreground); }\n\n @media (max-width: 720px) {\n .shell { width: min(100% - 32px, 880px); }\n .hero { padding: 48px 0 32px; }\n .title-row { align-items: flex-start; flex-direction: column; gap: 8px; }\n .cli { grid-template-columns: 1fr; gap: 18px; }\n .protocols { grid-template-columns: 1fr; }\n .protocol { border-right: 0; border-bottom: 1px solid var(--border); }\n .protocol:last-child { border-bottom: 0; }\n .capabilities-section { padding-top: 48px; }\n .capability-head { align-items: flex-start; flex-direction: column; gap: 10px; }\n footer { align-items: flex-start; flex-direction: column; }\n }\n`;\n\nconst script = String.raw`\n document.addEventListener(\"click\", (event) => {\n const button = event.target.closest(\"button.copy\");\n if (!button) return;\n navigator.clipboard?.writeText(button.dataset.copy ?? \"\").then(() => {\n button.textContent = \"Copied\";\n button.dataset.copied = \"true\";\n setTimeout(() => {\n button.textContent = \"Copy\";\n delete button.dataset.copied;\n }, 1400);\n });\n });\n`;\n","import type { AppDefinition } from \"@capable/core\";\nimport type {\n CapableServer,\n ServerMount,\n} from \"@capable/server\";\n\nconst DEPLOYMENT_URL_PLACEHOLDER = \"{{DEPLOYMENT_URL}}\";\n\nexport function productionSplash(): ServerMount<any> {\n return {\n kind: \"capable.server.mount\",\n compile(app) {\n const html = renderProductionSplash(app);\n return {\n name: \"production-splash\",\n fetch(request) {\n const url = new URL(request.url);\n if (request.method !== \"GET\" || url.pathname !== \"/\") {\n return undefined;\n }\n return productionSplashResponse(html, request);\n },\n };\n },\n };\n}\n\nexport function withProductionSplash(\n server: CapableServer,\n app: AppDefinition<any, any>,\n): CapableServer {\n const splash = productionSplash().compile(app, undefined);\n return Object.freeze({\n async fetch(request) {\n return await splash.fetch(request) ?? server.fetch(request);\n },\n });\n}\n\nexport function renderProductionSplash(app: AppDefinition<any, any>): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n <meta name=\"robots\" content=\"noindex\">\n <meta name=\"referrer\" content=\"no-referrer\">\n <title>${escapeHtml(app.name)} · Capable</title>\n <style>${styles}</style>\n </head>\n <body>\n <main>\n <section class=\"card\" aria-label=\"Deployment status\">\n <header>\n <h1>${escapeHtml(app.name)}</h1>\n <p class=\"status\">\n <span class=\"status-state\"><span class=\"status-dot\" aria-hidden=\"true\"></span>Ready</span>\n <span class=\"status-separator\" aria-hidden=\"true\">·</span>\n <span>Production</span>\n </p>\n </header>\n <div class=\"command\" role=\"group\" aria-label=\"Inspect from your terminal\">\n <div class=\"command-line\">\n <span class=\"command-prompt\" aria-hidden=\"true\">$</span>\n <code>capable cli --app ${DEPLOYMENT_URL_PLACEHOLDER} --help</code>\n </div>\n </div>\n <section class=\"endpoints\" aria-label=\"Deployment endpoints\">\n <a href=\"/openapi.json\">\n <span class=\"endpoint-name\">OpenAPI</span>\n <code class=\"endpoint-path\">/openapi.json</code>\n </a>\n <a href=\"/~capable/manifest\">\n <span class=\"endpoint-name\">Manifest</span>\n <code class=\"endpoint-path\">/~capable/manifest</code>\n </a>\n <div class=\"endpoint\">\n <span class=\"endpoint-name\">MCP</span>\n <code class=\"endpoint-path\">/mcp</code>\n </div>\n </section>\n </section>\n </main>\n </body>\n</html>`;\n}\n\nfunction productionSplashResponse(html: string, request: Request): Response {\n return new Response(\n html.replace(\n DEPLOYMENT_URL_PLACEHOLDER,\n () => escapeHtml(resolveDeploymentUrl(request)),\n ),\n {\n headers: {\n \"cache-control\": \"no-store\",\n \"content-security-policy\":\n \"default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'\",\n \"content-type\": \"text/html; charset=utf-8\",\n \"referrer-policy\": \"no-referrer\",\n \"x-content-type-options\": \"nosniff\",\n \"x-robots-tag\": \"noindex\",\n },\n },\n );\n}\n\nfunction resolveDeploymentUrl(request: Request): string {\n const url = new URL(request.url);\n const host = firstForwardedValue(request.headers.get(\"x-forwarded-host\")) ??\n request.headers.get(\"host\") ??\n url.host;\n const protocol =\n firstForwardedValue(request.headers.get(\"x-forwarded-proto\")) ??\n url.protocol.slice(0, -1);\n return `${protocol}://${host}`;\n}\n\nfunction firstForwardedValue(value: string | null): string | undefined {\n const first = value?.split(\",\")[0]?.trim();\n return first || undefined;\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => ({\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\",\n })[character]!);\n}\n\nconst styles = String.raw`\n :root {\n color-scheme: light dark;\n --background: #ffffff;\n --foreground: #0a0a0a;\n --muted: #575757;\n --faint: #737373;\n --border: rgba(0, 0, 0, .1);\n --surface: #fafafa;\n --accent: #087a4f;\n --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mono: ui-monospace, \"SF Mono\", Menlo, Monaco, Consolas, monospace;\n }\n @media (prefers-color-scheme: dark) {\n :root {\n --background: #0a0a0a;\n --foreground: #ededed;\n --muted: #a1a1a1;\n --faint: #8a8a8a;\n --border: rgba(255, 255, 255, .12);\n --surface: #131313;\n --accent: #3ecf8e;\n }\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; }\n body {\n min-height: 100vh;\n min-height: 100dvh;\n display: grid;\n place-items: center;\n padding: 2rem;\n background: var(--background);\n color: var(--foreground);\n font: 15px/1.55 var(--sans);\n font-feature-settings: \"cv11\", \"ss01\";\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n }\n main {\n width: min(100%, 27rem);\n }\n .card { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }\n header { display: flex; flex-direction: column; gap: .5rem; }\n h1 {\n margin: 0;\n overflow-wrap: anywhere;\n font-size: 1.25rem;\n font-weight: 600;\n letter-spacing: -.021em;\n line-height: 1.3;\n }\n .status {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: .25rem .5rem;\n margin: 0;\n color: var(--muted);\n font-size: .875rem;\n line-height: 1.5;\n }\n .status-state {\n display: inline-flex;\n align-items: center;\n gap: .5rem;\n color: var(--accent);\n font-weight: 500;\n line-height: inherit;\n }\n .status-dot {\n width: 6px;\n height: 6px;\n flex: none;\n border-radius: 50%;\n background: currentColor;\n }\n .status-separator { color: var(--faint); }\n .command {\n display: flex;\n flex-direction: column;\n gap: .5rem;\n padding: 1rem 1.0625rem;\n border: 1px solid var(--border);\n border-radius: .5rem;\n background: var(--surface);\n }\n .command-line {\n display: flex;\n align-items: center;\n gap: .5rem;\n min-width: 0;\n }\n .command-prompt { color: var(--faint); user-select: none; }\n code {\n color: var(--foreground);\n font: .8125rem/1.6 var(--mono);\n font-feature-settings: \"zero\", \"ss01\";\n overflow-wrap: anywhere;\n }\n .endpoints {\n display: flex;\n flex-direction: column;\n border-top: 1px solid var(--border);\n }\n .endpoints a, .endpoint {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 1rem;\n padding: .6875rem .125rem;\n border-bottom: 1px solid var(--border);\n color: var(--foreground);\n font-size: .8125rem;\n }\n .endpoints a {\n text-decoration: none;\n }\n .endpoint-name {\n font-weight: 500;\n }\n .endpoint-path {\n color: var(--faint);\n font-size: .75rem;\n text-align: right;\n transition: color .15s ease;\n }\n .endpoints a:hover .endpoint-path { color: var(--foreground); }\n .endpoints a:focus-visible {\n border-radius: 3px;\n outline: 2px solid var(--foreground);\n outline-offset: 2px;\n }\n @media (max-width: 30rem) {\n body { align-items: start; padding: 3rem 1.5rem 2rem; }\n }\n @media (prefers-reduced-motion: reduce) {\n * { transition: none !important; }\n }\n`;\n","import { mcp } from \"@capable/mcp/mount\";\nimport {\n protocol,\n createServer,\n http,\n type CapableServer,\n} from \"@capable/server\";\nimport type { AppDefinition } from \"@capable/core\";\nimport { devIndex, withDevIndex } from \"./dev-index.ts\";\nimport {\n productionSplash,\n withProductionSplash,\n} from \"./production-splash.ts\";\n\nexport type CapableNitroEntryOptions = {\n /** The default export of the project's `capable.app.*`. */\n readonly definition: unknown;\n /** The default export of `capable.server.*`, when the project has one. */\n readonly server?: { readonly fetch: (request: Request) => unknown } | undefined;\n readonly dev: boolean;\n};\n\n/**\n * Build the server Nitro hosts. The generated entry in the project supplies the\n * project's own modules, so nothing here depends on how they were resolved.\n */\nexport function createCapableNitroEntry(\n options: CapableNitroEntryOptions,\n): CapableServer {\n const definition = options.definition as AppDefinition<any, undefined>;\n if (options.server) {\n return options.dev\n ? withDevIndex(options.server as never, definition)\n : withProductionSplash(options.server as never, definition);\n }\n const server = createServer(definition, {\n mounts: options.dev\n ? [devIndex(), protocol(), http(), mcp()]\n : [productionSplash(), protocol(), http(), mcp()],\n });\n return options.dev ? server : withProductionMetadataCache(server);\n}\n\nconst productionMetadataPaths = new Set([\n \"/~capable/manifest\",\n \"/openapi.json\",\n]);\n\nfunction withProductionMetadataCache(server: {\n readonly fetch: (request: Request) => Promise<Response>;\n}) {\n return {\n async fetch(request: Request): Promise<Response> {\n const response = await server.fetch(request);\n if (\n request.method === \"GET\" &&\n response.ok &&\n productionMetadataPaths.has(new URL(request.url).pathname)\n ) {\n response.headers.set(\n \"cache-control\",\n \"public, max-age=0, must-revalidate\",\n );\n response.headers.set(\n \"vercel-cdn-cache-control\",\n \"public, max-age=31536000\",\n );\n }\n return response;\n },\n };\n}\n"],"mappings":";;;;AAUA,SAAgB,WAA6B;CAC3C,OAAO;EACL,MAAM;EACN,QAAQ,KAAK;GACX,MAAM,OAAO,eAAe,GAAG;GAC/B,OAAO;IACL,MAAM;IACN,MAAM,S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1,2 @@
|
|
|
1
|
-
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as protocol, t as CapableServer } from "./index-
|
|
1
|
+
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as protocol, t as CapableServer } from "./index-D-NV4PiU.mjs";
|
|
2
2
|
export { CapableServer, CompiledServerMount, ServerMiddleware, ServerMount, createServer, http, protocol };
|
package/dist/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as http, r as protocol, t as createServer } from "./src-
|
|
1
|
+
import { n as http, r as protocol, t as createServer } from "./src-C5jGDnuu.mjs";
|
|
2
2
|
export { createServer, http, protocol };
|