fix(prompt-gate): share message reservations
This commit is contained in:
+23
-9
@@ -13,6 +13,7 @@ import { loadAgentProfileColors } from "./agent-profile-colors"
|
||||
import { suppressRunInput } from "./stdin-suppression"
|
||||
import { createTimestampedStdoutController } from "./timestamp-output"
|
||||
import { createCliPostHog, getPostHogDistinctId } from "../../shared/posthog"
|
||||
import { promptAsyncAfterSessionIdle } from "../../shared/prompt-async-gate"
|
||||
|
||||
export { resolveRunAgent }
|
||||
|
||||
@@ -109,18 +110,31 @@ export async function run(options: RunOptions): Promise<number> {
|
||||
() => {},
|
||||
)
|
||||
|
||||
await client.session.promptAsync({
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: resolvedAgent,
|
||||
...(resolvedModel ? { model: resolvedModel } : {}),
|
||||
tools: {
|
||||
question: false,
|
||||
const promptResult = await promptAsyncAfterSessionIdle({
|
||||
client,
|
||||
sessionID,
|
||||
source: "cli-run",
|
||||
settleMs: 0,
|
||||
postDispatchHoldMs: 0,
|
||||
input: {
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: resolvedAgent,
|
||||
...(resolvedModel ? { model: resolvedModel } : {}),
|
||||
tools: {
|
||||
question: false,
|
||||
},
|
||||
parts: [{ type: "text", text: message }],
|
||||
},
|
||||
parts: [{ type: "text", text: message }],
|
||||
query: { directory },
|
||||
},
|
||||
query: { directory },
|
||||
})
|
||||
if (promptResult.status === "failed") {
|
||||
throw promptResult.error
|
||||
}
|
||||
if (promptResult.status !== "dispatched") {
|
||||
throw new Error(`Session ${sessionID} is not idle; promptAsync skipped by gate: ${promptResult.status}`)
|
||||
}
|
||||
const exitCode = await pollForCompletion(ctx, eventState, abortController)
|
||||
|
||||
abortController.abort()
|
||||
|
||||
Reference in New Issue
Block a user