@noelclaw/mcp 1.5.5 → 1.5.7
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/tools/insight.js +43 -2
- package/dist/tools/swarm.js +17 -46
- package/package.json +1 -1
package/dist/tools/insight.js
CHANGED
|
@@ -30,16 +30,57 @@ const AskNoelSchema = zod_1.z.object({
|
|
|
30
30
|
question: zod_1.z.string().min(1),
|
|
31
31
|
messages: zod_1.z.array(zod_1.z.object({ role: zod_1.z.enum(["user", "assistant"]), content: zod_1.z.string() })).optional(),
|
|
32
32
|
});
|
|
33
|
+
const BANKR_LLM_URL = "https://llm.bankr.bot/v1/chat/completions";
|
|
34
|
+
const BANKR_MODEL = process.env.BANKR_MODEL ?? "grok-3";
|
|
35
|
+
const NOEL_SYSTEM_PROMPT = `You are Noel, a crypto AI analyst with deep expertise in DeFi, on-chain data, market structure, and trading psychology. You provide sharp, direct analysis — no fluff, no disclaimers. You understand narratives, liquidity flows, whale behavior, and how sentiment drives price. When asked about a token or market, give your honest read with supporting reasoning.`;
|
|
36
|
+
async function askViaBankr(question, messages) {
|
|
37
|
+
const res = await fetch(BANKR_LLM_URL, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"X-API-Key": process.env.BANKR_API_KEY,
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
model: BANKR_MODEL,
|
|
45
|
+
messages: [
|
|
46
|
+
{ role: "system", content: NOEL_SYSTEM_PROMPT },
|
|
47
|
+
...messages,
|
|
48
|
+
{ role: "user", content: question },
|
|
49
|
+
],
|
|
50
|
+
max_tokens: 1024,
|
|
51
|
+
}),
|
|
52
|
+
signal: AbortSignal.timeout(30000),
|
|
53
|
+
});
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
const err = await res.text().catch(() => res.statusText);
|
|
56
|
+
throw new Error(`Bankr LLM error ${res.status}: ${err.slice(0, 200)}`);
|
|
57
|
+
}
|
|
58
|
+
const data = await res.json();
|
|
59
|
+
return data.choices?.[0]?.message?.content ?? "No response from model";
|
|
60
|
+
}
|
|
33
61
|
async function handleInsightTool(name, args) {
|
|
34
62
|
if (name !== "ask_noel")
|
|
35
63
|
return null;
|
|
36
64
|
const parsed = AskNoelSchema.safeParse(args);
|
|
37
65
|
if (!parsed.success)
|
|
38
66
|
return { content: [{ type: "text", text: `Invalid input: question ${parsed.error.issues[0].message}` }], isError: true };
|
|
67
|
+
const { question, messages = [] } = parsed.data;
|
|
68
|
+
// If BANKR_API_KEY is set, call Bankr LLM directly — faster, no Convex hop
|
|
69
|
+
if (process.env.BANKR_API_KEY) {
|
|
70
|
+
try {
|
|
71
|
+
const answer = await askViaBankr(question, messages);
|
|
72
|
+
return { content: [{ type: "text", text: answer }] };
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
// Fall through to Convex if Bankr call fails
|
|
76
|
+
console.error(`Bankr LLM failed, falling back to Convex: ${err.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Fallback: route through Convex backend
|
|
39
80
|
const data = await (0, convex_js_1.callConvex)("/mcp/chat", "POST", {
|
|
40
|
-
question
|
|
81
|
+
question,
|
|
41
82
|
agentId: "noel-default",
|
|
42
|
-
messages
|
|
83
|
+
messages,
|
|
43
84
|
}, "ask_noel");
|
|
44
85
|
return { content: [{ type: "text", text: data.answer ?? JSON.stringify(data) }] };
|
|
45
86
|
}
|
package/dist/tools/swarm.js
CHANGED
|
@@ -94,29 +94,18 @@ async function handleSwarmTool(name, args) {
|
|
|
94
94
|
(0, convex_js_1.callConvex)("/swarm/memory/write", "POST", { agentId: "market-monitor", key: "sol_price", value: priceOnly(snapshot.sol) }, "write_swarm_memory"),
|
|
95
95
|
]);
|
|
96
96
|
}
|
|
97
|
-
const fmtChange = (n) => `${n >= 0 ? "+" : ""}${n.toFixed(1)}%`;
|
|
98
|
-
const arrow = (n) => n >= 0 ? "▲" : "▼";
|
|
99
97
|
const p = (n) => `$${n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
100
|
-
const marketLines = snapshot ? [
|
|
101
|
-
``,
|
|
102
|
-
`📡 **Market Snapshot**`,
|
|
103
|
-
`| Asset | Price | 24h |`,
|
|
104
|
-
`|-------|-------|-----|`,
|
|
105
|
-
`| BTC | ${p(snapshot.btc)} | ${arrow(snapshot.btcChange)} ${fmtChange(snapshot.btcChange)} |`,
|
|
106
|
-
`| ETH | ${p(snapshot.eth)} | ${arrow(snapshot.ethChange)} ${fmtChange(snapshot.ethChange)} |`,
|
|
107
|
-
`| SOL | ${p(snapshot.sol)} | ${arrow(snapshot.solChange)} ${fmtChange(snapshot.solChange)} |`,
|
|
108
|
-
] : [];
|
|
109
98
|
return {
|
|
110
99
|
content: [{
|
|
111
100
|
type: "text",
|
|
112
101
|
text: [
|
|
113
|
-
`🤖 **Swarm
|
|
114
|
-
`Session:
|
|
115
|
-
`Started: ${
|
|
116
|
-
|
|
102
|
+
`🤖 **Swarm Started**`,
|
|
103
|
+
`Session ID: ${data.sessionId}`,
|
|
104
|
+
`Started at: ${data.startedAt}`,
|
|
105
|
+
snapshot ? `Market: BTC ${p(snapshot.btc)} | ETH ${p(snapshot.eth)} | SOL ${p(snapshot.sol)}` : "",
|
|
117
106
|
``,
|
|
118
|
-
`Use \`
|
|
119
|
-
].join("\n"),
|
|
107
|
+
`Use \`get_swarm_status\` to monitor, \`stop_swarm\` to stop.`,
|
|
108
|
+
].filter(Boolean).join("\n"),
|
|
120
109
|
}],
|
|
121
110
|
};
|
|
122
111
|
}
|
|
@@ -134,41 +123,23 @@ async function handleSwarmTool(name, args) {
|
|
|
134
123
|
const memory = data.memory ?? [];
|
|
135
124
|
const scores = data.scores ?? [];
|
|
136
125
|
const lines = [
|
|
137
|
-
`🤖 **Swarm Status
|
|
138
|
-
data.active && session ? `Session:
|
|
126
|
+
`🤖 **Swarm Status**`,
|
|
127
|
+
data.active && session ? `Status: active | Session: ${session.id}` : `No active swarm.`,
|
|
139
128
|
``,
|
|
140
129
|
];
|
|
141
130
|
if (memory.length > 0) {
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
for (const m of marketEntries) {
|
|
149
|
-
const val = m.value.split(" (")[0]; // strip timestamp
|
|
150
|
-
lines.push(` ${m.key.padEnd(7)} ${val}`);
|
|
151
|
-
}
|
|
152
|
-
lines.push("");
|
|
153
|
-
}
|
|
154
|
-
if (otherEntries.length > 0) {
|
|
155
|
-
lines.push(`🧠 **Agent Memory** (${otherEntries.length} entries)`);
|
|
156
|
-
for (const m of otherEntries.slice(0, 6)) {
|
|
157
|
-
lines.push(` [${m.agentId}] **${m.key}**: ${String(m.value).slice(0, 80)}`);
|
|
158
|
-
}
|
|
159
|
-
if (otherEntries.length > 6)
|
|
160
|
-
lines.push(` …and ${otherEntries.length - 6} more`);
|
|
161
|
-
lines.push("");
|
|
162
|
-
}
|
|
131
|
+
lines.push(`**Shared Memory** (${memory.length} entries)`);
|
|
132
|
+
for (const m of memory.slice(0, 5))
|
|
133
|
+
lines.push(`• [${m.agentId}] ${m.key}: ${m.value.slice(0, 80)}`);
|
|
134
|
+
if (memory.length > 5)
|
|
135
|
+
lines.push(` …and ${memory.length - 5} more`);
|
|
136
|
+
lines.push("");
|
|
163
137
|
}
|
|
164
138
|
if (scores.length > 0) {
|
|
165
|
-
lines.push(
|
|
139
|
+
lines.push(`**Execution Scores** (top skills)`);
|
|
166
140
|
const sorted = scores.sort((a, b) => b.lastScore - a.lastScore).slice(0, 5);
|
|
167
|
-
for (const s of sorted)
|
|
168
|
-
|
|
169
|
-
const bar = "█".repeat(Math.round(s.lastScore * 10)) + "░".repeat(10 - Math.round(s.lastScore * 10));
|
|
170
|
-
lines.push(` ${bar} ${pct}% ${s.skillName} (${s.successCount}W / ${s.failCount}L)`);
|
|
171
|
-
}
|
|
141
|
+
for (const s of sorted)
|
|
142
|
+
lines.push(`• ${s.skillName}: ${(s.lastScore * 100).toFixed(0)}% | ${s.successCount}W/${s.failCount}L | avg ${Math.round(s.avgDurationMs / 1000)}s`);
|
|
172
143
|
}
|
|
173
144
|
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
174
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noelclaw/mcp",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Noelclaw as an MCP skill — persistent memory, multi-agent coordination, scenario simulation, DeFi execution, and Sentinel-gated playbooks.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|