prior-cli 1.4.3 → 1.4.4
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/bin/prior.js +7 -0
- package/lib/agent.js +19 -8
- package/package.json +1 -1
package/bin/prior.js
CHANGED
|
@@ -934,6 +934,7 @@ Keep it under 350 words. Write prior.md now.`;
|
|
|
934
934
|
learnTextBuffer += (ev.content || '');
|
|
935
935
|
break;
|
|
936
936
|
case 'done': spinStop(); break;
|
|
937
|
+
case 'retry': spinStop(); process.stdout.write(c.warn(` ↻ retrying… (${ev.attempt}/${ev.max})\n`)); spinStart('reconnecting…'); break;
|
|
937
938
|
case 'error': spinStop(); console.error(c.err(` ✗ ${ev.message}`)); break;
|
|
938
939
|
}
|
|
939
940
|
},
|
|
@@ -1058,6 +1059,12 @@ Keep it under 350 words. Write prior.md now.`;
|
|
|
1058
1059
|
spinStart('thinking…');
|
|
1059
1060
|
break;
|
|
1060
1061
|
|
|
1062
|
+
case 'retry':
|
|
1063
|
+
spinStop();
|
|
1064
|
+
process.stdout.write(c.warn(` ↻ retrying… (${ev.attempt}/${ev.max})\n`));
|
|
1065
|
+
spinStart('reconnecting…');
|
|
1066
|
+
break;
|
|
1067
|
+
|
|
1061
1068
|
case 'cancelled':
|
|
1062
1069
|
spinStop();
|
|
1063
1070
|
console.log(c.muted(' ✗ Cancelled'));
|
package/lib/agent.js
CHANGED
|
@@ -218,14 +218,25 @@ async function runAgent({ messages, model, uncensored, cwd, projectContext, imag
|
|
|
218
218
|
pendingImages = null;
|
|
219
219
|
|
|
220
220
|
let result;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
const MAX_INFER_RETRIES = 10;
|
|
222
|
+
for (let attempt = 1; attempt <= MAX_INFER_RETRIES; attempt++) {
|
|
223
|
+
try {
|
|
224
|
+
result = await infer(history, model || 'qwen3.5:4b', token, { cwd, uncensored, projectContext, images: iterImages }, signal);
|
|
225
|
+
break;
|
|
226
|
+
} catch (err) {
|
|
227
|
+
if (err.name === 'AbortError' || signal?.aborted) {
|
|
228
|
+
await trackTokenUsage(token, totalPromptTokens, totalCompletionTokens);
|
|
229
|
+
send({ type: 'cancelled' }); send({ type: 'done' }); return;
|
|
230
|
+
}
|
|
231
|
+
if (attempt >= MAX_INFER_RETRIES) {
|
|
232
|
+
await trackTokenUsage(token, totalPromptTokens, totalCompletionTokens);
|
|
233
|
+
send({ type: 'error', message: err.message });
|
|
234
|
+
send({ type: 'done' });
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
send({ type: 'retry', attempt, max: MAX_INFER_RETRIES, message: err.message });
|
|
238
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
239
|
+
}
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
totalPromptTokens += result.promptTokens || 0;
|