@tini-works/inv-node 0.1.8 → 0.1.10
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/dist/cli.js +26 -17
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1357,22 +1357,6 @@ class WSHandlers {
|
|
|
1357
1357
|
askerNode: envelope.fromNode,
|
|
1358
1358
|
question: payload.question
|
|
1359
1359
|
});
|
|
1360
|
-
if (this.sendFn) {
|
|
1361
|
-
const nodes = this.store.listNodes(envelope.projectId);
|
|
1362
|
-
const allItems = nodes.flatMap((n) => this.store.listItems(n.id));
|
|
1363
|
-
const summary = allItems.map((i) => ({
|
|
1364
|
-
id: i.id,
|
|
1365
|
-
kind: i.kind,
|
|
1366
|
-
title: i.title,
|
|
1367
|
-
state: i.state,
|
|
1368
|
-
externalRef: i.externalRef || undefined
|
|
1369
|
-
}));
|
|
1370
|
-
this.sendFn(envelope.fromNode, {
|
|
1371
|
-
type: "query_respond",
|
|
1372
|
-
answer: JSON.stringify({ items: summary, count: summary.length }),
|
|
1373
|
-
responderId: payload.askerId
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
1360
|
} catch (err) {
|
|
1377
1361
|
const message = err instanceof Error ? err.message : String(err);
|
|
1378
1362
|
this.eventBus.emit("error", {
|
|
@@ -1750,10 +1734,18 @@ var TOOL_DEFINITIONS = [
|
|
|
1750
1734
|
},
|
|
1751
1735
|
required: ["itemId"]
|
|
1752
1736
|
}
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
name: "inv_online_nodes",
|
|
1740
|
+
description: "List all other nodes currently online in this project. Use this to discover who you can communicate with.",
|
|
1741
|
+
inputSchema: {
|
|
1742
|
+
type: "object",
|
|
1743
|
+
properties: {}
|
|
1744
|
+
}
|
|
1753
1745
|
}
|
|
1754
1746
|
];
|
|
1755
1747
|
function buildToolHandlers(engine, config, wsClient) {
|
|
1756
|
-
return (name, args) => {
|
|
1748
|
+
return async (name, args) => {
|
|
1757
1749
|
const text = (s) => ({
|
|
1758
1750
|
content: [{ type: "text", text: s }]
|
|
1759
1751
|
});
|
|
@@ -1933,6 +1925,23 @@ function buildToolHandlers(engine, config, wsClient) {
|
|
|
1933
1925
|
const items = engine.listChecklist(args.itemId ?? "");
|
|
1934
1926
|
return text(JSON.stringify(items, null, 2));
|
|
1935
1927
|
}
|
|
1928
|
+
case "inv_online_nodes": {
|
|
1929
|
+
if (!config.server.url || !config.server.token) {
|
|
1930
|
+
return text(JSON.stringify({ error: "Not configured for network" }));
|
|
1931
|
+
}
|
|
1932
|
+
const httpUrl = config.server.url.replace(/^ws/, "http").replace(/\/ws$/, "/api/online");
|
|
1933
|
+
const res = await fetch(`${httpUrl}?token=${config.server.token}`);
|
|
1934
|
+
if (!res.ok) {
|
|
1935
|
+
const err = await res.json();
|
|
1936
|
+
return text(JSON.stringify({ error: err.error ?? `HTTP ${res.status}` }));
|
|
1937
|
+
}
|
|
1938
|
+
const data = await res.json();
|
|
1939
|
+
return text(JSON.stringify({
|
|
1940
|
+
project: data.project,
|
|
1941
|
+
onlineNodes: data.nodes,
|
|
1942
|
+
count: data.nodes.length
|
|
1943
|
+
}, null, 2));
|
|
1944
|
+
}
|
|
1936
1945
|
default:
|
|
1937
1946
|
return text(JSON.stringify({ error: `Unknown tool: ${name}` }));
|
|
1938
1947
|
}
|