apps 0.0.1-beta.3 → 0.0.1-beta.31

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 (140) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-RN2MXB4R.js → chunk-3FJYVAE4.js} +128 -24
  4. package/js/chunk-4OKYLVU4.js +118 -0
  5. package/js/{chunk-LGIYBDWA.js → chunk-5DLG2FVN.js} +65 -1
  6. package/js/{chunk-PLCMJREA.js → chunk-5JVNM3CQ.js} +60 -20
  7. package/js/chunk-5XJR4XGW.js +254 -0
  8. package/js/{chunk-FZJOYIZO.js → chunk-6KG4DZD7.js} +1 -1
  9. package/js/{chunk-EVJUVWN2.js → chunk-6ZJ2H6P4.js} +2 -2
  10. package/js/{chunk-NQ3OMCA5.js → chunk-AUFVX4KM.js} +2 -2
  11. package/js/{chunk-D47C7KG5.js → chunk-AYM2FUI5.js} +2 -2
  12. package/js/{chunk-5MQZEB6Y.js → chunk-BGALSHLT.js} +37 -12
  13. package/js/{chunk-QKHR7BMF.js → chunk-CJY5X26R.js} +3 -3
  14. package/js/{chunk-M6ZRRIBI.js → chunk-DASNNAP4.js} +1 -1
  15. package/js/{chunk-ZCAMUXSG.js → chunk-ETLILMHY.js} +3 -4
  16. package/js/{chunk-FW5HBOIK.js → chunk-EXGKN554.js} +2005 -1710
  17. package/js/{chunk-SATWJKN6.js → chunk-FBBXFFFJ.js} +1 -1
  18. package/js/{chunk-JN55AYQH.js → chunk-FULRJSWU.js} +61 -32
  19. package/js/{chunk-HDTGZWP2.js → chunk-GG566OOE.js} +139 -32
  20. package/js/chunk-GZ4UHXRT.js +92 -0
  21. package/js/{chunk-YEJOQEII.js → chunk-HW3DPBZR.js} +45 -7
  22. package/js/{chunk-HDJH3RPR.js → chunk-MFHUR5SB.js} +2 -2
  23. package/js/{chunk-MYYEW3RA.js → chunk-N72RKJ5E.js} +984 -61
  24. package/js/{chunk-WFSQXYUT.js → chunk-NPGRURDG.js} +390 -18
  25. package/js/chunk-OD3KFKZD.js +1617 -0
  26. package/js/{chunk-FDNTX5QJ.js → chunk-OX233L7N.js} +2 -2
  27. package/js/{chunk-G7ZIRKMK.js → chunk-QYM4STZW.js} +118 -197
  28. package/js/chunk-RULZPNGP.js +801 -0
  29. package/js/{chunk-BMOIAIVR.js → chunk-UMCMZFXW.js} +49 -1
  30. package/js/{chunk-J7O55ZV7.js → chunk-W7F23NQ2.js} +419 -191
  31. package/js/chunk-WG5DFZFT.js +42 -0
  32. package/js/{chunk-T2LAZCAD.js → chunk-ZOY7PDMI.js} +1 -1
  33. package/js/client.js +120 -84
  34. package/js/contracts.js +110 -16
  35. package/js/effect.js +20 -20
  36. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  37. package/js/graphql.js +58 -54
  38. package/js/host.js +20 -20
  39. package/js/index.js +247 -204
  40. package/js/mcp/effect.js +24 -22
  41. package/js/mcp/stdio.js +35 -30
  42. package/js/mcp.js +105 -68
  43. package/js/openapi.js +4087 -1503
  44. package/js/react.js +3 -3
  45. package/js/skills/effect.js +5 -3
  46. package/js/skills.js +15 -15
  47. package/js/storage/facet.js +4 -4
  48. package/js/ui/auth/contracts.js +2 -2
  49. package/js/ui/auth.js +5 -5
  50. package/js/ui/contracts.js +5 -4
  51. package/js/ui/serving.js +8516 -214
  52. package/package.json +1 -1
  53. package/runtime.json +1 -1
  54. package/types/app-data/src/contracts/database.d.ts +33 -6
  55. package/types/app-data/src/implementation/schema.d.ts +2 -17
  56. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  57. package/types/apps/src/contracts/app.d.ts +7 -6
  58. package/types/apps/src/contracts/failure.d.ts +54 -0
  59. package/types/apps/src/contracts/graphql.d.ts +2 -1
  60. package/types/apps/src/contracts/host.d.ts +34 -11
  61. package/types/apps/src/contracts/mcp.d.ts +91 -10
  62. package/types/apps/src/contracts/network.d.ts +84 -0
  63. package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
  64. package/types/apps/src/contracts/openapi.d.ts +45 -9
  65. package/types/apps/src/contracts/operations.d.ts +5 -6
  66. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  67. package/types/apps/src/contracts/protocols/1.d.ts +251 -69
  68. package/types/apps/src/contracts/protocols/2.d.ts +710 -0
  69. package/types/apps/src/contracts/protocols/3.d.ts +716 -0
  70. package/types/apps/src/contracts/protocols/4.d.ts +1298 -0
  71. package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
  72. package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
  73. package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
  74. package/types/apps/src/contracts/protocols/8.d.ts +1119 -0
  75. package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
  76. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  77. package/types/apps/src/contracts/provider.d.ts +115 -10
  78. package/types/apps/src/contracts/router.d.ts +59 -0
  79. package/types/apps/src/contracts/skills.d.ts +18 -5
  80. package/types/apps/src/contracts/storage.d.ts +3 -3
  81. package/types/apps/src/contracts/ui.d.ts +18 -0
  82. package/types/apps/src/contracts/workflows.d.ts +34 -3
  83. package/types/apps/src/graphql.d.ts +1 -3
  84. package/types/apps/src/implementation/account-router.d.ts +12 -0
  85. package/types/apps/src/implementation/app.d.ts +5 -4
  86. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  87. package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
  88. package/types/apps/src/implementation/elicitation.d.ts +9 -9
  89. package/types/apps/src/implementation/failure-detail.d.ts +46 -0
  90. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  91. package/types/apps/src/implementation/graphql.d.ts +4 -3
  92. package/types/apps/src/implementation/input-problems.d.ts +4 -1
  93. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  94. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  95. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  96. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  97. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  98. package/types/apps/src/implementation/mcp.d.ts +52 -25
  99. package/types/apps/src/implementation/network.d.ts +16 -0
  100. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  101. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  102. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  103. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  104. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  105. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  106. package/types/apps/src/implementation/operations.d.ts +36 -3
  107. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  108. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  109. package/types/apps/src/implementation/provider.d.ts +19 -5
  110. package/types/apps/src/implementation/router-catalog.d.ts +224 -0
  111. package/types/apps/src/implementation/router.d.ts +68 -0
  112. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  113. package/types/apps/src/implementation/schema.d.ts +80 -1
  114. package/types/apps/src/implementation/skills.d.ts +2 -2
  115. package/types/apps/src/implementation/storage.d.ts +5 -3
  116. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  117. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  118. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  119. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  120. package/types/apps/src/implementation/ui-serving.d.ts +10 -4
  121. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  122. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  123. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  124. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  125. package/types/apps/src/index.d.ts +29 -11
  126. package/types/apps/src/mcp-stdio.d.ts +2 -5
  127. package/types/apps/src/mcp.d.ts +25 -5
  128. package/types/apps/src/openapi.d.ts +6 -6
  129. package/types/apps/src/skills.d.ts +4 -4
  130. package/types/telemetry/src/browser-operations.d.ts +5 -2
  131. package/types/telemetry/src/config.d.ts +2 -2
  132. package/types/utils/src/api-error.d.ts +48 -0
  133. package/js/chunk-PYUYJRSK.js +0 -93
  134. package/js/chunk-SWPD52J7.js +0 -35
  135. package/js/chunk-W7D7WVSY.js +0 -18
  136. package/js/chunk-Z5NMEGJN.js +0 -29
  137. package/js/chunk-ZJWDMTE3.js +0 -63
  138. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  139. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  140. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -0,0 +1,254 @@
1
+ import {
2
+ HostedTool,
3
+ RouterKey,
4
+ RouterMeta,
5
+ reservedRouterKeys
6
+ } from "./chunk-N72RKJ5E.js";
7
+ import {
8
+ decoderOf
9
+ } from "./chunk-NPGRURDG.js";
10
+ import {
11
+ Effect_exports,
12
+ Schema_exports
13
+ } from "./chunk-EXGKN554.js";
14
+
15
+ // src/implementation/authoring.ts
16
+ var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
17
+ var fromPromise = (callback) => (...args) => {
18
+ if (NativeCallback in callback) {
19
+ const native = callback[NativeCallback];
20
+ return native(...args);
21
+ }
22
+ return Effect_exports.tryPromise({ try: () => callback(...args), catch: (error) => error });
23
+ };
24
+ var toPromise = (operation, signal) => {
25
+ const native = (...args) => Effect_exports.suspend(() => {
26
+ if (signal === void 0) return operation(...args);
27
+ if (signal.aborted) return Effect_exports.interrupt;
28
+ const cancelled = Effect_exports.callback((resume) => {
29
+ if (signal.aborted) {
30
+ resume(Effect_exports.interrupt);
31
+ return;
32
+ }
33
+ const abort = () => resume(Effect_exports.interrupt);
34
+ signal.addEventListener("abort", abort, { once: true });
35
+ return Effect_exports.sync(() => signal.removeEventListener("abort", abort));
36
+ });
37
+ return Effect_exports.raceFirst(
38
+ cancelled,
39
+ Effect_exports.suspend(() => operation(...args))
40
+ );
41
+ });
42
+ return Object.assign((...args) => Effect_exports.runPromise(native(...args)), {
43
+ [NativeCallback]: native
44
+ });
45
+ };
46
+
47
+ // src/implementation/operations.ts
48
+ var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
49
+ var NativeRouterKey = /* @__PURE__ */ Symbol("apps.Router");
50
+ var operationDeclaration = (operation) => ({
51
+ kind: operation.kind,
52
+ [NativeOperation]: operation
53
+ });
54
+ var nativeOperation = (value) => {
55
+ if (typeof value !== "object" || value === null || !(NativeOperation in value)) return void 0;
56
+ return value[NativeOperation];
57
+ };
58
+ var operationOptions = (options) => {
59
+ const approval = options.approval;
60
+ return {
61
+ ...options.description === void 0 ? {} : { description: options.description },
62
+ ...options.title === void 0 ? {} : { title: options.title },
63
+ ...options.annotations === void 0 ? {} : { annotations: options.annotations },
64
+ ...options._meta === void 0 ? {} : { _meta: options._meta },
65
+ input: decoderOf(options.input),
66
+ ...approval === void 0 ? {} : {
67
+ approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
68
+ }
69
+ };
70
+ };
71
+ var approvedOperation = (operation, approval) => {
72
+ const copy = Object.defineProperties({}, Object.getOwnPropertyDescriptors(operation));
73
+ return Object.defineProperty(copy, "approval", {
74
+ enumerable: true,
75
+ value: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
76
+ });
77
+ };
78
+ var withApproval = (operation, approval) => ({
79
+ ...operation,
80
+ [NativeOperation]: approvedOperation(operation[NativeOperation], approval)
81
+ });
82
+ var toolAnnotations = (operation) => nativeOperation(operation)?.annotations;
83
+ var make = (kind, options, run) => operationDeclaration({
84
+ ...operationOptions(options),
85
+ kind,
86
+ // The host always validates JSON serialization, even without a stronger output declaration.
87
+ ...options.output === void 0 ? {} : { output: decoderOf(options.output) },
88
+ run: (context, input) => Effect_exports.tryPromise({
89
+ // SAFETY: defineApp checks the handler context against its requirements.
90
+ // The host validates account bindings and creates the matching storage facade.
91
+ try: () => run(context, input),
92
+ catch: (error) => error
93
+ })
94
+ });
95
+ var query = (options, run) => make("query", options, run);
96
+ var mutation = (options, run) => make("mutation", options, run);
97
+
98
+ // src/implementation/router.ts
99
+ var routerDeclaration = (node) => ({
100
+ [NativeRouterKey]: node
101
+ });
102
+ var nativeRouter = (value) => {
103
+ if (typeof value !== "object" || value === null || !(NativeRouterKey in value)) return void 0;
104
+ return value[NativeRouterKey];
105
+ };
106
+ var nativeNode = (value) => nativeOperation(value) ?? nativeRouter(value);
107
+ var metaOf = (options) => {
108
+ if (options === void 0) return void 0;
109
+ const defined = Object.fromEntries(
110
+ Object.entries(options).filter(([, value]) => value !== void 0)
111
+ );
112
+ return Object.keys(defined).length === 0 ? void 0 : Schema_exports.decodeUnknownSync(RouterMeta)(defined);
113
+ };
114
+ var mergeMeta = (base, override) => base === void 0 ? override : override === void 0 ? base : { ...base, ...override };
115
+ function router(children, options) {
116
+ const meta = metaOf(options);
117
+ const existing = nativeRouter(children);
118
+ if (existing !== void 0)
119
+ return routerDeclaration(
120
+ existing.kind === "router" ? { ...existing, ...withMeta(mergeMeta(existing.meta, meta)) } : { ...existing, ...withOverrides(mergeMeta(existing.overrides, meta)) }
121
+ );
122
+ const nodes = {};
123
+ for (const [key, value] of Object.entries(children)) {
124
+ if (reservedRouterKeys.has(key)) throw new Error(`Router key "${key}" is reserved`);
125
+ if (!Schema_exports.is(RouterKey)(key))
126
+ throw new Error(`Router key "${key}" must start with a letter or _ and contain no dots`);
127
+ const node = nativeNode(value);
128
+ if (node === void 0)
129
+ throw new Error(`Router key "${key}" must be a query, mutation or router`);
130
+ nodes[key] = node;
131
+ }
132
+ return routerDeclaration({ kind: "router", ...withMeta(meta), children: nodes });
133
+ }
134
+ var withMeta = (meta) => meta === void 0 ? {} : { meta };
135
+ var withOverrides = (overrides) => overrides === void 0 ? {} : { overrides };
136
+ var dynamicRouter = (source) => {
137
+ const meta = source.meta;
138
+ return routerDeclaration({
139
+ kind: "dynamic",
140
+ ...meta === void 0 ? {} : {
141
+ meta: () => fromPromise(async () => meta())().pipe(
142
+ Effect_exports.flatMap((options) => Schema_exports.decodeUnknownEffect(RouterMeta)(options))
143
+ )
144
+ },
145
+ list: () => fromPromise(async () => source.list())().pipe(
146
+ Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
147
+ ),
148
+ resolve: (name) => fromPromise(async () => source.resolve(name))().pipe(
149
+ Effect_exports.map((value) => {
150
+ if (value === void 0) return void 0;
151
+ const operation = nativeOperation(value);
152
+ if (operation === void 0) throw new Error("Expected an operation declaration");
153
+ return operation;
154
+ })
155
+ )
156
+ });
157
+ };
158
+ var joinPath = (path, name) => path === "" ? name : `${path}.${name}`;
159
+ var locate = (root, name) => {
160
+ if (root?.kind === "dynamic") return { kind: "dynamic", source: root, router: "", name };
161
+ let current = root;
162
+ let path = "";
163
+ let rest = name;
164
+ while (current !== void 0) {
165
+ const dot = rest.indexOf(".");
166
+ const key = dot < 0 ? rest : rest.slice(0, dot);
167
+ const child = Object.hasOwn(current.children, key) ? current.children[key] : void 0;
168
+ if (child === void 0) return void 0;
169
+ const remaining = dot < 0 ? void 0 : rest.slice(dot + 1);
170
+ switch (child.kind) {
171
+ case "query":
172
+ case "mutation":
173
+ return remaining === void 0 ? { kind: "operation", operation: child, router: path } : void 0;
174
+ case "dynamic":
175
+ return remaining === void 0 || remaining === "" ? void 0 : { kind: "dynamic", source: child, router: joinPath(path, key), name: remaining };
176
+ case "router":
177
+ if (remaining === void 0) return void 0;
178
+ current = child;
179
+ path = joinPath(path, key);
180
+ rest = remaining;
181
+ }
182
+ }
183
+ return void 0;
184
+ };
185
+ var declaredOperations = (root, path = "") => Object.entries(root?.children ?? {}).flatMap(([key, child]) => {
186
+ const name = joinPath(path, key);
187
+ switch (child.kind) {
188
+ case "query":
189
+ case "mutation":
190
+ return [{ name, router: path, operation: child }];
191
+ case "router":
192
+ return declaredOperations(child, name);
193
+ case "dynamic":
194
+ return [];
195
+ }
196
+ });
197
+ var withApprovals = (source, policy) => {
198
+ const native = nativeRouter(source);
199
+ if (native === void 0) throw new Error("withApprovals expects a router");
200
+ const operation = (node, name) => {
201
+ const approval = policy(operationDeclaration(node), name);
202
+ return approval === void 0 ? node : approvedOperation(node, approval);
203
+ };
204
+ const child = (node, name) => {
205
+ switch (node.kind) {
206
+ case "query":
207
+ case "mutation":
208
+ return operation(node, name);
209
+ case "router":
210
+ case "dynamic":
211
+ return walk(node, name);
212
+ }
213
+ };
214
+ const walk = (node, path) => node.kind === "dynamic" ? {
215
+ ...node,
216
+ resolve: (name) => node.resolve(name).pipe(
217
+ Effect_exports.flatMap(
218
+ (resolved) => resolved === void 0 ? Effect_exports.succeed(void 0) : Effect_exports.try({
219
+ try: () => operation(resolved, joinPath(path, name)),
220
+ catch: (error) => error
221
+ })
222
+ )
223
+ )
224
+ } : {
225
+ ...node,
226
+ children: Object.fromEntries(
227
+ Object.entries(node.children).map(([key, value]) => [
228
+ key,
229
+ child(value, joinPath(path, key))
230
+ ])
231
+ )
232
+ };
233
+ return routerDeclaration(walk(native, ""));
234
+ };
235
+
236
+ export {
237
+ fromPromise,
238
+ toPromise,
239
+ operationDeclaration,
240
+ nativeOperation,
241
+ withApproval,
242
+ toolAnnotations,
243
+ query,
244
+ mutation,
245
+ routerDeclaration,
246
+ nativeRouter,
247
+ mergeMeta,
248
+ router,
249
+ dynamicRouter,
250
+ joinPath,
251
+ locate,
252
+ declaredOperations,
253
+ withApprovals
254
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-FW5HBOIK.js";
3
+ } from "./chunk-EXGKN554.js";
4
4
 
5
5
  // src/contracts/storage.ts
6
6
  var StorageName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
@@ -3,7 +3,7 @@ import {
3
3
  invalidate,
4
4
  layer,
5
5
  mutation
6
- } from "./chunk-M6ZRRIBI.js";
6
+ } from "./chunk-DASNNAP4.js";
7
7
  import {
8
8
  Boolean,
9
9
  Cause,
@@ -158,7 +158,7 @@ import {
158
158
  void_2,
159
159
  whileLoop,
160
160
  zipRight
161
- } from "./chunk-FW5HBOIK.js";
161
+ } from "./chunk-EXGKN554.js";
162
162
  import {
163
163
  __export
164
164
  } from "./chunk-CZ7CSFO4.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  appSignInCallbackPath
3
- } from "./chunk-T2LAZCAD.js";
3
+ } from "./chunk-ZOY7PDMI.js";
4
4
  import {
5
5
  HttpServerResponse_exports
6
- } from "./chunk-QKHR7BMF.js";
6
+ } from "./chunk-CJY5X26R.js";
7
7
 
8
8
  // src/implementation/ui-auth.ts
9
9
  var appPrivateHeaders = {
@@ -3,14 +3,14 @@ import {
3
3
  CacheEntry,
4
4
  CacheError,
5
5
  cacheLimits
6
- } from "./chunk-LGIYBDWA.js";
6
+ } from "./chunk-5DLG2FVN.js";
7
7
  import {
8
8
  Clock_exports,
9
9
  Duration_exports,
10
10
  Effect_exports,
11
11
  Exit_exports,
12
12
  Schema_exports
13
- } from "./chunk-FW5HBOIK.js";
13
+ } from "./chunk-EXGKN554.js";
14
14
 
15
15
  // ../app-cache/src/index.ts
16
16
  var canonical = (value) => {
@@ -1,24 +1,32 @@
1
1
  import {
2
2
  CacheError
3
- } from "./chunk-LGIYBDWA.js";
3
+ } from "./chunk-5DLG2FVN.js";
4
4
  import {
5
5
  wrap
6
- } from "./chunk-WFSQXYUT.js";
6
+ } from "./chunk-NPGRURDG.js";
7
7
  import {
8
8
  JsonObject
9
- } from "./chunk-SATWJKN6.js";
9
+ } from "./chunk-FBBXFFFJ.js";
10
10
  import {
11
11
  Duration_exports,
12
12
  Effect_exports,
13
13
  Schema_exports
14
- } from "./chunk-FW5HBOIK.js";
14
+ } from "./chunk-EXGKN554.js";
15
15
 
16
16
  // src/implementation/catalog-cache.ts
17
+ var catalogScope = (options, invalid) => {
18
+ const { account, cache, headers } = options;
19
+ if (account === void 0)
20
+ return headers === void 0 ? Effect_exports.succeed(cache) : Effect_exports.fail(invalid());
21
+ if (cache === void 0) return Effect_exports.succeed(void 0);
22
+ return Effect_exports.try({ try: () => cache.forAccount(account), catch: invalid });
23
+ };
17
24
  var schema = (decoder) => wrap(decoder, false);
18
25
  var Manifest = Schema_exports.Struct({
19
26
  revision: Schema_exports.String,
20
27
  pages: Schema_exports.Int,
21
- summaries: Schema_exports.Int
28
+ summaries: Schema_exports.Int,
29
+ header: Schema_exports.optionalKey(JsonObject)
22
30
  });
23
31
  var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
24
32
  var catalogCache = (options) => Effect_exports.gen(function* () {
@@ -35,9 +43,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
35
43
  const retention = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor)) + Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor)) + 3e5;
36
44
  const local = yield* Effect_exports.cached(options.load());
37
45
  const refresh = (context) => Effect_exports.gen(function* () {
38
- const tools = yield* options.load(context);
46
+ const { tools, header } = yield* options.load(context);
39
47
  const digest = yield* invoke(
40
- () => crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(tools)))
48
+ () => crypto.subtle.digest(
49
+ "SHA-256",
50
+ new TextEncoder().encode(JSON.stringify({ tools, header: header ?? null }))
51
+ )
41
52
  );
42
53
  const revision = Array.from(
43
54
  new Uint8Array(digest),
@@ -104,7 +115,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
104
115
  yield* pageOut();
105
116
  yield* summaryOut();
106
117
  yield* flush();
107
- return { revision, pages: pages2, summaries };
118
+ return {
119
+ revision,
120
+ pages: pages2,
121
+ summaries,
122
+ ...header === void 0 ? {} : { header: yield* json(header) }
123
+ };
108
124
  });
109
125
  const getOptions = {
110
126
  key,
@@ -113,7 +129,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
113
129
  staleFor,
114
130
  load: (context) => Effect_exports.runPromise(refresh(context), { signal: context.signal })
115
131
  };
116
- const current = () => cache === void 0 ? Effect_exports.fail(new CacheError({ reason: "unavailable" })) : invoke(() => cache.get(getOptions));
132
+ let reading;
133
+ const current = () => cache === void 0 ? Effect_exports.fail(new CacheError({ reason: "unavailable" })) : invoke(
134
+ () => reading ??= cache.get(getOptions).finally(() => {
135
+ reading = void 0;
136
+ })
137
+ );
117
138
  if (options.revalidate) {
118
139
  if (cache === void 0) yield* local;
119
140
  else yield* invoke(() => cache.revalidate(getOptions));
@@ -140,14 +161,17 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
140
161
  return values;
141
162
  });
142
163
  const metadata = () => Effect_exports.gen(function* () {
143
- if (cache === void 0) return yield* local;
164
+ if (cache === void 0) return (yield* local).tools;
144
165
  const manifest = yield* current();
145
166
  return yield* pages(cache, manifest.revision, "page", manifest.pages, options.schema);
146
167
  });
147
168
  return {
148
169
  list: metadata,
170
+ /** The record stored with the current revision, if the source supplied one. */
171
+ header: () => cache === void 0 ? local.pipe(Effect_exports.map(({ header }) => header)) : current().pipe(Effect_exports.map((manifest) => manifest.header)),
149
172
  summaries: () => Effect_exports.gen(function* () {
150
- if (cache === void 0) return (yield* local).map((tool) => options.summary.of(tool));
173
+ if (cache === void 0)
174
+ return (yield* local).tools.map((tool) => options.summary.of(tool));
151
175
  const manifest = yield* current();
152
176
  return yield* pages(
153
177
  cache,
@@ -157,7 +181,7 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
157
181
  options.summary.schema
158
182
  );
159
183
  }),
160
- resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map((tools) => tools.find((tool) => tool.name === name))) : current().pipe(
184
+ resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map(({ tools }) => tools.find((tool) => tool.name === name))) : current().pipe(
161
185
  Effect_exports.flatMap(
162
186
  (manifest) => invoke(
163
187
  () => cache.read(part(manifest.revision, "tool", name), schema(options.schema))
@@ -168,5 +192,6 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
168
192
  });
169
193
 
170
194
  export {
195
+ catalogScope,
171
196
  catalogCache
172
197
  };
@@ -211,7 +211,7 @@ import {
211
211
  withFiber,
212
212
  withParentSpan,
213
213
  zero2 as zero
214
- } from "./chunk-FW5HBOIK.js";
214
+ } from "./chunk-EXGKN554.js";
215
215
  import {
216
216
  __export
217
217
  } from "./chunk-CZ7CSFO4.js";
@@ -4358,6 +4358,8 @@ export {
4358
4358
  bodyFormData,
4359
4359
  HttpClientRequest_exports,
4360
4360
  fromWeb2 as fromWeb,
4361
+ HttpServerResponse_exports,
4362
+ HttpServerRequest_exports,
4361
4363
  HttpTraceContext_exports,
4362
4364
  HttpClient,
4363
4365
  transformResponse,
@@ -4368,8 +4370,6 @@ export {
4368
4370
  TracerPropagationEnabled,
4369
4371
  layerMergedContext,
4370
4372
  HttpClient_exports,
4371
- HttpServerResponse_exports,
4372
- HttpServerRequest_exports,
4373
4373
  prefixPath,
4374
4374
  fromLiteral
4375
4375
  };
@@ -58,7 +58,7 @@ import {
58
58
  useSpan,
59
59
  void_2 as void_,
60
60
  withFiber
61
- } from "./chunk-FW5HBOIK.js";
61
+ } from "./chunk-EXGKN554.js";
62
62
 
63
63
  // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Reactivity.js
64
64
  var TypeId = "~effect/reactivity/Reactivity";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FetchHttpClient_exports
3
- } from "./chunk-HDJH3RPR.js";
3
+ } from "./chunk-MFHUR5SB.js";
4
4
  import {
5
5
  HttpBody_exports,
6
6
  HttpClient,
@@ -18,7 +18,7 @@ import {
18
18
  setBody,
19
19
  transformResponse,
20
20
  uint8Array
21
- } from "./chunk-QKHR7BMF.js";
21
+ } from "./chunk-CJY5X26R.js";
22
22
  import {
23
23
  Array as Array2,
24
24
  Boolean2 as Boolean,
@@ -125,7 +125,7 @@ import {
125
125
  withDefault2 as withDefault,
126
126
  withTracerEnabled,
127
127
  zero
128
- } from "./chunk-FW5HBOIK.js";
128
+ } from "./chunk-EXGKN554.js";
129
129
  import {
130
130
  __export
131
131
  } from "./chunk-CZ7CSFO4.js";
@@ -2508,7 +2508,6 @@ export {
2508
2508
  withRemoteSpan,
2509
2509
  invocationFetch,
2510
2510
  collectTelemetry,
2511
- TraceContext,
2512
2511
  externalTrace,
2513
2512
  traceLinks,
2514
2513
  pendingSpan