@rasputin-ai/node 0.12.0 → 0.12.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.
@@ -1 +1 @@
1
- {"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAEX,wBAAwB,EACxB,gBAAgB,EAGhB,MAAM,4BAA4B,CAAC;AAmRpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,EAC7C,QAAO,sBAA2B,KAChC,gBAy3DF,CAAC"}
1
+ {"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAEX,wBAAwB,EACxB,gBAAgB,EAGhB,MAAM,4BAA4B,CAAC;AAmRpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,EAC7C,QAAO,sBAA2B,KAChC,gBA05DF,CAAC"}
package/dist/index.js CHANGED
@@ -3017,11 +3017,14 @@ var createExecutionRecorder = (options, hooks = {}) => {
3017
3017
  };
3018
3018
  const skipCapture = (store, plan) => store.suppressCapture || plan.excluded || Boolean(store.recording.sessionExcludes?.(plan.definition));
3019
3019
  const durationSamplingApplies = (recording) => durationSamplingEnabled && recording.identityResolved === true && !recording.captureValues && !recording.retainSuccess;
3020
- const callerStore = (store, functionId, callId) => ({
3021
- ...store,
3022
- currentFunctionId: functionId,
3023
- ...callId === void 0 ? {} : { currentCallId: callId }
3024
- });
3020
+ const callStoreFor = (store, functionId, callId) => {
3021
+ const next = { ...store, currentCallId: callId };
3022
+ if (durationSamplingEnabled) next.currentFunctionId = functionId;
3023
+ return next;
3024
+ };
3025
+ const samplingStore = (store, functionId) => {
3026
+ return durationSamplingEnabled ? { ...store, currentFunctionId: functionId } : store;
3027
+ };
3025
3028
  const decideCallTiming = (recording, plan, callerFunctionId) => {
3026
3029
  if (!durationSamplingApplies(recording) || !durationSamples) return true;
3027
3030
  const typeKey = executionTypeKey(recording.execution);
@@ -3821,7 +3824,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3821
3824
  const startedAtNs2 = timed ? readCallClock() : 0n;
3822
3825
  try {
3823
3826
  const result = runStore(
3824
- callerStore(store, plan.functionId),
3827
+ samplingStore(store, plan.functionId),
3825
3828
  function __rasputinHandleRun__5() {
3826
3829
  return callback();
3827
3830
  }
@@ -3845,7 +3848,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3845
3848
  const startedAtNs = timed ? readCallClock() : 0n;
3846
3849
  if (!journal) {
3847
3850
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3848
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3851
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3849
3852
  return observeRecordedCallback(
3850
3853
  recording,
3851
3854
  recorderStartedAtNs,
@@ -3864,7 +3867,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3864
3867
  countDroppedEvents(recording, droppedBefore);
3865
3868
  settleInFlight(recording);
3866
3869
  };
3867
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3870
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3868
3871
  return observeRecordedCallback(
3869
3872
  recording,
3870
3873
  recorderStartedAtNs,
@@ -3878,7 +3881,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3878
3881
  });
3879
3882
  }
3880
3883
  if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
3881
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3884
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3882
3885
  return observeRecordedCallback(
3883
3886
  recording,
3884
3887
  recorderStartedAtNs,
@@ -3897,7 +3900,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3897
3900
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3898
3901
  } catch {
3899
3902
  journal.dropCall();
3900
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3903
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3901
3904
  return observeRecordedCallback(
3902
3905
  recording,
3903
3906
  recorderStartedAtNs,
@@ -3909,7 +3912,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3909
3912
  );
3910
3913
  });
3911
3914
  }
3912
- const callStore = callerStore(store, plan.functionId, callId);
3915
+ const callStore = callStoreFor(store, plan.functionId, callId);
3913
3916
  return runStore(callStore, function __rasputinHandleRun__5() {
3914
3917
  return observeRecordedCallback(
3915
3918
  recording,
@@ -3981,6 +3984,25 @@ var createExecutionRecorder = (options, hooks = {}) => {
3981
3984
  this.parentStore = parentStore;
3982
3985
  this.group = group;
3983
3986
  this.captureDroppedThrow = captureDroppedThrow;
3987
+ this.callerClaimed = false;
3988
+ }
3989
+ claimCaller() {
3990
+ if (this.callerClaimed || !durationSamplingEnabled || !this.plan) return;
3991
+ if (this.activeStore !== this.parentStore) return;
3992
+ this.previousFunctionId = this.parentStore.currentFunctionId;
3993
+ this.parentStore.currentFunctionId = this.plan.functionId;
3994
+ this.callerClaimed = true;
3995
+ }
3996
+ reclaimCaller() {
3997
+ if (!durationSamplingEnabled || !this.plan || this.activeStore !== this.parentStore) return;
3998
+ this.parentStore.currentFunctionId = this.plan.functionId;
3999
+ this.callerClaimed = true;
4000
+ }
4001
+ releaseCaller() {
4002
+ if (!this.callerClaimed) return;
4003
+ this.callerClaimed = false;
4004
+ if (this.previousFunctionId === void 0) delete this.parentStore.currentFunctionId;
4005
+ else this.parentStore.currentFunctionId = this.previousFunctionId;
3984
4006
  }
3985
4007
  leave(value) {
3986
4008
  try {
@@ -4050,6 +4072,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4050
4072
  try {
4051
4073
  if (this.ended) return;
4052
4074
  this.ended = true;
4075
+ this.releaseCaller();
4053
4076
  if (this.mode !== "excluded") settleInFlight(this.recording);
4054
4077
  expectStore(this, this.activeStore);
4055
4078
  enterStore(this, this.parentStore);
@@ -4073,6 +4096,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4073
4096
  try {
4074
4097
  expectStore(this, this.activeStore);
4075
4098
  this.suspended = true;
4099
+ this.releaseCaller();
4076
4100
  enterStore(this, this.parentStore);
4077
4101
  return value;
4078
4102
  } catch {
@@ -4086,6 +4110,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4086
4110
  expectStore(this, this.parentStore);
4087
4111
  this.suspended = false;
4088
4112
  enterStore(this, this.activeStore);
4113
+ this.reclaimCaller();
4089
4114
  } else {
4090
4115
  expectStore(this, this.activeStore);
4091
4116
  }
@@ -4144,12 +4169,11 @@ var createExecutionRecorder = (options, hooks = {}) => {
4144
4169
  capturedError.commit();
4145
4170
  };
4146
4171
  const activateUncaptured = (mode, recording, parentStore, plan, args, omitCallValues, parentCallId, startedAtNs, timed, group, captureDroppedThrow) => {
4147
- const activeStore = callerStore(parentStore, plan.functionId);
4148
4172
  const frame = new CallFrame(
4149
4173
  mode,
4150
4174
  recording,
4151
4175
  parentStore,
4152
- activeStore,
4176
+ parentStore,
4153
4177
  plan,
4154
4178
  args,
4155
4179
  omitCallValues,
@@ -4160,7 +4184,8 @@ var createExecutionRecorder = (options, hooks = {}) => {
4160
4184
  group,
4161
4185
  captureDroppedThrow
4162
4186
  );
4163
- enterStore(frame, activeStore);
4187
+ frame.claimCaller();
4188
+ enterStore(frame, parentStore);
4164
4189
  return frame;
4165
4190
  };
4166
4191
  const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
@@ -4307,7 +4332,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4307
4332
  false
4308
4333
  );
4309
4334
  }
4310
- const callStore = callerStore(store, plan.functionId, callId);
4335
+ const callStore = callStoreFor(store, plan.functionId, callId);
4311
4336
  const captured = new CallFrame(
4312
4337
  "captured",
4313
4338
  recording,
@@ -5466,7 +5491,7 @@ var installGlobalHandlers = (client, options = {}) => {
5466
5491
 
5467
5492
  // src/sdk-meta.ts
5468
5493
  var SDK_NAME = "@rasputin-ai/node";
5469
- var SDK_VERSION = "0.12.0";
5494
+ var SDK_VERSION = "0.12.1";
5470
5495
 
5471
5496
  // src/rasputin-init.ts
5472
5497
  var publicExecution = (runtime) => ({
@@ -1606,7 +1606,7 @@ import ts14 from "typescript";
1606
1606
  import { originalPositionFor as originalPositionFor2, TraceMap as TraceMap3 } from "@jridgewell/trace-mapping";
1607
1607
 
1608
1608
  // src/sdk-meta.ts
1609
- var SDK_VERSION = "0.12.0";
1609
+ var SDK_VERSION = "0.12.1";
1610
1610
 
1611
1611
  // src/auto-instrumentation/source-map-locations.ts
1612
1612
  import { readFileSync } from "node:fs";
@@ -1668,7 +1668,7 @@ import ts14 from "typescript";
1668
1668
  import { originalPositionFor as originalPositionFor3, TraceMap as TraceMap4 } from "@jridgewell/trace-mapping";
1669
1669
 
1670
1670
  // src/sdk-meta.ts
1671
- var SDK_VERSION = "0.12.0";
1671
+ var SDK_VERSION = "0.12.1";
1672
1672
 
1673
1673
  // src/auto-instrumentation/transform-disk-cache.ts
1674
1674
  var projectCacheDir = () => {
package/dist/internal.js CHANGED
@@ -2987,11 +2987,14 @@ var createExecutionRecorder = (options, hooks = {}) => {
2987
2987
  };
2988
2988
  const skipCapture = (store, plan) => store.suppressCapture || plan.excluded || Boolean(store.recording.sessionExcludes?.(plan.definition));
2989
2989
  const durationSamplingApplies = (recording) => durationSamplingEnabled && recording.identityResolved === true && !recording.captureValues && !recording.retainSuccess;
2990
- const callerStore = (store, functionId, callId) => ({
2991
- ...store,
2992
- currentFunctionId: functionId,
2993
- ...callId === void 0 ? {} : { currentCallId: callId }
2994
- });
2990
+ const callStoreFor = (store, functionId, callId) => {
2991
+ const next = { ...store, currentCallId: callId };
2992
+ if (durationSamplingEnabled) next.currentFunctionId = functionId;
2993
+ return next;
2994
+ };
2995
+ const samplingStore = (store, functionId) => {
2996
+ return durationSamplingEnabled ? { ...store, currentFunctionId: functionId } : store;
2997
+ };
2995
2998
  const decideCallTiming = (recording, plan, callerFunctionId) => {
2996
2999
  if (!durationSamplingApplies(recording) || !durationSamples) return true;
2997
3000
  const typeKey = executionTypeKey(recording.execution);
@@ -3791,7 +3794,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3791
3794
  const startedAtNs2 = timed ? readCallClock() : 0n;
3792
3795
  try {
3793
3796
  const result = runStore(
3794
- callerStore(store, plan.functionId),
3797
+ samplingStore(store, plan.functionId),
3795
3798
  function __rasputinHandleRun__5() {
3796
3799
  return callback();
3797
3800
  }
@@ -3815,7 +3818,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3815
3818
  const startedAtNs = timed ? readCallClock() : 0n;
3816
3819
  if (!journal) {
3817
3820
  memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
3818
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3821
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3819
3822
  return observeRecordedCallback(
3820
3823
  recording,
3821
3824
  recorderStartedAtNs,
@@ -3834,7 +3837,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3834
3837
  countDroppedEvents(recording, droppedBefore);
3835
3838
  settleInFlight(recording);
3836
3839
  };
3837
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3840
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3838
3841
  return observeRecordedCallback(
3839
3842
  recording,
3840
3843
  recorderStartedAtNs,
@@ -3848,7 +3851,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3848
3851
  });
3849
3852
  }
3850
3853
  if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
3851
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3854
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3852
3855
  return observeRecordedCallback(
3853
3856
  recording,
3854
3857
  recorderStartedAtNs,
@@ -3867,7 +3870,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3867
3870
  journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
3868
3871
  } catch {
3869
3872
  journal.dropCall();
3870
- return runStore(callerStore(store, plan.functionId), function __rasputinHandleRun__5() {
3873
+ return runStore(samplingStore(store, plan.functionId), function __rasputinHandleRun__5() {
3871
3874
  return observeRecordedCallback(
3872
3875
  recording,
3873
3876
  recorderStartedAtNs,
@@ -3879,7 +3882,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
3879
3882
  );
3880
3883
  });
3881
3884
  }
3882
- const callStore = callerStore(store, plan.functionId, callId);
3885
+ const callStore = callStoreFor(store, plan.functionId, callId);
3883
3886
  return runStore(callStore, function __rasputinHandleRun__5() {
3884
3887
  return observeRecordedCallback(
3885
3888
  recording,
@@ -3951,6 +3954,25 @@ var createExecutionRecorder = (options, hooks = {}) => {
3951
3954
  this.parentStore = parentStore;
3952
3955
  this.group = group;
3953
3956
  this.captureDroppedThrow = captureDroppedThrow;
3957
+ this.callerClaimed = false;
3958
+ }
3959
+ claimCaller() {
3960
+ if (this.callerClaimed || !durationSamplingEnabled || !this.plan) return;
3961
+ if (this.activeStore !== this.parentStore) return;
3962
+ this.previousFunctionId = this.parentStore.currentFunctionId;
3963
+ this.parentStore.currentFunctionId = this.plan.functionId;
3964
+ this.callerClaimed = true;
3965
+ }
3966
+ reclaimCaller() {
3967
+ if (!durationSamplingEnabled || !this.plan || this.activeStore !== this.parentStore) return;
3968
+ this.parentStore.currentFunctionId = this.plan.functionId;
3969
+ this.callerClaimed = true;
3970
+ }
3971
+ releaseCaller() {
3972
+ if (!this.callerClaimed) return;
3973
+ this.callerClaimed = false;
3974
+ if (this.previousFunctionId === void 0) delete this.parentStore.currentFunctionId;
3975
+ else this.parentStore.currentFunctionId = this.previousFunctionId;
3954
3976
  }
3955
3977
  leave(value) {
3956
3978
  try {
@@ -4020,6 +4042,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4020
4042
  try {
4021
4043
  if (this.ended) return;
4022
4044
  this.ended = true;
4045
+ this.releaseCaller();
4023
4046
  if (this.mode !== "excluded") settleInFlight(this.recording);
4024
4047
  expectStore(this, this.activeStore);
4025
4048
  enterStore(this, this.parentStore);
@@ -4043,6 +4066,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4043
4066
  try {
4044
4067
  expectStore(this, this.activeStore);
4045
4068
  this.suspended = true;
4069
+ this.releaseCaller();
4046
4070
  enterStore(this, this.parentStore);
4047
4071
  return value;
4048
4072
  } catch {
@@ -4056,6 +4080,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4056
4080
  expectStore(this, this.parentStore);
4057
4081
  this.suspended = false;
4058
4082
  enterStore(this, this.activeStore);
4083
+ this.reclaimCaller();
4059
4084
  } else {
4060
4085
  expectStore(this, this.activeStore);
4061
4086
  }
@@ -4114,12 +4139,11 @@ var createExecutionRecorder = (options, hooks = {}) => {
4114
4139
  capturedError.commit();
4115
4140
  };
4116
4141
  const activateUncaptured = (mode, recording, parentStore, plan, args, omitCallValues, parentCallId, startedAtNs, timed, group, captureDroppedThrow) => {
4117
- const activeStore = callerStore(parentStore, plan.functionId);
4118
4142
  const frame = new CallFrame(
4119
4143
  mode,
4120
4144
  recording,
4121
4145
  parentStore,
4122
- activeStore,
4146
+ parentStore,
4123
4147
  plan,
4124
4148
  args,
4125
4149
  omitCallValues,
@@ -4130,7 +4154,8 @@ var createExecutionRecorder = (options, hooks = {}) => {
4130
4154
  group,
4131
4155
  captureDroppedThrow
4132
4156
  );
4133
- enterStore(frame, activeStore);
4157
+ frame.claimCaller();
4158
+ enterStore(frame, parentStore);
4134
4159
  return frame;
4135
4160
  };
4136
4161
  const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
@@ -4277,7 +4302,7 @@ var createExecutionRecorder = (options, hooks = {}) => {
4277
4302
  false
4278
4303
  );
4279
4304
  }
4280
- const callStore = callerStore(store, plan.functionId, callId);
4305
+ const callStore = callStoreFor(store, plan.functionId, callId);
4281
4306
  const captured = new CallFrame(
4282
4307
  "captured",
4283
4308
  recording,
@@ -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.12.0";
3
+ export declare const SDK_VERSION = "0.12.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.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Official Rasputin AI SDK for Node and Bun.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@jridgewell/trace-mapping": "0.3.31",
52
- "@rasputin-ai/core": "0.12.0",
52
+ "@rasputin-ai/core": "0.12.1",
53
53
  "typescript": "5"
54
54
  },
55
55
  "devDependencies": {