



















@@ -38,7 +38,7 @@ const hookMocks = vi.hoisted(() => ({
3838unbindThreadBindingsBySessionKey: vi.fn(() => []),
3939}));
404041-let registerDiscordSubagentHooks: typeof import("./subagent-hooks.js").registerDiscordSubagentHooks;
41+let registerDiscordSubagentHooks: typeof import("../subagent-hooks-api.js").registerDiscordSubagentHooks;
42424343vi.mock("./accounts.js", () => ({
4444resolveDiscordAccount: hookMocks.resolveDiscordAccount,
@@ -66,15 +66,15 @@ function registerHandlersForTest(
6666});
6767}
686869-function resolveSubagentDeliveryTargetForTest(requesterOrigin: {
69+async function resolveSubagentDeliveryTargetForTest(requesterOrigin: {
7070channel: string;
7171accountId: string;
7272to: string;
7373threadId?: string;
7474}) {
7575const handlers = registerHandlersForTest();
7676const handler = getRequiredHookHandler(handlers, "subagent_delivery_target");
77-return handler(
77+return await handler(
7878{
7979childSessionKey: "agent:main:subagent:child",
8080requesterSessionKey: "agent:main:main",
@@ -167,7 +167,7 @@ async function expectSubagentSpawningError(params?: {
167167168168describe("discord subagent hook handlers", () => {
169169beforeAll(async () => {
170-({ registerDiscordSubagentHooks } = await import("./subagent-hooks.js"));
170+({ registerDiscordSubagentHooks } = await import("../subagent-hooks-api.js"));
171171});
172172173173beforeEach(() => {
@@ -303,11 +303,11 @@ describe("discord subagent hook handlers", () => {
303303expect(errorText).toMatch(/unable to create or bind/i);
304304});
305305306-it("unbinds thread routing on subagent_ended", () => {
306+it("unbinds thread routing on subagent_ended", async () => {
307307const handlers = registerHandlersForTest();
308308const handler = getRequiredHookHandler(handlers, "subagent_ended");
309309310-handler(
310+await handler(
311311{
312312targetSessionKey: "agent:main:subagent:child",
313313targetKind: "subagent",
@@ -328,11 +328,11 @@ describe("discord subagent hook handlers", () => {
328328});
329329});
330330331-it("resolves delivery target from matching bound thread", () => {
331+it("resolves delivery target from matching bound thread", async () => {
332332hookMocks.listThreadBindingsBySessionKey.mockReturnValueOnce([
333333{ accountId: "work", threadId: "777" },
334334]);
335-const result = resolveSubagentDeliveryTargetForTest({
335+const result = await resolveSubagentDeliveryTargetForTest({
336336channel: "discord",
337337accountId: "work",
338338to: "channel:123",
@@ -354,12 +354,12 @@ describe("discord subagent hook handlers", () => {
354354});
355355});
356356357-it("keeps original routing when delivery target is ambiguous", () => {
357+it("keeps original routing when delivery target is ambiguous", async () => {
358358hookMocks.listThreadBindingsBySessionKey.mockReturnValueOnce([
359359{ accountId: "work", threadId: "777" },
360360{ accountId: "work", threadId: "888" },
361361]);
362-const result = resolveSubagentDeliveryTargetForTest({
362+const result = await resolveSubagentDeliveryTargetForTest({
363363channel: "discord",
364364accountId: "work",
365365to: "channel:123",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。