@imbrace/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/bin/run.js +5 -0
  2. package/dist/base-command.d.ts +8 -0
  3. package/dist/base-command.js +48 -0
  4. package/dist/commands/ai-agent/create.d.ts +28 -0
  5. package/dist/commands/ai-agent/create.js +86 -0
  6. package/dist/commands/ai-agent/delete.d.ts +13 -0
  7. package/dist/commands/ai-agent/delete.js +39 -0
  8. package/dist/commands/ai-agent/get.d.ts +12 -0
  9. package/dist/commands/ai-agent/get.js +42 -0
  10. package/dist/commands/ai-agent/list-models.d.ts +10 -0
  11. package/dist/commands/ai-agent/list-models.js +36 -0
  12. package/dist/commands/ai-agent/list-providers.d.ts +9 -0
  13. package/dist/commands/ai-agent/list-providers.js +37 -0
  14. package/dist/commands/ai-agent/list.d.ts +9 -0
  15. package/dist/commands/ai-agent/list.js +36 -0
  16. package/dist/commands/ai-agent/update.d.ts +30 -0
  17. package/dist/commands/ai-agent/update.js +100 -0
  18. package/dist/commands/data-board/create-field.d.ts +14 -0
  19. package/dist/commands/data-board/create-field.js +46 -0
  20. package/dist/commands/data-board/create-item.d.ts +13 -0
  21. package/dist/commands/data-board/create-item.js +72 -0
  22. package/dist/commands/data-board/create.d.ts +10 -0
  23. package/dist/commands/data-board/create.js +45 -0
  24. package/dist/commands/data-board/delete-item.d.ts +14 -0
  25. package/dist/commands/data-board/delete-item.js +42 -0
  26. package/dist/commands/data-board/export-csv.d.ts +10 -0
  27. package/dist/commands/data-board/export-csv.js +34 -0
  28. package/dist/commands/data-board/list-items.d.ts +13 -0
  29. package/dist/commands/data-board/list-items.js +47 -0
  30. package/dist/commands/data-board/list.d.ts +9 -0
  31. package/dist/commands/data-board/list.js +33 -0
  32. package/dist/commands/data-board/update-item.d.ts +14 -0
  33. package/dist/commands/data-board/update-item.js +57 -0
  34. package/dist/commands/login.d.ts +12 -0
  35. package/dist/commands/login.js +71 -0
  36. package/dist/commands/logout.d.ts +6 -0
  37. package/dist/commands/logout.js +10 -0
  38. package/dist/commands/whoami.d.ts +9 -0
  39. package/dist/commands/whoami.js +29 -0
  40. package/dist/commands/workflow/create.d.ts +12 -0
  41. package/dist/commands/workflow/create.js +45 -0
  42. package/dist/commands/workflow/delete.d.ts +13 -0
  43. package/dist/commands/workflow/delete.js +40 -0
  44. package/dist/commands/workflow/get.d.ts +12 -0
  45. package/dist/commands/workflow/get.js +54 -0
  46. package/dist/commands/workflow/list.d.ts +9 -0
  47. package/dist/commands/workflow/list.js +36 -0
  48. package/dist/commands/workflow/node/add.d.ts +20 -0
  49. package/dist/commands/workflow/node/add.js +72 -0
  50. package/dist/commands/workflow/node/delete.d.ts +14 -0
  51. package/dist/commands/workflow/node/delete.js +40 -0
  52. package/dist/commands/workflow/node/list.d.ts +12 -0
  53. package/dist/commands/workflow/node/list.js +40 -0
  54. package/dist/commands/workflow/node/update.d.ts +15 -0
  55. package/dist/commands/workflow/node/update.js +47 -0
  56. package/dist/commands/workflow/piece/detail.d.ts +13 -0
  57. package/dist/commands/workflow/piece/detail.js +60 -0
  58. package/dist/commands/workflow/piece/list.d.ts +10 -0
  59. package/dist/commands/workflow/piece/list.js +40 -0
  60. package/dist/commands/workflow/run-detail.d.ts +12 -0
  61. package/dist/commands/workflow/run-detail.js +50 -0
  62. package/dist/commands/workflow/runs.d.ts +10 -0
  63. package/dist/commands/workflow/runs.js +40 -0
  64. package/dist/config.d.ts +27 -0
  65. package/dist/config.js +36 -0
  66. package/dist/http.d.ts +9 -0
  67. package/dist/http.js +40 -0
  68. package/dist/select-board.d.ts +1 -0
  69. package/dist/select-board.js +12 -0
  70. package/package.json +71 -0
@@ -0,0 +1,40 @@
1
+ import { Flags } from "@oclif/core";
2
+ import { BaseCommand } from "../../base-command.js";
3
+ import { apiRequest } from "../../http.js";
4
+ export default class WorkflowRuns extends BaseCommand {
5
+ static description = "List recent workflow runs (execution history)";
6
+ static examples = [
7
+ "imbrace workflow runs",
8
+ "imbrace workflow runs --limit 20 --json",
9
+ ];
10
+ static flags = {
11
+ limit: Flags.integer({ description: "Max number of runs to return", default: 10 }),
12
+ json: Flags.boolean({ description: "Output as JSON" }),
13
+ };
14
+ async run() {
15
+ const { flags } = await this.parse(WorkflowRuns);
16
+ try {
17
+ const res = await apiRequest(`/workflow/runs?limit=${flags.limit}`);
18
+ if (flags.json) {
19
+ this.log(JSON.stringify(res, null, 2));
20
+ return;
21
+ }
22
+ this.log(`\n Found ${res.count} run(s):\n`);
23
+ this.log(" RUN ID FLOW ID STATUS DURATION");
24
+ this.log(" ───────────────────────────────────────────────────────────────────────");
25
+ for (const run of res.data || []) {
26
+ const id = (run.id || "").padEnd(24);
27
+ const flowId = (run.flowId || "").padEnd(24);
28
+ const status = (run.status || "").padEnd(12);
29
+ const dur = run.startTime && run.finishTime
30
+ ? `${((new Date(run.finishTime).getTime() - new Date(run.startTime).getTime()) / 1000).toFixed(1)}s`
31
+ : "—";
32
+ this.log(` ${id} ${flowId} ${status} ${dur}`);
33
+ }
34
+ this.log("");
35
+ }
36
+ catch (error) {
37
+ this.error(`Failed: ${error.message}`);
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,27 @@
1
+ import Conf from "conf";
2
+ interface ImbraceConfig {
3
+ credential?: string;
4
+ method?: "api-key" | "password";
5
+ email?: string;
6
+ apiUrl?: string;
7
+ }
8
+ /**
9
+ * Saves credentials to ~/.config/imbrace/config.json
10
+ * Uses `conf` package — cross-platform, auto-create
11
+ */
12
+ export declare const config: Conf<ImbraceConfig>;
13
+ export declare function saveCredential(opts: {
14
+ credential: string;
15
+ method: "api-key" | "password";
16
+ email?: string;
17
+ }): void;
18
+ export declare function getCredential(): string | undefined;
19
+ export declare function getApiUrl(): string;
20
+ export declare function clearCredential(): void;
21
+ export declare function getAuthInfo(): {
22
+ credential: string | undefined;
23
+ method: "api-key" | "password" | undefined;
24
+ email: string | undefined;
25
+ apiUrl: string | undefined;
26
+ };
27
+ export {};
package/dist/config.js ADDED
@@ -0,0 +1,36 @@
1
+ import Conf from "conf";
2
+ /**
3
+ * Saves credentials to ~/.config/imbrace/config.json
4
+ * Uses `conf` package — cross-platform, auto-create
5
+ */
6
+ export const config = new Conf({
7
+ projectName: "imbrace",
8
+ defaults: {
9
+ apiUrl: "http://localhost:3456",
10
+ },
11
+ });
12
+ export function saveCredential(opts) {
13
+ config.set("credential", opts.credential);
14
+ config.set("method", opts.method);
15
+ if (opts.email)
16
+ config.set("email", opts.email);
17
+ }
18
+ export function getCredential() {
19
+ return config.get("credential");
20
+ }
21
+ export function getApiUrl() {
22
+ return config.get("apiUrl") || "http://localhost:3456";
23
+ }
24
+ export function clearCredential() {
25
+ config.delete("credential");
26
+ config.delete("method");
27
+ config.delete("email");
28
+ }
29
+ export function getAuthInfo() {
30
+ return {
31
+ credential: config.get("credential"),
32
+ method: config.get("method"),
33
+ email: config.get("email"),
34
+ apiUrl: config.get("apiUrl"),
35
+ };
36
+ }
package/dist/http.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * HTTP client for the local Hono API server
3
+ * Automatically attaches the Bearer token from config
4
+ */
5
+ export declare function apiRequest<T = any>(path: string, opts?: {
6
+ method?: string;
7
+ body?: any;
8
+ }): Promise<T>;
9
+ export declare function apiRequestText(path: string): Promise<string>;
package/dist/http.js ADDED
@@ -0,0 +1,40 @@
1
+ import { getCredential, getApiUrl } from "./config.js";
2
+ /**
3
+ * HTTP client for the local Hono API server
4
+ * Automatically attaches the Bearer token from config
5
+ */
6
+ export async function apiRequest(path, opts) {
7
+ const credential = getCredential();
8
+ const baseUrl = getApiUrl();
9
+ const headers = {
10
+ "Content-Type": "application/json",
11
+ };
12
+ if (credential) {
13
+ headers["Authorization"] = `Bearer ${credential}`;
14
+ }
15
+ const res = await fetch(`${baseUrl}${path}`, {
16
+ method: opts?.method || "GET",
17
+ headers,
18
+ body: opts?.body ? JSON.stringify(opts.body) : undefined,
19
+ });
20
+ const data = await res.json();
21
+ if (!res.ok) {
22
+ throw new Error(data?.message || `HTTP ${res.status}`);
23
+ }
24
+ return data;
25
+ }
26
+ export async function apiRequestText(path) {
27
+ const credential = getCredential();
28
+ const baseUrl = getApiUrl();
29
+ const headers = {
30
+ "Content-Type": "application/json",
31
+ };
32
+ if (credential) {
33
+ headers["Authorization"] = `Bearer ${credential}`;
34
+ }
35
+ const res = await fetch(`${baseUrl}${path}`, { method: "GET", headers });
36
+ if (!res.ok) {
37
+ throw new Error(`HTTP ${res.status}`);
38
+ }
39
+ return res.text();
40
+ }
@@ -0,0 +1 @@
1
+ export declare function selectBoard(): Promise<string>;
@@ -0,0 +1,12 @@
1
+ import { select } from "@inquirer/prompts";
2
+ import { apiRequest } from "./http.js";
3
+ export async function selectBoard() {
4
+ const res = await apiRequest("/data-board/list");
5
+ const boards = res.data || [];
6
+ if (!boards.length)
7
+ throw new Error("No boards found. Create a board first.");
8
+ return select({
9
+ message: "Select a board:",
10
+ choices: boards.map((b) => ({ name: `${b.name} (${b._id})`, value: b._id })),
11
+ });
12
+ }
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@imbrace/cli",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "CLI tool for interacting with the Imbrace CRM platform from the terminal",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/imbraceltd/imbrace-cli.git",
9
+ "directory": "cli"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/imbraceltd/imbrace-cli/issues"
13
+ },
14
+ "homepage": "https://github.com/imbraceltd/imbrace-cli#readme",
15
+ "license": "MIT",
16
+ "bin": {
17
+ "imbrace": "./bin/run.js"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsx src/commands",
22
+ "imbrace": "bun run bin/run.js",
23
+ "postpack": "rm -f oclif.manifest.json",
24
+ "prepack": "oclif manifest"
25
+ },
26
+ "dependencies": {
27
+ "@imbrace/sdk": "1.0.2",
28
+ "@inquirer/prompts": "^7.10.1",
29
+ "@oclif/core": "^4.2.0",
30
+ "@oclif/plugin-autocomplete": "^3.2.0",
31
+ "@oclif/plugin-help": "^6.2.0",
32
+ "conf": "^13.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.0.0",
36
+ "oclif": "^4.17.0",
37
+ "tsx": "^4.19.0",
38
+ "typescript": "^5.7.0"
39
+ },
40
+ "oclif": {
41
+ "bin": "imbrace",
42
+ "dirname": "imbrace",
43
+ "commands": "./dist/commands",
44
+ "topicSeparator": " ",
45
+ "plugins": [
46
+ "@oclif/plugin-help",
47
+ "@oclif/plugin-autocomplete"
48
+ ],
49
+ "topics": {
50
+ "data-board": {
51
+ "description": "Manage data boards — run `imbrace data-board --help` to see all commands"
52
+ },
53
+ "ai-agent": {
54
+ "description": "Manage AI agents — run `imbrace ai-agent --help` to see all commands"
55
+ },
56
+ "workflow": {
57
+ "description": "Manage workflows (Activepieces) — run `imbrace workflow --help` to see all commands"
58
+ },
59
+ "workflow:piece": {
60
+ "description": "Discover available integrations (pieces) — run `imbrace workflow piece --help`"
61
+ },
62
+ "workflow:node": {
63
+ "description": "Manage workflow nodes (trigger + actions) — run `imbrace workflow node --help`"
64
+ }
65
+ }
66
+ },
67
+ "files": [
68
+ "/bin",
69
+ "/dist"
70
+ ]
71
+ }