capable-kit 0.0.1-alpha.8 → 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 +108 -0
- package/README.md +6 -0
- package/dist/ai-sdk.d.mts +2 -2
- package/dist/ai-sdk.mjs +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 +4 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +82 -5
- package/dist/eve.mjs +358 -19
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-F4ba_olD.d.mts → index-D63DSGZG.d.mts} +10 -5
- package/dist/{index-Dl4NK9G0.d.mts → index-D8DWjQ9f.d.mts} +3 -3
- package/dist/{index-hdH_K5Zc.d.mts → index-DgxvtAmv.d.mts} +4 -4
- package/dist/{index-_qKFfWV4.d.mts → index-ftQx6OMr.d.mts} +23 -13
- 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-CEFAplR5.mjs → mount-B9TrHWHh.mjs} +3 -3
- package/dist/{mount-CEFAplR5.mjs.map → mount-B9TrHWHh.mjs.map} +1 -1
- package/dist/react-query.d.mts +1 -1
- package/dist/react-query.mjs +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +3 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-betOfnDL.mjs → src-B592M-6b.mjs} +143 -44
- package/dist/src-B592M-6b.mjs.map +1 -0
- package/dist/{src-D-cm2gQ6.mjs → src-Bd1Vnze8.mjs} +16 -2
- package/dist/src-Bd1Vnze8.mjs.map +1 -0
- package/dist/{src-BWxDO2Ua.mjs → src-CKC1BdXO.mjs} +3 -3
- package/dist/{src-BWxDO2Ua.mjs.map → src-CKC1BdXO.mjs.map} +1 -1
- package/dist/{src-D_0PIhqq.mjs → src-CL9eA6_p.mjs} +42 -25
- package/dist/src-CL9eA6_p.mjs.map +1 -0
- package/dist/{src-rkr5j_NH.mjs → src-Hw9WBgEW.mjs} +3 -3
- package/dist/{src-rkr5j_NH.mjs.map → src-Hw9WBgEW.mjs.map} +1 -1
- package/dist/{subscription-B-auXJbm.d.mts → subscription-DbnHcm7C.d.mts} +2 -2
- package/dist/swr.d.mts +1 -1
- package/dist/swr.mjs +1 -1
- package/docs/CONTEXT.md +17 -10
- package/docs/README.md +3 -0
- package/docs/internal/README.md +3 -0
- package/docs/internal/adr/0001-capability-is-the-semantic-boundary.md +1 -1
- package/docs/internal/architecture.md +11 -10
- package/docs/internal/capability-first-model.md +31 -8
- package/docs/internal/eve-recovery-validation.md +86 -0
- package/docs/internal/feedback/v-ray/README.md +258 -0
- package/docs/internal/feedback/v-ray/inference.mjs +43 -0
- package/docs/internal/feedback/v-ray/reproduce.mjs +36 -0
- package/docs/internal/implementation-friction.md +301 -1
- package/docs/internal/releases.md +79 -0
- package/docs/site/capable-orpc-and-trpc.mdx +2 -2
- package/docs/site/concepts/apps.mdx +6 -0
- package/docs/site/concepts/architecture.mdx +1 -1
- package/docs/site/concepts/capabilities.mdx +39 -2
- package/docs/site/concepts/errors.mdx +11 -1
- package/docs/site/concepts/presentations.mdx +16 -0
- package/docs/site/patterns/composition.mdx +50 -8
- package/docs/site/patterns/remote-apps.mdx +1 -1
- package/docs/site/quickstart.mdx +1 -1
- package/docs/site/reference/packages-and-entry-points.mdx +11 -3
- package/docs/site/surfaces/cli.mdx +33 -0
- package/docs/site/surfaces/eve.mdx +65 -18
- package/docs/site/surfaces/typescript.mdx +1 -1
- package/package-docs.mjs +3 -0
- package/package.json +10 -11
- package/src/bin.ts +0 -0
- package/src/index.test.ts +1 -1
- package/src/index.ts +1 -1
- package/dist/src-D-cm2gQ6.mjs.map +0 -1
- package/dist/src-D_0PIhqq.mjs.map +0 -1
- package/dist/src-betOfnDL.mjs.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Releases
|
|
2
|
+
|
|
3
|
+
`capable-kit` is the public release unit. Private workspace packages are bundled
|
|
4
|
+
into it; changes to their public behavior need a changeset for `capable-kit`.
|
|
5
|
+
|
|
6
|
+
## Record a change
|
|
7
|
+
|
|
8
|
+
Run `pnpm changeset`, or write a uniquely named Markdown file under `.changeset/`:
|
|
9
|
+
|
|
10
|
+
````md
|
|
11
|
+
---
|
|
12
|
+
"capable-kit": patch
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Added a versioned changelog to the installed package. Read
|
|
16
|
+
`node_modules/capable-kit/CHANGELOG.md` before upgrading.
|
|
17
|
+
````
|
|
18
|
+
|
|
19
|
+
Use `patch` for fixes and documentation, and `minor` for features. While the
|
|
20
|
+
stable base is 0.x, also use `minor` for breaking changes and explicitly label
|
|
21
|
+
these **Breaking**. Include before/after code, affected entry points, and any
|
|
22
|
+
behavior or configuration changes. Never infer compatibility from alpha numbers.
|
|
23
|
+
Internal-only changes do not require a changeset.
|
|
24
|
+
|
|
25
|
+
## Prepare and publish an alpha
|
|
26
|
+
|
|
27
|
+
The repository is in Changesets prerelease mode with the `alpha` tag. Keep
|
|
28
|
+
`.changeset/pre.json` and `.changeset/pre/` committed: these preserve prerelease
|
|
29
|
+
mode and entries already included in alpha releases.
|
|
30
|
+
Do not re-enter prerelease mode for each release.
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pnpm changeset status
|
|
34
|
+
pnpm release:version
|
|
35
|
+
pnpm install --lockfile-only
|
|
36
|
+
pnpm check
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Review and commit the changed package version, lockfile, changelog, and Changesets
|
|
40
|
+
state together. The next version is calculated from the pending bump types and
|
|
41
|
+
prerelease state; do not assume it will simply increment the existing alpha suffix.
|
|
42
|
+
|
|
43
|
+
When ready to publish from that reviewed commit:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pnpm release:publish
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This validates the repository and publishes unpublished public packages. While
|
|
50
|
+
all published versions are alphas and `latest` already exists, Changesets 3
|
|
51
|
+
publishes to `latest`. This is intentional: the current alpha is the default
|
|
52
|
+
installation while there is no stable release. After a stable release exists,
|
|
53
|
+
prerelease mode uses the `alpha` dist-tag. Review the publish plan when that
|
|
54
|
+
transition happens. Package prepack also rebuilds and
|
|
55
|
+
verifies the exported files and bundles documentation. Publishing needs npm
|
|
56
|
+
credentials. Push the release commit and generated tags after a successful release.
|
|
57
|
+
Changesets does not create GitHub Releases with this setup.
|
|
58
|
+
|
|
59
|
+
To leave alpha, run `pnpm exec changeset pre exit`, then follow the version/review
|
|
60
|
+
steps above. Review the resulting stable version and dist-tag before publishing.
|
|
61
|
+
|
|
62
|
+
## Find changes as a consumer or agent
|
|
63
|
+
|
|
64
|
+
Read `node_modules/capable-kit/CHANGELOG.md` for the installed version's release
|
|
65
|
+
history. When upgrading, read the target version's changelog and apply entries
|
|
66
|
+
newer than the installed version through the target version, oldest first.
|
|
67
|
+
Use exact versions from the lockfile, not only the range in `package.json`.
|
|
68
|
+
|
|
69
|
+
The same canonical changelog is linked from the website's package reference.
|
|
70
|
+
Repository main may contain newer releases than a locally installed package.
|
|
71
|
+
Release history starts with this setup; older alpha changes are not reconstructed.
|
|
72
|
+
|
|
73
|
+
## Initial release-note backfill
|
|
74
|
+
|
|
75
|
+
The initial pending notes cover user-facing changes after published
|
|
76
|
+
`0.0.1-alpha.8`, using release commit `69941bd` as the baseline. The npm
|
|
77
|
+
package's Eve, MCP, app-composition, and CLI source-map contents were checked
|
|
78
|
+
against that commit. Notes cover changes through `b8fada3` from main, plus the
|
|
79
|
+
Changesets setup. Already-shipped alpha.8 features are not listed as new.
|
|
@@ -83,11 +83,11 @@ import {
|
|
|
83
83
|
createApp,
|
|
84
84
|
createEveTools,
|
|
85
85
|
createRemoteApp,
|
|
86
|
-
|
|
86
|
+
composeApps,
|
|
87
87
|
} from "capable-kit";
|
|
88
88
|
|
|
89
89
|
const supportApp = createRemoteApp<typeof support>(supportTransport);
|
|
90
|
-
const app =
|
|
90
|
+
const app = composeApps(
|
|
91
91
|
supportApp,
|
|
92
92
|
createApp(localDefinition, {
|
|
93
93
|
context: createLocalContext,
|
|
@@ -180,6 +180,12 @@ The provider runs per call, so it can read a request-scoped session, open a tran
|
|
|
180
180
|
|
|
181
181
|
## Give one branch a different policy [#decorate]
|
|
182
182
|
|
|
183
|
+
Use `defineApp({ capabilities, middleware: [authorizeCapability], errors: AccessErrors })`
|
|
184
|
+
for policy shared by the whole app. App middleware runs before group and capability
|
|
185
|
+
middleware for both local and remote invocations executed by that definition.
|
|
186
|
+
See [Capability middleware](/concepts/capabilities#middleware) for the identity
|
|
187
|
+
arguments and a complete example.
|
|
188
|
+
|
|
183
189
|
A `group()` is useful when one branch needs shared behaviour that would be wrong for the rest of the app. Here the catalog stays public, while everything under `account` requires an authenticated user. Define the decorated subtree separately so the app remains a simple composition.
|
|
184
190
|
|
|
185
191
|
```ts title="capable.app.ts"
|
|
@@ -35,7 +35,7 @@ defineApp() a named tree of capabilities
|
|
|
35
35
|
| +-- { context } only when declared
|
|
36
36
|
+-- createRemoteApp(transport) lazy remote placement
|
|
37
37
|
|
|
|
38
|
-
|
|
38
|
+
composeApps() / selectApp() one typed app
|
|
39
39
|
|
|
|
40
40
|
+-- app.todos.list({}) direct call
|
|
41
41
|
+-- createCli(app) commands
|
|
@@ -145,6 +145,43 @@ export const listTodos = todoCapability({
|
|
|
145
145
|
|
|
146
146
|
Put middleware on a `group()` when several capabilities in one branch share the policy and the rest of the app does not.
|
|
147
147
|
|
|
148
|
+
Put middleware on `defineApp()` to apply it to every capability in that app.
|
|
149
|
+
All three scopes receive a readonly `capability` descriptor containing the
|
|
150
|
+
authored `id` and optional `effect`, plus `mode: "call" | "subscribe"`.
|
|
151
|
+
The ID stays the same when a capability moves to another application path.
|
|
152
|
+
An omitted effect remains `undefined`.
|
|
153
|
+
|
|
154
|
+
```ts title="capable.app.ts"
|
|
155
|
+
const AccessErrors = defineErrors({
|
|
156
|
+
FORBIDDEN: { status: 403, message: "Access denied" },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const definition = defineApp({
|
|
160
|
+
capabilities: { todos },
|
|
161
|
+
errors: AccessErrors,
|
|
162
|
+
middleware: [async ({ capability, mode, context, next }) => {
|
|
163
|
+
if (!await canCall(context.user, capability.id)) {
|
|
164
|
+
throw AccessErrors.FORBIDDEN();
|
|
165
|
+
}
|
|
166
|
+
console.info({ capabilityId: capability.id, mode });
|
|
167
|
+
return next();
|
|
168
|
+
}],
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
App middleware uses the Context required by the app's capabilities. It does
|
|
173
|
+
not add or narrow Context fields. Declare capabilities separately, then
|
|
174
|
+
compose them into the app so TypeScript can infer that Context before typing
|
|
175
|
+
the middleware. Input is parsed before middleware runs; at app and group
|
|
176
|
+
scope it is typed as `unknown`, because each capability can have a different
|
|
177
|
+
input schema. Middleware receives identity, not the handler or internal
|
|
178
|
+
capability definition.
|
|
179
|
+
|
|
180
|
+
The order is app middleware, outer-to-inner group middleware, capability
|
|
181
|
+
middleware, then the handler. Return values unwind in reverse order.
|
|
182
|
+
Subscriptions use the same chain for the complete subscription lifetime.
|
|
183
|
+
Middleware does not see input-validation failures or Context-provider failures.
|
|
184
|
+
|
|
148
185
|
## Describe each surface with metadata [#metadata]
|
|
149
186
|
|
|
150
187
|
App paths give every surface enough information to derive routes, commands, and tool names. Add `meta` when a surface needs details that the capability itself cannot express.
|
|
@@ -187,7 +224,7 @@ Only surfaces that need a presentation ask the runtime to produce it. The CLI re
|
|
|
187
224
|
Once these pieces are present, every caller enters the same lifecycle. A surface only translates its own transport into an input object.
|
|
188
225
|
|
|
189
226
|
1. **Parse input.** The input schema runs once.
|
|
190
|
-
2. **Run middleware.**
|
|
227
|
+
2. **Run middleware.** App middleware runs outermost, followed by outer-to-inner group middleware and capability middleware, in declaration order.
|
|
191
228
|
3. **Run the handler.** It receives `{ input, context, signal }`.
|
|
192
229
|
4. **Normalize errors.** Declared errors keep their contract; unexpected failures become `INTERNAL_SERVER_ERROR`.
|
|
193
230
|
5. **Validate output.** The optional output schema runs before the canonical result is returned.
|
|
@@ -206,7 +243,7 @@ const todo = await executeCapability(getTodo, {
|
|
|
206
243
|
});
|
|
207
244
|
```
|
|
208
245
|
|
|
209
|
-
Direct execution applies the capability's own validation, middleware, and declared errors. Middleware and errors contributed by
|
|
246
|
+
Direct execution applies the capability's own validation, middleware, and declared errors. Middleware and errors contributed by an app or group only exist when the capability is executed through the app tree that contains it. A handler that requires a user must check that requirement itself if it can also be executed directly; a check in group middleware does not narrow the handler's Context type.
|
|
210
247
|
|
|
211
248
|
## Put it all together [#complete]
|
|
212
249
|
|
|
@@ -88,6 +88,16 @@ const todos = group({
|
|
|
88
88
|
});
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
An app can contribute errors to every capability, including failures from app-wide middleware:
|
|
92
|
+
|
|
93
|
+
```ts title="capable.app.ts"
|
|
94
|
+
const definition = defineApp({
|
|
95
|
+
capabilities: { todos },
|
|
96
|
+
errors: AccessErrors,
|
|
97
|
+
middleware: [authorizeCapability],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
An app, its nested groups, and a capability may not redeclare an inherited error code. The conflict is reported when the app definition is created, not at call time. Inherited errors appear on each affected capability in the manifest and OpenAPI. Standalone `executeCapability()` calls only use errors declared on that capability.
|
|
92
102
|
|
|
93
103
|
</DocsPage>
|
|
@@ -34,6 +34,22 @@ export const getWeather = capability({
|
|
|
34
34
|
|
|
35
35
|
Typed calls still receive `{ city, temperature }`. The string is only produced when a presentation-aware surface asks for it.
|
|
36
36
|
|
|
37
|
+
A typed named renderer can appear before or after `handler`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const presentWeather = (weather: { city: string; temperature: number }) =>
|
|
41
|
+
`${weather.city}: ${weather.temperature}°C`;
|
|
42
|
+
|
|
43
|
+
capability({
|
|
44
|
+
id: "weather.get",
|
|
45
|
+
toPresentation: presentWeather,
|
|
46
|
+
handler: () => ({ city: "Vienna", temperature: 24 }),
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
When using an inline renderer with an inferred parameter, keep it after
|
|
51
|
+
`handler` so TypeScript can infer the result first.
|
|
52
|
+
|
|
37
53
|
## Compose richer output [#parts]
|
|
38
54
|
|
|
39
55
|
`toPresentation` may also return one part or an ordered array of strings and parts. Import the builders from the same root entry point:
|
|
@@ -80,21 +80,26 @@ export const local = createApp(localDefinition, {
|
|
|
80
80
|
});
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
Both definitions
|
|
83
|
+
Both definitions contribute named capabilities under the same `todos` path.
|
|
84
|
+
When the Apps are composed, those branches combine: `todos list` and
|
|
85
|
+
`todos create` run on the server, while `todos import` runs here.
|
|
84
86
|
|
|
85
|
-
##
|
|
87
|
+
## Compose them into one CLI [#compose]
|
|
86
88
|
|
|
87
|
-
`
|
|
89
|
+
`composeApps()` combines the two apps into one. App arguments contribute their
|
|
90
|
+
trees at the root, so the two `todos` branches become one. Calls dispatch by
|
|
91
|
+
capability id to whichever app owns them. No proxy server, no logic moved — the
|
|
92
|
+
import runs in this process, the creates run on the server.
|
|
88
93
|
|
|
89
94
|
```ts title="cli.ts"
|
|
90
|
-
import {
|
|
95
|
+
import { composeApps } from "capable-kit";
|
|
91
96
|
import { createCli } from "capable-kit/cli";
|
|
92
97
|
import { remote } from "./remote";
|
|
93
98
|
import { local } from "./local";
|
|
94
99
|
|
|
95
100
|
// One command tree. Calls dispatch by capability id to whichever
|
|
96
101
|
// app owns them — the server for list and create, this process for import.
|
|
97
|
-
const app =
|
|
102
|
+
const app = composeApps(remote, local);
|
|
98
103
|
|
|
99
104
|
process.exit(
|
|
100
105
|
await createCli(app, { invocationName: "mycli" }).run(process.argv.slice(2)),
|
|
@@ -118,15 +123,52 @@ mycli todos import ./todos.txt
|
|
|
118
123
|
# { "imported": 2 }
|
|
119
124
|
```
|
|
120
125
|
|
|
121
|
-
Path collisions, duplicate ids, and leaf/subtree conflicts fail when the
|
|
126
|
+
Path collisions, duplicate ids, and leaf/subtree conflicts fail when the
|
|
127
|
+
composed manifest first resolves, not at call time.
|
|
128
|
+
|
|
129
|
+
Object keys place an App beneath a navigational branch. This is useful for
|
|
130
|
+
external Apps that should keep a visible namespace:
|
|
131
|
+
|
|
132
|
+
```ts title="integrations.ts"
|
|
133
|
+
const app = composeApps(local, {
|
|
134
|
+
deepwiki,
|
|
135
|
+
integrations: {
|
|
136
|
+
linear,
|
|
137
|
+
github,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
await app.deepwiki.search({ query: "routing" });
|
|
142
|
+
await app.integrations.linear.issue({ id: "CAP-1" });
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The object shape is the resulting callable tree. Namespacing changes application
|
|
146
|
+
paths, not Capability IDs or where execution happens. A direct call beneath one
|
|
147
|
+
namespace discovers only that branch; complete-manifest surfaces such as CLI
|
|
148
|
+
still discover and validate the entire composition.
|
|
149
|
+
|
|
150
|
+
The same App may deliberately appear at more than one path:
|
|
151
|
+
|
|
152
|
+
```ts title="aliases.ts"
|
|
153
|
+
const app = composeApps({
|
|
154
|
+
internal: todos,
|
|
155
|
+
public: todos,
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Those paths are aliases backed by one execution owner. Repeating the same App at
|
|
160
|
+
the same path is deduplicated. Two different Apps may not claim the same
|
|
161
|
+
Capability ID, even when their manifests happen to look identical.
|
|
122
162
|
|
|
123
163
|
> **Placement stays explicit**
|
|
124
164
|
>
|
|
125
|
-
>
|
|
165
|
+
> Composition makes calling uniform, not location-transparent. Each capability
|
|
166
|
+
> still executes where it was created — behind the server's context and policy,
|
|
167
|
+
> or in this process. The CLI does not hide which is which; the source code does.
|
|
126
168
|
|
|
127
169
|
## Narrow what a surface sees [#select]
|
|
128
170
|
|
|
129
|
-
The same
|
|
171
|
+
The same composed tree can feed more than one surface. Before handing it to an agent, narrow it with `selectApp()`. An omitted `include` means everything; `exclude` wins.
|
|
130
172
|
|
|
131
173
|
```ts title="agent-surface.ts"
|
|
132
174
|
import { selectApp } from "capable-kit";
|
|
@@ -166,6 +166,6 @@ Calling is uniform; placement is still a decision you make in source. A remote c
|
|
|
166
166
|
| It needs to work offline or without a server | It enforces authorization the client must not be trusted with |
|
|
167
167
|
| Latency per call matters more than trust | The implementation must not ship to the caller |
|
|
168
168
|
|
|
169
|
-
When one process needs both,
|
|
169
|
+
When one process needs both, compose them: [composition](/patterns/composition) combines a remote app and a local app into a single tree that dispatches each call to whichever app owns it.
|
|
170
170
|
|
|
171
171
|
</DocsPage>
|
package/docs/site/quickstart.mdx
CHANGED
|
@@ -205,7 +205,7 @@ Capable works two ways: as its own service, or embedded in an app you already ha
|
|
|
205
205
|
|
|
206
206
|
> **Remote apps are apps**
|
|
207
207
|
>
|
|
208
|
-
> A remote app can be
|
|
208
|
+
> A remote app can be combined with a local one using `composeApps()`, so one command tree can mix capabilities that run on the server with capabilities that must run here. See [Composition](/patterns/composition).
|
|
209
209
|
|
|
210
210
|
8. ### Build for production
|
|
211
211
|
|
|
@@ -11,6 +11,14 @@ export const metadata = docMetadata("/reference/packages", frontmatter);
|
|
|
11
11
|
|
|
12
12
|
Entry points are explicit so that a server mount, a UI projection, or an agent integration never gets pulled into an application that does not use it.
|
|
13
13
|
|
|
14
|
+
## Changes and upgrades [#changes]
|
|
15
|
+
|
|
16
|
+
Read the [versioned changelog](https://github.com/vercel-labs/capable/blob/main/packages/capable/CHANGELOG.md)
|
|
17
|
+
for features, fixes, and breaking changes. It also ships at
|
|
18
|
+
`node_modules/capable-kit/CHANGELOG.md`. When upgrading, read the target version’s
|
|
19
|
+
changelog and apply entries after your installed version through your target
|
|
20
|
+
version, oldest first. Repository main may be ahead of your installed version.
|
|
21
|
+
|
|
14
22
|
## The root entry point [#root]
|
|
15
23
|
|
|
16
24
|
`capable-kit` is deliberately limited to authoring and composing apps. Everything you need to define capabilities lives here.
|
|
@@ -26,7 +34,7 @@ import {
|
|
|
26
34
|
watchQuery, // snapshot + invalidation subscriber
|
|
27
35
|
createApp, // definition + context -> callable app
|
|
28
36
|
createRemoteApp, // transport + definition type -> callable app
|
|
29
|
-
|
|
37
|
+
composeApps, // combine and place apps
|
|
30
38
|
selectApp, // narrow an app
|
|
31
39
|
subscribe, // iterate replacements
|
|
32
40
|
executeCapability, // run one capability without an app
|
|
@@ -60,11 +68,11 @@ import {
|
|
|
60
68
|
| --- | --- | --- |
|
|
61
69
|
| `capability()` | `capability(config)` | `capability<Context>()` or `capability.withContext<Context>()` binds a context type |
|
|
62
70
|
| `present` | `present.table(), .image(), .file()` | Portable presentation parts for `toPresentation` |
|
|
63
|
-
| `defineApp()` | `defineApp({ name, version, capabilities })` | Immutable definition, no context |
|
|
71
|
+
| `defineApp()` | `defineApp({ name, version, capabilities, middleware, errors })` | Immutable definition, no context |
|
|
64
72
|
| `group()` | `group({ middleware, errors, meta, capabilities })` | Anonymous decorated subtree |
|
|
65
73
|
| `createApp()` | `createApp(definition)` | Callable tree; context options exist only when declared |
|
|
66
74
|
| `createRemoteApp()` | `createRemoteApp<AppDefinition>(transport)` | Lazy, transport-backed remote placement |
|
|
67
|
-
| `
|
|
75
|
+
| `composeApps()` | `composeApps(a, { namespace: b })` | Root composition and tree-shaped placement, dispatch by id |
|
|
68
76
|
| `selectApp()` | `selectApp(app, { include, exclude })` | Exclude wins over include |
|
|
69
77
|
| `subscribe()` | `subscribe(app.todos.list, input, { signal })` | Async iterator of replacements |
|
|
70
78
|
| `executeCapability()` | `executeCapability(capability, { input, context, signal })` | No app tree, no group behaviour |
|
|
@@ -52,6 +52,39 @@ todo --help
|
|
|
52
52
|
|
|
53
53
|
`run()` resolves to an exit code: `0` on success, `1` for a failed capability, and `2` for a usage error.
|
|
54
54
|
|
|
55
|
+
For a single-operation CLI, map the Capability to an empty command path:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
capability({
|
|
59
|
+
id: "analysis.url",
|
|
60
|
+
input: z.object({ url: z.string() }),
|
|
61
|
+
meta: { cli: { command: [], positional: ["url"] } },
|
|
62
|
+
handler: ({ input }) => analyzeURL(input.url),
|
|
63
|
+
});
|
|
64
|
+
// pnpm cli vercel.com
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Bare invocation and `--help` keep the app name and command listing, with the root
|
|
68
|
+
Capability's arguments and options underneath. `--json`
|
|
69
|
+
or `--watch` selects execution even without positional arguments, applying schema
|
|
70
|
+
defaults or reporting missing required input. Only one Capability may map to the
|
|
71
|
+
root; longer subcommands still take precedence.
|
|
72
|
+
|
|
73
|
+
Pass markdansi's `RenderOptions` directly through `markdown` to customize terminal
|
|
74
|
+
presentations:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
createCli(app, {
|
|
78
|
+
invocationName: "pnpm cli",
|
|
79
|
+
markdown: { codeBox: false, tableBorder: "none", tableDense: true },
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
These options are forwarded unchanged for ordinary and watched presentations in
|
|
84
|
+
a TTY. `markdown.color` and `markdown.width`, when supplied, override the CLI's
|
|
85
|
+
color and columns defaults for presentation rendering. Redirected output remains
|
|
86
|
+
Markdown, and `--json` returns canonical output.
|
|
87
|
+
|
|
55
88
|
## How commands are derived [#mapping]
|
|
56
89
|
|
|
57
90
|
| Authored | Becomes |
|
|
@@ -13,18 +13,12 @@ export const metadata = docMetadata("/surfaces/eve", frontmatter);
|
|
|
13
13
|
|
|
14
14
|
## Start in-process [#local]
|
|
15
15
|
|
|
16
|
-
|
|
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
|
|
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) =>
|
|
@@ -63,18 +57,20 @@ The standalone server exposes the Capable transport at `/~capable/`. Its manifes
|
|
|
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="
|
|
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 {
|
|
71
|
-
import type { AppDefinition } from "../../capable.app";
|
|
63
|
+
import type { AppDefinition } from "./capable.app";
|
|
72
64
|
|
|
73
|
-
const app = createRemoteApp<AppDefinition>(
|
|
74
|
-
|
|
75
|
-
|
|
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) =>
|
|
@@ -112,10 +108,61 @@ meta: {
|
|
|
112
108
|
|
|
113
109
|
## Durability [#durability]
|
|
114
110
|
|
|
115
|
-
The tool
|
|
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>
|
|
@@ -100,7 +100,7 @@ for await (const todos of subscribe(app.todos.list, { status: "open" })) {
|
|
|
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.
|
|
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";
|
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
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
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
|
},
|
|
@@ -86,12 +83,13 @@
|
|
|
86
83
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
87
84
|
"markdansi": "0.3.2",
|
|
88
85
|
"nitro": "3.0.260610-beta",
|
|
89
|
-
"superjson": "2.2.6"
|
|
86
|
+
"superjson": "2.2.6",
|
|
87
|
+
"zod": "^4.4.3"
|
|
90
88
|
},
|
|
91
89
|
"peerDependencies": {
|
|
92
90
|
"@tanstack/react-query": ">=5.80.2 <6",
|
|
93
|
-
"ai": "^7.0.
|
|
94
|
-
"eve": "
|
|
91
|
+
"ai": "^7.0.82",
|
|
92
|
+
"eve": "0.52.3",
|
|
95
93
|
"swr": ">=2.3.0 <3"
|
|
96
94
|
},
|
|
97
95
|
"peerDependenciesMeta": {
|
|
@@ -107,5 +105,6 @@
|
|
|
107
105
|
"swr": {
|
|
108
106
|
"optional": true
|
|
109
107
|
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
108
|
+
},
|
|
109
|
+
"scripts": {}
|
|
110
|
+
}
|
package/src/bin.ts
CHANGED
|
File without changes
|
package/src/index.test.ts
CHANGED
|
@@ -29,6 +29,7 @@ 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",
|
|
34
35
|
"defineApp",
|
|
@@ -36,7 +37,6 @@ describe("capable public entry points", () => {
|
|
|
36
37
|
"executeCapability",
|
|
37
38
|
"group",
|
|
38
39
|
"md",
|
|
39
|
-
"mergeApps",
|
|
40
40
|
"present",
|
|
41
41
|
"selectApp",
|
|
42
42
|
"subscribe",
|