Files
dashlibstorage/API.modelmessage.md
2026-10-05 23:57:01 +02:00

57 lines
1.7 KiB
Markdown

# modelmessage
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `modelmessage.add`
*Source: `src/store/modelmessage/add.js`*
Appends a message to one of the user's own conversations. `user` messages are refused unless the conversation state is `idle`; other roles ('assistant', 'system', 'tool', 'reasoning') touch `updated_at` unconditionally.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `conversationId` | `number` | The conversation id. |
| `input` | `object` | Message input. |
| `input.message` | `string` | Message text. |
| `[input.role='user']` | `'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'` | Message role. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>`
**Throws**
`Error` — 'Conversation not found', 'Conversation is not idle', 'Message required', 'Invalid role'.
## `modelmessage.list`
*Source: `src/store/modelmessage/list.js`*
Lists messages of one of the user's own conversations, oldest first.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `conversationId` | `number` | The conversation id. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<Array<{id: number, conversation_id: number, created_at: string, role: string, message: string}>>`
**Throws**
`Error` — 'Conversation not found' if missing or owned by another user.
**Example**
```js
const messages = await store.modelmessage.list(42, 7);
```