hive-intelligence 1.1.3 → 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.
- package/LICENSE +23 -0
- package/README.md +315 -85
- package/agent-skills/.claude-plugin/plugin.json +10 -4
- package/agent-skills/.mcp.json +8 -0
- package/agent-skills/AGENTS.md +37 -0
- package/agent-skills/README.md +28 -23
- package/agent-skills/SKILL.md +40 -10
- package/agent-skills/evals/trigger-queries.json +270 -0
- package/agent-skills/package.json +4 -4
- package/agent-skills/packs/hive-build/SKILL.md +54 -25
- package/agent-skills/packs/hive-build/evals/evals.json +16 -3
- package/agent-skills/packs/hive-build/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-build-onboarding/SKILL.md +27 -34
- package/agent-skills/packs/hive-build-onboarding/evals/evals.json +1 -1
- package/agent-skills/packs/hive-build-onboarding/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-cli/SKILL.md +33 -35
- package/agent-skills/packs/hive-cli/evals/evals.json +1 -1
- package/agent-skills/packs/hive-cli/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-defi-research/SKILL.md +105 -19
- package/agent-skills/packs/hive-defi-research/evals/evals.json +6 -3
- package/agent-skills/packs/hive-defi-research/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-dex-pool-analysis/SKILL.md +106 -16
- package/agent-skills/packs/hive-dex-pool-analysis/evals/evals.json +5 -3
- package/agent-skills/packs/hive-dex-pool-analysis/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-market-research/SKILL.md +130 -21
- package/agent-skills/packs/hive-market-research/evals/evals.json +15 -2
- package/agent-skills/packs/hive-market-research/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-mcp/SKILL.md +98 -153
- package/agent-skills/packs/hive-mcp/evals/evals.json +4 -3
- package/agent-skills/packs/hive-mcp/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-mcp/references/client-install-matrix.md +62 -35
- package/agent-skills/packs/hive-mcp/references/clients.md +154 -0
- package/agent-skills/packs/hive-network-infrastructure/SKILL.md +105 -20
- package/agent-skills/packs/hive-network-infrastructure/evals/evals.json +4 -2
- package/agent-skills/packs/hive-network-infrastructure/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-nft-research/SKILL.md +105 -18
- package/agent-skills/packs/hive-nft-research/evals/evals.json +4 -2
- package/agent-skills/packs/hive-nft-research/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-prediction-markets/SKILL.md +108 -21
- package/agent-skills/packs/hive-prediction-markets/evals/evals.json +4 -2
- package/agent-skills/packs/hive-prediction-markets/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-query/SKILL.md +80 -33
- package/agent-skills/packs/hive-query/evals/evals.json +7 -5
- package/agent-skills/packs/hive-query/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-query/references/root-mcp-workflow.md +39 -18
- package/agent-skills/packs/hive-security-risk/SKILL.md +110 -19
- package/agent-skills/packs/hive-security-risk/evals/evals.json +4 -2
- package/agent-skills/packs/hive-security-risk/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-solana-analysis/SKILL.md +115 -19
- package/agent-skills/packs/hive-solana-analysis/evals/evals.json +4 -2
- package/agent-skills/packs/hive-solana-analysis/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-stateful-monitoring/SKILL.md +120 -0
- package/agent-skills/packs/hive-stateful-monitoring/evals/evals.json +54 -0
- package/agent-skills/packs/hive-stateful-monitoring/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-stateful-monitoring/references/b2b-subject-context.md +53 -0
- package/agent-skills/packs/hive-token-diligence/SKILL.md +119 -21
- package/agent-skills/packs/hive-token-diligence/evals/evals.json +6 -4
- package/agent-skills/packs/hive-token-diligence/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-tool-discovery/SKILL.md +48 -19
- package/agent-skills/packs/hive-tool-discovery/evals/evals.json +17 -3
- package/agent-skills/packs/hive-tool-discovery/evals/triggers.json +50 -0
- package/agent-skills/packs/hive-tool-discovery/references/discovery-surfaces.md +31 -6
- package/agent-skills/packs/hive-wallet-investigation/SKILL.md +111 -18
- package/agent-skills/packs/hive-wallet-investigation/evals/evals.json +5 -3
- package/agent-skills/packs/hive-wallet-investigation/evals/triggers.json +50 -0
- package/agent-skills/references/agents-routing.md +19 -7
- package/agent-skills/scripts/validate-agent-skills-package.mjs +116 -18
- package/agent-skills/skills.sh.json +3 -2
- package/bin/hive-mcp.js +5 -5
- package/build/{alias-CZ3DEYHF.js → alias-BKAVOYQV.js} +2 -3
- package/build/{api-client-I23XLSHU.js → api-client-FTVDFW5V.js} +4 -4
- package/build/{auth-KKINNBXT.js → auth-EZFJ5RYB.js} +3 -4
- package/build/{browser-auth-EEFGRHWY.js → browser-auth-OJSUNFBI.js} +2 -3
- package/build/{cache-EGNMENNA.js → cache-TBDQ7QBU.js} +2 -3
- package/build/{chunk-V77LO4RO.js → chunk-6PC3HUAK.js} +10 -4
- package/build/{chunk-XYBEFFZ3.js → chunk-725R3KLJ.js} +26 -4
- package/build/{chunk-PGBVNMNZ.js → chunk-7GD2MFYI.js} +57 -7
- package/build/{chunk-IDZD2NVG.js → chunk-AEU43ACS.js} +33 -10
- package/build/chunk-EPF36Q3Z.js +71 -0
- package/build/chunk-I5Z6FZRL.js +178 -0
- package/build/{chunk-KBVPIZS4.js → chunk-ILVPOLA7.js} +12 -4
- package/build/{chunk-B6G222LS.js → chunk-L326MQZP.js} +22 -6
- package/build/{chunk-QNCI4DEB.js → chunk-M6REON2I.js} +35 -21
- package/build/chunk-N32UIHBU.js +125 -0
- package/build/{chunk-IZTN7WFH.js → chunk-Q7VBYLX7.js} +12 -3
- package/build/chunk-QDZ7MAVN.js +447 -0
- package/build/{chunk-KGYBTXIN.js → chunk-R6YZTFQL.js} +2 -1
- package/build/{chunk-DYJBTKNR.js → chunk-RU6QOFHH.js} +9 -10
- package/build/{chunk-RKICZ6DZ.js → chunk-RUHO24SX.js} +16 -10
- package/build/{chunk-MPIUUE3T.js → chunk-TNQ7GJ6Q.js} +0 -60
- package/build/{chunk-2X3U4DFK.js → chunk-W2QL7LYI.js} +43586 -21498
- package/build/chunk-ZXKFJQDE.js +20 -0
- package/build/cli.js +3342 -3410
- package/build/{completion-BELZL7ND.js → completion-7KBW243H.js} +4 -5
- package/build/{config-TDX4VUGW.js → config-KAEUX6RM.js} +23 -4
- package/build/{config-dir-V43W2WIA.js → config-dir-5IH7MOOT.js} +2 -3
- package/build/{doctor-5K5UWHNX.js → doctor-ORDOCGLM.js} +34 -10
- package/build/{errors-E6MVUBNA.js → errors-HGHUF575.js} +2 -3
- package/build/{format-TSFSI2K7.js → format-H7FOQSYY.js} +1 -2
- package/build/{init-YQ5NBICF.js → init-UCTCUYFA.js} +52 -9
- package/build/init-all-BVWW3JVK.js +408 -0
- package/build/mcpServer-RUEOTTF7.js +34 -0
- package/build/monitor-worker.js +1396 -0
- package/build/{namespace-PVHBFDW2.js → namespace-L5DGCY7K.js} +2 -3
- package/build/{open-YUIJP37F.js → open-V2RNA3QT.js} +2 -3
- package/build/{output-IYJBFCYK.js → output-ITGLBKIG.js} +2 -3
- package/build/release.json +8 -0
- package/build/{serve-KWNJK6EY.js → serve-DKLR2WQH.js} +9 -4
- package/build/server.js +5399 -2945
- package/build/{setup-YTUKMPNP.js → setup-PTYFMTK5.js} +60 -56
- package/build/stdio.js +10 -8
- package/build/{telemetry-5IPRKZBL.js → telemetry-HPLDYR7U.js} +5 -4
- package/build/{tools-PJHWFCAG.js → tools-I7GLWTV6.js} +15 -15
- package/build/{uninstall-HWXEIP6K.js → uninstall-SAOIPL6K.js} +19 -11
- package/build/update-check-IEXPOYYR.js +18 -0
- package/build/upgrade-J4HIGCKE.js +171 -0
- package/build/version-Z4HJL4VV.js +16 -0
- package/build/{watch-KZ5EDZK3.js → watch-WVR4CGCD.js} +8 -7
- package/package.json +82 -41
- package/agent-skills/packs/hive-defi-research/references/workflow.md +0 -41
- package/agent-skills/packs/hive-dex-pool-analysis/references/workflow.md +0 -42
- package/agent-skills/packs/hive-market-research/references/workflow.md +0 -47
- package/agent-skills/packs/hive-network-infrastructure/references/workflow.md +0 -41
- package/agent-skills/packs/hive-nft-research/references/workflow.md +0 -42
- package/agent-skills/packs/hive-prediction-markets/references/workflow.md +0 -42
- package/agent-skills/packs/hive-security-risk/references/workflow.md +0 -46
- package/agent-skills/packs/hive-solana-analysis/references/workflow.md +0 -42
- package/agent-skills/packs/hive-token-diligence/references/workflow.md +0 -45
- package/agent-skills/packs/hive-wallet-investigation/references/workflow.md +0 -45
- package/build/alias-CZ3DEYHF.js.map +0 -1
- package/build/api-client-I23XLSHU.js.map +0 -1
- package/build/auth-KKINNBXT.js.map +0 -1
- package/build/browser-auth-EEFGRHWY.js.map +0 -1
- package/build/cache-EGNMENNA.js.map +0 -1
- package/build/chunk-2MYMHMBF.js +0 -340
- package/build/chunk-2MYMHMBF.js.map +0 -1
- package/build/chunk-2X3U4DFK.js.map +0 -1
- package/build/chunk-B6G222LS.js.map +0 -1
- package/build/chunk-DYJBTKNR.js.map +0 -1
- package/build/chunk-IDZD2NVG.js.map +0 -1
- package/build/chunk-IZTN7WFH.js.map +0 -1
- package/build/chunk-KBVPIZS4.js.map +0 -1
- package/build/chunk-KGYBTXIN.js.map +0 -1
- package/build/chunk-MPIUUE3T.js.map +0 -1
- package/build/chunk-PGBVNMNZ.js.map +0 -1
- package/build/chunk-QNCI4DEB.js.map +0 -1
- package/build/chunk-RKICZ6DZ.js.map +0 -1
- package/build/chunk-UKHZIVDT.js +0 -44
- package/build/chunk-UKHZIVDT.js.map +0 -1
- package/build/chunk-V77LO4RO.js.map +0 -1
- package/build/chunk-XYBEFFZ3.js.map +0 -1
- package/build/cli.js.map +0 -1
- package/build/completion-BELZL7ND.js.map +0 -1
- package/build/config-TDX4VUGW.js.map +0 -1
- package/build/config-dir-V43W2WIA.js.map +0 -1
- package/build/doctor-5K5UWHNX.js.map +0 -1
- package/build/errors-E6MVUBNA.js.map +0 -1
- package/build/format-TSFSI2K7.js.map +0 -1
- package/build/init-YQ5NBICF.js.map +0 -1
- package/build/init-all-6OWEQALB.js +0 -274
- package/build/init-all-6OWEQALB.js.map +0 -1
- package/build/mcpServer-AEX3RQ4U.js +0 -20
- package/build/mcpServer-AEX3RQ4U.js.map +0 -1
- package/build/namespace-PVHBFDW2.js.map +0 -1
- package/build/open-YUIJP37F.js.map +0 -1
- package/build/output-IYJBFCYK.js.map +0 -1
- package/build/serve-KWNJK6EY.js.map +0 -1
- package/build/server.js.map +0 -1
- package/build/setup-YTUKMPNP.js.map +0 -1
- package/build/stdio.js.map +0 -1
- package/build/telemetry-5IPRKZBL.js.map +0 -1
- package/build/tools-PJHWFCAG.js.map +0 -1
- package/build/uninstall-HWXEIP6K.js.map +0 -1
- package/build/watch-KZ5EDZK3.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
REGISTRY_PACKAGE,
|
|
3
4
|
SERVER_VERSION
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZXKFJQDE.js";
|
|
5
6
|
import {
|
|
6
7
|
ensureConfigDir,
|
|
7
8
|
getConfigDir,
|
|
8
9
|
readJsonFile,
|
|
9
10
|
writeJsonFile
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6PC3HUAK.js";
|
|
11
12
|
|
|
12
13
|
// src/cli/update-check.ts
|
|
13
14
|
import { join } from "path";
|
|
14
15
|
var CACHE_TTL_MS = 864e5;
|
|
15
|
-
var REGISTRY_PACKAGE = "hive-intelligence";
|
|
16
16
|
function getCachePath() {
|
|
17
17
|
return join(getConfigDir(), "cache", "update-check.json");
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ async function checkForUpdates() {
|
|
|
20
20
|
if (shouldSkipUpdateCheck(process.argv, process.env)) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
const cached =
|
|
23
|
+
const cached = readUpdateCache();
|
|
24
24
|
if (cached?.checkedAt) {
|
|
25
25
|
const age = Date.now() - new Date(cached.checkedAt).getTime();
|
|
26
26
|
if (age < CACHE_TTL_MS) {
|
|
@@ -30,36 +30,47 @@ async function checkForUpdates() {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
const latest = await fetchLatestVersion();
|
|
34
|
+
if (latest === null) return;
|
|
35
|
+
ensureConfigDir();
|
|
36
|
+
writeJsonFile(getCachePath(), {
|
|
37
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38
|
+
latestVersion: latest
|
|
39
|
+
});
|
|
40
|
+
if (isNewerVersion(latest, SERVER_VERSION)) showUpdateMessage(latest);
|
|
41
|
+
}
|
|
42
|
+
async function fetchLatestVersion(timeoutMs = 3e3) {
|
|
33
43
|
try {
|
|
34
44
|
const controller = new AbortController();
|
|
35
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
45
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
36
46
|
const res = await fetch(
|
|
37
47
|
`https://registry.npmjs.org/${REGISTRY_PACKAGE}/latest`,
|
|
38
|
-
{
|
|
39
|
-
signal: controller.signal
|
|
40
|
-
}
|
|
48
|
+
{ signal: controller.signal }
|
|
41
49
|
);
|
|
42
50
|
clearTimeout(timeout);
|
|
43
|
-
if (!res.ok) return;
|
|
51
|
+
if (!res.ok) return null;
|
|
44
52
|
const data = await res.json();
|
|
45
|
-
|
|
46
|
-
writeJsonFile(getCachePath(), {
|
|
47
|
-
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48
|
-
latestVersion: data.version ?? null
|
|
49
|
-
});
|
|
50
|
-
if (!data.version || !isNewerVersion(data.version, SERVER_VERSION)) return;
|
|
51
|
-
showUpdateMessage(data.version);
|
|
53
|
+
return data.version ?? null;
|
|
52
54
|
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function readUpdateCache() {
|
|
59
|
+
return readJsonFile(getCachePath());
|
|
60
|
+
}
|
|
61
|
+
function getPendingUpdateVersion() {
|
|
62
|
+
const cached = readUpdateCache();
|
|
63
|
+
if (cached?.latestVersion && isNewerVersion(cached.latestVersion, SERVER_VERSION)) {
|
|
64
|
+
return cached.latestVersion;
|
|
53
65
|
}
|
|
66
|
+
return null;
|
|
54
67
|
}
|
|
55
68
|
function shouldSkipUpdateCheck(argv = process.argv, env = process.env) {
|
|
56
69
|
if (env.CI || env.HIVE_NO_UPDATE_CHECK) return true;
|
|
57
70
|
if (env.NODE_ENV === "test" || env.VITEST || env.VITEST_WORKER_ID) {
|
|
58
71
|
return true;
|
|
59
72
|
}
|
|
60
|
-
return argv.some(
|
|
61
|
-
(arg) => ["--help", "-h", "--version", "-V"].includes(arg)
|
|
62
|
-
);
|
|
73
|
+
return argv.some((arg) => ["--help", "-h", "--version", "-V"].includes(arg));
|
|
63
74
|
}
|
|
64
75
|
function isNewerVersion(candidate, current) {
|
|
65
76
|
const parse = (version) => version.replace(/^[^\d]*/, "").split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10) || 0);
|
|
@@ -83,6 +94,9 @@ Update available: ${SERVER_VERSION} \u2192 ${newVersion}
|
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
export {
|
|
86
|
-
checkForUpdates
|
|
97
|
+
checkForUpdates,
|
|
98
|
+
fetchLatestVersion,
|
|
99
|
+
getPendingUpdateVersion,
|
|
100
|
+
shouldSkipUpdateCheck,
|
|
101
|
+
isNewerVersion
|
|
87
102
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-QNCI4DEB.js.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
executeRemoteTool
|
|
4
|
+
} from "./chunk-Q7VBYLX7.js";
|
|
5
|
+
import {
|
|
6
|
+
trackCommand
|
|
7
|
+
} from "./chunk-RU6QOFHH.js";
|
|
8
|
+
import {
|
|
9
|
+
debug,
|
|
10
|
+
dim,
|
|
11
|
+
shouldOutputJson,
|
|
12
|
+
writeOutput
|
|
13
|
+
} from "./chunk-725R3KLJ.js";
|
|
14
|
+
import {
|
|
15
|
+
resolveApiKey
|
|
16
|
+
} from "./chunk-6PC3HUAK.js";
|
|
17
|
+
|
|
18
|
+
// src/cli/execute.ts
|
|
19
|
+
import ora from "ora";
|
|
20
|
+
|
|
21
|
+
// src/cli/keyless-heroes.ts
|
|
22
|
+
var CHAIN_ID_TO_NAME = {
|
|
23
|
+
"1": "ethereum",
|
|
24
|
+
"10": "optimism",
|
|
25
|
+
"56": "bsc",
|
|
26
|
+
"137": "polygon",
|
|
27
|
+
"8453": "base",
|
|
28
|
+
"42161": "arbitrum",
|
|
29
|
+
"43114": "avalanche"
|
|
30
|
+
};
|
|
31
|
+
var ALCHEMY_NETWORK_TO_CHAIN = {
|
|
32
|
+
"eth-mainnet": "ethereum",
|
|
33
|
+
"opt-mainnet": "optimism",
|
|
34
|
+
"bnb-mainnet": "bsc",
|
|
35
|
+
"polygon-mainnet": "polygon",
|
|
36
|
+
"base-mainnet": "base",
|
|
37
|
+
"arb-mainnet": "arbitrum",
|
|
38
|
+
"avax-mainnet": "avalanche"
|
|
39
|
+
};
|
|
40
|
+
function firstListEntry(value) {
|
|
41
|
+
if (typeof value !== "string") return null;
|
|
42
|
+
const parts = value.split(",").map((part) => part.trim()).filter(Boolean);
|
|
43
|
+
return parts.length === 1 ? parts[0] : null;
|
|
44
|
+
}
|
|
45
|
+
function remapForKeylessHero(toolName, args) {
|
|
46
|
+
if (toolName === "get_price") {
|
|
47
|
+
const token = firstListEntry(args.ids);
|
|
48
|
+
if (!token) return null;
|
|
49
|
+
const vsCurrency = firstListEntry(args.vs_currencies) ?? "usd";
|
|
50
|
+
return {
|
|
51
|
+
tool: "get_token_price",
|
|
52
|
+
args: { token, vs_currency: vsCurrency },
|
|
53
|
+
note: "no API key \u2014 routed through the keyless get_token_price hero"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (toolName === "get_token_security") {
|
|
57
|
+
const address = firstListEntry(args.contract_addresses);
|
|
58
|
+
if (!address) return null;
|
|
59
|
+
const chainId = typeof args.chain_id === "string" || typeof args.chain_id === "number" ? String(args.chain_id) : null;
|
|
60
|
+
const chain = chainId ? CHAIN_ID_TO_NAME[chainId] ?? chainId : void 0;
|
|
61
|
+
return {
|
|
62
|
+
tool: "check_token_safety",
|
|
63
|
+
args: chain ? { address, chain } : { address },
|
|
64
|
+
note: "no API key \u2014 routed through the keyless check_token_safety hero"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (toolName === "alchemy_get_tokens_by_wallet") {
|
|
68
|
+
const address = typeof args.address === "string" && args.address.trim() ? args.address.trim() : null;
|
|
69
|
+
if (!address) return null;
|
|
70
|
+
const network = typeof args.network === "string" ? args.network.trim() : null;
|
|
71
|
+
const chain = network ? ALCHEMY_NETWORK_TO_CHAIN[network] : void 0;
|
|
72
|
+
return {
|
|
73
|
+
tool: "get_wallet_portfolio",
|
|
74
|
+
args: chain ? { address, chain } : { address },
|
|
75
|
+
note: "no API key \u2014 routed through the keyless get_wallet_portfolio hero"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/cli/execute.ts
|
|
82
|
+
async function executeTool(toolName, args, timeoutMs = 3e4) {
|
|
83
|
+
if (!resolveApiKey()) {
|
|
84
|
+
const remap = remapForKeylessHero(toolName, args);
|
|
85
|
+
if (remap) {
|
|
86
|
+
debug(remap.note);
|
|
87
|
+
toolName = remap.tool;
|
|
88
|
+
args = remap.args;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
debug(`Executing ${toolName} remotely`);
|
|
92
|
+
const showSpinner = !shouldOutputJson() && !!process.stderr.isTTY;
|
|
93
|
+
const spinner = showSpinner ? ora({ text: `Calling ${toolName}...`, stream: process.stderr }).start() : null;
|
|
94
|
+
const startMs = Date.now();
|
|
95
|
+
let response;
|
|
96
|
+
try {
|
|
97
|
+
response = await executeRemoteTool(toolName, args, timeoutMs);
|
|
98
|
+
spinner?.succeed(`${toolName} (${Date.now() - startMs}ms)`);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
spinner?.fail(`${toolName} failed (${Date.now() - startMs}ms)`);
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
trackCommand(
|
|
104
|
+
toolName,
|
|
105
|
+
Date.now() - startMs,
|
|
106
|
+
response.ok ? void 0 : response.error?.code
|
|
107
|
+
);
|
|
108
|
+
await writeOutput(response);
|
|
109
|
+
const quotaRemaining = response.meta?.quota_remaining;
|
|
110
|
+
if (typeof quotaRemaining === "number" && !resolveApiKey() && !shouldOutputJson()) {
|
|
111
|
+
process.stderr.write(
|
|
112
|
+
dim(
|
|
113
|
+
`${quotaRemaining} free call${quotaRemaining === 1 ? "" : "s"} left today \u2014 run \`hive auth login\` for a full key.`
|
|
114
|
+
) + "\n"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
const exitCode = response.error?.code === "TOOL_NOT_FOUND" ? 3 : response.error?.code === "PROVIDER_UNAVAILABLE" ? 5 : response.error?.code === "RATE_LIMITED" ? 6 : response.error?.code === "TIMEOUT" ? 124 : 4;
|
|
119
|
+
process.exit(exitCode);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
executeTool
|
|
125
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SERVER_VERSION
|
|
4
|
+
} from "./chunk-ZXKFJQDE.js";
|
|
2
5
|
import {
|
|
3
6
|
getNoRetry,
|
|
4
7
|
resolveApiKey,
|
|
5
8
|
resolveApiUrl
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6PC3HUAK.js";
|
|
7
10
|
|
|
8
11
|
// src/cli/api-client.ts
|
|
9
12
|
var MAX_RETRIES = 3;
|
|
@@ -56,7 +59,7 @@ async function fetchWithRetry(url, init, fetchFn = fetch) {
|
|
|
56
59
|
function getHeaders(apiKey) {
|
|
57
60
|
const headers = {
|
|
58
61
|
"Content-Type": "application/json",
|
|
59
|
-
"User-Agent": `hive-cli/${process.env.npm_package_version ??
|
|
62
|
+
"User-Agent": `hive-cli/${process.env.npm_package_version ?? SERVER_VERSION}`
|
|
60
63
|
};
|
|
61
64
|
if (apiKey) headers.Authorization = `Bearer ${apiKey}`;
|
|
62
65
|
return headers;
|
|
@@ -84,6 +87,13 @@ async function executeRemoteTool(toolName, args, timeoutMs = 3e4) {
|
|
|
84
87
|
signal: controller.signal
|
|
85
88
|
});
|
|
86
89
|
const data = await response.json();
|
|
90
|
+
const quotaHeader = response.headers?.get?.("x-quota-remaining");
|
|
91
|
+
if (quotaHeader != null && quotaHeader !== "") {
|
|
92
|
+
const quotaRemaining = Number.parseInt(quotaHeader, 10);
|
|
93
|
+
if (Number.isFinite(quotaRemaining)) {
|
|
94
|
+
data.meta = { ...data.meta ?? {}, quota_remaining: quotaRemaining };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
87
97
|
return data;
|
|
88
98
|
} catch (error) {
|
|
89
99
|
if (error instanceof Error && error.name === "AbortError") {
|
|
@@ -247,4 +257,3 @@ export {
|
|
|
247
257
|
revokeKeyApi,
|
|
248
258
|
getUsage
|
|
249
259
|
};
|
|
250
|
-
//# sourceMappingURL=chunk-IZTN7WFH.js.map
|