@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.
- package/dist/auto-instrumentation/schedule-instrumentation-manifest-upload.d.ts +2 -0
- package/dist/auto-instrumentation/schedule-instrumentation-manifest-upload.d.ts.map +1 -1
- package/dist/execution-recorder/error-observation.d.ts +14 -0
- package/dist/execution-recorder/error-observation.d.ts.map +1 -0
- package/dist/execution-recorder/execution-recorder-types.d.ts +10 -7
- package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +159 -66
- package/dist/instrument/build.js +142 -130
- package/dist/instrument/bun.js +143 -131
- package/dist/instrument/node.js +143 -131
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +157 -60
- package/dist/rasputin-init.d.ts.map +1 -1
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +5 -5
package/dist/internal.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { scheduleInstrumentationManifestUpload } from './auto-instrumentation/sc
|
|
|
2
2
|
export type { ExecutionRuntime, ExecutionRuntimeScope, ExecutionState, PreparedCallHandle, } from './execution-recorder';
|
|
3
3
|
export { createExecutionRecorder } from './execution-recorder';
|
|
4
4
|
export { installAutomaticExecutionRuntime } from './execution-recorder/automatic-runtime';
|
|
5
|
+
export { inertErrorObservation } from './execution-recorder/error-observation';
|
|
5
6
|
export type { InstallGlobalHandlersOptions } from './install-global-handlers';
|
|
6
7
|
export { installGlobalHandlers } from './install-global-handlers';
|
|
7
8
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,YAAY,EACX,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,YAAY,EACX,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -447,6 +447,8 @@ var unavailable = () => ({
|
|
|
447
447
|
var noopHandle = {
|
|
448
448
|
flushSoon() {
|
|
449
449
|
},
|
|
450
|
+
start() {
|
|
451
|
+
},
|
|
450
452
|
async wait() {
|
|
451
453
|
},
|
|
452
454
|
disconnect() {
|
|
@@ -469,8 +471,12 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
469
471
|
let stopped = false;
|
|
470
472
|
let working = false;
|
|
471
473
|
let debounceTimer;
|
|
474
|
+
let retryTimer;
|
|
475
|
+
let failedAttempts = 0;
|
|
472
476
|
const sessionAbort = new AbortController();
|
|
473
477
|
const debounceMs = 500;
|
|
478
|
+
const retryMs = 3e3;
|
|
479
|
+
const maxAttempts = 5;
|
|
474
480
|
const packageNamesOf = (manifest) => [
|
|
475
481
|
...new Set(
|
|
476
482
|
manifest.functions.map((fn) => fn.source.packageName).filter((name) => Boolean(name))
|
|
@@ -496,6 +502,20 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
496
502
|
clearTimeout(debounceTimer);
|
|
497
503
|
debounceTimer = void 0;
|
|
498
504
|
};
|
|
505
|
+
const clearRetry = () => {
|
|
506
|
+
if (retryTimer === void 0) return;
|
|
507
|
+
clearTimeout(retryTimer);
|
|
508
|
+
retryTimer = void 0;
|
|
509
|
+
};
|
|
510
|
+
const armRetry = () => {
|
|
511
|
+
if (stopped || failedAttempts >= maxAttempts) return;
|
|
512
|
+
clearRetry();
|
|
513
|
+
retryTimer = setTimeout(() => {
|
|
514
|
+
retryTimer = void 0;
|
|
515
|
+
flushSoon();
|
|
516
|
+
}, retryMs);
|
|
517
|
+
retryTimer.unref?.();
|
|
518
|
+
};
|
|
499
519
|
const flushSoon = () => {
|
|
500
520
|
clearDebounce();
|
|
501
521
|
if (stopped || !isInstrumentationManifestDirty() || working) return;
|
|
@@ -514,7 +534,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
514
534
|
continue;
|
|
515
535
|
}
|
|
516
536
|
const controller = new AbortController();
|
|
517
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
537
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
518
538
|
timeout.unref?.();
|
|
519
539
|
const abortUpload = () => controller.abort();
|
|
520
540
|
sessionAbort.signal.addEventListener("abort", abortUpload, { once: true });
|
|
@@ -543,6 +563,8 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
543
563
|
if (result.ok) {
|
|
544
564
|
verification = result.verification;
|
|
545
565
|
markInstrumentationManifestUploaded(generation);
|
|
566
|
+
failedAttempts = 0;
|
|
567
|
+
clearRetry();
|
|
546
568
|
if (verification.status === "verified") {
|
|
547
569
|
if (!loggedSuccess && options.logSuccess !== false) {
|
|
548
570
|
loggedSuccess = true;
|
|
@@ -556,13 +578,21 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
556
578
|
}
|
|
557
579
|
continue;
|
|
558
580
|
}
|
|
559
|
-
|
|
581
|
+
failedAttempts += 1;
|
|
582
|
+
if (failedAttempts >= maxAttempts && !loggedFailure) {
|
|
560
583
|
loggedFailure = true;
|
|
561
584
|
console.warn(report(manifest, false, unavailable()));
|
|
562
585
|
}
|
|
586
|
+
armRetry();
|
|
563
587
|
break;
|
|
564
588
|
} catch {
|
|
565
589
|
if (stopped) return;
|
|
590
|
+
failedAttempts += 1;
|
|
591
|
+
if (failedAttempts >= maxAttempts && !loggedFailure) {
|
|
592
|
+
loggedFailure = true;
|
|
593
|
+
console.warn(report(manifest, false, unavailable()));
|
|
594
|
+
}
|
|
595
|
+
armRetry();
|
|
566
596
|
break;
|
|
567
597
|
} finally {
|
|
568
598
|
clearTimeout(timeout);
|
|
@@ -583,10 +613,15 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
583
613
|
}, debounceMs);
|
|
584
614
|
debounceTimer.unref?.();
|
|
585
615
|
};
|
|
586
|
-
|
|
587
|
-
|
|
616
|
+
const start = () => {
|
|
617
|
+
if (stopped) return;
|
|
618
|
+
setInstrumentationManifestOnDirty(armFlush);
|
|
619
|
+
if (isInstrumentationManifestDirty()) armFlush();
|
|
620
|
+
};
|
|
621
|
+
if (!options.deferStart) start();
|
|
588
622
|
return {
|
|
589
623
|
flushSoon,
|
|
624
|
+
start,
|
|
590
625
|
wait: async (timeoutMs) => {
|
|
591
626
|
flushSoon();
|
|
592
627
|
if (timeoutMs === void 0) {
|
|
@@ -610,6 +645,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
610
645
|
disconnect: () => {
|
|
611
646
|
stopped = true;
|
|
612
647
|
clearDebounce();
|
|
648
|
+
clearRetry();
|
|
613
649
|
setInstrumentationManifestOnDirty(void 0);
|
|
614
650
|
sessionAbort.abort();
|
|
615
651
|
},
|
|
@@ -629,6 +665,21 @@ import {
|
|
|
629
665
|
runtimeFunctionId as runtimeFunctionId2
|
|
630
666
|
} from "@rasputin-ai/core";
|
|
631
667
|
|
|
668
|
+
// src/execution-recorder/error-observation.ts
|
|
669
|
+
var bindings = /* @__PURE__ */ new WeakMap();
|
|
670
|
+
var mintErrorObservation = (binding) => {
|
|
671
|
+
const observation = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
672
|
+
bindings.set(observation, binding);
|
|
673
|
+
return observation;
|
|
674
|
+
};
|
|
675
|
+
var bindingForObservation = (value) => {
|
|
676
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
677
|
+
return bindings.get(value);
|
|
678
|
+
};
|
|
679
|
+
var inertErrorObservation = () => {
|
|
680
|
+
return Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
681
|
+
};
|
|
682
|
+
|
|
632
683
|
// src/execution-recorder/execution-journal.ts
|
|
633
684
|
var KIND_ENTER = 1;
|
|
634
685
|
var KIND_EXIT = 2;
|
|
@@ -2635,8 +2686,7 @@ var noOpExecution = {
|
|
|
2635
2686
|
createScope: () => ({
|
|
2636
2687
|
run: (callback) => callback(),
|
|
2637
2688
|
getErrorState: () => void 0,
|
|
2638
|
-
|
|
2639
|
-
},
|
|
2689
|
+
observeError: () => inertErrorObservation(),
|
|
2640
2690
|
finish: () => {
|
|
2641
2691
|
}
|
|
2642
2692
|
}),
|
|
@@ -2749,7 +2799,12 @@ var createExecutionRecorder = (options) => {
|
|
|
2749
2799
|
let nextRuntimePlanId = 1;
|
|
2750
2800
|
const internedPlans = /* @__PURE__ */ new Map();
|
|
2751
2801
|
const preparedModules = /* @__PURE__ */ new WeakMap();
|
|
2752
|
-
const
|
|
2802
|
+
const owner = {};
|
|
2803
|
+
const ownerGeneration = 1;
|
|
2804
|
+
let storageClock = 0;
|
|
2805
|
+
let occurrenceCounter = 0;
|
|
2806
|
+
const recordingsById = /* @__PURE__ */ new Map();
|
|
2807
|
+
const evictedRecordingIds = [];
|
|
2753
2808
|
const retainedErrorRecordings = [];
|
|
2754
2809
|
const phases = phaseTimingEnabled ? { alsNs: 0n, materializeNs: 0n } : void 0;
|
|
2755
2810
|
const stats = {
|
|
@@ -2982,6 +3037,39 @@ var createExecutionRecorder = (options) => {
|
|
|
2982
3037
|
};
|
|
2983
3038
|
return boundedState.truncated?.size ? enforceRuntimeStateSizeBudget(boundedState, runtimeStateSizeBudget) : boundedState;
|
|
2984
3039
|
};
|
|
3040
|
+
const forgetDiscardedRecording = (recording) => {
|
|
3041
|
+
if (recording.hasError || recording.retainedForError) return;
|
|
3042
|
+
recordingsById.delete(recording.executionId);
|
|
3043
|
+
};
|
|
3044
|
+
const discardSuccessfulEvidence = (recording) => {
|
|
3045
|
+
if (recording.evidenceDiscarded) return;
|
|
3046
|
+
recording.evidenceDiscarded = true;
|
|
3047
|
+
recording.cachedState = void 0;
|
|
3048
|
+
recording.repeatedCalls = [];
|
|
3049
|
+
recording.lateCapturedCallIds = void 0;
|
|
3050
|
+
recording.capturedErrors = /* @__PURE__ */ new WeakMap();
|
|
3051
|
+
if (recording.journal) {
|
|
3052
|
+
journalPool.release(recording.journal);
|
|
3053
|
+
recording.journal = void 0;
|
|
3054
|
+
}
|
|
3055
|
+
recordingsById.delete(recording.executionId);
|
|
3056
|
+
};
|
|
3057
|
+
const mintOccurrence = (recording, provenance) => mintErrorObservation({
|
|
3058
|
+
owner,
|
|
3059
|
+
ownerGeneration,
|
|
3060
|
+
recordingId: recording.executionId,
|
|
3061
|
+
recordingGeneration: recording.storageGeneration,
|
|
3062
|
+
occurrenceId: ++occurrenceCounter,
|
|
3063
|
+
provenance
|
|
3064
|
+
});
|
|
3065
|
+
const dropOldestEvictedRecording = () => {
|
|
3066
|
+
while (evictedRecordingIds.length > maxRetainedErrorRecordings) {
|
|
3067
|
+
const oldId = evictedRecordingIds.shift();
|
|
3068
|
+
if (!oldId) continue;
|
|
3069
|
+
const old = recordingsById.get(oldId);
|
|
3070
|
+
if (old?.evicted) recordingsById.delete(oldId);
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
2985
3073
|
const evictRetainedRecording = (recording) => {
|
|
2986
3074
|
const eventCount = recording.cachedState?.events.length ?? recording.journal?.eventCount ?? 0;
|
|
2987
3075
|
const dropped = (recording.cachedState?.truncated?.eventsDropped ?? recording.journal?.dropped ?? 0) + eventCount;
|
|
@@ -3006,6 +3094,8 @@ var createExecutionRecorder = (options) => {
|
|
|
3006
3094
|
eventsDropped: Math.max(1, dropped)
|
|
3007
3095
|
}
|
|
3008
3096
|
};
|
|
3097
|
+
evictedRecordingIds.push(recording.executionId);
|
|
3098
|
+
dropOldestEvictedRecording();
|
|
3009
3099
|
};
|
|
3010
3100
|
const trimFinishedRetainedRecordings = (keep) => {
|
|
3011
3101
|
while (retainedErrorRecordings.length > maxRetainedErrorRecordings) {
|
|
@@ -3083,10 +3173,17 @@ var createExecutionRecorder = (options) => {
|
|
|
3083
3173
|
}
|
|
3084
3174
|
}
|
|
3085
3175
|
};
|
|
3086
|
-
const
|
|
3087
|
-
recording.
|
|
3088
|
-
|
|
3089
|
-
|
|
3176
|
+
const retainFailure = (recording) => {
|
|
3177
|
+
if (recording.evidenceDiscarded) return;
|
|
3178
|
+
if (!recording.hasError) {
|
|
3179
|
+
recording.hasError = true;
|
|
3180
|
+
stats.errorSnapshots++;
|
|
3181
|
+
if (recording.memory.underPressure && !recording.partialSnapshotCounted) {
|
|
3182
|
+
recording.partialSnapshotCounted = true;
|
|
3183
|
+
stats.partialErrorSnapshots++;
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
if (recording.budgetExpired) {
|
|
3090
3187
|
const eventsDropped = Math.max(
|
|
3091
3188
|
1,
|
|
3092
3189
|
recording.cachedState?.capture?.eventsDropped ?? recording.cachedState?.truncated?.eventsDropped ?? recording.memory.eventsDropped
|
|
@@ -3104,15 +3201,23 @@ var createExecutionRecorder = (options) => {
|
|
|
3104
3201
|
};
|
|
3105
3202
|
}
|
|
3106
3203
|
retainErrorRecording(recording);
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
stats.partialErrorSnapshots++;
|
|
3113
|
-
}
|
|
3204
|
+
recordingsById.set(recording.executionId, recording);
|
|
3205
|
+
};
|
|
3206
|
+
const observeFailure = (recording, provenance) => {
|
|
3207
|
+
if (!recording.evidenceDiscarded) {
|
|
3208
|
+
retainFailure(recording);
|
|
3114
3209
|
}
|
|
3115
|
-
|
|
3210
|
+
return mintOccurrence(recording, provenance);
|
|
3211
|
+
};
|
|
3212
|
+
const stateForObservation = (observation) => {
|
|
3213
|
+
const binding = bindingForObservation(observation);
|
|
3214
|
+
if (!binding) return void 0;
|
|
3215
|
+
if (binding.owner !== owner || binding.ownerGeneration !== ownerGeneration) return void 0;
|
|
3216
|
+
const recording = recordingsById.get(binding.recordingId);
|
|
3217
|
+
if (!recording || recording.evidenceDiscarded || recording.storageGeneration !== binding.recordingGeneration) {
|
|
3218
|
+
return void 0;
|
|
3219
|
+
}
|
|
3220
|
+
return stateFrom(recording, recording.finishedAtNs);
|
|
3116
3221
|
};
|
|
3117
3222
|
const countDroppedEvents = (recording, droppedBefore) => {
|
|
3118
3223
|
const dropped = recording.journal?.dropped ?? droppedBefore;
|
|
@@ -3176,11 +3281,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3176
3281
|
};
|
|
3177
3282
|
const captureCompletedThrow = (recording, plan, args, parentCallId, startedAtNs, error, capturedArgs) => {
|
|
3178
3283
|
if (!recording.journal) {
|
|
3179
|
-
rememberError(error, recording);
|
|
3180
3284
|
return;
|
|
3181
3285
|
}
|
|
3182
3286
|
if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
|
|
3183
|
-
rememberError(error, recording);
|
|
3184
3287
|
return;
|
|
3185
3288
|
}
|
|
3186
3289
|
const callId = ++recording.nextCallId;
|
|
@@ -3206,7 +3309,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3206
3309
|
capturedError.commit();
|
|
3207
3310
|
}
|
|
3208
3311
|
countDroppedEvents(recording, droppedBefore);
|
|
3209
|
-
rememberError(error, recording);
|
|
3210
3312
|
};
|
|
3211
3313
|
const recordSuppressedCall = (recording, group, parentCallId, startedAtNs, endedAtNs) => {
|
|
3212
3314
|
stats.repeatedCallsSuppressed++;
|
|
@@ -3252,7 +3354,12 @@ var createExecutionRecorder = (options) => {
|
|
|
3252
3354
|
try {
|
|
3253
3355
|
if (!recording.finished || recording.inFlightCalls > 0) return;
|
|
3254
3356
|
memoryBudget.release(recording.memory);
|
|
3357
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3358
|
+
discardSuccessfulEvidence(recording);
|
|
3359
|
+
return;
|
|
3360
|
+
}
|
|
3255
3361
|
releaseJournalIfIdle(recording);
|
|
3362
|
+
forgetDiscardedRecording(recording);
|
|
3256
3363
|
} catch {
|
|
3257
3364
|
}
|
|
3258
3365
|
};
|
|
@@ -3264,6 +3371,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3264
3371
|
recording.finished = true;
|
|
3265
3372
|
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
3266
3373
|
stats.activeExecutions = Math.max(0, stats.activeExecutions - 1);
|
|
3374
|
+
if (recording.runFailed && !recording.hasError) {
|
|
3375
|
+
retainFailure(recording);
|
|
3376
|
+
}
|
|
3267
3377
|
if (!recording.hasError) {
|
|
3268
3378
|
stats.successfulExecutionsDiscarded++;
|
|
3269
3379
|
}
|
|
@@ -3289,6 +3399,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3289
3399
|
sweepLongLivedExecutions(recorderStartedAtNs);
|
|
3290
3400
|
const recording = {
|
|
3291
3401
|
executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
|
|
3402
|
+
storageGeneration: ++storageClock,
|
|
3292
3403
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3293
3404
|
startedAtNs: recorderStartedAtNs,
|
|
3294
3405
|
inlineRecorderTimeNs: 0n,
|
|
@@ -3311,6 +3422,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3311
3422
|
stats.activeExecutions++;
|
|
3312
3423
|
stats.peakActiveExecutions = Math.max(stats.peakActiveExecutions, stats.activeExecutions);
|
|
3313
3424
|
liveRecordings.push(recording);
|
|
3425
|
+
recordingsById.set(recording.executionId, recording);
|
|
3314
3426
|
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3315
3427
|
const store = { recording };
|
|
3316
3428
|
return {
|
|
@@ -3324,8 +3436,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3324
3436
|
try {
|
|
3325
3437
|
return callback();
|
|
3326
3438
|
} catch (error) {
|
|
3439
|
+
recording.runFailed = true;
|
|
3327
3440
|
if (recording.budgetExpired || recording.evicted) {
|
|
3328
|
-
|
|
3441
|
+
retainFailure(recording);
|
|
3329
3442
|
}
|
|
3330
3443
|
throw error;
|
|
3331
3444
|
}
|
|
@@ -3335,21 +3448,21 @@ var createExecutionRecorder = (options) => {
|
|
|
3335
3448
|
return callback();
|
|
3336
3449
|
}
|
|
3337
3450
|
},
|
|
3338
|
-
|
|
3451
|
+
observeError: (_error) => {
|
|
3339
3452
|
try {
|
|
3340
|
-
|
|
3341
|
-
if (errorMetadata) mergeExecutionMetadata(recording.execution, errorMetadata);
|
|
3342
|
-
rememberError(error, recording);
|
|
3343
|
-
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3344
|
-
return stateFrom(recording, recording.finishedAtNs);
|
|
3453
|
+
return observeFailure(recording, "scope-observe");
|
|
3345
3454
|
} catch {
|
|
3346
|
-
return
|
|
3455
|
+
return inertErrorObservation();
|
|
3347
3456
|
}
|
|
3348
3457
|
},
|
|
3349
|
-
|
|
3458
|
+
getErrorState: (observation) => {
|
|
3350
3459
|
try {
|
|
3351
|
-
|
|
3460
|
+
const getStateStartedAtNs = process.hrtime.bigint();
|
|
3461
|
+
const state = stateForObservation(observation);
|
|
3462
|
+
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3463
|
+
return state;
|
|
3352
3464
|
} catch {
|
|
3465
|
+
return void 0;
|
|
3353
3466
|
}
|
|
3354
3467
|
},
|
|
3355
3468
|
finish: (finishMetadata) => finish(store, finishMetadata)
|
|
@@ -3358,16 +3471,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3358
3471
|
return noOpExecution.createScope(metadata);
|
|
3359
3472
|
}
|
|
3360
3473
|
};
|
|
3361
|
-
const getErrorState = (
|
|
3362
|
-
const getStateStartedAtNs = process.hrtime.bigint();
|
|
3474
|
+
const getErrorState = (observation) => {
|
|
3363
3475
|
try {
|
|
3364
|
-
|
|
3365
|
-
const recording = (weakKey ? errorExecutions.get(weakKey) : void 0) ?? currentStore()?.recording;
|
|
3366
|
-
if (!recording) return void 0;
|
|
3367
|
-
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
3368
|
-
rememberError(error, recording);
|
|
3369
|
-
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3370
|
-
return stateFrom(recording, recording.finishedAtNs);
|
|
3476
|
+
return stateForObservation(observation);
|
|
3371
3477
|
} catch {
|
|
3372
3478
|
return void 0;
|
|
3373
3479
|
}
|
|
@@ -3402,7 +3508,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3402
3508
|
return callback();
|
|
3403
3509
|
} catch (error) {
|
|
3404
3510
|
if (store.recording.budgetExpired || store.recording.evicted) {
|
|
3405
|
-
|
|
3511
|
+
retainFailure(store.recording);
|
|
3406
3512
|
}
|
|
3407
3513
|
throw error;
|
|
3408
3514
|
}
|
|
@@ -3450,8 +3556,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3450
3556
|
recorderStartedAtNs,
|
|
3451
3557
|
callback,
|
|
3452
3558
|
() => settleInFlight(recording),
|
|
3453
|
-
(
|
|
3454
|
-
rememberError(error, recording);
|
|
3559
|
+
(_error) => {
|
|
3455
3560
|
settleInFlight(recording);
|
|
3456
3561
|
}
|
|
3457
3562
|
);
|
|
@@ -3483,8 +3588,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3483
3588
|
recorderStartedAtNs,
|
|
3484
3589
|
callback,
|
|
3485
3590
|
() => settleInFlight(recording),
|
|
3486
|
-
(
|
|
3487
|
-
rememberError(error, recording);
|
|
3591
|
+
(_error) => {
|
|
3488
3592
|
settleInFlight(recording);
|
|
3489
3593
|
}
|
|
3490
3594
|
);
|
|
@@ -3502,8 +3606,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3502
3606
|
recorderStartedAtNs,
|
|
3503
3607
|
callback,
|
|
3504
3608
|
() => settleInFlight(recording),
|
|
3505
|
-
(
|
|
3506
|
-
rememberError(error, recording);
|
|
3609
|
+
(_error) => {
|
|
3507
3610
|
settleInFlight(recording);
|
|
3508
3611
|
}
|
|
3509
3612
|
);
|
|
@@ -3527,7 +3630,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3527
3630
|
},
|
|
3528
3631
|
(error) => {
|
|
3529
3632
|
if (!recording.journal) {
|
|
3530
|
-
rememberError(error, recording);
|
|
3531
3633
|
settleInFlight(recording);
|
|
3532
3634
|
return;
|
|
3533
3635
|
}
|
|
@@ -3541,7 +3643,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3541
3643
|
);
|
|
3542
3644
|
stats.functionCallsCaptured++;
|
|
3543
3645
|
capturedError.commit();
|
|
3544
|
-
rememberError(error, recording);
|
|
3545
3646
|
settleInFlight(recording);
|
|
3546
3647
|
}
|
|
3547
3648
|
);
|
|
@@ -3616,8 +3717,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3616
3717
|
const expiredStore = { recording: expired };
|
|
3617
3718
|
return {
|
|
3618
3719
|
leave: (value) => value,
|
|
3619
|
-
fail: (
|
|
3620
|
-
rememberError(error, expired);
|
|
3720
|
+
fail: () => {
|
|
3621
3721
|
},
|
|
3622
3722
|
end: () => {
|
|
3623
3723
|
},
|
|
@@ -3751,10 +3851,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3751
3851
|
}
|
|
3752
3852
|
return value;
|
|
3753
3853
|
},
|
|
3754
|
-
fail: (
|
|
3854
|
+
fail: (_error) => {
|
|
3755
3855
|
if (status === "failed") return;
|
|
3756
3856
|
status = "failed";
|
|
3757
|
-
rememberError(error, recording);
|
|
3758
3857
|
},
|
|
3759
3858
|
end: finishEnd,
|
|
3760
3859
|
...context
|
|
@@ -3775,10 +3874,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3775
3874
|
}
|
|
3776
3875
|
return value;
|
|
3777
3876
|
},
|
|
3778
|
-
fail: (
|
|
3877
|
+
fail: (_error) => {
|
|
3779
3878
|
if (status === "failed") return;
|
|
3780
3879
|
status = "failed";
|
|
3781
|
-
rememberError(error, recording);
|
|
3782
3880
|
},
|
|
3783
3881
|
end: finishEnd,
|
|
3784
3882
|
...context
|
|
@@ -3791,7 +3889,8 @@ var createExecutionRecorder = (options) => {
|
|
|
3791
3889
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3792
3890
|
} catch {
|
|
3793
3891
|
journal.dropCall();
|
|
3794
|
-
return dropWithoutCapture((
|
|
3892
|
+
return dropWithoutCapture(() => {
|
|
3893
|
+
});
|
|
3795
3894
|
}
|
|
3796
3895
|
const callStore = { recording, currentCallId: callId };
|
|
3797
3896
|
const captured = bindStoreTransitions(callStore, parentStore, recording, plan);
|
|
@@ -3806,7 +3905,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3806
3905
|
};
|
|
3807
3906
|
const writeThrow = (error) => {
|
|
3808
3907
|
if (!recording.journal) {
|
|
3809
|
-
rememberError(error, recording);
|
|
3810
3908
|
return;
|
|
3811
3909
|
}
|
|
3812
3910
|
const capturedError = serializedError(recording, error, callId);
|
|
@@ -3819,7 +3917,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3819
3917
|
);
|
|
3820
3918
|
stats.functionCallsCaptured++;
|
|
3821
3919
|
capturedError.commit();
|
|
3822
|
-
rememberError(error, recording);
|
|
3823
3920
|
};
|
|
3824
3921
|
return {
|
|
3825
3922
|
leave: (value) => {
|
|
@@ -3835,7 +3932,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3835
3932
|
try {
|
|
3836
3933
|
writeThrow(error);
|
|
3837
3934
|
} catch {
|
|
3838
|
-
rememberError(error, recording);
|
|
3839
3935
|
}
|
|
3840
3936
|
},
|
|
3841
3937
|
end: () => {
|
|
@@ -4139,6 +4235,7 @@ var installGlobalHandlers = (client, options = {}) => {
|
|
|
4139
4235
|
};
|
|
4140
4236
|
export {
|
|
4141
4237
|
createExecutionRecorder,
|
|
4238
|
+
inertErrorObservation,
|
|
4142
4239
|
installAutomaticExecutionRuntime,
|
|
4143
4240
|
installGlobalHandlers,
|
|
4144
4241
|
scheduleInstrumentationManifestUpload
|
|
@@ -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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,
|
|
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,kBA+D3D,CAAC"}
|
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.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Official Rasputin AI SDK for Node and Bun.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "bun
|
|
41
|
-
"prepublishOnly": "npm run build && bun
|
|
40
|
+
"build": "bun ../../scripts/build-package.ts .",
|
|
41
|
+
"prepublishOnly": "npm run build && bun ../../scripts/check-lockstep-versions.ts",
|
|
42
42
|
"pack:check": "npm run build && npm pack --dry-run",
|
|
43
|
-
"typecheck": "bun
|
|
43
|
+
"typecheck": "bun ../../scripts/generate-sdk-meta.ts . && bunx tsc --noEmit",
|
|
44
44
|
"lint": "biome check .",
|
|
45
45
|
"test": "bun test"
|
|
46
46
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
52
|
-
"@rasputin-ai/core": "0.
|
|
52
|
+
"@rasputin-ai/core": "0.7.0",
|
|
53
53
|
"typescript": "5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|