@usine/durable/harness
Classes
Section titled “Classes”DurableHarness
Section titled “DurableHarness”The orchestrator’s pi-durable Harness over one storage. A commit that fails after storage admission poisons the whole Session; the harness detects it, closes the Session, opens the storage again, and resumes its tasks. A step pi-durable keeps retrying without progress is handled the same way, and stops the harness for good when the reopened harness gets stuck again.
Extends
Section titled “Extends”Context.ServiceClass
Properties
Section titled “Properties”Service
Section titled “Service”
readonlyService:object
The service’s operations: what yield* DurableHarness returns.
defaultModel
Section titled “defaultModel”
readonlydefaultModel:Option.Option<ModelRef>
install
Section titled “install”
readonlyinstall: (extension) =>Effect.Effect<void>
Installs or replaces an extension; conversations that select it by name use the new code from their next phase.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
extension |
Extension |
Returns
Section titled “Returns”Effect.Effect<void>
models
Section titled “models”
readonlymodels:Models
resume
Section titled “resume”
readonlyresume: (beforeResume) =>Effect.Effect<void,DurableHarnessError>
Runs beforeResume on the open harness, then starts the task scheduler;
every reopen does both again. Call it once every extension is installed:
a generation resumed earlier would be prepared without the tools its
conversation selects.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
beforeResume |
BeforeResume |
Returns
Section titled “Returns”Effect.Effect<void, DurableHarnessError>
subscribe
Section titled “subscribe”
readonlysubscribe: (listener) =>Effect.Effect<void,never,Scope.Scope>
Observes commits, reopens, and the stop while the scope is open.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
HarnessListener |
Returns
Section titled “Returns”Effect.Effect<void, never, Scope.Scope>
readonlyuse: <A>(operation,run) =>Effect.Effect<A,DurableHarnessError>
Runs one call against the open harness. A call that fails because the Session was poisoned or replaced runs once more on the reopened harness, so it must be safe to repeat. Once the harness has stopped, every call fails with the reason it stopped.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
A |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
operation |
string |
run |
(harness, context) => Promise<A> |
Returns
Section titled “Returns”Effect.Effect<A, DurableHarnessError>
DurableHarnessError
Section titled “DurableHarnessError”A pi-durable call failed: the harness could not open, commit, read, or wait.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DurableHarnessError(…
args):DurableHarnessError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlycause:unknown
message
Section titled “message”
readonlymessage:string
operation
Section titled “operation”
readonlyoperation:string
Interfaces
Section titled “Interfaces”DurableHarnessOptions
Section titled “DurableHarnessOptions”What the harness runs on.
Properties
Section titled “Properties”defaultModel
Section titled “defaultModel”
readonlydefaultModel:Option<ModelRef>
The parent model when an Attempt names none; absent means the first model with a configured credential.
models
Section titled “models”
readonlymodels:Models
pi-ai model access for generation and parent model resolution.
openStorage
Section titled “openStorage”
readonlyopenStorage:Effect<Storage,DurableHarnessError>
Opens the storage; run again to reopen after a poisoned or stuck Session.
HarnessListener
Section titled “HarnessListener”Observes the open harness, across reopens.
Properties
Section titled “Properties”onCommit
Section titled “onCommit”
readonlyonCommit: (publication) =>void
Runs synchronously after every adopted commit; it must not block, throw, or call the harness.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
publication |
CommitPublication |
Returns
Section titled “Returns”void
onReopen
Section titled “onReopen”
readonlyonReopen: () =>void
Runs once a poisoned or stuck Session has been replaced by a freshly opened and resumed harness.
Returns
Section titled “Returns”void
onStop
Section titled “onStop”
readonlyonStop: () =>void
Runs once the harness has stopped for good; every later call fails with the reason.
Returns
Section titled “Returns”void
Type Aliases
Section titled “Type Aliases”BeforeResume
Section titled “BeforeResume”BeforeResume = (
harness) =>Effect.Effect<void>
Repairs storage through a freshly opened harness before its tasks run; it logs its own failures and never fails.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
harness |
Harness |
Returns
Section titled “Returns”Effect.Effect<void>
Variables
Section titled “Variables”durableError
Section titled “durableError”
constdurableError: (operation,cause) =>DurableHarnessError
Wraps a failed pi-durable call, naming what it was doing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
operation |
string |
cause |
unknown |
Returns
Section titled “Returns”
constlayer: (options) =>Layer.Layer<DurableHarness,DurableHarnessError>
Opens the harness for the layer’s lifetime; it is closed, without writing any task outcome, when the layer ends.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
DurableHarnessOptions |
Returns
Section titled “Returns”Layer.Layer<DurableHarness, DurableHarnessError>
StuckStepReports
Section titled “StuckStepReports”
constStuckStepReports:Context.Reference<number>
How many reports of one failure, with no commit adopted between them, mean pi-durable keeps retrying a step that cannot succeed. Its scheduler retries such a step at once, in microtasks, so until the harness closes the process runs no timer and no I/O. Provide another value to change it.