omnius 1.0.308 → 1.0.310

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 CHANGED
@@ -557607,6 +557607,17 @@ var init_ollama_pool = __esm({
557607
557607
  return;
557608
557608
  tryKill(pid, "SIGKILL");
557609
557609
  }, 8e3).unref();
557610
+ },
557611
+ onExit: (cb) => {
557612
+ let fired = false;
557613
+ const fireOnce = () => {
557614
+ if (fired)
557615
+ return;
557616
+ fired = true;
557617
+ cb();
557618
+ };
557619
+ child.once("exit", fireOnce);
557620
+ child.once("error", fireOnce);
557610
557621
  }
557611
557622
  };
557612
557623
  child.stdout?.on("data", () => {
@@ -558136,6 +558147,18 @@ var init_ollama_pool = __esm({
558136
558147
  spawnedAtMs
558137
558148
  }, proc);
558138
558149
  this.instances.push(inst);
558150
+ proc.onExit?.(() => {
558151
+ const idx = this.instances.indexOf(inst);
558152
+ if (idx < 0)
558153
+ return;
558154
+ this.instances.splice(idx, 1);
558155
+ this.emit("instance-exited", {
558156
+ id: inst.state.id,
558157
+ pid: proc.pid,
558158
+ port
558159
+ });
558160
+ this.wakeNextSlotWaiter();
558161
+ });
558139
558162
  this.emit("instance-spawned", {
558140
558163
  id: inst.state.id,
558141
558164
  pid: proc.pid,
@@ -565967,6 +565990,23 @@ function isOllamaModelNotFoundResponse(status, text2, model) {
565967
565990
  const modelLower = model.toLowerCase();
565968
565991
  return lower.includes("model") && lower.includes("not found") || lower.includes("not_found_error") || modelLower.length > 0 && lower.includes(modelLower) && lower.includes("not found");
565969
565992
  }
565993
+ function isBackendConnectionError(err) {
565994
+ if (err instanceof Error && err.name === "AbortError")
565995
+ return false;
565996
+ const parts = [];
565997
+ if (err instanceof Error) {
565998
+ parts.push(err.message);
565999
+ const cause = err.cause;
566000
+ if (cause instanceof Error)
566001
+ parts.push(cause.message);
566002
+ const code8 = cause?.code;
566003
+ if (typeof code8 === "string")
566004
+ parts.push(code8);
566005
+ } else if (typeof err === "string") {
566006
+ parts.push(err);
566007
+ }
566008
+ return /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EHOSTUNREACH|ENOTFOUND|EPIPE|socket hang up|UND_ERR/i.test(parts.join(" "));
566009
+ }
565970
566010
  function computeEffectiveThink(params) {
565971
566011
  if (process.env["OMNIUS_FORCE_NO_THINK"] === "1")
565972
566012
  return false;
@@ -581606,7 +581646,25 @@ ${description}`
581606
581646
  };
581607
581647
  if (combinedAbortSignal)
581608
581648
  fetchOpts.signal = combinedAbortSignal;
581609
- let resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, fetchOpts);
581649
+ let resp;
581650
+ try {
581651
+ resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, fetchOpts);
581652
+ } catch (err) {
581653
+ if (poolSlot?.poolOwned && isBackendConnectionError(err)) {
581654
+ const deadInstanceId = poolSlot.instanceId;
581655
+ releasePoolSlot(false);
581656
+ try {
581657
+ await getOllamaPool({
581658
+ baseInstanceUrl: this.baseUrl
581659
+ }).evictInstance(deadInstanceId);
581660
+ } catch {
581661
+ }
581662
+ requestBaseUrl = this.baseUrl;
581663
+ resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, fetchOpts);
581664
+ } else {
581665
+ throw err;
581666
+ }
581667
+ }
581610
581668
  if (!resp.ok) {
581611
581669
  const text2 = await resp.text().catch(() => "");
581612
581670
  if (poolSlot?.poolOwned && isOllamaModelNotFoundResponse(resp.status, text2, this.model)) {
@@ -581962,7 +582020,25 @@ ${description}`
581962
582020
  body: JSON.stringify(body),
581963
582021
  signal: streamAbort.signal
581964
582022
  };
581965
- let resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, streamFetchOpts);
582023
+ let resp;
582024
+ try {
582025
+ resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, streamFetchOpts);
582026
+ } catch (err) {
582027
+ if (poolSlot?.poolOwned && isBackendConnectionError(err)) {
582028
+ const deadInstanceId = poolSlot.instanceId;
582029
+ releasePoolSlot(false);
582030
+ try {
582031
+ await getOllamaPool({
582032
+ baseInstanceUrl: this.baseUrl
582033
+ }).evictInstance(deadInstanceId);
582034
+ } catch {
582035
+ }
582036
+ requestBaseUrl = this.baseUrl;
582037
+ resp = await fetch(`${requestBaseUrl}/v1/chat/completions`, streamFetchOpts);
582038
+ } else {
582039
+ throw err;
582040
+ }
582041
+ }
581966
582042
  if (!resp.ok) {
581967
582043
  const text2 = await resp.text().catch(() => "");
581968
582044
  if (poolSlot?.poolOwned && isOllamaModelNotFoundResponse(resp.status, text2, this.model)) {
@@ -607067,6 +607143,45 @@ __export(status_bar_exports, {
607067
607143
  unlockFooterRedraws: () => unlockFooterRedraws
607068
607144
  });
607069
607145
  import { readFileSync as readFileSync91 } from "node:fs";
607146
+ function stripSubAgentPrefix(label) {
607147
+ const stripped = label.replace(/^\s*sub[-\s]?agents?\b[\s:_–—-]*/i, "").trim();
607148
+ return stripped.length > 0 ? stripped : label.trim();
607149
+ }
607150
+ function xterm256ToRgb(i2) {
607151
+ if (i2 >= 232) {
607152
+ const v = 8 + (i2 - 232) * 10;
607153
+ return [v, v, v];
607154
+ }
607155
+ if (i2 >= 16) {
607156
+ const n2 = i2 - 16;
607157
+ const conv = (c8) => c8 === 0 ? 0 : 55 + c8 * 40;
607158
+ return [conv(Math.floor(n2 / 36)), conv(Math.floor(n2 % 36 / 6)), conv(n2 % 6)];
607159
+ }
607160
+ const base3 = [
607161
+ [0, 0, 0],
607162
+ [128, 0, 0],
607163
+ [0, 128, 0],
607164
+ [128, 128, 0],
607165
+ [0, 0, 128],
607166
+ [128, 0, 128],
607167
+ [0, 128, 128],
607168
+ [192, 192, 192],
607169
+ [128, 128, 128],
607170
+ [255, 0, 0],
607171
+ [0, 255, 0],
607172
+ [255, 255, 0],
607173
+ [0, 0, 255],
607174
+ [255, 0, 255],
607175
+ [0, 255, 255],
607176
+ [255, 255, 255]
607177
+ ];
607178
+ return base3[i2] ?? [0, 0, 0];
607179
+ }
607180
+ function contrastTextColor(colorIndex) {
607181
+ const [r2, g, b] = xterm256ToRgb(colorIndex);
607182
+ const luma = 0.299 * r2 + 0.587 * g + 0.114 * b;
607183
+ return luma >= 140 ? 16 : 231;
607184
+ }
607070
607185
  function formatPoolAge(ms) {
607071
607186
  if (ms < 6e4) return `${Math.max(0, Math.floor(ms / 1e3))}s`;
607072
607187
  if (ms < 60 * 6e4) return `${Math.floor(ms / 6e4)}m`;
@@ -607298,7 +607413,7 @@ var init_status_bar = __esm({
607298
607413
  BOX_FG = tuiBoxFg();
607299
607414
  TEXT_PRIMARY = tuiTextPrimary() < 0 ? 252 : tuiTextPrimary();
607300
607415
  TEXT_DIM = tuiTextDim();
607301
- NO_SUB_AGENTS_HEADER_LABEL = " no sub-agents ";
607416
+ NO_SUB_AGENTS_HEADER_LABEL = " no agents ";
607302
607417
  HEADER_ACCENT_GREEN = 154;
607303
607418
  HEADER_ACCENT_BOLD_FG = `\x1B[1;38;5;${HEADER_ACCENT_GREEN}m`;
607304
607419
  HEADER_BUTTON_BG = `\x1B[48;5;${HEADER_ACCENT_GREEN}m`;
@@ -607775,6 +607890,12 @@ var init_status_bar = __esm({
607775
607890
  const decorateMenuButton = (cmd, label) => {
607776
607891
  return `\x1B[38;5;${HEADER_ACCENT_GREEN}m🭁\x1B[0m${HEADER_BUTTON_FG}${HEADER_BUTTON_BG}${label}\x1B[0m${PANEL_BG_SEQ}\x1B[38;5;${HEADER_ACCENT_GREEN}m🭝\x1B[0m${PANEL_BG_SEQ}`;
607777
607892
  };
607893
+ const decorateAgentButton = (content, color, active) => {
607894
+ const bg = `\x1B[48;5;${color}m`;
607895
+ const fg2 = `\x1B[38;5;${contrastTextColor(color)}m`;
607896
+ const weight = active ? "\x1B[1m" : "";
607897
+ return `\x1B[38;5;${color}m🭁\x1B[0m${weight}${fg2}${bg}${content}\x1B[0m${PANEL_BG_SEQ}\x1B[38;5;${color}m🭝\x1B[0m${PANEL_BG_SEQ}`;
607898
+ };
607778
607899
  const renderBtn = (cmd, label) => {
607779
607900
  const fg2 = buttonFg(cmd);
607780
607901
  const left = _isWindows ? "" : "🛁";
@@ -607868,12 +607989,14 @@ var init_status_bar = __esm({
607868
607989
  for (const view of this._agentViews.values()) {
607869
607990
  if (view.id === "main" && this._activeViewId === "main") continue;
607870
607991
  const icon = view.status === "running" ? "●" : view.status === "completed" ? "✓" : view.status === "failed" ? "✗" : "○";
607871
- const base3 = ` ${trunc3(view.label)} ${icon} `;
607992
+ const content = ` ${trunc3(view.label)} ${icon} `;
607872
607993
  const viewColor = view.colorCode ?? (view.type === "telegram" ? 45 : 213);
607873
- const colored = view.id === this._activeViewId ? `\x1B[1;38;5;${viewColor}m${base3}\x1B[0m` : `\x1B[38;5;${viewColor}m${base3}\x1B[0m`;
607994
+ const active = view.id === this._activeViewId;
607995
+ const btn = decorateAgentButton(content, viewColor, active);
607874
607996
  sysItems.push({
607875
- render: () => renderBtn(`view:${view.id}`, colored) + " ",
607876
- w: base3.length + 1
607997
+ render: () => linkify(`view:${view.id}`, btn) + " ",
607998
+ w: content.length + 2 + 1
607999
+ // 2 border glyphs + trailing space
607877
608000
  });
607878
608001
  }
607879
608002
  } else {
@@ -608042,7 +608165,7 @@ var init_status_bar = __esm({
608042
608165
  if (view.id === "main" && this._activeViewId === "main") continue;
608043
608166
  const icon = view.status === "running" ? "●" : view.status === "completed" ? "✓" : view.status === "failed" ? "✗" : "○";
608044
608167
  const base3 = ` ${trunc3(view.label)} ${icon} `;
608045
- zones.push({ w: base3.length + 1, id: view.id, render: () => "" });
608168
+ zones.push({ w: base3.length + 2 + 1, id: view.id, render: () => "" });
608046
608169
  }
608047
608170
  } else {
608048
608171
  zones.push({ w: NO_SUB_AGENTS_HEADER_LABEL.length, render: () => "" });
@@ -609109,20 +609232,14 @@ var init_status_bar = __esm({
609109
609232
  return;
609110
609233
  }
609111
609234
  if (cmd === "header-toggle") {
609112
- const wasExpanded = this._headerExpanded;
609113
609235
  this._headerExpanded = !this._headerExpanded;
609114
609236
  this.refreshHeaderAndFooter();
609115
609237
  this.scrollRegionTop += this._headerExpanded ? 2 : -2;
609116
609238
  if (this.active) {
609117
609239
  this.applyScrollRegion();
609240
+ this.repaintContent();
609118
609241
  this.renderFooterAndPositionInput();
609119
609242
  }
609120
- if (!this._headerExpanded && wasExpanded) {
609121
- const base3 = this.scrollRegionTop;
609122
- let buf = `\x1B[${base3};1H\x1B[2K\x1B[${base3 + 1};1H\x1B[2K`;
609123
- buf += `\x1B[${base3};1H\x1BM\x1BM`;
609124
- this.termWrite(buf);
609125
- }
609126
609243
  return;
609127
609244
  }
609128
609245
  setPressedButton(cmd);
@@ -609212,7 +609329,7 @@ var init_status_bar = __esm({
609212
609329
  registerAgentView(id, label, type, taskSummary) {
609213
609330
  this._agentViews.set(id, {
609214
609331
  id,
609215
- label,
609332
+ label: stripSubAgentPrefix(label),
609216
609333
  type,
609217
609334
  contentLines: [],
609218
609335
  scrollOffset: 0,
@@ -609345,8 +609462,9 @@ var init_status_bar = __esm({
609345
609462
  for (const view of this._agentViews.values()) {
609346
609463
  if (view.id === "main" && this._activeViewId === "main") continue;
609347
609464
  const icon = view.status === "running" ? "●" : view.status === "completed" ? "✓" : view.status === "failed" ? "✗" : "○";
609348
- const label = ` ${view.label} ${icon} `;
609349
- const endCol = testCol + label.length - 1;
609465
+ const content = ` ${view.label} ${icon} `;
609466
+ const visW = content.length + 2;
609467
+ const endCol = testCol + visW - 1;
609350
609468
  if (col >= testCol && col <= endCol) return view.id;
609351
609469
  testCol = endCol + 2;
609352
609470
  }
@@ -610479,8 +610597,10 @@ ${CONTENT_BG_SEQ}`);
610479
610597
  if (rm4.ollamaPool?.enabled) {
610480
610598
  const pool3 = rm4.ollamaPool;
610481
610599
  const isConstrained = pool3.mode === "constrained";
610482
- const ready = isConstrained ? Math.max(1, pool3.readyGpuInstances) : pool3.readyGpuInstances;
610483
- const target = Math.max(1, pool3.targetGpuInstances);
610600
+ const baseCount = pool3.instances.some((i2) => !i2.poolOwned) ? 1 : 0;
610601
+ const spawnedReady = pool3.instances.filter((i2) => i2.poolOwned).length;
610602
+ const ready = isConstrained ? Math.max(1, baseCount + spawnedReady) : baseCount + spawnedReady;
610603
+ const target = isConstrained ? 1 : Math.max(ready, pool3.targetGpuInstances + baseCount);
610484
610604
  const allReady = ready >= target;
610485
610605
  const poolColor = allReady ? c3.green : c3.yellow;
610486
610606
  const poolDetail = `${_StatusBar.digitBar(ready)}/${_StatusBar.digitBar(target)}`;
@@ -640856,7 +640976,7 @@ async function handleBroker(arg, _ctx) {
640856
640976
  ` ${c3.dim("Idle-evict threshold:")} ${Math.round(broker.idleEvictMs / 1e3)}s`
640857
640977
  );
640858
640978
  safeLog(
640859
- ` ${c3.dim("Slot capacity:")} ${snap.slots.inUse}/${snap.slots.capacity} active, queue ${snap.slots.queueDepth}/${snap.slots.queueCapacity}`
640979
+ ` ${c3.dim("Slot capacity:")} ${snap.slots.inUse}/${snap.slots.capacity} active, QUEUE ${snap.slots.queueDepth}/${snap.slots.queueCapacity}`
640860
640980
  );
640861
640981
  safeLog("");
640862
640982
  if (snap.loaded.length === 0) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.308",
3
+ "version": "1.0.310",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.308",
9
+ "version": "1.0.310",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
@@ -2397,12 +2397,13 @@
2397
2397
  }
2398
2398
  },
2399
2399
  "node_modules/bare-stream": {
2400
- "version": "2.13.2",
2401
- "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.2.tgz",
2402
- "integrity": "sha512-2V5j0dOfxv3iIngIWMnW1O6UPXpeoU70HJzUJGVth/+RURhDyq7SEWTD70Y2SkUB0MQonYYWpIX3f85P/I22+Q==",
2400
+ "version": "2.13.3",
2401
+ "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.3.tgz",
2402
+ "integrity": "sha512-Kc+brLqvEqGkjyfiwJmImAOqLZL7OsoLKuavx+hJjgVV3nLTOjloJyPMFxjUPerGGHrNH0fLU06jjykMLWrERQ==",
2403
2403
  "license": "Apache-2.0",
2404
2404
  "optional": true,
2405
2405
  "dependencies": {
2406
+ "b4a": "^1.8.1",
2406
2407
  "streamx": "^2.25.0",
2407
2408
  "teex": "^1.0.1"
2408
2409
  },
@@ -3526,16 +3527,16 @@
3526
3527
  }
3527
3528
  },
3528
3529
  "node_modules/form-data": {
3529
- "version": "4.0.5",
3530
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
3531
- "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
3530
+ "version": "4.0.6",
3531
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz",
3532
+ "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==",
3532
3533
  "license": "MIT",
3533
3534
  "dependencies": {
3534
3535
  "asynckit": "^0.4.0",
3535
3536
  "combined-stream": "^1.0.8",
3536
3537
  "es-set-tostringtag": "^2.1.0",
3537
- "hasown": "^2.0.2",
3538
- "mime-types": "^2.1.12"
3538
+ "hasown": "^2.0.4",
3539
+ "mime-types": "^2.1.35"
3539
3540
  },
3540
3541
  "engines": {
3541
3542
  "node": ">= 6"
@@ -6690,9 +6691,9 @@
6690
6691
  }
6691
6692
  },
6692
6693
  "node_modules/streamx": {
6693
- "version": "2.27.0",
6694
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.27.0.tgz",
6695
- "integrity": "sha512-WZ189TKnHoAokYHvwzaAQMpd55cgUmFIcJFzBSgGcb886jau5DL+XdDhTWV4ps3FLvk+OORp0dLRTPsLZ21CSA==",
6694
+ "version": "2.28.0",
6695
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.0.tgz",
6696
+ "integrity": "sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==",
6696
6697
  "license": "MIT",
6697
6698
  "optional": true,
6698
6699
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.308",
3
+ "version": "1.0.310",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",