@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
|
@@ -14,9 +14,11 @@ type ScheduleInstrumentationManifestUploadOptions = {
|
|
|
14
14
|
logSuccess?: boolean;
|
|
15
15
|
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
16
16
|
enabled: boolean;
|
|
17
|
+
deferStart?: boolean;
|
|
17
18
|
};
|
|
18
19
|
type InstrumentationManifestUploadHandle = {
|
|
19
20
|
flushSoon: () => void;
|
|
21
|
+
start: () => void;
|
|
20
22
|
wait: (timeoutMs?: number) => Promise<void>;
|
|
21
23
|
disconnect: () => void;
|
|
22
24
|
verify: () => Promise<SourceVerification>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-instrumentation-manifest-upload.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/schedule-instrumentation-manifest-upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAGN,KAAK,kBAAkB,EAEvB,MAAM,mBAAmB,CAAC;AAY3B,KAAK,4CAA4C,GAAG;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjF,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule-instrumentation-manifest-upload.d.ts","sourceRoot":"","sources":["../../src/auto-instrumentation/schedule-instrumentation-manifest-upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAGN,KAAK,kBAAkB,EAEvB,MAAM,mBAAmB,CAAC;AAY3B,KAAK,4CAA4C,GAAG;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,mCAAmC,GAAG;IAC1C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC1C,CAAC;AAmBF,eAAO,MAAM,qCAAqC,GACjD,SAAS,4CAA4C,KACnD,mCAgOF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ErrorObservation } from '@rasputin-ai/core';
|
|
2
|
+
export type ObservationProvenance = 'instrumented-throw' | 'scope-observe';
|
|
3
|
+
export type ObservationBinding = {
|
|
4
|
+
owner: object;
|
|
5
|
+
ownerGeneration: number;
|
|
6
|
+
recordingId: string;
|
|
7
|
+
recordingGeneration: number;
|
|
8
|
+
occurrenceId: number;
|
|
9
|
+
provenance: ObservationProvenance;
|
|
10
|
+
};
|
|
11
|
+
export declare const mintErrorObservation: (binding: ObservationBinding) => ErrorObservation;
|
|
12
|
+
export declare const bindingForObservation: (value: unknown) => ObservationBinding | undefined;
|
|
13
|
+
export declare const inertErrorObservation: () => ErrorObservation;
|
|
14
|
+
//# sourceMappingURL=error-observation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-observation.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/error-observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAE3E,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,qBAAqB,CAAC;CAClC,CAAC;AAIF,eAAO,MAAM,oBAAoB,GAAI,SAAS,kBAAkB,KAAG,gBAIlE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,kBAAkB,GAAG,SAG3E,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,gBAExC,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* event model explicit allows the same bounded state to represent HTTP requests, jobs, scheduled
|
|
4
4
|
* work, and future serverless invocations without coupling the recorder to one framework lifecycle.
|
|
5
5
|
*/
|
|
6
|
-
import type { RuntimeExecutionEvent, RuntimeExecutionKind, RuntimeExecutionMetadata, RuntimeExecutionState, RuntimeFunctionDefinition, SourcePosition } from '@rasputin-ai/core';
|
|
6
|
+
import type { ErrorObservation, RuntimeExecutionEvent, RuntimeExecutionKind, RuntimeExecutionMetadata, RuntimeExecutionState, RuntimeFunctionDefinition, SourcePosition } from '@rasputin-ai/core';
|
|
7
7
|
import type { EncodedFunctionPlan } from '@rasputin-ai/recorder';
|
|
8
8
|
import type { PreparedFunctionPlan } from './function-plan';
|
|
9
9
|
/** A file glob (`src/logger/**`) or a regular expression matched against a function id. */
|
|
@@ -62,7 +62,7 @@ export type ExecutionRecorderOptions = {
|
|
|
62
62
|
*/
|
|
63
63
|
maxExecutionHoldMs?: number;
|
|
64
64
|
/**
|
|
65
|
-
* How many finished error recordings to keep for later
|
|
65
|
+
* How many finished error recordings to keep for later observation lookups.
|
|
66
66
|
* Older finished recordings are evicted and report `unavailable` /
|
|
67
67
|
* `retained_state_evicted`. Default: 32.
|
|
68
68
|
*/
|
|
@@ -151,13 +151,16 @@ export type ExecutionRecorderStats = {
|
|
|
151
151
|
export type ExecutionScope = {
|
|
152
152
|
/** Run `callback` under this recording's async context and return exactly what it returned. */
|
|
153
153
|
run: <T>(callback: () => T) => T;
|
|
154
|
-
/**
|
|
155
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Observe this failure as belonging to this execution. Ownership is fixed
|
|
156
|
+
* here; later capture only materializes this handle.
|
|
157
|
+
*/
|
|
158
|
+
observeError: (error: unknown) => ErrorObservation;
|
|
156
159
|
/** Mark the recording finished. The caller owns async completion. */
|
|
157
160
|
finish: (metadata?: Partial<ExecutionMetadata>) => void;
|
|
158
161
|
};
|
|
159
162
|
export type ExecutionRuntimeScope = ExecutionScope & {
|
|
160
|
-
getErrorState: (
|
|
163
|
+
getErrorState: (observation: ErrorObservation) => ExecutionState | undefined;
|
|
161
164
|
};
|
|
162
165
|
export type PreparedCallHandle = {
|
|
163
166
|
leave: (value?: unknown) => unknown;
|
|
@@ -175,7 +178,7 @@ export type PreparedCallHandle = {
|
|
|
175
178
|
resume: (value?: unknown) => unknown;
|
|
176
179
|
};
|
|
177
180
|
export type RasputinExecution = {
|
|
178
|
-
/** Start a recording you will drive yourself with `run` / `
|
|
181
|
+
/** Start a recording you will drive yourself with `run` / `observeError` / `finish`. */
|
|
179
182
|
createScope: (metadata: ExecutionMetadata) => ExecutionScope;
|
|
180
183
|
/**
|
|
181
184
|
* Wrap a function yourself when automatic instrumentation is not available.
|
|
@@ -191,7 +194,7 @@ export type ExecutionRuntime = {
|
|
|
191
194
|
createScope: (metadata: ExecutionMetadata) => ExecutionRuntimeScope;
|
|
192
195
|
trace: RasputinExecution['trace'];
|
|
193
196
|
getStats: RasputinExecution['getStats'];
|
|
194
|
-
getErrorState: (
|
|
197
|
+
getErrorState: (observation: ErrorObservation) => ExecutionState | undefined;
|
|
195
198
|
runFunction: <T>(definition: RuntimeFunctionDefinition | string, args: ArrayLike<unknown>, callback: () => T) => T;
|
|
196
199
|
runFunctionPlans: <T>(plans: readonly EncodedFunctionPlan[], planIndex: number, args: ArrayLike<unknown>, callback: () => T, omitValues?: boolean) => T;
|
|
197
200
|
prepareFunctionPlans: (plans: readonly EncodedFunctionPlan[]) => PreparedFunctionPlan[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-recorder-types.d.ts","sourceRoot":"","sources":["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;IACxD,2BAA2B,EAAE,MAAM,CAAC;IACpC,kEAAkE;IAClE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,eAAe,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,wBAAwB,EAAE,MAAM,CAAC;IACjC,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0GAA0G;IAC1G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG;IAC5B,+FAA+F;IAC/F,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC
|
|
1
|
+
{"version":3,"file":"execution-recorder-types.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,2FAA2F;AAC3F,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD,kFAAkF;AAClF,MAAM,MAAM,wBAAwB,GAAG;IACtC,sFAAsF;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AAU,CAAC,EAAE,OAAO,KAChB,CAAC,CAAC;IACP,qBAAqB,EAAE,CACtB,IAAI,EAAE,oBAAoB,EAC1B,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,EACxB,UAAU,CAAC,EAAE,OAAO,KAChB,kBAAkB,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAGX,wBAAwB,EACxB,gBAAgB,EAGhB,MAAM,4BAA4B,CAAC;AA2OpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,KAC3C,gBA2/CF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CaptureContext, RasputinClient, RasputinOptions } from '@rasputin-ai/core';
|
|
1
|
+
export type { CaptureContext, ErrorObservation, RasputinClient, RasputinOptions, } from '@rasputin-ai/core';
|
|
2
2
|
export type { ExecutionFunctionDescriptor, ExecutionKind, ExecutionMetadata, ExecutionRecorderOptions, ExecutionRecorderStats, ExecutionScope, ExecutionSourceExclusion, RasputinExecution, } from './execution-recorder';
|
|
3
3
|
export type { RasputinNodeClient, RasputinNodeClientStats, RasputinNodeOptions, } from './rasputin-init';
|
|
4
4
|
export { RasputinInit } from './rasputin-init';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,2BAA2B,EAC3B,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACX,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -476,6 +476,8 @@ var unavailable = () => ({
|
|
|
476
476
|
var noopHandle = {
|
|
477
477
|
flushSoon() {
|
|
478
478
|
},
|
|
479
|
+
start() {
|
|
480
|
+
},
|
|
479
481
|
async wait() {
|
|
480
482
|
},
|
|
481
483
|
disconnect() {
|
|
@@ -498,8 +500,12 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
498
500
|
let stopped = false;
|
|
499
501
|
let working = false;
|
|
500
502
|
let debounceTimer;
|
|
503
|
+
let retryTimer;
|
|
504
|
+
let failedAttempts = 0;
|
|
501
505
|
const sessionAbort = new AbortController();
|
|
502
506
|
const debounceMs = 500;
|
|
507
|
+
const retryMs = 3e3;
|
|
508
|
+
const maxAttempts = 5;
|
|
503
509
|
const packageNamesOf = (manifest) => [
|
|
504
510
|
...new Set(
|
|
505
511
|
manifest.functions.map((fn) => fn.source.packageName).filter((name) => Boolean(name))
|
|
@@ -525,6 +531,20 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
525
531
|
clearTimeout(debounceTimer);
|
|
526
532
|
debounceTimer = void 0;
|
|
527
533
|
};
|
|
534
|
+
const clearRetry = () => {
|
|
535
|
+
if (retryTimer === void 0) return;
|
|
536
|
+
clearTimeout(retryTimer);
|
|
537
|
+
retryTimer = void 0;
|
|
538
|
+
};
|
|
539
|
+
const armRetry = () => {
|
|
540
|
+
if (stopped || failedAttempts >= maxAttempts) return;
|
|
541
|
+
clearRetry();
|
|
542
|
+
retryTimer = setTimeout(() => {
|
|
543
|
+
retryTimer = void 0;
|
|
544
|
+
flushSoon();
|
|
545
|
+
}, retryMs);
|
|
546
|
+
retryTimer.unref?.();
|
|
547
|
+
};
|
|
528
548
|
const flushSoon = () => {
|
|
529
549
|
clearDebounce();
|
|
530
550
|
if (stopped || !isInstrumentationManifestDirty() || working) return;
|
|
@@ -543,7 +563,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
543
563
|
continue;
|
|
544
564
|
}
|
|
545
565
|
const controller = new AbortController();
|
|
546
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
566
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
547
567
|
timeout.unref?.();
|
|
548
568
|
const abortUpload = () => controller.abort();
|
|
549
569
|
sessionAbort.signal.addEventListener("abort", abortUpload, { once: true });
|
|
@@ -572,6 +592,8 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
572
592
|
if (result.ok) {
|
|
573
593
|
verification = result.verification;
|
|
574
594
|
markInstrumentationManifestUploaded(generation);
|
|
595
|
+
failedAttempts = 0;
|
|
596
|
+
clearRetry();
|
|
575
597
|
if (verification.status === "verified") {
|
|
576
598
|
if (!loggedSuccess && options.logSuccess !== false) {
|
|
577
599
|
loggedSuccess = true;
|
|
@@ -585,13 +607,21 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
585
607
|
}
|
|
586
608
|
continue;
|
|
587
609
|
}
|
|
588
|
-
|
|
610
|
+
failedAttempts += 1;
|
|
611
|
+
if (failedAttempts >= maxAttempts && !loggedFailure) {
|
|
589
612
|
loggedFailure = true;
|
|
590
613
|
console.warn(report(manifest, false, unavailable()));
|
|
591
614
|
}
|
|
615
|
+
armRetry();
|
|
592
616
|
break;
|
|
593
617
|
} catch {
|
|
594
618
|
if (stopped) return;
|
|
619
|
+
failedAttempts += 1;
|
|
620
|
+
if (failedAttempts >= maxAttempts && !loggedFailure) {
|
|
621
|
+
loggedFailure = true;
|
|
622
|
+
console.warn(report(manifest, false, unavailable()));
|
|
623
|
+
}
|
|
624
|
+
armRetry();
|
|
595
625
|
break;
|
|
596
626
|
} finally {
|
|
597
627
|
clearTimeout(timeout);
|
|
@@ -612,10 +642,15 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
612
642
|
}, debounceMs);
|
|
613
643
|
debounceTimer.unref?.();
|
|
614
644
|
};
|
|
615
|
-
|
|
616
|
-
|
|
645
|
+
const start = () => {
|
|
646
|
+
if (stopped) return;
|
|
647
|
+
setInstrumentationManifestOnDirty(armFlush);
|
|
648
|
+
if (isInstrumentationManifestDirty()) armFlush();
|
|
649
|
+
};
|
|
650
|
+
if (!options.deferStart) start();
|
|
617
651
|
return {
|
|
618
652
|
flushSoon,
|
|
653
|
+
start,
|
|
619
654
|
wait: async (timeoutMs) => {
|
|
620
655
|
flushSoon();
|
|
621
656
|
if (timeoutMs === void 0) {
|
|
@@ -639,6 +674,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
639
674
|
disconnect: () => {
|
|
640
675
|
stopped = true;
|
|
641
676
|
clearDebounce();
|
|
677
|
+
clearRetry();
|
|
642
678
|
setInstrumentationManifestOnDirty(void 0);
|
|
643
679
|
sessionAbort.abort();
|
|
644
680
|
},
|
|
@@ -658,6 +694,21 @@ import {
|
|
|
658
694
|
runtimeFunctionId as runtimeFunctionId2
|
|
659
695
|
} from "@rasputin-ai/core";
|
|
660
696
|
|
|
697
|
+
// src/execution-recorder/error-observation.ts
|
|
698
|
+
var bindings = /* @__PURE__ */ new WeakMap();
|
|
699
|
+
var mintErrorObservation = (binding) => {
|
|
700
|
+
const observation = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
701
|
+
bindings.set(observation, binding);
|
|
702
|
+
return observation;
|
|
703
|
+
};
|
|
704
|
+
var bindingForObservation = (value) => {
|
|
705
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
706
|
+
return bindings.get(value);
|
|
707
|
+
};
|
|
708
|
+
var inertErrorObservation = () => {
|
|
709
|
+
return Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
710
|
+
};
|
|
711
|
+
|
|
661
712
|
// src/execution-recorder/execution-journal.ts
|
|
662
713
|
var KIND_ENTER = 1;
|
|
663
714
|
var KIND_EXIT = 2;
|
|
@@ -2664,8 +2715,7 @@ var noOpExecution = {
|
|
|
2664
2715
|
createScope: () => ({
|
|
2665
2716
|
run: (callback) => callback(),
|
|
2666
2717
|
getErrorState: () => void 0,
|
|
2667
|
-
|
|
2668
|
-
},
|
|
2718
|
+
observeError: () => inertErrorObservation(),
|
|
2669
2719
|
finish: () => {
|
|
2670
2720
|
}
|
|
2671
2721
|
}),
|
|
@@ -2778,7 +2828,12 @@ var createExecutionRecorder = (options) => {
|
|
|
2778
2828
|
let nextRuntimePlanId = 1;
|
|
2779
2829
|
const internedPlans = /* @__PURE__ */ new Map();
|
|
2780
2830
|
const preparedModules = /* @__PURE__ */ new WeakMap();
|
|
2781
|
-
const
|
|
2831
|
+
const owner = {};
|
|
2832
|
+
const ownerGeneration = 1;
|
|
2833
|
+
let storageClock = 0;
|
|
2834
|
+
let occurrenceCounter = 0;
|
|
2835
|
+
const recordingsById = /* @__PURE__ */ new Map();
|
|
2836
|
+
const evictedRecordingIds = [];
|
|
2782
2837
|
const retainedErrorRecordings = [];
|
|
2783
2838
|
const phases = phaseTimingEnabled ? { alsNs: 0n, materializeNs: 0n } : void 0;
|
|
2784
2839
|
const stats = {
|
|
@@ -3011,6 +3066,39 @@ var createExecutionRecorder = (options) => {
|
|
|
3011
3066
|
};
|
|
3012
3067
|
return boundedState.truncated?.size ? enforceRuntimeStateSizeBudget(boundedState, runtimeStateSizeBudget) : boundedState;
|
|
3013
3068
|
};
|
|
3069
|
+
const forgetDiscardedRecording = (recording) => {
|
|
3070
|
+
if (recording.hasError || recording.retainedForError) return;
|
|
3071
|
+
recordingsById.delete(recording.executionId);
|
|
3072
|
+
};
|
|
3073
|
+
const discardSuccessfulEvidence = (recording) => {
|
|
3074
|
+
if (recording.evidenceDiscarded) return;
|
|
3075
|
+
recording.evidenceDiscarded = true;
|
|
3076
|
+
recording.cachedState = void 0;
|
|
3077
|
+
recording.repeatedCalls = [];
|
|
3078
|
+
recording.lateCapturedCallIds = void 0;
|
|
3079
|
+
recording.capturedErrors = /* @__PURE__ */ new WeakMap();
|
|
3080
|
+
if (recording.journal) {
|
|
3081
|
+
journalPool.release(recording.journal);
|
|
3082
|
+
recording.journal = void 0;
|
|
3083
|
+
}
|
|
3084
|
+
recordingsById.delete(recording.executionId);
|
|
3085
|
+
};
|
|
3086
|
+
const mintOccurrence = (recording, provenance) => mintErrorObservation({
|
|
3087
|
+
owner,
|
|
3088
|
+
ownerGeneration,
|
|
3089
|
+
recordingId: recording.executionId,
|
|
3090
|
+
recordingGeneration: recording.storageGeneration,
|
|
3091
|
+
occurrenceId: ++occurrenceCounter,
|
|
3092
|
+
provenance
|
|
3093
|
+
});
|
|
3094
|
+
const dropOldestEvictedRecording = () => {
|
|
3095
|
+
while (evictedRecordingIds.length > maxRetainedErrorRecordings) {
|
|
3096
|
+
const oldId = evictedRecordingIds.shift();
|
|
3097
|
+
if (!oldId) continue;
|
|
3098
|
+
const old = recordingsById.get(oldId);
|
|
3099
|
+
if (old?.evicted) recordingsById.delete(oldId);
|
|
3100
|
+
}
|
|
3101
|
+
};
|
|
3014
3102
|
const evictRetainedRecording = (recording) => {
|
|
3015
3103
|
const eventCount = recording.cachedState?.events.length ?? recording.journal?.eventCount ?? 0;
|
|
3016
3104
|
const dropped = (recording.cachedState?.truncated?.eventsDropped ?? recording.journal?.dropped ?? 0) + eventCount;
|
|
@@ -3035,6 +3123,8 @@ var createExecutionRecorder = (options) => {
|
|
|
3035
3123
|
eventsDropped: Math.max(1, dropped)
|
|
3036
3124
|
}
|
|
3037
3125
|
};
|
|
3126
|
+
evictedRecordingIds.push(recording.executionId);
|
|
3127
|
+
dropOldestEvictedRecording();
|
|
3038
3128
|
};
|
|
3039
3129
|
const trimFinishedRetainedRecordings = (keep) => {
|
|
3040
3130
|
while (retainedErrorRecordings.length > maxRetainedErrorRecordings) {
|
|
@@ -3112,10 +3202,17 @@ var createExecutionRecorder = (options) => {
|
|
|
3112
3202
|
}
|
|
3113
3203
|
}
|
|
3114
3204
|
};
|
|
3115
|
-
const
|
|
3116
|
-
recording.
|
|
3117
|
-
|
|
3118
|
-
|
|
3205
|
+
const retainFailure = (recording) => {
|
|
3206
|
+
if (recording.evidenceDiscarded) return;
|
|
3207
|
+
if (!recording.hasError) {
|
|
3208
|
+
recording.hasError = true;
|
|
3209
|
+
stats.errorSnapshots++;
|
|
3210
|
+
if (recording.memory.underPressure && !recording.partialSnapshotCounted) {
|
|
3211
|
+
recording.partialSnapshotCounted = true;
|
|
3212
|
+
stats.partialErrorSnapshots++;
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
if (recording.budgetExpired) {
|
|
3119
3216
|
const eventsDropped = Math.max(
|
|
3120
3217
|
1,
|
|
3121
3218
|
recording.cachedState?.capture?.eventsDropped ?? recording.cachedState?.truncated?.eventsDropped ?? recording.memory.eventsDropped
|
|
@@ -3133,15 +3230,23 @@ var createExecutionRecorder = (options) => {
|
|
|
3133
3230
|
};
|
|
3134
3231
|
}
|
|
3135
3232
|
retainErrorRecording(recording);
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
stats.partialErrorSnapshots++;
|
|
3142
|
-
}
|
|
3233
|
+
recordingsById.set(recording.executionId, recording);
|
|
3234
|
+
};
|
|
3235
|
+
const observeFailure = (recording, provenance) => {
|
|
3236
|
+
if (!recording.evidenceDiscarded) {
|
|
3237
|
+
retainFailure(recording);
|
|
3143
3238
|
}
|
|
3144
|
-
|
|
3239
|
+
return mintOccurrence(recording, provenance);
|
|
3240
|
+
};
|
|
3241
|
+
const stateForObservation = (observation) => {
|
|
3242
|
+
const binding = bindingForObservation(observation);
|
|
3243
|
+
if (!binding) return void 0;
|
|
3244
|
+
if (binding.owner !== owner || binding.ownerGeneration !== ownerGeneration) return void 0;
|
|
3245
|
+
const recording = recordingsById.get(binding.recordingId);
|
|
3246
|
+
if (!recording || recording.evidenceDiscarded || recording.storageGeneration !== binding.recordingGeneration) {
|
|
3247
|
+
return void 0;
|
|
3248
|
+
}
|
|
3249
|
+
return stateFrom(recording, recording.finishedAtNs);
|
|
3145
3250
|
};
|
|
3146
3251
|
const countDroppedEvents = (recording, droppedBefore) => {
|
|
3147
3252
|
const dropped = recording.journal?.dropped ?? droppedBefore;
|
|
@@ -3205,11 +3310,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3205
3310
|
};
|
|
3206
3311
|
const captureCompletedThrow = (recording, plan, args, parentCallId, startedAtNs, error, capturedArgs) => {
|
|
3207
3312
|
if (!recording.journal) {
|
|
3208
|
-
rememberError(error, recording);
|
|
3209
3313
|
return;
|
|
3210
3314
|
}
|
|
3211
3315
|
if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
|
|
3212
|
-
rememberError(error, recording);
|
|
3213
3316
|
return;
|
|
3214
3317
|
}
|
|
3215
3318
|
const callId = ++recording.nextCallId;
|
|
@@ -3235,7 +3338,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3235
3338
|
capturedError.commit();
|
|
3236
3339
|
}
|
|
3237
3340
|
countDroppedEvents(recording, droppedBefore);
|
|
3238
|
-
rememberError(error, recording);
|
|
3239
3341
|
};
|
|
3240
3342
|
const recordSuppressedCall = (recording, group, parentCallId, startedAtNs, endedAtNs) => {
|
|
3241
3343
|
stats.repeatedCallsSuppressed++;
|
|
@@ -3281,7 +3383,12 @@ var createExecutionRecorder = (options) => {
|
|
|
3281
3383
|
try {
|
|
3282
3384
|
if (!recording.finished || recording.inFlightCalls > 0) return;
|
|
3283
3385
|
memoryBudget.release(recording.memory);
|
|
3386
|
+
if (!recording.hasError && !recording.retainedForError) {
|
|
3387
|
+
discardSuccessfulEvidence(recording);
|
|
3388
|
+
return;
|
|
3389
|
+
}
|
|
3284
3390
|
releaseJournalIfIdle(recording);
|
|
3391
|
+
forgetDiscardedRecording(recording);
|
|
3285
3392
|
} catch {
|
|
3286
3393
|
}
|
|
3287
3394
|
};
|
|
@@ -3293,6 +3400,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3293
3400
|
recording.finished = true;
|
|
3294
3401
|
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
3295
3402
|
stats.activeExecutions = Math.max(0, stats.activeExecutions - 1);
|
|
3403
|
+
if (recording.runFailed && !recording.hasError) {
|
|
3404
|
+
retainFailure(recording);
|
|
3405
|
+
}
|
|
3296
3406
|
if (!recording.hasError) {
|
|
3297
3407
|
stats.successfulExecutionsDiscarded++;
|
|
3298
3408
|
}
|
|
@@ -3318,6 +3428,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3318
3428
|
sweepLongLivedExecutions(recorderStartedAtNs);
|
|
3319
3429
|
const recording = {
|
|
3320
3430
|
executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
|
|
3431
|
+
storageGeneration: ++storageClock,
|
|
3321
3432
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3322
3433
|
startedAtNs: recorderStartedAtNs,
|
|
3323
3434
|
inlineRecorderTimeNs: 0n,
|
|
@@ -3340,6 +3451,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3340
3451
|
stats.activeExecutions++;
|
|
3341
3452
|
stats.peakActiveExecutions = Math.max(stats.peakActiveExecutions, stats.activeExecutions);
|
|
3342
3453
|
liveRecordings.push(recording);
|
|
3454
|
+
recordingsById.set(recording.executionId, recording);
|
|
3343
3455
|
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3344
3456
|
const store = { recording };
|
|
3345
3457
|
return {
|
|
@@ -3353,8 +3465,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3353
3465
|
try {
|
|
3354
3466
|
return callback();
|
|
3355
3467
|
} catch (error) {
|
|
3468
|
+
recording.runFailed = true;
|
|
3356
3469
|
if (recording.budgetExpired || recording.evicted) {
|
|
3357
|
-
|
|
3470
|
+
retainFailure(recording);
|
|
3358
3471
|
}
|
|
3359
3472
|
throw error;
|
|
3360
3473
|
}
|
|
@@ -3364,21 +3477,21 @@ var createExecutionRecorder = (options) => {
|
|
|
3364
3477
|
return callback();
|
|
3365
3478
|
}
|
|
3366
3479
|
},
|
|
3367
|
-
|
|
3480
|
+
observeError: (_error) => {
|
|
3368
3481
|
try {
|
|
3369
|
-
|
|
3370
|
-
if (errorMetadata) mergeExecutionMetadata(recording.execution, errorMetadata);
|
|
3371
|
-
rememberError(error, recording);
|
|
3372
|
-
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3373
|
-
return stateFrom(recording, recording.finishedAtNs);
|
|
3482
|
+
return observeFailure(recording, "scope-observe");
|
|
3374
3483
|
} catch {
|
|
3375
|
-
return
|
|
3484
|
+
return inertErrorObservation();
|
|
3376
3485
|
}
|
|
3377
3486
|
},
|
|
3378
|
-
|
|
3487
|
+
getErrorState: (observation) => {
|
|
3379
3488
|
try {
|
|
3380
|
-
|
|
3489
|
+
const getStateStartedAtNs = process.hrtime.bigint();
|
|
3490
|
+
const state = stateForObservation(observation);
|
|
3491
|
+
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3492
|
+
return state;
|
|
3381
3493
|
} catch {
|
|
3494
|
+
return void 0;
|
|
3382
3495
|
}
|
|
3383
3496
|
},
|
|
3384
3497
|
finish: (finishMetadata) => finish(store, finishMetadata)
|
|
@@ -3387,16 +3500,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3387
3500
|
return noOpExecution.createScope(metadata);
|
|
3388
3501
|
}
|
|
3389
3502
|
};
|
|
3390
|
-
const getErrorState = (
|
|
3391
|
-
const getStateStartedAtNs = process.hrtime.bigint();
|
|
3503
|
+
const getErrorState = (observation) => {
|
|
3392
3504
|
try {
|
|
3393
|
-
|
|
3394
|
-
const recording = (weakKey ? errorExecutions.get(weakKey) : void 0) ?? currentStore()?.recording;
|
|
3395
|
-
if (!recording) return void 0;
|
|
3396
|
-
if (metadata) mergeExecutionMetadata(recording.execution, metadata);
|
|
3397
|
-
rememberError(error, recording);
|
|
3398
|
-
addRecorderTime(recording, process.hrtime.bigint() - getStateStartedAtNs);
|
|
3399
|
-
return stateFrom(recording, recording.finishedAtNs);
|
|
3505
|
+
return stateForObservation(observation);
|
|
3400
3506
|
} catch {
|
|
3401
3507
|
return void 0;
|
|
3402
3508
|
}
|
|
@@ -3431,7 +3537,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3431
3537
|
return callback();
|
|
3432
3538
|
} catch (error) {
|
|
3433
3539
|
if (store.recording.budgetExpired || store.recording.evicted) {
|
|
3434
|
-
|
|
3540
|
+
retainFailure(store.recording);
|
|
3435
3541
|
}
|
|
3436
3542
|
throw error;
|
|
3437
3543
|
}
|
|
@@ -3479,8 +3585,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3479
3585
|
recorderStartedAtNs,
|
|
3480
3586
|
callback,
|
|
3481
3587
|
() => settleInFlight(recording),
|
|
3482
|
-
(
|
|
3483
|
-
rememberError(error, recording);
|
|
3588
|
+
(_error) => {
|
|
3484
3589
|
settleInFlight(recording);
|
|
3485
3590
|
}
|
|
3486
3591
|
);
|
|
@@ -3512,8 +3617,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3512
3617
|
recorderStartedAtNs,
|
|
3513
3618
|
callback,
|
|
3514
3619
|
() => settleInFlight(recording),
|
|
3515
|
-
(
|
|
3516
|
-
rememberError(error, recording);
|
|
3620
|
+
(_error) => {
|
|
3517
3621
|
settleInFlight(recording);
|
|
3518
3622
|
}
|
|
3519
3623
|
);
|
|
@@ -3531,8 +3635,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3531
3635
|
recorderStartedAtNs,
|
|
3532
3636
|
callback,
|
|
3533
3637
|
() => settleInFlight(recording),
|
|
3534
|
-
(
|
|
3535
|
-
rememberError(error, recording);
|
|
3638
|
+
(_error) => {
|
|
3536
3639
|
settleInFlight(recording);
|
|
3537
3640
|
}
|
|
3538
3641
|
);
|
|
@@ -3556,7 +3659,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3556
3659
|
},
|
|
3557
3660
|
(error) => {
|
|
3558
3661
|
if (!recording.journal) {
|
|
3559
|
-
rememberError(error, recording);
|
|
3560
3662
|
settleInFlight(recording);
|
|
3561
3663
|
return;
|
|
3562
3664
|
}
|
|
@@ -3570,7 +3672,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3570
3672
|
);
|
|
3571
3673
|
stats.functionCallsCaptured++;
|
|
3572
3674
|
capturedError.commit();
|
|
3573
|
-
rememberError(error, recording);
|
|
3574
3675
|
settleInFlight(recording);
|
|
3575
3676
|
}
|
|
3576
3677
|
);
|
|
@@ -3645,8 +3746,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3645
3746
|
const expiredStore = { recording: expired };
|
|
3646
3747
|
return {
|
|
3647
3748
|
leave: (value) => value,
|
|
3648
|
-
fail: (
|
|
3649
|
-
rememberError(error, expired);
|
|
3749
|
+
fail: () => {
|
|
3650
3750
|
},
|
|
3651
3751
|
end: () => {
|
|
3652
3752
|
},
|
|
@@ -3780,10 +3880,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3780
3880
|
}
|
|
3781
3881
|
return value;
|
|
3782
3882
|
},
|
|
3783
|
-
fail: (
|
|
3883
|
+
fail: (_error) => {
|
|
3784
3884
|
if (status === "failed") return;
|
|
3785
3885
|
status = "failed";
|
|
3786
|
-
rememberError(error, recording);
|
|
3787
3886
|
},
|
|
3788
3887
|
end: finishEnd,
|
|
3789
3888
|
...context
|
|
@@ -3804,10 +3903,9 @@ var createExecutionRecorder = (options) => {
|
|
|
3804
3903
|
}
|
|
3805
3904
|
return value;
|
|
3806
3905
|
},
|
|
3807
|
-
fail: (
|
|
3906
|
+
fail: (_error) => {
|
|
3808
3907
|
if (status === "failed") return;
|
|
3809
3908
|
status = "failed";
|
|
3810
|
-
rememberError(error, recording);
|
|
3811
3909
|
},
|
|
3812
3910
|
end: finishEnd,
|
|
3813
3911
|
...context
|
|
@@ -3820,7 +3918,8 @@ var createExecutionRecorder = (options) => {
|
|
|
3820
3918
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3821
3919
|
} catch {
|
|
3822
3920
|
journal.dropCall();
|
|
3823
|
-
return dropWithoutCapture((
|
|
3921
|
+
return dropWithoutCapture(() => {
|
|
3922
|
+
});
|
|
3824
3923
|
}
|
|
3825
3924
|
const callStore = { recording, currentCallId: callId };
|
|
3826
3925
|
const captured = bindStoreTransitions(callStore, parentStore, recording, plan);
|
|
@@ -3835,7 +3934,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3835
3934
|
};
|
|
3836
3935
|
const writeThrow = (error) => {
|
|
3837
3936
|
if (!recording.journal) {
|
|
3838
|
-
rememberError(error, recording);
|
|
3839
3937
|
return;
|
|
3840
3938
|
}
|
|
3841
3939
|
const capturedError = serializedError(recording, error, callId);
|
|
@@ -3848,7 +3946,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3848
3946
|
);
|
|
3849
3947
|
stats.functionCallsCaptured++;
|
|
3850
3948
|
capturedError.commit();
|
|
3851
|
-
rememberError(error, recording);
|
|
3852
3949
|
};
|
|
3853
3950
|
return {
|
|
3854
3951
|
leave: (value) => {
|
|
@@ -3864,7 +3961,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3864
3961
|
try {
|
|
3865
3962
|
writeThrow(error);
|
|
3866
3963
|
} catch {
|
|
3867
|
-
rememberError(error, recording);
|
|
3868
3964
|
}
|
|
3869
3965
|
},
|
|
3870
3966
|
end: () => {
|
|
@@ -4169,7 +4265,7 @@ var installGlobalHandlers = (client, options = {}) => {
|
|
|
4169
4265
|
|
|
4170
4266
|
// src/sdk-meta.ts
|
|
4171
4267
|
var SDK_NAME = "@rasputin-ai/node";
|
|
4172
|
-
var SDK_VERSION = "0.
|
|
4268
|
+
var SDK_VERSION = "0.7.0";
|
|
4173
4269
|
|
|
4174
4270
|
// src/rasputin-init.ts
|
|
4175
4271
|
var publicExecution = (runtime) => ({
|
|
@@ -4177,7 +4273,7 @@ var publicExecution = (runtime) => ({
|
|
|
4177
4273
|
const scope = runtime.createScope(metadata);
|
|
4178
4274
|
return {
|
|
4179
4275
|
run: scope.run,
|
|
4180
|
-
|
|
4276
|
+
observeError: scope.observeError,
|
|
4181
4277
|
finish: scope.finish
|
|
4182
4278
|
};
|
|
4183
4279
|
},
|
|
@@ -4231,10 +4327,7 @@ var RasputinInit = (options) => {
|
|
|
4231
4327
|
sdkVersion: SDK_VERSION,
|
|
4232
4328
|
sdkName: SDK_NAME,
|
|
4233
4329
|
installTransportSignalHandlers: options.installTransportSignalHandlers,
|
|
4234
|
-
|
|
4235
|
-
error,
|
|
4236
|
-
context?.request ? { kind: "http", request: context.request } : void 0
|
|
4237
|
-
)
|
|
4330
|
+
resolveObservation: (observation) => runtime.getErrorState(observation)
|
|
4238
4331
|
});
|
|
4239
4332
|
if (enabled) {
|
|
4240
4333
|
loadInstrumentationManifestIfPresent(
|