@gonzih/cc-discord 0.2.12 → 0.2.14
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/bot.js +1 -1
- package/dist/meta-agent-manager.d.ts +4 -1
- package/dist/meta-agent-manager.js +6 -1
- package/dist/notifier.js +8 -7
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -1293,7 +1293,7 @@ export class CcDiscordBot {
|
|
|
1293
1293
|
startMetaAgentPolling() {
|
|
1294
1294
|
if (!this.wire)
|
|
1295
1295
|
return;
|
|
1296
|
-
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values())
|
|
1296
|
+
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values()));
|
|
1297
1297
|
}
|
|
1298
1298
|
stop() {
|
|
1299
1299
|
for (const [key, session] of this.sessions) {
|
|
@@ -39,7 +39,10 @@ export declare function spawnSession(ns: string, message: string, token: string,
|
|
|
39
39
|
export interface MetaAgentManager {
|
|
40
40
|
ensureWorkspace: (ns: string, repoUrl: string) => Promise<void>;
|
|
41
41
|
injectMcp: (ns: string, token: string) => void;
|
|
42
|
-
startPolling: (wire: Wire, getNamespaces: () =>
|
|
42
|
+
startPolling: (wire: Wire, getNamespaces: () => Array<{
|
|
43
|
+
namespace: string;
|
|
44
|
+
repoUrl: string;
|
|
45
|
+
}>) => void;
|
|
43
46
|
stop: () => void;
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
@@ -190,7 +190,7 @@ export function createMetaAgentManager() {
|
|
|
190
190
|
const namespaces = getNamespaces();
|
|
191
191
|
if (namespaces.length === 0)
|
|
192
192
|
return;
|
|
193
|
-
for (const ns of namespaces) {
|
|
193
|
+
for (const { namespace: ns, repoUrl } of namespaces) {
|
|
194
194
|
if (activeNamespaces.has(ns))
|
|
195
195
|
continue;
|
|
196
196
|
wire.discord.dequeue(ns)
|
|
@@ -228,6 +228,11 @@ export function createMetaAgentManager() {
|
|
|
228
228
|
});
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
+
// Ensure the workspace directory exists — idempotent if already cloned.
|
|
232
|
+
// This guards against the workspace being absent after a bot restart.
|
|
233
|
+
const wsPath = workspacePath(ns);
|
|
234
|
+
await ensureWorkspace(ns, repoUrl);
|
|
235
|
+
injectMcp(ns, wsPath, token);
|
|
231
236
|
spawnSession(ns, content, token, wire)
|
|
232
237
|
.catch((err) => {
|
|
233
238
|
console.error(`[meta-agent-manager] session error (ns=${ns}):`, err.message);
|
package/dist/notifier.js
CHANGED
|
@@ -47,13 +47,12 @@ export function parseNotification(raw) {
|
|
|
47
47
|
let isCron = false;
|
|
48
48
|
try {
|
|
49
49
|
const parsed = JSON.parse(raw);
|
|
50
|
-
// Drop cron-fire pings (⏰ …) — job completion notifications (✅/❌) still pass through
|
|
51
|
-
if (parsed.is_cron === true && parsed.text?.startsWith("⏰"))
|
|
52
|
-
return null;
|
|
53
50
|
// routing: absent/empty → all transports; non-empty → only listed transports
|
|
54
51
|
if (parsed.routing && parsed.routing.length > 0 && !parsed.routing.includes("discord")) {
|
|
55
52
|
return null;
|
|
56
53
|
}
|
|
54
|
+
if (parsed.is_cron === true)
|
|
55
|
+
return null;
|
|
57
56
|
if (parsed.text)
|
|
58
57
|
text = parsed.text;
|
|
59
58
|
driver = parsed.driver;
|
|
@@ -211,12 +210,14 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
|
|
|
211
210
|
const buf = metaAgentBuffers.get(ns);
|
|
212
211
|
if (!buf || !buf.text.trim())
|
|
213
212
|
return;
|
|
214
|
-
const
|
|
213
|
+
const text = `← [${ns}] ` + stripAnsi(buf.text.trim());
|
|
214
|
+
if (text.length < 30) {
|
|
215
|
+
buf.text = "";
|
|
216
|
+
buf.timer = null;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
215
219
|
buf.text = "";
|
|
216
220
|
buf.timer = null;
|
|
217
|
-
if (rawText.length < 20)
|
|
218
|
-
return;
|
|
219
|
-
const text = `← [${ns}] ` + rawText;
|
|
220
221
|
// During an active loop, route meta-agent output to the thread rather than main channel
|
|
221
222
|
const deliverTo = bot.getLoopThreadId(targetChannelId) ?? targetChannelId;
|
|
222
223
|
const chunks = splitLongMessage(text);
|