Defined in: packages/ai/src/stream-to-response.ts:803
Everything the resume helpers need to take a run over as a side effect of serving its log.
claim and pipe are injected, not imported. The two mechanisms a takeover needs (withRunClaim and pipeToRunLog) live in @tanstack/ai-sandbox, and @tanstack/ai must not depend on that package — that layering inversion is exactly what moving LockStore into core was meant to prevent, and it would make core depend on the sandbox package to serve a plain chat run. Injecting them keeps only the shape of a takeover in core (parse the run id, read the record, skip if terminal, claim, drive) and lets a background-worker-driven run supply its own pair. @tanstack/ai-sandbox's sandboxRunDriver fills both in.
claim: <T>(input, fn) => Promise<T>;Defined in: packages/ai/src/stream-to-response.ts:815
Run fn under exclusive ownership of the run, or reject if refused.
T
LockStore
string
(claim) => Promise<T>
Promise<T>
drive: (input) => AsyncIterable<AGUIEvent>;Defined in: packages/ai/src/stream-to-response.ts:809
Produce the run's remaining events. Called only once the claim is held.
string
AbortSignal
string
AsyncIterable<AGUIEvent>
locks: LockStore;Defined in: packages/ai/src/stream-to-response.ts:807
optional logger?: InternalLogger;Defined in: packages/ai/src/stream-to-response.ts:830
pipe: (stream, input) => Promise<unknown>;Defined in: packages/ai/src/stream-to-response.ts:824
Persist the driven stream to the run's producer-side durability log.
AsyncIterable<AGUIEvent>
string
AbortSignal
string
Promise<unknown>
request: Request;Defined in: packages/ai/src/stream-to-response.ts:805
The attach request; its run id is read with resolveResumeRunId.
runs: RunStore;Defined in: packages/ai/src/stream-to-response.ts:806
optional waitUntil?: (promise) => void;Defined in: packages/ai/src/stream-to-response.ts:829
Platform keep-alive (e.g. ctx.waitUntil) for the background drive.
Promise<unknown>
void