From dd3fecaf40bf4d7b144dde7d9da0d4117b7d873b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 17 May 2026 17:01:50 +0900 Subject: [PATCH] refactor(plugin): use unified internal prompt dispatch Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/plugin/event.ts | 11 +++++++---- src/plugin/unstable-agent-babysitter.ts | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugin/event.ts b/src/plugin/event.ts index 6c5cd1254..d14936726 100644 --- a/src/plugin/event.ts +++ b/src/plugin/event.ts @@ -43,7 +43,7 @@ import { buildTeamIdleWakeHintClient } from "./build-team-idle-wake-hint-client" import { createTeamLeadOrphanHandler } from "../hooks/team-session-events/team-lead-orphan-handler"; import { createTeamMemberErrorHandler } from "../hooks/team-session-events/team-member-error-handler"; import { createTeamMemberStatusHandler } from "../hooks/team-session-events/team-member-status-handler"; -import { promptAfterSessionIdle, promptAsyncAfterSessionIdle, releasePromptAsyncReservation } from "../hooks/shared/prompt-async-gate"; +import { dispatchInternalPrompt, releasePromptAsyncReservation } from "../hooks/shared/prompt-async-gate"; import type { CreatedHooks } from "../create-hooks"; import type { Managers } from "../create-managers"; @@ -510,7 +510,8 @@ export function createEventHandler(args: { }; if (typeof pluginContext.client.session.promptAsync === "function") { - const promptResult = await promptAsyncAfterSessionIdle({ + const promptResult = await dispatchInternalPrompt({ + mode: "async", client: pluginContext.client, sessionID, source: `model-fallback:${source}`, @@ -527,7 +528,8 @@ export function createEventHandler(args: { return; } - const promptResult = await promptAfterSessionIdle({ + const promptResult = await dispatchInternalPrompt({ + mode: "sync", client: pluginContext.client, sessionID, source: `model-fallback:${source}:sync`, @@ -942,7 +944,8 @@ export function createEventHandler(args: { log("[event] compaction before recovery continue failed:", { sessionID, error: err }); }); - const promptResult = await promptAfterSessionIdle({ + const promptResult = await dispatchInternalPrompt({ + mode: "sync", client: pluginContext.client, sessionID, source: "session-recovery:post-compaction-continue", diff --git a/src/plugin/unstable-agent-babysitter.ts b/src/plugin/unstable-agent-babysitter.ts index 040c26d21..5cfe2d555 100644 --- a/src/plugin/unstable-agent-babysitter.ts +++ b/src/plugin/unstable-agent-babysitter.ts @@ -3,7 +3,7 @@ import type { PluginContext } from "./types" import { createUnstableAgentBabysitterHook } from "../hooks" import type { BackgroundManager } from "../features/background-agent" -import { promptAsyncAfterSessionIdle } from "../hooks/shared/prompt-async-gate" +import { dispatchInternalPrompt } from "../hooks/shared/prompt-async-gate" export function createUnstableAgentBabysitter(args: { ctx: PluginContext @@ -27,7 +27,8 @@ export function createUnstableAgentBabysitter(args: { }, status: async () => ctx.client.session.status(), prompt: async (promptArgs) => { - const promptResult = await promptAsyncAfterSessionIdle({ + const promptResult = await dispatchInternalPrompt({ + mode: "async", client: ctx.client, sessionID: promptArgs.path.id, source: "unstable-agent-babysitter", @@ -38,7 +39,8 @@ export function createUnstableAgentBabysitter(args: { } }, promptAsync: async (promptArgs) => { - const promptResult = await promptAsyncAfterSessionIdle({ + const promptResult = await dispatchInternalPrompt({ + mode: "async", client: ctx.client, sessionID: promptArgs.path.id, source: "unstable-agent-babysitter",