@flue/client 0.0.4 → 0.0.5
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/index.mjs +28 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -204,7 +204,8 @@ async function runSkill(client, workdir, name, options) {
|
|
|
204
204
|
});
|
|
205
205
|
console.log(`[flue] skill("${name}"): prompt sent`, {
|
|
206
206
|
hasError: !!asyncResult.error,
|
|
207
|
-
error: asyncResult.error
|
|
207
|
+
error: asyncResult.error,
|
|
208
|
+
data: asyncResult.data
|
|
208
209
|
});
|
|
209
210
|
if (asyncResult.error) throw new Error(`Failed to send prompt for skill "${name}" (session ${sessionId}): ${JSON.stringify(asyncResult.error)}`);
|
|
210
211
|
console.log(`[flue] skill("${name}"): starting polling`);
|
|
@@ -216,21 +217,44 @@ async function runSkill(client, workdir, name, options) {
|
|
|
216
217
|
}
|
|
217
218
|
async function pollUntilIdle(client, sessionId, workdir, skillName, startTime) {
|
|
218
219
|
let emptyPolls = 0;
|
|
220
|
+
let pollCount = 0;
|
|
219
221
|
for (;;) {
|
|
220
222
|
await sleep(POLL_INTERVAL);
|
|
223
|
+
pollCount++;
|
|
221
224
|
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(0);
|
|
222
225
|
if (Date.now() - startTime > MAX_POLL_TIME) throw new Error(`Skill "${skillName}" timed out after ${elapsed}s. Session never went idle. This may indicate a stuck session or OpenCode bug.`);
|
|
223
|
-
const
|
|
226
|
+
const statusResult = await client.session.status({ query: { directory: workdir } });
|
|
227
|
+
const sessionStatus = statusResult.data?.[sessionId];
|
|
224
228
|
if (!sessionStatus || sessionStatus.type === "idle") {
|
|
225
229
|
const parts = await fetchAllAssistantParts(client, sessionId, workdir);
|
|
226
230
|
if (parts.length === 0) {
|
|
227
231
|
emptyPolls++;
|
|
228
|
-
if (emptyPolls
|
|
232
|
+
if (emptyPolls % 12 === 0) {
|
|
233
|
+
console.log(`[flue] skill("${skillName}"): status result: ${JSON.stringify({
|
|
234
|
+
hasData: !!statusResult.data,
|
|
235
|
+
sessionIds: statusResult.data ? Object.keys(statusResult.data) : [],
|
|
236
|
+
error: statusResult.error
|
|
237
|
+
})}`);
|
|
238
|
+
console.log(`[flue] skill("${skillName}"): sessionStatus for ${sessionId}: ${JSON.stringify(sessionStatus)}`);
|
|
239
|
+
}
|
|
240
|
+
if (emptyPolls >= MAX_EMPTY_POLLS) {
|
|
241
|
+
const allMessages = await client.session.messages({
|
|
242
|
+
path: { id: sessionId },
|
|
243
|
+
query: { directory: workdir }
|
|
244
|
+
});
|
|
245
|
+
console.error(`[flue] skill("${skillName}"): TIMEOUT DIAGNOSTICS`, JSON.stringify({
|
|
246
|
+
sessionId,
|
|
247
|
+
statusData: statusResult.data,
|
|
248
|
+
messageCount: Array.isArray(allMessages.data) ? allMessages.data.length : 0,
|
|
249
|
+
messages: allMessages.data
|
|
250
|
+
}, null, 2));
|
|
251
|
+
throw new Error(`Skill "${skillName}" produced no output after ${elapsed}s and ${emptyPolls} empty polls. The agent may have failed to start — check model ID and API key.`);
|
|
252
|
+
}
|
|
229
253
|
continue;
|
|
230
254
|
}
|
|
231
255
|
return parts;
|
|
232
256
|
}
|
|
233
|
-
console.log(`[flue] skill("${skillName}"): running (${elapsed}s)`);
|
|
257
|
+
if (pollCount % 12 === 0) console.log(`[flue] skill("${skillName}"): running (${elapsed}s)`);
|
|
234
258
|
}
|
|
235
259
|
}
|
|
236
260
|
/**
|