cc-viewer 1.9.20 → 1.9.22

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.
Files changed (33) hide show
  1. package/README.md +1 -0
  2. package/cli.js +25 -13
  3. package/dist/assets/{App-Cf04lonP.js → App-BN3viVRq.js} +2 -2
  4. package/dist/assets/{MdxEditorPanel-DKU2r-KQ.js → MdxEditorPanel-CmHF9Mz1.js} +1 -1
  5. package/dist/assets/{Mobile-DK6O4hoa.js → Mobile-nbI6IeX_.js} +1 -1
  6. package/dist/assets/{ProxyStatsModal-B2njUNcC.js → ProxyStatsModal-Ogrx3mxS.js} +1 -1
  7. package/dist/assets/{index-C8223pn2.js → index-DoFyHmPM.js} +2 -2
  8. package/dist/assets/seqResourceLoaders-n9iXZRHx.js +2 -0
  9. package/dist/index.html +1 -1
  10. package/package.json +1 -1
  11. package/server/i18n.js +93 -14
  12. package/server/interceptor.js +6 -0
  13. package/server/lib/async-write-queue.js +18 -0
  14. package/server/lib/auth.js +11 -3
  15. package/server/lib/base-path.js +89 -18
  16. package/server/lib/base-url.js +209 -0
  17. package/server/lib/log-management.js +21 -1
  18. package/server/lib/plugin-runtime.js +24 -5
  19. package/server/lib/v2/adapter.js +147 -15
  20. package/server/lib/v2/conversation-store.js +9 -0
  21. package/server/lib/v2/journal.js +35 -0
  22. package/server/lib/v2/layout.js +67 -1
  23. package/server/lib/v2/live-feed.js +15 -0
  24. package/server/lib/v2/replay.js +11 -3
  25. package/server/lib/v2/session-select.js +34 -2
  26. package/server/lib/v2/shard-manager.js +249 -0
  27. package/server/lib/v2/v2-writer.js +252 -6
  28. package/server/proxy.js +25 -11
  29. package/server/routes/events.js +75 -4
  30. package/server/routes/logs.js +47 -16
  31. package/server/routes/misc.js +15 -5
  32. package/server/server.js +85 -27
  33. package/dist/assets/seqResourceLoaders-0JGRMKPS.js +0 -2
package/README.md CHANGED
@@ -214,6 +214,7 @@ cc-viewer works in a single container or on a cloud host where you reach the UI
214
214
  * **Reverse-proxy note:** access control is based on the socket peer address (`X-Forwarded-For` is deliberately not trusted, to prevent spoofing). This does not affect remote admins — they authenticate by token/password, not by IP. It only means "same-container" detection relies on a real loopback connection.
215
215
 
216
216
  * **Design doc:** how local config maps to a cloud database and the cloud-sync model (cloud-authoritative, local read-only fallback) is described in [Config Convergence & Cloud-Sync Advisory](./docs/config-cloud-sync.md) ([中文](./docs/config-cloud-sync.zh.md)). This is a proposal, not yet implemented.
217
+ * **Reverse-proxy base URL:** when the platform maps the port to a public URL with a path prefix (e.g. `https://host.example.com/arca/api/v1/session/{token}`), set `CCV_BASE_URL` to it — prefix routing, WebSocket upgrades, Host allowlisting, and the share/QR links all follow automatically. See [Deploying behind a reverse-proxy URL](./docs/base-url.md) ([中文](./docs/base-url.zh.md)).
217
218
 
218
219
 
219
220
  ### Model-specific system prompts
package/cli.js CHANGED
@@ -15,7 +15,7 @@ import { INJECT_IMPORT, LEGACY_INJECT_IMPORTS, resolveCliPath, resolvePreferredC
15
15
  import { ensureHooks, removeAllManagedHooks } from './server/lib/ensure-hooks.js';
16
16
  import { injectCliJsAt, removeCliJsInjectionAt, INJECT_START as _INJECT_START, INJECT_END as _INJECT_END, buildInjectBlock as _buildInjectBlock } from './server/lib/cli-inject.js';
17
17
  import { inspectShellHook } from './server/lib/shell-hook-inspect.js';
18
- import { normalizeBasePath } from './server/lib/base-path.js';
18
+ import { resolveBaseConfig, externalUrlFromConfig } from './server/lib/base-url.js';
19
19
  import { mergeSettingsIntoArgs } from './server/lib/settings-merge.js';
20
20
  import { splitSdkLaunchArgs, resolveLaunchSystemPrompt, insertBeforeDashDash } from './server/lib/launch-config.js';
21
21
  import { createHardenedCleanup, installWinKeypressFallback } from './server/lib/term-signals.js';
@@ -614,8 +614,14 @@ async function runCliMode(extraClaudeArgs = [], cwd, noOpen = false) {
614
614
 
615
615
  // 4. 自动打开浏览器
616
616
  const protocol = serverMod.getProtocol();
617
- const basePath = normalizeBasePath(process.env.CCV_BASE_PATH);
618
- const url = `${protocol}://127.0.0.1:${port}${basePath}`;
617
+ const _cfg = resolveBaseConfig();
618
+ const url = `${protocol}://127.0.0.1:${port}${_cfg.basePath}`;
619
+ const _token = serverMod.getAccessToken();
620
+ // CCV_BASE_URL with a host: auto-open and the External line use the public URL (carrying
621
+ // ccv's own ?token= — without it the default token auth makes the remote link a 403 dead
622
+ // link). No request context here, so the scheme is the explicit value or https by default.
623
+ const externalUrl = externalUrlFromConfig(_cfg, { token: _token });
624
+ const openUrl = externalUrl || url;
619
625
  if (!noOpen) {
620
626
  try {
621
627
  // URL 含 & 在 cmd.exe 下会被当命令分隔符切断 query;用 spawn 数组传参避免 shell interpolation。
@@ -627,10 +633,10 @@ async function runCliMode(extraClaudeArgs = [], cwd, noOpen = false) {
627
633
  // would crash. Swallow it here as a best-effort fallback.
628
634
  let child;
629
635
  if (process.platform === 'win32') {
630
- child = spawn('cmd.exe', ['/c', 'start', '""', url], { stdio: 'ignore', detached: true, windowsHide: true });
636
+ child = spawn('cmd.exe', ['/c', 'start', '""', openUrl], { stdio: 'ignore', detached: true, windowsHide: true });
631
637
  } else {
632
638
  const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
633
- child = spawn(cmd, [url], { stdio: 'ignore', detached: true });
639
+ child = spawn(cmd, [openUrl], { stdio: 'ignore', detached: true });
634
640
  }
635
641
  child.on('error', () => {});
636
642
  child.unref();
@@ -639,10 +645,10 @@ async function runCliMode(extraClaudeArgs = [], cwd, noOpen = false) {
639
645
 
640
646
  console.log(`CC Viewer:`);
641
647
  console.log(` ➜ Local: ${url}`);
648
+ if (externalUrl) console.log(t('server.startedExternal', { url: externalUrl }));
642
649
  const _lanIps = serverMod.getAllLocalIps();
643
- const _token = serverMod.getAccessToken();
644
650
  for (const _ip of _lanIps) {
645
- console.log(` ➜ Network: ${protocol}://${_ip}:${port}${basePath}?token=${_token}`);
651
+ console.log(` ➜ Network: ${protocol}://${_ip}:${port}${_cfg.basePath}?token=${_token}`);
646
652
  }
647
653
  // 密码登录已启用时,把当前密码打印出来 —— 否则 `ccv --usePassword`(随机密码)在 CLI 模式下
648
654
  // 用户无从得知密码(server.js 的密码打印只在非 CLI 模式生效)。空密码=无防护,给出警告。
@@ -958,8 +964,14 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
958
964
 
959
965
  // 自动打开浏览器
960
966
  const protocol = serverMod.getProtocol();
961
- const basePath = normalizeBasePath(process.env.CCV_BASE_PATH);
962
- const url = `${protocol}://127.0.0.1:${port}${basePath}`;
967
+ const _cfg = resolveBaseConfig();
968
+ const url = `${protocol}://127.0.0.1:${port}${_cfg.basePath}`;
969
+ const _token = serverMod.getAccessToken();
970
+ // CCV_BASE_URL with a host: auto-open and the External line use the public URL (carrying
971
+ // ccv's own ?token= — without it the default token auth makes the remote link a 403 dead
972
+ // link). No request context here, so the scheme is the explicit value or https by default.
973
+ const externalUrl = externalUrlFromConfig(_cfg, { token: _token });
974
+ const openUrl = externalUrl || url;
963
975
  if (!noOpen) {
964
976
  try {
965
977
  // URL 含 & 在 cmd.exe 下会被当命令分隔符切断 query;用 spawn 数组传参避免 shell interpolation。
@@ -971,10 +983,10 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
971
983
  // would crash. Swallow it here as a best-effort fallback.
972
984
  let child;
973
985
  if (process.platform === 'win32') {
974
- child = spawn('cmd.exe', ['/c', 'start', '""', url], { stdio: 'ignore', detached: true, windowsHide: true });
986
+ child = spawn('cmd.exe', ['/c', 'start', '""', openUrl], { stdio: 'ignore', detached: true, windowsHide: true });
975
987
  } else {
976
988
  const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
977
- child = spawn(cmd, [url], { stdio: 'ignore', detached: true });
989
+ child = spawn(cmd, [openUrl], { stdio: 'ignore', detached: true });
978
990
  }
979
991
  child.on('error', () => {});
980
992
  child.unref();
@@ -983,10 +995,10 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
983
995
 
984
996
  console.log(`CC Viewer (SDK mode):`);
985
997
  console.log(` ➜ Local: ${url}`);
998
+ if (externalUrl) console.log(t('server.startedExternal', { url: externalUrl }));
986
999
  const _lanIps = serverMod.getAllLocalIps();
987
- const _token = serverMod.getAccessToken();
988
1000
  for (const _ip of _lanIps) {
989
- console.log(` ➜ Network: ${protocol}://${_ip}:${port}${basePath}?token=${_token}`);
1001
+ console.log(` ➜ Network: ${protocol}://${_ip}:${port}${_cfg.basePath}?token=${_token}`);
990
1002
  }
991
1003
  // 密码登录已启用时,把当前密码打印出来 —— 否则 `ccv --usePassword`(随机密码)在 CLI 模式下
992
1004
  // 用户无从得知密码(server.js 的密码打印只在非 CLI 模式生效)。空密码=无防护,给出警告。