@inworld/cli 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/dist/index.js +1086 -639
  2. package/dist/index.js.map +4 -4
  3. package/dist/package.json +49 -0
  4. package/dist/proto/generated/portal/ai/inworld/language_codes/language_codes.pb.d.ts +10 -0
  5. package/dist/proto/generated/portal/ai/inworld/language_codes/language_codes.pb.d.ts.map +1 -0
  6. package/dist/proto/generated/portal/ai/inworld/language_codes/language_codes.pb.js +16 -0
  7. package/dist/proto/generated/portal/ai/inworld/language_codes/language_codes.pb.js.map +1 -0
  8. package/dist/proto/generated/portal/ai/inworld/studio/v1/errors.pb.d.ts +13 -0
  9. package/dist/proto/generated/portal/ai/inworld/studio/v1/errors.pb.d.ts.map +1 -0
  10. package/dist/proto/generated/portal/ai/inworld/studio/v1/errors.pb.js +2 -0
  11. package/dist/proto/generated/portal/ai/inworld/studio/v1/errors.pb.js.map +1 -0
  12. package/dist/proto/generated/portal/ai/inworld/studio/v1/operations.pb.d.ts +7 -0
  13. package/dist/proto/generated/portal/ai/inworld/studio/v1/operations.pb.d.ts.map +1 -0
  14. package/dist/proto/generated/portal/ai/inworld/studio/v1/operations.pb.js +15 -0
  15. package/dist/proto/generated/portal/ai/inworld/studio/v1/operations.pb.js.map +1 -0
  16. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graph_configuration.pb.d.ts +14 -0
  17. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graph_configuration.pb.d.ts.map +1 -0
  18. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graph_configuration.pb.js +7 -0
  19. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graph_configuration.pb.js.map +1 -0
  20. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graphs.pb.d.ts +116 -0
  21. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graphs.pb.d.ts.map +1 -0
  22. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graphs.pb.js +71 -0
  23. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/graphs.pb.js.map +1 -0
  24. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/targeting.pb.d.ts +14 -0
  25. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/targeting.pb.d.ts.map +1 -0
  26. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/targeting.pb.js +7 -0
  27. package/dist/proto/generated/portal/ai/inworld/studio/v1/remote/configuration/targeting.pb.js.map +1 -0
  28. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.d.ts +76 -0
  29. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.d.ts.map +1 -0
  30. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.js +40 -0
  31. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.js.map +1 -0
  32. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/impression_event_data.pb.d.ts +10 -0
  33. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/impression_event_data.pb.d.ts.map +1 -0
  34. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/impression_event_data.pb.js +7 -0
  35. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/impression_event_data.pb.js.map +1 -0
  36. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/language_code.pb.d.ts +7 -0
  37. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/language_code.pb.d.ts.map +1 -0
  38. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/language_code.pb.js +13 -0
  39. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/language_code.pb.js.map +1 -0
  40. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/users.pb.d.ts +115 -0
  41. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/users.pb.d.ts.map +1 -0
  42. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/users.pb.js +86 -0
  43. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/users.pb.js.map +1 -0
  44. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.d.ts +255 -0
  45. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.d.ts.map +1 -0
  46. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.js +88 -0
  47. package/dist/proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.js.map +1 -0
  48. package/dist/proto/generated/portal/fetch.pb.d.ts +26 -0
  49. package/dist/proto/generated/portal/fetch.pb.d.ts.map +1 -0
  50. package/dist/proto/generated/portal/fetch.pb.js +274 -0
  51. package/dist/proto/generated/portal/fetch.pb.js.map +1 -0
  52. package/dist/src/auth/callback_server.d.ts +41 -0
  53. package/dist/src/auth/callback_server.d.ts.map +1 -0
  54. package/dist/src/auth/callback_server.js +136 -0
  55. package/dist/src/auth/callback_server.js.map +1 -0
  56. package/dist/src/auth/manager.d.ts +97 -0
  57. package/dist/src/auth/manager.d.ts.map +1 -0
  58. package/dist/src/auth/manager.js +340 -0
  59. package/dist/src/auth/manager.js.map +1 -0
  60. package/dist/src/auth/utils.d.ts +45 -0
  61. package/dist/src/auth/utils.d.ts.map +1 -0
  62. package/dist/src/auth/utils.js +183 -0
  63. package/dist/src/auth/utils.js.map +1 -0
  64. package/dist/src/commands/auth/disable_telemetry_command.d.ts +3 -0
  65. package/dist/src/commands/auth/disable_telemetry_command.d.ts.map +1 -0
  66. package/dist/src/commands/auth/enable_telemetry_command.d.ts +3 -0
  67. package/dist/src/commands/auth/enable_telemetry_command.d.ts.map +1 -0
  68. package/dist/src/commands/auth/login_ci_command.d.ts +3 -0
  69. package/dist/src/commands/auth/login_ci_command.d.ts.map +1 -0
  70. package/dist/src/commands/auth/login_ci_command.js +41 -0
  71. package/dist/src/commands/auth/login_ci_command.js.map +1 -0
  72. package/dist/src/commands/auth/login_command.d.ts +4 -0
  73. package/dist/src/commands/auth/login_command.d.ts.map +1 -0
  74. package/dist/src/commands/auth/login_command.js +134 -0
  75. package/dist/src/commands/auth/login_command.js.map +1 -0
  76. package/dist/src/commands/auth/logout_command.d.ts +4 -0
  77. package/dist/src/commands/auth/logout_command.d.ts.map +1 -0
  78. package/dist/src/commands/auth/logout_command.js +54 -0
  79. package/dist/src/commands/auth/logout_command.js.map +1 -0
  80. package/dist/src/commands/auth/print_access_token_command.d.ts +3 -0
  81. package/dist/src/commands/auth/print_access_token_command.d.ts.map +1 -0
  82. package/dist/src/commands/auth/print_access_token_command.js +21 -0
  83. package/dist/src/commands/auth/print_access_token_command.js.map +1 -0
  84. package/dist/src/commands/auth/print_api_key_command.d.ts +3 -0
  85. package/dist/src/commands/auth/print_api_key_command.d.ts.map +1 -0
  86. package/dist/src/commands/auth/print_api_key_command.js +26 -0
  87. package/dist/src/commands/auth/print_api_key_command.js.map +1 -0
  88. package/dist/src/commands/auth/status_command.d.ts +4 -0
  89. package/dist/src/commands/auth/status_command.d.ts.map +1 -0
  90. package/dist/src/commands/auth/status_command.js +84 -0
  91. package/dist/src/commands/auth/status_command.js.map +1 -0
  92. package/dist/src/commands/auth_command.d.ts +3 -0
  93. package/dist/src/commands/auth_command.d.ts.map +1 -0
  94. package/dist/src/commands/auth_command.js +20 -0
  95. package/dist/src/commands/auth_command.js.map +1 -0
  96. package/dist/src/commands/graph/graph_deploy_command.d.ts +24 -0
  97. package/dist/src/commands/graph/graph_deploy_command.d.ts.map +1 -0
  98. package/dist/src/commands/graph/graph_deploy_command.js +191 -0
  99. package/dist/src/commands/graph/graph_deploy_command.js.map +1 -0
  100. package/dist/src/commands/graph/graph_init_command.d.ts +4 -0
  101. package/dist/src/commands/graph/graph_init_command.d.ts.map +1 -0
  102. package/dist/src/commands/graph/graph_init_command.js +376 -0
  103. package/dist/src/commands/graph/graph_init_command.js.map +1 -0
  104. package/dist/src/commands/graph/graph_run_command.d.ts +24 -0
  105. package/dist/src/commands/graph/graph_run_command.d.ts.map +1 -0
  106. package/dist/src/commands/graph/graph_run_command.js +50 -0
  107. package/dist/src/commands/graph/graph_run_command.js.map +1 -0
  108. package/dist/src/commands/graph/graph_serve_command.d.ts +4 -0
  109. package/dist/src/commands/graph/graph_serve_command.d.ts.map +1 -0
  110. package/dist/src/commands/graph/graph_serve_command.js +40 -0
  111. package/dist/src/commands/graph/graph_serve_command.js.map +1 -0
  112. package/dist/src/commands/graph/graph_variant_command.d.ts +3 -0
  113. package/dist/src/commands/graph/graph_variant_command.d.ts.map +1 -0
  114. package/dist/src/commands/graph/graph_variant_command.js +13 -0
  115. package/dist/src/commands/graph/graph_variant_command.js.map +1 -0
  116. package/dist/src/commands/graph/graph_visualize_command.d.ts +7 -0
  117. package/dist/src/commands/graph/graph_visualize_command.d.ts.map +1 -0
  118. package/dist/src/commands/graph/graph_visualize_command.js +35 -0
  119. package/dist/src/commands/graph/graph_visualize_command.js.map +1 -0
  120. package/dist/src/commands/graph/variant/graph_variant_list_command.d.ts +3 -0
  121. package/dist/src/commands/graph/variant/graph_variant_list_command.d.ts.map +1 -0
  122. package/dist/src/commands/graph/variant/graph_variant_list_command.js +25 -0
  123. package/dist/src/commands/graph/variant/graph_variant_list_command.js.map +1 -0
  124. package/dist/src/commands/graph/variant/graph_variant_print_command.d.ts +7 -0
  125. package/dist/src/commands/graph/variant/graph_variant_print_command.d.ts.map +1 -0
  126. package/dist/src/commands/graph/variant/graph_variant_print_command.js +45 -0
  127. package/dist/src/commands/graph/variant/graph_variant_print_command.js.map +1 -0
  128. package/dist/src/commands/graph/variant/graph_variant_register_command.d.ts +3 -0
  129. package/dist/src/commands/graph/variant/graph_variant_register_command.d.ts.map +1 -0
  130. package/dist/src/commands/graph/variant/graph_variant_register_command.js +45 -0
  131. package/dist/src/commands/graph/variant/graph_variant_register_command.js.map +1 -0
  132. package/dist/src/commands/graph_command.d.ts +3 -0
  133. package/dist/src/commands/graph_command.d.ts.map +1 -0
  134. package/dist/src/commands/graph_command.js +20 -0
  135. package/dist/src/commands/graph_command.js.map +1 -0
  136. package/dist/src/commands/tts_commands.d.ts +17 -0
  137. package/dist/src/commands/tts_commands.d.ts.map +1 -0
  138. package/dist/src/commands/tts_commands.js +568 -0
  139. package/dist/src/commands/tts_commands.js.map +1 -0
  140. package/dist/src/commands/workspace_command.d.ts +12 -0
  141. package/dist/src/commands/workspace_command.d.ts.map +1 -0
  142. package/dist/src/commands/workspace_command.js +33 -0
  143. package/dist/src/commands/workspace_command.js.map +1 -0
  144. package/dist/src/constants.d.ts +10 -0
  145. package/dist/src/constants.d.ts.map +1 -0
  146. package/dist/src/constants.js +30 -0
  147. package/dist/src/constants.js.map +1 -0
  148. package/dist/src/grpc/core/InworldError.d.ts +30 -0
  149. package/dist/src/grpc/core/InworldError.d.ts.map +1 -0
  150. package/dist/src/grpc/core/InworldError.js +46 -0
  151. package/dist/src/grpc/core/InworldError.js.map +1 -0
  152. package/dist/src/grpc/core/statusCodes.d.ts +122 -0
  153. package/dist/src/grpc/core/statusCodes.d.ts.map +1 -0
  154. package/dist/src/grpc/core/statusCodes.js +133 -0
  155. package/dist/src/grpc/core/statusCodes.js.map +1 -0
  156. package/dist/src/index.d.ts +2 -0
  157. package/dist/src/index.d.ts.map +1 -0
  158. package/dist/src/services/analytics.d.ts +45 -0
  159. package/dist/src/services/analytics.d.ts.map +1 -0
  160. package/dist/src/services/deploy_service.d.ts +4 -0
  161. package/dist/src/services/deploy_service.d.ts.map +1 -0
  162. package/dist/src/services/deploy_service.js +128 -0
  163. package/dist/src/services/deploy_service.js.map +1 -0
  164. package/dist/src/services/graph_loader.d.ts +7 -0
  165. package/dist/src/services/graph_loader.d.ts.map +1 -0
  166. package/dist/src/services/graph_loader.js +103 -0
  167. package/dist/src/services/graph_loader.js.map +1 -0
  168. package/dist/src/services/graph_variant_service.d.ts +12 -0
  169. package/dist/src/services/graph_variant_service.d.ts.map +1 -0
  170. package/dist/src/services/graph_variant_service.js +66 -0
  171. package/dist/src/services/graph_variant_service.js.map +1 -0
  172. package/dist/src/services/tts_service.d.ts +273 -0
  173. package/dist/src/services/tts_service.d.ts.map +1 -0
  174. package/dist/src/services/tts_service.js +299 -0
  175. package/dist/src/services/tts_service.js.map +1 -0
  176. package/dist/src/services/update_checker.d.ts +37 -0
  177. package/dist/src/services/update_checker.d.ts.map +1 -0
  178. package/dist/src/services/workspace_service.d.ts +47 -0
  179. package/dist/src/services/workspace_service.d.ts.map +1 -0
  180. package/dist/src/services/workspace_service.js +222 -0
  181. package/dist/src/services/workspace_service.js.map +1 -0
  182. package/dist/src/templates/llm_tts/graph.d.ts +2 -0
  183. package/dist/src/templates/llm_tts/graph.d.ts.map +1 -0
  184. package/dist/src/utils/array.d.ts +2 -0
  185. package/dist/src/utils/array.d.ts.map +1 -0
  186. package/dist/src/utils/array.js +4 -0
  187. package/dist/src/utils/array.js.map +1 -0
  188. package/dist/src/utils/confirm.d.ts +62 -0
  189. package/dist/src/utils/confirm.d.ts.map +1 -0
  190. package/dist/src/utils/confirm.js +90 -0
  191. package/dist/src/utils/confirm.js.map +1 -0
  192. package/dist/src/utils/long_running_operations.d.ts +38 -0
  193. package/dist/src/utils/long_running_operations.d.ts.map +1 -0
  194. package/dist/src/utils/long_running_operations.js +62 -0
  195. package/dist/src/utils/long_running_operations.js.map +1 -0
  196. package/dist/src/utils/resource_name_helper.d.ts +12 -0
  197. package/dist/src/utils/resource_name_helper.d.ts.map +1 -0
  198. package/dist/src/utils/resource_name_helper.js +29 -0
  199. package/dist/src/utils/resource_name_helper.js.map +1 -0
  200. package/dist/src/utils/selector.d.ts +62 -0
  201. package/dist/src/utils/selector.d.ts.map +1 -0
  202. package/dist/src/utils/selector.js +77 -0
  203. package/dist/src/utils/selector.js.map +1 -0
  204. package/dist/src/utils/spinner.d.ts +75 -0
  205. package/dist/src/utils/spinner.d.ts.map +1 -0
  206. package/dist/src/utils/spinner.js +178 -0
  207. package/dist/src/utils/spinner.js.map +1 -0
  208. package/dist/src/utils/ui.d.ts +27 -0
  209. package/dist/src/utils/ui.d.ts.map +1 -0
  210. package/dist/src/utils/ui.js +83 -0
  211. package/dist/src/utils/ui.js.map +1 -0
  212. package/dist/templates/llm_tts/graph.ts +2 -1
  213. package/package.json +3 -2
  214. package/src/templates/llm_tts/graph.ts +2 -1
  215. package/dist/src/templates/simple/README.md +0 -106
  216. package/dist/src/templates/simple/graph.ts +0 -32
  217. package/dist/src/templates/simple/metadata.json +0 -26
  218. package/dist/templates/simple/README.md +0 -106
  219. package/dist/templates/simple/graph.ts +0 -32
  220. package/dist/templates/simple/metadata.json +0 -26
  221. package/src/templates/simple/README.md +0 -106
  222. package/src/templates/simple/graph.ts +0 -32
  223. package/src/templates/simple/metadata.json +0 -26
package/dist/index.js CHANGED
@@ -1,194 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
 
4
- // index.ts
5
- import chalk14 from "chalk";
6
- import { Command as Command19 } from "commander";
4
+ // src/index.ts
5
+ import chalk6 from "chalk";
6
+ import { Command as Command22 } from "commander";
7
7
 
8
8
  // src/commands/auth/login_command.ts
9
- import chalk3 from "chalk";
10
9
  import { exec } from "child_process";
11
10
  import { Command } from "commander";
12
- import * as readline2 from "readline";
11
+ import * as readline3 from "readline";
13
12
  import { promisify } from "util";
14
13
 
15
- // src/auth/callback-server.ts
16
- import * as http from "http";
17
-
18
- // src/constants.ts
19
- var DEFAULT_PLATFORM_ENDPOINT = "https://platform.inworld.ai";
20
- var resolvePlatformUrl = () => {
21
- if (process.env.INWORLD_PLATFORM_URL) {
22
- return process.env.INWORLD_PLATFORM_URL;
23
- }
24
- const env = (process.env.INWORLD_ENV || "").toUpperCase();
25
- switch (env) {
26
- case "DEV":
27
- return "https://platform.dev.inworld.ai";
28
- case "STAGE":
29
- return "https://platform.stage.inworld.ai";
30
- case "PROD":
31
- return "https://platform.inworld.ai";
32
- default:
33
- return DEFAULT_PLATFORM_ENDPOINT;
34
- }
35
- };
36
- var INWORLD_ENV = process.env.INWORLD_ENV || "PROD";
37
- var WORKSPACES_LIST_SIZE = 100;
38
- var PLATFORM_URL = resolvePlatformUrl();
39
- var FIREBASE_API_KEY = process.env.INWORLD_FIREBASE_API_KEY || "AIzaSyAPVBLVid0xPwjuU4Gmn_6_GyqxBq-SwQs";
40
- var INWORLD_CLI_AUTH_URL = process.env.INWORLD_CLI_AUTH_URL || "https://cli.inworld.ai/login";
41
- var INWORLD_CLI_AUTH_CALLBACK_PORT = parseInt(
42
- process.env.INWORLD_CLI_AUTH_CALLBACK_PORT || "8085",
43
- 10
44
- );
45
- var RUNTIME_VERSION = "0.6.3";
46
- var CLI_VERSION = "0.2.15";
47
-
48
- // src/utils/ui.ts
49
- import chalk from "chalk";
50
- function header(message) {
51
- console.log(chalk.bold(message));
52
- }
53
- function print(message) {
54
- console.log(chalk.dim.gray(message));
55
- }
56
- function printBright(message) {
57
- console.log(chalk.white(message));
58
- }
59
- function printLink(message) {
60
- console.log(chalk.dim.underline.cyan(message));
61
- }
62
- function printError(message) {
63
- console.error(chalk.dim.red(message));
64
- }
65
- function success(message) {
66
- console.log(chalk.dim.green(message));
67
- }
68
- function listItem(message) {
69
- console.log("\u2514 " + chalk.gray(message));
70
- }
71
-
72
- // src/auth/callback-server.ts
73
- async function createCallbackServer(options = {}) {
74
- const {
75
- port = 8085,
76
- allowedOrigins = ["http://localhost:3001", "https://cli.inworld.ai"],
77
- firebaseApiKey = FIREBASE_API_KEY
78
- } = options;
79
- return new Promise((resolve2, reject) => {
80
- const httpServer = http.createServer(
81
- {
82
- keepAlive: false
83
- },
84
- (req, res) => {
85
- const origin = req.headers.origin;
86
- if (origin && allowedOrigins.includes(origin)) {
87
- res.setHeader("Access-Control-Allow-Origin", origin);
88
- res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
89
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
90
- res.setHeader("Access-Control-Max-Age", "86400");
91
- }
92
- if (req.url?.startsWith("/callback") && req.method === "OPTIONS") {
93
- res.writeHead(204);
94
- res.end();
95
- return;
96
- }
97
- if (req.url?.startsWith("/callback") && req.method === "POST") {
98
- let body = "";
99
- req.on("data", (chunk) => {
100
- body += chunk.toString();
101
- });
102
- req.on("end", async () => {
103
- try {
104
- const data = JSON.parse(body);
105
- console.log();
106
- print("Received authentication data...");
107
- const refreshToken = data.refreshToken;
108
- const email = data.email;
109
- print("Exchanging tokens...");
110
- if (!firebaseApiKey) {
111
- throw new Error("FIREBASE_API_KEY is not set");
112
- }
113
- const tokenFetchResponse = await fetch(
114
- `https://securetoken.googleapis.com/v1/token?key=${firebaseApiKey}`,
115
- {
116
- method: "POST",
117
- body: new URLSearchParams({
118
- grant_type: "refresh_token",
119
- refresh_token: data.refreshToken
120
- })
121
- }
122
- );
123
- const tokenResponse = await tokenFetchResponse.json();
124
- if (tokenResponse.error) {
125
- throw new Error(
126
- `Token exchange failed: ${tokenResponse.error.message}`
127
- );
128
- }
129
- if (tokenResponse?.id_token) {
130
- res.writeHead(200, { "Content-Type": "application/json" });
131
- res.end(JSON.stringify({ success: true }));
132
- resolve2({
133
- server: httpServer,
134
- token: tokenResponse.id_token,
135
- refreshToken,
136
- email
137
- });
138
- } else {
139
- res.writeHead(400, { "Content-Type": "application/json" });
140
- res.end(JSON.stringify({ error: "No idToken provided" }));
141
- }
142
- } catch (error) {
143
- printError("Callback processing error:");
144
- console.error(error);
145
- res.writeHead(400, { "Content-Type": "application/json" });
146
- res.end(
147
- JSON.stringify({
148
- error: error instanceof Error ? error.message : "Invalid request"
149
- })
150
- );
151
- if (error instanceof Error && error.message.includes("JSON")) {
152
- print(
153
- "Invalid JSON received, waiting for valid callback..."
154
- );
155
- } else {
156
- reject(error);
157
- }
158
- }
159
- });
160
- req.on("error", (error) => {
161
- res.writeHead(500, { "Content-Type": "application/json" });
162
- res.end(JSON.stringify({ error: "Server error" }));
163
- reject(error);
164
- });
165
- } else if (req.url?.startsWith("/callback")) {
166
- res.writeHead(405, { "Content-Type": "application/json" });
167
- res.end(JSON.stringify({ error: "Method not allowed. Use POST." }));
168
- } else {
169
- res.writeHead(404, { "Content-Type": "application/json" });
170
- res.end(JSON.stringify({ error: "Not found" }));
171
- }
172
- }
173
- );
174
- httpServer.on("error", (error) => {
175
- reject(error);
176
- });
177
- httpServer.listen(port, "localhost");
178
- });
179
- }
180
- function stopCallbackServer(server) {
181
- return new Promise((resolve2, reject) => {
182
- server.close((err) => {
183
- if (err) {
184
- reject(err);
185
- } else {
186
- resolve2();
187
- }
188
- });
189
- });
190
- }
191
-
192
14
  // src/auth/manager.ts
193
15
  import Conf from "conf";
194
16
  import { createHash } from "crypto";
@@ -358,6 +180,162 @@ var Users = class {
358
180
  }
359
181
  };
360
182
 
183
+ // package.json
184
+ var package_default = {
185
+ name: "@inworld/cli",
186
+ version: "0.2.16",
187
+ type: "module",
188
+ main: "dist/index.js",
189
+ bin: {
190
+ inworld: "dist/index.js"
191
+ },
192
+ scripts: {
193
+ build: "node esbuild.config.js",
194
+ "build:tsc": "tsc --project tsconfig.json",
195
+ "build:types": "tsc --emitDeclarationOnly",
196
+ "build:all": "npm run build && npm run build:types",
197
+ start: "node dist/index.js",
198
+ dev: "tsx src/index.ts"
199
+ },
200
+ files: [
201
+ "dist/**/*",
202
+ "src/templates/**/*"
203
+ ],
204
+ author: "Inworld AI",
205
+ license: "MIT",
206
+ description: "Inworld CLI",
207
+ devDependencies: {
208
+ "@tsconfig/node-lts": "^22.0.2",
209
+ "@types/archiver": "^6.0.3",
210
+ "@types/express": "^5.0.3",
211
+ "@types/keytar": "^4.4.0",
212
+ "@types/node": "^24.1.0",
213
+ "@types/ora": "^3.1.0",
214
+ "@types/semver": "^7.5.8"
215
+ },
216
+ dependencies: {
217
+ "@zowe/secrets-for-zowe-sdk": "^8.27.0",
218
+ archiver: "^7.0.1",
219
+ chalk: "^5.3.0",
220
+ commander: "^12.0.0",
221
+ conf: "^14.0.0",
222
+ esbuild: "^0.25.10",
223
+ "jwt-decode": "^4.0.0",
224
+ mixpanel: "^0.18.1",
225
+ ora: "^8.2.0",
226
+ semver: "^7.6.3",
227
+ tsx: "^4.20.5",
228
+ typescript: "^5.8.3"
229
+ }
230
+ };
231
+
232
+ // src/constants.ts
233
+ var DEFAULT_PLATFORM_ENDPOINT = "https://platform.inworld.ai";
234
+ var resolvePlatformUrl = () => {
235
+ if (process.env.INWORLD_PLATFORM_URL) {
236
+ return process.env.INWORLD_PLATFORM_URL;
237
+ }
238
+ const env = (process.env.INWORLD_ENV || "").toUpperCase();
239
+ switch (env) {
240
+ case "DEV":
241
+ return "https://platform.dev.inworld.ai";
242
+ case "STAGE":
243
+ return "https://platform.stage.inworld.ai";
244
+ case "PROD":
245
+ return "https://platform.inworld.ai";
246
+ default:
247
+ return DEFAULT_PLATFORM_ENDPOINT;
248
+ }
249
+ };
250
+ var INWORLD_ENV = process.env.INWORLD_ENV || "PROD";
251
+ var WORKSPACES_LIST_SIZE = 100;
252
+ var PLATFORM_URL = resolvePlatformUrl();
253
+ var FIREBASE_API_KEY = process.env.INWORLD_FIREBASE_API_KEY || "AIzaSyAPVBLVid0xPwjuU4Gmn_6_GyqxBq-SwQs";
254
+ var INWORLD_CLI_AUTH_URL = process.env.INWORLD_CLI_AUTH_URL || "https://cli.inworld.ai/login";
255
+ var INWORLD_CLI_AUTH_CALLBACK_PORT = parseInt(
256
+ process.env.INWORLD_CLI_AUTH_CALLBACK_PORT || "8085",
257
+ 10
258
+ );
259
+ var MIXPANEL_TOKEN = process.env.INWORLD_MIXPANEL_TOKEN || "2cf13116e9701343ac27ddc452adfbbc";
260
+ var RUNTIME_VERSION = "0.6.4";
261
+ var CLI_VERSION = package_default.version;
262
+
263
+ // src/utils/ui.ts
264
+ import chalk from "chalk";
265
+ function printHeader(message) {
266
+ console.log(chalk.bold(message));
267
+ }
268
+ function p(message) {
269
+ console.log(message);
270
+ }
271
+ function print(message) {
272
+ console.log(chalk.dim.white(message));
273
+ }
274
+ function printBright(message) {
275
+ console.log(chalk.white(message));
276
+ }
277
+ function printLink(message) {
278
+ console.log(chalk.dim.underline.cyan(message));
279
+ }
280
+ function printError(message) {
281
+ console.error(chalk.dim.red(message));
282
+ }
283
+ function success(message) {
284
+ console.log(chalk.dim.green(message));
285
+ }
286
+ function printListItem(message) {
287
+ console.log("\u2514 " + chalk.gray(message));
288
+ }
289
+ function cyan(message) {
290
+ return chalk.cyan(message);
291
+ }
292
+ function green(message) {
293
+ return chalk.green(message);
294
+ }
295
+ function bold(message) {
296
+ return chalk.bold(message);
297
+ }
298
+ function bright(message) {
299
+ return chalk.whiteBright(message);
300
+ }
301
+ function dim(message) {
302
+ return chalk.dim(message);
303
+ }
304
+ function link(message) {
305
+ return chalk.dim.underline.cyan(message);
306
+ }
307
+ function printBox(lines, options) {
308
+ const color = options?.color || "yellow";
309
+ const padding = options?.padding ?? 2;
310
+ const stripAnsi = (str) => str.replace(/\x1b\[[0-9;]*m/g, "");
311
+ const maxContentWidth = Math.max(...lines.map((line) => stripAnsi(line).length));
312
+ const boxWidth = maxContentWidth + padding * 2;
313
+ const horizontalLine = "\u2500".repeat(boxWidth);
314
+ const emptyLine = " ".repeat(boxWidth);
315
+ const colorFn = chalk[color] || chalk.yellow;
316
+ p("");
317
+ p(colorFn("\u250C" + horizontalLine + "\u2510"));
318
+ p(colorFn("\u2502" + emptyLine + "\u2502"));
319
+ lines.forEach((line) => {
320
+ const actualLength = stripAnsi(line).length;
321
+ const leftPad = " ".repeat(padding);
322
+ const rightPad = " ".repeat(boxWidth - actualLength - padding);
323
+ p(colorFn("\u2502") + leftPad + line + rightPad + colorFn("\u2502"));
324
+ });
325
+ p(colorFn("\u2502" + emptyLine + "\u2502"));
326
+ p(colorFn("\u2514" + horizontalLine + "\u2518"));
327
+ p("");
328
+ }
329
+ function trimBase64Key(key) {
330
+ return key.substring(0, 3) + "..." + key.substring(key.length - 5);
331
+ }
332
+ function trimToken(token) {
333
+ return token.substring(0, 5) + "...";
334
+ }
335
+ function workspaceLink(workspaceId) {
336
+ return link(`${PLATFORM_URL}/v2/workspaces/${workspaceId}`);
337
+ }
338
+
361
339
  // src/auth/manager.ts
362
340
  var AuthManager = class _AuthManager {
363
341
  static SERVICE_NAME = "InworldCLI";
@@ -527,7 +505,6 @@ var AuthManager = class _AuthManager {
527
505
  */
528
506
  async generateInworldToken(firebaseToken) {
529
507
  try {
530
- print("Generating Inworld token...");
531
508
  const tokenResponse = await Users.GenerateTokenUser(
532
509
  {
533
510
  type: "AUTH_TYPE_FIREBASE" /* AUTH_TYPE_FIREBASE */,
@@ -606,7 +583,6 @@ var AuthManager = class _AuthManager {
606
583
  const credentials = await this.getCredentials();
607
584
  return credentials?.inworldToken || null;
608
585
  }
609
- print("Token expired, refreshing...");
610
586
  return await this.refreshToken();
611
587
  }
612
588
  /**
@@ -684,19 +660,268 @@ You can run "inworld login --force" to login with the correct environment.`
684
660
  };
685
661
  var authManager = new AuthManager();
686
662
 
687
- // src/utils/array.ts
688
- function isArrayOfType(arr, typeGuard) {
689
- return typeof arr !== "undefined" && Array.isArray(arr) && arr.every(typeGuard);
690
- }
691
-
692
- // src/grpc/core/statusCodes.ts
693
- var GrpcStatusCode = /* @__PURE__ */ ((GrpcStatusCode2) => {
694
- GrpcStatusCode2[GrpcStatusCode2["OK"] = 0] = "OK";
695
- GrpcStatusCode2[GrpcStatusCode2["CANCELLED"] = 1] = "CANCELLED";
696
- GrpcStatusCode2[GrpcStatusCode2["UNKNOWN"] = 2] = "UNKNOWN";
697
- GrpcStatusCode2[GrpcStatusCode2["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
698
- GrpcStatusCode2[GrpcStatusCode2["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
699
- GrpcStatusCode2[GrpcStatusCode2["NOT_FOUND"] = 5] = "NOT_FOUND";
663
+ // src/auth/callback_server.ts
664
+ import * as http from "http";
665
+ async function createCallbackServer(options = {}) {
666
+ const {
667
+ port = 8085,
668
+ allowedOrigins = ["http://localhost:3001", "https://cli.inworld.ai"],
669
+ firebaseApiKey = FIREBASE_API_KEY
670
+ } = options;
671
+ return new Promise((resolve2, reject) => {
672
+ const httpServer = http.createServer(
673
+ {
674
+ keepAlive: false
675
+ },
676
+ (req, res) => {
677
+ const origin = req.headers.origin;
678
+ if (origin && allowedOrigins.includes(origin)) {
679
+ res.setHeader("Access-Control-Allow-Origin", origin);
680
+ res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
681
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
682
+ res.setHeader("Access-Control-Max-Age", "86400");
683
+ }
684
+ if (req.url?.startsWith("/callback") && req.method === "OPTIONS") {
685
+ res.writeHead(204);
686
+ res.end();
687
+ return;
688
+ }
689
+ if (req.url?.startsWith("/callback") && req.method === "POST") {
690
+ let body = "";
691
+ req.on("data", (chunk) => {
692
+ body += chunk.toString();
693
+ });
694
+ req.on("end", async () => {
695
+ try {
696
+ const data = JSON.parse(body);
697
+ console.log();
698
+ print("Received authentication data...");
699
+ const refreshToken = data.refreshToken;
700
+ const email = data.email;
701
+ print("Exchanging tokens...");
702
+ if (!firebaseApiKey) {
703
+ throw new Error("FIREBASE_API_KEY is not set");
704
+ }
705
+ const tokenFetchResponse = await fetch(
706
+ `https://securetoken.googleapis.com/v1/token?key=${firebaseApiKey}`,
707
+ {
708
+ method: "POST",
709
+ body: new URLSearchParams({
710
+ grant_type: "refresh_token",
711
+ refresh_token: data.refreshToken
712
+ })
713
+ }
714
+ );
715
+ const tokenResponse = await tokenFetchResponse.json();
716
+ if (tokenResponse.error) {
717
+ throw new Error(
718
+ `Token exchange failed: ${tokenResponse.error.message}`
719
+ );
720
+ }
721
+ if (tokenResponse?.id_token) {
722
+ res.writeHead(200, { "Content-Type": "application/json" });
723
+ res.end(JSON.stringify({ success: true }));
724
+ resolve2({
725
+ server: httpServer,
726
+ token: tokenResponse.id_token,
727
+ refreshToken,
728
+ email
729
+ });
730
+ } else {
731
+ res.writeHead(400, { "Content-Type": "application/json" });
732
+ res.end(JSON.stringify({ error: "No idToken provided" }));
733
+ }
734
+ } catch (error) {
735
+ printError("Callback processing error:");
736
+ console.error(error);
737
+ res.writeHead(400, { "Content-Type": "application/json" });
738
+ res.end(
739
+ JSON.stringify({
740
+ error: error instanceof Error ? error.message : "Invalid request"
741
+ })
742
+ );
743
+ if (error instanceof Error && error.message.includes("JSON")) {
744
+ print(
745
+ "Invalid JSON received, waiting for valid callback..."
746
+ );
747
+ } else {
748
+ reject(error);
749
+ }
750
+ }
751
+ });
752
+ req.on("error", (error) => {
753
+ res.writeHead(500, { "Content-Type": "application/json" });
754
+ res.end(JSON.stringify({ error: "Server error" }));
755
+ reject(error);
756
+ });
757
+ } else if (req.url?.startsWith("/callback")) {
758
+ res.writeHead(405, { "Content-Type": "application/json" });
759
+ res.end(JSON.stringify({ error: "Method not allowed. Use POST." }));
760
+ } else {
761
+ res.writeHead(404, { "Content-Type": "application/json" });
762
+ res.end(JSON.stringify({ error: "Not found" }));
763
+ }
764
+ }
765
+ );
766
+ httpServer.on("error", (error) => {
767
+ reject(error);
768
+ });
769
+ httpServer.listen(port, "localhost");
770
+ });
771
+ }
772
+ function stopCallbackServer(server) {
773
+ return new Promise((resolve2, reject) => {
774
+ server.close((err) => {
775
+ if (err) {
776
+ reject(err);
777
+ } else {
778
+ resolve2();
779
+ }
780
+ });
781
+ });
782
+ }
783
+
784
+ // src/services/workspace_service.ts
785
+ import chalk2 from "chalk";
786
+
787
+ // proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.ts
788
+ var ApiKeys = class {
789
+ static ListApiKeys(req, initReq) {
790
+ return fetchReq(
791
+ `/v1alpha/${req["parent"]}/apikeys?${renderURLSearchParams(req, ["parent"])}`,
792
+ { ...initReq, method: "GET" }
793
+ );
794
+ }
795
+ static SuspendApiKey(req, initReq) {
796
+ return fetchReq(
797
+ `/v1alpha/${req["name"]}:suspend`,
798
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
799
+ );
800
+ }
801
+ static ActivateApiKey(req, initReq) {
802
+ return fetchReq(
803
+ `/v1alpha/${req["name"]}:activate`,
804
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
805
+ );
806
+ }
807
+ static DeleteApiKey(req, initReq) {
808
+ return fetchReq(
809
+ `/v1alpha/${req["name"]}`,
810
+ { ...initReq, method: "DELETE" }
811
+ );
812
+ }
813
+ static GenerateApiKey(req, initReq) {
814
+ return fetchReq(
815
+ `/v1alpha/${req["parent"]}/apikey:generate`,
816
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
817
+ );
818
+ }
819
+ static ListAuthScopes(req, initReq) {
820
+ return fetchReq(
821
+ `/v1alpha/${req["parent"]}/auth-scopes?${renderURLSearchParams(req, ["parent"])}`,
822
+ { ...initReq, method: "GET" }
823
+ );
824
+ }
825
+ };
826
+
827
+ // proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.ts
828
+ var Workspaces = class {
829
+ static GetWorkspace(req, initReq) {
830
+ return fetchReq(
831
+ `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["nameworkspaces"])}`,
832
+ { ...initReq, method: "GET" }
833
+ );
834
+ }
835
+ static ListWorkspaces(req, initReq) {
836
+ return fetchReq(
837
+ `/v1alpha/workspaces?${renderURLSearchParams(req, [])}`,
838
+ { ...initReq, method: "GET" }
839
+ );
840
+ }
841
+ static UpdateWorkspace(req, initReq) {
842
+ return fetchReq(
843
+ `/v1alpha/${req["workspace"]["name"]}`,
844
+ {
845
+ ...initReq,
846
+ method: "PATCH",
847
+ body: JSON.stringify(req["workspace"], replacer)
848
+ }
849
+ );
850
+ }
851
+ static CreateWorkspace(req, initReq) {
852
+ return fetchReq(
853
+ `/v1alpha/workspaces`,
854
+ {
855
+ ...initReq,
856
+ method: "POST",
857
+ body: JSON.stringify(req["workspace"], replacer)
858
+ }
859
+ );
860
+ }
861
+ static DeleteWorkspace(req, initReq) {
862
+ return fetchReq(
863
+ `/v1alpha/${req["name"]}`,
864
+ { ...initReq, method: "DELETE" }
865
+ );
866
+ }
867
+ static CloneWorkspace(req, initReq) {
868
+ return fetchReq(
869
+ `/v1alpha/${req["name"]}:clone`,
870
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
871
+ );
872
+ }
873
+ static ShareWorkspace(req, initReq) {
874
+ return fetchReq(
875
+ `/v1alpha/${req["name"]}:share`,
876
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
877
+ );
878
+ }
879
+ static generateResourceName(req, initReq) {
880
+ return fetchReq(`/v1alpha/${req["workspace"]}:generateResourceName`, {
881
+ ...initReq,
882
+ method: "POST",
883
+ body: JSON.stringify(req, replacer)
884
+ });
885
+ }
886
+ static GetWorkspaceShareInfo(req, initReq) {
887
+ return fetchReq(
888
+ `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["name"])}`,
889
+ { ...initReq, method: "GET" }
890
+ );
891
+ }
892
+ static GetWorkspaceLimitInfo(req, initReq) {
893
+ return fetchReq(
894
+ `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["name"])}`,
895
+ { ...initReq, method: "GET" }
896
+ );
897
+ }
898
+ static RemainWorkspaceLimitInfo(req, initReq) {
899
+ return fetchReq(
900
+ `/v1alpha/${req["name"]}:remain?${renderURLSearchParams(req, ["name"])}`,
901
+ { ...initReq, method: "GET" }
902
+ );
903
+ }
904
+ static SendImpressionEvent(req, initReq) {
905
+ return fetchReq(
906
+ `/v1alpha/${req["name"]}:impression`,
907
+ { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
908
+ );
909
+ }
910
+ };
911
+
912
+ // src/utils/array.ts
913
+ function isArrayOfType(arr, typeGuard) {
914
+ return typeof arr !== "undefined" && Array.isArray(arr) && arr.every(typeGuard);
915
+ }
916
+
917
+ // src/grpc/core/statusCodes.ts
918
+ var GrpcStatusCode = /* @__PURE__ */ ((GrpcStatusCode2) => {
919
+ GrpcStatusCode2[GrpcStatusCode2["OK"] = 0] = "OK";
920
+ GrpcStatusCode2[GrpcStatusCode2["CANCELLED"] = 1] = "CANCELLED";
921
+ GrpcStatusCode2[GrpcStatusCode2["UNKNOWN"] = 2] = "UNKNOWN";
922
+ GrpcStatusCode2[GrpcStatusCode2["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
923
+ GrpcStatusCode2[GrpcStatusCode2["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
924
+ GrpcStatusCode2[GrpcStatusCode2["NOT_FOUND"] = 5] = "NOT_FOUND";
700
925
  GrpcStatusCode2[GrpcStatusCode2["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
701
926
  GrpcStatusCode2[GrpcStatusCode2["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
702
927
  GrpcStatusCode2[GrpcStatusCode2["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
@@ -834,8 +1059,8 @@ var check = async (operationName, signal, returnWithMetadata) => retryableAuthen
834
1059
 
835
1060
  // src/auth/utils.ts
836
1061
  async function requireAuth() {
837
- const isAuthenticated2 = await authManager.isAuthenticated();
838
- if (!isAuthenticated2) {
1062
+ const isAuthenticated = await authManager.isAuthenticated();
1063
+ if (!isAuthenticated) {
839
1064
  console.log();
840
1065
  printError("\u274C Authentication required");
841
1066
  print("You must be logged in to use this command.");
@@ -956,133 +1181,41 @@ var authenticatedInworldRequest = async (pb, req, inworldToken, signal) => {
956
1181
  }
957
1182
  };
958
1183
 
959
- // src/services/workspace_service.ts
960
- import chalk2 from "chalk";
961
-
962
- // proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.ts
963
- var ApiKeys = class {
964
- static ListApiKeys(req, initReq) {
965
- return fetchReq(
966
- `/v1alpha/${req["parent"]}/apikeys?${renderURLSearchParams(req, ["parent"])}`,
967
- { ...initReq, method: "GET" }
968
- );
969
- }
970
- static SuspendApiKey(req, initReq) {
971
- return fetchReq(
972
- `/v1alpha/${req["name"]}:suspend`,
973
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
974
- );
975
- }
976
- static ActivateApiKey(req, initReq) {
977
- return fetchReq(
978
- `/v1alpha/${req["name"]}:activate`,
979
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
980
- );
981
- }
982
- static DeleteApiKey(req, initReq) {
983
- return fetchReq(
984
- `/v1alpha/${req["name"]}`,
985
- { ...initReq, method: "DELETE" }
986
- );
987
- }
988
- static GenerateApiKey(req, initReq) {
989
- return fetchReq(
990
- `/v1alpha/${req["parent"]}/apikey:generate`,
991
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
992
- );
993
- }
994
- static ListAuthScopes(req, initReq) {
995
- return fetchReq(
996
- `/v1alpha/${req["parent"]}/auth-scopes?${renderURLSearchParams(req, ["parent"])}`,
997
- { ...initReq, method: "GET" }
998
- );
999
- }
1000
- };
1001
-
1002
- // proto/generated/portal/ai/inworld/studio/v1alpha/workspaces.pb.ts
1003
- var Workspaces = class {
1004
- static GetWorkspace(req, initReq) {
1005
- return fetchReq(
1006
- `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["nameworkspaces"])}`,
1007
- { ...initReq, method: "GET" }
1008
- );
1009
- }
1010
- static ListWorkspaces(req, initReq) {
1011
- return fetchReq(
1012
- `/v1alpha/workspaces?${renderURLSearchParams(req, [])}`,
1013
- { ...initReq, method: "GET" }
1014
- );
1184
+ // src/utils/confirm.ts
1185
+ import * as readline from "readline";
1186
+ var globalForceYes = false;
1187
+ function setGlobalForceYes(value) {
1188
+ globalForceYes = value;
1189
+ }
1190
+ async function confirm(options) {
1191
+ const { message, forceYes, defaultValue = false } = options;
1192
+ if (forceYes !== void 0 ? forceYes : globalForceYes) {
1193
+ return true;
1015
1194
  }
1016
- static UpdateWorkspace(req, initReq) {
1017
- return fetchReq(
1018
- `/v1alpha/${req["workspace"]["name"]}`,
1019
- {
1020
- ...initReq,
1021
- method: "PATCH",
1022
- body: JSON.stringify(req["workspace"], replacer)
1195
+ const rl = readline.createInterface({
1196
+ input: process.stdin,
1197
+ output: process.stdout
1198
+ });
1199
+ return new Promise((resolve2) => {
1200
+ rl.question(message, (answer) => {
1201
+ rl.close();
1202
+ const trimmedAnswer = answer.trim().toLowerCase();
1203
+ if (trimmedAnswer === "y" || trimmedAnswer === "yes") {
1204
+ resolve2(true);
1205
+ return;
1023
1206
  }
1024
- );
1025
- }
1026
- static CreateWorkspace(req, initReq) {
1027
- return fetchReq(
1028
- `/v1alpha/workspaces`,
1029
- {
1030
- ...initReq,
1031
- method: "POST",
1032
- body: JSON.stringify(req["workspace"], replacer)
1207
+ if (trimmedAnswer === "n" || trimmedAnswer === "no") {
1208
+ resolve2(false);
1209
+ return;
1033
1210
  }
1034
- );
1035
- }
1036
- static DeleteWorkspace(req, initReq) {
1037
- return fetchReq(
1038
- `/v1alpha/${req["name"]}`,
1039
- { ...initReq, method: "DELETE" }
1040
- );
1041
- }
1042
- static CloneWorkspace(req, initReq) {
1043
- return fetchReq(
1044
- `/v1alpha/${req["name"]}:clone`,
1045
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
1046
- );
1047
- }
1048
- static ShareWorkspace(req, initReq) {
1049
- return fetchReq(
1050
- `/v1alpha/${req["name"]}:share`,
1051
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
1052
- );
1053
- }
1054
- static generateResourceName(req, initReq) {
1055
- return fetchReq(`/v1alpha/${req["workspace"]}:generateResourceName`, {
1056
- ...initReq,
1057
- method: "POST",
1058
- body: JSON.stringify(req, replacer)
1211
+ if (trimmedAnswer === "") {
1212
+ resolve2(defaultValue);
1213
+ return;
1214
+ }
1215
+ resolve2(false);
1059
1216
  });
1060
- }
1061
- static GetWorkspaceShareInfo(req, initReq) {
1062
- return fetchReq(
1063
- `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["name"])}`,
1064
- { ...initReq, method: "GET" }
1065
- );
1066
- }
1067
- static GetWorkspaceLimitInfo(req, initReq) {
1068
- return fetchReq(
1069
- `/v1alpha/${req["name"]}?${renderURLSearchParams(req, ["name"])}`,
1070
- { ...initReq, method: "GET" }
1071
- );
1072
- }
1073
- static RemainWorkspaceLimitInfo(req, initReq) {
1074
- return fetchReq(
1075
- `/v1alpha/${req["name"]}:remain?${renderURLSearchParams(req, ["name"])}`,
1076
- { ...initReq, method: "GET" }
1077
- );
1078
- }
1079
- static SendImpressionEvent(req, initReq) {
1080
- return fetchReq(
1081
- `/v1alpha/${req["name"]}:impression`,
1082
- { ...initReq, method: "POST", body: JSON.stringify(req, replacer) }
1083
- );
1084
- }
1085
- };
1217
+ });
1218
+ }
1086
1219
 
1087
1220
  // src/utils/resource_name_helper.ts
1088
1221
  var parseWorkspaceResourceName = (resourceName) => {
@@ -1103,7 +1236,7 @@ var getWorkspaceResourceName = (workspaceId) => {
1103
1236
  };
1104
1237
 
1105
1238
  // src/utils/selector.ts
1106
- import * as readline from "readline";
1239
+ import * as readline2 from "readline";
1107
1240
  async function selectItem(options) {
1108
1241
  const {
1109
1242
  items,
@@ -1123,13 +1256,13 @@ async function selectItem(options) {
1123
1256
  return items[0];
1124
1257
  }
1125
1258
  console.log();
1126
- header(title);
1259
+ printHeader(title);
1127
1260
  items.forEach((item, idx) => {
1128
1261
  const displayName = getDisplayName(item);
1129
1262
  const identifier = getIdentifier(item);
1130
- listItem(`${idx + 1}. ${displayName} (ID: ${identifier})`);
1263
+ printListItem(`${idx + 1}. ${displayName} (ID: ${identifier})`);
1131
1264
  });
1132
- const rl = readline.createInterface({
1265
+ const rl = readline2.createInterface({
1133
1266
  input: process.stdin,
1134
1267
  output: process.stdout
1135
1268
  });
@@ -1166,9 +1299,6 @@ async function selectItemOrExit(options) {
1166
1299
  }
1167
1300
  return selected;
1168
1301
  }
1169
- function trimBase64Key(key) {
1170
- return key.substring(0, 10) + "..." + key.substring(key.length - 10);
1171
- }
1172
1302
 
1173
1303
  // src/services/workspace_service.ts
1174
1304
  var WorkspaceService = class {
@@ -1238,7 +1368,8 @@ var WorkspaceService = class {
1238
1368
  workspaceResourceName
1239
1369
  ).workspaceId;
1240
1370
  print(`
1241
- Selecting workspace: ${chalk2.white(workspaceId)}...`);
1371
+ Selecting workspace: ${chalk2.whiteBright(workspaceId)}`);
1372
+ print(`Selected workspace link: ${workspaceLink(workspaceId)}`);
1242
1373
  let apiKey = null;
1243
1374
  const response = await authenticatedInworldRequest(ApiKeys.ListApiKeys, {
1244
1375
  parent: workspaceResourceName,
@@ -1252,40 +1383,31 @@ Selecting workspace: ${chalk2.white(workspaceId)}...`);
1252
1383
  apiKey = await this.pickApiKey(response.apiKeys, false);
1253
1384
  }
1254
1385
  } else {
1255
- const readline5 = await import("readline");
1256
- const rl = readline5.createInterface({
1257
- input: process.stdin,
1258
- output: process.stdout
1386
+ const shouldGenerate = await confirm({
1387
+ message: "No API keys found for this workspace. Would you like to generate one? (y/N): ",
1388
+ defaultValue: false
1259
1389
  });
1260
- await new Promise((resolve2) => {
1261
- rl.question(
1262
- "No API keys found for this workspace. Would you like to generate one? (y/N): ",
1263
- async (answer) => {
1264
- if (answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes") {
1265
- print("Generating API key...");
1266
- const generateApiKeyResponse = await authenticatedInworldRequest(
1267
- ApiKeys.GenerateApiKey,
1268
- {
1269
- parent: workspaceResourceName
1270
- }
1271
- );
1272
- if (!generateApiKeyResponse) {
1273
- printError("Failed to generate API key.");
1274
- process.exit(1);
1275
- }
1276
- apiKey = generateApiKeyResponse;
1277
- success("API key generated successfully.");
1278
- } else {
1279
- print("No API key will be generated.");
1280
- }
1281
- rl.close();
1282
- resolve2();
1390
+ if (shouldGenerate) {
1391
+ print("Generating API key...");
1392
+ const generateApiKeyResponse = await authenticatedInworldRequest(
1393
+ ApiKeys.GenerateApiKey,
1394
+ {
1395
+ parent: workspaceResourceName
1283
1396
  }
1284
1397
  );
1285
- });
1398
+ if (!generateApiKeyResponse) {
1399
+ printError("Failed to generate API key.");
1400
+ process.exit(1);
1401
+ }
1402
+ apiKey = generateApiKeyResponse;
1403
+ success("API key generated successfully.");
1404
+ } else {
1405
+ print("No API key will be generated.");
1406
+ }
1286
1407
  }
1287
1408
  const base64Key = this.returnBase64(apiKey?.key, apiKey?.secret);
1288
- print(`Selecting API key: ${chalk2.white(trimBase64Key(base64Key))}...`);
1409
+ print(`
1410
+ Selecting API key: ${chalk2.whiteBright(trimBase64Key(base64Key))}`);
1289
1411
  await authManager.updateWorkspaceAndApiKey(workspaceId, base64Key);
1290
1412
  success("\nWorkspace and API key selected.");
1291
1413
  }
@@ -1310,12 +1432,12 @@ Selecting workspace: ${chalk2.white(workspaceId)}...`);
1310
1432
  return;
1311
1433
  }
1312
1434
  console.log();
1313
- header(`API keys in workspace ${credentials.workspace}:`);
1435
+ printHeader(`API keys in workspace ${credentials.workspace}:`);
1314
1436
  apiKeys.forEach((apiKey, idx) => {
1315
1437
  const name = apiKey.name?.split("/").pop() || "unknown";
1316
1438
  const createdAt = apiKey.createTime ? new Date(apiKey.createTime).toLocaleDateString() : "unknown date";
1317
1439
  const state = apiKey.state || "unknown";
1318
- listItem(
1440
+ printListItem(
1319
1441
  `${idx + 1}. ${name} (created: ${createdAt}, state: ${state})`
1320
1442
  );
1321
1443
  });
@@ -1338,26 +1460,13 @@ Selecting workspace: ${chalk2.white(workspaceId)}...`);
1338
1460
  const apiKeys = response?.apiKeys || [];
1339
1461
  if (apiKeys.length === 0) {
1340
1462
  printError("No API keys found in the active workspace.");
1341
- const readline5 = await import("readline");
1342
- const rl = readline5.createInterface({
1343
- input: process.stdin,
1344
- output: process.stdout
1345
- });
1346
- await new Promise((resolve2) => {
1347
- rl.question(
1348
- "Would you like to generate a new API key? (y/N): ",
1349
- async (answer) => {
1350
- if (answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes") {
1351
- rl.close();
1352
- resolve2();
1353
- await this.generateApiKey();
1354
- } else {
1355
- rl.close();
1356
- resolve2();
1357
- }
1358
- }
1359
- );
1463
+ const shouldGenerate = await confirm({
1464
+ message: "Would you like to generate a new API key? (y/N): ",
1465
+ defaultValue: false
1360
1466
  });
1467
+ if (shouldGenerate) {
1468
+ await this.generateApiKey();
1469
+ }
1361
1470
  return;
1362
1471
  }
1363
1472
  if (apiKeys.length === 1) {
@@ -1417,12 +1526,12 @@ Selecting workspace: ${chalk2.white(workspaceId)}...`);
1417
1526
  success("API key activated successfully.");
1418
1527
  success("API key generated and activated successfully.");
1419
1528
  console.log();
1420
- header("API Key details:");
1421
- listItem(
1529
+ printHeader("API Key details:");
1530
+ printListItem(
1422
1531
  `Name: ${generateApiKeyResponse.name?.split("/").pop() || "unknown"}`
1423
1532
  );
1424
- listItem(`Key: ${generateApiKeyResponse.key}`);
1425
- listItem(`Base64: ${base64Key}`);
1533
+ printListItem(`Key: ${generateApiKeyResponse.key}`);
1534
+ printListItem(`Base64: ${base64Key}`);
1426
1535
  }
1427
1536
  };
1428
1537
 
@@ -1450,7 +1559,7 @@ var loginAction = async (options) => {
1450
1559
  process.exit(0);
1451
1560
  }
1452
1561
  console.log();
1453
- header("\u{1F3AD} Welcome to Inworld CLI!");
1562
+ printHeader("\u{1F3AD} Welcome to Inworld CLI!");
1454
1563
  if (options.force && await authManager.isAuthenticated()) {
1455
1564
  const credentials = await authManager.getCredentials();
1456
1565
  const email = credentials?.email || "Unknown";
@@ -1467,7 +1576,7 @@ var loginAction = async (options) => {
1467
1576
  print("Please visit the following URL to authenticate:");
1468
1577
  printLink(`${INWORLD_CLI_AUTH_URL}
1469
1578
  `);
1470
- const readlineInterface = readline2.createInterface({
1579
+ const readlineInterface = readline3.createInterface({
1471
1580
  input: process.stdin,
1472
1581
  output: process.stdout
1473
1582
  });
@@ -1548,37 +1657,27 @@ var loginCommand = makeLoginCommand(
1548
1657
  "Authenticate with Inworld Platform"
1549
1658
  );
1550
1659
  var loginCommandAlias = makeLoginCommand(
1551
- `Alias for "${chalk3.bold("inworld auth login")}"`
1660
+ `Alias for "${bold("inworld auth login")}"`
1552
1661
  );
1553
1662
 
1554
1663
  // src/commands/auth/logout_command.ts
1555
- import chalk4 from "chalk";
1556
1664
  import { Command as Command2 } from "commander";
1557
- import * as readline3 from "readline";
1558
1665
  var logoutAction = async (options) => {
1559
1666
  try {
1560
- const isAuthenticated2 = await authManager.isAuthenticated();
1561
- if (!isAuthenticated2) {
1667
+ const isAuthenticated = await authManager.isAuthenticated();
1668
+ if (!isAuthenticated) {
1562
1669
  print("You are not currently authenticated.");
1563
1670
  process.exit(0);
1564
1671
  }
1565
1672
  const credentials = await authManager.getCredentials();
1566
1673
  const email = credentials?.email || "Unknown user";
1567
1674
  console.log();
1568
- header("\u{1F3AD} Inworld CLI - Logout");
1675
+ printHeader("\u{1F3AD} Inworld CLI - Logout");
1569
1676
  print(`Current account: ${email}`);
1570
1677
  if (!options.force) {
1571
- const rl = readline3.createInterface({
1572
- input: process.stdin,
1573
- output: process.stdout
1574
- });
1575
- const confirmed = await new Promise((resolve2) => {
1576
- rl.question("\nAre you sure you want to logout? (y/N): ", (answer) => {
1577
- rl.close();
1578
- resolve2(
1579
- answer.toLowerCase() === "y" || answer.toLowerCase() === "yes"
1580
- );
1581
- });
1678
+ const confirmed = await confirm({
1679
+ message: "\nAre you sure you want to logout? (y/N): ",
1680
+ defaultValue: false
1582
1681
  });
1583
1682
  if (!confirmed) {
1584
1683
  console.log();
@@ -1603,22 +1702,21 @@ var makeLogoutCommand = (description) => {
1603
1702
  return new Command2("logout").description(description).option("-f, --force", "Skip confirmation prompt").action(logoutAction);
1604
1703
  };
1605
1704
  var logoutCommandAlias = makeLogoutCommand(
1606
- `Alias for "${chalk4.bold("inworld auth logout")}"`
1705
+ `Alias for "${bold("inworld auth logout")}"`
1607
1706
  );
1608
1707
  var logoutCommand = makeLogoutCommand(
1609
1708
  "Clear stored authentication credentials"
1610
1709
  );
1611
1710
 
1612
1711
  // src/commands/auth/status_command.ts
1613
- import chalk5 from "chalk";
1614
1712
  import { Command as Command3 } from "commander";
1615
1713
  var statusAction = async () => {
1616
1714
  try {
1617
1715
  const credentials = await authManager.getCredentials();
1618
- header("\nInworld CLI Status\n");
1716
+ printHeader("\nInworld CLI Status\n");
1619
1717
  if (!credentials) {
1620
1718
  print("Not authenticated.");
1621
- print(`Run \`${chalk5.white("inworld auth login")}\` to authenticate.`);
1719
+ print(`Run \`${bold("inworld auth login")}\` to authenticate.`);
1622
1720
  if (process.env.INWORLD_API_KEY) {
1623
1721
  print(
1624
1722
  `
@@ -1638,23 +1736,23 @@ INWORLD_API_KEY environment variable: ${trimBase64Key(process.env.INWORLD_API_KE
1638
1736
  console.log();
1639
1737
  printBright("Token Status:");
1640
1738
  print(
1641
- ` Inworld Token: ${credentials.inworldToken.substring(0, 20)}...`
1739
+ ` Inworld Token: ${trimToken(credentials.inworldToken)}`
1642
1740
  );
1643
1741
  print(` Expires At: ${expirationDate}`);
1644
1742
  print(` Status: ${isExpired ? "Expired" : "Valid"}`);
1645
1743
  } else {
1646
- header("\nToken Status:");
1744
+ printHeader("\nToken Status:");
1647
1745
  print(` Inworld Token: Not available`);
1648
1746
  }
1649
1747
  print(
1650
- ` Refresh Token: ${credentials.refreshToken.substring(0, 20)}...`
1748
+ ` Refresh Token: ${trimToken(credentials.refreshToken)}`
1651
1749
  );
1652
1750
  print(` Session Status: Active`);
1653
1751
  printBright("\nActive Workspace:");
1654
1752
  if (credentials.workspace) {
1655
1753
  print(` Workspace id: ${credentials.workspace}`);
1656
1754
  print(
1657
- ` Workspace link: ${chalk5.underline.dim.cyan(`${PLATFORM_URL}/v2/workspaces/${credentials.workspace}`)}`
1755
+ ` Workspace link: ${workspaceLink(credentials.workspace)}`
1658
1756
  );
1659
1757
  } else {
1660
1758
  print(` No workspace activated`);
@@ -1691,14 +1789,211 @@ var statusCommand = makeStatusCommand(
1691
1789
  "Display current authentication status and configuration"
1692
1790
  );
1693
1791
  var statusCommandAlias = makeStatusCommand(
1694
- `Alias for "${chalk5.bold("inworld auth status")}"`
1792
+ `Alias for "${bold("inworld auth status")}"`
1695
1793
  );
1696
1794
 
1697
1795
  // src/commands/auth_command.ts
1796
+ import { Command as Command9 } from "commander";
1797
+
1798
+ // src/commands/auth/disable_telemetry_command.ts
1799
+ import { Command as Command4 } from "commander";
1800
+
1801
+ // src/services/analytics.ts
1802
+ import Conf2 from "conf";
1803
+ import Mixpanel from "mixpanel";
1804
+ var Analytics = class _Analytics {
1805
+ static CONF_ENTRY_NAME = "analytics";
1806
+ conf;
1807
+ mixpanel = null;
1808
+ userId = null;
1809
+ initialized = false;
1810
+ constructor() {
1811
+ this.conf = new Conf2({
1812
+ projectName: "inworld-cli-config"
1813
+ });
1814
+ }
1815
+ /**
1816
+ * Initializes Mixpanel with user context (email and CLI version).
1817
+ * Only initializes if user is authenticated and hasn't opted out.
1818
+ */
1819
+ async initialize() {
1820
+ try {
1821
+ if (!this.isTelemetryEnabled()) {
1822
+ return;
1823
+ }
1824
+ if (!MIXPANEL_TOKEN) {
1825
+ return;
1826
+ }
1827
+ const credentials = await authManager.getCredentials();
1828
+ if (!credentials?.email) {
1829
+ return;
1830
+ }
1831
+ this.mixpanel = Mixpanel.init(MIXPANEL_TOKEN);
1832
+ this.userId = credentials.email;
1833
+ this.initialized = true;
1834
+ if (this.mixpanel && this.userId) {
1835
+ this.mixpanel.people.set(this.userId, {
1836
+ $email: credentials.email,
1837
+ cli_version: CLI_VERSION,
1838
+ environment: credentials.env || "PROD"
1839
+ });
1840
+ }
1841
+ } catch (error) {
1842
+ this.initialized = false;
1843
+ }
1844
+ }
1845
+ /**
1846
+ * Checks if telemetry is enabled (opt-in by default)
1847
+ */
1848
+ isTelemetryEnabled() {
1849
+ const config = this.conf.get(_Analytics.CONF_ENTRY_NAME);
1850
+ return config?.telemetryEnabled !== false;
1851
+ }
1852
+ /**
1853
+ * Enables or disables telemetry
1854
+ */
1855
+ setTelemetryEnabled(enabled) {
1856
+ this.conf.set(_Analytics.CONF_ENTRY_NAME, { telemetryEnabled: enabled });
1857
+ }
1858
+ /**
1859
+ * Tracks a command execution event
1860
+ * @param command The command being executed (e.g., 'auth login', 'graph deploy')
1861
+ * @param parameters Command parameters (sanitized, no sensitive data)
1862
+ */
1863
+ trackCommandExecution(command, parameters) {
1864
+ if (!this.initialized || !this.mixpanel || !this.userId) {
1865
+ return;
1866
+ }
1867
+ try {
1868
+ this.mixpanel.track("[inworld cli] command_execution", {
1869
+ distinct_id: this.userId,
1870
+ command,
1871
+ cli_version: CLI_VERSION,
1872
+ ...parameters
1873
+ });
1874
+ } catch (error) {
1875
+ }
1876
+ }
1877
+ /**
1878
+ * Tracks a command result event (success or failure)
1879
+ * @param command The command that was executed
1880
+ * @param success Whether the command succeeded
1881
+ * @param errorMessage Optional error message (sanitized)
1882
+ */
1883
+ trackCommandResult(command, success2, errorMessage) {
1884
+ if (!this.initialized || !this.mixpanel || !this.userId) {
1885
+ return;
1886
+ }
1887
+ try {
1888
+ this.mixpanel.track("[inworld_cli] command_result", {
1889
+ distinct_id: this.userId,
1890
+ command,
1891
+ success: success2,
1892
+ cli_version: CLI_VERSION,
1893
+ error_message: errorMessage
1894
+ });
1895
+ } catch (error) {
1896
+ }
1897
+ }
1898
+ /**
1899
+ * Flushes any pending events to Mixpanel
1900
+ * Should be called before the CLI exits
1901
+ */
1902
+ flush() {
1903
+ return new Promise((resolve2) => {
1904
+ if (!this.initialized || !this.mixpanel) {
1905
+ resolve2();
1906
+ return;
1907
+ }
1908
+ const timeout = setTimeout(() => resolve2(), 500);
1909
+ setTimeout(() => {
1910
+ clearTimeout(timeout);
1911
+ resolve2();
1912
+ }, 100);
1913
+ });
1914
+ }
1915
+ };
1916
+ var analytics = new Analytics();
1917
+
1918
+ // src/commands/auth/disable_telemetry_command.ts
1919
+ var disableTelemetryAction = async () => {
1920
+ try {
1921
+ analytics.setTelemetryEnabled(false);
1922
+ success("Telemetry disabled");
1923
+ print(
1924
+ "\nUsage data will no longer be collected. You can re-enable telemetry by running:"
1925
+ );
1926
+ print(` ${bold("inworld auth enable_telemetry")}`);
1927
+ process.exit(0);
1928
+ } catch (error) {
1929
+ printError("Failed to disable telemetry:");
1930
+ console.error(error);
1931
+ process.exit(1);
1932
+ }
1933
+ };
1934
+ var disableTelemetryCommand = new Command4("disable_cli_telemetry").description("Disable anonymous CLI usage analytics").action(disableTelemetryAction);
1935
+
1936
+ // src/commands/auth/enable_telemetry_command.ts
1937
+ import { Command as Command5 } from "commander";
1938
+ var enableTelemetryAction = async () => {
1939
+ try {
1940
+ analytics.setTelemetryEnabled(true);
1941
+ success("\u2713 Telemetry enabled");
1942
+ print(
1943
+ "\nAnonymous usage data will be collected to help improve the CLI."
1944
+ );
1945
+ print("\nYou can disable telemetry at any time by running:");
1946
+ print(` ${bold("inworld auth disable_telemetry")}`);
1947
+ process.exit(0);
1948
+ } catch (error) {
1949
+ printError("Failed to enable telemetry:");
1950
+ console.error(error);
1951
+ process.exit(1);
1952
+ }
1953
+ };
1954
+ var enableTelemetryCommand = new Command5("enable_cli_telemetry").description("Enable anonymous CLI usage analytics").action(enableTelemetryAction);
1955
+
1956
+ // src/commands/auth/login_ci_command.ts
1698
1957
  import { Command as Command6 } from "commander";
1958
+ var loginCiAction = async (options) => {
1959
+ try {
1960
+ setGlobalForceYes(true);
1961
+ console.log();
1962
+ printHeader("\u{1F3AD} Authenticating with external Firebase token");
1963
+ console.log();
1964
+ const success2 = await authManager.authenticateAndSaveCredentials(
1965
+ options.token,
1966
+ options.refreshToken || options.token,
1967
+ // Use token as fallback if no refresh token
1968
+ options.email,
1969
+ /* workspace */
1970
+ void 0,
1971
+ INWORLD_ENV
1972
+ );
1973
+ if (!success2) {
1974
+ printError("Failed to authenticate with provided token");
1975
+ process.exit(1);
1976
+ }
1977
+ console.log();
1978
+ success("\u2713 Authentication successful!");
1979
+ print(`Email: ${options.email}`);
1980
+ await WorkspaceService.activateWorkspace({ forceFirst: true });
1981
+ print("\nAuthentication completed.");
1982
+ process.exit(0);
1983
+ } catch (error) {
1984
+ console.log();
1985
+ printError("Token-based authentication failed:");
1986
+ console.error(error);
1987
+ process.exit(1);
1988
+ }
1989
+ };
1990
+ var loginCiCommand = new Command6("login-ci").description("Authenticate using Firebase token (for CI/testing)").requiredOption("-t, --token <token>", "Firebase ID token").requiredOption("-e, --email <email>", "Email address").option(
1991
+ "-r, --refresh-token <refreshToken>",
1992
+ "Firebase refresh token (optional, enables token refresh)"
1993
+ ).action(loginCiAction);
1699
1994
 
1700
1995
  // src/commands/auth/print_access_token_command.ts
1701
- import { Command as Command4 } from "commander";
1996
+ import { Command as Command7 } from "commander";
1702
1997
  var printAccessTokenAction = async () => {
1703
1998
  try {
1704
1999
  const token = await authManager.getValidToken();
@@ -1711,10 +2006,10 @@ var printAccessTokenAction = async () => {
1711
2006
  process.exit(1);
1712
2007
  }
1713
2008
  };
1714
- var printAccessTokenCommand = new Command4("print-access-token").description("Print the current Inworld access token").action(printAccessTokenAction);
2009
+ var printAccessTokenCommand = new Command7("print-access-token").description("Print the current Inworld access token").action(printAccessTokenAction);
1715
2010
 
1716
2011
  // src/commands/auth/print_api_key_command.ts
1717
- import { Command as Command5 } from "commander";
2012
+ import { Command as Command8 } from "commander";
1718
2013
  var printApiKeyAction = async () => {
1719
2014
  try {
1720
2015
  if (process.env.INWORLD_API_KEY) {
@@ -1731,17 +2026,16 @@ var printApiKeyAction = async () => {
1731
2026
  process.exit(1);
1732
2027
  }
1733
2028
  };
1734
- var printApiKeyCommand = new Command5("print-api-key").description("Print the current API key").action(printApiKeyAction);
2029
+ var printApiKeyCommand = new Command8("print-api-key").description("Print the current API key").action(printApiKeyAction);
1735
2030
 
1736
2031
  // src/commands/auth_command.ts
1737
- var authCommand = new Command6("auth").description("Manage Inworld authentication").addCommand(loginCommand).addCommand(logoutCommand).addCommand(printAccessTokenCommand).addCommand(printApiKeyCommand).addCommand(statusCommand).action(() => {
2032
+ var authCommand = new Command9("auth").description("Manage Inworld authentication").addCommand(loginCommand).addCommand(loginCiCommand).addCommand(logoutCommand).addCommand(printAccessTokenCommand).addCommand(printApiKeyCommand).addCommand(statusCommand).addCommand(disableTelemetryCommand).addCommand(enableTelemetryCommand).action(() => {
1738
2033
  authCommand.help();
1739
2034
  });
1740
2035
 
1741
2036
  // src/commands/graph/graph_deploy_command.ts
1742
2037
  import archiver from "archiver";
1743
- import chalk8 from "chalk";
1744
- import { Command as Command7 } from "commander";
2038
+ import { Command as Command10 } from "commander";
1745
2039
  import fs2 from "fs";
1746
2040
  import os from "os";
1747
2041
  import path2 from "path";
@@ -1828,7 +2122,7 @@ var GraphsService = class {
1828
2122
  };
1829
2123
 
1830
2124
  // src/utils/spinner.ts
1831
- import chalk6 from "chalk";
2125
+ import chalk3 from "chalk";
1832
2126
  import ora from "ora";
1833
2127
  var PHRASES = [
1834
2128
  "Condensing time-space matter",
@@ -1894,13 +2188,13 @@ var LROSpinner = class _LROSpinner {
1894
2188
  updateText() {
1895
2189
  const phrase = _LROSpinner.getRandomPhrase();
1896
2190
  const elapsedSeconds = Math.floor((Date.now() - this.startTime) / 1e3);
1897
- let text = chalk6.cyan(phrase);
2191
+ let text = chalk3.cyan(phrase);
1898
2192
  if (this.config.showIterations && this.iterationCount > 0) {
1899
- text += chalk6.gray(
2193
+ text += chalk3.gray(
1900
2194
  ` (iteration ${this.iterationCount}, ${elapsedSeconds}s)`
1901
2195
  );
1902
2196
  } else if (elapsedSeconds > 0) {
1903
- text += chalk6.gray(` (${elapsedSeconds}s)`);
2197
+ text += chalk3.gray(` (${elapsedSeconds}s)`);
1904
2198
  }
1905
2199
  this.spinner.text = text;
1906
2200
  }
@@ -1915,7 +2209,7 @@ var LROSpinner = class _LROSpinner {
1915
2209
  * Updates spinner with custom text temporarily
1916
2210
  */
1917
2211
  updateCustomText(text) {
1918
- this.spinner.text = chalk6.yellow(text);
2212
+ this.spinner.text = chalk3.yellow(text);
1919
2213
  }
1920
2214
  /**
1921
2215
  * Succeeds the spinner with a success message
@@ -1924,7 +2218,7 @@ var LROSpinner = class _LROSpinner {
1924
2218
  this.cleanup();
1925
2219
  const elapsedSeconds = Math.floor((Date.now() - this.startTime) / 1e3);
1926
2220
  const successText = text || `Deployment completed successfully in ${elapsedSeconds}s`;
1927
- this.spinner.succeed(chalk6.green(successText));
2221
+ this.spinner.succeed(chalk3.green(successText));
1928
2222
  }
1929
2223
  /**
1930
2224
  * Fails the spinner with an error message
@@ -1932,7 +2226,7 @@ var LROSpinner = class _LROSpinner {
1932
2226
  fail(text) {
1933
2227
  this.cleanup();
1934
2228
  const errorText = text || "Deployment failed";
1935
- this.spinner.fail(chalk6.red(errorText));
2229
+ this.spinner.fail(chalk3.red(errorText));
1936
2230
  }
1937
2231
  /**
1938
2232
  * Warns the spinner with a warning message
@@ -1940,7 +2234,7 @@ var LROSpinner = class _LROSpinner {
1940
2234
  warn(text) {
1941
2235
  this.cleanup();
1942
2236
  const warnText = text || "Deployment completed with warnings";
1943
- this.spinner.warn(chalk6.yellow(warnText));
2237
+ this.spinner.warn(chalk3.yellow(warnText));
1944
2238
  }
1945
2239
  /**
1946
2240
  * Stops the spinner without any status
@@ -1980,7 +2274,7 @@ function createLROSpinnerCallbacks(config) {
1980
2274
  spinner.updateIteration(checkData.checkIteration);
1981
2275
  if (checkData.checkIteration > checkData.checkLimit * 0.8) {
1982
2276
  spinner.updateCustomText(
1983
- chalk6.yellow(
2277
+ chalk3.yellow(
1984
2278
  `\u26A0\uFE0F Taking longer than expected... (${checkData.checkIteration}/${checkData.checkLimit})`
1985
2279
  )
1986
2280
  );
@@ -2115,7 +2409,6 @@ var registerGraph = async (workspaceId, graphId) => {
2115
2409
  };
2116
2410
 
2117
2411
  // src/services/graph_loader.ts
2118
- import chalk7 from "chalk";
2119
2412
  import * as esbuild from "esbuild";
2120
2413
  import fs from "fs";
2121
2414
  import { Module } from "module";
@@ -2177,11 +2470,7 @@ var loadGraph = async (file) => {
2177
2470
  }
2178
2471
  const graphId = module.graph.graphId;
2179
2472
  if (typeof graphId !== "string" || !/^[a-zA-Z0-9_-]+$/.test(graphId)) {
2180
- console.error(
2181
- chalk7.red(
2182
- "Error: Graph id must be a string containing only alphanumeric (latin) characters, dashes, or underscores."
2183
- )
2184
- );
2473
+ printError("Error: Graph id must be a string containing only alphanumeric (latin) characters, dashes, or underscores.");
2185
2474
  process.exit(1);
2186
2475
  }
2187
2476
  return {
@@ -2347,11 +2636,25 @@ inworld run ${graphFileName}
2347
2636
  }
2348
2637
  process.exit(1);
2349
2638
  }
2639
+ const startUrl = `${PLATFORM_URL.replace("platform", "api")}/cloud/${graphResourceName}/v1/graph:start`;
2350
2640
  success("Deployment successful!");
2351
2641
  success("Inworld Cloud URI:");
2352
- print(
2353
- `${PLATFORM_URL.replace("platform", "api")}/cloud/${graphResourceName}/v1/graph:start`
2354
- );
2642
+ print(startUrl);
2643
+ print(`
2644
+ Curl commands to try the graph:`);
2645
+ printBright(`
2646
+ TEMPLATE:
2647
+ `);
2648
+ printBright(` curl -X POST ${startUrl} \\`);
2649
+ printBright(' -H "Authorization: Basic $(inworld auth print-api-key)" \\');
2650
+ printBright(' -H "Content-Type: application/json" \\');
2651
+ printBright(" -d '{<YOUR_INPUT>}'");
2652
+ printBright(`
2653
+ EXAMPLE (LLM + TTS Pipeline):`);
2654
+ printBright(` curl -X POST ${startUrl} \\`);
2655
+ printBright(' -H "Authorization: Basic $(inworld auth print-api-key)" \\');
2656
+ printBright(' -H "Content-Type: application/json" \\');
2657
+ printBright(` -d '{"input": {"user_input":"Hello!"}}'`);
2355
2658
  try {
2356
2659
  fs2.rmSync(tempBaseDir, { recursive: true, force: true });
2357
2660
  } catch (_error) {
@@ -2364,21 +2667,21 @@ inworld run ${graphFileName}
2364
2667
  }
2365
2668
  };
2366
2669
  var makeDeployCommand = (description) => {
2367
- return new Command7("deploy").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").option("-i, --info", "Shows deployment info if any").option(
2670
+ return new Command10("deploy").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").option("-i, --info", "Shows deployment info if any").option(
2368
2671
  "-p, --package-only [file]",
2369
2672
  "Output file path (if not specified, outputs to graph-deployment.zip in current directory)"
2370
2673
  ).action(deployAction);
2371
2674
  };
2372
2675
  var deployCommand = makeDeployCommand(
2373
- "Packages a graph for deployment to the Inworld Cloud."
2676
+ "[preview] Packages a graph for deployment to the Inworld Cloud."
2374
2677
  );
2375
2678
  var deployCommandAlias = makeDeployCommand(
2376
- `Alias for "${chalk8.bold("inworld graph deploy")}"`
2679
+ `[preview] Alias for "${bold("inworld graph deploy")}"`
2377
2680
  );
2378
2681
 
2379
2682
  // src/commands/graph/graph_init_command.ts
2380
- import chalk9 from "chalk";
2381
- import { Command as Command8 } from "commander";
2683
+ import chalk4 from "chalk";
2684
+ import { Command as Command11 } from "commander";
2382
2685
  import fs3 from "fs";
2383
2686
  import path3 from "path";
2384
2687
  import * as readline4 from "readline";
@@ -2443,25 +2746,16 @@ function getAvailableTemplatesWithMetadata() {
2443
2746
  return templates;
2444
2747
  }
2445
2748
  async function promptNpmInstall() {
2446
- const rl = readline4.createInterface({
2447
- input: process.stdin,
2448
- output: process.stdout
2449
- });
2450
- return new Promise((resolve2) => {
2451
- rl.question(
2452
- "\n\u{1F4E6} Would you like to install dependencies now? (y/n) ",
2453
- (answer) => {
2454
- rl.close();
2455
- resolve2(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
2456
- }
2457
- );
2749
+ return confirm({
2750
+ message: "\nWould you like to install dependencies now? (y/n) ",
2751
+ defaultValue: false
2458
2752
  });
2459
2753
  }
2460
2754
  async function runNpmInstall(directory) {
2461
2755
  const { spawn } = await import("child_process");
2462
2756
  return new Promise((resolve2, reject) => {
2463
2757
  console.log();
2464
- print("\u{1F4E6} Installing dependencies...");
2758
+ print("Installing dependencies...");
2465
2759
  console.log();
2466
2760
  const install = spawn("npm", ["install"], {
2467
2761
  cwd: directory,
@@ -2471,7 +2765,7 @@ async function runNpmInstall(directory) {
2471
2765
  install.on("close", (code) => {
2472
2766
  if (code === 0) {
2473
2767
  console.log();
2474
- success("\u2705 Dependencies installed successfully!");
2768
+ success("Dependencies installed successfully!");
2475
2769
  resolve2();
2476
2770
  } else {
2477
2771
  console.log();
@@ -2534,23 +2828,23 @@ var initAction = async (options) => {
2534
2828
  if (options.listTemplates) {
2535
2829
  const templates2 = getAvailableTemplatesWithMetadata();
2536
2830
  console.log();
2537
- header("\u{1F4DA} Available templates:");
2831
+ printHeader("\u{1F4DA} Available templates:");
2538
2832
  console.log();
2539
2833
  for (const template of templates2) {
2540
- listItem(`${chalk9.cyan.bold(template.metadata.name)}`);
2541
- listItem(` ${template.metadata.description}`);
2834
+ printListItem(`${chalk4.cyan.bold(template.metadata.name)}`);
2835
+ printListItem(` ${template.metadata.description}`);
2542
2836
  if (template.metadata.tags && template.metadata.tags.length > 0) {
2543
- listItem(` Tags: ${template.metadata.tags.join(", ")}`);
2837
+ printListItem(` Tags: ${template.metadata.tags.join(", ")}`);
2544
2838
  }
2545
2839
  if (template.metadata.requirements?.apiKeys) {
2546
- listItem(
2840
+ printListItem(
2547
2841
  ` Required API Keys: ${template.metadata.requirements.apiKeys.join(", ")}`
2548
2842
  );
2549
2843
  }
2550
2844
  console.log();
2551
2845
  }
2552
2846
  print(
2553
- `Use ${chalk9.bold("inworld graph init")} to interactively select a template.`
2847
+ `Use ${chalk4.bold("inworld graph init")} to interactively select a template.`
2554
2848
  );
2555
2849
  console.log();
2556
2850
  return;
@@ -2564,9 +2858,12 @@ var initAction = async (options) => {
2564
2858
  }
2565
2859
  let selectedTemplate = null;
2566
2860
  let projectName;
2861
+ if (!options.template) {
2862
+ options.template = "llm_tts";
2863
+ }
2567
2864
  if (!options.template) {
2568
2865
  console.log();
2569
- header("\u{1F680} Welcome to Inworld Graph Project Initializer!");
2866
+ printHeader("\u{1F680} Welcome to Inworld Graph Project Initializer!");
2570
2867
  console.log();
2571
2868
  selectedTemplate = await selectItem({
2572
2869
  items: templates,
@@ -2579,7 +2876,7 @@ var initAction = async (options) => {
2579
2876
  });
2580
2877
  if (!selectedTemplate) {
2581
2878
  console.log();
2582
- print("\u26A0\uFE0F No template selected. Exiting.");
2879
+ print("No template selected. Exiting.");
2583
2880
  return;
2584
2881
  }
2585
2882
  } else {
@@ -2616,22 +2913,14 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2616
2913
  const projectDir = path3.join(currentDir, projectName);
2617
2914
  if (fs3.existsSync(projectDir)) {
2618
2915
  console.log();
2619
- print(`\u26A0\uFE0F Directory '${projectName}' already exists.`);
2916
+ print(`Directory '${projectName}' already exists.`);
2620
2917
  if (!options.template) {
2621
- const rl = readline4.createInterface({
2622
- input: process.stdin,
2623
- output: process.stdout
2624
- });
2625
- const confirmOverwrite = await new Promise((resolve2) => {
2626
- rl.question("Do you want to overwrite it? (y/n) ", (answer) => {
2627
- rl.close();
2628
- resolve2(
2629
- answer.toLowerCase() === "y" || answer.toLowerCase() === "yes"
2630
- );
2631
- });
2918
+ const confirmOverwrite = await confirm({
2919
+ message: "Do you want to overwrite it? (y/n) ",
2920
+ defaultValue: false
2632
2921
  });
2633
2922
  if (!confirmOverwrite) {
2634
- print("\u26A0\uFE0F Initialization cancelled.");
2923
+ print("Initialization cancelled.");
2635
2924
  return;
2636
2925
  }
2637
2926
  fs3.rmSync(projectDir, { recursive: true, force: true });
@@ -2646,15 +2935,15 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2646
2935
  const packageJsonPath = path3.join(projectDir, "package.json");
2647
2936
  const readmePath = path3.join(projectDir, "README.md");
2648
2937
  console.log();
2649
- header(`\u{1F680} Initializing Inworld graph project: ${projectName}`);
2650
- print(`\u{1F4C2} Creating project in: ${projectDir}`);
2651
- print(`\u{1F4CB} Using template: ${selectedTemplate.metadata.displayName}`);
2938
+ print(`Initializing Inworld graph project: ${bright(projectName)}`);
2939
+ print(` Creating project in: ${projectDir}`);
2940
+ print(` Using template: ${selectedTemplate.metadata.displayName}`);
2652
2941
  console.log();
2653
- print("\u{1F4DD} Creating graph file...");
2942
+ print(" Creating graph file...");
2654
2943
  const graphContent = createGraphTemplate(selectedTemplate.directory);
2655
2944
  fs3.writeFileSync(graphFilePath, graphContent, "utf-8");
2656
2945
  if (!options.skipPackageJson) {
2657
- print("\u{1F4E6} Creating package.json...");
2946
+ print(" Creating package.json...");
2658
2947
  const packageJson = createPackageJson(graphFileName);
2659
2948
  packageJson.name = projectName;
2660
2949
  fs3.writeFileSync(
@@ -2664,7 +2953,7 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2664
2953
  );
2665
2954
  }
2666
2955
  if (!options.skipReadme) {
2667
- print("\u{1F4DA} Creating README.md...");
2956
+ print(" Creating README.md...");
2668
2957
  const readmeContent = createReadme(
2669
2958
  selectedTemplate.directory,
2670
2959
  graphFileName
@@ -2673,18 +2962,13 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2673
2962
  }
2674
2963
  if (selectedTemplate.metadata.requirements?.apiKeys) {
2675
2964
  console.log();
2676
- print("\u26A0\uFE0F This template requires the following API keys:");
2965
+ print("This template requires the following API keys:");
2677
2966
  for (const key of selectedTemplate.metadata.requirements.apiKeys) {
2678
2967
  print(` \u2022 ${key}`);
2679
2968
  }
2680
2969
  }
2681
- if (selectedTemplate.metadata.examples?.curlCommand) {
2682
- console.log();
2683
- header("\u{1F4DD} Example usage:");
2684
- print(` ${selectedTemplate.metadata.examples.curlCommand}`);
2685
- }
2686
2970
  console.log();
2687
- success("\u2705 Inworld graph project initialized successfully!");
2971
+ success("Inworld graph project initialized successfully!");
2688
2972
  if (!options.skipInstall && !options.skipPackageJson) {
2689
2973
  const shouldInstall = await promptNpmInstall();
2690
2974
  if (shouldInstall) {
@@ -2695,24 +2979,23 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2695
2979
  print("\u26A0\uFE0F You can install dependencies manually by running:");
2696
2980
  print(` cd ${projectName} && npm install`);
2697
2981
  }
2982
+ } else {
2983
+ printBright(`
2984
+ ${dim("Skipping dependency installation. You can run `")}npm install${dim("` later.")}`);
2698
2985
  }
2699
2986
  }
2700
2987
  console.log();
2701
- header("\u{1F4CC} Next steps:");
2702
- print(` 1. ${chalk9.bold(`cd ${projectName}`)}`);
2988
+ printHeader("Next steps:\n");
2989
+ printBright(` ${dim("1. Run `")}cd ${projectName}${dim("`")}`);
2703
2990
  if (!options.skipInstall) {
2704
- print(` 2. ${chalk9.bold("npm install")} (if not already done)`);
2705
- print(
2706
- ` 3. ${chalk9.bold("npm start")} or ${chalk9.bold("npx inworld serve graph.ts")}`
2707
- );
2991
+ printBright(` ${dim("2. Run `")}npm install${dim("`")} ${dim("(if not already done)")}`);
2992
+ printBright(` ${dim("3. Run `")}npm start${dim("`")} ${dim("or `")}npx inworld serve ./graph.ts${dim("`")}`);
2708
2993
  } else {
2709
- print(
2710
- ` 2. ${chalk9.bold("npm start")} or ${chalk9.bold("npx inworld serve graph.ts")}`
2711
- );
2994
+ printBright(` ${dim("2. Run `")}npm start${dim("`")} ${dim("or `")}npx inworld serve ./graph.ts${dim("`")}`);
2712
2995
  }
2713
- if (selectedTemplate.metadata.requirements?.apiKeys) {
2714
- console.log();
2715
- print("\u{1F4A1} Remember to set your API keys before running!");
2996
+ if (selectedTemplate.metadata.examples?.curlCommand) {
2997
+ printBright("\nExample curl command:\n");
2998
+ printBright(`$ ${selectedTemplate.metadata.examples.curlCommand}`);
2716
2999
  }
2717
3000
  } catch (error) {
2718
3001
  printError("\u274C Error initializing project:");
@@ -2722,21 +3005,17 @@ Project name (${selectedTemplate.metadata.defaultProjectName}): `,
2722
3005
  };
2723
3006
  var makeInitCommand = (description) => {
2724
3007
  const availableTemplates = getAvailableTemplatesWithMetadata();
2725
- return new Command8("init").description(description).option("-n, --name <name>", "Name of the project directory").option(
2726
- "-t, --template <template>",
2727
- `Template to use: ${availableTemplates.map((t) => `"${t.directory}"`).join(" or ")}`
2728
- ).option("-l, --list-templates", "List all available templates").option("--skip-package-json", "Skip creating package.json file").option("--skip-readme", "Skip creating README.md file").option("--skip-install", "Skip npm install prompt").action(initAction);
3008
+ return new Command11("init").description(description).option("-n, --name <name>", "Name of the project directory").option("--skip-package-json", "Skip creating package.json file").option("--skip-readme", "Skip creating README.md file").option("--skip-install", "Skip npm install prompt").action(initAction);
2729
3009
  };
2730
3010
  var initCommand = makeInitCommand(
2731
3011
  "Initialize a new Inworld graph project (interactive if no options provided)"
2732
3012
  );
2733
3013
  var initCommandAlias = makeInitCommand(
2734
- `Alias for "${chalk9.bold("inworld graph init")}"`
3014
+ `Alias for "${chalk4.bold("inworld graph init")}"`
2735
3015
  );
2736
3016
 
2737
3017
  // src/commands/graph/graph_run_command.ts
2738
- import chalk10 from "chalk";
2739
- import { Command as Command9 } from "commander";
3018
+ import { Command as Command12 } from "commander";
2740
3019
  var runAction = async (file, request) => {
2741
3020
  try {
2742
3021
  const { graph } = await loadGraph(file);
@@ -2756,7 +3035,7 @@ var runAction = async (file, request) => {
2756
3035
  }
2757
3036
  };
2758
3037
  var makeRunCommand = (description) => {
2759
- return new Command9("run").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").argument(
3038
+ return new Command12("run").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").argument(
2760
3039
  "<request>",
2761
3040
  `
2762
3041
  Graph input, heavily depends on the exact graph. E.g.:
@@ -2780,12 +3059,11 @@ var runCommand = makeRunCommand(
2780
3059
  "Runs single execution against provided Inworld graph. Uses same input and output protocol as http server."
2781
3060
  );
2782
3061
  var runCommandAlias = makeRunCommand(
2783
- `Alias for "${chalk10.bold("inworld graph run")}"`
3062
+ `Alias for "${bold("inworld graph run")}"`
2784
3063
  );
2785
3064
 
2786
3065
  // src/commands/graph/graph_serve_command.ts
2787
- import chalk11 from "chalk";
2788
- import { Command as Command10 } from "commander";
3066
+ import { Command as Command13 } from "commander";
2789
3067
  var serveAction = async (file, options) => {
2790
3068
  try {
2791
3069
  const { graph } = await loadGraph(file);
@@ -2808,7 +3086,7 @@ var serveAction = async (file, options) => {
2808
3086
  }
2809
3087
  };
2810
3088
  var makeServeCommand = (description) => {
2811
- return new Command10("serve").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").option("-p, --port <port>", "Port to run the server on", "3000").option("--host <host>", "Host to bind the server to", "localhost").option(
3089
+ return new Command13("serve").description(description).argument("<file>", "Path to the graph file (e.g., test.ts)").option("-p, --port <port>", "Port to run the server on", "3000").option("--host <host>", "Host to bind the server to", "localhost").option(
2812
3090
  "-t, --transport <transport>",
2813
3091
  "Transport protocol (http or grpc)",
2814
3092
  "http"
@@ -2822,17 +3100,17 @@ var serveCommand = makeServeCommand(
2822
3100
  "Start a server that wraps an Inworld Runtime graph"
2823
3101
  );
2824
3102
  var serveCommandAlias = makeServeCommand(
2825
- `Alias for "${chalk11.bold("inworld graph serve")}"`
3103
+ `Alias for "${bold("inworld graph serve")}"`
2826
3104
  );
2827
3105
 
2828
3106
  // src/commands/graph_command.ts
2829
- import { Command as Command16 } from "commander";
3107
+ import { Command as Command19 } from "commander";
2830
3108
 
2831
3109
  // src/commands/graph/graph_variant_command.ts
2832
- import { Command as Command14 } from "commander";
3110
+ import { Command as Command17 } from "commander";
2833
3111
 
2834
3112
  // src/commands/graph/variant/graph_variant_list_command.ts
2835
- import { Command as Command11 } from "commander";
3113
+ import { Command as Command14 } from "commander";
2836
3114
 
2837
3115
  // src/services/graph_variant_service.ts
2838
3116
  var listGraphVariants = async (graphId) => {
@@ -2903,17 +3181,17 @@ var listVariantsAction = async (file) => {
2903
3181
  return;
2904
3182
  }
2905
3183
  console.log();
2906
- header(
3184
+ printHeader(
2907
3185
  `Registered variants of the graph "${graph.graphId}" in workspace "${workspaceId}":`
2908
3186
  );
2909
3187
  variants.graphVariants?.forEach((variant) => {
2910
- listItem(`${variant.name} - ${variant.displayName}`);
3188
+ printListItem(`${variant.name} - ${variant.displayName}`);
2911
3189
  });
2912
3190
  };
2913
- var graphListVariantsCommand = new Command11("list").description("List all registered variants of the graph.").argument("<file>", "Path to the graph file (e.g., graph.ts)").action(listVariantsAction);
3191
+ var graphListVariantsCommand = new Command14("list").description("List all registered variants of the graph.").argument("<file>", "Path to the graph file (e.g., graph.ts)").action(listVariantsAction);
2914
3192
 
2915
3193
  // src/commands/graph/variant/graph_variant_print_command.ts
2916
- import { Command as Command12 } from "commander";
3194
+ import { Command as Command15 } from "commander";
2917
3195
  import path4 from "path";
2918
3196
  var graphVariantPrintAction = async (file, options) => {
2919
3197
  try {
@@ -2933,14 +3211,13 @@ var graphVariantPrintAction = async (file, options) => {
2933
3211
  process.exit(1);
2934
3212
  }
2935
3213
  };
2936
- var graphVariantPrintCommand = new Command12("print").description("Print JSON representation of the graph variant").argument("<file>", "Path to the graph file (e.g., test.ts)").option(
3214
+ var graphVariantPrintCommand = new Command15("print").description("Print JSON representation of the graph variant").argument("<file>", "Path to the graph file (e.g., test.ts)").option(
2937
3215
  "-o, --output <file>",
2938
3216
  "Output file path (if not specified, outputs to console)"
2939
3217
  ).action(graphVariantPrintAction);
2940
3218
 
2941
3219
  // src/commands/graph/variant/graph_variant_register_command.ts
2942
- import chalk12 from "chalk";
2943
- import { Command as Command13 } from "commander";
3220
+ import { Command as Command16 } from "commander";
2944
3221
  var registerVariantsAction = async (file, options) => {
2945
3222
  const workspaceId = await requireWorkspace();
2946
3223
  const { graph } = await loadGraph(file);
@@ -2967,7 +3244,7 @@ var registerVariantsAction = async (file, options) => {
2967
3244
  );
2968
3245
  console.log();
2969
3246
  print(
2970
- `Now you can open ${chalk12.cyan.underline(uri)} and setup targeting for different variants`
3247
+ `Now you can open ${link(uri)} and setup targeting for different variants`
2971
3248
  );
2972
3249
  } else {
2973
3250
  if (isGrpcError(response) && response.code === 6 /* ALREADY_EXISTS */) {
@@ -2980,18 +3257,18 @@ var registerVariantsAction = async (file, options) => {
2980
3257
  }
2981
3258
  }
2982
3259
  };
2983
- var graphVariantRegisterCommand = new Command13("register").description("List all registered variants of the graph.").argument("<file>", "Path to the graph file (e.g., graph.ts)").requiredOption(
3260
+ var graphVariantRegisterCommand = new Command16("register").description("List all registered variants of the graph.").argument("<file>", "Path to the graph file (e.g., graph.ts)").requiredOption(
2984
3261
  "-d, --display-name <variantDisplayName>",
2985
3262
  "The display name of the variant"
2986
3263
  ).option("-f, --force", "Updates the variant if it already exists", false).action(registerVariantsAction);
2987
3264
 
2988
3265
  // src/commands/graph/graph_variant_command.ts
2989
- var graphVariantCommand = new Command14("variant").description("Manage Inworld graph variants").addCommand(graphListVariantsCommand).addCommand(graphVariantRegisterCommand).addCommand(graphVariantPrintCommand).action(() => {
3266
+ var graphVariantCommand = new Command17("variant").description("Manage Inworld graph variants").addCommand(graphListVariantsCommand).addCommand(graphVariantRegisterCommand).addCommand(graphVariantPrintCommand).action(() => {
2990
3267
  graphVariantCommand.help();
2991
3268
  });
2992
3269
 
2993
3270
  // src/commands/graph/graph_visualize_command.ts
2994
- import { Command as Command15 } from "commander";
3271
+ import { Command as Command18 } from "commander";
2995
3272
  import path5 from "path";
2996
3273
  var visualizeAction = async (file, options) => {
2997
3274
  try {
@@ -3005,20 +3282,20 @@ var visualizeAction = async (file, options) => {
3005
3282
  process.exit(1);
3006
3283
  }
3007
3284
  };
3008
- var visualizeCommand = new Command15("visualize").description("Generate a visualization of an Inworld Runtime graph").argument("<file>", "Path to the graph file (e.g., test.ts)").option(
3285
+ var visualizeCommand = new Command18("visualize").description("Generate a visualization of an Inworld Runtime graph").argument("<file>", "Path to the graph file (e.g., test.ts)").option(
3009
3286
  "-o, --output <file>",
3010
3287
  "Output file path (if not specified, outputs to graph.png in current directory)",
3011
3288
  "./graph.png"
3012
3289
  ).action(visualizeAction);
3013
3290
 
3014
3291
  // src/commands/graph_command.ts
3015
- var graphCommand = new Command16("graph").description("Manage Inworld graph projects").addCommand(initCommand).addCommand(serveCommand).addCommand(runCommand).addCommand(deployCommand).addCommand(visualizeCommand).addCommand(graphVariantCommand).action(() => {
3292
+ var graphCommand = new Command19("graph").description("Manage Inworld graph projects").addCommand(initCommand).addCommand(serveCommand).addCommand(runCommand).addCommand(deployCommand).addCommand(visualizeCommand).addCommand(graphVariantCommand).action(() => {
3016
3293
  graphCommand.help();
3017
3294
  });
3018
3295
 
3019
3296
  // src/commands/tts_commands.ts
3020
- import chalk13 from "chalk";
3021
- import { Command as Command17 } from "commander";
3297
+ import chalk5 from "chalk";
3298
+ import { Command as Command20 } from "commander";
3022
3299
  import { writeFile } from "fs/promises";
3023
3300
  import { resolve } from "path";
3024
3301
 
@@ -3289,7 +3566,7 @@ function wrapText(text, maxWidth) {
3289
3566
  if (currentLine) lines.push(currentLine);
3290
3567
  return lines;
3291
3568
  }
3292
- var listVoicesCommand = new Command17("list-voices").description("List all available voices from the workspace").option("-f, --filter <filter>", 'Filter voices (e.g., "language=en")').option("-j, --json", "Output as JSON").option("-c, --compact", "Compact output (voice IDs only)").action(async (options) => {
3569
+ var listVoicesCommand = new Command20("list-voices").description("List all available voices from the workspace").option("-f, --filter <filter>", 'Filter voices (e.g., "language=en")').option("-j, --json", "Output as JSON").option("-c, --compact", "Compact output (voice IDs only)").action(async (options) => {
3293
3570
  try {
3294
3571
  const response = await ttsService.listVoices(options.filter);
3295
3572
  if (options.json) {
@@ -3298,15 +3575,15 @@ var listVoicesCommand = new Command17("list-voices").description("List all avail
3298
3575
  return;
3299
3576
  }
3300
3577
  if (!response.voices || response.voices.length === 0) {
3301
- console.log(chalk13.yellow("\u26A0\uFE0F No voices found"));
3578
+ console.log(chalk5.yellow("\u26A0\uFE0F No voices found"));
3302
3579
  process.exit(0);
3303
3580
  return;
3304
3581
  }
3305
3582
  if (options.compact) {
3306
- console.log("\n" + chalk13.bold.green("\u{1F3A4} Available Voice IDs:"));
3307
- console.log(chalk13.gray("\u2500".repeat(50)));
3583
+ console.log("\n" + chalk5.bold.green("\u{1F3A4} Available Voice IDs:"));
3584
+ console.log(chalk5.gray("\u2500".repeat(50)));
3308
3585
  response.voices.sort((a, b) => a.voiceId.localeCompare(b.voiceId)).forEach((voice) => {
3309
- console.log(` ${chalk13.cyan("\u2022")} ${voice.voiceId}`);
3586
+ console.log(` ${chalk5.cyan("\u2022")} ${voice.voiceId}`);
3310
3587
  });
3311
3588
  console.log();
3312
3589
  process.exit(0);
@@ -3322,13 +3599,13 @@ var listVoicesCommand = new Command17("list-voices").description("List all avail
3322
3599
  voicesByLanguage.get(primaryLang).push(voice);
3323
3600
  });
3324
3601
  const sortedLanguages = Array.from(voicesByLanguage.keys()).sort();
3325
- console.log("\n" + chalk13.bold.green("Available TTS Voices"));
3602
+ console.log("\n" + chalk5.bold.green("Available TTS Voices"));
3326
3603
  console.log(
3327
- chalk13.gray(
3604
+ chalk5.gray(
3328
3605
  `Found ${response.voices.length} voices across ${sortedLanguages.length} languages`
3329
3606
  )
3330
3607
  );
3331
- console.log(chalk13.gray("\u2500".repeat(80)));
3608
+ console.log(chalk5.gray("\u2500".repeat(80)));
3332
3609
  sortedLanguages.forEach((lang, langIndex) => {
3333
3610
  const voices = voicesByLanguage.get(lang);
3334
3611
  const languageFlags = {
@@ -3348,19 +3625,19 @@ var listVoicesCommand = new Command17("list-voices").description("List all avail
3348
3625
  const flag = languageFlags[lang] || "\u{1F310}";
3349
3626
  console.log(
3350
3627
  `
3351
- ${flag} ${chalk13.bold.yellow(lang.toUpperCase())} ${chalk13.gray(`(${voices.length} voices)`)}`
3628
+ ${flag} ${chalk5.bold.yellow(lang.toUpperCase())} ${chalk5.gray(`(${voices.length} voices)`)}`
3352
3629
  );
3353
- console.log(chalk13.gray("\u2500".repeat(80)));
3630
+ console.log(chalk5.gray("\u2500".repeat(80)));
3354
3631
  voices.sort((a, b) => a.voiceId.localeCompare(b.voiceId)).forEach((voice) => {
3355
- const displayName = voice.displayName && voice.displayName !== voice.voiceId ? chalk13.gray(` (${voice.displayName})`) : "";
3632
+ const displayName = voice.displayName && voice.displayName !== voice.voiceId ? chalk5.gray(` (${voice.displayName})`) : "";
3356
3633
  console.log(
3357
- ` ${chalk13.cyan("\u25B8")} ${chalk13.bold.white(voice.voiceId)}${displayName}`
3634
+ ` ${chalk5.cyan("\u25B8")} ${chalk5.bold.white(voice.voiceId)}${displayName}`
3358
3635
  );
3359
3636
  if (voice.description) {
3360
3637
  const maxWidth = 76;
3361
3638
  const descriptionLines = wrapText(voice.description, maxWidth);
3362
3639
  descriptionLines.forEach((line) => {
3363
- console.log(` ${chalk13.gray(line)}`);
3640
+ console.log(` ${chalk5.gray(line)}`);
3364
3641
  });
3365
3642
  }
3366
3643
  });
@@ -3368,26 +3645,26 @@ ${flag} ${chalk13.bold.yellow(lang.toUpperCase())} ${chalk13.gray(`(${voices.le
3368
3645
  console.log();
3369
3646
  }
3370
3647
  });
3371
- console.log("\n" + chalk13.gray("\u2500".repeat(80)));
3372
- console.log(chalk13.gray("Tips:"));
3648
+ console.log("\n" + chalk5.gray("\u2500".repeat(80)));
3649
+ console.log(chalk5.gray("Tips:"));
3373
3650
  console.log(
3374
- chalk13.gray(' \u2022 Use --filter "language=<code>" to filter by language')
3651
+ chalk5.gray(' \u2022 Use --filter "language=<code>" to filter by language')
3375
3652
  );
3376
3653
  console.log(
3377
- chalk13.gray(" \u2022 Use --compact for a simple list of voice IDs")
3654
+ chalk5.gray(" \u2022 Use --compact for a simple list of voice IDs")
3378
3655
  );
3379
- console.log(chalk13.gray(" \u2022 Use --json for machine-readable output"));
3656
+ console.log(chalk5.gray(" \u2022 Use --json for machine-readable output"));
3380
3657
  console.log(
3381
- chalk13.gray('\nExample: inworld tts list-voices --filter "language=en"')
3658
+ chalk5.gray('\nExample: inworld tts list-voices --filter "language=en"')
3382
3659
  );
3383
3660
  console.log();
3384
3661
  } catch (error) {
3385
- console.error(chalk13.red("\u274C Error listing voices:"), error);
3662
+ console.error(chalk5.red("\u274C Error listing voices:"), error);
3386
3663
  process.exit(1);
3387
3664
  }
3388
3665
  process.exit(0);
3389
3666
  });
3390
- var synthesizeCommand = new Command17("synthesize").description("Synthesize text to speech").argument("<text>", "Text to synthesize (max 2000 characters)").requiredOption(
3667
+ var synthesizeCommand = new Command20("synthesize").description("Synthesize text to speech").argument("<text>", "Text to synthesize (max 2000 characters)").requiredOption(
3391
3668
  "-v, --voice <voiceId>",
3392
3669
  "Voice ID to use for synthesis",
3393
3670
  "Dennis"
@@ -3402,14 +3679,14 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3402
3679
  ).option("--format <format>", "Audio format (MP3, LINEAR16, OGG_OPUS)", "MP3").option("--timestamps <type>", "Include timestamps (WORD or CHARACTER)").option("-j, --json", "Output response as JSON (includes base64 audio)").option("--stats", "Show request performance statistics").option("--stream", "Use streaming API for synthesis").action(async (text, options) => {
3403
3680
  try {
3404
3681
  if (text.length > 2e3) {
3405
- console.error(chalk13.red("\u274C Error: Text exceeds 2000 character limit"));
3406
- console.log(chalk13.gray(`Current length: ${text.length} characters`));
3682
+ console.error(chalk5.red("\u274C Error: Text exceeds 2000 character limit"));
3683
+ console.log(chalk5.gray(`Current length: ${text.length} characters`));
3407
3684
  process.exit(1);
3408
3685
  }
3409
3686
  const temperature = parseFloat(options.temperature);
3410
3687
  if (isNaN(temperature) || temperature < 0 || temperature > 2) {
3411
3688
  console.error(
3412
- chalk13.red("\u274C Error: Temperature must be between 0.0 and 2.0")
3689
+ chalk5.red("\u274C Error: Temperature must be between 0.0 and 2.0")
3413
3690
  );
3414
3691
  process.exit(1);
3415
3692
  }
@@ -3418,10 +3695,10 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3418
3695
  "inworld-tts-1-max": "inworld-tts-1-max" /* INWORLD_TTS_1_MAX */
3419
3696
  };
3420
3697
  const modelId = modelMap[options.model] || "inworld-tts-1-max" /* INWORLD_TTS_1_MAX */;
3421
- console.log(chalk13.cyan("\u{1F399}\uFE0F Synthesizing speech..."));
3422
- console.log(chalk13.gray(`Voice: ${options.voice}`));
3423
- console.log(chalk13.gray(`Model: ${options.model}`));
3424
- console.log(chalk13.gray(`Text length: ${text.length} characters`));
3698
+ console.log(chalk5.cyan("\u{1F399}\uFE0F Synthesizing speech..."));
3699
+ console.log(chalk5.gray(`Voice: ${options.voice}`));
3700
+ console.log(chalk5.gray(`Model: ${options.model}`));
3701
+ console.log(chalk5.gray(`Text length: ${text.length} characters`));
3425
3702
  const request = {
3426
3703
  text,
3427
3704
  voiceId: options.voice,
@@ -3444,15 +3721,15 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3444
3721
  fileExtension = ".wav";
3445
3722
  if (options.format === "MP3") {
3446
3723
  console.log(
3447
- chalk13.yellow(
3724
+ chalk5.yellow(
3448
3725
  "\u26A0\uFE0F Warning: MP3 streaming requires special handling."
3449
3726
  )
3450
3727
  );
3451
3728
  console.log(
3452
- chalk13.yellow(" Audio chunks may not concatenate perfectly.")
3729
+ chalk5.yellow(" Audio chunks may not concatenate perfectly.")
3453
3730
  );
3454
3731
  console.log(
3455
- chalk13.yellow(
3732
+ chalk5.yellow(
3456
3733
  " Consider using LINEAR16 or OGG_OPUS for better streaming."
3457
3734
  )
3458
3735
  );
@@ -3465,8 +3742,8 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3465
3742
  streamFormat = "LINEAR16";
3466
3743
  fileExtension = ".wav";
3467
3744
  }
3468
- console.log(chalk13.cyan("\u{1F504} Using streaming synthesis..."));
3469
- console.log(chalk13.gray(`Format: ${streamFormat}${fileExtension}`));
3745
+ console.log(chalk5.cyan("\u{1F504} Using streaming synthesis..."));
3746
+ console.log(chalk5.gray(`Format: ${streamFormat}${fileExtension}`));
3470
3747
  const streamRequest = {
3471
3748
  ...request,
3472
3749
  audioConfig: {
@@ -3496,7 +3773,7 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3496
3773
  if (chunk.error) {
3497
3774
  streamError = chunk.error;
3498
3775
  console.error(
3499
- chalk13.red(`\u274C Stream error: ${chunk.error.message}`)
3776
+ chalk5.red(`\u274C Stream error: ${chunk.error.message}`)
3500
3777
  );
3501
3778
  } else {
3502
3779
  if (chunk.audioContent) {
@@ -3521,7 +3798,7 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3521
3798
  if (!options.json && !options.stats) {
3522
3799
  const chunkSizeKB = (chunkBuffer.length / 1024).toFixed(2);
3523
3800
  process.stdout.write(
3524
- chalk13.gray(
3801
+ chalk5.gray(
3525
3802
  `\rReceived chunk ${chunkCount} (${chunkSizeKB} KB)...`
3526
3803
  )
3527
3804
  );
@@ -3603,34 +3880,30 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3603
3880
  options.output || `output${fileExtension}`
3604
3881
  );
3605
3882
  await writeFile(outputPath, audioBuffer);
3606
- console.log(chalk13.green(`\u2705 Audio saved to: ${outputPath}`));
3883
+ console.log(chalk5.green(`\u2705 Audio saved to: ${outputPath}`));
3607
3884
  console.log(
3608
- chalk13.gray(
3885
+ chalk5.gray(
3609
3886
  `File size: ${(audioBuffer.length / 1024).toFixed(2)} KB`
3610
3887
  )
3611
3888
  );
3612
- console.log(chalk13.gray(`Chunks received: ${chunkCount}`));
3889
+ console.log(chalk5.gray(`Chunks received: ${chunkCount}`));
3613
3890
  if (allWordAlignments.words.length > 0) {
3614
3891
  console.log(
3615
- chalk13.gray(
3892
+ chalk5.gray(
3616
3893
  `Word timestamps collected: ${allWordAlignments.words.length}`
3617
3894
  )
3618
3895
  );
3619
3896
  }
3620
3897
  if (allCharacterAlignments.characters.length > 0) {
3621
3898
  console.log(
3622
- chalk13.gray(
3899
+ chalk5.gray(
3623
3900
  `Character timestamps collected: ${allCharacterAlignments.characters.length}`
3624
3901
  )
3625
3902
  );
3626
3903
  }
3627
3904
  }
3628
3905
  } else {
3629
- console.log(chalk13.cyan("\u{1F399}\uFE0F Synthesizing speech..."));
3630
- console.log(chalk13.gray(`Voice: ${options.voice}`));
3631
- console.log(chalk13.gray(`Model: ${options.model}`));
3632
- console.log(chalk13.gray(`Text length: ${text.length} characters`));
3633
- console.log(chalk13.gray(`Format: ${options.format || "MP3 (default)"}`));
3906
+ console.log(chalk5.gray(`Format: ${options.format || "MP3 (default)"}`));
3634
3907
  if (options.format === "LINEAR16") {
3635
3908
  fileExtension = ".wav";
3636
3909
  } else if (options.format === "OGG_OPUS") {
@@ -3649,9 +3922,9 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3649
3922
  options.output || `output${fileExtension}`
3650
3923
  );
3651
3924
  await writeFile(outputPath, audioBuffer);
3652
- console.log(chalk13.green(`\u2705 Audio saved to: ${outputPath}`));
3925
+ console.log(chalk5.green(`\u2705 Audio saved to: ${outputPath}`));
3653
3926
  console.log(
3654
- chalk13.gray(
3927
+ chalk5.gray(
3655
3928
  `File size: ${(audioBuffer.length / 1024).toFixed(2)} KB`
3656
3929
  )
3657
3930
  );
@@ -3667,25 +3940,25 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3667
3940
  if (isStreaming) {
3668
3941
  const sm = m;
3669
3942
  console.log(
3670
- "\n" + chalk13.cyan("\u{1F4CA} Streaming Performance Statistics:")
3943
+ "\n" + chalk5.cyan("\u{1F4CA} Streaming Performance Statistics:")
3671
3944
  );
3672
- console.log(chalk13.gray("\u2550".repeat(50)));
3673
- console.log(chalk13.bold.white("\n Streaming Timeline:"));
3674
- console.log(chalk13.gray(" \u2500".repeat(23)));
3945
+ console.log(chalk5.gray("\u2550".repeat(50)));
3946
+ console.log(chalk5.bold.white("\n Streaming Timeline:"));
3947
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3675
3948
  console.log(
3676
- chalk13.white(" \u23F1\uFE0F Time to First Chunk: ") + chalk13.yellow(`${sm.timeToFirstChunk.toFixed(0)} ms`)
3949
+ chalk5.white(" \u23F1\uFE0F Time to First Chunk: ") + chalk5.yellow(`${sm.timeToFirstChunk.toFixed(0)} ms`)
3677
3950
  );
3678
3951
  console.log(
3679
- chalk13.white(" \u23F2\uFE0F Total Stream Time: ") + chalk13.bold.yellow(`${sm.totalTime.toFixed(0)} ms`)
3952
+ chalk5.white(" \u23F2\uFE0F Total Stream Time: ") + chalk5.bold.yellow(`${sm.totalTime.toFixed(0)} ms`)
3680
3953
  );
3681
- console.log(chalk13.bold.white("\n Chunk Statistics:"));
3682
- console.log(chalk13.gray(" \u2500".repeat(23)));
3954
+ console.log(chalk5.bold.white("\n Chunk Statistics:"));
3955
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3683
3956
  console.log(
3684
- chalk13.white(" \u{1F4E6} Chunks Received: ") + chalk13.yellow(`${sm.chunksReceived}`)
3957
+ chalk5.white(" \u{1F4E6} Chunks Received: ") + chalk5.yellow(`${sm.chunksReceived}`)
3685
3958
  );
3686
3959
  if (sm.errorChunks > 0) {
3687
3960
  console.log(
3688
- chalk13.white(" \u26A0\uFE0F Error Chunks: ") + chalk13.red(`${sm.errorChunks}`)
3961
+ chalk5.white(" \u26A0\uFE0F Error Chunks: ") + chalk5.red(`${sm.errorChunks}`)
3689
3962
  );
3690
3963
  }
3691
3964
  if (sm.chunkSizes.length > 0) {
@@ -3693,10 +3966,10 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3693
3966
  const minChunkSize = Math.min(...sm.chunkSizes);
3694
3967
  const maxChunkSize = Math.max(...sm.chunkSizes);
3695
3968
  console.log(
3696
- chalk13.white(" \u{1F4CF} Avg Chunk Size: ") + chalk13.yellow(`${(avgChunkSize / 1024).toFixed(2)} KB`)
3969
+ chalk5.white(" \u{1F4CF} Avg Chunk Size: ") + chalk5.yellow(`${(avgChunkSize / 1024).toFixed(2)} KB`)
3697
3970
  );
3698
3971
  console.log(
3699
- chalk13.gray(" Min/Max: ") + chalk13.gray(
3972
+ chalk5.gray(" Min/Max: ") + chalk5.gray(
3700
3973
  `${(minChunkSize / 1024).toFixed(2)} - ${(maxChunkSize / 1024).toFixed(2)} KB`
3701
3974
  )
3702
3975
  );
@@ -3706,126 +3979,126 @@ var synthesizeCommand = new Command17("synthesize").description("Synthesize text
3706
3979
  const minInterval = Math.min(...sm.chunkIntervals);
3707
3980
  const maxInterval = Math.max(...sm.chunkIntervals);
3708
3981
  console.log(
3709
- chalk13.white(" \u23F3 Avg Chunk Interval: ") + chalk13.yellow(`${avgInterval.toFixed(0)} ms`)
3982
+ chalk5.white(" \u23F3 Avg Chunk Interval: ") + chalk5.yellow(`${avgInterval.toFixed(0)} ms`)
3710
3983
  );
3711
3984
  console.log(
3712
- chalk13.gray(" Min/Max: ") + chalk13.gray(
3985
+ chalk5.gray(" Min/Max: ") + chalk5.gray(
3713
3986
  `${minInterval.toFixed(0)} - ${maxInterval.toFixed(0)} ms`
3714
3987
  )
3715
3988
  );
3716
3989
  }
3717
- console.log(chalk13.bold.white("\n Data Transfer:"));
3718
- console.log(chalk13.gray(" \u2500".repeat(23)));
3990
+ console.log(chalk5.bold.white("\n Data Transfer:"));
3991
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3719
3992
  console.log(
3720
- chalk13.white(" \u{1F4E5} Total Data: ") + chalk13.yellow(`${(sm.totalBytes / 1024).toFixed(2)} KB`)
3993
+ chalk5.white(" \u{1F4E5} Total Data: ") + chalk5.yellow(`${(sm.totalBytes / 1024).toFixed(2)} KB`)
3721
3994
  );
3722
3995
  console.log(
3723
- chalk13.white(" \u{1F3B5} Audio File: ") + chalk13.yellow(
3996
+ chalk5.white(" \u{1F3B5} Audio File: ") + chalk5.yellow(
3724
3997
  `${((audioBuffer?.length || 0) / 1024).toFixed(2)} KB`
3725
3998
  )
3726
3999
  );
3727
- console.log(chalk13.bold.white("\n Performance Metrics:"));
3728
- console.log(chalk13.gray(" \u2500".repeat(23)));
4000
+ console.log(chalk5.bold.white("\n Performance Metrics:"));
4001
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3729
4002
  const throughputKBps = sm.totalBytes / 1024 / (sm.totalTime / 1e3);
3730
4003
  console.log(
3731
- chalk13.white(" \u{1F4F6} Stream Throughput: ") + chalk13.yellow(`${throughputKBps.toFixed(2)} KB/s`)
4004
+ chalk5.white(" \u{1F4F6} Stream Throughput: ") + chalk5.yellow(`${throughputKBps.toFixed(2)} KB/s`)
3732
4005
  );
3733
4006
  const audioDuration = (audioBuffer?.length || 0) / (128 * 125);
3734
4007
  const realTimeRatio = audioDuration / (sm.totalTime / 1e3);
3735
4008
  console.log(
3736
- chalk13.white(" \u{1F3B5} Audio Duration: ") + chalk13.yellow(`${audioDuration.toFixed(2)} seconds`)
4009
+ chalk5.white(" \u{1F3B5} Audio Duration: ") + chalk5.yellow(`${audioDuration.toFixed(2)} seconds`)
3737
4010
  );
3738
4011
  console.log(
3739
- chalk13.white(" \u26A1 Real-time Factor: ") + (realTimeRatio > 1 ? chalk13.green(`${realTimeRatio.toFixed(2)}x faster`) : chalk13.yellow(`${realTimeRatio.toFixed(2)}x`))
4012
+ chalk5.white(" \u26A1 Real-time Factor: ") + (realTimeRatio > 1 ? chalk5.green(`${realTimeRatio.toFixed(2)}x faster`) : chalk5.yellow(`${realTimeRatio.toFixed(2)}x`))
3740
4013
  );
3741
4014
  const streamingEfficiency = (sm.totalTime - sm.timeToFirstChunk) / sm.totalTime * 100;
3742
4015
  console.log(
3743
- chalk13.white(" \u{1F4C8} Stream Efficiency: ") + chalk13.yellow(`${streamingEfficiency.toFixed(1)}%`)
4016
+ chalk5.white(" \u{1F4C8} Stream Efficiency: ") + chalk5.yellow(`${streamingEfficiency.toFixed(1)}%`)
3744
4017
  );
3745
- console.log(chalk13.gray("\u2550".repeat(50)));
4018
+ console.log(chalk5.gray("\u2550".repeat(50)));
3746
4019
  } else {
3747
- console.log("\n" + chalk13.cyan("\u{1F4CA} Performance Statistics:"));
3748
- console.log(chalk13.gray("\u2550".repeat(50)));
3749
- console.log(chalk13.bold.white("\n Network Timing:"));
3750
- console.log(chalk13.gray(" \u2500".repeat(23)));
4020
+ console.log("\n" + chalk5.cyan("\u{1F4CA} Performance Statistics:"));
4021
+ console.log(chalk5.gray("\u2550".repeat(50)));
4022
+ console.log(chalk5.bold.white("\n Network Timing:"));
4023
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3751
4024
  console.log(
3752
- chalk13.white(" \u23F1\uFE0F Time to First Byte: ") + chalk13.yellow(`${m.ttfb.toFixed(0)} ms`)
4025
+ chalk5.white(" \u23F1\uFE0F Time to First Byte: ") + chalk5.yellow(`${m.ttfb.toFixed(0)} ms`)
3753
4026
  );
3754
4027
  if (m.downloadTime !== void 0) {
3755
4028
  console.log(
3756
- chalk13.white(" \u2B07\uFE0F Content Download: ") + chalk13.yellow(`${m.downloadTime.toFixed(0)} ms`)
4029
+ chalk5.white(" \u2B07\uFE0F Content Download: ") + chalk5.yellow(`${m.downloadTime.toFixed(0)} ms`)
3757
4030
  );
3758
4031
  }
3759
4032
  console.log(
3760
- chalk13.white(" \u23F2\uFE0F Total Time: ") + chalk13.bold.yellow(`${m.totalTime.toFixed(0)} ms`)
4033
+ chalk5.white(" \u23F2\uFE0F Total Time: ") + chalk5.bold.yellow(`${m.totalTime.toFixed(0)} ms`)
3761
4034
  );
3762
- console.log(chalk13.bold.white("\n Data Transfer:"));
3763
- console.log(chalk13.gray(" \u2500".repeat(23)));
4035
+ console.log(chalk5.bold.white("\n Data Transfer:"));
4036
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3764
4037
  if (m.requestSize) {
3765
4038
  console.log(
3766
- chalk13.white(" \u2B06\uFE0F Request Size: ") + chalk13.yellow(`${(m.requestSize / 1024).toFixed(2)} KB`)
4039
+ chalk5.white(" \u2B06\uFE0F Request Size: ") + chalk5.yellow(`${(m.requestSize / 1024).toFixed(2)} KB`)
3767
4040
  );
3768
4041
  }
3769
4042
  console.log(
3770
- chalk13.white(" \u2B07\uFE0F Response Size: ") + chalk13.yellow(`${(m.responseSize / 1024).toFixed(2)} KB`)
4043
+ chalk5.white(" \u2B07\uFE0F Response Size: ") + chalk5.yellow(`${(m.responseSize / 1024).toFixed(2)} KB`)
3771
4044
  );
3772
4045
  console.log(
3773
- chalk13.white(" \u{1F3B5} Audio File: ") + chalk13.yellow(
4046
+ chalk5.white(" \u{1F3B5} Audio File: ") + chalk5.yellow(
3774
4047
  `${((audioBuffer?.length || 0) / 1024).toFixed(2)} KB`
3775
4048
  )
3776
4049
  );
3777
- console.log(chalk13.bold.white("\n Performance Metrics:"));
3778
- console.log(chalk13.gray(" \u2500".repeat(23)));
4050
+ console.log(chalk5.bold.white("\n Performance Metrics:"));
4051
+ console.log(chalk5.gray(" \u2500".repeat(23)));
3779
4052
  const audioDuration = (audioBuffer?.length || 0) / (128 * 125);
3780
4053
  const realTimeRatio = audioDuration / (m.totalTime / 1e3);
3781
4054
  const serverTime = m.ttfb;
3782
4055
  console.log(
3783
- chalk13.white(" \u{1F5A5}\uFE0F Server Processing: ") + chalk13.yellow(`${Math.max(0, serverTime).toFixed(0)} ms`)
4056
+ chalk5.white(" \u{1F5A5}\uFE0F Server Processing: ") + chalk5.yellow(`${Math.max(0, serverTime).toFixed(0)} ms`)
3784
4057
  );
3785
4058
  console.log(
3786
- chalk13.white(" \u{1F3B5} Audio Duration: ") + chalk13.yellow(`${audioDuration.toFixed(2)} seconds`)
4059
+ chalk5.white(" \u{1F3B5} Audio Duration: ") + chalk5.yellow(`${audioDuration.toFixed(2)} seconds`)
3787
4060
  );
3788
4061
  console.log(
3789
- chalk13.white(" \u26A1 Real-time Factor: ") + (realTimeRatio > 1 ? chalk13.green(`${realTimeRatio.toFixed(2)}x faster`) : chalk13.yellow(`${realTimeRatio.toFixed(2)}x`))
4062
+ chalk5.white(" \u26A1 Real-time Factor: ") + (realTimeRatio > 1 ? chalk5.green(`${realTimeRatio.toFixed(2)}x faster`) : chalk5.yellow(`${realTimeRatio.toFixed(2)}x`))
3790
4063
  );
3791
4064
  const throughputMbps = (m.responseSize + (audioBuffer?.length || 0)) * 8 / (m.totalTime * 1e3);
3792
4065
  console.log(
3793
- chalk13.white(" \u{1F4F6} Throughput: ") + chalk13.yellow(`${throughputMbps.toFixed(2)} Mbps`)
4066
+ chalk5.white(" \u{1F4F6} Throughput: ") + chalk5.yellow(`${throughputMbps.toFixed(2)} Mbps`)
3794
4067
  );
3795
- console.log(chalk13.gray("\u2550".repeat(50)));
4068
+ console.log(chalk5.gray("\u2550".repeat(50)));
3796
4069
  }
3797
4070
  }
3798
4071
  if (response.timestampInfo?.wordAlignment) {
3799
4072
  const alignment = response.timestampInfo.wordAlignment;
3800
- console.log("\n" + chalk13.cyan("\u{1F4DD} Word Timestamps:"));
4073
+ console.log("\n" + chalk5.cyan("\u{1F4DD} Word Timestamps:"));
3801
4074
  alignment.words.forEach((word, i) => {
3802
4075
  const start = alignment.wordStartTimeSeconds[i].toFixed(3);
3803
4076
  const end = alignment.wordEndTimeSeconds[i].toFixed(3);
3804
- console.log(chalk13.gray(` ${start}s - ${end}s: ${word}`));
4077
+ console.log(chalk5.gray(` ${start}s - ${end}s: ${word}`));
3805
4078
  });
3806
4079
  }
3807
4080
  if (response.timestampInfo?.characterAlignment) {
3808
- console.log("\n" + chalk13.cyan("\u{1F4DD} Character Timestamps:"));
4081
+ console.log("\n" + chalk5.cyan("\u{1F4DD} Character Timestamps:"));
3809
4082
  console.log(
3810
- chalk13.gray(
4083
+ chalk5.gray(
3811
4084
  " (Too detailed to display - use --json to see full data)"
3812
4085
  )
3813
4086
  );
3814
4087
  }
3815
4088
  process.exit(0);
3816
4089
  } catch (error) {
3817
- console.error(chalk13.red("\u274C Error synthesizing speech:"));
3818
- console.error(chalk13.red(error.message || error));
4090
+ console.error(chalk5.red("\u274C Error synthesizing speech:"));
4091
+ console.error(chalk5.red(error.message || error));
3819
4092
  process.exit(1);
3820
4093
  }
3821
4094
  });
3822
- var ttsCommand = new Command17("tts").description("Text-to-speech functionality").addCommand(listVoicesCommand).addCommand(synthesizeCommand).action(() => {
4095
+ var ttsCommand = new Command20("tts").description("Text-to-speech functionality").addCommand(listVoicesCommand).addCommand(synthesizeCommand).action(() => {
3823
4096
  ttsCommand.help();
3824
4097
  });
3825
4098
 
3826
4099
  // src/commands/workspace_command.ts
3827
- import { Command as Command18 } from "commander";
3828
- var selectWorkspaceCommand = new Command18("select").description("Select a workspace for CLI operations").action(async () => {
4100
+ import { Command as Command21 } from "commander";
4101
+ var selectWorkspaceCommand = new Command21("select").description("Select a workspace for CLI operations").action(async () => {
3829
4102
  await requireAuth();
3830
4103
  try {
3831
4104
  await WorkspaceService.activateWorkspace();
@@ -3835,17 +4108,140 @@ var selectWorkspaceCommand = new Command18("select").description("Select a works
3835
4108
  process.exit(1);
3836
4109
  }
3837
4110
  });
3838
- var workspaceCommand = new Command18("workspace").description("Manage Inworld workspaces").alias("ws").addCommand(selectWorkspaceCommand).action(() => {
4111
+ var workspaceCommand = new Command21("workspace").description("Manage Inworld workspaces").alias("ws").addCommand(selectWorkspaceCommand).action(() => {
3839
4112
  workspaceCommand.help();
3840
4113
  });
3841
4114
 
3842
- // index.ts
4115
+ // src/services/update_checker.ts
4116
+ import Conf3 from "conf";
4117
+ import * as semver from "semver";
4118
+ var UpdateChecker = class _UpdateChecker {
4119
+ static PACKAGE_NAME = "@inworld/cli";
4120
+ static CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
4121
+ // 24 hours
4122
+ static NPM_REGISTRY_URL = "https://registry.npmjs.org";
4123
+ static REQUEST_TIMEOUT = 3e3;
4124
+ // 3 seconds
4125
+ static CONF_ENTRY_NAME = "updateCheck";
4126
+ conf;
4127
+ constructor() {
4128
+ this.conf = new Conf3({
4129
+ projectName: "inworld-cli-config"
4130
+ });
4131
+ }
4132
+ /**
4133
+ * Checks if an update is available and displays a notification if needed.
4134
+ * This method is non-blocking and will not throw errors.
4135
+ */
4136
+ async checkAndNotify() {
4137
+ try {
4138
+ const shouldCheck = this.shouldCheckForUpdate();
4139
+ if (!shouldCheck) {
4140
+ const cached = this.conf.get(_UpdateChecker.CONF_ENTRY_NAME);
4141
+ if (cached) {
4142
+ const shouldUpdate2 = this.compareVersions(
4143
+ CLI_VERSION,
4144
+ cached.latestVersion
4145
+ );
4146
+ if (shouldUpdate2) {
4147
+ this.displayUpdateNotification(cached.latestVersion);
4148
+ }
4149
+ }
4150
+ return;
4151
+ }
4152
+ const latestVersion = await this.fetchLatestVersion();
4153
+ if (!latestVersion) {
4154
+ return;
4155
+ }
4156
+ const shouldUpdate = this.compareVersions(CLI_VERSION, latestVersion);
4157
+ this.conf.set("updateCheck", {
4158
+ lastChecked: Date.now(),
4159
+ latestVersion,
4160
+ shouldUpdate
4161
+ });
4162
+ if (shouldUpdate) {
4163
+ this.displayUpdateNotification(latestVersion);
4164
+ }
4165
+ } catch (error) {
4166
+ }
4167
+ }
4168
+ /**
4169
+ * Determines if we should check for updates based on cache age
4170
+ */
4171
+ shouldCheckForUpdate() {
4172
+ const cached = this.conf.get("updateCheck");
4173
+ if (!cached) {
4174
+ return true;
4175
+ }
4176
+ const timeSinceLastCheck = Date.now() - cached.lastChecked;
4177
+ return timeSinceLastCheck > _UpdateChecker.CHECK_INTERVAL;
4178
+ }
4179
+ /**
4180
+ * Fetches the latest version from npm registry
4181
+ */
4182
+ async fetchLatestVersion() {
4183
+ try {
4184
+ const controller = new AbortController();
4185
+ const timeout = setTimeout(() => {
4186
+ controller.abort();
4187
+ }, _UpdateChecker.REQUEST_TIMEOUT);
4188
+ const response = await fetch(
4189
+ `${_UpdateChecker.NPM_REGISTRY_URL}/${_UpdateChecker.PACKAGE_NAME}/latest`,
4190
+ {
4191
+ signal: controller.signal,
4192
+ headers: {
4193
+ Accept: "application/json"
4194
+ }
4195
+ }
4196
+ );
4197
+ clearTimeout(timeout);
4198
+ if (!response.ok) {
4199
+ return null;
4200
+ }
4201
+ const data = await response.json();
4202
+ return data.version || null;
4203
+ } catch (error) {
4204
+ return null;
4205
+ }
4206
+ }
4207
+ /**
4208
+ * Compares current version with latest version
4209
+ * Returns true if an update is available
4210
+ */
4211
+ compareVersions(current, latest) {
4212
+ try {
4213
+ const currentClean = semver.clean(current);
4214
+ const latestClean = semver.clean(latest);
4215
+ if (!currentClean || !latestClean) {
4216
+ return false;
4217
+ }
4218
+ return semver.gt(latestClean, currentClean);
4219
+ } catch (error) {
4220
+ return false;
4221
+ }
4222
+ }
4223
+ /**
4224
+ * Displays a styled update notification to the user
4225
+ */
4226
+ displayUpdateNotification(latestVersion) {
4227
+ const lines = [
4228
+ bold("Update available! ") + `${CLI_VERSION} \u2192 ` + green(`${latestVersion}`),
4229
+ "",
4230
+ "Run " + cyan("npm install -g @inworld/cli") + " to update"
4231
+ ];
4232
+ printBox(lines, { color: "gray" });
4233
+ }
4234
+ };
4235
+ var updateChecker = new UpdateChecker();
4236
+
4237
+ // src/index.ts
3843
4238
  var version = CLI_VERSION;
3844
4239
  process.env.DISABLE_WELCOME_MESSAGE = "true";
3845
4240
  var InworldCLI = class {
3846
4241
  program;
4242
+ currentCommand = null;
3847
4243
  constructor() {
3848
- this.program = new Command19();
4244
+ this.program = new Command22();
3849
4245
  this.setupProgram();
3850
4246
  this.registerCommands();
3851
4247
  }
@@ -3855,8 +4251,44 @@ var InworldCLI = class {
3855
4251
  writeErr: (str) => process.stderr.write(str),
3856
4252
  getOutHelpWidth: () => process.stdout.columns || 80,
3857
4253
  getErrHelpWidth: () => process.stderr.columns || 80
4254
+ }).hook("preAction", (_thisCommand, actionCommand) => {
4255
+ const commandName = this.getCommandName(actionCommand);
4256
+ this.currentCommand = commandName;
4257
+ const options = actionCommand.opts();
4258
+ const sanitizedOptions = this.sanitizeOptions(options);
4259
+ analytics.trackCommandExecution(commandName, sanitizedOptions);
3858
4260
  });
3859
4261
  }
4262
+ /**
4263
+ * Gets the full command name from a Command instance
4264
+ */
4265
+ getCommandName(command) {
4266
+ let name = command.name();
4267
+ while (command.parent && command.parent.name() !== "inworld") {
4268
+ command = command.parent;
4269
+ name = `${command.name()} ${name}`;
4270
+ }
4271
+ return name;
4272
+ }
4273
+ /**
4274
+ * Sanitizes command options to remove sensitive data
4275
+ */
4276
+ sanitizeOptions(options) {
4277
+ const sanitized = {};
4278
+ const sensitiveKeys = ["token", "apikey", "password", "secret", "key"];
4279
+ for (const [key, value] of Object.entries(options)) {
4280
+ const lowerKey = key.toLowerCase();
4281
+ const isSensitive = sensitiveKeys.some((k) => lowerKey.includes(k));
4282
+ if (isSensitive) {
4283
+ sanitized[key] = "[REDACTED]";
4284
+ } else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
4285
+ sanitized[key] = value;
4286
+ } else {
4287
+ sanitized[key] = typeof value;
4288
+ }
4289
+ }
4290
+ return sanitized;
4291
+ }
3860
4292
  registerCommands() {
3861
4293
  this.program.addCommand(loginCommandAlias);
3862
4294
  this.program.addCommand(logoutCommandAlias);
@@ -3875,19 +4307,34 @@ var InworldCLI = class {
3875
4307
  }
3876
4308
  async run(args) {
3877
4309
  try {
4310
+ const initPromise = Promise.all([
4311
+ analytics.initialize().catch(() => {
4312
+ }),
4313
+ updateChecker.checkAndNotify().catch(() => {
4314
+ })
4315
+ ]);
4316
+ const timeoutPromise = new Promise(
4317
+ (resolve2) => setTimeout(resolve2, 1e3)
4318
+ );
4319
+ await Promise.race([initPromise, timeoutPromise]);
3878
4320
  await this.program.parseAsync(args);
4321
+ await analytics.flush();
3879
4322
  } catch (error) {
4323
+ if (this.currentCommand) {
4324
+ const errorMessage = error instanceof Error ? error.message : String(error);
4325
+ analytics.trackCommandResult(this.currentCommand, false, errorMessage);
4326
+ }
3880
4327
  console.error(
3881
- chalk14.red("Error:"),
4328
+ chalk6.red("Error:"),
3882
4329
  error instanceof Error ? error.message : String(error)
3883
4330
  );
4331
+ await analytics.flush();
3884
4332
  process.exit(1);
3885
4333
  }
3886
4334
  }
3887
4335
  };
3888
4336
  var cli = new InworldCLI();
3889
4337
  cli.run().catch((error) => {
3890
- console.error(chalk14.red("Fatal error:"), error);
4338
+ console.error(chalk6.red("Fatal error:"), error);
3891
4339
  process.exit(1);
3892
4340
  });
3893
- //# sourceMappingURL=index.js.map