capable-kit 0.0.1-alpha.7 → 0.0.1-alpha.8
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/dist/ai-sdk.d.mts +2 -2
- package/dist/ai-sdk.mjs +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +1 -1
- package/dist/bin.mjs +12 -9
- package/dist/bin.mjs.map +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +1 -1
- package/dist/eve.mjs +1 -1
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-DwXlaTXI.d.mts → index-Dl4NK9G0.d.mts} +20 -4
- package/dist/{index-Dbc4g9WM.d.mts → index-F4ba_olD.d.mts} +3 -3
- package/dist/{index-Be8-UVBC.d.mts → index-_qKFfWV4.d.mts} +4 -2
- package/dist/{index-D2CRRUzH.d.mts → index-hdH_K5Zc.d.mts} +6 -5
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/mcp.d.mts +35 -5
- package/dist/mcp.mjs +1 -1
- package/dist/mount-CEFAplR5.mjs +227 -0
- package/dist/mount-CEFAplR5.mjs.map +1 -0
- package/dist/react-query.d.mts +1 -1
- package/dist/react-query.mjs +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +8 -8
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-CDxL6w3d.mjs → src-BWxDO2Ua.mjs} +9 -6
- package/dist/src-BWxDO2Ua.mjs.map +1 -0
- package/dist/{src-DdV82An-.mjs → src-D-cm2gQ6.mjs} +6 -3
- package/dist/src-D-cm2gQ6.mjs.map +1 -0
- package/dist/{src-Db6-XSnU.mjs → src-D_0PIhqq.mjs} +3 -3
- package/dist/{src-Db6-XSnU.mjs.map → src-D_0PIhqq.mjs.map} +1 -1
- package/dist/{src-C2MGIlT0.mjs → src-betOfnDL.mjs} +25 -8
- package/dist/src-betOfnDL.mjs.map +1 -0
- package/dist/{src-BF70JLxI.mjs → src-rkr5j_NH.mjs} +162 -33
- package/dist/src-rkr5j_NH.mjs.map +1 -0
- package/dist/{subscription-Bq792Ad2.d.mts → subscription-B-auXJbm.d.mts} +2 -2
- package/dist/swr.d.mts +1 -1
- package/dist/swr.mjs +1 -1
- package/docs/CONTEXT.md +3 -1
- package/docs/internal/adr/0002-version-the-capable-value-codec.md +24 -0
- package/docs/internal/architecture.md +34 -3
- package/docs/internal/capability-first-model.md +1 -1
- package/docs/internal/implementation-friction.md +95 -0
- package/docs/site/capable-orpc-and-trpc.mdx +3 -3
- package/docs/site/concepts/apps.mdx +10 -7
- package/docs/site/concepts/architecture.mdx +1 -1
- package/docs/site/hosting/any-fetch-host.mdx +2 -2
- package/docs/site/hosting/next-js.mdx +38 -4
- package/docs/site/hosting/standalone-server.mdx +2 -2
- package/docs/site/introduction.mdx +9 -6
- package/docs/site/patterns/composition.mdx +7 -3
- package/docs/site/patterns/remote-apps.mdx +62 -8
- package/docs/site/patterns/subscriptions.mdx +2 -2
- package/docs/site/quickstart.mdx +18 -13
- package/docs/site/reference/packages-and-entry-points.mdx +2 -2
- package/docs/site/reference/surface-metadata.mdx +7 -2
- package/docs/site/reference/the-cap-cli.mdx +2 -2
- package/docs/site/surfaces/ai-sdk.mdx +3 -3
- package/docs/site/surfaces/cli.mdx +3 -3
- package/docs/site/surfaces/eve.mdx +5 -5
- package/docs/site/surfaces/mcp.mdx +73 -5
- package/docs/site/surfaces/react-query.mdx +3 -3
- package/docs/site/surfaces/swr.mdx +3 -3
- package/docs/site/surfaces/typescript.mdx +5 -5
- package/docs/site/surfaces.mdx +1 -1
- package/package.json +3 -2
- package/src/mcp.ts +4 -0
- package/dist/mount-xvMsjz1B.mjs +0 -178
- package/dist/mount-xvMsjz1B.mjs.map +0 -1
- package/dist/src-BF70JLxI.mjs.map +0 -1
- package/dist/src-C2MGIlT0.mjs.map +0 -1
- package/dist/src-CDxL6w3d.mjs.map +0 -1
- package/dist/src-DdV82An-.mjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { D as AppDefinition, q as MaybePromise } from "./index-
|
|
2
|
-
import { t as ApplicationSelection } from "./index-
|
|
3
|
-
import { r as ContextProvider, t as CapabilitySelection } from "./index-
|
|
1
|
+
import { D as AppDefinition, q as MaybePromise } from "./index-_qKFfWV4.mjs";
|
|
2
|
+
import { t as ApplicationSelection } from "./index-F4ba_olD.mjs";
|
|
3
|
+
import { p as ProtocolCodec, r as ContextProvider, t as CapabilitySelection } from "./index-Dl4NK9G0.mjs";
|
|
4
4
|
//#region packages/server/src/index.d.ts
|
|
5
5
|
type ServerMount<TContext> = {
|
|
6
6
|
readonly kind: "capable.server.mount";
|
|
7
|
-
compile(app: AppDefinition<any, TContext>, context: ContextProvider<TContext> | undefined): CompiledServerMount;
|
|
7
|
+
compile(app: AppDefinition<any, TContext>, context: ContextProvider<TContext> | undefined, onError?: (error: unknown) => void): CompiledServerMount;
|
|
8
8
|
};
|
|
9
9
|
type CompiledServerMount = {
|
|
10
10
|
readonly name: string;
|
|
@@ -13,6 +13,7 @@ type CompiledServerMount = {
|
|
|
13
13
|
declare function protocol<TContext = any>(options?: {
|
|
14
14
|
readonly path?: string;
|
|
15
15
|
readonly selection?: ApplicationSelection;
|
|
16
|
+
readonly codec?: ProtocolCodec;
|
|
16
17
|
}): ServerMount<TContext>;
|
|
17
18
|
declare function http<TContext = any>(options?: {
|
|
18
19
|
readonly path?: string;
|
|
@@ -39,4 +40,4 @@ type CreateServerArgs<TContext> = [TContext] extends [undefined] ? [options?: Cr
|
|
|
39
40
|
declare function createServer<TContext>(app: AppDefinition<any, TContext>, ...[providedOptions]: CreateServerArgs<TContext>): CapableServer;
|
|
40
41
|
//#endregion
|
|
41
42
|
export { createServer as a, ServerMount as i, CompiledServerMount as n, http as o, ServerMiddleware as r, protocol as s, CapableServer as t };
|
|
42
|
-
//# sourceMappingURL=index-
|
|
43
|
+
//# sourceMappingURL=index-hdH_K5Zc.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as CapabilityTree, B as PresentationRenderer, D as AppDefinition, E as AppContext, G as present, H as PresentationValue, J as md, N as defineApp, P as group, V as PresentationTableCell, a as CapabilityEffect, c as CapabilityInput, d as CapabilityMiddlewareArgs, f as CapabilityOutput, h as ExecuteCapabilityOptions, i as CapabilityDefinition, m as CapabilitySubscriberArgs, o as CapabilityFactory, p as CapabilitySubscriber, r as CapabilityContext, rt as defineErrors, s as CapabilityHandlerArgs, tt as DefinedErrors, u as CapabilityMiddleware, v as capability, y as executeCapability, z as PresentationPart } from "./index-
|
|
2
|
-
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-
|
|
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-
|
|
1
|
+
import { A as CapabilityTree, B as PresentationRenderer, D as AppDefinition, E as AppContext, G as present, H as PresentationValue, J as md, N as defineApp, P as group, V as PresentationTableCell, a as CapabilityEffect, c as CapabilityInput, d as CapabilityMiddlewareArgs, f as CapabilityOutput, h as ExecuteCapabilityOptions, i as CapabilityDefinition, m as CapabilitySubscriberArgs, o as CapabilityFactory, p as CapabilitySubscriber, r as CapabilityContext, rt as defineErrors, s as CapabilityHandlerArgs, tt as DefinedErrors, u as CapabilityMiddleware, v as capability, y as executeCapability, z as PresentationPart } from "./index-_qKFfWV4.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-B-auXJbm.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-F4ba_olD.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 PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type WatchQueryOptions, capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, present, selectApp, subscribe, watchQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as defineErrors, c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, v as present } from "./src-
|
|
1
|
+
import { S as defineErrors, c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, v as present } from "./src-D-cm2gQ6.mjs";
|
|
2
2
|
import { t as md } from "./projection-Cgq2u0Wt.mjs";
|
|
3
|
-
import { n as selectApp, o as createApp, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-
|
|
3
|
+
import { n as selectApp, o as createApp, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-betOfnDL.mjs";
|
|
4
4
|
export { capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, present, selectApp, subscribe, watchQuery };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
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, t as ApplicationSelection } from "./index-F4ba_olD.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-hdH_K5Zc.mjs";
|
|
3
3
|
//#region packages/mcp/src/index.d.ts
|
|
4
4
|
type McpCapabilityMeta = false | {
|
|
5
5
|
readonly name?: string;
|
|
6
|
+
readonly icons?: readonly McpIcon[];
|
|
7
|
+
readonly idempotentHint?: boolean;
|
|
8
|
+
readonly openWorldHint?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type McpIcon = {
|
|
11
|
+
readonly src: string;
|
|
12
|
+
readonly mimeType?: string;
|
|
13
|
+
readonly sizes?: readonly string[];
|
|
14
|
+
readonly theme?: "light" | "dark";
|
|
6
15
|
};
|
|
7
16
|
declare module "@capable/core" {
|
|
8
17
|
interface CapabilityMetaRegistry {
|
|
@@ -13,11 +22,17 @@ type McpTool = {
|
|
|
13
22
|
readonly name: string;
|
|
14
23
|
readonly title?: string;
|
|
15
24
|
readonly description?: string;
|
|
25
|
+
readonly icons?: readonly McpIcon[];
|
|
16
26
|
readonly inputSchema: JsonSchema;
|
|
17
27
|
readonly outputSchema?: JsonSchema;
|
|
28
|
+
readonly _meta: {
|
|
29
|
+
readonly "dev.capable/capabilityId": string;
|
|
30
|
+
};
|
|
18
31
|
readonly annotations: {
|
|
19
32
|
readonly readOnlyHint: boolean;
|
|
20
33
|
readonly destructiveHint: boolean;
|
|
34
|
+
readonly idempotentHint?: boolean;
|
|
35
|
+
readonly openWorldHint?: boolean;
|
|
21
36
|
};
|
|
22
37
|
call(input: unknown, options?: {
|
|
23
38
|
readonly signal?: AbortSignal;
|
|
@@ -26,11 +41,26 @@ type McpTool = {
|
|
|
26
41
|
declare function createMcp(app: AnyApp): Promise<readonly McpTool[]>;
|
|
27
42
|
//#endregion
|
|
28
43
|
//#region packages/mcp/src/mount.d.ts
|
|
29
|
-
|
|
44
|
+
type McpCacheHint = {
|
|
45
|
+
readonly ttlMs?: number;
|
|
46
|
+
readonly cacheScope?: "public" | "private";
|
|
47
|
+
};
|
|
48
|
+
type McpMountOptions = {
|
|
30
49
|
readonly path?: string;
|
|
31
50
|
readonly name?: string;
|
|
32
51
|
readonly version?: string;
|
|
33
|
-
|
|
52
|
+
readonly title?: string;
|
|
53
|
+
readonly description?: string;
|
|
54
|
+
readonly websiteUrl?: string;
|
|
55
|
+
readonly icons?: readonly McpIcon[];
|
|
56
|
+
readonly instructions?: string;
|
|
57
|
+
readonly selection?: ApplicationSelection;
|
|
58
|
+
readonly cache?: {
|
|
59
|
+
readonly discovery?: McpCacheHint;
|
|
60
|
+
readonly tools?: McpCacheHint;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
declare function mcp<TContext = any>(options?: McpMountOptions): ServerMount<TContext>;
|
|
34
64
|
//#endregion
|
|
35
|
-
export { McpCapabilityMeta, McpTool, createMcp, mcp };
|
|
65
|
+
export { type McpCacheHint, McpCapabilityMeta, McpIcon, type McpMountOptions, McpTool, createMcp, mcp };
|
|
36
66
|
//# sourceMappingURL=mcp.d.mts.map
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createMcp, t as mcp } from "./mount-
|
|
1
|
+
import { n as createMcp, t as mcp } from "./mount-CEFAplR5.mjs";
|
|
2
2
|
export { createMcp, mcp };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { y as renderPresentationMarkdown } from "./src-D-cm2gQ6.mjs";
|
|
2
|
+
import { a as TransportError, c as getAppRuntime, n as selectApp, o as createApp } from "./src-betOfnDL.mjs";
|
|
3
|
+
import { Server, createMcpHandler } from "@modelcontextprotocol/server";
|
|
4
|
+
//#region packages/mcp/src/index.ts
|
|
5
|
+
async function createMcp(app) {
|
|
6
|
+
const runtime = getAppRuntime(app);
|
|
7
|
+
const tools = flatten((await runtime.manifest()).capabilities).filter((capability) => capability.meta.mcp !== false).map((capability) => {
|
|
8
|
+
const meta = readMcpMeta(capability);
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
name: meta?.name ?? capability.path.join("__"),
|
|
11
|
+
...capability.title ? { title: capability.title } : {},
|
|
12
|
+
...capability.description ? { description: capability.description } : {},
|
|
13
|
+
...meta?.icons ? { icons: meta.icons } : {},
|
|
14
|
+
inputSchema: capability.input ?? {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {},
|
|
17
|
+
additionalProperties: false
|
|
18
|
+
},
|
|
19
|
+
...capability.output ? { outputSchema: capability.output } : {},
|
|
20
|
+
_meta: { "dev.capable/capabilityId": capability.id },
|
|
21
|
+
annotations: {
|
|
22
|
+
readOnlyHint: capability.effect === "read",
|
|
23
|
+
destructiveHint: capability.effect === "destructive",
|
|
24
|
+
...meta?.idempotentHint !== void 0 ? { idempotentHint: meta.idempotentHint } : {},
|
|
25
|
+
...meta?.openWorldHint !== void 0 ? { openWorldHint: meta.openWorldHint } : {}
|
|
26
|
+
},
|
|
27
|
+
call(input, options) {
|
|
28
|
+
return runtime.call({
|
|
29
|
+
id: capability.id,
|
|
30
|
+
input,
|
|
31
|
+
presentation: true,
|
|
32
|
+
...options?.signal ? { signal: options.signal } : {}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
const names = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const tool of tools) {
|
|
39
|
+
if (names.has(tool.name)) throw new Error(`Duplicate MCP tool name "${tool.name}"`);
|
|
40
|
+
names.add(tool.name);
|
|
41
|
+
}
|
|
42
|
+
return tools;
|
|
43
|
+
}
|
|
44
|
+
function readMcpMeta(capability) {
|
|
45
|
+
const value = capability.meta.mcp;
|
|
46
|
+
if (value === void 0) return void 0;
|
|
47
|
+
if (!isRecord(value)) return invalidMcpMeta(capability, "must be an object");
|
|
48
|
+
if (value.name !== void 0 && typeof value.name !== "string") return invalidMcpMeta(capability, "name must be a string");
|
|
49
|
+
if (value.idempotentHint !== void 0 && typeof value.idempotentHint !== "boolean") return invalidMcpMeta(capability, "idempotentHint must be a boolean");
|
|
50
|
+
if (value.openWorldHint !== void 0 && typeof value.openWorldHint !== "boolean") return invalidMcpMeta(capability, "openWorldHint must be a boolean");
|
|
51
|
+
if (value.icons !== void 0 && (!Array.isArray(value.icons) || !value.icons.every(isMcpIcon))) return invalidMcpMeta(capability, "icons must be MCP icon descriptors");
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function isMcpIcon(value) {
|
|
55
|
+
if (!isRecord(value) || typeof value.src !== "string") return false;
|
|
56
|
+
if (value.mimeType !== void 0 && typeof value.mimeType !== "string") return false;
|
|
57
|
+
if (value.sizes !== void 0 && (!Array.isArray(value.sizes) || !value.sizes.every((size) => typeof size === "string"))) return false;
|
|
58
|
+
return value.theme === void 0 || value.theme === "light" || value.theme === "dark";
|
|
59
|
+
}
|
|
60
|
+
function isRecord(value) {
|
|
61
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
62
|
+
}
|
|
63
|
+
function invalidMcpMeta(capability, reason) {
|
|
64
|
+
throw new Error(`Capability "${capability.id}" has invalid MCP metadata: ${reason}`);
|
|
65
|
+
}
|
|
66
|
+
function flatten(nodes) {
|
|
67
|
+
return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region packages/mcp/src/presentation.ts
|
|
71
|
+
function toMcpContent(presentation, output) {
|
|
72
|
+
if (!presentation?.length) return [{
|
|
73
|
+
type: "text",
|
|
74
|
+
text: stringify(output)
|
|
75
|
+
}];
|
|
76
|
+
const content = [];
|
|
77
|
+
for (const part of presentation) {
|
|
78
|
+
if (part.type === "markdown") {
|
|
79
|
+
content.push({
|
|
80
|
+
type: "text",
|
|
81
|
+
text: renderPresentationMarkdown(part)
|
|
82
|
+
});
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (part.type === "table") {
|
|
86
|
+
content.push({
|
|
87
|
+
type: "text",
|
|
88
|
+
text: renderPresentationMarkdown(part)
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (part.type === "image") {
|
|
93
|
+
content.push({
|
|
94
|
+
type: "text",
|
|
95
|
+
text: `[Image: ${part.alt}]`
|
|
96
|
+
}, {
|
|
97
|
+
type: "image",
|
|
98
|
+
data: part.base64,
|
|
99
|
+
mimeType: part.mimeType
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
content.push({
|
|
104
|
+
type: "resource_link",
|
|
105
|
+
uri: part.url,
|
|
106
|
+
name: part.name,
|
|
107
|
+
...part.description ? { description: part.description } : {},
|
|
108
|
+
...part.mimeType ? { mimeType: part.mimeType } : {},
|
|
109
|
+
...part.size === void 0 ? {} : { size: part.size }
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return content;
|
|
113
|
+
}
|
|
114
|
+
function stringify(value) {
|
|
115
|
+
return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region packages/mcp/src/mount.ts
|
|
119
|
+
function mcp(options = {}) {
|
|
120
|
+
validateCacheHint(options.cache?.discovery, "discovery");
|
|
121
|
+
validateCacheHint(options.cache?.tools, "tools");
|
|
122
|
+
const path = normalizePath(options.path ?? "/mcp");
|
|
123
|
+
return {
|
|
124
|
+
kind: "capable.server.mount",
|
|
125
|
+
compile(app, context, onError) {
|
|
126
|
+
const description = options.description ?? app.description;
|
|
127
|
+
const handler = createMcpHandler(async ({ requestInfo }) => {
|
|
128
|
+
try {
|
|
129
|
+
if (!requestInfo) throw new Error("The MCP HTTP handler requires request information");
|
|
130
|
+
const executable = createApp(app, context ? { context: () => context({ request: requestInfo }) } : void 0);
|
|
131
|
+
return createMcpServer(await createMcp(options.selection ? selectApp(executable, options.selection) : executable), {
|
|
132
|
+
name: options.name ?? app.name ?? "capable",
|
|
133
|
+
version: options.version ?? app.version ?? "0.0.0",
|
|
134
|
+
...options.title !== void 0 ? { title: options.title } : {},
|
|
135
|
+
...description !== void 0 ? { description } : {},
|
|
136
|
+
...options.websiteUrl !== void 0 ? { websiteUrl: options.websiteUrl } : {},
|
|
137
|
+
...options.icons !== void 0 ? { icons: toProtocolIcons(options.icons) } : {}
|
|
138
|
+
}, options);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
onError?.(error);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}, { legacy: "stateless" });
|
|
144
|
+
return {
|
|
145
|
+
name: "mcp",
|
|
146
|
+
async fetch(request) {
|
|
147
|
+
if (new URL(request.url).pathname !== path) return void 0;
|
|
148
|
+
return handler.fetch(request);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function createMcpServer(tools, info, options) {
|
|
155
|
+
const server = new Server(info, {
|
|
156
|
+
capabilities: { tools: {} },
|
|
157
|
+
...options.instructions !== void 0 ? { instructions: options.instructions } : {},
|
|
158
|
+
...options.cache !== void 0 ? { cacheHints: {
|
|
159
|
+
...options.cache.discovery !== void 0 ? { "server/discover": options.cache.discovery } : {},
|
|
160
|
+
...options.cache.tools !== void 0 ? { "tools/list": options.cache.tools } : {}
|
|
161
|
+
} } : {}
|
|
162
|
+
});
|
|
163
|
+
server.setRequestHandler("tools/list", () => ({ tools: tools.map(toProtocolTool) }));
|
|
164
|
+
server.setRequestHandler("tools/call", async (request, context) => {
|
|
165
|
+
const tool = tools.find(({ name }) => name === request.params.name);
|
|
166
|
+
if (!tool) return toolError(`Unknown tool "${request.params.name}"`);
|
|
167
|
+
try {
|
|
168
|
+
const result = await tool.call(request.params.arguments ?? {}, { signal: context.mcpReq.signal });
|
|
169
|
+
return server.projectCallToolResult({
|
|
170
|
+
content: toMcpContent(result.presentation, result.output),
|
|
171
|
+
structuredContent: result.output
|
|
172
|
+
}, tool.outputSchema);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (!(error instanceof TransportError)) throw error;
|
|
175
|
+
return toolError(error.message, {
|
|
176
|
+
code: error.code,
|
|
177
|
+
status: error.status,
|
|
178
|
+
data: error.data
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return server;
|
|
183
|
+
}
|
|
184
|
+
function toProtocolTool(tool) {
|
|
185
|
+
return {
|
|
186
|
+
name: tool.name,
|
|
187
|
+
...tool.title ? { title: tool.title } : {},
|
|
188
|
+
...tool.description ? { description: tool.description } : {},
|
|
189
|
+
...tool.icons ? { icons: toProtocolIcons(tool.icons) } : {},
|
|
190
|
+
inputSchema: tool.inputSchema,
|
|
191
|
+
...tool.outputSchema ? { outputSchema: tool.outputSchema } : {},
|
|
192
|
+
_meta: tool._meta,
|
|
193
|
+
annotations: tool.annotations
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function toProtocolIcons(icons) {
|
|
197
|
+
return icons.map((icon) => ({
|
|
198
|
+
src: icon.src,
|
|
199
|
+
...icon.mimeType !== void 0 ? { mimeType: icon.mimeType } : {},
|
|
200
|
+
...icon.sizes !== void 0 ? { sizes: [...icon.sizes] } : {},
|
|
201
|
+
...icon.theme !== void 0 ? { theme: icon.theme } : {}
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
function toolError(message, details) {
|
|
205
|
+
return {
|
|
206
|
+
isError: true,
|
|
207
|
+
content: [{
|
|
208
|
+
type: "text",
|
|
209
|
+
text: details ? JSON.stringify({
|
|
210
|
+
message,
|
|
211
|
+
...details
|
|
212
|
+
}) : message
|
|
213
|
+
}]
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function normalizePath(value) {
|
|
217
|
+
return `/${value.split("/").filter(Boolean).join("/")}`;
|
|
218
|
+
}
|
|
219
|
+
function validateCacheHint(hint, field) {
|
|
220
|
+
if (!hint) return;
|
|
221
|
+
if (hint.ttlMs !== void 0 && (!Number.isSafeInteger(hint.ttlMs) || hint.ttlMs < 0)) throw new RangeError(`MCP ${field} cache ttlMs must be a non-negative safe integer`);
|
|
222
|
+
if (hint.cacheScope !== void 0 && hint.cacheScope !== "public" && hint.cacheScope !== "private") throw new RangeError(`MCP ${field} cache cacheScope must be "public" or "private"`);
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
export { createMcp as n, mcp as t };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=mount-CEFAplR5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-CEFAplR5.mjs","names":[],"sources":["../../mcp/src/index.ts","../../mcp/src/presentation.ts","../../mcp/src/mount.ts"],"sourcesContent":["import type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n getAppRuntime,\n type AnyApp,\n type JsonSchema,\n type ManifestNode,\n type ManifestCapability,\n type CapabilityResult,\n} from \"@capable/app\";\n\nexport type McpCapabilityMeta =\n | false\n | {\n readonly name?: string;\n readonly icons?: readonly McpIcon[];\n readonly idempotentHint?: boolean;\n readonly openWorldHint?: boolean;\n };\n\nexport type McpIcon = {\n readonly src: string;\n readonly mimeType?: string;\n readonly sizes?: readonly string[];\n readonly theme?: \"light\" | \"dark\";\n};\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly mcp?: McpCapabilityMeta;\n }\n}\n\nexport type McpTool = {\n readonly name: string;\n readonly title?: string;\n readonly description?: string;\n readonly icons?: readonly McpIcon[];\n readonly inputSchema: JsonSchema;\n readonly outputSchema?: JsonSchema;\n readonly _meta: {\n readonly \"dev.capable/capabilityId\": string;\n };\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: boolean;\n readonly idempotentHint?: boolean;\n readonly openWorldHint?: boolean;\n };\n call(\n input: unknown,\n options?: { readonly signal?: AbortSignal },\n ): Promise<CapabilityResult>;\n};\n\nexport async function createMcp(\n app: AnyApp,\n): Promise<readonly McpTool[]> {\n const runtime = getAppRuntime(app);\n const manifest = await runtime.manifest();\n const tools = flatten(manifest.capabilities)\n .filter((capability) => capability.meta.mcp !== false)\n .map((capability) => {\n const meta = readMcpMeta(capability);\n return Object.freeze({\n name: meta?.name ?? capability.path.join(\"__\"),\n ...(capability.title ? { title: capability.title } : {}),\n ...(capability.description ? { description: capability.description } : {}),\n ...(meta?.icons ? { icons: meta.icons } : {}),\n inputSchema: capability.input ?? {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n ...(capability.output\n ? { outputSchema: capability.output }\n : {}),\n _meta: {\n \"dev.capable/capabilityId\": capability.id,\n },\n annotations: {\n readOnlyHint: capability.effect === \"read\",\n destructiveHint: capability.effect === \"destructive\",\n ...(meta?.idempotentHint !== undefined\n ? { idempotentHint: meta.idempotentHint }\n : {}),\n ...(meta?.openWorldHint !== undefined\n ? { openWorldHint: meta.openWorldHint }\n : {}),\n },\n call(input: unknown, options?: { readonly signal?: AbortSignal }) {\n return runtime.call({\n id: capability.id,\n input,\n presentation: true,\n ...(options?.signal ? { signal: options.signal } : {}),\n });\n },\n });\n });\n const names = new Set<string>();\n for (const tool of tools) {\n if (names.has(tool.name)) {\n throw new Error(`Duplicate MCP tool name \"${tool.name}\"`);\n }\n names.add(tool.name);\n }\n return tools;\n}\n\nfunction readMcpMeta(\n capability: ManifestCapability,\n): Exclude<McpCapabilityMeta, false> | undefined {\n const value = capability.meta.mcp;\n if (value === undefined) return undefined;\n if (!isRecord(value)) return invalidMcpMeta(capability, \"must be an object\");\n if (value.name !== undefined && typeof value.name !== \"string\") {\n return invalidMcpMeta(capability, \"name must be a string\");\n }\n if (\n value.idempotentHint !== undefined &&\n typeof value.idempotentHint !== \"boolean\"\n ) {\n return invalidMcpMeta(capability, \"idempotentHint must be a boolean\");\n }\n if (\n value.openWorldHint !== undefined &&\n typeof value.openWorldHint !== \"boolean\"\n ) {\n return invalidMcpMeta(capability, \"openWorldHint must be a boolean\");\n }\n if (\n value.icons !== undefined &&\n (!Array.isArray(value.icons) || !value.icons.every(isMcpIcon))\n ) {\n return invalidMcpMeta(capability, \"icons must be MCP icon descriptors\");\n }\n return value as Exclude<McpCapabilityMeta, false>;\n}\n\nfunction isMcpIcon(value: unknown): value is McpIcon {\n if (!isRecord(value) || typeof value.src !== \"string\") return false;\n if (value.mimeType !== undefined && typeof value.mimeType !== \"string\") {\n return false;\n }\n if (\n value.sizes !== undefined &&\n (!Array.isArray(value.sizes) ||\n !value.sizes.every((size) => typeof size === \"string\"))\n ) {\n return false;\n }\n return value.theme === undefined || value.theme === \"light\" ||\n value.theme === \"dark\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction invalidMcpMeta(\n capability: ManifestCapability,\n reason: string,\n): never {\n throw new Error(\n `Capability \"${capability.id}\" has invalid MCP metadata: ${reason}`,\n );\n}\n\nfunction flatten(nodes: readonly ManifestNode[]): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\" ? [node] : flatten(node.children)\n );\n}\n","import {\n renderPresentationMarkdown,\n type PresentationPart,\n} from \"@capable/core\";\nimport type { CallToolResult } from \"@modelcontextprotocol/server\";\n\nexport function toMcpContent(\n presentation: readonly PresentationPart[] | undefined,\n output: unknown,\n): CallToolResult[\"content\"] {\n if (!presentation?.length) {\n return [{ type: \"text\", text: stringify(output) }];\n }\n const content: CallToolResult[\"content\"] = [];\n for (const part of presentation) {\n if (part.type === \"markdown\") {\n content.push({ type: \"text\", text: renderPresentationMarkdown(part) });\n continue;\n }\n if (part.type === \"table\") {\n content.push({\n type: \"text\",\n text: renderPresentationMarkdown(part),\n });\n continue;\n }\n if (part.type === \"image\") {\n content.push(\n { type: \"text\", text: `[Image: ${part.alt}]` },\n {\n type: \"image\",\n data: part.base64,\n mimeType: part.mimeType,\n },\n );\n continue;\n }\n content.push({\n type: \"resource_link\",\n uri: part.url,\n name: part.name,\n ...(part.description ? { description: part.description } : {}),\n ...(part.mimeType ? { mimeType: part.mimeType } : {}),\n ...(part.size === undefined ? {} : { size: part.size }),\n });\n }\n return content;\n}\n\nfunction stringify(value: unknown): string {\n return typeof value === \"string\"\n ? value\n : JSON.stringify(value) ?? String(value);\n}\n","import type { ServerMount } from \"@capable/server\";\nimport {\n createApp,\n selectApp,\n TransportError,\n type ApplicationSelection,\n} from \"@capable/app\";\nimport {\n createMcpHandler,\n Server,\n type CallToolResult,\n type Icon,\n type Implementation,\n type Tool,\n} from \"@modelcontextprotocol/server\";\nimport {\n createMcp,\n type McpIcon,\n type McpTool,\n} from \"./index.ts\";\nimport { toMcpContent } from \"./presentation.ts\";\n\nexport type McpCacheHint = {\n readonly ttlMs?: number;\n readonly cacheScope?: \"public\" | \"private\";\n};\n\nexport type McpMountOptions = {\n readonly path?: string;\n readonly name?: string;\n readonly version?: string;\n readonly title?: string;\n readonly description?: string;\n readonly websiteUrl?: string;\n readonly icons?: readonly McpIcon[];\n readonly instructions?: string;\n readonly selection?: ApplicationSelection;\n readonly cache?: {\n readonly discovery?: McpCacheHint;\n readonly tools?: McpCacheHint;\n };\n};\n\nexport function mcp<TContext = any>(\n options: McpMountOptions = {},\n): ServerMount<TContext> {\n validateCacheHint(options.cache?.discovery, \"discovery\");\n validateCacheHint(options.cache?.tools, \"tools\");\n const path = normalizePath(options.path ?? \"/mcp\");\n return {\n kind: \"capable.server.mount\",\n compile(app, context, onError) {\n const description = options.description ?? app.description;\n const handler = createMcpHandler(async ({ requestInfo }) => {\n try {\n if (!requestInfo) {\n throw new Error(\n \"The MCP HTTP handler requires request information\",\n );\n }\n const executable = createApp(\n app,\n context\n ? { context: () => context({ request: requestInfo }) }\n : undefined as never,\n );\n const exposed = options.selection\n ? selectApp(executable, options.selection)\n : executable;\n const tools = await createMcp(exposed);\n return createMcpServer(tools, {\n name: options.name ?? app.name ?? \"capable\",\n version: options.version ?? app.version ?? \"0.0.0\",\n ...(options.title !== undefined ? { title: options.title } : {}),\n ...(description !== undefined\n ? { description }\n : {}),\n ...(options.websiteUrl !== undefined\n ? { websiteUrl: options.websiteUrl }\n : {}),\n ...(options.icons !== undefined\n ? { icons: toProtocolIcons(options.icons) }\n : {}),\n }, options);\n } catch (error) {\n onError?.(error);\n throw error;\n }\n }, {\n legacy: \"stateless\",\n });\n return {\n name: \"mcp\",\n async fetch(request) {\n if (new URL(request.url).pathname !== path) return undefined;\n return handler.fetch(request);\n },\n };\n },\n };\n}\n\nfunction createMcpServer(\n tools: readonly McpTool[],\n info: Implementation,\n options: Pick<McpMountOptions, \"instructions\" | \"cache\">,\n): Server {\n const server = new Server(info, {\n capabilities: { tools: {} },\n ...(options.instructions !== undefined\n ? { instructions: options.instructions }\n : {}),\n ...(options.cache !== undefined\n ? {\n cacheHints: {\n ...(options.cache.discovery !== undefined\n ? { \"server/discover\": options.cache.discovery }\n : {}),\n ...(options.cache.tools !== undefined\n ? { \"tools/list\": options.cache.tools }\n : {}),\n },\n }\n : {}),\n });\n server.setRequestHandler(\"tools/list\", () => ({\n tools: tools.map(toProtocolTool),\n }));\n server.setRequestHandler(\"tools/call\", async (request, context) => {\n const tool = tools.find(({ name }) => name === request.params.name);\n if (!tool) {\n return toolError(`Unknown tool \"${request.params.name}\"`);\n }\n try {\n const result = await tool.call(request.params.arguments ?? {}, {\n signal: context.mcpReq.signal,\n });\n return server.projectCallToolResult({\n content: toMcpContent(result.presentation, result.output),\n structuredContent: result.output,\n } satisfies CallToolResult, tool.outputSchema);\n } catch (error) {\n if (!(error instanceof TransportError)) throw error;\n return toolError(error.message, {\n code: error.code,\n status: error.status,\n data: error.data,\n });\n }\n });\n return server;\n}\n\nfunction toProtocolTool(tool: McpTool): Tool {\n return {\n name: tool.name,\n ...(tool.title ? { title: tool.title } : {}),\n ...(tool.description ? { description: tool.description } : {}),\n ...(tool.icons ? { icons: toProtocolIcons(tool.icons) } : {}),\n inputSchema: tool.inputSchema as Tool[\"inputSchema\"],\n ...(tool.outputSchema\n ? { outputSchema: tool.outputSchema as Tool[\"outputSchema\"] }\n : {}),\n _meta: tool._meta,\n annotations: tool.annotations,\n };\n}\n\nfunction toProtocolIcons(icons: readonly McpIcon[]): Icon[] {\n return icons.map((icon) => ({\n src: icon.src,\n ...(icon.mimeType !== undefined ? { mimeType: icon.mimeType } : {}),\n ...(icon.sizes !== undefined ? { sizes: [...icon.sizes] } : {}),\n ...(icon.theme !== undefined ? { theme: icon.theme } : {}),\n }));\n}\n\nfunction toolError(\n message: string,\n details?: Record<string, unknown>,\n): CallToolResult {\n return {\n isError: true,\n content: [{\n type: \"text\",\n text: details ? JSON.stringify({ message, ...details }) : message,\n }],\n };\n}\n\nfunction normalizePath(value: string): string {\n return `/${value.split(\"/\").filter(Boolean).join(\"/\")}`;\n}\n\nfunction validateCacheHint(\n hint: McpCacheHint | undefined,\n field: \"discovery\" | \"tools\",\n): void {\n if (!hint) return;\n if (\n hint.ttlMs !== undefined &&\n (!Number.isSafeInteger(hint.ttlMs) || hint.ttlMs < 0)\n ) {\n throw new RangeError(\n `MCP ${field} cache ttlMs must be a non-negative safe integer`,\n );\n }\n if (\n hint.cacheScope !== undefined &&\n hint.cacheScope !== \"public\" &&\n hint.cacheScope !== \"private\"\n ) {\n throw new RangeError(\n `MCP ${field} cache cacheScope must be \"public\" or \"private\"`,\n );\n }\n}\n"],"mappings":";;;;AAsDA,eAAsB,UACpB,KAC6B;CAC7B,MAAM,UAAU,cAAc,GAAG;CAEjC,MAAM,QAAQ,SAAQ,MADC,QAAQ,SAAS,EAAA,CACT,YAAY,CAAC,CACzC,QAAQ,eAAe,WAAW,KAAK,QAAQ,KAAK,CAAC,CACrD,KAAK,eAAe;EACnB,MAAM,OAAO,YAAY,UAAU;EACnC,OAAO,OAAO,OAAO;GACnB,MAAM,MAAM,QAAQ,WAAW,KAAK,KAAK,IAAI;GAC7C,GAAI,WAAW,QAAQ,EAAE,OAAO,WAAW,MAAM,IAAI,CAAC;GACtD,GAAI,WAAW,cAAc,EAAE,aAAa,WAAW,YAAY,IAAI,CAAC;GACxE,GAAI,MAAM,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;GAC3C,aAAa,WAAW,SAAS;IAC/B,MAAM;IACN,YAAY,CAAC;IACb,sBAAsB;GACxB;GACA,GAAI,WAAW,SACX,EAAE,cAAc,WAAW,OAAO,IAClC,CAAC;GACL,OAAO,EACL,4BAA4B,WAAW,GACzC;GACA,aAAa;IACX,cAA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,CAAC,MAAM;CACX,IACE,KAAK,UAAU,KAAA,MACd,CAAC,OAAO,cAAc,KAAK,KAAK,KAAK,KAAK,QAAQ,IAEnD,MAAM,IAAI,WACR,OAAO,MAAM,iDACf;CAEF,IACE,KAAK,eAAe,KAAA,KACpB,KAAK,eAAe,YACpB,KAAK,eAAe,WAEpB,MAAM,IAAI,WACR,OAAO,MAAM,gDACf;AAEJ"}
|
package/dist/react-query.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as AppCapabilityIsSubscribable } from "./index-
|
|
1
|
+
import { u as AppCapabilityIsSubscribable } from "./index-F4ba_olD.mjs";
|
|
2
2
|
import { QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
3
3
|
//#region packages/react-query/src/index.d.ts
|
|
4
4
|
type CapabilityCall = (...args: any[]) => Promise<any>;
|
package/dist/react-query.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CapableServer } from "./index-
|
|
1
|
+
import { t as CapableServer } from "./index-hdH_K5Zc.mjs";
|
|
2
2
|
//#region packages/nitro-host/src/runtime-support.d.ts
|
|
3
3
|
type CapableNitroEntryOptions = {
|
|
4
4
|
/** The default export of the project's `capable.app.*`. */
|
package/dist/runtime-support.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createHttpHandler } from "./src-
|
|
2
|
-
import { t as mcp } from "./mount-
|
|
3
|
-
import { n as http, r as protocol, t as createServer } from "./src-
|
|
1
|
+
import { t as createHttpHandler } from "./src-rkr5j_NH.mjs";
|
|
2
|
+
import { t as mcp } from "./mount-CEFAplR5.mjs";
|
|
3
|
+
import { n as http, r as protocol, t as createServer } from "./src-BWxDO2Ua.mjs";
|
|
4
4
|
//#region packages/nitro-host/src/dev-index.ts
|
|
5
5
|
function devIndex() {
|
|
6
6
|
return {
|
|
@@ -99,7 +99,7 @@ function renderDevIndex(app) {
|
|
|
99
99
|
|
|
100
100
|
<section class="protocols" aria-label="Application surfaces">
|
|
101
101
|
${protocolLink("OpenAPI", "/openapi.json", true)}
|
|
102
|
-
${protocolLink("Manifest", "/
|
|
102
|
+
${protocolLink("Manifest", "/~capable/manifest", true)}
|
|
103
103
|
${protocolLink("MCP", "/mcp", false)}
|
|
104
104
|
</section>
|
|
105
105
|
|
|
@@ -116,7 +116,7 @@ function renderDevIndex(app) {
|
|
|
116
116
|
|
|
117
117
|
<footer class="shell">
|
|
118
118
|
<span>Generated from the application definition</span>
|
|
119
|
-
<a href="/
|
|
119
|
+
<a href="/~capable/manifest">Application manifest <span aria-hidden="true">→</span></a>
|
|
120
120
|
</footer>
|
|
121
121
|
<script>${script}<\/script>
|
|
122
122
|
</body>
|
|
@@ -358,9 +358,9 @@ function renderProductionSplash(app) {
|
|
|
358
358
|
<span class="endpoint-name">OpenAPI</span>
|
|
359
359
|
<code class="endpoint-path">/openapi.json</code>
|
|
360
360
|
</a>
|
|
361
|
-
<a href="/
|
|
361
|
+
<a href="/~capable/manifest">
|
|
362
362
|
<span class="endpoint-name">Manifest</span>
|
|
363
|
-
<code class="endpoint-path"
|
|
363
|
+
<code class="endpoint-path">/~capable/manifest</code>
|
|
364
364
|
</a>
|
|
365
365
|
<div class="endpoint">
|
|
366
366
|
<span class="endpoint-name">MCP</span>
|
|
@@ -562,7 +562,7 @@ function createCapableNitroEntry(options) {
|
|
|
562
562
|
] });
|
|
563
563
|
return options.dev ? server : withProductionMetadataCache(server);
|
|
564
564
|
}
|
|
565
|
-
const productionMetadataPaths = /* @__PURE__ */ new Set(["/
|
|
565
|
+
const productionMetadataPaths = /* @__PURE__ */ new Set(["/~capable/manifest", "/openapi.json"]);
|
|
566
566
|
function withProductionMetadataCache(server) {
|
|
567
567
|
return { async fetch(request) {
|
|
568
568
|
const response = await server.fetch(request);
|