windmill-cli 1.804.0 → 1.806.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 +385 -237
  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.804.0",
16769
+ VERSION: "1.806.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -19971,7 +19971,7 @@ var init_auth = __esm(async () => {
19971
19971
  });
19972
19972
 
19973
19973
  // src/core/constants.ts
19974
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.804.0";
19974
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.806.0";
19975
19975
 
19976
19976
  // src/utils/git.ts
19977
19977
  import { execSync, spawnSync } from "node:child_process";
@@ -20709,7 +20709,7 @@ function getGitRepoRoot() {
20709
20709
  return null;
20710
20710
  }
20711
20711
  }
20712
- function findWmillYaml() {
20712
+ function locateWmillYaml() {
20713
20713
  const startDir = resolve5(process.cwd());
20714
20714
  const isInGitRepo = isGitRepository();
20715
20715
  const gitRoot = isInGitRepo ? getGitRepoRoot() : null;
@@ -20730,6 +20730,11 @@ function findWmillYaml() {
20730
20730
  }
20731
20731
  currentDir = parentDir;
20732
20732
  }
20733
+ return foundPath;
20734
+ }
20735
+ function findWmillYaml() {
20736
+ const startDir = resolve5(process.cwd());
20737
+ const foundPath = locateWmillYaml();
20733
20738
  if (!GLOBAL_CONFIG_OPT.noCdToRoot && foundPath && resolve5(dirname6(foundPath)) !== resolve5(startDir)) {
20734
20739
  const configDir = dirname6(foundPath);
20735
20740
  const relativePath = relative4(startDir, foundPath);
@@ -20742,6 +20747,24 @@ function findWmillYaml() {
20742
20747
  function getWmillYamlPath() {
20743
20748
  return findWmillYaml();
20744
20749
  }
20750
+ async function peekWorkspaceEntry(workspaceName) {
20751
+ if (RESERVED_WORKSPACE_KEYS.has(workspaceName)) {
20752
+ return;
20753
+ }
20754
+ const wmillYamlPath = locateWmillYaml();
20755
+ if (!wmillYamlPath) {
20756
+ return;
20757
+ }
20758
+ try {
20759
+ const conf = await yamlParseFile(wmillYamlPath);
20760
+ const workspaces = conf?.workspaces ?? conf?.gitBranches ?? conf?.environments ?? conf?.git_branches;
20761
+ const entry = workspaces?.[workspaceName];
20762
+ return typeof entry === "object" && entry !== null ? entry : undefined;
20763
+ } catch (e) {
20764
+ debug(`Failed to parse ${wmillYamlPath} for workspace lookup: ${e}`);
20765
+ return;
20766
+ }
20767
+ }
20745
20768
  async function readConfigFile(opts) {
20746
20769
  const warnIfMissing = opts?.warnIfMissing ?? true;
20747
20770
  try {
@@ -20965,6 +20988,48 @@ async function getEffectiveSettings(config, promotion, skipBranchValidation, sup
20965
20988
  }
20966
20989
  return effective;
20967
20990
  }
20991
+ function resolveWsNameFromBranch(opts, branchName) {
20992
+ const match = findWorkspaceByGitBranch(opts.workspaces, branchName);
20993
+ return match ? match[0] : branchName;
20994
+ }
20995
+ function resolveWsNameForConfigFromFlags(opts) {
20996
+ if (opts.branch) {
20997
+ return resolveWsNameFromBranch(opts, opts.branch);
20998
+ }
20999
+ if (opts.workspace) {
21000
+ const validKeys = getWorkspaceNames(opts.workspaces);
21001
+ if (validKeys.includes(opts.workspace)) {
21002
+ return opts.workspace;
21003
+ }
21004
+ }
21005
+ return;
21006
+ }
21007
+ function inferWsNameFromProfile(opts, profile) {
21008
+ if (!opts.workspaces)
21009
+ return;
21010
+ for (const name of getWorkspaceNames(opts.workspaces)) {
21011
+ const entry = opts.workspaces[name];
21012
+ if (!entry?.baseUrl)
21013
+ continue;
21014
+ try {
21015
+ const entryUrl = new URL(entry.baseUrl).toString();
21016
+ const profileUrl = new URL(profile.remote).toString();
21017
+ const entryWsId = entry.workspaceId ?? name;
21018
+ if (entryUrl === profileUrl && entryWsId === profile.workspaceId) {
21019
+ return name;
21020
+ }
21021
+ } catch {
21022
+ continue;
21023
+ }
21024
+ }
21025
+ return;
21026
+ }
21027
+ async function readEffectiveSyncBehavior(opts, profile) {
21028
+ const config = await readConfigFile({ warnIfMissing: false });
21029
+ const named = resolveWsNameForConfigFromFlags({ ...config, ...opts });
21030
+ const effective = await getEffectiveSettings(config, undefined, false, true, named ?? (profile ? inferWsNameFromProfile(config, profile) : undefined));
21031
+ return effective.syncBehavior;
21032
+ }
20968
21033
  function findWorkspaceByGitBranch(workspaces, branchName) {
20969
21034
  if (!workspaces)
20970
21035
  return;
@@ -23661,6 +23726,7 @@ async function tryResolveWorkspace(opts) {
23661
23726
  if (opts.workspace) {
23662
23727
  const config = await readConfigFile({ warnIfMissing: false });
23663
23728
  const wsEntry = config.workspaces?.[opts.workspace];
23729
+ let configuredTarget;
23664
23730
  if (wsEntry?.baseUrl) {
23665
23731
  const workspaceId = getEffectiveWorkspaceId(opts.workspace, wsEntry);
23666
23732
  let normalizedBaseUrl;
@@ -23672,6 +23738,7 @@ async function tryResolveWorkspace(opts) {
23672
23738
  error: colors.red.underline(`Invalid baseUrl in workspace '${opts.workspace}' configuration: ${wsEntry.baseUrl}`)
23673
23739
  };
23674
23740
  }
23741
+ configuredTarget = { workspaceId, baseUrl: normalizedBaseUrl };
23675
23742
  const allProfs = await allWorkspaces(opts.configDir);
23676
23743
  const matching = allProfs.filter((w) => w.remote === normalizedBaseUrl && w.workspaceId === workspaceId);
23677
23744
  if (matching.length >= 1) {
@@ -23694,6 +23761,12 @@ async function tryResolveWorkspace(opts) {
23694
23761
  error: colors.red.underline(`Workspace '${opts.workspace}' not found in wmill.yaml config or local profiles.`)
23695
23762
  };
23696
23763
  }
23764
+ if (configuredTarget && (e.workspaceId !== configuredTarget.workspaceId || e.remote !== configuredTarget.baseUrl)) {
23765
+ warnStderr(colors.yellow(`⚠️ Falling back to the local profile named '${opts.workspace}' (${e.workspaceId} on ${e.remote}), which does NOT match wmill.yaml:
23766
+ ` + ` wmill.yaml maps workspace '${opts.workspace}' to ${configuredTarget.workspaceId} on ${configuredTarget.baseUrl}, but no profile targets it.
23767
+ ` + ` Run: wmill workspace add <profile-name> ${configuredTarget.workspaceId} ${configuredTarget.baseUrl}`));
23768
+ }
23769
+ infoStderr(`Using local profile '${e.name}' → ${e.workspaceId} on ${e.remote}`);
23697
23770
  opts.__secret_workspace = e;
23698
23771
  return { isError: false, value: e };
23699
23772
  }
@@ -23813,6 +23886,7 @@ async function resolveWorkspace(opts, workspaceNameOverride) {
23813
23886
  infoStderr(colors.red(`Invalid base URL: ${opts.baseUrl}`));
23814
23887
  return process.exit(-1);
23815
23888
  }
23889
+ let resolved;
23816
23890
  if (opts.workspace) {
23817
23891
  let existingWorkspace = await getWorkspaceByName(opts.workspace, opts.configDir);
23818
23892
  if (!existingWorkspace) {
@@ -23828,18 +23902,28 @@ async function resolveWorkspace(opts, workspaceNameOverride) {
23828
23902
  infoStderr(colors.red(`Base URL mismatch: --base-url is ${normalizedBaseUrl} but workspace profile "${opts.workspace}" uses ${existingWorkspace.remote}`));
23829
23903
  return process.exit(-1);
23830
23904
  }
23831
- return {
23905
+ resolved = {
23832
23906
  ...existingWorkspace,
23833
23907
  token: opts.token
23834
23908
  };
23835
23909
  }
23836
23910
  }
23837
- return {
23911
+ resolved ??= {
23838
23912
  remote: normalizedBaseUrl,
23839
23913
  workspaceId: opts.workspace,
23840
23914
  name: opts.workspace,
23841
23915
  token: opts.token
23842
23916
  };
23917
+ const yamlEntry = await peekWorkspaceEntry(opts.workspace);
23918
+ const yamlWorkspaceId = yamlEntry?.workspaceId;
23919
+ if (yamlWorkspaceId && yamlWorkspaceId !== resolved.workspaceId) {
23920
+ warnStderr(colors.yellow(`⚠️ --base-url is set, so wmill.yaml is not consulted: workspace id '${resolved.workspaceId}' is sent to the API.
23921
+ wmill.yaml maps workspace '${opts.workspace}' to workspace id '${yamlWorkspaceId}'${yamlEntry.baseUrl ? ` on ${yamlEntry.baseUrl}` : ""}.
23922
+ Use '--workspace ${yamlWorkspaceId}', or drop --base-url/--token to resolve through wmill.yaml.`));
23923
+ }
23924
+ infoStderr(`Using workspace id '${resolved.workspaceId}' on ${normalizedBaseUrl} (--base-url given` + (resolved.name !== resolved.workspaceId ? `, profile '${resolved.name}')` : ")"));
23925
+ opts.__secret_workspace = resolved;
23926
+ return resolved;
23843
23927
  } else {
23844
23928
  infoStderr(colors.red("If you specify a base URL with --base-url, you must also specify a workspace (--workspace) and token (--token)."));
23845
23929
  return process.exit(-1);
@@ -45156,7 +45240,10 @@ async function downloadZip(workspace, plainSecrets, skipVariables, skipResources
45156
45240
  return process.exit(1);
45157
45241
  }
45158
45242
  if (zipResponse.status === 404 || body.includes("no rows returned")) {
45159
- info(colors.red(`Workspace '${workspace.workspaceId}' not found on ${workspace.remote}. Please check your --workspace and try again.`));
45243
+ info(colors.red(`Workspace id '${workspace.workspaceId}' not found on ${workspace.remote}` + (workspace.name !== workspace.workspaceId ? ` (resolved from profile '${workspace.name}')` : "") + `.
45244
+ ` + `Note this is the workspace *id* sent to the API, which is not necessarily what you passed to --workspace:
45245
+ ` + ` - check 'wmill workspace list' (the 'workspace id' column)
45246
+ ` + ` - check the 'workspaces' block of wmill.yaml ('workspaceId' overrides the workspace name)`));
45160
45247
  } else {
45161
45248
  info(colors.red(`Failed to request tarball from API: ${zipResponse.status} ${zipResponse.statusText}`));
45162
45249
  if (body)
@@ -56286,7 +56373,7 @@ var init_openflow = __esm(() => {
56286
56373
  openflow_default = {
56287
56374
  openapi: "3.0.3",
56288
56375
  info: {
56289
- version: "1.804.0",
56376
+ version: "1.806.0",
56290
56377
  title: "OpenFlow Spec",
56291
56378
  contact: {
56292
56379
  name: "Ruben Fiszel",
@@ -60033,6 +60120,163 @@ var init_src = __esm(() => {
60033
60120
  init_validation();
60034
60121
  });
60035
60122
 
60123
+ // src/core/permissioned_as.ts
60124
+ async function buildPermissionedAsContext(workspace, syncBehavior) {
60125
+ if (parseSyncBehavior(syncBehavior) < 1) {
60126
+ return;
60127
+ }
60128
+ const user = await whoami({ workspace });
60129
+ const userIsAdminOrDeployer = user.is_admin || (user.groups ?? []).includes("wm_deployers");
60130
+ debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`);
60131
+ return {
60132
+ userCache: new Map,
60133
+ userIsAdminOrDeployer,
60134
+ userEmail: user.email
60135
+ };
60136
+ }
60137
+ async function ensureUserCache(workspace, cache) {
60138
+ if (cache.size > 0)
60139
+ return;
60140
+ const users = await listUsers({ workspace });
60141
+ for (const user of users) {
60142
+ cache.set(user.username, { username: user.username, email: user.email });
60143
+ cache.set(user.email, { username: user.username, email: user.email });
60144
+ }
60145
+ }
60146
+ async function lookupUsernameByEmail(workspace, email, cache) {
60147
+ await ensureUserCache(workspace, cache);
60148
+ const entry = cache.get(email);
60149
+ if (!entry) {
60150
+ throw new Error(`Could not find username for email '${email}' in workspace. ` + `Make sure the user exists in the workspace.`);
60151
+ }
60152
+ return entry.username;
60153
+ }
60154
+ function contentHasOnBehalfOf(content, typeStr) {
60155
+ if (typeStr === "script") {
60156
+ return !!content.match(/has_on_behalf_of:\s*(true)/) || !!content.match(/on_behalf_of_email:\s*["']?([^\s"']+)["']?/);
60157
+ }
60158
+ if (typeStr === "flow") {
60159
+ return !!content.match(/has_on_behalf_of:\s*(true)/);
60160
+ }
60161
+ return false;
60162
+ }
60163
+ async function preCheckPermissionedAs(changes, userEmail, userIsAdminOrDeployer, acceptOverride, isInteractive) {
60164
+ if (userIsAdminOrDeployer)
60165
+ return;
60166
+ const wouldChangeItems = [];
60167
+ for (const change of changes) {
60168
+ let typeStr;
60169
+ try {
60170
+ typeStr = getTypeStrFromPath(change.path);
60171
+ } catch {
60172
+ continue;
60173
+ }
60174
+ if (change.name === "added") {
60175
+ const content = change.content;
60176
+ if (!content)
60177
+ continue;
60178
+ const isScriptMeta = typeStr === "script" && (change.path.endsWith(".script.yaml") || change.path.endsWith(".script.json"));
60179
+ const isFlowMeta = typeStr === "flow" && (change.path.endsWith("flow.yaml") || change.path.endsWith("flow.json"));
60180
+ if ((isScriptMeta || isFlowMeta) && contentHasOnBehalfOf(content, typeStr)) {
60181
+ const label = typeStr === "script" ? "(script owner)" : "(flow owner)";
60182
+ wouldChangeItems.push({ path: change.path, currentOwner: label });
60183
+ } else if (typeStr === "app") {
60184
+ wouldChangeItems.push({
60185
+ path: change.path,
60186
+ currentOwner: "(app policy owner)"
60187
+ });
60188
+ }
60189
+ continue;
60190
+ }
60191
+ if (change.name !== "edited")
60192
+ continue;
60193
+ const beforeContent = change.before;
60194
+ if (!beforeContent)
60195
+ continue;
60196
+ let currentOwner;
60197
+ if (typeStr === "script") {
60198
+ if (change.path.endsWith(".script.yaml") || change.path.endsWith(".script.json")) {
60199
+ const hasOboMatch = beforeContent.match(/has_on_behalf_of:\s*(true)/);
60200
+ if (hasOboMatch) {
60201
+ currentOwner = "(script owner)";
60202
+ } else {
60203
+ const emailMatch = beforeContent.match(/on_behalf_of_email:\s*["']?([^\s"']+)["']?/);
60204
+ if (emailMatch) {
60205
+ currentOwner = emailMatch[1];
60206
+ }
60207
+ }
60208
+ }
60209
+ } else if (typeStr === "flow") {
60210
+ if (change.path.endsWith("flow.yaml") || change.path.endsWith("flow.json")) {
60211
+ const hasOboMatch = beforeContent.match(/has_on_behalf_of:\s*(true)/);
60212
+ if (hasOboMatch) {
60213
+ wouldChangeItems.push({
60214
+ path: change.path,
60215
+ currentOwner: "(flow owner)"
60216
+ });
60217
+ }
60218
+ }
60219
+ continue;
60220
+ } else if (typeStr === "app") {
60221
+ wouldChangeItems.push({
60222
+ path: change.path,
60223
+ currentOwner: "(app policy owner)"
60224
+ });
60225
+ continue;
60226
+ } else if (typeStr === "schedule") {
60227
+ const match = beforeContent.match(/email:\s*["']?([^\s"']+)["']?/);
60228
+ if (match) {
60229
+ currentOwner = match[1];
60230
+ }
60231
+ } else if (typeStr.endsWith("_trigger")) {
60232
+ wouldChangeItems.push({
60233
+ path: change.path,
60234
+ currentOwner: "(trigger owner)"
60235
+ });
60236
+ continue;
60237
+ }
60238
+ if (currentOwner && currentOwner !== userEmail) {
60239
+ wouldChangeItems.push({ path: change.path, currentOwner });
60240
+ }
60241
+ }
60242
+ if (wouldChangeItems.length === 0)
60243
+ return;
60244
+ const itemList = wouldChangeItems.map((item) => ` - ${item.path} (current owner: ${item.currentOwner})`).join(`
60245
+ `);
60246
+ const message = `You are not an admin or member of 'wm_deployers'. The following ${wouldChangeItems.length} item(s) ` + `will have their permissioned_as/email changed to your user (${userEmail}):
60247
+ ${itemList}`;
60248
+ if (acceptOverride) {
60249
+ warn(colors.yellow(`Warning: ${message}`));
60250
+ return;
60251
+ }
60252
+ if (isInteractive) {
60253
+ warn(colors.yellow(message));
60254
+ const proceed = await Confirm.prompt({
60255
+ message: "Do you want to proceed? (use --accept-overriding-permissioned-as-with-self to skip this prompt)",
60256
+ default: false
60257
+ });
60258
+ if (!proceed) {
60259
+ info("Push cancelled.");
60260
+ process.exit(0);
60261
+ }
60262
+ } else {
60263
+ error(colors.red(`${message}
60264
+
60265
+ Use --accept-overriding-permissioned-as-with-self to proceed anyway.`));
60266
+ process.exit(1);
60267
+ }
60268
+ }
60269
+ var init_permissioned_as = __esm(async () => {
60270
+ init_services_gen();
60271
+ init_log();
60272
+ init_colors2();
60273
+ await __promiseAll([
60274
+ init_confirm(),
60275
+ init_types(),
60276
+ init_conf()
60277
+ ]);
60278
+ });
60279
+
60036
60280
  // src/core/extra_perms.ts
60037
60281
  function normalize5(value, source) {
60038
60282
  const perms = {};
@@ -62009,7 +62253,7 @@ async function push2(opts, filePath) {
62009
62253
  }
62010
62254
  } catch {}
62011
62255
  const codebases = await listSyncCodebases(opts);
62012
- await handleFile(filePath, workspace, [], opts.message, opts, await getRawWorkspaceDependencies(true), codebases);
62256
+ await handleFile(filePath, workspace, [], opts.message, opts, await getRawWorkspaceDependencies(true), codebases, await buildPermissionedAsContext(workspace.workspaceId, await readEffectiveSyncBehavior(opts, workspace)));
62013
62257
  info(colors.bold.underline.green(`Script ${filePath} pushed`));
62014
62258
  }
62015
62259
  async function findResourceFile(path) {
@@ -63104,6 +63348,7 @@ var init_script = __esm(async () => {
63104
63348
  await __promiseAll([
63105
63349
  init_auth(),
63106
63350
  init_context(),
63351
+ init_permissioned_as(),
63107
63352
  init_confirm(),
63108
63353
  init_utils(),
63109
63354
  init_specific_items(),
@@ -63867,149 +64112,6 @@ var init_shared_ui = __esm(async () => {
63867
64112
  await init_utils();
63868
64113
  });
63869
64114
 
63870
- // src/core/permissioned_as.ts
63871
- async function ensureUserCache(workspace, cache) {
63872
- if (cache.size > 0)
63873
- return;
63874
- const users = await listUsers({ workspace });
63875
- for (const user of users) {
63876
- cache.set(user.username, { username: user.username, email: user.email });
63877
- cache.set(user.email, { username: user.username, email: user.email });
63878
- }
63879
- }
63880
- async function lookupUsernameByEmail(workspace, email, cache) {
63881
- await ensureUserCache(workspace, cache);
63882
- const entry = cache.get(email);
63883
- if (!entry) {
63884
- throw new Error(`Could not find username for email '${email}' in workspace. ` + `Make sure the user exists in the workspace.`);
63885
- }
63886
- return entry.username;
63887
- }
63888
- function contentHasOnBehalfOf(content, typeStr) {
63889
- if (typeStr === "script") {
63890
- return !!content.match(/has_on_behalf_of:\s*(true)/) || !!content.match(/on_behalf_of_email:\s*["']?([^\s"']+)["']?/);
63891
- }
63892
- if (typeStr === "flow") {
63893
- return !!content.match(/has_on_behalf_of:\s*(true)/);
63894
- }
63895
- return false;
63896
- }
63897
- async function preCheckPermissionedAs(changes, userEmail, userIsAdminOrDeployer, acceptOverride, isInteractive) {
63898
- if (userIsAdminOrDeployer)
63899
- return;
63900
- const wouldChangeItems = [];
63901
- for (const change of changes) {
63902
- let typeStr;
63903
- try {
63904
- typeStr = getTypeStrFromPath(change.path);
63905
- } catch {
63906
- continue;
63907
- }
63908
- if (change.name === "added") {
63909
- const content = change.content;
63910
- if (!content)
63911
- continue;
63912
- const isScriptMeta = typeStr === "script" && (change.path.endsWith(".script.yaml") || change.path.endsWith(".script.json"));
63913
- const isFlowMeta = typeStr === "flow" && (change.path.endsWith("flow.yaml") || change.path.endsWith("flow.json"));
63914
- if ((isScriptMeta || isFlowMeta) && contentHasOnBehalfOf(content, typeStr)) {
63915
- const label = typeStr === "script" ? "(script owner)" : "(flow owner)";
63916
- wouldChangeItems.push({ path: change.path, currentOwner: label });
63917
- } else if (typeStr === "app") {
63918
- wouldChangeItems.push({
63919
- path: change.path,
63920
- currentOwner: "(app policy owner)"
63921
- });
63922
- }
63923
- continue;
63924
- }
63925
- if (change.name !== "edited")
63926
- continue;
63927
- const beforeContent = change.before;
63928
- if (!beforeContent)
63929
- continue;
63930
- let currentOwner;
63931
- if (typeStr === "script") {
63932
- if (change.path.endsWith(".script.yaml") || change.path.endsWith(".script.json")) {
63933
- const hasOboMatch = beforeContent.match(/has_on_behalf_of:\s*(true)/);
63934
- if (hasOboMatch) {
63935
- currentOwner = "(script owner)";
63936
- } else {
63937
- const emailMatch = beforeContent.match(/on_behalf_of_email:\s*["']?([^\s"']+)["']?/);
63938
- if (emailMatch) {
63939
- currentOwner = emailMatch[1];
63940
- }
63941
- }
63942
- }
63943
- } else if (typeStr === "flow") {
63944
- if (change.path.endsWith("flow.yaml") || change.path.endsWith("flow.json")) {
63945
- const hasOboMatch = beforeContent.match(/has_on_behalf_of:\s*(true)/);
63946
- if (hasOboMatch) {
63947
- wouldChangeItems.push({
63948
- path: change.path,
63949
- currentOwner: "(flow owner)"
63950
- });
63951
- }
63952
- }
63953
- continue;
63954
- } else if (typeStr === "app") {
63955
- wouldChangeItems.push({
63956
- path: change.path,
63957
- currentOwner: "(app policy owner)"
63958
- });
63959
- continue;
63960
- } else if (typeStr === "schedule") {
63961
- const match = beforeContent.match(/email:\s*["']?([^\s"']+)["']?/);
63962
- if (match) {
63963
- currentOwner = match[1];
63964
- }
63965
- } else if (typeStr.endsWith("_trigger")) {
63966
- wouldChangeItems.push({
63967
- path: change.path,
63968
- currentOwner: "(trigger owner)"
63969
- });
63970
- continue;
63971
- }
63972
- if (currentOwner && currentOwner !== userEmail) {
63973
- wouldChangeItems.push({ path: change.path, currentOwner });
63974
- }
63975
- }
63976
- if (wouldChangeItems.length === 0)
63977
- return;
63978
- const itemList = wouldChangeItems.map((item) => ` - ${item.path} (current owner: ${item.currentOwner})`).join(`
63979
- `);
63980
- const message = `You are not an admin or member of 'wm_deployers'. The following ${wouldChangeItems.length} item(s) ` + `will have their permissioned_as/email changed to your user (${userEmail}):
63981
- ${itemList}`;
63982
- if (acceptOverride) {
63983
- warn(colors.yellow(`Warning: ${message}`));
63984
- return;
63985
- }
63986
- if (isInteractive) {
63987
- warn(colors.yellow(message));
63988
- const proceed = await Confirm.prompt({
63989
- message: "Do you want to proceed? (use --accept-overriding-permissioned-as-with-self to skip this prompt)",
63990
- default: false
63991
- });
63992
- if (!proceed) {
63993
- info("Push cancelled.");
63994
- process.exit(0);
63995
- }
63996
- } else {
63997
- error(colors.red(`${message}
63998
-
63999
- Use --accept-overriding-permissioned-as-with-self to proceed anyway.`));
64000
- process.exit(1);
64001
- }
64002
- }
64003
- var init_permissioned_as = __esm(async () => {
64004
- init_services_gen();
64005
- init_log();
64006
- init_colors2();
64007
- await __promiseAll([
64008
- init_confirm(),
64009
- init_types()
64010
- ]);
64011
- });
64012
-
64013
64115
  // src/commands/resource/resource.ts
64014
64116
  import { mkdir as mkdir4, stat as stat6, writeFile as writeFile6, readdir as readdir3 } from "node:fs/promises";
64015
64117
  import nodePath from "node:path";
@@ -64654,22 +64756,6 @@ function computeWsSpecificFlagOnlyPushes(localMap, localSpecificItems, serverIte
64654
64756
  }
64655
64757
  return out;
64656
64758
  }
64657
- function resolveWsNameFromBranch(opts, branchName) {
64658
- const match = findWorkspaceByGitBranch(opts.workspaces, branchName);
64659
- return match ? match[0] : branchName;
64660
- }
64661
- function resolveWsNameForConfigFromFlags(opts) {
64662
- if (opts.branch) {
64663
- return resolveWsNameFromBranch(opts, opts.branch);
64664
- }
64665
- if (opts.workspace) {
64666
- const validKeys = getWorkspaceNames(opts.workspaces);
64667
- if (validKeys.includes(opts.workspace)) {
64668
- return opts.workspace;
64669
- }
64670
- }
64671
- return;
64672
- }
64673
64759
  function warnWorkspaceOverride(opts, wsNameForConfig) {
64674
64760
  if (!wsNameForConfig || !opts.workspaces)
64675
64761
  return;
@@ -64695,27 +64781,6 @@ function warnWorkspaceOverride(opts, wsNameForConfig) {
64695
64781
  function resolveWsNameForFiles(_opts, wsName) {
64696
64782
  return wsName;
64697
64783
  }
64698
- function inferWsNameFromProfile(opts, profile) {
64699
- if (!opts.workspaces)
64700
- return;
64701
- const wsNames = Object.keys(opts.workspaces).filter((k) => k !== "commonSpecificItems");
64702
- for (const name of wsNames) {
64703
- const entry = opts.workspaces[name];
64704
- if (!entry?.baseUrl)
64705
- continue;
64706
- try {
64707
- const entryUrl = new URL(entry.baseUrl).toString();
64708
- const profileUrl = new URL(profile.remote).toString();
64709
- const entryWsId = entry.workspaceId ?? name;
64710
- if (entryUrl === profileUrl && entryWsId === profile.workspaceId) {
64711
- return name;
64712
- }
64713
- } catch {
64714
- continue;
64715
- }
64716
- }
64717
- return;
64718
- }
64719
64784
  function mergeCliWithEffectiveOptions(cliOpts, effectiveOpts) {
64720
64785
  return Object.assign({}, effectiveOpts, cliOpts);
64721
64786
  }
@@ -67491,17 +67556,9 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
67491
67556
  ⚠ ${syncPushDestructiveWarning(opts.keepDeleted)}`));
67492
67557
  return;
67493
67558
  }
67494
- let permissionedAsContext = undefined;
67495
- if (parseSyncBehavior(opts.syncBehavior) >= 1) {
67496
- const user = await whoami({ workspace: workspace.workspaceId });
67497
- const userIsAdminOrDeployer = user.is_admin || (user.groups ?? []).includes("wm_deployers");
67498
- debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`);
67499
- permissionedAsContext = {
67500
- userCache: new Map,
67501
- userIsAdminOrDeployer,
67502
- userEmail: user.email
67503
- };
67504
- await preCheckPermissionedAs(changes.filter((c) => c.name !== "ws_specific_flag"), user.email, userIsAdminOrDeployer, opts.acceptOverridingPermissionedAsWithSelf ?? false, !!process.stdin.isTTY);
67559
+ const permissionedAsContext = await buildPermissionedAsContext(workspace.workspaceId, opts.syncBehavior);
67560
+ if (permissionedAsContext) {
67561
+ await preCheckPermissionedAs(changes.filter((c) => c.name !== "ws_specific_flag"), permissionedAsContext.userEmail, permissionedAsContext.userIsAdminOrDeployer, opts.acceptOverridingPermissionedAsWithSelf ?? false, !!process.stdin.isTTY);
67505
67562
  } else if (folderDefaultAnnotations && folderDefaultAnnotations.size > 0) {
67506
67563
  warn(colors.yellow(`This workspace has folder default_permissioned_as rules that affect ${folderDefaultAnnotations.size} item(s) being pushed, but syncBehavior is not set in wmill.yaml. Add 'syncBehavior: v1' to enable ownership preservation on update and on_behalf_of stripping on pull.`));
67507
67564
  }
@@ -72981,7 +73038,7 @@ async function push5(opts, filePath, remotePath) {
72981
73038
  await pushRawApp(workspace.workspaceId, remotePath, absoluteFilePath, undefined, merged.defaultTs);
72982
73039
  info(colors.bold.underline.green("Raw app pushed"));
72983
73040
  } else {
72984
- await pushApp(workspace.workspaceId, remotePath, absoluteFilePath);
73041
+ await pushApp(workspace.workspaceId, remotePath, absoluteFilePath, undefined, await buildPermissionedAsContext(workspace.workspaceId, await readEffectiveSyncBehavior(opts, workspace)));
72985
73042
  info(colors.bold.underline.green("App pushed"));
72986
73043
  }
72987
73044
  }
@@ -73006,7 +73063,8 @@ var init_app = __esm(async () => {
73006
73063
  init_lint2(),
73007
73064
  init_bundle_command(),
73008
73065
  init_new(),
73009
- init_generate_agents()
73066
+ init_generate_agents(),
73067
+ init_permissioned_as()
73010
73068
  ]);
73011
73069
  alreadySynced2 = [];
73012
73070
  APP_FOLDER_SUFFIXES = ["__raw_app", ".raw_app", "__app", ".app"];
@@ -73361,30 +73419,31 @@ async function pushVariable(workspace, remotePath, variable, localVariable, plai
73361
73419
  } catch {
73362
73420
  debug(`Variable ${remotePath} does not exist on remote`);
73363
73421
  }
73422
+ const { extra_perms: localPerms, ...localVariableBody } = localVariable;
73364
73423
  if (variable) {
73365
- if (isSuperset(localVariable, variable)) {
73424
+ if (isSuperset(localVariableBody, variable)) {
73366
73425
  debug(`Variable ${remotePath} is up-to-date`);
73367
- return;
73368
- }
73369
- debug(`Variable ${remotePath} is not up-to-date, updating`);
73370
- let nextIsSecret = undefined;
73371
- if (localVariable.is_secret !== variable.is_secret) {
73372
- if (localVariable.is_secret) {
73373
- nextIsSecret = true;
73374
- } else if (allowSecretDowngrade) {
73375
- nextIsSecret = false;
73426
+ } else {
73427
+ debug(`Variable ${remotePath} is not up-to-date, updating`);
73428
+ let nextIsSecret = undefined;
73429
+ if (localVariableBody.is_secret !== variable.is_secret) {
73430
+ if (localVariableBody.is_secret) {
73431
+ nextIsSecret = true;
73432
+ } else if (allowSecretDowngrade) {
73433
+ nextIsSecret = false;
73434
+ }
73376
73435
  }
73436
+ await updateVariable({
73437
+ workspace,
73438
+ path: remotePath.replaceAll(SEP16, "/"),
73439
+ alreadyEncrypted: !plainSecrets,
73440
+ requestBody: {
73441
+ ...localVariableBody,
73442
+ is_secret: nextIsSecret,
73443
+ ...wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}
73444
+ }
73445
+ });
73377
73446
  }
73378
- await updateVariable({
73379
- workspace,
73380
- path: remotePath.replaceAll(SEP16, "/"),
73381
- alreadyEncrypted: !plainSecrets,
73382
- requestBody: {
73383
- ...localVariable,
73384
- is_secret: nextIsSecret,
73385
- ...wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}
73386
- }
73387
- });
73388
73447
  } else {
73389
73448
  info(colors.yellow.bold(`Creating new variable ${remotePath}...`));
73390
73449
  await createVariable({
@@ -73392,11 +73451,12 @@ async function pushVariable(workspace, remotePath, variable, localVariable, plai
73392
73451
  alreadyEncrypted: !plainSecrets,
73393
73452
  requestBody: {
73394
73453
  path: remotePath.replaceAll(SEP16, "/"),
73395
- ...localVariable,
73454
+ ...localVariableBody,
73396
73455
  ...wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}
73397
73456
  }
73398
73457
  });
73399
73458
  }
73459
+ await applyExtraPermsDiff(workspace, "variable", remotePath.replaceAll(SEP16, "/"), localPerms, variable?.extra_perms);
73400
73460
  }
73401
73461
  async function push7(opts, filePath, remotePath) {
73402
73462
  const workspace = await resolveWorkspace(opts);
@@ -73482,6 +73542,7 @@ var init_variable = __esm(async () => {
73482
73542
  init_colors2();
73483
73543
  init_log();
73484
73544
  init_services_gen();
73545
+ init_extra_perms();
73485
73546
  await __promiseAll([
73486
73547
  init_auth(),
73487
73548
  init_context(),
@@ -73496,7 +73557,7 @@ var init_variable = __esm(async () => {
73496
73557
  // src/commands/schedule/schedule.ts
73497
73558
  import { mkdir as mkdir12, stat as stat13, writeFile as writeFile14 } from "node:fs/promises";
73498
73559
  import { dirname as dirname18 } from "node:path";
73499
- import { sep as SEP17 } from "node:path";
73560
+ import { sep as SEP17, resolve as pathResolve2 } from "node:path";
73500
73561
  async function list9(opts) {
73501
73562
  if (opts.json)
73502
73563
  setSilent(true);
@@ -73689,8 +73750,10 @@ async function disable(opts, path) {
73689
73750
  info(colors.yellow(`Schedule ${path} disabled.`));
73690
73751
  }
73691
73752
  async function push8(opts, filePath, remotePath) {
73753
+ filePath = pathResolve2(filePath);
73692
73754
  const workspace = await resolveWorkspace(opts);
73693
73755
  await requireLogin(opts);
73756
+ const syncBehavior = await readEffectiveSyncBehavior(opts, workspace);
73694
73757
  if (!validatePath(remotePath)) {
73695
73758
  return;
73696
73759
  }
@@ -73699,7 +73762,7 @@ async function push8(opts, filePath, remotePath) {
73699
73762
  throw new Error("file path must refer to a file.");
73700
73763
  }
73701
73764
  console.log(colors.bold.yellow("Pushing schedule..."));
73702
- await pushSchedule(workspace.workspaceId, remotePath, undefined, parseFromFile(filePath));
73765
+ await pushSchedule(workspace.workspaceId, remotePath, undefined, parseFromFile(filePath), await buildPermissionedAsContext(workspace.workspaceId, syncBehavior));
73703
73766
  console.log(colors.bold.underline.green("Schedule pushed"));
73704
73767
  }
73705
73768
  var import_yaml29, command17, schedule_default2;
@@ -75317,7 +75380,7 @@ var init_dependencies = __esm(async () => {
75317
75380
  // src/commands/trigger/trigger.ts
75318
75381
  import { mkdir as mkdir14, stat as stat15, writeFile as writeFile18 } from "node:fs/promises";
75319
75382
  import { dirname as dirname19 } from "node:path";
75320
- import { sep as SEP18 } from "node:path";
75383
+ import { sep as SEP18, resolve as pathResolve3 } from "node:path";
75321
75384
  async function getTrigger(triggerType, workspace, path) {
75322
75385
  const triggerFunctions = {
75323
75386
  http: getHttpTrigger,
@@ -75442,7 +75505,8 @@ async function pushNativeTrigger(workspace, filePath, _remoteTrigger, localTrigg
75442
75505
  is_flow: result.is_flow,
75443
75506
  service_config: result.service_config,
75444
75507
  error: result.error,
75445
- summary: result.summary
75508
+ summary: result.summary,
75509
+ enabled: result.enabled
75446
75510
  };
75447
75511
  debug(`Native trigger ${serviceName}/${externalId} exists on remote`);
75448
75512
  } catch {
@@ -75663,8 +75727,10 @@ async function extractTriggerKindFromPath(filePath) {
75663
75727
  return triggerMatch ? triggerMatch[1] : undefined;
75664
75728
  }
75665
75729
  async function push10(opts, filePath, remotePath) {
75730
+ filePath = pathResolve3(filePath);
75666
75731
  const workspace = await resolveWorkspace(opts);
75667
75732
  await requireLogin(opts);
75733
+ const syncBehavior = await readEffectiveSyncBehavior(opts, workspace);
75668
75734
  if (!validatePath(remotePath)) {
75669
75735
  return;
75670
75736
  }
@@ -75677,7 +75743,7 @@ async function push10(opts, filePath, remotePath) {
75677
75743
  if (!checkIfValidTrigger(triggerKind)) {
75678
75744
  throw new Error("Invalid trigger kind: " + triggerKind);
75679
75745
  }
75680
- await pushTrigger(triggerKind, workspace.workspaceId, remotePath, undefined, parseFromFile(filePath));
75746
+ await pushTrigger(triggerKind, workspace.workspaceId, remotePath, undefined, parseFromFile(filePath), await buildPermissionedAsContext(workspace.workspaceId, syncBehavior));
75681
75747
  console.log(colors.bold.underline.green("Trigger pushed"));
75682
75748
  }
75683
75749
  var import_yaml36, triggerTemplates, TRIGGER_SKIP_FIELDS, command21, trigger_default;
@@ -75692,7 +75758,9 @@ var init_trigger = __esm(async () => {
75692
75758
  init_types(),
75693
75759
  init_specific_items(),
75694
75760
  init_auth(),
75695
- init_context()
75761
+ init_context(),
75762
+ init_permissioned_as(),
75763
+ init_conf()
75696
75764
  ]);
75697
75765
  import_yaml36 = __toESM(require_dist(), 1);
75698
75766
  triggerTemplates = {
@@ -76254,7 +76322,7 @@ var init_local_path_scripts = __esm(async () => {
76254
76322
  });
76255
76323
 
76256
76324
  // src/commands/flow/flow.ts
76257
- import { dirname as dirname20, sep as SEP20 } from "node:path";
76325
+ import { dirname as dirname20, sep as SEP20, resolve as pathResolve4 } from "node:path";
76258
76326
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
76259
76327
  function normalizeOptionalString(value) {
76260
76328
  return typeof value === "string" && value.trim() === "" ? undefined : value ?? undefined;
@@ -76420,9 +76488,11 @@ async function push11(opts, filePath, remotePath) {
76420
76488
  if (!validatePath(remotePath)) {
76421
76489
  return;
76422
76490
  }
76491
+ filePath = pathResolve4(filePath);
76423
76492
  const workspace = await resolveWorkspace(opts);
76424
76493
  await requireLogin(opts);
76425
- await pushFlow(workspace.workspaceId, remotePath, filePath, opts.message);
76494
+ const syncBehavior = await readEffectiveSyncBehavior(opts, workspace);
76495
+ await pushFlow(workspace.workspaceId, remotePath, filePath, opts.message, await buildPermissionedAsContext(workspace.workspaceId, syncBehavior));
76426
76496
  info(colors.bold.underline.green("Flow pushed"));
76427
76497
  }
76428
76498
  async function list12(opts) {
@@ -77019,6 +77089,7 @@ var init_flow = __esm(async () => {
77019
77089
  init_script(),
77020
77090
  init_conf(),
77021
77091
  init_sync(),
77092
+ init_permissioned_as(),
77022
77093
  init_flow_metadata(),
77023
77094
  init_script(),
77024
77095
  init_codebase(),
@@ -82789,6 +82860,22 @@ def parse_sql_client_name(name: str) -> tuple[str, Optional[str]]
82789
82860
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
82790
82861
  # string, a tuple as a list.
82791
82862
  #
82863
+ # \`\`retry\`\` re-dispatches the task after a failure, inside \`\`@workflow\`\` only.
82864
+ # Every attempt is a step of its own (\`\`call_api\`\`, \`\`call_api#2\`\`, ...) and
82865
+ # the wait between two of them is a durable sleep, so a retrying task holds no
82866
+ # worker while it backs off. Keys: \`\`attempts\`\` (retries after the first
82867
+ # failure, a whole number from 0 to 100), \`\`delay\`\` (seconds before the first
82868
+ # retry, sub-second delays dropped), \`\`multiplier\`\` (applied to the delay
82869
+ # after each attempt, 1 keeps it constant), \`\`max_delay\`\` (ceiling in
82870
+ # seconds). \`\`attempts\`\` is required, and an out-of-range or unknown key is
82871
+ # rejected where the policy is written.
82872
+ #
82873
+ # A workflow sleeps once per round, so tasks backing off in the same fan-out
82874
+ # wait one after another rather than together: the delay before a fan-out
82875
+ # retries is the sum of every backoff pending in it, not the longest one, and
82876
+ # it grows with both the width of the fan-out and \`\`attempts\`\`. Retries with
82877
+ # no \`\`delay\`\` all go out in a single round.
82878
+ #
82792
82879
  # Usage::
82793
82880
  #
82794
82881
  # @task
@@ -82796,10 +82883,15 @@ def parse_sql_client_name(name: str) -> tuple[str, Optional[str]]
82796
82883
  #
82797
82884
  # @task(path="f/external_script", timeout=600, tag="gpu")
82798
82885
  # async def run_external(x: int): ...
82799
- def task(_func = None, path: Optional[str] = None, tag: Optional[str] = None, timeout: Optional[int] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
82886
+ #
82887
+ # @task(retry={"attempts": 3, "delay": 30, "multiplier": 2})
82888
+ # async def call_api(payload: dict): ...
82889
+ def task(_func = None, path: Optional[str] = None, tag: Optional[str] = None, timeout: Optional[int] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
82800
82890
 
82801
82891
  # Create a task that dispatches to a separate Windmill script.
82802
82892
  #
82893
+ # \`\`retry\`\` takes the same policy as :func:\`task\`.
82894
+ #
82803
82895
  # Usage::
82804
82896
  #
82805
82897
  # extract = task_script("f/data/extract", timeout=600)
@@ -82807,10 +82899,12 @@ def task(_func = None, path: Optional[str] = None, tag: Optional[str] = None, ti
82807
82899
  # @workflow
82808
82900
  # async def main():
82809
82901
  # data = await extract(url="https://...")
82810
- def task_script(path: str, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
82902
+ def task_script(path: str, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
82811
82903
 
82812
82904
  # Create a task that dispatches to a separate Windmill flow.
82813
82905
  #
82906
+ # \`\`retry\`\` takes the same policy as :func:\`task\`.
82907
+ #
82814
82908
  # Usage::
82815
82909
  #
82816
82910
  # pipeline = task_flow("f/etl/pipeline", priority=10)
@@ -82818,7 +82912,7 @@ def task_script(path: str, timeout: Optional[int] = None, tag: Optional[str] = N
82818
82912
  # @workflow
82819
82913
  # async def main():
82820
82914
  # result = await pipeline(input=data)
82821
- def task_flow(path: str, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
82915
+ def task_flow(path: str, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
82822
82916
 
82823
82917
  # Decorator marking an async function as a workflow-as-code entry point.
82824
82918
  #
@@ -84866,6 +84960,34 @@ A caught failure reads the same whether it came from a task or from a \`step()\`
84866
84960
  Import: \`import { workflow, task, taskScript, taskFlow, step, sleep, waitForApproval, getApprovalUrls, getResumeUrls, parallel } from "windmill-client"\`
84867
84961
 
84868
84962
  \`\`\`typescript
84963
+ /**
84964
+ * Re-dispatch policy for a failed task.
84965
+ *
84966
+ * Every attempt is a step of its own (\`fetch\`, \`fetch#2\`, \`fetch#3\`), and the
84967
+ * wait between two of them is a durable sleep, so a retrying task holds no
84968
+ * worker while it backs off.
84969
+ *
84970
+ * A workflow sleeps once per round, so tasks backing off in the same fan-out
84971
+ * wait one after another rather than together: the delay before a fan-out
84972
+ * retries is the sum of every backoff pending in it, not the longest one, and
84973
+ * it grows with both the width of the fan-out and \`attempts\`. Retries with no
84974
+ * \`delay\` all go out in a single round.
84975
+ */
84976
+ export interface TaskRetry {
84977
+ /** Attempts after the first failure: \`2\` runs the task at most 3 times.
84978
+ * A whole number from 0 to 100; anything else is rejected where the policy
84979
+ * is written. */
84980
+ attempts: number;
84981
+ /** Seconds to wait before the first retry. Default 0, retry immediately.
84982
+ * Sub-second delays are dropped — a durable sleep resolves to the second. */
84983
+ delay?: number;
84984
+ /** Applied to the delay after each attempt: 1 (the default) keeps it
84985
+ * constant, 2 doubles it. */
84986
+ multiplier?: number;
84987
+ /** Ceiling for the delay in seconds, for a \`multiplier\` above 1. */
84988
+ max_delay?: number;
84989
+ }
84990
+
84869
84991
  export interface TaskOptions {
84870
84992
  timeout?: number;
84871
84993
  tag?: string;
@@ -84874,6 +84996,7 @@ export interface TaskOptions {
84874
84996
  concurrency_limit?: number;
84875
84997
  concurrency_key?: string;
84876
84998
  concurrency_time_window_s?: number;
84999
+ retry?: TaskRetry;
84877
85000
  }
84878
85001
 
84879
85002
  /**
@@ -84891,9 +85014,11 @@ export async function getResumeUrls(approver?: string, flowLevel?: boolean): Pro
84891
85014
  * @example
84892
85015
  * const extract_data = task(async (url: string) => { ... });
84893
85016
  * const run_external = task("f/external_script", async (x: number) => { ... });
85017
+ * const call_api = task(fetchOrders, { retry: { attempts: 3, delay: 30, multiplier: 2 } });
84894
85018
  *
84895
85019
  * Inside a \`workflow()\`, calling a task dispatches it as a step.
84896
- * Outside a workflow, the function body executes directly.
85020
+ * Outside a workflow, the function body executes directly and
85021
+ * {@link TaskOptions} — retry included — does not apply.
84897
85022
  *
84898
85023
  * A task runs as its own job, so its result is always encoded as JSON and
84899
85024
  * decoded back before the caller sees it: a \`Date\` comes back as a string, a
@@ -85037,6 +85162,22 @@ def get_resume_urls(approver: str = None, flow_level: bool = None) -> dict
85037
85162
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
85038
85163
  # string, a tuple as a list.
85039
85164
  #
85165
+ # \`\`retry\`\` re-dispatches the task after a failure, inside \`\`@workflow\`\` only.
85166
+ # Every attempt is a step of its own (\`\`call_api\`\`, \`\`call_api#2\`\`, ...) and
85167
+ # the wait between two of them is a durable sleep, so a retrying task holds no
85168
+ # worker while it backs off. Keys: \`\`attempts\`\` (retries after the first
85169
+ # failure, a whole number from 0 to 100), \`\`delay\`\` (seconds before the first
85170
+ # retry, sub-second delays dropped), \`\`multiplier\`\` (applied to the delay
85171
+ # after each attempt, 1 keeps it constant), \`\`max_delay\`\` (ceiling in
85172
+ # seconds). \`\`attempts\`\` is required, and an out-of-range or unknown key is
85173
+ # rejected where the policy is written.
85174
+ #
85175
+ # A workflow sleeps once per round, so tasks backing off in the same fan-out
85176
+ # wait one after another rather than together: the delay before a fan-out
85177
+ # retries is the sum of every backoff pending in it, not the longest one, and
85178
+ # it grows with both the width of the fan-out and \`\`attempts\`\`. Retries with
85179
+ # no \`\`delay\`\` all go out in a single round.
85180
+ #
85040
85181
  # Usage::
85041
85182
  #
85042
85183
  # @task
@@ -85044,10 +85185,15 @@ def get_resume_urls(approver: str = None, flow_level: bool = None) -> dict
85044
85185
  #
85045
85186
  # @task(path="f/external_script", timeout=600, tag="gpu")
85046
85187
  # async def run_external(x: int): ...
85047
- def task(_func = None, *, path: Optional[str] = None, tag: Optional[str] = None, timeout: Optional[int] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
85188
+ #
85189
+ # @task(retry={"attempts": 3, "delay": 30, "multiplier": 2})
85190
+ # async def call_api(payload: dict): ...
85191
+ def task(_func = None, *, path: Optional[str] = None, tag: Optional[str] = None, timeout: Optional[int] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
85048
85192
 
85049
85193
  # Create a task that dispatches to a separate Windmill script.
85050
85194
  #
85195
+ # \`\`retry\`\` takes the same policy as :func:\`task\`.
85196
+ #
85051
85197
  # Usage::
85052
85198
  #
85053
85199
  # extract = task_script("f/data/extract", timeout=600)
@@ -85055,10 +85201,12 @@ def task(_func = None, *, path: Optional[str] = None, tag: Optional[str] = None,
85055
85201
  # @workflow
85056
85202
  # async def main():
85057
85203
  # data = await extract(url="https://...")
85058
- def task_script(path: str, *, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
85204
+ def task_script(path: str, *, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
85059
85205
 
85060
85206
  # Create a task that dispatches to a separate Windmill flow.
85061
85207
  #
85208
+ # \`\`retry\`\` takes the same policy as :func:\`task\`.
85209
+ #
85062
85210
  # Usage::
85063
85211
  #
85064
85212
  # pipeline = task_flow("f/etl/pipeline", priority=10)
@@ -85066,7 +85214,7 @@ def task_script(path: str, *, timeout: Optional[int] = None, tag: Optional[str]
85066
85214
  # @workflow
85067
85215
  # async def main():
85068
85216
  # result = await pipeline(input=data)
85069
- def task_flow(path: str, *, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None)
85217
+ def task_flow(path: str, *, timeout: Optional[int] = None, tag: Optional[str] = None, cache_ttl: Optional[int] = None, priority: Optional[int] = None, concurrency_limit: Optional[int] = None, concurrency_key: Optional[str] = None, concurrency_time_window_s: Optional[int] = None, retry: Optional[dict] = None)
85070
85218
 
85071
85219
  # Decorator marking an async function as a workflow-as-code entry point.
85072
85220
  #
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.804.0",
3
+ "version": "1.806.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",