replicas-cli 0.2.419 → 0.2.421
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.mjs +877 -685
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5543,8 +5543,8 @@ var require_cst_visit = __commonJS({
|
|
|
5543
5543
|
visit.REMOVE = REMOVE;
|
|
5544
5544
|
visit.itemAtPath = (cst, path6) => {
|
|
5545
5545
|
let item = cst;
|
|
5546
|
-
for (const [
|
|
5547
|
-
const tok = item?.[
|
|
5546
|
+
for (const [field2, index] of path6) {
|
|
5547
|
+
const tok = item?.[field2];
|
|
5548
5548
|
if (tok && "items" in tok) {
|
|
5549
5549
|
item = tok.items[index];
|
|
5550
5550
|
} else
|
|
@@ -5554,8 +5554,8 @@ var require_cst_visit = __commonJS({
|
|
|
5554
5554
|
};
|
|
5555
5555
|
visit.parentCollection = (cst, path6) => {
|
|
5556
5556
|
const parent = visit.itemAtPath(cst, path6.slice(0, -1));
|
|
5557
|
-
const
|
|
5558
|
-
const coll = parent?.[
|
|
5557
|
+
const field2 = path6[path6.length - 1][0];
|
|
5558
|
+
const coll = parent?.[field2];
|
|
5559
5559
|
if (coll && "items" in coll)
|
|
5560
5560
|
return coll;
|
|
5561
5561
|
throw new Error("Parent collection not found");
|
|
@@ -5564,11 +5564,11 @@ var require_cst_visit = __commonJS({
|
|
|
5564
5564
|
let ctrl = visitor(item, path6);
|
|
5565
5565
|
if (typeof ctrl === "symbol")
|
|
5566
5566
|
return ctrl;
|
|
5567
|
-
for (const
|
|
5568
|
-
const token = item[
|
|
5567
|
+
for (const field2 of ["key", "value"]) {
|
|
5568
|
+
const token = item[field2];
|
|
5569
5569
|
if (token && "items" in token) {
|
|
5570
5570
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5571
|
-
const ci = _visit(Object.freeze(path6.concat([[
|
|
5571
|
+
const ci = _visit(Object.freeze(path6.concat([[field2, i]])), token.items[i], visitor);
|
|
5572
5572
|
if (typeof ci === "number")
|
|
5573
5573
|
i = ci - 1;
|
|
5574
5574
|
else if (ci === BREAK)
|
|
@@ -5578,7 +5578,7 @@ var require_cst_visit = __commonJS({
|
|
|
5578
5578
|
i -= 1;
|
|
5579
5579
|
}
|
|
5580
5580
|
}
|
|
5581
|
-
if (typeof ctrl === "function" &&
|
|
5581
|
+
if (typeof ctrl === "function" && field2 === "key")
|
|
5582
5582
|
ctrl = ctrl(item, path6);
|
|
5583
5583
|
}
|
|
5584
5584
|
}
|
|
@@ -7336,13 +7336,13 @@ var require_dist = __commonJS({
|
|
|
7336
7336
|
// src/index.ts
|
|
7337
7337
|
import "dotenv/config";
|
|
7338
7338
|
import { Command, InvalidArgumentError } from "commander";
|
|
7339
|
-
import
|
|
7339
|
+
import chalk24 from "chalk";
|
|
7340
7340
|
|
|
7341
7341
|
// src/commands/login.ts
|
|
7342
7342
|
import http from "http";
|
|
7343
7343
|
import { URL as URL2 } from "url";
|
|
7344
|
-
import
|
|
7345
|
-
import
|
|
7344
|
+
import open2 from "open";
|
|
7345
|
+
import chalk2 from "chalk";
|
|
7346
7346
|
|
|
7347
7347
|
// src/lib/config.ts
|
|
7348
7348
|
import fs from "fs";
|
|
@@ -7404,6 +7404,14 @@ function setOrganizationId(organizationId) {
|
|
|
7404
7404
|
config3.organization_id = organizationId;
|
|
7405
7405
|
writeConfig(config3);
|
|
7406
7406
|
}
|
|
7407
|
+
function clearOrganizationId() {
|
|
7408
|
+
const config3 = readConfig();
|
|
7409
|
+
if (!config3) {
|
|
7410
|
+
return;
|
|
7411
|
+
}
|
|
7412
|
+
delete config3.organization_id;
|
|
7413
|
+
writeConfig(config3);
|
|
7414
|
+
}
|
|
7407
7415
|
function getOrganizationId() {
|
|
7408
7416
|
const config3 = readConfig();
|
|
7409
7417
|
return config3?.organization_id || null;
|
|
@@ -7448,6 +7456,11 @@ function readAgentConfig() {
|
|
|
7448
7456
|
}
|
|
7449
7457
|
}
|
|
7450
7458
|
|
|
7459
|
+
// src/lib/oauth-flow-ui.ts
|
|
7460
|
+
import chalk from "chalk";
|
|
7461
|
+
import open from "open";
|
|
7462
|
+
import prompts2 from "prompts";
|
|
7463
|
+
|
|
7451
7464
|
// src/lib/auth.ts
|
|
7452
7465
|
import { isAuthError, isAuthRetryableFetchError } from "@supabase/supabase-js";
|
|
7453
7466
|
|
|
@@ -7535,6 +7548,9 @@ async function getCurrentUser() {
|
|
|
7535
7548
|
};
|
|
7536
7549
|
}
|
|
7537
7550
|
|
|
7551
|
+
// src/lib/organization.ts
|
|
7552
|
+
import prompts from "prompts";
|
|
7553
|
+
|
|
7538
7554
|
// ../shared/src/type-guards.ts
|
|
7539
7555
|
function isRecord(value) {
|
|
7540
7556
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -10759,10 +10775,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
10759
10775
|
const shape = def.shape;
|
|
10760
10776
|
const propValues = {};
|
|
10761
10777
|
for (const key in shape) {
|
|
10762
|
-
const
|
|
10763
|
-
if (
|
|
10778
|
+
const field2 = shape[key]._zod;
|
|
10779
|
+
if (field2.values) {
|
|
10764
10780
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
10765
|
-
for (const v of
|
|
10781
|
+
for (const v of field2.values)
|
|
10766
10782
|
propValues[key].add(v);
|
|
10767
10783
|
}
|
|
10768
10784
|
}
|
|
@@ -22433,9 +22449,7 @@ function classifyCanvasFilename(filename) {
|
|
|
22433
22449
|
}
|
|
22434
22450
|
|
|
22435
22451
|
// ../shared/src/pricing.ts
|
|
22436
|
-
var INTEGRATION_SOURCES = ["slack", "linear", "github", "gitlab"];
|
|
22437
22452
|
var AUTOMATED_SOURCES = ["api", "automation"];
|
|
22438
|
-
var INTEGRATION_SOURCES_SQL = INTEGRATION_SOURCES.map((s) => `'${s}'`).join(", ");
|
|
22439
22453
|
var AUTOMATED_SOURCES_SQL = AUTOMATED_SOURCES.map((s) => `'${s}'`).join(", ");
|
|
22440
22454
|
var PLANS = {
|
|
22441
22455
|
trial: {
|
|
@@ -24478,7 +24492,7 @@ function formatTurnElapsed(ms) {
|
|
|
24478
24492
|
}
|
|
24479
24493
|
|
|
24480
24494
|
// ../shared/src/cli-version.ts
|
|
24481
|
-
var CLI_VERSION = "0.2.
|
|
24495
|
+
var CLI_VERSION = "0.2.421";
|
|
24482
24496
|
|
|
24483
24497
|
// ../shared/src/version.ts
|
|
24484
24498
|
function compareVersions(v1, v2) {
|
|
@@ -27086,6 +27100,9 @@ async function fetchOrganizations() {
|
|
|
27086
27100
|
);
|
|
27087
27101
|
return response.organizations;
|
|
27088
27102
|
}
|
|
27103
|
+
async function fetchActiveRole() {
|
|
27104
|
+
return orgAuthenticatedFetch("/v1/organization/membership").then((response) => response.role).catch(() => null);
|
|
27105
|
+
}
|
|
27089
27106
|
async function setActiveOrganization(organizationId) {
|
|
27090
27107
|
const organizations = await fetchOrganizations();
|
|
27091
27108
|
const organization = organizations.find((org2) => org2.id === organizationId);
|
|
@@ -27094,14 +27111,176 @@ async function setActiveOrganization(organizationId) {
|
|
|
27094
27111
|
}
|
|
27095
27112
|
setOrganizationId(organizationId);
|
|
27096
27113
|
}
|
|
27097
|
-
async function
|
|
27114
|
+
async function findActiveOrganization() {
|
|
27098
27115
|
const organizations = await fetchOrganizations();
|
|
27116
|
+
const currentId = getOrganizationId();
|
|
27117
|
+
return { organizations, organization: organizations.find((org2) => org2.id === currentId) ?? null };
|
|
27118
|
+
}
|
|
27119
|
+
async function promptForOrganization(organizations, currentId) {
|
|
27120
|
+
const { organizationId } = await prompts({
|
|
27121
|
+
type: "select",
|
|
27122
|
+
name: "organizationId",
|
|
27123
|
+
message: " Select an organization",
|
|
27124
|
+
choices: organizations.map((org2) => ({
|
|
27125
|
+
title: `${org2.name}${org2.id === currentId ? " (current)" : ""}`,
|
|
27126
|
+
value: org2.id
|
|
27127
|
+
})),
|
|
27128
|
+
initial: Math.max(0, organizations.findIndex((org2) => org2.id === currentId))
|
|
27129
|
+
});
|
|
27130
|
+
return organizations.find((org2) => org2.id === organizationId) ?? null;
|
|
27131
|
+
}
|
|
27132
|
+
async function ensureOrganization(options = {}) {
|
|
27133
|
+
const { organizations, organization } = await findActiveOrganization();
|
|
27099
27134
|
if (organizations.length === 0) {
|
|
27100
27135
|
throw new Error("You are not a member of any organization. Please contact support.");
|
|
27101
27136
|
}
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27137
|
+
if (organization) {
|
|
27138
|
+
return { organization, total: organizations.length, role: await fetchActiveRole() };
|
|
27139
|
+
}
|
|
27140
|
+
const canAsk = options.interactive === true && organizations.length > 1 && !!process.stdin.isTTY;
|
|
27141
|
+
if (canAsk) {
|
|
27142
|
+
const chosen = await promptForOrganization(organizations, null);
|
|
27143
|
+
if (!chosen) {
|
|
27144
|
+
clearOrganizationId();
|
|
27145
|
+
return { organization: null, total: organizations.length, role: null };
|
|
27146
|
+
}
|
|
27147
|
+
setOrganizationId(chosen.id);
|
|
27148
|
+
return { organization: chosen, total: organizations.length, role: await fetchActiveRole() };
|
|
27149
|
+
}
|
|
27150
|
+
const [newestOrganization] = organizations;
|
|
27151
|
+
setOrganizationId(newestOrganization.id);
|
|
27152
|
+
return {
|
|
27153
|
+
organization: newestOrganization,
|
|
27154
|
+
total: organizations.length,
|
|
27155
|
+
role: await fetchActiveRole()
|
|
27156
|
+
};
|
|
27157
|
+
}
|
|
27158
|
+
async function resolveActiveOrganization() {
|
|
27159
|
+
if (isAgentMode()) {
|
|
27160
|
+
return { organization: null, total: 0, role: null };
|
|
27161
|
+
}
|
|
27162
|
+
try {
|
|
27163
|
+
const [active, role] = await Promise.all([findActiveOrganization(), fetchActiveRole()]);
|
|
27164
|
+
return { organization: active.organization, total: active.organizations.length, role };
|
|
27165
|
+
} catch {
|
|
27166
|
+
return { organization: null, total: 0, role: null };
|
|
27167
|
+
}
|
|
27168
|
+
}
|
|
27169
|
+
|
|
27170
|
+
// src/lib/oauth-flow-ui.ts
|
|
27171
|
+
var LABEL_WIDTH = 16;
|
|
27172
|
+
var brand = chalk.hex("#3eeba3");
|
|
27173
|
+
function field(label, value) {
|
|
27174
|
+
console.log(` ${chalk.gray(label.padEnd(LABEL_WIDTH))}${value}`);
|
|
27175
|
+
}
|
|
27176
|
+
function appliesTo(target) {
|
|
27177
|
+
return target.isUserScoped ? "Personal Settings" : "Organization Settings";
|
|
27178
|
+
}
|
|
27179
|
+
function hyperlink(url2) {
|
|
27180
|
+
return `\x1B]8;;${url2}\x07${url2}\x1B]8;;\x07`;
|
|
27181
|
+
}
|
|
27182
|
+
function renderIdentity(identity) {
|
|
27183
|
+
field(
|
|
27184
|
+
"User",
|
|
27185
|
+
chalk.bold(identity.account ?? "unknown") + (identity.role ? chalk.gray(` (${identity.role})`) : "")
|
|
27186
|
+
);
|
|
27187
|
+
if (identity.organizationName) {
|
|
27188
|
+
field("Organization", chalk.bold(identity.organizationName));
|
|
27189
|
+
}
|
|
27190
|
+
}
|
|
27191
|
+
function renderTargetFields(target) {
|
|
27192
|
+
renderIdentity({
|
|
27193
|
+
account: target.replicasAccount,
|
|
27194
|
+
role: target.role,
|
|
27195
|
+
organizationName: target.organization?.name
|
|
27196
|
+
});
|
|
27197
|
+
field("Applies to", chalk.yellow.bold(appliesTo(target)));
|
|
27198
|
+
}
|
|
27199
|
+
async function resolveAuthFlowTarget(identity) {
|
|
27200
|
+
if (isAgentMode()) {
|
|
27201
|
+
return {
|
|
27202
|
+
...identity,
|
|
27203
|
+
replicasAccount: null,
|
|
27204
|
+
organization: null,
|
|
27205
|
+
role: null
|
|
27206
|
+
};
|
|
27207
|
+
}
|
|
27208
|
+
const [replicasAccount, active] = await Promise.all([
|
|
27209
|
+
getCurrentUser().then((user) => user.email).catch(() => null),
|
|
27210
|
+
resolveActiveOrganization()
|
|
27211
|
+
]);
|
|
27212
|
+
return {
|
|
27213
|
+
...identity,
|
|
27214
|
+
replicasAccount,
|
|
27215
|
+
organization: active.organization,
|
|
27216
|
+
role: active.role
|
|
27217
|
+
};
|
|
27218
|
+
}
|
|
27219
|
+
async function verifyAuthFlowTarget(target, assumeYes) {
|
|
27220
|
+
console.log(brand.bold(`
|
|
27221
|
+
Connect ${target.credentialLabel} \xB7 ${target.connectorLabel}
|
|
27222
|
+
`));
|
|
27223
|
+
renderTargetFields(target);
|
|
27224
|
+
if (!target.isUserScoped) {
|
|
27225
|
+
console.log(chalk.gray("\n Use --user to apply this to your personal account instead."));
|
|
27226
|
+
}
|
|
27227
|
+
console.log();
|
|
27228
|
+
if (assumeYes) {
|
|
27229
|
+
console.log(chalk.gray(" Confirmed by --yes."));
|
|
27230
|
+
} else {
|
|
27231
|
+
if (!process.stdin.isTTY) {
|
|
27232
|
+
throw new Error(
|
|
27233
|
+
"Cannot confirm the destination without a terminal. Re-run with --yes to accept the values above."
|
|
27234
|
+
);
|
|
27235
|
+
}
|
|
27236
|
+
const { confirmed } = await prompts2({
|
|
27237
|
+
type: "confirm",
|
|
27238
|
+
name: "confirmed",
|
|
27239
|
+
message: " Save credentials here?",
|
|
27240
|
+
initial: false
|
|
27241
|
+
});
|
|
27242
|
+
if (!confirmed) {
|
|
27243
|
+
console.log(chalk.yellow("\n Cancelled. Nothing was saved."));
|
|
27244
|
+
if (!target.isUserScoped) {
|
|
27245
|
+
console.log(
|
|
27246
|
+
chalk.gray(" To set this for your personal account instead, use the --user flag.\n")
|
|
27247
|
+
);
|
|
27248
|
+
}
|
|
27249
|
+
return false;
|
|
27250
|
+
}
|
|
27251
|
+
}
|
|
27252
|
+
return true;
|
|
27253
|
+
}
|
|
27254
|
+
function renderAuthFlowStep(step, total, title) {
|
|
27255
|
+
console.log(chalk.bold(`
|
|
27256
|
+
${step}/${total} ${title}`));
|
|
27257
|
+
}
|
|
27258
|
+
function renderAuthFlowDetail(text) {
|
|
27259
|
+
console.log(chalk.gray(` ${text}`));
|
|
27260
|
+
}
|
|
27261
|
+
function renderAuthFlowSuccess(providerLabel, summary, target) {
|
|
27262
|
+
console.log(brand.bold(`
|
|
27263
|
+
\u2713 ${target.credentialLabel} connected
|
|
27264
|
+
`));
|
|
27265
|
+
renderTargetFields(target);
|
|
27266
|
+
if (summary.email) {
|
|
27267
|
+
field(
|
|
27268
|
+
`${providerLabel} account`,
|
|
27269
|
+
chalk.bold(summary.email) + (summary.planType ? chalk.gray(` \xB7 ${summary.planType}`) : "")
|
|
27270
|
+
);
|
|
27271
|
+
}
|
|
27272
|
+
console.log();
|
|
27273
|
+
}
|
|
27274
|
+
async function openForApproval(host, authUrl) {
|
|
27275
|
+
let opened = true;
|
|
27276
|
+
try {
|
|
27277
|
+
await open(authUrl);
|
|
27278
|
+
} catch {
|
|
27279
|
+
opened = false;
|
|
27280
|
+
}
|
|
27281
|
+
renderAuthFlowDetail(opened ? `Opened ${host}` : `Could not open ${host} automatically`);
|
|
27282
|
+
renderAuthFlowDetail(opened ? "If it didn't open, visit:" : "Visit:");
|
|
27283
|
+
console.log(` ${chalk.gray.underline(hyperlink(authUrl))}`);
|
|
27105
27284
|
}
|
|
27106
27285
|
|
|
27107
27286
|
// src/commands/login.ts
|
|
@@ -27229,21 +27408,31 @@ async function loginCommand() {
|
|
|
27229
27408
|
try {
|
|
27230
27409
|
writeConfig(config3);
|
|
27231
27410
|
const user = await getCurrentUser();
|
|
27232
|
-
try {
|
|
27233
|
-
const orgId = await ensureOrganization();
|
|
27234
|
-
console.log(chalk.gray(` Organization: ${orgId}`));
|
|
27235
|
-
} catch (orgError) {
|
|
27236
|
-
console.log(chalk.yellow(" Warning: Could not fetch organizations"));
|
|
27237
|
-
console.log(chalk.gray(" You can set your organization later with: replicas org switch"));
|
|
27238
|
-
}
|
|
27239
27411
|
const successUrl = `${WEB_APP_URL}/cli-login/success?email=${encodeURIComponent(user.email)}`;
|
|
27240
27412
|
lastRedirectUrl = successUrl;
|
|
27241
27413
|
lastMessage = `Successfully logged in as ${user.email}. You can close this tab.`;
|
|
27242
27414
|
respondWithRedirect(res);
|
|
27243
27415
|
flushPendingResponses();
|
|
27244
|
-
|
|
27245
|
-
console.log(
|
|
27246
|
-
|
|
27416
|
+
const active = await ensureOrganization({ interactive: true }).catch(() => null);
|
|
27417
|
+
console.log(brand.bold("\n \u2713 Signed in to Replicas\n"));
|
|
27418
|
+
renderIdentity({
|
|
27419
|
+
account: user.email,
|
|
27420
|
+
role: active?.role ?? null,
|
|
27421
|
+
organizationName: active?.organization?.name
|
|
27422
|
+
});
|
|
27423
|
+
if (!active) {
|
|
27424
|
+
field("Organization", chalk2.yellow("could not be fetched"));
|
|
27425
|
+
console.log(chalk2.gray('\n Set one with "replicas org switch".'));
|
|
27426
|
+
} else if (!active.organization) {
|
|
27427
|
+
field("Organization", chalk2.yellow("none selected"));
|
|
27428
|
+
console.log(chalk2.gray('\n Choose one with "replicas org switch".'));
|
|
27429
|
+
} else if (active.total > 1) {
|
|
27430
|
+
console.log(
|
|
27431
|
+
chalk2.gray(`
|
|
27432
|
+
${active.total} organizations available. "replicas org switch" to change.`)
|
|
27433
|
+
);
|
|
27434
|
+
}
|
|
27435
|
+
console.log();
|
|
27247
27436
|
clearTimeout(authTimeout);
|
|
27248
27437
|
setImmediate(() => {
|
|
27249
27438
|
server.closeAllConnections?.();
|
|
@@ -27276,13 +27465,13 @@ async function loginCommand() {
|
|
|
27276
27465
|
}
|
|
27277
27466
|
const port = address.port;
|
|
27278
27467
|
const loginUrl = `${WEB_APP_URL}/cli-login?port=${port}&state=${state}`;
|
|
27279
|
-
console.log(
|
|
27280
|
-
console.log(
|
|
27468
|
+
console.log(brand("\nOpening browser for authentication..."));
|
|
27469
|
+
console.log(chalk2.gray(`If the browser doesn't open automatically, visit:
|
|
27281
27470
|
${loginUrl}
|
|
27282
27471
|
`));
|
|
27283
|
-
|
|
27284
|
-
console.log(
|
|
27285
|
-
console.log(
|
|
27472
|
+
open2(loginUrl).catch((error51) => {
|
|
27473
|
+
console.log(chalk2.yellow("Failed to open browser automatically."));
|
|
27474
|
+
console.log(chalk2.gray(`Please open this URL manually:
|
|
27286
27475
|
${loginUrl}
|
|
27287
27476
|
`));
|
|
27288
27477
|
});
|
|
@@ -27296,56 +27485,59 @@ ${loginUrl}
|
|
|
27296
27485
|
}
|
|
27297
27486
|
|
|
27298
27487
|
// src/commands/logout.ts
|
|
27299
|
-
import
|
|
27488
|
+
import chalk3 from "chalk";
|
|
27300
27489
|
function logoutCommand() {
|
|
27301
27490
|
if (!isAuthenticated()) {
|
|
27302
|
-
console.log(
|
|
27491
|
+
console.log(chalk3.yellow("You are not logged in."));
|
|
27303
27492
|
return;
|
|
27304
27493
|
}
|
|
27305
27494
|
deleteConfig();
|
|
27306
|
-
console.log(
|
|
27495
|
+
console.log(chalk3.green("\u2713 Successfully logged out!"));
|
|
27307
27496
|
}
|
|
27308
27497
|
|
|
27309
27498
|
// src/commands/whoami.ts
|
|
27310
|
-
import
|
|
27499
|
+
import chalk4 from "chalk";
|
|
27311
27500
|
async function whoamiCommand() {
|
|
27312
27501
|
if (isAgentMode()) {
|
|
27313
27502
|
const agent = readAgentConfig();
|
|
27314
27503
|
if (!agent) {
|
|
27315
|
-
console.log(
|
|
27504
|
+
console.log(chalk4.red("Agent mode config is incomplete."));
|
|
27316
27505
|
process.exit(1);
|
|
27317
27506
|
}
|
|
27318
|
-
console.log(
|
|
27319
|
-
|
|
27507
|
+
console.log(brand.bold("\n Workspace identity\n"));
|
|
27508
|
+
field("Workspace", chalk4.bold(agent.workspace_id));
|
|
27320
27509
|
if (agent.organization_id) {
|
|
27321
|
-
|
|
27510
|
+
field("Organization", chalk4.bold(agent.organization_id));
|
|
27322
27511
|
}
|
|
27323
27512
|
console.log();
|
|
27324
27513
|
return;
|
|
27325
27514
|
}
|
|
27326
27515
|
if (!isAuthenticated()) {
|
|
27327
|
-
console.log(
|
|
27328
|
-
console.log(
|
|
27516
|
+
console.log(chalk4.yellow("\n You are not signed in."));
|
|
27517
|
+
console.log(chalk4.gray(' Run "replicas login" to authenticate.\n'));
|
|
27329
27518
|
return;
|
|
27330
27519
|
}
|
|
27331
27520
|
try {
|
|
27332
|
-
const user = await getCurrentUser();
|
|
27333
|
-
console.log(
|
|
27334
|
-
|
|
27335
|
-
|
|
27336
|
-
|
|
27521
|
+
const [user, active] = await Promise.all([getCurrentUser(), resolveActiveOrganization()]);
|
|
27522
|
+
console.log(brand.bold("\n Replicas identity\n"));
|
|
27523
|
+
renderIdentity({
|
|
27524
|
+
account: user.email,
|
|
27525
|
+
role: active.role,
|
|
27526
|
+
organizationName: active.organization?.name
|
|
27527
|
+
});
|
|
27528
|
+
console.log();
|
|
27337
27529
|
} catch (error51) {
|
|
27338
|
-
console.error(
|
|
27530
|
+
console.error(chalk4.red("Failed to get user information."));
|
|
27339
27531
|
if (error51 instanceof Error) {
|
|
27340
|
-
console.error(
|
|
27532
|
+
console.error(chalk4.gray(error51.message));
|
|
27341
27533
|
}
|
|
27342
|
-
console.log(
|
|
27534
|
+
console.log(chalk4.gray('\n Try running "replicas login" again.\n'));
|
|
27343
27535
|
process.exit(1);
|
|
27344
27536
|
}
|
|
27345
27537
|
}
|
|
27346
27538
|
|
|
27347
27539
|
// src/commands/connect.ts
|
|
27348
|
-
import
|
|
27540
|
+
import chalk6 from "chalk";
|
|
27349
27541
|
|
|
27350
27542
|
// src/lib/ssh.ts
|
|
27351
27543
|
import { spawn } from "child_process";
|
|
@@ -27364,8 +27556,8 @@ async function connectSSH(token, host, proxyCommand) {
|
|
|
27364
27556
|
}
|
|
27365
27557
|
|
|
27366
27558
|
// src/lib/workspace-connection.ts
|
|
27367
|
-
import
|
|
27368
|
-
import
|
|
27559
|
+
import chalk5 from "chalk";
|
|
27560
|
+
import prompts3 from "prompts";
|
|
27369
27561
|
|
|
27370
27562
|
// src/lib/git.ts
|
|
27371
27563
|
import { execSync } from "child_process";
|
|
@@ -27413,7 +27605,7 @@ async function resolveWorkspaceRecord(workspaceName) {
|
|
|
27413
27605
|
}
|
|
27414
27606
|
const exactWorkspace = await fetchWorkspaceById(workspaceName);
|
|
27415
27607
|
if (exactWorkspace) return exactWorkspace;
|
|
27416
|
-
console.log(
|
|
27608
|
+
console.log(chalk5.blue(`
|
|
27417
27609
|
Searching for workspace: ${workspaceName}...`));
|
|
27418
27610
|
const response = await orgAuthenticatedFetch(
|
|
27419
27611
|
`/v1/workspaces?name=${encodeURIComponent(workspaceName)}`
|
|
@@ -27425,9 +27617,9 @@ Searching for workspace: ${workspaceName}...`));
|
|
|
27425
27617
|
if (response.workspaces.length === 1) {
|
|
27426
27618
|
selectedWorkspace = response.workspaces[0];
|
|
27427
27619
|
} else {
|
|
27428
|
-
console.log(
|
|
27620
|
+
console.log(chalk5.yellow(`
|
|
27429
27621
|
Found ${response.workspaces.length} workspaces matching "${workspaceName}":`));
|
|
27430
|
-
const selectResponse = await
|
|
27622
|
+
const selectResponse = await prompts3({
|
|
27431
27623
|
type: "select",
|
|
27432
27624
|
name: "workspaceId",
|
|
27433
27625
|
message: "Select a workspace:",
|
|
@@ -27446,9 +27638,9 @@ Found ${response.workspaces.length} workspaces matching "${workspaceName}":`));
|
|
|
27446
27638
|
}
|
|
27447
27639
|
selectedWorkspace = selected;
|
|
27448
27640
|
}
|
|
27449
|
-
console.log(
|
|
27641
|
+
console.log(chalk5.green(`
|
|
27450
27642
|
\u2713 Selected workspace: ${selectedWorkspace.name}`));
|
|
27451
|
-
console.log(
|
|
27643
|
+
console.log(chalk5.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
|
|
27452
27644
|
return selectedWorkspace;
|
|
27453
27645
|
}
|
|
27454
27646
|
async function prepareWorkspaceConnection(workspaceName) {
|
|
@@ -27458,12 +27650,12 @@ async function prepareWorkspaceConnection(workspaceName) {
|
|
|
27458
27650
|
`Workspace is currently ${selectedWorkspace.status}. Wake it using \`replicas interact\` (press w on a suspended workspace) or visit https://tryreplicas.com`
|
|
27459
27651
|
);
|
|
27460
27652
|
}
|
|
27461
|
-
console.log(
|
|
27653
|
+
console.log(chalk5.blue("\nRequesting SSH access token..."));
|
|
27462
27654
|
const tokenResponse = await orgAuthenticatedFetch(
|
|
27463
27655
|
`/v1/workspaces/${selectedWorkspace.id}/ssh-token`,
|
|
27464
27656
|
{ method: "POST" }
|
|
27465
27657
|
);
|
|
27466
|
-
console.log(
|
|
27658
|
+
console.log(chalk5.green("\u2713 SSH token received"));
|
|
27467
27659
|
let repoName = null;
|
|
27468
27660
|
if (isInsideGitRepo()) {
|
|
27469
27661
|
try {
|
|
@@ -27483,27 +27675,27 @@ async function prepareWorkspaceConnection(workspaceName) {
|
|
|
27483
27675
|
// src/commands/connect.ts
|
|
27484
27676
|
async function connectCommand(workspaceName) {
|
|
27485
27677
|
if (!isAuthenticated()) {
|
|
27486
|
-
console.log(
|
|
27678
|
+
console.log(chalk6.red('Not logged in. Please run "replicas login" first.'));
|
|
27487
27679
|
process.exit(1);
|
|
27488
27680
|
}
|
|
27489
27681
|
try {
|
|
27490
27682
|
const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
|
|
27491
|
-
console.log(
|
|
27683
|
+
console.log(chalk6.blue(`
|
|
27492
27684
|
Connecting to ${workspace.name}...`));
|
|
27493
27685
|
const sshCommand = `ssh ${sshToken}@${sshHost}`;
|
|
27494
|
-
console.log(
|
|
27495
|
-
console.log(
|
|
27686
|
+
console.log(chalk6.gray(`SSH command: ${sshCommand}`));
|
|
27687
|
+
console.log(chalk6.gray("\nPress Ctrl+D to disconnect.\n"));
|
|
27496
27688
|
await connectSSH(sshToken, sshHost, sshProxyCommand);
|
|
27497
|
-
console.log(
|
|
27689
|
+
console.log(chalk6.green("\n\u2713 Disconnected from workspace.\n"));
|
|
27498
27690
|
} catch (error51) {
|
|
27499
|
-
console.error(
|
|
27691
|
+
console.error(chalk6.red(`
|
|
27500
27692
|
Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27501
27693
|
process.exit(1);
|
|
27502
27694
|
}
|
|
27503
27695
|
}
|
|
27504
27696
|
|
|
27505
27697
|
// src/commands/code.ts
|
|
27506
|
-
import
|
|
27698
|
+
import chalk7 from "chalk";
|
|
27507
27699
|
import { spawn as spawn2 } from "child_process";
|
|
27508
27700
|
|
|
27509
27701
|
// src/lib/ssh-config.ts
|
|
@@ -27597,28 +27789,28 @@ function getWorkspaceHostAlias(workspaceName) {
|
|
|
27597
27789
|
// src/commands/code.ts
|
|
27598
27790
|
async function codeCommand(workspaceName) {
|
|
27599
27791
|
if (!isAuthenticated()) {
|
|
27600
|
-
console.log(
|
|
27792
|
+
console.log(chalk7.red('Not logged in. Please run "replicas login" first.'));
|
|
27601
27793
|
process.exit(1);
|
|
27602
27794
|
}
|
|
27603
27795
|
try {
|
|
27604
27796
|
const { workspace, sshToken, sshHost, sshProxyCommand, repoName } = await prepareWorkspaceConnection(workspaceName);
|
|
27605
27797
|
const hostAlias = getWorkspaceHostAlias(workspace.name);
|
|
27606
|
-
console.log(
|
|
27798
|
+
console.log(chalk7.blue("\nConfiguring SSH connection..."));
|
|
27607
27799
|
addOrUpdateSSHConfigEntry({
|
|
27608
27800
|
host: hostAlias,
|
|
27609
27801
|
hostname: sshHost,
|
|
27610
27802
|
user: sshToken,
|
|
27611
27803
|
proxyCommand: sshProxyCommand
|
|
27612
27804
|
});
|
|
27613
|
-
console.log(
|
|
27805
|
+
console.log(chalk7.green(`\u2713 SSH config entry created: ${hostAlias}`));
|
|
27614
27806
|
const paths = SANDBOX_PATHS;
|
|
27615
27807
|
const remotePath = repoName ? `${paths.WORKSPACES_DIR}/${repoName}` : paths.HOME_DIR;
|
|
27616
27808
|
const ideCommand = getIdeCommand();
|
|
27617
27809
|
const fullCommand = `${ideCommand} --remote ssh-remote+${hostAlias} ${remotePath}`;
|
|
27618
|
-
console.log(
|
|
27810
|
+
console.log(chalk7.blue(`
|
|
27619
27811
|
Opening ${ideCommand} for workspace ${workspace.name}...`));
|
|
27620
|
-
console.log(
|
|
27621
|
-
console.log(
|
|
27812
|
+
console.log(chalk7.gray(`Command: ${fullCommand}`));
|
|
27813
|
+
console.log(chalk7.yellow(`
|
|
27622
27814
|
Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
|
|
27623
27815
|
const ide = spawn2(ideCommand, [
|
|
27624
27816
|
"--remote",
|
|
@@ -27629,176 +27821,171 @@ Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
|
|
|
27629
27821
|
detached: false
|
|
27630
27822
|
});
|
|
27631
27823
|
ide.on("error", (error51) => {
|
|
27632
|
-
console.error(
|
|
27824
|
+
console.error(chalk7.red(`
|
|
27633
27825
|
Failed to launch ${ideCommand}: ${error51.message}`));
|
|
27634
|
-
console.log(
|
|
27826
|
+
console.log(chalk7.yellow(`
|
|
27635
27827
|
Make sure ${ideCommand} is installed and available in your PATH.`));
|
|
27636
|
-
console.log(
|
|
27828
|
+
console.log(chalk7.gray(`You can configure a different IDE with: replicas config set ide <command>`));
|
|
27637
27829
|
process.exit(1);
|
|
27638
27830
|
});
|
|
27639
27831
|
ide.on("close", (code) => {
|
|
27640
27832
|
if (code === 0) {
|
|
27641
|
-
console.log(
|
|
27833
|
+
console.log(chalk7.green(`
|
|
27642
27834
|
\u2713 ${ideCommand} closed successfully.
|
|
27643
27835
|
`));
|
|
27644
27836
|
}
|
|
27645
27837
|
});
|
|
27646
27838
|
} catch (error51) {
|
|
27647
|
-
console.error(
|
|
27839
|
+
console.error(chalk7.red(`
|
|
27648
27840
|
Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27649
27841
|
process.exit(1);
|
|
27650
27842
|
}
|
|
27651
27843
|
}
|
|
27652
27844
|
|
|
27653
27845
|
// src/commands/org.ts
|
|
27654
|
-
import
|
|
27655
|
-
import prompts2 from "prompts";
|
|
27846
|
+
import chalk8 from "chalk";
|
|
27656
27847
|
async function orgCommand() {
|
|
27657
27848
|
if (!isAuthenticated()) {
|
|
27658
|
-
console.log(
|
|
27849
|
+
console.log(chalk8.red('Not logged in. Please run "replicas login" first.'));
|
|
27659
27850
|
process.exit(1);
|
|
27660
27851
|
}
|
|
27661
27852
|
try {
|
|
27662
27853
|
const currentOrgId = getOrganizationId();
|
|
27663
27854
|
const organizations = await fetchOrganizations();
|
|
27664
27855
|
if (!currentOrgId) {
|
|
27665
|
-
console.log(
|
|
27666
|
-
console.log(
|
|
27856
|
+
console.log(chalk8.yellow("\n No organization selected."));
|
|
27857
|
+
console.log(chalk8.gray(' Run "replicas org switch" to select one.\n'));
|
|
27667
27858
|
return;
|
|
27668
27859
|
}
|
|
27669
27860
|
const currentOrg = organizations.find((org2) => org2.id === currentOrgId);
|
|
27670
27861
|
if (!currentOrg) {
|
|
27671
|
-
console.log(
|
|
27672
|
-
console.log(
|
|
27862
|
+
console.log(chalk8.yellow("\n The selected organization is no longer available to you."));
|
|
27863
|
+
console.log(chalk8.gray(' Run "replicas org switch" to select another.\n'));
|
|
27673
27864
|
return;
|
|
27674
27865
|
}
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
|
|
27678
|
-
|
|
27866
|
+
const [account, role] = await Promise.all([
|
|
27867
|
+
getCurrentUser().then((user) => user.email).catch(() => null),
|
|
27868
|
+
fetchActiveRole()
|
|
27869
|
+
]);
|
|
27870
|
+
console.log(brand.bold("\n Active organization\n"));
|
|
27871
|
+
renderIdentity({ account, role, organizationName: currentOrg.name });
|
|
27872
|
+
if (organizations.length > 1) {
|
|
27873
|
+
console.log(
|
|
27874
|
+
chalk8.gray(`
|
|
27875
|
+
${organizations.length} organizations available. "replicas org switch" to change.`)
|
|
27876
|
+
);
|
|
27877
|
+
}
|
|
27878
|
+
console.log();
|
|
27679
27879
|
} catch (error51) {
|
|
27680
|
-
console.error(
|
|
27880
|
+
console.error(chalk8.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27681
27881
|
process.exit(1);
|
|
27682
27882
|
}
|
|
27683
27883
|
}
|
|
27684
27884
|
async function orgSwitchCommand() {
|
|
27685
27885
|
if (!isAuthenticated()) {
|
|
27686
|
-
console.log(
|
|
27886
|
+
console.log(chalk8.red('Not logged in. Please run "replicas login" first.'));
|
|
27687
27887
|
process.exit(1);
|
|
27688
27888
|
}
|
|
27689
27889
|
try {
|
|
27690
27890
|
const organizations = await fetchOrganizations();
|
|
27691
27891
|
if (organizations.length === 0) {
|
|
27692
|
-
console.log(
|
|
27693
|
-
console.log(
|
|
27694
|
-
return;
|
|
27695
|
-
}
|
|
27696
|
-
if (organizations.length === 1) {
|
|
27697
|
-
await setActiveOrganization(organizations[0].id);
|
|
27698
|
-
console.log(chalk7.green(`
|
|
27699
|
-
\u2713 Organization set to: ${organizations[0].name}
|
|
27700
|
-
`));
|
|
27892
|
+
console.log(chalk8.yellow("\n You are not a member of any organization."));
|
|
27893
|
+
console.log(chalk8.gray(" Please contact support.\n"));
|
|
27701
27894
|
return;
|
|
27702
27895
|
}
|
|
27703
27896
|
const currentOrgId = getOrganizationId();
|
|
27704
|
-
|
|
27705
|
-
|
|
27706
|
-
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
|
|
27710
|
-
|
|
27711
|
-
|
|
27712
|
-
})),
|
|
27713
|
-
initial: organizations.findIndex((org2) => org2.id === currentOrgId)
|
|
27714
|
-
});
|
|
27715
|
-
if (!response.organizationId) {
|
|
27716
|
-
console.log(chalk7.yellow("\nCancelled."));
|
|
27717
|
-
return;
|
|
27897
|
+
let selectedId = organizations[0].id;
|
|
27898
|
+
if (organizations.length > 1) {
|
|
27899
|
+
const chosen = await promptForOrganization(organizations, currentOrgId);
|
|
27900
|
+
if (!chosen) {
|
|
27901
|
+
console.log(chalk8.yellow("\n Cancelled. The active organization is unchanged.\n"));
|
|
27902
|
+
return;
|
|
27903
|
+
}
|
|
27904
|
+
selectedId = chosen.id;
|
|
27718
27905
|
}
|
|
27719
|
-
await setActiveOrganization(
|
|
27720
|
-
const
|
|
27721
|
-
|
|
27722
|
-
|
|
27723
|
-
|
|
27906
|
+
await setActiveOrganization(selectedId);
|
|
27907
|
+
const selected = organizations.find((org2) => org2.id === selectedId);
|
|
27908
|
+
const [account, role] = await Promise.all([
|
|
27909
|
+
getCurrentUser().then((user) => user.email).catch(() => null),
|
|
27910
|
+
fetchActiveRole()
|
|
27911
|
+
]);
|
|
27912
|
+
console.log(brand.bold("\n \u2713 Active organization changed\n"));
|
|
27913
|
+
renderIdentity({ account, role, organizationName: selected?.name });
|
|
27914
|
+
console.log();
|
|
27724
27915
|
} catch (error51) {
|
|
27725
|
-
console.error(
|
|
27916
|
+
console.error(chalk8.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27726
27917
|
process.exit(1);
|
|
27727
27918
|
}
|
|
27728
27919
|
}
|
|
27729
27920
|
|
|
27730
27921
|
// src/commands/config.ts
|
|
27731
|
-
import
|
|
27922
|
+
import chalk9 from "chalk";
|
|
27732
27923
|
async function configGetCommand(key) {
|
|
27733
27924
|
if (!isAuthenticated()) {
|
|
27734
|
-
console.log(
|
|
27925
|
+
console.log(chalk9.red('Not logged in. Please run "replicas login" first.'));
|
|
27735
27926
|
process.exit(1);
|
|
27736
27927
|
}
|
|
27737
27928
|
try {
|
|
27738
27929
|
if (key === "ide") {
|
|
27739
27930
|
const ideCommand = getIdeCommand();
|
|
27740
|
-
console.log(
|
|
27931
|
+
console.log(chalk9.green(`
|
|
27741
27932
|
IDE command: ${ideCommand}
|
|
27742
27933
|
`));
|
|
27743
27934
|
} else {
|
|
27744
|
-
console.log(
|
|
27745
|
-
console.log(
|
|
27935
|
+
console.log(chalk9.red(`Unknown config key: ${key}`));
|
|
27936
|
+
console.log(chalk9.gray("Available keys: ide"));
|
|
27746
27937
|
process.exit(1);
|
|
27747
27938
|
}
|
|
27748
27939
|
} catch (error51) {
|
|
27749
|
-
console.error(
|
|
27940
|
+
console.error(chalk9.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27750
27941
|
process.exit(1);
|
|
27751
27942
|
}
|
|
27752
27943
|
}
|
|
27753
27944
|
async function configSetCommand(key, value) {
|
|
27754
27945
|
if (!isAuthenticated()) {
|
|
27755
|
-
console.log(
|
|
27946
|
+
console.log(chalk9.red('Not logged in. Please run "replicas login" first.'));
|
|
27756
27947
|
process.exit(1);
|
|
27757
27948
|
}
|
|
27758
27949
|
try {
|
|
27759
27950
|
if (key === "ide") {
|
|
27760
27951
|
setIdeCommand(value);
|
|
27761
|
-
console.log(
|
|
27952
|
+
console.log(chalk9.green(`
|
|
27762
27953
|
\u2713 IDE command set to: ${value}
|
|
27763
27954
|
`));
|
|
27764
27955
|
} else {
|
|
27765
|
-
console.log(
|
|
27766
|
-
console.log(
|
|
27956
|
+
console.log(chalk9.red(`Unknown config key: ${key}`));
|
|
27957
|
+
console.log(chalk9.gray("Available keys: ide"));
|
|
27767
27958
|
process.exit(1);
|
|
27768
27959
|
}
|
|
27769
27960
|
} catch (error51) {
|
|
27770
|
-
console.error(
|
|
27961
|
+
console.error(chalk9.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27771
27962
|
process.exit(1);
|
|
27772
27963
|
}
|
|
27773
27964
|
}
|
|
27774
27965
|
async function configListCommand() {
|
|
27775
27966
|
if (!isAuthenticated()) {
|
|
27776
|
-
console.log(
|
|
27967
|
+
console.log(chalk9.red('Not logged in. Please run "replicas login" first.'));
|
|
27777
27968
|
process.exit(1);
|
|
27778
27969
|
}
|
|
27779
27970
|
try {
|
|
27780
27971
|
const config3 = readConfig();
|
|
27781
27972
|
if (!config3) {
|
|
27782
|
-
console.log(
|
|
27973
|
+
console.log(chalk9.red("No config found. Please login first."));
|
|
27783
27974
|
process.exit(1);
|
|
27784
27975
|
}
|
|
27785
|
-
console.log(
|
|
27786
|
-
console.log(
|
|
27787
|
-
console.log(
|
|
27976
|
+
console.log(chalk9.green("\nCurrent configuration:"));
|
|
27977
|
+
console.log(chalk9.gray(` Organization ID: ${config3.organization_id || "(not set)"}`));
|
|
27978
|
+
console.log(chalk9.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
|
|
27788
27979
|
console.log();
|
|
27789
27980
|
} catch (error51) {
|
|
27790
|
-
console.error(
|
|
27981
|
+
console.error(chalk9.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
27791
27982
|
process.exit(1);
|
|
27792
27983
|
}
|
|
27793
27984
|
}
|
|
27794
27985
|
|
|
27795
|
-
// src/commands/codex-auth.ts
|
|
27796
|
-
import chalk10 from "chalk";
|
|
27797
|
-
|
|
27798
27986
|
// src/lib/codex-oauth.ts
|
|
27799
27987
|
import http2 from "http";
|
|
27800
27988
|
import { URL as URL3 } from "url";
|
|
27801
|
-
import open2 from "open";
|
|
27802
27989
|
|
|
27803
27990
|
// src/lib/pkce.ts
|
|
27804
27991
|
import { createHash, randomBytes } from "crypto";
|
|
@@ -27931,7 +28118,7 @@ function startCallbackServer(expectedState, codeVerifier) {
|
|
|
27931
28118
|
}
|
|
27932
28119
|
});
|
|
27933
28120
|
server.on("error", (err) => {
|
|
27934
|
-
if (err.code === "EADDRINUSE") {
|
|
28121
|
+
if ("code" in err && err.code === "EADDRINUSE") {
|
|
27935
28122
|
reject(new Error(`Port ${CALLBACK_PORT} is already in use. Please close any other OAuth flows and try again.`));
|
|
27936
28123
|
} else {
|
|
27937
28124
|
reject(err);
|
|
@@ -27940,104 +28127,124 @@ function startCallbackServer(expectedState, codeVerifier) {
|
|
|
27940
28127
|
server.listen(CALLBACK_PORT, "127.0.0.1");
|
|
27941
28128
|
});
|
|
27942
28129
|
}
|
|
27943
|
-
async function runCodexOAuthFlow() {
|
|
28130
|
+
async function runCodexOAuthFlow(totalSteps) {
|
|
27944
28131
|
const pkce = generatePkceCodes();
|
|
27945
28132
|
const state = generateState2();
|
|
27946
28133
|
const authUrl = buildAuthorizationUrl(pkce.codeChallenge, state);
|
|
27947
28134
|
const tokensPromise = startCallbackServer(state, pkce.codeVerifier);
|
|
27948
28135
|
await new Promise((resolve3) => setTimeout(resolve3, 500));
|
|
27949
|
-
|
|
27950
|
-
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
await open2(authUrl);
|
|
27954
|
-
} catch (openError) {
|
|
27955
|
-
console.warn("Failed to open browser automatically. Please open the URL manually.");
|
|
27956
|
-
}
|
|
27957
|
-
console.log("Waiting for authentication...");
|
|
27958
|
-
const tokens = await tokensPromise;
|
|
27959
|
-
console.log("\u2713 Successfully obtained Codex credentials");
|
|
27960
|
-
return tokens;
|
|
28136
|
+
renderAuthFlowStep(1, totalSteps, "Approve access in your browser");
|
|
28137
|
+
await openForApproval("auth.openai.com", authUrl);
|
|
28138
|
+
renderAuthFlowDetail("waiting for sign-in\u2026");
|
|
28139
|
+
return tokensPromise;
|
|
27961
28140
|
}
|
|
27962
28141
|
|
|
27963
28142
|
// src/lib/credential-upload.ts
|
|
27964
|
-
import
|
|
27965
|
-
|
|
27966
|
-
|
|
27967
|
-
\u2713 ${labels.providerLabel} authentication complete!`));
|
|
27968
|
-
if (response.email) {
|
|
27969
|
-
console.log(chalk9.gray(` Account: ${response.email}`));
|
|
27970
|
-
}
|
|
27971
|
-
if (response.planType) {
|
|
27972
|
-
console.log(chalk9.gray(` Plan: ${response.planType}`));
|
|
27973
|
-
}
|
|
27974
|
-
if (isUserScoped) {
|
|
27975
|
-
console.log(
|
|
27976
|
-
chalk9.gray(`
|
|
27977
|
-
Your personal ${labels.providerLabel} credentials have been saved.
|
|
27978
|
-
`)
|
|
27979
|
-
);
|
|
27980
|
-
} else {
|
|
27981
|
-
console.log(chalk9.gray(`
|
|
27982
|
-
You can now use ${labels.productLabel} in your workspaces.
|
|
27983
|
-
`));
|
|
27984
|
-
}
|
|
27985
|
-
}
|
|
27986
|
-
async function withAuthRecovery(operation) {
|
|
28143
|
+
import chalk10 from "chalk";
|
|
28144
|
+
var UPLOAD_STEPS = 1;
|
|
28145
|
+
async function withAuthRecovery(operation, assertStillApproved) {
|
|
27987
28146
|
try {
|
|
27988
|
-
return await operation();
|
|
28147
|
+
return { result: await operation(), reauthenticated: false };
|
|
27989
28148
|
} catch (error51) {
|
|
27990
28149
|
if (isAgentMode() || !isReplicasAuthError(error51)) {
|
|
27991
28150
|
throw error51;
|
|
27992
28151
|
}
|
|
27993
28152
|
const message = error51 instanceof NotAuthenticatedError ? "You're not signed in to Replicas. Signing in..." : "Your Replicas session expired. Re-authenticating...";
|
|
27994
|
-
console.log(
|
|
27995
|
-
${message}`));
|
|
28153
|
+
console.log(chalk10.yellow(`
|
|
28154
|
+
${message}`));
|
|
27996
28155
|
await loginCommand();
|
|
27997
|
-
|
|
27998
|
-
|
|
28156
|
+
await assertStillApproved();
|
|
28157
|
+
console.log(chalk10.gray(" Retrying credential upload..."));
|
|
28158
|
+
return { result: await operation(), reauthenticated: true };
|
|
27999
28159
|
}
|
|
28000
28160
|
}
|
|
28001
|
-
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
const
|
|
28006
|
-
|
|
28007
|
-
|
|
28161
|
+
function destinationWasKnown(target) {
|
|
28162
|
+
return target.replicasAccount !== null && (target.isUserScoped || target.organization !== null);
|
|
28163
|
+
}
|
|
28164
|
+
function assertDestinationUnchanged(approved, current) {
|
|
28165
|
+
const movedAccount = approved.replicasAccount !== null && current.replicasAccount !== approved.replicasAccount;
|
|
28166
|
+
const movedOrganization = approved.organization !== null && current.organization?.id !== approved.organization.id;
|
|
28167
|
+
if (!movedAccount && !movedOrganization) {
|
|
28168
|
+
return;
|
|
28169
|
+
}
|
|
28170
|
+
const from = movedAccount ? `${approved.replicasAccount} to ${current.replicasAccount ?? "an unknown account"}` : `${approved.organization?.name} to ${current.organization?.name ?? "an unknown organization"}`;
|
|
28171
|
+
throw new Error(
|
|
28172
|
+
`Signing in again moved the destination from ${from}, which you did not approve. Nothing was saved. Re-run the command to confirm the new destination.`
|
|
28173
|
+
);
|
|
28174
|
+
}
|
|
28175
|
+
async function runCredentialAuthFlow(options, flow) {
|
|
28176
|
+
const { providerLabel, credentialLabel, connectorLabel } = flow;
|
|
28177
|
+
const totalSteps = flow.oauthSteps + UPLOAD_STEPS;
|
|
28178
|
+
const isUserScoped = options.org !== true;
|
|
28179
|
+
const identity = { isUserScoped, credentialLabel, connectorLabel };
|
|
28008
28180
|
try {
|
|
28009
|
-
|
|
28010
|
-
|
|
28011
|
-
|
|
28012
|
-
const
|
|
28013
|
-
|
|
28014
|
-
|
|
28015
|
-
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
|
|
28181
|
+
if (options.org === true && options.user === true) {
|
|
28182
|
+
throw new Error("Pass either --org or --user, not both.");
|
|
28183
|
+
}
|
|
28184
|
+
const target = await resolveAuthFlowTarget(identity);
|
|
28185
|
+
if (!isUserScoped && !target.organization) {
|
|
28186
|
+
throw new Error(
|
|
28187
|
+
"Could not determine which organization to save to. Re-run the command, or use --user to save to your personal account."
|
|
28188
|
+
);
|
|
28189
|
+
}
|
|
28190
|
+
if (!isUserScoped && target.role && target.role !== "admin") {
|
|
28191
|
+
throw new Error(
|
|
28192
|
+
`Setting the ${credentialLabel} default for ${target.organization?.name ?? "your organization"} requires the admin role, and you are a ${target.role}. To set this for your personal account instead, use the --user flag.`
|
|
28193
|
+
);
|
|
28194
|
+
}
|
|
28195
|
+
if (!await verifyAuthFlowTarget(target, options.yes === true)) {
|
|
28196
|
+
process.exit(1);
|
|
28197
|
+
}
|
|
28198
|
+
const tokens = await flow.runOAuth(totalSteps);
|
|
28199
|
+
renderAuthFlowStep(totalSteps, totalSteps, "Saving credentials");
|
|
28200
|
+
const { result: response, reauthenticated } = await withAuthRecovery(
|
|
28201
|
+
() => orgAuthenticatedFetch(
|
|
28202
|
+
isUserScoped ? flow.userEndpoint : flow.orgEndpoint,
|
|
28203
|
+
{ method: "POST", body: flow.toRequestBody(tokens) }
|
|
28204
|
+
),
|
|
28205
|
+
async () => {
|
|
28206
|
+
const current = await resolveAuthFlowTarget(identity);
|
|
28207
|
+
assertDestinationUnchanged(target, current);
|
|
28208
|
+
if (!destinationWasKnown(current)) {
|
|
28209
|
+
throw new Error(
|
|
28210
|
+
"Could not confirm where these credentials would be saved after signing in. Nothing was saved. Re-run the command."
|
|
28211
|
+
);
|
|
28019
28212
|
}
|
|
28020
|
-
|
|
28213
|
+
if (!destinationWasKnown(target) && !await verifyAuthFlowTarget(current, options.yes === true)) {
|
|
28214
|
+
process.exit(1);
|
|
28215
|
+
}
|
|
28216
|
+
}
|
|
28021
28217
|
);
|
|
28022
28218
|
if (!response.success) {
|
|
28023
|
-
throw new Error(response.error ||
|
|
28219
|
+
throw new Error(response.error || `Failed to upload ${providerLabel} credentials to Replicas`);
|
|
28024
28220
|
}
|
|
28025
|
-
|
|
28026
|
-
|
|
28027
|
-
response,
|
|
28028
|
-
isUserScoped
|
|
28029
|
-
);
|
|
28221
|
+
const saved = reauthenticated || !target.organization ? await resolveAuthFlowTarget(identity) : target;
|
|
28222
|
+
renderAuthFlowSuccess(providerLabel, response, saved);
|
|
28030
28223
|
} catch (error51) {
|
|
28031
|
-
console.log(chalk10.red("\n\u2717 Error:"), error51 instanceof Error ? error51.message : error51);
|
|
28224
|
+
console.log(chalk10.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
|
|
28032
28225
|
process.exit(1);
|
|
28033
28226
|
}
|
|
28034
28227
|
}
|
|
28035
28228
|
|
|
28036
|
-
// src/commands/
|
|
28037
|
-
|
|
28229
|
+
// src/commands/codex-auth.ts
|
|
28230
|
+
async function codexAuthCommand(options = {}) {
|
|
28231
|
+
await runCredentialAuthFlow(options, {
|
|
28232
|
+
providerLabel: "Codex",
|
|
28233
|
+
credentialLabel: "Codex",
|
|
28234
|
+
connectorLabel: "OAuth",
|
|
28235
|
+
oauthSteps: 1,
|
|
28236
|
+
orgEndpoint: "/v1/codex/credentials",
|
|
28237
|
+
userEndpoint: "/v1/codex/user/credentials",
|
|
28238
|
+
runOAuth: runCodexOAuthFlow,
|
|
28239
|
+
toRequestBody: (tokens) => ({
|
|
28240
|
+
access_token: tokens.accessToken,
|
|
28241
|
+
refresh_token: tokens.refreshToken,
|
|
28242
|
+
id_token: tokens.idToken
|
|
28243
|
+
})
|
|
28244
|
+
});
|
|
28245
|
+
}
|
|
28038
28246
|
|
|
28039
28247
|
// src/lib/claude-oauth.ts
|
|
28040
|
-
import open3 from "open";
|
|
28041
28248
|
import readline from "readline";
|
|
28042
28249
|
import chalk11 from "chalk";
|
|
28043
28250
|
var DEFAULT_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
@@ -28059,15 +28266,18 @@ function buildAuthorizationUrl2(codeChallenge, state) {
|
|
|
28059
28266
|
});
|
|
28060
28267
|
return `${AUTHORIZATION_ENDPOINT2}?${params.toString()}`;
|
|
28061
28268
|
}
|
|
28062
|
-
async function promptForAuthorizationCode(
|
|
28063
|
-
|
|
28064
|
-
|
|
28065
|
-
|
|
28066
|
-
|
|
28269
|
+
async function promptForAuthorizationCode() {
|
|
28270
|
+
if (!process.stdin.isTTY) {
|
|
28271
|
+
throw new Error("Pasting the authorization code needs an interactive terminal.");
|
|
28272
|
+
}
|
|
28273
|
+
process.stdin.setRawMode(false);
|
|
28274
|
+
process.stdin.resume();
|
|
28275
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
28067
28276
|
return new Promise((resolve3) => {
|
|
28068
|
-
rl.
|
|
28069
|
-
|
|
28277
|
+
rl.on("close", () => resolve3(""));
|
|
28278
|
+
rl.question(chalk11.gray(" Paste code here: "), (answer) => {
|
|
28070
28279
|
resolve3(answer.trim());
|
|
28280
|
+
rl.close();
|
|
28071
28281
|
});
|
|
28072
28282
|
});
|
|
28073
28283
|
}
|
|
@@ -28127,22 +28337,14 @@ async function exchangeCodeForTokens2(code, state, expectedState, codeVerifier)
|
|
|
28127
28337
|
refreshTokenExpiresAt
|
|
28128
28338
|
};
|
|
28129
28339
|
}
|
|
28130
|
-
async function runClaudeOAuthFlow() {
|
|
28340
|
+
async function runClaudeOAuthFlow(totalSteps) {
|
|
28131
28341
|
const pkce = generatePkceCodes();
|
|
28132
28342
|
const state = generateState2();
|
|
28133
28343
|
const authUrl = buildAuthorizationUrl2(pkce.codeChallenge, state);
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
try {
|
|
28139
|
-
await open3(authUrl);
|
|
28140
|
-
} catch {
|
|
28141
|
-
console.warn(chalk11.yellow("Failed to open browser automatically. Please copy and open the URL manually."));
|
|
28142
|
-
}
|
|
28143
|
-
console.log(chalk11.cyan("After completing authentication, copy the code shown on the success page."));
|
|
28144
|
-
console.log(chalk11.cyan("You can paste either the full URL, or a value formatted as CODE#STATE.\n"));
|
|
28145
|
-
const userInput = await promptForAuthorizationCode("Paste the authorization code (or URL) here: ");
|
|
28344
|
+
renderAuthFlowStep(1, totalSteps, "Approve access in your browser");
|
|
28345
|
+
await openForApproval("claude.ai", authUrl);
|
|
28346
|
+
renderAuthFlowStep(2, totalSteps, "Paste the code Claude gives you");
|
|
28347
|
+
const userInput = await promptForAuthorizationCode();
|
|
28146
28348
|
if (!userInput) {
|
|
28147
28349
|
throw new Error("No authorization code provided.");
|
|
28148
28350
|
}
|
|
@@ -28150,51 +28352,32 @@ async function runClaudeOAuthFlow() {
|
|
|
28150
28352
|
if (!code) {
|
|
28151
28353
|
throw new Error("Unable to parse authorization code. Please try again.");
|
|
28152
28354
|
}
|
|
28153
|
-
|
|
28154
|
-
const tokens = await exchangeCodeForTokens2(code, returnedState, state, pkce.codeVerifier);
|
|
28155
|
-
console.log(chalk11.green("\u2713 Successfully obtained Claude credentials"));
|
|
28156
|
-
return tokens;
|
|
28355
|
+
return exchangeCodeForTokens2(code, returnedState, state, pkce.codeVerifier);
|
|
28157
28356
|
}
|
|
28158
28357
|
|
|
28159
28358
|
// src/commands/claude-auth.ts
|
|
28160
28359
|
async function claudeAuthCommand(options = {}) {
|
|
28161
|
-
|
|
28162
|
-
|
|
28163
|
-
|
|
28164
|
-
|
|
28165
|
-
|
|
28166
|
-
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
|
|
28173
|
-
|
|
28174
|
-
|
|
28175
|
-
|
|
28176
|
-
|
|
28177
|
-
|
|
28178
|
-
refresh_token_expires_at: tokens.refreshTokenExpiresAt
|
|
28179
|
-
}
|
|
28180
|
-
})
|
|
28181
|
-
);
|
|
28182
|
-
if (!response.success) {
|
|
28183
|
-
throw new Error(response.error || "Failed to upload Claude credentials to Replicas");
|
|
28184
|
-
}
|
|
28185
|
-
displayCredentialUploadSuccess(
|
|
28186
|
-
{ providerLabel: "Claude", productLabel: "Claude Code" },
|
|
28187
|
-
response,
|
|
28188
|
-
isUserScoped
|
|
28189
|
-
);
|
|
28190
|
-
} catch (error51) {
|
|
28191
|
-
console.log(chalk12.red("\n\u2717 Error:"), error51 instanceof Error ? error51.message : error51);
|
|
28192
|
-
process.exit(1);
|
|
28193
|
-
}
|
|
28360
|
+
await runCredentialAuthFlow(options, {
|
|
28361
|
+
providerLabel: "Claude",
|
|
28362
|
+
credentialLabel: "Claude Code",
|
|
28363
|
+
connectorLabel: "OAuth",
|
|
28364
|
+
oauthSteps: 2,
|
|
28365
|
+
orgEndpoint: "/v1/claude/credentials",
|
|
28366
|
+
userEndpoint: "/v1/claude/user/credentials",
|
|
28367
|
+
runOAuth: runClaudeOAuthFlow,
|
|
28368
|
+
toRequestBody: (tokens) => ({
|
|
28369
|
+
access_token: tokens.accessToken,
|
|
28370
|
+
refresh_token: tokens.refreshToken,
|
|
28371
|
+
token_type: tokens.tokenType,
|
|
28372
|
+
scope: tokens.scope,
|
|
28373
|
+
expires_at: tokens.expiresAt,
|
|
28374
|
+
refresh_token_expires_at: tokens.refreshTokenExpiresAt
|
|
28375
|
+
})
|
|
28376
|
+
});
|
|
28194
28377
|
}
|
|
28195
28378
|
|
|
28196
28379
|
// src/commands/init.ts
|
|
28197
|
-
import
|
|
28380
|
+
import chalk12 from "chalk";
|
|
28198
28381
|
import fs3 from "fs";
|
|
28199
28382
|
import path4 from "path";
|
|
28200
28383
|
function getDefaultConfig() {
|
|
@@ -28226,11 +28409,11 @@ function initCommand(options) {
|
|
|
28226
28409
|
const existingPath = path4.join(process.cwd(), filename);
|
|
28227
28410
|
if (fs3.existsSync(existingPath) && !options.force) {
|
|
28228
28411
|
console.log(
|
|
28229
|
-
|
|
28412
|
+
chalk12.yellow(
|
|
28230
28413
|
`${filename} already exists in this directory.`
|
|
28231
28414
|
)
|
|
28232
28415
|
);
|
|
28233
|
-
console.log(
|
|
28416
|
+
console.log(chalk12.gray("Use --force to overwrite the existing file."));
|
|
28234
28417
|
return;
|
|
28235
28418
|
}
|
|
28236
28419
|
}
|
|
@@ -28243,31 +28426,31 @@ function initCommand(options) {
|
|
|
28243
28426
|
}
|
|
28244
28427
|
try {
|
|
28245
28428
|
fs3.writeFileSync(configPath, configContent, "utf-8");
|
|
28246
|
-
console.log(
|
|
28429
|
+
console.log(chalk12.green(`\u2713 Created ${targetFilename}`));
|
|
28247
28430
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
28248
28431
|
if (filename === targetFilename) break;
|
|
28249
28432
|
const higherPath = path4.join(process.cwd(), filename);
|
|
28250
28433
|
if (fs3.existsSync(higherPath)) {
|
|
28251
28434
|
console.log("");
|
|
28252
28435
|
console.log(
|
|
28253
|
-
|
|
28436
|
+
chalk12.yellow(
|
|
28254
28437
|
`Warning: ${filename} already exists and takes priority over ${targetFilename}.`
|
|
28255
28438
|
)
|
|
28256
28439
|
);
|
|
28257
|
-
console.log(
|
|
28440
|
+
console.log(chalk12.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
|
|
28258
28441
|
}
|
|
28259
28442
|
}
|
|
28260
28443
|
console.log("");
|
|
28261
|
-
console.log(
|
|
28444
|
+
console.log(chalk12.gray("Configuration options:"));
|
|
28262
28445
|
console.log(
|
|
28263
|
-
|
|
28446
|
+
chalk12.gray(" systemPrompt - Custom instructions for AI coding assistants")
|
|
28264
28447
|
);
|
|
28265
28448
|
console.log(
|
|
28266
|
-
|
|
28449
|
+
chalk12.gray(" startHook - Commands to run on workspace startup")
|
|
28267
28450
|
);
|
|
28268
28451
|
if (!isYaml) {
|
|
28269
28452
|
console.log("");
|
|
28270
|
-
console.log(
|
|
28453
|
+
console.log(chalk12.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
|
|
28271
28454
|
}
|
|
28272
28455
|
} catch (error51) {
|
|
28273
28456
|
throw new Error(
|
|
@@ -28277,33 +28460,42 @@ function initCommand(options) {
|
|
|
28277
28460
|
}
|
|
28278
28461
|
|
|
28279
28462
|
// src/lib/version-check.ts
|
|
28280
|
-
import
|
|
28463
|
+
import chalk13 from "chalk";
|
|
28281
28464
|
var MONOLITH_URL2 = process.env.REPLICAS_MONOLITH_URL || "https://api.tryreplicas.com";
|
|
28282
28465
|
var VERSION_CHECK_TIMEOUT = 2e3;
|
|
28283
|
-
|
|
28284
|
-
|
|
28285
|
-
|
|
28286
|
-
|
|
28287
|
-
|
|
28288
|
-
signal: controller.signal
|
|
28289
|
-
});
|
|
28290
|
-
clearTimeout(timeoutId);
|
|
28291
|
-
if (!response.ok) return;
|
|
28292
|
-
const data = await response.json();
|
|
28293
|
-
const latestVersion = data.version;
|
|
28294
|
-
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
28295
|
-
console.error(chalk14.yellow(`
|
|
28296
|
-
Update available: ${currentVersion} \u2192 ${latestVersion}`));
|
|
28297
|
-
console.error(chalk14.cyan(`Run: curl -fsSL https://tryreplicas.com/install.sh | bash
|
|
28298
|
-
`));
|
|
28466
|
+
function startUpdateCheck(currentVersion) {
|
|
28467
|
+
let notice = null;
|
|
28468
|
+
process.on("exit", () => {
|
|
28469
|
+
if (notice) {
|
|
28470
|
+
process.stderr.write(notice);
|
|
28299
28471
|
}
|
|
28300
|
-
}
|
|
28301
|
-
|
|
28472
|
+
});
|
|
28473
|
+
void (async () => {
|
|
28474
|
+
try {
|
|
28475
|
+
const response = await fetch(`${MONOLITH_URL2}/v1/cli/version`, {
|
|
28476
|
+
signal: AbortSignal.timeout(VERSION_CHECK_TIMEOUT)
|
|
28477
|
+
});
|
|
28478
|
+
if (!response.ok) return;
|
|
28479
|
+
const payload = await response.json();
|
|
28480
|
+
if (typeof payload !== "object" || payload === null || !("version" in payload) || typeof payload.version !== "string") {
|
|
28481
|
+
return;
|
|
28482
|
+
}
|
|
28483
|
+
const latestVersion = payload.version;
|
|
28484
|
+
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
28485
|
+
notice = chalk13.dim(
|
|
28486
|
+
`
|
|
28487
|
+
Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: curl -fsSL https://tryreplicas.com/install.sh | bash
|
|
28488
|
+
`
|
|
28489
|
+
);
|
|
28490
|
+
}
|
|
28491
|
+
} catch {
|
|
28492
|
+
}
|
|
28493
|
+
})();
|
|
28302
28494
|
}
|
|
28303
28495
|
|
|
28304
28496
|
// src/commands/replica.ts
|
|
28305
|
-
import
|
|
28306
|
-
import
|
|
28497
|
+
import chalk14 from "chalk";
|
|
28498
|
+
import prompts4 from "prompts";
|
|
28307
28499
|
var CLI_CODING_AGENT_LABEL = getCodingAgentDisplayNames();
|
|
28308
28500
|
function parseReplicaAgent(value) {
|
|
28309
28501
|
if (!value) return void 0;
|
|
@@ -28311,15 +28503,15 @@ function parseReplicaAgent(value) {
|
|
|
28311
28503
|
if (isValidCodingAgentProvider(normalized)) {
|
|
28312
28504
|
return normalized;
|
|
28313
28505
|
}
|
|
28314
|
-
console.log(
|
|
28506
|
+
console.log(chalk14.red(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`));
|
|
28315
28507
|
process.exit(1);
|
|
28316
28508
|
}
|
|
28317
28509
|
function formatDate(dateString) {
|
|
28318
28510
|
return new Date(dateString).toLocaleString();
|
|
28319
28511
|
}
|
|
28320
28512
|
function formatStatus(status) {
|
|
28321
|
-
if (status === "active") return
|
|
28322
|
-
if (isWorkspaceSuspendedStatus(status)) return
|
|
28513
|
+
if (status === "active") return chalk14.green(status);
|
|
28514
|
+
if (isWorkspaceSuspendedStatus(status)) return chalk14.gray(status);
|
|
28323
28515
|
return status;
|
|
28324
28516
|
}
|
|
28325
28517
|
function truncate(text, maxLength) {
|
|
@@ -28330,95 +28522,95 @@ function formatDisplayMessage(message) {
|
|
|
28330
28522
|
const time3 = new Date(message.timestamp).toLocaleTimeString();
|
|
28331
28523
|
switch (message.type) {
|
|
28332
28524
|
case "user":
|
|
28333
|
-
console.log(
|
|
28525
|
+
console.log(chalk14.blue(`
|
|
28334
28526
|
[${time3}] USER:`));
|
|
28335
|
-
console.log(
|
|
28527
|
+
console.log(chalk14.white(` ${truncate(message.content, 500)}`));
|
|
28336
28528
|
break;
|
|
28337
28529
|
case "agent":
|
|
28338
|
-
console.log(
|
|
28530
|
+
console.log(chalk14.green(`
|
|
28339
28531
|
[${time3}] ASSISTANT:`));
|
|
28340
|
-
console.log(
|
|
28532
|
+
console.log(chalk14.white(` ${truncate(message.content, 500)}`));
|
|
28341
28533
|
break;
|
|
28342
28534
|
case "reasoning":
|
|
28343
|
-
console.log(
|
|
28535
|
+
console.log(chalk14.gray(`
|
|
28344
28536
|
[${time3}] THINKING:`));
|
|
28345
|
-
console.log(
|
|
28537
|
+
console.log(chalk14.gray(` ${truncate(message.content, 300)}`));
|
|
28346
28538
|
break;
|
|
28347
28539
|
case "command":
|
|
28348
|
-
console.log(
|
|
28540
|
+
console.log(chalk14.magenta(`
|
|
28349
28541
|
[${time3}] COMMAND:`));
|
|
28350
|
-
console.log(
|
|
28542
|
+
console.log(chalk14.white(` $ ${message.command}`));
|
|
28351
28543
|
if (message.output) {
|
|
28352
|
-
console.log(
|
|
28544
|
+
console.log(chalk14.gray(` ${truncate(message.output, 200)}`));
|
|
28353
28545
|
}
|
|
28354
28546
|
if (message.exitCode !== void 0) {
|
|
28355
|
-
const exitColor = message.exitCode === 0 ?
|
|
28547
|
+
const exitColor = message.exitCode === 0 ? chalk14.green : chalk14.red;
|
|
28356
28548
|
console.log(exitColor(` Exit code: ${message.exitCode}`));
|
|
28357
28549
|
}
|
|
28358
28550
|
break;
|
|
28359
28551
|
case "file_change":
|
|
28360
|
-
console.log(
|
|
28552
|
+
console.log(chalk14.yellow(`
|
|
28361
28553
|
[${time3}] FILE CHANGES:`));
|
|
28362
28554
|
for (const change of message.changes) {
|
|
28363
28555
|
const icon = change.kind === "add" ? "+" : change.kind === "delete" ? "-" : "~";
|
|
28364
|
-
const color = change.kind === "add" ?
|
|
28556
|
+
const color = change.kind === "add" ? chalk14.green : change.kind === "delete" ? chalk14.red : chalk14.yellow;
|
|
28365
28557
|
console.log(color(` ${icon} ${change.path}`));
|
|
28366
28558
|
}
|
|
28367
28559
|
break;
|
|
28368
28560
|
case "patch":
|
|
28369
|
-
console.log(
|
|
28561
|
+
console.log(chalk14.yellow(`
|
|
28370
28562
|
[${time3}] PATCH:`));
|
|
28371
28563
|
for (const op of message.operations) {
|
|
28372
28564
|
const icon = op.action === "add" ? "+" : op.action === "delete" ? "-" : "~";
|
|
28373
|
-
const color = op.action === "add" ?
|
|
28565
|
+
const color = op.action === "add" ? chalk14.green : op.action === "delete" ? chalk14.red : chalk14.yellow;
|
|
28374
28566
|
console.log(color(` ${icon} ${op.path}`));
|
|
28375
28567
|
}
|
|
28376
28568
|
break;
|
|
28377
28569
|
case "tool_call":
|
|
28378
|
-
console.log(
|
|
28570
|
+
console.log(chalk14.cyan(`
|
|
28379
28571
|
[${time3}] TOOL: ${message.tool}`));
|
|
28380
28572
|
if (message.output) {
|
|
28381
|
-
console.log(
|
|
28573
|
+
console.log(chalk14.gray(` ${truncate(message.output, 200)}`));
|
|
28382
28574
|
}
|
|
28383
28575
|
break;
|
|
28384
28576
|
case "web_search":
|
|
28385
|
-
console.log(
|
|
28577
|
+
console.log(chalk14.cyan(`
|
|
28386
28578
|
[${time3}] WEB SEARCH:`));
|
|
28387
|
-
console.log(
|
|
28579
|
+
console.log(chalk14.white(` "${message.query}"`));
|
|
28388
28580
|
break;
|
|
28389
28581
|
case "todo_list":
|
|
28390
|
-
console.log(
|
|
28582
|
+
console.log(chalk14.blue(`
|
|
28391
28583
|
[${time3}] PLAN:`));
|
|
28392
28584
|
for (const item of message.items) {
|
|
28393
|
-
const icon = item.completed ?
|
|
28585
|
+
const icon = item.completed ? chalk14.green("[x]") : chalk14.gray("[ ]");
|
|
28394
28586
|
console.log(` ${icon} ${item.text}`);
|
|
28395
28587
|
}
|
|
28396
28588
|
break;
|
|
28397
28589
|
case "subagent":
|
|
28398
|
-
console.log(
|
|
28590
|
+
console.log(chalk14.magenta(`
|
|
28399
28591
|
[${time3}] SUBAGENT: ${message.description}`));
|
|
28400
28592
|
if (message.output) {
|
|
28401
|
-
console.log(
|
|
28593
|
+
console.log(chalk14.gray(` ${truncate(message.output, 200)}`));
|
|
28402
28594
|
}
|
|
28403
28595
|
break;
|
|
28404
28596
|
case "subagent_followup":
|
|
28405
|
-
console.log(
|
|
28597
|
+
console.log(chalk14.magenta(`
|
|
28406
28598
|
[${time3}] MESSAGE SUBAGENT: ${message.targetTitle ?? message.chatId}`));
|
|
28407
|
-
console.log(
|
|
28599
|
+
console.log(chalk14.white(` ${truncate(message.message, 500)}`));
|
|
28408
28600
|
if (message.output) {
|
|
28409
|
-
console.log(
|
|
28601
|
+
console.log(chalk14.gray(` ${truncate(message.output, 200)}`));
|
|
28410
28602
|
}
|
|
28411
28603
|
break;
|
|
28412
28604
|
case "error":
|
|
28413
|
-
console.log(
|
|
28605
|
+
console.log(chalk14.red(`
|
|
28414
28606
|
[${time3}] ERROR:`));
|
|
28415
|
-
console.log(
|
|
28607
|
+
console.log(chalk14.red(` ${message.message}`));
|
|
28416
28608
|
break;
|
|
28417
28609
|
}
|
|
28418
28610
|
}
|
|
28419
28611
|
async function replicaListCommand(options) {
|
|
28420
28612
|
if (!canCallOrgApi()) {
|
|
28421
|
-
console.log(
|
|
28613
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28422
28614
|
process.exit(1);
|
|
28423
28615
|
}
|
|
28424
28616
|
try {
|
|
@@ -28430,79 +28622,79 @@ async function replicaListCommand(options) {
|
|
|
28430
28622
|
`/v1/replica${query ? "?" + query : ""}`
|
|
28431
28623
|
);
|
|
28432
28624
|
if (response.replicas.length === 0) {
|
|
28433
|
-
console.log(
|
|
28625
|
+
console.log(chalk14.yellow("\nNo replicas found.\n"));
|
|
28434
28626
|
return;
|
|
28435
28627
|
}
|
|
28436
|
-
console.log(
|
|
28628
|
+
console.log(chalk14.green(`
|
|
28437
28629
|
Replicas (Page ${response.page} of ${response.total_pages}, Total: ${response.total}):
|
|
28438
28630
|
`));
|
|
28439
28631
|
for (const replica of response.replicas) {
|
|
28440
|
-
console.log(
|
|
28441
|
-
console.log(
|
|
28632
|
+
console.log(chalk14.white(` ${replica.name}`));
|
|
28633
|
+
console.log(chalk14.gray(` ID: ${replica.id}`));
|
|
28442
28634
|
if (replica.repositories.length > 0) {
|
|
28443
|
-
console.log(
|
|
28635
|
+
console.log(chalk14.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
|
|
28444
28636
|
}
|
|
28445
|
-
console.log(
|
|
28446
|
-
console.log(
|
|
28637
|
+
console.log(chalk14.gray(` Status: ${formatStatus(replica.status)}`));
|
|
28638
|
+
console.log(chalk14.gray(` Created: ${formatDate(replica.created_at)}`));
|
|
28447
28639
|
if (replica.pull_requests && replica.pull_requests.length > 0) {
|
|
28448
|
-
console.log(
|
|
28640
|
+
console.log(chalk14.gray(` Pull Requests:`));
|
|
28449
28641
|
for (const pr of replica.pull_requests) {
|
|
28450
|
-
console.log(
|
|
28642
|
+
console.log(chalk14.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
|
|
28451
28643
|
}
|
|
28452
28644
|
}
|
|
28453
28645
|
console.log();
|
|
28454
28646
|
}
|
|
28455
28647
|
} catch (error51) {
|
|
28456
|
-
console.error(
|
|
28648
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28457
28649
|
process.exit(1);
|
|
28458
28650
|
}
|
|
28459
28651
|
}
|
|
28460
28652
|
async function replicaGetCommand(id) {
|
|
28461
28653
|
if (!isAuthenticated()) {
|
|
28462
|
-
console.log(
|
|
28654
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28463
28655
|
process.exit(1);
|
|
28464
28656
|
}
|
|
28465
28657
|
try {
|
|
28466
28658
|
const response = await orgAuthenticatedFetch(`/v1/replica/${id}`);
|
|
28467
28659
|
const replica = response.replica;
|
|
28468
|
-
console.log(
|
|
28660
|
+
console.log(chalk14.green(`
|
|
28469
28661
|
Replica: ${replica.name}
|
|
28470
28662
|
`));
|
|
28471
|
-
console.log(
|
|
28663
|
+
console.log(chalk14.gray(` ID: ${replica.id}`));
|
|
28472
28664
|
if (replica.repositories.length > 0) {
|
|
28473
|
-
console.log(
|
|
28665
|
+
console.log(chalk14.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
|
|
28474
28666
|
}
|
|
28475
|
-
console.log(
|
|
28476
|
-
console.log(
|
|
28667
|
+
console.log(chalk14.gray(` Status: ${formatStatus(replica.status)}`));
|
|
28668
|
+
console.log(chalk14.gray(` Created: ${formatDate(replica.created_at)}`));
|
|
28477
28669
|
if (replica.waking) {
|
|
28478
|
-
console.log(
|
|
28670
|
+
console.log(chalk14.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
|
|
28479
28671
|
} else {
|
|
28480
28672
|
if (replica.coding_agent) {
|
|
28481
|
-
console.log(
|
|
28673
|
+
console.log(chalk14.gray(` Coding Agent: ${replica.coding_agent}`));
|
|
28482
28674
|
}
|
|
28483
28675
|
if (replica.repository_statuses && replica.repository_statuses.length > 0) {
|
|
28484
|
-
console.log(
|
|
28676
|
+
console.log(chalk14.gray(" Repository Statuses:"));
|
|
28485
28677
|
for (const repositoryStatus of replica.repository_statuses) {
|
|
28486
|
-
const changeText = repositoryStatus.git_diff ? ` (${
|
|
28487
|
-
console.log(
|
|
28678
|
+
const changeText = repositoryStatus.git_diff ? ` (${chalk14.green(`+${repositoryStatus.git_diff.added}`)} / ${chalk14.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
|
|
28679
|
+
console.log(chalk14.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
|
|
28488
28680
|
}
|
|
28489
28681
|
}
|
|
28490
28682
|
}
|
|
28491
28683
|
if (replica.pull_requests && replica.pull_requests.length > 0) {
|
|
28492
|
-
console.log(
|
|
28684
|
+
console.log(chalk14.gray(` Pull Requests:`));
|
|
28493
28685
|
for (const pr of replica.pull_requests) {
|
|
28494
|
-
console.log(
|
|
28686
|
+
console.log(chalk14.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
|
|
28495
28687
|
}
|
|
28496
28688
|
}
|
|
28497
28689
|
console.log();
|
|
28498
28690
|
} catch (error51) {
|
|
28499
|
-
console.error(
|
|
28691
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28500
28692
|
process.exit(1);
|
|
28501
28693
|
}
|
|
28502
28694
|
}
|
|
28503
28695
|
async function replicaCreateCommand(name, options) {
|
|
28504
28696
|
if (!isAuthenticated()) {
|
|
28505
|
-
console.log(
|
|
28697
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28506
28698
|
process.exit(1);
|
|
28507
28699
|
}
|
|
28508
28700
|
try {
|
|
@@ -28511,7 +28703,7 @@ async function replicaCreateCommand(name, options) {
|
|
|
28511
28703
|
(env) => !env.is_global && (env.repository_id || env.repository_set_id)
|
|
28512
28704
|
);
|
|
28513
28705
|
if (environments.length === 0) {
|
|
28514
|
-
console.log(
|
|
28706
|
+
console.log(chalk14.red("No repository-bound environments found. Please add a repository or bind an environment first."));
|
|
28515
28707
|
process.exit(1);
|
|
28516
28708
|
}
|
|
28517
28709
|
let replicaName = name;
|
|
@@ -28519,11 +28711,11 @@ async function replicaCreateCommand(name, options) {
|
|
|
28519
28711
|
let selectedEnvironmentId = options.environment?.trim();
|
|
28520
28712
|
let codingAgent = parseReplicaAgent(options.agent);
|
|
28521
28713
|
if (replicaName && /\s/.test(replicaName)) {
|
|
28522
|
-
console.log(
|
|
28714
|
+
console.log(chalk14.red("Replica name cannot contain spaces."));
|
|
28523
28715
|
process.exit(1);
|
|
28524
28716
|
}
|
|
28525
28717
|
if (!replicaName) {
|
|
28526
|
-
const response2 = await
|
|
28718
|
+
const response2 = await prompts4({
|
|
28527
28719
|
type: "text",
|
|
28528
28720
|
name: "name",
|
|
28529
28721
|
message: "Enter replica name (without spaces):",
|
|
@@ -28534,13 +28726,13 @@ async function replicaCreateCommand(name, options) {
|
|
|
28534
28726
|
}
|
|
28535
28727
|
});
|
|
28536
28728
|
if (!response2.name) {
|
|
28537
|
-
console.log(
|
|
28729
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28538
28730
|
return;
|
|
28539
28731
|
}
|
|
28540
28732
|
replicaName = response2.name;
|
|
28541
28733
|
}
|
|
28542
28734
|
if (!selectedEnvironmentId) {
|
|
28543
|
-
const response2 = await
|
|
28735
|
+
const response2 = await prompts4({
|
|
28544
28736
|
type: "select",
|
|
28545
28737
|
name: "environment",
|
|
28546
28738
|
message: "Select environment:",
|
|
@@ -28551,26 +28743,26 @@ async function replicaCreateCommand(name, options) {
|
|
|
28551
28743
|
}))
|
|
28552
28744
|
});
|
|
28553
28745
|
if (!response2.environment) {
|
|
28554
|
-
console.log(
|
|
28746
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28555
28747
|
return;
|
|
28556
28748
|
}
|
|
28557
28749
|
selectedEnvironmentId = response2.environment;
|
|
28558
28750
|
}
|
|
28559
28751
|
if (!message) {
|
|
28560
|
-
const response2 = await
|
|
28752
|
+
const response2 = await prompts4({
|
|
28561
28753
|
type: "text",
|
|
28562
28754
|
name: "message",
|
|
28563
28755
|
message: "Enter initial message for the replica:",
|
|
28564
28756
|
validate: (value) => value.trim() ? true : "Message is required"
|
|
28565
28757
|
});
|
|
28566
28758
|
if (!response2.message) {
|
|
28567
|
-
console.log(
|
|
28759
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28568
28760
|
return;
|
|
28569
28761
|
}
|
|
28570
28762
|
message = response2.message;
|
|
28571
28763
|
}
|
|
28572
28764
|
if (!codingAgent) {
|
|
28573
|
-
const response2 = await
|
|
28765
|
+
const response2 = await prompts4({
|
|
28574
28766
|
type: "select",
|
|
28575
28767
|
name: "agent",
|
|
28576
28768
|
message: "Select coding agent:",
|
|
@@ -28578,7 +28770,7 @@ async function replicaCreateCommand(name, options) {
|
|
|
28578
28770
|
initial: 0
|
|
28579
28771
|
});
|
|
28580
28772
|
if (!response2.agent) {
|
|
28581
|
-
console.log(
|
|
28773
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28582
28774
|
return;
|
|
28583
28775
|
}
|
|
28584
28776
|
codingAgent = parseReplicaAgent(response2.agent);
|
|
@@ -28589,41 +28781,41 @@ async function replicaCreateCommand(name, options) {
|
|
|
28589
28781
|
environment_id: selectedEnvironmentId,
|
|
28590
28782
|
coding_agent: codingAgent
|
|
28591
28783
|
};
|
|
28592
|
-
console.log(
|
|
28784
|
+
console.log(chalk14.gray("\nCreating replica..."));
|
|
28593
28785
|
const response = await orgAuthenticatedFetch("/v1/replica", {
|
|
28594
28786
|
method: "POST",
|
|
28595
28787
|
body
|
|
28596
28788
|
});
|
|
28597
28789
|
const replica = response.replica;
|
|
28598
|
-
console.log(
|
|
28790
|
+
console.log(chalk14.green(`
|
|
28599
28791
|
Created replica: ${replica.name}`));
|
|
28600
|
-
console.log(
|
|
28601
|
-
console.log(
|
|
28792
|
+
console.log(chalk14.gray(` ID: ${replica.id}`));
|
|
28793
|
+
console.log(chalk14.gray(` Status: ${formatStatus(replica.status)}`));
|
|
28602
28794
|
if (replica.repositories.length > 0) {
|
|
28603
|
-
console.log(
|
|
28795
|
+
console.log(chalk14.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
|
|
28604
28796
|
}
|
|
28605
28797
|
console.log();
|
|
28606
28798
|
} catch (error51) {
|
|
28607
|
-
console.error(
|
|
28799
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28608
28800
|
process.exit(1);
|
|
28609
28801
|
}
|
|
28610
28802
|
}
|
|
28611
28803
|
async function replicaSendCommand(id, options) {
|
|
28612
28804
|
if (!isAuthenticated()) {
|
|
28613
|
-
console.log(
|
|
28805
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28614
28806
|
process.exit(1);
|
|
28615
28807
|
}
|
|
28616
28808
|
try {
|
|
28617
28809
|
let message = options.message;
|
|
28618
28810
|
if (!message) {
|
|
28619
|
-
const response2 = await
|
|
28811
|
+
const response2 = await prompts4({
|
|
28620
28812
|
type: "text",
|
|
28621
28813
|
name: "message",
|
|
28622
28814
|
message: "Enter message to send:",
|
|
28623
28815
|
validate: (value) => value.trim() ? true : "Message is required"
|
|
28624
28816
|
});
|
|
28625
28817
|
if (!response2.message) {
|
|
28626
|
-
console.log(
|
|
28818
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28627
28819
|
return;
|
|
28628
28820
|
}
|
|
28629
28821
|
message = response2.message;
|
|
@@ -28641,50 +28833,50 @@ async function replicaSendCommand(id, options) {
|
|
|
28641
28833
|
body
|
|
28642
28834
|
}
|
|
28643
28835
|
);
|
|
28644
|
-
const statusColor = response.status === "sent" ?
|
|
28836
|
+
const statusColor = response.status === "sent" ? chalk14.green : chalk14.yellow;
|
|
28645
28837
|
console.log(statusColor(`
|
|
28646
28838
|
Message ${response.status}`));
|
|
28647
28839
|
if (response.position !== void 0 && response.position > 0) {
|
|
28648
|
-
console.log(
|
|
28840
|
+
console.log(chalk14.gray(` Queue position: ${response.position}`));
|
|
28649
28841
|
}
|
|
28650
28842
|
console.log();
|
|
28651
28843
|
} catch (error51) {
|
|
28652
|
-
console.error(
|
|
28844
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28653
28845
|
process.exit(1);
|
|
28654
28846
|
}
|
|
28655
28847
|
}
|
|
28656
28848
|
async function replicaDeleteCommand(id, options) {
|
|
28657
28849
|
if (!isAuthenticated()) {
|
|
28658
|
-
console.log(
|
|
28850
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28659
28851
|
process.exit(1);
|
|
28660
28852
|
}
|
|
28661
28853
|
try {
|
|
28662
28854
|
if (!options.force) {
|
|
28663
|
-
const response = await
|
|
28855
|
+
const response = await prompts4({
|
|
28664
28856
|
type: "confirm",
|
|
28665
28857
|
name: "confirm",
|
|
28666
28858
|
message: `Are you sure you want to delete replica ${id}?`,
|
|
28667
28859
|
initial: false
|
|
28668
28860
|
});
|
|
28669
28861
|
if (!response.confirm) {
|
|
28670
|
-
console.log(
|
|
28862
|
+
console.log(chalk14.yellow("\nCancelled."));
|
|
28671
28863
|
return;
|
|
28672
28864
|
}
|
|
28673
28865
|
}
|
|
28674
28866
|
await orgAuthenticatedFetch(`/v1/replica/${id}`, {
|
|
28675
28867
|
method: "DELETE"
|
|
28676
28868
|
});
|
|
28677
|
-
console.log(
|
|
28869
|
+
console.log(chalk14.green(`
|
|
28678
28870
|
Replica ${id} deleted.
|
|
28679
28871
|
`));
|
|
28680
28872
|
} catch (error51) {
|
|
28681
|
-
console.error(
|
|
28873
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28682
28874
|
process.exit(1);
|
|
28683
28875
|
}
|
|
28684
28876
|
}
|
|
28685
28877
|
async function replicaReadCommand(id, options) {
|
|
28686
28878
|
if (!isAuthenticated()) {
|
|
28687
|
-
console.log(
|
|
28879
|
+
console.log(chalk14.red('Not logged in. Please run "replicas login" first.'));
|
|
28688
28880
|
process.exit(1);
|
|
28689
28881
|
}
|
|
28690
28882
|
try {
|
|
@@ -28696,53 +28888,53 @@ async function replicaReadCommand(id, options) {
|
|
|
28696
28888
|
`/v1/replica/${id}/read${query ? "?" + query : ""}`
|
|
28697
28889
|
);
|
|
28698
28890
|
if (response.waking) {
|
|
28699
|
-
console.log(
|
|
28891
|
+
console.log(chalk14.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
|
|
28700
28892
|
return;
|
|
28701
28893
|
}
|
|
28702
|
-
console.log(
|
|
28894
|
+
console.log(chalk14.green(`
|
|
28703
28895
|
Conversation History
|
|
28704
28896
|
`));
|
|
28705
28897
|
if (response.coding_agent) {
|
|
28706
|
-
console.log(
|
|
28898
|
+
console.log(chalk14.gray(` Agent: ${response.coding_agent}`));
|
|
28707
28899
|
}
|
|
28708
28900
|
if (response.thread_id) {
|
|
28709
|
-
console.log(
|
|
28901
|
+
console.log(chalk14.gray(` Thread ID: ${response.thread_id}`));
|
|
28710
28902
|
}
|
|
28711
|
-
console.log(
|
|
28712
|
-
console.log(
|
|
28903
|
+
console.log(chalk14.gray(` Total Events: ${response.total}`));
|
|
28904
|
+
console.log(chalk14.gray(` Showing: ${response.events.length} events`));
|
|
28713
28905
|
if (response.has_more) {
|
|
28714
|
-
console.log(
|
|
28906
|
+
console.log(chalk14.gray(` Has More: yes (use --offset to paginate)`));
|
|
28715
28907
|
}
|
|
28716
28908
|
console.log();
|
|
28717
28909
|
if (response.events.length === 0) {
|
|
28718
|
-
console.log(
|
|
28910
|
+
console.log(chalk14.yellow(" No events found.\n"));
|
|
28719
28911
|
return;
|
|
28720
28912
|
}
|
|
28721
|
-
console.log(
|
|
28913
|
+
console.log(chalk14.gray("-".repeat(60)));
|
|
28722
28914
|
const agentType = response.coding_agent || "claude";
|
|
28723
28915
|
const displayMessages = parseDisplayMessages(response.events, agentType, response.codexAspTranscript);
|
|
28724
28916
|
for (const message of displayMessages) {
|
|
28725
28917
|
formatDisplayMessage(message);
|
|
28726
28918
|
}
|
|
28727
|
-
console.log(
|
|
28919
|
+
console.log(chalk14.gray("\n" + "-".repeat(60)));
|
|
28728
28920
|
console.log();
|
|
28729
28921
|
} catch (error51) {
|
|
28730
|
-
console.error(
|
|
28922
|
+
console.error(chalk14.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28731
28923
|
process.exit(1);
|
|
28732
28924
|
}
|
|
28733
28925
|
}
|
|
28734
28926
|
|
|
28735
28927
|
// src/commands/repositories.ts
|
|
28736
|
-
import
|
|
28928
|
+
import chalk16 from "chalk";
|
|
28737
28929
|
|
|
28738
28930
|
// src/lib/command-utils.ts
|
|
28739
|
-
import
|
|
28931
|
+
import chalk15 from "chalk";
|
|
28740
28932
|
function formatDate2(dateString) {
|
|
28741
28933
|
return new Date(dateString).toLocaleString();
|
|
28742
28934
|
}
|
|
28743
28935
|
function ensureOrgApiAuthenticated() {
|
|
28744
28936
|
if (!canCallOrgApi()) {
|
|
28745
|
-
console.log(
|
|
28937
|
+
console.log(chalk15.red('Not logged in. Please run "replicas login" first.'));
|
|
28746
28938
|
process.exit(1);
|
|
28747
28939
|
}
|
|
28748
28940
|
}
|
|
@@ -28756,36 +28948,36 @@ async function repositoriesListCommand() {
|
|
|
28756
28948
|
try {
|
|
28757
28949
|
const response = await orgAuthenticatedFetch("/v1/repositories");
|
|
28758
28950
|
if (response.repositories.length === 0) {
|
|
28759
|
-
console.log(
|
|
28951
|
+
console.log(chalk16.yellow("\nNo repositories found.\n"));
|
|
28760
28952
|
return;
|
|
28761
28953
|
}
|
|
28762
|
-
console.log(
|
|
28954
|
+
console.log(chalk16.green(`
|
|
28763
28955
|
Repositories (${response.repositories.length}):
|
|
28764
28956
|
`));
|
|
28765
28957
|
for (const repo of response.repositories) {
|
|
28766
|
-
console.log(
|
|
28767
|
-
console.log(
|
|
28768
|
-
console.log(
|
|
28769
|
-
console.log(
|
|
28958
|
+
console.log(chalk16.white(` ${repo.name}`));
|
|
28959
|
+
console.log(chalk16.gray(` URL: ${repo.url}`));
|
|
28960
|
+
console.log(chalk16.gray(` Default Branch: ${repo.default_branch}`));
|
|
28961
|
+
console.log(chalk16.gray(` Created: ${formatDate2(repo.created_at)}`));
|
|
28770
28962
|
if (repo.github_repository_id) {
|
|
28771
|
-
console.log(
|
|
28963
|
+
console.log(chalk16.gray(` GitHub ID: ${repo.github_repository_id}`));
|
|
28772
28964
|
}
|
|
28773
28965
|
console.log();
|
|
28774
28966
|
}
|
|
28775
28967
|
} catch (error51) {
|
|
28776
|
-
console.error(
|
|
28968
|
+
console.error(chalk16.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28777
28969
|
process.exit(1);
|
|
28778
28970
|
}
|
|
28779
28971
|
}
|
|
28780
28972
|
|
|
28781
28973
|
// src/commands/automation.ts
|
|
28782
|
-
import
|
|
28783
|
-
import
|
|
28974
|
+
import chalk17 from "chalk";
|
|
28975
|
+
import prompts5 from "prompts";
|
|
28784
28976
|
function parseScopeFilter(value) {
|
|
28785
28977
|
if (!value) return void 0;
|
|
28786
28978
|
if (value === "org" || value === "user" || value === "all") return value;
|
|
28787
|
-
console.log(
|
|
28788
|
-
console.log(
|
|
28979
|
+
console.log(chalk17.red(`Invalid --owner: ${value}`));
|
|
28980
|
+
console.log(chalk17.gray("Valid options: org, user, all"));
|
|
28789
28981
|
process.exit(1);
|
|
28790
28982
|
}
|
|
28791
28983
|
function parseAgentProviderOption(value) {
|
|
@@ -28794,8 +28986,8 @@ function parseAgentProviderOption(value) {
|
|
|
28794
28986
|
if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
|
|
28795
28987
|
const lower = trimmed.toLowerCase();
|
|
28796
28988
|
if (!isValidAgentProvider(lower)) {
|
|
28797
|
-
console.log(
|
|
28798
|
-
console.log(
|
|
28989
|
+
console.log(chalk17.red(`Invalid --agent-provider: ${value}`));
|
|
28990
|
+
console.log(chalk17.gray(`Valid options: ${VALID_AGENT_PROVIDERS.join(", ")}, none`));
|
|
28799
28991
|
process.exit(1);
|
|
28800
28992
|
}
|
|
28801
28993
|
return lower;
|
|
@@ -28806,8 +28998,8 @@ function parseThinkingLevelOption(value) {
|
|
|
28806
28998
|
if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
|
|
28807
28999
|
const lower = trimmed.toLowerCase();
|
|
28808
29000
|
if (!isValidThinkingLevel(lower)) {
|
|
28809
|
-
console.log(
|
|
28810
|
-
console.log(
|
|
29001
|
+
console.log(chalk17.red(`Invalid --thinking-level: ${value}`));
|
|
29002
|
+
console.log(chalk17.gray(`Valid options: ${VALID_THINKING_LEVELS.join(", ")}, none`));
|
|
28811
29003
|
process.exit(1);
|
|
28812
29004
|
}
|
|
28813
29005
|
return lower;
|
|
@@ -28824,8 +29016,8 @@ function isWorkspaceLifecyclePolicy(value) {
|
|
|
28824
29016
|
function parseWorkspaceLifecyclePolicyOption(value) {
|
|
28825
29017
|
if (!value) return void 0;
|
|
28826
29018
|
if (isWorkspaceLifecyclePolicy(value)) return value;
|
|
28827
|
-
console.log(
|
|
28828
|
-
console.log(
|
|
29019
|
+
console.log(chalk17.red(`Invalid lifecycle policy: ${value}`));
|
|
29020
|
+
console.log(chalk17.gray(`Valid options: ${VALID_LIFECYCLE_POLICIES.join(", ")}`));
|
|
28829
29021
|
process.exit(1);
|
|
28830
29022
|
}
|
|
28831
29023
|
function parseExcludedActorsOption(value) {
|
|
@@ -28844,7 +29036,7 @@ function withExcludedActors(config3, excludedActors) {
|
|
|
28844
29036
|
}
|
|
28845
29037
|
function parseAutomationLifecycleOptions(options) {
|
|
28846
29038
|
if (options.sleepWhenDone && options.lifecycle && options.lifecycle !== "sleep_when_done") {
|
|
28847
|
-
console.log(
|
|
29039
|
+
console.log(chalk17.red("--sleep-when-done cannot be combined with a different --lifecycle value"));
|
|
28848
29040
|
process.exit(1);
|
|
28849
29041
|
}
|
|
28850
29042
|
if (options.sleepWhenDone) return "sleep_when_done";
|
|
@@ -28853,7 +29045,7 @@ function parseAutomationLifecycleOptions(options) {
|
|
|
28853
29045
|
function applyAgentSelection(body, existing) {
|
|
28854
29046
|
const result = validateAgentSelection(body, existing);
|
|
28855
29047
|
if (!result.ok) {
|
|
28856
|
-
console.log(
|
|
29048
|
+
console.log(chalk17.red(result.error.message));
|
|
28857
29049
|
process.exit(1);
|
|
28858
29050
|
}
|
|
28859
29051
|
const out = {};
|
|
@@ -28894,8 +29086,8 @@ function resolveTriggerRepositoryIds(repositories, repoNamesInput, provider) {
|
|
|
28894
29086
|
for (const repoName of repoNames) {
|
|
28895
29087
|
const repo = providerRepos.find((r) => r.name === repoName);
|
|
28896
29088
|
if (!repo) {
|
|
28897
|
-
console.log(
|
|
28898
|
-
console.log(
|
|
29089
|
+
console.log(chalk17.red(`Repository not found for ${provider} trigger filter: ${repoName}`));
|
|
29090
|
+
console.log(chalk17.gray(`Available: ${providerRepos.map((r) => r.name).join(", ")}`));
|
|
28899
29091
|
process.exit(1);
|
|
28900
29092
|
}
|
|
28901
29093
|
repoIds.push(repo.id);
|
|
@@ -28928,40 +29120,40 @@ function formatModeSummary(automation2) {
|
|
|
28928
29120
|
function resolveSelectableEnvironmentId(envInput, selectableEnvs) {
|
|
28929
29121
|
const resolved = resolveByNameOrId(envInput, selectableEnvs);
|
|
28930
29122
|
if (!resolved) {
|
|
28931
|
-
console.log(
|
|
29123
|
+
console.log(chalk17.red(`Environment not found: ${envInput}`));
|
|
28932
29124
|
const available = selectableEnvs.map((e) => e.name).join(", ");
|
|
28933
|
-
console.log(
|
|
29125
|
+
console.log(chalk17.gray(`Available: ${available || "(none)"}`));
|
|
28934
29126
|
process.exit(1);
|
|
28935
29127
|
}
|
|
28936
29128
|
return resolved.id;
|
|
28937
29129
|
}
|
|
28938
29130
|
function printAutomation(automation2) {
|
|
28939
|
-
console.log(
|
|
28940
|
-
console.log(
|
|
28941
|
-
console.log(
|
|
29131
|
+
console.log(chalk17.white(` ${automation2.name}`));
|
|
29132
|
+
console.log(chalk17.gray(` ID: ${automation2.id}`));
|
|
29133
|
+
console.log(chalk17.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
|
|
28942
29134
|
if (automation2.description) {
|
|
28943
|
-
console.log(
|
|
29135
|
+
console.log(chalk17.gray(` Description: ${automation2.description}`));
|
|
28944
29136
|
}
|
|
28945
|
-
console.log(
|
|
29137
|
+
console.log(chalk17.gray(` Enabled: ${automation2.enabled ? chalk17.green("yes") : chalk17.red("no")}`));
|
|
28946
29138
|
if (automation2.triggers.length > 0) {
|
|
28947
|
-
console.log(
|
|
29139
|
+
console.log(chalk17.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
|
|
28948
29140
|
}
|
|
28949
|
-
console.log(
|
|
29141
|
+
console.log(chalk17.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
|
|
28950
29142
|
if (automation2.cron_next_fire_at) {
|
|
28951
|
-
console.log(
|
|
29143
|
+
console.log(chalk17.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
|
|
28952
29144
|
}
|
|
28953
29145
|
if (automation2.workspace_lifecycle_policy && automation2.workspace_lifecycle_policy !== "default") {
|
|
28954
|
-
console.log(
|
|
29146
|
+
console.log(chalk17.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
|
|
28955
29147
|
}
|
|
28956
29148
|
if (automation2.agent_provider || automation2.model || automation2.thinking_level) {
|
|
28957
|
-
console.log(
|
|
29149
|
+
console.log(chalk17.gray(` Agent: ${formatAgentSummary(automation2)}`));
|
|
28958
29150
|
}
|
|
28959
29151
|
if (automation2.plan_mode || automation2.goal_mode || automation2.fast_mode) {
|
|
28960
|
-
console.log(
|
|
29152
|
+
console.log(chalk17.gray(` Modes: ${formatModeSummary(automation2)}`));
|
|
28961
29153
|
}
|
|
28962
|
-
console.log(
|
|
28963
|
-
console.log(
|
|
28964
|
-
console.log(
|
|
29154
|
+
console.log(chalk17.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? chalk17.green("managed") : "read-only"}`));
|
|
29155
|
+
console.log(chalk17.gray(` Created: ${formatDate2(automation2.created_at)}`));
|
|
29156
|
+
console.log(chalk17.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
|
|
28965
29157
|
console.log();
|
|
28966
29158
|
}
|
|
28967
29159
|
async function automationListCommand(options) {
|
|
@@ -28977,17 +29169,17 @@ async function automationListCommand(options) {
|
|
|
28977
29169
|
`/v1/automations${query ? "?" + query : ""}`
|
|
28978
29170
|
);
|
|
28979
29171
|
if (response.automations.length === 0) {
|
|
28980
|
-
console.log(
|
|
29172
|
+
console.log(chalk17.yellow("\nNo automations found.\n"));
|
|
28981
29173
|
return;
|
|
28982
29174
|
}
|
|
28983
|
-
console.log(
|
|
29175
|
+
console.log(chalk17.green(`
|
|
28984
29176
|
Automations (Page ${response.page} of ${response.totalPages}, Total: ${response.total}):
|
|
28985
29177
|
`));
|
|
28986
29178
|
for (const automation2 of response.automations) {
|
|
28987
29179
|
printAutomation(automation2);
|
|
28988
29180
|
}
|
|
28989
29181
|
} catch (error51) {
|
|
28990
|
-
console.error(
|
|
29182
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
28991
29183
|
process.exit(1);
|
|
28992
29184
|
}
|
|
28993
29185
|
}
|
|
@@ -28996,47 +29188,47 @@ async function automationGetCommand(id) {
|
|
|
28996
29188
|
try {
|
|
28997
29189
|
const response = await orgAuthenticatedFetch(`/v1/automations/${id}`);
|
|
28998
29190
|
const automation2 = response.automation;
|
|
28999
|
-
console.log(
|
|
29191
|
+
console.log(chalk17.green(`
|
|
29000
29192
|
Automation: ${automation2.name}
|
|
29001
29193
|
`));
|
|
29002
|
-
console.log(
|
|
29194
|
+
console.log(chalk17.gray(` ID: ${automation2.id}`));
|
|
29003
29195
|
if (automation2.description) {
|
|
29004
|
-
console.log(
|
|
29196
|
+
console.log(chalk17.gray(` Description: ${automation2.description}`));
|
|
29005
29197
|
}
|
|
29006
|
-
console.log(
|
|
29198
|
+
console.log(chalk17.gray(` Enabled: ${automation2.enabled ? chalk17.green("yes") : chalk17.red("no")}`));
|
|
29007
29199
|
if (automation2.triggers.length > 0) {
|
|
29008
|
-
console.log(
|
|
29200
|
+
console.log(chalk17.gray(` Triggers:`));
|
|
29009
29201
|
for (const trigger of automation2.triggers) {
|
|
29010
|
-
console.log(
|
|
29202
|
+
console.log(chalk17.gray(` - ${formatTrigger(trigger)}`));
|
|
29011
29203
|
}
|
|
29012
29204
|
}
|
|
29013
|
-
console.log(
|
|
29014
|
-
console.log(
|
|
29205
|
+
console.log(chalk17.gray(` Prompt: ${automation2.prompt}`));
|
|
29206
|
+
console.log(chalk17.gray(` Environment: ${automation2.environment_id}`));
|
|
29015
29207
|
if (automation2.cron_expression) {
|
|
29016
|
-
console.log(
|
|
29208
|
+
console.log(chalk17.gray(` Cron: ${automation2.cron_expression}`));
|
|
29017
29209
|
}
|
|
29018
29210
|
if (automation2.cron_timezone) {
|
|
29019
|
-
console.log(
|
|
29211
|
+
console.log(chalk17.gray(` Timezone: ${automation2.cron_timezone}`));
|
|
29020
29212
|
}
|
|
29021
29213
|
if (automation2.cron_next_fire_at) {
|
|
29022
|
-
console.log(
|
|
29214
|
+
console.log(chalk17.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
|
|
29023
29215
|
}
|
|
29024
29216
|
if (automation2.workspace_lifecycle_policy) {
|
|
29025
|
-
console.log(
|
|
29217
|
+
console.log(chalk17.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
|
|
29026
29218
|
}
|
|
29027
29219
|
if (automation2.workspace_auto_stop_minutes) {
|
|
29028
|
-
console.log(
|
|
29029
|
-
}
|
|
29030
|
-
console.log(
|
|
29031
|
-
console.log(
|
|
29032
|
-
console.log(
|
|
29033
|
-
console.log(
|
|
29034
|
-
console.log(
|
|
29035
|
-
console.log(
|
|
29036
|
-
console.log(
|
|
29220
|
+
console.log(chalk17.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
|
|
29221
|
+
}
|
|
29222
|
+
console.log(chalk17.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
|
|
29223
|
+
console.log(chalk17.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
|
|
29224
|
+
console.log(chalk17.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
|
|
29225
|
+
console.log(chalk17.gray(` Modes: ${formatModeSummary(automation2)}`));
|
|
29226
|
+
console.log(chalk17.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
|
|
29227
|
+
console.log(chalk17.gray(` Created: ${formatDate2(automation2.created_at)}`));
|
|
29228
|
+
console.log(chalk17.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
|
|
29037
29229
|
console.log();
|
|
29038
29230
|
} catch (error51) {
|
|
29039
|
-
console.error(
|
|
29231
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
29040
29232
|
process.exit(1);
|
|
29041
29233
|
}
|
|
29042
29234
|
}
|
|
@@ -29044,7 +29236,7 @@ async function promptForTriggers(repositories) {
|
|
|
29044
29236
|
const triggers = [];
|
|
29045
29237
|
let addMore = true;
|
|
29046
29238
|
while (addMore) {
|
|
29047
|
-
const typeResponse = await
|
|
29239
|
+
const typeResponse = await prompts5({
|
|
29048
29240
|
type: "select",
|
|
29049
29241
|
name: "type",
|
|
29050
29242
|
message: "Select trigger type:",
|
|
@@ -29056,14 +29248,14 @@ async function promptForTriggers(repositories) {
|
|
|
29056
29248
|
});
|
|
29057
29249
|
if (!typeResponse.type) return triggers;
|
|
29058
29250
|
if (typeResponse.type === "cron") {
|
|
29059
|
-
const scheduleResponse = await
|
|
29251
|
+
const scheduleResponse = await prompts5({
|
|
29060
29252
|
type: "text",
|
|
29061
29253
|
name: "schedule",
|
|
29062
29254
|
message: 'Enter cron expression (e.g. "0 9 * * 1-5" for weekdays at 9am):',
|
|
29063
29255
|
validate: (value) => value.trim() ? true : "Schedule is required"
|
|
29064
29256
|
});
|
|
29065
29257
|
if (!scheduleResponse.schedule) return triggers;
|
|
29066
|
-
const tzResponse = await
|
|
29258
|
+
const tzResponse = await prompts5({
|
|
29067
29259
|
type: "text",
|
|
29068
29260
|
name: "timezone",
|
|
29069
29261
|
message: "Enter timezone (default: UTC):",
|
|
@@ -29077,7 +29269,7 @@ async function promptForTriggers(repositories) {
|
|
|
29077
29269
|
}
|
|
29078
29270
|
});
|
|
29079
29271
|
} else if (typeResponse.type === "github") {
|
|
29080
|
-
const eventResponse = await
|
|
29272
|
+
const eventResponse = await prompts5({
|
|
29081
29273
|
type: "select",
|
|
29082
29274
|
name: "event",
|
|
29083
29275
|
message: "Select GitHub event:",
|
|
@@ -29087,7 +29279,7 @@ async function promptForTriggers(repositories) {
|
|
|
29087
29279
|
let triggerRepoIds;
|
|
29088
29280
|
const githubRepositories = repositories?.filter((repo) => !repo.provider || repo.provider === "github") ?? [];
|
|
29089
29281
|
if (githubRepositories.length > 0) {
|
|
29090
|
-
const filterResponse = await
|
|
29282
|
+
const filterResponse = await prompts5({
|
|
29091
29283
|
type: "multiselect",
|
|
29092
29284
|
name: "repos",
|
|
29093
29285
|
message: "Filter trigger to specific repositories (press enter to skip for all):",
|
|
@@ -29097,7 +29289,7 @@ async function promptForTriggers(repositories) {
|
|
|
29097
29289
|
triggerRepoIds = filterResponse.repos;
|
|
29098
29290
|
}
|
|
29099
29291
|
}
|
|
29100
|
-
const excludedActorsResponse = await
|
|
29292
|
+
const excludedActorsResponse = await prompts5({
|
|
29101
29293
|
type: "text",
|
|
29102
29294
|
name: "excludedActors",
|
|
29103
29295
|
message: "Exclude GitHub users (comma-separated, optional):"
|
|
@@ -29112,7 +29304,7 @@ async function promptForTriggers(repositories) {
|
|
|
29112
29304
|
}
|
|
29113
29305
|
});
|
|
29114
29306
|
} else if (typeResponse.type === "gitlab") {
|
|
29115
|
-
const eventResponse = await
|
|
29307
|
+
const eventResponse = await prompts5({
|
|
29116
29308
|
type: "select",
|
|
29117
29309
|
name: "event",
|
|
29118
29310
|
message: "Select GitLab event:",
|
|
@@ -29122,7 +29314,7 @@ async function promptForTriggers(repositories) {
|
|
|
29122
29314
|
let triggerRepoIds;
|
|
29123
29315
|
const gitlabRepositories = repositories?.filter((repo) => repo.provider === "gitlab") ?? [];
|
|
29124
29316
|
if (gitlabRepositories.length > 0) {
|
|
29125
|
-
const filterResponse = await
|
|
29317
|
+
const filterResponse = await prompts5({
|
|
29126
29318
|
type: "multiselect",
|
|
29127
29319
|
name: "repos",
|
|
29128
29320
|
message: "Filter trigger to specific GitLab projects (press enter to skip for all):",
|
|
@@ -29132,7 +29324,7 @@ async function promptForTriggers(repositories) {
|
|
|
29132
29324
|
triggerRepoIds = filterResponse.repos;
|
|
29133
29325
|
}
|
|
29134
29326
|
}
|
|
29135
|
-
const excludedActorsResponse = await
|
|
29327
|
+
const excludedActorsResponse = await prompts5({
|
|
29136
29328
|
type: "text",
|
|
29137
29329
|
name: "excludedActors",
|
|
29138
29330
|
message: "Exclude GitLab users (comma-separated, optional):"
|
|
@@ -29147,7 +29339,7 @@ async function promptForTriggers(repositories) {
|
|
|
29147
29339
|
}
|
|
29148
29340
|
});
|
|
29149
29341
|
}
|
|
29150
|
-
const moreResponse = await
|
|
29342
|
+
const moreResponse = await prompts5({
|
|
29151
29343
|
type: "confirm",
|
|
29152
29344
|
name: "more",
|
|
29153
29345
|
message: "Add another trigger?",
|
|
@@ -29161,22 +29353,22 @@ async function automationCreateCommand(name, options) {
|
|
|
29161
29353
|
ensureOrgApiAuthenticated();
|
|
29162
29354
|
const lifecyclePolicy = parseAutomationLifecycleOptions(options);
|
|
29163
29355
|
if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(lifecyclePolicy ?? "default")) {
|
|
29164
|
-
console.log(
|
|
29356
|
+
console.log(chalk17.red("--auto-stop-minutes requires --lifecycle default or delete_after_inactivity"));
|
|
29165
29357
|
process.exit(1);
|
|
29166
29358
|
}
|
|
29167
29359
|
if (options.autoStopMinutes) {
|
|
29168
29360
|
const minutes = parseInt(options.autoStopMinutes, 10);
|
|
29169
29361
|
if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
|
|
29170
|
-
console.log(
|
|
29362
|
+
console.log(chalk17.red("--auto-stop-minutes must be between 3 and 1440"));
|
|
29171
29363
|
process.exit(1);
|
|
29172
29364
|
}
|
|
29173
29365
|
}
|
|
29174
29366
|
if (options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
|
|
29175
|
-
console.log(
|
|
29367
|
+
console.log(chalk17.red("--trigger-github-exclude-users requires --trigger-github"));
|
|
29176
29368
|
process.exit(1);
|
|
29177
29369
|
}
|
|
29178
29370
|
if (options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
|
|
29179
|
-
console.log(
|
|
29371
|
+
console.log(chalk17.red("--trigger-gitlab-exclude-users requires --trigger-gitlab"));
|
|
29180
29372
|
process.exit(1);
|
|
29181
29373
|
}
|
|
29182
29374
|
const agentSelection = applyAgentSelection(
|
|
@@ -29192,35 +29384,35 @@ async function automationCreateCommand(name, options) {
|
|
|
29192
29384
|
const allEnvs = envResponse.environments;
|
|
29193
29385
|
const selectableEnvs = allEnvs.filter((env) => !env.is_global);
|
|
29194
29386
|
if (selectableEnvs.length === 0) {
|
|
29195
|
-
console.log(
|
|
29387
|
+
console.log(chalk17.red("No environments found. Please create an environment first."));
|
|
29196
29388
|
process.exit(1);
|
|
29197
29389
|
}
|
|
29198
29390
|
const repoResponse = await orgAuthenticatedFetch("/v1/repositories");
|
|
29199
29391
|
const repositories = repoResponse.repositories;
|
|
29200
29392
|
let automationName = name;
|
|
29201
29393
|
if (!automationName) {
|
|
29202
|
-
const response2 = await
|
|
29394
|
+
const response2 = await prompts5({
|
|
29203
29395
|
type: "text",
|
|
29204
29396
|
name: "name",
|
|
29205
29397
|
message: "Enter automation name:",
|
|
29206
29398
|
validate: (value) => value.trim() ? true : "Name is required"
|
|
29207
29399
|
});
|
|
29208
29400
|
if (!response2.name) {
|
|
29209
|
-
console.log(
|
|
29401
|
+
console.log(chalk17.yellow("\nCancelled."));
|
|
29210
29402
|
return;
|
|
29211
29403
|
}
|
|
29212
29404
|
automationName = response2.name;
|
|
29213
29405
|
}
|
|
29214
29406
|
let automationPrompt = options.prompt;
|
|
29215
29407
|
if (!automationPrompt) {
|
|
29216
|
-
const response2 = await
|
|
29408
|
+
const response2 = await prompts5({
|
|
29217
29409
|
type: "text",
|
|
29218
29410
|
name: "prompt",
|
|
29219
29411
|
message: "Enter the prompt for this automation:",
|
|
29220
29412
|
validate: (value) => value.trim() ? true : "Prompt is required"
|
|
29221
29413
|
});
|
|
29222
29414
|
if (!response2.prompt) {
|
|
29223
|
-
console.log(
|
|
29415
|
+
console.log(chalk17.yellow("\nCancelled."));
|
|
29224
29416
|
return;
|
|
29225
29417
|
}
|
|
29226
29418
|
automationPrompt = response2.prompt;
|
|
@@ -29229,7 +29421,7 @@ async function automationCreateCommand(name, options) {
|
|
|
29229
29421
|
if (options.environment) {
|
|
29230
29422
|
selectedEnvironmentId = resolveSelectableEnvironmentId(options.environment, selectableEnvs);
|
|
29231
29423
|
} else {
|
|
29232
|
-
const envResponse2 = await
|
|
29424
|
+
const envResponse2 = await prompts5({
|
|
29233
29425
|
type: "select",
|
|
29234
29426
|
name: "env",
|
|
29235
29427
|
message: "Select environment:",
|
|
@@ -29240,7 +29432,7 @@ async function automationCreateCommand(name, options) {
|
|
|
29240
29432
|
}))
|
|
29241
29433
|
});
|
|
29242
29434
|
if (!envResponse2.env) {
|
|
29243
|
-
console.log(
|
|
29435
|
+
console.log(chalk17.yellow("\nCancelled."));
|
|
29244
29436
|
return;
|
|
29245
29437
|
}
|
|
29246
29438
|
selectedEnvironmentId = envResponse2.env;
|
|
@@ -29282,13 +29474,13 @@ async function automationCreateCommand(name, options) {
|
|
|
29282
29474
|
if (triggers.length === 0) {
|
|
29283
29475
|
triggers = await promptForTriggers(repositories.map((r) => ({ id: r.id, name: r.name, provider: r.provider })));
|
|
29284
29476
|
if (triggers.length === 0) {
|
|
29285
|
-
console.log(
|
|
29477
|
+
console.log(chalk17.red("At least one trigger is required."));
|
|
29286
29478
|
process.exit(1);
|
|
29287
29479
|
}
|
|
29288
29480
|
}
|
|
29289
29481
|
let prFollowups = options.prFollowups === true;
|
|
29290
29482
|
if (options.prFollowups === void 0) {
|
|
29291
|
-
const prFollowupsResponse = await
|
|
29483
|
+
const prFollowupsResponse = await prompts5({
|
|
29292
29484
|
type: "confirm",
|
|
29293
29485
|
name: "prFollowups",
|
|
29294
29486
|
message: "Allow PR follow-ups?",
|
|
@@ -29311,25 +29503,25 @@ async function automationCreateCommand(name, options) {
|
|
|
29311
29503
|
...options.fastMode ? { fast_mode: true } : {},
|
|
29312
29504
|
...agentSelection
|
|
29313
29505
|
};
|
|
29314
|
-
console.log(
|
|
29506
|
+
console.log(chalk17.gray("\nCreating automation..."));
|
|
29315
29507
|
const response = await orgAuthenticatedFetch("/v1/automations", {
|
|
29316
29508
|
method: "POST",
|
|
29317
29509
|
body
|
|
29318
29510
|
});
|
|
29319
29511
|
const automation2 = response.automation;
|
|
29320
|
-
console.log(
|
|
29512
|
+
console.log(chalk17.green(`
|
|
29321
29513
|
Created automation: ${automation2.name}`));
|
|
29322
|
-
console.log(
|
|
29323
|
-
console.log(
|
|
29514
|
+
console.log(chalk17.gray(` ID: ${automation2.id}`));
|
|
29515
|
+
console.log(chalk17.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
|
|
29324
29516
|
if (automation2.triggers.length > 0) {
|
|
29325
|
-
console.log(
|
|
29517
|
+
console.log(chalk17.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
|
|
29326
29518
|
}
|
|
29327
29519
|
if (automation2.cron_next_fire_at) {
|
|
29328
|
-
console.log(
|
|
29520
|
+
console.log(chalk17.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
|
|
29329
29521
|
}
|
|
29330
29522
|
console.log();
|
|
29331
29523
|
} catch (error51) {
|
|
29332
|
-
console.error(
|
|
29524
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
29333
29525
|
process.exit(1);
|
|
29334
29526
|
}
|
|
29335
29527
|
}
|
|
@@ -29339,17 +29531,17 @@ async function automationEditCommand(id, options) {
|
|
|
29339
29531
|
if (options.autoStopMinutes) {
|
|
29340
29532
|
const minutes = parseInt(options.autoStopMinutes, 10);
|
|
29341
29533
|
if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
|
|
29342
|
-
console.log(
|
|
29534
|
+
console.log(chalk17.red("--auto-stop-minutes must be between 3 and 1440"));
|
|
29343
29535
|
process.exit(1);
|
|
29344
29536
|
}
|
|
29345
29537
|
}
|
|
29346
29538
|
const replacingTriggers = Boolean(options.triggerCron || options.triggerGithub || options.triggerGitlab);
|
|
29347
29539
|
if (replacingTriggers && options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
|
|
29348
|
-
console.log(
|
|
29540
|
+
console.log(chalk17.red("--trigger-github-exclude-users requires --trigger-github when replacing triggers"));
|
|
29349
29541
|
process.exit(1);
|
|
29350
29542
|
}
|
|
29351
29543
|
if (replacingTriggers && options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
|
|
29352
|
-
console.log(
|
|
29544
|
+
console.log(chalk17.red("--trigger-gitlab-exclude-users requires --trigger-gitlab when replacing triggers"));
|
|
29353
29545
|
process.exit(1);
|
|
29354
29546
|
}
|
|
29355
29547
|
const parsedAgent = {
|
|
@@ -29361,7 +29553,7 @@ async function automationEditCommand(id, options) {
|
|
|
29361
29553
|
const existing = await orgAuthenticatedFetch(`/v1/automations/${id}`);
|
|
29362
29554
|
const autoStopLifecyclePolicy = lifecyclePolicy ?? existing.automation.workspace_lifecycle_policy ?? "default";
|
|
29363
29555
|
if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(autoStopLifecyclePolicy)) {
|
|
29364
|
-
console.log(
|
|
29556
|
+
console.log(chalk17.red("--auto-stop-minutes requires --lifecycle default or delete_after_inactivity"));
|
|
29365
29557
|
process.exit(1);
|
|
29366
29558
|
}
|
|
29367
29559
|
const agentSelection = applyAgentSelection(parsedAgent, {
|
|
@@ -29371,7 +29563,7 @@ async function automationEditCommand(id, options) {
|
|
|
29371
29563
|
const body = {};
|
|
29372
29564
|
const hasOptions = options.name || options.prompt || options.enabled !== void 0 || options.prFollowups !== void 0 || options.triggerCron || options.triggerGithub || options.triggerGitlab || options.environment || options.triggerGithubExcludeUsers !== void 0 || options.triggerGitlabExcludeUsers !== void 0 || options.lifecycle || options.sleepWhenDone || options.autoStopMinutes || options.agentProvider !== void 0 || options.model !== void 0 || options.thinkingLevel !== void 0 || options.planMode !== void 0 || options.goalMode !== void 0 || options.fastMode !== void 0;
|
|
29373
29565
|
if (!hasOptions) {
|
|
29374
|
-
const nameResponse = await
|
|
29566
|
+
const nameResponse = await prompts5({
|
|
29375
29567
|
type: "text",
|
|
29376
29568
|
name: "name",
|
|
29377
29569
|
message: "Automation name:",
|
|
@@ -29380,7 +29572,7 @@ async function automationEditCommand(id, options) {
|
|
|
29380
29572
|
if (nameResponse.name && nameResponse.name !== existing.automation.name) {
|
|
29381
29573
|
body.name = nameResponse.name;
|
|
29382
29574
|
}
|
|
29383
|
-
const promptResponse = await
|
|
29575
|
+
const promptResponse = await prompts5({
|
|
29384
29576
|
type: "text",
|
|
29385
29577
|
name: "prompt",
|
|
29386
29578
|
message: "Prompt:",
|
|
@@ -29389,7 +29581,7 @@ async function automationEditCommand(id, options) {
|
|
|
29389
29581
|
if (promptResponse.prompt && promptResponse.prompt !== existing.automation.prompt) {
|
|
29390
29582
|
body.prompt = promptResponse.prompt;
|
|
29391
29583
|
}
|
|
29392
|
-
const enabledResponse = await
|
|
29584
|
+
const enabledResponse = await prompts5({
|
|
29393
29585
|
type: "confirm",
|
|
29394
29586
|
name: "enabled",
|
|
29395
29587
|
message: "Enabled?",
|
|
@@ -29399,7 +29591,7 @@ async function automationEditCommand(id, options) {
|
|
|
29399
29591
|
body.enabled = enabledResponse.enabled;
|
|
29400
29592
|
}
|
|
29401
29593
|
const existingPrFollowups = existing.automation.config.capabilities?.pr_followups === true;
|
|
29402
|
-
const prFollowupsResponse = await
|
|
29594
|
+
const prFollowupsResponse = await prompts5({
|
|
29403
29595
|
type: "confirm",
|
|
29404
29596
|
name: "prFollowups",
|
|
29405
29597
|
message: "Allow PR follow-ups?",
|
|
@@ -29408,7 +29600,7 @@ async function automationEditCommand(id, options) {
|
|
|
29408
29600
|
if (prFollowupsResponse.prFollowups !== void 0 && prFollowupsResponse.prFollowups !== existingPrFollowups) {
|
|
29409
29601
|
body.config = workspaceConfigWithPrFollowups(existing.automation.config, prFollowupsResponse.prFollowups);
|
|
29410
29602
|
}
|
|
29411
|
-
const editTriggersResponse = await
|
|
29603
|
+
const editTriggersResponse = await prompts5({
|
|
29412
29604
|
type: "confirm",
|
|
29413
29605
|
name: "edit",
|
|
29414
29606
|
message: "Edit triggers?",
|
|
@@ -29492,11 +29684,11 @@ async function automationEditCommand(id, options) {
|
|
|
29492
29684
|
return trigger;
|
|
29493
29685
|
});
|
|
29494
29686
|
if (!matchedGithub) {
|
|
29495
|
-
console.log(
|
|
29687
|
+
console.log(chalk17.red("No existing GitHub trigger found. Pass --trigger-github to create one."));
|
|
29496
29688
|
process.exit(1);
|
|
29497
29689
|
}
|
|
29498
29690
|
if (!matchedGitlab) {
|
|
29499
|
-
console.log(
|
|
29691
|
+
console.log(chalk17.red("No existing GitLab trigger found. Pass --trigger-gitlab to create one."));
|
|
29500
29692
|
process.exit(1);
|
|
29501
29693
|
}
|
|
29502
29694
|
}
|
|
@@ -29520,25 +29712,25 @@ async function automationEditCommand(id, options) {
|
|
|
29520
29712
|
Object.assign(body, agentSelection);
|
|
29521
29713
|
}
|
|
29522
29714
|
if (Object.keys(body).length === 0) {
|
|
29523
|
-
console.log(
|
|
29715
|
+
console.log(chalk17.yellow("\nNo changes made.\n"));
|
|
29524
29716
|
return;
|
|
29525
29717
|
}
|
|
29526
|
-
console.log(
|
|
29718
|
+
console.log(chalk17.gray("\nUpdating automation..."));
|
|
29527
29719
|
const response = await orgAuthenticatedFetch(`/v1/automations/${id}`, {
|
|
29528
29720
|
method: "PATCH",
|
|
29529
29721
|
body
|
|
29530
29722
|
});
|
|
29531
29723
|
const automation2 = response.automation;
|
|
29532
|
-
console.log(
|
|
29724
|
+
console.log(chalk17.green(`
|
|
29533
29725
|
Updated automation: ${automation2.name}`));
|
|
29534
|
-
console.log(
|
|
29535
|
-
console.log(
|
|
29726
|
+
console.log(chalk17.gray(` ID: ${automation2.id}`));
|
|
29727
|
+
console.log(chalk17.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
|
|
29536
29728
|
if (automation2.triggers.length > 0) {
|
|
29537
|
-
console.log(
|
|
29729
|
+
console.log(chalk17.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
|
|
29538
29730
|
}
|
|
29539
29731
|
console.log();
|
|
29540
29732
|
} catch (error51) {
|
|
29541
|
-
console.error(
|
|
29733
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
29542
29734
|
process.exit(1);
|
|
29543
29735
|
}
|
|
29544
29736
|
}
|
|
@@ -29549,12 +29741,12 @@ async function automationRunCommand(id) {
|
|
|
29549
29741
|
const automation2 = existing.automation;
|
|
29550
29742
|
const hasCronTrigger = automation2.triggers.some((t) => t.type === "cron");
|
|
29551
29743
|
if (!hasCronTrigger) {
|
|
29552
|
-
console.log(
|
|
29553
|
-
console.log(
|
|
29744
|
+
console.log(chalk17.red("\nManual run is only allowed for automations with a cron trigger."));
|
|
29745
|
+
console.log(chalk17.gray(`This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
|
|
29554
29746
|
console.log();
|
|
29555
29747
|
process.exit(1);
|
|
29556
29748
|
}
|
|
29557
|
-
console.log(
|
|
29749
|
+
console.log(chalk17.gray(`
|
|
29558
29750
|
Triggering automation "${automation2.name}"...`));
|
|
29559
29751
|
const response = await orgAuthenticatedFetch(
|
|
29560
29752
|
`/v1/automations/${id}/trigger`,
|
|
@@ -29564,20 +29756,20 @@ Triggering automation "${automation2.name}"...`));
|
|
|
29564
29756
|
}
|
|
29565
29757
|
);
|
|
29566
29758
|
if (!response.execution_id) {
|
|
29567
|
-
console.log(
|
|
29759
|
+
console.log(chalk17.red(`
|
|
29568
29760
|
Automation trigger returned no execution ID. The automation may not have started.`));
|
|
29569
29761
|
console.log();
|
|
29570
29762
|
process.exit(1);
|
|
29571
29763
|
}
|
|
29572
|
-
console.log(
|
|
29764
|
+
console.log(chalk17.green(`
|
|
29573
29765
|
Automation triggered successfully.`));
|
|
29574
|
-
console.log(
|
|
29766
|
+
console.log(chalk17.gray(` Execution ID: ${response.execution_id}`));
|
|
29575
29767
|
if (response.workspace_id) {
|
|
29576
|
-
console.log(
|
|
29768
|
+
console.log(chalk17.gray(` Workspace ID: ${response.workspace_id}`));
|
|
29577
29769
|
}
|
|
29578
29770
|
console.log();
|
|
29579
29771
|
} catch (error51) {
|
|
29580
|
-
console.error(
|
|
29772
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
29581
29773
|
process.exit(1);
|
|
29582
29774
|
}
|
|
29583
29775
|
}
|
|
@@ -29587,31 +29779,31 @@ async function automationDeleteCommand(id, options) {
|
|
|
29587
29779
|
const existing = await orgAuthenticatedFetch(`/v1/automations/${id}`);
|
|
29588
29780
|
const automationName = existing.automation.name;
|
|
29589
29781
|
if (!options.force) {
|
|
29590
|
-
const response = await
|
|
29782
|
+
const response = await prompts5({
|
|
29591
29783
|
type: "confirm",
|
|
29592
29784
|
name: "confirm",
|
|
29593
29785
|
message: `Are you sure you want to delete automation "${automationName}" (${id})?`,
|
|
29594
29786
|
initial: false
|
|
29595
29787
|
});
|
|
29596
29788
|
if (!response.confirm) {
|
|
29597
|
-
console.log(
|
|
29789
|
+
console.log(chalk17.yellow("\nCancelled."));
|
|
29598
29790
|
return;
|
|
29599
29791
|
}
|
|
29600
29792
|
}
|
|
29601
29793
|
await orgAuthenticatedFetch(`/v1/automations/${id}`, {
|
|
29602
29794
|
method: "DELETE"
|
|
29603
29795
|
});
|
|
29604
|
-
console.log(
|
|
29796
|
+
console.log(chalk17.green(`
|
|
29605
29797
|
Automation "${automationName}" (${id}) deleted.
|
|
29606
29798
|
`));
|
|
29607
29799
|
} catch (error51) {
|
|
29608
|
-
console.error(
|
|
29800
|
+
console.error(chalk17.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
|
|
29609
29801
|
process.exit(1);
|
|
29610
29802
|
}
|
|
29611
29803
|
}
|
|
29612
29804
|
|
|
29613
29805
|
// src/commands/preview.ts
|
|
29614
|
-
import
|
|
29806
|
+
import chalk18 from "chalk";
|
|
29615
29807
|
|
|
29616
29808
|
// src/lib/agent-api.ts
|
|
29617
29809
|
var MONOLITH_URL3 = process.env.MONOLITH_URL || process.env.REPLICAS_MONOLITH_URL || "https://api.tryreplicas.com";
|
|
@@ -29712,11 +29904,11 @@ async function previewListCommand(workspaceId) {
|
|
|
29712
29904
|
`/v1/workspaces/${workspaceId}/previews`
|
|
29713
29905
|
);
|
|
29714
29906
|
if (result.previews.length === 0) {
|
|
29715
|
-
console.log(
|
|
29907
|
+
console.log(chalk18.dim("No active previews"));
|
|
29716
29908
|
return;
|
|
29717
29909
|
}
|
|
29718
29910
|
for (const preview2 of result.previews) {
|
|
29719
|
-
console.log(` ${
|
|
29911
|
+
console.log(` ${chalk18.cyan(String(preview2.port))} \u2192 ${chalk18.underline(preview2.publicUrl)}`);
|
|
29720
29912
|
}
|
|
29721
29913
|
}
|
|
29722
29914
|
}
|
|
@@ -29729,7 +29921,7 @@ async function previewAddCommand(workspaceId, options) {
|
|
|
29729
29921
|
body: { port: portNum, authenticated: options.authenticated ?? false }
|
|
29730
29922
|
}
|
|
29731
29923
|
);
|
|
29732
|
-
console.log(
|
|
29924
|
+
console.log(chalk18.green(`Preview created: ${result.preview.publicUrl}`));
|
|
29733
29925
|
}
|
|
29734
29926
|
async function previewDeleteCommand(port) {
|
|
29735
29927
|
const portNum = parsePreviewPort(port);
|
|
@@ -29742,7 +29934,7 @@ async function previewRemoveCommand(workspaceId, options) {
|
|
|
29742
29934
|
`/v1/workspaces/${workspaceId}/previews/${portNum}`,
|
|
29743
29935
|
{ method: "DELETE" }
|
|
29744
29936
|
);
|
|
29745
|
-
console.log(
|
|
29937
|
+
console.log(chalk18.green(`Preview deleted on port ${portNum}`));
|
|
29746
29938
|
}
|
|
29747
29939
|
|
|
29748
29940
|
// src/commands/media.ts
|
|
@@ -29878,7 +30070,7 @@ async function mediaListCommand(options) {
|
|
|
29878
30070
|
}
|
|
29879
30071
|
|
|
29880
30072
|
// src/commands/slack.ts
|
|
29881
|
-
import
|
|
30073
|
+
import chalk19 from "chalk";
|
|
29882
30074
|
function getThreadOptions(options) {
|
|
29883
30075
|
const channelId = options.channel || process.env.SLACK_CHANNEL_ID;
|
|
29884
30076
|
const threadTs = options.threadTs || process.env.SLACK_THREAD_TS;
|
|
@@ -29895,10 +30087,10 @@ async function attachThread(request) {
|
|
|
29895
30087
|
method: "POST",
|
|
29896
30088
|
body: request
|
|
29897
30089
|
});
|
|
29898
|
-
console.log(
|
|
29899
|
-
console.log(
|
|
29900
|
-
console.log(
|
|
29901
|
-
console.log(
|
|
30090
|
+
console.log(chalk19.green("Slack thread attached."));
|
|
30091
|
+
console.log(chalk19.gray(` Channel: ${response.thread.channel_id}`));
|
|
30092
|
+
console.log(chalk19.gray(` Thread: ${response.thread.thread_ts}`));
|
|
30093
|
+
console.log(chalk19.gray(` Workspace: ${response.workspace.name} (${response.workspace.id})`));
|
|
29902
30094
|
}
|
|
29903
30095
|
async function slackThreadAttachCommand(options) {
|
|
29904
30096
|
const agentConfig = readAgentConfig();
|
|
@@ -29927,7 +30119,7 @@ async function slackThreadSwitchCommand(workspace, options) {
|
|
|
29927
30119
|
}
|
|
29928
30120
|
|
|
29929
30121
|
// src/commands/service.ts
|
|
29930
|
-
import
|
|
30122
|
+
import chalk20 from "chalk";
|
|
29931
30123
|
import { spawn as spawn3 } from "child_process";
|
|
29932
30124
|
import { closeSync, mkdirSync, openSync, readdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
29933
30125
|
import { homedir } from "os";
|
|
@@ -30070,7 +30262,7 @@ async function serviceListCommand() {
|
|
|
30070
30262
|
return;
|
|
30071
30263
|
}
|
|
30072
30264
|
for (const state of states) {
|
|
30073
|
-
const status = isRunning(state.pid) ?
|
|
30265
|
+
const status = isRunning(state.pid) ? chalk20.green("running") : chalk20.red("stopped");
|
|
30074
30266
|
console.log(`${state.name} ${status} pid ${state.pid} started ${state.startedAt}`);
|
|
30075
30267
|
console.log(` command: ${state.command} (cwd: ${state.cwd})`);
|
|
30076
30268
|
console.log(` logs: ${state.logFile}`);
|
|
@@ -30170,7 +30362,7 @@ import { spawn as spawn5, spawnSync as spawnSync3 } from "child_process";
|
|
|
30170
30362
|
import { createHash as createHash2 } from "crypto";
|
|
30171
30363
|
import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync4, readSync, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
30172
30364
|
import { dirname as dirname3 } from "path";
|
|
30173
|
-
import
|
|
30365
|
+
import chalk21 from "chalk";
|
|
30174
30366
|
|
|
30175
30367
|
// src/commands/computer/desktop.ts
|
|
30176
30368
|
import { spawnSync } from "child_process";
|
|
@@ -31027,7 +31219,7 @@ async function computerInfoCommand() {
|
|
|
31027
31219
|
);
|
|
31028
31220
|
}
|
|
31029
31221
|
console.log(viewerUrl);
|
|
31030
|
-
console.error(
|
|
31222
|
+
console.error(chalk21.dim(`Share this URL with the user to let them watch the desktop live.`));
|
|
31031
31223
|
}
|
|
31032
31224
|
async function computerStatusCommand() {
|
|
31033
31225
|
ensureServicesRunning();
|
|
@@ -31037,13 +31229,13 @@ async function computerStatusCommand() {
|
|
|
31037
31229
|
const r = spawnSync3("pgrep", ["-af", p], { stdio: "pipe" });
|
|
31038
31230
|
const running = r.status === 0 && !!r.stdout?.toString().trim();
|
|
31039
31231
|
const suffix = p === "x11vnc" && bridge ? bridgeStatus(bridge.x11vnc, true) : p === "websockify" && bridge ? bridgeStatus(bridge.websockify, false, true) : "";
|
|
31040
|
-
console.log(` ${running ?
|
|
31232
|
+
console.log(` ${running ? chalk21.green("\u25CF") : chalk21.red("\u25CB")} ${p}${suffix}`);
|
|
31041
31233
|
}
|
|
31042
31234
|
const viewerUrl = await lookupDesktopViewerUrl();
|
|
31043
31235
|
if (viewerUrl) {
|
|
31044
|
-
console.log(` ${
|
|
31236
|
+
console.log(` ${chalk21.cyan("preview")}: ${viewerUrl}`);
|
|
31045
31237
|
} else {
|
|
31046
|
-
console.log(` ${
|
|
31238
|
+
console.log(` ${chalk21.dim("preview: not yet registered (engine registers it at startup)")}`);
|
|
31047
31239
|
}
|
|
31048
31240
|
}
|
|
31049
31241
|
var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
@@ -33029,7 +33221,7 @@ async function computerLaunchCommand(app, args) {
|
|
|
33029
33221
|
}
|
|
33030
33222
|
|
|
33031
33223
|
// src/commands/interactive.ts
|
|
33032
|
-
import
|
|
33224
|
+
import chalk22 from "chalk";
|
|
33033
33225
|
|
|
33034
33226
|
// src/interactive/index.tsx
|
|
33035
33227
|
import { createCliRenderer } from "@opentui/core";
|
|
@@ -35069,7 +35261,7 @@ function ChatArea({
|
|
|
35069
35261
|
|
|
35070
35262
|
// src/interactive/components/WorkspaceInfo.tsx
|
|
35071
35263
|
import React6, { useState as useState5, useMemo as useMemo4, useCallback as useCallback7, useRef as useRef4 } from "react";
|
|
35072
|
-
import
|
|
35264
|
+
import open3 from "open";
|
|
35073
35265
|
import { useKeyboard as useKeyboard4 } from "@opentui/react";
|
|
35074
35266
|
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs8 } from "@opentui/react/jsx-runtime";
|
|
35075
35267
|
var WEB_APP_URL3 = process.env.REPLICAS_WEB_URL || "https://tryreplicas.com";
|
|
@@ -35284,18 +35476,18 @@ function WorkspaceInfo({ status, workspaceName, workspaceId, focused, loading, a
|
|
|
35284
35476
|
if (!item) return;
|
|
35285
35477
|
switch (item.type) {
|
|
35286
35478
|
case "dashboard":
|
|
35287
|
-
|
|
35479
|
+
open3(`${WEB_APP_URL3}/workspaces/${item.workspaceId}`).catch(() => {
|
|
35288
35480
|
});
|
|
35289
35481
|
break;
|
|
35290
35482
|
case "wake":
|
|
35291
35483
|
onWakeWorkspace(item.workspaceId);
|
|
35292
35484
|
break;
|
|
35293
35485
|
case "preview":
|
|
35294
|
-
|
|
35486
|
+
open3(item.url).catch(() => {
|
|
35295
35487
|
});
|
|
35296
35488
|
break;
|
|
35297
35489
|
case "pr":
|
|
35298
|
-
|
|
35490
|
+
open3(item.url).catch(() => {
|
|
35299
35491
|
});
|
|
35300
35492
|
break;
|
|
35301
35493
|
case "diff":
|
|
@@ -36167,14 +36359,14 @@ async function interactiveCommand() {
|
|
|
36167
36359
|
'No organization selected. Please run "replicas org switch" to select an organization.'
|
|
36168
36360
|
);
|
|
36169
36361
|
}
|
|
36170
|
-
console.log(
|
|
36362
|
+
console.log(chalk22.gray("Starting interactive mode..."));
|
|
36171
36363
|
await launchInteractive();
|
|
36172
36364
|
}
|
|
36173
36365
|
|
|
36174
36366
|
// src/commands/environment.ts
|
|
36175
36367
|
import fs5 from "fs";
|
|
36176
|
-
import
|
|
36177
|
-
import
|
|
36368
|
+
import chalk23 from "chalk";
|
|
36369
|
+
import prompts6 from "prompts";
|
|
36178
36370
|
var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
36179
36371
|
function maskValue(value) {
|
|
36180
36372
|
if (value.length <= 4) return "\u2022\u2022\u2022\u2022";
|
|
@@ -36186,38 +36378,38 @@ async function resolveEnvironmentId(input) {
|
|
|
36186
36378
|
const response = await orgAuthenticatedFetch("/v1/environments");
|
|
36187
36379
|
const resolved = resolveByNameOrId(input, response.environments);
|
|
36188
36380
|
if (!resolved) {
|
|
36189
|
-
console.log(
|
|
36381
|
+
console.log(chalk23.red(`Environment not found: ${input}`));
|
|
36190
36382
|
const available = response.environments.map((e) => e.name).join(", ");
|
|
36191
|
-
console.log(
|
|
36383
|
+
console.log(chalk23.gray(`Available: ${available || "(none)"}`));
|
|
36192
36384
|
process.exit(1);
|
|
36193
36385
|
}
|
|
36194
36386
|
return resolved.id;
|
|
36195
36387
|
}
|
|
36196
36388
|
function printEnvironment(env) {
|
|
36197
|
-
console.log(
|
|
36198
|
-
console.log(
|
|
36389
|
+
console.log(chalk23.white(` ${env.name}${env.is_global ? chalk23.gray(" (global)") : ""}`));
|
|
36390
|
+
console.log(chalk23.gray(` ID: ${env.id}`));
|
|
36199
36391
|
if (env.description) {
|
|
36200
|
-
console.log(
|
|
36392
|
+
console.log(chalk23.gray(` Description: ${env.description}`));
|
|
36201
36393
|
}
|
|
36202
36394
|
if (env.repository_id) {
|
|
36203
|
-
console.log(
|
|
36395
|
+
console.log(chalk23.gray(` Repository: ${env.repository_id}`));
|
|
36204
36396
|
} else if (env.repository_set_id) {
|
|
36205
|
-
console.log(
|
|
36397
|
+
console.log(chalk23.gray(` Repository Set: ${env.repository_set_id}`));
|
|
36206
36398
|
}
|
|
36207
36399
|
if (env.variable_count !== void 0) {
|
|
36208
|
-
console.log(
|
|
36400
|
+
console.log(chalk23.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
|
|
36209
36401
|
}
|
|
36210
|
-
console.log(
|
|
36402
|
+
console.log(chalk23.gray(` Updated: ${formatDate2(env.updated_at)}`));
|
|
36211
36403
|
console.log();
|
|
36212
36404
|
}
|
|
36213
36405
|
async function environmentListCommand() {
|
|
36214
36406
|
ensureOrgApiAuthenticated();
|
|
36215
36407
|
const response = await orgAuthenticatedFetch("/v1/environments");
|
|
36216
36408
|
if (response.environments.length === 0) {
|
|
36217
|
-
console.log(
|
|
36409
|
+
console.log(chalk23.yellow("\nNo environments found.\n"));
|
|
36218
36410
|
return;
|
|
36219
36411
|
}
|
|
36220
|
-
console.log(
|
|
36412
|
+
console.log(chalk23.green(`
|
|
36221
36413
|
Environments (${response.environments.length}):
|
|
36222
36414
|
`));
|
|
36223
36415
|
for (const env of response.environments) {
|
|
@@ -36228,7 +36420,7 @@ async function environmentGetCommand(idOrName) {
|
|
|
36228
36420
|
ensureOrgApiAuthenticated();
|
|
36229
36421
|
const id = await resolveEnvironmentId(idOrName);
|
|
36230
36422
|
const response = await orgAuthenticatedFetch(`/v1/environments/${id}`);
|
|
36231
|
-
console.log(
|
|
36423
|
+
console.log(chalk23.green(`
|
|
36232
36424
|
Environment: ${response.environment.name}
|
|
36233
36425
|
`));
|
|
36234
36426
|
printEnvironment(response.environment);
|
|
@@ -36237,14 +36429,14 @@ async function environmentCreateCommand(name, options) {
|
|
|
36237
36429
|
ensureOrgApiAuthenticated();
|
|
36238
36430
|
let envName = name;
|
|
36239
36431
|
if (!envName) {
|
|
36240
|
-
const r = await
|
|
36432
|
+
const r = await prompts6({
|
|
36241
36433
|
type: "text",
|
|
36242
36434
|
name: "name",
|
|
36243
36435
|
message: "Environment name:",
|
|
36244
36436
|
validate: (v) => v.trim() ? true : "Name is required"
|
|
36245
36437
|
});
|
|
36246
36438
|
if (!r.name) {
|
|
36247
|
-
console.log(
|
|
36439
|
+
console.log(chalk23.yellow("\nCancelled."));
|
|
36248
36440
|
return;
|
|
36249
36441
|
}
|
|
36250
36442
|
envName = r.name;
|
|
@@ -36257,8 +36449,8 @@ async function environmentCreateCommand(name, options) {
|
|
|
36257
36449
|
const repos2 = await orgAuthenticatedFetch("/v1/repositories");
|
|
36258
36450
|
const repo = repos2.repositories.find((r) => r.name === options.repository);
|
|
36259
36451
|
if (!repo) {
|
|
36260
|
-
console.log(
|
|
36261
|
-
console.log(
|
|
36452
|
+
console.log(chalk23.red(`Repository not found: ${options.repository}`));
|
|
36453
|
+
console.log(chalk23.gray(`Available: ${repos2.repositories.map((r) => r.name).join(", ")}`));
|
|
36262
36454
|
process.exit(1);
|
|
36263
36455
|
}
|
|
36264
36456
|
repositoryId = repo.id;
|
|
@@ -36266,7 +36458,7 @@ async function environmentCreateCommand(name, options) {
|
|
|
36266
36458
|
} else {
|
|
36267
36459
|
const repos2 = await orgAuthenticatedFetch("/v1/repositories");
|
|
36268
36460
|
if (repos2.repositories.length > 0) {
|
|
36269
|
-
const r = await
|
|
36461
|
+
const r = await prompts6({
|
|
36270
36462
|
type: "select",
|
|
36271
36463
|
name: "repo",
|
|
36272
36464
|
message: "Bind to repository (esc to skip):",
|
|
@@ -36288,9 +36480,9 @@ async function environmentCreateCommand(name, options) {
|
|
|
36288
36480
|
method: "POST",
|
|
36289
36481
|
body
|
|
36290
36482
|
});
|
|
36291
|
-
console.log(
|
|
36483
|
+
console.log(chalk23.green(`
|
|
36292
36484
|
Created environment: ${response.environment.name}`));
|
|
36293
|
-
console.log(
|
|
36485
|
+
console.log(chalk23.gray(` ID: ${response.environment.id}
|
|
36294
36486
|
`));
|
|
36295
36487
|
}
|
|
36296
36488
|
async function environmentEditCommand(idOrName, options) {
|
|
@@ -36309,21 +36501,21 @@ async function environmentEditCommand(idOrName, options) {
|
|
|
36309
36501
|
const repos2 = await orgAuthenticatedFetch("/v1/repositories");
|
|
36310
36502
|
const repo = repos2.repositories.find((r) => r.name === options.repository);
|
|
36311
36503
|
if (!repo) {
|
|
36312
|
-
console.log(
|
|
36504
|
+
console.log(chalk23.red(`Repository not found: ${options.repository}`));
|
|
36313
36505
|
process.exit(1);
|
|
36314
36506
|
}
|
|
36315
36507
|
body.repository_id = repo.id;
|
|
36316
36508
|
}
|
|
36317
36509
|
}
|
|
36318
36510
|
if (Object.keys(body).length === 0) {
|
|
36319
|
-
console.log(
|
|
36511
|
+
console.log(chalk23.yellow("\nNo changes specified. Pass --name, --description, --repository, or --system-prompt."));
|
|
36320
36512
|
return;
|
|
36321
36513
|
}
|
|
36322
36514
|
const response = await orgAuthenticatedFetch(`/v1/environments/${id}`, {
|
|
36323
36515
|
method: "PATCH",
|
|
36324
36516
|
body
|
|
36325
36517
|
});
|
|
36326
|
-
console.log(
|
|
36518
|
+
console.log(chalk23.green(`
|
|
36327
36519
|
Updated environment: ${response.environment.name}
|
|
36328
36520
|
`));
|
|
36329
36521
|
}
|
|
@@ -36331,27 +36523,27 @@ async function environmentDeleteCommand(idOrName, options) {
|
|
|
36331
36523
|
ensureOrgApiAuthenticated();
|
|
36332
36524
|
const id = await resolveEnvironmentId(idOrName);
|
|
36333
36525
|
if (!options.force) {
|
|
36334
|
-
const r = await
|
|
36526
|
+
const r = await prompts6({
|
|
36335
36527
|
type: "confirm",
|
|
36336
36528
|
name: "confirm",
|
|
36337
36529
|
message: `Delete environment ${idOrName}?`,
|
|
36338
36530
|
initial: false
|
|
36339
36531
|
});
|
|
36340
36532
|
if (!r.confirm) {
|
|
36341
|
-
console.log(
|
|
36533
|
+
console.log(chalk23.yellow("\nCancelled."));
|
|
36342
36534
|
return;
|
|
36343
36535
|
}
|
|
36344
36536
|
}
|
|
36345
36537
|
await orgAuthenticatedFetch(`/v1/environments/${id}`, { method: "DELETE" });
|
|
36346
|
-
console.log(
|
|
36538
|
+
console.log(chalk23.green(`
|
|
36347
36539
|
Deleted environment ${idOrName}.
|
|
36348
36540
|
`));
|
|
36349
36541
|
}
|
|
36350
36542
|
function printVariable(v, reveal) {
|
|
36351
|
-
console.log(
|
|
36352
|
-
console.log(
|
|
36353
|
-
console.log(
|
|
36354
|
-
console.log(
|
|
36543
|
+
console.log(chalk23.white(` ${v.key}`));
|
|
36544
|
+
console.log(chalk23.gray(` ID: ${v.id}`));
|
|
36545
|
+
console.log(chalk23.gray(` Value: ${reveal ? v.value : maskValue(v.value)}`));
|
|
36546
|
+
console.log(chalk23.gray(` Updated: ${formatDate2(v.updated_at)}`));
|
|
36355
36547
|
console.log();
|
|
36356
36548
|
}
|
|
36357
36549
|
async function envVarsListCommand(envIdOrName, options) {
|
|
@@ -36361,14 +36553,14 @@ async function envVarsListCommand(envIdOrName, options) {
|
|
|
36361
36553
|
`/v1/environments/${id}/variables`
|
|
36362
36554
|
);
|
|
36363
36555
|
if (response.environment_variables.length === 0) {
|
|
36364
|
-
console.log(
|
|
36556
|
+
console.log(chalk23.yellow("\nNo variables.\n"));
|
|
36365
36557
|
return;
|
|
36366
36558
|
}
|
|
36367
|
-
console.log(
|
|
36559
|
+
console.log(chalk23.green(`
|
|
36368
36560
|
Variables (${response.environment_variables.length}):
|
|
36369
36561
|
`));
|
|
36370
36562
|
if (!options.reveal) {
|
|
36371
|
-
console.log(
|
|
36563
|
+
console.log(chalk23.gray(" Values are masked. Pass --reveal to show full values.\n"));
|
|
36372
36564
|
}
|
|
36373
36565
|
for (const v of response.environment_variables) printVariable(v, !!options.reveal);
|
|
36374
36566
|
}
|
|
@@ -36385,7 +36577,7 @@ async function envVarsSetCommand(envIdOrName, key, value) {
|
|
|
36385
36577
|
`/v1/environments/${id}/variables/${match.id}`,
|
|
36386
36578
|
{ method: "PATCH", body: body2 }
|
|
36387
36579
|
);
|
|
36388
|
-
console.log(
|
|
36580
|
+
console.log(chalk23.green(`
|
|
36389
36581
|
Updated variable ${response2.environment_variable.key}.
|
|
36390
36582
|
`));
|
|
36391
36583
|
return;
|
|
@@ -36399,7 +36591,7 @@ Updated variable ${response2.environment_variable.key}.
|
|
|
36399
36591
|
`/v1/environments/${id}/variables`,
|
|
36400
36592
|
{ method: "POST", body }
|
|
36401
36593
|
);
|
|
36402
|
-
console.log(
|
|
36594
|
+
console.log(chalk23.green(`
|
|
36403
36595
|
Created variable ${response.environment_variable.key}.
|
|
36404
36596
|
`));
|
|
36405
36597
|
}
|
|
@@ -36413,36 +36605,36 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
|
|
|
36413
36605
|
);
|
|
36414
36606
|
const match = existing.environment_variables.find((v) => v.key === keyOrId);
|
|
36415
36607
|
if (!match) {
|
|
36416
|
-
console.log(
|
|
36608
|
+
console.log(chalk23.red(`Variable not found: ${keyOrId}`));
|
|
36417
36609
|
process.exit(1);
|
|
36418
36610
|
}
|
|
36419
36611
|
variableId = match.id;
|
|
36420
36612
|
}
|
|
36421
36613
|
if (!options.force) {
|
|
36422
|
-
const r = await
|
|
36614
|
+
const r = await prompts6({
|
|
36423
36615
|
type: "confirm",
|
|
36424
36616
|
name: "confirm",
|
|
36425
36617
|
message: `Delete variable ${keyOrId}?`,
|
|
36426
36618
|
initial: false
|
|
36427
36619
|
});
|
|
36428
36620
|
if (!r.confirm) {
|
|
36429
|
-
console.log(
|
|
36621
|
+
console.log(chalk23.yellow("\nCancelled."));
|
|
36430
36622
|
return;
|
|
36431
36623
|
}
|
|
36432
36624
|
}
|
|
36433
36625
|
await orgAuthenticatedFetch(`/v1/environments/${id}/variables/${variableId}`, {
|
|
36434
36626
|
method: "DELETE"
|
|
36435
36627
|
});
|
|
36436
|
-
console.log(
|
|
36628
|
+
console.log(chalk23.green(`
|
|
36437
36629
|
Deleted variable ${keyOrId}.
|
|
36438
36630
|
`));
|
|
36439
36631
|
}
|
|
36440
36632
|
function printFile(f) {
|
|
36441
|
-
console.log(
|
|
36442
|
-
console.log(
|
|
36443
|
-
console.log(
|
|
36444
|
-
console.log(
|
|
36445
|
-
console.log(
|
|
36633
|
+
console.log(chalk23.white(` ${f.path}`));
|
|
36634
|
+
console.log(chalk23.gray(` ID: ${f.id}`));
|
|
36635
|
+
console.log(chalk23.gray(` Name: ${f.name}`));
|
|
36636
|
+
console.log(chalk23.gray(` Size: ${f.content.length} bytes`));
|
|
36637
|
+
console.log(chalk23.gray(` Updated: ${formatDate2(f.updated_at)}`));
|
|
36446
36638
|
console.log();
|
|
36447
36639
|
}
|
|
36448
36640
|
async function envFilesListCommand(envIdOrName) {
|
|
@@ -36452,10 +36644,10 @@ async function envFilesListCommand(envIdOrName) {
|
|
|
36452
36644
|
`/v1/environments/${id}/files`
|
|
36453
36645
|
);
|
|
36454
36646
|
if (response.environment_files.length === 0) {
|
|
36455
|
-
console.log(
|
|
36647
|
+
console.log(chalk23.yellow("\nNo files.\n"));
|
|
36456
36648
|
return;
|
|
36457
36649
|
}
|
|
36458
|
-
console.log(
|
|
36650
|
+
console.log(chalk23.green(`
|
|
36459
36651
|
Files (${response.environment_files.length}):
|
|
36460
36652
|
`));
|
|
36461
36653
|
for (const f of response.environment_files) printFile(f);
|
|
@@ -36486,7 +36678,7 @@ async function envFilesSetCommand(envIdOrName, destinationPath, options) {
|
|
|
36486
36678
|
`/v1/environments/${id}/files/${match.id}`,
|
|
36487
36679
|
{ method: "PATCH", body: body2 }
|
|
36488
36680
|
);
|
|
36489
|
-
console.log(
|
|
36681
|
+
console.log(chalk23.green(`
|
|
36490
36682
|
Updated file ${response2.environment_file.path}.
|
|
36491
36683
|
`));
|
|
36492
36684
|
return;
|
|
@@ -36501,7 +36693,7 @@ Updated file ${response2.environment_file.path}.
|
|
|
36501
36693
|
`/v1/environments/${id}/files`,
|
|
36502
36694
|
{ method: "POST", body }
|
|
36503
36695
|
);
|
|
36504
|
-
console.log(
|
|
36696
|
+
console.log(chalk23.green(`
|
|
36505
36697
|
Created file ${response.environment_file.path}.
|
|
36506
36698
|
`));
|
|
36507
36699
|
}
|
|
@@ -36515,27 +36707,27 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
|
|
|
36515
36707
|
);
|
|
36516
36708
|
const match = existing.environment_files.find((f) => f.path === pathOrId);
|
|
36517
36709
|
if (!match) {
|
|
36518
|
-
console.log(
|
|
36710
|
+
console.log(chalk23.red(`File not found: ${pathOrId}`));
|
|
36519
36711
|
process.exit(1);
|
|
36520
36712
|
}
|
|
36521
36713
|
fileId = match.id;
|
|
36522
36714
|
}
|
|
36523
36715
|
if (!options.force) {
|
|
36524
|
-
const r = await
|
|
36716
|
+
const r = await prompts6({
|
|
36525
36717
|
type: "confirm",
|
|
36526
36718
|
name: "confirm",
|
|
36527
36719
|
message: `Delete file ${pathOrId}?`,
|
|
36528
36720
|
initial: false
|
|
36529
36721
|
});
|
|
36530
36722
|
if (!r.confirm) {
|
|
36531
|
-
console.log(
|
|
36723
|
+
console.log(chalk23.yellow("\nCancelled."));
|
|
36532
36724
|
return;
|
|
36533
36725
|
}
|
|
36534
36726
|
}
|
|
36535
36727
|
await orgAuthenticatedFetch(`/v1/environments/${id}/files/${fileId}`, {
|
|
36536
36728
|
method: "DELETE"
|
|
36537
36729
|
});
|
|
36538
|
-
console.log(
|
|
36730
|
+
console.log(chalk23.green(`
|
|
36539
36731
|
Deleted file ${pathOrId}.
|
|
36540
36732
|
`));
|
|
36541
36733
|
}
|
|
@@ -36546,15 +36738,15 @@ async function envStartHookGetCommand(envIdOrName) {
|
|
|
36546
36738
|
`/v1/environments/${id}/start-hooks`
|
|
36547
36739
|
);
|
|
36548
36740
|
if (!response.start_hook) {
|
|
36549
|
-
console.log(
|
|
36741
|
+
console.log(chalk23.yellow("\nNo start hook configured.\n"));
|
|
36550
36742
|
return;
|
|
36551
36743
|
}
|
|
36552
36744
|
const hook = response.start_hook;
|
|
36553
|
-
console.log(
|
|
36745
|
+
console.log(chalk23.green(`
|
|
36554
36746
|
Start hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
|
|
36555
36747
|
`));
|
|
36556
|
-
console.log(
|
|
36557
|
-
console.log(
|
|
36748
|
+
console.log(chalk23.gray(` ID: ${hook.id}`));
|
|
36749
|
+
console.log(chalk23.gray(` Created: ${formatDate2(hook.created_at)}
|
|
36558
36750
|
`));
|
|
36559
36751
|
console.log(hook.content);
|
|
36560
36752
|
console.log();
|
|
@@ -36569,10 +36761,10 @@ async function envStartHookSaveCommand(envIdOrName, options) {
|
|
|
36569
36761
|
{ method: "POST", body }
|
|
36570
36762
|
);
|
|
36571
36763
|
if (!response.start_hook) {
|
|
36572
|
-
console.log(
|
|
36764
|
+
console.log(chalk23.green("\nCleared start hook.\n"));
|
|
36573
36765
|
return;
|
|
36574
36766
|
}
|
|
36575
|
-
console.log(
|
|
36767
|
+
console.log(chalk23.green(`
|
|
36576
36768
|
Saved start hook v${response.start_hook.version}.
|
|
36577
36769
|
`));
|
|
36578
36770
|
}
|
|
@@ -36589,7 +36781,7 @@ async function envStartHookTestCommand(envIdOrName, options) {
|
|
|
36589
36781
|
body: { content },
|
|
36590
36782
|
onEvent: (event) => {
|
|
36591
36783
|
if (event.type === "progress" && event.message) {
|
|
36592
|
-
console.log(
|
|
36784
|
+
console.log(chalk23.gray(event.message));
|
|
36593
36785
|
} else if (event.type === "output" && event.output) {
|
|
36594
36786
|
process.stdout.write(event.output);
|
|
36595
36787
|
} else if (event.type === "complete") {
|
|
@@ -36602,21 +36794,21 @@ async function envStartHookTestCommand(envIdOrName, options) {
|
|
|
36602
36794
|
}
|
|
36603
36795
|
);
|
|
36604
36796
|
if (errorMessage) {
|
|
36605
|
-
console.log(
|
|
36797
|
+
console.log(chalk23.red(`
|
|
36606
36798
|
${errorMessage}
|
|
36607
36799
|
`));
|
|
36608
36800
|
process.exit(1);
|
|
36609
36801
|
}
|
|
36610
36802
|
if (timedOut) {
|
|
36611
|
-
console.log(
|
|
36803
|
+
console.log(chalk23.yellow("\nStart hook timed out.\n"));
|
|
36612
36804
|
process.exit(1);
|
|
36613
36805
|
}
|
|
36614
36806
|
if (exitCode === 0) {
|
|
36615
|
-
console.log(
|
|
36807
|
+
console.log(chalk23.green(`
|
|
36616
36808
|
Start hook passed (exit code ${exitCode}).
|
|
36617
36809
|
`));
|
|
36618
36810
|
} else {
|
|
36619
|
-
console.log(
|
|
36811
|
+
console.log(chalk23.red(`
|
|
36620
36812
|
Start hook failed (exit code ${exitCode ?? "unknown"}).
|
|
36621
36813
|
`));
|
|
36622
36814
|
process.exit(1);
|
|
@@ -36629,24 +36821,24 @@ async function envStartHookRepositoryHooksCommand(envIdOrName) {
|
|
|
36629
36821
|
`/v1/environments/${id}/start-hooks/repository-hooks`
|
|
36630
36822
|
);
|
|
36631
36823
|
if (response.repositories.length === 0) {
|
|
36632
|
-
console.log(
|
|
36824
|
+
console.log(chalk23.yellow("\nNo repositories bound to this environment.\n"));
|
|
36633
36825
|
return;
|
|
36634
36826
|
}
|
|
36635
|
-
console.log(
|
|
36827
|
+
console.log(chalk23.green(`
|
|
36636
36828
|
Repository start hooks (${response.repositories.length}):
|
|
36637
36829
|
`));
|
|
36638
36830
|
for (const repo of response.repositories) {
|
|
36639
|
-
console.log(
|
|
36831
|
+
console.log(chalk23.white(` ${repo.repository_name} @${repo.default_branch}`));
|
|
36640
36832
|
if (repo.error) {
|
|
36641
|
-
console.log(
|
|
36833
|
+
console.log(chalk23.red(` Error: ${repo.error}`));
|
|
36642
36834
|
} else if (repo.start_hook) {
|
|
36643
|
-
console.log(
|
|
36644
|
-
console.log(
|
|
36835
|
+
console.log(chalk23.gray(` Source: ${repo.filename ?? "(unknown)"}`));
|
|
36836
|
+
console.log(chalk23.gray(` Commands (${repo.start_hook.commands.length}):`));
|
|
36645
36837
|
for (const cmd of repo.start_hook.commands) {
|
|
36646
|
-
console.log(
|
|
36838
|
+
console.log(chalk23.gray(` ${cmd}`));
|
|
36647
36839
|
}
|
|
36648
36840
|
} else {
|
|
36649
|
-
console.log(
|
|
36841
|
+
console.log(chalk23.gray(` No startHook defined.`));
|
|
36650
36842
|
}
|
|
36651
36843
|
console.log();
|
|
36652
36844
|
}
|
|
@@ -36668,7 +36860,7 @@ function registerSlackCommands(parent) {
|
|
|
36668
36860
|
await slackThreadAttachCommand(options);
|
|
36669
36861
|
} catch (error51) {
|
|
36670
36862
|
if (error51 instanceof Error) {
|
|
36671
|
-
console.error(
|
|
36863
|
+
console.error(chalk24.red(`
|
|
36672
36864
|
\u2717 ${error51.message}
|
|
36673
36865
|
`));
|
|
36674
36866
|
}
|
|
@@ -36680,7 +36872,7 @@ function registerSlackCommands(parent) {
|
|
|
36680
36872
|
await slackThreadSwitchCommand(workspace, options);
|
|
36681
36873
|
} catch (error51) {
|
|
36682
36874
|
if (error51 instanceof Error) {
|
|
36683
|
-
console.error(
|
|
36875
|
+
console.error(chalk24.red(`
|
|
36684
36876
|
\u2717 ${error51.message}
|
|
36685
36877
|
`));
|
|
36686
36878
|
}
|
|
@@ -36694,7 +36886,7 @@ program.command("login").description("Authenticate with your Replicas account").
|
|
|
36694
36886
|
await loginCommand();
|
|
36695
36887
|
} catch (error51) {
|
|
36696
36888
|
if (error51 instanceof Error) {
|
|
36697
|
-
console.error(
|
|
36889
|
+
console.error(chalk24.red(`
|
|
36698
36890
|
\u2717 ${error51.message}
|
|
36699
36891
|
`));
|
|
36700
36892
|
}
|
|
@@ -36706,7 +36898,7 @@ program.command("init").description("Create a replicas.json or replicas.yaml con
|
|
|
36706
36898
|
initCommand(options);
|
|
36707
36899
|
} catch (error51) {
|
|
36708
36900
|
if (error51 instanceof Error) {
|
|
36709
|
-
console.error(
|
|
36901
|
+
console.error(chalk24.red(`
|
|
36710
36902
|
\u2717 ${error51.message}
|
|
36711
36903
|
`));
|
|
36712
36904
|
}
|
|
@@ -36718,7 +36910,7 @@ program.command("logout").description("Clear stored credentials").action(() => {
|
|
|
36718
36910
|
logoutCommand();
|
|
36719
36911
|
} catch (error51) {
|
|
36720
36912
|
if (error51 instanceof Error) {
|
|
36721
|
-
console.error(
|
|
36913
|
+
console.error(chalk24.red(`
|
|
36722
36914
|
\u2717 ${error51.message}
|
|
36723
36915
|
`));
|
|
36724
36916
|
}
|
|
@@ -36730,31 +36922,31 @@ program.command("whoami").description("Display current authenticated user").acti
|
|
|
36730
36922
|
await whoamiCommand();
|
|
36731
36923
|
} catch (error51) {
|
|
36732
36924
|
if (error51 instanceof Error) {
|
|
36733
|
-
console.error(
|
|
36925
|
+
console.error(chalk24.red(`
|
|
36734
36926
|
\u2717 ${error51.message}
|
|
36735
36927
|
`));
|
|
36736
36928
|
}
|
|
36737
36929
|
process.exit(1);
|
|
36738
36930
|
}
|
|
36739
36931
|
});
|
|
36740
|
-
program.command("codex-auth").description("
|
|
36932
|
+
program.command("codex-auth").description("Connect your Codex credentials to Replicas (personal by default)").option("-u, --user", "Store credentials for your personal account (default)").option("-o, --org", "Share credentials with the whole organization (admins only)").option("-y, --yes", "Skip the destination confirmation prompt").action(async (options) => {
|
|
36741
36933
|
try {
|
|
36742
36934
|
await codexAuthCommand(options);
|
|
36743
36935
|
} catch (error51) {
|
|
36744
36936
|
if (error51 instanceof Error) {
|
|
36745
|
-
console.error(
|
|
36937
|
+
console.error(chalk24.red(`
|
|
36746
36938
|
\u2717 ${error51.message}
|
|
36747
36939
|
`));
|
|
36748
36940
|
}
|
|
36749
36941
|
process.exit(1);
|
|
36750
36942
|
}
|
|
36751
36943
|
});
|
|
36752
|
-
program.command("claude-auth").description("
|
|
36944
|
+
program.command("claude-auth").description("Connect your Claude Code credentials to Replicas (personal by default)").option("-u, --user", "Store credentials for your personal account (default)").option("-o, --org", "Share credentials with the whole organization (admins only)").option("-y, --yes", "Skip the destination confirmation prompt").action(async (options) => {
|
|
36753
36945
|
try {
|
|
36754
36946
|
await claudeAuthCommand(options);
|
|
36755
36947
|
} catch (error51) {
|
|
36756
36948
|
if (error51 instanceof Error) {
|
|
36757
|
-
console.error(
|
|
36949
|
+
console.error(chalk24.red(`
|
|
36758
36950
|
\u2717 ${error51.message}
|
|
36759
36951
|
`));
|
|
36760
36952
|
}
|
|
@@ -36767,7 +36959,7 @@ org.command("switch").description("Switch to a different organization").action(a
|
|
|
36767
36959
|
await orgSwitchCommand();
|
|
36768
36960
|
} catch (error51) {
|
|
36769
36961
|
if (error51 instanceof Error) {
|
|
36770
|
-
console.error(
|
|
36962
|
+
console.error(chalk24.red(`
|
|
36771
36963
|
\u2717 ${error51.message}
|
|
36772
36964
|
`));
|
|
36773
36965
|
}
|
|
@@ -36779,7 +36971,7 @@ org.action(async () => {
|
|
|
36779
36971
|
await orgCommand();
|
|
36780
36972
|
} catch (error51) {
|
|
36781
36973
|
if (error51 instanceof Error) {
|
|
36782
|
-
console.error(
|
|
36974
|
+
console.error(chalk24.red(`
|
|
36783
36975
|
\u2717 ${error51.message}
|
|
36784
36976
|
`));
|
|
36785
36977
|
}
|
|
@@ -36791,7 +36983,7 @@ program.command("connect <workspace-name>").description("Connect to a workspace
|
|
|
36791
36983
|
await connectCommand(workspaceName);
|
|
36792
36984
|
} catch (error51) {
|
|
36793
36985
|
if (error51 instanceof Error) {
|
|
36794
|
-
console.error(
|
|
36986
|
+
console.error(chalk24.red(`
|
|
36795
36987
|
\u2717 ${error51.message}
|
|
36796
36988
|
`));
|
|
36797
36989
|
}
|
|
@@ -36803,7 +36995,7 @@ program.command("code <workspace-name>").description("Open a workspace in VSCode
|
|
|
36803
36995
|
await codeCommand(workspaceName);
|
|
36804
36996
|
} catch (error51) {
|
|
36805
36997
|
if (error51 instanceof Error) {
|
|
36806
|
-
console.error(
|
|
36998
|
+
console.error(chalk24.red(`
|
|
36807
36999
|
\u2717 ${error51.message}
|
|
36808
37000
|
`));
|
|
36809
37001
|
}
|
|
@@ -36816,7 +37008,7 @@ config2.command("get <key>").description("Get a configuration value").action(asy
|
|
|
36816
37008
|
await configGetCommand(key);
|
|
36817
37009
|
} catch (error51) {
|
|
36818
37010
|
if (error51 instanceof Error) {
|
|
36819
|
-
console.error(
|
|
37011
|
+
console.error(chalk24.red(`
|
|
36820
37012
|
\u2717 ${error51.message}
|
|
36821
37013
|
`));
|
|
36822
37014
|
}
|
|
@@ -36828,7 +37020,7 @@ config2.command("set <key> <value>").description("Set a configuration value").ac
|
|
|
36828
37020
|
await configSetCommand(key, value);
|
|
36829
37021
|
} catch (error51) {
|
|
36830
37022
|
if (error51 instanceof Error) {
|
|
36831
|
-
console.error(
|
|
37023
|
+
console.error(chalk24.red(`
|
|
36832
37024
|
\u2717 ${error51.message}
|
|
36833
37025
|
`));
|
|
36834
37026
|
}
|
|
@@ -36840,7 +37032,7 @@ config2.command("list").description("List all configuration values").action(asyn
|
|
|
36840
37032
|
await configListCommand();
|
|
36841
37033
|
} catch (error51) {
|
|
36842
37034
|
if (error51 instanceof Error) {
|
|
36843
|
-
console.error(
|
|
37035
|
+
console.error(chalk24.red(`
|
|
36844
37036
|
\u2717 ${error51.message}
|
|
36845
37037
|
`));
|
|
36846
37038
|
}
|
|
@@ -36852,7 +37044,7 @@ program.command("list").description("List all replicas").option("-p, --page <pag
|
|
|
36852
37044
|
await replicaListCommand(options);
|
|
36853
37045
|
} catch (error51) {
|
|
36854
37046
|
if (error51 instanceof Error) {
|
|
36855
|
-
console.error(
|
|
37047
|
+
console.error(chalk24.red(`
|
|
36856
37048
|
\u2717 ${error51.message}
|
|
36857
37049
|
`));
|
|
36858
37050
|
}
|
|
@@ -36864,7 +37056,7 @@ program.command("get <id>").description("Get replica details by ID").action(asyn
|
|
|
36864
37056
|
await replicaGetCommand(id);
|
|
36865
37057
|
} catch (error51) {
|
|
36866
37058
|
if (error51 instanceof Error) {
|
|
36867
|
-
console.error(
|
|
37059
|
+
console.error(chalk24.red(`
|
|
36868
37060
|
\u2717 ${error51.message}
|
|
36869
37061
|
`));
|
|
36870
37062
|
}
|
|
@@ -36876,7 +37068,7 @@ program.command("create [name]").description("Create a new replica").option("-m,
|
|
|
36876
37068
|
await replicaCreateCommand(name, options);
|
|
36877
37069
|
} catch (error51) {
|
|
36878
37070
|
if (error51 instanceof Error) {
|
|
36879
|
-
console.error(
|
|
37071
|
+
console.error(chalk24.red(`
|
|
36880
37072
|
\u2717 ${error51.message}
|
|
36881
37073
|
`));
|
|
36882
37074
|
}
|
|
@@ -36888,7 +37080,7 @@ program.command("send <id>").description("Send a message to a replica").option("
|
|
|
36888
37080
|
await replicaSendCommand(id, options);
|
|
36889
37081
|
} catch (error51) {
|
|
36890
37082
|
if (error51 instanceof Error) {
|
|
36891
|
-
console.error(
|
|
37083
|
+
console.error(chalk24.red(`
|
|
36892
37084
|
\u2717 ${error51.message}
|
|
36893
37085
|
`));
|
|
36894
37086
|
}
|
|
@@ -36900,7 +37092,7 @@ program.command("delete <id>").description("Delete a replica").option("-f, --for
|
|
|
36900
37092
|
await replicaDeleteCommand(id, options);
|
|
36901
37093
|
} catch (error51) {
|
|
36902
37094
|
if (error51 instanceof Error) {
|
|
36903
|
-
console.error(
|
|
37095
|
+
console.error(chalk24.red(`
|
|
36904
37096
|
\u2717 ${error51.message}
|
|
36905
37097
|
`));
|
|
36906
37098
|
}
|
|
@@ -36912,7 +37104,7 @@ program.command("read <id>").description("Read conversation history of a replica
|
|
|
36912
37104
|
await replicaReadCommand(id, options);
|
|
36913
37105
|
} catch (error51) {
|
|
36914
37106
|
if (error51 instanceof Error) {
|
|
36915
|
-
console.error(
|
|
37107
|
+
console.error(chalk24.red(`
|
|
36916
37108
|
\u2717 ${error51.message}
|
|
36917
37109
|
`));
|
|
36918
37110
|
}
|
|
@@ -36925,7 +37117,7 @@ automation.command("list").description("List all automations").option("-p, --pag
|
|
|
36925
37117
|
await automationListCommand(options);
|
|
36926
37118
|
} catch (error51) {
|
|
36927
37119
|
if (error51 instanceof Error) {
|
|
36928
|
-
console.error(
|
|
37120
|
+
console.error(chalk24.red(`
|
|
36929
37121
|
\u2717 ${error51.message}
|
|
36930
37122
|
`));
|
|
36931
37123
|
}
|
|
@@ -36937,7 +37129,7 @@ automation.command("get <id>").description("Get automation details by ID").actio
|
|
|
36937
37129
|
await automationGetCommand(id);
|
|
36938
37130
|
} catch (error51) {
|
|
36939
37131
|
if (error51 instanceof Error) {
|
|
36940
|
-
console.error(
|
|
37132
|
+
console.error(chalk24.red(`
|
|
36941
37133
|
\u2717 ${error51.message}
|
|
36942
37134
|
`));
|
|
36943
37135
|
}
|
|
@@ -36952,7 +37144,7 @@ automation.command("create [name]").description("Create a new automation").optio
|
|
|
36952
37144
|
});
|
|
36953
37145
|
} catch (error51) {
|
|
36954
37146
|
if (error51 instanceof Error) {
|
|
36955
|
-
console.error(
|
|
37147
|
+
console.error(chalk24.red(`
|
|
36956
37148
|
\u2717 ${error51.message}
|
|
36957
37149
|
`));
|
|
36958
37150
|
}
|
|
@@ -36964,7 +37156,7 @@ automation.command("edit <id>").description("Edit an existing automation").optio
|
|
|
36964
37156
|
await automationEditCommand(id, options);
|
|
36965
37157
|
} catch (error51) {
|
|
36966
37158
|
if (error51 instanceof Error) {
|
|
36967
|
-
console.error(
|
|
37159
|
+
console.error(chalk24.red(`
|
|
36968
37160
|
\u2717 ${error51.message}
|
|
36969
37161
|
`));
|
|
36970
37162
|
}
|
|
@@ -36976,7 +37168,7 @@ automation.command("run <id>").description("Manually trigger an automation (cron
|
|
|
36976
37168
|
await automationRunCommand(id);
|
|
36977
37169
|
} catch (error51) {
|
|
36978
37170
|
if (error51 instanceof Error) {
|
|
36979
|
-
console.error(
|
|
37171
|
+
console.error(chalk24.red(`
|
|
36980
37172
|
\u2717 ${error51.message}
|
|
36981
37173
|
`));
|
|
36982
37174
|
}
|
|
@@ -36988,7 +37180,7 @@ automation.command("delete <id>").description("Delete an automation").option("-f
|
|
|
36988
37180
|
await automationDeleteCommand(id, options);
|
|
36989
37181
|
} catch (error51) {
|
|
36990
37182
|
if (error51 instanceof Error) {
|
|
36991
|
-
console.error(
|
|
37183
|
+
console.error(chalk24.red(`
|
|
36992
37184
|
\u2717 ${error51.message}
|
|
36993
37185
|
`));
|
|
36994
37186
|
}
|
|
@@ -37000,7 +37192,7 @@ automation.action(async () => {
|
|
|
37000
37192
|
await automationListCommand({});
|
|
37001
37193
|
} catch (error51) {
|
|
37002
37194
|
if (error51 instanceof Error) {
|
|
37003
|
-
console.error(
|
|
37195
|
+
console.error(chalk24.red(`
|
|
37004
37196
|
\u2717 ${error51.message}
|
|
37005
37197
|
`));
|
|
37006
37198
|
}
|
|
@@ -37013,7 +37205,7 @@ repos.command("list").description("List all repositories").action(async () => {
|
|
|
37013
37205
|
await repositoriesListCommand();
|
|
37014
37206
|
} catch (error51) {
|
|
37015
37207
|
if (error51 instanceof Error) {
|
|
37016
|
-
console.error(
|
|
37208
|
+
console.error(chalk24.red(`
|
|
37017
37209
|
\u2717 ${error51.message}
|
|
37018
37210
|
`));
|
|
37019
37211
|
}
|
|
@@ -37025,7 +37217,7 @@ repos.action(async () => {
|
|
|
37025
37217
|
await repositoriesListCommand();
|
|
37026
37218
|
} catch (error51) {
|
|
37027
37219
|
if (error51 instanceof Error) {
|
|
37028
|
-
console.error(
|
|
37220
|
+
console.error(chalk24.red(`
|
|
37029
37221
|
\u2717 ${error51.message}
|
|
37030
37222
|
`));
|
|
37031
37223
|
}
|
|
@@ -37038,7 +37230,7 @@ environment.command("list").description("List all environments").action(async ()
|
|
|
37038
37230
|
await environmentListCommand();
|
|
37039
37231
|
} catch (error51) {
|
|
37040
37232
|
if (error51 instanceof Error) {
|
|
37041
|
-
console.error(
|
|
37233
|
+
console.error(chalk24.red(`
|
|
37042
37234
|
\u2717 ${error51.message}
|
|
37043
37235
|
`));
|
|
37044
37236
|
}
|
|
@@ -37050,7 +37242,7 @@ environment.command("get <id-or-name>").description('Get an environment by ID or
|
|
|
37050
37242
|
await environmentGetCommand(idOrName);
|
|
37051
37243
|
} catch (error51) {
|
|
37052
37244
|
if (error51 instanceof Error) {
|
|
37053
|
-
console.error(
|
|
37245
|
+
console.error(chalk24.red(`
|
|
37054
37246
|
\u2717 ${error51.message}
|
|
37055
37247
|
`));
|
|
37056
37248
|
}
|
|
@@ -37062,7 +37254,7 @@ environment.command("create [name]").description("Create a new environment").opt
|
|
|
37062
37254
|
await environmentCreateCommand(name, options);
|
|
37063
37255
|
} catch (error51) {
|
|
37064
37256
|
if (error51 instanceof Error) {
|
|
37065
|
-
console.error(
|
|
37257
|
+
console.error(chalk24.red(`
|
|
37066
37258
|
\u2717 ${error51.message}
|
|
37067
37259
|
`));
|
|
37068
37260
|
}
|
|
@@ -37074,7 +37266,7 @@ environment.command("edit <id-or-name>").description("Edit an environment").opti
|
|
|
37074
37266
|
await environmentEditCommand(idOrName, options);
|
|
37075
37267
|
} catch (error51) {
|
|
37076
37268
|
if (error51 instanceof Error) {
|
|
37077
|
-
console.error(
|
|
37269
|
+
console.error(chalk24.red(`
|
|
37078
37270
|
\u2717 ${error51.message}
|
|
37079
37271
|
`));
|
|
37080
37272
|
}
|
|
@@ -37086,7 +37278,7 @@ environment.command("delete <id-or-name>").description("Delete an environment").
|
|
|
37086
37278
|
await environmentDeleteCommand(idOrName, options);
|
|
37087
37279
|
} catch (error51) {
|
|
37088
37280
|
if (error51 instanceof Error) {
|
|
37089
|
-
console.error(
|
|
37281
|
+
console.error(chalk24.red(`
|
|
37090
37282
|
\u2717 ${error51.message}
|
|
37091
37283
|
`));
|
|
37092
37284
|
}
|
|
@@ -37099,7 +37291,7 @@ envVars.command("list <env>").description("List variables in an environment (val
|
|
|
37099
37291
|
await envVarsListCommand(env, options);
|
|
37100
37292
|
} catch (error51) {
|
|
37101
37293
|
if (error51 instanceof Error) {
|
|
37102
|
-
console.error(
|
|
37294
|
+
console.error(chalk24.red(`
|
|
37103
37295
|
\u2717 ${error51.message}
|
|
37104
37296
|
`));
|
|
37105
37297
|
}
|
|
@@ -37111,7 +37303,7 @@ envVars.command("set <env> <key> <value>").description("Create or update a varia
|
|
|
37111
37303
|
await envVarsSetCommand(env, key, value);
|
|
37112
37304
|
} catch (error51) {
|
|
37113
37305
|
if (error51 instanceof Error) {
|
|
37114
|
-
console.error(
|
|
37306
|
+
console.error(chalk24.red(`
|
|
37115
37307
|
\u2717 ${error51.message}
|
|
37116
37308
|
`));
|
|
37117
37309
|
}
|
|
@@ -37123,7 +37315,7 @@ envVars.command("delete <env> <key-or-id>").description("Delete a variable by ke
|
|
|
37123
37315
|
await envVarsDeleteCommand(env, keyOrId, options);
|
|
37124
37316
|
} catch (error51) {
|
|
37125
37317
|
if (error51 instanceof Error) {
|
|
37126
|
-
console.error(
|
|
37318
|
+
console.error(chalk24.red(`
|
|
37127
37319
|
\u2717 ${error51.message}
|
|
37128
37320
|
`));
|
|
37129
37321
|
}
|
|
@@ -37136,7 +37328,7 @@ envFiles.command("list <env>").description("List files in an environment").actio
|
|
|
37136
37328
|
await envFilesListCommand(env);
|
|
37137
37329
|
} catch (error51) {
|
|
37138
37330
|
if (error51 instanceof Error) {
|
|
37139
|
-
console.error(
|
|
37331
|
+
console.error(chalk24.red(`
|
|
37140
37332
|
\u2717 ${error51.message}
|
|
37141
37333
|
`));
|
|
37142
37334
|
}
|
|
@@ -37148,7 +37340,7 @@ envFiles.command("set <env> <destination-path>").description("Create or update a
|
|
|
37148
37340
|
await envFilesSetCommand(env, destinationPath, options);
|
|
37149
37341
|
} catch (error51) {
|
|
37150
37342
|
if (error51 instanceof Error) {
|
|
37151
|
-
console.error(
|
|
37343
|
+
console.error(chalk24.red(`
|
|
37152
37344
|
\u2717 ${error51.message}
|
|
37153
37345
|
`));
|
|
37154
37346
|
}
|
|
@@ -37160,7 +37352,7 @@ envFiles.command("delete <env> <path-or-id>").description("Delete a file by dest
|
|
|
37160
37352
|
await envFilesDeleteCommand(env, pathOrId, options);
|
|
37161
37353
|
} catch (error51) {
|
|
37162
37354
|
if (error51 instanceof Error) {
|
|
37163
|
-
console.error(
|
|
37355
|
+
console.error(chalk24.red(`
|
|
37164
37356
|
\u2717 ${error51.message}
|
|
37165
37357
|
`));
|
|
37166
37358
|
}
|
|
@@ -37173,7 +37365,7 @@ envStartHooks.command("get <env>").description("Show the active start hook for a
|
|
|
37173
37365
|
await envStartHookGetCommand(env);
|
|
37174
37366
|
} catch (error51) {
|
|
37175
37367
|
if (error51 instanceof Error) {
|
|
37176
|
-
console.error(
|
|
37368
|
+
console.error(chalk24.red(`
|
|
37177
37369
|
\u2717 ${error51.message}
|
|
37178
37370
|
`));
|
|
37179
37371
|
}
|
|
@@ -37185,7 +37377,7 @@ envStartHooks.command("save <env>").description("Save and activate a start hook
|
|
|
37185
37377
|
await envStartHookSaveCommand(env, options);
|
|
37186
37378
|
} catch (error51) {
|
|
37187
37379
|
if (error51 instanceof Error) {
|
|
37188
|
-
console.error(
|
|
37380
|
+
console.error(chalk24.red(`
|
|
37189
37381
|
\u2717 ${error51.message}
|
|
37190
37382
|
`));
|
|
37191
37383
|
}
|
|
@@ -37197,7 +37389,7 @@ envStartHooks.command("test <env>").description("Run a start hook in an isolated
|
|
|
37197
37389
|
await envStartHookTestCommand(env, options);
|
|
37198
37390
|
} catch (error51) {
|
|
37199
37391
|
if (error51 instanceof Error) {
|
|
37200
|
-
console.error(
|
|
37392
|
+
console.error(chalk24.red(`
|
|
37201
37393
|
\u2717 ${error51.message}
|
|
37202
37394
|
`));
|
|
37203
37395
|
}
|
|
@@ -37209,7 +37401,7 @@ envStartHooks.command("repository-hooks <env>").description("List per-repo start
|
|
|
37209
37401
|
await envStartHookRepositoryHooksCommand(env);
|
|
37210
37402
|
} catch (error51) {
|
|
37211
37403
|
if (error51 instanceof Error) {
|
|
37212
|
-
console.error(
|
|
37404
|
+
console.error(chalk24.red(`
|
|
37213
37405
|
\u2717 ${error51.message}
|
|
37214
37406
|
`));
|
|
37215
37407
|
}
|
|
@@ -37221,7 +37413,7 @@ environment.action(async () => {
|
|
|
37221
37413
|
await environmentListCommand();
|
|
37222
37414
|
} catch (error51) {
|
|
37223
37415
|
if (error51 instanceof Error) {
|
|
37224
|
-
console.error(
|
|
37416
|
+
console.error(chalk24.red(`
|
|
37225
37417
|
\u2717 ${error51.message}
|
|
37226
37418
|
`));
|
|
37227
37419
|
}
|
|
@@ -37233,7 +37425,7 @@ program.command("interact").alias("i").description("Launch the interactive termi
|
|
|
37233
37425
|
await interactiveCommand();
|
|
37234
37426
|
} catch (error51) {
|
|
37235
37427
|
if (error51 instanceof Error) {
|
|
37236
|
-
console.error(
|
|
37428
|
+
console.error(chalk24.red(`
|
|
37237
37429
|
\u2717 ${error51.message}
|
|
37238
37430
|
`));
|
|
37239
37431
|
}
|
|
@@ -37284,7 +37476,7 @@ if (isAgentMode()) {
|
|
|
37284
37476
|
await previewAddCommand(workspaceId, options);
|
|
37285
37477
|
} catch (error51) {
|
|
37286
37478
|
if (error51 instanceof Error) {
|
|
37287
|
-
console.error(
|
|
37479
|
+
console.error(chalk24.red(`
|
|
37288
37480
|
\u2717 ${error51.message}
|
|
37289
37481
|
`));
|
|
37290
37482
|
}
|
|
@@ -37296,7 +37488,7 @@ if (isAgentMode()) {
|
|
|
37296
37488
|
await previewListCommand(workspaceId);
|
|
37297
37489
|
} catch (error51) {
|
|
37298
37490
|
if (error51 instanceof Error) {
|
|
37299
|
-
console.error(
|
|
37491
|
+
console.error(chalk24.red(`
|
|
37300
37492
|
\u2717 ${error51.message}
|
|
37301
37493
|
`));
|
|
37302
37494
|
}
|
|
@@ -37308,7 +37500,7 @@ if (isAgentMode()) {
|
|
|
37308
37500
|
await previewRemoveCommand(workspaceId, options);
|
|
37309
37501
|
} catch (error51) {
|
|
37310
37502
|
if (error51 instanceof Error) {
|
|
37311
|
-
console.error(
|
|
37503
|
+
console.error(chalk24.red(`
|
|
37312
37504
|
\u2717 ${error51.message}
|
|
37313
37505
|
`));
|
|
37314
37506
|
}
|
|
@@ -37369,7 +37561,7 @@ if (isAgentMode()) {
|
|
|
37369
37561
|
await mediaUploadCommand(files, options);
|
|
37370
37562
|
} catch (error51) {
|
|
37371
37563
|
if (error51 instanceof Error) {
|
|
37372
|
-
console.error(
|
|
37564
|
+
console.error(chalk24.red(`
|
|
37373
37565
|
\u2717 ${error51.message}
|
|
37374
37566
|
`));
|
|
37375
37567
|
}
|
|
@@ -37380,7 +37572,7 @@ if (isAgentMode()) {
|
|
|
37380
37572
|
try {
|
|
37381
37573
|
await mediaShareCommand(mediaId);
|
|
37382
37574
|
} catch (error51) {
|
|
37383
|
-
if (error51 instanceof Error) console.error(
|
|
37575
|
+
if (error51 instanceof Error) console.error(chalk24.red(`
|
|
37384
37576
|
\u2717 ${error51.message}
|
|
37385
37577
|
`));
|
|
37386
37578
|
process.exit(1);
|
|
@@ -37390,7 +37582,7 @@ if (isAgentMode()) {
|
|
|
37390
37582
|
try {
|
|
37391
37583
|
await mediaRevokeCommand(mediaId);
|
|
37392
37584
|
} catch (error51) {
|
|
37393
|
-
if (error51 instanceof Error) console.error(
|
|
37585
|
+
if (error51 instanceof Error) console.error(chalk24.red(`
|
|
37394
37586
|
\u2717 ${error51.message}
|
|
37395
37587
|
`));
|
|
37396
37588
|
process.exit(1);
|
|
@@ -37401,7 +37593,7 @@ if (isAgentMode()) {
|
|
|
37401
37593
|
await mediaListCommand(options);
|
|
37402
37594
|
} catch (error51) {
|
|
37403
37595
|
if (error51 instanceof Error) {
|
|
37404
|
-
console.error(
|
|
37596
|
+
console.error(chalk24.red(`
|
|
37405
37597
|
\u2717 ${error51.message}
|
|
37406
37598
|
`));
|
|
37407
37599
|
}
|
|
@@ -37414,7 +37606,7 @@ if (isAgentMode()) {
|
|
|
37414
37606
|
await learningsReadCommand(options);
|
|
37415
37607
|
} catch (error51) {
|
|
37416
37608
|
if (error51 instanceof Error) {
|
|
37417
|
-
console.error(
|
|
37609
|
+
console.error(chalk24.red(`
|
|
37418
37610
|
\u2717 ${error51.message}
|
|
37419
37611
|
`));
|
|
37420
37612
|
}
|
|
@@ -37426,7 +37618,7 @@ if (isAgentMode()) {
|
|
|
37426
37618
|
await learningsAddCommand(options);
|
|
37427
37619
|
} catch (error51) {
|
|
37428
37620
|
if (error51 instanceof Error) {
|
|
37429
|
-
console.error(
|
|
37621
|
+
console.error(chalk24.red(`
|
|
37430
37622
|
\u2717 ${error51.message}
|
|
37431
37623
|
`));
|
|
37432
37624
|
}
|
|
@@ -37438,7 +37630,7 @@ if (isAgentMode()) {
|
|
|
37438
37630
|
await learningsUpdateCommand(id, options);
|
|
37439
37631
|
} catch (error51) {
|
|
37440
37632
|
if (error51 instanceof Error) {
|
|
37441
|
-
console.error(
|
|
37633
|
+
console.error(chalk24.red(`
|
|
37442
37634
|
\u2717 ${error51.message}
|
|
37443
37635
|
`));
|
|
37444
37636
|
}
|
|
@@ -37450,7 +37642,7 @@ if (isAgentMode()) {
|
|
|
37450
37642
|
await learningsDeleteCommand(id);
|
|
37451
37643
|
} catch (error51) {
|
|
37452
37644
|
if (error51 instanceof Error) {
|
|
37453
|
-
console.error(
|
|
37645
|
+
console.error(chalk24.red(`
|
|
37454
37646
|
\u2717 ${error51.message}
|
|
37455
37647
|
`));
|
|
37456
37648
|
}
|
|
@@ -37462,7 +37654,7 @@ if (isAgentMode()) {
|
|
|
37462
37654
|
await learningsWithdrawCommand(id);
|
|
37463
37655
|
} catch (error51) {
|
|
37464
37656
|
if (error51 instanceof Error) {
|
|
37465
|
-
console.error(
|
|
37657
|
+
console.error(chalk24.red(`
|
|
37466
37658
|
\u2717 ${error51.message}
|
|
37467
37659
|
`));
|
|
37468
37660
|
}
|
|
@@ -37475,7 +37667,7 @@ if (isAgentMode()) {
|
|
|
37475
37667
|
await fn(...args);
|
|
37476
37668
|
} catch (error51) {
|
|
37477
37669
|
if (error51 instanceof Error) {
|
|
37478
|
-
console.error(
|
|
37670
|
+
console.error(chalk24.red(`
|
|
37479
37671
|
\u2717 ${error51.message}
|
|
37480
37672
|
`));
|
|
37481
37673
|
}
|
|
@@ -37490,9 +37682,9 @@ if (isAgentMode()) {
|
|
|
37490
37682
|
computer.command("browser-state <path>").description("Wait for a Chrome page to settle, capture its viewport, and print a bounded accessibility state with actionable refs.").option("--full", "Return the full accessibility tree instead of a diff from the previous state").option("--limit <chars>", "Maximum visible text characters. Default 8000.").option("--element-limit <n>", "Maximum actionable elements. Default 120.").option("--timeout <ms>", "Maximum time to wait for state stability. Default 5000.").option("--stable-ms <ms>", "Required unchanged time before capture. Default 500.").option("--poll-ms <ms>", "State polling interval. Default 100.").option("--target-id <id>", "Target the Chrome page with this stable target id").option("--page <n>", "When multiple pages match, target the nth page. Default 0.").option("--title <text>", "Only target pages whose title contains text").option("--url <text>", "Only target pages whose URL contains text").action(wrap((path6, options) => computerBrowserStateCommand(path6, options)));
|
|
37491
37683
|
computer.command("browser-batch <actions>").description("Run an ordered, fail-fast JSON array of browser actions through one Chrome session.").option("--target-id <id>", "Target the Chrome page with this stable target id").option("--page <n>", "When multiple pages match, target the nth page. Default 0.").option("--title <text>", "Only target pages whose title contains text").option("--url <text>", "Only target pages whose URL contains text").action(wrap((actions, options) => computerBrowserBatchCommand(actions, options)));
|
|
37492
37684
|
computer.command("browser-click [text]").description("Click a Chrome element by ref from browser-state, or fall back to visible control text.").option("--ref <id>", "Click the backend DOM node ref from the latest browser state").option("--exact", "Require an exact text match instead of substring matching").option("--index <n>", "When multiple controls match, click the nth match. Default 0.").option("--button <button>", "Mouse button for ref clicks: left, middle, or right. Default left.").option("--double", "Double-click a ref target").option("--target-id <id>", "Only target the Chrome page with this target id").option("--page <n>", "When multiple pages match, target the nth page. Default 0.").option("--title <text>", "Only target pages whose title contains text").option("--url <text>", "Only target pages whose URL contains text").action(wrap((text, options) => computerBrowserClickCommand(text, options)));
|
|
37493
|
-
computer.command("browser-fill [field] [value]").description("Fill a Chrome field by ref from browser-state, or fall back to visible field text.").option("--ref <id>", "Fill the backend DOM node ref from the latest browser state").option("--exact", "Require an exact field match instead of substring matching").option("--index <n>", "When multiple fields match, fill the nth match. Default 0.").option("--target-id <id>", "Only target the Chrome page with this target id").option("--page <n>", "When multiple pages match, target the nth page. Default 0.").option("--title <text>", "Only target pages whose title contains text").option("--url <text>", "Only target pages whose URL contains text").action(wrap((
|
|
37494
|
-
const resolvedValue = value ?? (options.ref ?
|
|
37495
|
-
const resolvedField = value === void 0 && options.ref ? void 0 :
|
|
37685
|
+
computer.command("browser-fill [field] [value]").description("Fill a Chrome field by ref from browser-state, or fall back to visible field text.").option("--ref <id>", "Fill the backend DOM node ref from the latest browser state").option("--exact", "Require an exact field match instead of substring matching").option("--index <n>", "When multiple fields match, fill the nth match. Default 0.").option("--target-id <id>", "Only target the Chrome page with this target id").option("--page <n>", "When multiple pages match, target the nth page. Default 0.").option("--title <text>", "Only target pages whose title contains text").option("--url <text>", "Only target pages whose URL contains text").action(wrap((field2, value, options) => {
|
|
37686
|
+
const resolvedValue = value ?? (options.ref ? field2 : void 0);
|
|
37687
|
+
const resolvedField = value === void 0 && options.ref ? void 0 : field2;
|
|
37496
37688
|
if (resolvedValue === void 0) throw new Error("Provide <field> <value>, or --ref <id> <value>");
|
|
37497
37689
|
return computerBrowserFillCommand(resolvedField, resolvedValue, options);
|
|
37498
37690
|
}));
|
|
@@ -37531,7 +37723,7 @@ if (isAgentMode()) {
|
|
|
37531
37723
|
cmds.push(...kept);
|
|
37532
37724
|
}
|
|
37533
37725
|
async function main() {
|
|
37534
|
-
|
|
37726
|
+
startUpdateCheck(CLI_VERSION);
|
|
37535
37727
|
program.parse();
|
|
37536
37728
|
}
|
|
37537
37729
|
main().catch(() => {
|