Skip to content

Next

What a phase commits for its own task: the next checkpoint, a wait, or the task’s outcome. Returned from the body of TaskRuntime.commit.

import { type Ids, Next, TaskRuntime, Tx } from "@effective-harness/core"
import * as Effect from "effect/Effect"
declare const task: { readonly conversationId: Ids.ConversationId }
declare const receipt: { readonly id: string }
const program = Effect.gen(function* () {
yield* TaskRuntime.commit(
Effect.gen(function* () {
yield* Tx.appendEntry(task.conversationId, { kind: "app.receipt", data: receipt })
return Next.complete({ receipt: receipt.id })
})
)
})

Since v0.0.0


The task’s abort handler finished: the task ended aborted.

Signature

export interface Aborted<R> {
readonly _tag: "Aborted"
readonly reason?: string
readonly result?: R
}

Source

Since v0.0.0

The task finished with a result.

Signature

export interface Complete<R> {
readonly _tag: "Complete"
readonly result: R
}

Source

Since v0.0.0

Replace the checkpoint and keep running.

Signature

export interface Continue<C> {
readonly _tag: "Continue"
readonly checkpoint: C
}

Source

Since v0.0.0

The task finished with an error, and optionally a partial result.

Signature

export interface Fail<R> {
readonly _tag: "Fail"
readonly error: TaskOutcomeError
readonly result?: R
}

Source

Since v0.0.0

Signature

type Next<C = Json, R = Json> = Continue<C> | Wait<C> | Complete<R> | Fail<R> | Aborted<R>

Source

Since v0.0.0

Park the task without an invocation until every task in on is terminal, then resume at checkpoint.

Signature

export interface Wait<C> {
readonly _tag: "Wait"
readonly checkpoint: C
readonly on: ReadonlyArray<TaskId>
readonly policy: JoinPolicy
}

Source

Since v0.0.0

Finish aborted; the outcome of an abort handler.

Signature

declare const aborted: <R = never>(reason?: string, result?: R) => Aborted<R>

Source

Since v0.0.0

Finish with a result.

Signature

declare const complete: <R>(result: R) => Complete<R>

Source

Since v0.0.0

Replace the checkpoint and keep running.

Signature

declare const continue: <C>(checkpoint: C) => Continue<C>

Source

Since v0.0.0

Finish failed.

Signature

declare const fail: <R = never>(error: TaskOutcomeError | string, result?: R) => Fail<R>

Source

Since v0.0.0

Park until every task in on is terminal. failFast aborts the other tasks once one fails.

Signature

declare const wait: <C>(checkpoint: C, on: ReadonlyArray<TaskId>, policy: JoinPolicy) => Wait<C>

Source

Since v0.0.0