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 +34 -35
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -189,6 +189,7 @@ interface ChatMessage {
|
|
|
189
189
|
content: string;
|
|
190
190
|
toolCallId?: string;
|
|
191
191
|
toolCalls?: ToolCall[];
|
|
192
|
+
reasoningContent?: string;
|
|
192
193
|
}
|
|
193
194
|
interface ChatTool {
|
|
194
195
|
name: string;
|
|
@@ -198,6 +199,7 @@ interface ChatTool {
|
|
|
198
199
|
interface ToolChatResult {
|
|
199
200
|
content: string;
|
|
200
201
|
toolCalls: ToolCall[];
|
|
202
|
+
reasoningContent?: string;
|
|
201
203
|
}
|
|
202
204
|
interface ChatModel {
|
|
203
205
|
complete(messages: ChatMessage[]): Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -205,7 +205,7 @@ async function generateCronJobMessage(input) {
|
|
|
205
205
|
let toolCallsUsed = 0;
|
|
206
206
|
for (let turn = 0; turn < maxModelTurns; turn += 1) {
|
|
207
207
|
const result = await input.model.completeWithTools(messages, input.tools);
|
|
208
|
-
messages.push({ role: "assistant", content: result.content, toolCalls: result.toolCalls });
|
|
208
|
+
messages.push({ role: "assistant", content: result.content, toolCalls: result.toolCalls, reasoningContent: result.reasoningContent });
|
|
209
209
|
if (result.toolCalls.length === 0) {
|
|
210
210
|
break;
|
|
211
211
|
}
|
|
@@ -1389,7 +1389,8 @@ function toOpenAIMessage(message) {
|
|
|
1389
1389
|
arguments: JSON.stringify(toolCall.input)
|
|
1390
1390
|
}
|
|
1391
1391
|
}))
|
|
1392
|
-
} : {}
|
|
1392
|
+
} : {},
|
|
1393
|
+
...message.reasoningContent ? { reasoning_content: message.reasoningContent } : {}
|
|
1393
1394
|
};
|
|
1394
1395
|
}
|
|
1395
1396
|
function toOpenAITool(tool) {
|
|
@@ -1435,7 +1436,8 @@ var OpenAICompatibleChatModel = class {
|
|
|
1435
1436
|
throw new Error(`LLM \u8BF7\u6C42\u5931\u8D25\uFF1A${response.status} ${body}`);
|
|
1436
1437
|
}
|
|
1437
1438
|
const data = await response.json();
|
|
1438
|
-
const
|
|
1439
|
+
const message = data.choices?.[0]?.message;
|
|
1440
|
+
const content = message?.content?.trim();
|
|
1439
1441
|
if (!content) {
|
|
1440
1442
|
throw new Error("LLM \u8FD4\u56DE\u4E3A\u7A7A\u3002");
|
|
1441
1443
|
}
|
|
@@ -1467,7 +1469,8 @@ var OpenAICompatibleChatModel = class {
|
|
|
1467
1469
|
const message = data.choices?.[0]?.message;
|
|
1468
1470
|
return {
|
|
1469
1471
|
content: message?.content ?? "",
|
|
1470
|
-
toolCalls: parseToolCalls(message)
|
|
1472
|
+
toolCalls: parseToolCalls(message),
|
|
1473
|
+
reasoningContent: message?.reasoning_content ?? void 0
|
|
1471
1474
|
};
|
|
1472
1475
|
}
|
|
1473
1476
|
};
|
|
@@ -3656,7 +3659,8 @@ async function runFeishuToolLoop(input) {
|
|
|
3656
3659
|
messages.push({
|
|
3657
3660
|
role: "assistant",
|
|
3658
3661
|
content: assistantResult.content,
|
|
3659
|
-
toolCalls: assistantResult.toolCalls
|
|
3662
|
+
toolCalls: assistantResult.toolCalls,
|
|
3663
|
+
reasoningContent: assistantResult.reasoningContent
|
|
3660
3664
|
});
|
|
3661
3665
|
if (assistantResult.toolCalls.length === 0) {
|
|
3662
3666
|
return assistantResult.content || FEISHU_TOOL_LOOP_FALLBACK;
|
|
@@ -5128,24 +5132,28 @@ function buildHtml() {
|
|
|
5128
5132
|
}
|
|
5129
5133
|
|
|
5130
5134
|
async function load() {
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5135
|
+
try {
|
|
5136
|
+
const [status, recent, episodeList, chatList, fileList, jobList, qaLogList, cronJobList] = await Promise.all([
|
|
5137
|
+
fetch("/api/status").then((response) => response.json()),
|
|
5138
|
+
fetch("/api/messages/recent?limit=20").then((response) => response.json()),
|
|
5139
|
+
fetch("/api/episodes?limit=10").then((response) => response.json()),
|
|
5140
|
+
fetch("/api/chats").then((response) => response.json()),
|
|
5141
|
+
fetch("/api/files").then((response) => response.json()),
|
|
5142
|
+
fetch("/api/file-jobs").then((response) => response.json()),
|
|
5143
|
+
fetch("/api/qa-logs?limit=10").then((response) => response.json()),
|
|
5144
|
+
fetch("/api/cron-jobs").then((response) => response.json()),
|
|
5145
|
+
]);
|
|
5146
|
+
renderMetrics(status);
|
|
5147
|
+
renderMessages(recent.items);
|
|
5148
|
+
renderEpisodes(episodeList.items);
|
|
5149
|
+
renderChats(chatList.items);
|
|
5150
|
+
renderFiles(fileList.items);
|
|
5151
|
+
renderFileJobs(jobList.items);
|
|
5152
|
+
renderQaLogs(qaLogList.items);
|
|
5153
|
+
renderCronJobs(cronJobList.items);
|
|
5154
|
+
} catch (error) {
|
|
5155
|
+
metrics.innerHTML = '<div class="empty">\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A' + escapeHtml(error instanceof Error ? error.message : String(error)) + '</div>';
|
|
5156
|
+
}
|
|
5149
5157
|
}
|
|
5150
5158
|
|
|
5151
5159
|
async function processNow() {
|
|
@@ -5205,7 +5213,6 @@ function buildHtml() {
|
|
|
5205
5213
|
}
|
|
5206
5214
|
}, 5000);
|
|
5207
5215
|
</script>
|
|
5208
|
-
<script src="/app.js"></script>
|
|
5209
5216
|
</body>
|
|
5210
5217
|
</html>`;
|
|
5211
5218
|
}
|
|
@@ -5223,10 +5230,6 @@ function isAuthorizedWebAction(request, token) {
|
|
|
5223
5230
|
const provided = readHeader(request.headers["x-chattercatcher-web-token"]);
|
|
5224
5231
|
return provided === token;
|
|
5225
5232
|
}
|
|
5226
|
-
function extractInlineScript(html) {
|
|
5227
|
-
const match = /<script>([\s\S]*)<\/script>/.exec(html);
|
|
5228
|
-
return match?.[1] ?? "";
|
|
5229
|
-
}
|
|
5230
5233
|
function createWebApp(config) {
|
|
5231
5234
|
const app = Fastify({ logger: false });
|
|
5232
5235
|
const database = openDatabase(config);
|
|
@@ -5348,14 +5351,10 @@ function createWebApp(config) {
|
|
|
5348
5351
|
};
|
|
5349
5352
|
}
|
|
5350
5353
|
});
|
|
5351
|
-
app.get("/app.js", async (_request, reply) => {
|
|
5352
|
-
await tokenReady;
|
|
5353
|
-
reply.type("application/javascript; charset=utf-8");
|
|
5354
|
-
return extractInlineScript(buildHtml()).replaceAll("__WEB_ACTION_TOKEN__", webActionToken);
|
|
5355
|
-
});
|
|
5356
5354
|
app.get("/", async (_request, reply) => {
|
|
5355
|
+
await tokenReady;
|
|
5357
5356
|
reply.type("text/html; charset=utf-8");
|
|
5358
|
-
return buildHtml();
|
|
5357
|
+
return buildHtml().replaceAll("__WEB_ACTION_TOKEN__", webActionToken);
|
|
5359
5358
|
});
|
|
5360
5359
|
return app;
|
|
5361
5360
|
}
|