refactor(background-agent): 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:
@@ -6,7 +6,7 @@ import {
|
|||||||
clearAllDelegatedChildSessionBootstrap,
|
clearAllDelegatedChildSessionBootstrap,
|
||||||
getDelegatedChildSessionBootstrap,
|
getDelegatedChildSessionBootstrap,
|
||||||
} from "../../shared/delegated-child-session-bootstrap"
|
} from "../../shared/delegated-child-session-bootstrap"
|
||||||
import { promptAsyncAfterSessionIdle } from "../../shared/prompt-async-gate"
|
import { dispatchInternalPrompt } from "../../shared/prompt-async-gate"
|
||||||
import { clearSessionPromptParams, getSessionPromptParams } from "../../shared/session-prompt-params-state"
|
import { clearSessionPromptParams, getSessionPromptParams } from "../../shared/session-prompt-params-state"
|
||||||
import {
|
import {
|
||||||
getSessionAgent,
|
getSessionAgent,
|
||||||
@@ -2516,7 +2516,8 @@ describe("BackgroundManager.resume promptAsync gate state", () => {
|
|||||||
abort: async () => ({}),
|
abort: async () => ({}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await promptAsyncAfterSessionIdle({
|
await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client,
|
client,
|
||||||
sessionID: "session-reserved-resume",
|
sessionID: "session-reserved-resume",
|
||||||
source: "test-existing-reservation",
|
source: "test-existing-reservation",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { PluginInput } from "@opencode-ai/plugin"
|
|||||||
import type { BackgroundTaskConfig, TmuxConfig } from "../../config/schema"
|
import type { BackgroundTaskConfig, TmuxConfig } from "../../config/schema"
|
||||||
import { setContinuationMarkerSource } from "../../features/run-continuation-state"
|
import { setContinuationMarkerSource } from "../../features/run-continuation-state"
|
||||||
import type { ModelFallbackControllerAccessor } from "../../hooks/model-fallback"
|
import type { ModelFallbackControllerAccessor } from "../../hooks/model-fallback"
|
||||||
import { type PromptAsyncGateResult, promptAsyncAfterSessionIdle } from "../../hooks/shared/prompt-async-gate"
|
import { dispatchInternalPrompt, type PromptAsyncGateResult } from "../../hooks/shared/prompt-async-gate"
|
||||||
import { isSessionActive as isOpenCodeSessionActive } from "../../hooks/shared/session-idle-settle"
|
import { isSessionActive as isOpenCodeSessionActive } from "../../hooks/shared/session-idle-settle"
|
||||||
import {
|
import {
|
||||||
createInternalAgentTextPart,
|
createInternalAgentTextPart,
|
||||||
@@ -1290,7 +1290,8 @@ The fallback retry session is now created and can be inspected directly.
|
|||||||
applySessionPromptParams(existingTask.sessionId!, existingTask.model)
|
applySessionPromptParams(existingTask.sessionId!, existingTask.model)
|
||||||
}
|
}
|
||||||
|
|
||||||
promptAsyncAfterSessionIdle({
|
dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: this.client,
|
client: this.client,
|
||||||
sessionID: existingTask.sessionId,
|
sessionID: existingTask.sessionId,
|
||||||
source: "background-agent-resume",
|
source: "background-agent-resume",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { resolveRegisteredAgentName } from "../claude-code-session-state"
|
import { resolveRegisteredAgentName } from "../claude-code-session-state"
|
||||||
import { createInternalAgentTextPart, log, messagesInDirectory, normalizeSDKResponse } from "../../shared"
|
import { createInternalAgentTextPart, log, messagesInDirectory, normalizeSDKResponse } from "../../shared"
|
||||||
import { isSessionActive as isOpenCodeSessionActive, settleAfterSessionIdle } from "../../hooks/shared/session-idle-settle"
|
import { isSessionActive as isOpenCodeSessionActive, settleAfterSessionIdle } from "../../hooks/shared/session-idle-settle"
|
||||||
import { promptAsyncAfterSessionIdle } from "../../hooks/shared/prompt-async-gate"
|
import { dispatchInternalPrompt } from "../../hooks/shared/prompt-async-gate"
|
||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
@@ -137,7 +137,8 @@ export class ParentWakeNotifier {
|
|||||||
const notificationContent = latestWake.notifications.join("\n\n")
|
const notificationContent = latestWake.notifications.join("\n\n")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: this.deps.client,
|
client: this.deps.client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: "background-agent-parent-wake",
|
source: "background-agent-parent-wake",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
|
|
||||||
import { promptWithModelSuggestionRetry } from "../../shared"
|
import { promptWithModelSuggestionRetry } from "../../shared"
|
||||||
import { promptAsyncAfterSessionIdle } from "../../shared/prompt-async-gate"
|
import { dispatchInternalPrompt } from "../../shared/prompt-async-gate"
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
|
|
||||||
@@ -35,7 +35,8 @@ export function promptAsyncInDirectory(
|
|||||||
return Promise.reject(new Error("session id is required for routed promptAsync"))
|
return Promise.reject(new Error("session id is required for routed promptAsync"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return promptAsyncAfterSessionIdle({
|
return dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client,
|
client,
|
||||||
sessionID,
|
sessionID,
|
||||||
input: routedArgs,
|
input: routedArgs,
|
||||||
|
|||||||
Reference in New Issue
Block a user