@rasputin-ai/node 0.6.1 → 0.6.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.
@@ -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;CACjB,CAAC;AAEF,KAAK,mCAAmC,GAAG;IAC1C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,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;AAkBF,eAAO,MAAM,qCAAqC,GACjD,SAAS,4CAA4C,KACnD,mCA2LF,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"}
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(), 2e3);
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
- if (!loggedFailure) {
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
- setInstrumentationManifestOnDirty(armFlush);
616
- if (isInstrumentationManifestDirty()) armFlush();
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
  },
@@ -4169,7 +4205,7 @@ var installGlobalHandlers = (client, options = {}) => {
4169
4205
 
4170
4206
  // src/sdk-meta.ts
4171
4207
  var SDK_NAME = "@rasputin-ai/node";
4172
- var SDK_VERSION = "0.6.1";
4208
+ var SDK_VERSION = "0.6.2";
4173
4209
 
4174
4210
  // src/rasputin-init.ts
4175
4211
  var publicExecution = (runtime) => ({
@@ -1594,7 +1594,7 @@ import ts15 from "typescript";
1594
1594
  import { originalPositionFor as originalPositionFor2, TraceMap as TraceMap3 } from "@jridgewell/trace-mapping";
1595
1595
 
1596
1596
  // src/sdk-meta.ts
1597
- var SDK_VERSION = "0.6.1";
1597
+ var SDK_VERSION = "0.6.2";
1598
1598
 
1599
1599
  // src/auto-instrumentation/source-map-locations.ts
1600
1600
  import { readFileSync } from "node:fs";
@@ -1656,7 +1656,7 @@ import ts15 from "typescript";
1656
1656
  import { originalPositionFor as originalPositionFor3, TraceMap as TraceMap4 } from "@jridgewell/trace-mapping";
1657
1657
 
1658
1658
  // src/sdk-meta.ts
1659
- var SDK_VERSION = "0.6.1";
1659
+ var SDK_VERSION = "0.6.2";
1660
1660
 
1661
1661
  // src/auto-instrumentation/transform-disk-cache.ts
1662
1662
  var projectCacheDir = () => {
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(), 2e3);
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
- if (!loggedFailure) {
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
- setInstrumentationManifestOnDirty(armFlush);
587
- if (isInstrumentationManifestDirty()) armFlush();
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
  },
@@ -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.6.1";
3
+ export declare const SDK_VERSION = "0.6.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.6.1",
3
+ "version": "0.6.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.6.1",
52
+ "@rasputin-ai/core": "0.6.2",
53
53
  "typescript": "5"
54
54
  },
55
55
  "devDependencies": {