Skip to navigation

visibleMessages

View as MarkdownOpen in Claude

A static method that returns the transcript a browser may redraw, and nothing else. The service’s log holds the substituted system prompt and the tool calls and results alongside the dialogue, so relaying it would publish your prompt to anyone with a handle.

Only user and assistant messages with non-blank text are kept. Each is reduced to role, content and, when the source message is dated, timestamp in epoch seconds, so a restored transcript isn’t shown as sent now. The gateway’s log method uses this before it answers, and lastActivity() reads the same log for the idle clock.

Parameters

messages
readonly unknown[] | null | undefinedRequired

Messages as log() returns them in messages.

Returns

Array<Record<string, unknown>> — the visible turns, in order.

Examples

import { AIChatClient, ChatGateway } from '@signalwire/sdk';
const client = new AIChatClient({ space: 'your-space' });
const log = await client.log('chat-8f21');
const transcript = ChatGateway.visibleMessages(log.messages);
for (const turn of transcript) {
console.log(`${String(turn.role)}: ${String(turn.content)}`);
}