hive-intelligence 1.1.4 → 1.3.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.
Files changed (130) hide show
  1. package/README.md +182 -73
  2. package/agent-skills/.claude-plugin/plugin.json +4 -4
  3. package/agent-skills/.mcp.json +1 -4
  4. package/agent-skills/README.md +16 -10
  5. package/agent-skills/SKILL.md +30 -12
  6. package/agent-skills/package.json +1 -1
  7. package/agent-skills/packs/hive-build/SKILL.md +47 -19
  8. package/agent-skills/packs/hive-build/evals/evals.json +16 -3
  9. package/agent-skills/packs/hive-build/evals/triggers.json +50 -0
  10. package/agent-skills/packs/hive-build-onboarding/SKILL.md +27 -34
  11. package/agent-skills/packs/hive-build-onboarding/evals/evals.json +1 -1
  12. package/agent-skills/packs/hive-build-onboarding/evals/triggers.json +50 -0
  13. package/agent-skills/packs/hive-cli/SKILL.md +33 -35
  14. package/agent-skills/packs/hive-cli/evals/evals.json +1 -1
  15. package/agent-skills/packs/hive-cli/evals/triggers.json +50 -0
  16. package/agent-skills/packs/hive-defi-research/SKILL.md +105 -19
  17. package/agent-skills/packs/hive-defi-research/evals/evals.json +6 -3
  18. package/agent-skills/packs/hive-defi-research/evals/triggers.json +50 -0
  19. package/agent-skills/packs/hive-dex-pool-analysis/SKILL.md +106 -16
  20. package/agent-skills/packs/hive-dex-pool-analysis/evals/evals.json +5 -3
  21. package/agent-skills/packs/hive-dex-pool-analysis/evals/triggers.json +50 -0
  22. package/agent-skills/packs/hive-market-research/SKILL.md +130 -21
  23. package/agent-skills/packs/hive-market-research/evals/evals.json +15 -2
  24. package/agent-skills/packs/hive-market-research/evals/triggers.json +50 -0
  25. package/agent-skills/packs/hive-mcp/SKILL.md +69 -47
  26. package/agent-skills/packs/hive-mcp/evals/evals.json +3 -2
  27. package/agent-skills/packs/hive-mcp/evals/triggers.json +50 -0
  28. package/agent-skills/packs/hive-mcp/references/client-install-matrix.md +62 -35
  29. package/agent-skills/packs/hive-mcp/references/clients.md +81 -68
  30. package/agent-skills/packs/hive-network-infrastructure/SKILL.md +105 -20
  31. package/agent-skills/packs/hive-network-infrastructure/evals/evals.json +4 -2
  32. package/agent-skills/packs/hive-network-infrastructure/evals/triggers.json +50 -0
  33. package/agent-skills/packs/hive-nft-research/SKILL.md +105 -18
  34. package/agent-skills/packs/hive-nft-research/evals/evals.json +4 -2
  35. package/agent-skills/packs/hive-nft-research/evals/triggers.json +50 -0
  36. package/agent-skills/packs/hive-prediction-markets/SKILL.md +108 -21
  37. package/agent-skills/packs/hive-prediction-markets/evals/evals.json +4 -2
  38. package/agent-skills/packs/hive-prediction-markets/evals/triggers.json +50 -0
  39. package/agent-skills/packs/hive-query/SKILL.md +79 -33
  40. package/agent-skills/packs/hive-query/evals/evals.json +7 -5
  41. package/agent-skills/packs/hive-query/evals/triggers.json +50 -0
  42. package/agent-skills/packs/hive-query/references/root-mcp-workflow.md +39 -18
  43. package/agent-skills/packs/hive-security-risk/SKILL.md +110 -19
  44. package/agent-skills/packs/hive-security-risk/evals/evals.json +4 -2
  45. package/agent-skills/packs/hive-security-risk/evals/triggers.json +50 -0
  46. package/agent-skills/packs/hive-solana-analysis/SKILL.md +115 -19
  47. package/agent-skills/packs/hive-solana-analysis/evals/evals.json +4 -2
  48. package/agent-skills/packs/hive-solana-analysis/evals/triggers.json +50 -0
  49. package/agent-skills/packs/hive-stateful-monitoring/SKILL.md +92 -47
  50. package/agent-skills/packs/hive-stateful-monitoring/evals/evals.json +7 -2
  51. package/agent-skills/packs/hive-stateful-monitoring/evals/triggers.json +50 -0
  52. package/agent-skills/packs/hive-stateful-monitoring/references/b2b-subject-context.md +53 -0
  53. package/agent-skills/packs/hive-token-diligence/SKILL.md +119 -21
  54. package/agent-skills/packs/hive-token-diligence/evals/evals.json +6 -4
  55. package/agent-skills/packs/hive-token-diligence/evals/triggers.json +50 -0
  56. package/agent-skills/packs/hive-tool-discovery/SKILL.md +48 -19
  57. package/agent-skills/packs/hive-tool-discovery/evals/evals.json +17 -3
  58. package/agent-skills/packs/hive-tool-discovery/evals/triggers.json +50 -0
  59. package/agent-skills/packs/hive-tool-discovery/references/discovery-surfaces.md +31 -6
  60. package/agent-skills/packs/hive-wallet-investigation/SKILL.md +111 -18
  61. package/agent-skills/packs/hive-wallet-investigation/evals/evals.json +5 -3
  62. package/agent-skills/packs/hive-wallet-investigation/evals/triggers.json +50 -0
  63. package/agent-skills/references/agents-routing.md +17 -7
  64. package/agent-skills/scripts/validate-agent-skills-package.mjs +68 -8
  65. package/bin/hive-mcp.js +5 -5
  66. package/build/{alias-3OPMQF4X.js → alias-BKAVOYQV.js} +2 -2
  67. package/build/{api-client-EPF6FD7A.js → api-client-FTVDFW5V.js} +4 -4
  68. package/build/{auth-Q5Q24IRI.js → auth-EZFJ5RYB.js} +3 -3
  69. package/build/{browser-auth-VPF5LZMZ.js → browser-auth-OJSUNFBI.js} +2 -2
  70. package/build/{cache-T6KC5YEY.js → cache-TBDQ7QBU.js} +2 -2
  71. package/build/{chunk-POT2MBEK.js → chunk-6PC3HUAK.js} +10 -3
  72. package/build/{chunk-NP6NSOG2.js → chunk-725R3KLJ.js} +26 -3
  73. package/build/{chunk-GZPDEXO4.js → chunk-7GD2MFYI.js} +57 -6
  74. package/build/{chunk-ZXB53E7H.js → chunk-AEU43ACS.js} +31 -7
  75. package/build/chunk-EPF36Q3Z.js +71 -0
  76. package/build/chunk-I5Z6FZRL.js +178 -0
  77. package/build/{chunk-3WYWXTNN.js → chunk-ILVPOLA7.js} +12 -3
  78. package/build/{chunk-VBOKVQ74.js → chunk-L326MQZP.js} +6 -5
  79. package/build/{chunk-FRXMGRZQ.js → chunk-M6REON2I.js} +2 -2
  80. package/build/chunk-N32UIHBU.js +125 -0
  81. package/build/{chunk-7JWXBKEJ.js → chunk-Q7VBYLX7.js} +9 -2
  82. package/build/chunk-QDZ7MAVN.js +447 -0
  83. package/build/{chunk-ZTJVOWDQ.js → chunk-R6YZTFQL.js} +2 -0
  84. package/build/{chunk-YZ2PXBJK.js → chunk-RU6QOFHH.js} +6 -9
  85. package/build/{chunk-5XXI25JE.js → chunk-RUHO24SX.js} +16 -9
  86. package/build/{chunk-FH3YGSY5.js → chunk-TNQ7GJ6Q.js} +0 -59
  87. package/build/{chunk-JTUKQWIO.js → chunk-W2QL7LYI.js} +34807 -15070
  88. package/build/{chunk-ZCU7XQKF.js → chunk-ZXKFJQDE.js} +7 -1
  89. package/build/cli.js +3337 -3407
  90. package/build/{completion-46K674EL.js → completion-7KBW243H.js} +4 -4
  91. package/build/{config-XE6Q5P4I.js → config-KAEUX6RM.js} +23 -3
  92. package/build/{config-dir-MAWX5AUF.js → config-dir-5IH7MOOT.js} +2 -2
  93. package/build/{doctor-HGMQE6IN.js → doctor-ORDOCGLM.js} +12 -12
  94. package/build/{errors-J2PH3NLJ.js → errors-HGHUF575.js} +2 -2
  95. package/build/{format-5X2HIVDT.js → format-H7FOQSYY.js} +1 -1
  96. package/build/{init-JMDNM7ZZ.js → init-UCTCUYFA.js} +52 -8
  97. package/build/init-all-BVWW3JVK.js +408 -0
  98. package/build/mcpServer-RUEOTTF7.js +34 -0
  99. package/build/monitor-worker.js +296 -40
  100. package/build/{namespace-FSX2G3NM.js → namespace-L5DGCY7K.js} +2 -2
  101. package/build/{open-5A6ZQMGC.js → open-V2RNA3QT.js} +1 -1
  102. package/build/{output-V3D4YZ6U.js → output-ITGLBKIG.js} +2 -2
  103. package/build/release.json +8 -0
  104. package/build/{serve-AGCOXXFM.js → serve-DKLR2WQH.js} +3 -3
  105. package/build/server.js +4481 -2319
  106. package/build/{setup-RMETGJWK.js → setup-PTYFMTK5.js} +60 -55
  107. package/build/stdio.js +7 -6
  108. package/build/{telemetry-WCME5XEU.js → telemetry-HPLDYR7U.js} +5 -4
  109. package/build/{tools-KAB6QBZC.js → tools-I7GLWTV6.js} +15 -15
  110. package/build/{uninstall-FLJMBBSC.js → uninstall-SAOIPL6K.js} +19 -10
  111. package/build/{update-check-LNZQK3XA.js → update-check-IEXPOYYR.js} +4 -4
  112. package/build/{upgrade-DTUIHVPS.js → upgrade-J4HIGCKE.js} +5 -5
  113. package/build/{version-I6HDAF4L.js → version-Z4HJL4VV.js} +4 -2
  114. package/build/{watch-YNN255QX.js → watch-WVR4CGCD.js} +8 -7
  115. package/package.json +71 -35
  116. package/agent-skills/packs/hive-defi-research/references/workflow.md +0 -41
  117. package/agent-skills/packs/hive-dex-pool-analysis/references/workflow.md +0 -42
  118. package/agent-skills/packs/hive-market-research/references/workflow.md +0 -47
  119. package/agent-skills/packs/hive-network-infrastructure/references/workflow.md +0 -41
  120. package/agent-skills/packs/hive-nft-research/references/workflow.md +0 -42
  121. package/agent-skills/packs/hive-prediction-markets/references/workflow.md +0 -42
  122. package/agent-skills/packs/hive-security-risk/references/workflow.md +0 -46
  123. package/agent-skills/packs/hive-solana-analysis/references/workflow.md +0 -42
  124. package/agent-skills/packs/hive-token-diligence/references/workflow.md +0 -45
  125. package/agent-skills/packs/hive-wallet-investigation/references/workflow.md +0 -45
  126. package/build/chunk-4F5CI6LX.js +0 -340
  127. package/build/chunk-CEWCB5YS.js +0 -71
  128. package/build/chunk-IZPAMRHP.js +0 -43
  129. package/build/init-all-5SKNV75X.js +0 -273
  130. package/build/mcpServer-5TKKSKJM.js +0 -21
@@ -1,16 +1,25 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
2
  import {
3
+ consumeCredits,
3
4
  executeToolByName
4
- } from "./chunk-CEWCB5YS.js";
5
+ } from "./chunk-I5Z6FZRL.js";
5
6
  import {
7
+ HyperliquidAPI,
8
+ MIN_MONITOR_CADENCE_MS,
6
9
  closeRedisClient,
10
+ collectRwaRows,
11
+ getEnvVar,
7
12
  getSupabaseAdmin,
13
+ isManualMonitorCadence,
8
14
  isSupabaseConfigured,
15
+ monitorCadenceIntervalMs,
16
+ runScheduledHealthCanaries,
9
17
  secureLogger
10
- } from "./chunk-JTUKQWIO.js";
11
- import "./chunk-VBOKVQ74.js";
12
- import "./chunk-ZCU7XQKF.js";
13
- import "./chunk-3WYWXTNN.js";
18
+ } from "./chunk-W2QL7LYI.js";
19
+ import "./chunk-L326MQZP.js";
20
+ import "./chunk-EPF36Q3Z.js";
21
+ import "./chunk-ZXKFJQDE.js";
22
+ import "./chunk-ILVPOLA7.js";
14
23
 
15
24
  // src/monitor-worker.ts
16
25
  import { resolve } from "path";
@@ -218,7 +227,7 @@ function buildTokenWorkflowPlan(monitor) {
218
227
  }
219
228
  },
220
229
  {
221
- toolName: "get_token_price",
230
+ toolName: "codex_get_token_price",
222
231
  snapshotKey: "dex_price",
223
232
  args: { inputs: [{ networkId, address }] }
224
233
  },
@@ -260,7 +269,9 @@ function buildProtocolWorkflowPlan(monitor) {
260
269
  function buildMarketWorkflowPlan(monitor) {
261
270
  const ids = stringValue(monitor.target.ids) ?? stringValue(monitor.target.id) ?? stringValue(monitor.target.coin_id) ?? stringValue(monitor.target.symbol) ?? stringValue(monitor.target.name);
262
271
  if (!ids) {
263
- throw new Error("Market monitor target must include ids, id, coin_id, symbol, or name.");
272
+ throw new Error(
273
+ "Market monitor target must include ids, id, coin_id, symbol, or name."
274
+ );
264
275
  }
265
276
  const vsCurrencies = stringValue(monitor.target.vs_currencies) ?? stringValue(monitor.target.vs_currency) ?? "usd";
266
277
  const calls = [
@@ -312,7 +323,9 @@ function buildPredictionMarketWorkflowPlan(monitor) {
312
323
  }
313
324
  const phrase = stringValue(monitor.target.phrase) ?? stringValue(monitor.target.query) ?? stringValue(monitor.target.title);
314
325
  if (!phrase) {
315
- throw new Error("Prediction-market monitor target must include marketId or phrase.");
326
+ throw new Error(
327
+ "Prediction-market monitor target must include marketId or phrase."
328
+ );
316
329
  }
317
330
  return [
318
331
  {
@@ -589,25 +602,46 @@ function fingerprintSnapshot(snapshot) {
589
602
  }
590
603
  function computeNextRunAt(cadence, from = /* @__PURE__ */ new Date()) {
591
604
  const normalized = (cadence ?? "manual").trim().toLowerCase();
592
- if (!normalized || normalized === "manual" || normalized === "once") {
593
- return null;
594
- }
595
- const intervalMatch = normalized.match(/^(\d+)\s*(m|min|minute|minutes|h|hr|hour|hours|d|day|days|w|week|weeks)$/);
596
- const next = new Date(from);
597
- if (intervalMatch) {
598
- const amount = Number.parseInt(intervalMatch[1], 10);
599
- const unit = intervalMatch[2];
600
- if (unit.startsWith("m")) next.setMinutes(next.getMinutes() + amount);
601
- else if (unit.startsWith("h")) next.setHours(next.getHours() + amount);
602
- else if (unit.startsWith("d")) next.setDate(next.getDate() + amount);
603
- else next.setDate(next.getDate() + amount * 7);
604
- return next.toISOString();
605
+ if (isManualMonitorCadence(normalized)) return null;
606
+ const intervalMs = monitorCadenceIntervalMs(normalized);
607
+ if (intervalMs === null) return null;
608
+ return new Date(
609
+ from.getTime() + Math.max(intervalMs, MIN_MONITOR_CADENCE_MS)
610
+ ).toISOString();
611
+ }
612
+ async function defaultConsumeCredit(args) {
613
+ return consumeCredits({
614
+ userId: args.userId,
615
+ cost: 1,
616
+ idempotencyKey: `monitor-run:${args.runId}`,
617
+ requestId: args.runId
618
+ });
619
+ }
620
+ async function debitMonitorRunCredit(args) {
621
+ try {
622
+ const debit = await args.consumeCredit({
623
+ userId: args.monitor.user_id,
624
+ runId: args.runId
625
+ });
626
+ if (debit.code === "insufficient" || debit.code === "no_wallet") {
627
+ return {
628
+ ok: false,
629
+ code: "MONITOR_CREDIT_EXHAUSTED",
630
+ message: "Monitor run skipped because the account has no available credits."
631
+ };
632
+ }
633
+ return { ok: true };
634
+ } catch (error) {
635
+ secureLogger.warn("Monitor credit debit failed", {
636
+ monitorId: args.monitor.id,
637
+ error: error instanceof Error ? error.message : String(error)
638
+ });
639
+ return {
640
+ ok: false,
641
+ code: "MONITOR_CREDIT_UNAVAILABLE",
642
+ message: "Monitor run skipped because the credit service is temporarily unavailable."
643
+ };
605
644
  }
606
- if (normalized === "hourly") next.setHours(next.getHours() + 1);
607
- else if (normalized === "daily") next.setDate(next.getDate() + 1);
608
- else if (normalized === "weekly") next.setDate(next.getDate() + 7);
609
- else return null;
610
- return next.toISOString();
611
645
  }
612
646
  function hasAlertRule(monitor) {
613
647
  return monitor.rules.some(
@@ -656,7 +690,9 @@ function collectNumbersByKey(value, keyPatterns) {
656
690
  return;
657
691
  }
658
692
  if (isRecord(item)) {
659
- Object.entries(item).forEach(([childKey, child]) => visit(child, childKey));
693
+ Object.entries(item).forEach(
694
+ ([childKey, child]) => visit(child, childKey)
695
+ );
660
696
  }
661
697
  };
662
698
  visit(value);
@@ -668,7 +704,8 @@ function maxAbsPercentChange(previous, current) {
668
704
  for (let index = 0; index < count; index++) {
669
705
  const before = previous[index];
670
706
  const after = current[index];
671
- if (!Number.isFinite(before) || !Number.isFinite(after) || before === 0) continue;
707
+ if (!Number.isFinite(before) || !Number.isFinite(after) || before === 0)
708
+ continue;
672
709
  const change = Math.abs((after - before) / before * 100);
673
710
  maxChange = maxChange === null ? change : Math.max(maxChange, change);
674
711
  }
@@ -682,7 +719,9 @@ function thresholdSeverity(value, threshold) {
682
719
  }
683
720
  function detectRiskSeverity(snapshot) {
684
721
  const text = sortedJson(snapshot).toLowerCase();
685
- if (/\bcritical\b|is_malicious[^a-z0-9]*true|honeypot[^a-z0-9]*true|rugpull[^a-z0-9]*true/.test(text)) {
722
+ if (/\bcritical\b|is_malicious[^a-z0-9]*true|honeypot[^a-z0-9]*true|rugpull[^a-z0-9]*true/.test(
723
+ text
724
+ )) {
686
725
  return "critical";
687
726
  }
688
727
  if (/\bhigh\b|blacklist[^a-z0-9]*true|phishing[^a-z0-9]*true/.test(text)) {
@@ -709,7 +748,11 @@ function evaluateMonitorRules(args) {
709
748
  kind: "rule_risk_severity_at_least",
710
749
  severity: actual,
711
750
  title: `${args.monitor.name} matched risk severity rule`,
712
- evidence: { rule, actual_severity: actual, minimum_severity: minimum }
751
+ evidence: {
752
+ rule,
753
+ actual_severity: actual,
754
+ minimum_severity: minimum
755
+ }
713
756
  });
714
757
  }
715
758
  continue;
@@ -720,7 +763,11 @@ function evaluateMonitorRules(args) {
720
763
  price_change_pct: [/price/i, /usd/i],
721
764
  tvl_change_pct: [/tvl/i, /liquidity/i, /totalLiquidityUSD/i],
722
765
  fee_change_pct: [/fee/i, /fees/i, /total24h/i, /total7d/i],
723
- liquidity_change_pct: [/liquidity/i, /reserve.*usd/i, /totalLiquidityUSD/i],
766
+ liquidity_change_pct: [
767
+ /liquidity/i,
768
+ /reserve.*usd/i,
769
+ /totalLiquidityUSD/i
770
+ ],
724
771
  transfer_value_usd: [/value.*usd/i, /amount.*usd/i, /usd/i]
725
772
  };
726
773
  const patterns = patternsByType[type];
@@ -739,7 +786,10 @@ function evaluateMonitorRules(args) {
739
786
  continue;
740
787
  }
741
788
  if (!args.previousSnapshot) continue;
742
- const previousNumbers = collectNumbersByKey(args.previousSnapshot, patterns);
789
+ const previousNumbers = collectNumbersByKey(
790
+ args.previousSnapshot,
791
+ patterns
792
+ );
743
793
  const maxChange = maxAbsPercentChange(previousNumbers, currentNumbers);
744
794
  if (maxChange !== null && maxChange >= threshold) {
745
795
  evaluations.push({
@@ -823,12 +873,14 @@ var SupabaseMonitorRunnerStore = class {
823
873
  source: args.source,
824
874
  metadata: { worker_id: args.workerId }
825
875
  }).select("*").single();
826
- if (error) throw new Error(`Failed to create monitor run: ${error.message}`);
876
+ if (error)
877
+ throw new Error(`Failed to create monitor run: ${error.message}`);
827
878
  return data;
828
879
  }
829
880
  async getLatestSnapshot(monitorId) {
830
881
  const { data, error } = await this.supabase().from("monitor_snapshots").select("*").eq("monitor_id", monitorId).order("created_at", { ascending: false }).limit(1).maybeSingle();
831
- if (error) throw new Error(`Failed to fetch latest snapshot: ${error.message}`);
882
+ if (error)
883
+ throw new Error(`Failed to fetch latest snapshot: ${error.message}`);
832
884
  return data ?? null;
833
885
  }
834
886
  async writeSnapshot(args) {
@@ -879,7 +931,8 @@ var SupabaseMonitorRunnerStore = class {
879
931
  error_message: args.errorMessage ?? null,
880
932
  metadata: args.metadata ?? {}
881
933
  }).eq("id", args.runId);
882
- if (error) throw new Error(`Failed to finish monitor run: ${error.message}`);
934
+ if (error)
935
+ throw new Error(`Failed to finish monitor run: ${error.message}`);
883
936
  }
884
937
  async releaseMonitor(args) {
885
938
  const { error } = await this.supabase().from("monitors").update({
@@ -901,6 +954,36 @@ async function processMonitor(monitor, options) {
901
954
  const completedAt = options.now.toISOString();
902
955
  const nextRunAt = computeNextRunAt(monitor.cadence, options.now);
903
956
  try {
957
+ const debit = await debitMonitorRunCredit({
958
+ monitor,
959
+ runId: run.id,
960
+ consumeCredit: options.consumeCredit
961
+ });
962
+ if (!debit.ok) {
963
+ await options.store.finishRun({
964
+ runId: run.id,
965
+ status: "skipped",
966
+ summary: debit.message,
967
+ toolCalls: [],
968
+ errorCode: debit.code,
969
+ errorMessage: debit.message
970
+ });
971
+ await options.store.releaseMonitor({
972
+ monitor,
973
+ lastRunAt: completedAt,
974
+ nextRunAt
975
+ });
976
+ return {
977
+ monitorId: monitor.id,
978
+ kind: monitor.kind,
979
+ status: "skipped",
980
+ runId: run.id,
981
+ summary: debit.message,
982
+ nextRunAt,
983
+ observations: 0,
984
+ alerts: 0
985
+ };
986
+ }
904
987
  const previous = await options.store.getLatestSnapshot(monitor.id);
905
988
  const workflow = await executeMonitorWorkflow(
906
989
  monitor,
@@ -1051,10 +1134,14 @@ async function processMonitor(monitor, options) {
1051
1134
  async function runDueMonitors(options = {}) {
1052
1135
  const store = options.store ?? new SupabaseMonitorRunnerStore();
1053
1136
  const workerId = options.workerId ?? DEFAULT_WORKER_ID;
1054
- const batchSize = Math.max(1, Math.min(options.batchSize ?? DEFAULT_BATCH_SIZE, 100));
1137
+ const batchSize = Math.max(
1138
+ 1,
1139
+ Math.min(options.batchSize ?? DEFAULT_BATCH_SIZE, 100)
1140
+ );
1055
1141
  const lockTimeoutSeconds = options.lockTimeoutSeconds ?? DEFAULT_LOCK_TIMEOUT_SECONDS;
1056
1142
  const now = options.now ?? /* @__PURE__ */ new Date();
1057
1143
  const executeTool = options.executeTool ?? executeToolByName;
1144
+ const consumeCredit = options.consumeCredit ?? defaultConsumeCredit;
1058
1145
  const source = options.source ?? "scheduled";
1059
1146
  const claimed = await store.claimDueMonitors({
1060
1147
  batchSize,
@@ -1080,7 +1167,8 @@ async function runDueMonitors(options = {}) {
1080
1167
  workerId,
1081
1168
  now,
1082
1169
  source,
1083
- executeTool
1170
+ executeTool,
1171
+ consumeCredit
1084
1172
  })
1085
1173
  );
1086
1174
  }
@@ -1094,6 +1182,152 @@ async function runDueMonitors(options = {}) {
1094
1182
  };
1095
1183
  }
1096
1184
 
1185
+ // src/services/rwa-snapshot.ts
1186
+ var INSERT_CHUNK_SIZE = 500;
1187
+ var SNAPSHOT_MIN_GAP_MS = 55 * 60 * 1e3;
1188
+ function snapshotRowFor(row, capturedAt) {
1189
+ return {
1190
+ venue: row.venue,
1191
+ symbol: row.symbol,
1192
+ underlying: row.underlying,
1193
+ asset_class: row.asset_class,
1194
+ funding_rate: row.funding_rate,
1195
+ annualized: row.funding_annualized,
1196
+ mark_price: row.mark_price,
1197
+ oi: row.open_interest_usd,
1198
+ mechanism: row.funding_mechanism,
1199
+ flags: {
1200
+ market: row.market,
1201
+ funding_interval_hours: row.funding_interval_hours,
1202
+ borrow_apr_annual: row.borrow_apr_annual,
1203
+ is_delisted: row.is_delisted,
1204
+ is_price_suspect: row.is_price_suspect,
1205
+ price_suspect_basis: row.price_suspect_basis,
1206
+ price_deviation_pct: row.price_deviation_pct,
1207
+ volume_24h_usd: row.volume_24h_usd
1208
+ },
1209
+ captured_at: capturedAt
1210
+ };
1211
+ }
1212
+ async function persistRwaSnapshot() {
1213
+ if (!isSupabaseConfigured()) {
1214
+ return {
1215
+ ok: true,
1216
+ skipped: true,
1217
+ reason: "supabase_not_configured",
1218
+ capturedRows: 0,
1219
+ venueResults: [],
1220
+ writeErrors: [],
1221
+ capturedAt: null
1222
+ };
1223
+ }
1224
+ const { results, rows } = await collectRwaRows({
1225
+ hyperliquidApi: new HyperliquidAPI()
1226
+ });
1227
+ if (rows.length === 0) {
1228
+ return {
1229
+ ok: false,
1230
+ skipped: false,
1231
+ reason: "no_rows_from_any_venue",
1232
+ capturedRows: 0,
1233
+ venueResults: results,
1234
+ writeErrors: [],
1235
+ capturedAt: null
1236
+ };
1237
+ }
1238
+ const supabase = getSupabaseAdmin();
1239
+ const capturedAt = (/* @__PURE__ */ new Date()).toISOString();
1240
+ const payload = rows.map((row) => snapshotRowFor(row, capturedAt));
1241
+ const writeErrors = [];
1242
+ let insertedCount = 0;
1243
+ for (let i = 0; i < payload.length; i += INSERT_CHUNK_SIZE) {
1244
+ const chunk = payload.slice(i, i + INSERT_CHUNK_SIZE);
1245
+ const { error } = await supabase.from("rwa_funding_snapshots").insert(chunk);
1246
+ if (error) {
1247
+ writeErrors.push(`insert chunk ${i}: ${error.message}`);
1248
+ } else {
1249
+ insertedCount += chunk.length;
1250
+ }
1251
+ }
1252
+ const ok = writeErrors.length === 0;
1253
+ if (!ok) {
1254
+ secureLogger.warn("RWA snapshot write errors", {
1255
+ errorCount: writeErrors.length
1256
+ });
1257
+ }
1258
+ return {
1259
+ ok,
1260
+ skipped: false,
1261
+ capturedRows: insertedCount,
1262
+ venueResults: results,
1263
+ writeErrors,
1264
+ capturedAt
1265
+ };
1266
+ }
1267
+ async function runScheduledRwaSnapshot() {
1268
+ try {
1269
+ if ((getEnvVar("HIVE_RWA_SNAPSHOT_ENABLED") ?? "true") === "false") {
1270
+ return {
1271
+ ok: true,
1272
+ skipped: true,
1273
+ reason: "disabled_by_env",
1274
+ capturedRows: 0,
1275
+ venueResults: [],
1276
+ writeErrors: [],
1277
+ capturedAt: null
1278
+ };
1279
+ }
1280
+ if (!isSupabaseConfigured()) {
1281
+ return {
1282
+ ok: true,
1283
+ skipped: true,
1284
+ reason: "supabase_not_configured",
1285
+ capturedRows: 0,
1286
+ venueResults: [],
1287
+ writeErrors: [],
1288
+ capturedAt: null
1289
+ };
1290
+ }
1291
+ const supabase = getSupabaseAdmin();
1292
+ const { data, error } = await supabase.from("rwa_funding_snapshots").select("captured_at").order("captured_at", { ascending: false }).limit(1);
1293
+ if (error) {
1294
+ return {
1295
+ ok: false,
1296
+ skipped: false,
1297
+ reason: `cadence check failed: ${error.message}`,
1298
+ capturedRows: 0,
1299
+ venueResults: [],
1300
+ writeErrors: [error.message],
1301
+ capturedAt: null
1302
+ };
1303
+ }
1304
+ const latest = data?.[0]?.captured_at ? Date.parse(String(data[0].captured_at)) : null;
1305
+ if (latest != null && Number.isFinite(latest) && Date.now() - latest < SNAPSHOT_MIN_GAP_MS) {
1306
+ return {
1307
+ ok: true,
1308
+ skipped: true,
1309
+ reason: "within_cadence_gap",
1310
+ capturedRows: 0,
1311
+ venueResults: [],
1312
+ writeErrors: [],
1313
+ capturedAt: null
1314
+ };
1315
+ }
1316
+ return await persistRwaSnapshot();
1317
+ } catch (error) {
1318
+ const message = error instanceof Error ? error.message : String(error);
1319
+ return {
1320
+ ok: false,
1321
+ skipped: false,
1322
+ reason: message,
1323
+ capturedRows: 0,
1324
+ venueResults: [],
1325
+ writeErrors: [message],
1326
+ capturedAt: null
1327
+ };
1328
+ }
1329
+ }
1330
+
1097
1331
  // src/monitor-worker.ts
1098
1332
  function intEnv(name, fallback) {
1099
1333
  const parsed = Number.parseInt(process.env[name] ?? "", 10);
@@ -1105,19 +1339,41 @@ async function runMonitorWorkerFromEnv() {
1105
1339
  batchSize: intEnv("HIVE_MONITOR_WORKER_BATCH_SIZE", 10),
1106
1340
  workerId: process.env.HIVE_MONITOR_WORKER_ID,
1107
1341
  lockTimeoutSeconds: intEnv("HIVE_MONITOR_LOCK_TIMEOUT_SECONDS", 300)
1108
- });
1342
+ }).catch((error) => ({
1343
+ ok: false,
1344
+ claimed: 0,
1345
+ completed: 0,
1346
+ failed: 0,
1347
+ skipped: 0,
1348
+ results: [],
1349
+ error: error instanceof Error ? error.message : String(error)
1350
+ }));
1351
+ const scheduledHealthCanaries = await runScheduledHealthCanaries().catch(
1352
+ (error) => ({
1353
+ ok: false,
1354
+ skipped: false,
1355
+ persistent: false,
1356
+ duration: 0,
1357
+ canaries: {},
1358
+ errors: [error instanceof Error ? error.message : String(error)],
1359
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1360
+ })
1361
+ );
1362
+ const rwaSnapshot = await runScheduledRwaSnapshot();
1109
1363
  console.log(
1110
1364
  JSON.stringify(
1111
1365
  {
1112
1366
  service: "hive-monitor-worker",
1113
1367
  worker_id: process.env.HIVE_MONITOR_WORKER_ID ?? null,
1114
- ...result
1368
+ ...result,
1369
+ scheduled_health_canaries: scheduledHealthCanaries,
1370
+ rwa_snapshot: rwaSnapshot
1115
1371
  },
1116
1372
  null,
1117
1373
  2
1118
1374
  )
1119
1375
  );
1120
- if (!result.ok) process.exitCode = 1;
1376
+ if (!result.ok || !scheduledHealthCanaries.ok) process.exitCode = 1;
1121
1377
  } finally {
1122
1378
  await closeRedisClient();
1123
1379
  }
@@ -3,8 +3,8 @@ import {
3
3
  NAMESPACE,
4
4
  getAllDomainCommands,
5
5
  resolveCommand
6
- } from "./chunk-FH3YGSY5.js";
7
- import "./chunk-3WYWXTNN.js";
6
+ } from "./chunk-TNQ7GJ6Q.js";
7
+ import "./chunk-ILVPOLA7.js";
8
8
  export {
9
9
  NAMESPACE,
10
10
  getAllDomainCommands,
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import "./chunk-3WYWXTNN.js";
2
+ import "./chunk-ILVPOLA7.js";
3
3
 
4
4
  // src/cli/open.ts
5
5
  import { exec } from "child_process";
@@ -17,8 +17,8 @@ import {
17
17
  successEnvelope,
18
18
  writeOutput,
19
19
  yellow
20
- } from "./chunk-NP6NSOG2.js";
21
- import "./chunk-3WYWXTNN.js";
20
+ } from "./chunk-725R3KLJ.js";
21
+ import "./chunk-ILVPOLA7.js";
22
22
  export {
23
23
  bold,
24
24
  colorEnabled,
@@ -0,0 +1,8 @@
1
+ {
2
+ "package": "hive-intelligence",
3
+ "version": "1.3.0",
4
+ "buildSha": "ccb1dc457b4a439b822e8aafa1c783f043270344",
5
+ "imageDigest": "sha256:8c50b7b68edf9c6b7720b71221fadf668cbd31264f790f0c7efa24ab45fcc445",
6
+ "deployedUrl": "https://mcp.hiveintelligence.xyz",
7
+ "manifest": "https://raw.githubusercontent.com/hive-intel/hive-sdk/v1.3.0/releases/v1.3.0.json"
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import "./chunk-3WYWXTNN.js";
2
+ import "./chunk-ILVPOLA7.js";
3
3
 
4
4
  // src/cli/serve.ts
5
5
  import dotenv from "dotenv";
@@ -7,8 +7,8 @@ async function startStdio(envFile) {
7
7
  dotenv.config({ path: envFile || ".env", quiet: true });
8
8
  console.log = (...args) => console.error("[LOG]", ...args);
9
9
  const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
10
- const { createHiveMcpServer, SERVER_NAME, SERVER_VERSION } = await import("./mcpServer-5TKKSKJM.js");
11
- const { getPendingUpdateVersion } = await import("./update-check-LNZQK3XA.js");
10
+ const { createHiveMcpServer, SERVER_NAME, SERVER_VERSION } = await import("./mcpServer-RUEOTTF7.js");
11
+ const { getPendingUpdateVersion } = await import("./update-check-IEXPOYYR.js");
12
12
  const transport = new StdioServerTransport();
13
13
  const pendingUpdate = getPendingUpdateVersion();
14
14
  const instructionsSuffix = pendingUpdate ? `A newer Hive version (${pendingUpdate}) is available; this server is running ${SERVER_VERSION}. Tell the user to run "hive upgrade" and restart this client to get the latest tools and data.` : void 0;