@rasputin-ai/node 0.5.3 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +2 -216
  2. package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts +1 -3
  3. package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts.map +1 -1
  4. package/dist/auto-instrumentation/schedule-instrumentation-manifest-upload.d.ts.map +1 -1
  5. package/dist/auto-instrumentation/source-map-locations.d.ts +1 -1
  6. package/dist/auto-instrumentation/source-map-locations.d.ts.map +1 -1
  7. package/dist/auto-instrumentation/transform-disk-cache.d.ts +1 -1
  8. package/dist/auto-instrumentation/transform-disk-cache.d.ts.map +1 -1
  9. package/dist/execution-recorder/automatic-runtime.d.ts +2 -33
  10. package/dist/execution-recorder/automatic-runtime.d.ts.map +1 -1
  11. package/dist/execution-recorder/encode-frozen.d.ts +0 -8
  12. package/dist/execution-recorder/encode-frozen.d.ts.map +1 -1
  13. package/dist/execution-recorder/execution-recorder-types.d.ts +3 -4
  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/function-plan.d.ts +7 -22
  17. package/dist/execution-recorder/function-plan.d.ts.map +1 -1
  18. package/dist/execution-recorder/redact-keys.d.ts +0 -1
  19. package/dist/execution-recorder/redact-keys.d.ts.map +1 -1
  20. package/dist/execution-recorder/runtime-state-size-budget.d.ts +0 -2
  21. package/dist/execution-recorder/runtime-state-size-budget.d.ts.map +1 -1
  22. package/dist/execution-recorder/safe-serialize.d.ts +0 -2
  23. package/dist/execution-recorder/safe-serialize.d.ts.map +1 -1
  24. package/dist/execution-recorder/value-freeze.d.ts +0 -1
  25. package/dist/execution-recorder/value-freeze.d.ts.map +1 -1
  26. package/dist/index.js +146 -125
  27. package/dist/instrument/build.js +852 -588
  28. package/dist/instrument/bun.js +639 -373
  29. package/dist/instrument/node.js +605 -339
  30. package/dist/internal.js +143 -122
  31. package/dist/rasputin-init.d.ts +1 -0
  32. package/dist/rasputin-init.d.ts.map +1 -1
  33. package/dist/sdk-meta.d.ts +1 -1
  34. package/package.json +4 -2
  35. package/dist/auto-instrumentation/collect-instrumentation-delta.d.ts +0 -29
  36. package/dist/auto-instrumentation/collect-instrumentation-delta.d.ts.map +0 -1
  37. package/dist/auto-instrumentation/instrumentation-manifest-delta.d.ts +0 -49
  38. package/dist/auto-instrumentation/instrumentation-manifest-delta.d.ts.map +0 -1
  39. package/dist/auto-instrumentation/parameter-initializer-may-run-code.d.ts +0 -3
  40. package/dist/auto-instrumentation/parameter-initializer-may-run-code.d.ts.map +0 -1
  41. package/dist/auto-instrumentation/suspension-whitelist.d.ts +0 -33
  42. package/dist/auto-instrumentation/suspension-whitelist.d.ts.map +0 -1
  43. package/dist/auto-instrumentation/transform-source.d.ts +0 -27
  44. package/dist/auto-instrumentation/transform-source.d.ts.map +0 -1
  45. package/dist/auto-instrumentation/verify-instrumentation-isomorphism.d.ts +0 -2
  46. package/dist/auto-instrumentation/verify-instrumentation-isomorphism.d.ts.map +0 -1
  47. package/dist/auto-instrumentation/verify-transformed-source.d.ts +0 -2
  48. package/dist/auto-instrumentation/verify-transformed-source.d.ts.map +0 -1
  49. package/dist/execution-recorder/run-exactly-once.d.ts +0 -7
  50. package/dist/execution-recorder/run-exactly-once.d.ts.map +0 -1
package/dist/internal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/auto-instrumentation/schedule-instrumentation-manifest-upload.ts
2
2
  import {
3
- detectRelease,
3
+ parseReleaseSha,
4
4
  resolveEndpointUrls,
5
5
  uploadInstrumentationManifest
6
6
  } from "@rasputin-ai/core";
@@ -115,14 +115,89 @@ import {
115
115
  sourceLocatorFromFile as sourceLocatorFromFile2
116
116
  } from "@rasputin-ai/core";
117
117
 
118
- // src/execution-recorder/function-plan.ts
118
+ // ../recorder/src/run-exactly-once.ts
119
+ var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
120
+ let outcome;
121
+ const wrapped = function __rasputinHandleRun__3() {
122
+ try {
123
+ const value = callback();
124
+ outcome = { kind: "value", value };
125
+ return value;
126
+ } catch (caught) {
127
+ outcome = { kind: "throw", error: caught };
128
+ throw caught;
129
+ }
130
+ };
131
+ try {
132
+ invoke(wrapped);
133
+ } catch {
134
+ }
135
+ if (outcome?.kind === "throw") throw outcome.error;
136
+ if (outcome?.kind === "value") return outcome.value;
137
+ return callback();
138
+ };
139
+
140
+ // ../recorder/src/call-handle.ts
141
+ var passthroughHandle = () => ({
142
+ leave: (value) => value,
143
+ fail: () => {
144
+ },
145
+ end: () => {
146
+ },
147
+ run: function __rasputinHandleRun__3(callback) {
148
+ return runExactlyOnce((invoke) => invoke(), callback);
149
+ },
150
+ suspend: (value) => value,
151
+ resume: (value) => value
152
+ });
153
+ var isolateHandle = (handle) => ({
154
+ leave: (value) => {
155
+ try {
156
+ return handle.leave(value);
157
+ } catch {
158
+ return value;
159
+ }
160
+ },
161
+ fail: (error, liveArgs) => {
162
+ try {
163
+ handle.fail(error, liveArgs);
164
+ } catch {
165
+ }
166
+ },
167
+ end: () => {
168
+ try {
169
+ handle.end();
170
+ } catch {
171
+ }
172
+ },
173
+ run: function __rasputinHandleRun__3(callback) {
174
+ return runExactlyOnce((invoke) => handle.run(invoke), callback);
175
+ },
176
+ suspend: (value) => {
177
+ try {
178
+ return handle.suspend(value);
179
+ } catch {
180
+ return value;
181
+ }
182
+ },
183
+ resume: (value) => {
184
+ try {
185
+ return handle.resume(value);
186
+ } catch {
187
+ return value;
188
+ }
189
+ }
190
+ });
191
+
192
+ // ../recorder/src/encoded-function-plan.ts
193
+ var encodedPlanOmitsCallValues = (plan) => plan[6] === 1;
194
+ var encodedPlanHasPreBodyParameterEvaluation = (plan) => plan[7] === 1;
195
+
196
+ // ../recorder/src/function-plan.ts
119
197
  import {
120
198
  runtimeFunctionId,
121
199
  sourceLocatorFromFile
122
200
  } from "@rasputin-ai/core";
123
- var encodedPlanOmitsCallValues = (plan) => plan[6] === 1;
124
- var encodedPlanHasPreBodyParameterEvaluation = (plan) => plan[7] === 1;
125
- var EVENT_PAIR_BASE_ESTIMATED_BYTES = 512;
126
201
  var definitionFromEncodedPlan = (plan) => {
127
202
  const [functionId, name, packageName, packageRelativePath, line, column] = plan;
128
203
  const source = packageRelativePath ? {
@@ -138,7 +213,57 @@ var definitionFromEncodedPlan = (plan) => {
138
213
  ...encodedPlanHasPreBodyParameterEvaluation(plan) ? { parentAttribution: "pre_body_parameter_evaluation" } : {}
139
214
  };
140
215
  };
141
- var estimatedCallBytesFor = (functionId) => EVENT_PAIR_BASE_ESTIMATED_BYTES + Buffer.byteLength(functionId, "utf8") * 2;
216
+
217
+ // ../recorder/src/runtime-symbol.ts
218
+ var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
219
+
220
+ // ../recorder/src/registry.ts
221
+ var runtimeSymbol = Symbol.for(AUTOMATIC_RUNTIME_SYMBOL);
222
+ var passthroughRun = (_planIndex, _args, callback) => callback();
223
+ var passthroughEnter = () => passthroughHandle();
224
+ var bindPassthrough = (module) => {
225
+ module.cell.run = passthroughRun;
226
+ module.cell.enter = passthroughEnter;
227
+ };
228
+ var attachRunner = (cell) => {
229
+ const run = ((planIndex, args, callback, omitValues) => cell.run(planIndex, args, callback, omitValues));
230
+ run.enter = (planIndex, args, omitValues, callee) => cell.enter(planIndex, args, omitValues, callee);
231
+ return run;
232
+ };
233
+ var isCompatibleRegistry = (value) => typeof Reflect.get(value, "register") === "function" && Array.isArray(Reflect.get(value, "runtimes")) && Array.isArray(Reflect.get(value, "modules"));
234
+ var registerModule = (registry, plans, moduleIndex) => {
235
+ const cell = { run: passthroughRun, enter: passthroughEnter };
236
+ const module = {
237
+ plans,
238
+ cell,
239
+ ...moduleIndex === void 0 ? {} : { moduleIndex }
240
+ };
241
+ registry.modules.push(module);
242
+ registry.runtimes.at(-1)?.bind(module);
243
+ return attachRunner(cell);
244
+ };
245
+ var createRegistry = () => {
246
+ const registry = {
247
+ runtimes: [],
248
+ modules: [],
249
+ register(plans, moduleIndex) {
250
+ return registerModule(registry, plans, moduleIndex);
251
+ }
252
+ };
253
+ return registry;
254
+ };
255
+ var getAutomaticRuntimeRegistry = () => {
256
+ const existing = Reflect.get(globalThis, runtimeSymbol);
257
+ if (existing && typeof existing === "object" && isCompatibleRegistry(existing)) {
258
+ return existing;
259
+ }
260
+ if (existing != null) {
261
+ return createRegistry();
262
+ }
263
+ const registry = createRegistry();
264
+ Reflect.set(globalThis, runtimeSymbol, registry);
265
+ return registry;
266
+ };
142
267
 
143
268
  // src/auto-instrumentation/instrumentation-manifest-registry.ts
144
269
  var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.v3";
@@ -334,7 +459,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
334
459
  if (!options.enabled || !(options.projectApiKey ?? "").trim()) {
335
460
  return noopHandle;
336
461
  }
337
- const release = detectRelease({ release: options.release });
462
+ const release = parseReleaseSha(options.release);
338
463
  if (!release) return noopHandle;
339
464
  const { instrumentationManifestUrl } = resolveEndpointUrls(options.apiUrl);
340
465
  let inflight = Promise.resolve();
@@ -890,6 +1015,10 @@ var ExecutionJournalPool = class {
890
1015
  }
891
1016
  };
892
1017
 
1018
+ // src/execution-recorder/function-plan.ts
1019
+ var EVENT_PAIR_BASE_ESTIMATED_BYTES = 512;
1020
+ var estimatedCallBytesFor = (functionId) => EVENT_PAIR_BASE_ESTIMATED_BYTES + Buffer.byteLength(functionId, "utf8") * 2;
1021
+
893
1022
  // src/execution-recorder/recorder-memory-budget.ts
894
1023
  var EXECUTION_BASE_ESTIMATED_BYTES = 1024;
895
1024
  var SUMMARY_EVENT_BASE_ESTIMATED_BYTES = 256;
@@ -1025,28 +1154,6 @@ var RecorderMemoryBudget = class {
1025
1154
  }
1026
1155
  };
1027
1156
 
1028
- // src/execution-recorder/run-exactly-once.ts
1029
- var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
1030
- let outcome;
1031
- const wrapped = function __rasputinHandleRun__3() {
1032
- try {
1033
- const value = callback();
1034
- outcome = { kind: "value", value };
1035
- return value;
1036
- } catch (caught) {
1037
- outcome = { kind: "throw", error: caught };
1038
- throw caught;
1039
- }
1040
- };
1041
- try {
1042
- invoke(wrapped);
1043
- } catch {
1044
- }
1045
- if (outcome?.kind === "throw") throw outcome.error;
1046
- if (outcome?.kind === "value") return outcome.value;
1047
- return callback();
1048
- };
1049
-
1050
1157
  // src/execution-recorder/runtime-state-size-budget.ts
1051
1158
  import {
1052
1159
  rasputinUnavailable
@@ -1089,6 +1196,7 @@ var dropEventValues = (events) => {
1089
1196
  const marker = () => rasputinUnavailable(VALUE_OMITTED_REASON);
1090
1197
  const bounded = events.map((event) => {
1091
1198
  if (event.type === "function_enter") {
1199
+ if (event.args === void 0) return { ...event };
1092
1200
  dropped += event.args.length;
1093
1201
  return { ...event, args: event.args.map(marker) };
1094
1202
  }
@@ -2692,7 +2800,10 @@ var createExecutionRecorder = (options) => {
2692
2800
  };
2693
2801
  const encodeEventValues = (events) => events.map((event) => {
2694
2802
  if (event.type === "function_enter") {
2695
- return { ...event, args: event.args.map((argument) => serializer.encode(argument)) };
2803
+ return {
2804
+ ...event,
2805
+ ...event.args === void 0 ? {} : { args: event.args.map((argument) => serializer.encode(argument)) }
2806
+ };
2696
2807
  }
2697
2808
  if (event.type === "function_exit") {
2698
2809
  return { ...event, returnValue: serializer.encode(event.returnValue) };
@@ -2739,7 +2850,7 @@ var createExecutionRecorder = (options) => {
2739
2850
  };
2740
2851
  const eventsHaveOmittedValues = (events) => {
2741
2852
  for (const event of events) {
2742
- if (event.type === "function_enter" && event.args.some((arg) => rasputinTagKind(arg) === "omitted")) {
2853
+ if (event.type === "function_enter" && (event.args ?? []).some((arg) => rasputinTagKind(arg) === "omitted")) {
2743
2854
  return true;
2744
2855
  }
2745
2856
  if (event.type === "function_exit" && rasputinTagKind(event.returnValue) === "omitted") {
@@ -3854,69 +3965,6 @@ var createExecutionRecorder = (options) => {
3854
3965
  };
3855
3966
 
3856
3967
  // src/execution-recorder/automatic-runtime.ts
3857
- var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
3858
- var runtimeSymbol = Symbol.for(AUTOMATIC_RUNTIME_SYMBOL);
3859
- var passthroughHandle = () => ({
3860
- leave: (value) => value,
3861
- fail: () => {
3862
- },
3863
- end: () => {
3864
- },
3865
- run: function __rasputinHandleRun__3(callback) {
3866
- return runExactlyOnce((invoke) => invoke(), callback);
3867
- },
3868
- suspend: (value) => value,
3869
- resume: (value) => value
3870
- });
3871
- var isolateHandle = (handle) => ({
3872
- leave: (value) => {
3873
- try {
3874
- return handle.leave(value);
3875
- } catch {
3876
- return value;
3877
- }
3878
- },
3879
- fail: (error, liveArgs) => {
3880
- try {
3881
- handle.fail(error, liveArgs);
3882
- } catch {
3883
- }
3884
- },
3885
- end: () => {
3886
- try {
3887
- handle.end();
3888
- } catch {
3889
- }
3890
- },
3891
- run: function __rasputinHandleRun__3(callback) {
3892
- return runExactlyOnce((invoke) => handle.run(invoke), callback);
3893
- },
3894
- suspend: (value) => {
3895
- try {
3896
- return handle.suspend(value);
3897
- } catch {
3898
- return value;
3899
- }
3900
- },
3901
- resume: (value) => {
3902
- try {
3903
- return handle.resume(value);
3904
- } catch {
3905
- return value;
3906
- }
3907
- }
3908
- });
3909
- var passthroughRun = (_planIndex, _args, callback) => callback();
3910
- var passthroughEnter = () => passthroughHandle();
3911
- var bindPassthrough = (module) => {
3912
- module.cell.run = passthroughRun;
3913
- module.cell.enter = passthroughEnter;
3914
- };
3915
- var attachRunner = (cell) => {
3916
- const run = ((planIndex, args, callback, omitValues) => cell.run(planIndex, args, callback, omitValues));
3917
- run.enter = (planIndex, args, omitValues) => cell.enter(planIndex, args, omitValues);
3918
- return run;
3919
- };
3920
3968
  var bindExecution = (execution, module) => {
3921
3969
  const prepared = execution.prepareFunctionPlans(module.plans);
3922
3970
  module.cell.run = (planIndex, args, callback, omitValues) => {
@@ -3927,40 +3975,13 @@ var bindExecution = (execution, module) => {
3927
3975
  try {
3928
3976
  const plan = prepared[planIndex];
3929
3977
  return isolateHandle(
3930
- plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughEnter(planIndex, args, omitValues)
3978
+ plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle()
3931
3979
  );
3932
3980
  } catch {
3933
3981
  return passthroughHandle();
3934
3982
  }
3935
3983
  };
3936
3984
  };
3937
- var isRegistry = (value) => Array.isArray(Reflect.get(value, "runtimes")) && Array.isArray(Reflect.get(value, "modules")) && typeof Reflect.get(value, "register") === "function";
3938
- var registerModule = (registry, plans) => {
3939
- const cell = { run: passthroughRun, enter: passthroughEnter };
3940
- const module = { plans, cell };
3941
- registry.modules.push(module);
3942
- registry.runtimes.at(-1)?.bind(module);
3943
- return attachRunner(cell);
3944
- };
3945
- var createRegistry = () => {
3946
- const registry = {
3947
- runtimes: [],
3948
- modules: [],
3949
- register(plans) {
3950
- return registerModule(registry, plans);
3951
- }
3952
- };
3953
- return registry;
3954
- };
3955
- var getAutomaticRuntimeRegistry = () => {
3956
- const existing = Reflect.get(globalThis, runtimeSymbol);
3957
- if (existing && typeof existing === "object" && isRegistry(existing)) {
3958
- return existing;
3959
- }
3960
- const registry = createRegistry();
3961
- Reflect.set(globalThis, runtimeSymbol, registry);
3962
- return registry;
3963
- };
3964
3985
  var installAutomaticExecutionRuntime = (execution) => {
3965
3986
  const registry = getAutomaticRuntimeRegistry();
3966
3987
  const runtime = {
@@ -45,6 +45,7 @@ export type RasputinNodeClient = Omit<RasputinClient, 'getStats'> & {
45
45
  *
46
46
  * @example
47
47
  * RasputinInit({
48
+ * dsn: process.env.RASPUTIN_DSN!,
48
49
  * projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!,
49
50
  * release: process.env.RASPUTIN_RELEASE!,
50
51
  * environment: process.env.NODE_ENV ?? 'development',
@@ -1 +1 @@
1
- {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAMA,OAAO,EAIN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EACtB,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IACnD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG;IAC3D,qFAAqF;IACrF,QAAQ,EAAE,sBAAsB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG;IACnE,+EAA+E;IAC/E,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,EAAE,MAAM,uBAAuB,CAAC;IACxC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACvD,CAAC;AA+DF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,kBAmE3D,CAAC"}
1
+ {"version":3,"file":"rasputin-init.d.ts","sourceRoot":"","sources":["../src/rasputin-init.ts"],"names":[],"mappings":"AAMA,OAAO,EAIN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EACtB,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IACnD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG;IAC3D,qFAAqF;IACrF,QAAQ,EAAE,sBAAsB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG;IACnE,+EAA+E;IAC/E,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,EAAE,MAAM,uBAAuB,CAAC;IACxC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACvD,CAAC;AA+DF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,kBAmE3D,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /** Generated by scripts/generate-sdk-meta.ts — do not edit. */
2
2
  export declare const SDK_NAME = "@rasputin-ai/node";
3
- export declare const SDK_VERSION = "0.5.3";
3
+ export declare const SDK_VERSION = "0.6.1";
4
4
  //# sourceMappingURL=sdk-meta.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasputin-ai/node",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "description": "Official Rasputin AI SDK for Node and Bun.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,11 +49,13 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@jridgewell/trace-mapping": "0.3.31",
52
- "@rasputin-ai/core": "0.5.3",
52
+ "@rasputin-ai/core": "0.6.1",
53
53
  "typescript": "5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@rasputin-ai/core": "workspace:*",
57
+ "@rasputin-ai/instrumentation": "workspace:*",
58
+ "@rasputin-ai/recorder": "workspace:*",
57
59
  "@types/bun": "1.3.14",
58
60
  "@types/node": "22.13.10",
59
61
  "esbuild": "0.25.12"
@@ -1,29 +0,0 @@
1
- /**
2
- * Walks the TypeScript AST while a module is being transformed and records the static facts
3
- * Rasputin needs for replay: instrumented functions, call sites, and parameter destructuring
4
- * bindings. transform-source calls these collectors and passes the delta to the manifest
5
- * registry so the server can map runtime locations back to Git.
6
- */
7
- import type { InstrumentationParamBinding } from '@rasputin-ai/core';
8
- import ts from 'typescript';
9
- import type { RawManifestCallSite, RawManifestDestructure, RawManifestFunction } from './instrumentation-manifest-delta';
10
- type SourceLocation = {
11
- filePath: string;
12
- line: number;
13
- column: number;
14
- };
15
- type SourceLocationMapper = (location: SourceLocation) => SourceLocation | undefined;
16
- type CollectContext = {
17
- sourceFile: ts.SourceFile;
18
- mapLocation?: SourceLocationMapper;
19
- absolutePath: string;
20
- };
21
- export declare const collectFunctionParams: (node: ts.FunctionLikeDeclaration, sourceFile: ts.SourceFile) => {
22
- params: InstrumentationParamBinding[];
23
- paramNames: Set<string>;
24
- };
25
- export declare const mappedLocation: (sourceFile: ts.SourceFile, position: number, absolutePath: string, mapLocation?: SourceLocationMapper) => SourceLocation | undefined;
26
- export declare const collectCallSite: (call: ts.CallExpression | ts.NewExpression, caller: RawManifestFunction, context: CollectContext) => RawManifestCallSite | null;
27
- export declare const collectParamDestructure: (declaration: ts.VariableDeclaration, caller: RawManifestFunction, context: CollectContext) => RawManifestDestructure | null;
28
- export {};
29
- //# sourceMappingURL=collect-instrumentation-delta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collect-instrumentation-delta.d.ts","sourceRoot":"","sources":["../../src/auto-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1
- /**
2
- * One transformed file's contribution to the release manifest: functions, call sites, and
3
- * destructures. The registry concatenates these deltas before upload.
4
- */
5
- import type { InstrumentationArgIdentifier, InstrumentationParamBinding, InstrumentationSkipReason } from '@rasputin-ai/core';
6
- import type { EncodedFunctionPlan } from '../execution-recorder/function-plan';
7
- export type { InstrumentationSkipReason };
8
- export type RawManifestCallSite = {
9
- callerFunctionId: string;
10
- calleeName: string;
11
- calleeText: string;
12
- filePath: string;
13
- line: number;
14
- column: number;
15
- endLine: number;
16
- endColumn: number;
17
- resultBinding: string | null;
18
- argIdentifiers: InstrumentationArgIdentifier[];
19
- };
20
- export type RawManifestDestructure = {
21
- callerFunctionId: string;
22
- sourceParam: string;
23
- filePath: string;
24
- line: number;
25
- column: number;
26
- binding: InstrumentationParamBinding;
27
- };
28
- export type RawManifestFunction = {
29
- plan: EncodedFunctionPlan;
30
- functionId: string;
31
- filePath: string;
32
- name: string;
33
- startLine: number;
34
- startColumn: number;
35
- endLine: number;
36
- endColumn: number;
37
- params: InstrumentationParamBinding[];
38
- paramNames: Set<string>;
39
- instrumented: boolean;
40
- skipReason?: InstrumentationSkipReason;
41
- asyncFunction?: boolean;
42
- };
43
- export type InstrumentationManifestDelta = {
44
- functions: RawManifestFunction[];
45
- callSites: RawManifestCallSite[];
46
- destructures: RawManifestDestructure[];
47
- alreadyInstrumented?: boolean;
48
- };
49
- //# sourceMappingURL=instrumentation-manifest-delta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation-manifest-delta.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/instrumentation-manifest-delta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACX,4BAA4B,EAC5B,2BAA2B,EAC3B,yBAAyB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,MAAM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AAE,OAAO,CAAC;CAC9B,CAAC"}
@@ -1,3 +0,0 @@
1
- import ts from 'typescript';
2
- export declare const functionHasPreBodyParameterEvaluation: (node: ts.SignatureDeclaration) => boolean;
3
- //# sourceMappingURL=parameter-initializer-may-run-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parameter-initializer-may-run-code.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/parameter-initializer-may-run-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAqC5B,eAAO,MAAM,qCAAqC,GAAI,MAAM,EAAE,CAAC,oBAAoB,KAAG,OAOrF,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Phase-1 async instrumentation is a whitelist. Anything we have not proven
3
- * exact — `for await`, `await using`, async generators, unknown future
4
- * syntax — is skipped rather than approximated.
5
- */
6
- import ts from 'typescript';
7
- import type { InstrumentationSkipReason } from './instrumentation-manifest-delta';
8
- export declare const knownSuspensionSyntaxKindNames: () => readonly string[];
9
- export declare const unexpectedSuspensionSyntaxKindNames: () => string[];
10
- export type AsyncInstrumentationAction = {
11
- action: 'skip';
12
- reason: InstrumentationSkipReason;
13
- } | {
14
- action: 'inline';
15
- } | {
16
- action: 'suspend_resume';
17
- };
18
- type FunctionLike = ts.FunctionLikeDeclaration;
19
- export declare const isAsyncFunctionLike: (node: FunctionLike) => boolean;
20
- export declare const isAsyncGeneratorLike: (node: ts.Node) => node is FunctionLike;
21
- export declare const isSyncGeneratorLike: (node: ts.Node) => node is FunctionLike;
22
- export declare const ownBodyHasAwaitKeyword: (node: FunctionLike, sourceFile: ts.SourceFile) => boolean;
23
- export type OwnSuspensionFacts = {
24
- awaitExpressions: boolean;
25
- forAwait: boolean;
26
- awaitUsing: boolean;
27
- unknown: boolean;
28
- awaitKeyword: boolean;
29
- };
30
- export declare const ownSuspensionFacts: (node: FunctionLike, sourceFile: ts.SourceFile) => OwnSuspensionFacts;
31
- export declare const decideAsyncInstrumentation: (node: FunctionLike, sourceFile: ts.SourceFile) => AsyncInstrumentationAction;
32
- export {};
33
- //# sourceMappingURL=suspension-whitelist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suspension-whitelist.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/suspension-whitelist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAclF,eAAO,MAAM,8BAA8B,QAAO,SAAS,MAAM,EAAiC,CAAC;AAEnG,eAAO,MAAM,mCAAmC,QAAO,MAAM,EAU5D,CAAC;AAEF,MAAM,MAAM,0BAA0B,GACnC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,yBAAyB,CAAA;CAAE,GACrD;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEhC,KAAK,YAAY,GAAG,EAAE,CAAC,uBAAuB,CAAC;AAI/C,eAAO,MAAM,mBAAmB,GAAI,MAAM,YAAY,KAAG,OACU,CAAC;AAEpE,eAAO,MAAM,oBAAoB,GAAI,MAAM,EAAE,CAAC,IAAI,KAAG,IAAI,IAAI,YAIjC,CAAC;AAE7B,eAAO,MAAM,mBAAmB,GAAI,MAAM,EAAE,CAAC,IAAI,KAAG,IAAI,IAAI,YAIjC,CAAC;AAgE5B,eAAO,MAAM,sBAAsB,GAAI,MAAM,YAAY,EAAE,YAAY,EAAE,CAAC,UAAU,KAAG,OAOtF,CAAC;AAgBF,MAAM,MAAM,kBAAkB,GAAG;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC9B,MAAM,YAAY,EAClB,YAAY,EAAE,CAAC,UAAU,KACvB,kBAkBF,CAAC;AAiBF,eAAO,MAAM,0BAA0B,GACtC,MAAM,YAAY,EAClB,YAAY,EAAE,CAAC,UAAU,KACvB,0BAcF,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Shared source transformer for every runtime adapter. Keeping event injection independent from Bun,
3
- * Node, and future build-tool integrations is what lets each environment produce the same execution
4
- * tree and keeps recorder semantics from drifting between platforms.
5
- */
6
- import type { InstrumentationManifestDelta } from './instrumentation-manifest-delta';
7
- export type TransformSourceOptions = {
8
- filePath: string;
9
- mapLocation?: SourceLocationMapper;
10
- verifyTransform?: boolean;
11
- };
12
- export declare const RASPUTIN_INSTRUMENTATION_MARKER = "rasputin.instrumented.v3";
13
- export declare const RASPUTIN_INSTRUMENTATION_PREAMBLE = "/*rasputin.instrumented.v3*/";
14
- export declare const sourceIsRasputinInstrumented: (source: string) => boolean;
15
- export type TransformedSource = {
16
- code: string;
17
- delta: InstrumentationManifestDelta;
18
- };
19
- export type SourceLocation = {
20
- filePath: string;
21
- line: number;
22
- column: number;
23
- };
24
- export type SourceLocationMapper = (location: SourceLocation) => SourceLocation | undefined;
25
- /** Add low-overhead function-boundary hooks while preserving the customer's source lines. */
26
- export declare const transformSource: (source: string, options: TransformSourceOptions) => TransformedSource | undefined;
27
- //# sourceMappingURL=transform-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-source.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/transform-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,KAAK,EACX,4BAA4B,EAE5B,MAAM,kCAAkC,CAAC;AAwC1C,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAC1E,eAAO,MAAM,iCAAiC,iCAA2C,CAAC;AAE1F,eAAO,MAAM,4BAA4B,GAAI,QAAQ,MAAM,KAAG,OACX,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,4BAA4B,CAAC;CACpC,CAAC;AAOF,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,cAAc,KAAK,cAAc,GAAG,SAAS,CAAC;AAwgB5F,6FAA6F;AAC7F,eAAO,MAAM,eAAe,GAC3B,QAAQ,MAAM,EACd,SAAS,sBAAsB,KAC7B,iBAAiB,GAAG,SAwOtB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const instrumentationTreesAreIsomorphic: (filePath: string, original: string, transformed: string) => boolean;
2
- //# sourceMappingURL=verify-instrumentation-isomorphism.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-instrumentation-isomorphism.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/verify-instrumentation-isomorphism.ts"],"names":[],"mappings":"AA8KA,eAAO,MAAM,iCAAiC,GAC7C,UAAU,MAAM,EAChB,UAAU,MAAM,EAChB,aAAa,MAAM,KACjB,OAGF,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const transformedSourceIsInvalid: (filePath: string, code: string) => boolean;
2
- //# sourceMappingURL=verify-transformed-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-transformed-source.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/verify-transformed-source.ts"],"names":[],"mappings":"AAuIA,eAAO,MAAM,0BAA0B,GAAI,UAAU,MAAM,EAAE,MAAM,MAAM,KAAG,OAgB3E,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Run `callback` exactly once even when the store primitive throws. Used by
3
- * generated `H.run` so a Rasputin ALS failure cannot skip or double-run the
4
- * customer body, or replace its result.
5
- */
6
- export declare const runExactlyOnce: <T>(invoke: (callback: () => T) => T, callback: () => T) => T;
7
- //# sourceMappingURL=run-exactly-once.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-exactly-once.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/run-exactly-once.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAkC,CAAC,EAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EAChC,UAAU,MAAM,CAAC,KACf,CAoBF,CAAC"}