ThreadsApi
Class: ThreadsApi
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:28
Manages thread operations within the CodeBolt platform.
Threads represent execution units that can be created, monitored, and controlled through various states and lifecycle events. This API provides comprehensive functionality for thread management including CRUD operations, search, bulk operations, and execution control.
Constructors
Constructor
new ThreadsApi(http: HttpClient): ThreadsApi;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:29
Parameters
| Parameter | Type |
|---|---|
http | HttpClient |
Returns
ThreadsApi
Methods
advancedSearch()
advancedSearch(data: ThreadSearchRequest): Promise<Thread[]>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:144
Performs an advanced search for threads based on multiple criteria.
Allows complex queries with filtering, sorting, and pagination to find threads matching specific conditions. Use this for flexible thread discovery and management operations.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ThreadSearchRequest | The search request containing filter and query parameters |
Returns
Promise<Thread[]>
A promise that resolves to an array of matching Thread objects
Example
const results = await client.threads.advancedSearch({
status: 'active',
limit: 10
});
autoUpdateName()
autoUpdateName(data: AutoUpdateNameRequest): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:206
Automatically updates a thread's name based on its content.
Analyzes the thread's execution history, messages, and context to generate an appropriate name that reflects its purpose and activity. This is useful for maintaining descriptive thread labels without manual intervention.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | AutoUpdateNameRequest | The request containing the thread ID to rename |
Returns
Promise<void>
A promise that resolves when the thread name has been updated
Example
await client.threads.autoUpdateName({ threadId: 'thread-123' });
bulkDelete()
bulkDelete(data: ThreadBulkDeleteRequest): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:187
Deletes multiple threads in a single operation.
Removes the specified threads from the system in a bulk operation. This is more efficient than deleting threads individually and ensures atomic deletion of multiple threads.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ThreadBulkDeleteRequest | The bulk delete request containing thread IDs to delete |
Returns
Promise<void>
A promise that resolves when all threads have been deleted
Example
await client.threads.bulkDelete({
threadIds: ['thread-1', 'thread-2', 'thread-3']
});
bulkUpdate()
bulkUpdate(data: ThreadBulkUpdateRequest): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:166
Updates multiple threads in a single operation.
Performs bulk modifications across multiple threads simultaneously. This is more efficient than updating threads individually when you need to apply the same changes to many threads.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | ThreadBulkUpdateRequest | The bulk update request containing thread IDs and updates |
Returns
Promise<void>
A promise that resolves when all threads have been updated
Example
await client.threads.bulkUpdate({
threadIds: ['thread-1', 'thread-2'],
updates: { status: 'completed' }
});
cancel()
cancel(threadId: string): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:415
Cancels the execution of a thread.
Terminates the thread's operations and places it in a cancelled state. Unlike pausing, this action cannot be reversed and the thread will not continue execution. Use this to stop threads that are no longer needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | The unique identifier of the thread to cancel |
Returns
Promise<void>
A promise that resolves when the thread has been cancelled
Example
await client.threads.cancel('thread-123');
complete()
complete(threadId: string): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:434
Marks a thread as completed.
Sets the thread's status to completed, indicating that its execution has finished successfully. This is typically done automatically by the thread, but can be called manually when needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | The unique identifier of the thread to complete |
Returns
Promise<void>
A promise that resolves when the thread has been marked complete
Example
await client.threads.complete('thread-123');
create()
create(data: CreateThreadRequest): Promise<Thread>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:475
Creates a new thread with the specified configuration.
Initializes a new thread with the provided settings and parameters. The thread will be created in an initial state and can be executed when ready. Use this to set up new execution units.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | CreateThreadRequest | The thread creation request with configuration details |
Returns
Promise<Thread>
A promise that resolves to the newly created Thread object
Example
const thread = await client.threads.create({
name: 'Data Processing',
type: 'workflow'
});
delete()
delete(threadId: string): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:517
Deletes a thread from the system.
Permanently removes the specified thread and all its associated data. This action cannot be undone, so use with caution. Deleting a thread will also remove its relationships with other threads.
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | The unique identifier of the thread to delete |
Returns
Promise<void>
A promise that resolves when the thread has been deleted
Example
await client.threads.delete('thread-123');
execute()
execute(threadId: string, data?: ExecuteThreadRequest): Promise<Thread>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:355
Executes a thread with optional configuration parameters.
Starts or resumes execution of the specified thread. You can provide additional execution parameters to customize the run. The thread will process its configured tasks and operations.
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | The unique identifier of the thread to execute |
data? | ExecuteThreadRequest | Optional execution configuration parameters |
Returns
Promise<Thread>
A promise that resolves to the updated Thread object
Example
const thread = await client.threads.execute('thread-123', {
mode: 'sync'
});
getById()
getById(id: string): Promise<Thread>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:537
Retrieves a thread by its unique identifier.
Fetches the complete thread object including all its properties and current state. This is the primary method for accessing thread details when you know the thread's ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the thread to retrieve |
Returns
Promise<Thread>
A promise that resolves to the Thread object
Example
const thread = await client.threads.getById('thread-123');
console.log(thread.name, thread.status);
getChildren()
getChildren(threadId: string): Promise<Thread[]>;
Defined in: CodeBolt/packages/clientsdk/src/api/threads.api.ts:267
Retrieves all direct child threads of a specified thread.
Returns threads that are immediate descendants of the given parent thread. This is useful for navigating thread hierarchies and managing related threads.
Parameters
| Parameter | Type | Description |
|---|---|---|
threadId | string | The unique identifier of the parent thread |
Returns
Promise<Thread[]>
A promise that resolves to an array of child Thread objects
Example
const children = await client.threads.getChildren('thread-123');
children.forEach(child => console.log(child.name));