Skip to main content

DurableWorkerDeps

@retinue/monorepo


@retinue/monorepo / backend/src / DurableWorkerDeps

Type Alias: DurableWorkerDeps

DurableWorkerDeps = object

Defined in: backend/src/runtime/worker.ts:76

Properties​

buildContext​

readonly buildContext: (run) => ExecutionContext | Promise<ExecutionContext>

Defined in: backend/src/runtime/worker.ts:87

Host builds the execution context; identity never comes from model output.

Parameters​

run​

Run

Returns​

ExecutionContext | Promise<ExecutionContext>


channelFor?​

readonly optional channelFor?: (run) => string

Defined in: backend/src/runtime/worker.ts:96

Realtime channel for a run's events. Defaults to conversation:<id>.

Parameters​

run​

Run

Returns​

string


checkpoints​

readonly checkpoints: CheckpointStore

Defined in: backend/src/runtime/worker.ts:78


clock?​

readonly optional clock?: () => string

Defined in: backend/src/runtime/worker.ts:91

Returns​

string


concurrencyFor?​

readonly optional concurrencyFor?: (tenantId) => Promise<number | undefined> | number | undefined

Defined in: backend/src/runtime/worker.ts:133

The tenant's concurrent-run limit, or undefined for unlimited — REQ-058 (#246), task #265.

A function rather than a value, for the reason RateLimitGuardDeps.policyFor gives: limits are per tenant and change without a redeploy, and a value captured at construction would be the limits of whoever booted the process.

Absent or non-positive means unlimited, which is the branch that matters on the day this ships. A deployment upgrading into the feature with nothing configured must keep working; the alternative is an outage caused by adding a safety feature, which is how safety features get removed.

Parameters​

tenantId​

Run["tenantId"]

Returns​

Promise<number | undefined> | number | undefined


deferralBackoffMs?​

readonly optional deferralBackoffMs?: number

Defined in: backend/src/runtime/worker.ts:141

How long a deferred run waits before its next attempt. Default one second.

Not zero, and not the lease length. Zero spins a worker against the cap, burning capacity on the check itself; a full lease is longer than most runs, so a freed slot would sit idle. A second is short enough that a slot is picked up promptly and long enough that the retry is not the load.


engine​

readonly engine: AgentEngine

Defined in: backend/src/runtime/worker.ts:80


eventLog?​

readonly optional eventLog?: RunEventLog

Defined in: backend/src/runtime/worker.ts:82

Durable per-run event log for reconnect catch-up. Optional but required for gap-free reconnect.


keepaliveEveryMs?​

readonly optional keepaliveEveryMs?: number

Defined in: backend/src/runtime/worker.ts:94


leaseMs?​

readonly optional leaseMs?: number

Defined in: backend/src/runtime/worker.ts:93


locks?​

readonly optional locks?: DistributedLockStore

Defined in: backend/src/runtime/worker.ts:90

Optional belt-and-suspenders mutual exclusion around the atomic claim.


messages?​

readonly optional messages?: MessageStore

Defined in: backend/src/runtime/worker.ts:109

Records the assistant's turn when a run reaches a terminal state — #157.

Optional, because a host that reads history from the event log instead does not need it. Supply it and the next run's loadHistory sees what the assistant said; leave it out and the agent has amnesia between runs unless the host reconstructs the turn itself. That reconstruction was the gap: MessageStore was read-only, so the user's turn was persisted and the assistant's never was, and every host had to fold the event log to paper over the asymmetry.

Writes are idempotent on a message id derived from the run id, so a resumed run that completes after a restart records one turn, not two.


now?​

readonly optional now?: () => number

Defined in: backend/src/runtime/worker.ts:92

Returns​

number


onRunSettled?​

readonly optional onRunSettled?: (input) => Promise<void> | void

Defined in: backend/src/runtime/worker.ts:142

Parameters​

input​
context​

ExecutionContext

outcome​

"completed" | "failed" | "cancelled"

run​

Run

Returns​

Promise<void> | void


publisher​

readonly publisher: RealtimePublisher

Defined in: backend/src/runtime/worker.ts:79


runs​

readonly runs: RunStore

Defined in: backend/src/runtime/worker.ts:77


usage?​

readonly optional usage?: UsageRecorder

Defined in: backend/src/runtime/worker.ts:85

Records durable usage per realized step (doc 12). Recorded as usage is realized, so a later failure never loses the usage already consumed — and idempotently, so recovery never double-counts.


workerId​

readonly workerId: string

Defined in: backend/src/runtime/worker.ts:88