UNPKG

asteroid-odyssey

Version:

SDK for interacting with Asteroid Agents API

1,544 lines (1,537 loc) 173 kB
type AuthToken = string | undefined; interface Auth { /** * Which part of the request do we use to send the auth? * * @default 'header' */ in?: 'header' | 'query' | 'cookie'; /** * Header or query parameter name. * * @default 'Authorization' */ name?: string; scheme?: 'basic' | 'bearer'; type: 'apiKey' | 'http'; } interface SerializerOptions<T> { /** * @default true */ explode: boolean; style: T; } type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; type ObjectStyle = 'form' | 'deepObject'; type QuerySerializer = (query: Record<string, unknown>) => string; type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { allowReserved?: boolean; array?: Partial<SerializerOptions<ArrayStyle>>; object?: Partial<SerializerOptions<ObjectStyle>>; }; type QuerySerializerOptions = QuerySerializerOptionsObject & { /** * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ parameters?: Record<string, QuerySerializerOptionsObject>; }; type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'; type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = { /** * Returns the final request URL. */ buildUrl: BuildUrlFn; getConfig: () => Config; request: RequestFn; setConfig: (config: Config) => Config; } & { [K in HttpMethod]: MethodFn; } & ([SseFn] extends [never] ? { sse?: never; } : { sse: { [K in HttpMethod]: SseFn; }; }); interface Config$1 { /** * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ bodySerializer?: BodySerializer | null; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. * * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: Uppercase<HttpMethod>; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject * style, and reserved characters are percent-encoded. * * This method will have no effect if the native `paramsSerializer()` Axios * API function is used. * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ requestValidator?: (data: unknown) => Promise<unknown>; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ responseTransformer?: (data: unknown) => Promise<unknown>; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ responseValidator?: (data: unknown) => Promise<unknown>; } type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & { /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Implementing clients can call request interceptors inside this hook. */ onRequest?: (url: string, init: RequestInit) => Promise<Request>; /** * Callback invoked when a network or parsing error occurs during streaming. * * This option applies only if the endpoint returns a stream of events. * * @param error The error that occurred. */ onSseError?: (error: unknown) => void; /** * Callback invoked when an event is streamed from the server. * * This option applies only if the endpoint returns a stream of events. * * @param event Event streamed from the server. * @returns Nothing (void). */ onSseEvent?: (event: StreamEvent<TData>) => void; serializedBody?: RequestInit['body']; /** * Default retry delay in milliseconds. * * This option applies only if the endpoint returns a stream of events. * * @default 3000 */ sseDefaultRetryDelay?: number; /** * Maximum number of retry attempts before giving up. */ sseMaxRetryAttempts?: number; /** * Maximum retry delay in milliseconds. * * Applies only when exponential backoff is used. * * This option applies only if the endpoint returns a stream of events. * * @default 30000 */ sseMaxRetryDelay?: number; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ sseSleepFn?: (ms: number) => Promise<void>; url: string; }; interface StreamEvent<TData = unknown> { data: TData; event?: string; id?: string; retry?: number; } type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>; }; type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>; type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>; declare class Interceptors<Interceptor> { fns: Array<Interceptor | null>; clear(): void; eject(id: number | Interceptor): void; exists(id: number | Interceptor): boolean; getInterceptorIndex(id: number | Interceptor): number; update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; use(fn: Interceptor): number; } interface Middleware<Req, Res, Err, Options> { error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; request: Interceptors<ReqInterceptor<Req, Options>>; response: Interceptors<ResInterceptor<Res, Req, Options>>; } type ResponseStyle = 'data' | 'fields'; interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 { /** * Base URL for all requests made by this client. */ baseUrl?: T['baseUrl']; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. * * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. */ next?: never; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. * You can override this behavior with any of the {@link Body} methods. * Select `stream` if you don't want to parse response data at all. * * @default 'auto' */ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ responseStyle?: ResponseStyle; /** * Throw an error instead of returning it in the response? * * @default false */ throwOnError?: T['throwOnError']; } interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{ responseStyle: TResponseStyle; throwOnError: ThrowOnError; }>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> { /** * Any body that you want to add to your request. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ body?: unknown; path?: Record<string, unknown>; query?: Record<string, unknown>; /** * Security mechanism(s) to use for the request. */ security?: ReadonlyArray<Auth>; url: Url; } interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { serializedBody?: string; } type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : { data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; request: Request; response: Response; }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; error: undefined; } | { data: undefined; error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; }) & { request: Request; response: Response; }>; interface ClientOptions$1 { baseUrl?: string; responseStyle?: ResponseStyle; throwOnError?: boolean; } type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>; type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; type BuildUrlFn = <TData extends { body?: unknown; path?: Record<string, unknown>; query?: Record<string, unknown>; url: string; }>(options: TData & Options$1<TData>) => string; type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; }; interface TDataShape { body?: unknown; headers?: unknown; path?: unknown; query?: unknown; url: string; } type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>); type ClientOptions = { baseUrl: 'https://odyssey.asteroid.ai/agents/v2' | (string & {}); }; type AgentsAgentAvailableTool = { name: string; description: string; capability: string; isRequired: boolean; }; type AgentsAgentAvailableToolsResponse = { tools: Array<AgentsAgentAvailableTool>; }; type AgentsAgentBase = { id: CommonUuid; name: string; createdAt: string; organizationId?: CommonUuid; userId: CommonUuid; }; type AgentsAgentExecuteAgentRequest = { /** * The ID of the agent profile to use for this execution. Mutually exclusive with agentProfilePoolId. */ agentProfileId?: CommonUuid; /** * The ID of the agent profile pool to select a profile from. Mutually exclusive with agentProfileId. */ agentProfilePoolId?: CommonUuid; /** * Inputs to be merged into the placeholders defined in prompts */ inputs?: { [key: string]: unknown; }; /** * Deprecated: Use 'inputs' instead. Inputs to be merged into the placeholders defined in prompts * * @deprecated */ dynamicData?: { [key: string]: unknown; }; /** * Array of temporary files to attach to the execution. Must have been pre-uploaded using the stage file endpoint */ tempFiles?: Array<AgentsFilesTempFile>; /** * Optional metadata key-value pairs (string keys and string values) for organizing and filtering executions */ metadata?: { [key: string]: unknown; }; /** * The version of the agent to execute. If not provided, the latest version will be used. */ version?: number; /** * Per-execution runtime options that override or extend the agent's default settings. */ executionOptions?: AgentsAgentExecutionOptions; }; type AgentsAgentExecuteAgentResponse = { /** * The ID of the newly created execution */ executionId: CommonUuid; }; /** * Per-execution runtime options. */ type AgentsAgentExecutionOptions = { /** * Scopes shared-file storage to a per-entity subdirectory under each node's shared folder. The value is normalised to a filesystem-safe slug by the server. */ sharedStorageKey?: string; /** * Soft timeout in minutes. When the execution has been running longer than this value, a message is injected on every subsequent step urging the agent to wrap up and produce output. Must be greater than 0 and less than the agent's hard timeout (max_timeout_mins). */ softTimeoutMins?: number; }; type AgentsAgentSortField = 'name' | 'created_at'; type AgentsContextUserContextResponse = { userId: CommonUuid; email: string; organizations: Array<AgentsContextUserOrganization>; }; type AgentsContextUserOrganization = { id: CommonUuid; name: string; }; /** * Request to search Asteroid documentation */ type AgentsDocsSearchDocsRequest = { /** * Search query to find relevant documentation */ query: string; }; /** * Response containing documentation search results */ type AgentsDocsSearchDocsResponse = { /** * Search results matching the query */ results: Array<AgentsDocsSearchResult>; }; /** * A single documentation search result */ type AgentsDocsSearchResult = { /** * Result title */ title: string; /** * Result content/snippet */ content: string; /** * Source URL */ url?: string; }; /** * API key reference used for authentication */ type AgentsExecutionApiKeyRef = { /** * API key ID */ id: CommonUuid; /** * API key name */ name: string; }; /** * API-triggered execution context */ type AgentsExecutionApiTriggerContext = { /** * Trigger source discriminator */ source: 'api'; /** * Runner information */ runner: AgentsExecutionTriggerRunner; /** * API key used for authentication (may be hidden for privacy when admin-triggered) */ apiKey?: AgentsExecutionApiKeyRef; }; type AgentsExecutionActionName = 'element_click' | 'element_type' | 'element_select' | 'element_hover' | 'element_drag' | 'element_wait' | 'element_fill_form' | 'element_get_text' | 'element_file_upload' | 'coord_move' | 'coord_click' | 'coord_double_click' | 'coord_triple_click' | 'coord_drag' | 'coord_scroll' | 'nav_to' | 'nav_back' | 'nav_refresh' | 'nav_tabs' | 'nav_close_browser' | 'nav_resize_browser' | 'nav_install_browser' | 'nav_zoom_in' | 'nav_zoom_out' | 'obs_snapshot' | 'obs_snapshot_with_selectors' | 'obs_screenshot' | 'obs_console_messages' | 'obs_network_requests' | 'obs_extract_html' | 'script_eval' | 'script_playwright' | 'script_playwright_llm_vars' | 'script_hybrid_playwright' | 'browser_run_code' | 'browser_press_key' | 'browser_handle_dialog' | 'browser_read_clipboard' | 'browser_solve_captcha' | 'file_list' | 'file_read' | 'file_stage' | 'file_download' | 'file_pdf_save' | 'scratchpad_read' | 'scratchpad_write' | 'scriptpad_run_function' | 'scriptpad_search_replace' | 'scriptpad_read' | 'scriptpad_write' | 'ext_google_sheets_get_data' | 'ext_google_sheets_set_value' | 'ext_get_mail' | 'ext_send_mail' | 'ext_api_call' | 'util_wait_time' | 'util_get_datetime' | 'util_generate_totp_secret' | 'util_send_user_message' | 'agent_query_context' | 'agent_compile_workflow' | 'llm_call' | 'sdk_bash' | 'sdk_read' | 'sdk_write' | 'sdk_edit' | 'sdk_glob' | 'sdk_grep' | 'handoff_prepare' | 'read_file'; type AgentsExecutionActivity = { id: CommonUuid; payload: AgentsExecutionActivityPayloadUnion; executionId: CommonUuid; timestamp: string; }; type AgentsExecutionActivityActionCompletedInfo = ({ actionName: 'ext_api_call'; } & AgentsExecutionExtApiCallCompletedDetails) | ({ actionName: 'scratchpad_read'; } & AgentsExecutionScratchpadReadCompletedDetails) | ({ actionName: 'scratchpad_write'; } & AgentsExecutionScratchpadWriteCompletedDetails) | ({ actionName: 'script_playwright'; } & AgentsExecutionScriptPlaywrightCompletedDetails) | ({ actionName: 'script_hybrid_playwright'; } & AgentsExecutionScriptHybridPlaywrightCompletedDetails) | ({ actionName: 'browser_run_code'; } & AgentsExecutionBrowserRunCodeCompletedDetails) | ({ actionName: 'script_eval'; } & AgentsExecutionScriptEvalCompletedDetails) | ({ actionName: 'file_read'; } & AgentsExecutionFileReadCompletedDetails) | ({ actionName: 'file_list'; } & AgentsExecutionFileListCompletedDetails) | ({ actionName: 'file_stage'; } & AgentsExecutionFileStageCompletedDetails) | ({ actionName: 'element_file_upload'; } & AgentsExecutionElementFileUploadCompletedDetails) | ({ actionName: 'ext_get_mail'; } & AgentsExecutionExtGetMailCompletedDetails) | ({ actionName: 'scriptpad_run_function'; } & AgentsExecutionScriptPadRunFunctionCompletedDetails) | ({ actionName: 'scriptpad_read'; } & AgentsExecutionScriptpadReadCompletedDetails) | ({ actionName: 'scriptpad_write'; } & AgentsExecutionScriptpadWriteCompletedDetails) | ({ actionName: 'scriptpad_search_replace'; } & AgentsExecutionScriptpadSearchReplaceCompletedDetails) | ({ actionName: 'obs_snapshot_with_selectors'; } & AgentsExecutionObsSnapshotWithSelectorsCompletedDetails) | ({ actionName: 'util_get_datetime'; } & AgentsExecutionUtilGetDatetimeCompletedDetails) | ({ actionName: 'nav_to'; } & AgentsExecutionNavToCompletedDetails) | ({ actionName: 'agent_query_context'; } & AgentsExecutionAgentQueryContextCompletedDetails) | ({ actionName: 'sdk_bash'; } & AgentsExecutionSdkBashCompletedDetails) | ({ actionName: 'sdk_read'; } & AgentsExecutionSdkReadCompletedDetails) | ({ actionName: 'sdk_write'; } & AgentsExecutionSdkWriteCompletedDetails) | ({ actionName: 'sdk_edit'; } & AgentsExecutionSdkEditCompletedDetails) | ({ actionName: 'sdk_glob'; } & AgentsExecutionSdkGlobCompletedDetails) | ({ actionName: 'sdk_grep'; } & AgentsExecutionSdkGrepCompletedDetails) | ({ actionName: 'read_file'; } & AgentsExecutionReadFileCompletedDetails) | ({ actionName: 'handoff_prepare'; } & AgentsExecutionHandoffPrepareCompletedDetails) | ({ actionName: 'ext_send_mail'; } & AgentsExecutionExtSendMailCompletedDetails); type AgentsExecutionActivityActionCompletedPayload = { activityType: 'action_completed'; message: string; actionId: string; actionName: AgentsExecutionActionName; duration?: number; info?: AgentsExecutionActivityActionCompletedInfo; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityActionFailedPayload = { activityType: 'action_failed'; message: string; actionName: AgentsExecutionActionName; actionId: string; duration?: number; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityActionStartedInfo = ({ actionName: 'nav_to'; } & AgentsExecutionNavToStartedDetails) | ({ actionName: 'scratchpad_read'; } & AgentsExecutionScratchpadReadStartedDetails) | ({ actionName: 'scratchpad_write'; } & AgentsExecutionScratchpadWriteStartedDetails) | ({ actionName: 'scriptpad_run_function'; } & AgentsExecutionScriptpadRunFunctionStartedDetails) | ({ actionName: 'script_playwright'; } & AgentsExecutionScriptPlaywrightStartedDetails) | ({ actionName: 'script_hybrid_playwright'; } & AgentsExecutionScriptHybridPlaywrightStartedDetails) | ({ actionName: 'browser_run_code'; } & AgentsExecutionBrowserRunCodeStartedDetails) | ({ actionName: 'script_eval'; } & AgentsExecutionScriptEvalStartedDetails) | ({ actionName: 'scriptpad_search_replace'; } & AgentsExecutionScriptpadSearchReplaceStartedDetails) | ({ actionName: 'util_get_datetime'; } & AgentsExecutionUtilGetDatetimeStartedDetails) | ({ actionName: 'scriptpad_read'; } & AgentsExecutionScriptpadReadStartedDetails) | ({ actionName: 'llm_call'; } & AgentsExecutionLlmCallStartedDetails) | ({ actionName: 'agent_query_context'; } & AgentsExecutionAgentQueryContextStartedDetails) | ({ actionName: 'sdk_bash'; } & AgentsExecutionSdkBashStartedDetails) | ({ actionName: 'sdk_read'; } & AgentsExecutionSdkReadStartedDetails) | ({ actionName: 'sdk_write'; } & AgentsExecutionSdkWriteStartedDetails) | ({ actionName: 'sdk_edit'; } & AgentsExecutionSdkEditStartedDetails) | ({ actionName: 'sdk_glob'; } & AgentsExecutionSdkGlobStartedDetails) | ({ actionName: 'sdk_grep'; } & AgentsExecutionSdkGrepStartedDetails) | ({ actionName: 'read_file'; } & AgentsExecutionReadFileStartedDetails) | ({ actionName: 'handoff_prepare'; } & AgentsExecutionHandoffPrepareStartedDetails) | ({ actionName: 'ext_send_mail'; } & AgentsExecutionExtSendMailStartedDetails); type AgentsExecutionActivityActionStartedPayload = { activityType: 'action_started'; message: string; actionName: AgentsExecutionActionName; actionId: string; info?: AgentsExecutionActivityActionStartedInfo; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityCompactionPerformedPayload = { activityType: 'compaction_performed'; summaryTokens: number; durationMs: number; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityCompactionStartedPayload = { activityType: 'compaction_started'; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityDisplay = { turnId?: string; groupId?: string; summaryText?: string; presentationLevel?: AgentsExecutionActivityPresentationLevel; }; type AgentsExecutionActivityFileAddedPayload = { activityType: 'file_added'; fileId: CommonUuid; fileName: string; mimeType: string; fileSize: number; source: 'upload' | 'download' | 'agent'; presignedUrl: string; }; type AgentsExecutionActivityGenericPayload = { activityType: 'generic'; message: string; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityPayloadUnion = ({ activityType: 'terminal'; } & AgentsExecutionTerminalPayload) | ({ activityType: 'generic'; } & AgentsExecutionActivityGenericPayload) | ({ activityType: 'reasoning'; } & AgentsExecutionActivityReasoningPayload) | ({ activityType: 'compaction_started'; } & AgentsExecutionActivityCompactionStartedPayload) | ({ activityType: 'compaction_performed'; } & AgentsExecutionActivityCompactionPerformedPayload) | ({ activityType: 'step_started'; } & AgentsExecutionActivityStepStartedPayload) | ({ activityType: 'step_completed'; } & AgentsExecutionActivityStepCompletedPayload) | ({ activityType: 'transitioned_node'; } & AgentsExecutionActivityTransitionedNodePayload) | ({ activityType: 'status_changed'; } & AgentsExecutionActivityStatusChangedPayload) | ({ activityType: 'action_started'; } & AgentsExecutionActivityActionStartedPayload) | ({ activityType: 'action_completed'; } & AgentsExecutionActivityActionCompletedPayload) | ({ activityType: 'action_failed'; } & AgentsExecutionActivityActionFailedPayload) | ({ activityType: 'user_message_received'; } & AgentsExecutionActivityUserMessageReceivedPayload) | ({ activityType: 'file_added'; } & AgentsExecutionActivityFileAddedPayload) | ({ activityType: 'workflow_updated'; } & AgentsExecutionActivityWorkflowUpdatedPayload) | ({ activityType: 'playwright_script_generated'; } & AgentsExecutionActivityPlaywrightScriptGeneratedPayload) | ({ activityType: 'script_variables_substituted'; } & AgentsExecutionActivityScriptVariablesSubstitutedPayload) | ({ activityType: 'todos_updated'; } & AgentsExecutionActivityTodosUpdatedPayload); type AgentsExecutionActivityPlaywrightScriptGeneratedPayload = { activityType: 'playwright_script_generated'; nodeId: CommonUuid; nodeName: string; script: string; llmVars?: Array<AgentsGraphModelsNodesPropertiesPlaywrightScriptLlmVar>; context: string; oldScript?: string; }; type AgentsExecutionActivityPresentationLevel = 'primary' | 'secondary' | 'system'; type AgentsExecutionActivityReasoningPayload = { activityType: 'reasoning'; reasoning: string; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityScriptVariablesSubstitutedPayload = { activityType: 'script_variables_substituted'; nodeId: CommonUuid; nodeName: string; scriptFileName: string; placeholders: Array<string>; variables: { [key: string]: unknown; }; substituted: boolean; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityStatusChangedPayload = { activityType: 'status_changed'; status: AgentsExecutionStatus; completedPayload?: AgentsExecutionCompletedPayload; failedPayload?: AgentsExecutionFailedPayload; pausedPayload?: AgentsExecutionPausedPayload; awaitingConfirmationPayload?: AgentsExecutionAwaitingConfirmationPayload; cancelledPayload?: AgentsExecutionCancelledPayload; }; type AgentsExecutionActivityStepCompletedPayload = { activityType: 'step_completed'; stepNumber: number; }; type AgentsExecutionActivityStepStartedPayload = { activityType: 'step_started'; stepNumber: number; }; type AgentsExecutionActivityTodosUpdatedPayload = { activityType: 'todos_updated'; todos: Array<AgentsExecutionTodo>; display?: AgentsExecutionActivityDisplay; }; type AgentsExecutionActivityTransitionedNodePayload = { activityType: 'transitioned_node'; newNodeUUID: CommonUuid; newNodeName: string; newNodeType: string; fromNodeDuration?: number; transitionType?: AgentsGraphModelsTransitionsTransitionType; /** * Output variables provided by the from node */ fromNodeOutput?: Array<AgentsExecutionNodeOutputItem>; /** * A summary of the work done in the previous node */ fromNodeSummary?: string; }; type AgentsExecutionActivityUserMessageReceivedPayload = { activityType: 'user_message_received'; message: string; userUUID: CommonUuid; }; type AgentsExecutionActivityWorkflowUpdatedPayload = { activityType: 'workflow_updated'; workflowUpdate: Array<AgentsExecutionWorkflowUpdate>; }; type AgentsExecutionAgentQueryContextCompletedDetails = { actionName: 'agent_query_context'; query: string; answer: string; }; type AgentsExecutionAgentQueryContextStartedDetails = { actionName: 'agent_query_context'; query: string; }; type AgentsExecutionAskUserQuestion = { questions: Array<AgentsExecutionQuestionItem>; }; type AgentsExecutionAwaitingConfirmationPayload = { reason: string; }; type AgentsExecutionBrowserRunCodeCompletedDetails = { actionName: 'browser_run_code'; success: boolean; result: string; consoleLogs: Array<string>; failedLine?: number; }; type AgentsExecutionBrowserRunCodeStartedDetails = { actionName: 'browser_run_code'; code: string; }; type AgentsExecutionCancelReason = 'timeout' | 'max_steps' | 'user_requested' | 'script_failed'; type AgentsExecutionCancelledPayload = { reason: AgentsExecutionCancelReason; }; /** * User comment on an execution */ type AgentsExecutionComment = { /** * Unique identifier for the comment */ id: CommonUuid; /** * Execution this comment belongs to */ executionId: CommonUuid; /** * User who created the comment */ userId: CommonUuid; /** * Comment content */ content: string; /** * Whether the comment is public */ public: boolean; /** * When the comment was created */ createdAt: string; /** * When the comment was last updated */ updatedAt?: string; }; type AgentsExecutionCompletedPayload = { outcome: string; reasoning: string; result: unknown; lessons_learned?: string; }; type AgentsExecutionElementFileUploadCompletedDetails = { actionName: 'element_file_upload'; fileNames: Array<string>; }; /** * Execution result containing outcome, reasoning, and result data */ type AgentsExecutionExecutionResult = { /** * Unique identifier for the result */ id: CommonUuid; /** * Execution this result belongs to */ executionId: CommonUuid; /** * Outcome of the execution (success or failure) */ outcome: string; /** * AI reasoning for the outcome */ reasoning: string; /** * Result data as JSON */ result: unknown; /** * When the result was created */ createdAt: string; }; type AgentsExecutionExtApiCallCompletedDetails = { actionName: 'ext_api_call'; statusCode: string; responseBody: string; requestMethod?: string; requestUrl?: string; }; type AgentsExecutionExtGetMailCompletedDetails = { actionName: 'ext_get_mail'; emailCount: number; emails: Array<unknown>; }; type AgentsExecutionExtSendMailCompletedDetails = { actionName: 'ext_send_mail'; success: boolean; emailId?: string; }; type AgentsExecutionExtSendMailStartedDetails = { actionName: 'ext_send_mail'; to: Array<string>; subject: string; cc?: Array<string>; bcc?: Array<string>; bodyPreview?: string; }; type AgentsExecutionFailedPayload = { reason: string; os_error?: CommonOsError; }; type AgentsExecutionFileListCompletedDetails = { actionName: 'file_list'; fileNames: Array<string>; }; type AgentsExecutionFileReadCompletedDetails = { actionName: 'file_read'; fileNames: Array<string>; errorCount?: number; totalSizeBytes?: number; }; type AgentsExecutionFileStageCompletedDetails = { actionName: 'file_stage'; fileNames: Array<string>; }; type AgentsExecutionHandoffPrepareCompletedDetails = { actionName: 'handoff_prepare'; success: boolean; }; type AgentsExecutionHandoffPrepareStartedDetails = { actionName: 'handoff_prepare'; target?: string; summary?: string; variables?: Array<AgentsExecutionHandoffPrepareVariable>; }; type AgentsExecutionHandoffPrepareVariable = { name: string; value: string; }; /** * Human-applied label for categorizing executions */ type AgentsExecutionHumanLabel = { /** * Unique identifier for the label */ id: CommonUuid; /** * Organization this label belongs to */ organizationId: CommonUuid; /** * Display name of the label */ name: string; /** * Hex color code for the label (e.g., #FF5733) */ color: string; /** * When the label was created */ createdAt: string; }; type AgentsExecutionLlmCallPurpose = 'iris_pick_next_action' | 'transition_pick_next_node' | 'output_populate_result' | 'generate_hybrid_playwright_code' | 'generate_playwright_variables'; type AgentsExecutionLlmCallStartedDetails = { actionName: 'llm_call'; purpose: AgentsExecutionLlmCallPurpose; }; /** * Represents a single execution in a list view */ type AgentsExecutionListItem = { /** * The unique identifier of the execution */ id: CommonUuid; /** * The ID of the agent that was executed */ agentId: CommonUuid; /** * The ID of the workflow that was executed */ workflowId: CommonUuid; /** * The current status of the execution */ status: AgentsExecutionStatus; /** * When the execution was created */ createdAt: string; /** * When the execution reached a terminal state (if applicable) */ terminalAt?: string; /** * The organization this execution belongs to */ organizationId: CommonUuid; /** * The agent display name */ agentName: string; /** * The name of the agent profile used for this execution (if any) */ agentProfileName?: string; /** * The ID of the agent profile used for this execution (if any) */ agentProfileId?: CommonUuid; /** * Input variables used for this execution */ inputs?: { [key: string]: unknown; }; /** * Execution result with outcome, reasoning, and result data */ executionResult?: AgentsExecutionExecutionResult; /** * Execution duration in seconds (only present for terminal executions) */ duration?: number; /** * Human-applied labels for this execution */ humanLabels: Array<AgentsExecutionHumanLabel>; /** * Comments on this execution */ comments: Array<AgentsExecutionComment>; /** * Optional metadata key-value pairs attached to this execution */ metadata?: { [key: string]: unknown; }; /** * Recording URL for playback (if an environment was used and execution is terminal) */ recordingUrl?: string; /** * Live view URL for debugging (if an environment is active and execution is running) */ liveViewUrl?: string; /** * Deprecated: Use 'recordingUrl' instead. * * @deprecated */ browserRecordingUrl?: string; /** * Deprecated: Use 'liveViewUrl' instead. * * @deprecated */ browserLiveViewUrl?: string; /** * Context about how and by whom this execution was triggered (discriminated by source) */ triggerContext?: AgentsExecutionTriggerContext; /** * Per-execution runtime options (e.g. shared storage key) */ executionOptions?: AgentsAgentExecutionOptions; /** * Whether this execution has been rerun at least once */ hasBeenRerun: boolean; /** * ID of the execution this was rerun from, if applicable */ parentExecutionId?: CommonUuid; /** * Whether this execution is a live environment (astro-driven live session) — the UI hides activity-feed chrome for these runs. Optional because the Electric-synced shape does not yet carry this column. */ isLiveEnvironment?: boolean; }; type AgentsExecutionNavToCompletedDetails = { actionName: 'nav_to'; pageTitle?: string; }; type AgentsExecutionNavToStartedDetails = { actionName: 'nav_to'; url: string; }; type AgentsExecutionNodeDetails = { nodeID: CommonUuid; nodeName: string; nodeType: string; }; /** * A single output variable with a name and value */ type AgentsExecutionNodeOutputItem = { /** * The name of the output variable */ name: string; /** * The value of the output variable */ value: string; }; type AgentsExecutionObsSnapshotWithSelectorsCompletedDetails = { actionName: 'obs_snapshot_with_selectors'; url: string; title: string; }; type AgentsExecutionPausedPayload = { reason: string; question?: AgentsExecutionAskUserQuestion; }; type AgentsExecutionQuestionItem = { question: string; header: string; options: Array<AgentsExecutionQuestionOption>; multiSelect?: boolean; }; type AgentsExecutionQuestionOption = { label: string; description: string; }; type AgentsExecutionReadFileCompletedDetails = { actionName: 'read_file'; contentType: 'image' | 'document' | 'text' | 'unknown'; mimeType?: string; content?: string; }; type AgentsExecutionReadFileStartedDetails = { actionName: 'read_file'; filePath: string; }; type AgentsExecutionRulesDetails = { rules: string; }; /** * Schedule reference for schedule-triggered executions */ type AgentsExecutionScheduleRef = { /** * Schedule ID */ id: CommonUuid; /** * Cron expression of the schedule */ cronExpression: string; }; /** * Schedule-triggered execution context */ type AgentsExecutionScheduleTriggerContext = { /** * Trigger source discriminator */ source: 'schedule'; /** * Schedule that triggered the execution */ schedule: AgentsExecutionScheduleRef; }; type AgentsExecutionScratchpadReadCompletedDetails = { actionName: 'scratchpad_read'; content?: string; contentTruncated?: boolean; }; type AgentsExecutionScratchpadReadStartedDetails = { actionName: 'scratchpad_read'; operation: 'read'; }; type AgentsExecutionScratchpadWriteCompletedDetails = { actionName: 'scratchpad_write'; linesChanged: number; totalLines: number; patchesApplied: number; content?: string; contentTruncated?: boolean; }; type AgentsExecutionScratchpadWriteStartedDetails = { actionName: 'scratchpad_write'; operation: 'write'; }; type AgentsExecutionScriptEvalCompletedDetails = { actionName: 'script_eval'; result: unknown; }; type AgentsExecutionScriptEvalStartedDetails = { actionName: 'script_eval'; element?: string; ref?: string; function: string; }; type AgentsExecutionScriptHybridPlaywrightCompletedDetails = { actionName: 'script_hybrid_playwright'; success: boolean; result: string; consoleLogs: Array<string>; failedLine?: number; }; type AgentsExecutionScriptHybridPlaywrightStartedDetails = { actionName: 'script_hybrid_playwright'; llmVars?: Array<string>; }; type AgentsExecutionScriptPadRunFunctionCompletedDetails = { actionName: 'scriptpad_run_function'; success: boolean; result: string; consoleLogs: Array<string>; failedLine?: number; }; type AgentsExecutionScriptPlaywrightCompletedDetails = { actionName: 'script_playwright'; success: boolean; result: string; consoleLogs: Array<string>; failedLine?: number; }; type AgentsExecutionScriptPlaywrightStartedDetails = { actionName: 'script_playwright'; llmVars?: Array<string>; }; type AgentsExecutionScriptpadReadCompletedDetails = { actionName: 'scriptpad_read'; content: string; }; type AgentsExecutionScriptpadReadStartedDetails = { actionName: 'scriptpad_read'; offset: number; limit: number; }; type AgentsExecutionScriptpadRunFunctionStartedDetails = { actionName: 'scriptpad_run_function'; functionName: string; arguments: unknown; }; type AgentsExecutionScriptpadSearchReplaceCompletedDetails = { actionName: 'scriptpad_search_replace'; linesReplaced: number; linesReplacedWith: number; oldTotalLines: number; newTotalLines: number; oldScriptpad?: string; newScriptpad?: string; }; type AgentsExecutionScriptpadSearchReplaceStartedDetails = { actionName: 'scriptpad_search_replace'; search: string; replace: string; replaceAll: boolean; }; type AgentsExecutionScriptpadWriteCompletedDetails = { actionName: 'scriptpad_write'; linesChanged: number; totalLines: number; patchesApplied: number; scriptpad?: string; }; type AgentsExecutionSdkBashCompletedDetails = { actionName: 'sdk_bash'; output: string; exitCode?: number; }; type AgentsExecutionSdkBashStartedDetails = { actionName: 'sdk_bash'; command: string; description?: string; }; type AgentsExecutionSdkEditCompletedDetails = { actionName: 'sdk_edit'; success: boolean; }; type AgentsExecutionSdkEditStartedDetails = { actionName: 'sdk_edit'; filePath: string; oldString: string; newString: string; replaceAll?: boolean; }; type AgentsExecutionSdkGlobCompletedDetails = { actionName: 'sdk_glob'; files: Array<string>; }; type AgentsExecutionSdkGlobStartedDetails = { actionName: 'sdk_glob'; pattern: string; path?: string; }; type AgentsExecutionSdkGrepCompletedDetails = { actionName: 'sdk_grep'; output: string; outputMode?: string; }; type AgentsExecutionSdkGrepStartedDetails = { actionName: 'sdk_grep'; pattern: string; path?: string; glob?: string; outputMode?: string; }; type AgentsExecutionSdkReadCompletedDetails = { actionName: 'sdk_read'; content: string; }; type AgentsExecutionSdkReadStartedDetails = { actionName: 'sdk_read'; filePath: string; offset?: number; limit?: number; }; type AgentsExecutionSdkWriteCompletedDetails = { actionName: 'sdk_write'; success: boolean; }; type AgentsExecutionSdkWriteStartedDetails = { actionName: 'sdk_write'; filePath: string; }; /** * Fields that can be used for sorting executions */ type AgentsExecutionSortField = 'created_at' | 'status'; type AgentsExecutionStatus = 'starting' | 'running' | 'paused' | 'awaiting_confirmation' | 'completed' | 'cancelled' | 'failed' | 'paused_by_agent'; type AgentsExecutionTerminalPayload = { activityType: 'terminal'; reason: 'unsubscribe' | 'complete' | 'error'; message?: string; }; type AgentsExecutionTodo = { content: string; activeForm?: string; status: AgentsExecutionTodoStatus; }; type AgentsExecutionTodoStatus = 'pending' | 'in_progress' | 'completed'; type AgentsExecutionTransitionDetails = { transitionID: CommonUuid; transitionType: string; }; /** * Discriminated union of trigger contexts (discriminated by source) */ type AgentsExecutionTriggerContext = ({ source: 'api'; } & AgentsExecutionApiTriggerContext) | ({ source: 'ui'; } & AgentsExecutionUiTriggerContext) | ({ source: 'schedule'; } & AgentsExecutionScheduleTriggerContext); /** * Runner information - who triggered the execution */ type AgentsExecutionTriggerRunner = { /** * User ID of the runner */ userId: CommonUuid; /** * Email of the runner */ email: string; /** * Whether the user is an admin (may be hidden for privacy) */ isAdmin?: boolean; }; /** * UI-triggered execution context */ type AgentsExecutionUiTriggerContext = { /** * Trigger source discriminator */ source: 'ui'; /** * Runner information */ runner: AgentsExecutionTriggerRunner; }; type AgentsExecutionUpdateExecutionStatusRequest = { /** * The new status to set for the execution */ status: AgentsExecutionUpdateableStatus; }; type AgentsExecutionUpdateType = 'add' | 'edit' | 'delete'; /** * Status values that can be set via the update endpoint */ type AgentsExecutionUpdateableStatus = 'running' | 'paused' | 'cancelled'; type AgentsExecutionUserMessagesAddTextBody = { message: string; }; type AgentsExecutionUtilGetDatetimeCompletedDetails = { actionName: 'util_get_datetime'; usedBrowserTimezone: boolean; datetime: string; tzTimezoneIdentifier: string; }; type AgentsExecutionUtilGetDatetimeStartedDetails = { actionName: 'util_get_datetime'; tzTimezoneIdentifier: string; }; type AgentsExecutionWorkflowUpdate = { updateType: AgentsExecutionUpdateType; rulesDetails?: AgentsExecutionRulesDetails; nodeDetails?: AgentsExecutionNodeDetails; transitionDetails?: AgentsExecutionTransitionDetails; }; /** * A file tracked in the agent filesystem */ type AgentsFilesAgentFile = { id: CommonUuid; agentId: CommonUuid; filePath: string; fileName: string; fileSize: number; mimeType?: string; createdAt: string; updatedAt: string; executionId: CommonUuid; directory: AgentsFilesAgentFileDirectory; createdBy: AgentsFilesAgentFileCreatedBy; downloadUrl: string; }; /** * Creator of the file */ type AgentsFilesAgentFileCreatedBy = 'user' | 'agent' | 'environment' | 'system'; /** * Directory types within the agent filesystem */ type AgentsFilesAgentFileDirectory = 'uploads' | 'downloads' | 'workspace' | 'shared' | 'debug'; /** * Files grouped by their agent directory */ type AgentsFilesAgentFilesDirectoryListing = { uploads?: Array<AgentsFilesAgentFile>; downloads?: Array<AgentsFilesAgentFile>; workspace?: Array<AgentsFilesAgentFile>; shared?: Array<AgentsFilesAgentFile>; debug?: Array<AgentsFilesAgentFile>; }; /** * Response containing all agent files for an execution, grouped by directory */ type AgentsFilesAgentFilesResponse = { directories: AgentsFilesAgentFilesDirectoryListing; lastUpdated?: string; }; type AgentsFilesFile = { id: CommonUuid; executionId: CommonUuid; agentId: CommonUuid; filePath: string; fileName: string; fileExt: string; fileSize: number; fileType: string; mimeType: string; createdAt: string; downloadUrl: string; /** * @deprecated */ signedUrl: string; }; type AgentsFilesFilePart = Blob | File; /** * Request to set the frozen status of a shared file */ type AgentsFilesSetFrozenRequest = { isFrozen: boolean; }; /** * A file in the agent's persistent shared storage */ type AgentsFilesSharedFile = { id: CommonUuid; agentId: CommonUuid; filePath: string; fileName: string; fileSize: number; mimeType?: string; createdAt: string; updatedAt: string; version: number; isFrozen: boolean; lastModifiedByExecutionId?: CommonUuid; downloadUrl: string; }; /** * Response after uploading shared files */ type AgentsFilesSharedFileUploadResponse = { files: Array<AgentsFilesSharedFile>; }; /** * Response containing all shared files for an agent */ type AgentsFilesSharedFilesResponse = { files: Array<AgentsFilesSharedFile>; totalSize: number; }; type AgentsFilesTempFile = { id: CommonUuid; name: string; }; type AgentsFilesTempFilesResponse = { tempFiles: Array<AgentsFilesTempFile>; }; type AgentsGraphModelsAgentGraph = { nodes: Array<AgentsGraphModelsNodesNode>; transitions: Array<AgentsGraphModelsTransitionsTransition>; sticky_notes: Array<AgentsGraphModelsStickyNote>; }; /** * LLM provider for the new agent loop */ type AgentsGraphModelsLlmProvider = 'bedrock' | 'anthropic' | 'bifrost'; type AgentsGraphModelsNodesNode = { id: CommonUuid; name: string; type: AgentsGraphModelsNodesNodeType; description: string; properties: AgentsGraphModelsNodesNodePropertiesUnion; is_start_node: boolean; task?: string; position?: AgentsGraphModelsNodesPosition; }; type AgentsGraphModelsNodesNodePropertiesUnion = ({ type: 'iris'; } & AgentsGraphModelsNodesPropertiesIrisProperties) | ({ type: 'playwright_script'; } & AgentsGraphModelsNodesPropertiesPlaywrightScriptProperties) | ({ type: 'api'; } & AgentsGraphModelsNodesPropertiesApiProperties) | ({ type: 'url'; } & AgentsGraphModelsNodesPropertiesUrlProperties) | ({ type: 'output'; } & AgentsGraphModelsNodesPropertiesOutputProperties); type AgentsGraphModelsNodesNodeType = 'iris' | 'playwright_script' | 'api' | 'url' | 'output'; type AgentsGraphModelsNodesPosition = { x: number; y: number; }; type AgentsGraphModelsNodesPropertiesApiMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; type AgentsGraphModelsNodesPropertiesApiProperties = { type: 'api'; method: AgentsGraphModelsNodesPropertiesApiMethod; url: string; body: { [key: string]: unknown; }; headers: { [key: string]: unknown; }; }; type AgentsGraphModelsNodesPropertiesIrisPlaywrightScriptProperties = { script: string; llm_vars: Array<AgentsGraphModelsNodesPropertiesPlaywrightScriptLlmVar>; freeze_script: boolean; }; type AgentsGraphModelsNodesPropertiesIrisProperties = { type: 'iris'; instructions: string; tools: Array<string>; snapshot_compression: boolean; compression_strategies?: Array<string>; temperature: number; batch_actions: boolean; playwright_script_properties?: AgentsGraphModelsNodesPropertiesIrisPlaywrightScriptProperties; learn_and_compile?: boolean; /** * Relative path (within the node's own shared directory) of the * Playwright script that the runtime should execute before the LLM. * Setting this turns the node into a fast-path scripted node — combine * with `freeze: true` to skip the LLM entirely on success. * * The path is resolved at runtime against the node's shared * directory — i.e. `shared/<node-key>/<script_filepath>` o