Skip to content

armgit / cindy

Public Imported from GitHub
0

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

fix(plugin): 补齐任务配置退出的迁移与安装边界

liugaoweie70f1d399f53
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/cindyPrefsStore.test.ts
index 8eb789cbab..5537a1d891 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: { 'text.oneshot': 'cat:xd:codex:gpt-5.5' },
- media: {},
- blank: {},
+ 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': '' },
},
});
});
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts
index 86b46acec1..b537c62e5a 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/pluginModelPrefsMigration.test.ts
@@ -77,6 +77,36 @@ describe('per-plugin Host configuration opt-out', () => {
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', () => {
diff --git a/apps/desktop/src/main/cindy-brain/cindyPrefsStore.ts b/apps/desktop/src/main/cindy-brain/cindyPrefsStore.ts
index a9fdff22e0..5d0c2e449b 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, { 'text.oneshot'?: string }>;
+ overrides?: Record<string, Record<string, unknown>>;
}
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;
- const pin = (capsRaw as Record<string, unknown>)['text.oneshot'];
- overrides[ghostId] = typeof pin === 'string' && pin.length > 0 ? { 'text.oneshot': pin } : {};
+ // 迁移可能暂时跳过退出宿主管理的插件,其旧记录必须原样休眠。
+ overrides[ghostId] = { ...capsRaw as Record<string, unknown> };
}
return { inflightLimits, overrides };
}
@@ -111,17 +111,23 @@ 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]) => [ghostId, caps['text.oneshot'] ?? null]),
+ Object.entries(overrides).map(([ghostId, caps]) => {
+ const pin = caps['text.oneshot'];
+ return [ghostId, typeof pin === 'string' && pin.length > 0 ? pin : null];
+ }),
);
}
-/** 迁移完成后删除旧 `overrides` 键(保留其它键;文件随之为空则整份删除)。 */
-export function clearLegacyOverrides(): void {
+/** 只清理本次已处理的旧记录,其余插件继续休眠;全部处理后删除 overrides 键。 */
+export function clearLegacyOverrides(ghostIds: readonly string[]): void {
assertGhostPrefsWritable(GHOST_CINDY_PREFS_FILE);
store.invalidateIfChanged();
- if (!store.read().overrides) return;
- store.writePatch({ overrides: undefined });
- log.info('legacy ghost cindy overrides removed after migration');
+ 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 });
}
export const __testing = {
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index d2700129c4..d805fb9fa8 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -124,6 +124,7 @@ import {
ghostNodeSecretAuthorizationWithinCap,
ghostSetupAuthorizationWithinCap,
ghostSettingsUiWithinCap,
+ ghostTaskPreferencesWithinCap,
ghostSubscribeAuthorizationWithinCap,
ghostToolParametersWithinCap,
ghostUnknownV3FieldsWithinCap,
@@ -7354,6 +7355,7 @@ 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)
diff --git a/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts b/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts
index d8ec13627f..f134ae9118 100644
--- a/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts
+++ b/apps/desktop/src/main/cindy-brain/pluginTaskPrefsStore.ts
@@ -196,7 +196,8 @@ const legacyPinMigrationDone = new Set<string>();
* fastMode 留空,由现有解析按模型默认补;权限、目录等其它字段原样保留;
* - 已有 model(用户已显式选过)、轻量档位键(非 cat:)、解码失败的值,以及图像/
* 视频/向量覆盖一律丢弃(它们从此跟随系统默认);
- * - 先写新配置、再删旧文件的 `overrides` 键:中途失败下一次读取重跑,已写入的
+ * - 退出宿主管理的插件保留旧记录,恢复后再迁移;
+ * - 先写新配置、再删已处理的旧记录:中途失败下一次读取重跑,已写入的
* 插件因已有 model 被跳过,不会重复或覆盖。
*/
function migrateLegacyOneshotPins(): void {
@@ -210,13 +211,15 @@ 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 Object.entries(legacy)) {
+ for (const [ghostId, pin] of eligible) {
if (pin === null) continue;
const route = decodeCatalogModelPin(pin);
if (!route) {
@@ -245,13 +248,15 @@ function migrateLegacyOneshotPins(): void {
migrated.push(ghostId);
}
if (migrated.length > 0) store.writePatch({ errand });
- clearLegacyOverrides();
+ clearLegacyOverrides(eligible.map(([ghostId]) => ghostId));
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) {
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts
index c6b12eba9b..1934d9bb9b 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginWriteAccess.test.ts
@@ -37,9 +37,10 @@ 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, readPluginTaskConfig: () => preferencesEnabled ? cfg : {},
+ const allDeps = {...deps, showMobilePluginTaskPermission:mobilePrompt, readPluginTaskConfig: () => preferencesEnabled ? cfg : {},
readPluginTaskPermissionMode: () => preferencesEnabled ? cfg.permissionMode : null,
isPluginTaskPreferencesEnabled: () => preferencesEnabled,
pluginWriteAccessGate:gate, pluginWriteAccessIdentity:()=>identity};
@@ -62,9 +63,22 @@ 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), 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), 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; } };
}
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});
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 3827f11556..164202fe76 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -12795,15 +12795,18 @@ 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${t(mode === 'auto' ? 'pluginTaskWriteAccess.autoDetail' : 'pluginTaskWriteAccess.detail')}`,
+ detail: `${task.title}\n\n${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: t(mode === 'auto' ? 'pluginTaskWriteAccess.autoDetail' : 'pluginTaskWriteAccess.detail'),
+ detail,
buttons: [t('pluginTaskWriteAccess.allow'), t('pluginTaskWriteAccess.cancel')], defaultId: 1, cancelId: 1,
});
if (result.response !== 0) return { granted: false };
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 7526c774fa..d40251fd09 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -16165,6 +16165,8 @@
"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.json
index 55f7fee3d5..d2e29f5eeb 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -16102,6 +16102,8 @@
"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.json
index f52cdf424c..2df6ac62e7 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -16102,6 +16102,8 @@
"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.json
index 8540df79ef..8d2728ab3a 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -16105,6 +16105,8 @@
"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.json
index 3fec7bb55e..5b91d15761 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -16102,6 +16102,8 @@
"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.ts
index 33c92977e0..e7e3e98d31 100644
--- a/apps/desktop/src/shared/__tests__/ghost.test.ts
+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts
@@ -17,6 +17,7 @@ import {
ghostNodeSecretAuthorizationWithinCap,
ghostSetupAuthorizationWithinCap,
ghostSettingsUiWithinCap,
+ ghostTaskPreferencesWithinCap,
ghostSubscribeAuthorizationWithinCap,
ghostToolParametersWithinCap,
ghostUnknownV3FieldsWithinCap,
@@ -4598,6 +4599,29 @@ 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/ghost.ts b/apps/desktop/src/shared/ghost.ts
index 9e4fac5d0b..28b36da1a5 100644
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@ -2690,6 +2690,14 @@ 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 授权语义上限。
*
diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.md
index 666d7a980a..2af92c21a3 100644
--- a/docs/dev-rules/plugin-security-and-authoring.md
+++ b/docs/dev-rules/plugin-security-and-authoring.md
@@ -298,6 +298,7 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开
自定义市场以发现并规范化的 manifest 为能力上限。超出能力上限按包内容不一致拒绝并留待
来源修复,不转成用户审批流程;上限内的新版声明仍按上一条判断是否需要用户确认。能力上限按 Host 实际消费语义
比较:真实包不得从无到有增加 `settingsHtml` 设置 WebView 或扩大固定 `settingsHeight`;
+ `taskPreferences` 缺省或为 `true` 时,真实包不能改为 `false` 退出宿主配置管理;
OAuth `scopes` 换序或取子集属于收权,其它 OAuth、凭证标签与注入字段仍须保持在清单上限内;
`setup.requires` 只能保留或删除市场已有的完整需求组,不能增加组、收紧 `anyOf` 或更换引用;
真实包同名工具的 `parameters` JSON Schema 必须与市场规范值一致(仅对象键顺序可不同)。