windmill-utils-internal
Version:
Internal utility functions for Windmill
1,671 lines • 263 kB
TypeScript
/**
* Top-level flow definition containing metadata, configuration, and the flow structure
*/
export type OpenFlow = {
/**
* Short description of what this flow does
*/
summary: string;
/**
* Detailed documentation for this flow
*/
description?: string;
value: FlowValue;
/**
* JSON Schema for flow inputs. Use this to define input parameters, their types, defaults, and validation. For resource inputs, set type to 'object' and format to 'resource-<type>' (e.g., 'resource-stripe')
*/
schema?: {
[key: string]: unknown;
};
};
/**
* The flow structure containing modules and optional preprocessor/failure handlers
*/
export type FlowValue = {
/**
* Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch
*/
modules: Array<FlowModule>;
/**
* Special module that executes when the flow fails. Receives error object with message, name, stack, and step_id. Must have id 'failure'. Only supports script/rawscript types
*/
failure_module?: FlowModule;
/**
* Special module that runs before the first step on external triggers. Must have id 'preprocessor'. Only supports script/rawscript types. Cannot reference other step results
*/
preprocessor_module?: FlowModule;
/**
* If true, all steps run on the same worker for better performance
*/
same_worker?: boolean;
/**
* Maximum number of concurrent executions of this flow
*/
concurrent_limit?: number;
/**
* Expression to group concurrent executions (e.g., by user ID)
*/
concurrency_key?: string;
/**
* Time window in seconds for concurrent_limit
*/
concurrency_time_window_s?: number;
/**
* Delay in seconds to debounce flow executions
*/
debounce_delay_s?: number;
/**
* Expression to group debounced executions
*/
debounce_key?: string;
/**
* Arguments to accumulate across debounced executions
*/
debounce_args_to_accumulate?: Array<(string)>;
/**
* Maximum total time in seconds that a job can be debounced
*/
max_total_debouncing_time?: number;
/**
* Maximum number of times a job can be debounced
*/
max_total_debounces_amount?: number;
/**
* JavaScript expression to conditionally skip the entire flow
*/
skip_expr?: string;
/**
* Cache duration in seconds for flow results
*/
cache_ttl?: number;
cache_ignore_s3_path?: boolean;
/**
* Environment variables available to all steps
*/
flow_env?: {
[key: string]: (string);
};
/**
* Execution priority (higher numbers run first)
*/
priority?: number;
/**
* JavaScript expression to return early from the flow
*/
early_return?: string;
/**
* Whether this flow accepts chat-style input
*/
chat_input_enabled?: boolean;
/**
* Sticky notes attached to the flow
*/
notes?: Array<FlowNote>;
};
/**
* Retry configuration for failed module executions
*/
export type Retry = {
/**
* Retry with constant delay between attempts
*/
constant?: {
/**
* Number of retry attempts
*/
attempts?: number;
/**
* Seconds to wait between retries
*/
seconds?: number;
};
/**
* Retry with exponential backoff (delay doubles each time)
*/
exponential?: {
/**
* Number of retry attempts
*/
attempts?: number;
/**
* Multiplier for exponential backoff
*/
multiplier?: number;
/**
* Initial delay in seconds
*/
seconds?: number;
/**
* Random jitter percentage (0-100) to avoid thundering herd
*/
random_factor?: number;
};
/**
* Conditional retry based on error or result
*/
retry_if?: {
/**
* JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables
*/
expr: string;
};
};
/**
* Early termination condition for a module
*/
export type StopAfterIf = {
/**
* If true, following steps are skipped when this condition triggers
*/
skip_if_stopped?: boolean;
/**
* JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop
*/
expr: string;
/**
* Custom error message shown when stopping
*/
error_message?: string;
};
/**
* A single step in a flow. Can be a script, subflow, loop, or branch
*/
export type FlowModule = {
/**
* Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)
*/
id: string;
value: FlowModuleValue;
/**
* Early termination condition evaluated after this step completes
*/
stop_after_if?: StopAfterIf;
/**
* For loops only - early termination condition evaluated after all iterations complete
*/
stop_after_all_iters_if?: StopAfterIf;
/**
* Conditionally skip this step based on previous results or flow inputs
*/
skip_if?: {
/**
* JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'
*/
expr: string;
};
/**
* Delay before executing this step (in seconds or as expression)
*/
sleep?: InputTransform;
/**
* Cache duration in seconds for this step's results
*/
cache_ttl?: number;
cache_ignore_s3_path?: boolean;
/**
* Maximum execution time in seconds (static value or expression)
*/
timeout?: InputTransform;
/**
* If true, this step's result is deleted after use to save memory
*/
delete_after_use?: boolean;
/**
* Short description of what this step does
*/
summary?: string;
/**
* Mock configuration for testing without executing the actual step
*/
mock?: {
/**
* If true, return mock value instead of executing
*/
enabled?: boolean;
/**
* Value to return when mocked
*/
return_value?: unknown;
};
/**
* Configuration for approval/resume steps that wait for user input
*/
suspend?: {
/**
* Number of approvals required before continuing
*/
required_events?: number;
/**
* Timeout in seconds before auto-continuing or canceling
*/
timeout?: number;
/**
* Form schema for collecting input when resuming
*/
resume_form?: {
/**
* JSON Schema for the resume form
*/
schema?: {
[key: string]: unknown;
};
};
/**
* If true, only authenticated users can approve
*/
user_auth_required?: boolean;
/**
* Expression or list of groups that can approve
*/
user_groups_required?: InputTransform;
/**
* If true, the user who started the flow cannot approve
*/
self_approval_disabled?: boolean;
/**
* If true, hide the cancel button on the approval form
*/
hide_cancel?: boolean;
/**
* If true, continue flow on timeout instead of canceling
*/
continue_on_disapprove_timeout?: boolean;
};
/**
* Execution priority for this step (higher numbers run first)
*/
priority?: number;
/**
* If true, flow continues even if this step fails
*/
continue_on_error?: boolean;
/**
* Retry configuration if this step fails
*/
retry?: Retry;
};
/**
* Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs
*/
export type InputTransform = StaticTransform | JavascriptTransform;
/**
* Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'
*/
export type StaticTransform = {
/**
* The static value. For resources, use format '$res:path/to/resource'
*/
value?: unknown;
type: 'static';
};
/**
* JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside loops, use 'flow_input.iter.value' for the current iteration value
*/
export type JavascriptTransform = {
/**
* JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)
*/
expr: string;
type: 'javascript';
};
/**
* The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type
*/
export type FlowModuleValue = RawScript | PathScript | PathFlow | ForloopFlow | WhileloopFlow | BranchOne | BranchAll | Identity | AiAgent;
/**
* Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms
*/
export type RawScript = {
/**
* Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments
*/
input_transforms: {
[key: string]: InputTransform;
};
/**
* The script source code. Should export a 'main' function
*/
content: string;
/**
* Programming language for this script
*/
language: 'deno' | 'bun' | 'python3' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'php';
/**
* Optional path for saving this script
*/
path?: string;
/**
* Lock file content for dependencies
*/
lock?: string;
type: 'rawscript';
/**
* Worker group tag for execution routing
*/
tag?: string;
/**
* Maximum concurrent executions of this script
*/
concurrent_limit?: number;
/**
* Time window for concurrent_limit
*/
concurrency_time_window_s?: number;
/**
* Custom key for grouping concurrent executions
*/
custom_concurrency_key?: string;
/**
* If true, this script is a trigger that can start the flow
*/
is_trigger?: boolean;
/**
* External resources this script accesses (S3 objects, resources, etc.)
*/
assets?: Array<{
/**
* Path to the asset
*/
path: string;
/**
* Type of asset
*/
kind: 's3object' | 'resource' | 'ducklake' | 'datatable';
/**
* Access level for this asset
*/
access_type?: 'r' | 'w' | 'rw';
/**
* Alternative access level
*/
alt_access_type?: 'r' | 'w' | 'rw';
}>;
};
/**
* Programming language for this script
*/
export type language = 'deno' | 'bun' | 'python3' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'php';
/**
* Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code
*/
export type PathScript = {
/**
* Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments
*/
input_transforms: {
[key: string]: InputTransform;
};
/**
* Path to the script in the workspace (e.g., 'f/scripts/send_email')
*/
path: string;
/**
* Optional specific version hash of the script to use
*/
hash?: string;
type: 'script';
/**
* Override the script's default worker group tag
*/
tag_override?: string;
/**
* If true, this script is a trigger that can start the flow
*/
is_trigger?: boolean;
};
/**
* Reference to an existing flow by path. Use this to call another flow as a subflow
*/
export type PathFlow = {
/**
* Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments
*/
input_transforms: {
[key: string]: InputTransform;
};
/**
* Path to the flow in the workspace (e.g., 'f/flows/process_user')
*/
path: string;
type: 'flow';
};
/**
* Executes nested modules in a loop over an iterator. Inside the loop, use 'flow_input.iter.value' to access the current iteration value, and 'flow_input.iter.index' for the index. Supports parallel execution for better performance on I/O-bound operations
*/
export type ForloopFlow = {
/**
* Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'
*/
modules: Array<FlowModule>;
/**
* JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'
*/
iterator: InputTransform;
/**
* If true, iteration failures don't stop the loop. Failed iterations return null
*/
skip_failures: boolean;
type: 'forloopflow';
/**
* If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency
*/
parallel?: boolean;
/**
* Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression
*/
parallelism?: InputTransform;
squash?: boolean;
};
/**
* Executes nested modules repeatedly while a condition is true. The loop checks the condition after each iteration. Use stop_after_if on modules to control loop termination
*/
export type WhileloopFlow = {
/**
* Steps to execute in each iteration. Use stop_after_if to control when the loop ends
*/
modules: Array<FlowModule>;
/**
* If true, iteration failures don't stop the loop. Failed iterations return null
*/
skip_failures: boolean;
type: 'whileloopflow';
/**
* If true, iterations run concurrently (use with caution in while loops)
*/
parallel?: boolean;
/**
* Maximum number of concurrent iterations when parallel=true
*/
parallelism?: InputTransform;
squash?: boolean;
};
/**
* Conditional branching where only the first matching branch executes. Branches are evaluated in order, and the first one with a true expression runs. If no branches match, the default branch executes
*/
export type BranchOne = {
/**
* Array of branches to evaluate in order. The first branch with expr evaluating to true executes
*/
branches: Array<{
/**
* Short description of this branch condition
*/
summary?: string;
/**
* JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins
*/
expr: string;
/**
* Steps to execute if this branch's expr is true
*/
modules: Array<FlowModule>;
}>;
/**
* Steps to execute if no branch expressions match
*/
default: Array<FlowModule>;
type: 'branchone';
};
/**
* Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently
*/
export type BranchAll = {
/**
* Array of branches that all execute (either in parallel or sequentially)
*/
branches: Array<{
/**
* Short description of this branch's purpose
*/
summary?: string;
/**
* If true, failure in this branch doesn't fail the entire flow
*/
skip_failure?: boolean;
/**
* Steps to execute in this branch
*/
modules: Array<FlowModule>;
}>;
type: 'branchall';
/**
* If true, all branches execute concurrently. If false, they execute sequentially
*/
parallel?: boolean;
};
/**
* AI agent step that can use tools to accomplish tasks. The agent receives inputs and can call any of its configured tools to complete the task
*/
export type AiAgent = {
/**
* Input parameters for the AI agent mapped to their values
*/
input_transforms: {
provider: InputTransform;
output_type: InputTransform;
user_message: InputTransform;
system_prompt?: InputTransform;
streaming?: InputTransform;
memory?: InputTransform;
output_schema?: InputTransform;
user_images?: InputTransform;
max_completion_tokens?: InputTransform;
temperature?: InputTransform;
};
/**
* Array of tools the agent can use. The agent decides which tools to call based on the task
*/
tools: Array<{
/**
* Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')
*/
id: string;
/**
* Short description of what this tool does (shown to the AI)
*/
summary?: string;
/**
* The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference
*/
value: (({
tool_type: 'flowmodule';
} & FlowModuleValue) | {
tool_type: 'mcp';
/**
* Path to the MCP resource/server configuration
*/
resource_path: string;
/**
* Whitelist of specific tools to include from this MCP server
*/
include_tools?: Array<(string)>;
/**
* Blacklist of tools to exclude from this MCP server
*/
exclude_tools?: Array<(string)>;
} | {
tool_type: 'websearch';
});
}>;
type: 'aiagent';
/**
* If true, the agent can execute multiple tool calls in parallel
*/
parallel?: boolean;
};
/**
* Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder
*/
export type Identity = {
type: 'identity';
/**
* If true, marks this as a flow identity (special handling)
*/
flow?: boolean;
};
export type FlowStatus = {
step: number;
modules: Array<FlowStatusModule>;
user_states?: {
[key: string]: unknown;
};
preprocessor_module?: (FlowStatusModule);
failure_module: (FlowStatusModule & {
parent_module?: string;
});
retry?: {
fail_count?: number;
failed_jobs?: Array<(string)>;
};
};
export type FlowStatusModule = {
type: 'WaitingForPriorSteps' | 'WaitingForEvents' | 'WaitingForExecutor' | 'InProgress' | 'Success' | 'Failure';
id?: string;
job?: string;
count?: number;
progress?: number;
iterator?: {
index?: number;
itered?: Array<unknown>;
itered_len?: number;
args?: unknown;
};
flow_jobs?: Array<(string)>;
flow_jobs_success?: Array<(boolean)>;
flow_jobs_duration?: {
started_at?: Array<(string)>;
duration_ms?: Array<(number)>;
};
branch_chosen?: {
type: 'branch' | 'default';
branch?: number;
};
branchall?: {
branch: number;
len: number;
};
approvers?: Array<{
resume_id: number;
approver: string;
}>;
failed_retries?: Array<(string)>;
skipped?: boolean;
agent_actions?: Array<({
job_id: string;
function_name: string;
type: 'tool_call';
module_id: string;
} | {
call_id: string;
function_name: string;
resource_path: string;
type: 'mcp_tool_call';
arguments?: {
[key: string]: unknown;
};
} | {
type: 'web_search';
} | {
type: 'message';
})>;
agent_actions_success?: Array<(boolean)>;
};
export type type = 'WaitingForPriorSteps' | 'WaitingForEvents' | 'WaitingForExecutor' | 'InProgress' | 'Success' | 'Failure';
/**
* A sticky note attached to a flow for documentation and annotation
*/
export type FlowNote = {
/**
* Unique identifier for the note
*/
id: string;
/**
* Content of the note
*/
text: string;
/**
* Position of the note in the flow editor
*/
position?: {
/**
* X coordinate
*/
x: number;
/**
* Y coordinate
*/
y: number;
};
/**
* Size of the note in the flow editor
*/
size?: {
/**
* Width in pixels
*/
width: number;
/**
* Height in pixels
*/
height: number;
};
/**
* Color of the note (e.g., "yellow", "#ffff00")
*/
color: string;
/**
* Type of note - 'free' for standalone notes, 'group' for notes that group other nodes
*/
type: 'free' | 'group';
/**
* Whether the note is locked and cannot be edited or moved
*/
locked?: boolean;
/**
* For group notes, the IDs of nodes contained within this group
*/
contained_node_ids?: Array<(string)>;
};
/**
* Type of note - 'free' for standalone notes, 'group' for notes that group other nodes
*/
export type type2 = 'free' | 'group';
export type FlowConversation = {
/**
* Unique identifier for the conversation
*/
id: string;
/**
* The workspace ID where the conversation belongs
*/
workspace_id: string;
/**
* Path of the flow this conversation is for
*/
flow_path: string;
/**
* Optional title for the conversation
*/
title?: (string) | null;
/**
* When the conversation was created
*/
created_at: string;
/**
* When the conversation was last updated
*/
updated_at: string;
/**
* Username who created the conversation
*/
created_by: string;
};
export type FlowConversationMessage = {
/**
* Unique identifier for the message
*/
id: string;
/**
* The conversation this message belongs to
*/
conversation_id: string;
/**
* Type of the message
*/
message_type: 'user' | 'assistant' | 'system' | 'tool';
/**
* The message content
*/
content: string;
/**
* Associated job ID if this message came from a flow run
*/
job_id?: (string) | null;
/**
* When the message was created
*/
created_at: string;
/**
* The step name that produced that message
*/
step_name?: string;
/**
* Whether the message is a success
*/
success?: boolean;
};
/**
* Type of the message
*/
export type message_type = 'user' | 'assistant' | 'system' | 'tool';
export type EndpointTool = {
/**
* The tool name/operation ID
*/
name: string;
/**
* Short description of the tool
*/
description: string;
/**
* Detailed instructions for using the tool
*/
instructions: string;
/**
* API endpoint path
*/
path: string;
/**
* HTTP method (GET, POST, etc.)
*/
method: string;
/**
* JSON schema for path parameters
*/
path_params_schema?: {
[key: string]: unknown;
} | null;
/**
* JSON schema for query parameters
*/
query_params_schema?: {
[key: string]: unknown;
} | null;
/**
* JSON schema for request body
*/
body_schema?: {
[key: string]: unknown;
} | null;
};
export type AIProvider = 'openai' | 'azure_openai' | 'anthropic' | 'mistral' | 'deepseek' | 'googleai' | 'groq' | 'openrouter' | 'togetherai' | 'aws_bedrock' | 'customai';
export type GitSyncObjectType = 'script' | 'flow' | 'app' | 'folder' | 'resource' | 'variable' | 'secret' | 'resourcetype' | 'schedule' | 'user' | 'group' | 'trigger' | 'settings' | 'key';
export type AIProviderModel = {
model: string;
provider: AIProvider;
};
export type AIProviderConfig = {
resource_path: string;
models: Array<(string)>;
};
export type AIConfig = {
providers?: {
[key: string]: AIProviderConfig;
};
default_model?: AIProviderModel;
code_completion_model?: AIProviderModel;
custom_prompts?: {
[key: string]: (string);
};
max_tokens_per_model?: {
[key: string]: (number);
};
};
export type Alert = {
name: string;
tags_to_monitor: Array<(string)>;
jobs_num_threshold: number;
alert_cooldown_seconds: number;
alert_time_threshold_seconds: number;
};
export type Configs = {
alerts?: Array<Alert>;
} | null;
export type WorkspaceDependencies = {
id: number;
archived: boolean;
name?: string;
description?: string;
content: string;
language: ScriptLang;
workspace_id: string;
created_at: string;
};
export type NewWorkspaceDependencies = {
workspace_id: string;
language: ScriptLang;
name?: string;
description?: string;
content: string;
};
export type Script = {
workspace_id?: string;
hash: string;
path: string;
/**
* The first element is the direct parent of the script, the second is the parent of the first, etc
*
*/
parent_hashes?: Array<(string)>;
summary: string;
description: string;
content: string;
created_by: string;
created_at: string;
archived: boolean;
schema?: {
[key: string]: unknown;
};
deleted: boolean;
is_template: boolean;
extra_perms: {
[key: string]: (boolean);
};
lock?: string;
lock_error_logs?: string;
language: ScriptLang;
kind: 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor';
starred: boolean;
tag?: string;
has_draft?: boolean;
draft_only?: boolean;
envs?: Array<(string)>;
concurrent_limit?: number;
concurrency_time_window_s?: number;
concurrency_key?: string;
debounce_key?: string;
debounce_delay_s?: number;
debounce_args_to_accumulate?: Array<(string)>;
max_total_debouncing_time?: number;
max_total_debounces_amount?: number;
cache_ttl?: number;
dedicated_worker?: boolean;
ws_error_handler_muted?: boolean;
priority?: number;
restart_unless_cancelled?: boolean;
timeout?: number;
delete_after_use?: boolean;
visible_to_runner_only?: boolean;
no_main_func: boolean;
codebase?: string;
has_preprocessor: boolean;
on_behalf_of_email?: string;
};
export type kind = 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor';
export type NewScript = {
path: string;
parent_hash?: string;
summary: string;
description: string;
content: string;
schema?: {
[key: string]: unknown;
};
is_template?: boolean;
lock?: string;
language: ScriptLang;
kind?: 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor';
tag?: string;
draft_only?: boolean;
envs?: Array<(string)>;
concurrent_limit?: number;
concurrency_time_window_s?: number;
cache_ttl?: number;
cache_ignore_s3_path?: boolean;
dedicated_worker?: boolean;
ws_error_handler_muted?: boolean;
priority?: number;
restart_unless_cancelled?: boolean;
timeout?: number;
delete_after_use?: boolean;
deployment_message?: string;
concurrency_key?: string;
debounce_key?: string;
debounce_delay_s?: number;
debounce_args_to_accumulate?: Array<(string)>;
max_total_debouncing_time?: number;
max_total_debounces_amount?: number;
visible_to_runner_only?: boolean;
no_main_func?: boolean;
codebase?: string;
has_preprocessor?: boolean;
on_behalf_of_email?: string;
assets?: Array<{
path: string;
kind: AssetKind;
access_type?: 'r' | 'w' | 'rw';
alt_access_type?: 'r' | 'w' | 'rw';
}>;
};
export type NewScriptWithDraft = NewScript & {
draft?: NewScript;
hash: string;
};
export type ScriptHistory = {
script_hash: string;
deployment_msg?: string;
};
/**
* The arguments to pass to the script or flow
*/
export type ScriptArgs = {
[key: string]: unknown;
};
export type Input = {
id: string;
name: string;
created_by: string;
created_at: string;
is_public: boolean;
success?: boolean;
};
export type CreateInput = {
name: string;
args: {
[key: string]: unknown;
};
};
export type UpdateInput = {
id: string;
name: string;
is_public: boolean;
};
export type RunnableType = 'ScriptHash' | 'ScriptPath' | 'FlowPath';
export type QueuedJob = {
workspace_id?: string;
id: string;
parent_job?: string;
created_by?: string;
created_at?: string;
started_at?: string;
scheduled_for?: string;
running: boolean;
script_path?: string;
script_hash?: string;
args?: ScriptArgs;
logs?: string;
raw_code?: string;
canceled: boolean;
canceled_by?: string;
canceled_reason?: string;
last_ping?: string;
job_kind: 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlestepflow' | 'flowscript' | 'flownode' | 'appscript' | 'aiagent' | 'unassigned_script' | 'unassigned_flow' | 'unassigned_singlestepflow';
schedule_path?: string;
/**
* The user (u/userfoo) or group (g/groupfoo) whom
* the execution of this script will be permissioned_as and by extension its DT_TOKEN.
*
*/
permissioned_as: string;
flow_status?: FlowStatus;
workflow_as_code_status?: WorkflowStatus;
raw_flow?: FlowValue;
is_flow_step: boolean;
language?: ScriptLang;
email: string;
visible_to_owner: boolean;
mem_peak?: number;
tag: string;
priority?: number;
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
suspend?: number;
preprocessed?: boolean;
worker?: string;
};
export type job_kind = 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlestepflow' | 'flowscript' | 'flownode' | 'appscript' | 'aiagent' | 'unassigned_script' | 'unassigned_flow' | 'unassigned_singlestepflow';
export type CompletedJob = {
workspace_id?: string;
id: string;
parent_job?: string;
created_by: string;
created_at: string;
started_at: string;
completed_at?: string;
duration_ms: number;
success: boolean;
script_path?: string;
script_hash?: string;
args?: ScriptArgs;
result?: unknown;
logs?: string;
deleted?: boolean;
raw_code?: string;
canceled: boolean;
canceled_by?: string;
canceled_reason?: string;
job_kind: 'script' | 'preview' | 'dependencies' | 'flow' | 'flowdependencies' | 'appdependencies' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlestepflow' | 'flowscript' | 'flownode' | 'appscript' | 'aiagent' | 'unassigned_script' | 'unassigned_flow' | 'unassigned_singlestepflow';
schedule_path?: string;
/**
* The user (u/userfoo) or group (g/groupfoo) whom
* the execution of this script will be permissioned_as and by extension its DT_TOKEN.
*
*/
permissioned_as: string;
flow_status?: FlowStatus;
workflow_as_code_status?: WorkflowStatus;
raw_flow?: FlowValue;
is_flow_step: boolean;
language?: ScriptLang;
is_skipped: boolean;
email: string;
visible_to_owner: boolean;
mem_peak?: number;
tag: string;
priority?: number;
labels?: Array<(string)>;
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
preprocessed?: boolean;
worker?: string;
};
/**
* Completed job with full data for export/import operations
*/
export type ExportableCompletedJob = {
id: string;
parent_job?: string;
created_by: string;
created_at: string;
started_at?: string;
completed_at?: string;
duration_ms?: number;
script_path?: string;
script_hash?: string;
/**
* Full job arguments without size restrictions
*/
args?: {
[key: string]: unknown;
};
/**
* Full job result without size restrictions
*/
result?: {
[key: string]: unknown;
};
/**
* Complete job logs from v2_job table
*/
logs?: string;
raw_code?: string;
raw_lock?: string;
canceled_by?: string;
canceled_reason?: string;
job_kind: 'script' | 'preview' | 'dependencies' | 'flow' | 'flowdependencies' | 'appdependencies' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlestepflow' | 'flowscript' | 'flownode' | 'appscript' | 'aiagent' | 'unassigned_script' | 'unassigned_flow' | 'unassigned_singlestepflow';
/**
* Trigger path for the job (replaces schedule_path)
*/
trigger?: string;
trigger_kind?: 'webhook' | 'http' | 'websocket' | 'kafka' | 'email' | 'nats' | 'schedule' | 'app' | 'ui' | 'postgres' | 'sqs' | 'gcp';
permissioned_as: string;
permissioned_as_email?: string;
/**
* Flow status from v2_job_status table
*/
flow_status?: {
[key: string]: unknown;
};
workflow_as_code_status?: {
[key: string]: unknown;
};
raw_flow?: {
[key: string]: unknown;
};
is_flow_step?: boolean;
language?: ScriptLang;
is_skipped?: boolean;
email: string;
visible_to_owner: boolean;
mem_peak?: number;
tag?: string;
priority?: number;
labels?: Array<(string)>;
same_worker?: boolean;
flow_step_id?: string;
flow_innermost_root_job?: string;
concurrent_limit?: number;
concurrency_time_window_s?: number;
timeout?: number;
cache_ttl?: number;
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
preprocessed?: boolean;
worker?: string;
/**
* Actual job status from database
*/
status?: string;
};
export type trigger_kind = 'webhook' | 'http' | 'websocket' | 'kafka' | 'email' | 'nats' | 'schedule' | 'app' | 'ui' | 'postgres' | 'sqs' | 'gcp';
/**
* Queued job with full data for export/import operations
*/
export type ExportableQueuedJob = {
id: string;
parent_job?: string;
created_by: string;
created_at: string;
started_at?: string;
scheduled_for?: string;
script_path?: string;
script_hash?: string;
/**
* Full job arguments without size restrictions
*/
args?: {
[key: string]: unknown;
};
/**
* Complete job logs from v2_job table
*/
logs?: string;
raw_code?: string;
raw_lock?: string;
canceled_by?: string;
canceled_reason?: string;
job_kind: 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlestepflow' | 'flowscript' | 'flownode' | 'appscript' | 'aiagent' | 'unassigned_script' | 'unassigned_flow' | 'unassigned_singlestepflow';
/**
* Trigger path for the job (replaces schedule_path)
*/
trigger?: string;
trigger_kind?: 'webhook' | 'http' | 'websocket' | 'kafka' | 'email' | 'nats' | 'schedule' | 'app' | 'ui' | 'postgres' | 'sqs' | 'gcp';
permissioned_as: string;
permissioned_as_email?: string;
/**
* Flow status from v2_job_status table
*/
flow_status?: {
[key: string]: unknown;
};
workflow_as_code_status?: {
[key: string]: unknown;
};
raw_flow?: {
[key: string]: unknown;
};
is_flow_step?: boolean;
language?: ScriptLang;
email: string;
visible_to_owner: boolean;
mem_peak?: number;
tag?: string;
priority?: number;
labels?: Array<(string)>;
same_worker?: boolean;
flow_step_id?: string;
flow_innermost_root_job?: string;
concurrent_limit?: number;
concurrency_time_window_s?: number;
timeout?: number;
cache_ttl?: number;
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
preprocessed?: boolean;
suspend?: number;
suspend_until?: string;
};
export type ObscuredJob = {
typ?: string;
started_at?: string;
duration_ms?: number;
};
export type Job = (CompletedJob & {
type?: 'CompletedJob';
}) | (QueuedJob & {
type?: 'QueuedJob';
});
export type type3 = 'CompletedJob';
export type User = {
email: string;
username: string;
is_admin: boolean;
name?: string;
is_super_admin: boolean;
created_at: string;
operator: boolean;
disabled: boolean;
groups?: Array<(string)>;
folders: Array<(string)>;
folders_owners: Array<(string)>;
added_via?: ((UserSource) | null);
};
export type UserSource = {
/**
* How the user was added to the workspace
*/
source: 'domain' | 'instance_group' | 'manual';
/**
* The domain used for auto-invite (when source is 'domain')
*/
domain?: string;
/**
* The instance group name (when source is 'instance_group')
*/
group?: string;
};
/**
* How the user was added to the workspace
*/
export type source = 'domain' | 'instance_group' | 'manual';
export type UserUsage = {
email?: string;
executions?: number;
};
export type Login = {
email: string;
password: string;
};
export type EditWorkspaceUser = {
is_admin?: boolean;
operator?: boolean;
disabled?: boolean;
};
export type TruncatedToken = {
label?: string;
expiration?: string;
token_prefix: string;
created_at: string;
last_used_at: string;
scopes?: Array<(string)>;
email?: string;
};
export type NewToken = {
label?: string;
expiration?: string;
scopes?: Array<(string)>;
workspace_id?: string;
};
export type NewTokenImpersonate = {
label?: string;
expiration?: string;
impersonate_email: string;
workspace_id?: string;
};
export type ListableVariable = {
workspace_id: string;
path: string;
value?: string;
is_secret: boolean;
description?: string;
account?: number;
is_oauth?: boolean;
extra_perms: {
[key: string]: (boolean);
};
is_expired?: boolean;
refresh_error?: string;
is_linked?: boolean;
is_refreshed?: boolean;
expires_at?: string;
};
export type ContextualVariable = {
name: string;
value: string;
description: string;
is_custom: boolean;
};
export type CreateVariable = {
/**
* The path to the variable
*/
path: string;
/**
* The value of the variable
*/
value: string;
/**
* Whether the variable is a secret
*/
is_secret: boolean;
/**
* The description of the variable
*/
description: string;
/**
* The account identifier
*/
account?: number;
/**
* Whether the variable is an OAuth variable
*/
is_oauth?: boolean;
/**
* The expiration date of the variable
*/
expires_at?: string;
};
export type EditVariable = {
/**
* The path to the variable
*/
path?: string;
/**
* The new value of the variable
*/
value?: string;
/**
* Whether the variable is a secret
*/
is_secret?: boolean;
/**
* The new description of the variable
*/
description?: string;
};
export type AuditLog = {
workspace_id: string;
id: number;
timestamp: string;
username: string;
operation: 'jobs.run' | 'jobs.run.script' | 'jobs.run.preview' | 'jobs.run.flow' | 'jobs.run.flow_preview' | 'jobs.run.script_hub' | 'jobs.run.dependencies' | 'jobs.run.identity' | 'jobs.run.noop' | 'jobs.flow_dependencies' | 'jobs' | 'jobs.cancel' | 'jobs.force_cancel' | 'jobs.disapproval' | 'jobs.delete' | 'account.delete' | 'ai.request' | 'resources.create' | 'resources.update' | 'resources.delete' | 'resource_types.create' | 'resource_types.update' | 'resource_types.delete' | 'schedule.create' | 'schedule.setenabled' | 'schedule.edit' | 'schedule.delete' | 'scripts.create' | 'scripts.update' | 'scripts.archive' | 'scripts.delete' | 'users.create' | 'users.delete' | 'users.update' | 'users.login' | 'users.login_failure' | 'users.logout' | 'users.accept_invite' | 'users.decline_invite' | 'users.token.create' | 'users.token.delete' | 'users.add_to_workspace' | 'users.add_global' | 'users.setpassword' | 'users.impersonate' | 'users.leave_workspace' | 'oauth.login' | 'oauth.login_failure' | 'oauth.signup' | 'variables.create' | 'variables.delete' | 'variables.update' | 'flows.create' | 'flows.update' | 'flows.delete' | 'flows.archive' | 'apps.create' | 'apps.update' | 'apps.delete' | 'folder.create' | 'folder.update' | 'folder.delete' | 'folder.add_owner' | 'folder.remove_owner' | 'group.create' | 'group.delete' | 'group.edit' | 'group.adduser' | 'group.removeuser' | 'igroup.create' | 'igroup.delete' | 'igroup.adduser' | 'igroup.removeuser' | 'variables.decrypt_secret' | 'workspaces.edit_command_script' | 'workspaces.edit_deploy_to' | 'workspaces.edit_auto_invite_domain' | 'workspaces.edit_webhook' | 'workspaces.edit_copilot_config' | 'workspaces.edit_error_handler' | 'workspaces.create' | 'workspaces.update' | 'workspaces.archive' | 'workspaces.unarchive' | 'workspaces.delete';
action_kind: 'Created' | 'Updated' | 'Delete' | 'Execute';
resource?: string;
parameters?: {
[key: string]: unknown;
};
span?: string;
};
export type operation = 'jobs.run' | 'jobs.run.script' | 'jobs.run.preview' | 'jobs.run.flow' | 'jobs.run.flow_preview' | 'jobs.run.script_hub' | 'jobs.run.dependencies' | 'jobs.run.identity' | 'jobs.run.noop' | 'jobs.flow_dependencies' | 'jobs' | 'jobs.cancel' | 'jobs.force_cancel' | 'jobs.disapproval' | 'jobs.delete' | 'account.delete' | 'ai.request' | 'resources.create' | 'resources.update' | 'resources.delete' | 'resource_types.create' | 'resource_types.update' | 'resource_types.delete' | 'schedule.create' | 'schedule.setenabled' | 'schedule.edit' | 'schedule.delete' | 'scripts.create' | 'scripts.update' | 'scripts.archive' | 'scripts.delete' | 'users.create' | 'users.delete' | 'users.update' | 'users.login' | 'users.login_failure' | 'users.logout' | 'users.accept_invite' | 'users.decline_invite' | 'users.token.create' | 'users.token.delete' | 'users.add_to_workspace' | 'users.add_global' | 'users.setpassword' | 'users.impersonate' | 'users.leave_workspace' | 'oauth.login' | 'oauth.login_failure' | 'oauth.signup' | 'variables.create' | 'variables.delete' | 'variables.update' | 'flows.create' | 'flows.update' | 'flows.delete' | 'flows.archive' | 'apps.create' | 'apps.update' | 'apps.delete' | 'folder.create' | 'folder.update' | 'folder.delete' | 'folder.add_owner' | 'folder.remove_owner' | 'group.create' | 'group.delete' | 'group.edit' | 'group.adduser' | 'group.removeuser' | 'igroup.create' | 'igroup.delete' | 'igroup.adduser' | 'igroup.removeuser' | 'variables.decrypt_secret' | 'workspaces.edit_command_script' | 'workspaces.edit_deploy_to' | 'workspaces.edit_auto_invite_domain' | 'workspaces.edit_webhook' | 'workspaces.edit_copilot_config' | 'workspaces.edit_error_handler' | 'workspaces.create' | 'workspaces.update' | 'workspaces.archive' | 'workspaces.unarchive' | 'workspaces.delete';
export type action_kind = 'Created' | 'Updated' | 'Delete' | 'Execute';
export type MainArgSignature = {
type: 'Valid' | 'Invalid';
error: string;
star_args: boolean;
star_kwargs?: boolean;
args: Array<{
name: string;
typ: ('float' | 'int' | 'bool' | 'email' | 'unknown' | 'bytes' | 'dict' | 'datetime' | 'sql' | {
resource: (string) | null;
} | {
str: Array<(string)> | null;
} | {
object: {
name?: string;
props?: Array<{
key: string;
typ: ('float' | 'int' | 'bool' | 'email' | 'unknown' | 'bytes' | 'dict' | 'datetime' | 'sql' | {
str: unknown;
});
}>;
};
} | {
list: (('float' | 'int' | 'bool' | 'email' | 'unknown' | 'bytes' | 'dict' | 'datetime' | 'sql' | {
str: unknown;
}) | null);
});
has_default?: boolean;
default?: unknown;
}>;
no_main_func: (boolean) | null;
has_preprocessor: (boolean) | null;
};
export type type4 = 'Valid' | 'Invalid';
export type ScriptLang = 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp' | 'nu' | 'java' | 'ruby' | 'duckdb';
export type Preview = {
/**
* The code to run
*/
content?: string;
/**
* The path to the script
*/
path?: string;
/**
* The hash of the script
*/
script_hash?: string;
args: ScriptArgs;
language?: ScriptLang;
tag?: string;
kind?: 'code' | 'identity' | 'http';
dedicated_worker?: boolean;
lock?: string;
};
export type kind2 = 'code' | 'identity' | 'http';
export type PreviewInline = {
/**
* The code to run
*/
content: string;
args: ScriptArgs;
language: ScriptLang;
};
export type WorkflowTask = {
args: ScriptArgs;
};
export type WorkflowStatusRecord = {
[key: string]: WorkflowStatus;
};
export type WorkflowStatus = {
scheduled_for?: string;
started_at?: string;
duration_ms?: number;
name?: string;
};
export type CreateResource = {
/**
* The path to the resource
*/
path: string;
value: unknown;
/**
* The description of the resource
*/
description?: string;
/**
* The resource_type associated with the resource
*/
resource_type: string;
};
export type EditResource = {
/**
* The path to the resource
*/
path?: string;
/**
* The new description of the resource
*/
description?: string;
value?: unknown;
/**
* The new resource_type to be associated with the resource
*/
resource_type?: string;
};
export type Resource = {
workspace_id?: string;
path: string;
description?: string;
resource_type: string;
value?: unknown;
is_oauth: boolean;
extra_perms?: {
[key: string]: (boolean);
};
created_by?: string;
edited_at?: string;
};
export type ListableResource = {
workspace_id?: string;
path: string;
description?: string;
resource_type: string;
value?: unknown;
is_oauth: boolean;
extra_perms?: {
[key: string]: (boolean);
};
is_expired?: boolean;
refresh_error?: string;
is_linked: boolean;
is_refreshed: boolean;
account?: number;
created_by?: string;
edited_at?: string;
};
export type ResourceType = {
workspace_id?: string;
name: string;
schema?: unknown;
description?: string;
created_by?: string;
edited_at?: string;
format_extension?: string;
};
export type EditResourceType = {
schema?: unknown;
description?: string;
};
export type Schedule = {
path: string;
edited_by: string;
edited_at: string;
schedule: string;
timezone: string;
enabled: boolean;
script_path: string;
is_flow: boolean;
args?: ScriptArgs;
extra_perms: {
[key: string]: (boolean);
};
email: string;
error?: string;
on_failure?: string;
on_failure_times?: number;
on_failure_exact?: boolean;
on_failure_extra_args?: ScriptArgs;
on_recovery?: string;
on_recovery_times?: number;
on_recovery_extra_args?: ScriptArgs;
on_success?: string;
on_success_extra_args?: ScriptArgs;
ws_error_handler_muted?: boolean;
retry?: Retry;
summary?: string;
description?: string;
no_flow_overlap?: boolean;
tag?: string;
paused_until?: string;
cron_version?: string;
/**
* Path to a script that validates scheduled datetimes. Receives scheduled_for datetime and returns boolean.
*/
dynamic_skip?: string;
};
export type ScheduleWJobs = Schedule & {
jobs?: Array<{
id: string;
success: boolean;
duration_ms: number;
}>;
};
export type ErrorHandler = 'custom' | 'slack' | 'teams' | 'email';
export type NewSchedule = {
/**
* The path where the schedule will be created
*/
path: string;
/**
* The cron schedule to trigger the script or flow. Should include seconds.
*/
schedule: string;
/**
* The timezone to use for the cron schedule
*/
timezone: string;
/**
* The path to the script or flow to trigger
*/
script_path: string;
/**
* Whether the schedule is for a flow
*/
is_flow: boolean;
/**
* The arguments to pass to the script or flow
*/
args: ScriptArgs;
/**
* Whether the schedule is enabled
*/
enabled?: boolean;
/**
* The path to the script or flow to trigger on failure
*/
on_failure?: string;
/**
* The number of times to retry on failure
*/
on_failure_times?: number;
/**
* Whether the schedule should only run on the exact time
*/
on_failure_exact?: boolean;
/**
* The arguments to pass to the script or flow on failure
*/
on_failure_extra_args?: ScriptArgs;
/**
* The path to the script or flow to trigger on recovery
*/
on_recovery?: string;
/**
* The number of times to retry on recovery
*/
on_recovery_times?: number;
/**
* The arguments to pass to the script or flow on recovery
*/
on_recovery_extra_args?: Scrip