windmill-cli 1.834.0 → 1.836.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 +255 -65
  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.834.0",
16769
+ VERSION: "1.836.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -20074,7 +20074,7 @@ var init_auth = __esm(async () => {
20074
20074
  });
20075
20075
 
20076
20076
  // src/core/constants.ts
20077
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.834.0";
20077
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.836.0";
20078
20078
 
20079
20079
  // src/utils/resource_folders.ts
20080
20080
  import { existsSync } from "node:fs";
@@ -20867,9 +20867,9 @@ function gitSyncIncludePattern(pathType, path) {
20867
20867
  case "flow":
20868
20868
  return `${path}.flow/*,${path}__flow/*`;
20869
20869
  case "app":
20870
- return `${path}.app/*,${path}__app/*`;
20870
+ return `${path}.app/*,${path}__app/*,${path}.custom_path.*,${path}.*.custom_path.*`;
20871
20871
  case "raw_app":
20872
- return `${path}.raw_app/**,${path}__raw_app/**`;
20872
+ return `${path}.raw_app/**,${path}__raw_app/**,${path}.custom_path.*,${path}.*.custom_path.*`;
20873
20873
  case "folder":
20874
20874
  return `${path}/folder.meta.*`;
20875
20875
  case "resourcetype":
@@ -58782,7 +58782,7 @@ var init_openflow = __esm(() => {
58782
58782
  openflow_default = {
58783
58783
  openapi: "3.0.3",
58784
58784
  info: {
58785
- version: "1.834.0",
58785
+ version: "1.836.0",
58786
58786
  title: "OpenFlow Spec",
58787
58787
  contact: {
58788
58788
  name: "Ruben Fiszel",
@@ -58922,7 +58922,7 @@ var init_openflow = __esm(() => {
58922
58922
  },
58923
58923
  early_return: {
58924
58924
  type: "string",
58925
- description: "JavaScript expression to return early from the flow"
58925
+ description: "Id of the step whose result a sync webhook returns as soon as that step completes, while the rest of the flow keeps running. When the step does not run, or fails while the flow has a failure module, the flow's final result is returned instead."
58926
58926
  },
58927
58927
  chat_input_enabled: {
58928
58928
  type: "boolean",
@@ -63291,9 +63291,16 @@ function getWorkspaceSpecificTypeKinds() {
63291
63291
  "variable",
63292
63292
  "resource",
63293
63293
  "schedule",
63294
+ "custom_path",
63294
63295
  ...TRIGGER_TYPES.map((t) => `${t}_trigger`)
63295
63296
  ];
63296
63297
  }
63298
+ function isCustomPathFile(path) {
63299
+ const p = path.replaceAll("\\", "/");
63300
+ const slash = p.lastIndexOf("/");
63301
+ const parts = p.slice(slash + 1).split(".");
63302
+ return (parts.length == 3 || parts.length == 4) && parts[parts.length - 2] == "custom_path" && (parts[parts.length - 1] == "yaml" || parts[parts.length - 1] == "json") && !p.slice(0, slash + 1).includes(".") && !isFolderResourcePathAnyFormat(p) && !isScriptModulePath(p);
63303
+ }
63297
63304
  function isTriggerFile(path) {
63298
63305
  return TRIGGER_TYPES.some((type) => path.endsWith(`.${type}_trigger.yaml`) || path.endsWith(`.${type}_trigger.json`));
63299
63306
  }
@@ -63314,7 +63321,7 @@ function getFileTypeSuffix(path) {
63314
63321
  return null;
63315
63322
  }
63316
63323
  function buildItemTypePattern() {
63317
- const basicTypes = ["variable", "resource", "schedule"];
63324
+ const basicTypes = ["variable", "resource", "schedule", "custom_path"];
63318
63325
  const triggerTypes = TRIGGER_TYPES.map((t) => `${t}_trigger`);
63319
63326
  return `((${basicTypes.join("|")})|(${triggerTypes.join("|")}))`;
63320
63327
  }
@@ -63385,6 +63392,9 @@ function normalizeJsonToYaml(path) {
63385
63392
  return path.endsWith(".json") ? path.slice(0, -".json".length) + ".yaml" : path;
63386
63393
  }
63387
63394
  function isItemTypeConfigured(path, specificItems) {
63395
+ if (isCustomPathFile(path)) {
63396
+ return true;
63397
+ }
63388
63398
  if (!specificItems) {
63389
63399
  return false;
63390
63400
  }
@@ -63413,6 +63423,9 @@ function isItemTypeConfigured(path, specificItems) {
63413
63423
  return false;
63414
63424
  }
63415
63425
  function isSpecificItem(path, specificItems) {
63426
+ if (isCustomPathFile(path)) {
63427
+ return true;
63428
+ }
63416
63429
  if (!specificItems) {
63417
63430
  return false;
63418
63431
  }
@@ -63514,7 +63527,7 @@ function fromWorkspaceSpecificPath(workspaceSpecificPath, workspaceName) {
63514
63527
  return `${pathWithoutBranchAndExtension}${extension}`;
63515
63528
  }
63516
63529
  function getWorkspaceSpecificPath(basePath, specificItems, workspaceNameOverride) {
63517
- if (!specificItems) {
63530
+ if (!specificItems && !isCustomPathFile(basePath)) {
63518
63531
  return;
63519
63532
  }
63520
63533
  let currentWorkspace = null;
@@ -63532,7 +63545,7 @@ function getWorkspaceSpecificPath(basePath, specificItems, workspaceNameOverride
63532
63545
  return;
63533
63546
  }
63534
63547
  function isCurrentWorkspaceFile(path, workspaceNameOverride) {
63535
- if (isFilesetResource(path)) {
63548
+ if (isFilesetResource(path) || isFolderResourcePathAnyFormat(path)) {
63536
63549
  return false;
63537
63550
  }
63538
63551
  let currentWorkspace = null;
@@ -63554,7 +63567,7 @@ function isCurrentWorkspaceFile(path, workspaceNameOverride) {
63554
63567
  return pattern.test(path);
63555
63568
  }
63556
63569
  function isWorkspaceSpecificFile(path) {
63557
- if (isFilesetResource(path)) {
63570
+ if (isFilesetResource(path) || isFolderResourcePathAnyFormat(path)) {
63558
63571
  return false;
63559
63572
  }
63560
63573
  const typePattern = buildItemTypePattern();
@@ -63566,6 +63579,7 @@ var init_specific_items = __esm(async () => {
63566
63579
  await __promiseAll([
63567
63580
  init_git(),
63568
63581
  init_utils(),
63582
+ init_resource_folders(),
63569
63583
  init_conf(),
63570
63584
  init_types()
63571
63585
  ]);
@@ -65881,6 +65895,19 @@ async function track_job(workspace, id) {
65881
65895
  async function pollForJobResult(workspace, jobId) {
65882
65896
  return await pollJobWithQueueLogging(workspace, jobId);
65883
65897
  }
65898
+ async function ensurePreviewOnBehalfOfSupported(workspace, onBehalfOf) {
65899
+ if (!onBehalfOf)
65900
+ return;
65901
+ const probeId = await runScriptPreview({
65902
+ workspace,
65903
+ requestBody: { kind: "identity", args: {}, on_behalf_of: onBehalfOf }
65904
+ });
65905
+ const job = await getJob({ workspace, id: probeId });
65906
+ if (job.permissioned_as === onBehalfOf || job.email?.toLowerCase() === onBehalfOf.toLowerCase()) {
65907
+ return;
65908
+ }
65909
+ throw new Error(`The server does not support --on-behalf-of: it would run the preview as ${job.permissioned_as}, not ${onBehalfOf}. Upgrade the Windmill instance.`);
65910
+ }
65884
65911
  async function show(opts, path) {
65885
65912
  const workspace = await resolveWorkspace(opts);
65886
65913
  await requireLogin(opts);
@@ -66032,6 +66059,7 @@ async function preview(opts, filePath) {
66032
66059
  opts = await mergeConfigWithConfigFile(opts);
66033
66060
  const workspace = await resolveWorkspace(opts);
66034
66061
  await requireLogin(opts);
66062
+ await ensurePreviewOnBehalfOfSupported(workspace.workspaceId, opts.onBehalfOf);
66035
66063
  const argPath = filePath;
66036
66064
  filePath = toSyncRootRelativePath(filePath, cwdBeforeConfig);
66037
66065
  const remotePath = scriptPathToRemotePath(filePath);
@@ -66145,7 +66173,8 @@ async function preview(opts, filePath) {
66145
66173
  tag: opts.tag,
66146
66174
  kind: isTar ? "tarbundle" : "bundle",
66147
66175
  format: codebase?.format ?? "cjs",
66148
- temp_script_refs: tempScriptRefs
66176
+ temp_script_refs: tempScriptRefs,
66177
+ on_behalf_of: opts.onBehalfOf
66149
66178
  };
66150
66179
  form.append("preview", JSON.stringify(previewPayload));
66151
66180
  form.append("file", typeof bundledContent === "string" ? new Blob([bundledContent], { type: "application/javascript" }) : bundledContent);
@@ -66194,7 +66223,8 @@ async function preview(opts, filePath) {
66194
66223
  language,
66195
66224
  tag: opts.tag,
66196
66225
  modules: modules ?? undefined,
66197
- temp_script_refs: tempScriptRefs
66226
+ temp_script_refs: tempScriptRefs,
66227
+ on_behalf_of: opts.onBehalfOf
66198
66228
  }
66199
66229
  });
66200
66230
  const { result, success } = await pollForJobResult(workspace.workspaceId, jobId);
@@ -66333,7 +66363,7 @@ var init_script = __esm(async () => {
66333
66363
  languageAliases = {
66334
66364
  python: "python3"
66335
66365
  };
66336
- command7 = new Command().description("script related commands").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("list", "list all scripts").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("push", "push a local script spec. This overrides any remote versions. Use the script file (.ts, .js, .py, .sh)").arguments("<path:file>").option("--message <message:string>", "Deployment message").action(push3).command("get", "get a script's details").arguments("<path:file>").option("--json", "Output as JSON (for piping to jq)").action(get2).command("show", "show a script's content (alias for get)").arguments("<path:file>").action(show).command("run", "run a script by path").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(run2).command("preview", "preview a local script without deploying it. Supports both regular and codebase scripts.").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other than the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(preview).command("new", "create a new script").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("bootstrap", "create a new script (alias for new)").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("generate-metadata", 'DEPRECATED: re-generate script metadata. Use top-level "wmill generate-metadata" instead.').arguments("[script:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("--lock-only", "re-generate only the lock").option("--schema-only", "re-generate only script schema").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateMetadata2).command("set-permissioned-as", "Set the on_behalf_of_email for a script (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(setPermissionedAs).command("history", "show version history for a script").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history);
66366
+ command7 = new Command().description("script related commands").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("list", "list all scripts").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("push", "push a local script spec. This overrides any remote versions. Use the script file (.ts, .js, .py, .sh)").arguments("<path:file>").option("--message <message:string>", "Deployment message").action(push3).command("get", "get a script's details").arguments("<path:file>").option("--json", "Output as JSON (for piping to jq)").action(get2).command("show", "show a script's content (alias for get)").arguments("<path:file>").action(show).command("run", "run a script by path").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(run2).command("preview", "preview a local script without deploying it. Supports both regular and codebase scripts.").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other than the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").option("--on-behalf-of <identity:string>", "Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.").action(preview).command("new", "create a new script").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("bootstrap", "create a new script (alias for new)").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("generate-metadata", 'DEPRECATED: re-generate script metadata. Use top-level "wmill generate-metadata" instead.').arguments("[script:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("--lock-only", "re-generate only the lock").option("--schema-only", "re-generate only script schema").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateMetadata2).command("set-permissioned-as", "Set the on_behalf_of_email for a script (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(setPermissionedAs).command("history", "show version history for a script").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history);
66337
66367
  script_default = command7;
66338
66368
  });
66339
66369
 
@@ -68142,7 +68172,7 @@ async function pushFilesetParentResource(childPath, workspaceId, alreadySynced,
68142
68172
  if (cachedWsName && isWorkspaceSpecificFile(resourceFilePath)) {
68143
68173
  serverPath = fromWorkspaceSpecificPath(resourceFilePath, cachedWsName);
68144
68174
  wsSpecific = true;
68145
- } else if (specificItems && isSpecificItem(childPath, specificItems)) {
68175
+ } else if (isSpecificItem(childPath, specificItems)) {
68146
68176
  wsSpecific = true;
68147
68177
  }
68148
68178
  await pushResource(workspaceId, serverPath, undefined, newObj, resourceFilePath, wsSpecific ? true : undefined, true);
@@ -68306,6 +68336,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68306
68336
  markAccessFromPolicy(app);
68307
68337
  markIsolationFromPolicy(app, false);
68308
68338
  app.policy = undefined;
68339
+ delete app.custom_path;
68309
68340
  yield {
68310
68341
  isDirectory: false,
68311
68342
  path: path15.join(finalPath, "app.yaml"),
@@ -68344,7 +68375,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68344
68375
  markAccessFromPolicy(rawApp);
68345
68376
  markIsolationFromPolicy(rawApp, true);
68346
68377
  rawApp.policy = undefined;
68347
- delete rawApp?.["custom_path"];
68378
+ delete rawApp.custom_path;
68348
68379
  let inlineScripts;
68349
68380
  const value = rawApp?.["value"];
68350
68381
  const runnables = value?.["runnables"] ?? {};
@@ -68643,6 +68674,21 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68643
68674
  }
68644
68675
  }
68645
68676
  }
68677
+ if (kind == "app" || kind == "raw_app") {
68678
+ const customPath = JSON.parse(await f.async("text"))?.custom_path;
68679
+ if (customPath) {
68680
+ const appPath = removeSuffix(p, kind == "app" ? ".app.json" : ".raw_app.json");
68681
+ const obj = { custom_path: customPath };
68682
+ r.push({
68683
+ isDirectory: false,
68684
+ path: appPath + (useYaml ? ".custom_path.yaml" : ".custom_path.json"),
68685
+ async* getChildren() {},
68686
+ async getContentText() {
68687
+ return useYaml ? import_yaml22.stringify(obj, yamlOptions) : JSON.stringify(obj, null, 2);
68688
+ }
68689
+ });
68690
+ }
68691
+ }
68646
68692
  return r;
68647
68693
  }
68648
68694
  function _internal_folder(p, zip) {
@@ -68793,7 +68839,7 @@ async function elementsToMap(els, ignore, json, skips, specificItems, branchOver
68793
68839
  }
68794
68840
  if (skips.skipFlows && fileType === "flow")
68795
68841
  continue;
68796
- if (skips.skipApps && fileType === "app")
68842
+ if (skips.skipApps && (fileType === "app" || fileType === "custom_path"))
68797
68843
  continue;
68798
68844
  if (skips.skipFolders && fileType === "folder")
68799
68845
  continue;
@@ -69095,6 +69141,32 @@ function stripUnappliedSettingsFields(local, remote) {
69095
69141
  remoteInvite.instance_groups_roles ??= {};
69096
69142
  }
69097
69143
  }
69144
+ function liftInFileCustomPaths(localMap, json) {
69145
+ for (const key of Object.keys(localMap)) {
69146
+ const normalized = key.replaceAll(SEP9, "/");
69147
+ const type = isRawAppFolderMetadataFile(normalized) ? "raw_app" : isAppFolderMetadataFile(normalized) ? "app" : undefined;
69148
+ if (!type || normalized.endsWith(json ? ".yaml" : ".json"))
69149
+ continue;
69150
+ const appPath = extractResourceName(normalized, type);
69151
+ let obj;
69152
+ try {
69153
+ obj = json ? JSON.parse(localMap[key]) : yamlParseContent(key, localMap[key]);
69154
+ } catch {
69155
+ continue;
69156
+ }
69157
+ if (!appPath || !obj || typeof obj != "object" || !("custom_path" in obj)) {
69158
+ continue;
69159
+ }
69160
+ const customPath = obj.custom_path;
69161
+ delete obj.custom_path;
69162
+ localMap[key] = json ? JSON.stringify(obj, null, 2) : import_yaml22.stringify(obj, yamlOptions);
69163
+ const fileKey = appPath.replaceAll("/", SEP9) + (json ? ".custom_path.json" : ".custom_path.yaml");
69164
+ if (customPath && !(fileKey in localMap)) {
69165
+ const file = { custom_path: customPath };
69166
+ localMap[fileKey] = json ? JSON.stringify(file, null, 2) : import_yaml22.stringify(file, yamlOptions);
69167
+ }
69168
+ }
69169
+ }
69098
69170
  async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetadataDeletion, codebases, ignoreCodebaseChanges, specificItems, branchOverride, isEls1Remote, caseInsensitiveFs, parentOwnsScheduleEnabled) {
69099
69171
  let [m1, m2] = els2 ? await Promise.all([
69100
69172
  elementsToMap(els1, ignore, json, skips, specificItems, branchOverride, isEls1Remote),
@@ -69138,6 +69210,21 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
69138
69210
  depFiles: skips.skipWorkspaceDependencies ? Object.keys(await getRawWorkspaceDependencies(false)) : undefined
69139
69211
  }));
69140
69212
  }
69213
+ if (isEls1Remote === false) {
69214
+ liftInFileCustomPaths(m1, json);
69215
+ for (const [k, v] of Object.entries(m1)) {
69216
+ if (!isCustomPathFile(k) || k in m2)
69217
+ continue;
69218
+ let value;
69219
+ try {
69220
+ value = (json ? JSON.parse(v) : yamlParseContent(k, v))?.custom_path;
69221
+ } catch {
69222
+ continue;
69223
+ }
69224
+ if (!value)
69225
+ delete m1[k];
69226
+ }
69227
+ }
69141
69228
  const changes = [];
69142
69229
  function parseYaml(k, v) {
69143
69230
  if (k.endsWith(".script.yaml")) {
@@ -69265,6 +69352,9 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
69265
69352
  const remoteCodebase = {};
69266
69353
  for (const [k] of Object.entries(m2)) {
69267
69354
  if (m1[k] === undefined) {
69355
+ if (isEls1Remote === false && isCustomPathFile(k)) {
69356
+ continue;
69357
+ }
69268
69358
  if (!ignoreMetadataDeletion || !k?.endsWith(".script.yaml") && !k?.endsWith(".script.json")) {
69269
69359
  changes.push({ name: "deleted", path: k });
69270
69360
  } else if (k?.endsWith(".script.yaml")) {
@@ -69348,12 +69438,14 @@ function getOrderFromPath(p) {
69348
69438
  return 11;
69349
69439
  } else if (typ == "app") {
69350
69440
  return 12;
69351
- } else if (typ == "schedule") {
69441
+ } else if (typ == "custom_path") {
69352
69442
  return 13;
69353
- } else if (typ == "http_trigger" || typ == "websocket_trigger" || typ == "kafka_trigger" || typ == "nats_trigger" || typ == "postgres_trigger" || typ == "mqtt_trigger" || typ == "amqp_trigger" || typ == "sqs_trigger" || typ == "gcp_trigger" || typ == "azure_trigger" || typ == "email_trigger" || typ == "native_trigger") {
69443
+ } else if (typ == "schedule") {
69354
69444
  return 14;
69355
- } else {
69445
+ } else if (typ == "http_trigger" || typ == "websocket_trigger" || typ == "kafka_trigger" || typ == "nats_trigger" || typ == "postgres_trigger" || typ == "mqtt_trigger" || typ == "amqp_trigger" || typ == "sqs_trigger" || typ == "gcp_trigger" || typ == "azure_trigger" || typ == "email_trigger" || typ == "native_trigger") {
69356
69446
  return 15;
69447
+ } else {
69448
+ return 16;
69357
69449
  }
69358
69450
  }
69359
69451
  async function ignoreF(wmillconf) {
@@ -69757,7 +69849,7 @@ async function pull(opts) {
69757
69849
  type: change.name,
69758
69850
  path: change.path,
69759
69851
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
69760
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
69852
+ ...isSpecificItem(change.path, specificItems) ? {
69761
69853
  workspace_specific: true,
69762
69854
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
69763
69855
  } : {}
@@ -69787,7 +69879,7 @@ async function pull(opts) {
69787
69879
  for await (const rawChange of changes) {
69788
69880
  const change = rawChange;
69789
69881
  let targetPath = change.path;
69790
- if (specificItems && isSpecificItem(change.path, specificItems)) {
69882
+ if (isSpecificItem(change.path, specificItems)) {
69791
69883
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
69792
69884
  if (workspaceSpecificPath) {
69793
69885
  targetPath = workspaceSpecificPath;
@@ -69917,7 +70009,7 @@ Both local and remote have been modified.`));
69917
70009
  type: change.name,
69918
70010
  path: change.path,
69919
70011
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
69920
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
70012
+ ...isSpecificItem(change.path, specificItems) ? {
69921
70013
  workspace_specific: true,
69922
70014
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
69923
70015
  } : {}
@@ -70037,7 +70129,7 @@ function prettyChanges(changes, specificItems, branchOverride, folderDefaultAnno
70037
70129
  for (const change of changes) {
70038
70130
  let displayPath = change.path;
70039
70131
  let wsNote = "";
70040
- if (specificItems && isSpecificItem(change.path, specificItems)) {
70132
+ if (isSpecificItem(change.path, specificItems)) {
70041
70133
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, branchOverride);
70042
70134
  if (workspaceSpecificPath) {
70043
70135
  displayPath = workspaceSpecificPath;
@@ -70590,7 +70682,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70590
70682
  type: change.name,
70591
70683
  path: change.path,
70592
70684
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
70593
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
70685
+ ...isSpecificItem(change.path, specificItems) ? {
70594
70686
  workspace_specific: true,
70595
70687
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
70596
70688
  } : {}
@@ -70690,7 +70782,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70690
70782
  }
70691
70783
  const groupedChanges = new Map;
70692
70784
  for (const change of changes) {
70693
- const basePath = getScriptBasePathFromModulePath(change.path) ?? change.path.split(".")[0];
70785
+ const basePath = getScriptBasePathFromModulePath(change.path) ?? extractResourceName(change.path, "raw_app")?.replaceAll("/", SEP9) ?? extractResourceName(change.path, "app")?.replaceAll("/", SEP9) ?? change.path.split(".")[0];
70694
70786
  if (!groupedChanges.has(basePath)) {
70695
70787
  groupedChanges.set(basePath, []);
70696
70788
  }
@@ -70734,7 +70826,10 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70734
70826
  if (deleteRawApp) {
70735
70827
  changes = [deleteRawApp];
70736
70828
  } else {
70737
- changes.splice(1, changes.length - 1);
70829
+ changes = [
70830
+ changes[0],
70831
+ ...changes.slice(1).filter((c) => isCustomPathFile(c.path))
70832
+ ];
70738
70833
  }
70739
70834
  }
70740
70835
  for await (const change of changes) {
@@ -70823,7 +70918,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70823
70918
  const oldObj = parseFromPath(change.path, change.before);
70824
70919
  const newObj = parseFromPath(change.path, change.after);
70825
70920
  let originalWorkspaceSpecificPath;
70826
- const isWsSpecific = specificItems && isSpecificItem(change.path, specificItems);
70921
+ const isWsSpecific = isSpecificItem(change.path, specificItems);
70827
70922
  if (isWsSpecific) {
70828
70923
  originalWorkspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
70829
70924
  }
@@ -70881,7 +70976,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70881
70976
  }
70882
70977
  const obj = parseFromPath(change.path, change.content);
70883
70978
  let localFilePath = change.path;
70884
- const isAddedWsSpecific = specificItems && isSpecificItem(change.path, specificItems);
70979
+ const isAddedWsSpecific = isSpecificItem(change.path, specificItems);
70885
70980
  if (isAddedWsSpecific) {
70886
70981
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
70887
70982
  if (workspaceSpecificPath) {
@@ -71258,7 +71353,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
71258
71353
  type: change.name,
71259
71354
  path: change.path,
71260
71355
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
71261
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
71356
+ ...isSpecificItem(change.path, specificItems) ? {
71262
71357
  workspace_specific: true,
71263
71358
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
71264
71359
  } : {}
@@ -72610,7 +72705,7 @@ async function collectAppFiles(localPath) {
72610
72705
  await readDirRecursive(localPath);
72611
72706
  return files;
72612
72707
  }
72613
- async function pushRawApp(workspace, remotePath, localPath, message, defaultTs = "bun", permissionedAsContext) {
72708
+ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs = "bun", permissionedAsContext, customPathFromFile = true) {
72614
72709
  if (alreadySynced.includes(localPath)) {
72615
72710
  return;
72616
72711
  }
@@ -72673,10 +72768,12 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72673
72768
  extra_perms: localPerms,
72674
72769
  sandbox: _sandbox,
72675
72770
  frontend_api: _frontendApi,
72771
+ custom_path: localCustomPath,
72676
72772
  ...localAppNoPerms
72677
72773
  } = localApp;
72774
+ const customPath = customPathFromFile ? localCustomPath : undefined;
72678
72775
  if (app) {
72679
- const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && isolationUpToDate(isolation, deployedPolicy, true);
72776
+ const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && changedCustomPath(customPath, app) === undefined && isolationUpToDate(isolation, deployedPolicy, true);
72680
72777
  const filesUpToDate = deepEqual(files, app.value?.files);
72681
72778
  if (metadataUpToDate && filesUpToDate) {
72682
72779
  info(colors.green(`App ${remotePath} is up to date`));
@@ -72695,7 +72792,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72695
72792
  ...preserveFields,
72696
72793
  deployment_message: message,
72697
72794
  skip_draft_deletion: true,
72698
- ...localApp.custom_path ? { custom_path: localApp.custom_path } : {}
72795
+ custom_path: changedCustomPath(customPath, app)
72699
72796
  },
72700
72797
  js,
72701
72798
  css
@@ -72714,7 +72811,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72714
72811
  policy: appForPolicy.policy,
72715
72812
  deployment_message: message,
72716
72813
  skip_draft_deletion: true,
72717
- ...localApp.custom_path ? { custom_path: localApp.custom_path } : {}
72814
+ ...customPath ? { custom_path: customPath } : {}
72718
72815
  },
72719
72816
  js,
72720
72817
  css
@@ -74271,7 +74368,7 @@ data: reload
74271
74368
  if (!runnable) {
74272
74369
  throw new Error(`Runnable not found: ${runnableId}`);
74273
74370
  }
74274
- const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs);
74371
+ const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs, previewModules(runnables, runnableId));
74275
74372
  info(colors.gray(`[backend] Job started: ${uuid}`));
74276
74373
  const result = await waitForJob(workspaceId, uuid);
74277
74374
  return { uuid, result };
@@ -74296,7 +74393,7 @@ data: reload
74296
74393
  if (!runnable) {
74297
74394
  throw new Error(`Runnable not found: ${runnable_id}`);
74298
74395
  }
74299
- const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs);
74396
+ const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs, previewModules(runnables, runnable_id));
74300
74397
  info(colors.gray(`[backendAsync] Job started: ${uuid}`));
74301
74398
  respond("backendAsyncRes", uuid, false);
74302
74399
  waitForJob(workspaceId, uuid).then((result) => {
@@ -74612,7 +74709,43 @@ async function loadRunnables() {
74612
74709
  return {};
74613
74710
  }
74614
74711
  }
74615
- async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs) {
74712
+ function moduleExtension(language) {
74713
+ if (language === "bun" || language === "bunnative")
74714
+ return "ts";
74715
+ if (language === "python3")
74716
+ return "py";
74717
+ return;
74718
+ }
74719
+ function siblingImports(content, ext) {
74720
+ const pattern = ext === "ts" ? /(?:from|import)\s*['"]\.\/([^'"/]+?)(?:\.ts)?['"]/g : /^\s*from\s+\.([A-Za-z_]\w*)\s+import\b/gm;
74721
+ return Array.from(content.matchAll(pattern), (m) => m[1]);
74722
+ }
74723
+ function previewModules(runnables, runnableId) {
74724
+ const inlineScriptOf = (r) => r && ("inlineScript" in r) ? r.inlineScript : undefined;
74725
+ const own = inlineScriptOf(runnables[runnableId]);
74726
+ const ext = moduleExtension(own?.language);
74727
+ if (!own || !ext)
74728
+ return;
74729
+ const modules = {};
74730
+ const queue = siblingImports(own.content, ext);
74731
+ while (queue.length > 0) {
74732
+ const id = queue.pop();
74733
+ const key = `${id}.${ext}`;
74734
+ const inlineScript = inlineScriptOf(runnables[id]);
74735
+ if (key in modules || key === "main.ts")
74736
+ continue;
74737
+ if (!inlineScript || moduleExtension(inlineScript.language) !== ext) {
74738
+ continue;
74739
+ }
74740
+ modules[key] = {
74741
+ content: inlineScript.content,
74742
+ language: inlineScript.language
74743
+ };
74744
+ queue.push(...siblingImports(inlineScript.content, ext));
74745
+ }
74746
+ return Object.keys(modules).length > 0 ? modules : undefined;
74747
+ }
74748
+ async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs, modules) {
74616
74749
  const requestBody = {
74617
74750
  component: runnableId,
74618
74751
  args: args ?? {},
@@ -74637,12 +74770,14 @@ async function executeRunnable(runnable, workspace, appPath, runnableId, args, t
74637
74770
  if (inlineScript.id !== undefined) {
74638
74771
  requestBody.id = inlineScript.id;
74639
74772
  }
74773
+ const previewMods = inlineScript.id === undefined ? modules : undefined;
74640
74774
  requestBody.raw_code = {
74641
74775
  content: inlineScript.id === undefined ? inlineScript.content : "",
74642
74776
  language: inlineScript.language ?? "",
74643
74777
  path: `${appPath}/${runnableId}`,
74644
- lock: inlineScript.id === undefined ? inlineScript.lock : undefined,
74645
- cache_ttl: inlineScript.cache_ttl
74778
+ lock: inlineScript.id === undefined && !previewMods ? inlineScript.lock : undefined,
74779
+ cache_ttl: inlineScript.cache_ttl,
74780
+ ...previewMods ? { modules: previewMods } : {}
74646
74781
  };
74647
74782
  if (inlineScript.id === undefined && tempScriptRefs) {
74648
74783
  requestBody.temp_script_refs = tempScriptRefs;
@@ -75605,7 +75740,8 @@ CREATE SCHEMA IF NOT EXISTS ${schemaName};
75605
75740
  await mkdir10(path23.join(appDir, "backend"), { recursive: true });
75606
75741
  await mkdir10(path23.join(appDir, "sql_to_apply"), { recursive: true });
75607
75742
  const rawAppConfig = {
75608
- summary
75743
+ summary,
75744
+ sandbox: true
75609
75745
  };
75610
75746
  if (dataConfig.datatable) {
75611
75747
  rawAppConfig.data = dataConfig;
@@ -75987,6 +76123,23 @@ function stripEditorState(app) {
75987
76123
  delete app.value.parent_version;
75988
76124
  }
75989
76125
  }
76126
+ function changedCustomPath(local, deployed) {
76127
+ return (local ?? "") === (deployed?.custom_path ?? "") ? undefined : local;
76128
+ }
76129
+ async function pushAppCustomPath(workspace, remotePath, localFile) {
76130
+ remotePath = remotePath.replaceAll(SEP14, "/");
76131
+ const deployed = await getAppByPath({ workspace, path: remotePath });
76132
+ const customPath = changedCustomPath(localFile?.custom_path ?? "", deployed);
76133
+ if (customPath === undefined) {
76134
+ return;
76135
+ }
76136
+ info(colors.bold.yellow(`Setting custom path of app ${remotePath}...`));
76137
+ await updateApp({
76138
+ workspace,
76139
+ path: remotePath,
76140
+ requestBody: { custom_path: customPath, skip_draft_deletion: true }
76141
+ });
76142
+ }
75990
76143
  function isExecutionModeAnonymous(app) {
75991
76144
  return app?.["policy"]?.["execution_mode"] == "anonymous";
75992
76145
  }
@@ -76067,7 +76220,7 @@ function isolationUpToDate(isolation, deployedPolicy, rawApp) {
76067
76220
  const deployed = deployedPolicy?.frontend_sdk_scopes ?? [];
76068
76221
  return deployed.length === isolation.frontendApi.length && deployed.every((s, i) => s === isolation.frontendApi[i]);
76069
76222
  }
76070
- async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext) {
76223
+ async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext, customPathFromFile = true) {
76071
76224
  if (alreadySynced2.includes(localPath)) {
76072
76225
  return;
76073
76226
  }
@@ -76099,10 +76252,12 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76099
76252
  extra_perms: localPerms,
76100
76253
  sandbox: _sandbox,
76101
76254
  frontend_api: _frontendApi,
76255
+ custom_path: localCustomPath,
76102
76256
  ...localAppBody
76103
76257
  } = localApp;
76258
+ const customPath = customPathFromFile ? localCustomPath : undefined;
76104
76259
  if (app) {
76105
- if (isSuperset(localAppBody, app) && isolationUpToDate(isolation, deployedPolicy, false)) {
76260
+ if (isSuperset(localAppBody, app) && changedCustomPath(customPath, app) === undefined && isolationUpToDate(isolation, deployedPolicy, false)) {
76106
76261
  info(colors.green(`App ${remotePath} is up to date`));
76107
76262
  } else {
76108
76263
  info(colors.bold.yellow(`Updating app ${remotePath}...`));
@@ -76112,6 +76267,7 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76112
76267
  requestBody: {
76113
76268
  deployment_message: message,
76114
76269
  ...localAppBody,
76270
+ custom_path: changedCustomPath(customPath, app),
76115
76271
  ...preserveFields,
76116
76272
  skip_draft_deletion: true
76117
76273
  }
@@ -76125,6 +76281,7 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76125
76281
  path: remotePath,
76126
76282
  deployment_message: message,
76127
76283
  ...localAppBody,
76284
+ ...customPath ? { custom_path: customPath } : {},
76128
76285
  ...preserveFields,
76129
76286
  skip_draft_deletion: true
76130
76287
  }
@@ -77717,13 +77874,15 @@ async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced
77717
77874
  if (!appName) {
77718
77875
  throw new Error(`Could not extract app name from path: ${p}`);
77719
77876
  }
77720
- await pushApp(workspace, appName, buildFolderPath(appName, "app"), message, permissionedAsContext);
77877
+ await pushApp(workspace, appName, buildFolderPath(appName, "app"), message, permissionedAsContext, false);
77721
77878
  } else if (typeEnding === "raw_app") {
77722
77879
  const rawAppName = extractResourceName(p, "raw_app");
77723
77880
  if (!rawAppName) {
77724
77881
  throw new Error(`Could not extract raw app name from path: ${p}`);
77725
77882
  }
77726
- await pushRawApp(workspace, rawAppName, buildFolderPath(rawAppName, "raw_app"), message, defaultTs, permissionedAsContext);
77883
+ await pushRawApp(workspace, rawAppName, buildFolderPath(rawAppName, "raw_app"), message, defaultTs, permissionedAsContext, false);
77884
+ } else if (typeEnding === "custom_path") {
77885
+ await pushAppCustomPath(workspace, removeType(p, "custom_path"), newObj);
77727
77886
  } else if (typeEnding === "folder") {
77728
77887
  await pushFolder(workspace, p, befObj, newObj);
77729
77888
  } else if (typeEnding === "variable") {
@@ -77854,7 +78013,7 @@ function getTypeStrFromPath(p) {
77854
78013
  if (typeEnding?.endsWith("_native_trigger")) {
77855
78014
  return "native_trigger";
77856
78015
  }
77857
- if (typeEnding === "script" || typeEnding === "variable" || typeEnding === "resource" || typeEnding === "resource-type" || typeEnding === "app" || typeEnding === "schedule" || typeEnding === "http_trigger" || typeEnding === "websocket_trigger" || typeEnding === "kafka_trigger" || typeEnding === "nats_trigger" || typeEnding === "postgres_trigger" || typeEnding === "mqtt_trigger" || typeEnding === "amqp_trigger" || typeEnding === "sqs_trigger" || typeEnding === "gcp_trigger" || typeEnding === "azure_trigger" || typeEnding === "email_trigger" || typeEnding === "user" || typeEnding === "group" || typeEnding === "settings" || typeEnding === "encryption_key") {
78016
+ if (typeEnding === "script" || typeEnding === "variable" || typeEnding === "resource" || typeEnding === "resource-type" || typeEnding === "app" || typeEnding === "custom_path" || typeEnding === "schedule" || typeEnding === "http_trigger" || typeEnding === "websocket_trigger" || typeEnding === "kafka_trigger" || typeEnding === "nats_trigger" || typeEnding === "postgres_trigger" || typeEnding === "mqtt_trigger" || typeEnding === "amqp_trigger" || typeEnding === "sqs_trigger" || typeEnding === "gcp_trigger" || typeEnding === "azure_trigger" || typeEnding === "email_trigger" || typeEnding === "user" || typeEnding === "group" || typeEnding === "settings" || typeEnding === "encryption_key") {
77858
78017
  return typeEnding;
77859
78018
  } else {
77860
78019
  throw new Error("Could not infer type of path " + JSON.stringify(parsed));
@@ -78476,6 +78635,7 @@ async function preview2(opts, flowPath) {
78476
78635
  }
78477
78636
  const workspace = await resolveWorkspace(opts);
78478
78637
  await requireLogin(opts);
78638
+ await ensurePreviewOnBehalfOfSupported(workspace.workspaceId, opts.onBehalfOf);
78479
78639
  const codebases = useLocalPathScripts ? listSyncCodebases(opts) : [];
78480
78640
  const argPath = flowPath;
78481
78641
  flowPath = toSyncRootRelativePath(flowPath, cwdBeforeConfig);
@@ -78529,7 +78689,7 @@ async function preview2(opts, flowPath) {
78529
78689
  const input = opts.data ? await resolve9(opts.data) : {};
78530
78690
  debug(`Flow value: ${JSON.stringify(localFlow.value, null, 2)}`);
78531
78691
  if (opts.step) {
78532
- await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent, opts.tag);
78692
+ await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent, opts.tag, opts.onBehalfOf);
78533
78693
  return;
78534
78694
  }
78535
78695
  if (!opts.silent) {
@@ -78542,7 +78702,8 @@ async function preview2(opts, flowPath) {
78542
78702
  path: flowWmPath,
78543
78703
  args: input,
78544
78704
  tag: opts.tag,
78545
- temp_script_refs: tempScriptRefs
78705
+ temp_script_refs: tempScriptRefs,
78706
+ on_behalf_of: opts.onBehalfOf
78546
78707
  }
78547
78708
  });
78548
78709
  const { result, success } = await pollForJobResult(workspace.workspaceId, jobId);
@@ -78563,7 +78724,7 @@ async function preview2(opts, flowPath) {
78563
78724
  info(JSON.stringify(result, null, 2));
78564
78725
  }
78565
78726
  }
78566
- async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, tempScriptRefs, silent, tag) {
78727
+ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, tempScriptRefs, silent, tag, onBehalfOf) {
78567
78728
  const module = findStepInFlowValue(localFlow.value, stepId);
78568
78729
  if (!module) {
78569
78730
  const available = collectStepIds(localFlow.value).join(", ") || "(none)";
@@ -78583,7 +78744,8 @@ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, t
78583
78744
  flow_path: flowWmPath,
78584
78745
  args,
78585
78746
  tag,
78586
- temp_script_refs: tempScriptRefs
78747
+ temp_script_refs: tempScriptRefs,
78748
+ on_behalf_of: onBehalfOf
78587
78749
  }
78588
78750
  });
78589
78751
  } else if (moduleValue?.type === "script") {
@@ -78604,10 +78766,14 @@ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, t
78604
78766
  flow_path: flowWmPath,
78605
78767
  args,
78606
78768
  tag,
78607
- temp_script_refs: tempScriptRefs
78769
+ temp_script_refs: tempScriptRefs,
78770
+ on_behalf_of: onBehalfOf
78608
78771
  }
78609
78772
  });
78610
78773
  } else if (moduleValue?.type === "flow") {
78774
+ if (onBehalfOf) {
78775
+ throw new Error(`--on-behalf-of does not apply to step '${stepId}': a flow step runs the deployed flow ${moduleValue.path} by path, and this flag cannot override its identity.`);
78776
+ }
78611
78777
  info(colors.yellow(`Previewing step '${stepId}' (flow ${moduleValue.path})...`));
78612
78778
  jobId = await runFlowByPath({
78613
78779
  workspace: workspace.workspaceId,
@@ -78848,7 +79014,7 @@ var init_flow = __esm(async () => {
78848
79014
  ]);
78849
79015
  import_yaml41 = __toESM(require_dist(), 1);
78850
79016
  alreadySynced3 = [];
78851
- command22 = new Command().description("flow related commands").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("list", "list all flows").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("get", "get a flow's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get9).command("push", "push a local flow spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").option("--message <message:string>", "Deployment message").action(push11).command("run", "run a flow by path.").arguments("<path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not ouput anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(run3).command("preview", "preview a local flow without deploying it. Runs the flow definition from local files and uses local PathScripts by default. Pass --step <id> to run only one module in isolation (resolves nested steps inside branchone/branchall/forloopflow/whileloopflow plus the special preprocessor/failure modules; supported step types: rawscript, script, flow).").arguments("<flow_path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--remote", "Use deployed workspace scripts for PathScript steps instead of local files.").option("--step <step_id:string>", "Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(preview2).command("generate-locks", 'DEPRECATED: re-generate flow lock files. Use "wmill generate-metadata" instead.').arguments("[flow:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateLocks).command("new", "create a new empty flow").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("bootstrap", "create a new empty flow (alias for new)").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("history", "Show version history for a flow").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history2).command("show-version", "Show a specific version of a flow").arguments("<path:string> <version:string>").option("--json", "Output as JSON (for piping to jq)").action(showVersion).command("set-permissioned-as", "Set the on_behalf_of_email for a flow (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(async (opts, flowPath, email) => {
79017
+ command22 = new Command().description("flow related commands").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("list", "list all flows").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("get", "get a flow's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get9).command("push", "push a local flow spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").option("--message <message:string>", "Deployment message").action(push11).command("run", "run a flow by path.").arguments("<path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not ouput anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(run3).command("preview", "preview a local flow without deploying it. Runs the flow definition from local files and uses local PathScripts by default. Pass --step <id> to run only one module in isolation (resolves nested steps inside branchone/branchall/forloopflow/whileloopflow plus the special preprocessor/failure modules; supported step types: rawscript, script, flow).").arguments("<flow_path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--remote", "Use deployed workspace scripts for PathScript steps instead of local files.").option("--step <step_id:string>", "Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").option("--on-behalf-of <identity:string>", "Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.").action(preview2).command("generate-locks", 'DEPRECATED: re-generate flow lock files. Use "wmill generate-metadata" instead.').arguments("[flow:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateLocks).command("new", "create a new empty flow").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("bootstrap", "create a new empty flow (alias for new)").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("history", "Show version history for a flow").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history2).command("show-version", "Show a specific version of a flow").arguments("<path:string> <version:string>").option("--json", "Output as JSON (for piping to jq)").action(showVersion).command("set-permissioned-as", "Set the on_behalf_of_email for a flow (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(async (opts, flowPath, email) => {
78852
79018
  const workspace = await resolveWorkspace(opts);
78853
79019
  await requireLogin(opts);
78854
79020
  const remote = await getFlowByPath({
@@ -86477,7 +86643,7 @@ Reference a specific resource using \`$res:\` prefix:
86477
86643
 
86478
86644
  ## OpenFlow Schema
86479
86645
 
86480
- {"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: the n-th retry waits multiplier \\u00d7 seconds^n","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Base of the exponential (seconds); the n-th retry waits multiplier \\u00d7 seconds^n, where n counts constant retries too"},"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"},"job_token_scopes":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Scopes the token of this step's jobs is restricted to (domain:action[:resource], e.g. oidc:write), on top of the flow's own restriction: a step can only narrow it. Applies to everything the step runs (loop and branch bodies, AI agent tools)."},"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","typesafe","cloudflare"]},"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"},{"$ref":"#/components/schemas/AiDecision"}],"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","aidecision":"#/components/schemas/AiDecision"}}},"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."},"job_token_scopes":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Scopes the token of this tool's jobs is restricted to, on top of the agent step's own restriction: a tool can only narrow it."},"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"},"model":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Only on a step linked to a saved agent (see \`agent\`): replaces the model\\nsaved on the agent for this step's runs, on the agent's own provider resource. An\\nempty value keeps the saved model. Set it to an expression such as\\n\`flow_input.model\` to choose the model per run.\\n"},"reasoning_effort":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Only on a step linked to a saved agent (see \`agent\`): replaces the reasoning\\neffort saved on the agent for this step's runs, as a provider-native token (e.g.\\n'low', 'high', 'none'). An empty value sends no effort, so the model runs at its\\ndefault. Leave the input out to keep the saved effort, which holds only while the\\nstep runs the saved model. A step that is not linked sets both inside \`provider\`.\\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)\\nand, optionally, the \`model\` and \`reasoning_effort\` overrides of what the agent saved.\\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"]},"AiDecision":{"type":"object","description":"AI decision step: one call to a decision model (TypeSafe's Jev, Cloudflare's\\nJev-compatible Clef, or OpenAI's Decisions API) that answers typed questions about a\\nstate with calibrated probabilities, instead of generating text.\\nPrefer it over an AI agent to classify, route, score or check something: it is fast,\\ncheap and its answers are structured. Its result is { output: { <question name>: answer },\\nmodel, usage }, so a later step reads e.g. results.<id>.output.intent.choice. To route on\\nthe answers, follow it with a branchone whose branch exprs read\\nresults.<id>.output.<question>.choice. Usable as an AI agent tool, where the calling agent\\nsupplies the state.\\n","properties":{"input_transforms":{"type":"object","description":"Input parameters for the decision mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"state":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"What the questions are asked about: a string, an object or an array of strings.\\nAn object with descriptive keys holding only what the questions need works best.\\nExample: { message: flow_input.message, plan: results.a.plan }\\n"},"questions":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Object mapping each question name to { type, instructions, criteria }, where type is:\\n- 'choice': criteria maps each option to its description (up to 255); the answer\\n has choice, probabilities and confidence\\n- 'score': criteria is an ordered array of 2 to 10 level descriptions; the answer\\n has score, legend, probabilities and confidence\\n- 'noul': yes/no, criteria optionally { true, false } descriptions; the answer has\\n noul, the probability of yes (0 to 1)\\nExample: { intent: { type: 'choice', instructions: 'What does the customer want?',\\ncriteria: { refund: 'Money back', bug: 'Something is broken' } } }\\n"}},"required":["provider","state","questions"]},"type":{"type":"string","enum":["aidecision"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the step runs on the flow's tag (default \`flow\`)"}},"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"]}}
86646
+ {"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":"Id of the step whose result a sync webhook returns as soon as that step completes, while the rest of the flow keeps running. When the step does not run, or fails while the flow has a failure module, the flow's final result is returned instead."},"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: the n-th retry waits multiplier \\u00d7 seconds^n","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Base of the exponential (seconds); the n-th retry waits multiplier \\u00d7 seconds^n, where n counts constant retries too"},"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"},"job_token_scopes":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Scopes the token of this step's jobs is restricted to (domain:action[:resource], e.g. oidc:write), on top of the flow's own restriction: a step can only narrow it. Applies to everything the step runs (loop and branch bodies, AI agent tools)."},"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","typesafe","cloudflare"]},"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"},{"$ref":"#/components/schemas/AiDecision"}],"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","aidecision":"#/components/schemas/AiDecision"}}},"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."},"job_token_scopes":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Scopes the token of this tool's jobs is restricted to, on top of the agent step's own restriction: a tool can only narrow it."},"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"},"model":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Only on a step linked to a saved agent (see \`agent\`): replaces the model\\nsaved on the agent for this step's runs, on the agent's own provider resource. An\\nempty value keeps the saved model. Set it to an expression such as\\n\`flow_input.model\` to choose the model per run.\\n"},"reasoning_effort":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"String. Only on a step linked to a saved agent (see \`agent\`): replaces the reasoning\\neffort saved on the agent for this step's runs, as a provider-native token (e.g.\\n'low', 'high', 'none'). An empty value sends no effort, so the model runs at its\\ndefault. Leave the input out to keep the saved effort, which holds only while the\\nstep runs the saved model. A step that is not linked sets both inside \`provider\`.\\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)\\nand, optionally, the \`model\` and \`reasoning_effort\` overrides of what the agent saved.\\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"]},"AiDecision":{"type":"object","description":"AI decision step: one call to a decision model (TypeSafe's Jev, Cloudflare's\\nJev-compatible Clef, or OpenAI's Decisions API) that answers typed questions about a\\nstate with calibrated probabilities, instead of generating text.\\nPrefer it over an AI agent to classify, route, score or check something: it is fast,\\ncheap and its answers are structured. Its result is { output: { <question name>: answer },\\nmodel, usage }, so a later step reads e.g. results.<id>.output.intent.choice. To route on\\nthe answers, follow it with a branchone whose branch exprs read\\nresults.<id>.output.<question>.choice. Usable as an AI agent tool, where the calling agent\\nsupplies the state.\\n","properties":{"input_transforms":{"type":"object","description":"Input parameters for the decision mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"state":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"What the questions are asked about: a string, an object or an array of strings.\\nAn object with descriptive keys holding only what the questions need works best.\\nExample: { message: flow_input.message, plan: results.a.plan }\\n"},"questions":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Object mapping each question name to { type, instructions, criteria }, where type is:\\n- 'choice': criteria maps each option to its description (up to 255); the answer\\n has choice, probabilities and confidence\\n- 'score': criteria is an ordered array of 2 to 10 level descriptions; the answer\\n has score, legend, probabilities and confidence\\n- 'noul': yes/no, criteria optionally { true, false } descriptions; the answer has\\n noul, the probability of yes (0 to 1)\\nExample: { intent: { type: 'choice', instructions: 'What does the customer want?',\\ncriteria: { refund: 'Money back', bug: 'Something is broken' } } }\\n"}},"required":["provider","state","questions"]},"type":{"type":"string","enum":["aidecision"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the step runs on the flow's tag (default \`flow\`)"}},"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"]}}
86481
86647
  `,
86482
86648
  "raw-app": `---
86483
86649
  name: raw-app
@@ -86913,6 +87079,10 @@ def main(user_id: str):
86913
87079
  return user
86914
87080
  \`\`\`
86915
87081
 
87082
+ #### Sharing code between runnables
87083
+
87084
+ An inline runnable can import another inline runnable of the same app by its id, as a relative import: \`import { getDb } from './shared'\` (TypeScript, Bun) or \`from .shared import get_db\` (Python). This works across TypeScript (Bun) runnables and across Python runnables, not between the two. The imported runnable's own dependencies are picked up, and it can import further runnables in turn. A runnable that only holds helpers needs no \`main\`; the frontend just never calls it. A TypeScript runnable whose id is \`main\` cannot be imported, because that name is taken by the entrypoint file of every TypeScript job: give shared code any other id.
87085
+
86916
87086
  #### The \`wmill\` client is already authenticated
86917
87087
 
86918
87088
  An inline runnable runs as an ordinary Windmill job. \`import * as wmill from 'windmill-client'\` (TypeScript) and \`import wmill\` (Python) are already pointed at this instance and this workspace — there is nothing to configure.
@@ -86956,14 +87126,18 @@ A draft app is reachable by nobody; deploying is what exposes it, and its backen
86956
87126
  Either one lets those people run the app's backend runnables, so never open an app up unless the user asks.
86957
87127
  \`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.
86958
87128
 
87129
+ An app's custom URL is not in \`raw_app.yaml\`: each workspace has its own file next to the app folder, \`<app path>.<workspace>.custom_path.yaml\` (for example \`f/sales/dashboard.prod.custom_path.yaml\` holding \`custom_path: dashboard\`), where \`<workspace>\` is the workspace's name in \`wmill.yaml\`, or its id. A push applies only the target workspace's file and leaves the deployed custom URL alone when there is none, so deleting the file does not remove the URL: \`custom_path: ''\` does. Setting or clearing one takes a workspace admin.
87130
+
86959
87131
  ## Sandbox isolation and frontend API access
86960
87132
 
86961
- By default a deployed app's frontend runs with the viewer's own Windmill session. A sandboxed app is isolated from it: the frontend reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. The scopes are \`jobs:run\`, \`jobs:read\`, \`users:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls.
87133
+ New apps are sandboxed: the frontend is isolated from the viewer's own Windmill session and reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. With isolation turned off, the frontend runs with the viewer's full session. The scopes are \`jobs:run\`, \`jobs:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls. The viewer's identity needs no scope: it is in \`window.ctx\`, and whoami works with any of them.
87134
+
87135
+ Inside the sandbox, IndexedDB is unavailable, third-party sign-in and OAuth redirects fail, and requests to other services carry \`Origin: null\`, which an API that checks the origin rejects. Work around these first: call the service from a backend runnable, keep state in a data table or \`localStorage\`, or grant the frontend API scope the code needs. Suggest turning isolation off only when none of that works, and say plainly that it is a security risk: the app's code, and any XSS bug in it, then runs with the full Windmill permissions of everyone who opens the app.
86962
87136
  In \`raw_app.yaml\`:
86963
87137
 
86964
87138
  \`\`\`yaml
86965
87139
  sandbox: true
86966
- frontend_api: [jobs:run, users:read]
87140
+ frontend_api: [jobs:run]
86967
87141
  \`\`\`
86968
87142
 
86969
87143
  A file with a \`sandbox\` key states both settings: \`sandbox: false\` turns isolation off, and a missing \`frontend_api\` means no scopes. A file without the key leaves the deployed app's isolation and scopes as they are, so removing \`sandbox: true\` does not unsandbox it. \`frontend_api\` needs \`sandbox: true\`; the push fails otherwise.
@@ -88578,6 +88752,7 @@ flow related commands
88578
88752
  - \`--remote\` - Use deployed workspace scripts for PathScript steps instead of local files.
88579
88753
  - \`--step <step_id:string>\` - Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.
88580
88754
  - \`--tag <tag:string>\` - Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).
88755
+ - \`--on-behalf-of <identity:string>\` - Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.
88581
88756
  - \`flow new <flow_path:string>\` - create a new empty flow
88582
88757
  - \`--summary <summary:string>\` - flow summary
88583
88758
  - \`--description <description:string>\` - flow description
@@ -88976,6 +89151,7 @@ script related commands
88976
89151
  - \`-d --data <data:file>\` - Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.
88977
89152
  - \`-s --silent\` - Do not output anything other than the final output. Useful for scripting.
88978
89153
  - \`--tag <tag:string>\` - Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).
89154
+ - \`--on-behalf-of <identity:string>\` - Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.
88979
89155
  - \`script new <path:file> <language:string>\` - create a new script
88980
89156
  - \`--summary <summary:string>\` - script summary
88981
89157
  - \`--description <description:string>\` - script description
@@ -93465,6 +93641,17 @@ async function listWorkspacePaths() {
93465
93641
  items.push({ path: stripFolderSuffix(childRel, APP_SUFFIXES), kind: "raw_app" });
93466
93642
  continue;
93467
93643
  }
93644
+ if (entry.name.endsWith(getModuleFolderSuffix())) {
93645
+ const files = await readdir10(childAbs).catch(() => []);
93646
+ if (files.some((f) => f.startsWith("script.") && hasScriptExt(f))) {
93647
+ items.push({
93648
+ path: childRel.slice(0, -getModuleFolderSuffix().length),
93649
+ kind: "script",
93650
+ _metaPath: path25.join(childAbs, "script.yaml")
93651
+ });
93652
+ }
93653
+ continue;
93654
+ }
93468
93655
  if (entry.name.endsWith(DBT_MODULE_SUFFIX)) {
93469
93656
  const base = childRel.slice(0, -DBT_MODULE_SUFFIX.length);
93470
93657
  items.push({
@@ -93576,19 +93763,19 @@ async function dev2(opts) {
93576
93763
  const flowMetadataFile = getMetadataFileName("flow", "yaml");
93577
93764
  async function loadPaths(pathsToLoad) {
93578
93765
  const rest = [];
93579
- const dbtProjects = new Set;
93766
+ const scriptsWithModules = new Set;
93580
93767
  for (const raw of pathsToLoad) {
93581
93768
  const rel = (await realpath(raw).catch(() => raw)).replace(base + SEP22, "").replaceAll("\\", "/");
93582
- const wmPath = isDbtModulePath(rel) ? getScriptBasePathFromModulePath(rel) : undefined;
93769
+ const wmPath = getScriptBasePathFromModulePath(rel);
93583
93770
  if (wmPath)
93584
- dbtProjects.add(wmPath);
93771
+ scriptsWithModules.add(wmPath);
93585
93772
  else
93586
93773
  rest.push(raw);
93587
93774
  }
93588
- for (const wmPath of dbtProjects) {
93775
+ for (const wmPath of scriptsWithModules) {
93589
93776
  const edit = await loadWmPath(wmPath);
93590
93777
  if (edit) {
93591
- info("Updated " + wmPath + " (dbt project)");
93778
+ info("Updated " + wmPath + " (script modules)");
93592
93779
  broadcastChanges(edit);
93593
93780
  }
93594
93781
  }
@@ -93635,8 +93822,7 @@ async function dev2(opts) {
93635
93822
  info("Updated " + wmFlowPath);
93636
93823
  broadcastChanges(currentLastEdit);
93637
93824
  } else if (typ == "script") {
93638
- const splitted = cpath.split(".");
93639
- const wmPath = splitted[0];
93825
+ const wmPath = removeExtensionToPath(cpath);
93640
93826
  const content = await readTextFile(cpath);
93641
93827
  const lang = inferContentTypeFromFilePath(cpath, opts.defaultTs);
93642
93828
  const typed = (await parseMetadataFile(removeExtensionToPath(cpath), undefined))?.payload;
@@ -93647,7 +93833,8 @@ async function dev2(opts) {
93647
93833
  language: lang,
93648
93834
  tag: typed?.tag,
93649
93835
  lock: typed?.lock,
93650
- temp_script_refs: tempScriptRefs
93836
+ temp_script_refs: tempScriptRefs,
93837
+ modules: await readModulesFromDisk(wmPath + getModuleFolderSuffix(lang), opts.defaultTs, lang === "dbt", lang === "dbt")
93651
93838
  };
93652
93839
  info("Updated " + wmPath);
93653
93840
  broadcastChanges(currentLastEdit);
@@ -93690,8 +93877,11 @@ async function dev2(opts) {
93690
93877
  currentLastEdit = edit;
93691
93878
  return edit;
93692
93879
  } catch {}
93693
- for (const ext of exts) {
93694
- const filePath = wmPath + ext;
93880
+ const candidates = [
93881
+ ...exts.map((ext) => ({ ext, filePath: wmPath + ext, folderLayout: false })),
93882
+ ...exts.filter((ext) => !ext.includes("/")).map((ext) => ({ ext, filePath: wmPath + getModuleFolderSuffix() + "/script" + ext, folderLayout: true }))
93883
+ ];
93884
+ for (const { ext, filePath, folderLayout } of candidates) {
93695
93885
  try {
93696
93886
  const isAbsentDbtDescriptor = ext === "__dbt/" + DBT_DESCRIPTOR_NAME && !await access(filePath).then(() => true, () => false) && await access(wmPath + DBT_MODULE_SUFFIX + "/dbt_project.yml").then(() => true, () => false);
93697
93887
  if (!isAbsentDbtDescriptor) {
@@ -93699,7 +93889,7 @@ async function dev2(opts) {
93699
93889
  }
93700
93890
  const content = isAbsentDbtDescriptor ? "" : await readTextFile(filePath);
93701
93891
  const lang = inferContentTypeFromFilePath(filePath, opts.defaultTs);
93702
- const typed = (await parseMetadataFile(removeExtensionToPath(filePath), undefined))?.payload;
93892
+ const typed = (await parseMetadataFile(wmPath, undefined))?.payload;
93703
93893
  const edit = {
93704
93894
  type: "script",
93705
93895
  content,
@@ -93708,7 +93898,7 @@ async function dev2(opts) {
93708
93898
  tag: typed?.tag,
93709
93899
  lock: typed?.lock,
93710
93900
  temp_script_refs: tempScriptRefs,
93711
- modules: lang === "dbt" ? await readModulesFromDisk(wmPath + DBT_MODULE_SUFFIX, opts.defaultTs, true, true) : undefined
93901
+ modules: await readModulesFromDisk(wmPath + getModuleFolderSuffix(lang), opts.defaultTs, folderLayout || lang === "dbt", lang === "dbt")
93712
93902
  };
93713
93903
  currentLastEdit = edit;
93714
93904
  return edit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.834.0",
3
+ "version": "1.836.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",