Skip to content
providerkit
GitHub

BackgroundWorker

Defined in: agents/src/runs.ts:51

Minimum worker capabilities. Server 0.19/0.20 remain valid in best-effort mode, including their child callbacks; only awaited mode needs append.

  • Pick<Run, | "id" | "owner" | "input" | "checkpoint" | "resumed" | "crashes" | "signal" | "save" | "emit">
optional append?: (events) => Promise<void>;

Defined in: agents/src/runs.ts:55

Parameter Type
events readonly object[]

Promise<void>


readonly checkpoint: unknown;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:142

The last save before the worker died, under restart: "resume". null otherwise.

Pick.checkpoint

readonly crashes: number;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:146

How many times a dead worker’s run was taken over, this time included.

Pick.crashes

readonly id: string;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:138

Pick.id

readonly input: unknown;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:140

Pick.input

readonly owner: string;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:139

Pick.owner

readonly resumed: boolean;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:144

True when this run was started before: a worker died, or a drain put it back.

Pick.resumed

readonly signal: AbortSignal;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:151

Aborts when the run must stop. Its reason is a RunStopped saying why: lost (another worker took the run over), cancelled or shutdown. Pass it to every provider call.

Pick.signal
child<T>(
key,
spec,
fn
): Promise<ChildResult<T>>;

Defined in: agents/src/runs.ts:56

Type Parameter
T
Parameter Type
key string
spec ChildSpec
fn (run) => Promise<T>

Promise<ChildResult<T>>


emit(type, data?): void;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:174

Appends an event for tail, and returns at once. Appends run in order behind it, and the run does not finish before they do. One that fails goes to onError; it never throws.

Parameter Type
type string
data? unknown

void

Pick.emit

save(state): Promise<void>;

Defined in: node_modules/.bun/@[email protected]+19b32ddeae23987b/node_modules/@gusnips/server/dist/runs/index.d.ts:156

Keeps state as the checkpoint a resumed run starts from. Throws once this worker no longer holds the run.

Parameter Type
state unknown

Promise<void>

Pick.save