@cargo-ai/cli 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +114 -0
  2. package/build/api.d.ts +4 -0
  3. package/build/api.d.ts.map +1 -0
  4. package/build/api.js +10 -0
  5. package/build/commands/ai/agent.d.ts +4 -0
  6. package/build/commands/ai/agent.d.ts.map +1 -0
  7. package/build/commands/ai/agent.js +83 -0
  8. package/build/commands/ai/chat.d.ts +4 -0
  9. package/build/commands/ai/chat.d.ts.map +1 -0
  10. package/build/commands/ai/chat.js +71 -0
  11. package/build/commands/ai/document.d.ts +4 -0
  12. package/build/commands/ai/document.d.ts.map +1 -0
  13. package/build/commands/ai/document.js +59 -0
  14. package/build/commands/ai/file.d.ts +4 -0
  15. package/build/commands/ai/file.d.ts.map +1 -0
  16. package/build/commands/ai/file.js +74 -0
  17. package/build/commands/ai/index.d.ts +4 -0
  18. package/build/commands/ai/index.d.ts.map +1 -0
  19. package/build/commands/ai/index.js +33 -0
  20. package/build/commands/ai/mcpClient.d.ts +4 -0
  21. package/build/commands/ai/mcpClient.d.ts.map +1 -0
  22. package/build/commands/ai/mcpClient.js +31 -0
  23. package/build/commands/ai/mcpServer.d.ts +4 -0
  24. package/build/commands/ai/mcpServer.d.ts.map +1 -0
  25. package/build/commands/ai/mcpServer.js +62 -0
  26. package/build/commands/ai/memory.d.ts +4 -0
  27. package/build/commands/ai/memory.d.ts.map +1 -0
  28. package/build/commands/ai/memory.js +50 -0
  29. package/build/commands/ai/message.d.ts +4 -0
  30. package/build/commands/ai/message.d.ts.map +1 -0
  31. package/build/commands/ai/message.js +86 -0
  32. package/build/commands/ai/prompt.d.ts +4 -0
  33. package/build/commands/ai/prompt.d.ts.map +1 -0
  34. package/build/commands/ai/prompt.js +34 -0
  35. package/build/commands/ai/release.d.ts +4 -0
  36. package/build/commands/ai/release.d.ts.map +1 -0
  37. package/build/commands/ai/release.js +150 -0
  38. package/build/commands/ai/skill.d.ts +4 -0
  39. package/build/commands/ai/skill.d.ts.map +1 -0
  40. package/build/commands/ai/skill.js +96 -0
  41. package/build/commands/ai/suggestedAction.d.ts +4 -0
  42. package/build/commands/ai/suggestedAction.d.ts.map +1 -0
  43. package/build/commands/ai/suggestedAction.js +37 -0
  44. package/build/commands/ai/template.d.ts +4 -0
  45. package/build/commands/ai/template.d.ts.map +1 -0
  46. package/build/commands/ai/template.js +14 -0
  47. package/build/commands/ai/vote.d.ts +4 -0
  48. package/build/commands/ai/vote.d.ts.map +1 -0
  49. package/build/commands/ai/vote.js +28 -0
  50. package/build/commands/auth.d.ts +3 -0
  51. package/build/commands/auth.d.ts.map +1 -0
  52. package/build/commands/auth.js +73 -0
  53. package/build/commands/billing/index.d.ts +4 -0
  54. package/build/commands/billing/index.d.ts.map +1 -0
  55. package/build/commands/billing/index.js +9 -0
  56. package/build/commands/billing/subscription.d.ts +4 -0
  57. package/build/commands/billing/subscription.d.ts.map +1 -0
  58. package/build/commands/billing/subscription.js +119 -0
  59. package/build/commands/billing/usage.d.ts +4 -0
  60. package/build/commands/billing/usage.d.ts.map +1 -0
  61. package/build/commands/billing/usage.js +33 -0
  62. package/build/commands/connection/connector.d.ts +4 -0
  63. package/build/commands/connection/connector.d.ts.map +1 -0
  64. package/build/commands/connection/connector.js +129 -0
  65. package/build/commands/connection/index.d.ts +4 -0
  66. package/build/commands/connection/index.d.ts.map +1 -0
  67. package/build/commands/connection/index.js +11 -0
  68. package/build/commands/connection/integration.d.ts +4 -0
  69. package/build/commands/connection/integration.d.ts.map +1 -0
  70. package/build/commands/connection/integration.js +35 -0
  71. package/build/commands/connection/nativeIntegration.d.ts +4 -0
  72. package/build/commands/connection/nativeIntegration.d.ts.map +1 -0
  73. package/build/commands/connection/nativeIntegration.js +14 -0
  74. package/build/commands/expression/expressionEval.d.ts +4 -0
  75. package/build/commands/expression/expressionEval.d.ts.map +1 -0
  76. package/build/commands/expression/expressionEval.js +32 -0
  77. package/build/commands/expression/favoriteRecipe.d.ts +4 -0
  78. package/build/commands/expression/favoriteRecipe.d.ts.map +1 -0
  79. package/build/commands/expression/favoriteRecipe.js +24 -0
  80. package/build/commands/expression/index.d.ts +4 -0
  81. package/build/commands/expression/index.d.ts.map +1 -0
  82. package/build/commands/expression/index.js +11 -0
  83. package/build/commands/expression/recipe.d.ts +4 -0
  84. package/build/commands/expression/recipe.d.ts.map +1 -0
  85. package/build/commands/expression/recipe.js +98 -0
  86. package/build/commands/init.d.ts +4 -0
  87. package/build/commands/init.d.ts.map +1 -0
  88. package/build/commands/init.js +11 -0
  89. package/build/commands/orchestration/batch.d.ts +4 -0
  90. package/build/commands/orchestration/batch.d.ts.map +1 -0
  91. package/build/commands/orchestration/batch.js +106 -0
  92. package/build/commands/orchestration/draftRelease.d.ts +4 -0
  93. package/build/commands/orchestration/draftRelease.d.ts.map +1 -0
  94. package/build/commands/orchestration/draftRelease.js +73 -0
  95. package/build/commands/orchestration/index.d.ts +4 -0
  96. package/build/commands/orchestration/index.d.ts.map +1 -0
  97. package/build/commands/orchestration/index.js +25 -0
  98. package/build/commands/orchestration/node.d.ts +4 -0
  99. package/build/commands/orchestration/node.d.ts.map +1 -0
  100. package/build/commands/orchestration/node.js +44 -0
  101. package/build/commands/orchestration/play.d.ts +4 -0
  102. package/build/commands/orchestration/play.d.ts.map +1 -0
  103. package/build/commands/orchestration/play.js +63 -0
  104. package/build/commands/orchestration/record.d.ts +4 -0
  105. package/build/commands/orchestration/record.d.ts.map +1 -0
  106. package/build/commands/orchestration/record.js +194 -0
  107. package/build/commands/orchestration/release.d.ts +4 -0
  108. package/build/commands/orchestration/release.d.ts.map +1 -0
  109. package/build/commands/orchestration/release.js +27 -0
  110. package/build/commands/orchestration/run.d.ts +4 -0
  111. package/build/commands/orchestration/run.d.ts.map +1 -0
  112. package/build/commands/orchestration/run.js +196 -0
  113. package/build/commands/orchestration/template.d.ts +4 -0
  114. package/build/commands/orchestration/template.d.ts.map +1 -0
  115. package/build/commands/orchestration/template.js +22 -0
  116. package/build/commands/orchestration/tool.d.ts +4 -0
  117. package/build/commands/orchestration/tool.d.ts.map +1 -0
  118. package/build/commands/orchestration/tool.js +72 -0
  119. package/build/commands/orchestration/workflow.d.ts +4 -0
  120. package/build/commands/orchestration/workflow.d.ts.map +1 -0
  121. package/build/commands/orchestration/workflow.js +14 -0
  122. package/build/commands/revenueOrganization/allocation.d.ts +4 -0
  123. package/build/commands/revenueOrganization/allocation.d.ts.map +1 -0
  124. package/build/commands/revenueOrganization/allocation.js +45 -0
  125. package/build/commands/revenueOrganization/capacity.d.ts +4 -0
  126. package/build/commands/revenueOrganization/capacity.d.ts.map +1 -0
  127. package/build/commands/revenueOrganization/capacity.js +94 -0
  128. package/build/commands/revenueOrganization/index.d.ts +4 -0
  129. package/build/commands/revenueOrganization/index.d.ts.map +1 -0
  130. package/build/commands/revenueOrganization/index.js +13 -0
  131. package/build/commands/revenueOrganization/member.d.ts +4 -0
  132. package/build/commands/revenueOrganization/member.d.ts.map +1 -0
  133. package/build/commands/revenueOrganization/member.js +62 -0
  134. package/build/commands/revenueOrganization/territory.d.ts +4 -0
  135. package/build/commands/revenueOrganization/territory.d.ts.map +1 -0
  136. package/build/commands/revenueOrganization/territory.js +72 -0
  137. package/build/commands/runHandler.d.ts +4 -0
  138. package/build/commands/runHandler.d.ts.map +1 -0
  139. package/build/commands/runHandler.js +33 -0
  140. package/build/commands/segmentation/change.d.ts +4 -0
  141. package/build/commands/segmentation/change.d.ts.map +1 -0
  142. package/build/commands/segmentation/change.js +61 -0
  143. package/build/commands/segmentation/index.d.ts +4 -0
  144. package/build/commands/segmentation/index.d.ts.map +1 -0
  145. package/build/commands/segmentation/index.js +11 -0
  146. package/build/commands/segmentation/record.d.ts +4 -0
  147. package/build/commands/segmentation/record.d.ts.map +1 -0
  148. package/build/commands/segmentation/record.js +21 -0
  149. package/build/commands/segmentation/segment.d.ts +4 -0
  150. package/build/commands/segmentation/segment.d.ts.map +1 -0
  151. package/build/commands/segmentation/segment.js +130 -0
  152. package/build/commands/storage/column.d.ts +4 -0
  153. package/build/commands/storage/column.d.ts.map +1 -0
  154. package/build/commands/storage/column.js +84 -0
  155. package/build/commands/storage/dataset.d.ts +4 -0
  156. package/build/commands/storage/dataset.d.ts.map +1 -0
  157. package/build/commands/storage/dataset.js +20 -0
  158. package/build/commands/storage/index.d.ts +4 -0
  159. package/build/commands/storage/index.d.ts.map +1 -0
  160. package/build/commands/storage/index.js +17 -0
  161. package/build/commands/storage/model.d.ts +4 -0
  162. package/build/commands/storage/model.d.ts.map +1 -0
  163. package/build/commands/storage/model.js +141 -0
  164. package/build/commands/storage/record.d.ts +4 -0
  165. package/build/commands/storage/record.d.ts.map +1 -0
  166. package/build/commands/storage/record.js +15 -0
  167. package/build/commands/storage/relationship.d.ts +4 -0
  168. package/build/commands/storage/relationship.d.ts.map +1 -0
  169. package/build/commands/storage/relationship.js +27 -0
  170. package/build/commands/storage/run.d.ts +4 -0
  171. package/build/commands/storage/run.d.ts.map +1 -0
  172. package/build/commands/storage/run.js +42 -0
  173. package/build/commands/systemOfRecordIntegration/client.d.ts +4 -0
  174. package/build/commands/systemOfRecordIntegration/client.d.ts.map +1 -0
  175. package/build/commands/systemOfRecordIntegration/client.js +46 -0
  176. package/build/commands/systemOfRecordIntegration/index.d.ts +4 -0
  177. package/build/commands/systemOfRecordIntegration/index.d.ts.map +1 -0
  178. package/build/commands/systemOfRecordIntegration/index.js +11 -0
  179. package/build/commands/systemOfRecordIntegration/log.d.ts +4 -0
  180. package/build/commands/systemOfRecordIntegration/log.d.ts.map +1 -0
  181. package/build/commands/systemOfRecordIntegration/log.js +36 -0
  182. package/build/commands/systemOfRecordIntegration/systemOfRecord.d.ts +4 -0
  183. package/build/commands/systemOfRecordIntegration/systemOfRecord.d.ts.map +1 -0
  184. package/build/commands/systemOfRecordIntegration/systemOfRecord.js +72 -0
  185. package/build/commands/userManagement/index.d.ts +4 -0
  186. package/build/commands/userManagement/index.d.ts.map +1 -0
  187. package/build/commands/userManagement/index.js +32 -0
  188. package/build/commands/workspace/file.d.ts +4 -0
  189. package/build/commands/workspace/file.d.ts.map +1 -0
  190. package/build/commands/workspace/file.js +44 -0
  191. package/build/commands/workspace/folder.d.ts +4 -0
  192. package/build/commands/workspace/folder.d.ts.map +1 -0
  193. package/build/commands/workspace/folder.js +64 -0
  194. package/build/commands/workspace/index.d.ts +4 -0
  195. package/build/commands/workspace/index.d.ts.map +1 -0
  196. package/build/commands/workspace/index.js +17 -0
  197. package/build/commands/workspace/role.d.ts +4 -0
  198. package/build/commands/workspace/role.d.ts.map +1 -0
  199. package/build/commands/workspace/role.js +12 -0
  200. package/build/commands/workspace/token.d.ts +4 -0
  201. package/build/commands/workspace/token.d.ts.map +1 -0
  202. package/build/commands/workspace/token.js +31 -0
  203. package/build/commands/workspace/user.d.ts +4 -0
  204. package/build/commands/workspace/user.d.ts.map +1 -0
  205. package/build/commands/workspace/user.js +105 -0
  206. package/build/commands/workspace/workspaces.d.ts +4 -0
  207. package/build/commands/workspace/workspaces.d.ts.map +1 -0
  208. package/build/commands/workspace/workspaces.js +74 -0
  209. package/build/config.d.ts +7 -0
  210. package/build/config.d.ts.map +1 -0
  211. package/build/config.js +45 -0
  212. package/build/credentials.d.ts +10 -0
  213. package/build/credentials.d.ts.map +1 -0
  214. package/build/credentials.js +31 -0
  215. package/build/index.d.ts +2 -0
  216. package/build/index.d.ts.map +1 -0
  217. package/build/index.js +37 -0
  218. package/package.json +44 -0
@@ -0,0 +1,32 @@
1
+ import { handleApiCall, outputJson, parseJson } from "../runHandler.js";
2
+ export function registerUserManagementCommands(parent, getApi) {
3
+ const userMgmt = parent
4
+ .command("user-management")
5
+ .description("Current user (no workspace context)");
6
+ const user = userMgmt.command("user").description("Current user");
7
+ user
8
+ .command("get-current")
9
+ .description("Get current user")
10
+ .action(async () => {
11
+ const api = getApi();
12
+ const result = await handleApiCall(() => api.userManagement.user.getCurrent());
13
+ outputJson(result);
14
+ });
15
+ user
16
+ .command("update")
17
+ .description("Update current user")
18
+ .option("--first-name <name>", "First name")
19
+ .option("--last-name <name>", "Last name")
20
+ .option("--web-extension-data <json>", 'Web extension data (JSON object, e.g. {"key":"value"})')
21
+ .action(async (opts) => {
22
+ const api = getApi();
23
+ const result = await handleApiCall(() => api.userManagement.user.update({
24
+ firstName: opts.firstName,
25
+ lastName: opts.lastName,
26
+ webExtensionData: opts.webExtensionData !== undefined
27
+ ? parseJson(opts.webExtensionData, "--web-extension-data")
28
+ : undefined,
29
+ }));
30
+ outputJson(result);
31
+ });
32
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerFileCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CA+C7E"}
@@ -0,0 +1,44 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { basename } from "node:path";
3
+ import { handleApiCall, outputJson } from "../runHandler.js";
4
+ export function registerFileCommands(parent, getApi) {
5
+ const file = parent.command("file").description("Workspace file operations");
6
+ file
7
+ .command("upload")
8
+ .description("Upload a file")
9
+ .requiredOption("--file-path <path>", "Path to the file to upload")
10
+ .action(async (opts) => {
11
+ const buffer = await readFile(opts.filePath);
12
+ const name = basename(opts.filePath);
13
+ const fileObj = new File([buffer], name);
14
+ const api = getApi();
15
+ await handleApiCall(() => new Promise((resolve, reject) => {
16
+ api.workspaceManagement.file.upload({
17
+ file: fileObj,
18
+ onProgress: (pct) => {
19
+ process.stderr.write(`\rUpload progress: ${pct}%`);
20
+ },
21
+ onComplete: (result) => {
22
+ process.stderr.write("\n");
23
+ outputJson(result);
24
+ resolve();
25
+ },
26
+ onError: () => {
27
+ process.stderr.write("\n");
28
+ reject(new Error("Upload failed"));
29
+ },
30
+ });
31
+ }));
32
+ });
33
+ file
34
+ .command("list-columns")
35
+ .description("List columns for a file")
36
+ .requiredOption("--s3-filename <name>", "S3 filename")
37
+ .action(async (opts) => {
38
+ const api = getApi();
39
+ const result = await handleApiCall(() => api.workspaceManagement.file.listColumns({
40
+ s3Filename: opts.s3Filename,
41
+ }));
42
+ outputJson(result);
43
+ });
44
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerFolderCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=folder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/folder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CA6FN"}
@@ -0,0 +1,64 @@
1
+ import { handleApiCall, outputJson } from "../runHandler.js";
2
+ export function registerFolderCommands(parent, getApi) {
3
+ const folder = parent.command("folder").description("Folder operations");
4
+ folder
5
+ .command("list")
6
+ .description("List all folders")
7
+ .action(async () => {
8
+ const api = getApi();
9
+ const result = await handleApiCall(() => api.workspaceManagement.folder.all());
10
+ outputJson(result);
11
+ });
12
+ folder
13
+ .command("get <uuid>")
14
+ .description("Get a folder by UUID")
15
+ .action(async (uuid) => {
16
+ const api = getApi();
17
+ const result = await handleApiCall(() => api.workspaceManagement.folder.get(uuid));
18
+ outputJson(result);
19
+ });
20
+ folder
21
+ .command("create")
22
+ .description("Create a folder")
23
+ .requiredOption("--name <name>", "Folder name")
24
+ .requiredOption("--emoji-slug <slug>", "Emoji slug")
25
+ .requiredOption("--kind <kind>", "Folder kind")
26
+ .option("--parent-uuid <uuid>", "Parent folder UUID")
27
+ .action(async (opts) => {
28
+ const api = getApi();
29
+ const result = await handleApiCall(() => api.workspaceManagement.folder.create({
30
+ name: opts.name,
31
+ emojiSlug: opts.emojiSlug,
32
+ kind: opts.kind,
33
+ parentUuid: opts.parentUuid,
34
+ }));
35
+ outputJson(result);
36
+ });
37
+ folder
38
+ .command("update")
39
+ .description("Update a folder")
40
+ .requiredOption("--uuid <uuid>", "Folder UUID")
41
+ .option("--name <name>", "Folder name")
42
+ .option("--emoji-slug <slug>", "Emoji slug")
43
+ .option("--order <n>", "Order index")
44
+ .option("--parent-uuid <uuid>", "Parent folder UUID")
45
+ .action(async (opts) => {
46
+ const api = getApi();
47
+ const result = await handleApiCall(() => api.workspaceManagement.folder.update({
48
+ uuid: opts.uuid,
49
+ name: opts.name,
50
+ emojiSlug: opts.emojiSlug,
51
+ order: opts.order !== undefined ? parseInt(opts.order, 10) : undefined,
52
+ parentUuid: opts.parentUuid,
53
+ }));
54
+ outputJson(result);
55
+ });
56
+ folder
57
+ .command("remove <uuid>")
58
+ .description("Remove a folder")
59
+ .action(async (uuid) => {
60
+ const api = getApi();
61
+ await handleApiCall(() => api.workspaceManagement.folder.remove(uuid));
62
+ outputJson({ ok: true });
63
+ });
64
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerWorkspaceCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAQxC,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAWN"}
@@ -0,0 +1,17 @@
1
+ import { registerFileCommands } from "./file.js";
2
+ import { registerFolderCommands } from "./folder.js";
3
+ import { registerRoleCommands } from "./role.js";
4
+ import { registerTokenCommands } from "./token.js";
5
+ import { registerUserCommands } from "./user.js";
6
+ import { registerWorkspacesCommands } from "./workspaces.js";
7
+ export function registerWorkspaceCommands(parent, getApi) {
8
+ const workspace = parent
9
+ .command("workspace")
10
+ .description("Workspaces, users, tokens, roles, folders");
11
+ registerWorkspacesCommands(workspace, getApi);
12
+ registerUserCommands(workspace, getApi);
13
+ registerTokenCommands(workspace, getApi);
14
+ registerRoleCommands(workspace, getApi);
15
+ registerFolderCommands(workspace, getApi);
16
+ registerFileCommands(workspace, getApi);
17
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerRoleCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/role.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAa7E"}
@@ -0,0 +1,12 @@
1
+ import { handleApiCall, outputJson } from "../runHandler.js";
2
+ export function registerRoleCommands(parent, getApi) {
3
+ const role = parent.command("role").description("Role operations");
4
+ role
5
+ .command("list")
6
+ .description("List all roles")
7
+ .action(async () => {
8
+ const api = getApi();
9
+ const result = await handleApiCall(() => api.workspaceManagement.role.all());
10
+ outputJson(result);
11
+ });
12
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerTokenCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAoCN"}
@@ -0,0 +1,31 @@
1
+ import { handleApiCall, outputJson } from "../runHandler.js";
2
+ export function registerTokenCommands(parent, getApi) {
3
+ const token = parent.command("token").description("API token operations");
4
+ token
5
+ .command("list")
6
+ .description("List all tokens")
7
+ .action(async () => {
8
+ const api = getApi();
9
+ const result = await handleApiCall(() => api.workspaceManagement.token.all());
10
+ outputJson(result);
11
+ });
12
+ token
13
+ .command("create")
14
+ .description("Create a token")
15
+ .option("--from-user", "Create token from current user")
16
+ .action(async (opts) => {
17
+ const api = getApi();
18
+ const result = await handleApiCall(() => api.workspaceManagement.token.create({
19
+ fromUser: opts.fromUser !== undefined ? opts.fromUser : true,
20
+ }));
21
+ outputJson(result);
22
+ });
23
+ token
24
+ .command("remove <uuid>")
25
+ .description("Remove a token")
26
+ .action(async (uuid) => {
27
+ const api = getApi();
28
+ await handleApiCall(() => api.workspaceManagement.token.remove(uuid));
29
+ outputJson({ ok: true });
30
+ });
31
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerUserCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAIxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAmJ7E"}
@@ -0,0 +1,105 @@
1
+ import { getConfig } from "../../config.js";
2
+ import { handleApiCall, outputJson } from "../runHandler.js";
3
+ export function registerUserCommands(parent, getApi) {
4
+ const user = parent.command("user").description("Workspace user operations");
5
+ user
6
+ .command("list")
7
+ .description("List workspace users")
8
+ .option("--workspace-uuid <uuid>", "Workspace UUID (or set CARGO_WORKSPACE_UUID)")
9
+ .action(async (opts) => {
10
+ const config = getConfig();
11
+ const workspaceUuid = opts.workspaceUuid !== undefined
12
+ ? opts.workspaceUuid
13
+ : config.workspaceUuid;
14
+ if (workspaceUuid === undefined) {
15
+ throw new Error("--workspace-uuid or CARGO_WORKSPACE_UUID required");
16
+ }
17
+ const api = getApi();
18
+ const result = await handleApiCall(() => api.workspaceManagement.user.all({ workspaceUuid }));
19
+ outputJson(result);
20
+ });
21
+ user
22
+ .command("get-current")
23
+ .description("Get current user")
24
+ .action(async () => {
25
+ const api = getApi();
26
+ const result = await handleApiCall(() => api.workspaceManagement.user.getCurrent());
27
+ outputJson(result);
28
+ });
29
+ user
30
+ .command("create")
31
+ .description("Create a workspace user")
32
+ .requiredOption("--user-email <email>", "User email")
33
+ .requiredOption("--role-slug <slug>", "Role slug")
34
+ .action(async (opts) => {
35
+ const api = getApi();
36
+ const result = await handleApiCall(() => api.workspaceManagement.user.create({
37
+ userEmail: opts.userEmail,
38
+ roleSlug: opts.roleSlug,
39
+ }));
40
+ outputJson(result);
41
+ });
42
+ user
43
+ .command("remove")
44
+ .description("Remove a workspace user")
45
+ .requiredOption("--user-uuid <uuid>", "User UUID")
46
+ .action(async (opts) => {
47
+ const api = getApi();
48
+ await handleApiCall(() => api.workspaceManagement.user.remove({ userUuid: opts.userUuid }));
49
+ outputJson({ ok: true });
50
+ });
51
+ user
52
+ .command("update")
53
+ .description("Update a workspace user")
54
+ .requiredOption("--user-uuid <uuid>", "User UUID")
55
+ .requiredOption("--role-slug <slug>", "Role slug")
56
+ .action(async (opts) => {
57
+ const api = getApi();
58
+ const result = await handleApiCall(() => api.workspaceManagement.user.update({
59
+ userUuid: opts.userUuid,
60
+ roleSlug: opts.roleSlug,
61
+ }));
62
+ outputJson(result);
63
+ });
64
+ user
65
+ .command("upsert-permission")
66
+ .description("Upsert a user permission")
67
+ .option("--user-uuids <uuids>", "User UUIDs (comma-separated)")
68
+ .option("--emails <emails>", "User emails (comma-separated)")
69
+ .requiredOption("--action <action>", "Permission action")
70
+ .requiredOption("--resource-uuid <uuid>", "Resource UUID")
71
+ .requiredOption("--effect <effect>", "Permission effect (allow or deny)")
72
+ .action(async (opts) => {
73
+ if (opts.userUuids === undefined && opts.emails === undefined) {
74
+ throw new Error("--user-uuids or --emails is required");
75
+ }
76
+ const api = getApi();
77
+ const result = await handleApiCall(() => api.workspaceManagement.user.upsertPermission({
78
+ userUuids: opts.userUuids !== undefined
79
+ ? opts.userUuids.split(",").map((s) => s.trim())
80
+ : undefined,
81
+ emails: opts.emails !== undefined
82
+ ? opts.emails.split(",").map((s) => s.trim())
83
+ : undefined,
84
+ action: opts.action,
85
+ resourceUuid: opts.resourceUuid,
86
+ effect: opts.effect,
87
+ }));
88
+ outputJson(result);
89
+ });
90
+ user
91
+ .command("remove-permission")
92
+ .description("Remove a user permission")
93
+ .requiredOption("--user-uuid <uuid>", "User UUID")
94
+ .requiredOption("--resource-uuid <uuid>", "Resource UUID")
95
+ .requiredOption("--effect <effect>", "Permission effect (allow or deny)")
96
+ .action(async (opts) => {
97
+ const api = getApi();
98
+ await handleApiCall(() => api.workspaceManagement.user.removePermission({
99
+ userUuid: opts.userUuid,
100
+ resourceUuid: opts.resourceUuid,
101
+ effect: opts.effect,
102
+ }));
103
+ outputJson({ ok: true });
104
+ });
105
+ }
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { Api } from "../../api.js";
3
+ export declare function registerWorkspacesCommands(parent: Command, getApi: () => Api): void;
4
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../../src/commands/workspace/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CA0HN"}
@@ -0,0 +1,74 @@
1
+ import { handleApiCall, outputJson, parseJson } from "../runHandler.js";
2
+ export function registerWorkspacesCommands(parent, getApi) {
3
+ const workspaces = parent
4
+ .command("workspaces")
5
+ .description("Workspace list and management");
6
+ workspaces
7
+ .command("list")
8
+ .description("List all workspaces")
9
+ .option("--refresh", "Refresh")
10
+ .action(async (opts) => {
11
+ const api = getApi();
12
+ const result = await handleApiCall(() => api.workspaceManagement.workspace.all({
13
+ refresh: opts.refresh === true,
14
+ }));
15
+ outputJson(result);
16
+ });
17
+ workspaces
18
+ .command("create")
19
+ .description("Create a workspace")
20
+ .requiredOption("--name <name>", "Workspace name")
21
+ .option("--logo-base64 <data>", "Logo as base64 string")
22
+ .option("--metadata <json>", 'Metadata (JSON object, e.g. {"key":"value"})')
23
+ .action(async (opts) => {
24
+ const api = getApi();
25
+ const result = await handleApiCall(() => api.workspaceManagement.workspace.create({
26
+ name: opts.name,
27
+ logoBase64: opts.logoBase64,
28
+ metadata: opts.metadata !== undefined
29
+ ? parseJson(opts.metadata, "--metadata")
30
+ : undefined,
31
+ }));
32
+ outputJson(result);
33
+ });
34
+ workspaces
35
+ .command("update")
36
+ .description("Update a workspace")
37
+ .option("--name <name>", "Workspace name")
38
+ .option("--allowed-email-domains <list>", "Allowed email domains (comma-separated)")
39
+ .option("--logo-base64 <data>", "Logo as base64 string (use 'null' to remove)")
40
+ .option("--openai-api-key <key>", "OpenAI API key (use 'null' to remove)")
41
+ .option("--syncs <json>", "Syncs (JSON array)")
42
+ .option("--metadata <json>", 'Metadata (JSON object, e.g. {"key":"value"})')
43
+ .option("--chrome-extension-master-agent-uuid <uuid>", "Chrome extension master agent UUID (use 'null' to remove)")
44
+ .option("--chrome-extension-available-agent-uuids <list>", "Chrome extension available agent UUIDs (comma-separated, use 'null' to remove)")
45
+ .option("--default-role-uuid <uuid>", "Default role UUID (use 'null' to remove)")
46
+ .action(async (opts) => {
47
+ const nullOrValue = (v) => v === "null" ? null : v;
48
+ const api = getApi();
49
+ const result = await handleApiCall(() => api.workspaceManagement.workspace.update({
50
+ name: opts.name,
51
+ allowedEmailDomains: opts.allowedEmailDomains !== undefined
52
+ ? opts.allowedEmailDomains.split(",").map((s) => s.trim())
53
+ : undefined,
54
+ logoBase64: nullOrValue(opts.logoBase64),
55
+ openAiApiKey: nullOrValue(opts.openaiApiKey),
56
+ syncs: opts.syncs !== undefined
57
+ ? parseJson(opts.syncs, "--syncs")
58
+ : undefined,
59
+ metadata: opts.metadata !== undefined
60
+ ? parseJson(opts.metadata, "--metadata")
61
+ : undefined,
62
+ chromeExtensionMasterAgentUuid: nullOrValue(opts.chromeExtensionMasterAgentUuid),
63
+ chromeExtensionAvailableAgentUuids: opts.chromeExtensionAvailableAgentUuids === "null"
64
+ ? null
65
+ : opts.chromeExtensionAvailableAgentUuids !== undefined
66
+ ? opts.chromeExtensionAvailableAgentUuids
67
+ .split(",")
68
+ .map((s) => s.trim())
69
+ : undefined,
70
+ defaultRoleUuid: nullOrValue(opts.defaultRoleUuid),
71
+ }));
72
+ outputJson(result);
73
+ });
74
+ }
@@ -0,0 +1,7 @@
1
+ export type Config = {
2
+ baseUrl: string;
3
+ accessToken: string;
4
+ workspaceUuid: string | undefined;
5
+ };
6
+ export declare function getConfig(): Config;
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAIF,wBAAgB,SAAS,IAAI,MAAM,CAmBlC"}
@@ -0,0 +1,45 @@
1
+ import { loadCredentials } from "./credentials.js";
2
+ const DEFAULT_BASE_URL = "https://api.getcargo.io";
3
+ export function getConfig() {
4
+ const credentials = loadCredentials();
5
+ const accessToken = getAccessToken(credentials);
6
+ if (accessToken === undefined) {
7
+ console.error(JSON.stringify({
8
+ error: 'Not authenticated. Run "cargo-ai login --token <token>" or set CARGO_API_TOKEN.',
9
+ }));
10
+ process.exit(1);
11
+ }
12
+ const baseUrl = getBaseUrl(credentials);
13
+ const workspaceUuid = getWorkspaceUuid(credentials);
14
+ return { baseUrl, accessToken, workspaceUuid };
15
+ }
16
+ const getAccessToken = (credentials) => {
17
+ const envToken = process.env["CARGO_API_TOKEN"];
18
+ if (envToken !== undefined) {
19
+ return envToken;
20
+ }
21
+ if (credentials !== undefined) {
22
+ return credentials.accessToken;
23
+ }
24
+ return undefined;
25
+ };
26
+ const getBaseUrl = (credentials) => {
27
+ const envUrl = process.env["CARGO_BASE_URL"];
28
+ if (envUrl !== undefined) {
29
+ return envUrl;
30
+ }
31
+ if (credentials !== undefined && credentials.baseUrl !== undefined) {
32
+ return credentials.baseUrl;
33
+ }
34
+ return DEFAULT_BASE_URL;
35
+ };
36
+ const getWorkspaceUuid = (credentials) => {
37
+ const envUuid = process.env["CARGO_WORKSPACE_UUID"];
38
+ if (envUuid !== undefined) {
39
+ return envUuid;
40
+ }
41
+ if (credentials !== undefined) {
42
+ return credentials.workspaceUuid;
43
+ }
44
+ return undefined;
45
+ };
@@ -0,0 +1,10 @@
1
+ export type Credentials = {
2
+ accessToken: string;
3
+ workspaceUuid?: string;
4
+ baseUrl?: string;
5
+ };
6
+ export declare function loadCredentials(): Credentials | undefined;
7
+ export declare function saveCredentials(creds: Credentials): void;
8
+ export declare function clearCredentials(): boolean;
9
+ export declare function getCredentialsPath(): string;
10
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAKF,wBAAgB,eAAe,IAAI,WAAW,GAAG,SAAS,CAQzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAKxD;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAI1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
@@ -0,0 +1,31 @@
1
+ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync, } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ const CONFIG_DIR = join(homedir(), ".config", "cargo-ai");
5
+ const CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
6
+ export function loadCredentials() {
7
+ if (existsSync(CREDENTIALS_FILE) === false)
8
+ return undefined;
9
+ try {
10
+ const raw = readFileSync(CREDENTIALS_FILE, "utf-8");
11
+ return JSON.parse(raw);
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ export function saveCredentials(creds) {
18
+ mkdirSync(CONFIG_DIR, { recursive: true });
19
+ writeFileSync(CREDENTIALS_FILE, JSON.stringify(creds, null, 2) + "\n", {
20
+ mode: 0o600,
21
+ });
22
+ }
23
+ export function clearCredentials() {
24
+ if (existsSync(CREDENTIALS_FILE) === false)
25
+ return false;
26
+ unlinkSync(CREDENTIALS_FILE);
27
+ return true;
28
+ }
29
+ export function getCredentialsPath() {
30
+ return CREDENTIALS_FILE;
31
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/build/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { Command } from "commander";
2
+ import { createApi } from "./api.js";
3
+ import { registerAiCommands } from "./commands/ai/index.js";
4
+ import { registerAuthCommands } from "./commands/auth.js";
5
+ import { registerBillingCommands } from "./commands/billing/index.js";
6
+ import { registerConnectionCommands } from "./commands/connection/index.js";
7
+ import { registerExpressionCommands } from "./commands/expression/index.js";
8
+ import { registerInitCommand } from "./commands/init.js";
9
+ import { registerOrchestrationCommands } from "./commands/orchestration/index.js";
10
+ import { registerRevenueOrganizationCommands } from "./commands/revenueOrganization/index.js";
11
+ import { registerSegmentationCommands } from "./commands/segmentation/index.js";
12
+ import { registerStorageCommands } from "./commands/storage/index.js";
13
+ import { registerSystemOfRecordIntegrationCommands } from "./commands/systemOfRecordIntegration/index.js";
14
+ import { registerUserManagementCommands } from "./commands/userManagement/index.js";
15
+ import { registerWorkspaceCommands } from "./commands/workspace/index.js";
16
+ const program = new Command();
17
+ program.name("cargo-ai").description("Cargo API CLI").version("1.0.0");
18
+ registerAuthCommands(program);
19
+ const getApi = () => createApi();
20
+ registerInitCommand(program, getApi);
21
+ registerOrchestrationCommands(program, getApi);
22
+ registerWorkspaceCommands(program, getApi);
23
+ registerStorageCommands(program, getApi);
24
+ registerConnectionCommands(program, getApi);
25
+ registerBillingCommands(program, getApi);
26
+ registerSegmentationCommands(program, getApi);
27
+ registerRevenueOrganizationCommands(program, getApi);
28
+ registerExpressionCommands(program, getApi);
29
+ registerSystemOfRecordIntegrationCommands(program, getApi);
30
+ registerUserManagementCommands(program, getApi);
31
+ registerAiCommands(program, getApi);
32
+ program.parseAsync().catch((err) => {
33
+ console.error(JSON.stringify({
34
+ error: err instanceof Error ? err.message : String(err),
35
+ }));
36
+ process.exit(1);
37
+ });
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@cargo-ai/cli",
3
+ "version": "1.0.1",
4
+ "private": false,
5
+ "description": "Command-line interface for the Cargo API",
6
+ "engines": {
7
+ "node": ">=22"
8
+ },
9
+ "volta": {
10
+ "node": "22.14.0"
11
+ },
12
+ "type": "module",
13
+ "bin": {
14
+ "cargo-ai": "./build/index.js"
15
+ },
16
+ "files": [
17
+ "build",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc --build",
22
+ "dev": "tsx watch src/index.ts",
23
+ "start": "node build/index.js",
24
+ "type:check": "tsc --noEmit",
25
+ "lint": "eslint ./ --fix",
26
+ "lint:check": "eslint ./ --max-warnings=0",
27
+ "format": "prettier --write .",
28
+ "format:check": "prettier --check ."
29
+ },
30
+ "dependencies": {
31
+ "commander": "^12.1.0",
32
+ "@cargo-ai/api": "^1.0.8"
33
+ },
34
+ "devDependencies": {
35
+ "@cargo-ai/eslint-config": "*",
36
+ "@cargo-ai/prettier-config": "*",
37
+ "@cargo-ai/ts-config": "*",
38
+ "@types/node": "^20.10.8",
39
+ "eslint": "9.26.0",
40
+ "prettier": "3.3.3",
41
+ "tsx": "^4.19.2",
42
+ "typescript": "5.3.2"
43
+ }
44
+ }