[fix] session

This commit is contained in:
zhhe committed 2026-11-17 08:17:54 +08:00
1 parent 44e203d868
commit 14b6a546d0
4 files changed
+31 -4

No files matched your search

+14 -1
View File
@@ -53,6 +53,9 @@ export class MailDeliverer {
const id = sessionId;
const live = this.ctx.agents.get(id);
if (live) {
if (this.ctx.sessions.get(id) !== live.session) {
throw new Error(`会话 ${sessionId} 未进入全局 SessionStore`);
}
const borrowed = {
agent: live,
off: this.watch(live),
@@ -67,10 +70,20 @@ export class MailDeliverer {
handle = await this.ctx.agents.resume({ resumeSessionId: id });
}
catch {
handle = await this.ctx.agents.create({ sessionId: id });
// 与 ACP 的外部会话创建路径一致:cwd 是持久会话的工作区元数据。
handle = await this.ctx.agents.create({
sessionId: id,
meta: { cwd: process.cwd() },
});
created = true;
}
this.onLog?.(`[mail] ${sessionId} 会话已${created ? '创建' : '恢复'}`);
// DeepSeek 请求扩展通过全局 SessionStore 上传 dsh_session_log。若这里不可见,
// 继续 followup 只会让服务端按 sessionId 加载一份不存在的历史。
if (this.ctx.sessions.get(id) !== handle.agent.session) {
await handle.dispose();
throw new Error(`会话 ${sessionId} 创建后未进入全局 SessionStore`);
}
const owned = {
agent: handle.agent,
off: this.watch(handle.agent),
+1 -1
View File
@@ -3,7 +3,7 @@ import { MailGateway } from './gateway.js';
import { MailGatewayService } from './service.js';
export { Config } from './config.js';
export const name = 'dsh-mail-sender';
export const inject = ['agents', 'settings'];
export const inject = ['agents', 'sessions', 'settings'];
/**
* 常驻入口:邮件驱动会话,而不是等待模型调用的 Tool。
* 所有 IMAP/SMTP 资源与监听都收在 ctx.effect 里按序回收。