@rasputin-ai/node 0.6.1 → 0.7.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.
@@ -186,7 +186,7 @@ import { homedir } from "node:os";
186
186
  import { dirname as dirname2, join as join2 } from "node:path";
187
187
 
188
188
  // ../instrumentation/src/classify-function.ts
189
- import ts4 from "typescript";
189
+ import ts3 from "typescript";
190
190
 
191
191
  // ../instrumentation/src/collect-instrumentation-delta.ts
192
192
  import ts from "typescript";
@@ -368,9 +368,6 @@ var collectParamDestructure = (declaration, caller, context) => {
368
368
  // ../instrumentation/src/parse-source.ts
369
369
  import ts2 from "typescript";
370
370
 
371
- // ../instrumentation/src/svelte-generated.ts
372
- import ts3 from "typescript";
373
-
374
371
  // ../instrumentation/src/edits.ts
375
372
  var isIdentContinue = (code) => code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
376
373
  var isIdentStart = (code) => code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
@@ -418,7 +415,7 @@ var applyEdits = (source, edits) => {
418
415
  };
419
416
  var textOf = (edit) => edit.text;
420
417
 
421
- // ../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
418
+ // ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
422
419
  var comma = ",".charCodeAt(0);
423
420
  var semicolon = ";".charCodeAt(0);
424
421
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -505,7 +502,7 @@ function encode(decoded) {
505
502
  return writer.flush();
506
503
  }
507
504
 
508
- // ../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
505
+ // ../../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
509
506
  import { TraceMap as TraceMap2, decodedMappings } from "@jridgewell/trace-mapping";
510
507
  var SetArray = class {
511
508
  constructor() {
@@ -777,6 +774,11 @@ var encodeColumnMappings = (original, generated, file, edits) => {
777
774
  mappings: encoded.mappings
778
775
  };
779
776
  };
777
+ var exactTransformMap = (original, generated, file, edits) => {
778
+ const withoutUpstream = generated.replace(SOURCEMAP_COMMENT, "");
779
+ const { sources, mappings } = encodeColumnMappings(original, withoutUpstream, file, edits);
780
+ return { version: 3, file, sources, mappings };
781
+ };
780
782
  var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) => {
781
783
  const file = basenameOf(filePath);
782
784
  const withoutUpstream = generated.replace(SOURCEMAP_COMMENT, "");
@@ -790,11 +792,11 @@ var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) =
790
792
 
791
793
  // ../instrumentation/src/browser-function-edits.ts
792
794
  import { propertyNameIsSensitive } from "@rasputin-ai/core";
793
- import ts10 from "typescript";
795
+ import ts9 from "typescript";
794
796
 
795
797
  // ../instrumentation/src/suspension-whitelist.ts
796
- import ts5 from "typescript";
797
- var nodeFlags = ts5.NodeFlags;
798
+ import ts4 from "typescript";
799
+ var nodeFlags = ts4.NodeFlags;
798
800
  var AWAIT_USING_FLAG = nodeFlags.AwaitUsing ?? 0;
799
801
  var USING_FLAG = nodeFlags.Using ?? 0;
800
802
  var KNOWN_SUSPENSION_KIND_NAMES = [
@@ -804,8 +806,8 @@ var KNOWN_SUSPENSION_KIND_NAMES = [
804
806
  "YieldKeyword",
805
807
  "UsingKeyword"
806
808
  ];
807
- var isFunctionLike = (node) => ts5.isFunctionLike(node);
808
- var isAsyncFunctionLike = (node) => (ts5.getCombinedModifierFlags(node) & ts5.ModifierFlags.Async) !== 0;
809
+ var isFunctionLike = (node) => ts4.isFunctionLike(node);
810
+ var isAsyncFunctionLike = (node) => (ts4.getCombinedModifierFlags(node) & ts4.ModifierFlags.Async) !== 0;
809
811
  var isAsyncGeneratorLike = (node) => isFunctionLike(node) && isAsyncFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken);
810
812
  var isSyncGeneratorLike = (node) => isFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken) && !isAsyncFunctionLike(node);
811
813
  var visitOwnBody = (node, visitNode) => {
@@ -816,7 +818,7 @@ var visitOwnBody = (node, visitNode) => {
816
818
  return;
817
819
  }
818
820
  if (visitNode(candidate)) return;
819
- ts5.forEachChild(candidate, visit);
821
+ ts4.forEachChild(candidate, visit);
820
822
  };
821
823
  visit(node.body);
822
824
  };
@@ -844,16 +846,16 @@ var slicesOutside = (start, end, spans) => {
844
846
  };
845
847
  var sliceHasAwaitKeyword = (source, start, end) => {
846
848
  if (end <= start) return false;
847
- const scanner = ts5.createScanner(
848
- ts5.ScriptTarget.Latest,
849
+ const scanner = ts4.createScanner(
850
+ ts4.ScriptTarget.Latest,
849
851
  true,
850
- ts5.LanguageVariant.Standard,
852
+ ts4.LanguageVariant.Standard,
851
853
  source.slice(start, end)
852
854
  );
853
855
  while (true) {
854
856
  const token = scanner.scan();
855
- if (token === ts5.SyntaxKind.EndOfFileToken) return false;
856
- if (token === ts5.SyntaxKind.AwaitKeyword) return true;
857
+ if (token === ts4.SyntaxKind.EndOfFileToken) return false;
858
+ if (token === ts4.SyntaxKind.AwaitKeyword) return true;
857
859
  }
858
860
  };
859
861
  var ownBodyHasAwaitKeyword = (node, sourceFile) => {
@@ -871,7 +873,7 @@ var isAwaitUsingList = (node) => {
871
873
  return (node.flags & AWAIT_USING_FLAG) === AWAIT_USING_FLAG && (node.flags & USING_FLAG) !== 0;
872
874
  };
873
875
  var unknownSuspensionKind = (node) => {
874
- const name = ts5.SyntaxKind[node.kind];
876
+ const name = ts4.SyntaxKind[node.kind];
875
877
  if (typeof name !== "string" || !/Await|Yield|Using/.test(name)) return false;
876
878
  return !KNOWN_SUSPENSION_KIND_NAMES.includes(name);
877
879
  };
@@ -884,9 +886,9 @@ var ownSuspensionFacts = (node, sourceFile) => {
884
886
  awaitKeyword: ownBodyHasAwaitKeyword(node, sourceFile)
885
887
  };
886
888
  visitOwnBody(node, (candidate) => {
887
- if (ts5.isAwaitExpression(candidate)) facts.awaitExpressions = true;
888
- if (ts5.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
889
- if (ts5.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
889
+ if (ts4.isAwaitExpression(candidate)) facts.awaitExpressions = true;
890
+ if (ts4.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
891
+ if (ts4.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
890
892
  facts.awaitUsing = true;
891
893
  }
892
894
  if (unknownSuspensionKind(candidate)) facts.unknown = true;
@@ -897,7 +899,7 @@ var ownSuspensionFacts = (node, sourceFile) => {
897
899
  var bodyHasDirectEval = (node) => {
898
900
  let found = false;
899
901
  visitOwnBody(node, (candidate) => {
900
- if (ts5.isCallExpression(candidate) && ts5.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
902
+ if (ts4.isCallExpression(candidate) && ts4.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
901
903
  found = true;
902
904
  }
903
905
  return found;
@@ -921,34 +923,34 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
921
923
 
922
924
  // ../instrumentation/src/transform-source.ts
923
925
  import { basename, resolve as resolve4 } from "node:path";
924
- import ts9 from "typescript";
926
+ import ts8 from "typescript";
925
927
 
926
928
  // ../instrumentation/src/parameter-initializer-may-run-code.ts
927
- import ts6 from "typescript";
929
+ import ts5 from "typescript";
928
930
  var unwrap = (expression) => {
929
931
  let current = expression;
930
- while (ts6.isParenthesizedExpression(current) || ts6.isNonNullExpression(current)) {
932
+ while (ts5.isParenthesizedExpression(current) || ts5.isNonNullExpression(current)) {
931
933
  current = current.expression;
932
934
  }
933
935
  return current;
934
936
  };
935
937
  var isSafeLiteralInitializer = (expression) => {
936
938
  const current = unwrap(expression);
937
- if (ts6.isNumericLiteral(current) || ts6.isStringLiteral(current) || ts6.isNoSubstitutionTemplateLiteral(current) || ts6.isBigIntLiteral(current)) {
939
+ if (ts5.isNumericLiteral(current) || ts5.isStringLiteral(current) || ts5.isNoSubstitutionTemplateLiteral(current) || ts5.isBigIntLiteral(current)) {
938
940
  return true;
939
941
  }
940
- if (current.kind === ts6.SyntaxKind.TrueKeyword || current.kind === ts6.SyntaxKind.FalseKeyword || current.kind === ts6.SyntaxKind.NullKeyword) {
942
+ if (current.kind === ts5.SyntaxKind.TrueKeyword || current.kind === ts5.SyntaxKind.FalseKeyword || current.kind === ts5.SyntaxKind.NullKeyword) {
941
943
  return true;
942
944
  }
943
- if (ts6.isIdentifier(current) && current.text === "undefined") return true;
944
- if (ts6.isPrefixUnaryExpression(current) && (current.operator === ts6.SyntaxKind.PlusToken || current.operator === ts6.SyntaxKind.MinusToken)) {
945
- return ts6.isNumericLiteral(unwrap(current.operand));
945
+ if (ts5.isIdentifier(current) && current.text === "undefined") return true;
946
+ if (ts5.isPrefixUnaryExpression(current) && (current.operator === ts5.SyntaxKind.PlusToken || current.operator === ts5.SyntaxKind.MinusToken)) {
947
+ return ts5.isNumericLiteral(unwrap(current.operand));
946
948
  }
947
949
  return false;
948
950
  };
949
951
  var functionHasPreBodyParameterEvaluation = (node) => {
950
952
  for (const parameter of node.parameters) {
951
- if (ts6.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
953
+ if (ts5.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
952
954
  if (!parameter.initializer) continue;
953
955
  if (!isSafeLiteralInitializer(parameter.initializer)) return true;
954
956
  }
@@ -956,24 +958,24 @@ var functionHasPreBodyParameterEvaluation = (node) => {
956
958
  };
957
959
 
958
960
  // ../instrumentation/src/verify-instrumentation-isomorphism.ts
959
- import ts7 from "typescript";
961
+ import ts6 from "typescript";
960
962
  var RASPUTIN_IDENT = /^__rasputin/;
961
963
  var scriptKindFor = (filePath) => {
962
- if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
963
- if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
964
- if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
965
- return ts7.ScriptKind.JS;
964
+ if (/\.tsx$/i.test(filePath)) return ts6.ScriptKind.TSX;
965
+ if (/\.jsx$/i.test(filePath)) return ts6.ScriptKind.JSX;
966
+ if (/\.[cm]?ts$/i.test(filePath)) return ts6.ScriptKind.TS;
967
+ return ts6.ScriptKind.JS;
966
968
  };
967
- var parse = (filePath, source) => ts7.createSourceFile(filePath, source, ts7.ScriptTarget.Latest, true, scriptKindFor(filePath));
969
+ var parse = (filePath, source) => ts6.createSourceFile(filePath, source, ts6.ScriptTarget.Latest, true, scriptKindFor(filePath));
968
970
  var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
969
971
  var identText = (node) => {
970
- if (ts7.isIdentifier(node)) return node.text;
971
- if (ts7.isPrivateIdentifier(node)) return node.text;
972
+ if (ts6.isIdentifier(node)) return node.text;
973
+ if (ts6.isPrivateIdentifier(node)) return node.text;
972
974
  return void 0;
973
975
  };
974
976
  var calleeName = (expression) => {
975
- if (ts7.isIdentifier(expression)) return expression.text;
976
- if (ts7.isPropertyAccessExpression(expression)) {
977
+ if (ts6.isIdentifier(expression)) return expression.text;
978
+ if (ts6.isPropertyAccessExpression(expression)) {
977
979
  const object = identText(expression.expression);
978
980
  const property = identText(expression.name);
979
981
  if (object && isRasputinName(object) && property) return `${object}.${property}`;
@@ -981,7 +983,7 @@ var calleeName = (expression) => {
981
983
  return void 0;
982
984
  };
983
985
  var isRasputinCall = (node, methods) => {
984
- if (!ts7.isCallExpression(node)) return false;
986
+ if (!ts6.isCallExpression(node)) return false;
985
987
  const name = calleeName(node.expression);
986
988
  if (!name) return false;
987
989
  if (isRasputinName(name)) return !methods || methods.has(name.split(".")[1] ?? "");
@@ -991,20 +993,20 @@ var unwrapCall = (node) => {
991
993
  let current = node;
992
994
  while (isRasputinCall(current) && current.arguments.length === 1 && current.arguments[0]) {
993
995
  current = current.arguments[0];
994
- if (ts7.isParenthesizedExpression(current)) current = current.expression;
996
+ if (ts6.isParenthesizedExpression(current)) current = current.expression;
995
997
  }
996
- if (ts7.isParenthesizedExpression(current)) return current.expression;
998
+ if (ts6.isParenthesizedExpression(current)) return current.expression;
997
999
  return current;
998
1000
  };
999
1001
  var isRasputinStatement = (node) => {
1000
- if (ts7.isEmptyStatement(node)) return true;
1001
- if (ts7.isVariableStatement(node)) {
1002
+ if (ts6.isEmptyStatement(node)) return true;
1003
+ if (ts6.isVariableStatement(node)) {
1002
1004
  return node.declarationList.declarations.every((declaration) => {
1003
1005
  const name = identText(declaration.name);
1004
1006
  return Boolean(name && isRasputinName(name));
1005
1007
  });
1006
1008
  }
1007
- if (ts7.isExpressionStatement(node)) {
1009
+ if (ts6.isExpressionStatement(node)) {
1008
1010
  if (!isRasputinCall(node.expression)) return false;
1009
1011
  const unwrapped = unwrapCall(node.expression);
1010
1012
  return unwrapped === node.expression;
@@ -1018,7 +1020,7 @@ var isRasputinTryWrapper = (node) => {
1018
1020
  (statement) => !isRasputinStatement(statement)
1019
1021
  );
1020
1022
  const leftover = catchCalls[0];
1021
- const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts7.isThrowStatement(leftover) && ts7.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
1023
+ const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts6.isThrowStatement(leftover) && ts6.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
1022
1024
  if (!leftoverThrow && catchCalls.length > 0) return false;
1023
1025
  return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
1024
1026
  };
@@ -1026,7 +1028,7 @@ var flattenStatements = (statements) => {
1026
1028
  const flattened = [];
1027
1029
  for (const statement of statements) {
1028
1030
  if (isRasputinStatement(statement)) continue;
1029
- if (ts7.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
1031
+ if (ts6.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
1030
1032
  flattened.push(...flattenStatements(statement.tryBlock.statements));
1031
1033
  continue;
1032
1034
  }
@@ -1035,38 +1037,38 @@ var flattenStatements = (statements) => {
1035
1037
  return flattened;
1036
1038
  };
1037
1039
  var extra = (node) => {
1038
- if (ts7.isIdentifier(node) || ts7.isPrivateIdentifier(node)) {
1040
+ if (ts6.isIdentifier(node) || ts6.isPrivateIdentifier(node)) {
1039
1041
  return isRasputinName(node.text) ? "" : node.text;
1040
1042
  }
1041
- if (ts7.isStringLiteral(node) || ts7.isNumericLiteral(node) || ts7.isNoSubstitutionTemplateLiteral(node)) {
1043
+ if (ts6.isStringLiteral(node) || ts6.isNumericLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
1042
1044
  return node.text;
1043
1045
  }
1044
- if (ts7.isToken(node) && !ts7.isIdentifier(node)) return ts7.SyntaxKind[node.kind] ?? "";
1046
+ if (ts6.isToken(node) && !ts6.isIdentifier(node)) return ts6.SyntaxKind[node.kind] ?? "";
1045
1047
  return "";
1046
1048
  };
1047
1049
  var signatureOf = (node) => {
1048
1050
  const unwrapped = unwrapCall(node);
1049
1051
  if (unwrapped !== node) return signatureOf(unwrapped);
1050
- if (ts7.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
1051
- if (ts7.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
1052
+ if (ts6.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
1053
+ if (ts6.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
1052
1054
  return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
1053
1055
  }
1054
- if (ts7.isBlock(unwrapped)) {
1056
+ if (ts6.isBlock(unwrapped)) {
1055
1057
  const statements = flattenStatements(unwrapped.statements);
1056
1058
  return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
1057
1059
  }
1058
- if (ts7.isCatchClause(unwrapped)) {
1060
+ if (ts6.isCatchClause(unwrapped)) {
1059
1061
  const statements = flattenStatements(unwrapped.block.statements);
1060
1062
  const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
1061
1063
  return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
1062
1064
  }
1063
- if (ts7.isArrowFunction(unwrapped) && ts7.isBlock(unwrapped.body)) {
1065
+ if (ts6.isArrowFunction(unwrapped) && ts6.isBlock(unwrapped.body)) {
1064
1066
  const statements = flattenStatements(unwrapped.body.statements);
1065
1067
  const only = statements[0];
1066
- if (statements.length === 1 && only && ts7.isReturnStatement(only) && only.expression) {
1068
+ if (statements.length === 1 && only && ts6.isReturnStatement(only) && only.expression) {
1067
1069
  const expression = only.expression;
1068
1070
  const parts2 = [];
1069
- ts7.forEachChild(unwrapped, (child) => {
1071
+ ts6.forEachChild(unwrapped, (child) => {
1070
1072
  if (child === unwrapped.body) {
1071
1073
  const part2 = signatureOf(expression);
1072
1074
  if (part2) parts2.push(part2);
@@ -1079,11 +1081,11 @@ var signatureOf = (node) => {
1079
1081
  }
1080
1082
  }
1081
1083
  const parts = [];
1082
- ts7.forEachChild(unwrapped, (child) => {
1084
+ ts6.forEachChild(unwrapped, (child) => {
1083
1085
  const part = signatureOf(child);
1084
1086
  if (part) parts.push(part);
1085
1087
  });
1086
- const kind = ts7.SyntaxKind[unwrapped.kind] ?? "Node";
1088
+ const kind = ts6.SyntaxKind[unwrapped.kind] ?? "Node";
1087
1089
  const label = extra(unwrapped);
1088
1090
  return `${kind}${label}[${parts.join(",")}]`;
1089
1091
  };
@@ -1092,14 +1094,14 @@ var instrumentationTreesAreIsomorphic = (filePath, original, transformed) => {
1092
1094
  };
1093
1095
 
1094
1096
  // ../instrumentation/src/verify-transformed-source.ts
1095
- import ts8 from "typescript";
1096
- var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1097
+ import ts7 from "typescript";
1098
+ var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
1097
1099
  compilerOptions: {
1098
1100
  // ES2020 downlevel keeps native @decorators out of `new Function`.
1099
- target: ts8.ScriptTarget.ES2020,
1100
- module: ts8.ModuleKind.ESNext,
1101
+ target: ts7.ScriptTarget.ES2020,
1102
+ module: ts7.ModuleKind.ESNext,
1101
1103
  allowJs: true,
1102
- jsx: ts8.JsxEmit.React,
1104
+ jsx: ts7.JsxEmit.React,
1103
1105
  experimentalDecorators: true
1104
1106
  },
1105
1107
  reportDiagnostics: true,
@@ -1107,7 +1109,7 @@ var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1107
1109
  });
1108
1110
  var hasScanOrParseError = (diagnostics) => Boolean(
1109
1111
  diagnostics?.some(
1110
- (diagnostic) => diagnostic.category === ts8.DiagnosticCategory.Error && diagnostic.code < 2e3
1112
+ (diagnostic) => diagnostic.category === ts7.DiagnosticCategory.Error && diagnostic.code < 2e3
1111
1113
  )
1112
1114
  );
1113
1115
  var scriptBodyForEngine = (emitted) => (
@@ -1116,39 +1118,39 @@ var scriptBodyForEngine = (emitted) => (
1116
1118
  );
1117
1119
  var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
1118
1120
  var scriptKindFor2 = (filePath) => {
1119
- if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1120
- if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1121
- if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1122
- return ts8.ScriptKind.JS;
1121
+ if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
1122
+ if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
1123
+ if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
1124
+ return ts7.ScriptKind.JS;
1123
1125
  };
1124
- var isIterationStatement = (node) => ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
1126
+ var isIterationStatement = (node) => ts7.isForStatement(node) || ts7.isForOfStatement(node) || ts7.isForInStatement(node) || ts7.isWhileStatement(node) || ts7.isDoStatement(node);
1125
1127
  var unwrapLabeled = (node) => {
1126
1128
  let current = node;
1127
- while (ts8.isLabeledStatement(current)) current = current.statement;
1129
+ while (ts7.isLabeledStatement(current)) current = current.statement;
1128
1130
  return current;
1129
1131
  };
1130
1132
  var hasInvalidLabelJump = (sourceFile) => {
1131
1133
  const visit = (node, labels) => {
1132
- if (ts8.isFunctionLike(node)) {
1134
+ if (ts7.isFunctionLike(node)) {
1133
1135
  let nestedInvalid = false;
1134
- ts8.forEachChild(node, (child) => {
1136
+ ts7.forEachChild(node, (child) => {
1135
1137
  if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
1136
1138
  });
1137
1139
  return nestedInvalid;
1138
1140
  }
1139
- if (ts8.isLabeledStatement(node)) {
1141
+ if (ts7.isLabeledStatement(node)) {
1140
1142
  const next = new Map(labels);
1141
1143
  next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
1142
1144
  return visit(node.statement, next);
1143
1145
  }
1144
- if (ts8.isContinueStatement(node) && node.label) {
1146
+ if (ts7.isContinueStatement(node) && node.label) {
1145
1147
  if (labels.get(node.label.text) !== true) return true;
1146
1148
  }
1147
- if (ts8.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1149
+ if (ts7.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1148
1150
  return true;
1149
1151
  }
1150
1152
  let invalid = false;
1151
- ts8.forEachChild(node, (child) => {
1153
+ ts7.forEachChild(node, (child) => {
1152
1154
  if (visit(child, labels)) invalid = true;
1153
1155
  });
1154
1156
  return invalid;
@@ -1191,10 +1193,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
1191
1193
  var transformedSourceIsInvalid = (filePath, code) => {
1192
1194
  if (GLUED_INSTRUMENTATION.test(code)) return true;
1193
1195
  if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
1194
- const sourceFile = ts8.createSourceFile(
1196
+ const sourceFile = ts7.createSourceFile(
1195
1197
  filePath,
1196
1198
  code,
1197
- ts8.ScriptTarget.Latest,
1199
+ ts7.ScriptTarget.Latest,
1198
1200
  true,
1199
1201
  scriptKindFor2(filePath)
1200
1202
  );
@@ -1215,25 +1217,25 @@ var alreadyInstrumentedResult = (source) => ({
1215
1217
  delta: { functions: [], callSites: [], destructures: [], alreadyInstrumented: true }
1216
1218
  });
1217
1219
  var scriptKindFor3 = (filePath) => {
1218
- if (/\.tsx$/i.test(filePath)) return ts9.ScriptKind.TSX;
1219
- if (/\.jsx$/i.test(filePath)) return ts9.ScriptKind.JSX;
1220
- if (/\.[cm]?ts$/i.test(filePath)) return ts9.ScriptKind.TS;
1221
- return ts9.ScriptKind.JS;
1220
+ if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1221
+ if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1222
+ if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1223
+ return ts8.ScriptKind.JS;
1222
1224
  };
1223
1225
  var functionName = (node, sourceFile) => {
1224
- if (ts9.isConstructorDeclaration(node)) return "constructor";
1226
+ if (ts8.isConstructorDeclaration(node)) return "constructor";
1225
1227
  if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
1226
1228
  const parent = node.parent;
1227
- if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name)) return parent.name.text;
1228
- if (ts9.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1229
- if (ts9.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1229
+ if (ts8.isVariableDeclaration(parent) && ts8.isIdentifier(parent.name)) return parent.name.text;
1230
+ if (ts8.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1231
+ if (ts8.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1230
1232
  const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
1231
1233
  return `anonymous@${location.line + 1}:${location.character + 1}`;
1232
1234
  };
1233
1235
  var functionLocationPosition = (node, sourceFile) => {
1234
1236
  if (node.name) return node.name.getStart(sourceFile);
1235
1237
  const parent = node.parent;
1236
- if ((ts9.isVariableDeclaration(parent) || ts9.isPropertyAssignment(parent)) && parent.name) {
1238
+ if ((ts8.isVariableDeclaration(parent) || ts8.isPropertyAssignment(parent)) && parent.name) {
1237
1239
  return parent.name.getStart(sourceFile);
1238
1240
  }
1239
1241
  return node.getStart(sourceFile);
@@ -1246,12 +1248,12 @@ var functionBodyPrologueEnd = (body, sourceFile) => {
1246
1248
  }
1247
1249
  return end;
1248
1250
  };
1249
- var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
1251
+ var isStaticPropertyName = (name) => ts8.isIdentifier(name) || ts8.isStringLiteral(name) || ts8.isNoSubstitutionTemplateLiteral(name) || ts8.isNumericLiteral(name);
1250
1252
  var canReconstructBinding = (name) => {
1251
- if (ts9.isIdentifier(name)) return true;
1252
- if (ts9.isArrayBindingPattern(name)) {
1253
+ if (ts8.isIdentifier(name)) return true;
1254
+ if (ts8.isArrayBindingPattern(name)) {
1253
1255
  return name.elements.every(
1254
- (element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
1256
+ (element) => ts8.isOmittedExpression(element) || canReconstructBinding(element.name)
1255
1257
  );
1256
1258
  }
1257
1259
  return name.elements.every((element) => {
@@ -1260,10 +1262,10 @@ var canReconstructBinding = (name) => {
1260
1262
  });
1261
1263
  };
1262
1264
  var bindingValue = (name, sourceFile) => {
1263
- if (ts9.isIdentifier(name)) return name.text;
1264
- if (ts9.isArrayBindingPattern(name)) {
1265
+ if (ts8.isIdentifier(name)) return name.text;
1266
+ if (ts8.isArrayBindingPattern(name)) {
1265
1267
  const values = name.elements.map((element) => {
1266
- if (ts9.isOmittedExpression(element)) return "";
1268
+ if (ts8.isOmittedExpression(element)) return "";
1267
1269
  const value = bindingValue(element.name, sourceFile);
1268
1270
  return element.dotDotDotToken ? `...${value}` : value;
1269
1271
  });
@@ -1273,7 +1275,7 @@ var bindingValue = (name, sourceFile) => {
1273
1275
  const value = bindingValue(element.name, sourceFile);
1274
1276
  if (element.dotDotDotToken) return `...${value}`;
1275
1277
  if (!element.propertyName) return value;
1276
- const key = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1278
+ const key = ts8.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1277
1279
  return `${key}:${value}`;
1278
1280
  });
1279
1281
  return `{${properties.join(",")}}`;
@@ -1281,7 +1283,7 @@ var bindingValue = (name, sourceFile) => {
1281
1283
  var arrowArgsCapture = (node) => {
1282
1284
  const sourceFile = node.getSourceFile();
1283
1285
  const params = node.parameters.filter(
1284
- (parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
1286
+ (parameter) => !(ts8.isIdentifier(parameter.name) && parameter.name.text === "this")
1285
1287
  );
1286
1288
  if (!params.every((parameter) => canReconstructBinding(parameter.name))) {
1287
1289
  return {
@@ -1296,13 +1298,13 @@ var arrowArgsCapture = (node) => {
1296
1298
  return { args: `[${values.join(",")}]`, omitValues: false };
1297
1299
  };
1298
1300
  var isSupportedFunction = (node) => {
1299
- if (!ts9.isFunctionDeclaration(node) && !ts9.isFunctionExpression(node) && !ts9.isArrowFunction(node) && !ts9.isMethodDeclaration(node) && !ts9.isGetAccessorDeclaration(node) && !ts9.isSetAccessorDeclaration(node)) {
1301
+ if (!ts8.isFunctionDeclaration(node) && !ts8.isFunctionExpression(node) && !ts8.isArrowFunction(node) && !ts8.isMethodDeclaration(node) && !ts8.isGetAccessorDeclaration(node) && !ts8.isSetAccessorDeclaration(node)) {
1300
1302
  return false;
1301
1303
  }
1302
1304
  if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
1303
1305
  return true;
1304
1306
  };
1305
- var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
1307
+ var isDirectivePrologue = (statement) => ts8.isExpressionStatement(statement) && ts8.isStringLiteral(statement.expression);
1306
1308
  var insertPositionAfterPrologue = (source, sourceFile) => {
1307
1309
  const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
1308
1310
  let end = shebangEnd;
@@ -1353,7 +1355,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
1353
1355
  const end = functionBodyPrologueEnd(body, sourceFile);
1354
1356
  for (const statement of body.statements) {
1355
1357
  if (isDirectivePrologue(statement)) continue;
1356
- if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
1358
+ if (ts8.isExpressionStatement(statement) && ts8.isCallExpression(statement.expression) && statement.expression.expression.kind === ts8.SyntaxKind.SuperKeyword) {
1357
1359
  return statement.end;
1358
1360
  }
1359
1361
  break;
@@ -1364,15 +1366,15 @@ var failEpilogue = (handleName, errorName, args, restoreOnCatch) => `}catch(${er
1364
1366
  var walkOwnBody = (node, visitNode) => {
1365
1367
  if (!node.body) return;
1366
1368
  const visit = (candidate) => {
1367
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1369
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1368
1370
  visitNode(candidate);
1369
- ts9.forEachChild(candidate, visit);
1371
+ ts8.forEachChild(candidate, visit);
1370
1372
  };
1371
1373
  visit(node.body);
1372
1374
  };
1373
1375
  var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1374
1376
  walkOwnBody(node, (candidate) => {
1375
- if (!ts9.isAwaitExpression(candidate)) return;
1377
+ if (!ts8.isAwaitExpression(candidate)) return;
1376
1378
  wrap(
1377
1379
  edits,
1378
1380
  candidate.expression.getStart(sourceFile),
@@ -1393,7 +1395,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1393
1395
  };
1394
1396
  var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
1395
1397
  walkOwnBody(node, (candidate) => {
1396
- if (!ts9.isTryStatement(candidate)) return;
1398
+ if (!ts8.isTryStatement(candidate)) return;
1397
1399
  const blocks = [candidate.catchClause?.block, candidate.finallyBlock];
1398
1400
  for (const block of blocks) {
1399
1401
  if (!block) continue;
@@ -1409,10 +1411,10 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
1409
1411
  });
1410
1412
  };
1411
1413
  var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1412
- if (!node.body || !ts9.isBlock(node.body)) return;
1414
+ if (!node.body || !ts8.isBlock(node.body)) return;
1413
1415
  const visit = (candidate, at) => {
1414
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1415
- if (ts9.isReturnStatement(candidate) && candidate.expression) {
1416
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1417
+ if (ts8.isReturnStatement(candidate) && candidate.expression) {
1416
1418
  const expression = candidate.expression;
1417
1419
  wrap(
1418
1420
  edits,
@@ -1424,17 +1426,17 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1424
1426
  );
1425
1427
  return;
1426
1428
  }
1427
- ts9.forEachChild(candidate, (child) => visit(child, at + 1));
1429
+ ts8.forEachChild(candidate, (child) => visit(child, at + 1));
1428
1430
  };
1429
1431
  visit(node.body, depth + 1);
1430
1432
  };
1431
1433
  var transformSource = (source, options) => {
1432
1434
  if (source.includes("@rasputin-ignore-file")) return void 0;
1433
1435
  if (sourceIsRasputinInstrumented(source)) return alreadyInstrumentedResult(source);
1434
- const sourceFile = ts9.createSourceFile(
1436
+ const sourceFile = ts8.createSourceFile(
1435
1437
  options.filePath,
1436
1438
  source,
1437
- ts9.ScriptTarget.Latest,
1439
+ ts8.ScriptTarget.Latest,
1438
1440
  true,
1439
1441
  scriptKindFor3(options.filePath)
1440
1442
  );
@@ -1477,7 +1479,7 @@ var transformSource = (source, options) => {
1477
1479
  collected.asyncFunction = true;
1478
1480
  skipFunction(collected, "unsupported_async_generator");
1479
1481
  }
1480
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1482
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1481
1483
  return;
1482
1484
  }
1483
1485
  if (isSyncGeneratorLike(node) && node.body) {
@@ -1488,10 +1490,10 @@ var transformSource = (source, options) => {
1488
1490
  options.mapLocation
1489
1491
  );
1490
1492
  if (collected) skipFunction(collected, "unsupported_sync_generator");
1491
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1493
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1492
1494
  return;
1493
1495
  }
1494
- if (ts9.isConstructorDeclaration(node) && node.body) {
1496
+ if (ts8.isConstructorDeclaration(node) && node.body) {
1495
1497
  const collected = collectWrappedFunction(
1496
1498
  node,
1497
1499
  sourceFile,
@@ -1499,13 +1501,22 @@ var transformSource = (source, options) => {
1499
1501
  options.mapLocation
1500
1502
  );
1501
1503
  if (collected) skipFunction(collected, "unsupported_constructor");
1502
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1504
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1503
1505
  return;
1504
1506
  }
1505
1507
  if (isSupportedFunction(node)) {
1506
1508
  const collected = collectWrappedFunction(node, sourceFile, absolutePath, options.mapLocation);
1507
1509
  if (!collected) {
1508
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1510
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1511
+ return;
1512
+ }
1513
+ if (options.decideFunction?.({
1514
+ node,
1515
+ sourceFile,
1516
+ filePath: options.filePath,
1517
+ name: collected.name
1518
+ }) === "skip") {
1519
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1509
1520
  return;
1510
1521
  }
1511
1522
  const asyncFunction = isAsyncFunctionLike(node);
@@ -1513,7 +1524,7 @@ var transformSource = (source, options) => {
1513
1524
  const decision = asyncFunction ? decideAsyncInstrumentation(node, sourceFile) : { action: "inline" };
1514
1525
  if (decision.action === "skip") {
1515
1526
  skipFunction(collected, decision.reason);
1516
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1527
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1517
1528
  return;
1518
1529
  }
1519
1530
  if (functionHasPreBodyParameterEvaluation(node)) {
@@ -1526,29 +1537,29 @@ var transformSource = (source, options) => {
1526
1537
  suspendResume: decision.action === "suspend_resume"
1527
1538
  });
1528
1539
  delta.functions.push(collected);
1529
- ts9.forEachChild(node, (child) => visit(child, collected, depth + 1));
1540
+ ts8.forEachChild(node, (child) => visit(child, collected, depth + 1));
1530
1541
  return;
1531
1542
  }
1532
- if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
1543
+ if (caller && (ts8.isCallExpression(node) || ts8.isNewExpression(node))) {
1533
1544
  const site = collectCallSite(node, caller, collectContext);
1534
1545
  if (site) delta.callSites.push(site);
1535
1546
  }
1536
- if (caller && ts9.isVariableDeclaration(node)) {
1547
+ if (caller && ts8.isVariableDeclaration(node)) {
1537
1548
  const destructure = collectParamDestructure(node, caller, collectContext);
1538
1549
  if (destructure) delta.destructures.push(destructure);
1539
1550
  }
1540
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1551
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1541
1552
  };
1542
1553
  visit(sourceFile, void 0, 0);
1543
1554
  if (pending.length === 0) {
1544
1555
  return delta.functions.length > 0 ? { code: source, delta } : void 0;
1545
1556
  }
1546
1557
  for (const [planIndex, entry] of pending.entries()) {
1547
- const captured = ts9.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1558
+ const captured = ts8.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1548
1559
  const omitArg = captured.omitValues ? ",true" : "";
1549
1560
  const enterCall = `${runName}.enter(${planIndex},${captured.args}${omitArg})`;
1550
1561
  const epilogue = failEpilogue(handleName, errorName, captured.args, entry.suspendResume);
1551
- if (ts9.isBlock(entry.node.body)) {
1562
+ if (ts8.isBlock(entry.node.body)) {
1552
1563
  const prologueAt = insertAfterSuperOrPrologue(entry.node.body, sourceFile);
1553
1564
  const closeAt = entry.node.body.end - 1;
1554
1565
  wrap(
@@ -1632,31 +1643,32 @@ var transformSource = (source, options) => {
1632
1643
  }
1633
1644
  return {
1634
1645
  code: attachInlineSourceMap(source, transformed, options.filePath, edits, basename),
1635
- delta
1646
+ delta,
1647
+ map: exactTransformMap(source, transformed, basename(options.filePath), edits)
1636
1648
  };
1637
1649
  };
1638
1650
 
1639
1651
  // ../instrumentation/src/json-producer-sites.ts
1640
- import ts11 from "typescript";
1652
+ import ts10 from "typescript";
1641
1653
 
1642
1654
  // ../instrumentation/src/literal-sites.ts
1643
- import ts12 from "typescript";
1655
+ import ts11 from "typescript";
1644
1656
 
1645
1657
  // ../instrumentation/src/observe-sites.ts
1646
1658
  import { propertyNameIsSensitive as propertyNameIsSensitive2 } from "@rasputin-ai/core";
1647
- import ts13 from "typescript";
1659
+ import ts12 from "typescript";
1648
1660
 
1649
1661
  // ../instrumentation/src/verify-browser-source.ts
1650
- import ts14 from "typescript";
1662
+ import ts13 from "typescript";
1651
1663
 
1652
1664
  // ../instrumentation/src/provenance-function-edits.ts
1653
- import ts15 from "typescript";
1665
+ import ts14 from "typescript";
1654
1666
 
1655
1667
  // ../instrumentation/src/source-map-location.ts
1656
1668
  import { originalPositionFor as originalPositionFor3, TraceMap as TraceMap4 } from "@jridgewell/trace-mapping";
1657
1669
 
1658
1670
  // src/sdk-meta.ts
1659
- var SDK_VERSION = "0.6.1";
1671
+ var SDK_VERSION = "0.7.0";
1660
1672
 
1661
1673
  // src/auto-instrumentation/transform-disk-cache.ts
1662
1674
  var projectCacheDir = () => {