@rasputin-ai/node 0.9.0 → 0.10.0

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;
@@ -384,6 +348,9 @@ var issueHeadline = (issue) => {
384
348
  if (issue.reason === "invalid_mapping") {
385
349
  return `The configured package root for ${target} does not match this Git release.`;
386
350
  }
351
+ if (issue.reason === "commit_not_found") {
352
+ return `GitHub does not have this release commit while locating ${target}.`;
353
+ }
387
354
  return `GitHub could not be reached while locating ${target}.`;
388
355
  };
389
356
  var formatIssue = (issue) => {
@@ -402,8 +369,11 @@ var formatIssue = (issue) => {
402
369
  var formatConfigurationReport = (input) => {
403
370
  const packages = input.verification.packages ?? [];
404
371
  const unresolved = input.verification.unresolved;
405
- const mappingIssues = unresolved.filter((issue) => issue.reason !== "github_unavailable");
372
+ const mappingIssues = unresolved.filter(
373
+ (issue) => issue.reason !== "github_unavailable" && issue.reason !== "commit_not_found"
374
+ );
406
375
  const githubUnavailable = input.verification.status === "unavailable" || unresolved.some((issue) => issue.reason === "github_unavailable");
376
+ const commitNotFound = input.verification.status === "commit_not_found";
407
377
  const verified = input.uploaded && input.verification.status === "verified";
408
378
  const lines = [
409
379
  ...BANNER,
@@ -442,13 +412,19 @@ var formatConfigurationReport = (input) => {
442
412
  lines.push("! upload failed");
443
413
  } else {
444
414
  lines.push("\u2713 uploaded");
445
- lines.push(
446
- verified ? "\u2713 verified against GitHub" : "! some source files could not be mapped to this Git release"
447
- );
415
+ if (verified) {
416
+ lines.push("\u2713 verified against GitHub");
417
+ } else if (commitNotFound) {
418
+ lines.push("! this Git commit was not found in the connected repository");
419
+ } else {
420
+ lines.push("! some source files could not be mapped to this Git release");
421
+ }
448
422
  }
449
423
  lines.push("", "GitHub");
450
424
  if (!input.uploaded) {
451
425
  lines.push("! not verified");
426
+ } else if (commitNotFound) {
427
+ lines.push("! push this commit to GitHub so Rasputin can map source");
452
428
  } else if (githubUnavailable) {
453
429
  lines.push("! repository is not connected, or this release could not be read");
454
430
  } else {
@@ -595,7 +571,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
595
571
  failedAttempts = 0;
596
572
  clearRetry();
597
573
  if (verification.status === "verified") {
598
- if (!loggedSuccess && options.logSuccess !== false) {
574
+ if (!loggedSuccess && options.logSuccess === true) {
599
575
  loggedSuccess = true;
600
576
  console.info(report(manifest, true, verification));
601
577
  }
@@ -689,7 +665,6 @@ var scheduleInstrumentationManifestUpload = (options) => {
689
665
  // src/execution-recorder/execution-recorder.ts
690
666
  import { AsyncLocalStorage } from "node:async_hooks";
691
667
  import {
692
- createEnvSecretMatcher,
693
668
  rasputinOmitted,
694
669
  rasputinTagKind,
695
670
  runtimeFunctionId as runtimeFunctionId2
@@ -1136,7 +1111,7 @@ var RecorderMemoryBudget = class {
1136
1111
  }
1137
1112
  return allocation;
1138
1113
  }
1139
- captureValue(allocation, serialize) {
1114
+ captureValue(allocation, value, freeze) {
1140
1115
  if (allocation.released) {
1141
1116
  this.dropValues(allocation, 1);
1142
1117
  return MEMORY_BUDGET_VALUE_MARKER;
@@ -1151,13 +1126,13 @@ var RecorderMemoryBudget = class {
1151
1126
  this.dropValues(allocation, 1);
1152
1127
  return MEMORY_BUDGET_VALUE_MARKER;
1153
1128
  }
1154
- const serialized = serialize();
1155
- 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)) {
1156
1131
  this.markPressure(allocation, "structure-only");
1157
1132
  this.dropValues(allocation, 1);
1158
1133
  return MEMORY_BUDGET_VALUE_MARKER;
1159
1134
  }
1160
- return serialized.value;
1135
+ return frozen.value;
1161
1136
  }
1162
1137
  reserveCall(allocation, estimatedBytes) {
1163
1138
  if (allocation.mode === "metadata-only") {
@@ -1241,7 +1216,16 @@ import {
1241
1216
  } from "@rasputin-ai/core";
1242
1217
  var MAX_RUNTIME_STATE_BYTES = 256 * 1024;
1243
1218
  var VALUE_OMITTED_REASON = "runtime_state_size_budget";
1244
- 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
+ };
1245
1229
  var sizeMetadata = (originalBytes) => ({
1246
1230
  reason: "runtime_state_size_budget",
1247
1231
  originalBytes,
@@ -1407,51 +1391,12 @@ var enforceRuntimeStateSizeBudget = (input) => {
1407
1391
 
1408
1392
  // src/execution-recorder/encode-frozen.ts
1409
1393
  import { Buffer as Buffer3 } from "node:buffer";
1410
- import { RASPUTIN_REDACTED as RASPUTIN_REDACTED2 } from "@rasputin-ai/core";
1394
+ import { RASPUTIN_REDACTED } from "@rasputin-ai/core";
1411
1395
 
1412
1396
  // src/execution-recorder/value-freeze.ts
1413
1397
  import { Buffer as Buffer2 } from "node:buffer";
1414
1398
  import { types } from "node:util";
1415
- import {
1416
- MAX_ENV_SECRET_NEEDLE_LENGTH,
1417
- RASPUTIN_REDACTED,
1418
- RASPUTIN_WIRE_TAG
1419
- } from "@rasputin-ai/core";
1420
-
1421
- // src/execution-recorder/redact-keys.ts
1422
- import { defaultSensitivePropertyNames, propertyNameIsSensitive } from "@rasputin-ai/core";
1423
- var compactKey = (key) => {
1424
- let compacted = "";
1425
- for (let index = 0; index < key.length; index++) {
1426
- const code = key.charCodeAt(index);
1427
- if (code === 45 || code === 46 || code === 95) continue;
1428
- compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
1429
- }
1430
- return compacted;
1431
- };
1432
- var stripTrailingDigits = (value) => {
1433
- let end = value.length;
1434
- while (end > 0) {
1435
- const code = value.charCodeAt(end - 1);
1436
- if (code < 48 || code > 57) break;
1437
- end--;
1438
- }
1439
- return end === 0 ? value : value.slice(0, end);
1440
- };
1441
- var normalizeKey = (key) => stripTrailingDigits(compactKey(key));
1442
- var compileRedactKeys = (extra) => {
1443
- if (!extra?.length) return defaultSensitivePropertyNames();
1444
- return /* @__PURE__ */ new Set([...defaultSensitivePropertyNames(), ...extra.map(normalizeKey)]);
1445
- };
1446
- var keyIsRedacted = (key, redactKeys) => {
1447
- if (propertyNameIsSensitive(key)) return true;
1448
- if (redactKeys.has(key)) return true;
1449
- const compacted = compactKey(key);
1450
- if (redactKeys.has(compacted)) return true;
1451
- return redactKeys.has(stripTrailingDigits(compacted));
1452
- };
1453
-
1454
- // src/execution-recorder/value-freeze.ts
1399
+ import { RASPUTIN_WIRE_TAG } from "@rasputin-ai/core";
1455
1400
  var defaults = {
1456
1401
  maxDepth: 3,
1457
1402
  maxObjectKeys: 30,
@@ -1479,16 +1424,20 @@ var atom = (kind, extra = {}) => ({
1479
1424
  [FROZEN]: kind,
1480
1425
  ...extra
1481
1426
  });
1482
- var ownData = (value, key) => {
1427
+ var NO_DATA = Symbol("rasputin.no-data");
1428
+ var ownValue = (value, key) => {
1483
1429
  try {
1484
1430
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
1485
- if (!descriptor) return void 0;
1486
- if ("value" in descriptor) return { present: true, value: descriptor.value };
1487
- return void 0;
1431
+ if (descriptor && "value" in descriptor) return descriptor.value;
1432
+ return NO_DATA;
1488
1433
  } catch {
1489
- return void 0;
1434
+ return NO_DATA;
1490
1435
  }
1491
1436
  };
1437
+ var copyBoundedString = (value) => {
1438
+ if (value.length === 0) return value;
1439
+ return Buffer2.from(value, "utf16le").toString("utf16le");
1440
+ };
1492
1441
  var nativeErrorStackGet = (() => {
1493
1442
  try {
1494
1443
  return Object.getOwnPropertyDescriptor(Error.prototype, "stack")?.get;
@@ -1544,8 +1493,8 @@ var isDomException = (value) => {
1544
1493
  }
1545
1494
  };
1546
1495
  var functionNameOf = (value) => {
1547
- const own = ownData(value, "name");
1548
- 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;
1549
1498
  return "anonymous";
1550
1499
  };
1551
1500
  var errorNameOf = (value) => {
@@ -1558,8 +1507,8 @@ var errorNameOf = (value) => {
1558
1507
  }
1559
1508
  let current = value;
1560
1509
  while (current) {
1561
- const slot = ownData(current, "name");
1562
- 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;
1563
1512
  try {
1564
1513
  current = Object.getPrototypeOf(current);
1565
1514
  } catch {
@@ -1575,8 +1524,8 @@ var errorMessageOf = (value) => {
1575
1524
  } catch {
1576
1525
  }
1577
1526
  }
1578
- const own = ownData(value, "message");
1579
- if (own) return own.value;
1527
+ const message = ownValue(value, "message");
1528
+ if (message !== NO_DATA) return message;
1580
1529
  if (!nativeErrorMessageGet) return void 0;
1581
1530
  try {
1582
1531
  return nativeErrorMessageGet.call(value);
@@ -1585,8 +1534,8 @@ var errorMessageOf = (value) => {
1585
1534
  }
1586
1535
  };
1587
1536
  var errorStackOf = (value) => withoutPrepareStackTrace(() => {
1588
- const own = ownData(value, "stack");
1589
- 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;
1590
1539
  try {
1591
1540
  const getter = Object.getOwnPropertyDescriptor(value, "stack")?.get;
1592
1541
  if (getter && nativeInstanceStackGet && getter === nativeInstanceStackGet) {
@@ -1646,24 +1595,23 @@ var sampleBytes = (bytes, max) => {
1646
1595
  for (let index = 0; index < length; index++) sample[index] = bytes[index] ?? 0;
1647
1596
  return sample;
1648
1597
  };
1649
- var RESERVED_USER_KEYS = /* @__PURE__ */ new Set([
1650
- "__proto__",
1651
- "__rasputin_type",
1652
- "__rasputin_truncated",
1653
- "__rasputin_fields",
1654
- "__reason",
1655
- "__original_length",
1656
- "__serialized_bytes"
1657
- ]);
1658
- var assignFrozenField = (fields, key, value) => {
1659
- if (RESERVED_USER_KEYS.has(key) || key.startsWith("__rasputin_")) {
1660
- const escaped = fields.__rasputin_fields ?? [];
1661
- escaped.push({ name: key, value });
1662
- fields.__rasputin_fields = escaped;
1663
- 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);
1664
1607
  }
1665
- fields[key] = value;
1608
+ return meta;
1666
1609
  };
1610
+ var frozenRecord = (keys, values) => ({
1611
+ [FROZEN]: "record",
1612
+ keys,
1613
+ values
1614
+ });
1667
1615
  var ownEnumerableKeys = (value, maxKeys) => {
1668
1616
  const keys = [];
1669
1617
  let proto = null;
@@ -1693,97 +1641,8 @@ var bufferByteLength = (value) => {
1693
1641
  }
1694
1642
  };
1695
1643
  var stringEstimate = (value) => NODE + 2 + Buffer2.byteLength(value, "utf8");
1696
- var URL_LIKE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
1697
- "url",
1698
- "href",
1699
- "originalurl",
1700
- "path",
1701
- "pathname",
1702
- "search",
1703
- "query",
1704
- "requesturl",
1705
- "requesturi",
1706
- "location",
1707
- "referer",
1708
- "referrer",
1709
- "uri",
1710
- "connectionuri",
1711
- "connectionurl",
1712
- "databaseuri",
1713
- "databaseurl",
1714
- "mongouri",
1715
- "mongourl",
1716
- "redisuri",
1717
- "redisurl",
1718
- "postgresuri",
1719
- "postgresurl"
1720
- ]);
1721
- var compactPropertyName = (key) => {
1722
- let compacted = "";
1723
- for (let index = 0; index < key.length; index++) {
1724
- const code = key.charCodeAt(index);
1725
- if (code === 45 || code === 46 || code === 95) continue;
1726
- compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
1727
- }
1728
- return compacted;
1729
- };
1730
- var propertyNameLooksLikeUrl = (key) => URL_LIKE_PROPERTY_NAMES.has(compactPropertyName(key));
1731
- var looksLikeBareQueryString = (text) => {
1732
- if (!text.includes("=") || /\s/.test(text)) return false;
1733
- if (/^[a-z][a-z0-9+.-]*:/i.test(text) || text.startsWith("/")) return false;
1734
- return /^[^\s=]+=[^\s]*(&[^\s=]+=[^\s]*)*$/.test(text);
1735
- };
1736
- var redactSensitiveQuery = (text, redactKeys) => {
1737
- const queryAt = text.indexOf("?");
1738
- let prefix = "";
1739
- let query = "";
1740
- let suffix = "";
1741
- if (queryAt >= 0) {
1742
- if (queryAt === text.length - 1) return text;
1743
- const hashAt = text.indexOf("#", queryAt + 1);
1744
- prefix = text.slice(0, queryAt + 1);
1745
- query = hashAt < 0 ? text.slice(queryAt + 1) : text.slice(queryAt + 1, hashAt);
1746
- suffix = hashAt < 0 ? "" : text.slice(hashAt);
1747
- } else if (looksLikeBareQueryString(text)) {
1748
- query = text;
1749
- } else {
1750
- return text;
1751
- }
1752
- if (!query.includes("=")) return text;
1753
- let changed = false;
1754
- const next = query.split("&").map((part) => {
1755
- const equals = part.indexOf("=");
1756
- const rawKey = equals < 0 ? part : part.slice(0, equals);
1757
- if (!rawKey) return part;
1758
- let decoded = rawKey;
1759
- try {
1760
- decoded = decodeURIComponent(rawKey.replace(/\+/g, " "));
1761
- } catch {
1762
- decoded = rawKey;
1763
- }
1764
- if (!keyIsRedacted(decoded, redactKeys) && !keyIsRedacted(rawKey, redactKeys)) return part;
1765
- changed = true;
1766
- return `${rawKey}=${RASPUTIN_REDACTED}`;
1767
- });
1768
- if (!changed) return text;
1769
- return `${prefix}${next.join("&")}${suffix}`;
1770
- };
1771
- var redactUrlUserinfo = (text) => {
1772
- const schemeEnd = text.indexOf("://");
1773
- if (schemeEnd <= 0) return text;
1774
- const rest = text.slice(schemeEnd + 3);
1775
- let authorityEnd = rest.length;
1776
- for (const marker of ["/", "?", "#"]) {
1777
- const at = rest.indexOf(marker);
1778
- if (at >= 0 && at < authorityEnd) authorityEnd = at;
1779
- }
1780
- const authority = rest.slice(0, authorityEnd);
1781
- const userinfoEnd = authority.lastIndexOf("@");
1782
- if (userinfoEnd < 0) return text;
1783
- return `${text.slice(0, schemeEnd + 3)}${RASPUTIN_REDACTED}@${authority.slice(userinfoEnd + 1)}${rest.slice(authorityEnd)}`;
1784
- };
1785
- var redactUrlLikeString = (text, redactKeys) => redactSensitiveQuery(redactUrlUserinfo(text), redactKeys);
1786
1644
  var isFrozenAtom = (value) => typeof value === "object" && value !== null && FROZEN in value;
1645
+ var isFrozenRecord = (value) => isFrozenAtom(value) && value[FROZEN] === "record";
1787
1646
  var isRetainedOverflowChild = (value) => {
1788
1647
  if (isFrozenAtom(value)) {
1789
1648
  if (value[FROZEN] === "truncated") return true;
@@ -1801,16 +1660,13 @@ var keepOverflowChild = (child, overflowedOnChild) => {
1801
1660
  var BYTE_LIMIT = "max_serialized_value_bytes";
1802
1661
  var createValueFreezer = (options = {}) => {
1803
1662
  const limits = compileFreezeLimits(options);
1804
- const redactKeys = compileRedactKeys(options.redactKeys);
1805
- const redactSecretValues = options.redactSecretValues;
1806
1663
  const sharedPath = /* @__PURE__ */ new Set();
1807
1664
  let freezing = false;
1808
1665
  const add = (metrics, count) => {
1809
1666
  metrics.estimatedBytes += count;
1810
1667
  if (metrics.estimatedBytes > limits.maxSerializedValueBytes) metrics.oversize = true;
1811
1668
  };
1812
- const freezeInner = (value, depth, path, metrics) => {
1813
- if (metrics.oversize) return void 0;
1669
+ const freezeLeaf = (value, metrics) => {
1814
1670
  metrics.visitedNodes++;
1815
1671
  if (value === null) {
1816
1672
  add(metrics, 4);
@@ -1830,16 +1686,11 @@ var createValueFreezer = (options = {}) => {
1830
1686
  return value;
1831
1687
  }
1832
1688
  if (typeof value === "string") {
1833
- let text = value;
1834
- if (redactSecretValues) {
1835
- const cap = limits.maxStringLength + MAX_ENV_SECRET_NEEDLE_LENGTH;
1836
- text = redactSecretValues(value.length > cap ? value.slice(0, cap) : value);
1837
- }
1838
- if (text.length <= limits.maxStringLength) {
1839
- add(metrics, stringEstimate(text));
1840
- return text;
1689
+ if (value.length <= limits.maxStringLength) {
1690
+ add(metrics, stringEstimate(value));
1691
+ return value;
1841
1692
  }
1842
- const sliced = text.slice(0, limits.maxStringLength);
1693
+ const sliced = copyBoundedString(value.slice(0, limits.maxStringLength));
1843
1694
  add(metrics, NODE + stringEstimate(sliced) + 48);
1844
1695
  return atom("truncated", {
1845
1696
  reason: "max_string_length",
@@ -1870,10 +1721,13 @@ var createValueFreezer = (options = {}) => {
1870
1721
  add(metrics, NODE + stringEstimate(name));
1871
1722
  return atom("function", { value: name });
1872
1723
  }
1873
- if (typeof value !== "object") {
1874
- add(metrics, NODE + 16);
1875
- return atom("unserializable");
1876
- }
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++;
1877
1731
  if (path.has(value)) {
1878
1732
  add(metrics, NODE + 16);
1879
1733
  return atom("circular");
@@ -1902,9 +1756,9 @@ var createValueFreezer = (options = {}) => {
1902
1756
  const stack = errorStackOf(value);
1903
1757
  const extras = {};
1904
1758
  for (const key of ["code", "cause", "statusCode"]) {
1905
- const slot = ownData(value, key);
1906
- if (!slot) continue;
1907
- 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);
1908
1762
  }
1909
1763
  return atom("Error", {
1910
1764
  name,
@@ -1938,20 +1792,14 @@ var createValueFreezer = (options = {}) => {
1938
1792
  if (counted2 >= limits.maxArrayElements || metrics.oversize) break;
1939
1793
  const key = freezeInner(mapKey, depth + 1, path, metrics);
1940
1794
  if (!keepOverflowChild(key, metrics.oversize)) break;
1941
- if (typeof mapKey === "string" && keyIsRedacted(mapKey, redactKeys)) {
1942
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
1943
- if (metrics.oversize) break;
1944
- entries.push([key, RASPUTIN_REDACTED]);
1945
- } else {
1946
- const mapValue = freezeInner(
1947
- Map.prototype.get.call(value, mapKey),
1948
- depth + 1,
1949
- path,
1950
- metrics
1951
- );
1952
- if (!keepOverflowChild(mapValue, metrics.oversize)) break;
1953
- entries.push([key, mapValue]);
1954
- }
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]);
1955
1803
  counted2++;
1956
1804
  }
1957
1805
  const hitBytes2 = metrics.oversize && counted2 < Math.min(size, limits.maxArrayElements);
@@ -1993,7 +1841,6 @@ var createValueFreezer = (options = {}) => {
1993
1841
  add(metrics, 2);
1994
1842
  const items = [];
1995
1843
  const maxItems = value.length > limits.maxArrayElements ? limits.maxArrayElements - 1 : value.length;
1996
- let redactNext = false;
1997
1844
  for (let index = 0; index < maxItems; index++) {
1998
1845
  if (metrics.oversize) break;
1999
1846
  let descriptor;
@@ -2006,27 +1853,17 @@ var createValueFreezer = (options = {}) => {
2006
1853
  add(metrics, NODE + 16);
2007
1854
  if (metrics.oversize) break;
2008
1855
  items.push(atom("hole"));
2009
- redactNext = false;
2010
1856
  continue;
2011
1857
  }
2012
1858
  if (!("value" in descriptor)) {
2013
1859
  add(metrics, NODE + 16);
2014
1860
  if (metrics.oversize) break;
2015
1861
  items.push(atom("accessor"));
2016
- redactNext = false;
2017
1862
  continue;
2018
1863
  }
2019
- if (redactNext) {
2020
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
2021
- if (metrics.oversize) break;
2022
- items.push(RASPUTIN_REDACTED);
2023
- redactNext = false;
2024
- } else {
2025
- const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
2026
- if (!keepOverflowChild(frozen, metrics.oversize)) break;
2027
- items.push(frozen);
2028
- redactNext = typeof descriptor.value === "string" && keyIsRedacted(descriptor.value, redactKeys);
2029
- }
1864
+ const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
1865
+ if (!keepOverflowChild(frozen, metrics.oversize)) break;
1866
+ items.push(frozen);
2030
1867
  }
2031
1868
  if (metrics.oversize && items.length < maxItems) {
2032
1869
  add(metrics, NODE + 32);
@@ -2117,7 +1954,8 @@ var createValueFreezer = (options = {}) => {
2117
1954
  }
2118
1955
  }
2119
1956
  add(metrics, 2);
2120
- const fields = /* @__PURE__ */ Object.create(null);
1957
+ const recordKeys = [];
1958
+ const recordValues = [];
2121
1959
  let typeName;
2122
1960
  let prototype = null;
2123
1961
  try {
@@ -2127,12 +1965,12 @@ var createValueFreezer = (options = {}) => {
2127
1965
  }
2128
1966
  if (prototype && types.isProxy(prototype)) {
2129
1967
  add(metrics, NODE + 16);
2130
- return atom("instance", { type: "Proxy", value: fields });
1968
+ return atom("instance", { type: "Proxy", value: frozenRecord(recordKeys, recordValues) });
2131
1969
  }
2132
1970
  if (prototype && prototype !== Object.prototype) {
2133
1971
  typeName = "instance";
2134
1972
  if (!types.isProxy(prototype)) {
2135
- const ctor = ownData(prototype, "constructor")?.value;
1973
+ const ctor = ownValue(prototype, "constructor");
2136
1974
  if (typeof ctor === "function") {
2137
1975
  const name = functionNameOf(ctor);
2138
1976
  if (name && name !== "anonymous") typeName = name;
@@ -2140,8 +1978,6 @@ var createValueFreezer = (options = {}) => {
2140
1978
  }
2141
1979
  add(metrics, NODE + stringEstimate(typeName));
2142
1980
  }
2143
- const pairLabel = ownData(value, "name") ?? ownData(value, "key");
2144
- const pairIsSensitive = pairLabel !== void 0 && typeof pairLabel.value === "string" && keyIsRedacted(pairLabel.value, redactKeys);
2145
1981
  const { keys, truncated } = ownEnumerableKeys(value, limits.maxObjectKeys);
2146
1982
  const maxKeys = truncated ? Math.max(0, limits.maxObjectKeys - 1) : keys.length;
2147
1983
  let kept = 0;
@@ -2149,40 +1985,35 @@ var createValueFreezer = (options = {}) => {
2149
1985
  if (metrics.oversize) break;
2150
1986
  const key = keys[index];
2151
1987
  if (key === void 0) continue;
2152
- add(metrics, stringEstimate(key));
1988
+ add(metrics, NODE + 2 + keyMeta(key).utf8Bytes);
2153
1989
  if (metrics.oversize) break;
2154
- if (keyIsRedacted(key, redactKeys) || key === "value" && pairIsSensitive) {
2155
- add(metrics, stringEstimate(RASPUTIN_REDACTED));
2156
- if (metrics.oversize) break;
2157
- assignFrozenField(fields, key, RASPUTIN_REDACTED);
2158
- kept++;
2159
- continue;
2160
- }
2161
- const slot = ownData(value, key);
2162
- if (slot) {
2163
- const field = typeof slot.value === "string" && propertyNameLooksLikeUrl(key) ? redactUrlLikeString(slot.value, redactKeys) : slot.value;
2164
- 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);
2165
1993
  if (!keepOverflowChild(frozen, metrics.oversize)) break;
2166
- assignFrozenField(fields, key, frozen);
1994
+ recordKeys.push(key);
1995
+ recordValues.push(frozen);
2167
1996
  kept++;
2168
1997
  } else {
2169
1998
  add(metrics, NODE + 16);
2170
1999
  if (metrics.oversize) break;
2171
- assignFrozenField(fields, key, atom("accessor"));
2000
+ recordKeys.push(key);
2001
+ recordValues.push(atom("accessor"));
2172
2002
  kept++;
2173
2003
  }
2174
2004
  }
2005
+ const record = frozenRecord(recordKeys, recordValues);
2175
2006
  const hitBytes = metrics.oversize && kept < maxKeys;
2176
2007
  if (hitBytes || truncated) {
2177
2008
  return atom("instance", {
2178
2009
  type: typeName,
2179
- value: fields,
2010
+ value: record,
2180
2011
  truncated: true,
2181
2012
  reason: hitBytes ? BYTE_LIMIT : "max_object_keys"
2182
2013
  });
2183
2014
  }
2184
- if (typeName) return atom("instance", { type: typeName, value: fields });
2185
- return fields;
2015
+ if (typeName) return atom("instance", { type: typeName, value: record });
2016
+ return record;
2186
2017
  } catch (error) {
2187
2018
  add(metrics, NODE + 32);
2188
2019
  return atom("unserializable", {
@@ -2193,30 +2024,43 @@ var createValueFreezer = (options = {}) => {
2193
2024
  }
2194
2025
  };
2195
2026
  const freeze = (value) => {
2196
- 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
+ }
2197
2046
  const reentrant = freezing;
2198
2047
  const path = reentrant ? /* @__PURE__ */ new Set() : sharedPath;
2199
2048
  if (!reentrant) {
2200
2049
  freezing = true;
2201
- sharedPath.clear();
2050
+ if (sharedPath.size !== 0) sharedPath.clear();
2202
2051
  }
2203
2052
  try {
2204
- const frozen = freezeInner(value, 0, path, metrics);
2205
- return {
2206
- value: frozen,
2207
- estimatedBytes: metrics.estimatedBytes,
2208
- visitedNodes: metrics.visitedNodes,
2209
- oversize: metrics.oversize
2210
- };
2053
+ snapshot.value = freezeInner(value, 0, path, snapshot);
2054
+ return snapshot;
2211
2055
  } catch {
2212
2056
  return {
2213
2057
  value: atom("unserializable"),
2214
2058
  estimatedBytes: NODE + 16,
2215
- visitedNodes: Math.max(1, metrics.visitedNodes),
2059
+ visitedNodes: Math.max(1, snapshot.visitedNodes),
2216
2060
  oversize: false
2217
2061
  };
2218
2062
  } finally {
2219
- path.clear();
2063
+ if (path.size !== 0) path.clear();
2220
2064
  if (!reentrant) freezing = false;
2221
2065
  }
2222
2066
  };
@@ -2282,7 +2126,7 @@ var jsonStringUtf8Bytes = (value) => {
2282
2126
  }
2283
2127
  return bytes;
2284
2128
  };
2285
- var ownData2 = (value, key) => {
2129
+ var ownData = (value, key) => {
2286
2130
  try {
2287
2131
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
2288
2132
  if (descriptor && "value" in descriptor) return descriptor.value;
@@ -2304,11 +2148,12 @@ var jsonLiteralUtf8Bytes = (value) => {
2304
2148
  case "string":
2305
2149
  return jsonStringUtf8Bytes(value);
2306
2150
  case "object": {
2151
+ if (isFrozenAtom(value)) return jsonLiteralUtf8Bytes(encodeFrozen(value));
2307
2152
  if (Array.isArray(value)) {
2308
2153
  let bytes2 = 2;
2309
2154
  for (let index = 0; index < value.length; index++) {
2310
2155
  if (index > 0) bytes2 += 1;
2311
- bytes2 += jsonLiteralUtf8Bytes(ownData2(value, index));
2156
+ bytes2 += jsonLiteralUtf8Bytes(ownData(value, index));
2312
2157
  }
2313
2158
  return bytes2;
2314
2159
  }
@@ -2319,7 +2164,7 @@ var jsonLiteralUtf8Bytes = (value) => {
2319
2164
  if (!first) bytes += 1;
2320
2165
  first = false;
2321
2166
  bytes += jsonStringUtf8Bytes(key) + 1;
2322
- bytes += jsonLiteralUtf8Bytes(ownData2(record, key));
2167
+ bytes += jsonLiteralUtf8Bytes(ownData(record, key));
2323
2168
  }
2324
2169
  return bytes;
2325
2170
  }
@@ -2385,6 +2230,28 @@ var encodePlainObject = (value) => {
2385
2230
  }
2386
2231
  return encoded;
2387
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
+ };
2388
2255
  var encodeAtom = (frozen) => {
2389
2256
  const kind = frozen[FROZEN];
2390
2257
  switch (kind) {
@@ -2454,8 +2321,10 @@ var encodeAtom = (frozen) => {
2454
2321
  ...frozen.serializedBytes === void 0 ? {} : { __serialized_bytes: frozen.serializedBytes },
2455
2322
  ...frozen.value === void 0 ? {} : { value: encodeFrozen(frozen.value) }
2456
2323
  });
2324
+ case "record":
2325
+ return encodeRecord(frozen);
2457
2326
  case "instance": {
2458
- 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);
2459
2328
  const encoded = /* @__PURE__ */ Object.create(null);
2460
2329
  if (typeof fields === "object" && fields !== null && !Array.isArray(fields)) {
2461
2330
  for (const key of Object.keys(fields)) {
@@ -2482,7 +2351,8 @@ var encodeAtom = (frozen) => {
2482
2351
  }
2483
2352
  };
2484
2353
  var encodeFrozen = (value) => {
2485
- if (value === RASPUTIN_REDACTED2) return RASPUTIN_REDACTED2;
2354
+ if (value === RASPUTIN_REDACTED) return RASPUTIN_REDACTED;
2355
+ if (isFrozenRecord(value)) return encodeRecord(value);
2486
2356
  if (isFrozenAtom(value)) return encodeAtom(value);
2487
2357
  if (Array.isArray(value)) {
2488
2358
  const items = new Array(value.length);
@@ -2632,6 +2502,7 @@ var warnIfMissingAsyncContextFrame = () => {
2632
2502
  var DEFAULT_MAX_ACTIVE_MEMORY_BYTES = 64 * 1024 * 1024;
2633
2503
  var DEFAULT_MAX_EXECUTION_HOLD_MS = 6e4;
2634
2504
  var DEFAULT_MAX_RETAINED_ERROR_RECORDINGS = 32;
2505
+ var EMPTY_ARGS = [];
2635
2506
  var phaseTimingEnabled = process.env.RASPUTIN_RECORDER_PHASE_TIMING === "1";
2636
2507
  var manualFunctionDefinition = (value) => {
2637
2508
  const located = /^(.+):([^:@]+)@(\d+):(\d+)$/.exec(value);
@@ -2650,7 +2521,7 @@ var normalizeFunctionDefinition = (value) => typeof value === "string" ? manualF
2650
2521
  var elapsedMs2 = (startedAtNs, endedAtNs = process.hrtime.bigint()) => Number(endedAtNs - startedAtNs) / 1e6;
2651
2522
  var roundedMilliseconds2 = (nanoseconds) => Math.round(Number(nanoseconds) / 1e6 * 1e4) / 1e4;
2652
2523
  var addRecorderTime = (recording, nanoseconds) => {
2653
- if (process.env.RASPUTIN_RECORDER_PHASE_TIMING !== "1" || nanoseconds <= 0n) return;
2524
+ if (!phaseTimingEnabled || nanoseconds <= 0n) return;
2654
2525
  recording.inlineRecorderTimeNs += nanoseconds;
2655
2526
  };
2656
2527
  var mapArrayLike = (args, map) => {
@@ -2666,7 +2537,7 @@ var notifyObserver = (observer, value) => {
2666
2537
  } catch {
2667
2538
  }
2668
2539
  };
2669
- var observeRecordedCallback = function __rasputinHandleRun__2(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
2540
+ var observeRecordedCallback = function __rasputinHandleRun__3(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
2670
2541
  const callbackStartedAtNs = phaseTimingEnabled ? process.hrtime.bigint() : recorderStartedAtNs;
2671
2542
  const recordExitWork = (callbackEndedAtNs) => {
2672
2543
  if (!phaseTimingEnabled) return;
@@ -2819,11 +2690,7 @@ var createExecutionRecorder = (options) => {
2819
2690
  maxActiveMemoryBytes,
2820
2691
  options.maxSerializedValueBytes ?? 16 * 1024
2821
2692
  );
2822
- const envSecretMatcher = createEnvSecretMatcher();
2823
- const serializer = createSafeSerializer({
2824
- ...options,
2825
- ...envSecretMatcher.needleCount > 0 ? { redactSecretValues: envSecretMatcher.redact } : {}
2826
- });
2693
+ const serializer = createSafeSerializer(options);
2827
2694
  const excludesSource = createSourceExclusionMatcher(options.excludeSources);
2828
2695
  const journalPool = new ExecutionJournalPool(maxEventsPerExecution);
2829
2696
  const plansByRuntimeId = [];
@@ -2872,15 +2739,11 @@ var createExecutionRecorder = (options) => {
2872
2739
  stats.serializedValues++;
2873
2740
  stats.serializedValueNodes += frozen.visitedNodes;
2874
2741
  stats.serializedValueBytes += frozen.estimatedBytes;
2875
- return {
2876
- value: frozen.value,
2877
- bytes: frozen.estimatedBytes,
2878
- visitedNodes: frozen.visitedNodes
2879
- };
2742
+ return frozen;
2880
2743
  };
2881
2744
  const captureValue = (recording, value) => {
2882
2745
  try {
2883
- return memoryBudget.captureValue(recording.memory, () => freezeAndCount(value));
2746
+ return memoryBudget.captureValue(recording.memory, value, freezeAndCount);
2884
2747
  } catch {
2885
2748
  return { __rasputin_type: "unserializable" };
2886
2749
  }
@@ -3043,7 +2906,7 @@ var createExecutionRecorder = (options) => {
3043
2906
  version: 4,
3044
2907
  captureProfile: resolveCaptureProfile(recording, events, truncated, capture),
3045
2908
  executionId: recording.executionId,
3046
- startedAt: recording.startedAt,
2909
+ startedAt: new Date(recording.startedAtMs).toISOString(),
3047
2910
  durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
3048
2911
  recorder: { inlineWallTimeMs: 0 },
3049
2912
  execution: {
@@ -3077,7 +2940,7 @@ var createExecutionRecorder = (options) => {
3077
2940
  if (recording.evidenceDiscarded) return;
3078
2941
  recording.evidenceDiscarded = true;
3079
2942
  recording.cachedState = void 0;
3080
- recording.repeatedCalls = [];
2943
+ recording.repeatedCalls = void 0;
3081
2944
  recording.lateCapturedCallIds = void 0;
3082
2945
  recording.capturedErrors = /* @__PURE__ */ new WeakMap();
3083
2946
  if (recording.journal) {
@@ -3263,11 +3126,15 @@ var createExecutionRecorder = (options) => {
3263
3126
  countDroppedEvents(recording, droppedBefore);
3264
3127
  };
3265
3128
  const repeatedCallGroup = (recording, plan, parentCallId) => {
3266
- const slots = recording.repeatedCalls;
3267
- 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);
3268
3135
  if (!slot) {
3269
3136
  slot = {};
3270
- slots[plan.runtimePlanId] = slot;
3137
+ slots.set(plan.runtimePlanId, slot);
3271
3138
  }
3272
3139
  if (parentCallId === void 0) {
3273
3140
  if (!slot.root) slot.root = newRepeatedGroup(plan);
@@ -3417,10 +3284,10 @@ var createExecutionRecorder = (options) => {
3417
3284
  } catch {
3418
3285
  }
3419
3286
  };
3420
- const runStore = function __rasputinHandleRun__3(store, callback) {
3287
+ const runStore = function __rasputinHandleRun__4(store, callback) {
3421
3288
  if (!phaseTimingEnabled) return storage.run(store, callback);
3422
3289
  const alsStartedAtNs = process.hrtime.bigint();
3423
- return storage.run(store, function __rasputinHandleRun__4() {
3290
+ return storage.run(store, function __rasputinHandleRun__5() {
3424
3291
  addPhase("alsNs", process.hrtime.bigint() - alsStartedAtNs);
3425
3292
  return callback();
3426
3293
  });
@@ -3432,7 +3299,7 @@ var createExecutionRecorder = (options) => {
3432
3299
  const recording = {
3433
3300
  executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
3434
3301
  storageGeneration: ++storageClock,
3435
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3302
+ startedAtMs: Date.now(),
3436
3303
  startedAtNs: recorderStartedAtNs,
3437
3304
  inlineRecorderTimeNs: 0n,
3438
3305
  execution: {
@@ -3440,7 +3307,6 @@ var createExecutionRecorder = (options) => {
3440
3307
  ...metadata.request ? { request: { ...metadata.request } } : {}
3441
3308
  },
3442
3309
  journal: void 0,
3443
- repeatedCalls: [],
3444
3310
  capturedErrors: /* @__PURE__ */ new WeakMap(),
3445
3311
  nextCallId: 0,
3446
3312
  inFlightCalls: 0,
@@ -3458,11 +3324,11 @@ var createExecutionRecorder = (options) => {
3458
3324
  addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
3459
3325
  const store = { recording };
3460
3326
  return {
3461
- run: function __rasputinHandleRun__3(callback) {
3327
+ run: function __rasputinHandleRun__4(callback) {
3462
3328
  let startedCallback = false;
3463
3329
  try {
3464
3330
  const runStartedAtNs = process.hrtime.bigint();
3465
- return runStore(store, function __rasputinHandleRun__4() {
3331
+ return runStore(store, function __rasputinHandleRun__5() {
3466
3332
  startedCallback = true;
3467
3333
  addRecorderTime(recording, process.hrtime.bigint() - runStartedAtNs);
3468
3334
  try {
@@ -3510,14 +3376,14 @@ var createExecutionRecorder = (options) => {
3510
3376
  return void 0;
3511
3377
  }
3512
3378
  };
3513
- const runPreparedFunctionFromStore = function __rasputinHandleRun__3(store, plan, args, callback, omitValues) {
3379
+ const runPreparedFunctionFromStore = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
3514
3380
  let startedCallback = false;
3515
3381
  try {
3516
3382
  return runPreparedFunctionFromStoreInner(
3517
3383
  store,
3518
3384
  plan,
3519
3385
  args,
3520
- function __rasputinHandleRun__4() {
3386
+ function __rasputinHandleRun__5() {
3521
3387
  startedCallback = true;
3522
3388
  return callback();
3523
3389
  },
@@ -3528,7 +3394,7 @@ var createExecutionRecorder = (options) => {
3528
3394
  return callback();
3529
3395
  }
3530
3396
  };
3531
- const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__3(store, plan, args, callback, omitValues) {
3397
+ const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
3532
3398
  const omitCallValues = omitValues === true || plan.omitCallValues;
3533
3399
  if (!store) return callback();
3534
3400
  if (plan.disabled) {
@@ -3549,7 +3415,7 @@ var createExecutionRecorder = (options) => {
3549
3415
  const recorderStartedAtNs = process.hrtime.bigint();
3550
3416
  if (store.suppressCapture || plan.excluded) {
3551
3417
  stats.functionCallsExcluded++;
3552
- return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__4() {
3418
+ return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__5() {
3553
3419
  addRecorderTime(store.recording, process.hrtime.bigint() - recorderStartedAtNs);
3554
3420
  return callback();
3555
3421
  });
@@ -3567,7 +3433,7 @@ var createExecutionRecorder = (options) => {
3567
3433
  if (group.observedCalls > maxCapturedCallsPerFunction) {
3568
3434
  const startedAtNs2 = process.hrtime.bigint();
3569
3435
  try {
3570
- const result = runStore(store, function __rasputinHandleRun__4() {
3436
+ const result = runStore(store, function __rasputinHandleRun__5() {
3571
3437
  return callback();
3572
3438
  });
3573
3439
  recordSuppressedCall(recording, group, parentCallId, startedAtNs2, process.hrtime.bigint());
@@ -3582,7 +3448,7 @@ var createExecutionRecorder = (options) => {
3582
3448
  const startedAtNs = process.hrtime.bigint();
3583
3449
  if (!journal) {
3584
3450
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3585
- return runStore(store, function __rasputinHandleRun__4() {
3451
+ return runStore(store, function __rasputinHandleRun__5() {
3586
3452
  return observeRecordedCallback(
3587
3453
  recording,
3588
3454
  recorderStartedAtNs,
@@ -3601,7 +3467,7 @@ var createExecutionRecorder = (options) => {
3601
3467
  countDroppedEvents(recording, droppedBefore);
3602
3468
  settleInFlight(recording);
3603
3469
  };
3604
- return runStore(store, function __rasputinHandleRun__4() {
3470
+ return runStore(store, function __rasputinHandleRun__5() {
3605
3471
  return observeRecordedCallback(
3606
3472
  recording,
3607
3473
  recorderStartedAtNs,
@@ -3632,7 +3498,7 @@ var createExecutionRecorder = (options) => {
3632
3498
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3633
3499
  } catch {
3634
3500
  journal.dropCall();
3635
- return runStore(store, function __rasputinHandleRun__4() {
3501
+ return runStore(store, function __rasputinHandleRun__5() {
3636
3502
  return observeRecordedCallback(
3637
3503
  recording,
3638
3504
  recorderStartedAtNs,
@@ -3645,17 +3511,22 @@ var createExecutionRecorder = (options) => {
3645
3511
  });
3646
3512
  }
3647
3513
  const callStore = { recording, currentCallId: callId };
3648
- return runStore(callStore, function __rasputinHandleRun__4() {
3514
+ return runStore(callStore, function __rasputinHandleRun__5() {
3649
3515
  return observeRecordedCallback(
3650
3516
  recording,
3651
3517
  recorderStartedAtNs,
3652
3518
  callback,
3653
3519
  (value) => {
3654
3520
  if (recording.journal) {
3655
- const timestampNs = process.hrtime.bigint() - recording.startedAtNs;
3656
- const durationNs = process.hrtime.bigint() - startedAtNs;
3521
+ const endedAtNs = process.hrtime.bigint();
3657
3522
  const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
3658
- 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
+ );
3659
3530
  stats.functionCallsCaptured++;
3660
3531
  }
3661
3532
  settleInFlight(recording);
@@ -3666,11 +3537,12 @@ var createExecutionRecorder = (options) => {
3666
3537
  return;
3667
3538
  }
3668
3539
  const capturedError = serializedError(recording, error, callId);
3540
+ const endedAtNs = process.hrtime.bigint();
3669
3541
  recording.journal.finishCall(
3670
3542
  KIND_THROW,
3671
3543
  callId,
3672
- process.hrtime.bigint() - recording.startedAtNs,
3673
- process.hrtime.bigint() - startedAtNs,
3544
+ endedAtNs - recording.startedAtNs,
3545
+ endedAtNs - startedAtNs,
3674
3546
  capturedError.value
3675
3547
  );
3676
3548
  stats.functionCallsCaptured++;
@@ -3680,62 +3552,189 @@ var createExecutionRecorder = (options) => {
3680
3552
  );
3681
3553
  });
3682
3554
  };
3683
- const noopHandle2 = {
3684
- leave: (value) => value,
3685
- fail: () => {
3686
- },
3687
- end: () => {
3688
- },
3689
- run: function __rasputinHandleRun__3(callback) {
3690
- return runExactlyOnce((invoke) => invoke(), callback);
3691
- },
3692
- suspend: (value) => value,
3693
- resume: (value) => value
3694
- };
3695
- const bindStoreTransitions = (active, parent, recording, plan) => {
3696
- let suspended = false;
3697
- 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) {
3698
3576
  try {
3699
- storage.enterWith(next);
3577
+ if (this.status !== "failed") {
3578
+ this.status = "left";
3579
+ this.pendingReturn = value;
3580
+ }
3581
+ return value;
3700
3582
  } catch {
3701
- degradeAttribution(recording, plan);
3583
+ return value;
3702
3584
  }
3703
- };
3704
- const expectStore = (expected) => {
3705
- if (currentStore() !== expected) degradeAttribution(recording, plan);
3706
- };
3707
- return {
3708
- enterActive: () => enter(active),
3709
- run: function __rasputinHandleRun__3(callback) {
3710
- return runExactlyOnce((invoke) => {
3711
- try {
3712
- enter(parent);
3713
- } 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);
3714
3631
  }
3715
- return storage.run(active, invoke);
3716
- }, callback);
3717
- },
3718
- suspend: (value) => {
3719
- expectStore(active);
3720
- suspended = true;
3721
- 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);
3722
3662
  return value;
3723
- },
3724
- resume: (value) => {
3725
- if (suspended) {
3726
- expectStore(parent);
3727
- suspended = false;
3728
- 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);
3729
3674
  } else {
3730
- expectStore(active);
3675
+ expectStore(this, this.activeStore);
3731
3676
  }
3732
3677
  return value;
3733
- },
3734
- restore: () => {
3735
- expectStore(active);
3736
- enter(parent);
3678
+ } catch {
3679
+ return value;
3737
3680
  }
3738
- };
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;
3739
3738
  };
3740
3739
  const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
3741
3740
  if (!store) return noopHandle2;
@@ -3745,20 +3744,21 @@ var createExecutionRecorder = (options) => {
3745
3744
  }
3746
3745
  if (store.recording.finished) {
3747
3746
  if (!store.recording.budgetExpired && !store.recording.evicted) return noopHandle2;
3748
- const expired = store.recording;
3749
- const expiredStore = { recording: expired };
3750
- return {
3751
- leave: (value) => value,
3752
- fail: () => {
3753
- },
3754
- end: () => {
3755
- },
3756
- run: function __rasputinHandleRun__3(callback) {
3757
- return runExactlyOnce((invoke) => storage.run(expiredStore, invoke), callback);
3758
- },
3759
- suspend: (value) => value,
3760
- resume: (value) => value
3761
- };
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
+ );
3762
3762
  }
3763
3763
  stats.functionCallsObserved++;
3764
3764
  const recording = store.recording;
@@ -3767,22 +3767,22 @@ var createExecutionRecorder = (options) => {
3767
3767
  if (store.suppressCapture || plan.excluded) {
3768
3768
  stats.functionCallsExcluded++;
3769
3769
  const excludedStore = { ...store, suppressCapture: true };
3770
- const excluded = bindStoreTransitions(excludedStore, store, recording, plan);
3771
- excluded.enterActive();
3772
- let ended2 = false;
3773
- return {
3774
- leave: (value) => value,
3775
- fail: () => {
3776
- },
3777
- end: () => {
3778
- if (ended2) return;
3779
- ended2 = true;
3780
- excluded.restore();
3781
- },
3782
- run: excluded.run,
3783
- suspend: excluded.suspend,
3784
- resume: excluded.resume
3785
- };
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;
3786
3786
  }
3787
3787
  recording.inFlightCalls++;
3788
3788
  const group = repeatedCallGroup(recording, plan, parentCallId);
@@ -3792,127 +3792,64 @@ var createExecutionRecorder = (options) => {
3792
3792
  if (group.observedCalls === 1) journal?.notePlan(plan.runtimePlanId);
3793
3793
  } catch {
3794
3794
  }
3795
- let status = "open";
3796
- let pendingReturn;
3797
- let ended = false;
3798
3795
  const startedAtNs = process.hrtime.bigint();
3799
3796
  const parentStore = store;
3800
- const uncaptured = bindStoreTransitions(parentStore, parentStore, recording, plan);
3801
- const finishEnd = () => {
3802
- if (ended) return;
3803
- ended = true;
3804
- settleInFlight(recording);
3805
- uncaptured.restore();
3806
- };
3807
- const context = {
3808
- run: uncaptured.run,
3809
- suspend: uncaptured.suspend,
3810
- resume: uncaptured.resume
3811
- };
3812
3797
  if (group.observedCalls > maxCapturedCallsPerFunction) {
3813
- uncaptured.enterActive();
3814
- return {
3815
- leave: (value) => {
3816
- if (status !== "failed") {
3817
- status = "left";
3818
- pendingReturn = value;
3819
- }
3820
- return value;
3821
- },
3822
- fail: (error, liveArgs) => {
3823
- if (status === "failed") return;
3824
- status = "failed";
3825
- captureCompletedThrow(
3826
- recording,
3827
- plan,
3828
- liveArgs ?? args,
3829
- parentCallId,
3830
- startedAtNs,
3831
- error
3832
- );
3833
- },
3834
- end: () => {
3835
- if (status !== "failed") {
3836
- recordSuppressedCall(
3837
- recording,
3838
- group,
3839
- parentCallId,
3840
- startedAtNs,
3841
- process.hrtime.bigint()
3842
- );
3843
- }
3844
- finishEnd();
3845
- },
3846
- ...context
3847
- };
3798
+ return activateUncaptured(
3799
+ "suppressed",
3800
+ recording,
3801
+ parentStore,
3802
+ plan,
3803
+ args,
3804
+ omitCallValues,
3805
+ parentCallId,
3806
+ startedAtNs,
3807
+ group,
3808
+ false
3809
+ );
3848
3810
  }
3849
- const dropWithoutCapture = (onThrow) => {
3850
- uncaptured.enterActive();
3851
- return {
3852
- leave: (value) => {
3853
- if (status !== "failed") {
3854
- status = "left";
3855
- pendingReturn = value;
3856
- }
3857
- return value;
3858
- },
3859
- fail: (error) => {
3860
- if (status === "failed") return;
3861
- status = "failed";
3862
- onThrow(error);
3863
- },
3864
- end: () => {
3865
- if (status !== "failed") {
3866
- const droppedBefore = recording.journal?.dropped ?? 0;
3867
- recording.journal?.dropCall();
3868
- countDroppedEvents(recording, droppedBefore);
3869
- }
3870
- finishEnd();
3871
- },
3872
- ...context
3873
- };
3874
- };
3875
3811
  if (!journal) {
3876
3812
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3877
- uncaptured.enterActive();
3878
- return {
3879
- leave: (value) => {
3880
- if (status !== "failed") {
3881
- status = "left";
3882
- pendingReturn = value;
3883
- }
3884
- return value;
3885
- },
3886
- fail: (_error) => {
3887
- if (status === "failed") return;
3888
- status = "failed";
3889
- },
3890
- end: finishEnd,
3891
- ...context
3892
- };
3813
+ return activateUncaptured(
3814
+ "idle",
3815
+ recording,
3816
+ parentStore,
3817
+ plan,
3818
+ args,
3819
+ omitCallValues,
3820
+ parentCallId,
3821
+ startedAtNs,
3822
+ group,
3823
+ false
3824
+ );
3893
3825
  }
3894
3826
  if (!journal.canStartCall()) {
3895
- return dropWithoutCapture((error) => {
3896
- captureCompletedThrow(recording, plan, args, parentCallId, startedAtNs, error);
3897
- });
3827
+ return activateUncaptured(
3828
+ "dropped",
3829
+ recording,
3830
+ parentStore,
3831
+ plan,
3832
+ args,
3833
+ omitCallValues,
3834
+ parentCallId,
3835
+ startedAtNs,
3836
+ group,
3837
+ true
3838
+ );
3898
3839
  }
3899
3840
  if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
3900
- uncaptured.enterActive();
3901
- return {
3902
- leave: (value) => {
3903
- if (status !== "failed") {
3904
- status = "left";
3905
- pendingReturn = value;
3906
- }
3907
- return value;
3908
- },
3909
- fail: (_error) => {
3910
- if (status === "failed") return;
3911
- status = "failed";
3912
- },
3913
- end: finishEnd,
3914
- ...context
3915
- };
3841
+ return activateUncaptured(
3842
+ "idle",
3843
+ recording,
3844
+ parentStore,
3845
+ plan,
3846
+ args,
3847
+ omitCallValues,
3848
+ parentCallId,
3849
+ startedAtNs,
3850
+ group,
3851
+ false
3852
+ );
3916
3853
  }
3917
3854
  const callId = ++recording.nextCallId;
3918
3855
  const enterTimestampNs = process.hrtime.bigint() - recording.startedAtNs;
@@ -3921,65 +3858,36 @@ var createExecutionRecorder = (options) => {
3921
3858
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3922
3859
  } catch {
3923
3860
  journal.dropCall();
3924
- return dropWithoutCapture(() => {
3925
- });
3861
+ return activateUncaptured(
3862
+ "dropped",
3863
+ recording,
3864
+ parentStore,
3865
+ plan,
3866
+ args,
3867
+ omitCallValues,
3868
+ parentCallId,
3869
+ startedAtNs,
3870
+ group,
3871
+ false
3872
+ );
3926
3873
  }
3927
3874
  const callStore = { recording, currentCallId: callId };
3928
- const captured = bindStoreTransitions(callStore, parentStore, recording, plan);
3929
- captured.enterActive();
3930
- const writeExit = (value) => {
3931
- if (!recording.journal) return;
3932
- const timestampNs = process.hrtime.bigint() - recording.startedAtNs;
3933
- const durationNs = process.hrtime.bigint() - startedAtNs;
3934
- const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
3935
- recording.journal.finishCall(KIND_EXIT, callId, timestampNs, durationNs, returnValue);
3936
- stats.functionCallsCaptured++;
3937
- };
3938
- const writeThrow = (error) => {
3939
- if (!recording.journal) {
3940
- return;
3941
- }
3942
- const capturedError = serializedError(recording, error, callId);
3943
- recording.journal.finishCall(
3944
- KIND_THROW,
3945
- callId,
3946
- process.hrtime.bigint() - recording.startedAtNs,
3947
- process.hrtime.bigint() - startedAtNs,
3948
- capturedError.value
3949
- );
3950
- stats.functionCallsCaptured++;
3951
- capturedError.commit();
3952
- };
3953
- return {
3954
- leave: (value) => {
3955
- if (status !== "failed") {
3956
- status = "left";
3957
- pendingReturn = value;
3958
- }
3959
- return value;
3960
- },
3961
- fail: (error) => {
3962
- if (status === "failed") return;
3963
- status = "failed";
3964
- try {
3965
- writeThrow(error);
3966
- } catch {
3967
- }
3968
- },
3969
- end: () => {
3970
- try {
3971
- if (status !== "failed") writeExit(status === "left" ? pendingReturn : void 0);
3972
- } catch {
3973
- }
3974
- if (ended) return;
3975
- ended = true;
3976
- settleInFlight(recording);
3977
- captured.restore();
3978
- },
3979
- run: captured.run,
3980
- suspend: captured.suspend,
3981
- resume: captured.resume
3982
- };
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;
3983
3891
  };
3984
3892
  const runPreparedFunction = (plan, args, callback, omitValues) => {
3985
3893
  const store = currentStore();
@@ -3988,51 +3896,13 @@ var createExecutionRecorder = (options) => {
3988
3896
  }
3989
3897
  return runPreparedFunctionFromStore(store, plan, args, callback, omitValues);
3990
3898
  };
3991
- const isolateHandle2 = (handle) => ({
3992
- leave: (value) => {
3993
- try {
3994
- return handle.leave(value);
3995
- } catch {
3996
- return value;
3997
- }
3998
- },
3999
- fail: (error, liveArgs) => {
4000
- try {
4001
- handle.fail(error, liveArgs);
4002
- } catch {
4003
- }
4004
- },
4005
- end: () => {
4006
- try {
4007
- handle.end();
4008
- } catch {
4009
- }
4010
- },
4011
- run: function __rasputinHandleRun__3(callback) {
4012
- return runExactlyOnce((invoke) => handle.run(invoke), callback);
4013
- },
4014
- suspend: (value) => {
4015
- try {
4016
- return handle.suspend(value);
4017
- } catch {
4018
- return value;
4019
- }
4020
- },
4021
- resume: (value) => {
4022
- try {
4023
- return handle.resume(value);
4024
- } catch {
4025
- return value;
4026
- }
4027
- }
4028
- });
4029
3899
  const enterPreparedFunction = (plan, args, omitValues) => {
4030
3900
  try {
4031
3901
  const store = currentStore();
4032
3902
  if (store && !store.recording.finished && !store.recording.sawAutomatic) {
4033
3903
  store.recording.sawAutomatic = true;
4034
3904
  }
4035
- return isolateHandle2(enterPreparedFunctionFromStore(store, plan, args, omitValues));
3905
+ return enterPreparedFunctionFromStore(store, plan, args, omitValues);
4036
3906
  } catch {
4037
3907
  return noopHandle2;
4038
3908
  }
@@ -4059,14 +3929,14 @@ var createExecutionRecorder = (options) => {
4059
3929
  function trace(input, fn) {
4060
3930
  const definition = typeof input === "string" ? manualFunctionDefinition(input) : { ...input, functionId: runtimeFunctionId2(input) };
4061
3931
  const plan = preparePlan(definition);
4062
- return function __rasputinHandleRun__3(...args) {
3932
+ return function __rasputinHandleRun__4(...args) {
4063
3933
  if (new.target) {
4064
3934
  throw new TypeError("execution.trace() wraps function calls, not constructors");
4065
3935
  }
4066
3936
  const receiver = this;
4067
3937
  const store = currentStore();
4068
3938
  if (store && !store.recording.finished) store.recording.sawManual = true;
4069
- return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__4() {
3939
+ return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__5() {
4070
3940
  return fn.apply(receiver, args);
4071
3941
  });
4072
3942
  };
@@ -4102,9 +3972,7 @@ var bindExecution = (execution, module) => {
4102
3972
  module.cell.enter = (planIndex, args, omitValues) => {
4103
3973
  try {
4104
3974
  const plan = prepared[planIndex];
4105
- return isolateHandle(
4106
- plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle()
4107
- );
3975
+ return plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle();
4108
3976
  } catch {
4109
3977
  return passthroughHandle();
4110
3978
  }
@@ -4268,7 +4136,7 @@ var installGlobalHandlers = (client, options = {}) => {
4268
4136
 
4269
4137
  // src/sdk-meta.ts
4270
4138
  var SDK_NAME = "@rasputin-ai/node";
4271
- var SDK_VERSION = "0.9.0";
4139
+ var SDK_VERSION = "0.10.0";
4272
4140
 
4273
4141
  // src/rasputin-init.ts
4274
4142
  var publicExecution = (runtime) => ({
@@ -4330,6 +4198,7 @@ var RasputinInit = (options) => {
4330
4198
  sdkVersion: SDK_VERSION,
4331
4199
  sdkName: SDK_NAME,
4332
4200
  installTransportSignalHandlers: options.installTransportSignalHandlers,
4201
+ redactKeys: copyRedactKeys(options.executionRecorder?.redactKeys),
4333
4202
  resolveObservation: (observation) => runtime.getErrorState(observation)
4334
4203
  });
4335
4204
  if (enabled) {