@boxcrew/cli 0.1.1 → 0.1.3

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 (2) hide show
  1. package/dist/index.js +21 -87
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ import { Command } from "commander";
5
5
 
6
6
  // src/commands/login.ts
7
7
  import { createInterface } from "readline";
8
- import { createServer } from "http";
9
8
  import open from "open";
10
9
 
11
10
  // src/config.ts
@@ -19,106 +18,41 @@ var config = new Conf({
19
18
 
20
19
  // src/commands/login.ts
21
20
  var DEFAULT_FRONTEND_URL = "https://boxcrew.ai";
22
- var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
23
21
  function registerLoginCommand(program2) {
24
22
  program2.command("login").description("Authenticate with BoxCrew").option("--api-url <url>", "BoxCrew API URL").option(
25
23
  "--frontend-url <url>",
26
24
  "BoxCrew frontend URL",
27
25
  process.env.BOXCREW_FRONTEND_URL || DEFAULT_FRONTEND_URL
28
- ).option("--paste", "Use paste-based login (for headless environments)").action(
26
+ ).action(
29
27
  async (options) => {
30
28
  if (options.apiUrl) {
31
29
  config.set("apiUrl", options.apiUrl);
32
30
  }
33
- if (options.paste) {
34
- await pasteLogin();
35
- } else {
36
- await browserLogin(options.frontendUrl);
37
- }
38
- }
39
- );
40
- }
41
- async function pasteLogin() {
42
- console.log(
43
- "Create an API key in the BoxCrew dashboard (Settings > API Keys),"
44
- );
45
- console.log("then paste it below.\n");
46
- const rl = createInterface({
47
- input: process.stdin,
48
- output: process.stdout
49
- });
50
- const apiKey = await new Promise((resolve) => {
51
- rl.question("API key: ", (answer) => {
52
- rl.close();
53
- resolve(answer.trim());
54
- });
55
- });
56
- if (!apiKey.startsWith("bxk_")) {
57
- console.error('Invalid API key. Keys should start with "bxk_".');
58
- process.exit(1);
59
- }
60
- config.set("apiKey", apiKey);
61
- console.log("\nAuthenticated successfully! Credentials stored.");
62
- console.log(`API URL: ${config.get("apiUrl")}`);
63
- }
64
- async function browserLogin(frontendUrl) {
65
- return new Promise((resolve, reject) => {
66
- const server = createServer((req, res) => {
67
- const url = new URL(req.url || "/", `http://localhost`);
68
- if (url.pathname === "/callback") {
69
- const key = url.searchParams.get("key");
70
- if (key && key.startsWith("bxk_")) {
71
- config.set("apiKey", key);
72
- res.writeHead(200, { "Content-Type": "text/html" });
73
- res.end(`
74
- <!DOCTYPE html>
75
- <html>
76
- <head><title>BoxCrew CLI</title></head>
77
- <body style="font-family: system-ui, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; background: #0a0a0a; color: #fafafa;">
78
- <div style="text-align: center;">
79
- <h2>Authenticated!</h2>
80
- <p>You can close this tab and return to your terminal.</p>
81
- </div>
82
- </body>
83
- </html>
84
- `);
85
- console.log("\nAuthenticated successfully! Credentials stored.");
86
- console.log(`API URL: ${config.get("apiUrl")}`);
87
- server.close();
88
- clearTimeout(timeout);
89
- resolve();
90
- } else {
91
- res.writeHead(400, { "Content-Type": "text/plain" });
92
- res.end("Invalid key");
93
- }
94
- } else {
95
- res.writeHead(404, { "Content-Type": "text/plain" });
96
- res.end("Not found");
97
- }
98
- });
99
- server.listen(0, "127.0.0.1", () => {
100
- const addr = server.address();
101
- if (!addr || typeof addr === "string") {
102
- reject(new Error("Failed to start local server"));
103
- return;
104
- }
105
- const port = addr.port;
106
- const authUrl = `${frontendUrl}/cli-auth?port=${port}`;
31
+ const authUrl = `${options.frontendUrl}/cli-auth`;
107
32
  console.log("Opening browser to authenticate...");
108
33
  console.log(`If the browser doesn't open, visit: ${authUrl}
109
34
  `);
110
- console.log("Waiting for authentication...");
111
35
  open(authUrl).catch(() => {
112
36
  });
113
- });
114
- const timeout = setTimeout(() => {
115
- console.error(
116
- '\nLogin timed out. Use "bx login --paste" to authenticate manually.'
117
- );
118
- server.close();
119
- process.exit(1);
120
- }, LOGIN_TIMEOUT_MS);
121
- });
37
+ const rl = createInterface({
38
+ input: process.stdin,
39
+ output: process.stdout
40
+ });
41
+ const apiKey = await new Promise((resolve) => {
42
+ rl.question("Paste your API key: ", (answer) => {
43
+ rl.close();
44
+ resolve(answer.trim());
45
+ });
46
+ });
47
+ if (!apiKey.startsWith("bxk_")) {
48
+ console.error('Invalid API key. Keys should start with "bxk_".');
49
+ process.exit(1);
50
+ }
51
+ config.set("apiKey", apiKey);
52
+ console.log("\nAuthenticated successfully! Credentials stored.");
53
+ console.log(`API URL: ${config.get("apiUrl")}`);
54
+ }
55
+ );
122
56
  }
123
57
 
124
58
  // src/commands/logout.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxcrew/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "BoxCrew CLI — manage your agents from the terminal",
5
5
  "type": "module",
6
6
  "bin": {