ework-web 0.10.26 → 0.10.28

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.26",
3
+ "version": "0.10.28",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
@@ -103,3 +103,18 @@ export async function getSessionDaemonMap(): Promise<Map<string, SessionDaemonIn
103
103
  return new Map();
104
104
  }
105
105
  }
106
+
107
+ export async function resolveDaemonEndpoint(daemonId: number): Promise<string | null> {
108
+ try {
109
+ const rows = await getDB().all<{ internal_endpoint: string | null }>(
110
+ `SELECT internal_endpoint FROM {{d_daemons}} WHERE id = ?`,
111
+ [daemonId],
112
+ );
113
+ const ep = rows[0]?.internal_endpoint;
114
+ if (!ep) return null;
115
+ return ep;
116
+ } catch (e) {
117
+ log.info(`coordination: resolve daemon ${daemonId} failed (${e instanceof Error ? e.message : String(e)})`);
118
+ return null;
119
+ }
120
+ }
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ import { homedir } from "os";
6
6
  import { loadConfig, DB_OVERRIDABLE, parseOverride, resolveTtsBackend } from "./config";
7
7
  import type { Config } from "./config";
8
8
  import { setConfig, initDB, getDB } from "./db";
9
- import { getActiveDaemons, listAllDaemons, getSessionDaemonMap } from "./coordination";
9
+ import { getActiveDaemons, listAllDaemons, getSessionDaemonMap, resolveDaemonEndpoint } from "./coordination";
10
10
  import { testMysqlConnection, migrateSqliteToMysql, writeMysqlEnv, migrateMysqlToSqlite, writeSqliteEnv, migrateDaemonSqliteToMysql, generateMysqlDDL } from "./db-admin";
11
11
  import type { MysqlTargetOpts } from "./db-admin";
12
12
  import { checkAuth, makeAuthCookieHeader, clearAuthCookieHeader, loginHTML, sanitizeNext, ensureBootstrapAdmin, ensureBootstrapSystem, isReservedSystemLogin } from "./auth";
@@ -627,8 +627,22 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
627
627
  const desc = url.searchParams.get("asc") !== "1";
628
628
  const all = url.searchParams.get("all") === "1";
629
629
  const limit = Math.min(5000, Math.max(1, Number(url.searchParams.get("limit")) || 30));
630
+ const daemonEp = url.searchParams.get("daemon");
631
+ const daemonIdParam = url.searchParams.get("daemon_id");
632
+ if (!daemonEp && daemonIdParam) {
633
+ const id = Number(daemonIdParam);
634
+ if (Number.isFinite(id) && id > 0) {
635
+ const ep = await resolveDaemonEndpoint(id);
636
+ if (ep) {
637
+ const client = new RemoteOpencodeClient(ep);
638
+ const { html: body } = await buildSessionView(client, sid, desc, cfg.collapseLines, limit, all);
639
+ return html(body);
640
+ }
641
+ }
642
+ }
643
+ const client = daemonEp ? new RemoteOpencodeClient(daemonEp) : opencode;
630
644
  try {
631
- const { html: body } = await buildSessionView(opencode, sid, desc, cfg.collapseLines, limit, all);
645
+ const { html: body } = await buildSessionView(client, sid, desc, cfg.collapseLines, limit, all);
632
646
  return html(body);
633
647
  } catch (e) {
634
648
  const status = e instanceof OpencodeError ? e.status : 500;
@@ -649,7 +663,15 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
649
663
 
650
664
  if (url.pathname === "/file") {
651
665
  const rawPath = url.searchParams.get("path") ?? "";
652
- const daemonParam = url.searchParams.get("daemon");
666
+ let daemonParam = url.searchParams.get("daemon");
667
+ const daemonIdParam = url.searchParams.get("daemon_id");
668
+ if (!daemonParam && daemonIdParam) {
669
+ const id = Number(daemonIdParam);
670
+ if (Number.isFinite(id) && id > 0) {
671
+ const ep = await resolveDaemonEndpoint(id);
672
+ if (ep) daemonParam = ep;
673
+ }
674
+ }
653
675
  if (daemonParam && !isLocalhost(daemonParam)) {
654
676
  try {
655
677
  const mode = url.searchParams.get("mode") ?? "tail";