cassian-cli 0.1.5 → 0.1.6

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.
@@ -1 +1,3 @@
1
- export declare function exec(args: string[]): Promise<void>;
1
+ export declare function exec(args: string[], opts?: {
2
+ timeout?: string;
3
+ }): Promise<void>;
@@ -1,11 +1,12 @@
1
1
  import { ApiClient } from "../lib/api.js";
2
2
  import { loadConfig } from "../lib/config.js";
3
3
  import { fatal, handleError } from "../lib/errors.js";
4
- export async function exec(args) {
4
+ export async function exec(args, opts = {}) {
5
5
  if (args.length === 0) {
6
6
  fatal("No command specified.", "Usage: cassian exec <command>");
7
7
  }
8
8
  const command = args.join(" ");
9
+ const timeout = parseInt(opts.timeout || "600");
9
10
  let config;
10
11
  try {
11
12
  config = loadConfig();
@@ -22,7 +23,7 @@ export async function exec(args) {
22
23
  }
23
24
  const result = await client.post(`/v1/instances/${instance.id}/exec`, {
24
25
  command,
25
- timeout: 60,
26
+ timeout,
26
27
  });
27
28
  if (result.stdout)
28
29
  process.stdout.write(result.stdout);
@@ -9,8 +9,6 @@ export async function login() {
9
9
  const callbackUrl = `http://localhost:${CALLBACK_PORT}/callback`;
10
10
  const platformUrl = PLATFORM_URL;
11
11
  console.log();
12
- console.log(" Opening Cassian in your browser...");
13
- console.log();
14
12
  const authUrl = `${platformUrl}?cli_redirect=${encodeURIComponent(callbackUrl)}`;
15
13
  // Derive the allowed CORS origin from platformUrl (e.g. https://trycassian.com)
16
14
  const allowedOrigin = new URL(platformUrl).origin;
@@ -66,11 +64,19 @@ export async function login() {
66
64
  res.end();
67
65
  });
68
66
  server.listen(CALLBACK_PORT, "127.0.0.1", () => {
69
- open(authUrl).catch(() => {
70
- console.log(dim(" Browser didn't open? Visit:"));
71
- console.log(` ${authUrl}`);
72
- console.log();
73
- });
67
+ console.log(dim(" Login URL (open in any browser):"));
68
+ console.log(` ${authUrl}`);
69
+ console.log();
70
+ console.log(dim(" Press Enter to open in browser..."));
71
+ if (process.stdin.isTTY) {
72
+ process.stdin.setRawMode(true);
73
+ process.stdin.resume();
74
+ process.stdin.once("data", () => {
75
+ process.stdin.setRawMode(false);
76
+ process.stdin.pause();
77
+ open(authUrl).catch(() => { });
78
+ });
79
+ }
74
80
  });
75
81
  server.on("error", () => {
76
82
  fatal("Could not start login. Try again.");
package/dist/index.js CHANGED
@@ -43,8 +43,8 @@ program
43
43
  program
44
44
  .command("exec <command...>")
45
45
  .description("Run a command on the instance and return output")
46
- .option("--timeout <seconds>", "Command timeout in seconds", "60")
47
- .action((command, opts) => exec(command));
46
+ .option("--timeout <seconds>", "Command timeout in seconds", "600")
47
+ .action((command, opts) => exec(command, opts));
48
48
  program
49
49
  .command("sync")
50
50
  .description("Sync workspace from instance to local")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassian-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "The Cassian GPU cloud CLI — provision GPUs, sync files, and run workloads from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {