[fix] session
This commit is contained in:
4 files changed
+31
-4
No files matched your search
+14
-1
@@ -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
@@ -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 里按序回收。
|
||||
|
||||
+15
-1
@@ -69,6 +69,9 @@ export class MailDeliverer {
|
||||
const id = sessionId as 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: DriveHandle = {
|
||||
agent: live,
|
||||
off: this.watch(live),
|
||||
@@ -83,11 +86,22 @@ export class MailDeliverer {
|
||||
try {
|
||||
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: DriveHandle = {
|
||||
agent: handle.agent,
|
||||
off: this.watch(handle.agent),
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ 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。
|
||||
|
||||
Reference in new issue
Block a user