Skip to main content

windmill_api/models/
flow_module_tool.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.896.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// FlowModuleTool : A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct FlowModuleTool {
17    #[serde(rename = "input_transforms")]
18    pub input_transforms: Box<models::AiDecisionInputTransforms>,
19    /// The script source code. Should export a 'main' function
20    #[serde(rename = "content")]
21    pub content: String,
22    /// Programming language for this script
23    #[serde(rename = "language")]
24    pub language: Language,
25    /// Path to the flow in the workspace (e.g., 'f/flows/process_user')
26    #[serde(rename = "path")]
27    pub path: String,
28    /// Lock file content for dependencies
29    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
30    pub lock: Option<String>,
31    #[serde(rename = "type")]
32    pub r#type: Type,
33    /// Worker group tag for execution routing. If not set, the step runs on the flow's tag (default `flow`)
34    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
35    pub tag: Option<String>,
36    /// Maximum concurrent executions of this script
37    #[serde(rename = "concurrent_limit", skip_serializing_if = "Option::is_none")]
38    pub concurrent_limit: Option<f64>,
39    /// Time window for concurrent_limit
40    #[serde(rename = "concurrency_time_window_s", skip_serializing_if = "Option::is_none")]
41    pub concurrency_time_window_s: Option<f64>,
42    /// What a run of this step does when its concurrency limit is reached. `queue` (default) re-queues it to a later slot, `fail` ends it immediately as failed.
43    #[serde(rename = "on_concurrency_limit", skip_serializing_if = "Option::is_none")]
44    pub on_concurrency_limit: Option<OnConcurrencyLimit>,
45    /// Custom key for grouping concurrent executions
46    #[serde(rename = "custom_concurrency_key", skip_serializing_if = "Option::is_none")]
47    pub custom_concurrency_key: Option<String>,
48    /// If true, this script is a trigger that can start the flow
49    #[serde(rename = "is_trigger", skip_serializing_if = "Option::is_none")]
50    pub is_trigger: Option<bool>,
51    /// External resources this script accesses (S3 objects, resources, etc.)
52    #[serde(rename = "assets", skip_serializing_if = "Option::is_none")]
53    pub assets: Option<Vec<models::RawScriptAssetsInner>>,
54    /// Optional specific version hash of the script to use
55    #[serde(rename = "hash", skip_serializing_if = "Option::is_none")]
56    pub hash: Option<String>,
57    /// Override the subflow's worker group tag. Its steps run on this tag unless the subflow sets preserve_step_tags
58    #[serde(rename = "tag_override", skip_serializing_if = "Option::is_none")]
59    pub tag_override: Option<String>,
60    /// Steps to execute in each iteration
61    #[serde(rename = "modules")]
62    pub modules: Vec<models::FlowModule>,
63    #[serde(rename = "iterator")]
64    pub iterator: Box<models::InputTransform>,
65    /// If true, iteration failures don't stop the loop. Failed iterations return null
66    #[serde(rename = "skip_failures")]
67    pub skip_failures: bool,
68    #[serde(rename = "failure_threshold", skip_serializing_if = "Option::is_none")]
69    pub failure_threshold: Option<Box<models::InputTransform>>,
70    /// If true, the agent can execute multiple tool calls in parallel
71    #[serde(rename = "parallel", skip_serializing_if = "Option::is_none")]
72    pub parallel: Option<bool>,
73    #[serde(rename = "parallelism", skip_serializing_if = "Option::is_none")]
74    pub parallelism: Option<Box<models::InputTransform>>,
75    #[serde(rename = "squash", skip_serializing_if = "Option::is_none")]
76    pub squash: Option<bool>,
77    #[serde(rename = "iteration_label", skip_serializing_if = "Option::is_none")]
78    pub iteration_label: Option<Box<models::InputTransform>>,
79    /// Maximum number of iterations. Checked after each iteration; when reached and stop_after_if did not stop the loop, the loop fails with an error named 'LoopExhausted'
80    #[serde(rename = "max_iterations", skip_serializing_if = "Option::is_none")]
81    pub max_iterations: Option<i32>,
82    /// Maximum wall-clock seconds since the first iteration started, checked after each iteration. A running iteration is not interrupted, so the loop can exceed the limit by up to one iteration; the timeout of the body's steps caps an iteration. When reached and stop_after_if did not stop the loop, the loop fails with an error named 'LoopExhausted'
83    #[serde(rename = "max_duration_secs", skip_serializing_if = "Option::is_none")]
84    pub max_duration_secs: Option<i32>,
85    /// Array of branches that all execute (either in parallel or sequentially)
86    #[serde(rename = "branches")]
87    pub branches: Vec<models::BranchAllBranchesInner>,
88    /// Steps to execute if no branch expressions match
89    #[serde(rename = "default")]
90    pub default: Vec<models::FlowModule>,
91    /// If true, marks this as a flow identity (special handling)
92    #[serde(rename = "flow", skip_serializing_if = "Option::is_none")]
93    pub flow: Option<bool>,
94    /// Array of tools the agent can use. The agent decides which tools to call based on the task
95    #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
96    pub tools: Option<Vec<models::AgentTool>>,
97    /// If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled.
98    #[serde(rename = "omit_output_from_conversation", skip_serializing_if = "Option::is_none")]
99    pub omit_output_from_conversation: Option<bool>,
100    /// Path of a reusable `ai_agent` resource (hybrid linking). When set, the agent brain config (provider/model/system prompt/etc.) and tool set are resolved at runtime from that resource; the module's input_transforms then only carry the flow-local inputs (user_message, user_attachments, enabled_tools and the history inputs memory_id and previous_messages) and, optionally, the `model` and `reasoning_effort` overrides of what the agent saved. 
101    #[serde(rename = "agent", skip_serializing_if = "Option::is_none")]
102    pub agent: Option<String>,
103    /// Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the referenced agent's tools to this flow's context (flow_input/results) without mutating the shared resource; overlaid onto the tools' input_transforms at runtime — including when `agent` is unset, since a step forked for editing keeps these overrides until it is saved back or unlinked. 
104    #[serde(rename = "tool_inputs", skip_serializing_if = "Option::is_none")]
105    pub tool_inputs: Option<std::collections::HashMap<String, std::collections::HashMap<String, models::InputTransform>>>,
106    #[serde(rename = "tool_type")]
107    pub tool_type: ToolType,
108}
109
110impl FlowModuleTool {
111    /// A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
112    pub fn new(input_transforms: models::AiDecisionInputTransforms, content: String, language: Language, path: String, r#type: Type, modules: Vec<models::FlowModule>, iterator: models::InputTransform, skip_failures: bool, branches: Vec<models::BranchAllBranchesInner>, default: Vec<models::FlowModule>, tool_type: ToolType) -> FlowModuleTool {
113        FlowModuleTool {
114            input_transforms: Box::new(input_transforms),
115            content,
116            language,
117            path,
118            lock: None,
119            r#type,
120            tag: None,
121            concurrent_limit: None,
122            concurrency_time_window_s: None,
123            on_concurrency_limit: None,
124            custom_concurrency_key: None,
125            is_trigger: None,
126            assets: None,
127            hash: None,
128            tag_override: None,
129            modules,
130            iterator: Box::new(iterator),
131            skip_failures,
132            failure_threshold: None,
133            parallel: None,
134            parallelism: None,
135            squash: None,
136            iteration_label: None,
137            max_iterations: None,
138            max_duration_secs: None,
139            branches,
140            default,
141            flow: None,
142            tools: None,
143            omit_output_from_conversation: None,
144            agent: None,
145            tool_inputs: None,
146            tool_type,
147        }
148    }
149}
150/// Programming language for this script
151#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
152pub enum Language {
153    #[serde(rename = "deno")]
154    Deno,
155    #[serde(rename = "bun")]
156    Bun,
157    #[serde(rename = "bunnative")]
158    Bunnative,
159    #[serde(rename = "python3")]
160    Python3,
161    #[serde(rename = "go")]
162    Go,
163    #[serde(rename = "bash")]
164    Bash,
165    #[serde(rename = "powershell")]
166    Powershell,
167    #[serde(rename = "postgresql")]
168    Postgresql,
169    #[serde(rename = "mysql")]
170    Mysql,
171    #[serde(rename = "bigquery")]
172    Bigquery,
173    #[serde(rename = "snowflake")]
174    Snowflake,
175    #[serde(rename = "mssql")]
176    Mssql,
177    #[serde(rename = "oracledb")]
178    Oracledb,
179    #[serde(rename = "graphql")]
180    Graphql,
181    #[serde(rename = "nativets")]
182    Nativets,
183    #[serde(rename = "php")]
184    Php,
185    #[serde(rename = "rust")]
186    Rust,
187    #[serde(rename = "ansible")]
188    Ansible,
189    #[serde(rename = "csharp")]
190    Csharp,
191    #[serde(rename = "nu")]
192    Nu,
193    #[serde(rename = "java")]
194    Java,
195    #[serde(rename = "ruby")]
196    Ruby,
197    #[serde(rename = "rlang")]
198    Rlang,
199    #[serde(rename = "duckdb")]
200    Duckdb,
201}
202
203impl Default for Language {
204    fn default() -> Language {
205        Self::Deno
206    }
207}
208/// 
209#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
210pub enum Type {
211    #[serde(rename = "aidecision")]
212    Aidecision,
213}
214
215impl Default for Type {
216    fn default() -> Type {
217        Self::Aidecision
218    }
219}
220/// What a run of this step does when its concurrency limit is reached. `queue` (default) re-queues it to a later slot, `fail` ends it immediately as failed.
221#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
222pub enum OnConcurrencyLimit {
223    #[serde(rename = "queue")]
224    Queue,
225    #[serde(rename = "fail")]
226    Fail,
227}
228
229impl Default for OnConcurrencyLimit {
230    fn default() -> OnConcurrencyLimit {
231        Self::Queue
232    }
233}
234/// 
235#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
236pub enum ToolType {
237    #[serde(rename = "flowmodule")]
238    Flowmodule,
239}
240
241impl Default for ToolType {
242    fn default() -> ToolType {
243        Self::Flowmodule
244    }
245}
246