@gonzih/cc-tg 0.9.38 → 0.9.39
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/router.js +11 -4
- package/package.json +1 -1
package/dist/router.js
CHANGED
|
@@ -58,13 +58,16 @@ export function parseRoutingTag(text) {
|
|
|
58
58
|
export async function ensureMetaAgent(namespace, repoUrl, callTool, redis) {
|
|
59
59
|
const timeoutMs = parseInt(process.env.META_AGENT_TIMEOUT_MS ?? "10000", 10);
|
|
60
60
|
const statusKey = `cca:meta-agent:status:${namespace}`;
|
|
61
|
-
|
|
61
|
+
console.log(`[router] ensureMetaAgent namespace=${namespace} checking ${statusKey}`);
|
|
62
|
+
// Fast path: already running or idle (idle = ready to receive messages)
|
|
62
63
|
const statusRaw = await redis.get(statusKey);
|
|
63
64
|
if (statusRaw) {
|
|
64
65
|
try {
|
|
65
66
|
const status = JSON.parse(statusRaw);
|
|
66
|
-
if (status.status === "running")
|
|
67
|
+
if (status.status === "running" || status.status === "idle") {
|
|
68
|
+
console.log(`[router] meta-agent ${namespace} is already ready (status=${status.status})`);
|
|
67
69
|
return;
|
|
70
|
+
}
|
|
68
71
|
}
|
|
69
72
|
catch {
|
|
70
73
|
// Corrupt status value — fall through and restart
|
|
@@ -91,7 +94,7 @@ export async function ensureMetaAgent(namespace, repoUrl, callTool, redis) {
|
|
|
91
94
|
if (result === null) {
|
|
92
95
|
throw new Error(`start_meta_agent returned null — tool may not be available in cc-agent`);
|
|
93
96
|
}
|
|
94
|
-
// Poll until the meta-agent reports "running"
|
|
97
|
+
// Poll until the meta-agent reports "running" or "idle" (both mean ready)
|
|
95
98
|
const deadline = Date.now() + timeoutMs;
|
|
96
99
|
while (Date.now() < deadline) {
|
|
97
100
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
@@ -99,13 +102,17 @@ export async function ensureMetaAgent(namespace, repoUrl, callTool, redis) {
|
|
|
99
102
|
if (raw) {
|
|
100
103
|
try {
|
|
101
104
|
const s = JSON.parse(raw);
|
|
102
|
-
|
|
105
|
+
console.log(`[router] waiting for meta-agent ${namespace} — current status: ${s.status}`);
|
|
106
|
+
if (s.status === "running" || s.status === "idle")
|
|
103
107
|
return;
|
|
104
108
|
}
|
|
105
109
|
catch {
|
|
106
110
|
// ignore parse errors, keep polling
|
|
107
111
|
}
|
|
108
112
|
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(`[router] waiting for meta-agent ${namespace} — no status key yet`);
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
117
|
throw new Error(`Meta-agent for ${namespace} did not become ready within ${timeoutMs}ms`);
|
|
111
118
|
}
|