AbortCoordinator (shared/abort-coordinator.ts)

agent-afk · src/agent/providers/shared/abort-coordinator.ts · typescript · Apache-2.0
ai

Provider-neutral abort coordinator encapsulating the single AbortController slot, pending-abort drain, and close-promise with compare-and-clear semantics.

// Source: https://github.com/griffinwork40/agent-afk | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Per-session abort coordination, shared by every provider's query
 * orchestrator (`anthropic-direct/query.ts`, `openai-compatible/query.ts`).
 *
 * Owns the single `AbortController | null` slot that represents "is a turn
 * (or compact) currently in flight?" and the deferred abort reason for the
 * case where `interrupt()` / `close()` arrives between turns (no controller
 * to fire yet). Also owns the `closedPromise` that the outer loop races
 * against `promptStream.next()` so `close()` unblocks a pending pull.
 *
 * Lives in `providers/shared/` for the same reason `tool-l

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key