@rasputin-ai/node 0.16.0 → 1.0.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.
Files changed (33) hide show
  1. package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts.map +1 -1
  2. package/dist/auto-instrumentation/schedule-instrumentation-manifest-upload.d.ts.map +1 -1
  3. package/dist/create-rasputin-runtime.d.ts +72 -0
  4. package/dist/create-rasputin-runtime.d.ts.map +1 -0
  5. package/dist/execution-metrics/encode-execution-metrics-upload.d.ts.map +1 -1
  6. package/dist/execution-metrics/execution-metrics-collector.d.ts +3 -3
  7. package/dist/execution-metrics/execution-metrics-collector.d.ts.map +1 -1
  8. package/dist/execution-recorder/adaptive-recording-options.d.ts +3 -0
  9. package/dist/execution-recorder/adaptive-recording-options.d.ts.map +1 -1
  10. package/dist/execution-recorder/bind-adaptive-recorder.d.ts.map +1 -1
  11. package/dist/execution-recorder/execution-journal.d.ts +16 -1
  12. package/dist/execution-recorder/execution-journal.d.ts.map +1 -1
  13. package/dist/execution-recorder/execution-recorder-types.d.ts +18 -13
  14. package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
  15. package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
  16. package/dist/execution-recorder/execution-recording-sync.d.ts +0 -1
  17. package/dist/execution-recorder/execution-recording-sync.d.ts.map +1 -1
  18. package/dist/execution-recorder/runtime-state-size-budget.d.ts +3 -3
  19. package/dist/execution-recorder/runtime-state-size-budget.d.ts.map +1 -1
  20. package/dist/function-metrics/create-metrics-only-runtime.d.ts.map +1 -1
  21. package/dist/function-metrics/function-metrics-collector.d.ts.map +1 -1
  22. package/dist/index.js +878 -412
  23. package/dist/instrument/build.js +211 -355
  24. package/dist/instrument/bun.js +135 -246
  25. package/dist/instrument/node.js +135 -246
  26. package/dist/internal.d.ts +2 -0
  27. package/dist/internal.d.ts.map +1 -1
  28. package/dist/internal.js +983 -341
  29. package/dist/rasputin-init.d.ts +7 -60
  30. package/dist/rasputin-init.d.ts.map +1 -1
  31. package/dist/sdk-meta.d.ts +1 -1
  32. package/dist/sdk-meta.d.ts.map +1 -1
  33. package/package.json +3 -3
@@ -31,7 +31,8 @@ var registerFunctionMetricDeclarations = (declarations) => {
31
31
  import { resolve } from "node:path";
32
32
  import {
33
33
  INSTRUMENTATION_MANIFEST_SCHEMA_VERSION,
34
- sourceLocatorFromFile as sourceLocatorFromFile2
34
+ sourceLocatorFromFile as sourceLocatorFromFile2,
35
+ sourceLocatorKey
35
36
  } from "@rasputin-ai/core";
36
37
 
37
38
  // ../recorder/src/encoded-function-plan.ts
@@ -71,7 +72,7 @@ var encodeFunctionPlan = (source) => {
71
72
  var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
72
73
 
73
74
  // src/auto-instrumentation/instrumentation-manifest-registry.ts
74
- var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.v3";
75
+ var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.v4";
75
76
  var registrySymbol = Symbol.for(INSTRUMENTATION_MANIFEST_SYMBOL);
76
77
  var getRegistry2 = () => {
77
78
  const existing = Reflect.get(globalThis, registrySymbol);
@@ -146,9 +147,6 @@ import { homedir } from "node:os";
146
147
  import { dirname as dirname2, join as join2 } from "node:path";
147
148
  import { sourceLocatorFromFile as sourceLocatorFromFile4 } from "@rasputin-ai/core";
148
149
 
149
- // ../instrumentation/src/classify-function.ts
150
- import ts3 from "typescript";
151
-
152
150
  // ../instrumentation/src/collect-instrumentation-delta.ts
153
151
  import ts from "typescript";
154
152
  var paramBindingFromName = (name, sourceFile) => {
@@ -217,91 +215,6 @@ var mappedLocation = (sourceFile, position, absolutePath, mapLocation) => {
217
215
  };
218
216
  return mapLocation ? mapLocation(raw) : raw;
219
217
  };
220
- var unwrapExpression = (expression) => {
221
- let current = expression;
222
- while (ts.isParenthesizedExpression(current) || ts.isNonNullExpression(current)) {
223
- current = current.expression;
224
- }
225
- if (ts.isAwaitExpression(current)) return unwrapExpression(current.expression);
226
- return current;
227
- };
228
- var calleeFromExpression = (expression, sourceFile) => {
229
- const current = unwrapExpression(expression);
230
- if (ts.isIdentifier(current)) {
231
- return { calleeName: current.text, calleeText: current.text };
232
- }
233
- if (ts.isPropertyAccessExpression(current) && ts.isIdentifier(current.name)) {
234
- return {
235
- calleeName: current.name.text,
236
- calleeText: current.getText(sourceFile).replace(/\s+/g, "")
237
- };
238
- }
239
- return null;
240
- };
241
- var resultBindingForCall = (call) => {
242
- let node = call.parent;
243
- if (ts.isAwaitExpression(node)) node = node.parent;
244
- if (!ts.isVariableDeclaration(node)) return null;
245
- if (!ts.isIdentifier(node.name)) return null;
246
- const initializer = node.initializer;
247
- if (!initializer) return null;
248
- const inner = unwrapExpression(initializer);
249
- if (inner !== call) return null;
250
- return node.name.text;
251
- };
252
- var argIdentifiersForCall = (call) => {
253
- const identifiers = [];
254
- call.arguments?.forEach((argument, index) => {
255
- if (ts.isIdentifier(argument)) {
256
- identifiers.push({ index, kind: "identifier", name: argument.text });
257
- return;
258
- }
259
- if (!ts.isObjectLiteralExpression(argument)) return;
260
- const properties = [];
261
- for (const property of argument.properties) {
262
- if (ts.isShorthandPropertyAssignment(property)) {
263
- properties.push({ key: property.name.text, name: property.name.text });
264
- continue;
265
- }
266
- if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) && ts.isIdentifier(property.initializer)) {
267
- properties.push({ key: property.name.text, name: property.initializer.text });
268
- }
269
- }
270
- if (properties.length > 0) {
271
- identifiers.push({ index, kind: "object", properties });
272
- }
273
- });
274
- return identifiers;
275
- };
276
- var collectCallSite = (call, caller, context) => {
277
- const callee = calleeFromExpression(call.expression, context.sourceFile);
278
- if (!callee) return null;
279
- const start = mappedLocation(
280
- context.sourceFile,
281
- call.getStart(context.sourceFile),
282
- context.absolutePath,
283
- context.mapLocation
284
- );
285
- const end = mappedLocation(
286
- context.sourceFile,
287
- call.end,
288
- context.absolutePath,
289
- context.mapLocation
290
- );
291
- if (!start || !end) return null;
292
- return {
293
- callerFunctionId: caller.functionId,
294
- calleeName: callee.calleeName,
295
- calleeText: callee.calleeText,
296
- filePath: start.filePath,
297
- line: start.line,
298
- column: start.column,
299
- endLine: end.line,
300
- endColumn: end.column,
301
- resultBinding: resultBindingForCall(call),
302
- argIdentifiers: argIdentifiersForCall(call)
303
- };
304
- };
305
218
  var collectParamDestructure = (declaration, caller, context) => {
306
219
  if (!declaration.initializer || !ts.isIdentifier(declaration.initializer)) return null;
307
220
  if (!ts.isObjectBindingPattern(declaration.name) && !ts.isArrayBindingPattern(declaration.name)) {
@@ -326,9 +239,6 @@ var collectParamDestructure = (declaration, caller, context) => {
326
239
  };
327
240
  };
328
241
 
329
- // ../instrumentation/src/parse-source.ts
330
- import ts2 from "typescript";
331
-
332
242
  // ../instrumentation/src/edits.ts
333
243
  var isIdentContinue = (code) => code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
334
244
  var isIdentStart = (code) => code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
@@ -751,9 +661,43 @@ var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) =
751
661
  ` : `${withoutUpstream}${comment}`;
752
662
  };
753
663
 
754
- // ../instrumentation/src/browser-function-edits.ts
755
- import { propertyNameIsSensitive } from "@rasputin-ai/core";
756
- import ts10 from "typescript";
664
+ // ../instrumentation/src/parameter-initializer-may-run-code.ts
665
+ import ts2 from "typescript";
666
+ var unwrap = (expression) => {
667
+ let current = expression;
668
+ while (ts2.isParenthesizedExpression(current) || ts2.isNonNullExpression(current)) {
669
+ current = current.expression;
670
+ }
671
+ return current;
672
+ };
673
+ var isSafeLiteralInitializer = (expression) => {
674
+ const current = unwrap(expression);
675
+ if (ts2.isNumericLiteral(current) || ts2.isStringLiteral(current) || ts2.isNoSubstitutionTemplateLiteral(current) || ts2.isBigIntLiteral(current)) {
676
+ return true;
677
+ }
678
+ if (current.kind === ts2.SyntaxKind.TrueKeyword || current.kind === ts2.SyntaxKind.FalseKeyword || current.kind === ts2.SyntaxKind.NullKeyword) {
679
+ return true;
680
+ }
681
+ if (ts2.isIdentifier(current) && current.text === "undefined") return true;
682
+ if (ts2.isPrefixUnaryExpression(current) && (current.operator === ts2.SyntaxKind.PlusToken || current.operator === ts2.SyntaxKind.MinusToken)) {
683
+ return ts2.isNumericLiteral(unwrap(current.operand));
684
+ }
685
+ return false;
686
+ };
687
+ var functionHasPreBodyParameterEvaluation = (node) => {
688
+ for (const parameter of node.parameters) {
689
+ if (ts2.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
690
+ if (!parameter.initializer) continue;
691
+ if (!isSafeLiteralInitializer(parameter.initializer)) return true;
692
+ }
693
+ return false;
694
+ };
695
+
696
+ // ../instrumentation/src/parse-source.ts
697
+ import ts3 from "typescript";
698
+
699
+ // ../instrumentation/src/source-map-location.ts
700
+ import { originalPositionFor as originalPositionFor2, TraceMap as TraceMap3 } from "@jridgewell/trace-mapping";
757
701
 
758
702
  // ../instrumentation/src/suspension-whitelist.ts
759
703
  import ts4 from "typescript";
@@ -884,7 +828,7 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
884
828
 
885
829
  // ../instrumentation/src/transform-source.ts
886
830
  import { basename, resolve as resolve3 } from "node:path";
887
- import ts9 from "typescript";
831
+ import ts8 from "typescript";
888
832
 
889
833
  // ../instrumentation/src/function-metric-declarations.ts
890
834
  import {
@@ -1138,57 +1082,25 @@ var collectFunctionMetricDeclarations = (input) => {
1138
1082
  return declarations;
1139
1083
  };
1140
1084
 
1141
- // ../instrumentation/src/parameter-initializer-may-run-code.ts
1142
- import ts6 from "typescript";
1143
- var unwrap = (expression) => {
1144
- let current = expression;
1145
- while (ts6.isParenthesizedExpression(current) || ts6.isNonNullExpression(current)) {
1146
- current = current.expression;
1147
- }
1148
- return current;
1149
- };
1150
- var isSafeLiteralInitializer = (expression) => {
1151
- const current = unwrap(expression);
1152
- if (ts6.isNumericLiteral(current) || ts6.isStringLiteral(current) || ts6.isNoSubstitutionTemplateLiteral(current) || ts6.isBigIntLiteral(current)) {
1153
- return true;
1154
- }
1155
- if (current.kind === ts6.SyntaxKind.TrueKeyword || current.kind === ts6.SyntaxKind.FalseKeyword || current.kind === ts6.SyntaxKind.NullKeyword) {
1156
- return true;
1157
- }
1158
- if (ts6.isIdentifier(current) && current.text === "undefined") return true;
1159
- if (ts6.isPrefixUnaryExpression(current) && (current.operator === ts6.SyntaxKind.PlusToken || current.operator === ts6.SyntaxKind.MinusToken)) {
1160
- return ts6.isNumericLiteral(unwrap(current.operand));
1161
- }
1162
- return false;
1163
- };
1164
- var functionHasPreBodyParameterEvaluation = (node) => {
1165
- for (const parameter of node.parameters) {
1166
- if (ts6.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
1167
- if (!parameter.initializer) continue;
1168
- if (!isSafeLiteralInitializer(parameter.initializer)) return true;
1169
- }
1170
- return false;
1171
- };
1172
-
1173
1085
  // ../instrumentation/src/verify-instrumentation-isomorphism.ts
1174
- import ts7 from "typescript";
1086
+ import ts6 from "typescript";
1175
1087
  var RASPUTIN_IDENT = /^__rasputin/;
1176
1088
  var scriptKindFor = (filePath) => {
1177
- if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
1178
- if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
1179
- if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
1180
- return ts7.ScriptKind.JS;
1089
+ if (/\.tsx$/i.test(filePath)) return ts6.ScriptKind.TSX;
1090
+ if (/\.jsx$/i.test(filePath)) return ts6.ScriptKind.JSX;
1091
+ if (/\.[cm]?ts$/i.test(filePath)) return ts6.ScriptKind.TS;
1092
+ return ts6.ScriptKind.JS;
1181
1093
  };
1182
- var parse = (filePath, source) => ts7.createSourceFile(filePath, source, ts7.ScriptTarget.Latest, true, scriptKindFor(filePath));
1094
+ var parse = (filePath, source) => ts6.createSourceFile(filePath, source, ts6.ScriptTarget.Latest, true, scriptKindFor(filePath));
1183
1095
  var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
1184
1096
  var identText = (node) => {
1185
- if (ts7.isIdentifier(node)) return node.text;
1186
- if (ts7.isPrivateIdentifier(node)) return node.text;
1097
+ if (ts6.isIdentifier(node)) return node.text;
1098
+ if (ts6.isPrivateIdentifier(node)) return node.text;
1187
1099
  return void 0;
1188
1100
  };
1189
1101
  var calleeName = (expression) => {
1190
- if (ts7.isIdentifier(expression)) return expression.text;
1191
- if (ts7.isPropertyAccessExpression(expression)) {
1102
+ if (ts6.isIdentifier(expression)) return expression.text;
1103
+ if (ts6.isPropertyAccessExpression(expression)) {
1192
1104
  const object = identText(expression.expression);
1193
1105
  const property = identText(expression.name);
1194
1106
  if (object && isRasputinName(object) && property) return `${object}.${property}`;
@@ -1196,7 +1108,7 @@ var calleeName = (expression) => {
1196
1108
  return void 0;
1197
1109
  };
1198
1110
  var isRasputinCall = (node, methods) => {
1199
- if (!ts7.isCallExpression(node)) return false;
1111
+ if (!ts6.isCallExpression(node)) return false;
1200
1112
  const name = calleeName(node.expression);
1201
1113
  if (!name) return false;
1202
1114
  if (isRasputinName(name)) return !methods || methods.has(name.split(".")[1] ?? "");
@@ -1206,20 +1118,20 @@ var unwrapCall = (node) => {
1206
1118
  let current = node;
1207
1119
  while (isRasputinCall(current) && current.arguments.length === 1 && current.arguments[0]) {
1208
1120
  current = current.arguments[0];
1209
- if (ts7.isParenthesizedExpression(current)) current = current.expression;
1121
+ if (ts6.isParenthesizedExpression(current)) current = current.expression;
1210
1122
  }
1211
- if (ts7.isParenthesizedExpression(current)) return current.expression;
1123
+ if (ts6.isParenthesizedExpression(current)) return current.expression;
1212
1124
  return current;
1213
1125
  };
1214
1126
  var isRasputinStatement = (node) => {
1215
- if (ts7.isEmptyStatement(node)) return true;
1216
- if (ts7.isVariableStatement(node)) {
1127
+ if (ts6.isEmptyStatement(node)) return true;
1128
+ if (ts6.isVariableStatement(node)) {
1217
1129
  return node.declarationList.declarations.every((declaration) => {
1218
1130
  const name = identText(declaration.name);
1219
1131
  return Boolean(name && isRasputinName(name));
1220
1132
  });
1221
1133
  }
1222
- if (ts7.isExpressionStatement(node)) {
1134
+ if (ts6.isExpressionStatement(node)) {
1223
1135
  if (!isRasputinCall(node.expression)) return false;
1224
1136
  const unwrapped = unwrapCall(node.expression);
1225
1137
  return unwrapped === node.expression;
@@ -1233,7 +1145,7 @@ var isRasputinTryWrapper = (node) => {
1233
1145
  (statement) => !isRasputinStatement(statement)
1234
1146
  );
1235
1147
  const leftover = catchCalls[0];
1236
- const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts7.isThrowStatement(leftover) && ts7.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
1148
+ const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts6.isThrowStatement(leftover) && ts6.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
1237
1149
  if (!leftoverThrow && catchCalls.length > 0) return false;
1238
1150
  return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
1239
1151
  };
@@ -1241,7 +1153,7 @@ var flattenStatements = (statements) => {
1241
1153
  const flattened = [];
1242
1154
  for (const statement of statements) {
1243
1155
  if (isRasputinStatement(statement)) continue;
1244
- if (ts7.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
1156
+ if (ts6.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
1245
1157
  flattened.push(...flattenStatements(statement.tryBlock.statements));
1246
1158
  continue;
1247
1159
  }
@@ -1250,38 +1162,38 @@ var flattenStatements = (statements) => {
1250
1162
  return flattened;
1251
1163
  };
1252
1164
  var extra = (node) => {
1253
- if (ts7.isIdentifier(node) || ts7.isPrivateIdentifier(node)) {
1165
+ if (ts6.isIdentifier(node) || ts6.isPrivateIdentifier(node)) {
1254
1166
  return isRasputinName(node.text) ? "" : node.text;
1255
1167
  }
1256
- if (ts7.isStringLiteral(node) || ts7.isNumericLiteral(node) || ts7.isNoSubstitutionTemplateLiteral(node)) {
1168
+ if (ts6.isStringLiteral(node) || ts6.isNumericLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
1257
1169
  return node.text;
1258
1170
  }
1259
- if (ts7.isToken(node) && !ts7.isIdentifier(node)) return ts7.SyntaxKind[node.kind] ?? "";
1171
+ if (ts6.isToken(node) && !ts6.isIdentifier(node)) return ts6.SyntaxKind[node.kind] ?? "";
1260
1172
  return "";
1261
1173
  };
1262
1174
  var signatureOf = (node) => {
1263
1175
  const unwrapped = unwrapCall(node);
1264
1176
  if (unwrapped !== node) return signatureOf(unwrapped);
1265
- if (ts7.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
1266
- if (ts7.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
1177
+ if (ts6.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
1178
+ if (ts6.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
1267
1179
  return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
1268
1180
  }
1269
- if (ts7.isBlock(unwrapped)) {
1181
+ if (ts6.isBlock(unwrapped)) {
1270
1182
  const statements = flattenStatements(unwrapped.statements);
1271
1183
  return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
1272
1184
  }
1273
- if (ts7.isCatchClause(unwrapped)) {
1185
+ if (ts6.isCatchClause(unwrapped)) {
1274
1186
  const statements = flattenStatements(unwrapped.block.statements);
1275
1187
  const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
1276
1188
  return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
1277
1189
  }
1278
- if (ts7.isArrowFunction(unwrapped) && ts7.isBlock(unwrapped.body)) {
1190
+ if (ts6.isArrowFunction(unwrapped) && ts6.isBlock(unwrapped.body)) {
1279
1191
  const statements = flattenStatements(unwrapped.body.statements);
1280
1192
  const only = statements[0];
1281
- if (statements.length === 1 && only && ts7.isReturnStatement(only) && only.expression) {
1193
+ if (statements.length === 1 && only && ts6.isReturnStatement(only) && only.expression) {
1282
1194
  const expression = only.expression;
1283
1195
  const parts2 = [];
1284
- ts7.forEachChild(unwrapped, (child) => {
1196
+ ts6.forEachChild(unwrapped, (child) => {
1285
1197
  if (child === unwrapped.body) {
1286
1198
  const part2 = signatureOf(expression);
1287
1199
  if (part2) parts2.push(part2);
@@ -1294,11 +1206,11 @@ var signatureOf = (node) => {
1294
1206
  }
1295
1207
  }
1296
1208
  const parts = [];
1297
- ts7.forEachChild(unwrapped, (child) => {
1209
+ ts6.forEachChild(unwrapped, (child) => {
1298
1210
  const part = signatureOf(child);
1299
1211
  if (part) parts.push(part);
1300
1212
  });
1301
- const kind = ts7.SyntaxKind[unwrapped.kind] ?? "Node";
1213
+ const kind = ts6.SyntaxKind[unwrapped.kind] ?? "Node";
1302
1214
  const label = extra(unwrapped);
1303
1215
  return `${kind}${label}[${parts.join(",")}]`;
1304
1216
  };
@@ -1307,14 +1219,14 @@ var instrumentationTreesAreIsomorphic = (filePath, original, transformed) => {
1307
1219
  };
1308
1220
 
1309
1221
  // ../instrumentation/src/verify-transformed-source.ts
1310
- import ts8 from "typescript";
1311
- var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1222
+ import ts7 from "typescript";
1223
+ var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
1312
1224
  compilerOptions: {
1313
1225
  // ES2020 downlevel keeps native @decorators out of `new Function`.
1314
- target: ts8.ScriptTarget.ES2020,
1315
- module: ts8.ModuleKind.ESNext,
1226
+ target: ts7.ScriptTarget.ES2020,
1227
+ module: ts7.ModuleKind.ESNext,
1316
1228
  allowJs: true,
1317
- jsx: ts8.JsxEmit.React,
1229
+ jsx: ts7.JsxEmit.React,
1318
1230
  experimentalDecorators: true
1319
1231
  },
1320
1232
  reportDiagnostics: true,
@@ -1322,7 +1234,7 @@ var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1322
1234
  });
1323
1235
  var hasScanOrParseError = (diagnostics) => Boolean(
1324
1236
  diagnostics?.some(
1325
- (diagnostic) => diagnostic.category === ts8.DiagnosticCategory.Error && diagnostic.code < 2e3
1237
+ (diagnostic) => diagnostic.category === ts7.DiagnosticCategory.Error && diagnostic.code < 2e3
1326
1238
  )
1327
1239
  );
1328
1240
  var scriptBodyForEngine = (emitted) => (
@@ -1331,39 +1243,39 @@ var scriptBodyForEngine = (emitted) => (
1331
1243
  );
1332
1244
  var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
1333
1245
  var scriptKindFor2 = (filePath) => {
1334
- if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1335
- if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1336
- if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1337
- return ts8.ScriptKind.JS;
1246
+ if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
1247
+ if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
1248
+ if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
1249
+ return ts7.ScriptKind.JS;
1338
1250
  };
1339
- var isIterationStatement = (node) => ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
1251
+ var isIterationStatement = (node) => ts7.isForStatement(node) || ts7.isForOfStatement(node) || ts7.isForInStatement(node) || ts7.isWhileStatement(node) || ts7.isDoStatement(node);
1340
1252
  var unwrapLabeled = (node) => {
1341
1253
  let current = node;
1342
- while (ts8.isLabeledStatement(current)) current = current.statement;
1254
+ while (ts7.isLabeledStatement(current)) current = current.statement;
1343
1255
  return current;
1344
1256
  };
1345
1257
  var hasInvalidLabelJump = (sourceFile) => {
1346
1258
  const visit = (node, labels) => {
1347
- if (ts8.isFunctionLike(node)) {
1259
+ if (ts7.isFunctionLike(node)) {
1348
1260
  let nestedInvalid = false;
1349
- ts8.forEachChild(node, (child) => {
1261
+ ts7.forEachChild(node, (child) => {
1350
1262
  if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
1351
1263
  });
1352
1264
  return nestedInvalid;
1353
1265
  }
1354
- if (ts8.isLabeledStatement(node)) {
1266
+ if (ts7.isLabeledStatement(node)) {
1355
1267
  const next = new Map(labels);
1356
1268
  next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
1357
1269
  return visit(node.statement, next);
1358
1270
  }
1359
- if (ts8.isContinueStatement(node) && node.label) {
1271
+ if (ts7.isContinueStatement(node) && node.label) {
1360
1272
  if (labels.get(node.label.text) !== true) return true;
1361
1273
  }
1362
- if (ts8.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1274
+ if (ts7.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1363
1275
  return true;
1364
1276
  }
1365
1277
  let invalid = false;
1366
- ts8.forEachChild(node, (child) => {
1278
+ ts7.forEachChild(node, (child) => {
1367
1279
  if (visit(child, labels)) invalid = true;
1368
1280
  });
1369
1281
  return invalid;
@@ -1406,10 +1318,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
1406
1318
  var transformedSourceIsInvalid = (filePath, code) => {
1407
1319
  if (GLUED_INSTRUMENTATION.test(code)) return true;
1408
1320
  if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
1409
- const sourceFile = ts8.createSourceFile(
1321
+ const sourceFile = ts7.createSourceFile(
1410
1322
  filePath,
1411
1323
  code,
1412
- ts8.ScriptTarget.Latest,
1324
+ ts7.ScriptTarget.Latest,
1413
1325
  true,
1414
1326
  scriptKindFor2(filePath)
1415
1327
  );
@@ -1430,25 +1342,25 @@ var alreadyInstrumentedResult = (source) => ({
1430
1342
  delta: { functions: [], callSites: [], destructures: [], alreadyInstrumented: true }
1431
1343
  });
1432
1344
  var scriptKindFor3 = (filePath) => {
1433
- if (/\.tsx$/i.test(filePath)) return ts9.ScriptKind.TSX;
1434
- if (/\.jsx$/i.test(filePath)) return ts9.ScriptKind.JSX;
1435
- if (/\.[cm]?ts$/i.test(filePath)) return ts9.ScriptKind.TS;
1436
- return ts9.ScriptKind.JS;
1345
+ if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1346
+ if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1347
+ if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1348
+ return ts8.ScriptKind.JS;
1437
1349
  };
1438
1350
  var functionName = (node, sourceFile) => {
1439
- if (ts9.isConstructorDeclaration(node)) return "constructor";
1351
+ if (ts8.isConstructorDeclaration(node)) return "constructor";
1440
1352
  if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
1441
1353
  const parent = node.parent;
1442
- if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name)) return parent.name.text;
1443
- if (ts9.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1444
- if (ts9.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1354
+ if (ts8.isVariableDeclaration(parent) && ts8.isIdentifier(parent.name)) return parent.name.text;
1355
+ if (ts8.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1356
+ if (ts8.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1445
1357
  const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
1446
1358
  return `anonymous@${location.line + 1}:${location.character + 1}`;
1447
1359
  };
1448
1360
  var functionLocationPosition = (node, sourceFile) => {
1449
1361
  if (node.name) return node.name.getStart(sourceFile);
1450
1362
  const parent = node.parent;
1451
- if ((ts9.isVariableDeclaration(parent) || ts9.isPropertyAssignment(parent)) && parent.name) {
1363
+ if ((ts8.isVariableDeclaration(parent) || ts8.isPropertyAssignment(parent)) && parent.name) {
1452
1364
  return parent.name.getStart(sourceFile);
1453
1365
  }
1454
1366
  return node.getStart(sourceFile);
@@ -1461,12 +1373,12 @@ var functionBodyPrologueEnd = (body, sourceFile) => {
1461
1373
  }
1462
1374
  return end;
1463
1375
  };
1464
- var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
1376
+ var isStaticPropertyName = (name) => ts8.isIdentifier(name) || ts8.isStringLiteral(name) || ts8.isNoSubstitutionTemplateLiteral(name) || ts8.isNumericLiteral(name);
1465
1377
  var canReconstructBinding = (name) => {
1466
- if (ts9.isIdentifier(name)) return true;
1467
- if (ts9.isArrayBindingPattern(name)) {
1378
+ if (ts8.isIdentifier(name)) return true;
1379
+ if (ts8.isArrayBindingPattern(name)) {
1468
1380
  return name.elements.every(
1469
- (element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
1381
+ (element) => ts8.isOmittedExpression(element) || canReconstructBinding(element.name)
1470
1382
  );
1471
1383
  }
1472
1384
  return name.elements.every((element) => {
@@ -1475,10 +1387,10 @@ var canReconstructBinding = (name) => {
1475
1387
  });
1476
1388
  };
1477
1389
  var bindingValue = (name, sourceFile) => {
1478
- if (ts9.isIdentifier(name)) return name.text;
1479
- if (ts9.isArrayBindingPattern(name)) {
1390
+ if (ts8.isIdentifier(name)) return name.text;
1391
+ if (ts8.isArrayBindingPattern(name)) {
1480
1392
  const values = name.elements.map((element) => {
1481
- if (ts9.isOmittedExpression(element)) return "";
1393
+ if (ts8.isOmittedExpression(element)) return "";
1482
1394
  const value = bindingValue(element.name, sourceFile);
1483
1395
  return element.dotDotDotToken ? `...${value}` : value;
1484
1396
  });
@@ -1488,7 +1400,7 @@ var bindingValue = (name, sourceFile) => {
1488
1400
  const value = bindingValue(element.name, sourceFile);
1489
1401
  if (element.dotDotDotToken) return `...${value}`;
1490
1402
  if (!element.propertyName) return value;
1491
- const key = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1403
+ const key = ts8.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1492
1404
  return `${key}:${value}`;
1493
1405
  });
1494
1406
  return `{${properties.join(",")}}`;
@@ -1496,7 +1408,7 @@ var bindingValue = (name, sourceFile) => {
1496
1408
  var arrowArgsCapture = (node) => {
1497
1409
  const sourceFile = node.getSourceFile();
1498
1410
  const params = node.parameters.filter(
1499
- (parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
1411
+ (parameter) => !(ts8.isIdentifier(parameter.name) && parameter.name.text === "this")
1500
1412
  );
1501
1413
  if (!params.every((parameter) => canReconstructBinding(parameter.name))) {
1502
1414
  return {
@@ -1511,13 +1423,13 @@ var arrowArgsCapture = (node) => {
1511
1423
  return { args: `[${values.join(",")}]`, omitValues: false };
1512
1424
  };
1513
1425
  var isSupportedFunction = (node) => {
1514
- if (!ts9.isFunctionDeclaration(node) && !ts9.isFunctionExpression(node) && !ts9.isArrowFunction(node) && !ts9.isMethodDeclaration(node) && !ts9.isGetAccessorDeclaration(node) && !ts9.isSetAccessorDeclaration(node)) {
1426
+ if (!ts8.isFunctionDeclaration(node) && !ts8.isFunctionExpression(node) && !ts8.isArrowFunction(node) && !ts8.isMethodDeclaration(node) && !ts8.isGetAccessorDeclaration(node) && !ts8.isSetAccessorDeclaration(node)) {
1515
1427
  return false;
1516
1428
  }
1517
1429
  if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
1518
1430
  return true;
1519
1431
  };
1520
- var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
1432
+ var isDirectivePrologue = (statement) => ts8.isExpressionStatement(statement) && ts8.isStringLiteral(statement.expression);
1521
1433
  var insertPositionAfterPrologue = (source, sourceFile) => {
1522
1434
  const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
1523
1435
  let end = shebangEnd;
@@ -1568,7 +1480,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
1568
1480
  const end = functionBodyPrologueEnd(body, sourceFile);
1569
1481
  for (const statement of body.statements) {
1570
1482
  if (isDirectivePrologue(statement)) continue;
1571
- if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
1483
+ if (ts8.isExpressionStatement(statement) && ts8.isCallExpression(statement.expression) && statement.expression.expression.kind === ts8.SyntaxKind.SuperKeyword) {
1572
1484
  return statement.end;
1573
1485
  }
1574
1486
  break;
@@ -1579,15 +1491,15 @@ var failEpilogue = (handleName, errorName, args, restoreOnCatch) => `}catch(${er
1579
1491
  var walkOwnBody = (node, visitNode) => {
1580
1492
  if (!node.body) return;
1581
1493
  const visit = (candidate) => {
1582
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1494
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1583
1495
  visitNode(candidate);
1584
- ts9.forEachChild(candidate, visit);
1496
+ ts8.forEachChild(candidate, visit);
1585
1497
  };
1586
1498
  visit(node.body);
1587
1499
  };
1588
1500
  var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1589
1501
  walkOwnBody(node, (candidate) => {
1590
- if (!ts9.isAwaitExpression(candidate)) return;
1502
+ if (!ts8.isAwaitExpression(candidate)) return;
1591
1503
  wrap(
1592
1504
  edits,
1593
1505
  candidate.expression.getStart(sourceFile),
@@ -1608,7 +1520,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1608
1520
  };
1609
1521
  var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
1610
1522
  walkOwnBody(node, (candidate) => {
1611
- if (!ts9.isTryStatement(candidate)) return;
1523
+ if (!ts8.isTryStatement(candidate)) return;
1612
1524
  const blocks = [candidate.catchClause?.block, candidate.finallyBlock];
1613
1525
  for (const block of blocks) {
1614
1526
  if (!block) continue;
@@ -1624,10 +1536,10 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
1624
1536
  });
1625
1537
  };
1626
1538
  var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1627
- if (!node.body || !ts9.isBlock(node.body)) return;
1539
+ if (!node.body || !ts8.isBlock(node.body)) return;
1628
1540
  const visit = (candidate, at) => {
1629
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1630
- if (ts9.isReturnStatement(candidate) && candidate.expression) {
1541
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1542
+ if (ts8.isReturnStatement(candidate) && candidate.expression) {
1631
1543
  const expression = candidate.expression;
1632
1544
  wrap(
1633
1545
  edits,
@@ -1639,17 +1551,17 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1639
1551
  );
1640
1552
  return;
1641
1553
  }
1642
- ts9.forEachChild(candidate, (child) => visit(child, at + 1));
1554
+ ts8.forEachChild(candidate, (child) => visit(child, at + 1));
1643
1555
  };
1644
1556
  visit(node.body, depth + 1);
1645
1557
  };
1646
1558
  var transformSource = (source, options) => {
1647
1559
  if (source.includes("@rasputin-ignore-file")) return void 0;
1648
1560
  if (sourceIsRasputinInstrumented(source)) return alreadyInstrumentedResult(source);
1649
- const sourceFile = ts9.createSourceFile(
1561
+ const sourceFile = ts8.createSourceFile(
1650
1562
  options.filePath,
1651
1563
  source,
1652
- ts9.ScriptTarget.Latest,
1564
+ ts8.ScriptTarget.Latest,
1653
1565
  true,
1654
1566
  scriptKindFor3(options.filePath)
1655
1567
  );
@@ -1713,7 +1625,7 @@ var transformSource = (source, options) => {
1713
1625
  collected.asyncFunction = true;
1714
1626
  skipFunction(node, collected, "unsupported_async_generator");
1715
1627
  }
1716
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1628
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1717
1629
  return;
1718
1630
  }
1719
1631
  if (isSyncGeneratorLike(node) && node.body) {
@@ -1725,10 +1637,10 @@ var transformSource = (source, options) => {
1725
1637
  );
1726
1638
  if (collected)
1727
1639
  skipFunction(node, collected, "unsupported_sync_generator");
1728
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1640
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1729
1641
  return;
1730
1642
  }
1731
- if (ts9.isConstructorDeclaration(node) && node.body) {
1643
+ if (ts8.isConstructorDeclaration(node) && node.body) {
1732
1644
  const collected = collectWrappedFunction(
1733
1645
  node,
1734
1646
  sourceFile,
@@ -1737,13 +1649,13 @@ var transformSource = (source, options) => {
1737
1649
  );
1738
1650
  if (collected)
1739
1651
  skipFunction(node, collected, "unsupported_constructor");
1740
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1652
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1741
1653
  return;
1742
1654
  }
1743
1655
  if (isSupportedFunction(node)) {
1744
1656
  const collected = collectWrappedFunction(node, sourceFile, absolutePath, options.mapLocation);
1745
1657
  if (!collected) {
1746
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1658
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1747
1659
  return;
1748
1660
  }
1749
1661
  if (options.decideFunction?.({
@@ -1752,7 +1664,7 @@ var transformSource = (source, options) => {
1752
1664
  filePath: options.filePath,
1753
1665
  name: collected.name
1754
1666
  }) === "skip") {
1755
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1667
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1756
1668
  return;
1757
1669
  }
1758
1670
  const asyncFunction = isAsyncFunctionLike(node);
@@ -1760,7 +1672,7 @@ var transformSource = (source, options) => {
1760
1672
  const decision = asyncFunction ? decideAsyncInstrumentation(node, sourceFile) : { action: "inline" };
1761
1673
  if (decision.action === "skip") {
1762
1674
  skipFunction(node, collected, decision.reason);
1763
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1675
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1764
1676
  return;
1765
1677
  }
1766
1678
  if (functionHasPreBodyParameterEvaluation(node)) {
@@ -1774,29 +1686,25 @@ var transformSource = (source, options) => {
1774
1686
  });
1775
1687
  delta.functions.push(collected);
1776
1688
  rememberIdentity(node, collected);
1777
- ts9.forEachChild(node, (child) => visit(child, collected, depth + 1));
1689
+ ts8.forEachChild(node, (child) => visit(child, collected, depth + 1));
1778
1690
  return;
1779
1691
  }
1780
- if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
1781
- const site = collectCallSite(node, caller, collectContext);
1782
- if (site) delta.callSites.push(site);
1783
- }
1784
- if (caller && ts9.isVariableDeclaration(node)) {
1692
+ if (caller && ts8.isVariableDeclaration(node)) {
1785
1693
  const destructure = collectParamDestructure(node, caller, collectContext);
1786
1694
  if (destructure) delta.destructures.push(destructure);
1787
1695
  }
1788
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1696
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1789
1697
  };
1790
1698
  visit(sourceFile, void 0, 0);
1791
1699
  if (pending.length === 0) {
1792
1700
  return delta.functions.length > 0 ? withDeclarations({ code: source, delta }) : void 0;
1793
1701
  }
1794
1702
  for (const [planIndex, entry] of pending.entries()) {
1795
- const captured = ts9.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1703
+ const captured = ts8.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1796
1704
  const omitArg = captured.omitValues ? ",true" : "";
1797
1705
  const enterCall = `${runName}.enter(${planIndex},${captured.args}${omitArg})`;
1798
1706
  const epilogue = failEpilogue(handleName, errorName, captured.args, entry.suspendResume);
1799
- if (ts9.isBlock(entry.node.body)) {
1707
+ if (ts8.isBlock(entry.node.body)) {
1800
1708
  const prologueAt = insertAfterSuperOrPrologue(entry.node.body, sourceFile);
1801
1709
  const closeAt = entry.node.body.end - 1;
1802
1710
  wrap(
@@ -1885,27 +1793,8 @@ var transformSource = (source, options) => {
1885
1793
  });
1886
1794
  };
1887
1795
 
1888
- // ../instrumentation/src/json-producer-sites.ts
1889
- import ts11 from "typescript";
1890
-
1891
- // ../instrumentation/src/literal-sites.ts
1892
- import ts12 from "typescript";
1893
-
1894
- // ../instrumentation/src/observe-sites.ts
1895
- import { propertyNameIsSensitive as propertyNameIsSensitive2 } from "@rasputin-ai/core";
1896
- import ts13 from "typescript";
1897
-
1898
- // ../instrumentation/src/verify-browser-source.ts
1899
- import ts14 from "typescript";
1900
-
1901
- // ../instrumentation/src/provenance-function-edits.ts
1902
- import ts15 from "typescript";
1903
-
1904
- // ../instrumentation/src/source-map-location.ts
1905
- import { originalPositionFor as originalPositionFor2, TraceMap as TraceMap3 } from "@jridgewell/trace-mapping";
1906
-
1907
1796
  // src/sdk-meta.ts
1908
- var SDK_VERSION = "0.16.0";
1797
+ var SDK_VERSION = "1.0.0";
1909
1798
 
1910
1799
  // src/auto-instrumentation/source-map-locations.ts
1911
1800
  import { readFileSync } from "node:fs";