/** Provider-neutral clock used by requests, activities, workflows, and tests. */ export interface Clock { /** Return the current absolute instant. */ now(): Temporal.Instant; } /** * Serializable identity and timing data for one operation context. * * A snapshot can cross a queue, process, or Worker message. Cancellation does * not cross with it. The receiving host creates a new local `AbortSignal`. */ export interface Snapshot { /** Stable identity of the operation represented by this context. */ readonly id: string; readonly traceId?: string; readonly deploymentId?: string; readonly idempotencyKey?: string; readonly startedAt: string; readonly deadline?: string; } /** * Cancellation, deadline, identity, and clock carried through one operation. * * `id` names the current operation. The caller decides what the operation is, * such as an HTTP request, activity job, queue claim, workflow run, or process * command. Protocol-specific code can keep a more specific name such as * `requestId` and copy that value into `id` when it creates the context. */ export interface Context { /** Stable identity of the operation represented by this context. */ readonly id: string; readonly traceId?: string; readonly deploymentId?: string; readonly idempotencyKey?: string; readonly startedAt: Temporal.Instant; readonly deadline?: Temporal.Instant | undefined; readonly signal: AbortSignal; readonly clock: Clock; } /** Standard resource ownership operations available on one owned context. */ export interface Resources { /** Add an already disposable value to this context's lifetime. */ use(value: Value): Value; /** Add an arbitrary value with an explicit asynchronous or synchronous disposer. */ adopt(value: Value, dispose: (value: Value) => void | PromiseLike): Value; /** Add cleanup that runs when this context closes. */ defer(dispose: () => void | PromiseLike): void; } /** Independently owned context with deterministic cancellation and resource cleanup. */ export interface Owned extends Context, Resources, AsyncDisposable { /** Resolves after the context and every resource it owns have been disposed. */ readonly closed: Promise; } /** Inputs accepted while creating one owned operation context. */ export interface CreateOptions { /** Stable identity of the operation represented by the new context. */ readonly id: string; readonly traceId?: string; readonly deploymentId?: string; readonly idempotencyKey?: string; readonly startedAt?: Temporal.Instant; readonly deadline?: Temporal.Instant; readonly signal?: AbortSignal; readonly clock?: Clock; } /** Inputs accepted while deriving a child context. */ export interface ChildOptions extends Partial> { /** Override the inherited operation identity for a new nested operation. */ readonly id?: string; } /** Inputs accepted while restoring a serializable snapshot. */ export interface RestoreOptions { readonly signal?: AbortSignal; readonly clock?: Clock; }