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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# capable-kit
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.10
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fb54c20: Compose whole Apps, executable subtrees, or individual bound local and remote capabilities into an explicit command tree. References preserve their source ID, input/output types, execution context, middleware, errors, cancellation, and subscriptions.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { composeApps, customize } from "capable-kit";
|
|
11
|
+
import { createCli } from "capable-kit/cli";
|
|
12
|
+
|
|
13
|
+
const cliApp = composeApps({
|
|
14
|
+
stop: customize(desktop.plugins.stop, {
|
|
15
|
+
description: "Stop a running desktop instance.",
|
|
16
|
+
meta: { cli: { positional: ["instanceId"] } },
|
|
17
|
+
}),
|
|
18
|
+
debug: {
|
|
19
|
+
status: desktop.plugins.status,
|
|
20
|
+
screenshot: local.screenshot,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await createCli(cliApp).run(process.argv.slice(2));
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`customize()` accepts title, description, and opted-in surface metadata (initially CLI and MCP), snapshots them without mutating the original reference, and returns a composition entry. Each supplied metadata namespace replaces that namespace. Bind local definitions with `createApp()` first; `defineApp()` continues to accept definitions only. Output renderers and execution fields cannot be overridden.
|
|
28
|
+
|
|
29
|
+
Individual CLI/MCP references use their destination tree names; authored naming overrides apply only when explicitly supplied through `customize()`. A placed App or Group gets its outer name from the destination key while its internal navigation and presentation remain authored.
|
|
30
|
+
|
|
31
|
+
Customizations survive nested composition, selection, and manifest serialization. Same-owner aliases may have different display settings. CLI, MCP, AI SDK, and Eve use customized descriptions; backend execution and policy metadata retain the source contract. Clients reading the new optional manifest `customization` field need this version to display overrides; older clients may reject customized aliases on rediscovery.
|
|
32
|
+
|
|
33
|
+
Offline help works with an `ApplicationTransport` whose `manifest()` returns a bundled contract while `call()` and `subscribe()` still use the backend.
|
|
34
|
+
- bf8249c: Added subscription-only read capabilities for logs and events. Omit `handler` to
|
|
35
|
+
emit individual events without a dummy unary result:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const logs = capability({
|
|
39
|
+
id: "runs.logs",
|
|
40
|
+
effect: "read",
|
|
41
|
+
async *subscribe({ signal }) {
|
|
42
|
+
yield* followLogs({ signal });
|
|
43
|
+
},
|
|
44
|
+
toPresentation: (entry) => entry.message,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
for await (const entry of subscribe(app.runs.logs, {}, { signal })) {
|
|
48
|
+
appendLog(entry);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Each event is output-validated and optionally presented. Event streams may finish
|
|
53
|
+
without yielding and the HTTP/SSE transport establishes quiet streams without
|
|
54
|
+
waiting for an event. Opening a transport subscription parses input, resolves
|
|
55
|
+
context, enters middleware, and invokes the subscriber before its promise
|
|
56
|
+
resolves and before an event response is committed. Their failures retain
|
|
57
|
+
ordinary HTTP statuses, while failures inside an async-generator body use SSE
|
|
58
|
+
error frames. Readable CLI commands append event presentations by default;
|
|
59
|
+
`--json` emits NDJSON without materializing presentations. Event-only capabilities
|
|
60
|
+
have no unary call signature and are excluded from React Query/SWR state
|
|
61
|
+
projections and automatic HTTP/OpenAPI, MCP, AI SDK, and Eve tool projections.
|
|
62
|
+
Explicit unsupported HTTP or tool metadata is rejected; use `false` to disable
|
|
63
|
+
that projection. `handler` plus `subscribe` still means replacement snapshots,
|
|
64
|
+
including an initial snapshot supplied by the subscriber itself.
|
|
65
|
+
|
|
66
|
+
**Breaking:** The App manifest protocol changes from `capable.capabilities.v3`
|
|
67
|
+
to `capable.capabilities.v4`. Update clients and servers together and regenerate
|
|
68
|
+
bundled manifests. Custom transports and manifest consumers must replace the
|
|
69
|
+
old optional subscription field with the required execution kind:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// Before (other capability fields omitted)
|
|
73
|
+
{ subscription: { mode: "replace" } }
|
|
74
|
+
|
|
75
|
+
// After
|
|
76
|
+
{ execution: "live" } // handler + subscribe
|
|
77
|
+
{ execution: "unary" } // handler only
|
|
78
|
+
{ execution: "events" } // subscribe only
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The rich-value codec remains `capable.rich-json.v1`; event values preserve Dates
|
|
82
|
+
just like existing calls and replacements.
|
|
83
|
+
|
|
84
|
+
**Breaking:** The sixth `CapabilityDefinition` type argument is now an execution
|
|
85
|
+
kind instead of a subscription boolean. For manually annotated definitions:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// Before
|
|
89
|
+
type Live = CapabilityDefinition<Context, Input, Output, Errors, Meta, true>;
|
|
90
|
+
// After
|
|
91
|
+
type Live = CapabilityDefinition<Context, Input, Output, Errors, Meta, "live">;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Replace `false` with `"unary"`, and `boolean` with `"unary" | "live"` when
|
|
95
|
+
describing the previous two forms. Prefer factory inference when possible.
|
|
96
|
+
App subscription helpers now accept `AppCapabilityReference`; event references
|
|
97
|
+
are not callable. `executeCapability()` accepts only callable definitions.
|
|
98
|
+
|
|
99
|
+
`ApplicationTransport.subscribe()` now returns a promise for the opened async
|
|
100
|
+
iterator. Custom transports should complete request setup before resolving it:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
async subscribe(call) {
|
|
104
|
+
const response = await openSubscription(call);
|
|
105
|
+
return decodeEvents(response);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 0.1.0-alpha.9
|
|
110
|
+
|
|
111
|
+
### Minor Changes
|
|
112
|
+
|
|
113
|
+
- 46cd32f: Add app-wide `middleware` and declared `errors` to `defineApp()`. App, group, and capability middleware now receive a readonly `capability` descriptor (`id` and optional `effect`) and `mode` (`"call"` or `"subscribe"`), enabling centralized auditing and access policies.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { defineApp } from "capable-kit";
|
|
117
|
+
|
|
118
|
+
const definition = defineApp({
|
|
119
|
+
capabilities: { todos },
|
|
120
|
+
middleware: [async ({ capability, mode, next }) => {
|
|
121
|
+
console.info({ capabilityId: capability.id, mode });
|
|
122
|
+
return next();
|
|
123
|
+
}],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Execution proceeds through app middleware, outer-to-inner groups, capability middleware, and the handler. Subscriptions use the same chain for their lifetime. Capability identity remains unchanged by composition or path aliases. Input validation and context creation happen before middleware; app middleware does not narrow handler context, and direct `executeCapability()` calls do not inherit app or group policies.
|
|
128
|
+
- 46cd32f: Improve CLI root-command help and execution. Bare invocation and `--help` show app help plus root arguments and options. `--json` and `--watch` execute a root capability even without positional arguments, applying input defaults or reporting required input. Multiple root capabilities produce a usage error; longer subcommands take precedence.
|
|
129
|
+
|
|
130
|
+
Configure a single-operation CLI with an empty command path:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
capability({
|
|
134
|
+
id: "analysis.url",
|
|
135
|
+
input: z.object({ url: z.string() }),
|
|
136
|
+
meta: { cli: { command: [], positional: ["url"] } },
|
|
137
|
+
handler: ({ input }) => analyzeURL(input.url),
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Add `markdown` rendering options to `createCli()` and `runCli()`, including watched presentations:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { createCli } from "capable-kit/cli";
|
|
145
|
+
|
|
146
|
+
const cli = createCli(app, {
|
|
147
|
+
markdown: { codeBox: false, tableBorder: "none", tableDense: true },
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Explicit markdown color and width override CLI rendering defaults in a TTY. Redirected output stays Markdown and `--json` returns canonical output.
|
|
152
|
+
- 46cd32f: **Breaking:** Replace `mergeApps()` with `composeApps()` from `capable-kit` (also exported from `capable-kit/app`). Update imports and calls:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
// Before
|
|
156
|
+
import { mergeApps } from "capable-kit";
|
|
157
|
+
const app = mergeApps(remote, local);
|
|
158
|
+
|
|
159
|
+
// After
|
|
160
|
+
import { composeApps } from "capable-kit";
|
|
161
|
+
const app = composeApps(remote, local);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Compose apps at the root or place them beneath named object branches:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
const app = composeApps(local, { integrations: { github, linear } });
|
|
168
|
+
await app.integrations.linear.issue({ id: "CAP-1" });
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Placement changes callable paths without changing capability IDs or execution ownership. Direct calls resolve only the relevant branch; surfaces that request a complete manifest still discover the whole composition. The same app can appear at multiple paths as aliases, and repeating it at the same path is deduplicated. Different apps claiming the same capability ID are rejected.
|
|
172
|
+
- 46cd32f: Add `createEveAgentAdapter()` in `capable-kit/eve` to expose a remote Eve agent as an app with `send`, `result`, and `cancel` capabilities. Bind clients and authorization to the authenticated caller in the host:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { createEveAgentAdapter } from "capable-kit/eve";
|
|
176
|
+
|
|
177
|
+
const agent = createEveAgentAdapter({ name: "research", client, authorize });
|
|
178
|
+
const { runId } = await agent.app.research.send({ message: "Research routing" });
|
|
179
|
+
await agent.app.research.send({ runId, message: "Focus on Next.js", wait: true });
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Run IDs are durable Eve session IDs, allowing later processes to resume a conversation. `send` supports waiting and answering typed questions; approvals remain host-owned. The adapter also supplies CLI messaging and presentation support. For an app exposed with invocation name `recipes`:
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
recipes research send "Research routing" --wait
|
|
186
|
+
recipes research send "Focus on Next.js" --run-id '<runId>' --wait
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Breaking:** The Eve peer dependency is now exactly `0.52.3`, and the AI SDK peer minimum rises from `^7.0.0` to `^7.0.82`. Consumers of these optional integrations must use compatible versions.
|
|
190
|
+
|
|
191
|
+
**Breaking:** `createEveTools()` now discovers tools at `session.started` instead of `step.started` and reconstructs durable callbacks after cold starts. Providers may run again using the current execution session. Keep App/provider definitions in deployed module code and data in persistent storage; do not rely on rediscovering the tool catalog on every step. Side effects must tolerate replay.
|
|
192
|
+
|
|
193
|
+
Before, the published Eve SDK alone was sufficient. Now, Eve 0.52.3 also needs the `defineDurableCallback` backport: apply the repository's [Eve patch](https://github.com/vercel-labs/capable/blob/5e6fcfe/patches/eve%400.52.3.patch) using your package manager's patch mechanism (see the [patch instructions](https://github.com/vercel-labs/capable/blob/5e6fcfe/patches/README.md)). Installing unpatched Eve 0.52.3 is insufficient, and installing capable-kit does not apply the repository's pnpm patch to a consumer project.
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- 46cd32f: Fix capability output inference for handlers that return a mix of synchronous values and promises. Typed named `toPresentation` renderers can appear before or after `handler` without losing output inference:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
import { capability } from "capable-kit";
|
|
201
|
+
|
|
202
|
+
const render = (result: { name: string }) => result.name;
|
|
203
|
+
const hello = capability({
|
|
204
|
+
id: "hello",
|
|
205
|
+
toPresentation: render,
|
|
206
|
+
handler: () => ({ name: "World" }),
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For inline renderers with inferred parameters, continue placing `toPresentation` after `handler`. No runtime migration is required.
|
|
211
|
+
- 46cd32f: Ship a versioned CHANGELOG.md with the npm package and link it from the bundled documentation and package reference. People and coding agents can read `node_modules/capable-kit/CHANGELOG.md` for features, fixes, and migration instructions. Release history starts with this release; earlier alpha changes are not reconstructed.
|
|
212
|
+
|
|
213
|
+
Release history is recorded here starting with the first release using Changesets.
|
|
214
|
+
Earlier alpha releases are not documented in this file.
|
package/README.md
CHANGED
|
@@ -84,6 +84,12 @@ Coding agents should start with
|
|
|
84
84
|
writing Capable code. The package also includes its original TypeScript source
|
|
85
85
|
under `src/` when a guide does not cover a lower-level API detail.
|
|
86
86
|
|
|
87
|
+
## Changes and upgrades
|
|
88
|
+
|
|
89
|
+
Read [CHANGELOG.md](./CHANGELOG.md) for versioned features, fixes, and breaking
|
|
90
|
+
changes. When upgrading, use the target version’s changelog and apply all entries
|
|
91
|
+
after your installed version through your target version, oldest first.
|
|
92
|
+
|
|
87
93
|
## Package contents
|
|
88
94
|
|
|
89
95
|
The published package includes compiled ESM in `dist/`, declaration files, the
|
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { M as CapabilityTree, a as CapabilityDefinition, j as CapabilityGroupDefinition, m as CapabilityOutput, t as AnyCapability, u as CapabilityInput } from "./index-WiBWfyTn.mjs";
|
|
2
|
+
import { d as AnyApp, p as AppCapabilities } from "./index-1A44jLuE.mjs";
|
|
3
3
|
import { Tool, ToolExecutionOptions } from "ai";
|
|
4
4
|
//#region packages/ai-sdk/src/index.d.ts
|
|
5
5
|
type AiSdkCapabilityMeta = false | {
|
|
@@ -21,7 +21,7 @@ type AiSdkCapabilityTool<TCapability extends AnyCapability> = WithoutExecute<Too
|
|
|
21
21
|
execute(input: CapabilityInput<TCapability>, options: ToolExecutionOptions<any>): Promise<CapabilityOutput<TCapability>>;
|
|
22
22
|
};
|
|
23
23
|
type WithoutExecute<TTool> = TTool extends unknown ? Omit<TTool, "execute"> : never;
|
|
24
|
-
type CapabilityToolEntry<TCapability extends AnyCapability, TPath extends string> = CapabilityToolName<TCapability, TPath> extends (infer TName extends string) ? { readonly [TKey in TName]: AiSdkCapabilityTool<TCapability>; } : {};
|
|
24
|
+
type CapabilityToolEntry<TCapability extends AnyCapability, TPath extends string> = TCapability["execution"] extends "events" ? {} : CapabilityToolName<TCapability, TPath> extends (infer TName extends string) ? { readonly [TKey in TName]: AiSdkCapabilityTool<TCapability>; } : {};
|
|
25
25
|
type AiSdkToolNode<TNode, TPath extends string> = TNode extends AnyCapability ? CapabilityToolEntry<TNode, TPath> : TNode extends CapabilityGroupDefinition<infer TCapabilities, any, any> ? AiSdkToolTree<TCapabilities, TPath> : TNode extends CapabilityTree ? AiSdkToolTree<TNode, TPath> : {};
|
|
26
26
|
type UnionToIntersection<TValue> = (TValue extends unknown ? (value: TValue) => void : never) extends ((value: infer TIntersection) => void) ? TIntersection : never;
|
|
27
27
|
type Simplify<TValue> = { readonly [TKey in keyof TValue]: TValue[TKey]; };
|
package/dist/ai-sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as getAppRuntime, h as flattenManifestCapabilities, i as getCapabilityDisplay } from "./src-DePlcG_t.mjs";
|
|
2
2
|
import { jsonSchema, tool } from "ai";
|
|
3
3
|
//#region packages/ai-sdk/src/index.ts
|
|
4
4
|
const emptyInputSchema = Object.freeze({
|
|
@@ -17,14 +17,19 @@ async function createAiSdkTools(app) {
|
|
|
17
17
|
const runtime = getAppRuntime(app);
|
|
18
18
|
const manifest = await runtime.manifest();
|
|
19
19
|
const tools = Object.create(null);
|
|
20
|
-
for (const capability of
|
|
20
|
+
for (const capability of flattenManifestCapabilities(manifest.capabilities)) {
|
|
21
|
+
const display = getCapabilityDisplay(capability);
|
|
21
22
|
const meta = capability.meta.aiSdk;
|
|
22
23
|
if (meta === false) continue;
|
|
24
|
+
if (capability.execution === "events") {
|
|
25
|
+
if (meta !== void 0) throw new Error(`Event Capability "${capability.id}" cannot be exposed as an AI SDK tool`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
23
28
|
const name = meta?.name ?? capability.path.join("__");
|
|
24
29
|
if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) throw new Error(`AI SDK tool name "${name}" is invalid; set meta.aiSdk.name to 1-64 letters, numbers, underscores, or hyphens`);
|
|
25
30
|
if (Object.hasOwn(tools, name)) throw new Error(`Duplicate AI SDK tool name "${name}"`);
|
|
26
31
|
tools[name] = tool({
|
|
27
|
-
description:
|
|
32
|
+
description: display.description ?? display.title ?? `Run the Capable Capability at ${capability.path.join(".")}.`,
|
|
28
33
|
inputSchema: toAiSdkSchema(capability.input ?? emptyInputSchema),
|
|
29
34
|
...capability.output ? { outputSchema: toAiSdkSchema(capability.output) } : {},
|
|
30
35
|
...meta?.strict === void 0 ? {} : { strict: meta.strict },
|
|
@@ -32,7 +37,7 @@ async function createAiSdkTools(app) {
|
|
|
32
37
|
capabilityId: capability.id,
|
|
33
38
|
path: [...capability.path],
|
|
34
39
|
deprecated: capability.deprecated,
|
|
35
|
-
...
|
|
40
|
+
...display.title ? { title: display.title } : {},
|
|
36
41
|
...capability.effect ? { effect: capability.effect } : {}
|
|
37
42
|
} },
|
|
38
43
|
async execute(input, { abortSignal }) {
|
|
@@ -49,9 +54,6 @@ async function createAiSdkTools(app) {
|
|
|
49
54
|
function toAiSdkSchema(schema) {
|
|
50
55
|
return jsonSchema(schema);
|
|
51
56
|
}
|
|
52
|
-
function flatten(nodes) {
|
|
53
|
-
return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
|
|
54
|
-
}
|
|
55
57
|
//#endregion
|
|
56
58
|
export { createAiSdkTools };
|
|
57
59
|
|
package/dist/ai-sdk.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-sdk.mjs","names":[],"sources":["../../ai-sdk/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n
|
|
1
|
+
{"version":3,"file":"ai-sdk.mjs","names":[],"sources":["../../ai-sdk/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n getCapabilityDisplay,\n flattenManifestCapabilities,\n type AnyApp,\n type AppCapabilities,\n type JsonSchema,\n} from \"@capable/app\";\nimport type {\n AnyCapability,\n CapabilityDefinition,\n CapabilityGroupDefinition,\n CapabilityInput,\n CapabilityMetaRegistry,\n CapabilityOutput,\n CapabilityTree,\n} from \"@capable/core\";\nimport {\n jsonSchema,\n tool,\n type JSONSchema7,\n type Tool,\n type ToolExecutionOptions,\n} from \"ai\";\n\nexport type AiSdkCapabilityMeta =\n | false\n | {\n readonly name?: string;\n readonly strict?: boolean;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly aiSdk?: AiSdkCapabilityMeta;\n }\n}\n\ntype JoinPath<TPrefix extends string, TKey extends string> =\n TPrefix extends \"\" ? TKey : `${TPrefix}__${TKey}`;\n\ntype CapabilityAiSdkMeta<TCapability extends AnyCapability> =\n TCapability extends CapabilityDefinition<any, any, any, any, infer TMeta, any>\n ? \"aiSdk\" extends keyof TMeta\n ? TMeta[\"aiSdk\"]\n : undefined\n : undefined;\n\ntype IsAny<TValue> = 0 extends (1 & TValue) ? true : false;\n\ntype CapabilityToolName<\n TCapability extends AnyCapability,\n TDefault extends string,\n> = IsAny<CapabilityAiSdkMeta<TCapability>> extends true\n ? TDefault\n : CapabilityAiSdkMeta<TCapability> extends false\n ? never\n : CapabilityAiSdkMeta<TCapability> extends {\n readonly name: infer TName extends string;\n }\n ? TName\n : TDefault;\n\nexport type AiSdkCapabilityTool<TCapability extends AnyCapability> =\n WithoutExecute<\n Tool<CapabilityInput<TCapability>, CapabilityOutput<TCapability>>\n > & {\n execute(\n input: CapabilityInput<TCapability>,\n options: ToolExecutionOptions<any>,\n ): Promise<CapabilityOutput<TCapability>>;\n };\n\ntype WithoutExecute<TTool> =\n TTool extends unknown ? Omit<TTool, \"execute\"> : never;\n\ntype CapabilityToolEntry<\n TCapability extends AnyCapability,\n TPath extends string,\n> = TCapability[\"execution\"] extends \"events\" ? {} : CapabilityToolName<TCapability, TPath> extends infer TName extends string\n ? { readonly [TKey in TName]: AiSdkCapabilityTool<TCapability> }\n : {};\n\ntype AiSdkToolNode<\n TNode,\n TPath extends string,\n> = TNode extends AnyCapability\n ? CapabilityToolEntry<TNode, TPath>\n : TNode extends CapabilityGroupDefinition<infer TCapabilities, any, any>\n ? AiSdkToolTree<TCapabilities, TPath>\n : TNode extends CapabilityTree\n ? AiSdkToolTree<TNode, TPath>\n : {};\n\ntype UnionToIntersection<TValue> =\n (TValue extends unknown ? (value: TValue) => void : never) extends\n (value: infer TIntersection) => void ? TIntersection : never;\n\ntype Simplify<TValue> = { readonly [TKey in keyof TValue]: TValue[TKey] };\n\ntype AiSdkToolTree<\n TTree extends CapabilityTree,\n TPrefix extends string = \"\",\n> = string extends keyof TTree\n ? Readonly<Record<string, AiSdkCapabilityTool<AnyCapability>>>\n : UnionToIntersection<\n {\n [TKey in Extract<keyof TTree, string>]: AiSdkToolNode<\n TTree[TKey],\n JoinPath<TPrefix, TKey>\n >;\n }[Extract<keyof TTree, string>]\n >;\n\nexport type AiSdkTools<TApp extends AnyApp> = Simplify<\n AiSdkToolTree<AppCapabilities<TApp>>\n>;\n\nconst emptyInputSchema: JsonSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\n/**\n * Projects an executable Capable App into an AI SDK v7 ToolSet.\n *\n * Tool names and input/output types are preserved when the App retains its\n * authored Capability tree type. Untyped remote Apps return a string-keyed tool\n * set with unknown inputs and outputs.\n */\nexport async function createAiSdkTools<const TApp extends AnyApp>(\n app: TApp,\n): Promise<AiSdkTools<TApp>> {\n const runtime = getAppRuntime(app);\n const manifest = await runtime.manifest();\n const tools: Record<string, Tool<any, any>> = Object.create(null);\n\n for (const capability of flattenManifestCapabilities(manifest.capabilities)) {\n const display = getCapabilityDisplay(capability);\n const meta = capability.meta.aiSdk as AiSdkCapabilityMeta | undefined;\n if (meta === false) continue;\n if (capability.execution === \"events\") {\n if (meta !== undefined) {\n throw new Error(\n `Event Capability \"${capability.id}\" cannot be exposed as an AI SDK tool`,\n );\n }\n continue;\n }\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `AI SDK tool name \"${name}\" is invalid; set meta.aiSdk.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (Object.hasOwn(tools, name)) {\n throw new Error(`Duplicate AI SDK tool name \"${name}\"`);\n }\n\n tools[name] = tool({\n description:\n display.description ??\n display.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: toAiSdkSchema(capability.input ?? emptyInputSchema),\n ...(capability.output\n ? { outputSchema: toAiSdkSchema(capability.output) }\n : {}),\n ...(meta?.strict === undefined ? {} : { strict: meta.strict }),\n metadata: {\n capable: {\n capabilityId: capability.id,\n path: [...capability.path],\n deprecated: capability.deprecated,\n ...(display.title ? { title: display.title } : {}),\n ...(capability.effect ? { effect: capability.effect } : {}),\n },\n },\n async execute(input, { abortSignal }) {\n const result = await runtime.call({\n id: capability.id,\n input,\n ...(abortSignal ? { signal: abortSignal } : {}),\n });\n return result.output;\n },\n });\n }\n\n return Object.freeze(tools) as AiSdkTools<TApp>;\n}\n\nfunction toAiSdkSchema(schema: JsonSchema) {\n return jsonSchema(schema as JSONSchema7);\n}\n"],"mappings":";;;AAsHA,MAAM,mBAA+B,OAAO,OAAO;CACjD,MAAM;CACN,YAAY,OAAO,OAAO,CAAC,CAAC;CAC5B,sBAAsB;AACxB,CAAC;;;;;;;;AASD,eAAsB,iBACpB,KAC2B;CAC3B,MAAM,UAAU,cAAc,GAAG;CACjC,MAAM,WAAW,MAAM,QAAQ,SAAS;CACxC,MAAM,QAAwC,OAAO,OAAO,IAAI;CAEhE,KAAK,MAAM,cAAc,4BAA4B,SAAS,YAAY,GAAG;EAC3E,MAAM,UAAU,qBAAqB,UAAU;EAC/C,MAAM,OAAO,WAAW,KAAK;EAC7B,IAAI,SAAS,OAAO;EACpB,IAAI,WAAW,cAAc,UAAU;GACrC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MACR,qBAAqB,WAAW,GAAG,sCACrC;GAEF;EACF;EAEA,MAAM,OAAO,MAAM,QAAQ,WAAW,KAAK,KAAK,IAAI;EACpD,IAAI,CAAC,wBAAwB,KAAK,IAAI,GACpC,MAAM,IAAI,MACR,qBAAqB,KAAK,oFAC5B;EAEF,IAAI,OAAO,OAAO,OAAO,IAAI,GAC3B,MAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;EAGxD,MAAM,QAAQ,KAAK;GACjB,aACE,QAAQ,eACR,QAAQ,SACR,iCAAiC,WAAW,KAAK,KAAK,GAAG,EAAE;GAC7D,aAAa,cAAc,WAAW,SAAS,gBAAgB;GAC/D,GAAI,WAAW,SACX,EAAE,cAAc,cAAc,WAAW,MAAM,EAAE,IACjD,CAAC;GACL,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;GAC5D,UAAU,EACR,SAAS;IACP,cAAc,WAAW;IACzB,MAAM,CAAC,GAAG,WAAW,IAAI;IACzB,YAAY,WAAW;IACvB,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;IAChD,GAAI,WAAW,SAAS,EAAE,QAAQ,WAAW,OAAO,IAAI,CAAC;GAC3D,EACF;GACA,MAAM,QAAQ,OAAO,EAAE,eAAe;IAMpC,QAAO,MALc,QAAQ,KAAK;KAChC,IAAI,WAAW;KACf;KACA,GAAI,cAAc,EAAE,QAAQ,YAAY,IAAI,CAAC;IAC/C,CAAC,EAAA,CACa;GAChB;EACF,CAAC;CACH;CAEA,OAAO,OAAO,OAAO,KAAK;AAC5B;AAEA,SAAS,cAAc,QAAoB;CACzC,OAAO,WAAW,MAAqB;AACzC"}
|
package/dist/app.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, type AnyApp, type App, type AppCapabilities, type AppCapabilityCall, type AppCapabilityIsSubscribable, type AppContextProvider, type ApplicationManifest, type ApplicationSelection, type ApplicationTransport, type CallableTree, type CapabilityCall, type CapabilityResult, type JsonSchema, type ManifestCapability, type ManifestError, type ManifestGroup, type ManifestNode, TransportError, createApp, createAppManifest, createRemoteApp, getAppRuntime,
|
|
1
|
+
import { A as JsonSchema, C as TransportError, D as isApp, E as getAppRuntime, F as createAppManifest, I as flattenManifestCapabilities, M as ManifestError, N as ManifestGroup, O as subscribe, P as ManifestNode, S as CapabilityResult, T as createRemoteApp, _ as AppCapabilityReference, a as CustomizedCapability, b as CallableTree, c as getCapabilityNavigationMeta, d as AnyApp, f as App, g as AppCapabilityIsSubscribable, h as AppCapabilityIsLive, i as CapabilityCustomization, j as ManifestCapability, k as ApplicationManifest, l as APP_CAPABILITIES_SYMBOL, m as AppCapabilityCall, n as composeApps, o as customize, p as AppCapabilities, r as selectApp, s as getCapabilityDisplay, t as ApplicationSelection, u as APP_RUNTIME_SYMBOL, v as AppContextProvider, w as createApp, x as CapabilityCall, y as ApplicationTransport } from "./index-1A44jLuE.mjs";
|
|
2
|
+
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, type AnyApp, type App, type AppCapabilities, type AppCapabilityCall, type AppCapabilityIsLive, type AppCapabilityIsSubscribable, type AppCapabilityReference, type AppContextProvider, type ApplicationManifest, type ApplicationSelection, type ApplicationTransport, type CallableTree, type CapabilityCall, type CapabilityCustomization, type CapabilityResult, type CustomizedCapability, type JsonSchema, type ManifestCapability, type ManifestError, type ManifestGroup, type ManifestNode, TransportError, composeApps, createApp, createAppManifest, createRemoteApp, customize, flattenManifestCapabilities, getAppRuntime, getCapabilityDisplay, getCapabilityNavigationMeta, isApp, selectApp, subscribe };
|
package/dist/app.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, TransportError, createApp, createAppManifest, createRemoteApp, getAppRuntime,
|
|
1
|
+
import { a as getCapabilityNavigationMeta, c as TransportError, d as getAppRuntime, f as isApp, h as flattenManifestCapabilities, i as getCapabilityDisplay, l as createApp, m as createAppManifest, n as selectApp, o as APP_CAPABILITIES_SYMBOL, p as subscribe, r as customize, s as APP_RUNTIME_SYMBOL, t as composeApps, u as createRemoteApp } from "./src-DePlcG_t.mjs";
|
|
2
|
+
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, TransportError, composeApps, createApp, createAppManifest, createRemoteApp, customize, flattenManifestCapabilities, getAppRuntime, getCapabilityDisplay, getCapabilityNavigationMeta, isApp, selectApp, subscribe };
|
package/dist/bin.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as APPLICATION_SYMBOL } from "./src-
|
|
3
|
-
import {
|
|
4
|
-
import { a as createCliStyle, c as renderSection, l as supportsColor, n as runCli, o as descriptionColumn, s as renderRows } from "./src-
|
|
5
|
-
import { n as createHttpTransport } from "./src-
|
|
2
|
+
import { t as APPLICATION_SYMBOL } from "./src-B2WeUwUT.mjs";
|
|
3
|
+
import { f as isApp, l as createApp, u as createRemoteApp } from "./src-DePlcG_t.mjs";
|
|
4
|
+
import { a as createCliStyle, c as renderSection, l as supportsColor, n as runCli, o as descriptionColumn, s as renderRows } from "./src-3LE9S4QE.mjs";
|
|
5
|
+
import { n as createHttpTransport } from "./src-_6OmFRYa.mjs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as AnyApp } from "./index-1A44jLuE.mjs";
|
|
2
|
+
import { RenderOptions } from "markdansi";
|
|
2
3
|
//#region packages/cli/src/style.d.ts
|
|
3
4
|
type CliStyle = {
|
|
4
5
|
readonly bold: (text: string) => string;
|
|
@@ -30,6 +31,11 @@ type CliCapabilityMeta = false | {
|
|
|
30
31
|
readonly command?: readonly string[];
|
|
31
32
|
readonly positional?: readonly string[];
|
|
32
33
|
};
|
|
34
|
+
declare global {
|
|
35
|
+
interface CapableCustomizationMeta {
|
|
36
|
+
readonly cli?: CliCapabilityMeta;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
33
39
|
type CliGroupMeta = {
|
|
34
40
|
readonly name?: string;
|
|
35
41
|
};
|
|
@@ -50,6 +56,7 @@ type CreateCliOptions = {
|
|
|
50
56
|
readonly color?: boolean;
|
|
51
57
|
readonly isTTY?: boolean;
|
|
52
58
|
readonly columns?: number;
|
|
59
|
+
readonly markdown?: RenderOptions;
|
|
53
60
|
};
|
|
54
61
|
declare function createCli(app: AnyApp, cliOptions?: CreateCliOptions): {
|
|
55
62
|
run(argv: readonly string[], options?: {
|
|
@@ -63,6 +70,7 @@ declare function runCli(options: {
|
|
|
63
70
|
readonly color?: boolean;
|
|
64
71
|
readonly isTTY?: boolean;
|
|
65
72
|
readonly columns?: number;
|
|
73
|
+
readonly markdown?: RenderOptions;
|
|
66
74
|
readonly io?: Partial<CliIo>;
|
|
67
75
|
}): Promise<number>;
|
|
68
76
|
//#endregion
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createCliStyle, c as renderSection, i as ROW_INDENT, l as supportsColor, n as runCli, o as descriptionColumn, r as MARGIN, s as renderRows, t as createCli } from "./src-
|
|
1
|
+
import { a as createCliStyle, c as renderSection, i as ROW_INDENT, l as supportsColor, n as runCli, o as descriptionColumn, r as MARGIN, s as renderRows, t as createCli } from "./src-3LE9S4QE.mjs";
|
|
2
2
|
export { MARGIN, ROW_INDENT, createCli, createCliStyle, descriptionColumn, renderRows, renderSection, runCli, supportsColor };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-
|
|
3
|
-
export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type FilePresentationPart, type GroupMetaRegistry, type ImagePresentationPart, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type MarkdownPresentationPart, type MaybePromise, type PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type Schema, SchemaValidationError, type SubscribableCapability, type SubscribeCapabilityOptions, type TablePresentationPart, type WatchQueryOptions, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, normalizePresentation, parseSchema, present, renderPresentationMarkdown, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
|
1
|
+
import { $ as CapabilityErrorContract, A as CAPABILITY_GROUP_SYMBOL, B as MarkdownPresentationPart, C as isCapability, D as AnyCapabilityGroup, E as APPLICATION_SYMBOL, F as defineApp, G as TablePresentationPart, H as PresentationRenderer, I as group, J as renderPresentationMarkdown, K as normalizePresentation, L as isCapabilityGroup, M as CapabilityTree, N as GroupMetaRegistry, O as AppContext, P as LocatedCapability, Q as CAPABILITY_ERRORS_SYMBOL, R as FilePresentationPart, S as executeLocatedCapability, T as subscribeLocatedCapability, U as PresentationTableCell, V as PresentationPart, W as PresentationValue, X as md, Y as MaybePromise, Z as AnyDefinedErrors, _ as ExecuteCapabilityOptions, a as CapabilityDefinition, at as defineErrors, b as capability, c as CapabilityFactory, ct as InferSchemaInput, d as CapabilityMetaRegistry, dt as SchemaValidationError, et as CapabilityErrorDefinition, f as CapabilityMiddleware, ft as parseSchema, g as CapabilitySubscriberArgs, h as CapabilitySubscriber, i as CapabilityContext, it as ErrorMetaRegistry, j as CapabilityGroupDefinition, k as AppDefinition, l as CapabilityHandlerArgs, lt as InferSchemaOutput, m as CapabilityOutput, n as CAPABILITY_SYMBOL, nt as CapableError, o as CapabilityEffect, ot as AnyObjectSchema, p as CapabilityMiddlewareArgs, pt as schemaToJsonSchema, q as present, r as CallableCapability, rt as DefinedErrors, s as CapabilityExecution, st as AnySchema, t as AnyCapability, tt as CapabilityErrorFactory, u as CapabilityInput, ut as Schema, v as SubscribableCapability, w as subscribeCapability, x as executeCapability, y as SubscribeCapabilityOptions, z as ImagePresentationPart } from "./index-WiBWfyTn.mjs";
|
|
2
|
+
import { n as watchQuery, t as WatchQueryOptions } from "./subscription-DPdwovhw.mjs";
|
|
3
|
+
export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CallableCapability, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityExecution, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type FilePresentationPart, type GroupMetaRegistry, type ImagePresentationPart, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type MarkdownPresentationPart, type MaybePromise, type PresentationPart, type PresentationRenderer, type PresentationTableCell, type PresentationValue, type Schema, SchemaValidationError, type SubscribableCapability, type SubscribeCapabilityOptions, type TablePresentationPart, type WatchQueryOptions, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, normalizePresentation, parseSchema, present, renderPresentationMarkdown, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
package/dist/core.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as defineErrors, _ as normalizePresentation, a as isCapabilityGroup, b as CAPABILITY_ERRORS_SYMBOL, c as executeCapability, d as subscribeCapability, f as subscribeLocatedCapability, g as watchQuery, h as schemaToJsonSchema, i as group, l as executeLocatedCapability, m as parseSchema, n as CAPABILITY_GROUP_SYMBOL, o as CAPABILITY_SYMBOL, p as SchemaValidationError, r as defineApp, s as capability, t as APPLICATION_SYMBOL, u as isCapability, v as present, x as CapableError, y as renderPresentationMarkdown } from "./src-
|
|
1
|
+
import { S as defineErrors, _ as normalizePresentation, a as isCapabilityGroup, b as CAPABILITY_ERRORS_SYMBOL, c as executeCapability, d as subscribeCapability, f as subscribeLocatedCapability, g as watchQuery, h as schemaToJsonSchema, i as group, l as executeLocatedCapability, m as parseSchema, n as CAPABILITY_GROUP_SYMBOL, o as CAPABILITY_SYMBOL, p as SchemaValidationError, r as defineApp, s as capability, t as APPLICATION_SYMBOL, u as isCapability, v as present, x as CapableError, y as renderPresentationMarkdown } from "./src-B2WeUwUT.mjs";
|
|
2
2
|
import { t as md } from "./projection-Cgq2u0Wt.mjs";
|
|
3
3
|
export { APPLICATION_SYMBOL, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, CapableError, SchemaValidationError, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, normalizePresentation, parseSchema, present, renderPresentationMarkdown, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
|
package/dist/eve.d.mts
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as CapabilityDefinition, rt as DefinedErrors, ut as Schema } from "./index-WiBWfyTn.mjs";
|
|
2
|
+
import { d as AnyApp, f as App, j as ManifestCapability } from "./index-1A44jLuE.mjs";
|
|
2
3
|
import { DynamicResolveContext, DynamicSentinel, ToolDefinition } from "eve/tools";
|
|
3
4
|
import { Approval } from "eve/tools/approval";
|
|
5
|
+
import { Client } from "eve/client";
|
|
6
|
+
//#region packages/eve/src/agent.d.ts
|
|
7
|
+
interface EveAgentQuestion {
|
|
8
|
+
requestId: string;
|
|
9
|
+
prompt: string;
|
|
10
|
+
display?: "confirmation" | "select" | "text" | undefined;
|
|
11
|
+
allowFreeform?: boolean | undefined;
|
|
12
|
+
options?: {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description?: string | undefined;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
}
|
|
18
|
+
type EveAgentData = string | number | boolean | null | EveAgentData[] | {
|
|
19
|
+
[key: string]: EveAgentData;
|
|
20
|
+
};
|
|
21
|
+
interface EveAgentResult {
|
|
22
|
+
status: "running" | "waiting" | "completed" | "failed" | "cancelled";
|
|
23
|
+
cursor: number;
|
|
24
|
+
eventCount: number;
|
|
25
|
+
requests: EveAgentQuestion[];
|
|
26
|
+
text?: string | undefined;
|
|
27
|
+
data?: EveAgentData | undefined;
|
|
28
|
+
dataOmitted?: boolean | undefined;
|
|
29
|
+
textTruncated?: boolean | undefined;
|
|
30
|
+
requiresHostInput?: boolean | undefined;
|
|
31
|
+
error?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
type AgentCapability<TInput extends Record<string, unknown>, TOutput, TParsed extends Record<string, unknown> = TInput> = CapabilityDefinition<undefined, Schema<TInput, TParsed>, TOutput, DefinedErrors<{}>, {}, "unary">;
|
|
34
|
+
type AgentCapabilities = {
|
|
35
|
+
send: AgentCapability<{
|
|
36
|
+
message: string;
|
|
37
|
+
runId?: string | undefined;
|
|
38
|
+
requestId?: string | undefined;
|
|
39
|
+
optionId?: string | undefined;
|
|
40
|
+
wait?: boolean | undefined;
|
|
41
|
+
timeoutMs?: number | undefined;
|
|
42
|
+
}, EveAgentResult & {
|
|
43
|
+
runId: string;
|
|
44
|
+
}>;
|
|
45
|
+
result: AgentCapability<{
|
|
46
|
+
runId: string;
|
|
47
|
+
cursor?: number | undefined;
|
|
48
|
+
}, EveAgentResult, {
|
|
49
|
+
runId: string;
|
|
50
|
+
cursor: number;
|
|
51
|
+
}>;
|
|
52
|
+
cancel: AgentCapability<{
|
|
53
|
+
runId: string;
|
|
54
|
+
turnId?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
status: "accepted" | "no_active_turn";
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
interface EveAgentAdapter<TName extends string> {
|
|
60
|
+
readonly app: App<{ [K in TName]: AgentCapabilities; }>;
|
|
61
|
+
/** Abort local requests without cancelling remote execution. */
|
|
62
|
+
dispose(): void;
|
|
63
|
+
}
|
|
64
|
+
type EveAgentOperation = "send" | "result" | "cancel";
|
|
65
|
+
interface EveAgentAdapterOptions<TName extends string> {
|
|
66
|
+
/** Namespace and capability ID prefix; unique within the composed App. */
|
|
67
|
+
readonly name: TName;
|
|
68
|
+
/** Host-configured client for ONE authenticated caller. Never share an adapter across callers. */
|
|
69
|
+
readonly client: Pick<Client, "sessions">;
|
|
70
|
+
/** Recheck host-owned authorization on every invocation, including reconstructed reads. Throw to deny. */
|
|
71
|
+
readonly authorize: (operation: EveAgentOperation, runId?: string) => void | Promise<void>;
|
|
72
|
+
readonly maxEventsPerRead?: number;
|
|
73
|
+
readonly readTimeoutMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Wrap Eve execution as a caller-scoped Capable App.
|
|
77
|
+
* Eve session IDs are run IDs. Every read reconstructs state from durable events.
|
|
78
|
+
*/
|
|
79
|
+
declare function createEveAgentAdapter<const TName extends string>(options: EveAgentAdapterOptions<TName>): EveAgentAdapter<TName>;
|
|
80
|
+
//#endregion
|
|
4
81
|
//#region packages/eve/src/index.d.ts
|
|
5
82
|
type EveCapabilityMeta = false | {
|
|
6
83
|
readonly name?: string;
|
|
@@ -18,11 +95,11 @@ type EveTool = ToolDefinition<Record<string, unknown>, unknown>;
|
|
|
18
95
|
/**
|
|
19
96
|
* Projects an executable Capable App into native, in-process Eve tools.
|
|
20
97
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
98
|
+
* Eve owns the live executor bindings and checkpoints each call and result.
|
|
99
|
+
* Session resolvers rebuild App bindings after a cold start. Define the App or
|
|
100
|
+
* provider in deployed module code and keep persistent data outside the process.
|
|
24
101
|
*/
|
|
25
102
|
declare function createEveTools(app: EveAppProvider, options?: CreateEveToolsOptions): DynamicSentinel<Record<string, EveTool>>;
|
|
26
103
|
//#endregion
|
|
27
|
-
export { CreateEveToolsOptions, EveAppProvider, EveCapabilityMeta, createEveTools };
|
|
104
|
+
export { CreateEveToolsOptions, type EveAgentAdapter, type EveAgentAdapterOptions, type EveAgentData, type EveAgentOperation, type EveAgentQuestion, type EveAgentResult, EveAppProvider, EveCapabilityMeta, createEveAgentAdapter, createEveTools };
|
|
28
105
|
//# sourceMappingURL=eve.d.mts.map
|