loopengine 0.1.46 → 0.1.48

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.
@@ -429,6 +429,22 @@ export const agentsConfigPageHtml = `<!doctype html>
429
429
  });
430
430
  }
431
431
 
432
+ // A stale keep-alive TCP connection reused right after the server (or
433
+ // whatever's proxying it) closed it server-side fails silently — an
434
+ // empty/truncated response, surfaced here as "Unexpected end of JSON
435
+ // input" from r.json() — not a real request failure; a fresh
436
+ // connection on an immediate retry works. Retried exactly once, not
437
+ // looped: a genuine server-side error fails the retry too and should
438
+ // still surface, not get masked by retrying forever.
439
+ function fetchJsonRetryOnce(url, options) {
440
+ function attempt() {
441
+ return fetch(url, options).then(function (r) {
442
+ return r.json().then(function (j) { return { ok: r.ok, body: j }; });
443
+ });
444
+ }
445
+ return attempt().catch(function () { return attempt(); });
446
+ }
447
+
432
448
  function badge(label) {
433
449
  return '<span class="badge ' + (label === 'custom' ? 'badge-custom' : 'badge-default') + '">' + escapeHtml(label) + '</span>';
434
450
  }
@@ -808,12 +824,11 @@ export const agentsConfigPageHtml = `<!doctype html>
808
824
  if (maxTokens && String(maxTokens).trim()) body.model.maxTokens = parseInt(maxTokens, 10);
809
825
  var reasoningEffort = data.get('reasoningEffort');
810
826
  if (reasoningEffort) body.model.reasoningEffort = reasoningEffort;
811
- fetch('/agents/' + encodeURIComponent(name), {
827
+ fetchJsonRetryOnce('/agents/' + encodeURIComponent(name), {
812
828
  method: 'PUT',
813
829
  headers: { 'content-type': 'application/json' },
814
830
  body: JSON.stringify(body),
815
831
  })
816
- .then(function (r) { return r.json().then(function (j) { return { ok: r.ok, body: j }; }); })
817
832
  .then(function (result) {
818
833
  if (!result.ok) throw new Error(result.body.error || 'request failed');
819
834
  currentCfg = result.body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",