apps 0.0.1-beta.7 → 0.0.1-beta.70

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 (178) hide show
  1. package/README.md +25 -22
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-UESPOTUI.js → chunk-2YSTJMBD.js} +899 -190
  4. package/js/{chunk-RJDDBDSN.js → chunk-3CVQ3VPP.js} +762 -171
  5. package/js/chunk-3R3KFCDU.js +426 -0
  6. package/js/{chunk-FL2QR3XW.js → chunk-4NCIPADO.js} +326 -69
  7. package/js/chunk-5FHWNLCI.js +88 -0
  8. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  9. package/js/chunk-7LMU3ER3.js +274 -0
  10. package/js/chunk-CDXQDN7W.js +92 -0
  11. package/js/{chunk-RFVIONFX.js → chunk-ECCWT5GJ.js} +79 -41
  12. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  13. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  14. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  15. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  16. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  17. package/js/{chunk-WLE7WX2U.js → chunk-JW5LYSER.js} +2262 -474
  18. package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
  19. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  20. package/js/chunk-M5OLYYNU.js +347 -0
  21. package/js/chunk-MHB7IFG7.js +49 -0
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/{chunk-NKLWZJLE.js → chunk-RUP4JMKO.js} +25 -14
  25. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  26. package/js/{chunk-72JNVHPK.js → chunk-WDIVWSDG.js} +4 -3
  27. package/js/{chunk-CMYUWAX7.js → chunk-WGQP62EG.js} +126 -31
  28. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  29. package/js/{chunk-Z5M2LQOZ.js → chunk-ZEJ3IKEC.js} +67 -55
  30. package/js/chunk-ZR7QAG67.js +171 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +125 -26
  33. package/js/effect.js +19 -19
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +50 -40
  36. package/js/host.js +83 -58
  37. package/js/index.js +131 -46
  38. package/js/mcp/effect.js +23 -21
  39. package/js/mcp/stdio.js +44 -34
  40. package/js/mcp.js +76 -53
  41. package/js/openapi.js +4063 -1359
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -81
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +3 -4
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/contracts/cache.d.ts +2 -0
  53. package/types/app-cache/src/index.d.ts +10 -1
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +7 -3
  56. package/types/apps/src/contracts/cache.d.ts +20 -0
  57. package/types/apps/src/contracts/context.d.ts +19 -11
  58. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  59. package/types/apps/src/contracts/events.d.ts +93 -0
  60. package/types/apps/src/contracts/failure.d.ts +30 -1
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +641 -16
  63. package/types/apps/src/contracts/live.d.ts +2 -0
  64. package/types/apps/src/contracts/mcp.d.ts +80 -10
  65. package/types/apps/src/contracts/network.d.ts +120 -0
  66. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  67. package/types/apps/src/contracts/openapi.d.ts +41 -9
  68. package/types/apps/src/contracts/operations.d.ts +8 -4
  69. package/types/apps/src/contracts/placement.d.ts +102 -0
  70. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  71. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  72. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  73. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  74. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  75. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  76. package/types/apps/src/contracts/protocols/5.d.ts +157 -47
  77. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  78. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  79. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  80. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  81. package/types/apps/src/contracts/protocols/current.d.ts +3842 -0
  82. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  83. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  84. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  85. package/types/apps/src/contracts/provider.d.ts +90 -6
  86. package/types/apps/src/contracts/skills.d.ts +50 -13
  87. package/types/apps/src/contracts/sql.d.ts +63 -0
  88. package/types/apps/src/contracts/ui.d.ts +19 -1
  89. package/types/apps/src/contracts/workflows.d.ts +6 -0
  90. package/types/apps/src/facet.d.ts +4 -5
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +4 -3
  93. package/types/apps/src/implementation/authoring.d.ts +25 -5
  94. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  95. package/types/apps/src/implementation/cache.d.ts +4 -0
  96. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  97. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  98. package/types/apps/src/implementation/events.d.ts +59 -0
  99. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  100. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  101. package/types/apps/src/implementation/graphql.d.ts +4 -3
  102. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  103. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  104. package/types/apps/src/implementation/live.d.ts +2 -2
  105. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  106. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  107. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  108. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  109. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  110. package/types/apps/src/implementation/mcp.d.ts +20 -9
  111. package/types/apps/src/implementation/network.d.ts +16 -0
  112. package/types/apps/src/implementation/openapi-compile.d.ts +26 -6
  113. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  114. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  115. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  116. package/types/apps/src/implementation/openapi-source.d.ts +18 -0
  117. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  118. package/types/apps/src/implementation/operations.d.ts +17 -2
  119. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  120. package/types/apps/src/implementation/placement.d.ts +60 -0
  121. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +18 -3
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +11 -13
  126. package/types/apps/src/implementation/router.d.ts +16 -5
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +90 -10
  129. package/types/apps/src/implementation/skills.d.ts +18 -24
  130. package/types/apps/src/implementation/sql.d.ts +71 -0
  131. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  132. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  133. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  134. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  135. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  136. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  137. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  138. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  139. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  140. package/types/apps/src/implementation/workflows.d.ts +1 -1
  141. package/types/apps/src/index.d.ts +55 -13
  142. package/types/apps/src/mcp.d.ts +20 -1
  143. package/types/apps/src/openapi.d.ts +1 -1
  144. package/types/apps/src/react.d.ts +1 -1
  145. package/types/apps/src/skills.d.ts +10 -8
  146. package/types/telemetry/src/app-records.d.ts +42 -0
  147. package/types/telemetry/src/browser-operations.d.ts +7 -4
  148. package/types/telemetry/src/browser.d.ts +8 -3
  149. package/types/telemetry/src/config.d.ts +2 -2
  150. package/types/telemetry/src/index.d.ts +2 -1
  151. package/types/telemetry/src/layer.d.ts +2 -2
  152. package/types/telemetry/src/measurements.d.ts +1 -1
  153. package/types/telemetry/src/ownership.d.ts +56 -0
  154. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  155. package/types/telemetry/src/relay.d.ts +16 -6
  156. package/types/telemetry/src/span-attributes.d.ts +17 -1
  157. package/types/telemetry/src/transport.d.ts +8 -1
  158. package/types/utils/src/api-error.d.ts +55 -0
  159. package/types/utils/src/connection-failure.d.ts +33 -0
  160. package/types/utils/src/recorded-message.d.ts +18 -0
  161. package/types/utils/src/user-facing-error.d.ts +83 -0
  162. package/js/chunk-MKWZPDR6.js +0 -63
  163. package/js/chunk-N7YDVXYJ.js +0 -186
  164. package/js/chunk-OCYUEU47.js +0 -224
  165. package/js/chunk-PJJ24GU7.js +0 -877
  166. package/js/chunk-PZB6T6KU.js +0 -19
  167. package/js/chunk-R3EV5FTO.js +0 -97
  168. package/js/chunk-YXQHV65J.js +0 -242
  169. package/js/chunk-ZQINWV4W.js +0 -630
  170. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  171. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  172. package/types/app-data/src/implementation/promise.d.ts +0 -68
  173. package/types/app-data/src/implementation/range.d.ts +0 -8
  174. package/types/app-data/src/implementation/schema.d.ts +0 -18
  175. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  176. package/types/app-data/src/index.d.ts +0 -4
  177. package/types/apps/src/contracts/storage.d.ts +0 -68
  178. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  FetchHttpClient_exports
3
- } from "./chunk-57RKNWL2.js";
3
+ } from "./chunk-PD6I2SDG.js";
4
+ import {
5
+ recordedMessage
6
+ } from "./chunk-5FHWNLCI.js";
4
7
  import {
5
8
  HttpBody_exports,
6
9
  HttpClient,
@@ -16,17 +19,21 @@ import {
16
19
  post,
17
20
  retryTransient,
18
21
  setBody,
22
+ tap,
23
+ tapError,
19
24
  transformResponse,
20
25
  uint8Array
21
- } from "./chunk-UK573G7W.js";
26
+ } from "./chunk-EOPQ727L.js";
22
27
  import {
23
28
  Array as Array2,
24
29
  Boolean2 as Boolean,
30
+ Cause_exports,
25
31
  Clock,
26
32
  Clock_exports,
27
33
  Context_exports,
28
34
  CurrentLogAnnotations,
29
35
  CurrentLogSpans,
36
+ Duration_exports,
30
37
  Effect_exports,
31
38
  Exit_exports,
32
39
  FiberSet_exports,
@@ -37,8 +44,10 @@ import {
37
44
  Logger_exports,
38
45
  Metric_exports,
39
46
  Option_exports,
47
+ Predicate_exports,
40
48
  Record2 as Record,
41
49
  Redacted_exports,
50
+ Schedule_exports,
42
51
  Schema_exports,
43
52
  Scope,
44
53
  Semaphore_exports,
@@ -53,7 +62,7 @@ import {
53
62
  UndefinedOr,
54
63
  addDelay,
55
64
  addFinalizer,
56
- all,
65
+ all2 as all,
57
66
  allocate,
58
67
  andThen,
59
68
  annotateLogs,
@@ -89,9 +98,9 @@ import {
89
98
  isSome,
90
99
  layer,
91
100
  logDebug,
92
- make2 as make,
93
- make7 as make2,
94
- make8 as make3,
101
+ make,
102
+ make4 as make2,
103
+ make5 as make3,
95
104
  map,
96
105
  map3 as map2,
97
106
  map5 as map3,
@@ -107,7 +116,7 @@ import {
107
116
  prettyErrors,
108
117
  provideMerge,
109
118
  provideService,
110
- randomHex,
119
+ random,
111
120
  run2 as run,
112
121
  runtime,
113
122
  schema,
@@ -125,11 +134,150 @@ import {
125
134
  withDefault2 as withDefault,
126
135
  withTracerEnabled,
127
136
  zero
128
- } from "./chunk-CDL5PM2Q.js";
137
+ } from "./chunk-IFJU5SYQ.js";
129
138
  import {
130
139
  __export
131
140
  } from "./chunk-CZ7CSFO4.js";
132
141
 
142
+ // ../telemetry/src/ownership.ts
143
+ var ownerAttribute = "executor.owner";
144
+ var SpanOwner = Context_exports.Reference("@executor-js/telemetry/SpanOwner", {
145
+ defaultValue: () => void 0
146
+ });
147
+ var declaredOwner = (annotations) => Context_exports.get(annotations, SpanOwner);
148
+ var ownedBy = (owner, options = {}) => ({
149
+ ...options,
150
+ annotations: Context_exports.add(options.annotations ?? Context_exports.empty(), SpanOwner, owner)
151
+ });
152
+ var owned = (owner, name, options) => (effect2) => effect2.pipe(Effect_exports.withSpan(name, ownedBy(owner, options)));
153
+ var measuredSpan = (name, options, measure) => (effect2) => Effect_exports.useSpan(name, options, (span) => {
154
+ const inner = Effect_exports.withParentSpan(effect2, span);
155
+ if (span.status._tag === "Ended") return inner;
156
+ const { around, end } = measure(span.status.startTime);
157
+ return (around === void 0 ? inner : around(inner)).pipe(
158
+ Effect_exports.onExit(
159
+ (exit) => Effect_exports.flatMap(
160
+ Clock_exports.currentTimeNanos,
161
+ (now) => Effect_exports.sync(() => {
162
+ end(now, span);
163
+ span.end(now, exit);
164
+ })
165
+ )
166
+ )
167
+ );
168
+ });
169
+ var concurrent = ["executor", "person", "upstream", "app"];
170
+ var makeOwnershipAccounting = (origin, owner) => {
171
+ const totals = { executor: 0, app: 0, upstream: 0, person: 0 };
172
+ const innermost = { executor: 0, app: 0, upstream: 0, person: 0 };
173
+ const boundaries2 = /* @__PURE__ */ new WeakMap();
174
+ let reached = origin;
175
+ let done = false;
176
+ const advance = (time) => {
177
+ if (time <= reached) return;
178
+ const current = concurrent.find((candidate) => innermost[candidate] > 0) ?? owner;
179
+ totals[current] += Number(time - reached) / 1e6;
180
+ reached = time;
181
+ };
182
+ const enclosing = (boundary) => {
183
+ let found = boundary.parent;
184
+ while (found !== void 0 && !found.open) found = found.parent;
185
+ boundary.parent = found;
186
+ return found;
187
+ };
188
+ const opened = (boundary) => {
189
+ const parent = enclosing(boundary);
190
+ if (parent !== void 0 && parent.children++ === 0) innermost[parent.owner] -= 1;
191
+ innermost[boundary.owner] += 1;
192
+ };
193
+ const closed = (boundary) => {
194
+ boundary.open = false;
195
+ if (boundary.children === 0) innermost[boundary.owner] -= 1;
196
+ const parent = enclosing(boundary);
197
+ if (parent === void 0) return;
198
+ parent.children += boundary.children - 1;
199
+ if (parent.children === 0) innermost[parent.owner] += 1;
200
+ };
201
+ const observed = (tracer) => ({
202
+ ...tracer,
203
+ span: (options) => {
204
+ const span = tracer.span(options);
205
+ if (done) return span;
206
+ const parent = Option_exports.getOrUndefined(options.parent);
207
+ const enclosingBoundary = parent === void 0 ? void 0 : boundaries2.get(parent);
208
+ const boundary = {
209
+ owner: declaredOwner(options.annotations) ?? enclosingBoundary?.owner ?? owner,
210
+ parent: enclosingBoundary,
211
+ open: true,
212
+ children: 0
213
+ };
214
+ advance(options.startTime);
215
+ opened(boundary);
216
+ const tracked = {
217
+ _tag: "Span",
218
+ get name() {
219
+ return span.name;
220
+ },
221
+ get spanId() {
222
+ return span.spanId;
223
+ },
224
+ get traceId() {
225
+ return span.traceId;
226
+ },
227
+ get parent() {
228
+ return span.parent;
229
+ },
230
+ get annotations() {
231
+ return span.annotations;
232
+ },
233
+ get status() {
234
+ return span.status;
235
+ },
236
+ get attributes() {
237
+ return span.attributes;
238
+ },
239
+ get links() {
240
+ return span.links;
241
+ },
242
+ get sampled() {
243
+ return span.sampled;
244
+ },
245
+ get kind() {
246
+ return span.kind;
247
+ },
248
+ end: (endTime, exit) => {
249
+ if (boundary.open && !done) {
250
+ advance(endTime);
251
+ closed(boundary);
252
+ }
253
+ span.end(endTime, exit);
254
+ },
255
+ attribute: (key, value) => span.attribute(key, value),
256
+ event: (name, startTime, attributes2) => span.event(name, startTime, attributes2),
257
+ addLinks: (links) => span.addLinks(links)
258
+ };
259
+ boundaries2.set(tracked, boundary);
260
+ return tracked;
261
+ }
262
+ });
263
+ return {
264
+ /** Run `effect` with the spans it opens observed, including spans it hands to later work. */
265
+ observe: (effect2) => Effect_exports.gen(function* () {
266
+ const tracer = yield* Tracer_exports.Tracer;
267
+ return yield* effect2.pipe(Effect_exports.provideService(Tracer_exports.Tracer, observed(tracer)));
268
+ }),
269
+ /**
270
+ * Close the window at `end` and return its milliseconds by owner, each instant counted once.
271
+ * Spans still open count up to `end`; spans that open or end afterwards are ignored.
272
+ */
273
+ read: (end) => {
274
+ if (!done) advance(end);
275
+ done = true;
276
+ return totals;
277
+ }
278
+ };
279
+ };
280
+
133
281
  // ../telemetry/src/context.ts
134
282
  var captureTelemetry = Effect_exports.gen(function* () {
135
283
  let context2 = Context_exports.make(Tracer_exports.Tracer, yield* Tracer_exports.Tracer).pipe(
@@ -161,9 +309,10 @@ var invocationFetch = (signal) => Effect_exports.gen(function* () {
161
309
  const request = yield* Effect_exports.try(() => new Request(input, init));
162
310
  const client = yield* HttpClient_exports.HttpClient;
163
311
  const response = yield* client.execute(HttpClientRequest_exports.fromWeb(request)).pipe(
164
- Effect_exports.withSpan("provider.http.request", {
165
- attributes: { "http.request.method": request.method }
166
- }),
312
+ Effect_exports.withSpan(
313
+ "provider.http.request",
314
+ ownedBy("upstream", { attributes: { "http.request.method": request.method } })
315
+ ),
167
316
  Effect_exports.provideService(FetchHttpClient_exports.RequestInit, {
168
317
  cache: request.cache,
169
318
  credentials: request.credentials,
@@ -192,9 +341,12 @@ var invocationFetch = (signal) => Effect_exports.gen(function* () {
192
341
  streamed,
193
342
  HttpBody_exports.stream(
194
343
  body.stream.pipe(
195
- Stream_exports.withSpan("provider.http.response.read", {
196
- attributes: { "http.response.status_code": response.status }
197
- })
344
+ Stream_exports.withSpan(
345
+ "provider.http.response.read",
346
+ ownedBy("upstream", {
347
+ attributes: { "http.response.status_code": response.status }
348
+ })
349
+ )
198
350
  ),
199
351
  body.contentType,
200
352
  body.contentLength
@@ -487,15 +639,15 @@ function getTextEncoding() {
487
639
  const te = new globalThis.TextEncoder();
488
640
  const td = new globalThis.TextDecoder();
489
641
  globalThis[symbol] = {
490
- encodeUtf8(text) {
491
- return te.encode(text);
642
+ encodeUtf8(text2) {
643
+ return te.encode(text2);
492
644
  },
493
645
  decodeUtf8(bytes) {
494
646
  return td.decode(bytes);
495
647
  },
496
- checkUtf8(text) {
648
+ checkUtf8(text2) {
497
649
  try {
498
- encodeURIComponent(text);
650
+ encodeURIComponent(text2);
499
651
  return true;
500
652
  } catch (_) {
501
653
  return false;
@@ -700,8 +852,8 @@ var workerWall = Metric_exports.histogram("executor.worker.wall_ms", {
700
852
  attributes: { unit: "ms" },
701
853
  description: "Native Worker invocation wall time, including stream and cleanup lifetime, in milliseconds."
702
854
  });
703
- var recordExportFailure = (path, reason = "transport", records = 0) => {
704
- const signal = path.endsWith("/traces") ? "traces" : path.endsWith("/logs") ? "logs" : path.endsWith("/metrics") ? "metrics" : "other";
855
+ var recordExportFailure = (path, reason, records = 0) => {
856
+ const signal = path.endsWith("/traces") ? "traces" : path.endsWith("/logs") ? "logs" : path.endsWith("/metrics") ? "metrics" : path === "app" ? "app" : "other";
705
857
  return Metric_exports.update(Metric_exports.withAttributes(exportFailures, { signal, reason }), 1).pipe(
706
858
  Effect_exports.andThen(
707
859
  Metric_exports.update(Metric_exports.withAttributes(rejectedRecords, { signal, reason }), records)
@@ -851,6 +1003,53 @@ var telemetryHttpClient = Layer_exports.effect(
851
1003
  )
852
1004
  )
853
1005
  ).pipe(Layer_exports.provide(selectedClient));
1006
+ var retryDelay = (error) => Effect_exports.gen(function* () {
1007
+ if (!HttpClientError_exports.isHttpClientError(error) || error.reason._tag !== "StatusCodeError" || error.reason.response.status !== 429 && error.reason.response.status !== 503)
1008
+ return Duration_exports.seconds(1);
1009
+ const header = error.reason.response.headers["retry-after"]?.trim();
1010
+ if (header === void 0 || header === "")
1011
+ return Duration_exports.seconds(error.reason.response.status === 429 ? 5 : 1);
1012
+ const seconds2 = Number(header);
1013
+ if (Number.isFinite(seconds2)) return Duration_exports.seconds(seconds2 >= 0 ? seconds2 : 5);
1014
+ const date = Date.parse(header);
1015
+ if (Number.isNaN(date)) return Duration_exports.seconds(5);
1016
+ return Duration_exports.millis(Math.max(date - (yield* Clock_exports.currentTimeMillis), 1));
1017
+ });
1018
+ var retryTelemetryExport = (client) => client.pipe(
1019
+ HttpClient_exports.retryTransient({
1020
+ times: 3,
1021
+ schedule: Schedule_exports.forever.pipe(
1022
+ Schedule_exports.passthrough,
1023
+ Schedule_exports.addDelay(({ output }) => retryDelay(output))
1024
+ )
1025
+ })
1026
+ );
1027
+
1028
+ // ../telemetry/src/recorded-failure.ts
1029
+ var tagOf = (error) => Predicate_exports.hasProperty(error, "_tag") && Predicate_exports.isString(error._tag) ? error._tag : void 0;
1030
+ var recorded = (name, message) => {
1031
+ const error = new Error(message);
1032
+ error.name = name;
1033
+ error.stack = message === "" ? name : `${name}: ${message}`;
1034
+ return error;
1035
+ };
1036
+ var recordedError = (error) => {
1037
+ const tag = tagOf(error);
1038
+ if (tag !== void 0) return recorded(tag, recordedMessage(error) ?? "");
1039
+ if (!(error instanceof Error)) return recorded("UnrecognizedFailure", "");
1040
+ if (error.cause === void 0) return error;
1041
+ const copy = new Error(error.message, { cause: recordedError(error.cause) });
1042
+ copy.name = error.name;
1043
+ if (error.stack !== void 0) copy.stack = error.stack;
1044
+ return copy;
1045
+ };
1046
+ var recordedCause = (cause) => Cause_exports.fromReasons(
1047
+ cause.reasons.flatMap((reason) => {
1048
+ if (Cause_exports.isInterruptReason(reason)) return [reason];
1049
+ const replaced = Cause_exports.isFailReason(reason) ? Cause_exports.fail(recordedError(reason.error)) : Cause_exports.die(recordedError(reason.defect));
1050
+ return Cause_exports.annotate(replaced, Cause_exports.reasonAnnotations(reason)).reasons;
1051
+ })
1052
+ );
854
1053
 
855
1054
  // ../telemetry/src/span-attributes.ts
856
1055
  var LogicalOperationFailed = class extends Schema_exports.TaggedError()(
@@ -865,7 +1064,10 @@ var httpSpanAttributeAllowlist = /* @__PURE__ */ new Set([
865
1064
  "server.address",
866
1065
  "url.scheme",
867
1066
  // Path only. `url.full` and `url.query` carry the query string, so neither is listed.
1067
+ // Once a route is recorded, the path is that route's template (`allowlistedSpan`).
868
1068
  "url.path",
1069
+ // The router's matched path template, such as `/api/organizations/:organization`; no values.
1070
+ "http.route",
869
1071
  "http.request.header.content-type",
870
1072
  "http.request.header.content-length",
871
1073
  "http.request.header.user-agent",
@@ -878,51 +1080,70 @@ var spanAttributeAllowed = (key) => {
878
1080
  const name = key.toLowerCase();
879
1081
  return !httpNamespaces.some((namespace) => name.startsWith(namespace)) || httpSpanAttributeAllowlist.has(name);
880
1082
  };
881
- var allowedEntries = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([key]) => spanAttributeAllowed(key)));
882
- var allowlistedSpan = (span) => ({
883
- _tag: "Span",
884
- get name() {
885
- return span.name;
886
- },
887
- get spanId() {
888
- return span.spanId;
889
- },
890
- get traceId() {
891
- return span.traceId;
892
- },
893
- get parent() {
894
- return span.parent;
895
- },
896
- get annotations() {
897
- return span.annotations;
898
- },
899
- get status() {
900
- return span.status;
901
- },
902
- get attributes() {
903
- return span.attributes;
904
- },
905
- get links() {
906
- return span.links;
907
- },
908
- get sampled() {
909
- return span.sampled;
910
- },
911
- get kind() {
912
- return span.kind;
913
- },
914
- // A successful transport can carry a failed domain operation. The producer
915
- // explicitly marks that outcome; arbitrary result payloads are never inspected.
916
- end: (endTime, exit) => span.end(
917
- endTime,
918
- Exit_exports.isSuccess(exit) && span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit
919
- ),
920
- attribute: (key, value) => {
921
- if (spanAttributeAllowed(key)) span.attribute(key, value);
922
- },
923
- event: (name, startTime, attributes) => span.event(name, startTime, attributes === void 0 ? void 0 : allowedEntries(attributes)),
924
- addLinks: (links) => span.addLinks(links)
925
- });
1083
+ var allowedEntries = (attributes2) => Object.fromEntries(Object.entries(attributes2).filter(([key]) => spanAttributeAllowed(key)));
1084
+ var allowlistedSpan = (span) => {
1085
+ let path = false;
1086
+ let route;
1087
+ return {
1088
+ _tag: "Span",
1089
+ get name() {
1090
+ return span.name;
1091
+ },
1092
+ get spanId() {
1093
+ return span.spanId;
1094
+ },
1095
+ get traceId() {
1096
+ return span.traceId;
1097
+ },
1098
+ get parent() {
1099
+ return span.parent;
1100
+ },
1101
+ get annotations() {
1102
+ return span.annotations;
1103
+ },
1104
+ get status() {
1105
+ return span.status;
1106
+ },
1107
+ get attributes() {
1108
+ return span.attributes;
1109
+ },
1110
+ get links() {
1111
+ return span.links;
1112
+ },
1113
+ get sampled() {
1114
+ return span.sampled;
1115
+ },
1116
+ get kind() {
1117
+ return span.kind;
1118
+ },
1119
+ // A successful transport can carry a failed domain operation. The producer
1120
+ // explicitly marks that outcome; arbitrary result payloads are never inspected.
1121
+ // A failure records the fixed message an error declares in place of an app's text.
1122
+ end: (endTime, exit) => span.end(
1123
+ endTime,
1124
+ Exit_exports.isSuccess(exit) ? span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit : Exit_exports.failCause(recordedCause(exit.cause))
1125
+ ),
1126
+ attribute: (key, value) => {
1127
+ if (!spanAttributeAllowed(key)) return;
1128
+ if (key === "url.path" && typeof value === "string") {
1129
+ path = true;
1130
+ span.attribute(key, route ?? value);
1131
+ return;
1132
+ }
1133
+ if (key === "http.route" && typeof value === "string") {
1134
+ route = value;
1135
+ if (path) span.attribute("url.path", value);
1136
+ }
1137
+ span.attribute(key, value);
1138
+ },
1139
+ event: (name, startTime, attributes2) => span.event(
1140
+ name,
1141
+ startTime,
1142
+ attributes2 === void 0 ? void 0 : allowedEntries(attributes2)
1143
+ ),
1144
+ addLinks: (links) => span.addLinks(links)
1145
+ };
1146
+ };
926
1147
  var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_exports.Tracer)(
927
1148
  Tracer_exports.Tracer.pipe(
928
1149
  Effect_exports.map((tracer) => ({
@@ -934,6 +1155,8 @@ var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_e
934
1155
  if (recordAll && Option_exports.isSome(options.parent) && options.parent.value._tag === "ExternalSpan")
935
1156
  span.attribute("executor.trace.parent_sampled", options.parent.value.sampled);
936
1157
  if (clock !== void 0) span.attribute("executor.clock.type", clock);
1158
+ const owner = declaredOwner(options.annotations);
1159
+ if (owner !== void 0) span.attribute(ownerAttribute, owner);
937
1160
  return span;
938
1161
  }
939
1162
  }))
@@ -941,7 +1164,7 @@ var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_e
941
1164
  );
942
1165
  var allowlistedSpans = spanAttributes();
943
1166
 
944
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpLogger.js
1167
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpLogger.js
945
1168
  var OtlpLogger_exports = {};
946
1169
  __export(OtlpLogger_exports, {
947
1170
  layer: () => layer2,
@@ -949,7 +1172,7 @@ __export(OtlpLogger_exports, {
949
1172
  make: () => make6
950
1173
  });
951
1174
 
952
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/otlpEnv.js
1175
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/internal/otlpEnv.js
953
1176
  var exporterList = (path) => Array2(String2, path).pipe(map3((_) => _.map((_2) => _2.toLowerCase().trim()).filter((_2) => _2 !== "")));
954
1177
  var headersRecord = (path) => Record(String2, StringFromUriComponent, path);
955
1178
  var headers = (signal) => headersRecord(`OTEL_EXPORTER_OTLP_${signal}_HEADERS`).pipe(orElse(() => headersRecord("OTEL_EXPORTER_OTLP_HEADERS")), withDefault(void 0));
@@ -960,7 +1183,7 @@ var endpoint = (signal) => URL2(`OTEL_EXPORTER_OTLP_${signal}_ENDPOINT`).pipe(or
960
1183
  }))), withDefault(void 0));
961
1184
  var exporters = (signal) => exporterList(`OTEL_${signal}_EXPORTER`).pipe(withDefault([]));
962
1185
 
963
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpExporter.js
1186
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpExporter.js
964
1187
  var OtlpExporter_exports = {};
965
1188
  __export(OtlpExporter_exports, {
966
1189
  Flusher: () => Flusher,
@@ -1015,7 +1238,7 @@ var make4 = /* @__PURE__ */ fnUntraced(function* (options) {
1015
1238
  const scope = get(services, Scope);
1016
1239
  const exportInterval = max(fromInputUnsafe(options.exportInterval), zero);
1017
1240
  let disabledUntil = void 0;
1018
- const client = filterStatusOk(get(services, HttpClient)).pipe(transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
1241
+ const client = get(services, HttpClient).pipe(tap((response) => ignore(response.arrayBuffer)), tapError((error) => error.response ? ignore(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
1019
1242
  schedule: policy,
1020
1243
  times: 3
1021
1244
  }));
@@ -1072,7 +1295,7 @@ var make4 = /* @__PURE__ */ fnUntraced(function* (options) {
1072
1295
  };
1073
1296
  });
1074
1297
 
1075
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpResource.js
1298
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpResource.js
1076
1299
  var make5 = (options) => {
1077
1300
  const resourceAttributes = options.attributes ? entriesToAttributes(Object.entries(options.attributes)) : [];
1078
1301
  resourceAttributes.push({
@@ -1098,16 +1321,16 @@ var fromConfig = /* @__PURE__ */ fnUntraced(function* (options) {
1098
1321
  const env = yield* Record(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES").pipe(withDefault(void 0));
1099
1322
  const serviceName = options?.serviceName ?? options?.attributes?.["service.name"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_NAME")) ?? env?.["service.name"] ?? (yield* String3("OTEL_SERVICE_NAME"));
1100
1323
  const serviceVersion = options?.serviceVersion ?? options?.attributes?.["service.version"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_VERSION")) ?? env?.["service.version"];
1101
- const attributes = {
1324
+ const attributes2 = {
1102
1325
  ...env,
1103
1326
  ...options?.attributes
1104
1327
  };
1105
- delete attributes["service.name"];
1106
- delete attributes["service.version"];
1328
+ delete attributes2["service.name"];
1329
+ delete attributes2["service.version"];
1107
1330
  return make5({
1108
1331
  serviceName,
1109
1332
  serviceVersion,
1110
- attributes
1333
+ attributes: attributes2
1111
1334
  });
1112
1335
  }, orDie);
1113
1336
  var serviceNameUnsafe = (resource) => {
@@ -1118,14 +1341,14 @@ var serviceNameUnsafe = (resource) => {
1118
1341
  return serviceNameAttribute.value.stringValue;
1119
1342
  };
1120
1343
  var entriesToAttributes = (entries) => {
1121
- const attributes = [];
1344
+ const attributes2 = [];
1122
1345
  for (const [key, value] of entries) {
1123
- attributes.push({
1346
+ attributes2.push({
1124
1347
  key,
1125
1348
  value: unknownToAttributeValue(value)
1126
1349
  });
1127
1350
  }
1128
- return attributes;
1351
+ return attributes2;
1129
1352
  };
1130
1353
  var unknownToAttributeValue = (value) => {
1131
1354
  if (Array.isArray(value)) {
@@ -1161,7 +1384,7 @@ var unknownToAttributeValue = (value) => {
1161
1384
  }
1162
1385
  };
1163
1386
 
1164
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpSerialization.js
1387
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpSerialization.js
1165
1388
  var OtlpSerialization_exports = {};
1166
1389
  __export(OtlpSerialization_exports, {
1167
1390
  OtlpSerialization: () => OtlpSerialization,
@@ -1169,7 +1392,7 @@ __export(OtlpSerialization_exports, {
1169
1392
  layerProtobuf: () => layerProtobuf
1170
1393
  });
1171
1394
 
1172
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/protobuf.js
1395
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/internal/protobuf.js
1173
1396
  var WireType2 = {
1174
1397
  Varint: 0,
1175
1398
  Fixed64: 1,
@@ -1238,7 +1461,7 @@ var messageField = (fieldNumber, message) => lengthDelimitedField(fieldNumber, m
1238
1461
  var repeatedField = (fieldNumber, values, encode) => concat(...values.map((v) => messageField(fieldNumber, encode(v))));
1239
1462
  var optionalStringField = (fieldNumber, value) => value !== void 0 && value !== "" ? stringField(fieldNumber, value) : new Uint8Array(0);
1240
1463
 
1241
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/internal/otlpProtobuf.js
1464
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/internal/otlpProtobuf.js
1242
1465
  var encodeAnyValue = (value) => {
1243
1466
  if (value.stringValue !== void 0 && value.stringValue !== null) {
1244
1467
  return stringField(1, value.stringValue);
@@ -1268,7 +1491,7 @@ var encodeKeyValueList = (value) => repeatedField(1, value.values, encodeKeyValu
1268
1491
  var encodeKeyValue = (kv) => concat(stringField(1, kv.key), messageField(2, encodeAnyValue(kv.value)));
1269
1492
  var encodeInstrumentationScope = (scope) => concat(stringField(1, scope.name), optionalStringField(2, scope.version), scope.attributes ? repeatedField(3, scope.attributes, encodeKeyValue) : new Uint8Array(0), scope.droppedAttributesCount ? varintField(4, scope.droppedAttributesCount) : new Uint8Array(0));
1270
1493
  var encodeResource = (resource) => concat(repeatedField(1, resource.attributes, encodeKeyValue), resource.droppedAttributesCount > 0 ? varintField(2, resource.droppedAttributesCount) : new Uint8Array(0));
1271
- var encodeStatus = (status) => concat(optionalStringField(2, status.message), varintField(3, status.code));
1494
+ var encodeStatus = (status2) => concat(optionalStringField(2, status2.message), varintField(3, status2.code));
1272
1495
  var encodeEvent = (event) => concat(fixed64Field(1, BigInt(event.timeUnixNano)), stringField(2, event.name), repeatedField(3, event.attributes, encodeKeyValue), event.droppedAttributesCount > 0 ? varintField(4, event.droppedAttributesCount) : new Uint8Array(0));
1273
1496
  var encodeLink = (link) => concat(bytesFieldFromHex(1, link.traceId), bytesFieldFromHex(2, link.spanId), optionalStringField(3, link.traceState), repeatedField(4, link.attributes, encodeKeyValue), link.droppedAttributesCount > 0 ? varintField(5, link.droppedAttributesCount) : new Uint8Array(0), link.flags !== void 0 ? fixed32Field(6, link.flags) : new Uint8Array(0));
1274
1497
  var encodeSpan = (span) => concat(bytesFieldFromHex(1, span.traceId), bytesFieldFromHex(2, span.spanId), optionalStringField(3, span.traceState), span.parentSpanId !== void 0 ? bytesFieldFromHex(4, span.parentSpanId) : new Uint8Array(0), stringField(5, span.name), varintField(6, span.kind), fixed64Field(7, BigInt(span.startTimeUnixNano)), fixed64Field(8, BigInt(span.endTimeUnixNano)), repeatedField(9, span.attributes, encodeKeyValue), span.droppedAttributesCount > 0 ? varintField(10, span.droppedAttributesCount) : new Uint8Array(0), repeatedField(11, span.events, encodeEvent), span.droppedEventsCount > 0 ? varintField(12, span.droppedEventsCount) : new Uint8Array(0), repeatedField(13, span.links, encodeLink), span.droppedLinksCount > 0 ? varintField(14, span.droppedLinksCount) : new Uint8Array(0), messageField(15, encodeStatus(span.status)), span.flags !== void 0 ? fixed32Field(16, span.flags) : new Uint8Array(0));
@@ -1277,7 +1500,7 @@ var encodeResourceSpans = (resourceSpans) => concat(messageField(1, encodeResour
1277
1500
  var encodeTracesData = (tracesData) => repeatedField(1, tracesData.resourceSpans, encodeResourceSpans);
1278
1501
  var encodeNumberDataPoint = (point) => concat(fixed64Field(2, BigInt(point.startTimeUnixNano)), fixed64Field(3, BigInt(point.timeUnixNano)), point.asDouble !== void 0 ? doubleField(4, point.asDouble) : new Uint8Array(0), point.asInt !== void 0 ? fixed64Field(6, BigInt(point.asInt)) : new Uint8Array(0), repeatedField(7, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(8, point.flags) : new Uint8Array(0));
1279
1502
  var encodeHistogramDataPoint = (point) => {
1280
- const bucketCountsEncoded = concat(...point.bucketCounts.map((count) => fixed64Field(6, BigInt(count))));
1503
+ const bucketCountsEncoded = concat(...point.bucketCounts.map((count2) => fixed64Field(6, BigInt(count2))));
1281
1504
  const explicitBoundsEncoded = concat(...point.explicitBounds.map((bound) => doubleField(7, bound)));
1282
1505
  return concat(fixed64Field(2, BigInt(point.startTimeUnixNano)), fixed64Field(3, BigInt(point.timeUnixNano)), fixed64Field(4, BigInt(point.count)), point.sum !== void 0 ? doubleField(5, point.sum) : new Uint8Array(0), bucketCountsEncoded, explicitBoundsEncoded, repeatedField(9, point.attributes, encodeKeyValue), point.flags !== void 0 ? varintField(10, point.flags) : new Uint8Array(0), point.min !== void 0 ? doubleField(11, point.min) : new Uint8Array(0), point.max !== void 0 ? doubleField(12, point.max) : new Uint8Array(0));
1283
1506
  };
@@ -1293,7 +1516,7 @@ var encodeScopeLogs = (scopeLogs) => concat(messageField(1, encodeInstrumentatio
1293
1516
  var encodeResourceLogs = (resourceLogs) => concat(messageField(1, encodeResource(resourceLogs.resource)), repeatedField(2, resourceLogs.scopeLogs, encodeScopeLogs), optionalStringField(3, resourceLogs.schemaUrl));
1294
1517
  var encodeLogsData = (logsData) => repeatedField(1, logsData.resourceLogs, encodeResourceLogs);
1295
1518
 
1296
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpSerialization.js
1519
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpSerialization.js
1297
1520
  var OtlpSerialization = class extends (/* @__PURE__ */ Service()("effect/observability/OtlpSerialization")) {
1298
1521
  };
1299
1522
  var layerJson = /* @__PURE__ */ succeed(OtlpSerialization, {
@@ -1307,7 +1530,7 @@ var layerProtobuf = /* @__PURE__ */ succeed(OtlpSerialization, {
1307
1530
  logs: (logs) => uint8Array(encodeLogsData(logs), "application/x-protobuf")
1308
1531
  });
1309
1532
 
1310
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpLogger.js
1533
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpLogger.js
1311
1534
  var make6 = /* @__PURE__ */ fnUntraced(function* (options) {
1312
1535
  const serialization = yield* OtlpSerialization;
1313
1536
  const otelResource = yield* fromConfig(options.resource);
@@ -1385,8 +1608,8 @@ var makeLogRecord = (options, opts) => {
1385
1608
  const now = opts.clock.currentTimeNanosUnsafe();
1386
1609
  const nanosString = now.toString();
1387
1610
  const nowMillis = options.date.getTime();
1388
- const attributes = entriesToAttributes(Object.entries(options.fiber.getRef(CurrentLogAnnotations)));
1389
- attributes.push({
1611
+ const attributes2 = entriesToAttributes(Object.entries(options.fiber.getRef(CurrentLogAnnotations)));
1612
+ attributes2.push({
1390
1613
  key: "fiberId",
1391
1614
  value: {
1392
1615
  intValue: options.fiber.id
@@ -1394,7 +1617,7 @@ var makeLogRecord = (options, opts) => {
1394
1617
  });
1395
1618
  if (!opts.excludeLogSpans) {
1396
1619
  for (const [label, startTime] of options.fiber.getRef(CurrentLogSpans)) {
1397
- attributes.push({
1620
+ attributes2.push({
1398
1621
  key: `logSpan.${label}`,
1399
1622
  value: {
1400
1623
  stringValue: `${nowMillis - startTime}ms`
@@ -1403,7 +1626,7 @@ var makeLogRecord = (options, opts) => {
1403
1626
  }
1404
1627
  }
1405
1628
  if (options.cause.reasons.length > 0) {
1406
- attributes.push({
1629
+ attributes2.push({
1407
1630
  key: "log.error",
1408
1631
  value: {
1409
1632
  stringValue: pretty(options.cause)
@@ -1416,7 +1639,7 @@ var makeLogRecord = (options, opts) => {
1416
1639
  severityText: options.logLevel,
1417
1640
  timeUnixNano: nanosString,
1418
1641
  observedTimeUnixNano: nanosString,
1419
- attributes,
1642
+ attributes: attributes2,
1420
1643
  body: unknownToAttributeValue(message.length === 1 ? message[0] : message),
1421
1644
  droppedAttributesCount: 0
1422
1645
  };
@@ -1473,7 +1696,7 @@ var ESeverityNumber = {
1473
1696
  SEVERITY_NUMBER_FATAL4: 24
1474
1697
  };
1475
1698
 
1476
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpMetrics.js
1699
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpMetrics.js
1477
1700
  var OtlpMetrics_exports = {};
1478
1701
  __export(OtlpMetrics_exports, {
1479
1702
  layer: () => layer3,
@@ -1519,7 +1742,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1519
1742
  for (let i = 0, len = snapshot2.length; i < len; i++) {
1520
1743
  const state = snapshot2[i];
1521
1744
  const unit = state.attributes?.unit ?? state.attributes?.time_unit ?? "1";
1522
- const attributes = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1745
+ const attributes2 = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1523
1746
  const metricKey = makeMetricKey(state.id, state.attributes);
1524
1747
  switch (state.type) {
1525
1748
  case "Counter": {
@@ -1545,7 +1768,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1545
1768
  nextCounterState.set(metricKey, currentCount);
1546
1769
  }
1547
1770
  const dataPoint = {
1548
- attributes,
1771
+ attributes: attributes2,
1549
1772
  startTimeUnixNano: intervalStartTime,
1550
1773
  timeUnixNano: nowTime
1551
1774
  };
@@ -1572,7 +1795,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1572
1795
  }
1573
1796
  case "Gauge": {
1574
1797
  const dataPoint = {
1575
- attributes,
1798
+ attributes: attributes2,
1576
1799
  startTimeUnixNano: startTime,
1577
1800
  timeUnixNano: nowTime
1578
1801
  };
@@ -1632,7 +1855,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1632
1855
  });
1633
1856
  }
1634
1857
  const dataPoint = {
1635
- attributes,
1858
+ attributes: attributes2,
1636
1859
  startTimeUnixNano: intervalStartTime,
1637
1860
  timeUnixNano: nowTime,
1638
1861
  count: reportCount,
@@ -1671,7 +1894,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1671
1894
  }
1672
1895
  }
1673
1896
  dataPoints.push({
1674
- attributes: [...attributes, {
1897
+ attributes: [...attributes2, {
1675
1898
  key: "key",
1676
1899
  value: {
1677
1900
  stringValue: freqKey
@@ -1703,7 +1926,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1703
1926
  }
1704
1927
  case "Summary": {
1705
1928
  const dataPoints = [{
1706
- attributes: [...attributes, {
1929
+ attributes: [...attributes2, {
1707
1930
  key: "quantile",
1708
1931
  value: {
1709
1932
  stringValue: "min"
@@ -1715,7 +1938,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1715
1938
  }];
1716
1939
  for (const [quantile, value] of state.state.quantiles) {
1717
1940
  dataPoints.push({
1718
- attributes: [...attributes, {
1941
+ attributes: [...attributes2, {
1719
1942
  key: "quantile",
1720
1943
  value: {
1721
1944
  stringValue: quantile.toString()
@@ -1727,7 +1950,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1727
1950
  });
1728
1951
  }
1729
1952
  dataPoints.push({
1730
- attributes: [...attributes, {
1953
+ attributes: [...attributes2, {
1731
1954
  key: "quantile",
1732
1955
  value: {
1733
1956
  stringValue: "max"
@@ -1751,13 +1974,13 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1751
1974
  });
1752
1975
  }
1753
1976
  const countDataPoint = {
1754
- attributes,
1977
+ attributes: attributes2,
1755
1978
  startTimeUnixNano: intervalStartTime,
1756
1979
  timeUnixNano: nowTime,
1757
1980
  asInt: reportCount
1758
1981
  };
1759
1982
  const sumDataPoint = {
1760
- attributes,
1983
+ attributes: attributes2,
1761
1984
  startTimeUnixNano: intervalStartTime,
1762
1985
  timeUnixNano: nowTime,
1763
1986
  asDouble: reportSum
@@ -1870,11 +2093,11 @@ var layerFromConfig2 = (options) => gen(function* () {
1870
2093
  temporality: getOrUndefined(temporalityPreference)
1871
2094
  });
1872
2095
  }).pipe(orDie, unwrap);
1873
- var makeMetricKey = (id, attributes) => {
1874
- if (attributes === void 0 || Object.keys(attributes).length === 0) {
2096
+ var makeMetricKey = (id, attributes2) => {
2097
+ if (attributes2 === void 0 || Object.keys(attributes2).length === 0) {
1875
2098
  return id;
1876
2099
  }
1877
- const sortedEntries = Object.entries(attributes).sort((a, b) => a[0].localeCompare(b[0]));
2100
+ const sortedEntries = Object.entries(attributes2).sort((a, b) => a[0].localeCompare(b[0]));
1878
2101
  return `${id}:${JSON.stringify(sortedEntries)}`;
1879
2102
  };
1880
2103
  var EAggregationTemporality = {
@@ -1936,7 +2159,7 @@ var EAggregationTemporality = {
1936
2159
  AGGREGATION_TEMPORALITY_CUMULATIVE: 2
1937
2160
  };
1938
2161
 
1939
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/observability/OtlpTracer.js
2162
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/observability/OtlpTracer.js
1940
2163
  var OtlpTracer_exports = {};
1941
2164
  __export(OtlpTracer_exports, {
1942
2165
  layer: () => layer4,
@@ -2051,10 +2274,10 @@ var SpanImpl = class {
2051
2274
  };
2052
2275
  }
2053
2276
  get traceId() {
2054
- return this._traceId ??= isSome(this.parent) ? this.parent.value.traceId : randomHex(32);
2277
+ return this._traceId ??= isSome(this.parent) ? this.parent.value.traceId : random(32);
2055
2278
  }
2056
2279
  get spanId() {
2057
- return this._spanId ??= randomHex(16);
2280
+ return this._spanId ??= random(16);
2058
2281
  }
2059
2282
  get attributes() {
2060
2283
  return this._attributes ??= /* @__PURE__ */ new Map();
@@ -2074,39 +2297,39 @@ var SpanImpl = class {
2074
2297
  attribute(key, value) {
2075
2298
  this.attributes.set(key, value);
2076
2299
  }
2077
- event(name, startTime, attributes) {
2078
- this.events.push([name, startTime, attributes]);
2300
+ event(name, startTime, attributes2) {
2301
+ this.events.push([name, startTime, attributes2]);
2079
2302
  }
2080
2303
  addLinks(links) {
2081
2304
  this.links.push(...links);
2082
2305
  }
2083
2306
  };
2084
2307
  var makeOtlpSpan = (self) => {
2085
- const status = self.status;
2086
- const attributes = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2308
+ const status2 = self.status;
2309
+ const attributes2 = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2087
2310
  const events = [];
2088
2311
  if (self._events !== void 0) {
2089
2312
  for (let i = 0; i < self._events.length; i++) {
2090
- const [name, startTime, attributes2] = self._events[i];
2313
+ const [name, startTime, attributes3] = self._events[i];
2091
2314
  events.push({
2092
2315
  name,
2093
2316
  timeUnixNano: String(startTime),
2094
- attributes: attributes2 ? entriesToAttributes(Object.entries(attributes2)) : [],
2317
+ attributes: attributes3 ? entriesToAttributes(Object.entries(attributes3)) : [],
2095
2318
  droppedAttributesCount: 0
2096
2319
  });
2097
2320
  }
2098
2321
  }
2099
2322
  let otelStatus;
2100
- if (status.exit._tag === "Success") {
2323
+ if (status2.exit._tag === "Success") {
2101
2324
  otelStatus = {
2102
2325
  code: StatusCode.Ok
2103
2326
  };
2104
- } else if (hasInterruptsOnly(status.exit.cause)) {
2327
+ } else if (hasInterruptsOnly(status2.exit.cause)) {
2105
2328
  otelStatus = {
2106
2329
  code: StatusCode.Ok,
2107
2330
  message: "Interrupted"
2108
2331
  };
2109
- attributes.push({
2332
+ attributes2.push({
2110
2333
  key: "span.label",
2111
2334
  value: {
2112
2335
  stringValue: "\u26A0\uFE0E Interrupted"
@@ -2118,7 +2341,7 @@ var makeOtlpSpan = (self) => {
2118
2341
  }
2119
2342
  });
2120
2343
  } else {
2121
- const errors = prettyErrors(status.exit.cause, {
2344
+ const errors = prettyErrors(status2.exit.cause, {
2122
2345
  includeCauseInStack: true
2123
2346
  });
2124
2347
  otelStatus = {
@@ -2129,7 +2352,7 @@ var makeOtlpSpan = (self) => {
2129
2352
  for (const error of errors) {
2130
2353
  events.push({
2131
2354
  name: "exception",
2132
- timeUnixNano: String(status.endTime),
2355
+ timeUnixNano: String(status2.endTime),
2133
2356
  droppedAttributesCount: 0,
2134
2357
  attributes: [{
2135
2358
  "key": "exception.type",
@@ -2167,9 +2390,9 @@ var makeOtlpSpan = (self) => {
2167
2390
  parentSpanId: isSome(self.parent) ? self.parent.value.spanId : void 0,
2168
2391
  name: self.name,
2169
2392
  kind: SpanKind[self.kind],
2170
- startTimeUnixNano: String(status.startTime),
2171
- endTimeUnixNano: String(status.endTime),
2172
- attributes,
2393
+ startTimeUnixNano: String(status2.startTime),
2394
+ endTimeUnixNano: String(status2.endTime),
2395
+ attributes: attributes2,
2173
2396
  droppedAttributesCount: 0,
2174
2397
  events,
2175
2398
  droppedEventsCount: 0,
@@ -2245,30 +2468,387 @@ var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.with
2245
2468
  );
2246
2469
  };
2247
2470
 
2471
+ // ../telemetry/src/app-records.ts
2472
+ var appText = "Text from the app is not recorded";
2473
+ var unrecognized = "unrecognized";
2474
+ var operations = [
2475
+ "requirements",
2476
+ "inspect",
2477
+ "skills",
2478
+ "query",
2479
+ "mutate",
2480
+ "call",
2481
+ "account-check",
2482
+ "webhooks",
2483
+ "webhook-validate",
2484
+ "webhook-complete",
2485
+ "webhook-register",
2486
+ "webhook-unregister",
2487
+ "webhook-handle",
2488
+ "workflows",
2489
+ "workflow-validate",
2490
+ "workflow-run",
2491
+ "migrate"
2492
+ ];
2493
+ var httpMethods = [
2494
+ "GET",
2495
+ "HEAD",
2496
+ "POST",
2497
+ "PUT",
2498
+ "PATCH",
2499
+ "DELETE",
2500
+ "OPTIONS",
2501
+ "TRACE",
2502
+ "CONNECT"
2503
+ ];
2504
+ var appSpanNames = /* @__PURE__ */ new Set([
2505
+ "app.dispatch",
2506
+ ...operations.map((operation) => `app.${operation}`),
2507
+ "app.evaluate",
2508
+ "app.accounts.bind",
2509
+ "app.account.check",
2510
+ "app.catalog.read",
2511
+ "app.skills.load",
2512
+ "app.skills.routers",
2513
+ "app.tool.resolve",
2514
+ "app.tool.approval",
2515
+ "app.tool.elicitation",
2516
+ "app.elicitation.wait",
2517
+ "app.workflow.control",
2518
+ "app.operation.execute",
2519
+ "app.sql.migrate",
2520
+ "app.code",
2521
+ "app.cache.call",
2522
+ "app.cache.get",
2523
+ "app.cache.load",
2524
+ "app.cache.command",
2525
+ "app.cache.publish",
2526
+ "app.cache.flush",
2527
+ "app.cache.lease.renew",
2528
+ "provider.http.request",
2529
+ "provider.http.response.read",
2530
+ "provider.openapi.call",
2531
+ "provider.graphql.request",
2532
+ "provider.graphql.call",
2533
+ "provider.mcp.session",
2534
+ "provider.mcp.connect",
2535
+ "provider.mcp.close",
2536
+ "provider.mcp.request",
2537
+ "provider.mcp.call",
2538
+ "provider.mcp.discover",
2539
+ "provider.mcp.check",
2540
+ "provider.mcp.health",
2541
+ "provider.mcp.anonymous",
2542
+ "provider.mcp.elicitation",
2543
+ "sql.execute",
2544
+ ...httpMethods.map((method) => `http.client ${method}`)
2545
+ ]);
2546
+ var errorKinds = /* @__PURE__ */ new Set([
2547
+ "HostRequestInvalid",
2548
+ "HostAccountsInvalid",
2549
+ "HostDeclarationInvalid",
2550
+ "HostEvaluationFailed",
2551
+ "HostOperationNotFound",
2552
+ "HostOperationFailed",
2553
+ "HostKindMismatch",
2554
+ "HostToolNotFound",
2555
+ "HostInputInvalid",
2556
+ "HostOutputInvalid",
2557
+ "HostToolBlocked",
2558
+ "HostToolApprovalRequired",
2559
+ "HostToolPolicyFailed",
2560
+ "ElicitationFailed",
2561
+ "DatabaseLimitExceeded",
2562
+ "DatabaseFieldReserved",
2563
+ "SkillLoadFailed",
2564
+ "WorkflowFailure",
2565
+ "ProviderError",
2566
+ "OpenapiResponseError",
2567
+ "OpenapiError",
2568
+ "OpenapiCompileError",
2569
+ "GraphqlError",
2570
+ "McpError",
2571
+ "McpToolError",
2572
+ "McpCredentialsUnverified",
2573
+ "CacheError",
2574
+ "AppDatabaseError",
2575
+ "AppStorageError",
2576
+ "AppStorageUnavailable",
2577
+ "NetworkRefused",
2578
+ "FetchOptionUnsupported",
2579
+ "LogicalOperationFailed",
2580
+ "HttpClientError",
2581
+ "SchemaError",
2582
+ "TimeoutError",
2583
+ "UnknownError",
2584
+ "InterruptError",
2585
+ "Error",
2586
+ "TypeError",
2587
+ "RangeError",
2588
+ "ReferenceError",
2589
+ "SyntaxError",
2590
+ "EvalError",
2591
+ "URIError",
2592
+ "AggregateError",
2593
+ "AbortError",
2594
+ "string",
2595
+ "number",
2596
+ "bigint",
2597
+ "boolean",
2598
+ "symbol",
2599
+ "undefined",
2600
+ "object",
2601
+ "function"
2602
+ ]);
2603
+ var failureCodes = /* @__PURE__ */ new Set([
2604
+ // CacheError
2605
+ "unavailable",
2606
+ "storage",
2607
+ "invalid",
2608
+ "capacity",
2609
+ "timeout",
2610
+ // AppDatabaseError
2611
+ "schema",
2612
+ "schema_changed",
2613
+ "table",
2614
+ "index",
2615
+ "range",
2616
+ "value",
2617
+ "readonly",
2618
+ "cursor",
2619
+ "limit",
2620
+ "closed",
2621
+ "replay",
2622
+ // OpenapiError
2623
+ "invalid_definition",
2624
+ "invalid_input",
2625
+ "request",
2626
+ // McpError, McpCredentialsUnverified and ProviderError
2627
+ "unauthorized",
2628
+ "invalid_response",
2629
+ "forbidden",
2630
+ "rate_limited",
2631
+ "rejected",
2632
+ "anonymous_access",
2633
+ // NetworkRefused and FetchOptionUnsupported
2634
+ "private_address",
2635
+ "credential_host",
2636
+ "credential_app",
2637
+ "credential_expired",
2638
+ "redirect",
2639
+ "cache",
2640
+ "integrity"
2641
+ ]);
2642
+ var text = (value) => typeof value["stringValue"] === "string" ? value["stringValue"] : void 0;
2643
+ var integer = (value) => {
2644
+ const raw = value["intValue"];
2645
+ const number = typeof raw === "string" && /^-?\d{1,15}$/.test(raw) ? Number(raw) : raw;
2646
+ return typeof number === "number" && Number.isSafeInteger(number) ? number : void 0;
2647
+ };
2648
+ var oneOf = (...values) => (value) => {
2649
+ const found = text(value);
2650
+ return found !== void 0 && values.includes(found) ? { stringValue: found } : void 0;
2651
+ };
2652
+ var classified = (known) => (value) => {
2653
+ const found = text(value);
2654
+ return found === void 0 ? void 0 : { stringValue: known.has(found) ? found : unrecognized };
2655
+ };
2656
+ var flag = (value) => typeof value["boolValue"] === "boolean" ? { boolValue: value["boolValue"] } : void 0;
2657
+ var count = (value) => {
2658
+ const found = integer(value);
2659
+ return found !== void 0 && found >= 0 ? { intValue: found } : void 0;
2660
+ };
2661
+ var status = (value) => {
2662
+ const found = integer(value);
2663
+ return found !== void 0 && found >= 100 && found <= 599 ? { intValue: found } : void 0;
2664
+ };
2665
+ var duration = (value) => {
2666
+ const found = typeof value["doubleValue"] === "number" ? value["doubleValue"] : integer(value);
2667
+ return found !== void 0 && Number.isFinite(found) && found >= 0 ? { doubleValue: found } : void 0;
2668
+ };
2669
+ var spanAttributes2 = {
2670
+ "executor.operation": oneOf(...operations, "mutation", "discover"),
2671
+ "executor.outcome": oneOf("failed"),
2672
+ "executor.clock.type": oneOf("system", "cloudflare-io"),
2673
+ "executor.trace.parent_sampled": flag,
2674
+ "executor.failure.source": oneOf("app", "storage", "service"),
2675
+ "executor.failure.code": classified(failureCodes),
2676
+ "error.type": classified(errorKinds),
2677
+ "cache.operation": oneOf(
2678
+ "read",
2679
+ "acquire",
2680
+ "claim",
2681
+ "publish",
2682
+ "release",
2683
+ "renew",
2684
+ "write",
2685
+ "invalidate"
2686
+ ),
2687
+ "cache.result": oneOf("fresh", "stale", "miss", "local"),
2688
+ "cache.load.leased": flag,
2689
+ "cache.flush.index": count,
2690
+ "cache.flush.count": count,
2691
+ "cache.flush.entries": count,
2692
+ "cache.flush.bytes": count,
2693
+ "cache.leases": count,
2694
+ "mcp.transport": oneOf("http", "sse", "stdio"),
2695
+ "mcp.operation": oneOf("discover", "call", "check", "health"),
2696
+ "mcp.tool.is_error": flag,
2697
+ "rpc.system.name": oneOf("jsonrpc"),
2698
+ "rpc.method": oneOf("initialize", "tools/list", "tools/call", "ping"),
2699
+ "graphql.operation.type": oneOf("query", "mutation", "subscription"),
2700
+ "db.system.name": oneOf("sqlite"),
2701
+ "db.operation.name": oneOf("execute"),
2702
+ "http.request.method": oneOf(...httpMethods),
2703
+ "http.response.status_code": status,
2704
+ "url.scheme": oneOf("http", "https"),
2705
+ "span.label": oneOf("\u26A0\uFE0E Interrupted"),
2706
+ "status.interrupted": flag,
2707
+ "executor.milestone.reached": flag,
2708
+ "executor.owner": oneOf("executor", "app", "upstream", "person"),
2709
+ "executor.app.code": oneOf(
2710
+ "factory",
2711
+ "router",
2712
+ "approval",
2713
+ "handler",
2714
+ "loader",
2715
+ "cache",
2716
+ "webhook",
2717
+ "check",
2718
+ "skills",
2719
+ "elicitation",
2720
+ "workflow",
2721
+ "step"
2722
+ ),
2723
+ "executor.workflow.operation": oneOf("start", "get", "list", "terminate"),
2724
+ "cache.method": oneOf("get", "revalidate", "read", "readMany", "write", "invalidate"),
2725
+ "executor.upstream.wait_ms": duration,
2726
+ "executor.elicitation.wait_ms": duration,
2727
+ "executor.authored_ms": duration,
2728
+ "executor.overhead_ms": duration
2729
+ };
2730
+ var appSpanAttributeKeys = new Set(Object.keys(spanAttributes2));
2731
+ var logMessages = /* @__PURE__ */ new Set([
2732
+ "The app's request failed unexpectedly",
2733
+ "App cache refresh failed",
2734
+ "MCP catalog invalidation failed",
2735
+ "Telemetry export failed"
2736
+ ]);
2737
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2738
+ var spanId = (value) => typeof value === "string" && /^[a-f0-9]{16}$/.test(value) ? value : void 0;
2739
+ var nanos = (value) => typeof value === "string" && /^\d{1,20}$/.test(value) ? value : void 0;
2740
+ var between = (value, minimum, maximum) => typeof value === "number" && Number.isInteger(value) && value >= minimum && value <= maximum ? value : void 0;
2741
+ var attributes = (from) => (Array.isArray(from) ? from : []).flatMap((attribute) => {
2742
+ if (!isObject(attribute) || typeof attribute["key"] !== "string") return [];
2743
+ const key = attribute["key"];
2744
+ const keep = Object.hasOwn(spanAttributes2, key) ? spanAttributes2[key] : void 0;
2745
+ const value = attribute["value"];
2746
+ const kept = keep === void 0 || !isObject(value) ? void 0 : keep(value);
2747
+ return kept === void 0 ? [] : [{ key, value: kept }];
2748
+ });
2749
+ var exception = (event) => {
2750
+ const named = (Array.isArray(event["attributes"]) ? event["attributes"] : []).find(
2751
+ (attribute) => isObject(attribute) && attribute["key"] === "exception.type"
2752
+ );
2753
+ const type = isObject(named) && isObject(named["value"]) ? text(named["value"]) : void 0;
2754
+ const recorded2 = type !== void 0 && errorKinds.has(type) ? type : unrecognized;
2755
+ const time = nanos(event["timeUnixNano"]);
2756
+ return {
2757
+ name: "exception",
2758
+ ...time === void 0 ? {} : { timeUnixNano: time },
2759
+ attributes: [
2760
+ { key: "exception.type", value: { stringValue: recorded2 } },
2761
+ { key: "exception.message", value: { stringValue: appText } },
2762
+ { key: "exception.stacktrace", value: { stringValue: `${recorded2}: ${appText}` } }
2763
+ ]
2764
+ };
2765
+ };
2766
+ var appSpan = (span) => {
2767
+ const start = nanos(span["startTimeUnixNano"]);
2768
+ const end = nanos(span["endTimeUnixNano"]);
2769
+ if (start === void 0 || end === void 0) return void 0;
2770
+ const parent = spanId(span["parentSpanId"]);
2771
+ const kind = between(span["kind"], 0, 5);
2772
+ const code = isObject(span["status"]) ? between(span["status"]["code"], 0, 2) : void 0;
2773
+ const name = typeof span["name"] === "string" && appSpanNames.has(span["name"]) ? span["name"] : "app.unrecognized";
2774
+ return {
2775
+ traceId: span.traceId,
2776
+ spanId: span.spanId,
2777
+ ...parent === void 0 ? {} : { parentSpanId: parent },
2778
+ name,
2779
+ ...kind === void 0 ? {} : { kind },
2780
+ startTimeUnixNano: start,
2781
+ endTimeUnixNano: end,
2782
+ attributes: attributes(span["attributes"]),
2783
+ events: (Array.isArray(span["events"]) ? span["events"] : []).flatMap(
2784
+ (event) => isObject(event) && event["name"] === "exception" ? [exception(event)] : []
2785
+ ),
2786
+ ...code === void 0 ? {} : { status: { code } }
2787
+ };
2788
+ };
2789
+ var appLog = (log) => {
2790
+ const time = nanos(log["timeUnixNano"]);
2791
+ const observed = nanos(log["observedTimeUnixNano"]);
2792
+ const severity = between(log["severityNumber"], 1, 24);
2793
+ const level = log["severityText"];
2794
+ const body = isObject(log["body"]) ? text(log["body"]) : void 0;
2795
+ return {
2796
+ ...log.traceId === void 0 ? {} : { traceId: log.traceId },
2797
+ ...log.spanId === void 0 ? {} : { spanId: log.spanId },
2798
+ ...time === void 0 ? {} : { timeUnixNano: time },
2799
+ ...observed === void 0 ? {} : { observedTimeUnixNano: observed },
2800
+ ...severity === void 0 ? {} : { severityNumber: severity },
2801
+ ...typeof level === "string" && ["Trace", "Debug", "Info", "Warn", "Error", "Fatal"].includes(level) ? { severityText: level } : {},
2802
+ body: { stringValue: body !== void 0 && logMessages.has(body) ? body : appText }
2803
+ };
2804
+ };
2805
+
2248
2806
  // ../telemetry/src/relay.ts
2249
2807
  var makeTelemetryForwarder = Effect_exports.gen(function* () {
2250
2808
  const fibers = yield* FiberSet_exports.make();
2251
- const pending = yield* Semaphore_exports.make(16);
2252
2809
  const sender = yield* Semaphore_exports.make(1);
2253
- const failed = (reason) => recordExportFailure("app").pipe(Effect_exports.annotateLogs({ "executor.telemetry.failure": reason }));
2810
+ const pending = [];
2811
+ let queued = 0;
2812
+ const failed = (reason) => recordExportFailure("app", reason);
2813
+ const take = () => {
2814
+ let size = 0;
2815
+ let count2 = 0;
2816
+ while (count2 < pending.length && (count2 === 0 || size + pending[count2].size <= exportBudget))
2817
+ size += pending[count2++].size;
2818
+ queued -= size;
2819
+ return pending.splice(0, count2);
2820
+ };
2821
+ const sendAll = Effect_exports.suspend(() => {
2822
+ const forwards = take();
2823
+ return forwards.length === 0 ? Effect_exports.void : exportForwards(forwards, "executor-app").pipe(
2824
+ Effect_exports.catchTag("TimeoutError", () => failed("timeout")),
2825
+ Effect_exports.catch(() => failed("relay")),
2826
+ Effect_exports.andThen(sendAll)
2827
+ );
2828
+ });
2829
+ const drain = Effect_exports.suspend(
2830
+ () => sender.withPermitsIfAvailable(1)(sendAll).pipe(
2831
+ Effect_exports.flatMap((sent) => Option_exports.isSome(sent) && pending.length > 0 ? drain : Effect_exports.void)
2832
+ )
2833
+ );
2254
2834
  yield* Effect_exports.addFinalizer(
2255
2835
  () => FiberSet_exports.awaitEmpty(fibers).pipe(
2256
2836
  Effect_exports.timeoutOption("3 seconds"),
2257
- Effect_exports.flatMap((drained) => Option_exports.isNone(drained) ? failed("shutdown") : Effect_exports.void)
2258
- )
2259
- );
2260
- return (batch, traceId, build) => FiberSet_exports.run(
2261
- fibers,
2262
- sender.withPermits(1)(
2263
- forwardTelemetry(batch, traceId, build).pipe(Effect_exports.catch(() => failed("relay")))
2264
- ).pipe(
2265
- pending.withPermitsIfAvailable(1),
2266
2837
  Effect_exports.flatMap(
2267
- (accepted) => Option_exports.isNone(accepted) ? failed("capacity") : Effect_exports.void
2838
+ (drained) => Option_exports.isNone(drained) || pending.length > 0 ? failed("shutdown") : Effect_exports.void
2268
2839
  )
2269
2840
  )
2270
- ).pipe(Effect_exports.asVoid);
2841
+ );
2842
+ return (batch, traceId, source) => Effect_exports.suspend(() => {
2843
+ const size = [...batch.traces, ...batch.logs].reduce((total, body) => total + body.length, 0);
2844
+ if (queued + size > queueBudget) return failed("capacity");
2845
+ pending.push({ batch, traceId, source, size });
2846
+ queued += size;
2847
+ return FiberSet_exports.run(fibers, drain).pipe(Effect_exports.asVoid);
2848
+ });
2271
2849
  });
2850
+ var queueBudget = 8 * 1048576;
2851
+ var exportBudget = 4 * 1048576;
2272
2852
  var payloadBytes = 262144;
2273
2853
  var encoder = new TextEncoder();
2274
2854
  var Payload = Schema_exports.String.check(
@@ -2360,8 +2940,8 @@ var recordPacker = (prefix, suffix) => {
2360
2940
  }
2361
2941
  };
2362
2942
  };
2363
- var HexTrace = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{32}$/));
2364
- var HexSpan = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{16}$/));
2943
+ var HexTrace = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{32}$/u));
2944
+ var HexSpan = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{16}$/u));
2365
2945
  var Span = Schema_exports.StructWithRest(Schema_exports.Struct({ traceId: HexTrace, spanId: HexSpan }), [
2366
2946
  Schema_exports.Record(Schema_exports.String, Schema_exports.Json)
2367
2947
  ]);
@@ -2391,58 +2971,67 @@ var LogPayload = Schema_exports.fromJsonString(
2391
2971
  )
2392
2972
  })
2393
2973
  );
2394
- var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effect_exports.gen(function* () {
2974
+ var exportForwards = (forwards, service) => Effect_exports.gen(function* () {
2395
2975
  const config = yield* CurrentTelemetryConfig;
2396
2976
  if (config === void 0) return;
2397
- const resource = {
2977
+ const resource = ({ build, app }) => ({
2398
2978
  attributes: [
2399
2979
  { key: "service.name", value: { stringValue: service } },
2400
2980
  { key: "service.version", value: { stringValue: config.version } },
2401
2981
  { key: "deployment.environment.name", value: { stringValue: config.environment } },
2402
- ...build === void 0 ? [] : [{ key: "executor.build.id", value: { stringValue: build } }]
2982
+ ...build === void 0 ? [] : [{ key: "executor.build.id", value: { stringValue: build } }],
2983
+ ...app === void 0 ? [] : [{ key: "executor.app.id", value: { stringValue: app } }]
2403
2984
  ]
2404
- };
2405
- const client = yield* HttpClient_exports.HttpClient;
2406
- if (batch.dropped > 0) yield* recordExportFailure("app", "capacity", batch.dropped);
2985
+ });
2986
+ const client = retryTelemetryExport(yield* HttpClient_exports.HttpClient);
2987
+ const dropped = forwards.reduce((total, { batch }) => total + batch.dropped, 0);
2988
+ if (dropped > 0) yield* recordExportFailure("app", "capacity", dropped);
2407
2989
  for (const signal of ["traces", "logs"]) {
2408
2990
  const target = config[signal];
2409
- if (target === void 0 || batch[signal].length === 0) continue;
2410
- const data = signal === "traces" ? yield* Effect_exports.forEach(
2411
- batch.traces,
2412
- (body) => Schema_exports.decodeUnknownEffect(TracePayload)(body)
2413
- ).pipe(
2414
- Effect_exports.map((payloads) => ({
2415
- resourceSpans: [
2416
- {
2417
- resource,
2991
+ const sending = forwards.filter(({ batch }) => batch[signal].length > 0);
2992
+ if (target === void 0 || sending.length === 0) continue;
2993
+ const data = signal === "traces" ? {
2994
+ resourceSpans: yield* Effect_exports.forEach(
2995
+ sending,
2996
+ ({ batch, traceId, source }) => Effect_exports.forEach(
2997
+ batch.traces,
2998
+ (body) => Schema_exports.decodeUnknownEffect(TracePayload)(body)
2999
+ ).pipe(
3000
+ Effect_exports.map((payloads) => ({
3001
+ resource: resource(source),
2418
3002
  scopeSpans: [
2419
3003
  {
2420
3004
  scope: { name: service },
2421
- spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId)
3005
+ spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId).flatMap((span) => {
3006
+ if (service !== "executor-app") return [span];
3007
+ const kept = appSpan(span);
3008
+ return kept === void 0 ? [] : [kept];
3009
+ })
2422
3010
  }
2423
3011
  ]
2424
- }
2425
- ]
2426
- }))
2427
- ) : yield* Effect_exports.forEach(
2428
- batch.logs,
2429
- (body) => Schema_exports.decodeUnknownEffect(LogPayload)(body)
2430
- ).pipe(
2431
- Effect_exports.map((payloads) => ({
2432
- resourceLogs: [
2433
- {
2434
- resource,
3012
+ }))
3013
+ )
3014
+ )
3015
+ } : {
3016
+ resourceLogs: yield* Effect_exports.forEach(
3017
+ sending,
3018
+ ({ batch, traceId, source }) => Effect_exports.forEach(
3019
+ batch.logs,
3020
+ (body) => Schema_exports.decodeUnknownEffect(LogPayload)(body)
3021
+ ).pipe(
3022
+ Effect_exports.map((payloads) => ({
3023
+ resource: resource(source),
2435
3024
  scopeLogs: [
2436
3025
  {
2437
3026
  scope: { name: service },
2438
- logRecords: payloads.flatMap((payload) => payload.resourceLogs).flatMap((r) => r.scopeLogs.flatMap((s) => s.logRecords)).filter((log) => traceId === void 0 || log.traceId === traceId)
3027
+ logRecords: payloads.flatMap((payload) => payload.resourceLogs).flatMap((r) => r.scopeLogs.flatMap((s) => s.logRecords)).filter((log) => traceId === void 0 || log.traceId === traceId).map((log) => service === "executor-app" ? appLog(log) : log)
2439
3028
  }
2440
3029
  ]
2441
- }
2442
- ]
2443
- }))
2444
- );
2445
- yield* client.pipe(HttpClient_exports.filterStatusOk).execute(
3030
+ }))
3031
+ )
3032
+ )
3033
+ };
3034
+ yield* client.execute(
2446
3035
  HttpClientRequest_exports.post(target.url).pipe(
2447
3036
  HttpClientRequest_exports.setHeaders(
2448
3037
  target.headers === void 0 ? {} : Redacted_exports.value(target.headers)
@@ -2459,8 +3048,8 @@ var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effe
2459
3048
 
2460
3049
  // ../telemetry/src/trace-context.ts
2461
3050
  var TraceContext = Schema_exports.Struct({
2462
- traceId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{32}$)[a-f0-9]{32}$/)),
2463
- spanId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{16}$)[a-f0-9]{16}$/)),
3051
+ traceId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{32}$)[a-f0-9]{32}$/u)),
3052
+ spanId: Schema_exports.String.check(Schema_exports.isPattern(/^(?!0{16}$)[a-f0-9]{16}$/u)),
2464
3053
  sampled: Schema_exports.Boolean
2465
3054
  });
2466
3055
  var currentTraceContext = Effect_exports.currentSpan.pipe(
@@ -2502,13 +3091,15 @@ var pendingSpan = (name, options) => Effect_exports.gen(function* () {
2502
3091
 
2503
3092
  export {
2504
3093
  CurrentTelemetryConfig,
3094
+ owned,
3095
+ measuredSpan,
3096
+ makeOwnershipAccounting,
2505
3097
  OtlpExporter_exports,
2506
3098
  telemetryLayer,
2507
3099
  captureTelemetry,
2508
3100
  withRemoteSpan,
2509
3101
  invocationFetch,
2510
3102
  collectTelemetry,
2511
- TraceContext,
2512
3103
  externalTrace,
2513
3104
  traceLinks,
2514
3105
  pendingSpan