opencode-manifold 0.5.1 → 0.5.3
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.js +31 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,8 +276,15 @@ import { existsSync as existsSync4 } from "fs";
|
|
|
276
276
|
import { join as join4 } from "path";
|
|
277
277
|
|
|
278
278
|
// src/session-spawner.ts
|
|
279
|
+
async function cleanupSession(client, sessionId) {
|
|
280
|
+
try {
|
|
281
|
+
await client.session.delete({ path: { id: sessionId } });
|
|
282
|
+
} catch {}
|
|
283
|
+
}
|
|
279
284
|
async function waitForSessionIdle(client, sessionId, timeoutMs) {
|
|
280
285
|
const startTime = Date.now();
|
|
286
|
+
const lastLogTime = startTime;
|
|
287
|
+
let pollCount = 0;
|
|
281
288
|
while (Date.now() - startTime < timeoutMs) {
|
|
282
289
|
const statusResponse = await client.session.status({});
|
|
283
290
|
const statusData = statusResponse.data;
|
|
@@ -293,6 +300,30 @@ async function waitForSessionIdle(client, sessionId, timeoutMs) {
|
|
|
293
300
|
}
|
|
294
301
|
continue;
|
|
295
302
|
}
|
|
303
|
+
} else {
|
|
304
|
+
const messagesResponse = await client.session.messages({
|
|
305
|
+
path: { id: sessionId }
|
|
306
|
+
});
|
|
307
|
+
const messages = messagesResponse.data;
|
|
308
|
+
if (messages && Array.isArray(messages) && messages.length > 0) {
|
|
309
|
+
for (let i = messages.length - 1;i >= 0; i--) {
|
|
310
|
+
const msg = messages[i];
|
|
311
|
+
if (msg.info && msg.info.role === "assistant") {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
pollCount++;
|
|
318
|
+
const elapsed = Date.now() - startTime;
|
|
319
|
+
if (elapsed % 1e4 < 1000 && elapsed > 0 && Date.now() - lastLogTime > 1e4) {
|
|
320
|
+
await client.app.log({
|
|
321
|
+
body: {
|
|
322
|
+
service: "opencode-manifold",
|
|
323
|
+
level: "info",
|
|
324
|
+
message: `Still waiting for session ${sessionId}... (${Math.round(elapsed / 1000)}s elapsed)`
|
|
325
|
+
}
|
|
326
|
+
});
|
|
296
327
|
}
|
|
297
328
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
298
329
|
}
|
|
@@ -320,11 +351,6 @@ async function getLastAssistantMessage(client, sessionId) {
|
|
|
320
351
|
}
|
|
321
352
|
return "";
|
|
322
353
|
}
|
|
323
|
-
async function cleanupSession(client, sessionId) {
|
|
324
|
-
try {
|
|
325
|
-
await client.session.delete({ path: { id: sessionId } });
|
|
326
|
-
} catch {}
|
|
327
|
-
}
|
|
328
354
|
async function spawnSession(client, agent, prompt, timeoutSeconds) {
|
|
329
355
|
const timeoutMs = timeoutSeconds * 1000;
|
|
330
356
|
try {
|