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(permissions): 复核插件文件交接的最终授权

liugaoweie2f26a3fcff7
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/attachmentGrant.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/attachmentGrant.test.ts
index d9932f936c..fcbb830605 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/attachmentGrant.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/attachmentGrant.test.ts
@@ -37,6 +37,31 @@ function makeDeps(overrides: Partial<AttachmentGrantDeps> = {}): {
}
describe('grantAttachmentsToGhost', () => {
+ it.each(['resolveImageUrl', 'readFile', 'writeBlob', 'recordBlob', 'addRef'] as const)(
+ '%s await 后授权失效,不再执行下一步或返回成功',
+ async (phase) => {
+ let current = true;
+ const { deps, writeBlob, recordBlob, addRef } = makeDeps({ isCurrent: () => current });
+ const original = deps[phase];
+ // 包装具体异步边界,模拟等待期间切 Plan/权限代次。
+ Object.assign(deps, {
+ [phase]: async (...args: unknown[]) => {
+ const result = await (original as (...params: unknown[]) => unknown)(...args);
+ current = false;
+ return result;
+ },
+ });
+ const result = await grantAttachmentsToGhost(deps, {
+ ghostId: 'art', urls: ['xdt-image://s/a.png', 'xdt-image://s/b.png'],
+ });
+ expect(result).toMatchObject({ ok: false, message: expect.stringContaining('permissions changed') });
+ expect(result).not.toHaveProperty('hashes');
+ expect(writeBlob).toHaveBeenCalledTimes(['resolveImageUrl', 'readFile'].includes(phase) ? 0 : 1);
+ expect(recordBlob).toHaveBeenCalledTimes(['recordBlob', 'addRef'].includes(phase) ? 1 : 0);
+ expect(addRef).toHaveBeenCalledTimes(phase === 'addRef' ? 1 : 0);
+ },
+ );
+
it('happy path:逐张落仓 + ghost-grant 记账(originKind=user),按序返回指纹', async () => {
const { deps, recordBlob, addRef } = makeDeps();
const r = await grantAttachmentsToGhost(deps, {
diff --git a/apps/desktop/src/main/cindy-brain/attachmentGrant.ts b/apps/desktop/src/main/cindy-brain/attachmentGrant.ts
index 6c52c32146..a743e8cd74 100644
--- a/apps/desktop/src/main/cindy-brain/attachmentGrant.ts
+++ b/apps/desktop/src/main/cindy-brain/attachmentGrant.ts
@@ -29,6 +29,8 @@ export interface ResolvedGrantSource {
}
export interface AttachmentGrantDeps {
+ /** 同一次审批的实时有效性;异步落仓期间失效后不得继续授予插件引用。 */
+ isCurrent?: () => boolean;
/**
* 附件地址 → 磁盘路径与 mime(越界/非法/账本闸不过一律 throw)。真身是
* ghostAttachmentResolve + 总仓 blob 形态的账本出生闸(异步查账),故允许
@@ -74,6 +76,9 @@ export const MAX_GRANT_ONLY_ATTACHMENTS = 32;
*/
export class GrantPolicyError extends Error {}
+export const GRANT_AUTHORIZATION_CHANGED_MESSAGE =
+ 'Task or Plan permissions changed; retry with the current scope.';
+
export type AttachmentGrantResult =
| { ok: true; hashes: string[] }
| { ok: false; message: string };
@@ -87,16 +92,19 @@ export async function grantAttachmentsToGhost(
params: { ghostId: string; urls: string[]; maxCount?: number },
): Promise<AttachmentGrantResult> {
const { ghostId, urls } = params;
+ const expired = () => deps.isCurrent?.() === false;
+ const denied = { ok: false as const, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
const maxCount = params.maxCount ?? MAX_GRANT_ATTACHMENTS;
if (urls.length === 0) return { ok: true, hashes: [] };
if (urls.length > maxCount) {
return { ok: false, message: `附件过多(单次上限 ${maxCount} 项)` };
}
// 两阶段:先整批解析(纯校验零副作用,最常见的"地址不对"在这里整批拒,
- // 不留半批授权),再逐张落库(读盘/落仓/记账,中途失败仍整批报错;已写入
- // 的授权行无害——那张图确实是用户随消息给出的,留着不构成越权)。
+ // 不留半批授权),再逐张落库。中途失败不返回部分指纹;先前在授权仍有效
+ // 时提交的引用不回滚,但失效后不再落仓、授权或把整批派发给插件。
const resolved: ResolvedGrantSource[] = [];
for (const url of urls) {
+ if (expired()) return denied;
try {
resolved.push(await deps.resolveImageUrl(url));
} catch (err) {
@@ -118,8 +126,11 @@ export async function grantAttachmentsToGhost(
const hashes: string[] = [];
for (const r of resolved) {
try {
+ if (expired()) return denied;
const buffer = r.buffer ?? (await deps.readFile(r.absPath));
+ if (expired()) return denied;
const written = await deps.writeBlob({ buffer, mimeType: r.mimeType });
+ if (expired()) return denied;
await deps.recordBlob({
hash: written.hash,
ext: written.ext,
@@ -128,6 +139,7 @@ export async function grantAttachmentsToGhost(
isCache: false,
});
const originKind = r.originKind ?? 'user';
+ if (expired()) return denied;
await deps.addRef({
hash: written.hash,
// refKind 本身就是回退兼容边界:旧客户端只把 ghost-grant 当成人工
@@ -143,6 +155,7 @@ export async function grantAttachmentsToGhost(
return { ok: false, message: `附件过户失败:${message}` };
}
}
+ if (expired()) return denied;
deps.log?.info('ghost attachment grant: done', { ghostId, count: hashes.length });
return { ok: true, hashes };
}
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts
index 2070a3e16e..3d42d0faaf 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts
@@ -17,6 +17,7 @@ import { createHash } from 'node:crypto';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
+import type { AttachmentGrantDeps } from '../../cindy-brain/attachmentGrant';
import type {
GhostSetupEnsureRequest,
GhostSetupEnsureResult,
@@ -192,8 +193,8 @@ vi.mock('../../cindy-brain/ghostSetupCoordinator.js', () => ({
}),
}));
// 以下依赖在本测试路径上不会被触达,但 import 副作用重,一律断开。
-vi.mock('../../cindy-brain/attachmentGrant.js', () => ({
- GrantPolicyError: class extends Error {},
+vi.mock('../../cindy-brain/attachmentGrant.js', async (importOriginal) => ({
+ ...await importOriginal<typeof import('../../cindy-brain/attachmentGrant.js')>(),
grantAttachmentsToGhost: grantAttachmentsMock,
MAX_GRANT_ATTACHMENTS: 4,
MAX_GRANT_ONLY_ATTACHMENTS: 32,
@@ -2122,6 +2123,80 @@ describe('Full Access 插件文件交接', () => {
describe('Host Auto review', () => {
+ it.each(['bypassPermissions', 'auto', 'ask'].flatMap((permissionMode) =>
+ [false, true].map((grantOnly) => ({ permissionMode, grantOnly })),
+ ))('$permissionMode / grant_only=$grantOnly 在最终授权记账前再次复核', async ({ permissionMode, grantOnly }) => {
+ let current = true;
+ let granting = false;
+ const file = path.join(outsideDir, 'late-ledger.png');
+ fs.writeFileSync(file, 'late-ledger');
+ liveGrantStateMock.mockReturnValue({ permissionMode, remoteHostId: null,
+ isCurrent: () => current, reviewAction: async () => ({ verdict: 'allow' }),
+ });
+ ledgerHasRefMock.mockImplementation(async () => {
+ if (granting) current = false;
+ return false;
+ });
+ const actual = await vi.importActual<typeof import('../../cindy-brain/attachmentGrant')>('../../cindy-brain/attachmentGrant');
+ grantAttachmentsMock.mockImplementationOnce((deps: AttachmentGrantDeps, params) => {
+ granting = true;
+ return actual.grantAttachmentsToGhost({ ...deps,
+ writeBlob: async () => ({ hash: 'a'.repeat(64), ext: '.png', mimeType: 'image/png', bytes: 11 }),
+ recordBlob: async () => {},
+ }, params);
+ });
+ const result = await makeDeps().callGhostTool({ ghostId: 'art', tool: 'run', args: {}, attachments: [file], grantOnly });
+ expect(result).toMatchObject({ ok: false, message: expect.stringContaining('permissions changed') });
+ expect(ledgerAddRefMock).not.toHaveBeenCalled();
+ expect(dispatchMock).not.toHaveBeenCalled();
+ });
+
+ it.each(['dir', 'saveDir'] as const)('%s 在 Full 返回与票据签发之间失效时拒绝', async (lane) => {
+ let current = true;
+ liveGrantStateMock.mockImplementation(() => {
+ queueMicrotask(() => { current = false; });
+ return { permissionMode: 'bypassPermissions', remoteHostId: null, isCurrent: () => current };
+ });
+ const result = await makeDeps().callGhostTool({ ghostId: 'art', tool: 'run', args: {}, [lane]: outsideDir });
+ expect(result).toMatchObject({ ok: false, message: expect.stringContaining('permissions changed') });
+ expect(dirDepositMock).not.toHaveBeenCalled();
+ expect(saveDepositMock).not.toHaveBeenCalled();
+ expect(dispatchMock).not.toHaveBeenCalled();
+ });
+
+ it.each((['claude-code', 'codex', 'pi'] as const).flatMap((agentKind) =>
+ (['attachments', 'dir', 'saveDir'] as const).map((lane) => ({ agentKind, lane })),
+ ))('$agentKind 的 $lane 在派发前失效不能交给插件', async ({ agentKind, lane }) => {
+ let current = true;
+ const file = path.join(outsideDir, 'late-dispatch.png');
+ fs.writeFileSync(file, 'late-dispatch');
+ listMock.mockReturnValue([chipGhost('art', ['tool', 'session-context'])]);
+ liveGrantStateMock.mockReturnValue({ permissionMode: 'bypassPermissions', remoteHostId: null, isCurrent: () => current });
+ sessionSnapshotMock.mockImplementationOnce(async () => {
+ current = false;
+ return { workingDir: WORKDIR, permissionMode: 'auto', planModeEnabled: true, remoteHostId: null };
+ });
+ const result = await makeDeps(agentKind).callGhostTool({ ghostId: 'art', tool: 'run', args: {},
+ ...(lane === 'attachments' ? { attachments: [file] } : { [lane]: outsideDir }),
+ });
+ expect(result).toMatchObject({ ok: false, message: expect.stringContaining('permissions changed') });
+ expect(sessionSnapshotMock).toHaveBeenCalledOnce();
+ expect(dispatchMock).not.toHaveBeenCalled();
+ });
+
+ it('后一个目录取得新授权,不能替换同一请求中已失效的先前授权', async () => {
+ let generation = 0;
+ liveGrantStateMock.mockImplementation(() => {
+ const captured = generation++;
+ return { permissionMode: 'bypassPermissions', remoteHostId: null, isCurrent: () => generation === captured + 1 };
+ });
+ const result = await makeDeps().callGhostTool({ ghostId: 'art', tool: 'run', args: {}, dir: outsideDir, saveDir: outsideDir });
+ expect(result).toMatchObject({ ok: false, message: expect.stringContaining('permissions changed') });
+ expect(dirDepositMock).toHaveBeenCalledOnce();
+ expect(saveDepositMock).not.toHaveBeenCalled();
+ expect(dispatchMock).not.toHaveBeenCalled();
+ });
+
it.each(['bypassPermissions', 'auto', 'ask'] as const)('%s rejects media reveal and file handoff with unavailable Plan authority', async (permissionMode) => {
liveGrantStateMock.mockReturnValue({ permissionMode, remoteHostId: null, isCurrent: () => false });
const file = path.join(outsideDir, `plan-${permissionMode}.png`);
diff --git a/apps/desktop/src/main/mcp-integrations/ghost.ts b/apps/desktop/src/main/mcp-integrations/ghost.ts
index 443ff74323..744ce6175d 100644
--- a/apps/desktop/src/main/mcp-integrations/ghost.ts
+++ b/apps/desktop/src/main/mcp-integrations/ghost.ts
@@ -38,6 +38,7 @@ import { toolAutoReviewAction, type PermissionMode, type ReviewableAction, type
import { getLiziMcpSessionContext, type LiziMcpSessionContext } from '@cindy/mcps';
import {
+ GRANT_AUTHORIZATION_CHANGED_MESSAGE,
GrantPolicyError,
grantAttachmentsToGhost,
MAX_GRANT_ATTACHMENTS,
@@ -389,12 +390,12 @@ async function requestGrantConfirm(params: {
items: GhostGrantFileItem[];
getLiveSessionGrantState?: CindyGhostsHostDeps['getLiveSessionGrantState'];
}): Promise<
- | { ok: true; approvalSource: GhostGrantApprovalSource; allowDirs?: boolean }
+ | { ok: true; approvalSource: GhostGrantApprovalSource; allowDirs?: boolean; isCurrent?: () => boolean }
| { ok: false; message: string }
> {
let isCurrent: (() => boolean) | undefined;
const expired = () => isCurrent?.() === false;
- const denied = { ok: false as const, message: 'Task or Plan permissions changed; retry with the current scope.' };
+ const denied = { ok: false as const, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
if (params.sessionId && params.sessionInstanceId && params.getLiveSessionGrantState) {
try {
const live = params.getLiveSessionGrantState(params.sessionId, params.sessionInstanceId);
@@ -409,7 +410,7 @@ async function requestGrantConfirm(params: {
count: params.items.length,
grantSource: 'full-access',
});
- return { ok: true, approvalSource: 'full-access' };
+ return { ok: true, approvalSource: 'full-access', isCurrent };
}
if (live?.permissionMode === 'auto' && live.reviewAction) {
const decision = await live.reviewAction(toolAutoReviewAction('plugin_file_handoff', {
@@ -420,7 +421,7 @@ async function requestGrantConfirm(params: {
if (expired()) return denied;
if (decision.verdict === 'allow') {
log.info('ghost grant: AI approved outside-workdir handoff', { ghostId: params.ghostId, lane: params.lane, grantSource: 'auto-review' });
- return { ok: true, approvalSource: 'auto-review' };
+ return { ok: true, approvalSource: 'auto-review', isCurrent };
}
if (decision.verdict === 'block') return { ok: false, message: decision.reason ?? 'Automatic review denied this file handoff.' };
}
@@ -458,7 +459,7 @@ async function requestGrantConfirm(params: {
});
if (expired()) return denied;
if (decision.confirmed) {
- return { ok: true, approvalSource: 'user', allowDirs: decision.allowDirs };
+ return { ok: true, approvalSource: 'user', allowDirs: decision.allowDirs, isCurrent };
}
return {
ok: false,
@@ -579,9 +580,10 @@ async function prepareLocalPathAttachments(params: {
/** 项数上限(普通调用 MAX_GRANT_ATTACHMENTS;grant_only 批量预授权放宽)。 */
maxCount: number;
}): Promise<
- { ok: true; resolved: Map<string, ResolvedGrantSource> } | { ok: false; message: string }
+ { ok: true; resolved: Map<string, ResolvedGrantSource>; isCurrent?: () => boolean } | { ok: false; message: string }
> {
const resolved = new Map<string, ResolvedGrantSource>();
+ let isCurrent: (() => boolean) | undefined;
// 超项数上限时不弹确认,直接交给 grant 流程报标准错(别让用户白点一次)。
if (params.urls.length > params.maxCount) return { ok: true, resolved };
const outside: Array<{
@@ -707,6 +709,8 @@ async function prepareLocalPathAttachments(params: {
getLiveSessionGrantState: params.getLiveSessionGrantState,
});
if (!confirm.ok) return confirm;
+ isCurrent = confirm.isCurrent;
+ if (isCurrent?.() === false) return { ok: false, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
for (const o of needConfirm) {
// 人工确认记 user;Full Access 自动交接记 tool,不能伪装成用户点击。
// 两者都带 T1 字节落仓——确认/授权判定时读到的字节就是实际过户
@@ -741,7 +745,7 @@ async function prepareLocalPathAttachments(params: {
}
}
}
- return { ok: true, resolved };
+ return { ok: true, resolved, isCurrent };
}
/**
@@ -759,8 +763,8 @@ async function confirmDepositOutsideWorkdir(params: {
workdirAbs: string | null;
getLiveSessionGrantState?: CindyGhostsHostDeps['getLiveSessionGrantState'];
}): Promise<
- | { ok: true; userGranted: false }
- | { ok: true; userGranted: true; approvedRealPath: string }
+ | { ok: true; userGranted: false; isCurrent?: () => boolean }
+ | { ok: true; userGranted: true; approvedRealPath: string; isCurrent?: () => boolean }
| { ok: false; message: string }
> {
if (!path.isAbsolute(params.dirAbs)) return { ok: true, userGranted: false };
@@ -814,6 +818,7 @@ async function confirmDepositOutsideWorkdir(params: {
getLiveSessionGrantState: params.getLiveSessionGrantState,
});
if (!confirm.ok) return confirm;
+ if (confirm.isCurrent?.() === false) return { ok: false, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
// Full Access 是每次在实时档位上自动裁决,不伪造「用户确认过」的目录
// 记忆。这样热切回 ask/auto 后,同一路径的新过户会立刻恢复询问。
if (confirm.approvalSource === 'user' && params.sessionId) {
@@ -826,7 +831,7 @@ async function confirmDepositOutsideWorkdir(params: {
grantSource: 'user-confirmation',
});
}
- return { ok: true, userGranted: true, approvedRealPath: real };
+ return { ok: true, userGranted: true, approvedRealPath: real, isCurrent: confirm.isCurrent };
}
type ManagedToolGrantCandidate = {
@@ -851,7 +856,7 @@ async function prepareManagedToolGrantSources(params: {
sessionInstanceId: string | null;
getLiveSessionGrantState?: CindyGhostsHostDeps['getLiveSessionGrantState'];
}): Promise<
- { ok: true; resolved: Map<string, ResolvedGrantSource> } | { ok: false; message: string }
+ { ok: true; resolved: Map<string, ResolvedGrantSource>; isCurrent?: () => boolean } | { ok: false; message: string }
> {
// Preserve attachmentGrant's standard count error and, importantly, do not
// read or confirm an over-limit batch before that error is produced.
@@ -969,6 +974,7 @@ async function prepareManagedToolGrantSources(params: {
getLiveSessionGrantState: params.getLiveSessionGrantState,
});
if (!confirm.ok) return confirm;
+ if (confirm.isCurrent?.() === false) return { ok: false, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
const originKind = confirm.approvalSource === 'user' ? 'user' : 'tool';
const resolved = new Map<string, ResolvedGrantSource>();
@@ -981,7 +987,7 @@ async function prepareManagedToolGrantSources(params: {
};
for (const url of candidate.urls) resolved.set(url, source);
}
- return { ok: true, resolved };
+ return { ok: true, resolved, isCurrent: confirm.isCurrent };
}
/**
@@ -998,7 +1004,7 @@ async function grantAttachmentUrls(params: {
sessionInstanceId: string | null;
getLiveSessionGrantState?: CindyGhostsHostDeps['getLiveSessionGrantState'];
maxCount: number;
-}): Promise<{ ok: true; hashes: string[] } | { ok: false; message: string }> {
+}): Promise<{ ok: true; hashes: string[]; isCurrent: () => boolean } | { ok: false; message: string }> {
const { ghostId } = params;
const localGrant = await prepareLocalPathAttachments({
urls: params.urls,
@@ -1010,6 +1016,7 @@ async function grantAttachmentUrls(params: {
maxCount: params.maxCount,
});
if (!localGrant.ok) return localGrant;
+ if (localGrant.isCurrent?.() === false) return { ok: false, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
const managedToolGrant = await prepareManagedToolGrantSources({
urls: params.urls,
ghostId,
@@ -1020,8 +1027,11 @@ async function grantAttachmentUrls(params: {
getLiveSessionGrantState: params.getLiveSessionGrantState,
});
if (!managedToolGrant.ok) return managedToolGrant;
- return grantAttachmentsToGhost(
+ // 保留两次预处理捕获的授权,不能用后取的快照替换先前代次。
+ const isCurrent = () => localGrant.isCurrent?.() !== false && managedToolGrant.isCurrent?.() !== false;
+ const result = await grantAttachmentsToGhost(
{
+ isCurrent,
// 宽容解析:模型可能只有本地路径、缩图副本路径、或把 xdt-image
// 地址的会话段拼丢(多个会话实测都踩过)——统一归一化。
// 总仓 blob 形态(聊天附件或当前 Agent 工具结果的受管地址)额外过
@@ -1077,12 +1087,15 @@ async function grantAttachmentUrls(params: {
refId: p.refId,
originKind: p.originKind,
});
+ if (!isCurrent()) throw new GrantPolicyError(GRANT_AUTHORIZATION_CHANGED_MESSAGE);
return exists ? '' : ledger.addRef(p);
},
log,
},
{ ghostId, urls: params.urls, maxCount: params.maxCount },
);
+ if (!isCurrent()) return { ok: false, message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
+ return result.ok ? { ...result, isCurrent } : result;
}
function ghostHasTools(ghost: InstalledGhost): boolean {
@@ -1555,6 +1568,11 @@ export function getCindyGhostsMcpDeps(
// args.attachments 交给意识。任何一张失败整批拒(ATTACHMENT_INVALID),
// 不做半成品授权。全链路见 grantAttachmentUrls。
let mergedArgs = args;
+ // 文件交接的原授权要贯穿后续目录审批、上下文查询和最终派发。
+ const handoffChecks: Array<() => boolean> = [];
+ const handoffExpired = () => handoffChecks.some((isCurrent) => !isCurrent());
+ const handoffDenied = { ok: false as const, errorCode: 'PERMISSION_DENIED' as const,
+ message: GRANT_AUTHORIZATION_CHANGED_MESSAGE };
// Runtime setup gate: the shared visibility check above runs before any
// durable attachment grant, directory ticket, sandbox, card call, or dispatch.
// grant_only never dispatches and intentionally ignores its tool field.
@@ -1702,6 +1720,7 @@ export function getCindyGhostsMcpDeps(
message: t('newChat.pluginSetup.assessmentReadFailed'),
};
}
+ if (!grant.isCurrent()) return handoffDenied;
log.info('ghost grant-only: batch pre-granted', { ghostId, count: grant.hashes.length });
return {
ok: true,
@@ -1729,6 +1748,8 @@ export function getCindyGhostsMcpDeps(
if (!grant.ok) {
return { ok: false, errorCode: 'ATTACHMENT_INVALID', message: grant.message };
}
+ handoffChecks.push(grant.isCurrent);
+ if (handoffExpired()) return handoffDenied;
mergedArgs = { ...args, attachments: grant.hashes };
}
// 目录过户(xd-service 意识化二期):dir 收集文件发一次性票据,元数据
@@ -1736,6 +1757,7 @@ export function getCindyGhostsMcpDeps(
// networkSlot 凭票读盘代组 multipart。钳制两层策略:workdir 内直通,
// workdir 外(含无 workdir 语境)经确认卡放行。
if (dir !== undefined) {
+ if (handoffExpired()) return handoffDenied;
const dirConfirm = await confirmDepositOutsideWorkdir({
ghostId,
sessionId: sessionIdForConfirm,
@@ -1748,6 +1770,8 @@ export function getCindyGhostsMcpDeps(
if (!dirConfirm.ok) {
return { ok: false, errorCode: 'DIR_INVALID', message: dirConfirm.message };
}
+ if (dirConfirm.isCurrent) handoffChecks.push(dirConfirm.isCurrent);
+ if (handoffExpired()) return handoffDenied;
const deposited = getDirDepositVault().deposit({
ghostId,
dirAbs: dirConfirm.userGranted ? dirConfirm.approvedRealPath : dir,
@@ -1764,6 +1788,7 @@ export function getCindyGhostsMcpDeps(
// args.save_deposit——意识 fetch as:'file' 报票据,主机把响应字节直接
// 写进该目录,绝对路径与字节不进沙箱。钳制两层策略同 dir。
if (saveDir !== undefined) {
+ if (handoffExpired()) return handoffDenied;
const saveConfirm = await confirmDepositOutsideWorkdir({
ghostId,
sessionId: sessionIdForConfirm,
@@ -1776,6 +1801,8 @@ export function getCindyGhostsMcpDeps(
if (!saveConfirm.ok) {
return { ok: false, errorCode: 'DIR_INVALID', message: saveConfirm.message };
}
+ if (saveConfirm.isCurrent) handoffChecks.push(saveConfirm.isCurrent);
+ if (handoffExpired()) return handoffDenied;
const saveDeposited = getSaveDepositVault().deposit({
ghostId,
dirAbs: saveConfirm.userGranted ? saveConfirm.approvedRealPath : saveDir,
@@ -1875,6 +1902,7 @@ export function getCindyGhostsMcpDeps(
message: t('newChat.pluginSetup.assessmentReadFailed'),
};
}
+ if (handoffExpired()) return handoffDenied;
// ── 卡槽③:callId 在这里预铸并登记给卡片服务 ────────────────────
// 时序契约:register(供片窗开)→ dispatch(意识拿到同一 callId,执行
// 中可 card-update)→ finalize(问"这单供过卡吗",开晚到宽限窗)→