[feat] log

This commit is contained in:
zhhe committed 2026-11-17 07:58:03 +08:00
1 parent 1fcf56e3dd
commit 44e203d868
14 files changed
+305 -210

No files matched your search

+8 -1
View File
@@ -33,6 +33,7 @@ export class MailDeliverer {
content: [{ type: 'text', text: job.text }],
source: { kind: 'user' },
}));
this.onLog?.(`[mail] ${job.sessionId} 已交给模型,等待回复`);
}
dispose() {
this.offRoot();
@@ -61,12 +62,15 @@ export class MailDeliverer {
return borrowed;
}
let handle;
let created = false;
try {
handle = await this.ctx.agents.resume({ resumeSessionId: id });
}
catch {
handle = await this.ctx.agents.create({ sessionId: id });
created = true;
}
this.onLog?.(`[mail] ${sessionId} 会话已${created ? '创建' : '恢复'}`);
const owned = {
agent: handle.agent,
off: this.watch(handle.agent),
@@ -114,8 +118,11 @@ export class MailDeliverer {
this.pending.delete(sessionId);
if (!job)
return;
if (event.data.reason.kind !== 'completed' || !text)
if (event.data.reason.kind !== 'completed' || !text) {
this.onLog?.(`[mail] ${sessionId} 本轮未产生可回复文本(${event.data.reason.kind})`);
return;
}
this.onLog?.(`[mail] ${sessionId} 模型已回复,准备回信 ${job.from}`);
void this.onReply(job, text).catch(error => {
this.onLog?.(`[mail] 回信失败: ${error instanceof Error ? error.message : String(error)}`);
});