omnius 1.0.264 → 1.0.265

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
@@ -606077,6 +606077,7 @@ var init_status_bar = __esm({
606077
606077
  _autoScroll = true;
606078
606078
  /** Cached click region for the spacer button */
606079
606079
  _scrollBtnRegion = null;
606080
+ _copyBtnRegion = null;
606080
606081
  stdinHooked = false;
606081
606082
  /** COHERE distributed cognitive commons active flag */
606082
606083
  _cohereActive = false;
@@ -607776,6 +607777,12 @@ var init_status_bar = __esm({
607776
607777
  return;
607777
607778
  }
607778
607779
  }
607780
+ if (type === "press" && this._copyBtnRegion && row === this._copyBtnRegion.row) {
607781
+ if (col >= this._copyBtnRegion.start && col <= this._copyBtnRegion.end) {
607782
+ this.copySessionToClipboard();
607783
+ return;
607784
+ }
607785
+ }
607779
607786
  const pos = this.rowPositions(termRows());
607780
607787
  if (type === "press" && pos.tabBarRow > 0 && row === pos.tabBarRow) {
607781
607788
  const viewId = this.hitTestTabBar(col);
@@ -608627,6 +608634,60 @@ ${CONTENT_BG_SEQ}`);
608627
608634
  this._syncPagerScope();
608628
608635
  this.repaintContent();
608629
608636
  }
608637
+ /** Copy the visible session content to the system clipboard */
608638
+ copySessionToClipboard() {
608639
+ const lines = this._contentLines;
608640
+ if (!lines || lines.length === 0) return;
608641
+ const offset = this._contentScrollOffset;
608642
+ const visible = this.contentHeight;
608643
+ const startIdx = Math.max(0, offset);
608644
+ const endIdx = Math.min(lines.length, startIdx + visible);
608645
+ const visibleLines = lines.slice(startIdx, endIdx);
608646
+ const stripped = visibleLines.map(
608647
+ (line) => line.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "").replace(/\x1B\]?[^\x07]*\x07/g, "")
608648
+ );
608649
+ const text2 = stripped.join("\n");
608650
+ const clipboardCmds = [
608651
+ ["wl-copy", text2],
608652
+ ["xclip", ["-selection", "clipboard"], "-i"],
608653
+ ["xsel", "--clipboard", "--input"]
608654
+ ];
608655
+ let success = false;
608656
+ for (const [cmd, ...args] of clipboardCmds) {
608657
+ try {
608658
+ const { execSync: execSync63 } = __require("child_process");
608659
+ const child = __require("child_process").spawn(cmd, args, {
608660
+ stdio: ["pipe", "pipe", "pipe"]
608661
+ });
608662
+ if (child.stdin) {
608663
+ child.stdin.write(text2);
608664
+ child.stdin.end();
608665
+ }
608666
+ child.on("close", (code8) => {
608667
+ if (code8 === 0) success = true;
608668
+ });
608669
+ setTimeout(() => {
608670
+ if (!success) {
608671
+ try {
608672
+ child.kill();
608673
+ } catch {
608674
+ }
608675
+ }
608676
+ }, 500);
608677
+ break;
608678
+ } catch {
608679
+ continue;
608680
+ }
608681
+ }
608682
+ if (!success) {
608683
+ const fs11 = __require("fs");
608684
+ const os9 = __require("os");
608685
+ const tmpPath = __require("path").join(os9.tmpdir(), "omnius-session-copy.txt");
608686
+ fs11.writeFileSync(tmpPath, text2, "utf-8");
608687
+ process.stderr.write(`\x1B[38;5;208mClipboard unavailable — session saved to ${tmpPath}\x1B[0m
608688
+ `);
608689
+ }
608690
+ }
608630
608691
  /**
608631
608692
  * WO-TASK-02 — sync the tasks panel "pager" scope flag with the current
608632
608693
  * scroll-back state. While the user is scrolled back through content
@@ -608692,8 +608753,19 @@ ${CONTENT_BG_SEQ}`);
608692
608753
  start: startCol,
608693
608754
  end: startCol + label.length - 1
608694
608755
  };
608756
+ const copyLabel = " ⎘ copy session ";
608757
+ const copyCol = Math.max(startCol + label.length + 2, w - copyLabel.length);
608758
+ if (copyCol + copyLabel.length <= w) {
608759
+ buf += `\x1B[${spacerRow};${copyCol}H\x1B[38;5;141m${copyLabel}\x1B[0m${CONTENT_BG_SEQ}`;
608760
+ this._copyBtnRegion = {
608761
+ row: spacerRow,
608762
+ start: copyCol,
608763
+ end: copyCol + copyLabel.length - 1
608764
+ };
608765
+ }
608695
608766
  } else {
608696
608767
  this._scrollBtnRegion = null;
608768
+ this._copyBtnRegion = null;
608697
608769
  }
608698
608770
  }
608699
608771
  if (this._contentScrollOffset > 0) {
@@ -690936,7 +691008,7 @@ import {
690936
691008
  readSync as readSync2,
690937
691009
  closeSync as closeSync6
690938
691010
  } from "node:fs";
690939
- import { randomBytes as randomBytes28, randomUUID as randomUUID21 } from "node:crypto";
691011
+ import { randomBytes as randomBytes28, randomUUID as randomUUID21, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
690940
691012
  import { createHash as createHash42 } from "node:crypto";
690941
691013
  function memoryDbPaths3(baseDir = process.cwd()) {
690942
691014
  const dir = join164(baseDir, ".omnius");
@@ -692499,16 +692571,69 @@ function runtimeKeysExist() {
692499
692571
  return false;
692500
692572
  }
692501
692573
  }
692574
+ function tokensMatch(a2, b) {
692575
+ if (typeof a2 !== "string" || typeof b !== "string") return false;
692576
+ if (a2.length === 0 || b.length === 0) return false;
692577
+ const ab = Buffer.from(a2, "utf8");
692578
+ const bb = Buffer.from(b, "utf8");
692579
+ if (ab.length !== bb.length) return false;
692580
+ try {
692581
+ return timingSafeEqual2(ab, bb);
692582
+ } catch {
692583
+ return false;
692584
+ }
692585
+ }
692586
+ function scopedEnvKeySources() {
692587
+ const pick = (...names) => {
692588
+ for (const n2 of names) {
692589
+ const v = process.env[n2];
692590
+ if (v && v.trim()) return v.trim();
692591
+ }
692592
+ return void 0;
692593
+ };
692594
+ return [
692595
+ {
692596
+ value: pick("OMNIUS_REST_READ_API_KEY", "OMNIUS_READ_API_KEY"),
692597
+ scope: "read",
692598
+ user: "rest-read"
692599
+ },
692600
+ {
692601
+ value: pick("OMNIUS_REST_RUN_API_KEY", "OMNIUS_RUN_API_KEY"),
692602
+ scope: "run",
692603
+ user: "rest-run"
692604
+ },
692605
+ {
692606
+ value: pick("OMNIUS_REST_AUDITOR_API_KEY", "OMNIUS_AUDITOR_API_KEY"),
692607
+ scope: "read",
692608
+ user: "rest-auditor"
692609
+ },
692610
+ {
692611
+ value: pick("OMNIUS_REST_ADMIN_API_KEY", "OMNIUS_ADMIN_API_KEY"),
692612
+ scope: "admin",
692613
+ user: "rest-admin"
692614
+ },
692615
+ { value: pick("OMNIUS_REST_API_KEY"), scope: "admin", user: "rest-admin" }
692616
+ ];
692617
+ }
692618
+ function anyEnvAuthKeyConfigured() {
692619
+ if (process.env["OMNIUS_REST_API_KEYS"] || process.env["OMNIUS_API_KEYS"]) {
692620
+ return true;
692621
+ }
692622
+ if (process.env["OMNIUS_API_KEY"]) return true;
692623
+ return scopedEnvKeySources().some((s2) => Boolean(s2.value));
692624
+ }
692625
+ function anyAuthKeyConfigured() {
692626
+ return anyEnvAuthKeyConfigured() || runtimeKeysExist();
692627
+ }
692502
692628
  function resolveAuth(req3) {
692503
692629
  const authHeader = req3.headers["authorization"];
692504
- const token = authHeader?.startsWith("Bearer ") ? authHeader.slice(7) : null;
692630
+ const token = typeof authHeader === "string" && authHeader.startsWith("Bearer ") ? authHeader.slice(7).trim() : null;
692505
692631
  const multiKeys = process.env["OMNIUS_REST_API_KEYS"] || process.env["OMNIUS_API_KEYS"];
692506
- if (multiKeys) {
692507
- if (!token) return { authenticated: false, scope: "read" };
692632
+ if (token && multiKeys) {
692508
692633
  for (const entry of multiKeys.split(",")) {
692509
692634
  const parts = entry.trim().split(":");
692510
692635
  const [key, scope, user, rpmStr, tpdStr, maxJobsStr] = parts;
692511
- if (key === token) {
692636
+ if (key && tokensMatch(key, token)) {
692512
692637
  return {
692513
692638
  authenticated: true,
692514
692639
  scope: scope || "admin",
@@ -692519,26 +692644,25 @@ function resolveAuth(req3) {
692519
692644
  };
692520
692645
  }
692521
692646
  }
692522
- return { authenticated: false, scope: "read" };
692523
692647
  }
692524
- const scopedRestKeys = [
692525
- [process.env["OMNIUS_REST_READ_API_KEY"], "read", "rest-read"],
692526
- [process.env["OMNIUS_REST_RUN_API_KEY"], "run", "rest-run"],
692527
- [process.env["OMNIUS_REST_AUDITOR_API_KEY"], "read", "rest-auditor"],
692528
- [process.env["OMNIUS_REST_ADMIN_API_KEY"], "admin", "rest-admin"],
692529
- [process.env["OMNIUS_REST_API_KEY"], "admin", "rest-admin"]
692530
- ];
692531
- for (const [key, scope, user] of scopedRestKeys) {
692532
- if (key && token === key) return { authenticated: true, scope, user };
692648
+ if (token) {
692649
+ for (const source of scopedEnvKeySources()) {
692650
+ if (source.value && tokensMatch(source.value, token)) {
692651
+ return {
692652
+ authenticated: true,
692653
+ scope: source.scope,
692654
+ user: source.user
692655
+ };
692656
+ }
692657
+ }
692533
692658
  }
692534
692659
  const singleKey = process.env["OMNIUS_API_KEY"];
692535
- if (singleKey) {
692536
- if (token === singleKey)
692537
- return {
692538
- authenticated: true,
692539
- scope: "admin",
692540
- user: "legacy-omnius-api-key"
692541
- };
692660
+ if (token && singleKey && tokensMatch(singleKey, token)) {
692661
+ return {
692662
+ authenticated: true,
692663
+ scope: "admin",
692664
+ user: "legacy-omnius-api-key"
692665
+ };
692542
692666
  }
692543
692667
  if (token) {
692544
692668
  try {
@@ -692558,13 +692682,12 @@ function resolveAuth(req3) {
692558
692682
  } catch {
692559
692683
  }
692560
692684
  }
692561
- if (!singleKey) {
692685
+ if (!anyEnvAuthKeyConfigured()) {
692562
692686
  const insecureLoopbackAdmin = process.env["OMNIUS_INSECURE_LOOPBACK_ADMIN"] === "1";
692563
692687
  const remoteIp = (req3.socket?.remoteAddress || "").replace(/^::ffff:/, "");
692564
692688
  if (insecureLoopbackAdmin && isLoopbackIP(remoteIp)) {
692565
692689
  return { authenticated: true, scope: "admin", user: "insecure-loopback" };
692566
692690
  }
692567
- return { authenticated: false, scope: "read" };
692568
692691
  }
692569
692692
  return { authenticated: false, scope: "read" };
692570
692693
  }
@@ -692572,9 +692695,22 @@ function checkAuth(req3, res, requiredScope = "read") {
692572
692695
  const scopeLevel = { read: 1, run: 2, admin: 3 };
692573
692696
  const auth = resolveAuth(req3);
692574
692697
  if (!auth.authenticated) {
692698
+ if (process.env["OMNIUS_AUTH_DEBUG"] === "1") {
692699
+ const hasBearer = typeof req3.headers["authorization"] === "string" && req3.headers["authorization"].startsWith("Bearer ");
692700
+ const remoteIp = (req3.socket?.remoteAddress || "").replace(
692701
+ /^::ffff:/,
692702
+ ""
692703
+ );
692704
+ const reason = !hasBearer ? "no_bearer_token" : anyAuthKeyConfigured() ? "token_not_recognized" : "no_server_keys_configured";
692705
+ process.stderr.write(
692706
+ `[auth] 401 ${reason} ip=${remoteIp} requiredScope=${requiredScope}
692707
+ `
692708
+ );
692709
+ }
692575
692710
  jsonResponse(res, 401, {
692576
692711
  error: "Unauthorized",
692577
- message: "Invalid or missing Bearer token"
692712
+ message: "Invalid or missing Bearer token",
692713
+ hint: "Send 'Authorization: Bearer <token>'. The token must match OMNIUS_API_KEYS, a scoped OMNIUS_[REST_]<SCOPE>_API_KEY, OMNIUS_API_KEY, or a runtime/dashboard-minted key."
692578
692714
  });
692579
692715
  return false;
692580
692716
  }
@@ -699711,9 +699847,7 @@ function startApiServer(options2 = {}) {
699711
699847
  res.setHeader("X-API-Version", API_VERSION);
699712
699848
  const rawIp = req3.socket?.remoteAddress ?? "";
699713
699849
  const hasBearer = typeof req3.headers["authorization"] === "string" && req3.headers["authorization"].startsWith("Bearer ");
699714
- const anyKeyConfigured = hasBearer && Boolean(
699715
- process.env["OMNIUS_API_KEY"] || process.env["OMNIUS_API_KEYS"] || process.env["OMNIUS_REST_API_KEY"] || process.env["OMNIUS_REST_API_KEYS"] || process.env["OMNIUS_REST_READ_API_KEY"] || process.env["OMNIUS_REST_RUN_API_KEY"] || process.env["OMNIUS_REST_ADMIN_API_KEY"] || runtimeKeysExist()
699716
- );
699850
+ const anyKeyConfigured = hasBearer && anyAuthKeyConfigured();
699717
699851
  if (!isAllowedIP(rawIp, runtimeAccessMode) && !(hasBearer && anyKeyConfigured)) {
699718
699852
  _accessRejected++;
699719
699853
  metrics.totalErrors++;
@@ -700278,19 +700412,27 @@ function startApiServer(options2 = {}) {
700278
700412
  }
700279
700413
  }, 36e5).unref();
700280
700414
  }
700281
- const configuredRestKeys = process.env["OMNIUS_REST_API_KEYS"] || process.env["OMNIUS_API_KEYS"];
700282
- if (configuredRestKeys) {
700283
- const keyCount = configuredRestKeys.split(",").length;
700284
- log22(` Auth: ${keyCount} scoped key(s) (read/run/admin)
700285
- `);
700286
- } else if (process.env["OMNIUS_REST_API_KEY"] || process.env["OMNIUS_REST_ADMIN_API_KEY"] || process.env["OMNIUS_API_KEY"]) {
700287
- log22(` Auth: single Bearer token (admin scope)
700415
+ {
700416
+ const sources = [];
700417
+ const multiMap = process.env["OMNIUS_REST_API_KEYS"] || process.env["OMNIUS_API_KEYS"];
700418
+ if (multiMap) {
700419
+ sources.push(`${multiMap.split(",").length} multi-key map entry(ies)`);
700420
+ }
700421
+ const scopedCount = scopedEnvKeySources().filter(
700422
+ (s2) => Boolean(s2.value)
700423
+ ).length;
700424
+ if (scopedCount > 0) sources.push(`${scopedCount} scoped env key(s)`);
700425
+ if (process.env["OMNIUS_API_KEY"]) sources.push("legacy single key");
700426
+ if (runtimeKeysExist()) sources.push("runtime/dashboard keys");
700427
+ if (sources.length > 0) {
700428
+ log22(` Auth: enabled — ${sources.join(", ")}
700288
700429
  `);
700289
- } else {
700290
- log22(
700291
- ` Auth: disabled (set OMNIUS_REST_API_KEY or OMNIUS_REST_API_KEYS to enable)
700430
+ } else {
700431
+ log22(
700432
+ ` Auth: disabled (set OMNIUS_RUN_API_KEY / OMNIUS_REST_API_KEY / OMNIUS_API_KEYS, or mint a runtime key, to enable)
700292
700433
  `
700293
- );
700434
+ );
700435
+ }
700294
700436
  }
700295
700437
  log22(` Discovering sponsors in background...
700296
700438
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.264",
3
+ "version": "1.0.265",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "omnius",
9
- "version": "1.0.264",
9
+ "version": "1.0.265",
10
10
  "bundleDependencies": [
11
11
  "image-to-ascii"
12
12
  ],
@@ -6337,9 +6337,9 @@
6337
6337
  "license": "MIT"
6338
6338
  },
6339
6339
  "node_modules/semver": {
6340
- "version": "7.8.3",
6341
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.3.tgz",
6342
- "integrity": "sha512-wnilbGyMxzbY7dNOl7jpKbLSjcfeweJWU5j4+u5qW+6/wuGD9KzIGOyZnQVSBM9E7DtWaaH3CyHkppYrKYoxwg==",
6340
+ "version": "7.8.4",
6341
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
6342
+ "integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
6343
6343
  "license": "ISC",
6344
6344
  "bin": {
6345
6345
  "semver": "bin/semver.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnius",
3
- "version": "1.0.264",
3
+ "version": "1.0.265",
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",