@rasputin-ai/node 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/rasputin-init.ts
2
2
  import { join } from "node:path";
3
3
  import {
4
+ copyRedactKeys,
4
5
  createClient,
5
6
  isClientEnabled
6
7
  } from "@rasputin-ai/core";
@@ -16,7 +17,7 @@ import {
16
17
  // ../recorder/src/run-exactly-once.ts
17
18
  var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
18
19
  let outcome;
19
- const wrapped = function __rasputinHandleRun__3() {
20
+ const wrapped = function __rasputinHandleRun__4() {
20
21
  try {
21
22
  const value = callback();
22
23
  outcome = { kind: "value", value };
@@ -36,56 +37,19 @@ var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
36
37
  };
37
38
 
38
39
  // ../recorder/src/call-handle.ts
39
- var passthroughHandle = () => ({
40
+ var sharedPassthroughHandle = {
40
41
  leave: (value) => value,
41
42
  fail: () => {
42
43
  },
43
44
  end: () => {
44
45
  },
45
- run: function __rasputinHandleRun__3(callback) {
46
+ run: function __rasputinHandleRun__2(callback) {
46
47
  return runExactlyOnce((invoke) => invoke(), callback);
47
48
  },
48
49
  suspend: (value) => value,
49
50
  resume: (value) => value
50
- });
51
- var isolateHandle = (handle) => ({
52
- leave: (value) => {
53
- try {
54
- return handle.leave(value);
55
- } catch {
56
- return value;
57
- }
58
- },
59
- fail: (error, liveArgs) => {
60
- try {
61
- handle.fail(error, liveArgs);
62
- } catch {
63
- }
64
- },
65
- end: () => {
66
- try {
67
- handle.end();
68
- } catch {
69
- }
70
- },
71
- run: function __rasputinHandleRun__3(callback) {
72
- return runExactlyOnce((invoke) => handle.run(invoke), callback);
73
- },
74
- suspend: (value) => {
75
- try {
76
- return handle.suspend(value);
77
- } catch {
78
- return value;
79
- }
80
- },
81
- resume: (value) => {
82
- try {
83
- return handle.resume(value);
84
- } catch {
85
- return value;
86
- }
87
- }
88
- });
51
+ };
52
+ var passthroughHandle = () => sharedPassthroughHandle;
89
53
 
90
54
  // ../recorder/src/encoded-function-plan.ts
91
55
  var encodedPlanOmitsCallValues = (plan) => plan[6] === 1;
@@ -701,7 +665,6 @@ var scheduleInstrumentationManifestUpload = (options) => {
701
665
  // src/execution-recorder/execution-recorder.ts
702
666
  import { AsyncLocalStorage } from "node:async_hooks";
703
667
  import {
704
- createEnvSecretMatcher,
705
668
  rasputinOmitted,
706
669
  rasputinTagKind,
707
670
  runtimeFunctionId as runtimeFunctionId2
@@ -1148,7 +1111,7 @@ var RecorderMemoryBudget = class {
1148
1111
  }
1149
1112
  return allocation;
1150
1113
  }
1151
- captureValue(allocation, serialize) {
1114
+ captureValue(allocation, value, freeze) {
1152
1115
  if (allocation.released) {
1153
1116
  this.dropValues(allocation, 1);
1154
1117
  return MEMORY_BUDGET_VALUE_MARKER;
@@ -1163,13 +1126,13 @@ var RecorderMemoryBudget = class {
1163
1126
  this.dropValues(allocation, 1);
1164
1127
  return MEMORY_BUDGET_VALUE_MARKER;
1165
1128
  }
1166
- const serialized = serialize();
1167
- if (!this.reserve(allocation, serialized.bytes * VALUE_HEAP_ESTIMATE_MULTIPLIER)) {
1129
+ const frozen = freeze(value);
1130
+ if (!this.reserve(allocation, frozen.estimatedBytes * VALUE_HEAP_ESTIMATE_MULTIPLIER)) {
1168
1131
  this.markPressure(allocation, "structure-only");
1169
1132
  this.dropValues(allocation, 1);
1170
1133
  return MEMORY_BUDGET_VALUE_MARKER;
1171
1134
  }
1172
- return serialized.value;
1135
+ return frozen.value;
1173
1136
  }
1174
1137
  reserveCall(allocation, estimatedBytes) {
1175
1138
  if (allocation.mode === "metadata-only") {
@@ -1253,7 +1216,16 @@ import {
1253
1216
  } from "@rasputin-ai/core";
1254
1217
  var MAX_RUNTIME_STATE_BYTES = 256 * 1024;
1255
1218
  var VALUE_OMITTED_REASON = "runtime_state_size_budget";
1256
- var encodedBytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
1219
+ var RUNTIME_STATE_ENCODED_BYTES = Symbol.for("rasputin.runtime_state_encoded_bytes");
1220
+ var encodedBytes = (state) => {
1221
+ const bytes = Buffer.byteLength(JSON.stringify(state), "utf8");
1222
+ Object.defineProperty(state, RUNTIME_STATE_ENCODED_BYTES, {
1223
+ value: bytes,
1224
+ enumerable: false,
1225
+ configurable: true
1226
+ });
1227
+ return bytes;
1228
+ };
1257
1229
  var sizeMetadata = (originalBytes) => ({
1258
1230
  reason: "runtime_state_size_budget",
1259
1231
  originalBytes,
@@ -1419,51 +1391,12 @@ var enforceRuntimeStateSizeBudget = (input) => {
1419
1391
 
1420
1392
  // src/execution-recorder/encode-frozen.ts
1421
1393
  import { Buffer as Buffer3 } from "node:buffer";
1422
- import { RASPUTIN_REDACTED as RASPUTIN_REDACTED2 } from "@rasputin-ai/core";
1394
+ import { RASPUTIN_REDACTED } from "@rasputin-ai/core";
1423
1395
 
1424
1396
  // src/execution-recorder/value-freeze.ts
1425
1397
  import { Buffer as Buffer2 } from "node:buffer";
1426
1398
  import { types } from "node:util";
1427
- import {
1428
- MAX_ENV_SECRET_NEEDLE_LENGTH,
1429
- RASPUTIN_REDACTED,
1430
- RASPUTIN_WIRE_TAG
1431
- } from "@rasputin-ai/core";
1432
-
1433
- // src/execution-recorder/redact-keys.ts
1434
- import { defaultSensitivePropertyNames, propertyNameIsSensitive } from "@rasputin-ai/core";
1435
- var compactKey = (key) => {
1436
- let compacted = "";
1437
- for (let index = 0; index < key.length; index++) {
1438
- const code = key.charCodeAt(index);
1439
- if (code === 45 || code === 46 || code === 95) continue;
1440
- compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
1441
- }
1442
- return compacted;
1443
- };
1444
- var stripTrailingDigits = (value) => {
1445
- let end = value.length;
1446
- while (end > 0) {
1447
- const code = value.charCodeAt(end - 1);
1448
- if (code < 48 || code > 57) break;
1449
- end--;
1450
- }
1451
- return end === 0 ? value : value.slice(0, end);
1452
- };
1453
- var normalizeKey = (key) => stripTrailingDigits(compactKey(key));
1454
- var compileRedactKeys = (extra) => {
1455
- if (!extra?.length) return defaultSensitivePropertyNames();
1456
- return /* @__PURE__ */ new Set([...defaultSensitivePropertyNames(), ...extra.map(normalizeKey)]);
1457
- };
1458
- var keyIsRedacted = (key, redactKeys) => {
1459
- if (propertyNameIsSensitive(key)) return true;
1460
- if (redactKeys.has(key)) return true;
1461
- const compacted = compactKey(key);
1462
- if (redactKeys.has(compacted)) return true;
1463
- return redactKeys.has(stripTrailingDigits(compacted));
1464
- };
1465
-
1466
- // src/execution-recorder/value-freeze.ts
1399
+ import { RASPUTIN_WIRE_TAG } from "@rasputin-ai/core";
1467
1400
  var defaults = {
1468
1401
  maxDepth: 3,
1469
1402
  maxObjectKeys: 30,
@@ -1491,16 +1424,20 @@ var atom = (kind, extra = {}) => ({
1491
1424
  [FROZEN]: kind,
1492
1425
  ...extra
1493
1426
  });
1494
- var ownData = (value, key) => {
1427
+ var NO_DATA = Symbol("rasputin.no-data");
1428
+ var ownValue = (value, key) => {
1495
1429
  try {
1496
1430
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
1497
- if (!descriptor) return void 0;
1498
- if ("value" in descriptor) return { present: true, value: descriptor.value };
1499
- return void 0;
1431
+ if (descriptor && "value" in descriptor) return descriptor.value;
1432
+ return NO_DATA;
1500
1433
  } catch {
1501
- return void 0;
1434
+ return NO_DATA;
1502
1435
  }
1503
1436
  };
1437
+ var copyBoundedString = (value) => {
1438
+ if (value.length === 0) return value;
1439
+ return Buffer2.from(value, "utf16le").toString("utf16le");
1440
+ };
1504
1441
  var nativeErrorStackGet = (() => {
1505
1442
  try {
1506
1443
  return Object.getOwnPropertyDescriptor(Error.prototype, "stack")?.get;
@@ -1556,8 +1493,8 @@ var isDomException = (value) => {
1556
1493
  }
1557
1494
  };
1558
1495
  var functionNameOf = (value) => {
1559
- const own = ownData(value, "name");
1560
- if (own && typeof own.value === "string" && own.value.length > 0) return own.value;
1496
+ const name = ownValue(value, "name");
1497
+ if (typeof name === "string" && name.length > 0) return name;
1561
1498
  return "anonymous";
1562
1499
  };
1563
1500
  var errorNameOf = (value) => {
@@ -1570,8 +1507,8 @@ var errorNameOf = (value) => {
1570
1507
  }
1571
1508
  let current = value;
1572
1509
  while (current) {
1573
- const slot = ownData(current, "name");
1574
- if (slot && typeof slot.value === "string" && slot.value.length > 0) return slot.value;
1510
+ const name = ownValue(current, "name");
1511
+ if (typeof name === "string" && name.length > 0) return name;
1575
1512
  try {
1576
1513
  current = Object.getPrototypeOf(current);
1577
1514
  } catch {
@@ -1587,8 +1524,8 @@ var errorMessageOf = (value) => {
1587
1524
  } catch {
1588
1525
  }
1589
1526
  }
1590
- const own = ownData(value, "message");
1591
- if (own) return own.value;
1527
+ const message = ownValue(value, "message");
1528
+ if (message !== NO_DATA) return message;
1592
1529
  if (!nativeErrorMessageGet) return void 0;
1593
1530
  try {
1594
1531
  return nativeErrorMessageGet.call(value);
@@ -1597,8 +1534,8 @@ var errorMessageOf = (value) => {
1597
1534
  }
1598
1535
  };
1599
1536
  var errorStackOf = (value) => withoutPrepareStackTrace(() => {
1600
- const own = ownData(value, "stack");
1601
- if (own && typeof own.value === "string" && own.value.length > 0) return own.value;
1537
+ const ownStack = ownValue(value, "stack");
1538
+ if (typeof ownStack === "string" && ownStack.length > 0) return ownStack;
1602
1539
  try {
1603
1540
  const getter = Object.getOwnPropertyDescriptor(value, "stack")?.get;
1604
1541
  if (getter && nativeInstanceStackGet && getter === nativeInstanceStackGet) {
@@ -1658,24 +1595,23 @@ var sampleBytes = (bytes, max) => {
1658
1595
  for (let index = 0; index < length; index++) sample[index] = bytes[index] ?? 0;
1659
1596
  return sample;
1660
1597
  };
1661
- var RESERVED_USER_KEYS = /* @__PURE__ */ new Set([
1662
- "__proto__",
1663
- "__rasputin_type",
1664
- "__rasputin_truncated",
1665
- "__rasputin_fields",
1666
- "__reason",
1667
- "__original_length",
1668
- "__serialized_bytes"
1669
- ]);
1670
- var assignFrozenField = (fields, key, value) => {
1671
- if (RESERVED_USER_KEYS.has(key) || key.startsWith("__rasputin_")) {
1672
- const escaped = fields.__rasputin_fields ?? [];
1673
- escaped.push({ name: key, value });
1674
- fields.__rasputin_fields = escaped;
1675
- return;
1598
+ var KEY_META_CAP = 1024;
1599
+ var KEY_META_MAX_CHARS = 256;
1600
+ var keyMetaCache = /* @__PURE__ */ new Map();
1601
+ var keyMeta = (key) => {
1602
+ const cached = keyMetaCache.get(key);
1603
+ if (cached) return cached;
1604
+ const meta = { utf8Bytes: Buffer2.byteLength(key, "utf8") };
1605
+ if (key.length <= KEY_META_MAX_CHARS && keyMetaCache.size < KEY_META_CAP) {
1606
+ keyMetaCache.set(key, meta);
1676
1607
  }
1677
- fields[key] = value;
1608
+ return meta;
1678
1609
  };
1610
+ var frozenRecord = (keys, values) => ({
1611
+ [FROZEN]: "record",
1612
+ keys,
1613
+ values
1614
+ });
1679
1615
  var ownEnumerableKeys = (value, maxKeys) => {
1680
1616
  const keys = [];
1681
1617
  let proto = null;
@@ -1705,97 +1641,8 @@ var bufferByteLength = (value) => {
1705
1641
  }
1706
1642
  };
1707
1643
  var stringEstimate = (value) => NODE + 2 + Buffer2.byteLength(value, "utf8");
1708
- var URL_LIKE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
1709
- "url",
1710
- "href",
1711
- "originalurl",
1712
- "path",
1713
- "pathname",
1714
- "search",
1715
- "query",
1716
- "requesturl",
1717
- "requesturi",
1718
- "location",
1719
- "referer",
1720
- "referrer",
1721
- "uri",
1722
- "connectionuri",
1723
- "connectionurl",
1724
- "databaseuri",
1725
- "databaseurl",
1726
- "mongouri",
1727
- "mongourl",
1728
- "redisuri",
1729
- "redisurl",
1730
- "postgresuri",
1731
- "postgresurl"
1732
- ]);
1733
- var compactPropertyName = (key) => {
1734
- let compacted = "";
1735
- for (let index = 0; index < key.length; index++) {
1736
- const code = key.charCodeAt(index);
1737
- if (code === 45 || code === 46 || code === 95) continue;
1738
- compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
1739
- }
1740
- return compacted;
1741
- };
1742
- var propertyNameLooksLikeUrl = (key) => URL_LIKE_PROPERTY_NAMES.has(compactPropertyName(key));
1743
- var looksLikeBareQueryString = (text) => {
1744
- if (!text.includes("=") || /\s/.test(text)) return false;
1745
- if (/^[a-z][a-z0-9+.-]*:/i.test(text) || text.startsWith("/")) return false;
1746
- return /^[^\s=]+=[^\s]*(&[^\s=]+=[^\s]*)*$/.test(text);
1747
- };
1748
- var redactSensitiveQuery = (text, redactKeys) => {
1749
- const queryAt = text.indexOf("?");
1750
- let prefix = "";
1751
- let query = "";
1752
- let suffix = "";
1753
- if (queryAt >= 0) {
1754
- if (queryAt === text.length - 1) return text;
1755
- const hashAt = text.indexOf("#", queryAt + 1);
1756
- prefix = text.slice(0, queryAt + 1);
1757
- query = hashAt < 0 ? text.slice(queryAt + 1) : text.slice(queryAt + 1, hashAt);
1758
- suffix = hashAt < 0 ? "" : text.slice(hashAt);
1759
- } else if (looksLikeBareQueryString(text)) {
1760
- query = text;
1761
- } else {
1762
- return text;
1763
- }
1764
- if (!query.includes("=")) return text;
1765
- let changed = false;
1766
- const next = query.split("&").map((part) => {
1767
- const equals = part.indexOf("=");
1768
- const rawKey = equals < 0 ? part : part.slice(0, equals);
1769
- if (!rawKey) return part;
1770
- let decoded = rawKey;
1771
- try {
1772
- decoded = decodeURIComponent(rawKey.replace(/\+/g, " "));
1773
- } catch {
1774
- decoded = rawKey;
1775
- }
1776
- if (!keyIsRedacted(decoded, redactKeys) && !keyIsRedacted(rawKey, redactKeys)) return part;
1777
- changed = true;
1778
- return `${rawKey}=${RASPUTIN_REDACTED}`;
1779
- });
1780
- if (!changed) return text;
1781
- return `${prefix}${next.join("&")}${suffix}`;
1782
- };
1783
- var redactUrlUserinfo = (text) => {
1784
- const schemeEnd = text.indexOf("://");
1785
- if (schemeEnd <= 0) return text;
1786
- const rest = text.slice(schemeEnd + 3);
1787
- let authorityEnd = rest.length;
1788
- for (const marker of ["/", "?", "#"]) {
1789
- const at = rest.indexOf(marker);
1790
- if (at >= 0 && at < authorityEnd) authorityEnd = at;
1791
- }
1792
- const authority = rest.slice(0, authorityEnd);
1793
- const userinfoEnd = authority.lastIndexOf("@");
1794
- if (userinfoEnd < 0) return text;
1795
- return `${text.slice(0, schemeEnd + 3)}${RASPUTIN_REDACTED}@${authority.slice(userinfoEnd + 1)}${rest.slice(authorityEnd)}`;
1796
- };
1797
- var redactUrlLikeString = (text, redactKeys) => redactSensitiveQuery(redactUrlUserinfo(text), redactKeys);
1798
1644
  var isFrozenAtom = (value) => typeof value === "object" && value !== null && FROZEN in value;
1645
+ var isFrozenRecord = (value) => isFrozenAtom(value) && value[FROZEN] === "record";
1799
1646
  var isRetainedOverflowChild = (value) => {
1800
1647
  if (isFrozenAtom(value)) {
1801
1648
  if (value[FROZEN] === "truncated") return true;
@@ -1813,16 +1660,13 @@ var keepOverflowChild = (child, overflowedOnChild) => {
1813
1660
  var BYTE_LIMIT = "max_serialized_value_bytes";
1814
1661
  var createValueFreezer = (options = {}) => {
1815
1662
  const limits = compileFreezeLimits(options);
1816
- const redactKeys = compileRedactKeys(options.redactKeys);
1817
- const redactSecretValues = options.redactSecretValues;
1818
1663
  const sharedPath = /* @__PURE__ */ new Set();
1819
1664
  let freezing = false;
1820
1665
  const add = (metrics, count) => {
1821
1666
  metrics.estimatedBytes += count;
1822
1667
  if (metrics.estimatedBytes > limits.maxSerializedValueBytes) metrics.oversize = true;
1823
1668
  };
1824
- const freezeInner = (value, depth, path, metrics) => {
1825
- if (metrics.oversize) return void 0;
1669
+ const freezeLeaf = (value, metrics) => {
1826
1670
  metrics.visitedNodes++;
1827
1671
  if (value === null) {
1828
1672
  add(metrics, 4);
@@ -1842,16 +1686,11 @@ var createValueFreezer = (options = {}) => {
1842
1686
  return value;
1843
1687
  }
1844
1688
  if (typeof value === "string") {
1845
- let text = value;
1846
- if (redactSecretValues) {
1847
- const cap = limits.maxStringLength + MAX_ENV_SECRET_NEEDLE_LENGTH;
1848
- text = redactSecretValues(value.length > cap ? value.slice(0, cap) : value);
1849
- }
1850
- if (text.length <= limits.maxStringLength) {
1851
- add(metrics, stringEstimate(text));
1852
- return text;
1689
+ if (value.length <= limits.maxStringLength) {
1690
+ add(metrics, stringEstimate(value));
1691
+ return value;
1853
1692
  }
1854
- const sliced = text.slice(0, limits.maxStringLength);
1693
+ const sliced = copyBoundedString(value.slice(0, limits.maxStringLength));
1855
1694
  add(metrics, NODE + stringEstimate(sliced) + 48);
1856
1695
  return atom("truncated", {
1857
1696
  reason: "max_string_length",
@@ -1882,10 +1721,13 @@ var createValueFreezer = (options = {}) => {
1882
1721
  add(metrics, NODE + stringEstimate(name));
1883
1722
  return atom("function", { value: name });
1884
1723
  }
1885
- if (typeof value !== "object") {
1886
- add(metrics, NODE + 16);
1887
- return atom("unserializable");
1888
- }
1724
+ add(metrics, NODE + 16);
1725
+ return atom("unserializable");
1726
+ };
1727
+ const freezeInner = (value, depth, path, metrics) => {
1728
+ if (metrics.oversize) return void 0;
1729
+ if (value === null || typeof value !== "object") return freezeLeaf(value, metrics);
1730
+ metrics.visitedNodes++;
1889
1731
  if (path.has(value)) {
1890
1732
  add(metrics, NODE + 16);
1891
1733
  return atom("circular");
@@ -1914,9 +1756,9 @@ var createValueFreezer = (options = {}) => {
1914
1756
  const stack = errorStackOf(value);
1915
1757
  const extras = {};
1916
1758
  for (const key of ["code", "cause", "statusCode"]) {
1917
- const slot = ownData(value, key);
1918
- if (!slot) continue;
1919
- extras[key] = freezeInner(slot.value, depth + 1, path, metrics);
1759
+ const extra = ownValue(value, key);
1760
+ if (extra === NO_DATA) continue;
1761
+ extras[key] = freezeInner(extra, depth + 1, path, metrics);
1920
1762
  }
1921
1763
  return atom("Error", {
1922
1764
  name,
@@ -1950,20 +1792,14 @@ var createValueFreezer = (options = {}) => {
1950
1792
  if (counted2 >= limits.maxArrayElements || metrics.oversize) break;
1951
1793
  const key = freezeInner(mapKey, depth + 1, path, metrics);
1952
1794
  if (!keepOverflowChild(key, metrics.oversize)) break;
1953
- if (typeof mapKey === "string" && keyIsRedacted(mapKey, redactKeys)) {
1954
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
1955
- if (metrics.oversize) break;
1956
- entries.push([key, RASPUTIN_REDACTED]);
1957
- } else {
1958
- const mapValue = freezeInner(
1959
- Map.prototype.get.call(value, mapKey),
1960
- depth + 1,
1961
- path,
1962
- metrics
1963
- );
1964
- if (!keepOverflowChild(mapValue, metrics.oversize)) break;
1965
- entries.push([key, mapValue]);
1966
- }
1795
+ const mapValue = freezeInner(
1796
+ Map.prototype.get.call(value, mapKey),
1797
+ depth + 1,
1798
+ path,
1799
+ metrics
1800
+ );
1801
+ if (!keepOverflowChild(mapValue, metrics.oversize)) break;
1802
+ entries.push([key, mapValue]);
1967
1803
  counted2++;
1968
1804
  }
1969
1805
  const hitBytes2 = metrics.oversize && counted2 < Math.min(size, limits.maxArrayElements);
@@ -2005,7 +1841,6 @@ var createValueFreezer = (options = {}) => {
2005
1841
  add(metrics, 2);
2006
1842
  const items = [];
2007
1843
  const maxItems = value.length > limits.maxArrayElements ? limits.maxArrayElements - 1 : value.length;
2008
- let redactNext = false;
2009
1844
  for (let index = 0; index < maxItems; index++) {
2010
1845
  if (metrics.oversize) break;
2011
1846
  let descriptor;
@@ -2018,27 +1853,17 @@ var createValueFreezer = (options = {}) => {
2018
1853
  add(metrics, NODE + 16);
2019
1854
  if (metrics.oversize) break;
2020
1855
  items.push(atom("hole"));
2021
- redactNext = false;
2022
1856
  continue;
2023
1857
  }
2024
1858
  if (!("value" in descriptor)) {
2025
1859
  add(metrics, NODE + 16);
2026
1860
  if (metrics.oversize) break;
2027
1861
  items.push(atom("accessor"));
2028
- redactNext = false;
2029
1862
  continue;
2030
1863
  }
2031
- if (redactNext) {
2032
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
2033
- if (metrics.oversize) break;
2034
- items.push(RASPUTIN_REDACTED);
2035
- redactNext = false;
2036
- } else {
2037
- const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
2038
- if (!keepOverflowChild(frozen, metrics.oversize)) break;
2039
- items.push(frozen);
2040
- redactNext = typeof descriptor.value === "string" && keyIsRedacted(descriptor.value, redactKeys);
2041
- }
1864
+ const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
1865
+ if (!keepOverflowChild(frozen, metrics.oversize)) break;
1866
+ items.push(frozen);
2042
1867
  }
2043
1868
  if (metrics.oversize && items.length < maxItems) {
2044
1869
  add(metrics, NODE + 32);
@@ -2129,7 +1954,8 @@ var createValueFreezer = (options = {}) => {
2129
1954
  }
2130
1955
  }
2131
1956
  add(metrics, 2);
2132
- const fields = /* @__PURE__ */ Object.create(null);
1957
+ const recordKeys = [];
1958
+ const recordValues = [];
2133
1959
  let typeName;
2134
1960
  let prototype = null;
2135
1961
  try {
@@ -2139,12 +1965,12 @@ var createValueFreezer = (options = {}) => {
2139
1965
  }
2140
1966
  if (prototype && types.isProxy(prototype)) {
2141
1967
  add(metrics, NODE + 16);
2142
- return atom("instance", { type: "Proxy", value: fields });
1968
+ return atom("instance", { type: "Proxy", value: frozenRecord(recordKeys, recordValues) });
2143
1969
  }
2144
1970
  if (prototype && prototype !== Object.prototype) {
2145
1971
  typeName = "instance";
2146
1972
  if (!types.isProxy(prototype)) {
2147
- const ctor = ownData(prototype, "constructor")?.value;
1973
+ const ctor = ownValue(prototype, "constructor");
2148
1974
  if (typeof ctor === "function") {
2149
1975
  const name = functionNameOf(ctor);
2150
1976
  if (name && name !== "anonymous") typeName = name;
@@ -2152,8 +1978,6 @@ var createValueFreezer = (options = {}) => {
2152
1978
  }
2153
1979
  add(metrics, NODE + stringEstimate(typeName));
2154
1980
  }
2155
- const pairLabel = ownData(value, "name") ?? ownData(value, "key");
2156
- const pairIsSensitive = pairLabel !== void 0 && typeof pairLabel.value === "string" && keyIsRedacted(pairLabel.value, redactKeys);
2157
1981
  const { keys, truncated } = ownEnumerableKeys(value, limits.maxObjectKeys);
2158
1982
  const maxKeys = truncated ? Math.max(0, limits.maxObjectKeys - 1) : keys.length;
2159
1983
  let kept = 0;
@@ -2161,40 +1985,35 @@ var createValueFreezer = (options = {}) => {
2161
1985
  if (metrics.oversize) break;
2162
1986
  const key = keys[index];
2163
1987
  if (key === void 0) continue;
2164
- add(metrics, stringEstimate(key));
1988
+ add(metrics, NODE + 2 + keyMeta(key).utf8Bytes);
2165
1989
  if (metrics.oversize) break;
2166
- if (keyIsRedacted(key, redactKeys) || key === "value" && pairIsSensitive) {
2167
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
2168
- if (metrics.oversize) break;
2169
- assignFrozenField(fields, key, RASPUTIN_REDACTED);
2170
- kept++;
2171
- continue;
2172
- }
2173
- const slot = ownData(value, key);
2174
- if (slot) {
2175
- const field = typeof slot.value === "string" && propertyNameLooksLikeUrl(key) ? redactUrlLikeString(slot.value, redactKeys) : slot.value;
2176
- const frozen = freezeInner(field, depth + 1, path, metrics);
1990
+ const slot = ownValue(value, key);
1991
+ if (slot !== NO_DATA) {
1992
+ const frozen = freezeInner(slot, depth + 1, path, metrics);
2177
1993
  if (!keepOverflowChild(frozen, metrics.oversize)) break;
2178
- assignFrozenField(fields, key, frozen);
1994
+ recordKeys.push(key);
1995
+ recordValues.push(frozen);
2179
1996
  kept++;
2180
1997
  } else {
2181
1998
  add(metrics, NODE + 16);
2182
1999
  if (metrics.oversize) break;
2183
- assignFrozenField(fields, key, atom("accessor"));
2000
+ recordKeys.push(key);
2001
+ recordValues.push(atom("accessor"));
2184
2002
  kept++;
2185
2003
  }
2186
2004
  }
2005
+ const record = frozenRecord(recordKeys, recordValues);
2187
2006
  const hitBytes = metrics.oversize && kept < maxKeys;
2188
2007
  if (hitBytes || truncated) {
2189
2008
  return atom("instance", {
2190
2009
  type: typeName,
2191
- value: fields,
2010
+ value: record,
2192
2011
  truncated: true,
2193
2012
  reason: hitBytes ? BYTE_LIMIT : "max_object_keys"
2194
2013
  });
2195
2014
  }
2196
- if (typeName) return atom("instance", { type: typeName, value: fields });
2197
- return fields;
2015
+ if (typeName) return atom("instance", { type: typeName, value: record });
2016
+ return record;
2198
2017
  } catch (error) {
2199
2018
  add(metrics, NODE + 32);
2200
2019
  return atom("unserializable", {
@@ -2205,30 +2024,43 @@ var createValueFreezer = (options = {}) => {
2205
2024
  }
2206
2025
  };
2207
2026
  const freeze = (value) => {
2208
- const metrics = { visitedNodes: 0, estimatedBytes: 0, oversize: false };
2027
+ const snapshot = {
2028
+ value: void 0,
2029
+ estimatedBytes: 0,
2030
+ visitedNodes: 0,
2031
+ oversize: false
2032
+ };
2033
+ if (value === null || typeof value !== "object") {
2034
+ try {
2035
+ snapshot.value = freezeLeaf(value, snapshot);
2036
+ return snapshot;
2037
+ } catch {
2038
+ return {
2039
+ value: atom("unserializable"),
2040
+ estimatedBytes: NODE + 16,
2041
+ visitedNodes: Math.max(1, snapshot.visitedNodes),
2042
+ oversize: false
2043
+ };
2044
+ }
2045
+ }
2209
2046
  const reentrant = freezing;
2210
2047
  const path = reentrant ? /* @__PURE__ */ new Set() : sharedPath;
2211
2048
  if (!reentrant) {
2212
2049
  freezing = true;
2213
- sharedPath.clear();
2050
+ if (sharedPath.size !== 0) sharedPath.clear();
2214
2051
  }
2215
2052
  try {
2216
- const frozen = freezeInner(value, 0, path, metrics);
2217
- return {
2218
- value: frozen,
2219
- estimatedBytes: metrics.estimatedBytes,
2220
- visitedNodes: metrics.visitedNodes,
2221
- oversize: metrics.oversize
2222
- };
2053
+ snapshot.value = freezeInner(value, 0, path, snapshot);
2054
+ return snapshot;
2223
2055
  } catch {
2224
2056
  return {
2225
2057
  value: atom("unserializable"),
2226
2058
  estimatedBytes: NODE + 16,
2227
- visitedNodes: Math.max(1, metrics.visitedNodes),
2059
+ visitedNodes: Math.max(1, snapshot.visitedNodes),
2228
2060
  oversize: false
2229
2061
  };
2230
2062
  } finally {
2231
- path.clear();
2063
+ if (path.size !== 0) path.clear();
2232
2064
  if (!reentrant) freezing = false;
2233
2065
  }
2234
2066
  };
@@ -2294,7 +2126,7 @@ var jsonStringUtf8Bytes = (value) => {
2294
2126
  }
2295
2127
  return bytes;
2296
2128
  };
2297
- var ownData2 = (value, key) => {
2129
+ var ownData = (value, key) => {
2298
2130
  try {
2299
2131
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
2300
2132
  if (descriptor && "value" in descriptor) return descriptor.value;
@@ -2316,11 +2148,12 @@ var jsonLiteralUtf8Bytes = (value) => {
2316
2148
  case "string":
2317
2149
  return jsonStringUtf8Bytes(value);
2318
2150
  case "object": {
2151
+ if (isFrozenAtom(value)) return jsonLiteralUtf8Bytes(encodeFrozen(value));
2319
2152
  if (Array.isArray(value)) {
2320
2153
  let bytes2 = 2;
2321
2154
  for (let index = 0; index < value.length; index++) {
2322
2155
  if (index > 0) bytes2 += 1;
2323
- bytes2 += jsonLiteralUtf8Bytes(ownData2(value, index));
2156
+ bytes2 += jsonLiteralUtf8Bytes(ownData(value, index));
2324
2157
  }
2325
2158
  return bytes2;
2326
2159
  }
@@ -2331,7 +2164,7 @@ var jsonLiteralUtf8Bytes = (value) => {
2331
2164
  if (!first) bytes += 1;
2332
2165
  first = false;
2333
2166
  bytes += jsonStringUtf8Bytes(key) + 1;
2334
- bytes += jsonLiteralUtf8Bytes(ownData2(record, key));
2167
+ bytes += jsonLiteralUtf8Bytes(ownData(record, key));
2335
2168
  }
2336
2169
  return bytes;
2337
2170
  }
@@ -2397,6 +2230,28 @@ var encodePlainObject = (value) => {
2397
2230
  }
2398
2231
  return encoded;
2399
2232
  };
2233
+ var encodeRecord = (record) => {
2234
+ const encoded = /* @__PURE__ */ Object.create(null);
2235
+ const escaped = [];
2236
+ let fieldsAssigned = false;
2237
+ const keys = record.keys;
2238
+ const values = record.values;
2239
+ for (let index = 0; index < keys.length; index++) {
2240
+ const key = keys[index];
2241
+ if (key === void 0) continue;
2242
+ const encodedValue = encodeFrozen(values[index]);
2243
+ if (key === "__proto__" || RESERVED_WIRE_KEYS.has(key) || key.startsWith("__rasputin_")) {
2244
+ if (!fieldsAssigned) {
2245
+ encoded.__rasputin_fields = escaped;
2246
+ fieldsAssigned = true;
2247
+ }
2248
+ escaped.push({ name: key, value: encodedValue });
2249
+ continue;
2250
+ }
2251
+ encoded[key] = encodedValue;
2252
+ }
2253
+ return encoded;
2254
+ };
2400
2255
  var encodeAtom = (frozen) => {
2401
2256
  const kind = frozen[FROZEN];
2402
2257
  switch (kind) {
@@ -2466,8 +2321,10 @@ var encodeAtom = (frozen) => {
2466
2321
  ...frozen.serializedBytes === void 0 ? {} : { __serialized_bytes: frozen.serializedBytes },
2467
2322
  ...frozen.value === void 0 ? {} : { value: encodeFrozen(frozen.value) }
2468
2323
  });
2324
+ case "record":
2325
+ return encodeRecord(frozen);
2469
2326
  case "instance": {
2470
- const fields = typeof frozen.value === "object" && frozen.value !== null && !Array.isArray(frozen.value) ? encodePlainObject(frozen.value) : encodeFrozen(frozen.value);
2327
+ const fields = encodeFrozen(frozen.value);
2471
2328
  const encoded = /* @__PURE__ */ Object.create(null);
2472
2329
  if (typeof fields === "object" && fields !== null && !Array.isArray(fields)) {
2473
2330
  for (const key of Object.keys(fields)) {
@@ -2494,7 +2351,8 @@ var encodeAtom = (frozen) => {
2494
2351
  }
2495
2352
  };
2496
2353
  var encodeFrozen = (value) => {
2497
- if (value === RASPUTIN_REDACTED2) return RASPUTIN_REDACTED2;
2354
+ if (value === RASPUTIN_REDACTED) return RASPUTIN_REDACTED;
2355
+ if (isFrozenRecord(value)) return encodeRecord(value);
2498
2356
  if (isFrozenAtom(value)) return encodeAtom(value);
2499
2357
  if (Array.isArray(value)) {
2500
2358
  const items = new Array(value.length);
@@ -2644,6 +2502,7 @@ var warnIfMissingAsyncContextFrame = () => {
2644
2502
  var DEFAULT_MAX_ACTIVE_MEMORY_BYTES = 64 * 1024 * 1024;
2645
2503
  var DEFAULT_MAX_EXECUTION_HOLD_MS = 6e4;
2646
2504
  var DEFAULT_MAX_RETAINED_ERROR_RECORDINGS = 32;
2505
+ var EMPTY_ARGS = [];
2647
2506
  var phaseTimingEnabled = process.env.RASPUTIN_RECORDER_PHASE_TIMING === "1";
2648
2507
  var manualFunctionDefinition = (value) => {
2649
2508
  const located = /^(.+):([^:@]+)@(\d+):(\d+)$/.exec(value);
@@ -2662,7 +2521,7 @@ var normalizeFunctionDefinition = (value) => typeof value === "string" ? manualF
2662
2521
  var elapsedMs2 = (startedAtNs, endedAtNs = process.hrtime.bigint()) => Number(endedAtNs - startedAtNs) / 1e6;
2663
2522
  var roundedMilliseconds2 = (nanoseconds) => Math.round(Number(nanoseconds) / 1e6 * 1e4) / 1e4;
2664
2523
  var addRecorderTime = (recording, nanoseconds) => {
2665
- if (process.env.RASPUTIN_RECORDER_PHASE_TIMING !== "1" || nanoseconds <= 0n) return;
2524
+ if (!phaseTimingEnabled || nanoseconds <= 0n) return;
2666
2525
  recording.inlineRecorderTimeNs += nanoseconds;
2667
2526
  };
2668
2527
  var mapArrayLike = (args, map) => {
@@ -2678,7 +2537,7 @@ var notifyObserver = (observer, value) => {
2678
2537
  } catch {
2679
2538
  }
2680
2539
  };
2681
- var observeRecordedCallback = function __rasputinHandleRun__2(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
2540
+ var observeRecordedCallback = function __rasputinHandleRun__3(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
2682
2541
  const callbackStartedAtNs = phaseTimingEnabled ? process.hrtime.bigint() : recorderStartedAtNs;
2683
2542
  const recordExitWork = (callbackEndedAtNs) => {
2684
2543
  if (!phaseTimingEnabled) return;
@@ -2831,11 +2690,7 @@ var createExecutionRecorder = (options) => {
2831
2690
  maxActiveMemoryBytes,
2832
2691
  options.maxSerializedValueBytes ?? 16 * 1024
2833
2692
  );
2834
- const envSecretMatcher = createEnvSecretMatcher();
2835
- const serializer = createSafeSerializer({
2836
- ...options,
2837
- ...envSecretMatcher.needleCount > 0 ? { redactSecretValues: envSecretMatcher.redact } : {}
2838
- });
2693
+ const serializer = createSafeSerializer(options);
2839
2694
  const excludesSource = createSourceExclusionMatcher(options.excludeSources);
2840
2695
  const journalPool = new ExecutionJournalPool(maxEventsPerExecution);
2841
2696
  const plansByRuntimeId = [];
@@ -2884,15 +2739,11 @@ var createExecutionRecorder = (options) => {
2884
2739
  stats.serializedValues++;
2885
2740
  stats.serializedValueNodes += frozen.visitedNodes;
2886
2741
  stats.serializedValueBytes += frozen.estimatedBytes;
2887
- return {
2888
- value: frozen.value,
2889
- bytes: frozen.estimatedBytes,
2890
- visitedNodes: frozen.visitedNodes
2891
- };
2742
+ return frozen;
2892
2743
  };
2893
2744
  const captureValue = (recording, value) => {
2894
2745
  try {
2895
- return memoryBudget.captureValue(recording.memory, () => freezeAndCount(value));
2746
+ return memoryBudget.captureValue(recording.memory, value, freezeAndCount);
2896
2747
  } catch {
2897
2748
  return { __rasputin_type: "unserializable" };
2898
2749
  }
@@ -3055,7 +2906,7 @@ var createExecutionRecorder = (options) => {
3055
2906
  version: 4,
3056
2907
  captureProfile: resolveCaptureProfile(recording, events, truncated, capture),
3057
2908
  executionId: recording.executionId,
3058
- startedAt: recording.startedAt,
2909
+ startedAt: new Date(recording.startedAtMs).toISOString(),
3059
2910
  durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
3060
2911
  recorder: { inlineWallTimeMs: 0 },
3061
2912
  execution: {
@@ -3089,7 +2940,7 @@ var createExecutionRecorder = (options) => {
3089
2940
  if (recording.evidenceDiscarded) return;
3090
2941
  recording.evidenceDiscarded = true;
3091
2942
  recording.cachedState = void 0;
3092
- recording.repeatedCalls = [];
2943
+ recording.repeatedCalls = void 0;
3093
2944
  recording.lateCapturedCallIds = void 0;
3094
2945
  recording.capturedErrors = /* @__PURE__ */ new WeakMap();
3095
2946
  if (recording.journal) {
@@ -3275,11 +3126,15 @@ var createExecutionRecorder = (options) => {
3275
3126
  countDroppedEvents(recording, droppedBefore);
3276
3127
  };
3277
3128
  const repeatedCallGroup = (recording, plan, parentCallId) => {
3278
- const slots = recording.repeatedCalls;
3279
- let slot = slots[plan.runtimePlanId];
3129
+ let slots = recording.repeatedCalls;
3130
+ if (!slots) {
3131
+ slots = /* @__PURE__ */ new Map();
3132
+ recording.repeatedCalls = slots;
3133
+ }
3134
+ let slot = slots.get(plan.runtimePlanId);
3280
3135
  if (!slot) {
3281
3136
  slot = {};
3282
- slots[plan.runtimePlanId] = slot;
3137
+ slots.set(plan.runtimePlanId, slot);
3283
3138
  }
3284
3139
  if (parentCallId === void 0) {
3285
3140
  if (!slot.root) slot.root = newRepeatedGroup(plan);
@@ -3429,10 +3284,10 @@ var createExecutionRecorder = (options) => {
3429
3284
  } catch {
3430
3285
  }
3431
3286
  };
3432
- const runStore = function __rasputinHandleRun__3(store, callback) {
3287
+ const runStore = function __rasputinHandleRun__4(store, callback) {
3433
3288
  if (!phaseTimingEnabled) return storage.run(store, callback);
3434
3289
  const alsStartedAtNs = process.hrtime.bigint();
3435
- return storage.run(store, function __rasputinHandleRun__4() {
3290
+ return storage.run(store, function __rasputinHandleRun__5() {
3436
3291
  addPhase("alsNs", process.hrtime.bigint() - alsStartedAtNs);
3437
3292
  return callback();
3438
3293
  });
@@ -3444,7 +3299,7 @@ var createExecutionRecorder = (options) => {
3444
3299
  const recording = {
3445
3300
  executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
3446
3301
  storageGeneration: ++storageClock,
3447
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3302
+ startedAtMs: Date.now(),
3448
3303
  startedAtNs: recorderStartedAtNs,
3449
3304
  inlineRecorderTimeNs: 0n,
3450
3305
  execution: {
@@ -3452,7 +3307,6 @@ var createExecutionRecorder = (options) => {
3452
3307
  ...metadata.request ? { request: { ...metadata.request } } : {}
3453
3308
  },
3454
3309
  journal: void 0,
3455
- repeatedCalls: [],
3456
3310
  capturedErrors: /* @__PURE__ */ new WeakMap(),
3457
3311
  nextCallId: 0,
3458
3312
  inFlightCalls: 0,
@@ -3470,11 +3324,11 @@ var createExecutionRecorder = (options) => {
3470
3324
  addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
3471
3325
  const store = { recording };
3472
3326
  return {
3473
- run: function __rasputinHandleRun__3(callback) {
3327
+ run: function __rasputinHandleRun__4(callback) {
3474
3328
  let startedCallback = false;
3475
3329
  try {
3476
3330
  const runStartedAtNs = process.hrtime.bigint();
3477
- return runStore(store, function __rasputinHandleRun__4() {
3331
+ return runStore(store, function __rasputinHandleRun__5() {
3478
3332
  startedCallback = true;
3479
3333
  addRecorderTime(recording, process.hrtime.bigint() - runStartedAtNs);
3480
3334
  try {
@@ -3522,14 +3376,14 @@ var createExecutionRecorder = (options) => {
3522
3376
  return void 0;
3523
3377
  }
3524
3378
  };
3525
- const runPreparedFunctionFromStore = function __rasputinHandleRun__3(store, plan, args, callback, omitValues) {
3379
+ const runPreparedFunctionFromStore = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
3526
3380
  let startedCallback = false;
3527
3381
  try {
3528
3382
  return runPreparedFunctionFromStoreInner(
3529
3383
  store,
3530
3384
  plan,
3531
3385
  args,
3532
- function __rasputinHandleRun__4() {
3386
+ function __rasputinHandleRun__5() {
3533
3387
  startedCallback = true;
3534
3388
  return callback();
3535
3389
  },
@@ -3540,7 +3394,7 @@ var createExecutionRecorder = (options) => {
3540
3394
  return callback();
3541
3395
  }
3542
3396
  };
3543
- const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__3(store, plan, args, callback, omitValues) {
3397
+ const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
3544
3398
  const omitCallValues = omitValues === true || plan.omitCallValues;
3545
3399
  if (!store) return callback();
3546
3400
  if (plan.disabled) {
@@ -3561,7 +3415,7 @@ var createExecutionRecorder = (options) => {
3561
3415
  const recorderStartedAtNs = process.hrtime.bigint();
3562
3416
  if (store.suppressCapture || plan.excluded) {
3563
3417
  stats.functionCallsExcluded++;
3564
- return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__4() {
3418
+ return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__5() {
3565
3419
  addRecorderTime(store.recording, process.hrtime.bigint() - recorderStartedAtNs);
3566
3420
  return callback();
3567
3421
  });
@@ -3579,7 +3433,7 @@ var createExecutionRecorder = (options) => {
3579
3433
  if (group.observedCalls > maxCapturedCallsPerFunction) {
3580
3434
  const startedAtNs2 = process.hrtime.bigint();
3581
3435
  try {
3582
- const result = runStore(store, function __rasputinHandleRun__4() {
3436
+ const result = runStore(store, function __rasputinHandleRun__5() {
3583
3437
  return callback();
3584
3438
  });
3585
3439
  recordSuppressedCall(recording, group, parentCallId, startedAtNs2, process.hrtime.bigint());
@@ -3594,7 +3448,7 @@ var createExecutionRecorder = (options) => {
3594
3448
  const startedAtNs = process.hrtime.bigint();
3595
3449
  if (!journal) {
3596
3450
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3597
- return runStore(store, function __rasputinHandleRun__4() {
3451
+ return runStore(store, function __rasputinHandleRun__5() {
3598
3452
  return observeRecordedCallback(
3599
3453
  recording,
3600
3454
  recorderStartedAtNs,
@@ -3613,7 +3467,7 @@ var createExecutionRecorder = (options) => {
3613
3467
  countDroppedEvents(recording, droppedBefore);
3614
3468
  settleInFlight(recording);
3615
3469
  };
3616
- return runStore(store, function __rasputinHandleRun__4() {
3470
+ return runStore(store, function __rasputinHandleRun__5() {
3617
3471
  return observeRecordedCallback(
3618
3472
  recording,
3619
3473
  recorderStartedAtNs,
@@ -3644,7 +3498,7 @@ var createExecutionRecorder = (options) => {
3644
3498
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3645
3499
  } catch {
3646
3500
  journal.dropCall();
3647
- return runStore(store, function __rasputinHandleRun__4() {
3501
+ return runStore(store, function __rasputinHandleRun__5() {
3648
3502
  return observeRecordedCallback(
3649
3503
  recording,
3650
3504
  recorderStartedAtNs,
@@ -3657,17 +3511,22 @@ var createExecutionRecorder = (options) => {
3657
3511
  });
3658
3512
  }
3659
3513
  const callStore = { recording, currentCallId: callId };
3660
- return runStore(callStore, function __rasputinHandleRun__4() {
3514
+ return runStore(callStore, function __rasputinHandleRun__5() {
3661
3515
  return observeRecordedCallback(
3662
3516
  recording,
3663
3517
  recorderStartedAtNs,
3664
3518
  callback,
3665
3519
  (value) => {
3666
3520
  if (recording.journal) {
3667
- const timestampNs = process.hrtime.bigint() - recording.startedAtNs;
3668
- const durationNs = process.hrtime.bigint() - startedAtNs;
3521
+ const endedAtNs = process.hrtime.bigint();
3669
3522
  const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
3670
- recording.journal.finishCall(KIND_EXIT, callId, timestampNs, durationNs, returnValue);
3523
+ recording.journal.finishCall(
3524
+ KIND_EXIT,
3525
+ callId,
3526
+ endedAtNs - recording.startedAtNs,
3527
+ endedAtNs - startedAtNs,
3528
+ returnValue
3529
+ );
3671
3530
  stats.functionCallsCaptured++;
3672
3531
  }
3673
3532
  settleInFlight(recording);
@@ -3678,11 +3537,12 @@ var createExecutionRecorder = (options) => {
3678
3537
  return;
3679
3538
  }
3680
3539
  const capturedError = serializedError(recording, error, callId);
3540
+ const endedAtNs = process.hrtime.bigint();
3681
3541
  recording.journal.finishCall(
3682
3542
  KIND_THROW,
3683
3543
  callId,
3684
- process.hrtime.bigint() - recording.startedAtNs,
3685
- process.hrtime.bigint() - startedAtNs,
3544
+ endedAtNs - recording.startedAtNs,
3545
+ endedAtNs - startedAtNs,
3686
3546
  capturedError.value
3687
3547
  );
3688
3548
  stats.functionCallsCaptured++;
@@ -3692,62 +3552,189 @@ var createExecutionRecorder = (options) => {
3692
3552
  );
3693
3553
  });
3694
3554
  };
3695
- const noopHandle2 = {
3696
- leave: (value) => value,
3697
- fail: () => {
3698
- },
3699
- end: () => {
3700
- },
3701
- run: function __rasputinHandleRun__3(callback) {
3702
- return runExactlyOnce((invoke) => invoke(), callback);
3703
- },
3704
- suspend: (value) => value,
3705
- resume: (value) => value
3706
- };
3707
- const bindStoreTransitions = (active, parent, recording, plan) => {
3708
- let suspended = false;
3709
- const enter = (next) => {
3555
+ const noopHandle2 = passthroughHandle();
3556
+ class CallFrame {
3557
+ constructor(mode, recording, parentStore, activeStore, plan, args, omitCallValues, parentCallId, startedAtNs, callId, group, captureDroppedThrow) {
3558
+ this.mode = mode;
3559
+ this.status = "open";
3560
+ this.pendingReturn = void 0;
3561
+ this.ended = false;
3562
+ this.suspended = false;
3563
+ this.startedAtNs = startedAtNs;
3564
+ this.callId = callId;
3565
+ this.recording = recording;
3566
+ this.plan = plan;
3567
+ this.args = args;
3568
+ this.omitCallValues = omitCallValues;
3569
+ this.parentCallId = parentCallId;
3570
+ this.parentStore = parentStore;
3571
+ this.activeStore = activeStore;
3572
+ this.group = group;
3573
+ this.captureDroppedThrow = captureDroppedThrow;
3574
+ }
3575
+ leave(value) {
3710
3576
  try {
3711
- storage.enterWith(next);
3577
+ if (this.status !== "failed") {
3578
+ this.status = "left";
3579
+ this.pendingReturn = value;
3580
+ }
3581
+ return value;
3712
3582
  } catch {
3713
- degradeAttribution(recording, plan);
3583
+ return value;
3714
3584
  }
3715
- };
3716
- const expectStore = (expected) => {
3717
- if (currentStore() !== expected) degradeAttribution(recording, plan);
3718
- };
3719
- return {
3720
- enterActive: () => enter(active),
3721
- run: function __rasputinHandleRun__3(callback) {
3722
- return runExactlyOnce((invoke) => {
3723
- try {
3724
- enter(parent);
3725
- } catch {
3585
+ }
3586
+ fail(error, liveArgs) {
3587
+ try {
3588
+ if (this.status === "failed") return;
3589
+ this.status = "failed";
3590
+ if (this.mode === "captured") writeCapturedThrow(this, error);
3591
+ else if (this.mode === "suppressed" && this.plan) {
3592
+ captureCompletedThrow(
3593
+ this.recording,
3594
+ this.plan,
3595
+ liveArgs ?? this.args,
3596
+ this.parentCallId,
3597
+ this.startedAtNs,
3598
+ error
3599
+ );
3600
+ } else if (this.mode === "dropped" && this.captureDroppedThrow && this.plan) {
3601
+ captureCompletedThrow(
3602
+ this.recording,
3603
+ this.plan,
3604
+ this.args,
3605
+ this.parentCallId,
3606
+ this.startedAtNs,
3607
+ error
3608
+ );
3609
+ }
3610
+ } catch {
3611
+ }
3612
+ }
3613
+ end() {
3614
+ if (this.mode === "expired") return;
3615
+ try {
3616
+ if (this.status !== "failed") {
3617
+ if (this.mode === "captured") {
3618
+ writeCapturedExit(this, this.status === "left" ? this.pendingReturn : void 0);
3619
+ } else if (this.mode === "suppressed" && this.group) {
3620
+ recordSuppressedCall(
3621
+ this.recording,
3622
+ this.group,
3623
+ this.parentCallId,
3624
+ this.startedAtNs,
3625
+ process.hrtime.bigint()
3626
+ );
3627
+ } else if (this.mode === "dropped") {
3628
+ const droppedBefore = this.recording.journal?.dropped ?? 0;
3629
+ this.recording.journal?.dropCall();
3630
+ countDroppedEvents(this.recording, droppedBefore);
3726
3631
  }
3727
- return storage.run(active, invoke);
3728
- }, callback);
3729
- },
3730
- suspend: (value) => {
3731
- expectStore(active);
3732
- suspended = true;
3733
- enter(parent);
3632
+ }
3633
+ } catch {
3634
+ }
3635
+ try {
3636
+ if (this.ended) return;
3637
+ this.ended = true;
3638
+ if (this.mode !== "excluded") settleInFlight(this.recording);
3639
+ expectStore(this, this.activeStore);
3640
+ enterStore(this, this.parentStore);
3641
+ } catch {
3642
+ }
3643
+ }
3644
+ run(callback) {
3645
+ if (this.mode === "expired") {
3646
+ return runExactlyOnce((invoke) => storage.run(this.activeStore, invoke), callback);
3647
+ }
3648
+ return runExactlyOnce((invoke) => {
3649
+ try {
3650
+ enterStore(this, this.parentStore);
3651
+ } catch {
3652
+ }
3653
+ return storage.run(this.activeStore, invoke);
3654
+ }, callback);
3655
+ }
3656
+ suspend(value) {
3657
+ if (this.mode === "expired") return value;
3658
+ try {
3659
+ expectStore(this, this.activeStore);
3660
+ this.suspended = true;
3661
+ enterStore(this, this.parentStore);
3734
3662
  return value;
3735
- },
3736
- resume: (value) => {
3737
- if (suspended) {
3738
- expectStore(parent);
3739
- suspended = false;
3740
- enter(active);
3663
+ } catch {
3664
+ return value;
3665
+ }
3666
+ }
3667
+ resume(value) {
3668
+ if (this.mode === "expired") return value;
3669
+ try {
3670
+ if (this.suspended) {
3671
+ expectStore(this, this.parentStore);
3672
+ this.suspended = false;
3673
+ enterStore(this, this.activeStore);
3741
3674
  } else {
3742
- expectStore(active);
3675
+ expectStore(this, this.activeStore);
3743
3676
  }
3744
3677
  return value;
3745
- },
3746
- restore: () => {
3747
- expectStore(active);
3748
- enter(parent);
3678
+ } catch {
3679
+ return value;
3749
3680
  }
3750
- };
3681
+ }
3682
+ }
3683
+ const enterStore = (frame, next) => {
3684
+ if (currentStore() === next) return;
3685
+ try {
3686
+ storage.enterWith(next);
3687
+ } catch {
3688
+ if (frame.plan) degradeAttribution(frame.recording, frame.plan);
3689
+ }
3690
+ };
3691
+ const expectStore = (frame, expected) => {
3692
+ if (currentStore() !== expected && frame.plan) degradeAttribution(frame.recording, frame.plan);
3693
+ };
3694
+ const writeCapturedExit = (frame, value) => {
3695
+ if (!frame.recording.journal) return;
3696
+ const endedAtNs = process.hrtime.bigint();
3697
+ const returnValue = frame.omitCallValues ? rasputinOmitted() : captureValue(frame.recording, value);
3698
+ frame.recording.journal.finishCall(
3699
+ KIND_EXIT,
3700
+ frame.callId,
3701
+ endedAtNs - frame.recording.startedAtNs,
3702
+ endedAtNs - frame.startedAtNs,
3703
+ returnValue
3704
+ );
3705
+ stats.functionCallsCaptured++;
3706
+ };
3707
+ const writeCapturedThrow = (frame, error) => {
3708
+ if (!frame.recording.journal) return;
3709
+ const endedAtNs = process.hrtime.bigint();
3710
+ const capturedError = serializedError(frame.recording, error, frame.callId);
3711
+ frame.recording.journal.finishCall(
3712
+ KIND_THROW,
3713
+ frame.callId,
3714
+ endedAtNs - frame.recording.startedAtNs,
3715
+ endedAtNs - frame.startedAtNs,
3716
+ capturedError.value
3717
+ );
3718
+ stats.functionCallsCaptured++;
3719
+ capturedError.commit();
3720
+ };
3721
+ const activateUncaptured = (mode, recording, parentStore, plan, args, omitCallValues, parentCallId, startedAtNs, group, captureDroppedThrow) => {
3722
+ const frame = new CallFrame(
3723
+ mode,
3724
+ recording,
3725
+ parentStore,
3726
+ parentStore,
3727
+ plan,
3728
+ args,
3729
+ omitCallValues,
3730
+ parentCallId,
3731
+ startedAtNs,
3732
+ 0,
3733
+ group,
3734
+ captureDroppedThrow
3735
+ );
3736
+ enterStore(frame, parentStore);
3737
+ return frame;
3751
3738
  };
3752
3739
  const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
3753
3740
  if (!store) return noopHandle2;
@@ -3757,20 +3744,21 @@ var createExecutionRecorder = (options) => {
3757
3744
  }
3758
3745
  if (store.recording.finished) {
3759
3746
  if (!store.recording.budgetExpired && !store.recording.evicted) return noopHandle2;
3760
- const expired = store.recording;
3761
- const expiredStore = { recording: expired };
3762
- return {
3763
- leave: (value) => value,
3764
- fail: () => {
3765
- },
3766
- end: () => {
3767
- },
3768
- run: function __rasputinHandleRun__3(callback) {
3769
- return runExactlyOnce((invoke) => storage.run(expiredStore, invoke), callback);
3770
- },
3771
- suspend: (value) => value,
3772
- resume: (value) => value
3773
- };
3747
+ const expiredStore = { recording: store.recording };
3748
+ return new CallFrame(
3749
+ "expired",
3750
+ store.recording,
3751
+ expiredStore,
3752
+ expiredStore,
3753
+ void 0,
3754
+ EMPTY_ARGS,
3755
+ false,
3756
+ void 0,
3757
+ 0n,
3758
+ 0,
3759
+ void 0,
3760
+ false
3761
+ );
3774
3762
  }
3775
3763
  stats.functionCallsObserved++;
3776
3764
  const recording = store.recording;
@@ -3779,22 +3767,22 @@ var createExecutionRecorder = (options) => {
3779
3767
  if (store.suppressCapture || plan.excluded) {
3780
3768
  stats.functionCallsExcluded++;
3781
3769
  const excludedStore = { ...store, suppressCapture: true };
3782
- const excluded = bindStoreTransitions(excludedStore, store, recording, plan);
3783
- excluded.enterActive();
3784
- let ended2 = false;
3785
- return {
3786
- leave: (value) => value,
3787
- fail: () => {
3788
- },
3789
- end: () => {
3790
- if (ended2) return;
3791
- ended2 = true;
3792
- excluded.restore();
3793
- },
3794
- run: excluded.run,
3795
- suspend: excluded.suspend,
3796
- resume: excluded.resume
3797
- };
3770
+ const frame = new CallFrame(
3771
+ "excluded",
3772
+ recording,
3773
+ store,
3774
+ excludedStore,
3775
+ plan,
3776
+ EMPTY_ARGS,
3777
+ false,
3778
+ void 0,
3779
+ 0n,
3780
+ 0,
3781
+ void 0,
3782
+ false
3783
+ );
3784
+ enterStore(frame, excludedStore);
3785
+ return frame;
3798
3786
  }
3799
3787
  recording.inFlightCalls++;
3800
3788
  const group = repeatedCallGroup(recording, plan, parentCallId);
@@ -3804,127 +3792,64 @@ var createExecutionRecorder = (options) => {
3804
3792
  if (group.observedCalls === 1) journal?.notePlan(plan.runtimePlanId);
3805
3793
  } catch {
3806
3794
  }
3807
- let status = "open";
3808
- let pendingReturn;
3809
- let ended = false;
3810
3795
  const startedAtNs = process.hrtime.bigint();
3811
3796
  const parentStore = store;
3812
- const uncaptured = bindStoreTransitions(parentStore, parentStore, recording, plan);
3813
- const finishEnd = () => {
3814
- if (ended) return;
3815
- ended = true;
3816
- settleInFlight(recording);
3817
- uncaptured.restore();
3818
- };
3819
- const context = {
3820
- run: uncaptured.run,
3821
- suspend: uncaptured.suspend,
3822
- resume: uncaptured.resume
3823
- };
3824
3797
  if (group.observedCalls > maxCapturedCallsPerFunction) {
3825
- uncaptured.enterActive();
3826
- return {
3827
- leave: (value) => {
3828
- if (status !== "failed") {
3829
- status = "left";
3830
- pendingReturn = value;
3831
- }
3832
- return value;
3833
- },
3834
- fail: (error, liveArgs) => {
3835
- if (status === "failed") return;
3836
- status = "failed";
3837
- captureCompletedThrow(
3838
- recording,
3839
- plan,
3840
- liveArgs ?? args,
3841
- parentCallId,
3842
- startedAtNs,
3843
- error
3844
- );
3845
- },
3846
- end: () => {
3847
- if (status !== "failed") {
3848
- recordSuppressedCall(
3849
- recording,
3850
- group,
3851
- parentCallId,
3852
- startedAtNs,
3853
- process.hrtime.bigint()
3854
- );
3855
- }
3856
- finishEnd();
3857
- },
3858
- ...context
3859
- };
3798
+ return activateUncaptured(
3799
+ "suppressed",
3800
+ recording,
3801
+ parentStore,
3802
+ plan,
3803
+ args,
3804
+ omitCallValues,
3805
+ parentCallId,
3806
+ startedAtNs,
3807
+ group,
3808
+ false
3809
+ );
3860
3810
  }
3861
- const dropWithoutCapture = (onThrow) => {
3862
- uncaptured.enterActive();
3863
- return {
3864
- leave: (value) => {
3865
- if (status !== "failed") {
3866
- status = "left";
3867
- pendingReturn = value;
3868
- }
3869
- return value;
3870
- },
3871
- fail: (error) => {
3872
- if (status === "failed") return;
3873
- status = "failed";
3874
- onThrow(error);
3875
- },
3876
- end: () => {
3877
- if (status !== "failed") {
3878
- const droppedBefore = recording.journal?.dropped ?? 0;
3879
- recording.journal?.dropCall();
3880
- countDroppedEvents(recording, droppedBefore);
3881
- }
3882
- finishEnd();
3883
- },
3884
- ...context
3885
- };
3886
- };
3887
3811
  if (!journal) {
3888
3812
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3889
- uncaptured.enterActive();
3890
- return {
3891
- leave: (value) => {
3892
- if (status !== "failed") {
3893
- status = "left";
3894
- pendingReturn = value;
3895
- }
3896
- return value;
3897
- },
3898
- fail: (_error) => {
3899
- if (status === "failed") return;
3900
- status = "failed";
3901
- },
3902
- end: finishEnd,
3903
- ...context
3904
- };
3813
+ return activateUncaptured(
3814
+ "idle",
3815
+ recording,
3816
+ parentStore,
3817
+ plan,
3818
+ args,
3819
+ omitCallValues,
3820
+ parentCallId,
3821
+ startedAtNs,
3822
+ group,
3823
+ false
3824
+ );
3905
3825
  }
3906
3826
  if (!journal.canStartCall()) {
3907
- return dropWithoutCapture((error) => {
3908
- captureCompletedThrow(recording, plan, args, parentCallId, startedAtNs, error);
3909
- });
3827
+ return activateUncaptured(
3828
+ "dropped",
3829
+ recording,
3830
+ parentStore,
3831
+ plan,
3832
+ args,
3833
+ omitCallValues,
3834
+ parentCallId,
3835
+ startedAtNs,
3836
+ group,
3837
+ true
3838
+ );
3910
3839
  }
3911
3840
  if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
3912
- uncaptured.enterActive();
3913
- return {
3914
- leave: (value) => {
3915
- if (status !== "failed") {
3916
- status = "left";
3917
- pendingReturn = value;
3918
- }
3919
- return value;
3920
- },
3921
- fail: (_error) => {
3922
- if (status === "failed") return;
3923
- status = "failed";
3924
- },
3925
- end: finishEnd,
3926
- ...context
3927
- };
3841
+ return activateUncaptured(
3842
+ "idle",
3843
+ recording,
3844
+ parentStore,
3845
+ plan,
3846
+ args,
3847
+ omitCallValues,
3848
+ parentCallId,
3849
+ startedAtNs,
3850
+ group,
3851
+ false
3852
+ );
3928
3853
  }
3929
3854
  const callId = ++recording.nextCallId;
3930
3855
  const enterTimestampNs = process.hrtime.bigint() - recording.startedAtNs;
@@ -3933,65 +3858,36 @@ var createExecutionRecorder = (options) => {
3933
3858
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3934
3859
  } catch {
3935
3860
  journal.dropCall();
3936
- return dropWithoutCapture(() => {
3937
- });
3861
+ return activateUncaptured(
3862
+ "dropped",
3863
+ recording,
3864
+ parentStore,
3865
+ plan,
3866
+ args,
3867
+ omitCallValues,
3868
+ parentCallId,
3869
+ startedAtNs,
3870
+ group,
3871
+ false
3872
+ );
3938
3873
  }
3939
3874
  const callStore = { recording, currentCallId: callId };
3940
- const captured = bindStoreTransitions(callStore, parentStore, recording, plan);
3941
- captured.enterActive();
3942
- const writeExit = (value) => {
3943
- if (!recording.journal) return;
3944
- const timestampNs = process.hrtime.bigint() - recording.startedAtNs;
3945
- const durationNs = process.hrtime.bigint() - startedAtNs;
3946
- const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
3947
- recording.journal.finishCall(KIND_EXIT, callId, timestampNs, durationNs, returnValue);
3948
- stats.functionCallsCaptured++;
3949
- };
3950
- const writeThrow = (error) => {
3951
- if (!recording.journal) {
3952
- return;
3953
- }
3954
- const capturedError = serializedError(recording, error, callId);
3955
- recording.journal.finishCall(
3956
- KIND_THROW,
3957
- callId,
3958
- process.hrtime.bigint() - recording.startedAtNs,
3959
- process.hrtime.bigint() - startedAtNs,
3960
- capturedError.value
3961
- );
3962
- stats.functionCallsCaptured++;
3963
- capturedError.commit();
3964
- };
3965
- return {
3966
- leave: (value) => {
3967
- if (status !== "failed") {
3968
- status = "left";
3969
- pendingReturn = value;
3970
- }
3971
- return value;
3972
- },
3973
- fail: (error) => {
3974
- if (status === "failed") return;
3975
- status = "failed";
3976
- try {
3977
- writeThrow(error);
3978
- } catch {
3979
- }
3980
- },
3981
- end: () => {
3982
- try {
3983
- if (status !== "failed") writeExit(status === "left" ? pendingReturn : void 0);
3984
- } catch {
3985
- }
3986
- if (ended) return;
3987
- ended = true;
3988
- settleInFlight(recording);
3989
- captured.restore();
3990
- },
3991
- run: captured.run,
3992
- suspend: captured.suspend,
3993
- resume: captured.resume
3994
- };
3875
+ const captured = new CallFrame(
3876
+ "captured",
3877
+ recording,
3878
+ parentStore,
3879
+ callStore,
3880
+ plan,
3881
+ args,
3882
+ omitCallValues,
3883
+ parentCallId,
3884
+ startedAtNs,
3885
+ callId,
3886
+ group,
3887
+ false
3888
+ );
3889
+ enterStore(captured, callStore);
3890
+ return captured;
3995
3891
  };
3996
3892
  const runPreparedFunction = (plan, args, callback, omitValues) => {
3997
3893
  const store = currentStore();
@@ -4000,51 +3896,13 @@ var createExecutionRecorder = (options) => {
4000
3896
  }
4001
3897
  return runPreparedFunctionFromStore(store, plan, args, callback, omitValues);
4002
3898
  };
4003
- const isolateHandle2 = (handle) => ({
4004
- leave: (value) => {
4005
- try {
4006
- return handle.leave(value);
4007
- } catch {
4008
- return value;
4009
- }
4010
- },
4011
- fail: (error, liveArgs) => {
4012
- try {
4013
- handle.fail(error, liveArgs);
4014
- } catch {
4015
- }
4016
- },
4017
- end: () => {
4018
- try {
4019
- handle.end();
4020
- } catch {
4021
- }
4022
- },
4023
- run: function __rasputinHandleRun__3(callback) {
4024
- return runExactlyOnce((invoke) => handle.run(invoke), callback);
4025
- },
4026
- suspend: (value) => {
4027
- try {
4028
- return handle.suspend(value);
4029
- } catch {
4030
- return value;
4031
- }
4032
- },
4033
- resume: (value) => {
4034
- try {
4035
- return handle.resume(value);
4036
- } catch {
4037
- return value;
4038
- }
4039
- }
4040
- });
4041
3899
  const enterPreparedFunction = (plan, args, omitValues) => {
4042
3900
  try {
4043
3901
  const store = currentStore();
4044
3902
  if (store && !store.recording.finished && !store.recording.sawAutomatic) {
4045
3903
  store.recording.sawAutomatic = true;
4046
3904
  }
4047
- return isolateHandle2(enterPreparedFunctionFromStore(store, plan, args, omitValues));
3905
+ return enterPreparedFunctionFromStore(store, plan, args, omitValues);
4048
3906
  } catch {
4049
3907
  return noopHandle2;
4050
3908
  }
@@ -4071,14 +3929,14 @@ var createExecutionRecorder = (options) => {
4071
3929
  function trace(input, fn) {
4072
3930
  const definition = typeof input === "string" ? manualFunctionDefinition(input) : { ...input, functionId: runtimeFunctionId2(input) };
4073
3931
  const plan = preparePlan(definition);
4074
- return function __rasputinHandleRun__3(...args) {
3932
+ return function __rasputinHandleRun__4(...args) {
4075
3933
  if (new.target) {
4076
3934
  throw new TypeError("execution.trace() wraps function calls, not constructors");
4077
3935
  }
4078
3936
  const receiver = this;
4079
3937
  const store = currentStore();
4080
3938
  if (store && !store.recording.finished) store.recording.sawManual = true;
4081
- return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__4() {
3939
+ return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__5() {
4082
3940
  return fn.apply(receiver, args);
4083
3941
  });
4084
3942
  };
@@ -4114,9 +3972,7 @@ var bindExecution = (execution, module) => {
4114
3972
  module.cell.enter = (planIndex, args, omitValues) => {
4115
3973
  try {
4116
3974
  const plan = prepared[planIndex];
4117
- return isolateHandle(
4118
- plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle()
4119
- );
3975
+ return plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle();
4120
3976
  } catch {
4121
3977
  return passthroughHandle();
4122
3978
  }
@@ -4280,7 +4136,7 @@ var installGlobalHandlers = (client, options = {}) => {
4280
4136
 
4281
4137
  // src/sdk-meta.ts
4282
4138
  var SDK_NAME = "@rasputin-ai/node";
4283
- var SDK_VERSION = "0.9.1";
4139
+ var SDK_VERSION = "0.10.1";
4284
4140
 
4285
4141
  // src/rasputin-init.ts
4286
4142
  var publicExecution = (runtime) => ({
@@ -4342,6 +4198,7 @@ var RasputinInit = (options) => {
4342
4198
  sdkVersion: SDK_VERSION,
4343
4199
  sdkName: SDK_NAME,
4344
4200
  installTransportSignalHandlers: options.installTransportSignalHandlers,
4201
+ redactKeys: copyRedactKeys(options.executionRecorder?.redactKeys),
4345
4202
  resolveObservation: (observation) => runtime.getErrorState(observation)
4346
4203
  });
4347
4204
  if (enabled) {