windmill-cli 1.687.0 → 1.688.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 +142 -36
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -11812,7 +11812,7 @@ var init_OpenAPI = __esm(() => {
11812
11812
  PASSWORD: undefined,
11813
11813
  TOKEN: getEnv2("WM_TOKEN"),
11814
11814
  USERNAME: undefined,
11815
- VERSION: "1.687.0",
11815
+ VERSION: "1.688.0",
11816
11816
  WITH_CREDENTIALS: true,
11817
11817
  interceptors: {
11818
11818
  request: new Interceptors,
@@ -16745,7 +16745,8 @@ var backendVersion = () => {
16745
16745
  workspace: data2.workspace
16746
16746
  },
16747
16747
  query: {
16748
- force_cancel: data2.forceCancel
16748
+ force_cancel: data2.forceCancel,
16749
+ all_workspaces: data2.allWorkspaces
16749
16750
  },
16750
16751
  body: data2.requestBody,
16751
16752
  mediaType: "application/json"
@@ -67448,6 +67449,7 @@ var init_raw_apps = __esm(async () => {
67448
67449
  var exports_app_metadata = {};
67449
67450
  __export(exports_app_metadata, {
67450
67451
  inferRunnableSchemaFromFile: () => inferRunnableSchemaFromFile,
67452
+ inferAllInlineSchemas: () => inferAllInlineSchemas,
67451
67453
  getAppFolders: () => getAppFolders,
67452
67454
  generateLocksCommand: () => generateLocksCommand,
67453
67455
  generateAppLocksInternal: () => generateAppLocksInternal,
@@ -67455,7 +67457,7 @@ __export(exports_app_metadata, {
67455
67457
  APP_BACKEND_FOLDER: () => APP_BACKEND_FOLDER
67456
67458
  });
67457
67459
  import path13 from "node:path";
67458
- import { readFile as readFile11, mkdir as mkdir6 } from "node:fs/promises";
67460
+ import { readFile as readFile11, mkdir as mkdir6, readdir as readdir7 } from "node:fs/promises";
67459
67461
  import { sep as SEP11 } from "node:path";
67460
67462
  async function generateAppHash(rawReqs, folder, rawApp, defaultTs) {
67461
67463
  const runnablesFolder = rawApp ? path13.join(folder, APP_BACKEND_FOLDER) : folder;
@@ -67807,16 +67809,22 @@ ${text}`);
67807
67809
  throw new Error(`Failed to parse dependency response: ${rawResponse.statusText}, ${responseText}, ${e.message}`);
67808
67810
  }
67809
67811
  }
67810
- async function inferRunnableSchemaFromFile(appFolder, runnableFilePath) {
67812
+ async function inferRunnableSchemaFromFile(appFolder, runnableFilePath, defaultTs = "bun") {
67811
67813
  const fileName = path13.basename(runnableFilePath);
67812
67814
  if (fileName.endsWith(".lock") || fileName.endsWith(".yaml")) {
67813
67815
  return;
67814
67816
  }
67815
- const match2 = fileName.match(/^(.+)\.[^.]+$/);
67816
- if (!match2) {
67817
+ let runnableId;
67818
+ let ext2;
67819
+ for (const knownExt of Object.keys(EXTENSION_TO_LANGUAGE)) {
67820
+ if (fileName.endsWith("." + knownExt) && (!ext2 || knownExt.length > ext2.length)) {
67821
+ ext2 = knownExt;
67822
+ runnableId = fileName.slice(0, -(knownExt.length + 1));
67823
+ }
67824
+ }
67825
+ if (!runnableId || !ext2) {
67817
67826
  return;
67818
67827
  }
67819
- const runnableId = match2[1];
67820
67828
  const runnableFilePath2 = path13.join(appFolder, APP_BACKEND_FOLDER, `${runnableId}.yaml`);
67821
67829
  let runnable;
67822
67830
  try {
@@ -67831,15 +67839,23 @@ async function inferRunnableSchemaFromFile(appFolder, runnableFilePath) {
67831
67839
  }
67832
67840
  runnable = appFile.runnables[runnableId];
67833
67841
  } catch {
67834
- warn(colors.yellow(`Could not read runnable ${runnableId} from any source`));
67835
- return;
67842
+ runnable = { type: "inline" };
67836
67843
  }
67837
67844
  }
67838
- if (!runnable?.inlineScript) {
67845
+ let language;
67846
+ let currentSchema;
67847
+ if (runnable?.inlineScript) {
67848
+ language = runnable.inlineScript.language;
67849
+ currentSchema = runnable.inlineScript.schema;
67850
+ } else if (runnable?.type === "inline" || runnable?.type === "runnableByName") {
67851
+ language = getLanguageFromExtension(ext2, defaultTs);
67852
+ } else {
67853
+ return;
67854
+ }
67855
+ if (!language) {
67856
+ warn(colors.yellow(`Could not determine language for ${runnableId} (ext: ${ext2})`));
67839
67857
  return;
67840
67858
  }
67841
- const inlineScript = runnable.inlineScript;
67842
- const language = inlineScript.language;
67843
67859
  const fullFilePath = path13.join(appFolder, APP_BACKEND_FOLDER, runnableFilePath);
67844
67860
  let content;
67845
67861
  try {
@@ -67848,7 +67864,6 @@ async function inferRunnableSchemaFromFile(appFolder, runnableFilePath) {
67848
67864
  warn(colors.yellow(`Could not read file: ${fullFilePath}`));
67849
67865
  return;
67850
67866
  }
67851
- const currentSchema = inlineScript.schema;
67852
67867
  const remotePath = appFolder.replaceAll(SEP11, "/");
67853
67868
  try {
67854
67869
  const schemaResult = await inferSchema(language, content, currentSchema, `${remotePath}/${runnableId}`);
@@ -67862,6 +67877,28 @@ async function inferRunnableSchemaFromFile(appFolder, runnableFilePath) {
67862
67877
  return;
67863
67878
  }
67864
67879
  }
67880
+ async function inferAllInlineSchemas(appFolder, defaultTs = "bun") {
67881
+ const schemas = {};
67882
+ const backendPath = path13.join(appFolder, APP_BACKEND_FOLDER);
67883
+ let entries;
67884
+ try {
67885
+ entries = await readdir7(backendPath, { withFileTypes: true });
67886
+ } catch {
67887
+ return schemas;
67888
+ }
67889
+ for (const entry of entries) {
67890
+ if (!entry.isFile())
67891
+ continue;
67892
+ const fileName = entry.name;
67893
+ if (fileName.endsWith(".yaml") || fileName.endsWith(".lock"))
67894
+ continue;
67895
+ const result = await inferRunnableSchemaFromFile(appFolder, fileName, defaultTs);
67896
+ if (result) {
67897
+ schemas[result.runnableId] = result.schema;
67898
+ }
67899
+ }
67900
+ return schemas;
67901
+ }
67865
67902
  function getAppFolders(elems, extension) {
67866
67903
  return Object.keys(elems).filter((p) => p.endsWith(SEP11 + extension)).map((p) => p.substring(0, p.length - (SEP11 + extension).length));
67867
67904
  }
@@ -68196,7 +68233,19 @@ async function dev(opts, appFolder) {
68196
68233
  const appDir = path15.dirname(entryPoint) || process16.cwd();
68197
68234
  await ensureNodeModules(appDir);
68198
68235
  const inferredSchemas = {};
68199
- genRunnablesTs(inferredSchemas);
68236
+ try {
68237
+ Object.assign(inferredSchemas, await inferAllInlineSchemas(process16.cwd()));
68238
+ } catch (err) {
68239
+ warn(colors.yellow(`Could not seed inline schemas at startup: ${err.message}`));
68240
+ }
68241
+ const pathRunnableSchemas = {};
68242
+ try {
68243
+ const initialRunnables = await loadRunnablesFromBackend(path15.join(process16.cwd(), APP_BACKEND_FOLDER));
68244
+ Object.assign(pathRunnableSchemas, await fetchPathRunnableSchemas(workspaceId, initialRunnables));
68245
+ } catch (err) {
68246
+ warn(colors.yellow(`Could not fetch schemas for path-based runnables: ${err.message}`));
68247
+ }
68248
+ await genRunnablesTs(inferredSchemas, pathRunnableSchemas);
68200
68249
  const distDir = path15.join(process16.cwd(), "dist");
68201
68250
  if (!fs10.existsSync(distDir)) {
68202
68251
  fs10.mkdirSync(distDir);
@@ -68290,7 +68339,7 @@ data: reload
68290
68339
  if (result) {
68291
68340
  inferredSchemas[result.runnableId] = result.schema;
68292
68341
  info(colors.green(` Inferred Schemas: ${JSON.stringify(inferredSchemas, null, 2)}`));
68293
- await genRunnablesTs(inferredSchemas);
68342
+ await genRunnablesTs(inferredSchemas, pathRunnableSchemas);
68294
68343
  }
68295
68344
  } catch (error2) {
68296
68345
  error(colors.red(`Error inferring schema: ${error2.message}`));
@@ -68724,7 +68773,7 @@ data: reload
68724
68773
  process16.exit(0);
68725
68774
  });
68726
68775
  }
68727
- async function genRunnablesTs(schemaOverrides = {}) {
68776
+ async function genRunnablesTs(inlineSchemaOverrides = {}, pathSchemaOverrides = {}) {
68728
68777
  info(colors.blue("\uD83D\uDD04 Generating wmill.d.ts..."));
68729
68778
  const localPath = process16.cwd();
68730
68779
  const backendPath = path15.join(localPath, APP_BACKEND_FOLDER);
@@ -68737,21 +68786,65 @@ async function genRunnablesTs(schemaOverrides = {}) {
68737
68786
  runnables = {};
68738
68787
  }
68739
68788
  }
68740
- if (Object.keys(schemaOverrides).length > 0) {
68741
- for (const [runnableId, schema] of Object.entries(schemaOverrides)) {
68742
- if (runnables[runnableId]?.inlineScript) {
68743
- runnables[runnableId].inlineScript.schema = schema;
68744
- runnables[runnableId].type = "inline";
68745
- }
68746
- }
68747
- }
68748
68789
  try {
68749
- const newWmillTs = genWmillTs(runnables);
68790
+ const newWmillTs = buildWmillTs(runnables, inlineSchemaOverrides, pathSchemaOverrides);
68750
68791
  writeFileSync5(path15.join(process16.cwd(), "wmill.d.ts"), newWmillTs);
68751
68792
  } catch (error2) {
68752
68793
  error(colors.red(`Failed to generate wmill.d.ts: ${error2.message}`));
68753
68794
  }
68754
68795
  }
68796
+ function buildWmillTs(runnables, inlineSchemaOverrides = {}, pathSchemaOverrides = {}) {
68797
+ for (const [runnableId, schema] of Object.entries(inlineSchemaOverrides)) {
68798
+ if (runnables[runnableId]?.inlineScript) {
68799
+ runnables[runnableId].inlineScript.schema = schema;
68800
+ runnables[runnableId].type = "inline";
68801
+ }
68802
+ }
68803
+ for (const [runnableId, schema] of Object.entries(pathSchemaOverrides)) {
68804
+ const runnable = runnables[runnableId];
68805
+ if (runnable?.type === "path" && schema) {
68806
+ runnable.schema = schema;
68807
+ }
68808
+ }
68809
+ for (const runnable of Object.values(runnables)) {
68810
+ if (runnable?.type === "path" && !runnable.schema) {
68811
+ runnable.schema = {};
68812
+ }
68813
+ }
68814
+ return genWmillTs(runnables);
68815
+ }
68816
+ async function fetchPathRunnableSchemas(workspaceId, runnables) {
68817
+ const schemas = {};
68818
+ for (const [runnableId, runnable] of Object.entries(runnables)) {
68819
+ if (runnable?.type !== "path" || !runnable.path)
68820
+ continue;
68821
+ if (runnable.schema) {
68822
+ schemas[runnableId] = runnable.schema;
68823
+ continue;
68824
+ }
68825
+ try {
68826
+ if (runnable.runType === "script") {
68827
+ const script = await getScriptByPath({
68828
+ workspace: workspaceId,
68829
+ path: runnable.path
68830
+ });
68831
+ if (script.schema)
68832
+ schemas[runnableId] = script.schema;
68833
+ } else if (runnable.runType === "flow") {
68834
+ const flow = await getFlowByPath({
68835
+ workspace: workspaceId,
68836
+ path: runnable.path
68837
+ });
68838
+ const flowSchema = flow?.value?.schema ?? flow?.schema;
68839
+ if (flowSchema)
68840
+ schemas[runnableId] = flowSchema;
68841
+ }
68842
+ } catch (err) {
68843
+ warn(colors.yellow(`Failed to fetch schema for ${runnable.runType} ${runnable.path}: ${err.message}`));
68844
+ }
68845
+ }
68846
+ return schemas;
68847
+ }
68755
68848
  function convertRunnablesToApiFormat(runnables) {
68756
68849
  for (const [runnableId, runnable] of Object.entries(runnables)) {
68757
68850
  if (runnable?.type === "script" || runnable?.type === "hubscript" || runnable?.type === "flow") {
@@ -70145,7 +70238,7 @@ var init_app = __esm(async () => {
70145
70238
  });
70146
70239
 
70147
70240
  // src/commands/folder/folder.ts
70148
- import { stat as stat11, readdir as readdir7, writeFile as writeFile11, mkdir as mkdir8 } from "node:fs/promises";
70241
+ import { stat as stat11, readdir as readdir8, writeFile as writeFile11, mkdir as mkdir8 } from "node:fs/promises";
70149
70242
  import { sep as SEP14 } from "node:path";
70150
70243
  async function list7(opts) {
70151
70244
  if (opts.json)
@@ -70273,7 +70366,7 @@ async function addMissing(opts) {
70273
70366
  info("No 'f/' directory found. Nothing to do.");
70274
70367
  return;
70275
70368
  }
70276
- const entries = await readdir7(fDir, { withFileTypes: true });
70369
+ const entries = await readdir8(fDir, { withFileTypes: true });
70277
70370
  const missing = [];
70278
70371
  for (const entry of entries) {
70279
70372
  if (!entry.isDirectory())
@@ -71273,7 +71366,7 @@ var init_settings = __esm(async () => {
71273
71366
  });
71274
71367
 
71275
71368
  // src/commands/instance/instance.ts
71276
- import { readFile as readFile13, writeFile as writeFile15, readdir as readdir8, mkdir as mkdir11, rm as rm3, stat as stat14 } from "node:fs/promises";
71369
+ import { readFile as readFile13, writeFile as writeFile15, readdir as readdir9, mkdir as mkdir11, rm as rm3, stat as stat14 } from "node:fs/promises";
71277
71370
  import { appendFile } from "node:fs/promises";
71278
71371
  import * as path18 from "node:path";
71279
71372
  async function allInstances() {
@@ -71688,7 +71781,7 @@ async function getLocalWorkspaces(rootDir, localPrefix, folderPerInstance) {
71688
71781
  await mkdir11(localPrefix);
71689
71782
  }
71690
71783
  if (folderPerInstance) {
71691
- const prefixEntries = await readdir8(rootDir + "/" + localPrefix, { withFileTypes: true });
71784
+ const prefixEntries = await readdir9(rootDir + "/" + localPrefix, { withFileTypes: true });
71692
71785
  for (const dir of prefixEntries) {
71693
71786
  if (dir.isDirectory()) {
71694
71787
  const dirName = dir.name;
@@ -71699,7 +71792,7 @@ async function getLocalWorkspaces(rootDir, localPrefix, folderPerInstance) {
71699
71792
  }
71700
71793
  }
71701
71794
  } else {
71702
- const rootEntries = await readdir8(rootDir, { withFileTypes: true });
71795
+ const rootEntries = await readdir9(rootDir, { withFileTypes: true });
71703
71796
  for (const dir of rootEntries) {
71704
71797
  const dirName = dir.name;
71705
71798
  if (dirName.startsWith(localPrefix + "_")) {
@@ -76697,7 +76790,7 @@ await __promiseAll([
76697
76790
  import { stat as stat18, writeFile as writeFile20, rm as rm4 } from "node:fs/promises";
76698
76791
 
76699
76792
  // src/guidance/writer.ts
76700
- import { cp, mkdir as mkdir13, readdir as readdir9, readFile as readFile17, stat as stat17, writeFile as writeFile19 } from "node:fs/promises";
76793
+ import { cp, mkdir as mkdir13, readdir as readdir10, readFile as readFile17, stat as stat17, writeFile as writeFile19 } from "node:fs/promises";
76701
76794
  import { join as join17 } from "node:path";
76702
76795
 
76703
76796
  // src/guidance/core.ts
@@ -76740,6 +76833,19 @@ You MUST use the \`resources\` skill to manage resource types and credentials.
76740
76833
 
76741
76834
  You MUST use the \`cli-commands\` skill to use the CLI.
76742
76835
 
76836
+ ## Debugging Jobs
76837
+
76838
+ When the user reports a script or flow failure, is investigating unexpected output, or asks why something ran the way it did, use the CLI to fetch job details before speculating. See the \`cli-commands\` skill for all flags.
76839
+
76840
+ - \`wmill job list --script-path <path>\` — recent runs of a specific script or flow
76841
+ - \`wmill job list --failed --limit 20\` — recent failures across the workspace
76842
+ - \`wmill job get <id>\` — status, timing, and (for flows) the step tree with sub-job IDs
76843
+ - \`wmill job logs <id>\` — stdout/stderr; for flows, aggregates every step's logs
76844
+ - \`wmill job result <id>\` — JSON result of a completed job
76845
+ - \`wmill job cancel <id>\` — stop a running or queued job
76846
+
76847
+ For flow failures, start with \`wmill job get <id>\` to identify the failing step and its sub-job ID, then \`wmill job logs <sub-job-id>\` to drill in.
76848
+
76743
76849
  ## Skills
76744
76850
 
76745
76851
  For specific guidance, ALWAYS use the skills listed below.
@@ -76775,7 +76881,7 @@ var SKILLS = [
76775
76881
  { name: "triggers", description: "MUST use when configuring triggers." },
76776
76882
  { name: "schedules", description: "MUST use when configuring schedules." },
76777
76883
  { name: "resources", description: "MUST use when managing resources." },
76778
- { name: "cli-commands", description: "MUST use when using the CLI." }
76884
+ { name: "cli-commands", description: "MUST use when using the CLI, including debugging job failures and inspecting run history via `wmill job`." }
76779
76885
  ];
76780
76886
  var SKILL_CONTENT = {
76781
76887
  "write-script-bash": `---
@@ -81994,7 +82100,7 @@ wmill sync push
81994
82100
  `,
81995
82101
  "cli-commands": `---
81996
82102
  name: cli-commands
81997
- description: MUST use when using the CLI.
82103
+ description: MUST use when using the CLI, including debugging job failures and inspecting run history via \`wmill job\`.
81998
82104
  ---
81999
82105
 
82000
82106
  # Windmill CLI Commands
@@ -83607,7 +83713,7 @@ async function ensureSkillsDirectory(targetDir) {
83607
83713
  return skillsDir;
83608
83714
  }
83609
83715
  async function copyDirectoryContents(sourceDir, targetDir) {
83610
- const entries = await readdir9(sourceDir, { withFileTypes: true });
83716
+ const entries = await readdir10(sourceDir, { withFileTypes: true });
83611
83717
  await Promise.all(entries.map(async (entry) => {
83612
83718
  await cp(join17(sourceDir, entry.name), join17(targetDir, entry.name), {
83613
83719
  recursive: true,
@@ -83646,7 +83752,7 @@ ${schemaDocs.join(`
83646
83752
  `)}`;
83647
83753
  }
83648
83754
  async function readSkillMetadataFromDirectory(skillsDir) {
83649
- const entries = await readdir9(skillsDir, { withFileTypes: true });
83755
+ const entries = await readdir10(skillsDir, { withFileTypes: true });
83650
83756
  const skills = [];
83651
83757
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
83652
83758
  if (!entry.isDirectory()) {
@@ -85460,7 +85566,7 @@ var config_default = command35;
85460
85566
 
85461
85567
  // src/main.ts
85462
85568
  await init_context();
85463
- var VERSION = "1.687.0";
85569
+ var VERSION = "1.688.0";
85464
85570
  async function checkVersionSafe(cmd) {
85465
85571
  const mainCommand = cmd.getMainCommand();
85466
85572
  const upgradeCommand = mainCommand.getCommand("upgrade");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.687.0",
3
+ "version": "1.688.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",