novaprime 1.4.1 → 1.4.2
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/package.json +1 -1
- package/src/agent.js +16 -8
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -34,14 +34,22 @@ async function streamMessage(server, key, messages) {
|
|
|
34
34
|
const stopSpin = () => { if (spinning) { spinner.stop(); spinning = false; } };
|
|
35
35
|
const ensureSpin = (text) => { if (!spinning) { spinner.start(); spinning = true; } spinner.text = text; };
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// Retry transient connection drops (server restart window, brief network blip)
|
|
38
|
+
// so a 1–2s hiccup doesn't abort a long agentic build mid-turn.
|
|
39
|
+
const payload = JSON.stringify({ max_tokens: 16000, system: SYSTEM_PROMPT, tools: tools.definitions, messages, stream: true });
|
|
40
|
+
const url = server.replace(/\/$/, '') + '/v1/messages';
|
|
41
|
+
let res, lastErr = null;
|
|
42
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
43
|
+
try {
|
|
44
|
+
res = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json', 'x-novaprime-key': key }, body: payload });
|
|
45
|
+
lastErr = null;
|
|
46
|
+
break;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
lastErr = err;
|
|
49
|
+
if (attempt < 3) { ensureSpin(c.muted('connection dropped — reconnecting… (' + (attempt + 1) + '/3)')); await new Promise((r) => setTimeout(r, 1000 * (attempt + 1))); }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (lastErr) { stopSpin(); return { error: 'Could not reach NovaPrime: ' + lastErr.message + ' (retried 3×)' }; }
|
|
45
53
|
|
|
46
54
|
if (!res.ok) {
|
|
47
55
|
stopSpin();
|