当前状态:下文首段
zcodeTaskService.sendPrompt描述保留为 V4 前的故障背景; 当前实现以“V4 eager staging”一节和IPromptAttachmentTransferService为准。
WSL/SSH/Docker remote workspace 中,桌面 renderer 和 host 仍运行在本机,ZCode Agent runtime 运行在远端。ZCodePromptAttachment.localPath 过去只表达“一个本地路径”,没有说明这个路径属于 desktop host 还是 remote runtime。
这会让以下链路在 WSL remote 下断裂:
.zcode/tmp/paste-attachments/...,再把 Windows localPath 作为 file 附件发送。localPath。远端 agent 收到这些附件后,会在 remote runtime 的文件系统里 stat/read 该 localPath。WSL 中读取 C:\Users\... 或其他 host 路径会失败,因此表现为粘贴内容/附件不可读。
localPath。desktop host 包装远端 zcodeTaskService.sendPrompt 时,对 prompt 附件做 materialize:
attachments 中带 localPath 的附件。~/.zcode/tmp/prompt-attachments/<trace>/<random>/...。localPath,再调用远端 sendPrompt。sourceKind: "clipboard-text",长文本粘贴仍作为 deferred file reference,不提前塞入 prompt body。这只是边界修复。长期更完整的协议语义可以新增 attachment locality 字段,将 host-local、runtime-local、inline 三类来源显式编码。
V4 composer 不再等到点击发送才 materialize。选择 host-local 附件后,renderer 通过
IPromptAttachmentTransferService 立即请求承载当前 workspace scope 的 Local/Remote Host 暂存;服务按 operation id
发布连接级进度,并支持 cancel/cleanup。
renderer composer(Desktop continuous / Mobile shared-host replayable)
-> 当前窗口已有 Host attachment
├─ local:本地 transfer,localPath 零拷贝,staged=false
├─ SSH/WSL/Docker:attachment-scoped transfer
│ -> SourceServerConnectionManager 当前 generation 的文件传输能力
│ -> 同一 Transport Adapter / backend 的 exec + upload(progress, signal)
│ -> Source 用户私有 ~/.zcode/tmp/prompt-attachments/...,staged=true
└─ Server dev 直连:保持原 Source service;不开放 desktop localPath 暂存
attachment 关闭 / Source 换代 -> abort 未完成 operation + cleanup 未 adopt 文件
已 adopt -> CLI 已接受的 ref 生命周期,不由 attachment close 删除
根因:R3 移除旧 mixed service factory 时,也删掉了跨机 staging;全转发指向 Source 的
createLocalPromptAttachmentTransferService,它只会返回原 localPath 与 staged:false。
这是缺少文件系统边界转换,不能靠恢复本机 JWT、删除 composer 保护或伪造 staged 修复。
跨机 staging 由当前 Window Host 的 owning attachment 管理,不是 Source Core 可以直接执行的
普通业务 RPC。Host 暴露 attachment 时覆盖 IPromptAttachmentTransferService;RPC 合同中的
Source service 保留供 Source 本地路径语义使用。仅 SSH/WSL/Docker attachment 提供跨机能力。
Transport Adapter 只暴露窄 exec/upload 能力,复用已建立的 backend;Manager 将能力绑定当前
online connection,旧 generation 的新操作 fail-closed,不新建 SSH/WSL/Docker 连接或 Agent。
Source 的 Provider、JWT、文件/会话状态继续远端自持,不改为旧版混合权威。
Desktop 使用 continuous,手机仍只 attachment 已有 Host,粘贴临时文件沿同一 staging 合同; 内联字节继续走既有 V4 attachment transaction。staging 不改变 stream/queue/replay 语义。
身份隔离使用 workspaceKey = workspaceIdentity?.trim() || workspacePath;远程连接路由继续传递 remoteSessionId。
composer 判断附件是否必须远端物化时,对任意非空 workspaceIdentity 都按远端目标
fail closed,不要求 identity 已能被当前解析器识别;remoteSessionId 也直接证明目标是远端。
identity 已建立但 session id 尚未注入时,host-local 附件必须停在 waitingSession,待
session 就绪后再 stage;禁止非规范/新格式 identity 在注入窗口退化为本地 localPath 零复制。
SSH/WSL/Docker workspace 的 session service accessor 必须显式使用远端
promptAttachmentTransferService。不能从本地 baseServices 继承该服务,否则 eager stage
会在桌面本机完成并把 /Users/...、C:\Users\... 等 host path 原样交给远端 CLI。
远端 host-local 附件调用 stage 后必须得到 staged: true。staged: false 表示传输服务
没有跨越 host -> remote 文件系统边界,composer 必须 fail closed 并保持发送门禁,不能把返回
的 host path 包装成 ready AttachmentRef。
运行中暂存记录归承载该 workspace scope 的 Local/Remote Host 所有,relay/main 不维护镜像。
发送成功后将 staged file 标记为 adopted,供 runtime 在当前 session/queue 中读取;发送前删除或取消则立即清理。
未显式清理的 eager stage 由 24 小时 janitor 回收,避免 renderer 崩溃/断线遗留文件。
SSH SFTP 失败回落 exec pipe 时保留同一 operation id,进度不回退;WSL/Docker 也使用同一 progress/cancel 合同。
runtime 换代后未提交 ref 视为失效,renderer 按附件重试预算重新 stage;已进入 CLI queue/transcript 的 AttachmentRef 仍由 CLI 权威状态管理。
回归测试必须为本地、远端 accessor 注入不同的 transfer service 实例,并断言:
stage 返回 staged: false 并保留本机 localPath,
不调用 IRemoteBackend.upload。IRemoteBackend.upload。remoteSessionId
暂缺时,host-local 文件保持 waiting;id 注入后只调用远端 stage,不经过本地
attachmentPut/零复制路径。stage 返回 staged: false 时附件进入 permanent failed,prepareForSend 返回 null。desktop remote composer(renderer-local draft)
| workspaceIdentity=remote:*,remoteSessionId 暂缺
v
waitingSession --remoteSessionId ready--> queued/uploading
| |
| v
| remote transfer stage
| |
| staged:true | staged:false
| ready <-+-> permanent failed
| |
+-------------------------------------------+-> 禁止 sendText admission
mobile /remote
-> 继续 attachment 到桌面已有 shared host
-> 不创建新 runtime,不在 relay/main 保存附件状态
-> replayable 只恢复已 admission 的 conversation intent,不恢复 renderer-local 上传进度