Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge remote-tracking branch 'origin/main' into dash/plugin-card-compose-form
Dash93a204a8ac49
diff --cc apps/desktop/src/main/cindy-brain/forge.tsindex b7b89bafd1,84b0fc8da1..3c72dcc364--- a/apps/desktop/src/main/cindy-brain/forge.ts+++ b/apps/desktop/src/main/cindy-brain/forge.ts@@@ -1851,22 -1851,6 +1851,22 @@@ v3 直接用顶层字段声明插件贡\`agent\`、\`panel\`、\`mainView\`、\`card\`、\`subscribe\`、\`network\`、\`node\`、\`preview\`、\`skill\`;布尔能力写成字面量 \`true\`:\`notify\`、\`badge\`、\`confirm\`、\`fs\`、\`library\`、\`sessionContext\`、\`pick\`、\`workspace\`。不用的字段直接省略,+邮件插件声明 \`mail: true\`,调用 Cindy 内置 \`cindyMail.register(adapter)\`+(version 1),不生成卡片 HTML、不打包公共流程;纯邮件插件不需要 \`card\`。+阅读邮件可声明 \`mailReader:{tool,hosts}\`,工具接收 \`{url}\` 并返回 MailMessage,默认只读。+支持打开即已读时增加 \`mailReader.markRead:true\`,读取工具接受可选 \`markRead:true\`;+仅用户主动打开时传入,AI 读取和邻近预加载不传。成功读取后只标记当前邮件,不标记整个会话或草稿。+标记失败仍返回正文和 \`markReadFailed:true\`,由 Cindy 显示提示;新增 OAuth scope 不阻断已有授权的操作。+适配器提供 providerName、draftStorage(server/local)、selectAccount、readDraft、writeDraft。+通过 present 展示读回草稿,beforeTool 统一 get/send/update/delete,resolveDraft 获取最新位置。- Host 负责样式、编辑同步、发送、任务续接与旧卡只读收起;插件保留凭据、MIME 和服务商请求。++Host 负责样式、编辑同步、发送和任务续接;同一任务同一封邮件只显示最新卡片,旧快照保留但不重复展示。插件保留凭据、MIME 和服务商请求。+插件重启后,下一次卡片编辑或工具操作会自动读回原草稿,使用 Host 卡片中上次同步的内容、卡片编辑和邮箱最新内容做三方合并;单边变化、相同变化和不重叠的文字修改自动合并,只有无法合并的修改才保留两边内容并提示具体字段。版本标记或预览地址变化本身不算冲突。适配器返回 execution:not_executed 和 stale 读回快照时可合并后重试一次,未知操作结果不能重试。发送倒计时结束时若发现实际内容变化,展示合并稿并重新倒计时。+图文适配器的 attachmentItems 可为已有图片 key 添加 contentId,表示将同一附件插入 HTML 正文;必须核验实际图片字节、保留 MIME 引用,不能重复上传或把预览 URL 写入邮件。+工具说明应要求默认展示草稿卡等用户确认;只有用户已明确确认该邮件,或有效的用户/任务指令明确授权该范围内直接发送,才不再询问。写信/回复请求、编辑及自动审批本身不代表确认。+UI 和 Agent 发送都先进入 10 秒倒计时,卡片可撤销或立即发送;beforeTool(send) 等待最终回执。+撤销后保留草稿且不得自动重试。所有发送先创建并展示草稿,再走 beforeTool(send),不得保留直发旁路。+缺少 SDK 时只读可用,编辑/发送需更新 Cindy;不要绕开公共流程直接发送已展示草稿。+不能写 \`false\`。\`card: {}\` 与 \`agent: {}\` 分别表示基础聊天卡片能力和用户点击后发起 Agent 回合;其它对象型能力必须包含该能力真正需要的详单。diff --cc apps/desktop/src/renderer/components/chat/MessageStream.tsxindex 5ee255a1ae,843ff08827..d52bf155a0--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx@@@ -3102,8 -3193,17 +3212,17 @@@ export function MessageStream(// MessageStream scope so history pagination and live deltas can share the// parsed image targets without retaining state beyond the session mount.const markdownImageTargetCacheRef = useRef<MarkdownImageTargetCache>(new Map());- const { items: ungroupedRenderItems, singleResultMap } = useMemo(() => {- const built = streamProjection(+ const { items: ungroupedRenderItems, singleResultMap } = useMemo(() => buildMessageStreamRenderProjection({+ historyView, historySnapshot, historyLiveMessages, isSessionStreaming, handoff,+ taskUpdates, ghostCardSnapshot,+ generatedFilesItemCache: generatedFilesItemCacheRef.current,+ renderOptions: {- turnChangeSets, workingDir,++ sessionId, turnChangeSets, workingDir,+ botSessionId: simplifiedBotConversation ? sessionId : undefined,+ markdownImageTargetCache: markdownImageTargetCacheRef.current,+ cindyMakeSessionId, cindyMakeCompletionInComposer, subagentRunStatuses,+ },+ buildRaw: () => streamProjection(displayMessages,[getDataOwnerGeneration(),diff --cc apps/desktop/src/renderer/lib/makerChatStore.tsindex 935be5ff8d,d2e039dd83..ccb6aca8bd--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@@ -1,4 -1,4 +1,5 @@@+import { pendingGhostCardFormDelivery } from '@cindy/maker-shared/ghost-card-form';+ import { remoteAgentLimitErrorKey } from '../../shared/remoteAgentLimits';import { readBotTaskResults } from '@cindy/maker-shared/botCollaboration';import { asyncQuestionNeedsSupplement, formatAsyncQuestionSupplement } from '@cindy/maker-shared/interaction';import { isComposerTypingRecently } from './composerTypingActivity';diff --cc apps/mobile/src/session/HtmlFileReader.tsxindex a0d9f79f03,0903cbf8d9..465ab30967--- a/apps/mobile/src/session/HtmlFileReader.tsx+++ b/apps/mobile/src/session/HtmlFileReader.tsx@@@ -124,10 -127,10 +127,10 @@@ export function HtmlSnapshotReader({ pr// Themed backing for the strips under the floating controls; the viewport script paints// the page canvas itself, so this never becomes the background of an unstyled page.style={[styles.fill, { backgroundColor: colors.surfaceElevated }, paintedPreview !== preview && styles.unpainted]}- />{paintedPreview !== preview && loading ? <View style={StyleSheet.absoluteFill} pointerEvents="none">{loading}</View> : null}</View></View>;+ /> : null}{(!preview || paintedPreview !== preview) && loading ? <View key="loading" style={StyleSheet.absoluteFill} pointerEvents="none">{loading}</View> : null}</View></View>;}-export function HtmlFileReader({ html, testID }: { html: string; testID?: string }) {+export function HtmlFileReader({ html, testID, javaScriptEnabled = true }: { html: string; testID?: string; javaScriptEnabled?: boolean }) {// CSP 注入放在**渲染载体这一层**,而不是取件那一层:任何进到这个 WebView 的// HTML 都必须带策略,不管它有没有同目录资源(见 htmlPreviewCsp 的说明)。const guardedHtml = useMemo(() => withHtmlPreviewCsp(html), [html]);diff --cc docs/dev-rules/protocol-compatibility.mdindex aa14fbf8e4,8aa3878174..07b2b88d93--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@@ -2208,167 -2259,10 +2306,175 @@@ PC 同源 ghostPermissionItems 声明�伙伴资料快照 `companion.profile.v1` 新增可选的 `templateId`;新增偏好键 `companion.todo.v1:<id>`、`companion.routine.v1:<id>`、`companion.workbench.v1`,旧客户端不认识这些键,接管时忽略。镜像上传的房间消息可带 `media` 块;旧客户端按文件名显示。手机端同样不改原生指纹。+## Host-owned mail cards++Manifest v3 adds optional `mail: true`. Cindy serves the versioned `cindyMail` SDK+inside the provider sandbox before its entry point. Providers register mailbox+adapters; they do not need `card` or generate HTML. The local pipe accepts validated+`mail-draft-update` only from enabled mail providers with a live task-owned call.+Cindy renders and persists the existing `ghost_cards` row; no database migration+or relay version change. Old hosts lack the SDK: providers retain read-only tools+and require a Cindy update before draft editing/sending, without a direct-send fallback.++The host-only `data-cindy-mail` marker records account/draft identity, state and+`supersededBy`. Ordinary plugin HTML cannot retain it. Autosave replaces one view;+subsequent tool reads supersede matching provider/account/draft views in that task.+Obsolete or legacy mail actions are rejected on the Host. Historical snapshots remain stored.+The `plugin-card-actions` resource carries optional `mail` / `legacyMail` metadata;+desktop and mobile clients hide superseded mail cards and their plugin labels, leaving+only the latest card per provider/account/draft in that task, including sent/deleted+states. Legacy cards without this metadata retain their read-only fallback.+Old clients keep static fallback text+and receive no obsolete actions. Existing form capability negotiation and task/owner+checks still apply. Sent cards expose only optional task continuation, never send.+Mail receipt continuations use the existing `[UI_ACTION_TRIGGER]` prefix: the+Agent receives the complete receipt, while both clients hide the internal prompt+from chat and session previews. The original mail card remains the visible result.++Optional adapter `deleteDraft` adds a `deleteLabel` and `mail:delete:<key>` action+to active drafts only. It requires no form values because pending edits are+discarded. Deletion shares the per-draft save/send lock and cancels queued saves+and send countdowns. It discards the logical draft even if its content/revision+has changed, verifies the draft identity and refreshes the provider locator;+save/send conflict checks do not apply to explicit discard. Progress is shown+before provider read-back. Failed preparation remains retryable; a deletion+with an unknown provider outcome is never replayed.+Both clients treat `deleting` and terminal `deleted` as+read-only; the Host rejects late edits/sends and cannot restore a deleted card.+Unknown deletes stay locked until the mailbox is checked. Older adapters omit+the button; older clients fall back to inert text for the new states. Existing+remote action ownership/revision checks and the same card row carry this change.++Oversized tool results retain validated top-level `xdt_card_id` and+`xdt_anchor_card_id` in bounded valid JSON during persistence/import and remote+history compaction. The card content remains in the existing card store; no new+wire fields or schema are required. Uncorrelated live cards may only match calls+in the latest visible user turn, so incomplete older history cannot steal them.++Rich mail adapters opt in with `richText: true`; old adapters keep the existing+plain-text contract. Host fields add `mail-html`, `mail-attachments` and `hidden`+kinds, with `bodyHtml` / `quoteHtml` (64k characters) and `attachmentItems` (bounded+JSON metadata). Ordinary text remains 16k. Only Host mail gets the 1 MiB card+budget; arbitrary plugin HTML remains limited to 32 KiB. HTML previews are inert,+sandboxed documents, not markup mounted in Cindy's privileged renderer DOM.+HTML supports typing directly into rendered text in both clients and the enlarged+view, without an edit-mode button, formatting toolbar or source editor. Edits patch source text+only, preserving styles, links and CID image references, and synchronize the+plain-text alternative through the existing form autosave path. Sent/history+cards stay read-only. `editor.format: 'text'` retains+the existing compact plain-text input.++The Host mail SDK owns outgoing formatting for all rich adapters. Before preview,+autosave and send it extracts document wrappers into fragments, retains body+attributes on a content container, derives absent text alternatives, supplies+missing filename extensions from known MIME types, and reconnects managed preview+URLs to their attachment CIDs. Missing/duplicate inline references stop sending.+Normalized content is saved and read back before the existing countdown; adapter+read-back must retain the normalized structure. Adapters honor supplied filenames,+preserve MIME bytes/reply headers and verify the provider result. No new wire fields+or SDK version are required; plain-text-only adapters retain their existing path.+This is structural protection, not a guarantee of identical CSS rendering across+email clients. Ordinary fragments and explicitly authored plain text are retained.++Desktop attachment actions `mail:attach` / `mail:image` are native Host gestures,+not plugin HTML controls. The dispatcher verifies current view, owner, mail+capability and draft state before and after the native picker, and passes one+transient hash/size-bound file descriptor to the provider event. No arbitrary+path comes from form text. Pending or sent mail cannot open the picker. Mobile+resource metadata adds optional `mailUpload`; old hosts omit it and new phones+hide the upload button. Supporting hosts accept `mail:attach:<key>` with optional+`input.mailAttachment: {url,name}` and the complete form. Only existing OSS/peer+upload references with size and SHA-256 are accepted (16 MiB/file), never local+paths. The existing task materializer owns downloads and session cleanup; owner,+interaction lease and current draft state are checked before delivery. No new+relay channel, native dependency, database or runtime fingerprint is introduced.+Ordinary attachment removal retains the existing remote form delivery gate.+Optional `mail.images` contains validated managed preview URLs keyed by CID;+these URLs never replace CID references in the saved/sent message. The existing+media-deposit ledger owns these image bytes; no new file store or database exists.+Mobile resolves CID previews with the existing remote-media queue into data URLs+inside a sanitized mail WebView whose CSP blocks all page scripts. Host-injected+editing listeners send only a document revision, known text-run index and plain+text; the native side validates those before applying source patches. Desktop+uses parent-owned listeners in an iframe without script permission. Autosave+echoes do not reload either editing surface. CID substitutions never enter form+edits; missing images leave the rest of the email readable.+Attachment items optionally carry `mimeType` and `previewUrl` (validated managed+image URLs only). Both clients show file identity and size; image clicks use+their existing viewers. Removing a CID image removes its part and image nodes,+preserving the rest of the authored document. "Insert into message" assigns an+available `[email protected]` CID to an existing image key and inserts an HTML+image before the closing body tag. Adapters validate the actual bytes and write+that existing part as inline without uploading a duplicate. Compare part keys+and normalized Content-IDs, ignoring preview-only metadata when detecting edits.+After sandbox restart, the next card edit/send (including model send) restores+volatile state using the persisted account/draft/locator. It retains incoming+form edits and the same card key. Optional `baseValues` in the existing host card+retains the last synchronized values (not in plugin KV). The SDK's internal+`mail-draft-read` uses the same plugin/call/session ownership as publication.+It compares base, card edits and provider values: identical/one-sided changes and+independent text ranges merge automatically, ignoring preview-only metadata.+Unmergeable overlapping edits retain both versions and name the conflicting fields.+Legacy clean cards supply their own base; legacy errors without a base converge+only when contents agree. Pending/unknown/sent records never become drafts.+Adapters may return `execution:not_executed` with `stale` read-back; the SDK can+merge and retry once. Unknown writes never retry. Changed content discovered at+send time is shown before a fresh countdown; metadata-only drift needs no prompt.+Old clients ignore optional baseline values; existing remote form actions carry+no new required fields. The host SDK, not mailbox plugins, owns recovery/merging.+Recovery never resumes a previous countdown; a new send gets the full grace period.+Reading an unchanged draft in the same task reuses its existing card without+publishing another snapshot. The host verifies task ownership through+`mail-draft-read`; a different task still receives its own card. Fresh provider+fingerprints/locators are adopted even if visible content is unchanged. Desktop+mail cards require an exact tool ID or settled result to anchor them; the generic+same-plugin in-flight heuristic must not show old mail beneath a schema/read call.+Desktop HTML previews retain head styles, class selectors and body presentation+inside their inert sandbox. External CSS resources, scripts and navigation remain+blocked; preview sanitization never mutates the saved HTML.++### Read-only mail preview++Mail providers may declare `mailReader: { tool, hosts }` alongside `mail: true`.+The tool must be declared and read-only by default. Cindy matches exact HTTPS hosts+and calls it with `{ url }`; the provider resolves the account and message without+marking read or mutating drafts. Providers may opt in with `mailReader.markRead: true`+and accept optional `markRead:true` on that same tool. Only an explicit user opening+passes it; AI reads, probes and neighboring preloads remain read-only. Mark only the+successfully resolved selected message, never the whole thread or drafts. A failed+mark must retain the body and return `markReadFailed:true` for a non-blocking notice.+It returns `MailMessage` (maker-shared/mail-message).+Credentials and MIME parsing remain with the provider. Cindy validates the data+and reuses its inert HTML/CID/recipient renderers, never compose actions. Multiple+matching providers/accounts cannot silently select the first. Unknown providers or+older hosts keep normal browser opening. Attachments use managed image previews;+other file types retain their metadata and the mailbox opening fallback.++Desktop uses a session-scoped sidebar tab. Mobile/same-account remote clients use+the existing `mail-messages/message` remote resource, ID `[sessionId,url,read]`,+primitive `mail-message`.+Explicit opening adds optional `query:"open"` to resource get, or optional fourth+`opened:true` to `ghosts:mail-preview`; resource IDs and default read behavior stay+unchanged. Old hosts ignore the new optional values; old providers still receive+only `{url}`. No new channel, storage or native changes. Plugins adding an OAuth+scope must keep existing granted operations usable; missing new scopes may fail+marking read, not prevent viewing or composing.+Existing 256-character resource ID bounds still apply; overlong remote links fall back to browser opening. Shared-task access does not+grant mailbox access. Scope checks run before and after reads; clients bind display+to account/device/session/URL and ignore stale responses. No mail content is stored+in sidebar state or added to the chat by opening a link.++Desktop native mail cards also open this tab through `open-mail-card` with+`sessionId` and `callId`. The tab stores only the card ID and uses the existing+card editor/actions; session-scoped lookup and supersession select the current+view. This is a local desktop trial, not a new plugin or device-link capability.+Older URL-based reader tabs remain valid. Draft edits, deletion and delayed send+still use the same host-owned mail workflow as the chat card.+++ ## 伙伴导入的消息机器人分类++ `companion-import` Remote Resource 的 client primitives 可追加 `companion-import-bots-v1`。只有声明它的控制端+ (以及本机界面与 `import_agent`)的预览才会收到 `category: 'bots'` 条目及其可选 `platform` / `owner` 字段,导入时+ 会先在来源 Agent 里停用这些机器人再由伙伴连接;旧控制端的预览校验不认识新分类,所以照旧把 Telegram / Discord+ 放在 `connections`、不停来源,也不出现飞书 / 企业微信 / 钉钉条目。分类随预览快照与加密检查点保存,开始导入和恢复+ 都按当时的分类执行。不改 relay 帧、服务端 schema 或 Mobile 原生指纹。