capable-kit 0.0.1-alpha.8 → 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.
- package/CHANGELOG.md +214 -0
- package/README.md +6 -0
- package/dist/ai-sdk.d.mts +3 -3
- package/dist/ai-sdk.mjs +9 -7
- 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 +9 -1
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +82 -5
- package/dist/eve.mjs +364 -23
- 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-1A44jLuE.d.mts} +54 -16
- package/dist/{index-Dl4NK9G0.d.mts → index-CHuCLJIs.d.mts} +3 -3
- package/dist/{index-hdH_K5Zc.d.mts → index-D-NV4PiU.d.mts} +4 -4
- package/dist/{index-_qKFfWV4.d.mts → index-WiBWfyTn.d.mts} +63 -26
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/mcp.d.mts +7 -2
- package/dist/mcp.mjs +1 -1
- package/dist/{mount-CEFAplR5.mjs → mount-BmLHp349.mjs} +16 -8
- package/dist/mount-BmLHp349.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-D_0PIhqq.mjs → src-3LE9S4QE.mjs} +67 -38
- package/dist/src-3LE9S4QE.mjs.map +1 -0
- package/dist/{src-D-cm2gQ6.mjs → src-B2WeUwUT.mjs} +64 -32
- package/dist/src-B2WeUwUT.mjs.map +1 -0
- package/dist/{src-BWxDO2Ua.mjs → src-C5jGDnuu.mjs} +3 -3
- package/dist/{src-BWxDO2Ua.mjs.map → src-C5jGDnuu.mjs.map} +1 -1
- package/dist/src-DePlcG_t.mjs +787 -0
- package/dist/src-DePlcG_t.mjs.map +1 -0
- package/dist/{src-rkr5j_NH.mjs → src-_6OmFRYa.mjs} +28 -10
- package/dist/src-_6OmFRYa.mjs.map +1 -0
- package/dist/{subscription-B-auXJbm.d.mts → subscription-DPdwovhw.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 +39 -20
- 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/adr/0003-capability-reference-customization.md +68 -0
- package/docs/internal/architecture.md +31 -17
- package/docs/internal/capability-first-model.md +126 -17
- 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 +386 -1
- package/docs/internal/releases.md +79 -0
- package/docs/site/capable-orpc-and-trpc.mdx +2 -2
- package/docs/site/concepts/apps.mdx +7 -1
- package/docs/site/concepts/architecture.mdx +9 -1
- package/docs/site/concepts/capabilities.mdx +41 -4
- package/docs/site/concepts/errors.mdx +11 -1
- package/docs/site/concepts/presentations.mdx +20 -0
- package/docs/site/patterns/composition.mdx +152 -8
- package/docs/site/patterns/remote-apps.mdx +6 -2
- package/docs/site/patterns/subscriptions.mdx +79 -32
- package/docs/site/quickstart.mdx +1 -1
- package/docs/site/reference/packages-and-entry-points.mdx +50 -3
- package/docs/site/surfaces/cli.mdx +44 -0
- package/docs/site/surfaces/eve.mdx +65 -18
- package/docs/site/surfaces/typescript.mdx +3 -3
- package/package-docs.mjs +3 -0
- package/package.json +10 -11
- package/src/bin.ts +0 -0
- package/src/index.test.ts +2 -1
- package/src/index.ts +6 -1
- package/src/package.test.ts +9 -0
- package/dist/mount-CEFAplR5.mjs.map +0 -1
- package/dist/src-D-cm2gQ6.mjs.map +0 -1
- package/dist/src-D_0PIhqq.mjs.map +0 -1
- package/dist/src-betOfnDL.mjs +0 -481
- package/dist/src-betOfnDL.mjs.map +0 -1
- package/dist/src-rkr5j_NH.mjs.map +0 -1
package/docs/CONTEXT.md
CHANGED
|
@@ -2,24 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
**Capability**: one typed capability with a canonical string ID, optional
|
|
4
4
|
object-shaped input, optional output schema, declared errors, middleware,
|
|
5
|
-
optional effect,
|
|
6
|
-
|
|
5
|
+
optional effect, a handler and/or subscriber, open surface metadata, and optional
|
|
6
|
+
`toPresentation`. A handler alone is unary; a handler with a subscriber provides
|
|
7
|
+
replacement snapshots; a subscriber alone provides individual events.
|
|
7
8
|
It has no canonical HTTP method or path.
|
|
8
9
|
|
|
9
10
|
**App Definition**: immutable named object nesting created by `defineApp()`
|
|
10
11
|
whose leaves are Capabilities. It carries no context provider or execution
|
|
11
|
-
placement.
|
|
12
|
+
placement. It can contribute app-wide middleware and declared errors. Its paths
|
|
13
|
+
drive navigational interfaces and surface defaults.
|
|
12
14
|
|
|
13
15
|
**Group**: an anonymous decorated subtree created with `group()`. It has no ID.
|
|
14
16
|
It contributes semantic middleware and errors and exposes its metadata ancestry
|
|
15
17
|
to surface compilers.
|
|
16
18
|
|
|
17
|
-
**Capability ID**: canonical execution and transport identity.
|
|
18
|
-
within an Application.
|
|
19
|
+
**Capability ID**: canonical execution and transport identity. One ID has one
|
|
20
|
+
execution owner within an Application.
|
|
19
21
|
|
|
20
|
-
**Application path**:
|
|
22
|
+
**Application path**: an object path to a Capability, such as
|
|
21
23
|
`admin.users.create`. It drives direct App calls, CLI, and MCP navigation but
|
|
22
|
-
is not the Capability's identity.
|
|
24
|
+
is not the Capability's identity. One Capability may have multiple paths when
|
|
25
|
+
the same App runtime is deliberately composed under aliases.
|
|
23
26
|
|
|
24
27
|
**Effect**: optional `read`, `write`, or `destructive` intent. HTTP may derive
|
|
25
28
|
GET only from `read`; MCP may derive safety hints. Absence means unknown.
|
|
@@ -40,16 +43,22 @@ Capability declares context, local consumers must provide it through
|
|
|
40
43
|
Definition derives any required context type from its Capability tree but
|
|
41
44
|
stores no provider.
|
|
42
45
|
|
|
43
|
-
**App**: a context-erased typed
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
**Executable App**: a context-erased typed tree of callable operations and
|
|
47
|
+
event references in which every Capability has an execution owner and the
|
|
48
|
+
caller has no unresolved provider obligation. `createApp()` closes over direct
|
|
49
|
+
execution and its provider; `createRemoteApp()` wraps a transport without
|
|
50
|
+
performing I/O. Remote manifest discovery is lazy, validated, and cached.
|
|
51
|
+
`composeApps()` returns the same shape. The public TypeScript type remains
|
|
52
|
+
`App`. A low-level
|
|
47
53
|
`manifest() + call() + subscribe()` runtime lives behind internal symbols for
|
|
48
54
|
surfaces and composition.
|
|
49
55
|
|
|
50
|
-
**Application
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
**Application composition**: strict tree-shaped combination through
|
|
57
|
+
`composeApps()`. App arguments contribute at the root; object keys place Apps
|
|
58
|
+
beneath navigational branches. Calls dispatch by immutable Capability ID. One
|
|
59
|
+
ID has exactly one execution owner but may appear at multiple paths through
|
|
60
|
+
aliases. Conflicting ownership, path, and leaf/subtree conflicts fail when the
|
|
61
|
+
composed manifest first resolves.
|
|
53
62
|
|
|
54
63
|
**Capable transport**: an asynchronous boundary exposing `manifest()`,
|
|
55
64
|
`call()`, and `subscribe()`. `createRemoteApp()` wraps and caches it without
|
|
@@ -75,7 +84,7 @@ boundary. Omitted include means all; exclude wins.
|
|
|
75
84
|
`selectApp()` applies that policy before passing an App to a
|
|
76
85
|
surface.
|
|
77
86
|
|
|
78
|
-
**Canonical output**: handler
|
|
87
|
+
**Canonical output**: a handler result or subscription value after optional output validation. It is the
|
|
79
88
|
only semantic result.
|
|
80
89
|
|
|
81
90
|
**Presentation**: an optional, ordered, JSON-serializable sequence of Markdown,
|
|
@@ -89,6 +98,11 @@ declared errors, middleware, placement, and representations. Every emitted
|
|
|
89
98
|
item is a complete replacement Canonical Output. `subscribe(appCall, input)`
|
|
90
99
|
keeps App navigation collision-free.
|
|
91
100
|
|
|
101
|
+
**Event subscription**: a pull-based execution mode on a `read` Capability with
|
|
102
|
+
`subscribe` and no `handler`. It yields individual events, may complete without
|
|
103
|
+
yielding, and has no unary operation. `toPresentation` describes each event;
|
|
104
|
+
the CLI appends it. Event subscriptions do not imply buffering or replay.
|
|
105
|
+
|
|
92
106
|
## Invariants
|
|
93
107
|
|
|
94
108
|
- `@capable/core` depends on no transport, host, CLI, MCP, or HTTP package.
|
|
@@ -99,17 +113,22 @@ keeps App navigation collision-free.
|
|
|
99
113
|
- App Definitions never carry context providers.
|
|
100
114
|
- A context-free `createApp()` needs no provider; a contextual one satisfies
|
|
101
115
|
and erases only its own context before merging.
|
|
102
|
-
- A Capability
|
|
116
|
+
- A Capability ID has exactly one execution owner in an Application. Reusing
|
|
117
|
+
that App runtime at another path creates an alias; another runtime claiming
|
|
118
|
+
the same ID is invalid.
|
|
103
119
|
- Handlers receive only `{ input, context, signal }`.
|
|
104
120
|
- Semantic middleware and declared errors execute identically for every
|
|
105
121
|
surface.
|
|
106
|
-
- Subscription input is parsed once, every
|
|
122
|
+
- Subscription input is parsed once, every emitted value is output-validated,
|
|
107
123
|
middleware encloses the complete iterator lifetime, and cancellation aborts
|
|
108
124
|
before iterator cleanup.
|
|
125
|
+
- Opening a transport subscription parses input, resolves context, enters
|
|
126
|
+
middleware, and invokes the subscriber before its promise resolves. An event
|
|
127
|
+
transport awaits that promise before committing its streaming response.
|
|
128
|
+
Async-generator bodies still start on the first iterator pull.
|
|
109
129
|
- Platform adapters only translate their host to Fetch Request/Response.
|
|
110
130
|
- HTTP is a projection and deployment concern, not Capability identity.
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
semantics.
|
|
131
|
+
- Patches, buffering, replay, resumption, delivery guarantees, and reconnection
|
|
132
|
+
policy are not subscription semantics.
|
|
114
133
|
- Idempotence, approvals, and durable tasks remain deferred until a concrete
|
|
115
134
|
consumer proves their contract.
|
package/docs/README.md
CHANGED
|
@@ -8,6 +8,9 @@ the npm package is packed. It matches the installed package version.
|
|
|
8
8
|
Do not rely on remembered Capable APIs. Read the relevant bundled guide and
|
|
9
9
|
inspect `../src/` when you need a detail the guides do not cover.
|
|
10
10
|
|
|
11
|
+
Before upgrading, read [the versioned changelog](../CHANGELOG.md). Apply all
|
|
12
|
+
entries after the installed version through the target version, oldest first.
|
|
13
|
+
|
|
11
14
|
Start here:
|
|
12
15
|
|
|
13
16
|
1. [Introduction](./site/introduction.mdx)
|
package/docs/internal/README.md
CHANGED
|
@@ -10,7 +10,10 @@ docs:dev`). This directory is for people working *on* Capable.
|
|
|
10
10
|
| [architecture.md](./architecture.md) | How the packages are layered and why |
|
|
11
11
|
| [adr/](./adr) | Accepted decisions |
|
|
12
12
|
| [implementation-friction.md](./implementation-friction.md) | Live log of awkward or leaky implementation work |
|
|
13
|
+
| [feedback/v-ray/](./feedback/v-ray/README.md) | Reproduced migration feedback, compiler matrix, and prioritized proposals |
|
|
13
14
|
| [why-capable.md](./why-capable.md) | The original internal argument for the project |
|
|
14
15
|
|
|
15
16
|
If a change contradicts CONTEXT.md, change CONTEXT.md in the same commit or do
|
|
16
17
|
not make the change.
|
|
18
|
+
|
|
19
|
+
See [Releases](./releases.md) for changesets, alpha publishing, and migration notes.
|
|
@@ -19,6 +19,6 @@ not enter the handler contract or canonical output.
|
|
|
19
19
|
App Definitions do not own context provision. `createApp()` satisfies one
|
|
20
20
|
definition's context and erases it into a directly callable App;
|
|
21
21
|
`createRemoteApp()` returns the same callable shape while lazily discovering
|
|
22
|
-
and validating transport execution. `
|
|
22
|
+
and validating transport execution. `composeApps()` combines these
|
|
23
23
|
context-erased Apps, so unrelated local contexts never become one giant merged
|
|
24
24
|
context.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Capability references and presentation customization
|
|
2
|
+
|
|
3
|
+
Status: accepted
|
|
4
|
+
|
|
5
|
+
An Executable App, one of its subtrees, or one of its Capability references may
|
|
6
|
+
appear in `composeApps()`. The source runtime and path identify executable
|
|
7
|
+
behavior; the destination path identifies navigation. These are one placement
|
|
8
|
+
operation with the App root represented by an empty source path. Composition
|
|
9
|
+
does not reconstruct a core Capability or add an execution lifecycle. Local
|
|
10
|
+
definitions must be bound with `createApp()` first.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const app = composeApps({
|
|
14
|
+
stop: customize(desktop.plugins.stop, {
|
|
15
|
+
description: "Stop a running desktop instance.",
|
|
16
|
+
meta: { cli: { positional: ["instanceId"] } },
|
|
17
|
+
}),
|
|
18
|
+
debug: { status: desktop.plugins.status, screenshot: local.screenshot },
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`customize()` returns a non-callable Capability placement. It accepts title,
|
|
23
|
+
description, and surface metadata registered in the global
|
|
24
|
+
`CapableCustomizationMeta` interface.
|
|
25
|
+
CLI and MCP opt in initially. It never changes schemas, effect, errors,
|
|
26
|
+
middleware, context, handlers, subscriptions, or output presentation renderers.
|
|
27
|
+
A standalone function avoids reserving `with` or another command name in the
|
|
28
|
+
lazy App proxy.
|
|
29
|
+
|
|
30
|
+
The manifest retains the authored capability contract. Individual reference
|
|
31
|
+
placements carry a `customization.navigation: "destination"` marker, plus any
|
|
32
|
+
overrides supplied by the caller. CLI/MCP then derive names from the curated
|
|
33
|
+
path unless explicitly overridden in that field. A placed App or Group gets its
|
|
34
|
+
outer name from the destination key; navigation and presentation inside that
|
|
35
|
+
subtree remain authored. Alias contract comparison ignores path and
|
|
36
|
+
customization, but still compares original metadata. Surfaces
|
|
37
|
+
explicitly read display fields using `getCapabilityDisplay()`; executors and
|
|
38
|
+
policy callbacks continue to receive the original contract. HTTP/OpenAPI still
|
|
39
|
+
derive from core definitions and do not consume these overrides.
|
|
40
|
+
|
|
41
|
+
`customization` is an optional field in the v4 manifest. Clients may ignore it
|
|
42
|
+
and continue to execute the source contract, but must understand the field to
|
|
43
|
+
display overrides or compare customized aliases correctly.
|
|
44
|
+
|
|
45
|
+
Overrides are copied as immutable JSON. An outer customization wins for each
|
|
46
|
+
supplied title, description, or metadata namespace. Namespaces are replaced,
|
|
47
|
+
not recursively merged. A leaf reference carries its own metadata but not its
|
|
48
|
+
source groups' presentation ancestry. Backend group middleware and errors still
|
|
49
|
+
apply because calls retain the source runtime.
|
|
50
|
+
|
|
51
|
+
The ownership rule follows the terminal execution transport. Referencing the
|
|
52
|
+
same operation through nested compositions or multiple wrappers over one
|
|
53
|
+
transport creates aliases. Independently bound local Apps and distinct
|
|
54
|
+
transports cannot claim the same ID. Identical placements are deduplicated;
|
|
55
|
+
different customizations at the same path conflict. All fields needed for
|
|
56
|
+
display survive manifest serialization and nesting. Offline discovery is the
|
|
57
|
+
transport's responsibility, not a separate composition cache API.
|
|
58
|
+
|
|
59
|
+
`selectApp()` remains useful for filtering a tree at its existing paths. Curated
|
|
60
|
+
reference trees serve a different purpose: explicit selection and relocation.
|
|
61
|
+
|
|
62
|
+
MCP customization includes the namespace's annotation hints. These are surface
|
|
63
|
+
hints; `effect` remains authoritative for read-only and destructive annotations.
|
|
64
|
+
|
|
65
|
+
Composition changes navigation and opted-in presentation only. It never adds
|
|
66
|
+
middleware, errors, context requirements, providers, or another execution
|
|
67
|
+
lifecycle. A local wrapper around a remote invocation is a new Capability with
|
|
68
|
+
its own ID and schema; its handler may call the remote reference explicitly.
|
|
@@ -17,10 +17,10 @@ App Definition ──────────────► createServer(defini
|
|
|
17
17
|
└─ createRemoteApp(transport)
|
|
18
18
|
│ lazy manifest discovery
|
|
19
19
|
│
|
|
20
|
-
|
|
20
|
+
composeApps / selectApp
|
|
21
21
|
│
|
|
22
22
|
▼
|
|
23
|
-
App (typed
|
|
23
|
+
App (typed Capability reference tree)
|
|
24
24
|
│
|
|
25
25
|
┌─────────────┼──────────────┬────────────────────┐
|
|
26
26
|
▼ ▼ ▼ ▼
|
|
@@ -40,13 +40,13 @@ as `capable-kit/server`, `capable-kit/next`, and `capable-kit/swr`.
|
|
|
40
40
|
| ------------------- | -------------------------------------------------------------------- |
|
|
41
41
|
| `capable-kit` | Public facade and the user-installed `cap` command |
|
|
42
42
|
| `@capable/core` | Authoring, tree composition, validation, middleware, errors, execution |
|
|
43
|
-
| `@capable/app` |
|
|
43
|
+
| `@capable/app` | Typed local and remote Apps, composition, selection, manifests |
|
|
44
44
|
| `@capable/fetch` | Capable transport encoding and the HTTP/OpenAPI projection |
|
|
45
45
|
| `@capable/server` | Fetch server composition and protocol mounts |
|
|
46
46
|
| `@capable/cli` | Command derivation, parsing, help, and rendering |
|
|
47
47
|
| `@capable/mcp` | Tool derivation and the Streamable HTTP mount |
|
|
48
48
|
| `@capable/ai-sdk` | Typed AI SDK v7 tool projection |
|
|
49
|
-
| `@capable/eve` | Native
|
|
49
|
+
| `@capable/eve` | Native Eve tool projection and caller-scoped agent lifecycle Apps |
|
|
50
50
|
| `@capable/react-query` | Query keys, query options, mutations, live queries |
|
|
51
51
|
| `@capable/swr` | SWR keys, fetchers, mutations, and subscriptions |
|
|
52
52
|
| `@capable/next` | Method-export translation for the App Router |
|
|
@@ -58,7 +58,7 @@ and the complete execution lifecycle, `application.ts` owns Groups, App
|
|
|
58
58
|
Definitions, placement, and uniqueness. Keeping execution beside authoring
|
|
59
59
|
preserves the Capability seam from [ADR-0001](./adr/0001-capability-is-the-semantic-boundary.md).
|
|
60
60
|
|
|
61
|
-
The App package is transport-neutral: `runtime.ts` owns
|
|
61
|
+
The App package is transport-neutral: `runtime.ts` owns typed local and
|
|
62
62
|
remote Apps, `composition.ts` owns merge and selection, `manifest.ts` owns
|
|
63
63
|
manifest construction and tree invariants, and `index.ts` is only a facade.
|
|
64
64
|
|
|
@@ -73,10 +73,10 @@ interface ApplicationTransport {
|
|
|
73
73
|
output: unknown;
|
|
74
74
|
presentation?: readonly PresentationPart[];
|
|
75
75
|
}>;
|
|
76
|
-
subscribe({ id, input, signal, presentation }): AsyncIterableIterator<{
|
|
76
|
+
subscribe({ id, input, signal, presentation }): Promise<AsyncIterableIterator<{
|
|
77
77
|
output: unknown;
|
|
78
78
|
presentation?: readonly PresentationPart[];
|
|
79
|
-
}
|
|
79
|
+
}>>;
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -100,7 +100,7 @@ separate from authored HTTP APIs and from transport-neutral App semantics.
|
|
|
100
100
|
|
|
101
101
|
That private protocol defaults to the versioned `capable.rich-json.v1` codec,
|
|
102
102
|
which preserves runtime values such as `Date` in inputs, outputs, declared-error
|
|
103
|
-
data, and subscription
|
|
103
|
+
data, and subscription values. The codec ID crosses the boundary in the
|
|
104
104
|
`capable-codec` header, so mismatched peers fail before decoding. A deployment
|
|
105
105
|
can replace the value encoding without replacing HTTP or SSE framing:
|
|
106
106
|
|
|
@@ -131,24 +131,38 @@ OpenAPI contracts remain ordinary JSON.
|
|
|
131
131
|
|
|
132
132
|
Subscriptions are encoded at `POST /~capable/subscribe/:id` as SSE. Errors before
|
|
133
133
|
the first replacement are ordinary HTTP errors; a terminal error after streaming
|
|
134
|
-
began uses a typed SSE error frame.
|
|
134
|
+
began uses a typed SSE error frame. Event-only subscriptions establish without
|
|
135
|
+
waiting for their first value, flushing an SSE comment that does not become a
|
|
136
|
+
canonical event. Input parsing, context resolution, middleware entry, subscriber
|
|
137
|
+
invocation, and AsyncIterable validation complete before that response is
|
|
138
|
+
committed, so their failures retain ordinary HTTP statuses. Failures inside an
|
|
139
|
+
async-generator body happen after establishment and use typed SSE error frames.
|
|
140
|
+
|
|
141
|
+
Manifest protocol `capable.capabilities.v4` requires an `execution` field on each
|
|
142
|
+
Capability: `unary`, `live`, or `events`. This replaces the optional
|
|
143
|
+
`subscription: { mode: "replace" }` field. Clients and servers must upgrade
|
|
144
|
+
together; the value codec remains `capable.rich-json.v1`.
|
|
135
145
|
|
|
136
146
|
## Composition
|
|
137
147
|
|
|
138
|
-
`
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
`composeApps(a, b, { remote })` places executable Apps, their subtrees, and
|
|
149
|
+
individual Capability references into one tree. An App is the source subtree at
|
|
150
|
+
its root; a Group or Capability reference uses a deeper source path. App and
|
|
151
|
+
subtree arguments contribute their children at the root; object keys select
|
|
152
|
+
destination branches. Composition adds navigation and opted-in presentation,
|
|
153
|
+
with no semantic middleware or provider lifecycle. It returns synchronously and
|
|
154
|
+
resolves its inputs together when its complete manifest is first needed. Path
|
|
155
|
+
and ID conflicts therefore fail at that discovery boundary. A direct call under
|
|
156
|
+
a named branch resolves only placements that can contribute to that path:
|
|
143
157
|
|
|
144
158
|
```ts
|
|
145
159
|
const remote = createRemoteApp<AppDefinition>(transport);
|
|
146
|
-
const app =
|
|
147
|
-
remote,
|
|
160
|
+
const app = composeApps(
|
|
148
161
|
createApp(localDefinition, { context: createLocalContext }),
|
|
162
|
+
{ remote, tools: remote.admin },
|
|
149
163
|
);
|
|
150
164
|
|
|
151
|
-
await app.
|
|
165
|
+
await app.remote.todos.list();
|
|
152
166
|
```
|
|
153
167
|
|
|
154
168
|
## Surface compilation
|
|
@@ -46,8 +46,9 @@ const definition = defineApp({
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Core-owned Capability fields are `id`, descriptive metadata, optional `effect`,
|
|
49
|
-
optional object-shaped `input`, optional `output`, errors, middleware, `handler`,
|
|
50
|
-
|
|
49
|
+
optional object-shaped `input`, optional `output`, errors, middleware, `handler` and/or `subscribe`, and optional `toPresentation`.
|
|
50
|
+
At least one operation is required. Definitions derive `execution` as `unary`,
|
|
51
|
+
`live`, or `events`; authors do not configure this field. The open `meta` registry is
|
|
51
52
|
typed through module augmentation from surface packages, so core never depends
|
|
52
53
|
on HTTP, CLI, MCP, or Eve.
|
|
53
54
|
|
|
@@ -59,10 +60,29 @@ treated as no Presentation, so surfaces use their canonical-output fallback.
|
|
|
59
60
|
|
|
60
61
|
## Execution
|
|
61
62
|
|
|
62
|
-
Input is parsed once,
|
|
63
|
+
Input is parsed once, app middleware wraps outer-to-inner group middleware and
|
|
64
|
+
capability middleware, the handler
|
|
63
65
|
runs, thrown errors are normalized against the located error sets, and output is
|
|
64
66
|
validated. Every surface enters this same lifecycle.
|
|
65
67
|
|
|
68
|
+
App Definitions accept `middleware` and `errors` using the same inheritance
|
|
69
|
+
rules as Groups. Middleware at every scope receives a readonly `capability`
|
|
70
|
+
descriptor (`id`, `effect`) and execution `mode` (`call` or `subscribe`).
|
|
71
|
+
The descriptor does not expose executable definitions or application paths.
|
|
72
|
+
Middleware consumes the existing Context contract; it cannot refine downstream
|
|
73
|
+
Context types or introduce Context requirements on the App Definition.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const definition = defineApp({
|
|
77
|
+
capabilities: { todos },
|
|
78
|
+
errors: AccessErrors,
|
|
79
|
+
middleware: [({ capability, context, next }) => {
|
|
80
|
+
if (!canCall(context.user, capability.id)) throw AccessErrors.FORBIDDEN();
|
|
81
|
+
return next();
|
|
82
|
+
}],
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
66
86
|
A Capability executes without an Application:
|
|
67
87
|
|
|
68
88
|
```ts
|
|
@@ -70,7 +90,7 @@ await executeCapability(deleteTodo, { input, context, signal });
|
|
|
70
90
|
```
|
|
71
91
|
|
|
72
92
|
That boundary applies the Capability's own validation, middleware, and declared
|
|
73
|
-
errors. Group middleware and
|
|
93
|
+
errors. App and Group middleware and error sets are properties of placement and
|
|
74
94
|
therefore require execution through the tree.
|
|
75
95
|
|
|
76
96
|
## Errors
|
|
@@ -88,31 +108,80 @@ if (TodoErrors.NOT_FOUND.is(error)) console.error(error.data.todoId);
|
|
|
88
108
|
Declared error data is validated by the executor. Anything outside the located
|
|
89
109
|
Capability's error sets becomes `INTERNAL_SERVER_ERROR`, retaining the original
|
|
90
110
|
value only as a server-side `cause`. A Group and a Capability may not declare
|
|
91
|
-
the same code twice; the conflict fails when the definition is created.
|
|
111
|
+
the same code twice; the conflict fails when the definition is created. The same
|
|
112
|
+
rule applies to App errors inherited by Groups and Capabilities.
|
|
92
113
|
|
|
93
114
|
## Context and placement
|
|
94
115
|
|
|
95
116
|
`defineApp()` stores no context provider. `createApp()` supplies and erases one
|
|
96
117
|
context; `createRemoteApp()` returns a lazy, transport-backed App. Unrelated
|
|
97
|
-
local contexts are erased before `
|
|
118
|
+
local contexts are erased before `composeApps()` and never become one combined
|
|
98
119
|
context:
|
|
99
120
|
|
|
100
121
|
```ts
|
|
101
122
|
const remote = createRemoteApp<AppDefinition>(transport);
|
|
102
|
-
const app =
|
|
123
|
+
const app = composeApps(
|
|
103
124
|
remote,
|
|
104
125
|
createApp(localDefinition, { context: createLocalContext }),
|
|
105
126
|
);
|
|
106
127
|
```
|
|
107
128
|
|
|
108
|
-
|
|
109
|
-
manifest first resolves, then dispatches by Capability ID.
|
|
110
|
-
|
|
129
|
+
Composition validates path, ID ownership, and leaf/subtree conflicts when its
|
|
130
|
+
complete manifest first resolves, then dispatches by Capability ID. App
|
|
131
|
+
arguments contribute at the root; object keys reposition Apps, executable
|
|
132
|
+
subtrees, or individual references beneath navigational namespaces without
|
|
133
|
+
rewriting IDs. References that reach the same terminal transport create
|
|
134
|
+
aliases; distinct execution owners cannot claim the same ID. Direct calls
|
|
135
|
+
beneath a namespace resolve only the placements that can contribute to that
|
|
136
|
+
path.
|
|
137
|
+
|
|
138
|
+
Individual bound references may also be leaves of `composeApps()`:
|
|
111
139
|
|
|
112
|
-
|
|
140
|
+
```ts
|
|
141
|
+
const app = composeApps({
|
|
142
|
+
status: customize(remote.plugins.status, {
|
|
143
|
+
description: "Inspect this desktop instance.",
|
|
144
|
+
meta: { cli: { positional: ["instanceId"] } },
|
|
145
|
+
}),
|
|
146
|
+
screenshot: local.screenshot,
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
An executable Group proxy places its complete subtree. The destination key
|
|
151
|
+
names the placed Group; its title, description, internal paths, and nested Group
|
|
152
|
+
metadata remain authored:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const app = composeApps({
|
|
156
|
+
debug: remote.plugins,
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Navigation inside the subtree remains authored. For example, an absolute CLI
|
|
161
|
+
command on a child may intentionally appear outside the destination Group;
|
|
162
|
+
place individual leaves when destination paths should determine every surface
|
|
163
|
+
name.
|
|
164
|
+
|
|
165
|
+
A reference keeps source execution and adopts the destination path. Source
|
|
166
|
+
Group presentation ancestry is not copied; source middleware and errors still
|
|
167
|
+
execute. `customize()` returns an immutable composition entry and only accepts
|
|
168
|
+
title, description, and opted-in surface metadata. Overrides are stored in the
|
|
169
|
+
manifest separately from the source contract, survive serialization, and are
|
|
170
|
+
excluded from alias identity comparison. Original metadata remains part of the
|
|
171
|
+
contract. Outer overrides replace each supplied metadata namespace. See
|
|
172
|
+
[the decision](adr/0003-capability-reference-customization.md).
|
|
173
|
+
|
|
174
|
+
Composition adds no semantic behavior. It cannot add middleware, errors,
|
|
175
|
+
Context requirements, or another execution lifecycle around a reference. A
|
|
176
|
+
local wrapper around a remote invocation is a new Capability with its own ID
|
|
177
|
+
and input schema; its handler calls the remote reference explicitly.
|
|
178
|
+
|
|
179
|
+
## Subscriptions
|
|
113
180
|
|
|
114
181
|
A `read` Capability may define `subscribe` beside `handler`. Both modes share one
|
|
115
182
|
ID, input, output, error set, middleware, placement, and metadata.
|
|
183
|
+
The subscriber emits its own initial snapshot; subscribing never invokes the
|
|
184
|
+
unary handler.
|
|
116
185
|
|
|
117
186
|
```ts
|
|
118
187
|
subscribe: ({ input, context, signal }) =>
|
|
@@ -125,14 +194,54 @@ subscribe: ({ input, context, signal }) =>
|
|
|
125
194
|
|
|
126
195
|
`watchQuery()` pulls the invalidation source before reading its first snapshot,
|
|
127
196
|
so a concurrent change causes another snapshot instead of being missed.
|
|
128
|
-
Subscription input is parsed once, every
|
|
197
|
+
Subscription input is parsed once, every emitted value is output-validated,
|
|
129
198
|
middleware encloses the complete iterator lifetime, and cancellation aborts the
|
|
130
199
|
subscriber before cleanup.
|
|
131
200
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
201
|
+
A `read` Capability with only `subscribe` is an event stream:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const logs = capability({
|
|
205
|
+
id: "runs.logs",
|
|
206
|
+
effect: "read",
|
|
207
|
+
async *subscribe({ signal }) {
|
|
208
|
+
yield* followLogs({ signal });
|
|
209
|
+
},
|
|
210
|
+
toPresentation: entry => entry.message,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
for await (const entry of subscribe(app.runs.logs, {}, { signal })) {
|
|
214
|
+
appendLog(entry);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
An event stream needs no initial value and may complete without yielding.
|
|
219
|
+
Its App reference has no unary call signature; untyped unary calls fail with
|
|
220
|
+
`METHOD_NOT_ALLOWED`. Without an output schema, infer the yielded type. With a
|
|
221
|
+
schema, yield schema inputs and deliver parsed schema outputs to consumers and
|
|
222
|
+
presentations. Adding a handler changes the contract into replacement snapshots;
|
|
223
|
+
a snapshot and unrelated events belong in separate Capabilities.
|
|
224
|
+
|
|
225
|
+
`toPresentation` is optional and operates on each validated value. Typed consumers
|
|
226
|
+
and JSON CLI output do not request it. The CLI appends event presentations but
|
|
227
|
+
replaces live snapshots. An empty presentation selects canonical-output fallback,
|
|
228
|
+
not suppression. Event commands stream by default; live commands use `--watch`.
|
|
229
|
+
|
|
230
|
+
Event-only Capabilities are excluded from React Query/SWR state projections and
|
|
231
|
+
implicit unary HTTP/OpenAPI, MCP, AI SDK, and Eve projections. Explicit unsupported
|
|
232
|
+
HTTP/tool metadata is rejected when that projection is created; use `false` to
|
|
233
|
+
disable it.
|
|
234
|
+
|
|
235
|
+
Out of scope: patches, buffering, replay, resumption, delivery guarantees,
|
|
236
|
+
reconnection policy, and commands that start work and stream results. The Capable
|
|
237
|
+
transport uses SSE; that encoding is not part of core semantics. A quiet event
|
|
238
|
+
response establishes after input parsing, context resolution, middleware entry,
|
|
239
|
+
and subscriber invocation, without waiting for a domain event. Failures during
|
|
240
|
+
that preparation remain ordinary HTTP errors. Failures inside an async-generator
|
|
241
|
+
body use typed stream errors because the body starts on the first pull.
|
|
242
|
+
Establishment does not promise that a source listener or authorization inside a
|
|
243
|
+
generator body has completed; put request rejection in middleware when it must
|
|
244
|
+
affect the HTTP status.
|
|
136
245
|
|
|
137
246
|
## Surface direction
|
|
138
247
|
|
|
@@ -150,7 +259,7 @@ unary snapshot.
|
|
|
150
259
|
|
|
151
260
|
## Deferred
|
|
152
261
|
|
|
153
|
-
-
|
|
262
|
+
- Streaming commands that start work and yield results from that invocation.
|
|
154
263
|
- `idempotent`, until a retrying transport, Workflow integration, or another
|
|
155
264
|
real consumer proves its contract.
|
|
156
265
|
- Approvals and durable tasks. They wrap an invocation and never enter canonical
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Capable reproduction for Eve PR #2981
|
|
2
|
+
|
|
3
|
+
The integration uses `defineDurableCallback` from the PR at
|
|
4
|
+
`8e6964036657082ce1405864cf3313ad11fc8d60`, backported onto Eve 0.52.3 with the
|
|
5
|
+
checked-in pnpm patch. No Eve lifecycle code is changed.
|
|
6
|
+
|
|
7
|
+
User API:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export default createEveTools(({ session }) =>
|
|
11
|
+
appForUser(session.auth.current!.principalId), {
|
|
12
|
+
approval: capability =>
|
|
13
|
+
capability.effect === "destructive" ? approvalPolicy : undefined,
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Internally, the adapter uses `session.started` for recoverable discovery and
|
|
18
|
+
persists `{ id: capability.id }` in its generated execution callback. On recovery,
|
|
19
|
+
Eve reruns the resolver to register the current implementation. The App provider
|
|
20
|
+
is invoked again with the live execution session before the handler runs.
|
|
21
|
+
The app's code is reconstructable; its data resides outside the function process.
|
|
22
|
+
|
|
23
|
+
A regression surfaced during testing: an unauthorized approval attempt triggered
|
|
24
|
+
recovery with that responder as the current user. Holding onto the App from that
|
|
25
|
+
resolver caused later, legitimately approved execution to use the wrong user's
|
|
26
|
+
context. Recreating the execution App from `ToolContext.session` fixed it.
|
|
27
|
+
|
|
28
|
+
## Local test
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
pnpm install --frozen-lockfile
|
|
32
|
+
pnpm run build
|
|
33
|
+
pnpm --dir examples/eve run test:recovery
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Requires an AI Gateway credential. The test:
|
|
37
|
+
|
|
38
|
+
1. Creates a persistent todo and starts an agent deletion through the CLI.
|
|
39
|
+
2. Waits for an actual tool-approval request and a durable waiting event.
|
|
40
|
+
3. Stops Eve and verifies its health endpoint is unreachable.
|
|
41
|
+
4. Starts a fresh server with the same workflow and todo storage.
|
|
42
|
+
5. Submits an approval as another authenticated user and checks rejection.
|
|
43
|
+
6. Approves as the initiator and checks the original call's successful result.
|
|
44
|
+
7. Verifies the deletion receipt names the initiating user and the new instance.
|
|
45
|
+
8. Reads the completed result through a fresh CLI process.
|
|
46
|
+
|
|
47
|
+
## Vercel test
|
|
48
|
+
|
|
49
|
+
`examples/eve/vercel-recovery.e2e.ts` separates `prepare` and `resume` so a new
|
|
50
|
+
preview can be deployed while the call is paused. The driver uses the same
|
|
51
|
+
private Blob store as the deployed app. It checks the same request/call identity,
|
|
52
|
+
rejected responder, successful original-user execution, and persistent deletion.
|
|
53
|
+
It fails if the approval and execution instance markers are identical.
|
|
54
|
+
|
|
55
|
+
The test project is `timo-lins-projects/capable-eve-recovery`. Its routes require
|
|
56
|
+
new demo bearer credentials, and its Blob store is private. See the demo README
|
|
57
|
+
for environment variables and commands. Gateway credentials remain in sensitive
|
|
58
|
+
Preview environment variables; no credentials belong in a reproduction or PR.
|
|
59
|
+
|
|
60
|
+
No issue or PR comment has been posted by this task.
|
|
61
|
+
|
|
62
|
+
## Recorded result — September 9, 2026
|
|
63
|
+
|
|
64
|
+
Both the local stop/start test and the deployed two-phase test passed. The normal
|
|
65
|
+
CLI E2E also passed, alongside 126 unit tests, 5 auth integration tests,
|
|
66
|
+
typechecking, and the package build.
|
|
67
|
+
|
|
68
|
+
Deployed run: `wrun_41M22YGA1Q0GGVQMMJRQF13QQV`.
|
|
69
|
+
|
|
70
|
+
- Prepared on this immutable preview:
|
|
71
|
+
https://capable-eve-recovery-pilxxx6pq-timo-lins-projects.vercel.app
|
|
72
|
+
- Resumed through a newly deployed preview:
|
|
73
|
+
https://capable-eve-recovery-1qtw73tiv-timo-lins-projects.vercel.app
|
|
74
|
+
- Approval runtime marker: `16cfe5b5-ee66-4914-807b-7f15549f292b`.
|
|
75
|
+
- Execution runtime marker: `9f0c5a38-a12d-46e2-a1de-47bed69dd513`.
|
|
76
|
+
- Execution principal: `demo-user`.
|
|
77
|
+
- A fresh combined-CLI process subsequently read `status: "completed"` from
|
|
78
|
+
the deployed run and returned the deletion confirmation.
|
|
79
|
+
- The other authenticated principal's approval was rejected before execution.
|
|
80
|
+
- The successful result kept the original pending request's tool-call ID.
|
|
81
|
+
- The private Blob record contained the deletion, and the normal todo list no
|
|
82
|
+
longer contained that item.
|
|
83
|
+
|
|
84
|
+
These markers identify initialized demo runtime instances. The separate local
|
|
85
|
+
test additionally verifies that the original server process was actually stopped.
|
|
86
|
+
This is a focused approval-recovery test, not load or exhaustive replay testing.
|