apps 0.0.1-beta.0 → 0.0.1-beta.1
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 +97 -4
- package/framework-reference.json +1 -1
- package/js/{chunk-BPEFS4YF.js → chunk-2HHMABB6.js} +70 -14
- package/js/{chunk-SBKHUC5L.js → chunk-4LPG6RCH.js} +2 -2
- package/js/{chunk-LOKGDT6B.js → chunk-6IIO4NPI.js} +5 -4
- package/js/chunk-6YBRWRK3.js +160 -0
- package/js/{chunk-7JXHF5IF.js → chunk-BMOIAIVR.js} +1 -1
- package/js/chunk-CZ7CSFO4.js +39 -0
- package/js/{chunk-YDR4CPJA.js → chunk-EVJUVWN2.js} +8 -8
- package/js/{chunk-2OTCEKL2.js → chunk-FW5HBOIK.js} +2352 -1493
- package/js/{chunk-EP6AEUZO.js → chunk-FZJOYIZO.js} +1 -1
- package/js/{chunk-WIDTG42X.js → chunk-G7IE6BKC.js} +79 -26
- package/js/{chunk-VFUZI3NY.js → chunk-HDJH3RPR.js} +4 -4
- package/js/{chunk-HP7E42X6.js → chunk-IHQ4ML7K.js} +693 -219
- package/js/{chunk-Q2FD5IBM.js → chunk-KOXMLKTM.js} +430 -41
- package/js/{chunk-D6BKYP2L.js → chunk-M6ZRRIBI.js} +4 -4
- package/js/chunk-NCYXZN2G.js +6274 -0
- package/js/{chunk-3ANFZFCV.js → chunk-OHRT55C4.js} +15 -15
- package/js/{chunk-R6JMJSVT.js → chunk-PLCMJREA.js} +2 -2
- package/js/{chunk-C24KEZXR.js → chunk-PZ36XMXW.js} +36 -2
- package/js/{chunk-W7Q5EOTS.js → chunk-QKHR7BMF.js} +32 -32
- package/js/{chunk-X3YBZCJW.js → chunk-RBAC33PQ.js} +59 -38
- package/js/{chunk-36DNRFZQ.js → chunk-SATWJKN6.js} +1 -1
- package/js/chunk-SWPD52J7.js +35 -0
- package/js/{chunk-BKVL7XAJ.js → chunk-TE4KO4HI.js} +1 -1
- package/js/chunk-W7D7WVSY.js +18 -0
- package/js/{chunk-KWTCHVLT.js → chunk-X7SFGU4Q.js} +47 -51
- package/js/chunk-YEJOQEII.js +104 -0
- package/js/{chunk-OWD2YICM.js → chunk-ZCAMUXSG.js} +116 -87
- package/js/chunk-ZJWDMTE3.js +63 -0
- package/js/chunk-ZTFQHGEB.js +80 -0
- package/js/client.js +11 -11
- package/js/contracts.js +81 -25
- package/js/effect.js +20 -15
- package/js/graphql.js +223 -121
- package/js/host.js +75 -19
- package/js/index.js +191 -51
- package/js/mcp/effect.js +24 -17
- package/js/mcp/stdio.js +22 -17
- package/js/mcp.js +109 -24
- package/js/openapi.js +43897 -143
- package/js/operations/approval.js +1 -1
- package/js/react.js +4 -4
- package/js/skills/effect.js +12 -0
- package/js/skills.js +857 -0
- package/js/storage/facet.js +7 -7
- package/js/ui/auth/contracts.js +6 -6
- package/js/ui/auth.js +8 -8
- package/js/ui/contracts.js +5 -5
- package/js/ui/serving.js +12 -12
- package/package.json +9 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +79 -0
- package/types/app-cache/src/index.d.ts +35 -0
- package/types/apps/src/contracts/api-response-error.d.ts +43 -0
- package/types/apps/src/contracts/app.d.ts +11 -0
- package/types/apps/src/contracts/cache.d.ts +41 -0
- package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
- package/types/apps/src/contracts/dynamic-tools.d.ts +13 -0
- package/types/apps/src/contracts/graphql.d.ts +18 -1
- package/types/apps/src/contracts/host.d.ts +200 -7
- package/types/apps/src/contracts/mcp.d.ts +3 -1
- package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
- package/types/apps/src/contracts/openapi-document.d.ts +53 -0
- package/types/apps/src/contracts/openapi.d.ts +150 -30
- package/types/apps/src/contracts/provider-error.d.ts +15 -0
- package/types/apps/src/contracts/provider.d.ts +18 -1
- package/types/apps/src/contracts/skills.d.ts +113 -0
- package/types/apps/src/contracts/swagger-client.d.ts +29 -0
- package/types/apps/src/graphql.d.ts +6 -6
- package/types/apps/src/host.d.ts +1 -0
- package/types/apps/src/implementation/account-operations.d.ts +122 -3
- package/types/apps/src/implementation/app.d.ts +1 -1
- package/types/apps/src/implementation/cache-session.d.ts +7 -0
- package/types/apps/src/implementation/cache.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +29 -0
- package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
- package/types/apps/src/implementation/dynamic-tools.d.ts +8 -0
- package/types/apps/src/implementation/elicitation.d.ts +12 -12
- package/types/apps/src/implementation/git.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +10 -0
- package/types/apps/src/implementation/graphql.d.ts +81 -3
- package/types/apps/src/implementation/inflate.d.ts +16 -0
- package/types/apps/src/implementation/input-problems.d.ts +3 -0
- package/types/apps/src/implementation/mcp-call.d.ts +3 -2
- package/types/apps/src/implementation/mcp-catalog.d.ts +12 -0
- package/types/apps/src/implementation/mcp-client.d.ts +9 -8
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
- package/types/apps/src/implementation/mcp.d.ts +39 -2
- package/types/apps/src/implementation/openapi-compile.d.ts +119 -0
- package/types/apps/src/implementation/openapi-document.d.ts +53 -0
- package/types/apps/src/implementation/openapi-request.d.ts +11 -4
- package/types/apps/src/implementation/openapi-source.d.ts +36 -0
- package/types/apps/src/implementation/openapi.d.ts +39 -3
- package/types/apps/src/implementation/provider-error.d.ts +10 -0
- package/types/apps/src/implementation/schema.d.ts +11 -5
- package/types/apps/src/implementation/skill-files.d.ts +10 -0
- package/types/apps/src/implementation/skills.d.ts +43 -0
- package/types/apps/src/index.d.ts +7 -0
- package/types/apps/src/mcp.d.ts +5 -5
- package/types/apps/src/openapi.d.ts +3 -1
- package/types/apps/src/skills.d.ts +72 -0
- package/types/telemetry/src/config.d.ts +2 -0
- package/js/chunk-22WRQZT7.js +0 -389
- package/js/chunk-MLKGABMK.js +0 -9
package/README.md
CHANGED
|
@@ -49,10 +49,24 @@ keep rebuilds repeatable. Apps with no `apps` dependency use the host's framewor
|
|
|
49
49
|
In this repository, playground workspaces use `"apps": "workspace:*"` for development;
|
|
50
50
|
replace that workspace reference with a released version before deployment.
|
|
51
51
|
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
`liveOpenapiOperations` reads an OpenAPI document through `ctx.cache`. Generated
|
|
53
|
+
imports retain a source URL, allowed origin, and static credential bindings in
|
|
54
|
+
`openapi.json`. The framework compiles a revision on a cache miss. It writes each
|
|
55
|
+
operation and shared schema before publishing the current revision. A warm call
|
|
56
|
+
reads that revision and the requested operation's schema dependencies. It does
|
|
57
|
+
not download, parse, or read the full catalog. `openapiOperations` remains the
|
|
58
|
+
lower-level helper for already normalized metadata.
|
|
59
|
+
`parameterDefaults` binds path, query or header values to the selected account.
|
|
60
|
+
Those parameters become optional and publish their value as the schema `default`;
|
|
61
|
+
an explicit value still wins.
|
|
62
|
+
|
|
63
|
+
The default refresh window is five minutes fresh plus five minutes stale.
|
|
64
|
+
`freshFor` and `staleFor` can change it. A stale read schedules a bounded refresh;
|
|
65
|
+
a failed refresh keeps the last successful revision until its stale window ends.
|
|
66
|
+
The source URL and static compilation configuration identify a shared source.
|
|
67
|
+
Accounts bind at execution time. Live documents cannot change credential
|
|
68
|
+
placement or send credentials to another origin. Editing generated source and
|
|
69
|
+
redeploying is required to change those static choices.
|
|
56
70
|
|
|
57
71
|
Authenticated templates use `provider.many()` and `accountOperations` from `apps`:
|
|
58
72
|
|
|
@@ -71,6 +85,12 @@ export default defineApp({ accounts: { service: provider.many() } }, async ({ ac
|
|
|
71
85
|
);
|
|
72
86
|
```
|
|
73
87
|
|
|
88
|
+
MCP and GraphQL helpers accept `cache: ctx.cache.forAccount(account)` (or
|
|
89
|
+
`ctx.cache` for a public source). They return `{ dynamicTools }`, cache remote
|
|
90
|
+
metadata, and compile only the selected tool. The defaults are five minutes fresh
|
|
91
|
+
plus five minutes stale. Use `freshFor` / `staleFor` to change the windows, or
|
|
92
|
+
`revalidate: true` to await a refresh. Tool results are never cached.
|
|
93
|
+
|
|
74
94
|
Each combined tool takes `{ accountId, input }`. `input` keeps the upstream shape;
|
|
75
95
|
`accountId` must identify a selected account that exposes that tool. Discovery
|
|
76
96
|
and validation remain specific to each account. An empty selection returns no
|
|
@@ -189,3 +209,76 @@ Local and self-host products run authored apps in Alchemy/workerd, using the
|
|
|
189
209
|
same Worker build format and app-data facets as Cloud. Host filesystem and
|
|
190
210
|
subprocess access are unavailable to app code. Agent `execute(code)` continues
|
|
191
211
|
to use OpenCode CodeMode.
|
|
212
|
+
|
|
213
|
+
## App cache and lazy sources
|
|
214
|
+
|
|
215
|
+
Every app context has `cache`. Keys must contain every input that changes the
|
|
216
|
+
result. The host adds app and build isolation. Use `forAccount(account)` for
|
|
217
|
+
private data; it also includes the current credential fingerprint. Use the
|
|
218
|
+
shared cache for public metadata that is identical across accounts.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
const projects = await ctx.cache.forAccount(ctx.accounts.service).get({
|
|
222
|
+
key: ["projects", region],
|
|
223
|
+
schema: array(object({ id: string(), name: string() })),
|
|
224
|
+
freshFor: "1 minute",
|
|
225
|
+
staleFor: "2 minutes",
|
|
226
|
+
load: async ({ fetch, signal }) => {
|
|
227
|
+
const response = await fetch(urlFor(region), { signal });
|
|
228
|
+
if (!response.ok) throw new Error("Project lookup failed");
|
|
229
|
+
return response.json();
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Use the loader's `fetch`, `signal`, and `cache` for background work. Their
|
|
235
|
+
lifetime can outlast the original request. Only successful, schema-valid JSON
|
|
236
|
+
is stored. Concurrent misses share a fenced lease. `invalidate(key)` revokes
|
|
237
|
+
both a cached value and an in-flight loader's right to publish it. Cache storage
|
|
238
|
+
is disposable and bounded: 2 MB per entry, 8 MB per write batch, 128 entries per
|
|
239
|
+
batch, 128 MB and 100,000 entries per app, and seven days of retention. Capacity
|
|
240
|
+
errors are explicit. Background refreshes have a 30-second deadline.
|
|
241
|
+
|
|
242
|
+
`read` and `readMany` read retained data without loading it. `write` stores
|
|
243
|
+
bounded JSON batches with a retention duration. These support immutable pieces
|
|
244
|
+
that must be stored before a manifest becomes visible.
|
|
245
|
+
|
|
246
|
+
`dynamicTools({ list, resolve })` separates descriptions from executable
|
|
247
|
+
operations. `list()` returns tool metadata with qualified names such as
|
|
248
|
+
`queries.getProject`. `resolve(name)` returns a query/mutation declaration or
|
|
249
|
+
`undefined`. The host validates input and applies approval policy after resolving
|
|
250
|
+
an operation. `accountOperations` preserves this separation. Static operations
|
|
251
|
+
can run without resolving the source; listings reject duplicate names.
|
|
252
|
+
|
|
253
|
+
Assign the resolver to the app's `dynamicTools` field. The helper returns only
|
|
254
|
+
`list` and `resolve`, never static query or mutation maps. Both static maps are
|
|
255
|
+
optional, so an app can contain only dynamic tools.
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
export default defineApp(
|
|
259
|
+
{ accounts: {} },
|
|
260
|
+
{
|
|
261
|
+
dynamicTools: dynamicTools({
|
|
262
|
+
list: async () => [
|
|
263
|
+
{
|
|
264
|
+
name: "queries.ping",
|
|
265
|
+
description: "Return pong",
|
|
266
|
+
inputSchema: { type: "object", properties: {} },
|
|
267
|
+
readOnly: true,
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
resolve: async (name) =>
|
|
271
|
+
name === "queries.ping" ? query({ input: object({}) }, async () => "pong") : undefined,
|
|
272
|
+
}),
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Names include `queries.` or `mutations.`. `list` describes available tools;
|
|
278
|
+
`resolve` returns the matching query or mutation declaration.
|
|
279
|
+
|
|
280
|
+
`ctx.cache.revalidate(options)` takes the same options as `get`, but always
|
|
281
|
+
awaits a refresh. Concurrent refreshes share a load. The previous value stays
|
|
282
|
+
available to ordinary readers while refresh runs, and a failed refresh does not
|
|
283
|
+
remove it. Use this at an explicit connection or user refresh boundary; it is
|
|
284
|
+
not a reason to refresh on every tool call.
|