windmill-cli 1.830.0 → 1.832.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 +285 -81
  2. package/package.json +4 -4
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.830.0",
16769
+ VERSION: "1.832.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -20051,7 +20051,7 @@ var init_auth = __esm(async () => {
20051
20051
  });
20052
20052
 
20053
20053
  // src/core/constants.ts
20054
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.830.0";
20054
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.832.0";
20055
20055
 
20056
20056
  // src/utils/resource_folders.ts
20057
20057
  import { existsSync } from "node:fs";
@@ -20631,6 +20631,8 @@ var init_script_common = __esm(async () => {
20631
20631
  "py311",
20632
20632
  "py312",
20633
20633
  "py313",
20634
+ "py314",
20635
+ "py315",
20634
20636
  "sandbox"
20635
20637
  ],
20636
20638
  bun: ["npm", "nodejs", "native", "nobundling", "sandbox"],
@@ -34291,7 +34293,7 @@ function conditionsFor(svelte) {
34291
34293
  function detectFrameworks(appDir) {
34292
34294
  const packageJsonPath = path6.join(appDir, "package.json");
34293
34295
  if (!fs9.existsSync(packageJsonPath)) {
34294
- return { svelte: false, vue: false };
34296
+ return { svelte: false };
34295
34297
  }
34296
34298
  try {
34297
34299
  const packageJson = JSON.parse(readTextFileSync(packageJsonPath));
@@ -34300,11 +34302,10 @@ function detectFrameworks(appDir) {
34300
34302
  ...packageJson.devDependencies
34301
34303
  };
34302
34304
  return {
34303
- svelte: "svelte" in allDeps,
34304
- vue: "vue" in allDeps
34305
+ svelte: "svelte" in allDeps
34305
34306
  };
34306
34307
  } catch {
34307
- return { svelte: false, vue: false };
34308
+ return { svelte: false };
34308
34309
  }
34309
34310
  }
34310
34311
  function esmConditionTarget(subpath) {
@@ -34413,10 +34414,6 @@ async function createFrameworkPlugins(appDir) {
34413
34414
  info(colors.blue("\uD83D\uDD27 Svelte detected, adding svelte plugin..."));
34414
34415
  plugins.push(createSveltePlugin(appDir));
34415
34416
  }
34416
- if (frameworks.vue) {
34417
- info(colors.blue("\uD83D\uDD27 Vue detected, adding vue plugin..."));
34418
- throw new Error("Vue plugin not supported yet");
34419
- }
34420
34417
  return plugins;
34421
34418
  }
34422
34419
  async function ensureNodeModules(appDir) {
@@ -34443,7 +34440,7 @@ async function createBundle(options = {}) {
34443
34440
  const esbuild = await getEsbuild();
34444
34441
  const appDir = options.entryPoint ? path6.dirname(options.entryPoint) : process14.cwd();
34445
34442
  const frameworks = detectFrameworks(appDir);
34446
- const defaultEntry = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
34443
+ const defaultEntry = frameworks.svelte ? "index.ts" : "index.tsx";
34447
34444
  const entryPoint = options.entryPoint ?? defaultEntry;
34448
34445
  const outDir = options.outDir ?? "dist";
34449
34446
  const sourcemap = options.sourcemap ?? false;
@@ -57057,7 +57054,7 @@ var init_openflow = __esm(() => {
57057
57054
  openflow_default = {
57058
57055
  openapi: "3.0.3",
57059
57056
  info: {
57060
- version: "1.830.0",
57057
+ version: "1.832.0",
57061
57058
  title: "OpenFlow Spec",
57062
57059
  contact: {
57063
57060
  name: "Ruben Fiszel",
@@ -66550,6 +66547,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66550
66547
  error(`Failed to parse app.yaml at path: ${p}`);
66551
66548
  throw error2;
66552
66549
  }
66550
+ stripEditorState(app);
66553
66551
  let inlineScripts;
66554
66552
  try {
66555
66553
  inlineScripts = extractInlineScriptsForApps(undefined, app?.["value"], newPathAssigner(defaultTs, {
@@ -66570,6 +66568,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66570
66568
  };
66571
66569
  }
66572
66570
  markAccessFromPolicy(app);
66571
+ markIsolationFromPolicy(app, false);
66573
66572
  app.policy = undefined;
66574
66573
  yield {
66575
66574
  isDirectory: false,
@@ -66607,6 +66606,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66607
66606
  throw error2;
66608
66607
  }
66609
66608
  markAccessFromPolicy(rawApp);
66609
+ markIsolationFromPolicy(rawApp, true);
66610
66610
  rawApp.policy = undefined;
66611
66611
  delete rawApp?.["custom_path"];
66612
66612
  let inlineScripts;
@@ -67421,12 +67421,17 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
67421
67421
  }
67422
67422
  return o;
67423
67423
  } else {
67424
+ let o;
67424
67425
  try {
67425
- return yamlParseContent(k, v);
67426
+ o = yamlParseContent(k, v);
67426
67427
  } catch (error2) {
67427
67428
  error(`Failed to parse YAML content at path: ${k}`);
67428
67429
  throw error2;
67429
67430
  }
67431
+ if (path14.basename(k) == "app.yaml") {
67432
+ stripEditorState(o);
67433
+ }
67434
+ return o;
67430
67435
  }
67431
67436
  }
67432
67437
  const codebaseChanges = {};
@@ -70881,6 +70886,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70881
70886
  }
70882
70887
  const appFilePath = localPath + "raw_app.yaml";
70883
70888
  const localApp = await yamlParseFile(appFilePath);
70889
+ const isolation = statedIsolation(localApp, true);
70884
70890
  const backendPath = path16.join(localPath, APP_BACKEND_FOLDER);
70885
70891
  const runnablesFromBackend = await loadRunnablesFromBackend(backendPath, defaultTs);
70886
70892
  let runnables;
@@ -70897,12 +70903,12 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70897
70903
  repopulateFields(runnables);
70898
70904
  const appForPolicy = { ...localApp, runnables };
70899
70905
  const preserveFields = preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsContext);
70900
- await generatingPolicy(appForPolicy, remotePath, executionModeForPush(localApp, deployedPolicy), basePolicy(localApp, deployedPolicy, !!preserveFields.preserve_on_behalf_of));
70906
+ await generatingPolicy(appForPolicy, remotePath, executionModeForPush(localApp, deployedPolicy), basePolicy(localApp, deployedPolicy, !!preserveFields.preserve_on_behalf_of), isolation);
70901
70907
  const files = await collectAppFiles(localPath);
70902
70908
  async function createBundleRaw() {
70903
70909
  info(colors.yellow.bold(`Creating raw app ${remotePath} bundle...`));
70904
70910
  const frameworks = detectFrameworks(localPath);
70905
- const entryFile = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
70911
+ const entryFile = frameworks.svelte ? "index.ts" : "index.tsx";
70906
70912
  const entryPoint = localPath + entryFile;
70907
70913
  const sharedUiDir = path16.join(process.cwd(), "ui");
70908
70914
  return await createBundle({
@@ -70916,9 +70922,14 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70916
70922
  if (localApp.data) {
70917
70923
  value.data = localApp.data;
70918
70924
  }
70919
- const { extra_perms: localPerms, ...localAppNoPerms } = localApp;
70925
+ const {
70926
+ extra_perms: localPerms,
70927
+ sandbox: _sandbox,
70928
+ frontend_api: _frontendApi,
70929
+ ...localAppNoPerms
70930
+ } = localApp;
70920
70931
  if (app) {
70921
- const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app);
70932
+ const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && isolationUpToDate(isolation, deployedPolicy, true);
70922
70933
  const filesUpToDate = deepEqual(files, app.value?.files);
70923
70934
  if (metadataUpToDate && filesUpToDate) {
70924
70935
  info(colors.green(`App ${remotePath} is up to date`));
@@ -70965,11 +70976,11 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70965
70976
  }
70966
70977
  await applyExtraPermsDiff(workspace, "raw_app", remotePath, localPerms, app?.extra_perms);
70967
70978
  }
70968
- async function generatingPolicy(app, path, executionMode, base) {
70979
+ async function generatingPolicy(app, path, executionMode, base, isolation) {
70969
70980
  info(colors.gray(`Generating fresh policy for app ${path}...`));
70970
70981
  try {
70971
70982
  app.policy = await Q(app.runnables, base);
70972
- finalizeDerivedPolicy(app.policy, executionMode);
70983
+ finalizeDerivedPolicy(app.policy, executionMode, isolation, true);
70973
70984
  } catch (e) {
70974
70985
  error(colors.red(`Error generating policy for app ${path}: ${e}`));
70975
70986
  throw e;
@@ -72050,7 +72061,7 @@ async function dev(opts, appFolder) {
72050
72061
  });
72051
72062
  const shouldOpen = opts.open ?? true;
72052
72063
  const frameworks = detectFrameworks(process17.cwd());
72053
- const defaultEntry = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
72064
+ const defaultEntry = frameworks.svelte ? "index.ts" : "index.tsx";
72054
72065
  const entryPoint = opts.entry ?? defaultEntry;
72055
72066
  if (!fs13.existsSync(entryPoint)) {
72056
72067
  error(colors.red(`Entry point "${entryPoint}" not found. Please specify a valid entry point with --entry.`));
@@ -73314,7 +73325,7 @@ var init_dev = __esm(async () => {
73314
73325
  ]);
73315
73326
  command10 = new Command().description("Start a development server for building apps with live reload and hot module replacement").arguments("[app_folder:string]").option("--port <port:number>", "Port to run the dev server on (will find next available port if occupied)").option("--host <host:string>", "Host to bind the dev server to", {
73316
73327
  default: DEFAULT_HOST
73317
- }).option("--entry <entry:string>", "Entry point file (default: index.ts for Svelte/Vue, index.tsx otherwise)").option("--no-open", "Don't automatically open the browser").option("--recording", "Frame the app in a shell with a Record button, to capture a replayable session recording of the app under development").action(dev);
73328
+ }).option("--entry <entry:string>", "Entry point file (default: index.ts for Svelte, index.tsx otherwise)").option("--no-open", "Don't automatically open the browser").option("--recording", "Frame the app in a shell with a Record button, to capture a replayable session recording of the app under development").action(dev);
73318
73329
  dev_default = command10;
73319
73330
  });
73320
73331
 
@@ -73330,8 +73341,31 @@ function validateRawAppYaml(appData) {
73330
73341
  } else if (typeof appData.summary !== "string") {
73331
73342
  errors.push("Field 'summary' must be a string");
73332
73343
  }
73344
+ try {
73345
+ statedIsolation(appData, true);
73346
+ } catch (error) {
73347
+ errors.push(error.message);
73348
+ }
73333
73349
  return { errors, warnings };
73334
73350
  }
73351
+ async function viewerIdentityInputWarnings(runnables) {
73352
+ const warnings = [];
73353
+ for (const [id, runnable] of Object.entries(runnables)) {
73354
+ const { language, content } = runnable?.inlineScript ?? {};
73355
+ if (!SQL_LANGUAGES.has(language) || typeof content !== "string") {
73356
+ continue;
73357
+ }
73358
+ const { schema } = await inferSchema(language, content, {}, id);
73359
+ for (const arg of VIEWER_IDENTITY_ARGS) {
73360
+ const field = runnable.fields?.[arg];
73361
+ const serverFilled = field?.ctx !== undefined || field?.value !== undefined;
73362
+ if (arg in (schema?.properties ?? {}) && !serverFilled) {
73363
+ warnings.push(`Runnable '${id}': argument '${arg}' is a frontend input, so a viewer can send any value. ` + `If it identifies the viewer, set 'fields: { ${arg}: { ctx: ${arg} } }' in backend/${id}.yaml (next to 'type: inline') so the server fills it.`);
73364
+ }
73365
+ }
73366
+ }
73367
+ return warnings;
73368
+ }
73335
73369
  async function validateRunnables(appDir, appData) {
73336
73370
  const errors = [];
73337
73371
  const warnings = [];
@@ -73344,6 +73378,7 @@ async function validateRunnables(appDir, appData) {
73344
73378
  ` + ` - Runnable YAML files in the 'backend/' folder (e.g., backend/myRunnable.yaml)
73345
73379
  ` + " - Or a 'runnables' field in raw_app.yaml (legacy format)");
73346
73380
  } else if (hasBackendRunnables) {
73381
+ warnings.push(...await viewerIdentityInputWarnings(runnablesFromBackend));
73347
73382
  info(colors.gray(` Found ${Object.keys(runnablesFromBackend).length} runnable(s) in backend folder`));
73348
73383
  } else if (hasYamlRunnables) {
73349
73384
  info(colors.gray(` Found ${Object.keys(appData.runnables).length} runnable(s) in raw_app.yaml (legacy format)`));
@@ -73357,7 +73392,7 @@ async function validateBuild(appDir) {
73357
73392
  try {
73358
73393
  info(colors.blue("\uD83D\uDD28 Testing build..."));
73359
73394
  const frameworks = detectFrameworks(appDir);
73360
- const entryFile = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
73395
+ const entryFile = frameworks.svelte ? "index.ts" : "index.tsx";
73361
73396
  const entryPoint = path20.join(appDir, entryFile);
73362
73397
  await createBundle({
73363
73398
  entryPoint,
@@ -73444,7 +73479,7 @@ async function lint2(opts, appFolder) {
73444
73479
  ✅ All checks passed
73445
73480
  `));
73446
73481
  }
73447
- var command11, lint_default2;
73482
+ var SQL_LANGUAGES, VIEWER_IDENTITY_ARGS, command11, lint_default2;
73448
73483
  var init_lint2 = __esm(async () => {
73449
73484
  init_mod3();
73450
73485
  init_colors2();
@@ -73454,8 +73489,20 @@ var init_lint2 = __esm(async () => {
73454
73489
  init_bundle(),
73455
73490
  init_app_metadata(),
73456
73491
  init_raw_apps(),
73492
+ init_metadata(),
73493
+ init_app(),
73457
73494
  init_resource_folders()
73458
73495
  ]);
73496
+ SQL_LANGUAGES = new Set([
73497
+ "postgresql",
73498
+ "mysql",
73499
+ "bigquery",
73500
+ "snowflake",
73501
+ "mssql",
73502
+ "oracledb",
73503
+ "duckdb"
73504
+ ]);
73505
+ VIEWER_IDENTITY_ARGS = ["username", "email", "groups"];
73459
73506
  command11 = new Command().description("Lint a raw app folder to validate structure and buildability").arguments("[app_folder:string]").option("--fix", "Attempt to fix common issues (not implemented yet)").action(lint2);
73460
73507
  lint_default2 = command11;
73461
73508
  });
@@ -73466,7 +73513,7 @@ import * as path21 from "node:path";
73466
73513
  import process19 from "node:process";
73467
73514
  function entryPointFor(appDir) {
73468
73515
  const frameworks = detectFrameworks(appDir);
73469
- const candidates = frameworks.svelte || frameworks.vue ? ["index.ts", "index.tsx", "index.js"] : ["index.tsx", "index.ts", "index.js"];
73516
+ const candidates = frameworks.svelte ? ["index.ts", "index.tsx", "index.js"] : ["index.tsx", "index.ts", "index.js"];
73470
73517
  const entry = candidates.find((c) => fs15.existsSync(path21.join(appDir, c)));
73471
73518
  if (!entry) {
73472
73519
  throw new Error(`No entry point in ${appDir}: expected one of ${candidates.join(", ")}`);
@@ -73624,7 +73671,7 @@ async function newApp(opts) {
73624
73671
  error(colors.red(`Invalid path: ${validation.error}`));
73625
73672
  }
73626
73673
  }
73627
- const VALID_FRAMEWORKS = ["react19", "react18", "svelte5", "vue"];
73674
+ const VALID_FRAMEWORKS = ["react19", "react18", "svelte5"];
73628
73675
  let framework;
73629
73676
  if (opts.framework !== undefined) {
73630
73677
  if (!VALID_FRAMEWORKS.includes(opts.framework)) {
@@ -73638,8 +73685,7 @@ async function newApp(opts) {
73638
73685
  options: [
73639
73686
  { name: "React 19 (Recommended)", value: "react19" },
73640
73687
  { name: "React 18", value: "react18" },
73641
- { name: "Svelte 5", value: "svelte5" },
73642
- { name: "Vue 3", value: "vue" }
73688
+ { name: "Svelte 5", value: "svelte5" }
73643
73689
  ]
73644
73690
  });
73645
73691
  }
@@ -74006,18 +74052,7 @@ import './index.css'
74006
74052
  const app = mount(App, { target: document.getElementById("root")! });
74007
74053
 
74008
74054
  export default app;
74009
- `, appVue = `<template>
74010
- <h1>Hello {{ msg }}</h1>
74011
- </template>
74012
-
74013
- <script setup>
74014
- import { ref } from 'vue';
74015
- const msg = ref('world');
74016
- </script>`, indexVue = `import { createApp } from 'vue'
74017
- import App from './App.vue'
74018
- import "./index.css";
74019
-
74020
- createApp(App).mount('#root')`, indexCss = `body {
74055
+ `, indexCss = `body {
74021
74056
  margin: 0;
74022
74057
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
74023
74058
  background-color: #f5f5f5;
@@ -74097,26 +74132,11 @@ var init_new = __esm(async () => {
74097
74132
  "svelte": "^5.55.5",
74098
74133
  "windmill-client": "^1"
74099
74134
  }
74100
- }`
74101
- }
74102
- },
74103
- vue: {
74104
- name: "Vue 3",
74105
- files: {
74106
- "/index.ts": indexVue,
74107
- "/App.vue": appVue,
74108
- "/index.css": indexCss,
74109
- "/package.json": `{
74110
- "dependencies": {
74111
- "core-js": "3.26.1",
74112
- "vue": "3.5.13",
74113
- "windmill-client": "^1"
74114
- }
74115
74135
  }`
74116
74136
  }
74117
74137
  }
74118
74138
  };
74119
- command13 = new Command().description("create a new raw app from a template").option("--summary <summary:string>", "App summary (short description). Skips the prompt when provided. Triggers non-interactive mode.").option("--path <path:string>", "App path (e.g., f/folder/my_app or u/username/my_app). Skips the prompt when provided. Triggers non-interactive mode.").option("--framework <framework:string>", "Framework template: react19 | react18 | svelte5 | vue. Skips the prompt when provided. Triggers non-interactive mode.").option("--datatable <datatable:string>", "Datatable to wire up. Without this flag in non-interactive mode, no datatable is configured.").option("--schema <schema:string>", "Schema to use with --datatable. If it doesn't exist yet, a sql_to_apply/ migration (CREATE SCHEMA IF NOT EXISTS) is written for it.").option("--overwrite", "Overwrite the target directory if it already exists, without prompting.").option("--no-open-in-desktop", "Do not prompt to open the new app in Claude Desktop.").action(newApp);
74139
+ command13 = new Command().description("create a new raw app from a template").option("--summary <summary:string>", "App summary (short description). Skips the prompt when provided. Triggers non-interactive mode.").option("--path <path:string>", "App path (e.g., f/folder/my_app or u/username/my_app). Skips the prompt when provided. Triggers non-interactive mode.").option("--framework <framework:string>", "Framework template: react19 | react18 | svelte5. Skips the prompt when provided. Triggers non-interactive mode.").option("--datatable <datatable:string>", "Datatable to wire up. Without this flag in non-interactive mode, no datatable is configured.").option("--schema <schema:string>", "Schema to use with --datatable. If it doesn't exist yet, a sql_to_apply/ migration (CREATE SCHEMA IF NOT EXISTS) is written for it.").option("--overwrite", "Overwrite the target directory if it already exists, without prompting.").option("--no-open-in-desktop", "Do not prompt to open the new app in Claude Desktop.").action(newApp);
74120
74140
  new_default = command13;
74121
74141
  });
74122
74142
 
@@ -74187,6 +74207,11 @@ function replaceInlineScripts2(rec, localPath, addType) {
74187
74207
  }
74188
74208
  return [];
74189
74209
  }
74210
+ function stripEditorState(app) {
74211
+ if (app?.value && typeof app.value == "object") {
74212
+ delete app.value.parent_version;
74213
+ }
74214
+ }
74190
74215
  function isExecutionModeAnonymous(app) {
74191
74216
  return app?.["policy"]?.["execution_mode"] == "anonymous";
74192
74217
  }
@@ -74217,6 +74242,56 @@ function executionModeForPush(localApp, deployedPolicy) {
74217
74242
  }
74218
74243
  return deployedPolicy?.execution_mode === "viewer" ? "viewer" : "publisher";
74219
74244
  }
74245
+ function markIsolationFromPolicy(app, rawApp) {
74246
+ if (app?.["policy"]?.["sandbox"] !== true) {
74247
+ return;
74248
+ }
74249
+ app.sandbox = true;
74250
+ const scopes = app.policy.frontend_sdk_scopes;
74251
+ if (rawApp && Array.isArray(scopes) && scopes.length > 0) {
74252
+ app.frontend_api = scopes;
74253
+ }
74254
+ }
74255
+ function statedIsolation(localApp, rawApp) {
74256
+ const sandbox = localApp?.["sandbox"];
74257
+ const scopes = localApp?.["frontend_api"] ?? [];
74258
+ if (sandbox !== undefined && typeof sandbox !== "boolean") {
74259
+ throw new Error("'sandbox' must be true or false");
74260
+ }
74261
+ if (!Array.isArray(scopes) || scopes.some((s) => typeof s !== "string")) {
74262
+ throw new Error("'frontend_api' must be a list of scopes");
74263
+ }
74264
+ if (scopes.length > 0 && !rawApp) {
74265
+ throw new Error("'frontend_api' is only available to full-code apps");
74266
+ }
74267
+ const seen = new Set;
74268
+ for (const scope of scopes) {
74269
+ if (!FRONTEND_API_SCOPES.includes(scope)) {
74270
+ throw new Error(`Invalid frontend_api scope '${scope}'. Allowed scopes: ${FRONTEND_API_SCOPES.join(", ")}`);
74271
+ }
74272
+ if (seen.has(scope)) {
74273
+ throw new Error(`Duplicate frontend_api scope '${scope}'`);
74274
+ }
74275
+ seen.add(scope);
74276
+ }
74277
+ if (scopes.length > 0 && sandbox !== true) {
74278
+ throw new Error("'frontend_api' requires 'sandbox: true': an unsandboxed app gets no frontend API token");
74279
+ }
74280
+ return sandbox === undefined ? undefined : { sandbox, frontendApi: scopes };
74281
+ }
74282
+ function isolationUpToDate(isolation, deployedPolicy, rawApp) {
74283
+ if (!isolation) {
74284
+ return true;
74285
+ }
74286
+ if (deployedPolicy?.sandbox === true !== isolation.sandbox) {
74287
+ return false;
74288
+ }
74289
+ if (!rawApp) {
74290
+ return true;
74291
+ }
74292
+ const deployed = deployedPolicy?.frontend_sdk_scopes ?? [];
74293
+ return deployed.length === isolation.frontendApi.length && deployed.every((s, i) => s === isolation.frontendApi[i]);
74294
+ }
74220
74295
  async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext) {
74221
74296
  if (alreadySynced2.includes(localPath)) {
74222
74297
  return;
@@ -74240,12 +74315,19 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
74240
74315
  }
74241
74316
  const path = localPath + "app.yaml";
74242
74317
  const localApp = await yamlParseFile(path);
74318
+ stripEditorState(localApp);
74319
+ const isolation = statedIsolation(localApp, false);
74243
74320
  replaceInlineScripts2(localApp.value, localPath, true);
74244
74321
  const preserveFields = preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsContext);
74245
- await generatingPolicy2(localApp, remotePath, executionModeForPush(localApp, deployedPolicy), basePolicy(localApp, deployedPolicy, !!preserveFields.preserve_on_behalf_of));
74246
- const { extra_perms: localPerms, ...localAppBody } = localApp;
74322
+ await generatingPolicy2(localApp, remotePath, executionModeForPush(localApp, deployedPolicy), basePolicy(localApp, deployedPolicy, !!preserveFields.preserve_on_behalf_of), isolation);
74323
+ const {
74324
+ extra_perms: localPerms,
74325
+ sandbox: _sandbox,
74326
+ frontend_api: _frontendApi,
74327
+ ...localAppBody
74328
+ } = localApp;
74247
74329
  if (app) {
74248
- if (isSuperset(localAppBody, app)) {
74330
+ if (isSuperset(localAppBody, app) && isolationUpToDate(isolation, deployedPolicy, false)) {
74249
74331
  info(colors.green(`App ${remotePath} is up to date`));
74250
74332
  } else {
74251
74333
  info(colors.bold.yellow(`Updating app ${remotePath}...`));
@@ -74275,11 +74357,11 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
74275
74357
  }
74276
74358
  await applyExtraPermsDiff(workspace, "app", remotePath, localPerms, app?.extra_perms);
74277
74359
  }
74278
- async function generatingPolicy2(app, path, executionMode, base) {
74360
+ async function generatingPolicy2(app, path, executionMode, base, isolation) {
74279
74361
  info(colors.gray(`Generating fresh policy for app ${path}...`));
74280
74362
  try {
74281
74363
  app.policy = await G3(app.value, base);
74282
- finalizeDerivedPolicy(app.policy, executionMode);
74364
+ finalizeDerivedPolicy(app.policy, executionMode, isolation);
74283
74365
  } catch (e) {
74284
74366
  error(colors.red(`Error generating policy for app ${path}: ${e}`));
74285
74367
  throw e;
@@ -74303,9 +74385,15 @@ function preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsCont
74303
74385
  info(`Preserving ${deployedPolicy?.on_behalf_of_email ?? onBehalfOf} as permissioned_as for app ${remotePath}`);
74304
74386
  return { preserve_on_behalf_of: true };
74305
74387
  }
74306
- function finalizeDerivedPolicy(policy, executionMode) {
74388
+ function finalizeDerivedPolicy(policy, executionMode, isolation, rawApp = false) {
74307
74389
  policy.triggerables = undefined;
74308
74390
  policy.execution_mode = executionMode;
74391
+ if (isolation) {
74392
+ policy.sandbox = isolation.sandbox;
74393
+ if (rawApp) {
74394
+ policy.frontend_sdk_scopes = isolation.frontendApi.length > 0 ? isolation.frontendApi : undefined;
74395
+ }
74396
+ }
74309
74397
  }
74310
74398
  async function list6(opts) {
74311
74399
  const workspace = await resolveWorkspace(opts);
@@ -74417,7 +74505,7 @@ async function push5(opts, filePath, remotePath) {
74417
74505
  info(colors.bold.underline.green("App pushed"));
74418
74506
  }
74419
74507
  }
74420
- var alreadySynced2, APP_FOLDER_SUFFIXES, command14, app_default;
74508
+ var alreadySynced2, FRONTEND_API_SCOPES, APP_FOLDER_SUFFIXES, command14, app_default;
74421
74509
  var init_app = __esm(async () => {
74422
74510
  init_mod3();
74423
74511
  init_mod6();
@@ -74442,6 +74530,15 @@ var init_app = __esm(async () => {
74442
74530
  init_permissioned_as()
74443
74531
  ]);
74444
74532
  alreadySynced2 = [];
74533
+ FRONTEND_API_SCOPES = [
74534
+ "jobs:run",
74535
+ "jobs:read",
74536
+ "users:read",
74537
+ "resources:read",
74538
+ "variables:read",
74539
+ "flow_conversations:read",
74540
+ "flow_conversations:write"
74541
+ ];
74445
74542
  APP_FOLDER_SUFFIXES = ["__raw_app", ".raw_app", "__app", ".app"];
74446
74543
  command14 = new Command().description("app related commands").option("--json", "Output as JSON (for piping to jq)").action(list6).command("list", "list all apps").option("--json", "Output as JSON (for piping to jq)").action(list6).command("get", "get an app's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get4).command("push", "push a local app. With no args, infers the app from the current directory and the remote path from its location relative to wmill.yaml.").arguments("[file_path:string] [remote_path:string]").action(push5).command("dev", dev_default).command("lint", lint_default2).command("bundle", bundle_command_default).command("new", new_default).command("generate-agents", generate_agents_default).command("generate-locks", 'DEPRECATED: re-generate app lockfiles. Use "wmill generate-metadata" instead.').arguments("[app_folder:string]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("--default-ts <runtime:string>", "Default TypeScript runtime (bun or deno)").action(async (opts, appFolder) => {
74447
74544
  warn(colors.yellow('This command is deprecated. Use "wmill generate-metadata" instead.'));
@@ -79765,6 +79862,7 @@ var init_skills_gen = __esm(() => {
79765
79862
  { name: "resources", description: "MUST use when managing resources." },
79766
79863
  { name: "write-workflow-as-code", description: "MUST use when writing or modifying Windmill Workflow-as-Code scripts using workflow, task, step, sleep, approvals, taskScript, taskFlow, task_script, or task_flow." },
79767
79864
  { name: "write-pipeline", description: "MUST use when creating or modifying a data pipeline, a set of scripts marked `pipeline` and wired together by `on` / `materialize` annotations." },
79865
+ { name: "datatables", description: "MUST use when changing a data table's schema, writing or running its migrations, or working with its roles and permissions." },
79768
79866
  { name: "cli-commands", description: "MUST use when using the CLI, including debugging job failures and inspecting run history via `wmill job`." },
79769
79867
  { name: "preview", description: "MUST use when opening the Windmill dev page / visual preview of a flow, script, or app. Triggers on words like preview, open, navigate to, visualize, see the flow/app/script, and after writing a flow/script/app for visual verification." }
79770
79868
  ];
@@ -80835,6 +80933,9 @@ async sleep(seconds: number): Promise<void>
80835
80933
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
80836
80934
  * the round that runs the body sees the same types every replay sees: a \`Date\`
80837
80935
  * comes back as a string, a \`Map\` as \`{}\`. {@link Jsonified} is that shape.
80936
+ *
80937
+ * Called from inside a task body, \`fn\` runs in place and nothing is
80938
+ * checkpointed: a task is a single job and is never replayed.
80838
80939
  */
80839
80940
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
80840
80941
 
@@ -81678,6 +81779,9 @@ async sleep(seconds: number): Promise<void>
81678
81779
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
81679
81780
  * the round that runs the body sees the same types every replay sees: a \`Date\`
81680
81781
  * comes back as a string, a \`Map\` as \`{}\`. {@link Jsonified} is that shape.
81782
+ *
81783
+ * Called from inside a task body, \`fn\` runs in place and nothing is
81784
+ * checkpointed: a task is a single job and is never replayed.
81681
81785
  */
81682
81786
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
81683
81787
 
@@ -82627,6 +82731,9 @@ async sleep(seconds: number): Promise<void>
82627
82731
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
82628
82732
  * the round that runs the body sees the same types every replay sees: a \`Date\`
82629
82733
  * comes back as a string, a \`Map\` as \`{}\`. {@link Jsonified} is that shape.
82734
+ *
82735
+ * Called from inside a task body, \`fn\` runs in place and nothing is
82736
+ * checkpointed: a task is a single job and is never replayed.
82630
82737
  */
82631
82738
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
82632
82739
 
@@ -84802,7 +84909,9 @@ def parse_sql_client_name(name: str) -> tuple[str, Optional[str]]
84802
84909
  #
84803
84910
  # - **v2 (inside @workflow)**: dispatches as a checkpoint step.
84804
84911
  # - **v1 (WM_JOB_ID set, no @workflow)**: dispatches via HTTP API.
84805
- # - **Standalone**: executes the function body directly.
84912
+ # - **Standalone, or called from inside another v2 task**: executes the
84913
+ # function body directly. A task runs as a single job, so the tasks it
84914
+ # calls run in that same job, without their own options.
84806
84915
  #
84807
84916
  # A task runs as its own job, so its result is always encoded as JSON and
84808
84917
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
@@ -84888,12 +84997,15 @@ def workflow(func)
84888
84997
  # \`\`fn\`\`'s result is encoded as JSON and decoded back before it is returned,
84889
84998
  # so the round that runs the body sees the same types every replay sees:
84890
84999
  # a \`\`datetime\`\` comes back as a string, a tuple as a list.
85000
+ #
85001
+ # Called from inside a task body, \`\`fn\`\` runs in place and nothing is
85002
+ # checkpointed: a task is a single job and is never replayed.
84891
85003
  async def step(name: str, fn)
84892
85004
 
84893
85005
  # Server-side sleep — suspend the workflow for the given duration without holding a worker.
84894
85006
  #
84895
85007
  # Inside a @workflow, the parent job suspends and auto-resumes after \`\`seconds\`\`.
84896
- # Outside a workflow, falls back to \`\`asyncio.sleep\`\`.
85008
+ # Outside a workflow, or inside a task body, falls back to \`\`asyncio.sleep\`\`.
84897
85009
  async def sleep(seconds: int)
84898
85010
 
84899
85011
  # Suspend the workflow and wait for an external approval.
@@ -85340,6 +85452,27 @@ Name the parameters by adding comments before the statement:
85340
85452
  SELECT * FROM users WHERE name = ? AND age > ?;
85341
85453
  \`\`\`
85342
85454
 
85455
+ ## Array parameters
85456
+
85457
+ Declare a list with a \`[]\` suffix on the element type (\`(varchar[])\`,
85458
+ \`(int[])\`), or \`(array)\` for an untyped one. Snowflake cannot bind an array
85459
+ directly, so Windmill binds the list as JSON text: wrap the placeholder with
85460
+ \`PARSE_JSON(?)\`, and cast to \`ARRAY\` where a function expects one.
85461
+
85462
+ \`\`\`sql
85463
+ -- ? groups (varchar[])
85464
+ SELECT o.* FROM orders o
85465
+ WHERE ARRAY_CONTAINS(o.owner_group::VARIANT, PARSE_JSON(?)::ARRAY);
85466
+ \`\`\`
85467
+
85468
+ Or join on the elements with \`FLATTEN\`:
85469
+
85470
+ \`\`\`sql
85471
+ -- ? groups (varchar[])
85472
+ SELECT o.* FROM orders o
85473
+ JOIN TABLE(FLATTEN(input => PARSE_JSON(?))) g ON g.value::STRING = o.owner_group;
85474
+ \`\`\`
85475
+
85343
85476
  ## Receiving an S3Object as a script parameter
85344
85477
 
85345
85478
  Declare the arg with type \`(s3object)\`. Windmill renders an S3 file picker for
@@ -86080,7 +86213,7 @@ You need three values to run the command:
86080
86213
 
86081
86214
  1. **summary** — a short description of the app
86082
86215
  2. **path** — the windmill path, e.g. \`f/folder/my_app\` or \`u/username/my_app\`
86083
- 3. **framework** — one of \`react19\` (recommended), \`react18\`, \`svelte5\`, \`vue\`
86216
+ 3. **framework** — one of \`react19\` (recommended), \`react18\`, \`svelte5\`
86084
86217
 
86085
86218
  **summary and path**: if the user's request did not supply them, ask. Do not guess values and do not invent paths.
86086
86219
 
@@ -86152,7 +86285,7 @@ my_app{{RAW_APP_SUFFIX}}/
86152
86285
  ├── DATATABLES.md # Database schemas (run 'wmill app generate-agents' to refresh)
86153
86286
  ├── raw_app.yaml # App configuration (summary, path, data settings)
86154
86287
  ├── index.tsx # Frontend entry point
86155
- ├── App.tsx # Main React/Svelte/Vue component
86288
+ ├── App.tsx # Main React/Svelte component
86156
86289
  ├── index.css # Styles
86157
86290
  ├── package.json # Frontend dependencies
86158
86291
  ├── wmill.ts # Auto-generated backend type definitions (DO NOT EDIT)
@@ -86251,7 +86384,7 @@ data:
86251
86384
  - \`<datatable>/<table>\` — Specific table in public schema
86252
86385
  - \`<datatable>/<schema>:<table>\` — Table in specific schema
86253
86386
 
86254
- **Roles:** when a datatable is under roles, its queries run as a role, which only reaches what it was granted. \`roles\` records the role the app uses each datatable through; the app's code must pass the same role: \`wmill.datatable('main', { role: 'analyst' })\` in TypeScript, \`wmill.datatable('main', role='analyst')\` in Python. A datatable without an entry is used as its default role.
86387
+ **Roles:** when a datatable is under roles, its queries run as a role, which only reaches what it was granted. \`roles\` records the role the app uses each datatable through; the app's code must pass the same role: \`wmill.datatable('main', { role: 'analyst' })\` in TypeScript, \`wmill.datatable('main', role='analyst')\` in Python. A datatable without an entry is used as its default role, if it has one, plus the roles of whoever is using the app unless that default is \`admin\`.
86255
86388
 
86256
86389
  ## SQL Migrations (sql_to_apply/)
86257
86390
 
@@ -86310,7 +86443,7 @@ For the rest, tell the user which command fits their intent and let them run it
86310
86443
 
86311
86444
  # Windmill Raw Apps
86312
86445
 
86313
- Raw apps let you build custom frontends with React, Svelte, or Vue that connect to Windmill backend runnables and datatables.
86446
+ Raw apps let you build custom frontends with React or Svelte that connect to Windmill backend runnables and datatables.
86314
86447
 
86315
86448
  ## App shape
86316
86449
 
@@ -86326,7 +86459,7 @@ A new app gets the setup Windmill's own new-app dialog gives one: a framework, t
86326
86459
 
86327
86460
  ### Framework
86328
86461
 
86329
- Use the framework the user named. When they named none, follow what there is to follow: the app being edited, or the apps the request points at. With nothing to follow, use **React 19**, the recommended default, **without asking**. React 18, Svelte 5 and Vue are for when they are asked for.
86462
+ Use the framework the user named. When they named none, follow what there is to follow: the app being edited, or the apps the request points at. With nothing to follow, use **React 19**, the recommended default, **without asking**. React 18 and Svelte 5 are for when they are asked for. These three are the only frameworks the raw app bundler builds. When the user asks to build or convert an app in another framework, write no code in it: say it is not available and offer these three instead.
86330
86463
 
86331
86464
  ### Data setup
86332
86465
 
@@ -86356,7 +86489,7 @@ Then build what was chosen: the data table and schema become the app's \`data.da
86356
86489
 
86357
86490
  ### Entrypoint
86358
86491
 
86359
- The entrypoint is \`index.tsx\` for React and \`index.ts\` for Svelte and Vue. It is both the bundling entrypoint (the bundler is esbuild) and the **mount** entrypoint: the preview executes the bundle against an empty \`<div id="root">\` and auto-renders nothing, so the entrypoint must mount a top-level \`App\` itself. Keep the UI in \`App.tsx\` / \`App.svelte\` / \`App.vue\` and keep the entrypoint as the mount shim.
86492
+ The entrypoint is \`index.tsx\` for React and \`index.ts\` for Svelte. It is both the bundling entrypoint (the bundler is esbuild) and the **mount** entrypoint: the preview executes the bundle against an empty \`<div id="root">\` and auto-renders nothing, so the entrypoint must mount a top-level \`App\` itself. Keep the UI in \`App.tsx\` / \`App.svelte\` and keep the entrypoint as the mount shim.
86360
86493
 
86361
86494
  React (\`index.tsx\`):
86362
86495
 
@@ -86368,7 +86501,7 @@ import App from './App'
86368
86501
  createRoot(document.getElementById('root')!).render(<App />)
86369
86502
  \`\`\`
86370
86503
 
86371
- Svelte (\`index.ts\`): \`mount(App, { target: document.getElementById('root')! })\`. Vue (\`index.ts\`): \`createApp(App).mount('#root')\`.
86504
+ Svelte (\`index.ts\`): \`mount(App, { target: document.getElementById('root')! })\`.
86372
86505
 
86373
86506
  **Never replace the entrypoint with a bare component** (\`export default function App() { ... }\` and no mount call). A component that is defined but never mounted renders a blank screen with **no error thrown** — it never executes, so nothing reaches the console or the error overlay. If an app renders blank, check that the entrypoint still mounts \`App\` into \`#root\`.
86374
86507
 
@@ -86441,16 +86574,16 @@ Apply it to customer data, internal notes and anything else a viewer of the demo
86441
86574
 
86442
86575
  ### Chat UIs over a flow in chat mode
86443
86576
 
86444
- 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.
86577
+ 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-labs/chat-sdk\` to \`package.json\` and use it directly, it detects the app's Windmill and credential.
86445
86578
 
86446
86579
  \`\`\`tsx
86447
- import { useWindmillChat } from 'windmill-chat/react'
86580
+ import { useWindmillChat } from '@windmill-labs/chat-sdk/react'
86448
86581
 
86449
86582
  const chat = useWindmillChat({ flowPath: 'f/support/assistant' })
86450
86583
  // chat.messages ({ role, content, pending, success, tool? }), chat.status, chat.sendMessage(text), chat.stop()
86451
86584
  \`\`\`
86452
86585
 
86453
- \`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.
86586
+ \`@windmill-labs/chat-sdk/ai-sdk\` gives a \`ChatTransport\` for the Vercel AI SDK's \`useChat\`, \`@windmill-labs/chat-sdk/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.
86454
86587
 
86455
86588
  ## Backend runnables
86456
86589
 
@@ -86534,6 +86667,18 @@ A draft app is reachable by nobody; deploying is what exposes it, and its backen
86534
86667
  Either one lets those people run the app's backend runnables, so never open an app up unless the user asks.
86535
86668
  \`public: true\` in \`raw_app.yaml\` deploys the app for anonymous users, and \`guests: true\` for guests. Remove the line and the next push closes the app again.
86536
86669
 
86670
+ ## Sandbox isolation and frontend API access
86671
+
86672
+ By default a deployed app's frontend runs with the viewer's own Windmill session. A sandboxed app is isolated from it: the frontend reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. The scopes are \`jobs:run\`, \`jobs:read\`, \`users:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls.
86673
+ In \`raw_app.yaml\`:
86674
+
86675
+ \`\`\`yaml
86676
+ sandbox: true
86677
+ frontend_api: [jobs:run, users:read]
86678
+ \`\`\`
86679
+
86680
+ A file with a \`sandbox\` key states both settings: \`sandbox: false\` turns isolation off, and a missing \`frontend_api\` means no scopes. A file without the key leaves the deployed app's isolation and scopes as they are, so removing \`sandbox: true\` does not unsandbox it. \`frontend_api\` needs \`sandbox: true\`; the push fails otherwise.
86681
+
86537
86682
  ## Data Tables
86538
86683
 
86539
86684
  Data tables are PostgreSQL databases managed by Windmill. Backend runnables query them via the \`wmill\` client; the frontend never queries them directly. **When the app needs to store or persist data** (user data, settings, application state, records, logs), use a data table.
@@ -86545,6 +86690,7 @@ Data tables are PostgreSQL databases managed by Windmill. Backend runnables quer
86545
86690
  3. **No DDL inside runnables**: runnables only read and write rows (SELECT, INSERT, UPDATE, DELETE) on existing tables. Never CREATE, ALTER or DROP a table from a runnable.
86546
86691
  4. **Qualify table names**: an unqualified name means the \`public\` schema, so write every other table as \`schema.table\`, in table creation and queries alike. The app's \`data\` config sets the default datatable and schema its tables go in; use them consistently across runnables.
86547
86692
  5. **Pass the role**: when the app's \`data.roles\` gives a data table a role, every \`wmill.datatable\` call on it passes that role (\`wmill.datatable('main', { role: 'analyst' })\` in TypeScript, \`wmill.datatable('main', role='analyst')\` in Python). The role only reaches what it was granted, so a query outside it fails with \`permission denied\`.
86693
+ 6. **Per-viewer rows**: a data table with no entry in \`data.roles\` is called with no role. Unless its default role is \`admin\`, the connection then holds the default role, if it has one, plus every role the person using the app is a tenant of, and is refused when that is none. Row-level security policies written as \`pg_has_role(current_user, '<role>', 'member')\` return that viewer's rows with nothing added to the runnable. A role pins the connection to that one role for every viewer, so where rows should differ per viewer give the data table no \`data.roles\` entry.
86548
86694
 
86549
86695
  \`wmill datatable list\` lists the workspace's data tables. Create or change tables with a migration in \`sql_to_apply/\` (see "SQL Migrations" above), then add them to \`data.tables\` in \`raw_app.yaml\`.
86550
86696
 
@@ -86598,7 +86744,7 @@ def main(user_id: str):
86598
86744
  7. **Mark sensitive UI with \`data-wm-no-record\`** — it is what keeps that data out of a recorded demo; passwords are handled for you.
86599
86745
  8. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
86600
86746
  9. **Deploy what a path runnable points at** — a path runnable aimed at a draft fails at runtime; tell the user what needs deploying.
86601
- 10. **Use \`windmill-chat\` for a chat over a chat-mode flow** — never a runnable that runs the flow and polls its stream.
86747
+ 10. **Use \`@windmill-labs/chat-sdk\` for a chat over a chat-mode flow** — never a runnable that runs the flow and polls its stream.
86602
86748
  `,
86603
86749
  triggers: `---
86604
86750
  name: triggers
@@ -87165,6 +87311,8 @@ async def enrich(customer_id: str):
87165
87311
 
87166
87312
  In TypeScript, prefer assigning each task to a named top-level const. In Python, prefer top-level async functions decorated with \`@task()\` or \`@task\`.
87167
87313
 
87314
+ Only the workflow body dispatches steps. A task runs as a single job, so a task or \`step()\` called from inside a task body runs in place in that job, as a plain function call: no child job, no checkpoint, and its task options (retry, timeout, tag) do not apply. \`sleep()\` there waits in the job, and \`taskScript()\` / \`taskFlow()\` / \`waitForApproval()\` (\`task_script()\` / \`task_flow()\` / \`wait_for_approval()\`) throw. To get separate jobs, call the tasks one after another from the workflow body and pass results between them.
87315
+
87168
87316
  For existing scripts:
87169
87317
 
87170
87318
  \`\`\`typescript
@@ -87330,8 +87478,9 @@ export async function getResumeUrls(approver?: string, flowLevel?: boolean): Pro
87330
87478
  * const call_api = task(fetchOrders, { retry: { attempts: 3, delay: 30, multiplier: 2 } });
87331
87479
  *
87332
87480
  * Inside a \`workflow()\`, calling a task dispatches it as a step.
87333
- * Outside a workflow, the function body executes directly and
87334
- * {@link TaskOptions} — retry included — does not apply.
87481
+ * Outside a workflow, or called from inside another task, the function body
87482
+ * executes directly and {@link TaskOptions} — retry included — does not apply:
87483
+ * a task runs as a single job, so the tasks it calls run in that same job.
87335
87484
  *
87336
87485
  * A task runs as its own job, so its result is always encoded as JSON and
87337
87486
  * decoded back before the caller sees it: a \`Date\` comes back as a string, a
@@ -87375,6 +87524,9 @@ export function workflow<T>(fn: (...args: any[]) => Promise<T>)
87375
87524
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
87376
87525
  * the round that runs the body sees the same types every replay sees: a \`Date\`
87377
87526
  * comes back as a string, a \`Map\` as \`{}\`. {@link Jsonified} is that shape.
87527
+ *
87528
+ * Called from inside a task body, \`fn\` runs in place and nothing is
87529
+ * checkpointed: a task is a single job and is never replayed.
87378
87530
  */
87379
87531
  export async function step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
87380
87532
 
@@ -87473,7 +87625,9 @@ def get_resume_urls(approver: str = None, flow_level: bool = None) -> dict
87473
87625
  #
87474
87626
  # - **v2 (inside @workflow)**: dispatches as a checkpoint step.
87475
87627
  # - **v1 (WM_JOB_ID set, no @workflow)**: dispatches via HTTP API.
87476
- # - **Standalone**: executes the function body directly.
87628
+ # - **Standalone, or called from inside another v2 task**: executes the
87629
+ # function body directly. A task runs as a single job, so the tasks it
87630
+ # calls run in that same job, without their own options.
87477
87631
  #
87478
87632
  # A task runs as its own job, so its result is always encoded as JSON and
87479
87633
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
@@ -87559,12 +87713,15 @@ def workflow(func)
87559
87713
  # \`\`fn\`\`'s result is encoded as JSON and decoded back before it is returned,
87560
87714
  # so the round that runs the body sees the same types every replay sees:
87561
87715
  # a \`\`datetime\`\` comes back as a string, a tuple as a list.
87716
+ #
87717
+ # Called from inside a task body, \`\`fn\`\` runs in place and nothing is
87718
+ # checkpointed: a task is a single job and is never replayed.
87562
87719
  async def step(name: str, fn)
87563
87720
 
87564
87721
  # Server-side sleep — suspend the workflow for the given duration without holding a worker.
87565
87722
  #
87566
87723
  # Inside a @workflow, the parent job suspends and auto-resumes after \`\`seconds\`\`.
87567
- # Outside a workflow, falls back to \`\`asyncio.sleep\`\`.
87724
+ # Outside a workflow, or inside a task body, falls back to \`\`asyncio.sleep\`\`.
87568
87725
  async def sleep(seconds: int)
87569
87726
 
87570
87727
  # Suspend the workflow and wait for an external approval.
@@ -87793,6 +87950,53 @@ Node \`f/sales/orders_daily\` (runs when \`orders\` is produced, writes a rollup
87793
87950
  SELECT date_trunc('day', ts) AS day, count(*) AS n
87794
87951
  FROM ducklake.main.orders GROUP BY 1
87795
87952
  \`\`\`
87953
+ `,
87954
+ datatables: `---
87955
+ name: datatables
87956
+ description: MUST use when changing a data table's schema, writing or running its migrations, or working with its roles and permissions.
87957
+ ---
87958
+
87959
+ # Data tables: schema changes, migrations and permissions
87960
+
87961
+ A data table is a PostgreSQL database managed by Windmill and shared by the whole workspace: scripts, flows and apps reach it by name, \`main\` being the default. It is configured in the workspace settings (Data Tables), never created by SQL.
87962
+
87963
+ ## Changing the schema
87964
+
87965
+ A data table with migrations enabled keeps its schema as an ordered list of versioned SQL migrations, each an \`up\` and an optional \`down\`. That list is what git sync and a workspace merge carry, and what rebuilds the schema in another workspace. So first find out whether migrations are enabled on the data table:
87966
+
87967
+ - **Enabled**: make every schema change (CREATE, ALTER, DROP, anything but row data) as a new migration. A change made with plain SQL exists in that one database only, and the history no longer describes it.
87968
+ - **Not enabled**: schema changes are plain SQL. Enabling migrations is a workspace admin's decision, made in the Data Tables settings, not a step to take on the way to something else.
87969
+
87970
+ Writing a migration:
87971
+
87972
+ - Wrap the statements in \`BEGIN; ... END;\` so it applies atomically. Leave the frame out only for a statement that cannot run in a transaction, such as \`CREATE INDEX CONCURRENTLY\`: such a migration can fail half applied.
87973
+ - Give it a \`down\` that undoes the \`up\` whenever the change is reversible. Without one it cannot be rolled back.
87974
+ - Migrations apply oldest first. One that is applied is not edited: correct it with a new migration.
87975
+ - Row data is not schema. Insert, update and delete rows with plain SQL, migrations or not.
87976
+
87977
+ \`wmill datatable migrate new <name>\` scaffolds \`migrations/datatable/<datatable>/<timestamp>_<name>.up.sql\` and \`.down.sql\`, \`wmill datatable migrate up\` pushes the local files and applies what is pending, \`wmill datatable migrate down\` rolls back the most recent one and \`wmill datatable migrate status\` lists them. All take \`-d <datatable>\` and default to \`main\`.
87978
+
87979
+ ## A migration is not a draft
87980
+
87981
+ A migration is saved to the workspace and changes the database as soon as it is applied, for everything that reads those tables. To try a schema out without touching tables already in use:
87982
+
87983
+ - put the new tables in a schema of their own, created by the same migration (\`CREATE SCHEMA IF NOT EXISTS\`), and point what you are building at it. A raw app names its schema in its \`data\` config, which is why a new app gets a new schema by default;
87984
+ - or work in a workspace fork whose data table was cloned when the fork was created ("Clone schema only" or "Clone schema and data"): migrations applied there change that copy alone, and reach the parent workspace when the fork is merged. A fork that kept the original data table points at the parent's database, so a migration applied in it changes the parent's tables at once.
87985
+
87986
+ Altering or dropping a table other scripts or apps use is neither of those: say what depends on it before doing it.
87987
+
87988
+ ## Roles and permissions
87989
+
87990
+ Data table roles are a self-hosted Enterprise Edition feature, for data tables on managed Postgres (the instance database or the external managed instance). Without them, and always on a data table backed by a Postgres resource, everyone who can use the data table reaches all of it: there is no per-user, per-schema or per-row access to promise.
87991
+
87992
+ A data table under roles is reached as a Postgres role, and Postgres enforces what that role was granted:
87993
+
87994
+ - roles are assigned, per data table, to users, groups or folders. \`admin\` is the connection the data table had before roles: it owns the existing objects and ignores grants;
87995
+ - a connection either names a role (\`wmill.datatable('main', { role: 'analyst' })\`, \`role='analyst'\` in Python, \`datatable://main?role=analyst\`) and holds that role alone, or names none and is resolved from the data table's default role;
87996
+ - \`permission denied\` means the role in use lacks a grant. Say which role and which object: the grant is a data table admin's to give, in the roles drawer of the Database Manager. Do not switch to \`admin\` to get past it;
87997
+ - a migration runs as the role its SQL declares on its first line, \`-- role <name>\`, the same one in its \`down\`. One that declares none runs as \`admin\`, which only those who may use \`admin\` can do.
87998
+
87999
+ Read the Permissions section of https://www.windmill.dev/docs/core_concepts/persistent_storage/data_tables before designing who reaches what: it covers tenants, grants, the default role and the roles a connection that names none ends up holding, rows that differ per viewer through row-level security, and how forks and raw apps behave under roles.
87796
88000
  `,
87797
88001
  "cli-commands": `---
87798
88002
  name: cli-commands
@@ -87831,7 +88035,7 @@ app related commands
87831
88035
  - \`app dev [app_folder:string]\` - Start a development server for building apps with live reload and hot module replacement
87832
88036
  - \`--port <port:number>\` - Port to run the dev server on (will find next available port if occupied)
87833
88037
  - \`--host <host:string>\` - Host to bind the dev server to
87834
- - \`--entry <entry:string>\` - Entry point file (default: index.ts for Svelte/Vue, index.tsx otherwise)
88038
+ - \`--entry <entry:string>\` - Entry point file (default: index.ts for Svelte, index.tsx otherwise)
87835
88039
  - \`--no-open\` - Don't automatically open the browser
87836
88040
  - \`--recording\` - Frame the app in a shell with a Record button, to capture a replayable session recording of the app under development
87837
88041
  - \`app lint [app_folder:string]\` - Lint a raw app folder to validate structure and buildability
@@ -87842,7 +88046,7 @@ app related commands
87842
88046
  - \`app new\` - create a new raw app from a template
87843
88047
  - \`--summary <summary:string>\` - App summary (short description). Skips the prompt when provided. Triggers non-interactive mode.
87844
88048
  - \`--path <path:string>\` - App path (e.g., f/folder/my_app or u/username/my_app). Skips the prompt when provided. Triggers non-interactive mode.
87845
- - \`--framework <framework:string>\` - Framework template: react19 | react18 | svelte5 | vue. Skips the prompt when provided. Triggers non-interactive mode.
88049
+ - \`--framework <framework:string>\` - Framework template: react19 | react18 | svelte5. Skips the prompt when provided. Triggers non-interactive mode.
87846
88050
  - \`--datatable <datatable:string>\` - Datatable to wire up. Without this flag in non-interactive mode, no datatable is configured.
87847
88051
  - \`--schema <schema:string>\` - Schema to use with --datatable. If it doesn't exist yet, a sql_to_apply/ migration (CREATE SCHEMA IF NOT EXISTS) is written for it.
87848
88052
  - \`--overwrite\` - Overwrite the target directory if it already exists, without prompting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.830.0",
3
+ "version": "1.832.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",
@@ -17,14 +17,14 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "esbuild": "0.28.2",
20
- "windmill-parser-wasm-asset": "1.753.0",
20
+ "windmill-parser-wasm-asset": "1.830.0",
21
21
  "windmill-parser-wasm-csharp": "1.510.1",
22
22
  "windmill-parser-wasm-go": "1.761.0",
23
23
  "windmill-parser-wasm-java": "1.510.1",
24
24
  "windmill-parser-wasm-nu": "1.510.1",
25
25
  "windmill-parser-wasm-php": "1.647.1",
26
- "windmill-parser-wasm-py": "1.782.0",
27
- "windmill-parser-wasm-py-imports": "1.693.1",
26
+ "windmill-parser-wasm-py": "1.830.0",
27
+ "windmill-parser-wasm-py-imports": "1.830.0",
28
28
  "windmill-parser-wasm-r": "1.668.1",
29
29
  "windmill-parser-wasm-regex": "1.764.0",
30
30
  "windmill-parser-wasm-ruby": "1.526.1",