mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-06 16:34:36 +00:00
fix(app): settle out-of-band submissions compatibly
This commit is contained in:
@@ -1952,19 +1952,12 @@ export class AgentManager {
|
||||
* emitted by the handler flow through dispatchStream so they persist and
|
||||
* broadcast like normal timeline events.
|
||||
*/
|
||||
tryRunOutOfBand(
|
||||
agentId: string,
|
||||
prompt: AgentPromptInput,
|
||||
runOptions?: AgentRunOptions,
|
||||
): boolean {
|
||||
tryRunOutOfBand(agentId: string, prompt: AgentPromptInput): boolean {
|
||||
const agent = this.requireSessionAgent(agentId);
|
||||
const handler = agent.session.tryHandleOutOfBand?.(prompt);
|
||||
if (!handler) {
|
||||
return false;
|
||||
}
|
||||
if (typeof prompt !== "string") {
|
||||
throw new Error("Out-of-band commands require a text prompt");
|
||||
}
|
||||
const dispatch = (event: AgentStreamEvent): void => {
|
||||
// Persist timeline items so they show up in fetchAgentTimeline; broadcast
|
||||
// for live subscribers. Other event types are broadcast only.
|
||||
@@ -1980,15 +1973,6 @@ export class AgentManager {
|
||||
}
|
||||
this.dispatchStream(agent.id, event, { timestamp: new Date().toISOString() });
|
||||
};
|
||||
dispatch({
|
||||
type: "timeline",
|
||||
provider: agent.provider,
|
||||
item: {
|
||||
type: "user_message",
|
||||
text: prompt,
|
||||
...(runOptions?.clientMessageId ? { clientMessageId: runOptions.clientMessageId } : {}),
|
||||
},
|
||||
});
|
||||
void (async () => {
|
||||
try {
|
||||
await handler.run({ emit: dispatch });
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function startAgentRun(
|
||||
// Out-of-band commands (e.g. /goal pause) must run WITHOUT canceling an
|
||||
// in-flight turn — replaceAgentRun would interrupt the running turn. The
|
||||
// intercept lives at this layer so it covers every prompt entrypoint.
|
||||
if (agentManager.tryRunOutOfBand(agentId, prompt, options?.runOptions)) {
|
||||
if (agentManager.tryRunOutOfBand(agentId, prompt)) {
|
||||
return { outOfBand: true };
|
||||
}
|
||||
const shouldReplace = Boolean(options?.replaceRunning && agentManager.hasInFlightRun(agentId));
|
||||
|
||||
@@ -6335,6 +6335,7 @@ export class Session {
|
||||
agentId,
|
||||
accepted: true,
|
||||
error: null,
|
||||
outOfBand: true,
|
||||
},
|
||||
});
|
||||
return;
|
||||
@@ -6362,6 +6363,7 @@ export class Session {
|
||||
agentId,
|
||||
accepted: true,
|
||||
error: null,
|
||||
outOfBand: false,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user