Remove legacy orchestration and MCP aliases; reroute recursive pipeline API

This commit is contained in:
2026-02-23 16:02:20 -05:00
parent 62e2491cde
commit 1363bceecc
15 changed files with 88 additions and 102 deletions

View File

@@ -8,7 +8,6 @@ import { type ProjectContextPatch, type FileSystemProjectContextStore } from "./
import { PersonaRegistry } from "./persona-registry.js";
import {
FileSystemStateContextManager,
type SessionHistoryEntry,
} from "./state-context.js";
import type { ActorExecutionResult, ActorResultStatus } from "./pipeline.js";
@@ -56,14 +55,7 @@ export class PersistenceLifecycleObserver implements PipelineLifecycleObserver {
})
: {};
const legacyHistoryEvent: SessionHistoryEntry = {
nodeId: event.node.id,
event: event.result.status,
timestamp: new Date().toISOString(),
...(event.result.payload ? { data: event.result.payload } : {}),
};
const domainHistoryEvents: SessionHistoryEntry[] = event.domainEvents.map((domainEvent) => ({
const domainHistoryEvents = event.domainEvents.map((domainEvent) => ({
nodeId: event.node.id,
event: domainEvent.type,
timestamp: domainEvent.timestamp,
@@ -85,7 +77,6 @@ export class PersistenceLifecycleObserver implements PipelineLifecycleObserver {
...(event.result.stateMetadata ?? {}),
...behaviorPatch,
},
historyEvent: legacyHistoryEvent,
historyEvents: domainHistoryEvents,
});

View File

@@ -132,6 +132,25 @@ export type RecursiveRunOutput<TIntent extends RecursiveChildIntent, TOutput> =
| RecursiveCompleteResult<TOutput>
| RecursiveFanoutPlan<TIntent, TOutput>;
export type RecursiveRunInput<TIntent extends RecursiveChildIntent, TOutput> = {
sessionId: string;
depth: number;
signal?: AbortSignal;
run: (
input: RecursiveRunContext<TIntent>,
) => Promise<RecursiveRunOutput<TIntent, TOutput>> | RecursiveRunOutput<TIntent, TOutput>;
childMiddleware?: RecursiveChildMiddleware<TIntent>;
};
type SessionRecursiveRunInput<TIntent extends RecursiveChildIntent, TOutput> = Omit<
RecursiveRunInput<TIntent, TOutput>,
"sessionId"
>;
type SessionRecursiveRunner = <TIntent extends RecursiveChildIntent, TOutput>(
input: SessionRecursiveRunInput<TIntent, TOutput>,
) => Promise<TOutput>;
type RecursiveChildOutcome = { status: "success" } | { status: "failure"; error: Error };
export type RecursiveChildMiddleware<TIntent extends RecursiveChildIntent> = {
@@ -193,6 +212,7 @@ export class AgentSession {
constructor(
private readonly manager: AgentManager,
public readonly id: string,
private readonly recursiveRunner: SessionRecursiveRunner,
) {}
async runAgent<T>(input: {
@@ -211,6 +231,12 @@ export class AgentSession {
close(): void {
this.manager.closeSession(this.id);
}
async runRecursive<TIntent extends RecursiveChildIntent, TOutput>(
input: SessionRecursiveRunInput<TIntent, TOutput>,
): Promise<TOutput> {
return this.recursiveRunner(input);
}
}
export class AgentManager {
@@ -256,7 +282,12 @@ export class AgentManager {
this.sessions.get(parentSessionId)?.childSessionIds.add(sessionId);
}
return new AgentSession(this, sessionId);
return new AgentSession(this, sessionId, (input) =>
this.runRecursiveNode({
sessionId,
...input,
}),
);
}
closeSession(sessionId: string): void {
@@ -297,28 +328,6 @@ export class AgentManager {
}
}
/**
* @deprecated Prefer running recursive topologies through SchemaDrivenExecutionEngine.runSession.
* This method remains available for internal orchestration and low-level tests.
*/
async runRecursiveAgent<TIntent extends RecursiveChildIntent, TOutput>(input: {
sessionId: string;
depth: number;
signal?: AbortSignal;
run: (
input: RecursiveRunContext<TIntent>,
) => Promise<RecursiveRunOutput<TIntent, TOutput>> | RecursiveRunOutput<TIntent, TOutput>;
childMiddleware?: RecursiveChildMiddleware<TIntent>;
}): Promise<TOutput> {
return this.runRecursiveNode({
sessionId: input.sessionId,
depth: input.depth,
signal: input.signal,
run: input.run,
childMiddleware: input.childMiddleware,
});
}
getLimits(): AgentManagerLimits {
return { ...this.limits };
}

View File

@@ -65,13 +65,7 @@ export type PipelineNode = {
export type PipelineEdge = {
from: string;
to: string;
on?:
| "success"
| "validation_fail"
| "failure"
| "always"
| "onTaskComplete"
| "onValidationFail";
on?: "success" | "validation_fail" | "failure" | "always";
event?: DomainEventType;
when?: RouteCondition[];
};
@@ -278,8 +272,6 @@ function parsePipelineEdge(value: unknown): PipelineEdge {
"validation_fail",
"failure",
"always",
"onTaskComplete",
"onValidationFail",
];
const rawOn = value.on;

View File

@@ -164,12 +164,6 @@ function shouldEdgeRun(
if (edge.on === "failure" && status === "failure") {
return true;
}
if (edge.on === "onTaskComplete" && status === "success") {
return true;
}
if (edge.on === "onValidationFail" && status === "validation_fail") {
return true;
}
return false;
}
@@ -598,8 +592,7 @@ export class PipelineExecutor {
const maxRetriesForNode = this.getMaxRetriesForNode(node);
try {
const output = await this.options.manager.runRecursiveAgent<RetryIntent, NodeAttemptResult>({
sessionId: managerRunSessionId,
const output = await managerRunSession.runRecursive<RetryIntent, NodeAttemptResult>({
depth,
signal,
run: async ({ intent, depth: recursiveDepth, signal: recursiveSignal }) => {

View File

@@ -209,7 +209,6 @@ export class FileSystemStateContextManager {
patch: {
flags?: Record<string, boolean>;
metadata?: JsonObject;
historyEvent?: SessionHistoryEntry;
historyEvents?: SessionHistoryEntry[];
},
): Promise<StoredSessionState> {
@@ -221,9 +220,6 @@ export class FileSystemStateContextManager {
if (patch.metadata) {
Object.assign(current.metadata, patch.metadata);
}
if (patch.historyEvent) {
current.history.push(patch.historyEvent);
}
if (patch.historyEvents && patch.historyEvents.length > 0) {
current.history.push(...patch.historyEvents);
}