@rasputin-ai/node 0.11.1 → 0.11.3
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.
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recording-sync.d.ts.map +1 -1
- package/dist/index.js +88 -67
- package/dist/instrument/bun.js +1 -1
- package/dist/instrument/node.js +1 -1
- package/dist/internal.js +87 -66
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAGX,wBAAwB,EACxB,gBAAgB,EAGhB,MAAM,4BAA4B,CAAC;AAoQpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,EAC7C,QAAO,sBAA2B,KAChC,
|
|
1
|
+
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,sBAAsB,EAAsB,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EAGX,wBAAwB,EACxB,gBAAgB,EAGhB,MAAM,4BAA4B,CAAC;AAoQpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,EAC7C,QAAO,sBAA2B,KAChC,gBA4wDF,CAAC"}
|
|
@@ -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;
|
|
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
|
@@ -3217,6 +3217,11 @@ var createExecutionRecorder = (options, hooks = {}) => {
|
|
|
3217
3217
|
}
|
|
3218
3218
|
}
|
|
3219
3219
|
detachLiveRecording(recording);
|
|
3220
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3221
|
+
recording.repeatedCalls = void 0;
|
|
3222
|
+
recording.lateCapturedCallIds = void 0;
|
|
3223
|
+
recordingsById.delete(recording.executionId);
|
|
3224
|
+
}
|
|
3220
3225
|
};
|
|
3221
3226
|
const sweepLongLivedExecutions = (nowNs) => {
|
|
3222
3227
|
if (nowNs - lastSweepNs < sweepIntervalNs && liveRecordings.length < 256) return;
|
|
@@ -3453,7 +3458,12 @@ var createExecutionRecorder = (options, hooks = {}) => {
|
|
|
3453
3458
|
const finish = (store, metadata) => {
|
|
3454
3459
|
try {
|
|
3455
3460
|
const { recording } = store;
|
|
3456
|
-
if (recording.finished)
|
|
3461
|
+
if (recording.finished) {
|
|
3462
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3463
|
+
discardSuccessfulEvidence(recording);
|
|
3464
|
+
}
|
|
3465
|
+
return;
|
|
3466
|
+
}
|
|
3457
3467
|
const recorderStartedAtNs = process.hrtime.bigint();
|
|
3458
3468
|
recording.finished = true;
|
|
3459
3469
|
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
@@ -4429,6 +4439,12 @@ var classifyHttpFailure = (status) => {
|
|
|
4429
4439
|
return "non_retryable_http";
|
|
4430
4440
|
};
|
|
4431
4441
|
var backoffMs = (attempt) => Math.min(3e3, 250 * 2 ** attempt);
|
|
4442
|
+
var abortFrom = (parent, child) => {
|
|
4443
|
+
const onAbort = () => child.abort();
|
|
4444
|
+
parent.addEventListener("abort", onAbort, { once: true });
|
|
4445
|
+
if (parent.aborted) onAbort();
|
|
4446
|
+
return () => parent.removeEventListener("abort", onAbort);
|
|
4447
|
+
};
|
|
4432
4448
|
var createExecutionRecordingCoordinator = (options) => {
|
|
4433
4449
|
const environment = trimmed2(options.environment);
|
|
4434
4450
|
const nowMs = () => options.nowMs?.() ?? Date.now();
|
|
@@ -4547,7 +4563,6 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4547
4563
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
4548
4564
|
}
|
|
4549
4565
|
};
|
|
4550
|
-
const workSignal = (signal) => AbortSignal.any([signal, cancelWork.signal]);
|
|
4551
4566
|
const interruptWork = () => {
|
|
4552
4567
|
cancelWork.abort();
|
|
4553
4568
|
cancelWork = new AbortController();
|
|
@@ -4570,19 +4585,17 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4570
4585
|
});
|
|
4571
4586
|
};
|
|
4572
4587
|
const withRequestTimeout = async (signal, run) => {
|
|
4573
|
-
const
|
|
4574
|
-
const
|
|
4575
|
-
const timer = setTimeout(() => timeout.abort(), REQUEST_TIMEOUT_MS);
|
|
4588
|
+
const request = new AbortController();
|
|
4589
|
+
const timer = setTimeout(() => request.abort(), REQUEST_TIMEOUT_MS);
|
|
4576
4590
|
timer.unref?.();
|
|
4577
|
-
const
|
|
4578
|
-
|
|
4579
|
-
if (combined.aborted) timeout.abort();
|
|
4580
|
-
const requestSignal = AbortSignal.any([combined, timeout.signal]);
|
|
4591
|
+
const stopParent = abortFrom(signal, request);
|
|
4592
|
+
const stopCancel = abortFrom(cancelWork.signal, request);
|
|
4581
4593
|
try {
|
|
4582
|
-
return await run(
|
|
4594
|
+
return await run(request.signal);
|
|
4583
4595
|
} finally {
|
|
4584
4596
|
clearTimeout(timer);
|
|
4585
|
-
|
|
4597
|
+
stopParent();
|
|
4598
|
+
stopCancel();
|
|
4586
4599
|
}
|
|
4587
4600
|
};
|
|
4588
4601
|
const postEncoded = async (url, encoded, signal, readBody) => withRequestTimeout(signal, async (requestSignal) => {
|
|
@@ -4835,73 +4848,81 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4835
4848
|
await joinUntil(flight, signal);
|
|
4836
4849
|
};
|
|
4837
4850
|
const sendRecordings = async (batch, signal) => {
|
|
4838
|
-
const
|
|
4839
|
-
|
|
4840
|
-
|
|
4851
|
+
const followed = new AbortController();
|
|
4852
|
+
const stopParent = abortFrom(signal, followed);
|
|
4853
|
+
const stopCancel = abortFrom(cancelWork.signal, followed);
|
|
4854
|
+
const combined = followed.signal;
|
|
4841
4855
|
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
4856
|
if (combined.aborted) return false;
|
|
4857
|
+
let encoded;
|
|
4871
4858
|
try {
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4859
|
+
encoded = await encodeJsonRequestBodyAsync(
|
|
4860
|
+
{
|
|
4861
|
+
instance_id: instanceId,
|
|
4862
|
+
recordings: batch.map((item) => ({
|
|
4863
|
+
session_id: item.sessionId,
|
|
4864
|
+
execution_id: item.executionId,
|
|
4865
|
+
outcome: item.outcome,
|
|
4866
|
+
runtime_state: item.runtimeState,
|
|
4867
|
+
release: options.release,
|
|
4868
|
+
redact_keys: copyRedactKeys([
|
|
4869
|
+
...redactKeys ?? [],
|
|
4870
|
+
...item.redactKeys ?? []
|
|
4871
|
+
])?.slice(0, MAX_REDACT_KEYS),
|
|
4872
|
+
scrub_pii: item.scrubPii ?? scrubPii
|
|
4873
|
+
}))
|
|
4874
|
+
},
|
|
4875
|
+
void 0,
|
|
4876
|
+
combined
|
|
4884
4877
|
);
|
|
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
4878
|
} catch (error) {
|
|
4895
4879
|
if (combined.aborted || error instanceof Error && error.name === "AbortError") {
|
|
4896
4880
|
rememberFailure("aborted");
|
|
4897
4881
|
return false;
|
|
4898
4882
|
}
|
|
4899
4883
|
rememberFailure("network_error");
|
|
4900
|
-
|
|
4901
|
-
await wait(backoffMs(attempt), combined);
|
|
4884
|
+
return false;
|
|
4902
4885
|
}
|
|
4886
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
4887
|
+
if (combined.aborted) return false;
|
|
4888
|
+
try {
|
|
4889
|
+
const { response, body } = await postEncoded(
|
|
4890
|
+
options.recordingsUrl,
|
|
4891
|
+
encoded,
|
|
4892
|
+
combined,
|
|
4893
|
+
async (uploadResponse) => {
|
|
4894
|
+
if (!uploadResponse.ok) return void 0;
|
|
4895
|
+
try {
|
|
4896
|
+
return unwrapPayload(await uploadResponse.json());
|
|
4897
|
+
} catch {
|
|
4898
|
+
return void 0;
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
);
|
|
4902
|
+
if (response.ok) {
|
|
4903
|
+
applyCompletedSessionIds(body?.completed_session_ids);
|
|
4904
|
+
return true;
|
|
4905
|
+
}
|
|
4906
|
+
const kind = classifyHttpFailure(response.status);
|
|
4907
|
+
rememberFailure(kind);
|
|
4908
|
+
if (kind === "non_retryable_http") return true;
|
|
4909
|
+
if (attempt === MAX_RETRIES) return false;
|
|
4910
|
+
await wait(backoffMs(attempt), combined);
|
|
4911
|
+
} catch (error) {
|
|
4912
|
+
if (combined.aborted || error instanceof Error && error.name === "AbortError") {
|
|
4913
|
+
rememberFailure("aborted");
|
|
4914
|
+
return false;
|
|
4915
|
+
}
|
|
4916
|
+
rememberFailure("network_error");
|
|
4917
|
+
if (attempt === MAX_RETRIES) return false;
|
|
4918
|
+
await wait(backoffMs(attempt), combined);
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
return false;
|
|
4922
|
+
} finally {
|
|
4923
|
+
stopParent();
|
|
4924
|
+
stopCancel();
|
|
4903
4925
|
}
|
|
4904
|
-
return false;
|
|
4905
4926
|
};
|
|
4906
4927
|
const drainRecordings = async (signal) => {
|
|
4907
4928
|
while (recordings.length > 0 && !signal.aborted) {
|
|
@@ -5233,7 +5254,7 @@ var installGlobalHandlers = (client, options = {}) => {
|
|
|
5233
5254
|
|
|
5234
5255
|
// src/sdk-meta.ts
|
|
5235
5256
|
var SDK_NAME = "@rasputin-ai/node";
|
|
5236
|
-
var SDK_VERSION = "0.11.
|
|
5257
|
+
var SDK_VERSION = "0.11.3";
|
|
5237
5258
|
|
|
5238
5259
|
// src/rasputin-init.ts
|
|
5239
5260
|
var publicExecution = (runtime) => ({
|
package/dist/instrument/bun.js
CHANGED
|
@@ -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.
|
|
1609
|
+
var SDK_VERSION = "0.11.3";
|
|
1610
1610
|
|
|
1611
1611
|
// src/auto-instrumentation/source-map-locations.ts
|
|
1612
1612
|
import { readFileSync } from "node:fs";
|
package/dist/instrument/node.js
CHANGED
|
@@ -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.
|
|
1671
|
+
var SDK_VERSION = "0.11.3";
|
|
1672
1672
|
|
|
1673
1673
|
// src/auto-instrumentation/transform-disk-cache.ts
|
|
1674
1674
|
var projectCacheDir = () => {
|
package/dist/internal.js
CHANGED
|
@@ -3187,6 +3187,11 @@ var createExecutionRecorder = (options, hooks = {}) => {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
}
|
|
3189
3189
|
detachLiveRecording(recording);
|
|
3190
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3191
|
+
recording.repeatedCalls = void 0;
|
|
3192
|
+
recording.lateCapturedCallIds = void 0;
|
|
3193
|
+
recordingsById.delete(recording.executionId);
|
|
3194
|
+
}
|
|
3190
3195
|
};
|
|
3191
3196
|
const sweepLongLivedExecutions = (nowNs) => {
|
|
3192
3197
|
if (nowNs - lastSweepNs < sweepIntervalNs && liveRecordings.length < 256) return;
|
|
@@ -3423,7 +3428,12 @@ var createExecutionRecorder = (options, hooks = {}) => {
|
|
|
3423
3428
|
const finish = (store, metadata) => {
|
|
3424
3429
|
try {
|
|
3425
3430
|
const { recording } = store;
|
|
3426
|
-
if (recording.finished)
|
|
3431
|
+
if (recording.finished) {
|
|
3432
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3433
|
+
discardSuccessfulEvidence(recording);
|
|
3434
|
+
}
|
|
3435
|
+
return;
|
|
3436
|
+
}
|
|
3427
3437
|
const recorderStartedAtNs = process.hrtime.bigint();
|
|
3428
3438
|
recording.finished = true;
|
|
3429
3439
|
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
@@ -4399,6 +4409,12 @@ var classifyHttpFailure = (status) => {
|
|
|
4399
4409
|
return "non_retryable_http";
|
|
4400
4410
|
};
|
|
4401
4411
|
var backoffMs = (attempt) => Math.min(3e3, 250 * 2 ** attempt);
|
|
4412
|
+
var abortFrom = (parent, child) => {
|
|
4413
|
+
const onAbort = () => child.abort();
|
|
4414
|
+
parent.addEventListener("abort", onAbort, { once: true });
|
|
4415
|
+
if (parent.aborted) onAbort();
|
|
4416
|
+
return () => parent.removeEventListener("abort", onAbort);
|
|
4417
|
+
};
|
|
4402
4418
|
var createExecutionRecordingCoordinator = (options) => {
|
|
4403
4419
|
const environment = trimmed2(options.environment);
|
|
4404
4420
|
const nowMs = () => options.nowMs?.() ?? Date.now();
|
|
@@ -4517,7 +4533,6 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4517
4533
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
4518
4534
|
}
|
|
4519
4535
|
};
|
|
4520
|
-
const workSignal = (signal) => AbortSignal.any([signal, cancelWork.signal]);
|
|
4521
4536
|
const interruptWork = () => {
|
|
4522
4537
|
cancelWork.abort();
|
|
4523
4538
|
cancelWork = new AbortController();
|
|
@@ -4540,19 +4555,17 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4540
4555
|
});
|
|
4541
4556
|
};
|
|
4542
4557
|
const withRequestTimeout = async (signal, run) => {
|
|
4543
|
-
const
|
|
4544
|
-
const
|
|
4545
|
-
const timer = setTimeout(() => timeout.abort(), REQUEST_TIMEOUT_MS);
|
|
4558
|
+
const request = new AbortController();
|
|
4559
|
+
const timer = setTimeout(() => request.abort(), REQUEST_TIMEOUT_MS);
|
|
4546
4560
|
timer.unref?.();
|
|
4547
|
-
const
|
|
4548
|
-
|
|
4549
|
-
if (combined.aborted) timeout.abort();
|
|
4550
|
-
const requestSignal = AbortSignal.any([combined, timeout.signal]);
|
|
4561
|
+
const stopParent = abortFrom(signal, request);
|
|
4562
|
+
const stopCancel = abortFrom(cancelWork.signal, request);
|
|
4551
4563
|
try {
|
|
4552
|
-
return await run(
|
|
4564
|
+
return await run(request.signal);
|
|
4553
4565
|
} finally {
|
|
4554
4566
|
clearTimeout(timer);
|
|
4555
|
-
|
|
4567
|
+
stopParent();
|
|
4568
|
+
stopCancel();
|
|
4556
4569
|
}
|
|
4557
4570
|
};
|
|
4558
4571
|
const postEncoded = async (url, encoded, signal, readBody) => withRequestTimeout(signal, async (requestSignal) => {
|
|
@@ -4805,73 +4818,81 @@ var createExecutionRecordingCoordinator = (options) => {
|
|
|
4805
4818
|
await joinUntil(flight, signal);
|
|
4806
4819
|
};
|
|
4807
4820
|
const sendRecordings = async (batch, signal) => {
|
|
4808
|
-
const
|
|
4809
|
-
|
|
4810
|
-
|
|
4821
|
+
const followed = new AbortController();
|
|
4822
|
+
const stopParent = abortFrom(signal, followed);
|
|
4823
|
+
const stopCancel = abortFrom(cancelWork.signal, followed);
|
|
4824
|
+
const combined = followed.signal;
|
|
4811
4825
|
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
4826
|
if (combined.aborted) return false;
|
|
4827
|
+
let encoded;
|
|
4841
4828
|
try {
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4829
|
+
encoded = await encodeJsonRequestBodyAsync(
|
|
4830
|
+
{
|
|
4831
|
+
instance_id: instanceId,
|
|
4832
|
+
recordings: batch.map((item) => ({
|
|
4833
|
+
session_id: item.sessionId,
|
|
4834
|
+
execution_id: item.executionId,
|
|
4835
|
+
outcome: item.outcome,
|
|
4836
|
+
runtime_state: item.runtimeState,
|
|
4837
|
+
release: options.release,
|
|
4838
|
+
redact_keys: copyRedactKeys([
|
|
4839
|
+
...redactKeys ?? [],
|
|
4840
|
+
...item.redactKeys ?? []
|
|
4841
|
+
])?.slice(0, MAX_REDACT_KEYS),
|
|
4842
|
+
scrub_pii: item.scrubPii ?? scrubPii
|
|
4843
|
+
}))
|
|
4844
|
+
},
|
|
4845
|
+
void 0,
|
|
4846
|
+
combined
|
|
4854
4847
|
);
|
|
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
4848
|
} catch (error) {
|
|
4865
4849
|
if (combined.aborted || error instanceof Error && error.name === "AbortError") {
|
|
4866
4850
|
rememberFailure("aborted");
|
|
4867
4851
|
return false;
|
|
4868
4852
|
}
|
|
4869
4853
|
rememberFailure("network_error");
|
|
4870
|
-
|
|
4871
|
-
await wait(backoffMs(attempt), combined);
|
|
4854
|
+
return false;
|
|
4872
4855
|
}
|
|
4856
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
4857
|
+
if (combined.aborted) return false;
|
|
4858
|
+
try {
|
|
4859
|
+
const { response, body } = await postEncoded(
|
|
4860
|
+
options.recordingsUrl,
|
|
4861
|
+
encoded,
|
|
4862
|
+
combined,
|
|
4863
|
+
async (uploadResponse) => {
|
|
4864
|
+
if (!uploadResponse.ok) return void 0;
|
|
4865
|
+
try {
|
|
4866
|
+
return unwrapPayload(await uploadResponse.json());
|
|
4867
|
+
} catch {
|
|
4868
|
+
return void 0;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
);
|
|
4872
|
+
if (response.ok) {
|
|
4873
|
+
applyCompletedSessionIds(body?.completed_session_ids);
|
|
4874
|
+
return true;
|
|
4875
|
+
}
|
|
4876
|
+
const kind = classifyHttpFailure(response.status);
|
|
4877
|
+
rememberFailure(kind);
|
|
4878
|
+
if (kind === "non_retryable_http") return true;
|
|
4879
|
+
if (attempt === MAX_RETRIES) return false;
|
|
4880
|
+
await wait(backoffMs(attempt), combined);
|
|
4881
|
+
} catch (error) {
|
|
4882
|
+
if (combined.aborted || error instanceof Error && error.name === "AbortError") {
|
|
4883
|
+
rememberFailure("aborted");
|
|
4884
|
+
return false;
|
|
4885
|
+
}
|
|
4886
|
+
rememberFailure("network_error");
|
|
4887
|
+
if (attempt === MAX_RETRIES) return false;
|
|
4888
|
+
await wait(backoffMs(attempt), combined);
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4891
|
+
return false;
|
|
4892
|
+
} finally {
|
|
4893
|
+
stopParent();
|
|
4894
|
+
stopCancel();
|
|
4873
4895
|
}
|
|
4874
|
-
return false;
|
|
4875
4896
|
};
|
|
4876
4897
|
const drainRecordings = async (signal) => {
|
|
4877
4898
|
while (recordings.length > 0 && !signal.aborted) {
|
package/dist/sdk-meta.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rasputin-ai/node",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
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.
|
|
52
|
+
"@rasputin-ai/core": "0.11.3",
|
|
53
53
|
"typescript": "5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|