capable-kit 0.0.1-alpha.4 → 0.0.1-alpha.5
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 +4 -4
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +2 -2
- package/dist/eve.d.mts +1 -1
- package/dist/eve.mjs +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-BB5ogMv-.d.mts → index-Be8-UVBC.d.mts} +49 -8
- package/dist/{index-DJ--zcWG.d.mts → index-D2CRRUzH.d.mts} +4 -4
- package/dist/{index-B_I9n6gN.d.mts → index-Dbc4g9WM.d.mts} +4 -3
- package/dist/{index-DCrxWCTv.d.mts → index-DwXlaTXI.d.mts} +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/mcp.d.mts +2 -2
- package/dist/mcp.mjs +1 -1
- package/dist/{mount-BEBJ2Tss.mjs → mount-xvMsjz1B.mjs} +53 -9
- package/dist/mount-xvMsjz1B.mjs.map +1 -0
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +4 -4
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-D9pLpfeO.mjs → src-BF70JLxI.mjs} +23 -12
- package/dist/src-BF70JLxI.mjs.map +1 -0
- package/dist/{src-3UaBqI8H.mjs → src-C2MGIlT0.mjs} +17 -18
- package/dist/src-C2MGIlT0.mjs.map +1 -0
- package/dist/{src-ChDFqZaE.mjs → src-CDxL6w3d.mjs} +3 -3
- package/dist/{src-ChDFqZaE.mjs.map → src-CDxL6w3d.mjs.map} +1 -1
- package/dist/{src-BjBxOv7x.mjs → src-Db6-XSnU.mjs} +20 -12
- package/dist/src-Db6-XSnU.mjs.map +1 -0
- package/dist/{src-B53ZbNtC.mjs → src-DdV82An-.mjs} +137 -3
- package/dist/src-DdV82An-.mjs.map +1 -0
- package/dist/{subscription-McaLyHM2.d.mts → subscription-Bq792Ad2.d.mts} +2 -2
- package/docs/CONTEXT.md +8 -3
- package/docs/internal/architecture.md +11 -3
- package/docs/internal/capability-first-model.md +7 -1
- package/docs/internal/implementation-friction.md +31 -0
- package/docs/site/concepts/architecture.mdx +10 -2
- package/docs/site/concepts/capabilities.mdx +6 -6
- package/docs/site/concepts/presentations.mdx +161 -0
- package/docs/site/introduction.mdx +166 -49
- package/docs/site/quickstart.mdx +103 -10
- package/docs/site/reference/packages-and-entry-points.mdx +2 -0
- package/docs/site/reference/the-cap-cli.mdx +1 -1
- package/docs/site/surfaces/cli.mdx +2 -2
- package/docs/site/surfaces/http-and-openapi.mdx +1 -1
- package/docs/site/surfaces/mcp.mdx +13 -0
- package/package.json +1 -1
- package/src/index.test.ts +1 -0
- package/src/index.ts +5 -1
- package/src/package.test.ts +2 -1
- package/dist/mount-BEBJ2Tss.mjs.map +0 -1
- package/dist/src-3UaBqI8H.mjs.map +0 -1
- package/dist/src-B53ZbNtC.mjs.map +0 -1
- package/dist/src-BjBxOv7x.mjs.map +0 -1
- package/dist/src-D9pLpfeO.mjs.map +0 -1
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { c as AppCapabilities, o as AnyApp } from "./index-
|
|
1
|
+
import { A as CapabilityTree, c as CapabilityInput, f as CapabilityOutput, i as CapabilityDefinition, k as CapabilityGroupDefinition, t as AnyCapability } from "./index-Be8-UVBC.mjs";
|
|
2
|
+
import { c as AppCapabilities, o as AnyApp } from "./index-Dbc4g9WM.mjs";
|
|
3
3
|
import { Tool, ToolExecutionOptions } from "ai";
|
|
4
4
|
//#region packages/ai-sdk/src/index.d.ts
|
|
5
5
|
type AiSdkCapabilityMeta = false | {
|
package/dist/ai-sdk.mjs
CHANGED
package/dist/app.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as JsonSchema, D as ManifestNode, E as ManifestGroup, O as createAppManifest, S as ApplicationManifest, T as ManifestError, _ as createApp, a as APP_RUNTIME_SYMBOL, b as isApp, c as AppCapabilities, d as AppContextProvider, f as ApplicationTransport, g as TransportError, h as CapabilityResult, i as APP_CAPABILITIES_SYMBOL, l as AppCapabilityCall, m as CapabilityCall, n as mergeApps, o as AnyApp, p as CallableTree, r as selectApp, s as App, t as ApplicationSelection, u as AppCapabilityIsSubscribable, v as createRemoteApp, w as ManifestCapability, x as subscribe, y as getAppRuntime } from "./index-
|
|
1
|
+
import { C as JsonSchema, D as ManifestNode, E as ManifestGroup, O as createAppManifest, S as ApplicationManifest, T as ManifestError, _ as createApp, a as APP_RUNTIME_SYMBOL, b as isApp, c as AppCapabilities, d as AppContextProvider, f as ApplicationTransport, g as TransportError, h as CapabilityResult, i as APP_CAPABILITIES_SYMBOL, l as AppCapabilityCall, m as CapabilityCall, n as mergeApps, o as AnyApp, p as CallableTree, r as selectApp, s as App, t as ApplicationSelection, u as AppCapabilityIsSubscribable, v as createRemoteApp, w as ManifestCapability, x as subscribe, y as getAppRuntime } from "./index-Dbc4g9WM.mjs";
|
|
2
2
|
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, type AnyApp, type App, type AppCapabilities, type AppCapabilityCall, type AppCapabilityIsSubscribable, type AppContextProvider, type ApplicationManifest, type ApplicationSelection, type ApplicationTransport, type CallableTree, type CapabilityCall, type CapabilityResult, type JsonSchema, type ManifestCapability, type ManifestError, type ManifestGroup, type ManifestNode, TransportError, createApp, createAppManifest, createRemoteApp, getAppRuntime, isApp, mergeApps, selectApp, subscribe };
|
package/dist/app.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TransportError, c as getAppRuntime, d as createAppManifest, i as APP_RUNTIME_SYMBOL, l as isApp, n as selectApp, o as createApp, r as APP_CAPABILITIES_SYMBOL, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-
|
|
1
|
+
import { a as TransportError, c as getAppRuntime, d as createAppManifest, i as APP_RUNTIME_SYMBOL, l as isApp, n as selectApp, o as createApp, r as APP_CAPABILITIES_SYMBOL, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-C2MGIlT0.mjs";
|
|
2
2
|
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, TransportError, createApp, createAppManifest, createRemoteApp, getAppRuntime, isApp, mergeApps, selectApp, subscribe };
|
package/dist/bin.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as APPLICATION_SYMBOL } from "./src-
|
|
3
|
-
import { l as isApp, o as createApp, s as createRemoteApp } from "./src-
|
|
4
|
-
import { a as createCliStyle, c as renderSection, l as supportsColor, n as runCli, o as descriptionColumn, s as renderRows } from "./src-
|
|
5
|
-
import { n as createHttpTransport } from "./src-
|
|
2
|
+
import { t as APPLICATION_SYMBOL } from "./src-DdV82An-.mjs";
|
|
3
|
+
import { l as isApp, o as createApp, s as createRemoteApp } from "./src-C2MGIlT0.mjs";
|
|
4
|
+
import { a as createCliStyle, c as renderSection, l as supportsColor, n as runCli, o as descriptionColumn, s as renderRows } from "./src-Db6-XSnU.mjs";
|
|
5
|
+
import { n as createHttpTransport } from "./src-BF70JLxI.mjs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
package/dist/cli.d.mts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createCliStyle, c as renderSection, i as ROW_INDENT, l as supportsColor, n as runCli, o as descriptionColumn, r as MARGIN, s as renderRows, t as createCli } from "./src-
|
|
1
|
+
import { a as createCliStyle, c as renderSection, i as ROW_INDENT, l as supportsColor, n as runCli, o as descriptionColumn, r as MARGIN, s as renderRows, t as createCli } from "./src-Db6-XSnU.mjs";
|
|
2
2
|
export { MARGIN, ROW_INDENT, createCli, createCliStyle, descriptionColumn, renderRows, renderSection, runCli, supportsColor };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-
|
|
3
|
-
export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type GroupMetaRegistry, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type
|
|
1
|
+
import { $ as CapabilityErrorFactory, A as CapabilityTree, B as PresentationRenderer, C as subscribeLocatedCapability, D as AppDefinition, E as AppContext, F as isCapabilityGroup, G as present, H as PresentationValue, I as FilePresentationPart, J as md, K as renderPresentationMarkdown, L as ImagePresentationPart, M as LocatedCapability, N as defineApp, O as CAPABILITY_GROUP_SYMBOL, P as group, Q as CapabilityErrorDefinition, R as MarkdownPresentationPart, S as subscribeCapability, T as AnyCapabilityGroup, U as TablePresentationPart, V as PresentationTableCell, W as normalizePresentation, X as CAPABILITY_ERRORS_SYMBOL, Y as AnyDefinedErrors, Z as CapabilityErrorContract, _ as SubscribeCapabilityOptions, a as CapabilityEffect, at as AnySchema, b as executeLocatedCapability, c as CapabilityInput, ct as Schema, d as CapabilityMiddlewareArgs, dt as schemaToJsonSchema, et as CapableError, f as CapabilityOutput, g as SubscribableCapability, h as ExecuteCapabilityOptions, i as CapabilityDefinition, it as AnyObjectSchema, j as GroupMetaRegistry, k as CapabilityGroupDefinition, l as CapabilityMetaRegistry, lt as SchemaValidationError, m as CapabilitySubscriberArgs, n as CAPABILITY_SYMBOL, nt as ErrorMetaRegistry, o as CapabilityFactory, ot as InferSchemaInput, p as CapabilitySubscriber, q as MaybePromise, r as CapabilityContext, rt as defineErrors, s as CapabilityHandlerArgs, st as InferSchemaOutput, t as AnyCapability, tt as DefinedErrors, u as CapabilityMiddleware, ut as parseSchema, v as capability, w as APPLICATION_SYMBOL, x as isCapability, y as executeCapability, z as PresentationPart } from "./index-Be8-UVBC.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-Bq792Ad2.mjs";
|
|
3
|
+
export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type FilePresentationPart, type GroupMetaRegistry, type ImagePresentationPart, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type MarkdownPresentationPart, type MaybePromise, type PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type Schema, SchemaValidationError, type SubscribableCapability, type SubscribeCapabilityOptions, type TablePresentationPart, type WatchQueryOptions, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, normalizePresentation, parseSchema, present, renderPresentationMarkdown, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
package/dist/core.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { S as defineErrors, _ as normalizePresentation, a as isCapabilityGroup, b as CAPABILITY_ERRORS_SYMBOL, c as executeCapability, d as subscribeCapability, f as subscribeLocatedCapability, g as watchQuery, h as schemaToJsonSchema, i as group, l as executeLocatedCapability, m as parseSchema, n as CAPABILITY_GROUP_SYMBOL, o as CAPABILITY_SYMBOL, p as SchemaValidationError, r as defineApp, s as capability, t as APPLICATION_SYMBOL, u as isCapability, v as present, x as CapableError, y as renderPresentationMarkdown } from "./src-DdV82An-.mjs";
|
|
2
2
|
import { t as md } from "./projection-Cgq2u0Wt.mjs";
|
|
3
|
-
export { APPLICATION_SYMBOL, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, CapableError, SchemaValidationError, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, parseSchema, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
|
3
|
+
export { APPLICATION_SYMBOL, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, CapableError, SchemaValidationError, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, normalizePresentation, parseSchema, present, renderPresentationMarkdown, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
package/dist/eve.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as AnyApp, w as ManifestCapability } from "./index-
|
|
1
|
+
import { o as AnyApp, w as ManifestCapability } from "./index-Dbc4g9WM.mjs";
|
|
2
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
|
package/dist/eve.mjs
CHANGED
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-DwXlaTXI.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-BF70JLxI.mjs";
|
|
2
2
|
export { createHttpHandler, createHttpTransport, createProtocolHandler };
|
|
@@ -68,6 +68,50 @@ declare function defineErrors<const TDefinitions extends CapabilityErrorContract
|
|
|
68
68
|
type MaybePromise<T> = T | Promise<T>;
|
|
69
69
|
declare function md(strings: TemplateStringsArray, ...values: readonly unknown[]): string;
|
|
70
70
|
//#endregion
|
|
71
|
+
//#region packages/core/src/presentation.d.ts
|
|
72
|
+
type PresentationTableCell = string | number | boolean | null;
|
|
73
|
+
type MarkdownPresentationPart = {
|
|
74
|
+
readonly type: "markdown";
|
|
75
|
+
readonly markdown: string;
|
|
76
|
+
};
|
|
77
|
+
type TablePresentationPart = {
|
|
78
|
+
readonly type: "table";
|
|
79
|
+
readonly caption?: string;
|
|
80
|
+
readonly columns: readonly string[];
|
|
81
|
+
readonly rows: readonly (readonly PresentationTableCell[])[];
|
|
82
|
+
};
|
|
83
|
+
type ImagePresentationPart = {
|
|
84
|
+
readonly type: "image";
|
|
85
|
+
readonly base64: string;
|
|
86
|
+
readonly mimeType: `image/${string}`;
|
|
87
|
+
readonly alt: string;
|
|
88
|
+
};
|
|
89
|
+
type FilePresentationPart = {
|
|
90
|
+
readonly type: "file";
|
|
91
|
+
readonly url: string;
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly mimeType?: string;
|
|
94
|
+
readonly size?: number;
|
|
95
|
+
readonly description?: string;
|
|
96
|
+
};
|
|
97
|
+
type PresentationPart = MarkdownPresentationPart | TablePresentationPart | ImagePresentationPart | FilePresentationPart;
|
|
98
|
+
type PresentationNode = string | PresentationPart;
|
|
99
|
+
type PresentationValue = PresentationNode | readonly PresentationNode[];
|
|
100
|
+
type PresentationRenderer<TOutput, TContext> = (output: TOutput, options: {
|
|
101
|
+
readonly context: TContext;
|
|
102
|
+
}) => MaybePromise<PresentationValue>;
|
|
103
|
+
type TablePresentationOptions = Omit<TablePresentationPart, "type">;
|
|
104
|
+
type ImagePresentationOptions = Omit<ImagePresentationPart, "type">;
|
|
105
|
+
type FilePresentationOptions = Omit<FilePresentationPart, "type">;
|
|
106
|
+
type PresentationBuilders = Readonly<{
|
|
107
|
+
table(options: TablePresentationOptions): TablePresentationPart;
|
|
108
|
+
image(options: ImagePresentationOptions): ImagePresentationPart;
|
|
109
|
+
file(options: FilePresentationOptions): FilePresentationPart;
|
|
110
|
+
}>;
|
|
111
|
+
declare const present: PresentationBuilders;
|
|
112
|
+
declare function normalizePresentation(value: PresentationValue): readonly PresentationPart[];
|
|
113
|
+
declare function renderPresentationMarkdown(presentation: PresentationPart | readonly PresentationPart[]): string;
|
|
114
|
+
//#endregion
|
|
71
115
|
//#region packages/core/src/application.d.ts
|
|
72
116
|
declare const CAPABILITY_GROUP_SYMBOL: unique symbol;
|
|
73
117
|
declare const APPLICATION_SYMBOL: unique symbol;
|
|
@@ -157,9 +201,6 @@ type CapabilityMiddlewareArgs<TContext, TInput = unknown> = {
|
|
|
157
201
|
next(): Promise<unknown>;
|
|
158
202
|
};
|
|
159
203
|
type CapabilityMiddleware<TContext, TInput = unknown> = (args: CapabilityMiddlewareArgs<TContext, TInput>) => MaybePromise<unknown>;
|
|
160
|
-
type MarkdownRenderer<TOutput, TContext> = (output: TOutput, options: {
|
|
161
|
-
readonly context: TContext;
|
|
162
|
-
}) => MaybePromise<string>;
|
|
163
204
|
type CapabilityDefinition<TContext = unknown, TInput extends AnyObjectSchema | undefined = AnyObjectSchema | undefined, TOutput = unknown, TErrors extends AnyDefinedErrors = AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry> = OpenMeta<CapabilityMetaRegistry>, TSubscribable extends boolean = boolean> = {
|
|
164
205
|
readonly [CAPABILITY_SYMBOL]: true;
|
|
165
206
|
readonly id: string;
|
|
@@ -174,7 +215,7 @@ type CapabilityDefinition<TContext = unknown, TInput extends AnyObjectSchema | u
|
|
|
174
215
|
readonly meta: TMeta;
|
|
175
216
|
readonly handler: (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => MaybePromise<TOutput>;
|
|
176
217
|
readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, any>;
|
|
177
|
-
readonly
|
|
218
|
+
readonly toPresentation?: PresentationRenderer<TOutput, TContext>;
|
|
178
219
|
readonly "~capable/context"?: (context: TContext) => TContext;
|
|
179
220
|
readonly "~capable/input"?: TInput;
|
|
180
221
|
readonly "~capable/output"?: TOutput;
|
|
@@ -210,13 +251,13 @@ type CapabilityBaseConfig<TContext, TInput extends AnyObjectSchema | undefined,
|
|
|
210
251
|
type ExplicitOutputCapabilityConfig<TContext, TInput extends AnyObjectSchema | undefined, TOutput extends AnySchema, TErrors extends AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry>> = CapabilityBaseConfig<TContext, TInput, TErrors, TMeta> & {
|
|
211
252
|
readonly output: TOutput;
|
|
212
253
|
readonly handler: (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => MaybePromise<InferSchemaInput<TOutput>>;
|
|
213
|
-
readonly
|
|
254
|
+
readonly toPresentation?: PresentationRenderer<InferSchemaOutput<TOutput>, TContext>;
|
|
214
255
|
readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, InferSchemaInput<TOutput>>;
|
|
215
256
|
};
|
|
216
257
|
type InferredOutputCapabilityConfig<TContext, TInput extends AnyObjectSchema | undefined, THandler extends (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown, TErrors extends AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry>> = CapabilityBaseConfig<TContext, TInput, TErrors, TMeta> & {
|
|
217
258
|
readonly output?: never;
|
|
218
259
|
readonly handler: THandler;
|
|
219
|
-
readonly
|
|
260
|
+
readonly toPresentation?: PresentationRenderer<Awaited<ReturnType<THandler>>, TContext>;
|
|
220
261
|
readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, Awaited<ReturnType<THandler>>>;
|
|
221
262
|
};
|
|
222
263
|
type CapabilityFactory<TContext> = {
|
|
@@ -251,5 +292,5 @@ declare function subscribeLocatedCapability(located: LocatedCapability, input: u
|
|
|
251
292
|
}): AsyncIterableIterator<unknown>;
|
|
252
293
|
declare function isCapability(value: unknown): value is AnyCapability;
|
|
253
294
|
//#endregion
|
|
254
|
-
export {
|
|
255
|
-
//# sourceMappingURL=index-
|
|
295
|
+
export { CapabilityErrorFactory as $, CapabilityTree as A, PresentationRenderer as B, subscribeLocatedCapability as C, AppDefinition as D, AppContext as E, isCapabilityGroup as F, present as G, PresentationValue as H, FilePresentationPart as I, md as J, renderPresentationMarkdown as K, ImagePresentationPart as L, LocatedCapability as M, defineApp as N, CAPABILITY_GROUP_SYMBOL as O, group as P, CapabilityErrorDefinition as Q, MarkdownPresentationPart as R, subscribeCapability as S, AnyCapabilityGroup as T, TablePresentationPart as U, PresentationTableCell as V, normalizePresentation as W, CAPABILITY_ERRORS_SYMBOL as X, AnyDefinedErrors as Y, CapabilityErrorContract as Z, SubscribeCapabilityOptions as _, CapabilityEffect as a, AnySchema as at, executeLocatedCapability as b, CapabilityInput as c, Schema as ct, CapabilityMiddlewareArgs as d, schemaToJsonSchema as dt, CapableError as et, CapabilityOutput as f, SubscribableCapability as g, ExecuteCapabilityOptions as h, CapabilityDefinition as i, AnyObjectSchema as it, GroupMetaRegistry as j, CapabilityGroupDefinition as k, CapabilityMetaRegistry as l, SchemaValidationError as lt, CapabilitySubscriberArgs as m, CAPABILITY_SYMBOL as n, ErrorMetaRegistry as nt, CapabilityFactory as o, InferSchemaInput as ot, CapabilitySubscriber as p, MaybePromise as q, CapabilityContext as r, defineErrors as rt, CapabilityHandlerArgs as s, InferSchemaOutput as st, AnyCapability as t, DefinedErrors as tt, CapabilityMiddleware as u, parseSchema as ut, capability as v, APPLICATION_SYMBOL as w, isCapability as x, executeCapability as y, PresentationPart as z };
|
|
296
|
+
//# sourceMappingURL=index-Be8-UVBC.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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-Be8-UVBC.mjs";
|
|
2
|
+
import { t as ApplicationSelection } from "./index-Dbc4g9WM.mjs";
|
|
3
|
+
import { r as ContextProvider, t as CapabilitySelection } from "./index-DwXlaTXI.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, protocol as s, CapableServer as t };
|
|
42
|
-
//# sourceMappingURL=index-
|
|
42
|
+
//# sourceMappingURL=index-D2CRRUzH.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as CapabilityTree, D as AppDefinition, E as AppContext, f as CapabilityOutput, g as SubscribableCapability, i as CapabilityDefinition, it as AnyObjectSchema, k as CapabilityGroupDefinition, ot as InferSchemaInput, q as MaybePromise, t as AnyCapability, z as PresentationPart } from "./index-Be8-UVBC.mjs";
|
|
2
2
|
//#region packages/app/src/manifest.d.ts
|
|
3
3
|
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
4
4
|
type ManifestError = {
|
|
@@ -46,10 +46,11 @@ type CapabilityCall = {
|
|
|
46
46
|
readonly id: string;
|
|
47
47
|
readonly input?: unknown;
|
|
48
48
|
readonly signal?: AbortSignal;
|
|
49
|
+
readonly presentation?: boolean;
|
|
49
50
|
};
|
|
50
51
|
type CapabilityResult = {
|
|
51
52
|
readonly output: unknown;
|
|
52
|
-
readonly
|
|
53
|
+
readonly presentation?: readonly PresentationPart[];
|
|
53
54
|
};
|
|
54
55
|
interface ApplicationTransport {
|
|
55
56
|
manifest(options?: {
|
|
@@ -121,4 +122,4 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
|
|
|
121
122
|
declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
|
|
122
123
|
//#endregion
|
|
123
124
|
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 };
|
|
124
|
-
//# sourceMappingURL=index-
|
|
125
|
+
//# sourceMappingURL=index-Dbc4g9WM.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-
|
|
1
|
+
import { A as CapabilityTree, D as AppDefinition, M as LocatedCapability } from "./index-Be8-UVBC.mjs";
|
|
2
|
+
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-Dbc4g9WM.mjs";
|
|
3
3
|
//#region packages/fetch/src/capable.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-DwXlaTXI.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as
|
|
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-
|
|
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
|
|
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-Be8-UVBC.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-Bq792Ad2.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-Dbc4g9WM.mjs";
|
|
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 { c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability,
|
|
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-DdV82An-.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-
|
|
4
|
-
export { capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, selectApp, subscribe, watchQuery };
|
|
3
|
+
import { n as selectApp, o as createApp, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-C2MGIlT0.mjs";
|
|
4
|
+
export { capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, present, 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-Dbc4g9WM.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-D2CRRUzH.mjs";
|
|
3
3
|
//#region packages/mcp/src/index.d.ts
|
|
4
4
|
type McpCapabilityMeta = false | {
|
|
5
5
|
readonly name?: string;
|
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-xvMsjz1B.mjs";
|
|
2
2
|
export { createMcp, mcp };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as renderPresentationMarkdown } from "./src-DdV82An-.mjs";
|
|
2
|
+
import { a as TransportError, c as getAppRuntime, o as createApp } from "./src-C2MGIlT0.mjs";
|
|
2
3
|
import { Server, createMcpHandler } from "@modelcontextprotocol/server";
|
|
3
4
|
//#region packages/mcp/src/index.ts
|
|
4
5
|
async function createMcp(app) {
|
|
@@ -23,6 +24,7 @@ async function createMcp(app) {
|
|
|
23
24
|
return runtime.call({
|
|
24
25
|
id: capability.id,
|
|
25
26
|
input,
|
|
27
|
+
presentation: true,
|
|
26
28
|
...options?.signal ? { signal: options.signal } : {}
|
|
27
29
|
});
|
|
28
30
|
}
|
|
@@ -48,6 +50,54 @@ function flatten(nodes) {
|
|
|
48
50
|
return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
|
|
49
51
|
}
|
|
50
52
|
//#endregion
|
|
53
|
+
//#region packages/mcp/src/presentation.ts
|
|
54
|
+
function toMcpContent(presentation, output) {
|
|
55
|
+
if (!presentation?.length) return [{
|
|
56
|
+
type: "text",
|
|
57
|
+
text: stringify(output)
|
|
58
|
+
}];
|
|
59
|
+
const content = [];
|
|
60
|
+
for (const part of presentation) {
|
|
61
|
+
if (part.type === "markdown") {
|
|
62
|
+
content.push({
|
|
63
|
+
type: "text",
|
|
64
|
+
text: renderPresentationMarkdown(part)
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (part.type === "table") {
|
|
69
|
+
content.push({
|
|
70
|
+
type: "text",
|
|
71
|
+
text: renderPresentationMarkdown(part)
|
|
72
|
+
});
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (part.type === "image") {
|
|
76
|
+
content.push({
|
|
77
|
+
type: "text",
|
|
78
|
+
text: `[Image: ${part.alt}]`
|
|
79
|
+
}, {
|
|
80
|
+
type: "image",
|
|
81
|
+
data: part.base64,
|
|
82
|
+
mimeType: part.mimeType
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
content.push({
|
|
87
|
+
type: "resource_link",
|
|
88
|
+
uri: part.url,
|
|
89
|
+
name: part.name,
|
|
90
|
+
...part.description ? { description: part.description } : {},
|
|
91
|
+
...part.mimeType ? { mimeType: part.mimeType } : {},
|
|
92
|
+
...part.size === void 0 ? {} : { size: part.size }
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return content;
|
|
96
|
+
}
|
|
97
|
+
function stringify(value) {
|
|
98
|
+
return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
51
101
|
//#region packages/mcp/src/mount.ts
|
|
52
102
|
function mcp(options = {}) {
|
|
53
103
|
const path = normalizePath(options.path ?? "/mcp");
|
|
@@ -80,10 +130,7 @@ function createMcpServer(tools, info) {
|
|
|
80
130
|
try {
|
|
81
131
|
const result = await tool.call(request.params.arguments ?? {}, { signal: context.mcpReq.signal });
|
|
82
132
|
return {
|
|
83
|
-
content:
|
|
84
|
-
type: "text",
|
|
85
|
-
text: result.markdown ?? stringify(result.output)
|
|
86
|
-
}],
|
|
133
|
+
content: toMcpContent(result.presentation, result.output),
|
|
87
134
|
structuredContent: isRecord(result.output) ? result.output : { value: result.output }
|
|
88
135
|
};
|
|
89
136
|
} catch (error) {
|
|
@@ -119,9 +166,6 @@ function toolError(message, details) {
|
|
|
119
166
|
}]
|
|
120
167
|
};
|
|
121
168
|
}
|
|
122
|
-
function stringify(value) {
|
|
123
|
-
return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
124
|
-
}
|
|
125
169
|
function normalizePath(value) {
|
|
126
170
|
return `/${value.split("/").filter(Boolean).join("/")}`;
|
|
127
171
|
}
|
|
@@ -131,4 +175,4 @@ function isRecord(value) {
|
|
|
131
175
|
//#endregion
|
|
132
176
|
export { createMcp as n, mcp as t };
|
|
133
177
|
|
|
134
|
-
//# sourceMappingURL=mount-
|
|
178
|
+
//# sourceMappingURL=mount-xvMsjz1B.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-xvMsjz1B.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 };\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 inputSchema: JsonSchema;\n readonly outputSchema?: JsonSchema;\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: 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 = capability.meta.mcp as Exclude<McpCapabilityMeta, false> | undefined;\n return Object.freeze({\n name: meta?.name ?? capability.path.join(\"__\"),\n ...(capability.title ? { title: capability.title } : {}),\n ...(capability.description ? { description: capability.description } : {}),\n inputSchema: capability.input ?? {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n ...(capability.output\n ? { outputSchema: mcpOutputSchema(capability.output) }\n : {}),\n annotations: {\n readOnlyHint: capability.effect === \"read\",\n destructiveHint: capability.effect === \"destructive\",\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 mcpOutputSchema(schema: JsonSchema): JsonSchema {\n if (schema.type === \"object\") return schema;\n return {\n type: \"object\",\n properties: { value: schema },\n required: [\"value\"],\n additionalProperties: false,\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 { createApp, TransportError } from \"@capable/app\";\nimport {\n createMcpHandler,\n Server,\n type CallToolResult,\n type Tool,\n} from \"@modelcontextprotocol/server\";\nimport { createMcp, type McpTool } from \"./index.ts\";\nimport { toMcpContent } from \"./presentation.ts\";\n\nexport function mcp<TContext = any>(\n options: {\n readonly path?: string;\n readonly name?: string;\n readonly version?: string;\n } = {},\n): ServerMount<TContext> {\n const path = normalizePath(options.path ?? \"/mcp\");\n return {\n kind: \"capable.server.mount\",\n compile(app, context) {\n const handler = createMcpHandler(async ({ requestInfo }) => {\n if (!requestInfo) {\n throw new Error(\"The MCP HTTP handler requires request information\");\n }\n const executable = createApp(\n app,\n context\n ? { context: () => context({ request: requestInfo }) }\n : undefined as never,\n );\n const tools = await createMcp(executable);\n return createMcpServer(tools, {\n name: options.name ?? app.name ?? \"capable\",\n version: options.version ?? app.version ?? \"0.0.0\",\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: { readonly name: string; readonly version: string },\n): Server {\n const server = new Server(info, {\n capabilities: { tools: {} },\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 {\n content: toMcpContent(result.presentation, result.output),\n structuredContent: isRecord(result.output)\n ? result.output\n : { value: result.output },\n } satisfies CallToolResult;\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 inputSchema: tool.inputSchema as Tool[\"inputSchema\"],\n ...(tool.outputSchema\n ? { outputSchema: tool.outputSchema as Tool[\"outputSchema\"] }\n : {}),\n annotations: tool.annotations,\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 isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CapableServer } from "./index-
|
|
1
|
+
import { t as CapableServer } from "./index-D2CRRUzH.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-BF70JLxI.mjs";
|
|
2
|
+
import { t as mcp } from "./mount-xvMsjz1B.mjs";
|
|
3
|
+
import { n as http, r as protocol, t as createServer } from "./src-CDxL6w3d.mjs";
|
|
4
4
|
//#region packages/nitro-host/src/dev-index.ts
|
|
5
5
|
function devIndex() {
|
|
6
6
|
return {
|
|
@@ -34,7 +34,7 @@ function renderDevIndex(app) {
|
|
|
34
34
|
const route = routeByCapability.get(capability);
|
|
35
35
|
const command = cliCommand(entry);
|
|
36
36
|
const canOpen = route?.method === "GET" && capability.input === void 0;
|
|
37
|
-
const badges = [capability.
|
|
37
|
+
const badges = [capability.toPresentation ? "Presentation" : void 0, capability.deprecated ? "Deprecated" : void 0].filter(Boolean);
|
|
38
38
|
return `
|
|
39
39
|
<article class="capability">
|
|
40
40
|
<div class="capability-head">
|