Skip to main content
createHarnessRunLedger(ports, execute, options?): HarnessRunLedger
Parameters 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() is this.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’s queue().
  • The task’s id is the run’s task_id. Queueing the run again, as recover() does, leaves one pending task for it.
  • __telnyx_agent_harness_run names no method of the class, so the task reaches onTask(). The class overrides onTask() to hand it to dispatch().

HarnessRunLedger

Methods accept()
accept(input, options): Promise<HarnessRunAcceptance>
Parameters Returns Promise<HarnessRunAcceptance> cancel()
cancel(runId): Promise<HarnessRun | undefined>
Parameters Returns Promise<HarnessRun | undefined> dispatch()
dispatch(task): Promise<HarnessRun | undefined>
Execute one task emitted by accept() after validating its private harness envelope. Parameters Returns Promise<HarnessRun | undefined> get()
get(runId): Promise<HarnessRun | undefined>
Parameters Returns Promise<HarnessRun | undefined> list()
list(options?): Promise<readonly HarnessRun[]>
Parameters Returns Promise<readonly HarnessRun[]> recover()
recover(): Promise<number>
Re-enqueue accepted and interrupted runs. Recovery is at-least-once, never exactly-once. Returns Promise<number> run()
run(runId): Promise<HarnessRun | undefined>
Claim and execute an admitted run; host task handlers call this with their persistent run id. Parameters Returns Promise<HarnessRun | undefined> status()
status(runId): Promise<"accepted" | "running" | "awaiting_approval" | "resume_pending" | "completed" | "failed" | "canceled" | "outcome_unknown" | undefined>
Parameters Returns Promise<"accepted" | "running" | "awaiting_approval" | "resume_pending" | "completed" | "failed" | "canceled" | "outcome_unknown" | undefined>

HarnessRunLedgerOptions

Properties checkpoints?
readonly optional checkpoints?: HarnessCheckpoint
Deterministic test seam for crash-window recovery coverage. requireApprovalIdentity?
readonly optional requireApprovalIdentity?: boolean
Approval-capable harnesses bind admission to a host-attested subject.

HarnessCheckpoint

HarnessCheckpoint = (point) => void
Parameters Returns void

ensureHarnessDurabilitySchema()

ensureHarnessDurabilitySchema(ports): void
Parameters Returns void

HarnessInjectedCrash

Internal deterministic crash signal. It intentionally leaves persistent state at the interrupted boundary. Constructors Constructor
new HarnessInjectedCrash(cause): HarnessInjectedCrash
Parameters Returns HarnessInjectedCrash Properties cause?
optional cause?: unknown
message
message: string
name
name: string
stack?
optional stack?: string
stackTraceLimit
static stackTraceLimit: number
The 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()
static captureStackTrace(targetObject, constructorOpt?): void
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
The first line of the trace will be prefixed with ${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:
Parameters Returns void prepareStackTrace()
static prepareStackTrace(err, stackTraces): any
Parameters 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?
optional cause?: unknown
message
message: string
name
name: string
stack?
optional stack?: string
stackTraceLimit
static stackTraceLimit: number
The 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()
static captureStackTrace(targetObject, constructorOpt?): void
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
The first line of the trace will be prefixed with ${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:
Parameters Returns void prepareStackTrace()
static prepareStackTrace(err, stackTraces): any
Parameters Returns any See https://v8.dev/docs/stack-trace-api#customizing-stack-traces