@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.
@@ -124,7 +124,7 @@ import { homedir } from "node:os";
124
124
  import { dirname as dirname2, join as join2 } from "node:path";
125
125
 
126
126
  // ../instrumentation/src/classify-function.ts
127
- import ts4 from "typescript";
127
+ import ts3 from "typescript";
128
128
 
129
129
  // ../instrumentation/src/collect-instrumentation-delta.ts
130
130
  import ts from "typescript";
@@ -306,9 +306,6 @@ var collectParamDestructure = (declaration, caller, context) => {
306
306
  // ../instrumentation/src/parse-source.ts
307
307
  import ts2 from "typescript";
308
308
 
309
- // ../instrumentation/src/svelte-generated.ts
310
- import ts3 from "typescript";
311
-
312
309
  // ../instrumentation/src/edits.ts
313
310
  var isIdentContinue = (code) => code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
314
311
  var isIdentStart = (code) => code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95;
@@ -356,7 +353,7 @@ var applyEdits = (source, edits) => {
356
353
  };
357
354
  var textOf = (edit) => edit.text;
358
355
 
359
- // ../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
356
+ // ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
360
357
  var comma = ",".charCodeAt(0);
361
358
  var semicolon = ";".charCodeAt(0);
362
359
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -443,7 +440,7 @@ function encode(decoded) {
443
440
  return writer.flush();
444
441
  }
445
442
 
446
- // ../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
443
+ // ../../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
447
444
  import { TraceMap, decodedMappings } from "@jridgewell/trace-mapping";
448
445
  var SetArray = class {
449
446
  constructor() {
@@ -715,6 +712,11 @@ var encodeColumnMappings = (original, generated, file, edits) => {
715
712
  mappings: encoded.mappings
716
713
  };
717
714
  };
715
+ var exactTransformMap = (original, generated, file, edits) => {
716
+ const withoutUpstream = generated.replace(SOURCEMAP_COMMENT, "");
717
+ const { sources, mappings } = encodeColumnMappings(original, withoutUpstream, file, edits);
718
+ return { version: 3, file, sources, mappings };
719
+ };
718
720
  var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) => {
719
721
  const file = basenameOf(filePath);
720
722
  const withoutUpstream = generated.replace(SOURCEMAP_COMMENT, "");
@@ -728,11 +730,11 @@ var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) =
728
730
 
729
731
  // ../instrumentation/src/browser-function-edits.ts
730
732
  import { propertyNameIsSensitive } from "@rasputin-ai/core";
731
- import ts10 from "typescript";
733
+ import ts9 from "typescript";
732
734
 
733
735
  // ../instrumentation/src/suspension-whitelist.ts
734
- import ts5 from "typescript";
735
- var nodeFlags = ts5.NodeFlags;
736
+ import ts4 from "typescript";
737
+ var nodeFlags = ts4.NodeFlags;
736
738
  var AWAIT_USING_FLAG = nodeFlags.AwaitUsing ?? 0;
737
739
  var USING_FLAG = nodeFlags.Using ?? 0;
738
740
  var KNOWN_SUSPENSION_KIND_NAMES = [
@@ -742,8 +744,8 @@ var KNOWN_SUSPENSION_KIND_NAMES = [
742
744
  "YieldKeyword",
743
745
  "UsingKeyword"
744
746
  ];
745
- var isFunctionLike = (node) => ts5.isFunctionLike(node);
746
- var isAsyncFunctionLike = (node) => (ts5.getCombinedModifierFlags(node) & ts5.ModifierFlags.Async) !== 0;
747
+ var isFunctionLike = (node) => ts4.isFunctionLike(node);
748
+ var isAsyncFunctionLike = (node) => (ts4.getCombinedModifierFlags(node) & ts4.ModifierFlags.Async) !== 0;
747
749
  var isAsyncGeneratorLike = (node) => isFunctionLike(node) && isAsyncFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken);
748
750
  var isSyncGeneratorLike = (node) => isFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken) && !isAsyncFunctionLike(node);
749
751
  var visitOwnBody = (node, visitNode) => {
@@ -754,7 +756,7 @@ var visitOwnBody = (node, visitNode) => {
754
756
  return;
755
757
  }
756
758
  if (visitNode(candidate)) return;
757
- ts5.forEachChild(candidate, visit);
759
+ ts4.forEachChild(candidate, visit);
758
760
  };
759
761
  visit(node.body);
760
762
  };
@@ -782,16 +784,16 @@ var slicesOutside = (start, end, spans) => {
782
784
  };
783
785
  var sliceHasAwaitKeyword = (source, start, end) => {
784
786
  if (end <= start) return false;
785
- const scanner = ts5.createScanner(
786
- ts5.ScriptTarget.Latest,
787
+ const scanner = ts4.createScanner(
788
+ ts4.ScriptTarget.Latest,
787
789
  true,
788
- ts5.LanguageVariant.Standard,
790
+ ts4.LanguageVariant.Standard,
789
791
  source.slice(start, end)
790
792
  );
791
793
  while (true) {
792
794
  const token = scanner.scan();
793
- if (token === ts5.SyntaxKind.EndOfFileToken) return false;
794
- if (token === ts5.SyntaxKind.AwaitKeyword) return true;
795
+ if (token === ts4.SyntaxKind.EndOfFileToken) return false;
796
+ if (token === ts4.SyntaxKind.AwaitKeyword) return true;
795
797
  }
796
798
  };
797
799
  var ownBodyHasAwaitKeyword = (node, sourceFile) => {
@@ -809,7 +811,7 @@ var isAwaitUsingList = (node) => {
809
811
  return (node.flags & AWAIT_USING_FLAG) === AWAIT_USING_FLAG && (node.flags & USING_FLAG) !== 0;
810
812
  };
811
813
  var unknownSuspensionKind = (node) => {
812
- const name = ts5.SyntaxKind[node.kind];
814
+ const name = ts4.SyntaxKind[node.kind];
813
815
  if (typeof name !== "string" || !/Await|Yield|Using/.test(name)) return false;
814
816
  return !KNOWN_SUSPENSION_KIND_NAMES.includes(name);
815
817
  };
@@ -822,9 +824,9 @@ var ownSuspensionFacts = (node, sourceFile) => {
822
824
  awaitKeyword: ownBodyHasAwaitKeyword(node, sourceFile)
823
825
  };
824
826
  visitOwnBody(node, (candidate) => {
825
- if (ts5.isAwaitExpression(candidate)) facts.awaitExpressions = true;
826
- if (ts5.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
827
- if (ts5.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
827
+ if (ts4.isAwaitExpression(candidate)) facts.awaitExpressions = true;
828
+ if (ts4.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
829
+ if (ts4.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
828
830
  facts.awaitUsing = true;
829
831
  }
830
832
  if (unknownSuspensionKind(candidate)) facts.unknown = true;
@@ -835,7 +837,7 @@ var ownSuspensionFacts = (node, sourceFile) => {
835
837
  var bodyHasDirectEval = (node) => {
836
838
  let found = false;
837
839
  visitOwnBody(node, (candidate) => {
838
- if (ts5.isCallExpression(candidate) && ts5.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
840
+ if (ts4.isCallExpression(candidate) && ts4.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
839
841
  found = true;
840
842
  }
841
843
  return found;
@@ -859,34 +861,34 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
859
861
 
860
862
  // ../instrumentation/src/transform-source.ts
861
863
  import { basename, resolve as resolve3 } from "node:path";
862
- import ts9 from "typescript";
864
+ import ts8 from "typescript";
863
865
 
864
866
  // ../instrumentation/src/parameter-initializer-may-run-code.ts
865
- import ts6 from "typescript";
867
+ import ts5 from "typescript";
866
868
  var unwrap = (expression) => {
867
869
  let current = expression;
868
- while (ts6.isParenthesizedExpression(current) || ts6.isNonNullExpression(current)) {
870
+ while (ts5.isParenthesizedExpression(current) || ts5.isNonNullExpression(current)) {
869
871
  current = current.expression;
870
872
  }
871
873
  return current;
872
874
  };
873
875
  var isSafeLiteralInitializer = (expression) => {
874
876
  const current = unwrap(expression);
875
- if (ts6.isNumericLiteral(current) || ts6.isStringLiteral(current) || ts6.isNoSubstitutionTemplateLiteral(current) || ts6.isBigIntLiteral(current)) {
877
+ if (ts5.isNumericLiteral(current) || ts5.isStringLiteral(current) || ts5.isNoSubstitutionTemplateLiteral(current) || ts5.isBigIntLiteral(current)) {
876
878
  return true;
877
879
  }
878
- if (current.kind === ts6.SyntaxKind.TrueKeyword || current.kind === ts6.SyntaxKind.FalseKeyword || current.kind === ts6.SyntaxKind.NullKeyword) {
880
+ if (current.kind === ts5.SyntaxKind.TrueKeyword || current.kind === ts5.SyntaxKind.FalseKeyword || current.kind === ts5.SyntaxKind.NullKeyword) {
879
881
  return true;
880
882
  }
881
- if (ts6.isIdentifier(current) && current.text === "undefined") return true;
882
- if (ts6.isPrefixUnaryExpression(current) && (current.operator === ts6.SyntaxKind.PlusToken || current.operator === ts6.SyntaxKind.MinusToken)) {
883
- return ts6.isNumericLiteral(unwrap(current.operand));
883
+ if (ts5.isIdentifier(current) && current.text === "undefined") return true;
884
+ if (ts5.isPrefixUnaryExpression(current) && (current.operator === ts5.SyntaxKind.PlusToken || current.operator === ts5.SyntaxKind.MinusToken)) {
885
+ return ts5.isNumericLiteral(unwrap(current.operand));
884
886
  }
885
887
  return false;
886
888
  };
887
889
  var functionHasPreBodyParameterEvaluation = (node) => {
888
890
  for (const parameter of node.parameters) {
889
- if (ts6.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
891
+ if (ts5.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
890
892
  if (!parameter.initializer) continue;
891
893
  if (!isSafeLiteralInitializer(parameter.initializer)) return true;
892
894
  }
@@ -894,24 +896,24 @@ var functionHasPreBodyParameterEvaluation = (node) => {
894
896
  };
895
897
 
896
898
  // ../instrumentation/src/verify-instrumentation-isomorphism.ts
897
- import ts7 from "typescript";
899
+ import ts6 from "typescript";
898
900
  var RASPUTIN_IDENT = /^__rasputin/;
899
901
  var scriptKindFor = (filePath) => {
900
- if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
901
- if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
902
- if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
903
- return ts7.ScriptKind.JS;
902
+ if (/\.tsx$/i.test(filePath)) return ts6.ScriptKind.TSX;
903
+ if (/\.jsx$/i.test(filePath)) return ts6.ScriptKind.JSX;
904
+ if (/\.[cm]?ts$/i.test(filePath)) return ts6.ScriptKind.TS;
905
+ return ts6.ScriptKind.JS;
904
906
  };
905
- var parse = (filePath, source) => ts7.createSourceFile(filePath, source, ts7.ScriptTarget.Latest, true, scriptKindFor(filePath));
907
+ var parse = (filePath, source) => ts6.createSourceFile(filePath, source, ts6.ScriptTarget.Latest, true, scriptKindFor(filePath));
906
908
  var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
907
909
  var identText = (node) => {
908
- if (ts7.isIdentifier(node)) return node.text;
909
- if (ts7.isPrivateIdentifier(node)) return node.text;
910
+ if (ts6.isIdentifier(node)) return node.text;
911
+ if (ts6.isPrivateIdentifier(node)) return node.text;
910
912
  return void 0;
911
913
  };
912
914
  var calleeName = (expression) => {
913
- if (ts7.isIdentifier(expression)) return expression.text;
914
- if (ts7.isPropertyAccessExpression(expression)) {
915
+ if (ts6.isIdentifier(expression)) return expression.text;
916
+ if (ts6.isPropertyAccessExpression(expression)) {
915
917
  const object = identText(expression.expression);
916
918
  const property = identText(expression.name);
917
919
  if (object && isRasputinName(object) && property) return `${object}.${property}`;
@@ -919,7 +921,7 @@ var calleeName = (expression) => {
919
921
  return void 0;
920
922
  };
921
923
  var isRasputinCall = (node, methods) => {
922
- if (!ts7.isCallExpression(node)) return false;
924
+ if (!ts6.isCallExpression(node)) return false;
923
925
  const name = calleeName(node.expression);
924
926
  if (!name) return false;
925
927
  if (isRasputinName(name)) return !methods || methods.has(name.split(".")[1] ?? "");
@@ -929,20 +931,20 @@ var unwrapCall = (node) => {
929
931
  let current = node;
930
932
  while (isRasputinCall(current) && current.arguments.length === 1 && current.arguments[0]) {
931
933
  current = current.arguments[0];
932
- if (ts7.isParenthesizedExpression(current)) current = current.expression;
934
+ if (ts6.isParenthesizedExpression(current)) current = current.expression;
933
935
  }
934
- if (ts7.isParenthesizedExpression(current)) return current.expression;
936
+ if (ts6.isParenthesizedExpression(current)) return current.expression;
935
937
  return current;
936
938
  };
937
939
  var isRasputinStatement = (node) => {
938
- if (ts7.isEmptyStatement(node)) return true;
939
- if (ts7.isVariableStatement(node)) {
940
+ if (ts6.isEmptyStatement(node)) return true;
941
+ if (ts6.isVariableStatement(node)) {
940
942
  return node.declarationList.declarations.every((declaration) => {
941
943
  const name = identText(declaration.name);
942
944
  return Boolean(name && isRasputinName(name));
943
945
  });
944
946
  }
945
- if (ts7.isExpressionStatement(node)) {
947
+ if (ts6.isExpressionStatement(node)) {
946
948
  if (!isRasputinCall(node.expression)) return false;
947
949
  const unwrapped = unwrapCall(node.expression);
948
950
  return unwrapped === node.expression;
@@ -956,7 +958,7 @@ var isRasputinTryWrapper = (node) => {
956
958
  (statement) => !isRasputinStatement(statement)
957
959
  );
958
960
  const leftover = catchCalls[0];
959
- const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts7.isThrowStatement(leftover) && ts7.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
961
+ const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts6.isThrowStatement(leftover) && ts6.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
960
962
  if (!leftoverThrow && catchCalls.length > 0) return false;
961
963
  return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
962
964
  };
@@ -964,7 +966,7 @@ var flattenStatements = (statements) => {
964
966
  const flattened = [];
965
967
  for (const statement of statements) {
966
968
  if (isRasputinStatement(statement)) continue;
967
- if (ts7.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
969
+ if (ts6.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
968
970
  flattened.push(...flattenStatements(statement.tryBlock.statements));
969
971
  continue;
970
972
  }
@@ -973,38 +975,38 @@ var flattenStatements = (statements) => {
973
975
  return flattened;
974
976
  };
975
977
  var extra = (node) => {
976
- if (ts7.isIdentifier(node) || ts7.isPrivateIdentifier(node)) {
978
+ if (ts6.isIdentifier(node) || ts6.isPrivateIdentifier(node)) {
977
979
  return isRasputinName(node.text) ? "" : node.text;
978
980
  }
979
- if (ts7.isStringLiteral(node) || ts7.isNumericLiteral(node) || ts7.isNoSubstitutionTemplateLiteral(node)) {
981
+ if (ts6.isStringLiteral(node) || ts6.isNumericLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
980
982
  return node.text;
981
983
  }
982
- if (ts7.isToken(node) && !ts7.isIdentifier(node)) return ts7.SyntaxKind[node.kind] ?? "";
984
+ if (ts6.isToken(node) && !ts6.isIdentifier(node)) return ts6.SyntaxKind[node.kind] ?? "";
983
985
  return "";
984
986
  };
985
987
  var signatureOf = (node) => {
986
988
  const unwrapped = unwrapCall(node);
987
989
  if (unwrapped !== node) return signatureOf(unwrapped);
988
- if (ts7.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
989
- if (ts7.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
990
+ if (ts6.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
991
+ if (ts6.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
990
992
  return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
991
993
  }
992
- if (ts7.isBlock(unwrapped)) {
994
+ if (ts6.isBlock(unwrapped)) {
993
995
  const statements = flattenStatements(unwrapped.statements);
994
996
  return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
995
997
  }
996
- if (ts7.isCatchClause(unwrapped)) {
998
+ if (ts6.isCatchClause(unwrapped)) {
997
999
  const statements = flattenStatements(unwrapped.block.statements);
998
1000
  const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
999
1001
  return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
1000
1002
  }
1001
- if (ts7.isArrowFunction(unwrapped) && ts7.isBlock(unwrapped.body)) {
1003
+ if (ts6.isArrowFunction(unwrapped) && ts6.isBlock(unwrapped.body)) {
1002
1004
  const statements = flattenStatements(unwrapped.body.statements);
1003
1005
  const only = statements[0];
1004
- if (statements.length === 1 && only && ts7.isReturnStatement(only) && only.expression) {
1006
+ if (statements.length === 1 && only && ts6.isReturnStatement(only) && only.expression) {
1005
1007
  const expression = only.expression;
1006
1008
  const parts2 = [];
1007
- ts7.forEachChild(unwrapped, (child) => {
1009
+ ts6.forEachChild(unwrapped, (child) => {
1008
1010
  if (child === unwrapped.body) {
1009
1011
  const part2 = signatureOf(expression);
1010
1012
  if (part2) parts2.push(part2);
@@ -1017,11 +1019,11 @@ var signatureOf = (node) => {
1017
1019
  }
1018
1020
  }
1019
1021
  const parts = [];
1020
- ts7.forEachChild(unwrapped, (child) => {
1022
+ ts6.forEachChild(unwrapped, (child) => {
1021
1023
  const part = signatureOf(child);
1022
1024
  if (part) parts.push(part);
1023
1025
  });
1024
- const kind = ts7.SyntaxKind[unwrapped.kind] ?? "Node";
1026
+ const kind = ts6.SyntaxKind[unwrapped.kind] ?? "Node";
1025
1027
  const label = extra(unwrapped);
1026
1028
  return `${kind}${label}[${parts.join(",")}]`;
1027
1029
  };
@@ -1030,14 +1032,14 @@ var instrumentationTreesAreIsomorphic = (filePath, original, transformed) => {
1030
1032
  };
1031
1033
 
1032
1034
  // ../instrumentation/src/verify-transformed-source.ts
1033
- import ts8 from "typescript";
1034
- var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1035
+ import ts7 from "typescript";
1036
+ var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
1035
1037
  compilerOptions: {
1036
1038
  // ES2020 downlevel keeps native @decorators out of `new Function`.
1037
- target: ts8.ScriptTarget.ES2020,
1038
- module: ts8.ModuleKind.ESNext,
1039
+ target: ts7.ScriptTarget.ES2020,
1040
+ module: ts7.ModuleKind.ESNext,
1039
1041
  allowJs: true,
1040
- jsx: ts8.JsxEmit.React,
1042
+ jsx: ts7.JsxEmit.React,
1041
1043
  experimentalDecorators: true
1042
1044
  },
1043
1045
  reportDiagnostics: true,
@@ -1045,7 +1047,7 @@ var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1045
1047
  });
1046
1048
  var hasScanOrParseError = (diagnostics) => Boolean(
1047
1049
  diagnostics?.some(
1048
- (diagnostic) => diagnostic.category === ts8.DiagnosticCategory.Error && diagnostic.code < 2e3
1050
+ (diagnostic) => diagnostic.category === ts7.DiagnosticCategory.Error && diagnostic.code < 2e3
1049
1051
  )
1050
1052
  );
1051
1053
  var scriptBodyForEngine = (emitted) => (
@@ -1054,39 +1056,39 @@ var scriptBodyForEngine = (emitted) => (
1054
1056
  );
1055
1057
  var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
1056
1058
  var scriptKindFor2 = (filePath) => {
1057
- if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1058
- if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1059
- if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1060
- return ts8.ScriptKind.JS;
1059
+ if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
1060
+ if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
1061
+ if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
1062
+ return ts7.ScriptKind.JS;
1061
1063
  };
1062
- var isIterationStatement = (node) => ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
1064
+ var isIterationStatement = (node) => ts7.isForStatement(node) || ts7.isForOfStatement(node) || ts7.isForInStatement(node) || ts7.isWhileStatement(node) || ts7.isDoStatement(node);
1063
1065
  var unwrapLabeled = (node) => {
1064
1066
  let current = node;
1065
- while (ts8.isLabeledStatement(current)) current = current.statement;
1067
+ while (ts7.isLabeledStatement(current)) current = current.statement;
1066
1068
  return current;
1067
1069
  };
1068
1070
  var hasInvalidLabelJump = (sourceFile) => {
1069
1071
  const visit = (node, labels) => {
1070
- if (ts8.isFunctionLike(node)) {
1072
+ if (ts7.isFunctionLike(node)) {
1071
1073
  let nestedInvalid = false;
1072
- ts8.forEachChild(node, (child) => {
1074
+ ts7.forEachChild(node, (child) => {
1073
1075
  if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
1074
1076
  });
1075
1077
  return nestedInvalid;
1076
1078
  }
1077
- if (ts8.isLabeledStatement(node)) {
1079
+ if (ts7.isLabeledStatement(node)) {
1078
1080
  const next = new Map(labels);
1079
1081
  next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
1080
1082
  return visit(node.statement, next);
1081
1083
  }
1082
- if (ts8.isContinueStatement(node) && node.label) {
1084
+ if (ts7.isContinueStatement(node) && node.label) {
1083
1085
  if (labels.get(node.label.text) !== true) return true;
1084
1086
  }
1085
- if (ts8.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1087
+ if (ts7.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1086
1088
  return true;
1087
1089
  }
1088
1090
  let invalid = false;
1089
- ts8.forEachChild(node, (child) => {
1091
+ ts7.forEachChild(node, (child) => {
1090
1092
  if (visit(child, labels)) invalid = true;
1091
1093
  });
1092
1094
  return invalid;
@@ -1129,10 +1131,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
1129
1131
  var transformedSourceIsInvalid = (filePath, code) => {
1130
1132
  if (GLUED_INSTRUMENTATION.test(code)) return true;
1131
1133
  if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
1132
- const sourceFile = ts8.createSourceFile(
1134
+ const sourceFile = ts7.createSourceFile(
1133
1135
  filePath,
1134
1136
  code,
1135
- ts8.ScriptTarget.Latest,
1137
+ ts7.ScriptTarget.Latest,
1136
1138
  true,
1137
1139
  scriptKindFor2(filePath)
1138
1140
  );
@@ -1153,25 +1155,25 @@ var alreadyInstrumentedResult = (source) => ({
1153
1155
  delta: { functions: [], callSites: [], destructures: [], alreadyInstrumented: true }
1154
1156
  });
1155
1157
  var scriptKindFor3 = (filePath) => {
1156
- if (/\.tsx$/i.test(filePath)) return ts9.ScriptKind.TSX;
1157
- if (/\.jsx$/i.test(filePath)) return ts9.ScriptKind.JSX;
1158
- if (/\.[cm]?ts$/i.test(filePath)) return ts9.ScriptKind.TS;
1159
- return ts9.ScriptKind.JS;
1158
+ if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1159
+ if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1160
+ if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1161
+ return ts8.ScriptKind.JS;
1160
1162
  };
1161
1163
  var functionName = (node, sourceFile) => {
1162
- if (ts9.isConstructorDeclaration(node)) return "constructor";
1164
+ if (ts8.isConstructorDeclaration(node)) return "constructor";
1163
1165
  if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
1164
1166
  const parent = node.parent;
1165
- if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name)) return parent.name.text;
1166
- if (ts9.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1167
- if (ts9.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1167
+ if (ts8.isVariableDeclaration(parent) && ts8.isIdentifier(parent.name)) return parent.name.text;
1168
+ if (ts8.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1169
+ if (ts8.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1168
1170
  const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
1169
1171
  return `anonymous@${location.line + 1}:${location.character + 1}`;
1170
1172
  };
1171
1173
  var functionLocationPosition = (node, sourceFile) => {
1172
1174
  if (node.name) return node.name.getStart(sourceFile);
1173
1175
  const parent = node.parent;
1174
- if ((ts9.isVariableDeclaration(parent) || ts9.isPropertyAssignment(parent)) && parent.name) {
1176
+ if ((ts8.isVariableDeclaration(parent) || ts8.isPropertyAssignment(parent)) && parent.name) {
1175
1177
  return parent.name.getStart(sourceFile);
1176
1178
  }
1177
1179
  return node.getStart(sourceFile);
@@ -1184,12 +1186,12 @@ var functionBodyPrologueEnd = (body, sourceFile) => {
1184
1186
  }
1185
1187
  return end;
1186
1188
  };
1187
- var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
1189
+ var isStaticPropertyName = (name) => ts8.isIdentifier(name) || ts8.isStringLiteral(name) || ts8.isNoSubstitutionTemplateLiteral(name) || ts8.isNumericLiteral(name);
1188
1190
  var canReconstructBinding = (name) => {
1189
- if (ts9.isIdentifier(name)) return true;
1190
- if (ts9.isArrayBindingPattern(name)) {
1191
+ if (ts8.isIdentifier(name)) return true;
1192
+ if (ts8.isArrayBindingPattern(name)) {
1191
1193
  return name.elements.every(
1192
- (element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
1194
+ (element) => ts8.isOmittedExpression(element) || canReconstructBinding(element.name)
1193
1195
  );
1194
1196
  }
1195
1197
  return name.elements.every((element) => {
@@ -1198,10 +1200,10 @@ var canReconstructBinding = (name) => {
1198
1200
  });
1199
1201
  };
1200
1202
  var bindingValue = (name, sourceFile) => {
1201
- if (ts9.isIdentifier(name)) return name.text;
1202
- if (ts9.isArrayBindingPattern(name)) {
1203
+ if (ts8.isIdentifier(name)) return name.text;
1204
+ if (ts8.isArrayBindingPattern(name)) {
1203
1205
  const values = name.elements.map((element) => {
1204
- if (ts9.isOmittedExpression(element)) return "";
1206
+ if (ts8.isOmittedExpression(element)) return "";
1205
1207
  const value = bindingValue(element.name, sourceFile);
1206
1208
  return element.dotDotDotToken ? `...${value}` : value;
1207
1209
  });
@@ -1211,7 +1213,7 @@ var bindingValue = (name, sourceFile) => {
1211
1213
  const value = bindingValue(element.name, sourceFile);
1212
1214
  if (element.dotDotDotToken) return `...${value}`;
1213
1215
  if (!element.propertyName) return value;
1214
- const key = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1216
+ const key = ts8.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
1215
1217
  return `${key}:${value}`;
1216
1218
  });
1217
1219
  return `{${properties.join(",")}}`;
@@ -1219,7 +1221,7 @@ var bindingValue = (name, sourceFile) => {
1219
1221
  var arrowArgsCapture = (node) => {
1220
1222
  const sourceFile = node.getSourceFile();
1221
1223
  const params = node.parameters.filter(
1222
- (parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
1224
+ (parameter) => !(ts8.isIdentifier(parameter.name) && parameter.name.text === "this")
1223
1225
  );
1224
1226
  if (!params.every((parameter) => canReconstructBinding(parameter.name))) {
1225
1227
  return {
@@ -1234,13 +1236,13 @@ var arrowArgsCapture = (node) => {
1234
1236
  return { args: `[${values.join(",")}]`, omitValues: false };
1235
1237
  };
1236
1238
  var isSupportedFunction = (node) => {
1237
- if (!ts9.isFunctionDeclaration(node) && !ts9.isFunctionExpression(node) && !ts9.isArrowFunction(node) && !ts9.isMethodDeclaration(node) && !ts9.isGetAccessorDeclaration(node) && !ts9.isSetAccessorDeclaration(node)) {
1239
+ if (!ts8.isFunctionDeclaration(node) && !ts8.isFunctionExpression(node) && !ts8.isArrowFunction(node) && !ts8.isMethodDeclaration(node) && !ts8.isGetAccessorDeclaration(node) && !ts8.isSetAccessorDeclaration(node)) {
1238
1240
  return false;
1239
1241
  }
1240
1242
  if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
1241
1243
  return true;
1242
1244
  };
1243
- var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
1245
+ var isDirectivePrologue = (statement) => ts8.isExpressionStatement(statement) && ts8.isStringLiteral(statement.expression);
1244
1246
  var insertPositionAfterPrologue = (source, sourceFile) => {
1245
1247
  const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
1246
1248
  let end = shebangEnd;
@@ -1291,7 +1293,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
1291
1293
  const end = functionBodyPrologueEnd(body, sourceFile);
1292
1294
  for (const statement of body.statements) {
1293
1295
  if (isDirectivePrologue(statement)) continue;
1294
- if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
1296
+ if (ts8.isExpressionStatement(statement) && ts8.isCallExpression(statement.expression) && statement.expression.expression.kind === ts8.SyntaxKind.SuperKeyword) {
1295
1297
  return statement.end;
1296
1298
  }
1297
1299
  break;
@@ -1302,15 +1304,15 @@ var failEpilogue = (handleName, errorName, args, restoreOnCatch) => `}catch(${er
1302
1304
  var walkOwnBody = (node, visitNode) => {
1303
1305
  if (!node.body) return;
1304
1306
  const visit = (candidate) => {
1305
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1307
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1306
1308
  visitNode(candidate);
1307
- ts9.forEachChild(candidate, visit);
1309
+ ts8.forEachChild(candidate, visit);
1308
1310
  };
1309
1311
  visit(node.body);
1310
1312
  };
1311
1313
  var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1312
1314
  walkOwnBody(node, (candidate) => {
1313
- if (!ts9.isAwaitExpression(candidate)) return;
1315
+ if (!ts8.isAwaitExpression(candidate)) return;
1314
1316
  wrap(
1315
1317
  edits,
1316
1318
  candidate.expression.getStart(sourceFile),
@@ -1331,7 +1333,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
1331
1333
  };
1332
1334
  var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
1333
1335
  walkOwnBody(node, (candidate) => {
1334
- if (!ts9.isTryStatement(candidate)) return;
1336
+ if (!ts8.isTryStatement(candidate)) return;
1335
1337
  const blocks = [candidate.catchClause?.block, candidate.finallyBlock];
1336
1338
  for (const block of blocks) {
1337
1339
  if (!block) continue;
@@ -1347,10 +1349,10 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
1347
1349
  });
1348
1350
  };
1349
1351
  var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1350
- if (!node.body || !ts9.isBlock(node.body)) return;
1352
+ if (!node.body || !ts8.isBlock(node.body)) return;
1351
1353
  const visit = (candidate, at) => {
1352
- if (candidate !== node && ts9.isFunctionLike(candidate)) return;
1353
- if (ts9.isReturnStatement(candidate) && candidate.expression) {
1354
+ if (candidate !== node && ts8.isFunctionLike(candidate)) return;
1355
+ if (ts8.isReturnStatement(candidate) && candidate.expression) {
1354
1356
  const expression = candidate.expression;
1355
1357
  wrap(
1356
1358
  edits,
@@ -1362,17 +1364,17 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
1362
1364
  );
1363
1365
  return;
1364
1366
  }
1365
- ts9.forEachChild(candidate, (child) => visit(child, at + 1));
1367
+ ts8.forEachChild(candidate, (child) => visit(child, at + 1));
1366
1368
  };
1367
1369
  visit(node.body, depth + 1);
1368
1370
  };
1369
1371
  var transformSource = (source, options) => {
1370
1372
  if (source.includes("@rasputin-ignore-file")) return void 0;
1371
1373
  if (sourceIsRasputinInstrumented(source)) return alreadyInstrumentedResult(source);
1372
- const sourceFile = ts9.createSourceFile(
1374
+ const sourceFile = ts8.createSourceFile(
1373
1375
  options.filePath,
1374
1376
  source,
1375
- ts9.ScriptTarget.Latest,
1377
+ ts8.ScriptTarget.Latest,
1376
1378
  true,
1377
1379
  scriptKindFor3(options.filePath)
1378
1380
  );
@@ -1415,7 +1417,7 @@ var transformSource = (source, options) => {
1415
1417
  collected.asyncFunction = true;
1416
1418
  skipFunction(collected, "unsupported_async_generator");
1417
1419
  }
1418
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1420
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1419
1421
  return;
1420
1422
  }
1421
1423
  if (isSyncGeneratorLike(node) && node.body) {
@@ -1426,10 +1428,10 @@ var transformSource = (source, options) => {
1426
1428
  options.mapLocation
1427
1429
  );
1428
1430
  if (collected) skipFunction(collected, "unsupported_sync_generator");
1429
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1431
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1430
1432
  return;
1431
1433
  }
1432
- if (ts9.isConstructorDeclaration(node) && node.body) {
1434
+ if (ts8.isConstructorDeclaration(node) && node.body) {
1433
1435
  const collected = collectWrappedFunction(
1434
1436
  node,
1435
1437
  sourceFile,
@@ -1437,13 +1439,22 @@ var transformSource = (source, options) => {
1437
1439
  options.mapLocation
1438
1440
  );
1439
1441
  if (collected) skipFunction(collected, "unsupported_constructor");
1440
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1442
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1441
1443
  return;
1442
1444
  }
1443
1445
  if (isSupportedFunction(node)) {
1444
1446
  const collected = collectWrappedFunction(node, sourceFile, absolutePath, options.mapLocation);
1445
1447
  if (!collected) {
1446
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1448
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1449
+ return;
1450
+ }
1451
+ if (options.decideFunction?.({
1452
+ node,
1453
+ sourceFile,
1454
+ filePath: options.filePath,
1455
+ name: collected.name
1456
+ }) === "skip") {
1457
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1447
1458
  return;
1448
1459
  }
1449
1460
  const asyncFunction = isAsyncFunctionLike(node);
@@ -1451,7 +1462,7 @@ var transformSource = (source, options) => {
1451
1462
  const decision = asyncFunction ? decideAsyncInstrumentation(node, sourceFile) : { action: "inline" };
1452
1463
  if (decision.action === "skip") {
1453
1464
  skipFunction(collected, decision.reason);
1454
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1465
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1455
1466
  return;
1456
1467
  }
1457
1468
  if (functionHasPreBodyParameterEvaluation(node)) {
@@ -1464,29 +1475,29 @@ var transformSource = (source, options) => {
1464
1475
  suspendResume: decision.action === "suspend_resume"
1465
1476
  });
1466
1477
  delta.functions.push(collected);
1467
- ts9.forEachChild(node, (child) => visit(child, collected, depth + 1));
1478
+ ts8.forEachChild(node, (child) => visit(child, collected, depth + 1));
1468
1479
  return;
1469
1480
  }
1470
- if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
1481
+ if (caller && (ts8.isCallExpression(node) || ts8.isNewExpression(node))) {
1471
1482
  const site = collectCallSite(node, caller, collectContext);
1472
1483
  if (site) delta.callSites.push(site);
1473
1484
  }
1474
- if (caller && ts9.isVariableDeclaration(node)) {
1485
+ if (caller && ts8.isVariableDeclaration(node)) {
1475
1486
  const destructure = collectParamDestructure(node, caller, collectContext);
1476
1487
  if (destructure) delta.destructures.push(destructure);
1477
1488
  }
1478
- ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
1489
+ ts8.forEachChild(node, (child) => visit(child, caller, depth + 1));
1479
1490
  };
1480
1491
  visit(sourceFile, void 0, 0);
1481
1492
  if (pending.length === 0) {
1482
1493
  return delta.functions.length > 0 ? { code: source, delta } : void 0;
1483
1494
  }
1484
1495
  for (const [planIndex, entry] of pending.entries()) {
1485
- const captured = ts9.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1496
+ const captured = ts8.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
1486
1497
  const omitArg = captured.omitValues ? ",true" : "";
1487
1498
  const enterCall = `${runName}.enter(${planIndex},${captured.args}${omitArg})`;
1488
1499
  const epilogue = failEpilogue(handleName, errorName, captured.args, entry.suspendResume);
1489
- if (ts9.isBlock(entry.node.body)) {
1500
+ if (ts8.isBlock(entry.node.body)) {
1490
1501
  const prologueAt = insertAfterSuperOrPrologue(entry.node.body, sourceFile);
1491
1502
  const closeAt = entry.node.body.end - 1;
1492
1503
  wrap(
@@ -1570,31 +1581,32 @@ var transformSource = (source, options) => {
1570
1581
  }
1571
1582
  return {
1572
1583
  code: attachInlineSourceMap(source, transformed, options.filePath, edits, basename),
1573
- delta
1584
+ delta,
1585
+ map: exactTransformMap(source, transformed, basename(options.filePath), edits)
1574
1586
  };
1575
1587
  };
1576
1588
 
1577
1589
  // ../instrumentation/src/json-producer-sites.ts
1578
- import ts11 from "typescript";
1590
+ import ts10 from "typescript";
1579
1591
 
1580
1592
  // ../instrumentation/src/literal-sites.ts
1581
- import ts12 from "typescript";
1593
+ import ts11 from "typescript";
1582
1594
 
1583
1595
  // ../instrumentation/src/observe-sites.ts
1584
1596
  import { propertyNameIsSensitive as propertyNameIsSensitive2 } from "@rasputin-ai/core";
1585
- import ts13 from "typescript";
1597
+ import ts12 from "typescript";
1586
1598
 
1587
1599
  // ../instrumentation/src/verify-browser-source.ts
1588
- import ts14 from "typescript";
1600
+ import ts13 from "typescript";
1589
1601
 
1590
1602
  // ../instrumentation/src/provenance-function-edits.ts
1591
- import ts15 from "typescript";
1603
+ import ts14 from "typescript";
1592
1604
 
1593
1605
  // ../instrumentation/src/source-map-location.ts
1594
1606
  import { originalPositionFor as originalPositionFor2, TraceMap as TraceMap3 } from "@jridgewell/trace-mapping";
1595
1607
 
1596
1608
  // src/sdk-meta.ts
1597
- var SDK_VERSION = "0.6.1";
1609
+ var SDK_VERSION = "0.7.0";
1598
1610
 
1599
1611
  // src/auto-instrumentation/source-map-locations.ts
1600
1612
  import { readFileSync } from "node:fs";