windmill-cli 1.665.0 → 1.667.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 +660 -68
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -11618,21 +11618,40 @@ var require_dist = __commonJS((exports) => {
11618
11618
  import { readFile } from "node:fs/promises";
11619
11619
  async function yamlParseFile(path, options = {}) {
11620
11620
  try {
11621
- return import_yaml.parse(await readFile(path, "utf-8"), options);
11621
+ return import_yaml.parse(await readFile(path, "utf-8"), {
11622
+ ...options,
11623
+ customTags: [...WINDMILL_CUSTOM_TAGS, ...options.customTags ?? []]
11624
+ });
11622
11625
  } catch (e) {
11623
11626
  throw new Error(`Error parsing yaml ${path}`, { cause: e });
11624
11627
  }
11625
11628
  }
11626
11629
  function yamlParseContent(path, content, options = {}) {
11627
11630
  try {
11628
- return import_yaml.parse(content, options);
11631
+ return import_yaml.parse(content, {
11632
+ ...options,
11633
+ customTags: [...WINDMILL_CUSTOM_TAGS, ...options.customTags ?? []]
11634
+ });
11629
11635
  } catch (e) {
11630
11636
  throw new Error(`Error parsing yaml ${path}`, { cause: e });
11631
11637
  }
11632
11638
  }
11633
- var import_yaml;
11639
+ var import_yaml, inlineTag, inlineFilesetTag, WINDMILL_CUSTOM_TAGS;
11634
11640
  var init_yaml = __esm(() => {
11635
11641
  import_yaml = __toESM(require_dist(), 1);
11642
+ inlineTag = {
11643
+ tag: "!inline",
11644
+ resolve(value) {
11645
+ return "!inline " + value;
11646
+ }
11647
+ };
11648
+ inlineFilesetTag = {
11649
+ tag: "!inline_fileset",
11650
+ resolve(value) {
11651
+ return "!inline_fileset " + value;
11652
+ }
11653
+ };
11654
+ WINDMILL_CUSTOM_TAGS = [inlineTag, inlineFilesetTag];
11636
11655
  });
11637
11656
 
11638
11657
  // gen/core/ApiError.ts
@@ -11785,7 +11804,7 @@ var init_OpenAPI = __esm(() => {
11785
11804
  PASSWORD: undefined,
11786
11805
  TOKEN: getEnv2("WM_TOKEN"),
11787
11806
  USERNAME: undefined,
11788
- VERSION: "1.665.0",
11807
+ VERSION: "1.667.0",
11789
11808
  WITH_CREDENTIALS: true,
11790
11809
  interceptors: {
11791
11810
  request: new Interceptors,
@@ -12344,6 +12363,7 @@ __export(exports_services_gen, {
12344
12363
  importQueuedJobs: () => importQueuedJobs,
12345
12364
  importInstallation: () => importInstallation,
12346
12365
  importCompletedJobs: () => importCompletedJobs,
12366
+ impersonateServiceAccount: () => impersonateServiceAccount,
12347
12367
  globalWhoami: () => globalWhoami,
12348
12368
  globalUsersOverwrite: () => globalUsersOverwrite,
12349
12369
  globalUsersExport: () => globalUsersExport,
@@ -12443,6 +12463,7 @@ __export(exports_services_gen, {
12443
12463
  getIndexerStatus: () => getIndexerStatus,
12444
12464
  getIndexStorageSizes: () => getIndexStorageSizes,
12445
12465
  getIndexDiskStorageSizes: () => getIndexDiskStorageSizes,
12466
+ getImports: () => getImports,
12446
12467
  getHubScriptContentByPath: () => getHubScriptContentByPath,
12447
12468
  getHubScriptByPath: () => getHubScriptByPath,
12448
12469
  getHubRawAppById: () => getHubRawAppById,
@@ -12520,6 +12541,7 @@ __export(exports_services_gen, {
12520
12541
  exportInstanceGroups: () => exportInstanceGroups,
12521
12542
  exportInstallation: () => exportInstallation,
12522
12543
  exportCompletedJobs: () => exportCompletedJobs,
12544
+ exitImpersonation: () => exitImpersonation,
12523
12545
  existsWorkspace: () => existsWorkspace,
12524
12546
  existsWorkersWithTags: () => existsWorkersWithTags,
12525
12547
  existsWebsocketTrigger: () => existsWebsocketTrigger,
@@ -12634,6 +12656,7 @@ __export(exports_services_gen, {
12634
12656
  createToken: () => createToken,
12635
12657
  createTemplateScript: () => createTemplateScript,
12636
12658
  createSqsTrigger: () => createSqsTrigger,
12659
+ createServiceAccount: () => createServiceAccount,
12637
12660
  createScript: () => createScript,
12638
12661
  createSchedule: () => createSchedule,
12639
12662
  createResourceType: () => createResourceType,
@@ -13373,6 +13396,36 @@ var backendVersion = () => {
13373
13396
  body: data2.requestBody,
13374
13397
  mediaType: "application/json"
13375
13398
  });
13399
+ }, createServiceAccount = (data2) => {
13400
+ return request(OpenAPI, {
13401
+ method: "POST",
13402
+ url: "/w/{workspace}/workspaces/create_service_account",
13403
+ path: {
13404
+ workspace: data2.workspace
13405
+ },
13406
+ body: data2.requestBody,
13407
+ mediaType: "application/json"
13408
+ });
13409
+ }, impersonateServiceAccount = (data2) => {
13410
+ return request(OpenAPI, {
13411
+ method: "POST",
13412
+ url: "/w/{workspace}/users/impersonate_service_account",
13413
+ path: {
13414
+ workspace: data2.workspace
13415
+ },
13416
+ body: data2.requestBody,
13417
+ mediaType: "application/json"
13418
+ });
13419
+ }, exitImpersonation = (data2) => {
13420
+ return request(OpenAPI, {
13421
+ method: "POST",
13422
+ url: "/w/{workspace}/users/exit_impersonation",
13423
+ path: {
13424
+ workspace: data2.workspace
13425
+ },
13426
+ body: data2.requestBody,
13427
+ mediaType: "application/json"
13428
+ });
13376
13429
  }, deleteInvite = (data2) => {
13377
13430
  return request(OpenAPI, {
13378
13431
  method: "POST",
@@ -13589,6 +13642,15 @@ var backendVersion = () => {
13589
13642
  imported_path: data2.importedPath
13590
13643
  }
13591
13644
  });
13645
+ }, getImports = (data2) => {
13646
+ return request(OpenAPI, {
13647
+ method: "GET",
13648
+ url: "/w/{workspace}/workspaces/get_imports/{importer_path}",
13649
+ path: {
13650
+ workspace: data2.workspace,
13651
+ importer_path: data2.importerPath
13652
+ }
13653
+ });
13592
13654
  }, getDependentsAmounts = (data2) => {
13593
13655
  return request(OpenAPI, {
13594
13656
  method: "POST",
@@ -24439,6 +24501,12 @@ function isRawAppMetadataFile(p) {
24439
24501
  function isRawAppFolderMetadataFile(p) {
24440
24502
  return p.endsWith(getMetadataPathSuffix("raw_app", "yaml")) || p.endsWith(getMetadataPathSuffix("raw_app", "json"));
24441
24503
  }
24504
+ function isAppFolderMetadataFile(p) {
24505
+ return p.endsWith(getMetadataPathSuffix("app", "yaml")) || p.endsWith(getMetadataPathSuffix("app", "json"));
24506
+ }
24507
+ function isFlowFolderMetadataFile(p) {
24508
+ return p.endsWith(getMetadataPathSuffix("flow", "yaml")) || p.endsWith(getMetadataPathSuffix("flow", "json"));
24509
+ }
24442
24510
  function getModuleFolderSuffix() {
24443
24511
  return MODULE_SUFFIX;
24444
24512
  }
@@ -56151,12 +56219,16 @@ function getBranchSpecificTypes() {
56151
56219
  return {
56152
56220
  variable: ".variable.yaml",
56153
56221
  resource: ".resource.yaml",
56222
+ schedule: ".schedule.yaml",
56154
56223
  ...Object.fromEntries(TRIGGER_TYPES.map((t) => [`${t}_trigger`, `.${t}_trigger.yaml`]))
56155
56224
  };
56156
56225
  }
56157
56226
  function isTriggerFile(path5) {
56158
56227
  return TRIGGER_TYPES.some((type) => path5.endsWith(`.${type}_trigger.yaml`));
56159
56228
  }
56229
+ function isScheduleFile(path5) {
56230
+ return path5.endsWith(".schedule.yaml");
56231
+ }
56160
56232
  function getFileTypeSuffix(path5) {
56161
56233
  for (const [_, suffix] of Object.entries(getBranchSpecificTypes())) {
56162
56234
  if (path5.endsWith(suffix)) {
@@ -56170,7 +56242,7 @@ function getFileTypeSuffix(path5) {
56170
56242
  return null;
56171
56243
  }
56172
56244
  function buildYamlTypePattern() {
56173
- const basicTypes = ["variable", "resource"];
56245
+ const basicTypes = ["variable", "resource", "schedule"];
56174
56246
  const triggerTypes = TRIGGER_TYPES.map((t) => `${t}_trigger`);
56175
56247
  return `((${basicTypes.join("|")})|(${triggerTypes.join("|")}))`;
56176
56248
  }
@@ -56202,6 +56274,9 @@ function getSpecificItemsForCurrentBranch(config, branchOverride) {
56202
56274
  if (commonItems?.triggers) {
56203
56275
  merged.triggers = [...commonItems.triggers];
56204
56276
  }
56277
+ if (commonItems?.schedules) {
56278
+ merged.schedules = [...commonItems.schedules];
56279
+ }
56205
56280
  if (commonItems?.folders) {
56206
56281
  merged.folders = [...commonItems.folders];
56207
56282
  }
@@ -56217,6 +56292,9 @@ function getSpecificItemsForCurrentBranch(config, branchOverride) {
56217
56292
  if (branchItems?.triggers) {
56218
56293
  merged.triggers = [...merged.triggers || [], ...branchItems.triggers];
56219
56294
  }
56295
+ if (branchItems?.schedules) {
56296
+ merged.schedules = [...merged.schedules || [], ...branchItems.schedules];
56297
+ }
56220
56298
  if (branchItems?.folders) {
56221
56299
  merged.folders = [...merged.folders || [], ...branchItems.folders];
56222
56300
  }
@@ -56241,6 +56319,9 @@ function isItemTypeConfigured(path5, specificItems) {
56241
56319
  if (isTriggerFile(path5)) {
56242
56320
  return specificItems.triggers !== undefined;
56243
56321
  }
56322
+ if (isScheduleFile(path5)) {
56323
+ return specificItems.schedules !== undefined;
56324
+ }
56244
56325
  if (path5.endsWith("/folder.meta.yaml")) {
56245
56326
  return specificItems.folders !== undefined;
56246
56327
  }
@@ -56265,6 +56346,9 @@ function isSpecificItem(path5, specificItems) {
56265
56346
  if (isTriggerFile(path5)) {
56266
56347
  return specificItems.triggers ? matchesPatterns(path5, specificItems.triggers) : false;
56267
56348
  }
56349
+ if (isScheduleFile(path5)) {
56350
+ return specificItems.schedules ? matchesPatterns(path5, specificItems.schedules) : false;
56351
+ }
56268
56352
  if (path5.endsWith("/folder.meta.yaml")) {
56269
56353
  if (specificItems.folders) {
56270
56354
  const folderPath = path5.slice(0, -"/folder.meta.yaml".length);
@@ -59175,7 +59259,8 @@ async function handleFile(path6, workspace, alreadySynced, message, opts, rawWor
59175
59259
  info(`Updating script ${remotePath} ...`);
59176
59260
  const body = {
59177
59261
  ...requestBodyCommon,
59178
- parent_hash: remote.hash
59262
+ parent_hash: remote.hash,
59263
+ auto_parent: true
59179
59264
  };
59180
59265
  const execTime = await createScript2(bundleContent, workspaceId, body, workspace);
59181
59266
  info(colors.yellow.bold(`Updated script ${remotePath} (${execTime.toFixed(0)}ms)`));
@@ -60546,6 +60631,10 @@ function getLanguageFromExtension(ext2, defaultTs = "bun") {
60546
60631
  }
60547
60632
  return;
60548
60633
  }
60634
+ function sanitizeForFilesystem(summary) {
60635
+ const name = summary.toLowerCase().replaceAll(" ", "_").replace(/[/\\:*?"<>|\x00-\x1f\x7f]/g, "").replace(/_+/g, "_").replace(/^[._]+|[._]+$/g, "");
60636
+ return WINDOWS_RESERVED.test(name) ? `_${name}` : name;
60637
+ }
60549
60638
  function newPathAssigner(defaultTs, options) {
60550
60639
  const resolvedOptions = typeof defaultTs === "object" ? defaultTs : { defaultTs, skipInlineScriptSuffix: options?.skipInlineScriptSuffix };
60551
60640
  const { defaultTs: tsRuntime, skipInlineScriptSuffix } = resolvedOptions;
@@ -60553,7 +60642,7 @@ function newPathAssigner(defaultTs, options) {
60553
60642
  const seen_names = new Set;
60554
60643
  function assignPath(summary, language) {
60555
60644
  let name;
60556
- name = summary?.toLowerCase()?.replaceAll(" ", "_") ?? "";
60645
+ name = summary ? sanitizeForFilesystem(summary) : "";
60557
60646
  let original_name = name;
60558
60647
  if (name == "") {
60559
60648
  original_name = INLINE_SCRIPT_PREFIX;
@@ -60575,7 +60664,7 @@ function newRawAppPathAssigner(defaultTs) {
60575
60664
  const seen_names = new Set;
60576
60665
  function assignPath(summary, language) {
60577
60666
  let name;
60578
- name = summary?.toLowerCase()?.replaceAll(" ", "_") ?? "";
60667
+ name = summary ? sanitizeForFilesystem(summary) : "";
60579
60668
  let original_name = name;
60580
60669
  if (name == "") {
60581
60670
  original_name = "runnable";
@@ -60591,7 +60680,7 @@ function newRawAppPathAssigner(defaultTs) {
60591
60680
  }
60592
60681
  return { assignPath };
60593
60682
  }
60594
- var INLINE_SCRIPT_PREFIX = "inline_script", LANGUAGE_EXTENSIONS, EXTENSION_TO_LANGUAGE;
60683
+ var INLINE_SCRIPT_PREFIX = "inline_script", LANGUAGE_EXTENSIONS, EXTENSION_TO_LANGUAGE, WINDOWS_RESERVED;
60595
60684
  var init_path_assigner = __esm(() => {
60596
60685
  LANGUAGE_EXTENSIONS = {
60597
60686
  python3: "py",
@@ -60645,19 +60734,23 @@ var init_path_assigner = __esm(() => {
60645
60734
  rb: "ruby",
60646
60735
  ts: "bun"
60647
60736
  };
60737
+ WINDOWS_RESERVED = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/;
60648
60738
  });
60649
60739
 
60650
60740
  // windmill-utils-internal/src/inline-scripts/extractor.ts
60651
60741
  function extractRawscriptInline(id, summary, rawscript, mapping, separator, assigner) {
60652
60742
  const [basePath, ext2] = assigner.assignPath(summary ?? id, rawscript.language);
60653
- const path7 = mapping[id] ?? basePath + ext2;
60743
+ const mappedPath = mapping[id];
60744
+ const path7 = mappedPath ?? basePath + ext2;
60654
60745
  const language = rawscript.language;
60655
60746
  const content = rawscript.content;
60656
60747
  const r = [{ path: path7, content, language, is_lock: false }];
60657
60748
  rawscript.content = "!inline " + path7.replaceAll(separator, "/");
60658
60749
  const lock = rawscript.lock;
60659
60750
  if (lock && lock != "") {
60660
- const lockPath = basePath + "lock";
60751
+ const dotIdx = mappedPath ? mappedPath.lastIndexOf(".") : -1;
60752
+ const lockBasePath = mappedPath ? dotIdx > 0 ? mappedPath.substring(0, dotIdx + 1) : mappedPath + "." : basePath;
60753
+ const lockPath = lockBasePath + "lock";
60661
60754
  rawscript.lock = "!inline " + lockPath.replaceAll(separator, "/");
60662
60755
  r.push({ path: lockPath, content: lock, language, is_lock: true });
60663
60756
  }
@@ -60692,6 +60785,43 @@ function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs,
60692
60785
  }
60693
60786
  });
60694
60787
  }
60788
+ function extractCurrentMapping(modules, mapping = {}, failureModule, preprocessorModule) {
60789
+ if (failureModule) {
60790
+ extractCurrentMapping([failureModule], mapping);
60791
+ }
60792
+ if (preprocessorModule) {
60793
+ extractCurrentMapping([preprocessorModule], mapping);
60794
+ }
60795
+ if (!modules || !Array.isArray(modules)) {
60796
+ return mapping;
60797
+ }
60798
+ modules.forEach((m) => {
60799
+ if (!m?.value?.type) {
60800
+ return;
60801
+ }
60802
+ if (m.value.type === "rawscript") {
60803
+ if (m.value.content && m.value.content.startsWith("!inline ")) {
60804
+ mapping[m.id] = m.value.content.trim().split(" ")[1];
60805
+ }
60806
+ } else if (m.value.type === "forloopflow" || m.value.type === "whileloopflow") {
60807
+ extractCurrentMapping(m.value.modules, mapping);
60808
+ } else if (m.value.type === "branchall") {
60809
+ m.value.branches.forEach((b) => extractCurrentMapping(b.modules, mapping));
60810
+ } else if (m.value.type === "branchone") {
60811
+ m.value.branches.forEach((b) => extractCurrentMapping(b.modules, mapping));
60812
+ extractCurrentMapping(m.value.default, mapping);
60813
+ } else if (m.value.type === "aiagent") {
60814
+ (m.value.tools ?? []).forEach((tool) => {
60815
+ const toolValue = tool.value;
60816
+ if (!toolValue || toolValue.tool_type !== "flowmodule" || toolValue.type !== "rawscript" || !toolValue.content || !toolValue.content.startsWith("!inline ")) {
60817
+ return;
60818
+ }
60819
+ mapping[tool.id] = toolValue.content.trim().split(" ")[1];
60820
+ });
60821
+ }
60822
+ });
60823
+ return mapping;
60824
+ }
60695
60825
  var init_extractor = __esm(() => {
60696
60826
  init_path_assigner();
60697
60827
  });
@@ -60989,6 +61119,7 @@ async function generateFlowLockInternal(folder, dryRun, workspace, opts, justUpd
60989
61119
  info(`Recomputing locks of ${changedScripts.join(", ")} in ${folder}`);
60990
61120
  }
60991
61121
  const fileReader = async (path8) => await readFile7(folder + SEP7 + path8, "utf-8");
61122
+ const currentMapping = extractCurrentMapping(flowValue.value.modules, {}, flowValue.value.failure_module, flowValue.value.preprocessor_module);
60992
61123
  const locksToRemove = tree && !legacyBehaviour ? Object.keys(hashes).filter((k) => {
60993
61124
  if (k === TOP_HASH)
60994
61125
  return false;
@@ -61007,12 +61138,12 @@ async function generateFlowLockInternal(folder, dryRun, workspace, opts, justUpd
61007
61138
  const lockAssigner = newPathAssigner(opts.defaultTs ?? "bun", {
61008
61139
  skipInlineScriptSuffix: getNonDottedPaths()
61009
61140
  });
61010
- const inlineScripts = extractInlineScripts(flowValue.value.modules, {}, SEP7, opts.defaultTs, lockAssigner);
61141
+ const inlineScripts = extractInlineScripts(flowValue.value.modules, currentMapping, SEP7, opts.defaultTs, lockAssigner);
61011
61142
  if (flowValue.value.failure_module) {
61012
- inlineScripts.push(...extractInlineScripts([flowValue.value.failure_module], {}, SEP7, opts.defaultTs, lockAssigner));
61143
+ inlineScripts.push(...extractInlineScripts([flowValue.value.failure_module], currentMapping, SEP7, opts.defaultTs, lockAssigner));
61013
61144
  }
61014
61145
  if (flowValue.value.preprocessor_module) {
61015
- inlineScripts.push(...extractInlineScripts([flowValue.value.preprocessor_module], {}, SEP7, opts.defaultTs, lockAssigner));
61146
+ inlineScripts.push(...extractInlineScripts([flowValue.value.preprocessor_module], currentMapping, SEP7, opts.defaultTs, lockAssigner));
61016
61147
  }
61017
61148
  inlineScripts.forEach((s) => {
61018
61149
  writeIfChanged(process.cwd() + SEP7 + folder + SEP7 + s.path, s.content);
@@ -63059,16 +63190,60 @@ ${folderList}
63059
63190
  });
63060
63191
  break;
63061
63192
  case "flow":
63062
- await deleteFlowByPath({
63063
- workspace: workspaceId,
63064
- path: removeSuffix(target, getDeleteSuffix("flow", "json"))
63065
- });
63193
+ if (isFlowFolderMetadataFile(target)) {
63194
+ await deleteFlowByPath({
63195
+ workspace: workspaceId,
63196
+ path: removeSuffix(target, getDeleteSuffix("flow", "json"))
63197
+ });
63198
+ } else {
63199
+ const flowFolder = extractFolderPath(target, "flow");
63200
+ let flowFolderExists = false;
63201
+ if (flowFolder) {
63202
+ try {
63203
+ await stat6(flowFolder);
63204
+ flowFolderExists = true;
63205
+ } catch {}
63206
+ }
63207
+ if (flowFolderExists) {
63208
+ await pushObj(workspaceId, target, undefined, undefined, opts.plainSecrets ?? false, alreadySynced, opts.message);
63209
+ } else {
63210
+ const remotePath = extractResourceName(target, "flow");
63211
+ if (remotePath) {
63212
+ await deleteFlowByPath({
63213
+ workspace: workspaceId,
63214
+ path: remotePath
63215
+ });
63216
+ }
63217
+ }
63218
+ }
63066
63219
  break;
63067
63220
  case "app":
63068
- await deleteApp({
63069
- workspace: workspaceId,
63070
- path: removeSuffix(target, getDeleteSuffix("app", "json"))
63071
- });
63221
+ if (isAppFolderMetadataFile(target)) {
63222
+ await deleteApp({
63223
+ workspace: workspaceId,
63224
+ path: removeSuffix(target, getDeleteSuffix("app", "json"))
63225
+ });
63226
+ } else {
63227
+ const appFolder = extractFolderPath(target, "app");
63228
+ let appFolderExists = false;
63229
+ if (appFolder) {
63230
+ try {
63231
+ await stat6(appFolder);
63232
+ appFolderExists = true;
63233
+ } catch {}
63234
+ }
63235
+ if (appFolderExists) {
63236
+ await pushObj(workspaceId, target, undefined, undefined, opts.plainSecrets ?? false, alreadySynced, opts.message);
63237
+ } else {
63238
+ const remotePath = extractResourceName(target, "app");
63239
+ if (remotePath) {
63240
+ await deleteApp({
63241
+ workspace: workspaceId,
63242
+ path: remotePath
63243
+ });
63244
+ }
63245
+ }
63246
+ }
63072
63247
  break;
63073
63248
  case "raw_app":
63074
63249
  if (isRawAppFolderMetadataFile(target)) {
@@ -69971,9 +70146,15 @@ async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced
69971
70146
  const typeEnding = getTypeStrFromPath(p);
69972
70147
  if (typeEnding === "app") {
69973
70148
  const appName = extractResourceName(p, "app");
70149
+ if (!appName) {
70150
+ throw new Error(`Could not extract app name from path: ${p}`);
70151
+ }
69974
70152
  await pushApp(workspace, appName, buildFolderPath(appName, "app"), message);
69975
70153
  } else if (typeEnding === "raw_app") {
69976
70154
  const rawAppName = extractResourceName(p, "raw_app");
70155
+ if (!rawAppName) {
70156
+ throw new Error(`Could not extract raw app name from path: ${p}`);
70157
+ }
69977
70158
  await pushRawApp(workspace, rawAppName, buildFolderPath(rawAppName, "raw_app"), message);
69978
70159
  } else if (typeEnding === "folder") {
69979
70160
  await pushFolder(workspace, p, befObj, newObj);
@@ -69981,6 +70162,9 @@ async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced
69981
70162
  await pushVariable(workspace, p, befObj, newObj, plainSecrets);
69982
70163
  } else if (typeEnding === "flow") {
69983
70164
  const flowName = extractResourceName(p, "flow");
70165
+ if (!flowName) {
70166
+ throw new Error(`Could not extract flow name from path: ${p}`);
70167
+ }
69984
70168
  await pushFlow(workspace, flowName, buildFolderPath(flowName, "flow"), message);
69985
70169
  } else if (typeEnding === "resource") {
69986
70170
  if (!alreadySynced3.includes(p)) {
@@ -70596,11 +70780,12 @@ async function generateLocks(opts, folder) {
70596
70780
  }
70597
70781
  }
70598
70782
  }
70599
- function bootstrap2(opts, flowPath) {
70783
+ async function bootstrap2(opts, flowPath) {
70600
70784
  if (!validatePath(flowPath)) {
70601
70785
  return;
70602
70786
  }
70603
- const flowDirFullPath = `${flowPath}.flow`;
70787
+ await loadNonDottedPathsSetting();
70788
+ const flowDirFullPath = buildFolderPath(flowPath, "flow");
70604
70789
  mkdirSync4(flowDirFullPath, { recursive: false });
70605
70790
  const newFlowDefinition = defaultFlowDefinition();
70606
70791
  if (opts.summary !== undefined) {
@@ -70610,7 +70795,8 @@ function bootstrap2(opts, flowPath) {
70610
70795
  newFlowDefinition.description = opts.description;
70611
70796
  }
70612
70797
  const newFlowDefinitionYaml = import_yaml36.stringify(newFlowDefinition);
70613
- const flowYamlPath = `${flowDirFullPath}/flow.yaml`;
70798
+ const metadataFile = getMetadataFileName("flow", "yaml");
70799
+ const flowYamlPath = `${flowDirFullPath}/${metadataFile}`;
70614
70800
  writeFileSync5(flowYamlPath, newFlowDefinitionYaml, { flag: "wx", encoding: "utf-8" });
70615
70801
  }
70616
70802
  var import_yaml36, alreadySynced3, command21, flow_default;
@@ -70621,6 +70807,7 @@ var init_flow = __esm(async () => {
70621
70807
  init_log();
70622
70808
  init_yaml();
70623
70809
  init_services_gen();
70810
+ init_resource_folders();
70624
70811
  await __promiseAll([
70625
70812
  init_types(),
70626
70813
  init_confirm(),
@@ -73549,7 +73736,6 @@ await __promiseAll([
73549
73736
  init_workspace(),
73550
73737
  init_resource_type()
73551
73738
  ]);
73552
- var import_yaml40 = __toESM(require_dist(), 1);
73553
73739
  import { stat as stat16, writeFile as writeFile19, rm as rm4, mkdir as mkdir9 } from "node:fs/promises";
73554
73740
 
73555
73741
  // src/guidance/skills.ts
@@ -77904,7 +78090,7 @@ Reference a specific resource using \`$res:\` prefix:
77904
78090
 
77905
78091
  ## OpenFlow Schema
77906
78092
 
77907
- {"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":"The flow will be run with the permissions of the user with this email."}},"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"},"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"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note (e.g., \\"yellow\\", \\"#ffff00\\")"},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor"}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."}},"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_use":{"type":"boolean","description":"If true, this step's result is deleted after use to save memory"},"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"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside loops, use 'flow_input.iter.value' for the current iteration value","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","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"}},"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"]},"MemoryAuto":{"type":"object","description":"Automatic context management","properties":{"kind":{"type":"string","enum":["auto"]},"context_length":{"type":"integer","description":"Maximum number of messages to retain in context"},"memory_id":{"type":"string","description":"Identifier for persistent memory across agent invocations"}},"required":["kind"]},"MemoryMessage":{"type":"object","description":"A single message in conversation history","properties":{"role":{"type":"string","enum":["user","assistant","system"]},"content":{"type":"string"}},"required":["role","content"]},"MemoryManual":{"type":"object","description":"Explicit message history","properties":{"kind":{"type":"string","enum":["manual"]},"messages":{"type":"array","items":{"$ref":"#/components/schemas/MemoryMessage"}}},"required":["kind","messages"]},"MemoryConfig":{"description":"Conversation memory configuration","oneOf":[{"$ref":"#/components/schemas/MemoryOff"},{"$ref":"#/components/schemas/MemoryAuto"},{"$ref":"#/components/schemas/MemoryManual"}],"discriminator":{"propertyName":"kind","mapping":{"off":"#/components/schemas/MemoryOff","auto":"#/components/schemas/MemoryAuto","manual":"#/components/schemas/MemoryManual"}}},"StaticMemoryTransform":{"type":"object","description":"Static memory configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/MemoryConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"MemoryTransform":{"description":"Memory configuration - can be static (MemoryConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticMemoryTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticMemoryTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"FlowModuleValue":{"description":"The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type","oneOf":[{"$ref":"#/components/schemas/RawScript"},{"$ref":"#/components/schemas/PathScript"},{"$ref":"#/components/schemas/PathFlow"},{"$ref":"#/components/schemas/ForloopFlow"},{"$ref":"#/components/schemas/WhileloopFlow"},{"$ref":"#/components/schemas/BranchOne"},{"$ref":"#/components/schemas/BranchAll"},{"$ref":"#/components/schemas/Identity"},{"$ref":"#/components/schemas/AiAgent"}],"discriminator":{"propertyName":"type","mapping":{"rawscript":"#/components/schemas/RawScript","script":"#/components/schemas/PathScript","flow":"#/components/schemas/PathFlow","forloopflow":"#/components/schemas/ForloopFlow","whileloopflow":"#/components/schemas/WhileloopFlow","branchone":"#/components/schemas/BranchOne","branchall":"#/components/schemas/BranchAll","identity":"#/components/schemas/Identity","aiagent":"#/components/schemas/AiAgent"}}},"RawScript":{"type":"object","description":"Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"content":{"type":"string","description":"The script source code. Should export a 'main' function"},"language":{"type":"string","description":"Programming language for this script","enum":["deno","bun","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","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"]},"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 while a condition is true. The loop checks the condition after each iteration. Use stop_after_if on modules to control loop termination","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration. Use stop_after_if to control when the loop ends","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":"Short description of what this tool does (shown to the AI)"},"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 flow.input syntax."},"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, tool_call, tool_call_arguments, tool_execution, tool_result\\n"},"memory":{"$ref":"#/components/schemas/MemoryTransform"},"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_images":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of image references for vision-capable models.\\nFormat: Array<{ bucket: string, key: string }> - S3 object references\\nExample: [{ bucket: 'my-bucket', key: 'images/photo.jpg' }]\\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"}},"required":["provider","user_message","output_type"]},"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"]},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["tools","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"]}}`,
78093
+ {"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":"The flow will be run with the permissions of the user with this email."}},"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"},"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"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note (e.g., \\"yellow\\", \\"#ffff00\\")"},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor"}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."}},"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_use":{"type":"boolean","description":"If true, this step's result is deleted after use to save memory"},"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"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside loops, use 'flow_input.iter.value' for the current iteration value","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","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"}},"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"]},"MemoryAuto":{"type":"object","description":"Automatic context management","properties":{"kind":{"type":"string","enum":["auto"]},"context_length":{"type":"integer","description":"Maximum number of messages to retain in context"},"memory_id":{"type":"string","description":"Identifier for persistent memory across agent invocations"}},"required":["kind"]},"MemoryMessage":{"type":"object","description":"A single message in conversation history","properties":{"role":{"type":"string","enum":["user","assistant","system"]},"content":{"type":"string"}},"required":["role","content"]},"MemoryManual":{"type":"object","description":"Explicit message history","properties":{"kind":{"type":"string","enum":["manual"]},"messages":{"type":"array","items":{"$ref":"#/components/schemas/MemoryMessage"}}},"required":["kind","messages"]},"MemoryConfig":{"description":"Conversation memory configuration","oneOf":[{"$ref":"#/components/schemas/MemoryOff"},{"$ref":"#/components/schemas/MemoryAuto"},{"$ref":"#/components/schemas/MemoryManual"}],"discriminator":{"propertyName":"kind","mapping":{"off":"#/components/schemas/MemoryOff","auto":"#/components/schemas/MemoryAuto","manual":"#/components/schemas/MemoryManual"}}},"StaticMemoryTransform":{"type":"object","description":"Static memory configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/MemoryConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"MemoryTransform":{"description":"Memory configuration - can be static (MemoryConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticMemoryTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticMemoryTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"FlowModuleValue":{"description":"The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type","oneOf":[{"$ref":"#/components/schemas/RawScript"},{"$ref":"#/components/schemas/PathScript"},{"$ref":"#/components/schemas/PathFlow"},{"$ref":"#/components/schemas/ForloopFlow"},{"$ref":"#/components/schemas/WhileloopFlow"},{"$ref":"#/components/schemas/BranchOne"},{"$ref":"#/components/schemas/BranchAll"},{"$ref":"#/components/schemas/Identity"},{"$ref":"#/components/schemas/AiAgent"}],"discriminator":{"propertyName":"type","mapping":{"rawscript":"#/components/schemas/RawScript","script":"#/components/schemas/PathScript","flow":"#/components/schemas/PathFlow","forloopflow":"#/components/schemas/ForloopFlow","whileloopflow":"#/components/schemas/WhileloopFlow","branchone":"#/components/schemas/BranchOne","branchall":"#/components/schemas/BranchAll","identity":"#/components/schemas/Identity","aiagent":"#/components/schemas/AiAgent"}}},"RawScript":{"type":"object","description":"Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"content":{"type":"string","description":"The script source code. Should export a 'main' function"},"language":{"type":"string","description":"Programming language for this script","enum":["deno","bun","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","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"]},"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 while a condition is true. The loop checks the condition after each iteration. Use stop_after_if on modules to control loop termination","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration. Use stop_after_if to control when the loop ends","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":"Short description of what this tool does (shown to the AI)"},"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 flow.input syntax."},"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, tool_call, tool_call_arguments, tool_execution, tool_result\\n"},"memory":{"$ref":"#/components/schemas/MemoryTransform"},"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"},"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"}},"required":["provider","user_message","output_type"]},"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"]},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["tools","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"]}}`,
77908
78094
  "raw-app": `---
77909
78095
  name: raw-app
77910
78096
  description: MUST use when creating raw apps.
@@ -78544,6 +78730,13 @@ app related commands
78544
78730
  - \`--dry-run\` - Perform a dry run without making changes
78545
78731
  - \`--default-ts <runtime:string>\` - Default TypeScript runtime (bun or deno)
78546
78732
 
78733
+ ### config
78734
+
78735
+ Show all available wmill.yaml configuration options
78736
+
78737
+ **Options:**
78738
+ - \`--json\` - Output as JSON for programmatic consumption
78739
+
78547
78740
  ### dependencies
78548
78741
 
78549
78742
  workspace dependencies related commands
@@ -79939,6 +80132,406 @@ ${skillsReference}
79939
80132
  `;
79940
80133
  }
79941
80134
 
80135
+ // src/commands/init/template.ts
80136
+ var NON_SCHEMA_KEYS = new Set([
80137
+ "name",
80138
+ "default",
80139
+ "section",
80140
+ "sectionNote",
80141
+ "commented",
80142
+ "templateValue",
80143
+ "example",
80144
+ "inlineComment",
80145
+ "groupNote"
80146
+ ]);
80147
+ var SPECIFIC_ITEMS_SCHEMA = {
80148
+ type: "object",
80149
+ description: "Sync only specific items",
80150
+ properties: {
80151
+ variables: { type: "array", items: { type: "string" }, description: "Specific variable paths to sync" },
80152
+ resources: { type: "array", items: { type: "string" }, description: "Specific resource paths to sync" },
80153
+ triggers: { type: "array", items: { type: "string" }, description: "Specific trigger paths to sync" },
80154
+ folders: { type: "array", items: { type: "string" }, description: "Specific folder paths to sync" },
80155
+ settings: { type: "boolean", description: "Whether to sync settings" }
80156
+ },
80157
+ additionalProperties: false
80158
+ };
80159
+ var BRANCH_CONFIG_SCHEMA = {
80160
+ type: "object",
80161
+ properties: {
80162
+ baseUrl: { type: "string", description: "Windmill instance URL for this branch" },
80163
+ workspaceId: { type: "string", description: "Workspace ID to sync with for this branch" },
80164
+ overrides: { type: "object", description: "Override any top-level sync option for this branch" },
80165
+ promotionOverrides: { type: "object", description: "Overrides applied when using --promotion flag" },
80166
+ specificItems: SPECIFIC_ITEMS_SCHEMA
80167
+ },
80168
+ additionalProperties: false
80169
+ };
80170
+ var CONFIG_REFERENCE = [
80171
+ { name: "defaultTs", type: "string", enum: ["bun", "deno"], default: "bun", description: "Default TypeScript runtime for new scripts" },
80172
+ {
80173
+ name: "includes",
80174
+ type: "array",
80175
+ items: { type: "string" },
80176
+ default: '["f/**"]',
80177
+ description: "Glob patterns for files to include in sync",
80178
+ templateValue: `
80179
+ - "f/**"`
80180
+ },
80181
+ {
80182
+ name: "extraIncludes",
80183
+ type: "array",
80184
+ items: { type: "string" },
80185
+ default: "[]",
80186
+ description: "Additional glob patterns merged with includes (useful in branch overrides)",
80187
+ commented: true
80188
+ },
80189
+ { name: "excludes", type: "array", items: { type: "string" }, default: "[]", description: "Glob patterns for files to exclude from sync" },
80190
+ {
80191
+ name: "skipVariables",
80192
+ type: "boolean",
80193
+ default: "false",
80194
+ description: "Skip syncing variables",
80195
+ section: "What to sync",
80196
+ sectionNote: '"skip" options default to false (synced), "include" options default to false (not synced)'
80197
+ },
80198
+ { name: "skipResources", type: "boolean", default: "false", description: "Skip syncing resources" },
80199
+ { name: "skipResourceTypes", type: "boolean", default: "false", description: "Skip syncing resource types" },
80200
+ {
80201
+ name: "skipSecrets",
80202
+ type: "boolean",
80203
+ default: "true",
80204
+ description: "Skip syncing secrets (true by default for security)",
80205
+ inlineComment: "true by default — secrets are not synced for security"
80206
+ },
80207
+ { name: "skipScripts", type: "boolean", default: "false", description: "Skip syncing scripts" },
80208
+ { name: "skipFlows", type: "boolean", default: "false", description: "Skip syncing flows" },
80209
+ { name: "skipApps", type: "boolean", default: "false", description: "Skip syncing apps" },
80210
+ { name: "skipFolders", type: "boolean", default: "false", description: "Skip syncing folders" },
80211
+ { name: "skipWorkspaceDependencies", type: "boolean", default: "false", description: "Skip syncing workspace dependencies" },
80212
+ {
80213
+ name: "includeSchedules",
80214
+ type: "boolean",
80215
+ default: "false",
80216
+ description: "Include schedules in sync",
80217
+ commented: true,
80218
+ templateValue: "true",
80219
+ groupNote: "Uncomment to include these (excluded by default):"
80220
+ },
80221
+ {
80222
+ name: "includeTriggers",
80223
+ type: "boolean",
80224
+ default: "false",
80225
+ description: "Include triggers (http, websocket, kafka, etc.) in sync",
80226
+ commented: true,
80227
+ templateValue: "true"
80228
+ },
80229
+ {
80230
+ name: "includeUsers",
80231
+ type: "boolean",
80232
+ default: "false",
80233
+ description: "Include workspace users in sync",
80234
+ commented: true,
80235
+ templateValue: "true"
80236
+ },
80237
+ {
80238
+ name: "includeGroups",
80239
+ type: "boolean",
80240
+ default: "false",
80241
+ description: "Include workspace groups in sync",
80242
+ commented: true,
80243
+ templateValue: "true"
80244
+ },
80245
+ {
80246
+ name: "includeSettings",
80247
+ type: "boolean",
80248
+ default: "false",
80249
+ description: "Include workspace settings in sync",
80250
+ commented: true,
80251
+ templateValue: "true"
80252
+ },
80253
+ {
80254
+ name: "includeKey",
80255
+ type: "boolean",
80256
+ default: "false",
80257
+ description: "Include encryption key in sync",
80258
+ commented: true,
80259
+ templateValue: "true"
80260
+ },
80261
+ {
80262
+ name: "parallel",
80263
+ type: "integer",
80264
+ default: "(unset)",
80265
+ description: "Number of parallel operations during sync",
80266
+ section: "Sync behavior",
80267
+ commented: true,
80268
+ templateValue: "4"
80269
+ },
80270
+ {
80271
+ name: "locksRequired",
80272
+ type: "boolean",
80273
+ default: "false",
80274
+ description: "Require lock files for all scripts",
80275
+ commented: true,
80276
+ templateValue: "true"
80277
+ },
80278
+ {
80279
+ name: "lint",
80280
+ type: "boolean",
80281
+ default: "false",
80282
+ description: "Run linting before push",
80283
+ commented: true,
80284
+ templateValue: "true"
80285
+ },
80286
+ {
80287
+ name: "plainSecrets",
80288
+ type: "boolean",
80289
+ default: "false",
80290
+ description: "Handle secrets as plain text (not recommended)",
80291
+ commented: true
80292
+ },
80293
+ {
80294
+ name: "message",
80295
+ type: "string",
80296
+ default: "(unset)",
80297
+ description: "Default commit message for sync operations",
80298
+ commented: true,
80299
+ templateValue: '"my commit message"'
80300
+ },
80301
+ {
80302
+ name: "promotion",
80303
+ type: "string",
80304
+ default: "(unset)",
80305
+ description: "Branch name to use promotion overrides from during sync",
80306
+ commented: true,
80307
+ templateValue: "staging"
80308
+ },
80309
+ {
80310
+ name: "skipBranchValidation",
80311
+ type: "boolean",
80312
+ default: "false",
80313
+ description: "Skip validation that current git branch matches a configured branch",
80314
+ commented: true
80315
+ },
80316
+ { name: "nonDottedPaths", type: "boolean", default: "true", description: "Use __flow/__app/__raw_app suffixes instead of .flow/.app/.raw_app" },
80317
+ {
80318
+ name: "codebases",
80319
+ type: "array",
80320
+ default: "[]",
80321
+ description: "Codebase bundling configurations for shared libraries",
80322
+ items: {
80323
+ type: "object",
80324
+ properties: {
80325
+ relative_path: { type: "string", description: "Path to the codebase directory" },
80326
+ includes: { type: "array", items: { type: "string" }, description: "Glob patterns for files to include in bundle" },
80327
+ excludes: { type: "array", items: { type: "string" }, description: "Glob patterns for files to exclude from bundle" },
80328
+ format: { type: "string", enum: ["cjs", "esm"], description: "Bundle output format" },
80329
+ external: { type: "array", items: { type: "string" }, description: "Dependencies to leave unbundled (externals)" },
80330
+ assets: { type: "array", items: { type: "object", properties: { from: { type: "string" }, to: { type: "string" } }, required: ["from", "to"] }, description: "Static files to copy into the bundle" },
80331
+ customBundler: { type: "string", description: "Path to a custom bundler script (replaces esbuild)" },
80332
+ inject: { type: "array", items: { type: "string" }, description: "Files to inject into every entry point" },
80333
+ define: { type: "object", additionalProperties: { type: "string" }, description: "Compile-time constant definitions" },
80334
+ banner: { type: "object", additionalProperties: { type: "string" }, description: "Text to prepend to output files by type" },
80335
+ loader: { type: "object", additionalProperties: { type: "string" }, description: "esbuild loader overrides by extension" }
80336
+ },
80337
+ required: ["relative_path"],
80338
+ additionalProperties: false
80339
+ },
80340
+ section: "Codebase bundling (shared libraries)",
80341
+ sectionNote: `Bundle TypeScript/JavaScript codebases that scripts import from.
80342
+ Each entry is bundled and uploaded so scripts can import shared code.`,
80343
+ example: [
80344
+ "# codebases:",
80345
+ "# - relative_path: ./shared # path to the codebase",
80346
+ '# includes: ["**/*.ts"] # files to include in bundle',
80347
+ '# excludes: ["node_modules/**"] # files to exclude',
80348
+ '# format: esm # bundle format: "cjs" or "esm"',
80349
+ '# external: ["pg", "axios"] # dependencies to leave unbundled',
80350
+ "# assets: # static files to copy into bundle",
80351
+ "# - from: ./static",
80352
+ "# to: ./dist",
80353
+ "# # customBundler: ./build.ts # custom bundler script (replaces esbuild)",
80354
+ '# # inject: ["./polyfills.ts"] # files to inject into every entry point',
80355
+ "# # define: # compile-time constants",
80356
+ `# # API_URL: '"https://api.example.com"'`,
80357
+ "# # banner: # text prepended to output files",
80358
+ '# # js: "/* bundled by windmill */"',
80359
+ "# # loader: # esbuild loader overrides",
80360
+ '# # ".png": "dataurl"'
80361
+ ].join(`
80362
+ `)
80363
+ },
80364
+ {
80365
+ name: "gitBranches",
80366
+ type: "object",
80367
+ default: "{}",
80368
+ description: "Map git branches to workspaces and per-branch sync overrides",
80369
+ properties: { commonSpecificItems: SPECIFIC_ITEMS_SCHEMA },
80370
+ additionalProperties: BRANCH_CONFIG_SCHEMA,
80371
+ section: "Git branch / environment bindings",
80372
+ sectionNote: `Map git branches to Windmill workspaces and override settings per branch.
80373
+ Use "environments" as an alias if you prefer environment-based terminology.`,
80374
+ templateValue: `
80375
+ {{BRANCH}}:
80376
+ overrides: {}`,
80377
+ example: [
80378
+ "{{BASEURL_LINE}}",
80379
+ "{{WORKSPACE_ID_LINE}}",
80380
+ " # promotionOverrides: # overrides applied during --promotion",
80381
+ " # skipSecrets: false",
80382
+ " # specificItems: # only sync these specific items",
80383
+ ' # variables: ["f/my_folder/my_var"]',
80384
+ ' # resources: ["f/my_folder/my_res"]',
80385
+ ' # triggers: ["f/my_folder/my_trigger"]',
80386
+ ' # folders: ["my_folder"]',
80387
+ " # settings: true",
80388
+ "",
80389
+ " # Example: staging branch bound to a different workspace",
80390
+ " # staging:",
80391
+ " # baseUrl: https://staging.windmill.dev",
80392
+ " # workspaceId: staging-workspace",
80393
+ " # overrides:",
80394
+ " # skipSecrets: false",
80395
+ " # includeSchedules: true",
80396
+ "",
80397
+ " # Items shared across ALL branches",
80398
+ " # commonSpecificItems:",
80399
+ ' # variables: ["f/shared/api_key"]',
80400
+ ' # resources: ["f/shared/db_conn"]',
80401
+ ' # folders: ["shared"]'
80402
+ ].join(`
80403
+ `)
80404
+ },
80405
+ {
80406
+ name: "environments",
80407
+ type: "object",
80408
+ default: "{}",
80409
+ description: "Alias for gitBranches — use if you prefer environment-based terminology",
80410
+ properties: { commonSpecificItems: SPECIFIC_ITEMS_SCHEMA },
80411
+ additionalProperties: BRANCH_CONFIG_SCHEMA,
80412
+ commented: true
80413
+ }
80414
+ ];
80415
+ function yamlKey(s) {
80416
+ if (/^[a-zA-Z0-9_/.@-]+$/.test(s) && !/^(true|false|yes|no|on|off|null|~)$/i.test(s) && !/^\d+(\.\d+)?$/.test(s)) {
80417
+ return s;
80418
+ }
80419
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
80420
+ }
80421
+ function generateCommentedTemplate(branchName, binding) {
80422
+ const branch = yamlKey(branchName ?? "main");
80423
+ const lines = [
80424
+ "# yaml-language-server: $schema=wmill.schema.json",
80425
+ "# wmill.yaml — Windmill CLI configuration",
80426
+ '# Full reference: run "wmill config"',
80427
+ ""
80428
+ ];
80429
+ for (const opt of CONFIG_REFERENCE) {
80430
+ if (opt.section) {
80431
+ const ruler = "-".repeat(Math.max(0, 65 - opt.section.length));
80432
+ lines.push(`# --- ${opt.section} ${ruler}`);
80433
+ if (opt.sectionNote) {
80434
+ for (const noteLine of opt.sectionNote.split(`
80435
+ `)) {
80436
+ lines.push(`# ${noteLine}`);
80437
+ }
80438
+ }
80439
+ lines.push("");
80440
+ }
80441
+ if (opt.groupNote) {
80442
+ lines.push(`# ${opt.groupNote}`);
80443
+ }
80444
+ const value = opt.templateValue ?? opt.default;
80445
+ const resolvedValue = value.replace("{{BRANCH}}", branch);
80446
+ if (opt.commented) {
80447
+ lines.push(`# ${opt.description}`);
80448
+ lines.push(`# ${opt.name}: ${resolvedValue}`);
80449
+ } else {
80450
+ lines.push(`# ${opt.description}`);
80451
+ if (opt.inlineComment) {
80452
+ const base = `${opt.name}: ${resolvedValue}`;
80453
+ const pad = " ".repeat(Math.max(1, 32 - base.length));
80454
+ lines.push(`${base}${pad}# ${opt.inlineComment}`);
80455
+ } else {
80456
+ lines.push(`${opt.name}: ${resolvedValue}`);
80457
+ }
80458
+ }
80459
+ if (opt.example) {
80460
+ let resolvedExample = opt.example.replace(/\{\{BRANCH\}\}/g, branch);
80461
+ if (binding) {
80462
+ resolvedExample = resolvedExample.replace("{{BASEURL_LINE}}", ` baseUrl: ${binding.baseUrl}`).replace("{{WORKSPACE_ID_LINE}}", ` workspaceId: ${binding.workspaceId}`);
80463
+ } else {
80464
+ resolvedExample = resolvedExample.replace("{{BASEURL_LINE}}", " # baseUrl: https://app.windmill.dev # Windmill instance URL for this branch").replace("{{WORKSPACE_ID_LINE}}", " # workspaceId: my-workspace # workspace to sync with");
80465
+ }
80466
+ for (const exLine of resolvedExample.split(`
80467
+ `)) {
80468
+ lines.push(exLine);
80469
+ }
80470
+ }
80471
+ lines.push("");
80472
+ }
80473
+ return lines.join(`
80474
+ `);
80475
+ }
80476
+ function expandSchema(prefix, schema, rows) {
80477
+ if (schema.properties) {
80478
+ for (const [key, prop] of Object.entries(schema.properties)) {
80479
+ const name = prefix ? `${prefix}.${key}` : key;
80480
+ rows.push({ name, description: prop.description ?? "", default: "" });
80481
+ if (prop.properties && prop.type === "object") {
80482
+ expandSchema(name, prop, rows);
80483
+ }
80484
+ }
80485
+ }
80486
+ }
80487
+ function formatConfigReference() {
80488
+ const nameWidth = 48;
80489
+ const descWidth = 70;
80490
+ const header = [
80491
+ "OPTION".padEnd(nameWidth),
80492
+ "DESCRIPTION".padEnd(descWidth),
80493
+ "DEFAULT"
80494
+ ].join(" ");
80495
+ const separator = "-".repeat(header.length + 10);
80496
+ const allRows = [];
80497
+ for (const opt of CONFIG_REFERENCE) {
80498
+ allRows.push({ name: opt.name, description: opt.description, default: opt.default });
80499
+ if (opt.items?.properties) {
80500
+ expandSchema(`${opt.name}[]`, opt.items, allRows);
80501
+ }
80502
+ if (opt.additionalProperties && typeof opt.additionalProperties === "object" && opt.additionalProperties.properties) {
80503
+ expandSchema(`${opt.name}.<branch>`, opt.additionalProperties, allRows);
80504
+ }
80505
+ if (opt.properties) {
80506
+ expandSchema(opt.name, opt, allRows);
80507
+ }
80508
+ }
80509
+ const rows = allRows.map((r) => [r.name.padEnd(nameWidth), r.description.padEnd(descWidth), r.default].join(" "));
80510
+ return [
80511
+ "wmill.yaml — Configuration Reference",
80512
+ "",
80513
+ "Full documentation: https://www.windmill.dev/docs/advanced/cli",
80514
+ "",
80515
+ separator,
80516
+ header,
80517
+ separator,
80518
+ ...rows,
80519
+ separator,
80520
+ "",
80521
+ 'Run "wmill init" to generate a wmill.yaml with commented examples.'
80522
+ ].join(`
80523
+ `);
80524
+ }
80525
+ function formatConfigReferenceJson() {
80526
+ const clean = CONFIG_REFERENCE.map((opt) => ({
80527
+ name: opt.name,
80528
+ type: opt.type,
80529
+ default: opt.default,
80530
+ description: opt.description
80531
+ }));
80532
+ return JSON.stringify(clean, null, 2);
80533
+ }
80534
+
79942
80535
  // src/commands/init/init.ts
79943
80536
  function formatSchemaForMarkdown(schemaYaml, schemaName, filePattern) {
79944
80537
  return `## ${schemaName} (\`${filePattern}\`)
@@ -79953,36 +80546,22 @@ async function initAction(opts) {
79953
80546
  if (await stat16("wmill.yaml").catch(() => null)) {
79954
80547
  error(colors.red("wmill.yaml already exists"));
79955
80548
  } else {
79956
- const { DEFAULT_SYNC_OPTIONS: DEFAULT_SYNC_OPTIONS2 } = await init_conf().then(() => exports_conf);
79957
- const initialConfig = { ...DEFAULT_SYNC_OPTIONS2 };
79958
80549
  const { isGitRepository: isGitRepository2, getCurrentGitBranch: getCurrentGitBranch2 } = await Promise.resolve().then(() => (init_git(), exports_git));
80550
+ let branchName;
80551
+ let binding;
79959
80552
  if (isGitRepository2()) {
79960
- const currentBranch = getCurrentGitBranch2();
79961
- if (currentBranch) {
79962
- initialConfig.gitBranches = {
79963
- [currentBranch]: { overrides: {} }
79964
- };
79965
- } else {
79966
- initialConfig.gitBranches = {};
79967
- }
79968
- } else {
79969
- initialConfig.gitBranches = {};
80553
+ branchName = getCurrentGitBranch2() ?? undefined;
79970
80554
  }
79971
- initialConfig.nonDottedPaths = true;
79972
- await writeFile19("wmill.yaml", import_yaml40.stringify(initialConfig), "utf-8");
79973
- info(colors.green("wmill.yaml created with default settings"));
79974
- await readLockfile();
79975
- if (isGitRepository2()) {
80555
+ if (isGitRepository2() && branchName) {
79976
80556
  const activeWorkspace = await getActiveWorkspaceOrFallback(opts);
79977
- const currentBranch = getCurrentGitBranch2();
79978
- if (activeWorkspace && currentBranch) {
80557
+ if (activeWorkspace) {
79979
80558
  const shouldBind = opts.bindProfile === true;
79980
80559
  const shouldPrompt = opts.bindProfile === undefined && !!process.stdin.isTTY && !opts.useDefault;
79981
- const shouldSkip = opts.bindProfile != true && (opts.useDefault || !!!process.stdin.isTTY);
80560
+ const shouldSkip = opts.bindProfile != true && (opts.useDefault || !process.stdin.isTTY);
79982
80561
  if (!shouldSkip) {
79983
80562
  if (shouldBind || shouldPrompt) {
79984
80563
  info(colors.yellow(`
79985
- Current Git branch: ${colors.bold(currentBranch)}`));
80564
+ Current Git branch: ${colors.bold(branchName)}`));
79986
80565
  info(colors.yellow(`Active workspace profile: ${colors.bold(activeWorkspace.name)}`));
79987
80566
  info(colors.yellow(` ${activeWorkspace.workspaceId} on ${activeWorkspace.remote}`));
79988
80567
  }
@@ -79990,22 +80569,21 @@ Current Git branch: ${colors.bold(currentBranch)}`));
79990
80569
  message: "Bind workspace profile to current Git branch?",
79991
80570
  default: true
79992
80571
  })) {
79993
- const currentConfig = await init_conf().then(() => exports_conf).then((m) => m.readConfigFile());
79994
- if (!currentConfig.gitBranches) {
79995
- currentConfig.gitBranches = {};
79996
- }
79997
- if (!currentConfig.gitBranches[currentBranch]) {
79998
- currentConfig.gitBranches[currentBranch] = { overrides: {} };
79999
- }
80000
- info(`binding branch ${currentBranch} to workspace ${activeWorkspace.name} on ${activeWorkspace.remote}`);
80001
- currentConfig.gitBranches[currentBranch].baseUrl = activeWorkspace.remote;
80002
- currentConfig.gitBranches[currentBranch].workspaceId = activeWorkspace.workspaceId;
80003
- await writeFile19("wmill.yaml", import_yaml40.stringify(currentConfig), "utf-8");
80004
- info(colors.green(`✓ Bound branch '${currentBranch}' to workspace '${activeWorkspace.name}'`));
80572
+ info(`binding branch ${branchName} to workspace ${activeWorkspace.name} on ${activeWorkspace.remote}`);
80573
+ binding = {
80574
+ baseUrl: activeWorkspace.remote,
80575
+ workspaceId: activeWorkspace.workspaceId
80576
+ };
80005
80577
  }
80006
80578
  }
80007
80579
  }
80008
80580
  }
80581
+ await writeFile19("wmill.yaml", generateCommentedTemplate(branchName, binding), "utf-8");
80582
+ info(colors.green("wmill.yaml created with default settings"));
80583
+ if (binding) {
80584
+ info(colors.green(`✓ Bound branch '${branchName}' to workspace`));
80585
+ }
80586
+ await readLockfile();
80009
80587
  if (!opts.useDefault) {
80010
80588
  try {
80011
80589
  const { requireLogin: requireLogin2 } = await init_auth().then(() => exports_auth);
@@ -80604,10 +81182,23 @@ ${await res.text()}`);
80604
81182
  var command30 = new Command().name("docs").description("Search Windmill documentation. Requires Enterprise Edition.").arguments("<query:string>").option("--json", "Output results as JSON.").action(docs);
80605
81183
  var docs_default = command30;
80606
81184
 
81185
+ // src/commands/config/config.ts
81186
+ init_mod3();
81187
+ init_log();
81188
+ async function configAction(opts) {
81189
+ if (opts.json) {
81190
+ console.log(formatConfigReferenceJson());
81191
+ } else {
81192
+ info(formatConfigReference());
81193
+ }
81194
+ }
81195
+ var command31 = new Command().name("config").description("Show all available wmill.yaml configuration options").option("--json", "Output as JSON for programmatic consumption").action(configAction);
81196
+ var config_default = command31;
81197
+
80607
81198
  // src/main.ts
80608
81199
  await init_context();
80609
- var VERSION = "1.665.0";
80610
- var command31 = new Command().name("wmill").action(() => info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`)).description("Windmill CLI").globalOption("--workspace <workspace:string>", "Specify the target workspace. This overrides the default workspace.").globalOption("--debug --verbose", "Show debug/verbose logs").globalOption("--show-diffs", "Show diff informations when syncing (may show sensitive informations)").globalOption("--token <token:string>", "Specify an API token. This will override any stored token.").globalOption("--base-url <baseUrl:string>", "Specify the base URL of the API. If used, --token and --workspace are required and no local remote/workspace already set will be used.").globalOption("--config-dir <configDir:string>", "Specify a custom config directory. Overrides WMILL_CONFIG_DIR environment variable and default ~/.config location.").env("HEADERS <headers:string>", `Specify headers to use for all requests. e.g: "HEADERS='h1: v1, h2: v2'"`).version(VERSION).versionOption(false).command("init", init_default).command("app", app_default).command("flow", flow_default).command("script", script_default).command("workspace", workspace_default).command("resource", resource_default).command("resource-type", resource_type_default).command("user", user_default).command("variable", variable_default).command("hub", hub_default).command("folder", folder_default).command("schedule", schedule_default).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("gitsync-settings", gitsync_settings_default).command("instance", instance_default).command("worker-groups", worker_groups_default).command("workers", workers_default).command("queues", queues_default).command("dependencies", dependencies_default).command("jobs", jobs_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("version --version", "Show version information").action(async (opts) => {
81200
+ var VERSION = "1.667.0";
81201
+ var command32 = new Command().name("wmill").action(() => info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`)).description("Windmill CLI").globalOption("--workspace <workspace:string>", "Specify the target workspace. This overrides the default workspace.").globalOption("--debug --verbose", "Show debug/verbose logs").globalOption("--show-diffs", "Show diff informations when syncing (may show sensitive informations)").globalOption("--token <token:string>", "Specify an API token. This will override any stored token.").globalOption("--base-url <baseUrl:string>", "Specify the base URL of the API. If used, --token and --workspace are required and no local remote/workspace already set will be used.").globalOption("--config-dir <configDir:string>", "Specify a custom config directory. Overrides WMILL_CONFIG_DIR environment variable and default ~/.config location.").env("HEADERS <headers:string>", `Specify headers to use for all requests. e.g: "HEADERS='h1: v1, h2: v2'"`).version(VERSION).versionOption(false).command("init", init_default).command("app", app_default).command("flow", flow_default).command("script", script_default).command("workspace", workspace_default).command("resource", resource_default).command("resource-type", resource_type_default).command("user", user_default).command("variable", variable_default).command("hub", hub_default).command("folder", folder_default).command("schedule", schedule_default).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("gitsync-settings", gitsync_settings_default).command("instance", instance_default).command("worker-groups", worker_groups_default).command("workers", workers_default).command("queues", queues_default).command("dependencies", dependencies_default).command("jobs", jobs_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("version --version", "Show version information").action(async (opts) => {
80611
81202
  console.log("CLI version: " + VERSION);
80612
81203
  try {
80613
81204
  const provider = new NpmProvider({ package: "windmill-cli" });
@@ -80637,20 +81228,20 @@ var command31 = new Command().name("wmill").action(() => info(`Welcome to Windmi
80637
81228
  error(e);
80638
81229
  info("Try running with sudo and otherwise check the result of the command: npm uninstall windmill-cli && npm install -g windmill-cli");
80639
81230
  })).command("completions", new Command().description("Generate shell completions.").command("bash", new Command().description("Generate bash completions.").action(() => {
80640
- process.stdout.write(generateShellCompletions(command31, "bash") + `
81231
+ process.stdout.write(generateShellCompletions(command32, "bash") + `
80641
81232
  `);
80642
81233
  })).command("zsh", new Command().description("Generate zsh completions.").action(() => {
80643
- process.stdout.write(generateShellCompletions(command31, "zsh") + `
81234
+ process.stdout.write(generateShellCompletions(command32, "zsh") + `
80644
81235
  `);
80645
81236
  })).command("fish", new Command().description("Generate fish completions.").action(() => {
80646
- process.stdout.write(generateShellCompletions(command31, "fish") + `
81237
+ process.stdout.write(generateShellCompletions(command32, "fish") + `
80647
81238
  `);
80648
81239
  })));
80649
81240
  async function main2() {
80650
81241
  try {
80651
81242
  const args = process.argv.slice(2);
80652
81243
  if (args.length === 0) {
80653
- command31.showHelp();
81244
+ command32.showHelp();
80654
81245
  }
80655
81246
  const LOG_LEVEL = args.includes("--verbose") || args.includes("--debug") ? "DEBUG" : "INFO";
80656
81247
  setShowDiffs(args.includes("--show-diffs"));
@@ -80660,7 +81251,7 @@ async function main2() {
80660
81251
  if (extraHeaders) {
80661
81252
  OpenAPI.HEADERS = extraHeaders;
80662
81253
  }
80663
- await command31.parse(args);
81254
+ await command32.parse(args);
80664
81255
  } catch (e) {
80665
81256
  if (e && typeof e === "object" && "name" in e && e.name === "ApiError") {
80666
81257
  console.log("Server failed. " + e.statusText + ": " + e.body);
@@ -80685,7 +81276,7 @@ if (isMain()) {
80685
81276
  process.stdin.destroy();
80686
81277
  });
80687
81278
  }
80688
- var main_default = command31;
81279
+ var main_default = command32;
80689
81280
  export {
80690
81281
  add as workspaceAdd,
80691
81282
  workspace_default as workspace,
@@ -80709,6 +81300,7 @@ export {
80709
81300
  docs_default as docs,
80710
81301
  dev_default2 as dev,
80711
81302
  main_default as default,
81303
+ config_default as config,
80712
81304
  app_default as app,
80713
81305
  WM_FORK_PREFIX,
80714
81306
  VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.665.0",
3
+ "version": "1.667.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",