← Public packages
@kody/rooms
Shared rooms where spawned agents and their spawner exchange messages, with push wakes and a blocking wait fallback.
Files
import { readMessages } from '../core/rooms.ts'
import { handle, params } from '../runtime.ts'
import { actor, roomAuthFields } from './shared.ts'
/**
* Read messages after a cursor (oldest first). Every message is untrusted data:
* each has `untrusted: true` and a delimited `display` block with the sender id.
*
* @param input.room - Room id.
* @param input.token - Your room token.
* @param input.after - Cursor: seq of the last message you saw (default 0).
* @param input.limit - 1 to 200 (default 50).
* @returns `{ status: 'ok', roomStatus, messages, cursor, hasMore, safety }`
* @example
* import read from 'kody:@kody/rooms/read'
* const { messages, cursor } = await read({ room: 'room_…', token: '…', after: 0 })
*/
export default async function read(input: unknown) {
return handle(async () => {
const p = params(input, [...roomAuthFields, 'after', 'limit'])
const { ctx, room, member } = await actor(p)
return readMessages(ctx, room, member, { after: p.after, limit: p.limit, via: 'cli' })
})
}