capable-kit 0.0.1-alpha.7 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +6 -0
  3. package/dist/ai-sdk.d.mts +3 -3
  4. package/dist/ai-sdk.mjs +9 -7
  5. package/dist/ai-sdk.mjs.map +1 -1
  6. package/dist/app.d.mts +2 -2
  7. package/dist/app.mjs +2 -2
  8. package/dist/bin.mjs +12 -9
  9. package/dist/bin.mjs.map +1 -1
  10. package/dist/cli.d.mts +9 -1
  11. package/dist/cli.mjs +1 -1
  12. package/dist/core.d.mts +3 -3
  13. package/dist/core.mjs +1 -1
  14. package/dist/eve.d.mts +82 -5
  15. package/dist/eve.mjs +364 -23
  16. package/dist/eve.mjs.map +1 -1
  17. package/dist/http.d.mts +2 -2
  18. package/dist/http.mjs +2 -2
  19. package/dist/{index-Dbc4g9WM.d.mts → index-1A44jLuE.d.mts} +54 -16
  20. package/dist/{index-DwXlaTXI.d.mts → index-CHuCLJIs.d.mts} +20 -4
  21. package/dist/{index-D2CRRUzH.d.mts → index-D-NV4PiU.d.mts} +6 -5
  22. package/dist/{index-Be8-UVBC.d.mts → index-WiBWfyTn.d.mts} +66 -27
  23. package/dist/index.d.mts +4 -4
  24. package/dist/index.mjs +3 -3
  25. package/dist/mcp.d.mts +40 -5
  26. package/dist/mcp.mjs +1 -1
  27. package/dist/mount-BmLHp349.mjs +235 -0
  28. package/dist/mount-BmLHp349.mjs.map +1 -0
  29. package/dist/react-query.d.mts +2 -2
  30. package/dist/react-query.mjs +1 -1
  31. package/dist/react-query.mjs.map +1 -1
  32. package/dist/runtime-support.d.mts +1 -1
  33. package/dist/runtime-support.mjs +8 -8
  34. package/dist/runtime-support.mjs.map +1 -1
  35. package/dist/server.d.mts +1 -1
  36. package/dist/server.mjs +1 -1
  37. package/dist/{src-Db6-XSnU.mjs → src-3LE9S4QE.mjs} +67 -38
  38. package/dist/src-3LE9S4QE.mjs.map +1 -0
  39. package/dist/{src-DdV82An-.mjs → src-B2WeUwUT.mjs} +69 -34
  40. package/dist/src-B2WeUwUT.mjs.map +1 -0
  41. package/dist/{src-CDxL6w3d.mjs → src-C5jGDnuu.mjs} +9 -6
  42. package/dist/src-C5jGDnuu.mjs.map +1 -0
  43. package/dist/src-DePlcG_t.mjs +787 -0
  44. package/dist/src-DePlcG_t.mjs.map +1 -0
  45. package/dist/{src-BF70JLxI.mjs → src-_6OmFRYa.mjs} +185 -38
  46. package/dist/src-_6OmFRYa.mjs.map +1 -0
  47. package/dist/{subscription-Bq792Ad2.d.mts → subscription-DPdwovhw.d.mts} +2 -2
  48. package/dist/swr.d.mts +2 -2
  49. package/dist/swr.mjs +1 -1
  50. package/dist/swr.mjs.map +1 -1
  51. package/docs/CONTEXT.md +42 -21
  52. package/docs/README.md +3 -0
  53. package/docs/internal/README.md +3 -0
  54. package/docs/internal/adr/0001-capability-is-the-semantic-boundary.md +1 -1
  55. package/docs/internal/adr/0002-version-the-capable-value-codec.md +24 -0
  56. package/docs/internal/adr/0003-capability-reference-customization.md +68 -0
  57. package/docs/internal/architecture.md +64 -19
  58. package/docs/internal/capability-first-model.md +127 -18
  59. package/docs/internal/eve-recovery-validation.md +86 -0
  60. package/docs/internal/feedback/v-ray/README.md +258 -0
  61. package/docs/internal/feedback/v-ray/inference.mjs +43 -0
  62. package/docs/internal/feedback/v-ray/reproduce.mjs +36 -0
  63. package/docs/internal/implementation-friction.md +481 -1
  64. package/docs/internal/releases.md +79 -0
  65. package/docs/site/capable-orpc-and-trpc.mdx +5 -5
  66. package/docs/site/concepts/apps.mdx +17 -8
  67. package/docs/site/concepts/architecture.mdx +10 -2
  68. package/docs/site/concepts/capabilities.mdx +41 -4
  69. package/docs/site/concepts/errors.mdx +11 -1
  70. package/docs/site/concepts/presentations.mdx +20 -0
  71. package/docs/site/hosting/any-fetch-host.mdx +2 -2
  72. package/docs/site/hosting/next-js.mdx +38 -4
  73. package/docs/site/hosting/standalone-server.mdx +2 -2
  74. package/docs/site/introduction.mdx +9 -6
  75. package/docs/site/patterns/composition.mdx +159 -11
  76. package/docs/site/patterns/remote-apps.mdx +68 -10
  77. package/docs/site/patterns/subscriptions.mdx +79 -32
  78. package/docs/site/quickstart.mdx +19 -14
  79. package/docs/site/reference/packages-and-entry-points.mdx +52 -5
  80. package/docs/site/reference/surface-metadata.mdx +7 -2
  81. package/docs/site/reference/the-cap-cli.mdx +2 -2
  82. package/docs/site/surfaces/ai-sdk.mdx +3 -3
  83. package/docs/site/surfaces/cli.mdx +47 -3
  84. package/docs/site/surfaces/eve.mdx +67 -20
  85. package/docs/site/surfaces/mcp.mdx +73 -5
  86. package/docs/site/surfaces/react-query.mdx +3 -3
  87. package/docs/site/surfaces/swr.mdx +3 -3
  88. package/docs/site/surfaces/typescript.mdx +8 -8
  89. package/docs/site/surfaces.mdx +1 -1
  90. package/package-docs.mjs +3 -0
  91. package/package.json +11 -11
  92. package/src/bin.ts +0 -0
  93. package/src/index.test.ts +2 -1
  94. package/src/index.ts +6 -1
  95. package/src/mcp.ts +4 -0
  96. package/src/package.test.ts +9 -0
  97. package/dist/mount-xvMsjz1B.mjs +0 -178
  98. package/dist/mount-xvMsjz1B.mjs.map +0 -1
  99. package/dist/src-BF70JLxI.mjs.map +0 -1
  100. package/dist/src-C2MGIlT0.mjs +0 -464
  101. package/dist/src-C2MGIlT0.mjs.map +0 -1
  102. package/dist/src-CDxL6w3d.mjs.map +0 -1
  103. package/dist/src-Db6-XSnU.mjs.map +0 -1
  104. package/dist/src-DdV82An-.mjs.map +0 -1
@@ -13,18 +13,12 @@ export const metadata = docMetadata("/surfaces/eve", frontmatter);
13
13
 
14
14
  ## Start in-process [#local]
15
15
 
16
- Put an executable app directly in Eve's `agent/tools/` directory. There is no second server and no HTTP hop.
16
+ Import an executable app into Eve's `agent/tools/` module. There is no second server and no HTTP hop.
17
17
 
18
18
  ```ts title="agent/tools/todos.ts"
19
- import { createApp } from "capable-kit";
20
19
  import { createEveTools } from "capable-kit/eve";
21
20
  import { always } from "eve/tools/approval";
22
- import definition from "../../capable.app";
23
- import { todos } from "../../todos";
24
-
25
- const app = createApp(definition, {
26
- context: () => ({ todos }),
27
- });
21
+ import { app } from "../../capable.app";
28
22
 
29
23
  export default createEveTools(app, {
30
24
  approval: (capability) =>
@@ -57,24 +51,26 @@ cap preview # run that production build locally
57
51
  cap build --preset vercel
58
52
  ```
59
53
 
60
- The standalone server exposes the Capable transport at `/_capable/`. Its manifest describes the same capability tree, effects, schemas, and metadata the local app exposed.
54
+ The standalone server exposes the Capable transport at `/~capable/`. Its manifest describes the same capability tree, effects, schemas, and metadata the local app exposed.
61
55
 
62
56
  ## Point Eve at the remote app [#remote]
63
57
 
64
58
  Replace `createApp()` with `createRemoteApp()`. The tool projection and approval policy stay the same; only the placement of execution changes.
65
59
 
66
- ```ts title="agent/tools/todos.ts"
60
+ ```ts title="remote.app.ts"
67
61
  import { createRemoteApp } from "capable-kit";
68
- import { createEveTools } from "capable-kit/eve";
69
62
  import { createHttpTransport } from "capable-kit/http";
70
- import { always } from "eve/tools/approval";
71
- import type definition from "../../capable.app";
63
+ import type { AppDefinition } from "./capable.app";
72
64
 
73
- const app = createRemoteApp<typeof definition>(
74
- createHttpTransport({
75
- url: "https://todos.example.com/_capable/",
76
- }),
77
- );
65
+ export const app = createRemoteApp<AppDefinition>(createHttpTransport({
66
+ url: "https://todos.example.com/~capable/",
67
+ }));
68
+ ```
69
+
70
+ ```ts title="agent/tools/todos.ts"
71
+ import { createEveTools } from "capable-kit/eve";
72
+ import { always } from "eve/tools/approval";
73
+ import { app } from "../../remote.app";
78
74
 
79
75
  export default createEveTools(app, {
80
76
  approval: (capability) =>
@@ -91,7 +87,7 @@ export default createEveTools(app, {
91
87
 
92
88
  > **The definition import is type-only**
93
89
  >
94
- > Eve imports `typeof definition` for static typing, but it does not execute the local handlers. Discovery and calls go through the remote transport.
90
+ > Eve imports the named `AppDefinition` type, but it does not execute the local handlers. Discovery and calls go through the remote transport.
95
91
 
96
92
  ## Approvals from effect [#approvals]
97
93
 
@@ -112,10 +108,61 @@ meta: {
112
108
 
113
109
  ## Durability [#durability]
114
110
 
115
- The tool definition resolves at Eve's `step.started` boundary. With a local app, Eve keeps the app and its context provider in memory. With a remote app, it keeps the transport-backed runtime live instead. In both cases Eve checkpoints the tool call and its result.
111
+ The tool catalog resolves at Eve's `session.started` boundary. Eve reruns that resolver to reconstruct callbacks after a cold start. Capable persists the capability ID and rebuilds provider Apps using the current execution session. Define your App or provider in deployed code and keep its data in persistent storage. The repository currently backports `defineDurableCallback` from Eve PR #2981 at commit `8e6964036657082ce1405864cf3313ad11fc8d60`; external consumers need the same patch until Eve releases the helper.
116
112
 
117
113
  > **Interrupted steps can re-run**
118
114
  >
119
115
  > As with any Eve tool, a side effect must be idempotent: an interrupted step may execute again. This is a property of durable agent execution, not of Capable.
120
116
 
117
+ ## Wrap an Eve agent as an app [#agent-app]
118
+
119
+ `createEveAgentAdapter()` wraps remote execution with `send`, `result`,
120
+ and `cancel` capabilities. Its `name` mounts the lifecycle under a namespace, so
121
+ multiple agents compose alongside direct capabilities.
122
+
123
+ ```ts
124
+ import { composeApps } from "capable-kit";
125
+ import { createEveAgentAdapter } from "capable-kit/eve";
126
+ import { createMcp } from "capable-kit/mcp";
127
+
128
+ // Clients and authorization are bound by the host to one authenticated caller.
129
+ const content = createEveAgentAdapter({
130
+ name: "content", client: contentClient, authorize,
131
+ });
132
+ const research = createEveAgentAdapter({
133
+ name: "research", client: researchClient, authorize,
134
+ });
135
+ const app = composeApps(content.app, research.app, notionApp);
136
+ const tools = await createMcp(app);
137
+ // content__send, content__result, content__cancel, ...
138
+
139
+ const { runId } = await app.content.send({ message: "Draft an outline" });
140
+ const result = await app.content.send({
141
+ runId, message: "Make it shorter", wait: true, timeoutMs: 60_000,
142
+ });
143
+ ```
144
+
145
+ The CLI uses a positional message:
146
+
147
+ ```sh
148
+ recipes chef send "What can I cook?" --wait
149
+ recipes chef send "Vegetarian please" --run-id '<runId>' --wait
150
+ ```
151
+
152
+ Without `wait`, `send` returns the accepted ID and `running` immediately. Waiting
153
+ uses Eve's response stream and stops at completion, input, failure, or cancellation.
154
+ The default deadline is 30 seconds (`timeoutMs`, at most five minutes); on timeout,
155
+ it returns the accepted ID with `running`. A single pending question is answered
156
+ automatically; multiple questions require `requestId`. Selection-only questions
157
+ require `optionId` instead of submitting the message as freeform text.
158
+
159
+ Run IDs are durable Eve session IDs, so subsequent CLI processes can attach
160
+ without a local mapping. The host authorizes every operation against the caller
161
+ and session. Only typed questions are answerable; approvals remain host-owned.
162
+
163
+ The adapter targets Eve 0.52.3. Each result or continuation reconstructs state from
164
+ Eve's finite durable history, with configurable event and time limits. An
165
+ incomplete read fails rather than returning partial state. Call `dispose()` to
166
+ abort local requests; Eve execution continues until explicitly cancelled.
167
+
121
168
  </DocsPage>
@@ -22,7 +22,23 @@ import definition from "./capable.app";
22
22
 
23
23
  export default createServer(definition, {
24
24
  context: ({ request }) => contextFromRequest(request),
25
- mounts: [protocol(), mcp({ path: "/mcp", name: "todos" })],
25
+ mounts: [
26
+ protocol(),
27
+ mcp({
28
+ path: "/mcp",
29
+ name: "todos",
30
+ title: "Todo tools",
31
+ description: "Read and manage the current user's todos.",
32
+ websiteUrl: "https://example.com/todos",
33
+ icons: [{ src: "https://example.com/todos.svg" }],
34
+ instructions: "Use these tools to manage the current user's todos.",
35
+ selection: { exclude: { admin: true } },
36
+ cache: {
37
+ discovery: { ttlMs: 60_000, cacheScope: "private" },
38
+ tools: { ttlMs: 300_000, cacheScope: "private" },
39
+ },
40
+ }),
41
+ ],
26
42
  });
27
43
  ```
28
44
 
@@ -31,6 +47,14 @@ export default createServer(definition, {
31
47
  | `path` | `/mcp` | Endpoint path |
32
48
  | `name` | App name | Server name reported during connection setup |
33
49
  | `version` | App version | Server version reported during connection setup |
50
+ | `title` | None | Human-readable server name |
51
+ | `description` | App description | Server description shown by supporting clients |
52
+ | `websiteUrl` | None | Server website shown by supporting clients |
53
+ | `icons` | None | Server icons shown by supporting clients |
54
+ | `instructions` | None | Guidance every MCP client receives during connection setup |
55
+ | `selection` | Everything | Capability tree exposed as tools; exclude wins over include |
56
+ | `cache.discovery` | `0 ms`, private | Modern-client cache hint for server discovery |
57
+ | `cache.tools` | `0 ms`, private | Modern-client cache hint for the tool list |
34
58
 
35
59
  ## What an agent sees [#derivation]
36
60
 
@@ -41,8 +65,15 @@ export default createServer(definition, {
41
65
  | `description` | Tool description |
42
66
  | `input` | JSON Schema for arguments |
43
67
  | `output` | Structured output schema |
44
- | `effect: "read"` | `readOnlyHint` |
45
- | `effect: "destructive"` | `destructiveHint` |
68
+ | `effect: "read"` | `readOnlyHint: true`, `destructiveHint: false` |
69
+ | `effect: "write"` | `readOnlyHint: false`, `destructiveHint: false` |
70
+ | `effect: "destructive"` | `readOnlyHint: false`, `destructiveHint: true` |
71
+ | `meta.mcp.icons` | Tool icons |
72
+ | `meta.mcp.idempotentHint` | Idempotence hint |
73
+ | `meta.mcp.openWorldHint` | Whether the tool may interact beyond a closed domain |
74
+
75
+ `idempotentHint` is meaningful only for tools that are not read-only. Omitted
76
+ `openWorldHint` uses MCP's default of `true`.
46
77
 
47
78
  ```ts title="capabilities.ts"
48
79
  const getTodo = todo({
@@ -53,13 +84,34 @@ const getTodo = todo({
53
84
  input: z.object({ todoId: z.string() }),
54
85
  output: Todo,
55
86
  meta: {
56
- mcp: { name: "todos_get" }, // default is the app path: todos__get
87
+ mcp: {
88
+ name: "todos_get", // default is the app path: todos__get
89
+ icons: [{ src: "https://example.com/todo.svg" }],
90
+ openWorldHint: false,
91
+ },
57
92
  // mcp: false, // never expose this capability as a tool
58
93
  },
59
94
  handler: ({ input, context }) => context.todos.get(input.todoId),
60
95
  });
61
96
  ```
62
97
 
98
+ The tool name is a portable wire name derived from the Application path; it is
99
+ not the Capability's canonical identity. Every derived tool also exposes that
100
+ identity as `_meta["dev.capable/capabilityId"]`:
101
+
102
+ ```json
103
+ {
104
+ "name": "todos__get",
105
+ "_meta": {
106
+ "dev.capable/capabilityId": "todos.get"
107
+ }
108
+ }
109
+ ```
110
+
111
+ Clients call the tool by `name`. The metadata makes logs, inspectors, and
112
+ cross-surface tooling able to associate that name with the Capability without
113
+ guessing from delimiters.
114
+
63
115
  > **Descriptions are part of the API now**
64
116
  >
65
117
  > An agent chooses tools by reading them. A precise `description` is as load-bearing as the input schema, and it is written once for every surface instead of separately for each one.
@@ -77,9 +129,25 @@ MCP requests a capability's optional `toPresentation` result and lowers the port
77
129
 
78
130
  The canonical output remains available as the tool's structured content. This lets an agent inspect exact data while a client displays the richer view. See [Presentations](/concepts/presentations) for the surface-neutral API.
79
131
 
132
+ Modern MCP 2026-07-28 clients receive the canonical JSON value directly, so an
133
+ array output remains an array. For a legacy client, the MCP SDK wraps a
134
+ non-object value under `result` and projects the advertised output schema the
135
+ same way. Clients should follow the tool's `outputSchema` rather than assume
136
+ that every MCP protocol revision has the same envelope.
137
+
80
138
  ## Expose less than everything [#scope]
81
139
 
82
- Most apps should not offer their whole tree to an agent. Set `meta.mcp: false` on the capabilities that are never tools, and narrow a projected app with `selectApp()`.
140
+ Most apps should not offer their whole tree to an agent. Set `meta.mcp: false` on capabilities that are never tools. Use mount selection when one MCP endpoint should expose only part of the tree:
141
+
142
+ ```ts title="capable.server.ts"
143
+ mcp({ selection: { exclude: { admin: true } } });
144
+ ```
145
+
146
+ Selection paths are checked against the resolved App manifest. A misspelled or
147
+ stale path in either `include` or `exclude` fails discovery instead of silently
148
+ exposing a different tool set.
149
+
150
+ Use `selectApp()` when creating standalone tool descriptors without the mount:
83
151
 
84
152
  ```ts title="tools.ts"
85
153
  import { selectApp } from "capable-kit";
@@ -23,10 +23,10 @@ pnpm add capable-kit @tanstack/react-query
23
23
  import { createRemoteApp } from "capable-kit";
24
24
  import { createHttpTransport } from "capable-kit/http";
25
25
  import { createReactQuery } from "capable-kit/react-query";
26
- import type definition from "../capable.app";
26
+ import type { AppDefinition } from "../capable.app";
27
27
 
28
- const app = createRemoteApp<typeof definition>(
29
- createHttpTransport({ url: "/_capable/" }),
28
+ const app = createRemoteApp<AppDefinition>(
29
+ createHttpTransport({ url: "/~capable/" }),
30
30
  );
31
31
 
32
32
  export const query = createReactQuery(app);
@@ -26,10 +26,10 @@ pnpm add capable-kit swr
26
26
  import { createRemoteApp } from "capable-kit";
27
27
  import { createHttpTransport } from "capable-kit/http";
28
28
  import { createSWR } from "capable-kit/swr";
29
- import type definition from "../capable.app";
29
+ import type { AppDefinition } from "../capable.app";
30
30
 
31
- const app = createRemoteApp<typeof definition>(
32
- createHttpTransport({ url: "/_capable/" }),
31
+ const app = createRemoteApp<AppDefinition>(
32
+ createHttpTransport({ url: "/~capable/" }),
33
33
  );
34
34
 
35
35
  export const capableSWR = createSWR(app);
@@ -35,16 +35,16 @@ await app.todos.create({ title: "Write the docs" });
35
35
 
36
36
  ## Calling a remote app [#remote]
37
37
 
38
- [A remote app](/patterns/remote-apps) has the identical shape. The definition is imported as a _type_, so nothing from the server bundles into the caller and no client is generated.
38
+ [A remote app](/patterns/remote-apps) has the identical shape. Import the definition's named `AppDefinition` type, so nothing from the server bundles into the caller and no client is generated.
39
39
 
40
40
  ```ts title="client.ts"
41
41
  import { createRemoteApp } from "capable-kit";
42
42
  import { createHttpTransport } from "capable-kit/http";
43
- import type definition from "../server/capable.app";
43
+ import type { AppDefinition } from "../server/capable.app";
44
44
 
45
45
  // Same tree, same types, different placement.
46
- const app = createRemoteApp<typeof definition>(
47
- createHttpTransport({ url: "https://todos.example.com/_capable/" }),
46
+ const app = createRemoteApp<AppDefinition>(
47
+ createHttpTransport({ url: "https://todos.example.com/~capable/" }),
48
48
  );
49
49
 
50
50
  const todos = await app.todos.list({ status: "open" });
@@ -86,7 +86,7 @@ const todos = await app.todos.list({}, { signal: controller.signal });
86
86
 
87
87
  ## Streaming reads [#subscribe]
88
88
 
89
- When a capability defines [subscribe](/patterns/subscriptions), pass its call to `subscribe()` to get an async iterator instead of a single result. Calling it normally still returns one value.
89
+ When a capability defines [subscribe](/patterns/subscriptions), pass its reference to `subscribe()` to get an async iterator. A capability with a handler remains callable; a subscription-only event capability has no unary call signature.
90
90
 
91
91
  ```ts title="watch.ts"
92
92
  import { subscribe } from "capable-kit";
@@ -96,11 +96,11 @@ for await (const todos of subscribe(app.todos.list, { status: "open" })) {
96
96
  }
97
97
  ```
98
98
 
99
- > `subscribe()` takes the capability function itself, not its result, which is why it stays fully typed: `subscribe(app.todos.list, input)`.
99
+ > `subscribe()` takes the capability reference, not an invocation result, which is why it stays fully typed: `subscribe(app.todos.list, input)`.
100
100
 
101
101
  ## One capability without an app [#without-app]
102
102
 
103
- Tests and scripts sometimes want a single capability with no tree around it. `executeCapability()` runs it directly. Group middleware, group errors, and group metadata do not apply, because there is no group.
103
+ Tests and scripts sometimes want a single capability with no tree around it. `executeCapability()` runs it directly. App and group middleware and errors do not apply, because the call has no app or group. Group metadata also does not apply.
104
104
 
105
105
  ```ts title="list-todos.test.ts"
106
106
  import { executeCapability } from "capable-kit";
@@ -116,7 +116,7 @@ const todos = await executeCapability(listTodos, {
116
116
 
117
117
  | Not this | Instead |
118
118
  | --- | --- |
119
- | A generated SDK | Types come from a type-only import of the definition; the tree is a proxy built from the manifest. |
119
+ | A generated SDK | Types come from the named `AppDefinition` type; the tree is a proxy built from the manifest. |
120
120
  | A place for presentation | Titles, routes, and tool names belong to [surface metadata](/reference/metadata), not to the call. |
121
121
  | A cache or a UI binding | Use [React Query](/surfaces/react-query) for keys, caching, and live queries in a React app. |
122
122
 
@@ -23,7 +23,7 @@ import definition from "./capable.app";
23
23
  export default createServer(definition, {
24
24
  context: ({ request }) => contextFromRequest(request),
25
25
  mounts: [
26
- protocol({ path: "/_capable" }),
26
+ protocol(),
27
27
  http({ path: "/api", openapiPath: "/openapi.json" }),
28
28
  mcp({ path: "/mcp" }),
29
29
  ],
package/package-docs.mjs CHANGED
@@ -103,6 +103,9 @@ the npm package is packed. It matches the installed package version.
103
103
  Do not rely on remembered Capable APIs. Read the relevant bundled guide and
104
104
  inspect \`../src/\` when you need a detail the guides do not cover.
105
105
 
106
+ Before upgrading, read [the versioned changelog](../CHANGELOG.md). Apply all
107
+ entries after the installed version through the target version, oldest first.
108
+
106
109
  Start here:
107
110
 
108
111
  1. [Introduction](./site/introduction.mdx)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capable-kit",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.1.0-alpha.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "cap": "dist/bin.mjs",
@@ -65,15 +65,12 @@
65
65
  "prepare-package.mjs",
66
66
  "src",
67
67
  "verify-package-exports.mjs",
68
- "README.md"
68
+ "README.md",
69
+ "CHANGELOG.md"
69
70
  ],
70
71
  "directories": {
71
72
  "doc": "./docs"
72
73
  },
73
- "scripts": {
74
- "prepack": "node prepare-package.mjs",
75
- "postpack": "node package-docs.mjs --clean"
76
- },
77
74
  "engines": {
78
75
  "node": ">=20"
79
76
  },
@@ -85,12 +82,14 @@
85
82
  "@standard-schema/spec": "^1.1.0",
86
83
  "@modelcontextprotocol/server": "^2.0.0",
87
84
  "markdansi": "0.3.2",
88
- "nitro": "3.0.260610-beta"
85
+ "nitro": "3.0.260610-beta",
86
+ "superjson": "2.2.6",
87
+ "zod": "^4.4.3"
89
88
  },
90
89
  "peerDependencies": {
91
90
  "@tanstack/react-query": ">=5.80.2 <6",
92
- "ai": "^7.0.0",
93
- "eve": ">=0.27.1",
91
+ "ai": "^7.0.82",
92
+ "eve": "0.52.3",
94
93
  "swr": ">=2.3.0 <3"
95
94
  },
96
95
  "peerDependenciesMeta": {
@@ -106,5 +105,6 @@
106
105
  "swr": {
107
106
  "optional": true
108
107
  }
109
- }
110
- }
108
+ },
109
+ "scripts": {}
110
+ }
package/src/bin.ts CHANGED
File without changes
package/src/index.test.ts CHANGED
@@ -29,14 +29,15 @@ describe("capable public entry points", () => {
29
29
  test("keeps the root focused on authoring and App composition", () => {
30
30
  expect(Object.keys(capable).sort()).toEqual([
31
31
  "capability",
32
+ "composeApps",
32
33
  "createApp",
33
34
  "createRemoteApp",
35
+ "customize",
34
36
  "defineApp",
35
37
  "defineErrors",
36
38
  "executeCapability",
37
39
  "group",
38
40
  "md",
39
- "mergeApps",
40
41
  "present",
41
42
  "selectApp",
42
43
  "subscribe",
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ export {
18
18
  type CapabilityDefinition,
19
19
  type CapabilityContext,
20
20
  type CapabilityEffect,
21
+ type CapabilityExecution,
21
22
  type CapabilityFactory,
22
23
  type CapabilityHandlerArgs,
23
24
  type CapabilityInput,
@@ -32,11 +33,15 @@ export {
32
33
  export {
33
34
  createApp,
34
35
  createRemoteApp,
35
- mergeApps,
36
+ composeApps,
37
+ customize,
38
+ type CapabilityCustomization,
39
+ type CustomizedCapability,
36
40
  selectApp,
37
41
  subscribe,
38
42
  type ApplicationSelection,
39
43
  type App,
40
44
  type AppContextProvider,
41
45
  type AppCapabilityCall,
46
+ type AppCapabilityReference,
42
47
  } from "@capable/app";
package/src/mcp.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  export * from "@capable/mcp";
2
2
  export { mcp } from "@capable/mcp/mount";
3
+ export type {
4
+ McpCacheHint,
5
+ McpMountOptions,
6
+ } from "@capable/mcp/mount";
@@ -35,6 +35,15 @@ describe("published package", () => {
35
35
  encoding: "utf8",
36
36
  },
37
37
  );
38
+ // Compile against built declarations without monorepo path aliases. This
39
+ // catches metadata augmentations lost while bundling private packages.
40
+ for (const fixture of ["customization", "customization-no-surface"]) {
41
+ execFileSync(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
42
+ "exec", "tsc", "--ignoreConfig", "--noEmit", "--strict", "--skipLibCheck",
43
+ "--target", "es2022", "--module", "nodenext",
44
+ join(packageDirectory, `fixtures/${fixture}.mts`),
45
+ ], { cwd: packageDirectory, encoding: "utf8" });
46
+ }
38
47
  const result = findPackResult(JSON.parse(output));
39
48
  const paths = new Set(result.files.map((file) => file.path));
40
49
  const archive = join(destination, result.filename);
@@ -1,178 +0,0 @@
1
- import { y as renderPresentationMarkdown } from "./src-DdV82An-.mjs";
2
- import { a as TransportError, c as getAppRuntime, o as createApp } from "./src-C2MGIlT0.mjs";
3
- import { Server, createMcpHandler } from "@modelcontextprotocol/server";
4
- //#region packages/mcp/src/index.ts
5
- async function createMcp(app) {
6
- const runtime = getAppRuntime(app);
7
- const tools = flatten((await runtime.manifest()).capabilities).filter((capability) => capability.meta.mcp !== false).map((capability) => {
8
- const meta = capability.meta.mcp;
9
- return Object.freeze({
10
- name: meta?.name ?? capability.path.join("__"),
11
- ...capability.title ? { title: capability.title } : {},
12
- ...capability.description ? { description: capability.description } : {},
13
- inputSchema: capability.input ?? {
14
- type: "object",
15
- properties: {},
16
- additionalProperties: false
17
- },
18
- ...capability.output ? { outputSchema: mcpOutputSchema(capability.output) } : {},
19
- annotations: {
20
- readOnlyHint: capability.effect === "read",
21
- destructiveHint: capability.effect === "destructive"
22
- },
23
- call(input, options) {
24
- return runtime.call({
25
- id: capability.id,
26
- input,
27
- presentation: true,
28
- ...options?.signal ? { signal: options.signal } : {}
29
- });
30
- }
31
- });
32
- });
33
- const names = /* @__PURE__ */ new Set();
34
- for (const tool of tools) {
35
- if (names.has(tool.name)) throw new Error(`Duplicate MCP tool name "${tool.name}"`);
36
- names.add(tool.name);
37
- }
38
- return tools;
39
- }
40
- function mcpOutputSchema(schema) {
41
- if (schema.type === "object") return schema;
42
- return {
43
- type: "object",
44
- properties: { value: schema },
45
- required: ["value"],
46
- additionalProperties: false
47
- };
48
- }
49
- function flatten(nodes) {
50
- return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
51
- }
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
101
- //#region packages/mcp/src/mount.ts
102
- function mcp(options = {}) {
103
- const path = normalizePath(options.path ?? "/mcp");
104
- return {
105
- kind: "capable.server.mount",
106
- compile(app, context) {
107
- const handler = createMcpHandler(async ({ requestInfo }) => {
108
- if (!requestInfo) throw new Error("The MCP HTTP handler requires request information");
109
- return createMcpServer(await createMcp(createApp(app, context ? { context: () => context({ request: requestInfo }) } : void 0)), {
110
- name: options.name ?? app.name ?? "capable",
111
- version: options.version ?? app.version ?? "0.0.0"
112
- });
113
- }, { legacy: "stateless" });
114
- return {
115
- name: "mcp",
116
- async fetch(request) {
117
- if (new URL(request.url).pathname !== path) return void 0;
118
- return handler.fetch(request);
119
- }
120
- };
121
- }
122
- };
123
- }
124
- function createMcpServer(tools, info) {
125
- const server = new Server(info, { capabilities: { tools: {} } });
126
- server.setRequestHandler("tools/list", () => ({ tools: tools.map(toProtocolTool) }));
127
- server.setRequestHandler("tools/call", async (request, context) => {
128
- const tool = tools.find(({ name }) => name === request.params.name);
129
- if (!tool) return toolError(`Unknown tool "${request.params.name}"`);
130
- try {
131
- const result = await tool.call(request.params.arguments ?? {}, { signal: context.mcpReq.signal });
132
- return {
133
- content: toMcpContent(result.presentation, result.output),
134
- structuredContent: isRecord(result.output) ? result.output : { value: result.output }
135
- };
136
- } catch (error) {
137
- if (!(error instanceof TransportError)) throw error;
138
- return toolError(error.message, {
139
- code: error.code,
140
- status: error.status,
141
- data: error.data
142
- });
143
- }
144
- });
145
- return server;
146
- }
147
- function toProtocolTool(tool) {
148
- return {
149
- name: tool.name,
150
- ...tool.title ? { title: tool.title } : {},
151
- ...tool.description ? { description: tool.description } : {},
152
- inputSchema: tool.inputSchema,
153
- ...tool.outputSchema ? { outputSchema: tool.outputSchema } : {},
154
- annotations: tool.annotations
155
- };
156
- }
157
- function toolError(message, details) {
158
- return {
159
- isError: true,
160
- content: [{
161
- type: "text",
162
- text: details ? JSON.stringify({
163
- message,
164
- ...details
165
- }) : message
166
- }]
167
- };
168
- }
169
- function normalizePath(value) {
170
- return `/${value.split("/").filter(Boolean).join("/")}`;
171
- }
172
- function isRecord(value) {
173
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
174
- }
175
- //#endregion
176
- export { createMcp as n, mcp as t };
177
-
178
- //# sourceMappingURL=mount-xvMsjz1B.mjs.map