125 lines
4.0 KiB
Markdown
125 lines
4.0 KiB
Markdown
# modelconversation
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `modelconversation.create`
|
|
|
|
*Source: `src/store/modelconversation/create.js`*
|
|
|
|
Creates a new (idle) model conversation for the user in the selected company.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `input` | `object` | Conversation input. |
|
|
| `input.provider` | `string` | LLM provider name. |
|
|
| `input.model` | `string` | Model identifier. |
|
|
| `[input.started_by]` | `number|null` | Id of the conversation that starts this one as a subagent (unenforced reference; omit/null for a top-level conversation). |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string, started_by: number|null}>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — 'Provider required', 'Model required' or 'Invalid started_by'.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const c = await store.modelconversation.create(42, { provider: 'openrouter', model: 'openai/gpt-5' });
|
|
```
|
|
|
|
## `modelconversation.delete`
|
|
|
|
*Source: `src/store/modelconversation/delete.js`*
|
|
|
|
Deletes a model conversation by ID for the user in the selected company, together with every subagent conversation below it (`started_by` chain, recursively) and their messages.
|
|
|
|
**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<void>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — 'Conversation not found'.
|
|
|
|
## `modelconversation.get`
|
|
|
|
*Source: `src/store/modelconversation/get.js`*
|
|
|
|
Gets a single model conversation by ID for the user in the selected company.
|
|
|
|
**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<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string, started_by: number|null, first_user_message: string|null}>` — `first_user_message` is the stored `message` payload of the first `user` message (null if none yet).
|
|
|
|
**Throws**
|
|
|
|
`Error` — 'Conversation not found'.
|
|
|
|
## `modelconversation.list`
|
|
|
|
*Source: `src/store/modelconversation/list.js`*
|
|
|
|
Lists the user's own model conversations in the selected company, newest activity first.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<Array<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string, started_by: number|null, first_user_message: string|null}>>` — `started_by` is the originating conversation id for subagent conversations (null otherwise), so clients can build a tree. `first_user_message` is the stored `message` payload of the conversation's first `user` message (null if none yet).
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const conversations = await store.modelconversation.list(42);
|
|
```
|
|
|
|
## `modelconversation.setState`
|
|
|
|
*Source: `src/store/modelconversation/setState.js`*
|
|
|
|
Sets the state of a model conversation ('idle' | 'busy').
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `conversationId` | `number` | The conversation id. |
|
|
| `state` | `string` | The new state ('idle' | 'busy'). |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string, started_by: number|null}>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — 'Invalid state' or 'Conversation not found'.
|