













@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
22import os from "node:os";
33import path from "node:path";
44import { beforeEach, describe, expect, it, vi } from "vitest";
5+import { getReplyPayloadMetadata, setReplyPayloadMetadata } from "../reply-payload.js";
5667const ensureSandboxWorkspaceForSession = vi.hoisted(() => vi.fn());
78const resolveOutboundAttachmentFromUrl = vi.hoisted(() => vi.fn());
@@ -108,6 +109,39 @@ describe("createReplyMediaPathNormalizer", () => {
108109expect(mediaAccess.workspaceDir).toBe("/tmp/agent-workspace");
109110});
110111112+it("preserves reply metadata when media normalization clones the payload", async () => {
113+const normalize = createReplyMediaPathNormalizer({
114+cfg: {},
115+sessionKey: "session-key",
116+workspaceDir: "/tmp/agent-workspace",
117+});
118+const payload = setReplyPayloadMetadata(
119+{
120+text: "Here is the image",
121+mediaUrls: ["./out/photo.png"],
122+},
123+{
124+sourceReplyTranscriptMirror: {
125+sessionKey: "main",
126+text: "Here is the image",
127+mediaUrls: ["./out/photo.png"],
128+idempotencyKey: "source-reply:0",
129+},
130+},
131+);
132+133+const result = await normalize(payload);
134+135+expect(result).not.toBe(payload);
136+expectMedia(result, "/tmp/outbound-media/photo.png", ["/tmp/outbound-media/photo.png"]);
137+expect(getReplyPayloadMetadata(result)?.sourceReplyTranscriptMirror).toEqual({
138+sessionKey: "main",
139+text: "Here is the image",
140+mediaUrls: ["./out/photo.png"],
141+idempotencyKey: "source-reply:0",
142+});
143+});
144+111145it("maps sandbox-relative media back to the host sandbox workspace before staging", async () => {
112146ensureSandboxWorkspaceForSession.mockResolvedValue({
113147workspaceDir: "/tmp/sandboxes/session-1",
此內容由慣性聚合(RSS閱讀器)自動聚合整理,僅供閱讀參考。 原文來自 — 版權歸原作者所有。