diff --git a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.i18n.yaml b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.i18n.yaml index 9decc56ab5..b30bceb7f4 100644 --- a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.i18n.yaml +++ b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.md -2026-11-23-chat-files-live-in-the-aeven-folder.md: 18dba0ae335888409022eab367d53ecb8dd60d79 -2026-11-23-chat-files-live-in-the-aeven-folder.zh.md: 06d7263ea1e871a81a1ffe8282c3e8347bd810a8 +2026-11-23-chat-files-live-in-the-aeven-folder.md: c66c1b743eaae83fe7ab6fe5a1421303cf3e6759 +2026-11-23-chat-files-live-in-the-aeven-folder.zh.md: bceeca1f9b1b9e5cb5a3a8408e63c1c9fa8ad7a0 diff --git a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.md b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.md index 18dba0ae33..c66c1b743e 100644 --- a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.md +++ b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.md @@ -15,7 +15,7 @@ A chat without a folder of its own works inside the account's Aeven folder on ev - **Hosted.** With `AVN_HOSTED_SANDBOX=1`, `aeven-folder-sync` uses `sandbox/accounts` with `perAccount`, so each account's managed folder, the only folder its jailed commands see and the one its disk quota covers, is its Aeven folder. The files cloud sessions make reach the account's desktops and the file cloud. `advertise` stays false: a jailed command sees only its session's subfolder, not the folder's root. A cloud session filed in a folder workspace works in `.aeven-projects//`, which file sync ignores: that workspace's files already travel through its workspace folder or Git, and syncing the cloud's copy as well sent the same project twice, without its `.git`. - **Desktop.** `working-directory` asks the new `working-directory/account-folder` bail event for a session that records no directory, or sits in a workspace without a folder, and `aeven-folder-sync` answers with the account's Aeven folder when this device's folder belongs to that account. The session then works in `~/Documents/Aeven/chats`, and a conversation another device ran resolves its relative paths in the copy file sync brought here. Without an answer, such as a second account of a device whose folder another account claimed, the session records no directory and keeps the sandbox policy's `~/.aeven/chats`. The claim of an unowned folder is synchronous so that resolution stays synchronous. - **Ignores.** The default file sync ignores add `.npm` and `.local`, which a jailed command's home caches inside its workspace, and `.aeven-projects`. -- **Reading produced images.** The turn tail shows a produced image whole, from its stored copy where one was recorded, the way generated images show: a lone image at its own proportions, several as tiles. The `produced-images` Turn data index names those images, so a closed Turn's reply that embeds one, by its path or by the copy `reply-images/stored` recorded, leaves it to the tail. +- **Reading produced images.** The turn tail draws a produced image through the conversation's image renderer, in the frames generated images take, from the full reference of the copy a tool result of the Turn shared. `GET /api/attachment-file` serves a copy the log cites as an image or names only in produced files, not just one cited as a file: the first realization loaded every produced image from that route, which refused image copies with `ATTACHMENT_NOT_REFERENCED`, so each tile fell back to a row; it shipped without a live check on chat.aeven.io. A closed Turn's reply that embeds a produced image through the copy `reply-images/stored` recorded leaves it to the tail only when the tail can draw that copy. A file the closing message mentions opens like its row, the Files sidebar with its stored copy first. - **Opening a missing file.** `session/openWorkspacePath` classifies an opener failure at a path where nothing exists as `session/path-missing`, and reports any other failure with the opener's stderr instead of the `Command failed:` line. The chat view's file opener no longer prefixes the Host message. A produced file with a stored copy downloads the copy where the path is missing; otherwise the dialog names the file and the folder and offers that folder instead of a Retry that cannot succeed ([file-open failure dialog](../bug-fix/2026-08-18-tool-row-file-open-failure.md)). A prose link naming only the tail of exactly one produced path opens that path. ## Alternatives considered diff --git a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.zh.md b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.zh.md index 06d7263ea1..bceeca1f9b 100644 --- a/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.zh.md +++ b/.agents/notes/implemented/architecture/2026-11-23-chat-files-live-in-the-aeven-folder.zh.md @@ -15,7 +15,7 @@ Status: implemented - **托管。** 设置 `AVN_HOSTED_SANDBOX=1` 时,`aeven-folder-sync` 以 `perAccount` 使用 `sandbox/accounts`,因此每个账户的托管文件夹(其受限命令唯一能看到、也由其磁盘配额覆盖的文件夹)就是它的 Aeven 文件夹。云端会话制作的文件会到达账户的桌面设备和文件云。`advertise` 仍为 false:受限命令只能看到其会话的子文件夹,看不到该文件夹的根目录。归入文件夹工作区的云端会话在 `.aeven-projects//` 中工作,文件同步忽略它:该工作区的文件已经经由其工作区文件夹或 Git 传输,再同步云端副本会把同一个项目发送两次,而且不带 `.git`。 - **桌面。** 对于未记录目录、或位于没有文件夹的工作区中的会话,`working-directory` 通过新的 `working-directory/account-folder` bail 事件询问,当本设备的文件夹属于该账户时,`aeven-folder-sync` 回答账户的 Aeven 文件夹。会话随即在 `~/Documents/Aeven/chats` 中工作,另一台设备运行的对话也在文件同步带到本机的副本中解析其相对路径。没有回答时(例如设备的文件夹已被另一个账户认领时的第二个账户),会话不记录目录,继续使用沙箱策略的 `~/.aeven/chats`。认领无主文件夹是同步的,因此目录解析仍保持同步。 - **忽略规则。** 默认的文件同步忽略规则新增 `.npm` 与 `.local`(受限命令的主目录会在其工作区内缓存它们),以及 `.aeven-projects`。 -- **查看产出图片。** 轮次尾部以完整图片显示产出的图片,有记录的存储副本时来自该副本,方式与生成图片相同:单张保持自身比例,多张平铺。`produced-images` 轮次数据索引列出这些图片,因此已关闭轮次的回复若按路径或按 `reply-images/stored` 记录的副本嵌入其中某张,会把它留给尾部。 +- **查看产出图片。** 轮次尾部通过对话的图片渲染器、在生成图片所用的框中绘制产出图片,来源是该轮次某个工具结果共享的副本的完整引用。`GET /api/attachment-file` 提供日志以图片引用或仅在产出文件中命名的副本,而不只是以文件引用的副本:最初的实现从该路由加载每张产出图片,而该路由以 `ATTACHMENT_NOT_REFERENCED` 拒绝图片副本,因此每个图块都退回为一行;它在发布前没有在 chat.aeven.io 上实际检查。已关闭轮次的回复通过 `reply-images/stored` 记录的副本嵌入产出图片时,只有在尾部能绘制该副本时才把它留给尾部。收尾消息提到的文件像其行一样打开,先在 Files 侧栏中打开其存储副本。 - **打开缺失的文件。** `session/openWorkspacePath` 把在不存在任何东西的路径上发生的打开器失败归类为 `session/path-missing`,其他失败则报告打开器的 stderr,而不是 `Command failed:` 那一行。聊天视图的文件打开器不再给 Host 消息加前缀。有存储副本的产出文件在路径缺失时下载该副本;否则对话框写出文件和文件夹,并提供打开该文件夹,而不是一个不可能成功的重试([文件打开失败对话框](../bug-fix/2026-08-18-tool-row-file-open-failure.zh.md))。只写出恰好一个产出路径末尾的正文链接会打开该路径。 ## 考虑过的替代方案 diff --git a/packages/api/session-controller/README.i18n.yaml b/packages/api/session-controller/README.i18n.yaml index 2ffaa7188c..b274eb4ce3 100644 --- a/packages/api/session-controller/README.i18n.yaml +++ b/packages/api/session-controller/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/api/session-controller/README.md -README.md: 157ff3e4b28278b2bbd5b8e7baab803995d74314 -README.zh.md: 395644e15e05c840b43f6665fad8ecc1a824d644 +README.md: 8294b6fff4e9ec1f5fa94ea4af2e21c01f457351 +README.zh.md: c8c2d14d4d4e02316d0580c0e58af8edd9537ce6 diff --git a/packages/api/session-controller/README.md b/packages/api/session-controller/README.md index 157ff3e4b2..8294b6fff4 100644 --- a/packages/api/session-controller/README.md +++ b/packages/api/session-controller/README.md @@ -33,7 +33,7 @@ Content search on a Host that limits sessions to their owner asks the search pro The authenticated `/api/file` route serves absolute paths through the composed filesystem provider. Each file response carries the file's version as its `ETag` with `Cache-Control: private, no-cache`, so a browser re-displaying an unchanged image gets an empty 304 after one `stat`, and every load still passes authentication. For extensionless raster files, including durable attachment objects, it identifies PNG, JPEG, WebP, and GIF bytes so a Markdown image can reference the stored path directly. `pathReads: false` leaves the route unregistered, for a Host serving several accounts whose readers must reach files only through a Session of their own. `/api/attachment-file` serves a stored original only when the Session log cites it: as a file content block, or as a non-image file reference a tool result records in its metadata, such as the film `show_motion` stores. -`openWorkspacePath` refuses with `session/open-unavailable` while `canOpenWorkspacePath()` reports false, so a Host without a desktop never runs a native opener for a caller. When the native opener fails and nothing exists at the path, it refuses with `session/path-missing` and the path, such as a file another device of the account wrote; any other failure is `gateway/internal` with the opener's stderr, not the `Command failed:` line that names its argv. +`GET /api/attachment-file` serves a stored copy the Session log cites as a file, as an image (a produced image's copy, which a tool result shares as an image), or only by id in a tool result's produced files, whose name and media type then come from the produced path. `openWorkspacePath` refuses with `session/open-unavailable` while `canOpenWorkspacePath()` reports false, so a Host without a desktop never runs a native opener for a caller. When the native opener fails and nothing exists at the path, it refuses with `session/path-missing` and the path, such as a file another device of the account wrote; any other failure is `gateway/internal` with the opener's stderr, not the `Command failed:` line that names its argv. The Client adapter exposes `SessionEventStream`, a Gateway `RemoteJournalStream` bound to one ordinary or direct-subagent address. It opens follow before the initial page, publishes only contiguous `replace`, `prepend`, and `append` changes, and repairs reconnect or sequence gaps through a tail page. Backwards paging has two verbs: `loadOlder()` pulls one 50-message page, and `loadThrough(seq)` — the turn-jump loader — installs one 200-message window anchored on the target seq in a single round trip however far back that is, lowering a shared target when a repeated call joins the pass in flight, stopping once the installed window already covers that target, and reporting busy through the same `loadingOlder` snapshot bit. Ordinary records cover `[event.seq, event.seq]`; packed rows cover `[event.seq, event.seq + memberCount - 1]`. A business, persistence, or unresolved continuity failure terminates the stream, while only physical carrier loss selects automatic resumption. `SessionControlStream` is a Gateway `RemoteSnapshotStream`; every generation opens with a complete process-local baseline, so reconnect replaces queue, jobs, and projection state instead of treating transient values as durable events. diff --git a/packages/api/session-controller/README.zh.md b/packages/api/session-controller/README.zh.md index 395644e15e..c8c2d14d4d 100644 --- a/packages/api/session-controller/README.zh.md +++ b/packages/api/session-controller/README.zh.md @@ -33,7 +33,7 @@ kind: "package-reference" 经过身份验证的 `/api/file` 路由通过已组合的文件系统提供者提供绝对路径文件。每个文件响应都以文件版本作为 `ETag`,并带 `Cache-Control: private, no-cache`,因此浏览器重新显示未变化的图片时,经一次 `stat` 后得到空的 304,而每次加载仍需通过身份验证。对于无扩展名的栅格文件,包括持久化的附件对象,它会识别 PNG、JPEG、WebP 和 GIF 字节,使 Markdown 图片能够直接引用已存储的路径。`pathReads: false` 不注册该路由,适用于服务多个账号、其读者只能通过自己的 Session 访问文件的 Host。`/api/attachment-file` 只在 Session 日志引用某个已存储原件时才提供它:作为文件内容块,或作为工具结果在其元数据中记录的非图片文件引用,例如 `show_motion` 存储的影片。 -当 `canOpenWorkspacePath()` 报告 false 时,`openWorkspacePath` 以 `session/open-unavailable` 拒绝,因此没有桌面的 Host 绝不会为调用者运行原生打开器。原生打开器失败且该路径上什么都不存在时,它以 `session/path-missing` 及该路径拒绝,例如账户另一台设备写出的文件;其他失败为 `gateway/internal`,附带打开器的 stderr,而不是写出其 argv 的 `Command failed:` 那一行。 +`GET /api/attachment-file` 提供会话日志以文件、以图片(产出图片的副本,工具结果将其作为图片共享)或仅在工具结果的产出文件中以 id 引用的存储副本;后者的名称和媒体类型取自产出路径。当 `canOpenWorkspacePath()` 报告 false 时,`openWorkspacePath` 以 `session/open-unavailable` 拒绝,因此没有桌面的 Host 绝不会为调用者运行原生打开器。原生打开器失败且该路径上什么都不存在时,它以 `session/path-missing` 及该路径拒绝,例如账户另一台设备写出的文件;其他失败为 `gateway/internal`,附带打开器的 stderr,而不是写出其 argv 的 `Command failed:` 那一行。 Client adapter 提供 `SessionEventStream`,即绑定到一个普通 Session 或 direct subagent address 的 Gateway `RemoteJournalStream`。它在读取首个 page 前打开 follow,只发布连续的 `replace`、`prepend` 和 `append` 变更,并通过 tail page 修复重连或 seq 缺口。向后分页有两个动词:`loadOlder()` 拉一页 50 条 message,而 `loadThrough(seq)`——轮次跳转加载器——无论目标在多远之前,都只用一个往返安装一个锚定在目标 seq 上的 200 条 message 窗口;重复调用会加入进行中的那一趟并下调共享目标,已安装的窗口覆盖该目标时该趟即结束;忙碌状态复用同一个 `loadingOlder` 快照位。普通 record 覆盖 `[event.seq, event.seq]`,packed row 覆盖 `[event.seq, event.seq + memberCount - 1]`。业务、persistence 或无法恢复的连续性错误会终止 stream,只有物理载体断开才触发自动恢复。`SessionControlStream` 是 Gateway `RemoteSnapshotStream`;每代都以完整的进程本地 baseline 开始,因此重连会替换 queue、jobs 和 projection 状态,而不会把瞬态值当作 durable event。 diff --git a/packages/api/session-controller/src/commands.ts b/packages/api/session-controller/src/commands.ts index fee8445ccc..1a21654e87 100644 --- a/packages/api/session-controller/src/commands.ts +++ b/packages/api/session-controller/src/commands.ts @@ -2,11 +2,13 @@ import { randomUUID } from 'node:crypto' import type { Context } from '@deepseek-ai/cordis' +import { stat } from 'node:fs/promises' +import { producedCopyName, producedMediaType } from './produced-copies.ts' import { brandString } from '@aeven/brand' import type { Agent, ModelSelection as AgentModelSelection } from '@aeven/agent' import { AttachmentError, admitPromptContent } from '@aeven/attachment' import { readFetchedAttachment } from './file-uploads.ts' -import type { FileAttachmentRef, ImageAttachmentRef, StoredFileAttachment, StoredImageAttachment } from '@aeven/attachment' +import type { AttachmentId, FileAttachmentRef, ImageAttachmentRef, StoredFileAttachment, StoredImageAttachment } from '@aeven/attachment' import { ReasoningEffortId, createUserMessage, freezeMessage, } from '@aeven/llm' @@ -758,10 +760,27 @@ export class SessionCommandController { */ async referencedFile(sessionId: SessionId, attachmentId: string): Promise { const source = await this.readSessionState(sessionId) - const ref = referencedAttachment(source.events, 'file', attachmentId) + const ref = referencedAttachment(source.events, 'file', attachmentId) ?? await this.producedCopyRef(source.events, attachmentId) return ref === undefined ? undefined : readFetchedAttachment(this.ctx, attachmentId, () => this.ctx.attachments.readFile(ref)) } + /** + * The reference of a stored copy a tool result names only in its produced files, which records the copy's id and the + * file's path but no file block: the name and media type come from the path, the length from the stored object. + * @param events - the Session log. + * @param attachmentId - the copy's id. + * @returns the reference, or undefined when no produced file names the copy or this Host does not hold it. + */ + private async producedCopyRef(events: readonly SessionEvent[], attachmentId: string): Promise { + const name = producedCopyName(events, attachmentId) + if (name === undefined) return undefined + const id = brandString(attachmentId) + const host = this.ctx.attachments.fileHostPath({ attachmentId: id } as FileAttachmentRef) + const bytes = host === undefined ? undefined : await stat(host).then(info => info.size, () => undefined) + if (bytes === undefined) return undefined + return { attachmentId: id, mediaType: producedMediaType(name), bytes, name, extraction: { textId: id } } as unknown as FileAttachmentRef + } + /** * Read one image the addressed Session log cites. * @param sessionId - the Session whose log is searched. diff --git a/packages/api/session-controller/src/file-uploads.ts b/packages/api/session-controller/src/file-uploads.ts index b03976fc11..ecdef39b6e 100644 --- a/packages/api/session-controller/src/file-uploads.ts +++ b/packages/api/session-controller/src/file-uploads.ts @@ -229,6 +229,7 @@ function attachmentReadFailure(error: unknown): Response { async function read( request: Request, readReferenced: (sessionId: SessionId, attachmentId: string) => Promise, + readReferencedImage: (sessionId: SessionId, attachmentId: string) => Promise, ): Promise { const url = new URL(request.url) const sessionId = url.searchParams.get('sessionId') @@ -236,14 +237,21 @@ async function read( if (sessionId === null || sessionId === '' || attachmentId === null || attachmentId === '') { return failure(400, 'INVALID_ATTACHMENT_REF', 'sessionId and id are required.') } - let stored: StoredFileAttachment | undefined + let stored: StoredOriginal | undefined try { - stored = await readReferenced(brandString(sessionId), attachmentId) + const file = await readReferenced(brandString(sessionId), attachmentId) + // A file a command produced is cited as an image when it is one, which its row, its link, and its download all + // read through this route. + const image = file === undefined ? await readReferencedImage(brandString(sessionId), attachmentId) : undefined + const imageName = image === undefined ? '' : image.ref.name ?? derivedImageName(String(image.ref.attachmentId), image.ref.mediaType) + stored = file !== undefined + ? { mediaType: file.ref.mediaType, name: file.ref.name, data: file.data } + : image === undefined ? undefined : { mediaType: image.ref.mediaType, name: imageName, data: image.data } } catch (error) { return attachmentReadFailure(error) } if (stored === undefined) return failure(404, 'ATTACHMENT_NOT_REFERENCED', 'File is not referenced by this session.') - return storedOriginal({ mediaType: stored.ref.mediaType, name: stored.ref.name, data: stored.data }, request) + return storedOriginal(stored, request) } /** @@ -324,18 +332,20 @@ export function registerImageReadRoute( } /** - * Register the stored-original read route. + * Register the stored-original read route, which serves a stored copy the Session log cites as a file or as an image. * @param ctx - context carrying the connection service. * @param readReferenced - Session-authorized reader of one cited original. + * @param readReferencedImage - Session-authorized reader of one cited image, such as a produced image's copy. */ export function registerFileReadRoute( ctx: Context, readReferenced: (sessionId: SessionId, attachmentId: string) => Promise, + readReferencedImage: (sessionId: SessionId, attachmentId: string) => Promise, ): void { ctx.effect(() => ctx.connection.fetch.register({ path: FILE_READ_PATH, methods: ['GET', 'HEAD'], - fetch: request => read(request, readReferenced), + fetch: request => read(request, readReferenced, readReferencedImage), }), 'session-controller: /api/attachment-file') } diff --git a/packages/api/session-controller/src/index.ts b/packages/api/session-controller/src/index.ts index a8010646b8..8c798822a5 100644 --- a/packages/api/session-controller/src/index.ts +++ b/packages/api/session-controller/src/index.ts @@ -209,7 +209,11 @@ export class SessionController extends TypertRemoteService { }) }) ctx.inject(['connection', 'attachments'], (readCtx) => { - registerFileReadRoute(readCtx, (sessionId, attachmentId) => this.commands.referencedFile(sessionId, attachmentId)) + registerFileReadRoute( + readCtx, + (sessionId, attachmentId) => this.commands.referencedFile(sessionId, attachmentId), + (sessionId, attachmentId) => this.commands.referencedImage(sessionId, attachmentId), + ) registerImageReadRoute( readCtx, (sessionId, attachmentId) => this.commands.referencedImage(sessionId, attachmentId), diff --git a/packages/api/session-controller/src/produced-copies.ts b/packages/api/session-controller/src/produced-copies.ts new file mode 100644 index 0000000000..e8043574f3 --- /dev/null +++ b/packages/api/session-controller/src/produced-copies.ts @@ -0,0 +1,46 @@ +/** + * Stored copies a tool result names only in its produced files: the copy's id beside the path of the file it copies, + * with no file or image block. The file route serves such a copy under the produced file's name and media type. + * @module @aeven/api-session-controller/produced-copies + */ +import type { SessionEvent } from '@aeven/session' + +/** Media types of the files commands commonly produce, by extension; others are served as bytes. */ +const PRODUCED_MEDIA_TYPES: Readonly> = { + jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', webp: 'image/webp', gif: 'image/gif', svg: 'image/svg+xml', + pdf: 'application/pdf', mp4: 'video/mp4', webm: 'video/webm', mp3: 'audio/mpeg', wav: 'audio/wav', txt: 'text/plain', + csv: 'text/csv', json: 'application/json', html: 'text/html', + docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', +} + +/** + * The name of the produced file a tool result of the log names a stored copy for. + * @param events - the Session log. + * @param attachmentId - the copy's id. + * @returns the produced file's base name from the latest result that names the copy, or undefined when none does. + */ +export function producedCopyName(events: readonly SessionEvent[], attachmentId: string): string | undefined { + let path: string | undefined + for (const event of events) { + if (event.type !== 'tool/result') continue + const produced = (event.data.meta as { producedFiles?: unknown } | undefined)?.producedFiles + if (!Array.isArray(produced)) continue + for (const file of produced as unknown[]) { + const entry = file as { path?: unknown; attachmentId?: unknown } | null + if (entry?.attachmentId === attachmentId && typeof entry.path === 'string') path = entry.path + } + } + return path === undefined ? undefined : path.slice(Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')) + 1) +} + +/** + * The media type a produced file's name declares. + * @param name - the file's base name. + * @returns the type its extension names, or `application/octet-stream` for one this list does not know. + */ +export function producedMediaType(name: string): string { + const dot = name.lastIndexOf('.') + return (dot < 0 ? undefined : PRODUCED_MEDIA_TYPES[name.slice(dot + 1).toLowerCase()]) ?? 'application/octet-stream' +} diff --git a/packages/api/session-controller/tests/attachment-file-route.host.spec.ts b/packages/api/session-controller/tests/attachment-file-route.host.spec.ts new file mode 100644 index 0000000000..89add3dffd --- /dev/null +++ b/packages/api/session-controller/tests/attachment-file-route.host.spec.ts @@ -0,0 +1,116 @@ +import type { Context } from '@deepseek-ai/cordis' +import type { StoredFileAttachment, StoredImageAttachment } from '@aeven/attachment' +import type { SessionEvent } from '@aeven/session' +import { describe, expect, it } from 'vitest' +import { registerFileReadRoute } from '../src/file-uploads.ts' +import { producedCopyName, producedMediaType } from '../src/produced-copies.ts' + +const DIGEST = '2abf4a2f07dfbed60e7930cdbda278b33583587ef42616851e8109f333815503' +const BYTES = new Uint8Array([0xff, 0xd8, 0xff, 0xe0]) +const URL_INLINE = `http://localhost/api/attachment-file?sessionId=s-1&id=sha256:${DIGEST}` + +/** A produced image's copy as a tool result shares it: an image block, not a file block. */ +function image(name?: string): StoredImageAttachment { + return { + ref: { + attachmentId: `sha256:${DIGEST}`, mediaType: 'image/jpeg', bytes: BYTES.byteLength, width: 1736, height: 1830, + ...(name === undefined ? {} : { name }), + }, + data: BYTES, + } as unknown as StoredImageAttachment +} + +/** A stored original a user message or tool result cites as a file. */ +function file(name: string): StoredFileAttachment { + return { + ref: { attachmentId: `sha256:${DIGEST}`, mediaType: 'application/pdf', bytes: BYTES.byteLength, name }, + data: BYTES, + } as unknown as StoredFileAttachment +} + +/** + * Mount the route over double readers and return it. + * @param readFile - the reader of a copy the session cites as a file. + * @param readImage - the reader of a copy the session cites as an image. + * @returns the registered request handler. + */ +function routeFor( + readFile: () => Promise, + readImage: () => Promise, +) { + let route: ((request: Request) => Promise) | undefined + registerFileReadRoute({ + connection: { + fetch: { + register: (entry: { fetch: (request: Request) => Promise }) => { + route = entry.fetch + return () => {} + }, + }, + }, + effect: (register: () => void) => { register() }, + } as unknown as Context, readFile, readImage) + if (route === undefined) throw new Error('File route was not registered') + return route +} + +describe('the stored-original route', () => { + it('serves a copy the session cites as a file', async () => { + const response = await routeFor(async () => file('report.pdf'), async () => undefined)(new Request(URL_INLINE)) + + expect(response.status).toBe(200) + expect(response.headers.get('Content-Type')).toBe('application/pdf') + expect(response.headers.get('Content-Disposition')).toContain('filename="report.pdf"') + }) + + it('serves a produced image whose copy the session cites as an image, for its row, its link, and its download', async () => { + const route = routeFor(async () => undefined, async () => image('Rainbow_High_Set_of_6_Dolls.jpg')) + const inline = await route(new Request(URL_INLINE)) + const download = await route(new Request(`${URL_INLINE}&download=1`)) + + expect(inline.status).toBe(200) + expect(inline.headers.get('Content-Type')).toBe('image/jpeg') + expect(new Uint8Array(await inline.arrayBuffer())).toEqual(BYTES) + expect(download.headers.get('Content-Disposition')).toContain('attachment; filename="Rainbow_High_Set_of_6_Dolls.jpg"') + }) + + it('names an image copy stored without a name after its digest', async () => { + const response = await routeFor(async () => undefined, async () => image())(new Request(URL_INLINE)) + + expect(response.headers.get('Content-Disposition')).toContain('filename="2abf4a2f07df.jpg"') + }) + + it('refuses a copy the session cites neither as a file nor as an image', async () => { + const response = await routeFor(async () => undefined, async () => undefined)(new Request(URL_INLINE)) + + expect(response.status).toBe(404) + await expect(response.json()).resolves.toMatchObject({ code: 'ATTACHMENT_NOT_REFERENCED' }) + }) +}) + +describe('copies named only in produced files', () => { + /** A tool result whose produced files name a copy, as a desktop records an image it wrote without sharing it. */ + function result(path: string, attachmentId: string): SessionEvent { + const meta = { producedFiles: [{ path, created: true, attachmentId }] } + return { type: 'tool/result', seq: 1, time: 0, data: { meta } } as unknown as SessionEvent + } + + it('finds the produced file a copy belongs to, by its base name, from the latest result naming it', () => { + const events = [ + result('/Users/elizabethtrejo/.aeven/chats/draft.jpg', 'sha256:3cd4'), + result('/Users/elizabethtrejo/.aeven/chats/Rainbow_High_Set_of_6_Dolls_preview.jpg', 'sha256:3cd4'), + result('C:\\Users\\e\\other.png', 'sha256:9eb1'), + ] + + expect(producedCopyName(events, 'sha256:3cd4')).toBe('Rainbow_High_Set_of_6_Dolls_preview.jpg') + expect(producedCopyName(events, 'sha256:9eb1')).toBe('other.png') + expect(producedCopyName(events, 'sha256:none')).toBeUndefined() + }) + + it('takes the media type the produced name declares, bytes for an unknown one', () => { + expect(producedMediaType('Rainbow.JPG')).toBe('image/jpeg') + expect(producedMediaType('deck.pptx')).toBe('application/vnd.openxmlformats-officedocument.presentationml.presentation') + expect(producedMediaType('notes')).toBe('application/octet-stream') + expect(producedMediaType('model.blend')).toBe('application/octet-stream') + }) +}) diff --git a/packages/api/session-controller/tsconfig.host.json b/packages/api/session-controller/tsconfig.host.json index c82a7401b3..66d91a0735 100644 --- a/packages/api/session-controller/tsconfig.host.json +++ b/packages/api/session-controller/tsconfig.host.json @@ -17,6 +17,7 @@ "src/interactions.ts", "src/file-references.ts", "src/file-uploads.ts", + "src/produced-copies.ts", "src/history.ts", "src/list.ts", "src/media-references.ts", diff --git a/packages/client/ui-chat/src/client/chat/AssistantNodeView.tsx b/packages/client/ui-chat/src/client/chat/AssistantNodeView.tsx index ee4f9076ec..7a924b0772 100644 --- a/packages/client/ui-chat/src/client/chat/AssistantNodeView.tsx +++ b/packages/client/ui-chat/src/client/chat/AssistantNodeView.tsx @@ -2,6 +2,8 @@ import { memo, useCallback, useMemo } from 'react' import type { ChatNodeViewProps, TurnTailOwnerProps } from '../contract/slots.ts' import { AssistantMarkdown } from './AssistantMarkdown.tsx' import { assistantImageUrl } from './workspace-images.ts' +import type { GeneratedImages, ProducedImages } from '../contract/generated-images.ts' +import type { ReadImages } from '../conversation-nodes/read-images.ts' /** A file of the Host's content-addressed attachment store (`attachments/v1/objects//`). */ const ATTACHMENT_OBJECT_PATH = /\/attachments\/v1\/objects\/[0-9a-f]{2}\/([0-9a-f]{64})$/ @@ -17,30 +19,14 @@ export const AssistantNodeView = memo(function AssistantNodeView({ : undefined const generated = useTurnData('generated-images') const read = useTurnData('read-images') - // The closed Turn's tail shows its produced images whole; a reply showing one of them, by its path or by the copy - // `reply-images/stored` recorded of the path it wrote, leaves it there. + // The closed Turn's tail draws its produced images; a reply showing one of them through the copy + // `reply-images/stored` recorded of the path it wrote leaves it there, but only a copy the tail can draw. const produced = useTurnData('produced-images') const tailImages = turn?.status === 'closed' ? produced : undefined - const imageVisible = useCallback((source: string): boolean => { - if (generated === undefined && tailImages === undefined) return true - let decoded = source - try { decoded = decodeURI(source) } catch { - // Malformed escapes retain the authored source for exact comparison. - } - const relative = cwd === undefined || !decoded.startsWith(`${cwd.replace(/\/$/, '')}/`) - ? undefined - : decoded.slice(cwd.replace(/\/$/, '').length + 1) - if (tailImages !== undefined) { - if (tailImages.paths.has(decoded) || (relative !== undefined && tailImages.paths.has(relative))) return false - const stored = read?.byPath.get(decoded) - if (stored !== undefined && tailImages.attachmentIds.has(String(stored.attachmentId))) return false - } - if (generated === undefined) return true - if (generated.sources.has(decoded)) return false - if (relative !== undefined && generated.sources.has(relative)) return false - const segments = decoded.split(/[/?#]/) - return !segments.some(segment => generated.attachmentIds.has(segment) || generated.attachmentIds.has(segment.replace(/^image:/, ''))) - }, [cwd, generated, read, tailImages]) + const imageVisible = useCallback( + (source: string): boolean => replyImageVisible(source, { cwd, generated, read, tailImages }), + [cwd, generated, read, tailImages], + ) // An authored image of a file this Turn read with read_image shows the copy // stored then: the file itself may be gone, or on another device's disk. A // path into the Host's attachment store names a stored image by its hash. @@ -66,8 +52,8 @@ export const AssistantNodeView = memo(function AssistantNodeView({ const owner = useMemo(() => { if (turn?.status !== 'closed' || data.finalNode === undefined) return undefined if (tail?.closing?.finalNode.seq !== data.finalNode.seq) return undefined - return { turn, seq: data.finalNode.seq, cwd, openFile } - }, [cwd, data.finalNode, openFile, tail, turn]) + return { turn, seq: data.finalNode.seq, cwd, openFile, renderImages: renderMessageImages } + }, [cwd, data.finalNode, openFile, renderMessageImages, tail, turn]) const mentions = useMemo( () => owner === undefined ? undefined : fileMentions(owner), [fileMentions, owner], @@ -99,3 +85,44 @@ export const AssistantNodeView = memo(function AssistantNodeView({ /> ) }) + +/** What decides whether a reply's Markdown image stays in the reply. */ +export interface ReplyImageContext { + /** The Session workspace root, against which a source may be written. */ + cwd: string | undefined + /** The Turn's generated images, which their own frames show. */ + generated: GeneratedImages | undefined + /** The Turn's stored images, by the path a reply showed and by attachment id. */ + read: ReadImages | undefined + /** The produced images a closed Turn's tail draws; undefined while the Turn runs. */ + tailImages: ProducedImages | undefined +} + +/** + * Whether a reply shows one of its Markdown images itself. An image a generated-image frame or the closed Turn's tail + * already draws is left to them; the tail takes only a copy a tool result of the Turn shared in full, which it draws. + * @param source - the image source as the reply wrote it. + * @param context - the Turn's generated, stored, and produced images. + * @returns false when another surface of the Turn draws the image. + */ +export function replyImageVisible(source: string, context: ReplyImageContext): boolean { + const { cwd, generated, read, tailImages } = context + if (generated === undefined && tailImages === undefined) return true + let decoded = source + try { decoded = decodeURI(source) } catch { + // Malformed escapes retain the authored source for exact comparison. + } + const relative = cwd === undefined || !decoded.startsWith(`${cwd.replace(/\/$/, '')}/`) + ? undefined + : decoded.slice(cwd.replace(/\/$/, '').length + 1) + if (tailImages !== undefined) { + const stored = read?.byPath.get(decoded) + const drawn = stored !== undefined && read?.byAttachment.has(String(stored.attachmentId)) === true + if (drawn && tailImages.attachmentIds.has(String(stored.attachmentId))) return false + } + if (generated === undefined) return true + if (generated.sources.has(decoded)) return false + if (relative !== undefined && generated.sources.has(relative)) return false + const segments = decoded.split(/[/?#]/) + return !segments.some(segment => generated.attachmentIds.has(segment) || generated.attachmentIds.has(segment.replace(/^image:/, ''))) +} diff --git a/packages/client/ui-chat/src/client/contract/slots.ts b/packages/client/ui-chat/src/client/contract/slots.ts index b0bf330c8d..9151f854dc 100644 --- a/packages/client/ui-chat/src/client/contract/slots.ts +++ b/packages/client/ui-chat/src/client/contract/slots.ts @@ -49,6 +49,8 @@ export interface TurnTailOwnerProps { /** Session workspace root, when the session list row carries one; tails display paths relative to it. */ cwd?: string | undefined openFile: OpenWorkspaceFile + /** The conversation's image renderer, which draws an image the Turn produced the way a generated image is drawn. */ + renderImages?: RenderMessageImages | undefined } /** Owner currency of prose file links, which any Assistant step of a Session may carry. */ diff --git a/packages/client/ui-chat/tests/reply-image-visible.client.spec.ts b/packages/client/ui-chat/tests/reply-image-visible.client.spec.ts new file mode 100644 index 0000000000..7e1d6e73ef --- /dev/null +++ b/packages/client/ui-chat/tests/reply-image-visible.client.spec.ts @@ -0,0 +1,44 @@ +/** + * Whether a reply shows its own Markdown image or leaves it to another surface of the Turn: a generated-image frame, + * or the closed Turn's tail, which draws a produced image only from a copy a tool result shared in full (#761). + */ +import { describe, expect, it } from 'vitest' +import type { ImageAttachmentRef } from '@aeven/attachment' +import { replyImageVisible } from '../src/client/chat/AssistantNodeView.tsx' + +const PINK = '/datadrive/apps/aeven-hosted/home/sandbox/accounts/b1b1/chats/Rainbow_High_Set_of_6_Dolls.jpg' +const copy = { + attachmentId: 'sha256:2abf4a2f', mediaType: 'image/jpeg', bytes: 622650, width: 1736, height: 1830, +} as unknown as ImageAttachmentRef +const tail = { attachmentIds: new Set(['sha256:2abf4a2f']), paths: new Set(['Rainbow_High_Set_of_6_Dolls.jpg']) } + +describe('replyImageVisible', () => { + it('leaves a produced image to the tail when the Turn shared its copy in full', () => { + const read = { byPath: new Map([[PINK, copy]]), byAttachment: new Map([['sha256:2abf4a2f', copy]]) } + expect(replyImageVisible(PINK, { cwd: undefined, generated: undefined, read, tailImages: tail })).toBe(false) + }) + + it('keeps a produced image in the reply when the tail cannot draw its copy, so it never disappears from both', () => { + // `reply-images/stored` recorded the reply's copy, but no tool result of the Turn shared it as an image. + const read = { byPath: new Map([[PINK, copy]]), byAttachment: new Map() } + expect(replyImageVisible(PINK, { cwd: undefined, generated: undefined, read, tailImages: tail })).toBe(true) + }) + + it('keeps an image named only by a produced path, which the tail no longer hides by path', () => { + const context = { cwd: '/w', generated: undefined, read: undefined, tailImages: tail } + expect(replyImageVisible('Rainbow_High_Set_of_6_Dolls.jpg', context)).toBe(true) + }) + + it('keeps every image while the Turn runs, before its tail is drawn', () => { + const read = { byPath: new Map([[PINK, copy]]), byAttachment: new Map([['sha256:2abf4a2f', copy]]) } + expect(replyImageVisible(PINK, { cwd: undefined, generated: undefined, read, tailImages: undefined })).toBe(true) + }) + + it('leaves a generated image to its frame, by path relative to the workspace or by attachment id', () => { + const generated = { callIds: new Set(), attachmentIds: new Set(['sha256:abc']), sources: new Set(['out/a.png']) } + const context = { cwd: '/w', generated, read: undefined, tailImages: undefined } + expect(replyImageVisible('/w/out/a.png', context)).toBe(false) + expect(replyImageVisible('image:sha256:abc', context)).toBe(false) + expect(replyImageVisible('/w/out/b.png', context)).toBe(true) + }) +}) diff --git a/packages/client/ui-deliverables/README.i18n.yaml b/packages/client/ui-deliverables/README.i18n.yaml index f1f09b84b6..08eea6c4cd 100644 --- a/packages/client/ui-deliverables/README.i18n.yaml +++ b/packages/client/ui-deliverables/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/client/ui-deliverables/README.md -README.md: ca0746a40e7fe8cdde0fd1efe8dcd4c7b0460576 -README.zh.md: f99222896674e623f589ac4042f1797692a7f09c +README.md: 781d0897f789587126426cf0089244444cb48f5c +README.zh.md: 3478b951dc534f410632e8193af0128db9431983 diff --git a/packages/client/ui-deliverables/README.md b/packages/client/ui-deliverables/README.md index ca0746a40e..781d0897f7 100644 --- a/packages/client/ui-deliverables/README.md +++ b/packages/client/ui-deliverables/README.md @@ -25,7 +25,7 @@ This package renders the deliverables row a finished turn ends with — the file ## Use this package -Mount this plugin alongside `ui-conversation`; a finished turn then ends with the produced-files row between the closing message's body and its action footer. New-file pills and edited-file rows preview the selected file in the Files sidebar through `sidebarFiles.open`, handing it the file's stored copy when the result recorded one, so a media file another device wrote plays there; a non-text file without a sidebar viewer opens in the default app when the page is loopback and the Host can open paths, and otherwise downloads its stored copy through `/api/attachment-file` when the result recorded one, such as a conversation another device of the account runs, and through `sidebarFiles.fileUrl` when it did not. A produced video or audio file also plays in place above the tables, from its stored copy when one is recorded and from `sidebarFiles.fileUrl` otherwise; a file neither source can serve keeps only its row. A produced image shows whole above the tables instead of as a row, from the same sources: a lone image at its own proportions, several as tiles the way generated images are; a click opens it as its row would, and an image neither source serves returns to its row. The `produced-images` Turn data index this plugin publishes names the images a Turn's commands declared, so once the Turn closed a reply that shows one of them as a Markdown image leaves it to the tail. On the desktop, a file whose path is missing on this Host downloads its stored copy instead of opening the refusal dialog, and a prose link naming only the tail of exactly one produced path, such as its basename, opens that produced path. A Turn whose commands declared `output_files` lists only those outputs, so a resume's `cv.json` or a deck's `deck.json` stays out of the row and the prose links. Inline mentions use the Host opener, with relative paths resolved against the session cwd, except that a page which is not loopback downloads a file's stored copy when the result recorded one; when the row first appears, it queries `session.canOpenWorkspacePath()`, and an omitted-file **Show in folder** action opens the session workspace only when the page is loopback and that query succeeds with `true`. +Mount this plugin alongside `ui-conversation`; a finished turn then ends with the produced-files row between the closing message's body and its action footer. New-file pills and edited-file rows preview the selected file in the Files sidebar through `sidebarFiles.open`, handing it the file's stored copy when the result recorded one, so a media file another device wrote plays there; a non-text file without a sidebar viewer opens in the default app when the page is loopback and the Host can open paths, and otherwise downloads its stored copy through `/api/attachment-file` when the result recorded one, such as a conversation another device of the account runs, and through `sidebarFiles.fileUrl` when it did not. A produced video or audio file also plays in place above the tables, from its stored copy when one is recorded and from `sidebarFiles.fileUrl` otherwise; a file neither source can serve keeps only its row. A produced image is drawn above the tables the way a generated image is: through the conversation's image renderer (`renderImages` of the turn-tail owner) in a 3:2 or 2:3 frame, a lone landscape image across the column and a lone portrait in two thirds of it, from the full image reference of the copy any tool result of the Turn shared. An image whose reference the Turn does not carry shows from its stored copy's URL, and one neither source serves returns to its row. The `produced-images` Turn data index this plugin publishes names the images a Turn's commands declared, so once the Turn closed a reply that shows one of them through its stored copy leaves it to the tail. A file the closing message mentions opens the way its row does: the Files sidebar with its stored copy first. On the desktop, a file whose path is missing on this Host downloads its stored copy instead of opening the refusal dialog, and a prose link naming only the tail of exactly one produced path, such as its basename, opens that produced path. A Turn whose commands declared `output_files` lists only those outputs, so a resume's `cv.json` or a deck's `deck.json` stays out of the row and the prose links. Inline mentions use the Host opener, with relative paths resolved against the session cwd, except that a page which is not loopback downloads a file's stored copy when the result recorded one; when the row first appears, it queries `session.canOpenWorkspacePath()`, and an omitted-file **Show in folder** action opens the session workspace only when the page is loopback and that query succeeds with `true`. ### The row diff --git a/packages/client/ui-deliverables/README.zh.md b/packages/client/ui-deliverables/README.zh.md index f992228966..3478b951dc 100644 --- a/packages/client/ui-deliverables/README.zh.md +++ b/packages/client/ui-deliverables/README.zh.md @@ -25,7 +25,7 @@ kind: "package-reference" ## 使用本包 -与 `ui-conversation` 一起挂载本插件;已完成轮次随即以产出文件行收尾,位于收尾消息正文与其动作页脚之间。新文件胶囊和编辑文件行通过 `sidebarFiles.open` 在 Files 侧栏预览选定文件,结果记录了存储副本时一并交给它,使另一台设备写出的媒体文件也能在那里播放;没有侧栏查看器的非文本文件在页面为 loopback 且 Host 能打开路径时于默认应用中打开,否则在结果记录了存储副本时(例如由账户另一台设备运行的对话)通过 `/api/attachment-file` 下载该副本,未记录时通过 `sidebarFiles.fileUrl` 下载。产出的视频或音频文件还会在表格上方就地播放,有记录的存储副本时来自该副本,否则来自 `sidebarFiles.fileUrl`;两种来源都无法提供的文件只保留其行。产出的图片以完整图片显示在表格上方,而不是一行,来源相同:单张图片保持自身比例,多张时像生成图片那样平铺;点击后按其行的方式打开,两种来源都无法提供的图片回到其行。本插件发布的 `produced-images` 轮次数据索引列出轮次命令声明的图片,因此轮次关闭后,以 Markdown 图片显示其中某张的回复会把它留给尾部。在桌面上,路径在本 Host 上缺失的文件会下载其存储副本,而不是打开拒绝对话框;只写出恰好一个产出路径末尾(例如其文件名)的正文链接会打开该产出路径。命令声明了 `output_files` 的轮次只列出这些输出,因此简历的 `cv.json` 或演示文稿的 `deck.json` 不会出现在该行和正文链接中。行内提及经 Host 打开器打开文件,相对路径按会话 cwd 解析;但页面不是 loopback 且结果记录了存储副本时,改为下载该副本;该行首次显示时会查询 `session.canOpenWorkspacePath()`,有文件被省略、页面为 loopback 且查询成功返回 `true` 时,**在文件夹中显示**动作才会打开会话工作区。 +与 `ui-conversation` 一起挂载本插件;已完成轮次随即以产出文件行收尾,位于收尾消息正文与其动作页脚之间。新文件胶囊和编辑文件行通过 `sidebarFiles.open` 在 Files 侧栏预览选定文件,结果记录了存储副本时一并交给它,使另一台设备写出的媒体文件也能在那里播放;没有侧栏查看器的非文本文件在页面为 loopback 且 Host 能打开路径时于默认应用中打开,否则在结果记录了存储副本时(例如由账户另一台设备运行的对话)通过 `/api/attachment-file` 下载该副本,未记录时通过 `sidebarFiles.fileUrl` 下载。产出的视频或音频文件还会在表格上方就地播放,有记录的存储副本时来自该副本,否则来自 `sidebarFiles.fileUrl`;两种来源都无法提供的文件只保留其行。产出的图片会像生成图片那样绘制在表格上方:通过对话的图片渲染器(轮次尾部所有者的 `renderImages`)绘制在 3:2 或 2:3 的框中,单张横图占满整栏,单张竖图占三分之二,来源是该轮次任一工具结果共享的副本的完整图片引用。轮次没有其引用的图片从其存储副本的 URL 显示,两种来源都无法提供的图片回到其行。本插件发布的 `produced-images` 轮次数据索引列出轮次命令声明的图片,因此轮次关闭后,通过存储副本显示其中某张的回复会把它留给尾部。收尾消息提到的文件按其行的方式打开:先在 Files 侧栏中打开其存储副本。在桌面上,路径在本 Host 上缺失的文件会下载其存储副本,而不是打开拒绝对话框;只写出恰好一个产出路径末尾(例如其文件名)的正文链接会打开该产出路径。命令声明了 `output_files` 的轮次只列出这些输出,因此简历的 `cv.json` 或演示文稿的 `deck.json` 不会出现在该行和正文链接中。行内提及经 Host 打开器打开文件,相对路径按会话 cwd 解析;但页面不是 loopback 且结果记录了存储副本时,改为下载该副本;该行首次显示时会查询 `session.canOpenWorkspacePath()`,有文件被省略、页面为 loopback 且查询成功返回 `true` 时,**在文件夹中显示**动作才会打开会话工作区。 ### 该行 diff --git a/packages/client/ui-deliverables/package.json b/packages/client/ui-deliverables/package.json index b76a7dbff0..854025d997 100644 --- a/packages/client/ui-deliverables/package.json +++ b/packages/client/ui-deliverables/package.json @@ -48,24 +48,25 @@ "@deepseek-ai/cordis": "workspace:^" }, "devDependencies": { - "@aeven/client-ui-sidebar-files": "workspace:^", "@aeven/api-remotes": "workspace:^", "@aeven/api-session-controller": "workspace:^", + "@aeven/attachment": "workspace:^", "@aeven/client-connection": "workspace:^", "@aeven/client-locale": "workspace:^", "@aeven/client-store": "workspace:^", "@aeven/client-test-runtime": "workspace:^", "@aeven/client-ui-chat": "workspace:^", "@aeven/client-ui-conversation": "workspace:^", + "@aeven/client-ui-primitives": "workspace:^", "@aeven/client-ui-renderer": "workspace:^", + "@aeven/client-ui-sidebar-files": "workspace:^", "@aeven/client-ui-slots": "workspace:^", - "@types/react": "~18.3.1", - "@deepseek-ai/cordis": "workspace:^", - "react": "^18.2.0", - "@aeven/client-ui-primitives": "workspace:^", "@aeven/session": "workspace:^", "@aeven/system-prompt": "workspace:^", - "@aeven/util-workspace-path": "workspace:^" + "@aeven/util-workspace-path": "workspace:^", + "@deepseek-ai/cordis": "workspace:^", + "@types/react": "~18.3.1", + "react": "^18.2.0" }, "dependencies": { "diff": "^9.0.0" diff --git a/packages/client/ui-deliverables/src/client/ProducedFiles.module.css b/packages/client/ui-deliverables/src/client/ProducedFiles.module.css index 8927d934d9..a8cb31556b 100644 --- a/packages/client/ui-deliverables/src/client/ProducedFiles.module.css +++ b/packages/client/ui-deliverables/src/client/ProducedFiles.module.css @@ -24,10 +24,11 @@ --deliverable-toolbar-color: #fff; } -/* Produced images, shown whole as the generated-image lane shows its frames: - a lone landscape image fills the column and a lone portrait takes two thirds - of it, both at their own proportions; several share the column as 3:2 or 2:3 - tiles, halves wrapping into rows of two, three in thirds. */ +/* Produced images, drawn as the generated-image lane draws its frames: a + frame decides the geometry and the image fills it edge to edge, 3:2 for a + landscape image and 2:3 for a portrait; a lone landscape frame fills the + column and a lone portrait takes two thirds of it; two share it in halves, + three in thirds, and a fourth wraps into rows of two. */ .images { display: flex; @@ -55,13 +56,9 @@ aspect-ratio: 2 / 3; } -.images[data-produced-images='3'] .imageFrame { - flex: 1 1 calc(33.333% - 8px); -} - .images[data-produced-images='1'] .imageFrame { flex: 0 0 100%; - aspect-ratio: auto; + width: 100%; } .images[data-produced-images='1'] .imageFrame[data-orientation='portrait'] { @@ -69,6 +66,16 @@ width: 66.666%; } +.images[data-produced-images='3'] .imageFrame { + flex: 1 1 calc(33.333% - 8px); +} + +/* Whatever the frame holds, the renderer's image or a plain one, takes the whole box. */ +.imageFrame > * { + width: 100%; + height: 100%; +} + .image { display: block; width: 100%; @@ -76,10 +83,6 @@ object-fit: cover; } -.images[data-produced-images='1'] .image { - height: auto; -} - /* Edited files. */ .card { diff --git a/packages/client/ui-deliverables/src/client/ProducedFiles.tsx b/packages/client/ui-deliverables/src/client/ProducedFiles.tsx index 1b23b39662..dfc4221886 100644 --- a/packages/client/ui-deliverables/src/client/ProducedFiles.tsx +++ b/packages/client/ui-deliverables/src/client/ProducedFiles.tsx @@ -4,6 +4,7 @@ import { VideoPlayer, videoPlayerLabels, } from '@aeven/client-ui-primitives' import type { HostObservable, InjectFace, PropsLocale } from '@aeven/client-ui-slots' +import type { ImageAttachmentRef } from '@aeven/attachment' import type { TurnTailOwnerProps } from '@aeven/client-ui-chat/client' import { basename, type ProducedFile } from './turn-deliverables.ts' import { revealLabel } from './file-menu.ts' @@ -62,9 +63,10 @@ export interface ProducedFilesInjected { } /** Matched files plus the opener, workspace root, locale, and injected Host capability. */ -export type ProducedFilesProps = Pick & { - matched: readonly ProducedFile[] -} & PropsLocale & InjectFace +export type ProducedFilesProps = Pick + & Partial> & { + matched: readonly ProducedFile[] + } & PropsLocale & InjectFace type Translate = ProducedFilesProps['t'] @@ -76,7 +78,7 @@ type Translate = ProducedFilesProps['t'] */ export function ProducedFiles({ matched, openFile, previewFile, fileUrl, attachmentUrl, cwd, isLoopback, ensureWorkspacePathOpen, - openFileMenu, useWorkspacePathOpen, t, + openFileMenu, useWorkspacePathOpen, renderImages, turn, t, }: ProducedFilesProps) { useEffect(() => { ensureWorkspacePathOpen() }, [ensureWorkspacePathOpen]) const hostCanOpenPath = useWorkspacePathOpen(available => available === true) @@ -110,6 +112,8 @@ export function ProducedFiles({ ))} {images.length > 0 && ( file.image} src={file => file.attachmentId === undefined ? fileUrl(file.path) : attachmentUrl(file.attachmentId)} onUnavailable={(path) => { setUnshown(previous => new Set(previous).add(path)) }} /> )} @@ -126,11 +130,16 @@ export function ProducedFiles({ } /** - * A turn's produced images, shown whole: a lone image at its own proportions, several as tiles across the column the - * way generated images are. A click opens the image as its row would. + * A turn's produced images, drawn the way generated images are: through the conversation's image renderer in 3:2 or + * 2:3 frames, a lone landscape image across the column and a lone portrait in two thirds of it. An image whose stored + * reference the Turn does not carry shows from its URL instead, and a click opens it as its row would. */ -function ProducedImages({ files, src, openFile, menu, onUnavailable, t }: { +function ProducedImages({ files, imageOf, renderImages, turn, src, openFile, menu, onUnavailable, t }: { files: readonly ProducedFile[] + /** The stored image a file's copy is, when the Turn carries its full reference. */ + imageOf: (file: ProducedFile) => ImageAttachmentRef | undefined + renderImages: TurnTailOwnerProps['renderImages'] + turn: number | undefined src: (file: ProducedFile) => string openFile: (file: ProducedFile) => void menu: ((path: string) => (event: MouseEvent) => void) | undefined @@ -141,20 +150,31 @@ function ProducedImages({ files, src, openFile, menu, onUnavailable, t }: { const [portrait, setPortrait] = useState>(() => new Set()) return (
- {files.map(file => ( - - ))} + {files.map((file) => { + const image = imageOf(file) + if (image !== undefined && renderImages !== undefined) { + return ( +
image.width ? 'portrait' : 'landscape'} + onContextMenu={menu?.(file.path)}> + {renderImages({ images: [{ attachment: image }], align: 'start', layout: 'fill', turn })} +
+ ) + } + return ( + + ) + })}
) } diff --git a/packages/client/ui-deliverables/src/client/index.ts b/packages/client/ui-deliverables/src/client/index.ts index 2cb79c4821..df27a1d350 100644 --- a/packages/client/ui-deliverables/src/client/index.ts +++ b/packages/client/ui-deliverables/src/client/index.ts @@ -10,14 +10,15 @@ import type { Context as ClientContext } from '@deepseek-ai/cordis' import type {} from '@aeven/api-remotes/client' import { createSnapshotStore } from '@aeven/client-store' -import type { ChatFileMentions } from '@aeven/client-ui-chat/client' +import type { ChatFileMentions, TurnTailOwnerProps } from '@aeven/client-ui-chat/client' +import type { SessionId } from '@aeven/session/types' import type {} from '@aeven/client-locale/client' import type {} from '@aeven/client-ui-conversation/client' import type {} from '@aeven/client-ui-renderer/client' import type {} from '@aeven/client-ui-sidebar-files/client' import { ProducedFiles } from './ProducedFiles.tsx' import { desktopFileMenus, fileMenuLabels, revealFile, showFileMenu } from './file-menu.ts' -import { downloadUrl, producedFileLinks } from './file-links.ts' +import { openProducedFile, producedFileLinks, type FileOpening } from './file-links.ts' import { en, es, NS, zh, type DeliverablesKey } from './locales.ts' import { deliverablesDefinition, producedFileMentions, producedImagesDefinition, producedFilesForClosing, selectProducedFiles, @@ -115,26 +116,29 @@ export function apply(ctx: ClientContext): void { ) // The prose side of the same vocabulary: the chat view reaches this face // via ctx.get, so its absence — this plugin composed out — is the off state. + // How a produced file opens from the prose: the Files sidebar first, with the file's stored copy, then the path on + // the reader's own desktop, falling back to the copy where the path is missing, then a download of the copy. + const openingFor = (sessionId: SessionId, openFile: TurnTailOwnerProps['openFile']): FileOpening => ({ + previewFile: (path: string, copy?: string) => + copy === undefined ? ctx.sidebarFiles.open(sessionId, path) : ctx.sidebarFiles.open(sessionId, path, copy), + fileUrl: (path: string, download?: boolean) => ctx.sidebarFiles.fileUrl(sessionId, path, download), + attachmentUrl: (attachmentId: string, download?: boolean) => attachmentUrl(sessionId, attachmentId, download), + canOpenPath: () => ctx.remote.$host.isLoopback && workspacePathOpen.getSnapshot() === true, + openFile, + }) + // The prose side of the same vocabulary: the chat view reaches this face + // via ctx.get, so its absence — this plugin composed out — is the off state. const mentions: ChatFileMentions = { forClosing(owner, sessionId) { // Same claim test the turn-tail chain entry runs: no produced files, // no vocabulary — the two surfaces agree by construction. const files = selectProducedFiles(owner) if (files === null) return undefined + ensureWorkspacePathOpen() + const opening = openingFor(sessionId, owner.openFile) return producedFileMentions( files, - // The conversation may run on another device of the account: a file with a stored copy downloads from it, - // as the row's does, where the page is not the Host's own desktop or the Host has nothing at the path. - (file) => { - const attachmentId = file.attachmentId - if (attachmentId === undefined) { - owner.openFile(file.path) - return - } - const download = () => { downloadUrl(attachmentUrl(sessionId, attachmentId, true)) } - if (ctx.remote.$host.isLoopback) owner.openFile(file.path, download) - else download() - }, + (file) => { openProducedFile(file, opening) }, path => t('produced.open', { name: path }), showMenu === undefined ? undefined : (path) => { showMenu(path, owner.cwd) }, ) @@ -143,14 +147,7 @@ export function apply(ctx: ClientContext): void { ensureWorkspacePathOpen() // Read when a link resolves, so files a later result of the same Turn settles are seen. const produced = () => producedFilesForClosing(owner.turn?.data.get('deliverables')) - return producedFileLinks(owner.cwd, produced, { - previewFile: (path: string, copy?: string) => - copy === undefined ? ctx.sidebarFiles.open(sessionId, path) : ctx.sidebarFiles.open(sessionId, path, copy), - fileUrl: (path: string, download?: boolean) => ctx.sidebarFiles.fileUrl(sessionId, path, download), - attachmentUrl: (attachmentId: string, download?: boolean) => attachmentUrl(sessionId, attachmentId, download), - canOpenPath: () => ctx.remote.$host.isLoopback && workspacePathOpen.getSnapshot() === true, - openFile: owner.openFile, - }) + return producedFileLinks(owner.cwd, produced, openingFor(sessionId, owner.openFile)) }, } ctx.provide('chatFileMentions', mentions) diff --git a/packages/client/ui-deliverables/src/client/turn-deliverables.ts b/packages/client/ui-deliverables/src/client/turn-deliverables.ts index f4b9029378..c84c0cf077 100644 --- a/packages/client/ui-deliverables/src/client/turn-deliverables.ts +++ b/packages/client/ui-deliverables/src/client/turn-deliverables.ts @@ -7,6 +7,7 @@ import { diffArrays } from 'diff' import { isAppendSurfaceEvent } from '@aeven/session/surface' import type { ProducedImages, TurnTailOwnerProps } from '@aeven/client-ui-chat/client' import type { ConversationNodeDefinition } from '@aeven/client-ui-conversation/client' +import type { ImageAttachmentRef } from '@aeven/attachment' import { fileKindOf, type MarkdownFileMentions } from '@aeven/client-ui-primitives' /** Lines one successful mutation added and deleted. */ @@ -25,6 +26,8 @@ interface ProducedPath { readonly counts?: LineCounts | undefined /** The stored copy of the file the deployment shared, absent when it shared none. */ readonly attachmentId?: string | undefined + /** That copy's full reference when the result shared it as an image, which the image renderer draws. */ + readonly image?: ImageAttachmentRef | undefined /** Whether a command declared the file as an output, rather than a file tool writing it. */ readonly declared?: true | undefined } @@ -39,6 +42,8 @@ export interface ProducedFile { readonly counts?: LineCounts | undefined /** The latest stored copy of the file, for a reader who cannot open the Host's folders. */ readonly attachmentId?: string | undefined + /** The latest copy's full image reference, when the result shared the file as an image. */ + readonly image?: ImageAttachmentRef | undefined } /** A recognized mutation call, held until its result settles. */ @@ -54,6 +59,8 @@ interface MutationCall { /** Immutable produced-file facts published against one Turn. */ export interface DeliverablesTurnData { readonly produced: readonly ProducedPath[] + /** Every image a successful tool result of the Turn shared, by attachment id, with its full reference. */ + readonly images?: ReadonlyMap | undefined } declare module '@aeven/client-ui-conversation/client' { @@ -263,16 +270,24 @@ export function producedFilesForClosing( const seen = files.get(produced.path) if (seen === undefined) { files.set(produced.path, { - path: produced.path, created: produced.created, counts: produced.counts, attachmentId: produced.attachmentId, + path: produced.path, created: produced.created, counts: produced.counts, attachmentId: produced.attachmentId, image: produced.image, }) continue } const counts = seen.counts === undefined || produced.counts === undefined ? undefined : { added: seen.counts.added + produced.counts.added, deleted: seen.counts.deleted + produced.counts.deleted } - files.set(produced.path, { ...seen, counts, attachmentId: produced.attachmentId ?? seen.attachmentId }) + files.set(produced.path, { + ...seen, + counts, + attachmentId: produced.attachmentId ?? seen.attachmentId, + image: produced.attachmentId === undefined ? seen.image : produced.image, + }) } - return [...files.values()] + // A copy shared by another result of the Turn, such as the image the agent viewed after writing it, is drawn too. + return [...files.values()].map(file => file.image !== undefined || file.attachmentId === undefined + ? file + : { ...file, image: data.images?.get(file.attachmentId) }) } /** @@ -304,6 +319,21 @@ function storedCopies(content: readonly unknown[]): Map { return copies } +/** + * The images a tool result shared, by attachment id, with the full reference the image renderer draws them from. + * @param content - the result's content blocks. + * @returns image references by attachment id. + */ +function sharedImages(content: readonly unknown[]): Map { + const images = new Map() + for (const block of content) { + if (!isRecord(block) || block.type !== 'image' || !isRecord(block.attachment)) continue + const ref = block.attachment as unknown as ImageAttachmentRef + if (typeof ref.attachmentId === 'string') images.set(ref.attachmentId, ref) + } + return images +} + /** Turn-local successful mutation accumulator; it publishes no view Node. */ export const deliverablesDefinition: ConversationNodeDefinition = { kind: 'deliverables', @@ -317,7 +347,7 @@ export const deliverablesDefinition: ConversationNodeDefinition { if (match.event.type !== 'turn/start') throw new Error('deliverables start requires turn/start') - return { turn: match.event.data.turn, calls: new Map(), produced: [] } + return { turn: match.event.data.turn, calls: new Map(), produced: [], images: new Map() } }, update: (context, match) => { if (match.event.type === 'tool/call') { @@ -332,37 +362,43 @@ export const deliverablesDefinition: ConversationNodeDefinition { if (!isRecord(file) || pathValue(file.path) === null || typeof file.created !== 'boolean') return [] // A result recorded before entries named their copy still attached it, under the file's own name. const attachmentId = typeof file.attachmentId === 'string' ? file.attachmentId : stored.get(basename(file.path as string)) + const image = attachmentId === undefined ? undefined : images.get(attachmentId) return [{ seq, path: file.path as string, created: file.created, declared: true as const, ...attachmentId === undefined ? {} : { attachmentId }, + ...image === undefined ? {} : { image }, }] }) - return { ...context.state, produced: [...context.state.produced, ...produced] } + return { ...state, produced: [...state.produced, ...produced] } } const callId = String(match.event.data.message.source.callId) - const calls = context.state.calls.get(callId) - if (calls === undefined || calls.length === 0) return context.state + const calls = state.calls.get(callId) + if (calls === undefined || calls.length === 0) return state const text = result.content.map(block => block.type === 'text' ? block.text : '').join('\n') const produced = calls.map(call => ({ seq, path: call.path, ...settledMutation(call, text, meta) })) - return { ...context.state, produced: [...context.state.produced, ...produced] } + return { ...state, produced: [...state.produced, ...produced] } }, buildLocationData: (context, scope, previous) => { if (scope !== 'turn' || context.state === undefined) return null if (previous?.kind === 'turn' && previous.turn === context.state.turn && previous.key === 'deliverables' - && previous.value.produced === context.state.produced) return previous + && previous.value.produced === context.state.produced + && previous.value.images === context.state.images) return previous return { kind: 'turn', turn: context.state.turn, key: 'deliverables', - value: { produced: context.state.produced }, + value: { produced: context.state.produced, images: context.state.images }, } }, } diff --git a/packages/client/ui-deliverables/tests/produced-files.client.spec.tsx b/packages/client/ui-deliverables/tests/produced-files.client.spec.tsx index 638c4f1320..4ccba6d377 100644 --- a/packages/client/ui-deliverables/tests/produced-files.client.spec.tsx +++ b/packages/client/ui-deliverables/tests/produced-files.client.spec.tsx @@ -26,6 +26,7 @@ import { type DeliverablesTurnData, } from '../src/client/turn-deliverables.ts' import { apply, inject } from '../src/client/index.ts' +import type { ImageAttachmentRef } from '@aeven/attachment' import type { SessionEvent } from '@aeven/session/types' import { SessionId } from '@aeven/session' @@ -416,6 +417,76 @@ describe('produced-file Turn data', () => { }) }) +describe('produced images (#761)', () => { + /** A produced image's stored copy as a tool result shares it: an image block with its full reference. */ + const rainbow = { + attachmentId: 'sha256:2abf4a2f', mediaType: 'image/jpeg', bytes: 622650, width: 1736, height: 1830, + name: 'Rainbow_High_Set_of_6_Dolls.jpg', + } as unknown as ImageAttachmentRef + + function imageResult(seq: number, callId: string, producedFiles: unknown, images: readonly unknown[]): SessionLiveEventEntry { + return at(seq, 'tool/result', { + turn: 1, step: 1, ...producedFiles === undefined ? {} : { meta: { producedFiles } }, + message: { + source: { type: 'tool-result', callId }, + content: [{ type: 'tool-result', content: images.map(attachment => ({ type: 'image', attachment })) }], + }, + }) + } + + it('carries the full image reference of a copy the producing result shares', () => { + const value = assembler([ + at(1, 'turn/start', { turn: 1 }), + call(2, 'crop', 'bash', { command: 'python crop.py', output_files: ['Rainbow_High_Set_of_6_Dolls.jpg'] }), + imageResult(3, 'crop', [{ path: 'Rainbow_High_Set_of_6_Dolls.jpg', created: true, attachmentId: rainbow.attachmentId }], [rainbow]), + ]) + expect(selectProducedFiles(tailOwner(deliverablesOf(value), 4))).toEqual([ + { path: 'Rainbow_High_Set_of_6_Dolls.jpg', created: true, counts: undefined, attachmentId: rainbow.attachmentId, image: rainbow }, + ]) + }) + + it('takes the reference from a later result of the Turn that shares the copy, as a desktop records it', () => { + const path = '/Users/elizabethtrejo/.aeven/chats/Rainbow_High_Set_of_6_Dolls.jpg' + const value = assembler([ + at(1, 'turn/start', { turn: 1 }), + call(2, 'crop', 'bash', { command: 'python crop.py', output_files: [path] }), + imageResult(3, 'crop', [{ path, created: true, attachmentId: rainbow.attachmentId }], []), + call(4, 'view', 'read_image', { path }), + imageResult(5, 'view', undefined, [rainbow]), + ]) + expect(selectProducedFiles(tailOwner(deliverablesOf(value), 6))?.[0]?.image).toEqual(rainbow) + }) + + const props = { + ensureWorkspacePathOpen: () => {}, revealFile: () => {}, previewFile: vi.fn().mockResolvedValue(true), openFile: vi.fn(), + fileUrl: (path: string) => `http://localhost/api/workspace-file?path=${path}`, + attachmentUrl: (id: string) => `http://localhost/api/attachment-file?id=${id}`, + isLoopback: false, useWorkspacePathOpen: vi.fn().mockReturnValue(true), t: vi.fn().mockImplementation((key: string) => key), + } + + it('draws a produced image through the conversation renderer, the way a generated image is drawn, not as a row', () => { + const renderImages = vi.fn().mockReturnValue() + const view = render() + + expect(renderImages).toHaveBeenCalledWith({ images: [{ attachment: rainbow }], align: 'start', layout: 'fill', turn: 3 }) + expect(view.getByTestId('rendered')).not.toBeNull() + expect(view.container.querySelector('[data-produced-images="1"] [data-orientation="portrait"]')).not.toBeNull() + expect(view.container.querySelector('[data-created-files]')).toBeNull() + }) + + it('shows an image without a reference from its stored copy, and returns it to its row only when the copy fails', () => { + const view = render() + const image = view.container.querySelector('img') + expect(image?.getAttribute('src')).toBe('http://localhost/api/attachment-file?id=sha256:3cd4812a') + expect(view.container.querySelector('[data-created-files]')).toBeNull() + + fireEvent.error(image as HTMLImageElement) + expect(view.container.querySelector('[data-created-files]')).not.toBeNull() + }) +}) + describe('producedFileMentions resolver', () => { const label = (path: string) => `打开 ${path}` @@ -542,7 +613,8 @@ describe('plugin registration', () => { injected.ensureWorkspacePathOpen() // The prose face is live while the plugin is: a produced turn yields a - // resolver whose matches open through the owner-supplied opener. + // resolver whose matches open the way the file's row does, in the Files + // sidebar first, so the owner's desktop opener is not reached here. const opened: string[] = [] const owner = tailOwner( produced([2, 'site/report.html']), @@ -552,7 +624,9 @@ describe('plugin registration', () => { const service = (ctx as unknown as { get(name: string): ChatFileMentions | undefined }).get('chatFileMentions') const mentions = service?.forClosing(owner, SessionId('s1')) mentions?.resolve('report.html')?.open() - expect(opened).toEqual(['site/report.html']) + await vi.waitFor(() => { expect(openSidebarFile).toHaveBeenCalledWith('s1', 'site/report.html') }) + expect(opened).toEqual([]) + openSidebarFile.mockClear() // A turn that produced nothing yields no vocabulary at all. expect(service?.forClosing(tailOwner(undefined, 2), SessionId('s1'))).toBeUndefined() // Path links resolve for any step, through the Session's own workspace route, diff --git a/packages/client/ui-deliverables/tsconfig.json b/packages/client/ui-deliverables/tsconfig.json index 666be7c3cb..3603fd15de 100644 --- a/packages/client/ui-deliverables/tsconfig.json +++ b/packages/client/ui-deliverables/tsconfig.json @@ -8,7 +8,9 @@ "src" ], "references": [ - { "path": "../ui-sidebar-files" }, + { + "path": "../ui-sidebar-files" + }, { "path": "../../api/remotes/tsconfig.client.json" }, @@ -44,6 +46,9 @@ }, { "path": "../../core/session" + }, + { + "path": "../../attachment/attachment" } ] } diff --git a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts index 457f066425..7b6d01f95e 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -234,7 +234,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.assistant-actions\', () => ctx.slots.register(\n { name: \'conversation.chat.assistant-actions\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:366', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:368', }, { key: 'conversation.chat.commandview', @@ -279,7 +279,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.commandview\', () => ctx.slots.register(\n { name: \'conversation.chat.commandview\', key: \'\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:354', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:356', }, { key: 'conversation.chat.node', @@ -352,7 +352,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.node\', () => ctx.slots.register(\n { name: \'conversation.chat.node\', key: \'\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:335', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:337', }, { key: 'conversation.chat.turnTail', @@ -369,10 +369,11 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ }, ], ownerProps: [ - '/** Owner currency of the completed-Turn extension chain. */\nexport interface TurnTailOwnerProps {\n turn: TurnLocation\n seq: number\n /** Session workspace root, when the session list row carries one; tails display paths relative to it. */\n cwd?: string | undefined\n openFile: OpenWorkspaceFile\n}', + '/** Owner currency of the completed-Turn extension chain. */\nexport interface TurnTailOwnerProps {\n turn: TurnLocation\n seq: number\n /** Session workspace root, when the session list row carries one; tails display paths relative to it. */\n cwd?: string | undefined\n openFile: OpenWorkspaceFile\n /** The conversation\'s image renderer, which draws an image the Turn produced the way a generated image is drawn. */\n renderImages?: RenderMessageImages | undefined\n}', ], ownerPropsReferences: [ 'OpenWorkspaceFile', + 'RenderMessageImages', 'TurnLocation', ], standardProps: [ @@ -398,7 +399,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.turnTail\', () => ctx.slots.register(\n { name: \'conversation.chat.turnTail\', select: owner => null },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:360', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:362', }, { key: 'conversation.chat.user-actions', @@ -453,7 +454,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.user-actions\', () => ctx.slots.register(\n { name: \'conversation.chat.user-actions\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:373', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:375', }, { key: 'conversation.composer', @@ -624,7 +625,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.details.tool\', () => ctx.slots.register(\n { name: \'conversation.details.tool\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:379', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:381', }, { key: 'conversation.hero.agentPreset', @@ -1173,7 +1174,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.message.images\', () => ctx.slots.register(\n { name: \'conversation.message.images\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-chat/src/client/contract/slots.ts:348', + source: 'packages/client/ui-chat/src/client/contract/slots.ts:350', }, { key: 'conversation.navigation.utilities', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c6d643e10c..f963835f24 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3541,6 +3541,9 @@ importers: '@aeven/api-session-controller': specifier: workspace:^ version: link:../../api/session-controller + '@aeven/attachment': + specifier: workspace:^ + version: link:../../attachment/attachment '@aeven/client-connection': specifier: workspace:^ version: link:../connection