import type { TaskTransportOptions } from '../../lib/tasks'; import type { Renderer, Unmounter, Widget } from '../../types'; export type TasksRenderState = { /** * The latest (unwrapped) task output, or `undefined` before the first * `submit` resolves. */ output: TOutput | undefined; /** * Whether a `submit` request is currently in flight. */ isLoading: boolean; /** * The error thrown by the last `submit`, or `undefined` when the last request * succeeded (or none has run yet). */ error: Error | undefined; /** * Sends `variables` as the task `input` and updates the render state with the * result. Clears the previous `output` immediately, then resolves with this * call's own output once the request settles (or `undefined` if it failed — * the failure is surfaced via `error`). The returned promise never rejects. */ submit: (variables: Record) => Promise; /** * Supersedes any in-flight `submit` so its pending result is ignored (the * underlying request is not aborted, just abandoned) and clears the output, * error, and loading state. Use when the inputs that produced the request are * no longer valid. */ invalidate: () => void; }; /** * Either `agentId` or a custom `transport` is required. */ export type TasksSource = { agentId: string; transport?: TaskTransportOptions; } | { transport: TaskTransportOptions; agentId?: never; }; export type TasksConnectorParams = TasksSource & { /** ID of the configured task to run. Either `task` or `kind` is required. */ task?: string; /** Kind of configured task to run. Either `task` or `kind` is required. */ kind?: string; stream?: boolean; }; export type TasksWidgetDescription = { $$type: 'ais.tasks'; renderState: TasksRenderState; }; export type TasksConnector = (renderFn: Renderer, TasksConnectorParams>, unmountFn?: Unmounter) => (widgetParams: TasksConnectorParams) => Widget & { widgetParams: TasksConnectorParams; }>; declare const connectTasks: TasksConnector; export default connectTasks;