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.864.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 script's default worker group tag
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    /// If true, the agent can execute multiple tool calls in parallel
69    #[serde(rename = "parallel", skip_serializing_if = "Option::is_none")]
70    pub parallel: Option<bool>,
71    #[serde(rename = "parallelism", skip_serializing_if = "Option::is_none")]
72    pub parallelism: Option<Box<models::InputTransform>>,
73    #[serde(rename = "squash", skip_serializing_if = "Option::is_none")]
74    pub squash: Option<bool>,
75    /// 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'
76    #[serde(rename = "max_iterations", skip_serializing_if = "Option::is_none")]
77    pub max_iterations: Option<i32>,
78    /// 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'
79    #[serde(rename = "max_duration_secs", skip_serializing_if = "Option::is_none")]
80    pub max_duration_secs: Option<i32>,
81    /// Array of branches that all execute (either in parallel or sequentially)
82    #[serde(rename = "branches")]
83    pub branches: Vec<models::BranchAllBranchesInner>,
84    /// Steps to execute if no branch expressions match
85    #[serde(rename = "default")]
86    pub default: Vec<models::FlowModule>,
87    /// If true, marks this as a flow identity (special handling)
88    #[serde(rename = "flow", skip_serializing_if = "Option::is_none")]
89    pub flow: Option<bool>,
90    /// Array of tools the agent can use. The agent decides which tools to call based on the task
91    #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
92    pub tools: Option<Vec<models::AgentTool>>,
93    /// If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled.
94    #[serde(rename = "omit_output_from_conversation", skip_serializing_if = "Option::is_none")]
95    pub omit_output_from_conversation: Option<bool>,
96    /// 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. 
97    #[serde(rename = "agent", skip_serializing_if = "Option::is_none")]
98    pub agent: Option<String>,
99    /// 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. 
100    #[serde(rename = "tool_inputs", skip_serializing_if = "Option::is_none")]
101    pub tool_inputs: Option<std::collections::HashMap<String, std::collections::HashMap<String, models::InputTransform>>>,
102    #[serde(rename = "tool_type")]
103    pub tool_type: ToolType,
104}
105
106impl FlowModuleTool {
107    /// A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
108    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 {
109        FlowModuleTool {
110            input_transforms: Box::new(input_transforms),
111            content,
112            language,
113            path,
114            lock: None,
115            r#type,
116            tag: None,
117            concurrent_limit: None,
118            concurrency_time_window_s: None,
119            on_concurrency_limit: None,
120            custom_concurrency_key: None,
121            is_trigger: None,
122            assets: None,
123            hash: None,
124            tag_override: None,
125            modules,
126            iterator: Box::new(iterator),
127            skip_failures,
128            parallel: None,
129            parallelism: None,
130            squash: None,
131            max_iterations: None,
132            max_duration_secs: None,
133            branches,
134            default,
135            flow: None,
136            tools: None,
137            omit_output_from_conversation: None,
138            agent: None,
139            tool_inputs: None,
140            tool_type,
141        }
142    }
143}
144/// Programming language for this script
145#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
146pub enum Language {
147    #[serde(rename = "deno")]
148    Deno,
149    #[serde(rename = "bun")]
150    Bun,
151    #[serde(rename = "bunnative")]
152    Bunnative,
153    #[serde(rename = "python3")]
154    Python3,
155    #[serde(rename = "go")]
156    Go,
157    #[serde(rename = "bash")]
158    Bash,
159    #[serde(rename = "powershell")]
160    Powershell,
161    #[serde(rename = "postgresql")]
162    Postgresql,
163    #[serde(rename = "mysql")]
164    Mysql,
165    #[serde(rename = "bigquery")]
166    Bigquery,
167    #[serde(rename = "snowflake")]
168    Snowflake,
169    #[serde(rename = "mssql")]
170    Mssql,
171    #[serde(rename = "oracledb")]
172    Oracledb,
173    #[serde(rename = "graphql")]
174    Graphql,
175    #[serde(rename = "nativets")]
176    Nativets,
177    #[serde(rename = "php")]
178    Php,
179    #[serde(rename = "rust")]
180    Rust,
181    #[serde(rename = "ansible")]
182    Ansible,
183    #[serde(rename = "csharp")]
184    Csharp,
185    #[serde(rename = "nu")]
186    Nu,
187    #[serde(rename = "java")]
188    Java,
189    #[serde(rename = "ruby")]
190    Ruby,
191    #[serde(rename = "rlang")]
192    Rlang,
193    #[serde(rename = "duckdb")]
194    Duckdb,
195}
196
197impl Default for Language {
198    fn default() -> Language {
199        Self::Deno
200    }
201}
202/// 
203#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
204pub enum Type {
205    #[serde(rename = "aidecision")]
206    Aidecision,
207}
208
209impl Default for Type {
210    fn default() -> Type {
211        Self::Aidecision
212    }
213}
214/// 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.
215#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
216pub enum OnConcurrencyLimit {
217    #[serde(rename = "queue")]
218    Queue,
219    #[serde(rename = "fail")]
220    Fail,
221}
222
223impl Default for OnConcurrencyLimit {
224    fn default() -> OnConcurrencyLimit {
225        Self::Queue
226    }
227}
228/// 
229#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
230pub enum ToolType {
231    #[serde(rename = "flowmodule")]
232    Flowmodule,
233}
234
235impl Default for ToolType {
236    fn default() -> ToolType {
237        Self::Flowmodule
238    }
239}
240