apps 0.0.1-beta.36 → 0.0.1-beta.37

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 (34) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-KZFV3WCJ.js → chunk-24EIFQYZ.js} +377 -50
  3. package/js/chunk-2FWXCU5I.js +16 -0
  4. package/js/{chunk-ZQWDOHEO.js → chunk-3LRFKLUX.js} +4 -4
  5. package/js/{chunk-BKJDZYK7.js → chunk-7KEKFBV7.js} +1 -1
  6. package/js/{chunk-4U2VUDET.js → chunk-BWUHMKHQ.js} +1 -1
  7. package/js/{chunk-CZLCA2O4.js → chunk-CAOHGMNW.js} +2 -2
  8. package/js/{chunk-SRB2WDU7.js → chunk-D45FU4TZ.js} +1 -1
  9. package/js/{chunk-UBAKWXAJ.js → chunk-GHDZEEPO.js} +24 -20
  10. package/js/{chunk-556EWA6P.js → chunk-KEZ4YZSP.js} +16 -3
  11. package/js/{chunk-XEXUHXC3.js → chunk-LQBR7AI7.js} +11 -1
  12. package/js/{chunk-WAGGHNWH.js → chunk-QQKHJ72Y.js} +4 -4
  13. package/js/{chunk-A2NN45C7.js → chunk-U74JVKTQ.js} +3 -3
  14. package/js/{chunk-WMVTBHGK.js → chunk-UCOMVHGW.js} +2 -2
  15. package/js/client.js +2 -1
  16. package/js/contracts.js +3 -2
  17. package/js/effect.js +10 -9
  18. package/js/graphql.js +11 -10
  19. package/js/host.js +10 -9
  20. package/js/index.js +5 -4
  21. package/js/mcp/effect.js +12 -11
  22. package/js/mcp/stdio.js +12 -11
  23. package/js/mcp.js +13 -12
  24. package/js/openapi.js +9 -8
  25. package/js/skills/effect.js +3 -2
  26. package/js/skills.js +5 -4
  27. package/js/ui/serving.js +2 -1
  28. package/package.json +1 -1
  29. package/runtime.json +1 -1
  30. package/types/apps/src/contracts/workflows.d.ts +6 -0
  31. package/types/telemetry/src/app-records.d.ts +42 -0
  32. package/types/telemetry/src/recorded-failure.d.ts +20 -0
  33. package/types/utils/src/api-error.d.ts +5 -0
  34. package/types/utils/src/recorded-message.d.ts +15 -0
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  FetchHttpClient_exports
3
3
  } from "./chunk-TADLIUEU.js";
4
+ import {
5
+ recordedMessage
6
+ } from "./chunk-2FWXCU5I.js";
4
7
  import {
5
8
  HttpBody_exports,
6
9
  HttpClient,
@@ -24,6 +27,7 @@ import {
24
27
  import {
25
28
  Array as Array2,
26
29
  Boolean2 as Boolean,
30
+ Cause_exports,
27
31
  Clock,
28
32
  Clock_exports,
29
33
  Context_exports,
@@ -489,15 +493,15 @@ function getTextEncoding() {
489
493
  const te = new globalThis.TextEncoder();
490
494
  const td = new globalThis.TextDecoder();
491
495
  globalThis[symbol] = {
492
- encodeUtf8(text) {
493
- return te.encode(text);
496
+ encodeUtf8(text2) {
497
+ return te.encode(text2);
494
498
  },
495
499
  decodeUtf8(bytes) {
496
500
  return td.decode(bytes);
497
501
  },
498
- checkUtf8(text) {
502
+ checkUtf8(text2) {
499
503
  try {
500
- encodeURIComponent(text);
504
+ encodeURIComponent(text2);
501
505
  return true;
502
506
  } catch (_) {
503
507
  return false;
@@ -854,6 +858,21 @@ var telemetryHttpClient = Layer_exports.effect(
854
858
  )
855
859
  ).pipe(Layer_exports.provide(selectedClient));
856
860
 
861
+ // ../telemetry/src/recorded-failure.ts
862
+ var recordedError = (error) => {
863
+ const message = recordedMessage(error);
864
+ if (message === void 0 || !(error instanceof Error)) return error;
865
+ const recorded = new Error(message);
866
+ recorded.name = error.name;
867
+ recorded.stack = `${error.name}: ${message}`;
868
+ return recorded;
869
+ };
870
+ var recordedCause = (cause) => Cause_exports.fromReasons(
871
+ Cause_exports.map(cause, recordedError).reasons.flatMap(
872
+ (reason) => Cause_exports.isDieReason(reason) && recordedMessage(reason.defect) !== void 0 ? Cause_exports.annotate(Cause_exports.die(recordedError(reason.defect)), Cause_exports.reasonAnnotations(reason)).reasons : [reason]
873
+ )
874
+ );
875
+
857
876
  // ../telemetry/src/span-attributes.ts
858
877
  var LogicalOperationFailed = class extends Schema_exports.TaggedError()(
859
878
  "LogicalOperationFailed",
@@ -880,7 +899,7 @@ var spanAttributeAllowed = (key) => {
880
899
  const name = key.toLowerCase();
881
900
  return !httpNamespaces.some((namespace) => name.startsWith(namespace)) || httpSpanAttributeAllowlist.has(name);
882
901
  };
883
- var allowedEntries = (attributes) => Object.fromEntries(Object.entries(attributes).filter(([key]) => spanAttributeAllowed(key)));
902
+ var allowedEntries = (attributes2) => Object.fromEntries(Object.entries(attributes2).filter(([key]) => spanAttributeAllowed(key)));
884
903
  var allowlistedSpan = (span) => ({
885
904
  _tag: "Span",
886
905
  get name() {
@@ -915,14 +934,15 @@ var allowlistedSpan = (span) => ({
915
934
  },
916
935
  // A successful transport can carry a failed domain operation. The producer
917
936
  // explicitly marks that outcome; arbitrary result payloads are never inspected.
937
+ // A failure records the fixed message an error declares in place of an app's text.
918
938
  end: (endTime, exit) => span.end(
919
939
  endTime,
920
- Exit_exports.isSuccess(exit) && span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit
940
+ Exit_exports.isSuccess(exit) ? span.attributes.get("executor.outcome") === "failed" ? Exit_exports.fail(new LogicalOperationFailed()) : exit : Exit_exports.failCause(recordedCause(exit.cause))
921
941
  ),
922
942
  attribute: (key, value) => {
923
943
  if (spanAttributeAllowed(key)) span.attribute(key, value);
924
944
  },
925
- event: (name, startTime, attributes) => span.event(name, startTime, attributes === void 0 ? void 0 : allowedEntries(attributes)),
945
+ event: (name, startTime, attributes2) => span.event(name, startTime, attributes2 === void 0 ? void 0 : allowedEntries(attributes2)),
926
946
  addLinks: (links) => span.addLinks(links)
927
947
  });
928
948
  var spanAttributes = (clock, recordAll = false) => Layer_exports.effect(Tracer_exports.Tracer)(
@@ -1100,16 +1120,16 @@ var fromConfig = /* @__PURE__ */ fnUntraced(function* (options) {
1100
1120
  const env = yield* Record(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES").pipe(withDefault(void 0));
1101
1121
  const serviceName = options?.serviceName ?? options?.attributes?.["service.name"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_NAME")) ?? env?.["service.name"] ?? (yield* String3("OTEL_SERVICE_NAME"));
1102
1122
  const serviceVersion = options?.serviceVersion ?? options?.attributes?.["service.version"] ?? (yield* schema(UndefinedOr(String2), "OTEL_SERVICE_VERSION")) ?? env?.["service.version"];
1103
- const attributes = {
1123
+ const attributes2 = {
1104
1124
  ...env,
1105
1125
  ...options?.attributes
1106
1126
  };
1107
- delete attributes["service.name"];
1108
- delete attributes["service.version"];
1127
+ delete attributes2["service.name"];
1128
+ delete attributes2["service.version"];
1109
1129
  return make5({
1110
1130
  serviceName,
1111
1131
  serviceVersion,
1112
- attributes
1132
+ attributes: attributes2
1113
1133
  });
1114
1134
  }, orDie);
1115
1135
  var serviceNameUnsafe = (resource) => {
@@ -1120,14 +1140,14 @@ var serviceNameUnsafe = (resource) => {
1120
1140
  return serviceNameAttribute.value.stringValue;
1121
1141
  };
1122
1142
  var entriesToAttributes = (entries) => {
1123
- const attributes = [];
1143
+ const attributes2 = [];
1124
1144
  for (const [key, value] of entries) {
1125
- attributes.push({
1145
+ attributes2.push({
1126
1146
  key,
1127
1147
  value: unknownToAttributeValue(value)
1128
1148
  });
1129
1149
  }
1130
- return attributes;
1150
+ return attributes2;
1131
1151
  };
1132
1152
  var unknownToAttributeValue = (value) => {
1133
1153
  if (Array.isArray(value)) {
@@ -1270,7 +1290,7 @@ var encodeKeyValueList = (value) => repeatedField(1, value.values, encodeKeyValu
1270
1290
  var encodeKeyValue = (kv) => concat(stringField(1, kv.key), messageField(2, encodeAnyValue(kv.value)));
1271
1291
  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));
1272
1292
  var encodeResource = (resource) => concat(repeatedField(1, resource.attributes, encodeKeyValue), resource.droppedAttributesCount > 0 ? varintField(2, resource.droppedAttributesCount) : new Uint8Array(0));
1273
- var encodeStatus = (status) => concat(optionalStringField(2, status.message), varintField(3, status.code));
1293
+ var encodeStatus = (status2) => concat(optionalStringField(2, status2.message), varintField(3, status2.code));
1274
1294
  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));
1275
1295
  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));
1276
1296
  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));
@@ -1279,7 +1299,7 @@ var encodeResourceSpans = (resourceSpans) => concat(messageField(1, encodeResour
1279
1299
  var encodeTracesData = (tracesData) => repeatedField(1, tracesData.resourceSpans, encodeResourceSpans);
1280
1300
  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));
1281
1301
  var encodeHistogramDataPoint = (point) => {
1282
- const bucketCountsEncoded = concat(...point.bucketCounts.map((count) => fixed64Field(6, BigInt(count))));
1302
+ const bucketCountsEncoded = concat(...point.bucketCounts.map((count2) => fixed64Field(6, BigInt(count2))));
1283
1303
  const explicitBoundsEncoded = concat(...point.explicitBounds.map((bound) => doubleField(7, bound)));
1284
1304
  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));
1285
1305
  };
@@ -1387,8 +1407,8 @@ var makeLogRecord = (options, opts) => {
1387
1407
  const now = opts.clock.currentTimeNanosUnsafe();
1388
1408
  const nanosString = now.toString();
1389
1409
  const nowMillis = options.date.getTime();
1390
- const attributes = entriesToAttributes(Object.entries(options.fiber.getRef(CurrentLogAnnotations)));
1391
- attributes.push({
1410
+ const attributes2 = entriesToAttributes(Object.entries(options.fiber.getRef(CurrentLogAnnotations)));
1411
+ attributes2.push({
1392
1412
  key: "fiberId",
1393
1413
  value: {
1394
1414
  intValue: options.fiber.id
@@ -1396,7 +1416,7 @@ var makeLogRecord = (options, opts) => {
1396
1416
  });
1397
1417
  if (!opts.excludeLogSpans) {
1398
1418
  for (const [label, startTime] of options.fiber.getRef(CurrentLogSpans)) {
1399
- attributes.push({
1419
+ attributes2.push({
1400
1420
  key: `logSpan.${label}`,
1401
1421
  value: {
1402
1422
  stringValue: `${nowMillis - startTime}ms`
@@ -1405,7 +1425,7 @@ var makeLogRecord = (options, opts) => {
1405
1425
  }
1406
1426
  }
1407
1427
  if (options.cause.reasons.length > 0) {
1408
- attributes.push({
1428
+ attributes2.push({
1409
1429
  key: "log.error",
1410
1430
  value: {
1411
1431
  stringValue: pretty(options.cause)
@@ -1418,7 +1438,7 @@ var makeLogRecord = (options, opts) => {
1418
1438
  severityText: options.logLevel,
1419
1439
  timeUnixNano: nanosString,
1420
1440
  observedTimeUnixNano: nanosString,
1421
- attributes,
1441
+ attributes: attributes2,
1422
1442
  body: unknownToAttributeValue(message.length === 1 ? message[0] : message),
1423
1443
  droppedAttributesCount: 0
1424
1444
  };
@@ -1521,7 +1541,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1521
1541
  for (let i = 0, len = snapshot2.length; i < len; i++) {
1522
1542
  const state = snapshot2[i];
1523
1543
  const unit = state.attributes?.unit ?? state.attributes?.time_unit ?? "1";
1524
- const attributes = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1544
+ const attributes2 = state.attributes ? entriesToAttributes(Object.entries(state.attributes)) : [];
1525
1545
  const metricKey = makeMetricKey(state.id, state.attributes);
1526
1546
  switch (state.type) {
1527
1547
  case "Counter": {
@@ -1547,7 +1567,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1547
1567
  nextCounterState.set(metricKey, currentCount);
1548
1568
  }
1549
1569
  const dataPoint = {
1550
- attributes,
1570
+ attributes: attributes2,
1551
1571
  startTimeUnixNano: intervalStartTime,
1552
1572
  timeUnixNano: nowTime
1553
1573
  };
@@ -1574,7 +1594,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1574
1594
  }
1575
1595
  case "Gauge": {
1576
1596
  const dataPoint = {
1577
- attributes,
1597
+ attributes: attributes2,
1578
1598
  startTimeUnixNano: startTime,
1579
1599
  timeUnixNano: nowTime
1580
1600
  };
@@ -1634,7 +1654,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1634
1654
  });
1635
1655
  }
1636
1656
  const dataPoint = {
1637
- attributes,
1657
+ attributes: attributes2,
1638
1658
  startTimeUnixNano: intervalStartTime,
1639
1659
  timeUnixNano: nowTime,
1640
1660
  count: reportCount,
@@ -1673,7 +1693,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1673
1693
  }
1674
1694
  }
1675
1695
  dataPoints.push({
1676
- attributes: [...attributes, {
1696
+ attributes: [...attributes2, {
1677
1697
  key: "key",
1678
1698
  value: {
1679
1699
  stringValue: freqKey
@@ -1705,7 +1725,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1705
1725
  }
1706
1726
  case "Summary": {
1707
1727
  const dataPoints = [{
1708
- attributes: [...attributes, {
1728
+ attributes: [...attributes2, {
1709
1729
  key: "quantile",
1710
1730
  value: {
1711
1731
  stringValue: "min"
@@ -1717,7 +1737,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1717
1737
  }];
1718
1738
  for (const [quantile, value] of state.state.quantiles) {
1719
1739
  dataPoints.push({
1720
- attributes: [...attributes, {
1740
+ attributes: [...attributes2, {
1721
1741
  key: "quantile",
1722
1742
  value: {
1723
1743
  stringValue: quantile.toString()
@@ -1729,7 +1749,7 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1729
1749
  });
1730
1750
  }
1731
1751
  dataPoints.push({
1732
- attributes: [...attributes, {
1752
+ attributes: [...attributes2, {
1733
1753
  key: "quantile",
1734
1754
  value: {
1735
1755
  stringValue: "max"
@@ -1753,13 +1773,13 @@ var make7 = /* @__PURE__ */ fnUntraced(function* (options) {
1753
1773
  });
1754
1774
  }
1755
1775
  const countDataPoint = {
1756
- attributes,
1776
+ attributes: attributes2,
1757
1777
  startTimeUnixNano: intervalStartTime,
1758
1778
  timeUnixNano: nowTime,
1759
1779
  asInt: reportCount
1760
1780
  };
1761
1781
  const sumDataPoint = {
1762
- attributes,
1782
+ attributes: attributes2,
1763
1783
  startTimeUnixNano: intervalStartTime,
1764
1784
  timeUnixNano: nowTime,
1765
1785
  asDouble: reportSum
@@ -1872,11 +1892,11 @@ var layerFromConfig2 = (options) => gen(function* () {
1872
1892
  temporality: getOrUndefined(temporalityPreference)
1873
1893
  });
1874
1894
  }).pipe(orDie, unwrap);
1875
- var makeMetricKey = (id, attributes) => {
1876
- if (attributes === void 0 || Object.keys(attributes).length === 0) {
1895
+ var makeMetricKey = (id, attributes2) => {
1896
+ if (attributes2 === void 0 || Object.keys(attributes2).length === 0) {
1877
1897
  return id;
1878
1898
  }
1879
- const sortedEntries = Object.entries(attributes).sort((a, b) => a[0].localeCompare(b[0]));
1899
+ const sortedEntries = Object.entries(attributes2).sort((a, b) => a[0].localeCompare(b[0]));
1880
1900
  return `${id}:${JSON.stringify(sortedEntries)}`;
1881
1901
  };
1882
1902
  var EAggregationTemporality = {
@@ -2076,39 +2096,39 @@ var SpanImpl = class {
2076
2096
  attribute(key, value) {
2077
2097
  this.attributes.set(key, value);
2078
2098
  }
2079
- event(name, startTime, attributes) {
2080
- this.events.push([name, startTime, attributes]);
2099
+ event(name, startTime, attributes2) {
2100
+ this.events.push([name, startTime, attributes2]);
2081
2101
  }
2082
2102
  addLinks(links) {
2083
2103
  this.links.push(...links);
2084
2104
  }
2085
2105
  };
2086
2106
  var makeOtlpSpan = (self) => {
2087
- const status = self.status;
2088
- const attributes = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2107
+ const status2 = self.status;
2108
+ const attributes2 = self._attributes === void 0 ? [] : entriesToAttributes(self._attributes);
2089
2109
  const events = [];
2090
2110
  if (self._events !== void 0) {
2091
2111
  for (let i = 0; i < self._events.length; i++) {
2092
- const [name, startTime, attributes2] = self._events[i];
2112
+ const [name, startTime, attributes3] = self._events[i];
2093
2113
  events.push({
2094
2114
  name,
2095
2115
  timeUnixNano: String(startTime),
2096
- attributes: attributes2 ? entriesToAttributes(Object.entries(attributes2)) : [],
2116
+ attributes: attributes3 ? entriesToAttributes(Object.entries(attributes3)) : [],
2097
2117
  droppedAttributesCount: 0
2098
2118
  });
2099
2119
  }
2100
2120
  }
2101
2121
  let otelStatus;
2102
- if (status.exit._tag === "Success") {
2122
+ if (status2.exit._tag === "Success") {
2103
2123
  otelStatus = {
2104
2124
  code: StatusCode.Ok
2105
2125
  };
2106
- } else if (hasInterruptsOnly(status.exit.cause)) {
2126
+ } else if (hasInterruptsOnly(status2.exit.cause)) {
2107
2127
  otelStatus = {
2108
2128
  code: StatusCode.Ok,
2109
2129
  message: "Interrupted"
2110
2130
  };
2111
- attributes.push({
2131
+ attributes2.push({
2112
2132
  key: "span.label",
2113
2133
  value: {
2114
2134
  stringValue: "\u26A0\uFE0E Interrupted"
@@ -2120,7 +2140,7 @@ var makeOtlpSpan = (self) => {
2120
2140
  }
2121
2141
  });
2122
2142
  } else {
2123
- const errors = prettyErrors(status.exit.cause, {
2143
+ const errors = prettyErrors(status2.exit.cause, {
2124
2144
  includeCauseInStack: true
2125
2145
  });
2126
2146
  otelStatus = {
@@ -2131,7 +2151,7 @@ var makeOtlpSpan = (self) => {
2131
2151
  for (const error of errors) {
2132
2152
  events.push({
2133
2153
  name: "exception",
2134
- timeUnixNano: String(status.endTime),
2154
+ timeUnixNano: String(status2.endTime),
2135
2155
  droppedAttributesCount: 0,
2136
2156
  attributes: [{
2137
2157
  "key": "exception.type",
@@ -2169,9 +2189,9 @@ var makeOtlpSpan = (self) => {
2169
2189
  parentSpanId: isSome(self.parent) ? self.parent.value.spanId : void 0,
2170
2190
  name: self.name,
2171
2191
  kind: SpanKind[self.kind],
2172
- startTimeUnixNano: String(status.startTime),
2173
- endTimeUnixNano: String(status.endTime),
2174
- attributes,
2192
+ startTimeUnixNano: String(status2.startTime),
2193
+ endTimeUnixNano: String(status2.endTime),
2194
+ attributes: attributes2,
2175
2195
  droppedAttributesCount: 0,
2176
2196
  events,
2177
2197
  droppedEventsCount: 0,
@@ -2247,6 +2267,309 @@ var telemetryLayer = (config, lifetime = "process", logger = Logger_exports.with
2247
2267
  );
2248
2268
  };
2249
2269
 
2270
+ // ../telemetry/src/app-records.ts
2271
+ var appText = "Text from the app is not recorded";
2272
+ var unrecognized = "unrecognized";
2273
+ var operations = [
2274
+ "requirements",
2275
+ "inspect",
2276
+ "skills",
2277
+ "query",
2278
+ "mutate",
2279
+ "call",
2280
+ "account-check",
2281
+ "webhooks",
2282
+ "webhook-validate",
2283
+ "webhook-complete",
2284
+ "webhook-register",
2285
+ "webhook-unregister",
2286
+ "webhook-handle",
2287
+ "workflows",
2288
+ "workflow-validate",
2289
+ "workflow-run"
2290
+ ];
2291
+ var httpMethods = [
2292
+ "GET",
2293
+ "HEAD",
2294
+ "POST",
2295
+ "PUT",
2296
+ "PATCH",
2297
+ "DELETE",
2298
+ "OPTIONS",
2299
+ "TRACE",
2300
+ "CONNECT"
2301
+ ];
2302
+ var appSpanNames = /* @__PURE__ */ new Set([
2303
+ "app.dispatch",
2304
+ ...operations.map((operation) => `app.${operation}`),
2305
+ "app.evaluate",
2306
+ "app.accounts.bind",
2307
+ "app.account.check",
2308
+ "app.catalog.read",
2309
+ "app.skills.load",
2310
+ "app.skills.routers",
2311
+ "app.tool.approval",
2312
+ "app.tool.elicitation",
2313
+ "app.operation.execute",
2314
+ "app.cache.get",
2315
+ "app.cache.load",
2316
+ "app.cache.command",
2317
+ "app.cache.publish",
2318
+ "app.cache.flush",
2319
+ "app.cache.lease.renew",
2320
+ "provider.http.request",
2321
+ "provider.http.response.read",
2322
+ "provider.openapi.call",
2323
+ "provider.graphql.request",
2324
+ "provider.graphql.call",
2325
+ "provider.mcp.session",
2326
+ "provider.mcp.connect",
2327
+ "provider.mcp.close",
2328
+ "provider.mcp.request",
2329
+ "provider.mcp.call",
2330
+ "provider.mcp.discover",
2331
+ "provider.mcp.check",
2332
+ "provider.mcp.health",
2333
+ "provider.mcp.anonymous",
2334
+ "provider.mcp.elicitation",
2335
+ "sql.execute",
2336
+ ...httpMethods.map((method) => `http.client ${method}`)
2337
+ ]);
2338
+ var errorKinds = /* @__PURE__ */ new Set([
2339
+ "HostRequestInvalid",
2340
+ "HostAccountsInvalid",
2341
+ "HostDeclarationInvalid",
2342
+ "HostEvaluationFailed",
2343
+ "HostOperationNotFound",
2344
+ "HostOperationFailed",
2345
+ "HostKindMismatch",
2346
+ "HostToolNotFound",
2347
+ "HostInputInvalid",
2348
+ "HostOutputInvalid",
2349
+ "HostToolBlocked",
2350
+ "HostToolApprovalRequired",
2351
+ "HostToolPolicyFailed",
2352
+ "ElicitationFailed",
2353
+ "DatabaseLimitExceeded",
2354
+ "DatabaseFieldReserved",
2355
+ "SkillLoadFailed",
2356
+ "WorkflowFailure",
2357
+ "ProviderError",
2358
+ "OpenapiResponseError",
2359
+ "OpenapiError",
2360
+ "OpenapiCompileError",
2361
+ "GraphqlError",
2362
+ "McpError",
2363
+ "McpToolError",
2364
+ "McpCredentialsUnverified",
2365
+ "CacheError",
2366
+ "AppDatabaseError",
2367
+ "AppStorageError",
2368
+ "AppStorageUnavailable",
2369
+ "NetworkRefused",
2370
+ "FetchOptionUnsupported",
2371
+ "LogicalOperationFailed",
2372
+ "HttpClientError",
2373
+ "SchemaError",
2374
+ "TimeoutError",
2375
+ "UnknownError",
2376
+ "InterruptError",
2377
+ "Error",
2378
+ "TypeError",
2379
+ "RangeError",
2380
+ "ReferenceError",
2381
+ "SyntaxError",
2382
+ "EvalError",
2383
+ "URIError",
2384
+ "AggregateError",
2385
+ "AbortError",
2386
+ "string",
2387
+ "number",
2388
+ "bigint",
2389
+ "boolean",
2390
+ "symbol",
2391
+ "undefined",
2392
+ "object",
2393
+ "function"
2394
+ ]);
2395
+ var failureCodes = /* @__PURE__ */ new Set([
2396
+ // CacheError
2397
+ "unavailable",
2398
+ "storage",
2399
+ "invalid",
2400
+ "capacity",
2401
+ "timeout",
2402
+ // AppDatabaseError
2403
+ "schema",
2404
+ "schema_changed",
2405
+ "table",
2406
+ "index",
2407
+ "range",
2408
+ "value",
2409
+ "readonly",
2410
+ "cursor",
2411
+ "limit",
2412
+ "closed",
2413
+ "replay",
2414
+ // OpenapiError
2415
+ "invalid_definition",
2416
+ "invalid_input",
2417
+ "request",
2418
+ // McpError, McpCredentialsUnverified and ProviderError
2419
+ "unauthorized",
2420
+ "invalid_response",
2421
+ "forbidden",
2422
+ "rate_limited",
2423
+ "rejected",
2424
+ "anonymous_access",
2425
+ // NetworkRefused and FetchOptionUnsupported
2426
+ "private_address",
2427
+ "credential_host",
2428
+ "credential_app",
2429
+ "credential_expired",
2430
+ "redirect",
2431
+ "cache",
2432
+ "integrity"
2433
+ ]);
2434
+ var text = (value) => typeof value["stringValue"] === "string" ? value["stringValue"] : void 0;
2435
+ var integer = (value) => {
2436
+ const raw = value["intValue"];
2437
+ const number = typeof raw === "string" && /^-?\d{1,15}$/.test(raw) ? Number(raw) : raw;
2438
+ return typeof number === "number" && Number.isSafeInteger(number) ? number : void 0;
2439
+ };
2440
+ var oneOf = (...values) => (value) => {
2441
+ const found = text(value);
2442
+ return found !== void 0 && values.includes(found) ? { stringValue: found } : void 0;
2443
+ };
2444
+ var classified = (known) => (value) => {
2445
+ const found = text(value);
2446
+ return found === void 0 ? void 0 : { stringValue: known.has(found) ? found : unrecognized };
2447
+ };
2448
+ var flag = (value) => typeof value["boolValue"] === "boolean" ? { boolValue: value["boolValue"] } : void 0;
2449
+ var count = (value) => {
2450
+ const found = integer(value);
2451
+ return found !== void 0 && found >= 0 ? { intValue: found } : void 0;
2452
+ };
2453
+ var status = (value) => {
2454
+ const found = integer(value);
2455
+ return found !== void 0 && found >= 100 && found <= 599 ? { intValue: found } : void 0;
2456
+ };
2457
+ var spanAttributes2 = {
2458
+ "executor.operation": oneOf(...operations, "mutation", "discover"),
2459
+ "executor.outcome": oneOf("failed"),
2460
+ "executor.clock.type": oneOf("system", "cloudflare-io"),
2461
+ "executor.trace.parent_sampled": flag,
2462
+ "executor.failure.source": oneOf("app", "storage", "service"),
2463
+ "executor.failure.code": classified(failureCodes),
2464
+ "error.type": classified(errorKinds),
2465
+ "cache.operation": oneOf(
2466
+ "read",
2467
+ "acquire",
2468
+ "claim",
2469
+ "publish",
2470
+ "release",
2471
+ "renew",
2472
+ "write",
2473
+ "invalidate"
2474
+ ),
2475
+ "cache.result": oneOf("fresh", "stale", "miss", "local"),
2476
+ "cache.load.leased": flag,
2477
+ "cache.flush.index": count,
2478
+ "cache.flush.count": count,
2479
+ "cache.flush.entries": count,
2480
+ "cache.flush.bytes": count,
2481
+ "cache.leases": count,
2482
+ "mcp.transport": oneOf("http", "sse", "stdio"),
2483
+ "mcp.operation": oneOf("discover", "call", "check", "health"),
2484
+ "mcp.tool.is_error": flag,
2485
+ "rpc.system.name": oneOf("jsonrpc"),
2486
+ "rpc.method": oneOf("initialize", "tools/list", "tools/call", "ping"),
2487
+ "graphql.operation.type": oneOf("query", "mutation", "subscription"),
2488
+ "db.system.name": oneOf("sqlite"),
2489
+ "db.operation.name": oneOf("execute"),
2490
+ "http.request.method": oneOf(...httpMethods),
2491
+ "http.response.status_code": status,
2492
+ "url.scheme": oneOf("http", "https"),
2493
+ "span.label": oneOf("\u26A0\uFE0E Interrupted"),
2494
+ "status.interrupted": flag,
2495
+ "executor.milestone.reached": flag
2496
+ };
2497
+ var appSpanAttributeKeys = new Set(Object.keys(spanAttributes2));
2498
+ var logMessages = /* @__PURE__ */ new Set([
2499
+ "The app's request failed unexpectedly",
2500
+ "App cache refresh failed",
2501
+ "MCP catalog invalidation failed",
2502
+ "Telemetry export failed"
2503
+ ]);
2504
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2505
+ var spanId = (value) => typeof value === "string" && /^[a-f0-9]{16}$/.test(value) ? value : void 0;
2506
+ var nanos = (value) => typeof value === "string" && /^\d{1,20}$/.test(value) ? value : void 0;
2507
+ var between = (value, minimum, maximum) => typeof value === "number" && Number.isInteger(value) && value >= minimum && value <= maximum ? value : void 0;
2508
+ var attributes = (from) => (Array.isArray(from) ? from : []).flatMap((attribute) => {
2509
+ if (!isObject(attribute) || typeof attribute["key"] !== "string") return [];
2510
+ const key = attribute["key"];
2511
+ const keep = Object.hasOwn(spanAttributes2, key) ? spanAttributes2[key] : void 0;
2512
+ const value = attribute["value"];
2513
+ const kept = keep === void 0 || !isObject(value) ? void 0 : keep(value);
2514
+ return kept === void 0 ? [] : [{ key, value: kept }];
2515
+ });
2516
+ var exception = (event) => {
2517
+ const named = (Array.isArray(event["attributes"]) ? event["attributes"] : []).find(
2518
+ (attribute) => isObject(attribute) && attribute["key"] === "exception.type"
2519
+ );
2520
+ const type = isObject(named) && isObject(named["value"]) ? text(named["value"]) : void 0;
2521
+ const recorded = type !== void 0 && errorKinds.has(type) ? type : unrecognized;
2522
+ const time = nanos(event["timeUnixNano"]);
2523
+ return {
2524
+ name: "exception",
2525
+ ...time === void 0 ? {} : { timeUnixNano: time },
2526
+ attributes: [
2527
+ { key: "exception.type", value: { stringValue: recorded } },
2528
+ { key: "exception.message", value: { stringValue: appText } },
2529
+ { key: "exception.stacktrace", value: { stringValue: `${recorded}: ${appText}` } }
2530
+ ]
2531
+ };
2532
+ };
2533
+ var appSpan = (span) => {
2534
+ const start = nanos(span["startTimeUnixNano"]);
2535
+ const end = nanos(span["endTimeUnixNano"]);
2536
+ if (start === void 0 || end === void 0) return void 0;
2537
+ const parent = spanId(span["parentSpanId"]);
2538
+ const kind = between(span["kind"], 0, 5);
2539
+ const code = isObject(span["status"]) ? between(span["status"]["code"], 0, 2) : void 0;
2540
+ const name = typeof span["name"] === "string" && appSpanNames.has(span["name"]) ? span["name"] : "app.unrecognized";
2541
+ return {
2542
+ traceId: span.traceId,
2543
+ spanId: span.spanId,
2544
+ ...parent === void 0 ? {} : { parentSpanId: parent },
2545
+ name,
2546
+ ...kind === void 0 ? {} : { kind },
2547
+ startTimeUnixNano: start,
2548
+ endTimeUnixNano: end,
2549
+ attributes: attributes(span["attributes"]),
2550
+ events: (Array.isArray(span["events"]) ? span["events"] : []).flatMap(
2551
+ (event) => isObject(event) && event["name"] === "exception" ? [exception(event)] : []
2552
+ ),
2553
+ ...code === void 0 ? {} : { status: { code } }
2554
+ };
2555
+ };
2556
+ var appLog = (log) => {
2557
+ const time = nanos(log["timeUnixNano"]);
2558
+ const observed = nanos(log["observedTimeUnixNano"]);
2559
+ const severity = between(log["severityNumber"], 1, 24);
2560
+ const level = log["severityText"];
2561
+ const body = isObject(log["body"]) ? text(log["body"]) : void 0;
2562
+ return {
2563
+ ...log.traceId === void 0 ? {} : { traceId: log.traceId },
2564
+ ...log.spanId === void 0 ? {} : { spanId: log.spanId },
2565
+ ...time === void 0 ? {} : { timeUnixNano: time },
2566
+ ...observed === void 0 ? {} : { observedTimeUnixNano: observed },
2567
+ ...severity === void 0 ? {} : { severityNumber: severity },
2568
+ ...typeof level === "string" && ["Trace", "Debug", "Info", "Warn", "Error", "Fatal"].includes(level) ? { severityText: level } : {},
2569
+ body: { stringValue: body !== void 0 && logMessages.has(body) ? body : appText }
2570
+ };
2571
+ };
2572
+
2250
2573
  // ../telemetry/src/relay.ts
2251
2574
  var makeTelemetryForwarder = Effect_exports.gen(function* () {
2252
2575
  const fibers = yield* FiberSet_exports.make();
@@ -2420,7 +2743,11 @@ var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effe
2420
2743
  scopeSpans: [
2421
2744
  {
2422
2745
  scope: { name: service },
2423
- spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId)
2746
+ spans: payloads.flatMap((payload) => payload.resourceSpans).flatMap((r) => r.scopeSpans.flatMap((s) => s.spans)).filter((span) => traceId === void 0 || span.traceId === traceId).flatMap((span) => {
2747
+ if (service !== "executor-app") return [span];
2748
+ const kept = appSpan(span);
2749
+ return kept === void 0 ? [] : [kept];
2750
+ })
2424
2751
  }
2425
2752
  ]
2426
2753
  }
@@ -2437,7 +2764,7 @@ var forwardTelemetry = (batch, traceId, build, service = "executor-app") => Effe
2437
2764
  scopeLogs: [
2438
2765
  {
2439
2766
  scope: { name: service },
2440
- logRecords: payloads.flatMap((payload) => payload.resourceLogs).flatMap((r) => r.scopeLogs.flatMap((s) => s.logRecords)).filter((log) => traceId === void 0 || log.traceId === traceId)
2767
+ 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)
2441
2768
  }
2442
2769
  ]
2443
2770
  }