windmill-cli 1.811.0 → 1.812.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 +859 -620
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -16766,7 +16766,7 @@ var init_OpenAPI = __esm(() => {
16766
16766
  PASSWORD: undefined,
16767
16767
  TOKEN: getEnv3("WM_TOKEN"),
16768
16768
  USERNAME: undefined,
16769
- VERSION: "1.811.0",
16769
+ VERSION: "1.812.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -17066,6 +17066,37 @@ var getAuditLog = (data) => {
17066
17066
  all_workspaces: data.allWorkspaces
17067
17067
  }
17068
17068
  });
17069
+ }, listTrash = (data) => {
17070
+ return request(OpenAPI, {
17071
+ method: "GET",
17072
+ url: "/w/{workspace}/trash/list",
17073
+ path: {
17074
+ workspace: data.workspace
17075
+ },
17076
+ query: {
17077
+ item_kind: data.itemKind,
17078
+ page: data.page,
17079
+ per_page: data.perPage
17080
+ }
17081
+ });
17082
+ }, getTrashItem = (data) => {
17083
+ return request(OpenAPI, {
17084
+ method: "GET",
17085
+ url: "/w/{workspace}/trash/get/{id}",
17086
+ path: {
17087
+ workspace: data.workspace,
17088
+ id: data.id
17089
+ }
17090
+ });
17091
+ }, restoreTrashItem = (data) => {
17092
+ return request(OpenAPI, {
17093
+ method: "POST",
17094
+ url: "/w/{workspace}/trash/restore/{id}",
17095
+ path: {
17096
+ workspace: data.workspace,
17097
+ id: data.id
17098
+ }
17099
+ });
17069
17100
  }, login = (data) => {
17070
17101
  return request(OpenAPI, {
17071
17102
  method: "POST",
@@ -19971,352 +20002,7 @@ var init_auth = __esm(async () => {
19971
20002
  });
19972
20003
 
19973
20004
  // src/core/constants.ts
19974
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.811.0";
19975
-
19976
- // src/utils/git.ts
19977
- import { execSync, spawnSync } from "node:child_process";
19978
- function getCurrentGitBranch() {
19979
- try {
19980
- const result = execSync("git rev-parse --abbrev-ref HEAD", {
19981
- encoding: "utf8",
19982
- stdio: "pipe"
19983
- });
19984
- const branch = result.trim();
19985
- return branch || null;
19986
- } catch (error) {
19987
- debug(`Failed to get Git branch: ${error}`);
19988
- return null;
19989
- }
19990
- }
19991
- function gitBranchExists(branchName) {
19992
- const r = spawnSync("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], { stdio: "pipe" });
19993
- return r.status === 0;
19994
- }
19995
- function renameCurrentGitBranch(newName) {
19996
- const r = spawnSync("git", ["branch", "-m", newName], {
19997
- encoding: "utf8",
19998
- stdio: "pipe"
19999
- });
20000
- if ((r.status ?? 1) !== 0) {
20001
- throw new Error(`git branch -m ${newName} failed (exit ${r.status}): ${r.stderr ?? ""}`);
20002
- }
20003
- }
20004
- function getOriginalBranchForWorkspaceForks(branchName) {
20005
- if (!branchName || !branchName.startsWith(WM_FORK_PREFIX)) {
20006
- return null;
20007
- }
20008
- const start = branchName.indexOf("/") + 1;
20009
- const end = branchName.lastIndexOf("/");
20010
- if (start < 0 || end < 0 || end - start <= 0) {
20011
- return null;
20012
- }
20013
- return branchName.slice(start, end);
20014
- }
20015
- function getWorkspaceIdForWorkspaceForkFromBranchName(branchName) {
20016
- if (!branchName.startsWith(WM_FORK_PREFIX)) {
20017
- return null;
20018
- }
20019
- const start = branchName.lastIndexOf("/") + 1;
20020
- if (start < 0) {
20021
- return null;
20022
- }
20023
- return `${WM_FORK_PREFIX}-${branchName.slice(start)}`;
20024
- }
20025
- function gitRecordedDatatableMigrationPaths() {
20026
- if (!isGitRepository()) {
20027
- return {
20028
- kind: "unknown",
20029
- reason: "this directory is not a git repository",
20030
- remedy: "Run the push from a git checkout of the synced repository"
20031
- };
20032
- }
20033
- const shallow = spawnSync("git", ["rev-parse", "--is-shallow-repository"], {
20034
- encoding: "utf8",
20035
- stdio: "pipe"
20036
- });
20037
- if ((shallow.stdout ?? "").trim() === "true") {
20038
- return {
20039
- kind: "unknown",
20040
- reason: "this is a shallow clone, so its history is truncated",
20041
- remedy: "Fetch the full history (for actions/checkout, fetch-depth: 0)"
20042
- };
20043
- }
20044
- const sparse = spawnSync("git", ["config", "--type=bool", "--get", "core.sparseCheckout"], { encoding: "utf8", stdio: "pipe" });
20045
- if ((sparse.stdout ?? "").trim() === "true") {
20046
- return {
20047
- kind: "unknown",
20048
- reason: "this is a sparse checkout, so its working tree may not hold every tracked file",
20049
- remedy: "Run the push from a full (non-sparse) checkout"
20050
- };
20051
- }
20052
- const prefixOut = spawnSync("git", ["rev-parse", "--show-prefix"], {
20053
- encoding: "utf8",
20054
- stdio: "pipe"
20055
- });
20056
- if ((prefixOut.status ?? 1) !== 0) {
20057
- return {
20058
- kind: "unknown",
20059
- reason: "the repository root could not be resolved",
20060
- remedy: "Check that git runs correctly in this directory"
20061
- };
20062
- }
20063
- const prefix = (prefixOut.stdout ?? "").trim();
20064
- const r = spawnSync("git", ["log", "HEAD", "--format=", "--name-only", "--", "migrations/datatable"], { encoding: "utf8", stdio: "pipe", maxBuffer: 64 * 1024 * 1024 });
20065
- if ((r.status ?? 1) !== 0) {
20066
- debug(`Could not read git history for migrations: ${r.stderr ?? ""}`);
20067
- return {
20068
- kind: "unknown",
20069
- reason: "its history could not be read",
20070
- remedy: "Check that git runs correctly in this directory"
20071
- };
20072
- }
20073
- const paths = new Set;
20074
- for (const line of (r.stdout ?? "").split(`
20075
- `)) {
20076
- const p = line.trim();
20077
- if (p.length === 0)
20078
- continue;
20079
- if (prefix.length > 0) {
20080
- if (!p.startsWith(prefix))
20081
- continue;
20082
- paths.add(p.slice(prefix.length));
20083
- } else {
20084
- paths.add(p);
20085
- }
20086
- }
20087
- return { kind: "known", paths };
20088
- }
20089
- function isGitRepository() {
20090
- try {
20091
- execSync("git rev-parse --git-dir", {
20092
- encoding: "utf8",
20093
- stdio: "pipe"
20094
- });
20095
- return true;
20096
- } catch (error) {
20097
- debug(`Failed to check Git repository: ${error}`);
20098
- return false;
20099
- }
20100
- }
20101
- function isForkWorkspace(workspaceId, parentWorkspaceId) {
20102
- return !!parentWorkspaceId || workspaceId.startsWith(FORK_WORKSPACE_PREFIX);
20103
- }
20104
- function forkBranchName(workspaceId, originalBranch, devWorkspaceLabel) {
20105
- if (devWorkspaceLabel) {
20106
- return devWorkspaceLabel;
20107
- }
20108
- const branchPrefix = `${WM_FORK_PREFIX}/${originalBranch}/`;
20109
- return workspaceId.startsWith(FORK_WORKSPACE_PREFIX) ? workspaceId.replace(FORK_WORKSPACE_PREFIX, branchPrefix) : `${branchPrefix}${workspaceId}`;
20110
- }
20111
- function computeGitSyncDeployBranch(params) {
20112
- const {
20113
- workspaceId,
20114
- parentWorkspaceId,
20115
- devWorkspaceLabel,
20116
- items,
20117
- useIndividualBranch,
20118
- groupByFolder,
20119
- clonedBranchName
20120
- } = params;
20121
- const isDevWorkspace = !!devWorkspaceLabel;
20122
- if (isForkWorkspace(workspaceId, parentWorkspaceId) && !(isDevWorkspace && useIndividualBranch)) {
20123
- return forkBranchName(workspaceId, clonedBranchName, devWorkspaceLabel);
20124
- }
20125
- const fallback = isDevWorkspace ? forkBranchName(workspaceId, clonedBranchName, devWorkspaceLabel) : null;
20126
- if (items.length === 0)
20127
- return fallback;
20128
- const first = items[0];
20129
- if (!useIndividualBranch || first.path_type === "user" || first.path_type === "group") {
20130
- return fallback;
20131
- }
20132
- const ref = first.path || first.parent_path;
20133
- if (!ref)
20134
- return fallback;
20135
- return groupByFolder ? `wm_deploy/${workspaceId}/${ref.split("/").slice(0, 2).join("__")}` : `wm_deploy/${workspaceId}/${first.path_type}/${ref.replaceAll("/", "__")}`;
20136
- }
20137
- function composeGitSyncCommitHeader(items) {
20138
- const typeCounts = new Map;
20139
- for (const item of items) {
20140
- typeCounts.set(item.path_type, (typeCounts.get(item.path_type) ?? 0) + 1);
20141
- }
20142
- const sorted = Array.from(typeCounts.entries()).sort((a, b) => b[1] - a[1]);
20143
- const parts = [];
20144
- let othersCount = 0;
20145
- for (let i = 0;i < sorted.length; i++) {
20146
- const [pathType, count] = sorted[i];
20147
- if (i < 3) {
20148
- const label = count > 1 ? `${pathType}s` : pathType;
20149
- if (i === 2 && sorted.length === 3) {
20150
- parts.push(`and ${count} ${label}`);
20151
- } else {
20152
- parts.push(`${count} ${label}`);
20153
- }
20154
- } else {
20155
- othersCount += count;
20156
- }
20157
- }
20158
- let header = `[WM]: Deployed ${parts.join(", ")}`;
20159
- if (othersCount > 0) {
20160
- header += ` and ${othersCount} other object${othersCount > 1 ? "s" : ""}`;
20161
- }
20162
- return header;
20163
- }
20164
- function gitSyncCommitMessage(items) {
20165
- const descs = items.map((i) => i.commit_msg);
20166
- const [h, d] = descs.length === 1 ? [descs[0], ""] : [composeGitSyncCommitHeader(items), descs.join(`
20167
- `)];
20168
- return {
20169
- header: h === undefined || h === "" ? "no commit msg" : h,
20170
- description: d ?? ""
20171
- };
20172
- }
20173
- function gitSyncIncludePattern(pathType, path) {
20174
- switch (pathType) {
20175
- case "flow":
20176
- return `${path}.flow/*,${path}__flow/*`;
20177
- case "app":
20178
- return `${path}.app/*,${path}__app/*`;
20179
- case "raw_app":
20180
- return `${path}.raw_app/**,${path}__raw_app/**`;
20181
- case "folder":
20182
- return `${path}/folder.meta.*`;
20183
- case "resourcetype":
20184
- return `${path}.resource-type.*`;
20185
- case "resource":
20186
- return `${path}.resource.*`;
20187
- case "variable":
20188
- return `${path}.variable.*`;
20189
- case "schedule":
20190
- return `${path}.schedule.*`;
20191
- case "user":
20192
- return `${path}.user.*`;
20193
- case "group":
20194
- return `${path}.group.*`;
20195
- case "httptrigger":
20196
- return `${path}.http_trigger.*`;
20197
- case "websockettrigger":
20198
- return `${path}.websocket_trigger.*`;
20199
- case "kafkatrigger":
20200
- return `${path}.kafka_trigger.*`;
20201
- case "natstrigger":
20202
- return `${path}.nats_trigger.*`;
20203
- case "postgrestrigger":
20204
- return `${path}.postgres_trigger.*`;
20205
- case "mqtttrigger":
20206
- return `${path}.mqtt_trigger.*`;
20207
- case "amqptrigger":
20208
- return `${path}.amqp_trigger.*`;
20209
- case "sqstrigger":
20210
- return `${path}.sqs_trigger.*`;
20211
- case "gcptrigger":
20212
- return `${path}.gcp_trigger.*`;
20213
- case "azuretrigger":
20214
- return `${path}.azure_trigger.*`;
20215
- case "emailtrigger":
20216
- return `${path}.email_trigger.*`;
20217
- case "datatable_migration":
20218
- return `${path}.up.sql,${path}.down.sql`;
20219
- default:
20220
- return `${path}.*,${path}__mod/**`;
20221
- }
20222
- }
20223
- function deriveGitSyncDeployIncludes(items, useIndividualBranch) {
20224
- const extraIncludes = [];
20225
- for (const { path_type, path, parent_path } of items) {
20226
- if (path) {
20227
- extraIncludes.push(...gitSyncIncludePattern(path_type, path).split(","));
20228
- }
20229
- if (parent_path) {
20230
- extraIncludes.push(...gitSyncIncludePattern(path_type, parent_path).split(","));
20231
- }
20232
- }
20233
- const forcedIncludes = {};
20234
- if (!useIndividualBranch) {
20235
- const has = (pred) => items.some((i) => pred(i.path_type));
20236
- if (has((t) => t === "schedule"))
20237
- forcedIncludes.includeSchedules = true;
20238
- if (has((t) => t === "group"))
20239
- forcedIncludes.includeGroups = true;
20240
- if (has((t) => t === "user"))
20241
- forcedIncludes.includeUsers = true;
20242
- if (has((t) => t.includes("trigger")))
20243
- forcedIncludes.includeTriggers = true;
20244
- if (has((t) => t === "settings"))
20245
- forcedIncludes.includeSettings = true;
20246
- if (has((t) => t === "key"))
20247
- forcedIncludes.includeKey = true;
20248
- }
20249
- return { extraIncludes, forcedIncludes };
20250
- }
20251
- function git(args, opts) {
20252
- const r = spawnSync("git", args, { encoding: "utf8", stdio: "pipe" });
20253
- const status = r.status ?? 1;
20254
- if (r.error) {
20255
- if (opts?.allowFail)
20256
- return { status, stdout: "", stderr: String(r.error) };
20257
- throw r.error;
20258
- }
20259
- if (status !== 0 && !opts?.allowFail) {
20260
- throw new Error(`git ${args.join(" ")} failed (exit ${status}): ${r.stderr ?? ""}`);
20261
- }
20262
- return { status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
20263
- }
20264
- function checkoutGitSyncDeployBranch(branch) {
20265
- const existing = git(["checkout", branch], { allowFail: true });
20266
- if (existing.status === 0) {
20267
- info(`Switched to existing branch ${branch}`);
20268
- return;
20269
- }
20270
- git(["checkout", "-b", branch]);
20271
- git(["config", "--add", "--bool", "push.autoSetupRemote", "true"]);
20272
- info(`Created and switched to branch ${branch}`);
20273
- }
20274
- function gitSyncDeployPush(params) {
20275
- const { items, authorName, authorEmail, onlyCreateBranch } = params;
20276
- const committerName = params.committerName ?? authorName;
20277
- const committerEmail = params.committerEmail ?? authorEmail;
20278
- git(["config", "user.email", committerEmail]);
20279
- git(["config", "user.name", committerName]);
20280
- if (onlyCreateBranch) {
20281
- git(["push", "--porcelain"]);
20282
- return { pushed: true };
20283
- }
20284
- for (const { path, parent_path } of items) {
20285
- if (path) {
20286
- git(["add", "wmill-lock.yaml", `${path}**`], { allowFail: true });
20287
- }
20288
- if (parent_path) {
20289
- git(["add", "wmill-lock.yaml", `${parent_path}**`], { allowFail: true });
20290
- }
20291
- }
20292
- const staged = git(["diff", "--cached", "--quiet"], { allowFail: true });
20293
- if (staged.status === 0) {
20294
- info("No changes detected, nothing to commit.");
20295
- return { pushed: false };
20296
- }
20297
- const { header, description } = gitSyncCommitMessage(items);
20298
- git([
20299
- "commit",
20300
- "--author",
20301
- `${authorName} <${authorEmail}>`,
20302
- "-m",
20303
- header,
20304
- "-m",
20305
- description
20306
- ]);
20307
- const push = git(["push", "--porcelain"], { allowFail: true });
20308
- if (push.status !== 0) {
20309
- info(`Push failed, rebasing and retrying: ${push.stderr}`);
20310
- git(["pull", "--rebase"]);
20311
- git(["push", "--porcelain"]);
20312
- }
20313
- return { pushed: true };
20314
- }
20315
- var FORK_WORKSPACE_PREFIX;
20316
- var init_git = __esm(() => {
20317
- init_log();
20318
- FORK_WORKSPACE_PREFIX = `${WM_FORK_PREFIX}-`;
20319
- });
20005
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.812.0";
20320
20006
 
20321
20007
  // src/utils/resource_folders.ts
20322
20008
  import { existsSync } from "node:fs";
@@ -20683,6 +20369,575 @@ var init_resource_folders = __esm(async () => {
20683
20369
  DBT_ENV_VAR_CALL = /\{\{\s*env_var\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]*)['"]\s*)?\)\s*\}\}/g;
20684
20370
  });
20685
20371
 
20372
+ // src/utils/script_common.ts
20373
+ function workspaceDependenciesPathToLanguageAndFilename(path) {
20374
+ const relativePath = path.replace("dependencies/", "");
20375
+ for (const { filename, language } of workspaceDependenciesLanguages) {
20376
+ if (relativePath.endsWith(filename)) {
20377
+ return {
20378
+ name: relativePath === filename ? undefined : relativePath.replace("." + filename, ""),
20379
+ language
20380
+ };
20381
+ }
20382
+ }
20383
+ }
20384
+ function extractWorkspaceDepsAnnotation(scriptContent, language) {
20385
+ const config = LANG_ANNOTATION_CONFIG[language];
20386
+ if (!config)
20387
+ return null;
20388
+ const { comment, keyword, validityRe } = config;
20389
+ const extraMarkerUnderscore = `extra_${keyword}:`;
20390
+ const extraMarkerHyphen = `extra-${keyword}:`;
20391
+ const manualMarker = `${keyword}:`;
20392
+ const stripComment = (l) => {
20393
+ if (!l.startsWith(comment))
20394
+ return null;
20395
+ return l.substring(comment.length).trimStart();
20396
+ };
20397
+ const isExtra = (l) => {
20398
+ const s = stripComment(l);
20399
+ return s !== null && (s.startsWith(extraMarkerUnderscore) || s.startsWith(extraMarkerHyphen));
20400
+ };
20401
+ const isManual = (l) => {
20402
+ const s = stripComment(l);
20403
+ return s !== null && s.startsWith(manualMarker);
20404
+ };
20405
+ const lines = scriptContent.split(`
20406
+ `);
20407
+ let pos = -1;
20408
+ for (let i = 0;i < lines.length; i++) {
20409
+ if (isExtra(lines[i]) || isManual(lines[i])) {
20410
+ pos = i;
20411
+ break;
20412
+ }
20413
+ }
20414
+ if (pos === -1)
20415
+ return null;
20416
+ const annotationLine = lines[pos];
20417
+ const mode = isExtra(annotationLine) ? "extra" : "manual";
20418
+ const marker = mode === "extra" ? annotationLine.includes(extraMarkerUnderscore) ? extraMarkerUnderscore : extraMarkerHyphen : manualMarker;
20419
+ const unparsed = annotationLine.replaceAll(marker, "").replaceAll(comment, "");
20420
+ const external = unparsed.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
20421
+ const inlineParts = [];
20422
+ for (let i = pos + 1;i < lines.length; i++) {
20423
+ const l = lines[i];
20424
+ if (validityRe) {
20425
+ const match = validityRe.exec(l);
20426
+ if (match && match[1]) {
20427
+ inlineParts.push(match[1]);
20428
+ } else {
20429
+ break;
20430
+ }
20431
+ } else {
20432
+ if (!l.startsWith(comment)) {
20433
+ break;
20434
+ }
20435
+ inlineParts.push(l.substring(comment.length));
20436
+ }
20437
+ }
20438
+ const inlineStr = inlineParts.join(`
20439
+ `);
20440
+ const inline = inlineStr.trim().length > 0 ? inlineStr : null;
20441
+ return { mode, external, inline };
20442
+ }
20443
+ function hasLockAffectingAnnotation(scriptContent, language) {
20444
+ const comment = LANG_COMMENT_LIT[language];
20445
+ const names = LANG_ANNOTATIONS[language];
20446
+ if (!comment || !names)
20447
+ return false;
20448
+ for (const line of scriptContent.split(`
20449
+ `)) {
20450
+ const trimmed = line.trim();
20451
+ if (trimmed === "")
20452
+ continue;
20453
+ if (!trimmed.startsWith(comment))
20454
+ break;
20455
+ if (language === "python3" && /^#\s?py:/.test(line))
20456
+ return true;
20457
+ const body = trimmed.slice(comment.length).trim();
20458
+ const key = body.split("=")[0].trim();
20459
+ if (names.includes(key))
20460
+ return true;
20461
+ }
20462
+ return false;
20463
+ }
20464
+ function sharedLockPathFor(depFilePath) {
20465
+ const name = depFilePath.replaceAll("\\", "/").split("/").pop();
20466
+ return `${SHARED_LOCK_DIR}/${name}.lock`;
20467
+ }
20468
+ function depFileOfSharedLock(p) {
20469
+ const normalized = p.replaceAll("\\", "/");
20470
+ if (!normalized.startsWith(SHARED_LOCK_DIR + "/"))
20471
+ return;
20472
+ const name = normalized.slice(SHARED_LOCK_DIR.length + 1);
20473
+ if (name.includes("/") || !name.endsWith(".lock"))
20474
+ return;
20475
+ const depFile = "dependencies/" + name.slice(0, -".lock".length);
20476
+ const info = workspaceDependenciesPathToLanguageAndFilename(depFile);
20477
+ return info && languageNeedsLock(info.language) ? depFile : undefined;
20478
+ }
20479
+ function isSharedLockPath(p) {
20480
+ return depFileOfSharedLock(p) !== undefined;
20481
+ }
20482
+ function languageNeedsLock(language) {
20483
+ return workspaceDependenciesLanguages.some((l) => l.language === language) && language !== "powershell" || language === "deno" || language === "rust" || language === "ansible";
20484
+ }
20485
+ function inferContentTypeFromFilePath(contentPath, defaultTs) {
20486
+ if (contentPath.endsWith(".py")) {
20487
+ return "python3";
20488
+ } else if (contentPath.endsWith("fetch.ts")) {
20489
+ return "nativets";
20490
+ } else if (contentPath.endsWith("bun.ts")) {
20491
+ return "bun";
20492
+ } else if (contentPath.endsWith("deno.ts")) {
20493
+ return "deno";
20494
+ } else if (contentPath.endsWith(".ts")) {
20495
+ return defaultTs ?? "bun";
20496
+ } else if (contentPath.endsWith(".go")) {
20497
+ return "go";
20498
+ } else if (contentPath.endsWith(".my.sql")) {
20499
+ return "mysql";
20500
+ } else if (contentPath.endsWith(".bq.sql")) {
20501
+ return "bigquery";
20502
+ } else if (contentPath.endsWith(".odb.sql")) {
20503
+ return "oracledb";
20504
+ } else if (contentPath.endsWith(".duckdb.sql")) {
20505
+ return "duckdb";
20506
+ } else if (contentPath.endsWith(".sf.sql")) {
20507
+ return "snowflake";
20508
+ } else if (contentPath.endsWith(".ms.sql")) {
20509
+ return "mssql";
20510
+ } else if (contentPath.endsWith(".pg.sql")) {
20511
+ return "postgresql";
20512
+ } else if (contentPath.endsWith(".gql")) {
20513
+ return "graphql";
20514
+ } else if (contentPath.endsWith(".sh")) {
20515
+ return "bash";
20516
+ } else if (contentPath.endsWith(".ps1")) {
20517
+ return "powershell";
20518
+ } else if (contentPath.endsWith(".php")) {
20519
+ return "php";
20520
+ } else if (contentPath.endsWith(".rs")) {
20521
+ return "rust";
20522
+ } else if (contentPath.endsWith(".cs")) {
20523
+ return "csharp";
20524
+ } else if (contentPath.endsWith(".playbook.yml")) {
20525
+ return "ansible";
20526
+ } else if (contentPath.endsWith(".nu")) {
20527
+ return "nu";
20528
+ } else if (contentPath.endsWith(".java")) {
20529
+ return "java";
20530
+ } else if (contentPath.endsWith(".rb")) {
20531
+ return "ruby";
20532
+ } else if (isDbtDescriptorPath(contentPath)) {
20533
+ return "dbt";
20534
+ } else if (contentPath.endsWith(".r")) {
20535
+ return "rlang";
20536
+ } else {
20537
+ const ext = contentPath.substring(contentPath.lastIndexOf("."));
20538
+ let hint = "";
20539
+ if (ext === ".sql") {
20540
+ hint = `
20541
+ Bare .sql is ambiguous — use a dialect extension: .pg.sql (postgresql), .my.sql (mysql), .bq.sql (bigquery), .sf.sql (snowflake), .ms.sql (mssql), .odb.sql (oracledb), .duckdb.sql (duckdb)`;
20542
+ }
20543
+ throw new Error(`Cannot infer script language from extension '${ext}' (file ${contentPath}).` + hint + "\nSupported extensions: .ts (bun/deno), .py, .go, .sh, .ps1, .php, .rs, .cs, .nu, .java, .rb, .r, .gql, .playbook.yml, .pg.sql, .my.sql, .bq.sql, .sf.sql, .ms.sql, .odb.sql, .duckdb.sql, and a dbt project folder `<name>__dbt/`");
20544
+ }
20545
+ }
20546
+ var workspaceDependenciesLanguages, LANG_ANNOTATION_CONFIG, LANG_COMMENT_LIT, LANG_ANNOTATIONS, SHARED_LOCK_DIR = "locks";
20547
+ var init_script_common = __esm(async () => {
20548
+ await init_resource_folders();
20549
+ workspaceDependenciesLanguages = [
20550
+ { language: "bun", filename: "package.json" },
20551
+ { language: "python3", filename: "requirements.in" },
20552
+ { language: "php", filename: "composer.json" },
20553
+ { language: "go", filename: "go.mod" },
20554
+ { language: "powershell", filename: "modules.json" }
20555
+ ];
20556
+ LANG_ANNOTATION_CONFIG = {
20557
+ python3: { comment: "#", keyword: "requirements", validityRe: /^#\s?(\S+)\s*$/ },
20558
+ bun: { comment: "//", keyword: "package_json" },
20559
+ nativets: { comment: "//", keyword: "package_json" },
20560
+ go: { comment: "//", keyword: "go_mod" },
20561
+ php: { comment: "//", keyword: "composer_json" },
20562
+ powershell: { comment: "#", keyword: "modules_json" }
20563
+ };
20564
+ LANG_COMMENT_LIT = {
20565
+ python3: "#",
20566
+ ansible: "#",
20567
+ powershell: "#",
20568
+ bun: "//",
20569
+ nativets: "//",
20570
+ deno: "//",
20571
+ go: "//",
20572
+ php: "//",
20573
+ rust: "//!"
20574
+ };
20575
+ LANG_ANNOTATIONS = {
20576
+ python3: [
20577
+ "no_cache",
20578
+ "no_postinstall",
20579
+ "py_select_latest",
20580
+ "skip_result_postprocessing",
20581
+ "py310",
20582
+ "py311",
20583
+ "py312",
20584
+ "py313",
20585
+ "sandbox"
20586
+ ],
20587
+ bun: ["npm", "nodejs", "native", "nobundling", "sandbox"],
20588
+ nativets: ["npm", "nodejs", "native", "nobundling", "sandbox"],
20589
+ deno: ["npm", "nodejs", "native", "nobundling", "sandbox"],
20590
+ go: ["go1_22_compat"]
20591
+ };
20592
+ });
20593
+
20594
+ // src/utils/git.ts
20595
+ import { execSync, spawnSync } from "node:child_process";
20596
+ function getCurrentGitBranch() {
20597
+ try {
20598
+ const result = execSync("git rev-parse --abbrev-ref HEAD", {
20599
+ encoding: "utf8",
20600
+ stdio: "pipe"
20601
+ });
20602
+ const branch = result.trim();
20603
+ return branch || null;
20604
+ } catch (error) {
20605
+ debug(`Failed to get Git branch: ${error}`);
20606
+ return null;
20607
+ }
20608
+ }
20609
+ function gitBranchExists(branchName) {
20610
+ const r = spawnSync("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], { stdio: "pipe" });
20611
+ return r.status === 0;
20612
+ }
20613
+ function renameCurrentGitBranch(newName) {
20614
+ const r = spawnSync("git", ["branch", "-m", newName], {
20615
+ encoding: "utf8",
20616
+ stdio: "pipe"
20617
+ });
20618
+ if ((r.status ?? 1) !== 0) {
20619
+ throw new Error(`git branch -m ${newName} failed (exit ${r.status}): ${r.stderr ?? ""}`);
20620
+ }
20621
+ }
20622
+ function getOriginalBranchForWorkspaceForks(branchName) {
20623
+ if (!branchName || !branchName.startsWith(WM_FORK_PREFIX)) {
20624
+ return null;
20625
+ }
20626
+ const start = branchName.indexOf("/") + 1;
20627
+ const end = branchName.lastIndexOf("/");
20628
+ if (start < 0 || end < 0 || end - start <= 0) {
20629
+ return null;
20630
+ }
20631
+ return branchName.slice(start, end);
20632
+ }
20633
+ function getWorkspaceIdForWorkspaceForkFromBranchName(branchName) {
20634
+ if (!branchName.startsWith(WM_FORK_PREFIX)) {
20635
+ return null;
20636
+ }
20637
+ const start = branchName.lastIndexOf("/") + 1;
20638
+ if (start < 0) {
20639
+ return null;
20640
+ }
20641
+ return `${WM_FORK_PREFIX}-${branchName.slice(start)}`;
20642
+ }
20643
+ function gitRecordedDatatableMigrationPaths() {
20644
+ if (!isGitRepository()) {
20645
+ return {
20646
+ kind: "unknown",
20647
+ reason: "this directory is not a git repository",
20648
+ remedy: "Run the push from a git checkout of the synced repository"
20649
+ };
20650
+ }
20651
+ const shallow = spawnSync("git", ["rev-parse", "--is-shallow-repository"], {
20652
+ encoding: "utf8",
20653
+ stdio: "pipe"
20654
+ });
20655
+ if ((shallow.stdout ?? "").trim() === "true") {
20656
+ return {
20657
+ kind: "unknown",
20658
+ reason: "this is a shallow clone, so its history is truncated",
20659
+ remedy: "Fetch the full history (for actions/checkout, fetch-depth: 0)"
20660
+ };
20661
+ }
20662
+ const sparse = spawnSync("git", ["config", "--type=bool", "--get", "core.sparseCheckout"], { encoding: "utf8", stdio: "pipe" });
20663
+ if ((sparse.stdout ?? "").trim() === "true") {
20664
+ return {
20665
+ kind: "unknown",
20666
+ reason: "this is a sparse checkout, so its working tree may not hold every tracked file",
20667
+ remedy: "Run the push from a full (non-sparse) checkout"
20668
+ };
20669
+ }
20670
+ const prefixOut = spawnSync("git", ["rev-parse", "--show-prefix"], {
20671
+ encoding: "utf8",
20672
+ stdio: "pipe"
20673
+ });
20674
+ if ((prefixOut.status ?? 1) !== 0) {
20675
+ return {
20676
+ kind: "unknown",
20677
+ reason: "the repository root could not be resolved",
20678
+ remedy: "Check that git runs correctly in this directory"
20679
+ };
20680
+ }
20681
+ const prefix = (prefixOut.stdout ?? "").trim();
20682
+ const r = spawnSync("git", ["log", "HEAD", "--format=", "--name-only", "--", "migrations/datatable"], { encoding: "utf8", stdio: "pipe", maxBuffer: 64 * 1024 * 1024 });
20683
+ if ((r.status ?? 1) !== 0) {
20684
+ debug(`Could not read git history for migrations: ${r.stderr ?? ""}`);
20685
+ return {
20686
+ kind: "unknown",
20687
+ reason: "its history could not be read",
20688
+ remedy: "Check that git runs correctly in this directory"
20689
+ };
20690
+ }
20691
+ const paths = new Set;
20692
+ for (const line of (r.stdout ?? "").split(`
20693
+ `)) {
20694
+ const p = line.trim();
20695
+ if (p.length === 0)
20696
+ continue;
20697
+ if (prefix.length > 0) {
20698
+ if (!p.startsWith(prefix))
20699
+ continue;
20700
+ paths.add(p.slice(prefix.length));
20701
+ } else {
20702
+ paths.add(p);
20703
+ }
20704
+ }
20705
+ return { kind: "known", paths };
20706
+ }
20707
+ function isGitRepository() {
20708
+ try {
20709
+ execSync("git rev-parse --git-dir", {
20710
+ encoding: "utf8",
20711
+ stdio: "pipe"
20712
+ });
20713
+ return true;
20714
+ } catch (error) {
20715
+ debug(`Failed to check Git repository: ${error}`);
20716
+ return false;
20717
+ }
20718
+ }
20719
+ function isForkWorkspace(workspaceId, parentWorkspaceId) {
20720
+ return !!parentWorkspaceId || workspaceId.startsWith(FORK_WORKSPACE_PREFIX);
20721
+ }
20722
+ function forkBranchName(workspaceId, originalBranch, devWorkspaceLabel) {
20723
+ if (devWorkspaceLabel) {
20724
+ return devWorkspaceLabel;
20725
+ }
20726
+ const branchPrefix = `${WM_FORK_PREFIX}/${originalBranch}/`;
20727
+ return workspaceId.startsWith(FORK_WORKSPACE_PREFIX) ? workspaceId.replace(FORK_WORKSPACE_PREFIX, branchPrefix) : `${branchPrefix}${workspaceId}`;
20728
+ }
20729
+ function computeGitSyncDeployBranch(params) {
20730
+ const {
20731
+ workspaceId,
20732
+ parentWorkspaceId,
20733
+ devWorkspaceLabel,
20734
+ items,
20735
+ useIndividualBranch,
20736
+ groupByFolder,
20737
+ clonedBranchName
20738
+ } = params;
20739
+ const isDevWorkspace = !!devWorkspaceLabel;
20740
+ if (isForkWorkspace(workspaceId, parentWorkspaceId) && !(isDevWorkspace && useIndividualBranch)) {
20741
+ return forkBranchName(workspaceId, clonedBranchName, devWorkspaceLabel);
20742
+ }
20743
+ const fallback = isDevWorkspace ? forkBranchName(workspaceId, clonedBranchName, devWorkspaceLabel) : null;
20744
+ if (items.length === 0)
20745
+ return fallback;
20746
+ const first = items[0];
20747
+ if (!useIndividualBranch || first.path_type === "user" || first.path_type === "group") {
20748
+ return fallback;
20749
+ }
20750
+ const ref = first.path || first.parent_path;
20751
+ if (!ref)
20752
+ return fallback;
20753
+ return groupByFolder ? `wm_deploy/${workspaceId}/${ref.split("/").slice(0, 2).join("__")}` : `wm_deploy/${workspaceId}/${first.path_type}/${ref.replaceAll("/", "__")}`;
20754
+ }
20755
+ function composeGitSyncCommitHeader(items) {
20756
+ const typeCounts = new Map;
20757
+ for (const item of items) {
20758
+ typeCounts.set(item.path_type, (typeCounts.get(item.path_type) ?? 0) + 1);
20759
+ }
20760
+ const sorted = Array.from(typeCounts.entries()).sort((a, b) => b[1] - a[1]);
20761
+ const parts = [];
20762
+ let othersCount = 0;
20763
+ for (let i = 0;i < sorted.length; i++) {
20764
+ const [pathType, count] = sorted[i];
20765
+ if (i < 3) {
20766
+ const label = count > 1 ? `${pathType}s` : pathType;
20767
+ if (i === 2 && sorted.length === 3) {
20768
+ parts.push(`and ${count} ${label}`);
20769
+ } else {
20770
+ parts.push(`${count} ${label}`);
20771
+ }
20772
+ } else {
20773
+ othersCount += count;
20774
+ }
20775
+ }
20776
+ let header = `[WM]: Deployed ${parts.join(", ")}`;
20777
+ if (othersCount > 0) {
20778
+ header += ` and ${othersCount} other object${othersCount > 1 ? "s" : ""}`;
20779
+ }
20780
+ return header;
20781
+ }
20782
+ function gitSyncCommitMessage(items) {
20783
+ const descs = items.map((i) => i.commit_msg);
20784
+ const [h, d] = descs.length === 1 ? [descs[0], ""] : [composeGitSyncCommitHeader(items), descs.join(`
20785
+ `)];
20786
+ return {
20787
+ header: h === undefined || h === "" ? "no commit msg" : h,
20788
+ description: d ?? ""
20789
+ };
20790
+ }
20791
+ function gitSyncIncludePattern(pathType, path) {
20792
+ switch (pathType) {
20793
+ case "flow":
20794
+ return `${path}.flow/*,${path}__flow/*`;
20795
+ case "app":
20796
+ return `${path}.app/*,${path}__app/*`;
20797
+ case "raw_app":
20798
+ return `${path}.raw_app/**,${path}__raw_app/**`;
20799
+ case "folder":
20800
+ return `${path}/folder.meta.*`;
20801
+ case "resourcetype":
20802
+ return `${path}.resource-type.*`;
20803
+ case "resource":
20804
+ return `${path}.resource.*`;
20805
+ case "variable":
20806
+ return `${path}.variable.*`;
20807
+ case "schedule":
20808
+ return `${path}.schedule.*`;
20809
+ case "user":
20810
+ return `${path}.user.*`;
20811
+ case "group":
20812
+ return `${path}.group.*`;
20813
+ case "httptrigger":
20814
+ return `${path}.http_trigger.*`;
20815
+ case "websockettrigger":
20816
+ return `${path}.websocket_trigger.*`;
20817
+ case "kafkatrigger":
20818
+ return `${path}.kafka_trigger.*`;
20819
+ case "natstrigger":
20820
+ return `${path}.nats_trigger.*`;
20821
+ case "postgrestrigger":
20822
+ return `${path}.postgres_trigger.*`;
20823
+ case "mqtttrigger":
20824
+ return `${path}.mqtt_trigger.*`;
20825
+ case "amqptrigger":
20826
+ return `${path}.amqp_trigger.*`;
20827
+ case "sqstrigger":
20828
+ return `${path}.sqs_trigger.*`;
20829
+ case "gcptrigger":
20830
+ return `${path}.gcp_trigger.*`;
20831
+ case "azuretrigger":
20832
+ return `${path}.azure_trigger.*`;
20833
+ case "emailtrigger":
20834
+ return `${path}.email_trigger.*`;
20835
+ case "datatable_migration":
20836
+ return `${path}.up.sql,${path}.down.sql`;
20837
+ default:
20838
+ return `${path}.*,${path}__mod/**`;
20839
+ }
20840
+ }
20841
+ function deriveGitSyncDeployIncludes(items, useIndividualBranch) {
20842
+ const extraIncludes = [];
20843
+ for (const { path_type, path, parent_path } of items) {
20844
+ if (path) {
20845
+ extraIncludes.push(...gitSyncIncludePattern(path_type, path).split(","));
20846
+ }
20847
+ if (parent_path) {
20848
+ extraIncludes.push(...gitSyncIncludePattern(path_type, parent_path).split(","));
20849
+ }
20850
+ }
20851
+ const forcedIncludes = {};
20852
+ if (!useIndividualBranch) {
20853
+ const has = (pred) => items.some((i) => pred(i.path_type));
20854
+ if (has((t) => t === "schedule"))
20855
+ forcedIncludes.includeSchedules = true;
20856
+ if (has((t) => t === "group"))
20857
+ forcedIncludes.includeGroups = true;
20858
+ if (has((t) => t === "user"))
20859
+ forcedIncludes.includeUsers = true;
20860
+ if (has((t) => t.includes("trigger")))
20861
+ forcedIncludes.includeTriggers = true;
20862
+ if (has((t) => t === "settings"))
20863
+ forcedIncludes.includeSettings = true;
20864
+ if (has((t) => t === "key"))
20865
+ forcedIncludes.includeKey = true;
20866
+ }
20867
+ return { extraIncludes, forcedIncludes };
20868
+ }
20869
+ function git(args, opts) {
20870
+ const r = spawnSync("git", args, { encoding: "utf8", stdio: "pipe" });
20871
+ const status = r.status ?? 1;
20872
+ if (r.error) {
20873
+ if (opts?.allowFail)
20874
+ return { status, stdout: "", stderr: String(r.error) };
20875
+ throw r.error;
20876
+ }
20877
+ if (status !== 0 && !opts?.allowFail) {
20878
+ throw new Error(`git ${args.join(" ")} failed (exit ${status}): ${r.stderr ?? ""}`);
20879
+ }
20880
+ return { status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
20881
+ }
20882
+ function checkoutGitSyncDeployBranch(branch) {
20883
+ const existing = git(["checkout", branch], { allowFail: true });
20884
+ if (existing.status === 0) {
20885
+ info(`Switched to existing branch ${branch}`);
20886
+ return;
20887
+ }
20888
+ git(["checkout", "-b", branch]);
20889
+ git(["config", "--add", "--bool", "push.autoSetupRemote", "true"]);
20890
+ info(`Created and switched to branch ${branch}`);
20891
+ }
20892
+ function gitSyncDeployPush(params) {
20893
+ const { items, authorName, authorEmail, onlyCreateBranch } = params;
20894
+ const committerName = params.committerName ?? authorName;
20895
+ const committerEmail = params.committerEmail ?? authorEmail;
20896
+ git(["config", "user.email", committerEmail]);
20897
+ git(["config", "user.name", committerName]);
20898
+ if (onlyCreateBranch) {
20899
+ git(["push", "--porcelain"]);
20900
+ return { pushed: true };
20901
+ }
20902
+ for (const { path, parent_path } of items) {
20903
+ if (path) {
20904
+ git(["add", "wmill-lock.yaml", `${path}**`], { allowFail: true });
20905
+ }
20906
+ if (parent_path) {
20907
+ git(["add", "wmill-lock.yaml", `${parent_path}**`], { allowFail: true });
20908
+ }
20909
+ }
20910
+ git(["add", "-A", "--", SHARED_LOCK_DIR], { allowFail: true });
20911
+ const staged = git(["diff", "--cached", "--quiet"], { allowFail: true });
20912
+ if (staged.status === 0) {
20913
+ info("No changes detected, nothing to commit.");
20914
+ return { pushed: false };
20915
+ }
20916
+ const { header, description } = gitSyncCommitMessage(items);
20917
+ git([
20918
+ "commit",
20919
+ "--author",
20920
+ `${authorName} <${authorEmail}>`,
20921
+ "-m",
20922
+ header,
20923
+ "-m",
20924
+ description
20925
+ ]);
20926
+ const push = git(["push", "--porcelain"], { allowFail: true });
20927
+ if (push.status !== 0) {
20928
+ info(`Push failed, rebasing and retrying: ${push.stderr}`);
20929
+ git(["pull", "--rebase"]);
20930
+ git(["push", "--porcelain"]);
20931
+ }
20932
+ return { pushed: true };
20933
+ }
20934
+ var FORK_WORKSPACE_PREFIX;
20935
+ var init_git = __esm(async () => {
20936
+ init_log();
20937
+ await init_script_common();
20938
+ FORK_WORKSPACE_PREFIX = `${WM_FORK_PREFIX}-`;
20939
+ });
20940
+
20686
20941
  // src/core/conf.ts
20687
20942
  import { join as join6, dirname as dirname6, resolve as resolve5, relative as relative4 } from "node:path";
20688
20943
  import { existsSync as existsSync3 } from "node:fs";
@@ -21068,10 +21323,10 @@ function convertGitBranchesToWorkspaces(gitBranches) {
21068
21323
  var import_yaml3, showDiffs = false, SUPPORTED_SYNC_BEHAVIOR_VERSION = 1, GLOBAL_CONFIG_OPT, legacyConfigWarned = false, DEFAULT_SYNC_OPTIONS, RESERVED_WORKSPACE_KEYS;
21069
21324
  var init_conf = __esm(async () => {
21070
21325
  init_log();
21071
- init_git();
21072
21326
  await __promiseAll([
21073
21327
  init_yaml(),
21074
21328
  init_confirm(),
21329
+ init_git(),
21075
21330
  init_resource_folders()
21076
21331
  ]);
21077
21332
  import_yaml3 = __toESM(require_dist(), 1);
@@ -21465,10 +21720,10 @@ var init_fork = __esm(async () => {
21465
21720
  init_log();
21466
21721
  init_client();
21467
21722
  init_services_gen();
21468
- init_git();
21469
21723
  await __promiseAll([
21470
21724
  init_input(),
21471
21725
  init_workspace(),
21726
+ init_git(),
21472
21727
  init_context(),
21473
21728
  init_conf()
21474
21729
  ]);
@@ -23089,7 +23344,7 @@ async function getWorkspaceByName(workspaceName, configDirOverride) {
23089
23344
  return;
23090
23345
  }
23091
23346
  async function forkBranchAutoTargetNote() {
23092
- await Promise.resolve().then(() => init_git());
23347
+ await init_git();
23093
23348
  const branch = getCurrentGitBranch();
23094
23349
  if (!branch || !getOriginalBranchForWorkspaceForks(branch)) {
23095
23350
  return;
@@ -23306,7 +23561,7 @@ async function whoami2(_opts) {
23306
23561
  const whoamiInfo = await requireLogin(_opts);
23307
23562
  info(JSON.stringify(whoamiInfo, null, 2));
23308
23563
  const activeName = await getActiveWorkspaceName(_opts);
23309
- await Promise.resolve().then(() => init_git());
23564
+ await init_git();
23310
23565
  const branch = getCurrentGitBranch();
23311
23566
  const originalBranch = branch ? getOriginalBranchForWorkspaceForks(branch) : null;
23312
23567
  if (originalBranch) {
@@ -23404,7 +23659,7 @@ async function getActiveWorkspaceOrFallback(opts) {
23404
23659
  return activeWorkspace;
23405
23660
  }
23406
23661
  async function bind(opts, doBind) {
23407
- await Promise.resolve().then(() => init_git());
23662
+ await init_git();
23408
23663
  await init_conf();
23409
23664
  const { stringify: yamlStringify } = await Promise.resolve().then(() => __toESM(require_dist(), 1));
23410
23665
  const config = await readConfigFile();
@@ -24105,7 +24360,6 @@ var init_context = __esm(async () => {
24105
24360
  init_log();
24106
24361
  init_mod6();
24107
24362
  init_http_guards();
24108
- init_git();
24109
24363
  init_levenshtein_distance();
24110
24364
  await __promiseAll([
24111
24365
  init_select(),
@@ -24115,7 +24369,8 @@ var init_context = __esm(async () => {
24115
24369
  init_utils(),
24116
24370
  init_workspace(),
24117
24371
  init_branch_profiles(),
24118
- init_conf()
24372
+ init_conf(),
24373
+ init_git()
24119
24374
  ]);
24120
24375
  REMOTE_PATH_RE = /^[ufg](\/[^/]+){2,}$/;
24121
24376
  });
@@ -24378,6 +24633,14 @@ function capitalize(str) {
24378
24633
  function formatTimestamp(ts) {
24379
24634
  return new Date(ts).toISOString().replace("T", " ").substring(0, 19);
24380
24635
  }
24636
+ function apiErrorMessage(e) {
24637
+ if (!(e && typeof e === "object" && ("name" in e) && e.name === "ApiError")) {
24638
+ return;
24639
+ }
24640
+ const { body, statusText } = e;
24641
+ const bodyStr = typeof body === "object" && body !== null ? JSON.stringify(body) : String(body ?? "");
24642
+ return statusText + ": " + bodyStr.replace(/\s*[@(]\w+\.rs:\d+[:\d]*\)?/g, "");
24643
+ }
24381
24644
  function validateRequiredArgs(schema) {
24382
24645
  const required = schema?.required ?? [];
24383
24646
  if (required.length > 0) {
@@ -34562,228 +34825,6 @@ main <- function(x, name = "default") {
34562
34825
  };
34563
34826
  });
34564
34827
 
34565
- // src/utils/script_common.ts
34566
- function workspaceDependenciesPathToLanguageAndFilename(path) {
34567
- const relativePath = path.replace("dependencies/", "");
34568
- for (const { filename, language } of workspaceDependenciesLanguages) {
34569
- if (relativePath.endsWith(filename)) {
34570
- return {
34571
- name: relativePath === filename ? undefined : relativePath.replace("." + filename, ""),
34572
- language
34573
- };
34574
- }
34575
- }
34576
- }
34577
- function extractWorkspaceDepsAnnotation(scriptContent, language) {
34578
- const config = LANG_ANNOTATION_CONFIG[language];
34579
- if (!config)
34580
- return null;
34581
- const { comment, keyword, validityRe } = config;
34582
- const extraMarkerUnderscore = `extra_${keyword}:`;
34583
- const extraMarkerHyphen = `extra-${keyword}:`;
34584
- const manualMarker = `${keyword}:`;
34585
- const stripComment = (l) => {
34586
- if (!l.startsWith(comment))
34587
- return null;
34588
- return l.substring(comment.length).trimStart();
34589
- };
34590
- const isExtra = (l) => {
34591
- const s = stripComment(l);
34592
- return s !== null && (s.startsWith(extraMarkerUnderscore) || s.startsWith(extraMarkerHyphen));
34593
- };
34594
- const isManual = (l) => {
34595
- const s = stripComment(l);
34596
- return s !== null && s.startsWith(manualMarker);
34597
- };
34598
- const lines = scriptContent.split(`
34599
- `);
34600
- let pos = -1;
34601
- for (let i = 0;i < lines.length; i++) {
34602
- if (isExtra(lines[i]) || isManual(lines[i])) {
34603
- pos = i;
34604
- break;
34605
- }
34606
- }
34607
- if (pos === -1)
34608
- return null;
34609
- const annotationLine = lines[pos];
34610
- const mode = isExtra(annotationLine) ? "extra" : "manual";
34611
- const marker = mode === "extra" ? annotationLine.includes(extraMarkerUnderscore) ? extraMarkerUnderscore : extraMarkerHyphen : manualMarker;
34612
- const unparsed = annotationLine.replaceAll(marker, "").replaceAll(comment, "");
34613
- const external = unparsed.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
34614
- const inlineParts = [];
34615
- for (let i = pos + 1;i < lines.length; i++) {
34616
- const l = lines[i];
34617
- if (validityRe) {
34618
- const match = validityRe.exec(l);
34619
- if (match && match[1]) {
34620
- inlineParts.push(match[1]);
34621
- } else {
34622
- break;
34623
- }
34624
- } else {
34625
- if (!l.startsWith(comment)) {
34626
- break;
34627
- }
34628
- inlineParts.push(l.substring(comment.length));
34629
- }
34630
- }
34631
- const inlineStr = inlineParts.join(`
34632
- `);
34633
- const inline = inlineStr.trim().length > 0 ? inlineStr : null;
34634
- return { mode, external, inline };
34635
- }
34636
- function hasLockAffectingAnnotation(scriptContent, language) {
34637
- const comment = LANG_COMMENT_LIT[language];
34638
- const names = LANG_ANNOTATIONS[language];
34639
- if (!comment || !names)
34640
- return false;
34641
- for (const line of scriptContent.split(`
34642
- `)) {
34643
- const trimmed = line.trim();
34644
- if (trimmed === "")
34645
- continue;
34646
- if (!trimmed.startsWith(comment))
34647
- break;
34648
- if (language === "python3" && /^#\s?py:/.test(line))
34649
- return true;
34650
- const body = trimmed.slice(comment.length).trim();
34651
- const key = body.split("=")[0].trim();
34652
- if (names.includes(key))
34653
- return true;
34654
- }
34655
- return false;
34656
- }
34657
- function sharedLockPathFor(depFilePath) {
34658
- const name = depFilePath.replaceAll("\\", "/").split("/").pop();
34659
- return `${SHARED_LOCK_DIR}/${name}.lock`;
34660
- }
34661
- function depFileOfSharedLock(p) {
34662
- const normalized = p.replaceAll("\\", "/");
34663
- if (!normalized.startsWith(SHARED_LOCK_DIR + "/"))
34664
- return;
34665
- const name = normalized.slice(SHARED_LOCK_DIR.length + 1);
34666
- if (name.includes("/") || !name.endsWith(".lock"))
34667
- return;
34668
- const depFile = "dependencies/" + name.slice(0, -".lock".length);
34669
- const info = workspaceDependenciesPathToLanguageAndFilename(depFile);
34670
- return info && languageNeedsLock(info.language) ? depFile : undefined;
34671
- }
34672
- function isSharedLockPath(p) {
34673
- return depFileOfSharedLock(p) !== undefined;
34674
- }
34675
- function languageNeedsLock(language) {
34676
- return workspaceDependenciesLanguages.some((l) => l.language === language) && language !== "powershell" || language === "deno" || language === "rust" || language === "ansible";
34677
- }
34678
- function inferContentTypeFromFilePath(contentPath, defaultTs) {
34679
- if (contentPath.endsWith(".py")) {
34680
- return "python3";
34681
- } else if (contentPath.endsWith("fetch.ts")) {
34682
- return "nativets";
34683
- } else if (contentPath.endsWith("bun.ts")) {
34684
- return "bun";
34685
- } else if (contentPath.endsWith("deno.ts")) {
34686
- return "deno";
34687
- } else if (contentPath.endsWith(".ts")) {
34688
- return defaultTs ?? "bun";
34689
- } else if (contentPath.endsWith(".go")) {
34690
- return "go";
34691
- } else if (contentPath.endsWith(".my.sql")) {
34692
- return "mysql";
34693
- } else if (contentPath.endsWith(".bq.sql")) {
34694
- return "bigquery";
34695
- } else if (contentPath.endsWith(".odb.sql")) {
34696
- return "oracledb";
34697
- } else if (contentPath.endsWith(".duckdb.sql")) {
34698
- return "duckdb";
34699
- } else if (contentPath.endsWith(".sf.sql")) {
34700
- return "snowflake";
34701
- } else if (contentPath.endsWith(".ms.sql")) {
34702
- return "mssql";
34703
- } else if (contentPath.endsWith(".pg.sql")) {
34704
- return "postgresql";
34705
- } else if (contentPath.endsWith(".gql")) {
34706
- return "graphql";
34707
- } else if (contentPath.endsWith(".sh")) {
34708
- return "bash";
34709
- } else if (contentPath.endsWith(".ps1")) {
34710
- return "powershell";
34711
- } else if (contentPath.endsWith(".php")) {
34712
- return "php";
34713
- } else if (contentPath.endsWith(".rs")) {
34714
- return "rust";
34715
- } else if (contentPath.endsWith(".cs")) {
34716
- return "csharp";
34717
- } else if (contentPath.endsWith(".playbook.yml")) {
34718
- return "ansible";
34719
- } else if (contentPath.endsWith(".nu")) {
34720
- return "nu";
34721
- } else if (contentPath.endsWith(".java")) {
34722
- return "java";
34723
- } else if (contentPath.endsWith(".rb")) {
34724
- return "ruby";
34725
- } else if (isDbtDescriptorPath(contentPath)) {
34726
- return "dbt";
34727
- } else if (contentPath.endsWith(".r")) {
34728
- return "rlang";
34729
- } else {
34730
- const ext = contentPath.substring(contentPath.lastIndexOf("."));
34731
- let hint = "";
34732
- if (ext === ".sql") {
34733
- hint = `
34734
- Bare .sql is ambiguous — use a dialect extension: .pg.sql (postgresql), .my.sql (mysql), .bq.sql (bigquery), .sf.sql (snowflake), .ms.sql (mssql), .odb.sql (oracledb), .duckdb.sql (duckdb)`;
34735
- }
34736
- throw new Error(`Cannot infer script language from extension '${ext}' (file ${contentPath}).` + hint + "\nSupported extensions: .ts (bun/deno), .py, .go, .sh, .ps1, .php, .rs, .cs, .nu, .java, .rb, .r, .gql, .playbook.yml, .pg.sql, .my.sql, .bq.sql, .sf.sql, .ms.sql, .odb.sql, .duckdb.sql, and a dbt project folder `<name>__dbt/`");
34737
- }
34738
- }
34739
- var workspaceDependenciesLanguages, LANG_ANNOTATION_CONFIG, LANG_COMMENT_LIT, LANG_ANNOTATIONS, SHARED_LOCK_DIR = "locks";
34740
- var init_script_common = __esm(async () => {
34741
- await init_resource_folders();
34742
- workspaceDependenciesLanguages = [
34743
- { language: "bun", filename: "package.json" },
34744
- { language: "python3", filename: "requirements.in" },
34745
- { language: "php", filename: "composer.json" },
34746
- { language: "go", filename: "go.mod" },
34747
- { language: "powershell", filename: "modules.json" }
34748
- ];
34749
- LANG_ANNOTATION_CONFIG = {
34750
- python3: { comment: "#", keyword: "requirements", validityRe: /^#\s?(\S+)\s*$/ },
34751
- bun: { comment: "//", keyword: "package_json" },
34752
- nativets: { comment: "//", keyword: "package_json" },
34753
- go: { comment: "//", keyword: "go_mod" },
34754
- php: { comment: "//", keyword: "composer_json" },
34755
- powershell: { comment: "#", keyword: "modules_json" }
34756
- };
34757
- LANG_COMMENT_LIT = {
34758
- python3: "#",
34759
- ansible: "#",
34760
- powershell: "#",
34761
- bun: "//",
34762
- nativets: "//",
34763
- deno: "//",
34764
- go: "//",
34765
- php: "//",
34766
- rust: "//!"
34767
- };
34768
- LANG_ANNOTATIONS = {
34769
- python3: [
34770
- "no_cache",
34771
- "no_postinstall",
34772
- "py_select_latest",
34773
- "skip_result_postprocessing",
34774
- "py310",
34775
- "py311",
34776
- "py312",
34777
- "py313",
34778
- "sandbox"
34779
- ],
34780
- bun: ["npm", "nodejs", "native", "nobundling", "sandbox"],
34781
- nativets: ["npm", "nodejs", "native", "nobundling", "sandbox"],
34782
- deno: ["npm", "nodejs", "native", "nobundling", "sandbox"],
34783
- go: ["go1_22_compat"]
34784
- };
34785
- });
34786
-
34787
34828
  // node_modules/balanced-match/dist/esm/index.js
34788
34829
  var balanced = (a, b, str) => {
34789
34830
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
@@ -56381,7 +56422,7 @@ var init_openflow = __esm(() => {
56381
56422
  openflow_default = {
56382
56423
  openapi: "3.0.3",
56383
56424
  info: {
56384
- version: "1.811.0",
56425
+ version: "1.812.0",
56385
56426
  title: "OpenFlow Spec",
56386
56427
  contact: {
56387
56428
  name: "Ruben Fiszel",
@@ -57802,6 +57843,22 @@ Example: { type: 'object', properties: { name: { type: 'string' }, age: { type:
57802
57843
  description: `Array of file references (images or PDFs) for the AI agent.
57803
57844
  Format: Array<{ bucket: string, key: string }> - S3 object references
57804
57845
  Example: [{ bucket: 'my-bucket', key: 'documents/report.pdf' }]
57846
+ `
57847
+ },
57848
+ enabled_tools: {
57849
+ allOf: [
57850
+ {
57851
+ $ref: "#/components/schemas/InputTransform"
57852
+ }
57853
+ ],
57854
+ description: `Array of strings naming which of the tools configured in \`tools\` the agent may call
57855
+ this run. Leaving it unset carries every one of them; an empty array carries none.
57856
+ A tool is named as the model is shown it. An entry the model is shown nothing of is
57857
+ named by what identifies it instead: an MCP server by its resource path, carrying
57858
+ every tool it exposes (which of them stays that entry's include_tools/exclude_tools),
57859
+ and a websearch entry by the reserved name '__wm_web_search', whatever summary it carries
57860
+ (no tool may take that name).
57861
+ Example: ['get_user', 'u/admin/github_mcp', '__wm_web_search']
57805
57862
  `
57806
57863
  },
57807
57864
  max_completion_tokens: {
@@ -57869,7 +57926,7 @@ Range: 1-1000.
57869
57926
  description: `Path of a reusable \`ai_agent\` resource (hybrid linking). When set, the agent brain
57870
57927
  config (provider/model/system prompt/etc.) and tool set are resolved at runtime from
57871
57928
  that resource; the module's input_transforms then only carry the flow-local inputs
57872
- (user_message/user_attachments).
57929
+ (user_message/user_attachments/enabled_tools).
57873
57930
  `
57874
57931
  },
57875
57932
  tool_inputs: {
@@ -58726,6 +58783,16 @@ Frontend appends a \`*\` to the displayed name.
58726
58783
  type: "boolean",
58727
58784
  description: "If true, passes the request body as a raw string instead of parsing as JSON"
58728
58785
  },
58786
+ allowed_origins: {
58787
+ type: "array",
58788
+ nullable: true,
58789
+ maxItems: 100,
58790
+ items: {
58791
+ type: "string",
58792
+ maxLength: 256
58793
+ },
58794
+ description: "Origins allowed to call this route cross-origin, matched against the request's Origin header (ignoring case) and echoed back on a match. When set, the list governs both the preflight and the response, overriding any Access-Control-Allow-Origin the runnable returns via wm_headers. Use ['*'] to opt out of any restriction, including the http_route_default_allowed_origins instance setting. An empty list is not a configuration and resolves exactly as null does. When null, the instance setting applies, or Access-Control-Allow-Origin: * if it is unset. Ignored on a static website, which has no authentication of its own and so hands out public files: restricting which browsers may read them protects nothing while breaking cross-origin webfonts and fetches. A single-file static asset is not exempt, since it can carry an authentication_method."
58795
+ },
58729
58796
  error_handler_path: {
58730
58797
  type: "string",
58731
58798
  description: "Path to a script to run when the triggered job fails. A bare path, without the script/ or flow/ prefix a schedule error handler takes; it cannot be a flow."
@@ -60747,8 +60814,8 @@ function isWorkspaceSpecificFile(path) {
60747
60814
  var workspacePatternCache;
60748
60815
  var init_specific_items = __esm(async () => {
60749
60816
  init_esm2();
60750
- init_git();
60751
60817
  await __promiseAll([
60818
+ init_git(),
60752
60819
  init_utils(),
60753
60820
  init_conf(),
60754
60821
  init_types()
@@ -63426,7 +63493,6 @@ var init_script = __esm(async () => {
63426
63493
  init_log();
63427
63494
  init_http_guards();
63428
63495
  init_services_gen();
63429
- init_git();
63430
63496
  init_script_bootstrap();
63431
63497
  init_job_polling();
63432
63498
  init_tar();
@@ -63438,6 +63504,7 @@ var init_script = __esm(async () => {
63438
63504
  init_confirm(),
63439
63505
  init_utils(),
63440
63506
  init_specific_items(),
63507
+ init_git(),
63441
63508
  init_metadata(),
63442
63509
  init_utils(),
63443
63510
  init_script_common(),
@@ -64422,13 +64489,13 @@ var init_resource = __esm(async () => {
64422
64489
  init_colors2();
64423
64490
  init_log();
64424
64491
  init_services_gen();
64425
- init_git();
64426
64492
  await __promiseAll([
64427
64493
  init_types(),
64428
64494
  init_auth(),
64429
64495
  init_context(),
64430
64496
  init_utils(),
64431
- init_specific_items()
64497
+ init_specific_items(),
64498
+ init_git()
64432
64499
  ]);
64433
64500
  import_yaml11 = __toESM(require_dist(), 1);
64434
64501
  command7 = new Command().description("resource related commands").option("--json", "Output as JSON (for piping to jq)").action(list5).command("list", "list all resources").option("--json", "Output as JSON (for piping to jq)").action(list5).command("get", "get a resource's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get3).command("new", "create a new resource locally").arguments("<path:string>").action(newResource).command("push", "push a local resource spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").action(push3);
@@ -66510,6 +66577,32 @@ function countDatatableMigrationRecords(changes) {
66510
66577
  function untrackedDatatableMigrationDeletions(changes, recorded) {
66511
66578
  return changes.filter((c) => c.name === "deleted" && isDatatableMigrationPath(c.path) && !(recorded.kind === "known" && recorded.paths.has(c.path)));
66512
66579
  }
66580
+ function secretBearingObjectKind(p) {
66581
+ if (isFilesetResource(p))
66582
+ return;
66583
+ if (p.endsWith(".lock"))
66584
+ return;
66585
+ let typ;
66586
+ try {
66587
+ typ = getTypeStrFromPath(p);
66588
+ } catch {
66589
+ return;
66590
+ }
66591
+ return typ === "variable" || typ === "resource" ? typ : undefined;
66592
+ }
66593
+ function secretBearingObjectPath(p) {
66594
+ const normalized = p.replaceAll(SEP9, "/");
66595
+ return secretBearingObjectKind(p) === "resource" ? removeResourceSuffix(normalized) : normalized.replace(/\.variable\.(yaml|json)$/, "");
66596
+ }
66597
+ function describeSecretBearingChanges(changes) {
66598
+ const objects = { variable: new Set, resource: new Set };
66599
+ for (const c of changes) {
66600
+ const kind = secretBearingObjectKind(c.path);
66601
+ if (kind)
66602
+ objects[kind].add(secretBearingObjectPath(c.path));
66603
+ }
66604
+ return ["variable", "resource"].filter((k) => objects[k].size > 0).map((k) => `${objects[k].size} ${k}${objects[k].size > 1 ? "s" : ""}`).join(" and ");
66605
+ }
66513
66606
  function removesDbtDescriptor(change) {
66514
66607
  return isDbtDescriptorPath(change.path) && (change.name === "added" && change.content === "" || change.name === "edited" && change.after === "");
66515
66608
  }
@@ -68318,6 +68411,10 @@ ${pushedCount} of ${changes.length} changes pushed to the remote workspace ${wor
68318
68411
  info(colors.bold.green.underline(`
68319
68412
  Done! All ${changes.length} changes pushed to the remote workspace ${workspace.workspaceId} named ${workspace.name} (${(performance.now() - start).toFixed(0)}ms)`));
68320
68413
  }
68414
+ const deletedSecretBearing = changes.filter((c) => c.name === "deleted" && secretBearingObjectKind(c.path) !== undefined && !failedChanges.some((f) => f.path === c.path));
68415
+ if (deletedSecretBearing.length > 0) {
68416
+ info(colors.gray(`${describeSecretBearingChanges(deletedSecretBearing)} deleted. The workspace trashbin keeps a deleted item for three days; a workspace admin can restore it with \`wmill trash list\` and \`wmill trash restore <id>\`, or from Workspace settings -> Trashbin.`));
68417
+ }
68321
68418
  if (failedChanges.length > 0) {
68322
68419
  process.exitCode = 1;
68323
68420
  }
@@ -68377,7 +68474,6 @@ var init_sync = __esm(async () => {
68377
68474
  init_log();
68378
68475
  init_esm2();
68379
68476
  init_services_gen();
68380
- init_git();
68381
68477
  init_path_assigner();
68382
68478
  init_extractor();
68383
68479
  await __promiseAll([
@@ -68396,6 +68492,7 @@ var init_sync = __esm(async () => {
68396
68492
  init_conf(),
68397
68493
  init_permissioned_as(),
68398
68494
  init_specific_items(),
68495
+ init_git(),
68399
68496
  init_types(),
68400
68497
  init_codebase(),
68401
68498
  init_metadata(),
@@ -75912,10 +76009,10 @@ var init_trigger = __esm(async () => {
75912
76009
  init_mod6();
75913
76010
  init_colors2();
75914
76011
  init_log();
75915
- init_git();
75916
76012
  await __promiseAll([
75917
76013
  init_types(),
75918
76014
  init_specific_items(),
76015
+ init_git(),
75919
76016
  init_auth(),
75920
76017
  init_context(),
75921
76018
  init_permissioned_as(),
@@ -77981,13 +78078,13 @@ var init_pull2 = __esm(async () => {
77981
78078
  init_colors2();
77982
78079
  init_log();
77983
78080
  init_services_gen();
77984
- init_git();
77985
78081
  await __promiseAll([
77986
78082
  init_auth(),
77987
78083
  init_context(),
77988
78084
  init_conf(),
77989
78085
  init_sync(),
77990
78086
  init_utils(),
78087
+ init_git(),
77991
78088
  init_legacySettings(),
77992
78089
  init_utils2()
77993
78090
  ]);
@@ -78243,10 +78340,10 @@ var init_status = __esm(async () => {
78243
78340
  init_colors2();
78244
78341
  init_log();
78245
78342
  init_services_gen();
78246
- init_git();
78247
78343
  await __promiseAll([
78248
78344
  init_auth(),
78249
- init_context()
78345
+ init_context(),
78346
+ init_git()
78250
78347
  ]);
78251
78348
  });
78252
78349
 
@@ -78393,6 +78490,8 @@ No CI workflow runs \`wmill sync push\` automatically, so deploy directly from t
78393
78490
  - \`wmill sync push --dry-run\` to preview.
78394
78491
  - \`wmill sync push\` to apply.
78395
78492
 
78493
+ A push deletes remote items that have no local file. They land in the workspace trashbin for three days: \`wmill trash list\` shows them and \`wmill trash restore <id>\` puts one back (both need a workspace admin).
78494
+
78396
78495
  ### In both cases
78397
78496
 
78398
78497
  Only deploy when the user explicitly asks to deploy, publish, push, or ship — not when they say "run", "try", or "test". For testing local edits use the per-entity \`preview\` commands (\`wmill script preview\`, \`wmill flow preview\`) — they don't deploy.
@@ -84013,7 +84112,7 @@ Reference a specific resource using \`$res:\` prefix:
84013
84112
 
84014
84113
  ## OpenFlow Schema
84015
84114
 
84016
- {"OpenFlow":{"type":"object","description":"Top-level flow definition containing metadata, configuration, and the flow structure","properties":{"summary":{"type":"string","description":"Short description of what this flow does"},"description":{"type":"string","description":"Detailed documentation for this flow"},"value":{"$ref":"#/components/schemas/FlowValue"},"schema":{"type":"object","description":"JSON Schema for flow inputs. Use this to define input parameters, their types, defaults, and validation. For resource inputs, set type to 'object' and format to 'resource-<type>' (e.g., 'resource-stripe')"},"on_behalf_of_email":{"type":"string","description":"Address of the account the flow runs on behalf of. Derived from on_behalf_of on read; accepted on write, where it is resolved to the account it names."},"on_behalf_of":{"type":"string","description":"The flow runs with the permissions of this identity: u/{username}, g/{group}, or a bare email when the username is itself email-shaped. The only stored half of the identity; on_behalf_of_email is derived from it. Omit it when writing and it is resolved from that address instead."}},"required":["summary","value"]},"FlowValue":{"type":"object","description":"The flow structure containing modules and optional preprocessor/failure handlers","properties":{"modules":{"type":"array","description":"Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch","items":{"$ref":"#/components/schemas/FlowModule"}},"failure_module":{"description":"Special module that executes when the flow fails. Receives error object with message, name, stack, and step_id. Must have id 'failure'. Only supports script/rawscript types","$ref":"#/components/schemas/FlowModule"},"preprocessor_module":{"description":"Special module that runs before the first step on external triggers. Must have id 'preprocessor'. Only supports script/rawscript types. Cannot reference other step results","$ref":"#/components/schemas/FlowModule"},"same_worker":{"type":"boolean","description":"If true, all steps run on the same worker for better performance"},"preserve_step_tags":{"type":"boolean","description":"If true and the flow runs on a custom worker tag, steps that declare their own non-empty tag run on it instead of inheriting the flow tag. Steps without their own tag still inherit the flow tag."},"concurrent_limit":{"type":"number","description":"Maximum number of concurrent executions of this flow"},"concurrency_key":{"type":"string","description":"Expression to group concurrent executions (e.g., by user ID)"},"concurrency_time_window_s":{"type":"number","description":"Time window in seconds for concurrent_limit"},"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce flow executions"},"debounce_key":{"type":"string","description":"Expression to group debounced executions"},"debounce_args_to_accumulate":{"type":"array","description":"Arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds that a job can be debounced"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of times a job can be debounced"},"skip_expr":{"type":"string","description":"JavaScript expression to conditionally skip the entire flow"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for flow results"},"cache_ignore_s3_path":{"type":"boolean"},"delete_after_secs":{"type":"integer","description":"If set, delete the flow job's args, result and logs after this many seconds following job completion"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note (e.g., \\"yellow\\", \\"#ffff00\\")"},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor"}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."},"error_include_result":{"type":"boolean","description":"When stopping with an error (error_message set), embed the stopping step's own result inside the raised error object (as error.result) instead of discarding it. The top-level result stays { error }. Defaults to false."}},"required":["expr"]},"FlowModule":{"type":"object","description":"A single step in a flow. Can be a script, subflow, loop, or branch","properties":{"id":{"type":"string","description":"Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)"},"value":{"$ref":"#/components/schemas/FlowModuleValue"},"stop_after_if":{"description":"Early termination condition evaluated after this step completes","$ref":"#/components/schemas/StopAfterIf"},"stop_after_all_iters_if":{"description":"For loops only - early termination condition evaluated after all iterations complete","$ref":"#/components/schemas/StopAfterIf"},"skip_if":{"type":"object","description":"Conditionally skip this step based on previous results or flow inputs","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'"}},"required":["expr"]},"sleep":{"description":"Delay before executing this step (in seconds or as expression)","$ref":"#/components/schemas/InputTransform"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for this step's results"},"cache_ignore_s3_path":{"type":"boolean"},"timeout":{"description":"Maximum execution time in seconds (static value or expression)","$ref":"#/components/schemas/InputTransform"},"delete_after_secs":{"type":"integer","description":"If set, delete the step's args, result and logs after this many seconds following job completion"},"summary":{"type":"string","description":"Short description of what this step does"},"mock":{"type":"object","description":"Mock configuration for testing without executing the actual step","properties":{"enabled":{"type":"boolean","description":"If true, return mock value instead of executing"},"return_value":{"description":"Value to return when mocked"}}},"suspend":{"type":"object","description":"Configuration for approval/resume steps that wait for user input","properties":{"required_events":{"type":"integer","description":"Number of approvals required before continuing"},"timeout":{"type":"integer","description":"Timeout in seconds before auto-continuing or canceling"},"resume_form":{"type":"object","description":"Form schema for collecting input when resuming","properties":{"schema":{"type":"object","description":"JSON Schema for the resume form"}}},"user_auth_required":{"type":"boolean","description":"If true, only authenticated users can approve"},"user_groups_required":{"description":"Expression or list of groups that can approve","$ref":"#/components/schemas/InputTransform"},"self_approval_disabled":{"type":"boolean","description":"If true, the user who started the flow cannot approve"},"hide_cancel":{"type":"boolean","description":"If true, hide the cancel button on the approval form"},"continue_on_disapprove_timeout":{"type":"boolean","description":"If true, continue flow on timeout instead of canceling"},"skin":{"type":"string","enum":["detailed","minimal"],"description":"How the approval request is presented, on the approval page and in Slack/Teams approval messages. 'detailed' (used when unset) shows the flow details (arguments, graph, approvers); 'minimal' shows only the request: the step description, form and approve/reject actions"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside for loops, use 'flow_input.iter.value' for the current iteration value (in while loops it equals 'flow_input.iter.index')","properties":{"expr":{"type":"string","description":"JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)"},"type":{"type":"string","enum":["javascript"]}},"required":["expr","type"]},"AiTransform":{"type":"object","description":"Value resolved by the AI runtime for this input. The AI engine decides how to satisfy the parameter.","properties":{"type":{"type":"string","enum":["ai"]}},"required":["type"]},"AIProviderKind":{"type":"string","description":"Supported AI provider types","enum":["openai","azure_openai","azure_foundry","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"},"reasoning_effort":{"type":"string","description":"Provider-native reasoning effort token (e.g. 'low', 'high', 'none') for models that support extended thinking. Optional; unset leaves the provider default."}},"required":["kind","resource","model"]},"StaticProviderTransform":{"type":"object","description":"Static provider configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/ProviderConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"ProviderTransform":{"description":"Provider configuration - can be static (ProviderConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticProviderTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticProviderTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"MemoryOff":{"type":"object","description":"No conversation memory/context","properties":{"kind":{"type":"string","enum":["off"]}},"required":["kind"]},"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","bunnative","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","rlang","duckdb"]},"path":{"type":"string","description":"Optional path for saving this script"},"lock":{"type":"string","description":"Lock file content for dependencies"},"type":{"type":"string","enum":["rawscript"]},"tag":{"type":"string","description":"Worker group tag for execution routing"},"concurrent_limit":{"type":"number","description":"Maximum concurrent executions of this script"},"concurrency_time_window_s":{"type":"number","description":"Time window for concurrent_limit"},"custom_concurrency_key":{"type":"string","description":"Custom key for grouping concurrent executions"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"},"assets":{"type":"array","description":"External resources this script accesses (S3 objects, resources, etc.)","items":{"type":"object","required":["path","kind"],"properties":{"path":{"type":"string","description":"Path to the asset"},"kind":{"type":"string","description":"Type of asset","enum":["s3object","resource","ducklake","datatable","volume","dbt"]},"access_type":{"type":"string","nullable":true,"description":"Access level for this asset","enum":["r","w","rw"]},"alt_access_type":{"type":"string","nullable":true,"description":"Alternative access level","enum":["r","w","rw"]}}}}},"required":["type","content","language","input_transforms"]},"PathScript":{"type":"object","description":"Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the script in the workspace (e.g., 'f/scripts/send_email')"},"hash":{"type":"string","description":"Optional specific version hash of the script to use"},"type":{"type":"string","enum":["script"]},"tag_override":{"type":"string","description":"Override the script's default worker group tag"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"}},"required":["type","path","input_transforms"]},"PathFlow":{"type":"object","description":"Reference to an existing flow by path. Use this to call another flow as a subflow","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the flow in the workspace (e.g., 'f/flows/process_user')"},"type":{"type":"string","enum":["flow"]}},"required":["type","path","input_transforms"]},"ForloopFlow":{"type":"object","description":"Executes nested modules in a loop over an iterator. Inside the loop, use 'flow_input.iter.value' to access the current iteration value, and 'flow_input.iter.index' for the index. Supports parallel execution for better performance on I/O-bound operations","properties":{"modules":{"type":"array","description":"Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'","items":{"$ref":"#/components/schemas/FlowModule"}},"iterator":{"description":"JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'","$ref":"#/components/schemas/InputTransform"},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["forloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","iterator","skip_failures","type"]},"WhileloopFlow":{"type":"object","description":"Executes nested modules repeatedly until stopped. The implicit iterator is the iteration counter, so 'flow_input.iter.value' equals 'flow_input.iter.index' (0, 1, 2, ...) and never carries state. To carry state across iterations, a step reads its own previous-iteration result via 'results.<its_own_id>' with a first-iteration fallback - the loop's stop_after_if must then be on that inner step (a plain single-step body with stop_after_if on the loop module does not resolve 'results' across iterations and never terminates); plain counters can instead be derived from 'flow_input.iter.index', which works in every configuration. stop_after_if is evaluated after each iteration - on the loop module 'result' is the last iteration's result","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration","items":{"$ref":"#/components/schemas/FlowModule"}},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["whileloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (use with caution in while loops)"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","skip_failures","type"]},"BranchOne":{"type":"object","description":"Conditional branching where only the first matching branch executes. Branches are evaluated in order, and the first one with a true expression runs. If no branches match, the default branch executes","properties":{"branches":{"type":"array","description":"Array of branches to evaluate in order. The first branch with expr evaluating to true executes","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch condition"},"expr":{"type":"string","description":"JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins"},"modules":{"type":"array","description":"Steps to execute if this branch's expr is true","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules","expr"]}},"default":{"type":"array","description":"Steps to execute if no branch expressions match","items":{"$ref":"#/components/schemas/FlowModule"}},"type":{"type":"string","enum":["branchone"]}},"required":["branches","default","type"]},"BranchAll":{"type":"object","description":"Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently","properties":{"branches":{"type":"array","description":"Array of branches that all execute (either in parallel or sequentially)","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch's purpose"},"skip_failure":{"type":"boolean","description":"If true, failure in this branch doesn't fail the entire flow"},"modules":{"type":"array","description":"Steps to execute in this branch","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules"]}},"type":{"type":"string","enum":["branchall"]},"parallel":{"type":"boolean","description":"If true, all branches execute concurrently. If false, they execute sequentially"}},"required":["branches","type"]},"AgentTool":{"type":"object","description":"A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool","properties":{"id":{"type":"string","description":"Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')"},"summary":{"type":"string","description":"The name the AI agent calls this tool by, not a human label. On a flowmodule tool it must match ^[a-zA-Z0-9_]+$ - letters, numbers and underscores only (e.g. 'search_documentation', not 'Search documentation') - and always be set; on an mcp or websearch tool it is a plain label. Put the human-readable explanation in 'description'."},"description":{"type":"string","description":"Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script."},"value":{"$ref":"#/components/schemas/ToolValue"}},"required":["id","value"]},"ToolValue":{"description":"The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference","oneOf":[{"$ref":"#/components/schemas/FlowModuleTool"},{"$ref":"#/components/schemas/McpToolValue"},{"$ref":"#/components/schemas/WebsearchToolValue"}],"discriminator":{"propertyName":"tool_type","mapping":{"flowmodule":"#/components/schemas/FlowModuleTool","mcp":"#/components/schemas/McpToolValue","websearch":"#/components/schemas/WebsearchToolValue"}}},"FlowModuleTool":{"description":"A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module","allOf":[{"type":"object","properties":{"tool_type":{"type":"string","enum":["flowmodule"]}},"required":["tool_type"]},{"$ref":"#/components/schemas/FlowModuleValue"}]},"WebsearchToolValue":{"type":"object","description":"A tool implemented as a websearch tool. The AI can call this like any other websearch tool","properties":{"tool_type":{"type":"string","enum":["websearch"]}},"required":["tool_type"]},"McpToolValue":{"type":"object","description":"Reference to an external MCP (Model Context Protocol) tool. The AI can call tools from MCP servers","properties":{"tool_type":{"type":"string","enum":["mcp"]},"resource_path":{"type":"string","description":"Path to the MCP resource/server configuration"},"include_tools":{"type":"array","description":"Whitelist of specific tools to include from this MCP server","items":{"type":"string"}},"exclude_tools":{"type":"array","description":"Blacklist of tools to exclude from this MCP server","items":{"type":"string"}}},"required":["tool_type","resource_path"]},"AiAgent":{"type":"object","description":"AI agent step that can use tools to accomplish tasks. The agent receives inputs and can call any of its configured tools to complete the task","properties":{"input_transforms":{"type":"object","description":"Input parameters for the AI agent mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"output_type":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Output format type.\\nValid values: 'text' (default) - plain text response, 'image' - image generation\\n"},"user_message":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"The user's prompt/message to the AI agent. Supports variable interpolation with 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, reasoning_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"},"max_iterations":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Number. Limits how many times the agent can loop through reasoning and tool use.\\nRange: 1-1000.\\n"}},"required":["user_message"]},"tools":{"type":"array","description":"Array of tools the agent can use. The agent decides which tools to call based on the task","items":{"$ref":"#/components/schemas/AgentTool"}},"type":{"type":"string","enum":["aiagent"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the AI agent step runs on the flow's tag (default \`flow\`)"},"omit_output_from_conversation":{"type":"boolean","default":false,"description":"If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled."},"agent":{"type":"string","description":"Path of a reusable \`ai_agent\` resource (hybrid linking). When set, the agent brain\\nconfig (provider/model/system prompt/etc.) and tool set are resolved at runtime from\\nthat resource; the module's input_transforms then only carry the flow-local inputs\\n(user_message/user_attachments).\\n"},"tool_inputs":{"type":"object","description":"Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the\\nreferenced agent's tools to this flow's context (flow_input/results) without mutating the\\nshared resource; overlaid onto the tools' input_transforms at runtime \\u2014 including when\\n\`agent\` is unset, since a step forked for editing keeps these overrides until it is saved\\nback or unlinked.\\n","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}}},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["type","input_transforms"]},"Identity":{"type":"object","description":"Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder","properties":{"type":{"type":"string","enum":["identity"]},"flow":{"type":"boolean","description":"If true, marks this as a flow identity (special handling)"}},"required":["type"]},"FlowStatus":{"type":"object","properties":{"step":{"type":"integer"},"modules":{"type":"array","items":{"$ref":"#/components/schemas/FlowStatusModule"}},"user_states":{"additionalProperties":true},"preprocessor_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"}]},"failure_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"},{"type":"object","properties":{"parent_module":{"type":"string"}}}]},"retry":{"type":"object","properties":{"fail_count":{"type":"integer"},"failed_jobs":{"type":"array","items":{"type":"string","format":"uuid"}}}}},"required":["step","modules","failure_module"]},"FlowStatusModule":{"type":"object","properties":{"type":{"type":"string","enum":["WaitingForPriorSteps","WaitingForEvents","WaitingForExecutor","InProgress","Success","Failure"]},"id":{"type":"string"},"job":{"type":"string","format":"uuid"},"count":{"type":"integer"},"progress":{"type":"integer"},"iterator":{"type":"object","properties":{"index":{"type":"integer"},"itered":{"type":"array","items":{}},"itered_len":{"type":"integer"},"args":{}}},"flow_jobs":{"type":"array","items":{"type":"string"}},"flow_jobs_success":{"type":"array","items":{"type":"boolean"}},"flow_jobs_duration":{"type":"object","properties":{"started_at":{"type":"array","items":{"type":"string"}},"duration_ms":{"type":"array","items":{"type":"integer"}}}},"branch_chosen":{"type":"object","properties":{"type":{"type":"string","enum":["branch","default"]},"branch":{"type":"integer"}},"required":["type"]},"branchall":{"type":"object","properties":{"branch":{"type":"integer"},"len":{"type":"integer"}},"required":["branch","len"]},"approvers":{"type":"array","items":{"type":"object","properties":{"resume_id":{"type":"integer"},"approver":{"type":"string"}},"required":["resume_id","approver"]}},"failed_retries":{"type":"array","items":{"type":"string","format":"uuid"}},"skipped":{"type":"boolean"},"agent_actions":{"type":"array","items":{"type":"object","oneOf":[{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"type":{"type":"string","enum":["tool_call"]},"module_id":{"type":"string"}},"required":["job_id","function_name","type","module_id"]},{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"resource_path":{"type":"string"},"type":{"type":"string","enum":["mcp_tool_call"]},"arguments":{"type":"object"}},"required":["call_id","function_name","resource_path","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]}},"required":["content","type"]}]}},"agent_actions_success":{"type":"array","items":{"type":"boolean"}}},"required":["type"]}}`,
84115
+ {"OpenFlow":{"type":"object","description":"Top-level flow definition containing metadata, configuration, and the flow structure","properties":{"summary":{"type":"string","description":"Short description of what this flow does"},"description":{"type":"string","description":"Detailed documentation for this flow"},"value":{"$ref":"#/components/schemas/FlowValue"},"schema":{"type":"object","description":"JSON Schema for flow inputs. Use this to define input parameters, their types, defaults, and validation. For resource inputs, set type to 'object' and format to 'resource-<type>' (e.g., 'resource-stripe')"},"on_behalf_of_email":{"type":"string","description":"Address of the account the flow runs on behalf of. Derived from on_behalf_of on read; accepted on write, where it is resolved to the account it names."},"on_behalf_of":{"type":"string","description":"The flow runs with the permissions of this identity: u/{username}, g/{group}, or a bare email when the username is itself email-shaped. The only stored half of the identity; on_behalf_of_email is derived from it. Omit it when writing and it is resolved from that address instead."}},"required":["summary","value"]},"FlowValue":{"type":"object","description":"The flow structure containing modules and optional preprocessor/failure handlers","properties":{"modules":{"type":"array","description":"Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch","items":{"$ref":"#/components/schemas/FlowModule"}},"failure_module":{"description":"Special module that executes when the flow fails. Receives error object with message, name, stack, and step_id. Must have id 'failure'. Only supports script/rawscript types","$ref":"#/components/schemas/FlowModule"},"preprocessor_module":{"description":"Special module that runs before the first step on external triggers. Must have id 'preprocessor'. Only supports script/rawscript types. Cannot reference other step results","$ref":"#/components/schemas/FlowModule"},"same_worker":{"type":"boolean","description":"If true, all steps run on the same worker for better performance"},"preserve_step_tags":{"type":"boolean","description":"If true and the flow runs on a custom worker tag, steps that declare their own non-empty tag run on it instead of inheriting the flow tag. Steps without their own tag still inherit the flow tag."},"concurrent_limit":{"type":"number","description":"Maximum number of concurrent executions of this flow"},"concurrency_key":{"type":"string","description":"Expression to group concurrent executions (e.g., by user ID)"},"concurrency_time_window_s":{"type":"number","description":"Time window in seconds for concurrent_limit"},"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce flow executions"},"debounce_key":{"type":"string","description":"Expression to group debounced executions"},"debounce_args_to_accumulate":{"type":"array","description":"Arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds that a job can be debounced"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of times a job can be debounced"},"skip_expr":{"type":"string","description":"JavaScript expression to conditionally skip the entire flow"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for flow results"},"cache_ignore_s3_path":{"type":"boolean"},"delete_after_secs":{"type":"integer","description":"If set, delete the flow job's args, result and logs after this many seconds following job completion"},"flow_env":{"type":"object","description":"Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource).","additionalProperties":{}},"priority":{"type":"number","description":"Execution priority (higher numbers run first)"},"early_return":{"type":"string","description":"JavaScript expression to return early from the flow"},"chat_input_enabled":{"type":"boolean","description":"Whether this flow accepts chat-style input"},"notes":{"type":"array","description":"Sticky notes attached to the flow","items":{"$ref":"#/components/schemas/FlowNote"}},"groups":{"type":"array","description":"Semantic groups of modules for organizational purposes","items":{"$ref":"#/components/schemas/FlowGroup"}}},"required":["modules"]},"Retry":{"type":"object","description":"Retry configuration for failed module executions","properties":{"constant":{"type":"object","description":"Retry with constant delay between attempts","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"seconds":{"type":"integer","description":"Seconds to wait between retries"}}},"exponential":{"type":"object","description":"Retry with exponential backoff (delay doubles each time)","properties":{"attempts":{"type":"integer","description":"Number of retry attempts"},"multiplier":{"type":"integer","description":"Multiplier for exponential backoff"},"seconds":{"type":"integer","minimum":1,"description":"Initial delay in seconds"},"random_factor":{"type":"integer","minimum":0,"maximum":100,"description":"Random jitter percentage (0-100) to avoid thundering herd"}}},"retry_if":{"$ref":"#/components/schemas/RetryIf"}}},"FlowNote":{"type":"object","description":"A sticky note attached to a flow for documentation and annotation","properties":{"id":{"type":"string","description":"Unique identifier for the note"},"text":{"type":"string","description":"Content of the note"},"position":{"type":"object","description":"Position of the note in the flow editor","properties":{"x":{"type":"number","description":"X coordinate"},"y":{"type":"number","description":"Y coordinate"}},"required":["x","y"]},"size":{"type":"object","description":"Size of the note in the flow editor","properties":{"width":{"type":"number","description":"Width in pixels"},"height":{"type":"number","description":"Height in pixels"}},"required":["width","height"]},"color":{"type":"string","description":"Color of the note (e.g., \\"yellow\\", \\"#ffff00\\")"},"type":{"type":"string","enum":["free","group"],"description":"Type of note - 'free' for standalone notes, 'group' for notes that group other nodes"},"locked":{"type":"boolean","default":false,"description":"Whether the note is locked and cannot be edited or moved"},"contained_node_ids":{"type":"array","items":{"type":"string"},"description":"For group notes, the IDs of nodes contained within this group"}},"required":["id","text","color","type"]},"FlowGroup":{"type":"object","description":"A semantic group of flow modules for organizational purposes. Does not affect execution \\u2014 modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.","properties":{"summary":{"type":"string","description":"Display name for this group"},"note":{"type":"string","description":"Markdown note shown below the group header"},"autocollapse":{"type":"boolean","default":false,"description":"If true, this group is collapsed by default in the flow editor. UI hint only."},"start_id":{"type":"string","description":"ID of the first flow module in this group (topological entry point)"},"end_id":{"type":"string","description":"ID of the last flow module in this group (topological exit point)"},"color":{"type":"string","description":"Color for the group in the flow editor"}},"required":["start_id","end_id"]},"RetryIf":{"type":"object","description":"Conditional retry based on error or result","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables"}},"required":["expr"]},"StopAfterIf":{"type":"object","description":"Early termination condition for a module","properties":{"skip_if_stopped":{"type":"boolean","description":"If true, following steps are skipped when this condition triggers"},"expr":{"type":"string","description":"JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop"},"error_message":{"type":"string","nullable":true,"description":"Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised."},"error_include_result":{"type":"boolean","description":"When stopping with an error (error_message set), embed the stopping step's own result inside the raised error object (as error.result) instead of discarding it. The top-level result stays { error }. Defaults to false."}},"required":["expr"]},"FlowModule":{"type":"object","description":"A single step in a flow. Can be a script, subflow, loop, or branch","properties":{"id":{"type":"string","description":"Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)"},"value":{"$ref":"#/components/schemas/FlowModuleValue"},"stop_after_if":{"description":"Early termination condition evaluated after this step completes","$ref":"#/components/schemas/StopAfterIf"},"stop_after_all_iters_if":{"description":"For loops only - early termination condition evaluated after all iterations complete","$ref":"#/components/schemas/StopAfterIf"},"skip_if":{"type":"object","description":"Conditionally skip this step based on previous results or flow inputs","properties":{"expr":{"type":"string","description":"JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'"}},"required":["expr"]},"sleep":{"description":"Delay before executing this step (in seconds or as expression)","$ref":"#/components/schemas/InputTransform"},"cache_ttl":{"type":"number","description":"Cache duration in seconds for this step's results"},"cache_ignore_s3_path":{"type":"boolean"},"timeout":{"description":"Maximum execution time in seconds (static value or expression)","$ref":"#/components/schemas/InputTransform"},"delete_after_secs":{"type":"integer","description":"If set, delete the step's args, result and logs after this many seconds following job completion"},"summary":{"type":"string","description":"Short description of what this step does"},"mock":{"type":"object","description":"Mock configuration for testing without executing the actual step","properties":{"enabled":{"type":"boolean","description":"If true, return mock value instead of executing"},"return_value":{"description":"Value to return when mocked"}}},"suspend":{"type":"object","description":"Configuration for approval/resume steps that wait for user input","properties":{"required_events":{"type":"integer","description":"Number of approvals required before continuing"},"timeout":{"type":"integer","description":"Timeout in seconds before auto-continuing or canceling"},"resume_form":{"type":"object","description":"Form schema for collecting input when resuming","properties":{"schema":{"type":"object","description":"JSON Schema for the resume form"}}},"user_auth_required":{"type":"boolean","description":"If true, only authenticated users can approve"},"user_groups_required":{"description":"Expression or list of groups that can approve","$ref":"#/components/schemas/InputTransform"},"self_approval_disabled":{"type":"boolean","description":"If true, the user who started the flow cannot approve"},"hide_cancel":{"type":"boolean","description":"If true, hide the cancel button on the approval form"},"continue_on_disapprove_timeout":{"type":"boolean","description":"If true, continue flow on timeout instead of canceling"},"skin":{"type":"string","enum":["detailed","minimal"],"description":"How the approval request is presented, on the approval page and in Slack/Teams approval messages. 'detailed' (used when unset) shows the flow details (arguments, graph, approvers); 'minimal' shows only the request: the step description, form and approve/reject actions"}}},"priority":{"type":"number","description":"Execution priority for this step (higher numbers run first)"},"continue_on_error":{"type":"boolean","description":"If true, flow continues even if this step fails"},"retry":{"description":"Retry configuration if this step fails","$ref":"#/components/schemas/Retry"},"debouncing":{"description":"Debounce configuration for this step (EE only)","type":"object","properties":{"debounce_delay_s":{"type":"integer","description":"Delay in seconds to debounce this step's executions across flow runs"},"debounce_key":{"type":"string","description":"Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"},"debounce_args_to_accumulate":{"type":"array","description":"Array-type arguments to accumulate across debounced executions","items":{"type":"string"}},"max_total_debouncing_time":{"type":"integer","description":"Maximum total time in seconds before forced execution"},"max_total_debounces_amount":{"type":"integer","description":"Maximum number of debounces before forced execution"}}}},"required":["value","id"]},"InputTransform":{"description":"Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs","oneOf":[{"$ref":"#/components/schemas/StaticTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"StaticTransform":{"type":"object","description":"Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'","properties":{"value":{"description":"The static value. For resources, use format '$res:path/to/resource'"},"type":{"type":"string","enum":["static"]}},"required":["type"]},"JavascriptTransform":{"type":"object","description":"JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside for loops, use 'flow_input.iter.value' for the current iteration value (in while loops it equals 'flow_input.iter.index')","properties":{"expr":{"type":"string","description":"JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)"},"type":{"type":"string","enum":["javascript"]}},"required":["expr","type"]},"AiTransform":{"type":"object","description":"Value resolved by the AI runtime for this input. The AI engine decides how to satisfy the parameter.","properties":{"type":{"type":"string","enum":["ai"]}},"required":["type"]},"AIProviderKind":{"type":"string","description":"Supported AI provider types","enum":["openai","azure_openai","azure_foundry","anthropic","mistral","deepseek","googleai","groq","openrouter","togetherai","customai","aws_bedrock"]},"ProviderConfig":{"type":"object","description":"Complete AI provider configuration with resource reference and model selection","properties":{"kind":{"$ref":"#/components/schemas/AIProviderKind"},"resource":{"type":"string","description":"Resource reference in format '$res:{resource_path}' pointing to provider credentials"},"model":{"type":"string","description":"Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')"},"reasoning_effort":{"type":"string","description":"Provider-native reasoning effort token (e.g. 'low', 'high', 'none') for models that support extended thinking. Optional; unset leaves the provider default."}},"required":["kind","resource","model"]},"StaticProviderTransform":{"type":"object","description":"Static provider configuration passed directly to the AI agent","properties":{"value":{"$ref":"#/components/schemas/ProviderConfig"},"type":{"type":"string","enum":["static"]}},"required":["type","value"]},"ProviderTransform":{"description":"Provider configuration - can be static (ProviderConfig), JavaScript expression, or AI-determined","oneOf":[{"$ref":"#/components/schemas/StaticProviderTransform"},{"$ref":"#/components/schemas/JavascriptTransform"},{"$ref":"#/components/schemas/AiTransform"}],"discriminator":{"propertyName":"type","mapping":{"static":"#/components/schemas/StaticProviderTransform","javascript":"#/components/schemas/JavascriptTransform","ai":"#/components/schemas/AiTransform"}}},"MemoryOff":{"type":"object","description":"No conversation memory/context","properties":{"kind":{"type":"string","enum":["off"]}},"required":["kind"]},"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","bunnative","python3","go","bash","powershell","postgresql","mysql","bigquery","snowflake","mssql","oracledb","graphql","nativets","php","rust","ansible","csharp","nu","java","ruby","rlang","duckdb"]},"path":{"type":"string","description":"Optional path for saving this script"},"lock":{"type":"string","description":"Lock file content for dependencies"},"type":{"type":"string","enum":["rawscript"]},"tag":{"type":"string","description":"Worker group tag for execution routing"},"concurrent_limit":{"type":"number","description":"Maximum concurrent executions of this script"},"concurrency_time_window_s":{"type":"number","description":"Time window for concurrent_limit"},"custom_concurrency_key":{"type":"string","description":"Custom key for grouping concurrent executions"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"},"assets":{"type":"array","description":"External resources this script accesses (S3 objects, resources, etc.)","items":{"type":"object","required":["path","kind"],"properties":{"path":{"type":"string","description":"Path to the asset"},"kind":{"type":"string","description":"Type of asset","enum":["s3object","resource","ducklake","datatable","volume","dbt"]},"access_type":{"type":"string","nullable":true,"description":"Access level for this asset","enum":["r","w","rw"]},"alt_access_type":{"type":"string","nullable":true,"description":"Alternative access level","enum":["r","w","rw"]}}}}},"required":["type","content","language","input_transforms"]},"PathScript":{"type":"object","description":"Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the script in the workspace (e.g., 'f/scripts/send_email')"},"hash":{"type":"string","description":"Optional specific version hash of the script to use"},"type":{"type":"string","enum":["script"]},"tag_override":{"type":"string","description":"Override the script's default worker group tag"},"is_trigger":{"type":"boolean","description":"If true, this script is a trigger that can start the flow"}},"required":["type","path","input_transforms"]},"PathFlow":{"type":"object","description":"Reference to an existing flow by path. Use this to call another flow as a subflow","properties":{"input_transforms":{"type":"object","description":"Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}},"path":{"type":"string","description":"Path to the flow in the workspace (e.g., 'f/flows/process_user')"},"type":{"type":"string","enum":["flow"]}},"required":["type","path","input_transforms"]},"ForloopFlow":{"type":"object","description":"Executes nested modules in a loop over an iterator. Inside the loop, use 'flow_input.iter.value' to access the current iteration value, and 'flow_input.iter.index' for the index. Supports parallel execution for better performance on I/O-bound operations","properties":{"modules":{"type":"array","description":"Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'","items":{"$ref":"#/components/schemas/FlowModule"}},"iterator":{"description":"JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'","$ref":"#/components/schemas/InputTransform"},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["forloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","iterator","skip_failures","type"]},"WhileloopFlow":{"type":"object","description":"Executes nested modules repeatedly until stopped. The implicit iterator is the iteration counter, so 'flow_input.iter.value' equals 'flow_input.iter.index' (0, 1, 2, ...) and never carries state. To carry state across iterations, a step reads its own previous-iteration result via 'results.<its_own_id>' with a first-iteration fallback - the loop's stop_after_if must then be on that inner step (a plain single-step body with stop_after_if on the loop module does not resolve 'results' across iterations and never terminates); plain counters can instead be derived from 'flow_input.iter.index', which works in every configuration. stop_after_if is evaluated after each iteration - on the loop module 'result' is the last iteration's result","properties":{"modules":{"type":"array","description":"Steps to execute in each iteration","items":{"$ref":"#/components/schemas/FlowModule"}},"skip_failures":{"type":"boolean","description":"If true, iteration failures don't stop the loop. Failed iterations return null"},"type":{"type":"string","enum":["whileloopflow"]},"parallel":{"type":"boolean","description":"If true, iterations run concurrently (use with caution in while loops)"},"parallelism":{"description":"Maximum number of concurrent iterations when parallel=true","$ref":"#/components/schemas/InputTransform"},"squash":{"type":"boolean"}},"required":["modules","skip_failures","type"]},"BranchOne":{"type":"object","description":"Conditional branching where only the first matching branch executes. Branches are evaluated in order, and the first one with a true expression runs. If no branches match, the default branch executes","properties":{"branches":{"type":"array","description":"Array of branches to evaluate in order. The first branch with expr evaluating to true executes","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch condition"},"expr":{"type":"string","description":"JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins"},"modules":{"type":"array","description":"Steps to execute if this branch's expr is true","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules","expr"]}},"default":{"type":"array","description":"Steps to execute if no branch expressions match","items":{"$ref":"#/components/schemas/FlowModule"}},"type":{"type":"string","enum":["branchone"]}},"required":["branches","default","type"]},"BranchAll":{"type":"object","description":"Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently","properties":{"branches":{"type":"array","description":"Array of branches that all execute (either in parallel or sequentially)","items":{"type":"object","properties":{"summary":{"type":"string","description":"Short description of this branch's purpose"},"skip_failure":{"type":"boolean","description":"If true, failure in this branch doesn't fail the entire flow"},"modules":{"type":"array","description":"Steps to execute in this branch","items":{"$ref":"#/components/schemas/FlowModule"}}},"required":["modules"]}},"type":{"type":"string","enum":["branchall"]},"parallel":{"type":"boolean","description":"If true, all branches execute concurrently. If false, they execute sequentially"}},"required":["branches","type"]},"AgentTool":{"type":"object","description":"A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool","properties":{"id":{"type":"string","description":"Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')"},"summary":{"type":"string","description":"The name the AI agent calls this tool by, not a human label. On a flowmodule tool it must match ^[a-zA-Z0-9_]+$ - letters, numbers and underscores only (e.g. 'search_documentation', not 'Search documentation') - and always be set; on an mcp or websearch tool it is a plain label. Put the human-readable explanation in 'description'."},"description":{"type":"string","description":"Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script."},"value":{"$ref":"#/components/schemas/ToolValue"}},"required":["id","value"]},"ToolValue":{"description":"The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference","oneOf":[{"$ref":"#/components/schemas/FlowModuleTool"},{"$ref":"#/components/schemas/McpToolValue"},{"$ref":"#/components/schemas/WebsearchToolValue"}],"discriminator":{"propertyName":"tool_type","mapping":{"flowmodule":"#/components/schemas/FlowModuleTool","mcp":"#/components/schemas/McpToolValue","websearch":"#/components/schemas/WebsearchToolValue"}}},"FlowModuleTool":{"description":"A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module","allOf":[{"type":"object","properties":{"tool_type":{"type":"string","enum":["flowmodule"]}},"required":["tool_type"]},{"$ref":"#/components/schemas/FlowModuleValue"}]},"WebsearchToolValue":{"type":"object","description":"A tool implemented as a websearch tool. The AI can call this like any other websearch tool","properties":{"tool_type":{"type":"string","enum":["websearch"]}},"required":["tool_type"]},"McpToolValue":{"type":"object","description":"Reference to an external MCP (Model Context Protocol) tool. The AI can call tools from MCP servers","properties":{"tool_type":{"type":"string","enum":["mcp"]},"resource_path":{"type":"string","description":"Path to the MCP resource/server configuration"},"include_tools":{"type":"array","description":"Whitelist of specific tools to include from this MCP server","items":{"type":"string"}},"exclude_tools":{"type":"array","description":"Blacklist of tools to exclude from this MCP server","items":{"type":"string"}}},"required":["tool_type","resource_path"]},"AiAgent":{"type":"object","description":"AI agent step that can use tools to accomplish tasks. The agent receives inputs and can call any of its configured tools to complete the task","properties":{"input_transforms":{"type":"object","description":"Input parameters for the AI agent mapped to their values","properties":{"provider":{"$ref":"#/components/schemas/ProviderTransform"},"output_type":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Output format type.\\nValid values: 'text' (default) - plain text response, 'image' - image generation\\n"},"user_message":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"The user's prompt/message to the AI agent. Supports variable interpolation with 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, reasoning_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"},"enabled_tools":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Array of strings naming which of the tools configured in \`tools\` the agent may call\\nthis run. Leaving it unset carries every one of them; an empty array carries none.\\nA tool is named as the model is shown it. An entry the model is shown nothing of is\\nnamed by what identifies it instead: an MCP server by its resource path, carrying\\nevery tool it exposes (which of them stays that entry's include_tools/exclude_tools),\\nand a websearch entry by the reserved name '__wm_web_search', whatever summary it carries\\n(no tool may take that name).\\nExample: ['get_user', 'u/admin/github_mcp', '__wm_web_search']\\n"},"max_completion_tokens":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Integer. Maximum number of tokens the AI will generate in its response.\\nRange: 1 to 4,294,967,295. Typical values: 256-4096 for most use cases.\\n"},"temperature":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Float. Controls randomness/creativity of responses.\\nRange: 0.0 to 2.0 (provider-dependent)\\n- 0.0 = deterministic, focused responses\\n- 0.7 = balanced (common default)\\n- 1.0+ = more creative/random\\n"},"max_iterations":{"allOf":[{"$ref":"#/components/schemas/InputTransform"}],"description":"Number. Limits how many times the agent can loop through reasoning and tool use.\\nRange: 1-1000.\\n"}},"required":["user_message"]},"tools":{"type":"array","description":"Array of tools the agent can use. The agent decides which tools to call based on the task","items":{"$ref":"#/components/schemas/AgentTool"}},"type":{"type":"string","enum":["aiagent"]},"tag":{"type":"string","description":"Worker group tag for execution routing. If not set, the AI agent step runs on the flow's tag (default \`flow\`)"},"omit_output_from_conversation":{"type":"boolean","default":false,"description":"If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled."},"agent":{"type":"string","description":"Path of a reusable \`ai_agent\` resource (hybrid linking). When set, the agent brain\\nconfig (provider/model/system prompt/etc.) and tool set are resolved at runtime from\\nthat resource; the module's input_transforms then only carry the flow-local inputs\\n(user_message/user_attachments/enabled_tools).\\n"},"tool_inputs":{"type":"object","description":"Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the\\nreferenced agent's tools to this flow's context (flow_input/results) without mutating the\\nshared resource; overlaid onto the tools' input_transforms at runtime \\u2014 including when\\n\`agent\` is unset, since a step forked for editing keeps these overrides until it is saved\\nback or unlinked.\\n","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/InputTransform"}}},"parallel":{"type":"boolean","description":"If true, the agent can execute multiple tool calls in parallel"}},"required":["type","input_transforms"]},"Identity":{"type":"object","description":"Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder","properties":{"type":{"type":"string","enum":["identity"]},"flow":{"type":"boolean","description":"If true, marks this as a flow identity (special handling)"}},"required":["type"]},"FlowStatus":{"type":"object","properties":{"step":{"type":"integer"},"modules":{"type":"array","items":{"$ref":"#/components/schemas/FlowStatusModule"}},"user_states":{"additionalProperties":true},"preprocessor_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"}]},"failure_module":{"allOf":[{"$ref":"#/components/schemas/FlowStatusModule"},{"type":"object","properties":{"parent_module":{"type":"string"}}}]},"retry":{"type":"object","properties":{"fail_count":{"type":"integer"},"failed_jobs":{"type":"array","items":{"type":"string","format":"uuid"}}}}},"required":["step","modules","failure_module"]},"FlowStatusModule":{"type":"object","properties":{"type":{"type":"string","enum":["WaitingForPriorSteps","WaitingForEvents","WaitingForExecutor","InProgress","Success","Failure"]},"id":{"type":"string"},"job":{"type":"string","format":"uuid"},"count":{"type":"integer"},"progress":{"type":"integer"},"iterator":{"type":"object","properties":{"index":{"type":"integer"},"itered":{"type":"array","items":{}},"itered_len":{"type":"integer"},"args":{}}},"flow_jobs":{"type":"array","items":{"type":"string"}},"flow_jobs_success":{"type":"array","items":{"type":"boolean"}},"flow_jobs_duration":{"type":"object","properties":{"started_at":{"type":"array","items":{"type":"string"}},"duration_ms":{"type":"array","items":{"type":"integer"}}}},"branch_chosen":{"type":"object","properties":{"type":{"type":"string","enum":["branch","default"]},"branch":{"type":"integer"}},"required":["type"]},"branchall":{"type":"object","properties":{"branch":{"type":"integer"},"len":{"type":"integer"}},"required":["branch","len"]},"approvers":{"type":"array","items":{"type":"object","properties":{"resume_id":{"type":"integer"},"approver":{"type":"string"}},"required":["resume_id","approver"]}},"failed_retries":{"type":"array","items":{"type":"string","format":"uuid"}},"skipped":{"type":"boolean"},"agent_actions":{"type":"array","items":{"type":"object","oneOf":[{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"type":{"type":"string","enum":["tool_call"]},"module_id":{"type":"string"}},"required":["job_id","function_name","type","module_id"]},{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"function_name":{"type":"string"},"resource_path":{"type":"string"},"type":{"type":"string","enum":["mcp_tool_call"]},"arguments":{"type":"object"}},"required":["call_id","function_name","resource_path","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["message"]}},"required":["content","type"]}]}},"agent_actions_success":{"type":"array","items":{"type":"boolean"}}},"required":["type"]}}`,
84017
84116
  "raw-app": `---
84018
84117
  name: raw-app
84019
84118
  description: MUST use when creating raw apps.
@@ -84346,6 +84445,19 @@ An app can be demoed by recording a session: every interaction becomes a step ca
84346
84445
 
84347
84446
  Apply it to customer data, internal notes and anything else a viewer of the demo should not see. It costs nothing when the app is never recorded.
84348
84447
 
84448
+ ### Chat UIs over a flow in chat mode
84449
+
84450
+ A flow deployed with chat mode on is a chat backend (streaming answer, tool calls, memory, conversation history). Do not drive it through a runnable: add \`windmill-chat\` to \`package.json\` and use it directly, it detects the app's Windmill and credential.
84451
+
84452
+ \`\`\`tsx
84453
+ import { useWindmillChat } from 'windmill-chat/react'
84454
+
84455
+ const chat = useWindmillChat({ flowPath: 'f/support/assistant' })
84456
+ // chat.messages ({ role, content, pending, success, tool? }), chat.status, chat.sendMessage(text), chat.stop()
84457
+ \`\`\`
84458
+
84459
+ \`windmill-chat/ai-sdk\` gives a \`ChatTransport\` for the Vercel AI SDK's \`useChat\`, \`windmill-chat/assistant-ui\` a runtime for assistant-ui. The flow must be deployed, not a draft. A sandboxed app needs \`jobs:run\` in its frontend SDK scopes, plus \`flow_conversations:write\` for the conversation sidebar; without them the chat keeps history in the browser.
84460
+
84349
84461
  ## Backend runnables
84350
84462
 
84351
84463
  Each runnable has a unique key (used to call it from the frontend) and one of four types:
@@ -84474,6 +84586,7 @@ def main(user_id: str):
84474
84586
  6. **Mark sensitive UI with \`data-wm-no-record\`** — it is what keeps that data out of a recorded demo; passwords are handled for you.
84475
84587
  7. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
84476
84588
  8. **Deploy what a path runnable points at** — a path runnable aimed at a draft fails at runtime; tell the user what needs deploying.
84589
+ 9. **Use \`windmill-chat\` for a chat over a chat-mode flow** — never a runnable that runs the flow and polls its stream.
84477
84590
  `,
84478
84591
  triggers: `---
84479
84592
  name: triggers
@@ -86159,6 +86272,27 @@ Manage API tokens
86159
86272
  - \`--expiration <expiration:string>\` - Token expiration (ISO 8601 timestamp)
86160
86273
  - \`token delete <token_prefix:string>\` - Delete a token by its prefix
86161
86274
 
86275
+ ### trash
86276
+
86277
+ List, inspect and restore items deleted in the last three days (requires admin)
86278
+
86279
+ **Options:**
86280
+ - \`--json\` - Output as JSON (for piping to jq)
86281
+ - \`--kind <kind:string>\` - Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger
86282
+ - \`--limit <limit:integer>\` - Number of items to return (default 100, max 1000)
86283
+ - \`--page <page:integer>\` - Page to return, starting at 1
86284
+
86285
+ **Subcommands:**
86286
+
86287
+ - \`trash list\` - List trashed items, most recently deleted first
86288
+ - \`--json\` - Output as JSON (for piping to jq)
86289
+ - \`--kind <kind:string>\` - Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger
86290
+ - \`--limit <limit:integer>\` - Number of items to return (default 100, max 1000)
86291
+ - \`--page <page:integer>\` - Page to return, starting at 1
86292
+ - \`trash get <id:integer>\` - Show a trashed item and the data it was deleted with
86293
+ - \`--json\` - Output as JSON (for piping to jq)
86294
+ - \`trash restore <ids...:integer>\` - Put trashed items back at their paths
86295
+
86162
86296
  ### trigger
86163
86297
 
86164
86298
  trigger related commands
@@ -86962,6 +87096,21 @@ properties:
86962
87096
  type: boolean
86963
87097
  description: If true, passes the request body as a raw string instead of parsing
86964
87098
  as JSON
87099
+ allowed_origins:
87100
+ type: array
87101
+ items:
87102
+ type: string
87103
+ description: 'Origins allowed to call this route cross-origin, matched against
87104
+ the request''s Origin header (ignoring case) and echoed back on a match. When
87105
+ set, the list governs both the preflight and the response, overriding any Access-Control-Allow-Origin
87106
+ the runnable returns via wm_headers. Use [''*''] to opt out of any restriction,
87107
+ including the http_route_default_allowed_origins instance setting. An empty
87108
+ list is not a configuration and resolves exactly as null does. When null, the
87109
+ instance setting applies, or Access-Control-Allow-Origin: * if it is unset.
87110
+ Ignored on a static website, which has no authentication of its own and so hands
87111
+ out public files: restricting which browsers may read them protects nothing
87112
+ while breaking cross-origin webfonts and fetches. A single-file static asset
87113
+ is not exempt, since it can carry an authentication_method.'
86965
87114
  error_handler_path:
86966
87115
  type: string
86967
87116
  description: Path to a script to run when the triggered job fails. A bare path,
@@ -89537,7 +89686,7 @@ async function pull2(opts) {
89537
89686
  info("failed to parse schema for " + x.name);
89538
89687
  continue;
89539
89688
  }
89540
- if (resourceTypes.find((y) => y.name === x.name && typeof y.schema !== "string" && deepEqual(y.schema, x.schema) && y.description === x.description && (y.is_fileset ?? false) === (x.is_fileset ?? false) && (y.format_extension ?? null) === (x.format_extension ?? null))) {
89689
+ if (resourceTypes.find((y) => y.name === x.name && typeof y.schema !== "string" && deepEqual(y.schema, x.schema) && y.description === x.description && (y.is_fileset ?? false) === (x.is_fileset ?? false) && (y.format_extension ?? null) === (x.format_extension ?? null) && (x.display_name === undefined || (y.display_name ?? null) === x.display_name))) {
89541
89690
  info("skipping " + x.name + " (same as current)");
89542
89691
  continue;
89543
89692
  }
@@ -92021,7 +92170,7 @@ async function initAction(opts) {
92021
92170
  if (await stat20("wmill.yaml").catch(() => null)) {
92022
92171
  info("wmill.yaml already exists, skipping config generation");
92023
92172
  } else {
92024
- await Promise.resolve().then(() => init_git());
92173
+ await init_git();
92025
92174
  let branchName;
92026
92175
  let wsBindings;
92027
92176
  const inGitRepo = isGitRepository();
@@ -92979,6 +93128,98 @@ async function deleteToken2(opts, tokenPrefix) {
92979
93128
  var command38 = new Command().description("Manage API tokens").option("--json", "Output as JSON (for piping to jq)").action(list16).command("list", "List API tokens").option("--json", "Output as JSON (for piping to jq)").action(list16).command("create", "Create a new API token").option("--label <label:string>", "Token label").option("--expiration <expiration:string>", "Token expiration (ISO 8601 timestamp)").action(create2).command("delete", "Delete a token by its prefix").arguments("<token_prefix:string>").action(deleteToken2);
92980
93129
  var token_default = command38;
92981
93130
 
93131
+ // src/commands/trash/trash.ts
93132
+ init_mod3();
93133
+ init_mod6();
93134
+ init_colors2();
93135
+ init_log();
93136
+ init_services_gen();
93137
+ await __promiseAll([
93138
+ init_auth(),
93139
+ init_context(),
93140
+ init_conf(),
93141
+ init_utils()
93142
+ ]);
93143
+ async function list17(opts) {
93144
+ if (opts.json)
93145
+ setSilent(true);
93146
+ opts = await mergeConfigWithConfigFile(opts);
93147
+ const workspace = await resolveWorkspace(opts);
93148
+ await requireLogin(opts);
93149
+ if (opts.page !== undefined && opts.page < 1) {
93150
+ throw new Error("--page starts at 1");
93151
+ }
93152
+ const items = await listTrash({
93153
+ workspace: workspace.workspaceId,
93154
+ itemKind: opts.kind,
93155
+ page: opts.page === undefined ? undefined : opts.page - 1,
93156
+ perPage: opts.limit
93157
+ });
93158
+ if (opts.json) {
93159
+ console.log(JSON.stringify(items));
93160
+ return;
93161
+ }
93162
+ if (items.length === 0) {
93163
+ info("No trashed items found.");
93164
+ return;
93165
+ }
93166
+ new Table2().header(["ID", "Kind", "Path", "Deleted by", "Deleted at", "Expires at"]).padding(2).border(true).body(items.map((item) => [
93167
+ String(item.id),
93168
+ item.item_kind,
93169
+ item.item_path,
93170
+ item.deleted_by,
93171
+ formatTimestamp(item.deleted_at),
93172
+ formatTimestamp(item.expires_at)
93173
+ ])).render();
93174
+ info(colors.gray("`wmill trash get <id>` shows what an item held, `wmill trash restore <id>` puts it back."));
93175
+ }
93176
+ async function get13(opts, id) {
93177
+ if (opts.json)
93178
+ setSilent(true);
93179
+ opts = await mergeConfigWithConfigFile(opts);
93180
+ const workspace = await resolveWorkspace(opts);
93181
+ await requireLogin(opts);
93182
+ const item = await getTrashItem({
93183
+ workspace: workspace.workspaceId,
93184
+ id
93185
+ });
93186
+ if (opts.json) {
93187
+ console.log(JSON.stringify(item));
93188
+ return;
93189
+ }
93190
+ console.log(colors.bold("ID:") + " " + item.id);
93191
+ console.log(colors.bold("Kind:") + " " + item.item_kind);
93192
+ console.log(colors.bold("Path:") + " " + item.item_path);
93193
+ console.log(colors.bold("Deleted by:") + " " + item.deleted_by);
93194
+ console.log(colors.bold("Deleted at:") + " " + formatTimestamp(item.deleted_at));
93195
+ console.log(colors.bold("Expires at:") + " " + formatTimestamp(item.expires_at));
93196
+ console.log(colors.bold("Data:"));
93197
+ console.log(JSON.stringify(item.item_data, null, 2));
93198
+ }
93199
+ async function restore(opts, ...ids) {
93200
+ opts = await mergeConfigWithConfigFile(opts);
93201
+ const workspace = await resolveWorkspace(opts);
93202
+ await requireLogin(opts);
93203
+ let failed = 0;
93204
+ for (const id of ids) {
93205
+ try {
93206
+ const message = await restoreTrashItem({
93207
+ workspace: workspace.workspaceId,
93208
+ id
93209
+ });
93210
+ info(colors.green(message));
93211
+ } catch (e) {
93212
+ failed += 1;
93213
+ error(`Could not restore trash item ${id}: ${apiErrorMessage(e) ?? String(e)}`);
93214
+ }
93215
+ }
93216
+ if (failed > 0) {
93217
+ process.exitCode = 1;
93218
+ }
93219
+ }
93220
+ var command39 = new Command().description("List, inspect and restore items deleted in the last three days (requires admin)").option("--json", "Output as JSON (for piping to jq)").option("--kind <kind:string>", "Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger").option("--limit <limit:integer>", "Number of items to return (default 100, max 1000)").option("--page <page:integer>", "Page to return, starting at 1").action(list17).command("list", "List trashed items, most recently deleted first").option("--json", "Output as JSON (for piping to jq)").option("--kind <kind:string>", "Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger").option("--limit <limit:integer>", "Number of items to return (default 100, max 1000)").option("--page <page:integer>", "Page to return, starting at 1").action(list17).command("get", "Show a trashed item and the data it was deleted with").arguments("<id:integer>").option("--json", "Output as JSON (for piping to jq)").action(get13).command("restore", "Put trashed items back at their paths").arguments("<ids...:integer>").action(restore);
93221
+ var trash_default = command39;
93222
+
92982
93223
  // src/main.ts
92983
93224
  await init_generate_metadata();
92984
93225
 
@@ -93038,8 +93279,8 @@ ${await res.text()}`);
93038
93279
  console.log();
93039
93280
  }
93040
93281
  }
93041
- var command39 = new Command().name("docs").description("Search Windmill documentation.").arguments("<query:string>").option("--json", "Output results as JSON.").action(docs);
93042
- var docs_default = command39;
93282
+ var command40 = new Command().name("docs").description("Search Windmill documentation.").arguments("<query:string>").option("--json", "Output results as JSON.").action(docs);
93283
+ var docs_default = command40;
93043
93284
 
93044
93285
  // src/commands/config/config.ts
93045
93286
  init_mod3();
@@ -93109,8 +93350,8 @@ async function migrateAction() {
93109
93350
  info(` Also removed additional legacy keys: ${legacyKeys.slice(1).join(", ")}`);
93110
93351
  }
93111
93352
  }
93112
- var command40 = new Command().name("config").description("Show all available wmill.yaml configuration options").option("--json", "Output as JSON for programmatic consumption").action(configAction).command("migrate").description("Migrate wmill.yaml from gitBranches/environments to workspaces format").action(migrateAction);
93113
- var config_default = command40;
93353
+ var command41 = new Command().name("config").description("Show all available wmill.yaml configuration options").option("--json", "Output as JSON for programmatic consumption").action(configAction).command("migrate").description("Migrate wmill.yaml from gitBranches/environments to workspaces format").action(migrateAction);
93354
+ var config_default = command41;
93114
93355
 
93115
93356
  // src/commands/datatable/datatable.ts
93116
93357
  init_mod3();
@@ -95001,7 +95242,7 @@ function signalToNumber(name) {
95001
95242
  // src/commands/datatable/datatable.ts
95002
95243
  await init_datatable_migrations();
95003
95244
  var DEFAULT_DATATABLE_NAME2 = "main";
95004
- async function list17(opts) {
95245
+ async function list18(opts) {
95005
95246
  if (opts.json)
95006
95247
  setSilent(true);
95007
95248
  const workspace = await resolveWorkspace(opts);
@@ -95078,8 +95319,8 @@ async function serve2(opts) {
95078
95319
  async function psql2(opts) {
95079
95320
  await psql(opts);
95080
95321
  }
95081
- var command41 = new Command().description("datatable related commands").command("list", "list all datatables in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list17).command("run", "run a SQL query on a datatable").arguments("<sql:string>").option("-n --name <name:string>", "Datatable name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run4).command("migrate", migrateCommand).command("create", "register a datatable database in the workspace (default: instance-backed 'main') so scripts can use datatable://<name>").arguments("[name:string]").option("--resource <resource:string>", "Back the datatable with an existing postgresql resource path instead of the instance database").option("--force", "Allow adding to a workspace that already has datatables (fork metadata on existing ones is not preserved)").action(create3).command("serve", "Serve all datatables as a Postgres-wire endpoint (psql, DBeaver, pgAdmin); the client picks the datatable via the database name in its connection string").option("--port <port:number>", "Port to listen on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address (default: 127.0.0.1)").option("--password <password:string>", "Password for Postgres clients (default: generate a random password at startup)").action(serve2).command("psql", "Start a serve listener and launch psql connected to it").option("-n --name <name:string>", "Datatable to connect psql to (default: main)").option("--port <port:number>", "Port the proxy listens on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address for the proxy (default: 127.0.0.1)").option("--password <password:string>", "Password for the temporary Postgres proxy (default: generate a random password at startup)").action(psql2);
95082
- var datatable_default = command41;
95322
+ var command42 = new Command().description("datatable related commands").command("list", "list all datatables in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list18).command("run", "run a SQL query on a datatable").arguments("<sql:string>").option("-n --name <name:string>", "Datatable name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run4).command("migrate", migrateCommand).command("create", "register a datatable database in the workspace (default: instance-backed 'main') so scripts can use datatable://<name>").arguments("[name:string]").option("--resource <resource:string>", "Back the datatable with an existing postgresql resource path instead of the instance database").option("--force", "Allow adding to a workspace that already has datatables (fork metadata on existing ones is not preserved)").action(create3).command("serve", "Serve all datatables as a Postgres-wire endpoint (psql, DBeaver, pgAdmin); the client picks the datatable via the database name in its connection string").option("--port <port:number>", "Port to listen on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address (default: 127.0.0.1)").option("--password <password:string>", "Password for Postgres clients (default: generate a random password at startup)").action(serve2).command("psql", "Start a serve listener and launch psql connected to it").option("-n --name <name:string>", "Datatable to connect psql to (default: main)").option("--port <port:number>", "Port the proxy listens on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address for the proxy (default: 127.0.0.1)").option("--password <password:string>", "Password for the temporary Postgres proxy (default: generate a random password at startup)").action(psql2);
95323
+ var datatable_default = command42;
95083
95324
 
95084
95325
  // src/commands/pipeline/pipeline.ts
95085
95326
  init_mod3();
@@ -96369,8 +96610,8 @@ async function dev3(opts, folderArg) {
96369
96610
  process27.exit(0);
96370
96611
  });
96371
96612
  }
96372
- var command42 = new Command().description("Live-preview a data pipeline from local files: watch an `f/<folder>` of `// pipeline` scripts, push the working-tree graph to the dev page, and run the cascade via preview (no deploy).").arguments("[folder:string]").option("--port <port:number>", "Port for the dev WebSocket server.").option("--no-open", "Do not open the browser automatically.").option("--frontend <origin:string>", "Origin serving the /pipeline_dev page (e.g. http://localhost:3000 for a locally-run frontend). Defaults to the workspace remote; use it when the remote's deployed frontend predates the dev page.").action(dev3);
96373
- var dev_default3 = command42;
96613
+ var command43 = new Command().description("Live-preview a data pipeline from local files: watch an `f/<folder>` of `// pipeline` scripts, push the working-tree graph to the dev page, and run the cascade via preview (no deploy).").arguments("[folder:string]").option("--port <port:number>", "Port for the dev WebSocket server.").option("--no-open", "Do not open the browser automatically.").option("--frontend <origin:string>", "Origin serving the /pipeline_dev page (e.g. http://localhost:3000 for a locally-run frontend). Defaults to the workspace remote; use it when the remote's deployed frontend predates the dev page.").action(dev3);
96614
+ var dev_default3 = command43;
96374
96615
 
96375
96616
  // src/commands/pipeline/docs.ts
96376
96617
  init_gen();
@@ -96688,7 +96929,7 @@ async function apiGet(path) {
96688
96929
  }
96689
96930
  return await response.json();
96690
96931
  }
96691
- async function list18(opts) {
96932
+ async function list19(opts) {
96692
96933
  if (opts.json)
96693
96934
  setSilent(true);
96694
96935
  const workspace = await resolveWorkspace(opts);
@@ -97261,8 +97502,8 @@ Full logs: ${runUrl}`);
97261
97502
  info(colors.green.bold(`Bounded run complete — ${order.length} script(s) succeeded.`));
97262
97503
  }
97263
97504
  }
97264
- var command43 = new Command().description("inspect asset-driven pipelines (scripts marked `// pipeline`, wired by `// on <spec>` annotations)").command("list", "list pipeline folders in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list18).command("show", "render a pipeline folder's DAG (sources, lineage, subscriptions) in the terminal").arguments("<folder:string>").option("--json", "Output the raw asset graph as JSON").option("--local", "Build the graph from local working-tree files (// pipeline scripts) instead of the deployed workspace — no deploy needed.").action(show2).command("run", "run a cascade: from --from (a root OR any mid-DAG model), fan downstream up to the --to end node(s)").arguments("<folder:string>").option("--from <script:string>", "Start script (short name or path). May be any node, including a mid-DAG model — that node plus its transitive downstream runs, upstream is NOT re-run (dbt `--select model+`). Defaults to the folder's sole schedule/manual root.").option("--to <node:string>", "End node(s) to stop at — script names/paths or asset URIs (e.g. datatable://main/staged). Repeatable or comma-separated. Omit to run the full downstream.", { collect: true }).option("--dry-run", "Print the topological run plan without executing.").option("--json", "Output the plan as JSON (for piping to jq).").option("--local", "Run the local working-tree scripts via preview (no deploy) instead of the deployed versions; the graph is built from local files.").option("--upload <binding:string>", "Bind an object to a data_upload/webhook entry point so it runs in the cascade, as SCRIPT[:PARAM]=SOURCE (SOURCE is a local file or an s3://key). Local files are uploaded to the workspace store; the S3Object param is inferred when the script has exactly one. Repeatable.", { collect: true }).option("--arg <binding:string>", "Pass a plain run arg to a script in the cascade, as SCRIPT:PARAM=VALUE (VALUE is parsed as JSON when possible, else taken as a string — e.g. daily_report:partition=2026-07-02). Repeatable.", { collect: true }).option("--partition <value:string>", "Partition value for `// partitioned` scripts in the run (e.g. 2026-06-30) — use it to backfill a past slice. With --local, time kinds (daily/hourly/weekly/monthly) default to the current UTC period when omitted; `dynamic` always needs it. Deployed runs without it defer to backend run-start resolution.").action(run5).command("docs", "generate PIPELINE.md (+ AGENTS.md pointer) describing a folder's pipeline graph and datatable schemas, for an editor / agentic loop").arguments("<folder:string>").option("--local", "Build the graph from local working-tree files instead of the deployed workspace.").action(generatePipelineDocs).command("dev", dev_default3);
97265
- var pipeline_default = command43;
97505
+ var command44 = new Command().description("inspect asset-driven pipelines (scripts marked `// pipeline`, wired by `// on <spec>` annotations)").command("list", "list pipeline folders in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list19).command("show", "render a pipeline folder's DAG (sources, lineage, subscriptions) in the terminal").arguments("<folder:string>").option("--json", "Output the raw asset graph as JSON").option("--local", "Build the graph from local working-tree files (// pipeline scripts) instead of the deployed workspace — no deploy needed.").action(show2).command("run", "run a cascade: from --from (a root OR any mid-DAG model), fan downstream up to the --to end node(s)").arguments("<folder:string>").option("--from <script:string>", "Start script (short name or path). May be any node, including a mid-DAG model — that node plus its transitive downstream runs, upstream is NOT re-run (dbt `--select model+`). Defaults to the folder's sole schedule/manual root.").option("--to <node:string>", "End node(s) to stop at — script names/paths or asset URIs (e.g. datatable://main/staged). Repeatable or comma-separated. Omit to run the full downstream.", { collect: true }).option("--dry-run", "Print the topological run plan without executing.").option("--json", "Output the plan as JSON (for piping to jq).").option("--local", "Run the local working-tree scripts via preview (no deploy) instead of the deployed versions; the graph is built from local files.").option("--upload <binding:string>", "Bind an object to a data_upload/webhook entry point so it runs in the cascade, as SCRIPT[:PARAM]=SOURCE (SOURCE is a local file or an s3://key). Local files are uploaded to the workspace store; the S3Object param is inferred when the script has exactly one. Repeatable.", { collect: true }).option("--arg <binding:string>", "Pass a plain run arg to a script in the cascade, as SCRIPT:PARAM=VALUE (VALUE is parsed as JSON when possible, else taken as a string — e.g. daily_report:partition=2026-07-02). Repeatable.", { collect: true }).option("--partition <value:string>", "Partition value for `// partitioned` scripts in the run (e.g. 2026-06-30) — use it to backfill a past slice. With --local, time kinds (daily/hourly/weekly/monthly) default to the current UTC period when omitted; `dynamic` always needs it. Deployed runs without it defer to backend run-start resolution.").action(run5).command("docs", "generate PIPELINE.md (+ AGENTS.md pointer) describing a folder's pipeline graph and datatable schemas, for an editor / agentic loop").arguments("<folder:string>").option("--local", "Build the graph from local working-tree files instead of the deployed workspace.").action(generatePipelineDocs).command("dev", dev_default3);
97506
+ var pipeline_default = command44;
97266
97507
 
97267
97508
  // src/commands/ducklake/ducklake.ts
97268
97509
  init_mod3();
@@ -97274,7 +97515,7 @@ await __promiseAll([
97274
97515
  init_context()
97275
97516
  ]);
97276
97517
  var DEFAULT_DUCKLAKE_NAME = "main";
97277
- async function list19(opts) {
97518
+ async function list20(opts) {
97278
97519
  if (opts.json)
97279
97520
  setSilent(true);
97280
97521
  const workspace = await resolveWorkspace(opts);
@@ -97292,8 +97533,8 @@ async function run6(opts, sql) {
97292
97533
  const name = opts.name ?? DEFAULT_DUCKLAKE_NAME;
97293
97534
  await runCatalogQuery(opts, "ducklake", name, sql);
97294
97535
  }
97295
- var command44 = new Command().description("ducklake related commands").command("list", "list all ducklakes in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list19).command("run", "run a SQL query on a ducklake").arguments("<sql:string>").option("-n --name <name:string>", "Ducklake name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run6);
97296
- var ducklake_default = command44;
97536
+ var command45 = new Command().description("ducklake related commands").command("list", "list all ducklakes in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list20).command("run", "run a SQL query on a ducklake").arguments("<sql:string>").option("-n --name <name:string>", "Ducklake name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run6);
97537
+ var ducklake_default = command45;
97297
97538
 
97298
97539
  // src/commands/object-storage/object-storage.ts
97299
97540
  init_mod3();
@@ -97494,8 +97735,8 @@ async function preview3(opts, fileKey) {
97494
97735
  `);
97495
97736
  }
97496
97737
  }
97497
- var command45 = new Command().alias("s3").description("Object storage (S3) related commands. Operates on the workspace's default object storage; use --storage to target a configured secondary storage.").action(listStorages).command("list", "List configured object storages for the workspace (default + secondary).").option("--json", "Output as JSON (for piping to jq)").action(listStorages).command("files", "List files in an object storage. Optionally filter by prefix.").alias("ls").arguments("[prefix:string]").option("--json", "Output as JSON (for piping to jq)").option("--max-keys <maxKeys:number>", "Page size (default 100)").option("--marker <marker:string>", "Pagination marker from a previous response").option("--storage <storage:string>", "Secondary storage name (omit for the workspace default)").action(listFiles).command("upload", "Upload a local file to object storage at the given file key.").arguments("<local_path:string> <file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--content-type <contentType:string>", "Content-Type header to set on the object").option("--content-disposition <contentDisposition:string>", "Content-Disposition header to set on the object").action(upload).command("download", "Download an object to a local file (or stdout). Default output path is the basename of the file key in the current directory.").arguments("<file_key:string> [output_path:string]").option("--storage <storage:string>", "Secondary storage name").option("--stdout", "Write file contents to stdout instead of a file").action(download).command("delete", "Delete an object from object storage. Prompts for confirmation unless --yes is set.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--yes", "Skip the confirmation prompt").action(del).command("move", "Move an object within the same storage (rename or relocate by key).").arguments("<src_file_key:string> <dest_file_key:string>").option("--storage <storage:string>", "Secondary storage name").action(move).command("info", "Show metadata (size, mime, last-modified) for an object.").arguments("<file_key:string>").option("--json", "Output as JSON (for piping to jq)").option("--storage <storage:string>", "Secondary storage name").action(info2).command("preview", "Preview the contents of an object (text/CSV). Use --bytes-from / --bytes-length to peek at a slice of binary files.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--mime <mime:string>", "Override the detected mime type (e.g. text/csv)").option("--bytes-from <bytesFrom:number>", "Start offset in bytes").option("--bytes-length <bytesLength:number>", "Number of bytes to read").option("--csv-separator <csvSeparator:string>", "CSV column separator (default ,)").option("--csv-header", "Treat the first CSV row as a header").action(preview3);
97498
- var object_storage_default = command45;
97738
+ var command46 = new Command().alias("s3").description("Object storage (S3) related commands. Operates on the workspace's default object storage; use --storage to target a configured secondary storage.").action(listStorages).command("list", "List configured object storages for the workspace (default + secondary).").option("--json", "Output as JSON (for piping to jq)").action(listStorages).command("files", "List files in an object storage. Optionally filter by prefix.").alias("ls").arguments("[prefix:string]").option("--json", "Output as JSON (for piping to jq)").option("--max-keys <maxKeys:number>", "Page size (default 100)").option("--marker <marker:string>", "Pagination marker from a previous response").option("--storage <storage:string>", "Secondary storage name (omit for the workspace default)").action(listFiles).command("upload", "Upload a local file to object storage at the given file key.").arguments("<local_path:string> <file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--content-type <contentType:string>", "Content-Type header to set on the object").option("--content-disposition <contentDisposition:string>", "Content-Disposition header to set on the object").action(upload).command("download", "Download an object to a local file (or stdout). Default output path is the basename of the file key in the current directory.").arguments("<file_key:string> [output_path:string]").option("--storage <storage:string>", "Secondary storage name").option("--stdout", "Write file contents to stdout instead of a file").action(download).command("delete", "Delete an object from object storage. Prompts for confirmation unless --yes is set.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--yes", "Skip the confirmation prompt").action(del).command("move", "Move an object within the same storage (rename or relocate by key).").arguments("<src_file_key:string> <dest_file_key:string>").option("--storage <storage:string>", "Secondary storage name").action(move).command("info", "Show metadata (size, mime, last-modified) for an object.").arguments("<file_key:string>").option("--json", "Output as JSON (for piping to jq)").option("--storage <storage:string>", "Secondary storage name").action(info2).command("preview", "Preview the contents of an object (text/CSV). Use --bytes-from / --bytes-length to peek at a slice of binary files.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--mime <mime:string>", "Override the detected mime type (e.g. text/csv)").option("--bytes-from <bytesFrom:number>", "Start offset in bytes").option("--bytes-length <bytesLength:number>", "Number of bytes to read").option("--csv-separator <csvSeparator:string>", "CSV column separator (default ,)").option("--csv-header", "Treat the first CSV row as a header").action(preview3);
97739
+ var object_storage_default = command46;
97499
97740
 
97500
97741
  // src/main.ts
97501
97742
  await init_context();
@@ -97515,7 +97756,7 @@ async function checkVersionSafe(cmd) {
97515
97756
  }
97516
97757
  mainCommand.version(`${currentVersion} (New version available: ${latestVersion}. Run '${mainCommand.getName()} upgrade' to upgrade to the latest version!)`);
97517
97758
  }
97518
- var command46 = 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).helpOption("-h, --help", "Show this help.", {
97759
+ var command47 = 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).helpOption("-h, --help", "Show this help.", {
97519
97760
  action: async function() {
97520
97761
  const self2 = this;
97521
97762
  const long = self2.getRawArgs().includes(`--${self2.getHelpOption()?.name}`);
@@ -97527,7 +97768,7 @@ var command46 = new Command().name("wmill").action(() => info(`Welcome to Windmi
97527
97768
  self2.showHelp({ long });
97528
97769
  self2.exit();
97529
97770
  }
97530
- }).command("init", init_default).command("refresh", refresh_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_default2).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("gitsync-settings", gitsync_settings_default).command("protection-rules", protection_rules_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("job", job_default).command("group", group_default).command("audit", audit_default).command("token", token_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("datatable", datatable_default).command("pipeline", pipeline_default).command("ducklake", ducklake_default).command("object-storage", object_storage_default).command("version --version", "Show version information").action(async (opts) => {
97771
+ }).command("init", init_default).command("refresh", refresh_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_default2).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("gitsync-settings", gitsync_settings_default).command("protection-rules", protection_rules_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("job", job_default).command("group", group_default).command("audit", audit_default).command("token", token_default).command("trash", trash_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("datatable", datatable_default).command("pipeline", pipeline_default).command("ducklake", ducklake_default).command("object-storage", object_storage_default).command("version --version", "Show version information").action(async (opts) => {
97531
97772
  console.log("CLI version: " + VERSION);
97532
97773
  try {
97533
97774
  const provider = new NpmProvider({ package: "windmill-cli" });
@@ -97557,20 +97798,20 @@ var command46 = new Command().name("wmill").action(() => info(`Welcome to Windmi
97557
97798
  error(e);
97558
97799
  info("Try running with sudo and otherwise check the result of the command: npm uninstall windmill-cli && npm install -g windmill-cli");
97559
97800
  })).command("completions", new Command().description("Generate shell completions.").command("bash", new Command().description("Generate bash completions.").action(() => {
97560
- process.stdout.write(generateShellCompletions(command46, "bash") + `
97801
+ process.stdout.write(generateShellCompletions(command47, "bash") + `
97561
97802
  `);
97562
97803
  })).command("zsh", new Command().description("Generate zsh completions.").action(() => {
97563
- process.stdout.write(generateShellCompletions(command46, "zsh") + `
97804
+ process.stdout.write(generateShellCompletions(command47, "zsh") + `
97564
97805
  `);
97565
97806
  })).command("fish", new Command().description("Generate fish completions.").action(() => {
97566
- process.stdout.write(generateShellCompletions(command46, "fish") + `
97807
+ process.stdout.write(generateShellCompletions(command47, "fish") + `
97567
97808
  `);
97568
97809
  })));
97569
97810
  async function main2() {
97570
97811
  try {
97571
97812
  const args = process.argv.slice(2);
97572
97813
  if (args.length === 0) {
97573
- command46.showHelp();
97814
+ command47.showHelp();
97574
97815
  }
97575
97816
  const LOG_LEVEL = args.includes("--verbose") || args.includes("--debug") ? "DEBUG" : "INFO";
97576
97817
  setShowDiffs(args.includes("--show-diffs"));
@@ -97591,13 +97832,11 @@ async function main2() {
97591
97832
  await init_tsconfig();
97592
97833
  await warnIfTsconfigStale().catch(() => {});
97593
97834
  }
97594
- await command46.parse(args);
97835
+ await command47.parse(args);
97595
97836
  } catch (e) {
97596
- if (e && typeof e === "object" && "name" in e && e.name === "ApiError") {
97597
- const body = e.body;
97598
- let bodyStr = typeof body === "object" && body !== null ? JSON.stringify(body) : String(body ?? "");
97599
- bodyStr = bodyStr.replace(/\s*[@(]\w+\.rs:\d+[:\d]*\)?/g, "");
97600
- error("Server failed. " + e.statusText + ": " + bodyStr);
97837
+ const apiError = apiErrorMessage(e);
97838
+ if (apiError !== undefined) {
97839
+ error("Server failed. " + apiError);
97601
97840
  } else if (e instanceof Error) {
97602
97841
  error(e.message);
97603
97842
  } else if (e !== undefined && e !== null) {
@@ -97627,7 +97866,7 @@ if (isMain()) {
97627
97866
  process.stdin.destroy();
97628
97867
  });
97629
97868
  }
97630
- var main_default = command46;
97869
+ var main_default = command47;
97631
97870
  export {
97632
97871
  VERSION,
97633
97872
  WM_FORK_PREFIX,