refactor(plugin): use unified internal prompt dispatch
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+7
-4
@@ -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 { createTeamLeadOrphanHandler } from "../hooks/team-session-events/team-lead-orphan-handler";
|
||||||
import { createTeamMemberErrorHandler } from "../hooks/team-session-events/team-member-error-handler";
|
import { createTeamMemberErrorHandler } from "../hooks/team-session-events/team-member-error-handler";
|
||||||
import { createTeamMemberStatusHandler } from "../hooks/team-session-events/team-member-status-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 { CreatedHooks } from "../create-hooks";
|
||||||
import type { Managers } from "../create-managers";
|
import type { Managers } from "../create-managers";
|
||||||
@@ -510,7 +510,8 @@ export function createEventHandler(args: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof pluginContext.client.session.promptAsync === "function") {
|
if (typeof pluginContext.client.session.promptAsync === "function") {
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: pluginContext.client,
|
client: pluginContext.client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: `model-fallback:${source}`,
|
source: `model-fallback:${source}`,
|
||||||
@@ -527,7 +528,8 @@ export function createEventHandler(args: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const promptResult = await promptAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "sync",
|
||||||
client: pluginContext.client,
|
client: pluginContext.client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: `model-fallback:${source}:sync`,
|
source: `model-fallback:${source}:sync`,
|
||||||
@@ -942,7 +944,8 @@ export function createEventHandler(args: {
|
|||||||
log("[event] compaction before recovery continue failed:", { sessionID, error: err });
|
log("[event] compaction before recovery continue failed:", { sessionID, error: err });
|
||||||
});
|
});
|
||||||
|
|
||||||
const promptResult = await promptAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "sync",
|
||||||
client: pluginContext.client,
|
client: pluginContext.client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: "session-recovery:post-compaction-continue",
|
source: "session-recovery:post-compaction-continue",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { PluginContext } from "./types"
|
|||||||
|
|
||||||
import { createUnstableAgentBabysitterHook } from "../hooks"
|
import { createUnstableAgentBabysitterHook } from "../hooks"
|
||||||
import type { BackgroundManager } from "../features/background-agent"
|
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: {
|
export function createUnstableAgentBabysitter(args: {
|
||||||
ctx: PluginContext
|
ctx: PluginContext
|
||||||
@@ -27,7 +27,8 @@ export function createUnstableAgentBabysitter(args: {
|
|||||||
},
|
},
|
||||||
status: async () => ctx.client.session.status(),
|
status: async () => ctx.client.session.status(),
|
||||||
prompt: async (promptArgs) => {
|
prompt: async (promptArgs) => {
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: ctx.client,
|
client: ctx.client,
|
||||||
sessionID: promptArgs.path.id,
|
sessionID: promptArgs.path.id,
|
||||||
source: "unstable-agent-babysitter",
|
source: "unstable-agent-babysitter",
|
||||||
@@ -38,7 +39,8 @@ export function createUnstableAgentBabysitter(args: {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
promptAsync: async (promptArgs) => {
|
promptAsync: async (promptArgs) => {
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: ctx.client,
|
client: ctx.client,
|
||||||
sessionID: promptArgs.path.id,
|
sessionID: promptArgs.path.id,
|
||||||
source: "unstable-agent-babysitter",
|
source: "unstable-agent-babysitter",
|
||||||
|
|||||||
Reference in New Issue
Block a user