replicas-cli 0.2.419 → 0.2.420

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