windmill-cli 1.829.0 → 1.831.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 +290 -90
  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.829.0",
16769
+ VERSION: "1.831.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.829.0";
20054
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.831.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"],
@@ -21122,9 +21124,6 @@ async function readConfigFile(opts) {
21122
21124
  delete conf?.gitBranches;
21123
21125
  delete conf?.environments;
21124
21126
  delete conf?.git_branches;
21125
- if (conf?.defaultTs == undefined) {
21126
- warn("No defaultTs defined in your wmill.yaml. Using 'bun' as default.");
21127
- }
21128
21127
  setNonDottedPaths(conf?.nonDottedPaths ?? false);
21129
21128
  const syncBehaviorVersion = parseSyncBehavior(conf?.syncBehavior);
21130
21129
  if (syncBehaviorVersion > SUPPORTED_SYNC_BEHAVIOR_VERSION) {
@@ -21391,7 +21390,6 @@ var init_conf = __esm(async () => {
21391
21390
  import_yaml3 = __toESM(require_dist(), 1);
21392
21391
  GLOBAL_CONFIG_OPT = { noCdToRoot: false };
21393
21392
  DEFAULT_SYNC_OPTIONS = {
21394
- defaultTs: "bun",
21395
21393
  includes: ["f/**"],
21396
21394
  excludes: [],
21397
21395
  codebases: [],
@@ -34295,7 +34293,7 @@ function conditionsFor(svelte) {
34295
34293
  function detectFrameworks(appDir) {
34296
34294
  const packageJsonPath = path6.join(appDir, "package.json");
34297
34295
  if (!fs9.existsSync(packageJsonPath)) {
34298
- return { svelte: false, vue: false };
34296
+ return { svelte: false };
34299
34297
  }
34300
34298
  try {
34301
34299
  const packageJson = JSON.parse(readTextFileSync(packageJsonPath));
@@ -34304,11 +34302,10 @@ function detectFrameworks(appDir) {
34304
34302
  ...packageJson.devDependencies
34305
34303
  };
34306
34304
  return {
34307
- svelte: "svelte" in allDeps,
34308
- vue: "vue" in allDeps
34305
+ svelte: "svelte" in allDeps
34309
34306
  };
34310
34307
  } catch {
34311
- return { svelte: false, vue: false };
34308
+ return { svelte: false };
34312
34309
  }
34313
34310
  }
34314
34311
  function esmConditionTarget(subpath) {
@@ -34417,10 +34414,6 @@ async function createFrameworkPlugins(appDir) {
34417
34414
  info(colors.blue("\uD83D\uDD27 Svelte detected, adding svelte plugin..."));
34418
34415
  plugins.push(createSveltePlugin(appDir));
34419
34416
  }
34420
- if (frameworks.vue) {
34421
- info(colors.blue("\uD83D\uDD27 Vue detected, adding vue plugin..."));
34422
- throw new Error("Vue plugin not supported yet");
34423
- }
34424
34417
  return plugins;
34425
34418
  }
34426
34419
  async function ensureNodeModules(appDir) {
@@ -34447,7 +34440,7 @@ async function createBundle(options = {}) {
34447
34440
  const esbuild = await getEsbuild();
34448
34441
  const appDir = options.entryPoint ? path6.dirname(options.entryPoint) : process14.cwd();
34449
34442
  const frameworks = detectFrameworks(appDir);
34450
- const defaultEntry = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
34443
+ const defaultEntry = frameworks.svelte ? "index.ts" : "index.tsx";
34451
34444
  const entryPoint = options.entryPoint ?? defaultEntry;
34452
34445
  const outDir = options.outDir ?? "dist";
34453
34446
  const sourcemap = options.sourcemap ?? false;
@@ -57061,7 +57054,7 @@ var init_openflow = __esm(() => {
57061
57054
  openflow_default = {
57062
57055
  openapi: "3.0.3",
57063
57056
  info: {
57064
- version: "1.829.0",
57057
+ version: "1.831.0",
57065
57058
  title: "OpenFlow Spec",
57066
57059
  contact: {
57067
57060
  name: "Ruben Fiszel",
@@ -61254,8 +61247,8 @@ async function buildPermissionedAsContext(workspace, syncBehavior) {
61254
61247
  return;
61255
61248
  }
61256
61249
  const user = await whoami({ workspace });
61257
- const userIsAdminOrDeployer = user.is_admin || (user.groups ?? []).includes("wm_deployers");
61258
- debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`);
61250
+ const userIsAdminOrDeployer = user.is_admin || user.is_super_admin || (user.groups ?? []).includes("wm_deployers");
61251
+ debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, is_super_admin=${user.is_super_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`);
61259
61252
  return {
61260
61253
  userCache: new Map,
61261
61254
  userIsAdminOrDeployer,
@@ -66554,6 +66547,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66554
66547
  error(`Failed to parse app.yaml at path: ${p}`);
66555
66548
  throw error2;
66556
66549
  }
66550
+ stripEditorState(app);
66557
66551
  let inlineScripts;
66558
66552
  try {
66559
66553
  inlineScripts = extractInlineScriptsForApps(undefined, app?.["value"], newPathAssigner(defaultTs, {
@@ -66574,6 +66568,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66574
66568
  };
66575
66569
  }
66576
66570
  markAccessFromPolicy(app);
66571
+ markIsolationFromPolicy(app, false);
66577
66572
  app.policy = undefined;
66578
66573
  yield {
66579
66574
  isDirectory: false,
@@ -66611,6 +66606,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
66611
66606
  throw error2;
66612
66607
  }
66613
66608
  markAccessFromPolicy(rawApp);
66609
+ markIsolationFromPolicy(rawApp, true);
66614
66610
  rawApp.policy = undefined;
66615
66611
  delete rawApp?.["custom_path"];
66616
66612
  let inlineScripts;
@@ -67425,12 +67421,17 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
67425
67421
  }
67426
67422
  return o;
67427
67423
  } else {
67424
+ let o;
67428
67425
  try {
67429
- return yamlParseContent(k, v);
67426
+ o = yamlParseContent(k, v);
67430
67427
  } catch (error2) {
67431
67428
  error(`Failed to parse YAML content at path: ${k}`);
67432
67429
  throw error2;
67433
67430
  }
67431
+ if (path14.basename(k) == "app.yaml") {
67432
+ stripEditorState(o);
67433
+ }
67434
+ return o;
67434
67435
  }
67435
67436
  }
67436
67437
  const codebaseChanges = {};
@@ -70885,6 +70886,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70885
70886
  }
70886
70887
  const appFilePath = localPath + "raw_app.yaml";
70887
70888
  const localApp = await yamlParseFile(appFilePath);
70889
+ const isolation = statedIsolation(localApp, true);
70888
70890
  const backendPath = path16.join(localPath, APP_BACKEND_FOLDER);
70889
70891
  const runnablesFromBackend = await loadRunnablesFromBackend(backendPath, defaultTs);
70890
70892
  let runnables;
@@ -70901,12 +70903,12 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70901
70903
  repopulateFields(runnables);
70902
70904
  const appForPolicy = { ...localApp, runnables };
70903
70905
  const preserveFields = preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsContext);
70904
- 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);
70905
70907
  const files = await collectAppFiles(localPath);
70906
70908
  async function createBundleRaw() {
70907
70909
  info(colors.yellow.bold(`Creating raw app ${remotePath} bundle...`));
70908
70910
  const frameworks = detectFrameworks(localPath);
70909
- const entryFile = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
70911
+ const entryFile = frameworks.svelte ? "index.ts" : "index.tsx";
70910
70912
  const entryPoint = localPath + entryFile;
70911
70913
  const sharedUiDir = path16.join(process.cwd(), "ui");
70912
70914
  return await createBundle({
@@ -70920,9 +70922,14 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70920
70922
  if (localApp.data) {
70921
70923
  value.data = localApp.data;
70922
70924
  }
70923
- const { extra_perms: localPerms, ...localAppNoPerms } = localApp;
70925
+ const {
70926
+ extra_perms: localPerms,
70927
+ sandbox: _sandbox,
70928
+ frontend_api: _frontendApi,
70929
+ ...localAppNoPerms
70930
+ } = localApp;
70924
70931
  if (app) {
70925
- const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app);
70932
+ const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && isolationUpToDate(isolation, deployedPolicy, true);
70926
70933
  const filesUpToDate = deepEqual(files, app.value?.files);
70927
70934
  if (metadataUpToDate && filesUpToDate) {
70928
70935
  info(colors.green(`App ${remotePath} is up to date`));
@@ -70969,11 +70976,11 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
70969
70976
  }
70970
70977
  await applyExtraPermsDiff(workspace, "raw_app", remotePath, localPerms, app?.extra_perms);
70971
70978
  }
70972
- async function generatingPolicy(app, path, executionMode, base) {
70979
+ async function generatingPolicy(app, path, executionMode, base, isolation) {
70973
70980
  info(colors.gray(`Generating fresh policy for app ${path}...`));
70974
70981
  try {
70975
70982
  app.policy = await Q(app.runnables, base);
70976
- finalizeDerivedPolicy(app.policy, executionMode);
70983
+ finalizeDerivedPolicy(app.policy, executionMode, isolation, true);
70977
70984
  } catch (e) {
70978
70985
  error(colors.red(`Error generating policy for app ${path}: ${e}`));
70979
70986
  throw e;
@@ -72054,7 +72061,7 @@ async function dev(opts, appFolder) {
72054
72061
  });
72055
72062
  const shouldOpen = opts.open ?? true;
72056
72063
  const frameworks = detectFrameworks(process17.cwd());
72057
- const defaultEntry = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
72064
+ const defaultEntry = frameworks.svelte ? "index.ts" : "index.tsx";
72058
72065
  const entryPoint = opts.entry ?? defaultEntry;
72059
72066
  if (!fs13.existsSync(entryPoint)) {
72060
72067
  error(colors.red(`Entry point "${entryPoint}" not found. Please specify a valid entry point with --entry.`));
@@ -73318,7 +73325,7 @@ var init_dev = __esm(async () => {
73318
73325
  ]);
73319
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", {
73320
73327
  default: DEFAULT_HOST
73321
- }).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);
73322
73329
  dev_default = command10;
73323
73330
  });
73324
73331
 
@@ -73334,8 +73341,31 @@ function validateRawAppYaml(appData) {
73334
73341
  } else if (typeof appData.summary !== "string") {
73335
73342
  errors.push("Field 'summary' must be a string");
73336
73343
  }
73344
+ try {
73345
+ statedIsolation(appData, true);
73346
+ } catch (error) {
73347
+ errors.push(error.message);
73348
+ }
73337
73349
  return { errors, warnings };
73338
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
+ }
73339
73369
  async function validateRunnables(appDir, appData) {
73340
73370
  const errors = [];
73341
73371
  const warnings = [];
@@ -73348,6 +73378,7 @@ async function validateRunnables(appDir, appData) {
73348
73378
  ` + ` - Runnable YAML files in the 'backend/' folder (e.g., backend/myRunnable.yaml)
73349
73379
  ` + " - Or a 'runnables' field in raw_app.yaml (legacy format)");
73350
73380
  } else if (hasBackendRunnables) {
73381
+ warnings.push(...await viewerIdentityInputWarnings(runnablesFromBackend));
73351
73382
  info(colors.gray(` Found ${Object.keys(runnablesFromBackend).length} runnable(s) in backend folder`));
73352
73383
  } else if (hasYamlRunnables) {
73353
73384
  info(colors.gray(` Found ${Object.keys(appData.runnables).length} runnable(s) in raw_app.yaml (legacy format)`));
@@ -73361,7 +73392,7 @@ async function validateBuild(appDir) {
73361
73392
  try {
73362
73393
  info(colors.blue("\uD83D\uDD28 Testing build..."));
73363
73394
  const frameworks = detectFrameworks(appDir);
73364
- const entryFile = frameworks.svelte || frameworks.vue ? "index.ts" : "index.tsx";
73395
+ const entryFile = frameworks.svelte ? "index.ts" : "index.tsx";
73365
73396
  const entryPoint = path20.join(appDir, entryFile);
73366
73397
  await createBundle({
73367
73398
  entryPoint,
@@ -73448,7 +73479,7 @@ async function lint2(opts, appFolder) {
73448
73479
  ✅ All checks passed
73449
73480
  `));
73450
73481
  }
73451
- var command11, lint_default2;
73482
+ var SQL_LANGUAGES, VIEWER_IDENTITY_ARGS, command11, lint_default2;
73452
73483
  var init_lint2 = __esm(async () => {
73453
73484
  init_mod3();
73454
73485
  init_colors2();
@@ -73458,8 +73489,20 @@ var init_lint2 = __esm(async () => {
73458
73489
  init_bundle(),
73459
73490
  init_app_metadata(),
73460
73491
  init_raw_apps(),
73492
+ init_metadata(),
73493
+ init_app(),
73461
73494
  init_resource_folders()
73462
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"];
73463
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);
73464
73507
  lint_default2 = command11;
73465
73508
  });
@@ -73470,7 +73513,7 @@ import * as path21 from "node:path";
73470
73513
  import process19 from "node:process";
73471
73514
  function entryPointFor(appDir) {
73472
73515
  const frameworks = detectFrameworks(appDir);
73473
- 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"];
73474
73517
  const entry = candidates.find((c) => fs15.existsSync(path21.join(appDir, c)));
73475
73518
  if (!entry) {
73476
73519
  throw new Error(`No entry point in ${appDir}: expected one of ${candidates.join(", ")}`);
@@ -73628,7 +73671,7 @@ async function newApp(opts) {
73628
73671
  error(colors.red(`Invalid path: ${validation.error}`));
73629
73672
  }
73630
73673
  }
73631
- const VALID_FRAMEWORKS = ["react19", "react18", "svelte5", "vue"];
73674
+ const VALID_FRAMEWORKS = ["react19", "react18", "svelte5"];
73632
73675
  let framework;
73633
73676
  if (opts.framework !== undefined) {
73634
73677
  if (!VALID_FRAMEWORKS.includes(opts.framework)) {
@@ -73642,8 +73685,7 @@ async function newApp(opts) {
73642
73685
  options: [
73643
73686
  { name: "React 19 (Recommended)", value: "react19" },
73644
73687
  { name: "React 18", value: "react18" },
73645
- { name: "Svelte 5", value: "svelte5" },
73646
- { name: "Vue 3", value: "vue" }
73688
+ { name: "Svelte 5", value: "svelte5" }
73647
73689
  ]
73648
73690
  });
73649
73691
  }
@@ -74010,18 +74052,7 @@ import './index.css'
74010
74052
  const app = mount(App, { target: document.getElementById("root")! });
74011
74053
 
74012
74054
  export default app;
74013
- `, appVue = `<template>
74014
- <h1>Hello {{ msg }}</h1>
74015
- </template>
74016
-
74017
- <script setup>
74018
- import { ref } from 'vue';
74019
- const msg = ref('world');
74020
- </script>`, indexVue = `import { createApp } from 'vue'
74021
- import App from './App.vue'
74022
- import "./index.css";
74023
-
74024
- createApp(App).mount('#root')`, indexCss = `body {
74055
+ `, indexCss = `body {
74025
74056
  margin: 0;
74026
74057
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
74027
74058
  background-color: #f5f5f5;
@@ -74101,26 +74132,11 @@ var init_new = __esm(async () => {
74101
74132
  "svelte": "^5.55.5",
74102
74133
  "windmill-client": "^1"
74103
74134
  }
74104
- }`
74105
- }
74106
- },
74107
- vue: {
74108
- name: "Vue 3",
74109
- files: {
74110
- "/index.ts": indexVue,
74111
- "/App.vue": appVue,
74112
- "/index.css": indexCss,
74113
- "/package.json": `{
74114
- "dependencies": {
74115
- "core-js": "3.26.1",
74116
- "vue": "3.5.13",
74117
- "windmill-client": "^1"
74118
- }
74119
74135
  }`
74120
74136
  }
74121
74137
  }
74122
74138
  };
74123
- 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);
74124
74140
  new_default = command13;
74125
74141
  });
74126
74142
 
@@ -74191,6 +74207,11 @@ function replaceInlineScripts2(rec, localPath, addType) {
74191
74207
  }
74192
74208
  return [];
74193
74209
  }
74210
+ function stripEditorState(app) {
74211
+ if (app?.value && typeof app.value == "object") {
74212
+ delete app.value.parent_version;
74213
+ }
74214
+ }
74194
74215
  function isExecutionModeAnonymous(app) {
74195
74216
  return app?.["policy"]?.["execution_mode"] == "anonymous";
74196
74217
  }
@@ -74221,6 +74242,56 @@ function executionModeForPush(localApp, deployedPolicy) {
74221
74242
  }
74222
74243
  return deployedPolicy?.execution_mode === "viewer" ? "viewer" : "publisher";
74223
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
+ }
74224
74295
  async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext) {
74225
74296
  if (alreadySynced2.includes(localPath)) {
74226
74297
  return;
@@ -74244,12 +74315,19 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
74244
74315
  }
74245
74316
  const path = localPath + "app.yaml";
74246
74317
  const localApp = await yamlParseFile(path);
74318
+ stripEditorState(localApp);
74319
+ const isolation = statedIsolation(localApp, false);
74247
74320
  replaceInlineScripts2(localApp.value, localPath, true);
74248
74321
  const preserveFields = preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsContext);
74249
- await generatingPolicy2(localApp, remotePath, executionModeForPush(localApp, deployedPolicy), basePolicy(localApp, deployedPolicy, !!preserveFields.preserve_on_behalf_of));
74250
- 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;
74251
74329
  if (app) {
74252
- if (isSuperset(localAppBody, app)) {
74330
+ if (isSuperset(localAppBody, app) && isolationUpToDate(isolation, deployedPolicy, false)) {
74253
74331
  info(colors.green(`App ${remotePath} is up to date`));
74254
74332
  } else {
74255
74333
  info(colors.bold.yellow(`Updating app ${remotePath}...`));
@@ -74279,11 +74357,11 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
74279
74357
  }
74280
74358
  await applyExtraPermsDiff(workspace, "app", remotePath, localPerms, app?.extra_perms);
74281
74359
  }
74282
- async function generatingPolicy2(app, path, executionMode, base) {
74360
+ async function generatingPolicy2(app, path, executionMode, base, isolation) {
74283
74361
  info(colors.gray(`Generating fresh policy for app ${path}...`));
74284
74362
  try {
74285
74363
  app.policy = await G3(app.value, base);
74286
- finalizeDerivedPolicy(app.policy, executionMode);
74364
+ finalizeDerivedPolicy(app.policy, executionMode, isolation);
74287
74365
  } catch (e) {
74288
74366
  error(colors.red(`Error generating policy for app ${path}: ${e}`));
74289
74367
  throw e;
@@ -74307,9 +74385,15 @@ function preserveOnBehalfOfFields(remotePath, deployedPolicy, permissionedAsCont
74307
74385
  info(`Preserving ${deployedPolicy?.on_behalf_of_email ?? onBehalfOf} as permissioned_as for app ${remotePath}`);
74308
74386
  return { preserve_on_behalf_of: true };
74309
74387
  }
74310
- function finalizeDerivedPolicy(policy, executionMode) {
74388
+ function finalizeDerivedPolicy(policy, executionMode, isolation, rawApp = false) {
74311
74389
  policy.triggerables = undefined;
74312
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
+ }
74313
74397
  }
74314
74398
  async function list6(opts) {
74315
74399
  const workspace = await resolveWorkspace(opts);
@@ -74421,7 +74505,7 @@ async function push5(opts, filePath, remotePath) {
74421
74505
  info(colors.bold.underline.green("App pushed"));
74422
74506
  }
74423
74507
  }
74424
- var alreadySynced2, APP_FOLDER_SUFFIXES, command14, app_default;
74508
+ var alreadySynced2, FRONTEND_API_SCOPES, APP_FOLDER_SUFFIXES, command14, app_default;
74425
74509
  var init_app = __esm(async () => {
74426
74510
  init_mod3();
74427
74511
  init_mod6();
@@ -74446,6 +74530,15 @@ var init_app = __esm(async () => {
74446
74530
  init_permissioned_as()
74447
74531
  ]);
74448
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
+ ];
74449
74542
  APP_FOLDER_SUFFIXES = ["__raw_app", ".raw_app", "__app", ".app"];
74450
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) => {
74451
74544
  warn(colors.yellow('This command is deprecated. Use "wmill generate-metadata" instead.'));
@@ -75531,7 +75624,7 @@ async function pushWorkspaceSettings(workspace, _path, settings, localSettings)
75531
75624
  const localOperatorSettings = localSettings.operator_settings && {
75532
75625
  ...localSettings.operator_settings
75533
75626
  };
75534
- for (const key of ["builder_flows", "manage_schedules", "manage_triggers"]) {
75627
+ for (const key of ["builder_flows", "builder_apps", "manage_schedules", "manage_triggers"]) {
75535
75628
  const remote = settings.operator_settings?.[key];
75536
75629
  if (localOperatorSettings && localOperatorSettings[key] === undefined && remote !== undefined) {
75537
75630
  localOperatorSettings[key] = remote;
@@ -79769,6 +79862,7 @@ var init_skills_gen = __esm(() => {
79769
79862
  { name: "resources", description: "MUST use when managing resources." },
79770
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." },
79771
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." },
79772
79866
  { name: "cli-commands", description: "MUST use when using the CLI, including debugging job failures and inspecting run history via `wmill job`." },
79773
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." }
79774
79868
  ];
@@ -80839,6 +80933,9 @@ async sleep(seconds: number): Promise<void>
80839
80933
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
80840
80934
  * the round that runs the body sees the same types every replay sees: a \`Date\`
80841
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.
80842
80939
  */
80843
80940
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
80844
80941
 
@@ -81682,6 +81779,9 @@ async sleep(seconds: number): Promise<void>
81682
81779
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
81683
81780
  * the round that runs the body sees the same types every replay sees: a \`Date\`
81684
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.
81685
81785
  */
81686
81786
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
81687
81787
 
@@ -82631,6 +82731,9 @@ async sleep(seconds: number): Promise<void>
82631
82731
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
82632
82732
  * the round that runs the body sees the same types every replay sees: a \`Date\`
82633
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.
82634
82737
  */
82635
82738
  async step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
82636
82739
 
@@ -84806,7 +84909,9 @@ def parse_sql_client_name(name: str) -> tuple[str, Optional[str]]
84806
84909
  #
84807
84910
  # - **v2 (inside @workflow)**: dispatches as a checkpoint step.
84808
84911
  # - **v1 (WM_JOB_ID set, no @workflow)**: dispatches via HTTP API.
84809
- # - **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.
84810
84915
  #
84811
84916
  # A task runs as its own job, so its result is always encoded as JSON and
84812
84917
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
@@ -84892,12 +84997,15 @@ def workflow(func)
84892
84997
  # \`\`fn\`\`'s result is encoded as JSON and decoded back before it is returned,
84893
84998
  # so the round that runs the body sees the same types every replay sees:
84894
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.
84895
85003
  async def step(name: str, fn)
84896
85004
 
84897
85005
  # Server-side sleep — suspend the workflow for the given duration without holding a worker.
84898
85006
  #
84899
85007
  # Inside a @workflow, the parent job suspends and auto-resumes after \`\`seconds\`\`.
84900
- # Outside a workflow, falls back to \`\`asyncio.sleep\`\`.
85008
+ # Outside a workflow, or inside a task body, falls back to \`\`asyncio.sleep\`\`.
84901
85009
  async def sleep(seconds: int)
84902
85010
 
84903
85011
  # Suspend the workflow and wait for an external approval.
@@ -85344,6 +85452,27 @@ Name the parameters by adding comments before the statement:
85344
85452
  SELECT * FROM users WHERE name = ? AND age > ?;
85345
85453
  \`\`\`
85346
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
+
85347
85476
  ## Receiving an S3Object as a script parameter
85348
85477
 
85349
85478
  Declare the arg with type \`(s3object)\`. Windmill renders an S3 file picker for
@@ -86084,7 +86213,7 @@ You need three values to run the command:
86084
86213
 
86085
86214
  1. **summary** — a short description of the app
86086
86215
  2. **path** — the windmill path, e.g. \`f/folder/my_app\` or \`u/username/my_app\`
86087
- 3. **framework** — one of \`react19\` (recommended), \`react18\`, \`svelte5\`, \`vue\`
86216
+ 3. **framework** — one of \`react19\` (recommended), \`react18\`, \`svelte5\`
86088
86217
 
86089
86218
  **summary and path**: if the user's request did not supply them, ask. Do not guess values and do not invent paths.
86090
86219
 
@@ -86156,7 +86285,7 @@ my_app{{RAW_APP_SUFFIX}}/
86156
86285
  ├── DATATABLES.md # Database schemas (run 'wmill app generate-agents' to refresh)
86157
86286
  ├── raw_app.yaml # App configuration (summary, path, data settings)
86158
86287
  ├── index.tsx # Frontend entry point
86159
- ├── App.tsx # Main React/Svelte/Vue component
86288
+ ├── App.tsx # Main React/Svelte component
86160
86289
  ├── index.css # Styles
86161
86290
  ├── package.json # Frontend dependencies
86162
86291
  ├── wmill.ts # Auto-generated backend type definitions (DO NOT EDIT)
@@ -86255,7 +86384,7 @@ data:
86255
86384
  - \`<datatable>/<table>\` — Specific table in public schema
86256
86385
  - \`<datatable>/<schema>:<table>\` — Table in specific schema
86257
86386
 
86258
- **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\`.
86259
86388
 
86260
86389
  ## SQL Migrations (sql_to_apply/)
86261
86390
 
@@ -86314,7 +86443,7 @@ For the rest, tell the user which command fits their intent and let them run it
86314
86443
 
86315
86444
  # Windmill Raw Apps
86316
86445
 
86317
- 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.
86318
86447
 
86319
86448
  ## App shape
86320
86449
 
@@ -86330,7 +86459,7 @@ A new app gets the setup Windmill's own new-app dialog gives one: a framework, t
86330
86459
 
86331
86460
  ### Framework
86332
86461
 
86333
- 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.
86334
86463
 
86335
86464
  ### Data setup
86336
86465
 
@@ -86360,7 +86489,7 @@ Then build what was chosen: the data table and schema become the app's \`data.da
86360
86489
 
86361
86490
  ### Entrypoint
86362
86491
 
86363
- 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.
86364
86493
 
86365
86494
  React (\`index.tsx\`):
86366
86495
 
@@ -86372,7 +86501,7 @@ import App from './App'
86372
86501
  createRoot(document.getElementById('root')!).render(<App />)
86373
86502
  \`\`\`
86374
86503
 
86375
- 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')! })\`.
86376
86505
 
86377
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\`.
86378
86507
 
@@ -86445,16 +86574,16 @@ Apply it to customer data, internal notes and anything else a viewer of the demo
86445
86574
 
86446
86575
  ### Chat UIs over a flow in chat mode
86447
86576
 
86448
- 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.
86449
86578
 
86450
86579
  \`\`\`tsx
86451
- import { useWindmillChat } from 'windmill-chat/react'
86580
+ import { useWindmillChat } from '@windmill-labs/chat-sdk/react'
86452
86581
 
86453
86582
  const chat = useWindmillChat({ flowPath: 'f/support/assistant' })
86454
86583
  // chat.messages ({ role, content, pending, success, tool? }), chat.status, chat.sendMessage(text), chat.stop()
86455
86584
  \`\`\`
86456
86585
 
86457
- \`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.
86458
86587
 
86459
86588
  ## Backend runnables
86460
86589
 
@@ -86538,6 +86667,18 @@ A draft app is reachable by nobody; deploying is what exposes it, and its backen
86538
86667
  Either one lets those people run the app's backend runnables, so never open an app up unless the user asks.
86539
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.
86540
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
+
86541
86682
  ## Data Tables
86542
86683
 
86543
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.
@@ -86549,6 +86690,7 @@ Data tables are PostgreSQL databases managed by Windmill. Backend runnables quer
86549
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.
86550
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.
86551
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.
86552
86694
 
86553
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\`.
86554
86696
 
@@ -86602,7 +86744,7 @@ def main(user_id: str):
86602
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.
86603
86745
  8. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
86604
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.
86605
- 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.
86606
86748
  `,
86607
86749
  triggers: `---
86608
86750
  name: triggers
@@ -87169,6 +87311,8 @@ async def enrich(customer_id: str):
87169
87311
 
87170
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\`.
87171
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
+
87172
87316
  For existing scripts:
87173
87317
 
87174
87318
  \`\`\`typescript
@@ -87334,8 +87478,9 @@ export async function getResumeUrls(approver?: string, flowLevel?: boolean): Pro
87334
87478
  * const call_api = task(fetchOrders, { retry: { attempts: 3, delay: 30, multiplier: 2 } });
87335
87479
  *
87336
87480
  * Inside a \`workflow()\`, calling a task dispatches it as a step.
87337
- * Outside a workflow, the function body executes directly and
87338
- * {@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.
87339
87484
  *
87340
87485
  * A task runs as its own job, so its result is always encoded as JSON and
87341
87486
  * decoded back before the caller sees it: a \`Date\` comes back as a string, a
@@ -87379,6 +87524,9 @@ export function workflow<T>(fn: (...args: any[]) => Promise<T>)
87379
87524
  * \`fn\`'s result is encoded as JSON and decoded back before it is returned, so
87380
87525
  * the round that runs the body sees the same types every replay sees: a \`Date\`
87381
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.
87382
87530
  */
87383
87531
  export async function step<T>(name: string, fn: () => T | Promise<T>,): Promise<Jsonified<Awaited<T>>>
87384
87532
 
@@ -87477,7 +87625,9 @@ def get_resume_urls(approver: str = None, flow_level: bool = None) -> dict
87477
87625
  #
87478
87626
  # - **v2 (inside @workflow)**: dispatches as a checkpoint step.
87479
87627
  # - **v1 (WM_JOB_ID set, no @workflow)**: dispatches via HTTP API.
87480
- # - **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.
87481
87631
  #
87482
87632
  # A task runs as its own job, so its result is always encoded as JSON and
87483
87633
  # decoded back before the caller sees it: a \`\`datetime\`\` comes back as a
@@ -87563,12 +87713,15 @@ def workflow(func)
87563
87713
  # \`\`fn\`\`'s result is encoded as JSON and decoded back before it is returned,
87564
87714
  # so the round that runs the body sees the same types every replay sees:
87565
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.
87566
87719
  async def step(name: str, fn)
87567
87720
 
87568
87721
  # Server-side sleep — suspend the workflow for the given duration without holding a worker.
87569
87722
  #
87570
87723
  # Inside a @workflow, the parent job suspends and auto-resumes after \`\`seconds\`\`.
87571
- # Outside a workflow, falls back to \`\`asyncio.sleep\`\`.
87724
+ # Outside a workflow, or inside a task body, falls back to \`\`asyncio.sleep\`\`.
87572
87725
  async def sleep(seconds: int)
87573
87726
 
87574
87727
  # Suspend the workflow and wait for an external approval.
@@ -87797,6 +87950,53 @@ Node \`f/sales/orders_daily\` (runs when \`orders\` is produced, writes a rollup
87797
87950
  SELECT date_trunc('day', ts) AS day, count(*) AS n
87798
87951
  FROM ducklake.main.orders GROUP BY 1
87799
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.
87800
88000
  `,
87801
88001
  "cli-commands": `---
87802
88002
  name: cli-commands
@@ -87835,7 +88035,7 @@ app related commands
87835
88035
  - \`app dev [app_folder:string]\` - Start a development server for building apps with live reload and hot module replacement
87836
88036
  - \`--port <port:number>\` - Port to run the dev server on (will find next available port if occupied)
87837
88037
  - \`--host <host:string>\` - Host to bind the dev server to
87838
- - \`--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)
87839
88039
  - \`--no-open\` - Don't automatically open the browser
87840
88040
  - \`--recording\` - Frame the app in a shell with a Record button, to capture a replayable session recording of the app under development
87841
88041
  - \`app lint [app_folder:string]\` - Lint a raw app folder to validate structure and buildability
@@ -87846,7 +88046,7 @@ app related commands
87846
88046
  - \`app new\` - create a new raw app from a template
87847
88047
  - \`--summary <summary:string>\` - App summary (short description). Skips the prompt when provided. Triggers non-interactive mode.
87848
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.
87849
- - \`--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.
87850
88050
  - \`--datatable <datatable:string>\` - Datatable to wire up. Without this flag in non-interactive mode, no datatable is configured.
87851
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.
87852
88052
  - \`--overwrite\` - Overwrite the target directory if it already exists, without prompting.
@@ -93754,8 +93954,8 @@ var CONFIG_REFERENCE = [
93754
93954
  type: "string",
93755
93955
  enum: ["bun", "deno"],
93756
93956
  default: "bun",
93757
- description: "Default TypeScript runtime for new scripts",
93758
- inlineComment: "bun or deno"
93957
+ description: "TypeScript runtime of a plain .ts script (bun when absent)",
93958
+ skipInTemplate: true
93759
93959
  },
93760
93960
  {
93761
93961
  name: "includes",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.829.0",
3
+ "version": "1.831.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",