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(provider-sharing): 补齐 IM 凭证授权并清理切档后的临时批准

DavidShenbfcd51b9f5c7
diff --git a/apps/desktop/src/main/im/shared/__tests__/cardActionAskMulti.test.ts b/apps/desktop/src/main/im/shared/__tests__/cardActionAskMulti.test.ts
index afe19fa97d..b4e6b22625 100644
--- a/apps/desktop/src/main/im/shared/__tests__/cardActionAskMulti.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/cardActionAskMulti.test.ts
@@ -85,6 +85,9 @@ import { createCardActionHandler } from '../cardActionHandler';
import { createCardBuilders } from '../cardBuilders';
import { cancelPending, lookupPending, registerPending } from '../pendingInteractions';
import { activateImAccountBoundary } from '../../accountBoundary';
+import { PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL } from '../../../../shared/providerShareCredentialConsent';
+import { createSharedPermission } from '../../../maker-ipc/sharedPermission';
+import { presentSharedPermissionCard } from '../permissionPresentation';
import type { ImChannelAdapter } from '../types';
import type { ImTurnRunner } from '../turnRunner';
@@ -184,6 +187,56 @@ afterEach(() => {
for (const id of liveRequestIds.splice(0)) cancelPending(id, 'test-end');
});
+describe('本机凭证确认卡的 IM 按钮', () => {
+ it.each(['direct', 'shared'] as const)('%s 路径保留任务授权,普通卡忽略按钮伪造的标记', async (route) => {
+ const im = makeIm();
+ let handler!: (event: IMCardActionEvent) => Promise<void>;
+ im.onCardAction.mockImplementation((cb) => {
+ handler = cb;
+ return () => {};
+ });
+ createCardActionHandler(adapter, cards, turnRunner)(im)();
+ for (const choice of ['always', 'once', 'deny', 'ordinary']) {
+ const requestId = `credential-${route}-${choice}`;
+ liveRequestIds.push(requestId);
+ const credentialContext = {
+ metadata: { hostOwnedConfirmation: 'shared_provider_credential' },
+ suggestions: [PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL],
+ };
+ const permissionRequest = {
+ toolName: 'Read',
+ ...(choice === 'ordinary' ? {} : credentialContext),
+ };
+ const decision = route === 'direct'
+ ? registerPending(requestId, 'permission', 'card-1', { permissionRequest })
+ : presentSharedPermissionCard({
+ requestId, permissionRequest, owner: Symbol(), permission: createSharedPermission(),
+ send: async () => ({ messageId: 'card-1' }),
+ resolved: () => ({ body: 'resolved', buttons: [] }),
+ update: im.updateInteractiveCard,
+ onError: (error) => { throw error; },
+ });
+ await handler({
+ channelName: 'feishu', chatId: 'ou_owner', messageId: 'card-1', senderId: 'ou_owner',
+ buttonId: choice === 'deny' ? 'permission:deny' : `permission:allow:${choice === 'ordinary' ? 'always' : choice}`,
+ // Payload metadata must never control the permission scope.
+ payload: { requestId, ...credentialContext },
+ });
+ const expected = choice === 'deny'
+ ? { kind: 'permission', behavior: 'deny', reason: 'user_denied' }
+ : {
+ kind: 'permission', behavior: 'allow',
+ ...(choice === 'once' ? {} : {
+ permissionUpdates: choice === 'ordinary'
+ ? [{ type: 'addRules', rules: [{ toolName: 'Read' }], behavior: 'allow', destination: 'session' }]
+ : [PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL],
+ }),
+ };
+ await expect(decision).resolves.toEqual(expected);
+ }
+ });
+});
+
describe('ask 多题/多选打勾卡', () => {
it('多选题: 切换勾选态并原地 patch(✓ 前缀), 再点一次取消', async () => {
const { im, press, patchedSpec } = setupAskMulti('req-toggle');
diff --git a/apps/desktop/src/main/im/shared/__tests__/interactionCardModel.test.ts b/apps/desktop/src/main/im/shared/__tests__/interactionCardModel.test.ts
index a835525f99..26d7d16dd7 100644
--- a/apps/desktop/src/main/im/shared/__tests__/interactionCardModel.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/interactionCardModel.test.ts
@@ -11,6 +11,7 @@
import { describe, expect, it } from 'vitest';
import { SESSION_PERMISSION_DESTINATION, type InteractionRequest } from '@cindy/maker-core';
+import { PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL } from '../../../../shared/providerShareCredentialConsent';
import { composeInteractionCard } from '../../../hook-control/interactions';
import { ui } from '../../feishu/uiText';
@@ -67,7 +68,7 @@ function imDecisionFromButton(
return buildPermissionAllowOnceDecision();
case 'permission:allow:always':
return toolName
- ? buildPermissionAllowAlwaysDecision(toolName)
+ ? buildPermissionAllowAlwaysDecision({ toolName })
: buildPermissionAllowOnceDecision();
case 'permission:deny':
return buildPermissionDenyDecision(PERMISSION_USER_DENIED_REASON);
@@ -263,7 +264,7 @@ describe('composeInteractionModel — v1 规则', () => {
});
it('permission 的会话级 addRules destination 与 maker-core 常量同值(防漂移)', () => {
- const decision = buildPermissionAllowAlwaysDecision('Bash');
+ const decision = buildPermissionAllowAlwaysDecision({ toolName: 'Bash' });
expect(decision).toEqual({
kind: 'permission',
behavior: 'allow',
@@ -280,6 +281,24 @@ describe('composeInteractionModel — v1 规则', () => {
});
describe('跨实现一致性 — IM cardBuilders vs hook composeInteractionCard', () => {
+ it('本机凭证卡回传专用授权标记,普通卡不采信孤立的标记或 metadata', () => {
+ const req: PermissionRequest = {
+ ...PERMISSION_RICH,
+ metadata: { hostOwnedConfirmation: 'shared_provider_credential' },
+ suggestions: [PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL],
+ };
+ const expected = {
+ kind: 'permission', behavior: 'allow',
+ permissionUpdates: [PROVIDER_SHARE_CREDENTIAL_SESSION_APPROVAL],
+ };
+ expect(composeInteractionModel(req).choices[1].decision).toEqual(expected);
+ const hook = composeInteractionCard(req)!;
+ expect(hook.decisions.get(hook.card.buttons[1].id)).toEqual(expected);
+ const ordinary = buildPermissionAllowAlwaysDecision({ toolName: req.toolName });
+ expect(buildPermissionAllowAlwaysDecision({ ...req, metadata: undefined })).toEqual(ordinary);
+ expect(buildPermissionAllowAlwaysDecision({ ...req, suggestions: undefined })).toEqual(ordinary);
+ });
+
it('ask(多问 / 多选 / 超长 label): 两侧选项集与决策逐项对齐', () => {
const model = composeInteractionModel(ASK_MULTI)!;
if (model.kind !== 'ask_user_question') throw new Error('unreachable');
diff --git a/apps/desktop/src/main/im/shared/__tests__/pendingInteractions.test.ts b/apps/desktop/src/main/im/shared/__tests__/pendingInteractions.test.ts
index 581c213341..bfd4454f5b 100644
--- a/apps/desktop/src/main/im/shared/__tests__/pendingInteractions.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/pendingInteractions.test.ts
@@ -55,7 +55,7 @@ describe('cancelPending 交还卡片地址', () => {
// register 走了默认 extras; 这里补登记带 permissionCard 的版本(新 requestId)。
const resolve2 = vi.fn();
registerPendingExternal('req-perm2', 'permission', 'chat|666', resolve2, vi.fn(), {
- toolName: 'Bash',
+ permissionRequest: { toolName: 'Bash' },
permissionCard: { title: '🔧 工具调用:Bash', body: '**参数预览**\n```json\n{"cmd": "ls"}\n```' },
});
diff --git a/apps/desktop/src/main/im/shared/__tests__/permissionPresentation.test.ts b/apps/desktop/src/main/im/shared/__tests__/permissionPresentation.test.ts
index 40538aae83..ff6d31eab0 100644
--- a/apps/desktop/src/main/im/shared/__tests__/permissionPresentation.test.ts
+++ b/apps/desktop/src/main/im/shared/__tests__/permissionPresentation.test.ts
@@ -26,7 +26,7 @@ function presentation(requestId: string, send = vi.fn(async () => ({ messageId:
const onError = vi.fn();
const result = presentSharedPermissionCard({
requestId,
- toolName: 'Bash',
+ permissionRequest: { toolName: 'Bash' },
owner: Symbol(),
permission,
send,
diff --git a/apps/desktop/src/main/im/shared/cardActionHandler.ts b/apps/desktop/src/main/im/shared/cardActionHandler.ts
index e101ee8620..8d655c977f 100644
--- a/apps/desktop/src/main/im/shared/cardActionHandler.ts
+++ b/apps/desktop/src/main/im/shared/cardActionHandler.ts
@@ -1446,18 +1446,15 @@ export function createCardActionHandler(
case 'permission:allow:once':
return buildPermissionAllowOnceDecision();
case 'permission:allow:always': {
- // "Allow always for this session": ask the SDK to add a session-scoped
- // allow rule for the same toolName so subsequent calls of the same tool
- // skip the canUseTool callback. toolName comes from the original
- // InteractionRequest (stashed in pendingInteractions at register time).
+ // 授权范围只从本机保存的原请求恢复,不采信按钮回传的授权标记。
const entry = requestId ? lookupPending(requestId) : null;
- const toolName = entry?.toolName;
- if (!toolName) {
- // No toolName recoverable — degrade to plain allow (one-shot). User
+ const request = entry?.permissionRequest;
+ if (!request) {
+ // No request recoverable — degrade to plain allow (one-shot). User
// sees the same outcome as "allow once" for this single call.
return buildPermissionAllowOnceDecision();
}
- return buildPermissionAllowAlwaysDecision(toolName);
+ return buildPermissionAllowAlwaysDecision(request);
}
case 'permission:deny':
return buildPermissionDenyDecision(PERMISSION_USER_DENIED_REASON);
diff --git a/apps/desktop/src/main/im/shared/interactionCardModel.ts b/apps/desktop/src/main/im/shared/interactionCardModel.ts
index 23cd630188..f89f66656c 100644
--- a/apps/desktop/src/main/im/shared/interactionCardModel.ts
+++ b/apps/desktop/src/main/im/shared/interactionCardModel.ts
@@ -28,6 +28,12 @@ import type {
InteractionDecision,
InteractionRequest,
} from '@cindy/maker-core';
+import { isProviderShareCredentialSessionApproval } from '../../../shared/providerShareCredentialConsent';
+
+export type SessionPermissionRequest = Pick<
+ Extract<InteractionRequest, { kind: 'permission' }>,
+ 'toolName' | 'metadata' | 'suggestions'
+>;
// ── 语义常量 ────────────────────────────────────────────────────────────────
@@ -142,12 +148,17 @@ export function buildPermissionAllowOnceDecision(): InteractionDecision {
* createSessionPermissionUpdate 同值, 这里就地写死只为不给 hook 链路引入
* maker-core 运行期依赖; 漂移由本模块单测钉住(见 __tests__)。
*/
-export function buildPermissionAllowAlwaysDecision(toolName: string): InteractionDecision {
+export function buildPermissionAllowAlwaysDecision(request: SessionPermissionRequest): InteractionDecision {
+ // 本机凭证卡的授权范围由宿主定义,不能转换成普通工具的 addRules。
+ if (request.metadata?.hostOwnedConfirmation === 'shared_provider_credential'
+ && isProviderShareCredentialSessionApproval(request.suggestions)) {
+ return { kind: 'permission', behavior: 'allow', permissionUpdates: request.suggestions };
+ }
return {
kind: 'permission',
behavior: 'allow',
permissionUpdates: [
- { type: 'addRules', rules: [{ toolName }], behavior: 'allow', destination: 'session' },
+ { type: 'addRules', rules: [{ toolName: request.toolName }], behavior: 'allow', destination: 'session' },
],
};
}
@@ -374,7 +385,7 @@ export function composeInteractionModel(req: InteractionRequest): InteractionMod
index: 1,
label: null,
style: 'default',
- decision: buildPermissionAllowAlwaysDecision(req.toolName),
+ decision: buildPermissionAllowAlwaysDecision(req),
},
{
choiceId: 'permission:deny',
diff --git a/apps/desktop/src/main/im/shared/pendingInteractions.ts b/apps/desktop/src/main/im/shared/pendingInteractions.ts
index 2c02729193..28040eaa3f 100644
--- a/apps/desktop/src/main/im/shared/pendingInteractions.ts
+++ b/apps/desktop/src/main/im/shared/pendingInteractions.ts
@@ -17,6 +17,7 @@ import {
buildAskNoAnswerDecision,
buildPermissionDenyDecision,
buildPlanDenyDecision,
+ type SessionPermissionRequest,
} from './interactionCardModel';
interface PendingEntry {
@@ -30,12 +31,10 @@ interface PendingEntry {
/** For sanity / log: which kind we're awaiting. */
kind: InteractionDecision['kind'];
/**
- * Original toolName from the InteractionRequest (only set when kind ===
- * 'permission'). Needed to construct `permissionUpdates` for "always
- * allow this tool" semantics — cardActionHandler doesn't have access to
- * the request, so we stash it here at register time.
+ * Original permission context, including host-owned session consent.
+ * Only the stored request determines "always allow"; button payloads do not.
*/
- toolName?: string;
+ permissionRequest?: SessionPermissionRequest;
/**
* 授权卡原始正文(title + body, 仅 kind === 'permission')。点击后收口时
* 保留它再追加决策结果 — 用户需要看到自己批准的是什么, 不能整卡换成
@@ -45,7 +44,7 @@ interface PendingEntry {
/**
* 多题/多选打勾卡的原始问题(仅 kind === 'ask_user_question' 且
* needsAskMultiCard 时登记)。ask:multi 按键要按问题下标改写勾选态并
- * 重建卡片, cardActionHandler 拿不到原始请求, 与 toolName 同理登记在此。
+ * 重建卡片, cardActionHandler 拿不到原始请求, 与 permissionRequest 同理登记在此。
*/
askQuestions?: AskUserQuestionItem[];
/**
@@ -65,7 +64,7 @@ export function registerPending(
extras?: {
sharedPermission?: SharedPermission;
owner?: symbol;
- toolName?: string;
+ permissionRequest?: SessionPermissionRequest;
permissionCard?: { title: string; body: string };
askQuestions?: AskUserQuestionItem[];
askSelections?: Map<number, Set<number>>;
@@ -97,7 +96,7 @@ export function registerPendingExternal(
extras?: {
sharedPermission?: SharedPermission;
owner?: symbol;
- toolName?: string;
+ permissionRequest?: SessionPermissionRequest;
permissionCard?: { title: string; body: string };
askQuestions?: AskUserQuestionItem[];
askSelections?: Map<number, Set<number>>;
@@ -113,7 +112,7 @@ export function registerPendingExternal(
messageId,
kind,
owner: extras?.owner,
- toolName: extras?.toolName,
+ permissionRequest: extras?.permissionRequest,
permissionCard: extras?.permissionCard,
askQuestions: extras?.askQuestions,
askSelections: extras?.askSelections,
diff --git a/apps/desktop/src/main/im/shared/permissionPresentation.ts b/apps/desktop/src/main/im/shared/permissionPresentation.ts
index e19c563f3d..c048fd6ad4 100644
--- a/apps/desktop/src/main/im/shared/permissionPresentation.ts
+++ b/apps/desktop/src/main/im/shared/permissionPresentation.ts
@@ -6,6 +6,7 @@ import {
} from '../../maker-ipc/sharedPermission';
import { hasSessionPermissionUpdates } from '@cindy/maker-core';
import { forgetSharedPending, registerPendingExternal } from './pendingInteractions';
+import type { SessionPermissionRequest } from './interactionCardModel';
/** Receipt only: the Host may hold the choice until the task resumes. */
export const INTERACTION_CHOICE_RECEIVED_TEXT = '已收到你的选择。';
@@ -26,7 +27,7 @@ export function permissionOutcomeText(decision: InteractionDecision, toolName?:
/** Register before network IO; a Desktop decision may arrive while send is in flight. */
export function presentSharedPermissionCard(args: {
requestId: string;
- toolName: string;
+ permissionRequest: SessionPermissionRequest;
owner: symbol;
permission: SharedPermission;
send(): Promise<{ messageId: string }>;
@@ -44,7 +45,7 @@ export function presentSharedPermissionCard(args: {
() => {
permission.settle({ kind: 'permission', behavior: 'deny', reason: 'session_disposed' });
},
- { owner: args.owner, toolName: args.toolName, sharedPermission: permission },
+ { owner: args.owner, permissionRequest: args.permissionRequest, sharedPermission: permission },
);
void permission.result.then(() => forgetSharedPending(requestId, permission));
// Sending and updating are presentation only: neither delays execution nor
diff --git a/apps/desktop/src/main/im/shared/turnRunner.ts b/apps/desktop/src/main/im/shared/turnRunner.ts
index cd5f212dc3..efdb27eda4 100644
--- a/apps/desktop/src/main/im/shared/turnRunner.ts
+++ b/apps/desktop/src/main/im/shared/turnRunner.ts
@@ -2174,7 +2174,7 @@ export function createTurnRunner(
{
owner: pendingOwner,
...(req.kind === 'permission'
- ? { toolName: req.toolName, permissionCard: { title: spec.title ?? '', body: spec.body } }
+ ? { permissionRequest: req, permissionCard: { title: spec.title ?? '', body: spec.body } }
: askMultiExtras(req)),
},
);
@@ -3730,7 +3730,7 @@ export function createTurnRunner(
const permissionUi = adapter.ui.cards.permission;
return presentSharedPermissionCard({
requestId: req.requestId,
- toolName: req.toolName,
+ permissionRequest: req,
owner: pendingOwner,
permission: sharedPermission,
send: async () => {
@@ -3816,13 +3816,12 @@ export function createTurnRunner(
req.requestId,
req.kind as InteractionDecision['kind'],
messageId,
- // Stash toolName for permission requests so cardActionHandler can
- // build permissionUpdates when the user picks 'allow:always'.
+ // Preserve the permission scope for the 'allow:always' decision.
// permissionCard 留着收口时恢复原始正文(工具名 + 参数预览)。
{
owner: pendingOwner,
...(req.kind === 'permission'
- ? { toolName: req.toolName, permissionCard: { title: spec.title ?? '', body: spec.body } }
+ ? { permissionRequest: req, permissionCard: { title: spec.title ?? '', body: spec.body } }
: askMultiExtras(req)),
},
);
diff --git a/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts b/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts
index 5ddc7057bc..70e700c448 100644
--- a/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts
+++ b/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts
@@ -704,6 +704,34 @@ describe('shared provider credentials', () => {
await executor.close();
});
+ it.each(['normal', 'plan'] as const)('revokes temporary credential approvals when leaving %s mode', async (mode) => {
+ const confirm = vi.fn<() => Promise<ExecutorConfirmation>>()
+ .mockResolvedValueOnce('session').mockResolvedValue(false);
+ const { executor, gate } = sharedExecutor(mode, confirm);
+ const env = path.join(project, '.env');
+ fs.writeFileSync(env, 'TOKEN=1');
+ const read: ExecutorAction = { kind: 'read', path: env };
+ const write: ExecutorAction = { kind: 'write', path: env };
+ const command: ExecutorAction = { kind: 'exec', command: 'cat .env', cwd: project };
+ const unrelated: ExecutorAction = { kind: 'write', path: path.join(outside, 'plain.txt') };
+ try {
+ expect(text(await executor.callTool('Read', { file_path: env }))).toBe('1\tTOKEN=1');
+ expect(executor.check(write).ok).toBe(true);
+ // Session consent is already active when these approvals are recorded.
+ gate.recordApproval(command);
+ gate.recordApproval(unrelated);
+ executor.setGateMode(mode === 'normal' ? 'plan' : 'normal');
+ expect(executor.check(unrelated).ok).toBe(true);
+ for (const action of [read, write, command]) expect(executor.check(action).ok).toBe(false);
+ executor.setGateMode('full');
+ for (const action of [read, write, command]) expect(executor.check(action).ok).toBe(false);
+ expect((await executor.callTool('Read', { file_path: env })).isError).toBe(true);
+ expect(confirm).toHaveBeenCalledTimes(2);
+ } finally {
+ await executor.close();
+ }
+ });
+
it('does not grant credentials from a cancelled, closed or outdated confirmation', async () => {
for (const end of ['cancel', 'close', 'permission-change']) {
let answer!: (result: ExecutorConfirmation) => void;
diff --git a/apps/desktop/src/main/remote-agent/executor/gate.ts b/apps/desktop/src/main/remote-agent/executor/gate.ts
index 53f83ee723..2ebb32c4b2 100644
--- a/apps/desktop/src/main/remote-agent/executor/gate.ts
+++ b/apps/desktop/src/main/remote-agent/executor/gate.ts
@@ -53,6 +53,7 @@ interface Approval {
kind: 'path' | 'exec' | 'fetch';
key: string;
expiresAt: number;
+ credential: boolean;
}
export function executorGateModeFor(
@@ -111,6 +112,8 @@ export class ExecutorGate {
setMode(mode: ExecutorGateMode): void {
this.credentialsAllowedForSession = false;
+ // 同一路径的临时批准也必须撤销,否则它会在 TTL 内绕过恢复后的凭证确认。
+ this.approvals = this.approvals.filter((approval) => !approval.credential);
this.mode = mode;
}
@@ -126,7 +129,11 @@ export class ExecutorGate {
/** 本机用户在确认卡上允许了一个操作后调用。 */
recordApproval(action: ExecutorAction): void {
this.prune();
- this.approvals.push({ ...approvalOf(action), expiresAt: this.now() + EXECUTOR_APPROVAL_TTL_MS });
+ this.approvals.push({
+ ...approvalOf(action),
+ expiresAt: this.now() + EXECUTOR_APPROVAL_TTL_MS,
+ credential: this.isCredentialAction(action),
+ });
if (this.approvals.length > MAX_APPROVALS) this.approvals.splice(0, this.approvals.length - MAX_APPROVALS);
}
@@ -135,7 +142,11 @@ export class ExecutorGate {
* 真实目标再判一次)、目录级读取的根本身是凭证目录,或命令读取 / 打出凭证。
*/
needsCredentialConsent(action: ExecutorAction): boolean {
- if (!this.options.confirmCredentials || this.credentialsAllowedForSession) return false;
+ return !this.credentialsAllowedForSession && this.isCredentialAction(action);
+ }
+
+ private isCredentialAction(action: ExecutorAction): boolean {
+ if (!this.options.confirmCredentials) return false;
if (action.kind === 'fetch') return false;
if (action.kind === 'exec') {
return isShareCredentialCommand(action.command, this.workspace.allRoots(), { cwd: action.cwd, platform: process.platform });
diff --git a/docs/product-rules/telegram-bot-parity.md b/docs/product-rules/telegram-bot-parity.md
index 26332990bf..493bd001f8 100644
--- a/docs/product-rules/telegram-bot-parity.md
+++ b/docs/product-rules/telegram-bot-parity.md
@@ -66,7 +66,7 @@ App 完成未读与提醒统一由 `renderer/hooks/useSessionRunningStatus.ts`
| 能力 | 单一真相源 | 共享到什么程度 |
|---|---|---|
| 子代理输出隔离 | `im/shared/agentEventScope.ts` + `maker-core/agents/claude-code/translator.ts` | 官方 `hook-control/turnObserver` 与个人 `im/shared/turnRunner` 在消费实时事件前过滤带 `agentMeta.parentUuid` 的子代理事件。内部正文、工具/思考、媒体旁路和终态不进入主任务的 IM 回帖,也不影响主任务收口;个人侧自动任务转播同样适用。Claude translator 为子代理工具结果保留归属,主代理流式事件不继承子代理元数据;主任务正文统计和最后消息的实质内容判定只消费主代理,子代理完整消息与流式增量都不阻断主任务 result 截断补发,也不覆盖 silent-stop 判定。整轮失败即使由子代理 API 错误引起,仍按主任务失败收口。主代理主动引用的成果正常发送,桌面完整记录不变。 |
-| 普通工具权限的多处确认 | `maker-ipc/interactionRouter.ts` + `sharedPermission.ts` | IM 与 Cindy 共用一个决定,首次有效回答生效,桌面/手机与渠道同步收口。来源正文由 `im/shared/interactionSource.ts` 构造;个人富卡与官方 Hook 分别负责各自载体更新。未来渠道复用同一注册接口,详见 [共享合同](im-permission-confirmation.md)。 |
+| 普通工具权限的多处确认 | `maker-ipc/interactionRouter.ts` + `sharedPermission.ts` | IM 与 Cindy 共用一个决定,首次有效回答生效,桌面/手机与渠道同步收口。来源正文由 `im/shared/interactionSource.ts` 构造;个人富卡与官方 Hook 分别负责各自载体更新。供应商分享的本机凭证确认卡共用 `interactionCardModel.ts` 回传当前任务的凭证授权标记;个人卡片点击从 pending 保存的原请求恢复作用域,不转换成通用工具允许规则。未来渠道复用同一注册接口,详见 [共享合同](im-permission-confirmation.md)。 |
| 模型列表的开关就绪 | `maker-host/model-visibility-mirror.ts` | 个人 `/model` 与官方 `listAgentModels` 均等待当前账号配置同步;超时返回错误,不把未同步当成全部关闭或回退出厂开关。 |
| 过程区与正文的**文本合成** | `im/shared/turnPresenter.ts` + `turnActivity.ts` | 过程区怎么排(工具步骤、思考步骤、耗时行)、过程区与正文怎么拼(`composeProgressView`)。**正文累积不算**——见第三节:`createTurnPresenter` 按 `mode` 实例化两个独立引擎,累积、消息投影、`finalText()` 判据都不同,改一个引擎不影响另一个 |
| 运行中**过程消息**的生命周期、渲染与出站失败判据(官方需双方协商 `telegram-progress-ops-v1`) | `packages/lizi-im/src/telegram/streamingText.ts`(`startTelegramProgressCarrier` 与个人 `startTelegramStreaming` 是同一个 handle 类)+ `progressFrame.ts` + `outboundPolicy.ts` + `markdown.ts` 的 `markdownToTelegramHtml` | 惰性占位、1.5s 尾沿节流、首帧 send 后续 edit、单帧上限 `TELEGRAM_PROGRESS_FRAME_MAX_CHARS = 3800`(源 markdown 字符数;官方 presenter 的 `PresenterPolicy.intermediateMaxRenderedChars` 默认值也取它)、NO_REPLY 及其前缀不落地、HTML 被拒(400)回落纯文本、`message is not modified` 视为成功、429 按 `retry_after` 全长退避后重试一次——两侧跑同一份代码。**传输不同**:个人走 Bot API(`index.ts` 的 `callSend` / `sendRenderedChunk` / `editHtml`),官方走 msg.op(`hook-control/telegramTurnCarrier.ts` 只实现 `TelegramStreamingDeps` 的 msg.op 版,并经 `telegramMsgOp.ts` 把 `msg.op.result` 的 `channelErrorCode` / `error` / `retryAfterMs` 映射成同形错误);服务端只执行,不做转换与回落。未协商时官方仍由服务端渲染 `turn.progress`,本行对官方不成立 |