windmill-cli 1.819.0 → 1.820.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/esm/main.js +1020 -58
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -16766,7 +16766,7 @@ var init_OpenAPI = __esm(() => {
16766
16766
  PASSWORD: undefined,
16767
16767
  TOKEN: getEnv3("WM_TOKEN"),
16768
16768
  USERNAME: undefined,
16769
- VERSION: "1.819.0",
16769
+ VERSION: "1.820.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -17203,9 +17203,21 @@ var getAuditLog = (data) => {
17203
17203
  path: {
17204
17204
  workspace: data.workspace
17205
17205
  },
17206
+ query: {
17207
+ background: data.background
17208
+ },
17206
17209
  body: data.requestBody,
17207
17210
  mediaType: "application/json"
17208
17211
  });
17212
+ }, getForkCreationStatus = (data) => {
17213
+ return request(OpenAPI, {
17214
+ method: "GET",
17215
+ url: "/w/{workspace}/workspaces/fork_creation_status/{creation_id}",
17216
+ path: {
17217
+ workspace: data.workspace,
17218
+ creation_id: data.creationId
17219
+ }
17220
+ });
17209
17221
  }, existsWorkspace = (data) => {
17210
17222
  return request(OpenAPI, {
17211
17223
  method: "POST",
@@ -18402,7 +18414,10 @@ var getAuditLog = (data) => {
18402
18414
  memory_id: data.memoryId
18403
18415
  },
18404
18416
  body: data.requestBody,
18405
- mediaType: "application/json"
18417
+ mediaType: "application/json",
18418
+ errors: {
18419
+ 409: 'Chat-enabled flow only: the conversation named by `memory_id` is still answering a message. The body is JSON: `{ "error": string, "running_turn": { "job_id", "user_seq" } }`.'
18420
+ }
18406
18421
  });
18407
18422
  }, batchReRunJobs = (data) => {
18408
18423
  return request(OpenAPI, {
@@ -18464,7 +18479,10 @@ var getAuditLog = (data) => {
18464
18479
  memory_id: data.memoryId
18465
18480
  },
18466
18481
  body: data.requestBody,
18467
- mediaType: "application/json"
18482
+ mediaType: "application/json",
18483
+ errors: {
18484
+ 409: 'Chat-enabled flow only: the conversation named by `memory_id` is still answering a message. The body is JSON: `{ "error": string, "running_turn": { "job_id", "user_seq" } }`.'
18485
+ }
18468
18486
  });
18469
18487
  }, listQueue = (data) => {
18470
18488
  return request(OpenAPI, {
@@ -20023,7 +20041,7 @@ var init_auth = __esm(async () => {
20023
20041
  });
20024
20042
 
20025
20043
  // src/core/constants.ts
20026
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.819.0";
20044
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.820.0";
20027
20045
 
20028
20046
  // src/utils/resource_folders.ts
20029
20047
  import { existsSync } from "node:fs";
@@ -21381,6 +21399,34 @@ var init_conf = __esm(async () => {
21381
21399
 
21382
21400
  // src/commands/workspace/fork.ts
21383
21401
  import process10 from "node:process";
21402
+ async function waitForForkCreation(parentWorkspace, creationId) {
21403
+ let failingSince;
21404
+ let lastStep;
21405
+ while (true) {
21406
+ let result;
21407
+ try {
21408
+ result = await getForkCreationStatus({
21409
+ workspace: parentWorkspace,
21410
+ creationId
21411
+ });
21412
+ failingSince = undefined;
21413
+ } catch (e) {
21414
+ failingSince ??= Date.now();
21415
+ if (Date.now() - failingSince >= 3 * 60 * 1000)
21416
+ throw e;
21417
+ }
21418
+ if (result?.status === "running" && result.step && result.step !== lastStep) {
21419
+ lastStep = result.step;
21420
+ info(colors.gray(`${lastStep}...`));
21421
+ }
21422
+ if (result?.status === "completed")
21423
+ return;
21424
+ if (result?.status === "failed") {
21425
+ throw new Error(result.error ?? "Unknown error");
21426
+ }
21427
+ await new Promise((resolve) => setTimeout(resolve, 1500));
21428
+ }
21429
+ }
21384
21430
  async function createWorkspaceFork2(opts, workspaceName, workspaceId = undefined) {
21385
21431
  if (!isGitRepository()) {
21386
21432
  throw new Error("You can only create forks within a git repo. Forks are tracked with git and synced to your instance with the git sync workflow.");
@@ -21584,8 +21630,9 @@ Found ${datatables.length} datatable(s):`);
21584
21630
  throw e;
21585
21631
  }
21586
21632
  try {
21587
- const result = await createWorkspaceFork({
21633
+ const response = await createWorkspaceFork({
21588
21634
  workspace: workspace.workspaceId,
21635
+ background: true,
21589
21636
  requestBody: {
21590
21637
  id: trueWorkspaceId,
21591
21638
  name: opts.createWorkspaceName ?? workspaceName ?? trueWorkspaceId,
@@ -21593,9 +21640,12 @@ Found ${datatables.length} datatable(s):`);
21593
21640
  forked_datatables: forkedDatatables
21594
21641
  }
21595
21642
  });
21596
- info(colors.green(`✅ ${result}`));
21643
+ if (!response.startsWith("Created forked workspace")) {
21644
+ await waitForForkCreation(workspace.workspaceId, response);
21645
+ }
21646
+ info(colors.green(`✅ Created forked workspace ${trueWorkspaceId}`));
21597
21647
  } catch (error2) {
21598
- error(colors.red(`Failed to create forked workspace: ${error2.message}`));
21648
+ error(colors.red(`Failed to create forked workspace: ${apiErrorMessage(error2) ?? error2.message}`));
21599
21649
  throw error2;
21600
21650
  }
21601
21651
  const newBranchName = `${WM_FORK_PREFIX}/${clonedBranchName}/${workspaceId}`;
@@ -21756,6 +21806,7 @@ var init_fork = __esm(async () => {
21756
21806
  init_input(),
21757
21807
  init_workspace(),
21758
21808
  init_git(),
21809
+ init_utils(),
21759
21810
  init_context(),
21760
21811
  init_conf()
21761
21812
  ]);
@@ -56982,7 +57033,7 @@ var init_openflow = __esm(() => {
56982
57033
  openflow_default = {
56983
57034
  openapi: "3.0.3",
56984
57035
  info: {
56985
- version: "1.819.0",
57036
+ version: "1.820.0",
56986
57037
  title: "OpenFlow Spec",
56987
57038
  contact: {
56988
57039
  name: "Ruben Fiszel",
@@ -57245,7 +57296,7 @@ var init_openflow = __esm(() => {
57245
57296
  },
57246
57297
  color: {
57247
57298
  type: "string",
57248
- description: 'Color of the note (e.g., "yellow", "#ffff00")'
57299
+ description: "Color of the note, one of: yellow, blue, green, purple, pink, orange, red, cyan, lime, gray. Any other value renders unstyled."
57249
57300
  },
57250
57301
  type: {
57251
57302
  type: "string",
@@ -57253,7 +57304,7 @@ var init_openflow = __esm(() => {
57253
57304
  "free",
57254
57305
  "group"
57255
57306
  ],
57256
- description: "Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"
57307
+ description: "Type of note - 'free' for standalone notes. 'group' notes are deprecated; segment a flow with FlowValue.groups instead."
57257
57308
  },
57258
57309
  locked: {
57259
57310
  type: "boolean",
@@ -57302,7 +57353,7 @@ var init_openflow = __esm(() => {
57302
57353
  },
57303
57354
  color: {
57304
57355
  type: "string",
57305
- description: "Color for the group in the flow editor"
57356
+ description: "Color for the group in the flow editor, one of: yellow, blue, green, purple, pink, orange, red, cyan, lime, gray. Omit it to let the editor pick one."
57306
57357
  }
57307
57358
  },
57308
57359
  required: [
@@ -57725,6 +57776,30 @@ var init_openflow = __esm(() => {
57725
57776
  "kind"
57726
57777
  ]
57727
57778
  },
57779
+ MemoryCompaction: {
57780
+ type: "object",
57781
+ description: `Keeps the whole memory named by the run's memory id (or the step's \`memory_id\`), replacing
57782
+ its older part with a summary as the conversation approaches the model's context window.
57783
+ Without a memory id the agent runs without memory, and compaction bounds the run's own loop.
57784
+ `,
57785
+ properties: {
57786
+ kind: {
57787
+ type: "string",
57788
+ enum: [
57789
+ "compaction"
57790
+ ]
57791
+ },
57792
+ context_window: {
57793
+ type: "integer",
57794
+ description: `Overrides the context window looked up from the model, in tokens. Only a model
57795
+ Windmill does not know needs one; those fall back to 128000.
57796
+ `
57797
+ }
57798
+ },
57799
+ required: [
57800
+ "kind"
57801
+ ]
57802
+ },
57728
57803
  MemoryMessage: {
57729
57804
  type: "object",
57730
57805
  description: "A single message in conversation history",
@@ -57778,6 +57853,9 @@ var init_openflow = __esm(() => {
57778
57853
  {
57779
57854
  $ref: "#/components/schemas/MemoryWindow"
57780
57855
  },
57856
+ {
57857
+ $ref: "#/components/schemas/MemoryCompaction"
57858
+ },
57781
57859
  {
57782
57860
  $ref: "#/components/schemas/MemoryAuto"
57783
57861
  },
@@ -58417,7 +58495,7 @@ Streaming events include: token_delta, reasoning_token_delta, tool_call, tool_ca
58417
58495
  $ref: "#/components/schemas/InputTransform"
58418
58496
  }
58419
58497
  ],
58420
- description: "String. Names the memory this step reads and writes, overriding the memory id the run\nwas started with (the chat conversation, an app chat session or the `memory_id` run\nparameter). Leave unset to use the run's memory id. A fixed value shares one memory\nacross every run; an expression such as `flow_input.customer_id` keeps one memory per\nkey. When it evaluates to an empty value the agent runs without memory. Read only\nwhile `memory` is `window`: it is ignored when memory is off, and an older `auto` or\n`manual` memory reads neither history input.\n"
58498
+ description: "String. Names the memory this step reads and writes, overriding the memory id the run\nwas started with (the chat conversation, an app chat session or the `memory_id` run\nparameter). Leave unset to use the run's memory id. A fixed value shares one memory\nacross every run; an expression such as `flow_input.customer_id` keeps one memory per\nkey. When it evaluates to an empty value the agent runs without memory. Read only\nwhile `memory` is `window` or `compaction`: it is ignored when memory is off, and an\nolder `auto` or `manual` memory reads neither history input.\n"
58421
58499
  },
58422
58500
  previous_messages: {
58423
58501
  allOf: [
@@ -60804,6 +60882,218 @@ var init_src = __esm(() => {
60804
60882
  init_validation();
60805
60883
  });
60806
60884
 
60885
+ // src/commands/lint/flow_semantics.ts
60886
+ function asArray(value) {
60887
+ return Array.isArray(value) ? value : [];
60888
+ }
60889
+ function walkModules(modules, pointer, lists, agents) {
60890
+ if (!Array.isArray(modules))
60891
+ return;
60892
+ lists.push({ pointer, modules });
60893
+ modules.forEach((m, i) => {
60894
+ const value = m?.value;
60895
+ const at = `${pointer}/${i}/value`;
60896
+ switch (value?.type) {
60897
+ case "forloopflow":
60898
+ case "whileloopflow":
60899
+ walkModules(value.modules, `${at}/modules`, lists, agents);
60900
+ break;
60901
+ case "branchone":
60902
+ walkModules(value.default, `${at}/default`, lists, agents);
60903
+ asArray(value.branches).forEach((b, bi) => walkModules(b?.modules, `${at}/branches/${bi}/modules`, lists, agents));
60904
+ break;
60905
+ case "branchall":
60906
+ asArray(value.branches).forEach((b, bi) => walkModules(b?.modules, `${at}/branches/${bi}/modules`, lists, agents));
60907
+ break;
60908
+ case "aiagent":
60909
+ collectAgents(m, `${pointer}/${i}`, agents);
60910
+ break;
60911
+ }
60912
+ });
60913
+ }
60914
+ function collectAgents(module, pointer, agents) {
60915
+ if (typeof module?.value?.agent === "string" && module.value.agent !== "") {
60916
+ return;
60917
+ }
60918
+ agents.push({ pointer, module });
60919
+ asArray(module?.value?.tools).forEach((tool, i) => {
60920
+ if (tool?.value?.type === "aiagent") {
60921
+ collectAgents(tool, `${pointer}/value/tools/${i}`, agents);
60922
+ }
60923
+ });
60924
+ }
60925
+ function checkAgentTools(agent, report) {
60926
+ const tools = agent.module?.value?.tools;
60927
+ if (!Array.isArray(tools))
60928
+ return;
60929
+ const seen = new Map;
60930
+ tools.forEach((tool, i) => {
60931
+ const kind = tool?.value?.tool_type;
60932
+ if (kind === "mcp" || kind === "websearch")
60933
+ return;
60934
+ const at = `${agent.pointer}/value/tools/${i}`;
60935
+ const name = tool?.summary;
60936
+ if (typeof name !== "string" || name.length === 0) {
60937
+ report.errors.push(`${at} has no summary: a tool's summary is the name the agent calls it by`);
60938
+ return;
60939
+ }
60940
+ if (!TOOL_NAME_REGEX.test(name)) {
60941
+ report.errors.push(`${at} tool name '${name}' may only contain letters, numbers and underscores (a run that offers this tool fails with 'Invalid tool name')`);
60942
+ return;
60943
+ }
60944
+ if (name === WEBSEARCH_ENABLED_NAME) {
60945
+ report.errors.push(`${at} tool name '${name}' is reserved for enabling web search`);
60946
+ return;
60947
+ }
60948
+ if (seen.has(name)) {
60949
+ report.errors.push(`${at} tool name '${name}' is already used by tool ${seen.get(name)} of this agent`);
60950
+ return;
60951
+ }
60952
+ seen.set(name, i);
60953
+ if (RESERVED_IDS.has(name)) {
60954
+ report.warnings.push(`${at} tool name '${name}' is a reserved id; the flow editor refuses it`);
60955
+ }
60956
+ });
60957
+ }
60958
+ function checkColor(at, color, report) {
60959
+ if (color === undefined || color === null)
60960
+ return;
60961
+ if (typeof color !== "string" || !PALETTE.includes(color)) {
60962
+ report.warnings.push(`${at} color '${color}' renders unstyled; use one of: ${PALETTE.join(", ")}`);
60963
+ }
60964
+ }
60965
+ function checkGroups(groups, lists, report) {
60966
+ if (!Array.isArray(groups))
60967
+ return;
60968
+ const location = new Map;
60969
+ lists.forEach((l, list) => l.modules.forEach((m, index) => {
60970
+ if (typeof m?.id === "string")
60971
+ location.set(m.id, { list, index });
60972
+ }));
60973
+ const placed = [];
60974
+ const keys = new Set;
60975
+ groups.forEach((g, i) => {
60976
+ const at = `/value/groups/${i}`;
60977
+ checkColor(at, g?.color, report);
60978
+ const startId = g?.start_id;
60979
+ const endId = g?.end_id;
60980
+ if (typeof startId !== "string" || typeof endId !== "string")
60981
+ return;
60982
+ const key = `${startId}:${endId}`;
60983
+ if (keys.has(key)) {
60984
+ report.errors.push(`${at} spans the same steps as another group (${startId} to ${endId})`);
60985
+ return;
60986
+ }
60987
+ keys.add(key);
60988
+ for (const id of [startId, endId]) {
60989
+ if (VIRTUAL_NODE_IDS.has(id)) {
60990
+ report.errors.push(`${at} cannot include the '${id}' node`);
60991
+ return;
60992
+ }
60993
+ if (!location.has(id)) {
60994
+ report.errors.push(id === "preprocessor" || id === "failure" ? `${at} cannot include the '${id}' module` : `${at} references '${id}', which is not a step of this flow`);
60995
+ return;
60996
+ }
60997
+ }
60998
+ const start = location.get(startId);
60999
+ const end = location.get(endId);
61000
+ if (start.list !== end.list) {
61001
+ report.errors.push(`${at} starts at '${startId}' and ends at '${endId}', which are not in the same branch`);
61002
+ return;
61003
+ }
61004
+ if (start.index > end.index) {
61005
+ report.errors.push(`${at} starts at '${startId}', which comes after its end '${endId}'`);
61006
+ return;
61007
+ }
61008
+ placed.push({ at, list: start.list, start: start.index, end: end.index });
61009
+ });
61010
+ for (let a = 0;a < placed.length; a++) {
61011
+ for (let b = a + 1;b < placed.length; b++) {
61012
+ const x = placed[a];
61013
+ const y = placed[b];
61014
+ if (x.list !== y.list)
61015
+ continue;
61016
+ const disjoint = x.end < y.start || y.end < x.start;
61017
+ const nested = x.start <= y.start && y.end <= x.end || y.start <= x.start && x.end <= y.end;
61018
+ if (!disjoint && !nested) {
61019
+ report.errors.push(`${y.at} partly overlaps ${x.at}: groups may nest but not overlap`);
61020
+ }
61021
+ }
61022
+ }
61023
+ }
61024
+ function checkNotes(notes, report) {
61025
+ if (!Array.isArray(notes))
61026
+ return;
61027
+ const ids = new Set;
61028
+ notes.forEach((n, i) => {
61029
+ const at = `/value/notes/${i}`;
61030
+ checkColor(at, n?.color, report);
61031
+ if (typeof n?.id === "string") {
61032
+ if (ids.has(n.id)) {
61033
+ report.warnings.push(`${at} reuses the note id '${n.id}'`);
61034
+ }
61035
+ ids.add(n.id);
61036
+ }
61037
+ if (n?.type === "group") {
61038
+ report.warnings.push(`${at} is a 'group' note, which is deprecated: use value.groups instead`);
61039
+ } else if (!n?.position || !n?.size) {
61040
+ report.warnings.push(`${at} has no position or size, so the editor places it at the origin and cannot resize it`);
61041
+ }
61042
+ });
61043
+ }
61044
+ function checkFlowSemantics(flow) {
61045
+ const report = { errors: [], warnings: [] };
61046
+ const value = flow?.value;
61047
+ if (!value || typeof value !== "object")
61048
+ return report;
61049
+ const lists = [];
61050
+ const agents = [];
61051
+ walkModules(value.modules, "/value/modules", lists, agents);
61052
+ for (const agent of agents) {
61053
+ checkAgentTools(agent, report);
61054
+ }
61055
+ checkGroups(value.groups, lists, report);
61056
+ checkNotes(value.notes, report);
61057
+ return report;
61058
+ }
61059
+ var TOOL_NAME_REGEX, WEBSEARCH_ENABLED_NAME = "__wm_web_search", RESERVED_IDS, PALETTE, VIRTUAL_NODE_IDS;
61060
+ var init_flow_semantics = __esm(() => {
61061
+ TOOL_NAME_REGEX = /^[a-zA-Z0-9_]+$/;
61062
+ RESERVED_IDS = new Set([
61063
+ "do",
61064
+ "bg",
61065
+ "ctx",
61066
+ "state",
61067
+ "if",
61068
+ "else",
61069
+ "for",
61070
+ "delete",
61071
+ "while",
61072
+ "new",
61073
+ "in",
61074
+ "failure",
61075
+ "preprocessor",
61076
+ "__wm_agent_root",
61077
+ "as",
61078
+ "Input",
61079
+ "Result",
61080
+ "Trigger"
61081
+ ]);
61082
+ PALETTE = [
61083
+ "yellow",
61084
+ "blue",
61085
+ "green",
61086
+ "purple",
61087
+ "pink",
61088
+ "orange",
61089
+ "red",
61090
+ "cyan",
61091
+ "lime",
61092
+ "gray"
61093
+ ];
61094
+ VIRTUAL_NODE_IDS = new Set(["Input", "Result", "Trigger"]);
61095
+ });
61096
+
60807
61097
  // src/utils/app_files.ts
60808
61098
  function deploysWithRawApp(relativePath) {
60809
61099
  const segments = relativePath.split("/").filter(Boolean);
@@ -64676,6 +64966,14 @@ async function runLint(opts, directory) {
64676
64966
  ...formatYamlDiagnostics(result.parsed),
64677
64967
  ...result.errors.map((error) => formatValidationError(error))
64678
64968
  ];
64969
+ if (target.type === "flow") {
64970
+ const semantics = checkFlowSemantics(result.parsed?.data);
64971
+ fileErrors.push(...semantics.errors);
64972
+ warnings.push(...semantics.warnings.map((message) => ({
64973
+ path: normalizedPath,
64974
+ message
64975
+ })));
64976
+ }
64679
64977
  if (fileErrors.length > 0) {
64680
64978
  issues.push({
64681
64979
  path: normalizedPath,
@@ -64797,6 +65095,7 @@ var init_lint = __esm(async () => {
64797
65095
  init_mod3();
64798
65096
  init_log();
64799
65097
  init_src();
65098
+ init_flow_semantics();
64800
65099
  await __promiseAll([
64801
65100
  init_yaml(),
64802
65101
  init_conf(),
@@ -64809,7 +65108,7 @@ var init_lint = __esm(async () => {
64809
65108
  YAML_FILE_REGEX = /\.ya?ml$/i;
64810
65109
  NATIVE_TRIGGER_REGEX = /\.[^.]+_native_trigger\.ya?ml$/i;
64811
65110
  FLAT_SCRIPT_METADATA_REGEX = /\.script\.(yaml|json|lock)$/;
64812
- command6 = new Command().description("Validate Windmill flow, schedule, and trigger YAML files in a directory, and report script metadata that has no deployable content file").arguments("[directory:string]").option("--json", "Output results in JSON format").option("--fail-on-warn", "Exit with code 1 when warnings are emitted").option("--locks-required", "Fail if scripts or flow inline scripts that need locks have no locks").option("-w, --watch", "Watch for file changes and re-lint automatically").action(lint);
65111
+ command6 = new Command().description("Validate Windmill flow, schedule, and trigger YAML files in a directory (including AI agent tool names and flow groups/notes), and report script metadata that has no deployable content file").arguments("[directory:string]").option("--json", "Output results in JSON format").option("--fail-on-warn", "Exit with code 1 when warnings are emitted").option("--locks-required", "Fail if scripts or flow inline scripts that need locks have no locks").option("-w, --watch", "Watch for file changes and re-lint automatically").action(lint);
64813
65112
  lint_default = command6;
64814
65113
  });
64815
65114
 
@@ -65804,6 +66103,9 @@ function generateAgentsDocumentation(data) {
65804
66103
  const tables = data?.tables ?? [];
65805
66104
  const defaultDatatable = data?.datatable;
65806
66105
  const defaultSchema = data?.schema;
66106
+ const role = defaultDatatable ? data?.roles?.[defaultDatatable] : undefined;
66107
+ const datatableCall = `wmill.datatable('${defaultDatatable || "main"}'${role ? `, { role: '${role}' }` : ""})`;
66108
+ const tableRef = defaultSchema ? `${defaultSchema}.table` : "table";
65807
66109
  return `# AI Agent Instructions
65808
66110
 
65809
66111
  For complete raw app documentation (app structure, backend runnables, datatables, SQL migrations), use the \`raw-app\` skill.
@@ -65814,7 +66116,9 @@ This file contains **app-specific configuration** for this raw app instance.
65814
66116
 
65815
66117
  ## Data Configuration
65816
66118
 
65817
- ${defaultDatatable ? `**Default Datatable:** \`${defaultDatatable}\`${defaultSchema ? ` | **Default Schema:** \`${defaultSchema}\`` : ""}` : "**No default datatable configured.** Set `data.datatable` in `raw_app.yaml` to enable database access."}
66119
+ ${defaultDatatable ? `**Default Datatable:** \`${defaultDatatable}\`${defaultSchema ? ` | **Default Schema:** \`${defaultSchema}\`` : ""}${role ? ` | **Role:** \`${role}\` (pass it to every \`wmill.datatable\` call)` : ""}${defaultSchema ? `
66120
+
66121
+ Write this app's tables as \`${defaultSchema}.<table>\`, in migrations and queries: an unqualified name means the \`public\` schema.` : ""}` : "**No default datatable configured.** Set `data.datatable` in `raw_app.yaml` to enable database access."}
65818
66122
 
65819
66123
  ### Whitelisted Tables
65820
66124
 
@@ -65855,8 +66159,8 @@ const result = await backend.<name>({ arg: 'value' });
65855
66159
 
65856
66160
  **Query datatable (TypeScript):**
65857
66161
  \`\`\`typescript
65858
- const sql = wmill.datatable();
65859
- const rows = await sql\`SELECT * FROM table WHERE id = \${id}\`.fetch();
66162
+ const sql = ${datatableCall};
66163
+ const rows = await sql\`SELECT * FROM ${tableRef} WHERE id = \${id}\`.fetch();
65860
66164
  \`\`\`
65861
66165
 
65862
66166
  **SQL migrations:** Add \`.sql\` files to \`sql_to_apply/\`, run \`wmill app dev\`, then whitelist tables
@@ -79122,7 +79426,8 @@ You are a helpful assistant that can help with Windmill scripts, flows, apps, an
79122
79426
  ## Important Notes
79123
79427
  - Every new entity MUST be created using the skills listed below.
79124
79428
  - Every modification of an entity MUST be done using the skills listed below.
79125
- - User MUST be asked where to create the entity. It can be in its user folder, under u/{user_name} folder, or in a new folder, /f/{folder_name}/. folder_name and user_name must be provided by the user.
79429
+ - User MUST be asked where to create the entity: in their user space, \`u/{user_name}/<name>\`, or in a folder, \`f/{folder_name}/<name>\` (no leading \`/\`; a bare \`f/<name>\` with no folder segment is invalid). folder_name and user_name must be provided by the user.
79430
+ - A new folder needs its \`f/{folder_name}/folder.meta.yaml\`: create it with \`wmill folder new {folder_name}\`. \`wmill sync push\` refuses a folder without one for non-admins.
79126
79431
 
79127
79432
  ## Script Writing Guide
79128
79433
 
@@ -79134,6 +79439,10 @@ For Workflow-as-Code scripts, use the \`write-workflow-as-code\` skill.
79134
79439
  You MUST use the \`write-flow\` skill to create or modify flows.
79135
79440
  When a new flow needs to be created, YOU run \`wmill flow new <path>\` yourself (with \`--summary\` and optional \`--description\`) to scaffold the folder and \`flow.yaml\`, then edit \`flow.yaml\` to fill in modules and schema. Do NOT scaffold the folder + yaml by hand and do NOT tell the user to run \`wmill flow new\`. If path or summary are missing from the user's request, ask via \`AskUserQuestion\` (one call, all missing fields) — never invent them. See the \`write-flow\` skill for the procedure.
79136
79441
 
79442
+ ## Data Pipelines
79443
+
79444
+ A data pipeline is NOT a flow: it is a set of independent scripts in one folder, marked \`pipeline\` and wired together by \`on\` / \`materialize\` annotations. When the user asks for a data pipeline (or to ingest, transform or materialize data across steps), you MUST use the \`write-pipeline\` skill and build pipeline scripts, not a flow.
79445
+
79137
79446
  ## Raw App Development
79138
79447
 
79139
79448
  You MUST use the \`raw-app\` skill to create or modify raw apps.
@@ -79300,6 +79609,7 @@ var init_skills_gen = __esm(() => {
79300
79609
  { name: "schedules", description: "MUST use when configuring schedules." },
79301
79610
  { name: "resources", description: "MUST use when managing resources." },
79302
79611
  { name: "write-workflow-as-code", description: "MUST use when writing or modifying Windmill Workflow-as-Code scripts using workflow, task, step, sleep, approvals, taskScript, taskFlow, task_script, or task_flow." },
79612
+ { name: "write-pipeline", description: "MUST use when creating or modifying a data pipeline, a set of scripts marked `pipeline` and wired together by `on` / `materialize` annotations." },
79303
79613
  { name: "cli-commands", description: "MUST use when using the CLI, including debugging job failures and inspecting run history via `wmill job`." },
79304
79614
  { name: "preview", description: "MUST use when opening the Windmill dev page / visual preview of a flow, script, or app. Triggers on words like preview, open, navigate to, visualize, see the flow/app/script, and after writing a flow/script/app for visual verification." }
79305
79615
  ];
@@ -79354,6 +79664,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
79354
79664
 
79355
79665
  Use \`wmill resource-type list --schema\` to discover available resource types.
79356
79666
 
79667
+ # Windmill Script Writing Guide
79668
+
79669
+ ## General Principles
79670
+
79671
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
79672
+ - Libraries are installed automatically - do not show installation instructions
79673
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
79674
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
79675
+
79676
+ ## Return Values
79677
+
79678
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
79679
+ - Return values become available to subsequent flow steps via \`results.step_id\`
79680
+
79681
+ ## Preprocessor Scripts
79682
+
79683
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
79684
+
79685
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
79686
+
79687
+ The returned object determines the parameter values passed to the flow.
79688
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
79689
+
79357
79690
  # Ansible
79358
79691
 
79359
79692
  Windmill runs Ansible playbooks with \`ansible-playbook\`. A script is a single YAML
@@ -79494,6 +79827,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
79494
79827
 
79495
79828
  Use \`wmill resource-type list --schema\` to discover available resource types.
79496
79829
 
79830
+ # Windmill Script Writing Guide
79831
+
79832
+ ## General Principles
79833
+
79834
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
79835
+ - Libraries are installed automatically - do not show installation instructions
79836
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
79837
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
79838
+
79839
+ ## Return Values
79840
+
79841
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
79842
+ - Return values become available to subsequent flow steps via \`results.step_id\`
79843
+
79844
+ ## Preprocessor Scripts
79845
+
79846
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
79847
+
79848
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
79849
+
79850
+ The returned object determines the parameter values passed to the flow.
79851
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
79852
+
79497
79853
  # Bash
79498
79854
 
79499
79855
  ## Structure
@@ -79594,6 +79950,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
79594
79950
 
79595
79951
  Use \`wmill resource-type list --schema\` to discover available resource types.
79596
79952
 
79953
+ # Windmill Script Writing Guide
79954
+
79955
+ ## General Principles
79956
+
79957
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
79958
+ - Libraries are installed automatically - do not show installation instructions
79959
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
79960
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
79961
+
79962
+ ## Return Values
79963
+
79964
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
79965
+ - Return values become available to subsequent flow steps via \`results.step_id\`
79966
+
79967
+ ## Preprocessor Scripts
79968
+
79969
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
79970
+
79971
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
79972
+
79973
+ The returned object determines the parameter values passed to the flow.
79974
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
79975
+
79597
79976
  # BigQuery
79598
79977
 
79599
79978
  Arguments use \`@name\` syntax.
@@ -79687,6 +80066,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
79687
80066
 
79688
80067
  Use \`wmill resource-type list --schema\` to discover available resource types.
79689
80068
 
80069
+ # Windmill Script Writing Guide
80070
+
80071
+ ## General Principles
80072
+
80073
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
80074
+ - Libraries are installed automatically - do not show installation instructions
80075
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
80076
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
80077
+
80078
+ ## Return Values
80079
+
80080
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
80081
+ - Return values become available to subsequent flow steps via \`results.step_id\`
80082
+
80083
+ ## Preprocessor Scripts
80084
+
80085
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
80086
+
80087
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
80088
+
80089
+ The returned object determines the parameter values passed to the flow.
80090
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
80091
+
79690
80092
  # TypeScript (Bun)
79691
80093
 
79692
80094
  Bun runtime with full npm ecosystem and fastest execution. **Bun is the default and preferred TypeScript runtime** — choose it for any TypeScript script unless there is a major reason to use Deno for that specific use-case.
@@ -79741,7 +80143,7 @@ import * as wmill from "windmill-client";
79741
80143
 
79742
80144
  **Prefer \`windmill-client\` over raw \`fetch\` for anything that talks to Windmill** — reading resources/variables/states, running scripts and flows, S3 object operations, etc. It handles auth, the workspace, and the base URL for you, so you don't hand-roll URLs or tokens. Reserve \`fetch\` for calling *external* HTTP APIs that aren't Windmill.
79743
80145
 
79744
- The full \`windmill-client\` API reference (every exported function and its signature) is included in this skill below — consult it for the exact method to use instead of guessing or falling back to \`fetch\`.
80146
+ The full \`windmill-client\` API reference (every exported function and its signature) is included below — consult it for the exact method to use instead of guessing or falling back to \`fetch\`.
79745
80147
 
79746
80148
  ## Preprocessor Scripts
79747
80149
 
@@ -79759,7 +80161,9 @@ type Event = {
79759
80161
  | "postgres"
79760
80162
  | "sqs"
79761
80163
  | "mqtt"
79762
- | "gcp";
80164
+ | "amqp"
80165
+ | "gcp"
80166
+ | "azure";
79763
80167
  body: any;
79764
80168
  headers: Record<string, string>;
79765
80169
  query: Record<string, string>;
@@ -79807,7 +80211,6 @@ const result: wmill.S3Object = await wmill.writeS3File(
79807
80211
  );
79808
80212
  \`\`\`
79809
80213
 
79810
-
79811
80214
  # TypeScript SDK (windmill-client)
79812
80215
 
79813
80216
  Import: import * as wmill from 'windmill-client'
@@ -80483,6 +80886,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
80483
80886
 
80484
80887
  Use \`wmill resource-type list --schema\` to discover available resource types.
80485
80888
 
80889
+ # Windmill Script Writing Guide
80890
+
80891
+ ## General Principles
80892
+
80893
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
80894
+ - Libraries are installed automatically - do not show installation instructions
80895
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
80896
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
80897
+
80898
+ ## Return Values
80899
+
80900
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
80901
+ - Return values become available to subsequent flow steps via \`results.step_id\`
80902
+
80903
+ ## Preprocessor Scripts
80904
+
80905
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
80906
+
80907
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
80908
+
80909
+ The returned object determines the parameter values passed to the flow.
80910
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
80911
+
80486
80912
  # TypeScript (Bun Native)
80487
80913
 
80488
80914
  Native TypeScript execution. Native scripts are Bun scripts that run on the native worker — a lightweight V8 isolate that exposes \`fetch\` and the JavaScript standard library — and can be heavily parallelized. Every script MUST start with \`//native\` on its first line so Windmill routes it to the native worker; without it the exact same script runs on the regular Bun worker. You may import npm packages and other Windmill scripts (e.g. \`./helper.ts\`) — imports are resolved and bundled just like a regular Bun script — as long as everything (your code and its dependencies) relies only on \`fetch\` and the standard library. Libraries that need Node/Bun runtime APIs (filesystem, \`node:*\` modules, child processes, native addons) will not work on the native worker; use the regular \`bun\` language for those.
@@ -80534,7 +80960,7 @@ export async function main(url: string) {
80534
80960
 
80535
80961
  \`windmill-client\` works on the native worker (its calls go over \`fetch\`), so use it as the **preferred way to talk to Windmill** — reading resources/variables/states, running scripts and flows, and the S3 helpers below (\`loadS3File\`, \`loadS3FileStream\`, \`writeS3File\`, \`S3Object\`). It handles auth, the workspace, and the base URL for you. Reserve raw \`fetch\` for calling *external* HTTP APIs that aren't Windmill.
80536
80962
 
80537
- The full \`windmill-client\` API reference (every exported function and its signature) is included in this skill below — consult it for the exact method instead of hand-rolling a \`fetch\` against the Windmill API.
80963
+ The full \`windmill-client\` API reference (every exported function and its signature) is included below — consult it for the exact method instead of hand-rolling a \`fetch\` against the Windmill API.
80538
80964
 
80539
80965
  ## Preprocessor Scripts
80540
80966
 
@@ -80553,7 +80979,9 @@ type Event = {
80553
80979
  | "postgres"
80554
80980
  | "sqs"
80555
80981
  | "mqtt"
80556
- | "gcp";
80982
+ | "amqp"
80983
+ | "gcp"
80984
+ | "azure";
80557
80985
  body: any;
80558
80986
  headers: Record<string, string>;
80559
80987
  query: Record<string, string>;
@@ -80603,7 +81031,6 @@ const result: wmill.S3Object = await wmill.writeS3File(
80603
81031
  );
80604
81032
  \`\`\`
80605
81033
 
80606
-
80607
81034
  # TypeScript SDK (windmill-client)
80608
81035
 
80609
81036
  Import: import * as wmill from 'windmill-client'
@@ -81279,6 +81706,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
81279
81706
 
81280
81707
  Use \`wmill resource-type list --schema\` to discover available resource types.
81281
81708
 
81709
+ # Windmill Script Writing Guide
81710
+
81711
+ ## General Principles
81712
+
81713
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
81714
+ - Libraries are installed automatically - do not show installation instructions
81715
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
81716
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
81717
+
81718
+ ## Return Values
81719
+
81720
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
81721
+ - Return values become available to subsequent flow steps via \`results.step_id\`
81722
+
81723
+ ## Preprocessor Scripts
81724
+
81725
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
81726
+
81727
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
81728
+
81729
+ The returned object determines the parameter values passed to the flow.
81730
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
81731
+
81282
81732
  # C#
81283
81733
 
81284
81734
  The script must contain a public static \`Main\` method inside a class:
@@ -81371,6 +81821,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
81371
81821
 
81372
81822
  Use \`wmill resource-type list --schema\` to discover available resource types.
81373
81823
 
81824
+ # Windmill Script Writing Guide
81825
+
81826
+ ## General Principles
81827
+
81828
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
81829
+ - Libraries are installed automatically - do not show installation instructions
81830
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
81831
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
81832
+
81833
+ ## Return Values
81834
+
81835
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
81836
+ - Return values become available to subsequent flow steps via \`results.step_id\`
81837
+
81838
+ ## Preprocessor Scripts
81839
+
81840
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
81841
+
81842
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
81843
+
81844
+ The returned object determines the parameter values passed to the flow.
81845
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
81846
+
81374
81847
  # TypeScript (Deno)
81375
81848
 
81376
81849
  Deno runtime with npm support via \`npm:\` prefix and native Deno libraries.
@@ -81427,7 +81900,7 @@ import * as wmill from "windmill-client";
81427
81900
 
81428
81901
  **Prefer \`windmill-client\` over raw \`fetch\` for anything that talks to Windmill** — reading resources/variables/states, running scripts and flows, S3 object operations, etc. It handles auth, the workspace, and the base URL for you. Reserve \`fetch\` for calling *external* HTTP APIs that aren't Windmill.
81429
81902
 
81430
- The full \`windmill-client\` API reference (every exported function and its signature) is included in this skill below — consult it for the exact method instead of guessing or falling back to \`fetch\`.
81903
+ The full \`windmill-client\` API reference (every exported function and its signature) is included below — consult it for the exact method instead of guessing or falling back to \`fetch\`.
81431
81904
 
81432
81905
  ## Preprocessor Scripts
81433
81906
 
@@ -81445,7 +81918,9 @@ type Event = {
81445
81918
  | "postgres"
81446
81919
  | "sqs"
81447
81920
  | "mqtt"
81448
- | "gcp";
81921
+ | "amqp"
81922
+ | "gcp"
81923
+ | "azure";
81449
81924
  body: any;
81450
81925
  headers: Record<string, string>;
81451
81926
  query: Record<string, string>;
@@ -81493,7 +81968,6 @@ const result: wmill.S3Object = await wmill.writeS3File(
81493
81968
  );
81494
81969
  \`\`\`
81495
81970
 
81496
-
81497
81971
  # TypeScript SDK (windmill-client)
81498
81972
 
81499
81973
  Import: import * as wmill from 'windmill-client'
@@ -82169,6 +82643,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82169
82643
 
82170
82644
  Use \`wmill resource-type list --schema\` to discover available resource types.
82171
82645
 
82646
+ # Windmill Script Writing Guide
82647
+
82648
+ ## General Principles
82649
+
82650
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
82651
+ - Libraries are installed automatically - do not show installation instructions
82652
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
82653
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
82654
+
82655
+ ## Return Values
82656
+
82657
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
82658
+ - Return values become available to subsequent flow steps via \`results.step_id\`
82659
+
82660
+ ## Preprocessor Scripts
82661
+
82662
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
82663
+
82664
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
82665
+
82666
+ The returned object determines the parameter values passed to the flow.
82667
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
82668
+
82172
82669
  # DuckDB
82173
82670
 
82174
82671
  Arguments are defined with comments and used with \`$name\` syntax:
@@ -82295,6 +82792,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82295
82792
 
82296
82793
  Use \`wmill resource-type list --schema\` to discover available resource types.
82297
82794
 
82795
+ # Windmill Script Writing Guide
82796
+
82797
+ ## General Principles
82798
+
82799
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
82800
+ - Libraries are installed automatically - do not show installation instructions
82801
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
82802
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
82803
+
82804
+ ## Return Values
82805
+
82806
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
82807
+ - Return values become available to subsequent flow steps via \`results.step_id\`
82808
+
82809
+ ## Preprocessor Scripts
82810
+
82811
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
82812
+
82813
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
82814
+
82815
+ The returned object determines the parameter values passed to the flow.
82816
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
82817
+
82298
82818
  # Go
82299
82819
 
82300
82820
  ## Structure
@@ -82404,6 +82924,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82404
82924
 
82405
82925
  Use \`wmill resource-type list --schema\` to discover available resource types.
82406
82926
 
82927
+ # Windmill Script Writing Guide
82928
+
82929
+ ## General Principles
82930
+
82931
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
82932
+ - Libraries are installed automatically - do not show installation instructions
82933
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
82934
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
82935
+
82936
+ ## Return Values
82937
+
82938
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
82939
+ - Return values become available to subsequent flow steps via \`results.step_id\`
82940
+
82941
+ ## Preprocessor Scripts
82942
+
82943
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
82944
+
82945
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
82946
+
82947
+ The returned object determines the parameter values passed to the flow.
82948
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
82949
+
82407
82950
  # GraphQL
82408
82951
 
82409
82952
  ## Structure
@@ -82500,6 +83043,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82500
83043
 
82501
83044
  Use \`wmill resource-type list --schema\` to discover available resource types.
82502
83045
 
83046
+ # Windmill Script Writing Guide
83047
+
83048
+ ## General Principles
83049
+
83050
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83051
+ - Libraries are installed automatically - do not show installation instructions
83052
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83053
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83054
+
83055
+ ## Return Values
83056
+
83057
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83058
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83059
+
83060
+ ## Preprocessor Scripts
83061
+
83062
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83063
+
83064
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83065
+
83066
+ The returned object determines the parameter values passed to the flow.
83067
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83068
+
82503
83069
  # Java
82504
83070
 
82505
83071
  The script must contain a Main public class with a \`public static main()\` method:
@@ -82589,6 +83155,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82589
83155
 
82590
83156
  Use \`wmill resource-type list --schema\` to discover available resource types.
82591
83157
 
83158
+ # Windmill Script Writing Guide
83159
+
83160
+ ## General Principles
83161
+
83162
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83163
+ - Libraries are installed automatically - do not show installation instructions
83164
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83165
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83166
+
83167
+ ## Return Values
83168
+
83169
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83170
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83171
+
83172
+ ## Preprocessor Scripts
83173
+
83174
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83175
+
83176
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83177
+
83178
+ The returned object determines the parameter values passed to the flow.
83179
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83180
+
82592
83181
  # Microsoft SQL Server (MSSQL)
82593
83182
 
82594
83183
  Arguments use \`@P1\`, \`@P2\`, etc.
@@ -82681,6 +83270,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82681
83270
 
82682
83271
  Use \`wmill resource-type list --schema\` to discover available resource types.
82683
83272
 
83273
+ # Windmill Script Writing Guide
83274
+
83275
+ ## General Principles
83276
+
83277
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83278
+ - Libraries are installed automatically - do not show installation instructions
83279
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83280
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83281
+
83282
+ ## Return Values
83283
+
83284
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83285
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83286
+
83287
+ ## Preprocessor Scripts
83288
+
83289
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83290
+
83291
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83292
+
83293
+ The returned object determines the parameter values passed to the flow.
83294
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83295
+
82684
83296
  # MySQL
82685
83297
 
82686
83298
  Arguments use \`?\` placeholders.
@@ -82774,6 +83386,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82774
83386
 
82775
83387
  Use \`wmill resource-type list --schema\` to discover available resource types.
82776
83388
 
83389
+ # Windmill Script Writing Guide
83390
+
83391
+ ## General Principles
83392
+
83393
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83394
+ - Libraries are installed automatically - do not show installation instructions
83395
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83396
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83397
+
83398
+ ## Return Values
83399
+
83400
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83401
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83402
+
83403
+ ## Preprocessor Scripts
83404
+
83405
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83406
+
83407
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83408
+
83409
+ The returned object determines the parameter values passed to the flow.
83410
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83411
+
82777
83412
  # PHP
82778
83413
 
82779
83414
  ## Structure
@@ -82882,6 +83517,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82882
83517
 
82883
83518
  Use \`wmill resource-type list --schema\` to discover available resource types.
82884
83519
 
83520
+ # Windmill Script Writing Guide
83521
+
83522
+ ## General Principles
83523
+
83524
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83525
+ - Libraries are installed automatically - do not show installation instructions
83526
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83527
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83528
+
83529
+ ## Return Values
83530
+
83531
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83532
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83533
+
83534
+ ## Preprocessor Scripts
83535
+
83536
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83537
+
83538
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83539
+
83540
+ The returned object determines the parameter values passed to the flow.
83541
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83542
+
82885
83543
  # PostgreSQL
82886
83544
 
82887
83545
  Arguments are obtained directly in the statement with \`$1::{type}\`, \`$2::{type}\`, etc.
@@ -82973,6 +83631,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
82973
83631
 
82974
83632
  Use \`wmill resource-type list --schema\` to discover available resource types.
82975
83633
 
83634
+ # Windmill Script Writing Guide
83635
+
83636
+ ## General Principles
83637
+
83638
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83639
+ - Libraries are installed automatically - do not show installation instructions
83640
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83641
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83642
+
83643
+ ## Return Values
83644
+
83645
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83646
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83647
+
83648
+ ## Preprocessor Scripts
83649
+
83650
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83651
+
83652
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83653
+
83654
+ The returned object determines the parameter values passed to the flow.
83655
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83656
+
82976
83657
  # PowerShell
82977
83658
 
82978
83659
  ## Structure
@@ -83079,6 +83760,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
83079
83760
 
83080
83761
  Use \`wmill resource-type list --schema\` to discover available resource types.
83081
83762
 
83763
+ # Windmill Script Writing Guide
83764
+
83765
+ ## General Principles
83766
+
83767
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
83768
+ - Libraries are installed automatically - do not show installation instructions
83769
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
83770
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
83771
+
83772
+ ## Return Values
83773
+
83774
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
83775
+ - Return values become available to subsequent flow steps via \`results.step_id\`
83776
+
83777
+ ## Preprocessor Scripts
83778
+
83779
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
83780
+
83781
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
83782
+
83783
+ The returned object determines the parameter values passed to the flow.
83784
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
83785
+
83082
83786
  # Python
83083
83787
 
83084
83788
  ## Structure
@@ -83162,7 +83866,7 @@ For preprocessor scripts, the function should be named \`preprocessor\` and rece
83162
83866
  from typing import TypedDict, Literal, Any
83163
83867
 
83164
83868
  class Event(TypedDict):
83165
- kind: Literal["webhook", "http", "websocket", "kafka", "email", "nats", "postgres", "sqs", "mqtt", "gcp"]
83869
+ kind: Literal["webhook", "http", "websocket", "kafka", "email", "nats", "postgres", "sqs", "mqtt", "amqp", "gcp", "azure"]
83166
83870
  body: Any
83167
83871
  headers: dict[str, str]
83168
83872
  query: dict[str, str]
@@ -83213,7 +83917,6 @@ result: S3Object = wmill.write_s3_file(
83213
83917
  )
83214
83918
  \`\`\`
83215
83919
 
83216
-
83217
83920
  # Python SDK (wmill)
83218
83921
 
83219
83922
  Import: import wmill
@@ -84010,7 +84713,6 @@ async def parallel(items, fn, *, concurrency: Optional[int] = None)
84010
84713
  # partition: Partition number (from event['partition'])
84011
84714
  # offset: Message offset to commit (from event['offset'])
84012
84715
  def commit_kafka_offsets(trigger_path: str, topic: str, partition: int, offset: int) -> None
84013
-
84014
84716
  `,
84015
84717
  "write-script-rlang": `---
84016
84718
  name: write-script-rlang
@@ -84062,6 +84764,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
84062
84764
 
84063
84765
  Use \`wmill resource-type list --schema\` to discover available resource types.
84064
84766
 
84767
+ # Windmill Script Writing Guide
84768
+
84769
+ ## General Principles
84770
+
84771
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
84772
+ - Libraries are installed automatically - do not show installation instructions
84773
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
84774
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
84775
+
84776
+ ## Return Values
84777
+
84778
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
84779
+ - Return values become available to subsequent flow steps via \`results.step_id\`
84780
+
84781
+ ## Preprocessor Scripts
84782
+
84783
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
84784
+
84785
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
84786
+
84787
+ The returned object determines the parameter values passed to the flow.
84788
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
84789
+
84065
84790
  # R
84066
84791
 
84067
84792
  ## Structure
@@ -84198,6 +84923,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
84198
84923
 
84199
84924
  Use \`wmill resource-type list --schema\` to discover available resource types.
84200
84925
 
84926
+ # Windmill Script Writing Guide
84927
+
84928
+ ## General Principles
84929
+
84930
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
84931
+ - Libraries are installed automatically - do not show installation instructions
84932
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
84933
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
84934
+
84935
+ ## Return Values
84936
+
84937
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
84938
+ - Return values become available to subsequent flow steps via \`results.step_id\`
84939
+
84940
+ ## Preprocessor Scripts
84941
+
84942
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
84943
+
84944
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
84945
+
84946
+ The returned object determines the parameter values passed to the flow.
84947
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
84948
+
84201
84949
  # Rust
84202
84950
 
84203
84951
  ## Structure
@@ -84324,6 +85072,29 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
84324
85072
 
84325
85073
  Use \`wmill resource-type list --schema\` to discover available resource types.
84326
85074
 
85075
+ # Windmill Script Writing Guide
85076
+
85077
+ ## General Principles
85078
+
85079
+ - A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
85080
+ - Libraries are installed automatically - do not show installation instructions
85081
+ - In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it \`main\` (\`Main\` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no \`main\`: their language section shows how they take arguments
85082
+ - Where the language has a Windmill client (\`wmill\`), use it to interact with the platform
85083
+
85084
+ ## Return Values
85085
+
85086
+ - A script can return any JSON-serializable value; a SQL script returns the rows its query produces
85087
+ - Return values become available to subsequent flow steps via \`results.step_id\`
85088
+
85089
+ ## Preprocessor Scripts
85090
+
85091
+ Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
85092
+
85093
+ A preprocessor is written in TypeScript or Python: its function is named \`preprocessor\` instead of \`main\`, and it receives a single parameter called \`event\` (the language section gives its type).
85094
+
85095
+ The returned object determines the parameter values passed to the flow.
85096
+ e.g., \`{ b: 1, a: 2 }\` calls the flow with \`a = 2\` and \`b = 1\`, assuming the flow has two inputs called \`a\` and \`b\`.
85097
+
84327
85098
  # Snowflake
84328
85099
 
84329
85100
  Arguments use \`?\` placeholders.
@@ -84454,7 +85225,6 @@ An input typed as a resource (\`format: resource-<type>\` in the schema) takes t
84454
85225
 
84455
85226
  To open the flow visually in the dev page (graph + live reload), use the \`preview\` skill. Always **offer** it as a one-sentence next step (e.g. "Want me to open the visual preview?") rather than opening it automatically — opening the dev page has side effects (browser window, possibly a \`launch.json\` entry under MCP-preview branches) the user should consent to. If the user already asked to see/preview/visualize the flow in their original request, skip the offer and just invoke the skill.
84456
85227
 
84457
-
84458
85228
  # Windmill Flow Building Guide
84459
85229
 
84460
85230
  ## OpenFlow Schema
@@ -84627,8 +85397,8 @@ names, so neither is name-checked at all — leave those summaries as they are.
84627
85397
  - Always set \`summary\`. It must be unique among that agent's tools, and must not be one of the
84628
85398
  reserved ids (\`do\`, \`bg\`, \`ctx\`, \`state\`, \`if\`, \`else\`, \`for\`, \`delete\`, \`while\`, \`new\`, \`in\`,
84629
85399
  \`failure\`, \`preprocessor\`, \`as\`, \`Input\`, \`Result\`, \`Trigger\`)
84630
- - A tool name outside that character set is rejected: flow write tools refuse it, and a flow that
84631
- reaches the worker with one fails every run with \`Invalid tool name\`
85400
+ - A tool name outside that character set fails any run that offers the tool to the agent, with \`Invalid tool name\`.
85401
+ \`wmill lint <flow folder>\` reports it before anything runs.
84632
85402
  - Tool \`id\` follows the same rules as any module ID — unique across the flow, underscores not spaces
84633
85403
  - \`description\` is optional free text telling the agent when and how to call the tool. Set it
84634
85404
  whenever the name alone does not make that obvious; it overrides the description derived from the
@@ -84651,9 +85421,11 @@ names, so neither is name-checked at all — leave those summaries as they are.
84651
85421
 
84652
85422
  ## Loop Structure Rules
84653
85423
 
85424
+ - A \`forloopflow\` runs its \`modules\` once per element of \`iterator\`, a javascript expression returning an array (e.g. \`results.get_items\`); \`parallel: true\` runs the iterations concurrently, and \`skip_failures: true\` carries on past a failed iteration
84654
85425
  - For \`whileloopflow\`, break the loop with a module-level \`stop_after_if\`: on the loop module itself, or on an inner step (required when that step carries state via its own \`results\` — see below)
84655
85426
  - \`stop_after_if\` is always a sibling of \`id\` and \`value\` on a flow module — never a direct key of the loop's \`value\` object
84656
85427
  - \`stop_after_all_iters_if\` is for checks after the whole loop finishes, not the normal per-iteration break condition
85428
+ - \`stop_after_if\` is evaluated after each iteration: on the loop module, \`result\` is that iteration's result (what its last step returned); on an inner step, it is that step's result
84657
85429
  - \`flow_input.iter.value\` in a \`whileloopflow\` is just the iteration index (same number as \`flow_input.iter.index\`) — it never carries state, so \`flow_input.iter.value.<field>\` is always undefined and a loop whose stop condition depends on it never terminates
84658
85430
  - To carry state across iterations, a step reads its own previous-iteration result via \`results.<its_own_id>\` with a first-iteration fallback (e.g. \`results.b ?? flow_input.start\`) — but then the loop's \`stop_after_if\` MUST sit on that inner step, not on the loop module: a body that is exactly one plain step with the stop condition on the loop module runs on a fast path where \`results.<step_id>\` is null on every iteration and the loop never terminates (bodies with 2+ steps, or whose single step has its own \`stop_after_if\`, retry or similar, resolve \`results\` across iterations regardless of stop placement)
84659
85431
  - For state that is just a counter, derive it from the index instead (e.g. \`flow_input.iter.index + 1\`) — that works in every configuration, including with \`stop_after_if\` on the loop module
@@ -84791,6 +85563,7 @@ Incorrect shape (identity has no resume URLs — not a real approval):
84791
85563
 
84792
85564
  ## Branch Result Scope Rules
84793
85565
 
85566
+ - A \`branchone\` runs the first of its \`branches\` whose \`expr\` is true, in order, and its \`default\` modules when none is; a \`branchall\` runs every branch (concurrently with \`parallel: true\`)
84794
85567
  - Inside a branch, you may reference earlier outer steps and earlier steps in the same branch
84795
85568
  - Outside a \`branchone\`, do NOT reference ids of steps that only exist inside its branches or default branch. Use \`results.<branchone_module_id>\` instead
84796
85569
  - Outside a \`branchall\`, do NOT reference ids of steps inside its branches. Use \`results.<branchall_module_id>\` instead
@@ -84850,6 +85623,41 @@ JavaScript transform (dynamic expression):
84850
85623
  - For flow inputs: Use type \`"object"\` with format \`"resource-{type}"\` (e.g., \`"resource-postgresql"\`)
84851
85624
  - For step inputs: Use static value \`"$res:path/to/resource"\`
84852
85625
 
85626
+ ## Reusing Existing Scripts and Flows
85627
+
85628
+ Unless the user asked for new code, look for a workspace script or flow that already does a step's job before writing it, and reuse it by path instead of copying its logic into a rawscript:
85629
+
85630
+ - a workspace script: \`type: script\` with \`path\` (e.g. \`f/folder/send_email\`)
85631
+ - a workspace flow, run as a subflow: \`type: flow\` with \`path\`
85632
+ - a Hub script: \`type: script\` with a \`hub/<version>/<app>/<name>\` path
85633
+
85634
+ The step's \`input_transforms\` must cover the reused item's inputs, so read its input schema first.
85635
+ Find candidates in the local tree (a \`.script.yaml\` sits next to each script and holds its input schema, a \`flow.yaml\` in each flow folder) and on the workspace with \`wmill script list\` / \`wmill flow list\`; \`wmill script get <path>\` and \`wmill flow get <path>\` show an item's details.
85636
+
85637
+ ## Organizing Flows: Groups and Notes
85638
+
85639
+ Groups and notes shape how a flow reads in the editor; neither changes what it does.
85640
+
85641
+ **Segment every non-trivial flow into groups without waiting to be asked.** Whenever a flow has more than a couple of steps, or consecutive steps form a stage ("fetch", "transform", "notify"), put them in a group, and aim for every meaningful step to belong to one. Use notes sparingly, for flow-wide information that belongs to no span of steps: the flow's purpose, key assumptions, warnings, TODOs. One note is usually enough; never label a run of steps with a note, which is what a group is for.
85642
+
85643
+ \`value.groups\` lists the groups, each spanning the steps from \`start_id\` to \`end_id\`:
85644
+
85645
+ - \`start_id\`, \`end_id\` (required): ids of the group's first and last step; the same id for both makes a one-step group
85646
+ - \`summary\`: the group's title
85647
+ - \`note\`: markdown shown under the title
85648
+ - \`color\`: one of \`yellow\`, \`blue\`, \`green\`, \`purple\`, \`pink\`, \`orange\`, \`red\`, \`cyan\`, \`lime\`, \`gray\`, never a hex code or CSS color; leave it out and the editor picks one
85649
+ - \`autocollapse\`: \`true\` shows the group collapsed by default
85650
+
85651
+ The editor refuses to draw a flow whose groups break any of these rules:
85652
+
85653
+ - \`start_id\` and \`end_id\` are steps of the same list: both top-level, or both in the same loop body or branch. A group can hold a loop or branch step whole, but cannot start outside one and end inside it
85654
+ - \`start_id\` does not come after \`end_id\` in that list
85655
+ - groups nest (one entirely inside another) but never partly overlap, and no two groups share both \`start_id\` and \`end_id\`
85656
+ - groups hold ordinary steps only: never \`preprocessor\`, \`failure\`, \`Input\`, \`Result\`, \`Trigger\`, or an AI agent's tools
85657
+
85658
+ \`value.notes\` lists sticky notes, each with a unique \`id\`, markdown \`text\`, a \`color\` from the same list, and \`type: free\`. The \`group\` note type is deprecated; use \`value.groups\` instead.
85659
+ Give each note a \`position\` (\`{ x, y }\`) and a \`size\` (\`{ width, height }\`): the editor draws a note without them at the origin and cannot resize it. \`x: -400\` with \`width: 275\` places it beside the graph.
85660
+
84853
85661
  ## Final Structural Self-Check
84854
85662
 
84855
85663
  Before finalizing a flow, verify:
@@ -84859,6 +85667,8 @@ Before finalizing a flow, verify:
84859
85667
  - any approval step has module-level \`suspend\`
84860
85668
  - no downstream step references inner branch step ids from outside the branch
84861
85669
  - every AI agent flowmodule tool has a unique \`summary\` made only of letters, numbers and underscores
85670
+ - every group starts and ends on steps of the same list, start before end, nesting without partial overlap
85671
+ - \`wmill lint <flow folder>\` reports no error
84862
85672
 
84863
85673
  ## S3 Object Operations
84864
85674
 
@@ -84913,10 +85723,10 @@ Reference a specific resource using \`$res:\` prefix:
84913
85723
  }
84914
85724
  \`\`\`
84915
85725
 
84916
-
84917
85726
  ## OpenFlow Schema
84918
85727
 
84919
- {"OpenFlow":{"type":"object","description":"Top-level flow definition containing metadata, configuration, and the flow structure","properties":{"summary":{"type":"string","description":"Short description of what this flow does"},"description":{"type":"string","description":"Detailed documentation for this flow"},"value":{"$ref":"#/components/schemas/FlowValue"},"schema":{"type":"object","description":"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')"},"on_behalf_of_email":{"type":"string","description":"Address of the account the flow runs on behalf of. Derived from on_behalf_of on read; accepted on write, where it is resolved to the account it names."},"on_behalf_of":{"type":"string","description":"The flow runs with the permissions of this identity: u/{username}, g/{group}, or a bare email when the username is itself email-shaped. The only stored half of the identity; on_behalf_of_email is derived from it. Omit it when writing and it is resolved from that address instead."}},"required":["summary","value"]},"FlowValue":{"type":"object","description":"The flow structure containing modules and optional preprocessor/failure handlers","properties":{"modules":{"type":"array","description":"Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch","items":{"$ref":"#/components/schemas/FlowModule"}},"failure_module":{"description":"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","$ref":"#/components/schemas/FlowModule"},"preprocessor_module":{"description":"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","$ref":"#/components/schemas/FlowModule"},"same_worker":{"type":"boolean","description":"If true, all steps run on the same worker for better performance"},"preserve_step_tags":{"type":"boolean","description":"If true and the flow runs on a custom worker tag, steps that declare their own non-empty tag run on it instead of inheriting the flow tag. Steps without their own tag still inherit the flow tag."},"concurrent_limit":{"type":"number","description":"Maximum number of concurrent executions of this flow"},"concurrency_key":{"type":"string","description":"Expression to group concurrent executions (e.g., by user ID)"},"concurrency_time_window_s":{"type":"number","description":"Time window in seconds for concurrent_limit"},"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce flow executions"},"debounce_key":{"type":"string","description":"Expression to group debounced executions"},"debounce_args_to_accumulate":{"type":"array","description":"Arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds that a job can be debounced"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of times a job can be debounced"},"skip_expr":{"type":"string","description":"JavaScript expression to conditionally skip the entire flow"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for flow results"},"cache_ignore_s3_path":{"type":"boolean"},"delete_after_secs":{"type":"integer","description":"If set, delete the flow job's args, result and logs after this many seconds following job completion"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note (e.g., \\"yellow\\", \\"#ffff00\\")"},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor"}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."},"error_include_result":{"type":"boolean","description":"When stopping with an error (error_message set), embed the stopping step's own result inside the raised error object (as error.result) instead of discarding it. The top-level result stays { error }. Defaults to false."}},"required":["expr"]},"FlowModule":{"type":"object","description":"A single step in a flow. Can be a script, subflow, loop, or branch","properties":{"id":{"type":"string","description":"Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)"},"value":{"$ref":"#/components/schemas/FlowModuleValue"},"stop_after_if":{"description":"Early termination condition evaluated after this step completes","$ref":"#/components/schemas/StopAfterIf"},"stop_after_all_iters_if":{"description":"For loops only - early termination condition evaluated after all iterations complete","$ref":"#/components/schemas/StopAfterIf"},"skip_if":{"type":"object","description":"Conditionally skip this step based on previous results or flow inputs","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'"}},"required":["expr"]},"sleep":{"description":"Delay before executing this step (in seconds or as expression)","$ref":"#/components/schemas/InputTransform"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for this step's results"},"cache_ignore_s3_path":{"type":"boolean"},"timeout":{"description":"Maximum execution time in seconds (static value or expression)","$ref":"#/components/schemas/InputTransform"},"delete_after_secs":{"type":"integer","description":"If set, delete the step's args, result and logs after this many seconds following job completion"},"summary":{"type":"string","description":"Short description of what this step does"},"mock":{"type":"object","description":"Mock configuration for testing without executing the actual step","properties":{"enabled":{"type":"boolean","description":"If true, return mock value instead of executing"},"return_value":{"description":"Value to return when mocked"}}},"suspend":{"type":"object","description":"Configuration for approval/resume steps that wait for user input","properties":{"required_events":{"type":"integer","description":"Number of approvals required before continuing"},"timeout":{"type":"integer","description":"Timeout in seconds before auto-continuing or canceling"},"resume_form":{"type":"object","description":"Form schema for collecting input when resuming","properties":{"schema":{"type":"object","description":"JSON Schema for the resume form"}}},"user_auth_required":{"type":"boolean","description":"If true, only authenticated users can approve"},"user_groups_required":{"description":"Expression or list of groups that can approve","$ref":"#/components/schemas/InputTransform"},"self_approval_disabled":{"type":"boolean","description":"If true, the user who started the flow cannot approve"},"hide_cancel":{"type":"boolean","description":"If true, hide the cancel button on the approval form"},"continue_on_disapprove_timeout":{"type":"boolean","description":"If true, continue flow on timeout instead of canceling"},"skin":{"type":"string","enum":["detailed","minimal"],"description":"How the approval request is presented, on the approval page and in Slack/Teams approval messages. 'detailed' (used when unset) shows the flow details (arguments, graph, approvers); 'minimal' shows only the request: the step description, form and approve/reject actions"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside for loops, use 'flow_input.iter.value' for the current iteration value (in while loops it equals 'flow_input.iter.index')","properties":{"expr":{"type":"string","description":"JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)"},"type":{"type":"string","enum":["javascript"]}},"required":["expr","type"]},"AiTransform":{"type":"object","description":"Value resolved by the AI runtime for this input. The AI engine decides how to satisfy the parameter.","properties":{"type":{"type":"string","enum":["ai"]}},"required":["type"]},"AIProviderKind":{"type":"string","description":"Supported AI provider types","enum":["openai","azure_openai","azure_foundry","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"},"reasoning_effort":{"type":"string","description":"Provider-native reasoning effort token (e.g. 'low', 'high', 'none') for models that support extended thinking. Optional; unset leaves the provider default."}},"required":["kind","resource","model"]},"StaticProviderTransform":{"type":"object","description":"Static provider configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/ProviderConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"ProviderTransform":{"description":"Provider configuration - can be static (ProviderConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticProviderTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticProviderTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"MemoryOff":{"type":"object","description":"No conversation memory/context","properties":{"kind":{"type":"string","enum":["off"]}},"required":["kind"]},"MemoryWindow":{"type":"object","description":"Keeps the most recent messages of the memory named by the run's memory id (or the step's\\n\`memory_id\`). Without a memory id the agent runs without memory.\\n","properties":{"kind":{"type":"string","enum":["window"]},"context_length":{"type":"integer","description":"Number of most recent messages to load and store. 0 turns memory off."}},"required":["kind","context_length"]},"MemoryAuto":{"type":"object","deprecated":true,"description":"Deprecated, still read as it was written: the run's memory id, else the \`memory_id\` here.\\nThe step's own \`memory_id\` is not read while this kind is set; switch the kind to \`window\`\\nto use it. Without a \`context_length\`, or with 0, it is \`off\` and reads \`previous_messages\`.\\n","properties":{"kind":{"type":"string","enum":["auto"]},"context_length":{"type":"integer","description":"Maximum number of messages to retain in context"},"memory_id":{"type":"string","description":"Identifier for persistent memory across agent invocations"}},"required":["kind"]},"MemoryMessage":{"type":"object","description":"A single message in conversation history","properties":{"role":{"type":"string","enum":["user","assistant","system"]},"content":{"type":"string"}},"required":["role","content"]},"MemoryManual":{"type":"object","deprecated":true,"description":"Deprecated, still read as it was written. Move the step to \`off\` with \`previous_messages\` instead.","properties":{"kind":{"type":"string","enum":["manual"]},"messages":{"type":"array","items":{"$ref":"#/components/schemas/MemoryMessage"}}},"required":["kind","messages"]},"MemoryConfig":{"description":"Managed memory, stored by Windmill and replayed with each request. The memory is named by a memory id, see \`memory_id\`. While it is off, a step can supply its history in \`previous_messages\`.","oneOf":[{"$ref":"#/components/schemas/MemoryOff"},{"$ref":"#/components/schemas/MemoryWindow"},{"$ref":"#/components/schemas/MemoryAuto"},{"$ref":"#/components/schemas/MemoryManual"}],"discriminator":{"propertyName":"kind","mapping":{"off":"#/components/schemas/MemoryOff","window":"#/components/schemas/MemoryWindow","auto":"#/components/schemas/MemoryAuto","manual":"#/components/schemas/MemoryManual"}}},"StaticMemoryTransform":{"type":"object","description":"Static memory configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/MemoryConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"MemoryTransform":{"description":"Memory configuration - can be static (MemoryConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticMemoryTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticMemoryTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"FlowModuleValue":{"description":"The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type","oneOf":[{"$ref":"#/components/schemas/RawScript"},{"$ref":"#/components/schemas/PathScript"},{"$ref":"#/components/schemas/PathFlow"},{"$ref":"#/components/schemas/ForloopFlow"},{"$ref":"#/components/schemas/WhileloopFlow"},{"$ref":"#/components/schemas/BranchOne"},{"$ref":"#/components/schemas/BranchAll"},{"$ref":"#/components/schemas/Identity"},{"$ref":"#/components/schemas/AiAgent"}],"discriminator":{"propertyName":"type","mapping":{"rawscript":"#/components/schemas/RawScript","script":"#/components/schemas/PathScript","flow":"#/components/schemas/PathFlow","forloopflow":"#/components/schemas/ForloopFlow","whileloopflow":"#/components/schemas/WhileloopFlow","branchone":"#/components/schemas/BranchOne","branchall":"#/components/schemas/BranchAll","identity":"#/components/schemas/Identity","aiagent":"#/components/schemas/AiAgent"}}},"RawScript":{"type":"object","description":"Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"content":{"type":"string","description":"The script source code. Should export a 'main' function"},"language":{"type":"string","description":"Programming language for this script","enum":["deno","bun","bunnative","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","rlang","duckdb"]},"path":{"type":"string","description":"Optional path for saving this script"},"lock":{"type":"string","description":"Lock file content for dependencies"},"type":{"type":"string","enum":["rawscript"]},"tag":{"type":"string","description":"Worker group tag for execution routing"},"concurrent_limit":{"type":"number","description":"Maximum concurrent executions of this script"},"concurrency_time_window_s":{"type":"number","description":"Time window for concurrent_limit"},"custom_concurrency_key":{"type":"string","description":"Custom key for grouping concurrent executions"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"},"assets":{"type":"array","description":"External resources this script accesses (S3 objects, resources, etc.)","items":{"type":"object","required":["path","kind"],"properties":{"path":{"type":"string","description":"Path to the asset"},"kind":{"type":"string","description":"Type of asset","enum":["s3object","resource","ducklake","datatable","volume","dbt"]},"access_type":{"type":"string","nullable":true,"description":"Access level for this asset","enum":["r","w","rw"]},"alt_access_type":{"type":"string","nullable":true,"description":"Alternative access level","enum":["r","w","rw"]}}}}},"required":["type","content","language","input_transforms"]},"PathScript":{"type":"object","description":"Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the script in the workspace (e.g., 'f/scripts/send_email')"},"hash":{"type":"string","description":"Optional specific version hash of the script to use"},"type":{"type":"string","enum":["script"]},"tag_override":{"type":"string","description":"Override the script's default worker group tag"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"}},"required":["type","path","input_transforms"]},"PathFlow":{"type":"object","description":"Reference to an existing flow by path. Use this to call another flow as a subflow","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the flow in the workspace (e.g., 'f/flows/process_user')"},"type":{"type":"string","enum":["flow"]}},"required":["type","path","input_transforms"]},"ForloopFlow":{"type":"object","description":"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","properties":{"modules":{"type":"array","description":"Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'","items":{"$ref":"#/components/schemas/FlowModule"}},"iterator":{"description":"JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'","$ref":"#/components/schemas/InputTransform"},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["forloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","iterator","skip_failures","type"]},"WhileloopFlow":{"type":"object","description":"Executes nested modules repeatedly until stopped. The implicit iterator is the iteration counter, so 'flow_input.iter.value' equals 'flow_input.iter.index' (0, 1, 2, ...) and never carries state. To carry state across iterations, a step reads its own previous-iteration result via 'results.<its_own_id>' with a first-iteration fallback - the loop's stop_after_if must then be on that inner step (a plain single-step body with stop_after_if on the loop module does not resolve 'results' across iterations and never terminates); plain counters can instead be derived from 'flow_input.iter.index', which works in every configuration. stop_after_if is evaluated after each iteration - on the loop module 'result' is the last iteration's result","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration","items":{"$ref":"#/components/schemas/FlowModule"}},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["whileloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (use with caution in while loops)"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","skip_failures","type"]},"BranchOne":{"type":"object","description":"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","properties":{"branches":{"type":"array","description":"Array of branches to evaluate in order. The first branch with expr evaluating to true executes","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch condition"},"expr":{"type":"string","description":"JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins"},"modules":{"type":"array","description":"Steps to execute if this branch's expr is true","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules","expr"]}},"default":{"type":"array","description":"Steps to execute if no branch expressions match","items":{"$ref":"#/components/schemas/FlowModule"}},"type":{"type":"string","enum":["branchone"]}},"required":["branches","default","type"]},"BranchAll":{"type":"object","description":"Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently","properties":{"branches":{"type":"array","description":"Array of branches that all execute (either in parallel or sequentially)","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch's purpose"},"skip_failure":{"type":"boolean","description":"If true, failure in this branch doesn't fail the entire flow"},"modules":{"type":"array","description":"Steps to execute in this branch","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules"]}},"type":{"type":"string","enum":["branchall"]},"parallel":{"type":"boolean","description":"If true, all branches execute concurrently. If false, they execute sequentially"}},"required":["branches","type"]},"AgentTool":{"type":"object","description":"A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool","properties":{"id":{"type":"string","description":"Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')"},"summary":{"type":"string","description":"The name the AI agent calls this tool by, not a human label. On a flowmodule tool it must match ^[a-zA-Z0-9_]+$ - letters, numbers and underscores only (e.g. 'search_documentation', not 'Search documentation') - and always be set; on an mcp or websearch tool it is a plain label. Put the human-readable explanation in 'description'."},"description":{"type":"string","description":"Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script."},"value":{"$ref":"#/components/schemas/ToolValue"}},"required":["id","value"]},"ToolValue":{"description":"The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference","oneOf":[{"$ref":"#/components/schemas/FlowModuleTool"},{"$ref":"#/components/schemas/McpToolValue"},{"$ref":"#/components/schemas/WebsearchToolValue"}],"discriminator":{"propertyName":"tool_type","mapping":{"flowmodule":"#/components/schemas/FlowModuleTool","mcp":"#/components/schemas/McpToolValue","websearch":"#/components/schemas/WebsearchToolValue"}}},"FlowModuleTool":{"description":"A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module","allOf":[{"type":"object","properties":{"tool_type":{"type":"string","enum":["flowmodule"]}},"required":["tool_type"]},{"$ref":"#/components/schemas/FlowModuleValue"}]},"WebsearchToolValue":{"type":"object","description":"A tool implemented as a websearch tool. The AI can call this like any other websearch tool","properties":{"tool_type":{"type":"string","enum":["websearch"]}},"required":["tool_type"]},"McpToolValue":{"type":"object","description":"Reference to an external MCP (Model Context Protocol) tool. The AI can call tools from MCP servers","properties":{"tool_type":{"type":"string","enum":["mcp"]},"resource_path":{"type":"string","description":"Path to the MCP resource/server configuration"},"include_tools":{"type":"array","description":"Whitelist of specific tools to include from this MCP server","items":{"type":"string"}},"exclude_tools":{"type":"array","description":"Blacklist of tools to exclude from this MCP server","items":{"type":"string"}}},"required":["tool_type","resource_path"]},"AiAgent":{"type":"object","description":"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","properties":{"input_transforms":{"type":"object","description":"Input parameters for the AI agent mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"output_type":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Output format type.\\nValid values: 'text' (default) - plain text response, 'image' - image generation\\n"},"user_message":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"The user's prompt/message to the AI agent. Supports variable interpolation with\\nflow.input syntax. Required unless memory is off and \`previous_messages\` supplies\\nthe prompt; image output always needs it.\\n"},"system_prompt":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"System instructions that guide the AI's behavior, persona, and response style. Optional."},"streaming":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Boolean. If true, stream the AI response incrementally.\\nStreaming events include: token_delta, reasoning_token_delta, tool_call, tool_call_arguments, tool_execution, tool_result\\n"},"memory":{"$ref":"#/components/schemas/MemoryTransform"},"memory_id":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Names the memory this step reads and writes, overriding the memory id the run\\nwas started with (the chat conversation, an app chat session or the \`memory_id\` run\\nparameter). Leave unset to use the run's memory id. A fixed value shares one memory\\nacross every run; an expression such as \`flow_input.customer_id\` keeps one memory per\\nkey. When it evaluates to an empty value the agent runs without memory. Read only\\nwhile \`memory\` is \`window\`: it is ignored when memory is off, and an older \`auto\` or\\n\`manual\` memory reads neither history input.\\n"},"previous_messages":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of MemoryMessage. History supplied by the flow, sent between the system prompt\\nand the user message. Read only while \`memory\` is off or absent: managed memory\\nignores it, and an older \`auto\` or \`manual\` memory reads neither history input.\\n"},"output_schema":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"JSON Schema object defining structured output format. Used when you need the AI to return data in a specific shape.\\nSupports standard JSON Schema properties: type, properties, required, items, enum, pattern, minLength, maxLength, minimum, maximum, etc.\\nExample: { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' } }, required: ['name'] }\\n"},"user_attachments":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of file references (images or PDFs) for the AI agent.\\nFormat: Array<{ bucket: string, key: string }> - S3 object references\\nExample: [{ bucket: 'my-bucket', key: 'documents/report.pdf' }]\\n"},"enabled_tools":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of strings naming which of the tools configured in \`tools\` the agent may call\\nthis run. Leaving it unset carries every one of them; an empty array carries none.\\nA tool is named as the model is shown it. An entry the model is shown nothing of is\\nnamed by what identifies it instead: an MCP server by its resource path, carrying\\nevery tool it exposes (which of them stays that entry's include_tools/exclude_tools),\\nand a websearch entry by the reserved name '__wm_web_search', whatever summary it carries\\n(no tool may take that name).\\nExample: ['get_user', 'u/admin/github_mcp', '__wm_web_search']\\n"},"max_completion_tokens":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Integer. Maximum number of tokens the AI will generate in its response.\\nRange: 1 to 4,294,967,295. Typical values: 256-4096 for most use cases.\\n"},"temperature":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Float. Controls randomness/creativity of responses.\\nRange: 0.0 to 2.0 (provider-dependent)\\n- 0.0 = deterministic, focused responses\\n- 0.7 = balanced (common default)\\n- 1.0+ = more creative/random\\n"},"max_iterations":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Number. Limits how many times the agent can loop through reasoning and tool use.\\nRange: 1-1000.\\n"}}},"tools":{"type":"array","description":"Array of tools the agent can use. The agent decides which tools to call based on the task","items":{"$ref":"#/components/schemas/AgentTool"}},"type":{"type":"string","enum":["aiagent"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the AI agent step runs on the flow's tag (default \`flow\`)"},"omit_output_from_conversation":{"type":"boolean","default":false,"description":"If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled."},"agent":{"type":"string","description":"Path of a reusable \`ai_agent\` resource (hybrid linking). When set, the agent brain\\nconfig (provider/model/system prompt/etc.) and tool set are resolved at runtime from\\nthat resource; the module's input_transforms then only carry the flow-local inputs\\n(user_message, user_attachments, enabled_tools and the history inputs memory_id and previous_messages).\\n"},"tool_inputs":{"type":"object","description":"Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the\\nreferenced agent's tools to this flow's context (flow_input/results) without mutating the\\nshared resource; overlaid onto the tools' input_transforms at runtime \\u2014 including when\\n\`agent\` is unset, since a step forked for editing keeps these overrides until it is saved\\nback or unlinked.\\n","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}}},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["type","input_transforms"]},"Identity":{"type":"object","description":"Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder","properties":{"type":{"type":"string","enum":["identity"]},"flow":{"type":"boolean","description":"If true, marks this as a flow identity (special handling)"}},"required":["type"]},"FlowStatus":{"type":"object","properties":{"step":{"type":"integer"},"modules":{"type":"array","items":{"$ref":"#/components/schemas/FlowStatusModule"}},"user_states":{"additionalProperties":true},"preprocessor_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"}]},"failure_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"},{"type":"object","properties":{"parent_module":{"type":"string"}}}]},"retry":{"type":"object","properties":{"fail_count":{"type":"integer"},"failed_jobs":{"type":"array","items":{"type":"string","format":"uuid"}}}}},"required":["step","modules","failure_module"]},"FlowStatusModule":{"type":"object","properties":{"type":{"type":"string","enum":["WaitingForPriorSteps","WaitingForEvents","WaitingForExecutor","InProgress","Success","Failure"]},"id":{"type":"string"},"job":{"type":"string","format":"uuid"},"count":{"type":"integer"},"progress":{"type":"integer"},"iterator":{"type":"object","properties":{"index":{"type":"integer"},"itered":{"type":"array","items":{}},"itered_len":{"type":"integer"},"args":{}}},"flow_jobs":{"type":"array","items":{"type":"string"}},"flow_jobs_success":{"type":"array","items":{"type":"boolean"}},"flow_jobs_duration":{"type":"object","properties":{"started_at":{"type":"array","items":{"type":"string"}},"duration_ms":{"type":"array","items":{"type":"integer"}}}},"branch_chosen":{"type":"object","properties":{"type":{"type":"string","enum":["branch","default"]},"branch":{"type":"integer"}},"required":["type"]},"branchall":{"type":"object","properties":{"branch":{"type":"integer"},"len":{"type":"integer"}},"required":["branch","len"]},"approvers":{"type":"array","items":{"type":"object","properties":{"resume_id":{"type":"integer"},"approver":{"type":"string"}},"required":["resume_id","approver"]}},"failed_retries":{"type":"array","items":{"type":"string","format":"uuid"}},"skipped":{"type":"boolean"},"agent_actions":{"type":"array","items":{"type":"object","oneOf":[{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"type":{"type":"string","enum":["tool_call"]},"module_id":{"type":"string"}},"required":["job_id","function_name","type","module_id"]},{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"resource_path":{"type":"string"},"type":{"type":"string","enum":["mcp_tool_call"]},"arguments":{"type":"object"}},"required":["call_id","function_name","resource_path","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]}},"required":["content","type"]}]}},"agent_actions_success":{"type":"array","items":{"type":"boolean"}}},"required":["type"]}}`,
85728
+ {"OpenFlow":{"type":"object","description":"Top-level flow definition containing metadata, configuration, and the flow structure","properties":{"summary":{"type":"string","description":"Short description of what this flow does"},"description":{"type":"string","description":"Detailed documentation for this flow"},"value":{"$ref":"#/components/schemas/FlowValue"},"schema":{"type":"object","description":"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')"},"on_behalf_of_email":{"type":"string","description":"Address of the account the flow runs on behalf of. Derived from on_behalf_of on read; accepted on write, where it is resolved to the account it names."},"on_behalf_of":{"type":"string","description":"The flow runs with the permissions of this identity: u/{username}, g/{group}, or a bare email when the username is itself email-shaped. The only stored half of the identity; on_behalf_of_email is derived from it. Omit it when writing and it is resolved from that address instead."}},"required":["summary","value"]},"FlowValue":{"type":"object","description":"The flow structure containing modules and optional preprocessor/failure handlers","properties":{"modules":{"type":"array","description":"Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch","items":{"$ref":"#/components/schemas/FlowModule"}},"failure_module":{"description":"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","$ref":"#/components/schemas/FlowModule"},"preprocessor_module":{"description":"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","$ref":"#/components/schemas/FlowModule"},"same_worker":{"type":"boolean","description":"If true, all steps run on the same worker for better performance"},"preserve_step_tags":{"type":"boolean","description":"If true and the flow runs on a custom worker tag, steps that declare their own non-empty tag run on it instead of inheriting the flow tag. Steps without their own tag still inherit the flow tag."},"concurrent_limit":{"type":"number","description":"Maximum number of concurrent executions of this flow"},"concurrency_key":{"type":"string","description":"Expression to group concurrent executions (e.g., by user ID)"},"concurrency_time_window_s":{"type":"number","description":"Time window in seconds for concurrent_limit"},"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce flow executions"},"debounce_key":{"type":"string","description":"Expression to group debounced executions"},"debounce_args_to_accumulate":{"type":"array","description":"Arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds that a job can be debounced"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of times a job can be debounced"},"skip_expr":{"type":"string","description":"JavaScript expression to conditionally skip the entire flow"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for flow results"},"cache_ignore_s3_path":{"type":"boolean"},"delete_after_secs":{"type":"integer","description":"If set, delete the flow job's args, result and logs after this many seconds following job completion"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note, one of: yellow, blue, green, purple, pink, orange, red, cyan, lime, gray. Any other value renders unstyled."},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes. 'group' notes are deprecated; segment a flow with FlowValue.groups instead."},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor, one of: yellow, blue, green, purple, pink, orange, red, cyan, lime, gray. Omit it to let the editor pick one."}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."},"error_include_result":{"type":"boolean","description":"When stopping with an error (error_message set), embed the stopping step's own result inside the raised error object (as error.result) instead of discarding it. The top-level result stays { error }. Defaults to false."}},"required":["expr"]},"FlowModule":{"type":"object","description":"A single step in a flow. Can be a script, subflow, loop, or branch","properties":{"id":{"type":"string","description":"Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)"},"value":{"$ref":"#/components/schemas/FlowModuleValue"},"stop_after_if":{"description":"Early termination condition evaluated after this step completes","$ref":"#/components/schemas/StopAfterIf"},"stop_after_all_iters_if":{"description":"For loops only - early termination condition evaluated after all iterations complete","$ref":"#/components/schemas/StopAfterIf"},"skip_if":{"type":"object","description":"Conditionally skip this step based on previous results or flow inputs","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'"}},"required":["expr"]},"sleep":{"description":"Delay before executing this step (in seconds or as expression)","$ref":"#/components/schemas/InputTransform"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for this step's results"},"cache_ignore_s3_path":{"type":"boolean"},"timeout":{"description":"Maximum execution time in seconds (static value or expression)","$ref":"#/components/schemas/InputTransform"},"delete_after_secs":{"type":"integer","description":"If set, delete the step's args, result and logs after this many seconds following job completion"},"summary":{"type":"string","description":"Short description of what this step does"},"mock":{"type":"object","description":"Mock configuration for testing without executing the actual step","properties":{"enabled":{"type":"boolean","description":"If true, return mock value instead of executing"},"return_value":{"description":"Value to return when mocked"}}},"suspend":{"type":"object","description":"Configuration for approval/resume steps that wait for user input","properties":{"required_events":{"type":"integer","description":"Number of approvals required before continuing"},"timeout":{"type":"integer","description":"Timeout in seconds before auto-continuing or canceling"},"resume_form":{"type":"object","description":"Form schema for collecting input when resuming","properties":{"schema":{"type":"object","description":"JSON Schema for the resume form"}}},"user_auth_required":{"type":"boolean","description":"If true, only authenticated users can approve"},"user_groups_required":{"description":"Expression or list of groups that can approve","$ref":"#/components/schemas/InputTransform"},"self_approval_disabled":{"type":"boolean","description":"If true, the user who started the flow cannot approve"},"hide_cancel":{"type":"boolean","description":"If true, hide the cancel button on the approval form"},"continue_on_disapprove_timeout":{"type":"boolean","description":"If true, continue flow on timeout instead of canceling"},"skin":{"type":"string","enum":["detailed","minimal"],"description":"How the approval request is presented, on the approval page and in Slack/Teams approval messages. 'detailed' (used when unset) shows the flow details (arguments, graph, approvers); 'minimal' shows only the request: the step description, form and approve/reject actions"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside for loops, use 'flow_input.iter.value' for the current iteration value (in while loops it equals 'flow_input.iter.index')","properties":{"expr":{"type":"string","description":"JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)"},"type":{"type":"string","enum":["javascript"]}},"required":["expr","type"]},"AiTransform":{"type":"object","description":"Value resolved by the AI runtime for this input. The AI engine decides how to satisfy the parameter.","properties":{"type":{"type":"string","enum":["ai"]}},"required":["type"]},"AIProviderKind":{"type":"string","description":"Supported AI provider types","enum":["openai","azure_openai","azure_foundry","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"},"reasoning_effort":{"type":"string","description":"Provider-native reasoning effort token (e.g. 'low', 'high', 'none') for models that support extended thinking. Optional; unset leaves the provider default."}},"required":["kind","resource","model"]},"StaticProviderTransform":{"type":"object","description":"Static provider configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/ProviderConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"ProviderTransform":{"description":"Provider configuration - can be static (ProviderConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticProviderTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticProviderTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"MemoryOff":{"type":"object","description":"No conversation memory/context","properties":{"kind":{"type":"string","enum":["off"]}},"required":["kind"]},"MemoryWindow":{"type":"object","description":"Keeps the most recent messages of the memory named by the run's memory id (or the step's\\n\`memory_id\`). Without a memory id the agent runs without memory.\\n","properties":{"kind":{"type":"string","enum":["window"]},"context_length":{"type":"integer","description":"Number of most recent messages to load and store. 0 turns memory off."}},"required":["kind","context_length"]},"MemoryAuto":{"type":"object","deprecated":true,"description":"Deprecated, still read as it was written: the run's memory id, else the \`memory_id\` here.\\nThe step's own \`memory_id\` is not read while this kind is set; switch the kind to \`window\`\\nto use it. Without a \`context_length\`, or with 0, it is \`off\` and reads \`previous_messages\`.\\n","properties":{"kind":{"type":"string","enum":["auto"]},"context_length":{"type":"integer","description":"Maximum number of messages to retain in context"},"memory_id":{"type":"string","description":"Identifier for persistent memory across agent invocations"}},"required":["kind"]},"MemoryCompaction":{"type":"object","description":"Keeps the whole memory named by the run's memory id (or the step's \`memory_id\`), replacing\\nits older part with a summary as the conversation approaches the model's context window.\\nWithout a memory id the agent runs without memory, and compaction bounds the run's own loop.\\n","properties":{"kind":{"type":"string","enum":["compaction"]},"context_window":{"type":"integer","description":"Overrides the context window looked up from the model, in tokens. Only a model\\nWindmill does not know needs one; those fall back to 128000.\\n"}},"required":["kind"]},"MemoryMessage":{"type":"object","description":"A single message in conversation history","properties":{"role":{"type":"string","enum":["user","assistant","system"]},"content":{"type":"string"}},"required":["role","content"]},"MemoryManual":{"type":"object","deprecated":true,"description":"Deprecated, still read as it was written. Move the step to \`off\` with \`previous_messages\` instead.","properties":{"kind":{"type":"string","enum":["manual"]},"messages":{"type":"array","items":{"$ref":"#/components/schemas/MemoryMessage"}}},"required":["kind","messages"]},"MemoryConfig":{"description":"Managed memory, stored by Windmill and replayed with each request. The memory is named by a memory id, see \`memory_id\`. While it is off, a step can supply its history in \`previous_messages\`.","oneOf":[{"$ref":"#/components/schemas/MemoryOff"},{"$ref":"#/components/schemas/MemoryWindow"},{"$ref":"#/components/schemas/MemoryCompaction"},{"$ref":"#/components/schemas/MemoryAuto"},{"$ref":"#/components/schemas/MemoryManual"}],"discriminator":{"propertyName":"kind","mapping":{"off":"#/components/schemas/MemoryOff","window":"#/components/schemas/MemoryWindow","compaction":"#/components/schemas/MemoryCompaction","auto":"#/components/schemas/MemoryAuto","manual":"#/components/schemas/MemoryManual"}}},"StaticMemoryTransform":{"type":"object","description":"Static memory configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/MemoryConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"MemoryTransform":{"description":"Memory configuration - can be static (MemoryConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticMemoryTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticMemoryTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"FlowModuleValue":{"description":"The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type","oneOf":[{"$ref":"#/components/schemas/RawScript"},{"$ref":"#/components/schemas/PathScript"},{"$ref":"#/components/schemas/PathFlow"},{"$ref":"#/components/schemas/ForloopFlow"},{"$ref":"#/components/schemas/WhileloopFlow"},{"$ref":"#/components/schemas/BranchOne"},{"$ref":"#/components/schemas/BranchAll"},{"$ref":"#/components/schemas/Identity"},{"$ref":"#/components/schemas/AiAgent"}],"discriminator":{"propertyName":"type","mapping":{"rawscript":"#/components/schemas/RawScript","script":"#/components/schemas/PathScript","flow":"#/components/schemas/PathFlow","forloopflow":"#/components/schemas/ForloopFlow","whileloopflow":"#/components/schemas/WhileloopFlow","branchone":"#/components/schemas/BranchOne","branchall":"#/components/schemas/BranchAll","identity":"#/components/schemas/Identity","aiagent":"#/components/schemas/AiAgent"}}},"RawScript":{"type":"object","description":"Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"content":{"type":"string","description":"The script source code. Should export a 'main' function"},"language":{"type":"string","description":"Programming language for this script","enum":["deno","bun","bunnative","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","rlang","duckdb"]},"path":{"type":"string","description":"Optional path for saving this script"},"lock":{"type":"string","description":"Lock file content for dependencies"},"type":{"type":"string","enum":["rawscript"]},"tag":{"type":"string","description":"Worker group tag for execution routing"},"concurrent_limit":{"type":"number","description":"Maximum concurrent executions of this script"},"concurrency_time_window_s":{"type":"number","description":"Time window for concurrent_limit"},"custom_concurrency_key":{"type":"string","description":"Custom key for grouping concurrent executions"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"},"assets":{"type":"array","description":"External resources this script accesses (S3 objects, resources, etc.)","items":{"type":"object","required":["path","kind"],"properties":{"path":{"type":"string","description":"Path to the asset"},"kind":{"type":"string","description":"Type of asset","enum":["s3object","resource","ducklake","datatable","volume","dbt"]},"access_type":{"type":"string","nullable":true,"description":"Access level for this asset","enum":["r","w","rw"]},"alt_access_type":{"type":"string","nullable":true,"description":"Alternative access level","enum":["r","w","rw"]}}}}},"required":["type","content","language","input_transforms"]},"PathScript":{"type":"object","description":"Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the script in the workspace (e.g., 'f/scripts/send_email')"},"hash":{"type":"string","description":"Optional specific version hash of the script to use"},"type":{"type":"string","enum":["script"]},"tag_override":{"type":"string","description":"Override the script's default worker group tag"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"}},"required":["type","path","input_transforms"]},"PathFlow":{"type":"object","description":"Reference to an existing flow by path. Use this to call another flow as a subflow","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the flow in the workspace (e.g., 'f/flows/process_user')"},"type":{"type":"string","enum":["flow"]}},"required":["type","path","input_transforms"]},"ForloopFlow":{"type":"object","description":"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","properties":{"modules":{"type":"array","description":"Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'","items":{"$ref":"#/components/schemas/FlowModule"}},"iterator":{"description":"JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'","$ref":"#/components/schemas/InputTransform"},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["forloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","iterator","skip_failures","type"]},"WhileloopFlow":{"type":"object","description":"Executes nested modules repeatedly until stopped. The implicit iterator is the iteration counter, so 'flow_input.iter.value' equals 'flow_input.iter.index' (0, 1, 2, ...) and never carries state. To carry state across iterations, a step reads its own previous-iteration result via 'results.<its_own_id>' with a first-iteration fallback - the loop's stop_after_if must then be on that inner step (a plain single-step body with stop_after_if on the loop module does not resolve 'results' across iterations and never terminates); plain counters can instead be derived from 'flow_input.iter.index', which works in every configuration. stop_after_if is evaluated after each iteration - on the loop module 'result' is the last iteration's result","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration","items":{"$ref":"#/components/schemas/FlowModule"}},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["whileloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (use with caution in while loops)"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","skip_failures","type"]},"BranchOne":{"type":"object","description":"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","properties":{"branches":{"type":"array","description":"Array of branches to evaluate in order. The first branch with expr evaluating to true executes","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch condition"},"expr":{"type":"string","description":"JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins"},"modules":{"type":"array","description":"Steps to execute if this branch's expr is true","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules","expr"]}},"default":{"type":"array","description":"Steps to execute if no branch expressions match","items":{"$ref":"#/components/schemas/FlowModule"}},"type":{"type":"string","enum":["branchone"]}},"required":["branches","default","type"]},"BranchAll":{"type":"object","description":"Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently","properties":{"branches":{"type":"array","description":"Array of branches that all execute (either in parallel or sequentially)","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch's purpose"},"skip_failure":{"type":"boolean","description":"If true, failure in this branch doesn't fail the entire flow"},"modules":{"type":"array","description":"Steps to execute in this branch","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules"]}},"type":{"type":"string","enum":["branchall"]},"parallel":{"type":"boolean","description":"If true, all branches execute concurrently. If false, they execute sequentially"}},"required":["branches","type"]},"AgentTool":{"type":"object","description":"A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool","properties":{"id":{"type":"string","description":"Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')"},"summary":{"type":"string","description":"The name the AI agent calls this tool by, not a human label. On a flowmodule tool it must match ^[a-zA-Z0-9_]+$ - letters, numbers and underscores only (e.g. 'search_documentation', not 'Search documentation') - and always be set; on an mcp or websearch tool it is a plain label. Put the human-readable explanation in 'description'."},"description":{"type":"string","description":"Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script."},"value":{"$ref":"#/components/schemas/ToolValue"}},"required":["id","value"]},"ToolValue":{"description":"The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference","oneOf":[{"$ref":"#/components/schemas/FlowModuleTool"},{"$ref":"#/components/schemas/McpToolValue"},{"$ref":"#/components/schemas/WebsearchToolValue"}],"discriminator":{"propertyName":"tool_type","mapping":{"flowmodule":"#/components/schemas/FlowModuleTool","mcp":"#/components/schemas/McpToolValue","websearch":"#/components/schemas/WebsearchToolValue"}}},"FlowModuleTool":{"description":"A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module","allOf":[{"type":"object","properties":{"tool_type":{"type":"string","enum":["flowmodule"]}},"required":["tool_type"]},{"$ref":"#/components/schemas/FlowModuleValue"}]},"WebsearchToolValue":{"type":"object","description":"A tool implemented as a websearch tool. The AI can call this like any other websearch tool","properties":{"tool_type":{"type":"string","enum":["websearch"]}},"required":["tool_type"]},"McpToolValue":{"type":"object","description":"Reference to an external MCP (Model Context Protocol) tool. The AI can call tools from MCP servers","properties":{"tool_type":{"type":"string","enum":["mcp"]},"resource_path":{"type":"string","description":"Path to the MCP resource/server configuration"},"include_tools":{"type":"array","description":"Whitelist of specific tools to include from this MCP server","items":{"type":"string"}},"exclude_tools":{"type":"array","description":"Blacklist of tools to exclude from this MCP server","items":{"type":"string"}}},"required":["tool_type","resource_path"]},"AiAgent":{"type":"object","description":"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","properties":{"input_transforms":{"type":"object","description":"Input parameters for the AI agent mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"output_type":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Output format type.\\nValid values: 'text' (default) - plain text response, 'image' - image generation\\n"},"user_message":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"The user's prompt/message to the AI agent. Supports variable interpolation with\\nflow.input syntax. Required unless memory is off and \`previous_messages\` supplies\\nthe prompt; image output always needs it.\\n"},"system_prompt":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"System instructions that guide the AI's behavior, persona, and response style. Optional."},"streaming":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Boolean. If true, stream the AI response incrementally.\\nStreaming events include: token_delta, reasoning_token_delta, tool_call, tool_call_arguments, tool_execution, tool_result\\n"},"memory":{"$ref":"#/components/schemas/MemoryTransform"},"memory_id":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Names the memory this step reads and writes, overriding the memory id the run\\nwas started with (the chat conversation, an app chat session or the \`memory_id\` run\\nparameter). Leave unset to use the run's memory id. A fixed value shares one memory\\nacross every run; an expression such as \`flow_input.customer_id\` keeps one memory per\\nkey. When it evaluates to an empty value the agent runs without memory. Read only\\nwhile \`memory\` is \`window\` or \`compaction\`: it is ignored when memory is off, and an\\nolder \`auto\` or \`manual\` memory reads neither history input.\\n"},"previous_messages":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of MemoryMessage. History supplied by the flow, sent between the system prompt\\nand the user message. Read only while \`memory\` is off or absent: managed memory\\nignores it, and an older \`auto\` or \`manual\` memory reads neither history input.\\n"},"output_schema":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"JSON Schema object defining structured output format. Used when you need the AI to return data in a specific shape.\\nSupports standard JSON Schema properties: type, properties, required, items, enum, pattern, minLength, maxLength, minimum, maximum, etc.\\nExample: { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' } }, required: ['name'] }\\n"},"user_attachments":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of file references (images or PDFs) for the AI agent.\\nFormat: Array<{ bucket: string, key: string }> - S3 object references\\nExample: [{ bucket: 'my-bucket', key: 'documents/report.pdf' }]\\n"},"enabled_tools":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of strings naming which of the tools configured in \`tools\` the agent may call\\nthis run. Leaving it unset carries every one of them; an empty array carries none.\\nA tool is named as the model is shown it. An entry the model is shown nothing of is\\nnamed by what identifies it instead: an MCP server by its resource path, carrying\\nevery tool it exposes (which of them stays that entry's include_tools/exclude_tools),\\nand a websearch entry by the reserved name '__wm_web_search', whatever summary it carries\\n(no tool may take that name).\\nExample: ['get_user', 'u/admin/github_mcp', '__wm_web_search']\\n"},"max_completion_tokens":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Integer. Maximum number of tokens the AI will generate in its response.\\nRange: 1 to 4,294,967,295. Typical values: 256-4096 for most use cases.\\n"},"temperature":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Float. Controls randomness/creativity of responses.\\nRange: 0.0 to 2.0 (provider-dependent)\\n- 0.0 = deterministic, focused responses\\n- 0.7 = balanced (common default)\\n- 1.0+ = more creative/random\\n"},"max_iterations":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Number. Limits how many times the agent can loop through reasoning and tool use.\\nRange: 1-1000.\\n"}}},"tools":{"type":"array","description":"Array of tools the agent can use. The agent decides which tools to call based on the task","items":{"$ref":"#/components/schemas/AgentTool"}},"type":{"type":"string","enum":["aiagent"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the AI agent step runs on the flow's tag (default \`flow\`)"},"omit_output_from_conversation":{"type":"boolean","default":false,"description":"If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled."},"agent":{"type":"string","description":"Path of a reusable \`ai_agent\` resource (hybrid linking). When set, the agent brain\\nconfig (provider/model/system prompt/etc.) and tool set are resolved at runtime from\\nthat resource; the module's input_transforms then only carry the flow-local inputs\\n(user_message, user_attachments, enabled_tools and the history inputs memory_id and previous_messages).\\n"},"tool_inputs":{"type":"object","description":"Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the\\nreferenced agent's tools to this flow's context (flow_input/results) without mutating the\\nshared resource; overlaid onto the tools' input_transforms at runtime \\u2014 including when\\n\`agent\` is unset, since a step forked for editing keeps these overrides until it is saved\\nback or unlinked.\\n","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}}},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["type","input_transforms"]},"Identity":{"type":"object","description":"Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder","properties":{"type":{"type":"string","enum":["identity"]},"flow":{"type":"boolean","description":"If true, marks this as a flow identity (special handling)"}},"required":["type"]},"FlowStatus":{"type":"object","properties":{"step":{"type":"integer"},"modules":{"type":"array","items":{"$ref":"#/components/schemas/FlowStatusModule"}},"user_states":{"additionalProperties":true},"preprocessor_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"}]},"failure_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"},{"type":"object","properties":{"parent_module":{"type":"string"}}}]},"retry":{"type":"object","properties":{"fail_count":{"type":"integer"},"failed_jobs":{"type":"array","items":{"type":"string","format":"uuid"}}}}},"required":["step","modules","failure_module"]},"FlowStatusModule":{"type":"object","properties":{"type":{"type":"string","enum":["WaitingForPriorSteps","WaitingForEvents","WaitingForExecutor","InProgress","Success","Failure"]},"id":{"type":"string"},"job":{"type":"string","format":"uuid"},"count":{"type":"integer"},"progress":{"type":"integer"},"iterator":{"type":"object","properties":{"index":{"type":"integer"},"itered":{"type":"array","items":{}},"itered_len":{"type":"integer"},"args":{}}},"flow_jobs":{"type":"array","items":{"type":"string"}},"flow_jobs_success":{"type":"array","items":{"type":"boolean"}},"flow_jobs_duration":{"type":"object","properties":{"started_at":{"type":"array","items":{"type":"string"}},"duration_ms":{"type":"array","items":{"type":"integer"}}}},"branch_chosen":{"type":"object","properties":{"type":{"type":"string","enum":["branch","default"]},"branch":{"type":"integer"}},"required":["type"]},"branchall":{"type":"object","properties":{"branch":{"type":"integer"},"len":{"type":"integer"}},"required":["branch","len"]},"approvers":{"type":"array","items":{"type":"object","properties":{"resume_id":{"type":"integer"},"approver":{"type":"string"}},"required":["resume_id","approver"]}},"failed_retries":{"type":"array","items":{"type":"string","format":"uuid"}},"skipped":{"type":"boolean"},"agent_actions":{"type":"array","items":{"type":"object","oneOf":[{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"type":{"type":"string","enum":["tool_call"]},"module_id":{"type":"string"}},"required":["job_id","function_name","type","module_id"]},{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"resource_path":{"type":"string"},"type":{"type":"string","enum":["mcp_tool_call"]},"arguments":{"type":"object"}},"required":["call_id","function_name","resource_path","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]}},"required":["content","type"]}]}},"agent_actions_success":{"type":"array","items":{"type":"boolean"}}},"required":["type"]}}
85729
+ `,
84920
85730
  "raw-app": `---
84921
85731
  name: raw-app
84922
85732
  description: MUST use when creating raw apps.
@@ -85087,7 +85897,7 @@ The \`data\` block in \`raw_app.yaml\` controls which tables the app can query.
85087
85897
  \`\`\`yaml
85088
85898
  data:
85089
85899
  datatable: main # Default datatable
85090
- schema: app_schema # Default schema (optional)
85900
+ schema: app_schema # Schema the app's tables go in (optional); still write them as app_schema.<table>
85091
85901
  tables:
85092
85902
  - main/users # Table in public schema
85093
85903
  - main/app_schema:items # Table in specific schema
@@ -85132,6 +85942,8 @@ data:
85132
85942
  - main/users
85133
85943
  \`\`\`
85134
85944
 
85945
+ A migration runs with no default schema, so a table outside \`public\` is created with its schema, \`CREATE TABLE IF NOT EXISTS app_schema.items (...)\`, listed as \`main/app_schema:items\`, and queried as \`app_schema.items\`.
85946
+
85135
85947
  ### Migration best practices
85136
85948
 
85137
85949
  - **Use idempotent SQL**: \`CREATE TABLE IF NOT EXISTS\`, etc.
@@ -85141,8 +85953,9 @@ data:
85141
85953
 
85142
85954
  ## CLI Commands
85143
85955
 
85144
- Two commands you run yourself, not the user:
85956
+ Commands you run yourself, not the user:
85145
85957
  - \`wmill app new\` — run it with flags, per the "Creating a Raw App" section above.
85958
+ - \`wmill app lint <app_folder>\` — checks the app's structure and that it builds. Run it after editing, before offering a preview or a deploy; a bundle that compiles still says nothing about behavior, so a preview is what checks that.
85146
85959
  - \`wmill generate-metadata\` — (re)generates local lock files and refreshes \`wmill-lock.yaml\` content hashes; writes local files only (not a deploy). After adding or editing a runnable, offer it and run it on agreement — or automatically if the project's \`AGENTS.md\` opts into that (see "After creating a runnable" above).
85147
85960
 
85148
85961
  For the rest, tell the user which command fits their intent and let them run it — these deploy to the workspace, overwrite local files, or launch a long-running server, so the user should consent each time:
@@ -85154,8 +85967,6 @@ For the rest, tell the user which command fits their intent and let them run it
85154
85967
  | \`wmill sync push\` | Deploy app to Windmill |
85155
85968
  | \`wmill sync pull\` | Pull latest from Windmill |
85156
85969
 
85157
-
85158
-
85159
85970
  # Windmill Raw Apps
85160
85971
 
85161
85972
  Raw apps let you build custom frontends with React, Svelte, or Vue that connect to Windmill backend runnables and datatables.
@@ -85206,6 +86017,8 @@ Import the generated bindings and call the runnable like a function. \`./wmill\`
85206
86017
  | \`getJob(jobId)\` | a \`Job\` (\`{ type, success, result, duration_ms, ... }\`) | polling status without blocking |
85207
86018
  | \`streamJob(jobId, onUpdate?)\` | the final result, calling \`onUpdate\` per chunk | showing output as it is produced |
85208
86019
 
86020
+ A runnable is always called with **one object** whose keys are its \`main\` parameters — \`main(user_id: string, limit: number)\` is called as \`backend.get_users({ user_id, limit })\`, never with positional arguments. A runnable without parameters is called with no argument. Resource and variable ids handed to the \`wmill\` client are paths (\`u/<user>/<name>\` or \`f/<folder>/<name>\`).
86021
+
85209
86022
  Run and wait — the common case:
85210
86023
 
85211
86024
  \`\`\`tsx
@@ -85279,9 +86092,10 @@ Each runnable has a unique key (used to call it from the frontend) and one of fo
85279
86092
 
85280
86093
  ### Inline runnables
85281
86094
 
85282
- Inline runnables carry their own source code. For file-based raw apps, the runnable language is determined by the backend file extension. The script must expose a \`main\` function as its entrypoint.
86095
+ Inline runnables carry their own source code, and must expose a \`main\` function as their entrypoint.
86096
+ On disk, a runnable's language is determined by its backend file extension.
85283
86097
 
85284
- **TypeScript example** (\`backend/get_user.ts\`):
86098
+ **TypeScript example** (runnable \`get_user\`):
85285
86099
 
85286
86100
  \`\`\`typescript
85287
86101
  import * as wmill from 'windmill-client';
@@ -85293,7 +86107,7 @@ export async function main(user_id: string) {
85293
86107
  }
85294
86108
  \`\`\`
85295
86109
 
85296
- **Python example** (\`backend/get_user.py\`):
86110
+ **Python example** (runnable \`get_user\`):
85297
86111
 
85298
86112
  \`\`\`python
85299
86113
  import wmill
@@ -85310,12 +86124,14 @@ An inline runnable runs as an ordinary Windmill job. \`import * as wmill from 'w
85310
86124
 
85311
86125
  **Don't read \`WM_TOKEN\` or \`BASE_INTERNAL_URL\` and build an API URL to \`fetch\`.** The client's own \`setClient\` already reads exactly those, and it also sets the credentials mode a raw app needs (\`WM_RAW_APP\` suppresses credentials, because a sandboxed bundle calls the API from an opaque origin that can never pair with \`Access-Control-Allow-Origin: *\`). Rebuilding that by hand drops the parts you can't see. Use \`wmill.*\` for everything Windmill, and \`fetch\` only for third-party APIs.
85312
86126
 
85313
- Prefer the \`wmill\` functions that appear in the SDK reference; for an endpoint none of them covers, the generated service classes (\`JobService\`, \`ScriptService\`, ...) are importable from \`windmill-client\`. What is not available is a name you guessed at: \`getBaseUrl\` and \`getWorkspaceToken\` are inventions, not API.
86127
+ Use only \`wmill\` functions the SDK actually exports; for an endpoint none of them covers, the generated service classes (\`JobService\`, \`ScriptService\`, ...) are importable from \`windmill-client\`. What is not available is a name you guessed at: \`getBaseUrl\` and \`getWorkspaceToken\` are inventions, not API.
85314
86128
 
85315
86129
  ### Path runnables (script / flow / hubscript)
85316
86130
 
85317
86131
  When \`type\` is \`script\`, \`flow\`, or \`hubscript\`, the runnable just stores a \`path\` to an existing workspace or hub item — no inline code. The referenced item's input/output schema becomes the runnable's surface.
85318
86132
 
86133
+ Before writing an inline runnable, look for a workspace script or flow that already does the job, or a Hub script (a prebuilt integration at \`hub/<version>/<app>/<name>\`) for a third-party service, and reference it instead of copying its logic.
86134
+
85319
86135
  ### Draft code vs deployed code
85320
86136
 
85321
86137
  This decides whether an app works before anything is deployed:
@@ -85335,15 +86151,29 @@ Prefer a **path runnable of type \`flow\`** over an inline runnable that calls \
85335
86151
 
85336
86152
  \`staticInputs\` is an optional \`Record<string, any>\` for arguments not overridable from the frontend. Useful with path runnables to pre-fill some args while leaving the rest to the frontend caller.
85337
86153
 
86154
+ ## Who can open a deployed app
86155
+
86156
+ A draft app is reachable by nobody; deploying is what exposes it, and its backend runnables with it. Otherwise only users with access to the app can open it, unless the app is opened to:
86157
+
86158
+ - **anonymous** users: anyone with the URL, without logging in;
86159
+ - **guests**: anyone the instance's identity provider authenticates, whether or not they belong to the workspace.
86160
+
86161
+ Either one lets those people run the app's backend runnables, so never open an app up unless the user asks.
86162
+ \`public: true\` in \`raw_app.yaml\` deploys the app for anonymous users, and \`guests: true\` for guests. Remove the line and the next push closes the app again.
86163
+
85338
86164
  ## Data Tables
85339
86165
 
85340
- Data tables are PostgreSQL databases managed by Windmill. Backend runnables query them via the \`wmill\` client; the frontend never queries them directly.
86166
+ Data tables are PostgreSQL databases managed by Windmill. Backend runnables query them via the \`wmill\` client; the frontend never queries them directly. **When the app needs to store or persist data** (user data, settings, application state, records, logs), use a data table.
85341
86167
 
85342
86168
  ### Critical rules
85343
86169
 
85344
- 1. **Whitelisted tables only**: a runnable can only query tables listed in the app's \`data.tables\` config. Tables not in this list are not accessible.
85345
- 2. **Add tables before using**: queries against unlisted tables fail at runtime. When you introduce a new table, register it in \`data.tables\` first.
85346
- 3. **Use the configured datatable/schema**: the app's \`data\` config sets the default datatable and schema; reference them consistently across runnables.
86170
+ 1. **Check what exists first**: look up the workspace's data tables and their tables before designing storage, and reuse a suitable table rather than creating another. Never assume a \`main\` data table exists.
86171
+ 2. **Whitelisted tables only**: a runnable can only query tables listed in the app's \`data.tables\` config. Queries against unlisted tables fail at runtime, so register a new table there before using it.
86172
+ 3. **No DDL inside runnables**: runnables only read and write rows (SELECT, INSERT, UPDATE, DELETE) on existing tables. Never CREATE, ALTER or DROP a table from a runnable.
86173
+ 4. **Qualify table names**: an unqualified name means the \`public\` schema, so write every other table as \`schema.table\`, in table creation and queries alike. The app's \`data\` config sets the default datatable and schema its tables go in; use them consistently across runnables.
86174
+ 5. **Pass the role**: when the app's \`data.roles\` gives a data table a role, every \`wmill.datatable\` call on it passes that role (\`wmill.datatable('main', { role: 'analyst' })\` in TypeScript, \`wmill.datatable('main', role='analyst')\` in Python). The role only reaches what it was granted, so a query outside it fails with \`permission denied\`.
86175
+
86176
+ \`wmill datatable list\` lists the workspace's data tables. Create or change tables with a migration in \`sql_to_apply/\` (see "SQL Migrations" above), then add them to \`data.tables\` in \`raw_app.yaml\`.
85347
86177
 
85348
86178
  ### Querying in TypeScript (Bun/Deno)
85349
86179
 
@@ -85578,6 +86408,14 @@ Reference variables in resource values:
85578
86408
  - \`$var:u/username/name\` - User variable
85579
86409
  - \`$var:f/folder/name\` - Folder variable
85580
86410
 
86411
+ ## Secrets
86412
+
86413
+ Never put a secret (password, API key, token) inline in a resource value. Store it in a secret variable and reference that variable as \`$var:<path>\`.
86414
+
86415
+ - \`$var:<path>\` is a reference, not a value: it resolves to the variable's value at run time. Never invent a value for a variable.
86416
+ - A resource that references a variable needs the variable to exist first, so create or deploy the variable before the resource.
86417
+ - A secret's plaintext never goes in a file of the repo: a \`.variable.yaml\` holding it would be committed. Ask the user to create the secret on the workspace instead, e.g. \`wmill variable add '<value>' <path>\` (a secret by default), then reference it by path.
86418
+
85581
86419
  ## Resource References
85582
86420
 
85583
86421
  Reference other resources:
@@ -85859,14 +86697,13 @@ For a **visual** open-the-script-in-the-dev-page preview (rather than \`script p
85859
86697
 
85860
86698
  Use \`wmill resource-type list --schema\` to discover available resource types.
85861
86699
 
85862
- Workflow-as-Code files use the normal script CLI workflow. There are no separate WAC deploy commands.
85863
-
85864
86700
  # Windmill Workflow-as-Code Writing Guide
85865
86701
 
85866
86702
  ## Scope
85867
86703
 
85868
86704
  Use this guide when writing or modifying Windmill Workflow-as-Code (WAC) scripts.
85869
86705
  WAC is authored as a Windmill script and deployed with the normal script workflow. It is not an OpenFlow YAML flow.
86706
+ Workflow-as-Code files use the normal script CLI workflow. There are no separate WAC deploy commands.
85870
86707
 
85871
86708
  Supported WAC authoring targets:
85872
86709
  - Bun TypeScript scripts that import from \`windmill-client\`
@@ -86051,7 +86888,6 @@ TypeScript: avoid broad \`try/catch\` around WAC SDK calls. The SDK uses an inte
86051
86888
 
86052
86889
  A caught failure reads the same whether it came from a task or from a \`step()\`, and the same in the round that ran the failing body as in every round replaying it. It carries \`step_key\`, \`child_job_id\` (absent for a \`step()\`, which runs in the workflow job and has no child job), a \`message\` that is the failure's own message, and \`result\` = \`{"error": {"name", "message", "stack"?, "extra"?}}\`. \`name\`, \`message\` and \`stack\` are the fields that read the same whichever side failed; \`name\` and \`message\` are always there, \`stack\` only when the failure had a traceback to give. \`extra\` carries the failure's own custom fields (an exception's attributes, an error's properties) and is best-effort: it is absent when there were none, and a task can report entries a step does not, so read it defensively and don't branch on its absence. \`extra\` is dropped when it is too large to keep in the checkpoint, and \`extra_omitted: true\` says so — absent \`extra\` with no \`extra_omitted\` means the failure simply had no custom fields. Branch on those, not on the original exception type: the workflow body re-runs from the top every round and a replay rebuilds the failure from the checkpoint, so nothing outside that record survives. Python raises \`TaskError\`; TypeScript throws an \`Error\` named \`TaskError\` carrying the same fields. Nothing is chained onto \`__cause__\` / \`cause\` — the traceback is in \`result.error.stack\`, and is also printed to the job log when the step fails.
86053
86890
 
86054
-
86055
86891
  ## TypeScript Workflow-as-Code API (windmill-client)
86056
86892
 
86057
86893
  Import: \`import { workflow, task, taskScript, taskFlow, step, sleep, waitForApproval, getApprovalUrls, getResumeUrls, parallel } from "windmill-client"\`
@@ -86420,6 +87256,132 @@ def get_approval_urls(step_key: str = 'approval', approver: str = None) -> dict
86420
87256
  # results = await parallel(items, process, concurrency=5)
86421
87257
  async def parallel(items, fn, *, concurrency: Optional[int] = None)
86422
87258
  \`\`\`
87259
+ `,
87260
+ "write-pipeline": `---
87261
+ name: write-pipeline
87262
+ description: MUST use when creating or modifying a data pipeline, a set of scripts marked \`pipeline\` and wired together by \`on\` / \`materialize\` annotations.
87263
+ ---
87264
+
87265
+ # Data pipeline authoring
87266
+
87267
+ A **data pipeline** is NOT a flow. A flow is one runnable that orchestrates steps internally. A data pipeline is a set of **independent scripts**, each deployed on its own, that form a DAG by reading and writing shared **storage assets** (DuckLake tables, data tables, S3 objects, volumes, resources) and by declaring execution **triggers**. The pipeline is visualized and edited at \`/pipeline/<folder>\`; every node is a normal workspace script that happens to carry pipeline annotations. When the user asks for a "data pipeline" (or to "ingest / transform / materialize" data across steps), build pipeline-annotated scripts — do NOT build a flow.
87268
+
87269
+ ## Default to DuckDB + DuckLake
87270
+
87271
+ A pipeline node that produces a table should almost always be a **\`duckdb\`** node that materializes its output into a **DuckLake** table with \`-- materialize ducklake://<name>/<table>\` (in a DuckDB node the annotation uses SQL \`--\` comment syntax; write the body as a bare \`SELECT\` and let the runtime do the write). DuckLake is the default lakehouse store for pipelines and is the shape the pipeline editor is built around, so prefer it unless the work specifically calls for something else:
87272
+
87273
+ - \`postgresql\` / data tables — only for row-level, OLTP-style mutations against an existing Postgres data table (frequent single-row upserts/updates, transactional reads that an app queries live).
87274
+ - \`bun\` / \`python3\` — only for non-tabular work that doesn't map to SQL: calling an external API, wrangling files, arbitrary glue. When such a node still produces tabular data for downstream steps, land it in DuckLake (write it with the wmill SDK / ducklake helpers) rather than inventing a parallel store.
87275
+
87276
+ Do not spread a pipeline across postgres, S3, and DuckLake when one DuckLake lake would do; a consistent DuckLake lakehouse is the goal.
87277
+
87278
+ ## Storage prerequisites
87279
+
87280
+ A DuckLake pipeline only runs once the workspace has **object storage** (S3 / Azure Blob / GCS) **and a DuckLake catalog** configured — DuckLake tables and \`s3://\` assets can't be materialized or read without it. Check which DuckLake catalogs the workspace has before you build.
87281
+ \`wmill ducklake list\` lists them.
87282
+ Drafting the annotated scripts does not require storage, but the pipeline can't ingest, materialize, or read its assets until it exists. So if there is none (or the user hits "storage not configured" errors), say so and give the right next step **by role**:
87283
+
87284
+ - a workspace **admin** sets it up in Workspace settings → Object Storage (add an S3/Azure/GCS storage), then adds a DuckLake catalog on top of it;
87285
+ - anyone **without admin rights** should ask a workspace admin to configure object storage + a DuckLake catalog.
87286
+
87287
+ Never hand back a DuckLake pipeline that cannot run without flagging the missing storage and pointing to who sets it up.
87288
+
87289
+ ## What makes a script a pipeline node
87290
+
87291
+ A script joins the pipeline when its source begins with the \`pipeline\` annotation as a top-of-file comment, **written in the script's own comment syntax** — \`//\` for TS/JS (bun), \`--\` for SQL (DuckDB/Postgres), \`#\` for Python/Bash. So it's \`-- pipeline\` in a DuckDB node, \`# pipeline\` in a Python node, \`// pipeline\` in a bun node. Every annotation below uses that same prefix (the \`//\` shown is the TS form). All other wiring is expressed as annotation comments near the top of the file:
87292
+
87293
+ - \`// on <ref>\` — declares an execution-DAG **input** (what triggers/feeds this node). \`<ref>\` is either:
87294
+ - an **asset URI** (the node runs when that asset is produced upstream): \`ducklake://main/orders\`, \`datatable://main/users\`, \`$res:f/folder/my_resource\`, \`volume://name/path\`, or an S3 object (see the S3 storage-form rule below).
87295
+ - a **native trigger kind**: \`schedule\`, \`webhook\`, \`email\`, \`kafka\`, \`mqtt\`, \`amqp\`, \`nats\`, \`postgres\`, \`sqs\`, \`gcp\`, or \`data_upload\` (a user-uploaded S3 file). For these the actual trigger row (cron, topic, …) is created separately; the annotation only declares the binding. **\`data_upload\` is special**: there is no trigger row — the node instead declares an **\`S3Object\` input parameter** fed by the auto-generated upload picker; it never hard-codes a key. Any language can be the \`data_upload\` node:
87296
+ - Python (has \`import wmill\`): \`def main(file: wmill.S3Object):\` then \`wmill.load_s3_file(file)\`; TS (has \`import * as wmill from "windmill-client"\`): \`export async function main(file: wmill.S3Object)\`. Qualify the type as \`wmill.S3Object\` (or add \`from wmill import S3Object\` / \`import { S3Object } from "windmill-client"\`) — a bare \`S3Object\` is undefined.
87297
+ - **DuckDB** takes the s3object arg via a \`-- $<name> (s3object)\` declaration and reads it directly, so a single DuckDB node can ingest **and** materialize:
87298
+ \`\`\`
87299
+ -- pipeline
87300
+ -- on data_upload
87301
+ -- materialize ducklake://main/raw_uploads
87302
+ -- $file (s3object)
87303
+ SELECT * FROM read_csv($file)
87304
+ \`\`\`
87305
+ - **Outputs** are inferred from what the body writes — a \`CREATE TABLE\`, a \`wmill.writeS3File(...)\`, a DuckLake/datatable write. To declare a managed output explicitly, use \`// materialize <asset-uri>\`.
87306
+ - Optional badges: \`// partitioned <daily|hourly|weekly|monthly|dynamic>\`, \`// freshness <duration>\` (e.g. \`1h\`), \`// tag <worker-tag>\`, \`// retry <count> [delay]\`, \`// data_test <kind> ...\` (managed DuckLake targets only — deploy rejects it beside a \`dbt://\` one), \`// measure <name> = <agg> [where <pred>]\` and \`// dimension <name> = <expr>\` (see "Declared metrics" below).
87307
+
87308
+ ## S3 object wiring (storage form matters)
87309
+
87310
+ An \`s3://\` URI's first slashes select the **storage**, not part of the key — get this wrong and the producer/consumer edge silently won't connect:
87311
+
87312
+ - \`s3:///<key>\` (**triple** slash, empty first segment) = the **default** workspace storage. A downstream node reading or triggering on that object uses \`s3:///<key>\` — e.g. DuckDB \`-- on s3:///orders/2024.parquet\` and \`read_parquet('s3:///orders/2024.parquet')\`.
87313
+ - \`s3://<storage>/<key>\` (**double** slash, non-empty first segment) = a **named secondary** storage called \`<storage>\` — so \`s3://ingest/x\` means storage \`ingest\`, key \`x\`, NOT key \`ingest/x\`. Only use this when the object genuinely lives in a configured secondary storage; never invent a bucket/storage name for a default-storage object (it breaks the edge).
87314
+
87315
+ To make the producer side visible to lineage, a Python/TS node MUST pass the **\`S3Object\` form**, not a bare key string: Python \`wmill.write_s3_file(wmill.S3Object(s3="<key>"), data)\` (or the import-free dict \`{"s3": "<key>"}\`), TS \`wmill.writeS3File({ s3: "<key>" }, data)\`. That records the default-storage asset \`/<key>\`, which a downstream \`s3:///<key>\` reader connects to (same key both sides). A bare \`write_s3_file("<key>", ...)\` records **no** asset and produces **no** edge. Add \`storage="<name>"\` only for a named secondary storage.
87316
+
87317
+ The key must be a **string literal** — the graph parser is static and cannot follow a variable, f-string, or computed path, so \`write_s3_file(wmill.S3Object(s3=key_var), ...)\` records no edge. Inline the literal (\`s3="events/user_events.parquet"\`) on both the writing and reading node. The same rule applies to every asset URI in an annotation or SDK call (\`ducklake://\`, \`datatable://\`, \`s3://\`): write them literally, not via a variable.
87318
+
87319
+ ## Materialize (the managed output)
87320
+
87321
+ > **A MANAGED \`// materialize\` is DuckDB-only**, and its target must be a DuckLake table (\`ducklake://<name>/<table>\`). Deploy **rejects** a \`ducklake://\` \`// materialize\` on any other language (\`python3\`, \`bun\`, \`postgresql\`). For a non-DuckDB node writing the lake, do **not** use \`// materialize\` — write the output via the SDK (\`wmill.writeS3File(...)\`, ducklake helpers, …) and let it be inferred. Use \`duckdb\` when a node should materialize a DuckLake table.
87322
+ >
87323
+ > The one target ANY language may declare (except a dbt script, whose writes come from its manifest) is a **warehouse relation**: \`// materialize manual dbt://<warehouse>/<schema>/<name>\`, where \`<warehouse>\` is a warehouse the workspace configures under Settings → dbt. \`manual\` is the only mode it has — nothing generates warehouse DDL, so the node issues its own write (a postgresql \`CREATE TABLE\` / \`INSERT\`, an SDK load, …) and the annotation records the outcome. Use it on an ingestion node whose output a dbt project reads as a \`source\`: the declared relation and the dbt model land on ONE graph node, and a downstream \`// on dbt://<warehouse>/<schema>/<name>\` fires when the ingestion node completes.
87324
+
87325
+ A managed \`// materialize ducklake://<name>/<table>\` tells the runtime to write the node's output table **for you**: write the body as a single \`SELECT\` and the runtime wraps it in the create/replace — do **not** also write your own \`CREATE TABLE\` / \`INSERT\`. (The opposite holds for the \`dbt://\` target above: there the node writes its own DDL and the strategies below do not apply.) Write strategy:
87326
+
87327
+ - no option → **replace** the whole table each run (full refresh; the only mode whose output columns may change);
87328
+ - \`// materialize <uri> append\` → INSERT-append rows (incremental);
87329
+ - \`// materialize <uri> key=<col>\` → merge/upsert on \`<col>\`.
87330
+
87331
+ \`// materialize manual <uri>\` opts **out** of managed writes — the script writes its own DDL and the annotation only records the output asset for lineage.
87332
+
87333
+ \`materialize\` pairs with partitioning for incremental pipelines: a \`// partitioned <daily|hourly|weekly|monthly|dynamic>\` node runs **once per partition** (append/merge into a fixed-schema table). The \`{partition}\` token, usable in any asset URI **and** in the body SQL, is replaced at run time by the current partition's **identity string**:
87334
+
87335
+ - To filter the source to the active slice on a time grain, use the runtime-injected macro: \`WHERE wm_partition(<ts_col>) = {partition}\`. \`wm_partition(ts)\` buckets a timestamp in exactly the identity format the runtime uses for daily/hourly/weekly/monthly, so it always matches; never hand-write a \`strftime\` format.
87336
+ - Do NOT write \`= TIMESTAMP {partition}\`: the identity string is not a valid timestamp literal for hourly/weekly/monthly and errors at run time.
87337
+ - For \`dynamic\` partitioning the identity is the caller-supplied key (not a timestamp, no macro), so filter on it directly: \`WHERE <your_key_col> = {partition}\`.
87338
+
87339
+ \`materialize\` is an output **declaration** on a node — not a command. There is no "materialize run".
87340
+
87341
+ ## Declared metrics (\`measure\` / \`dimension\`)
87342
+
87343
+ On a node that materializes a DuckLake table, \`// measure <name> = <aggregate> [where <predicate>]\` names the canonical way to aggregate that table (e.g. \`// measure revenue = sum(amount) where not is_refund\`), and \`// dimension <name> = <expr>\` names a way to slice it (e.g. \`// dimension region = region\`, \`// dimension month = date_trunc('month', ordered_at)\`). They execute nothing: they are catalogued at deploy so the editor and other agents reuse the definition instead of re-deriving it and silently disagreeing.
87344
+
87345
+ - Keep the predicate in the \`where\` clause rather than folding it into the aggregate: it is rendered as \`<agg> FILTER (WHERE <pred>)\`, which is what lets two measures with different predicates share one GROUP BY.
87346
+ - DuckLake-only, and only meaningful next to \`// materialize\`.
87347
+ - Declare one when a number carries a judgement call someone else would get wrong (refunds excluded, test rows dropped, which column is the amount); do NOT blanket every table with measures — an obvious \`count(*)\` earns nothing.
87348
+ - To use a metric another node declares, read that node and reuse its exact expression rather than guessing it.
87349
+
87350
+ ## How to build one
87351
+
87352
+ 1. Put every node in the **same folder**: \`f/<folder>/<name>\`. The folder is the pipeline.
87353
+ 2. Write each node as its own script. Default to \`duckdb\` materializing into DuckLake (see "Default to DuckDB + DuckLake" above); pick \`postgresql\`, \`bun\`, or \`python3\` only when that section says the work calls for it.
87354
+ 3. Start each body with \`// pipeline\`, then the \`// on\` input declarations, then the transform that writes the output.
87355
+ 4. **Chain nodes by asset URI**: read an upstream node's output asset, then \`// on <that-same-uri>\` in the downstream node so the edge forms. Reuse exact asset paths from existing nodes rather than inventing parallel ones.
87356
+ 5. Don't deploy nodes unless the user asks to. A pipeline only "runs" once its scripts are deployed and their triggers exist.
87357
+
87358
+ Locally:
87359
+
87360
+ - create each node with \`wmill script new f/<folder>/<name> <language>\`, then write its body;
87361
+ - \`wmill pipeline show <folder> --local\` draws the graph from your working tree — check that every edge you meant to form is there;
87362
+ - \`wmill pipeline dev <folder>\` live-previews the pipeline, and \`wmill pipeline run <folder> --local\` runs the cascade from local files without deploying (\`--dry-run\` prints the plan first);
87363
+ - a trigger such as \`// on schedule\` only declares the binding: the schedule or trigger itself is created separately (see the \`schedules\` and \`triggers\` skills).
87364
+
87365
+ ## Example (DuckDB → DuckLake, scheduled ingest + downstream transform)
87366
+
87367
+ Node \`f/sales/orders_ingest\` (runs on a schedule, materializes a DuckLake table):
87368
+
87369
+ \`\`\`sql
87370
+ -- pipeline
87371
+ -- on schedule
87372
+ -- materialize ducklake://main/orders
87373
+ SELECT * FROM read_csv('s3:///raw/orders/*.csv')
87374
+ \`\`\`
87375
+
87376
+ Node \`f/sales/orders_daily\` (runs when \`orders\` is produced, writes a rollup):
87377
+
87378
+ \`\`\`sql
87379
+ -- pipeline
87380
+ -- on ducklake://main/orders
87381
+ -- materialize ducklake://main/orders_daily
87382
+ SELECT date_trunc('day', ts) AS day, count(*) AS n
87383
+ FROM ducklake.main.orders GROUP BY 1
87384
+ \`\`\`
86423
87385
  `,
86424
87386
  "cli-commands": `---
86425
87387
  name: cli-commands
@@ -86803,7 +87765,7 @@ Manage jobs (import/export)
86803
87765
 
86804
87766
  ### lint
86805
87767
 
86806
- Validate Windmill flow, schedule, and trigger YAML files in a directory, and report script metadata that has no deployable content file
87768
+ Validate Windmill flow, schedule, and trigger YAML files in a directory (including AI agent tool names and flow groups/notes), and report script metadata that has no deployable content file
86807
87769
 
86808
87770
  **Arguments:** \`[directory:string]\`
86809
87771
 
@@ -91155,23 +92117,23 @@ import * as fs17 from "node:fs";
91155
92117
 
91156
92118
  // src/commands/dev/pathscript-restore.ts
91157
92119
  var TAG_KEY = "_originalPathScript";
91158
- function walkModules(modules, visitor) {
92120
+ function walkModules2(modules, visitor) {
91159
92121
  for (const module of modules) {
91160
92122
  if (!module.value)
91161
92123
  continue;
91162
92124
  const val = module.value;
91163
92125
  if (val.type === "forloopflow" || val.type === "whileloopflow") {
91164
- walkModules(val.modules, visitor);
92126
+ walkModules2(val.modules, visitor);
91165
92127
  } else if (val.type === "branchall") {
91166
92128
  for (const branch of val.branches ?? []) {
91167
- walkModules(branch.modules, visitor);
92129
+ walkModules2(branch.modules, visitor);
91168
92130
  }
91169
92131
  } else if (val.type === "branchone") {
91170
92132
  for (const branch of val.branches ?? []) {
91171
- walkModules(branch.modules, visitor);
92133
+ walkModules2(branch.modules, visitor);
91172
92134
  }
91173
92135
  if (val.default) {
91174
- walkModules(val.default, visitor);
92136
+ walkModules2(val.default, visitor);
91175
92137
  }
91176
92138
  } else if (val.type === "aiagent") {
91177
92139
  for (const tool of val.tools ?? []) {
@@ -91184,11 +92146,11 @@ function walkModules(modules, visitor) {
91184
92146
  }
91185
92147
  function walkFlow(flowValue, visitor) {
91186
92148
  if (flowValue?.modules)
91187
- walkModules(flowValue.modules, visitor);
92149
+ walkModules2(flowValue.modules, visitor);
91188
92150
  if (flowValue?.failure_module)
91189
- walkModules([flowValue.failure_module], visitor);
92151
+ walkModules2([flowValue.failure_module], visitor);
91190
92152
  if (flowValue?.preprocessor_module)
91191
- walkModules([flowValue.preprocessor_module], visitor);
92153
+ walkModules2([flowValue.preprocessor_module], visitor);
91192
92154
  }
91193
92155
  function snapshotPathScripts(flowValue) {
91194
92156
  walkFlow(flowValue, {