Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
type OrchestrationV2ProviderTurn,
type OrchestrationV2RuntimeRequest,
type OrchestrationV2Subagent,
type OrchestrationV2SubagentActivation,
type OrchestrationV2TurnItem,
type OrchestrationV2UserInputQuestion,
type ProviderApprovalDecision,
Expand Down Expand Up @@ -66,6 +67,7 @@ import {
makeSubagentConversationArtifacts,
subagentThreadTitle,
} from "../SubagentProjection.ts";
import { defaultSubagentRole, subagentActivationId } from "../SubagentObservability.ts";
import {
ProviderAdapterEnsureThreadError,
ProviderAdapterForkThreadError,
Expand Down Expand Up @@ -1926,6 +1928,12 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
const turnItemOrdinal =
existing?.turnItemOrdinal ?? (yield* resolveItemOrdinal(context, nativeTaskId));
const taskStatus = update.status;
const activationId = subagentActivationId(nodeId, 1);
const settled =
taskStatus === "completed" ||
taskStatus === "failed" ||
taskStatus === "cancelled" ||
taskStatus === "interrupted";
const task: OrchestrationV2Subagent = {
...(existing?.task ?? {
id: nodeId,
Expand All @@ -1942,12 +1950,21 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
prompt: update.prompt,
title: update.title,
model: update.model,
kind: "subagent" as const,
role: defaultSubagentRole(),
result: null,
usage: null,
currentActivationId: activationId,
activationCount: 1,
workflow: null,
workflowMembership: null,
recentActivity: [],
startedAt: now,
}),
status: taskStatus,
result: existing?.assistantText || update.result,
completedAt: taskStatus === "running" ? null : now,
currentActivationId: settled ? null : activationId,
completedAt: settled ? (existing?.task.completedAt ?? now) : null,
updatedAt: now,
};
const subagent: ActiveAcpSubagent = existing ?? {
Expand Down Expand Up @@ -2065,7 +2082,7 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
...subagent.task,
status: taskStatus,
result,
completedAt: taskStatus === "running" ? null : now,
completedAt: settled ? (subagent.task.completedAt ?? now) : null,
updatedAt: now,
};
const providerThreadId = subagent.task.providerThreadId;
Expand Down Expand Up @@ -2112,6 +2129,23 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
},
});
yield* emitProviderEvent({ type: "subagent.updated", driver, subagent: subagent.task });
yield* emitProviderEvent({
type: "subagent_activation.updated",
driver,
activation: {
id: activationId,
threadId: subagent.task.threadId,
subagentId: subagent.task.id,
runId: subagent.task.runId,
providerTurnId: subagent.providerTurnId,
ordinal: 1,
status: taskStatus,
usage: null,
startedAt: subagent.task.startedAt,
completedAt: settled ? now : null,
updatedAt: now,
} satisfies OrchestrationV2SubagentActivation,
});
yield* emitProviderEvent({
type: "turn_item.updated",
driver,
Expand Down
Loading
Loading