cc-viewer 1.5.17 → 1.5.18

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/interceptor.js CHANGED
@@ -207,7 +207,7 @@ export function resetWorkspace() {
207
207
  LOG_FILE = '';
208
208
  }
209
209
 
210
- const MAX_LOG_SIZE = 200 * 1024 * 1024; // 200MB
210
+ const MAX_LOG_SIZE = 150 * 1024 * 1024; // 150MB
211
211
 
212
212
  const SUBAGENT_SYSTEM_RE = /command execution specialist|file search specialist|planning specialist|general-purpose agent/i;
213
213
 
@@ -617,7 +617,7 @@ export function setupInterceptor() {
617
617
  // 在发起请求前先写入一条未完成的条目,让前端可以检测在途请求
618
618
  if (requestEntry) {
619
619
  try {
620
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
620
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
621
621
  } catch { }
622
622
  }
623
623
 
@@ -682,12 +682,12 @@ export function setupInterceptor() {
682
682
  // 移除在途请求标记,保持原始报文
683
683
  delete requestEntry.inProgress;
684
684
  delete requestEntry.requestId;
685
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
685
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
686
686
  } catch (err) {
687
687
  requestEntry.response.body = streamedContent.slice(0, 1000);
688
688
  delete requestEntry.inProgress;
689
689
  delete requestEntry.requestId;
690
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
690
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
691
691
  }
692
692
  controller.close();
693
693
  break;
@@ -717,7 +717,7 @@ export function setupInterceptor() {
717
717
  };
718
718
  delete requestEntry.inProgress;
719
719
  delete requestEntry.requestId;
720
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
720
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
721
721
  }
722
722
  } else {
723
723
  // 对于非流式响应,可以安全读取body
@@ -741,11 +741,11 @@ export function setupInterceptor() {
741
741
  delete requestEntry.inProgress;
742
742
  delete requestEntry.requestId;
743
743
 
744
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
744
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
745
745
  } catch (err) {
746
746
  delete requestEntry.inProgress;
747
747
  delete requestEntry.requestId;
748
- appendFileSync(LOG_FILE, JSON.stringify(requestEntry, null, 2) + '\n---\n');
748
+ appendFileSync(LOG_FILE, JSON.stringify(requestEntry) + '\n---\n');
749
749
  }
750
750
  }
751
751
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-viewer",
3
- "version": "1.5.17",
3
+ "version": "1.5.18",
4
4
  "description": "Claude Code Logger visualization management tool",
5
5
  "license": "MIT",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -1438,7 +1438,18 @@ async function handleRequest(req, res) {
1438
1438
  return;
1439
1439
  }
1440
1440
  }
1441
- // files 已按时间正序传入,合并内容写入第一个文件
1441
+ // files 已按时间正序传入,校验合并后总大小不超过 300MB
1442
+ const MAX_MERGE_SIZE = 300 * 1024 * 1024;
1443
+ let totalSize = 0;
1444
+ for (const f of files) {
1445
+ totalSize += statSync(join(LOG_DIR, f)).size;
1446
+ }
1447
+ if (totalSize > MAX_MERGE_SIZE) {
1448
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1449
+ res.end(JSON.stringify({ error: `Merged size (${(totalSize / 1024 / 1024).toFixed(1)}MB) exceeds 300MB limit` }));
1450
+ return;
1451
+ }
1452
+ // 合并内容写入第一个文件
1442
1453
  const targetFile = files[0];
1443
1454
  const targetPath = join(LOG_DIR, targetFile);
1444
1455
  const contents = files.map(f => readFileSync(join(LOG_DIR, f), 'utf-8').trimEnd());