/** * Messages: messages between conversations and the user, delivered as inputs or notes. Other extensions send one-way * messages and answer the user's open questions here. */ import type { Context } from '@earendil-works/chord' import { defineDoc } from '@earendil-works/pi-durable' import type { EntryId } from '@earendil-works/pi-durable' import { defineApi } from '../messages/compat.ts' import type { Device } from '../messages/compat.ts' import { MessagesDoc } from './refs.ts' import type { Question, Via } from './refs.ts' /** One message as the log stores it. */ export type Message = { id: number from: number | 'user' to: number | 'user' text: string at: number reply: boolean re?: number state: 'sent' | 'delivered' | 'answered' | 'dismissed' | 'failed' | 'stopped' entry?: EntryId answer?: EntryId error?: string /** The tool call that sent it: `message`'s or `branch`'s own id, `