/** * Cancel a specific in-flight completion by `requestId`. * * `completion(...)` exposes a stable `requestId` (UUIDv4, generated * client-side) on the returned `CompletionRun`. Pass it to * `cancel({ requestId })` to abort that exact run without affecting any * other inference happening on the same model. * * Two cancel paths exist: * * 1. `cancel({ requestId })` — targeted cancel, the primary path * introduced in 0.11.0. The `requestId` is available synchronously * on the `CompletionRun`. Same-tick cancels (issued before the * server has registered the request) are recorded and applied * retroactively when `begin(...)` arrives, so they aren't silently * dropped. * 2. `cancel({ operation: "inference", modelId })` — broad cancel * (escape hatch, kept indefinitely). Cancels every inference running * on the model. Useful for unload, app shutdown, admin sweeps when * the caller doesn't have a `requestId` to hand. * * --- Cancel outcomes (0.11.0+) --- * * A cancel surfaces on two channels: * * - `run.events` ends *normally* with a `completionDone` event carrying * `stopReason: "cancelled"`. The loop exits cleanly, no thrown error. * - `run.text` / `run.final` / `run.stats` / `run.toolCalls` reject * with `InferenceCancelledError(requestId, partial)`, where `partial` * holds whatever the model produced before the cancel landed * (accumulated `text`, completed `toolCalls`, last-known `stats`). * * Pick the channel that matches how you consume the run: event-loop * consumers don't need to catch anything; promise-aggregate consumers * pattern-match on `instanceof InferenceCancelledError`. */ export {}; //# sourceMappingURL=cancel-by-request-id.d.ts.map