replicas-cli 0.3.345 → 0.3.347
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.cjs +80 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22785,7 +22785,7 @@ var init_workspace_identity = __esm({
|
|
|
22785
22785
|
});
|
|
22786
22786
|
|
|
22787
22787
|
// ../shared/src/routes/environment.ts
|
|
22788
|
-
var ENVIRONMENT_MCP_TRANSPORTS, stringMap, createEnvironmentMcpRequestSchema, updateEnvironmentMcpRequestSchema, screenPasswordSchema, hostSchema, createEnvironmentDeviceRequestSchema, updateEnvironmentDeviceRequestSchema, deviceConnectionResponseSchema, deviceHostKeysRequestSchema, DEVICE_CONNECT_COMMAND, provisionedDeviceSchema;
|
|
22788
|
+
var ENVIRONMENT_MCP_TRANSPORTS, stringMap, createEnvironmentMcpRequestSchema, updateEnvironmentMcpRequestSchema, screenPasswordSchema, hostSchema, createEnvironmentDeviceRequestSchema, updateEnvironmentDeviceRequestSchema, DEVICE_ONLINE_WINDOW_MS, isDeviceOnline, deviceConnectionResponseSchema, deviceHostKeysRequestSchema, DEVICE_CONNECT_COMMAND, provisionedDeviceSchema;
|
|
22789
22789
|
var init_environment = __esm({
|
|
22790
22790
|
"../shared/src/routes/environment.ts"() {
|
|
22791
22791
|
"use strict";
|
|
@@ -22816,6 +22816,8 @@ var init_environment = __esm({
|
|
|
22816
22816
|
host: external_exports.union([hostSchema, external_exports.literal("")]).optional().describe("New hostname or IP, or an empty string for a device that connects to Replicas itself."),
|
|
22817
22817
|
screen_password: external_exports.union([screenPasswordSchema, external_exports.literal("")]).optional().describe("New Screen Sharing password, or an empty string to remove it.")
|
|
22818
22818
|
});
|
|
22819
|
+
DEVICE_ONLINE_WINDOW_MS = 3e4;
|
|
22820
|
+
isDeviceOnline = (lastSeenAt, now = Date.now()) => lastSeenAt !== null && now - Date.parse(lastSeenAt) < DEVICE_ONLINE_WINDOW_MS;
|
|
22819
22821
|
deviceConnectionResponseSchema = external_exports.object({
|
|
22820
22822
|
name: external_exports.string(),
|
|
22821
22823
|
port: external_exports.number(),
|
|
@@ -23498,6 +23500,34 @@ until docker info >/dev/null 2>&1; do sleep 0.2; done
|
|
|
23498
23500
|
});
|
|
23499
23501
|
|
|
23500
23502
|
// ../shared/src/format.ts
|
|
23503
|
+
function relativeParts(input2, now = Date.now()) {
|
|
23504
|
+
const then = new Date(input2).getTime();
|
|
23505
|
+
if (Number.isNaN(then)) return null;
|
|
23506
|
+
const seconds = Math.max(0, Math.floor((now - then) / 1e3));
|
|
23507
|
+
const minutes = Math.floor(seconds / 60);
|
|
23508
|
+
const hours = Math.floor(minutes / 60);
|
|
23509
|
+
const days = Math.floor(hours / 24);
|
|
23510
|
+
const months = Math.floor(days / 30);
|
|
23511
|
+
return { then, seconds, minutes, hours, days, months, years: Math.floor(months / 12) };
|
|
23512
|
+
}
|
|
23513
|
+
function compactTimeAgo(input2, options) {
|
|
23514
|
+
const p = relativeParts(input2, options?.now);
|
|
23515
|
+
if (!p) return "";
|
|
23516
|
+
if (p.seconds < 60) return options?.seconds === false ? "now" : `${p.seconds}s`;
|
|
23517
|
+
if (p.minutes < 60) return `${p.minutes}m`;
|
|
23518
|
+
if (p.hours < 24) return `${p.hours}h`;
|
|
23519
|
+
if (p.days < 30) return `${p.days}d`;
|
|
23520
|
+
if (p.months < 12) return `${p.months}mo`;
|
|
23521
|
+
return `${p.years}y`;
|
|
23522
|
+
}
|
|
23523
|
+
function formatCompactRelativeTime(input2, now = Date.now()) {
|
|
23524
|
+
const then = new Date(input2).getTime();
|
|
23525
|
+
if (Number.isNaN(then)) return "";
|
|
23526
|
+
if (Math.abs(then - now) < 6e4) return "just now";
|
|
23527
|
+
const future = then > now;
|
|
23528
|
+
const compact = compactTimeAgo(future ? now - (then - now) : then, { now });
|
|
23529
|
+
return future ? `in ${compact}` : `${compact} ago`;
|
|
23530
|
+
}
|
|
23501
23531
|
var init_format = __esm({
|
|
23502
23532
|
"../shared/src/format.ts"() {
|
|
23503
23533
|
"use strict";
|
|
@@ -37492,7 +37522,7 @@ var CLI_VERSION;
|
|
|
37492
37522
|
var init_cli_version = __esm({
|
|
37493
37523
|
"../shared/src/cli-version.ts"() {
|
|
37494
37524
|
"use strict";
|
|
37495
|
-
CLI_VERSION = "0.3.
|
|
37525
|
+
CLI_VERSION = "0.3.347";
|
|
37496
37526
|
}
|
|
37497
37527
|
});
|
|
37498
37528
|
|
|
@@ -50703,7 +50733,11 @@ function maskValue(value) {
|
|
|
50703
50733
|
async function resolveEnvironmentId(input2) {
|
|
50704
50734
|
if (input2 === "global") return "global";
|
|
50705
50735
|
if (UUID_RE.test(input2)) return input2;
|
|
50706
|
-
const response = await orgAuthenticatedFetch("/v1/environments");
|
|
50736
|
+
const response = await orgAuthenticatedFetch("/v1/environments?scope=all");
|
|
50737
|
+
const named = response.environments.filter((environment2) => environment2.name === input2);
|
|
50738
|
+
if (named.length > 1) {
|
|
50739
|
+
throw new Error(`Both a team and a personal environment are named ${input2}. Use an ID: ${named.map((e) => `${e.id}${e.user_id ? " (personal)" : ""}`).join(", ")}`);
|
|
50740
|
+
}
|
|
50707
50741
|
const resolved = resolveByNameOrId(input2, response.environments);
|
|
50708
50742
|
if (!resolved) {
|
|
50709
50743
|
throw new Error(`Environment not found: ${input2}. Available: ${response.environments.map((e) => e.name).join(", ") || "(none)"}`);
|
|
@@ -50711,7 +50745,7 @@ async function resolveEnvironmentId(input2) {
|
|
|
50711
50745
|
return resolved.id;
|
|
50712
50746
|
}
|
|
50713
50747
|
function printEnvironment(env) {
|
|
50714
|
-
console.log(import_chalk20.default.white(` ${env.name}`));
|
|
50748
|
+
console.log(import_chalk20.default.white(` ${env.name}${env.user_id ? import_chalk20.default.gray(" (personal)") : ""}`));
|
|
50715
50749
|
console.log(import_chalk20.default.gray(` ID: ${env.id}`));
|
|
50716
50750
|
if (env.description) {
|
|
50717
50751
|
console.log(import_chalk20.default.gray(` Description: ${env.description}`));
|
|
@@ -50728,7 +50762,7 @@ function printEnvironment(env) {
|
|
|
50728
50762
|
}
|
|
50729
50763
|
async function environmentListCommand() {
|
|
50730
50764
|
ensureOrgApiAuthenticated();
|
|
50731
|
-
const response = await orgAuthenticatedFetch("/v1/environments");
|
|
50765
|
+
const response = await orgAuthenticatedFetch("/v1/environments?scope=all");
|
|
50732
50766
|
output2(response, ({ environments }) => {
|
|
50733
50767
|
if (environments.length === 0) {
|
|
50734
50768
|
console.log(import_chalk20.default.yellow("\nNo environments found.\n"));
|
|
@@ -51277,8 +51311,15 @@ async function envDevicesListCommand(env) {
|
|
|
51277
51311
|
`/v1/environments/${await resolveEnvironmentId(env)}/devices`
|
|
51278
51312
|
);
|
|
51279
51313
|
output2(response, ({ environment_devices }) => {
|
|
51314
|
+
if (environment_devices.length === 0) {
|
|
51315
|
+
console.log(import_chalk20.default.yellow(`
|
|
51316
|
+
No devices. Add one with: replicas env devices add ${env} <name> --user <user>
|
|
51317
|
+
`));
|
|
51318
|
+
return;
|
|
51319
|
+
}
|
|
51280
51320
|
for (const device of environment_devices) {
|
|
51281
|
-
|
|
51321
|
+
const status = isDeviceOnline(device.last_seen_at) ? import_chalk20.default.green("online") : import_chalk20.default.yellow(device.last_seen_at ? `offline, last seen ${formatCompactRelativeTime(device.last_seen_at)}` : "offline");
|
|
51322
|
+
console.log(`${device.id} ${device.name} ${device.host === null ? `${device.username}, connects from the device ${status}` : `${device.username}@${device.host}:${device.port}`}`);
|
|
51282
51323
|
}
|
|
51283
51324
|
});
|
|
51284
51325
|
}
|
|
@@ -51297,6 +51338,26 @@ async function envDevicesAddCommand(env, name, options) {
|
|
|
51297
51338
|
}
|
|
51298
51339
|
});
|
|
51299
51340
|
}
|
|
51341
|
+
async function envDevicesEditCommand(env, nameOrId, options) {
|
|
51342
|
+
const body = { name: options.name, host: options.host, username: options.user, port: options.port, screen_password: options.screenPassword };
|
|
51343
|
+
if (Object.values(body).every((value) => value === void 0)) {
|
|
51344
|
+
throw new Error("No changes specified. Pass --name, --host, --user, --port, or --screen-password.");
|
|
51345
|
+
}
|
|
51346
|
+
const id = await resolveEnvironmentId(env);
|
|
51347
|
+
const { environment_devices } = await orgAuthenticatedFetch(`/v1/environments/${id}/devices`);
|
|
51348
|
+
const device = resolveByNameOrId(nameOrId, environment_devices);
|
|
51349
|
+
if (!device) throw new Error(`Device not found: ${nameOrId}`);
|
|
51350
|
+
const response = await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}`, { method: "PATCH", body });
|
|
51351
|
+
const connect2 = device.host !== null && response.environment_device.host === null ? await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}/connect-token`) : void 0;
|
|
51352
|
+
output2({ ...response, connect_token: connect2?.token }, ({ environment_device, connect_token }) => {
|
|
51353
|
+
console.log(import_chalk20.default.green(`Updated device ${environment_device.name}. Workspaces started from now on get the change.`));
|
|
51354
|
+
if (connect_token) {
|
|
51355
|
+
console.log(import_chalk20.default.green("It now connects from the device. Keep this running on it, and paste this token when it asks:"));
|
|
51356
|
+
console.log(DEVICE_CONNECT_COMMAND);
|
|
51357
|
+
console.log(connect_token);
|
|
51358
|
+
}
|
|
51359
|
+
});
|
|
51360
|
+
}
|
|
51300
51361
|
async function envDevicesRemoveCommand(env, nameOrId) {
|
|
51301
51362
|
const id = await resolveEnvironmentId(env);
|
|
51302
51363
|
const { environment_devices } = await orgAuthenticatedFetch(`/v1/environments/${id}/devices`);
|
|
@@ -51524,7 +51585,7 @@ Replica: ${replica.name}
|
|
|
51524
51585
|
}
|
|
51525
51586
|
async function replicaCreateCommand(name, options) {
|
|
51526
51587
|
ensureOrgApiAuthenticated();
|
|
51527
|
-
const envResponse = await orgAuthenticatedFetch("/v1/environments");
|
|
51588
|
+
const envResponse = await orgAuthenticatedFetch("/v1/environments?scope=all");
|
|
51528
51589
|
const environments = envResponse.environments;
|
|
51529
51590
|
if (environments.length === 0) {
|
|
51530
51591
|
throw new Error("No environments found. Please create an environment first.");
|
|
@@ -51561,7 +51622,7 @@ async function replicaCreateCommand(name, options) {
|
|
|
51561
51622
|
name: "environment",
|
|
51562
51623
|
message: "Select environment:",
|
|
51563
51624
|
choices: environments.map((env) => ({
|
|
51564
|
-
title: env.name,
|
|
51625
|
+
title: env.user_id ? `${env.name} (personal)` : env.name,
|
|
51565
51626
|
value: env.id,
|
|
51566
51627
|
description: `${env.repository_ids?.length ?? 0} repositories`
|
|
51567
51628
|
}))
|
|
@@ -54604,7 +54665,7 @@ function registerEnvironmentHookCommands(parent, config3) {
|
|
|
54604
54665
|
}
|
|
54605
54666
|
hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
|
|
54606
54667
|
}
|
|
54607
|
-
var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr2, canvas, credentials, automation, repos, plugins, skills, media, environment, envVars, envFiles, envSkills, envMcps, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
|
|
54668
|
+
var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr2, canvas, credentials, automation, repos, plugins, skills, media, environment, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
|
|
54608
54669
|
var init_src2 = __esm({
|
|
54609
54670
|
"src/index.ts"() {
|
|
54610
54671
|
"use strict";
|
|
@@ -54647,6 +54708,7 @@ var init_src2 = __esm({
|
|
|
54647
54708
|
init_organization2();
|
|
54648
54709
|
init_output();
|
|
54649
54710
|
init_visuals();
|
|
54711
|
+
init_port();
|
|
54650
54712
|
init_src();
|
|
54651
54713
|
collect = (value, previous) => [...previous, value];
|
|
54652
54714
|
program = new import_commander.Command();
|
|
@@ -54837,13 +54899,17 @@ var init_src2 = __esm({
|
|
|
54837
54899
|
envMcps.command("list <env>").description("List MCP servers").action(run(envMcpsListCommand));
|
|
54838
54900
|
envMcps.command("add <env> <name>").description("Add a remote (--url) or stdio (--command) MCP server").option("-u, --url <url>", "Remote server URL").addOption(new import_commander.Option("--transport <transport>", "Remote transport").choices(["http", "sse"])).option("-H, --header <key=value>", "HTTP header (repeatable)", collect, []).option("-c, --command <command>", "Executable for a stdio server").option("--arg <arg>", "Argument for the stdio command (repeatable)", collect, []).option("--env <key=value>", "Environment variable for the stdio command (repeatable)", collect, []).action(run(envMcpsAddCommand));
|
|
54839
54901
|
envMcps.command("remove <env> <name-or-id>").description("Remove an MCP server").action(run(envMcpsRemoveCommand));
|
|
54902
|
+
parsePortOption = (value) => {
|
|
54903
|
+
try {
|
|
54904
|
+
return parsePort(value);
|
|
54905
|
+
} catch (error62) {
|
|
54906
|
+
throw new import_commander.InvalidArgumentError(String(error62 instanceof Error ? error62.message : error62));
|
|
54907
|
+
}
|
|
54908
|
+
};
|
|
54840
54909
|
envDevices = environment.command("devices").description("Computers the agent reaches over SSH, like a Mac mini or your own laptop");
|
|
54841
54910
|
envDevices.command("list <env>").description("List devices").action(run(envDevicesListCommand));
|
|
54842
|
-
envDevices.command("add <env> <name>").description("Add a device and print the command that allows its key on the device").option("--host <host>", "Hostname or IP, such as its Tailscale name. Leave it out to connect from the device instead").requiredOption("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port (default 22)", (
|
|
54843
|
-
|
|
54844
|
-
if (!Number.isInteger(port)) throw new import_commander.InvalidArgumentError("must be a whole number");
|
|
54845
|
-
return port;
|
|
54846
|
-
}).option("--screen-password <password>", "Screen Sharing password, so the agent can see and control the screen").action(run(envDevicesAddCommand));
|
|
54911
|
+
envDevices.command("add <env> <name>").description("Add a device and print the command that allows its key on the device").option("--host <host>", "Hostname or IP, such as its Tailscale name. Leave it out to connect from the device instead").requiredOption("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port (default 22)", parsePortOption).option("--screen-password <password>", "Screen Sharing password, so the agent can see and control the screen").action(run(envDevicesAddCommand));
|
|
54912
|
+
envDevices.command("edit <env> <name-or-id>").description("Change a device without replacing its key or connect token").option("--name <name>", "New name").option("--host <host>", 'New hostname or IP, or "" to connect from the device instead').option("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port", parsePortOption).option("--screen-password <password>", 'Screen Sharing password, or "" to remove it').action(run(envDevicesEditCommand));
|
|
54847
54913
|
envDevices.command("remove <env> <name-or-id>").description("Remove a device and delete its key").action(run(envDevicesRemoveCommand));
|
|
54848
54914
|
envDevices.command("reset <env> <name-or-id>").description("Replace the connect token of a device that connects from itself and forget its SSH identity, for a leaked token or a reinstalled device").action(run(envDevicesResetCommand));
|
|
54849
54915
|
program.command("device").description("Run on one of your computers so Replicas workspaces can reach it").command("connect").description("Keep this computer reachable from the workspaces that have it, without opening ports or a tailnet. Asks for the token from the device's settings, or reads REPLICAS_DEVICE_TOKEN").action(run(deviceConnectCommand));
|