capable-kit 0.0.1-alpha.2 → 0.0.1-alpha.3
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/README.md +16 -0
- package/dist/ai-sdk.d.mts +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/bin.mjs +176 -15
- package/dist/bin.mjs.map +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/eve.d.mts +3 -3
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-Dp-D73pf.d.mts → index-AqKbVZ8Z.d.mts} +2 -2
- package/dist/{index-CThfifn8.d.mts → index-B2ru1zGQ.d.mts} +3 -3
- package/dist/{index-BxJhwhKm.d.mts → index-B_I9n6gN.d.mts} +4 -5
- package/dist/index.d.mts +1 -1
- package/dist/mcp.d.mts +2 -2
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +15 -3
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/src-3UaBqI8H.mjs.map +1 -1
- package/dist/src-B53ZbNtC.mjs.map +1 -1
- package/dist/src-BjBxOv7x.mjs.map +1 -1
- package/dist/{src-XRJ9hgYX.mjs → src-DX2xrplP.mjs} +18 -2
- package/dist/src-DX2xrplP.mjs.map +1 -0
- package/dist/{src-DpSA-hBO.mjs → src-DtSY5fzY.mjs} +2 -2
- package/dist/{src-DpSA-hBO.mjs.map → src-DtSY5fzY.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/src-XRJ9hgYX.mjs.map +0 -1
package/dist/eve.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as AnyApp, w as ManifestCapability } from "./index-
|
|
2
|
-
import { DynamicResolveContext, ToolDefinition } from "eve/tools";
|
|
1
|
+
import { o as AnyApp, w as ManifestCapability } from "./index-B_I9n6gN.mjs";
|
|
2
|
+
import { DynamicResolveContext, DynamicSentinel, ToolDefinition } from "eve/tools";
|
|
3
3
|
import { Approval } from "eve/tools/approval";
|
|
4
4
|
//#region packages/eve/src/index.d.ts
|
|
5
5
|
type EveCapabilityMeta = false | {
|
|
@@ -22,7 +22,7 @@ type EveTool = ToolDefinition<Record<string, unknown>, unknown>;
|
|
|
22
22
|
* keeps step-scoped executors live, so the Capable App and its context provider do
|
|
23
23
|
* not have to cross a durable serialization boundary.
|
|
24
24
|
*/
|
|
25
|
-
declare function createEveTools(app: EveAppProvider, options?: CreateEveToolsOptions):
|
|
25
|
+
declare function createEveTools(app: EveAppProvider, options?: CreateEveToolsOptions): DynamicSentinel<Record<string, EveTool>>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { CreateEveToolsOptions, EveAppProvider, EveCapabilityMeta, createEveTools };
|
|
28
28
|
//# sourceMappingURL=eve.d.mts.map
|
package/dist/eve.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eve.mjs","names":[],"sources":["../../eve/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n type AnyApp,\n type ManifestNode,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n type DynamicResolveContext,\n type ToolDefinition,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\nexport type EveAppProvider =\n | AnyApp\n | ((\n context: DynamicResolveContext,\n ) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * The returned dynamic definition resolves at `step.started`. Eve deliberately\n * keeps step-scoped executors live, so the Capable App and its context provider do\n * not have to cross a durable serialization boundary.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n) {\n const capabilitiesByApp = new WeakMap<\n AnyApp,\n Promise<readonly ManifestCapability[]>\n >();\n const capabilities = (resolvedApp: AnyApp) => {\n const existing = capabilitiesByApp.get(resolvedApp);\n if (existing) return existing;\n const resolved = getAppRuntime(resolvedApp).manifest().then((manifest) =>\n flatten(manifest.capabilities)\n );\n capabilitiesByApp.set(resolvedApp, resolved);\n return resolved;\n };\n\n return defineDynamic({\n events: {\n \"step.started\": async (_event, context) => {\n const resolvedApp = typeof app === \"function\"\n ? await app(context)\n : app;\n const runtime = getAppRuntime(resolvedApp);\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of await capabilities(resolvedApp)) {\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const approval = options.approval?.(capability);\n const tool: EveTool = {\n description:\n capability.description ??\n capability.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n async execute(input, context) {\n const result = await runtime.call({\n id: capability.id,\n input,\n signal: context.abortSignal,\n });\n return result.output;\n },\n };\n tools[name] = defineTool(tool);\n }\n\n return tools;\n },\n },\n });\n}\n\nfunction flatten(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\" ? [node] : flatten(node.children)\n );\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"eve.mjs","names":[],"sources":["../../eve/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n type AnyApp,\n type ManifestNode,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n type DynamicResolveContext,\n type DynamicSentinel,\n type ToolDefinition,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\nexport type EveAppProvider =\n | AnyApp\n | ((\n context: DynamicResolveContext,\n ) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * The returned dynamic definition resolves at `step.started`. Eve deliberately\n * keeps step-scoped executors live, so the Capable App and its context provider do\n * not have to cross a durable serialization boundary.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n): DynamicSentinel<Record<string, EveTool>> {\n const capabilitiesByApp = new WeakMap<\n AnyApp,\n Promise<readonly ManifestCapability[]>\n >();\n const capabilities = (resolvedApp: AnyApp) => {\n const existing = capabilitiesByApp.get(resolvedApp);\n if (existing) return existing;\n const resolved = getAppRuntime(resolvedApp).manifest().then((manifest) =>\n flatten(manifest.capabilities)\n );\n capabilitiesByApp.set(resolvedApp, resolved);\n return resolved;\n };\n\n return defineDynamic({\n events: {\n \"step.started\": async (_event, context) => {\n const resolvedApp = typeof app === \"function\"\n ? await app(context)\n : app;\n const runtime = getAppRuntime(resolvedApp);\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of await capabilities(resolvedApp)) {\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const approval = options.approval?.(capability);\n const tool: EveTool = {\n description:\n capability.description ??\n capability.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n async execute(input, context) {\n const result = await runtime.call({\n id: capability.id,\n input,\n signal: context.abortSignal,\n });\n return result.output;\n },\n };\n tools[name] = defineTool(tool);\n }\n\n return tools;\n },\n },\n });\n}\n\nfunction flatten(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\" ? [node] : flatten(node.children)\n );\n}\n"],"mappings":";;;AAwCA,MAAM,mBAAmB,OAAO,OAAO;CACrC,MAAM;CACN,YAAY,OAAO,OAAO,CAAC,CAAC;CAC5B,sBAAsB;AACxB,CAAC;;;;;;;;AAWD,SAAgB,eACd,KACA,UAAiC,CAAC,GACQ;CAC1C,MAAM,oCAAoB,IAAI,QAG5B;CACF,MAAM,gBAAgB,gBAAwB;EAC5C,MAAM,WAAW,kBAAkB,IAAI,WAAW;EAClD,IAAI,UAAU,O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Ae,CAAC,IAAI,IAAI,QAAQ,KAAK,QAAQ,CAC7D;AACF"}
|
package/dist/http.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, i as HttpCapabilityMeta, l as TransportHeaders, n as CompiledHttpRoute, o as HttpMethod, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-
|
|
1
|
+
import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, i as HttpCapabilityMeta, l as TransportHeaders, n as CompiledHttpRoute, o as HttpMethod, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-AqKbVZ8Z.mjs";
|
|
2
2
|
export { type CapabilitySelection, type CompiledHttpRoute, type ContextProvider, type FetchHandler, type HttpCapabilityMeta, type HttpGroupMeta, type HttpMethod, type TransportHeaders, createHttpHandler, createHttpTransport, createProtocolHandler };
|
package/dist/http.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-
|
|
1
|
+
import { n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-DX2xrplP.mjs";
|
|
2
2
|
export { createHttpHandler, createHttpTransport, createProtocolHandler };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { N as LocatedCapability, O as AppDefinition, j as CapabilityTree } from "./index-BB5ogMv-.mjs";
|
|
2
|
-
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-
|
|
2
|
+
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-B_I9n6gN.mjs";
|
|
3
3
|
//#region packages/fetch/src/standard.d.ts
|
|
4
4
|
type FetchHandler = (request: Request) => Response | Promise<Response>;
|
|
5
5
|
declare function createProtocolHandler(application: AnyApp | ((request: Request) => AnyApp | Promise<AnyApp>), options?: {
|
|
@@ -54,4 +54,4 @@ declare function createHttpHandler<const TCapabilities extends CapabilityTree, T
|
|
|
54
54
|
};
|
|
55
55
|
//#endregion
|
|
56
56
|
export { HttpGroupMeta as a, FetchHandler as c, createProtocolHandler as d, HttpCapabilityMeta as i, TransportHeaders as l, CompiledHttpRoute as n, HttpMethod as o, ContextProvider as r, createHttpHandler as s, CapabilitySelection as t, createHttpTransport as u };
|
|
57
|
-
//# sourceMappingURL=index-
|
|
57
|
+
//# sourceMappingURL=index-AqKbVZ8Z.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as MaybePromise, O as AppDefinition } from "./index-BB5ogMv-.mjs";
|
|
2
|
-
import { t as ApplicationSelection } from "./index-
|
|
3
|
-
import { r as ContextProvider, t as CapabilitySelection } from "./index-
|
|
2
|
+
import { t as ApplicationSelection } from "./index-B_I9n6gN.mjs";
|
|
3
|
+
import { r as ContextProvider, t as CapabilitySelection } from "./index-AqKbVZ8Z.mjs";
|
|
4
4
|
//#region packages/server/src/index.d.ts
|
|
5
5
|
type ServerMount<TContext> = {
|
|
6
6
|
readonly kind: "capable.server.mount";
|
|
@@ -39,4 +39,4 @@ type CreateServerArgs<TContext> = [TContext] extends [undefined] ? [options?: Cr
|
|
|
39
39
|
declare function createServer<TContext>(app: AppDefinition<any, TContext>, ...[providedOptions]: CreateServerArgs<TContext>): CapableServer;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { createServer as a, ServerMount as i, CompiledServerMount as n, http as o, ServerMiddleware as r, standard as s, CapableServer as t };
|
|
42
|
-
//# sourceMappingURL=index-
|
|
42
|
+
//# sourceMappingURL=index-B2ru1zGQ.d.mts.map
|
|
@@ -65,11 +65,10 @@ type AppCapabilityType<TCapability extends AnyCapability> = {
|
|
|
65
65
|
};
|
|
66
66
|
type AppCapabilityInput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends AnyObjectSchema ? InferSchemaInput<TInput> : Record<never, never> : never;
|
|
67
67
|
type AppCapabilityOutput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any> ? TOutput : never;
|
|
68
|
-
type
|
|
68
|
+
type AppCapabilityOptions = {
|
|
69
69
|
readonly signal?: AbortSignal;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}] : never;
|
|
70
|
+
};
|
|
71
|
+
type AppCapabilityArgs<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends undefined ? [input?: Record<never, never>, options?: AppCapabilityOptions] : Record<never, never> extends AppCapabilityInput<TCapability> ? [input?: AppCapabilityInput<TCapability>, options?: AppCapabilityOptions] : [input: AppCapabilityInput<TCapability>, options?: AppCapabilityOptions] : never;
|
|
73
72
|
type AppCapabilityCall<TCapability extends AnyCapability> = ((...args: AppCapabilityArgs<TCapability>) => Promise<AppCapabilityOutput<TCapability>>) & AppCapabilityType<TCapability>;
|
|
74
73
|
type AppCapabilityIsSubscribable<TCall> = TCall extends AppCapabilityType<infer TCapability> ? TCapability extends CapabilityDefinition<any, any, any, any, any, true> ? true : false : false;
|
|
75
74
|
type CallableTree<TTree> = TTree extends AnyCapability ? AppCapabilityCall<TTree> : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any> ? CallableTree<TCapabilities> : TTree extends CapabilityTree ? { readonly [TKey in keyof TTree]: CallableTree<TTree[TKey]>; } : never;
|
|
@@ -122,4 +121,4 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
|
|
|
122
121
|
declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
|
|
123
122
|
//#endregion
|
|
124
123
|
export { JsonSchema as C, ManifestNode as D, ManifestGroup as E, createAppManifest as O, ApplicationManifest as S, ManifestError as T, createApp as _, APP_RUNTIME_SYMBOL as a, isApp as b, AppCapabilities as c, AppContextProvider as d, ApplicationTransport as f, TransportError as g, CapabilityResult as h, APP_CAPABILITIES_SYMBOL as i, AppCapabilityCall as l, CapabilityCall as m, mergeApps as n, AnyApp as o, CallableTree as p, selectApp as r, App as s, ApplicationSelection as t, AppCapabilityIsSubscribable as u, createRemoteApp as v, ManifestCapability as w, subscribe as x, getAppRuntime as y };
|
|
125
|
-
//# sourceMappingURL=index-
|
|
124
|
+
//# sourceMappingURL=index-B_I9n6gN.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { D as AppContext, F as group, G as DefinedErrors, O as AppDefinition, P as defineApp, R as md, a as CapabilityEffect, b as executeCapability, c as CapabilityInput, d as CapabilityMiddlewareArgs, f as CapabilityOutput, g as MarkdownRenderer, h as ExecuteCapabilityOptions, i as CapabilityDefinition, j as CapabilityTree, m as CapabilitySubscriberArgs, o as CapabilityFactory, p as CapabilitySubscriber, q as defineErrors, r as CapabilityContext, s as CapabilityHandlerArgs, u as CapabilityMiddleware, y as capability } from "./index-BB5ogMv-.mjs";
|
|
2
2
|
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-McaLyHM2.mjs";
|
|
3
|
-
import { _ as createApp, d as AppContextProvider, l as AppCapabilityCall, n as mergeApps, r as selectApp, s as App, t as ApplicationSelection, v as createRemoteApp, x as subscribe } from "./index-
|
|
3
|
+
import { _ as createApp, d as AppContextProvider, l as AppCapabilityCall, n as mergeApps, r as selectApp, s as App, t as ApplicationSelection, v as createRemoteApp, x as subscribe } from "./index-B_I9n6gN.mjs";
|
|
4
4
|
export { type App, type AppCapabilityCall, type AppContext, type AppContextProvider, type AppDefinition, type ApplicationSelection, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityFactory, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, type DefinedErrors, type ExecuteCapabilityOptions, type MarkdownRenderer, type WatchQueryOptions, capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, selectApp, subscribe, watchQuery };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-
|
|
2
|
-
import { i as ServerMount } from "./index-
|
|
1
|
+
import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-B_I9n6gN.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-B2ru1zGQ.mjs";
|
|
3
3
|
//#region packages/mcp/src/index.d.ts
|
|
4
4
|
type McpCapabilityMeta = false | {
|
|
5
5
|
readonly name?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CapableServer } from "./index-
|
|
1
|
+
import { t as CapableServer } from "./index-B2ru1zGQ.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-
|
|
1
|
+
import { t as createHttpHandler } from "./src-DX2xrplP.mjs";
|
|
2
2
|
import { t as mcp } from "./mount--YHrgRHJ.mjs";
|
|
3
|
-
import { n as http, r as standard, t as createServer } from "./src-
|
|
3
|
+
import { n as http, r as standard, t as createServer } from "./src-DtSY5fzY.mjs";
|
|
4
4
|
//#region packages/nitro-host/src/dev-index.ts
|
|
5
5
|
function devIndex() {
|
|
6
6
|
return {
|
|
@@ -549,7 +549,7 @@ const styles = String.raw`
|
|
|
549
549
|
function createCapableNitroEntry(options) {
|
|
550
550
|
const definition = options.definition;
|
|
551
551
|
if (options.server) return options.dev ? withDevIndex(options.server, definition) : withProductionSplash(options.server, definition);
|
|
552
|
-
|
|
552
|
+
const server = createServer(definition, { mounts: options.dev ? [
|
|
553
553
|
devIndex(),
|
|
554
554
|
standard(),
|
|
555
555
|
http(),
|
|
@@ -560,6 +560,18 @@ function createCapableNitroEntry(options) {
|
|
|
560
560
|
http(),
|
|
561
561
|
mcp()
|
|
562
562
|
] });
|
|
563
|
+
return options.dev ? server : withProductionMetadataCache(server);
|
|
564
|
+
}
|
|
565
|
+
const productionMetadataPaths = /* @__PURE__ */ new Set(["/_capable/manifest", "/openapi.json"]);
|
|
566
|
+
function withProductionMetadataCache(server) {
|
|
567
|
+
return { async fetch(request) {
|
|
568
|
+
const response = await server.fetch(request);
|
|
569
|
+
if (request.method === "GET" && response.ok && productionMetadataPaths.has(new URL(request.url).pathname)) {
|
|
570
|
+
response.headers.set("cache-control", "public, max-age=0, must-revalidate");
|
|
571
|
+
response.headers.set("vercel-cdn-cache-control", "public, max-age=31536000");
|
|
572
|
+
}
|
|
573
|
+
return response;
|
|
574
|
+
} };
|
|
563
575
|
}
|
|
564
576
|
//#endregion
|
|
565
577
|
export { createCapableNitroEntry };
|
|
@@ -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.toMarkdown ? \"Markdown\" : 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 { createServer, http, standard } 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(options: CapableNitroEntryOptions) {\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 return createServer(definition, {\n mounts: options.dev\n ? [devIndex(), standard(), http(), mcp()]\n : [productionSplash(), standard(), http(), mcp()],\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,MAAM,EACxB,SAAS,EAAE,gBAAgB,2BAA2B,EACxD,CAAC;IACH;GACF;EACF;CACF;AACF;AAEA,SAAgB,aACd,QACA,KACe;CACf,MAAM,QAAQ,SAAS,CAAC,CAAC,QAAQ,KAAK,KAAA,CAAS;CAC/C,OAAO,OAAO,OAAO,EACnB,MAAM,MAAM,SAAS;EACnB,OAAO,MAAM,MAAM,MAAM,OAAO,KAAK,OAAO,MAAM,OAAO;CAC3D,EACF,CAAC;AACH;AAEA,SAAgB,eAAe,KAAsC;CACnE,MAAM,SAAS,kBAAkB,GAAG,CAAC,CAAC;CACtC,MAAM,oBAAoB,IAAI,IAC5B,OAAO,KAAK,UAAU,CAAC,MAAM,WAAW,YAAY,KAAK,CAAC,CAC5D;CACA,MAAM,kBAAkB,IAAI,oBAAoB;CAChD,MAAM,eAAe,IAAI,oBACtB,KAAK,UAAU,WAAW,KAAK,CAAC,CAAC,CACjC,MAAM,YAA+B,YAAY,KAAA,CAAS;CAC7D,MAAM,eAAe,IAAI,oBAAoB,KAAK,UAAU;EAC1D,MAAM,aAAa,MAAM;EACzB,MAAM,QAAQ,kBAAkB,IAAI,UAAU;EAC9C,MAAM,UAAU,WAAW,KAAK;EAChC,MAAM,UAAU,OAAO,WAAW,SAAS,WAAW,UAAU,KAAA;EAChE,MAA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B;CACtD,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;CAC/B,MAAM,OAAO,oBAAoB,QAAQ,QAAQ,IAAI,kBAAkB,CAAC,KACtE,QAAQ,QAAQ,IAAI,MAAM,KAC1B,IAAI;CAIN,OAAO,GAFL,oBAAoB,QAAQ,QAAQ,IAAI,mBAAmB,CAAC,KAC1D,IAAI,SAAS,MAAM,GAAG,EAAE,EACT,KAAK;AAC1B;AAEA,SAAS,oBAAoB,OAA0C;CAErE,OADc,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,KACzB,KAAA;AAClB;AAEA,SAAS,WAAW,OAAuB;CACzC,OAAO,MAAM,QAAQ,aAAa,eAAe;EAC/C,KAAK;EACL,KAAK;EACL,KAAK;EACL,MAAK;EACL,KAAK;CACP,EAAA,CAAG,UAAW;AAChB;AAEA,MAAM,SAAS,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjHzB,SAAgB,wBAAwB,SAAmC;CACzE,MAAM,aAAa,QAAQ;CAC3B,IAAI,QAAQ,QACV,OAAO,QAAQ,MACX,aAAa,QAAQ,QAAiB,UAAU,IAChD,qBAAqB,QAAQ,QAAiB,UAAU;CAE9D,OAAO,aAAa,YAAY,EAC9B,QAAQ,QAAQ,MACZ;EAAC,SAAS;EAAG,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,IACtC;EAAC,iBAAiB;EAAG,SAAS;EAAG,KAAK;EAAG,IAAI;CAAC,EACpD,CAAC;AACH"}
|
|
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.toMarkdown ? \"Markdown\" : 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 createServer,\n http,\n standard,\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(), standard(), http(), mcp()]\n : [productionSplash(), standard(), 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,MAA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2 @@
|
|
|
1
|
-
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as standard, t as CapableServer } from "./index-
|
|
1
|
+
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as standard, t as CapableServer } from "./index-B2ru1zGQ.mjs";
|
|
2
2
|
export { CapableServer, CompiledServerMount, ServerMiddleware, ServerMount, createServer, http, standard };
|
package/dist/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as http, r as standard, t as createServer } from "./src-
|
|
1
|
+
import { n as http, r as standard, t as createServer } from "./src-DtSY5fzY.mjs";
|
|
2
2
|
export { createServer, http, standard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src-3UaBqI8H.mjs","names":[],"sources":["../../app/src/manifest.ts","../../app/src/runtime.ts","../../app/src/composition.ts"],"sourcesContent":["import {\n isCapability,\n isCapabilityGroup,\n schemaToJsonSchema,\n type AppDefinition,\n type LocatedCapability,\n} from \"@capable/core\";\n\nexport type JsonSchema = Readonly<Record<string, unknown>>;\n\nexport type ManifestError = {\n readonly message?: string;\n readonly data?: JsonSchema;\n readonly status?: number;\n readonly meta?: Readonly<Record<string, unknown>>;\n};\n\nexport type ManifestCapability = {\n readonly type: \"capability\";\n readonly id: string;\n readonly path: readonly string[];\n readonly title?: string;\n readonly description?: string;\n readonly deprecated: boolean;\n readonly effect?: \"read\" | \"write\" | \"destructive\";\n readonly subscription?: { readonly mode: \"replace\" };\n readonly input?: JsonSchema;\n readonly output?: JsonSchema;\n readonly errors: Readonly<Record<string, ManifestError>>;\n readonly meta: Readonly<Record<string, unknown>>;\n};\n\nexport type ManifestGroup = {\n readonly type: \"group\";\n readonly key: string;\n readonly title?: string;\n readonly description?: string;\n readonly meta: Readonly<Record<string, unknown>>;\n readonly children: readonly ManifestNode[];\n};\n\nexport type ManifestNode = ManifestGroup | ManifestCapability;\n\nexport type ApplicationManifest = {\n readonly protocol: \"capable.capabilities.v2\";\n readonly name: string;\n readonly version: string;\n readonly description?: string;\n readonly capabilities: readonly ManifestNode[];\n};\n\nexport function createAppManifest(\n definition: AppDefinition<any>,\n): ApplicationManifest {\n const byCapability = new Map(\n definition.locatedCapabilities.map((entry) => [entry.capability, entry]),\n );\n return Object.freeze({\n protocol: \"capable.capabilities.v2\",\n name: definition.name,\n version: definition.version,\n ...(definition.description ? { description: definition.description } : {}),\n capabilities: manifestNodes(definition.capabilities, byCapability),\n });\n}\n\nexport function validateManifest(\n manifest: ApplicationManifest,\n label: string,\n): void {\n if (manifest.protocol !== \"capable.capabilities.v2\") {\n throw new Error(`${label} uses unsupported protocol \"${manifest.protocol}\"`);\n }\n const capabilities = flattenManifestCapabilities(manifest.capabilities);\n const ids = new Set<string>();\n const paths = new Set<string>();\n for (const capability of capabilities) {\n const path = capability.path.join(\".\");\n if (ids.has(capability.id)) {\n throw new Error(\n `${label} contains duplicate Capability id \"${capability.id}\"`,\n );\n }\n if (paths.has(path)) {\n throw new Error(`${label} contains duplicate Capability path \"${path}\"`);\n }\n ids.add(capability.id);\n paths.add(path);\n }\n validateManifestPaths(manifest.capabilities, [], label);\n}\n\nexport function mergeApplicationManifests(\n manifests: readonly ApplicationManifest[],\n): ApplicationManifest {\n const conflicts = collectManifestConflicts(manifests);\n if (conflicts.length) {\n throw new Error(\n `Cannot merge Apps:\\n${conflicts.map((item) => `- ${item}`).join(\"\\n\")}`,\n );\n }\n return Object.freeze({\n protocol: \"capable.capabilities.v2\",\n name: manifests.map(({ name }) => name).join(\" + \"),\n version: manifests.map(({ version }) => version).join(\" + \"),\n capabilities: mergeManifestNodes(\n manifests.flatMap(({ capabilities }) => capabilities),\n ),\n });\n}\n\nexport function selectManifest(\n source: ApplicationManifest,\n selection: {\n readonly include?: unknown;\n readonly exclude?: unknown;\n },\n): ApplicationManifest {\n return Object.freeze({\n ...source,\n capabilities: filterManifestNodes(source.capabilities, selection),\n });\n}\n\nexport function flattenManifestCapabilities(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\"\n ? [node]\n : flattenManifestCapabilities(node.children)\n );\n}\n\nexport function findManifestCapability(\n nodes: readonly ManifestNode[],\n path: readonly string[],\n): ManifestCapability | undefined {\n let current = nodes;\n for (let index = 0; index < path.length; index++) {\n const key = path[index]!;\n const node = current.find((candidate) =>\n candidate.type === \"group\"\n ? candidate.key === key\n : candidate.path.at(-1) === key\n );\n if (!node) return undefined;\n if (node.type === \"capability\") {\n return index === path.length - 1 ? node : undefined;\n }\n current = node.children;\n }\n return undefined;\n}\n\nfunction manifestNodes(\n tree: Readonly<Record<string, unknown>>,\n located: ReadonlyMap<unknown, LocatedCapability>,\n): readonly ManifestNode[] {\n const nodes: ManifestNode[] = [];\n for (const [key, value] of Object.entries(tree)) {\n if (isCapability(value)) {\n const entry = located.get(value);\n if (entry) nodes.push(manifestCapability(entry));\n continue;\n }\n const decorated = isCapabilityGroup(value);\n const childTree = decorated\n ? value.capabilities\n : value as Readonly<Record<string, unknown>>;\n const children = manifestNodes(childTree, located);\n nodes.push(Object.freeze({\n type: \"group\",\n key,\n ...(decorated && value.title ? { title: value.title } : {}),\n ...(decorated && value.description\n ? { description: value.description }\n : {}),\n meta: decorated ? value.meta : {},\n children,\n } satisfies ManifestGroup));\n }\n return nodes;\n}\n\nfunction manifestCapability(entry: LocatedCapability): ManifestCapability {\n const capability = entry.capability;\n return Object.freeze({\n type: \"capability\",\n id: capability.id,\n path: entry.path,\n ...(capability.title ? { title: capability.title } : {}),\n ...(capability.description ? { description: capability.description } : {}),\n deprecated: capability.deprecated,\n ...(capability.effect ? { effect: capability.effect } : {}),\n ...(capability.subscribe\n ? { subscription: { mode: \"replace\" as const } }\n : {}),\n ...(capability.input\n ? { input: schemaToJsonSchema(capability.input, \"input\") }\n : {}),\n ...(capability.output\n ? { output: schemaToJsonSchema(capability.output, \"output\") }\n : {}),\n errors: Object.fromEntries(\n Object.entries(entry.errors).map(([code, definition]) => [\n code,\n {\n ...(definition.message ? { message: definition.message } : {}),\n ...(typeof definition.status === \"number\"\n ? { status: definition.status }\n : {}),\n ...(definition.data\n ? { data: schemaToJsonSchema(definition.data, \"output\") }\n : {}),\n ...(definition.meta ? { meta: definition.meta } : {}),\n } satisfies ManifestError,\n ]),\n ),\n meta: capability.meta,\n });\n}\n\nfunction validateManifestPaths(\n nodes: readonly ManifestNode[],\n parent: readonly string[],\n label: string,\n): void {\n for (const node of nodes) {\n if (node.type === \"group\") {\n validateManifestPaths(node.children, [...parent, node.key], label);\n continue;\n }\n if (!samePath(node.path, [...parent, node.path.at(-1)!])) {\n throw new Error(\n `${label} Capability \"${node.id}\" declares path \"${node.path.join(\".\")}\" that does not match its manifest placement`,\n );\n }\n }\n}\n\nfunction collectManifestConflicts(\n manifests: readonly ApplicationManifest[],\n): readonly string[] {\n const conflicts: string[] = [];\n for (const manifest of manifests) {\n try {\n validateManifest(manifest, manifest.name);\n } catch (error) {\n conflicts.push(error instanceof Error ? error.message : String(error));\n }\n }\n const capabilities = manifests.flatMap((manifest, source) =>\n flattenManifestCapabilities(manifest.capabilities).map((capability) => ({\n capability,\n source,\n label: manifest.name,\n }))\n );\n for (let leftIndex = 0; leftIndex < capabilities.length; leftIndex++) {\n for (\n let rightIndex = leftIndex + 1;\n rightIndex < capabilities.length;\n rightIndex++\n ) {\n const left = capabilities[leftIndex]!;\n const right = capabilities[rightIndex]!;\n if (left.source === right.source) continue;\n const sameId = left.capability.id === right.capability.id;\n const sameCapabilityPath = samePath(\n left.capability.path,\n right.capability.path,\n );\n if (sameCapabilityPath) {\n conflicts.push(\n sameId\n ? `Capability \"${left.capability.id}\" is mounted twice at \"${left.capability.path.join(\".\")}\" by \"${left.label}\" and \"${right.label}\"`\n : `Path \"${left.capability.path.join(\".\")}\" contains both \"${left.capability.id}\" from \"${left.label}\" and \"${right.capability.id}\" from \"${right.label}\"`,\n );\n continue;\n }\n if (sameId) {\n conflicts.push(\n `Capability id \"${left.capability.id}\" appears at both \"${left.capability.path.join(\".\")}\" in \"${left.label}\" and \"${right.capability.path.join(\".\")}\"`,\n );\n }\n if (\n isPathPrefix(left.capability.path, right.capability.path) ||\n isPathPrefix(right.capability.path, left.capability.path)\n ) {\n const leaf = left.capability.path.length < right.capability.path.length\n ? left\n : right;\n const subtree = leaf === left ? right : left;\n conflicts.push(\n `Leaf \"${leaf.capability.path.join(\".\")}\" from \"${leaf.label}\" collides with subtree Capability \"${subtree.capability.path.join(\".\")}\" from \"${subtree.label}\"`,\n );\n }\n }\n }\n return [...new Set(conflicts)];\n}\n\nfunction mergeManifestNodes(\n nodes: readonly ManifestNode[],\n): readonly ManifestNode[] {\n const merged = new Map<string, ManifestNode>();\n for (const node of nodes) {\n const key = node.type === \"group\" ? node.key : node.path.at(-1)!;\n const previous = merged.get(key);\n if (!previous) {\n merged.set(key, node);\n continue;\n }\n if (previous.type !== \"group\" || node.type !== \"group\") {\n throw new Error(`Manifest node collision at \"${key}\"`);\n }\n merged.set(key, Object.freeze({\n type: \"group\",\n key,\n ...mergeGroupField(\"title\", previous.title, node.title, key),\n ...mergeGroupField(\n \"description\",\n previous.description,\n node.description,\n key,\n ),\n meta: mergeGroupMeta(previous.meta, node.meta, key),\n children: mergeManifestNodes([...previous.children, ...node.children]),\n }));\n }\n return [...merged.values()];\n}\n\nfunction mergeGroupField(\n field: \"title\" | \"description\",\n left: string | undefined,\n right: string | undefined,\n path: string,\n): Record<string, string> {\n if (left && right && left !== right) {\n throw new Error(`Group \"${path}\" has conflicting ${field}`);\n }\n const value = left ?? right;\n return value ? { [field]: value } : {};\n}\n\nfunction mergeGroupMeta(\n left: Readonly<Record<string, unknown>>,\n right: Readonly<Record<string, unknown>>,\n path: string,\n): Readonly<Record<string, unknown>> {\n const merged: Record<string, unknown> = { ...left };\n for (const [key, value] of Object.entries(right)) {\n if (\n key in merged &&\n JSON.stringify(merged[key]) !== JSON.stringify(value)\n ) {\n throw new Error(\n `Group \"${path}\" has conflicting metadata for \"${key}\"`,\n );\n }\n merged[key] = value;\n }\n return Object.freeze(merged);\n}\n\nfunction filterManifestNodes(\n nodes: readonly ManifestNode[],\n selection: {\n readonly include?: unknown;\n readonly exclude?: unknown;\n },\n): readonly ManifestNode[] {\n const filtered: ManifestNode[] = [];\n for (const node of nodes) {\n if (node.type === \"capability\") {\n const included = selection.include\n ? matchesSelection(selection.include, node.path)\n : true;\n if (included && !matchesSelection(selection.exclude, node.path)) {\n filtered.push(node);\n }\n continue;\n }\n const children = filterManifestNodes(node.children, selection);\n if (children.length) filtered.push(Object.freeze({ ...node, children }));\n }\n return filtered;\n}\n\nfunction matchesSelection(\n tree: unknown,\n path: readonly string[],\n): boolean {\n let current = tree;\n for (const segment of path) {\n if (current === true) return true;\n if (!current || typeof current !== \"object\" || Array.isArray(current)) {\n return false;\n }\n current = (current as Record<string, unknown>)[segment];\n }\n return current === true || (\n Boolean(current) && typeof current === \"object\" && !Array.isArray(current)\n );\n}\n\nfunction samePath(\n left: readonly string[],\n right: readonly string[],\n): boolean {\n return left.length === right.length &&\n left.every((segment, index) => segment === right[index]);\n}\n\nfunction isPathPrefix(\n prefix: readonly string[],\n path: readonly string[],\n): boolean {\n return prefix.length < path.length &&\n prefix.every((segment, index) => segment === path[index]);\n}\n","import {\n CapableError,\n executeLocatedCapability,\n subscribeLocatedCapability,\n type AnyCapability,\n type AnyObjectSchema,\n type AppDefinition,\n type AppContext,\n type InferSchemaInput,\n type LocatedCapability,\n type MaybePromise,\n type CapabilityDefinition,\n type CapabilityGroupDefinition,\n type CapabilityOutput,\n type CapabilityTree,\n type SubscribableCapability,\n} from \"@capable/core\";\nimport {\n createAppManifest,\n findManifestCapability,\n validateManifest,\n type ApplicationManifest,\n} from \"./manifest.ts\";\n\nexport type CapabilityCall = {\n readonly id: string;\n readonly input?: unknown;\n readonly signal?: AbortSignal;\n};\n\nexport type CapabilityResult = {\n readonly output: unknown;\n readonly markdown?: string;\n};\n\nexport interface ApplicationTransport {\n manifest(\n options?: { readonly signal?: AbortSignal },\n ): Promise<ApplicationManifest>;\n call(call: CapabilityCall): Promise<CapabilityResult>;\n subscribe(call: CapabilityCall): AsyncIterableIterator<CapabilityResult>;\n}\n\nexport const APP_RUNTIME_SYMBOL = Symbol.for(\"capable.app.runtime\");\nexport const APP_CAPABILITIES_SYMBOL = Symbol.for(\"capable.app.capabilities\");\nconst APP_CALL_SYMBOL = Symbol.for(\"capable.app.call\");\n\ntype AppCapabilityType<TCapability extends AnyCapability> = {\n readonly \"~capable/capability\"?: TCapability;\n};\n\ntype AppCapabilityInput<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, infer TInput, any, any, any>\n ? TInput extends AnyObjectSchema\n ? InferSchemaInput<TInput>\n : Record<never, never>\n : never;\n\ntype AppCapabilityOutput<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any>\n ? TOutput\n : never;\n\ntype AppCapabilityArgs<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, infer TInput, any, any, any>\n ? TInput extends undefined\n ? [\n input?: Record<never, never>,\n options?: { readonly signal?: AbortSignal },\n ]\n : [\n input: AppCapabilityInput<TCapability>,\n options?: { readonly signal?: AbortSignal },\n ]\n : never;\n\nexport type AppCapabilityCall<TCapability extends AnyCapability> = ((\n ...args: AppCapabilityArgs<TCapability>\n) => Promise<AppCapabilityOutput<TCapability>>) &\n AppCapabilityType<TCapability>;\n\nexport type AppCapabilityIsSubscribable<TCall> =\n TCall extends AppCapabilityType<infer TCapability>\n ? TCapability extends CapabilityDefinition<any, any, any, any, any, true>\n ? true\n : false\n : false;\n\nexport type CallableTree<TTree> =\n TTree extends AnyCapability\n ? AppCapabilityCall<TTree>\n : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any>\n ? CallableTree<TCapabilities>\n : TTree extends CapabilityTree\n ? { readonly [TKey in keyof TTree]: CallableTree<TTree[TKey]> }\n : never;\n\nexport type App<\n TCapabilities extends CapabilityTree = CapabilityTree,\n> = CallableTree<TCapabilities> & {\n readonly [APP_RUNTIME_SYMBOL]: ApplicationTransport;\n readonly [APP_CAPABILITIES_SYMBOL]?: TCapabilities;\n};\n\nexport type AnyApp = {\n readonly [APP_RUNTIME_SYMBOL]: ApplicationTransport;\n readonly [APP_CAPABILITIES_SYMBOL]?: CapabilityTree;\n};\n\ntype DefinitionCapabilities<TDefinition extends AppDefinition<any, any>> =\n TDefinition extends AppDefinition<infer TCapabilities>\n ? TCapabilities\n : never;\n\nexport type AppCapabilities<\n TApplication extends AnyApp,\n> = TApplication extends {\n readonly [APP_CAPABILITIES_SYMBOL]?: infer TCapabilities extends CapabilityTree;\n}\n ? TCapabilities\n : never;\n\nexport function getAppRuntime(\n app: AnyApp,\n): ApplicationTransport {\n return app[APP_RUNTIME_SYMBOL];\n}\n\nexport function isApp(value: unknown): value is AnyApp {\n return Boolean(\n value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n (value as Partial<AnyApp>)[APP_RUNTIME_SYMBOL],\n );\n}\n\nexport function appFromRuntime<\n TCapabilities extends CapabilityTree,\n>(\n runtime: ApplicationTransport,\n): App<TCapabilities> {\n const read = (path: readonly string[], root: boolean, key: PropertyKey) => {\n if (root && key === APP_RUNTIME_SYMBOL) return runtime;\n if (!root && key === APP_CALL_SYMBOL) return { runtime, path };\n if (key === \"then\") return undefined;\n if (typeof key !== \"string\") return undefined;\n return proxy([...path, key], false);\n };\n\n const proxy = (path: readonly string[], root: boolean): unknown => {\n if (root) {\n return new Proxy({}, {\n get(_target, key) {\n return read(path, true, key);\n },\n });\n }\n return new Proxy(() => undefined, {\n get(_target, key) {\n return read(path, false, key);\n },\n async apply(_target, _this, args: [unknown?, { signal?: AbortSignal }?]) {\n const capability = findManifestCapability(\n (await runtime.manifest()).capabilities,\n path,\n );\n if (!capability) {\n throw new Error(`No Capability exists at \"${path.join(\".\")}\"`);\n }\n const result = await runtime.call({\n id: capability.id,\n input: args[0] ?? {},\n ...(args[1]?.signal ? { signal: args[1].signal } : {}),\n });\n return result.output;\n },\n });\n };\n\n return proxy([], true) as App<TCapabilities>;\n}\n\nexport function subscribe<\n const TCapability extends SubscribableCapability,\n>(\n capabilityCall: AppCapabilityCall<TCapability>,\n ...args: AppCapabilityArgs<TCapability>\n): AsyncIterableIterator<CapabilityOutput<TCapability>> {\n const binding = (\n capabilityCall as unknown as Record<PropertyKey, unknown>\n )[APP_CALL_SYMBOL] as\n | {\n readonly runtime: ApplicationTransport;\n readonly path: readonly string[];\n }\n | undefined;\n if (!binding) {\n throw new Error(\"subscribe() requires a Capability call from a Capable App\");\n }\n\n return (async function* () {\n const manifest = await binding.runtime.manifest();\n const capability = findManifestCapability(\n manifest.capabilities,\n binding.path,\n );\n if (!capability) {\n throw new Error(`No Capability exists at \"${binding.path.join(\".\")}\"`);\n }\n if (!capability.subscription) {\n throw new Error(`Capability \"${capability.id}\" is not subscribable`);\n }\n const stream = binding.runtime.subscribe({\n id: capability.id,\n input: args[0] ?? {},\n ...(args[1]?.signal ? { signal: args[1].signal } : {}),\n });\n try {\n for await (const result of stream) {\n yield result.output as CapabilityOutput<TCapability>;\n }\n } finally {\n await stream.return?.();\n }\n })();\n}\n\nexport type AppContextProvider<TContext> = (call: {\n readonly id: string;\n readonly signal?: AbortSignal;\n}) => MaybePromise<TContext>;\n\ntype CreateAppOptions<TContext> = {\n readonly context: AppContextProvider<TContext>;\n};\n\ntype CreateAppArgs<TContext> = [TContext] extends [undefined]\n ? [options?: Partial<CreateAppOptions<TContext>>]\n : [options: CreateAppOptions<TContext>];\n\nconst localManifestCache = new WeakMap<object, ApplicationManifest>();\nconst localCapabilityCache = new WeakMap<\n object,\n ReadonlyMap<string, LocatedCapability>\n>();\n\nexport function createApp<\n const TDefinition extends AppDefinition<any, any>,\n>(\n definition: TDefinition,\n ...[options]: CreateAppArgs<AppContext<TDefinition>>\n): App<DefinitionCapabilities<TDefinition>> {\n let manifest = localManifestCache.get(definition);\n if (!manifest) {\n manifest = createAppManifest(definition);\n localManifestCache.set(definition, manifest);\n }\n let byId = localCapabilityCache.get(definition);\n if (!byId) {\n byId = new Map(\n definition.locatedCapabilities.map((entry) => [entry.capability.id, entry]),\n );\n localCapabilityCache.set(definition, byId);\n }\n\n const runtime: ApplicationTransport = Object.freeze({\n async manifest() {\n return manifest;\n },\n async call({ id, input = {}, signal }: CapabilityCall) {\n const located = byId.get(id);\n if (!located) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n\n let context: unknown;\n try {\n context = options?.context\n ? await options.context({\n id,\n ...(signal ? { signal } : {}),\n })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n let output: unknown;\n try {\n output = await executeLocatedCapability(located, input, {\n context,\n ...(signal ? { signal } : {}),\n });\n } catch (error) {\n if (error instanceof CapableError) {\n throw new TransportError(error.code, {\n ...(error.message ? { message: error.message } : {}),\n ...(typeof error.status === \"number\"\n ? { status: error.status }\n : {}),\n ...(error.data === undefined ? {} : { data: error.data }),\n cause: error,\n });\n }\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause: error });\n }\n\n let markdown: string | undefined;\n try {\n markdown = located.capability.toMarkdown\n ? await located.capability.toMarkdown(output, { context })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n return {\n output,\n ...(markdown ? { markdown } : {}),\n };\n },\n async *subscribe({ id, input = {}, signal }: CapabilityCall) {\n const located = byId.get(id);\n if (!located) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n if (!located.capability.subscribe) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n\n let context: unknown;\n try {\n context = options?.context\n ? await options.context({\n id,\n ...(signal ? { signal } : {}),\n })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n const stream = subscribeLocatedCapability(located, input, {\n context,\n ...(signal ? { signal } : {}),\n });\n try {\n for await (const output of stream) {\n let markdown: string | undefined;\n try {\n markdown = located.capability.toMarkdown\n ? await located.capability.toMarkdown(output, { context })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n yield {\n output,\n ...(markdown ? { markdown } : {}),\n };\n }\n } catch (error) {\n throw toTransportError(error);\n } finally {\n await stream.return?.();\n }\n },\n });\n return appFromRuntime(runtime);\n}\n\nexport function createRemoteApp<\n TDefinition extends AppDefinition<any, any> = AppDefinition<CapabilityTree>,\n>(\n transport: ApplicationTransport,\n): App<DefinitionCapabilities<TDefinition>> {\n const manifest = createManifestResolver(async () => {\n const manifest = await transport.manifest();\n validateManifest(manifest, \"Remote App\");\n return manifest;\n });\n return appFromRuntime(Object.freeze({\n manifest,\n async call(call: CapabilityCall) {\n await manifest();\n return transport.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await manifest();\n yield* transport.subscribe(call);\n },\n }));\n}\n\nexport function createManifestResolver(\n load: () => Promise<ApplicationManifest>,\n): () => Promise<ApplicationManifest> {\n let cached: Promise<ApplicationManifest> | undefined;\n return () => {\n if (cached) return cached;\n const attempt = Promise.resolve().then(load);\n cached = attempt;\n void attempt.catch(() => {\n if (cached === attempt) cached = undefined;\n });\n return attempt;\n };\n}\n\nexport class TransportError extends Error {\n readonly code: string;\n readonly status: number | undefined;\n readonly data: unknown;\n\n constructor(\n code: string,\n options: {\n readonly message?: string;\n readonly status?: number;\n readonly data?: unknown;\n readonly cause?: unknown;\n } = {},\n ) {\n super(options.message ?? code, { cause: options.cause });\n this.name = \"TransportError\";\n this.code = code;\n this.status = options.status;\n this.data = options.data;\n }\n}\n\nfunction toTransportError(error: unknown): TransportError {\n if (error instanceof TransportError) return error;\n if (error instanceof CapableError) {\n return new TransportError(error.code, {\n ...(error.message ? { message: error.message } : {}),\n ...(typeof error.status === \"number\" ? { status: error.status } : {}),\n ...(error.data === undefined ? {} : { data: error.data }),\n cause: error,\n });\n }\n return new TransportError(\"INTERNAL_SERVER_ERROR\", { cause: error });\n}\n","import type {\n AnyCapability,\n CapabilityGroupDefinition,\n CapabilityTree,\n} from \"@capable/core\";\nimport {\n appFromRuntime,\n createManifestResolver,\n getAppRuntime,\n TransportError,\n type AnyApp,\n type App,\n type AppCapabilities,\n type ApplicationTransport,\n type CapabilityCall,\n} from \"./runtime.ts\";\nimport {\n flattenManifestCapabilities,\n mergeApplicationManifests,\n selectManifest,\n} from \"./manifest.ts\";\n\ntype UnionToIntersection<TValue> =\n (TValue extends unknown ? (value: TValue) => void : never) extends\n (value: infer TIntersection) => void ? TIntersection : never;\n\ntype MergedCapabilities<\n TApplications extends readonly AnyApp[],\n> = UnionToIntersection<AppCapabilities<TApplications[number]>> &\n CapabilityTree;\n\nexport function mergeApps<\n const TApplications extends readonly [\n AnyApp,\n ...AnyApp[],\n ],\n>(\n ...applications: TApplications\n): App<MergedCapabilities<TApplications>> {\n const runtimes = applications.map(getAppRuntime);\n let dispatch: ReadonlyMap<string, ApplicationTransport> | undefined;\n\n const resolve = createManifestResolver(async () => {\n const manifests = await Promise.all(\n runtimes.map((runtime) => runtime.manifest()),\n );\n const nextDispatch = new Map<string, ApplicationTransport>();\n manifests.forEach((manifest, index) => {\n for (\n const capability of flattenManifestCapabilities(\n manifest.capabilities,\n )\n ) {\n nextDispatch.set(capability.id, runtimes[index]!);\n }\n });\n const merged = mergeApplicationManifests(manifests);\n dispatch = nextDispatch;\n return merged;\n });\n\n return appFromRuntime(Object.freeze({\n manifest: resolve,\n async call(call: CapabilityCall) {\n await resolve();\n const target = dispatch?.get(call.id);\n if (!target) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n return target.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await resolve();\n const target = dispatch?.get(call.id);\n if (!target) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n yield* target.subscribe(call);\n },\n }));\n}\n\ntype SelectionNode<TTree> =\n TTree extends AnyCapability\n ? true\n : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any>\n ? true | SelectionNode<TCapabilities>\n : TTree extends CapabilityTree\n ? true | {\n readonly [TKey in keyof TTree]?: SelectionNode<TTree[TKey]>;\n }\n : never;\n\nexport type ApplicationSelection<\n TCapabilities extends CapabilityTree = CapabilityTree,\n> = {\n readonly include?: Exclude<SelectionNode<TCapabilities>, true>;\n readonly exclude?: Exclude<SelectionNode<TCapabilities>, true>;\n};\n\nexport function selectApp<\n const TCapabilities extends CapabilityTree,\n>(\n application: App<TCapabilities>,\n selection: ApplicationSelection<TCapabilities>,\n): App<TCapabilities> {\n const runtime = getAppRuntime(application);\n let ids: ReadonlySet<string> | undefined;\n const manifest = createManifestResolver(async () => {\n const selected = selectManifest(await runtime.manifest(), selection);\n ids = new Set(\n flattenManifestCapabilities(selected.capabilities).map(\n (capability) => capability.id,\n ),\n );\n return selected;\n });\n return appFromRuntime(Object.freeze({\n manifest,\n async call(call: CapabilityCall) {\n await manifest();\n if (!ids?.has(call.id)) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n return runtime.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await manifest();\n if (!ids?.has(call.id)) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n yield* runtime.subscribe(call);\n },\n }));\n}\n"],"mappings":";;AAmDA,SAAgB,kBACd,YACqB;CACrB,MAAM,eAAe,IAAI,IACvB,WAAW,oBAAoB,KAAK,UAAU,CAAC,MAAM,YAAY,KAAK,CAAC,CACzE;CACA,OAAO,OAAO,OAAO;EACnB,UAAU;EACV,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,GAAI,WAAW,cAAc,EAAE,aAAa,WAAW,YAAY,IAAI,CAAC;EACxE,cAAc,cAAc,WAAW,cAAc,YAAY;CACnE,CAAC;AACH;AAEA,SAAgB,iBACd,UACA,OACM;CACN,IAAI,SAAS,aAAa,2BACxB,MAAM,IAAI,MAAM,GAAG,MAAM,8BAA8B,SAAS,SAAS,EAAE;CAE7E,MAAM,eAAe,4BAA4B,SAAS,YAAY;CACtE,MAAM,s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AAI;EACzB;EACA,OAAO,UAAU,MAAsB;GACrC,MAAM,QAAQ;GACd,MAAM,SAAS,UAAU,IAAI,KAAK,EAAE;GACpC,IAAI,CAAC,QAAQ,MAAM,IAAI,eAAe,aAAa,EAAE,QAAQ,IAAI,CAAC;GAClE,OAAO,OAAO,UAAU,IAAI;EAC9B;CACF,CAAC,CAAC;AACJ;AAoBA,SAAgB,UAGd,aACA,WACoB;CACpB,MAAM,UAAU,cAAc,WAAW;CACzC,IAAI;CACJ,MAAM,WAAW,uBAAuB,YAAY;EAClD,MAAM,WAAW,eAAe,MAAM,QAAQ,SAAS,GAAG,SAAS;EACnE,MAAM,IAAI,IACR,4BAA4B,SAAS,YAAY,CAAC,CAAC,KAChD,eAAe,WAAW,EAC7B,CACF;EACA,OAAO;CACT,CAAC;CACD,OAAO,eAAe,OAAO,OAAO;EAClC;EACA,MAAM,KAAK,MAAsB;GAC/B,MAAM,SAAS;GACf,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,GACnB,MAAM,IAAI,eAAe,aAAa,EAAE,QAAQ,IAAI,CAAC;GAEvD,OAAO,QAAQ,KAAK,IAAI;EAC1B;EACA,OAAO,UAAU,MAAsB;GACrC,MAAM,SAAS;GACf,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,GACnB,MAAM,IAAI,eAAe,aAAa,EAAE,QAAQ,IAAI,CAAC;GAEvD,OAAO,QAAQ,UAAU,IAAI;EAC/B;CACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"src-3UaBqI8H.mjs","names":[],"sources":["../../app/src/manifest.ts","../../app/src/runtime.ts","../../app/src/composition.ts"],"sourcesContent":["import {\n isCapability,\n isCapabilityGroup,\n schemaToJsonSchema,\n type AppDefinition,\n type LocatedCapability,\n} from \"@capable/core\";\n\nexport type JsonSchema = Readonly<Record<string, unknown>>;\n\nexport type ManifestError = {\n readonly message?: string;\n readonly data?: JsonSchema;\n readonly status?: number;\n readonly meta?: Readonly<Record<string, unknown>>;\n};\n\nexport type ManifestCapability = {\n readonly type: \"capability\";\n readonly id: string;\n readonly path: readonly string[];\n readonly title?: string;\n readonly description?: string;\n readonly deprecated: boolean;\n readonly effect?: \"read\" | \"write\" | \"destructive\";\n readonly subscription?: { readonly mode: \"replace\" };\n readonly input?: JsonSchema;\n readonly output?: JsonSchema;\n readonly errors: Readonly<Record<string, ManifestError>>;\n readonly meta: Readonly<Record<string, unknown>>;\n};\n\nexport type ManifestGroup = {\n readonly type: \"group\";\n readonly key: string;\n readonly title?: string;\n readonly description?: string;\n readonly meta: Readonly<Record<string, unknown>>;\n readonly children: readonly ManifestNode[];\n};\n\nexport type ManifestNode = ManifestGroup | ManifestCapability;\n\nexport type ApplicationManifest = {\n readonly protocol: \"capable.capabilities.v2\";\n readonly name: string;\n readonly version: string;\n readonly description?: string;\n readonly capabilities: readonly ManifestNode[];\n};\n\nexport function createAppManifest(\n definition: AppDefinition<any>,\n): ApplicationManifest {\n const byCapability = new Map(\n definition.locatedCapabilities.map((entry) => [entry.capability, entry]),\n );\n return Object.freeze({\n protocol: \"capable.capabilities.v2\",\n name: definition.name,\n version: definition.version,\n ...(definition.description ? { description: definition.description } : {}),\n capabilities: manifestNodes(definition.capabilities, byCapability),\n });\n}\n\nexport function validateManifest(\n manifest: ApplicationManifest,\n label: string,\n): void {\n if (manifest.protocol !== \"capable.capabilities.v2\") {\n throw new Error(`${label} uses unsupported protocol \"${manifest.protocol}\"`);\n }\n const capabilities = flattenManifestCapabilities(manifest.capabilities);\n const ids = new Set<string>();\n const paths = new Set<string>();\n for (const capability of capabilities) {\n const path = capability.path.join(\".\");\n if (ids.has(capability.id)) {\n throw new Error(\n `${label} contains duplicate Capability id \"${capability.id}\"`,\n );\n }\n if (paths.has(path)) {\n throw new Error(`${label} contains duplicate Capability path \"${path}\"`);\n }\n ids.add(capability.id);\n paths.add(path);\n }\n validateManifestPaths(manifest.capabilities, [], label);\n}\n\nexport function mergeApplicationManifests(\n manifests: readonly ApplicationManifest[],\n): ApplicationManifest {\n const conflicts = collectManifestConflicts(manifests);\n if (conflicts.length) {\n throw new Error(\n `Cannot merge Apps:\\n${conflicts.map((item) => `- ${item}`).join(\"\\n\")}`,\n );\n }\n return Object.freeze({\n protocol: \"capable.capabilities.v2\",\n name: manifests.map(({ name }) => name).join(\" + \"),\n version: manifests.map(({ version }) => version).join(\" + \"),\n capabilities: mergeManifestNodes(\n manifests.flatMap(({ capabilities }) => capabilities),\n ),\n });\n}\n\nexport function selectManifest(\n source: ApplicationManifest,\n selection: {\n readonly include?: unknown;\n readonly exclude?: unknown;\n },\n): ApplicationManifest {\n return Object.freeze({\n ...source,\n capabilities: filterManifestNodes(source.capabilities, selection),\n });\n}\n\nexport function flattenManifestCapabilities(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\"\n ? [node]\n : flattenManifestCapabilities(node.children)\n );\n}\n\nexport function findManifestCapability(\n nodes: readonly ManifestNode[],\n path: readonly string[],\n): ManifestCapability | undefined {\n let current = nodes;\n for (let index = 0; index < path.length; index++) {\n const key = path[index]!;\n const node = current.find((candidate) =>\n candidate.type === \"group\"\n ? candidate.key === key\n : candidate.path.at(-1) === key\n );\n if (!node) return undefined;\n if (node.type === \"capability\") {\n return index === path.length - 1 ? node : undefined;\n }\n current = node.children;\n }\n return undefined;\n}\n\nfunction manifestNodes(\n tree: Readonly<Record<string, unknown>>,\n located: ReadonlyMap<unknown, LocatedCapability>,\n): readonly ManifestNode[] {\n const nodes: ManifestNode[] = [];\n for (const [key, value] of Object.entries(tree)) {\n if (isCapability(value)) {\n const entry = located.get(value);\n if (entry) nodes.push(manifestCapability(entry));\n continue;\n }\n const decorated = isCapabilityGroup(value);\n const childTree = decorated\n ? value.capabilities\n : value as Readonly<Record<string, unknown>>;\n const children = manifestNodes(childTree, located);\n nodes.push(Object.freeze({\n type: \"group\",\n key,\n ...(decorated && value.title ? { title: value.title } : {}),\n ...(decorated && value.description\n ? { description: value.description }\n : {}),\n meta: decorated ? value.meta : {},\n children,\n } satisfies ManifestGroup));\n }\n return nodes;\n}\n\nfunction manifestCapability(entry: LocatedCapability): ManifestCapability {\n const capability = entry.capability;\n return Object.freeze({\n type: \"capability\",\n id: capability.id,\n path: entry.path,\n ...(capability.title ? { title: capability.title } : {}),\n ...(capability.description ? { description: capability.description } : {}),\n deprecated: capability.deprecated,\n ...(capability.effect ? { effect: capability.effect } : {}),\n ...(capability.subscribe\n ? { subscription: { mode: \"replace\" as const } }\n : {}),\n ...(capability.input\n ? { input: schemaToJsonSchema(capability.input, \"input\") }\n : {}),\n ...(capability.output\n ? { output: schemaToJsonSchema(capability.output, \"output\") }\n : {}),\n errors: Object.fromEntries(\n Object.entries(entry.errors).map(([code, definition]) => [\n code,\n {\n ...(definition.message ? { message: definition.message } : {}),\n ...(typeof definition.status === \"number\"\n ? { status: definition.status }\n : {}),\n ...(definition.data\n ? { data: schemaToJsonSchema(definition.data, \"output\") }\n : {}),\n ...(definition.meta ? { meta: definition.meta } : {}),\n } satisfies ManifestError,\n ]),\n ),\n meta: capability.meta,\n });\n}\n\nfunction validateManifestPaths(\n nodes: readonly ManifestNode[],\n parent: readonly string[],\n label: string,\n): void {\n for (const node of nodes) {\n if (node.type === \"group\") {\n validateManifestPaths(node.children, [...parent, node.key], label);\n continue;\n }\n if (!samePath(node.path, [...parent, node.path.at(-1)!])) {\n throw new Error(\n `${label} Capability \"${node.id}\" declares path \"${node.path.join(\".\")}\" that does not match its manifest placement`,\n );\n }\n }\n}\n\nfunction collectManifestConflicts(\n manifests: readonly ApplicationManifest[],\n): readonly string[] {\n const conflicts: string[] = [];\n for (const manifest of manifests) {\n try {\n validateManifest(manifest, manifest.name);\n } catch (error) {\n conflicts.push(error instanceof Error ? error.message : String(error));\n }\n }\n const capabilities = manifests.flatMap((manifest, source) =>\n flattenManifestCapabilities(manifest.capabilities).map((capability) => ({\n capability,\n source,\n label: manifest.name,\n }))\n );\n for (let leftIndex = 0; leftIndex < capabilities.length; leftIndex++) {\n for (\n let rightIndex = leftIndex + 1;\n rightIndex < capabilities.length;\n rightIndex++\n ) {\n const left = capabilities[leftIndex]!;\n const right = capabilities[rightIndex]!;\n if (left.source === right.source) continue;\n const sameId = left.capability.id === right.capability.id;\n const sameCapabilityPath = samePath(\n left.capability.path,\n right.capability.path,\n );\n if (sameCapabilityPath) {\n conflicts.push(\n sameId\n ? `Capability \"${left.capability.id}\" is mounted twice at \"${left.capability.path.join(\".\")}\" by \"${left.label}\" and \"${right.label}\"`\n : `Path \"${left.capability.path.join(\".\")}\" contains both \"${left.capability.id}\" from \"${left.label}\" and \"${right.capability.id}\" from \"${right.label}\"`,\n );\n continue;\n }\n if (sameId) {\n conflicts.push(\n `Capability id \"${left.capability.id}\" appears at both \"${left.capability.path.join(\".\")}\" in \"${left.label}\" and \"${right.capability.path.join(\".\")}\"`,\n );\n }\n if (\n isPathPrefix(left.capability.path, right.capability.path) ||\n isPathPrefix(right.capability.path, left.capability.path)\n ) {\n const leaf = left.capability.path.length < right.capability.path.length\n ? left\n : right;\n const subtree = leaf === left ? right : left;\n conflicts.push(\n `Leaf \"${leaf.capability.path.join(\".\")}\" from \"${leaf.label}\" collides with subtree Capability \"${subtree.capability.path.join(\".\")}\" from \"${subtree.label}\"`,\n );\n }\n }\n }\n return [...new Set(conflicts)];\n}\n\nfunction mergeManifestNodes(\n nodes: readonly ManifestNode[],\n): readonly ManifestNode[] {\n const merged = new Map<string, ManifestNode>();\n for (const node of nodes) {\n const key = node.type === \"group\" ? node.key : node.path.at(-1)!;\n const previous = merged.get(key);\n if (!previous) {\n merged.set(key, node);\n continue;\n }\n if (previous.type !== \"group\" || node.type !== \"group\") {\n throw new Error(`Manifest node collision at \"${key}\"`);\n }\n merged.set(key, Object.freeze({\n type: \"group\",\n key,\n ...mergeGroupField(\"title\", previous.title, node.title, key),\n ...mergeGroupField(\n \"description\",\n previous.description,\n node.description,\n key,\n ),\n meta: mergeGroupMeta(previous.meta, node.meta, key),\n children: mergeManifestNodes([...previous.children, ...node.children]),\n }));\n }\n return [...merged.values()];\n}\n\nfunction mergeGroupField(\n field: \"title\" | \"description\",\n left: string | undefined,\n right: string | undefined,\n path: string,\n): Record<string, string> {\n if (left && right && left !== right) {\n throw new Error(`Group \"${path}\" has conflicting ${field}`);\n }\n const value = left ?? right;\n return value ? { [field]: value } : {};\n}\n\nfunction mergeGroupMeta(\n left: Readonly<Record<string, unknown>>,\n right: Readonly<Record<string, unknown>>,\n path: string,\n): Readonly<Record<string, unknown>> {\n const merged: Record<string, unknown> = { ...left };\n for (const [key, value] of Object.entries(right)) {\n if (\n key in merged &&\n JSON.stringify(merged[key]) !== JSON.stringify(value)\n ) {\n throw new Error(\n `Group \"${path}\" has conflicting metadata for \"${key}\"`,\n );\n }\n merged[key] = value;\n }\n return Object.freeze(merged);\n}\n\nfunction filterManifestNodes(\n nodes: readonly ManifestNode[],\n selection: {\n readonly include?: unknown;\n readonly exclude?: unknown;\n },\n): readonly ManifestNode[] {\n const filtered: ManifestNode[] = [];\n for (const node of nodes) {\n if (node.type === \"capability\") {\n const included = selection.include\n ? matchesSelection(selection.include, node.path)\n : true;\n if (included && !matchesSelection(selection.exclude, node.path)) {\n filtered.push(node);\n }\n continue;\n }\n const children = filterManifestNodes(node.children, selection);\n if (children.length) filtered.push(Object.freeze({ ...node, children }));\n }\n return filtered;\n}\n\nfunction matchesSelection(\n tree: unknown,\n path: readonly string[],\n): boolean {\n let current = tree;\n for (const segment of path) {\n if (current === true) return true;\n if (!current || typeof current !== \"object\" || Array.isArray(current)) {\n return false;\n }\n current = (current as Record<string, unknown>)[segment];\n }\n return current === true || (\n Boolean(current) && typeof current === \"object\" && !Array.isArray(current)\n );\n}\n\nfunction samePath(\n left: readonly string[],\n right: readonly string[],\n): boolean {\n return left.length === right.length &&\n left.every((segment, index) => segment === right[index]);\n}\n\nfunction isPathPrefix(\n prefix: readonly string[],\n path: readonly string[],\n): boolean {\n return prefix.length < path.length &&\n prefix.every((segment, index) => segment === path[index]);\n}\n","import {\n CapableError,\n executeLocatedCapability,\n subscribeLocatedCapability,\n type AnyCapability,\n type AnyObjectSchema,\n type AppDefinition,\n type AppContext,\n type InferSchemaInput,\n type LocatedCapability,\n type MaybePromise,\n type CapabilityDefinition,\n type CapabilityGroupDefinition,\n type CapabilityOutput,\n type CapabilityTree,\n type SubscribableCapability,\n} from \"@capable/core\";\nimport {\n createAppManifest,\n findManifestCapability,\n validateManifest,\n type ApplicationManifest,\n} from \"./manifest.ts\";\n\nexport type CapabilityCall = {\n readonly id: string;\n readonly input?: unknown;\n readonly signal?: AbortSignal;\n};\n\nexport type CapabilityResult = {\n readonly output: unknown;\n readonly markdown?: string;\n};\n\nexport interface ApplicationTransport {\n manifest(\n options?: { readonly signal?: AbortSignal },\n ): Promise<ApplicationManifest>;\n call(call: CapabilityCall): Promise<CapabilityResult>;\n subscribe(call: CapabilityCall): AsyncIterableIterator<CapabilityResult>;\n}\n\nexport const APP_RUNTIME_SYMBOL: unique symbol = Symbol.for(\n \"capable.app.runtime\",\n) as never;\nexport const APP_CAPABILITIES_SYMBOL: unique symbol = Symbol.for(\n \"capable.app.capabilities\",\n) as never;\nconst APP_CALL_SYMBOL = Symbol.for(\"capable.app.call\");\n\ntype AppCapabilityType<TCapability extends AnyCapability> = {\n readonly \"~capable/capability\"?: TCapability;\n};\n\ntype AppCapabilityInput<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, infer TInput, any, any, any>\n ? TInput extends AnyObjectSchema\n ? InferSchemaInput<TInput>\n : Record<never, never>\n : never;\n\ntype AppCapabilityOutput<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any>\n ? TOutput\n : never;\n\ntype AppCapabilityOptions = { readonly signal?: AbortSignal };\n\ntype AppCapabilityArgs<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, infer TInput, any, any, any>\n ? TInput extends undefined\n ? [\n input?: Record<never, never>,\n options?: AppCapabilityOptions,\n ]\n : Record<never, never> extends AppCapabilityInput<TCapability>\n ? [\n input?: AppCapabilityInput<TCapability>,\n options?: AppCapabilityOptions,\n ]\n : [\n input: AppCapabilityInput<TCapability>,\n options?: AppCapabilityOptions,\n ]\n : never;\n\nexport type AppCapabilityCall<TCapability extends AnyCapability> = ((\n ...args: AppCapabilityArgs<TCapability>\n) => Promise<AppCapabilityOutput<TCapability>>) &\n AppCapabilityType<TCapability>;\n\nexport type AppCapabilityIsSubscribable<TCall> =\n TCall extends AppCapabilityType<infer TCapability>\n ? TCapability extends CapabilityDefinition<any, any, any, any, any, true>\n ? true\n : false\n : false;\n\nexport type CallableTree<TTree> =\n TTree extends AnyCapability\n ? AppCapabilityCall<TTree>\n : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any>\n ? CallableTree<TCapabilities>\n : TTree extends CapabilityTree\n ? { readonly [TKey in keyof TTree]: CallableTree<TTree[TKey]> }\n : never;\n\nexport type App<\n TCapabilities extends CapabilityTree = CapabilityTree,\n> = CallableTree<TCapabilities> & {\n readonly [APP_RUNTIME_SYMBOL]: ApplicationTransport;\n readonly [APP_CAPABILITIES_SYMBOL]?: TCapabilities;\n};\n\nexport type AnyApp = {\n readonly [APP_RUNTIME_SYMBOL]: ApplicationTransport;\n readonly [APP_CAPABILITIES_SYMBOL]?: CapabilityTree;\n};\n\ntype DefinitionCapabilities<TDefinition extends AppDefinition<any, any>> =\n TDefinition extends AppDefinition<infer TCapabilities>\n ? TCapabilities\n : never;\n\nexport type AppCapabilities<\n TApplication extends AnyApp,\n> = TApplication extends {\n readonly [APP_CAPABILITIES_SYMBOL]?: infer TCapabilities extends CapabilityTree;\n}\n ? TCapabilities\n : never;\n\nexport function getAppRuntime(\n app: AnyApp,\n): ApplicationTransport {\n return app[APP_RUNTIME_SYMBOL];\n}\n\nexport function isApp(value: unknown): value is AnyApp {\n return Boolean(\n value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n (value as Partial<AnyApp>)[APP_RUNTIME_SYMBOL],\n );\n}\n\nexport function appFromRuntime<\n TCapabilities extends CapabilityTree,\n>(\n runtime: ApplicationTransport,\n): App<TCapabilities> {\n const read = (path: readonly string[], root: boolean, key: PropertyKey) => {\n if (root && key === APP_RUNTIME_SYMBOL) return runtime;\n if (!root && key === APP_CALL_SYMBOL) return { runtime, path };\n if (key === \"then\") return undefined;\n if (typeof key !== \"string\") return undefined;\n return proxy([...path, key], false);\n };\n\n const proxy = (path: readonly string[], root: boolean): unknown => {\n if (root) {\n return new Proxy({}, {\n get(_target, key) {\n return read(path, true, key);\n },\n });\n }\n return new Proxy(() => undefined, {\n get(_target, key) {\n return read(path, false, key);\n },\n async apply(_target, _this, args: [unknown?, { signal?: AbortSignal }?]) {\n const capability = findManifestCapability(\n (await runtime.manifest()).capabilities,\n path,\n );\n if (!capability) {\n throw new Error(`No Capability exists at \"${path.join(\".\")}\"`);\n }\n const result = await runtime.call({\n id: capability.id,\n input: args[0] ?? {},\n ...(args[1]?.signal ? { signal: args[1].signal } : {}),\n });\n return result.output;\n },\n });\n };\n\n return proxy([], true) as App<TCapabilities>;\n}\n\nexport function subscribe<\n const TCapability extends SubscribableCapability,\n>(\n capabilityCall: AppCapabilityCall<TCapability>,\n ...args: AppCapabilityArgs<TCapability>\n): AsyncIterableIterator<CapabilityOutput<TCapability>> {\n const binding = (\n capabilityCall as unknown as Record<PropertyKey, unknown>\n )[APP_CALL_SYMBOL] as\n | {\n readonly runtime: ApplicationTransport;\n readonly path: readonly string[];\n }\n | undefined;\n if (!binding) {\n throw new Error(\"subscribe() requires a Capability call from a Capable App\");\n }\n\n return (async function* () {\n const manifest = await binding.runtime.manifest();\n const capability = findManifestCapability(\n manifest.capabilities,\n binding.path,\n );\n if (!capability) {\n throw new Error(`No Capability exists at \"${binding.path.join(\".\")}\"`);\n }\n if (!capability.subscription) {\n throw new Error(`Capability \"${capability.id}\" is not subscribable`);\n }\n const stream = binding.runtime.subscribe({\n id: capability.id,\n input: args[0] ?? {},\n ...(args[1]?.signal ? { signal: args[1].signal } : {}),\n });\n try {\n for await (const result of stream) {\n yield result.output as CapabilityOutput<TCapability>;\n }\n } finally {\n await stream.return?.();\n }\n })();\n}\n\nexport type AppContextProvider<TContext> = (call: {\n readonly id: string;\n readonly signal?: AbortSignal;\n}) => MaybePromise<TContext>;\n\ntype CreateAppOptions<TContext> = {\n readonly context: AppContextProvider<TContext>;\n};\n\ntype CreateAppArgs<TContext> = [TContext] extends [undefined]\n ? [options?: Partial<CreateAppOptions<TContext>>]\n : [options: CreateAppOptions<TContext>];\n\nconst localManifestCache = new WeakMap<object, ApplicationManifest>();\nconst localCapabilityCache = new WeakMap<\n object,\n ReadonlyMap<string, LocatedCapability>\n>();\n\nexport function createApp<\n const TDefinition extends AppDefinition<any, any>,\n>(\n definition: TDefinition,\n ...[options]: CreateAppArgs<AppContext<TDefinition>>\n): App<DefinitionCapabilities<TDefinition>> {\n let manifest = localManifestCache.get(definition);\n if (!manifest) {\n manifest = createAppManifest(definition);\n localManifestCache.set(definition, manifest);\n }\n let byId = localCapabilityCache.get(definition);\n if (!byId) {\n byId = new Map(\n definition.locatedCapabilities.map((entry) => [entry.capability.id, entry]),\n );\n localCapabilityCache.set(definition, byId);\n }\n\n const runtime: ApplicationTransport = Object.freeze({\n async manifest() {\n return manifest;\n },\n async call({ id, input = {}, signal }: CapabilityCall) {\n const located = byId.get(id);\n if (!located) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n\n let context: unknown;\n try {\n context = options?.context\n ? await options.context({\n id,\n ...(signal ? { signal } : {}),\n })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n let output: unknown;\n try {\n output = await executeLocatedCapability(located, input, {\n context,\n ...(signal ? { signal } : {}),\n });\n } catch (error) {\n if (error instanceof CapableError) {\n throw new TransportError(error.code, {\n ...(error.message ? { message: error.message } : {}),\n ...(typeof error.status === \"number\"\n ? { status: error.status }\n : {}),\n ...(error.data === undefined ? {} : { data: error.data }),\n cause: error,\n });\n }\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause: error });\n }\n\n let markdown: string | undefined;\n try {\n markdown = located.capability.toMarkdown\n ? await located.capability.toMarkdown(output, { context })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n return {\n output,\n ...(markdown ? { markdown } : {}),\n };\n },\n async *subscribe({ id, input = {}, signal }: CapabilityCall) {\n const located = byId.get(id);\n if (!located) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n if (!located.capability.subscribe) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n\n let context: unknown;\n try {\n context = options?.context\n ? await options.context({\n id,\n ...(signal ? { signal } : {}),\n })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n\n const stream = subscribeLocatedCapability(located, input, {\n context,\n ...(signal ? { signal } : {}),\n });\n try {\n for await (const output of stream) {\n let markdown: string | undefined;\n try {\n markdown = located.capability.toMarkdown\n ? await located.capability.toMarkdown(output, { context })\n : undefined;\n } catch (cause) {\n throw new TransportError(\"INTERNAL_SERVER_ERROR\", { cause });\n }\n yield {\n output,\n ...(markdown ? { markdown } : {}),\n };\n }\n } catch (error) {\n throw toTransportError(error);\n } finally {\n await stream.return?.();\n }\n },\n });\n return appFromRuntime(runtime);\n}\n\nexport function createRemoteApp<\n TDefinition extends AppDefinition<any, any> = AppDefinition<CapabilityTree>,\n>(\n transport: ApplicationTransport,\n): App<DefinitionCapabilities<TDefinition>> {\n const manifest = createManifestResolver(async () => {\n const manifest = await transport.manifest();\n validateManifest(manifest, \"Remote App\");\n return manifest;\n });\n return appFromRuntime(Object.freeze({\n manifest,\n async call(call: CapabilityCall) {\n await manifest();\n return transport.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await manifest();\n yield* transport.subscribe(call);\n },\n }));\n}\n\nexport function createManifestResolver(\n load: () => Promise<ApplicationManifest>,\n): () => Promise<ApplicationManifest> {\n let cached: Promise<ApplicationManifest> | undefined;\n return () => {\n if (cached) return cached;\n const attempt = Promise.resolve().then(load);\n cached = attempt;\n void attempt.catch(() => {\n if (cached === attempt) cached = undefined;\n });\n return attempt;\n };\n}\n\nexport class TransportError extends Error {\n readonly code: string;\n readonly status: number | undefined;\n readonly data: unknown;\n\n constructor(\n code: string,\n options: {\n readonly message?: string;\n readonly status?: number;\n readonly data?: unknown;\n readonly cause?: unknown;\n } = {},\n ) {\n super(options.message ?? code, { cause: options.cause });\n this.name = \"TransportError\";\n this.code = code;\n this.status = options.status;\n this.data = options.data;\n }\n}\n\nfunction toTransportError(error: unknown): TransportError {\n if (error instanceof TransportError) return error;\n if (error instanceof CapableError) {\n return new TransportError(error.code, {\n ...(error.message ? { message: error.message } : {}),\n ...(typeof error.status === \"number\" ? { status: error.status } : {}),\n ...(error.data === undefined ? {} : { data: error.data }),\n cause: error,\n });\n }\n return new TransportError(\"INTERNAL_SERVER_ERROR\", { cause: error });\n}\n","import type {\n AnyCapability,\n CapabilityGroupDefinition,\n CapabilityTree,\n} from \"@capable/core\";\nimport {\n appFromRuntime,\n createManifestResolver,\n getAppRuntime,\n TransportError,\n type AnyApp,\n type App,\n type AppCapabilities,\n type ApplicationTransport,\n type CapabilityCall,\n} from \"./runtime.ts\";\nimport {\n flattenManifestCapabilities,\n mergeApplicationManifests,\n selectManifest,\n} from \"./manifest.ts\";\n\ntype UnionToIntersection<TValue> =\n (TValue extends unknown ? (value: TValue) => void : never) extends\n (value: infer TIntersection) => void ? TIntersection : never;\n\ntype MergedCapabilities<\n TApplications extends readonly AnyApp[],\n> = UnionToIntersection<AppCapabilities<TApplications[number]>> &\n CapabilityTree;\n\nexport function mergeApps<\n const TApplications extends readonly [\n AnyApp,\n ...AnyApp[],\n ],\n>(\n ...applications: TApplications\n): App<MergedCapabilities<TApplications>> {\n const runtimes = applications.map(getAppRuntime);\n let dispatch: ReadonlyMap<string, ApplicationTransport> | undefined;\n\n const resolve = createManifestResolver(async () => {\n const manifests = await Promise.all(\n runtimes.map((runtime) => runtime.manifest()),\n );\n const nextDispatch = new Map<string, ApplicationTransport>();\n manifests.forEach((manifest, index) => {\n for (\n const capability of flattenManifestCapabilities(\n manifest.capabilities,\n )\n ) {\n nextDispatch.set(capability.id, runtimes[index]!);\n }\n });\n const merged = mergeApplicationManifests(manifests);\n dispatch = nextDispatch;\n return merged;\n });\n\n return appFromRuntime(Object.freeze({\n manifest: resolve,\n async call(call: CapabilityCall) {\n await resolve();\n const target = dispatch?.get(call.id);\n if (!target) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n return target.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await resolve();\n const target = dispatch?.get(call.id);\n if (!target) throw new TransportError(\"NOT_FOUND\", { status: 404 });\n yield* target.subscribe(call);\n },\n }));\n}\n\ntype SelectionNode<TTree> =\n TTree extends AnyCapability\n ? true\n : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any>\n ? true | SelectionNode<TCapabilities>\n : TTree extends CapabilityTree\n ? true | {\n readonly [TKey in keyof TTree]?: SelectionNode<TTree[TKey]>;\n }\n : never;\n\nexport type ApplicationSelection<\n TCapabilities extends CapabilityTree = CapabilityTree,\n> = {\n readonly include?: Exclude<SelectionNode<TCapabilities>, true>;\n readonly exclude?: Exclude<SelectionNode<TCapabilities>, true>;\n};\n\nexport function selectApp<\n const TCapabilities extends CapabilityTree,\n>(\n application: App<TCapabilities>,\n selection: ApplicationSelection<TCapabilities>,\n): App<TCapabilities> {\n const runtime = getAppRuntime(application);\n let ids: ReadonlySet<string> | undefined;\n const manifest = createManifestResolver(async () => {\n const selected = selectManifest(await runtime.manifest(), selection);\n ids = new Set(\n flattenManifestCapabilities(selected.capabilities).map(\n (capability) => capability.id,\n ),\n );\n return selected;\n });\n return appFromRuntime(Object.freeze({\n manifest,\n async call(call: CapabilityCall) {\n await manifest();\n if (!ids?.has(call.id)) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n return runtime.call(call);\n },\n async *subscribe(call: CapabilityCall) {\n await manifest();\n if (!ids?.has(call.id)) {\n throw new TransportError(\"NOT_FOUND\", { status: 404 });\n }\n yield* runtime.subscribe(call);\n },\n }));\n}\n"],"mappings":";;AAmDA,SAAgB,kBACd,YACqB;CACrB,MAAM,eAAe,IAAI,IACvB,WAAW,oBAAoB,KAAK,UAAU,CAAC,MAAM,YAAY,KAAK,CAAC,CACzE;CACA,OAAO,OAAO,OAAO;EACnB,UAAU;EACV,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,GAAI,WAAW,cAAc,EAAE,aAAa,WAAW,YAAY,IAAI,CAAC;EACxE,cAAc,cAAc,WAAW,cAAc,YAAY;CACnE,CAAC;AACH;AAEA,SAAgB,iBACd,UACA,OACM;CACN,IAAI,SAAS,aAAa,2BACxB,MAAM,IAAI,MAAM,GAAG,MAAM,8BAA8B,SAAS,SAAS,EAAE;CAE7E,MAAM,eAAe,4BAA4B,SAAS,YAAY;CACtE,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,cAAc,cAAc;EACrC,MAAM,OAAO,WAAW,KAAK,KAAK,GAAG;EACrC,IAAI,IAAI,IAAI,WAAW,EAAE,GACvB,MAAM,IAAI,MACR,GAAG,MAAM,qCAAqC,WAAW,GAAG,EAC9D;EAEF,IAAI,MAAM,IAAI,IAAI,GAChB,MAAM,IAAI,MAAM,GAAG,MAAM,uCAAuC,KAAK,EAAE;EAEzE,IAAI,IAAI,WAAW,EAAE;EACrB,MAAM,IAAI,IAAI;CAChB;CACA,sBAAsB,SAAS,cAAc,CAAC,GAAG,KAAK;AACxD;AAEA,SAAgB,0BACd,WACqB;CACrB,MAAM,YAAY,yBAAyB,SAAS;CACpD,IAAI,UAAU,QACZ,MAAM,IAAI,MACR,uBAAuB,UAAU,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,GACvE;CAEF,OAAO,OAAO,OAAO;EAC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