Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
plugin tasks: prefer the lightest effort across the auxiliary chain; quiet library sync without a focused session
Dash4adb0884d4d9
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskDefaultRoute.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskDefaultRoute.test.tsindex dcd9b2ebb8..3d9825c987 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskDefaultRoute.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskDefaultRoute.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from 'vitest';import { encodeCatalogModelPin } from '../../../shared/catalogModelPin.js';-import { auxiliaryChainSessionCandidates, pluginTaskSelectionIsOpen } from '../pluginTaskDefaultRoute.js';+import { auxiliaryChainSessionCandidates, pluginTaskRouteAttempts, pluginTaskSelectionIsOpen } from '../pluginTaskDefaultRoute.js';describe('auxiliaryChainSessionCandidates', () => {// Rule: a plugin's own persistent task (no originating session) follows the@@ -21,6 +21,16 @@ describe('auxiliaryChainSessionCandidates', () => {]);});+ // Rule: a chain head without a light effort level yields to a later candidate+ // that has one; default efforts are only a last pass. tier: unit.+ it('tries every candidate at a light effort before any candidate at its default', () => {+ expect(pluginTaskRouteAttempts(['a', 'b'])).toEqual([+ { candidate: 'a', effort: 'low' }, { candidate: 'a', effort: 'medium' },+ { candidate: 'b', effort: 'low' }, { candidate: 'b', effort: 'medium' },+ { candidate: 'a', effort: undefined }, { candidate: 'b', effort: undefined },+ ]);+ });+it('treats any explicit identifying field as a closed selection', () => {expect(pluginTaskSelectionIsOpen({})).toBe(true);expect(pluginTaskSelectionIsOpen({ effort: 'low' })).toBe(true);diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.tsindex abf818ee54..8cd801ead1 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest';import { readFileSync } from 'node:fs';import { createHash } from 'node:crypto';import ts from 'typescript';-import { pluginTaskSelectionIsOpen } from '../pluginTaskDefaultRoute.js';+import { pluginTaskRouteAttempts, pluginTaskSelectionIsOpen } from '../pluginTaskDefaultRoute.js';import { createSessionExecutionResolver } from '../sessionExecutionSelection.js';import { Session } from '@cindy/maker-core';import { fastModeToStorage } from '@cindy/maker-shared';@@ -1423,14 +1423,17 @@ it('an open plugin selection without a source session follows the auxiliary chaiactiveOwnerScopeKey: () => 'owner', assertPlugin: () => {}, getPluginTaskSourceSessionId: () => sourceSessionId,resolveSessionExecution: resolver, PluginTaskError, routeUnavailable: () => { throw Error('unavailable'); },getEffectiveAuxiliaryModelRefs: () => ['chain'], getEffectiveAuxiliaryModelChainSnapshot: () => 'chain',- auxiliaryChainSessionCandidates: () => candidates, pluginTaskSelectionIsOpen };+ auxiliaryChainSessionCandidates: () => candidates, pluginTaskRouteAttempts, pluginTaskSelectionIsOpen };const js = ts.transpileModule(`${resolve}\nreturn resolveRoute;`, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;return new Function(...Object.keys(deps), js)(...Object.values(deps))('p') as Promise<{ model: string; effort: string }>;};// First usable candidate wins, at low effort.await expect(run([{ agentKind: 'codex', providerId: f.route.providerId, model: 'missing' }, { agentKind: 'codex', providerId: f.route.providerId, model: 'cheap' }])).resolves.toMatchObject({ model: 'cheap', effort: 'low' });- // A model without a low effort level still routes, at its default effort.+ // A chain head without a light effort level yields to the next candidate that has one.+ await expect(run([{ agentKind: 'codex', providerId: f.route.providerId, model: 'nolow' }, { agentKind: 'codex', providerId: f.route.providerId, model: 'cheap' }]))+ .resolves.toMatchObject({ model: 'cheap', effort: 'low' });+ // Only when no candidate offers a light level does a model route at its default effort.await expect(run([{ agentKind: 'codex', providerId: f.route.providerId, model: 'nolow' }])).resolves.toMatchObject({ model: 'nolow' });// No usable candidate: the new-task selection remains the last resort.await expect(run([{ agentKind: 'codex', providerId: f.route.providerId, model: 'missing' }])).resolves.toMatchObject({ model: 'next', effort: 'high' });@@ -1498,7 +1501,7 @@ it.each([resolveSessionExecution: resolver, PluginTaskError, routeUnavailable: () => { throw Error('unavailable'); },// No auxiliary chain configured in this scenario: the new-task selection stays the inherited default.getEffectiveAuxiliaryModelRefs: () => [], getEffectiveAuxiliaryModelChainSnapshot: () => '',- auxiliaryChainSessionCandidates: () => [], pluginTaskSelectionIsOpen };+ auxiliaryChainSessionCandidates: () => [], pluginTaskRouteAttempts, pluginTaskSelectionIsOpen };const js = ts.transpileModule(`${resolve}\nreturn {${preference} resolveRoute};`, {compilerOptions: { target: ts.ScriptTarget.ES2022 },}).outputText;diff --git a/apps/desktop/src/main/maker-ipc/pluginTaskDefaultRoute.ts b/apps/desktop/src/main/maker-ipc/pluginTaskDefaultRoute.tsindex 1483ca1e64..b3d33d8dc8 100644--- a/apps/desktop/src/main/maker-ipc/pluginTaskDefaultRoute.ts+++ b/apps/desktop/src/main/maker-ipc/pluginTaskDefaultRoute.ts@@ -44,6 +44,24 @@ export function auxiliaryChainSessionCandidates(refs: readonly string[]): Pluginreturn out;}+/** Reasoning levels light enough for a plugin's background work, cheapest first. */+export const PLUGIN_TASK_LIGHT_EFFORTS = ['low', 'medium'] as const;++/**+ * Route attempts in order: every candidate at a light effort before any candidate+ * at its default. A chain head that only offers high/xhigh (deepseek-v4-flash on+ * xd) therefore yields to the next candidate that has low, instead of running+ * subtitle passages at high reasoning.+ */+export function pluginTaskRouteAttempts<T>(+ candidates: readonly T[],+): Array<{ candidate: T; effort: (typeof PLUGIN_TASK_LIGHT_EFFORTS)[number] | undefined }> {+ return [+ ...candidates.flatMap(candidate => PLUGIN_TASK_LIGHT_EFFORTS.map(effort => ({ candidate, effort }))),+ ...candidates.map(candidate => ({ candidate, effort: undefined })),+ ];+}+/** The plugin left the route open when none of the identifying fields is set. */export function pluginTaskSelectionIsOpen(selection: { agentKind?: unknown; model?: unknown; providerId?: unknown }): boolean {return !selection.agentKind && !selection.model && !selection.providerId;diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 95bead7903..4b95cf7508 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -663,7 +663,7 @@ import { createBotGroupWorkDir } from './botGroupWorkDir.js';import { createBotGroupAttachmentStore } from './botGroupAttachments.js';import { requestUtilityText } from '../utility-model/oneShotCandidates.js';import { getEffectiveAuxiliaryModelChainSnapshot, getEffectiveAuxiliaryModelRefs } from '../utility-model/resolveAuxiliaryModelChain.js';-import { auxiliaryChainSessionCandidates, pluginTaskSelectionIsOpen } from './pluginTaskDefaultRoute.js';+import { auxiliaryChainSessionCandidates, pluginTaskRouteAttempts, pluginTaskSelectionIsOpen } from './pluginTaskDefaultRoute.js';import { validateExistingLocalProjectDirectory } from '../mcp-integrations/createProject.js';import { gitExec } from '../worktree/gitExec.js';import { BOT_GROUP_CLIENT_ID_PREFIX } from '../../shared/botGroupChat.js';@@ -4433,11 +4433,13 @@ async function syncLibraryReadonlyExtraDir(visible, new Set(getMaker().listActiveSessions().map((session) => session.id)), focused,);let granted = false;+ let focusedLocal = false;for (const sessionId of targets) {if (generation !== libraryExtraDirSyncGeneration) return 'superseded';const remote = await sessionIsRemote(sessionId);if (generation !== libraryExtraDirSyncGeneration) return 'superseded';const nextRoot = !remote && grantRoot && sessionId === focused ? grantRoot : null;+ if (nextRoot) focusedLocal = true;// 没有 Library 槽可撤、这次也不给:什么都不变,不碰运行中的会话。否则每次切换焦点都要把每个开着的任务的附加// 目录重新下发一遍,远程 Agent 那台恰好连不上时回滚失败、会话被关,正在跑的一轮就此中断(2026-10-11 实测)。// 运行时的 Library 槽只会来自已落库的那份(启动从库里读,改动先改运行时再落库,落库失败回滚),库里没有即运行时没有。@@ -4458,6 +4460,10 @@ async function syncLibraryReadonlyExtraDir(}if (generation !== libraryExtraDirSyncGeneration) return 'superseded';}+ // A plugin writing its library with no local agent session focused (a hidden+ // background task, or the plugin panel open on its own) has nobody to grant to;+ // that is an ordinary not-granted, not a failure to warn about on every write.+ if (grantRoot && !granted && !focusedLocal) return 'not-granted';if (grantRoot && !granted) {throw new Error('library extraDirs not granted to focused session');}@@ -14177,17 +14183,15 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)let execution: Awaited<ReturnType<typeof resolveSessionExecution>> | undefined;if (!sourceSessionId && pluginTaskSelectionIsOpen(selection)) {// A plugin's own task with no originating session follows the auxiliary- // chain at low effort; an unavailable candidate falls through to the next,- // and the new-task selection remains the last resort.- for (const candidate of auxiliaryChainSessionCandidates(getEffectiveAuxiliaryModelRefs())) {- for (const effort of ['low', undefined] as const) {- try {- execution = await resolveSessionExecution({ ...selection, ...candidate, ...(effort ? { effort } : {}) });- assertPlugin(pluginId);- break;- } catch { execution = undefined; }- }- if (execution) break;+ // chain at the lightest effort any candidate offers; only when none has a+ // light level do candidates run at their default, and the new-task+ // selection remains the last resort.+ for (const { candidate, effort } of pluginTaskRouteAttempts(auxiliaryChainSessionCandidates(getEffectiveAuxiliaryModelRefs()))) {+ try {+ execution = await resolveSessionExecution({ ...selection, ...candidate, ...(effort ? { effort } : {}) });+ assertPlugin(pluginId);+ break;+ } catch { execution = undefined; }}}execution ??= await resolveSessionExecution(selection, sourceSessionId);