createHarnessRunLedger(Parametersports,execute,options?):HarnessRunLedger
Returns
HarnessRunLedger
On the Agent Runtime
The ledger records each run in the SQL port. It executes each run in a task of the tasks port.ports.sql.exec()runs on the instance’s own SQLite database,this.ctx.storage.sql.ports.sql.transactionSync()isthis.ctx.storage.transactionSync(). The schema is created and migrated in one such transaction. A migration that throws is rolled back whole.- The ledger’s tables share the database with any table the class creates. Their names begin with
__telnyx_agent_harness_.
accept()queues the run’s task after the run’s row commits, through the class’squeue().- The task’s
idis the run’stask_id. Queueing the run again, asrecover()does, leaves one pending task for it. __telnyx_agent_harness_runnames no method of the class, so the task reachesonTask(). The class overridesonTask()to hand it todispatch().
HarnessRunLedger
Methods accept()accept(Parametersinput,options):Promise<HarnessRunAcceptance>
Returns
Promise<HarnessRunAcceptance>
cancel()
cancel(ParametersrunId):Promise<HarnessRun|undefined>
Returns
Promise<HarnessRun | undefined>
dispatch()
dispatch(Execute one task emitted bytask):Promise<HarnessRun|undefined>
accept() after validating its private harness envelope.
Parameters
Returns
Promise<HarnessRun | undefined>
get()
get(ParametersrunId):Promise<HarnessRun|undefined>
Returns
Promise<HarnessRun | undefined>
list()
list(Parametersoptions?):Promise<readonlyHarnessRun[]>
Returns
Promise<readonly HarnessRun[]>
recover()
recover():Re-enqueue accepted and interrupted runs. Recovery is at-least-once, never exactly-once. ReturnsPromise<number>
Promise<number>
run()
run(Claim and execute an admitted run; host task handlers call this with their persistent run id. ParametersrunId):Promise<HarnessRun|undefined>
Returns
Promise<HarnessRun | undefined>
status()
status(ParametersrunId):Promise<"accepted"|"running"|"awaiting_approval"|"resume_pending"|"completed"|"failed"|"canceled"|"outcome_unknown"|undefined>
Returns
Promise<"accepted" | "running" | "awaiting_approval" | "resume_pending" | "completed" | "failed" | "canceled" | "outcome_unknown" | undefined>
HarnessRunLedgerOptions
Properties checkpoints?Deterministic test seam for crash-window recovery coverage. requireApprovalIdentity?readonlyoptionalcheckpoints?:HarnessCheckpoint
Approval-capable harnesses bind admission to a host-attested subject.readonlyoptionalrequireApprovalIdentity?:boolean
HarnessCheckpoint
HarnessCheckpoint = (Parameterspoint) =>void
Returns
void
ensureHarnessDurabilitySchema()
ensureHarnessDurabilitySchema(Parametersports):void
Returns
void
HarnessInjectedCrash
Internal deterministic crash signal. It intentionally leaves persistent state at the interrupted boundary. Constructors Constructornew HarnessInjectedCrash(Parameterscause):HarnessInjectedCrash
Returns
HarnessInjectedCrash
Properties
cause?
messageoptionalcause?:unknown
message: string
name
name: string
stack?
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
HarnessApprovalPause
Internal control signal: approval state was persistently recorded before pausing. Constructors Constructor
new HarnessApprovalPause(): HarnessApprovalPause
Returns
HarnessApprovalPause
Properties
cause?
messageoptionalcause?:unknown
message: string
name
name: string
stack?
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces