Concurrency-limited scheduler for workflow tasks with abort and timeout support.
// Source: https://github.com/Firstp1ck/pi-coding-agent-forge | License: MIT | Copyright 2026 Firstpick
// Provided via justclaw.it.com; keep this notice with the code.
import { WorkflowCancelledError, WorkflowError } from "./errors.ts";
import { HARD_MAX_CONCURRENCY } from "./schema.ts";
export type WorkflowSchedulerSnapshot = {
maxConcurrency: number;
active: number;
queued: number;
pausedRuns: string[];
};
export type WorkflowScheduleOptions = {
signal?: AbortSignal;
timeoutMs?: number;
runId?: string;
callId?: string;
};
type Waiter = {
resolve: (release: () => void) => void;
reject: (error: unknown) => void;
signal?: AbortSignal;
runId?: string;
onAbort?: () => void;
};
export class WorkflowAgentScheduler {
readonly maxConcurrency: number;
#active = 0
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key