@amaster.ai/runtime-cli 1.1.13 → 1.1.14-beta.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.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync, realpathSync } from 'fs';
1
+ import { readFileSync, existsSync, rmSync, mkdirSync, writeFileSync, realpathSync } from 'fs';
2
2
  import { join, resolve, basename } from 'path';
3
3
  import { homedir } from 'os';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { Command, Option } from 'commander';
6
- import chalk3 from 'chalk';
6
+ import chalk4 from 'chalk';
7
7
  import { createClient } from '@amaster.ai/client';
8
8
  import ora from 'ora';
9
9
  import { File } from 'buffer';
@@ -329,9 +329,9 @@ async function login(appCode, options) {
329
329
  const appConfig = getAppConfig(appCode);
330
330
  if (!appConfig) {
331
331
  spinner.fail(`App not configured: ${appCode}`);
332
- console.error(chalk3.red(`
332
+ console.error(chalk4.red(`
333
333
  \u274C App not found: ${appCode}`));
334
- console.log(chalk3.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
334
+ console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
335
335
  process.exit(1);
336
336
  }
337
337
  let username = options.username;
@@ -380,7 +380,7 @@ async function login(appCode, options) {
380
380
  const result = await client.auth.login(loginParams);
381
381
  if (result.error) {
382
382
  spinner.fail("Login failed");
383
- console.error(chalk3.red(result.error.message));
383
+ console.error(chalk4.red(result.error.message));
384
384
  process.exit(1);
385
385
  }
386
386
  const loginData = result.data;
@@ -414,16 +414,16 @@ async function login(appCode, options) {
414
414
  format: options.format,
415
415
  pretty: () => {
416
416
  console.log(
417
- chalk3.green(
417
+ chalk4.green(
418
418
  `
419
419
  Welcome, ${loginData.user?.displayName || loginData.user?.email || loginData.user?.username || email}!`
420
420
  )
421
421
  );
422
- console.log(chalk3.gray(`App: ${appCode}`));
423
- console.log(chalk3.gray(`URL: ${appConfig.baseURL}`));
422
+ console.log(chalk4.gray(`App: ${appCode}`));
423
+ console.log(chalk4.gray(`URL: ${appConfig.baseURL}`));
424
424
  if (expiresAt) {
425
425
  const expires = new Date(expiresAt);
426
- console.log(chalk3.gray(`Session expires: ${expires.toLocaleString()}`));
426
+ console.log(chalk4.gray(`Session expires: ${expires.toLocaleString()}`));
427
427
  }
428
428
  }
429
429
  }
@@ -459,7 +459,7 @@ async function logout(appCode, options = {}) {
459
459
  {
460
460
  format: options.format,
461
461
  pretty: () => {
462
- console.log(chalk3.green(`Logged out from ${appCode}`));
462
+ console.log(chalk4.green(`Logged out from ${appCode}`));
463
463
  }
464
464
  }
465
465
  );
@@ -475,7 +475,7 @@ async function getMe(getClient, options = {}) {
475
475
  const result = await client.auth.getMe();
476
476
  if (result.error) {
477
477
  spinner.fail("Failed to fetch user info");
478
- console.error(chalk3.red(result.error.message));
478
+ console.error(chalk4.red(result.error.message));
479
479
  process.exit(1);
480
480
  }
481
481
  spinner.succeed("User info retrieved");
@@ -483,11 +483,11 @@ async function getMe(getClient, options = {}) {
483
483
  renderOutput(user, {
484
484
  format: options.format,
485
485
  pretty: () => {
486
- console.log(chalk3.blue("\n\u{1F464} User Profile\n"));
487
- console.log(` ${chalk3.bold("UID:")} ${user?.uid}`);
488
- console.log(` ${chalk3.bold("Email:")} ${user?.email}`);
489
- console.log(` ${chalk3.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
490
- console.log(` ${chalk3.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
486
+ console.log(chalk4.blue("\n\u{1F464} User Profile\n"));
487
+ console.log(` ${chalk4.bold("UID:")} ${user?.uid}`);
488
+ console.log(` ${chalk4.bold("Email:")} ${user?.email}`);
489
+ console.log(` ${chalk4.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
490
+ console.log(` ${chalk4.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
491
491
  }
492
492
  });
493
493
  } catch (error) {
@@ -617,7 +617,7 @@ function exitWithCommandError(spinner, failureMessage, error) {
617
617
  spinner.fail(failureMessage);
618
618
  const details = error instanceof Error ? error.message : String(error);
619
619
  if (details) {
620
- console.error(chalk3.red(details));
620
+ console.error(chalk4.red(details));
621
621
  }
622
622
  process.exit(1);
623
623
  }
@@ -682,7 +682,7 @@ async function listEntities(client, options) {
682
682
  });
683
683
  if (result.error) {
684
684
  spinner.fail("Failed to fetch entities");
685
- console.error(chalk3.red(result.error.message));
685
+ console.error(chalk4.red(result.error.message));
686
686
  process.exit(1);
687
687
  }
688
688
  spinner.stop();
@@ -702,12 +702,12 @@ async function listEntities(client, options) {
702
702
  renderOutput(result.data, {
703
703
  format: options.format,
704
704
  pretty: () => {
705
- console.log(chalk3.blue(`
705
+ console.log(chalk4.blue(`
706
706
  \u{1F4E6} ${options.entity} in ${options.namespace}`));
707
- console.log(chalk3.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
707
+ console.log(chalk4.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
708
708
  `));
709
709
  if (items.length === 0) {
710
- console.log(chalk3.gray(" \u6682\u65E0\u6570\u636E"));
710
+ console.log(chalk4.gray(" \u6682\u65E0\u6570\u636E"));
711
711
  return;
712
712
  }
713
713
  const firstItem = items[0];
@@ -727,7 +727,7 @@ async function listEntities(client, options) {
727
727
  });
728
728
  const headerLine = keys.map((key) => {
729
729
  const width = widths[key] ?? 0;
730
- return chalk3.bold(key.slice(0, width).padEnd(width));
730
+ return chalk4.bold(key.slice(0, width).padEnd(width));
731
731
  }).join("\u2502");
732
732
  console.log(" " + headerLine);
733
733
  console.log(" " + keys.map((key) => "\u2500".repeat(widths[key] ?? 0)).join("\u253C"));
@@ -743,7 +743,7 @@ async function listEntities(client, options) {
743
743
  }
744
744
  console.log();
745
745
  if (items.length < total) {
746
- console.log(chalk3.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
746
+ console.log(chalk4.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
747
747
  }
748
748
  }
749
749
  });
@@ -758,14 +758,14 @@ async function getEntity(client, options) {
758
758
  const result = await entityClient.get(options.namespace, options.entity, options.id);
759
759
  if (result.error) {
760
760
  spinner.fail("Failed to fetch entity");
761
- console.error(chalk3.red(result.error.message));
761
+ console.error(chalk4.red(result.error.message));
762
762
  process.exit(1);
763
763
  }
764
764
  spinner.succeed("Entity retrieved");
765
765
  renderOutput(result.data, {
766
766
  format: options.format,
767
767
  pretty: () => {
768
- console.log(chalk3.blue(`
768
+ console.log(chalk4.blue(`
769
769
  \u{1F4C4} ${options.entity}
770
770
  `));
771
771
  console.log(JSON.stringify(result.data, null, 2));
@@ -783,14 +783,14 @@ async function createEntity(client, options) {
783
783
  const result = await entityClient.create(options.namespace, options.entity, data);
784
784
  if (result.error) {
785
785
  spinner.fail("Failed to create entity");
786
- console.error(chalk3.red(result.error.message));
786
+ console.error(chalk4.red(result.error.message));
787
787
  process.exit(1);
788
788
  }
789
789
  spinner.succeed("Entity created");
790
790
  renderOutput(result.data, {
791
791
  format: options.format,
792
792
  pretty: () => {
793
- console.log(chalk3.green("\nCreated entity:"));
793
+ console.log(chalk4.green("\nCreated entity:"));
794
794
  console.log(JSON.stringify(result.data, null, 2));
795
795
  }
796
796
  });
@@ -806,14 +806,14 @@ async function updateEntity(client, options) {
806
806
  const result = await entityClient.update(options.namespace, options.entity, options.id, data);
807
807
  if (result.error) {
808
808
  spinner.fail("Failed to update entity");
809
- console.error(chalk3.red(result.error.message));
809
+ console.error(chalk4.red(result.error.message));
810
810
  process.exit(1);
811
811
  }
812
812
  spinner.succeed("Entity updated");
813
813
  renderOutput(result.data, {
814
814
  format: options.format,
815
815
  pretty: () => {
816
- console.log(chalk3.green("\nUpdated entity:"));
816
+ console.log(chalk4.green("\nUpdated entity:"));
817
817
  console.log(JSON.stringify(result.data, null, 2));
818
818
  }
819
819
  });
@@ -828,7 +828,7 @@ async function deleteEntity(client, options) {
828
828
  const result = await entityClient.delete(options.namespace, options.entity, options.id);
829
829
  if (result.error) {
830
830
  spinner.fail("Failed to delete entity");
831
- console.error(chalk3.red(result.error.message));
831
+ console.error(chalk4.red(result.error.message));
832
832
  process.exit(1);
833
833
  }
834
834
  spinner.succeed("Entity deleted");
@@ -842,7 +842,7 @@ async function deleteEntity(client, options) {
842
842
  {
843
843
  format: options.format,
844
844
  pretty: () => {
845
- console.log(chalk3.green(`
845
+ console.log(chalk4.green(`
846
846
  Deleted ${options.entity} with ID: ${options.id}`));
847
847
  }
848
848
  }
@@ -859,14 +859,14 @@ async function listEntityOptions(client, options) {
859
859
  const result = await entityClient.options(options.namespace, options.entity, fields);
860
860
  if (result.error) {
861
861
  spinner.fail("Failed to fetch entity options");
862
- console.error(chalk3.red(result.error.message));
862
+ console.error(chalk4.red(result.error.message));
863
863
  process.exit(1);
864
864
  }
865
865
  spinner.succeed(`Found ${result.data?.length || 0} options`);
866
866
  renderOutput(result.data || [], {
867
867
  format: options.format,
868
868
  pretty: () => {
869
- console.log(chalk3.blue(`
869
+ console.log(chalk4.blue(`
870
870
  \u{1F9FE} ${options.entity} options
871
871
  `));
872
872
  console.log(JSON.stringify(result.data || [], null, 2));
@@ -889,14 +889,14 @@ async function bulkUpdateEntities(client, options) {
889
889
  const result = await entityClient.bulkUpdate(options.namespace, options.entity, items);
890
890
  if (result.error) {
891
891
  spinner.fail("Failed to bulk update entities");
892
- console.error(chalk3.red(result.error.message));
892
+ console.error(chalk4.red(result.error.message));
893
893
  process.exit(1);
894
894
  }
895
895
  spinner.succeed(`Updated ${items.length} entities`);
896
896
  renderOutput(result.data, {
897
897
  format: options.format,
898
898
  pretty: () => {
899
- console.log(chalk3.green(`
899
+ console.log(chalk4.green(`
900
900
  Bulk updated ${items.length} ${options.entity} records:`));
901
901
  console.log(JSON.stringify(result.data, null, 2));
902
902
  }
@@ -913,7 +913,7 @@ async function bulkDeleteEntities(client, options) {
913
913
  const result = await entityClient.bulkDelete(options.namespace, options.entity, ids);
914
914
  if (result.error) {
915
915
  spinner.fail("Failed to bulk delete entities");
916
- console.error(chalk3.red(result.error.message));
916
+ console.error(chalk4.red(result.error.message));
917
917
  process.exit(1);
918
918
  }
919
919
  spinner.succeed(`Deleted ${ids.length} entities`);
@@ -928,7 +928,7 @@ async function bulkDeleteEntities(client, options) {
928
928
  {
929
929
  format: options.format,
930
930
  pretty: () => {
931
- console.log(chalk3.green(`
931
+ console.log(chalk4.green(`
932
932
  Deleted ${ids.length} ${options.entity} records.`));
933
933
  }
934
934
  }
@@ -937,10 +937,165 @@ Deleted ${ids.length} ${options.entity} records.`));
937
937
  exitWithCommandError(spinner, "Failed to bulk delete entities", error);
938
938
  }
939
939
  }
940
+ function resolveInputSource2(input) {
941
+ if (!input.startsWith("@")) {
942
+ return input;
943
+ }
944
+ const filePath = input.slice(1);
945
+ if (!filePath) {
946
+ throw new Error("File path is required after '@'.");
947
+ }
948
+ return readFileSync(filePath, "utf8");
949
+ }
950
+ function exitWithCommandError2(spinner, failureMessage, error) {
951
+ spinner.fail(failureMessage);
952
+ const details = error instanceof Error ? error.message : String(error);
953
+ if (details) {
954
+ console.error(chalk4.red(details));
955
+ }
956
+ process.exit(1);
957
+ }
958
+ function parseTableNamesInput(input) {
959
+ if (!input) {
960
+ return void 0;
961
+ }
962
+ const source = resolveInputSource2(input).trim();
963
+ if (!source) {
964
+ return void 0;
965
+ }
966
+ if (source.startsWith("[")) {
967
+ let parsed;
968
+ try {
969
+ parsed = JSON.parse(source);
970
+ } catch (error) {
971
+ const reason = error instanceof Error ? error.message : String(error);
972
+ throw new Error(`Invalid table list: ${reason}`);
973
+ }
974
+ if (!Array.isArray(parsed)) {
975
+ throw new Error("Table list must be a JSON array.");
976
+ }
977
+ return parsed.map((value, index) => {
978
+ if (typeof value !== "string") {
979
+ throw new Error(`Table name at index ${index} must be a string.`);
980
+ }
981
+ return value;
982
+ });
983
+ }
984
+ const values = source.split(/[,\n]/).map((entry) => entry.trim()).filter(Boolean);
985
+ return values.length > 0 ? values : void 0;
986
+ }
987
+ async function listDatasources(client, options = {}) {
988
+ const spinner = createSpinner("Fetching datasources...", options.format);
989
+ try {
990
+ const result = await client.http.request({
991
+ url: "/api/entity/source/list_with_models",
992
+ method: "GET"
993
+ });
994
+ if (result.error) {
995
+ spinner.fail("Failed to fetch datasources");
996
+ console.error(chalk4.red(result.error.message));
997
+ process.exit(1);
998
+ }
999
+ const datasources = result.data || [];
1000
+ spinner.succeed(`Found ${datasources.length} datasource${datasources.length === 1 ? "" : "s"}`);
1001
+ renderOutput(datasources, {
1002
+ format: options.format,
1003
+ tableRows: datasources.map((source) => ({
1004
+ sourceId: source.sourceId,
1005
+ name: source.name,
1006
+ systemBuilt: source.systemBuilt,
1007
+ synchronizeMode: source.synchronizeMode,
1008
+ modelCount: source.models?.length || 0
1009
+ })),
1010
+ csvRows: datasources.map((source) => ({
1011
+ sourceId: source.sourceId,
1012
+ name: source.name,
1013
+ systemBuilt: source.systemBuilt,
1014
+ synchronizeMode: source.synchronizeMode,
1015
+ modelCount: source.models?.length || 0
1016
+ })),
1017
+ ndjsonItems: datasources,
1018
+ pretty: () => {
1019
+ console.log(chalk4.blue("\nData Sources\n"));
1020
+ if (datasources.length === 0) {
1021
+ console.log(chalk4.gray("No datasources found."));
1022
+ return;
1023
+ }
1024
+ for (const source of datasources) {
1025
+ console.log(`${chalk4.green("\u2022")} ${chalk4.bold(source.name)} ${chalk4.gray(`(${source.sourceId})`)}`);
1026
+ console.log(` ${chalk4.gray("System Built:")} ${source.systemBuilt}`);
1027
+ console.log(` ${chalk4.gray("Sync Mode:")} ${source.synchronizeMode}`);
1028
+ if (!source.models || source.models.length === 0) {
1029
+ console.log(` ${chalk4.gray("Models:")} none`);
1030
+ continue;
1031
+ }
1032
+ console.log(` ${chalk4.gray("Models:")}`);
1033
+ for (const model of source.models) {
1034
+ const suffix = model.description ? ` ${chalk4.gray(`- ${model.description}`)}` : "";
1035
+ console.log(` - ${chalk4.bold(model.tableName)} ${chalk4.gray(`(${model.modelId})`)}${suffix}`);
1036
+ }
1037
+ }
1038
+ }
1039
+ });
1040
+ } catch (error) {
1041
+ exitWithCommandError2(spinner, "Failed to fetch datasources", error);
1042
+ }
1043
+ }
1044
+ async function getTableSchema(client, options) {
1045
+ const spinner = createSpinner(`Fetching table schema for ${options.sourceId}...`, options.format);
1046
+ try {
1047
+ const tableNames = parseTableNamesInput(options.tables);
1048
+ const search = new URLSearchParams();
1049
+ if (tableNames && tableNames.length > 0) {
1050
+ search.set("tableNames", tableNames.join(","));
1051
+ }
1052
+ const query = search.toString();
1053
+ const url = `/api/entity/source/${encodeURIComponent(options.sourceId)}/create_table_statements${query ? `?${query}` : ""}`;
1054
+ const result = await client.http.request({
1055
+ url,
1056
+ method: "GET"
1057
+ });
1058
+ if (result.error) {
1059
+ spinner.fail("Failed to fetch table schema");
1060
+ console.error(chalk4.red(result.error.message));
1061
+ process.exit(1);
1062
+ }
1063
+ const tables = result.data || [];
1064
+ spinner.succeed(`Fetched schema for ${tables.length} table${tables.length === 1 ? "" : "s"}`);
1065
+ renderOutput(tables, {
1066
+ format: options.format,
1067
+ tableRows: tables.map((table) => ({
1068
+ tableName: table.tableName,
1069
+ createTableSql: table.createTableSql
1070
+ })),
1071
+ csvRows: tables.map((table) => ({
1072
+ tableName: table.tableName,
1073
+ createTableSql: table.createTableSql
1074
+ })),
1075
+ ndjsonItems: tables,
1076
+ pretty: () => {
1077
+ console.log(chalk4.blue(`
1078
+ Table Schemas: ${options.sourceId}
1079
+ `));
1080
+ if (tables.length === 0) {
1081
+ console.log(chalk4.gray("No tables found."));
1082
+ return;
1083
+ }
1084
+ for (const table of tables) {
1085
+ console.log(chalk4.green(table.tableName));
1086
+ console.log(table.createTableSql);
1087
+ console.log();
1088
+ }
1089
+ }
1090
+ });
1091
+ } catch (error) {
1092
+ exitWithCommandError2(spinner, "Failed to fetch table schema", error);
1093
+ }
1094
+ }
940
1095
  function isPlainObject3(value) {
941
1096
  return typeof value === "object" && value !== null && !Array.isArray(value);
942
1097
  }
943
- function resolveInputSource2(input) {
1098
+ function resolveInputSource3(input) {
944
1099
  if (!input.startsWith("@")) {
945
1100
  return input;
946
1101
  }
@@ -951,7 +1106,7 @@ function resolveInputSource2(input) {
951
1106
  return readFileSync(filePath, "utf8");
952
1107
  }
953
1108
  function parseJsonInput2(input, label) {
954
- const source = resolveInputSource2(input).trim();
1109
+ const source = resolveInputSource3(input).trim();
955
1110
  if (!source) {
956
1111
  throw new Error(`${label} is required.`);
957
1112
  }
@@ -992,11 +1147,11 @@ function loadOptionalJsonObjectInput2(input, label) {
992
1147
  }
993
1148
  return value;
994
1149
  }
995
- function exitWithCommandError2(spinner, failureMessage, error) {
1150
+ function exitWithCommandError3(spinner, failureMessage, error) {
996
1151
  spinner.fail(failureMessage);
997
1152
  const details = error instanceof Error ? error.message : String(error);
998
1153
  if (details) {
999
- console.error(chalk3.red(details));
1154
+ console.error(chalk4.red(details));
1000
1155
  }
1001
1156
  process.exit(1);
1002
1157
  }
@@ -1005,7 +1160,7 @@ function extractClientErrorMessage(error) {
1005
1160
  }
1006
1161
  function exitWithClientError(spinner, failureMessage, error, diagnosticMessage) {
1007
1162
  spinner.fail(failureMessage);
1008
- console.error(chalk3.red(diagnosticMessage || extractClientErrorMessage(error)));
1163
+ console.error(chalk4.red(diagnosticMessage || extractClientErrorMessage(error)));
1009
1164
  process.exit(1);
1010
1165
  }
1011
1166
  function inspectStartEventFormConfiguration(bpmnXml) {
@@ -1186,7 +1341,7 @@ async function listProcesses(client, options = {}) {
1186
1341
  const result = await bpmClient.getProcessDefinitions(params);
1187
1342
  if (result.error) {
1188
1343
  spinner.fail("Failed to fetch processes");
1189
- console.error(chalk3.red(result.error.message));
1344
+ console.error(chalk4.red(result.error.message));
1190
1345
  process.exit(1);
1191
1346
  }
1192
1347
  spinner.succeed(`Found ${result.data?.length || 0} process definitions`);
@@ -1194,19 +1349,19 @@ async function listProcesses(client, options = {}) {
1194
1349
  renderOutput(processes, {
1195
1350
  format: options.format,
1196
1351
  pretty: () => {
1197
- console.log(chalk3.blue("\n\u{1F4CA} Process Definitions\n"));
1352
+ console.log(chalk4.blue("\n\u{1F4CA} Process Definitions\n"));
1198
1353
  for (const proc of processes) {
1199
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(proc.key)}`);
1200
- console.log(` ${chalk3.gray("ID:")} ${proc.id || "N/A"}`);
1201
- console.log(` ${chalk3.gray("Name:")} ${proc.name || "N/A"}`);
1202
- console.log(` ${chalk3.gray("Version:")} ${proc.version || "N/A"}`);
1203
- console.log(` ${chalk3.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
1354
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(proc.key)}`);
1355
+ console.log(` ${chalk4.gray("ID:")} ${proc.id || "N/A"}`);
1356
+ console.log(` ${chalk4.gray("Name:")} ${proc.name || "N/A"}`);
1357
+ console.log(` ${chalk4.gray("Version:")} ${proc.version || "N/A"}`);
1358
+ console.log(` ${chalk4.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
1204
1359
  console.log();
1205
1360
  }
1206
1361
  }
1207
1362
  });
1208
1363
  } catch (error) {
1209
- exitWithCommandError2(spinner, "Failed to fetch processes", error);
1364
+ exitWithCommandError3(spinner, "Failed to fetch processes", error);
1210
1365
  }
1211
1366
  }
1212
1367
  async function getProcessXml(client, options) {
@@ -1216,21 +1371,21 @@ async function getProcessXml(client, options) {
1216
1371
  const result = await bpmClient.getProcessXml(options.key);
1217
1372
  if (result.error) {
1218
1373
  spinner.fail("Failed to fetch process XML");
1219
- console.error(chalk3.red(result.error.message));
1374
+ console.error(chalk4.red(result.error.message));
1220
1375
  process.exit(1);
1221
1376
  }
1222
1377
  spinner.succeed("Process XML retrieved");
1223
1378
  renderOutput(result.data, {
1224
1379
  format: options.format,
1225
1380
  pretty: () => {
1226
- console.log(chalk3.blue(`
1381
+ console.log(chalk4.blue(`
1227
1382
  \u{1F4C4} BPMN XML: ${options.key}
1228
1383
  `));
1229
1384
  console.log(result.data?.bpmn20Xml || "");
1230
1385
  }
1231
1386
  });
1232
1387
  } catch (error) {
1233
- exitWithCommandError2(spinner, "Failed to fetch process XML", error);
1388
+ exitWithCommandError3(spinner, "Failed to fetch process XML", error);
1234
1389
  }
1235
1390
  }
1236
1391
  async function startProcess(client, options) {
@@ -1241,22 +1396,22 @@ async function startProcess(client, options) {
1241
1396
  const result = await bpmClient.startProcess(options.key, variables);
1242
1397
  if (result.error) {
1243
1398
  spinner.fail("Failed to start process");
1244
- console.error(chalk3.red(result.error.message));
1399
+ console.error(chalk4.red(result.error.message));
1245
1400
  process.exit(1);
1246
1401
  }
1247
1402
  spinner.succeed("Process started");
1248
1403
  renderOutput(result.data, {
1249
1404
  format: options.format,
1250
1405
  pretty: () => {
1251
- console.log(chalk3.green("\nProcess Instance:"));
1252
- console.log(` ${chalk3.bold("ID:")} ${result.data?.id}`);
1253
- console.log(` ${chalk3.bold("Definition ID:")} ${result.data?.definitionId}`);
1254
- console.log(` ${chalk3.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
1255
- console.log(` ${chalk3.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
1406
+ console.log(chalk4.green("\nProcess Instance:"));
1407
+ console.log(` ${chalk4.bold("ID:")} ${result.data?.id}`);
1408
+ console.log(` ${chalk4.bold("Definition ID:")} ${result.data?.definitionId}`);
1409
+ console.log(` ${chalk4.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
1410
+ console.log(` ${chalk4.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
1256
1411
  }
1257
1412
  });
1258
1413
  } catch (error) {
1259
- exitWithCommandError2(spinner, "Failed to start process", error);
1414
+ exitWithCommandError3(spinner, "Failed to start process", error);
1260
1415
  }
1261
1416
  }
1262
1417
  async function listProcessInstances(client, options = {}) {
@@ -1267,7 +1422,7 @@ async function listProcessInstances(client, options = {}) {
1267
1422
  const result = await bpmClient.getProcessInstances(params);
1268
1423
  if (result.error) {
1269
1424
  spinner.fail("Failed to fetch process instances");
1270
- console.error(chalk3.red(result.error.message));
1425
+ console.error(chalk4.red(result.error.message));
1271
1426
  process.exit(1);
1272
1427
  }
1273
1428
  spinner.succeed(`Found ${result.data?.length || 0} process instances`);
@@ -1275,20 +1430,20 @@ async function listProcessInstances(client, options = {}) {
1275
1430
  renderOutput(instances, {
1276
1431
  format: options.format,
1277
1432
  pretty: () => {
1278
- console.log(chalk3.blue("\n\u{1F504} Process Instances\n"));
1433
+ console.log(chalk4.blue("\n\u{1F504} Process Instances\n"));
1279
1434
  for (const instance of instances) {
1280
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(instance.id)}`);
1281
- console.log(` ${chalk3.gray("Definition:")} ${instance.definitionId || "N/A"}`);
1282
- console.log(` ${chalk3.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
1435
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(instance.id)}`);
1436
+ console.log(` ${chalk4.gray("Definition:")} ${instance.definitionId || "N/A"}`);
1437
+ console.log(` ${chalk4.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
1283
1438
  console.log(
1284
- ` ${chalk3.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
1439
+ ` ${chalk4.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
1285
1440
  );
1286
1441
  console.log();
1287
1442
  }
1288
1443
  }
1289
1444
  });
1290
1445
  } catch (error) {
1291
- exitWithCommandError2(spinner, "Failed to fetch process instances", error);
1446
+ exitWithCommandError3(spinner, "Failed to fetch process instances", error);
1292
1447
  }
1293
1448
  }
1294
1449
  async function getProcessInstance(client, options) {
@@ -1298,19 +1453,19 @@ async function getProcessInstance(client, options) {
1298
1453
  const result = await bpmClient.getProcessInstance(options.id);
1299
1454
  if (result.error) {
1300
1455
  spinner.fail("Failed to fetch process instance");
1301
- console.error(chalk3.red(result.error.message));
1456
+ console.error(chalk4.red(result.error.message));
1302
1457
  process.exit(1);
1303
1458
  }
1304
1459
  spinner.succeed("Process instance retrieved");
1305
1460
  renderOutput(result.data, {
1306
1461
  format: options.format,
1307
1462
  pretty: () => {
1308
- console.log(chalk3.blue("\n\u{1F4CA} Process Instance\n"));
1463
+ console.log(chalk4.blue("\n\u{1F4CA} Process Instance\n"));
1309
1464
  console.log(JSON.stringify(result.data, null, 2));
1310
1465
  }
1311
1466
  });
1312
1467
  } catch (error) {
1313
- exitWithCommandError2(spinner, "Failed to fetch process instance", error);
1468
+ exitWithCommandError3(spinner, "Failed to fetch process instance", error);
1314
1469
  }
1315
1470
  }
1316
1471
  async function getActivityInstanceTree(client, options) {
@@ -1320,19 +1475,19 @@ async function getActivityInstanceTree(client, options) {
1320
1475
  const result = await bpmClient.getActivityInstanceTree(options.id);
1321
1476
  if (result.error) {
1322
1477
  spinner.fail("Failed to fetch activity instance tree");
1323
- console.error(chalk3.red(result.error.message));
1478
+ console.error(chalk4.red(result.error.message));
1324
1479
  process.exit(1);
1325
1480
  }
1326
1481
  spinner.succeed("Activity instance tree retrieved");
1327
1482
  renderOutput(result.data, {
1328
1483
  format: options.format,
1329
1484
  pretty: () => {
1330
- console.log(chalk3.blue("\n\u{1F333} Activity Instance Tree\n"));
1485
+ console.log(chalk4.blue("\n\u{1F333} Activity Instance Tree\n"));
1331
1486
  console.log(JSON.stringify(result.data, null, 2));
1332
1487
  }
1333
1488
  });
1334
1489
  } catch (error) {
1335
- exitWithCommandError2(spinner, "Failed to fetch activity instance tree", error);
1490
+ exitWithCommandError3(spinner, "Failed to fetch activity instance tree", error);
1336
1491
  }
1337
1492
  }
1338
1493
  async function getActiveActivities(client, options) {
@@ -1342,7 +1497,7 @@ async function getActiveActivities(client, options) {
1342
1497
  const result = await bpmClient.getActiveActivities(options.id);
1343
1498
  if (result.error) {
1344
1499
  spinner.fail("Failed to fetch active activities");
1345
- console.error(chalk3.red(result.error.message));
1500
+ console.error(chalk4.red(result.error.message));
1346
1501
  process.exit(1);
1347
1502
  }
1348
1503
  const activities = Array.isArray(result.data) ? result.data : [];
@@ -1350,12 +1505,12 @@ async function getActiveActivities(client, options) {
1350
1505
  renderOutput(result.data, {
1351
1506
  format: options.format,
1352
1507
  pretty: () => {
1353
- console.log(chalk3.blue("\n\u26A1 Active Activities\n"));
1508
+ console.log(chalk4.blue("\n\u26A1 Active Activities\n"));
1354
1509
  console.log(JSON.stringify(result.data, null, 2));
1355
1510
  }
1356
1511
  });
1357
1512
  } catch (error) {
1358
- exitWithCommandError2(spinner, "Failed to fetch active activities", error);
1513
+ exitWithCommandError3(spinner, "Failed to fetch active activities", error);
1359
1514
  }
1360
1515
  }
1361
1516
  async function getRuntimeVariables(client, options) {
@@ -1365,19 +1520,19 @@ async function getRuntimeVariables(client, options) {
1365
1520
  const result = await bpmClient.getRuntimeVariables(options.id);
1366
1521
  if (result.error) {
1367
1522
  spinner.fail("Failed to fetch runtime variables");
1368
- console.error(chalk3.red(result.error.message));
1523
+ console.error(chalk4.red(result.error.message));
1369
1524
  process.exit(1);
1370
1525
  }
1371
1526
  spinner.succeed("Runtime variables retrieved");
1372
1527
  renderOutput(result.data, {
1373
1528
  format: options.format,
1374
1529
  pretty: () => {
1375
- console.log(chalk3.blue("\n\u{1F9EE} Runtime Variables\n"));
1530
+ console.log(chalk4.blue("\n\u{1F9EE} Runtime Variables\n"));
1376
1531
  console.log(JSON.stringify(result.data, null, 2));
1377
1532
  }
1378
1533
  });
1379
1534
  } catch (error) {
1380
- exitWithCommandError2(spinner, "Failed to fetch runtime variables", error);
1535
+ exitWithCommandError3(spinner, "Failed to fetch runtime variables", error);
1381
1536
  }
1382
1537
  }
1383
1538
  async function getProcessVariables(client, options) {
@@ -1390,19 +1545,19 @@ async function getProcessVariables(client, options) {
1390
1545
  });
1391
1546
  if (result.error) {
1392
1547
  spinner.fail("Failed to fetch process variables");
1393
- console.error(chalk3.red(result.error.message));
1548
+ console.error(chalk4.red(result.error.message));
1394
1549
  process.exit(1);
1395
1550
  }
1396
1551
  spinner.succeed(`Found ${result.data?.length || 0} variables`);
1397
1552
  renderOutput(result.data || [], {
1398
1553
  format: options.format,
1399
1554
  pretty: () => {
1400
- console.log(chalk3.blue("\n\u{1F9FE} Process Variables\n"));
1555
+ console.log(chalk4.blue("\n\u{1F9FE} Process Variables\n"));
1401
1556
  console.log(JSON.stringify(result.data || [], null, 2));
1402
1557
  }
1403
1558
  });
1404
1559
  } catch (error) {
1405
- exitWithCommandError2(spinner, "Failed to fetch process variables", error);
1560
+ exitWithCommandError3(spinner, "Failed to fetch process variables", error);
1406
1561
  }
1407
1562
  }
1408
1563
  async function deleteProcessInstance(client, options) {
@@ -1414,7 +1569,7 @@ async function deleteProcessInstance(client, options) {
1414
1569
  });
1415
1570
  if (result.error) {
1416
1571
  spinner.fail("Failed to delete process instance");
1417
- console.error(chalk3.red(result.error.message));
1572
+ console.error(chalk4.red(result.error.message));
1418
1573
  process.exit(1);
1419
1574
  }
1420
1575
  spinner.succeed("Process instance deleted");
@@ -1427,12 +1582,12 @@ async function deleteProcessInstance(client, options) {
1427
1582
  {
1428
1583
  format: options.format,
1429
1584
  pretty: () => {
1430
- console.log(chalk3.green(`Deleted process instance: ${options.id}`));
1585
+ console.log(chalk4.green(`Deleted process instance: ${options.id}`));
1431
1586
  }
1432
1587
  }
1433
1588
  );
1434
1589
  } catch (error) {
1435
- exitWithCommandError2(spinner, "Failed to delete process instance", error);
1590
+ exitWithCommandError3(spinner, "Failed to delete process instance", error);
1436
1591
  }
1437
1592
  }
1438
1593
  async function suspendProcessInstance(client, options) {
@@ -1442,7 +1597,7 @@ async function suspendProcessInstance(client, options) {
1442
1597
  const result = await bpmClient.suspendProcessInstance(options.id);
1443
1598
  if (result.error) {
1444
1599
  spinner.fail("Failed to suspend process instance");
1445
- console.error(chalk3.red(result.error.message));
1600
+ console.error(chalk4.red(result.error.message));
1446
1601
  process.exit(1);
1447
1602
  }
1448
1603
  spinner.succeed("Process instance suspended");
@@ -1454,12 +1609,12 @@ async function suspendProcessInstance(client, options) {
1454
1609
  {
1455
1610
  format: options.format,
1456
1611
  pretty: () => {
1457
- console.log(chalk3.green(`Suspended process instance: ${options.id}`));
1612
+ console.log(chalk4.green(`Suspended process instance: ${options.id}`));
1458
1613
  }
1459
1614
  }
1460
1615
  );
1461
1616
  } catch (error) {
1462
- exitWithCommandError2(spinner, "Failed to suspend process instance", error);
1617
+ exitWithCommandError3(spinner, "Failed to suspend process instance", error);
1463
1618
  }
1464
1619
  }
1465
1620
  async function activateProcessInstance(client, options) {
@@ -1469,7 +1624,7 @@ async function activateProcessInstance(client, options) {
1469
1624
  const result = await bpmClient.activateProcessInstance(options.id);
1470
1625
  if (result.error) {
1471
1626
  spinner.fail("Failed to activate process instance");
1472
- console.error(chalk3.red(result.error.message));
1627
+ console.error(chalk4.red(result.error.message));
1473
1628
  process.exit(1);
1474
1629
  }
1475
1630
  spinner.succeed("Process instance activated");
@@ -1481,12 +1636,12 @@ async function activateProcessInstance(client, options) {
1481
1636
  {
1482
1637
  format: options.format,
1483
1638
  pretty: () => {
1484
- console.log(chalk3.green(`Activated process instance: ${options.id}`));
1639
+ console.log(chalk4.green(`Activated process instance: ${options.id}`));
1485
1640
  }
1486
1641
  }
1487
1642
  );
1488
1643
  } catch (error) {
1489
- exitWithCommandError2(spinner, "Failed to activate process instance", error);
1644
+ exitWithCommandError3(spinner, "Failed to activate process instance", error);
1490
1645
  }
1491
1646
  }
1492
1647
  async function modifyProcessInstance(client, options) {
@@ -1501,7 +1656,7 @@ async function modifyProcessInstance(client, options) {
1501
1656
  const result = await bpmClient.modifyProcessInstance(options.id, modification);
1502
1657
  if (result.error) {
1503
1658
  spinner.fail("Failed to modify process instance");
1504
- console.error(chalk3.red(result.error.message));
1659
+ console.error(chalk4.red(result.error.message));
1505
1660
  process.exit(1);
1506
1661
  }
1507
1662
  spinner.succeed("Process instance modified");
@@ -1514,12 +1669,12 @@ async function modifyProcessInstance(client, options) {
1514
1669
  {
1515
1670
  format: options.format,
1516
1671
  pretty: () => {
1517
- console.log(chalk3.green(`Modified process instance: ${options.id}`));
1672
+ console.log(chalk4.green(`Modified process instance: ${options.id}`));
1518
1673
  }
1519
1674
  }
1520
1675
  );
1521
1676
  } catch (error) {
1522
- exitWithCommandError2(spinner, "Failed to modify process instance", error);
1677
+ exitWithCommandError3(spinner, "Failed to modify process instance", error);
1523
1678
  }
1524
1679
  }
1525
1680
  async function listTasks(client, options) {
@@ -1530,7 +1685,7 @@ async function listTasks(client, options) {
1530
1685
  const result = await bpmClient.getTasks(params);
1531
1686
  if (result.error) {
1532
1687
  spinner.fail("Failed to fetch tasks");
1533
- console.error(chalk3.red(result.error.message));
1688
+ console.error(chalk4.red(result.error.message));
1534
1689
  process.exit(1);
1535
1690
  }
1536
1691
  spinner.succeed(`Found ${result.data?.length || 0} tasks`);
@@ -1538,19 +1693,19 @@ async function listTasks(client, options) {
1538
1693
  renderOutput(tasks, {
1539
1694
  format: options.format,
1540
1695
  pretty: () => {
1541
- console.log(chalk3.blue("\n\u{1F4DD} Tasks\n"));
1696
+ console.log(chalk4.blue("\n\u{1F4DD} Tasks\n"));
1542
1697
  for (const task of tasks) {
1543
- console.log(` ${chalk3.green("\u2022")} ${chalk3.bold(task.name || task.id)}`);
1544
- console.log(` ${chalk3.gray("ID:")} ${task.id}`);
1545
- console.log(` ${chalk3.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
1546
- console.log(` ${chalk3.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
1547
- console.log(` ${chalk3.gray("Created:")} ${task.created || "N/A"}`);
1698
+ console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(task.name || task.id)}`);
1699
+ console.log(` ${chalk4.gray("ID:")} ${task.id}`);
1700
+ console.log(` ${chalk4.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
1701
+ console.log(` ${chalk4.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
1702
+ console.log(` ${chalk4.gray("Created:")} ${task.created || "N/A"}`);
1548
1703
  console.log();
1549
1704
  }
1550
1705
  }
1551
1706
  });
1552
1707
  } catch (error) {
1553
- exitWithCommandError2(spinner, "Failed to fetch tasks", error);
1708
+ exitWithCommandError3(spinner, "Failed to fetch tasks", error);
1554
1709
  }
1555
1710
  }
1556
1711
  async function getTask(client, options) {
@@ -1560,19 +1715,19 @@ async function getTask(client, options) {
1560
1715
  const result = await bpmClient.getTask(options.id);
1561
1716
  if (result.error) {
1562
1717
  spinner.fail("Failed to fetch task");
1563
- console.error(chalk3.red(result.error.message));
1718
+ console.error(chalk4.red(result.error.message));
1564
1719
  process.exit(1);
1565
1720
  }
1566
1721
  spinner.succeed("Task retrieved");
1567
1722
  renderOutput(result.data, {
1568
1723
  format: options.format,
1569
1724
  pretty: () => {
1570
- console.log(chalk3.blue("\n\u{1F4DD} Task\n"));
1725
+ console.log(chalk4.blue("\n\u{1F4DD} Task\n"));
1571
1726
  console.log(JSON.stringify(result.data, null, 2));
1572
1727
  }
1573
1728
  });
1574
1729
  } catch (error) {
1575
- exitWithCommandError2(spinner, "Failed to fetch task", error);
1730
+ exitWithCommandError3(spinner, "Failed to fetch task", error);
1576
1731
  }
1577
1732
  }
1578
1733
  async function getTaskCount(client, options) {
@@ -1583,18 +1738,18 @@ async function getTaskCount(client, options) {
1583
1738
  const result = await bpmClient.getTaskCount(params);
1584
1739
  if (result.error) {
1585
1740
  spinner.fail("Failed to fetch task count");
1586
- console.error(chalk3.red(result.error.message));
1741
+ console.error(chalk4.red(result.error.message));
1587
1742
  process.exit(1);
1588
1743
  }
1589
1744
  spinner.succeed("Task count retrieved");
1590
1745
  renderOutput(result.data, {
1591
1746
  format: options.format,
1592
1747
  pretty: () => {
1593
- console.log(chalk3.green(`Task count: ${result.data?.count ?? 0}`));
1748
+ console.log(chalk4.green(`Task count: ${result.data?.count ?? 0}`));
1594
1749
  }
1595
1750
  });
1596
1751
  } catch (error) {
1597
- exitWithCommandError2(spinner, "Failed to fetch task count", error);
1752
+ exitWithCommandError3(spinner, "Failed to fetch task count", error);
1598
1753
  }
1599
1754
  }
1600
1755
  async function completeTask(client, options) {
@@ -1605,7 +1760,7 @@ async function completeTask(client, options) {
1605
1760
  const result = await bpmClient.completeTask(options.id, variables);
1606
1761
  if (result.error) {
1607
1762
  spinner.fail("Failed to complete task");
1608
- console.error(chalk3.red(result.error.message));
1763
+ console.error(chalk4.red(result.error.message));
1609
1764
  process.exit(1);
1610
1765
  }
1611
1766
  spinner.succeed("Task completed");
@@ -1617,12 +1772,12 @@ async function completeTask(client, options) {
1617
1772
  {
1618
1773
  format: options.format,
1619
1774
  pretty: () => {
1620
- console.log(chalk3.green(`Completed task: ${options.id}`));
1775
+ console.log(chalk4.green(`Completed task: ${options.id}`));
1621
1776
  }
1622
1777
  }
1623
1778
  );
1624
1779
  } catch (error) {
1625
- exitWithCommandError2(spinner, "Failed to complete task", error);
1780
+ exitWithCommandError3(spinner, "Failed to complete task", error);
1626
1781
  }
1627
1782
  }
1628
1783
  async function delegateTask(client, options) {
@@ -1632,7 +1787,7 @@ async function delegateTask(client, options) {
1632
1787
  const result = await bpmClient.delegateTask(options.id, options.userId);
1633
1788
  if (result.error) {
1634
1789
  spinner.fail("Failed to delegate task");
1635
- console.error(chalk3.red(result.error.message));
1790
+ console.error(chalk4.red(result.error.message));
1636
1791
  process.exit(1);
1637
1792
  }
1638
1793
  spinner.succeed("Task delegated");
@@ -1645,12 +1800,12 @@ async function delegateTask(client, options) {
1645
1800
  {
1646
1801
  format: options.format,
1647
1802
  pretty: () => {
1648
- console.log(chalk3.green(`Delegated task ${options.id} to ${options.userId}`));
1803
+ console.log(chalk4.green(`Delegated task ${options.id} to ${options.userId}`));
1649
1804
  }
1650
1805
  }
1651
1806
  );
1652
1807
  } catch (error) {
1653
- exitWithCommandError2(spinner, "Failed to delegate task", error);
1808
+ exitWithCommandError3(spinner, "Failed to delegate task", error);
1654
1809
  }
1655
1810
  }
1656
1811
  async function getTaskForm(client, options) {
@@ -1660,19 +1815,19 @@ async function getTaskForm(client, options) {
1660
1815
  const result = await bpmClient.getTaskForm(options.id);
1661
1816
  if (result.error) {
1662
1817
  spinner.fail("Failed to fetch task form");
1663
- console.error(chalk3.red(result.error.message));
1818
+ console.error(chalk4.red(result.error.message));
1664
1819
  process.exit(1);
1665
1820
  }
1666
1821
  spinner.succeed("Task form retrieved");
1667
1822
  renderOutput(result.data, {
1668
1823
  format: options.format,
1669
1824
  pretty: () => {
1670
- console.log(chalk3.blue("\n\u{1F9E9} Task Form\n"));
1825
+ console.log(chalk4.blue("\n\u{1F9E9} Task Form\n"));
1671
1826
  console.log(JSON.stringify(result.data, null, 2));
1672
1827
  }
1673
1828
  });
1674
1829
  } catch (error) {
1675
- exitWithCommandError2(spinner, "Failed to fetch task form", error);
1830
+ exitWithCommandError3(spinner, "Failed to fetch task form", error);
1676
1831
  }
1677
1832
  }
1678
1833
  async function getTaskFormSchema(client, options) {
@@ -1695,12 +1850,12 @@ async function getTaskFormSchema(client, options) {
1695
1850
  renderOutput(result.data, {
1696
1851
  format: options.format,
1697
1852
  pretty: () => {
1698
- console.log(chalk3.blue("\n\u{1F9E9} Task Form Schema\n"));
1853
+ console.log(chalk4.blue("\n\u{1F9E9} Task Form Schema\n"));
1699
1854
  console.log(JSON.stringify(result.data, null, 2));
1700
1855
  }
1701
1856
  });
1702
1857
  } catch (error) {
1703
- exitWithCommandError2(spinner, "Failed to fetch task form schema", error);
1858
+ exitWithCommandError3(spinner, "Failed to fetch task form schema", error);
1704
1859
  }
1705
1860
  }
1706
1861
  async function getTaskFormVariables(client, options) {
@@ -1710,19 +1865,19 @@ async function getTaskFormVariables(client, options) {
1710
1865
  const result = await bpmClient.getTaskFormVariables(options.id);
1711
1866
  if (result.error) {
1712
1867
  spinner.fail("Failed to fetch task form variables");
1713
- console.error(chalk3.red(result.error.message));
1868
+ console.error(chalk4.red(result.error.message));
1714
1869
  process.exit(1);
1715
1870
  }
1716
1871
  spinner.succeed("Task form variables retrieved");
1717
1872
  renderOutput(result.data, {
1718
1873
  format: options.format,
1719
1874
  pretty: () => {
1720
- console.log(chalk3.blue("\n\u{1F9EE} Task Form Variables\n"));
1875
+ console.log(chalk4.blue("\n\u{1F9EE} Task Form Variables\n"));
1721
1876
  console.log(JSON.stringify(result.data, null, 2));
1722
1877
  }
1723
1878
  });
1724
1879
  } catch (error) {
1725
- exitWithCommandError2(spinner, "Failed to fetch task form variables", error);
1880
+ exitWithCommandError3(spinner, "Failed to fetch task form variables", error);
1726
1881
  }
1727
1882
  }
1728
1883
  async function getTaskRenderedForm(client, options) {
@@ -1732,19 +1887,19 @@ async function getTaskRenderedForm(client, options) {
1732
1887
  const result = await bpmClient.getTaskRenderedForm(options.id);
1733
1888
  if (result.error) {
1734
1889
  spinner.fail("Failed to fetch rendered task form");
1735
- console.error(chalk3.red(result.error.message));
1890
+ console.error(chalk4.red(result.error.message));
1736
1891
  process.exit(1);
1737
1892
  }
1738
1893
  spinner.succeed("Rendered task form retrieved");
1739
1894
  renderOutput(result.data, {
1740
1895
  format: options.format,
1741
1896
  pretty: () => {
1742
- console.log(chalk3.blue("\n\u{1F9FE} Rendered Task Form\n"));
1897
+ console.log(chalk4.blue("\n\u{1F9FE} Rendered Task Form\n"));
1743
1898
  console.log(result.data || "");
1744
1899
  }
1745
1900
  });
1746
1901
  } catch (error) {
1747
- exitWithCommandError2(spinner, "Failed to fetch rendered task form", error);
1902
+ exitWithCommandError3(spinner, "Failed to fetch rendered task form", error);
1748
1903
  }
1749
1904
  }
1750
1905
  async function getTaskDeployedForm(client, options) {
@@ -1754,19 +1909,19 @@ async function getTaskDeployedForm(client, options) {
1754
1909
  const result = await bpmClient.getTaskDeployedForm(options.id);
1755
1910
  if (result.error) {
1756
1911
  spinner.fail("Failed to fetch deployed task form");
1757
- console.error(chalk3.red(result.error.message));
1912
+ console.error(chalk4.red(result.error.message));
1758
1913
  process.exit(1);
1759
1914
  }
1760
1915
  spinner.succeed("Deployed task form retrieved");
1761
1916
  renderOutput(result.data, {
1762
1917
  format: options.format,
1763
1918
  pretty: () => {
1764
- console.log(chalk3.blue("\n\u{1F9FE} Deployed Task Form\n"));
1919
+ console.log(chalk4.blue("\n\u{1F9FE} Deployed Task Form\n"));
1765
1920
  console.log(JSON.stringify(result.data, null, 2));
1766
1921
  }
1767
1922
  });
1768
1923
  } catch (error) {
1769
- exitWithCommandError2(spinner, "Failed to fetch deployed task form", error);
1924
+ exitWithCommandError3(spinner, "Failed to fetch deployed task form", error);
1770
1925
  }
1771
1926
  }
1772
1927
  async function getStartFormInfo(client, options) {
@@ -1786,12 +1941,12 @@ async function getStartFormInfo(client, options) {
1786
1941
  renderOutput(result.data, {
1787
1942
  format: options.format,
1788
1943
  pretty: () => {
1789
- console.log(chalk3.blue("\n\u{1F680} Start Form Info\n"));
1944
+ console.log(chalk4.blue("\n\u{1F680} Start Form Info\n"));
1790
1945
  console.log(JSON.stringify(result.data, null, 2));
1791
1946
  }
1792
1947
  });
1793
1948
  } catch (error) {
1794
- exitWithCommandError2(spinner, "Failed to fetch start form info", error);
1949
+ exitWithCommandError3(spinner, "Failed to fetch start form info", error);
1795
1950
  }
1796
1951
  }
1797
1952
  async function getStartFormVariables(client, options) {
@@ -1811,12 +1966,12 @@ async function getStartFormVariables(client, options) {
1811
1966
  renderOutput(result.data, {
1812
1967
  format: options.format,
1813
1968
  pretty: () => {
1814
- console.log(chalk3.blue("\n\u{1F680} Start Form Variables\n"));
1969
+ console.log(chalk4.blue("\n\u{1F680} Start Form Variables\n"));
1815
1970
  console.log(JSON.stringify(result.data, null, 2));
1816
1971
  }
1817
1972
  });
1818
1973
  } catch (error) {
1819
- exitWithCommandError2(spinner, "Failed to fetch start form variables", error);
1974
+ exitWithCommandError3(spinner, "Failed to fetch start form variables", error);
1820
1975
  }
1821
1976
  }
1822
1977
  async function getDeployedStartForm(client, options) {
@@ -1836,12 +1991,12 @@ async function getDeployedStartForm(client, options) {
1836
1991
  renderOutput(result.data, {
1837
1992
  format: options.format,
1838
1993
  pretty: () => {
1839
- console.log(chalk3.blue("\n\u{1F680} Deployed Start Form\n"));
1994
+ console.log(chalk4.blue("\n\u{1F680} Deployed Start Form\n"));
1840
1995
  console.log(JSON.stringify(result.data, null, 2));
1841
1996
  }
1842
1997
  });
1843
1998
  } catch (error) {
1844
- exitWithCommandError2(spinner, "Failed to fetch deployed start form", error);
1999
+ exitWithCommandError3(spinner, "Failed to fetch deployed start form", error);
1845
2000
  }
1846
2001
  }
1847
2002
  async function listHistoryTasks(client, options = {}) {
@@ -1852,7 +2007,7 @@ async function listHistoryTasks(client, options = {}) {
1852
2007
  const result = await bpmClient.getHistoryTasks(params);
1853
2008
  if (result.error) {
1854
2009
  spinner.fail("Failed to fetch history tasks");
1855
- console.error(chalk3.red(result.error.message));
2010
+ console.error(chalk4.red(result.error.message));
1856
2011
  process.exit(1);
1857
2012
  }
1858
2013
  const tasks = result.data || [];
@@ -1860,12 +2015,12 @@ async function listHistoryTasks(client, options = {}) {
1860
2015
  renderOutput(tasks, {
1861
2016
  format: options.format,
1862
2017
  pretty: () => {
1863
- console.log(chalk3.blue("\n\u{1F4DA} History Tasks\n"));
2018
+ console.log(chalk4.blue("\n\u{1F4DA} History Tasks\n"));
1864
2019
  console.log(JSON.stringify(tasks, null, 2));
1865
2020
  }
1866
2021
  });
1867
2022
  } catch (error) {
1868
- exitWithCommandError2(spinner, "Failed to fetch history tasks", error);
2023
+ exitWithCommandError3(spinner, "Failed to fetch history tasks", error);
1869
2024
  }
1870
2025
  }
1871
2026
  async function getHistoryTaskCount(client, options = {}) {
@@ -1876,18 +2031,18 @@ async function getHistoryTaskCount(client, options = {}) {
1876
2031
  const result = await bpmClient.getHistoryTaskCount(params);
1877
2032
  if (result.error) {
1878
2033
  spinner.fail("Failed to fetch history task count");
1879
- console.error(chalk3.red(result.error.message));
2034
+ console.error(chalk4.red(result.error.message));
1880
2035
  process.exit(1);
1881
2036
  }
1882
2037
  spinner.succeed("History task count retrieved");
1883
2038
  renderOutput(result.data, {
1884
2039
  format: options.format,
1885
2040
  pretty: () => {
1886
- console.log(chalk3.green(`History task count: ${result.data?.count ?? 0}`));
2041
+ console.log(chalk4.green(`History task count: ${result.data?.count ?? 0}`));
1887
2042
  }
1888
2043
  });
1889
2044
  } catch (error) {
1890
- exitWithCommandError2(spinner, "Failed to fetch history task count", error);
2045
+ exitWithCommandError3(spinner, "Failed to fetch history task count", error);
1891
2046
  }
1892
2047
  }
1893
2048
  async function listHistoryProcessInstances(client, options = {}) {
@@ -1898,7 +2053,7 @@ async function listHistoryProcessInstances(client, options = {}) {
1898
2053
  const result = await bpmClient.getHistoryProcessInstances(params);
1899
2054
  if (result.error) {
1900
2055
  spinner.fail("Failed to fetch history process instances");
1901
- console.error(chalk3.red(result.error.message));
2056
+ console.error(chalk4.red(result.error.message));
1902
2057
  process.exit(1);
1903
2058
  }
1904
2059
  const instances = result.data || [];
@@ -1906,12 +2061,12 @@ async function listHistoryProcessInstances(client, options = {}) {
1906
2061
  renderOutput(instances, {
1907
2062
  format: options.format,
1908
2063
  pretty: () => {
1909
- console.log(chalk3.blue("\n\u{1F4DA} History Process Instances\n"));
2064
+ console.log(chalk4.blue("\n\u{1F4DA} History Process Instances\n"));
1910
2065
  console.log(JSON.stringify(instances, null, 2));
1911
2066
  }
1912
2067
  });
1913
2068
  } catch (error) {
1914
- exitWithCommandError2(spinner, "Failed to fetch history process instances", error);
2069
+ exitWithCommandError3(spinner, "Failed to fetch history process instances", error);
1915
2070
  }
1916
2071
  }
1917
2072
  async function getHistoryProcessInstanceCount(client, options = {}) {
@@ -1922,18 +2077,18 @@ async function getHistoryProcessInstanceCount(client, options = {}) {
1922
2077
  const result = await bpmClient.getHistoryProcessInstanceCount(params);
1923
2078
  if (result.error) {
1924
2079
  spinner.fail("Failed to fetch history process instance count");
1925
- console.error(chalk3.red(result.error.message));
2080
+ console.error(chalk4.red(result.error.message));
1926
2081
  process.exit(1);
1927
2082
  }
1928
2083
  spinner.succeed("History process instance count retrieved");
1929
2084
  renderOutput(result.data, {
1930
2085
  format: options.format,
1931
2086
  pretty: () => {
1932
- console.log(chalk3.green(`History process instance count: ${result.data?.count ?? 0}`));
2087
+ console.log(chalk4.green(`History process instance count: ${result.data?.count ?? 0}`));
1933
2088
  }
1934
2089
  });
1935
2090
  } catch (error) {
1936
- exitWithCommandError2(spinner, "Failed to fetch history process instance count", error);
2091
+ exitWithCommandError3(spinner, "Failed to fetch history process instance count", error);
1937
2092
  }
1938
2093
  }
1939
2094
  async function getHistoryProcessInstance(client, options) {
@@ -1943,19 +2098,19 @@ async function getHistoryProcessInstance(client, options) {
1943
2098
  const result = await bpmClient.getHistoryProcessInstance(options.id);
1944
2099
  if (result.error) {
1945
2100
  spinner.fail("Failed to fetch history process instance");
1946
- console.error(chalk3.red(result.error.message));
2101
+ console.error(chalk4.red(result.error.message));
1947
2102
  process.exit(1);
1948
2103
  }
1949
2104
  spinner.succeed("History process instance retrieved");
1950
2105
  renderOutput(result.data, {
1951
2106
  format: options.format,
1952
2107
  pretty: () => {
1953
- console.log(chalk3.blue("\n\u{1F4DA} History Process Instance\n"));
2108
+ console.log(chalk4.blue("\n\u{1F4DA} History Process Instance\n"));
1954
2109
  console.log(JSON.stringify(result.data, null, 2));
1955
2110
  }
1956
2111
  });
1957
2112
  } catch (error) {
1958
- exitWithCommandError2(spinner, "Failed to fetch history process instance", error);
2113
+ exitWithCommandError3(spinner, "Failed to fetch history process instance", error);
1959
2114
  }
1960
2115
  }
1961
2116
  async function listHistoryActivityInstances(client, options = {}) {
@@ -1966,7 +2121,7 @@ async function listHistoryActivityInstances(client, options = {}) {
1966
2121
  const result = await bpmClient.getHistoryActivityInstances(params);
1967
2122
  if (result.error) {
1968
2123
  spinner.fail("Failed to fetch history activity instances");
1969
- console.error(chalk3.red(result.error.message));
2124
+ console.error(chalk4.red(result.error.message));
1970
2125
  process.exit(1);
1971
2126
  }
1972
2127
  const activities = result.data || [];
@@ -1974,12 +2129,12 @@ async function listHistoryActivityInstances(client, options = {}) {
1974
2129
  renderOutput(activities, {
1975
2130
  format: options.format,
1976
2131
  pretty: () => {
1977
- console.log(chalk3.blue("\n\u{1F4DA} History Activity Instances\n"));
2132
+ console.log(chalk4.blue("\n\u{1F4DA} History Activity Instances\n"));
1978
2133
  console.log(JSON.stringify(activities, null, 2));
1979
2134
  }
1980
2135
  });
1981
2136
  } catch (error) {
1982
- exitWithCommandError2(spinner, "Failed to fetch history activity instances", error);
2137
+ exitWithCommandError3(spinner, "Failed to fetch history activity instances", error);
1983
2138
  }
1984
2139
  }
1985
2140
  async function listHistoryVariableInstances(client, options = {}) {
@@ -1990,7 +2145,7 @@ async function listHistoryVariableInstances(client, options = {}) {
1990
2145
  const result = await bpmClient.getHistoryVariableInstances(params);
1991
2146
  if (result.error) {
1992
2147
  spinner.fail("Failed to fetch history variable instances");
1993
- console.error(chalk3.red(result.error.message));
2148
+ console.error(chalk4.red(result.error.message));
1994
2149
  process.exit(1);
1995
2150
  }
1996
2151
  const variables = result.data || [];
@@ -1998,12 +2153,12 @@ async function listHistoryVariableInstances(client, options = {}) {
1998
2153
  renderOutput(variables, {
1999
2154
  format: options.format,
2000
2155
  pretty: () => {
2001
- console.log(chalk3.blue("\n\u{1F4DA} History Variable Instances\n"));
2156
+ console.log(chalk4.blue("\n\u{1F4DA} History Variable Instances\n"));
2002
2157
  console.log(JSON.stringify(variables, null, 2));
2003
2158
  }
2004
2159
  });
2005
2160
  } catch (error) {
2006
- exitWithCommandError2(spinner, "Failed to fetch history variable instances", error);
2161
+ exitWithCommandError3(spinner, "Failed to fetch history variable instances", error);
2007
2162
  }
2008
2163
  }
2009
2164
  async function listUserOperationLogs(client, options = {}) {
@@ -2014,7 +2169,7 @@ async function listUserOperationLogs(client, options = {}) {
2014
2169
  const result = await bpmClient.getUserOperationLogs(params);
2015
2170
  if (result.error) {
2016
2171
  spinner.fail("Failed to fetch user operation logs");
2017
- console.error(chalk3.red(result.error.message));
2172
+ console.error(chalk4.red(result.error.message));
2018
2173
  process.exit(1);
2019
2174
  }
2020
2175
  const logs = result.data || [];
@@ -2022,12 +2177,12 @@ async function listUserOperationLogs(client, options = {}) {
2022
2177
  renderOutput(logs, {
2023
2178
  format: options.format,
2024
2179
  pretty: () => {
2025
- console.log(chalk3.blue("\n\u{1F4DA} User Operation Logs\n"));
2180
+ console.log(chalk4.blue("\n\u{1F4DA} User Operation Logs\n"));
2026
2181
  console.log(JSON.stringify(logs, null, 2));
2027
2182
  }
2028
2183
  });
2029
2184
  } catch (error) {
2030
- exitWithCommandError2(spinner, "Failed to fetch user operation logs", error);
2185
+ exitWithCommandError3(spinner, "Failed to fetch user operation logs", error);
2031
2186
  }
2032
2187
  }
2033
2188
  async function deleteHistoryProcessInstance(client, options) {
@@ -2037,7 +2192,7 @@ async function deleteHistoryProcessInstance(client, options) {
2037
2192
  const result = await bpmClient.deleteHistoryProcessInstance(options.id);
2038
2193
  if (result.error) {
2039
2194
  spinner.fail("Failed to delete history process instance");
2040
- console.error(chalk3.red(result.error.message));
2195
+ console.error(chalk4.red(result.error.message));
2041
2196
  process.exit(1);
2042
2197
  }
2043
2198
  spinner.succeed("History process instance deleted");
@@ -2049,12 +2204,12 @@ async function deleteHistoryProcessInstance(client, options) {
2049
2204
  {
2050
2205
  format: options.format,
2051
2206
  pretty: () => {
2052
- console.log(chalk3.green(`Deleted history process instance: ${options.id}`));
2207
+ console.log(chalk4.green(`Deleted history process instance: ${options.id}`));
2053
2208
  }
2054
2209
  }
2055
2210
  );
2056
2211
  } catch (error) {
2057
- exitWithCommandError2(spinner, "Failed to delete history process instance", error);
2212
+ exitWithCommandError3(spinner, "Failed to delete history process instance", error);
2058
2213
  }
2059
2214
  }
2060
2215
  async function listRoles(client, options = {}) {
@@ -2064,7 +2219,7 @@ async function listRoles(client, options = {}) {
2064
2219
  const result = await bpmClient.getRoles();
2065
2220
  if (result.error) {
2066
2221
  spinner.fail("Failed to fetch roles");
2067
- console.error(chalk3.red(result.error.message));
2222
+ console.error(chalk4.red(result.error.message));
2068
2223
  process.exit(1);
2069
2224
  }
2070
2225
  const roles = result.data || [];
@@ -2072,12 +2227,12 @@ async function listRoles(client, options = {}) {
2072
2227
  renderOutput(roles, {
2073
2228
  format: options.format,
2074
2229
  pretty: () => {
2075
- console.log(chalk3.blue("\n\u{1F465} Roles\n"));
2230
+ console.log(chalk4.blue("\n\u{1F465} Roles\n"));
2076
2231
  console.log(JSON.stringify(roles, null, 2));
2077
2232
  }
2078
2233
  });
2079
2234
  } catch (error) {
2080
- exitWithCommandError2(spinner, "Failed to fetch roles", error);
2235
+ exitWithCommandError3(spinner, "Failed to fetch roles", error);
2081
2236
  }
2082
2237
  }
2083
2238
  async function getUserRoles(client, options) {
@@ -2087,7 +2242,7 @@ async function getUserRoles(client, options) {
2087
2242
  const result = await bpmClient.getUserRoles(options.userId);
2088
2243
  if (result.error) {
2089
2244
  spinner.fail("Failed to fetch user roles");
2090
- console.error(chalk3.red(result.error.message));
2245
+ console.error(chalk4.red(result.error.message));
2091
2246
  process.exit(1);
2092
2247
  }
2093
2248
  const roles = result.data || [];
@@ -2095,17 +2250,17 @@ async function getUserRoles(client, options) {
2095
2250
  renderOutput(roles, {
2096
2251
  format: options.format,
2097
2252
  pretty: () => {
2098
- console.log(chalk3.blue(`
2253
+ console.log(chalk4.blue(`
2099
2254
  \u{1F464} User Roles: ${options.userId}
2100
2255
  `));
2101
2256
  console.log(JSON.stringify(roles, null, 2));
2102
2257
  }
2103
2258
  });
2104
2259
  } catch (error) {
2105
- exitWithCommandError2(spinner, "Failed to fetch user roles", error);
2260
+ exitWithCommandError3(spinner, "Failed to fetch user roles", error);
2106
2261
  }
2107
2262
  }
2108
- function resolveInputSource3(input) {
2263
+ function resolveInputSource4(input) {
2109
2264
  if (!input.startsWith("@")) {
2110
2265
  return input;
2111
2266
  }
@@ -2116,7 +2271,7 @@ function resolveInputSource3(input) {
2116
2271
  return readFileSync(filePath, "utf8");
2117
2272
  }
2118
2273
  function parseJsonInput3(input, label) {
2119
- const source = resolveInputSource3(input).trim();
2274
+ const source = resolveInputSource4(input).trim();
2120
2275
  if (!source) {
2121
2276
  throw new Error(`${label} is required.`);
2122
2277
  }
@@ -2150,11 +2305,11 @@ function loadOptionalJsonArrayInput(input, label) {
2150
2305
  }
2151
2306
  return value;
2152
2307
  }
2153
- function exitWithCommandError3(spinner, failureMessage, error) {
2308
+ function exitWithCommandError4(spinner, failureMessage, error) {
2154
2309
  spinner.fail(failureMessage);
2155
2310
  const details = error instanceof Error ? error.message : String(error);
2156
2311
  if (details) {
2157
- console.error(chalk3.red(details));
2312
+ console.error(chalk4.red(details));
2158
2313
  }
2159
2314
  process.exit(1);
2160
2315
  }
@@ -2189,26 +2344,26 @@ async function runWorkflow(client, options) {
2189
2344
  const result = await workflowClient.run(options.name, request);
2190
2345
  if (result.error) {
2191
2346
  spinner.fail("Failed to run workflow");
2192
- console.error(chalk3.red(result.error.message));
2347
+ console.error(chalk4.red(result.error.message));
2193
2348
  process.exit(1);
2194
2349
  }
2195
2350
  spinner.succeed("Workflow completed");
2196
2351
  renderOutput(result.data, {
2197
2352
  format: options.format,
2198
2353
  pretty: () => {
2199
- console.log(chalk3.blue("\n\u26A1 Workflow Run\n"));
2354
+ console.log(chalk4.blue("\n\u26A1 Workflow Run\n"));
2200
2355
  console.log(JSON.stringify(result.data, null, 2));
2201
2356
  }
2202
2357
  });
2203
2358
  } catch (error) {
2204
- exitWithCommandError3(spinner, "Failed to run workflow", error);
2359
+ exitWithCommandError4(spinner, "Failed to run workflow", error);
2205
2360
  }
2206
2361
  }
2207
- function exitWithCommandError4(spinner, failureMessage, error) {
2362
+ function exitWithCommandError5(spinner, failureMessage, error) {
2208
2363
  spinner.fail(failureMessage);
2209
2364
  const details = error instanceof Error ? error.message : String(error);
2210
2365
  if (details) {
2211
- console.error(chalk3.red(details));
2366
+ console.error(chalk4.red(details));
2212
2367
  }
2213
2368
  process.exit(1);
2214
2369
  }
@@ -2247,20 +2402,20 @@ async function uploadFile(client, options) {
2247
2402
  const result = await s3Client.upload(file);
2248
2403
  if (result.error) {
2249
2404
  spinner.fail("Upload failed");
2250
- console.error(chalk3.red(result.error.message));
2405
+ console.error(chalk4.red(result.error.message));
2251
2406
  process.exit(1);
2252
2407
  }
2253
2408
  spinner.succeed("Upload complete");
2254
2409
  renderOutput(result.data, {
2255
2410
  format: options.format,
2256
2411
  pretty: () => {
2257
- console.log(chalk3.green("\nFile uploaded:"));
2258
- console.log(` ${chalk3.bold("Key:")} ${result.data?.key}`);
2259
- console.log(` ${chalk3.bold("URL:")} ${result.data?.url || "N/A"}`);
2412
+ console.log(chalk4.green("\nFile uploaded:"));
2413
+ console.log(` ${chalk4.bold("Key:")} ${result.data?.key}`);
2414
+ console.log(` ${chalk4.bold("URL:")} ${result.data?.url || "N/A"}`);
2260
2415
  }
2261
2416
  });
2262
2417
  } catch (error) {
2263
- exitWithCommandError4(spinner, "Upload failed", error);
2418
+ exitWithCommandError5(spinner, "Upload failed", error);
2264
2419
  }
2265
2420
  }
2266
2421
  async function downloadFile(client, options) {
@@ -2270,12 +2425,12 @@ async function downloadFile(client, options) {
2270
2425
  const result = await s3Client.download(options.key);
2271
2426
  if (result.error) {
2272
2427
  spinner.fail("Download failed");
2273
- console.error(chalk3.red(result.error.message));
2428
+ console.error(chalk4.red(result.error.message));
2274
2429
  process.exit(1);
2275
2430
  }
2276
2431
  if (!result.data) {
2277
2432
  spinner.fail("Download failed");
2278
- console.error(chalk3.red("Empty file response."));
2433
+ console.error(chalk4.red("Empty file response."));
2279
2434
  process.exit(1);
2280
2435
  }
2281
2436
  const outputPath = resolve(options.output);
@@ -2291,13 +2446,13 @@ async function downloadFile(client, options) {
2291
2446
  {
2292
2447
  format: options.format,
2293
2448
  pretty: () => {
2294
- console.log(chalk3.green(`
2449
+ console.log(chalk4.green(`
2295
2450
  File saved to: ${outputPath}`));
2296
2451
  }
2297
2452
  }
2298
2453
  );
2299
2454
  } catch (error) {
2300
- exitWithCommandError4(spinner, "Download failed", error);
2455
+ exitWithCommandError5(spinner, "Download failed", error);
2301
2456
  }
2302
2457
  }
2303
2458
  async function getFileMetadata(client, options) {
@@ -2307,21 +2462,21 @@ async function getFileMetadata(client, options) {
2307
2462
  const result = await s3Client.getMetadata(options.key);
2308
2463
  if (result.error) {
2309
2464
  spinner.fail("Failed to fetch metadata");
2310
- console.error(chalk3.red(result.error.message));
2465
+ console.error(chalk4.red(result.error.message));
2311
2466
  process.exit(1);
2312
2467
  }
2313
2468
  spinner.succeed("Metadata retrieved");
2314
2469
  renderOutput(result.data, {
2315
2470
  format: options.format,
2316
2471
  pretty: () => {
2317
- console.log(chalk3.blue(`
2472
+ console.log(chalk4.blue(`
2318
2473
  \u{1F4C4} Metadata for ${options.key}
2319
2474
  `));
2320
2475
  console.log(JSON.stringify(result.data, null, 2));
2321
2476
  }
2322
2477
  });
2323
2478
  } catch (error) {
2324
- exitWithCommandError4(spinner, "Failed to fetch metadata", error);
2479
+ exitWithCommandError5(spinner, "Failed to fetch metadata", error);
2325
2480
  }
2326
2481
  }
2327
2482
 
@@ -2362,8 +2517,8 @@ async function initOpenClaw(options) {
2362
2517
  const existingConfig = getAppConfig(options.appCode);
2363
2518
  if (existingConfig && !options.force) {
2364
2519
  spinner.fail(`App already exists: ${options.appCode}`);
2365
- console.log(chalk3.yellow(`Use --force to reinitialize`));
2366
- console.log(chalk3.gray(`Current URL: ${existingConfig.baseURL}`));
2520
+ console.log(chalk4.yellow(`Use --force to reinitialize`));
2521
+ console.log(chalk4.gray(`Current URL: ${existingConfig.baseURL}`));
2367
2522
  process.exit(1);
2368
2523
  }
2369
2524
  addApp(options.appCode, {
@@ -2374,8 +2529,8 @@ async function initOpenClaw(options) {
2374
2529
  if (!openClawDetected) {
2375
2530
  spinner.succeed(`App initialized: ${options.appCode}`);
2376
2531
  if (pretty) {
2377
- console.log(chalk3.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
2378
- console.log(chalk3.gray(" Install OpenClaw: npm install -g openclaw"));
2532
+ console.log(chalk4.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
2533
+ console.log(chalk4.gray(" Install OpenClaw: npm install -g openclaw"));
2379
2534
  } else {
2380
2535
  renderOutput(
2381
2536
  {
@@ -2393,9 +2548,9 @@ async function initOpenClaw(options) {
2393
2548
  }
2394
2549
  spinner.succeed(`App initialized: ${options.appCode}`);
2395
2550
  if (pretty) {
2396
- console.log(chalk3.blue("\n\u{1F4CB} Configuration:\n"));
2397
- console.log(` App Code: ${chalk3.green(options.appCode)}`);
2398
- console.log(` Base URL: ${chalk3.gray(options.baseURL)}`);
2551
+ console.log(chalk4.blue("\n\u{1F4CB} Configuration:\n"));
2552
+ console.log(` App Code: ${chalk4.green(options.appCode)}`);
2553
+ console.log(` Base URL: ${chalk4.gray(options.baseURL)}`);
2399
2554
  console.log();
2400
2555
  }
2401
2556
  spinner.start("Downloading skills...");
@@ -2467,16 +2622,16 @@ async function initOpenClaw(options) {
2467
2622
  };
2468
2623
  if (pretty) {
2469
2624
  console.log();
2470
- console.log(chalk3.green("\u2705 Initialization complete!"));
2625
+ console.log(chalk4.green("\u2705 Initialization complete!"));
2471
2626
  console.log();
2472
2627
  console.log(`Next step: Login to your app`);
2473
- console.log(chalk3.gray(` amaster login --app ${options.appCode}`));
2628
+ console.log(chalk4.gray(` amaster login --app ${options.appCode}`));
2474
2629
  console.log();
2475
2630
  if (apps.length > 1) {
2476
- console.log(chalk3.blue("Configured apps:"));
2631
+ console.log(chalk4.blue("Configured apps:"));
2477
2632
  for (const app of apps) {
2478
2633
  const config = getAppConfig(app);
2479
- console.log(` ${chalk3.gray("\u2022")} ${app} - ${config?.baseURL}`);
2634
+ console.log(` ${chalk4.gray("\u2022")} ${app} - ${config?.baseURL}`);
2480
2635
  }
2481
2636
  console.log();
2482
2637
  }
@@ -2577,6 +2732,14 @@ async function downloadMcpConfig(ossEndpoint, appCode) {
2577
2732
  }
2578
2733
 
2579
2734
  // src/cli.ts
2735
+ function resolveCliVersion() {
2736
+ try {
2737
+ const packageJsonUrl = new URL("../package.json", import.meta.url);
2738
+ return JSON.parse(readFileSync(packageJsonUrl, "utf-8")).version || "0.0.0";
2739
+ } catch {
2740
+ return "0.0.0";
2741
+ }
2742
+ }
2580
2743
  function resolveAppCode(optionsApp) {
2581
2744
  if (optionsApp) {
2582
2745
  return optionsApp;
@@ -2585,22 +2748,22 @@ function resolveAppCode(optionsApp) {
2585
2748
  if (defaultApp) {
2586
2749
  return defaultApp;
2587
2750
  }
2588
- console.error(chalk3.red("\u274C No app specified."));
2589
- console.log(chalk3.yellow("Use one of:"));
2590
- console.log(chalk3.gray(" 1. Add --app <app-code> to the command"));
2591
- console.log(chalk3.gray(" 2. Set a default app: amaster use <app-code>"));
2751
+ console.error(chalk4.red("\u274C No app specified."));
2752
+ console.log(chalk4.yellow("Use one of:"));
2753
+ console.log(chalk4.gray(" 1. Add --app <app-code> to the command"));
2754
+ console.log(chalk4.gray(" 2. Set a default app: amaster use <app-code>"));
2592
2755
  process.exit(1);
2593
2756
  }
2594
2757
  function createAmasterClient(appCode) {
2595
2758
  const appConfig = getAppConfig(appCode);
2596
2759
  if (!appConfig) {
2597
- console.error(chalk3.red(`\u274C App not configured: ${appCode}`));
2598
- console.log(chalk3.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
2760
+ console.error(chalk4.red(`\u274C App not configured: ${appCode}`));
2761
+ console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
2599
2762
  process.exit(1);
2600
2763
  }
2601
2764
  const token = getAccessToken(appCode);
2602
2765
  if (token && shouldRefreshToken(appCode)) {
2603
- console.error(chalk3.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
2766
+ console.error(chalk4.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
2604
2767
  }
2605
2768
  const client = createClient({
2606
2769
  baseURL: appConfig.baseURL,
@@ -2611,12 +2774,12 @@ function createAmasterClient(appCode) {
2611
2774
  } : {},
2612
2775
  onUnauthorized: () => {
2613
2776
  if (token) {
2614
- console.error(chalk3.red("\n\u274C Session expired. Please login again."));
2615
- console.error(chalk3.yellow(`Run: amaster login --app ${appCode}`));
2777
+ console.error(chalk4.red("\n\u274C Session expired. Please login again."));
2778
+ console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
2616
2779
  } else {
2617
- console.error(chalk3.red(`
2780
+ console.error(chalk4.red(`
2618
2781
  \u274C Authentication required for app: ${appCode}`));
2619
- console.error(chalk3.yellow(`Run: amaster login --app ${appCode}`));
2782
+ console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
2620
2783
  }
2621
2784
  process.exit(1);
2622
2785
  }
@@ -2627,7 +2790,7 @@ function createAmasterClient(appCode) {
2627
2790
  return client;
2628
2791
  }
2629
2792
  var program = new Command();
2630
- program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version("1.0.0");
2793
+ program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version(resolveCliVersion());
2631
2794
  program.command("apps").description("List all configured apps").addOption(createFormatOption()).action((options) => {
2632
2795
  const apps = listApps();
2633
2796
  const current = getCurrentApp();
@@ -2643,17 +2806,17 @@ program.command("apps").description("List all configured apps").addOption(create
2643
2806
  renderOutput(appSummaries, {
2644
2807
  format: options.format,
2645
2808
  pretty: () => {
2646
- console.log(chalk3.blue("\n\u{1F4F1} Configured Apps\n"));
2809
+ console.log(chalk4.blue("\n\u{1F4F1} Configured Apps\n"));
2647
2810
  if (appSummaries.length === 0) {
2648
- console.log(chalk3.gray(" No apps configured"));
2649
- console.log(chalk3.gray(" Run: amaster init --app-code <code> --url <url>"));
2811
+ console.log(chalk4.gray(" No apps configured"));
2812
+ console.log(chalk4.gray(" Run: amaster init --app-code <code> --url <url>"));
2650
2813
  } else {
2651
2814
  for (const app of appSummaries) {
2652
- const prefix = app.current ? chalk3.green("\u2192 ") : " ";
2653
- console.log(`${prefix}${chalk3.bold(app.appCode)}${app.current ? chalk3.green(" (current)") : ""}`);
2654
- console.log(` ${chalk3.gray(app.baseURL || "No URL")}`);
2815
+ const prefix = app.current ? chalk4.green("\u2192 ") : " ";
2816
+ console.log(`${prefix}${chalk4.bold(app.appCode)}${app.current ? chalk4.green(" (current)") : ""}`);
2817
+ console.log(` ${chalk4.gray(app.baseURL || "No URL")}`);
2655
2818
  console.log(
2656
- ` ${app.authenticated ? chalk3.green("\u25CF Authenticated") : chalk3.yellow("\u25CB Not authenticated")}`
2819
+ ` ${app.authenticated ? chalk4.green("\u25CF Authenticated") : chalk4.yellow("\u25CB Not authenticated")}`
2657
2820
  );
2658
2821
  console.log();
2659
2822
  }
@@ -2672,12 +2835,12 @@ program.command("use <app-code>").description("Set the default app for subsequen
2672
2835
  {
2673
2836
  format: options.format,
2674
2837
  pretty: () => {
2675
- console.log(chalk3.green(`\u2705 Now using app: ${appCode}`));
2838
+ console.log(chalk4.green(`\u2705 Now using app: ${appCode}`));
2676
2839
  }
2677
2840
  }
2678
2841
  );
2679
2842
  } else {
2680
- console.error(chalk3.red(`\u274C App not found: ${appCode}`));
2843
+ console.error(chalk4.red(`\u274C App not found: ${appCode}`));
2681
2844
  process.exit(1);
2682
2845
  }
2683
2846
  });
@@ -2794,6 +2957,21 @@ entityCmd.command("bulk-delete <namespace> <entity>").description("Bulk delete e
2794
2957
  format: options.format
2795
2958
  });
2796
2959
  });
2960
+ var modelCmd = program.command("model").description("Discover runtime datasources and table schemas");
2961
+ 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) => {
2962
+ const appCode = resolveAppCode(options.app);
2963
+ await listDatasources(createAmasterClient(appCode), {
2964
+ format: options.format
2965
+ });
2966
+ });
2967
+ 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) => {
2968
+ const appCode = resolveAppCode(options.app);
2969
+ await getTableSchema(createAmasterClient(appCode), {
2970
+ sourceId,
2971
+ tables: options.tables,
2972
+ format: options.format
2973
+ });
2974
+ });
2797
2975
  var bpmCmd = program.command("bpm").description("Manage BPM processes and tasks");
2798
2976
  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) => {
2799
2977
  const appCode = resolveAppCode(options.app);