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.
Files changed (106) hide show
  1. package/README.md +97 -4
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-BPEFS4YF.js → chunk-2HHMABB6.js} +70 -14
  4. package/js/{chunk-SBKHUC5L.js → chunk-4LPG6RCH.js} +2 -2
  5. package/js/{chunk-LOKGDT6B.js → chunk-6IIO4NPI.js} +5 -4
  6. package/js/chunk-6YBRWRK3.js +160 -0
  7. package/js/{chunk-7JXHF5IF.js → chunk-BMOIAIVR.js} +1 -1
  8. package/js/chunk-CZ7CSFO4.js +39 -0
  9. package/js/{chunk-YDR4CPJA.js → chunk-EVJUVWN2.js} +8 -8
  10. package/js/{chunk-2OTCEKL2.js → chunk-FW5HBOIK.js} +2352 -1493
  11. package/js/{chunk-EP6AEUZO.js → chunk-FZJOYIZO.js} +1 -1
  12. package/js/{chunk-WIDTG42X.js → chunk-G7IE6BKC.js} +79 -26
  13. package/js/{chunk-VFUZI3NY.js → chunk-HDJH3RPR.js} +4 -4
  14. package/js/{chunk-HP7E42X6.js → chunk-IHQ4ML7K.js} +693 -219
  15. package/js/{chunk-Q2FD5IBM.js → chunk-KOXMLKTM.js} +430 -41
  16. package/js/{chunk-D6BKYP2L.js → chunk-M6ZRRIBI.js} +4 -4
  17. package/js/chunk-NCYXZN2G.js +6274 -0
  18. package/js/{chunk-3ANFZFCV.js → chunk-OHRT55C4.js} +15 -15
  19. package/js/{chunk-R6JMJSVT.js → chunk-PLCMJREA.js} +2 -2
  20. package/js/{chunk-C24KEZXR.js → chunk-PZ36XMXW.js} +36 -2
  21. package/js/{chunk-W7Q5EOTS.js → chunk-QKHR7BMF.js} +32 -32
  22. package/js/{chunk-X3YBZCJW.js → chunk-RBAC33PQ.js} +59 -38
  23. package/js/{chunk-36DNRFZQ.js → chunk-SATWJKN6.js} +1 -1
  24. package/js/chunk-SWPD52J7.js +35 -0
  25. package/js/{chunk-BKVL7XAJ.js → chunk-TE4KO4HI.js} +1 -1
  26. package/js/chunk-W7D7WVSY.js +18 -0
  27. package/js/{chunk-KWTCHVLT.js → chunk-X7SFGU4Q.js} +47 -51
  28. package/js/chunk-YEJOQEII.js +104 -0
  29. package/js/{chunk-OWD2YICM.js → chunk-ZCAMUXSG.js} +116 -87
  30. package/js/chunk-ZJWDMTE3.js +63 -0
  31. package/js/chunk-ZTFQHGEB.js +80 -0
  32. package/js/client.js +11 -11
  33. package/js/contracts.js +81 -25
  34. package/js/effect.js +20 -15
  35. package/js/graphql.js +223 -121
  36. package/js/host.js +75 -19
  37. package/js/index.js +191 -51
  38. package/js/mcp/effect.js +24 -17
  39. package/js/mcp/stdio.js +22 -17
  40. package/js/mcp.js +109 -24
  41. package/js/openapi.js +43897 -143
  42. package/js/operations/approval.js +1 -1
  43. package/js/react.js +4 -4
  44. package/js/skills/effect.js +12 -0
  45. package/js/skills.js +857 -0
  46. package/js/storage/facet.js +7 -7
  47. package/js/ui/auth/contracts.js +6 -6
  48. package/js/ui/auth.js +8 -8
  49. package/js/ui/contracts.js +5 -5
  50. package/js/ui/serving.js +12 -12
  51. package/package.json +9 -1
  52. package/runtime.json +1 -1
  53. package/types/app-cache/src/contracts/cache.d.ts +79 -0
  54. package/types/app-cache/src/index.d.ts +35 -0
  55. package/types/apps/src/contracts/api-response-error.d.ts +43 -0
  56. package/types/apps/src/contracts/app.d.ts +11 -0
  57. package/types/apps/src/contracts/cache.d.ts +41 -0
  58. package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
  59. package/types/apps/src/contracts/dynamic-tools.d.ts +13 -0
  60. package/types/apps/src/contracts/graphql.d.ts +18 -1
  61. package/types/apps/src/contracts/host.d.ts +200 -7
  62. package/types/apps/src/contracts/mcp.d.ts +3 -1
  63. package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
  64. package/types/apps/src/contracts/openapi-document.d.ts +53 -0
  65. package/types/apps/src/contracts/openapi.d.ts +150 -30
  66. package/types/apps/src/contracts/provider-error.d.ts +15 -0
  67. package/types/apps/src/contracts/provider.d.ts +18 -1
  68. package/types/apps/src/contracts/skills.d.ts +113 -0
  69. package/types/apps/src/contracts/swagger-client.d.ts +29 -0
  70. package/types/apps/src/graphql.d.ts +6 -6
  71. package/types/apps/src/host.d.ts +1 -0
  72. package/types/apps/src/implementation/account-operations.d.ts +122 -3
  73. package/types/apps/src/implementation/app.d.ts +1 -1
  74. package/types/apps/src/implementation/cache-session.d.ts +7 -0
  75. package/types/apps/src/implementation/cache.d.ts +6 -0
  76. package/types/apps/src/implementation/catalog-cache.d.ts +29 -0
  77. package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
  78. package/types/apps/src/implementation/dynamic-tools.d.ts +8 -0
  79. package/types/apps/src/implementation/elicitation.d.ts +12 -12
  80. package/types/apps/src/implementation/git.d.ts +25 -0
  81. package/types/apps/src/implementation/graphql-catalog.d.ts +10 -0
  82. package/types/apps/src/implementation/graphql.d.ts +81 -3
  83. package/types/apps/src/implementation/inflate.d.ts +16 -0
  84. package/types/apps/src/implementation/input-problems.d.ts +3 -0
  85. package/types/apps/src/implementation/mcp-call.d.ts +3 -2
  86. package/types/apps/src/implementation/mcp-catalog.d.ts +12 -0
  87. package/types/apps/src/implementation/mcp-client.d.ts +9 -8
  88. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  89. package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
  90. package/types/apps/src/implementation/mcp.d.ts +39 -2
  91. package/types/apps/src/implementation/openapi-compile.d.ts +119 -0
  92. package/types/apps/src/implementation/openapi-document.d.ts +53 -0
  93. package/types/apps/src/implementation/openapi-request.d.ts +11 -4
  94. package/types/apps/src/implementation/openapi-source.d.ts +36 -0
  95. package/types/apps/src/implementation/openapi.d.ts +39 -3
  96. package/types/apps/src/implementation/provider-error.d.ts +10 -0
  97. package/types/apps/src/implementation/schema.d.ts +11 -5
  98. package/types/apps/src/implementation/skill-files.d.ts +10 -0
  99. package/types/apps/src/implementation/skills.d.ts +43 -0
  100. package/types/apps/src/index.d.ts +7 -0
  101. package/types/apps/src/mcp.d.ts +5 -5
  102. package/types/apps/src/openapi.d.ts +3 -1
  103. package/types/apps/src/skills.d.ts +72 -0
  104. package/types/telemetry/src/config.d.ts +2 -0
  105. package/js/chunk-22WRQZT7.js +0 -389
  106. 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
- `openapiOperations` accepts normalized operations from the template generator,
53
- credential placement metadata, and an optional selected account. It does not
54
- parse a raw OpenAPI specification. `packages/app-templates` owns that compiler.
55
- No extra OpenAPI parser is installed in the app.
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.