@yancyyu/openhermit 1.6.14 → 1.6.16

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/bin/hermit.mjs CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { spawn, execSync } from 'node:child_process';
18
18
  import crypto from 'node:crypto';
19
- import { closeSync, existsSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
19
+ import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
20
20
  import { createRequire } from 'node:module';
21
21
  import os from 'node:os';
22
22
  import path from 'node:path';
@@ -90,6 +90,7 @@ const daemonRequested = args.includes('--daemon');
90
90
  const daemonChild = process.env.HERMIT_DAEMON_CHILD === '1';
91
91
  const daemonPidPath = path.join(hermitHome, 'openhermit.pid');
92
92
  const daemonLogPath = path.join(hermitHome, 'logs', 'openhermit.log');
93
+ const serverLogPath = path.join(hermitHome, 'logs', 'openhermit-server.log');
93
94
  const ccConnectConfigPath =
94
95
  process.env.HERMIT_CC_CONNECT_CONFIG ||
95
96
  process.env.CC_CONNECT_CONFIG ||
@@ -498,7 +499,7 @@ function resolveCcConnectRunner() {
498
499
  }
499
500
 
500
501
  function resolveTsxLoader() {
501
- return require.resolve('tsx');
502
+ return pathToFileURL(require.resolve('tsx')).href;
502
503
  }
503
504
 
504
505
  function resolveAliasLoaderRegister() {
@@ -576,6 +577,29 @@ if (!existsSync(distRenderererDir) || !existsSync(path.join(distRenderererDir, '
576
577
  // Start the server
577
578
  console.log('[openHermit] Launching server...\n');
578
579
 
580
+ function appendServerLog(chunk) {
581
+ try {
582
+ mkdirSync(path.dirname(serverLogPath), { recursive: true });
583
+ appendFileSync(serverLogPath, chunk);
584
+ } catch {
585
+ // Logging must never block startup.
586
+ }
587
+ }
588
+
589
+ function printServerLogTail() {
590
+ try {
591
+ const content = readFileSync(serverLogPath, 'utf-8');
592
+ const lines = content.trimEnd().split(/\r?\n/).slice(-60);
593
+ if (lines.length > 0) {
594
+ console.error(`[openHermit] Server log: ${serverLogPath}`);
595
+ console.error('[openHermit] Last server log lines:');
596
+ console.error(lines.join('\n'));
597
+ }
598
+ } catch {
599
+ console.error(`[openHermit] Server log: ${serverLogPath}`);
600
+ }
601
+ }
602
+
579
603
  const serverProcess = spawn(process.execPath, ['--import', resolveAliasLoaderRegister(), '--import', resolveTsxLoader(), 'src/main/server.ts'], {
580
604
  cwd: repoRoot,
581
605
  detached: true,
@@ -590,7 +614,17 @@ const serverProcess = spawn(process.execPath, ['--import', resolveAliasLoaderReg
590
614
  CC_CONNECT_BRIDGE_TOKEN: ccTokens.bridgeToken,
591
615
  CC_CONNECT_CONFIG: ccConnectConfigPath,
592
616
  },
593
- stdio: 'inherit',
617
+ stdio: ['ignore', 'pipe', 'pipe'],
618
+ });
619
+
620
+ serverProcess.stdout?.on('data', (chunk) => {
621
+ process.stdout.write(chunk);
622
+ appendServerLog(chunk);
623
+ });
624
+
625
+ serverProcess.stderr?.on('data', (chunk) => {
626
+ process.stderr.write(chunk);
627
+ appendServerLog(chunk);
594
628
  });
595
629
 
596
630
  serverProcess.on('exit', (code) => {
@@ -598,6 +632,7 @@ serverProcess.on('exit', (code) => {
598
632
  signalDaemon(ccConnectProcess?.pid, 'SIGTERM');
599
633
  if (code !== 0) {
600
634
  console.error(`[openHermit] Server exited with code ${code}`);
635
+ printServerLogTail();
601
636
  process.exit(code ?? 1);
602
637
  }
603
638
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yancyyu/openhermit",
3
3
  "type": "module",
4
- "version": "1.6.14",
4
+ "version": "1.6.16",
5
5
  "description": "openHermit: team-oriented agent management workbench atop cc-connect.",
6
6
  "license": "AGPL-3.0",
7
7
  "author": {
@@ -50,6 +50,16 @@ import { TaskDispatchService } from './services/teams-mvp/TaskDispatchService';
50
50
  import type { TaskBusConfig } from '@shared/types/team';
51
51
  import { UpdateService } from './services/UpdateService';
52
52
 
53
+ process.on('uncaughtException', (err) => {
54
+ console.error('[openHermit:server] uncaughtException', err);
55
+ process.exit(1);
56
+ });
57
+
58
+ process.on('unhandledRejection', (reason) => {
59
+ console.error('[openHermit:server] unhandledRejection', reason);
60
+ process.exit(1);
61
+ });
62
+
53
63
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
54
64
  const pkg = JSON.parse(readFileSync(path.join(__dirname, '../../package.json'), 'utf-8'));
55
65
  const REPO_ROOT = path.resolve(__dirname, '..', '..');