ework-web 0.10.36 → 0.10.37

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.36",
3
+ "version": "0.10.37",
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",
package/src/index.ts CHANGED
@@ -693,13 +693,10 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
693
693
  const status = e instanceof OpencodeError ? e.status : 500;
694
694
  if (status === 404 && /^ses_[0-9A-Za-z]{8,}/.test(sid)) {
695
695
  return html(errorPage(
696
- "会话尚未写入数据库",
697
- `会话 ID ${sid} 在 opencode.db 里找不到。\n\n` +
698
- `常见原因:daemon 把尚未完成的 opencode run session ID 写进了评论(早期捕获),\n` +
699
- `但 opencode 进程因 LLM 鉴权失败 / git clone 失败 / 其他错误退出前没把这条 session\n` +
700
- `持久化到 DB。\n\n` +
701
- `排查:docker logs ework-aio 看 opencode 子进程的报错;确认 OPENCODE_AI_API_KEY 已配置\n` +
702
- `或 ~/.config/opencode/auth.json 存在。`
696
+ "找不到会话",
697
+ `会话 ID ${sid} 在 opencode 数据库中不存在。\n\n` +
698
+ `可能原因:opencode 进程异常退出、session 尚未持久化、或 daemon 连接问题。\n\n` +
699
+ `请检查 daemon 日志或确认 session ID 正确。`
703
700
  ), 404);
704
701
  }
705
702
  return html(errorPage(status === 404 ? "找不到会话" : "加载失败", errMsg(e)), status);
package/src/opencode.ts CHANGED
@@ -416,16 +416,16 @@ export class MultiDaemonOpencodeClient implements OpencodeClientInterface {
416
416
  async exportSession(id: string): Promise<SessionExport> {
417
417
  try {
418
418
  return await Promise.any(this.clients.map((c) => c.exportSession(id)));
419
- } catch {
420
- throw new OpencodeError(`session ${id} not found on any daemon`, 404);
419
+ } catch (e) {
420
+ throw pickErrorFromAggregate(e, id);
421
421
  }
422
422
  }
423
423
 
424
424
  async exportSessionRaw(id: string): Promise<string> {
425
425
  try {
426
426
  return await Promise.any(this.clients.map((c) => c.exportSessionRaw(id)));
427
- } catch {
428
- throw new OpencodeError(`session ${id} not found on any daemon`, 404);
427
+ } catch (e) {
428
+ throw pickErrorFromAggregate(e, id);
429
429
  }
430
430
  }
431
431
 
@@ -450,6 +450,18 @@ export function createOpencodeClient(cfg: Config, daemonEndpoint?: string): Open
450
450
  return new OpencodeClient(cfg);
451
451
  }
452
452
 
453
+ function pickErrorFromAggregate(e: unknown, id: string): OpencodeError {
454
+ if (e instanceof AggregateError) {
455
+ const errors = e.errors as unknown[];
456
+ const non404 = errors.find(
457
+ (err) => err instanceof OpencodeError && err.status !== 404,
458
+ ) as OpencodeError | undefined;
459
+ if (non404) return non404;
460
+ }
461
+ if (e instanceof OpencodeError) return e;
462
+ return new OpencodeError(`session ${id} not found on any daemon`, 404);
463
+ }
464
+
453
465
  async function readCapped(stream: ReadableStream<Uint8Array> | null, maxBytes: number): Promise<string> {
454
466
  if (!stream) return "";
455
467
  const reader = stream.getReader();