@rasputin-ai/node 0.11.1 → 0.11.2

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-recording-sync.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recording-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,KAAK,cAAc,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,KAAK,EAEX,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAe9F,KAAK,6BAA6B,GAAG,uBAAuB,GAAG;IAC9D,YAAY,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5D,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC7F,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC7D,CAAC;AAEF,KAAK,oCAAoC,GAAG;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA+BF,eAAO,MAAM,mCAAmC,GAC/C,SAAS,oCAAoC,KAC3C,6BAsrBF,CAAC"}
1
+ {"version":3,"file":"execution-recording-sync.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recording-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,KAAK,cAAc,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,KAAK,EAEX,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAe9F,KAAK,6BAA6B,GAAG,uBAAuB,GAAG;IAC9D,YAAY,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5D,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC7F,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC7D,CAAC;AAEF,KAAK,oCAAoC,GAAG;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAwCF,eAAO,MAAM,mCAAmC,GAC/C,SAAS,oCAAoC,KAC3C,6BA0rBF,CAAC"}
package/dist/index.js CHANGED
@@ -4429,6 +4429,12 @@ var classifyHttpFailure = (status) => {
4429
4429
  return "non_retryable_http";
4430
4430
  };
4431
4431
  var backoffMs = (attempt) => Math.min(3e3, 250 * 2 ** attempt);
4432
+ var abortFrom = (parent, child) => {
4433
+ const onAbort = () => child.abort();
4434
+ parent.addEventListener("abort", onAbort, { once: true });
4435
+ if (parent.aborted) onAbort();
4436
+ return () => parent.removeEventListener("abort", onAbort);
4437
+ };
4432
4438
  var createExecutionRecordingCoordinator = (options) => {
4433
4439
  const environment = trimmed2(options.environment);
4434
4440
  const nowMs = () => options.nowMs?.() ?? Date.now();
@@ -4547,7 +4553,6 @@ var createExecutionRecordingCoordinator = (options) => {
4547
4553
  if (onAbort) signal.removeEventListener("abort", onAbort);
4548
4554
  }
4549
4555
  };
4550
- const workSignal = (signal) => AbortSignal.any([signal, cancelWork.signal]);
4551
4556
  const interruptWork = () => {
4552
4557
  cancelWork.abort();
4553
4558
  cancelWork = new AbortController();
@@ -4570,19 +4575,17 @@ var createExecutionRecordingCoordinator = (options) => {
4570
4575
  });
4571
4576
  };
4572
4577
  const withRequestTimeout = async (signal, run) => {
4573
- const combined = workSignal(signal);
4574
- const timeout = new AbortController();
4575
- const timer = setTimeout(() => timeout.abort(), REQUEST_TIMEOUT_MS);
4578
+ const request = new AbortController();
4579
+ const timer = setTimeout(() => request.abort(), REQUEST_TIMEOUT_MS);
4576
4580
  timer.unref?.();
4577
- const onAbort = () => timeout.abort();
4578
- combined.addEventListener("abort", onAbort, { once: true });
4579
- if (combined.aborted) timeout.abort();
4580
- const requestSignal = AbortSignal.any([combined, timeout.signal]);
4581
+ const stopParent = abortFrom(signal, request);
4582
+ const stopCancel = abortFrom(cancelWork.signal, request);
4581
4583
  try {
4582
- return await run(requestSignal);
4584
+ return await run(request.signal);
4583
4585
  } finally {
4584
4586
  clearTimeout(timer);
4585
- combined.removeEventListener("abort", onAbort);
4587
+ stopParent();
4588
+ stopCancel();
4586
4589
  }
4587
4590
  };
4588
4591
  const postEncoded = async (url, encoded, signal, readBody) => withRequestTimeout(signal, async (requestSignal) => {
@@ -4835,73 +4838,81 @@ var createExecutionRecordingCoordinator = (options) => {
4835
4838
  await joinUntil(flight, signal);
4836
4839
  };
4837
4840
  const sendRecordings = async (batch, signal) => {
4838
- const combined = workSignal(signal);
4839
- if (combined.aborted) return false;
4840
- let encoded;
4841
+ const followed = new AbortController();
4842
+ const stopParent = abortFrom(signal, followed);
4843
+ const stopCancel = abortFrom(cancelWork.signal, followed);
4844
+ const combined = followed.signal;
4841
4845
  try {
4842
- encoded = await encodeJsonRequestBodyAsync(
4843
- {
4844
- instance_id: instanceId,
4845
- recordings: batch.map((item) => ({
4846
- session_id: item.sessionId,
4847
- execution_id: item.executionId,
4848
- outcome: item.outcome,
4849
- runtime_state: item.runtimeState,
4850
- release: options.release,
4851
- redact_keys: copyRedactKeys([...redactKeys ?? [], ...item.redactKeys ?? []])?.slice(
4852
- 0,
4853
- MAX_REDACT_KEYS
4854
- ),
4855
- scrub_pii: item.scrubPii ?? scrubPii
4856
- }))
4857
- },
4858
- void 0,
4859
- combined
4860
- );
4861
- } catch (error) {
4862
- if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4863
- rememberFailure("aborted");
4864
- return false;
4865
- }
4866
- rememberFailure("network_error");
4867
- return false;
4868
- }
4869
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4870
4846
  if (combined.aborted) return false;
4847
+ let encoded;
4871
4848
  try {
4872
- const { response, body } = await postEncoded(
4873
- options.recordingsUrl,
4874
- encoded,
4875
- combined,
4876
- async (uploadResponse) => {
4877
- if (!uploadResponse.ok) return void 0;
4878
- try {
4879
- return unwrapPayload(await uploadResponse.json());
4880
- } catch {
4881
- return void 0;
4882
- }
4883
- }
4849
+ encoded = await encodeJsonRequestBodyAsync(
4850
+ {
4851
+ instance_id: instanceId,
4852
+ recordings: batch.map((item) => ({
4853
+ session_id: item.sessionId,
4854
+ execution_id: item.executionId,
4855
+ outcome: item.outcome,
4856
+ runtime_state: item.runtimeState,
4857
+ release: options.release,
4858
+ redact_keys: copyRedactKeys([
4859
+ ...redactKeys ?? [],
4860
+ ...item.redactKeys ?? []
4861
+ ])?.slice(0, MAX_REDACT_KEYS),
4862
+ scrub_pii: item.scrubPii ?? scrubPii
4863
+ }))
4864
+ },
4865
+ void 0,
4866
+ combined
4884
4867
  );
4885
- if (response.ok) {
4886
- applyCompletedSessionIds(body?.completed_session_ids);
4887
- return true;
4888
- }
4889
- const kind = classifyHttpFailure(response.status);
4890
- rememberFailure(kind);
4891
- if (kind === "non_retryable_http") return true;
4892
- if (attempt === MAX_RETRIES) return false;
4893
- await wait(backoffMs(attempt), combined);
4894
4868
  } catch (error) {
4895
4869
  if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4896
4870
  rememberFailure("aborted");
4897
4871
  return false;
4898
4872
  }
4899
4873
  rememberFailure("network_error");
4900
- if (attempt === MAX_RETRIES) return false;
4901
- await wait(backoffMs(attempt), combined);
4874
+ return false;
4902
4875
  }
4876
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4877
+ if (combined.aborted) return false;
4878
+ try {
4879
+ const { response, body } = await postEncoded(
4880
+ options.recordingsUrl,
4881
+ encoded,
4882
+ combined,
4883
+ async (uploadResponse) => {
4884
+ if (!uploadResponse.ok) return void 0;
4885
+ try {
4886
+ return unwrapPayload(await uploadResponse.json());
4887
+ } catch {
4888
+ return void 0;
4889
+ }
4890
+ }
4891
+ );
4892
+ if (response.ok) {
4893
+ applyCompletedSessionIds(body?.completed_session_ids);
4894
+ return true;
4895
+ }
4896
+ const kind = classifyHttpFailure(response.status);
4897
+ rememberFailure(kind);
4898
+ if (kind === "non_retryable_http") return true;
4899
+ if (attempt === MAX_RETRIES) return false;
4900
+ await wait(backoffMs(attempt), combined);
4901
+ } catch (error) {
4902
+ if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4903
+ rememberFailure("aborted");
4904
+ return false;
4905
+ }
4906
+ rememberFailure("network_error");
4907
+ if (attempt === MAX_RETRIES) return false;
4908
+ await wait(backoffMs(attempt), combined);
4909
+ }
4910
+ }
4911
+ return false;
4912
+ } finally {
4913
+ stopParent();
4914
+ stopCancel();
4903
4915
  }
4904
- return false;
4905
4916
  };
4906
4917
  const drainRecordings = async (signal) => {
4907
4918
  while (recordings.length > 0 && !signal.aborted) {
@@ -5233,7 +5244,7 @@ var installGlobalHandlers = (client, options = {}) => {
5233
5244
 
5234
5245
  // src/sdk-meta.ts
5235
5246
  var SDK_NAME = "@rasputin-ai/node";
5236
- var SDK_VERSION = "0.11.1";
5247
+ var SDK_VERSION = "0.11.2";
5237
5248
 
5238
5249
  // src/rasputin-init.ts
5239
5250
  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.11.1";
1609
+ var SDK_VERSION = "0.11.2";
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.11.1";
1671
+ var SDK_VERSION = "0.11.2";
1672
1672
 
1673
1673
  // src/auto-instrumentation/transform-disk-cache.ts
1674
1674
  var projectCacheDir = () => {
package/dist/internal.js CHANGED
@@ -4399,6 +4399,12 @@ var classifyHttpFailure = (status) => {
4399
4399
  return "non_retryable_http";
4400
4400
  };
4401
4401
  var backoffMs = (attempt) => Math.min(3e3, 250 * 2 ** attempt);
4402
+ var abortFrom = (parent, child) => {
4403
+ const onAbort = () => child.abort();
4404
+ parent.addEventListener("abort", onAbort, { once: true });
4405
+ if (parent.aborted) onAbort();
4406
+ return () => parent.removeEventListener("abort", onAbort);
4407
+ };
4402
4408
  var createExecutionRecordingCoordinator = (options) => {
4403
4409
  const environment = trimmed2(options.environment);
4404
4410
  const nowMs = () => options.nowMs?.() ?? Date.now();
@@ -4517,7 +4523,6 @@ var createExecutionRecordingCoordinator = (options) => {
4517
4523
  if (onAbort) signal.removeEventListener("abort", onAbort);
4518
4524
  }
4519
4525
  };
4520
- const workSignal = (signal) => AbortSignal.any([signal, cancelWork.signal]);
4521
4526
  const interruptWork = () => {
4522
4527
  cancelWork.abort();
4523
4528
  cancelWork = new AbortController();
@@ -4540,19 +4545,17 @@ var createExecutionRecordingCoordinator = (options) => {
4540
4545
  });
4541
4546
  };
4542
4547
  const withRequestTimeout = async (signal, run) => {
4543
- const combined = workSignal(signal);
4544
- const timeout = new AbortController();
4545
- const timer = setTimeout(() => timeout.abort(), REQUEST_TIMEOUT_MS);
4548
+ const request = new AbortController();
4549
+ const timer = setTimeout(() => request.abort(), REQUEST_TIMEOUT_MS);
4546
4550
  timer.unref?.();
4547
- const onAbort = () => timeout.abort();
4548
- combined.addEventListener("abort", onAbort, { once: true });
4549
- if (combined.aborted) timeout.abort();
4550
- const requestSignal = AbortSignal.any([combined, timeout.signal]);
4551
+ const stopParent = abortFrom(signal, request);
4552
+ const stopCancel = abortFrom(cancelWork.signal, request);
4551
4553
  try {
4552
- return await run(requestSignal);
4554
+ return await run(request.signal);
4553
4555
  } finally {
4554
4556
  clearTimeout(timer);
4555
- combined.removeEventListener("abort", onAbort);
4557
+ stopParent();
4558
+ stopCancel();
4556
4559
  }
4557
4560
  };
4558
4561
  const postEncoded = async (url, encoded, signal, readBody) => withRequestTimeout(signal, async (requestSignal) => {
@@ -4805,73 +4808,81 @@ var createExecutionRecordingCoordinator = (options) => {
4805
4808
  await joinUntil(flight, signal);
4806
4809
  };
4807
4810
  const sendRecordings = async (batch, signal) => {
4808
- const combined = workSignal(signal);
4809
- if (combined.aborted) return false;
4810
- let encoded;
4811
+ const followed = new AbortController();
4812
+ const stopParent = abortFrom(signal, followed);
4813
+ const stopCancel = abortFrom(cancelWork.signal, followed);
4814
+ const combined = followed.signal;
4811
4815
  try {
4812
- encoded = await encodeJsonRequestBodyAsync(
4813
- {
4814
- instance_id: instanceId,
4815
- recordings: batch.map((item) => ({
4816
- session_id: item.sessionId,
4817
- execution_id: item.executionId,
4818
- outcome: item.outcome,
4819
- runtime_state: item.runtimeState,
4820
- release: options.release,
4821
- redact_keys: copyRedactKeys([...redactKeys ?? [], ...item.redactKeys ?? []])?.slice(
4822
- 0,
4823
- MAX_REDACT_KEYS
4824
- ),
4825
- scrub_pii: item.scrubPii ?? scrubPii
4826
- }))
4827
- },
4828
- void 0,
4829
- combined
4830
- );
4831
- } catch (error) {
4832
- if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4833
- rememberFailure("aborted");
4834
- return false;
4835
- }
4836
- rememberFailure("network_error");
4837
- return false;
4838
- }
4839
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4840
4816
  if (combined.aborted) return false;
4817
+ let encoded;
4841
4818
  try {
4842
- const { response, body } = await postEncoded(
4843
- options.recordingsUrl,
4844
- encoded,
4845
- combined,
4846
- async (uploadResponse) => {
4847
- if (!uploadResponse.ok) return void 0;
4848
- try {
4849
- return unwrapPayload(await uploadResponse.json());
4850
- } catch {
4851
- return void 0;
4852
- }
4853
- }
4819
+ encoded = await encodeJsonRequestBodyAsync(
4820
+ {
4821
+ instance_id: instanceId,
4822
+ recordings: batch.map((item) => ({
4823
+ session_id: item.sessionId,
4824
+ execution_id: item.executionId,
4825
+ outcome: item.outcome,
4826
+ runtime_state: item.runtimeState,
4827
+ release: options.release,
4828
+ redact_keys: copyRedactKeys([
4829
+ ...redactKeys ?? [],
4830
+ ...item.redactKeys ?? []
4831
+ ])?.slice(0, MAX_REDACT_KEYS),
4832
+ scrub_pii: item.scrubPii ?? scrubPii
4833
+ }))
4834
+ },
4835
+ void 0,
4836
+ combined
4854
4837
  );
4855
- if (response.ok) {
4856
- applyCompletedSessionIds(body?.completed_session_ids);
4857
- return true;
4858
- }
4859
- const kind = classifyHttpFailure(response.status);
4860
- rememberFailure(kind);
4861
- if (kind === "non_retryable_http") return true;
4862
- if (attempt === MAX_RETRIES) return false;
4863
- await wait(backoffMs(attempt), combined);
4864
4838
  } catch (error) {
4865
4839
  if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4866
4840
  rememberFailure("aborted");
4867
4841
  return false;
4868
4842
  }
4869
4843
  rememberFailure("network_error");
4870
- if (attempt === MAX_RETRIES) return false;
4871
- await wait(backoffMs(attempt), combined);
4844
+ return false;
4872
4845
  }
4846
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4847
+ if (combined.aborted) return false;
4848
+ try {
4849
+ const { response, body } = await postEncoded(
4850
+ options.recordingsUrl,
4851
+ encoded,
4852
+ combined,
4853
+ async (uploadResponse) => {
4854
+ if (!uploadResponse.ok) return void 0;
4855
+ try {
4856
+ return unwrapPayload(await uploadResponse.json());
4857
+ } catch {
4858
+ return void 0;
4859
+ }
4860
+ }
4861
+ );
4862
+ if (response.ok) {
4863
+ applyCompletedSessionIds(body?.completed_session_ids);
4864
+ return true;
4865
+ }
4866
+ const kind = classifyHttpFailure(response.status);
4867
+ rememberFailure(kind);
4868
+ if (kind === "non_retryable_http") return true;
4869
+ if (attempt === MAX_RETRIES) return false;
4870
+ await wait(backoffMs(attempt), combined);
4871
+ } catch (error) {
4872
+ if (combined.aborted || error instanceof Error && error.name === "AbortError") {
4873
+ rememberFailure("aborted");
4874
+ return false;
4875
+ }
4876
+ rememberFailure("network_error");
4877
+ if (attempt === MAX_RETRIES) return false;
4878
+ await wait(backoffMs(attempt), combined);
4879
+ }
4880
+ }
4881
+ return false;
4882
+ } finally {
4883
+ stopParent();
4884
+ stopCancel();
4873
4885
  }
4874
- return false;
4875
4886
  };
4876
4887
  const drainRecordings = async (signal) => {
4877
4888
  while (recordings.length > 0 && !signal.aborted) {
@@ -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.11.1";
3
+ export declare const SDK_VERSION = "0.11.2";
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.11.1",
3
+ "version": "0.11.2",
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.11.1",
52
+ "@rasputin-ai/core": "0.11.2",
53
53
  "typescript": "5"
54
54
  },
55
55
  "devDependencies": {