refactor(prompt-callers): migrate shared and cli 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:
@@ -13,7 +13,7 @@ import { loadAgentProfileColors } from "./agent-profile-colors"
|
|||||||
import { suppressRunInput } from "./stdin-suppression"
|
import { suppressRunInput } from "./stdin-suppression"
|
||||||
import { createTimestampedStdoutController } from "./timestamp-output"
|
import { createTimestampedStdoutController } from "./timestamp-output"
|
||||||
import { createCliPostHog, getPostHogDistinctId } from "../../shared/posthog"
|
import { createCliPostHog, getPostHogDistinctId } from "../../shared/posthog"
|
||||||
import { promptAsyncAfterSessionIdle } from "../../shared/prompt-async-gate"
|
import { dispatchInternalPrompt } from "../../shared/prompt-async-gate"
|
||||||
|
|
||||||
export { resolveRunAgent }
|
export { resolveRunAgent }
|
||||||
|
|
||||||
@@ -110,7 +110,8 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
() => {},
|
() => {},
|
||||||
)
|
)
|
||||||
|
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client,
|
client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: "cli-run",
|
source: "cli-run",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const { afterEach, describe, expect, test } = require("bun:test")
|
|||||||
import { injectContinuation } from "./continuation-injection"
|
import { injectContinuation } from "./continuation-injection"
|
||||||
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
|
import { OMO_INTERNAL_INITIATOR_MARKER } from "../../shared/internal-initiator-marker"
|
||||||
import {
|
import {
|
||||||
promptAsyncAfterSessionIdle,
|
dispatchInternalPrompt,
|
||||||
releaseAllPromptAsyncReservationsForTesting,
|
releaseAllPromptAsyncReservationsForTesting,
|
||||||
releasePromptAsyncReservation,
|
releasePromptAsyncReservation,
|
||||||
} from "../shared/prompt-async-gate"
|
} from "../shared/prompt-async-gate"
|
||||||
@@ -260,7 +260,8 @@ describe("injectContinuation", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when
|
// when
|
||||||
const peerMessageResult = await promptAsyncAfterSessionIdle({
|
const peerMessageResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client: ctx.client,
|
client: ctx.client,
|
||||||
sessionID,
|
sessionID,
|
||||||
source: "team-live-delivery",
|
source: "team-live-delivery",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import {
|
|||||||
type PromptRetryOptions,
|
type PromptRetryOptions,
|
||||||
} from "./prompt-timeout-context"
|
} from "./prompt-timeout-context"
|
||||||
import {
|
import {
|
||||||
promptAfterSessionIdle,
|
dispatchInternalPrompt,
|
||||||
promptAsyncAfterSessionIdle,
|
|
||||||
releasePromptAsyncReservation,
|
releasePromptAsyncReservation,
|
||||||
} from "./prompt-async-gate"
|
} from "./prompt-async-gate"
|
||||||
|
|
||||||
@@ -100,7 +99,8 @@ export async function promptWithModelSuggestionRetry(
|
|||||||
const timeoutContext = createPromptTimeoutContext(args, timeoutMs)
|
const timeoutContext = createPromptTimeoutContext(args, timeoutMs)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const promptResult = await promptAsyncAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "async",
|
||||||
client,
|
client,
|
||||||
sessionID: args.path.id,
|
sessionID: args.path.id,
|
||||||
input: {
|
input: {
|
||||||
@@ -140,7 +140,8 @@ export async function promptSyncWithModelSuggestionRetry(
|
|||||||
try {
|
try {
|
||||||
const timeoutContext = createPromptTimeoutContext(args, timeoutMs)
|
const timeoutContext = createPromptTimeoutContext(args, timeoutMs)
|
||||||
try {
|
try {
|
||||||
const promptResult = await promptAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "sync",
|
||||||
client,
|
client,
|
||||||
sessionID: args.path.id,
|
sessionID: args.path.id,
|
||||||
input: {
|
input: {
|
||||||
@@ -197,7 +198,8 @@ export async function promptSyncWithModelSuggestionRetry(
|
|||||||
|
|
||||||
const timeoutContext = createPromptTimeoutContext(retryArgs, timeoutMs)
|
const timeoutContext = createPromptTimeoutContext(retryArgs, timeoutMs)
|
||||||
try {
|
try {
|
||||||
const promptResult = await promptAfterSessionIdle({
|
const promptResult = await dispatchInternalPrompt({
|
||||||
|
mode: "sync",
|
||||||
client,
|
client,
|
||||||
sessionID: retryArgs.path.id,
|
sessionID: retryArgs.path.id,
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
promptSyncWithModelSuggestionRetry,
|
promptSyncWithModelSuggestionRetry,
|
||||||
promptWithModelSuggestionRetry,
|
promptWithModelSuggestionRetry,
|
||||||
} from "./model-suggestion-retry"
|
} from "./model-suggestion-retry"
|
||||||
import { promptAsyncAfterSessionIdle } from "./prompt-async-gate"
|
import { dispatchInternalPrompt } from "./prompt-async-gate"
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
|
|
||||||
@@ -59,7 +59,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