TaskBridgeClient

The main entry point for interacting with the TaskBridge backend.

Provides methods to start tasks, observe their progress via streaming events, submit actions for suspended tasks, and cancel active tasks.

Samples

val client =
    TaskBridgeClient.create(
        TaskBridgeConfig(
            baseUrl = "https://api.example.com",
            transportFactory =
                OkHttpTaskBridgeTransportFactory<Unit>(
                    OkHttpTaskBridgeTransportConfig(okHttpClient = OkHttpClient()),
                ),
            authHeaderProvider = { _, _ -> "Bearer your-token" },
        ),
    )

Functions

Link copied to clipboard
abstract suspend fun cancelTask(context: Ctx, taskId: String, reason: String? = null): CancelTaskResponse

Requests cancellation of an active task.

Link copied to clipboard
suspend fun TaskBridgeClient<Unit>.cancelTask(taskId: String, reason: String? = null): CancelTaskResponse
Link copied to clipboard
abstract fun observeTaskEvents(context: Ctx, taskId: String, lastEventId: String? = null): Flow<TaskEvent>

Returns a Flow of events for a specific task.

Link copied to clipboard
fun TaskBridgeClient<Unit>.observeTaskEvents(taskId: String, lastEventId: String? = null): Flow<TaskEvent>
Link copied to clipboard
abstract suspend fun startTaskJson(context: Ctx, request: TaskCreateJsonRequest): TaskCreatedResponse

Starts a new task with JSON input.

Link copied to clipboard

Extension methods for TaskBridgeClient with Unit context to maintain backward compatibility.

Link copied to clipboard
abstract suspend fun startTaskMultipart(context: Ctx, clientRequestId: String, taskType: String, inputJson: String?, metadataJson: String?, attachments: List<TaskBridgeMultipartAttachment>): TaskCreatedResponse

Starts a new task using multipart/form-data, typically for uploading files.

Link copied to clipboard
suspend fun TaskBridgeClient<Unit>.startTaskMultipart(clientRequestId: String, taskType: String, inputJson: String?, metadataJson: String?, attachments: List<TaskBridgeMultipartAttachment>): TaskCreatedResponse
Link copied to clipboard
abstract suspend fun submitAction(context: Ctx, taskId: String, action: TaskActionRequest): SubmitActionResponse

Submits a user action to resume a suspended task.

Link copied to clipboard