Skip to main content

Class: SqlOutbox

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:586

Durable outbound deliveries with retry backoff, manual replay and content scrubbing.

Implements​

Constructors​

Constructor​

new SqlOutbox(opts): SqlOutbox

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:591

Checks the adapter capabilities and prefix without creating tables.

Parameters​

opts​

SqlStoreOptions

Returns​

SqlOutbox

Methods​

cancel()​

cancel(runId, destinationRef): Promise<boolean>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:645

Ends every pending delivery of the run to the destination, their mail bodies emptied.

Parameters​

runId​

string

destinationRef​

string

Returns​

Promise<boolean>

Implementation of​

IOutbox.cancel


due()​

due(now, limit?): Promise<OutboxDelivery[]>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:608

Lists pending deliveries due at now, ordered by due time and id; a mail delivery past its expiry is left out.

Parameters​

now​

number

limit?​

number = 100

Returns​

Promise<OutboxDelivery[]>

Implementation of​

IOutbox.due


endExpired()​

endExpired(now): Promise<number>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:650

Ends every pending mail delivery whose expiry has passed, dead with its body emptied; the count ended.

Parameters​

now​

number

Returns​

Promise<number>

Implementation of​

IOutbox.endExpired


enqueue()​

enqueue(d, now): Promise<void>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:599

Enqueues once per delivery id, refusing new content behind the run's fence (a mail delivery is content).

Parameters​

d​

OutboxEnqueue

now​

number

Returns​

Promise<void>

Implementation of​

IOutbox.enqueue


holdUntil()​

holdUntil(id, notBefore): Promise<boolean>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:640

Moves a pending delivery's next attempt to notBefore, never earlier than it is, without counting an attempt.

Parameters​

id​

string

notBefore​

number

Returns​

Promise<boolean>

Implementation of​

IOutbox.holdUntil


listByRun()​

listByRun(runId): Promise<OutboxDelivery[]>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:672

Lists all deliveries of a run, including delivered and dead ones.

Parameters​

runId​

string

Returns​

Promise<OutboxDelivery[]>

Implementation of​

IOutbox.listByRun


markDead()​

markDead(id): Promise<boolean>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:635

Ends a pending delivery at once, a mail's body emptied; one no longer pending is left as it is.

Parameters​

id​

string

Returns​

Promise<boolean>

Implementation of​

IOutbox.markDead


markDelivered()​

markDelivered(id): Promise<void>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:612

Marks a delivery accepted by its destination; a mail's body goes with it, so it outlives no pending delivery.

Parameters​

id​

string

Returns​

Promise<void>

Implementation of​

IOutbox.markDelivered


markFailed()​

markFailed(id, now): Promise<void>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:616

Advances retry backoff, giving up a day after the first failed attempt. A delivery no longer pending (delivered, or given up) is left as it is.

Parameters​

id​

string

now​

number

Returns​

Promise<void>

Implementation of​

IOutbox.markFailed


purgeContent()​

purgeContent(runId): Promise<void>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:659

Fences new content and scrubs content deliveries, including delivered rows; content-free deliveries keep their type and payload. A send of the run that sendClaimed has under way in this process and that has not written its body yet stops.

Parameters​

runId​

string

Returns​

Promise<void>

Implementation of​

IOutbox.purgeContent


replay()​

replay(id, now): Promise<void>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:631

Resets attempts and makes a delivery due now without restoring any purged payload; a mail delivery is never replayed.

Parameters​

id​

string

now​

number

Returns​

Promise<void>

Implementation of​

IOutbox.replay


sendClaimed()​

sendClaimed(candidate, send): Promise<boolean>

Defined in: packages/agentos/src/io/channels/meetings/stores/sql.ts:685

Sends one delivery as the table holds it now, not as due returned it: one gone or no longer pending is skipped (false). The signal send gets aborts when this outbox's purgeContent purges the delivery's run, so a send that has not written its body yet stops (false); any other rejection is send's. A purge committed through another instance or process reaches a send only through the re-read, so the manager that purges and the dispatcher take the same SqlOutbox.

Parameters​

candidate​

OutboxDelivery

A delivery due returned.

send​

(fresh, signal) => Promise<void>

Sends the fresh copy under the signal.

Returns​

Promise<boolean>

Implementation of​

IOutbox.sendClaimed