Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugin): 将任务配置声明收敛为默认卡片显隐
liugaoweib32efed5b642
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.tsindex 5537a1d891..8eb789cbab 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.ts@@ -1,6 +1,6 @@/*** cindyPrefsStore.test.ts — cindy 槽隐藏配置(在途并发上限)的 normalize 单测。- * 旧 `overrides` 为按插件迁移保留原始记录;迁移读写链路见+ * 旧 `overrides` 只为一次性迁移保留快问快答钉值;迁移读写链路见* pluginModelPrefsMigration.test.ts。*/@@ -29,7 +29,7 @@ describe('normalize(坏形态清洗)', () => {expect(__testing.normalize({ inflightLimits: 'nope' })).toEqual({ inflightLimits: {} });});- it('旧 overrides 保留尚未迁移插件的完整记录,丢弃非对象条目', () => {+ it('旧 overrides 只留快问快答钉值供迁移,媒体/向量覆盖与坏条目不再读取', () => {expect(__testing.normalize({overrides: {@@ -43,9 +43,9 @@ describe('normalize(坏形态清洗)', () => {).toEqual({inflightLimits: {},overrides: {- art: { 'image.generate': 'gpt-image-2', 'text.oneshot': 'cat:xd:codex:gpt-5.5' },- media: { 'video.generate': 'vid-pro', 'embed.text': 'emb-1' },- blank: { 'text.oneshot': '' },+ art: { 'text.oneshot': 'cat:xd:codex:gpt-5.5' },+ media: {},+ blank: {},},});});diff --git a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.tsindex 34845cf03e..5c9fb91f35 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts@@ -1705,13 +1705,10 @@ describe('scaffoldGhostDir', () => {});describe('FORGE_GUIDE', () => {- it('documents opting out of Host task configuration without bypassing user task authorization', () => {- expect(FORGE_GUIDE).toContain('"taskPreferences": false');- expect(FORGE_GUIDE).toContain('旧配置不参与执行');- expect(FORGE_GUIDE).toContain('仅更新该任务');- expect(FORGE_GUIDE).toContain('旧客户端忽略此字段,继续使用原卡片及配置');- expect(FORGE_GUIDE).toContain('"taskPreferences": true');- expect(FORGE_GUIDE).toContain('此声明只作用于当前插件,不关闭任务 API,也不影响其他插件');+ it('documents optional Host task card visibility separately from task capabilities', () => {+ expect(FORGE_GUIDE).toContain('"showTaskPreferences": false');+ expect(FORGE_GUIDE).toContain('"showTaskPreferences": true');+ expect(FORGE_GUIDE).toContain('任务 API、已有配置的读取和执行规则、权限检查均保持原样');});it('账号业务元数据使用插件 KV,不声明 Host 昵称接口', () => {diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostInstallConsent.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostInstallConsent.test.tsindex 38692c26d6..9706b8f8d7 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostInstallConsent.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostInstallConsent.test.ts@@ -130,36 +130,6 @@ describe('obtainGhostInstallConsent', () => {).resolves.toEqual({ mode: 'unprompted' });});- it('requires existing update consent before a plugin stops using host task preferences', async () => {- const current = installed({ ...manifest(['api.weather.test']), agent: { tasks: true } });- const next = { ...current.manifest, version: '1.1.0', taskPreferences: false };- await expect(- obtainGhostInstallConsent({ mode: 'automatic' }, current, next, reviewedDigest),- ).rejects.toMatchObject({- facts: { kind: 'update', added: [expect.objectContaining({ key: 'task-preferences:self-managed' })] },- });- expect(() => assertGhostInstallConsent({ mode: 'unprompted' }, current, next, reviewedDigest))- .toThrow(/requires user confirmation/);- await expect(- obtainGhostInstallConsent(- { mode: 'prompt', prompt: userPrompt(false), initiator: 'user', origin: 'market' },- current, next, reviewedDigest,- ),- ).rejects.toMatchObject({ code: 'MUTATION_CANCELLED' });- const prompt = userPrompt(true);- const decision = await obtainGhostInstallConsent(- { mode: 'prompt', prompt, initiator: 'user', origin: 'market' },- current, next, reviewedDigest,- );- expect(prompt).toHaveBeenCalledOnce();- expect(() => assertGhostInstallConsent(decision, current, next, reviewedDigest)).not.toThrow();- await expect(- obtainGhostInstallConsent(- { mode: 'automatic' }, installed(next), { ...next, version: '1.2.0' }, reviewedDigest,- ),- ).resolves.toEqual({ mode: 'unprompted' });- });-it('skips confirmation only for server default installs', async () => {await expect(obtainGhostInstallConsent(diff --git a/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.tsindex 8814dcd3a0..2972ebe1ec 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts@@ -114,23 +114,21 @@ function setup(};}describe('mobile plugin pages', () => {- it('disables Host task settings only for the instance declaring taskPreferences:false', async () => {+ it.each([undefined, true, false])('projects task card visibility without removing task settings access: %s', async (showTaskPreferences) => {const h = setup();- h.ghost.manifest.agent = {tasks:true};- h.ghost.manifest.taskPreferences = false;- const other = {...h.ghost, manifest:{...h.ghost.manifest, id:'other', taskPreferences:true}};- h.ghosts.push(other);- const context = {controllerDeviceId:'phone-a'}, client = {protocolVersion:1,primitives:['plugin-capabilities']};- const ref = {collectionId:'plugins',kind:'plugin',id:'practice'};- const detail = await h.provider.get!(context,{ref,client});- expect(detail.blocks?.find(block=>block.id==='capabilities')?.data).toMatchObject({tasks:false});- for (const actionId of ['task-settings:get','task-settings:set'])- await expect(h.provider.invoke!(context,{collectionId:'plugins',resourceRef:ref,actionId,input:{},client})).rejects.toThrow();- expect(h.taskSettings.read).not.toHaveBeenCalled();- expect(h.taskSettings.update).not.toHaveBeenCalled();- await h.provider.invoke!(context,{collectionId:'plugins',resourceRef:{...ref,id:'other'},actionId:'task-settings:get',input:{},client});- expect(h.taskSettings.read).toHaveBeenCalledWith('other','r1');+ h.ghost.manifest.agent = { tasks: true };+ h.ghost.manifest.showTaskPreferences = showTaskPreferences;+ const context = { controllerDeviceId: 'phone-a' };+ const client = { protocolVersion: 1, primitives: ['plugin-capabilities'] };+ const ref = { collectionId: 'plugins', kind: 'plugin', id: 'practice' };+ const detail = await h.provider.get!(context, { ref, client });+ expect(detail.blocks?.find(block => block.id === 'capabilities')?.data)+ .toMatchObject({ tasks: showTaskPreferences !== false });+ expect(h.ghost.manifest.agent.tasks).toBe(true);+ await h.invoke('task-settings:get');+ expect(h.taskSettings.read).toHaveBeenCalledWith('practice', 'r1');});+it('adds usage facts to the existing capabilities block and preserves unknown setup on a failed read', async () => {const h = setup({setupAssessment: () => {diff --git a/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.tsindex b537c62e5a..4da3cc04de 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts@@ -42,73 +42,12 @@ beforeEach(() => {owner.id = 'owner-a';cindy.__testing.resetStore();task.__testing.resetLegacyPinMigration();- task.setPluginTaskPreferencesResolver(() => true);});afterEach(() => {- task.setPluginTaskPreferencesResolver(() => true);fs.rmSync(owner.root, { recursive: true, force: true });});-describe('per-plugin Host configuration opt-out', () => {- it('ignores all saved defaults for the opted-out instance while another instance stays unchanged', () => {- const saved = { agentKind: 'codex', model: 'saved', providerId: 'source', effort: 'high', fastMode: true,- permissionMode: 'auto', workingDir: path.join(owner.root, 'project') };- writeJson(TASK_FILE, { errand: { '_root__ping': saved, '_ns__acme__ping': saved }, sessions: { '_root__ping': 'existing-task' } });- task.setPluginTaskPreferencesResolver(id => id !== '_root__ping');- expect(task.readPluginTaskConfig('_root__ping')).toEqual({});- expect(task.readPluginTaskPermissionMode('_root__ping')).toBeNull();- expect(task.readPluginTaskConfig('_ns__acme__ping')).toEqual(saved);- expect(task.readPluginTaskPermissionMode('_ns__acme__ping')).toBe('auto');- expect(() => task.writePluginTaskConfig('_root__ping', { model: 'replacement' })).toThrow('PLUGIN_TASK_PREFERENCES_DISABLED');- expect(() => task.writePluginTaskConfig('_root__ping', null)).toThrow('PLUGIN_TASK_PREFERENCES_DISABLED');- expect(task.readGhostErrandSessionId('_root__ping')).toBe('existing-task');- expect(readJson(TASK_FILE)).toMatchObject({ errand: { '_root__ping': saved } });- task.setPluginTaskPreferencesResolver(() => true);- expect(task.readPluginTaskConfig('_root__ping')).toEqual(saved);- });-- it('does not create preference files or run legacy migration when the instance opts out', () => {- const legacy = { overrides: { ping: { 'text.oneshot': 'cat:xd:codex:old' } } };- writeJson(CINDY_FILE, legacy);- task.setPluginTaskPreferencesResolver(id => id !== 'ping');- expect(task.readPluginTaskConfig('ping')).toEqual({});- expect(() => task.writePluginTaskConfig('ping', { permissionMode: 'auto' })).toThrow('PLUGIN_TASK_PREFERENCES_DISABLED');- expect(readJson(TASK_FILE)).toBeUndefined();- expect(readJson(CINDY_FILE)).toEqual(legacy);- });-- it('migrates another instance without rewriting dormant legacy records, then resumes after opt-in', () => {- const dormant = {- 'text.oneshot': 'cat:xd:codex:old',- 'image.generate': 'saved-image-model',- future: { keep: true },- };- const saved = { permissionMode: 'auto', workingDir: path.join(owner.root, 'project') };- writeJson(CINDY_FILE, { overrides: {- '_root__ping': dormant,- '_ns__acme__ping': { 'text.oneshot': 'cat:other:codex:active' },- } });- writeJson(TASK_FILE, { errand: { '_root__ping': saved }, sessions: {} });- task.setPluginTaskPreferencesResolver(id => id !== '_root__ping');-- expect(task.readPluginTaskConfig('_ns__acme__ping')).toMatchObject({ model: 'active' });- expect(readJson(CINDY_FILE)).toEqual({ overrides: { '_root__ping': dormant } });- expect(readJson(TASK_FILE)).toMatchObject({ errand: { '_root__ping': saved } });- expect(task.readPluginTaskConfig('_root__ping')).toEqual({});- expect(task.readPluginTaskConfig('_ns__acme__ping')).toMatchObject({ model: 'active' });- expect(readJson(CINDY_FILE)).toEqual({ overrides: { '_root__ping': dormant } });-- task.setPluginTaskPreferencesResolver(() => true);- expect(task.readPluginTaskConfig('_root__ping')).toEqual({- ...saved, agentKind: 'codex', providerId: 'xd', model: 'old',- });- expect(readJson(CINDY_FILE)).toBeUndefined();- task.writePluginTaskConfig('_root__ping', null);- expect(task.readPluginTaskConfig('_root__ping')).toEqual({});- });-});-describe('legacy per-ability pins → plugin model preference', () => {it('migrates catalog pins, drops profile keys and media overrides, keeps other keys', () => {// 旧布局:快问快答目录钉 / 轻量档位键 / 媒体与向量覆盖 / 并发上限 / 未知键。diff --git a/apps/desktop/src/main/cindy-brain/cindyPrefsStore.ts b/apps/desktop/src/main/cindy-brain/cindyPrefsStore.tsindex 5d0c2e449b..a9fdff22e0 100644--- a/apps/desktop/src/main/cindy-brain/cindyPrefsStore.ts+++ b/apps/desktop/src/main/cindy-brain/cindyPrefsStore.ts@@ -10,8 +10,8 @@** 旧版这里还有 `overrides`(插件详情「Cindy 能力」逐项钉的模型)。2026-10 起* 插件只有一个「模型」字段,存在 pluginTaskPrefsStore;旧 `overrides` 只留给- * 迁移读取(见 readLegacyOneshotPins / clearLegacyOverrides),只清理已处理的插件;- * 退出宿主管理的旧记录保留,全部迁移后删掉该键。旧版本读到缺键视为无覆盖。+ * 一次性迁移读取(见 readLegacyOneshotPins / clearLegacyOverrides),迁移后+ * 从文件里删掉该键。旧版本回退读到缺键视为无覆盖,不会判损坏。*/import { desktopMakerLogger } from '../maker-host/logger-adapter.js';@@ -34,10 +34,10 @@ interface GhostCindyPrefs {/** ghostId → 在途代办并发上限(正整数;缺项 = 不限并发)。 */inflightLimits: Record<string, number>;/**- * 旧版逐能力钉档,只供迁移;尚未迁移的记录原样保留。- * 运行时只读取快问快答钉值,其它能力键没有消费者。+ * 旧版逐能力钉档里的快问快答钉值(ghostId → 原始字符串),只供一次性迁移;+ * 其它能力键(图像/视频/向量)不再有消费者,读取时直接忽略。*/- overrides?: Record<string, Record<string, unknown>>;+ overrides?: Record<string, { 'text.oneshot'?: string }>;}const DEFAULTS: GhostCindyPrefs = { inflightLimits: {} };@@ -57,8 +57,8 @@ function normalize(raw: unknown): GhostCindyPrefs {const overrides: NonNullable<GhostCindyPrefs['overrides']> = {};for (const [ghostId, capsRaw] of Object.entries(overridesRaw as Record<string, unknown>)) {if (!capsRaw || typeof capsRaw !== 'object') continue;- // 迁移可能暂时跳过退出宿主管理的插件,其旧记录必须原样休眠。- overrides[ghostId] = { ...capsRaw as Record<string, unknown> };+ const pin = (capsRaw as Record<string, unknown>)['text.oneshot'];+ overrides[ghostId] = typeof pin === 'string' && pin.length > 0 ? { 'text.oneshot': pin } : {};}return { inflightLimits, overrides };}@@ -111,23 +111,17 @@ export function readLegacyOneshotPins(): Record<string, string | null> | null {const overrides = store.read().overrides;if (!overrides) return null;return Object.fromEntries(- Object.entries(overrides).map(([ghostId, caps]) => {- const pin = caps['text.oneshot'];- return [ghostId, typeof pin === 'string' && pin.length > 0 ? pin : null];- }),+ Object.entries(overrides).map(([ghostId, caps]) => [ghostId, caps['text.oneshot'] ?? null]),);}-/** 只清理本次已处理的旧记录,其余插件继续休眠;全部处理后删除 overrides 键。 */-export function clearLegacyOverrides(ghostIds: readonly string[]): void {+/** 迁移完成后删除旧 `overrides` 键(保留其它键;文件随之为空则整份删除)。 */+export function clearLegacyOverrides(): void {assertGhostPrefsWritable(GHOST_CINDY_PREFS_FILE);store.invalidateIfChanged();- const current = store.read().overrides;- if (!current) return;- const overrides = { ...current };- for (const ghostId of ghostIds) delete overrides[ghostId];- store.writePatch({ overrides: Object.keys(overrides).length > 0 ? overrides : undefined });- log.info('legacy ghost cindy overrides removed after migration', { ghostIds });+ if (!store.read().overrides) return;+ store.writePatch({ overrides: undefined });+ log.info('legacy ghost cindy overrides removed after migration');}export const __testing = {diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.tsindex 344bf1a1ae..515791a16e 100644--- a/apps/desktop/src/main/cindy-brain/forge.ts+++ b/apps/desktop/src/main/cindy-brain/forge.ts@@ -1743,8 +1743,8 @@ my-ghost/// 一级主视图是独立能力,见 §4.20。使用时直接声明:// "mainView": { "title": "工作台", "icon": "puzzle", "html": "main-view.html" }"settingsHtml": "settings.html", // 可选:设置页「自定义设置区」自绘界面(见 §4.8;声明了用户填的凭证时仍必填,用于长期管理/替换/清除;调用前缺失时主机也会在统一 Setup 卡内联收单,见 §4.7)- "settingsHeight": 360, // 可选:固定高度 px(160–800);缺省 = 随内容自适应(矮内容真收矮,高至 800);内容会动态增减时才声明,避免抖动- "taskPreferences": true // 可选:缺省/true 使用宿主模型与任务配置管理;false 仅本插件自行维护,见 §4.8+ "showTaskPreferences": true, // 可选:是否显示宿主「模型与任务」卡,缺省/true 显示,false 隐藏;见 §4.8+ "settingsHeight": 360 // 可选:固定高度 px(160–800);缺省 = 随内容自适应(矮内容真收矮,高至 800);内容会动态增减时才声明,避免抖动}\`\`\`@@ -2421,7 +2421,7 @@ const r = await cindy.send({标题同一条),不拉起 Agent、没有工具、碰不到用户文件、不进任何会话——要"干活"(读文件、查资料、多步操作)请用派活(§4.11.1);- 选型仍不在你手里(没有 tier/model 参数),但有两级偏好:**用户可在插件- 详情页「模型与任务」里给这个插件选一个默认模型**(宿主只有这一个默认模型字段,快问+ 详情页「模型与任务」里给这个插件选一个模型**(插件只有这一个模型字段,快问快答与你新建的任务共用;选了就钉死,失败不回落);你也可以在身份卡\`cindy\` 里声明 \`"oneshotModel": "<目录模型 id>"\` 表达偏好——主机目录解析得到(且用户没停用)就用它,解析不到按未声明处理。优先级:用户选的模型 >@@ -3439,21 +3439,11 @@ tool-call 内轮询时记得定期发 tool-progress 心跳续命(见 §4"长任"settingsHeight": 360 // 可选:固定高度 px(160–800);缺省 = 随内容自适应(矮内容真收矮),超 800 内部滚动\`\`\`-**宿主模型与任务配置管理(可选)**:顶层 \`taskPreferences\` 只接受布尔值。-省略或设为 \`true\` 时,快问快答、普通任务、旧版代办或工作区插件沿用原有配置管理与卡片。-声明 \`"taskPreferences": false\` 后,配置由插件自己维护(例如经 /kv 保存每项模型和任务去向):-- Desktop 和手机不显示宿主「模型与任务」卡,宿主配置读写入口停用。-- 宿主不再读取或写回该插件的默认模型、权限和目录,旧配置不参与执行,也不自动复制到插件。-- 普通任务模型通过 §4.11.3 的 route 指定;未传仍按原 API 使用发起任务或当前新任务选择。- 快问快答未设宿主模型覆盖,按身份卡 oneshotModel/系统辅助模型链执行;旧 errand 与工作区同样跳过宿主配置。-- 新普通任务初始权限为 ask、目录由宿主管理;目录选择仍走亲选记录和现有工作区 API。- requestWriteAccess 仍须用户确认,但仅更新该任务,不为插件后续任务保存全局默认权限。- 后续发送和协同检查该任务自身已获授的权限及 Plan 状态,不再套用宿主逐插件权限上限。-此开关不关闭任务 API,也不直接授予更高任务权限;不要求声明 settingsHtml,没有相应能力也不会创建卡片。-退出宿主管理会取消既有任务上的插件默认权限上限,因此安装确认会单列说明。-从缺省/true 更新为 false 须经现有扩权更新确认,后台自动更新会等待用户确认;服务端默认安装沿用既有豁免。-恢复为 \`true\` 或删除此字段后,宿主重新使用原来保存的配置;关闭期间不删除这些数据。-旧客户端忽略此字段,继续使用原卡片及配置;依赖关闭语义的插件必须要求支持此字段的客户端版本。+**宿主默认配置卡(可选)**:顶层 \`showTaskPreferences\` 只接受布尔值。+省略或设为 \`true\` 时,符合能力条件的插件继续显示宿主「模型与任务」卡。+声明 \`"showTaskPreferences": false\` 可隐藏 Desktop 和手机上的该卡,供插件在自己的设置界面提供配置。+这只是显示声明:任务 API、已有配置的读取和执行规则、权限检查均保持原样;也不会为没有相应能力的插件新增卡片。+旧客户端不识别此字段时仍显示原卡片;依赖隐藏效果的插件应使用支持此字段的客户端版本。**渲染环境**:与面板同款沙箱页(零桥、无通用网络直连,与同插件面板/逻辑页共用浏览器存储和\`BroadcastChannel\`,脚本/样式/字体/媒体/数据请求仍只认同源)。所有插件 HTML 页面@@ -3895,8 +3885,7 @@ const q = await cindy.agent.queryErrand({ jobId: r.jobId });后台隐藏只能经 §4.11.3 的 \`hiddenTasks\` 声明,且用户始终能在插件详情页查看与接手;- 这是旧版任务接口,不是插件全部 AI 能力。普通任务管理用 §4.11.3,继续用户任务用 §4.11,快问快答用 §4.0.2;不要把这些能力统一称为代办。-- 使用宿主配置管理时,新建任务共用插件详情「任务设置」中的模型组合(Agent、供应商、模型、推理强度、Fast)。- 声明 \`taskPreferences:false\` 时跳过宿主配置,详见 §4.8;旧接口缺省权限仍按下述规则。+- 新建任务共用插件详情「任务设置」中的模型组合(Agent、供应商、模型、推理强度、Fast)。没有覆盖时,沿用宿主核实的同插件本机在途 \`callId\` 所属任务;面板直接创建使用当前新任务选择。无显式覆盖的已有专属任务保留自身模型,用户在任务中改选后可继续复用。显式配置发生冲突时,新任务创建成功才替换映射,旧任务与历史保留。@@ -4075,11 +4064,6 @@ create/send 的 requestKey 持久去重;同键不同内容拒绝。删除后省略 route 时使用用户给本插件的任务模型覆盖;无覆盖则沿用发起任务,面板直接创建时沿用当前新任务选择。可显式传\`{agentKind:'codex',providerId:'...',model:'...',effort:'high',fastMode:false}\`;无推理档位模型用空 effort。-插件若自行维护各项模型、任务去向等配置,可在身份卡声明 \`taskPreferences:false\`(见 §4.8)。-此时宿主不显示「模型与任务」卡,也不读写该插件的模型、权限或目录默认值;-上述模型来源直接跳过插件宿主覆盖,新任务仍初始为 ask、宿主管理目录。-\`requestWriteAccess\` 经用户确认后只更新该任务,后续派发按任务自身授权检查;-此声明只作用于当前插件,不关闭任务 API,也不影响其他插件。先查 \`capabilities().sourceCallContext\`:支持时,Agent 在途调用可在 create 中转传 \`callId\`。宿主核对同插件本机调用后读取其模型;不能自报 sourceSessionId 或权限。面板直接创建省略 callId。新字段需该能力为 true 才发送,旧客户端不能假定支持;同 requestKey 的重放保留原创建结果。diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.tsindex d805fb9fa8..26f0701e7c 100644--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@ -124,7 +124,6 @@ import {ghostNodeSecretAuthorizationWithinCap,ghostSetupAuthorizationWithinCap,ghostSettingsUiWithinCap,- ghostTaskPreferencesWithinCap,ghostSubscribeAuthorizationWithinCap,ghostToolParametersWithinCap,ghostUnknownV3FieldsWithinCap,@@ -360,7 +359,7 @@ import {} from './cindySlot.js';import { GhostAgentSlot, type GhostAgentTurnRunner } from './agentSlot.js';import { GhostErrandSlot, type GhostErrandRunner } from './errandSlot.js';-import { readPluginTaskConfig, writePluginTaskConfig, validatePluginTaskConfig, relocateGhostErrandPrefs, setPluginTaskPreferencesResolver } from './pluginTaskPrefsStore.js';+import { readPluginTaskConfig, writePluginTaskConfig, validatePluginTaskConfig, relocateGhostErrandPrefs } from './pluginTaskPrefsStore.js';import {GhostNodeRuntimeBroker,type NodeRuntimeStartAttemptContext,@@ -728,8 +727,6 @@ function currentGhostAppContext() {let managerSingleton: GhostManager | null = null;let ghostSetupManifestTrackerSingleton: GhostSetupManifestTracker | null = null;-setPluginTaskPreferencesResolver(id => findGhostForInstanceId(id)?.manifest.taskPreferences !== false);-function getGhostSetupManifestTracker(): GhostSetupManifestTracker {if (!ghostSetupManifestTrackerSingleton) {ghostSetupManifestTrackerSingleton = new GhostSetupManifestTracker(@@ -7355,7 +7352,6 @@ async function installOrUpdateMarketGhostPackageLocked(!ghostNodeSecretAuthorizationWithinCap(expected.manifestCap, inspected.canonicalManifest) ||!ghostSetupAuthorizationWithinCap(expected.manifestCap, inspected.canonicalManifest) ||!ghostSettingsUiWithinCap(expected.manifestCap, inspected.canonicalManifest) ||- !ghostTaskPreferencesWithinCap(expected.manifestCap, inspected.canonicalManifest) ||!ghostSubscribeAuthorizationWithinCap(expected.manifestCap, inspected.canonicalManifest) ||!ghostToolParametersWithinCap(expected.manifestCap, inspected.canonicalManifest) ||!ghostUnknownV3FieldsWithinCap(expected.manifestCap, inspected.canonicalManifest)@@ -8941,7 +8937,6 @@ export function registerGhostIpc(): void {try {const ghost = findGhostForInstanceId(ghostId);if (!ghost) throwIpcError('NOT_FOUND', '插件实例已变化,请刷新后重试');- if (ghost.manifest.taskPreferences === false) throwIpcError('PERMISSION_DENIED', 'PLUGIN_TASK_PREFERENCES_DISABLED');return { config: writePluginTaskConfig(installedGhostStoragePart(ghost), config) };}finally { release(); }diff --git a/apps/desktop/src/main/cindy-brain/mobilePageService.ts b/apps/desktop/src/main/cindy-brain/mobilePageService.tsindex 872b41c9a7..dda8ba7149 100644--- a/apps/desktop/src/main/cindy-brain/mobilePageService.ts+++ b/apps/desktop/src/main/cindy-brain/mobilePageService.ts@@ -436,7 +436,7 @@ export class MobilePluginPages {})) ?? [],permissions,details: detailFacts,- tasks: ghost.manifest.taskPreferences !== false && Boolean(ghost.manifest.agent?.tasks || ghost.manifest.agent?.errand),+ tasks: ghost.manifest.showTaskPreferences !== false && Boolean(ghost.manifest.agent?.tasks || ghost.manifest.agent?.errand),mobile: parsePluginMobileDeclaration(ghost.manifest.mobile) !== null,usage: mobilePluginUsage(ghost,@@ -460,7 +460,6 @@ export class MobilePluginPages {if (!settings ||!ghost.enabled ||- ghost.manifest.taskPreferences === false ||!(ghost.manifest.agent?.tasks || ghost.manifest.agent?.errand))return fail();diff --git a/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts b/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.tsindex f134ae9118..36dc68b45c 100644--- a/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts+++ b/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts@@ -150,23 +150,6 @@ function createStore() {let store = createStore();-// The installed manifest owns this policy; resolve it live rather than persisting-// another switch in the preference file. Unchanged plugins keep the old behavior.-let preferencesEnabled: (ghostId: string) => boolean = () => true;-export function setPluginTaskPreferencesResolver(resolve: (ghostId: string) => boolean): void {- preferencesEnabled = resolve;-}-export function isPluginTaskPreferencesEnabled(ghostId: string): boolean {- return preferencesEnabled(ghostId);-}--/** null means the plugin manages settings; only the task's own granted mode applies. */-export function readPluginTaskPermissionMode(ghostId: string): GhostErrandPermissionMode | null {- return isPluginTaskPreferencesEnabled(ghostId)- ? clampPluginTaskPermissionMode(readPluginTaskConfig(ghostId).permissionMode)- : null;-}-// Register owns the runtime catalog; configuration persistence never builds another picker.let validateSelection: ((config: PluginTaskConfig) => Promise<void>) | null = null;export function setPluginTaskConfigValidator(validator: (config: PluginTaskConfig) => Promise<void>): void {@@ -196,8 +179,7 @@ const legacyPinMigrationDone = new Set<string>();* fastMode 留空,由现有解析按模型默认补;权限、目录等其它字段原样保留;* - 已有 model(用户已显式选过)、轻量档位键(非 cat:)、解码失败的值,以及图像/* 视频/向量覆盖一律丢弃(它们从此跟随系统默认);- * - 退出宿主管理的插件保留旧记录,恢复后再迁移;- * - 先写新配置、再删已处理的旧记录:中途失败下一次读取重跑,已写入的+ * - 先写新配置、再删旧文件的 `overrides` 键:中途失败下一次读取重跑,已写入的* 插件因已有 model 被跳过,不会重复或覆盖。*/function migrateLegacyOneshotPins(): void {@@ -211,15 +193,13 @@ function migrateLegacyOneshotPins(): void {try {const legacy = readLegacyOneshotPins();if (legacy) {- const eligible = Object.entries(legacy).filter(([ghostId]) => isPluginTaskPreferencesEnabled(ghostId));- if (eligible.length === 0) return;assertGhostPrefsWritable('ghost-errand-prefs.json');store.invalidateIfChanged();const errand = { ...store.read().errand };const migrated: string[] = [];const kept: string[] = [];const dropped: string[] = [];- for (const [ghostId, pin] of eligible) {+ for (const [ghostId, pin] of Object.entries(legacy)) {if (pin === null) continue;const route = decodeCatalogModelPin(pin);if (!route) {@@ -248,15 +228,13 @@ function migrateLegacyOneshotPins(): void {migrated.push(ghostId);}if (migrated.length > 0) store.writePatch({ errand });- clearLegacyOverrides(eligible.map(([ghostId]) => ghostId));+ clearLegacyOverrides();log.info('legacy plugin oneshot pins migrated to plugin model preference', {source: GHOST_CINDY_PREFS_FILE,migrated,keptExistingModel: kept,droppedUnsupportedPins: dropped,});- // 未迁移的插件可能在当前进程中恢复宿主管理,不能把整个 owner 标成完成。- if (eligible.length < Object.keys(legacy).length) return;}legacyPinMigrationDone.add(scope);} catch (error) {@@ -269,7 +247,6 @@ function migrateLegacyOneshotPins(): void {/** 读某插件的任务配置(缺省空对象 = 全跟随默认)。 */export function readPluginTaskConfig(ghostId: string): PluginTaskConfig {- if (!isPluginTaskPreferencesEnabled(ghostId)) return {};migrateLegacyOneshotPins();// mtime 守卫现读:直接改文件也算配置入口(与 cindy prefs 同契约)。store.invalidateIfChanged();@@ -282,7 +259,6 @@ export function readPluginTaskConfig(ghostId: string): PluginTaskConfig {* 形状粗筛,逐字段值域清洗统一在这里(单一执法点)。返回清洗后的落盘值。*/export function writePluginTaskConfig(ghostId: string, config: unknown): PluginTaskConfig {- if (!isPluginTaskPreferencesEnabled(ghostId)) throw new Error('PLUGIN_TASK_PREFERENCES_DISABLED');assertGhostPrefsWritable('ghost-errand-prefs.json');migrateLegacyOneshotPins();store.invalidateIfChanged();diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaLifecycleService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaLifecycleService.test.tsindex beee20aac1..840633687f 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaLifecycleService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaLifecycleService.test.ts@@ -1186,7 +1186,7 @@ describe('retained tasks after explicit plugin uninstall', () => {maker:{getSession:()=>null},inputCoordinator:{getAcceptedInputProvenance:()=>active},createPluginTaskStore:()=>({get:async(id:string)=>id==='run'?{operation:'send',targetId:'lead',pluginId:'plugin',payload:'{"inputMessageId":"plugin-task:run"}'}:{operation:'create',pluginId:'plugin',payload:JSON.stringify({ownershipRevoked:state==='revoked'})}}),pluginTaskServiceForCurrentOwner:()=>({get:async()=>({status:'active',permissionMode:state==='ask'?'default':'auto',planModeEnabled:state==='plan'})}),- isPluginTaskAuthorized:()=>state!=='disabled',readPluginTaskConfig:()=>({permissionMode:'auto'}), readPluginTaskPermissionMode: () => 'auto'};+ isPluginTaskAuthorized:()=>state!=='disabled',readPluginTaskConfig:()=>({permissionMode:'auto'})};const override=new Function('hasAcceptedUserTaskInput', ...Object.keys(bindings),js)(hasAcceptedUserTaskInput, ...Object.values(bindings));const ordinary=state==='revoked'&&['human','idle'].includes(input);if(state==='healthy'||ordinary)await expect(override('lead')).resolves.toMatchObject({permissionMode:ordinary?undefined:'auto'});@@ -1199,7 +1199,7 @@ describe('retained tasks after explicit plugin uninstall', () => {maker: {getSession:()=>null}, inputCoordinator: { getAcceptedInputProvenance: () => null },createPluginTaskStore: () => ({ get: async () => ({ operation: 'create', pluginId: 'plugin', payload: '{}' }) }),pluginTaskServiceForCurrentOwner: () => ({ get: async () => ({ status, permissionMode: 'auto', planModeEnabled }) }),- isPluginTaskAuthorized: () => true, readPluginTaskConfig: () => ({ permissionMode: 'auto' }), readPluginTaskPermissionMode: () => 'auto',+ isPluginTaskAuthorized: () => true, readPluginTaskConfig: () => ({ permissionMode: 'auto' }),};const override = new Function('hasAcceptedUserTaskInput', ...Object.keys(callbacks), js)(hasAcceptedUserTaskInput, ...Object.values(callbacks));const { deps, service } = createDeps({ getWorkerPermissionModeOverride: override,@@ -1222,7 +1222,7 @@ describe('retained tasks after explicit plugin uninstall', () => {maker: {getSession:()=>null}, inputCoordinator: { getAcceptedInputProvenance: () => null },createPluginTaskStore: () => ({ get: async () => ({ operation: 'create', pluginId: 'plugin', payload: JSON.stringify({ ownershipRevoked: true }) }) }),pluginTaskServiceForCurrentOwner: () => ({ get }), isPluginTaskAuthorized: () => false,- readPluginTaskConfig: () => ({ permissionMode: 'auto' }), readPluginTaskPermissionMode: () => 'auto',+ readPluginTaskConfig: () => ({ permissionMode: 'auto' }),};const override = new Function('hasAcceptedUserTaskInput', ...Object.keys(callbacks), js)(hasAcceptedUserTaskInput, ...Object.values(callbacks));const { deps, service } = createDeps({diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.tsindex 94cf978273..94f49061e6 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.ts@@ -445,7 +445,7 @@ describe('OrcaTeamService', () => {? {operation:'send',targetId:'lead-1',pluginId:'plugin',payload:'{"inputMessageId":"plugin-task:run"}'}: {operation:'create',pluginId:'plugin',payload:JSON.stringify({ownershipRevoked:revoked})}}),pluginTaskServiceForCurrentOwner:()=>({get:async()=>({status:'active',permissionMode:'auto'})}),- isPluginTaskAuthorized:()=>!revoked,readPluginTaskConfig:()=>({permissionMode:'auto'}), readPluginTaskPermissionMode: () => 'auto'};+ isPluginTaskAuthorized:()=>!revoked,readPluginTaskConfig:()=>({permissionMode:'auto'})};const capture = new Function('hasAcceptedUserTaskInput', ...Object.keys(bindings),ts.transpileModule(`${helper}\nreturn captureOrcaPluginAuthority;`,{compilerOptions:{target:ts.ScriptTarget.ES2022}}).outputText)(hasAcceptedUserTaskInput, ...Object.values(bindings));const {deps,service,getWorker}=createDeps({captureControlAuthority:async id=>(await capture(id)).assertCurrent});const list=deps.listWorkersByLead;diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.tsindex 52ea7b0a88..1a0a414d33 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts@@ -82,7 +82,7 @@ describe('Host provenance across Orca creation waits', () => {if (!receipt || receipt.pluginId !== pluginId || JSON.parse(receipt.payload).ownershipRevoked) throw new PluginTaskError('TASK_NOT_FOUND', 'Revoked');return { ...task };} }),- isPluginTaskAuthorized: () => enabled, readPluginTaskConfig: () => ({ permissionMode: 'auto', workingDir: directoryCase ? configured : task.workingDir }), readPluginTaskPermissionMode: () => 'auto',+ isPluginTaskAuthorized: () => enabled, readPluginTaskConfig: () => ({ permissionMode: 'auto', workingDir: directoryCase ? configured : task.workingDir }),resolvePluginWorkerDirectory: vi.fn(async () => {directoryResolved = true; directoryReads = 0;if (directoryCase && !configured && !picked) throw new PluginTaskError('PERMISSION_DENIED', 'Directory revoked');@@ -3503,7 +3503,7 @@ describe('production plugin Auto admission after reservation', () => {if (JSON.parse(receipt.payload).ownershipRevoked) throw new PluginTaskError('TASK_NOT_FOUND', 'Not owned');return { ...task };} }),- readPluginTaskConfig: () => ({ permissionMode: 'auto', workingDir: task.workingDir }), readPluginTaskPermissionMode: () => 'auto',+ readPluginTaskConfig: () => ({ permissionMode: 'auto', workingDir: task.workingDir }),isPluginTaskAuthorized: () => enabled,resolvePluginWorkerDirectory: async () => task.workingDir,isGhostPickedDir: () => false, PluginTaskError,@@ -3567,7 +3567,7 @@ describe('production plugin Auto admission after reservation', () => {const callbackDeps = { getCurrentDbClientSnapshot: () => epoch, PluginTaskError, assertPluginWorkerDirectoryScope,createPluginTaskStore: () => ({ get: async () => ({ operation: 'create', pluginId: 'plugin', payload: state === 'malformed' ? '{' : JSON.stringify({ ownershipRevoked: true, teamPlan: { items: [] } }) }) }),pluginTaskServiceForCurrentOwner: () => ({ get }), isPluginTaskAuthorized: () => state === 'reinstalled',- readPluginTaskConfig: () => ({ permissionMode: 'auto' }), readPluginTaskPermissionMode: () => 'auto',+ readPluginTaskConfig: () => ({ permissionMode: 'auto' }),};const validateCreationPlan = new Function(...Object.keys(callbackDeps), js)(...Object.values(callbackDeps));const { deps, service } = createDeps({ validateCreationPlan });@@ -3622,7 +3622,7 @@ describe('production plugin Auto admission after reservation', () => {}return task();} }),- readPluginTaskConfig: () => ({ permissionMode: mode, workingDir: path.resolve('repo') }), readPluginTaskPermissionMode: () => mode,+ readPluginTaskConfig: () => ({ permissionMode: mode, workingDir: path.resolve('repo') }),isPluginTaskAuthorized: () => enabled,resolvePluginWorkerDirectory: async ({requested}: {requested: string}) => { if (reserved && point === 'directory') revoke(); return requested === path.resolve('other') ? requested : path.resolve('repo'); },realpathWorkingDirectory: async (dir: string) => dir === path.resolve('other') ? dir : path.resolve('repo'),diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginStartTeamAdmission.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginStartTeamAdmission.test.tsindex 250ca8794f..e9021ea420 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginStartTeamAdmission.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginStartTeamAdmission.test.ts@@ -24,7 +24,7 @@ function fixture(initial = 'active', afterConfirmation = initial) {return create();});const deps = { service, getCurrentDbClientSnapshot: () => epoch, PluginTaskError, assertPluginTaskResult, startOrcaTeamForCaller: start,- isPluginTaskAuthorized: () => true, readPluginTaskConfig: () => ({ permissionMode: 'auto' }), readPluginTaskPermissionMode: () => 'auto' };+ isPluginTaskAuthorized: () => true, readPluginTaskConfig: () => ({ permissionMode: 'auto' }) };const run = new Function(...Object.keys(deps), js)(...Object.values(deps));return { run: () => run('plugin', { kind: 'startTeam', taskId: 'task' }), start, create };}@@ -84,7 +84,7 @@ describe('public start_team Full access admission', () => {createPluginTaskStore: () => ({ get: async () => state === 'ordinary' ? null: { operation: 'create', pluginId: 'plugin', payload: JSON.stringify({ ownershipRevoked: revoked }) } }),pluginTaskServiceForCurrentOwner: () => ({ get: async () => task }),- isPluginTaskAuthorized: () => state !== 'disabled', readPluginTaskConfig: () => ({ permissionMode: 'auto' }), readPluginTaskPermissionMode: () => 'auto',+ isPluginTaskAuthorized: () => state !== 'disabled', readPluginTaskConfig: () => ({ permissionMode: 'auto' }),assertLeadCollabProjectEnabled: async () => {}, getWorkerPermissionModeFromCreationPrefs: () => preference,orcaWorkerPermissionConfirmBridge: { request }, t: (key: string) => key, orcaLifecycleService: lifecycle,};@@ -163,7 +163,7 @@ describe('plugin team activation uses the native lifecycle compensation', () =>sendWorkerReadyPlaceholder: vi.fn(), rollbackCreatedWorker: vi.fn(), broadcastSessionCreated: vi.fn(), broadcastOrcaWorkerChanged: vi.fn(),};const callbacks = { service, getCurrentDbClientSnapshot: () => epoch, PluginTaskError, assertPluginTaskResult,- isPluginTaskAuthorized: () => authorized, readPluginTaskConfig: () => ({ ...cfg }), readPluginTaskPermissionMode: () => cfg.permissionMode,+ isPluginTaskAuthorized: () => authorized, readPluginTaskConfig: () => ({ ...cfg }),assertLeadCollabProjectEnabled: async () => {}, getWorkerPermissionModeFromCreationPrefs: () => 'auto',startOrcaTeamWithPermissionGate, orcaWorkerPermissionConfirmBridge: { request: vi.fn() }, t: (key: string) => key,orcaLifecycleService: createOrcaLifecycleService(deps) };diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.tsindex dfdbc7f3af..43bf695043 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts@@ -30,7 +30,7 @@ it('rejects oversized plans before saving and refuses oversized legacy receipts});it.each([false,true])('production Auto context checks uninstall after its projection await (worker=%s)', async worker => {- for (const revoked of [false,true]) for (const configuredMode of ['auto', 'ask', null]) {+ for (const revoked of [false,true]) {const f=fixture(),task=await f.create();const session={...f.route,source:'plugin',workingDir:'/answer',permissionMode:'auto',status:'active'};const results=[[session],worker?[{leadId:task.taskId,label:'w',teamId:'team',teamStatus:'active'}]:[],[session]];@@ -40,7 +40,7 @@ it.each([false,true])('production Auto context checks uninstall after its projecconst deps={setAutoReviewContextResolver:(callback:typeof load)=>{load=callback;},createPluginTaskReviewResolver:(callback:typeof load)=>callback,getCurrentDbClientSnapshot:()=>epoch,sessions:{},orcaWorkers:{},orcaTeams:{},eq:()=>true,createPluginTaskStore:()=>f.deps.store,drainPersistQueue:async()=>{},- pluginTaskServiceForCurrentOwner:()=>f.service,readPluginTaskPermissionMode:()=>configuredMode,+ pluginTaskServiceForCurrentOwner:()=>f.service,readPluginTaskConfig:()=>({permissionMode:'auto'}),readPluginTaskPlanReceipt,pluginTaskAuthorizationRevision:()=> 'new-install',isPluginTaskAuthorized:()=>true};const source=readFileSync(new URL('../register.ts',import.meta.url),'utf8');const start=source.indexOf(' setAutoReviewContextResolver(createPluginTaskReviewResolver(async sessionId => {');@@ -48,7 +48,7 @@ it.each([false,true])('production Auto context checks uninstall after its projecconst js=ts.transpileModule(block,{compilerOptions:{target:ts.ScriptTarget.ES2022}}).outputText;new Function(...Object.keys(deps),js)(...Object.values(deps));if(revoked)await expect(load(worker?'worker':task.taskId)).rejects.toMatchObject({code:'TASK_NOT_FOUND'});- else await expect(load(worker?'worker':task.taskId)).resolves.toMatchObject({authorized:configuredMode !== 'ask',pluginId:'p'});+ else await expect(load(worker?'worker':task.taskId)).resolves.toMatchObject({authorized:true,pluginId:'p'});}});@@ -865,21 +865,6 @@ it('a rejected operation does not poison subsequent drain', async () => {describe('current plugin dispatch authority', () => {- it.each(['ask', 'acceptEdits', 'auto'])('uses the task-granted %s permission when Host preferences are disabled', async permissionMode => {- const f = fixture(), task = await f.create();- f.tasks.get(task.taskId)!.permissionMode = permissionMode;- f.deps.readPermissionMode = () => null;- const run = await f.service.send('p', {taskId:task.taskId,expectedRevision:task.revision,requestKey:'self-managed',text:'input'});- expect(run.status).toBe('queued');- expect(f.deps.dispatch).toHaveBeenCalledOnce();- await expect(f.service.accept(task.taskId,{clientId:run.inputMessageId},f.execution)).resolves.toBeUndefined();- expect(JSON.parse(f.rows.get(run.runId)!.payload)).toMatchObject({status:'running', execution:f.execution});- });- it('keeps Plan Mode and invalid task permissions blocked without a Host preference cap', () => {- expect(isPluginTaskPermissionAllowed('auto', null, true)).toBe(false);- for (const mode of ['bypassPermissions', 'unknown', undefined, null])- expect(isPluginTaskPermissionAllowed(mode, null)).toBe(false);- });it.each(['before', 'route', 'insert'])('blocks independent Plan Mode before dispatch at %s', async point => {const f=fixture(), task=await f.create();const enable=()=>Object.assign(f.tasks.get(task.taskId)!,{permissionMode:'auto',planModeEnabled:true});diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.tsindex 1934d9bb9b..53af65d30b 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts@@ -20,7 +20,7 @@ const settingSource = source.slice(source.indexOf(' ipcMain.handle(\n MAKER_const planSource = source.slice(source.indexOf(' ipcMain.handle(\n MAKER_INVOKE.SET_PLAN_MODE,'), source.indexOf(' ipcMain.handle(MAKER_INVOKE.EXPORT_SESSION_HTML,'));const planJs = ts.transpileModule(planSource, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;const settingJs = ts.transpileModule(settingSource, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;-function fixture(preferencesEnabled = true) {+function fixture() {let identity = 'owner-epoch-install';const gate = new PluginWriteAccessGate();let cfg: Record<string, unknown> = { permissionMode: 'plan', model: 'old' };@@ -37,13 +37,9 @@ function fixture(preferencesEnabled = true) {const queue = { ensureQueueRestored: vi.fn(async (_id: string) => {}), isQueueRestored: vi.fn((_id: string) => true), getQueueControlSnapshot: vi.fn((_id: string) => ({ pendingQueue: [] as string[] })) };const slots = new Set<string>();const dialog = { showMessageBox: vi.fn(async () => ({ response: 0 })) };- const mobilePrompt = vi.fn(async () => true);const write = vi.fn((_id: string, value: Record<string, unknown>) => { cfg = value; });const deps = { isPluginTaskPermissionAllowed, withSessionPermissionChange, withSessionRestartLock, drainPersistQueue:drain,messages,sessions,eq:()=>true,and:()=>true,service, getCurrentDbClientSnapshot: () => ownership.current, readPluginTaskConfig: () => cfg, pluginPermissionRequests: slots, PluginTaskError, maker: { getSession: () => cold ? null : live }, inputCoordinator: queue, dialog, t: (x: string) => x, getInstalledGhostName: () => 'fixture', clampPluginTaskPermissionMode: (x: string) => x, writePluginTaskConfig: write, broadcastSessionPatched: vi.fn() };- const allDeps = {...deps, showMobilePluginTaskPermission:mobilePrompt, readPluginTaskConfig: () => preferencesEnabled ? cfg : {},- readPluginTaskPermissionMode: () => preferencesEnabled ? cfg.permissionMode : null,- isPluginTaskPreferencesEnabled: () => preferencesEnabled,- pluginWriteAccessGate:gate, pluginWriteAccessIdentity:()=>identity};+ const allDeps = {...deps, pluginWriteAccessGate:gate, pluginWriteAccessIdentity:()=>identity};const run = new Function(...Object.keys(allDeps), js)(...Object.values(allDeps));let setMode!: (event: unknown, sessionId: string, mode: string) => Promise<unknown>;let setPlan!: (event:unknown, sessionId:string, enabled:boolean)=>Promise<unknown>;@@ -63,40 +59,8 @@ function fixture(preferencesEnabled = true) {getLiveSession:()=>cold?null:live,persist:async next=>{await epoch.client.tx('bots.persistSessionPermission',{mode:next});},});- return {setPlan:(enabled:boolean)=>setPlan({},'task',enabled),planPersist,forgetGrants,runtimePlan:()=>runtimePlan,nativePlan:(enabled:boolean|null)=>{runtimePlan=enabled;},setImMode, setMode:(mode:string)=>setMode({},'task',mode), persistedResults, remote:()=>{remote=true;}, cold:()=>{cold=true;}, runtimeMode:()=>runtimeMode, changeOwner:()=>{ownership.current={};}, run: (mode = 'acceptEdits', explicit = false) => run('plugin', { kind: 'requestWriteAccess', taskId: 'task', mode }, explicit), runMobile:(mode:string)=>run('plugin',{kind:'requestWriteAccess',taskId:'task',mode,mobilePageId:'page'}), mobilePrompt, queue, gate, identity: (next: string) => {identity=next;}, service, live, epoch, dialog, slots, write, history, drain, config: () => cfg, change: (next: Record<string, unknown>) => { cfg = next; } };+ return {setPlan:(enabled:boolean)=>setPlan({},'task',enabled),planPersist,forgetGrants,runtimePlan:()=>runtimePlan,nativePlan:(enabled:boolean|null)=>{runtimePlan=enabled;},setImMode, setMode:(mode:string)=>setMode({},'task',mode), persistedResults, remote:()=>{remote=true;}, cold:()=>{cold=true;}, runtimeMode:()=>runtimeMode, changeOwner:()=>{ownership.current={};}, run: (mode = 'acceptEdits', explicit = false) => run('plugin', { kind: 'requestWriteAccess', taskId: 'task', mode }, explicit), queue, gate, identity: (next: string) => {identity=next;}, service, live, epoch, dialog, slots, write, history, drain, config: () => cfg, change: (next: Record<string, unknown>) => { cfg = next; } };}-describe('plugin-managed task configuration', () => {- it.each([- {mode:'acceptEdits',enabled:false,key:'taskOnlyDetail'},- {mode:'auto',enabled:false,key:'autoTaskOnlyDetail'},- {mode:'acceptEdits',enabled:true,key:'detail'},- {mode:'auto',enabled:true,key:'autoDetail'},- ])('explains the actual permission scope for $mode with Host preferences $enabled on both clients',async ({mode,enabled,key})=>{- const desktop=fixture(enabled);- await desktop.run(mode);- expect(desktop.dialog.showMessageBox).toHaveBeenCalledWith(expect.objectContaining({detail:`pluginTaskWriteAccess.${key}`}));- const mobile=fixture(enabled);- await mobile.runMobile(mode);- expect(mobile.mobilePrompt).toHaveBeenCalledWith('plugin','page',expect.objectContaining({detail:expect.stringContaining(`pluginTaskWriteAccess.${key}`)}));- });- it.each(['acceptEdits', 'auto'])('confirms %s for this task without writing Host defaults', async mode => {- const f = fixture(false);- await expect(f.run(mode)).resolves.toMatchObject({granted:true});- expect(f.dialog.showMessageBox).toHaveBeenCalledOnce();- expect(f.history.permissionMode).toBe(mode);- expect(f.live.setPermissionMode).toHaveBeenCalledWith(mode);- expect(f.write).not.toHaveBeenCalled();- expect(f.config()).toEqual({permissionMode:'plan',model:'old'});- });- it('reuses the task grant without consulting the dormant Host permission preference', async () => {- const f = fixture(false);- f.service.get.mockResolvedValue({taskId:'task',revision:1,status:'active',permissionMode:'auto'});- await expect(f.run('auto')).resolves.toMatchObject({granted:true});- expect(f.dialog.showMessageBox).not.toHaveBeenCalled();- expect(f.write).not.toHaveBeenCalled();- });-});-describe('shared-provider credential grants on permission changes', () => {it('clears the task grant only when permission or Plan mode really changes, even without a running agent', async () => {const f=fixture();f.cold();diff --git a/apps/desktop/src/main/maker-ipc/pluginTaskService.ts b/apps/desktop/src/main/maker-ipc/pluginTaskService.tsindex c97dd75333..5c42b24229 100644--- a/apps/desktop/src/main/maker-ipc/pluginTaskService.ts+++ b/apps/desktop/src/main/maker-ipc/pluginTaskService.ts@@ -74,11 +74,11 @@ export function readPluginTaskPlanReceipt(payload: string): { teamPlan?: PluginTexport function assertPluginTaskResult(result: { ok: boolean; errorCode?: string }, message: string): void {if (!result.ok) throw new PluginTaskError(result.errorCode || 'HOST_NOT_READY', message);}-/** Host-managed preferences cap task authority; null opts out of that cap, never of task/Plan checks. */+/** A live task cannot exercise more authority than the plugin's current setting. */export function isPluginTaskPermissionAllowed(taskMode: unknown, configuredMode: unknown, planModeEnabled = false): boolean {const rank = (mode: unknown) => mode === 'plan' ? 0 : mode === 'ask' ? 1 : mode === 'acceptEdits' ? 2 : mode === 'auto' ? 3 : -1;const task = rank(taskMode);- return !planModeEnabled && task >= 0 && (configuredMode === null || task <= Math.max(0, rank(configuredMode)));+ return !planModeEnabled && task >= 0 && task <= Math.max(0, rank(configuredMode));}const fail = (code: string, message: string): never => {throw new PluginTaskError(code, message);diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 164202fe76..0c4bbebe0a 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -1373,8 +1373,6 @@ import {} from '../cindy-brain/index.js';import {readPluginTaskConfig,- readPluginTaskPermissionMode,- isPluginTaskPreferencesEnabled,clampPluginTaskPermissionMode,setPluginTaskConfigValidator,writePluginTaskConfig,@@ -12522,7 +12520,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)pluginTaskEpoch = snapshot;pluginTasks = createPluginTaskService({store: createPluginTaskStore(snapshot.client), assertCurrent, assertAuthorized: assertPlugin, resolveRoute,- readPermissionMode: readPluginTaskPermissionMode,+ readPermissionMode: pluginId => clampPluginTaskPermissionMode(readPluginTaskConfig(pluginId).permissionMode),readLiveSession: taskId => maker.getSession(taskId),setModel: async (taskId, route, assertUnchanged) => {const current = await sessionControlService.getSessionRuntime({ targetSessionId: taskId });@@ -12761,7 +12759,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)const mode = request.mode ?? 'acceptEdits';const cfg = readPluginTaskConfig(pluginId);assertCallerCurrent();- if (isPluginTaskPermissionAllowed(task.permissionMode, readPluginTaskPermissionMode(pluginId)) && (mode === 'acceptEdits' ? task.permissionMode === 'acceptEdits' || task.permissionMode === 'auto' : task.permissionMode === 'auto')) return { granted: true, task };+ if (isPluginTaskPermissionAllowed(task.permissionMode, cfg.permissionMode) && (mode === 'acceptEdits' ? task.permissionMode === 'acceptEdits' || task.permissionMode === 'auto' : task.permissionMode === 'auto')) return { granted: true, task };if (pluginPermissionRequests.size) throw new PluginTaskError('TASK_BUSY', 'A permission request is already open');const identity = pluginWriteAccessIdentity(pluginId);const assertRequestCurrent = () => {@@ -12795,18 +12793,15 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)assertRequestCurrent();// Busy/preflight failures have not asked the user anything; do not consume an attempt.return await pluginWriteAccessGate.request(JSON.stringify([pluginId, task.taskId]), identity, mode, explicitWriteAccess, async () => {- const detail = t(isPluginTaskPreferencesEnabled(pluginId)- ? mode === 'auto' ? 'pluginTaskWriteAccess.autoDetail' : 'pluginTaskWriteAccess.detail'- : mode === 'auto' ? 'pluginTaskWriteAccess.autoTaskOnlyDetail' : 'pluginTaskWriteAccess.taskOnlyDetail');const result = request.mobilePageId ? { response: await showMobilePluginTaskPermission(pluginId, request.mobilePageId, {title: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoTitle' : 'pluginTaskWriteAccess.title'),message: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoMessage' : 'pluginTaskWriteAccess.message').replace('{{name}}', getInstalledGhostName(pluginId) ?? pluginId),- detail: `${task.title}\n\n${detail}`,+ detail: `${task.title}\n\n${t(mode === 'auto' ? 'pluginTaskWriteAccess.autoDetail' : 'pluginTaskWriteAccess.detail')}`,allow: t('pluginTaskWriteAccess.allow'), cancel: t('pluginTaskWriteAccess.cancel'),}) ? 0 : 1 } : await dialog.showMessageBox({type: 'question', title: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoTitle' : 'pluginTaskWriteAccess.title'),message: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoMessage' : 'pluginTaskWriteAccess.message').replace('{{name}}', getInstalledGhostName(pluginId) ?? pluginId),- detail,+ detail: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoDetail' : 'pluginTaskWriteAccess.detail'),buttons: [t('pluginTaskWriteAccess.allow'), t('pluginTaskWriteAccess.cancel')], defaultId: 1, cancelId: 1,});if (result.response !== 0) return { granted: false };@@ -12839,7 +12834,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)assertPlanInactive();const currentConfig = readPluginTaskConfig(pluginId);if (currentConfig.permissionMode !== cfg.permissionMode) throw new PluginTaskError('PERMISSION_DENIED', 'Permission settings changed');- if (isPluginTaskPreferencesEnabled(pluginId) && (mode === 'auto' || ['ask', 'plan'].includes(clampPluginTaskPermissionMode(currentConfig.permissionMode)))) writePluginTaskConfig(pluginId, {...currentConfig, permissionMode: mode});+ if (mode === 'auto' || ['ask', 'plan'].includes(clampPluginTaskPermissionMode(currentConfig.permissionMode))) writePluginTaskConfig(pluginId, {...currentConfig, permissionMode: mode});broadcastSessionPatched(task.taskId, {permissionMode: mode});return { granted: true, task: updatedTask };} catch (error) {@@ -14196,8 +14191,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)if (task.status !== 'active') {throw new PluginTaskError('TASK_BUSY', 'Archived tasks cannot create Workers');}- const configuredMode = readPluginTaskPermissionMode(pluginId);- if (!isPluginTaskAuthorized(pluginId) || task.planModeEnabled || task.permissionMode !== 'auto' || (configuredMode !== null && configuredMode !== 'auto')) {+ if (!isPluginTaskAuthorized(pluginId) || task.planModeEnabled || task.permissionMode !== 'auto' || readPluginTaskConfig(pluginId).permissionMode !== 'auto') {throw new PluginTaskError('PERMISSION_DENIED', 'Authorize Auto for the plugin coordinator before creating Workers');}};@@ -16071,12 +16065,12 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)projection.revision,]);if (epoch !== getCurrentDbClientSnapshot()) throw new Error('Account changed');- const configuredMode = readPluginTaskPermissionMode(receipt.pluginId);+ const config = readPluginTaskConfig(receipt.pluginId);const approvalRevision = pluginTaskAuthorizationRevision(receipt.pluginId);return {pluginId: receipt.pluginId,- authorized: !!unchanged && approvalRevision !== null && isPluginTaskAuthorized(receipt.pluginId) && (configuredMode === null || configuredMode === 'auto'),- revision: [epoch.userId, epoch.clientEpoch, approvalRevision, configuredMode, link],+ authorized: !!unchanged && approvalRevision !== null && isPluginTaskAuthorized(receipt.pluginId) && config.permissionMode === 'auto',+ revision: [epoch.userId, epoch.clientEpoch, approvalRevision, config.permissionMode, link],plan: data.teamPlan, settledLabels: data.settledLabels,registeredRoute: data.route,session: { workingDir: session.workingDir, permissionMode: session.permissionMode, planModeEnabled: !!session.planModeEnabled, status: session.status,diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsxindex 2db5b1de12..c96508c4c0 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx@@ -855,12 +855,12 @@ describe('Ghost plugin detail sections', () => {{ name: 'plugin tasks', manifest: { agent: { tasks: true } }, taskRows: true, showCard: true },{ name: 'legacy errands', manifest: { agent: { errand: true } }, taskRows: true, showCard: true },{ name: 'workspaces', manifest: { workspace: true }, taskRows: true, showCard: true },- { name: 'explicitly enabled tasks', manifest: { agent: { tasks: true }, taskPreferences: true }, taskRows: true, showCard: true },- { name: 'opted-out tasks', manifest: { agent: { tasks: true }, taskPreferences: false }, taskRows: true, showCard: false },- { name: 'opted-out quick answers', manifest: { cindy: { text: ['oneshot'] }, taskPreferences: false }, taskRows: false, showCard: false },- { name: 'opted-out legacy errands', manifest: { agent: { errand: true }, taskPreferences: false }, taskRows: true, showCard: false },- { name: 'opted-out workspaces', manifest: { workspace: true, taskPreferences: false }, taskRows: true, showCard: false },- ])('respects the Host task preferences choice for $name', ({ manifest, taskRows, showCard }) => {+ { name: 'explicitly enabled tasks', manifest: { agent: { tasks: true }, showTaskPreferences: true }, taskRows: true, showCard: true },+ { name: 'opted-out tasks', manifest: { agent: { tasks: true }, showTaskPreferences: false }, taskRows: true, showCard: false },+ { name: 'opted-out quick answers', manifest: { cindy: { text: ['oneshot'] }, showTaskPreferences: false }, taskRows: false, showCard: false },+ { name: 'opted-out legacy errands', manifest: { agent: { errand: true }, showTaskPreferences: false }, taskRows: true, showCard: false },+ { name: 'opted-out workspaces', manifest: { workspace: true, showTaskPreferences: false }, taskRows: true, showCard: false },+ ])('respects Host task card visibility for $name', ({ manifest, taskRows, showCard }) => {vi.stubGlobal('ResizeObserver', class { observe() {} unobserve() {} disconnect() {} });Object.assign(window.electronAPI, {ghosts: {@@ -918,7 +918,7 @@ describe('Ghost plugin detail sections', () => {manifest: {schemaVersion: 3, minCindyVersion: '0.1.0', kind: 'chip', id: 'art', name: 'Art',version: '1.0.0', entry: 'main.js', cindy: { image: ['generate', 'edit'], embed: ['text'] },- taskPreferences: true,+ showTaskPreferences: true,},dir: '/plugins/art',namespace: null,diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.tsindex 316c72dcfd..e266843eb8 100644--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts@@ -74,9 +74,9 @@ export interface GhostPluginDetail extends GhostPluginListItem {tools: readonly GhostToolDecl[];hasSettingsUi: boolean;/**- * 宿主「模型与任务」默认配置卡(快问快答与新建任务共用)。声明了快问快答- * 或任何新建任务能力时默认展示;taskPreferences:false 停用宿主配置管理。- * 图像/视频/向量没有逐插件选模,始终跟随系统默认。+ * 宿主「模型与任务」卡:插件的唯一模型字段(快问快答与新建任务共用)。声明了+ * 快问快答(cindy.text 含 oneshot)或任何新建任务能力即展示;图像/视频/向量+ * 没有逐插件选模,始终跟随系统默认。showTaskPreferences:false 仅隐藏该卡。*/hasTaskPreferences: boolean;/** 能新建任务(agent.tasks / 旧 agent.errand / workspace):卡片额外展示权限与工作目录。 */@@ -314,7 +314,7 @@ export function toGhostPluginDetail(tools: manifest.tools ?? [],hasSettingsUi: Boolean(manifest.settingsHtml),hasTaskPreferences:- manifest.taskPreferences !== false &&+ manifest.showTaskPreferences !== false &&(hasPluginTasks || (manifest.cindy?.text ?? []).includes('oneshot')),hasPluginTasks,panelMinWidth: manifest.panel ? (manifest.panel.minWidth ?? 280) : null,diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 2a45087b54..7526c774fa 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -6498,8 +6498,6 @@"agentTasksRequest": "Review task permission","agentTasks": "Can create and manage its own Cindy tasks","agentTasksDetail": "Can send messages, read results and stop its own executions. Tasks remain visible to you. Uses this plugin’s AI settings and may incur model charges; does not grant access to other tasks.",- "selfManagedTaskPreferences": "Manages Its Own Model and Task Settings",- "selfManagedTaskPreferencesDetail": "Stops using Cindy’s saved model, permission and working-directory defaults for this plugin. Existing tasks use their own grants without the plugin’s default permission limit. Does not grant new task permissions.","agentHiddenTasks": "Can create background tasks hidden from the task list","agentHiddenTasksDetail": "Tasks this plugin creates can stay out of the task list, search and notifications. You can always view, open or show them in the task list from Background Tasks on this plugin’s page; uninstalling the plugin shows them again.","agentErrand": "Create tasks, perform work, and read results",@@ -16167,8 +16165,6 @@"title": "Allow this plugin’s AI to edit files?","message": "Allow the AI in “{{name}}” to edit files and continue?","detail": "This sets the plugin’s AI permission to Allow edits for future tasks too. A separate working directory is not a system sandbox; commands still follow Cindy permission checks. You can switch back to read-only in the plugin’s AI settings.",- "taskOnlyDetail": "Allow edits only for this task, without saving a default permission for future plugin tasks. A working directory is not a system sandbox; commands still follow Cindy permission checks.",- "autoTaskOnlyDetail": "Cindy will review actions automatically only for this task and its Workers. Actions requiring confirmation or denied actions still pause. This is not Full access. The choice is not saved as the default permission for future plugin tasks.","allow": "Allow and continue","cancel": "Not now"},diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex c7b2cde92e..55f7fee3d5 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -6469,8 +6469,6 @@"agentTasksRequest": "セッション権限を確認","agentTasks": "このプラグインの Cindy セッションを作成・管理できます","agentTasksDetail": "メッセージの送信、結果の読み取り、自身の実行の停止ができます。セッションはユーザーに表示されます。プラグインの AI 設定を使用し、モデル料金が発生する場合があります。他のセッションへのアクセスは許可されません。",- "selfManagedTaskPreferences": "モデルとタスクの設定を独自に管理",- "selfManagedTaskPreferencesDetail": "このプラグイン用に Cindy が保存したモデル、権限、作業ディレクトリの設定を使用しなくなります。既存タスクは自身に付与された権限で実行され、プラグインの既定の権限制限は適用されません。新たなタスク権限が自動的に付与されることはありません。","agentHiddenTasks": "セッションリストに表示されないバックグラウンドセッションを作成できます","agentHiddenTasksDetail": "このプラグインが作成したセッションを、セッションリスト・検索・通知に表示しないようにできます。プラグイン詳細の「バックグラウンドセッション」からいつでも確認したり開いたり、セッションリストに表示したりできます。プラグインをアンインストールすると再び表示されます。","agentErrand": "タスクを作成し、作業を実行して結果を取得できます",@@ -16104,8 +16102,6 @@"title": "このプラグインの AI にファイルの編集を許可しますか?","message": "「{{name}}」の AI にファイルの編集を許可して続行しますか?","detail": "このプラグインの AI 権限を編集可能に変更します。今後のタスクにも適用されます。独立した作業ディレクトリはシステムのサンドボックスではなく、コマンドには引き続き Cindy の権限チェックが適用されます。プラグインの AI 設定でいつでも読み取り専用に戻せます。",- "taskOnlyDetail": "このセッションにのみファイルの編集を許可します。このプラグインの今後のセッションの既定権限には保存されません。作業ディレクトリはシステムのサンドボックスではなく、コマンドには引き続き Cindy の権限チェックが適用されます。",- "autoTaskOnlyDetail": "このセッションとその Worker の操作のみを Cindy が自動審査します。確認が必要な操作や拒否された操作は停止します。完全アクセスではありません。この選択はプラグインの今後のセッションの既定権限には保存されません。","allow": "許可して続行","cancel": "今は許可しない","autoTitle": "Auto 自動承認を有効化",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 48f58684a1..f52cdf424c 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -6469,8 +6469,6 @@"agentTasksRequest": "세션 권한 확인","agentTasks": "이 플러그인의 Cindy 세션을 만들고 관리할 수 있음","agentTasksDetail": "메시지를 보내고 결과를 읽으며 자신의 실행을 중지할 수 있습니다. 세션은 사용자에게 표시됩니다. 플러그인의 AI 설정을 사용하며 모델 비용이 발생할 수 있습니다. 다른 세션에 대한 접근 권한은 부여하지 않습니다.",- "selfManagedTaskPreferences": "모델 및 작업 설정을 자체 관리",- "selfManagedTaskPreferencesDetail": "Cindy에 저장된 이 플러그인의 모델, 권한, 작업 디렉터리 설정을 더 이상 사용하지 않습니다. 기존 작업은 자체적으로 부여받은 권한으로 실행되며 플러그인의 기본 권한 제한을 받지 않습니다. 새 작업 권한이 자동으로 부여되지는 않습니다.","agentHiddenTasks": "세션 목록에 표시되지 않는 백그라운드 세션을 만들 수 있음","agentHiddenTasksDetail": "이 플러그인이 만든 세션을 세션 목록, 검색, 알림에 표시하지 않을 수 있습니다. 플러그인 상세의 「백그라운드 세션」에서 언제든지 확인하고 열거나 세션 목록에 표시할 수 있으며, 플러그인을 제거하면 다시 표시됩니다.","agentErrand": "작업을 만들고 실행하며 결과를 읽을 수 있습니다",@@ -16104,8 +16102,6 @@"title": "이 플러그인의 AI가 파일을 수정하도록 허용할까요?","message": "“{{name}}”의 AI가 파일을 수정하도록 허용하고 계속할까요?","detail": "이 플러그인의 AI 권한을 수정 가능으로 변경하며, 이후 작업에도 적용됩니다. 별도의 작업 디렉터리는 시스템 샌드박스가 아니며, 명령에는 계속 Cindy의 권한 검사가 적용됩니다. 플러그인 AI 설정에서 언제든지 읽기 전용으로 되돌릴 수 있습니다.",- "taskOnlyDetail": "이 세션에서만 파일 수정을 허용하며, 플러그인의 이후 세션에 적용할 기본 권한으로 저장하지 않습니다. 작업 디렉터리는 시스템 샌드박스가 아니며, 명령에는 계속 Cindy의 권한 검사가 적용됩니다.",- "autoTaskOnlyDetail": "Cindy가 이 세션과 해당 Worker의 동작만 자동 심사합니다. 확인이 필요하거나 거부된 동작은 일시 중지됩니다. 전체 접근 권한이 아니며, 이 선택은 플러그인의 이후 세션에 적용할 기본 권한으로 저장되지 않습니다.","allow": "허용하고 계속","cancel": "지금은 허용 안 함","autoTitle": "Auto 자동 승인 사용",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 9e71c76b26..8540df79ef 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -6469,8 +6469,6 @@"agentTasksRequest": "确认任务权限","agentTasks": "可创建和管理本插件的 Cindy 任务","agentTasksDetail": "可发送消息、读取结果和停止本插件的执行,任务对你可见。沿用插件的 AI 配置,可能产生模型费用;不授予其他任务的访问权。",- "selfManagedTaskPreferences": "自行管理模型与任务配置",- "selfManagedTaskPreferencesDetail": "不再使用 Cindy 为此插件保存的模型、权限和工作目录设置。已有任务按自身授权执行,不再受插件默认权限限制;不会自动授予新的任务权限。","agentHiddenTasks": "可创建不显示在任务列表里的后台任务","agentHiddenTasksDetail": "本插件创建的任务可以不出现在任务列表、搜索和通知里。你可以随时在插件详情的「后台任务」中查看、打开,或显示到任务列表;卸载插件时这些任务会恢复显示。","agentErrand": "可以新建任务、执行工作并读取结果",@@ -16107,8 +16105,6 @@"title": "允许插件的 AI 修改文件?","message": "允许“{{name}}”的 AI 修改文件并继续?","detail": "将此插件的 AI 权限设为“允许修改”,后续任务沿用此选择。独立作答目录不是系统沙箱;命令仍遵循 Cindy 的权限检查。你可以随时在插件 AI 设置中改回只读。",- "taskOnlyDetail": "仅允许当前任务修改文件,不会保存为此插件后续任务的默认权限。工作目录不是系统沙箱;命令仍遵循 Cindy 的权限检查。",- "autoTaskOnlyDetail": "仅当前任务及其 Worker 的操作交由 Cindy 自动审批,需要人工确认或遭拒时仍会暂停;这不是完全访问。此选择不会保存为插件后续任务的默认权限。","allow": "允许并继续","cancel": "暂不允许"},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 1c2f74b026..3fec7bb55e 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -6469,8 +6469,6 @@"agentTasksRequest": "確認任務權限","agentTasks": "可建立和管理本插件的 Cindy 任務","agentTasksDetail": "可傳送訊息、讀取結果和停止本插件的執行,任務對你可見。沿用插件的 AI 配置,可能產生模型費用;不授予其他任務的存取權。",- "selfManagedTaskPreferences": "自行管理模型與任務配置",- "selfManagedTaskPreferencesDetail": "不再使用 Cindy 為此插件儲存的模型、權限和工作目錄設定。既有任務依自身授權執行,不再受插件預設權限限制;不會自動授予新的任務權限。","agentHiddenTasks": "可建立不顯示在任務列表裡的後臺任務","agentHiddenTasksDetail": "本插件建立的任務可以不出現在任務列表、搜尋和通知裡。你可以隨時在插件詳情的「後臺任務」中查看、開啟,或顯示到任務列表;解除安裝插件時這些任務會恢復顯示。","agentErrand": "可建立任務、執行工作並讀取結果",@@ -16104,8 +16102,6 @@"title": "允許此插件的 AI 修改檔案?","message": "允許「{{name}}」的 AI 修改檔案並繼續?","detail": "將此插件的 AI 權限設為「允許修改」,後續任務也會沿用此選擇。獨立工作目錄不是系統沙箱;命令仍遵循 Cindy 的權限檢查。你可以隨時在插件 AI 設定中改回唯讀。",- "taskOnlyDetail": "僅允許目前任務修改檔案,不會儲存為此插件後續任務的預設權限。工作目錄不是系統沙箱;命令仍遵循 Cindy 的權限檢查。",- "autoTaskOnlyDetail": "僅目前任務及其 Worker 的操作交由 Cindy 自動審批,需要人工確認或遭拒時仍會暫停;這不是完全存取。此選擇不會儲存為插件後續任務的預設權限。","allow": "允許並繼續","cancel": "暫不允許","autoTitle": "啟用 Auto 自動審批",diff --git a/apps/desktop/src/shared/__tests__/ghost.test.ts b/apps/desktop/src/shared/__tests__/ghost.test.tsindex 335c6cacbd..ddb9da8aa7 100644--- a/apps/desktop/src/shared/__tests__/ghost.test.ts+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts@@ -17,7 +17,6 @@ import {ghostNodeSecretAuthorizationWithinCap,ghostSetupAuthorizationWithinCap,ghostSettingsUiWithinCap,- ghostTaskPreferencesWithinCap,ghostSubscribeAuthorizationWithinCap,ghostToolParametersWithinCap,ghostUnknownV3FieldsWithinCap,@@ -3760,7 +3759,7 @@ describe('ghost · 交互卡 action id 形状(v2)', () => {});describe('ghost · settingsHtml 自绘设置区 + settingsHeight', () => {- it.each([2, 3])('taskPreferences 在 schema v%s 中保留配置管理选择,缺省不新增字段或权限', (schemaVersion) => {+ it.each([2, 3])('showTaskPreferences 在 schema v%s 中只声明卡片显示,不改变任务能力或权限', (schemaVersion) => {const base = {...goodManifest(),schemaVersion,@@ -3772,24 +3771,20 @@ describe('ghost · settingsHtml 自绘设置区 + settingsHeight', () => {const original = validateGhostManifest(base);expect(original.ok).toBe(true);if (!original.ok) return;- for (const taskPreferences of [undefined, true, false]) {- const result = validateGhostManifest({ ...base, taskPreferences });+ for (const showTaskPreferences of [undefined, true, false]) {+ const result = validateGhostManifest({ ...base, showTaskPreferences });expect(result.ok).toBe(true);if (!result.ok) continue;- expect(result.manifest.taskPreferences).toBe(taskPreferences);- expect(Object.hasOwn(result.manifest, 'taskPreferences')).toBe(taskPreferences !== undefined);+ expect(result.manifest.showTaskPreferences).toBe(showTaskPreferences);+ expect(Object.hasOwn(result.manifest, 'showTaskPreferences')).toBe(showTaskPreferences !== undefined);expect(result.manifest.agent?.tasks).toBe(true);- const permissions = ghostPermissionItems(result.manifest);- expect(permissions.filter(item => item.key !== 'task-preferences:self-managed'))- .toEqual(ghostPermissionItems(original.manifest));- expect(permissions.some(item => item.key === 'task-preferences:self-managed'))- .toBe(taskPreferences === false);+ expect(ghostPermissionItems(result.manifest)).toEqual(ghostPermissionItems(original.manifest));expect(validateNormalizedGhostManifest(result.manifest)).toEqual(result);}- for (const taskPreferences of [null, 0, 1, 'false', {}, []]) {- expect(validateGhostManifest({ ...base, taskPreferences })).toMatchObject({+ for (const showTaskPreferences of [null, 0, 1, 'false', {}, []]) {+ expect(validateGhostManifest({ ...base, showTaskPreferences })).toMatchObject({ok: false,- reason: 'taskPreferences 必须是布尔值',+ reason: 'showTaskPreferences 必须是布尔值',});}});@@ -4603,29 +4598,6 @@ describe('ghostPermissionProjectionFingerprint', () => {).toEqual([expect.objectContaining({ key: 'network:secret:oauth_token' })]);});- it.each([2, 3])('v%s market cap rejects an undisclosed task-preferences opt-out', schemaVersion => {- const manifest = (taskPreferences: boolean | undefined) => validateGhostManifest({- schemaVersion,- id: 'task-prefs-helper',- name: 'Task preferences helper',- version: '1.0.0',- entry: 'main.js',- ...(schemaVersion === 2 ? { slots: ['agent'] } : {}),- ...(schemaVersion === 3 ? { minCindyVersion: '0.1.0' } : {}),- ...(taskPreferences === undefined ? {} : { taskPreferences }),- });- for (const reviewed of [undefined, true, false]) {- for (const actual of [undefined, true, false]) {- const cap = manifest(reviewed);- const downloaded = manifest(actual);- expect(cap.ok && downloaded.ok).toBe(true);- if (!cap.ok || !downloaded.ok) continue;- expect(ghostTaskPreferencesWithinCap(cap.manifest, downloaded.manifest))- .toBe(actual !== false || reviewed === false);- }- }- });-it('market cap requires settings UI presence and only allows its height to stay or shrink', () => {const withoutSettings = validateGhostManifest(goodChipManifest());const autoHeight = validateGhostManifest({diff --git a/apps/desktop/src/shared/__tests__/ghostInstallConsent.test.ts b/apps/desktop/src/shared/__tests__/ghostInstallConsent.test.tsindex 03765d1872..fa95160c45 100644--- a/apps/desktop/src/shared/__tests__/ghostInstallConsent.test.ts+++ b/apps/desktop/src/shared/__tests__/ghostInstallConsent.test.ts@@ -51,36 +51,6 @@ describe('plugin install consent', () => {expect(ghostUpdateNeedsConsent(current, manifest({ version: '1.1.0' }))).toBe(false);});- it.each([2, 3])('reviews opting out of host task preferences in schema v%s', (schemaVersion) => {- const base = {- schemaVersion,- ...(schemaVersion === 2 ? { slots: ['agent'] } : {}),- agent: { tasks: true },- tools: undefined,- network: undefined,- };- for (const previous of [undefined, true, false]) {- const current = installed(manifest({ ...base, taskPreferences: previous }));- for (const next of [undefined, true, false]) {- const candidate = manifest({ ...base, version: '1.1.0', taskPreferences: next });- const facts = evaluateGhostInstallConsent(current, candidate);- if (next === false && previous !== false) {- expect(facts?.kind).toBe('update');- if (facts?.kind !== 'update') throw new Error('expected update facts');- expect(facts.added.map(item => item.key)).toEqual(['task-preferences:self-managed']);- expect(facts.removed).toEqual([]);- expect(ghostUpdateNeedsConsent(current, candidate)).toBe(true);- } else {- expect(facts).toBeNull();- expect(ghostUpdateNeedsConsent(current, candidate)).toBe(false);- }- }- }- const facts = evaluateGhostInstallConsent(null, manifest({ ...base, taskPreferences: false }));- if (facts?.kind !== 'install') throw new Error('expected install facts');- expect(facts.permissions.map(item => item.key)).toContain('task-preferences:self-managed');- });-it('keeps an update silent when it only removes permissions or changes tools', () => {const current = installed(manifest({ network: { hosts: ['api.weather.test', 'maps.weather.test'] } }));expect(evaluateGhostInstallConsent(current, manifest({ version: '1.1.0' }))).toBeNull();diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.tsindex 91976c0288..70acdc82ab 100644--- a/apps/desktop/src/shared/ghost.ts+++ b/apps/desktop/src/shared/ghost.ts@@ -1472,11 +1472,8 @@ export interface GhostManifest {* 页用它避免抖动)。须与 settingsHtml 成对声明。*/settingsHeight?: number;- /**- * 是否使用宿主「模型与任务」配置管理;缺省或 true 沿用原行为。- * false 由插件维护配置:不显示卡片,也不读写宿主的逐插件默认值。- */- taskPreferences?: boolean;+ /** 是否显示宿主「模型与任务」默认配置卡;缺省或 true 显示,false 仅隐藏卡片。 */+ showTaskPreferences?: boolean;/*** 卡片能力;空对象表示基础卡片渲染。* externalLinks: true 时卡片内可声明 data-ghost-link,点击经宿主确认框后打开浏览器。@@ -1951,17 +1948,6 @@ export function ghostDeclaresHiddenTasks(manifest: Pick<GhostManifest, 'agent'>export function ghostPermissionItems(manifest: GhostManifest): GhostPermissionItem[] {const items: GhostPermissionItem[] = [];- // Opting out also removes the host's per-plugin permission cap from existing- // tasks. Keep this in the existing install/update consent projection so an- // automatic update cannot silently restore an older task grant.- if (manifest.taskPreferences === false) {- items.push({- key: 'task-preferences:self-managed',- kind: 'agent',- labelKey: 'selfManagedTaskPreferences',- detailKey: 'selfManagedTaskPreferencesDetail',- });- }for (const [category, actions] of Object.entries(manifest.cindy ?? {})) {if (category === 'oneshotModel') continue; // 偏好模型是标量意图,不是能力键if (!Array.isArray(actions)) continue;@@ -2701,14 +2687,6 @@ export function ghostSettingsUiWithinCap(return actual.settingsHeight <= reviewed.settingsHeight;}-/** 真实包不能未经市场声明就退出宿主任务配置管理。缺省与 true 等价。 */-export function ghostTaskPreferencesWithinCap(- reviewed: GhostManifest,- actual: GhostManifest,-): boolean {- return actual.taskPreferences !== false || reviewed.taskPreferences === false;-}-/*** 市场清单对真实包的 network 授权语义上限。*@@ -3016,7 +2994,7 @@ const GHOST_MANIFEST_KNOWN_TOP_LEVEL_FIELDS = new Set(['node','settingsHtml','settingsHeight',- 'taskPreferences',+ 'showTaskPreferences','slots','card','tools',@@ -4134,8 +4112,8 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: booif (raw.settingsHtml !== undefined && !isSafeGhostRelativePath(raw.settingsHtml)) {return { ok: false, reason: 'settingsHtml 必须是安装目录内的安全相对路径' };}- if (raw.taskPreferences !== undefined && typeof raw.taskPreferences !== 'boolean') {- return { ok: false, reason: 'taskPreferences 必须是布尔值' };+ if (raw.showTaskPreferences !== undefined && typeof raw.showTaskPreferences !== 'boolean') {+ return { ok: false, reason: 'showTaskPreferences 必须是布尔值' };}if (raw.settingsHeight !== undefined) {if (raw.settingsHtml === undefined) {@@ -6048,8 +6026,8 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: boo...(raw.settingsHtml !== undefined ? { settingsHtml: raw.settingsHtml as string } : {}),...(raw.mobile !== undefined ? { mobile: raw.mobile as GhostManifest['mobile'] } : {}),...(raw.settingsHeight !== undefined ? { settingsHeight: raw.settingsHeight as number } : {}),- ...(raw.taskPreferences !== undefined- ? { taskPreferences: raw.taskPreferences as boolean }+ ...(raw.showTaskPreferences !== undefined+ ? { showTaskPreferences: raw.showTaskPreferences as boolean }: {}),...(tools !== undefined ? { tools } : {}),...(card !== undefined || prepared.v3BaseCard || slots.includes('card')diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.mdindex df6bafd9da..0e43545a17 100644--- a/docs/dev-rules/plugin-security-and-authoring.md+++ b/docs/dev-rules/plugin-security-and-authoring.md@@ -136,16 +136,11 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开但当前 Host 不展示、不授权、也不因此阻止安装或发布。未来 Host 识别该字段后,才按正常的能力展示和运行时守门链路启用。不能把未知字段猜成现有权限,也不能让它意外获得能力。-- 顶层 `taskPreferences?: boolean` 选择是否使用宿主的「模型与任务」配置管理,默认启用。- `false` 时由插件自行存储配置,Desktop/手机隐藏配置卡、拒绝宿主配置写入,所有任务/- 快问快答入口不再读取旧的逐插件模型、权限与目录。旧数据不删除、关闭期间不参与执行;- 恢复启用后重新生效。不填或 `true` 时存量插件完全沿用原行为,无相应能力不创建卡片。- 任务能力批准不变;新普通任务仍以 ask 创建,插件用 route 和现有目录 API 表达配置,- 权限提升仍经用户确认,只修改该任务、不写回已停用的宿主配置;发送/协同以任务自身- 的已授权权限与 Plan 状态守门。不开 Full access,不绕过目录亲选或模型准入。- 旧客户端忽略字段并继续使用旧配置;依赖此语义须要求客户端版本支持。不要求 settingsHtml。- 实现见 `pluginTaskPrefsStore.ts`、`pluginTaskService.ts`、`ghostPluginViewModel.ts` 与- `mobilePageService.ts`;作者用法见 `FORGE_GUIDE` §4.8,回归覆盖协议、存储、任务授权与两端入口。+- 顶层 `showTaskPreferences?: boolean` 仅控制宿主「模型与任务」默认配置卡的显示。+ 省略或 `true` 沿用原有能力条件;`false` 隐藏 Desktop 和手机上的该卡,由插件提供自己的配置界面。+ 任务 API、已有配置的读取和执行规则、权限检查及安装确认均不改变。此字段不是能力授权,+ 无相应能力时设为 `true` 也不会新增卡片。旧客户端不识别时仍显示原卡片。+ 实现见 `ghostPluginViewModel.ts`、`mobilePageService.ts`;作者用法见 `FORGE_GUIDE` §4.8。- `agent.tasks` 另需 Host receipt 的显式任务能力批准事实;旧 receipt 没有该事实时,只在首次任务能力调用通过既有宿主权限界面确认,原插件的启用态、其它能力、凭证和设置保持不变。拒绝、窗口不可用、账号或安装版本变化均不授予任务权限;同能力更新@@ -233,9 +228,6 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开全部条目。首次安装展示全部权限并确认;更新相对当前已装版本按 `diffInstalledGhostPermissionItems`比较,新增条目、同 key 条目内容变化或内置 OAuth 客户端变化才算权限变多,只删除不算;已装版本没有有效批准基线时按全部权限新增处理。- 顶层 `taskPreferences: false` 以独立条目参与此投影:退出宿主管理会移除既有任务上的- 插件默认权限上限,不能通过静默更新重新启用旧任务授权。缺省/`true` → `false`- 需要扩权确认;保持 `false` 不重复确认,恢复宿主管理不算扩权。不新增独立批准状态。- 入口与确认界面:插件页、拖入、双击 `.cindy` 与设置页导入由发起窗口弹确认框(`GhostInstallConsentWindowBridge` → `GhostInstallConsentHost`,只投给、也只接受发起安装的那个 webContents);Agent 调用 `ghost_market_install`/`ghost_forge_install` 不论任务权限档@@ -301,7 +293,6 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开自定义市场以发现并规范化的 manifest 为能力上限。超出能力上限按包内容不一致拒绝并留待来源修复,不转成用户审批流程;上限内的新版声明仍按上一条判断是否需要用户确认。能力上限按 Host 实际消费语义比较:真实包不得从无到有增加 `settingsHtml` 设置 WebView 或扩大固定 `settingsHeight`;- `taskPreferences` 缺省或为 `true` 时,真实包不能改为 `false` 退出宿主配置管理;OAuth `scopes` 换序或取子集属于收权,其它 OAuth、凭证标签与注入字段仍须保持在清单上限内;`setup.requires` 只能保留或删除市场已有的完整需求组,不能增加组、收紧 `anyOf` 或更换引用;真实包同名工具的 `parameters` JSON Schema 必须与市场规范值一致(仅对象键顺序可不同)。diff --git a/docs/dev-rules/plugin-task-api-implementation.md b/docs/dev-rules/plugin-task-api-implementation.mdindex 2ef0fd360c..a22f591cfd 100644--- a/docs/dev-rules/plugin-task-api-implementation.md+++ b/docs/dev-rules/plugin-task-api-implementation.md@@ -83,18 +83,10 @@ if (capabilities.operations.includes('models')) {新任务选择;用户可为插件单独覆盖。模型、Agent、供应商、推理强度和 Fast 作为完整组合解析,绝不从另一 Agent 的历史草稿拼出一组值。权限独立设置,不随模型来源继承。-以下宿主配置管理默认启用。插件可在自己的 `ghost.json` 顶层声明-`taskPreferences: false`,仅让该插件自行维护配置:隐藏「模型与任务」卡片,宿主不再-读写该插件的模型、权限和工作目录默认值,旧配置不参与执行;其他插件及任务 API 保持可用。-插件通过显式 route、`setModel` 和既有目录/授权 API 管理任务,不得直接指定更高权限。-未传 route 时跳过插件宿主覆盖,继续使用原发起任务/当前新任务选择;快问快答跳过-宿主模型覆盖,仍依次使用身份卡 `oneshotModel` 和系统辅助模型链。新普通任务初始为-`ask`、宿主管理目录;已有任务按自身授权派发,Plan、归属和能力批准检查保持。-省略声明或设为 `true` 保持旧行为,并可恢复使用原宿主配置;旧客户端忽略该字段,-因此依赖此语义的插件须使用已支持该声明的客户端。-退出管理会移除既有任务上的逐插件默认权限上限,因此该声明进入现有安装权限投影。-首次安装会列出说明;缺省/`true` → `false` 的更新需要现有扩权确认,后台自动更新不代为确认。-已批准的 `false` → `false` 不重复确认,恢复宿主管理不算扩权;服务端默认安装保留既有豁免。+插件可在 `ghost.json` 顶层声明 `showTaskPreferences: false`,隐藏 Desktop 和手机上的+宿主「模型与任务」默认配置卡,并在自己的设置界面提供配置。省略或设为 `true` 保持原有显示条件。+此字段仅控制卡片显示;以下任务 API、模型优先级、已有默认配置和权限检查全部保持原样。+旧客户端不识别该字段时仍显示原卡片。| 入口 | 模型来源与复用 | 权限与结果 || --- | --- | --- |@@ -229,7 +221,7 @@ Claude Code 适配层 `toSdkModelString` 会按目录窗口自动追加 `[1m]`插件新增的 tasks 能力首次使用时复用宿主权限确认。拒绝、超时或确认失败后,同一账号代际和安装修订在当前宿主进程内不再自动弹窗;插件重载或重复调用不能清除该状态。用户可在本机插件详情权限区点击“确认任务权限”重新进入原确认流程,点击不等于批准;在途确认不并发,账号、安装修订或发起窗口改变时旧结果无效。旧插件的既有功能、启用态、凭证与设置不变。此显式入口不向插件页面或 device-link 暴露;重启宿主后可重新首次询问。-逻辑页可调用 cindy.tasks.requestWriteAccess({taskId, mode?})。省略 mode 保留旧行为(acceptEdits,仅限未开始执行的任务);mode: auto 请求宿主原生确认,为空闲自有任务及插件后续任务启用 Auto。声明 `taskPreferences: false` 时仅更新该任务的授权,不读写插件宿主默认值,也不为后续新任务提权。插件不能替用户确认,不能请求 Full access。拒绝不改状态;账号、配置、任务版本在确认期间改变则拒绝写入。Auto 插件主任务的 Worker 固定使用 Auto,不继承或改写全局 Worker 偏好;授权撤销后拒绝新建。Host 读取该次权限时一并保留账号与插件来源,在团队查询、Worker 准备/启动、落盘后以及首条输入的 accepted 回调中复核;在途卸载、重装、归属消失或降权不能将本次创建降为普通 Orca。调用开始前已明确撤销的旧用户任务仍可新发起普通 Orca。首条输入(任务或就绪消息)真正接收时沿现有回调再次复核;任务接收生命周期的异步更新前后均检查,失败回滚本次临时运行态并取消派发。直发拒绝后,在派发调用退出后才沿原生命周期清理新 Worker;排队后迟到的拒绝仅取消该输入并回滚本次临时状态,保留 Worker 和用户数据。既有内存回调不构成跨重启的授权事务,也不保证中断已接收执行。失败沿原生命周期尽力清理,不保证跨账号数据库补偿或跨进程事务。独立目录不是沙箱。返回 granted 与更新后的 task/revision,插件应继续原批次。+逻辑页可调用 cindy.tasks.requestWriteAccess({taskId, mode?})。省略 mode 保留旧行为(acceptEdits,仅限未开始执行的任务);mode: auto 请求宿主原生确认,为空闲自有任务及插件后续任务启用 Auto。插件不能替用户确认,不能请求 Full access。拒绝不改状态;账号、配置、任务版本在确认期间改变则拒绝写入。Auto 插件主任务的 Worker 固定使用 Auto,不继承或改写全局 Worker 偏好;授权撤销后拒绝新建。Host 读取该次权限时一并保留账号与插件来源,在团队查询、Worker 准备/启动、落盘后以及首条输入的 accepted 回调中复核;在途卸载、重装、归属消失或降权不能将本次创建降为普通 Orca。调用开始前已明确撤销的旧用户任务仍可新发起普通 Orca。首条输入(任务或就绪消息)真正接收时沿现有回调再次复核;任务接收生命周期的异步更新前后均检查,失败回滚本次临时运行态并取消派发。直发拒绝后,在派发调用退出后才沿原生命周期清理新 Worker;排队后迟到的拒绝仅取消该输入并回滚本次临时状态,保留 Worker 和用户数据。既有内存回调不构成跨重启的授权事务,也不保证中断已接收执行。失败沿原生命周期尽力清理,不保证跨账号数据库补偿或跨进程事务。独立目录不是沙箱。返回 granted 与更新后的 task/revision,插件应继续原批次。### 主任务协调评测@@ -286,7 +278,7 @@ Host 只接受经绑定插件身份写入的自有创建收据;已登记计划已识别插件任务的协调任务或 Worker 缺少有效范围时返回既有 authorizationError,在缓存、本地安全动作或 Host MCP 快捷路径之前拒绝自动授权;不退回普通任务、不从消息补造范围。旧计划继续可读,不事后补填;新范围须在新任务中登记完整计划。Ask/acceptEdits 保留既有逐次人工确认,普通无插件归属任务不受此限制。没有新增权限档位、没有提升到 Full access。-审批在查询缓存前重新核对插件批准版本、启用状态、宿主管理时的 Auto 设置、账号 epoch、任务状态、+审批在查询缓存前重新核对插件批准版本、启用状态、Auto 设置、账号 epoch、任务状态、团队归属和计划匹配;异步结果返回前再次核对。历史投影和归属读取完成后,以同一条只读 SQL 比较本次使用的任务/Lead 权限、独立 Plan、状态、路由目录、团队链接及计划收据,并复核授权投影修订号仍与读取值一致、投影已同步且版本为 3;变化拒绝本次授权,查询失败保留 unavailable。该检查同时覆盖 Lead 和 Worker 的真人证据变化,不只检查当前 Worker 的意图。Lead 或 Worker 已开启独立 Plan 时不恢复委派 Auto。Worker 别名目录的异步解析在该次归属和最终授权核验之前完成;核验后只同步消费本次目录匹配结果,不再等待文件系统读取。该结果不写入回执,也不替代可信本地工作区边界。diff --git a/packages/plugin-protocol/src/__tests__/manifest.test.ts b/packages/plugin-protocol/src/__tests__/manifest.test.tsindex e540bb1456..25622ed536 100644--- a/packages/plugin-protocol/src/__tests__/manifest.test.ts+++ b/packages/plugin-protocol/src/__tests__/manifest.test.ts@@ -31,7 +31,7 @@ const validManifest = {} as const;describe('Ghost manifest contract', () => {- it.each([2, 3])('preserves the optional Host task preferences flag in schema v%s', (schemaVersion) => {+ it.each([2, 3])('preserves the optional Host task card visibility flag in schema v%s', (schemaVersion) => {const base = {...validManifest,schemaVersion,@@ -40,19 +40,19 @@ describe('Ghost manifest contract', () => {tools: undefined,agent: { tasks: true },};- for (const taskPreferences of [undefined, true, false]) {- const result = validateGhostManifest({ ...base, taskPreferences });+ for (const showTaskPreferences of [undefined, true, false]) {+ const result = validateGhostManifest({ ...base, showTaskPreferences });expect(result.ok).toBe(true);if (!result.ok) continue;- expect(result.manifest.taskPreferences).toBe(taskPreferences);- expect(Object.hasOwn(result.manifest, 'taskPreferences')).toBe(taskPreferences !== undefined);+ expect(result.manifest.showTaskPreferences).toBe(showTaskPreferences);+ expect(Object.hasOwn(result.manifest, 'showTaskPreferences')).toBe(showTaskPreferences !== undefined);expect(result.manifest.agent?.tasks).toBe(true);expect(validateGhostManifest(result.manifest)).toEqual(result);}- for (const taskPreferences of [null, 0, 1, 'false', {}, []]) {- expect(validateGhostManifest({ ...base, taskPreferences })).toMatchObject({+ for (const showTaskPreferences of [null, 0, 1, 'false', {}, []]) {+ expect(validateGhostManifest({ ...base, showTaskPreferences })).toMatchObject({ok: false,- reason: 'taskPreferences 必须是布尔值',+ reason: 'showTaskPreferences 必须是布尔值',});}});diff --git a/packages/plugin-protocol/src/manifest.ts b/packages/plugin-protocol/src/manifest.tsindex 69936c5707..9a9b2a9a11 100644--- a/packages/plugin-protocol/src/manifest.ts+++ b/packages/plugin-protocol/src/manifest.ts@@ -926,11 +926,8 @@ export interface GhostManifest {* 页用它避免抖动)。须与 settingsHtml 成对声明。*/settingsHeight?: number;- /**- * 是否使用宿主「模型与任务」配置管理;缺省或 true 沿用原行为。- * false 由插件维护配置:不显示卡片,也不读写宿主的逐插件默认值。- */- taskPreferences?: boolean;+ /** 是否显示宿主「模型与任务」默认配置卡;缺省或 true 显示,false 仅隐藏卡片。 */+ showTaskPreferences?: boolean;/** 仅 schemaVersion 2 存在的兼容声明。 */slots?: LegacyGhostSlot[];/**@@ -1175,7 +1172,7 @@ const GHOST_MANIFEST_KNOWN_TOP_LEVEL_FIELDS = new Set(['node','settingsHtml','settingsHeight',- 'taskPreferences',+ 'showTaskPreferences','slots','card','tools',@@ -1647,8 +1644,8 @@ export function validateGhostManifest(value: unknown): ManifestValidation {if (raw.settingsHtml !== undefined && !isSafeGhostRelativePath(raw.settingsHtml)) {return { ok: false, reason: 'settingsHtml 必须是安装目录内的安全相对路径' };}- if (raw.taskPreferences !== undefined && typeof raw.taskPreferences !== 'boolean') {- return { ok: false, reason: 'taskPreferences 必须是布尔值' };+ if (raw.showTaskPreferences !== undefined && typeof raw.showTaskPreferences !== 'boolean') {+ return { ok: false, reason: 'showTaskPreferences 必须是布尔值' };}if (raw.settingsHeight !== undefined) {if (raw.settingsHtml === undefined) {@@ -3755,8 +3752,8 @@ export function validateGhostManifest(value: unknown): ManifestValidation {...(raw.settingsHtml !== undefined ? { settingsHtml: raw.settingsHtml as string } : {}),...(raw.mobile !== undefined ? { mobile: raw.mobile as GhostManifest['mobile'] } : {}),...(raw.settingsHeight !== undefined ? { settingsHeight: raw.settingsHeight as number } : {}),- ...(raw.taskPreferences !== undefined- ? { taskPreferences: raw.taskPreferences as boolean }+ ...(raw.showTaskPreferences !== undefined+ ? { showTaskPreferences: raw.showTaskPreferences as boolean }: {}),...(prepared.schemaVersion === 2 ? { slots } : {}),...(card !== undefined