capable-kit 0.1.0-alpha.10 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -106
- package/dist/ai-sdk.d.mts +3 -3
- package/dist/ai-sdk.mjs +7 -9
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +2 -2
- package/dist/bin.mjs +4 -4
- package/dist/cli.d.mts +1 -6
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +3 -3
- package/dist/eve.mjs +7 -9
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-1A44jLuE.d.mts → index-D63DSGZG.d.mts} +17 -50
- package/dist/{index-CHuCLJIs.d.mts → index-D8DWjQ9f.d.mts} +3 -3
- package/dist/{index-D-NV4PiU.d.mts → index-DgxvtAmv.d.mts} +4 -4
- package/dist/{index-WiBWfyTn.d.mts → index-ftQx6OMr.d.mts} +16 -43
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/mcp.d.mts +2 -7
- package/dist/mcp.mjs +1 -1
- package/dist/{mount-BmLHp349.mjs → mount-B9TrHWHh.mjs} +8 -16
- package/dist/mount-B9TrHWHh.mjs.map +1 -0
- package/dist/react-query.d.mts +2 -2
- package/dist/react-query.mjs +1 -1
- package/dist/react-query.mjs.map +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +3 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-DePlcG_t.mjs → src-B592M-6b.mjs} +105 -312
- package/dist/src-B592M-6b.mjs.map +1 -0
- package/dist/{src-B2WeUwUT.mjs → src-Bd1Vnze8.mjs} +31 -49
- package/dist/src-Bd1Vnze8.mjs.map +1 -0
- package/dist/{src-C5jGDnuu.mjs → src-CKC1BdXO.mjs} +3 -3
- package/dist/{src-C5jGDnuu.mjs.map → src-CKC1BdXO.mjs.map} +1 -1
- package/dist/{src-3LE9S4QE.mjs → src-CL9eA6_p.mjs} +17 -29
- package/dist/src-CL9eA6_p.mjs.map +1 -0
- package/dist/{src-_6OmFRYa.mjs → src-Hw9WBgEW.mjs} +10 -28
- package/dist/src-Hw9WBgEW.mjs.map +1 -0
- package/dist/{subscription-DPdwovhw.d.mts → subscription-DbnHcm7C.d.mts} +2 -2
- package/dist/swr.d.mts +2 -2
- package/dist/swr.mjs +1 -1
- package/dist/swr.mjs.map +1 -1
- package/docs/CONTEXT.md +11 -23
- package/docs/internal/architecture.md +14 -27
- package/docs/internal/capability-first-model.md +13 -99
- package/docs/internal/implementation-friction.md +0 -85
- package/docs/site/concepts/apps.mdx +1 -1
- package/docs/site/concepts/architecture.mdx +0 -8
- package/docs/site/concepts/capabilities.mdx +2 -2
- package/docs/site/concepts/presentations.mdx +0 -4
- package/docs/site/patterns/composition.mdx +5 -107
- package/docs/site/patterns/remote-apps.mdx +1 -5
- package/docs/site/patterns/subscriptions.mdx +32 -79
- package/docs/site/reference/packages-and-entry-points.mdx +2 -41
- package/docs/site/surfaces/cli.mdx +0 -11
- package/docs/site/surfaces/typescript.mdx +2 -2
- package/package.json +1 -1
- package/src/index.test.ts +0 -1
- package/src/index.ts +0 -5
- package/src/package.test.ts +0 -9
- package/dist/mount-BmLHp349.mjs.map +0 -1
- package/dist/src-3LE9S4QE.mjs.map +0 -1
- package/dist/src-B2WeUwUT.mjs.map +0 -1
- package/dist/src-DePlcG_t.mjs.map +0 -1
- package/dist/src-_6OmFRYa.mjs.map +0 -1
- package/docs/internal/adr/0003-capability-reference-customization.md +0 -68
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-ftQx6OMr.mjs";
|
|
2
2
|
//#region packages/app/src/manifest.d.ts
|
|
3
3
|
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
4
4
|
type ManifestError = {
|
|
@@ -9,20 +9,15 @@ type ManifestError = {
|
|
|
9
9
|
};
|
|
10
10
|
type ManifestCapability = {
|
|
11
11
|
readonly type: "capability";
|
|
12
|
-
readonly customization?: {
|
|
13
|
-
/** Use the Capability's placed path for surface navigation. */
|
|
14
|
-
readonly navigation?: "destination";
|
|
15
|
-
readonly title?: string;
|
|
16
|
-
readonly description?: string;
|
|
17
|
-
readonly meta?: Readonly<Record<string, unknown>>;
|
|
18
|
-
};
|
|
19
12
|
readonly id: string;
|
|
20
13
|
readonly path: readonly string[];
|
|
21
14
|
readonly title?: string;
|
|
22
15
|
readonly description?: string;
|
|
23
16
|
readonly deprecated: boolean;
|
|
24
17
|
readonly effect?: "read" | "write" | "destructive";
|
|
25
|
-
readonly
|
|
18
|
+
readonly subscription?: {
|
|
19
|
+
readonly mode: "replace";
|
|
20
|
+
};
|
|
26
21
|
readonly input?: JsonSchema;
|
|
27
22
|
readonly output?: JsonSchema;
|
|
28
23
|
readonly errors: Readonly<Record<string, ManifestError>>;
|
|
@@ -38,14 +33,13 @@ type ManifestGroup = {
|
|
|
38
33
|
};
|
|
39
34
|
type ManifestNode = ManifestGroup | ManifestCapability;
|
|
40
35
|
type ApplicationManifest = {
|
|
41
|
-
readonly protocol: "capable.capabilities.
|
|
36
|
+
readonly protocol: "capable.capabilities.v3";
|
|
42
37
|
readonly name: string;
|
|
43
38
|
readonly version: string;
|
|
44
39
|
readonly description?: string;
|
|
45
40
|
readonly capabilities: readonly ManifestNode[];
|
|
46
41
|
};
|
|
47
42
|
declare function createAppManifest(definition: AppDefinition<any>): ApplicationManifest;
|
|
48
|
-
declare function flattenManifestCapabilities(nodes: readonly ManifestNode[]): readonly ManifestCapability[];
|
|
49
43
|
//#endregion
|
|
50
44
|
//#region packages/app/src/runtime.d.ts
|
|
51
45
|
type CapabilityCall = {
|
|
@@ -63,12 +57,12 @@ interface ApplicationTransport {
|
|
|
63
57
|
readonly signal?: AbortSignal;
|
|
64
58
|
}): Promise<ApplicationManifest>;
|
|
65
59
|
call(call: CapabilityCall): Promise<CapabilityResult>;
|
|
66
|
-
subscribe(call: CapabilityCall):
|
|
60
|
+
subscribe(call: CapabilityCall): AsyncIterableIterator<CapabilityResult>;
|
|
67
61
|
}
|
|
68
62
|
declare const APP_RUNTIME_SYMBOL: unique symbol;
|
|
69
63
|
declare const APP_CAPABILITIES_SYMBOL: unique symbol;
|
|
70
|
-
type
|
|
71
|
-
readonly "~capable/capability"
|
|
64
|
+
type AppCapabilityType<TCapability extends AnyCapability> = {
|
|
65
|
+
readonly "~capable/capability"?: TCapability;
|
|
72
66
|
};
|
|
73
67
|
type AppCapabilityInput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends AnyObjectSchema ? InferSchemaInput<TInput> : Record<never, never> : never;
|
|
74
68
|
type AppCapabilityOutput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any> ? TOutput : never;
|
|
@@ -76,10 +70,9 @@ type AppCapabilityOptions = {
|
|
|
76
70
|
readonly signal?: AbortSignal;
|
|
77
71
|
};
|
|
78
72
|
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;
|
|
79
|
-
type AppCapabilityCall<TCapability extends AnyCapability> = ((...args: AppCapabilityArgs<TCapability>) => Promise<AppCapabilityOutput<TCapability>>) &
|
|
80
|
-
type AppCapabilityIsSubscribable<TCall> = TCall extends
|
|
81
|
-
type
|
|
82
|
-
type CallableTree<TTree> = TTree extends AnyCapability ? TTree["execution"] extends "events" ? AppCapabilityReference<TTree> : AppCapabilityCall<TTree> : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any> ? CallableTree<TCapabilities> : TTree extends CapabilityTree ? { readonly [TKey in keyof TTree]: CallableTree<TTree[TKey]>; } : never;
|
|
73
|
+
type AppCapabilityCall<TCapability extends AnyCapability> = ((...args: AppCapabilityArgs<TCapability>) => Promise<AppCapabilityOutput<TCapability>>) & AppCapabilityType<TCapability>;
|
|
74
|
+
type AppCapabilityIsSubscribable<TCall> = TCall extends AppCapabilityType<infer TCapability> ? TCapability extends CapabilityDefinition<any, any, any, any, any, true> ? true : false : false;
|
|
75
|
+
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;
|
|
83
76
|
type App<TCapabilities extends CapabilityTree = CapabilityTree> = CallableTree<TCapabilities> & {
|
|
84
77
|
readonly [APP_RUNTIME_SYMBOL]: ApplicationTransport;
|
|
85
78
|
readonly [APP_CAPABILITIES_SYMBOL]?: TCapabilities;
|
|
@@ -94,7 +87,7 @@ type AppCapabilities<TApplication extends AnyApp> = TApplication extends {
|
|
|
94
87
|
} ? TCapabilities : never;
|
|
95
88
|
declare function getAppRuntime(app: AnyApp): ApplicationTransport;
|
|
96
89
|
declare function isApp(value: unknown): value is AnyApp;
|
|
97
|
-
declare function subscribe<const TCapability extends SubscribableCapability>(capabilityCall:
|
|
90
|
+
declare function subscribe<const TCapability extends SubscribableCapability>(capabilityCall: AppCapabilityCall<TCapability>, ...args: AppCapabilityArgs<TCapability>): AsyncIterableIterator<CapabilityOutput<TCapability>>;
|
|
98
91
|
type AppContextProvider<TContext> = (call: {
|
|
99
92
|
readonly id: string;
|
|
100
93
|
readonly signal?: AbortSignal;
|
|
@@ -117,40 +110,14 @@ declare class TransportError extends Error {
|
|
|
117
110
|
});
|
|
118
111
|
}
|
|
119
112
|
//#endregion
|
|
120
|
-
//#region packages/app/src/customization.d.ts
|
|
121
|
-
declare global {
|
|
122
|
-
interface CapableCustomizationMeta {}
|
|
123
|
-
}
|
|
124
|
-
type CapabilityCustomization = {
|
|
125
|
-
readonly title?: string;
|
|
126
|
-
readonly description?: string;
|
|
127
|
-
readonly meta?: keyof CapableCustomizationMeta extends never ? never : Partial<CapableCustomizationMeta>;
|
|
128
|
-
};
|
|
129
|
-
declare const CUSTOMIZED_SYMBOL: unique symbol;
|
|
130
|
-
type CustomizedCapability<TCapability extends AnyCapability = any> = {
|
|
131
|
-
readonly [CUSTOMIZED_SYMBOL]: true;
|
|
132
|
-
readonly reference: AppCapabilityReference<TCapability>;
|
|
133
|
-
readonly customization: CapabilityCustomization;
|
|
134
|
-
};
|
|
135
|
-
/** Customize a bound local or remote reference without changing its execution. */
|
|
136
|
-
declare function customize<TCapability extends AnyCapability>(reference: AppCapabilityReference<TCapability> | CustomizedCapability<TCapability>, options: CapabilityCustomization): CustomizedCapability<TCapability>;
|
|
137
|
-
/** Surface-facing fields only. Policies and executors retain the source contract. */
|
|
138
|
-
declare function getCapabilityDisplay(capability: ManifestCapability): {
|
|
139
|
-
readonly title?: string;
|
|
140
|
-
readonly description?: string;
|
|
141
|
-
readonly meta: Readonly<Record<string, unknown>>;
|
|
142
|
-
};
|
|
143
|
-
/** Navigation overrides come from the destination only for relocated leaves. */
|
|
144
|
-
declare function getCapabilityNavigationMeta<TSurface extends keyof CapableCustomizationMeta>(capability: ManifestCapability, surface: TSurface): CapableCustomizationMeta[TSurface] | undefined;
|
|
145
|
-
//#endregion
|
|
146
113
|
//#region packages/app/src/composition.d.ts
|
|
147
114
|
type UnionToIntersection<TValue> = (TValue extends unknown ? (value: TValue) => void : never) extends ((value: infer TIntersection) => void) ? TIntersection : never;
|
|
148
115
|
type AppComposition = AnyApp | {
|
|
149
|
-
readonly [key: string]: AppComposition
|
|
116
|
+
readonly [key: string]: AppComposition;
|
|
150
117
|
};
|
|
151
|
-
type ComposedNode<TNode> = TNode extends AnyApp ? AppCapabilities<TNode> : TNode extends
|
|
118
|
+
type ComposedNode<TNode> = TNode extends AnyApp ? AppCapabilities<TNode> : TNode extends Readonly<Record<string, unknown>> ? { readonly [TKey in keyof TNode]: ComposedNode<TNode[TKey]>; } : never;
|
|
152
119
|
type ComposedCapabilities<TNodes extends readonly AppComposition[]> = UnionToIntersection<ComposedNode<TNodes[number]>> extends (infer TCapabilities extends CapabilityTree) ? TCapabilities : never;
|
|
153
|
-
/** Compose
|
|
120
|
+
/** Compose root Apps and tree-shaped App placements into one executable App. */
|
|
154
121
|
declare function composeApps<const TNodes extends readonly [AppComposition, ...AppComposition[]]>(...nodes: TNodes): App<ComposedCapabilities<TNodes>>;
|
|
155
122
|
type SelectionNode<TTree> = TTree extends AnyCapability ? true : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any> ? true | SelectionNode<TCapabilities> : TTree extends CapabilityTree ? true | { readonly [TKey in keyof TTree]?: SelectionNode<TTree[TKey]>; } : never;
|
|
156
123
|
type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree> = {
|
|
@@ -159,5 +126,5 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
|
|
|
159
126
|
};
|
|
160
127
|
declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
|
|
161
128
|
//#endregion
|
|
162
|
-
export { JsonSchema as
|
|
163
|
-
//# sourceMappingURL=index-
|
|
129
|
+
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, composeApps 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 };
|
|
130
|
+
//# sourceMappingURL=index-D63DSGZG.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as CapabilityTree, D as AppDefinition, M as LocatedCapability } from "./index-ftQx6OMr.mjs";
|
|
2
|
+
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-D63DSGZG.mjs";
|
|
3
3
|
//#region packages/fetch/src/codec.d.ts
|
|
4
4
|
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
5
5
|
readonly [key: string]: JsonValue;
|
|
@@ -70,4 +70,4 @@ declare function createHttpHandler<const TCapabilities extends CapabilityTree, T
|
|
|
70
70
|
};
|
|
71
71
|
//#endregion
|
|
72
72
|
export { HttpGroupMeta as a, FetchHandler as c, createProtocolHandler as d, JsonValue as f, HttpCapabilityMeta as i, TransportHeaders as l, defineProtocolCodec as m, CompiledHttpRoute as n, HttpMethod as o, ProtocolCodec as p, ContextProvider as r, createHttpHandler as s, CapabilitySelection as t, createHttpTransport as u };
|
|
73
|
-
//# sourceMappingURL=index-
|
|
73
|
+
//# sourceMappingURL=index-D8DWjQ9f.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ApplicationSelection } from "./index-
|
|
3
|
-
import { p as ProtocolCodec, r as ContextProvider, t as CapabilitySelection } from "./index-
|
|
1
|
+
import { D as AppDefinition, q as MaybePromise } from "./index-ftQx6OMr.mjs";
|
|
2
|
+
import { t as ApplicationSelection } from "./index-D63DSGZG.mjs";
|
|
3
|
+
import { p as ProtocolCodec, r as ContextProvider, t as CapabilitySelection } from "./index-D8DWjQ9f.mjs";
|
|
4
4
|
//#region packages/server/src/index.d.ts
|
|
5
5
|
type ServerMount<TContext> = {
|
|
6
6
|
readonly kind: "capable.server.mount";
|
|
@@ -40,4 +40,4 @@ type CreateServerArgs<TContext> = [TContext] extends [undefined] ? [options?: Cr
|
|
|
40
40
|
declare function createServer<TContext>(app: AppDefinition<any, TContext>, ...[providedOptions]: CreateServerArgs<TContext>): CapableServer;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { createServer as a, ServerMount as i, CompiledServerMount as n, http as o, ServerMiddleware as r, protocol as s, CapableServer as t };
|
|
43
|
-
//# sourceMappingURL=index-
|
|
43
|
+
//# sourceMappingURL=index-DgxvtAmv.d.mts.map
|
|
@@ -213,8 +213,7 @@ type CapabilityMiddlewareArgs<TContext, TInput = unknown> = {
|
|
|
213
213
|
next(): Promise<unknown>;
|
|
214
214
|
};
|
|
215
215
|
type CapabilityMiddleware<TContext, TInput = unknown> = (args: CapabilityMiddlewareArgs<TContext, TInput>) => MaybePromise<unknown>;
|
|
216
|
-
type
|
|
217
|
-
type CapabilityDefinition<TContext = unknown, TInput extends AnyObjectSchema | undefined = AnyObjectSchema | undefined, TOutput = unknown, TErrors extends AnyDefinedErrors = AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry> = OpenMeta<CapabilityMetaRegistry>, TExecution extends CapabilityExecution = CapabilityExecution> = {
|
|
216
|
+
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> = {
|
|
218
217
|
readonly [CAPABILITY_SYMBOL]: true;
|
|
219
218
|
readonly id: string;
|
|
220
219
|
readonly title?: string;
|
|
@@ -226,31 +225,19 @@ type CapabilityDefinition<TContext = unknown, TInput extends AnyObjectSchema | u
|
|
|
226
225
|
readonly errors: TErrors;
|
|
227
226
|
readonly middleware: readonly CapabilityMiddleware<TContext, ParsedInput<TInput>>[];
|
|
228
227
|
readonly meta: TMeta;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
readonly handler: (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => MaybePromise<TOutput>;
|
|
229
|
+
readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, any>;
|
|
230
|
+
readonly toPresentation?: PresentationRenderer<TOutput, TContext>;
|
|
232
231
|
readonly "~capable/context"?: (context: TContext) => TContext;
|
|
233
232
|
readonly "~capable/input"?: TInput;
|
|
234
233
|
readonly "~capable/output"?: TOutput;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, any>;
|
|
239
|
-
} : TExecution extends "live" ? {
|
|
240
|
-
readonly execution: "live";
|
|
241
|
-
readonly handler: (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => MaybePromise<TOutput>;
|
|
242
|
-
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, any>;
|
|
243
|
-
} : {
|
|
244
|
-
readonly execution: "unary";
|
|
245
|
-
readonly handler: (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => MaybePromise<TOutput>;
|
|
246
|
-
readonly subscribe?: never;
|
|
247
|
-
});
|
|
248
|
-
type AnyCapability = CapabilityDefinition<any, any, any, any, any, CapabilityExecution>;
|
|
234
|
+
readonly "~capable/subscribable"?: TSubscribable;
|
|
235
|
+
};
|
|
236
|
+
type AnyCapability = CapabilityDefinition<any, any, any, any, any, any>;
|
|
249
237
|
type CapabilityInput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends AnyObjectSchema ? InferSchemaInput<TInput> : EmptyInput : never;
|
|
250
238
|
type CapabilityOutput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any> ? TOutput : never;
|
|
251
239
|
type CapabilityContext<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<infer TContext, any, any, any, any> ? TContext : never;
|
|
252
|
-
type SubscribableCapability = CapabilityDefinition<any, any, any, any, any,
|
|
253
|
-
type CallableCapability = CapabilityDefinition<any, any, any, any, any, "unary" | "live">;
|
|
240
|
+
type SubscribableCapability = CapabilityDefinition<any, any, any, any, any, true>;
|
|
254
241
|
type ExecuteCapabilityOptions<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<infer TContext, infer TInput, any, any, any> ? (TInput extends AnyObjectSchema ? {
|
|
255
242
|
readonly input: InferSchemaInput<TInput>;
|
|
256
243
|
} : {
|
|
@@ -285,40 +272,26 @@ type InferredOutputCapabilityConfig<TContext, TInput extends AnyObjectSchema | u
|
|
|
285
272
|
readonly toPresentation?: PresentationRenderer<Awaited<TReturn>, TContext>;
|
|
286
273
|
readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, Awaited<TReturn>>;
|
|
287
274
|
};
|
|
288
|
-
type ExplicitEventConfig<TContext, TInput extends AnyObjectSchema | undefined, TOutput extends AnySchema, TErrors extends AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry>> = Omit<ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta>, "handler" | "subscribe" | "effect"> & {
|
|
289
|
-
readonly handler?: never;
|
|
290
|
-
readonly effect: "read";
|
|
291
|
-
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, InferSchemaInput<TOutput>>;
|
|
292
|
-
};
|
|
293
|
-
type InferredEventConfig<TContext, TInput extends AnyObjectSchema | undefined, TOutput, TErrors extends AnyDefinedErrors, TMeta extends OpenMeta<CapabilityMetaRegistry>> = CapabilityBaseConfig<TContext, TInput, TErrors, TMeta> & {
|
|
294
|
-
readonly handler?: never;
|
|
295
|
-
readonly output?: never;
|
|
296
|
-
readonly effect: "read";
|
|
297
|
-
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, TOutput>;
|
|
298
|
-
readonly toPresentation?: PresentationRenderer<NoInfer<TOutput>, TContext>;
|
|
299
|
-
};
|
|
300
275
|
type CapabilityFactory<TContext> = {
|
|
301
|
-
<TInput extends AnyObjectSchema | undefined = undefined, TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitEventConfig<TContext, TInput, TOutput, TErrors, TMeta>): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta, "events">;
|
|
302
|
-
<TInput extends AnyObjectSchema | undefined = undefined, TOutput = unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredEventConfig<TContext, TInput, TOutput, TErrors, TMeta>): CapabilityDefinition<TContext, TInput, TOutput, TErrors, TMeta, "events">;
|
|
303
276
|
<TInput extends AnyObjectSchema | undefined = undefined, TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
|
|
304
277
|
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, InferSchemaInput<TOutput>>;
|
|
305
|
-
}): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta,
|
|
278
|
+
}): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta, true>;
|
|
306
279
|
<TInput extends AnyObjectSchema | undefined = undefined, TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
|
|
307
280
|
readonly subscribe?: never;
|
|
308
|
-
}): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta,
|
|
281
|
+
}): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta, false>;
|
|
309
282
|
<TInput extends AnyObjectSchema | undefined = undefined, TReturn = unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, TReturn, TErrors, TMeta> & {
|
|
310
283
|
readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, Awaited<TReturn>>;
|
|
311
|
-
}): CapabilityDefinition<TContext, TInput, Awaited<TReturn>, TErrors, TMeta,
|
|
284
|
+
}): CapabilityDefinition<TContext, TInput, Awaited<TReturn>, TErrors, TMeta, true>;
|
|
312
285
|
<TInput extends AnyObjectSchema | undefined = undefined, TReturn = unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, TReturn, TErrors, TMeta> & {
|
|
313
286
|
readonly subscribe?: never;
|
|
314
|
-
}): CapabilityDefinition<TContext, TInput, Awaited<TReturn>, TErrors, TMeta,
|
|
287
|
+
}): CapabilityDefinition<TContext, TInput, Awaited<TReturn>, TErrors, TMeta, false>;
|
|
315
288
|
};
|
|
316
289
|
type CapabilityFunction = CapabilityFactory<undefined> & {
|
|
317
290
|
<TContext>(): CapabilityFactory<TContext>;
|
|
318
291
|
withContext<TContext>(): CapabilityFactory<TContext>;
|
|
319
292
|
};
|
|
320
293
|
declare const capability: CapabilityFunction;
|
|
321
|
-
declare function executeCapability<const TCapability extends
|
|
294
|
+
declare function executeCapability<const TCapability extends AnyCapability>(capability: TCapability, options: ExecuteCapabilityOptions<TCapability>): Promise<CapabilityOutput<TCapability>>;
|
|
322
295
|
declare function executeLocatedCapability(located: LocatedCapability, input: unknown, options: {
|
|
323
296
|
readonly context: unknown;
|
|
324
297
|
readonly signal?: AbortSignal;
|
|
@@ -328,8 +301,8 @@ declare function subscribeCapability<const TCapability extends SubscribableCapab
|
|
|
328
301
|
declare function subscribeLocatedCapability(located: LocatedCapability, input: unknown, options: {
|
|
329
302
|
readonly context: unknown;
|
|
330
303
|
readonly signal?: AbortSignal;
|
|
331
|
-
}):
|
|
304
|
+
}): AsyncIterableIterator<unknown>;
|
|
332
305
|
declare function isCapability(value: unknown): value is AnyCapability;
|
|
333
306
|
//#endregion
|
|
334
|
-
export {
|
|
335
|
-
//# sourceMappingURL=index-
|
|
307
|
+
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 };
|
|
308
|
+
//# sourceMappingURL=index-ftQx6OMr.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-
|
|
3
|
-
import {
|
|
4
|
-
export { type App, type AppCapabilityCall, 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-ftQx6OMr.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-DbnHcm7C.mjs";
|
|
3
|
+
import { _ as createApp, d as AppContextProvider, l as AppCapabilityCall, n as composeApps, r as selectApp, s as App, t as ApplicationSelection, v as createRemoteApp, x as subscribe } from "./index-D63DSGZG.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, composeApps, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, 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-Bd1Vnze8.mjs";
|
|
2
2
|
import { t as md } from "./projection-Cgq2u0Wt.mjs";
|
|
3
|
-
import {
|
|
4
|
-
export { capability, composeApps, createApp, createRemoteApp,
|
|
3
|
+
import { n as selectApp, o as createApp, s as createRemoteApp, t as composeApps, u as subscribe } from "./src-B592M-6b.mjs";
|
|
4
|
+
export { capability, composeApps, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, present, selectApp, subscribe, watchQuery };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as ServerMount } from "./index-
|
|
1
|
+
import { C as JsonSchema, h as CapabilityResult, o as AnyApp, t as ApplicationSelection } from "./index-D63DSGZG.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-DgxvtAmv.mjs";
|
|
3
3
|
//#region packages/mcp/src/index.d.ts
|
|
4
4
|
type McpCapabilityMeta = false | {
|
|
5
5
|
readonly name?: string;
|
|
@@ -7,11 +7,6 @@ type McpCapabilityMeta = false | {
|
|
|
7
7
|
readonly idempotentHint?: boolean;
|
|
8
8
|
readonly openWorldHint?: boolean;
|
|
9
9
|
};
|
|
10
|
-
declare global {
|
|
11
|
-
interface CapableCustomizationMeta {
|
|
12
|
-
readonly mcp?: McpCapabilityMeta;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
10
|
type McpIcon = {
|
|
16
11
|
readonly src: string;
|
|
17
12
|
readonly mimeType?: 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-B9TrHWHh.mjs";
|
|
2
2
|
export { createMcp, mcp };
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import { y as renderPresentationMarkdown } from "./src-
|
|
2
|
-
import { a as
|
|
1
|
+
import { y as renderPresentationMarkdown } from "./src-Bd1Vnze8.mjs";
|
|
2
|
+
import { a as TransportError, c as getAppRuntime, n as selectApp, o as createApp } from "./src-B592M-6b.mjs";
|
|
3
3
|
import { Server, createMcpHandler } from "@modelcontextprotocol/server";
|
|
4
4
|
//#region packages/mcp/src/index.ts
|
|
5
5
|
async function createMcp(app) {
|
|
6
6
|
const runtime = getAppRuntime(app);
|
|
7
|
-
const tools =
|
|
8
|
-
...capability,
|
|
9
|
-
...getCapabilityDisplay(capability)
|
|
10
|
-
})).filter((capability) => {
|
|
11
|
-
const meta = capability.meta.mcp;
|
|
12
|
-
if (meta === false) return false;
|
|
13
|
-
if (capability.execution !== "events") return true;
|
|
14
|
-
if (meta !== void 0) throw new Error(`Event Capability "${capability.id}" cannot be exposed as an MCP tool`);
|
|
15
|
-
return false;
|
|
16
|
-
}).map((capability) => {
|
|
7
|
+
const tools = flatten((await runtime.manifest()).capabilities).filter((capability) => capability.meta.mcp !== false).map((capability) => {
|
|
17
8
|
const meta = readMcpMeta(capability);
|
|
18
|
-
const navigation = getCapabilityNavigationMeta(capability, "mcp");
|
|
19
|
-
const name = navigation === false ? void 0 : navigation?.name;
|
|
20
9
|
return Object.freeze({
|
|
21
|
-
name: name ?? capability.path.join("__"),
|
|
10
|
+
name: meta?.name ?? capability.path.join("__"),
|
|
22
11
|
...capability.title ? { title: capability.title } : {},
|
|
23
12
|
...capability.description ? { description: capability.description } : {},
|
|
24
13
|
...meta?.icons ? { icons: meta.icons } : {},
|
|
@@ -74,6 +63,9 @@ function isRecord(value) {
|
|
|
74
63
|
function invalidMcpMeta(capability, reason) {
|
|
75
64
|
throw new Error(`Capability "${capability.id}" has invalid MCP metadata: ${reason}`);
|
|
76
65
|
}
|
|
66
|
+
function flatten(nodes) {
|
|
67
|
+
return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
|
|
68
|
+
}
|
|
77
69
|
//#endregion
|
|
78
70
|
//#region packages/mcp/src/presentation.ts
|
|
79
71
|
function toMcpContent(presentation, output) {
|
|
@@ -232,4 +224,4 @@ function validateCacheHint(hint, field) {
|
|
|
232
224
|
//#endregion
|
|
233
225
|
export { createMcp as n, mcp as t };
|
|
234
226
|
|
|
235
|
-
//# sourceMappingURL=mount-
|
|
227
|
+
//# sourceMappingURL=mount-B9TrHWHh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-B9TrHWHh.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,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AS,GAAG;GAAQ,CAAC,IAAI;EAC5D,CAAC;CACH;AACF;AAEA,SAAS,cAAc,OAAuB;CAC5C,OAAO,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACtD;AAEA,SAAS,kBACP,MACA,OACM;CACN,IAAI,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 {
|
|
1
|
+
import { u as AppCapabilityIsSubscribable } from "./index-D63DSGZG.mjs";
|
|
2
2
|
import { QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
3
3
|
//#region packages/react-query/src/index.d.ts
|
|
4
4
|
type CapabilityCall = (...args: any[]) => Promise<any>;
|
|
@@ -24,7 +24,7 @@ type ReactQueryLiveCapability<TCall extends CapabilityCall> = ReactQueryCapabili
|
|
|
24
24
|
readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
type ReactQueryNode<TValue> = TValue extends CapabilityCall ?
|
|
27
|
+
type ReactQueryNode<TValue> = TValue extends CapabilityCall ? AppCapabilityIsSubscribable<TValue> extends true ? ReactQueryLiveCapability<TValue> : ReactQueryCapability<TValue> : TValue extends object ? { readonly [TKey in Extract<keyof TValue, string>]: ReactQueryNode<TValue[TKey]>; } : never;
|
|
28
28
|
type ReactQueryApp<TApp extends object> = ReactQueryNode<TApp>;
|
|
29
29
|
declare function createReactQuery<const TApp extends object>(app: TApp, options?: {
|
|
30
30
|
readonly keyPrefix?: QueryKey;
|
package/dist/react-query.mjs
CHANGED
package/dist/react-query.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.mjs","names":[],"sources":["../../react-query/src/index.ts"],"sourcesContent":["import {\n subscribe,\n type
|
|
1
|
+
{"version":3,"file":"react-query.mjs","names":[],"sources":["../../react-query/src/index.ts"],"sourcesContent":["import {\n subscribe,\n type AppCapabilityIsSubscribable,\n} from \"@capable/app\";\nimport {\n experimental_streamedQuery,\n type QueryFunction,\n type QueryKey,\n type UseMutationOptions,\n type UseQueryOptions,\n} from \"@tanstack/react-query\";\n\ntype CapabilityCall = (...args: any[]) => Promise<any>;\n\nconst subscribeCall = subscribe as unknown as (\n capabilityCall: CapabilityCall,\n input: unknown,\n options: { readonly signal: AbortSignal },\n) => AsyncIterableIterator<unknown>;\n\ntype CapabilityInput<TCall extends CapabilityCall> =\n Exclude<Parameters<TCall>[0], undefined>;\n\ntype CapabilityVariables<TCall extends CapabilityCall> =\n undefined extends Parameters<TCall>[0]\n ? void\n : Parameters<TCall>[0];\n\ntype CapabilityOutput<TCall extends CapabilityCall> =\n Awaited<ReturnType<TCall>>;\n\nexport type CapabilityQueryOptions<\n TCall extends CapabilityCall,\n TData = CapabilityOutput<TCall>,\n> = Omit<\n UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n >,\n \"queryKey\" | \"queryFn\"\n>;\n\nexport type CapabilityMutationOptions<\n TCall extends CapabilityCall,\n TOnMutateResult = unknown,\n> = Omit<\n UseMutationOptions<\n CapabilityOutput<TCall>,\n Error,\n CapabilityVariables<TCall>,\n TOnMutateResult\n >,\n \"mutationKey\" | \"mutationFn\"\n>;\n\nexport type ReactQueryCapability<TCall extends CapabilityCall> = {\n queryKey(input?: CapabilityInput<TCall>): QueryKey;\n queryOptions<TData = CapabilityOutput<TCall>>(\n input: CapabilityInput<TCall>,\n options?: CapabilityQueryOptions<TCall, TData>,\n ): UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n > & {\n readonly queryKey: QueryKey;\n readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;\n };\n mutationOptions<TOnMutateResult = unknown>(\n options?: CapabilityMutationOptions<TCall, TOnMutateResult>,\n ): UseMutationOptions<\n CapabilityOutput<TCall>,\n Error,\n CapabilityVariables<TCall>,\n TOnMutateResult\n > & {\n readonly mutationKey: QueryKey;\n readonly mutationFn: (\n variables: CapabilityVariables<TCall>,\n ) => Promise<CapabilityOutput<TCall>>;\n };\n};\n\nexport type ReactQueryLiveCapability<TCall extends CapabilityCall> =\n ReactQueryCapability<TCall> & {\n liveQueryOptions<TData = CapabilityOutput<TCall>>(\n input: CapabilityInput<TCall>,\n options?: CapabilityQueryOptions<TCall, TData>,\n ): UseQueryOptions<\n CapabilityOutput<TCall>,\n Error,\n TData,\n QueryKey\n > & {\n readonly queryKey: QueryKey;\n readonly queryFn: QueryFunction<CapabilityOutput<TCall>, QueryKey>;\n };\n };\n\ntype ReactQueryNode<TValue> =\n TValue extends CapabilityCall\n ? AppCapabilityIsSubscribable<TValue> extends true\n ? ReactQueryLiveCapability<TValue>\n : ReactQueryCapability<TValue>\n : TValue extends object\n ? {\n readonly [TKey in Extract<keyof TValue, string>]:\n ReactQueryNode<TValue[TKey]>;\n }\n : never;\n\nexport type ReactQueryApp<TApp extends object> = ReactQueryNode<TApp>;\n\nexport function createReactQuery<const TApp extends object>(\n app: TApp,\n options: {\n readonly keyPrefix?: QueryKey;\n } = {},\n): ReactQueryApp<TApp> {\n const keyPrefix = Object.freeze([...(options.keyPrefix ?? [\"capable\"])]);\n\n const callableAt = (path: readonly string[]): CapabilityCall => {\n let current: unknown = app;\n for (const segment of path) {\n current = (current as Record<string, unknown>)[segment];\n }\n return current as CapabilityCall;\n };\n\n const capabilityKey = (\n path: readonly string[],\n input?: unknown,\n ): QueryKey => Object.freeze([\n ...keyPrefix,\n ...path,\n ...(input === undefined ? [] : [input]),\n ]);\n\n const proxy = (path: readonly string[]): unknown =>\n new Proxy({}, {\n get(_target, key) {\n if (key === \"then\") return undefined;\n if (key === \"queryKey\") {\n return (input?: unknown) => capabilityKey(path, input);\n }\n if (key === \"queryOptions\") {\n return (\n input: unknown,\n queryOptions: Record<string, unknown> = {},\n ) => ({\n ...queryOptions,\n queryKey: capabilityKey(path, input),\n queryFn: ({ signal }: { readonly signal: AbortSignal }) =>\n callableAt(path)(input, { signal }),\n });\n }\n if (key === \"liveQueryOptions\") {\n return (\n input: unknown,\n queryOptions: Record<string, unknown> = {},\n ) => ({\n ...queryOptions,\n queryKey: capabilityKey(path, input),\n queryFn: experimental_streamedQuery<unknown, unknown>({\n streamFn: ({ signal }) =>\n subscribeCall(callableAt(path), input, { signal }),\n reducer: (_current, output) => output,\n initialValue: undefined,\n }) as QueryFunction<unknown, QueryKey>,\n });\n }\n if (key === \"mutationOptions\") {\n return (\n mutationOptions: Record<string, unknown> = {},\n ) => ({\n ...mutationOptions,\n mutationKey: capabilityKey(path),\n mutationFn: (input?: unknown) =>\n callableAt(path)(input ?? {}),\n });\n }\n if (typeof key !== \"string\") return undefined;\n return proxy([...path, key]);\n },\n });\n\n return proxy([]) as ReactQueryApp<TApp>;\n}\n"],"mappings":";;;AAcA,MAAM,gBAAgB;AAsGtB,SAAgB,iBACd,KACA,UAEI,CAAC,GACgB;CACrB,MAAM,YAAY,OAAO,OAAO,CAAC,GAAI,QAAQ,aAAa,CAAC,SAAS,CAAE,CAAC;CAEvE,MAAM,cAAc,SAA4C;EAC9D,IAAI,UAAmB;EACvB,KAAK,MAAM,WAAW,MACpB,UAAW,QAAoC;EAEjD,OAAO;CACT;CAEA,MAAM,iBACJ,MACA,UACa,OAAO,OAAO;EAC3B,GAAG;EACH,GAAG;EACH,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;CACvC,CAAC;CAED,MAAM,SAAS,SACb,IAAI,MAAM,CAAC,GAAG,EACZ,IAAI,SAAS,KAAK;EAChB,IAAI,QAAQ,QAAQ,OAAO,KAAA;EAC3B,IAAI,QAAQ,YACV,QAAQ,UAAoB,cAAc,MAAM,KAAK;EAEvD,IAAI,QAAQ,gBACV,QACE,OACA,eAAwC,CAAC,OACrC;GACJ,GAAG;GACH,UAAU,cAAc,MAAM,KAAK;GACnC,UAAU,EAAE,aACV,WAAW,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;EACtC;EAEF,IAAI,QAAQ,oBACV,QACE,OACA,eAAwC,CAAC,OACrC;GACJ,GAAG;GACH,UAAU,cAAc,MAAM,KAAK;GACnC,SAAS,2BAA6C;IACpD,WAAW,EAAE,aACX,cAAc,WAAW,IAAI,GAAG,OAAO,EAAE,OAAO,CAAC;IACnD,UAAU,UAAU,WAAW;IAC/B,cAAc,KAAA;GAChB,CAAC;EACH;EAEF,IAAI,QAAQ,mBACV,QACE,kBAA2C,CAAC,OACxC;GACJ,GAAG;GACH,aAAa,cAAc,IAAI;GAC/B,aAAa,UACX,WAAW,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;EAChC;EAEF,IAAI,OAAO,QAAQ,UAAU,OAAO,KAAA;EACpC,OAAO,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC;CAC7B,EACF,CAAC;CAEH,OAAO,MAAM,CAAC,CAAC;AACjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CapableServer } from "./index-
|
|
1
|
+
import { t as CapableServer } from "./index-DgxvtAmv.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-Hw9WBgEW.mjs";
|
|
2
|
+
import { t as mcp } from "./mount-B9TrHWHh.mjs";
|
|
3
|
+
import { n as http, r as protocol, t as createServer } from "./src-CKC1BdXO.mjs";
|
|
4
4
|
//#region packages/nitro-host/src/dev-index.ts
|
|
5
5
|
function devIndex() {
|
|
6
6
|
return {
|
package/dist/server.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as protocol, t as CapableServer } from "./index-
|
|
1
|
+
import { a as createServer, i as ServerMount, n as CompiledServerMount, o as http, r as ServerMiddleware, s as protocol, t as CapableServer } from "./index-DgxvtAmv.mjs";
|
|
2
2
|
export { CapableServer, CompiledServerMount, ServerMiddleware, ServerMount, createServer, http, protocol };
|
package/dist/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as http, r as protocol, t as createServer } from "./src-
|
|
1
|
+
import { n as http, r as protocol, t as createServer } from "./src-CKC1BdXO.mjs";
|
|
2
2
|
export { createServer, http, protocol };
|