A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep a mailbox secret while another row uses the same address
Fei2411f333b11bce30
diff --git a/ds-bot/src/host/connectors/mail/index.js b/ds-bot/src/host/connectors/mail/index.jsindex cb193808..5d32e0fb 100644--- a/ds-bot/src/host/connectors/mail/index.js+++ b/ds-bot/src/host/connectors/mail/index.js@@ -339,7 +339,9 @@ export function install(rt, host) {const account = accountOf(body.id ?? body.address)if (account === undefined) throw new Error('No such account')await rt.loadSecrets()- for (const suffix of ['PASSWORD', 'TOKEN', 'REFRESH']) {+ // Secrets are per address; a duplicate row from before adds were merged still needs them.+ const shared = accountList().some(other => other.id !== account.id && other.address === account.address)+ if (!shared) for (const suffix of ['PASSWORD', 'TOKEN', 'REFRESH']) {const name = mailSecretName(account.address, suffix)if (rt.secretValue(name) !== undefined) await rt.secretEndpoint('secret-delete', { name }).catch(() => {})}diff --git a/ds-bot/test/connectors-engine.test.js b/ds-bot/test/connectors-engine.test.jsindex 1d10dc82..5f9c52b9 100644--- a/ds-bot/test/connectors-engine.test.js+++ b/ds-bot/test/connectors-engine.test.js@@ -680,6 +680,24 @@ test('mail account remove drops the secret and unregisters the tools', async (t)assert.equal(rt.teamTools.some(d => d.name === 'mail_send'), false)})+test('removing one of two rows for the same address keeps the shared secret', async (t) => {+ const address = addressAt('qq.com')+ const row = id => ({ id, address, provider: 'qq', auth: 'password', imap: { host: 'imap.qq.com', port: 993, secure: true }, smtp: { host: 'smtp.qq.com', port: 465, secure: true }, createdAt: 1 })+ const home = teamHome({ connectors: { mail: { accounts: { ma: row('ma'), mb: row('mb') } } } })+ const ctx = fakeContext()+ const rt = createRuntime(ctx, { home, github: false, mail: { connect: async () => fakeSession() } })+ t.after(async () => { await ctx.dispose(); rmSync(home, { recursive: true, force: true }) })+ await rt.load(); await rt.loadSecrets()+ await rt.secretEndpoint('secret-set', { name: mailSecretName(address, 'PASSWORD'), value: 'PASSP', scope: [] })+ await rt.connectorEndpoint('mail-account-remove', { id: 'ma' })+ await rt.loadSecrets()+ assert.equal(rt.secretValue(mailSecretName(address, 'PASSWORD')), 'PASSP')+ assert.deepEqual(rt.mailView().accounts.map(a => a.id), ['mb'])+ await rt.connectorEndpoint('mail-account-remove', { id: 'mb' })+ await rt.loadSecrets()+ assert.equal(rt.secretValue(mailSecretName(address, 'PASSWORD')), undefined)+})+const { imapOptions } = await import('../src/host/connectors/mail/transport.js')const { IMAP_ID } = await import('../src/host/connectors/mail/presets.js')