hive-intelligence 1.1.2 → 1.1.4
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 +12 -10
- package/README.md +325 -351
- package/agent-skills/.claude-plugin/plugin.json +111 -0
- package/agent-skills/.mcp.json +11 -0
- package/agent-skills/AGENTS.md +37 -0
- package/agent-skills/LICENSE +21 -0
- package/agent-skills/README.md +145 -0
- package/agent-skills/SKILL.md +80 -0
- package/agent-skills/evals/README.md +20 -0
- package/agent-skills/evals/trigger-queries.json +464 -0
- package/agent-skills/package.json +49 -0
- package/agent-skills/packs/hive-build/SKILL.md +328 -0
- package/agent-skills/packs/hive-build/evals/evals.json +28 -0
- package/agent-skills/packs/hive-build-onboarding/SKILL.md +137 -0
- package/agent-skills/packs/hive-build-onboarding/evals/evals.json +27 -0
- package/agent-skills/packs/hive-cli/SKILL.md +141 -0
- package/agent-skills/packs/hive-cli/evals/evals.json +27 -0
- package/agent-skills/packs/hive-defi-research/SKILL.md +42 -0
- package/agent-skills/packs/hive-defi-research/evals/evals.json +27 -0
- package/agent-skills/packs/hive-defi-research/references/workflow.md +41 -0
- package/agent-skills/packs/hive-dex-pool-analysis/SKILL.md +41 -0
- package/agent-skills/packs/hive-dex-pool-analysis/evals/evals.json +27 -0
- package/agent-skills/packs/hive-dex-pool-analysis/references/workflow.md +42 -0
- package/agent-skills/packs/hive-market-research/SKILL.md +45 -0
- package/agent-skills/packs/hive-market-research/evals/evals.json +27 -0
- package/agent-skills/packs/hive-market-research/references/workflow.md +47 -0
- package/agent-skills/packs/hive-mcp/SKILL.md +147 -0
- package/agent-skills/packs/hive-mcp/evals/evals.json +38 -0
- package/agent-skills/packs/hive-mcp/references/client-install-matrix.md +83 -0
- package/agent-skills/packs/hive-mcp/references/clients.md +141 -0
- package/agent-skills/packs/hive-network-infrastructure/SKILL.md +44 -0
- package/agent-skills/packs/hive-network-infrastructure/evals/evals.json +27 -0
- package/agent-skills/packs/hive-network-infrastructure/references/workflow.md +41 -0
- package/agent-skills/packs/hive-nft-research/SKILL.md +41 -0
- package/agent-skills/packs/hive-nft-research/evals/evals.json +27 -0
- package/agent-skills/packs/hive-nft-research/references/workflow.md +42 -0
- package/agent-skills/packs/hive-prediction-markets/SKILL.md +44 -0
- package/agent-skills/packs/hive-prediction-markets/evals/evals.json +27 -0
- package/agent-skills/packs/hive-prediction-markets/references/workflow.md +42 -0
- package/agent-skills/packs/hive-query/SKILL.md +99 -0
- package/agent-skills/packs/hive-query/evals/evals.json +38 -0
- package/agent-skills/packs/hive-query/references/root-mcp-workflow.md +54 -0
- package/agent-skills/packs/hive-security-risk/SKILL.md +42 -0
- package/agent-skills/packs/hive-security-risk/evals/evals.json +27 -0
- package/agent-skills/packs/hive-security-risk/references/workflow.md +46 -0
- package/agent-skills/packs/hive-solana-analysis/SKILL.md +42 -0
- package/agent-skills/packs/hive-solana-analysis/evals/evals.json +27 -0
- package/agent-skills/packs/hive-solana-analysis/references/workflow.md +42 -0
- package/agent-skills/packs/hive-stateful-monitoring/SKILL.md +75 -0
- package/agent-skills/packs/hive-stateful-monitoring/evals/evals.json +49 -0
- package/agent-skills/packs/hive-token-diligence/SKILL.md +44 -0
- package/agent-skills/packs/hive-token-diligence/evals/evals.json +27 -0
- package/agent-skills/packs/hive-token-diligence/references/workflow.md +45 -0
- package/agent-skills/packs/hive-tool-discovery/SKILL.md +49 -0
- package/agent-skills/packs/hive-tool-discovery/evals/evals.json +38 -0
- package/agent-skills/packs/hive-tool-discovery/references/discovery-surfaces.md +62 -0
- package/agent-skills/packs/hive-wallet-investigation/SKILL.md +42 -0
- package/agent-skills/packs/hive-wallet-investigation/evals/evals.json +27 -0
- package/agent-skills/packs/hive-wallet-investigation/references/workflow.md +45 -0
- package/agent-skills/references/agents-routing.md +51 -0
- package/agent-skills/scripts/validate-agent-skills-package.mjs +216 -0
- package/agent-skills/skills.sh.json +41 -0
- package/bin/hive-mcp.js +33 -0
- package/build/{alias-INGXWFCG.js → alias-3OPMQF4X.js} +2 -3
- package/build/api-client-EPF6FD7A.js +28 -0
- package/build/auth-Q5Q24IRI.js +39 -0
- package/build/browser-auth-VPF5LZMZ.js +8 -0
- package/build/{cache-US4LSZPI.js → cache-T6KC5YEY.js} +2 -3
- package/build/{chunk-QMRVH5ZP.js → chunk-3WYWXTNN.js} +9 -2
- package/build/chunk-4F5CI6LX.js +340 -0
- package/build/chunk-5XXI25JE.js +496 -0
- package/build/chunk-7JWXBKEJ.js +252 -0
- package/build/chunk-CEWCB5YS.js +71 -0
- package/build/{chunk-CGXVV6WR.js → chunk-FH3YGSY5.js} +86 -105
- package/build/chunk-FRXMGRZQ.js +102 -0
- package/build/chunk-GZPDEXO4.js +126 -0
- package/build/chunk-IZPAMRHP.js +43 -0
- package/build/chunk-JTUKQWIO.js +79720 -0
- package/build/{chunk-CP3FXEQA.js → chunk-NP6NSOG2.js} +4 -6
- package/build/{chunk-XQJ6PB2L.js → chunk-POT2MBEK.js} +0 -1
- package/build/chunk-VBOKVQ74.js +280 -0
- package/build/{chunk-WKVZVQTG.js → chunk-YZ2PXBJK.js} +6 -4
- package/build/chunk-ZCU7XQKF.js +14 -0
- package/build/chunk-ZTJVOWDQ.js +85 -0
- package/build/chunk-ZXB53E7H.js +246 -0
- package/build/cli.js +138 -125
- package/build/{completion-J6HFY6PS.js → completion-46K674EL.js} +54 -50
- package/build/config-XE6Q5P4I.js +57 -0
- package/build/{config-dir-IEOID7Q6.js → config-dir-MAWX5AUF.js} +2 -3
- package/build/{doctor-7WZMCQC7.js → doctor-HGMQE6IN.js} +37 -13
- package/build/{errors-U6UZWVSD.js → errors-J2PH3NLJ.js} +2 -3
- package/build/format-5X2HIVDT.js +42 -0
- package/build/{init-CAVIFVSH.js → init-JMDNM7ZZ.js} +1 -2
- package/build/init-all-5SKNV75X.js +273 -0
- package/build/mcpServer-5TKKSKJM.js +21 -0
- package/build/monitor-worker.js +1140 -0
- package/build/{namespace-7JWWBWBL.js → namespace-FSX2G3NM.js} +2 -3
- package/build/{open-FUXYIHFO.js → open-5A6ZQMGC.js} +5 -6
- package/build/{output-7PGQWJY2.js → output-V3D4YZ6U.js} +2 -3
- package/build/serve-AGCOXXFM.js +49 -0
- package/build/server.js +5042 -14125
- package/build/setup-RMETGJWK.js +135 -0
- package/build/stdio.js +32 -0
- package/build/{telemetry-KNWMQURH.js → telemetry-WCME5XEU.js} +4 -4
- package/build/{tools-VRRMBCZQ.js → tools-KAB6QBZC.js} +15 -15
- package/build/uninstall-FLJMBBSC.js +114 -0
- package/build/update-check-LNZQK3XA.js +18 -0
- package/build/upgrade-DTUIHVPS.js +171 -0
- package/build/version-I6HDAF4L.js +14 -0
- package/build/{watch-A75SVIQ6.js → watch-YNN255QX.js} +7 -7
- package/package.json +124 -53
- package/bin/hive.js +0 -25
- package/build/alias-INGXWFCG.js.map +0 -1
- package/build/auth-77MKFFBQ.js +0 -233
- package/build/auth-77MKFFBQ.js.map +0 -1
- package/build/cache-US4LSZPI.js.map +0 -1
- package/build/chunk-CGXVV6WR.js.map +0 -1
- package/build/chunk-CP3FXEQA.js.map +0 -1
- package/build/chunk-DTUDM6HX.js +0 -3108
- package/build/chunk-DTUDM6HX.js.map +0 -1
- package/build/chunk-LBTLYTZS.js +0 -115
- package/build/chunk-LBTLYTZS.js.map +0 -1
- package/build/chunk-OK3LSM73.js +0 -22
- package/build/chunk-OK3LSM73.js.map +0 -1
- package/build/chunk-QMRVH5ZP.js.map +0 -1
- package/build/chunk-RRI526CJ.js +0 -212
- package/build/chunk-RRI526CJ.js.map +0 -1
- package/build/chunk-WKVZVQTG.js.map +0 -1
- package/build/chunk-XQJ6PB2L.js.map +0 -1
- package/build/cli.js.map +0 -1
- package/build/completion-J6HFY6PS.js.map +0 -1
- package/build/config-ANFERP7A.js +0 -99
- package/build/config-ANFERP7A.js.map +0 -1
- package/build/config-dir-IEOID7Q6.js.map +0 -1
- package/build/doctor-7WZMCQC7.js.map +0 -1
- package/build/errors-U6UZWVSD.js.map +0 -1
- package/build/format-CVLLK6GD.js +0 -75
- package/build/format-CVLLK6GD.js.map +0 -1
- package/build/init-CAVIFVSH.js.map +0 -1
- package/build/namespace-7JWWBWBL.js.map +0 -1
- package/build/open-FUXYIHFO.js.map +0 -1
- package/build/output-7PGQWJY2.js.map +0 -1
- package/build/server.js.map +0 -1
- package/build/telemetry-KNWMQURH.js.map +0 -1
- package/build/tools-VRRMBCZQ.js.map +0 -1
- package/build/version-3TZ3U4IR.js +0 -9
- package/build/version-3TZ3U4IR.js.map +0 -1
- package/build/watch-A75SVIQ6.js.map +0 -1
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ensureConfigDir,
|
|
4
|
+
getConfig,
|
|
5
|
+
getCredentials,
|
|
6
|
+
saveConfig,
|
|
7
|
+
saveCredentials
|
|
8
|
+
} from "./chunk-POT2MBEK.js";
|
|
9
|
+
|
|
10
|
+
// src/cli/auth.ts
|
|
11
|
+
import { createInterface } from "readline";
|
|
12
|
+
function maskKey(key) {
|
|
13
|
+
if (!key) return "(empty)";
|
|
14
|
+
const visible = Math.min(8, key.length - 1);
|
|
15
|
+
return key.slice(0, visible) + "...";
|
|
16
|
+
}
|
|
17
|
+
function saveProfile(name, apiKey, apiUrl) {
|
|
18
|
+
ensureConfigDir();
|
|
19
|
+
const creds = getCredentials();
|
|
20
|
+
creds.profiles[name] = {
|
|
21
|
+
apiKey,
|
|
22
|
+
apiUrl,
|
|
23
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
24
|
+
};
|
|
25
|
+
saveCredentials(creds);
|
|
26
|
+
const config = getConfig();
|
|
27
|
+
config.activeProfile = name;
|
|
28
|
+
saveConfig(config);
|
|
29
|
+
}
|
|
30
|
+
function removeProfile(name) {
|
|
31
|
+
const creds = getCredentials();
|
|
32
|
+
delete creds.profiles[name];
|
|
33
|
+
saveCredentials(creds);
|
|
34
|
+
const config = getConfig();
|
|
35
|
+
if (config.activeProfile === name) {
|
|
36
|
+
const remaining = Object.keys(creds.profiles);
|
|
37
|
+
config.activeProfile = remaining[0] ?? "default";
|
|
38
|
+
saveConfig(config);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getActiveProfile() {
|
|
42
|
+
const config = getConfig();
|
|
43
|
+
const creds = getCredentials();
|
|
44
|
+
const profile = creds.profiles[config.activeProfile];
|
|
45
|
+
if (!profile) return null;
|
|
46
|
+
return { name: config.activeProfile, ...profile, isActive: true };
|
|
47
|
+
}
|
|
48
|
+
function listProfiles() {
|
|
49
|
+
const config = getConfig();
|
|
50
|
+
const creds = getCredentials();
|
|
51
|
+
return Object.entries(creds.profiles).map(([name, p]) => ({
|
|
52
|
+
name,
|
|
53
|
+
...p,
|
|
54
|
+
isActive: name === config.activeProfile
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
function switchProfile(name) {
|
|
58
|
+
const creds = getCredentials();
|
|
59
|
+
if (!creds.profiles[name]) {
|
|
60
|
+
throw new Error(`Profile "${name}" not found`);
|
|
61
|
+
}
|
|
62
|
+
const config = getConfig();
|
|
63
|
+
config.activeProfile = name;
|
|
64
|
+
saveConfig(config);
|
|
65
|
+
}
|
|
66
|
+
var ask = (rl, q) => new Promise((resolve) => rl.question(q, resolve));
|
|
67
|
+
function askSecret(prompt) {
|
|
68
|
+
if (!process.stdin.isTTY) {
|
|
69
|
+
const rl = createInterface({
|
|
70
|
+
input: process.stdin,
|
|
71
|
+
output: process.stderr
|
|
72
|
+
});
|
|
73
|
+
return new Promise(
|
|
74
|
+
(resolve) => rl.question(prompt, (ans) => {
|
|
75
|
+
rl.close();
|
|
76
|
+
resolve(ans);
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
process.stderr.write(prompt);
|
|
82
|
+
const chunks = [];
|
|
83
|
+
const stdin = process.stdin;
|
|
84
|
+
const wasRaw = stdin.isRaw;
|
|
85
|
+
if (typeof stdin.setRawMode === "function") {
|
|
86
|
+
stdin.setRawMode(true);
|
|
87
|
+
}
|
|
88
|
+
stdin.resume();
|
|
89
|
+
stdin.setEncoding("utf-8");
|
|
90
|
+
const onData = (ch) => {
|
|
91
|
+
const c = ch.toString();
|
|
92
|
+
if (c === "\n" || c === "\r" || c === "") {
|
|
93
|
+
stdin.removeListener("data", onData);
|
|
94
|
+
if (typeof stdin.setRawMode === "function") {
|
|
95
|
+
stdin.setRawMode(wasRaw ?? false);
|
|
96
|
+
}
|
|
97
|
+
stdin.pause();
|
|
98
|
+
process.stderr.write("\n");
|
|
99
|
+
resolve(chunks.join(""));
|
|
100
|
+
} else if (c === "") {
|
|
101
|
+
process.exit(130);
|
|
102
|
+
} else if (c === "\x7F" || c === "\b") {
|
|
103
|
+
if (chunks.length > 0) {
|
|
104
|
+
chunks.pop();
|
|
105
|
+
process.stderr.write("\b \b");
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
chunks.push(c);
|
|
109
|
+
process.stderr.write("*");
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
stdin.on("data", onData);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async function runLogin(opts) {
|
|
116
|
+
const profileName = opts.profile ?? "default";
|
|
117
|
+
if (opts.manual) {
|
|
118
|
+
process.stderr.write(`
|
|
119
|
+
Hive CLI \u2014 Login (profile: ${profileName})
|
|
120
|
+
|
|
121
|
+
`);
|
|
122
|
+
let apiKey;
|
|
123
|
+
let apiUrl;
|
|
124
|
+
if (process.stdin.isTTY) {
|
|
125
|
+
apiKey = (await askSecret("API Key: ")).trim();
|
|
126
|
+
if (!apiKey) {
|
|
127
|
+
process.stderr.write("No API key provided. Aborting.\n");
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
const rl = createInterface({
|
|
131
|
+
input: process.stdin,
|
|
132
|
+
output: process.stderr
|
|
133
|
+
});
|
|
134
|
+
const urlInput = await ask(
|
|
135
|
+
rl,
|
|
136
|
+
`API URL [https://mcp.hiveintelligence.xyz]: `
|
|
137
|
+
);
|
|
138
|
+
rl.close();
|
|
139
|
+
apiUrl = urlInput.trim() || "https://mcp.hiveintelligence.xyz";
|
|
140
|
+
} else {
|
|
141
|
+
const lines = await new Promise((resolve) => {
|
|
142
|
+
const collected = [];
|
|
143
|
+
const rl = createInterface({
|
|
144
|
+
input: process.stdin,
|
|
145
|
+
output: process.stderr
|
|
146
|
+
});
|
|
147
|
+
process.stderr.write("API Key: ");
|
|
148
|
+
rl.on("line", (line) => {
|
|
149
|
+
collected.push(line);
|
|
150
|
+
if (collected.length === 1) {
|
|
151
|
+
process.stderr.write(
|
|
152
|
+
`API URL [https://mcp.hiveintelligence.xyz]: `
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (collected.length >= 2) {
|
|
156
|
+
rl.close();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
rl.on("close", () => resolve(collected));
|
|
160
|
+
});
|
|
161
|
+
apiKey = (lines[0] ?? "").trim();
|
|
162
|
+
if (!apiKey) {
|
|
163
|
+
process.stderr.write("No API key provided. Aborting.\n");
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
apiUrl = (lines[1] ?? "").trim() || "https://mcp.hiveintelligence.xyz";
|
|
167
|
+
}
|
|
168
|
+
process.stderr.write(`
|
|
169
|
+
Validating against ${apiUrl}...
|
|
170
|
+
`);
|
|
171
|
+
try {
|
|
172
|
+
const controller = new AbortController();
|
|
173
|
+
const timer = setTimeout(() => controller.abort(), 1e4);
|
|
174
|
+
const resp = await fetch(`${apiUrl}/ping`, {
|
|
175
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
176
|
+
signal: controller.signal
|
|
177
|
+
});
|
|
178
|
+
clearTimeout(timer);
|
|
179
|
+
if (resp.ok) {
|
|
180
|
+
process.stderr.write("Key validated successfully.\n");
|
|
181
|
+
} else if (resp.status === 401 || resp.status === 403) {
|
|
182
|
+
process.stderr.write(
|
|
183
|
+
`Warning: Server returned ${resp.status} \u2014 key may be invalid.
|
|
184
|
+
`
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
process.stderr.write(`Warning: Server returned ${resp.status}.
|
|
188
|
+
`);
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
process.stderr.write(
|
|
192
|
+
"Warning: Could not reach server \u2014 saving anyway.\n"
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
saveProfile(profileName, apiKey, apiUrl);
|
|
196
|
+
process.stderr.write(
|
|
197
|
+
`
|
|
198
|
+
Profile "${profileName}" saved. Key: ${maskKey(apiKey)}
|
|
199
|
+
`
|
|
200
|
+
);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
process.stderr.write(`
|
|
204
|
+
Hive CLI \u2014 Login (profile: ${profileName})
|
|
205
|
+
`);
|
|
206
|
+
try {
|
|
207
|
+
const { browserLogin } = await import("./browser-auth-VPF5LZMZ.js");
|
|
208
|
+
const apiUrl = process.env.HIVE_API_URL || "https://mcp.hiveintelligence.xyz";
|
|
209
|
+
const websiteUrl = process.env.HIVE_WEBSITE_URL || "https://hiveintelligence.xyz";
|
|
210
|
+
const result = await browserLogin({ baseUrl: websiteUrl });
|
|
211
|
+
saveProfile(profileName, result.key, apiUrl);
|
|
212
|
+
if (result.email) {
|
|
213
|
+
const creds = getCredentials();
|
|
214
|
+
if (creds.profiles[profileName]) {
|
|
215
|
+
creds.profiles[profileName].email = result.email;
|
|
216
|
+
saveCredentials(creds);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
process.stderr.write(`
|
|
220
|
+
Authenticated as ${result.email || "unknown"}
|
|
221
|
+
`);
|
|
222
|
+
process.stderr.write(`API Key: ${maskKey(result.key)}
|
|
223
|
+
`);
|
|
224
|
+
process.stderr.write(`Profile "${profileName}" saved.
|
|
225
|
+
|
|
226
|
+
`);
|
|
227
|
+
process.stderr.write(
|
|
228
|
+
`Next: run 'hive setup' to configure your AI client.
|
|
229
|
+
`
|
|
230
|
+
);
|
|
231
|
+
} catch (err) {
|
|
232
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
233
|
+
process.stderr.write(`
|
|
234
|
+
Login failed: ${msg}
|
|
235
|
+
`);
|
|
236
|
+
process.stderr.write(
|
|
237
|
+
`Fallback: run 'hive auth login --manual' to paste your key.
|
|
238
|
+
`
|
|
239
|
+
);
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async function runLogout() {
|
|
244
|
+
const config = getConfig();
|
|
245
|
+
const profile = config.activeProfile;
|
|
246
|
+
removeProfile(profile);
|
|
247
|
+
process.stderr.write(`Logged out of profile "${profile}".
|
|
248
|
+
`);
|
|
249
|
+
}
|
|
250
|
+
async function runWhoami() {
|
|
251
|
+
const profile = getActiveProfile();
|
|
252
|
+
if (!profile) {
|
|
253
|
+
process.stderr.write("Not logged in. Run: hive auth login\n");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
process.stderr.write(
|
|
257
|
+
`
|
|
258
|
+
Profile: ${profile.name}${profile.isActive ? " (active)" : ""}
|
|
259
|
+
`
|
|
260
|
+
);
|
|
261
|
+
process.stderr.write(`API Key: ${maskKey(profile.apiKey)}
|
|
262
|
+
`);
|
|
263
|
+
process.stderr.write(`API URL: ${profile.apiUrl}
|
|
264
|
+
`);
|
|
265
|
+
process.stderr.write(`Created: ${profile.createdAt}
|
|
266
|
+
|
|
267
|
+
`);
|
|
268
|
+
}
|
|
269
|
+
async function runProfiles() {
|
|
270
|
+
const profiles = listProfiles();
|
|
271
|
+
if (profiles.length === 0) {
|
|
272
|
+
process.stderr.write("No profiles configured. Run: hive auth login\n");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
for (const p of profiles) {
|
|
276
|
+
const marker = p.isActive ? " *" : "";
|
|
277
|
+
process.stderr.write(
|
|
278
|
+
` ${p.name}${marker} ${maskKey(p.apiKey)} ${p.apiUrl}
|
|
279
|
+
`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
process.stderr.write("\n");
|
|
283
|
+
}
|
|
284
|
+
async function runSwitch(name) {
|
|
285
|
+
try {
|
|
286
|
+
switchProfile(name);
|
|
287
|
+
process.stderr.write(`Switched to profile "${name}".
|
|
288
|
+
`);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
process.stderr.write(
|
|
291
|
+
(err instanceof Error ? err.message : String(err)) + "\n"
|
|
292
|
+
);
|
|
293
|
+
process.exit(1);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function runSignup(opts) {
|
|
297
|
+
const { authSignup } = await import("./api-client-EPF6FD7A.js");
|
|
298
|
+
const profileName = opts.profile ?? "default";
|
|
299
|
+
process.stderr.write(`
|
|
300
|
+
Hive CLI \u2014 Signup (profile: ${profileName})
|
|
301
|
+
|
|
302
|
+
`);
|
|
303
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
304
|
+
const email = await ask(rl, "Email: ");
|
|
305
|
+
rl.close();
|
|
306
|
+
const password = await askSecret("Password: ");
|
|
307
|
+
if (!email.trim() || !password.trim()) {
|
|
308
|
+
process.stderr.write("Email and password are required. Aborting.\n");
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
process.stderr.write("\nCreating account...\n");
|
|
312
|
+
const result = await authSignup(email.trim(), password.trim());
|
|
313
|
+
if (!result.ok) {
|
|
314
|
+
const errMsg = result.error?.message ?? "Signup failed";
|
|
315
|
+
process.stderr.write(`Error: ${errMsg}
|
|
316
|
+
`);
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
const apiKey = result.data?.api_key;
|
|
320
|
+
const keyValue = apiKey?.key;
|
|
321
|
+
const apiUrl = process.env.HIVE_API_URL || "https://mcp.hiveintelligence.xyz";
|
|
322
|
+
if (keyValue) {
|
|
323
|
+
saveProfile(profileName, keyValue, apiUrl);
|
|
324
|
+
process.stderr.write(`
|
|
325
|
+
Account created successfully!
|
|
326
|
+
`);
|
|
327
|
+
process.stderr.write(`API Key: ${keyValue}
|
|
328
|
+
`);
|
|
329
|
+
process.stderr.write(
|
|
330
|
+
`WARNING: Save this key \u2014 it will not be shown again.
|
|
331
|
+
`
|
|
332
|
+
);
|
|
333
|
+
process.stderr.write(`
|
|
334
|
+
Profile "${profileName}" saved.
|
|
335
|
+
`);
|
|
336
|
+
} else {
|
|
337
|
+
process.stderr.write(`
|
|
338
|
+
Account created but no API key was generated.
|
|
339
|
+
`);
|
|
340
|
+
process.stderr.write(`Run: hive keys create
|
|
341
|
+
`);
|
|
342
|
+
}
|
|
343
|
+
const resultData = result.data;
|
|
344
|
+
const session = resultData?.session;
|
|
345
|
+
if (session?.access_token) {
|
|
346
|
+
const creds = getCredentials();
|
|
347
|
+
creds.profiles[profileName] = {
|
|
348
|
+
...creds.profiles[profileName],
|
|
349
|
+
jwt: session.access_token
|
|
350
|
+
};
|
|
351
|
+
saveCredentials(creds);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
async function runKeysList() {
|
|
355
|
+
const { listKeysApi } = await import("./api-client-EPF6FD7A.js");
|
|
356
|
+
const creds = getCredentials();
|
|
357
|
+
const config = getConfig();
|
|
358
|
+
const jwt = creds.profiles[config.activeProfile]?.jwt;
|
|
359
|
+
if (!jwt) {
|
|
360
|
+
process.stderr.write(
|
|
361
|
+
"No session token. Run: hive auth signup or hive auth login\n"
|
|
362
|
+
);
|
|
363
|
+
process.exit(1);
|
|
364
|
+
}
|
|
365
|
+
const result = await listKeysApi(jwt);
|
|
366
|
+
if (!result.ok) {
|
|
367
|
+
process.stderr.write("Failed to list keys. Try logging in again.\n");
|
|
368
|
+
process.exit(1);
|
|
369
|
+
}
|
|
370
|
+
const keys = result.data;
|
|
371
|
+
if (!keys || keys.length === 0) {
|
|
372
|
+
process.stderr.write("No API keys found. Run: hive keys create\n");
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
process.stderr.write(`
|
|
376
|
+
${"KEY".padEnd(20)} ${"NAME".padEnd(15)} STATUS
|
|
377
|
+
`);
|
|
378
|
+
process.stderr.write(
|
|
379
|
+
` ${"\u2500".repeat(20)} ${"\u2500".repeat(15)} ${"\u2500".repeat(10)}
|
|
380
|
+
`
|
|
381
|
+
);
|
|
382
|
+
for (const k of keys) {
|
|
383
|
+
const prefix = k.prefix || "???";
|
|
384
|
+
const name = k.name || "Unnamed";
|
|
385
|
+
const enabled = k.enabled ? "active" : "disabled";
|
|
386
|
+
process.stderr.write(
|
|
387
|
+
` ${(prefix + "...").padEnd(20)} ${name.padEnd(15)} ${enabled}
|
|
388
|
+
`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
process.stderr.write("\n");
|
|
392
|
+
}
|
|
393
|
+
async function runKeysCreate(opts) {
|
|
394
|
+
const { createKey } = await import("./api-client-EPF6FD7A.js");
|
|
395
|
+
const creds = getCredentials();
|
|
396
|
+
const config = getConfig();
|
|
397
|
+
const jwt = creds.profiles[config.activeProfile]?.jwt;
|
|
398
|
+
if (!jwt) {
|
|
399
|
+
process.stderr.write(
|
|
400
|
+
"No session token. Run: hive auth signup or hive auth login\n"
|
|
401
|
+
);
|
|
402
|
+
process.exit(1);
|
|
403
|
+
}
|
|
404
|
+
const name = opts.name ?? "CLI Key";
|
|
405
|
+
process.stderr.write(`Creating API key "${name}"...
|
|
406
|
+
`);
|
|
407
|
+
const result = await createKey(jwt, name);
|
|
408
|
+
if (!result.ok) {
|
|
409
|
+
const errMsg = result.error?.message ?? "Key creation failed";
|
|
410
|
+
process.stderr.write(`Error: ${errMsg}
|
|
411
|
+
`);
|
|
412
|
+
process.exit(1);
|
|
413
|
+
}
|
|
414
|
+
const data = result.data;
|
|
415
|
+
process.stderr.write(`
|
|
416
|
+
API Key: ${data.key}
|
|
417
|
+
`);
|
|
418
|
+
process.stderr.write(`Key ID: ${data.key_id}
|
|
419
|
+
`);
|
|
420
|
+
process.stderr.write(
|
|
421
|
+
`WARNING: Save this key \u2014 it will not be shown again.
|
|
422
|
+
|
|
423
|
+
`
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
async function runKeysRevoke(keyId) {
|
|
427
|
+
const { revokeKeyApi } = await import("./api-client-EPF6FD7A.js");
|
|
428
|
+
const creds = getCredentials();
|
|
429
|
+
const config = getConfig();
|
|
430
|
+
const jwt = creds.profiles[config.activeProfile]?.jwt;
|
|
431
|
+
if (!jwt) {
|
|
432
|
+
process.stderr.write(
|
|
433
|
+
"No session token. Run: hive auth signup or hive auth login\n"
|
|
434
|
+
);
|
|
435
|
+
process.exit(1);
|
|
436
|
+
}
|
|
437
|
+
process.stderr.write(`Revoking key ${keyId}...
|
|
438
|
+
`);
|
|
439
|
+
const result = await revokeKeyApi(jwt, keyId);
|
|
440
|
+
if (result.ok) {
|
|
441
|
+
process.stderr.write("Key revoked.\n");
|
|
442
|
+
} else {
|
|
443
|
+
process.stderr.write("Failed to revoke key.\n");
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
async function runUsage() {
|
|
448
|
+
const { getUsage } = await import("./api-client-EPF6FD7A.js");
|
|
449
|
+
const result = await getUsage();
|
|
450
|
+
if (!result.ok) {
|
|
451
|
+
process.stderr.write("Failed to fetch usage. Check your API key.\n");
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
const data = result.data;
|
|
455
|
+
const plan = data.plan;
|
|
456
|
+
const keys = data.keys;
|
|
457
|
+
process.stderr.write(`
|
|
458
|
+
Plan: ${plan.name ?? plan.id}
|
|
459
|
+
`);
|
|
460
|
+
process.stderr.write(` Rate: ${plan.rate_limit_per_min}/min
|
|
461
|
+
`);
|
|
462
|
+
process.stderr.write(` Quota: ${plan.monthly_credits}/month
|
|
463
|
+
`);
|
|
464
|
+
process.stderr.write(` Keys: ${data.total_keys}
|
|
465
|
+
|
|
466
|
+
`);
|
|
467
|
+
if (keys && keys.length > 0) {
|
|
468
|
+
for (const k of keys) {
|
|
469
|
+
const remaining = k.credits_remaining ?? "unlimited";
|
|
470
|
+
process.stderr.write(
|
|
471
|
+
` ${k.prefix}... ${k.name} credits: ${remaining}
|
|
472
|
+
`
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
process.stderr.write("\n");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export {
|
|
480
|
+
maskKey,
|
|
481
|
+
saveProfile,
|
|
482
|
+
removeProfile,
|
|
483
|
+
getActiveProfile,
|
|
484
|
+
listProfiles,
|
|
485
|
+
switchProfile,
|
|
486
|
+
runLogin,
|
|
487
|
+
runLogout,
|
|
488
|
+
runWhoami,
|
|
489
|
+
runProfiles,
|
|
490
|
+
runSwitch,
|
|
491
|
+
runSignup,
|
|
492
|
+
runKeysList,
|
|
493
|
+
runKeysCreate,
|
|
494
|
+
runKeysRevoke,
|
|
495
|
+
runUsage
|
|
496
|
+
};
|