TaskRuntime
The service a running phase handler or abort handler uses to advance its task. It is provided to every handler and
is bound to that one invocation: once the invocation ends, its operations fail with InvocationEnded.
Since v0.0.0
ReadError (type alias)
Section titled “ReadError (type alias)”Failures of the runtime’s committed reads.
Signature
type ReadError = StorageFailure | SessionPoisoned | InvocationEndedSince v0.0.0
TaskRuntime (class)
Section titled “TaskRuntime (class)”Signature
declare class TaskRuntimeSince v0.0.0
TaskRuntimeShape (interface)
Section titled “TaskRuntimeShape (interface)”Signature
export interface TaskRuntimeShape { readonly taskId: TaskId readonly conversationId: ConversationId /** `run` for phase handlers; `abort` for the abort handler, which cannot wait. */ readonly mode: "run" | "abort" /** * Run `body` as one atomic commit with `Tx` provided. When it returns a `Next`, the task's state is replaced in * the same commit; returning nothing leaves it unchanged. */ readonly commit: <E, R>( body: Effect.Effect<Next<any, any> | void, E, R> ) => Effect.Effect<void, E | TaskCommitError, Exclude<R, Tx>> /** The memo's committed value, if any. */ readonly readMemo: (name: string) => Effect.Effect<Option.Option<Json>, InvocationEnded> /** First writer wins: stores `candidate` unless the memo exists; returns the durable winner. */ readonly memo: (name: string, candidate: Json) => Effect.Effect<Json, TaskCommitError> /** The committed task record. */ readonly getTask: (id: TaskId) => Effect.Effect<Option.Option<TaskRecord>, ReadError> /** Wait for a terminal receipt; for example, a child task that a tool created. */ readonly waitForTask: (id: TaskId) => Effect.Effect<TaskRecord, TaskNotFound | SchedulerClosed | ReadError> /** Outcomes of terminal tasks, in order. Used after a wait. */ readonly outcomes: ( ids: ReadonlyArray<TaskId> ) => Effect.Effect<ReadonlyArray<TaskOutcome>, TaskNotFound | TaskNotTerminal | ReadError> /** Wait until the clock reaches `until` (epoch milliseconds). Resumes correctly after a restart. */ readonly sleep: (until: number) => Effect.Effect<void, InvocationEnded> /** The clock, in epoch milliseconds. */ readonly now: Effect.Effect<number, InvocationEnded> /** * A handle bound to this invocation for an existing conversation, such as a subagent's; `None` when it does not * exist. See `ConversationHandle`. */ readonly conversation: (id: ConversationId) => Effect.Effect<Option.Option<ConversationHandle>, ReadError>}Since v0.0.0
commit
Section titled “commit”Signature
declare const commit: <E, R>(body: Effect.Effect<Next<any, any> | void, E, R>) => anySince v0.0.0
conversation
Section titled “conversation”An invocation-bound handle of an existing conversation; see TaskRuntimeShape.conversation.
Signature
declare const conversation: (id: ConversationId) => anySince v0.0.0
getTask
Section titled “getTask”Signature
declare const getTask: (id: TaskId) => anySince v0.0.0
Signature
declare const memo: (name: string, candidate: Json) => anySince v0.0.0
Signature
declare const now: Effect.Effect<number, InvocationEnded, TaskRuntime>Since v0.0.0
outcomes
Section titled “outcomes”Signature
declare const outcomes: (ids: ReadonlyArray<TaskId>) => anySince v0.0.0
readMemo
Section titled “readMemo”Signature
declare const readMemo: (name: string) => anySince v0.0.0
Signature
declare const sleep: (until: number) => anySince v0.0.0
taskId
Section titled “taskId”The id of the running task.
Signature
declare const taskId: Effect.Effect<any, never, TaskRuntime>Since v0.0.0
waitForTask
Section titled “waitForTask”Signature
declare const waitForTask: (id: TaskId) => anySince v0.0.0