replicas-cli 0.2.585 → 0.2.587

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.cjs +448 -400
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7362,10 +7362,10 @@ var require_dist = __commonJS({
7362
7362
  });
7363
7363
 
7364
7364
  // src/index.ts
7365
- var import_config21 = require("dotenv/config");
7365
+ var import_config22 = require("dotenv/config");
7366
7366
  var import_node_child_process2 = require("child_process");
7367
7367
  var import_commander = require("commander");
7368
- var import_chalk22 = __toESM(require("chalk"));
7368
+ var import_chalk23 = __toESM(require("chalk"));
7369
7369
 
7370
7370
  // src/commands/login.ts
7371
7371
  var import_http = __toESM(require("http"));
@@ -22696,6 +22696,17 @@ var PLANS = {
22696
22696
  var TEAM_PLAN = PLANS.team;
22697
22697
  var ENTERPRISE_PLAN = PLANS.enterprise;
22698
22698
 
22699
+ // ../shared/src/port.ts
22700
+ function isValidPort(port) {
22701
+ return Number.isInteger(port) && Number(port) >= 1 && Number(port) <= 65535;
22702
+ }
22703
+ function parsePort(port) {
22704
+ if (!/^\d+$/.test(port)) throw new Error("Port must be a number between 1 and 65535");
22705
+ const portNumber = Number(port);
22706
+ if (!isValidPort(portNumber)) throw new Error("Port must be a number between 1 and 65535");
22707
+ return portNumber;
22708
+ }
22709
+
22699
22710
  // ../shared/src/models-dev.ts
22700
22711
  var MODELS_DEV_CACHE_MS = 5 * 6e4;
22701
22712
  var modelsDevCatalogSchema = external_exports.record(external_exports.string(), external_exports.object({
@@ -24472,7 +24483,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
24472
24483
  });
24473
24484
 
24474
24485
  // ../shared/src/cli-version.ts
24475
- var CLI_VERSION = "0.2.585";
24486
+ var CLI_VERSION = "0.2.587";
24476
24487
 
24477
24488
  // ../shared/src/version.ts
24478
24489
  function compareVersions(v1, v2) {
@@ -27888,14 +27899,33 @@ var import_chalk6 = __toESM(require("chalk"));
27888
27899
  // src/lib/ssh.ts
27889
27900
  var import_child_process = require("child_process");
27890
27901
  var SSH_OPTIONS = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"];
27891
- async function connectSSH(token, host, proxyCommand) {
27902
+ function buildSSHArgs(token, host, proxyCommand, localForward) {
27903
+ return [
27904
+ ...SSH_OPTIONS,
27905
+ ...proxyCommand ? ["-o", `ProxyCommand=${proxyCommand}`] : [],
27906
+ ...localForward ? [
27907
+ "-N",
27908
+ "-o",
27909
+ "ExitOnForwardFailure=yes",
27910
+ "-o",
27911
+ "ServerAliveInterval=30",
27912
+ "-L",
27913
+ `127.0.0.1:${localForward.localPort}:127.0.0.1:${localForward.remotePort}`
27914
+ ] : [],
27915
+ `${token}@${host}`
27916
+ ];
27917
+ }
27918
+ async function connectSSH(token, host, proxyCommand, localForward) {
27892
27919
  return new Promise((resolve2, reject) => {
27893
- const sshArgs = proxyCommand ? [...SSH_OPTIONS, "-o", `ProxyCommand=${proxyCommand}`, `${token}@${host}`] : [...SSH_OPTIONS, `${token}@${host}`];
27894
- const ssh = (0, import_child_process.spawn)("ssh", sshArgs, {
27920
+ const ssh = (0, import_child_process.spawn)("ssh", buildSSHArgs(token, host, proxyCommand, localForward), {
27895
27921
  stdio: "inherit"
27896
27922
  });
27897
- ssh.on("close", () => {
27898
- resolve2();
27923
+ ssh.on("close", (code) => {
27924
+ if (localForward && code) {
27925
+ reject(new Error(`SSH tunnel exited with code ${code}`));
27926
+ } else {
27927
+ resolve2();
27928
+ }
27899
27929
  });
27900
27930
  ssh.on("error", reject);
27901
27931
  });
@@ -28239,26 +28269,41 @@ Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28239
28269
  }
28240
28270
  }
28241
28271
 
28242
- // src/commands/org.ts
28272
+ // src/commands/tunnel.ts
28243
28273
  var import_chalk8 = __toESM(require("chalk"));
28274
+ async function tunnelCommand(workspaceName, options) {
28275
+ if (!isAuthenticated()) {
28276
+ throw new Error('Not logged in. Please run "replicas login" first.');
28277
+ }
28278
+ const remotePort = parsePort(options.port);
28279
+ const localPort = options.localPort ? parsePort(options.localPort) : remotePort;
28280
+ const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
28281
+ console.log(import_chalk8.default.green(`
28282
+ \u2713 Forwarding localhost:${localPort} to ${workspace.name}:${remotePort}`));
28283
+ console.log(import_chalk8.default.gray(" Press Ctrl+C to stop.\n"));
28284
+ await connectSSH(sshToken, sshHost, sshProxyCommand, { localPort, remotePort });
28285
+ }
28286
+
28287
+ // src/commands/org.ts
28288
+ var import_chalk9 = __toESM(require("chalk"));
28244
28289
  async function orgCommand() {
28245
28290
  if (!isAuthenticated()) {
28246
- console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
28291
+ console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
28247
28292
  process.exit(1);
28248
28293
  }
28249
28294
  try {
28250
28295
  const currentOrgId = getConfirmedOrganizationId();
28251
28296
  const organizations = await fetchOrganizations();
28252
28297
  if (!currentOrgId) {
28253
- console.log(import_chalk8.default.yellow("\n No organization selected."));
28254
- console.log(import_chalk8.default.gray(' Run "replicas org switch" to select one.\n'));
28298
+ console.log(import_chalk9.default.yellow("\n No organization selected."));
28299
+ console.log(import_chalk9.default.gray(' Run "replicas org switch" to select one.\n'));
28255
28300
  return;
28256
28301
  }
28257
28302
  const currentOrg = organizations.find((org2) => org2.id === currentOrgId);
28258
28303
  if (!currentOrg) {
28259
28304
  clearOrganizationId();
28260
- console.log(import_chalk8.default.yellow("\n The selected organization is no longer available to you."));
28261
- console.log(import_chalk8.default.gray(' Run "replicas org switch" to select another.\n'));
28305
+ console.log(import_chalk9.default.yellow("\n The selected organization is no longer available to you."));
28306
+ console.log(import_chalk9.default.gray(' Run "replicas org switch" to select another.\n'));
28262
28307
  return;
28263
28308
  }
28264
28309
  const [account, role] = await Promise.all([
@@ -28269,26 +28314,26 @@ async function orgCommand() {
28269
28314
  renderIdentity({ account, role, organizationName: currentOrg.name });
28270
28315
  if (organizations.length > 1) {
28271
28316
  console.log(
28272
- import_chalk8.default.gray(`
28317
+ import_chalk9.default.gray(`
28273
28318
  ${organizations.length} organizations available. "replicas org switch" to change.`)
28274
28319
  );
28275
28320
  }
28276
28321
  console.log();
28277
28322
  } catch (error51) {
28278
- console.error(import_chalk8.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28323
+ console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28279
28324
  process.exit(1);
28280
28325
  }
28281
28326
  }
28282
28327
  async function orgSwitchCommand() {
28283
28328
  if (!isAuthenticated()) {
28284
- console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
28329
+ console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
28285
28330
  process.exit(1);
28286
28331
  }
28287
28332
  try {
28288
28333
  const organizations = await fetchOrganizations();
28289
28334
  if (organizations.length === 0) {
28290
- console.log(import_chalk8.default.yellow("\n You are not a member of any organization."));
28291
- console.log(import_chalk8.default.gray(" Please contact support.\n"));
28335
+ console.log(import_chalk9.default.yellow("\n You are not a member of any organization."));
28336
+ console.log(import_chalk9.default.gray(" Please contact support.\n"));
28292
28337
  return;
28293
28338
  }
28294
28339
  const currentOrgId = getConfirmedOrganizationId();
@@ -28296,7 +28341,7 @@ async function orgSwitchCommand() {
28296
28341
  if (organizations.length > 1) {
28297
28342
  const chosen = await promptForOrganization(organizations, currentOrgId);
28298
28343
  if (!chosen) {
28299
- console.log(import_chalk8.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
28344
+ console.log(import_chalk9.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
28300
28345
  return;
28301
28346
  }
28302
28347
  selectedId = chosen.id;
@@ -28311,72 +28356,72 @@ async function orgSwitchCommand() {
28311
28356
  renderIdentity({ account, role, organizationName: selected?.name });
28312
28357
  console.log();
28313
28358
  } catch (error51) {
28314
- console.error(import_chalk8.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28359
+ console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28315
28360
  process.exit(1);
28316
28361
  }
28317
28362
  }
28318
28363
 
28319
28364
  // src/commands/config.ts
28320
- var import_chalk9 = __toESM(require("chalk"));
28365
+ var import_chalk10 = __toESM(require("chalk"));
28321
28366
  async function configGetCommand(key) {
28322
28367
  if (!isAuthenticated()) {
28323
- console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
28368
+ console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
28324
28369
  process.exit(1);
28325
28370
  }
28326
28371
  try {
28327
28372
  if (key === "ide") {
28328
28373
  const ideCommand = getIdeCommand();
28329
- console.log(import_chalk9.default.green(`
28374
+ console.log(import_chalk10.default.green(`
28330
28375
  IDE command: ${ideCommand}
28331
28376
  `));
28332
28377
  } else {
28333
- console.log(import_chalk9.default.red(`Unknown config key: ${key}`));
28334
- console.log(import_chalk9.default.gray("Available keys: ide"));
28378
+ console.log(import_chalk10.default.red(`Unknown config key: ${key}`));
28379
+ console.log(import_chalk10.default.gray("Available keys: ide"));
28335
28380
  process.exit(1);
28336
28381
  }
28337
28382
  } catch (error51) {
28338
- console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28383
+ console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28339
28384
  process.exit(1);
28340
28385
  }
28341
28386
  }
28342
28387
  async function configSetCommand(key, value) {
28343
28388
  if (!isAuthenticated()) {
28344
- console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
28389
+ console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
28345
28390
  process.exit(1);
28346
28391
  }
28347
28392
  try {
28348
28393
  if (key === "ide") {
28349
28394
  setIdeCommand(value);
28350
- console.log(import_chalk9.default.green(`
28395
+ console.log(import_chalk10.default.green(`
28351
28396
  \u2713 IDE command set to: ${value}
28352
28397
  `));
28353
28398
  } else {
28354
- console.log(import_chalk9.default.red(`Unknown config key: ${key}`));
28355
- console.log(import_chalk9.default.gray("Available keys: ide"));
28399
+ console.log(import_chalk10.default.red(`Unknown config key: ${key}`));
28400
+ console.log(import_chalk10.default.gray("Available keys: ide"));
28356
28401
  process.exit(1);
28357
28402
  }
28358
28403
  } catch (error51) {
28359
- console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28404
+ console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28360
28405
  process.exit(1);
28361
28406
  }
28362
28407
  }
28363
28408
  async function configListCommand() {
28364
28409
  if (!isAuthenticated()) {
28365
- console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
28410
+ console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
28366
28411
  process.exit(1);
28367
28412
  }
28368
28413
  try {
28369
28414
  const config3 = readConfig();
28370
28415
  if (!config3) {
28371
- console.log(import_chalk9.default.red("No config found. Please login first."));
28416
+ console.log(import_chalk10.default.red("No config found. Please login first."));
28372
28417
  process.exit(1);
28373
28418
  }
28374
- console.log(import_chalk9.default.green("\nCurrent configuration:"));
28375
- console.log(import_chalk9.default.gray(` Organization ID: ${config3.organization_id || "(not set)"}`));
28376
- console.log(import_chalk9.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
28419
+ console.log(import_chalk10.default.green("\nCurrent configuration:"));
28420
+ console.log(import_chalk10.default.gray(` Organization ID: ${config3.organization_id || "(not set)"}`));
28421
+ console.log(import_chalk10.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
28377
28422
  console.log();
28378
28423
  } catch (error51) {
28379
- console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28424
+ console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28380
28425
  process.exit(1);
28381
28426
  }
28382
28427
  }
@@ -28538,7 +28583,7 @@ async function runCodexOAuthFlow(totalSteps) {
28538
28583
  }
28539
28584
 
28540
28585
  // src/lib/credential-upload.ts
28541
- var import_chalk10 = __toESM(require("chalk"));
28586
+ var import_chalk11 = __toESM(require("chalk"));
28542
28587
  var UPLOAD_STEPS = 1;
28543
28588
  async function withAuthRecovery(operation, afterReauthentication) {
28544
28589
  try {
@@ -28548,11 +28593,11 @@ async function withAuthRecovery(operation, afterReauthentication) {
28548
28593
  throw error51;
28549
28594
  }
28550
28595
  const message = error51 instanceof NotAuthenticatedError ? "You're not signed in to Replicas. Signing in..." : "Your Replicas session expired. Re-authenticating...";
28551
- console.log(import_chalk10.default.yellow(`
28596
+ console.log(import_chalk11.default.yellow(`
28552
28597
  ${message}`));
28553
28598
  await loginCommand();
28554
28599
  await afterReauthentication?.();
28555
- console.log(import_chalk10.default.gray(" Retrying..."));
28600
+ console.log(import_chalk11.default.gray(" Retrying..."));
28556
28601
  return { result: await operation(), reauthenticated: true };
28557
28602
  }
28558
28603
  }
@@ -28619,7 +28664,7 @@ async function runCredentialAuthFlow(options, flow) {
28619
28664
  const saved = reauthenticated || !target.organization ? await resolveAuthFlowTarget(identity) : target;
28620
28665
  renderAuthFlowSuccess(providerLabel, response, saved);
28621
28666
  } catch (error51) {
28622
- console.log(import_chalk10.default.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
28667
+ console.log(import_chalk11.default.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
28623
28668
  process.exit(1);
28624
28669
  }
28625
28670
  }
@@ -28644,7 +28689,7 @@ async function codexAuthCommand(options = {}) {
28644
28689
 
28645
28690
  // src/lib/claude-oauth.ts
28646
28691
  var import_readline = __toESM(require("readline"));
28647
- var import_chalk11 = __toESM(require("chalk"));
28692
+ var import_chalk12 = __toESM(require("chalk"));
28648
28693
  var DEFAULT_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
28649
28694
  var CLAUDE_CLIENT_ID = process.env.CLAUDE_OAUTH_CLIENT_ID || DEFAULT_CLIENT_ID;
28650
28695
  var AUTHORIZATION_ENDPOINT2 = "https://claude.ai/oauth/authorize";
@@ -28673,7 +28718,7 @@ async function promptForAuthorizationCode() {
28673
28718
  const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
28674
28719
  return new Promise((resolve2) => {
28675
28720
  rl.on("close", () => resolve2(""));
28676
- rl.question(import_chalk11.default.gray(" Paste code here: "), (answer) => {
28721
+ rl.question(import_chalk12.default.gray(" Paste code here: "), (answer) => {
28677
28722
  resolve2(answer.trim());
28678
28723
  rl.close();
28679
28724
  });
@@ -28775,7 +28820,7 @@ async function claudeAuthCommand(options = {}) {
28775
28820
  }
28776
28821
 
28777
28822
  // src/commands/init.ts
28778
- var import_chalk12 = __toESM(require("chalk"));
28823
+ var import_chalk13 = __toESM(require("chalk"));
28779
28824
  var import_fs3 = __toESM(require("fs"));
28780
28825
  var import_path4 = __toESM(require("path"));
28781
28826
  function getDefaultConfig() {
@@ -28807,11 +28852,11 @@ function initCommand(options) {
28807
28852
  const existingPath = import_path4.default.join(process.cwd(), filename);
28808
28853
  if (import_fs3.default.existsSync(existingPath) && !options.force) {
28809
28854
  console.log(
28810
- import_chalk12.default.yellow(
28855
+ import_chalk13.default.yellow(
28811
28856
  `${filename} already exists in this directory.`
28812
28857
  )
28813
28858
  );
28814
- console.log(import_chalk12.default.gray("Use --force to overwrite the existing file."));
28859
+ console.log(import_chalk13.default.gray("Use --force to overwrite the existing file."));
28815
28860
  return;
28816
28861
  }
28817
28862
  }
@@ -28824,31 +28869,31 @@ function initCommand(options) {
28824
28869
  }
28825
28870
  try {
28826
28871
  import_fs3.default.writeFileSync(configPath, configContent, "utf-8");
28827
- console.log(import_chalk12.default.green(`\u2713 Created ${targetFilename}`));
28872
+ console.log(import_chalk13.default.green(`\u2713 Created ${targetFilename}`));
28828
28873
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
28829
28874
  if (filename === targetFilename) break;
28830
28875
  const higherPath = import_path4.default.join(process.cwd(), filename);
28831
28876
  if (import_fs3.default.existsSync(higherPath)) {
28832
28877
  console.log("");
28833
28878
  console.log(
28834
- import_chalk12.default.yellow(
28879
+ import_chalk13.default.yellow(
28835
28880
  `Warning: ${filename} already exists and takes priority over ${targetFilename}.`
28836
28881
  )
28837
28882
  );
28838
- console.log(import_chalk12.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
28883
+ console.log(import_chalk13.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
28839
28884
  }
28840
28885
  }
28841
28886
  console.log("");
28842
- console.log(import_chalk12.default.gray("Configuration options:"));
28887
+ console.log(import_chalk13.default.gray("Configuration options:"));
28843
28888
  console.log(
28844
- import_chalk12.default.gray(" systemPrompt - Custom instructions for AI coding assistants")
28889
+ import_chalk13.default.gray(" systemPrompt - Custom instructions for AI coding assistants")
28845
28890
  );
28846
28891
  console.log(
28847
- import_chalk12.default.gray(" startHook - Commands to run on workspace startup")
28892
+ import_chalk13.default.gray(" startHook - Commands to run on workspace startup")
28848
28893
  );
28849
28894
  if (!isYaml) {
28850
28895
  console.log("");
28851
- console.log(import_chalk12.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
28896
+ console.log(import_chalk13.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
28852
28897
  }
28853
28898
  } catch (error51) {
28854
28899
  throw new Error(
@@ -28858,7 +28903,7 @@ function initCommand(options) {
28858
28903
  }
28859
28904
 
28860
28905
  // src/lib/version-check.ts
28861
- var import_chalk13 = __toESM(require("chalk"));
28906
+ var import_chalk14 = __toESM(require("chalk"));
28862
28907
  var VERSION_CHECK_TIMEOUT = 2e3;
28863
28908
  function startUpdateCheck(currentVersion) {
28864
28909
  let notice = null;
@@ -28879,7 +28924,7 @@ function startUpdateCheck(currentVersion) {
28879
28924
  }
28880
28925
  const latestVersion = payload.version;
28881
28926
  if (compareVersions(latestVersion, currentVersion) > 0) {
28882
- notice = import_chalk13.default.dim(
28927
+ notice = import_chalk14.default.dim(
28883
28928
  `
28884
28929
  Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm install -g replicas-cli@latest
28885
28930
  `
@@ -28891,7 +28936,7 @@ Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm in
28891
28936
  }
28892
28937
 
28893
28938
  // src/commands/replica.ts
28894
- var import_chalk14 = __toESM(require("chalk"));
28939
+ var import_chalk15 = __toESM(require("chalk"));
28895
28940
  var import_prompts6 = __toESM(require("prompts"));
28896
28941
  var CLI_CODING_AGENT_LABEL = getCodingAgentDisplayNames();
28897
28942
  function parseReplicaAgent(value) {
@@ -28900,15 +28945,15 @@ function parseReplicaAgent(value) {
28900
28945
  if (isValidCodingAgentProvider(normalized)) {
28901
28946
  return normalized;
28902
28947
  }
28903
- console.log(import_chalk14.default.red(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`));
28948
+ console.log(import_chalk15.default.red(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`));
28904
28949
  process.exit(1);
28905
28950
  }
28906
28951
  function formatDate(dateString) {
28907
28952
  return new Date(dateString).toLocaleString();
28908
28953
  }
28909
28954
  function formatStatus(status) {
28910
- if (status === "active") return import_chalk14.default.green(status);
28911
- if (isWorkspaceSuspendedStatus(status)) return import_chalk14.default.gray(status);
28955
+ if (status === "active") return import_chalk15.default.green(status);
28956
+ if (isWorkspaceSuspendedStatus(status)) return import_chalk15.default.gray(status);
28912
28957
  return status;
28913
28958
  }
28914
28959
  function truncate(text, maxLength) {
@@ -28919,95 +28964,95 @@ function formatDisplayMessage(message) {
28919
28964
  const time3 = new Date(message.timestamp).toLocaleTimeString();
28920
28965
  switch (message.type) {
28921
28966
  case "user":
28922
- console.log(import_chalk14.default.blue(`
28967
+ console.log(import_chalk15.default.blue(`
28923
28968
  [${time3}] USER:`));
28924
- console.log(import_chalk14.default.white(` ${truncate(message.content, 500)}`));
28969
+ console.log(import_chalk15.default.white(` ${truncate(message.content, 500)}`));
28925
28970
  break;
28926
28971
  case "agent":
28927
- console.log(import_chalk14.default.green(`
28972
+ console.log(import_chalk15.default.green(`
28928
28973
  [${time3}] ASSISTANT:`));
28929
- console.log(import_chalk14.default.white(` ${truncate(message.content, 500)}`));
28974
+ console.log(import_chalk15.default.white(` ${truncate(message.content, 500)}`));
28930
28975
  break;
28931
28976
  case "reasoning":
28932
- console.log(import_chalk14.default.gray(`
28977
+ console.log(import_chalk15.default.gray(`
28933
28978
  [${time3}] THINKING:`));
28934
- console.log(import_chalk14.default.gray(` ${truncate(message.content, 300)}`));
28979
+ console.log(import_chalk15.default.gray(` ${truncate(message.content, 300)}`));
28935
28980
  break;
28936
28981
  case "command":
28937
- console.log(import_chalk14.default.magenta(`
28982
+ console.log(import_chalk15.default.magenta(`
28938
28983
  [${time3}] COMMAND:`));
28939
- console.log(import_chalk14.default.white(` $ ${message.command}`));
28984
+ console.log(import_chalk15.default.white(` $ ${message.command}`));
28940
28985
  if (message.output) {
28941
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
28986
+ console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
28942
28987
  }
28943
28988
  if (message.exitCode !== void 0) {
28944
- const exitColor = message.exitCode === 0 ? import_chalk14.default.green : import_chalk14.default.red;
28989
+ const exitColor = message.exitCode === 0 ? import_chalk15.default.green : import_chalk15.default.red;
28945
28990
  console.log(exitColor(` Exit code: ${message.exitCode}`));
28946
28991
  }
28947
28992
  break;
28948
28993
  case "file_change":
28949
- console.log(import_chalk14.default.yellow(`
28994
+ console.log(import_chalk15.default.yellow(`
28950
28995
  [${time3}] FILE CHANGES:`));
28951
28996
  for (const change of message.changes) {
28952
28997
  const icon = change.kind === "add" ? "+" : change.kind === "delete" ? "-" : "~";
28953
- const color = change.kind === "add" ? import_chalk14.default.green : change.kind === "delete" ? import_chalk14.default.red : import_chalk14.default.yellow;
28998
+ const color = change.kind === "add" ? import_chalk15.default.green : change.kind === "delete" ? import_chalk15.default.red : import_chalk15.default.yellow;
28954
28999
  console.log(color(` ${icon} ${change.path}`));
28955
29000
  }
28956
29001
  break;
28957
29002
  case "patch":
28958
- console.log(import_chalk14.default.yellow(`
29003
+ console.log(import_chalk15.default.yellow(`
28959
29004
  [${time3}] PATCH:`));
28960
29005
  for (const op of message.operations) {
28961
29006
  const icon = op.action === "add" ? "+" : op.action === "delete" ? "-" : "~";
28962
- const color = op.action === "add" ? import_chalk14.default.green : op.action === "delete" ? import_chalk14.default.red : import_chalk14.default.yellow;
29007
+ const color = op.action === "add" ? import_chalk15.default.green : op.action === "delete" ? import_chalk15.default.red : import_chalk15.default.yellow;
28963
29008
  console.log(color(` ${icon} ${op.path}`));
28964
29009
  }
28965
29010
  break;
28966
29011
  case "tool_call":
28967
- console.log(import_chalk14.default.cyan(`
29012
+ console.log(import_chalk15.default.cyan(`
28968
29013
  [${time3}] TOOL: ${message.tool}`));
28969
29014
  if (message.output) {
28970
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
29015
+ console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
28971
29016
  }
28972
29017
  break;
28973
29018
  case "web_search":
28974
- console.log(import_chalk14.default.cyan(`
29019
+ console.log(import_chalk15.default.cyan(`
28975
29020
  [${time3}] WEB SEARCH:`));
28976
- console.log(import_chalk14.default.white(` "${message.query}"`));
29021
+ console.log(import_chalk15.default.white(` "${message.query}"`));
28977
29022
  break;
28978
29023
  case "todo_list":
28979
- console.log(import_chalk14.default.blue(`
29024
+ console.log(import_chalk15.default.blue(`
28980
29025
  [${time3}] PLAN:`));
28981
29026
  for (const item of message.items) {
28982
- const icon = item.completed ? import_chalk14.default.green("[x]") : import_chalk14.default.gray("[ ]");
29027
+ const icon = item.completed ? import_chalk15.default.green("[x]") : import_chalk15.default.gray("[ ]");
28983
29028
  console.log(` ${icon} ${item.text}`);
28984
29029
  }
28985
29030
  break;
28986
29031
  case "subagent":
28987
- console.log(import_chalk14.default.magenta(`
29032
+ console.log(import_chalk15.default.magenta(`
28988
29033
  [${time3}] SUBAGENT: ${message.description}`));
28989
29034
  if (message.output) {
28990
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
29035
+ console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
28991
29036
  }
28992
29037
  break;
28993
29038
  case "subagent_followup":
28994
- console.log(import_chalk14.default.magenta(`
29039
+ console.log(import_chalk15.default.magenta(`
28995
29040
  [${time3}] MESSAGE SUBAGENT: ${message.targetTitle ?? message.chatId}`));
28996
- console.log(import_chalk14.default.white(` ${truncate(message.message, 500)}`));
29041
+ console.log(import_chalk15.default.white(` ${truncate(message.message, 500)}`));
28997
29042
  if (message.output) {
28998
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
29043
+ console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
28999
29044
  }
29000
29045
  break;
29001
29046
  case "error":
29002
- console.log(import_chalk14.default.red(`
29047
+ console.log(import_chalk15.default.red(`
29003
29048
  [${time3}] ERROR:`));
29004
- console.log(import_chalk14.default.red(` ${message.message}`));
29049
+ console.log(import_chalk15.default.red(` ${message.message}`));
29005
29050
  break;
29006
29051
  }
29007
29052
  }
29008
29053
  async function replicaListCommand(options) {
29009
29054
  if (!canCallOrgApi()) {
29010
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29055
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29011
29056
  process.exit(1);
29012
29057
  }
29013
29058
  try {
@@ -29019,86 +29064,86 @@ async function replicaListCommand(options) {
29019
29064
  `/v1/replica${query ? "?" + query : ""}`
29020
29065
  );
29021
29066
  if (response.replicas.length === 0) {
29022
- console.log(import_chalk14.default.yellow("\nNo replicas found.\n"));
29067
+ console.log(import_chalk15.default.yellow("\nNo replicas found.\n"));
29023
29068
  return;
29024
29069
  }
29025
- console.log(import_chalk14.default.green(`
29070
+ console.log(import_chalk15.default.green(`
29026
29071
  Replicas (Page ${response.page} of ${response.total_pages}, Total: ${response.total}):
29027
29072
  `));
29028
29073
  for (const replica of response.replicas) {
29029
- console.log(import_chalk14.default.white(` ${replica.name}`));
29030
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
29074
+ console.log(import_chalk15.default.white(` ${replica.name}`));
29075
+ console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
29031
29076
  if (replica.repositories.length > 0) {
29032
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29077
+ console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29033
29078
  }
29034
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
29035
- console.log(import_chalk14.default.gray(` Created: ${formatDate(replica.created_at)}`));
29079
+ console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
29080
+ console.log(import_chalk15.default.gray(` Created: ${formatDate(replica.created_at)}`));
29036
29081
  if (replica.pull_requests && replica.pull_requests.length > 0) {
29037
- console.log(import_chalk14.default.gray(` Pull Requests:`));
29082
+ console.log(import_chalk15.default.gray(` Pull Requests:`));
29038
29083
  for (const pr of replica.pull_requests) {
29039
- console.log(import_chalk14.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29084
+ console.log(import_chalk15.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29040
29085
  }
29041
29086
  }
29042
29087
  console.log();
29043
29088
  }
29044
29089
  } catch (error51) {
29045
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29090
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29046
29091
  process.exit(1);
29047
29092
  }
29048
29093
  }
29049
29094
  async function replicaGetCommand(id) {
29050
29095
  if (!isAuthenticated()) {
29051
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29096
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29052
29097
  process.exit(1);
29053
29098
  }
29054
29099
  try {
29055
29100
  const response = await orgAuthenticatedFetch(`/v1/replica/${id}`);
29056
29101
  const replica = response.replica;
29057
- console.log(import_chalk14.default.green(`
29102
+ console.log(import_chalk15.default.green(`
29058
29103
  Replica: ${replica.name}
29059
29104
  `));
29060
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
29105
+ console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
29061
29106
  if (replica.repositories.length > 0) {
29062
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29107
+ console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29063
29108
  }
29064
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
29065
- console.log(import_chalk14.default.gray(` Created: ${formatDate(replica.created_at)}`));
29109
+ console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
29110
+ console.log(import_chalk15.default.gray(` Created: ${formatDate(replica.created_at)}`));
29066
29111
  if (replica.waking) {
29067
- console.log(import_chalk14.default.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
29112
+ console.log(import_chalk15.default.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
29068
29113
  } else {
29069
29114
  if (replica.coding_agent) {
29070
- console.log(import_chalk14.default.gray(` Coding Agent: ${replica.coding_agent}`));
29115
+ console.log(import_chalk15.default.gray(` Coding Agent: ${replica.coding_agent}`));
29071
29116
  }
29072
29117
  if (replica.repository_statuses && replica.repository_statuses.length > 0) {
29073
- console.log(import_chalk14.default.gray(" Repository Statuses:"));
29118
+ console.log(import_chalk15.default.gray(" Repository Statuses:"));
29074
29119
  for (const repositoryStatus of replica.repository_statuses) {
29075
- const changeText = repositoryStatus.git_diff ? ` (${import_chalk14.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk14.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
29076
- console.log(import_chalk14.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
29120
+ const changeText = repositoryStatus.git_diff ? ` (${import_chalk15.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk15.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
29121
+ console.log(import_chalk15.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
29077
29122
  }
29078
29123
  }
29079
29124
  }
29080
29125
  if (replica.pull_requests && replica.pull_requests.length > 0) {
29081
- console.log(import_chalk14.default.gray(` Pull Requests:`));
29126
+ console.log(import_chalk15.default.gray(` Pull Requests:`));
29082
29127
  for (const pr of replica.pull_requests) {
29083
- console.log(import_chalk14.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29128
+ console.log(import_chalk15.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29084
29129
  }
29085
29130
  }
29086
29131
  console.log();
29087
29132
  } catch (error51) {
29088
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29133
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29089
29134
  process.exit(1);
29090
29135
  }
29091
29136
  }
29092
29137
  async function replicaCreateCommand(name, options) {
29093
29138
  if (!isAuthenticated()) {
29094
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29139
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29095
29140
  process.exit(1);
29096
29141
  }
29097
29142
  try {
29098
29143
  const envResponse = await orgAuthenticatedFetch("/v1/environments");
29099
29144
  const environments = envResponse.environments;
29100
29145
  if (environments.length === 0) {
29101
- console.log(import_chalk14.default.red("No environments found. Please create an environment first."));
29146
+ console.log(import_chalk15.default.red("No environments found. Please create an environment first."));
29102
29147
  process.exit(1);
29103
29148
  }
29104
29149
  let replicaName = name;
@@ -29106,7 +29151,7 @@ async function replicaCreateCommand(name, options) {
29106
29151
  let selectedEnvironmentId = options.environment?.trim();
29107
29152
  let codingAgent = parseReplicaAgent(options.agent);
29108
29153
  if (replicaName && /\s/.test(replicaName)) {
29109
- console.log(import_chalk14.default.red("Replica name cannot contain spaces."));
29154
+ console.log(import_chalk15.default.red("Replica name cannot contain spaces."));
29110
29155
  process.exit(1);
29111
29156
  }
29112
29157
  if (!replicaName) {
@@ -29121,7 +29166,7 @@ async function replicaCreateCommand(name, options) {
29121
29166
  }
29122
29167
  });
29123
29168
  if (!response2.name) {
29124
- console.log(import_chalk14.default.yellow("\nCancelled."));
29169
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29125
29170
  return;
29126
29171
  }
29127
29172
  replicaName = response2.name;
@@ -29138,7 +29183,7 @@ async function replicaCreateCommand(name, options) {
29138
29183
  }))
29139
29184
  });
29140
29185
  if (!response2.environment) {
29141
- console.log(import_chalk14.default.yellow("\nCancelled."));
29186
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29142
29187
  return;
29143
29188
  }
29144
29189
  selectedEnvironmentId = response2.environment;
@@ -29151,7 +29196,7 @@ async function replicaCreateCommand(name, options) {
29151
29196
  validate: (value) => value.trim() ? true : "Message is required"
29152
29197
  });
29153
29198
  if (!response2.message) {
29154
- console.log(import_chalk14.default.yellow("\nCancelled."));
29199
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29155
29200
  return;
29156
29201
  }
29157
29202
  message = response2.message;
@@ -29165,7 +29210,7 @@ async function replicaCreateCommand(name, options) {
29165
29210
  initial: 0
29166
29211
  });
29167
29212
  if (!response2.agent) {
29168
- console.log(import_chalk14.default.yellow("\nCancelled."));
29213
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29169
29214
  return;
29170
29215
  }
29171
29216
  codingAgent = parseReplicaAgent(response2.agent);
@@ -29176,28 +29221,28 @@ async function replicaCreateCommand(name, options) {
29176
29221
  environment_id: selectedEnvironmentId,
29177
29222
  coding_agent: codingAgent
29178
29223
  };
29179
- console.log(import_chalk14.default.gray("\nCreating replica..."));
29224
+ console.log(import_chalk15.default.gray("\nCreating replica..."));
29180
29225
  const response = await orgAuthenticatedFetch("/v1/replica", {
29181
29226
  method: "POST",
29182
29227
  body
29183
29228
  });
29184
29229
  const replica = response.replica;
29185
- console.log(import_chalk14.default.green(`
29230
+ console.log(import_chalk15.default.green(`
29186
29231
  Created replica: ${replica.name}`));
29187
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
29188
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
29232
+ console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
29233
+ console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
29189
29234
  if (replica.repositories.length > 0) {
29190
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29235
+ console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29191
29236
  }
29192
29237
  console.log();
29193
29238
  } catch (error51) {
29194
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29239
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29195
29240
  process.exit(1);
29196
29241
  }
29197
29242
  }
29198
29243
  async function replicaSendCommand(id, options) {
29199
29244
  if (!isAuthenticated()) {
29200
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29245
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29201
29246
  process.exit(1);
29202
29247
  }
29203
29248
  try {
@@ -29210,7 +29255,7 @@ async function replicaSendCommand(id, options) {
29210
29255
  validate: (value) => value.trim() ? true : "Message is required"
29211
29256
  });
29212
29257
  if (!response2.message) {
29213
- console.log(import_chalk14.default.yellow("\nCancelled."));
29258
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29214
29259
  return;
29215
29260
  }
29216
29261
  message = response2.message;
@@ -29228,21 +29273,21 @@ async function replicaSendCommand(id, options) {
29228
29273
  body
29229
29274
  }
29230
29275
  );
29231
- const statusColor = response.status === "sent" ? import_chalk14.default.green : import_chalk14.default.yellow;
29276
+ const statusColor = response.status === "sent" ? import_chalk15.default.green : import_chalk15.default.yellow;
29232
29277
  console.log(statusColor(`
29233
29278
  Message ${response.status}`));
29234
29279
  if (response.position !== void 0 && response.position > 0) {
29235
- console.log(import_chalk14.default.gray(` Queue position: ${response.position}`));
29280
+ console.log(import_chalk15.default.gray(` Queue position: ${response.position}`));
29236
29281
  }
29237
29282
  console.log();
29238
29283
  } catch (error51) {
29239
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29284
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29240
29285
  process.exit(1);
29241
29286
  }
29242
29287
  }
29243
29288
  async function replicaDeleteCommand(id, options) {
29244
29289
  if (!isAuthenticated()) {
29245
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29290
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29246
29291
  process.exit(1);
29247
29292
  }
29248
29293
  try {
@@ -29254,24 +29299,24 @@ async function replicaDeleteCommand(id, options) {
29254
29299
  initial: false
29255
29300
  });
29256
29301
  if (!response.confirm) {
29257
- console.log(import_chalk14.default.yellow("\nCancelled."));
29302
+ console.log(import_chalk15.default.yellow("\nCancelled."));
29258
29303
  return;
29259
29304
  }
29260
29305
  }
29261
29306
  await orgAuthenticatedFetch(`/v1/replica/${id}`, {
29262
29307
  method: "DELETE"
29263
29308
  });
29264
- console.log(import_chalk14.default.green(`
29309
+ console.log(import_chalk15.default.green(`
29265
29310
  Replica ${id} deleted.
29266
29311
  `));
29267
29312
  } catch (error51) {
29268
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29313
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29269
29314
  process.exit(1);
29270
29315
  }
29271
29316
  }
29272
29317
  async function replicaReadCommand(id, options) {
29273
29318
  if (!isAuthenticated()) {
29274
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
29319
+ console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29275
29320
  process.exit(1);
29276
29321
  }
29277
29322
  try {
@@ -29283,53 +29328,53 @@ async function replicaReadCommand(id, options) {
29283
29328
  `/v1/replica/${id}/read${query ? "?" + query : ""}`
29284
29329
  );
29285
29330
  if (response.waking) {
29286
- console.log(import_chalk14.default.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
29331
+ console.log(import_chalk15.default.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
29287
29332
  return;
29288
29333
  }
29289
- console.log(import_chalk14.default.green(`
29334
+ console.log(import_chalk15.default.green(`
29290
29335
  Conversation History
29291
29336
  `));
29292
29337
  if (response.coding_agent) {
29293
- console.log(import_chalk14.default.gray(` Agent: ${response.coding_agent}`));
29338
+ console.log(import_chalk15.default.gray(` Agent: ${response.coding_agent}`));
29294
29339
  }
29295
29340
  if (response.thread_id) {
29296
- console.log(import_chalk14.default.gray(` Thread ID: ${response.thread_id}`));
29341
+ console.log(import_chalk15.default.gray(` Thread ID: ${response.thread_id}`));
29297
29342
  }
29298
- console.log(import_chalk14.default.gray(` Total Events: ${response.total}`));
29299
- console.log(import_chalk14.default.gray(` Showing: ${response.events.length} events`));
29343
+ console.log(import_chalk15.default.gray(` Total Events: ${response.total}`));
29344
+ console.log(import_chalk15.default.gray(` Showing: ${response.events.length} events`));
29300
29345
  if (response.has_more) {
29301
- console.log(import_chalk14.default.gray(` Has More: yes (--before-event ${response.eventsStartIndex} for the previous page)`));
29346
+ console.log(import_chalk15.default.gray(` Has More: yes (--before-event ${response.eventsStartIndex} for the previous page)`));
29302
29347
  }
29303
29348
  console.log();
29304
29349
  if (response.events.length === 0) {
29305
- console.log(import_chalk14.default.yellow(" No events found.\n"));
29350
+ console.log(import_chalk15.default.yellow(" No events found.\n"));
29306
29351
  return;
29307
29352
  }
29308
- console.log(import_chalk14.default.gray("-".repeat(60)));
29353
+ console.log(import_chalk15.default.gray("-".repeat(60)));
29309
29354
  const agentType = response.coding_agent || "claude";
29310
29355
  const displayMessages = parseDisplayMessages(response.events, agentType, response.codexAspTranscript);
29311
29356
  for (const message of displayMessages) {
29312
29357
  formatDisplayMessage(message);
29313
29358
  }
29314
- console.log(import_chalk14.default.gray("\n" + "-".repeat(60)));
29359
+ console.log(import_chalk15.default.gray("\n" + "-".repeat(60)));
29315
29360
  console.log();
29316
29361
  } catch (error51) {
29317
- console.error(import_chalk14.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29362
+ console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29318
29363
  process.exit(1);
29319
29364
  }
29320
29365
  }
29321
29366
 
29322
29367
  // src/commands/repositories.ts
29323
- var import_chalk16 = __toESM(require("chalk"));
29368
+ var import_chalk17 = __toESM(require("chalk"));
29324
29369
 
29325
29370
  // src/lib/command-utils.ts
29326
- var import_chalk15 = __toESM(require("chalk"));
29371
+ var import_chalk16 = __toESM(require("chalk"));
29327
29372
  function formatDate2(dateString) {
29328
29373
  return new Date(dateString).toLocaleString();
29329
29374
  }
29330
29375
  function ensureOrgApiAuthenticated() {
29331
29376
  if (!canCallOrgApi()) {
29332
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
29377
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
29333
29378
  process.exit(1);
29334
29379
  }
29335
29380
  }
@@ -29343,36 +29388,36 @@ async function repositoriesListCommand() {
29343
29388
  try {
29344
29389
  const response = await orgAuthenticatedFetch("/v1/repositories");
29345
29390
  if (response.repositories.length === 0) {
29346
- console.log(import_chalk16.default.yellow("\nNo repositories found.\n"));
29391
+ console.log(import_chalk17.default.yellow("\nNo repositories found.\n"));
29347
29392
  return;
29348
29393
  }
29349
- console.log(import_chalk16.default.green(`
29394
+ console.log(import_chalk17.default.green(`
29350
29395
  Repositories (${response.repositories.length}):
29351
29396
  `));
29352
29397
  for (const repo of response.repositories) {
29353
- console.log(import_chalk16.default.white(` ${repo.name}`));
29354
- console.log(import_chalk16.default.gray(` URL: ${repo.url}`));
29355
- console.log(import_chalk16.default.gray(` Default Branch: ${repo.default_branch}`));
29356
- console.log(import_chalk16.default.gray(` Created: ${formatDate2(repo.created_at)}`));
29398
+ console.log(import_chalk17.default.white(` ${repo.name}`));
29399
+ console.log(import_chalk17.default.gray(` URL: ${repo.url}`));
29400
+ console.log(import_chalk17.default.gray(` Default Branch: ${repo.default_branch}`));
29401
+ console.log(import_chalk17.default.gray(` Created: ${formatDate2(repo.created_at)}`));
29357
29402
  if (repo.github_repository_id) {
29358
- console.log(import_chalk16.default.gray(` GitHub ID: ${repo.github_repository_id}`));
29403
+ console.log(import_chalk17.default.gray(` GitHub ID: ${repo.github_repository_id}`));
29359
29404
  }
29360
29405
  console.log();
29361
29406
  }
29362
29407
  } catch (error51) {
29363
- console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29408
+ console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29364
29409
  process.exit(1);
29365
29410
  }
29366
29411
  }
29367
29412
 
29368
29413
  // src/commands/automation.ts
29369
- var import_chalk17 = __toESM(require("chalk"));
29414
+ var import_chalk18 = __toESM(require("chalk"));
29370
29415
  var import_prompts7 = __toESM(require("prompts"));
29371
29416
  function parseScopeFilter(value) {
29372
29417
  if (!value) return void 0;
29373
29418
  if (value === "org" || value === "user" || value === "all") return value;
29374
- console.log(import_chalk17.default.red(`Invalid --owner: ${value}`));
29375
- console.log(import_chalk17.default.gray("Valid options: org, user, all"));
29419
+ console.log(import_chalk18.default.red(`Invalid --owner: ${value}`));
29420
+ console.log(import_chalk18.default.gray("Valid options: org, user, all"));
29376
29421
  process.exit(1);
29377
29422
  }
29378
29423
  function parseAgentProviderOption(value) {
@@ -29381,8 +29426,8 @@ function parseAgentProviderOption(value) {
29381
29426
  if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
29382
29427
  const lower = trimmed.toLowerCase();
29383
29428
  if (!isValidAgentProvider(lower)) {
29384
- console.log(import_chalk17.default.red(`Invalid --agent-provider: ${value}`));
29385
- console.log(import_chalk17.default.gray(`Valid options: ${VALID_AGENT_PROVIDERS.join(", ")}, none`));
29429
+ console.log(import_chalk18.default.red(`Invalid --agent-provider: ${value}`));
29430
+ console.log(import_chalk18.default.gray(`Valid options: ${VALID_AGENT_PROVIDERS.join(", ")}, none`));
29386
29431
  process.exit(1);
29387
29432
  }
29388
29433
  return lower;
@@ -29393,8 +29438,8 @@ function parseThinkingLevelOption(value) {
29393
29438
  if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
29394
29439
  const lower = trimmed.toLowerCase();
29395
29440
  if (!isValidThinkingLevel(lower)) {
29396
- console.log(import_chalk17.default.red(`Invalid --thinking-level: ${value}`));
29397
- console.log(import_chalk17.default.gray(`Valid options: ${VALID_THINKING_LEVELS.join(", ")}, none`));
29441
+ console.log(import_chalk18.default.red(`Invalid --thinking-level: ${value}`));
29442
+ console.log(import_chalk18.default.gray(`Valid options: ${VALID_THINKING_LEVELS.join(", ")}, none`));
29398
29443
  process.exit(1);
29399
29444
  }
29400
29445
  return lower;
@@ -29411,8 +29456,8 @@ function isAutomationLifecyclePolicy(value) {
29411
29456
  function parseWorkspaceLifecyclePolicyOption(value) {
29412
29457
  if (!value) return void 0;
29413
29458
  if (isAutomationLifecyclePolicy(value)) return value;
29414
- console.log(import_chalk17.default.red(`Invalid lifecycle policy: ${value}`));
29415
- console.log(import_chalk17.default.gray(`Valid options: ${AUTOMATION_LIFECYCLE_POLICIES.join(", ")}`));
29459
+ console.log(import_chalk18.default.red(`Invalid lifecycle policy: ${value}`));
29460
+ console.log(import_chalk18.default.gray(`Valid options: ${AUTOMATION_LIFECYCLE_POLICIES.join(", ")}`));
29416
29461
  process.exit(1);
29417
29462
  }
29418
29463
  function parseExcludedActorsOption(value) {
@@ -29431,7 +29476,7 @@ function withExcludedActors(config3, excludedActors) {
29431
29476
  }
29432
29477
  function parseAutomationLifecycleOptions(options) {
29433
29478
  if (options.sleepWhenDone && options.lifecycle && options.lifecycle !== "sleep_when_done") {
29434
- console.log(import_chalk17.default.red("--sleep-when-done cannot be combined with a different --lifecycle value"));
29479
+ console.log(import_chalk18.default.red("--sleep-when-done cannot be combined with a different --lifecycle value"));
29435
29480
  process.exit(1);
29436
29481
  }
29437
29482
  if (options.sleepWhenDone) return "sleep_when_done";
@@ -29440,7 +29485,7 @@ function parseAutomationLifecycleOptions(options) {
29440
29485
  function applyAgentSelection(body, existing) {
29441
29486
  const result = validateAgentSelection(body, existing);
29442
29487
  if (!result.ok) {
29443
- console.log(import_chalk17.default.red(result.error.message));
29488
+ console.log(import_chalk18.default.red(result.error.message));
29444
29489
  process.exit(1);
29445
29490
  }
29446
29491
  const out = {};
@@ -29481,8 +29526,8 @@ function resolveTriggerRepositoryIds(repositories, repoNamesInput, provider) {
29481
29526
  for (const repoName of repoNames) {
29482
29527
  const repo = providerRepos.find((r) => r.name === repoName);
29483
29528
  if (!repo) {
29484
- console.log(import_chalk17.default.red(`Repository not found for ${provider} trigger filter: ${repoName}`));
29485
- console.log(import_chalk17.default.gray(`Available: ${providerRepos.map((r) => r.name).join(", ")}`));
29529
+ console.log(import_chalk18.default.red(`Repository not found for ${provider} trigger filter: ${repoName}`));
29530
+ console.log(import_chalk18.default.gray(`Available: ${providerRepos.map((r) => r.name).join(", ")}`));
29486
29531
  process.exit(1);
29487
29532
  }
29488
29533
  repoIds.push(repo.id);
@@ -29515,43 +29560,43 @@ function formatModeSummary(automation2) {
29515
29560
  function resolveSelectableEnvironmentId(envInput, selectableEnvs) {
29516
29561
  const resolved = resolveByNameOrId(envInput, selectableEnvs);
29517
29562
  if (!resolved) {
29518
- console.log(import_chalk17.default.red(`Environment not found: ${envInput}`));
29563
+ console.log(import_chalk18.default.red(`Environment not found: ${envInput}`));
29519
29564
  const available = selectableEnvs.map((e) => e.name).join(", ");
29520
- console.log(import_chalk17.default.gray(`Available: ${available || "(none)"}`));
29565
+ console.log(import_chalk18.default.gray(`Available: ${available || "(none)"}`));
29521
29566
  process.exit(1);
29522
29567
  }
29523
29568
  return resolved.id;
29524
29569
  }
29525
29570
  function printAutomation(automation2) {
29526
- console.log(import_chalk17.default.white(` ${automation2.name}`));
29527
- console.log(import_chalk17.default.gray(` ID: ${automation2.id}`));
29528
- console.log(import_chalk17.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
29571
+ console.log(import_chalk18.default.white(` ${automation2.name}`));
29572
+ console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
29573
+ console.log(import_chalk18.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
29529
29574
  if (automation2.description) {
29530
- console.log(import_chalk17.default.gray(` Description: ${automation2.description}`));
29575
+ console.log(import_chalk18.default.gray(` Description: ${automation2.description}`));
29531
29576
  }
29532
- console.log(import_chalk17.default.gray(` Enabled: ${automation2.enabled ? import_chalk17.default.green("yes") : import_chalk17.default.red("no")}`));
29577
+ console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? import_chalk18.default.green("yes") : import_chalk18.default.red("no")}`));
29533
29578
  if (automation2.triggers.length > 0) {
29534
- console.log(import_chalk17.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
29579
+ console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
29535
29580
  }
29536
29581
  if (automation2.github_check_names.length > 0) {
29537
- console.log(import_chalk17.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
29582
+ console.log(import_chalk18.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
29538
29583
  }
29539
- console.log(import_chalk17.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
29584
+ console.log(import_chalk18.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
29540
29585
  if (automation2.cron_next_fire_at) {
29541
- console.log(import_chalk17.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29586
+ console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29542
29587
  }
29543
29588
  if (automation2.workspace_lifecycle_policy && automation2.workspace_lifecycle_policy !== "default") {
29544
- console.log(import_chalk17.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
29589
+ console.log(import_chalk18.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
29545
29590
  }
29546
29591
  if (automation2.agent_provider || automation2.model || automation2.thinking_level) {
29547
- console.log(import_chalk17.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
29592
+ console.log(import_chalk18.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
29548
29593
  }
29549
29594
  if (automation2.plan_mode || automation2.goal_mode || automation2.fast_mode) {
29550
- console.log(import_chalk17.default.gray(` Modes: ${formatModeSummary(automation2)}`));
29595
+ console.log(import_chalk18.default.gray(` Modes: ${formatModeSummary(automation2)}`));
29551
29596
  }
29552
- console.log(import_chalk17.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk17.default.green("managed") : "read-only"}`));
29553
- console.log(import_chalk17.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
29554
- console.log(import_chalk17.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
29597
+ console.log(import_chalk18.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk18.default.green("managed") : "read-only"}`));
29598
+ console.log(import_chalk18.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
29599
+ console.log(import_chalk18.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
29555
29600
  console.log();
29556
29601
  }
29557
29602
  async function automationListCommand(options) {
@@ -29570,17 +29615,17 @@ async function automationListCommand(options) {
29570
29615
  `/v1/automations${query ? "?" + query : ""}`
29571
29616
  );
29572
29617
  if (response.automations.length === 0) {
29573
- console.log(import_chalk17.default.yellow("\nNo automations found.\n"));
29618
+ console.log(import_chalk18.default.yellow("\nNo automations found.\n"));
29574
29619
  return;
29575
29620
  }
29576
- console.log(import_chalk17.default.green(`
29621
+ console.log(import_chalk18.default.green(`
29577
29622
  Automations (Page ${response.page} of ${response.totalPages}, Total: ${response.total}):
29578
29623
  `));
29579
29624
  for (const automation2 of response.automations) {
29580
29625
  printAutomation(automation2);
29581
29626
  }
29582
29627
  } catch (error51) {
29583
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29628
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29584
29629
  process.exit(1);
29585
29630
  }
29586
29631
  }
@@ -29589,50 +29634,50 @@ async function automationGetCommand(id) {
29589
29634
  try {
29590
29635
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`);
29591
29636
  const automation2 = response.automation;
29592
- console.log(import_chalk17.default.green(`
29637
+ console.log(import_chalk18.default.green(`
29593
29638
  Automation: ${automation2.name}
29594
29639
  `));
29595
- console.log(import_chalk17.default.gray(` ID: ${automation2.id}`));
29640
+ console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
29596
29641
  if (automation2.description) {
29597
- console.log(import_chalk17.default.gray(` Description: ${automation2.description}`));
29642
+ console.log(import_chalk18.default.gray(` Description: ${automation2.description}`));
29598
29643
  }
29599
- console.log(import_chalk17.default.gray(` Enabled: ${automation2.enabled ? import_chalk17.default.green("yes") : import_chalk17.default.red("no")}`));
29644
+ console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? import_chalk18.default.green("yes") : import_chalk18.default.red("no")}`));
29600
29645
  if (automation2.triggers.length > 0) {
29601
- console.log(import_chalk17.default.gray(` Triggers:`));
29646
+ console.log(import_chalk18.default.gray(` Triggers:`));
29602
29647
  for (const trigger of automation2.triggers) {
29603
- console.log(import_chalk17.default.gray(` - ${formatTrigger(trigger)}`));
29648
+ console.log(import_chalk18.default.gray(` - ${formatTrigger(trigger)}`));
29604
29649
  }
29605
29650
  }
29606
29651
  if (automation2.github_check_names.length > 0) {
29607
- console.log(import_chalk17.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
29652
+ console.log(import_chalk18.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
29608
29653
  }
29609
- console.log(import_chalk17.default.gray(` Prompt: ${automation2.prompt}`));
29610
- console.log(import_chalk17.default.gray(` Environment: ${automation2.environment_id}`));
29654
+ console.log(import_chalk18.default.gray(` Prompt: ${automation2.prompt}`));
29655
+ console.log(import_chalk18.default.gray(` Environment: ${automation2.environment_id}`));
29611
29656
  if (automation2.cron_expression) {
29612
- console.log(import_chalk17.default.gray(` Cron: ${automation2.cron_expression}`));
29657
+ console.log(import_chalk18.default.gray(` Cron: ${automation2.cron_expression}`));
29613
29658
  }
29614
29659
  if (automation2.cron_timezone) {
29615
- console.log(import_chalk17.default.gray(` Timezone: ${automation2.cron_timezone}`));
29660
+ console.log(import_chalk18.default.gray(` Timezone: ${automation2.cron_timezone}`));
29616
29661
  }
29617
29662
  if (automation2.cron_next_fire_at) {
29618
- console.log(import_chalk17.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29663
+ console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29619
29664
  }
29620
29665
  if (automation2.workspace_lifecycle_policy) {
29621
- console.log(import_chalk17.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
29666
+ console.log(import_chalk18.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
29622
29667
  }
29623
29668
  if (automation2.workspace_auto_stop_minutes) {
29624
- console.log(import_chalk17.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
29625
- }
29626
- console.log(import_chalk17.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
29627
- console.log(import_chalk17.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
29628
- console.log(import_chalk17.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
29629
- console.log(import_chalk17.default.gray(` Modes: ${formatModeSummary(automation2)}`));
29630
- console.log(import_chalk17.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
29631
- console.log(import_chalk17.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
29632
- console.log(import_chalk17.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
29669
+ console.log(import_chalk18.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
29670
+ }
29671
+ console.log(import_chalk18.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
29672
+ console.log(import_chalk18.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
29673
+ console.log(import_chalk18.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
29674
+ console.log(import_chalk18.default.gray(` Modes: ${formatModeSummary(automation2)}`));
29675
+ console.log(import_chalk18.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
29676
+ console.log(import_chalk18.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
29677
+ console.log(import_chalk18.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
29633
29678
  console.log();
29634
29679
  } catch (error51) {
29635
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29680
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29636
29681
  process.exit(1);
29637
29682
  }
29638
29683
  }
@@ -29757,22 +29802,22 @@ async function automationCreateCommand(name, options) {
29757
29802
  ensureOrgApiAuthenticated();
29758
29803
  const lifecyclePolicy = parseAutomationLifecycleOptions(options);
29759
29804
  if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(lifecyclePolicy ?? "default")) {
29760
- console.log(import_chalk17.default.red("--auto-stop-minutes requires --lifecycle default"));
29805
+ console.log(import_chalk18.default.red("--auto-stop-minutes requires --lifecycle default"));
29761
29806
  process.exit(1);
29762
29807
  }
29763
29808
  if (options.autoStopMinutes) {
29764
29809
  const minutes = parseInt(options.autoStopMinutes, 10);
29765
29810
  if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
29766
- console.log(import_chalk17.default.red("--auto-stop-minutes must be between 3 and 1440"));
29811
+ console.log(import_chalk18.default.red("--auto-stop-minutes must be between 3 and 1440"));
29767
29812
  process.exit(1);
29768
29813
  }
29769
29814
  }
29770
29815
  if (options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
29771
- console.log(import_chalk17.default.red("--trigger-github-exclude-users requires --trigger-github"));
29816
+ console.log(import_chalk18.default.red("--trigger-github-exclude-users requires --trigger-github"));
29772
29817
  process.exit(1);
29773
29818
  }
29774
29819
  if (options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
29775
- console.log(import_chalk17.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab"));
29820
+ console.log(import_chalk18.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab"));
29776
29821
  process.exit(1);
29777
29822
  }
29778
29823
  const agentSelection = applyAgentSelection(
@@ -29787,7 +29832,7 @@ async function automationCreateCommand(name, options) {
29787
29832
  const envResponse = await orgAuthenticatedFetch("/v1/environments");
29788
29833
  const selectableEnvs = envResponse.environments;
29789
29834
  if (selectableEnvs.length === 0) {
29790
- console.log(import_chalk17.default.red("No environments found. Please create an environment first."));
29835
+ console.log(import_chalk18.default.red("No environments found. Please create an environment first."));
29791
29836
  process.exit(1);
29792
29837
  }
29793
29838
  const repoResponse = await orgAuthenticatedFetch("/v1/repositories");
@@ -29801,7 +29846,7 @@ async function automationCreateCommand(name, options) {
29801
29846
  validate: (value) => value.trim() ? true : "Name is required"
29802
29847
  });
29803
29848
  if (!response2.name) {
29804
- console.log(import_chalk17.default.yellow("\nCancelled."));
29849
+ console.log(import_chalk18.default.yellow("\nCancelled."));
29805
29850
  return;
29806
29851
  }
29807
29852
  automationName = response2.name;
@@ -29815,7 +29860,7 @@ async function automationCreateCommand(name, options) {
29815
29860
  validate: (value) => value.trim() ? true : "Prompt is required"
29816
29861
  });
29817
29862
  if (!response2.prompt) {
29818
- console.log(import_chalk17.default.yellow("\nCancelled."));
29863
+ console.log(import_chalk18.default.yellow("\nCancelled."));
29819
29864
  return;
29820
29865
  }
29821
29866
  automationPrompt = response2.prompt;
@@ -29835,7 +29880,7 @@ async function automationCreateCommand(name, options) {
29835
29880
  }))
29836
29881
  });
29837
29882
  if (!envResponse2.env) {
29838
- console.log(import_chalk17.default.yellow("\nCancelled."));
29883
+ console.log(import_chalk18.default.yellow("\nCancelled."));
29839
29884
  return;
29840
29885
  }
29841
29886
  selectedEnvironmentId = envResponse2.env;
@@ -29877,7 +29922,7 @@ async function automationCreateCommand(name, options) {
29877
29922
  if (triggers.length === 0) {
29878
29923
  triggers = await promptForTriggers(repositories.map((r) => ({ id: r.id, name: r.name, provider: r.provider })));
29879
29924
  if (triggers.length === 0) {
29880
- console.log(import_chalk17.default.red("At least one trigger is required."));
29925
+ console.log(import_chalk18.default.red("At least one trigger is required."));
29881
29926
  process.exit(1);
29882
29927
  }
29883
29928
  }
@@ -29907,25 +29952,25 @@ async function automationCreateCommand(name, options) {
29907
29952
  ...options.fastMode ? { fast_mode: true } : {},
29908
29953
  ...agentSelection
29909
29954
  };
29910
- console.log(import_chalk17.default.gray("\nCreating automation..."));
29955
+ console.log(import_chalk18.default.gray("\nCreating automation..."));
29911
29956
  const response = await orgAuthenticatedFetch("/v1/automations", {
29912
29957
  method: "POST",
29913
29958
  body
29914
29959
  });
29915
29960
  const automation2 = response.automation;
29916
- console.log(import_chalk17.default.green(`
29961
+ console.log(import_chalk18.default.green(`
29917
29962
  Created automation: ${automation2.name}`));
29918
- console.log(import_chalk17.default.gray(` ID: ${automation2.id}`));
29919
- console.log(import_chalk17.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
29963
+ console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
29964
+ console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
29920
29965
  if (automation2.triggers.length > 0) {
29921
- console.log(import_chalk17.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
29966
+ console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
29922
29967
  }
29923
29968
  if (automation2.cron_next_fire_at) {
29924
- console.log(import_chalk17.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29969
+ console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
29925
29970
  }
29926
29971
  console.log();
29927
29972
  } catch (error51) {
29928
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29973
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29929
29974
  process.exit(1);
29930
29975
  }
29931
29976
  }
@@ -29935,17 +29980,17 @@ async function automationEditCommand(id, options) {
29935
29980
  if (options.autoStopMinutes) {
29936
29981
  const minutes = parseInt(options.autoStopMinutes, 10);
29937
29982
  if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
29938
- console.log(import_chalk17.default.red("--auto-stop-minutes must be between 3 and 1440"));
29983
+ console.log(import_chalk18.default.red("--auto-stop-minutes must be between 3 and 1440"));
29939
29984
  process.exit(1);
29940
29985
  }
29941
29986
  }
29942
29987
  const replacingTriggers = Boolean(options.triggerCron || options.triggerGithub || options.triggerGitlab);
29943
29988
  if (replacingTriggers && options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
29944
- console.log(import_chalk17.default.red("--trigger-github-exclude-users requires --trigger-github when replacing triggers"));
29989
+ console.log(import_chalk18.default.red("--trigger-github-exclude-users requires --trigger-github when replacing triggers"));
29945
29990
  process.exit(1);
29946
29991
  }
29947
29992
  if (replacingTriggers && options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
29948
- console.log(import_chalk17.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab when replacing triggers"));
29993
+ console.log(import_chalk18.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab when replacing triggers"));
29949
29994
  process.exit(1);
29950
29995
  }
29951
29996
  const parsedAgent = {
@@ -29957,7 +30002,7 @@ async function automationEditCommand(id, options) {
29957
30002
  const existing = await orgAuthenticatedFetch(`/v1/automations/${id}`);
29958
30003
  const autoStopLifecyclePolicy = lifecyclePolicy ?? toAutomationLifecyclePolicy(existing.automation.workspace_lifecycle_policy);
29959
30004
  if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(autoStopLifecyclePolicy)) {
29960
- console.log(import_chalk17.default.red("--auto-stop-minutes requires --lifecycle default"));
30005
+ console.log(import_chalk18.default.red("--auto-stop-minutes requires --lifecycle default"));
29961
30006
  process.exit(1);
29962
30007
  }
29963
30008
  const agentSelection = applyAgentSelection(parsedAgent, {
@@ -30097,11 +30142,11 @@ async function automationEditCommand(id, options) {
30097
30142
  return trigger;
30098
30143
  });
30099
30144
  if (!matchedGithub) {
30100
- console.log(import_chalk17.default.red("No existing GitHub trigger found. Pass --trigger-github to create one."));
30145
+ console.log(import_chalk18.default.red("No existing GitHub trigger found. Pass --trigger-github to create one."));
30101
30146
  process.exit(1);
30102
30147
  }
30103
30148
  if (!matchedGitlab) {
30104
- console.log(import_chalk17.default.red("No existing GitLab trigger found. Pass --trigger-gitlab to create one."));
30149
+ console.log(import_chalk18.default.red("No existing GitLab trigger found. Pass --trigger-gitlab to create one."));
30105
30150
  process.exit(1);
30106
30151
  }
30107
30152
  }
@@ -30124,25 +30169,25 @@ async function automationEditCommand(id, options) {
30124
30169
  Object.assign(body, agentSelection);
30125
30170
  }
30126
30171
  if (Object.keys(body).length === 0) {
30127
- console.log(import_chalk17.default.yellow("\nNo changes made.\n"));
30172
+ console.log(import_chalk18.default.yellow("\nNo changes made.\n"));
30128
30173
  return;
30129
30174
  }
30130
- console.log(import_chalk17.default.gray("\nUpdating automation..."));
30175
+ console.log(import_chalk18.default.gray("\nUpdating automation..."));
30131
30176
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`, {
30132
30177
  method: "PATCH",
30133
30178
  body
30134
30179
  });
30135
30180
  const automation2 = response.automation;
30136
- console.log(import_chalk17.default.green(`
30181
+ console.log(import_chalk18.default.green(`
30137
30182
  Updated automation: ${automation2.name}`));
30138
- console.log(import_chalk17.default.gray(` ID: ${automation2.id}`));
30139
- console.log(import_chalk17.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
30183
+ console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
30184
+ console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
30140
30185
  if (automation2.triggers.length > 0) {
30141
- console.log(import_chalk17.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30186
+ console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30142
30187
  }
30143
30188
  console.log();
30144
30189
  } catch (error51) {
30145
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30190
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30146
30191
  process.exit(1);
30147
30192
  }
30148
30193
  }
@@ -30153,12 +30198,12 @@ async function automationRunCommand(id) {
30153
30198
  const automation2 = existing.automation;
30154
30199
  const hasCronTrigger = automation2.triggers.some((t) => t.type === "cron");
30155
30200
  if (!hasCronTrigger) {
30156
- console.log(import_chalk17.default.red("\nManual run is only allowed for automations with a cron trigger."));
30157
- console.log(import_chalk17.default.gray(`This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30201
+ console.log(import_chalk18.default.red("\nManual run is only allowed for automations with a cron trigger."));
30202
+ console.log(import_chalk18.default.gray(`This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30158
30203
  console.log();
30159
30204
  process.exit(1);
30160
30205
  }
30161
- console.log(import_chalk17.default.gray(`
30206
+ console.log(import_chalk18.default.gray(`
30162
30207
  Triggering automation "${automation2.name}"...`));
30163
30208
  const response = await orgAuthenticatedFetch(
30164
30209
  `/v1/automations/${id}/trigger`,
@@ -30168,20 +30213,20 @@ Triggering automation "${automation2.name}"...`));
30168
30213
  }
30169
30214
  );
30170
30215
  if (!response.execution_id) {
30171
- console.log(import_chalk17.default.red(`
30216
+ console.log(import_chalk18.default.red(`
30172
30217
  Automation trigger returned no execution ID. The automation may not have started.`));
30173
30218
  console.log();
30174
30219
  process.exit(1);
30175
30220
  }
30176
- console.log(import_chalk17.default.green(`
30221
+ console.log(import_chalk18.default.green(`
30177
30222
  Automation triggered successfully.`));
30178
- console.log(import_chalk17.default.gray(` Execution ID: ${response.execution_id}`));
30223
+ console.log(import_chalk18.default.gray(` Execution ID: ${response.execution_id}`));
30179
30224
  if (response.workspace_id) {
30180
- console.log(import_chalk17.default.gray(` Workspace ID: ${response.workspace_id}`));
30225
+ console.log(import_chalk18.default.gray(` Workspace ID: ${response.workspace_id}`));
30181
30226
  }
30182
30227
  console.log();
30183
30228
  } catch (error51) {
30184
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30229
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30185
30230
  process.exit(1);
30186
30231
  }
30187
30232
  }
@@ -30198,38 +30243,38 @@ async function automationDeleteCommand(id, options) {
30198
30243
  initial: false
30199
30244
  });
30200
30245
  if (!response.confirm) {
30201
- console.log(import_chalk17.default.yellow("\nCancelled."));
30246
+ console.log(import_chalk18.default.yellow("\nCancelled."));
30202
30247
  return;
30203
30248
  }
30204
30249
  }
30205
30250
  await orgAuthenticatedFetch(`/v1/automations/${id}`, {
30206
30251
  method: "DELETE"
30207
30252
  });
30208
- console.log(import_chalk17.default.green(`
30253
+ console.log(import_chalk18.default.green(`
30209
30254
  Automation "${automationName}" (${id}) deleted.
30210
30255
  `));
30211
30256
  } catch (error51) {
30212
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30257
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30213
30258
  process.exit(1);
30214
30259
  }
30215
30260
  }
30216
30261
  async function automationCheckCommand(checkRunId, options) {
30217
30262
  const id = Number(checkRunId);
30218
30263
  if (!Number.isSafeInteger(id)) {
30219
- console.error(import_chalk17.default.red("Error: check run ID must be an integer"));
30264
+ console.error(import_chalk18.default.red("Error: check run ID must be an integer"));
30220
30265
  process.exit(1);
30221
30266
  }
30222
30267
  if (!options.token) {
30223
- console.error(import_chalk17.default.red("Error: --token is required"));
30268
+ console.error(import_chalk18.default.red("Error: --token is required"));
30224
30269
  process.exit(1);
30225
30270
  }
30226
30271
  const { conclusion } = options;
30227
30272
  if (!isAutomationCheckConclusion(conclusion)) {
30228
- console.error(import_chalk17.default.red(`Error: --conclusion must be one of ${AUTOMATION_CHECK_CONCLUSIONS.join(", ")}`));
30273
+ console.error(import_chalk18.default.red(`Error: --conclusion must be one of ${AUTOMATION_CHECK_CONCLUSIONS.join(", ")}`));
30229
30274
  process.exit(1);
30230
30275
  }
30231
30276
  if (!options.title?.trim()) {
30232
- console.error(import_chalk17.default.red("Error: --title is required"));
30277
+ console.error(import_chalk18.default.red("Error: --title is required"));
30233
30278
  process.exit(1);
30234
30279
  }
30235
30280
  const body = {
@@ -30243,19 +30288,19 @@ async function automationCheckCommand(checkRunId, options) {
30243
30288
  `/v1/automations/checks/${id}`,
30244
30289
  { method: "POST", body }
30245
30290
  );
30246
- console.log(response.reported ? import_chalk17.default.green(`
30291
+ console.log(response.reported ? import_chalk18.default.green(`
30247
30292
  Reported ${conclusion} for "${response.name}".
30248
- `) : import_chalk17.default.yellow(`
30293
+ `) : import_chalk18.default.yellow(`
30249
30294
  Skipped "${response.name}" \u2014 a newer run of this automation owns it and will report the verdict.
30250
30295
  `));
30251
30296
  } catch (error51) {
30252
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30297
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30253
30298
  process.exit(1);
30254
30299
  }
30255
30300
  }
30256
30301
 
30257
30302
  // src/commands/preview.ts
30258
- var import_chalk18 = __toESM(require("chalk"));
30303
+ var import_chalk19 = __toESM(require("chalk"));
30259
30304
 
30260
30305
  // src/lib/agent-api.ts
30261
30306
  var ENGINE_PORT = process.env.REPLICAS_ENGINE_PORT || "3737";
@@ -30307,13 +30352,7 @@ async function engineFetch(path6, options) {
30307
30352
  }
30308
30353
 
30309
30354
  // src/commands/preview.ts
30310
- function parsePreviewPort(port) {
30311
- const portNum = parseInt(port, 10);
30312
- if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
30313
- throw new Error("Port must be a number between 1 and 65535");
30314
- }
30315
- return portNum;
30316
- }
30355
+ var parsePreviewPort = parsePort;
30317
30356
  function createAgentPreview(port, authenticated) {
30318
30357
  return agentFetch("/v1/previews", {
30319
30358
  method: "POST",
@@ -30355,11 +30394,11 @@ async function previewListCommand(workspaceId) {
30355
30394
  `/v1/workspaces/${workspaceId}/previews`
30356
30395
  );
30357
30396
  if (result.previews.length === 0) {
30358
- console.log(import_chalk18.default.dim("No active previews"));
30397
+ console.log(import_chalk19.default.dim("No active previews"));
30359
30398
  return;
30360
30399
  }
30361
30400
  for (const preview2 of result.previews) {
30362
- console.log(` ${import_chalk18.default.cyan(String(preview2.port))} \u2192 ${import_chalk18.default.underline(preview2.publicUrl)}`);
30401
+ console.log(` ${import_chalk19.default.cyan(String(preview2.port))} \u2192 ${import_chalk19.default.underline(preview2.publicUrl)}`);
30363
30402
  }
30364
30403
  }
30365
30404
  }
@@ -30372,7 +30411,7 @@ async function previewAddCommand(workspaceId, options) {
30372
30411
  body: { port: portNum, authenticated: options.authenticated ?? false }
30373
30412
  }
30374
30413
  );
30375
- console.log(import_chalk18.default.green(`Preview created: ${result.preview.publicUrl}`));
30414
+ console.log(import_chalk19.default.green(`Preview created: ${result.preview.publicUrl}`));
30376
30415
  }
30377
30416
  async function previewDeleteCommand(port) {
30378
30417
  const portNum = parsePreviewPort(port);
@@ -30385,7 +30424,7 @@ async function previewRemoveCommand(workspaceId, options) {
30385
30424
  `/v1/workspaces/${workspaceId}/previews/${portNum}`,
30386
30425
  { method: "DELETE" }
30387
30426
  );
30388
- console.log(import_chalk18.default.green(`Preview deleted on port ${portNum}`));
30427
+ console.log(import_chalk19.default.green(`Preview deleted on port ${portNum}`));
30389
30428
  }
30390
30429
 
30391
30430
  // src/commands/media.ts
@@ -30558,7 +30597,7 @@ async function mediaListCommand(options) {
30558
30597
  }
30559
30598
 
30560
30599
  // src/commands/slack.ts
30561
- var import_chalk19 = __toESM(require("chalk"));
30600
+ var import_chalk20 = __toESM(require("chalk"));
30562
30601
  function getThreadOptions(options) {
30563
30602
  const channelId = options.channel || process.env.REPLICAS_SLACK_CHANNEL_ID || process.env.SLACK_CHANNEL_ID;
30564
30603
  const threadTs = options.threadTs || process.env.REPLICAS_SLACK_THREAD_TS || process.env.SLACK_THREAD_TS;
@@ -30575,10 +30614,10 @@ async function attachThread(request) {
30575
30614
  method: "POST",
30576
30615
  body: request
30577
30616
  });
30578
- console.log(import_chalk19.default.green("Slack thread attached."));
30579
- console.log(import_chalk19.default.gray(` Channel: ${response.thread.channel_id}`));
30580
- console.log(import_chalk19.default.gray(` Thread: ${response.thread.thread_ts}`));
30581
- console.log(import_chalk19.default.gray(` Workspace: ${response.workspace.name} (${response.workspace.id})`));
30617
+ console.log(import_chalk20.default.green("Slack thread attached."));
30618
+ console.log(import_chalk20.default.gray(` Channel: ${response.thread.channel_id}`));
30619
+ console.log(import_chalk20.default.gray(` Thread: ${response.thread.thread_ts}`));
30620
+ console.log(import_chalk20.default.gray(` Workspace: ${response.workspace.name} (${response.workspace.id})`));
30582
30621
  }
30583
30622
  async function slackThreadAttachCommand(options) {
30584
30623
  const agentConfig = readAgentConfig();
@@ -30607,7 +30646,7 @@ async function slackThreadSwitchCommand(workspace, options) {
30607
30646
  }
30608
30647
 
30609
30648
  // src/commands/service.ts
30610
- var import_chalk20 = __toESM(require("chalk"));
30649
+ var import_chalk21 = __toESM(require("chalk"));
30611
30650
  var import_node_child_process = require("child_process");
30612
30651
  var import_node_fs = require("fs");
30613
30652
  var import_node_os = require("os");
@@ -30750,7 +30789,7 @@ async function serviceListCommand() {
30750
30789
  return;
30751
30790
  }
30752
30791
  for (const state of states) {
30753
- const status = isRunning(state.pid) ? import_chalk20.default.green("running") : import_chalk20.default.red("stopped");
30792
+ const status = isRunning(state.pid) ? import_chalk21.default.green("running") : import_chalk21.default.red("stopped");
30754
30793
  console.log(`${state.name} ${status} pid ${state.pid} started ${state.startedAt}`);
30755
30794
  console.log(` command: ${state.command} (cwd: ${state.cwd})`);
30756
30795
  console.log(` logs: ${state.logFile}`);
@@ -30810,7 +30849,7 @@ async function mothershipRelayCommand(options) {
30810
30849
 
30811
30850
  // src/commands/environment.ts
30812
30851
  var import_fs5 = __toESM(require("fs"));
30813
- var import_chalk21 = __toESM(require("chalk"));
30852
+ var import_chalk22 = __toESM(require("chalk"));
30814
30853
  var import_prompts8 = __toESM(require("prompts"));
30815
30854
  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}$/;
30816
30855
  function maskValue(value) {
@@ -30823,38 +30862,38 @@ async function resolveEnvironmentId(input) {
30823
30862
  const response = await orgAuthenticatedFetch("/v1/environments");
30824
30863
  const resolved = resolveByNameOrId(input, response.environments);
30825
30864
  if (!resolved) {
30826
- console.log(import_chalk21.default.red(`Environment not found: ${input}`));
30865
+ console.log(import_chalk22.default.red(`Environment not found: ${input}`));
30827
30866
  const available = response.environments.map((e) => e.name).join(", ");
30828
- console.log(import_chalk21.default.gray(`Available: ${available || "(none)"}`));
30867
+ console.log(import_chalk22.default.gray(`Available: ${available || "(none)"}`));
30829
30868
  process.exit(1);
30830
30869
  }
30831
30870
  return resolved.id;
30832
30871
  }
30833
30872
  function printEnvironment(env) {
30834
- console.log(import_chalk21.default.white(` ${env.name}${env.is_global ? import_chalk21.default.gray(" (global)") : ""}`));
30835
- console.log(import_chalk21.default.gray(` ID: ${env.id}`));
30873
+ console.log(import_chalk22.default.white(` ${env.name}${env.is_global ? import_chalk22.default.gray(" (global)") : ""}`));
30874
+ console.log(import_chalk22.default.gray(` ID: ${env.id}`));
30836
30875
  if (env.description) {
30837
- console.log(import_chalk21.default.gray(` Description: ${env.description}`));
30876
+ console.log(import_chalk22.default.gray(` Description: ${env.description}`));
30838
30877
  }
30839
30878
  if (env.repository_id) {
30840
- console.log(import_chalk21.default.gray(` Repository: ${env.repository_id}`));
30879
+ console.log(import_chalk22.default.gray(` Repository: ${env.repository_id}`));
30841
30880
  } else if (env.repository_set_id) {
30842
- console.log(import_chalk21.default.gray(` Repository Set: ${env.repository_set_id}`));
30881
+ console.log(import_chalk22.default.gray(` Repository Set: ${env.repository_set_id}`));
30843
30882
  }
30844
30883
  if (env.variable_count !== void 0) {
30845
- console.log(import_chalk21.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
30884
+ console.log(import_chalk22.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
30846
30885
  }
30847
- console.log(import_chalk21.default.gray(` Updated: ${formatDate2(env.updated_at)}`));
30886
+ console.log(import_chalk22.default.gray(` Updated: ${formatDate2(env.updated_at)}`));
30848
30887
  console.log();
30849
30888
  }
30850
30889
  async function environmentListCommand() {
30851
30890
  ensureOrgApiAuthenticated();
30852
30891
  const response = await orgAuthenticatedFetch("/v1/environments");
30853
30892
  if (response.environments.length === 0) {
30854
- console.log(import_chalk21.default.yellow("\nNo environments found.\n"));
30893
+ console.log(import_chalk22.default.yellow("\nNo environments found.\n"));
30855
30894
  return;
30856
30895
  }
30857
- console.log(import_chalk21.default.green(`
30896
+ console.log(import_chalk22.default.green(`
30858
30897
  Environments (${response.environments.length}):
30859
30898
  `));
30860
30899
  for (const env of response.environments) {
@@ -30865,7 +30904,7 @@ async function environmentGetCommand(idOrName) {
30865
30904
  ensureOrgApiAuthenticated();
30866
30905
  const id = await resolveEnvironmentId(idOrName);
30867
30906
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}`);
30868
- console.log(import_chalk21.default.green(`
30907
+ console.log(import_chalk22.default.green(`
30869
30908
  Environment: ${response.environment.name}
30870
30909
  `));
30871
30910
  printEnvironment(response.environment);
@@ -30881,7 +30920,7 @@ async function environmentCreateCommand(name, options) {
30881
30920
  validate: (v) => v.trim() ? true : "Name is required"
30882
30921
  });
30883
30922
  if (!r.name) {
30884
- console.log(import_chalk21.default.yellow("\nCancelled."));
30923
+ console.log(import_chalk22.default.yellow("\nCancelled."));
30885
30924
  return;
30886
30925
  }
30887
30926
  envName = r.name;
@@ -30894,8 +30933,8 @@ async function environmentCreateCommand(name, options) {
30894
30933
  const repos2 = await orgAuthenticatedFetch("/v1/repositories");
30895
30934
  const repo = repos2.repositories.find((r) => r.name === options.repository);
30896
30935
  if (!repo) {
30897
- console.log(import_chalk21.default.red(`Repository not found: ${options.repository}`));
30898
- console.log(import_chalk21.default.gray(`Available: ${repos2.repositories.map((r) => r.name).join(", ")}`));
30936
+ console.log(import_chalk22.default.red(`Repository not found: ${options.repository}`));
30937
+ console.log(import_chalk22.default.gray(`Available: ${repos2.repositories.map((r) => r.name).join(", ")}`));
30899
30938
  process.exit(1);
30900
30939
  }
30901
30940
  repositoryId = repo.id;
@@ -30925,9 +30964,9 @@ async function environmentCreateCommand(name, options) {
30925
30964
  method: "POST",
30926
30965
  body
30927
30966
  });
30928
- console.log(import_chalk21.default.green(`
30967
+ console.log(import_chalk22.default.green(`
30929
30968
  Created environment: ${response.environment.name}`));
30930
- console.log(import_chalk21.default.gray(` ID: ${response.environment.id}
30969
+ console.log(import_chalk22.default.gray(` ID: ${response.environment.id}
30931
30970
  `));
30932
30971
  }
30933
30972
  async function environmentEditCommand(idOrName, options) {
@@ -30946,21 +30985,21 @@ async function environmentEditCommand(idOrName, options) {
30946
30985
  const repos2 = await orgAuthenticatedFetch("/v1/repositories");
30947
30986
  const repo = repos2.repositories.find((r) => r.name === options.repository);
30948
30987
  if (!repo) {
30949
- console.log(import_chalk21.default.red(`Repository not found: ${options.repository}`));
30988
+ console.log(import_chalk22.default.red(`Repository not found: ${options.repository}`));
30950
30989
  process.exit(1);
30951
30990
  }
30952
30991
  body.repository_id = repo.id;
30953
30992
  }
30954
30993
  }
30955
30994
  if (Object.keys(body).length === 0) {
30956
- console.log(import_chalk21.default.yellow("\nNo changes specified. Pass --name, --description, --repository, or --system-prompt."));
30995
+ console.log(import_chalk22.default.yellow("\nNo changes specified. Pass --name, --description, --repository, or --system-prompt."));
30957
30996
  return;
30958
30997
  }
30959
30998
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}`, {
30960
30999
  method: "PATCH",
30961
31000
  body
30962
31001
  });
30963
- console.log(import_chalk21.default.green(`
31002
+ console.log(import_chalk22.default.green(`
30964
31003
  Updated environment: ${response.environment.name}
30965
31004
  `));
30966
31005
  }
@@ -30975,20 +31014,20 @@ async function environmentDeleteCommand(idOrName, options) {
30975
31014
  initial: false
30976
31015
  });
30977
31016
  if (!r.confirm) {
30978
- console.log(import_chalk21.default.yellow("\nCancelled."));
31017
+ console.log(import_chalk22.default.yellow("\nCancelled."));
30979
31018
  return;
30980
31019
  }
30981
31020
  }
30982
31021
  await orgAuthenticatedFetch(`/v1/environments/${id}`, { method: "DELETE" });
30983
- console.log(import_chalk21.default.green(`
31022
+ console.log(import_chalk22.default.green(`
30984
31023
  Deleted environment ${idOrName}.
30985
31024
  `));
30986
31025
  }
30987
31026
  function printVariable(v, reveal) {
30988
- console.log(import_chalk21.default.white(` ${v.key}`));
30989
- console.log(import_chalk21.default.gray(` ID: ${v.id}`));
30990
- console.log(import_chalk21.default.gray(` Value: ${reveal ? v.value : maskValue(v.value)}`));
30991
- console.log(import_chalk21.default.gray(` Updated: ${formatDate2(v.updated_at)}`));
31027
+ console.log(import_chalk22.default.white(` ${v.key}`));
31028
+ console.log(import_chalk22.default.gray(` ID: ${v.id}`));
31029
+ console.log(import_chalk22.default.gray(` Value: ${reveal ? v.value : maskValue(v.value)}`));
31030
+ console.log(import_chalk22.default.gray(` Updated: ${formatDate2(v.updated_at)}`));
30992
31031
  console.log();
30993
31032
  }
30994
31033
  async function envVarsListCommand(envIdOrName, options) {
@@ -30998,14 +31037,14 @@ async function envVarsListCommand(envIdOrName, options) {
30998
31037
  `/v1/environments/${id}/variables`
30999
31038
  );
31000
31039
  if (response.environment_variables.length === 0) {
31001
- console.log(import_chalk21.default.yellow("\nNo variables.\n"));
31040
+ console.log(import_chalk22.default.yellow("\nNo variables.\n"));
31002
31041
  return;
31003
31042
  }
31004
- console.log(import_chalk21.default.green(`
31043
+ console.log(import_chalk22.default.green(`
31005
31044
  Variables (${response.environment_variables.length}):
31006
31045
  `));
31007
31046
  if (!options.reveal) {
31008
- console.log(import_chalk21.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
31047
+ console.log(import_chalk22.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
31009
31048
  }
31010
31049
  for (const v of response.environment_variables) printVariable(v, !!options.reveal);
31011
31050
  }
@@ -31022,7 +31061,7 @@ async function envVarsSetCommand(envIdOrName, key, value) {
31022
31061
  `/v1/environments/${id}/variables/${match.id}`,
31023
31062
  { method: "PATCH", body: body2 }
31024
31063
  );
31025
- console.log(import_chalk21.default.green(`
31064
+ console.log(import_chalk22.default.green(`
31026
31065
  Updated variable ${response2.environment_variable.key}.
31027
31066
  `));
31028
31067
  return;
@@ -31036,7 +31075,7 @@ Updated variable ${response2.environment_variable.key}.
31036
31075
  `/v1/environments/${id}/variables`,
31037
31076
  { method: "POST", body }
31038
31077
  );
31039
- console.log(import_chalk21.default.green(`
31078
+ console.log(import_chalk22.default.green(`
31040
31079
  Created variable ${response.environment_variable.key}.
31041
31080
  `));
31042
31081
  }
@@ -31050,7 +31089,7 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
31050
31089
  );
31051
31090
  const match = existing.environment_variables.find((v) => v.key === keyOrId);
31052
31091
  if (!match) {
31053
- console.log(import_chalk21.default.red(`Variable not found: ${keyOrId}`));
31092
+ console.log(import_chalk22.default.red(`Variable not found: ${keyOrId}`));
31054
31093
  process.exit(1);
31055
31094
  }
31056
31095
  variableId = match.id;
@@ -31063,23 +31102,23 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
31063
31102
  initial: false
31064
31103
  });
31065
31104
  if (!r.confirm) {
31066
- console.log(import_chalk21.default.yellow("\nCancelled."));
31105
+ console.log(import_chalk22.default.yellow("\nCancelled."));
31067
31106
  return;
31068
31107
  }
31069
31108
  }
31070
31109
  await orgAuthenticatedFetch(`/v1/environments/${id}/variables/${variableId}`, {
31071
31110
  method: "DELETE"
31072
31111
  });
31073
- console.log(import_chalk21.default.green(`
31112
+ console.log(import_chalk22.default.green(`
31074
31113
  Deleted variable ${keyOrId}.
31075
31114
  `));
31076
31115
  }
31077
31116
  function printFile(f) {
31078
- console.log(import_chalk21.default.white(` ${f.path}`));
31079
- console.log(import_chalk21.default.gray(` ID: ${f.id}`));
31080
- console.log(import_chalk21.default.gray(` Name: ${f.name}`));
31081
- console.log(import_chalk21.default.gray(` Size: ${f.content.length} bytes`));
31082
- console.log(import_chalk21.default.gray(` Updated: ${formatDate2(f.updated_at)}`));
31117
+ console.log(import_chalk22.default.white(` ${f.path}`));
31118
+ console.log(import_chalk22.default.gray(` ID: ${f.id}`));
31119
+ console.log(import_chalk22.default.gray(` Name: ${f.name}`));
31120
+ console.log(import_chalk22.default.gray(` Size: ${f.content.length} bytes`));
31121
+ console.log(import_chalk22.default.gray(` Updated: ${formatDate2(f.updated_at)}`));
31083
31122
  console.log();
31084
31123
  }
31085
31124
  async function envFilesListCommand(envIdOrName) {
@@ -31089,10 +31128,10 @@ async function envFilesListCommand(envIdOrName) {
31089
31128
  `/v1/environments/${id}/files`
31090
31129
  );
31091
31130
  if (response.environment_files.length === 0) {
31092
- console.log(import_chalk21.default.yellow("\nNo files.\n"));
31131
+ console.log(import_chalk22.default.yellow("\nNo files.\n"));
31093
31132
  return;
31094
31133
  }
31095
- console.log(import_chalk21.default.green(`
31134
+ console.log(import_chalk22.default.green(`
31096
31135
  Files (${response.environment_files.length}):
31097
31136
  `));
31098
31137
  for (const f of response.environment_files) printFile(f);
@@ -31123,7 +31162,7 @@ async function envFilesSetCommand(envIdOrName, destinationPath, options) {
31123
31162
  `/v1/environments/${id}/files/${match.id}`,
31124
31163
  { method: "PATCH", body: body2 }
31125
31164
  );
31126
- console.log(import_chalk21.default.green(`
31165
+ console.log(import_chalk22.default.green(`
31127
31166
  Updated file ${response2.environment_file.path}.
31128
31167
  `));
31129
31168
  return;
@@ -31138,7 +31177,7 @@ Updated file ${response2.environment_file.path}.
31138
31177
  `/v1/environments/${id}/files`,
31139
31178
  { method: "POST", body }
31140
31179
  );
31141
- console.log(import_chalk21.default.green(`
31180
+ console.log(import_chalk22.default.green(`
31142
31181
  Created file ${response.environment_file.path}.
31143
31182
  `));
31144
31183
  }
@@ -31152,7 +31191,7 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
31152
31191
  );
31153
31192
  const match = existing.environment_files.find((f) => f.path === pathOrId);
31154
31193
  if (!match) {
31155
- console.log(import_chalk21.default.red(`File not found: ${pathOrId}`));
31194
+ console.log(import_chalk22.default.red(`File not found: ${pathOrId}`));
31156
31195
  process.exit(1);
31157
31196
  }
31158
31197
  fileId = match.id;
@@ -31165,14 +31204,14 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
31165
31204
  initial: false
31166
31205
  });
31167
31206
  if (!r.confirm) {
31168
- console.log(import_chalk21.default.yellow("\nCancelled."));
31207
+ console.log(import_chalk22.default.yellow("\nCancelled."));
31169
31208
  return;
31170
31209
  }
31171
31210
  }
31172
31211
  await orgAuthenticatedFetch(`/v1/environments/${id}/files/${fileId}`, {
31173
31212
  method: "DELETE"
31174
31213
  });
31175
- console.log(import_chalk21.default.green(`
31214
+ console.log(import_chalk22.default.green(`
31176
31215
  Deleted file ${pathOrId}.
31177
31216
  `));
31178
31217
  }
@@ -31181,16 +31220,16 @@ async function envHookGetCommand(envIdOrName, kind) {
31181
31220
  const id = await resolveEnvironmentId(envIdOrName);
31182
31221
  const hook = kind === "warm" ? (await orgAuthenticatedFetch(`/v1/environments/${id}/warm-hooks`)).warm_hook : (await orgAuthenticatedFetch(`/v1/environments/${id}/start-hooks`)).start_hook;
31183
31222
  if (!hook) {
31184
- console.log(import_chalk21.default.yellow(`
31223
+ console.log(import_chalk22.default.yellow(`
31185
31224
  No ${kind} hook configured.
31186
31225
  `));
31187
31226
  return;
31188
31227
  }
31189
- console.log(import_chalk21.default.green(`
31228
+ console.log(import_chalk22.default.green(`
31190
31229
  ${kind === "warm" ? "Warm" : "Start"} hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
31191
31230
  `));
31192
- console.log(import_chalk21.default.gray(` ID: ${hook.id}`));
31193
- console.log(import_chalk21.default.gray(` Created: ${formatDate2(hook.created_at)}
31231
+ console.log(import_chalk22.default.gray(` ID: ${hook.id}`));
31232
+ console.log(import_chalk22.default.gray(` Created: ${formatDate2(hook.created_at)}
31194
31233
  `));
31195
31234
  console.log(hook.content);
31196
31235
  console.log();
@@ -31205,7 +31244,7 @@ async function envHookSaveCommand(envIdOrName, options, kind) {
31205
31244
  `/v1/environments/${id}/warm-hooks/save`,
31206
31245
  { method: "POST", body: body2 }
31207
31246
  );
31208
- console.log(import_chalk21.default.green(`
31247
+ console.log(import_chalk22.default.green(`
31209
31248
  Saved warm hook v${response2.warm_hook.version}.
31210
31249
  `));
31211
31250
  return;
@@ -31215,7 +31254,7 @@ Saved warm hook v${response2.warm_hook.version}.
31215
31254
  `/v1/environments/${id}/start-hooks/save`,
31216
31255
  { method: "POST", body }
31217
31256
  );
31218
- console.log(import_chalk21.default.green(response.start_hook ? `
31257
+ console.log(import_chalk22.default.green(response.start_hook ? `
31219
31258
  Saved start hook v${response.start_hook.version}.
31220
31259
  ` : "\nCleared start hook.\n"));
31221
31260
  }
@@ -31232,7 +31271,7 @@ async function envHookTestCommand(envIdOrName, options, kind) {
31232
31271
  body: kind === "warm" ? { content, mode: options.save ? "save_test" : "test_only" } : { content },
31233
31272
  onEvent: (event) => {
31234
31273
  if (event.type === "progress" && event.message) {
31235
- console.log(import_chalk21.default.gray(event.message));
31274
+ console.log(import_chalk22.default.gray(event.message));
31236
31275
  } else if (event.type === "output" && event.output) {
31237
31276
  process.stdout.write(event.output);
31238
31277
  } else if (event.type === "complete") {
@@ -31245,23 +31284,23 @@ async function envHookTestCommand(envIdOrName, options, kind) {
31245
31284
  }
31246
31285
  );
31247
31286
  if (errorMessage) {
31248
- console.log(import_chalk21.default.red(`
31287
+ console.log(import_chalk22.default.red(`
31249
31288
  ${errorMessage}
31250
31289
  `));
31251
31290
  process.exit(1);
31252
31291
  }
31253
31292
  if (timedOut) {
31254
- console.log(import_chalk21.default.yellow(`
31293
+ console.log(import_chalk22.default.yellow(`
31255
31294
  ${kind === "warm" ? "Warm" : "Start"} hook timed out.
31256
31295
  `));
31257
31296
  process.exit(1);
31258
31297
  }
31259
31298
  if (exitCode === 0) {
31260
- console.log(import_chalk21.default.green(`
31299
+ console.log(import_chalk22.default.green(`
31261
31300
  ${kind === "warm" ? "Warm" : "Start"} hook passed${options.save ? " and was saved" : ""} (exit code ${exitCode}).
31262
31301
  `));
31263
31302
  } else {
31264
- console.log(import_chalk21.default.red(`
31303
+ console.log(import_chalk22.default.red(`
31265
31304
  ${kind === "warm" ? "Warm" : "Start"} hook failed (exit code ${exitCode ?? "unknown"}).
31266
31305
  `));
31267
31306
  process.exit(1);
@@ -31276,24 +31315,24 @@ async function envHookRepositoryHooksCommand(envIdOrName, kind) {
31276
31315
  `/v1/environments/${id}/start-hooks/repository-hooks`
31277
31316
  )).repositories.map((repository) => ({ ...repository, hook: repository.start_hook }));
31278
31317
  if (repositories.length === 0) {
31279
- console.log(import_chalk21.default.yellow("\nNo repositories bound to this environment.\n"));
31318
+ console.log(import_chalk22.default.yellow("\nNo repositories bound to this environment.\n"));
31280
31319
  return;
31281
31320
  }
31282
- console.log(import_chalk21.default.green(`
31321
+ console.log(import_chalk22.default.green(`
31283
31322
  Repository ${kind} hooks (${repositories.length}):
31284
31323
  `));
31285
31324
  for (const repo of repositories) {
31286
- console.log(import_chalk21.default.white(` ${repo.repository_name} @${repo.default_branch}`));
31325
+ console.log(import_chalk22.default.white(` ${repo.repository_name} @${repo.default_branch}`));
31287
31326
  if (repo.error) {
31288
- console.log(import_chalk21.default.red(` Error: ${repo.error}`));
31327
+ console.log(import_chalk22.default.red(` Error: ${repo.error}`));
31289
31328
  } else if (repo.hook) {
31290
- console.log(import_chalk21.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
31291
- console.log(import_chalk21.default.gray(` Commands (${repo.hook.commands.length}):`));
31329
+ console.log(import_chalk22.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
31330
+ console.log(import_chalk22.default.gray(` Commands (${repo.hook.commands.length}):`));
31292
31331
  for (const cmd of repo.hook.commands) {
31293
- console.log(import_chalk21.default.gray(` ${cmd}`));
31332
+ console.log(import_chalk22.default.gray(` ${cmd}`));
31294
31333
  }
31295
31334
  } else {
31296
- console.log(import_chalk21.default.gray(` No ${kind}Hook defined.`));
31335
+ console.log(import_chalk22.default.gray(` No ${kind}Hook defined.`));
31297
31336
  }
31298
31337
  console.log();
31299
31338
  }
@@ -31357,7 +31396,7 @@ program.hook("preAction", async (_command, actionCommand) => {
31357
31396
  throw new Error('No organization selected. Run "replicas org switch" to select one.');
31358
31397
  }
31359
31398
  } catch (error51) {
31360
- console.error(import_chalk22.default.red(`
31399
+ console.error(import_chalk23.default.red(`
31361
31400
  \u2717 ${error51 instanceof Error ? error51.message : "Unknown error"}
31362
31401
  `));
31363
31402
  process.exit(1);
@@ -31371,7 +31410,7 @@ function registerSlackCommands(parent) {
31371
31410
  await slackThreadAttachCommand(options);
31372
31411
  } catch (error51) {
31373
31412
  if (error51 instanceof Error) {
31374
- console.error(import_chalk22.default.red(`
31413
+ console.error(import_chalk23.default.red(`
31375
31414
  \u2717 ${error51.message}
31376
31415
  `));
31377
31416
  }
@@ -31383,7 +31422,7 @@ function registerSlackCommands(parent) {
31383
31422
  await slackThreadSwitchCommand(workspace, options);
31384
31423
  } catch (error51) {
31385
31424
  if (error51 instanceof Error) {
31386
- console.error(import_chalk22.default.red(`
31425
+ console.error(import_chalk23.default.red(`
31387
31426
  \u2717 ${error51.message}
31388
31427
  `));
31389
31428
  }
@@ -31397,7 +31436,7 @@ program.command("login").description("Authenticate with your Replicas account").
31397
31436
  await loginCommand();
31398
31437
  } catch (error51) {
31399
31438
  if (error51 instanceof Error) {
31400
- console.error(import_chalk22.default.red(`
31439
+ console.error(import_chalk23.default.red(`
31401
31440
  \u2717 ${error51.message}
31402
31441
  `));
31403
31442
  }
@@ -31409,7 +31448,7 @@ program.command("init").description("Create a replicas.json or replicas.yaml con
31409
31448
  initCommand(options);
31410
31449
  } catch (error51) {
31411
31450
  if (error51 instanceof Error) {
31412
- console.error(import_chalk22.default.red(`
31451
+ console.error(import_chalk23.default.red(`
31413
31452
  \u2717 ${error51.message}
31414
31453
  `));
31415
31454
  }
@@ -31421,7 +31460,7 @@ program.command("logout").description("Clear stored credentials").action(() => {
31421
31460
  logoutCommand();
31422
31461
  } catch (error51) {
31423
31462
  if (error51 instanceof Error) {
31424
- console.error(import_chalk22.default.red(`
31463
+ console.error(import_chalk23.default.red(`
31425
31464
  \u2717 ${error51.message}
31426
31465
  `));
31427
31466
  }
@@ -31433,7 +31472,7 @@ program.command("whoami").description("Display current authenticated user").acti
31433
31472
  await whoamiCommand();
31434
31473
  } catch (error51) {
31435
31474
  if (error51 instanceof Error) {
31436
- console.error(import_chalk22.default.red(`
31475
+ console.error(import_chalk23.default.red(`
31437
31476
  \u2717 ${error51.message}
31438
31477
  `));
31439
31478
  }
@@ -31445,7 +31484,7 @@ program.command("codex-auth").description("Connect your Codex credentials to Rep
31445
31484
  await codexAuthCommand(options);
31446
31485
  } catch (error51) {
31447
31486
  if (error51 instanceof Error) {
31448
- console.error(import_chalk22.default.red(`
31487
+ console.error(import_chalk23.default.red(`
31449
31488
  \u2717 ${error51.message}
31450
31489
  `));
31451
31490
  }
@@ -31457,7 +31496,7 @@ program.command("claude-auth").description("Connect your Claude Code credentials
31457
31496
  await claudeAuthCommand(options);
31458
31497
  } catch (error51) {
31459
31498
  if (error51 instanceof Error) {
31460
- console.error(import_chalk22.default.red(`
31499
+ console.error(import_chalk23.default.red(`
31461
31500
  \u2717 ${error51.message}
31462
31501
  `));
31463
31502
  }
@@ -31470,7 +31509,7 @@ org.command("switch").description("Switch to a different organization").action(a
31470
31509
  await orgSwitchCommand();
31471
31510
  } catch (error51) {
31472
31511
  if (error51 instanceof Error) {
31473
- console.error(import_chalk22.default.red(`
31512
+ console.error(import_chalk23.default.red(`
31474
31513
  \u2717 ${error51.message}
31475
31514
  `));
31476
31515
  }
@@ -31482,7 +31521,7 @@ org.action(async () => {
31482
31521
  await orgCommand();
31483
31522
  } catch (error51) {
31484
31523
  if (error51 instanceof Error) {
31485
- console.error(import_chalk22.default.red(`
31524
+ console.error(import_chalk23.default.red(`
31486
31525
  \u2717 ${error51.message}
31487
31526
  `));
31488
31527
  }
@@ -31494,19 +31533,28 @@ program.command("connect <workspace-name...>").description("Connect to a workspa
31494
31533
  await connectCommand(workspaceName.join(" "));
31495
31534
  } catch (error51) {
31496
31535
  if (error51 instanceof Error) {
31497
- console.error(import_chalk22.default.red(`
31536
+ console.error(import_chalk23.default.red(`
31498
31537
  \u2717 ${error51.message}
31499
31538
  `));
31500
31539
  }
31501
31540
  process.exit(1);
31502
31541
  }
31503
31542
  });
31543
+ program.command("tunnel <workspace-name...>").description("Forward a workspace port to localhost").requiredOption("-p, --port <port>", "Workspace port to forward").option("-l, --local-port <port>", "Local port (defaults to the workspace port)").action(async (workspaceName, options) => {
31544
+ try {
31545
+ await tunnelCommand(workspaceName.join(" "), options);
31546
+ } catch (error51) {
31547
+ console.error(import_chalk23.default.red(`
31548
+ Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31549
+ process.exit(1);
31550
+ }
31551
+ });
31504
31552
  program.command("code <workspace-name...>").description("Open a workspace in VSCode/Cursor via Remote SSH").action(async (workspaceName) => {
31505
31553
  try {
31506
31554
  await codeCommand(workspaceName.join(" "));
31507
31555
  } catch (error51) {
31508
31556
  if (error51 instanceof Error) {
31509
- console.error(import_chalk22.default.red(`
31557
+ console.error(import_chalk23.default.red(`
31510
31558
  \u2717 ${error51.message}
31511
31559
  `));
31512
31560
  }
@@ -31519,7 +31567,7 @@ config2.command("get <key>").description("Get a configuration value").action(asy
31519
31567
  await configGetCommand(key);
31520
31568
  } catch (error51) {
31521
31569
  if (error51 instanceof Error) {
31522
- console.error(import_chalk22.default.red(`
31570
+ console.error(import_chalk23.default.red(`
31523
31571
  \u2717 ${error51.message}
31524
31572
  `));
31525
31573
  }
@@ -31531,7 +31579,7 @@ config2.command("set <key> <value>").description("Set a configuration value").ac
31531
31579
  await configSetCommand(key, value);
31532
31580
  } catch (error51) {
31533
31581
  if (error51 instanceof Error) {
31534
- console.error(import_chalk22.default.red(`
31582
+ console.error(import_chalk23.default.red(`
31535
31583
  \u2717 ${error51.message}
31536
31584
  `));
31537
31585
  }
@@ -31543,7 +31591,7 @@ config2.command("list").description("List all configuration values").action(asyn
31543
31591
  await configListCommand();
31544
31592
  } catch (error51) {
31545
31593
  if (error51 instanceof Error) {
31546
- console.error(import_chalk22.default.red(`
31594
+ console.error(import_chalk23.default.red(`
31547
31595
  \u2717 ${error51.message}
31548
31596
  `));
31549
31597
  }
@@ -31555,7 +31603,7 @@ program.command("list").description("List all replicas").option("-p, --page <pag
31555
31603
  await replicaListCommand(options);
31556
31604
  } catch (error51) {
31557
31605
  if (error51 instanceof Error) {
31558
- console.error(import_chalk22.default.red(`
31606
+ console.error(import_chalk23.default.red(`
31559
31607
  \u2717 ${error51.message}
31560
31608
  `));
31561
31609
  }
@@ -31567,7 +31615,7 @@ program.command("get <id>").description("Get replica details by ID").action(asyn
31567
31615
  await replicaGetCommand(id);
31568
31616
  } catch (error51) {
31569
31617
  if (error51 instanceof Error) {
31570
- console.error(import_chalk22.default.red(`
31618
+ console.error(import_chalk23.default.red(`
31571
31619
  \u2717 ${error51.message}
31572
31620
  `));
31573
31621
  }
@@ -31579,7 +31627,7 @@ program.command("create [name]").description("Create a new replica").option("-m,
31579
31627
  await replicaCreateCommand(name, options);
31580
31628
  } catch (error51) {
31581
31629
  if (error51 instanceof Error) {
31582
- console.error(import_chalk22.default.red(`
31630
+ console.error(import_chalk23.default.red(`
31583
31631
  \u2717 ${error51.message}
31584
31632
  `));
31585
31633
  }
@@ -31591,7 +31639,7 @@ program.command("send <id>").description("Send a message to a replica").option("
31591
31639
  await replicaSendCommand(id, options);
31592
31640
  } catch (error51) {
31593
31641
  if (error51 instanceof Error) {
31594
- console.error(import_chalk22.default.red(`
31642
+ console.error(import_chalk23.default.red(`
31595
31643
  \u2717 ${error51.message}
31596
31644
  `));
31597
31645
  }
@@ -31603,7 +31651,7 @@ program.command("delete <id>").description("Delete a replica").option("-f, --for
31603
31651
  await replicaDeleteCommand(id, options);
31604
31652
  } catch (error51) {
31605
31653
  if (error51 instanceof Error) {
31606
- console.error(import_chalk22.default.red(`
31654
+ console.error(import_chalk23.default.red(`
31607
31655
  \u2717 ${error51.message}
31608
31656
  `));
31609
31657
  }
@@ -31615,7 +31663,7 @@ program.command("read <id>").description("Read conversation history of a replica
31615
31663
  await replicaReadCommand(id, options);
31616
31664
  } catch (error51) {
31617
31665
  if (error51 instanceof Error) {
31618
- console.error(import_chalk22.default.red(`
31666
+ console.error(import_chalk23.default.red(`
31619
31667
  \u2717 ${error51.message}
31620
31668
  `));
31621
31669
  }
@@ -31628,7 +31676,7 @@ automation.command("list").description("List all automations").option("-p, --pag
31628
31676
  await automationListCommand(options);
31629
31677
  } catch (error51) {
31630
31678
  if (error51 instanceof Error) {
31631
- console.error(import_chalk22.default.red(`
31679
+ console.error(import_chalk23.default.red(`
31632
31680
  \u2717 ${error51.message}
31633
31681
  `));
31634
31682
  }
@@ -31640,7 +31688,7 @@ automation.command("get <id>").description("Get automation details by ID").actio
31640
31688
  await automationGetCommand(id);
31641
31689
  } catch (error51) {
31642
31690
  if (error51 instanceof Error) {
31643
- console.error(import_chalk22.default.red(`
31691
+ console.error(import_chalk23.default.red(`
31644
31692
  \u2717 ${error51.message}
31645
31693
  `));
31646
31694
  }
@@ -31655,7 +31703,7 @@ automation.command("create [name]").description("Create a new automation").optio
31655
31703
  });
31656
31704
  } catch (error51) {
31657
31705
  if (error51 instanceof Error) {
31658
- console.error(import_chalk22.default.red(`
31706
+ console.error(import_chalk23.default.red(`
31659
31707
  \u2717 ${error51.message}
31660
31708
  `));
31661
31709
  }
@@ -31667,7 +31715,7 @@ automation.command("edit <id>").description("Edit an existing automation").optio
31667
31715
  await automationEditCommand(id, options);
31668
31716
  } catch (error51) {
31669
31717
  if (error51 instanceof Error) {
31670
- console.error(import_chalk22.default.red(`
31718
+ console.error(import_chalk23.default.red(`
31671
31719
  \u2717 ${error51.message}
31672
31720
  `));
31673
31721
  }
@@ -31679,7 +31727,7 @@ automation.command("run <id>").description("Manually trigger an automation (cron
31679
31727
  await automationRunCommand(id);
31680
31728
  } catch (error51) {
31681
31729
  if (error51 instanceof Error) {
31682
- console.error(import_chalk22.default.red(`
31730
+ console.error(import_chalk23.default.red(`
31683
31731
  \u2717 ${error51.message}
31684
31732
  `));
31685
31733
  }
@@ -31691,7 +31739,7 @@ automation.command("delete <id>").description("Delete an automation").option("-f
31691
31739
  await automationDeleteCommand(id, options);
31692
31740
  } catch (error51) {
31693
31741
  if (error51 instanceof Error) {
31694
- console.error(import_chalk22.default.red(`
31742
+ console.error(import_chalk23.default.red(`
31695
31743
  \u2717 ${error51.message}
31696
31744
  `));
31697
31745
  }
@@ -31703,7 +31751,7 @@ automation.command("check <checkRunId>").description("Report this automation run
31703
31751
  await automationCheckCommand(checkRunId, options);
31704
31752
  } catch (error51) {
31705
31753
  if (error51 instanceof Error) {
31706
- console.error(import_chalk22.default.red(`
31754
+ console.error(import_chalk23.default.red(`
31707
31755
  \u2717 ${error51.message}
31708
31756
  `));
31709
31757
  }
@@ -31715,7 +31763,7 @@ automation.action(async () => {
31715
31763
  await automationListCommand({});
31716
31764
  } catch (error51) {
31717
31765
  if (error51 instanceof Error) {
31718
- console.error(import_chalk22.default.red(`
31766
+ console.error(import_chalk23.default.red(`
31719
31767
  \u2717 ${error51.message}
31720
31768
  `));
31721
31769
  }
@@ -31728,7 +31776,7 @@ repos.command("list").description("List all repositories").action(async () => {
31728
31776
  await repositoriesListCommand();
31729
31777
  } catch (error51) {
31730
31778
  if (error51 instanceof Error) {
31731
- console.error(import_chalk22.default.red(`
31779
+ console.error(import_chalk23.default.red(`
31732
31780
  \u2717 ${error51.message}
31733
31781
  `));
31734
31782
  }
@@ -31740,7 +31788,7 @@ repos.action(async () => {
31740
31788
  await repositoriesListCommand();
31741
31789
  } catch (error51) {
31742
31790
  if (error51 instanceof Error) {
31743
- console.error(import_chalk22.default.red(`
31791
+ console.error(import_chalk23.default.red(`
31744
31792
  \u2717 ${error51.message}
31745
31793
  `));
31746
31794
  }
@@ -31753,7 +31801,7 @@ environment.command("list").description("List all environments").action(async ()
31753
31801
  await environmentListCommand();
31754
31802
  } catch (error51) {
31755
31803
  if (error51 instanceof Error) {
31756
- console.error(import_chalk22.default.red(`
31804
+ console.error(import_chalk23.default.red(`
31757
31805
  \u2717 ${error51.message}
31758
31806
  `));
31759
31807
  }
@@ -31765,7 +31813,7 @@ environment.command("get <id-or-name>").description('Get an environment by ID or
31765
31813
  await environmentGetCommand(idOrName);
31766
31814
  } catch (error51) {
31767
31815
  if (error51 instanceof Error) {
31768
- console.error(import_chalk22.default.red(`
31816
+ console.error(import_chalk23.default.red(`
31769
31817
  \u2717 ${error51.message}
31770
31818
  `));
31771
31819
  }
@@ -31777,7 +31825,7 @@ environment.command("create [name]").description("Create a new environment").opt
31777
31825
  await environmentCreateCommand(name, options);
31778
31826
  } catch (error51) {
31779
31827
  if (error51 instanceof Error) {
31780
- console.error(import_chalk22.default.red(`
31828
+ console.error(import_chalk23.default.red(`
31781
31829
  \u2717 ${error51.message}
31782
31830
  `));
31783
31831
  }
@@ -31789,7 +31837,7 @@ environment.command("edit <id-or-name>").description("Edit an environment").opti
31789
31837
  await environmentEditCommand(idOrName, options);
31790
31838
  } catch (error51) {
31791
31839
  if (error51 instanceof Error) {
31792
- console.error(import_chalk22.default.red(`
31840
+ console.error(import_chalk23.default.red(`
31793
31841
  \u2717 ${error51.message}
31794
31842
  `));
31795
31843
  }
@@ -31801,7 +31849,7 @@ environment.command("delete <id-or-name>").description("Delete an environment").
31801
31849
  await environmentDeleteCommand(idOrName, options);
31802
31850
  } catch (error51) {
31803
31851
  if (error51 instanceof Error) {
31804
- console.error(import_chalk22.default.red(`
31852
+ console.error(import_chalk23.default.red(`
31805
31853
  \u2717 ${error51.message}
31806
31854
  `));
31807
31855
  }
@@ -31814,7 +31862,7 @@ envVars.command("list <env>").description("List variables in an environment (val
31814
31862
  await envVarsListCommand(env, options);
31815
31863
  } catch (error51) {
31816
31864
  if (error51 instanceof Error) {
31817
- console.error(import_chalk22.default.red(`
31865
+ console.error(import_chalk23.default.red(`
31818
31866
  \u2717 ${error51.message}
31819
31867
  `));
31820
31868
  }
@@ -31826,7 +31874,7 @@ envVars.command("set <env> <key> <value>").description("Create or update a varia
31826
31874
  await envVarsSetCommand(env, key, value);
31827
31875
  } catch (error51) {
31828
31876
  if (error51 instanceof Error) {
31829
- console.error(import_chalk22.default.red(`
31877
+ console.error(import_chalk23.default.red(`
31830
31878
  \u2717 ${error51.message}
31831
31879
  `));
31832
31880
  }
@@ -31838,7 +31886,7 @@ envVars.command("delete <env> <key-or-id>").description("Delete a variable by ke
31838
31886
  await envVarsDeleteCommand(env, keyOrId, options);
31839
31887
  } catch (error51) {
31840
31888
  if (error51 instanceof Error) {
31841
- console.error(import_chalk22.default.red(`
31889
+ console.error(import_chalk23.default.red(`
31842
31890
  \u2717 ${error51.message}
31843
31891
  `));
31844
31892
  }
@@ -31851,7 +31899,7 @@ envFiles.command("list <env>").description("List files in an environment").actio
31851
31899
  await envFilesListCommand(env);
31852
31900
  } catch (error51) {
31853
31901
  if (error51 instanceof Error) {
31854
- console.error(import_chalk22.default.red(`
31902
+ console.error(import_chalk23.default.red(`
31855
31903
  \u2717 ${error51.message}
31856
31904
  `));
31857
31905
  }
@@ -31863,7 +31911,7 @@ envFiles.command("set <env> <destination-path>").description("Create or update a
31863
31911
  await envFilesSetCommand(env, destinationPath, options);
31864
31912
  } catch (error51) {
31865
31913
  if (error51 instanceof Error) {
31866
- console.error(import_chalk22.default.red(`
31914
+ console.error(import_chalk23.default.red(`
31867
31915
  \u2717 ${error51.message}
31868
31916
  `));
31869
31917
  }
@@ -31875,7 +31923,7 @@ envFiles.command("delete <env> <path-or-id>").description("Delete a file by dest
31875
31923
  await envFilesDeleteCommand(env, pathOrId, options);
31876
31924
  } catch (error51) {
31877
31925
  if (error51 instanceof Error) {
31878
- console.error(import_chalk22.default.red(`
31926
+ console.error(import_chalk23.default.red(`
31879
31927
  \u2717 ${error51.message}
31880
31928
  `));
31881
31929
  }
@@ -31888,7 +31936,7 @@ function registerEnvironmentHookCommands(parent, config3) {
31888
31936
  try {
31889
31937
  await command();
31890
31938
  } catch (error51) {
31891
- if (error51 instanceof Error) console.error(import_chalk22.default.red(`
31939
+ if (error51 instanceof Error) console.error(import_chalk23.default.red(`
31892
31940
  \u2717 ${error51.message}
31893
31941
  `));
31894
31942
  process.exit(1);
@@ -31924,7 +31972,7 @@ environment.action(async () => {
31924
31972
  await environmentListCommand();
31925
31973
  } catch (error51) {
31926
31974
  if (error51 instanceof Error) {
31927
- console.error(import_chalk22.default.red(`
31975
+ console.error(import_chalk23.default.red(`
31928
31976
  \u2717 ${error51.message}
31929
31977
  `));
31930
31978
  }
@@ -31975,7 +32023,7 @@ if (isAgentMode()) {
31975
32023
  await previewAddCommand(workspaceId, options);
31976
32024
  } catch (error51) {
31977
32025
  if (error51 instanceof Error) {
31978
- console.error(import_chalk22.default.red(`
32026
+ console.error(import_chalk23.default.red(`
31979
32027
  \u2717 ${error51.message}
31980
32028
  `));
31981
32029
  }
@@ -31987,7 +32035,7 @@ if (isAgentMode()) {
31987
32035
  await previewListCommand(workspaceId);
31988
32036
  } catch (error51) {
31989
32037
  if (error51 instanceof Error) {
31990
- console.error(import_chalk22.default.red(`
32038
+ console.error(import_chalk23.default.red(`
31991
32039
  \u2717 ${error51.message}
31992
32040
  `));
31993
32041
  }
@@ -31999,7 +32047,7 @@ if (isAgentMode()) {
31999
32047
  await previewRemoveCommand(workspaceId, options);
32000
32048
  } catch (error51) {
32001
32049
  if (error51 instanceof Error) {
32002
- console.error(import_chalk22.default.red(`
32050
+ console.error(import_chalk23.default.red(`
32003
32051
  \u2717 ${error51.message}
32004
32052
  `));
32005
32053
  }
@@ -32060,7 +32108,7 @@ if (isAgentMode()) {
32060
32108
  await mediaUploadCommand(files, options);
32061
32109
  } catch (error51) {
32062
32110
  if (error51 instanceof Error) {
32063
- console.error(import_chalk22.default.red(`
32111
+ console.error(import_chalk23.default.red(`
32064
32112
  \u2717 ${error51.message}
32065
32113
  `));
32066
32114
  }
@@ -32071,7 +32119,7 @@ if (isAgentMode()) {
32071
32119
  try {
32072
32120
  await mediaShareCommand(mediaId);
32073
32121
  } catch (error51) {
32074
- if (error51 instanceof Error) console.error(import_chalk22.default.red(`
32122
+ if (error51 instanceof Error) console.error(import_chalk23.default.red(`
32075
32123
  \u2717 ${error51.message}
32076
32124
  `));
32077
32125
  process.exit(1);
@@ -32081,7 +32129,7 @@ if (isAgentMode()) {
32081
32129
  try {
32082
32130
  await mediaRevokeCommand(mediaId);
32083
32131
  } catch (error51) {
32084
- if (error51 instanceof Error) console.error(import_chalk22.default.red(`
32132
+ if (error51 instanceof Error) console.error(import_chalk23.default.red(`
32085
32133
  \u2717 ${error51.message}
32086
32134
  `));
32087
32135
  process.exit(1);
@@ -32092,7 +32140,7 @@ if (isAgentMode()) {
32092
32140
  await mediaListCommand(options);
32093
32141
  } catch (error51) {
32094
32142
  if (error51 instanceof Error) {
32095
- console.error(import_chalk22.default.red(`
32143
+ console.error(import_chalk23.default.red(`
32096
32144
  \u2717 ${error51.message}
32097
32145
  `));
32098
32146
  }
@@ -32105,7 +32153,7 @@ if (isAgentMode()) {
32105
32153
  await mothershipSpawnCommand(options);
32106
32154
  } catch (error51) {
32107
32155
  if (error51 instanceof Error) {
32108
- console.error(import_chalk22.default.red(`
32156
+ console.error(import_chalk23.default.red(`
32109
32157
  \u2717 ${error51.message}
32110
32158
  `));
32111
32159
  }
@@ -32117,7 +32165,7 @@ if (isAgentMode()) {
32117
32165
  await mothershipRelayCommand(options);
32118
32166
  } catch (error51) {
32119
32167
  if (error51 instanceof Error) {
32120
- console.error(import_chalk22.default.red(`
32168
+ console.error(import_chalk23.default.red(`
32121
32169
  \u2717 ${error51.message}
32122
32170
  `));
32123
32171
  }
@@ -32149,7 +32197,7 @@ async function main() {
32149
32197
  if (process.argv[2] === "computer" && isAgentMode()) {
32150
32198
  const result = (0, import_node_child_process2.spawnSync)("replicas-computer", process.argv.slice(3), { stdio: "inherit" });
32151
32199
  if (result.error) {
32152
- console.error(import_chalk22.default.red(`
32200
+ console.error(import_chalk23.default.red(`
32153
32201
  \u2717 replicas-computer is unavailable in this workspace image
32154
32202
  `));
32155
32203
  process.exitCode = 1;