This commit is contained in:
seb
2026-10-05 23:57:01 +02:00
parent 191a0b29e2
commit 86ce3a3316
5 changed files with 6 additions and 6 deletions

2
API.md
View File

@@ -292,7 +292,7 @@ The store is exposed as a `LibDashStore` instance (see `src/index.js`). Each met
- `list(googleAuthId: number, tx?: object): Promise<Array<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>>` - `list(googleAuthId: number, tx?: object): Promise<Array<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>>`
- `setState(googleAuthId: number, conversationId: number, state: string, tx?: object): Promise<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>` - `setState(googleAuthId: number, conversationId: number, state: string, tx?: object): Promise<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>`
- [modelmessage](API.modelmessage.md) - [modelmessage](API.modelmessage.md)
- `add(googleAuthId: number, conversationId: number, input: {message: string, role?: 'user'|'assistant'|'system'|'tool'|'reasoning'}, tx?: object): Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>` - `add(googleAuthId: number, conversationId: number, input: {message: string, role?: 'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'}, tx?: object): Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>`
- `list(googleAuthId: number, conversationId: number, tx?: object): Promise<Array<{id: number, conversation_id: number, created_at: string, role: string, message: string}>>` - `list(googleAuthId: number, conversationId: number, tx?: object): Promise<Array<{id: number, conversation_id: number, created_at: string, role: string, message: string}>>`
- [modelvfs](API.modelvfs.md) - [modelvfs](API.modelvfs.md)
- `delete(googleAuthId: number, name: string, tx?: object): Promise<{deleted: boolean}>` - `delete(googleAuthId: number, name: string, tx?: object): Promise<{deleted: boolean}>`

View File

@@ -16,7 +16,7 @@ Appends a message to one of the user's own conversations. `user` messages are re
| `conversationId` | `number` | The conversation id. | | `conversationId` | `number` | The conversation id. |
| `input` | `object` | Message input. | | `input` | `object` | Message input. |
| `input.message` | `string` | Message text. | | `input.message` | `string` | Message text. |
| `[input.role='user']` | `'user'|'assistant'|'system'|'tool'|'reasoning'` | Message role. | | `[input.role='user']` | `'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'` | Message role. |
| `[tx]` | `object` | Optional transaction to run within. | | `[tx]` | `object` | Optional transaction to run within. |
**Returns** **Returns**

View File

@@ -833,7 +833,7 @@ BEGIN
role NVARCHAR(20) NOT NULL, role NVARCHAR(20) NOT NULL,
message NVARCHAR(MAX) NOT NULL, message NVARCHAR(MAX) NOT NULL,
CONSTRAINT FK_modelmessage_conversation FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE, CONSTRAINT FK_modelmessage_conversation FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE,
CONSTRAINT CK_modelmessage_role CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning')) CONSTRAINT CK_modelmessage_role CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning', 'usage'))
); );
CREATE INDEX IX_modelmessage_conversation ON modelmessage (conversation_id, id); CREATE INDEX IX_modelmessage_conversation ON modelmessage (conversation_id, id);
END END

View File

@@ -518,7 +518,7 @@ CREATE TABLE IF NOT EXISTS modelmessage (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
conversation_id INTEGER NOT NULL, conversation_id INTEGER NOT NULL,
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}), created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
role TEXT NOT NULL CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning')), role TEXT NOT NULL CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning', 'usage')),
message TEXT NOT NULL, message TEXT NOT NULL,
FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE
); );

View File

@@ -31,7 +31,7 @@ export default function add(provider) {
* @param {number} conversationId - The conversation id. * @param {number} conversationId - The conversation id.
* @param {object} input - Message input. * @param {object} input - Message input.
* @param {string} input.message - Message text. * @param {string} input.message - Message text.
* @param {'user'|'assistant'|'system'|'tool'|'reasoning'} [input.role='user'] - Message role. * @param {'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'} [input.role='user'] - Message role.
* @param {object} [tx] - Optional transaction to run within. * @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>} * @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'. * @throws {Error} 'Conversation not found', 'Conversation is not idle', 'Message required', 'Invalid role'.
@@ -42,7 +42,7 @@ export default function add(provider) {
throw new Error('Conversation not found'); throw new Error('Conversation not found');
} }
const role = input.role || 'user'; const role = input.role || 'user';
if (!['user', 'assistant', 'system', 'tool', 'reasoning'].includes(role)) { if (!['user', 'assistant', 'system', 'tool', 'reasoning', 'usage'].includes(role)) {
throw new Error('Invalid role'); throw new Error('Invalid role');
} }
const message = input.message != null ? String(input.message) : ''; const message = input.message != null ? String(input.message) : '';