@amaster.ai/runtime-cli 1.1.13 → 1.1.14-beta.1

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.
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync, realpathSync } from 'fs';
2
+ import { readFileSync, existsSync, rmSync, mkdirSync, writeFileSync, realpathSync } from 'fs';
3
3
  import { join, resolve, basename } from 'path';
4
4
  import { homedir } from 'os';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { Command, Option } from 'commander';
7
- import chalk3 from 'chalk';
7
+ import chalk4 from 'chalk';
8
8
  import { createClient } from '@amaster.ai/client';
9
9
  import ora from 'ora';
10
10
  import { File } from 'buffer';
@@ -327,9 +327,9 @@ async function login(appCode, options) {
327
327
  const appConfig = getAppConfig(appCode);
328
328
  if (!appConfig) {
329
329
  spinner.fail(`App not configured: ${appCode}`);
330
- console.error(chalk3.red(`
330
+ console.error(chalk4.red(`
331
331
  \u274C App not found: ${appCode}`));
332
- console.log(chalk3.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
332
+ console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
333
333
  process.exit(1);
334
334
  }
335
335
  let username = options.username;
@@ -378,7 +378,7 @@ async function login(appCode, options) {
378
378
  const result = await client.auth.login(loginParams);
379
379
  if (result.error) {
380
380
  spinner.fail("Login failed");
381
- console.error(chalk3.red(result.error.message));
381
+ console.error(chalk4.red(result.error.message));
382
382
  process.exit(1);
383
383
  }
384
384
  const loginData = result.data;
@@ -412,16 +412,16 @@ async function login(appCode, options) {
412
412
  format: options.format,
413
413
  pretty: () => {
414
414
  console.log(
415
- chalk3.green(
415
+ chalk4.green(
416
416
  `
417
417
  Welcome, ${loginData.user?.displayName || loginData.user?.email || loginData.user?.username || email}!`
418
418
  )
419
419
  );
420
- console.log(chalk3.gray(`App: ${appCode}`));
421
- console.log(chalk3.gray(`URL: ${appConfig.baseURL}`));
420
+ console.log(chalk4.gray(`App: ${appCode}`));
421
+ console.log(chalk4.gray(`URL: ${appConfig.baseURL}`));
422
422
  if (expiresAt) {
423
423
  const expires = new Date(expiresAt);
424
- console.log(chalk3.gray(`Session expires: ${expires.toLocaleString()}`));
424
+ console.log(chalk4.gray(`Session expires: ${expires.toLocaleString()}`));
425
425
  }
426
426
  }
427
427
  }
@@ -457,7 +457,7 @@ async function logout(appCode, options = {}) {
457
457
  {
458
458
  format: options.format,
459
459
  pretty: () => {
460
- console.log(chalk3.green(`Logged out from ${appCode}`));
460
+ console.log(chalk4.green(`Logged out from ${appCode}`));
461
461
  }
462
462
  }
463
463
  );
@@ -473,7 +473,7 @@ async function getMe(getClient, options = {}) {
473
473
  const result = await client.auth.getMe();
474
474
  if (result.error) {
475
475
  spinner.fail("Failed to fetch user info");
476
- console.error(chalk3.red(result.error.message));
476
+ console.error(chalk4.red(result.error.message));
477
477
  process.exit(1);
478
478
  }
479
479
  spinner.succeed("User info retrieved");
@@ -481,11 +481,11 @@ async function getMe(getClient, options = {}) {
481
481
  renderOutput(user, {
482
482
  format: options.format,
483
483
  pretty: () => {
484
- console.log(chalk3.blue("\n\u{1F464} User Profile\n"));
485
- console.log(` ${chalk3.bold("UID:")} ${user?.uid}`);
486
- console.log(` ${chalk3.bold("Email:")} ${user?.email}`);
487
- console.log(` ${chalk3.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
488
- console.log(` ${chalk3.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
484
+ console.log(chalk4.blue("\n\u{1F464} User Profile\n"));
485
+ console.log(` ${chalk4.bold("UID:")} ${user?.uid}`);
486
+ console.log(` ${chalk4.bold("Email:")} ${user?.email}`);
487
+ console.log(` ${chalk4.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
488
+ console.log(` ${chalk4.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
489
489
  }
490
490
  });
491
491
  } catch (error) {
@@ -615,7 +615,7 @@ function exitWithCommandError(spinner, failureMessage, error) {
615
615
  spinner.fail(failureMessage);
616
616
  const details = error instanceof Error ? error.message : String(error);
617
617
  if (details) {
618
- console.error(chalk3.red(details));
618
+ console.error(chalk4.red(details));
619
619
  }
620
620
  process.exit(1);
621
621
  }
@@ -680,7 +680,7 @@ async function listEntities(client, options) {
680
680
  });
681
681
  if (result.error) {
682
682
  spinner.fail("Failed to fetch entities");
683
- console.error(chalk3.red(result.error.message));
683
+ console.error(chalk4.red(result.error.message));
684
684
  process.exit(1);
685
685
  }
686
686
  spinner.stop();
@@ -700,12 +700,12 @@ async function listEntities(client, options) {
700
700
  renderOutput(result.data, {
701
701
  format: options.format,
702
702
  pretty: () => {
703
- console.log(chalk3.blue(`
703
+ console.log(chalk4.blue(`
704
704
  \u{1F4E6} ${options.entity} in ${options.namespace}`));
705
- console.log(chalk3.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
705
+ console.log(chalk4.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
706
706
  `));
707
707
  if (items.length === 0) {
708
- console.log(chalk3.gray(" \u6682\u65E0\u6570\u636E"));
708
+ console.log(chalk4.gray(" \u6682\u65E0\u6570\u636E"));
709
709
  return;
710
710
  }
711
711
  const firstItem = items[0];
@@ -725,7 +725,7 @@ async function listEntities(client, options) {
725
725
  });
726
726
  const headerLine = keys.map((key) => {
727
727
  const width = widths[key] ?? 0;
728
- return chalk3.bold(key.slice(0, width).padEnd(width));
728
+ return chalk4.bold(key.slice(0, width).padEnd(width));
729
729
  }).join("\u2502");
730
730
  console.log(" " + headerLine);
731
731
  console.log(" " + keys.map((key) => "\u2500".repeat(widths[key] ?? 0)).join("\u253C"));
@@ -741,7 +741,7 @@ async function listEntities(client, options) {
741
741
  }
742
742
  console.log();
743
743
  if (items.length < total) {
744
- console.log(chalk3.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
744
+ console.log(chalk4.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
745
745
  }
746
746
  }
747
747
  });
@@ -756,14 +756,14 @@ async function getEntity(client, options) {
756
756
  const result = await entityClient.get(options.namespace, options.entity, options.id);
757
757
  if (result.error) {
758
758
  spinner.fail("Failed to fetch entity");
759
- console.error(chalk3.red(result.error.message));
759
+ console.error(chalk4.red(result.error.message));
760
760
  process.exit(1);
761
761
  }
762
762
  spinner.succeed("Entity retrieved");
763
763
  renderOutput(result.data, {
764
764
  format: options.format,
765
765
  pretty: () => {
766
- console.log(chalk3.blue(`
766
+ console.log(chalk4.blue(`
767
767
  \u{1F4C4} ${options.entity}
768
768
  `));
769
769
  console.log(JSON.stringify(result.data, null, 2));
@@ -781,14 +781,14 @@ async function createEntity(client, options) {
781
781
  const result = await entityClient.create(options.namespace, options.entity, data);
782
782
  if (result.error) {
783
783
  spinner.fail("Failed to create entity");
784
- console.error(chalk3.red(result.error.message));
784
+ console.error(chalk4.red(result.error.message));
785
785
  process.exit(1);
786
786
  }
787
787
  spinner.succeed("Entity created");
788
788
  renderOutput(result.data, {
789
789
  format: options.format,
790
790
  pretty: () => {
791
- console.log(chalk3.green("\nCreated entity:"));
791
+ console.log(chalk4.green("\nCreated entity:"));
792
792
  console.log(JSON.stringify(result.data, null, 2));
793
793
  }
794
794
  });
@@ -804,14 +804,14 @@ async function updateEntity(client, options) {
804
804
  const result = await entityClient.update(options.namespace, options.entity, options.id, data);
805
805
  if (result.error) {
806
806
  spinner.fail("Failed to update entity");
807
- console.error(chalk3.red(result.error.message));
807
+ console.error(chalk4.red(result.error.message));
808
808
  process.exit(1);
809
809
  }
810
810
  spinner.succeed("Entity updated");
811
811
  renderOutput(result.data, {
812
812
  format: options.format,
813
813
  pretty: () => {
814
- console.log(chalk3.green("\nUpdated entity:"));
814
+ console.log(chalk4.green("\nUpdated entity:"));
815
815
  console.log(JSON.stringify(result.data, null, 2));
816
816
  }
817
817
  });
@@ -826,7 +826,7 @@ async function deleteEntity(client, options) {
826
826
  const result = await entityClient.delete(options.namespace, options.entity, options.id);
827
827
  if (result.error) {
828
828
  spinner.fail("Failed to delete entity");
829
- console.error(chalk3.red(result.error.message));
829
+ console.error(chalk4.red(result.error.message));
830
830
  process.exit(1);
831
831
  }
832
832
  spinner.succeed("Entity deleted");
@@ -840,7 +840,7 @@ async function deleteEntity(client, options) {
840
840
  {
841
841
  format: options.format,
842
842
  pretty: () => {
843
- console.log(chalk3.green(`
843
+ console.log(chalk4.green(`
844
844
  Deleted ${options.entity} with ID: ${options.id}`));
845
845
  }
846
846
  }
@@ -857,14 +857,14 @@ async function listEntityOptions(client, options) {
857
857
  const result = await entityClient.options(options.namespace, options.entity, fields);
858
858
  if (result.error) {
859
859
  spinner.fail("Failed to fetch entity options");
860
- console.error(chalk3.red(result.error.message));
860
+ console.error(chalk4.red(result.error.message));
861
861
  process.exit(1);
862
862
  }
863
863
  spinner.succeed(`Found ${result.data?.length || 0} options`);
864
864
  renderOutput(result.data || [], {
865
865
  format: options.format,
866
866
  pretty: () => {
867
- console.log(chalk3.blue(`
867
+ console.log(chalk4.blue(`
868
868
  \u{1F9FE} ${options.entity} options
869
869
  `));
870
870
  console.log(JSON.stringify(result.data || [], null, 2));
@@ -887,14 +887,14 @@ async function bulkUpdateEntities(client, options) {
887
887
  const result = await entityClient.bulkUpdate(options.namespace, options.entity, items);
888
888
  if (result.error) {
889
889
  spinner.fail("Failed to bulk update entities");
890
- console.error(chalk3.red(result.error.message));
890
+ console.error(chalk4.red(result.error.message));
891
891
  process.exit(1);
892
892
  }
893
893
  spinner.succeed(`Updated ${items.length} entities`);
894
894
  renderOutput(result.data, {
895
895
  format: options.format,
896
896
  pretty: () => {
897
- console.log(chalk3.green(`
897
+ console.log(chalk4.green(`
898
898
  Bulk updated ${items.length} ${options.entity} records:`));
899
899
  console.log(JSON.stringify(result.data, null, 2));
900
900
  }
@@ -911,7 +911,7 @@ async function bulkDeleteEntities(client, options) {
911
911
  const result = await entityClient.bulkDelete(options.namespace, options.entity, ids);
912
912
  if (result.error) {
913
913
  spinner.fail("Failed to bulk delete entities");
914
- console.error(chalk3.red(result.error.message));
914
+ console.error(chalk4.red(result.error.message));
915
915
  process.exit(1);
916
916
  }
917
917
  spinner.succeed(`Deleted ${ids.length} entities`);
@@ -926,7 +926,7 @@ async function bulkDeleteEntities(client, options) {
926
926
  {
927
927
  format: options.format,
928
928
  pretty: () => {
929
- console.log(chalk3.green(`
929
+ console.log(chalk4.green(`
930
930
  Deleted ${ids.length} ${options.entity} records.`));
931
931
  }
932
932
  }
@@ -935,10 +935,165 @@ Deleted ${ids.length} ${options.entity} records.`));
935
935
  exitWithCommandError(spinner, "Failed to bulk delete entities", error);
936
936
  }
937
937
  }
938
+ function resolveInputSource2(input) {
939
+ if (!input.startsWith("@")) {
940
+ return input;
941
+ }
942
+ const filePath = input.slice(1);
943
+ if (!filePath) {
944
+ throw new Error("File path is required after '@'.");
945
+ }
946
+ return readFileSync(filePath, "utf8");
947
+ }
948
+ function exitWithCommandError2(spinner, failureMessage, error) {
949
+ spinner.fail(failureMessage);
950
+ const details = error instanceof Error ? error.message : String(error);
951
+ if (details) {
952
+ console.error(chalk4.red(details));
953
+ }
954
+ process.exit(1);
955
+ }
956
+ function parseTableNamesInput(input) {
957
+ if (!input) {
958
+ return void 0;
959
+ }
960
+ const source = resolveInputSource2(input).trim();
961
+ if (!source) {
962
+ return void 0;
963
+ }
964
+ if (source.startsWith("[")) {
965
+ let parsed;
966
+ try {
967
+ parsed = JSON.parse(source);
968
+ } catch (error) {
969
+ const reason = error instanceof Error ? error.message : String(error);
970
+ throw new Error(`Invalid table list: ${reason}`);
971
+ }
972
+ if (!Array.isArray(parsed)) {
973
+ throw new Error("Table list must be a JSON array.");
974
+ }
975
+ return parsed.map((value, index) => {
976
+ if (typeof value !== "string") {
977
+ throw new Error(`Table name at index ${index} must be a string.`);
978
+ }
979
+ return value;
980
+ });
981
+ }
982
+ const values = source.split(/[,\n]/).map((entry) => entry.trim()).filter(Boolean);
983
+ return values.length > 0 ? values : void 0;
984
+ }
985
+ async function listDatasources(client, options = {}) {
986
+ const spinner = createSpinner("Fetching datasources...", options.format);
987
+ try {
988
+ const result = await client.http.request({
989
+ url: "/api/entity/source/list_with_models",
990
+ method: "GET"
991
+ });
992
+ if (result.error) {
993
+ spinner.fail("Failed to fetch datasources");
994
+ console.error(chalk4.red(result.error.message));
995
+ process.exit(1);
996
+ }
997
+ const datasources = result.data || [];
998
+ spinner.succeed(`Found ${datasources.length} datasource${datasources.length === 1 ? "" : "s"}`);
999
+ renderOutput(datasources, {
1000
+ format: options.format,
1001
+ tableRows: datasources.map((source) => ({
1002
+ sourceId: source.sourceId,
1003
+ name: source.name,
1004
+ systemBuilt: source.systemBuilt,
1005
+ synchronizeMode: source.synchronizeMode,
1006
+ modelCount: source.models?.length || 0
1007
+ })),
1008
+ csvRows: datasources.map((source) => ({
1009
+ sourceId: source.sourceId,
1010
+ name: source.name,
1011
+ systemBuilt: source.systemBuilt,
1012
+ synchronizeMode: source.synchronizeMode,
1013
+ modelCount: source.models?.length || 0
1014
+ })),
1015
+ ndjsonItems: datasources,
1016
+ pretty: () => {
1017
+ console.log(chalk4.blue("\nData Sources\n"));
1018
+ if (datasources.length === 0) {
1019
+ console.log(chalk4.gray("No datasources found."));
1020
+ return;
1021
+ }
1022
+ for (const source of datasources) {
1023
+ console.log(`${chalk4.green("\u2022")} ${chalk4.bold(source.name)} ${chalk4.gray(`(${source.sourceId})`)}`);
1024
+ console.log(` ${chalk4.gray("System Built:")} ${source.systemBuilt}`);
1025
+ console.log(` ${chalk4.gray("Sync Mode:")} ${source.synchronizeMode}`);
1026
+ if (!source.models || source.models.length === 0) {
1027
+ console.log(` ${chalk4.gray("Models:")} none`);
1028
+ continue;
1029
+ }
1030
+ console.log(` ${chalk4.gray("Models:")}`);
1031
+ for (const model of source.models) {
1032
+ const suffix = model.description ? ` ${chalk4.gray(`- ${model.description}`)}` : "";
1033
+ console.log(` - ${chalk4.bold(model.tableName)} ${chalk4.gray(`(${model.modelId})`)}${suffix}`);
1034
+ }
1035
+ }
1036
+ }
1037
+ });
1038
+ } catch (error) {
1039
+ exitWithCommandError2(spinner, "Failed to fetch datasources", error);
1040
+ }
1041
+ }
1042
+ async function getTableSchema(client, options) {
1043
+ const spinner = createSpinner(`Fetching table schema for ${options.sourceId}...`, options.format);
1044
+ try {
1045
+ const tableNames = parseTableNamesInput(options.tables);
1046
+ const search = new URLSearchParams();
1047
+ if (tableNames && tableNames.length > 0) {
1048
+ search.set("tableNames", tableNames.join(","));
1049
+ }
1050
+ const query = search.toString();
1051
+ const url = `/api/entity/source/${encodeURIComponent(options.sourceId)}/create_table_statements${query ? `?${query}` : ""}`;
1052
+ const result = await client.http.request({
1053
+ url,
1054
+ method: "GET"
1055
+ });
1056
+ if (result.error) {
1057
+ spinner.fail("Failed to fetch table schema");
1058
+ console.error(chalk4.red(result.error.message));
1059
+ process.exit(1);
1060
+ }
1061
+ const tables = result.data || [];
1062
+ spinner.succeed(`Fetched schema for ${tables.length} table${tables.length === 1 ? "" : "s"}`);
1063
+ renderOutput(tables, {
1064
+ format: options.format,
1065
+ tableRows: tables.map((table) => ({
1066
+ tableName: table.tableName,
1067
+ createTableSql: table.createTableSql
1068
+ })),
1069
+ csvRows: tables.map((table) => ({
1070
+ tableName: table.tableName,
1071
+ createTableSql: table.createTableSql
1072
+ })),
1073
+ ndjsonItems: tables,
1074
+ pretty: () => {
1075
+ console.log(chalk4.blue(`
1076
+ Table Schemas: ${options.sourceId}
1077
+ `));
1078
+ if (tables.length === 0) {
1079
+ console.log(chalk4.gray("No tables found."));
1080
+ return;
1081
+ }
1082
+ for (const table of tables) {
1083
+ console.log(chalk4.green(table.tableName));
1084
+ console.log(table.createTableSql);
1085
+ console.log();
1086
+ }
1087
+ }
1088
+ });
1089
+ } catch (error) {
1090
+ exitWithCommandError2(spinner, "Failed to fetch table schema", error);
1091
+ }
1092
+ }
938
1093
  function isPlainObject3(value) {
939
1094
  return typeof value === "object" && value !== null && !Array.isArray(value);
940
1095
  }
941
- function resolveInputSource2(input) {
1096
+ function resolveInputSource3(input) {
942
1097
  if (!input.startsWith("@")) {
943
1098
  return input;
944
1099
  }
@@ -949,7 +1104,7 @@ function resolveInputSource2(input) {
949
1104
  return readFileSync(filePath, "utf8");
950
1105
  }
951
1106
  function parseJsonInput2(input, label) {
952
- const source = resolveInputSource2(input).trim();
1107
+ const source = resolveInputSource3(input).trim();
953
1108
  if (!source) {
954
1109
  throw new Error(`${label} is required.`);
955
1110
  }
@@ -990,11 +1145,11 @@ function loadOptionalJsonObjectInput2(input, label) {
990
1145
  }
991
1146
  return value;
992
1147
  }
993
- function exitWithCommandError2(spinner, failureMessage, error) {
1148
+ function exitWithCommandError3(spinner, failureMessage, error) {
994
1149
  spinner.fail(failureMessage);
995
1150
  const details = error instanceof Error ? error.message : String(error);
996
1151
  if (details) {
997
- console.error(chalk3.red(details));
1152
+ console.error(chalk4.red(details));
998
1153
  }
999
1154
  process.exit(1);
1000
1155
  }
@@ -1003,7 +1158,7 @@ function extractClientErrorMessage(error) {
1003
1158
  }
1004
1159
  function exitWithClientError(spinner, failureMessage, error, diagnosticMessage) {
1005
1160
  spinner.fail(failureMessage);
1006
- console.error(chalk3.red(diagnosticMessage || extractClientErrorMessage(error)));
1161
+ console.error(chalk4.red(diagnosticMessage || extractClientErrorMessage(error)));
1007
1162
  process.exit(1);
1008
1163
  }
1009
1164
  function inspectStartEventFormConfiguration(bpmnXml) {
@@ -1184,7 +1339,7 @@ async function listProcesses(client, options = {}) {
1184
1339
  const result = await bpmClient.getProcessDefinitions(params);
1185
1340
  if (result.error) {
1186
1341
  spinner.fail("Failed to fetch processes");
1187
- console.error(chalk3.red(result.error.message));
1342
+ console.error(chalk4.red(result.error.message));
1188
1343
  process.exit(1);
1189
1344
  }
1190
1345
  spinner.succeed(`Found ${result.data?.length || 0} process definitions`);
@@ -1192,19 +1347,19 @@ async function listProcesses(client, options = {}) {
1192
1347
  renderOutput(processes, {
1193
1348
  format: options.format,
1194
1349
  pretty: () => {
1195
- console.log(chalk3.blue("\n\u{1F4CA} Process Definitions\n"));
1350
+ console.log(chalk4.blue("\n\u{1F4CA} Process Definitions\n"));
1196
1351
  for (const proc of processes) {
1197
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(proc.key)}`);
1198
- console.log(` ${chalk3.gray("ID:")} ${proc.id || "N/A"}`);
1199
- console.log(` ${chalk3.gray("Name:")} ${proc.name || "N/A"}`);
1200
- console.log(` ${chalk3.gray("Version:")} ${proc.version || "N/A"}`);
1201
- console.log(` ${chalk3.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
1352
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(proc.key)}`);
1353
+ console.log(` ${chalk4.gray("ID:")} ${proc.id || "N/A"}`);
1354
+ console.log(` ${chalk4.gray("Name:")} ${proc.name || "N/A"}`);
1355
+ console.log(` ${chalk4.gray("Version:")} ${proc.version || "N/A"}`);
1356
+ console.log(` ${chalk4.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
1202
1357
  console.log();
1203
1358
  }
1204
1359
  }
1205
1360
  });
1206
1361
  } catch (error) {
1207
- exitWithCommandError2(spinner, "Failed to fetch processes", error);
1362
+ exitWithCommandError3(spinner, "Failed to fetch processes", error);
1208
1363
  }
1209
1364
  }
1210
1365
  async function getProcessXml(client, options) {
@@ -1214,21 +1369,21 @@ async function getProcessXml(client, options) {
1214
1369
  const result = await bpmClient.getProcessXml(options.key);
1215
1370
  if (result.error) {
1216
1371
  spinner.fail("Failed to fetch process XML");
1217
- console.error(chalk3.red(result.error.message));
1372
+ console.error(chalk4.red(result.error.message));
1218
1373
  process.exit(1);
1219
1374
  }
1220
1375
  spinner.succeed("Process XML retrieved");
1221
1376
  renderOutput(result.data, {
1222
1377
  format: options.format,
1223
1378
  pretty: () => {
1224
- console.log(chalk3.blue(`
1379
+ console.log(chalk4.blue(`
1225
1380
  \u{1F4C4} BPMN XML: ${options.key}
1226
1381
  `));
1227
1382
  console.log(result.data?.bpmn20Xml || "");
1228
1383
  }
1229
1384
  });
1230
1385
  } catch (error) {
1231
- exitWithCommandError2(spinner, "Failed to fetch process XML", error);
1386
+ exitWithCommandError3(spinner, "Failed to fetch process XML", error);
1232
1387
  }
1233
1388
  }
1234
1389
  async function startProcess(client, options) {
@@ -1239,22 +1394,22 @@ async function startProcess(client, options) {
1239
1394
  const result = await bpmClient.startProcess(options.key, variables);
1240
1395
  if (result.error) {
1241
1396
  spinner.fail("Failed to start process");
1242
- console.error(chalk3.red(result.error.message));
1397
+ console.error(chalk4.red(result.error.message));
1243
1398
  process.exit(1);
1244
1399
  }
1245
1400
  spinner.succeed("Process started");
1246
1401
  renderOutput(result.data, {
1247
1402
  format: options.format,
1248
1403
  pretty: () => {
1249
- console.log(chalk3.green("\nProcess Instance:"));
1250
- console.log(` ${chalk3.bold("ID:")} ${result.data?.id}`);
1251
- console.log(` ${chalk3.bold("Definition ID:")} ${result.data?.definitionId}`);
1252
- console.log(` ${chalk3.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
1253
- console.log(` ${chalk3.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
1404
+ console.log(chalk4.green("\nProcess Instance:"));
1405
+ console.log(` ${chalk4.bold("ID:")} ${result.data?.id}`);
1406
+ console.log(` ${chalk4.bold("Definition ID:")} ${result.data?.definitionId}`);
1407
+ console.log(` ${chalk4.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
1408
+ console.log(` ${chalk4.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
1254
1409
  }
1255
1410
  });
1256
1411
  } catch (error) {
1257
- exitWithCommandError2(spinner, "Failed to start process", error);
1412
+ exitWithCommandError3(spinner, "Failed to start process", error);
1258
1413
  }
1259
1414
  }
1260
1415
  async function listProcessInstances(client, options = {}) {
@@ -1265,7 +1420,7 @@ async function listProcessInstances(client, options = {}) {
1265
1420
  const result = await bpmClient.getProcessInstances(params);
1266
1421
  if (result.error) {
1267
1422
  spinner.fail("Failed to fetch process instances");
1268
- console.error(chalk3.red(result.error.message));
1423
+ console.error(chalk4.red(result.error.message));
1269
1424
  process.exit(1);
1270
1425
  }
1271
1426
  spinner.succeed(`Found ${result.data?.length || 0} process instances`);
@@ -1273,20 +1428,20 @@ async function listProcessInstances(client, options = {}) {
1273
1428
  renderOutput(instances, {
1274
1429
  format: options.format,
1275
1430
  pretty: () => {
1276
- console.log(chalk3.blue("\n\u{1F504} Process Instances\n"));
1431
+ console.log(chalk4.blue("\n\u{1F504} Process Instances\n"));
1277
1432
  for (const instance of instances) {
1278
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(instance.id)}`);
1279
- console.log(` ${chalk3.gray("Definition:")} ${instance.definitionId || "N/A"}`);
1280
- console.log(` ${chalk3.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
1433
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(instance.id)}`);
1434
+ console.log(` ${chalk4.gray("Definition:")} ${instance.definitionId || "N/A"}`);
1435
+ console.log(` ${chalk4.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
1281
1436
  console.log(
1282
- ` ${chalk3.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
1437
+ ` ${chalk4.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
1283
1438
  );
1284
1439
  console.log();
1285
1440
  }
1286
1441
  }
1287
1442
  });
1288
1443
  } catch (error) {
1289
- exitWithCommandError2(spinner, "Failed to fetch process instances", error);
1444
+ exitWithCommandError3(spinner, "Failed to fetch process instances", error);
1290
1445
  }
1291
1446
  }
1292
1447
  async function getProcessInstance(client, options) {
@@ -1296,19 +1451,19 @@ async function getProcessInstance(client, options) {
1296
1451
  const result = await bpmClient.getProcessInstance(options.id);
1297
1452
  if (result.error) {
1298
1453
  spinner.fail("Failed to fetch process instance");
1299
- console.error(chalk3.red(result.error.message));
1454
+ console.error(chalk4.red(result.error.message));
1300
1455
  process.exit(1);
1301
1456
  }
1302
1457
  spinner.succeed("Process instance retrieved");
1303
1458
  renderOutput(result.data, {
1304
1459
  format: options.format,
1305
1460
  pretty: () => {
1306
- console.log(chalk3.blue("\n\u{1F4CA} Process Instance\n"));
1461
+ console.log(chalk4.blue("\n\u{1F4CA} Process Instance\n"));
1307
1462
  console.log(JSON.stringify(result.data, null, 2));
1308
1463
  }
1309
1464
  });
1310
1465
  } catch (error) {
1311
- exitWithCommandError2(spinner, "Failed to fetch process instance", error);
1466
+ exitWithCommandError3(spinner, "Failed to fetch process instance", error);
1312
1467
  }
1313
1468
  }
1314
1469
  async function getActivityInstanceTree(client, options) {
@@ -1318,19 +1473,19 @@ async function getActivityInstanceTree(client, options) {
1318
1473
  const result = await bpmClient.getActivityInstanceTree(options.id);
1319
1474
  if (result.error) {
1320
1475
  spinner.fail("Failed to fetch activity instance tree");
1321
- console.error(chalk3.red(result.error.message));
1476
+ console.error(chalk4.red(result.error.message));
1322
1477
  process.exit(1);
1323
1478
  }
1324
1479
  spinner.succeed("Activity instance tree retrieved");
1325
1480
  renderOutput(result.data, {
1326
1481
  format: options.format,
1327
1482
  pretty: () => {
1328
- console.log(chalk3.blue("\n\u{1F333} Activity Instance Tree\n"));
1483
+ console.log(chalk4.blue("\n\u{1F333} Activity Instance Tree\n"));
1329
1484
  console.log(JSON.stringify(result.data, null, 2));
1330
1485
  }
1331
1486
  });
1332
1487
  } catch (error) {
1333
- exitWithCommandError2(spinner, "Failed to fetch activity instance tree", error);
1488
+ exitWithCommandError3(spinner, "Failed to fetch activity instance tree", error);
1334
1489
  }
1335
1490
  }
1336
1491
  async function getActiveActivities(client, options) {
@@ -1340,7 +1495,7 @@ async function getActiveActivities(client, options) {
1340
1495
  const result = await bpmClient.getActiveActivities(options.id);
1341
1496
  if (result.error) {
1342
1497
  spinner.fail("Failed to fetch active activities");
1343
- console.error(chalk3.red(result.error.message));
1498
+ console.error(chalk4.red(result.error.message));
1344
1499
  process.exit(1);
1345
1500
  }
1346
1501
  const activities = Array.isArray(result.data) ? result.data : [];
@@ -1348,12 +1503,12 @@ async function getActiveActivities(client, options) {
1348
1503
  renderOutput(result.data, {
1349
1504
  format: options.format,
1350
1505
  pretty: () => {
1351
- console.log(chalk3.blue("\n\u26A1 Active Activities\n"));
1506
+ console.log(chalk4.blue("\n\u26A1 Active Activities\n"));
1352
1507
  console.log(JSON.stringify(result.data, null, 2));
1353
1508
  }
1354
1509
  });
1355
1510
  } catch (error) {
1356
- exitWithCommandError2(spinner, "Failed to fetch active activities", error);
1511
+ exitWithCommandError3(spinner, "Failed to fetch active activities", error);
1357
1512
  }
1358
1513
  }
1359
1514
  async function getRuntimeVariables(client, options) {
@@ -1363,19 +1518,19 @@ async function getRuntimeVariables(client, options) {
1363
1518
  const result = await bpmClient.getRuntimeVariables(options.id);
1364
1519
  if (result.error) {
1365
1520
  spinner.fail("Failed to fetch runtime variables");
1366
- console.error(chalk3.red(result.error.message));
1521
+ console.error(chalk4.red(result.error.message));
1367
1522
  process.exit(1);
1368
1523
  }
1369
1524
  spinner.succeed("Runtime variables retrieved");
1370
1525
  renderOutput(result.data, {
1371
1526
  format: options.format,
1372
1527
  pretty: () => {
1373
- console.log(chalk3.blue("\n\u{1F9EE} Runtime Variables\n"));
1528
+ console.log(chalk4.blue("\n\u{1F9EE} Runtime Variables\n"));
1374
1529
  console.log(JSON.stringify(result.data, null, 2));
1375
1530
  }
1376
1531
  });
1377
1532
  } catch (error) {
1378
- exitWithCommandError2(spinner, "Failed to fetch runtime variables", error);
1533
+ exitWithCommandError3(spinner, "Failed to fetch runtime variables", error);
1379
1534
  }
1380
1535
  }
1381
1536
  async function getProcessVariables(client, options) {
@@ -1388,19 +1543,19 @@ async function getProcessVariables(client, options) {
1388
1543
  });
1389
1544
  if (result.error) {
1390
1545
  spinner.fail("Failed to fetch process variables");
1391
- console.error(chalk3.red(result.error.message));
1546
+ console.error(chalk4.red(result.error.message));
1392
1547
  process.exit(1);
1393
1548
  }
1394
1549
  spinner.succeed(`Found ${result.data?.length || 0} variables`);
1395
1550
  renderOutput(result.data || [], {
1396
1551
  format: options.format,
1397
1552
  pretty: () => {
1398
- console.log(chalk3.blue("\n\u{1F9FE} Process Variables\n"));
1553
+ console.log(chalk4.blue("\n\u{1F9FE} Process Variables\n"));
1399
1554
  console.log(JSON.stringify(result.data || [], null, 2));
1400
1555
  }
1401
1556
  });
1402
1557
  } catch (error) {
1403
- exitWithCommandError2(spinner, "Failed to fetch process variables", error);
1558
+ exitWithCommandError3(spinner, "Failed to fetch process variables", error);
1404
1559
  }
1405
1560
  }
1406
1561
  async function deleteProcessInstance(client, options) {
@@ -1412,7 +1567,7 @@ async function deleteProcessInstance(client, options) {
1412
1567
  });
1413
1568
  if (result.error) {
1414
1569
  spinner.fail("Failed to delete process instance");
1415
- console.error(chalk3.red(result.error.message));
1570
+ console.error(chalk4.red(result.error.message));
1416
1571
  process.exit(1);
1417
1572
  }
1418
1573
  spinner.succeed("Process instance deleted");
@@ -1425,12 +1580,12 @@ async function deleteProcessInstance(client, options) {
1425
1580
  {
1426
1581
  format: options.format,
1427
1582
  pretty: () => {
1428
- console.log(chalk3.green(`Deleted process instance: ${options.id}`));
1583
+ console.log(chalk4.green(`Deleted process instance: ${options.id}`));
1429
1584
  }
1430
1585
  }
1431
1586
  );
1432
1587
  } catch (error) {
1433
- exitWithCommandError2(spinner, "Failed to delete process instance", error);
1588
+ exitWithCommandError3(spinner, "Failed to delete process instance", error);
1434
1589
  }
1435
1590
  }
1436
1591
  async function suspendProcessInstance(client, options) {
@@ -1440,7 +1595,7 @@ async function suspendProcessInstance(client, options) {
1440
1595
  const result = await bpmClient.suspendProcessInstance(options.id);
1441
1596
  if (result.error) {
1442
1597
  spinner.fail("Failed to suspend process instance");
1443
- console.error(chalk3.red(result.error.message));
1598
+ console.error(chalk4.red(result.error.message));
1444
1599
  process.exit(1);
1445
1600
  }
1446
1601
  spinner.succeed("Process instance suspended");
@@ -1452,12 +1607,12 @@ async function suspendProcessInstance(client, options) {
1452
1607
  {
1453
1608
  format: options.format,
1454
1609
  pretty: () => {
1455
- console.log(chalk3.green(`Suspended process instance: ${options.id}`));
1610
+ console.log(chalk4.green(`Suspended process instance: ${options.id}`));
1456
1611
  }
1457
1612
  }
1458
1613
  );
1459
1614
  } catch (error) {
1460
- exitWithCommandError2(spinner, "Failed to suspend process instance", error);
1615
+ exitWithCommandError3(spinner, "Failed to suspend process instance", error);
1461
1616
  }
1462
1617
  }
1463
1618
  async function activateProcessInstance(client, options) {
@@ -1467,7 +1622,7 @@ async function activateProcessInstance(client, options) {
1467
1622
  const result = await bpmClient.activateProcessInstance(options.id);
1468
1623
  if (result.error) {
1469
1624
  spinner.fail("Failed to activate process instance");
1470
- console.error(chalk3.red(result.error.message));
1625
+ console.error(chalk4.red(result.error.message));
1471
1626
  process.exit(1);
1472
1627
  }
1473
1628
  spinner.succeed("Process instance activated");
@@ -1479,12 +1634,12 @@ async function activateProcessInstance(client, options) {
1479
1634
  {
1480
1635
  format: options.format,
1481
1636
  pretty: () => {
1482
- console.log(chalk3.green(`Activated process instance: ${options.id}`));
1637
+ console.log(chalk4.green(`Activated process instance: ${options.id}`));
1483
1638
  }
1484
1639
  }
1485
1640
  );
1486
1641
  } catch (error) {
1487
- exitWithCommandError2(spinner, "Failed to activate process instance", error);
1642
+ exitWithCommandError3(spinner, "Failed to activate process instance", error);
1488
1643
  }
1489
1644
  }
1490
1645
  async function modifyProcessInstance(client, options) {
@@ -1499,7 +1654,7 @@ async function modifyProcessInstance(client, options) {
1499
1654
  const result = await bpmClient.modifyProcessInstance(options.id, modification);
1500
1655
  if (result.error) {
1501
1656
  spinner.fail("Failed to modify process instance");
1502
- console.error(chalk3.red(result.error.message));
1657
+ console.error(chalk4.red(result.error.message));
1503
1658
  process.exit(1);
1504
1659
  }
1505
1660
  spinner.succeed("Process instance modified");
@@ -1512,12 +1667,12 @@ async function modifyProcessInstance(client, options) {
1512
1667
  {
1513
1668
  format: options.format,
1514
1669
  pretty: () => {
1515
- console.log(chalk3.green(`Modified process instance: ${options.id}`));
1670
+ console.log(chalk4.green(`Modified process instance: ${options.id}`));
1516
1671
  }
1517
1672
  }
1518
1673
  );
1519
1674
  } catch (error) {
1520
- exitWithCommandError2(spinner, "Failed to modify process instance", error);
1675
+ exitWithCommandError3(spinner, "Failed to modify process instance", error);
1521
1676
  }
1522
1677
  }
1523
1678
  async function listTasks(client, options) {
@@ -1528,7 +1683,7 @@ async function listTasks(client, options) {
1528
1683
  const result = await bpmClient.getTasks(params);
1529
1684
  if (result.error) {
1530
1685
  spinner.fail("Failed to fetch tasks");
1531
- console.error(chalk3.red(result.error.message));
1686
+ console.error(chalk4.red(result.error.message));
1532
1687
  process.exit(1);
1533
1688
  }
1534
1689
  spinner.succeed(`Found ${result.data?.length || 0} tasks`);
@@ -1536,19 +1691,19 @@ async function listTasks(client, options) {
1536
1691
  renderOutput(tasks, {
1537
1692
  format: options.format,
1538
1693
  pretty: () => {
1539
- console.log(chalk3.blue("\n\u{1F4DD} Tasks\n"));
1694
+ console.log(chalk4.blue("\n\u{1F4DD} Tasks\n"));
1540
1695
  for (const task of tasks) {
1541
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(task.name || task.id)}`);
1542
- console.log(` ${chalk3.gray("ID:")} ${task.id}`);
1543
- console.log(` ${chalk3.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
1544
- console.log(` ${chalk3.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
1545
- console.log(` ${chalk3.gray("Created:")} ${task.created || "N/A"}`);
1696
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(task.name || task.id)}`);
1697
+ console.log(` ${chalk4.gray("ID:")} ${task.id}`);
1698
+ console.log(` ${chalk4.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
1699
+ console.log(` ${chalk4.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
1700
+ console.log(` ${chalk4.gray("Created:")} ${task.created || "N/A"}`);
1546
1701
  console.log();
1547
1702
  }
1548
1703
  }
1549
1704
  });
1550
1705
  } catch (error) {
1551
- exitWithCommandError2(spinner, "Failed to fetch tasks", error);
1706
+ exitWithCommandError3(spinner, "Failed to fetch tasks", error);
1552
1707
  }
1553
1708
  }
1554
1709
  async function getTask(client, options) {
@@ -1558,19 +1713,19 @@ async function getTask(client, options) {
1558
1713
  const result = await bpmClient.getTask(options.id);
1559
1714
  if (result.error) {
1560
1715
  spinner.fail("Failed to fetch task");
1561
- console.error(chalk3.red(result.error.message));
1716
+ console.error(chalk4.red(result.error.message));
1562
1717
  process.exit(1);
1563
1718
  }
1564
1719
  spinner.succeed("Task retrieved");
1565
1720
  renderOutput(result.data, {
1566
1721
  format: options.format,
1567
1722
  pretty: () => {
1568
- console.log(chalk3.blue("\n\u{1F4DD} Task\n"));
1723
+ console.log(chalk4.blue("\n\u{1F4DD} Task\n"));
1569
1724
  console.log(JSON.stringify(result.data, null, 2));
1570
1725
  }
1571
1726
  });
1572
1727
  } catch (error) {
1573
- exitWithCommandError2(spinner, "Failed to fetch task", error);
1728
+ exitWithCommandError3(spinner, "Failed to fetch task", error);
1574
1729
  }
1575
1730
  }
1576
1731
  async function getTaskCount(client, options) {
@@ -1581,18 +1736,18 @@ async function getTaskCount(client, options) {
1581
1736
  const result = await bpmClient.getTaskCount(params);
1582
1737
  if (result.error) {
1583
1738
  spinner.fail("Failed to fetch task count");
1584
- console.error(chalk3.red(result.error.message));
1739
+ console.error(chalk4.red(result.error.message));
1585
1740
  process.exit(1);
1586
1741
  }
1587
1742
  spinner.succeed("Task count retrieved");
1588
1743
  renderOutput(result.data, {
1589
1744
  format: options.format,
1590
1745
  pretty: () => {
1591
- console.log(chalk3.green(`Task count: ${result.data?.count ?? 0}`));
1746
+ console.log(chalk4.green(`Task count: ${result.data?.count ?? 0}`));
1592
1747
  }
1593
1748
  });
1594
1749
  } catch (error) {
1595
- exitWithCommandError2(spinner, "Failed to fetch task count", error);
1750
+ exitWithCommandError3(spinner, "Failed to fetch task count", error);
1596
1751
  }
1597
1752
  }
1598
1753
  async function completeTask(client, options) {
@@ -1603,7 +1758,7 @@ async function completeTask(client, options) {
1603
1758
  const result = await bpmClient.completeTask(options.id, variables);
1604
1759
  if (result.error) {
1605
1760
  spinner.fail("Failed to complete task");
1606
- console.error(chalk3.red(result.error.message));
1761
+ console.error(chalk4.red(result.error.message));
1607
1762
  process.exit(1);
1608
1763
  }
1609
1764
  spinner.succeed("Task completed");
@@ -1615,12 +1770,12 @@ async function completeTask(client, options) {
1615
1770
  {
1616
1771
  format: options.format,
1617
1772
  pretty: () => {
1618
- console.log(chalk3.green(`Completed task: ${options.id}`));
1773
+ console.log(chalk4.green(`Completed task: ${options.id}`));
1619
1774
  }
1620
1775
  }
1621
1776
  );
1622
1777
  } catch (error) {
1623
- exitWithCommandError2(spinner, "Failed to complete task", error);
1778
+ exitWithCommandError3(spinner, "Failed to complete task", error);
1624
1779
  }
1625
1780
  }
1626
1781
  async function delegateTask(client, options) {
@@ -1630,7 +1785,7 @@ async function delegateTask(client, options) {
1630
1785
  const result = await bpmClient.delegateTask(options.id, options.userId);
1631
1786
  if (result.error) {
1632
1787
  spinner.fail("Failed to delegate task");
1633
- console.error(chalk3.red(result.error.message));
1788
+ console.error(chalk4.red(result.error.message));
1634
1789
  process.exit(1);
1635
1790
  }
1636
1791
  spinner.succeed("Task delegated");
@@ -1643,12 +1798,12 @@ async function delegateTask(client, options) {
1643
1798
  {
1644
1799
  format: options.format,
1645
1800
  pretty: () => {
1646
- console.log(chalk3.green(`Delegated task ${options.id} to ${options.userId}`));
1801
+ console.log(chalk4.green(`Delegated task ${options.id} to ${options.userId}`));
1647
1802
  }
1648
1803
  }
1649
1804
  );
1650
1805
  } catch (error) {
1651
- exitWithCommandError2(spinner, "Failed to delegate task", error);
1806
+ exitWithCommandError3(spinner, "Failed to delegate task", error);
1652
1807
  }
1653
1808
  }
1654
1809
  async function getTaskForm(client, options) {
@@ -1658,19 +1813,19 @@ async function getTaskForm(client, options) {
1658
1813
  const result = await bpmClient.getTaskForm(options.id);
1659
1814
  if (result.error) {
1660
1815
  spinner.fail("Failed to fetch task form");
1661
- console.error(chalk3.red(result.error.message));
1816
+ console.error(chalk4.red(result.error.message));
1662
1817
  process.exit(1);
1663
1818
  }
1664
1819
  spinner.succeed("Task form retrieved");
1665
1820
  renderOutput(result.data, {
1666
1821
  format: options.format,
1667
1822
  pretty: () => {
1668
- console.log(chalk3.blue("\n\u{1F9E9} Task Form\n"));
1823
+ console.log(chalk4.blue("\n\u{1F9E9} Task Form\n"));
1669
1824
  console.log(JSON.stringify(result.data, null, 2));
1670
1825
  }
1671
1826
  });
1672
1827
  } catch (error) {
1673
- exitWithCommandError2(spinner, "Failed to fetch task form", error);
1828
+ exitWithCommandError3(spinner, "Failed to fetch task form", error);
1674
1829
  }
1675
1830
  }
1676
1831
  async function getTaskFormSchema(client, options) {
@@ -1693,12 +1848,12 @@ async function getTaskFormSchema(client, options) {
1693
1848
  renderOutput(result.data, {
1694
1849
  format: options.format,
1695
1850
  pretty: () => {
1696
- console.log(chalk3.blue("\n\u{1F9E9} Task Form Schema\n"));
1851
+ console.log(chalk4.blue("\n\u{1F9E9} Task Form Schema\n"));
1697
1852
  console.log(JSON.stringify(result.data, null, 2));
1698
1853
  }
1699
1854
  });
1700
1855
  } catch (error) {
1701
- exitWithCommandError2(spinner, "Failed to fetch task form schema", error);
1856
+ exitWithCommandError3(spinner, "Failed to fetch task form schema", error);
1702
1857
  }
1703
1858
  }
1704
1859
  async function getTaskFormVariables(client, options) {
@@ -1708,19 +1863,19 @@ async function getTaskFormVariables(client, options) {
1708
1863
  const result = await bpmClient.getTaskFormVariables(options.id);
1709
1864
  if (result.error) {
1710
1865
  spinner.fail("Failed to fetch task form variables");
1711
- console.error(chalk3.red(result.error.message));
1866
+ console.error(chalk4.red(result.error.message));
1712
1867
  process.exit(1);
1713
1868
  }
1714
1869
  spinner.succeed("Task form variables retrieved");
1715
1870
  renderOutput(result.data, {
1716
1871
  format: options.format,
1717
1872
  pretty: () => {
1718
- console.log(chalk3.blue("\n\u{1F9EE} Task Form Variables\n"));
1873
+ console.log(chalk4.blue("\n\u{1F9EE} Task Form Variables\n"));
1719
1874
  console.log(JSON.stringify(result.data, null, 2));
1720
1875
  }
1721
1876
  });
1722
1877
  } catch (error) {
1723
- exitWithCommandError2(spinner, "Failed to fetch task form variables", error);
1878
+ exitWithCommandError3(spinner, "Failed to fetch task form variables", error);
1724
1879
  }
1725
1880
  }
1726
1881
  async function getTaskRenderedForm(client, options) {
@@ -1730,19 +1885,19 @@ async function getTaskRenderedForm(client, options) {
1730
1885
  const result = await bpmClient.getTaskRenderedForm(options.id);
1731
1886
  if (result.error) {
1732
1887
  spinner.fail("Failed to fetch rendered task form");
1733
- console.error(chalk3.red(result.error.message));
1888
+ console.error(chalk4.red(result.error.message));
1734
1889
  process.exit(1);
1735
1890
  }
1736
1891
  spinner.succeed("Rendered task form retrieved");
1737
1892
  renderOutput(result.data, {
1738
1893
  format: options.format,
1739
1894
  pretty: () => {
1740
- console.log(chalk3.blue("\n\u{1F9FE} Rendered Task Form\n"));
1895
+ console.log(chalk4.blue("\n\u{1F9FE} Rendered Task Form\n"));
1741
1896
  console.log(result.data || "");
1742
1897
  }
1743
1898
  });
1744
1899
  } catch (error) {
1745
- exitWithCommandError2(spinner, "Failed to fetch rendered task form", error);
1900
+ exitWithCommandError3(spinner, "Failed to fetch rendered task form", error);
1746
1901
  }
1747
1902
  }
1748
1903
  async function getTaskDeployedForm(client, options) {
@@ -1752,19 +1907,19 @@ async function getTaskDeployedForm(client, options) {
1752
1907
  const result = await bpmClient.getTaskDeployedForm(options.id);
1753
1908
  if (result.error) {
1754
1909
  spinner.fail("Failed to fetch deployed task form");
1755
- console.error(chalk3.red(result.error.message));
1910
+ console.error(chalk4.red(result.error.message));
1756
1911
  process.exit(1);
1757
1912
  }
1758
1913
  spinner.succeed("Deployed task form retrieved");
1759
1914
  renderOutput(result.data, {
1760
1915
  format: options.format,
1761
1916
  pretty: () => {
1762
- console.log(chalk3.blue("\n\u{1F9FE} Deployed Task Form\n"));
1917
+ console.log(chalk4.blue("\n\u{1F9FE} Deployed Task Form\n"));
1763
1918
  console.log(JSON.stringify(result.data, null, 2));
1764
1919
  }
1765
1920
  });
1766
1921
  } catch (error) {
1767
- exitWithCommandError2(spinner, "Failed to fetch deployed task form", error);
1922
+ exitWithCommandError3(spinner, "Failed to fetch deployed task form", error);
1768
1923
  }
1769
1924
  }
1770
1925
  async function getStartFormInfo(client, options) {
@@ -1784,12 +1939,12 @@ async function getStartFormInfo(client, options) {
1784
1939
  renderOutput(result.data, {
1785
1940
  format: options.format,
1786
1941
  pretty: () => {
1787
- console.log(chalk3.blue("\n\u{1F680} Start Form Info\n"));
1942
+ console.log(chalk4.blue("\n\u{1F680} Start Form Info\n"));
1788
1943
  console.log(JSON.stringify(result.data, null, 2));
1789
1944
  }
1790
1945
  });
1791
1946
  } catch (error) {
1792
- exitWithCommandError2(spinner, "Failed to fetch start form info", error);
1947
+ exitWithCommandError3(spinner, "Failed to fetch start form info", error);
1793
1948
  }
1794
1949
  }
1795
1950
  async function getStartFormVariables(client, options) {
@@ -1809,12 +1964,12 @@ async function getStartFormVariables(client, options) {
1809
1964
  renderOutput(result.data, {
1810
1965
  format: options.format,
1811
1966
  pretty: () => {
1812
- console.log(chalk3.blue("\n\u{1F680} Start Form Variables\n"));
1967
+ console.log(chalk4.blue("\n\u{1F680} Start Form Variables\n"));
1813
1968
  console.log(JSON.stringify(result.data, null, 2));
1814
1969
  }
1815
1970
  });
1816
1971
  } catch (error) {
1817
- exitWithCommandError2(spinner, "Failed to fetch start form variables", error);
1972
+ exitWithCommandError3(spinner, "Failed to fetch start form variables", error);
1818
1973
  }
1819
1974
  }
1820
1975
  async function getDeployedStartForm(client, options) {
@@ -1834,12 +1989,12 @@ async function getDeployedStartForm(client, options) {
1834
1989
  renderOutput(result.data, {
1835
1990
  format: options.format,
1836
1991
  pretty: () => {
1837
- console.log(chalk3.blue("\n\u{1F680} Deployed Start Form\n"));
1992
+ console.log(chalk4.blue("\n\u{1F680} Deployed Start Form\n"));
1838
1993
  console.log(JSON.stringify(result.data, null, 2));
1839
1994
  }
1840
1995
  });
1841
1996
  } catch (error) {
1842
- exitWithCommandError2(spinner, "Failed to fetch deployed start form", error);
1997
+ exitWithCommandError3(spinner, "Failed to fetch deployed start form", error);
1843
1998
  }
1844
1999
  }
1845
2000
  async function listHistoryTasks(client, options = {}) {
@@ -1850,7 +2005,7 @@ async function listHistoryTasks(client, options = {}) {
1850
2005
  const result = await bpmClient.getHistoryTasks(params);
1851
2006
  if (result.error) {
1852
2007
  spinner.fail("Failed to fetch history tasks");
1853
- console.error(chalk3.red(result.error.message));
2008
+ console.error(chalk4.red(result.error.message));
1854
2009
  process.exit(1);
1855
2010
  }
1856
2011
  const tasks = result.data || [];
@@ -1858,12 +2013,12 @@ async function listHistoryTasks(client, options = {}) {
1858
2013
  renderOutput(tasks, {
1859
2014
  format: options.format,
1860
2015
  pretty: () => {
1861
- console.log(chalk3.blue("\n\u{1F4DA} History Tasks\n"));
2016
+ console.log(chalk4.blue("\n\u{1F4DA} History Tasks\n"));
1862
2017
  console.log(JSON.stringify(tasks, null, 2));
1863
2018
  }
1864
2019
  });
1865
2020
  } catch (error) {
1866
- exitWithCommandError2(spinner, "Failed to fetch history tasks", error);
2021
+ exitWithCommandError3(spinner, "Failed to fetch history tasks", error);
1867
2022
  }
1868
2023
  }
1869
2024
  async function getHistoryTaskCount(client, options = {}) {
@@ -1874,18 +2029,18 @@ async function getHistoryTaskCount(client, options = {}) {
1874
2029
  const result = await bpmClient.getHistoryTaskCount(params);
1875
2030
  if (result.error) {
1876
2031
  spinner.fail("Failed to fetch history task count");
1877
- console.error(chalk3.red(result.error.message));
2032
+ console.error(chalk4.red(result.error.message));
1878
2033
  process.exit(1);
1879
2034
  }
1880
2035
  spinner.succeed("History task count retrieved");
1881
2036
  renderOutput(result.data, {
1882
2037
  format: options.format,
1883
2038
  pretty: () => {
1884
- console.log(chalk3.green(`History task count: ${result.data?.count ?? 0}`));
2039
+ console.log(chalk4.green(`History task count: ${result.data?.count ?? 0}`));
1885
2040
  }
1886
2041
  });
1887
2042
  } catch (error) {
1888
- exitWithCommandError2(spinner, "Failed to fetch history task count", error);
2043
+ exitWithCommandError3(spinner, "Failed to fetch history task count", error);
1889
2044
  }
1890
2045
  }
1891
2046
  async function listHistoryProcessInstances(client, options = {}) {
@@ -1896,7 +2051,7 @@ async function listHistoryProcessInstances(client, options = {}) {
1896
2051
  const result = await bpmClient.getHistoryProcessInstances(params);
1897
2052
  if (result.error) {
1898
2053
  spinner.fail("Failed to fetch history process instances");
1899
- console.error(chalk3.red(result.error.message));
2054
+ console.error(chalk4.red(result.error.message));
1900
2055
  process.exit(1);
1901
2056
  }
1902
2057
  const instances = result.data || [];
@@ -1904,12 +2059,12 @@ async function listHistoryProcessInstances(client, options = {}) {
1904
2059
  renderOutput(instances, {
1905
2060
  format: options.format,
1906
2061
  pretty: () => {
1907
- console.log(chalk3.blue("\n\u{1F4DA} History Process Instances\n"));
2062
+ console.log(chalk4.blue("\n\u{1F4DA} History Process Instances\n"));
1908
2063
  console.log(JSON.stringify(instances, null, 2));
1909
2064
  }
1910
2065
  });
1911
2066
  } catch (error) {
1912
- exitWithCommandError2(spinner, "Failed to fetch history process instances", error);
2067
+ exitWithCommandError3(spinner, "Failed to fetch history process instances", error);
1913
2068
  }
1914
2069
  }
1915
2070
  async function getHistoryProcessInstanceCount(client, options = {}) {
@@ -1920,18 +2075,18 @@ async function getHistoryProcessInstanceCount(client, options = {}) {
1920
2075
  const result = await bpmClient.getHistoryProcessInstanceCount(params);
1921
2076
  if (result.error) {
1922
2077
  spinner.fail("Failed to fetch history process instance count");
1923
- console.error(chalk3.red(result.error.message));
2078
+ console.error(chalk4.red(result.error.message));
1924
2079
  process.exit(1);
1925
2080
  }
1926
2081
  spinner.succeed("History process instance count retrieved");
1927
2082
  renderOutput(result.data, {
1928
2083
  format: options.format,
1929
2084
  pretty: () => {
1930
- console.log(chalk3.green(`History process instance count: ${result.data?.count ?? 0}`));
2085
+ console.log(chalk4.green(`History process instance count: ${result.data?.count ?? 0}`));
1931
2086
  }
1932
2087
  });
1933
2088
  } catch (error) {
1934
- exitWithCommandError2(spinner, "Failed to fetch history process instance count", error);
2089
+ exitWithCommandError3(spinner, "Failed to fetch history process instance count", error);
1935
2090
  }
1936
2091
  }
1937
2092
  async function getHistoryProcessInstance(client, options) {
@@ -1941,19 +2096,19 @@ async function getHistoryProcessInstance(client, options) {
1941
2096
  const result = await bpmClient.getHistoryProcessInstance(options.id);
1942
2097
  if (result.error) {
1943
2098
  spinner.fail("Failed to fetch history process instance");
1944
- console.error(chalk3.red(result.error.message));
2099
+ console.error(chalk4.red(result.error.message));
1945
2100
  process.exit(1);
1946
2101
  }
1947
2102
  spinner.succeed("History process instance retrieved");
1948
2103
  renderOutput(result.data, {
1949
2104
  format: options.format,
1950
2105
  pretty: () => {
1951
- console.log(chalk3.blue("\n\u{1F4DA} History Process Instance\n"));
2106
+ console.log(chalk4.blue("\n\u{1F4DA} History Process Instance\n"));
1952
2107
  console.log(JSON.stringify(result.data, null, 2));
1953
2108
  }
1954
2109
  });
1955
2110
  } catch (error) {
1956
- exitWithCommandError2(spinner, "Failed to fetch history process instance", error);
2111
+ exitWithCommandError3(spinner, "Failed to fetch history process instance", error);
1957
2112
  }
1958
2113
  }
1959
2114
  async function listHistoryActivityInstances(client, options = {}) {
@@ -1964,7 +2119,7 @@ async function listHistoryActivityInstances(client, options = {}) {
1964
2119
  const result = await bpmClient.getHistoryActivityInstances(params);
1965
2120
  if (result.error) {
1966
2121
  spinner.fail("Failed to fetch history activity instances");
1967
- console.error(chalk3.red(result.error.message));
2122
+ console.error(chalk4.red(result.error.message));
1968
2123
  process.exit(1);
1969
2124
  }
1970
2125
  const activities = result.data || [];
@@ -1972,12 +2127,12 @@ async function listHistoryActivityInstances(client, options = {}) {
1972
2127
  renderOutput(activities, {
1973
2128
  format: options.format,
1974
2129
  pretty: () => {
1975
- console.log(chalk3.blue("\n\u{1F4DA} History Activity Instances\n"));
2130
+ console.log(chalk4.blue("\n\u{1F4DA} History Activity Instances\n"));
1976
2131
  console.log(JSON.stringify(activities, null, 2));
1977
2132
  }
1978
2133
  });
1979
2134
  } catch (error) {
1980
- exitWithCommandError2(spinner, "Failed to fetch history activity instances", error);
2135
+ exitWithCommandError3(spinner, "Failed to fetch history activity instances", error);
1981
2136
  }
1982
2137
  }
1983
2138
  async function listHistoryVariableInstances(client, options = {}) {
@@ -1988,7 +2143,7 @@ async function listHistoryVariableInstances(client, options = {}) {
1988
2143
  const result = await bpmClient.getHistoryVariableInstances(params);
1989
2144
  if (result.error) {
1990
2145
  spinner.fail("Failed to fetch history variable instances");
1991
- console.error(chalk3.red(result.error.message));
2146
+ console.error(chalk4.red(result.error.message));
1992
2147
  process.exit(1);
1993
2148
  }
1994
2149
  const variables = result.data || [];
@@ -1996,12 +2151,12 @@ async function listHistoryVariableInstances(client, options = {}) {
1996
2151
  renderOutput(variables, {
1997
2152
  format: options.format,
1998
2153
  pretty: () => {
1999
- console.log(chalk3.blue("\n\u{1F4DA} History Variable Instances\n"));
2154
+ console.log(chalk4.blue("\n\u{1F4DA} History Variable Instances\n"));
2000
2155
  console.log(JSON.stringify(variables, null, 2));
2001
2156
  }
2002
2157
  });
2003
2158
  } catch (error) {
2004
- exitWithCommandError2(spinner, "Failed to fetch history variable instances", error);
2159
+ exitWithCommandError3(spinner, "Failed to fetch history variable instances", error);
2005
2160
  }
2006
2161
  }
2007
2162
  async function listUserOperationLogs(client, options = {}) {
@@ -2012,7 +2167,7 @@ async function listUserOperationLogs(client, options = {}) {
2012
2167
  const result = await bpmClient.getUserOperationLogs(params);
2013
2168
  if (result.error) {
2014
2169
  spinner.fail("Failed to fetch user operation logs");
2015
- console.error(chalk3.red(result.error.message));
2170
+ console.error(chalk4.red(result.error.message));
2016
2171
  process.exit(1);
2017
2172
  }
2018
2173
  const logs = result.data || [];
@@ -2020,12 +2175,12 @@ async function listUserOperationLogs(client, options = {}) {
2020
2175
  renderOutput(logs, {
2021
2176
  format: options.format,
2022
2177
  pretty: () => {
2023
- console.log(chalk3.blue("\n\u{1F4DA} User Operation Logs\n"));
2178
+ console.log(chalk4.blue("\n\u{1F4DA} User Operation Logs\n"));
2024
2179
  console.log(JSON.stringify(logs, null, 2));
2025
2180
  }
2026
2181
  });
2027
2182
  } catch (error) {
2028
- exitWithCommandError2(spinner, "Failed to fetch user operation logs", error);
2183
+ exitWithCommandError3(spinner, "Failed to fetch user operation logs", error);
2029
2184
  }
2030
2185
  }
2031
2186
  async function deleteHistoryProcessInstance(client, options) {
@@ -2035,7 +2190,7 @@ async function deleteHistoryProcessInstance(client, options) {
2035
2190
  const result = await bpmClient.deleteHistoryProcessInstance(options.id);
2036
2191
  if (result.error) {
2037
2192
  spinner.fail("Failed to delete history process instance");
2038
- console.error(chalk3.red(result.error.message));
2193
+ console.error(chalk4.red(result.error.message));
2039
2194
  process.exit(1);
2040
2195
  }
2041
2196
  spinner.succeed("History process instance deleted");
@@ -2047,12 +2202,12 @@ async function deleteHistoryProcessInstance(client, options) {
2047
2202
  {
2048
2203
  format: options.format,
2049
2204
  pretty: () => {
2050
- console.log(chalk3.green(`Deleted history process instance: ${options.id}`));
2205
+ console.log(chalk4.green(`Deleted history process instance: ${options.id}`));
2051
2206
  }
2052
2207
  }
2053
2208
  );
2054
2209
  } catch (error) {
2055
- exitWithCommandError2(spinner, "Failed to delete history process instance", error);
2210
+ exitWithCommandError3(spinner, "Failed to delete history process instance", error);
2056
2211
  }
2057
2212
  }
2058
2213
  async function listRoles(client, options = {}) {
@@ -2062,7 +2217,7 @@ async function listRoles(client, options = {}) {
2062
2217
  const result = await bpmClient.getRoles();
2063
2218
  if (result.error) {
2064
2219
  spinner.fail("Failed to fetch roles");
2065
- console.error(chalk3.red(result.error.message));
2220
+ console.error(chalk4.red(result.error.message));
2066
2221
  process.exit(1);
2067
2222
  }
2068
2223
  const roles = result.data || [];
@@ -2070,12 +2225,12 @@ async function listRoles(client, options = {}) {
2070
2225
  renderOutput(roles, {
2071
2226
  format: options.format,
2072
2227
  pretty: () => {
2073
- console.log(chalk3.blue("\n\u{1F465} Roles\n"));
2228
+ console.log(chalk4.blue("\n\u{1F465} Roles\n"));
2074
2229
  console.log(JSON.stringify(roles, null, 2));
2075
2230
  }
2076
2231
  });
2077
2232
  } catch (error) {
2078
- exitWithCommandError2(spinner, "Failed to fetch roles", error);
2233
+ exitWithCommandError3(spinner, "Failed to fetch roles", error);
2079
2234
  }
2080
2235
  }
2081
2236
  async function getUserRoles(client, options) {
@@ -2085,7 +2240,7 @@ async function getUserRoles(client, options) {
2085
2240
  const result = await bpmClient.getUserRoles(options.userId);
2086
2241
  if (result.error) {
2087
2242
  spinner.fail("Failed to fetch user roles");
2088
- console.error(chalk3.red(result.error.message));
2243
+ console.error(chalk4.red(result.error.message));
2089
2244
  process.exit(1);
2090
2245
  }
2091
2246
  const roles = result.data || [];
@@ -2093,17 +2248,19 @@ async function getUserRoles(client, options) {
2093
2248
  renderOutput(roles, {
2094
2249
  format: options.format,
2095
2250
  pretty: () => {
2096
- console.log(chalk3.blue(`
2251
+ console.log(chalk4.blue(`
2097
2252
  \u{1F464} User Roles: ${options.userId}
2098
2253
  `));
2099
2254
  console.log(JSON.stringify(roles, null, 2));
2100
2255
  }
2101
2256
  });
2102
2257
  } catch (error) {
2103
- exitWithCommandError2(spinner, "Failed to fetch user roles", error);
2258
+ exitWithCommandError3(spinner, "Failed to fetch user roles", error);
2104
2259
  }
2105
2260
  }
2106
- function resolveInputSource3(input) {
2261
+ var WORKFLOW_LIST_PATH = "/api/proxy/builtin/platform/workflow/openapi/apps";
2262
+ var WORKFLOW_GET_PATH = (workflowId) => `/api/proxy/builtin/platform/workflow/openapi/apps/${encodeURIComponent(workflowId)}/dsl`;
2263
+ function resolveInputSource4(input) {
2107
2264
  if (!input.startsWith("@")) {
2108
2265
  return input;
2109
2266
  }
@@ -2114,7 +2271,7 @@ function resolveInputSource3(input) {
2114
2271
  return readFileSync(filePath, "utf8");
2115
2272
  }
2116
2273
  function parseJsonInput3(input, label) {
2117
- const source = resolveInputSource3(input).trim();
2274
+ const source = resolveInputSource4(input).trim();
2118
2275
  if (!source) {
2119
2276
  throw new Error(`${label} is required.`);
2120
2277
  }
@@ -2128,6 +2285,151 @@ function parseJsonInput3(input, label) {
2128
2285
  function isPlainObject4(value) {
2129
2286
  return typeof value === "object" && value !== null && !Array.isArray(value);
2130
2287
  }
2288
+ function parseWorkflowTracing(value) {
2289
+ if (!value) {
2290
+ return null;
2291
+ }
2292
+ if (isPlainObject4(value)) {
2293
+ return value;
2294
+ }
2295
+ if (typeof value !== "string") {
2296
+ return null;
2297
+ }
2298
+ try {
2299
+ const parsed = JSON.parse(value);
2300
+ return isPlainObject4(parsed) ? parsed : null;
2301
+ } catch {
2302
+ return null;
2303
+ }
2304
+ }
2305
+ function getRunnableName(summary) {
2306
+ const tracing = parseWorkflowTracing(summary.tracing);
2307
+ const baseName = tracing?.base_name;
2308
+ if (typeof baseName === "string" && baseName.trim()) {
2309
+ return baseName.trim();
2310
+ }
2311
+ return null;
2312
+ }
2313
+ function normalizeWorkflowSummary(summary) {
2314
+ return {
2315
+ ...summary,
2316
+ id: typeof summary.id === "string" ? summary.id : "",
2317
+ name: typeof summary.name === "string" ? summary.name : "",
2318
+ runnable_name: getRunnableName(summary),
2319
+ description: typeof summary.description === "string" ? summary.description : null,
2320
+ mode: typeof summary.mode === "string" ? summary.mode : null
2321
+ };
2322
+ }
2323
+ function extractWorkflowInputVariables(dsl) {
2324
+ if (!isPlainObject4(dsl)) {
2325
+ return [];
2326
+ }
2327
+ const candidateNodeSets = [];
2328
+ if (Array.isArray(dsl.nodes)) {
2329
+ candidateNodeSets.push(dsl.nodes);
2330
+ }
2331
+ if (isPlainObject4(dsl.graph) && Array.isArray(dsl.graph.nodes)) {
2332
+ candidateNodeSets.push(dsl.graph.nodes);
2333
+ }
2334
+ const variables = [];
2335
+ for (const nodeSet of candidateNodeSets) {
2336
+ for (const node of nodeSet) {
2337
+ if (!isPlainObject4(node) || !isPlainObject4(node.data)) {
2338
+ continue;
2339
+ }
2340
+ const nodeData = node.data;
2341
+ if (nodeData.type !== "start" || !Array.isArray(nodeData.variables)) {
2342
+ continue;
2343
+ }
2344
+ for (const variable of nodeData.variables) {
2345
+ if (!isPlainObject4(variable) || typeof variable.variable !== "string") {
2346
+ continue;
2347
+ }
2348
+ variables.push({
2349
+ ...variable,
2350
+ variable: variable.variable,
2351
+ label: typeof variable.label === "string" ? variable.label : void 0,
2352
+ required: typeof variable.required === "boolean" ? variable.required : void 0,
2353
+ type: typeof variable.type === "string" ? variable.type : void 0
2354
+ });
2355
+ }
2356
+ }
2357
+ }
2358
+ return variables;
2359
+ }
2360
+ function normalizeWorkflowDefinition(definition) {
2361
+ return {
2362
+ ...definition,
2363
+ workflow_id: typeof definition.workflow_id === "string" ? definition.workflow_id : "",
2364
+ app_id: typeof definition.app_id === "string" ? definition.app_id : "",
2365
+ version: typeof definition.version === "string" ? definition.version : void 0,
2366
+ name: typeof definition.name === "string" ? definition.name : "",
2367
+ dsl: isPlainObject4(definition.dsl) ? definition.dsl : void 0,
2368
+ context: typeof definition.context === "string" ? definition.context : void 0,
2369
+ input_variables: extractWorkflowInputVariables(definition.dsl)
2370
+ };
2371
+ }
2372
+ function invalidResponse(status, message) {
2373
+ return {
2374
+ data: null,
2375
+ error: {
2376
+ status,
2377
+ message
2378
+ },
2379
+ status
2380
+ };
2381
+ }
2382
+ function createWorkflowService(client) {
2383
+ return {
2384
+ async list(params = {}) {
2385
+ const response = await client.http.request({
2386
+ url: WORKFLOW_LIST_PATH,
2387
+ method: "GET",
2388
+ params: {
2389
+ page: params.page ?? 1,
2390
+ limit: params.limit ?? 20,
2391
+ mode: params.mode ?? "workflow"
2392
+ }
2393
+ });
2394
+ if (!response.data || !Array.isArray(response.data.data)) {
2395
+ return invalidResponse(
2396
+ response.status,
2397
+ response.error?.message || "Invalid workflow list response structure"
2398
+ );
2399
+ }
2400
+ return {
2401
+ ...response,
2402
+ data: {
2403
+ ...response.data,
2404
+ page: typeof response.data.page === "number" ? response.data.page : params.page ?? 1,
2405
+ limit: typeof response.data.limit === "number" ? response.data.limit : params.limit ?? 20,
2406
+ total: typeof response.data.total === "number" ? response.data.total : response.data.data.length,
2407
+ has_more: typeof response.data.has_more === "boolean" ? response.data.has_more : false,
2408
+ data: response.data.data.map(normalizeWorkflowSummary)
2409
+ }
2410
+ };
2411
+ },
2412
+ async get(workflowId) {
2413
+ if (!workflowId) {
2414
+ return invalidResponse(400, "workflowId is required");
2415
+ }
2416
+ const response = await client.http.request({
2417
+ url: WORKFLOW_GET_PATH(workflowId),
2418
+ method: "GET"
2419
+ });
2420
+ if (!response.data || !isPlainObject4(response.data)) {
2421
+ return invalidResponse(
2422
+ response.status,
2423
+ response.error?.message || "Invalid workflow definition response structure"
2424
+ );
2425
+ }
2426
+ return {
2427
+ ...response,
2428
+ data: normalizeWorkflowDefinition(response.data)
2429
+ };
2430
+ }
2431
+ };
2432
+ }
2131
2433
  function loadOptionalJsonObjectInput3(input, label) {
2132
2434
  if (!input) {
2133
2435
  return {};
@@ -2148,11 +2450,11 @@ function loadOptionalJsonArrayInput(input, label) {
2148
2450
  }
2149
2451
  return value;
2150
2452
  }
2151
- function exitWithCommandError3(spinner, failureMessage, error) {
2453
+ function exitWithCommandError4(spinner, failureMessage, error) {
2152
2454
  spinner.fail(failureMessage);
2153
2455
  const details = error instanceof Error ? error.message : String(error);
2154
2456
  if (details) {
2155
- console.error(chalk3.red(details));
2457
+ console.error(chalk4.red(details));
2156
2458
  }
2157
2459
  process.exit(1);
2158
2460
  }
@@ -2187,26 +2489,148 @@ async function runWorkflow(client, options) {
2187
2489
  const result = await workflowClient.run(options.name, request);
2188
2490
  if (result.error) {
2189
2491
  spinner.fail("Failed to run workflow");
2190
- console.error(chalk3.red(result.error.message));
2492
+ console.error(chalk4.red(result.error.message));
2191
2493
  process.exit(1);
2192
2494
  }
2193
2495
  spinner.succeed("Workflow completed");
2194
2496
  renderOutput(result.data, {
2195
2497
  format: options.format,
2196
2498
  pretty: () => {
2197
- console.log(chalk3.blue("\n\u26A1 Workflow Run\n"));
2499
+ console.log(chalk4.blue("\n\u26A1 Workflow Run\n"));
2198
2500
  console.log(JSON.stringify(result.data, null, 2));
2199
2501
  }
2200
2502
  });
2201
2503
  } catch (error) {
2202
- exitWithCommandError3(spinner, "Failed to run workflow", error);
2504
+ exitWithCommandError4(spinner, "Failed to run workflow", error);
2203
2505
  }
2204
2506
  }
2205
- function exitWithCommandError4(spinner, failureMessage, error) {
2507
+ async function listWorkflows(client, options = {}) {
2508
+ const spinner = createSpinner("Fetching workflows...", options.format);
2509
+ try {
2510
+ const workflowService = createWorkflowService(client);
2511
+ const result = await workflowService.list({
2512
+ page: options.page,
2513
+ limit: options.limit,
2514
+ mode: options.mode
2515
+ });
2516
+ if (result.error) {
2517
+ spinner.fail("Failed to fetch workflows");
2518
+ console.error(chalk4.red(result.error.message));
2519
+ process.exit(1);
2520
+ }
2521
+ const payload = result.data;
2522
+ const workflows = payload?.data || [];
2523
+ spinner.succeed(`Found ${workflows.length} workflow${workflows.length === 1 ? "" : "s"}`);
2524
+ renderOutput(payload, {
2525
+ format: options.format,
2526
+ tableRows: workflows.map((workflow) => ({
2527
+ id: workflow.id,
2528
+ runnableName: workflow.runnable_name,
2529
+ platformName: workflow.name,
2530
+ mode: workflow.mode,
2531
+ description: workflow.description
2532
+ })),
2533
+ csvRows: workflows.map((workflow) => ({
2534
+ id: workflow.id,
2535
+ runnableName: workflow.runnable_name,
2536
+ platformName: workflow.name,
2537
+ mode: workflow.mode,
2538
+ description: workflow.description
2539
+ })),
2540
+ ndjsonItems: workflows,
2541
+ pretty: () => {
2542
+ console.log(chalk4.blue("\nWorkflows\n"));
2543
+ if (workflows.length === 0) {
2544
+ console.log(chalk4.gray("No workflows found."));
2545
+ return;
2546
+ }
2547
+ for (const workflow of workflows) {
2548
+ console.log(`${chalk4.green("\u2022")} ${chalk4.bold(workflow.runnable_name || workflow.name)}`);
2549
+ console.log(` ${chalk4.gray("ID:")} ${workflow.id}`);
2550
+ console.log(` ${chalk4.gray("Platform Name:")} ${workflow.name}`);
2551
+ console.log(` ${chalk4.gray("Mode:")} ${workflow.mode || "workflow"}`);
2552
+ if (workflow.description) {
2553
+ console.log(` ${chalk4.gray("Description:")} ${workflow.description}`);
2554
+ }
2555
+ }
2556
+ }
2557
+ });
2558
+ } catch (error) {
2559
+ exitWithCommandError4(spinner, "Failed to fetch workflows", error);
2560
+ }
2561
+ }
2562
+ async function getWorkflow(client, options) {
2563
+ const spinner = createSpinner(`Fetching workflow: ${options.id}...`, options.format);
2564
+ try {
2565
+ const workflowService = createWorkflowService(client);
2566
+ const result = await workflowService.get(options.id);
2567
+ if (result.error) {
2568
+ spinner.fail("Failed to fetch workflow");
2569
+ console.error(chalk4.red(result.error.message));
2570
+ process.exit(1);
2571
+ }
2572
+ const workflow = result.data;
2573
+ const inputVariables = workflow?.input_variables || [];
2574
+ spinner.succeed("Workflow loaded");
2575
+ renderOutput(workflow, {
2576
+ format: options.format,
2577
+ tableRows: workflow ? [
2578
+ {
2579
+ appId: workflow.app_id,
2580
+ workflowId: workflow.workflow_id,
2581
+ runnableName: workflow.name,
2582
+ version: workflow.version || null,
2583
+ inputVariables: inputVariables.map((item) => item.variable).join(", ")
2584
+ }
2585
+ ] : [],
2586
+ csvRows: workflow ? [
2587
+ {
2588
+ appId: workflow.app_id,
2589
+ workflowId: workflow.workflow_id,
2590
+ runnableName: workflow.name,
2591
+ version: workflow.version || null,
2592
+ inputVariables: inputVariables.map((item) => item.variable).join(", ")
2593
+ }
2594
+ ] : [],
2595
+ ndjsonItems: workflow ? [workflow] : [],
2596
+ pretty: () => {
2597
+ if (!workflow) {
2598
+ console.log(chalk4.gray("No workflow found."));
2599
+ return;
2600
+ }
2601
+ console.log(chalk4.blue(`
2602
+ Workflow: ${workflow.name}
2603
+ `));
2604
+ console.log(`${chalk4.gray("App ID:")} ${workflow.app_id}`);
2605
+ console.log(`${chalk4.gray("Workflow ID:")} ${workflow.workflow_id}`);
2606
+ if (workflow.version) {
2607
+ console.log(`${chalk4.gray("Version:")} ${workflow.version}`);
2608
+ }
2609
+ console.log(`
2610
+ ${chalk4.gray("Input Variables:")}`);
2611
+ if (inputVariables.length === 0) {
2612
+ console.log(chalk4.gray(" none"));
2613
+ } else {
2614
+ for (const variable of inputVariables) {
2615
+ const label = variable.label ? ` ${chalk4.gray(`(${variable.label})`)}` : "";
2616
+ const type = variable.type ? ` ${chalk4.gray(`[${variable.type}]`)}` : "";
2617
+ const required = variable.required ? chalk4.yellow(" required") : chalk4.gray(" optional");
2618
+ console.log(` - ${chalk4.bold(variable.variable)}${label}${type}${required}`);
2619
+ }
2620
+ }
2621
+ console.log(`
2622
+ ${chalk4.gray("Run With:")} amaster workflow run ${workflow.name} --app <app-code> --input '{...}'`);
2623
+ }
2624
+ });
2625
+ } catch (error) {
2626
+ exitWithCommandError4(spinner, "Failed to fetch workflow", error);
2627
+ }
2628
+ }
2629
+ function exitWithCommandError5(spinner, failureMessage, error) {
2206
2630
  spinner.fail(failureMessage);
2207
2631
  const details = error instanceof Error ? error.message : String(error);
2208
2632
  if (details) {
2209
- console.error(chalk3.red(details));
2633
+ console.error(chalk4.red(details));
2210
2634
  }
2211
2635
  process.exit(1);
2212
2636
  }
@@ -2245,20 +2669,20 @@ async function uploadFile(client, options) {
2245
2669
  const result = await s3Client.upload(file);
2246
2670
  if (result.error) {
2247
2671
  spinner.fail("Upload failed");
2248
- console.error(chalk3.red(result.error.message));
2672
+ console.error(chalk4.red(result.error.message));
2249
2673
  process.exit(1);
2250
2674
  }
2251
2675
  spinner.succeed("Upload complete");
2252
2676
  renderOutput(result.data, {
2253
2677
  format: options.format,
2254
2678
  pretty: () => {
2255
- console.log(chalk3.green("\nFile uploaded:"));
2256
- console.log(` ${chalk3.bold("Key:")} ${result.data?.key}`);
2257
- console.log(` ${chalk3.bold("URL:")} ${result.data?.url || "N/A"}`);
2679
+ console.log(chalk4.green("\nFile uploaded:"));
2680
+ console.log(` ${chalk4.bold("Key:")} ${result.data?.key}`);
2681
+ console.log(` ${chalk4.bold("URL:")} ${result.data?.url || "N/A"}`);
2258
2682
  }
2259
2683
  });
2260
2684
  } catch (error) {
2261
- exitWithCommandError4(spinner, "Upload failed", error);
2685
+ exitWithCommandError5(spinner, "Upload failed", error);
2262
2686
  }
2263
2687
  }
2264
2688
  async function downloadFile(client, options) {
@@ -2268,12 +2692,12 @@ async function downloadFile(client, options) {
2268
2692
  const result = await s3Client.download(options.key);
2269
2693
  if (result.error) {
2270
2694
  spinner.fail("Download failed");
2271
- console.error(chalk3.red(result.error.message));
2695
+ console.error(chalk4.red(result.error.message));
2272
2696
  process.exit(1);
2273
2697
  }
2274
2698
  if (!result.data) {
2275
2699
  spinner.fail("Download failed");
2276
- console.error(chalk3.red("Empty file response."));
2700
+ console.error(chalk4.red("Empty file response."));
2277
2701
  process.exit(1);
2278
2702
  }
2279
2703
  const outputPath = resolve(options.output);
@@ -2289,13 +2713,13 @@ async function downloadFile(client, options) {
2289
2713
  {
2290
2714
  format: options.format,
2291
2715
  pretty: () => {
2292
- console.log(chalk3.green(`
2716
+ console.log(chalk4.green(`
2293
2717
  File saved to: ${outputPath}`));
2294
2718
  }
2295
2719
  }
2296
2720
  );
2297
2721
  } catch (error) {
2298
- exitWithCommandError4(spinner, "Download failed", error);
2722
+ exitWithCommandError5(spinner, "Download failed", error);
2299
2723
  }
2300
2724
  }
2301
2725
  async function getFileMetadata(client, options) {
@@ -2305,21 +2729,21 @@ async function getFileMetadata(client, options) {
2305
2729
  const result = await s3Client.getMetadata(options.key);
2306
2730
  if (result.error) {
2307
2731
  spinner.fail("Failed to fetch metadata");
2308
- console.error(chalk3.red(result.error.message));
2732
+ console.error(chalk4.red(result.error.message));
2309
2733
  process.exit(1);
2310
2734
  }
2311
2735
  spinner.succeed("Metadata retrieved");
2312
2736
  renderOutput(result.data, {
2313
2737
  format: options.format,
2314
2738
  pretty: () => {
2315
- console.log(chalk3.blue(`
2739
+ console.log(chalk4.blue(`
2316
2740
  \u{1F4C4} Metadata for ${options.key}
2317
2741
  `));
2318
2742
  console.log(JSON.stringify(result.data, null, 2));
2319
2743
  }
2320
2744
  });
2321
2745
  } catch (error) {
2322
- exitWithCommandError4(spinner, "Failed to fetch metadata", error);
2746
+ exitWithCommandError5(spinner, "Failed to fetch metadata", error);
2323
2747
  }
2324
2748
  }
2325
2749
 
@@ -2360,8 +2784,8 @@ async function initOpenClaw(options) {
2360
2784
  const existingConfig = getAppConfig(options.appCode);
2361
2785
  if (existingConfig && !options.force) {
2362
2786
  spinner.fail(`App already exists: ${options.appCode}`);
2363
- console.log(chalk3.yellow(`Use --force to reinitialize`));
2364
- console.log(chalk3.gray(`Current URL: ${existingConfig.baseURL}`));
2787
+ console.log(chalk4.yellow(`Use --force to reinitialize`));
2788
+ console.log(chalk4.gray(`Current URL: ${existingConfig.baseURL}`));
2365
2789
  process.exit(1);
2366
2790
  }
2367
2791
  addApp(options.appCode, {
@@ -2372,8 +2796,8 @@ async function initOpenClaw(options) {
2372
2796
  if (!openClawDetected) {
2373
2797
  spinner.succeed(`App initialized: ${options.appCode}`);
2374
2798
  if (pretty) {
2375
- console.log(chalk3.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
2376
- console.log(chalk3.gray(" Install OpenClaw: npm install -g openclaw"));
2799
+ console.log(chalk4.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
2800
+ console.log(chalk4.gray(" Install OpenClaw: npm install -g openclaw"));
2377
2801
  } else {
2378
2802
  renderOutput(
2379
2803
  {
@@ -2391,9 +2815,9 @@ async function initOpenClaw(options) {
2391
2815
  }
2392
2816
  spinner.succeed(`App initialized: ${options.appCode}`);
2393
2817
  if (pretty) {
2394
- console.log(chalk3.blue("\n\u{1F4CB} Configuration:\n"));
2395
- console.log(` App Code: ${chalk3.green(options.appCode)}`);
2396
- console.log(` Base URL: ${chalk3.gray(options.baseURL)}`);
2818
+ console.log(chalk4.blue("\n\u{1F4CB} Configuration:\n"));
2819
+ console.log(` App Code: ${chalk4.green(options.appCode)}`);
2820
+ console.log(` Base URL: ${chalk4.gray(options.baseURL)}`);
2397
2821
  console.log();
2398
2822
  }
2399
2823
  spinner.start("Downloading skills...");
@@ -2465,16 +2889,16 @@ async function initOpenClaw(options) {
2465
2889
  };
2466
2890
  if (pretty) {
2467
2891
  console.log();
2468
- console.log(chalk3.green("\u2705 Initialization complete!"));
2892
+ console.log(chalk4.green("\u2705 Initialization complete!"));
2469
2893
  console.log();
2470
2894
  console.log(`Next step: Login to your app`);
2471
- console.log(chalk3.gray(` amaster login --app ${options.appCode}`));
2895
+ console.log(chalk4.gray(` amaster login --app ${options.appCode}`));
2472
2896
  console.log();
2473
2897
  if (apps.length > 1) {
2474
- console.log(chalk3.blue("Configured apps:"));
2898
+ console.log(chalk4.blue("Configured apps:"));
2475
2899
  for (const app of apps) {
2476
2900
  const config = getAppConfig(app);
2477
- console.log(` ${chalk3.gray("\u2022")} ${app} - ${config?.baseURL}`);
2901
+ console.log(` ${chalk4.gray("\u2022")} ${app} - ${config?.baseURL}`);
2478
2902
  }
2479
2903
  console.log();
2480
2904
  }
@@ -2575,6 +2999,14 @@ async function downloadMcpConfig(ossEndpoint, appCode) {
2575
2999
  }
2576
3000
 
2577
3001
  // src/cli.ts
3002
+ function resolveCliVersion() {
3003
+ try {
3004
+ const packageJsonUrl = new URL("../package.json", import.meta.url);
3005
+ return JSON.parse(readFileSync(packageJsonUrl, "utf-8")).version || "0.0.0";
3006
+ } catch {
3007
+ return "0.0.0";
3008
+ }
3009
+ }
2578
3010
  function resolveAppCode(optionsApp) {
2579
3011
  if (optionsApp) {
2580
3012
  return optionsApp;
@@ -2583,38 +3015,39 @@ function resolveAppCode(optionsApp) {
2583
3015
  if (defaultApp) {
2584
3016
  return defaultApp;
2585
3017
  }
2586
- console.error(chalk3.red("\u274C No app specified."));
2587
- console.log(chalk3.yellow("Use one of:"));
2588
- console.log(chalk3.gray(" 1. Add --app <app-code> to the command"));
2589
- console.log(chalk3.gray(" 2. Set a default app: amaster use <app-code>"));
3018
+ console.error(chalk4.red("\u274C No app specified."));
3019
+ console.log(chalk4.yellow("Use one of:"));
3020
+ console.log(chalk4.gray(" 1. Add --app <app-code> to the command"));
3021
+ console.log(chalk4.gray(" 2. Set a default app: amaster use <app-code>"));
2590
3022
  process.exit(1);
2591
3023
  }
2592
3024
  function createAmasterClient(appCode) {
2593
3025
  const appConfig = getAppConfig(appCode);
2594
3026
  if (!appConfig) {
2595
- console.error(chalk3.red(`\u274C App not configured: ${appCode}`));
2596
- console.log(chalk3.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
3027
+ console.error(chalk4.red(`\u274C App not configured: ${appCode}`));
3028
+ console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
2597
3029
  process.exit(1);
2598
3030
  }
2599
3031
  const token = getAccessToken(appCode);
2600
3032
  if (token && shouldRefreshToken(appCode)) {
2601
- console.error(chalk3.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
3033
+ console.error(chalk4.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
2602
3034
  }
2603
3035
  const client = createClient({
2604
3036
  baseURL: appConfig.baseURL,
2605
- ...token ? {
2606
- headers: {
3037
+ headers: {
3038
+ "x-app-code": appCode,
3039
+ ...token ? {
2607
3040
  Authorization: `Bearer ${token}`
2608
- }
2609
- } : {},
3041
+ } : {}
3042
+ },
2610
3043
  onUnauthorized: () => {
2611
3044
  if (token) {
2612
- console.error(chalk3.red("\n\u274C Session expired. Please login again."));
2613
- console.error(chalk3.yellow(`Run: amaster login --app ${appCode}`));
3045
+ console.error(chalk4.red("\n\u274C Session expired. Please login again."));
3046
+ console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
2614
3047
  } else {
2615
- console.error(chalk3.red(`
3048
+ console.error(chalk4.red(`
2616
3049
  \u274C Authentication required for app: ${appCode}`));
2617
- console.error(chalk3.yellow(`Run: amaster login --app ${appCode}`));
3050
+ console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
2618
3051
  }
2619
3052
  process.exit(1);
2620
3053
  }
@@ -2625,7 +3058,7 @@ function createAmasterClient(appCode) {
2625
3058
  return client;
2626
3059
  }
2627
3060
  var program = new Command();
2628
- program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version("1.0.0");
3061
+ program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version(resolveCliVersion());
2629
3062
  program.command("apps").description("List all configured apps").addOption(createFormatOption()).action((options) => {
2630
3063
  const apps = listApps();
2631
3064
  const current = getCurrentApp();
@@ -2641,17 +3074,17 @@ program.command("apps").description("List all configured apps").addOption(create
2641
3074
  renderOutput(appSummaries, {
2642
3075
  format: options.format,
2643
3076
  pretty: () => {
2644
- console.log(chalk3.blue("\n\u{1F4F1} Configured Apps\n"));
3077
+ console.log(chalk4.blue("\n\u{1F4F1} Configured Apps\n"));
2645
3078
  if (appSummaries.length === 0) {
2646
- console.log(chalk3.gray(" No apps configured"));
2647
- console.log(chalk3.gray(" Run: amaster init --app-code <code> --url <url>"));
3079
+ console.log(chalk4.gray(" No apps configured"));
3080
+ console.log(chalk4.gray(" Run: amaster init --app-code <code> --url <url>"));
2648
3081
  } else {
2649
3082
  for (const app of appSummaries) {
2650
- const prefix = app.current ? chalk3.green("\u2192 ") : " ";
2651
- console.log(`${prefix}${chalk3.bold(app.appCode)}${app.current ? chalk3.green(" (current)") : ""}`);
2652
- console.log(` ${chalk3.gray(app.baseURL || "No URL")}`);
3083
+ const prefix = app.current ? chalk4.green("\u2192 ") : " ";
3084
+ console.log(`${prefix}${chalk4.bold(app.appCode)}${app.current ? chalk4.green(" (current)") : ""}`);
3085
+ console.log(` ${chalk4.gray(app.baseURL || "No URL")}`);
2653
3086
  console.log(
2654
- ` ${app.authenticated ? chalk3.green("\u25CF Authenticated") : chalk3.yellow("\u25CB Not authenticated")}`
3087
+ ` ${app.authenticated ? chalk4.green("\u25CF Authenticated") : chalk4.yellow("\u25CB Not authenticated")}`
2655
3088
  );
2656
3089
  console.log();
2657
3090
  }
@@ -2670,12 +3103,12 @@ program.command("use <app-code>").description("Set the default app for subsequen
2670
3103
  {
2671
3104
  format: options.format,
2672
3105
  pretty: () => {
2673
- console.log(chalk3.green(`\u2705 Now using app: ${appCode}`));
3106
+ console.log(chalk4.green(`\u2705 Now using app: ${appCode}`));
2674
3107
  }
2675
3108
  }
2676
3109
  );
2677
3110
  } else {
2678
- console.error(chalk3.red(`\u274C App not found: ${appCode}`));
3111
+ console.error(chalk4.red(`\u274C App not found: ${appCode}`));
2679
3112
  process.exit(1);
2680
3113
  }
2681
3114
  });
@@ -2792,6 +3225,21 @@ entityCmd.command("bulk-delete <namespace> <entity>").description("Bulk delete e
2792
3225
  format: options.format
2793
3226
  });
2794
3227
  });
3228
+ var modelCmd = program.command("model").description("Discover runtime datasources and table schemas");
3229
+ modelCmd.command("datasources").description("List runtime datasources with their models").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (options) => {
3230
+ const appCode = resolveAppCode(options.app);
3231
+ await listDatasources(createAmasterClient(appCode), {
3232
+ format: options.format
3233
+ });
3234
+ });
3235
+ modelCmd.command("table-schema <source-id>").description("Get CREATE TABLE statements for one datasource").option("--app <app-code>", "App code (uses default if not specified)").option("--tables <tables>", "Comma-separated table names, JSON array, or @file").addOption(createFormatOption()).action(async (sourceId, options) => {
3236
+ const appCode = resolveAppCode(options.app);
3237
+ await getTableSchema(createAmasterClient(appCode), {
3238
+ sourceId,
3239
+ tables: options.tables,
3240
+ format: options.format
3241
+ });
3242
+ });
2795
3243
  var bpmCmd = program.command("bpm").description("Manage BPM processes and tasks");
2796
3244
  bpmCmd.command("processes").description("List process definitions").option("--app <app-code>", "App code (uses default if not specified)").option("--key <key>", "Filter by process definition key").option("--name <name>", "Filter by process definition name").option("--latest-version", "Only return latest version").option("--active", "Only return active process definitions").option("--suspended", "Only return suspended process definitions").option("--sort-by <field>", "Sort field").addOption(new Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional ProcessDefinitionQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
2797
3245
  const appCode = resolveAppCode(options.app);
@@ -3144,7 +3592,25 @@ bpmCmd.command("start-form-deployed <key>").description("Get deployed start form
3144
3592
  format: options.format
3145
3593
  });
3146
3594
  });
3147
- var workflowCmd = program.command("workflow").description("Run workflows");
3595
+ var workflowCmd = program.command("workflow").description("Inspect and run workflows");
3596
+ workflowCmd.command("list").description("List runnable workflows").option("--app <app-code>", "App code (uses default if not specified)").option("--page <n>", "Page number").option("--limit <n>", "Page size").addOption(
3597
+ new Option("--mode <mode>", "Workflow app mode").choices(["workflow", "chat", "completion", "agent-chat"])
3598
+ ).addOption(createFormatOption()).action(async (options) => {
3599
+ const appCode = resolveAppCode(options.app);
3600
+ await listWorkflows(createAmasterClient(appCode), {
3601
+ page: options.page ? parseInt(options.page, 10) : void 0,
3602
+ limit: options.limit ? parseInt(options.limit, 10) : void 0,
3603
+ mode: options.mode,
3604
+ format: options.format
3605
+ });
3606
+ });
3607
+ workflowCmd.command("get <id>").alias("inspect").description("Get workflow details and input variables by workflow app ID").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
3608
+ const appCode = resolveAppCode(options.app);
3609
+ await getWorkflow(createAmasterClient(appCode), {
3610
+ id,
3611
+ format: options.format
3612
+ });
3613
+ });
3148
3614
  workflowCmd.command("run <name>").alias("execute").description("Run a workflow").option("--app <app-code>", "App code (uses default if not specified)").option("-i, --input <json>", "Workflow inputs object as JSON or @file").option("-r, --request <json>", "Full WorkflowRunRequest as JSON or @file").addOption(
3149
3615
  new Option("--response-mode <mode>", "Workflow response mode").choices(["blocking", "streaming"])
3150
3616
  ).option("--user <user>", "Workflow user identifier").option("--files <json>", "Workflow files array as JSON or @file").option("--trace-id <traceId>", "Workflow trace ID").addOption(createFormatOption()).action(async (name, options) => {