apps 0.0.1-beta.1 → 0.0.1-beta.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/README.md +65 -43
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/{chunk-2HHMABB6.js → chunk-5T57N25Q.js} +61 -13
- package/js/{chunk-6IIO4NPI.js → chunk-72JNVHPK.js} +21 -9
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-X7SFGU4Q.js → chunk-CRDWFA74.js} +28 -9
- package/js/{chunk-G7IE6BKC.js → chunk-EPT3ZP52.js} +8 -8
- package/js/chunk-FL2QR3XW.js +507 -0
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-ZTFQHGEB.js → chunk-IPI4MFSN.js} +3 -5
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/chunk-NKLWZJLE.js +172 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/chunk-R3EV5FTO.js +97 -0
- package/js/{chunk-6YBRWRK3.js → chunk-RFVIONFX.js} +43 -14
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-KOXMLKTM.js → chunk-V5KNQVCT.js} +308 -316
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-IHQ4ML7K.js → chunk-WLE7WX2U.js} +554 -102
- package/js/{chunk-RBAC33PQ.js → chunk-YXQHV65J.js} +58 -83
- package/js/chunk-Z5M2LQOZ.js +209 -0
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +70 -15
- package/js/effect.js +19 -19
- package/js/es-APDZKREY.js +40968 -0
- package/js/graphql.js +34 -39
- package/js/host.js +23 -23
- package/js/index.js +199 -195
- package/js/mcp/effect.js +21 -21
- package/js/mcp/stdio.js +25 -25
- package/js/mcp.js +60 -44
- package/js/openapi.js +826 -41682
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -4
- package/js/skills.js +53 -17
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +9 -8
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +42 -2
- package/types/app-cache/src/index.d.ts +59 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/cache.d.ts +4 -1
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +34 -679
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +11 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
- package/types/apps/src/contracts/protocols/2.d.ts +668 -0
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
- package/types/apps/src/contracts/provider.d.ts +51 -5
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +17 -8
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/cache.d.ts +3 -1
- package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +3 -2
- package/types/apps/src/implementation/openapi-document.d.ts +0 -2
- package/types/apps/src/implementation/openapi-names.d.ts +18 -0
- package/types/apps/src/implementation/openapi-request.d.ts +0 -1
- package/types/apps/src/implementation/openapi-source.d.ts +7 -7
- package/types/apps/src/implementation/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider.d.ts +9 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +5 -6
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-serving.d.ts +4 -2
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +5 -4
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/skills.d.ts +6 -3
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
package/README.md
CHANGED
|
@@ -11,22 +11,22 @@ For local testing, install the tarball made by `bun run pack` in this directory.
|
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
import { defineApp } from "apps";
|
|
14
|
-
import {
|
|
14
|
+
import { mcpRouter } from "apps/mcp";
|
|
15
15
|
|
|
16
16
|
export default defineApp({ accounts: {} }, async ({ signal }) => ({
|
|
17
|
-
|
|
17
|
+
tools: await mcpRouter({
|
|
18
18
|
url: "https://mcp.deepwiki.com/mcp",
|
|
19
19
|
...(signal === undefined ? {} : { signal }),
|
|
20
|
-
})
|
|
20
|
+
}),
|
|
21
21
|
}));
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
| Import | Helper
|
|
25
|
-
| ---------------- |
|
|
26
|
-
| `apps/mcp` | `
|
|
27
|
-
| `apps/mcp/stdio` | `
|
|
28
|
-
| `apps/graphql` | `
|
|
29
|
-
| `apps/openapi` | `
|
|
24
|
+
| Import | Helper | App dependency |
|
|
25
|
+
| ---------------- | --------------- | --------------------------- |
|
|
26
|
+
| `apps/mcp` | `mcpRouter` | `@modelcontextprotocol/sdk` |
|
|
27
|
+
| `apps/mcp/stdio` | `stdioRouter` | `@modelcontextprotocol/sdk` |
|
|
28
|
+
| `apps/graphql` | `graphqlRouter` | `graphql` |
|
|
29
|
+
| `apps/openapi` | `openapiRouter` | None |
|
|
30
30
|
|
|
31
31
|
MCP and GraphQL are optional peers. Subpath imports isolate their module graphs;
|
|
32
32
|
optional peers keep unused libraries out of the dependency installation. The
|
|
@@ -43,18 +43,19 @@ Declare the needed peer in the deployed app's `package.json`, for example:
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Product runtimes compile authored source and declared dependencies inside workerd,
|
|
46
|
-
then retain the executable Worker modules.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
then retain the executable Worker modules. Every app declares the exact `apps`
|
|
47
|
+
version in `package.json`; it selects the framework for both server and browser
|
|
48
|
+
code and keeps rebuilds repeatable. A build without it fails and names the
|
|
49
|
+
version the host ships.
|
|
49
50
|
In this repository, playground workspaces use `"apps": "workspace:*"` for development;
|
|
50
51
|
replace that workspace reference with a released version before deployment.
|
|
51
52
|
|
|
52
|
-
`
|
|
53
|
+
`liveOpenapiRouter` reads an OpenAPI document through `ctx.cache`. Generated
|
|
53
54
|
imports retain a source URL, allowed origin, and static credential bindings in
|
|
54
55
|
`openapi.json`. The framework compiles a revision on a cache miss. It writes each
|
|
55
56
|
operation and shared schema before publishing the current revision. A warm call
|
|
56
57
|
reads that revision and the requested operation's schema dependencies. It does
|
|
57
|
-
not download, parse, or read the full catalog. `
|
|
58
|
+
not download, parse, or read the full catalog. `openapiRouter` remains the
|
|
58
59
|
lower-level helper for already normalized metadata.
|
|
59
60
|
`parameterDefaults` binds path, query or header values to the selected account.
|
|
60
61
|
Those parameters become optional and publish their value as the schema `default`;
|
|
@@ -68,25 +69,28 @@ Accounts bind at execution time. Live documents cannot change credential
|
|
|
68
69
|
placement or send credentials to another origin. Editing generated source and
|
|
69
70
|
redeploying is required to change those static choices.
|
|
70
71
|
|
|
71
|
-
Authenticated templates use `provider.many()` and `
|
|
72
|
+
Authenticated templates use `provider.many()` and `accountRouter` from `apps`:
|
|
72
73
|
|
|
73
74
|
```ts
|
|
74
|
-
export default defineApp(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
export default defineApp(
|
|
76
|
+
{ accounts: { service: provider.many() } },
|
|
77
|
+
async ({ accounts, signal }) => ({
|
|
78
|
+
tools: await accountRouter(
|
|
79
|
+
accounts.service,
|
|
80
|
+
(account) =>
|
|
81
|
+
mcpRouter({
|
|
82
|
+
url: "https://example.com/mcp",
|
|
83
|
+
headers: { Authorization: "Bearer " + account.fields.token },
|
|
84
|
+
signal,
|
|
85
|
+
}),
|
|
86
|
+
{ signal },
|
|
87
|
+
),
|
|
88
|
+
}),
|
|
85
89
|
);
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
MCP and GraphQL helpers accept `cache: ctx.cache.forAccount(account)` (or
|
|
89
|
-
`ctx.cache` for a public source). They return
|
|
93
|
+
`ctx.cache` for a public source). They return a dynamic router, cache remote
|
|
90
94
|
metadata, and compile only the selected tool. The defaults are five minutes fresh
|
|
91
95
|
plus five minutes stale. Use `freshFor` / `staleFor` to change the windows, or
|
|
92
96
|
`revalidate: true` to await a refresh. Tool results are never cached.
|
|
@@ -171,7 +175,7 @@ and [hosting notes](../../notes/app-ui.md).
|
|
|
171
175
|
|
|
172
176
|
## Webhooks
|
|
173
177
|
|
|
174
|
-
Expose `webhooks: { issueOpened }` beside
|
|
178
|
+
Expose `webhooks: { issueOpened }` beside `tools`. Each definition
|
|
175
179
|
has an `account` requirement, `config` and `state` schemas, and async `register`,
|
|
176
180
|
`handle`, and `unregister` callbacks. Register and unregister must be idempotent;
|
|
177
181
|
handle must verify the provider signature before acting.
|
|
@@ -243,39 +247,57 @@ errors are explicit. Background refreshes have a 30-second deadline.
|
|
|
243
247
|
bounded JSON batches with a retention duration. These support immutable pieces
|
|
244
248
|
that must be stored before a manifest becomes visible.
|
|
245
249
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
`
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
`
|
|
255
|
-
|
|
250
|
+
## Routers
|
|
251
|
+
|
|
252
|
+
An app's `tools` is a router. Keys form tool paths, and routers nest like tRPC's:
|
|
253
|
+
`router({ health, issues: router({ list, close }, { description }) })` exposes
|
|
254
|
+
`health`, `issues.list` and `issues.close`. Each query or mutation keeps its own
|
|
255
|
+
kind; names carry no `queries.` or `mutations.` prefix. Router options are
|
|
256
|
+
`title`, `description`, `instructions`, `icons` and `tags`. Instructions become a
|
|
257
|
+
skill named `tools` for the root router and `tools-<path>` below it, such as
|
|
258
|
+
`tools-issues`. Paths other than lowercase letters and digits get a slug and a
|
|
259
|
+
hash of the path, so names never collide. An authored skill with the same name
|
|
260
|
+
replaces the generated one. `router(source, options)` overrides a source's
|
|
261
|
+
metadata. Keys `__proto__`, `constructor` and `prototype` are reserved, and an
|
|
262
|
+
mutation can be mounted at only one path.
|
|
263
|
+
|
|
264
|
+
Protocol helpers return routers, so an app mounts several sources under keys.
|
|
265
|
+
`mcpRouter` takes its title, description, icons and instructions from the
|
|
266
|
+
server, and `liveOpenapiRouter` from the document's `info` and tags. `stdioRouter`,
|
|
267
|
+
`openapiRouter` and `graphqlRouter` carry no source metadata. A nested router that fails to load is reported on its own catalog entry;
|
|
268
|
+
the app's other tools still load. The root failing fails discovery.
|
|
269
|
+
|
|
270
|
+
`dynamicRouter({ list, resolve })` separates descriptions from executable
|
|
271
|
+
operations. `list()` returns tool metadata with names relative to the router,
|
|
272
|
+
such as `getProject`; names may contain dots. `resolve(name)` returns a
|
|
273
|
+
query/mutation declaration or `undefined`. The host validates input and applies
|
|
274
|
+
approval policy after resolving an operation. `accountRouter` preserves this
|
|
275
|
+
separation. Static operations run without resolving a source; listings reject
|
|
276
|
+
duplicate names.
|
|
256
277
|
|
|
257
278
|
```ts
|
|
258
279
|
export default defineApp(
|
|
259
280
|
{ accounts: {} },
|
|
260
281
|
{
|
|
261
|
-
|
|
282
|
+
tools: dynamicRouter({
|
|
262
283
|
list: async () => [
|
|
263
284
|
{
|
|
264
|
-
name: "
|
|
285
|
+
name: "ping",
|
|
265
286
|
description: "Return pong",
|
|
266
287
|
inputSchema: { type: "object", properties: {} },
|
|
267
288
|
readOnly: true,
|
|
268
289
|
},
|
|
269
290
|
],
|
|
270
291
|
resolve: async (name) =>
|
|
271
|
-
name === "
|
|
292
|
+
name === "ping" ? query({ input: object({}) }, async () => "pong") : undefined,
|
|
272
293
|
}),
|
|
273
294
|
},
|
|
274
295
|
);
|
|
275
296
|
```
|
|
276
297
|
|
|
277
|
-
|
|
278
|
-
`resolve` returns the matching
|
|
298
|
+
Mark queries with `readOnly: true`; other listed tools are mutations. `list`
|
|
299
|
+
describes available tools; `resolve` returns the matching declaration. An
|
|
300
|
+
optional `meta()` returns the router's title, description and instructions.
|
|
279
301
|
|
|
280
302
|
`ctx.cache.revalidate(options)` takes the same options as `get`, but always
|
|
281
303
|
awaits a refresh. Concurrent refreshes share a load. The previous value stays
|