@craftspace/cli 0.4.1 → 0.4.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/index.js +29 -7
- package/dist/machine.d.ts +2 -1
- package/dist/machine.js +25 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19259,7 +19259,8 @@ var ConnectionToolSchema = external_exports.object({
|
|
|
19259
19259
|
});
|
|
19260
19260
|
var ListConnectionToolsResponseSchema = external_exports.object({
|
|
19261
19261
|
tools: external_exports.array(ConnectionToolSchema),
|
|
19262
|
-
reachable: external_exports.boolean()
|
|
19262
|
+
reachable: external_exports.boolean(),
|
|
19263
|
+
error: external_exports.string().optional()
|
|
19263
19264
|
});
|
|
19264
19265
|
var CreateConnectionBodySchema = external_exports.object({
|
|
19265
19266
|
kind: external_exports.enum(ConnectionKind),
|
|
@@ -19782,7 +19783,7 @@ var SaveWorkstationBodySchema = external_exports.object({
|
|
|
19782
19783
|
var WorkstationResponseSchema = external_exports.object({ workstation: WorkstationSchema });
|
|
19783
19784
|
|
|
19784
19785
|
// ../../shared/dist/machines/machine.js
|
|
19785
|
-
var CLI_VERSION = "0.4.
|
|
19786
|
+
var CLI_VERSION = "0.4.3";
|
|
19786
19787
|
var CLI_PACKAGE = "@craftspace/cli";
|
|
19787
19788
|
var CLI_INSTALL = `npm i -g ${CLI_PACKAGE}`;
|
|
19788
19789
|
var MACHINE_BEAT_INTERVAL_MS = 15e3;
|
|
@@ -23112,8 +23113,9 @@ var machine = {
|
|
|
23112
23113
|
};
|
|
23113
23114
|
return answer.machine;
|
|
23114
23115
|
},
|
|
23115
|
-
async
|
|
23116
|
-
|
|
23116
|
+
async controlPlane(override) {
|
|
23117
|
+
const where = override ?? process.env.CRAFTSPACE_URL ?? (await readConfig())?.url ?? DEFAULT_URL;
|
|
23118
|
+
return where.replace(/\/$/, "");
|
|
23117
23119
|
},
|
|
23118
23120
|
async signIn({ url: url2, why, install = false }) {
|
|
23119
23121
|
const where = url2 ?? (await readConfig())?.url ?? DEFAULT_URL;
|
|
@@ -23266,7 +23268,10 @@ ${ui.dim("\u2192")} ${ui.name(target.name)} ${ui.dim(`\xB7 ${where}`)}
|
|
|
23266
23268
|
|
|
23267
23269
|
`);
|
|
23268
23270
|
return new Promise((resolve) => {
|
|
23269
|
-
const session = spawn2("ssh", ["-t", where], {
|
|
23271
|
+
const session = spawn2("ssh", ["-t", where], {
|
|
23272
|
+
stdio: "inherit",
|
|
23273
|
+
env: { ...process.env, TERM: portableTerm(process.env.TERM) }
|
|
23274
|
+
});
|
|
23270
23275
|
session.on("error", (error51) => {
|
|
23271
23276
|
ui.say(ui.bad(`could not start ssh`, error51.message));
|
|
23272
23277
|
resolve(1);
|
|
@@ -23274,6 +23279,9 @@ ${ui.dim("\u2192")} ${ui.name(target.name)} ${ui.dim(`\xB7 ${where}`)}
|
|
|
23274
23279
|
session.on("exit", (code) => resolve(code ?? 0));
|
|
23275
23280
|
});
|
|
23276
23281
|
}
|
|
23282
|
+
function portableTerm(local) {
|
|
23283
|
+
return local !== void 0 && PORTABLE_TERMS.has(local) ? local : "xterm-256color";
|
|
23284
|
+
}
|
|
23277
23285
|
function nowhereToGo({ url: url2 }) {
|
|
23278
23286
|
ui.say(`
|
|
23279
23287
|
${ui.attention("No workstations here yet.")}
|
|
@@ -23603,6 +23611,21 @@ var KEYS_BEGIN = "# craftspace begin";
|
|
|
23603
23611
|
var KEYS_END = "# craftspace end";
|
|
23604
23612
|
var UPDATE_EVERY_MS = 6 * 60 * 60 * 1e3;
|
|
23605
23613
|
var BEATING = "beating every 15s, outbound only, and keeps this set up";
|
|
23614
|
+
var PORTABLE_TERMS = /* @__PURE__ */ new Set([
|
|
23615
|
+
"ansi",
|
|
23616
|
+
"dumb",
|
|
23617
|
+
"linux",
|
|
23618
|
+
"rxvt",
|
|
23619
|
+
"rxvt-unicode",
|
|
23620
|
+
"rxvt-unicode-256color",
|
|
23621
|
+
"screen",
|
|
23622
|
+
"screen-256color",
|
|
23623
|
+
"vt100",
|
|
23624
|
+
"vt220",
|
|
23625
|
+
"xterm",
|
|
23626
|
+
"xterm-color",
|
|
23627
|
+
"xterm-256color"
|
|
23628
|
+
]);
|
|
23606
23629
|
var LINGER_LINE = `sudo loginctl enable-linger ${os5.userInfo().username}`;
|
|
23607
23630
|
var DEFAULT_URL = process.env.CRAFTSPACE_URL ?? "https://craftspace.app";
|
|
23608
23631
|
var PROBE_EVERY_MS = 3e5;
|
|
@@ -23615,7 +23638,7 @@ setup.widenPath();
|
|
|
23615
23638
|
var program2 = new Command();
|
|
23616
23639
|
program2.enablePositionalOptions().name("cs").description("Sign this machine in to your team, so every agent on it reads the same brain.").version(CLI_VERSION).showHelpAfterError();
|
|
23617
23640
|
program2.command("login").description("sign this machine in").option("--token <token>", "the login token from your team", process.env.CRAFTSPACE_TOKEN).option("--url <url>", "your control plane, remembered after the first login").option("--no-install", "do not install anything this machine is missing").action(async ({ token, url: url2, install }) => {
|
|
23618
|
-
const where =
|
|
23641
|
+
const where = await machine.controlPlane(url2);
|
|
23619
23642
|
const signed = token === void 0 ? (await machine.signIn({ url: where, why: "Signing this machine in.", install })).machine : await machine.login({ token, url: where, install });
|
|
23620
23643
|
const daemon = await machine.daemon();
|
|
23621
23644
|
ui.say(ui.heading(`Signed in as ${signed.ownerName}`));
|
|
@@ -23654,7 +23677,6 @@ try {
|
|
|
23654
23677
|
function machineSpecs({ platform, cores, memoryGb }) {
|
|
23655
23678
|
return [platform, cores === null ? null : `${cores} vCPU`, memoryGb == null ? null : `${memoryGb} GB`].filter((part) => part !== null).join(" \xB7 ");
|
|
23656
23679
|
}
|
|
23657
|
-
var DEFAULT_URL2 = "https://craftspace.app";
|
|
23658
23680
|
function secondsSince(at) {
|
|
23659
23681
|
return Math.round((Date.now() - new Date(at).getTime()) / 1e3);
|
|
23660
23682
|
}
|
package/dist/machine.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const machine: {
|
|
|
6
6
|
url: string;
|
|
7
7
|
install: boolean;
|
|
8
8
|
}): Promise<Machine>;
|
|
9
|
-
|
|
9
|
+
controlPlane(override?: string): Promise<string>;
|
|
10
10
|
signIn({ url, why, install }: {
|
|
11
11
|
url?: string;
|
|
12
12
|
why: string;
|
|
@@ -25,6 +25,7 @@ export declare const machine: {
|
|
|
25
25
|
}>;
|
|
26
26
|
logout(): Promise<void>;
|
|
27
27
|
};
|
|
28
|
+
export declare function portableTerm(local: string | undefined): string;
|
|
28
29
|
export declare function tokenIn(line: string): string | undefined;
|
|
29
30
|
export declare function nextDelayMs(failures: number, busy?: boolean): number;
|
|
30
31
|
interface Auth {
|
package/dist/machine.js
CHANGED
|
@@ -43,8 +43,9 @@ export const machine = {
|
|
|
43
43
|
};
|
|
44
44
|
return answer.machine;
|
|
45
45
|
},
|
|
46
|
-
async
|
|
47
|
-
|
|
46
|
+
async controlPlane(override) {
|
|
47
|
+
const where = override ?? process.env.CRAFTSPACE_URL ?? (await readConfig())?.url ?? DEFAULT_URL;
|
|
48
|
+
return where.replace(/\/$/, '');
|
|
48
49
|
},
|
|
49
50
|
async signIn({ url, why, install = false }) {
|
|
50
51
|
const where = url ?? (await readConfig())?.url ?? DEFAULT_URL;
|
|
@@ -196,7 +197,10 @@ async function openTerminal(target) {
|
|
|
196
197
|
const where = `${target.sshUser ?? 'root'}@${target.sshAddress}`;
|
|
197
198
|
ui.say(`\n${ui.dim('\u2192')} ${ui.name(target.name)} ${ui.dim(`\u00b7 ${where}`)}\n\n`);
|
|
198
199
|
return new Promise((resolve) => {
|
|
199
|
-
const session = spawn('ssh', ['-t', where], {
|
|
200
|
+
const session = spawn('ssh', ['-t', where], {
|
|
201
|
+
stdio: 'inherit',
|
|
202
|
+
env: { ...process.env, TERM: portableTerm(process.env.TERM) },
|
|
203
|
+
});
|
|
200
204
|
session.on('error', (error) => {
|
|
201
205
|
ui.say(ui.bad(`could not start ssh`, error.message));
|
|
202
206
|
resolve(1);
|
|
@@ -204,6 +208,9 @@ async function openTerminal(target) {
|
|
|
204
208
|
session.on('exit', (code) => resolve(code ?? 0));
|
|
205
209
|
});
|
|
206
210
|
}
|
|
211
|
+
export function portableTerm(local) {
|
|
212
|
+
return local !== undefined && PORTABLE_TERMS.has(local) ? local : 'xterm-256color';
|
|
213
|
+
}
|
|
207
214
|
function nowhereToGo({ url }) {
|
|
208
215
|
ui.say(`\n${ui.attention('No workstations here yet.')}\n\n`);
|
|
209
216
|
ui.say(ui.field('Add one', ui.link(`${url}/workstations`)));
|
|
@@ -524,6 +531,21 @@ const KEYS_BEGIN = '# craftspace begin';
|
|
|
524
531
|
const KEYS_END = '# craftspace end';
|
|
525
532
|
const UPDATE_EVERY_MS = 6 * 60 * 60 * 1_000;
|
|
526
533
|
const BEATING = 'beating every 15s, outbound only, and keeps this set up';
|
|
534
|
+
const PORTABLE_TERMS = new Set([
|
|
535
|
+
'ansi',
|
|
536
|
+
'dumb',
|
|
537
|
+
'linux',
|
|
538
|
+
'rxvt',
|
|
539
|
+
'rxvt-unicode',
|
|
540
|
+
'rxvt-unicode-256color',
|
|
541
|
+
'screen',
|
|
542
|
+
'screen-256color',
|
|
543
|
+
'vt100',
|
|
544
|
+
'vt220',
|
|
545
|
+
'xterm',
|
|
546
|
+
'xterm-color',
|
|
547
|
+
'xterm-256color',
|
|
548
|
+
]);
|
|
527
549
|
const LINGER_LINE = `sudo loginctl enable-linger ${os.userInfo().username}`;
|
|
528
550
|
const DEFAULT_URL = process.env.CRAFTSPACE_URL ?? 'https://craftspace.app';
|
|
529
551
|
const PROBE_EVERY_MS = 300_000;
|