@inworld/cli 0.2.15 → 0.3.0-rc.5

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 (225) hide show
  1. package/dist/index.js +1246 -544
  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 +8 -9
  213. package/package.json +5 -4
  214. package/dist/src/templates/simple/README.md +0 -106
  215. package/dist/src/templates/simple/graph.ts +0 -32
  216. package/dist/src/templates/simple/metadata.json +0 -26
  217. package/dist/templates/simple/README.md +0 -106
  218. package/dist/templates/simple/graph.ts +0 -32
  219. package/dist/templates/simple/metadata.json +0 -26
  220. package/src/templates/llm_tts/README.md +0 -155
  221. package/src/templates/llm_tts/graph.ts +0 -30
  222. package/src/templates/llm_tts/metadata.json +0 -41
  223. package/src/templates/simple/README.md +0 -106
  224. package/src/templates/simple/graph.ts +0 -32
  225. package/src/templates/simple/metadata.json +0 -26
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAC3B,GAAoB,EACpB,SAAqC;IAErC,OAAO,CACL,OAAO,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Sets the global auto-confirm flag
3
+ * @param value If true, all confirmations will be auto-accepted
4
+ */
5
+ export declare function setGlobalForceYes(value: boolean): void;
6
+ /**
7
+ * Gets the current global auto-confirm flag value
8
+ */
9
+ export declare function getGlobalForceYes(): boolean;
10
+ /**
11
+ * Options for confirmation prompts
12
+ */
13
+ export interface ConfirmOptions {
14
+ /**
15
+ * The prompt message to show the user
16
+ */
17
+ message: string;
18
+ /**
19
+ * If true, automatically confirm without prompting
20
+ * Overrides global forceYes setting
21
+ */
22
+ forceYes?: boolean;
23
+ /**
24
+ * The default value if user just presses enter (defaults to false)
25
+ */
26
+ defaultValue?: boolean;
27
+ }
28
+ /**
29
+ * Prompts the user for a yes/no confirmation
30
+ * Supports auto-confirm via forceYes parameter or global setting
31
+ *
32
+ * @param options Confirmation options
33
+ * @returns Promise that resolves to true if user confirmed, false otherwise
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const shouldProceed = await confirm({
38
+ * message: 'Do you want to continue?',
39
+ * defaultValue: false
40
+ * });
41
+ * if (shouldProceed) {
42
+ * // proceed with action
43
+ * }
44
+ * ```
45
+ */
46
+ export declare function confirm(options: ConfirmOptions): Promise<boolean>;
47
+ /**
48
+ * Prompts the user for confirmation and exits the process if declined
49
+ *
50
+ * @param options Confirmation options
51
+ * @param exitCode Exit code to use if user declines (defaults to 1)
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * await confirmOrExit({
56
+ * message: 'This will delete all data. Continue? (y/N): '
57
+ * });
58
+ * // Code only reaches here if user confirmed
59
+ * ```
60
+ */
61
+ export declare function confirmOrExit(options: ConfirmOptions, exitCode?: number): Promise<void>;
62
+ //# sourceMappingURL=confirm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../../src/utils/confirm.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAwCvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,QAAQ,GAAE,MAAU,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -0,0 +1,90 @@
1
+ import * as readline from 'readline';
2
+ /**
3
+ * Global context for confirmation prompts
4
+ */
5
+ let globalForceYes = false;
6
+ /**
7
+ * Sets the global auto-confirm flag
8
+ * @param value If true, all confirmations will be auto-accepted
9
+ */
10
+ export function setGlobalForceYes(value) {
11
+ globalForceYes = value;
12
+ }
13
+ /**
14
+ * Gets the current global auto-confirm flag value
15
+ */
16
+ export function getGlobalForceYes() {
17
+ return globalForceYes;
18
+ }
19
+ /**
20
+ * Prompts the user for a yes/no confirmation
21
+ * Supports auto-confirm via forceYes parameter or global setting
22
+ *
23
+ * @param options Confirmation options
24
+ * @returns Promise that resolves to true if user confirmed, false otherwise
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const shouldProceed = await confirm({
29
+ * message: 'Do you want to continue?',
30
+ * defaultValue: false
31
+ * });
32
+ * if (shouldProceed) {
33
+ * // proceed with action
34
+ * }
35
+ * ```
36
+ */
37
+ export async function confirm(options) {
38
+ const { message, forceYes, defaultValue = false } = options;
39
+ // Check if we should auto-confirm (local override or global setting)
40
+ if (forceYes !== undefined ? forceYes : globalForceYes) {
41
+ return true;
42
+ }
43
+ const rl = readline.createInterface({
44
+ input: process.stdin,
45
+ output: process.stdout,
46
+ });
47
+ return new Promise((resolve) => {
48
+ rl.question(message, (answer) => {
49
+ rl.close();
50
+ const trimmedAnswer = answer.trim().toLowerCase();
51
+ // Handle explicit yes/no
52
+ if (trimmedAnswer === 'y' || trimmedAnswer === 'yes') {
53
+ resolve(true);
54
+ return;
55
+ }
56
+ if (trimmedAnswer === 'n' || trimmedAnswer === 'no') {
57
+ resolve(false);
58
+ return;
59
+ }
60
+ // Empty answer uses default
61
+ if (trimmedAnswer === '') {
62
+ resolve(defaultValue);
63
+ return;
64
+ }
65
+ // Invalid input defaults to false for safety
66
+ resolve(false);
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Prompts the user for confirmation and exits the process if declined
72
+ *
73
+ * @param options Confirmation options
74
+ * @param exitCode Exit code to use if user declines (defaults to 1)
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * await confirmOrExit({
79
+ * message: 'This will delete all data. Continue? (y/N): '
80
+ * });
81
+ * // Code only reaches here if user confirmed
82
+ * ```
83
+ */
84
+ export async function confirmOrExit(options, exitCode = 1) {
85
+ const confirmed = await confirm(options);
86
+ if (!confirmed) {
87
+ process.exit(exitCode);
88
+ }
89
+ }
90
+ //# sourceMappingURL=confirm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../../src/utils/confirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,cAAc,GAAG,KAAK,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAuBD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAuB;IACnD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAE5D,qEAAqE;IACrE,IAAI,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAc,EAAE,EAAE;YACtC,EAAE,CAAC,KAAK,EAAE,CAAC;YAEX,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAElD,yBAAyB;YACzB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;gBACrD,OAAO,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO;YACT,CAAC;YAED,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBACpD,OAAO,CAAC,KAAK,CAAC,CAAC;gBACf,OAAO;YACT,CAAC;YAED,4BAA4B;YAC5B,IAAI,aAAa,KAAK,EAAE,EAAE,CAAC;gBACzB,OAAO,CAAC,YAAY,CAAC,CAAC;gBACtB,OAAO;YACT,CAAC;YAED,6CAA6C;YAC7C,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAuB,EACvB,WAAmB,CAAC;IAEpB,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { ErrorStatus } from '@/grpc/core/InworldError';
2
+ export type LongRunningOperationResponse = {
3
+ name: string;
4
+ metadata?: any;
5
+ done: boolean;
6
+ error?: ErrorStatus;
7
+ response?: any;
8
+ };
9
+ export declare const isLongRunningOperationResponse: (obj: any) => obj is LongRunningOperationResponse;
10
+ export declare const CHECK_LIMIT = 60;
11
+ export declare const CHECK_TIMEOUT = 2000;
12
+ export type LROPollOptions<T> = {
13
+ currentIteration?: number;
14
+ skipCheck?: boolean;
15
+ isRunning?: boolean;
16
+ operationName?: string;
17
+ startCallback?: (operationName: string) => void;
18
+ iterationCallback?: (operationName: string, checkResponse: {
19
+ done?: boolean | undefined;
20
+ response?: T | undefined;
21
+ error?: string | undefined;
22
+ } | undefined, checkData: {
23
+ checkIteration: number;
24
+ checkLimit: number;
25
+ checkTimeout: number;
26
+ }) => void;
27
+ doneCallback?: (operationName: string, response: T | undefined) => void;
28
+ errorCallback?: (operationName: string, error: string) => void;
29
+ };
30
+ export declare const checkLRO: <T>({ operationName, signal, checkLimit, checkTimeout, pollOptions, returnWithMetadata, }: {
31
+ operationName: string;
32
+ signal?: AbortSignal;
33
+ checkLimit?: number;
34
+ checkTimeout?: number;
35
+ pollOptions?: LROPollOptions<T>;
36
+ returnWithMetadata?: boolean;
37
+ }) => Promise<T>;
38
+ //# sourceMappingURL=long_running_operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"long_running_operations.d.ts","sourceRoot":"","sources":["../../../src/utils/long_running_operations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AASF,eAAO,MAAM,8BAA8B,GACzC,KAAK,GAAG,KACP,GAAG,IAAI,4BAK6C,CAAC;AAExD,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,iBAAiB,CAAC,EAAE,CAClB,aAAa,EAAE,MAAM,EACrB,aAAa,EACT;QACE,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC3B,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,GACD,SAAS,EACb,SAAS,EAAE;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,KACE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChE,CAAC;AAGF,eAAO,MAAM,QAAQ,GAAU,CAAC,EAAE,uFAO/B;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,eA2CA,CAAC"}
@@ -0,0 +1,62 @@
1
+ // Potred from portal ui code.
2
+ import { Operations } from '@/proto/generated/portal/ai/inworld/studio/v1/operations.pb';
3
+ import { retryableAuthenticatedInworldRequest } from '@/auth/utils';
4
+ const isOperationError = (obj) => typeof obj === 'object' &&
5
+ obj !== null &&
6
+ typeof obj.code === 'number' &&
7
+ typeof obj.message === 'string' &&
8
+ ('details' in obj ? Array.isArray(obj.details) : true);
9
+ export const isLongRunningOperationResponse = (obj) => typeof obj === 'object' &&
10
+ obj !== null &&
11
+ typeof obj.name === 'string' &&
12
+ typeof obj.done === 'boolean' &&
13
+ ('error' in obj ? isOperationError(obj.error) : true);
14
+ export const CHECK_LIMIT = 60;
15
+ export const CHECK_TIMEOUT = 2000;
16
+ //Decoupled polling logic from calling the operation
17
+ export const checkLRO = async ({ operationName, signal, checkLimit, checkTimeout, pollOptions, returnWithMetadata, }) => {
18
+ let checkResponse;
19
+ checkLimit = checkLimit ?? CHECK_LIMIT;
20
+ checkTimeout = checkTimeout ?? CHECK_TIMEOUT;
21
+ if (pollOptions?.startCallback) {
22
+ pollOptions.startCallback(operationName);
23
+ }
24
+ for (let i = pollOptions?.currentIteration ?? 0; i < checkLimit; i++) {
25
+ signal?.throwIfAborted();
26
+ try {
27
+ checkResponse = await check(operationName, signal, returnWithMetadata);
28
+ if (checkResponse?.done) {
29
+ if (checkResponse?.error || checkResponse?.metadata?.error) {
30
+ pollOptions?.errorCallback?.(operationName, checkResponse.error || checkResponse?.metadata?.error);
31
+ throw checkResponse.error || checkResponse?.metadata?.error;
32
+ }
33
+ pollOptions?.doneCallback?.(operationName, checkResponse?.response);
34
+ return (returnWithMetadata ? checkResponse : checkResponse?.response);
35
+ }
36
+ else {
37
+ pollOptions?.iterationCallback?.(operationName, checkResponse, {
38
+ checkIteration: i,
39
+ checkLimit,
40
+ checkTimeout,
41
+ });
42
+ }
43
+ }
44
+ catch (error) {
45
+ pollOptions?.errorCallback?.(operationName, error);
46
+ throw error;
47
+ }
48
+ await new Promise((resolve) => setTimeout(resolve, checkTimeout));
49
+ }
50
+ throw new Error(`Operation timeout. Max number of checks reached ${checkLimit}`);
51
+ };
52
+ const check = async (operationName, signal, returnWithMetadata) => retryableAuthenticatedInworldRequest(Operations.GetOperation, {
53
+ nameworkspacescharactersoperations: operationName,
54
+ }, returnWithMetadata
55
+ ? {
56
+ withMetadata: true,
57
+ maxRetries: 1,
58
+ backoffFactor: 2,
59
+ minTimeout: 300,
60
+ }
61
+ : undefined, signal);
62
+ //# sourceMappingURL=long_running_operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"long_running_operations.js","sourceRoot":"","sources":["../../../src/utils/long_running_operations.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAYpE,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAsB,EAAE,CACxD,OAAO,GAAG,KAAK,QAAQ;IACvB,GAAG,KAAK,IAAI;IACZ,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;IAC5B,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;IAC/B,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,GAAQ,EAC6B,EAAE,CACvC,OAAO,GAAG,KAAK,QAAQ;IACvB,GAAG,KAAK,IAAI;IACZ,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;IAC5B,OAAO,GAAG,CAAC,IAAI,KAAK,SAAS;IAC7B,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AA2BlC,oDAAoD;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAK,EAChC,aAAa,EACb,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,GAQnB,EAAE,E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KAAK,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,IAAI,KAAK,CACb,mDAAmD,UAAU,EAAE,CAChE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,KAAK,EACjB,aAAqB,EACrB,MAAoB,EACpB,kBAA4B,EAC5B,EAAE,CACF,oCAAoC,CAUlC,UAAU,CAAC,YAAY,EACvB;IACE,kCAAkC,EAAE,aAAa;CAClD,EACD,kBAAkB;IAChB,CAAC,CAAC;QACE,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,CAAC;QAChB,UAAU,EAAE,GAAG;KAChB;IACH,CAAC,CAAC,SAAS,EACb,MAAM,CACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ export declare const parseWorkspaceResourceName: (resourceName: string) => {
2
+ workspaceId: string;
3
+ };
4
+ export declare const parseGraphResourceName: (resourceName: string) => {
5
+ workspaceId: string;
6
+ graphId: string;
7
+ };
8
+ export declare const getGraphResourceName: (workspaceId: string, graphId: string) => string;
9
+ export declare const getGraphVariantResourceName: (workspaceId: string, graphId: string, variantId: string) => string;
10
+ export declare const getWorkspaceResourceName: (workspaceId: string) => string;
11
+ export declare const getGraphDeploymentResourceName: (workspaceId: string, graphId: string) => string;
12
+ //# sourceMappingURL=resource_name_helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource_name_helper.d.ts","sourceRoot":"","sources":["../../../src/utils/resource_name_helper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,cAAc,MAAM;;CAM9D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,cAAc,MAAM;;;CAW1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,EAAE,SAAS,MAAM,WAExE,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,aAAa,MAAM,EACnB,SAAS,MAAM,EACf,WAAW,MAAM,WAGlB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,aAAa,MAAM,WAE3D,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACzC,aAAa,MAAM,EACnB,SAAS,MAAM,WAGhB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const parseWorkspaceResourceName = (resourceName) => {
2
+ const [collection, workspaceId] = resourceName.split('/');
3
+ if (collection !== 'workspaces') {
4
+ throw new Error(`Invalid workspace resource name: ${resourceName}`);
5
+ }
6
+ return { workspaceId };
7
+ };
8
+ export const parseGraphResourceName = (resourceName) => {
9
+ const [workspaceCollection, workspaceId, graphCollection, graphId] = resourceName.split('/');
10
+ if (workspaceCollection !== 'workspaces' ||
11
+ graphCollection !== 'graphs' ||
12
+ graphId === undefined) {
13
+ throw new Error(`Invalid graph resource name: ${resourceName}`);
14
+ }
15
+ return { workspaceId, graphId };
16
+ };
17
+ export const getGraphResourceName = (workspaceId, graphId) => {
18
+ return `workspaces/${workspaceId}/graphs/${graphId}`;
19
+ };
20
+ export const getGraphVariantResourceName = (workspaceId, graphId, variantId) => {
21
+ return `${getGraphResourceName(workspaceId, graphId)}/variants/${variantId}`;
22
+ };
23
+ export const getWorkspaceResourceName = (workspaceId) => {
24
+ return `workspaces/${workspaceId}`;
25
+ };
26
+ export const getGraphDeploymentResourceName = (workspaceId, graphId) => {
27
+ return `${getGraphResourceName(workspaceId, graphId)}/deploy`;
28
+ };
29
+ //# sourceMappingURL=resource_name_helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource_name_helper.js","sourceRoot":"","sources":["../../../src/utils/resource_name_helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAoB,EAAE,EAAE;IACjE,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,YAA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C"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Options for configuring the selector behavior
3
+ */
4
+ export interface SelectorOptions<T> {
5
+ /**
6
+ * The items to select from
7
+ */
8
+ items: T[];
9
+ /**
10
+ * Function to get the display name for an item
11
+ */
12
+ getDisplayName: (item: T) => string;
13
+ /**
14
+ * Function to get the ID/resource name for an item
15
+ */
16
+ getIdentifier: (item: T) => string;
17
+ /**
18
+ * The prompt message to show to the user
19
+ */
20
+ prompt: string;
21
+ /**
22
+ * The title to show before listing items
23
+ */
24
+ title: string;
25
+ /**
26
+ * If true, automatically select the first item without prompting
27
+ */
28
+ forceFirst?: boolean;
29
+ /**
30
+ * Message to show when no items are found
31
+ */
32
+ noItemsMessage?: string;
33
+ /**
34
+ * Message to show for invalid selection
35
+ */
36
+ invalidSelectionMessage?: string;
37
+ }
38
+ /**
39
+ * Generic selector utility that provides a consistent interface for selecting items
40
+ * from a list. Supports selection by index number or identifier.
41
+ *
42
+ * @param options Configuration options for the selector
43
+ * @returns The selected item or null if no selection was made
44
+ */
45
+ export declare function selectItem<T>(options: SelectorOptions<T>): Promise<T | null>;
46
+ /**
47
+ * Selector options with exit capability
48
+ */
49
+ export interface SelectorWithExitOptions<T> extends SelectorOptions<T> {
50
+ /**
51
+ * If true, the process will exit with code 1 when selection fails
52
+ */
53
+ exitOnFailure?: boolean;
54
+ }
55
+ /**
56
+ * Wrapper around selectItem that exits the process on failure
57
+ *
58
+ * @param options Configuration options for the selector
59
+ * @returns The selected item (never null due to process exit on failure)
60
+ */
61
+ export declare function selectItemOrExit<T>(options: SelectorWithExitOptions<T>): Promise<T>;
62
+ //# sourceMappingURL=selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../../src/utils/selector.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX;;OAEG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAEpC;;OAEG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAEnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAwEnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACpE;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,CAAC,CAAC,CAUZ"}
@@ -0,0 +1,77 @@
1
+ import * as readline from 'readline';
2
+ import * as ui from './ui';
3
+ /**
4
+ * Generic selector utility that provides a consistent interface for selecting items
5
+ * from a list. Supports selection by index number or identifier.
6
+ *
7
+ * @param options Configuration options for the selector
8
+ * @returns The selected item or null if no selection was made
9
+ */
10
+ export async function selectItem(options) {
11
+ const { items, getDisplayName, getIdentifier, prompt, title, forceFirst = false, noItemsMessage = 'No items found.', invalidSelectionMessage = 'Invalid selection. Please enter a valid number or identifier.', } = options;
12
+ if (items.length === 0) {
13
+ ui.printError(noItemsMessage);
14
+ return null;
15
+ }
16
+ // If forceFirst is true, return the first item without prompting
17
+ if (forceFirst) {
18
+ return items[0];
19
+ }
20
+ // Display available items
21
+ console.log();
22
+ ui.printHeader(title);
23
+ items.forEach((item, idx) => {
24
+ const displayName = getDisplayName(item);
25
+ const identifier = getIdentifier(item);
26
+ ui.printListItem(`${idx + 1}. ${displayName} (ID: ${identifier})`);
27
+ });
28
+ // Create readline interface for user input
29
+ const rl = readline.createInterface({
30
+ input: process.stdin,
31
+ output: process.stdout,
32
+ });
33
+ const question = (query) => new Promise((resolve) => rl.question(query, resolve));
34
+ let selectedItem = null;
35
+ try {
36
+ while (!selectedItem) {
37
+ const answer = (await question(`\n${prompt} `)).trim();
38
+ // Try to match by number
39
+ const idx = parseInt(answer, 10);
40
+ if (!isNaN(idx) && idx >= 1 && idx <= items.length) {
41
+ selectedItem = items[idx - 1];
42
+ }
43
+ else {
44
+ // Try to match by identifier (full or partial)
45
+ selectedItem =
46
+ items.find((item) => {
47
+ const identifier = getIdentifier(item);
48
+ return (identifier === answer || identifier.split('/').pop() === answer);
49
+ }) || null;
50
+ }
51
+ if (!selectedItem) {
52
+ ui.printError(invalidSelectionMessage);
53
+ // Exit the loop and return null for invalid selection
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ finally {
59
+ rl.close();
60
+ }
61
+ return selectedItem;
62
+ }
63
+ /**
64
+ * Wrapper around selectItem that exits the process on failure
65
+ *
66
+ * @param options Configuration options for the selector
67
+ * @returns The selected item (never null due to process exit on failure)
68
+ */
69
+ export async function selectItemOrExit(options) {
70
+ const { exitOnFailure = true, ...selectorOptions } = options;
71
+ const selected = await selectItem(selectorOptions);
72
+ if (!selected && exitOnFailure) {
73
+ process.exit(1);
74
+ }
75
+ return selected;
76
+ }
77
+ //# sourceMappingURL=selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.js","sourceRoot":"","sources":["../../../src/utils/selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AA+C3B;;;;;;GAMG;AACH,MAAM,CAAC,K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AAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,QAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Configuration for the LRO spinner
3
+ */
4
+ export interface LROSpinnerConfig {
5
+ initialText?: string;
6
+ phraseInterval?: number;
7
+ showIterations?: boolean;
8
+ spinnerStyle?: string;
9
+ }
10
+ /**
11
+ * Creates and manages a spinner for long-running operations
12
+ */
13
+ export declare class LROSpinner {
14
+ private spinner;
15
+ private phraseInterval?;
16
+ private currentPhraseIndex;
17
+ private config;
18
+ private iterationCount;
19
+ private startTime;
20
+ constructor(config?: LROSpinnerConfig);
21
+ /**
22
+ * Starts the spinner with rotating phrases
23
+ */
24
+ start(): void;
25
+ /**
26
+ * Updates the spinner text with current phrase and optional iteration count
27
+ */
28
+ private updateText;
29
+ /**
30
+ * Updates the iteration count
31
+ */
32
+ updateIteration(iteration: number): void;
33
+ /**
34
+ * Updates spinner with custom text temporarily
35
+ */
36
+ updateCustomText(text: string): void;
37
+ /**
38
+ * Succeeds the spinner with a success message
39
+ */
40
+ succeed(text?: string): void;
41
+ /**
42
+ * Fails the spinner with an error message
43
+ */
44
+ fail(text?: string): void;
45
+ /**
46
+ * Warns the spinner with a warning message
47
+ */
48
+ warn(text?: string): void;
49
+ /**
50
+ * Stops the spinner without any status
51
+ */
52
+ stop(): void;
53
+ /**
54
+ * Cleans up intervals
55
+ */
56
+ private cleanup;
57
+ /**
58
+ * Gets a random phrase for one-off usage
59
+ */
60
+ static getRandomPhrase(): string;
61
+ }
62
+ /**
63
+ * Helper function to create spinner callbacks for LRO operations
64
+ */
65
+ export declare function createLROSpinnerCallbacks(config?: LROSpinnerConfig): {
66
+ startCallback: (operationName: string) => void;
67
+ iterationCallback: (operationName: string, _checkResponse: any, checkData: {
68
+ checkIteration: number;
69
+ checkLimit: number;
70
+ checkTimeout: number;
71
+ }) => void;
72
+ doneCallback: (_operationName: string, _response: any) => void;
73
+ errorCallback: (operationName: string, error: string) => void;
74
+ };
75
+ //# sourceMappingURL=spinner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/utils/spinner.ts"],"names":[],"mappings":"AA8BA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,GAAE,gBAAqB;IAkBzC;;OAEG;IACH,KAAK,IAAI,IAAI;IAWb;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKxC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpC;;OAEG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ5B;;OAEG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAMzB;;OAEG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAMzB;;OAEG;IACH,IAAI,IAAI,IAAI;IAKZ;;OAEG;IACH,OAAO,CAAC,OAAO;IAOf;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,MAAM;CAGjC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,gBAAgB;mCAIhC,MAAM;uCASpB,MAAM,kBACL,GAAG,aACR;QACT,cAAc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