capable-kit 0.1.0-alpha.10 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -106
- package/dist/ai-sdk.d.mts +3 -3
- package/dist/ai-sdk.mjs +7 -9
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +2 -2
- package/dist/bin.mjs +4 -4
- package/dist/cli.d.mts +1 -6
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +1 -1
- package/dist/eve.d.mts +3 -3
- package/dist/eve.mjs +7 -9
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-1A44jLuE.d.mts → index-D63DSGZG.d.mts} +17 -50
- package/dist/{index-CHuCLJIs.d.mts → index-D8DWjQ9f.d.mts} +3 -3
- package/dist/{index-D-NV4PiU.d.mts → index-DgxvtAmv.d.mts} +4 -4
- package/dist/{index-WiBWfyTn.d.mts → index-ftQx6OMr.d.mts} +16 -43
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/mcp.d.mts +2 -7
- package/dist/mcp.mjs +1 -1
- package/dist/{mount-BmLHp349.mjs → mount-B9TrHWHh.mjs} +8 -16
- package/dist/mount-B9TrHWHh.mjs.map +1 -0
- package/dist/react-query.d.mts +2 -2
- package/dist/react-query.mjs +1 -1
- package/dist/react-query.mjs.map +1 -1
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +3 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{src-DePlcG_t.mjs → src-B592M-6b.mjs} +105 -312
- package/dist/src-B592M-6b.mjs.map +1 -0
- package/dist/{src-B2WeUwUT.mjs → src-Bd1Vnze8.mjs} +31 -49
- package/dist/src-Bd1Vnze8.mjs.map +1 -0
- package/dist/{src-C5jGDnuu.mjs → src-CKC1BdXO.mjs} +3 -3
- package/dist/{src-C5jGDnuu.mjs.map → src-CKC1BdXO.mjs.map} +1 -1
- package/dist/{src-3LE9S4QE.mjs → src-CL9eA6_p.mjs} +17 -29
- package/dist/src-CL9eA6_p.mjs.map +1 -0
- package/dist/{src-_6OmFRYa.mjs → src-Hw9WBgEW.mjs} +10 -28
- package/dist/src-Hw9WBgEW.mjs.map +1 -0
- package/dist/{subscription-DPdwovhw.d.mts → subscription-DbnHcm7C.d.mts} +2 -2
- package/dist/swr.d.mts +2 -2
- package/dist/swr.mjs +1 -1
- package/dist/swr.mjs.map +1 -1
- package/docs/CONTEXT.md +11 -23
- package/docs/internal/architecture.md +14 -27
- package/docs/internal/capability-first-model.md +13 -99
- package/docs/internal/implementation-friction.md +0 -85
- package/docs/site/concepts/apps.mdx +1 -1
- package/docs/site/concepts/architecture.mdx +0 -8
- package/docs/site/concepts/capabilities.mdx +2 -2
- package/docs/site/concepts/presentations.mdx +0 -4
- package/docs/site/patterns/composition.mdx +5 -107
- package/docs/site/patterns/remote-apps.mdx +1 -5
- package/docs/site/patterns/subscriptions.mdx +32 -79
- package/docs/site/reference/packages-and-entry-points.mdx +2 -41
- package/docs/site/surfaces/cli.mdx +0 -11
- package/docs/site/surfaces/typescript.mdx +2 -2
- package/package.json +1 -1
- package/src/index.test.ts +0 -1
- package/src/index.ts +0 -5
- package/src/package.test.ts +0 -9
- package/dist/mount-BmLHp349.mjs.map +0 -1
- package/dist/src-3LE9S4QE.mjs.map +0 -1
- package/dist/src-B2WeUwUT.mjs.map +0 -1
- package/dist/src-DePlcG_t.mjs.map +0 -1
- package/dist/src-_6OmFRYa.mjs.map +0 -1
- package/docs/internal/adr/0003-capability-reference-customization.md +0 -68
|
@@ -20,7 +20,7 @@ App Definition ──────────────► createServer(defini
|
|
|
20
20
|
composeApps / selectApp
|
|
21
21
|
│
|
|
22
22
|
▼
|
|
23
|
-
App (typed
|
|
23
|
+
App (typed callable object tree)
|
|
24
24
|
│
|
|
25
25
|
┌─────────────┼──────────────┬────────────────────┐
|
|
26
26
|
▼ ▼ ▼ ▼
|
|
@@ -40,7 +40,7 @@ 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` | Callable local and remote Apps, merge, 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 |
|
|
@@ -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 callable 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 }):
|
|
76
|
+
subscribe({ id, input, signal, presentation }): 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 replacements. 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,35 +131,22 @@ 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.
|
|
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`.
|
|
134
|
+
began uses a typed SSE error frame.
|
|
145
135
|
|
|
146
136
|
## Composition
|
|
147
137
|
|
|
148
|
-
`composeApps(a, b, { remote })`
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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:
|
|
138
|
+
`composeApps(a, b, { remote })` combines executable Apps into one tree rather
|
|
139
|
+
than building a pipeline. App arguments contribute at the root; object keys
|
|
140
|
+
place Apps beneath navigational branches. It returns synchronously and resolves
|
|
141
|
+
its inputs together when its complete manifest is first needed. Path and ID
|
|
142
|
+
conflicts therefore fail at that discovery boundary. A direct call under a
|
|
143
|
+
named branch resolves only that branch:
|
|
157
144
|
|
|
158
145
|
```ts
|
|
159
146
|
const remote = createRemoteApp<AppDefinition>(transport);
|
|
160
147
|
const app = composeApps(
|
|
161
148
|
createApp(localDefinition, { context: createLocalContext }),
|
|
162
|
-
{ remote
|
|
149
|
+
{ remote },
|
|
163
150
|
);
|
|
164
151
|
|
|
165
152
|
await app.remote.todos.list();
|
|
@@ -46,9 +46,8 @@ 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
|
-
|
|
51
|
-
`live`, or `events`; authors do not configure this field. The open `meta` registry is
|
|
49
|
+
optional object-shaped `input`, optional `output`, errors, middleware, `handler`,
|
|
50
|
+
optional `subscribe`, and optional `toPresentation`. The open `meta` registry is
|
|
52
51
|
typed through module augmentation from surface packages, so core never depends
|
|
53
52
|
on HTTP, CLI, MCP, or Eve.
|
|
54
53
|
|
|
@@ -128,60 +127,15 @@ const app = composeApps(
|
|
|
128
127
|
|
|
129
128
|
Composition validates path, ID ownership, and leaf/subtree conflicts when its
|
|
130
129
|
complete manifest first resolves, then dispatches by Capability ID. App
|
|
131
|
-
arguments contribute at the root; object keys reposition Apps
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
beneath a namespace resolve only the placements that can contribute to that
|
|
136
|
-
path.
|
|
130
|
+
arguments contribute at the root; object keys reposition Apps beneath
|
|
131
|
+
navigational namespaces without rewriting IDs. Reusing one App runtime creates
|
|
132
|
+
aliases; distinct runtimes cannot claim the same ID. Direct calls beneath a
|
|
133
|
+
namespace resolve only the branches that can contribute to that path.
|
|
137
134
|
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
135
|
+
## Replacement subscriptions
|
|
180
136
|
|
|
181
137
|
A `read` Capability may define `subscribe` beside `handler`. Both modes share one
|
|
182
138
|
ID, input, output, error set, middleware, placement, and metadata.
|
|
183
|
-
The subscriber emits its own initial snapshot; subscribing never invokes the
|
|
184
|
-
unary handler.
|
|
185
139
|
|
|
186
140
|
```ts
|
|
187
141
|
subscribe: ({ input, context, signal }) =>
|
|
@@ -194,54 +148,14 @@ subscribe: ({ input, context, signal }) =>
|
|
|
194
148
|
|
|
195
149
|
`watchQuery()` pulls the invalidation source before reading its first snapshot,
|
|
196
150
|
so a concurrent change causes another snapshot instead of being missed.
|
|
197
|
-
Subscription input is parsed once, every
|
|
151
|
+
Subscription input is parsed once, every replacement is output-validated,
|
|
198
152
|
middleware encloses the complete iterator lifetime, and cancellation aborts the
|
|
199
153
|
subscriber before cleanup.
|
|
200
154
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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.
|
|
155
|
+
Out of scope, deliberately: patches, generic domain events, buffering, replay,
|
|
156
|
+
resumption, delivery guarantees, and reconnection policy. The Capable transport
|
|
157
|
+
happens to use SSE; that encoding is not part of core semantics. MCP invokes the
|
|
158
|
+
unary snapshot.
|
|
245
159
|
|
|
246
160
|
## Surface direction
|
|
247
161
|
|
|
@@ -259,7 +173,7 @@ affect the HTTP status.
|
|
|
259
173
|
|
|
260
174
|
## Deferred
|
|
261
175
|
|
|
262
|
-
-
|
|
176
|
+
- Generic response and event streaming, separate from replacement subscriptions.
|
|
263
177
|
- `idempotent`, until a retrying transport, Workflow integration, or another
|
|
264
178
|
real consumer proves its contract.
|
|
265
179
|
- Approvals and durable tasks. They wrap an invocation and never enter canonical
|
|
@@ -1143,88 +1143,3 @@ stays in the CLI surface, and `--json` retains canonical output.
|
|
|
1143
1143
|
- **Resolution:** Confirmed that `latest` is the intended default while there is
|
|
1144
1144
|
no stable release, retained the standard Changesets publish flow, and corrected
|
|
1145
1145
|
the release guide's unconditional claim that prerelease mode uses `alpha`.
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
## 2026-09-11 — Event streams exposed replacement assumptions across surfaces
|
|
1149
|
-
|
|
1150
|
-
- **Observed:** Capability definitions and App references assumed a unary handler;
|
|
1151
|
-
the manifest's subscription flag could describe only replacements. Empty
|
|
1152
|
-
subscriptions failed, and SSE waited for the first value before responding.
|
|
1153
|
-
- **Why it matters:** Logs can remain quiet or finish with no entries. Treating
|
|
1154
|
-
them as live state also causes the CLI to erase earlier entries and state
|
|
1155
|
-
projections to retain only the last event.
|
|
1156
|
-
- **Current choice:** Derive one execution kind (`unary`, `live`, `events`) from
|
|
1157
|
-
handler/subscriber presence. Use it in core, manifest v4, and projections. Keep
|
|
1158
|
-
lazy App proxies, with non-callable event references in types and runtime unary
|
|
1159
|
-
rejection. Make transport subscription opening asynchronous, so local, composed,
|
|
1160
|
-
remote, and HTTP runtimes await validation and middleware without a second
|
|
1161
|
-
readiness protocol. Event SSE responses then flush a comment without inventing
|
|
1162
|
-
an event.
|
|
1163
|
-
- **Type friction:** An empty inferred generator yields `never`; a stored
|
|
1164
|
-
`PresentationRenderer<never>` was not assignable to the erased definition's
|
|
1165
|
-
`PresentationRenderer<any>`. Store it as a method signature, whose parameter is
|
|
1166
|
-
assignable after type erasure, while authored configs retain strict renderer
|
|
1167
|
-
checking and the return remains a `PresentationValue`.
|
|
1168
|
-
- **Follow-up:** State projections remain synchronous proxies. Event-only paths
|
|
1169
|
-
are omitted from their static types, while direct untyped unary invocation is
|
|
1170
|
-
rejected by the App runtime. Async-generator bodies still start on first pull,
|
|
1171
|
-
so buffering, replay, and source-listener readiness remain application
|
|
1172
|
-
responsibilities.
|
|
1173
|
-
|
|
1174
|
-
## Individual references and customization
|
|
1175
|
-
|
|
1176
|
-
- **Observed:** Reconstructing remote leaves as core definitions would duplicate
|
|
1177
|
-
validation/execution and lose source group policy. The existing lazy proxy
|
|
1178
|
-
already stores the runtime/path binding used by subscriptions.
|
|
1179
|
-
- **Current choice:** Share that binding reader with composition. Keep
|
|
1180
|
-
`defineApp()` definition-only and bind local capabilities before composition.
|
|
1181
|
-
- **Observed:** Selection and composition duplicated cached ID dispatch and
|
|
1182
|
-
NOT_FOUND checks; MCP, AI SDK, and Eve each repeated the manifest walker.
|
|
1183
|
-
- **Current choice:** Share one derived-runtime dispatcher and the existing
|
|
1184
|
-
manifest walker. Retain `selectApp()` for filtering without relocation.
|
|
1185
|
-
- **Observed:** Alias checks compare source metadata, which cannot safely be
|
|
1186
|
-
treated as display-only. Policy callbacks also consume the original manifest.
|
|
1187
|
-
- **Current choice:** Store `customization` separately; surfaces explicitly read
|
|
1188
|
-
display fields. Only opted-in namespaces are typed as customizable. No proxy
|
|
1189
|
-
method or additional reserved command key is needed.
|
|
1190
|
-
- **Observed:** A contextless fixture with group middleware annotated as
|
|
1191
|
-
`CapabilityMiddleware<undefined>` widened inference to unknown in the current
|
|
1192
|
-
group/definition types. This is independent of reference composition.
|
|
1193
|
-
- **Current choice:** The fixture uses context-agnostic middleware and explicitly
|
|
1194
|
-
supplies an undefined context, preserving its concrete capability tree. A core
|
|
1195
|
-
inference change is outside this feature.
|
|
1196
|
-
- **Observed:** The declaration bundler leaves module augmentations aimed at
|
|
1197
|
-
private workspace modules rather than the bundled interface. Source typechecks
|
|
1198
|
-
passed while a built-package fixture accepted invalid customization namespaces.
|
|
1199
|
-
- **Current choice:** Use a global `CapableCustomizationMeta` interface for the
|
|
1200
|
-
new closed registry, loaded by surface imports. This avoids declaration-file
|
|
1201
|
-
rewriting or public-to-private module dependencies. Existing core metadata
|
|
1202
|
-
uses an open registry; changing that older API is outside this feature.
|
|
1203
|
-
- **Observed:** Treating lazy Group proxies as invalid required a type-only marker
|
|
1204
|
-
and a separate runtime branch even though the proxy already carried the same
|
|
1205
|
-
runtime/path binding as a Capability reference.
|
|
1206
|
-
- **Resolution:** Executable Group proxies place their complete subtree. Whole
|
|
1207
|
-
Apps, Group subtrees, and Capability leaves now share one source-path placement
|
|
1208
|
-
model, so the marker and the missing-leaf special case were removed. Subtree
|
|
1209
|
-
placement preserves internal paths and Group presentation but adds no local
|
|
1210
|
-
semantic middleware.
|
|
1211
|
-
- **Observed:** Manifest conflict checks treated a wrapping composed runtime as
|
|
1212
|
-
the owner, while direct path resolution already returned the terminal
|
|
1213
|
-
transport. Re-referencing the same operation through a nested composition
|
|
1214
|
-
therefore produced a false ownership conflict.
|
|
1215
|
-
- **Resolution:** Resolve and cache each placed Capability's terminal transport
|
|
1216
|
-
while assembling the composed manifest. Alias checks and ID dispatch now use
|
|
1217
|
-
that same owner identity.
|
|
1218
|
-
- **Observed:** Authored CLI root commands and MCP names could defeat the curated
|
|
1219
|
-
tree. Identical customization objects could also conflict due to key order.
|
|
1220
|
-
- **Current choice:** Individual references carry an explicit destination-
|
|
1221
|
-
navigation marker beside any customization; CLI/MCP use destination names
|
|
1222
|
-
unless explicitly overridden there. A placed Group also gets its outer name
|
|
1223
|
-
from the destination key while preserving its authored interior. Snapshot
|
|
1224
|
-
object keys canonically so equivalent customizations deduplicate. A typed
|
|
1225
|
-
navigation-metadata helper keeps that destination/source choice out of the
|
|
1226
|
-
individual surface packages.
|
|
1227
|
-
- **Observed:** Full composition resolution returned the same terminal transport
|
|
1228
|
-
map twice as `owners` and `targets`, even though conflict checks and dispatch
|
|
1229
|
-
need the same identity.
|
|
1230
|
-
- **Resolution:** Keep one typed `owners` map and build dispatch from it.
|
|
@@ -176,7 +176,7 @@ The provider runs per call, so it can read a request-scoped session, open a tran
|
|
|
176
176
|
|
|
177
177
|
> **then is reserved**
|
|
178
178
|
>
|
|
179
|
-
> Every
|
|
179
|
+
> Every level of the tree is a callable proxy. Capable reserves `then` at every path so an app can never be mistaken for a promise by `await`.
|
|
180
180
|
|
|
181
181
|
## Give one branch a different policy [#decorate]
|
|
182
182
|
|
|
@@ -65,14 +65,6 @@ interface ApplicationTransport {
|
|
|
65
65
|
output: unknown;
|
|
66
66
|
presentation?: readonly PresentationPart[];
|
|
67
67
|
}>;
|
|
68
|
-
subscribe(args: {
|
|
69
|
-
id: string;
|
|
70
|
-
input: unknown;
|
|
71
|
-
signal?: AbortSignal;
|
|
72
|
-
}): Promise<AsyncIterableIterator<{
|
|
73
|
-
output: unknown;
|
|
74
|
-
presentation?: readonly PresentationPart[];
|
|
75
|
-
}>>;
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
const app = createRemoteApp(transport);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Capabilities"
|
|
3
|
-
description: "
|
|
3
|
+
description: "A capability is one typed capability: input, output, errors, middleware, and a handler."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import { DocsPage, docMetadata } from "../../_components/docs-page";
|
|
@@ -249,7 +249,7 @@ Direct execution applies the capability's own validation, middleware, and declar
|
|
|
249
249
|
|
|
250
250
|
A capability can grow into the full declaration below, but only as each concern becomes real. The handler remains the centre; every other field either strengthens its contract, shares semantic policy, or helps a surface present it.
|
|
251
251
|
|
|
252
|
-
A read capability can add `subscribe` beside its handler
|
|
252
|
+
Subscriptions are the remaining optional execution mode. A read capability can add `subscribe` beside its handler when it needs to emit replacement snapshots; see [Subscriptions](/patterns/subscriptions).
|
|
253
253
|
|
|
254
254
|
```ts title="capabilities.ts"
|
|
255
255
|
import { capability, defineErrors, md } from "capable-kit";
|
|
@@ -174,8 +174,4 @@ An empty array means that no presentation is available, so the surface falls bac
|
|
|
174
174
|
|
|
175
175
|
This is a portable presentation model, not an MCP authoring API and not a UI component framework. It has no JSX, layout system, callbacks, or protocol-specific fields. New part types should be added only when several surfaces can give them a useful meaning.
|
|
176
176
|
|
|
177
|
-
## Subscription presentations [#subscriptions]
|
|
178
|
-
|
|
179
|
-
`toPresentation` describes each validated subscription value using the same API as unary results. Event-only subscriptions append presentations in the CLI; replacement subscriptions redraw the current snapshot in terminals. Typed `subscribe()` consumers and CLI `--json` output use canonical values without generating presentations. An empty presentation selects canonical-output fallback, not suppression. See [Subscriptions](/patterns/subscriptions).
|
|
180
|
-
|
|
181
177
|
</DocsPage>
|
|
@@ -126,14 +126,12 @@ mycli todos import ./todos.txt
|
|
|
126
126
|
Path collisions, duplicate ids, and leaf/subtree conflicts fail when the
|
|
127
127
|
composed manifest first resolves, not at call time.
|
|
128
128
|
|
|
129
|
-
Object keys place an App
|
|
130
|
-
|
|
131
|
-
visible namespace or contribute one existing group:
|
|
129
|
+
Object keys place an App beneath a navigational branch. This is useful for
|
|
130
|
+
external Apps that should keep a visible namespace:
|
|
132
131
|
|
|
133
132
|
```ts title="integrations.ts"
|
|
134
133
|
const app = composeApps(local, {
|
|
135
134
|
deepwiki,
|
|
136
|
-
tools: remote.admin,
|
|
137
135
|
integrations: {
|
|
138
136
|
linear,
|
|
139
137
|
github,
|
|
@@ -158,11 +156,9 @@ const app = composeApps({
|
|
|
158
156
|
});
|
|
159
157
|
```
|
|
160
158
|
|
|
161
|
-
Those paths are aliases backed by one
|
|
162
|
-
same
|
|
163
|
-
|
|
164
|
-
transports may not claim the same Capability ID, even when their manifests
|
|
165
|
-
happen to look identical.
|
|
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.
|
|
166
162
|
|
|
167
163
|
> **Placement stays explicit**
|
|
168
164
|
>
|
|
@@ -170,104 +166,6 @@ happen to look identical.
|
|
|
170
166
|
> still executes where it was created — behind the server's context and policy,
|
|
171
167
|
> or in this process. The CLI does not hide which is which; the source code does.
|
|
172
168
|
|
|
173
|
-
## Curate individual capabilities [#references]
|
|
174
|
-
|
|
175
|
-
Use individual references when the local tree should choose exactly which
|
|
176
|
-
capabilities to expose and where they appear. Both local and remote references
|
|
177
|
-
retain their original execution binding:
|
|
178
|
-
|
|
179
|
-
```ts title="radar-cli.ts"
|
|
180
|
-
import { composeApps, customize } from "capable-kit";
|
|
181
|
-
import { createCli } from "capable-kit/cli";
|
|
182
|
-
|
|
183
|
-
// desktop is a createRemoteApp<DesktopApp>(transport).
|
|
184
|
-
// local is a createApp(localDefinition), with its context already supplied.
|
|
185
|
-
const cliApp = composeApps({
|
|
186
|
-
stop: customize(desktop.plugins.stop, {
|
|
187
|
-
description: "Stop a running desktop instance.",
|
|
188
|
-
meta: { cli: { positional: ["instanceId"] } },
|
|
189
|
-
}),
|
|
190
|
-
debug: {
|
|
191
|
-
status: desktop.plugins.status,
|
|
192
|
-
continue: desktop.plugins.continue,
|
|
193
|
-
screenshot: local.screenshot,
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
await createCli(cliApp, { invocationName: "radar" }).run(process.argv.slice(2));
|
|
198
|
-
await cliApp.debug.status({ instanceId: "one" });
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
References preserve input/output types, IDs, errors, cancellation, subscriptions,
|
|
202
|
-
and the backend's app/group middleware. Construction performs no discovery.
|
|
203
|
-
The local tree determines paths and CLI/MCP names. Authored `cli.name`,
|
|
204
|
-
`cli.command`, and `mcp.name` do not override an individually placed reference;
|
|
205
|
-
use `customize()` to set a name or command explicitly in the curated tree.
|
|
206
|
-
Other source metadata, such as positional arguments, remains available unless
|
|
207
|
-
its namespace is replaced. Source group display metadata is not copied when
|
|
208
|
-
moving a leaf. Place a whole App or executable Group subtree to retain its
|
|
209
|
-
existing internal navigation and presentation:
|
|
210
|
-
|
|
211
|
-
```ts
|
|
212
|
-
const app = composeApps({
|
|
213
|
-
debug: desktop.plugins,
|
|
214
|
-
});
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
The destination key names the placed Group, so this example creates `debug` even
|
|
218
|
-
if `plugins` has an authored CLI name. Its title, description, and navigation
|
|
219
|
-
inside the subtree remain authored. An absolute `meta.cli.command` on a child may
|
|
220
|
-
therefore place that command outside `debug`. Use individual references when
|
|
221
|
-
every CLI/MCP name should follow the destination tree.
|
|
222
|
-
|
|
223
|
-
`customize(reference, options)` accepts `title`, `description`, and `meta`.
|
|
224
|
-
CLI and MCP metadata are supported initially. Import the relevant surface entry
|
|
225
|
-
point to load its metadata types. It returns an immutable **composition entry**,
|
|
226
|
-
not a callable; invoke or subscribe through the resulting App. Bind local
|
|
227
|
-
capability definitions with `createApp()` first. Remote references do not belong
|
|
228
|
-
inside `defineApp()`.
|
|
229
|
-
|
|
230
|
-
Each supplied metadata namespace replaces that namespace, retaining other
|
|
231
|
-
namespaces. For example, overriding `meta.cli` does not replace `meta.mcp`.
|
|
232
|
-
Customizing an already customized entry, or a reference from a composed App,
|
|
233
|
-
applies outer overrides last. Title and description can be set to an empty
|
|
234
|
-
string to suppress authored text. Execution fields and output renderers cannot
|
|
235
|
-
be overridden.
|
|
236
|
-
|
|
237
|
-
The same source capability can appear at several paths with different display
|
|
238
|
-
settings. Repeating an identical placement is deduplicated; conflicting settings
|
|
239
|
-
at the same path fail. A manifest stores overrides separately from the source
|
|
240
|
-
contract, so nested composition, `selectApp()`, and remote discovery preserve
|
|
241
|
-
them. Policy callbacks still receive the original metadata. CLI, MCP, AI SDK,
|
|
242
|
-
and Eve honor customized descriptions; HTTP/OpenAPI continue to use authored
|
|
243
|
-
definitions. Older clients may ignore overrides or reject customized aliases;
|
|
244
|
-
use the updated client when re-exporting these Apps.
|
|
245
|
-
|
|
246
|
-
Composition cannot add middleware, errors, Context requirements, or another
|
|
247
|
-
execution lifecycle around a reference. Local workflow capabilities remain
|
|
248
|
-
normal capabilities: read stdin, save files, or orchestrate remote calls inside
|
|
249
|
-
their handlers. A local wrapper is a new operation with its own ID and input
|
|
250
|
-
schema, so forwarding a call inside a handler does not automatically forward its
|
|
251
|
-
remote error declarations or subscriptions.
|
|
252
|
-
|
|
253
|
-
## Offline help [#offline-help]
|
|
254
|
-
|
|
255
|
-
Help requires runtime schemas; the TypeScript generic alone cannot supply them.
|
|
256
|
-
Bundle the manifest with the CLI and return it from the transport:
|
|
257
|
-
|
|
258
|
-
```ts
|
|
259
|
-
const desktop = createRemoteApp<DesktopApp>({
|
|
260
|
-
manifest: async () => bundledManifest,
|
|
261
|
-
call: request => transport.call(request),
|
|
262
|
-
subscribe: request => transport.subscribe(request),
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
Help then works without the backend. Execution still needs it. Keep the bundled
|
|
267
|
-
manifest aligned with the backend contract and the client types. A curated leaf
|
|
268
|
-
still resolves against its source App's manifest; it does not introduce a
|
|
269
|
-
per-capability discovery protocol.
|
|
270
|
-
|
|
271
169
|
## Narrow what a surface sees [#select]
|
|
272
170
|
|
|
273
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.
|
|
@@ -72,10 +72,6 @@ JSON.
|
|
|
72
72
|
|
|
73
73
|
HTTP is the transport that ships, but it is not privileged. `ApplicationTransport` is an interface with `manifest()`, `call()`, and `subscribe()`, so "remote" can mean a worker, a child process, a message queue, a browser extension port, or a stub in a test.
|
|
74
74
|
|
|
75
|
-
`subscribe()` resolves after the remote stream is opened, then returns its async
|
|
76
|
-
iterator. This keeps request and authorization failures separate from errors
|
|
77
|
-
emitted after streaming begins.
|
|
78
|
-
|
|
79
75
|
```ts title="worker-transport.ts"
|
|
80
76
|
import type { ApplicationTransport } from "capable-kit/app";
|
|
81
77
|
|
|
@@ -84,7 +80,7 @@ export function createWorkerTransport(worker: Worker): ApplicationTransport {
|
|
|
84
80
|
return {
|
|
85
81
|
manifest: (options) => send(worker, { kind: "manifest" }, options),
|
|
86
82
|
call: (call) => send(worker, { kind: "call", call }),
|
|
87
|
-
subscribe:
|
|
83
|
+
subscribe: (call) => stream(worker, call),
|
|
88
84
|
};
|
|
89
85
|
}
|
|
90
86
|
```
|