@arker-ai/sdk 0.6.2 → 0.6.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.
- package/dist/cli.cjs +18 -154
- package/dist/cli.js +17 -154
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -26,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
// src/cli.ts
|
|
27
27
|
var import_node_fs = require("fs");
|
|
28
28
|
var import_node_child_process = require("child_process");
|
|
29
|
+
var import_node_module = require("module");
|
|
29
30
|
var import_node_os = require("os");
|
|
30
31
|
var import_node_path = require("path");
|
|
31
32
|
var import_node_process = require("process");
|
|
@@ -963,6 +964,14 @@ function bufferConstructor() {
|
|
|
963
964
|
}
|
|
964
965
|
|
|
965
966
|
// src/cli.ts
|
|
967
|
+
var import_meta = {};
|
|
968
|
+
var VERSION = (() => {
|
|
969
|
+
try {
|
|
970
|
+
return (0, import_node_module.createRequire)(import_meta.url)("../package.json").version;
|
|
971
|
+
} catch {
|
|
972
|
+
return "unknown";
|
|
973
|
+
}
|
|
974
|
+
})();
|
|
966
975
|
function parseArgs(argv) {
|
|
967
976
|
const positional = [];
|
|
968
977
|
const flags = {};
|
|
@@ -1001,6 +1010,7 @@ function readFileConfig() {
|
|
|
1001
1010
|
}
|
|
1002
1011
|
return {};
|
|
1003
1012
|
}
|
|
1013
|
+
var DEFAULT_REGION = "us-west-2";
|
|
1004
1014
|
function clientFromArgs(args) {
|
|
1005
1015
|
const file = readFileConfig();
|
|
1006
1016
|
const explicitBaseUrl = args.flags["base-url"] ?? process.env.ARKER_BASE_URL;
|
|
@@ -1008,14 +1018,11 @@ function clientFromArgs(args) {
|
|
|
1008
1018
|
const apiKey = args.flags["api-key"] ?? process.env.ARKER_API_KEY ?? file.apiKey;
|
|
1009
1019
|
const baseUrl = explicitBaseUrl ?? (explicitRegion ? void 0 : file.baseUrl);
|
|
1010
1020
|
const controlBaseUrl = args.flags["control-base-url"] ?? process.env.ARKER_CONTROL_BASE_URL;
|
|
1011
|
-
const region = explicitRegion ?? file.region;
|
|
1021
|
+
const region = explicitRegion ?? file.region ?? (baseUrl ? void 0 : DEFAULT_REGION);
|
|
1012
1022
|
const provider = args.flags.provider ?? process.env.ARKER_PROVIDER;
|
|
1013
1023
|
if (!apiKey) {
|
|
1014
1024
|
die("Missing API key. Set ARKER_API_KEY or pass --api-key.");
|
|
1015
1025
|
}
|
|
1016
|
-
if (!baseUrl && !region) {
|
|
1017
|
-
die("Missing region. Set ARKER_REGION or pass --region (e.g. us-west-2). --provider (aws|aws-burst) defaults to aws.");
|
|
1018
|
-
}
|
|
1019
1026
|
return new Arker({ apiKey, baseUrl, region, provider, controlBaseUrl });
|
|
1020
1027
|
}
|
|
1021
1028
|
function out(value) {
|
|
@@ -1503,134 +1510,6 @@ function bridgePty(pty, options) {
|
|
|
1503
1510
|
});
|
|
1504
1511
|
});
|
|
1505
1512
|
}
|
|
1506
|
-
var SSH_PORT_DEFAULT = 22;
|
|
1507
|
-
function defaultIdentityBase() {
|
|
1508
|
-
return (0, import_node_path.join)((0, import_node_os.homedir)(), ".ssh", "id_ed25519");
|
|
1509
|
-
}
|
|
1510
|
-
function resolveLocalSshKey(args) {
|
|
1511
|
-
const explicit = args.flags.identity;
|
|
1512
|
-
const privateKeyPath = explicit ? explicit.replace(/\.pub$/, "") : defaultIdentityBase();
|
|
1513
|
-
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
1514
|
-
if (!(0, import_node_fs.existsSync)(publicKeyPath)) {
|
|
1515
|
-
if (!boolFlag(args, "generate")) {
|
|
1516
|
-
die(
|
|
1517
|
-
`no SSH public key at ${publicKeyPath}. Pass --identity <path>, or --generate to create an ed25519 key pair.`
|
|
1518
|
-
);
|
|
1519
|
-
}
|
|
1520
|
-
err(`generating ed25519 key pair at ${privateKeyPath}`);
|
|
1521
|
-
const gen = (0, import_node_child_process.spawnSync)(
|
|
1522
|
-
"ssh-keygen",
|
|
1523
|
-
["-t", "ed25519", "-N", "", "-f", privateKeyPath, "-C", "arker-cli"],
|
|
1524
|
-
{ stdio: "inherit" }
|
|
1525
|
-
);
|
|
1526
|
-
if (gen.status !== 0) die("ssh-keygen failed to generate a key pair");
|
|
1527
|
-
}
|
|
1528
|
-
const publicKey = (0, import_node_fs.readFileSync)(publicKeyPath, "utf8").trim();
|
|
1529
|
-
if (!publicKey) die(`SSH public key at ${publicKeyPath} is empty`);
|
|
1530
|
-
return { publicKey, privateKeyPath, publicKeyPath };
|
|
1531
|
-
}
|
|
1532
|
-
async function registerAccountSshKey(client, publicKey, label) {
|
|
1533
|
-
return client._request(
|
|
1534
|
-
"POST",
|
|
1535
|
-
"/v1/account/ssh-keys",
|
|
1536
|
-
{ public_key: publicKey, label: label ?? null },
|
|
1537
|
-
client.baseUrl
|
|
1538
|
-
);
|
|
1539
|
-
}
|
|
1540
|
-
function resolveSshHost(args, client) {
|
|
1541
|
-
const explicit = args.flags.host ?? process.env.ARKER_SSH_HOST;
|
|
1542
|
-
if (explicit) return explicit;
|
|
1543
|
-
if (client.region) return `aws-${client.region}.arker.ai`;
|
|
1544
|
-
try {
|
|
1545
|
-
return new URL(client.baseUrl).hostname;
|
|
1546
|
-
} catch {
|
|
1547
|
-
die("could not determine SSH host; pass --host <hostname>");
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
async function cmdSsh(args, client) {
|
|
1551
|
-
const vmId = args.flags["vm-id"] ?? args.positional[0];
|
|
1552
|
-
if (!vmId) {
|
|
1553
|
-
die(
|
|
1554
|
-
"usage: arker ssh <vm_id> [--identity <path>] [--generate] [--host <h>] [--port <n>] [--connect|-c] [--skip-register]"
|
|
1555
|
-
);
|
|
1556
|
-
}
|
|
1557
|
-
const { publicKey, privateKeyPath } = resolveLocalSshKey(args);
|
|
1558
|
-
if (!boolFlag(args, "skip-register")) {
|
|
1559
|
-
const label = args.flags.label ?? `arker-cli ${(0, import_node_os.homedir)().split("/").pop() ?? ""}`.trim();
|
|
1560
|
-
try {
|
|
1561
|
-
const key = await registerAccountSshKey(client, publicKey, label);
|
|
1562
|
-
err(`registered SSH key ${key.fingerprint}${key.label ? ` (${key.label})` : ""}`);
|
|
1563
|
-
} catch (e) {
|
|
1564
|
-
if (e instanceof ArkerError && e.status === 409) {
|
|
1565
|
-
die(`this SSH key is already registered to a different account: ${e.message}`);
|
|
1566
|
-
}
|
|
1567
|
-
if (e instanceof ArkerError && e.status === 403) {
|
|
1568
|
-
die(
|
|
1569
|
-
"your API key lacks the developer role required to register SSH keys. Register the key in the console, then re-run with --skip-register."
|
|
1570
|
-
);
|
|
1571
|
-
}
|
|
1572
|
-
throw e;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
const host = resolveSshHost(args, client);
|
|
1576
|
-
const port = numFlag(args, "port") ?? SSH_PORT_DEFAULT;
|
|
1577
|
-
const sshArgs = [
|
|
1578
|
-
"-i",
|
|
1579
|
-
privateKeyPath,
|
|
1580
|
-
...port !== 22 ? ["-p", String(port)] : [],
|
|
1581
|
-
`${vmId}@${host}`
|
|
1582
|
-
];
|
|
1583
|
-
const command = `ssh ${sshArgs.join(" ")}`;
|
|
1584
|
-
if (boolFlag(args, "connect") || boolFlag(args, "c")) {
|
|
1585
|
-
err(`connecting: ${command}`);
|
|
1586
|
-
const r = (0, import_node_child_process.spawnSync)("ssh", sshArgs, { stdio: "inherit" });
|
|
1587
|
-
process.exit(r.status ?? 1);
|
|
1588
|
-
}
|
|
1589
|
-
out(command);
|
|
1590
|
-
}
|
|
1591
|
-
async function cmdSshKeys(args, client) {
|
|
1592
|
-
const sub = args.positional[0];
|
|
1593
|
-
const rest = args.positional.slice(1);
|
|
1594
|
-
switch (sub) {
|
|
1595
|
-
case void 0:
|
|
1596
|
-
case "ls":
|
|
1597
|
-
case "list": {
|
|
1598
|
-
const res = await client._request(
|
|
1599
|
-
"GET",
|
|
1600
|
-
"/v1/account/ssh-keys",
|
|
1601
|
-
void 0,
|
|
1602
|
-
client.baseUrl
|
|
1603
|
-
);
|
|
1604
|
-
if (args.flags.json) return out(res);
|
|
1605
|
-
for (const k of res.keys) {
|
|
1606
|
-
out(`${k.id} ${k.fingerprint} ${k.label ?? "\u2014"}`);
|
|
1607
|
-
}
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
case "add": {
|
|
1611
|
-
const { publicKey } = resolveLocalSshKey(args);
|
|
1612
|
-
const label = args.flags.label;
|
|
1613
|
-
const key = await registerAccountSshKey(client, publicKey, label);
|
|
1614
|
-
if (args.flags.json) return out(key);
|
|
1615
|
-
out(`${key.id} ${key.fingerprint} ${key.label ?? "\u2014"}`);
|
|
1616
|
-
return;
|
|
1617
|
-
}
|
|
1618
|
-
case "rm":
|
|
1619
|
-
case "delete": {
|
|
1620
|
-
const id = rest[0] ?? die("usage: arker ssh-keys rm <key_id>");
|
|
1621
|
-
const r = await client._request(
|
|
1622
|
-
"DELETE",
|
|
1623
|
-
`/v1/account/ssh-keys/${encodeURIComponent(id)}`,
|
|
1624
|
-
void 0,
|
|
1625
|
-
client.baseUrl
|
|
1626
|
-
);
|
|
1627
|
-
out(r.deleted ? `deleted ${id}` : "delete failed");
|
|
1628
|
-
return;
|
|
1629
|
-
}
|
|
1630
|
-
default:
|
|
1631
|
-
die("usage: arker ssh-keys <ls|add|rm> ...");
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
1513
|
function numFlag(args, name) {
|
|
1635
1514
|
const v = args.flags[name];
|
|
1636
1515
|
if (typeof v === "string") return Number(v);
|
|
@@ -1651,7 +1530,7 @@ async function readAllStdin() {
|
|
|
1651
1530
|
function usage() {
|
|
1652
1531
|
out(
|
|
1653
1532
|
[
|
|
1654
|
-
|
|
1533
|
+
`arker v${VERSION}`,
|
|
1655
1534
|
"",
|
|
1656
1535
|
"Usage:",
|
|
1657
1536
|
" arker <command> [args]",
|
|
@@ -1668,8 +1547,6 @@ function usage() {
|
|
|
1668
1547
|
" arker run <vm> <command> [--session-id <id>] [--session-idx N] run a command",
|
|
1669
1548
|
" arker resize <vm> [--memory-mib N] [--vcpu N] [--disk-mib N] resize a VM (PATCH)",
|
|
1670
1549
|
" arker shell [vm_id] native PTY shell (forks ubuntu-full if no vm)",
|
|
1671
|
-
" arker ssh <vm_id> register your SSH key + print the ssh command",
|
|
1672
|
-
" arker ssh <vm_id> --connect register + drop straight into the ssh session",
|
|
1673
1550
|
"",
|
|
1674
1551
|
"Resources:",
|
|
1675
1552
|
" arker vms <ls|get|rm|fork|run> ...",
|
|
@@ -1677,12 +1554,11 @@ function usage() {
|
|
|
1677
1554
|
" arker sessions <ls|get|create|rm> <vm_id> ...",
|
|
1678
1555
|
" arker syncs <ls|create|rm> <vm_id> ...",
|
|
1679
1556
|
" arker filesystems <ls|create|get|rm> ... (alias: fs)",
|
|
1680
|
-
" arker ssh-keys <ls|add|rm> ... manage account SSH keys",
|
|
1681
1557
|
"",
|
|
1682
1558
|
"Flags:",
|
|
1683
1559
|
" --api-key <key> (or env ARKER_API_KEY)",
|
|
1684
1560
|
" --region <region> (or env ARKER_REGION; e.g. us-west-2)",
|
|
1685
|
-
" --provider <aws
|
|
1561
|
+
" --provider <aws> (or env ARKER_PROVIDER; default aws)",
|
|
1686
1562
|
" --base-url <url> override compute URL (env ARKER_BASE_URL)",
|
|
1687
1563
|
" --control-base-url <url> override CF Worker URL (env ARKER_CONTROL_BASE_URL)",
|
|
1688
1564
|
" --json emit JSON instead of tabular output",
|
|
@@ -1705,18 +1581,7 @@ function usage() {
|
|
|
1705
1581
|
" --session-id <id> reconnect to an existing PTY session",
|
|
1706
1582
|
" --command <path> shell executable path (default: /bin/bash)",
|
|
1707
1583
|
" --cols <n> --rows <n> initial terminal size",
|
|
1708
|
-
" --no-persist close the remote PTY process on disconnect"
|
|
1709
|
-
"",
|
|
1710
|
-
"SSH flags:",
|
|
1711
|
-
" --identity <path> local key (private or .pub); default ~/.ssh/id_ed25519",
|
|
1712
|
-
" --generate create an ed25519 key pair if none exists",
|
|
1713
|
-
" --host <hostname> SSH host (or env ARKER_SSH_HOST; default aws-<region>.arker.ai)",
|
|
1714
|
-
" --port <n> SSH port (default 22)",
|
|
1715
|
-
" --connect, -c exec ssh instead of just printing the command",
|
|
1716
|
-
" --skip-register don't register the key (assume already registered)",
|
|
1717
|
-
" --label <text> label for the registered key",
|
|
1718
|
-
"",
|
|
1719
|
-
`Arker org id: ${ARKER_ORG_ID}`
|
|
1584
|
+
" --no-persist close the remote PTY process on disconnect"
|
|
1720
1585
|
].join("\n")
|
|
1721
1586
|
);
|
|
1722
1587
|
process.exit(2);
|
|
@@ -1746,11 +1611,10 @@ async function main() {
|
|
|
1746
1611
|
return await cmdSyncs(args, client);
|
|
1747
1612
|
case "shell":
|
|
1748
1613
|
return await cmdShell(args, client);
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
return await cmdSshKeys(args, client);
|
|
1614
|
+
// SSH is descoped/unsupported and hidden from the interface. The
|
|
1615
|
+
// implementation below (cmdSsh / cmdSshKeys) is kept intact; re-add
|
|
1616
|
+
// the `ssh` / `ssh-keys` cases here and their help entries to expose
|
|
1617
|
+
// it once the server-side SSH path is supported.
|
|
1754
1618
|
// Resources.
|
|
1755
1619
|
case "vms":
|
|
1756
1620
|
return await cmdVms(args, client);
|
package/dist/cli.js
CHANGED
|
@@ -8,9 +8,17 @@ import {
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { readFileSync, existsSync } from "fs";
|
|
10
10
|
import { spawnSync } from "child_process";
|
|
11
|
+
import { createRequire } from "module";
|
|
11
12
|
import { homedir } from "os";
|
|
12
13
|
import { join } from "path";
|
|
13
14
|
import { stdin as input, stdout as output } from "process";
|
|
15
|
+
var VERSION = (() => {
|
|
16
|
+
try {
|
|
17
|
+
return createRequire(import.meta.url)("../package.json").version;
|
|
18
|
+
} catch {
|
|
19
|
+
return "unknown";
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
14
22
|
function parseArgs(argv) {
|
|
15
23
|
const positional = [];
|
|
16
24
|
const flags = {};
|
|
@@ -49,6 +57,7 @@ function readFileConfig() {
|
|
|
49
57
|
}
|
|
50
58
|
return {};
|
|
51
59
|
}
|
|
60
|
+
var DEFAULT_REGION = "us-west-2";
|
|
52
61
|
function clientFromArgs(args) {
|
|
53
62
|
const file = readFileConfig();
|
|
54
63
|
const explicitBaseUrl = args.flags["base-url"] ?? process.env.ARKER_BASE_URL;
|
|
@@ -56,14 +65,11 @@ function clientFromArgs(args) {
|
|
|
56
65
|
const apiKey = args.flags["api-key"] ?? process.env.ARKER_API_KEY ?? file.apiKey;
|
|
57
66
|
const baseUrl = explicitBaseUrl ?? (explicitRegion ? void 0 : file.baseUrl);
|
|
58
67
|
const controlBaseUrl = args.flags["control-base-url"] ?? process.env.ARKER_CONTROL_BASE_URL;
|
|
59
|
-
const region = explicitRegion ?? file.region;
|
|
68
|
+
const region = explicitRegion ?? file.region ?? (baseUrl ? void 0 : DEFAULT_REGION);
|
|
60
69
|
const provider = args.flags.provider ?? process.env.ARKER_PROVIDER;
|
|
61
70
|
if (!apiKey) {
|
|
62
71
|
die("Missing API key. Set ARKER_API_KEY or pass --api-key.");
|
|
63
72
|
}
|
|
64
|
-
if (!baseUrl && !region) {
|
|
65
|
-
die("Missing region. Set ARKER_REGION or pass --region (e.g. us-west-2). --provider (aws|aws-burst) defaults to aws.");
|
|
66
|
-
}
|
|
67
73
|
return new Arker({ apiKey, baseUrl, region, provider, controlBaseUrl });
|
|
68
74
|
}
|
|
69
75
|
function out(value) {
|
|
@@ -551,134 +557,6 @@ function bridgePty(pty, options) {
|
|
|
551
557
|
});
|
|
552
558
|
});
|
|
553
559
|
}
|
|
554
|
-
var SSH_PORT_DEFAULT = 22;
|
|
555
|
-
function defaultIdentityBase() {
|
|
556
|
-
return join(homedir(), ".ssh", "id_ed25519");
|
|
557
|
-
}
|
|
558
|
-
function resolveLocalSshKey(args) {
|
|
559
|
-
const explicit = args.flags.identity;
|
|
560
|
-
const privateKeyPath = explicit ? explicit.replace(/\.pub$/, "") : defaultIdentityBase();
|
|
561
|
-
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
562
|
-
if (!existsSync(publicKeyPath)) {
|
|
563
|
-
if (!boolFlag(args, "generate")) {
|
|
564
|
-
die(
|
|
565
|
-
`no SSH public key at ${publicKeyPath}. Pass --identity <path>, or --generate to create an ed25519 key pair.`
|
|
566
|
-
);
|
|
567
|
-
}
|
|
568
|
-
err(`generating ed25519 key pair at ${privateKeyPath}`);
|
|
569
|
-
const gen = spawnSync(
|
|
570
|
-
"ssh-keygen",
|
|
571
|
-
["-t", "ed25519", "-N", "", "-f", privateKeyPath, "-C", "arker-cli"],
|
|
572
|
-
{ stdio: "inherit" }
|
|
573
|
-
);
|
|
574
|
-
if (gen.status !== 0) die("ssh-keygen failed to generate a key pair");
|
|
575
|
-
}
|
|
576
|
-
const publicKey = readFileSync(publicKeyPath, "utf8").trim();
|
|
577
|
-
if (!publicKey) die(`SSH public key at ${publicKeyPath} is empty`);
|
|
578
|
-
return { publicKey, privateKeyPath, publicKeyPath };
|
|
579
|
-
}
|
|
580
|
-
async function registerAccountSshKey(client, publicKey, label) {
|
|
581
|
-
return client._request(
|
|
582
|
-
"POST",
|
|
583
|
-
"/v1/account/ssh-keys",
|
|
584
|
-
{ public_key: publicKey, label: label ?? null },
|
|
585
|
-
client.baseUrl
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
function resolveSshHost(args, client) {
|
|
589
|
-
const explicit = args.flags.host ?? process.env.ARKER_SSH_HOST;
|
|
590
|
-
if (explicit) return explicit;
|
|
591
|
-
if (client.region) return `aws-${client.region}.arker.ai`;
|
|
592
|
-
try {
|
|
593
|
-
return new URL(client.baseUrl).hostname;
|
|
594
|
-
} catch {
|
|
595
|
-
die("could not determine SSH host; pass --host <hostname>");
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
async function cmdSsh(args, client) {
|
|
599
|
-
const vmId = args.flags["vm-id"] ?? args.positional[0];
|
|
600
|
-
if (!vmId) {
|
|
601
|
-
die(
|
|
602
|
-
"usage: arker ssh <vm_id> [--identity <path>] [--generate] [--host <h>] [--port <n>] [--connect|-c] [--skip-register]"
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
const { publicKey, privateKeyPath } = resolveLocalSshKey(args);
|
|
606
|
-
if (!boolFlag(args, "skip-register")) {
|
|
607
|
-
const label = args.flags.label ?? `arker-cli ${homedir().split("/").pop() ?? ""}`.trim();
|
|
608
|
-
try {
|
|
609
|
-
const key = await registerAccountSshKey(client, publicKey, label);
|
|
610
|
-
err(`registered SSH key ${key.fingerprint}${key.label ? ` (${key.label})` : ""}`);
|
|
611
|
-
} catch (e) {
|
|
612
|
-
if (e instanceof ArkerError && e.status === 409) {
|
|
613
|
-
die(`this SSH key is already registered to a different account: ${e.message}`);
|
|
614
|
-
}
|
|
615
|
-
if (e instanceof ArkerError && e.status === 403) {
|
|
616
|
-
die(
|
|
617
|
-
"your API key lacks the developer role required to register SSH keys. Register the key in the console, then re-run with --skip-register."
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
throw e;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
const host = resolveSshHost(args, client);
|
|
624
|
-
const port = numFlag(args, "port") ?? SSH_PORT_DEFAULT;
|
|
625
|
-
const sshArgs = [
|
|
626
|
-
"-i",
|
|
627
|
-
privateKeyPath,
|
|
628
|
-
...port !== 22 ? ["-p", String(port)] : [],
|
|
629
|
-
`${vmId}@${host}`
|
|
630
|
-
];
|
|
631
|
-
const command = `ssh ${sshArgs.join(" ")}`;
|
|
632
|
-
if (boolFlag(args, "connect") || boolFlag(args, "c")) {
|
|
633
|
-
err(`connecting: ${command}`);
|
|
634
|
-
const r = spawnSync("ssh", sshArgs, { stdio: "inherit" });
|
|
635
|
-
process.exit(r.status ?? 1);
|
|
636
|
-
}
|
|
637
|
-
out(command);
|
|
638
|
-
}
|
|
639
|
-
async function cmdSshKeys(args, client) {
|
|
640
|
-
const sub = args.positional[0];
|
|
641
|
-
const rest = args.positional.slice(1);
|
|
642
|
-
switch (sub) {
|
|
643
|
-
case void 0:
|
|
644
|
-
case "ls":
|
|
645
|
-
case "list": {
|
|
646
|
-
const res = await client._request(
|
|
647
|
-
"GET",
|
|
648
|
-
"/v1/account/ssh-keys",
|
|
649
|
-
void 0,
|
|
650
|
-
client.baseUrl
|
|
651
|
-
);
|
|
652
|
-
if (args.flags.json) return out(res);
|
|
653
|
-
for (const k of res.keys) {
|
|
654
|
-
out(`${k.id} ${k.fingerprint} ${k.label ?? "\u2014"}`);
|
|
655
|
-
}
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
case "add": {
|
|
659
|
-
const { publicKey } = resolveLocalSshKey(args);
|
|
660
|
-
const label = args.flags.label;
|
|
661
|
-
const key = await registerAccountSshKey(client, publicKey, label);
|
|
662
|
-
if (args.flags.json) return out(key);
|
|
663
|
-
out(`${key.id} ${key.fingerprint} ${key.label ?? "\u2014"}`);
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
case "rm":
|
|
667
|
-
case "delete": {
|
|
668
|
-
const id = rest[0] ?? die("usage: arker ssh-keys rm <key_id>");
|
|
669
|
-
const r = await client._request(
|
|
670
|
-
"DELETE",
|
|
671
|
-
`/v1/account/ssh-keys/${encodeURIComponent(id)}`,
|
|
672
|
-
void 0,
|
|
673
|
-
client.baseUrl
|
|
674
|
-
);
|
|
675
|
-
out(r.deleted ? `deleted ${id}` : "delete failed");
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
default:
|
|
679
|
-
die("usage: arker ssh-keys <ls|add|rm> ...");
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
560
|
function numFlag(args, name) {
|
|
683
561
|
const v = args.flags[name];
|
|
684
562
|
if (typeof v === "string") return Number(v);
|
|
@@ -699,7 +577,7 @@ async function readAllStdin() {
|
|
|
699
577
|
function usage() {
|
|
700
578
|
out(
|
|
701
579
|
[
|
|
702
|
-
|
|
580
|
+
`arker v${VERSION}`,
|
|
703
581
|
"",
|
|
704
582
|
"Usage:",
|
|
705
583
|
" arker <command> [args]",
|
|
@@ -716,8 +594,6 @@ function usage() {
|
|
|
716
594
|
" arker run <vm> <command> [--session-id <id>] [--session-idx N] run a command",
|
|
717
595
|
" arker resize <vm> [--memory-mib N] [--vcpu N] [--disk-mib N] resize a VM (PATCH)",
|
|
718
596
|
" arker shell [vm_id] native PTY shell (forks ubuntu-full if no vm)",
|
|
719
|
-
" arker ssh <vm_id> register your SSH key + print the ssh command",
|
|
720
|
-
" arker ssh <vm_id> --connect register + drop straight into the ssh session",
|
|
721
597
|
"",
|
|
722
598
|
"Resources:",
|
|
723
599
|
" arker vms <ls|get|rm|fork|run> ...",
|
|
@@ -725,12 +601,11 @@ function usage() {
|
|
|
725
601
|
" arker sessions <ls|get|create|rm> <vm_id> ...",
|
|
726
602
|
" arker syncs <ls|create|rm> <vm_id> ...",
|
|
727
603
|
" arker filesystems <ls|create|get|rm> ... (alias: fs)",
|
|
728
|
-
" arker ssh-keys <ls|add|rm> ... manage account SSH keys",
|
|
729
604
|
"",
|
|
730
605
|
"Flags:",
|
|
731
606
|
" --api-key <key> (or env ARKER_API_KEY)",
|
|
732
607
|
" --region <region> (or env ARKER_REGION; e.g. us-west-2)",
|
|
733
|
-
" --provider <aws
|
|
608
|
+
" --provider <aws> (or env ARKER_PROVIDER; default aws)",
|
|
734
609
|
" --base-url <url> override compute URL (env ARKER_BASE_URL)",
|
|
735
610
|
" --control-base-url <url> override CF Worker URL (env ARKER_CONTROL_BASE_URL)",
|
|
736
611
|
" --json emit JSON instead of tabular output",
|
|
@@ -753,18 +628,7 @@ function usage() {
|
|
|
753
628
|
" --session-id <id> reconnect to an existing PTY session",
|
|
754
629
|
" --command <path> shell executable path (default: /bin/bash)",
|
|
755
630
|
" --cols <n> --rows <n> initial terminal size",
|
|
756
|
-
" --no-persist close the remote PTY process on disconnect"
|
|
757
|
-
"",
|
|
758
|
-
"SSH flags:",
|
|
759
|
-
" --identity <path> local key (private or .pub); default ~/.ssh/id_ed25519",
|
|
760
|
-
" --generate create an ed25519 key pair if none exists",
|
|
761
|
-
" --host <hostname> SSH host (or env ARKER_SSH_HOST; default aws-<region>.arker.ai)",
|
|
762
|
-
" --port <n> SSH port (default 22)",
|
|
763
|
-
" --connect, -c exec ssh instead of just printing the command",
|
|
764
|
-
" --skip-register don't register the key (assume already registered)",
|
|
765
|
-
" --label <text> label for the registered key",
|
|
766
|
-
"",
|
|
767
|
-
`Arker org id: ${ARKER_ORG_ID}`
|
|
631
|
+
" --no-persist close the remote PTY process on disconnect"
|
|
768
632
|
].join("\n")
|
|
769
633
|
);
|
|
770
634
|
process.exit(2);
|
|
@@ -794,11 +658,10 @@ async function main() {
|
|
|
794
658
|
return await cmdSyncs(args, client);
|
|
795
659
|
case "shell":
|
|
796
660
|
return await cmdShell(args, client);
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
return await cmdSshKeys(args, client);
|
|
661
|
+
// SSH is descoped/unsupported and hidden from the interface. The
|
|
662
|
+
// implementation below (cmdSsh / cmdSshKeys) is kept intact; re-add
|
|
663
|
+
// the `ssh` / `ssh-keys` cases here and their help entries to expose
|
|
664
|
+
// it once the server-side SSH path is supported.
|
|
802
665
|
// Resources.
|
|
803
666
|
case "vms":
|
|
804
667
|
return await cmdVms(args, client);
|
package/package.json
CHANGED