Skip to content

Variable: MessageStorageNamespace

Makaio Framework


Makaio Framework / services-core/session/messages/namespace / MessageStorageNamespace

const MessageStorageNamespace: object

Defined in: ../../../packages/services/core/src/session/messages/namespace.ts:28

Message storage namespace with Drizzle extension.

Bus subjects are defined in @makaio/contracts (source of truth). This namespace extends the contracts definition with the Drizzle table schema so handlers can access the messages table.

readonly optional __filterPayload?: object

Phantom property for type extraction. Never accessed at runtime. Enables ExtractFilterPayload<T> to infer the FilterPayload type parameter without relying on complex nested generic inference.

adapterMessageId: string

adapterSessionId: never

after: never

agentId: never

blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]

contentText: string

emitEvent: never

includeAfter: never

limit: never

message: { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; } | { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId?: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }

{ adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }

optional adapterMessageId?: string

Adapter’s stable message identifier for fork detection

optional adapterSessionId?: string

Provider’s session ID for context continuity

optional agentId?: string

Agent ID (required for assistant, null for user)

blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]

Structured blocks (text, reasoning, tool_call, tool_output)

contentText: string

Plain text content for FTS5 search

optional editOf?: string

If this is an edit, references the original message

messageId: string

Unique message identifier

optional origin?: "text" | "voice" | "compact"

Origin of the message (e.g. ‘voice’, ‘text’). NULL for messages predating this field.

role: "user" | "assistant" = SessionMessageRoleSchema

Message role: ‘user’ or ‘assistant’

sessionId: string

Session this message belongs to

timestamp: number

Message timestamp (Unix ms)

turnId: string | null

Turn this message belongs to. NULL for native imports (no turn tracking).


{ adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId?: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }

optional adapterMessageId?: string

Adapter’s stable message identifier for fork detection

optional adapterSessionId?: string

Provider’s session ID for context continuity

optional agentId?: string

Agent ID (required for assistant, null for user)

blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: … | …; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]

Structured blocks (text, reasoning, tool_call, tool_output)

contentText: string

Plain text content for FTS5 search

optional editOf?: string

If this is an edit, references the original message

optional messageId?: string

optional origin?: "text" | "voice" | "compact"

Origin of the message (e.g. ‘voice’, ‘text’). NULL for messages predating this field.

role: "user" | "assistant" = SessionMessageRoleSchema

Message role: ‘user’ or ‘assistant’

sessionId: string

Session this message belongs to

timestamp: number

Message timestamp (Unix ms)

turnId: string | null

Turn this message belongs to. NULL for native imports (no turn tracking).

messageId: string

order: never

origin: never

query: string

role: "user" | "assistant"

sessionId: string

timestamp: number

turnId: string | null

readonly domain: "message"

Storage domain name (without ‘storage:’ prefix).

extensions: object

drizzle: object

messages: SQLiteTableWithColumns<{ columns: { adapterMessageId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "adapter_message_id"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; adapterSessionId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "adapter_session_id"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; agentId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "agent_id"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; blocks: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: true; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "blocks"; notNull: true; tableName: "messages"; }, { }, { length: number | undefined; }>; contentText: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "content_text"; notNull: true; tableName: "messages"; }, { }, { length: number | undefined; }>; editOf: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "edit_of"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; messageId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: true; name: "message_id"; notNull: true; tableName: "messages"; }, { }, { length: number | undefined; }>; origin: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: "text" | "voice" | "compact"; dataType: "string"; driverParam: string; enumValues: ["voice", "text", "compact"]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "origin"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; role: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: "user" | "assistant"; dataType: "string"; driverParam: string; enumValues: ["user", "assistant"]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "role"; notNull: true; tableName: "messages"; }, { }, { length: number | undefined; }>; sessionId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "session_id"; notNull: true; tableName: "messages"; }, { }, { length: number | undefined; }>; timestamp: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteInteger"; data: number; dataType: "number"; driverParam: number; enumValues: undefined; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "timestamp"; notNull: true; tableName: "messages"; }, { }, { }>; turnId: SQLiteColumn<{ baseColumn: never; columnType: "SQLiteText"; data: string; dataType: "string"; driverParam: string; enumValues: [string, ...string[]]; generated: undefined; hasDefault: false; hasRuntimeDefault: false; identity: undefined; isAutoincrement: false; isPrimaryKey: false; name: "turn_id"; notNull: false; tableName: "messages"; }, { }, { length: number | undefined; }>; }; dialect: "sqlite"; name: "messages"; schema: undefined; }>

Messages table schema.

The single source of truth for conversation content as consumed by Makaio (UI history, search, transforms, routing).

Design principles:

  • Messages are first-class entities, not embedded in events
  • Single source of truth for conversation content
  • Blocks stored as JSON for flexible structure
  • contentText extracted for FTS5 search
  • session_events tracks lifecycle (turns, branches) but not content

name: "storage:message"

subjects: BusSubjects<FlatSubjectDefinitions<"storage:message", { append: { request: ZodObject<{ emitEvent: ZodOptional<ZodBoolean>; message: ZodObject<{ adapterMessageId: ZodOptional<ZodString>; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<…, …>>; contentText: ZodString; editOf: ZodOptional<ZodString>; messageId: ZodOptional<ZodString>; origin: ZodOptional<ZodEnum<…>>; role: ZodEnum<{ assistant: …; user: …; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; }, $strip>; response: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<ZodString>; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<…, …>>; contentText: ZodString; editOf: ZodOptional<ZodString>; messageId: ZodString; origin: ZodOptional<ZodEnum<…>>; role: ZodEnum<{ assistant: …; user: …; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; }, $strip>; }; ftsSearch: { request: ZodObject<{ limit: ZodDefault<ZodOptional<ZodNumber>>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ results: ZodArray<ZodObject<{ excerpt: ZodString; messageId: ZodString; score: ZodNumber; sessionId: ZodString; }, $strip>>; total: ZodNumber; }, $strip>; }; get: { request: ZodObject<{ messageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>>; }, $strip>; }; getByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>>; }, $strip>; }; getBySession: { request: ZodObject<{ after: ZodOptional<ZodObject<{ messageId: ZodString; timestamp: ZodNumber; }, $strip>>; includeAfter: ZodOptional<ZodBoolean>; limit: ZodOptional<ZodNumber>; order: ZodOptional<ZodEnum<{ asc: "asc"; desc: "desc"; }>>; sessionId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>>; nextCursor: ZodNullable<ZodObject<{ messageId: ZodString; timestamp: ZodNumber; }, $strip>>; }, $strip>; }; getByTurn: { request: ZodObject<{ turnId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>>; }, $strip>; }; search: { request: ZodObject<{ limit: ZodOptional<ZodNumber>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>>; total: ZodNumber; }, $strip>; }; stored: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<ZodString>; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<[…, …, …, …], "type">>; contentText: ZodString; editOf: ZodOptional<ZodString>; messageId: ZodString; origin: ZodOptional<ZodEnum<{ compact: …; text: …; voice: …; }>>; role: ZodEnum<{ assistant: "assistant"; user: "user"; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; }, $strip>; upsertByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<[ZodObject<…, …>, ZodObject<…, …>, ZodObject<…, …>, ZodObject<…, …>], "type">>; contentText: ZodString; origin: ZodOptional<ZodEnum<{ compact: "compact"; text: "text"; voice: "voice"; }>>; role: ZodEnum<{ assistant: "assistant"; user: "user"; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; response: ZodObject<{ created: ZodBoolean; messageId: ZodString; }, $strip>; }; }>, "storage:message">

scopedBus(context?): Promise<ScopedBus<"storage:message", SubjectRecordFromSchemaRecord<{ append: { request: ZodObject<{ emitEvent: ZodOptional<ZodBoolean>; message: ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodOptional<…>; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>; }, $strip>; response: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>; }, $strip>; }; ftsSearch: { request: ZodObject<{ limit: ZodDefault<ZodOptional<ZodNumber>>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ results: ZodArray<ZodObject<{ excerpt: …; messageId: …; score: …; sessionId: …; }, $strip>>; total: ZodNumber; }, $strip>; }; get: { request: ZodObject<{ messageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; getByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; getBySession: { request: ZodObject<{ after: ZodOptional<ZodObject<{ messageId: …; timestamp: …; }, $strip>>; includeAfter: ZodOptional<ZodBoolean>; limit: ZodOptional<ZodNumber>; order: ZodOptional<ZodEnum<{ asc: …; desc: …; }>>; sessionId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; nextCursor: ZodNullable<ZodObject<{ messageId: …; timestamp: …; }, $strip>>; }, $strip>; }; getByTurn: { request: ZodObject<{ turnId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; search: { request: ZodObject<{ limit: ZodOptional<ZodNumber>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; total: ZodNumber; }, $strip>; }; stored: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<ZodString>; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<…, …>>; contentText: ZodString; editOf: ZodOptional<ZodString>; messageId: ZodString; origin: ZodOptional<ZodEnum<…>>; role: ZodEnum<{ assistant: …; user: …; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; }, $strip>; upsertByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<[…, …, …, …], "type">>; contentText: ZodString; origin: ZodOptional<ZodEnum<{ compact: …; text: …; voice: …; }>>; role: ZodEnum<{ assistant: "assistant"; user: "user"; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; response: ZodObject<{ created: ZodBoolean; messageId: ZodString; }, $strip>; }; }>, { adapterMessageId: string; adapterSessionId: never; after: never; agentId: never; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; emitEvent: never; includeAfter: never; limit: never; message: { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "image"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "attachment"; } | { content: string; metadata?: Record<…, …>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; } | { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "image"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "attachment"; } | { content: string; metadata?: Record<…, …>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId?: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }; messageId: string; order: never; origin: never; query: string; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }>>

MakaioBusContext

Promise<ScopedBus<"storage:message", SubjectRecordFromSchemaRecord<{ append: { request: ZodObject<{ emitEvent: ZodOptional<ZodBoolean>; message: ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodOptional<…>; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>; }, $strip>; response: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<…>; adapterSessionId: ZodOptional<…>; agentId: ZodOptional<…>; blocks: ZodArray<…>; contentText: ZodString; editOf: ZodOptional<…>; messageId: ZodString; origin: ZodOptional<…>; role: ZodEnum<…>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<…>; }, $strip>; }, $strip>; }; ftsSearch: { request: ZodObject<{ limit: ZodDefault<ZodOptional<ZodNumber>>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ results: ZodArray<ZodObject<{ excerpt: …; messageId: …; score: …; sessionId: …; }, $strip>>; total: ZodNumber; }, $strip>; }; get: { request: ZodObject<{ messageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; getByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; }, $strip>; response: ZodObject<{ message: ZodNullable<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; getBySession: { request: ZodObject<{ after: ZodOptional<ZodObject<{ messageId: …; timestamp: …; }, $strip>>; includeAfter: ZodOptional<ZodBoolean>; limit: ZodOptional<ZodNumber>; order: ZodOptional<ZodEnum<{ asc: …; desc: …; }>>; sessionId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; nextCursor: ZodNullable<ZodObject<{ messageId: …; timestamp: …; }, $strip>>; }, $strip>; }; getByTurn: { request: ZodObject<{ turnId: ZodString; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; }, $strip>; }; search: { request: ZodObject<{ limit: ZodOptional<ZodNumber>; query: ZodString; sessionId: ZodOptional<ZodString>; }, $strip>; response: ZodObject<{ messages: ZodArray<ZodObject<{ adapterMessageId: …; adapterSessionId: …; agentId: …; blocks: …; contentText: …; editOf: …; messageId: …; origin: …; role: …; sessionId: …; timestamp: …; turnId: …; }, $strip>>; total: ZodNumber; }, $strip>; }; stored: ZodObject<{ message: ZodObject<{ adapterMessageId: ZodOptional<ZodString>; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<…, …>>; contentText: ZodString; editOf: ZodOptional<ZodString>; messageId: ZodString; origin: ZodOptional<ZodEnum<…>>; role: ZodEnum<{ assistant: …; user: …; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; }, $strip>; upsertByAdapterMessageId: { request: ZodObject<{ adapterMessageId: ZodString; adapterSessionId: ZodOptional<ZodString>; agentId: ZodOptional<ZodString>; blocks: ZodArray<ZodDiscriminatedUnion<[…, …, …, …], "type">>; contentText: ZodString; origin: ZodOptional<ZodEnum<{ compact: …; text: …; voice: …; }>>; role: ZodEnum<{ assistant: "assistant"; user: "user"; }>; sessionId: ZodString; timestamp: ZodNumber; turnId: ZodNullable<ZodString>; }, $strip>; response: ZodObject<{ created: ZodBoolean; messageId: ZodString; }, $strip>; }; }>, { adapterMessageId: string; adapterSessionId: never; after: never; agentId: never; blocks: ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; emitEvent: never; includeAfter: never; limit: never; message: { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "image"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "attachment"; } | { content: string; metadata?: Record<…, …>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; } | { adapterMessageId?: string; adapterSessionId?: string; agentId?: string; blocks: ({ content: string; type: "text"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "image"; } | { source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: …; mimeType: …; type: …; } | { mimeType?: …; type: …; url: …; }; type: "attachment"; } | { content: string; metadata?: Record<…, …>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; contentText: string; editOf?: string; messageId?: string; origin?: "text" | "voice" | "compact"; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }; messageId: string; order: never; origin: never; query: string; role: "user" | "assistant"; sessionId: string; timestamp: number; turnId: string | null; }>>

import { MessageStorageNamespace, MessageStorageSubjects } from '@makaio/services-core/session';
// Use bus subjects
const { message } = await bus.request(MessageStorageSubjects.get, { messageId: '123' });
// Access drizzle schemas for custom queries
const { messages } = MessageStorageNamespace.extensions.drizzle;