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。

Merge main and preserve group plan and auth recovery behavior

Chris242f6dc8a8d4
diff --cc apps/desktop/src/main/maker-ipc/chatServer.ts
index 78924ff2e0,5239918a7c..54ea9ba231
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@@ -68,10 -68,17 +69,16 @@@ interface Running
releaseToolAuthority?: () => void;
}
class ChatResponseError extends Error {
- constructor(code: string, readonly status: number) { super(code); }
+ constructor(code: string, readonly status: number, readonly retryAt?: number) { super(code); }
}
+ const CHAT_AUTH_RETRY_MS = 60_000;
+ const CHAT_REFRESHABLE_ERROR_CODES = new Set(['TOKEN_EXPIRED', 'INVALID_TOKEN', 'AUTH_REQUIRED']);
+ const recoverableAuth = (error: ChatResponseError) => error.status === 401
+ && (CHAT_REFRESHABLE_ERROR_CODES.has(error.message) || error.message === 'INVALID_CHAT_RESPONSE');
+ const retryableResponse = (error: ChatResponseError) => recoverableAuth(error)
+ || error.status >= 500 || [408, 429].includes(error.status);
const id = z.string().uuid();
const groupInput = z.object({ name: z.string().trim().min(1).max(40), botIds: z.array(z.string().min(1)).max(6) });
-const failure = (message: string): BotGroupFailure => ({ ok: false, errorCode: 'HOST_NOT_READY', message });
const bodyText = (m: Message) => m.deleted ? '(消息已删除)' : m.content.filter(b => b.namespace !== 'cindy.local-history' || b.data?.activity === true).map(b => b.text ?? b.fallback ?? (b.type === 'media' ? `[附件: ${b.caption ?? '文件'}]` : '')).join('\n');
// Presentation only: keep actor IDs and stored names independent of ownership labels.
const memberName = (m: Member) => m.kind === 'bot' && m.ownerName.trim() ? `${m.name} (${m.ownerName.trim()})` : m.name;
diff --cc apps/desktop/src/renderer/__tests__/newMakerOrcaCreateOrder.test.ts
index 0020ad6fc8,582253c021..d303d0621d
--- a/apps/desktop/src/renderer/__tests__/newMakerOrcaCreateOrder.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerOrcaCreateOrder.test.ts
@@@ -218,10 -218,14 +218,13 @@@ describe('NewMakerDraftRoute Orca worke
expect(body.indexOf('void refreshRemoteDeviceSessions(')).toBeGreaterThan(finallyAt);
});
- it('narrows the device-link worker source against the controlled device catalog', () => {
- // 草稿里持久化的来源/模型按**目标设备**的目录收窄:device-link 分支必须用
- // agentCatalogProviders(由 deviceProviders 派生,Agent 在另一台电脑运行时再收窄到
- // 那台开放远程调用的来源),拿控制端的 localProviders 收窄等于用错机器的目录。
+ it('narrows the device-link worker source against the agent device catalog', () => {
+ // 未选择远程 Agent 时用被控电脑目录;选择后用运行 Agent 的电脑开放远程调用的目录。
+ // 两条 device-link 路径必须用 agentCatalogProviders,不能改用控制端 localProviders。
const collapsed = source.replace(/\s+/g, ' ');
+ expect(source).toMatch(
+ /const agentCatalogProviders = useMemo\(\s*\(\) => \(effectiveAgentDeviceId \? remoteAgentProviders\(deviceProviders\) : deviceProviders\)/,
+ );
expect(
collapsed.match(
/draftEnableOrcaOptions\( effectiveCollab, agentCatalogProviders, !deviceProvidersLoading, true, \)/g,
diff --cc apps/mobile/src/session/BotGroupChatScreen.tsx
index c3f8aaf6dc,e1820a25eb..6c05b4a971
--- a/apps/mobile/src/session/BotGroupChatScreen.tsx
+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx
@@@ -445,7 -461,7 +461,7 @@@ function BotGroupTimelineItem(
const variant = botGroupNoticeVariant(message.noticeCode, message.planId !== null);
return <Text style={styles.notice} testID="botGroup.notice">{variant ? t(`groupChat.notice.${variant}`, { name }) : message.content}</Text>;
}
- if (message.kind === 'message' && message.authorKind === 'user') {
- if (message.authorKind === 'user' && message.isSelf !== false) {
++ if (message.kind === 'message' && message.authorKind === 'user' && message.isSelf !== false) {
// Older computers send no attachments; a message with only attachments has no bubble.
const attachments = message.attachments ?? [];
const bubble = message.content.trim().length > 0 || attachments.length === 0;
diff --cc docs/dev-rules/protocol-compatibility.md
index 6a4de448d0,6e73f75361..afb324de26
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@@ -1012,30 -1018,18 +1018,46 @@@ Mobile 据此区分已关闭与已删�
不增加分页、客户端重组或重试,不提高传输大小上限;本机 Desktop 设置仍读取完整目录。
“关闭后必须重选”的提示与发送前检查随 Mobile 更新;旧版控制端仍沿用各自既有选择处理。
+### 伙伴群聊成员操作与发送错误(#5604–#5606)
+
+`bot-group-chat` 数据追加可选 `supportsMemberRemoval`;仅为 true 时手机调用
+`remove-member({ actorId })`,主机复用现有 Chat Server 单成员 remove 与管理权限校验。
+成员投影中的 actorId/actorKind 在手机保留,真人不作为分工负责人/步骤候选;缺字段的
+旧本地伙伴保持原行为。旧手机继续用 `set-members`,新主机只校验其中新增的本机伙伴,
+不丢弃既有真人/外来伙伴 ID。新版手机连旧主机时不调用新动作,伙伴管理沿用旧入口;
+真人移出需升级主机,不能用整份伙伴名单差分假报成功。
+
+群错误仍以稳定码作为 Remote Resource 错误 message,新增附件、鉴权、群服务不可达、
+历史迁移、权限、归档及结果未确认等分类;新版双端本地化,旧端遇到未知码保留原通用失败提示。
+不透传服务器正文或异常文本。仅群 send 的 invoke 预算增加到 180 秒,不改变其他动作、
+共享连接、自动重试或授权。超时不能证明操作未执行,重试沿用 clientId;当前账号主机进程
+合并相同在途请求并缓存最近成功回执,服务器 operationId 仍是最终幂等依据。
+不新增 IPC channel、数据库迁移或 Mobile 原生指纹输入。
+
+### 服务器伙伴群讨论与分工补全
+
+Chat Server `/me` 追加 `capabilities.groupDiscussionParity: 1`。Desktop 只在该能力存在时发送
+可选 `mentionsAll`、`planningMode`,辅助判断后用 `continue({automatic:true})`,停止判断用
+`messages/:id/cancel-planning`。旧服务器继续收到旧形状;能力协商并不恢复旧服务端缺失的行为。
+整个服务端集群升级后再发布客户端,不能在新旧副本混用时提前承诺该能力。
+
+领取执行追加可选 `attachment_after_seq`,按伙伴/群/授权版本/分工步骤隔离成功投递水位。
+缺字段时沿用旧读取范围;新客户端以此翻页收集未见附件,保留每轮 40 个上限及缺失名称提示。
+`cindy.group-notice` v1 的 integration 卡映射到已有 plan-failed/member-failed/member-timeout
+展示提示,仅承担文案,不授予执行权限。Mobile 继续消费主机既有群资源投影,无新增原生能力。
++
+ ## 委派任务的完成通知归属
+
+ 既有 `SessionActivityPayload` 可选字段 `completionNotification` 影响远端桌面、手机与飞书完成通知:
+ `pending` 表示该轮终态回传正在判定,`teammate` 表示同一委派执行结果已成功交回伙伴;
+ 缺省或未知值按普通任务完成通知处理。完成 phase、摘要和 attention 在 pending 阶段照常发送,
+ 回传决定通过同一活动通道更新;执行宿主等到真实 `done` 的回传边界再决定,前置
+ `status: Done` 不能提前消费归属。本机外部通知共用这一决定;控制端的手机/飞书调用
+ 在活动仍运行或 `pending` 时等待同一活动通道更新,已回传伙伴则取消调用。已读、断开、
+ 新一轮运行、报错或待交互使旧完成调用失效,不延迟错误与待答通知,也不更改任何未读。
+ 控制端桌面仅对已观察运行的任务补发必要 fallback 一次,重连的
+ 基线终态不补发历史提醒。错误与待交互不受此字段影响。
+
+ 新控制端连接旧执行端沿用原通知;旧控制端忽略该字段,仍可能发独立完成外部通知,完整远端
+ 去重需要两端更新。手机外部推送在执行端及远控 Desktop 的通知出口完成去重,手机无需新增协议处理;
+ 移动列表继续原 phase/attention 语义。无需服务端、数据库 migration 或 Mobile fingerprint 改动。