



























@@ -21,6 +21,24 @@ const {
2121 wakeMusicGenerationTaskCompletion,
2222} = await import("./music-generate-background.js");
232324+function getDeliveredInternalEvents(): Array<Record<string, unknown>> {
25+const params = announceDeliveryMocks.deliverSubagentAnnouncement.mock.calls[0]?.[0] as
26+| { internalEvents?: unknown }
27+| undefined;
28+expect(params?.internalEvents).toBeTruthy();
29+if (!Array.isArray(params?.internalEvents)) {
30+throw new Error("Expected delivered internal events");
31+}
32+return params.internalEvents as Array<Record<string, unknown>>;
33+}
34+35+function expectReplyInstructionContains(text: string) {
36+const event = getDeliveredInternalEvents().find(
37+(item) => typeof item.replyInstruction === "string" && item.replyInstruction.includes(text),
38+);
39+expect(event).toBeDefined();
40+}
41+2442describe("music generate background helpers", () => {
2543beforeEach(() => {
2644resetMediaBackgroundMocks({
@@ -45,11 +63,13 @@ describe("music generate background helpers", () => {
4563providerId: "google",
4664});
476548-expect(handle).toMatchObject({
49-taskId: "task-123",
50-requesterSessionKey: "agent:main:discord:direct:123",
51-taskLabel: "night-drive synthwave",
52-});
66+expect(handle).not.toBeNull();
67+if (!handle) {
68+throw new Error("Expected music generation task handle");
69+}
70+expect(handle.taskId).toBe("task-123");
71+expect(handle.requesterSessionKey).toBe("agent:main:discord:direct:123");
72+expect(handle.taskLabel).toBe("night-drive synthwave");
5373expectQueuedTaskRun({
5474 taskExecutorMocks,
5575taskKind: MUSIC_GENERATION_TASK_KIND,
@@ -115,28 +135,8 @@ describe("music generate background helpers", () => {
115135},
116136});
117137118-expect(announceDeliveryMocks.deliverSubagentAnnouncement).toHaveBeenCalledWith(
119-expect.objectContaining({
120-internalEvents: expect.arrayContaining([
121-expect.objectContaining({
122-replyInstruction: expect.stringContaining(
123-"the user will NOT see your normal assistant final reply",
124-),
125-}),
126-]),
127-}),
128-);
129-expect(announceDeliveryMocks.deliverSubagentAnnouncement).toHaveBeenCalledWith(
130-expect.objectContaining({
131-internalEvents: expect.arrayContaining([
132-expect.objectContaining({
133-replyInstruction: expect.stringContaining(
134-"Do not put MEDIA: lines only in your final answer",
135-),
136-}),
137-]),
138-}),
139-);
138+expectReplyInstructionContains("the user will NOT see your normal assistant final reply");
139+expectReplyInstructionContains("Do not put MEDIA: lines only in your final answer");
140140});
141141142142it("queues a completion event when direct send is enabled globally", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。