@gonzih/cc-discord 0.2.0 → 0.2.1
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 +5 -1
- package/dist/meta-agent-manager.js +22 -4
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -1063,7 +1063,7 @@ export class CcDiscordBot {
|
|
|
1063
1063
|
startMetaAgentPolling() {
|
|
1064
1064
|
if (!this.wire)
|
|
1065
1065
|
return;
|
|
1066
|
-
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values())
|
|
1066
|
+
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values()));
|
|
1067
1067
|
}
|
|
1068
1068
|
stop() {
|
|
1069
1069
|
for (const [key, session] of this.sessions) {
|
|
@@ -36,10 +36,14 @@ export declare function injectMcp(ns: string, wsPath: string, token: string): vo
|
|
|
36
36
|
* Returns a Promise that resolves when the process exits.
|
|
37
37
|
*/
|
|
38
38
|
export declare function spawnSession(ns: string, message: string, token: string, wire: Wire): Promise<void>;
|
|
39
|
+
export interface NamespaceEntry {
|
|
40
|
+
namespace: string;
|
|
41
|
+
repoUrl: string;
|
|
42
|
+
}
|
|
39
43
|
export interface MetaAgentManager {
|
|
40
44
|
ensureWorkspace: (ns: string, repoUrl: string) => Promise<void>;
|
|
41
45
|
injectMcp: (ns: string, token: string) => void;
|
|
42
|
-
startPolling: (wire: Wire,
|
|
46
|
+
startPolling: (wire: Wire, getNamespaceEntries: () => NamespaceEntry[]) => void;
|
|
43
47
|
stop: () => void;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
@@ -183,14 +183,14 @@ export function createMetaAgentManager() {
|
|
|
183
183
|
const wsPath = workspacePath(ns);
|
|
184
184
|
injectMcp(ns, wsPath, token);
|
|
185
185
|
},
|
|
186
|
-
startPolling(wire,
|
|
186
|
+
startPolling(wire, getNamespaceEntries) {
|
|
187
187
|
if (pollInterval)
|
|
188
188
|
return; // already running
|
|
189
189
|
pollInterval = setInterval(() => {
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
190
|
+
const entries = getNamespaceEntries();
|
|
191
|
+
if (entries.length === 0)
|
|
192
192
|
return;
|
|
193
|
-
for (const ns of
|
|
193
|
+
for (const { namespace: ns, repoUrl } of entries) {
|
|
194
194
|
if (activeNamespaces.has(ns))
|
|
195
195
|
continue;
|
|
196
196
|
wire.discord.dequeue(ns)
|
|
@@ -228,6 +228,24 @@ export function createMetaAgentManager() {
|
|
|
228
228
|
});
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
+
// Ensure workspace exists before spawning — clone happens once, no-op on repeat.
|
|
232
|
+
try {
|
|
233
|
+
await ensureWorkspace(ns, repoUrl);
|
|
234
|
+
injectMcp(ns, workspacePath(ns), token);
|
|
235
|
+
}
|
|
236
|
+
catch (wsErr) {
|
|
237
|
+
const msg = wsErr instanceof Error ? wsErr.message : String(wsErr);
|
|
238
|
+
console.error(`[meta-agent-manager] workspace setup failed (ns=${ns}):`, msg);
|
|
239
|
+
activeNamespaces.delete(ns);
|
|
240
|
+
await wire.discord.setStatus(ns, {
|
|
241
|
+
namespace: ns,
|
|
242
|
+
status: "idle",
|
|
243
|
+
isTyping: false,
|
|
244
|
+
turnCount: 0,
|
|
245
|
+
updatedAt: new Date().toISOString(),
|
|
246
|
+
}).catch(() => { });
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
231
249
|
spawnSession(ns, content, token, wire)
|
|
232
250
|
.catch((err) => {
|
|
233
251
|
console.error(`[meta-agent-manager] session error (ns=${ns}):`, err.message);
|