@deeplake/hivemind 0.7.60 → 0.7.62
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/bundle/cli.js +34 -0
- package/codex/bundle/capture.js +34 -0
- package/codex/bundle/commands/auth-login.js +34 -0
- package/codex/bundle/graph-pull-worker.js +34 -0
- package/codex/bundle/pre-tool-use.js +34 -0
- package/codex/bundle/session-start-setup.js +34 -0
- package/codex/bundle/session-start.js +34 -0
- package/codex/bundle/shell/deeplake-shell.js +34 -0
- package/codex/bundle/stop.js +34 -0
- package/cursor/bundle/capture.js +34 -0
- package/cursor/bundle/commands/auth-login.js +34 -0
- package/cursor/bundle/graph-pull-worker.js +34 -0
- package/cursor/bundle/pre-tool-use.js +34 -0
- package/cursor/bundle/session-start.js +34 -0
- package/cursor/bundle/shell/deeplake-shell.js +34 -0
- package/hermes/bundle/capture.js +34 -0
- package/hermes/bundle/commands/auth-login.js +34 -0
- package/hermes/bundle/graph-pull-worker.js +34 -0
- package/hermes/bundle/pre-tool-use.js +34 -0
- package/hermes/bundle/session-start.js +34 -0
- package/hermes/bundle/shell/deeplake-shell.js +34 -0
- package/mcp/bundle/server.js +34 -0
- package/openclaw/dist/index.js +29 -1
- package/openclaw/openclaw.plugin.json +1 -1
- package/openclaw/package.json +1 -1
- package/package.json +2 -1
- package/scripts/audit-openclaw-bundle.mjs +187 -0
- package/scripts/ensure-tree-sitter.mjs +91 -0
- package/scripts/pack-check.mjs +29 -0
- package/scripts/sync-versions.d.mts +15 -0
- package/scripts/sync-versions.mjs +103 -0
- package/scripts/verify-install.sh +218 -0
|
@@ -741,6 +741,9 @@ function traceSql(msg) {
|
|
|
741
741
|
log3(msg);
|
|
742
742
|
}
|
|
743
743
|
var _signalledBalanceExhausted = false;
|
|
744
|
+
var _signalledLowBalance = false;
|
|
745
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
746
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
744
747
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
745
748
|
if (status !== 402)
|
|
746
749
|
return;
|
|
@@ -761,6 +764,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
761
764
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
762
765
|
});
|
|
763
766
|
}
|
|
767
|
+
function signalLowBalanceFromHeader(resp) {
|
|
768
|
+
if (_signalledLowBalance)
|
|
769
|
+
return;
|
|
770
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
771
|
+
if (!raw)
|
|
772
|
+
return;
|
|
773
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
774
|
+
return;
|
|
775
|
+
const balance = Number(raw.trim());
|
|
776
|
+
if (!Number.isFinite(balance))
|
|
777
|
+
return;
|
|
778
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
779
|
+
return;
|
|
780
|
+
if (balance <= 0)
|
|
781
|
+
return;
|
|
782
|
+
_signalledLowBalance = true;
|
|
783
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
784
|
+
enqueueNotification({
|
|
785
|
+
id: "low-balance-warning",
|
|
786
|
+
severity: "warn",
|
|
787
|
+
transient: true,
|
|
788
|
+
title: "Your org's Hivemind balance is running low",
|
|
789
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
790
|
+
dedupKey: { reason: "low-balance" }
|
|
791
|
+
}).catch((e) => {
|
|
792
|
+
_signalledLowBalance = false;
|
|
793
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
794
|
+
});
|
|
795
|
+
}
|
|
764
796
|
function billingUrl() {
|
|
765
797
|
try {
|
|
766
798
|
const c = loadCredentials();
|
|
@@ -886,6 +918,7 @@ var DeeplakeApi = class {
|
|
|
886
918
|
}
|
|
887
919
|
throw lastError;
|
|
888
920
|
}
|
|
921
|
+
signalLowBalanceFromHeader(resp);
|
|
889
922
|
if (resp.ok) {
|
|
890
923
|
const raw = await resp.json();
|
|
891
924
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -1046,6 +1079,7 @@ var DeeplakeApi = class {
|
|
|
1046
1079
|
...deeplakeClientHeader()
|
|
1047
1080
|
}
|
|
1048
1081
|
});
|
|
1082
|
+
signalLowBalanceFromHeader(resp);
|
|
1049
1083
|
if (resp.ok) {
|
|
1050
1084
|
const data = await resp.json();
|
|
1051
1085
|
return {
|
|
@@ -468,6 +468,9 @@ function traceSql(msg) {
|
|
|
468
468
|
log3(msg);
|
|
469
469
|
}
|
|
470
470
|
var _signalledBalanceExhausted = false;
|
|
471
|
+
var _signalledLowBalance = false;
|
|
472
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
473
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
471
474
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
472
475
|
if (status !== 402)
|
|
473
476
|
return;
|
|
@@ -488,6 +491,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
488
491
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
489
492
|
});
|
|
490
493
|
}
|
|
494
|
+
function signalLowBalanceFromHeader(resp) {
|
|
495
|
+
if (_signalledLowBalance)
|
|
496
|
+
return;
|
|
497
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
498
|
+
if (!raw)
|
|
499
|
+
return;
|
|
500
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
501
|
+
return;
|
|
502
|
+
const balance = Number(raw.trim());
|
|
503
|
+
if (!Number.isFinite(balance))
|
|
504
|
+
return;
|
|
505
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
506
|
+
return;
|
|
507
|
+
if (balance <= 0)
|
|
508
|
+
return;
|
|
509
|
+
_signalledLowBalance = true;
|
|
510
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
511
|
+
enqueueNotification({
|
|
512
|
+
id: "low-balance-warning",
|
|
513
|
+
severity: "warn",
|
|
514
|
+
transient: true,
|
|
515
|
+
title: "Your org's Hivemind balance is running low",
|
|
516
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
517
|
+
dedupKey: { reason: "low-balance" }
|
|
518
|
+
}).catch((e) => {
|
|
519
|
+
_signalledLowBalance = false;
|
|
520
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
491
523
|
function billingUrl() {
|
|
492
524
|
try {
|
|
493
525
|
const c = loadCredentials();
|
|
@@ -613,6 +645,7 @@ var DeeplakeApi = class {
|
|
|
613
645
|
}
|
|
614
646
|
throw lastError;
|
|
615
647
|
}
|
|
648
|
+
signalLowBalanceFromHeader(resp);
|
|
616
649
|
if (resp.ok) {
|
|
617
650
|
const raw = await resp.json();
|
|
618
651
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -773,6 +806,7 @@ var DeeplakeApi = class {
|
|
|
773
806
|
...deeplakeClientHeader()
|
|
774
807
|
}
|
|
775
808
|
});
|
|
809
|
+
signalLowBalanceFromHeader(resp);
|
|
776
810
|
if (resp.ok) {
|
|
777
811
|
const data = await resp.json();
|
|
778
812
|
return {
|
|
@@ -477,6 +477,9 @@ function traceSql(msg) {
|
|
|
477
477
|
log3(msg);
|
|
478
478
|
}
|
|
479
479
|
var _signalledBalanceExhausted = false;
|
|
480
|
+
var _signalledLowBalance = false;
|
|
481
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
482
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
480
483
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
481
484
|
if (status !== 402)
|
|
482
485
|
return;
|
|
@@ -497,6 +500,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
497
500
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
498
501
|
});
|
|
499
502
|
}
|
|
503
|
+
function signalLowBalanceFromHeader(resp) {
|
|
504
|
+
if (_signalledLowBalance)
|
|
505
|
+
return;
|
|
506
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
507
|
+
if (!raw)
|
|
508
|
+
return;
|
|
509
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
510
|
+
return;
|
|
511
|
+
const balance = Number(raw.trim());
|
|
512
|
+
if (!Number.isFinite(balance))
|
|
513
|
+
return;
|
|
514
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
515
|
+
return;
|
|
516
|
+
if (balance <= 0)
|
|
517
|
+
return;
|
|
518
|
+
_signalledLowBalance = true;
|
|
519
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
520
|
+
enqueueNotification({
|
|
521
|
+
id: "low-balance-warning",
|
|
522
|
+
severity: "warn",
|
|
523
|
+
transient: true,
|
|
524
|
+
title: "Your org's Hivemind balance is running low",
|
|
525
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
526
|
+
dedupKey: { reason: "low-balance" }
|
|
527
|
+
}).catch((e) => {
|
|
528
|
+
_signalledLowBalance = false;
|
|
529
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
500
532
|
function billingUrl() {
|
|
501
533
|
try {
|
|
502
534
|
const c = loadCredentials();
|
|
@@ -622,6 +654,7 @@ var DeeplakeApi = class {
|
|
|
622
654
|
}
|
|
623
655
|
throw lastError;
|
|
624
656
|
}
|
|
657
|
+
signalLowBalanceFromHeader(resp);
|
|
625
658
|
if (resp.ok) {
|
|
626
659
|
const raw = await resp.json();
|
|
627
660
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -782,6 +815,7 @@ var DeeplakeApi = class {
|
|
|
782
815
|
...deeplakeClientHeader()
|
|
783
816
|
}
|
|
784
817
|
});
|
|
818
|
+
signalLowBalanceFromHeader(resp);
|
|
785
819
|
if (resp.ok) {
|
|
786
820
|
const data = await resp.json();
|
|
787
821
|
return {
|
|
@@ -533,6 +533,9 @@ function traceSql(msg) {
|
|
|
533
533
|
log3(msg);
|
|
534
534
|
}
|
|
535
535
|
var _signalledBalanceExhausted = false;
|
|
536
|
+
var _signalledLowBalance = false;
|
|
537
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
538
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
536
539
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
537
540
|
if (status !== 402)
|
|
538
541
|
return;
|
|
@@ -553,6 +556,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
553
556
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
554
557
|
});
|
|
555
558
|
}
|
|
559
|
+
function signalLowBalanceFromHeader(resp) {
|
|
560
|
+
if (_signalledLowBalance)
|
|
561
|
+
return;
|
|
562
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
563
|
+
if (!raw)
|
|
564
|
+
return;
|
|
565
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
566
|
+
return;
|
|
567
|
+
const balance = Number(raw.trim());
|
|
568
|
+
if (!Number.isFinite(balance))
|
|
569
|
+
return;
|
|
570
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
571
|
+
return;
|
|
572
|
+
if (balance <= 0)
|
|
573
|
+
return;
|
|
574
|
+
_signalledLowBalance = true;
|
|
575
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
576
|
+
enqueueNotification({
|
|
577
|
+
id: "low-balance-warning",
|
|
578
|
+
severity: "warn",
|
|
579
|
+
transient: true,
|
|
580
|
+
title: "Your org's Hivemind balance is running low",
|
|
581
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
582
|
+
dedupKey: { reason: "low-balance" }
|
|
583
|
+
}).catch((e) => {
|
|
584
|
+
_signalledLowBalance = false;
|
|
585
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
586
|
+
});
|
|
587
|
+
}
|
|
556
588
|
function billingUrl() {
|
|
557
589
|
try {
|
|
558
590
|
const c = loadCredentials();
|
|
@@ -678,6 +710,7 @@ var DeeplakeApi = class {
|
|
|
678
710
|
}
|
|
679
711
|
throw lastError;
|
|
680
712
|
}
|
|
713
|
+
signalLowBalanceFromHeader(resp);
|
|
681
714
|
if (resp.ok) {
|
|
682
715
|
const raw = await resp.json();
|
|
683
716
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -838,6 +871,7 @@ var DeeplakeApi = class {
|
|
|
838
871
|
...deeplakeClientHeader()
|
|
839
872
|
}
|
|
840
873
|
});
|
|
874
|
+
signalLowBalanceFromHeader(resp);
|
|
841
875
|
if (resp.ok) {
|
|
842
876
|
const data = await resp.json();
|
|
843
877
|
return {
|
|
@@ -67172,6 +67172,9 @@ function traceSql(msg) {
|
|
|
67172
67172
|
log3(msg);
|
|
67173
67173
|
}
|
|
67174
67174
|
var _signalledBalanceExhausted = false;
|
|
67175
|
+
var _signalledLowBalance = false;
|
|
67176
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
67177
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
67175
67178
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
67176
67179
|
if (status !== 402)
|
|
67177
67180
|
return;
|
|
@@ -67192,6 +67195,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
67192
67195
|
log3(`enqueue balance-exhausted failed: ${e6 instanceof Error ? e6.message : String(e6)}`);
|
|
67193
67196
|
});
|
|
67194
67197
|
}
|
|
67198
|
+
function signalLowBalanceFromHeader(resp) {
|
|
67199
|
+
if (_signalledLowBalance)
|
|
67200
|
+
return;
|
|
67201
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
67202
|
+
if (!raw)
|
|
67203
|
+
return;
|
|
67204
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
67205
|
+
return;
|
|
67206
|
+
const balance = Number(raw.trim());
|
|
67207
|
+
if (!Number.isFinite(balance))
|
|
67208
|
+
return;
|
|
67209
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
67210
|
+
return;
|
|
67211
|
+
if (balance <= 0)
|
|
67212
|
+
return;
|
|
67213
|
+
_signalledLowBalance = true;
|
|
67214
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
67215
|
+
enqueueNotification({
|
|
67216
|
+
id: "low-balance-warning",
|
|
67217
|
+
severity: "warn",
|
|
67218
|
+
transient: true,
|
|
67219
|
+
title: "Your org's Hivemind balance is running low",
|
|
67220
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
67221
|
+
dedupKey: { reason: "low-balance" }
|
|
67222
|
+
}).catch((e6) => {
|
|
67223
|
+
_signalledLowBalance = false;
|
|
67224
|
+
log3(`enqueue low-balance failed: ${e6 instanceof Error ? e6.message : String(e6)}`);
|
|
67225
|
+
});
|
|
67226
|
+
}
|
|
67195
67227
|
function billingUrl() {
|
|
67196
67228
|
try {
|
|
67197
67229
|
const c15 = loadCredentials();
|
|
@@ -67317,6 +67349,7 @@ var DeeplakeApi = class {
|
|
|
67317
67349
|
}
|
|
67318
67350
|
throw lastError;
|
|
67319
67351
|
}
|
|
67352
|
+
signalLowBalanceFromHeader(resp);
|
|
67320
67353
|
if (resp.ok) {
|
|
67321
67354
|
const raw = await resp.json();
|
|
67322
67355
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -67477,6 +67510,7 @@ var DeeplakeApi = class {
|
|
|
67477
67510
|
...deeplakeClientHeader()
|
|
67478
67511
|
}
|
|
67479
67512
|
});
|
|
67513
|
+
signalLowBalanceFromHeader(resp);
|
|
67480
67514
|
if (resp.ok) {
|
|
67481
67515
|
const data = await resp.json();
|
|
67482
67516
|
return {
|
package/hermes/bundle/capture.js
CHANGED
|
@@ -477,6 +477,9 @@ function traceSql(msg) {
|
|
|
477
477
|
log3(msg);
|
|
478
478
|
}
|
|
479
479
|
var _signalledBalanceExhausted = false;
|
|
480
|
+
var _signalledLowBalance = false;
|
|
481
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
482
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
480
483
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
481
484
|
if (status !== 402)
|
|
482
485
|
return;
|
|
@@ -497,6 +500,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
497
500
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
498
501
|
});
|
|
499
502
|
}
|
|
503
|
+
function signalLowBalanceFromHeader(resp) {
|
|
504
|
+
if (_signalledLowBalance)
|
|
505
|
+
return;
|
|
506
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
507
|
+
if (!raw)
|
|
508
|
+
return;
|
|
509
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
510
|
+
return;
|
|
511
|
+
const balance = Number(raw.trim());
|
|
512
|
+
if (!Number.isFinite(balance))
|
|
513
|
+
return;
|
|
514
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
515
|
+
return;
|
|
516
|
+
if (balance <= 0)
|
|
517
|
+
return;
|
|
518
|
+
_signalledLowBalance = true;
|
|
519
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
520
|
+
enqueueNotification({
|
|
521
|
+
id: "low-balance-warning",
|
|
522
|
+
severity: "warn",
|
|
523
|
+
transient: true,
|
|
524
|
+
title: "Your org's Hivemind balance is running low",
|
|
525
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
526
|
+
dedupKey: { reason: "low-balance" }
|
|
527
|
+
}).catch((e) => {
|
|
528
|
+
_signalledLowBalance = false;
|
|
529
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
500
532
|
function billingUrl() {
|
|
501
533
|
try {
|
|
502
534
|
const c = loadCredentials();
|
|
@@ -622,6 +654,7 @@ var DeeplakeApi = class {
|
|
|
622
654
|
}
|
|
623
655
|
throw lastError;
|
|
624
656
|
}
|
|
657
|
+
signalLowBalanceFromHeader(resp);
|
|
625
658
|
if (resp.ok) {
|
|
626
659
|
const raw = await resp.json();
|
|
627
660
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -782,6 +815,7 @@ var DeeplakeApi = class {
|
|
|
782
815
|
...deeplakeClientHeader()
|
|
783
816
|
}
|
|
784
817
|
});
|
|
818
|
+
signalLowBalanceFromHeader(resp);
|
|
785
819
|
if (resp.ok) {
|
|
786
820
|
const data = await resp.json();
|
|
787
821
|
return {
|
|
@@ -741,6 +741,9 @@ function traceSql(msg) {
|
|
|
741
741
|
log3(msg);
|
|
742
742
|
}
|
|
743
743
|
var _signalledBalanceExhausted = false;
|
|
744
|
+
var _signalledLowBalance = false;
|
|
745
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
746
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
744
747
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
745
748
|
if (status !== 402)
|
|
746
749
|
return;
|
|
@@ -761,6 +764,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
761
764
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
762
765
|
});
|
|
763
766
|
}
|
|
767
|
+
function signalLowBalanceFromHeader(resp) {
|
|
768
|
+
if (_signalledLowBalance)
|
|
769
|
+
return;
|
|
770
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
771
|
+
if (!raw)
|
|
772
|
+
return;
|
|
773
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
774
|
+
return;
|
|
775
|
+
const balance = Number(raw.trim());
|
|
776
|
+
if (!Number.isFinite(balance))
|
|
777
|
+
return;
|
|
778
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
779
|
+
return;
|
|
780
|
+
if (balance <= 0)
|
|
781
|
+
return;
|
|
782
|
+
_signalledLowBalance = true;
|
|
783
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
784
|
+
enqueueNotification({
|
|
785
|
+
id: "low-balance-warning",
|
|
786
|
+
severity: "warn",
|
|
787
|
+
transient: true,
|
|
788
|
+
title: "Your org's Hivemind balance is running low",
|
|
789
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
790
|
+
dedupKey: { reason: "low-balance" }
|
|
791
|
+
}).catch((e) => {
|
|
792
|
+
_signalledLowBalance = false;
|
|
793
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
794
|
+
});
|
|
795
|
+
}
|
|
764
796
|
function billingUrl() {
|
|
765
797
|
try {
|
|
766
798
|
const c = loadCredentials();
|
|
@@ -886,6 +918,7 @@ var DeeplakeApi = class {
|
|
|
886
918
|
}
|
|
887
919
|
throw lastError;
|
|
888
920
|
}
|
|
921
|
+
signalLowBalanceFromHeader(resp);
|
|
889
922
|
if (resp.ok) {
|
|
890
923
|
const raw = await resp.json();
|
|
891
924
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -1046,6 +1079,7 @@ var DeeplakeApi = class {
|
|
|
1046
1079
|
...deeplakeClientHeader()
|
|
1047
1080
|
}
|
|
1048
1081
|
});
|
|
1082
|
+
signalLowBalanceFromHeader(resp);
|
|
1049
1083
|
if (resp.ok) {
|
|
1050
1084
|
const data = await resp.json();
|
|
1051
1085
|
return {
|
|
@@ -468,6 +468,9 @@ function traceSql(msg) {
|
|
|
468
468
|
log3(msg);
|
|
469
469
|
}
|
|
470
470
|
var _signalledBalanceExhausted = false;
|
|
471
|
+
var _signalledLowBalance = false;
|
|
472
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
473
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
471
474
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
472
475
|
if (status !== 402)
|
|
473
476
|
return;
|
|
@@ -488,6 +491,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
488
491
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
489
492
|
});
|
|
490
493
|
}
|
|
494
|
+
function signalLowBalanceFromHeader(resp) {
|
|
495
|
+
if (_signalledLowBalance)
|
|
496
|
+
return;
|
|
497
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
498
|
+
if (!raw)
|
|
499
|
+
return;
|
|
500
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
501
|
+
return;
|
|
502
|
+
const balance = Number(raw.trim());
|
|
503
|
+
if (!Number.isFinite(balance))
|
|
504
|
+
return;
|
|
505
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
506
|
+
return;
|
|
507
|
+
if (balance <= 0)
|
|
508
|
+
return;
|
|
509
|
+
_signalledLowBalance = true;
|
|
510
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
511
|
+
enqueueNotification({
|
|
512
|
+
id: "low-balance-warning",
|
|
513
|
+
severity: "warn",
|
|
514
|
+
transient: true,
|
|
515
|
+
title: "Your org's Hivemind balance is running low",
|
|
516
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
517
|
+
dedupKey: { reason: "low-balance" }
|
|
518
|
+
}).catch((e) => {
|
|
519
|
+
_signalledLowBalance = false;
|
|
520
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
491
523
|
function billingUrl() {
|
|
492
524
|
try {
|
|
493
525
|
const c = loadCredentials();
|
|
@@ -613,6 +645,7 @@ var DeeplakeApi = class {
|
|
|
613
645
|
}
|
|
614
646
|
throw lastError;
|
|
615
647
|
}
|
|
648
|
+
signalLowBalanceFromHeader(resp);
|
|
616
649
|
if (resp.ok) {
|
|
617
650
|
const raw = await resp.json();
|
|
618
651
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -773,6 +806,7 @@ var DeeplakeApi = class {
|
|
|
773
806
|
...deeplakeClientHeader()
|
|
774
807
|
}
|
|
775
808
|
});
|
|
809
|
+
signalLowBalanceFromHeader(resp);
|
|
776
810
|
if (resp.ok) {
|
|
777
811
|
const data = await resp.json();
|
|
778
812
|
return {
|
|
@@ -477,6 +477,9 @@ function traceSql(msg) {
|
|
|
477
477
|
log3(msg);
|
|
478
478
|
}
|
|
479
479
|
var _signalledBalanceExhausted = false;
|
|
480
|
+
var _signalledLowBalance = false;
|
|
481
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
482
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
480
483
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
481
484
|
if (status !== 402)
|
|
482
485
|
return;
|
|
@@ -497,6 +500,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
497
500
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
498
501
|
});
|
|
499
502
|
}
|
|
503
|
+
function signalLowBalanceFromHeader(resp) {
|
|
504
|
+
if (_signalledLowBalance)
|
|
505
|
+
return;
|
|
506
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
507
|
+
if (!raw)
|
|
508
|
+
return;
|
|
509
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
510
|
+
return;
|
|
511
|
+
const balance = Number(raw.trim());
|
|
512
|
+
if (!Number.isFinite(balance))
|
|
513
|
+
return;
|
|
514
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
515
|
+
return;
|
|
516
|
+
if (balance <= 0)
|
|
517
|
+
return;
|
|
518
|
+
_signalledLowBalance = true;
|
|
519
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
520
|
+
enqueueNotification({
|
|
521
|
+
id: "low-balance-warning",
|
|
522
|
+
severity: "warn",
|
|
523
|
+
transient: true,
|
|
524
|
+
title: "Your org's Hivemind balance is running low",
|
|
525
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
526
|
+
dedupKey: { reason: "low-balance" }
|
|
527
|
+
}).catch((e) => {
|
|
528
|
+
_signalledLowBalance = false;
|
|
529
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
500
532
|
function billingUrl() {
|
|
501
533
|
try {
|
|
502
534
|
const c = loadCredentials();
|
|
@@ -622,6 +654,7 @@ var DeeplakeApi = class {
|
|
|
622
654
|
}
|
|
623
655
|
throw lastError;
|
|
624
656
|
}
|
|
657
|
+
signalLowBalanceFromHeader(resp);
|
|
625
658
|
if (resp.ok) {
|
|
626
659
|
const raw = await resp.json();
|
|
627
660
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -782,6 +815,7 @@ var DeeplakeApi = class {
|
|
|
782
815
|
...deeplakeClientHeader()
|
|
783
816
|
}
|
|
784
817
|
});
|
|
818
|
+
signalLowBalanceFromHeader(resp);
|
|
785
819
|
if (resp.ok) {
|
|
786
820
|
const data = await resp.json();
|
|
787
821
|
return {
|
|
@@ -532,6 +532,9 @@ function traceSql(msg) {
|
|
|
532
532
|
log3(msg);
|
|
533
533
|
}
|
|
534
534
|
var _signalledBalanceExhausted = false;
|
|
535
|
+
var _signalledLowBalance = false;
|
|
536
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
537
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
535
538
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
536
539
|
if (status !== 402)
|
|
537
540
|
return;
|
|
@@ -552,6 +555,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
552
555
|
log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
553
556
|
});
|
|
554
557
|
}
|
|
558
|
+
function signalLowBalanceFromHeader(resp) {
|
|
559
|
+
if (_signalledLowBalance)
|
|
560
|
+
return;
|
|
561
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
562
|
+
if (!raw)
|
|
563
|
+
return;
|
|
564
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
565
|
+
return;
|
|
566
|
+
const balance = Number(raw.trim());
|
|
567
|
+
if (!Number.isFinite(balance))
|
|
568
|
+
return;
|
|
569
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
570
|
+
return;
|
|
571
|
+
if (balance <= 0)
|
|
572
|
+
return;
|
|
573
|
+
_signalledLowBalance = true;
|
|
574
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
575
|
+
enqueueNotification({
|
|
576
|
+
id: "low-balance-warning",
|
|
577
|
+
severity: "warn",
|
|
578
|
+
transient: true,
|
|
579
|
+
title: "Your org's Hivemind balance is running low",
|
|
580
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
581
|
+
dedupKey: { reason: "low-balance" }
|
|
582
|
+
}).catch((e) => {
|
|
583
|
+
_signalledLowBalance = false;
|
|
584
|
+
log3(`enqueue low-balance failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
585
|
+
});
|
|
586
|
+
}
|
|
555
587
|
function billingUrl() {
|
|
556
588
|
try {
|
|
557
589
|
const c = loadCredentials();
|
|
@@ -677,6 +709,7 @@ var DeeplakeApi = class {
|
|
|
677
709
|
}
|
|
678
710
|
throw lastError;
|
|
679
711
|
}
|
|
712
|
+
signalLowBalanceFromHeader(resp);
|
|
680
713
|
if (resp.ok) {
|
|
681
714
|
const raw = await resp.json();
|
|
682
715
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -837,6 +870,7 @@ var DeeplakeApi = class {
|
|
|
837
870
|
...deeplakeClientHeader()
|
|
838
871
|
}
|
|
839
872
|
});
|
|
873
|
+
signalLowBalanceFromHeader(resp);
|
|
840
874
|
if (resp.ok) {
|
|
841
875
|
const data = await resp.json();
|
|
842
876
|
return {
|
|
@@ -67172,6 +67172,9 @@ function traceSql(msg) {
|
|
|
67172
67172
|
log3(msg);
|
|
67173
67173
|
}
|
|
67174
67174
|
var _signalledBalanceExhausted = false;
|
|
67175
|
+
var _signalledLowBalance = false;
|
|
67176
|
+
var LOW_BALANCE_THRESHOLD_CENTS = 200;
|
|
67177
|
+
var BALANCE_HEADER = "X-Activeloop-Balance-Cents";
|
|
67175
67178
|
function maybeSignalBalanceExhausted(status, bodyText) {
|
|
67176
67179
|
if (status !== 402)
|
|
67177
67180
|
return;
|
|
@@ -67192,6 +67195,35 @@ function maybeSignalBalanceExhausted(status, bodyText) {
|
|
|
67192
67195
|
log3(`enqueue balance-exhausted failed: ${e6 instanceof Error ? e6.message : String(e6)}`);
|
|
67193
67196
|
});
|
|
67194
67197
|
}
|
|
67198
|
+
function signalLowBalanceFromHeader(resp) {
|
|
67199
|
+
if (_signalledLowBalance)
|
|
67200
|
+
return;
|
|
67201
|
+
const raw = resp.headers?.get?.(BALANCE_HEADER);
|
|
67202
|
+
if (!raw)
|
|
67203
|
+
return;
|
|
67204
|
+
if (!/^-?\d+$/.test(raw.trim()))
|
|
67205
|
+
return;
|
|
67206
|
+
const balance = Number(raw.trim());
|
|
67207
|
+
if (!Number.isFinite(balance))
|
|
67208
|
+
return;
|
|
67209
|
+
if (balance >= LOW_BALANCE_THRESHOLD_CENTS)
|
|
67210
|
+
return;
|
|
67211
|
+
if (balance <= 0)
|
|
67212
|
+
return;
|
|
67213
|
+
_signalledLowBalance = true;
|
|
67214
|
+
log3(`balance below threshold (${balance}\xA2) \u2014 enqueuing low-balance banner`);
|
|
67215
|
+
enqueueNotification({
|
|
67216
|
+
id: "low-balance-warning",
|
|
67217
|
+
severity: "warn",
|
|
67218
|
+
transient: true,
|
|
67219
|
+
title: "Your org's Hivemind balance is running low",
|
|
67220
|
+
body: `Only $${(balance / 100).toFixed(2)} of prepaid balance remains. Admins can top up at ${billingUrl()}; otherwise ask an org admin to top up before requests start failing.`,
|
|
67221
|
+
dedupKey: { reason: "low-balance" }
|
|
67222
|
+
}).catch((e6) => {
|
|
67223
|
+
_signalledLowBalance = false;
|
|
67224
|
+
log3(`enqueue low-balance failed: ${e6 instanceof Error ? e6.message : String(e6)}`);
|
|
67225
|
+
});
|
|
67226
|
+
}
|
|
67195
67227
|
function billingUrl() {
|
|
67196
67228
|
try {
|
|
67197
67229
|
const c15 = loadCredentials();
|
|
@@ -67317,6 +67349,7 @@ var DeeplakeApi = class {
|
|
|
67317
67349
|
}
|
|
67318
67350
|
throw lastError;
|
|
67319
67351
|
}
|
|
67352
|
+
signalLowBalanceFromHeader(resp);
|
|
67320
67353
|
if (resp.ok) {
|
|
67321
67354
|
const raw = await resp.json();
|
|
67322
67355
|
if (!raw?.rows || !raw?.columns)
|
|
@@ -67477,6 +67510,7 @@ var DeeplakeApi = class {
|
|
|
67477
67510
|
...deeplakeClientHeader()
|
|
67478
67511
|
}
|
|
67479
67512
|
});
|
|
67513
|
+
signalLowBalanceFromHeader(resp);
|
|
67480
67514
|
if (resp.ok) {
|
|
67481
67515
|
const data = await resp.json();
|
|
67482
67516
|
return {
|