Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(bots): 导入机器人接管要求明确主人,重启与回滚可续接,并核对原机器人未被更换

Chriscbe29bc17f50
diff --git a/apps/desktop/src/main/bot-import/__tests__/botTakeover.test.ts b/apps/desktop/src/main/bot-import/__tests__/botTakeover.test.ts
index e56dffc724..7a8758791f 100644
--- a/apps/desktop/src/main/bot-import/__tests__/botTakeover.test.ts
+++ b/apps/desktop/src/main/bot-import/__tests__/botTakeover.test.ts
@@ -22,6 +22,7 @@ else if (args[0] === 'config' && args[1] === 'patch') {
const merge = (node, patch) => { for (const [key, value] of Object.entries(patch)) { if (value === null) delete node[key]; else if (typeof value === 'object') merge(node[key] ??= {}, value); else node[key] = value; } };
merge(config, JSON.parse(fs.readFileSync(0, 'utf8')));
} else if (args[0] === 'gateway' && args[1] === 'restart') {
+ if (fs.existsSync(path.join(home, 'fail-restart'))) process.exit(1);
const stateFile = path.join(home, 'gateway_state.json');
if (!fs.existsSync(path.join(home, 'restart-keeps-live'))) {
const state = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
@@ -73,8 +74,8 @@ it('stops a live Hermes bot, restarts the gateway, waits for it to let go, then
expect(await t.calls()).toEqual(['config set platforms.telegram.enabled false', 'gateway restart']);
expect((await t.readConfig()).platforms.telegram.enabled).toBe(false);
expect(t.target.connect).toHaveBeenCalledTimes(1);
- expect(t.saves.map(record => record?.phase)).toEqual(['stopping', 'stopping', 'stopped', 'stopped', 'connected']);
- expect(t.saves.at(-1)).toEqual({ phase: 'connected', original: { present: false }, wasLive: true, changed: true, restarted: true });
+ expect(t.saves.map(record => record?.phase)).toEqual(['stopping', 'stopping', 'stopped', 'stopped', 'stopped', 'connected']);
+ expect(t.saves.at(-1)).toEqual({ phase: 'connected', original: { present: false }, wasLive: true, changed: true, restartRequested: true, restarted: true });
for (const call of await t.calls()) expect(call).not.toContain('fake-telegram-token');
});
@@ -118,6 +119,42 @@ it('does not connect when the source switch or the live bot does not stop', asyn
expect((await t.readConfig()).platforms.telegram.enabled).toBe(false);
});
+it('retries a gateway restart that did not succeed instead of waiting on it forever', async () => {
+ const t = await setup('hermes', { name: 'Ada' }, { live: true, env: telegramEnv });
+ await fs.writeFile(path.join(t.state, 'fail-restart'), '');
+ expect(await t.run()).toBe('IMPORT_IM_BOT_SOURCE_STOP_UNCONFIRMED');
+ const record = t.saves.at(-1)!;
+ expect(record).toMatchObject({ phase: 'stopped', restartRequested: true });
+ expect(record.restarted).toBeUndefined();
+ await fs.rm(path.join(t.state, 'fail-restart'));
+ expect(await t.run(record)).toBeUndefined();
+ expect((await t.calls()).filter(call => call === 'gateway restart')).toHaveLength(2);
+ expect(t.target.connect).toHaveBeenCalledTimes(1);
+});
+
+it('finishes an interrupted rollback and re-stops a source that came back on, never serving both sides', async () => {
+ const t = await setup('hermes', { name: 'Ada' }, { env: telegramEnv });
+ // Crash after the switch was restored but before the record was cleared.
+ const restoring: ImportBotRecord = { phase: 'restoring', original: { present: false }, wasLive: false, changed: true };
+ expect(await t.run(restoring)).toBe('IMPORT_IM_BOT_CONNECT_FAILED');
+ expect(t.target.connect).not.toHaveBeenCalled();
+ expect(t.saves.at(-1)).toBeUndefined();
+ // A "stopped" record whose source is enabled again is stopped once more before connecting.
+ expect(await t.run({ ...restoring, phase: 'stopped' })).toBeUndefined();
+ expect(await t.calls()).toEqual(['config unset platforms.telegram.enabled', 'config set platforms.telegram.enabled false']);
+ expect((await t.readConfig()).platforms.telegram.enabled).toBe(false);
+ expect(t.target.connect).toHaveBeenCalledTimes(1);
+});
+
+it('leaves a bot swapped in after the preview running and does not connect the old one', async () => {
+ const t = await setup('hermes', { name: 'Ada' }, { live: true, env: telegramEnv });
+ await fs.writeFile(path.join(t.state, '.env'), 'TELEGRAM_BOT_TOKEN=67890:fake-new-token\nTELEGRAM_ALLOWED_USERS=424242');
+ expect(await t.run()).toBe('IMPORT_IM_BOT_SOURCE_CHANGED');
+ expect(await t.calls()).toEqual([]);
+ expect(t.target.connect).not.toHaveBeenCalled();
+ expect(t.saves).toEqual([]);
+});
+
it('resumes an interrupted takeover without stopping or restarting twice', async () => {
const t = await setup('hermes', { name: 'Ada', platforms: { telegram: { enabled: false } } }, { env: telegramEnv });
const record: ImportBotRecord = { phase: 'stopped', original: { present: false }, wasLive: true, changed: true, restarted: true };
diff --git a/apps/desktop/src/main/bot-import/__tests__/sources.test.ts b/apps/desktop/src/main/bot-import/__tests__/sources.test.ts
index 2b8b96a55c..24bf9f8e7b 100644
--- a/apps/desktop/src/main/bot-import/__tests__/sources.test.ts
+++ b/apps/desktop/src/main/bot-import/__tests__/sources.test.ts
@@ -248,6 +248,17 @@ describe('installed agent imports', () => {
const legacy = await inspectImportSource(source!, reader);
expect(legacy.items.some(item => item.view.category === 'bots' || ['feishu', 'wecom'].includes(item.credential?.format ?? ''))).toBe(false);
expect(legacy.items.find(item => item.credential?.format === 'telegram')?.view).toMatchObject({ category: 'connections', name: 'Telegram · default' });
+ // Every platform needs a known owner before its source bot can be stopped.
+ await write('.hermes/.env', ['FEISHU_APP_ID=cli_fixture', 'FEISHU_APP_SECRET=fake-feishu-secret',
+ 'WECOM_BOT_ID=fixture-wecom', 'WECOM_SECRET=fake-wecom-secret', 'WECOM_ALLOWED_USERS=alice,bob'].join('\n'));
+ await write('.hermes/config.yaml', 'name: Ada\n');
+ const unowned = (await inspectImportSource(source!, reader, undefined, { bots: true })).items.filter(item => item.view.category === 'bots');
+ expect(unowned.map(({ view }) => [view.platform, view.owner, view.selected, view.issues])).toEqual([
+ ['feishu', undefined, true, ['IMPORT_IM_BOT_OWNER_MISSING']],
+ ['wecom', 'alice', false, undefined],
+ ['wecom', 'bob', false, undefined],
+ ]);
+ expect(unowned[1]!.view.exclusiveWith).toEqual([unowned[2]!.view.id]);
});
it('offers exclusive owner alternatives for a few allowed users and asks for an owner beyond five', async () => {
diff --git a/apps/desktop/src/main/bot-import/botTakeover.ts b/apps/desktop/src/main/bot-import/botTakeover.ts
index 0e675f7452..eb77faa5d2 100644
--- a/apps/desktop/src/main/bot-import/botTakeover.ts
+++ b/apps/desktop/src/main/bot-import/botTakeover.ts
@@ -1,6 +1,6 @@
import { promises as fs } from 'node:fs';
import path from 'node:path';
-import { readImportSourceBot, type SourceReaderDeps } from './sources.js';
+import { importBotIdentity, readImportSourceBot, readImportSourceBotIdentity, type SourceReaderDeps } from './sources.js';
import { resolveSourceCli } from './takeover.js';
import { importedProcessEnvironment, runImportedProcess } from './process.js';
import { CompanionImportError, object, string, type ImportItem, type ImportSource } from './types.js';
@@ -8,13 +8,17 @@ import type { ImportedImBotTarget } from './imBotConnections.js';
/** Durable per-bot progress in the import receipt; a retry resumes from it instead of stopping twice. */
export interface ImportBotRecord {
- phase: 'stopping' | 'stopped' | 'connected';
+ /** `restoring`: the companion could not connect and the source switch is being put back. */
+ phase: 'stopping' | 'stopped' | 'restoring' | 'connected';
/** The source switch before this import, restored when the companion cannot connect. */
original?: { present: boolean; value?: unknown };
/** This import turned the source switch off. */
changed?: boolean;
/** The source gateway was serving the bot when the import began. */
wasLive?: boolean;
+ /** A gateway restart was issued (it may have run even when unconfirmed), so a restore restarts again. */
+ restartRequested?: boolean;
+ /** The restart command succeeded; an unconfirmed restart is retried on the next attempt. */
restarted?: boolean;
}
@@ -110,16 +114,18 @@ export async function takeOverImportedBot(input: BotTakeoverInput): Promise<stri
: run(['config', 'patch', '--stdin'], JSON.stringify(nested(bot.enabledPath, present ? value : null)));
const liveness = () => source.kind === 'hermes' ? hermesLiveness(source, bot.platform, alive) : Promise.resolve({ live: false, parked: false });
const restartGateway = () => run(['gateway', 'restart'], undefined, 120_000);
- /** Only undo what this import did; a still-unknown restore keeps the record for the next retry. */
+ /** Only undo what this import did; a still-unknown restore keeps the `restoring` record for the next retry. */
const restore = async () => {
if (!record) return;
if (record.changed && record.original) {
+ // Durable before the switch flips back: a resumed import finishes the restore instead of connecting.
+ if (record.phase !== 'restoring') await save({ ...record, phase: 'restoring' });
try {
await setSwitch(record.original.value, record.original.present);
// The switch was on when this import turned it off.
if (!(await readImportSourceBot(source, bot)).enabled) return;
const { parked } = await liveness();
- if (record.restarted && !parked) await restartGateway();
+ if ((record.restartRequested || record.restarted) && !parked) await restartGateway();
} catch (error) {
if (error instanceof CompanionImportError && error.code === 'OWNER_CHANGED') throw error;
return;
@@ -129,21 +135,33 @@ export async function takeOverImportedBot(input: BotTakeoverInput): Promise<stri
};
try {
+ if (record?.phase === 'restoring') { await restore(); return 'IMPORT_IM_BOT_CONNECT_FAILED'; }
const existing = target.existing();
if (existing === 'self') { await save({ ...(record ?? {}), phase: 'connected' }); return undefined; }
if (existing === 'other') { await restore(); return 'IMPORT_IM_BOT_IN_USE'; }
+ /** The switch at this path must still belong to the previewed bot before this import touches it. */
+ const sameBot = async () => {
+ const current = await readImportSourceBotIdentity(source, bot, readers); assertOwner();
+ return !!current && current === importBotIdentity(item.credential?.value);
+ };
if (!record) {
// Nothing changes in the source before the companion side is known to be addable.
const blocked = await target.preflight(); assertOwner();
if (blocked) return blocked;
+ if (!(await sameBot())) return 'IMPORT_IM_BOT_SOURCE_CHANGED';
const before = await readImportSourceBot(source, bot); assertOwner();
const { live } = await liveness();
await save({ phase: 'stopping', original: { present: before.present, ...(before.present ? { value: before.value } : {}) },
wasLive: source.kind === 'hermes' ? live : before.enabled });
+ } else if (record.phase === 'stopped' && (await readImportSourceBot(source, bot)).enabled) {
+ // The source came back on after an earlier stop: stop it again before connecting.
+ await save({ ...record, phase: 'stopping' });
}
if (record!.phase === 'stopping') {
if ((await readImportSourceBot(source, bot)).enabled) {
cli ??= await resolveSourceCli(source, readers.home, readers.env); assertOwner();
+ // Only an unchanged bot is ever switched off by this import.
+ if (!record!.changed && !(await sameBot())) { await save(undefined); return 'IMPORT_IM_BOT_SOURCE_CHANGED'; }
await save({ ...record!, changed: true });
await setSwitch(false);
if ((await readImportSourceBot(source, bot)).enabled) {
@@ -158,8 +176,8 @@ export async function takeOverImportedBot(input: BotTakeoverInput): Promise<stri
let state = await liveness();
// A restart would unpark a parked profile, so a parked bot is never restarted.
if (state.live && !state.parked && !record!.restarted) {
- await save({ ...record!, restarted: true });
- await restartGateway();
+ await save({ ...record!, restartRequested: true });
+ if (await restartGateway()) await save({ ...record!, restarted: true });
state = await liveness();
}
const deadline = timing.now() + timing.timeoutMs;
@@ -173,6 +191,8 @@ export async function takeOverImportedBot(input: BotTakeoverInput): Promise<stri
// OpenClaw hot-reloads channel config; Telegram's conflict window still catches a slow stop.
await timing.sleep(timing.settleMs); assertOwner();
}
+ // Confirm once more right before connecting: both sides must never serve the bot together.
+ if ((await readImportSourceBot(source, bot)).enabled) return 'IMPORT_IM_BOT_SOURCE_STOP_UNCONFIRMED';
const issue = await target.connect(); assertOwner();
if (!issue) { await save({ ...record!, phase: 'connected' }); return undefined; }
await restore();
diff --git a/apps/desktop/src/main/bot-import/imBotConnections.ts b/apps/desktop/src/main/bot-import/imBotConnections.ts
index 71ec8a9a32..ea63a7a445 100644
--- a/apps/desktop/src/main/bot-import/imBotConnections.ts
+++ b/apps/desktop/src/main/bot-import/imBotConnections.ts
@@ -45,7 +45,8 @@ export function importedImBotTarget(botId: string, credential: { format: string;
const channel = credential.format;
if (!['telegram', 'discord', 'feishu', 'wecom', 'dingtalk'].includes(channel)) return 'IMPORT_IM_BOT_CONNECT_FAILED';
const owner = string(value.ownerUserId);
- if ((channel === 'telegram' || channel === 'discord') && !owner) return 'IMPORT_IM_BOT_OWNER_MISSING';
+ // Without a known owner the companion would adopt whoever messages the bot first.
+ if (!owner) return 'IMPORT_IM_BOT_OWNER_MISSING';
let input: BotImConnectionAddInput;
try {
input = parseBotImConnectionAddInput({ botId, channel, token: value.token, ownerUserId: owner, appId: value.appId, appSecret: value.appSecret,
diff --git a/apps/desktop/src/main/bot-import/sources.ts b/apps/desktop/src/main/bot-import/sources.ts
index 6eb0dc02a0..55ca7de78b 100644
--- a/apps/desktop/src/main/bot-import/sources.ts
+++ b/apps/desktop/src/main/bot-import/sources.ts
@@ -303,7 +303,7 @@ interface SourceBot {
enabled: boolean;
enabledPath: string[];
owner?: string;
- /** Telegram / Discord allowed users when no single owner is evident. */
+ /** Allowed users when no single owner is evident. */
ownerCandidates?: string[];
/** Other agents also route through this bot: stopping it affects them, so it is not preselected. */
shared?: boolean;
@@ -368,11 +368,11 @@ function hermesBots(source: ImportSource, values: Record<string, unknown>, env:
: { appKey: value('DINGTALK_CLIENT_ID', extra.client_id), appSecret: value('DINGTALK_CLIENT_SECRET', extra.client_secret) };
if (Object.values(fields).some(field => !field)) continue;
const domain = string(env.FEISHU_DOMAIN) || string(extra.domain);
- // Feishu: only a single open_id admin; WeCom / DingTalk: only a single explicit allowed user.
+ // Feishu: open_id admins; WeCom / DingTalk: explicit allowed users.
const owners = platform === 'feishu' ? userIds(listOf(extra.admins), [], /^ou_[A-Za-z0-9_-]{1,128}$/) : allowed(PLAIN_USER_ID);
bots.push({ platform, account: 'default', name: sourceBotName(source, 'default', platform === 'feishu' ? env.FEISHU_BOT_NAME : '', extra.bot_name, block.name),
credential: fields, ...(platform === 'feishu' ? { service: /lark/i.test(domain) ? 'lark' as const : 'feishu' as const } : {}),
- enabled, enabledPath, ...(owners.length === 1 ? { owner: owners[0] } : {}) });
+ enabled, enabledPath, ...inferOwner(owners) });
}
return bots;
}
@@ -423,9 +423,8 @@ async function openclawBots(source: ImportSource, values: Record<string, unknown
const pattern = /^ou_[A-Za-z0-9_-]{1,128}$/;
const owners = prefixed('feishu', pattern);
const allowed = owners.length ? owners : userIds(listOf(merged.allowFrom), ['feishu:', 'lark:'], pattern);
- const owner = allowed.length === 1 ? allowed[0] : undefined;
bots.push({ platform, account, name, credential: { appId, appSecret }, service: domain === 'lark' || /larksuite/i.test(domain) ? 'lark' : 'feishu',
- enabled, enabledPath, shared: route.shared, ...(owner ? { owner } : {}) });
+ enabled, enabledPath, shared: route.shared, ...inferOwner(allowed) });
continue;
}
let token = platform === 'telegram' ? '' : secretReference(merged.token);
@@ -459,6 +458,7 @@ async function sourceBots(source: ImportSource, values: Record<string, unknown>,
/**
* One entry per bot; an ambiguous owner offers up to five exclusive alternatives, none preselected.
+ * Every platform needs a known owner: the companion would otherwise adopt whoever messages it first.
* A bot carries its own credential: references the source environment defines are resolved here,
* so importing the bot never also requires selecting its token under connections.
*/
@@ -478,7 +478,7 @@ function pushBotItems(items: ImportItem[], bots: SourceBot[], env: Record<string
});
const id = entryId(bot.platform, bot.account);
const candidates = bot.owner ? [] : bot.ownerCandidates ?? [];
- if (bot.owner || (bot.platform !== 'telegram' && bot.platform !== 'discord')) items.push(item(id, bot.owner));
+ if (bot.owner) items.push(item(id, bot.owner));
else if (candidates.length > 1 && candidates.length <= BOT_OWNER_ALTERNATIVES) {
const ids = candidates.map(owner => entryId(bot.platform, `${bot.account}\0owner:${owner}`));
candidates.forEach((owner, index) => items.push(item(ids[index]!, owner, { selected: false, exclusiveWith: ids.filter((_id, other) => other !== index) })));
@@ -486,6 +486,26 @@ function pushBotItems(items: ImportItem[], bots: SourceBot[], env: Record<string
}
}
+const BOT_IDENTITY_FIELDS = ['token', 'appId', 'wecomBotId', 'appKey'] as const;
+
+/** The platform identity (token / app ID / bot ID) of one bot credential. */
+export function importBotIdentity(credential: unknown): string {
+ const value = object(credential);
+ return BOT_IDENTITY_FIELDS.map(field => string(value[field])).find(Boolean) ?? '';
+}
+
+/** The bot's current identity in its source, re-read with the source's own environment; '' when it is gone. */
+export async function readImportSourceBotIdentity(source: ImportSource, bot: NonNullable<ImportItem['bot']>, deps: SourceReaderDeps): Promise<string> {
+ const budget = createImportBudget();
+ const values = await config(path.dirname(source.configFile), source.configFile, budget);
+ const env = await sourceEnvironment(source, values, budget);
+ const found = (await sourceBots(source, values, env, deps, budget, optionalText, true))
+ .find(candidate => candidate.platform === bot.platform && candidate.account === bot.account);
+ if (!found) return '';
+ return importBotIdentity(Object.fromEntries(Object.entries(found.credential).map(([field, value]) =>
+ [field, value.replace(REFERENCE, (match, name: string) => Object.hasOwn(env, name) ? env[name]! : match)])));
+}
+
/** Current source switch for one imported bot, re-read from its native config. */
export async function readImportSourceBot(source: ImportSource, bot: NonNullable<ImportItem['bot']>): Promise<{ enabled: boolean; present: boolean; value?: unknown }> {
const values = await config(path.dirname(source.configFile), source.configFile, createImportBudget());
diff --git a/apps/desktop/src/main/bot-import/transfer.ts b/apps/desktop/src/main/bot-import/transfer.ts
index 945cc5282d..abf3b4c361 100644
--- a/apps/desktop/src/main/bot-import/transfer.ts
+++ b/apps/desktop/src/main/bot-import/transfer.ts
@@ -72,6 +72,7 @@ export const IMPORT_IM_BOT_ISSUES: ReadonlySet<string> = new Set([
'IMPORT_IM_BOT_IN_USE',
'IMPORT_IM_BOT_CONNECT_FAILED',
'IMPORT_IM_BOT_SOURCE_STOP_UNCONFIRMED',
+ 'IMPORT_IM_BOT_SOURCE_CHANGED',
]);
const IM_BOT_FORMATS = new Set(['telegram', 'discord']);
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 3039738541..b99d04c468 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -9825,6 +9825,7 @@
"imBotInUse": "This bot is already connected on this computer, in Settings → IM bots or on another teammate.",
"imBotConnectFailed": "Couldn’t connect this bot. Try again on the teammate’s Messaging platforms page.",
"imBotSourceStopUnconfirmed": "The original bot hasn’t stopped yet, so it wasn’t handed to the teammate. You can connect it later on the teammate’s Messaging platforms page.",
+ "imBotSourceChanged": "The original bot changed after the preview, so it wasn’t stopped. Reload the preview and import again.",
"bots": "Messaging bots",
"botsNote": "After import, these bots stop in {{source}} and the teammate takes them over.",
"sourceDisabled": "Already off",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index e8d00703eb..cfb1592c92 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -9779,6 +9779,7 @@
"imBotInUse": "このボットはすでにこのコンピューターで使われています(設定 → IM ボット、または別の仲間)。",
"imBotConnectFailed": "このボットに接続できませんでした。仲間の「メッセージプラットフォーム」ページでやり直してください。",
"imBotSourceStopUnconfirmed": "元のボットがまだ停止していないため、仲間に引き継いでいません。あとで仲間の「メッセージプラットフォーム」ページで接続できます。",
+ "imBotSourceChanged": "プレビュー後に元のボットが変更されたため、停止していません。再読み込みしてからインポートしてください。",
"bots": "メッセージボット",
"botsNote": "インポート後、{{source}} のこれらのボットは停止し、仲間が引き継ぎます。",
"sourceDisabled": "元から停止中",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 8239666449..ef1103e28a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -9779,6 +9779,7 @@
"imBotInUse": "이 봇은 이미 이 컴퓨터에서 사용 중입니다 (설정 → IM 봇, 또는 다른 동료).",
"imBotConnectFailed": "이 봇에 연결하지 못했습니다. 동료의 메시지 플랫폼 페이지에서 다시 시도하세요.",
"imBotSourceStopUnconfirmed": "기존 봇이 아직 멈추지 않아 동료에게 넘기지 않았습니다. 나중에 동료의 메시지 플랫폼 페이지에서 연결할 수 있습니다.",
+ "imBotSourceChanged": "미리보기 후 기존 봇이 바뀌어 중지하지 않았습니다. 다시 읽은 뒤 가져오세요.",
"bots": "메시지 봇",
"botsNote": "가져온 후 {{source}}의 이 봇들은 중지되고 동료가 이어받습니다.",
"sourceDisabled": "원래 사용 중지됨",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index a15e8a7f17..2fd2050451 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -9779,6 +9779,7 @@
"imBotInUse": "这个机器人已经在这台电脑上用了:在 设置 → IM 机器人 里,或者在另一位伙伴那里。",
"imBotConnectFailed": "没能连上这个机器人,请到伙伴的「消息平台」页重试。",
"imBotSourceStopUnconfirmed": "原来的机器人还没停下,暂时没有接给伙伴。可以稍后在伙伴的「消息平台」页连接。",
+ "imBotSourceChanged": "原来的机器人在预览后换过了,没有停用它。请重新读取后再导入。",
"bots": "消息机器人",
"botsNote": "导入后,{{source}} 里的这些机器人会停用,由伙伴接管。",
"sourceDisabled": "原来已停用",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 83b57b4513..aaf651ddc8 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -9779,6 +9779,7 @@
"imBotInUse": "這個機器人已經在這台電腦上使用了:在 設定 → IM 機器人 裡,或是在另一位夥伴那裡。",
"imBotConnectFailed": "沒能連上這個機器人,請到夥伴的「訊息平台」頁重試。",
"imBotSourceStopUnconfirmed": "原本的機器人還沒停下,暫時沒有接給夥伴。可以稍後在夥伴的「訊息平台」頁連線。",
+ "imBotSourceChanged": "原本的機器人在預覽後換過了,沒有停用它。請重新讀取後再匯入。",
"bots": "訊息機器人",
"botsNote": "匯入後,{{source}} 裡的這些機器人會停用,由夥伴接管。",
"sourceDisabled": "原本已停用",
diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.json
index c8ebc1ebd4..ac3d6ff68b 100644
--- a/apps/mobile/src/i18n/locales/en/devices.json
+++ b/apps/mobile/src/i18n/locales/en/devices.json
@@ -825,6 +825,7 @@
"imBotInUse": "This bot is already connected on this computer, in Settings → IM bots or on another teammate.",
"imBotConnectFailed": "Couldn’t connect this bot. Try again on the teammate’s Messaging platforms page.",
"imBotSourceStopUnconfirmed": "The original bot hasn’t stopped yet, so it wasn’t handed to the teammate. You can connect it later on the teammate’s Messaging platforms page.",
+ "imBotSourceChanged": "The original bot changed after the preview, so it wasn’t stopped. Reload the preview and import again.",
"bots": "Messaging bots",
"botsNote": "After import, these bots stop in {{source}} and the teammate takes them over.",
"sourceDisabled": "Already off",
diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.json
index 5af3d6a55f..7706b0fb89 100644
--- a/apps/mobile/src/i18n/locales/ja/devices.json
+++ b/apps/mobile/src/i18n/locales/ja/devices.json
@@ -825,6 +825,7 @@
"imBotInUse": "このボットはすでにこのコンピューターで使われています(設定 → IM ボット、または別の仲間)。",
"imBotConnectFailed": "このボットに接続できませんでした。仲間の「メッセージプラットフォーム」ページでやり直してください。",
"imBotSourceStopUnconfirmed": "元のボットがまだ停止していないため、仲間に引き継いでいません。あとで仲間の「メッセージプラットフォーム」ページで接続できます。",
+ "imBotSourceChanged": "プレビュー後に元のボットが変更されたため、停止していません。再読み込みしてからインポートしてください。",
"bots": "メッセージボット",
"botsNote": "インポート後、{{source}} のこれらのボットは停止し、仲間が引き継ぎます。",
"sourceDisabled": "元から停止中",
diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.json
index 1fd0d84afa..c658b98ae7 100644
--- a/apps/mobile/src/i18n/locales/ko/devices.json
+++ b/apps/mobile/src/i18n/locales/ko/devices.json
@@ -825,6 +825,7 @@
"imBotInUse": "이 봇은 이미 이 컴퓨터에서 사용 중입니다 (설정 → IM 봇, 또는 다른 동료).",
"imBotConnectFailed": "이 봇에 연결하지 못했습니다. 동료의 메시지 플랫폼 페이지에서 다시 시도하세요.",
"imBotSourceStopUnconfirmed": "기존 봇이 아직 멈추지 않아 동료에게 넘기지 않았습니다. 나중에 동료의 메시지 플랫폼 페이지에서 연결할 수 있습니다.",
+ "imBotSourceChanged": "미리보기 후 기존 봇이 바뀌어 중지하지 않았습니다. 다시 읽은 뒤 가져오세요.",
"bots": "메시지 봇",
"botsNote": "가져온 후 {{source}}의 이 봇들은 중지되고 동료가 이어받습니다.",
"sourceDisabled": "원래 사용 중지됨",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.json
index 3e8da0b059..074a78d00a 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json
@@ -825,6 +825,7 @@
"imBotInUse": "这个机器人已经在这台电脑上用了:在 设置 → IM 机器人 里,或者在另一位伙伴那里。",
"imBotConnectFailed": "没能连上这个机器人,请到伙伴的「消息平台」页重试。",
"imBotSourceStopUnconfirmed": "原来的机器人还没停下,暂时没有接给伙伴。可以稍后在伙伴的「消息平台」页连接。",
+ "imBotSourceChanged": "原来的机器人在预览后换过了,没有停用它。请重新读取后再导入。",
"bots": "消息机器人",
"botsNote": "导入后,{{source}} 里的这些机器人会停用,由伙伴接管。",
"sourceDisabled": "原来已停用",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.json
index fd75039e33..9fb481904d 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json
@@ -825,6 +825,7 @@
"imBotInUse": "這個機器人已經在這台電腦上使用了:在 設定 → IM 機器人 裡,或是在另一位夥伴那裡。",
"imBotConnectFailed": "沒能連上這個機器人,請到夥伴的「訊息平台」頁重試。",
"imBotSourceStopUnconfirmed": "原本的機器人還沒停下,暫時沒有接給夥伴。可以稍後在夥伴的「訊息平台」頁連線。",
+ "imBotSourceChanged": "原本的機器人在預覽後換過了,沒有停用它。請重新讀取後再匯入。",
"bots": "訊息機器人",
"botsNote": "匯入後,{{source}} 裡的這些機器人會停用,由夥伴接管。",
"sourceDisabled": "原本已停用",
diff --git a/packages/maker-shared/src/companionImport.ts b/packages/maker-shared/src/companionImport.ts
index 8c61751780..2d93e508f8 100644
--- a/packages/maker-shared/src/companionImport.ts
+++ b/packages/maker-shared/src/companionImport.ts
@@ -256,6 +256,8 @@ export function companionImportReasonKey(code?: string): string {
IMPORT_IM_BOT_IN_USE: 'imBotInUse', IMPORT_IM_BOT_CONNECT_FAILED: 'imBotConnectFailed',
// 原 Agent 里的机器人没能确认停下,没有接给伙伴。
IMPORT_IM_BOT_SOURCE_STOP_UNCONFIRMED: 'imBotSourceStopUnconfirmed',
+ // 预览后原来位置上的机器人换了,没有停用它。
+ IMPORT_IM_BOT_SOURCE_CHANGED: 'imBotSourceChanged',
};
return code && keys[code] || 'itemFailed';
}