chattercatcher 0.1.20 → 0.1.21

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/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import fs14 from "fs/promises";
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "chattercatcher",
11
- version: "0.1.20",
11
+ version: "0.1.21",
12
12
  description: "\u672C\u5730\u4F18\u5148\u7684\u98DE\u4E66/Lark \u5BB6\u5EAD\u7FA4\u77E5\u8BC6\u5E93\u673A\u5668\u4EBA",
13
13
  type: "module",
14
14
  main: "dist/index.js",
@@ -983,7 +983,8 @@ function toOpenAIMessage(message) {
983
983
  arguments: JSON.stringify(toolCall.input)
984
984
  }
985
985
  }))
986
- } : {}
986
+ } : {},
987
+ ...message.reasoningContent ? { reasoning_content: message.reasoningContent } : {}
987
988
  };
988
989
  }
989
990
  function toOpenAITool(tool) {
@@ -1029,7 +1030,8 @@ var OpenAICompatibleChatModel = class {
1029
1030
  throw new Error(`LLM \u8BF7\u6C42\u5931\u8D25\uFF1A${response.status} ${body}`);
1030
1031
  }
1031
1032
  const data2 = await response.json();
1032
- const content = data2.choices?.[0]?.message?.content?.trim();
1033
+ const message = data2.choices?.[0]?.message;
1034
+ const content = message?.content?.trim();
1033
1035
  if (!content) {
1034
1036
  throw new Error("LLM \u8FD4\u56DE\u4E3A\u7A7A\u3002");
1035
1037
  }
@@ -1061,7 +1063,8 @@ var OpenAICompatibleChatModel = class {
1061
1063
  const message = data2.choices?.[0]?.message;
1062
1064
  return {
1063
1065
  content: message?.content ?? "",
1064
- toolCalls: parseToolCalls(message)
1066
+ toolCalls: parseToolCalls(message),
1067
+ reasoningContent: message?.reasoning_content ?? void 0
1065
1068
  };
1066
1069
  }
1067
1070
  };
@@ -3027,7 +3030,7 @@ async function generateCronJobMessage(input2) {
3027
3030
  let toolCallsUsed = 0;
3028
3031
  for (let turn = 0; turn < maxModelTurns; turn += 1) {
3029
3032
  const result = await input2.model.completeWithTools(messages, input2.tools);
3030
- messages.push({ role: "assistant", content: result.content, toolCalls: result.toolCalls });
3033
+ messages.push({ role: "assistant", content: result.content, toolCalls: result.toolCalls, reasoningContent: result.reasoningContent });
3031
3034
  if (result.toolCalls.length === 0) {
3032
3035
  break;
3033
3036
  }
@@ -3801,7 +3804,8 @@ async function runFeishuToolLoop(input2) {
3801
3804
  messages.push({
3802
3805
  role: "assistant",
3803
3806
  content: assistantResult.content,
3804
- toolCalls: assistantResult.toolCalls
3807
+ toolCalls: assistantResult.toolCalls,
3808
+ reasoningContent: assistantResult.reasoningContent
3805
3809
  });
3806
3810
  if (assistantResult.toolCalls.length === 0) {
3807
3811
  return assistantResult.content || FEISHU_TOOL_LOOP_FALLBACK;
@@ -5550,24 +5554,28 @@ function buildHtml() {
5550
5554
  }
5551
5555
 
5552
5556
  async function load() {
5553
- const [status, recent, episodeList, chatList, fileList, jobList, qaLogList, cronJobList] = await Promise.all([
5554
- fetch("/api/status").then((response) => response.json()),
5555
- fetch("/api/messages/recent?limit=20").then((response) => response.json()),
5556
- fetch("/api/episodes?limit=10").then((response) => response.json()),
5557
- fetch("/api/chats").then((response) => response.json()),
5558
- fetch("/api/files").then((response) => response.json()),
5559
- fetch("/api/file-jobs").then((response) => response.json()),
5560
- fetch("/api/qa-logs?limit=10").then((response) => response.json()),
5561
- fetch("/api/cron-jobs").then((response) => response.json()),
5562
- ]);
5563
- renderMetrics(status);
5564
- renderMessages(recent.items);
5565
- renderEpisodes(episodeList.items);
5566
- renderChats(chatList.items);
5567
- renderFiles(fileList.items);
5568
- renderFileJobs(jobList.items);
5569
- renderQaLogs(qaLogList.items);
5570
- renderCronJobs(cronJobList.items);
5557
+ try {
5558
+ const [status, recent, episodeList, chatList, fileList, jobList, qaLogList, cronJobList] = await Promise.all([
5559
+ fetch("/api/status").then((response) => response.json()),
5560
+ fetch("/api/messages/recent?limit=20").then((response) => response.json()),
5561
+ fetch("/api/episodes?limit=10").then((response) => response.json()),
5562
+ fetch("/api/chats").then((response) => response.json()),
5563
+ fetch("/api/files").then((response) => response.json()),
5564
+ fetch("/api/file-jobs").then((response) => response.json()),
5565
+ fetch("/api/qa-logs?limit=10").then((response) => response.json()),
5566
+ fetch("/api/cron-jobs").then((response) => response.json()),
5567
+ ]);
5568
+ renderMetrics(status);
5569
+ renderMessages(recent.items);
5570
+ renderEpisodes(episodeList.items);
5571
+ renderChats(chatList.items);
5572
+ renderFiles(fileList.items);
5573
+ renderFileJobs(jobList.items);
5574
+ renderQaLogs(qaLogList.items);
5575
+ renderCronJobs(cronJobList.items);
5576
+ } catch (error) {
5577
+ metrics.innerHTML = '<div class="empty">\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A' + escapeHtml(error instanceof Error ? error.message : String(error)) + '</div>';
5578
+ }
5571
5579
  }
5572
5580
 
5573
5581
  async function processNow() {
@@ -5627,7 +5635,6 @@ function buildHtml() {
5627
5635
  }
5628
5636
  }, 5000);
5629
5637
  </script>
5630
- <script src="/app.js"></script>
5631
5638
  </body>
5632
5639
  </html>`;
5633
5640
  }
@@ -5645,10 +5652,6 @@ function isAuthorizedWebAction(request, token) {
5645
5652
  const provided = readHeader(request.headers["x-chattercatcher-web-token"]);
5646
5653
  return provided === token;
5647
5654
  }
5648
- function extractInlineScript(html) {
5649
- const match = /<script>([\s\S]*)<\/script>/.exec(html);
5650
- return match?.[1] ?? "";
5651
- }
5652
5655
  function createWebApp(config) {
5653
5656
  const app = Fastify({ logger: false });
5654
5657
  const database = openDatabase(config);
@@ -5770,14 +5773,10 @@ function createWebApp(config) {
5770
5773
  };
5771
5774
  }
5772
5775
  });
5773
- app.get("/app.js", async (_request, reply) => {
5774
- await tokenReady;
5775
- reply.type("application/javascript; charset=utf-8");
5776
- return extractInlineScript(buildHtml()).replaceAll("__WEB_ACTION_TOKEN__", webActionToken);
5777
- });
5778
5776
  app.get("/", async (_request, reply) => {
5777
+ await tokenReady;
5779
5778
  reply.type("text/html; charset=utf-8");
5780
- return buildHtml();
5779
+ return buildHtml().replaceAll("__WEB_ACTION_TOKEN__", webActionToken);
5781
5780
  });
5782
5781
  return app;
5783
5782
  }