cassian-cli 0.1.4 → 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.
@@ -0,0 +1,3 @@
1
+ export declare function exec(args: string[], opts?: {
2
+ timeout?: string;
3
+ }): Promise<void>;
@@ -0,0 +1,37 @@
1
+ import { ApiClient } from "../lib/api.js";
2
+ import { loadConfig } from "../lib/config.js";
3
+ import { fatal, handleError } from "../lib/errors.js";
4
+ export async function exec(args, opts = {}) {
5
+ if (args.length === 0) {
6
+ fatal("No command specified.", "Usage: cassian exec <command>");
7
+ }
8
+ const command = args.join(" ");
9
+ const timeout = parseInt(opts.timeout || "600");
10
+ let config;
11
+ try {
12
+ config = loadConfig();
13
+ }
14
+ catch (e) {
15
+ fatal(e.message);
16
+ }
17
+ try {
18
+ const client = new ApiClient();
19
+ const { instances } = await client.get("/v1/instances");
20
+ const instance = instances.find((i) => i.name === config.name && i.status === "running");
21
+ if (!instance) {
22
+ fatal(`${config.name} is not running.`, "Run: cassian up");
23
+ }
24
+ const result = await client.post(`/v1/instances/${instance.id}/exec`, {
25
+ command,
26
+ timeout,
27
+ });
28
+ if (result.stdout)
29
+ process.stdout.write(result.stdout);
30
+ if (result.stderr)
31
+ process.stderr.write(result.stderr);
32
+ process.exit(result.exit_code);
33
+ }
34
+ catch (err) {
35
+ handleError(err);
36
+ }
37
+ }
@@ -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.");
@@ -128,6 +128,7 @@ export async function up() {
128
128
  resources: {
129
129
  memory: config.resources?.memory || null,
130
130
  shm_size: config.resources?.shm_size || null,
131
+ cpus: config.resources?.cpus || null,
131
132
  },
132
133
  });
133
134
  spinner.succeed("Instance ready");
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import { status } from "./commands/status.js";
14
14
  import { logs } from "./commands/logs.js";
15
15
  import { volumeCreate, volumeList, volumeDelete } from "./commands/volume.js";
16
16
  import { sync } from "./commands/sync.js";
17
+ import { exec } from "./commands/exec.js";
17
18
  const program = new Command();
18
19
  program
19
20
  .name("cassian")
@@ -39,6 +40,11 @@ program
39
40
  .command("ssh")
40
41
  .description("SSH into the running instance")
41
42
  .action(ssh);
43
+ program
44
+ .command("exec <command...>")
45
+ .description("Run a command on the instance and return output")
46
+ .option("--timeout <seconds>", "Command timeout in seconds", "600")
47
+ .action((command, opts) => exec(command, opts));
42
48
  program
43
49
  .command("sync")
44
50
  .description("Sync workspace from instance to local")
package/dist/types.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface CassianConfig {
19
19
  resources?: {
20
20
  memory?: string;
21
21
  shm_size?: string;
22
+ cpus?: number;
22
23
  };
23
24
  workspace?: {
24
25
  setup?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassian-cli",
3
- "version": "0.1.4",
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": {