Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions packages/sdk/src/modules/agents.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export interface AgentsModuleConfig {
*
* This module is available to use with a client in all authentication modes:
*
* - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
* - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations. Each user can read and add messages only to conversations they created, even if the user is an admin.
* - **Service role authentication** (`base44.asServiceRole.agents`): Operations are invoked with the service role for backend code that needs elevated permissions.
*
* ## Generated Types
Expand All @@ -215,15 +215,15 @@ export interface AgentsModuleConfig {
*/
export interface AgentsModule {
/**
* Gets all conversations from all agents in the app.
* Gets the current user's conversations with all agents in the app.
*
* Retrieves all conversations. Use {@linkcode listConversations | listConversations()} to filter which conversations are returned, apply sorting, or paginate results. Use {@linkcode getConversation | getConversation()} to retrieve a specific conversation by ID.
* Retrieves every conversation the current user started, across all agents. Conversations that other users started aren't included, even if the user is an admin. Use {@linkcode listConversations | listConversations()} to filter which conversations are returned, apply sorting, or paginate results. Use {@linkcode getConversation | getConversation()} to retrieve a specific conversation by ID.
*
* @returns Promise resolving to an array of conversations.
*
* @example
* ```typescript
* // Get all conversations
* // Get the current user's conversations
* const conversations = await base44.agents.getConversations();
* console.log(`Total conversations: ${conversations.length}`);
* ```
Expand All @@ -236,13 +236,15 @@ export interface AgentsModule {
/**
* Gets a specific conversation by ID.
*
* Retrieves a single conversation using its unique identifier. To retrieve
* all conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
* Retrieves a single conversation using its unique identifier. The conversation must belong to the current user. If another user created it, the request fails with a `403` error. If no conversation has that ID, the request fails with a `404` error. To retrieve
* all of the current user's conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
*
* This function returns the complete stored conversation including full tool call results, even for large responses.
*
* A user can access only their own conversations. Other users' conversations aren't available through this method.
*
* @param conversationId - The unique identifier of the conversation.
* @returns Promise resolving to the conversation, or undefined if not found.
* @returns Promise resolving to the conversation.
*
* @example
* ```typescript
Expand All @@ -253,17 +255,17 @@ export interface AgentsModule {
* }
* ```
*
* @see {@linkcode getConversations | getConversations()} for retrieving all conversations
* @see {@linkcode getConversations | getConversations()} for retrieving all of the current user's conversations
* @see {@linkcode listConversations | listConversations()} for filtering and sorting conversations
*/
getConversation(
conversationId: string
): Promise<AgentConversation | undefined>;

/**
* Lists conversations with filtering, sorting, and pagination.
* Lists the current user's conversations with filtering, sorting, and pagination.
*
* Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. For cases where you need all conversations without filtering, use {@linkcode getConversations | getConversations()}. To retrieve a specific conversation by ID, use {@linkcode getConversation | getConversation()}.
* Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. Results only include conversations the current user created, even with a filter on `created_by_id`. For cases where you need all of the current user's conversations without filtering, use {@linkcode getConversations | getConversations()}. To retrieve a specific conversation by ID, use {@linkcode getConversation | getConversation()}.
*
* @param filterParams - Filter parameters for querying conversations.
* @returns Promise resolving to an array of filtered conversations.
Expand All @@ -290,7 +292,7 @@ export interface AgentsModule {
* });
* ```
*
* @see {@linkcode getConversations | getConversations()} for retrieving all conversations without filtering
* @see {@linkcode getConversations | getConversations()} for retrieving all of the current user's conversations without filtering
* @see {@linkcode getConversation | getConversation()} for retrieving a specific conversation by ID
*/
listConversations(
Expand All @@ -300,6 +302,8 @@ export interface AgentsModule {
/**
* Creates a new conversation with an agent.
*
* The conversation belongs to the current user. Only that user can read it or add messages to it.
*
* @param conversation - Conversation details including agent name and optional metadata.
* @returns Promise resolving to the created conversation.
*
Expand All @@ -324,9 +328,11 @@ export interface AgentsModule {
/**
* Adds a message to a conversation.
*
* Sends a message to the agent and updates the conversation. This method
* Sends a message to the agent and updates the conversation. You can only add messages to conversations the current user created. This method
* also updates the realtime socket to notify any subscribers.
*
* A user can add messages only to their own conversations. Other users' conversations aren't available through this method.
*
* @param conversation - The conversation to add the message to.
* @param message - The message to add.
* @returns Promise resolving to the created message.
Expand All @@ -350,9 +356,11 @@ export interface AgentsModule {
* Subscribes to realtime updates for a conversation.
*
* Establishes a WebSocket connection to receive instant updates when new
* messages are added to the conversation. Returns an unsubscribe function
* messages are added to the conversation. You can only subscribe to conversations the current user created. Returns an unsubscribe function
* to clean up the connection.
*
*
* A user can subscribe only to their own conversations. Other users' conversations aren't available through this method.
*
* <Note>
* When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
* </Note>
Expand Down
19 changes: 16 additions & 3 deletions packages/sdk/src/modules/entities.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface DeleteManyResult {
export interface UpdateManyResult {
/** Whether the operation was successful. */
success: boolean;
/** Number of entities that were updated. */
/** Number of entities that were updated. This includes records that already held the new values, because every update refreshes `updated_date`. */
updated: number;
/** Whether there are more entities matching the query that were not updated in this batch. When `true`, call `updateMany` again with the same query to update the next batch. */
has_more: boolean;
Expand Down Expand Up @@ -850,6 +850,8 @@ export interface EntityHandler<T = any> {
* records first and then updates them. Learn more about
* [concurrent updates](/developers/backend/resources/entities/entity-schemas#concurrent-updates).
*
* This method isn't available for the built-in `User` entity, and calling it fails with a 405 error.
*
* To update a single record by ID, use {@linkcode update | update()} instead. To update
* multiple specific records with different data each, use {@linkcode bulkUpdate | bulkUpdate()}.
*
Expand Down Expand Up @@ -1100,8 +1102,19 @@ export interface EntityHandler<T = any> {
*
* You can update up to 500 records per request.
*
* This isn't a transaction. Each record is written on its own, so if the call
* fails partway, the records already written stay written. Learn more about
* This method isn't available for the built-in `User` entity, and calling it fails with a 405 error.
*
* This isn't a transaction. Before writing, the call validates each record and checks that:
*
* - The `id` matches an existing record that the entity's
* [row-level security](/developers/backend/resources/entities/security#row-level-security-rls)
* update rule lets you update.
* - Each change passes the entity's
* [field-level security](/developers/backend/resources/entities/security#field-level-security-fls)
* write rules.
* - The record matches the entity's schema.
*
* After validation, each record is updated independently. Learn more about
* [concurrent updates](/developers/backend/resources/entities/entity-schemas#concurrent-updates).
*
* To apply the same update to all records matching a query, use
Expand Down
Loading