cassian-cli 0.1.4 → 0.1.5

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 @@
1
+ export declare function exec(args: string[]): Promise<void>;
@@ -0,0 +1,36 @@
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) {
5
+ if (args.length === 0) {
6
+ fatal("No command specified.", "Usage: cassian exec <command>");
7
+ }
8
+ const command = args.join(" ");
9
+ let config;
10
+ try {
11
+ config = loadConfig();
12
+ }
13
+ catch (e) {
14
+ fatal(e.message);
15
+ }
16
+ try {
17
+ const client = new ApiClient();
18
+ const { instances } = await client.get("/v1/instances");
19
+ const instance = instances.find((i) => i.name === config.name && i.status === "running");
20
+ if (!instance) {
21
+ fatal(`${config.name} is not running.`, "Run: cassian up");
22
+ }
23
+ const result = await client.post(`/v1/instances/${instance.id}/exec`, {
24
+ command,
25
+ timeout: 60,
26
+ });
27
+ if (result.stdout)
28
+ process.stdout.write(result.stdout);
29
+ if (result.stderr)
30
+ process.stderr.write(result.stderr);
31
+ process.exit(result.exit_code);
32
+ }
33
+ catch (err) {
34
+ handleError(err);
35
+ }
36
+ }
@@ -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", "60")
47
+ .action((command, opts) => exec(command));
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.5",
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": {