merge: integrate origin/main into feature/workflow-steps (FN-7039)
Resolve conflicts from 56 upstream commits: - db.ts: renumber my migrations around main's new migration 130 (columnDwellMs) — enable-id normalization 130→131, drop-table 131→132, SCHEMA_VERSION→132. - index.ts / routes.ts: take main's new MCP exports/imports; keep WORKFLOW_STEP_TEMPLATES array removed (kept the WorkflowStepTemplate type). - merger.ts: keep the legacy post-merge execution path removed (U7c) over main's version. - ci-workflow.test.ts (from main): add port-4040/process-supervisor allowlist markers to the gate-script assertions that reference the checker filenames (pre-existing self-match). Gate green (engine-core 299, ci-shape 62); boot smoke PASS; migration tests + typecheck clean.
This commit is contained in:
@@ -5142,6 +5142,21 @@ export function reorderAutomationSteps(id: string, stepIds: string[], options?:
|
||||
export interface RoutineRunResponse {
|
||||
routine: Routine;
|
||||
result: RoutineExecutionResult;
|
||||
liveRunId?: string;
|
||||
}
|
||||
|
||||
export type RoutineRunStreamEvent =
|
||||
| { type: "run"; runId?: string; scheduleId?: string; status?: string }
|
||||
| { type: "step"; runId?: string; stepIndex?: number; stepId?: string; stepName?: string; stepType?: string; status?: string; success?: boolean; error?: string }
|
||||
| { type: "output"; runId?: string; text?: string }
|
||||
| { type: "tool"; runId?: string; status?: string; name?: string; args?: unknown; isError?: boolean; result?: unknown }
|
||||
| { type: "complete"; runId?: string; result?: RoutineExecutionResult }
|
||||
| { type: "error"; runId?: string; message?: string; result?: RoutineExecutionResult };
|
||||
|
||||
export interface RoutineRunStreamHandlers {
|
||||
onEvent: (event: RoutineRunStreamEvent) => void;
|
||||
onConnectionStateChange?: (state: StreamConnectionState) => void;
|
||||
onFatalError?: (message: string) => void;
|
||||
}
|
||||
|
||||
export function fetchRoutines(options?: SchedulingScopeOptions): Promise<Routine[]> {
|
||||
@@ -5180,6 +5195,39 @@ export function runRoutine(id: string, options?: SchedulingScopeOptions): Promis
|
||||
});
|
||||
}
|
||||
|
||||
export function streamRoutineRun(id: string, handlers: RoutineRunStreamHandlers, options?: SchedulingScopeOptions & { runId?: string }) {
|
||||
const baseUrl = withSchedulingScope(`/routines/${id}/run/stream`, options);
|
||||
const separator = baseUrl.includes("?") ? "&" : "?";
|
||||
const url = options?.runId ? `${baseUrl}${separator}runId=${encodeURIComponent(options.runId)}` : baseUrl;
|
||||
const parse = (type: RoutineRunStreamEvent["type"], event: MessageEvent) => {
|
||||
let data: Record<string, unknown> = {};
|
||||
try {
|
||||
data = event.data ? JSON.parse(event.data) : {};
|
||||
} catch {
|
||||
data = { message: event.data };
|
||||
}
|
||||
handlers.onEvent({ type, ...data } as RoutineRunStreamEvent);
|
||||
};
|
||||
return createResilientEventSource(
|
||||
url,
|
||||
{
|
||||
events: {
|
||||
run: (event) => parse("run", event),
|
||||
step: (event) => parse("step", event),
|
||||
output: (event) => parse("output", event),
|
||||
tool: (event) => parse("tool", event),
|
||||
complete: (event) => parse("complete", event),
|
||||
error: (event) => parse("error", event),
|
||||
},
|
||||
},
|
||||
{
|
||||
maxReconnectAttempts: 2,
|
||||
onConnectionStateChange: handlers.onConnectionStateChange,
|
||||
onFatalError: handlers.onFatalError,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function fetchRoutineRuns(id: string, options?: SchedulingScopeOptions): Promise<RoutineExecutionResult[]> {
|
||||
return api<RoutineExecutionResult[]>(withSchedulingScope(`/routines/${id}/runs`, options));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user