Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 导入的消息机器人自带凭证,不再要求另勾环境与连接
Chrisafacc1aefc34
diff --git a/apps/desktop/src/main/bot-import/__tests__/sources.test.ts b/apps/desktop/src/main/bot-import/__tests__/sources.test.tsindex db20f87ecb..2b8b96a55c 100644--- a/apps/desktop/src/main/bot-import/__tests__/sources.test.ts+++ b/apps/desktop/src/main/bot-import/__tests__/sources.test.ts@@ -239,9 +239,10 @@ describe('installed agent imports', () => {{ platform: 'feishu', name: 'Ada Lark', selected: false, enabled: false, owner: 'ou_fixtureowner' },{ platform: 'wecom', name: 'Ada', selected: true, enabled: undefined, owner: 'alice' },]);- expect(bots[1]!.credential?.value).toEqual({ appId: '${FEISHU_APP_ID}', appSecret: '${FEISHU_APP_SECRET}', account: 'default', service: 'lark', ownerUserId: 'ou_fixtureowner' });+ // A bot carries its own credential, so it never also requires selecting its token under connections.+ expect(bots[1]!.credential?.value).toEqual({ appId: 'cli_fixture', appSecret: 'fake-feishu-secret', account: 'default', service: 'lark', ownerUserId: 'ou_fixtureowner' });expect(bots[1]!.bot).toEqual({ platform: 'feishu', account: 'default', enabledPath: ['platforms', 'feishu', 'enabled'] });- for (const bot of bots) expect(bot.view.dependsOn!.every(id => snapshot.items.some(item => item.view.id === id && item.view.selected))).toBe(true);+ for (const bot of bots) expect(bot.view.dependsOn).toEqual([]);expect(JSON.stringify(bots.map(item => item.view))).not.toMatch(/fake-|cli_fixture|fixture-wecom/);// Controllers without the bots category keep today's Telegram / Discord connections and no others.const legacy = await inspectImportSource(source!, reader);diff --git a/apps/desktop/src/main/bot-import/sources.ts b/apps/desktop/src/main/bot-import/sources.tsindex 91ab6a5fc9..6eb0dc02a0 100644--- a/apps/desktop/src/main/bot-import/sources.ts+++ b/apps/desktop/src/main/bot-import/sources.ts@@ -188,7 +188,7 @@ async function connections(items: ImportItem[], source: ImportSource, values: Remcp: { name, enabled, ...(command ? { command, args: Array.isArray(record.args) ? record.args.map(string) : [], cwd, transport: 'stdio' as const } : { url, transport: record.transport === 'sse' ? 'sse' as const : 'http' as const }),env: scalarEnv(record.env), headers: scalarEnvHeaders(record.headers) } });}- if (bots) pushBotItems(items, await sourceBots(source, values, env, deps, budget, readText));+ if (bots) pushBotItems(items, await sourceBots(source, values, env, deps, budget, readText), env);else await legacyImBots(items, source, values, env, deps, budget, readText);// Keep native auth metadata without exposing its contents or inventing a refresh protocol.// API keys have a direct environment equivalent; provider OAuth needs its native refresh adapter.@@ -457,9 +457,16 @@ async function sourceBots(source: ImportSource, values: Record<string, unknown>,return source.kind === 'hermes' ? hermesBots(source, values, env) : openclawBots(source, values, env, deps, budget, readText, allAgents);}-/** One entry per bot; an ambiguous owner offers up to five exclusive alternatives, none preselected. */-function pushBotItems(items: ImportItem[], bots: SourceBot[]) {- for (const bot of bots) {+/**+ * One entry per bot; an ambiguous owner offers up to five exclusive alternatives, none preselected.+ * 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.+ */+function pushBotItems(items: ImportItem[], bots: SourceBot[], env: Record<string, string> = {}) {+ for (const original of bots) {+ const credential = Object.fromEntries(Object.entries(original.credential).map(([field, value]) =>+ [field, value.replace(REFERENCE, (match, name: string) => Object.hasOwn(env, name) ? env[name]! : match)]));+ const bot = { ...original, credential };const references = [...new Set(Object.values(bot.credential).flatMap(value => [...value.matchAll(REFERENCE)].map(match => match[1]!)))];const selected = bot.enabled && !bot.shared;const item = (id: string, owner: string | undefined, view: Partial<ImportItem['view']> = {}): ImportItem => ({@@ -524,7 +531,8 @@ export function createImportSourceReader(deps: SourceReaderDeps, budget = create}await connections(items, source, values, deps, budget, readText);// Mask every bot credential, including bots routed to other agents and platforms the legacy path skips.- pushBotItems(items, await sourceBots(source, values, await sourceEnvironment(source, values, budget, readText), deps, budget, readText, true));+ const env = await sourceEnvironment(source, values, budget, readText);+ pushBotItems(items, await sourceBots(source, values, env, deps, budget, readText, true), env);sourceConfiguration(items, source, values);return previewImportRedactions(items);};