Skip to content

MessageSessionStoreShape

Defined in: packages/core/src/session/schema.ts:220

The service shape of a message session store.

readonly consistency: Consistency

Defined in: packages/core/src/session/schema.ts:225

strong stores provide compare-and-set; eventual stores (KV) do not and must not be used for concurrent writers.

acquire(id, owner, ttlMs): Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>

Defined in: packages/core/src/session/schema.ts:274

Acquires a short lease for one writer. Returns false when another owner holds an unexpired lease. Expired leases are taken over.

string

string

number

Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>


attachMessage(id, message): Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>

Defined in: packages/core/src/session/schema.ts:249

Attaches the platform message without changing the interaction version.

string

string = ...

string = ...

string = Schema.String

Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>


close(id): Effect<void, SessionStoreError | SessionNotFound>

Defined in: packages/core/src/session/schema.ts:256

Marks a session closed. Closing a closed session is a no-op.

string

Effect<void, SessionStoreError | SessionNotFound>


create(session): Effect<void, SessionStoreError | SessionAlreadyExists>

Defined in: packages/core/src/session/schema.ts:226

string = Schema.String

Application build fingerprint. Empty means “do not check”.

string = Schema.String

Registered component key, resolved by the platform integration.

number = Schema.Finite

boolean = Schema.Boolean

number = ...

string = Schema.String

string = ...

{ channelId?: string; guildId?: string; id: string; } = ...

string = ...

string = ...

string = Schema.String

unknown = Schema.Unknown

{[key: string]: unknown; } = ...

"closed" | "pending" | "active" = ...

number = Schema.Finite

number = Schema.Int

The state version the message on the platform shows. Bumped per interaction.

Effect<void, SessionStoreError | SessionAlreadyExists>


findByMessage(messageId): Effect<Option<string>, SessionStoreError>

Defined in: packages/core/src/session/schema.ts:254

The session that owns a platform message, if one is known.

string

Effect<Option<string>, SessionStoreError>


get(id): Effect<Option<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }>, SessionStoreError>

Defined in: packages/core/src/session/schema.ts:227

string

Effect<Option<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }>, SessionStoreError>


listActive(options?): Effect<SessionPage, SessionStoreError>

Defined in: packages/core/src/session/schema.ts:269

One bounded page of sessions a restart could resume eagerly, ordered by id. Pass the returned cursor back until it is absent.

SessionPageOptions

Effect<SessionPage, SessionStoreError>


release(id, owner): Effect<void, SessionStoreError>

Defined in: packages/core/src/session/schema.ts:286

Releases a lease only if owner still holds it.

string

string

Effect<void, SessionStoreError>


renew(id, owner, ttlMs): Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>

Defined in: packages/core/src/session/schema.ts:280

Extends an unexpired lease held by owner; false means it was lost.

string

string

number

Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>


setState(id, expectedVersion, state): Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>

Defined in: packages/core/src/session/schema.ts:243

Stores the first state and marks the session active without bumping the version.

string

number

State

Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>


sweep(now, options?): Effect<SessionSweepPage, SessionStoreError>

Defined in: packages/core/src/session/schema.ts:261

Removes one bounded page of closed and expired sessions, ordered by id. Pass the returned cursor back until it is absent.

number

SessionPageOptions

Effect<SessionSweepPage, SessionStoreError>


update(id, expectedVersion, update, leaseOwner?): Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>

Defined in: packages/core/src/session/schema.ts:232

Compares expectedVersion, applies update, bumps the version and returns the stored record. The callback must not mutate the record.

string

number

(session) => object

string

When set, the version check and the lease check commit together. A missing or foreign lease fails with SessionLeaseLost and does not write.

Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>