hive-intelligence 0.1.0 → 0.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 +21 -0
- package/README.md +112 -77
- package/bin/hive.js +25 -0
- package/build/alias-INGXWFCG.js +41 -0
- package/build/alias-INGXWFCG.js.map +1 -0
- package/build/auth-PVT4GTAD.js +233 -0
- package/build/auth-PVT4GTAD.js.map +1 -0
- package/build/cache-US4LSZPI.js +52 -0
- package/build/cache-US4LSZPI.js.map +1 -0
- package/build/chunk-FAFUYZQS.js +280 -0
- package/build/chunk-FAFUYZQS.js.map +1 -0
- package/build/chunk-IWBWPHYY.js +212 -0
- package/build/chunk-IWBWPHYY.js.map +1 -0
- package/build/chunk-LBTLYTZS.js +115 -0
- package/build/chunk-LBTLYTZS.js.map +1 -0
- package/build/chunk-N43VRMVB.js +3108 -0
- package/build/chunk-N43VRMVB.js.map +1 -0
- package/build/chunk-NEKSTV6P.js +911 -0
- package/build/chunk-NEKSTV6P.js.map +1 -0
- package/build/chunk-OK3LSM73.js +22 -0
- package/build/chunk-OK3LSM73.js.map +1 -0
- package/build/chunk-QMRVH5ZP.js +44 -0
- package/build/chunk-QMRVH5ZP.js.map +1 -0
- package/build/chunk-WKVZVQTG.js +66 -0
- package/build/chunk-WKVZVQTG.js.map +1 -0
- package/build/chunk-XQJ6PB2L.js +95 -0
- package/build/chunk-XQJ6PB2L.js.map +1 -0
- package/build/cli.js +3858 -0
- package/build/cli.js.map +1 -0
- package/build/completion-N35TWBLT.js +274 -0
- package/build/completion-N35TWBLT.js.map +1 -0
- package/build/config-2VDB2ZHE.js +100 -0
- package/build/config-2VDB2ZHE.js.map +1 -0
- package/build/config-dir-IEOID7Q6.js +31 -0
- package/build/config-dir-IEOID7Q6.js.map +1 -0
- package/build/doctor-GYP6IHPP.js +231 -0
- package/build/doctor-GYP6IHPP.js.map +1 -0
- package/build/errors-HRGXEUZR.js +17 -0
- package/build/errors-HRGXEUZR.js.map +1 -0
- package/build/format-4OIUGZKY.js +43 -0
- package/build/format-4OIUGZKY.js.map +1 -0
- package/build/init-YOJK6CH2.js +102 -0
- package/build/init-YOJK6CH2.js.map +1 -0
- package/build/namespace-GWTS6U6J.js +13 -0
- package/build/namespace-GWTS6U6J.js.map +1 -0
- package/build/open-FUXYIHFO.js +37 -0
- package/build/open-FUXYIHFO.js.map +1 -0
- package/build/output-6TJ3JTZ7.js +41 -0
- package/build/output-6TJ3JTZ7.js.map +1 -0
- package/build/server.js +14763 -0
- package/build/server.js.map +1 -0
- package/build/telemetry-KNWMQURH.js +18 -0
- package/build/telemetry-KNWMQURH.js.map +1 -0
- package/build/tools-4W3GGCUC.js +178 -0
- package/build/tools-4W3GGCUC.js.map +1 -0
- package/build/version-3TZ3U4IR.js +9 -0
- package/build/version-3TZ3U4IR.js.map +1 -0
- package/build/watch-P2QWGFYV.js +67 -0
- package/build/watch-P2QWGFYV.js.map +1 -0
- package/package.json +56 -15
- package/.env,example +0 -1
- package/dist/client.d.ts +0 -7
- package/dist/client.js +0 -52
- package/dist/errors.d.ts +0 -7
- package/dist/errors.js +0 -15
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -20
- package/dist/types.d.ts +0 -19
- package/dist/types.js +0 -2
- package/example.ts +0 -35
- package/jest.config.js +0 -7
- package/src/client.js +0 -52
- package/src/client.ts +0 -42
- package/src/errors.js +0 -15
- package/src/errors.ts +0 -11
- package/src/index.js +0 -20
- package/src/index.ts +0 -5
- package/src/types.js +0 -2
- package/src/types.ts +0 -21
- package/tests/client.test.js +0 -28
- package/tests/client.test.ts +0 -18
- package/tests/hive.test.js +0 -69
- package/tests/hive.test.ts +0 -63
- package/tsconfig.json +0 -117
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
disableTelemetry,
|
|
4
|
+
enableTelemetry,
|
|
5
|
+
isTelemetryEnabled,
|
|
6
|
+
telemetryStatus,
|
|
7
|
+
trackCommand
|
|
8
|
+
} from "./chunk-WKVZVQTG.js";
|
|
9
|
+
import "./chunk-XQJ6PB2L.js";
|
|
10
|
+
import "./chunk-QMRVH5ZP.js";
|
|
11
|
+
export {
|
|
12
|
+
disableTelemetry,
|
|
13
|
+
enableTelemetry,
|
|
14
|
+
isTelemetryEnabled,
|
|
15
|
+
telemetryStatus,
|
|
16
|
+
trackCommand
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=telemetry-KNWMQURH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
fetchToolCatalog
|
|
4
|
+
} from "./chunk-LBTLYTZS.js";
|
|
5
|
+
import {
|
|
6
|
+
info,
|
|
7
|
+
shouldOutputJson,
|
|
8
|
+
successEnvelope,
|
|
9
|
+
writeOutput
|
|
10
|
+
} from "./chunk-FAFUYZQS.js";
|
|
11
|
+
import "./chunk-XQJ6PB2L.js";
|
|
12
|
+
import "./chunk-QMRVH5ZP.js";
|
|
13
|
+
|
|
14
|
+
// src/cli/tools.ts
|
|
15
|
+
async function loadToolCatalog() {
|
|
16
|
+
const { getCachedTools, setCachedTools } = await import("./cache-US4LSZPI.js");
|
|
17
|
+
const cached = getCachedTools();
|
|
18
|
+
if (cached) return cached;
|
|
19
|
+
const response = await fetchToolCatalog();
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
const msg = response.error && typeof response.error === "object" && "message" in response.error ? String(response.error.message) : "Failed to fetch tool catalog";
|
|
22
|
+
const { CliError } = await import("./errors-HRGXEUZR.js");
|
|
23
|
+
const { outputError } = await import("./output-6TJ3JTZ7.js");
|
|
24
|
+
await outputError(
|
|
25
|
+
new CliError("API_ERROR", msg, "Check: hive-mcp doctor"),
|
|
26
|
+
{}
|
|
27
|
+
);
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const data = response.data;
|
|
31
|
+
const tools = Array.isArray(data) ? data : data && typeof data === "object" && "tools" in data && Array.isArray(data.tools) ? data.tools : [];
|
|
32
|
+
setCachedTools(tools);
|
|
33
|
+
return tools;
|
|
34
|
+
}
|
|
35
|
+
async function listTools(opts) {
|
|
36
|
+
let tools = await loadToolCatalog();
|
|
37
|
+
if (opts.provider) {
|
|
38
|
+
const prefix = opts.provider.toLowerCase();
|
|
39
|
+
tools = tools.filter((t) => t.name.toLowerCase().startsWith(prefix + "_"));
|
|
40
|
+
}
|
|
41
|
+
if (opts.category) {
|
|
42
|
+
const { NAMESPACE } = await import("./namespace-GWTS6U6J.js");
|
|
43
|
+
const cat = opts.category.toLowerCase();
|
|
44
|
+
const ns = NAMESPACE.find(
|
|
45
|
+
(d) => d.name === cat || d.description.toLowerCase().includes(cat)
|
|
46
|
+
);
|
|
47
|
+
if (ns) {
|
|
48
|
+
const categoryTools = new Set(ns.commands.map((cmd) => cmd.tool));
|
|
49
|
+
tools = tools.filter((t) => categoryTools.has(t.name));
|
|
50
|
+
} else {
|
|
51
|
+
tools = tools.filter(
|
|
52
|
+
(t) => (t.provider ?? "").toLowerCase().includes(cat) || (t.name ?? "").toLowerCase().includes(cat)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const totalFiltered = tools.length;
|
|
57
|
+
const limit = Math.max(1, parseInt(opts.limit ?? "50", 10) || 50);
|
|
58
|
+
const offset = Math.max(0, parseInt(opts.offset ?? "0", 10) || 0);
|
|
59
|
+
tools = tools.slice(offset, offset + limit);
|
|
60
|
+
const items = tools.map((t) => ({
|
|
61
|
+
name: t.name,
|
|
62
|
+
title: t.title,
|
|
63
|
+
description: t.description && t.description.length > 120 ? t.description.slice(0, 117) + "..." : t.description
|
|
64
|
+
}));
|
|
65
|
+
const data = {
|
|
66
|
+
totalCount: totalFiltered,
|
|
67
|
+
offset,
|
|
68
|
+
limit,
|
|
69
|
+
showing: items.length,
|
|
70
|
+
tools: items
|
|
71
|
+
};
|
|
72
|
+
if (shouldOutputJson()) {
|
|
73
|
+
await writeOutput(successEnvelope(data, {}));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const { table } = await import("./format-4OIUGZKY.js");
|
|
77
|
+
const rangeStart = totalFiltered === 0 ? 0 : offset + 1;
|
|
78
|
+
const rangeEnd = offset + items.length;
|
|
79
|
+
info(`
|
|
80
|
+
Showing ${rangeStart}-${rangeEnd} of ${totalFiltered} tools
|
|
81
|
+
`);
|
|
82
|
+
info(
|
|
83
|
+
table(
|
|
84
|
+
["Name", "Title"],
|
|
85
|
+
items.map((t) => [t.name, t.title ?? ""])
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
async function searchTools(query) {
|
|
90
|
+
const allTools = await loadToolCatalog();
|
|
91
|
+
const q = query.toLowerCase();
|
|
92
|
+
const matches = allTools.filter(
|
|
93
|
+
(t) => t.name.toLowerCase().includes(q) || (t.description ?? "").toLowerCase().includes(q) || (t.title ?? "").toLowerCase().includes(q)
|
|
94
|
+
);
|
|
95
|
+
const items = matches.map((t) => ({
|
|
96
|
+
name: t.name,
|
|
97
|
+
title: t.title,
|
|
98
|
+
description: t.description && t.description.length > 120 ? t.description.slice(0, 117) + "..." : t.description
|
|
99
|
+
}));
|
|
100
|
+
const data = { totalCount: items.length, query, tools: items };
|
|
101
|
+
if (shouldOutputJson()) {
|
|
102
|
+
await writeOutput(successEnvelope(data, {}));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const { table } = await import("./format-4OIUGZKY.js");
|
|
106
|
+
info(`
|
|
107
|
+
${matches.length} matches for "${query}"
|
|
108
|
+
`);
|
|
109
|
+
if (matches.length === 0) {
|
|
110
|
+
info("No tools found. Try a broader search term.\n");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
info(
|
|
114
|
+
table(
|
|
115
|
+
["Name", "Title"],
|
|
116
|
+
matches.map((t) => [t.name, t.title ?? ""])
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
async function toolInfo(name) {
|
|
121
|
+
const allTools = await loadToolCatalog();
|
|
122
|
+
const tool = allTools.find((t2) => t2.name === name);
|
|
123
|
+
if (!tool) {
|
|
124
|
+
const { CliError, suggestSimilarTools } = await import("./errors-HRGXEUZR.js");
|
|
125
|
+
const { outputError } = await import("./output-6TJ3JTZ7.js");
|
|
126
|
+
const similar = suggestSimilarTools(
|
|
127
|
+
name,
|
|
128
|
+
allTools.map((t2) => t2.name)
|
|
129
|
+
);
|
|
130
|
+
const suggestion = similar.length > 0 ? `Did you mean: ${similar.join(", ")}?` : `Run: hive-mcp tools search "${name}"`;
|
|
131
|
+
await outputError(
|
|
132
|
+
new CliError("TOOL_NOT_FOUND", `Tool "${name}" not found`, suggestion),
|
|
133
|
+
{ tool: name }
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const t = tool;
|
|
137
|
+
const data = {
|
|
138
|
+
name: t.name,
|
|
139
|
+
title: t.title,
|
|
140
|
+
provider: t.provider ?? null,
|
|
141
|
+
readOnly: t.annotations?.readOnlyHint ?? null,
|
|
142
|
+
description: t.description,
|
|
143
|
+
inputSchema: t.inputSchema
|
|
144
|
+
};
|
|
145
|
+
if (shouldOutputJson()) {
|
|
146
|
+
await writeOutput(successEnvelope(data, { tool: name }));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
info(`
|
|
150
|
+
${t.title ?? t.name}`);
|
|
151
|
+
info(`Name: ${t.name}`);
|
|
152
|
+
if (t.provider) info(`Provider: ${t.provider}`);
|
|
153
|
+
info(`Read-only: ${t.annotations?.readOnlyHint ?? "unknown"}`);
|
|
154
|
+
info(`
|
|
155
|
+
Description:
|
|
156
|
+
${t.description}
|
|
157
|
+
`);
|
|
158
|
+
if (t.inputSchema) {
|
|
159
|
+
info("Input Schema:");
|
|
160
|
+
info(JSON.stringify(t.inputSchema, null, 2));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function refreshTools() {
|
|
164
|
+
const { clearCache } = await import("./cache-US4LSZPI.js");
|
|
165
|
+
const { info: printInfo } = await import("./output-6TJ3JTZ7.js");
|
|
166
|
+
clearCache();
|
|
167
|
+
printInfo("Cache cleared. Fetching fresh tool catalog...\n");
|
|
168
|
+
const tools = await loadToolCatalog();
|
|
169
|
+
printInfo(`${tools.length} tools loaded.
|
|
170
|
+
`);
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
listTools,
|
|
174
|
+
refreshTools,
|
|
175
|
+
searchTools,
|
|
176
|
+
toolInfo
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=tools-4W3GGCUC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/tools.ts"],"sourcesContent":["import {\n shouldOutputJson,\n writeOutput,\n successEnvelope,\n info,\n} from \"./output.js\";\nimport { fetchToolCatalog } from \"./api-client.js\";\n\ninterface ToolEntry {\n name: string;\n title?: string;\n description?: string;\n inputSchema?: unknown;\n annotations?: Record<string, unknown>;\n provider?: string;\n}\n\nasync function loadToolCatalog(): Promise<ToolEntry[]> {\n const { getCachedTools, setCachedTools } = await import(\"./cache.js\");\n const cached = getCachedTools();\n if (cached) return cached as ToolEntry[];\n\n const response = await fetchToolCatalog();\n if (!response.ok) {\n const msg =\n response.error &&\n typeof response.error === \"object\" &&\n \"message\" in response.error\n ? String(response.error.message)\n : \"Failed to fetch tool catalog\";\n const { CliError } = await import(\"./errors.js\");\n const { outputError } = await import(\"./output.js\");\n await outputError(\n new CliError(\"API_ERROR\", msg, \"Check: hive-mcp doctor\"),\n {},\n );\n return [];\n }\n const data = response.data as\n | { totalCount?: number; tools?: ToolEntry[] }\n | ToolEntry[];\n const tools = Array.isArray(data)\n ? data\n : data &&\n typeof data === \"object\" &&\n \"tools\" in data &&\n Array.isArray(data.tools)\n ? data.tools\n : [];\n\n setCachedTools(tools);\n return tools;\n}\n\nexport async function listTools(opts: {\n category?: string;\n provider?: string;\n limit?: string;\n offset?: string;\n}): Promise<void> {\n let tools = await loadToolCatalog();\n\n if (opts.provider) {\n const prefix = opts.provider.toLowerCase();\n tools = tools.filter((t) => t.name.toLowerCase().startsWith(prefix + \"_\"));\n }\n\n if (opts.category) {\n const { NAMESPACE } = await import(\"./namespace.js\");\n const cat = opts.category.toLowerCase();\n const ns = NAMESPACE.find(\n (d) => d.name === cat || d.description.toLowerCase().includes(cat),\n );\n if (ns) {\n const categoryTools = new Set(ns.commands.map((cmd) => cmd.tool));\n tools = tools.filter((t) => categoryTools.has(t.name));\n } else {\n // Fallback: substring match on name/provider for unknown categories\n tools = tools.filter(\n (t) =>\n (t.provider ?? \"\").toLowerCase().includes(cat) ||\n (t.name ?? \"\").toLowerCase().includes(cat),\n );\n }\n }\n\n const totalFiltered = tools.length;\n const limit = Math.max(1, parseInt(opts.limit ?? \"50\", 10) || 50);\n const offset = Math.max(0, parseInt(opts.offset ?? \"0\", 10) || 0);\n tools = tools.slice(offset, offset + limit);\n\n const items = tools.map((t) => ({\n name: t.name,\n title: t.title,\n description:\n t.description && t.description.length > 120\n ? t.description.slice(0, 117) + \"...\"\n : t.description,\n }));\n\n const data = {\n totalCount: totalFiltered,\n offset,\n limit,\n showing: items.length,\n tools: items,\n };\n\n if (shouldOutputJson()) {\n await writeOutput(successEnvelope(data, {}));\n return;\n }\n\n const { table } = await import(\"./format.js\");\n const rangeStart = totalFiltered === 0 ? 0 : offset + 1;\n const rangeEnd = offset + items.length;\n info(`\\nShowing ${rangeStart}-${rangeEnd} of ${totalFiltered} tools\\n`);\n info(\n table(\n [\"Name\", \"Title\"],\n items.map((t) => [t.name, t.title ?? \"\"]),\n ),\n );\n}\n\nexport async function searchTools(query: string): Promise<void> {\n const allTools = await loadToolCatalog();\n const q = query.toLowerCase();\n\n const matches = allTools.filter(\n (t) =>\n t.name.toLowerCase().includes(q) ||\n (t.description ?? \"\").toLowerCase().includes(q) ||\n (t.title ?? \"\").toLowerCase().includes(q),\n );\n\n const items = matches.map((t) => ({\n name: t.name,\n title: t.title,\n description:\n t.description && t.description.length > 120\n ? t.description.slice(0, 117) + \"...\"\n : t.description,\n }));\n\n const data = { totalCount: items.length, query, tools: items };\n\n if (shouldOutputJson()) {\n await writeOutput(successEnvelope(data, {}));\n return;\n }\n\n const { table } = await import(\"./format.js\");\n info(`\\n${matches.length} matches for \"${query}\"\\n`);\n if (matches.length === 0) {\n info(\"No tools found. Try a broader search term.\\n\");\n return;\n }\n info(\n table(\n [\"Name\", \"Title\"],\n matches.map((t) => [t.name, t.title ?? \"\"]),\n ),\n );\n}\n\nexport async function toolInfo(name: string): Promise<void> {\n const allTools = await loadToolCatalog();\n const tool = allTools.find((t) => t.name === name);\n\n if (!tool) {\n const { CliError, suggestSimilarTools } = await import(\"./errors.js\");\n const { outputError } = await import(\"./output.js\");\n const similar = suggestSimilarTools(\n name,\n allTools.map((t) => t.name),\n );\n const suggestion =\n similar.length > 0\n ? `Did you mean: ${similar.join(\", \")}?`\n : `Run: hive-mcp tools search \"${name}\"`;\n await outputError(\n new CliError(\"TOOL_NOT_FOUND\", `Tool \"${name}\" not found`, suggestion),\n { tool: name },\n );\n }\n\n // After outputError (which calls process.exit), this is unreachable,\n // but TypeScript doesn't know that. The non-null assertion is safe.\n const t = tool!;\n\n const data = {\n name: t.name,\n title: t.title,\n provider: t.provider ?? null,\n readOnly: t.annotations?.readOnlyHint ?? null,\n description: t.description,\n inputSchema: t.inputSchema,\n };\n\n if (shouldOutputJson()) {\n await writeOutput(successEnvelope(data, { tool: name }));\n return;\n }\n\n info(`\\n${t.title ?? t.name}`);\n info(`Name: ${t.name}`);\n if (t.provider) info(`Provider: ${t.provider}`);\n info(`Read-only: ${t.annotations?.readOnlyHint ?? \"unknown\"}`);\n info(`\\nDescription:\\n${t.description}\\n`);\n if (t.inputSchema) {\n info(\"Input Schema:\");\n info(JSON.stringify(t.inputSchema, null, 2));\n }\n}\n\nexport async function refreshTools(): Promise<void> {\n const { clearCache } = await import(\"./cache.js\");\n const { info: printInfo } = await import(\"./output.js\");\n clearCache();\n printInfo(\"Cache cleared. Fetching fresh tool catalog...\\n\");\n const tools = await loadToolCatalog();\n printInfo(`${tools.length} tools loaded.\\n`);\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,eAAe,kBAAwC;AACrD,QAAM,EAAE,gBAAgB,eAAe,IAAI,MAAM,OAAO,qBAAY;AACpE,QAAM,SAAS,eAAe;AAC9B,MAAI,OAAQ,QAAO;AAEnB,QAAM,WAAW,MAAM,iBAAiB;AACxC,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,MACJ,SAAS,SACT,OAAO,SAAS,UAAU,YAC1B,aAAa,SAAS,QAClB,OAAO,SAAS,MAAM,OAAO,IAC7B;AACN,UAAM,EAAE,SAAS,IAAI,MAAM,OAAO,sBAAa;AAC/C,UAAM,EAAE,YAAY,IAAI,MAAM,OAAO,sBAAa;AAClD,UAAM;AAAA,MACJ,IAAI,SAAS,aAAa,KAAK,wBAAwB;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO,CAAC;AAAA,EACV;AACA,QAAM,OAAO,SAAS;AAGtB,QAAM,QAAQ,MAAM,QAAQ,IAAI,IAC5B,OACA,QACE,OAAO,SAAS,YAChB,WAAW,QACX,MAAM,QAAQ,KAAK,KAAK,IACxB,KAAK,QACL,CAAC;AAEP,iBAAe,KAAK;AACpB,SAAO;AACT;AAEA,eAAsB,UAAU,MAKd;AAChB,MAAI,QAAQ,MAAM,gBAAgB;AAElC,MAAI,KAAK,UAAU;AACjB,UAAM,SAAS,KAAK,SAAS,YAAY;AACzC,YAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,KAAK,YAAY,EAAE,WAAW,SAAS,GAAG,CAAC;AAAA,EAC3E;AAEA,MAAI,KAAK,UAAU;AACjB,UAAM,EAAE,UAAU,IAAI,MAAM,OAAO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M,CAAC,CAAC;AAAA,EAC7C;AACF;AAEA,eAAsB,eAA8B;AAClD,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,qBAAY;AAChD,QAAM,EAAE,MAAM,UAAU,IAAI,MAAM,OAAO,sBAAa;AACtD,aAAW;AACX,YAAU,iDAAiD;AAC3D,QAAM,QAAQ,MAAM,gBAAgB;AACpC,YAAU,GAAG,MAAM,MAAM;AAAA,CAAkB;AAC7C;","names":["t"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
executeTool
|
|
4
|
+
} from "./chunk-N43VRMVB.js";
|
|
5
|
+
import "./chunk-WKVZVQTG.js";
|
|
6
|
+
import "./chunk-LBTLYTZS.js";
|
|
7
|
+
import "./chunk-FAFUYZQS.js";
|
|
8
|
+
import "./chunk-XQJ6PB2L.js";
|
|
9
|
+
import "./chunk-QMRVH5ZP.js";
|
|
10
|
+
|
|
11
|
+
// src/cli/watch.ts
|
|
12
|
+
var MAX_CONSECUTIVE_FAILURES = 10;
|
|
13
|
+
async function runWatch(toolName, args, intervalSec, timeoutMs) {
|
|
14
|
+
process.stderr.write(
|
|
15
|
+
`Watching ${toolName} every ${intervalSec}s (Ctrl+C to stop)
|
|
16
|
+
|
|
17
|
+
`
|
|
18
|
+
);
|
|
19
|
+
let consecutiveFailures = 0;
|
|
20
|
+
let timer = null;
|
|
21
|
+
const run = async () => {
|
|
22
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
23
|
+
process.stderr.write(`\u2500\u2500 ${timestamp} \u2500\u2500
|
|
24
|
+
`);
|
|
25
|
+
try {
|
|
26
|
+
await executeTool(toolName, args, timeoutMs);
|
|
27
|
+
consecutiveFailures = 0;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
consecutiveFailures++;
|
|
30
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
31
|
+
process.stderr.write(
|
|
32
|
+
` Error (${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}): ${msg}
|
|
33
|
+
`
|
|
34
|
+
);
|
|
35
|
+
if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
|
|
36
|
+
process.stderr.write(
|
|
37
|
+
`
|
|
38
|
+
Aborting watch: ${MAX_CONSECUTIVE_FAILURES} consecutive failures.
|
|
39
|
+
`
|
|
40
|
+
);
|
|
41
|
+
process.exit(4);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
process.stderr.write("\n");
|
|
45
|
+
const backoffMultiplier = Math.min(Math.pow(2, consecutiveFailures), 5);
|
|
46
|
+
const nextInterval = consecutiveFailures > 0 ? intervalSec * backoffMultiplier : intervalSec;
|
|
47
|
+
if (consecutiveFailures > 0) {
|
|
48
|
+
process.stderr.write(` Backing off: next poll in ${nextInterval}s
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
timer = setTimeout(run, nextInterval * 1e3);
|
|
52
|
+
};
|
|
53
|
+
await run();
|
|
54
|
+
const cleanup = () => {
|
|
55
|
+
if (timer) clearTimeout(timer);
|
|
56
|
+
process.stderr.write("\nWatch stopped.\n");
|
|
57
|
+
process.exit(0);
|
|
58
|
+
};
|
|
59
|
+
process.on("SIGINT", cleanup);
|
|
60
|
+
process.on("SIGTERM", cleanup);
|
|
61
|
+
await new Promise(() => {
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
runWatch
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=watch-P2QWGFYV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/watch.ts"],"sourcesContent":["import { executeTool } from \"./execute.js\";\n\nconst MAX_CONSECUTIVE_FAILURES = 10;\n\nexport async function runWatch(\n toolName: string,\n args: Record<string, unknown>,\n intervalSec: number,\n timeoutMs: number,\n): Promise<void> {\n process.stderr.write(\n `Watching ${toolName} every ${intervalSec}s (Ctrl+C to stop)\\n\\n`,\n );\n\n let consecutiveFailures = 0;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n const run = async () => {\n const timestamp = new Date().toISOString().replace(\"T\", \" \").slice(0, 19);\n process.stderr.write(`── ${timestamp} ──\\n`);\n try {\n await executeTool(toolName, args, timeoutMs);\n consecutiveFailures = 0;\n } catch (err) {\n consecutiveFailures++;\n const msg = err instanceof Error ? err.message : String(err);\n process.stderr.write(\n ` Error (${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}): ${msg}\\n`,\n );\n\n if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {\n process.stderr.write(\n `\\nAborting watch: ${MAX_CONSECUTIVE_FAILURES} consecutive failures.\\n`,\n );\n process.exit(4);\n }\n }\n process.stderr.write(\"\\n\");\n\n // Exponential backoff on consecutive failures: double interval per failure, cap at 5x\n const backoffMultiplier = Math.min(Math.pow(2, consecutiveFailures), 5);\n const nextInterval =\n consecutiveFailures > 0 ? intervalSec * backoffMultiplier : intervalSec;\n\n if (consecutiveFailures > 0) {\n process.stderr.write(` Backing off: next poll in ${nextInterval}s\\n`);\n }\n\n timer = setTimeout(run, nextInterval * 1000);\n };\n\n await run();\n\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n process.stderr.write(\"\\nWatch stopped.\\n\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n await new Promise(() => {});\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAM,2BAA2B;AAEjC,eAAsB,SACpB,UACA,MACA,aACA,WACe;AACf,UAAQ,OAAO;AAAA,IACb,YAAY,QAAQ,UAAU,WAAW;AAAA;AAAA;AAAA,EAC3C;AAEA,MAAI,sBAAsB;AAC1B,MAAI,QAA8C;AAElD,QAAM,MAAM,YAAY;AACtB,UAAM,aAAY,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.0",
|
|
4
|
+
"description": "MCP server and CLI for Hive Intelligence — crypto, DeFi, stocks, forex, and macro data",
|
|
5
|
+
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"
|
|
7
|
+
"build": "tsup && chmod 755 build/server.js build/cli.js",
|
|
8
|
+
"prepare": "npm run build",
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"inspector": "npx @modelcontextprotocol/inspector node build/server.js",
|
|
11
|
+
"start": "node build/server.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"crypto",
|
|
17
|
+
"defi",
|
|
18
|
+
"blockchain",
|
|
19
|
+
"stocks",
|
|
20
|
+
"forex",
|
|
21
|
+
"financial-data",
|
|
22
|
+
"ai-tools",
|
|
23
|
+
"cli"
|
|
24
|
+
],
|
|
25
|
+
"author": "Hive Intelligence",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/hive-intel/hive-crypto-mcp"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://hiveintelligence.xyz",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20.0.0"
|
|
9
34
|
},
|
|
10
|
-
"keywords": [],
|
|
11
|
-
"author": "",
|
|
12
|
-
"description": "",
|
|
13
35
|
"dependencies": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
36
|
+
"@cloudflare/cabidela": "^0.2.4",
|
|
37
|
+
"@modelcontextprotocol/sdk": "1.13.0",
|
|
38
|
+
"commander": "^14.0.3",
|
|
39
|
+
"cors": "^2.8.5",
|
|
40
|
+
"dotenv": "^16.5.0",
|
|
41
|
+
"express": "^5.1.0",
|
|
42
|
+
"fastest-levenshtein": "^1.0.16",
|
|
43
|
+
"ora": "8"
|
|
16
44
|
},
|
|
17
45
|
"devDependencies": {
|
|
18
|
-
"@types/
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
46
|
+
"@types/cors": "^2.8.17",
|
|
47
|
+
"@types/express": "^5.0.3",
|
|
48
|
+
"@types/node": "^20.0.0",
|
|
49
|
+
"tsup": "^8.5.0",
|
|
50
|
+
"tsx": "^4.0.0",
|
|
51
|
+
"typescript": "^5.8.3",
|
|
52
|
+
"winston": "^3.11.0"
|
|
53
|
+
},
|
|
54
|
+
"bin": {
|
|
55
|
+
"hive-intelligence": "./build/server.js",
|
|
56
|
+
"hive": "./bin/hive.js"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"bin/**/*",
|
|
60
|
+
"build/**/*",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE"
|
|
63
|
+
]
|
|
23
64
|
}
|
package/.env,example
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
HIVE_API_KEY=
|
package/dist/client.d.ts
DELETED
package/dist/client.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/client.ts
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.HiveSearchClient = void 0;
|
|
17
|
-
const axios_1 = __importDefault(require("axios"));
|
|
18
|
-
const errors_1 = require("./errors");
|
|
19
|
-
class HiveSearchClient {
|
|
20
|
-
constructor(apiKey) {
|
|
21
|
-
this.baseUrl = 'https://api.hiveintelligence.xyz/v1/search';
|
|
22
|
-
this.apiKey = apiKey;
|
|
23
|
-
}
|
|
24
|
-
search(params) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const response = yield axios_1.default.post(this.baseUrl, params, {
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
return response.data;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error.response) {
|
|
37
|
-
// Extracting error details from the API response
|
|
38
|
-
const errorMessage = error.response.data.error || error.response.data.message || 'Unknown error';
|
|
39
|
-
// Throwing the custom error with the extracted message
|
|
40
|
-
throw new errors_1.HiveSearchAPIError(error.response.status, error.response.statusText, error.response.data, // Body of the response
|
|
41
|
-
errorMessage // Message from the response
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
// If no response was received, throw a general error
|
|
46
|
-
throw new Error('Unknown error occurred while calling HiveSearch API');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.HiveSearchClient = HiveSearchClient;
|
package/dist/errors.d.ts
DELETED
package/dist/errors.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HiveSearchAPIError = void 0;
|
|
4
|
-
class HiveSearchAPIError extends Error {
|
|
5
|
-
constructor(status, statusText, body, message // Add message to hold the specific error details
|
|
6
|
-
) {
|
|
7
|
-
super(`HiveSearch API Error: ${status} ${statusText} - ${message}`);
|
|
8
|
-
this.status = status;
|
|
9
|
-
this.statusText = statusText;
|
|
10
|
-
this.body = body;
|
|
11
|
-
this.message = message;
|
|
12
|
-
this.name = 'HiveSearchAPIError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.HiveSearchAPIError = HiveSearchAPIError;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/index.ts
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./client"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
20
|
-
__exportStar(require("./errors"), exports);
|
package/dist/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface HiveSearchMessage {
|
|
2
|
-
role: 'user' | 'assistant';
|
|
3
|
-
content: string;
|
|
4
|
-
}
|
|
5
|
-
export interface HiveSearchRequest {
|
|
6
|
-
prompt?: string;
|
|
7
|
-
messages?: HiveSearchMessage[];
|
|
8
|
-
temperature?: number;
|
|
9
|
-
top_k?: number;
|
|
10
|
-
top_p?: number;
|
|
11
|
-
include_data_sources?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface HiveSearchResponse {
|
|
14
|
-
response: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
isAdditionalDataRequired: [] | null;
|
|
18
|
-
data_sources?: string[];
|
|
19
|
-
}
|
package/dist/types.js
DELETED
package/example.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { HiveSearchClient } from './dist/client'
|
|
2
|
-
import { HiveSearchRequest, HiveSearchMessage, HiveSearchResponse } from './dist/types'
|
|
3
|
-
import { config } from 'dotenv';
|
|
4
|
-
config();
|
|
5
|
-
|
|
6
|
-
// Get API key from env
|
|
7
|
-
const apiKey = process.env.HIVE_API_KEY;
|
|
8
|
-
if (!apiKey) {
|
|
9
|
-
throw new Error('Please set the HIVE_API_KEY environment variable');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Initialize client
|
|
13
|
-
const client = new HiveSearchClient(apiKey);
|
|
14
|
-
|
|
15
|
-
// 🟡 Example 1: Prompt-based query
|
|
16
|
-
const promptRequest: HiveSearchRequest = {
|
|
17
|
-
prompt: 'What is the current price of Ethereum?'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
client.search(promptRequest).then((response: HiveSearchResponse) => {
|
|
21
|
-
console.log('Prompt Response:', response);
|
|
22
|
-
}).catch(console.error);
|
|
23
|
-
|
|
24
|
-
// 🟢 Example 2: Chat-style query
|
|
25
|
-
const chatRequest: HiveSearchRequest = {
|
|
26
|
-
messages: [
|
|
27
|
-
{ role: 'user', content: 'Price of' },
|
|
28
|
-
{ role: 'assistant', content: 'Price of what?' },
|
|
29
|
-
{ role: 'user', content: 'BTC' }
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
client.search(chatRequest).then((response: HiveSearchResponse) => {
|
|
34
|
-
console.log('Chat Response:', response);
|
|
35
|
-
}).catch(console.error);
|
package/jest.config.js
DELETED
package/src/client.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/client.ts
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.HiveSearchClient = void 0;
|
|
17
|
-
const axios_1 = __importDefault(require("axios"));
|
|
18
|
-
const errors_1 = require("./errors");
|
|
19
|
-
class HiveSearchClient {
|
|
20
|
-
constructor(apiKey) {
|
|
21
|
-
this.baseUrl = 'https://api.hiveintelligence.xyz/v1/search';
|
|
22
|
-
this.apiKey = apiKey;
|
|
23
|
-
}
|
|
24
|
-
search(params) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const response = yield axios_1.default.post(this.baseUrl, params, {
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
return response.data;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error.response) {
|
|
37
|
-
// Extracting error details from the API response
|
|
38
|
-
const errorMessage = error.response.data.error || error.response.data.message || 'Unknown error';
|
|
39
|
-
// Throwing the custom error with the extracted message
|
|
40
|
-
throw new errors_1.HiveSearchAPIError(error.response.status, error.response.statusText, error.response.data, // Body of the response
|
|
41
|
-
errorMessage // Message from the response
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
// If no response was received, throw a general error
|
|
46
|
-
throw new Error('Unknown error occurred while calling HiveSearch API');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.HiveSearchClient = HiveSearchClient;
|