Add RPC subagent subscriptions
This commit is contained in:
@@ -162,6 +162,7 @@ export interface ExecutorOptions {
|
||||
description?: string;
|
||||
index: number;
|
||||
id: string;
|
||||
parentToolCallId?: string;
|
||||
modelOverride?: string | string[];
|
||||
/**
|
||||
* Active model selector of the parent session, used as an auth-aware fallback
|
||||
@@ -840,6 +841,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
agent: agent.name,
|
||||
agentSource: agent.source,
|
||||
task,
|
||||
parentToolCallId: options.parentToolCallId,
|
||||
assignment,
|
||||
progress: { ...progress },
|
||||
sessionFile: subtaskSessionFile,
|
||||
@@ -922,20 +924,23 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
progress.recentOutput = [];
|
||||
};
|
||||
|
||||
const emitSubagentEvent = (event: AgentSessionEvent) => {
|
||||
if (!options.eventBus) return;
|
||||
options.eventBus.emit(TASK_SUBAGENT_EVENT_CHANNEL, {
|
||||
id,
|
||||
index,
|
||||
agent: agent.name,
|
||||
agentSource: agent.source,
|
||||
task,
|
||||
assignment,
|
||||
sessionFile: subtaskSessionFile,
|
||||
event,
|
||||
parentToolCallId: options.parentToolCallId,
|
||||
});
|
||||
};
|
||||
|
||||
const processEvent = (event: AgentEvent) => {
|
||||
if (resolved) return;
|
||||
|
||||
if (options.eventBus) {
|
||||
options.eventBus.emit(TASK_SUBAGENT_EVENT_CHANNEL, {
|
||||
index,
|
||||
agent: agent.name,
|
||||
agentSource: agent.source,
|
||||
task,
|
||||
assignment,
|
||||
event,
|
||||
});
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
let flushProgress = false;
|
||||
|
||||
@@ -1354,6 +1359,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
options.eventBus.emit(TASK_SUBAGENT_LIFECYCLE_CHANNEL, {
|
||||
id,
|
||||
agent: agent.name,
|
||||
parentToolCallId: options.parentToolCallId,
|
||||
agentSource: agent.source,
|
||||
description: options.description,
|
||||
status: "started",
|
||||
@@ -1452,6 +1458,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
|
||||
const MAX_YIELD_RETRIES = 3;
|
||||
unsubscribe = session.subscribe(event => {
|
||||
emitSubagentEvent(event);
|
||||
if (event.type === "auto_retry_start") {
|
||||
progress.retryState = {
|
||||
attempt: event.attempt,
|
||||
@@ -1704,6 +1711,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
options.eventBus.emit(TASK_SUBAGENT_LIFECYCLE_CHANNEL, {
|
||||
id,
|
||||
agent: agent.name,
|
||||
parentToolCallId: options.parentToolCallId,
|
||||
agentSource: agent.source,
|
||||
description: options.description,
|
||||
status: progress.status as "completed" | "failed" | "aborted",
|
||||
|
||||
Reference in New Issue
Block a user