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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/agent.js +16 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "novaprime",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "NovaPrime — an AI coding assistant in your terminal, powered by GLM.",
5
5
  "bin": {
6
6
  "novaprime": "bin/novaprime.js"
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
- let res;
38
- try {
39
- res = await fetch(server.replace(/\/$/, '') + '/v1/messages', {
40
- method: 'POST',
41
- headers: { 'content-type': 'application/json', 'x-novaprime-key': key },
42
- body: JSON.stringify({ max_tokens: 16000, system: SYSTEM_PROMPT, tools: tools.definitions, messages, stream: true }),
43
- });
44
- } catch (err) { stopSpin(); return { error: 'Could not reach NovaPrime: ' + err.message }; }
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();