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。

feat(desktop): 寄存上限调至单次 50MB / 每插件 1GB (#784)

Lizicb3432345b29
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/cindySlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/cindySlot.test.ts
index 6daf7e5733..176276939e 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/cindySlot.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/cindySlot.test.ts
@@ -926,7 +926,9 @@ describe('寄存(deposit_media / release_media)', () => {
it('单次上限:超限在解码前就拒(不为超长串分配解码缓冲)', async () => {
const { slot, sniffDepositMime, depositMedia } = makeSlot();
// 只造字符数、不造真字节:上限判定必须早于 base64 校验与解码。
- const huge = 'A'.repeat(GHOST_CINDY_DEPOSIT_MAX_BYTES * 2);
+ // 刚好越过字符闸(4/3 膨胀率 + padding)即可,不用造两倍——上限已是
+ // 50MB 量级,乘 2 会让每次跑测试白分配上百 MB。
+ const huge = 'A'.repeat(Math.ceil((GHOST_CINDY_DEPOSIT_MAX_BYTES * 4) / 3) + 1024);
const r = await slot.handleModelRequest('art', depositReq(huge));
expect(r).toMatchObject({ ok: false });
expect((r as { message: string }).message).toContain('单次寄存上限');
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
index 43adb374bb..065ffcf31e 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
@@ -538,7 +538,7 @@ describe('FORGE_GUIDE', () => {
"kind: 'deposit_media'",
"kind: 'release_media'",
'"cindy": { "media": ["deposit"] }',
- '每意识配额 512MB',
+ '每意识配额 1GB',
'寄存物不是产物',
]) {
expect(FORGE_GUIDE).toContain(marker);
diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.ts
index 5706b1855b..16b5adba1f 100644
--- a/apps/desktop/src/main/cindy-brain/forge.ts
+++ b/apps/desktop/src/main/cindy-brain/forge.ts
@@ -1206,8 +1206,9 @@ await cindy.send({ type: 'cindy-request', kind: 'release_media', hash: r.hash })
- **类型按字节判**:主机读魔数,只收图片 / 视频 / 音频 / glb。你自报的 mime 或
文件名一概不参考,识别不出直接拒——别拿 svg、zip、json 来试;
-- **单次 ≤16MB**(解码后字节)。超大文件请自己在面板侧压缩再寄存;
-- **每意识配额 512MB**,只算寄存物(你生成的图不占这个额)。同一张图反复寄存
+- **单次 ≤50MB**(解码后字节)。字节要以 base64 走一次 IPC,再大请自己在面板侧
+ 压缩或分片,别指望上限继续抬;
+- **每意识配额 1GB**,只算寄存物(你生成的图不占这个额)。同一张图反复寄存
不重复占额(内容寻址天然去重)。**满了就拒**——不会静默淘汰旧的,因为
"昨天能改今天改不了"是比"存不进去"更糟的体验。用 \`release_media\` 释放;
返回里的 \`quotaUsedBytes\` / \`quotaLimitBytes\` 可用来提前提示用户;
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 074314a389..e0a1af72c0 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -2652,7 +2652,7 @@
"cindyVideoGenerate": "Video generation (delegated to Cindy)",
"cindyVideoEdit": "Image-to-video (delegated to Cindy, reference images from its own media only)",
"cindyMediaDeposit": "Can save images, video or audio it holds into your media library",
- "cindyMediaDepositDetail": "This lets AI work on material you paste or drop into the plugin. Saved items are recorded under this plugin, use at most {{quota}} MB, and are cleaned up when you uninstall it.",
+ "cindyMediaDepositDetail": "This lets AI work on material you paste or drop into the plugin. Saved items are recorded under this plugin, use at most {{quota}}, and are cleaned up when you uninstall it.",
"agentUserAction": "Can start a new Agent turn after you click a plugin card",
"agentUserActionDetail": "Each click permits one turn only, and only in the session that owns the card.",
"agentBackground": "Can automatically start new Agent turns in the background",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index a845b8446e..3b4aae1cf5 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -2651,7 +2651,7 @@
"cindyVideoGenerate": "動画生成(Cindy に代行依頼)",
"cindyVideoEdit": "画像から動画(Cindy に代行依頼、参照画像は自身名義のもののみ)",
"cindyMediaDeposit": "保有している画像・動画・音声をあなたのメディアライブラリに保存できます",
- "cindyMediaDepositDetail": "プラグイン内で貼り付け・ドロップした素材も AI で加工できるようにするための権限です。保存内容はこのプラグイン名義で記録され、最大 {{quota}} MB まで使用し、アンインストール時に併せて削除されます。",
+ "cindyMediaDepositDetail": "プラグイン内で貼り付け・ドロップした素材も AI で加工できるようにするための権限です。保存内容はこのプラグイン名義で記録され、最大 {{quota}} まで使用し、アンインストール時に併せて削除されます。",
"agentUserAction": "プラグインカードをクリックした後、Agent の新しいターンを開始できます",
"agentUserActionDetail": "1 回のクリックにつき 1 回だけ開始でき、そのカードが属するセッションでのみ使用できます。",
"agentBackground": "バックグラウンドで Agent の新しいターンを自動的に開始できます",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index f95eafd88b..2394e2e459 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -2651,7 +2651,7 @@
"cindyVideoGenerate": "영상 생성(Cindy에게 대행 요청)",
"cindyVideoEdit": "이미지로 영상 만들기(Cindy에게 대행 요청, 참조 이미지는 자신 소유만)",
"cindyMediaDeposit": "보유한 이미지·영상·오디오를 내 미디어 라이브러리에 저장할 수 있음",
- "cindyMediaDepositDetail": "플러그인에 붙여넣거나 끌어다 놓은 소재도 AI가 편집할 수 있게 하는 권한입니다. 저장된 항목은 이 플러그인 이름으로 기록되며 최대 {{quota}} MB까지 사용하고, 플러그인을 삭제하면 함께 정리됩니다.",
+ "cindyMediaDepositDetail": "플러그인에 붙여넣거나 끌어다 놓은 소재도 AI가 편집할 수 있게 하는 권한입니다. 저장된 항목은 이 플러그인 이름으로 기록되며 최대 {{quota}}까지 사용하고, 플러그인을 삭제하면 함께 정리됩니다.",
"agentUserAction": "플러그인 카드를 클릭한 뒤 Agent의 새 작업을 시작할 수 있음",
"agentUserActionDetail": "클릭 한 번마다 한 번만 시작할 수 있으며, 해당 카드가 속한 세션에서만 사용할 수 있습니다.",
"agentBackground": "백그라운드에서 Agent의 새 작업을 자동으로 시작할 수 있음",
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 8bcbd1108b..2bd77b4684 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -2651,7 +2651,7 @@
"cindyVideoGenerate": "视频生成(请 Cindy 代办)",
"cindyVideoEdit": "图生视频(请 Cindy 代办,参考图仅限它名下的图)",
"cindyMediaDeposit": "可将它手中的图片、视频或音频存入你的媒体库",
- "cindyMediaDepositDetail": "用于让你在插件里粘贴或拖入的素材也能被 AI 加工。存入的内容记在这个插件名下,最多占用 {{quota}} MB,卸载插件时一并清理。",
+ "cindyMediaDepositDetail": "用于让你在插件里粘贴或拖入的素材也能被 AI 加工。存入的内容记在这个插件名下,最多占用 {{quota}},卸载插件时一并清理。",
"agentUserAction": "用户点击插件卡片后,可让 Agent 开始新一轮工作",
"agentUserActionDetail": "每次点击只允许启动一次,并且只能使用这张卡所属的对话。",
"agentBackground": "可在后台自动让 Agent 开始新一轮工作",
diff --git a/apps/desktop/src/shared/__tests__/ghost.test.ts b/apps/desktop/src/shared/__tests__/ghost.test.ts
index d60352ddc2..b46200aead 100644
--- a/apps/desktop/src/shared/__tests__/ghost.test.ts
+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts
@@ -1439,8 +1439,13 @@ describe('ghost · cindy 详单 video 类目', () => {
labelKey: 'cindyMediaDeposit',
detailKey: 'cindyMediaDepositDetail',
});
- expect(Number(items[0].detailArgs?.quota)).toBe(
- Math.floor(GHOST_CINDY_DEPOSIT_QUOTA_BYTES / (1024 * 1024)),
+ // 数字与单位都从常量算出来(locale 里只有 {{quota}} 占位):反解回字节
+ // 必须等于常量本身 —— 上限调成 GB 量级时,写死 "MB" 的文案就是错的。
+ const quota = items[0].detailArgs?.quota ?? '';
+ expect(quota).toMatch(/^\d+ (MB|GB)$/);
+ const [amount, unit] = quota.split(' ');
+ expect(Number(amount) * 1024 * 1024 * (unit === 'GB' ? 1024 : 1)).toBe(
+ GHOST_CINDY_DEPOSIT_QUOTA_BYTES,
);
});
diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.ts
index abe3d76a60..cc0869a32a 100644
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@ -1412,9 +1412,16 @@ const GHOST_CINDY_PERM_DETAIL: Record<string, string> = {
'media.deposit': 'cindyMediaDepositDetail',
};
-/** 字节 → 确认框里给用户看的整数 MB(向下取整,不给"511.99"这种数)。 */
-function formatGhostQuotaMb(bytes: number): string {
- return String(Math.floor(bytes / (1024 * 1024)));
+/**
+ * 字节 → 确认框里给用户看的容量(含单位)。整数向下取整,不给"511.99"这种数;
+ * 整 GB 用 GB 表述(1GB 显示成"1024 MB"读起来像凑数)。单位跟着数字一起从
+ * 常量算出来,locale 里只留 {{quota}} 占位 —— 否则上限改成 GB 量级时,四份
+ * locale 里写死的 "MB" 就成了错的。
+ */
+function formatGhostQuotaSize(bytes: number): string {
+ const mb = Math.floor(bytes / (1024 * 1024));
+ if (mb >= 1024 && mb % 1024 === 0) return `${mb / 1024} GB`;
+ return `${mb} MB`;
}
/**
@@ -1439,7 +1446,7 @@ export function ghostPermissionItems(manifest: GhostManifest): GhostPermissionIt
// 寄存上限由常量单源插值进确认框说明(媒体规则要求装入确认展示
// 持久媒体占用上限);改常量四份 locale 自动跟随。
...(cap === 'media.deposit'
- ? { detailArgs: { quota: formatGhostQuotaMb(GHOST_CINDY_DEPOSIT_QUOTA_BYTES) } }
+ ? { detailArgs: { quota: formatGhostQuotaSize(GHOST_CINDY_DEPOSIT_QUOTA_BYTES) } }
: {}),
});
}
@@ -4656,8 +4663,20 @@ export const GHOST_CINDY_MAX_ASYNC_JOBS = 2;
* 自带三重硬闸:单次上限、每意识累计配额、令牌桶频控。
*/
-/** 单次寄存上限(解码后字节;与 fs 槽单次写同量级,超限整单拒)。 */
-export const GHOST_CINDY_DEPOSIT_MAX_BYTES = 16 * 1024 * 1024;
+/**
+ * 单次寄存上限(解码后字节;超限整单拒)。
+ *
+ * 2026-07-29 由 16MB(fs 槽单次写量级)上调至 50MB:实拍照片与短视频素材
+ * 常态超过 16MB,压到 16MB 以下要插件自己转码,与"画布上的图直接能改"的
+ * 目标冲突。下游没有新的天花板 —— network `as:'media'` 的入仓硬顶本就是
+ * GHOST_FETCH_MEDIA_MAX_BYTES(256MB),blobStore 不设上限。
+ *
+ * 代价说明白:寄存的字节以 base64 走一次 ghost-pipe IPC(50MB → 约 67MB
+ * 字符串的瞬时分配),这是本通道与 network 通道的结构性差别 —— 后者字节
+ * 全程在主机手里、不过 IPC。因此这个数不宜再往上抬;真需要更大的素材,
+ * 正确解法是插件侧压缩或分片,不是继续抬上限。
+ */
+export const GHOST_CINDY_DEPOSIT_MAX_BYTES = 50 * 1024 * 1024;
/**
* 每意识寄存累计配额(字节)。只统计**寄存**引用(refKind 'ghost-deposit'),
@@ -4665,8 +4684,11 @@ export const GHOST_CINDY_DEPOSIT_MAX_BYTES = 16 * 1024 * 1024;
* 存不进来。内容寻址天然去重:同一张图反复寄存不重复占额。
* 用满的释放口是 release_media(面板删素材时撤回),不做静默 LRU 淘汰
* ——"昨天能改今天改不了"正是 #784 要消灭的体验。
+ *
+ * 2026-07-29 由 512MB 上调至 1GB:单次上限同步抬到 50MB 后,原配额只够存
+ * 十来件大素材,重度使用的无限画布会频繁撞顶。
*/
-export const GHOST_CINDY_DEPOSIT_QUOTA_BYTES = 512 * 1024 * 1024;
+export const GHOST_CINDY_DEPOSIT_QUOTA_BYTES = 1024 * 1024 * 1024;
/**
* 频控令牌桶:容量 = 允许的突发张数(用户一次粘一批图要立刻可用),
@@ -4776,9 +4798,8 @@ export type GhostPipeCindyRequest =
kind: 'deposit_media';
/**
* 媒体字节的 base64(不含 data: 前缀;解码后 ≤
- * GHOST_CINDY_DEPOSIT_MAX_BYTES,与 fs 槽单次写同量级)。真实类型由
- * 主机按字节魔数判定,识别不出受支持媒体一律拒收——自报的 mime /
- * 扩展名不作为依据。
+ * GHOST_CINDY_DEPOSIT_MAX_BYTES = 50MB)。真实类型由主机按字节魔数
+ * 判定,识别不出受支持媒体一律拒收——自报的 mime / 扩展名不作为依据。
*/
data: string;
/** 可选备注(入账 label;仅供主机侧账目与排查,不进聊天)。 */