replicas-cli 0.3.441 → 0.3.442

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 +511 -458
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -50971,6 +50971,113 @@ var init_logout = __esm({
50971
50971
  }
50972
50972
  });
50973
50973
 
50974
+ // ../shared/src/currency.ts
50975
+ function formatCents(cents) {
50976
+ return `$${(cents / 100).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
50977
+ }
50978
+ var init_currency = __esm({
50979
+ "../shared/src/currency.ts"() {
50980
+ "use strict";
50981
+ }
50982
+ });
50983
+
50984
+ // src/lib/command-utils.ts
50985
+ function formatDate(dateString) {
50986
+ return new Date(dateString).toLocaleString();
50987
+ }
50988
+ function printReplicaActivity(activity) {
50989
+ console.log(import_chalk6.default.gray(` Agent: ${activity.state.replaceAll("_", " ")}${activity.current_step ? ` \xB7 ${activity.current_step}` : ""}`));
50990
+ if (activity.last_agent_message) console.log(import_chalk6.default.gray(` Last message: ${activity.last_agent_message}`));
50991
+ }
50992
+ function ensureOrgApiAuthenticated() {
50993
+ if (!canCallOrgApi()) {
50994
+ throw new Error('Not logged in. Run "replicas login" or "replicas login --api-key".');
50995
+ }
50996
+ }
50997
+ function resolveByNameOrId(input2, items) {
50998
+ return items.find((item) => item.id === input2 || item.name === input2);
50999
+ }
51000
+ function parseKeyValuePairs(pairs) {
51001
+ return Object.fromEntries(pairs.map((pair) => {
51002
+ const separator = pair.indexOf("=");
51003
+ if (separator < 1) throw new Error(`Expected key=value, got: ${pair}`);
51004
+ return [pair.slice(0, separator), pair.slice(separator + 1)];
51005
+ }));
51006
+ }
51007
+ async function confirmAction(message2) {
51008
+ if (!isInteractive()) throw new Error(`${message2} Pass -f to confirm without a terminal.`);
51009
+ const { confirm } = await (0, import_prompts8.default)({ type: "confirm", name: "confirm", message: message2, initial: false });
51010
+ if (!confirm) console.log(import_chalk6.default.yellow("\nCancelled."));
51011
+ return Boolean(confirm);
51012
+ }
51013
+ function parseRequestTimeout(value) {
51014
+ if (!value) return VARIABLE_REQUEST_WAIT.defaultMs;
51015
+ const timeout = /^(\d+)(s|m)?$/.exec(value.trim());
51016
+ if (!timeout) throw new Error(`Invalid timeout "${value}". Use seconds or minutes, for example 90s or 10m`);
51017
+ return Math.min(Math.max(Number(timeout[1]) * (timeout[2] === "m" ? 6e4 : 1e3), VARIABLE_REQUEST_WAIT.pollMs), VARIABLE_REQUEST_WAIT.maxMs);
51018
+ }
51019
+ async function waitForUser(params) {
51020
+ const { timeoutMs } = params;
51021
+ if (!isJsonMode()) console.log(import_chalk6.default.gray(`
51022
+ ${params.asked} Waiting up to ${timeoutMs >= 6e4 ? `${Math.round(timeoutMs / 6e4)} minute(s)` : `${timeoutMs / 1e3} seconds`}\u2026`));
51023
+ let value = params.initial;
51024
+ const deadline = Date.now() + timeoutMs;
51025
+ while (!params.settled(value) && Date.now() < deadline) {
51026
+ await new Promise((resolve4) => setTimeout(resolve4, VARIABLE_REQUEST_WAIT.pollMs));
51027
+ value = await params.poll(true);
51028
+ }
51029
+ return params.settled(value) ? value : params.poll(false);
51030
+ }
51031
+ var import_chalk6, import_prompts8;
51032
+ var init_command_utils = __esm({
51033
+ "src/lib/command-utils.ts"() {
51034
+ "use strict";
51035
+ import_chalk6 = __toESM(require("chalk"));
51036
+ init_src();
51037
+ import_prompts8 = __toESM(require("prompts"));
51038
+ init_config();
51039
+ init_output();
51040
+ }
51041
+ });
51042
+
51043
+ // src/commands/billing.ts
51044
+ async function billingCommand() {
51045
+ output2(await orgAuthenticatedFetch("/v1/organization/billing/balance"), ({ plan, period_start, period_end, credit, limit, blocked }) => {
51046
+ console.log(brand.bold("\n Billing\n"));
51047
+ field("Plan", plan);
51048
+ field("Period", `${formatDate(period_start)} \u2013 ${formatDate(period_end)}`);
51049
+ if (credit) {
51050
+ field("Balance", `${import_chalk7.default.bold(formatCents(credit.remaining_cents))} left, ${formatCents(credit.used_cents)} used of ${formatCents(credit.total_cents)}`);
51051
+ if (credit.one_time_cents) field("Credit", `${formatCents(credit.plan_cents)} plan + ${formatCents(credit.one_time_cents)} one-time`);
51052
+ if (credit.overage_cents) field("Overage", formatCents(credit.overage_cents));
51053
+ }
51054
+ field("Limit", limit ? `${formatCents(limit.remaining_cents)} left before workspaces stop (${limit.kind === "credit" ? "credit" : "usage limit"} ${formatCents(limit.limit_cents)})` : "none");
51055
+ if (blocked) field("Blocked", import_chalk7.default.red(blocked.message));
51056
+ console.log();
51057
+ });
51058
+ }
51059
+ async function billingUsageCommand(options) {
51060
+ const query = new URLSearchParams(Object.entries(options).filter((entry) => !!entry[1]));
51061
+ const usage = await orgAuthenticatedFetch(`/v1/organization/billing/usage${query.size ? `?${query}` : ""}`);
51062
+ output2(usage, ({ points, sources }) => {
51063
+ for (const point of points) console.log(`${point.bucket} ${formatCents(point.cents)}`);
51064
+ console.log(import_chalk7.default.gray(`
51065
+ ${sources.map((source) => `${source.source} ${formatCents(source.cents)}`).join(", ") || "No usage"}`));
51066
+ });
51067
+ }
51068
+ var import_chalk7;
51069
+ var init_billing2 = __esm({
51070
+ "src/commands/billing.ts"() {
51071
+ "use strict";
51072
+ import_chalk7 = __toESM(require("chalk"));
51073
+ init_currency();
51074
+ init_api2();
51075
+ init_command_utils();
51076
+ init_oauth_flow_ui();
51077
+ init_output();
51078
+ }
51079
+ });
51080
+
50974
51081
  // src/commands/identity.ts
50975
51082
  async function fetchToken(audience, awsSourceIdentity) {
50976
51083
  let response;
@@ -51019,12 +51126,12 @@ async function identityTokenCommand(options) {
51019
51126
  }
51020
51127
  async function identityExecCommand(command, options) {
51021
51128
  if (command.length === 0) {
51022
- console.error(import_chalk6.default.red("Provide a command to run: replicas identity exec -- <command>"));
51129
+ console.error(import_chalk8.default.red("Provide a command to run: replicas identity exec -- <command>"));
51023
51130
  process.exit(1);
51024
51131
  }
51025
51132
  const tokenResult = await fetchToken(options.audience);
51026
51133
  if (!tokenResult.ok) {
51027
- console.error(import_chalk6.default.red(tokenResult.error.message));
51134
+ console.error(import_chalk8.default.red(tokenResult.error.message));
51028
51135
  process.exitCode = 1;
51029
51136
  return;
51030
51137
  }
@@ -51048,7 +51155,7 @@ async function identityAwsCredentialsCommand(options) {
51048
51155
  }
51049
51156
  const result = await fetchToken(options.audience, options.sourceIdentity);
51050
51157
  if (!result.ok) {
51051
- console.error(import_chalk6.default.red(result.error.message));
51158
+ console.error(import_chalk8.default.red(result.error.message));
51052
51159
  process.exitCode = 1;
51053
51160
  return;
51054
51161
  }
@@ -51095,7 +51202,7 @@ async function identityAwsCredentialsCommand(options) {
51095
51202
  (0, import_node_fs.rmSync)(directory, { recursive: true, force: true });
51096
51203
  }
51097
51204
  }
51098
- var import_node_crypto, import_node_fs, import_node_child_process, import_node_os, import_node_path, import_chalk6;
51205
+ var import_node_crypto, import_node_fs, import_node_child_process, import_node_os, import_node_path, import_chalk8;
51099
51206
  var init_identity = __esm({
51100
51207
  "src/commands/identity.ts"() {
51101
51208
  "use strict";
@@ -51104,71 +51211,12 @@ var init_identity = __esm({
51104
51211
  import_node_child_process = require("child_process");
51105
51212
  import_node_os = require("os");
51106
51213
  import_node_path = require("path");
51107
- import_chalk6 = __toESM(require("chalk"));
51214
+ import_chalk8 = __toESM(require("chalk"));
51108
51215
  init_output();
51109
51216
  init_src();
51110
51217
  }
51111
51218
  });
51112
51219
 
51113
- // src/lib/command-utils.ts
51114
- function formatDate(dateString) {
51115
- return new Date(dateString).toLocaleString();
51116
- }
51117
- function printReplicaActivity(activity) {
51118
- console.log(import_chalk7.default.gray(` Agent: ${activity.state.replaceAll("_", " ")}${activity.current_step ? ` \xB7 ${activity.current_step}` : ""}`));
51119
- if (activity.last_agent_message) console.log(import_chalk7.default.gray(` Last message: ${activity.last_agent_message}`));
51120
- }
51121
- function ensureOrgApiAuthenticated() {
51122
- if (!canCallOrgApi()) {
51123
- throw new Error('Not logged in. Run "replicas login" or "replicas login --api-key".');
51124
- }
51125
- }
51126
- function resolveByNameOrId(input2, items) {
51127
- return items.find((item) => item.id === input2 || item.name === input2);
51128
- }
51129
- function parseKeyValuePairs(pairs) {
51130
- return Object.fromEntries(pairs.map((pair) => {
51131
- const separator = pair.indexOf("=");
51132
- if (separator < 1) throw new Error(`Expected key=value, got: ${pair}`);
51133
- return [pair.slice(0, separator), pair.slice(separator + 1)];
51134
- }));
51135
- }
51136
- async function confirmAction(message2) {
51137
- if (!isInteractive()) throw new Error(`${message2} Pass -f to confirm without a terminal.`);
51138
- const { confirm } = await (0, import_prompts8.default)({ type: "confirm", name: "confirm", message: message2, initial: false });
51139
- if (!confirm) console.log(import_chalk7.default.yellow("\nCancelled."));
51140
- return Boolean(confirm);
51141
- }
51142
- function parseRequestTimeout(value) {
51143
- if (!value) return VARIABLE_REQUEST_WAIT.defaultMs;
51144
- const timeout = /^(\d+)(s|m)?$/.exec(value.trim());
51145
- if (!timeout) throw new Error(`Invalid timeout "${value}". Use seconds or minutes, for example 90s or 10m`);
51146
- return Math.min(Math.max(Number(timeout[1]) * (timeout[2] === "m" ? 6e4 : 1e3), VARIABLE_REQUEST_WAIT.pollMs), VARIABLE_REQUEST_WAIT.maxMs);
51147
- }
51148
- async function waitForUser(params) {
51149
- const { timeoutMs } = params;
51150
- if (!isJsonMode()) console.log(import_chalk7.default.gray(`
51151
- ${params.asked} Waiting up to ${timeoutMs >= 6e4 ? `${Math.round(timeoutMs / 6e4)} minute(s)` : `${timeoutMs / 1e3} seconds`}\u2026`));
51152
- let value = params.initial;
51153
- const deadline = Date.now() + timeoutMs;
51154
- while (!params.settled(value) && Date.now() < deadline) {
51155
- await new Promise((resolve4) => setTimeout(resolve4, VARIABLE_REQUEST_WAIT.pollMs));
51156
- value = await params.poll(true);
51157
- }
51158
- return params.settled(value) ? value : params.poll(false);
51159
- }
51160
- var import_chalk7, import_prompts8;
51161
- var init_command_utils = __esm({
51162
- "src/lib/command-utils.ts"() {
51163
- "use strict";
51164
- import_chalk7 = __toESM(require("chalk"));
51165
- init_src();
51166
- import_prompts8 = __toESM(require("prompts"));
51167
- init_config();
51168
- init_output();
51169
- }
51170
- });
51171
-
51172
51220
  // src/lib/ssh.ts
51173
51221
  function buildSSHArgs(token, host, proxyCommand, localForward) {
51174
51222
  return [
@@ -51267,7 +51315,7 @@ async function resolveWorkspaceRecord(workspaceName) {
51267
51315
  const exactWorkspace = await fetchWorkspaceById(workspaceName);
51268
51316
  if (exactWorkspace) return exactWorkspace;
51269
51317
  }
51270
- console.log(import_chalk8.default.blue(workspaceName ? `
51318
+ console.log(import_chalk9.default.blue(workspaceName ? `
51271
51319
  Searching for workspace: ${workspaceName}...` : "\nLoading workspaces..."));
51272
51320
  const params = new URLSearchParams({ limit: "100" });
51273
51321
  if (workspaceName) params.set("name", workspaceName);
@@ -51286,7 +51334,7 @@ Searching for workspace: ${workspaceName}...` : "\nLoading workspaces..."));
51286
51334
  selectedWorkspace = workspaces[0];
51287
51335
  } else {
51288
51336
  if (workspaceName) {
51289
- console.log(import_chalk8.default.yellow(`
51337
+ console.log(import_chalk9.default.yellow(`
51290
51338
  Found ${workspaces.length} workspaces matching "${workspaceName}":`));
51291
51339
  }
51292
51340
  const selectResponse = await ask({
@@ -51308,9 +51356,9 @@ Found ${workspaces.length} workspaces matching "${workspaceName}":`));
51308
51356
  }
51309
51357
  selectedWorkspace = selected;
51310
51358
  }
51311
- console.log(import_chalk8.default.green(`
51359
+ console.log(import_chalk9.default.green(`
51312
51360
  \u2713 Selected workspace: ${selectedWorkspace.name}`));
51313
- console.log(import_chalk8.default.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
51361
+ console.log(import_chalk9.default.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
51314
51362
  return selectedWorkspace;
51315
51363
  }
51316
51364
  async function prepareWorkspaceConnection(workspaceName) {
@@ -51320,12 +51368,12 @@ async function prepareWorkspaceConnection(workspaceName) {
51320
51368
  `Workspace is currently ${selectedWorkspace.status}. Wake it at ${DEFAULT_WEB_APP_URL}`
51321
51369
  );
51322
51370
  }
51323
- console.log(import_chalk8.default.blue("\nRequesting SSH access token..."));
51371
+ console.log(import_chalk9.default.blue("\nRequesting SSH access token..."));
51324
51372
  const tokenResponse = await orgAuthenticatedFetch(
51325
51373
  `/v1/workspaces/${selectedWorkspace.id}/ssh-token`,
51326
51374
  { method: "POST" }
51327
51375
  );
51328
- console.log(import_chalk8.default.green("\u2713 SSH token received"));
51376
+ console.log(import_chalk9.default.green("\u2713 SSH token received"));
51329
51377
  let repoName = null;
51330
51378
  if (isInsideGitRepo()) {
51331
51379
  try {
@@ -51341,11 +51389,11 @@ async function prepareWorkspaceConnection(workspaceName) {
51341
51389
  repoName
51342
51390
  };
51343
51391
  }
51344
- var import_chalk8;
51392
+ var import_chalk9;
51345
51393
  var init_workspace_connection = __esm({
51346
51394
  "src/lib/workspace-connection.ts"() {
51347
51395
  "use strict";
51348
- import_chalk8 = __toESM(require("chalk"));
51396
+ import_chalk9 = __toESM(require("chalk"));
51349
51397
  init_src();
51350
51398
  init_config();
51351
51399
  init_api2();
@@ -51358,19 +51406,19 @@ var init_workspace_connection = __esm({
51358
51406
  async function connectCommand(workspaceName) {
51359
51407
  ensureOrgApiAuthenticated();
51360
51408
  const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
51361
- console.log(import_chalk9.default.blue(`
51409
+ console.log(import_chalk10.default.blue(`
51362
51410
  Connecting to ${workspace.name}...`));
51363
51411
  const sshCommand = `ssh ${sshToken}@${sshHost}`;
51364
- console.log(import_chalk9.default.gray(`SSH command: ${sshCommand}`));
51365
- console.log(import_chalk9.default.gray("\nPress Ctrl+D to disconnect.\n"));
51412
+ console.log(import_chalk10.default.gray(`SSH command: ${sshCommand}`));
51413
+ console.log(import_chalk10.default.gray("\nPress Ctrl+D to disconnect.\n"));
51366
51414
  await connectSSH(sshToken, sshHost, sshProxyCommand);
51367
- console.log(import_chalk9.default.green("\n\u2713 Disconnected from workspace.\n"));
51415
+ console.log(import_chalk10.default.green("\n\u2713 Disconnected from workspace.\n"));
51368
51416
  }
51369
- var import_chalk9;
51417
+ var import_chalk10;
51370
51418
  var init_connect = __esm({
51371
51419
  "src/commands/connect.ts"() {
51372
51420
  "use strict";
51373
- import_chalk9 = __toESM(require("chalk"));
51421
+ import_chalk10 = __toESM(require("chalk"));
51374
51422
  init_command_utils();
51375
51423
  init_ssh();
51376
51424
  init_workspace_connection();
@@ -51479,22 +51527,22 @@ async function codeCommand(workspaceName) {
51479
51527
  }
51480
51528
  const { workspace, sshToken, sshHost, sshProxyCommand, repoName } = await prepareWorkspaceConnection(workspaceName);
51481
51529
  const hostAlias = getWorkspaceHostAlias(workspace.name);
51482
- console.log(import_chalk10.default.blue("\nConfiguring SSH connection..."));
51530
+ console.log(import_chalk11.default.blue("\nConfiguring SSH connection..."));
51483
51531
  addOrUpdateSSHConfigEntry({
51484
51532
  host: hostAlias,
51485
51533
  hostname: sshHost,
51486
51534
  user: sshToken,
51487
51535
  proxyCommand: sshProxyCommand
51488
51536
  });
51489
- console.log(import_chalk10.default.green(`\u2713 SSH config entry created: ${hostAlias}`));
51537
+ console.log(import_chalk11.default.green(`\u2713 SSH config entry created: ${hostAlias}`));
51490
51538
  const paths = SANDBOX_PATHS;
51491
51539
  const remotePath = repoName ? `${paths.WORKSPACES_DIR}/${repoName}` : paths.HOME_DIR;
51492
51540
  const ideCommand = getIdeCommand();
51493
51541
  const fullCommand = `${ideCommand} --remote ssh-remote+${hostAlias} ${remotePath}`;
51494
- console.log(import_chalk10.default.blue(`
51542
+ console.log(import_chalk11.default.blue(`
51495
51543
  Opening ${ideCommand} for workspace ${workspace.name}...`));
51496
- console.log(import_chalk10.default.gray(`Command: ${fullCommand}`));
51497
- console.log(import_chalk10.default.yellow(`
51544
+ console.log(import_chalk11.default.gray(`Command: ${fullCommand}`));
51545
+ console.log(import_chalk11.default.yellow(`
51498
51546
  Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
51499
51547
  const ide = (0, import_child_process3.spawn)(ideCommand, [
51500
51548
  "--remote",
@@ -51505,26 +51553,26 @@ Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
51505
51553
  detached: false
51506
51554
  });
51507
51555
  ide.on("error", (error62) => {
51508
- console.error(import_chalk10.default.red(`
51556
+ console.error(import_chalk11.default.red(`
51509
51557
  Failed to launch ${ideCommand}: ${error62.message}`));
51510
- console.log(import_chalk10.default.yellow(`
51558
+ console.log(import_chalk11.default.yellow(`
51511
51559
  Make sure ${ideCommand} is installed and available in your PATH.`));
51512
- console.log(import_chalk10.default.gray(`You can configure a different IDE with: replicas config set ide <command>`));
51560
+ console.log(import_chalk11.default.gray(`You can configure a different IDE with: replicas config set ide <command>`));
51513
51561
  process.exit(1);
51514
51562
  });
51515
51563
  ide.on("close", (code) => {
51516
51564
  if (code === 0) {
51517
- console.log(import_chalk10.default.green(`
51565
+ console.log(import_chalk11.default.green(`
51518
51566
  \u2713 ${ideCommand} closed successfully.
51519
51567
  `));
51520
51568
  }
51521
51569
  });
51522
51570
  }
51523
- var import_chalk10, import_child_process3;
51571
+ var import_chalk11, import_child_process3;
51524
51572
  var init_code = __esm({
51525
51573
  "src/commands/code.ts"() {
51526
51574
  "use strict";
51527
- import_chalk10 = __toESM(require("chalk"));
51575
+ import_chalk11 = __toESM(require("chalk"));
51528
51576
  import_child_process3 = require("child_process");
51529
51577
  init_src();
51530
51578
  init_config();
@@ -51541,16 +51589,16 @@ async function tunnelCommand(workspaceName, options) {
51541
51589
  const remotePort = parsePort(options.port);
51542
51590
  const localPort = options.localPort ? parsePort(options.localPort) : remotePort;
51543
51591
  const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
51544
- console.log(import_chalk11.default.green(`
51592
+ console.log(import_chalk12.default.green(`
51545
51593
  \u2713 Forwarding localhost:${localPort} to ${workspace.name}:${remotePort}`));
51546
- console.log(import_chalk11.default.gray(" Press Ctrl+C to stop.\n"));
51594
+ console.log(import_chalk12.default.gray(" Press Ctrl+C to stop.\n"));
51547
51595
  await connectSSH(sshToken, sshHost, sshProxyCommand, { localPort, remotePort });
51548
51596
  }
51549
- var import_chalk11;
51597
+ var import_chalk12;
51550
51598
  var init_tunnel = __esm({
51551
51599
  "src/commands/tunnel.ts"() {
51552
51600
  "use strict";
51553
- import_chalk11 = __toESM(require("chalk"));
51601
+ import_chalk12 = __toESM(require("chalk"));
51554
51602
  init_command_utils();
51555
51603
  init_port();
51556
51604
  init_ssh();
@@ -51564,8 +51612,8 @@ async function orgCommand() {
51564
51612
  const { organization } = await orgAuthenticatedFetch("/v1/whoami");
51565
51613
  output2({ organization }, () => {
51566
51614
  console.log(brand.bold("\n Active organization\n"));
51567
- field("Organization", import_chalk12.default.bold(organization.name));
51568
- console.log(import_chalk12.default.gray("\n Fixed by your API key. Use a key from another organization to switch.\n"));
51615
+ field("Organization", import_chalk13.default.bold(organization.name));
51616
+ console.log(import_chalk13.default.gray("\n Fixed by your API key. Use a key from another organization to switch.\n"));
51569
51617
  });
51570
51618
  return;
51571
51619
  }
@@ -51574,8 +51622,8 @@ async function orgCommand() {
51574
51622
  const organizations = await fetchOrganizations();
51575
51623
  if (!currentOrgId) {
51576
51624
  output2({ organization: null }, () => {
51577
- console.log(import_chalk12.default.yellow("\n No organization selected."));
51578
- console.log(import_chalk12.default.gray(' Run "replicas org switch" to select one.\n'));
51625
+ console.log(import_chalk13.default.yellow("\n No organization selected."));
51626
+ console.log(import_chalk13.default.gray(' Run "replicas org switch" to select one.\n'));
51579
51627
  });
51580
51628
  return;
51581
51629
  }
@@ -51583,8 +51631,8 @@ async function orgCommand() {
51583
51631
  if (!currentOrg) {
51584
51632
  clearOrganizationId();
51585
51633
  output2({ organization: null }, () => {
51586
- console.log(import_chalk12.default.yellow("\n The selected organization is no longer available to you."));
51587
- console.log(import_chalk12.default.gray(' Run "replicas org switch" to select another.\n'));
51634
+ console.log(import_chalk13.default.yellow("\n The selected organization is no longer available to you."));
51635
+ console.log(import_chalk13.default.gray(' Run "replicas org switch" to select another.\n'));
51588
51636
  });
51589
51637
  return;
51590
51638
  }
@@ -51597,7 +51645,7 @@ async function orgCommand() {
51597
51645
  renderIdentity({ account, role, organizationName: currentOrg.name });
51598
51646
  if (organizations.length > 1) {
51599
51647
  console.log(
51600
- import_chalk12.default.gray(`
51648
+ import_chalk13.default.gray(`
51601
51649
  ${organizations.length} organizations available. "replicas org switch" to change.`)
51602
51650
  );
51603
51651
  }
@@ -51620,7 +51668,7 @@ async function orgSwitchCommand() {
51620
51668
  if (organizations.length > 1) {
51621
51669
  const chosen = await promptForOrganization(organizations, currentOrgId);
51622
51670
  if (!chosen) {
51623
- console.log(import_chalk12.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
51671
+ console.log(import_chalk13.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
51624
51672
  return;
51625
51673
  }
51626
51674
  selectedId = chosen.id;
@@ -51645,11 +51693,11 @@ async function orgMembersCommand() {
51645
51693
  }
51646
51694
  });
51647
51695
  }
51648
- var import_chalk12, NOT_LOGGED_IN;
51696
+ var import_chalk13, NOT_LOGGED_IN;
51649
51697
  var init_org = __esm({
51650
51698
  "src/commands/org.ts"() {
51651
51699
  "use strict";
51652
- import_chalk12 = __toESM(require("chalk"));
51700
+ import_chalk13 = __toESM(require("chalk"));
51653
51701
  init_api2();
51654
51702
  init_command_utils();
51655
51703
  init_oauth_flow_ui();
@@ -51668,7 +51716,7 @@ function assertKnownKey(key) {
51668
51716
  async function configGetCommand(key) {
51669
51717
  ensureOrgApiAuthenticated();
51670
51718
  assertKnownKey(key);
51671
- output2({ ide: getIdeCommand() }, ({ ide }) => console.log(import_chalk13.default.green(`
51719
+ output2({ ide: getIdeCommand() }, ({ ide }) => console.log(import_chalk14.default.green(`
51672
51720
  IDE command: ${ide}
51673
51721
  `)));
51674
51722
  }
@@ -51676,7 +51724,7 @@ async function configSetCommand(key, value) {
51676
51724
  ensureOrgApiAuthenticated();
51677
51725
  assertKnownKey(key);
51678
51726
  setIdeCommand(value);
51679
- output2({ ide: value }, () => console.log(import_chalk13.default.green(`
51727
+ output2({ ide: value }, () => console.log(import_chalk14.default.green(`
51680
51728
  \u2713 IDE command set to: ${value}
51681
51729
  `)));
51682
51730
  }
@@ -51685,17 +51733,17 @@ async function configListCommand() {
51685
51733
  const config3 = readConfig();
51686
51734
  if (!config3) throw new Error("No config found. Please login first.");
51687
51735
  output2({ organization_id: config3.organization_id ?? null, ide: config3.ide_command ?? null }, () => {
51688
- console.log(import_chalk13.default.green("\nCurrent configuration:"));
51689
- console.log(import_chalk13.default.gray(` Organization ID: ${config3.organization_id || (config3.api_key ? "(set by API key)" : "(not set)")}`));
51690
- console.log(import_chalk13.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
51736
+ console.log(import_chalk14.default.green("\nCurrent configuration:"));
51737
+ console.log(import_chalk14.default.gray(` Organization ID: ${config3.organization_id || (config3.api_key ? "(set by API key)" : "(not set)")}`));
51738
+ console.log(import_chalk14.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
51691
51739
  console.log();
51692
51740
  });
51693
51741
  }
51694
- var import_chalk13;
51742
+ var import_chalk14;
51695
51743
  var init_config2 = __esm({
51696
51744
  "src/commands/config.ts"() {
51697
51745
  "use strict";
51698
- import_chalk13 = __toESM(require("chalk"));
51746
+ import_chalk14 = __toESM(require("chalk"));
51699
51747
  init_config();
51700
51748
  init_command_utils();
51701
51749
  init_output();
@@ -51881,11 +51929,11 @@ async function withAuthRecovery(operation, afterReauthentication) {
51881
51929
  throw error62;
51882
51930
  }
51883
51931
  const message2 = error62 instanceof NotAuthenticatedError ? "You're not signed in to Replicas. Signing in..." : "Your Replicas session expired. Re-authenticating...";
51884
- console.log(import_chalk14.default.yellow(`
51932
+ console.log(import_chalk15.default.yellow(`
51885
51933
  ${message2}`));
51886
51934
  await loginCommand();
51887
51935
  await afterReauthentication?.();
51888
- console.log(import_chalk14.default.gray(" Retrying..."));
51936
+ console.log(import_chalk15.default.gray(" Retrying..."));
51889
51937
  return { result: await operation(), reauthenticated: true };
51890
51938
  }
51891
51939
  }
@@ -51961,12 +52009,12 @@ async function runCredentialAuthFlow(options, flow) {
51961
52009
  return completionUrl.toString();
51962
52010
  });
51963
52011
  }
51964
- var import_chalk14, UPLOAD_STEPS;
52012
+ var import_chalk15, UPLOAD_STEPS;
51965
52013
  var init_credential_upload = __esm({
51966
52014
  "src/lib/credential-upload.ts"() {
51967
52015
  "use strict";
51968
52016
  init_urls();
51969
- import_chalk14 = __toESM(require("chalk"));
52017
+ import_chalk15 = __toESM(require("chalk"));
51970
52018
  init_api2();
51971
52019
  init_auth();
51972
52020
  init_oauth_flow_ui();
@@ -52034,7 +52082,7 @@ async function promptForAuthorizationCode() {
52034
52082
  const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
52035
52083
  return new Promise((resolve4) => {
52036
52084
  rl.on("close", () => resolve4(""));
52037
- rl.question(import_chalk15.default.gray(" Paste code here: "), (answer) => {
52085
+ rl.question(import_chalk16.default.gray(" Paste code here: "), (answer) => {
52038
52086
  resolve4(answer.trim());
52039
52087
  rl.close();
52040
52088
  });
@@ -52110,12 +52158,12 @@ async function runClaudeOAuthFlow(totalSteps) {
52110
52158
  }
52111
52159
  return exchangeCodeForTokens2(code, returnedState, state, pkce.codeVerifier);
52112
52160
  }
52113
- var import_readline, import_chalk15, DEFAULT_CLIENT_ID, CLAUDE_CLIENT_ID, AUTHORIZATION_ENDPOINT2, TOKEN_ENDPOINT2, REDIRECT_URI, SCOPES;
52161
+ var import_readline, import_chalk16, DEFAULT_CLIENT_ID, CLAUDE_CLIENT_ID, AUTHORIZATION_ENDPOINT2, TOKEN_ENDPOINT2, REDIRECT_URI, SCOPES;
52114
52162
  var init_claude_oauth = __esm({
52115
52163
  "src/lib/claude-oauth.ts"() {
52116
52164
  "use strict";
52117
52165
  import_readline = __toESM(require("readline"));
52118
- import_chalk15 = __toESM(require("chalk"));
52166
+ import_chalk16 = __toESM(require("chalk"));
52119
52167
  init_oauth_flow_ui();
52120
52168
  init_output();
52121
52169
  init_pkce();
@@ -52306,27 +52354,27 @@ function initCommand(options) {
52306
52354
  }
52307
52355
  const higherPriority = REPLICAS_CONFIG_FILENAMES.slice(0, REPLICAS_CONFIG_FILENAMES.indexOf(targetFilename)).filter((filename) => import_fs3.default.existsSync(import_path4.default.join(process.cwd(), filename)));
52308
52356
  output2({ path: configPath, shadowed_by: higherPriority }, () => {
52309
- console.log(import_chalk16.default.green(`\u2713 Created ${targetFilename}`));
52357
+ console.log(import_chalk17.default.green(`\u2713 Created ${targetFilename}`));
52310
52358
  for (const filename of higherPriority) {
52311
52359
  console.log("");
52312
- console.log(import_chalk16.default.yellow(`Warning: ${filename} already exists and takes priority over ${targetFilename}.`));
52313
- console.log(import_chalk16.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
52360
+ console.log(import_chalk17.default.yellow(`Warning: ${filename} already exists and takes priority over ${targetFilename}.`));
52361
+ console.log(import_chalk17.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
52314
52362
  }
52315
52363
  console.log("");
52316
- console.log(import_chalk16.default.gray("Configuration options:"));
52317
- console.log(import_chalk16.default.gray(" systemPrompt - Custom instructions for AI coding assistants"));
52318
- console.log(import_chalk16.default.gray(" startHook - Commands to run on workspace startup"));
52364
+ console.log(import_chalk17.default.gray("Configuration options:"));
52365
+ console.log(import_chalk17.default.gray(" systemPrompt - Custom instructions for AI coding assistants"));
52366
+ console.log(import_chalk17.default.gray(" startHook - Commands to run on workspace startup"));
52319
52367
  if (!isYaml) {
52320
52368
  console.log("");
52321
- console.log(import_chalk16.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
52369
+ console.log(import_chalk17.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
52322
52370
  }
52323
52371
  });
52324
52372
  }
52325
- var import_chalk16, import_fs3, import_path4;
52373
+ var import_chalk17, import_fs3, import_path4;
52326
52374
  var init_init = __esm({
52327
52375
  "src/commands/init.ts"() {
52328
52376
  "use strict";
52329
- import_chalk16 = __toESM(require("chalk"));
52377
+ import_chalk17 = __toESM(require("chalk"));
52330
52378
  import_fs3 = __toESM(require("fs"));
52331
52379
  import_path4 = __toESM(require("path"));
52332
52380
  init_src();
@@ -52370,10 +52418,10 @@ async function readSecret(service, name) {
52370
52418
  async function credentialsListCommand(agent) {
52371
52419
  const response = await orgAuthenticatedFetch(`/v1/agents/${agent}/credentials`);
52372
52420
  output2(response, ({ credentials: credentials2, selected }) => {
52373
- if (credentials2.length === 0) console.log(import_chalk17.default.yellow(`No credentials connected for ${agent}.`));
52421
+ if (credentials2.length === 0) console.log(import_chalk18.default.yellow(`No credentials connected for ${agent}.`));
52374
52422
  for (const { method, scope } of credentials2) {
52375
52423
  const isSelected = selected?.method === method && selected.scope === scope;
52376
- console.log(`${method} ${scope}${isSelected ? import_chalk17.default.green(" (used by new workspaces)") : ""}`);
52424
+ console.log(`${method} ${scope}${isSelected ? import_chalk18.default.green(" (used by new workspaces)") : ""}`);
52377
52425
  }
52378
52426
  });
52379
52427
  }
@@ -52381,12 +52429,12 @@ async function credentialsGetCommand(service, options) {
52381
52429
  const status = await orgAuthenticatedFetch(credentialsPath(service, options));
52382
52430
  output2(status, ({ hasCredentials, ...fields }) => {
52383
52431
  if (!hasCredentials) {
52384
- console.log(import_chalk17.default.yellow(`No ${scopeLabel(options)} ${service} credentials.`));
52432
+ console.log(import_chalk18.default.yellow(`No ${scopeLabel(options)} ${service} credentials.`));
52385
52433
  return;
52386
52434
  }
52387
52435
  const width = Math.max(...Object.keys(fields).map((key) => key.length)) + 2;
52388
52436
  for (const [key, value] of Object.entries(fields)) {
52389
- console.log(`${import_chalk17.default.gray(key.padEnd(width))}${typeof value === "string" ? value : JSON.stringify(value)}`);
52437
+ console.log(`${import_chalk18.default.gray(key.padEnd(width))}${typeof value === "string" ? value : JSON.stringify(value)}`);
52390
52438
  }
52391
52439
  });
52392
52440
  }
@@ -52400,35 +52448,35 @@ async function credentialsSetCommand(service, options) {
52400
52448
  [secretField]: await readSecret(service, secretField === "api_key" ? "API key" : "AWS secret access key")
52401
52449
  };
52402
52450
  const response = await orgAuthenticatedFetch(path11, { method: "POST", body });
52403
- output2(response, () => console.log(import_chalk17.default.green(`Saved ${scopeLabel(options)} ${service} credentials.`)));
52451
+ output2(response, () => console.log(import_chalk18.default.green(`Saved ${scopeLabel(options)} ${service} credentials.`)));
52404
52452
  }
52405
52453
  async function credentialsRemoveCommand(service, options) {
52406
52454
  const response = await orgAuthenticatedFetch(credentialsPath(service, options), { method: "DELETE" });
52407
- output2(response, ({ success: success2 }) => console.log(success2 ? import_chalk17.default.green(`Removed ${scopeLabel(options)} ${service} credentials.`) : `No ${scopeLabel(options)} ${service} credentials to remove.`));
52455
+ output2(response, ({ success: success2 }) => console.log(success2 ? import_chalk18.default.green(`Removed ${scopeLabel(options)} ${service} credentials.`) : `No ${scopeLabel(options)} ${service} credentials to remove.`));
52408
52456
  }
52409
52457
  async function credentialsUsageCommand({ org: org2, user }) {
52410
52458
  const scope = org2 ? "org" : user ? "user" : null;
52411
52459
  const response = await orgAuthenticatedFetch(`/v1/agents/subscription-usage${scope ? `?scope=${scope}` : ""}`);
52412
52460
  output2(response, ({ accounts }) => {
52413
- if (accounts.length === 0) console.log(import_chalk17.default.yellow("No Claude or Codex subscriptions connected."));
52461
+ if (accounts.length === 0) console.log(import_chalk18.default.yellow("No Claude or Codex subscriptions connected."));
52414
52462
  for (const account of accounts) {
52415
- const limits = account.reconnectRequired ? import_chalk17.default.yellow(`Reconnect required: run ${getSubscriptionAuthCommand(account.provider, account.scope)} with the same account`) : !account.windows ? import_chalk17.default.gray("Usage unavailable, try again in a few minutes") : account.windows.length === 0 ? "No usage limits" : account.windows.map((window) => [
52463
+ const limits = account.reconnectRequired ? import_chalk18.default.yellow(`Reconnect required: run ${getSubscriptionAuthCommand(account.provider, account.scope)} with the same account`) : !account.windows ? import_chalk18.default.gray("Usage unavailable, try again in a few minutes") : account.windows.length === 0 ? "No usage limits" : account.windows.map((window) => [
52416
52464
  window.kind === "session" ? "5-hour" : "weekly",
52417
52465
  window.model,
52418
52466
  `${Math.round(window.usedPercent)}%`,
52419
- window.resetsAt && import_chalk17.default.gray(`(resets ${formatDate(window.resetsAt)})`)
52467
+ window.resetsAt && import_chalk18.default.gray(`(resets ${formatDate(window.resetsAt)})`)
52420
52468
  ].filter(Boolean).join(" ")).join(", ");
52421
52469
  const label = [account.email ?? account.credentialId, account.planType].filter(Boolean).join(" ");
52422
52470
  console.log(`${account.provider} ${scopeLabel({ org: account.scope === "org" })} ${label} ${limits}`);
52423
- if (account.exhaustedUntil) console.log(import_chalk17.default.gray(` Workspaces skip this account until ${formatDate(account.exhaustedUntil)}`));
52471
+ if (account.exhaustedUntil) console.log(import_chalk18.default.gray(` Workspaces skip this account until ${formatDate(account.exhaustedUntil)}`));
52424
52472
  }
52425
52473
  });
52426
52474
  }
52427
- var import_chalk17, OPTIONAL_SECRET_SERVICES, scopeLabel;
52475
+ var import_chalk18, OPTIONAL_SECRET_SERVICES, scopeLabel;
52428
52476
  var init_credentials2 = __esm({
52429
52477
  "src/commands/credentials.ts"() {
52430
52478
  "use strict";
52431
- import_chalk17 = __toESM(require("chalk"));
52479
+ import_chalk18 = __toESM(require("chalk"));
52432
52480
  init_src();
52433
52481
  init_subscription_usage();
52434
52482
  init_api2();
@@ -52459,7 +52507,7 @@ function startUpdateCheck(currentVersion) {
52459
52507
  }
52460
52508
  const latestVersion = payload.version;
52461
52509
  if (compareVersions(latestVersion, currentVersion) > 0) {
52462
- notice = import_chalk18.default.dim(
52510
+ notice = import_chalk19.default.dim(
52463
52511
  `
52464
52512
  Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm install -g replicas-cli@latest
52465
52513
  `
@@ -52469,11 +52517,11 @@ Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm in
52469
52517
  }
52470
52518
  })();
52471
52519
  }
52472
- var import_chalk18, VERSION_CHECK_TIMEOUT;
52520
+ var import_chalk19, VERSION_CHECK_TIMEOUT;
52473
52521
  var init_version_check = __esm({
52474
52522
  "src/lib/version-check.ts"() {
52475
52523
  "use strict";
52476
- import_chalk18 = __toESM(require("chalk"));
52524
+ import_chalk19 = __toESM(require("chalk"));
52477
52525
  init_src();
52478
52526
  init_monolith_url();
52479
52527
  init_output();
@@ -52486,20 +52534,20 @@ async function repositoriesListCommand() {
52486
52534
  ensureOrgApiAuthenticated();
52487
52535
  output2(await orgAuthenticatedFetch("/v1/repositories"), ({ repositories }) => {
52488
52536
  if (repositories.length === 0) {
52489
- console.log(import_chalk19.default.yellow("\nNo repositories found.\n"));
52537
+ console.log(import_chalk20.default.yellow("\nNo repositories found.\n"));
52490
52538
  return;
52491
52539
  }
52492
- console.log(import_chalk19.default.green(`
52540
+ console.log(import_chalk20.default.green(`
52493
52541
  Repositories (${repositories.length}):
52494
52542
  `));
52495
52543
  for (const repo of repositories) {
52496
- console.log(import_chalk19.default.white(` ${repo.name}`));
52497
- console.log(import_chalk19.default.gray(` ID: ${repo.id}`));
52498
- console.log(import_chalk19.default.gray(` URL: ${repo.url}`));
52499
- console.log(import_chalk19.default.gray(` Default Branch: ${repo.default_branch}`));
52500
- console.log(import_chalk19.default.gray(` Created: ${formatDate(repo.created_at)}`));
52544
+ console.log(import_chalk20.default.white(` ${repo.name}`));
52545
+ console.log(import_chalk20.default.gray(` ID: ${repo.id}`));
52546
+ console.log(import_chalk20.default.gray(` URL: ${repo.url}`));
52547
+ console.log(import_chalk20.default.gray(` Default Branch: ${repo.default_branch}`));
52548
+ console.log(import_chalk20.default.gray(` Created: ${formatDate(repo.created_at)}`));
52501
52549
  if (repo.github_repository_id) {
52502
- console.log(import_chalk19.default.gray(` GitHub ID: ${repo.github_repository_id}`));
52550
+ console.log(import_chalk20.default.gray(` GitHub ID: ${repo.github_repository_id}`));
52503
52551
  }
52504
52552
  console.log();
52505
52553
  }
@@ -52554,11 +52602,11 @@ async function repositoriesBranchesCommand(repository) {
52554
52602
  for (const branch of branches) console.log(branch);
52555
52603
  });
52556
52604
  }
52557
- var import_chalk19, splitList;
52605
+ var import_chalk20, splitList;
52558
52606
  var init_repositories2 = __esm({
52559
52607
  "src/commands/repositories.ts"() {
52560
52608
  "use strict";
52561
- import_chalk19 = __toESM(require("chalk"));
52609
+ import_chalk20 = __toESM(require("chalk"));
52562
52610
  init_api2();
52563
52611
  init_command_utils();
52564
52612
  init_output();
@@ -52586,22 +52634,22 @@ async function resolveEnvironmentId(input2) {
52586
52634
  return resolved.id;
52587
52635
  }
52588
52636
  function printEnvironment(env, repoSkillCount) {
52589
- console.log(import_chalk20.default.white(` ${env.name}${env.user_id ? import_chalk20.default.gray(" (personal)") : ""}`));
52590
- console.log(import_chalk20.default.gray(` ID: ${env.id}`));
52637
+ console.log(import_chalk21.default.white(` ${env.name}${env.user_id ? import_chalk21.default.gray(" (personal)") : ""}`));
52638
+ console.log(import_chalk21.default.gray(` ID: ${env.id}`));
52591
52639
  if (env.description) {
52592
- console.log(import_chalk20.default.gray(` Description: ${env.description}`));
52640
+ console.log(import_chalk21.default.gray(` Description: ${env.description}`));
52593
52641
  }
52594
52642
  const repositoryIds = env.repository_ids ?? [];
52595
52643
  if (repositoryIds.length > 0) {
52596
- console.log(import_chalk20.default.gray(` Repositories: ${repositoryIds.join(", ")}`));
52644
+ console.log(import_chalk21.default.gray(` Repositories: ${repositoryIds.join(", ")}`));
52597
52645
  }
52598
52646
  if (env.variable_count !== void 0) {
52599
- console.log(import_chalk20.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Added skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
52647
+ console.log(import_chalk21.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Added skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
52600
52648
  }
52601
52649
  if (repoSkillCount !== void 0) {
52602
- console.log(import_chalk20.default.gray(` Repository skills: ${repoSkillCount}`));
52650
+ console.log(import_chalk21.default.gray(` Repository skills: ${repoSkillCount}`));
52603
52651
  }
52604
- console.log(import_chalk20.default.gray(` Updated: ${formatDate(env.updated_at)}`));
52652
+ console.log(import_chalk21.default.gray(` Updated: ${formatDate(env.updated_at)}`));
52605
52653
  console.log();
52606
52654
  }
52607
52655
  async function environmentListCommand() {
@@ -52609,10 +52657,10 @@ async function environmentListCommand() {
52609
52657
  const response = await orgAuthenticatedFetch("/v1/environments?scope=all");
52610
52658
  output2(response, ({ environments }) => {
52611
52659
  if (environments.length === 0) {
52612
- console.log(import_chalk20.default.yellow("\nNo environments found.\n"));
52660
+ console.log(import_chalk21.default.yellow("\nNo environments found.\n"));
52613
52661
  return;
52614
52662
  }
52615
- console.log(import_chalk20.default.green(`
52663
+ console.log(import_chalk21.default.green(`
52616
52664
  Environments (${environments.length}):
52617
52665
  `));
52618
52666
  for (const env of environments) printEnvironment(env);
@@ -52624,13 +52672,13 @@ async function environmentGetCommand(idOrName) {
52624
52672
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}`);
52625
52673
  const repoSkills = await orgAuthenticatedFetch(`/v1/environments/${response.environment.id}/repo-skills`);
52626
52674
  output2({ ...response, ...repoSkills }, ({ environment: environment2 }) => {
52627
- console.log(import_chalk20.default.green(`
52675
+ console.log(import_chalk21.default.green(`
52628
52676
  Environment: ${environment2.name}
52629
52677
  `));
52630
52678
  const linkedSkills = repoSkills.repo_skills.filter((skill) => skill.path.startsWith(`.${skill.framework}/skills/`));
52631
52679
  printEnvironment(environment2, new Set(linkedSkills.map((skill) => `${skill.repository_id}:${skill.path.split("/")[2]}`)).size);
52632
52680
  for (const message2 of [repoSkills.error, ...repoSkills.repo_errors.map((repo) => `${repo.repository_full_name}: ${repo.error}`)]) {
52633
- if (message2) console.log(import_chalk20.default.yellow(` Could not read repository skills: ${message2}`));
52681
+ if (message2) console.log(import_chalk21.default.yellow(` Could not read repository skills: ${message2}`));
52634
52682
  }
52635
52683
  });
52636
52684
  }
@@ -52645,7 +52693,7 @@ async function environmentCreateCommand(name, options) {
52645
52693
  validate: (v) => v.trim() ? true : "Name is required"
52646
52694
  });
52647
52695
  if (!r.name) {
52648
- console.log(import_chalk20.default.yellow("\nCancelled."));
52696
+ console.log(import_chalk21.default.yellow("\nCancelled."));
52649
52697
  return;
52650
52698
  }
52651
52699
  envName = r.name;
@@ -52679,9 +52727,9 @@ async function environmentCreateCommand(name, options) {
52679
52727
  body
52680
52728
  });
52681
52729
  output2(response, ({ environment: environment2 }) => {
52682
- console.log(import_chalk20.default.green(`
52730
+ console.log(import_chalk21.default.green(`
52683
52731
  Created environment: ${environment2.name}`));
52684
- console.log(import_chalk20.default.gray(` ID: ${environment2.id}
52732
+ console.log(import_chalk21.default.gray(` ID: ${environment2.id}
52685
52733
  `));
52686
52734
  });
52687
52735
  }
@@ -52702,7 +52750,7 @@ async function environmentEditCommand(idOrName, options) {
52702
52750
  method: "PATCH",
52703
52751
  body
52704
52752
  });
52705
- output2(response, ({ environment: environment2 }) => console.log(import_chalk20.default.green(`
52753
+ output2(response, ({ environment: environment2 }) => console.log(import_chalk21.default.green(`
52706
52754
  Updated environment: ${environment2.name}
52707
52755
  `)));
52708
52756
  }
@@ -52716,10 +52764,10 @@ Deleted environment ${idOrName}.
52716
52764
  `);
52717
52765
  }
52718
52766
  function printVariable(v) {
52719
- console.log(import_chalk20.default.white(` ${v.key}`));
52720
- console.log(import_chalk20.default.gray(` ID: ${v.id}`));
52721
- console.log(import_chalk20.default.gray(` Value: ${v.value}`));
52722
- console.log(import_chalk20.default.gray(` Updated: ${formatDate(v.updated_at)}`));
52767
+ console.log(import_chalk21.default.white(` ${v.key}`));
52768
+ console.log(import_chalk21.default.gray(` ID: ${v.id}`));
52769
+ console.log(import_chalk21.default.gray(` Value: ${v.value}`));
52770
+ console.log(import_chalk21.default.gray(` Updated: ${formatDate(v.updated_at)}`));
52723
52771
  console.log();
52724
52772
  }
52725
52773
  async function envVarsListCommand(envIdOrName, options) {
@@ -52731,14 +52779,14 @@ async function envVarsListCommand(envIdOrName, options) {
52731
52779
  const variables = options.reveal ? response.environment_variables : response.environment_variables.map((v) => ({ ...v, value: maskValue(v.value) }));
52732
52780
  output2({ environment_variables: variables }, ({ environment_variables }) => {
52733
52781
  if (environment_variables.length === 0) {
52734
- console.log(import_chalk20.default.yellow("\nNo variables.\n"));
52782
+ console.log(import_chalk21.default.yellow("\nNo variables.\n"));
52735
52783
  return;
52736
52784
  }
52737
- console.log(import_chalk20.default.green(`
52785
+ console.log(import_chalk21.default.green(`
52738
52786
  Variables (${environment_variables.length}):
52739
52787
  `));
52740
52788
  if (!options.reveal) {
52741
- console.log(import_chalk20.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
52789
+ console.log(import_chalk21.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
52742
52790
  }
52743
52791
  for (const v of environment_variables) printVariable(v);
52744
52792
  });
@@ -52756,7 +52804,7 @@ async function envVarsSetCommand(envIdOrName, key, value) {
52756
52804
  `/v1/environments/${id}/variables/${match.id}`,
52757
52805
  { method: "PATCH", body: body2 }
52758
52806
  );
52759
- output2({ ...response2, environment_variable: { ...response2.environment_variable, value: maskValue(response2.environment_variable.value) } }, ({ environment_variable }) => console.log(import_chalk20.default.green(`
52807
+ output2({ ...response2, environment_variable: { ...response2.environment_variable, value: maskValue(response2.environment_variable.value) } }, ({ environment_variable }) => console.log(import_chalk21.default.green(`
52760
52808
  Updated variable ${environment_variable.key}.
52761
52809
  `)));
52762
52810
  return;
@@ -52770,7 +52818,7 @@ Updated variable ${environment_variable.key}.
52770
52818
  `/v1/environments/${id}/variables`,
52771
52819
  { method: "POST", body }
52772
52820
  );
52773
- output2({ ...response, environment_variable: { ...response.environment_variable, value: maskValue(response.environment_variable.value) } }, ({ environment_variable }) => console.log(import_chalk20.default.green(`
52821
+ output2({ ...response, environment_variable: { ...response.environment_variable, value: maskValue(response.environment_variable.value) } }, ({ environment_variable }) => console.log(import_chalk21.default.green(`
52774
52822
  Created variable ${environment_variable.key}.
52775
52823
  `)));
52776
52824
  }
@@ -52806,15 +52854,15 @@ async function envVarsRequestCommand(requiredKeys, options) {
52806
52854
  const local = parsePosixEnvFile(readRuntimeEnv());
52807
52855
  const available = options.replace ? [] : keys.filter((key) => Object.hasOwn(local, key) && local[key].length > 0);
52808
52856
  const wanted = keys.filter((key) => !available.includes(key));
52809
- const loadHint = import_chalk20.default.gray(`
52857
+ const loadHint = import_chalk21.default.gray(`
52810
52858
  Values are never printed. Load them into a command with: . ~/.replicas/runtime-env.sh && <command>
52811
52859
  `);
52812
52860
  if (wanted.length === 0) {
52813
52861
  output2({ status: "provided", exported: available, missing: [] }, () => {
52814
52862
  console.log(`
52815
- ${import_chalk20.default.green("Already available:")} ${available.join(", ")}`);
52863
+ ${import_chalk21.default.green("Already available:")} ${available.join(", ")}`);
52816
52864
  console.log(loadHint);
52817
- console.log(import_chalk20.default.gray(" If a value is wrong, run this again with --replace to ask the user for a new one.\n"));
52865
+ console.log(import_chalk21.default.gray(" If a value is wrong, run this again with --replace to ask the user for a new one.\n"));
52818
52866
  });
52819
52867
  return;
52820
52868
  }
@@ -52850,11 +52898,11 @@ async function envVarsRequestCommand(requiredKeys, options) {
52850
52898
  console.log("");
52851
52899
  if (exported.length > 0 || available.length > 0) {
52852
52900
  const where = request.destination === "workspace" ? "this workspace only" : "saved to the environment";
52853
- console.log(` ${import_chalk20.default.green("Provided:")} ${[...available, ...exported].join(", ")} ${import_chalk20.default.gray(`(${where})`)}`);
52901
+ console.log(` ${import_chalk21.default.green("Provided:")} ${[...available, ...exported].join(", ")} ${import_chalk21.default.gray(`(${where})`)}`);
52854
52902
  }
52855
52903
  if (request.status === "pending") {
52856
- console.log(` ${import_chalk20.default.yellow("Still waiting for:")} ${missing.join(", ")}`);
52857
- console.log(import_chalk20.default.gray(options.wait === false ? `
52904
+ console.log(` ${import_chalk21.default.yellow("Still waiting for:")} ${missing.join(", ")}`);
52905
+ console.log(import_chalk21.default.gray(options.wait === false ? `
52858
52906
  Asked above the chat composer (${created.url}). Keep working, and run this command again when you need the values.
52859
52907
  ` : created.wait ? `
52860
52908
  The form stays open above the chat composer (${created.url}). End your turn and say what the values are for. When the user saves, you get a message; run this command again then.
@@ -52864,21 +52912,21 @@ async function envVarsRequestCommand(requiredKeys, options) {
52864
52912
  `));
52865
52913
  return;
52866
52914
  }
52867
- if (missing.length > 0) console.log(` ${import_chalk20.default.gray(request.status === "skipped" ? "Skipped by the user:" : "Not provided:")} ${missing.join(", ")}`);
52915
+ if (missing.length > 0) console.log(` ${import_chalk21.default.gray(request.status === "skipped" ? "Skipped by the user:" : "Not provided:")} ${missing.join(", ")}`);
52868
52916
  if (exported.length === 0) {
52869
- console.log(import_chalk20.default.gray("\n Continue without them, or ask the user how they want to proceed.\n"));
52917
+ console.log(import_chalk21.default.gray("\n Continue without them, or ask the user how they want to proceed.\n"));
52870
52918
  return;
52871
52919
  }
52872
52920
  console.log(loadHint);
52873
- if (options.replace) console.log(import_chalk20.default.gray(" Leave out --replace from now on; running it again asks the user again.\n"));
52921
+ if (options.replace) console.log(import_chalk21.default.gray(" Leave out --replace from now on; running it again asks the user again.\n"));
52874
52922
  });
52875
52923
  }
52876
52924
  function printFile(f) {
52877
- console.log(import_chalk20.default.white(` ${f.path}`));
52878
- console.log(import_chalk20.default.gray(` ID: ${f.id}`));
52879
- console.log(import_chalk20.default.gray(` Name: ${f.name}`));
52880
- console.log(import_chalk20.default.gray(` Size: ${f.content.length} bytes`));
52881
- console.log(import_chalk20.default.gray(` Updated: ${formatDate(f.updated_at)}`));
52925
+ console.log(import_chalk21.default.white(` ${f.path}`));
52926
+ console.log(import_chalk21.default.gray(` ID: ${f.id}`));
52927
+ console.log(import_chalk21.default.gray(` Name: ${f.name}`));
52928
+ console.log(import_chalk21.default.gray(` Size: ${f.content.length} bytes`));
52929
+ console.log(import_chalk21.default.gray(` Updated: ${formatDate(f.updated_at)}`));
52882
52930
  console.log();
52883
52931
  }
52884
52932
  async function envFilesListCommand(envIdOrName) {
@@ -52889,10 +52937,10 @@ async function envFilesListCommand(envIdOrName) {
52889
52937
  );
52890
52938
  output2(response, ({ environment_files }) => {
52891
52939
  if (environment_files.length === 0) {
52892
- console.log(import_chalk20.default.yellow("\nNo files.\n"));
52940
+ console.log(import_chalk21.default.yellow("\nNo files.\n"));
52893
52941
  return;
52894
52942
  }
52895
- console.log(import_chalk20.default.green(`
52943
+ console.log(import_chalk21.default.green(`
52896
52944
  Files (${environment_files.length}):
52897
52945
  `));
52898
52946
  for (const f of environment_files) printFile(f);
@@ -52924,7 +52972,7 @@ async function envFilesSetCommand(envIdOrName, destinationPath, options) {
52924
52972
  `/v1/environments/${id}/files/${match.id}`,
52925
52973
  { method: "PATCH", body: body2 }
52926
52974
  );
52927
- output2(response2, ({ environment_file }) => console.log(import_chalk20.default.green(`
52975
+ output2(response2, ({ environment_file }) => console.log(import_chalk21.default.green(`
52928
52976
  Updated file ${environment_file.path}.
52929
52977
  `)));
52930
52978
  return;
@@ -52939,7 +52987,7 @@ Updated file ${environment_file.path}.
52939
52987
  `/v1/environments/${id}/files`,
52940
52988
  { method: "POST", body }
52941
52989
  );
52942
- output2(response, ({ environment_file }) => console.log(import_chalk20.default.green(`
52990
+ output2(response, ({ environment_file }) => console.log(import_chalk21.default.green(`
52943
52991
  Created file ${environment_file.path}.
52944
52992
  `)));
52945
52993
  }
@@ -52969,16 +53017,16 @@ async function envHookGetCommand(envIdOrName, kind) {
52969
53017
  const hook = kind === "warm" ? (await orgAuthenticatedFetch(`/v1/environments/${id}/warm-hooks`)).warm_hook : (await orgAuthenticatedFetch(`/v1/environments/${id}/start-hooks`)).start_hook;
52970
53018
  output2({ hook }, () => {
52971
53019
  if (!hook) {
52972
- console.log(import_chalk20.default.yellow(`
53020
+ console.log(import_chalk21.default.yellow(`
52973
53021
  No ${kind} hook configured.
52974
53022
  `));
52975
53023
  return;
52976
53024
  }
52977
- console.log(import_chalk20.default.green(`
53025
+ console.log(import_chalk21.default.green(`
52978
53026
  ${kind === "warm" ? "Warm" : "Start"} hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
52979
53027
  `));
52980
- console.log(import_chalk20.default.gray(` ID: ${hook.id}`));
52981
- console.log(import_chalk20.default.gray(` Created: ${formatDate(hook.created_at)}
53028
+ console.log(import_chalk21.default.gray(` ID: ${hook.id}`));
53029
+ console.log(import_chalk21.default.gray(` Created: ${formatDate(hook.created_at)}
52982
53030
  `));
52983
53031
  console.log(hook.content);
52984
53032
  console.log();
@@ -52994,7 +53042,7 @@ async function envHookSaveCommand(envIdOrName, options, kind) {
52994
53042
  `/v1/environments/${id}/warm-hooks/save`,
52995
53043
  { method: "POST", body: body2 }
52996
53044
  );
52997
- output2(response2, ({ warm_hook }) => console.log(import_chalk20.default.green(warm_hook ? `
53045
+ output2(response2, ({ warm_hook }) => console.log(import_chalk21.default.green(warm_hook ? `
52998
53046
  Saved warm hook v${warm_hook.version}.
52999
53047
  ` : "\nCleared warm hook.\n")));
53000
53048
  return;
@@ -53004,7 +53052,7 @@ Saved warm hook v${warm_hook.version}.
53004
53052
  `/v1/environments/${id}/start-hooks/save`,
53005
53053
  { method: "POST", body }
53006
53054
  );
53007
- output2(response, ({ start_hook }) => console.log(import_chalk20.default.green(start_hook ? `
53055
+ output2(response, ({ start_hook }) => console.log(import_chalk21.default.green(start_hook ? `
53008
53056
  Saved start hook v${start_hook.version}.
53009
53057
  ` : "\nCleared start hook.\n")));
53010
53058
  }
@@ -53022,7 +53070,7 @@ async function envHookTestCommand(envIdOrName, options, kind) {
53022
53070
  body: kind === "warm" ? { content, mode: options.save ? "save_test" : "test_only" } : { content },
53023
53071
  onEvent: (event) => {
53024
53072
  if (event.type === "progress" && event.message) {
53025
- console.log(import_chalk20.default.gray(event.message));
53073
+ console.log(import_chalk21.default.gray(event.message));
53026
53074
  } else if (event.type === "output" && event.output) {
53027
53075
  logs += event.output;
53028
53076
  if (!isJsonMode()) process.stdout.write(event.output);
@@ -53039,7 +53087,7 @@ async function envHookTestCommand(envIdOrName, options, kind) {
53039
53087
  const label = kind === "warm" ? "Warm" : "Start";
53040
53088
  const passed = !timedOut && exitCode === 0;
53041
53089
  output2({ passed, exit_code: exitCode, timed_out: timedOut, saved: passed && !!options.save, output: logs }, () => {
53042
- if (passed) console.log(import_chalk20.default.green(`
53090
+ if (passed) console.log(import_chalk21.default.green(`
53043
53091
  ${label} hook passed${options.save ? " and was saved" : ""} (exit code ${exitCode}).
53044
53092
  `));
53045
53093
  });
@@ -53056,24 +53104,24 @@ async function envHookRepositoryHooksCommand(envIdOrName, kind) {
53056
53104
  )).repositories.map((repository) => ({ ...repository, hook: repository.start_hook }));
53057
53105
  output2({ repositories }, () => {
53058
53106
  if (repositories.length === 0) {
53059
- console.log(import_chalk20.default.yellow("\nNo repositories bound to this environment.\n"));
53107
+ console.log(import_chalk21.default.yellow("\nNo repositories bound to this environment.\n"));
53060
53108
  return;
53061
53109
  }
53062
- console.log(import_chalk20.default.green(`
53110
+ console.log(import_chalk21.default.green(`
53063
53111
  Repository ${kind} hooks (${repositories.length}):
53064
53112
  `));
53065
53113
  for (const repo of repositories) {
53066
- console.log(import_chalk20.default.white(` ${repo.repository_name} @${repo.default_branch}`));
53114
+ console.log(import_chalk21.default.white(` ${repo.repository_name} @${repo.default_branch}`));
53067
53115
  if (repo.error) {
53068
- console.log(import_chalk20.default.red(` Error: ${repo.error}`));
53116
+ console.log(import_chalk21.default.red(` Error: ${repo.error}`));
53069
53117
  } else if (repo.hook) {
53070
- console.log(import_chalk20.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
53071
- console.log(import_chalk20.default.gray(` Commands (${repo.hook.commands.length}):`));
53118
+ console.log(import_chalk21.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
53119
+ console.log(import_chalk21.default.gray(` Commands (${repo.hook.commands.length}):`));
53072
53120
  for (const cmd of repo.hook.commands) {
53073
- console.log(import_chalk20.default.gray(` ${cmd}`));
53121
+ console.log(import_chalk21.default.gray(` ${cmd}`));
53074
53122
  }
53075
53123
  } else {
53076
- console.log(import_chalk20.default.gray(` No ${kind}Hook defined.`));
53124
+ console.log(import_chalk21.default.gray(` No ${kind}Hook defined.`));
53077
53125
  }
53078
53126
  console.log();
53079
53127
  }
@@ -53115,7 +53163,7 @@ async function envSkillsAddCommand(env, source, slug, options) {
53115
53163
  const id = await resolveEnvironmentId(env);
53116
53164
  const body = { environment_id: id, source, slug, name: options.name ?? slug };
53117
53165
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/skills`, { method: "POST", body });
53118
- output2(response, () => console.log(import_chalk20.default.green(`Added skill ${slug} from ${source}`)));
53166
+ output2(response, () => console.log(import_chalk21.default.green(`Added skill ${slug} from ${source}`)));
53119
53167
  }
53120
53168
  async function envSkillsRemoveCommand(env, slugOrId) {
53121
53169
  const id = await resolveEnvironmentId(env);
@@ -53143,7 +53191,7 @@ async function envMcpsAddCommand(env, name, options) {
53143
53191
  const id = await resolveEnvironmentId(env);
53144
53192
  const body = { environment_id: id, name, ...server };
53145
53193
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/mcps`, { method: "POST", body });
53146
- output2(response, () => console.log(import_chalk20.default.green(`Added MCP server ${name}`)));
53194
+ output2(response, () => console.log(import_chalk21.default.green(`Added MCP server ${name}`)));
53147
53195
  }
53148
53196
  async function envMcpsRemoveCommand(env, nameOrId) {
53149
53197
  const id = await resolveEnvironmentId(env);
@@ -53159,13 +53207,13 @@ async function envDevicesListCommand(env) {
53159
53207
  );
53160
53208
  output2(response, ({ environment_devices }) => {
53161
53209
  if (environment_devices.length === 0) {
53162
- console.log(import_chalk20.default.yellow(`
53210
+ console.log(import_chalk21.default.yellow(`
53163
53211
  No devices. Add one with: replicas env devices add ${env} <name> --user <user>
53164
53212
  `));
53165
53213
  return;
53166
53214
  }
53167
53215
  for (const device of environment_devices) {
53168
- const status = isDeviceOnline(device.last_seen_at) ? import_chalk20.default.green("online") : import_chalk20.default.yellow(device.last_seen_at ? `offline, last seen ${formatCompactRelativeTime(device.last_seen_at)}` : "offline");
53216
+ const status = isDeviceOnline(device.last_seen_at) ? import_chalk21.default.green("online") : import_chalk21.default.yellow(device.last_seen_at ? `offline, last seen ${formatCompactRelativeTime(device.last_seen_at)}` : "offline");
53169
53217
  console.log(`${device.id} ${device.name} ${device.host === null ? `${device.username}, connects from the device ${status}` : `${device.username}@${device.host}:${device.port}`}`);
53170
53218
  }
53171
53219
  });
@@ -53176,10 +53224,10 @@ async function envDevicesAddCommand(env, name, options) {
53176
53224
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/devices`, { method: "POST", body });
53177
53225
  const connect2 = options.host === void 0 ? await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${response.environment_device.id}/connect-token`) : void 0;
53178
53226
  output2({ ...response, connect_token: connect2?.token }, ({ environment_device, connect_token }) => {
53179
- console.log(import_chalk20.default.green(`Added device ${name}. Allow its key by running this on the device as ${options.user}:`));
53227
+ console.log(import_chalk21.default.green(`Added device ${name}. Allow its key by running this on the device as ${options.user}:`));
53180
53228
  console.log(`mkdir -p ~/.ssh && echo '${environment_device.public_key}' >> ~/.ssh/authorized_keys`);
53181
53229
  if (connect_token) {
53182
- console.log(import_chalk20.default.green("Then keep this running on it, so workspaces can reach it, and paste this token when it asks:"));
53230
+ console.log(import_chalk21.default.green("Then keep this running on it, so workspaces can reach it, and paste this token when it asks:"));
53183
53231
  console.log(DEVICE_CONNECT_COMMAND);
53184
53232
  console.log(connect_token);
53185
53233
  }
@@ -53197,9 +53245,9 @@ async function envDevicesEditCommand(env, nameOrId, options) {
53197
53245
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}`, { method: "PATCH", body });
53198
53246
  const connect2 = device.host !== null && response.environment_device.host === null ? await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}/connect-token`) : void 0;
53199
53247
  output2({ ...response, connect_token: connect2?.token }, ({ environment_device, connect_token }) => {
53200
- console.log(import_chalk20.default.green(`Updated device ${environment_device.name}. Workspaces started from now on get the change.`));
53248
+ console.log(import_chalk21.default.green(`Updated device ${environment_device.name}. Workspaces started from now on get the change.`));
53201
53249
  if (connect_token) {
53202
- console.log(import_chalk20.default.green("It now connects from the device. Keep this running on it, and paste this token when it asks:"));
53250
+ console.log(import_chalk21.default.green("It now connects from the device. Keep this running on it, and paste this token when it asks:"));
53203
53251
  console.log(DEVICE_CONNECT_COMMAND);
53204
53252
  console.log(connect_token);
53205
53253
  }
@@ -53220,7 +53268,7 @@ async function envDevicesResetCommand(env, nameOrId) {
53220
53268
  if (!device) throw new Error(`Device not found: ${nameOrId}`);
53221
53269
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}/connect-token`, { method: "POST" });
53222
53270
  output2(response, ({ token }) => {
53223
- console.log(import_chalk20.default.green(`Reset ${device.name}'s connection. Its old token no longer works; run this on it again and paste the new token when it asks:`));
53271
+ console.log(import_chalk21.default.green(`Reset ${device.name}'s connection. Its old token no longer works; run this on it again and paste the new token when it asks:`));
53224
53272
  console.log(DEVICE_CONNECT_COMMAND);
53225
53273
  console.log(token);
53226
53274
  });
@@ -53230,17 +53278,17 @@ function envWarmPoolCommand(enabled) {
53230
53278
  const id = await resolveEnvironmentId(env);
53231
53279
  const body = { environment_id: id, enabled };
53232
53280
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}/warm-pools`, { method: "PUT", body });
53233
- output2(response, () => console.log(import_chalk20.default.green(`Warm pool ${enabled ? "enabled" : "disabled"}`)));
53281
+ output2(response, () => console.log(import_chalk21.default.green(`Warm pool ${enabled ? "enabled" : "disabled"}`)));
53234
53282
  };
53235
53283
  }
53236
- var import_fs4, import_os3, import_path5, import_chalk20, RUNTIME_ENV_FILE;
53284
+ var import_fs4, import_os3, import_path5, import_chalk21, RUNTIME_ENV_FILE;
53237
53285
  var init_environment3 = __esm({
53238
53286
  "src/commands/environment.ts"() {
53239
53287
  "use strict";
53240
53288
  import_fs4 = __toESM(require("fs"));
53241
53289
  import_os3 = __toESM(require("os"));
53242
53290
  import_path5 = __toESM(require("path"));
53243
- import_chalk20 = __toESM(require("chalk"));
53291
+ import_chalk21 = __toESM(require("chalk"));
53244
53292
  init_api2();
53245
53293
  init_command_utils();
53246
53294
  init_output();
@@ -53260,8 +53308,8 @@ function parseReplicaAgent(value) {
53260
53308
  throw new Error(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`);
53261
53309
  }
53262
53310
  function formatStatus(status) {
53263
- if (status === "active") return import_chalk21.default.green(status);
53264
- if (isWorkspaceSuspendedStatus(status)) return import_chalk21.default.gray(status);
53311
+ if (status === "active") return import_chalk22.default.green(status);
53312
+ if (isWorkspaceSuspendedStatus(status)) return import_chalk22.default.gray(status);
53265
53313
  return status;
53266
53314
  }
53267
53315
  function truncate(text4, maxLength) {
@@ -53272,93 +53320,93 @@ function formatDisplayMessage(message2) {
53272
53320
  const time3 = new Date(message2.timestamp).toLocaleTimeString();
53273
53321
  switch (message2.type) {
53274
53322
  case "user":
53275
- console.log(import_chalk21.default.blue(`
53323
+ console.log(import_chalk22.default.blue(`
53276
53324
  [${time3}] USER:`));
53277
- console.log(import_chalk21.default.white(` ${truncate(message2.content, 500)}`));
53325
+ console.log(import_chalk22.default.white(` ${truncate(message2.content, 500)}`));
53278
53326
  break;
53279
53327
  case "agent":
53280
- console.log(import_chalk21.default.green(`
53328
+ console.log(import_chalk22.default.green(`
53281
53329
  [${time3}] ASSISTANT:`));
53282
- console.log(import_chalk21.default.white(` ${truncate(message2.content, 500)}`));
53330
+ console.log(import_chalk22.default.white(` ${truncate(message2.content, 500)}`));
53283
53331
  break;
53284
53332
  case "reasoning":
53285
- console.log(import_chalk21.default.gray(`
53333
+ console.log(import_chalk22.default.gray(`
53286
53334
  [${time3}] THINKING:`));
53287
- console.log(import_chalk21.default.gray(` ${truncate(message2.content, 300)}`));
53335
+ console.log(import_chalk22.default.gray(` ${truncate(message2.content, 300)}`));
53288
53336
  break;
53289
53337
  case "command":
53290
- console.log(import_chalk21.default.magenta(`
53338
+ console.log(import_chalk22.default.magenta(`
53291
53339
  [${time3}] COMMAND:`));
53292
- console.log(import_chalk21.default.white(` $ ${message2.command}`));
53340
+ console.log(import_chalk22.default.white(` $ ${message2.command}`));
53293
53341
  if (message2.output) {
53294
- console.log(import_chalk21.default.gray(` ${truncate(message2.output, 200)}`));
53342
+ console.log(import_chalk22.default.gray(` ${truncate(message2.output, 200)}`));
53295
53343
  }
53296
53344
  if (message2.exitCode !== void 0) {
53297
- const exitColor = message2.exitCode === 0 ? import_chalk21.default.green : import_chalk21.default.red;
53345
+ const exitColor = message2.exitCode === 0 ? import_chalk22.default.green : import_chalk22.default.red;
53298
53346
  console.log(exitColor(` Exit code: ${message2.exitCode}`));
53299
53347
  }
53300
53348
  break;
53301
53349
  case "file_change":
53302
- console.log(import_chalk21.default.yellow(`
53350
+ console.log(import_chalk22.default.yellow(`
53303
53351
  [${time3}] FILE CHANGES:`));
53304
53352
  for (const change of message2.changes) {
53305
53353
  const icon = change.kind === "add" ? "+" : change.kind === "delete" ? "-" : "~";
53306
- const color = change.kind === "add" ? import_chalk21.default.green : change.kind === "delete" ? import_chalk21.default.red : import_chalk21.default.yellow;
53354
+ const color = change.kind === "add" ? import_chalk22.default.green : change.kind === "delete" ? import_chalk22.default.red : import_chalk22.default.yellow;
53307
53355
  console.log(color(` ${icon} ${change.path}`));
53308
53356
  }
53309
53357
  break;
53310
53358
  case "patch":
53311
- console.log(import_chalk21.default.yellow(`
53359
+ console.log(import_chalk22.default.yellow(`
53312
53360
  [${time3}] PATCH:`));
53313
53361
  for (const op of message2.operations) {
53314
53362
  const icon = op.action === "add" ? "+" : op.action === "delete" ? "-" : "~";
53315
- const color = op.action === "add" ? import_chalk21.default.green : op.action === "delete" ? import_chalk21.default.red : import_chalk21.default.yellow;
53363
+ const color = op.action === "add" ? import_chalk22.default.green : op.action === "delete" ? import_chalk22.default.red : import_chalk22.default.yellow;
53316
53364
  console.log(color(` ${icon} ${op.path}`));
53317
53365
  }
53318
53366
  break;
53319
53367
  case "tool_call":
53320
- console.log(import_chalk21.default.cyan(`
53368
+ console.log(import_chalk22.default.cyan(`
53321
53369
  [${time3}] TOOL: ${message2.tool}`));
53322
53370
  if (message2.output) {
53323
- console.log(import_chalk21.default.gray(` ${truncate(message2.output, 200)}`));
53371
+ console.log(import_chalk22.default.gray(` ${truncate(message2.output, 200)}`));
53324
53372
  }
53325
53373
  if (message2.inputRequest?.status === "pending") {
53326
53374
  const { requestId, options, questions } = message2.inputRequest;
53327
- console.log(import_chalk21.default.yellow(` Awaiting answer, request ID: ${requestId}`));
53328
- for (const option of options ?? []) console.log(import_chalk21.default.white(` ${option.id}: ${option.label}`));
53375
+ console.log(import_chalk22.default.yellow(` Awaiting answer, request ID: ${requestId}`));
53376
+ for (const option of options ?? []) console.log(import_chalk22.default.white(` ${option.id}: ${option.label}`));
53329
53377
  for (const question of questions ?? []) {
53330
- console.log(import_chalk21.default.white(` Question ${question.id}: ${question.prompt}${question.multiSelect ? " (multi-select)" : ""}`));
53331
- for (const option of question.options) console.log(import_chalk21.default.gray(` ${option.id}: ${option.label}`));
53378
+ console.log(import_chalk22.default.white(` Question ${question.id}: ${question.prompt}${question.multiSelect ? " (multi-select)" : ""}`));
53379
+ for (const option of question.options) console.log(import_chalk22.default.gray(` ${option.id}: ${option.label}`));
53332
53380
  }
53333
53381
  if (questions?.length) {
53334
- console.log(import_chalk21.default.gray(` Selection ID: '{"<question>":{"options":["<option>"]}}', '{"<question>":{"custom":"<text>"}}', or declined`));
53382
+ console.log(import_chalk22.default.gray(` Selection ID: '{"<question>":{"options":["<option>"]}}', '{"<question>":{"custom":"<text>"}}', or declined`));
53335
53383
  }
53336
53384
  }
53337
53385
  break;
53338
53386
  case "web_search":
53339
- console.log(import_chalk21.default.cyan(`
53387
+ console.log(import_chalk22.default.cyan(`
53340
53388
  [${time3}] WEB SEARCH:`));
53341
- console.log(import_chalk21.default.white(` "${message2.query}"`));
53389
+ console.log(import_chalk22.default.white(` "${message2.query}"`));
53342
53390
  break;
53343
53391
  case "todo_list":
53344
- console.log(import_chalk21.default.blue(`
53392
+ console.log(import_chalk22.default.blue(`
53345
53393
  [${time3}] PLAN:`));
53346
53394
  for (const item of message2.items) {
53347
- const icon = item.completed ? import_chalk21.default.green("[x]") : import_chalk21.default.gray("[ ]");
53395
+ const icon = item.completed ? import_chalk22.default.green("[x]") : import_chalk22.default.gray("[ ]");
53348
53396
  console.log(` ${icon} ${item.text}`);
53349
53397
  }
53350
53398
  break;
53351
53399
  case "subagent":
53352
- console.log(import_chalk21.default.magenta(`
53400
+ console.log(import_chalk22.default.magenta(`
53353
53401
  [${time3}] SUBAGENT: ${message2.description}`));
53354
53402
  if (message2.output) {
53355
- console.log(import_chalk21.default.gray(` ${truncate(message2.output, 200)}`));
53403
+ console.log(import_chalk22.default.gray(` ${truncate(message2.output, 200)}`));
53356
53404
  }
53357
53405
  break;
53358
53406
  case "error":
53359
- console.log(import_chalk21.default.red(`
53407
+ console.log(import_chalk22.default.red(`
53360
53408
  [${time3}] ERROR:`));
53361
- console.log(import_chalk21.default.red(` ${message2.message}`));
53409
+ console.log(import_chalk22.default.red(` ${message2.message}`));
53362
53410
  break;
53363
53411
  }
53364
53412
  }
@@ -53373,24 +53421,24 @@ async function replicaListCommand(options) {
53373
53421
  );
53374
53422
  output2(response, (response2) => {
53375
53423
  if (response2.replicas.length === 0) {
53376
- console.log(import_chalk21.default.yellow("\nNo replicas found.\n"));
53424
+ console.log(import_chalk22.default.yellow("\nNo replicas found.\n"));
53377
53425
  return;
53378
53426
  }
53379
- console.log(import_chalk21.default.green(`
53427
+ console.log(import_chalk22.default.green(`
53380
53428
  Replicas (Page ${response2.page} of ${response2.total_pages}, Total: ${response2.total}):
53381
53429
  `));
53382
53430
  for (const replica of response2.replicas) {
53383
- console.log(import_chalk21.default.white(` ${replica.name}`));
53384
- console.log(import_chalk21.default.gray(` ID: ${replica.id}`));
53431
+ console.log(import_chalk22.default.white(` ${replica.name}`));
53432
+ console.log(import_chalk22.default.gray(` ID: ${replica.id}`));
53385
53433
  if (replica.repositories.length > 0) {
53386
- console.log(import_chalk21.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53434
+ console.log(import_chalk22.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53387
53435
  }
53388
- console.log(import_chalk21.default.gray(` Status: ${formatStatus(replica.status)}`));
53389
- console.log(import_chalk21.default.gray(` Created: ${formatDate(replica.created_at)}`));
53436
+ console.log(import_chalk22.default.gray(` Status: ${formatStatus(replica.status)}`));
53437
+ console.log(import_chalk22.default.gray(` Created: ${formatDate(replica.created_at)}`));
53390
53438
  if (replica.pull_requests && replica.pull_requests.length > 0) {
53391
- console.log(import_chalk21.default.gray(` Pull Requests:`));
53439
+ console.log(import_chalk22.default.gray(` Pull Requests:`));
53392
53440
  for (const pr2 of replica.pull_requests) {
53393
- console.log(import_chalk21.default.cyan(` - ${pr2.repository} #${pr2.number}: ${pr2.url}`));
53441
+ console.log(import_chalk22.default.cyan(` - ${pr2.repository} #${pr2.number}: ${pr2.url}`));
53394
53442
  }
53395
53443
  }
53396
53444
  console.log();
@@ -53401,30 +53449,30 @@ async function replicaGetCommand(id) {
53401
53449
  ensureOrgApiAuthenticated();
53402
53450
  const response = await orgAuthenticatedFetch(`/v1/replica/${id}`);
53403
53451
  output2(response, ({ replica }) => {
53404
- console.log(import_chalk21.default.green(`
53452
+ console.log(import_chalk22.default.green(`
53405
53453
  Replica: ${replica.name}
53406
53454
  `));
53407
- console.log(import_chalk21.default.gray(` ID: ${replica.id}`));
53455
+ console.log(import_chalk22.default.gray(` ID: ${replica.id}`));
53408
53456
  if (replica.repositories.length > 0) {
53409
- console.log(import_chalk21.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53457
+ console.log(import_chalk22.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53410
53458
  }
53411
- console.log(import_chalk21.default.gray(` Status: ${formatStatus(replica.status)}`));
53412
- console.log(import_chalk21.default.gray(` Created: ${formatDate(replica.created_at)}`));
53459
+ console.log(import_chalk22.default.gray(` Status: ${formatStatus(replica.status)}`));
53460
+ console.log(import_chalk22.default.gray(` Created: ${formatDate(replica.created_at)}`));
53413
53461
  if (replica.coding_agent) {
53414
- console.log(import_chalk21.default.gray(` Coding Agent: ${replica.coding_agent}`));
53462
+ console.log(import_chalk22.default.gray(` Coding Agent: ${replica.coding_agent}`));
53415
53463
  }
53416
53464
  if (replica.activity) printReplicaActivity(replica.activity);
53417
53465
  if (replica.repository_statuses && replica.repository_statuses.length > 0) {
53418
- console.log(import_chalk21.default.gray(" Repository Statuses:"));
53466
+ console.log(import_chalk22.default.gray(" Repository Statuses:"));
53419
53467
  for (const repositoryStatus of replica.repository_statuses) {
53420
- const changeText = repositoryStatus.git_diff ? ` (${import_chalk21.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk21.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
53421
- console.log(import_chalk21.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
53468
+ const changeText = repositoryStatus.git_diff ? ` (${import_chalk22.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk22.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
53469
+ console.log(import_chalk22.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
53422
53470
  }
53423
53471
  }
53424
53472
  if (replica.pull_requests && replica.pull_requests.length > 0) {
53425
- console.log(import_chalk21.default.gray(` Pull Requests:`));
53473
+ console.log(import_chalk22.default.gray(` Pull Requests:`));
53426
53474
  for (const pr2 of replica.pull_requests) {
53427
- console.log(import_chalk21.default.cyan(` - ${pr2.repository} #${pr2.number}: ${pr2.url}`));
53475
+ console.log(import_chalk22.default.cyan(` - ${pr2.repository} #${pr2.number}: ${pr2.url}`));
53428
53476
  }
53429
53477
  }
53430
53478
  console.log();
@@ -53451,7 +53499,7 @@ async function replicaCreateCommand(name, options) {
53451
53499
  });
53452
53500
  const answer = response2.name;
53453
53501
  if (!answer) {
53454
- console.log(import_chalk21.default.yellow("\nCancelled."));
53502
+ console.log(import_chalk22.default.yellow("\nCancelled."));
53455
53503
  return;
53456
53504
  }
53457
53505
  replicaName = answer;
@@ -53469,7 +53517,7 @@ async function replicaCreateCommand(name, options) {
53469
53517
  });
53470
53518
  const answer = response2.environment;
53471
53519
  if (!answer) {
53472
- console.log(import_chalk21.default.yellow("\nCancelled."));
53520
+ console.log(import_chalk22.default.yellow("\nCancelled."));
53473
53521
  return;
53474
53522
  }
53475
53523
  selectedEnvironmentId = answer;
@@ -53483,7 +53531,7 @@ async function replicaCreateCommand(name, options) {
53483
53531
  });
53484
53532
  const answer = response2.message;
53485
53533
  if (!answer) {
53486
- console.log(import_chalk21.default.yellow("\nCancelled."));
53534
+ console.log(import_chalk22.default.yellow("\nCancelled."));
53487
53535
  return;
53488
53536
  }
53489
53537
  message2 = answer;
@@ -53497,7 +53545,7 @@ async function replicaCreateCommand(name, options) {
53497
53545
  initial: 0
53498
53546
  });
53499
53547
  if (!response2.agent) {
53500
- console.log(import_chalk21.default.yellow("\nCancelled."));
53548
+ console.log(import_chalk22.default.yellow("\nCancelled."));
53501
53549
  return;
53502
53550
  }
53503
53551
  codingAgent = parseReplicaAgent(response2.agent);
@@ -53509,20 +53557,20 @@ async function replicaCreateCommand(name, options) {
53509
53557
  coding_agent: codingAgent,
53510
53558
  lifecycle_policy: "default"
53511
53559
  };
53512
- console.log(import_chalk21.default.gray("\nCreating replica..."));
53560
+ console.log(import_chalk22.default.gray("\nCreating replica..."));
53513
53561
  const response = await orgAuthenticatedFetch("/v1/replica", {
53514
53562
  method: "POST",
53515
53563
  body
53516
53564
  });
53517
53565
  output2(response, ({ replica }) => {
53518
- console.log(import_chalk21.default.green(`
53566
+ console.log(import_chalk22.default.green(`
53519
53567
  Created replica: ${replica.name}`));
53520
- console.log(import_chalk21.default.gray(` ID: ${replica.id}`));
53521
- console.log(import_chalk21.default.gray(` Status: ${formatStatus(replica.status)}`));
53568
+ console.log(import_chalk22.default.gray(` ID: ${replica.id}`));
53569
+ console.log(import_chalk22.default.gray(` Status: ${formatStatus(replica.status)}`));
53522
53570
  if (replica.repositories.length > 0) {
53523
- console.log(import_chalk21.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53571
+ console.log(import_chalk22.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
53524
53572
  }
53525
- console.log(import_chalk21.default.cyan(` Link: ${getWorkspaceDashboardUrl(replica.id, { webAppUrl: process.env.REPLICAS_WEB_URL || DEFAULT_WEB_APP_URL })}`));
53573
+ console.log(import_chalk22.default.cyan(` Link: ${getWorkspaceDashboardUrl(replica.id, { webAppUrl: process.env.REPLICAS_WEB_URL || DEFAULT_WEB_APP_URL })}`));
53526
53574
  console.log();
53527
53575
  });
53528
53576
  }
@@ -53538,7 +53586,7 @@ async function replicaSendCommand(id, options) {
53538
53586
  });
53539
53587
  const answer = response2.message;
53540
53588
  if (!answer) {
53541
- console.log(import_chalk21.default.yellow("\nCancelled."));
53589
+ console.log(import_chalk22.default.yellow("\nCancelled."));
53542
53590
  return;
53543
53591
  }
53544
53592
  message2 = answer;
@@ -53563,14 +53611,14 @@ async function replicaSendCommand(id, options) {
53563
53611
  }
53564
53612
  );
53565
53613
  output2(response, (response2) => {
53566
- const statusColor = response2.status === "sent" ? import_chalk21.default.green : import_chalk21.default.yellow;
53614
+ const statusColor = response2.status === "sent" ? import_chalk22.default.green : import_chalk22.default.yellow;
53567
53615
  console.log(statusColor(`
53568
53616
  Message ${response2.status}`));
53569
53617
  if (response2.chat_id) {
53570
- console.log(import_chalk21.default.gray(` Chat: ${response2.chat_id}`));
53618
+ console.log(import_chalk22.default.gray(` Chat: ${response2.chat_id}`));
53571
53619
  }
53572
53620
  if (response2.position !== void 0 && response2.position > 0) {
53573
- console.log(import_chalk21.default.gray(` Queue position: ${response2.position}`));
53621
+ console.log(import_chalk22.default.gray(` Queue position: ${response2.position}`));
53574
53622
  }
53575
53623
  console.log();
53576
53624
  });
@@ -53597,40 +53645,40 @@ async function replicaReadCommand(id, options) {
53597
53645
  `/v1/replica/${id}/history${query ? "?" + query : ""}`
53598
53646
  );
53599
53647
  output2(response, (response2) => {
53600
- console.log(import_chalk21.default.green(`
53648
+ console.log(import_chalk22.default.green(`
53601
53649
  Conversation History
53602
53650
  `));
53603
53651
  if (response2.coding_agent) {
53604
- console.log(import_chalk21.default.gray(` Agent: ${response2.coding_agent}`));
53652
+ console.log(import_chalk22.default.gray(` Agent: ${response2.coding_agent}`));
53605
53653
  }
53606
53654
  if (response2.thread_id) {
53607
- console.log(import_chalk21.default.gray(` Thread ID: ${response2.thread_id}`));
53655
+ console.log(import_chalk22.default.gray(` Thread ID: ${response2.thread_id}`));
53608
53656
  }
53609
- console.log(import_chalk21.default.gray(` Total Events: ${response2.total}`));
53657
+ console.log(import_chalk22.default.gray(` Total Events: ${response2.total}`));
53610
53658
  if (response2.has_more) {
53611
53659
  const previousPage = response2.beforeCursor ? `--before '${response2.beforeCursor}'` : `--before-event ${response2.eventsStartIndex}`;
53612
- console.log(import_chalk21.default.gray(` Has More: yes (${previousPage} for the previous page)`));
53660
+ console.log(import_chalk22.default.gray(` Has More: yes (${previousPage} for the previous page)`));
53613
53661
  }
53614
53662
  console.log();
53615
53663
  if (response2.events.length === 0) {
53616
- console.log(import_chalk21.default.yellow(" No events found.\n"));
53664
+ console.log(import_chalk22.default.yellow(" No events found.\n"));
53617
53665
  return;
53618
53666
  }
53619
- console.log(import_chalk21.default.gray("-".repeat(60)));
53667
+ console.log(import_chalk22.default.gray("-".repeat(60)));
53620
53668
  const agentType = response2.coding_agent || "claude";
53621
53669
  const displayMessages = parseDisplayMessages(response2.events, agentType);
53622
53670
  for (const message2 of displayMessages) {
53623
53671
  formatDisplayMessage(message2);
53624
53672
  }
53625
- console.log(import_chalk21.default.gray("\n" + "-".repeat(60)));
53673
+ console.log(import_chalk22.default.gray("\n" + "-".repeat(60)));
53626
53674
  console.log();
53627
53675
  });
53628
53676
  }
53629
- var import_chalk21, CLI_CODING_AGENT_LABEL;
53677
+ var import_chalk22, CLI_CODING_AGENT_LABEL;
53630
53678
  var init_replica2 = __esm({
53631
53679
  "src/commands/replica.ts"() {
53632
53680
  "use strict";
53633
- import_chalk21 = __toESM(require("chalk"));
53681
+ import_chalk22 = __toESM(require("chalk"));
53634
53682
  init_api2();
53635
53683
  init_environment3();
53636
53684
  init_command_utils();
@@ -53646,7 +53694,7 @@ async function workspaceRenameCommand(id, name) {
53646
53694
  method: "PATCH",
53647
53695
  body: { name }
53648
53696
  });
53649
- output2(response, ({ workspace }) => console.log(import_chalk22.default.green(`Renamed workspace to ${workspace.name}`)));
53697
+ output2(response, ({ workspace }) => console.log(import_chalk23.default.green(`Renamed workspace to ${workspace.name}`)));
53650
53698
  }
53651
53699
  async function workspaceWakeCommand(id, options) {
53652
53700
  await orgAuthenticatedFetch(`/v1/replica/${id}/wake${options.restore ? "?restore=true" : ""}`, { method: "POST" });
@@ -53666,7 +53714,7 @@ async function workspaceWaitCommand(id, options) {
53666
53714
  if (options.chat) query.set("chat_id", options.chat);
53667
53715
  const step = result?.activity.current_step;
53668
53716
  result = await orgAuthenticatedFetch(`/v1/replica/${id}/wait?${query}`);
53669
- if (!result.done && result.activity.current_step && result.activity.current_step !== step) console.error(import_chalk22.default.gray(`\u2026 ${result.activity.current_step}`));
53717
+ if (!result.done && result.activity.current_step && result.activity.current_step !== step) console.error(import_chalk23.default.gray(`\u2026 ${result.activity.current_step}`));
53670
53718
  } while (!result.done && result.activity.state !== "waiting_for_input" && Date.now() < deadline);
53671
53719
  output2(result, ({ done, status, deleted, activity }) => {
53672
53720
  console.log(done ? `Done (status: ${deleted ? "deleted" : status})` : activity.state === "waiting_for_input" ? "The agent is waiting for input" : `Still working after timeout (status: ${status})`);
@@ -53678,7 +53726,7 @@ async function workspaceStatusCommand(id) {
53678
53726
  output2(await orgAuthenticatedFetch(`/v1/replica/${id}/status`), (status) => {
53679
53727
  const agentsWith = (suffix) => Object.entries(status).filter(([key, value]) => value === true && key.startsWith("is") && key.endsWith(suffix)).map(([key]) => key.slice(2, -suffix.length).toLowerCase());
53680
53728
  console.log(`Status: ${status.status}`);
53681
- if (status.message || status.error) console.log(import_chalk22.default.yellow(status.message || status.error));
53729
+ if (status.message || status.error) console.log(import_chalk23.default.yellow(status.message || status.error));
53682
53730
  const working = agentsWith("Processing");
53683
53731
  const awaiting = agentsWith("AwaitingInput");
53684
53732
  if (working.length > 0) console.log(`Working: ${working.join(", ")}`);
@@ -53706,8 +53754,8 @@ async function workspaceExecCommand(id, command, options) {
53706
53754
  output2(result, () => {
53707
53755
  process.stdout.write(result.output.endsWith("\n") || !result.output ? result.output : `${result.output}
53708
53756
  `);
53709
- if (result.truncated) console.error(import_chalk22.default.yellow("Output truncated."));
53710
- if (result.timed_out) console.error(import_chalk22.default.yellow("Command timed out."));
53757
+ if (result.truncated) console.error(import_chalk23.default.yellow("Output truncated."));
53758
+ if (result.timed_out) console.error(import_chalk23.default.yellow("Command timed out."));
53711
53759
  });
53712
53760
  process.exitCode = result.exit_code ?? 1;
53713
53761
  }
@@ -53722,11 +53770,11 @@ async function workspaceHooksCommand(id) {
53722
53770
  return;
53723
53771
  }
53724
53772
  for (const entry of entries) {
53725
- const result = entry.timedOut ? import_chalk22.default.red("timed out") : entry.exitCode === 0 ? import_chalk22.default.green("exit 0") : import_chalk22.default.red(`exit ${entry.exitCode}`);
53726
- console.log(import_chalk22.default.bold(`
53773
+ const result = entry.timedOut ? import_chalk23.default.red("timed out") : entry.exitCode === 0 ? import_chalk23.default.green("exit 0") : import_chalk23.default.red(`exit ${entry.exitCode}`);
53774
+ console.log(import_chalk23.default.bold(`
53727
53775
  [${entry.kind}] ${entry.hookName} (${entry.hookType}) ${result} at ${formatDate(entry.executedAt)}`));
53728
53776
  console.log(entry.output.trimEnd());
53729
- if (entry.outputTruncated) console.log(import_chalk22.default.gray(`\u2026 truncated (${entry.outputTotalChars} chars total)`));
53777
+ if (entry.outputTruncated) console.log(import_chalk23.default.gray(`\u2026 truncated (${entry.outputTotalChars} chars total)`));
53730
53778
  }
53731
53779
  });
53732
53780
  }
@@ -53734,7 +53782,7 @@ async function workspaceLogsCommand(id, sessionId, options) {
53734
53782
  if (!sessionId) {
53735
53783
  output2(await orgAuthenticatedFetch(`/v1/replica/${id}/logs`), ({ currentSessionId, sessions }) => {
53736
53784
  for (const session of sessions) {
53737
- const current = session.sessionId === currentSessionId ? import_chalk22.default.green(" (current)") : "";
53785
+ const current = session.sessionId === currentSessionId ? import_chalk23.default.green(" (current)") : "";
53738
53786
  console.log(`${session.sessionId} ${session.sizeBytes} bytes ${formatDate(session.updatedAt)}${current}`);
53739
53787
  }
53740
53788
  });
@@ -53747,7 +53795,7 @@ async function workspaceLogsCommand(id, sessionId, options) {
53747
53795
  output2(await orgAuthenticatedFetch(`/v1/replica/${id}/logs/${sessionId}${query ? `?${query}` : ""}`), (log) => {
53748
53796
  console.log(log.lines.join("\n"));
53749
53797
  if (log.hasMore) {
53750
- console.error(import_chalk22.default.gray(`Lines ${log.offset}-${log.offset + log.lines.length} of ${log.totalLines}. Next: --offset ${log.offset + log.lines.length}`));
53798
+ console.error(import_chalk23.default.gray(`Lines ${log.offset}-${log.offset + log.lines.length} of ${log.totalLines}. Next: --offset ${log.offset + log.lines.length}`));
53751
53799
  }
53752
53800
  });
53753
53801
  }
@@ -53787,16 +53835,16 @@ async function prViewCommand(id, prUrls) {
53787
53835
  );
53788
53836
  output2(response, ({ pullRequests }) => {
53789
53837
  for (const { url: url2, details, error: error62 } of pullRequests) {
53790
- console.log(import_chalk22.default.bold(`
53838
+ console.log(import_chalk23.default.bold(`
53791
53839
  ${url2}`));
53792
53840
  if (!details) {
53793
- console.log(import_chalk22.default.red(` ${error62 ?? "Details unavailable"}`));
53841
+ console.log(import_chalk23.default.red(` ${error62 ?? "Details unavailable"}`));
53794
53842
  continue;
53795
53843
  }
53796
53844
  console.log(` ${details.title}`);
53797
53845
  console.log(` State: ${details.state} Mergeability: ${details.mergeability} CI: ${details.ciStatus}`);
53798
53846
  console.log(` ${details.headBranch} \u2192 ${details.baseBranch} +${details.additions ?? 0} -${details.deletions ?? 0} in ${details.changedFiles} files`);
53799
- if (details.mergeBlockers?.length) console.log(import_chalk22.default.yellow(` Blocked by: ${details.mergeBlockers.join(", ").replaceAll("_", " ")}`));
53847
+ if (details.mergeBlockers?.length) console.log(import_chalk23.default.yellow(` Blocked by: ${details.mergeBlockers.join(", ").replaceAll("_", " ")}`));
53800
53848
  }
53801
53849
  });
53802
53850
  }
@@ -53836,14 +53884,14 @@ async function canvasPutCommand(id, filename, options) {
53836
53884
  { method: "PUT", body }
53837
53885
  );
53838
53886
  if (!result.saved) throw new Error(`${filename} changed while saving; retry`);
53839
- output2(result, () => console.log(import_chalk22.default.green(`Saved ${filename}`)));
53887
+ output2(result, () => console.log(import_chalk23.default.green(`Saved ${filename}`)));
53840
53888
  }
53841
- var import_fs5, import_chalk22, getCanvasFile;
53889
+ var import_fs5, import_chalk23, getCanvasFile;
53842
53890
  var init_workspace = __esm({
53843
53891
  "src/commands/workspace.ts"() {
53844
53892
  "use strict";
53845
53893
  import_fs5 = __toESM(require("fs"));
53846
- import_chalk22 = __toESM(require("chalk"));
53894
+ import_chalk23 = __toESM(require("chalk"));
53847
53895
  init_src();
53848
53896
  init_api2();
53849
53897
  init_command_utils();
@@ -53859,7 +53907,7 @@ function printQueue(queue) {
53859
53907
  return;
53860
53908
  }
53861
53909
  queue.forEach((message2, index) => {
53862
- const steered = message2.steeredAt ? import_chalk23.default.cyan(" (steered)") : "";
53910
+ const steered = message2.steeredAt ? import_chalk24.default.cyan(" (steered)") : "";
53863
53911
  console.log(`${index} ${message2.id}${steered} ${message2.message.replace(/\s+/g, " ").slice(0, 120)}`);
53864
53912
  });
53865
53913
  }
@@ -53869,7 +53917,7 @@ function printGoal({ goal }) {
53869
53917
  async function chatListCommand(id) {
53870
53918
  output2(await orgAuthenticatedFetch(`/v1/replica/${id}/chats`), ({ chats }) => {
53871
53919
  for (const chat2 of chats) {
53872
- console.log(`${chat2.id} ${chat2.provider} ${chat2.processing ? import_chalk23.default.green("working") : "idle"} ${chat2.title}`);
53920
+ console.log(`${chat2.id} ${chat2.provider} ${chat2.processing ? import_chalk24.default.green("working") : "idle"} ${chat2.title}`);
53873
53921
  }
53874
53922
  });
53875
53923
  }
@@ -53892,7 +53940,7 @@ async function chatRestoreCommand(id, chatId) {
53892
53940
  outputSuccess(`Restored chat ${chatId}`);
53893
53941
  }
53894
53942
  async function chatInterruptCommand(id, chatId) {
53895
- output2(await orgAuthenticatedFetch(chatPath2(id, chatId, "/interrupt"), { method: "POST" }), ({ interrupted }) => console.log(interrupted ? import_chalk23.default.green("Interrupted.") : "Nothing to interrupt."));
53943
+ output2(await orgAuthenticatedFetch(chatPath2(id, chatId, "/interrupt"), { method: "POST" }), ({ interrupted }) => console.log(interrupted ? import_chalk24.default.green("Interrupted.") : "Nothing to interrupt."));
53896
53944
  }
53897
53945
  async function chatForkCommand(id, chatId, options) {
53898
53946
  const provider2 = parseReplicaAgent(options.agent);
@@ -53922,7 +53970,7 @@ async function chatAnswerCommand(id, chatId, requestId, selectionId) {
53922
53970
  method: "POST",
53923
53971
  body: { requestId, selectionId }
53924
53972
  });
53925
- output2(response, ({ resolved }) => console.log(resolved ? import_chalk23.default.green("Answer sent.") : import_chalk23.default.yellow("That question is no longer pending.")));
53973
+ output2(response, ({ resolved }) => console.log(resolved ? import_chalk24.default.green("Answer sent.") : import_chalk24.default.yellow("That question is no longer pending.")));
53926
53974
  }
53927
53975
  async function chatCommandsCommand(id, chatId) {
53928
53976
  output2(await orgAuthenticatedFetch(chatPath2(id, chatId, "/slash-commands")), ({ commands }) => {
@@ -53933,7 +53981,7 @@ async function chatCommandsCommand(id, chatId) {
53933
53981
  }
53934
53982
  async function chatQueueListCommand(id, chatId) {
53935
53983
  output2(await orgAuthenticatedFetch(chatPath2(id, chatId, "/queue")), ({ processing, queue }) => {
53936
- console.log(import_chalk23.default.gray(processing ? "Agent is working." : "Agent is idle."));
53984
+ console.log(import_chalk24.default.gray(processing ? "Agent is working." : "Agent is idle."));
53937
53985
  printQueue(queue);
53938
53986
  });
53939
53987
  }
@@ -53943,11 +53991,11 @@ async function mutateQueue(path11, method, body) {
53943
53991
  else console.log("Done.");
53944
53992
  });
53945
53993
  }
53946
- var import_chalk23, chatPath2, chatQueueClearCommand, chatQueueRemoveCommand, chatQueueEditCommand, chatQueueMoveCommand, chatQueueActionCommand;
53994
+ var import_chalk24, chatPath2, chatQueueClearCommand, chatQueueRemoveCommand, chatQueueEditCommand, chatQueueMoveCommand, chatQueueActionCommand;
53947
53995
  var init_chat = __esm({
53948
53996
  "src/commands/chat.ts"() {
53949
53997
  "use strict";
53950
- import_chalk23 = __toESM(require("chalk"));
53998
+ import_chalk24 = __toESM(require("chalk"));
53951
53999
  init_api2();
53952
54000
  init_output();
53953
54001
  init_replica2();
@@ -53991,13 +54039,13 @@ async function pluginsDisconnectCommand(pluginId, options) {
53991
54039
  await pluginsPath(options, `/${pluginId}${options.connection ? `/connections/${options.connection}` : ""}`),
53992
54040
  { method: "DELETE" }
53993
54041
  );
53994
- output2(response, ({ success: success2 }) => console.log(success2 ? import_chalk24.default.green(`Disconnected ${pluginId}`) : `${pluginId} was not connected`));
54042
+ output2(response, ({ success: success2 }) => console.log(success2 ? import_chalk25.default.green(`Disconnected ${pluginId}`) : `${pluginId} was not connected`));
53995
54043
  }
53996
- var import_chalk24, pluginsPath;
54044
+ var import_chalk25, pluginsPath;
53997
54045
  var init_plugins3 = __esm({
53998
54046
  "src/commands/plugins.ts"() {
53999
54047
  "use strict";
54000
- import_chalk24 = __toESM(require("chalk"));
54048
+ import_chalk25 = __toESM(require("chalk"));
54001
54049
  init_api2();
54002
54050
  init_command_utils();
54003
54051
  init_output();
@@ -54016,20 +54064,20 @@ async function fetchCurrentRun() {
54016
54064
  }
54017
54065
  async function environmentSetupStatusCommand() {
54018
54066
  output2(await fetchCurrentRun(), ({ run: run2, environment: environment2, repositories }) => {
54019
- console.log(import_chalk25.default.bold(`
54067
+ console.log(import_chalk26.default.bold(`
54020
54068
  Environment setup: ${environment2.name}
54021
54069
  `));
54022
54070
  console.log(` Run: ${run2.id}`);
54023
- console.log(` Status: ${run2.status}${run2.error ? import_chalk25.default.red(` (${run2.error})`) : ""}`);
54071
+ console.log(` Status: ${run2.status}${run2.error ? import_chalk26.default.red(` (${run2.error})`) : ""}`);
54024
54072
  console.log(` Environment: ${environment2.id}`);
54025
54073
  console.log(` Repositories: ${repositories.map((repo) => `${repo.name} (${repo.default_branch})`).join(", ") || "none"}`);
54026
54074
  console.log("\n Steps:");
54027
54075
  for (const step of ENVIRONMENT_SETUP_STEPS) {
54028
54076
  const status = run2.steps[step.key] ?? "pending";
54029
- const marker = status === "completed" ? import_chalk25.default.green("\u2713") : status === "in_progress" ? import_chalk25.default.cyan("\u25B8") : status === "skipped" ? import_chalk25.default.gray("\u2013") : import_chalk25.default.gray("\u25CB");
54030
- console.log(` ${marker} ${step.key.padEnd(11)} ${import_chalk25.default.gray(step.label)} ${import_chalk25.default.gray(`[${status}]`)}`);
54077
+ const marker = status === "completed" ? import_chalk26.default.green("\u2713") : status === "in_progress" ? import_chalk26.default.cyan("\u25B8") : status === "skipped" ? import_chalk26.default.gray("\u2013") : import_chalk26.default.gray("\u25CB");
54078
+ console.log(` ${marker} ${step.key.padEnd(11)} ${import_chalk26.default.gray(step.label)} ${import_chalk26.default.gray(`[${status}]`)}`);
54031
54079
  }
54032
- console.log(run2.proposal ? import_chalk25.default.gray("\n A proposal has been submitted. Run `propose` again to replace it.\n") : import_chalk25.default.gray("\n No proposal yet. Submit one with `replicas environment-setup propose --file <path>`.\n"));
54080
+ console.log(run2.proposal ? import_chalk26.default.gray("\n A proposal has been submitted. Run `propose` again to replace it.\n") : import_chalk26.default.gray("\n No proposal yet. Submit one with `replicas environment-setup propose --file <path>`.\n"));
54033
54081
  });
54034
54082
  }
54035
54083
  async function environmentSetupStepCommand(key, status) {
@@ -54045,7 +54093,7 @@ async function environmentSetupStepCommand(key, status) {
54045
54093
  method: "POST",
54046
54094
  body
54047
54095
  });
54048
- output2(result, () => console.log(import_chalk25.default.green(`
54096
+ output2(result, () => console.log(import_chalk26.default.green(`
54049
54097
  \u2713 ${key} \u2192 ${status}
54050
54098
  `)));
54051
54099
  }
@@ -54064,22 +54112,22 @@ async function environmentSetupProposeCommand(options) {
54064
54112
  body: { proposal }
54065
54113
  });
54066
54114
  output2(result, ({ run: { proposal: submitted } }) => {
54067
- console.log(import_chalk25.default.green("\n\u2713 Proposal submitted.\n"));
54115
+ console.log(import_chalk26.default.green("\n\u2713 Proposal submitted.\n"));
54068
54116
  if (submitted) {
54069
54117
  console.log(` Automations: ${submitted.automations.length}`);
54070
54118
  console.log(` Variables: ${submitted.variables.length}`);
54071
54119
  console.log(` Checks: ${submitted.verification.length}`);
54072
54120
  console.log(` Media: ${submitted.media.length}`);
54073
54121
  }
54074
- console.log(import_chalk25.default.gray("\n The user reviews and saves it from the Environment panel; nothing has been applied yet.\n"));
54122
+ console.log(import_chalk26.default.gray("\n The user reviews and saves it from the Environment panel; nothing has been applied yet.\n"));
54075
54123
  });
54076
54124
  }
54077
- var import_fs6, import_chalk25, STEP_KEYS;
54125
+ var import_fs6, import_chalk26, STEP_KEYS;
54078
54126
  var init_environment_setup2 = __esm({
54079
54127
  "src/commands/environment-setup.ts"() {
54080
54128
  "use strict";
54081
54129
  import_fs6 = __toESM(require("fs"));
54082
- import_chalk25 = __toESM(require("chalk"));
54130
+ import_chalk26 = __toESM(require("chalk"));
54083
54131
  init_api2();
54084
54132
  init_command_utils();
54085
54133
  init_config();
@@ -54322,41 +54370,41 @@ function resolveSelectableEnvironmentId(envInput, selectableEnvs) {
54322
54370
  return resolved.id;
54323
54371
  }
54324
54372
  function printAutomation(automation2) {
54325
- console.log(import_chalk26.default.white(` ${automation2.name}`));
54326
- console.log(import_chalk26.default.gray(` ID: ${automation2.id}`));
54327
- console.log(import_chalk26.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
54373
+ console.log(import_chalk27.default.white(` ${automation2.name}`));
54374
+ console.log(import_chalk27.default.gray(` ID: ${automation2.id}`));
54375
+ console.log(import_chalk27.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
54328
54376
  if (automation2.description) {
54329
- console.log(import_chalk26.default.gray(` Description: ${automation2.description}`));
54377
+ console.log(import_chalk27.default.gray(` Description: ${automation2.description}`));
54330
54378
  }
54331
- console.log(import_chalk26.default.gray(` Enabled: ${automation2.enabled ? import_chalk26.default.green("yes") : import_chalk26.default.red("no")}`));
54379
+ console.log(import_chalk27.default.gray(` Enabled: ${automation2.enabled ? import_chalk27.default.green("yes") : import_chalk27.default.red("no")}`));
54332
54380
  if (automation2.auto_paused_at) {
54333
- console.log(import_chalk26.default.yellow(` ${truncate2(formatAutoPause(automation2), 120)}`));
54381
+ console.log(import_chalk27.default.yellow(` ${truncate2(formatAutoPause(automation2), 120)}`));
54334
54382
  }
54335
54383
  if (automation2.triggers.length > 0) {
54336
- console.log(import_chalk26.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54384
+ console.log(import_chalk27.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54337
54385
  }
54338
54386
  if (automation2.github_check_names.length > 0) {
54339
- console.log(import_chalk26.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
54387
+ console.log(import_chalk27.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
54340
54388
  }
54341
- console.log(import_chalk26.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
54389
+ console.log(import_chalk27.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
54342
54390
  if (automation2.cron_next_fire_at) {
54343
- console.log(import_chalk26.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)}`));
54391
+ console.log(import_chalk27.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)}`));
54344
54392
  }
54345
- console.log(import_chalk26.default.gray(` Runs: ${formatRuns(automation2)}`));
54346
- console.log(import_chalk26.default.gray(` Workspace: ${formatDestination(automation2)}`));
54347
- if (automation2.background) console.log(import_chalk26.default.gray(" List: background"));
54393
+ console.log(import_chalk27.default.gray(` Runs: ${formatRuns(automation2)}`));
54394
+ console.log(import_chalk27.default.gray(` Workspace: ${formatDestination(automation2)}`));
54395
+ if (automation2.background) console.log(import_chalk27.default.gray(" List: background"));
54348
54396
  if (automation2.workspace_lifecycle_policy && automation2.workspace_lifecycle_policy !== "default") {
54349
- console.log(import_chalk26.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
54397
+ console.log(import_chalk27.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
54350
54398
  }
54351
54399
  if (automation2.agent_provider || automation2.model || automation2.thinking_level) {
54352
- console.log(import_chalk26.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
54400
+ console.log(import_chalk27.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
54353
54401
  }
54354
54402
  if (automation2.plan_mode || automation2.goal_mode || automation2.fast_mode) {
54355
- console.log(import_chalk26.default.gray(` Modes: ${formatModeSummary(automation2)}`));
54403
+ console.log(import_chalk27.default.gray(` Modes: ${formatModeSummary(automation2)}`));
54356
54404
  }
54357
- console.log(import_chalk26.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk26.default.green("managed") : "read-only"}`));
54358
- console.log(import_chalk26.default.gray(` Created: ${formatDate(automation2.created_at)}`));
54359
- console.log(import_chalk26.default.gray(` Updated: ${formatDate(automation2.updated_at)}`));
54405
+ console.log(import_chalk27.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk27.default.green("managed") : "read-only"}`));
54406
+ console.log(import_chalk27.default.gray(` Created: ${formatDate(automation2.created_at)}`));
54407
+ console.log(import_chalk27.default.gray(` Updated: ${formatDate(automation2.updated_at)}`));
54360
54408
  console.log();
54361
54409
  }
54362
54410
  async function resolveCredentialsMember(value) {
@@ -54387,10 +54435,10 @@ async function automationListCommand(options) {
54387
54435
  );
54388
54436
  output2(response, (response2) => {
54389
54437
  if (response2.automations.length === 0) {
54390
- console.log(import_chalk26.default.yellow("\nNo automations found.\n"));
54438
+ console.log(import_chalk27.default.yellow("\nNo automations found.\n"));
54391
54439
  return;
54392
54440
  }
54393
- console.log(import_chalk26.default.green(`
54441
+ console.log(import_chalk27.default.green(`
54394
54442
  Automations (Page ${response2.page} of ${response2.totalPages}, Total: ${response2.total}):
54395
54443
  `));
54396
54444
  for (const automation2 of response2.automations) {
@@ -54402,49 +54450,49 @@ async function automationGetCommand(id) {
54402
54450
  ensureOrgApiAuthenticated();
54403
54451
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`);
54404
54452
  output2(response.automation, (automation2) => {
54405
- console.log(import_chalk26.default.green(`
54453
+ console.log(import_chalk27.default.green(`
54406
54454
  Automation: ${automation2.name}
54407
54455
  `));
54408
- console.log(import_chalk26.default.gray(` ID: ${automation2.id}`));
54456
+ console.log(import_chalk27.default.gray(` ID: ${automation2.id}`));
54409
54457
  if (automation2.description) {
54410
- console.log(import_chalk26.default.gray(` Description: ${automation2.description}`));
54458
+ console.log(import_chalk27.default.gray(` Description: ${automation2.description}`));
54411
54459
  }
54412
- console.log(import_chalk26.default.gray(` Enabled: ${automation2.enabled ? import_chalk26.default.green("yes") : import_chalk26.default.red("no")}`));
54460
+ console.log(import_chalk27.default.gray(` Enabled: ${automation2.enabled ? import_chalk27.default.green("yes") : import_chalk27.default.red("no")}`));
54413
54461
  if (automation2.auto_paused_at) {
54414
- console.log(import_chalk26.default.yellow(` ${formatAutoPause(automation2)}`));
54462
+ console.log(import_chalk27.default.yellow(` ${formatAutoPause(automation2)}`));
54415
54463
  }
54416
54464
  if (automation2.triggers.length > 0) {
54417
- console.log(import_chalk26.default.gray(` Triggers:`));
54465
+ console.log(import_chalk27.default.gray(` Triggers:`));
54418
54466
  for (const trigger of automation2.triggers) {
54419
- console.log(import_chalk26.default.gray(` - ${formatTrigger(trigger)}`));
54467
+ console.log(import_chalk27.default.gray(` - ${formatTrigger(trigger)}`));
54420
54468
  }
54421
54469
  }
54422
54470
  if (automation2.github_check_names.length > 0) {
54423
- console.log(import_chalk26.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
54471
+ console.log(import_chalk27.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
54424
54472
  }
54425
- console.log(import_chalk26.default.gray(` Prompt: ${automation2.prompt}`));
54426
- console.log(import_chalk26.default.gray(` Environment: ${automation2.environment_id}`));
54473
+ console.log(import_chalk27.default.gray(` Prompt: ${automation2.prompt}`));
54474
+ console.log(import_chalk27.default.gray(` Environment: ${automation2.environment_id}`));
54427
54475
  if (automation2.cron_next_fire_at) {
54428
- console.log(import_chalk26.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)}`));
54476
+ console.log(import_chalk27.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)}`));
54429
54477
  }
54430
- console.log(import_chalk26.default.gray(` Runs: ${formatRuns(automation2)}`));
54431
- console.log(import_chalk26.default.gray(` Workspace: ${formatDestination(automation2)}`));
54432
- console.log(import_chalk26.default.gray(` List: ${automation2.background ? "background" : "main"}`));
54433
- if (automation2.credential_user_id) console.log(import_chalk26.default.gray(` Credentials: member ${automation2.credential_user_id}, then the organization's`));
54434
- console.log(import_chalk26.default.gray(` Size: ${automation2.workspace_size ?? DEFAULT_WORKSPACE_SIZE}${automation2.target_workspace_id ? " (new workspaces only; runs reuse the pinned workspace)" : ""}`));
54478
+ console.log(import_chalk27.default.gray(` Runs: ${formatRuns(automation2)}`));
54479
+ console.log(import_chalk27.default.gray(` Workspace: ${formatDestination(automation2)}`));
54480
+ console.log(import_chalk27.default.gray(` List: ${automation2.background ? "background" : "main"}`));
54481
+ if (automation2.credential_user_id) console.log(import_chalk27.default.gray(` Credentials: member ${automation2.credential_user_id}, then the organization's`));
54482
+ console.log(import_chalk27.default.gray(` Size: ${automation2.workspace_size ?? DEFAULT_WORKSPACE_SIZE}${automation2.target_workspace_id ? " (new workspaces only; runs reuse the pinned workspace)" : ""}`));
54435
54483
  if (automation2.workspace_lifecycle_policy) {
54436
- console.log(import_chalk26.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
54484
+ console.log(import_chalk27.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
54437
54485
  }
54438
54486
  if (automation2.workspace_auto_stop_minutes) {
54439
- console.log(import_chalk26.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
54440
- }
54441
- console.log(import_chalk26.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
54442
- console.log(import_chalk26.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
54443
- console.log(import_chalk26.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
54444
- console.log(import_chalk26.default.gray(` Modes: ${formatModeSummary(automation2)}`));
54445
- console.log(import_chalk26.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
54446
- console.log(import_chalk26.default.gray(` Created: ${formatDate(automation2.created_at)}`));
54447
- console.log(import_chalk26.default.gray(` Updated: ${formatDate(automation2.updated_at)}`));
54487
+ console.log(import_chalk27.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
54488
+ }
54489
+ console.log(import_chalk27.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
54490
+ console.log(import_chalk27.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
54491
+ console.log(import_chalk27.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
54492
+ console.log(import_chalk27.default.gray(` Modes: ${formatModeSummary(automation2)}`));
54493
+ console.log(import_chalk27.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
54494
+ console.log(import_chalk27.default.gray(` Created: ${formatDate(automation2.created_at)}`));
54495
+ console.log(import_chalk27.default.gray(` Updated: ${formatDate(automation2.updated_at)}`));
54448
54496
  console.log();
54449
54497
  });
54450
54498
  }
@@ -54616,7 +54664,7 @@ async function automationCreateCommand(name, options) {
54616
54664
  });
54617
54665
  const answer = response2.name;
54618
54666
  if (!answer) {
54619
- console.log(import_chalk26.default.yellow("\nCancelled."));
54667
+ console.log(import_chalk27.default.yellow("\nCancelled."));
54620
54668
  return;
54621
54669
  }
54622
54670
  automationName = answer;
@@ -54631,7 +54679,7 @@ async function automationCreateCommand(name, options) {
54631
54679
  });
54632
54680
  const answer = response2.prompt;
54633
54681
  if (!answer) {
54634
- console.log(import_chalk26.default.yellow("\nCancelled."));
54682
+ console.log(import_chalk27.default.yellow("\nCancelled."));
54635
54683
  return;
54636
54684
  }
54637
54685
  automationPrompt = answer;
@@ -54653,7 +54701,7 @@ async function automationCreateCommand(name, options) {
54653
54701
  }))
54654
54702
  });
54655
54703
  if (!envResponse2.env) {
54656
- console.log(import_chalk26.default.yellow("\nCancelled."));
54704
+ console.log(import_chalk27.default.yellow("\nCancelled."));
54657
54705
  return;
54658
54706
  }
54659
54707
  selectedEnvironmentId = envResponse2.env;
@@ -54695,25 +54743,25 @@ async function automationCreateCommand(name, options) {
54695
54743
  ...options.fastMode ? { fast_mode: true } : {},
54696
54744
  ...agentSelection
54697
54745
  };
54698
- console.log(import_chalk26.default.gray("\nCreating automation..."));
54746
+ console.log(import_chalk27.default.gray("\nCreating automation..."));
54699
54747
  const response = await orgAuthenticatedFetch("/v1/automations", {
54700
54748
  method: "POST",
54701
54749
  body
54702
54750
  });
54703
54751
  output2(response.automation, (automation2) => {
54704
- console.log(import_chalk26.default.green(`
54752
+ console.log(import_chalk27.default.green(`
54705
54753
  Created automation: ${automation2.name}`));
54706
- console.log(import_chalk26.default.gray(` ID: ${automation2.id}`));
54707
- console.log(import_chalk26.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
54754
+ console.log(import_chalk27.default.gray(` ID: ${automation2.id}`));
54755
+ console.log(import_chalk27.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
54708
54756
  if (automation2.triggers.length > 0) {
54709
- console.log(import_chalk26.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54757
+ console.log(import_chalk27.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54710
54758
  }
54711
54759
  if (automation2.cron_next_fire_at) {
54712
- console.log(import_chalk26.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)} (${automation2.cron_next_fire_at})`));
54760
+ console.log(import_chalk27.default.gray(` Next Run: ${formatDate(automation2.cron_next_fire_at)} (${automation2.cron_next_fire_at})`));
54713
54761
  }
54714
- console.log(import_chalk26.default.gray(` Runs: ${formatRuns(automation2)}`));
54715
- console.log(import_chalk26.default.gray(` Workspace: ${formatDestination(automation2)}`));
54716
- console.log(import_chalk26.default.gray(` List: ${automation2.background ? "background" : "main"}`));
54762
+ console.log(import_chalk27.default.gray(` Runs: ${formatRuns(automation2)}`));
54763
+ console.log(import_chalk27.default.gray(` Workspace: ${formatDestination(automation2)}`));
54764
+ console.log(import_chalk27.default.gray(` List: ${automation2.background ? "background" : "main"}`));
54717
54765
  console.log();
54718
54766
  });
54719
54767
  }
@@ -54870,21 +54918,21 @@ async function automationEditCommand(id, options) {
54870
54918
  Object.assign(body, agentSelection);
54871
54919
  }
54872
54920
  if (Object.keys(body).length === 0) {
54873
- output2(existing.automation, () => console.log(import_chalk26.default.yellow("\nNo changes made.\n")));
54921
+ output2(existing.automation, () => console.log(import_chalk27.default.yellow("\nNo changes made.\n")));
54874
54922
  return;
54875
54923
  }
54876
- console.log(import_chalk26.default.gray("\nUpdating automation..."));
54924
+ console.log(import_chalk27.default.gray("\nUpdating automation..."));
54877
54925
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`, {
54878
54926
  method: "PATCH",
54879
54927
  body
54880
54928
  });
54881
54929
  output2(response.automation, (automation2) => {
54882
- console.log(import_chalk26.default.green(`
54930
+ console.log(import_chalk27.default.green(`
54883
54931
  Updated automation: ${automation2.name}`));
54884
- console.log(import_chalk26.default.gray(` ID: ${automation2.id}`));
54885
- console.log(import_chalk26.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
54932
+ console.log(import_chalk27.default.gray(` ID: ${automation2.id}`));
54933
+ console.log(import_chalk27.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
54886
54934
  if (automation2.triggers.length > 0) {
54887
- console.log(import_chalk26.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54935
+ console.log(import_chalk27.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
54888
54936
  }
54889
54937
  console.log();
54890
54938
  });
@@ -54896,7 +54944,7 @@ async function automationRunCommand(id) {
54896
54944
  if (!hasCronTrigger(automation2.triggers)) {
54897
54945
  throw new Error(`Manual run is only allowed for automations with a cron trigger. This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`);
54898
54946
  }
54899
- console.log(import_chalk26.default.gray(`
54947
+ console.log(import_chalk27.default.gray(`
54900
54948
  Triggering automation "${automation2.name}"...`));
54901
54949
  const response = await orgAuthenticatedFetch(
54902
54950
  `/v1/automations/${id}/trigger`,
@@ -54907,11 +54955,11 @@ Triggering automation "${automation2.name}"...`));
54907
54955
  );
54908
54956
  if (!response.execution_id) throw new Error("Automation trigger returned no execution ID. The automation may not have started.");
54909
54957
  output2(response, (response2) => {
54910
- console.log(import_chalk26.default.green(`
54958
+ console.log(import_chalk27.default.green(`
54911
54959
  Automation triggered successfully.`));
54912
- console.log(import_chalk26.default.gray(` Execution ID: ${response2.execution_id}`));
54960
+ console.log(import_chalk27.default.gray(` Execution ID: ${response2.execution_id}`));
54913
54961
  if (response2.workspace_id) {
54914
- console.log(import_chalk26.default.gray(` Workspace ID: ${response2.workspace_id}`));
54962
+ console.log(import_chalk27.default.gray(` Workspace ID: ${response2.workspace_id}`));
54915
54963
  }
54916
54964
  console.log();
54917
54965
  });
@@ -54945,9 +54993,9 @@ async function automationCheckCommand(checkRunId, options) {
54945
54993
  `/v1/automations/checks/${id}`,
54946
54994
  { method: "POST", body }
54947
54995
  );
54948
- output2(response, (response2) => console.log(response2.reported ? import_chalk26.default.green(`
54996
+ output2(response, (response2) => console.log(response2.reported ? import_chalk27.default.green(`
54949
54997
  Reported ${conclusion} for "${response2.name}".
54950
- `) : import_chalk26.default.yellow(`
54998
+ `) : import_chalk27.default.yellow(`
54951
54999
  Skipped "${response2.name}" \u2014 a newer run of this automation owns it and will report the verdict.
54952
55000
  `)));
54953
55001
  }
@@ -54963,7 +55011,7 @@ async function automationExecutionsCommand(id, options) {
54963
55011
  for (const execution of response2.executions) {
54964
55012
  console.log(`${execution.id} ${execution.status} ${formatDate(execution.triggered_at)} ${execution.workspace_id ?? "-"}${execution.error ? ` ${execution.error}` : ""}`);
54965
55013
  }
54966
- console.log(import_chalk26.default.gray(`Page ${response2.page} of ${response2.totalPages} (${response2.total} runs)`));
55014
+ console.log(import_chalk27.default.gray(`Page ${response2.page} of ${response2.totalPages} (${response2.total} runs)`));
54967
55015
  });
54968
55016
  }
54969
55017
  async function automationRetryCommand(id, executionId) {
@@ -54971,13 +55019,13 @@ async function automationRetryCommand(id, executionId) {
54971
55019
  `/v1/automations/${id}/executions/${executionId}/retry`,
54972
55020
  { method: "POST" }
54973
55021
  );
54974
- output2(response, (response2) => console.log(import_chalk26.default.green(`Retried as execution ${response2.execution_id}${response2.workspace_id ? ` in workspace ${response2.workspace_id}` : ""}`)));
55022
+ output2(response, (response2) => console.log(import_chalk27.default.green(`Retried as execution ${response2.execution_id}${response2.workspace_id ? ` in workspace ${response2.workspace_id}` : ""}`)));
54975
55023
  }
54976
- var import_chalk26, DURATION_UNIT_MS;
55024
+ var import_chalk27, DURATION_UNIT_MS;
54977
55025
  var init_automation = __esm({
54978
55026
  "src/commands/automation.ts"() {
54979
55027
  "use strict";
54980
- import_chalk26 = __toESM(require("chalk"));
55028
+ import_chalk27 = __toESM(require("chalk"));
54981
55029
  init_output();
54982
55030
  init_api2();
54983
55031
  init_config();
@@ -55096,9 +55144,9 @@ async function previewListCommand(workspaceId) {
55096
55144
  `/v1/replica/${workspaceId}/previews`
55097
55145
  );
55098
55146
  output2(result, ({ previews }) => {
55099
- if (previews.length === 0) console.log(import_chalk27.default.dim("No active previews"));
55147
+ if (previews.length === 0) console.log(import_chalk28.default.dim("No active previews"));
55100
55148
  for (const preview2 of previews) {
55101
- console.log(` ${import_chalk27.default.cyan(String(preview2.port))} \u2192 ${import_chalk27.default.underline(preview2.publicUrl)}`);
55149
+ console.log(` ${import_chalk28.default.cyan(String(preview2.port))} \u2192 ${import_chalk28.default.underline(preview2.publicUrl)}`);
55102
55150
  }
55103
55151
  });
55104
55152
  }
@@ -55112,7 +55160,7 @@ async function previewAddCommand(workspaceId, options) {
55112
55160
  body: { port: portNum, authenticated: options.authenticated ?? false }
55113
55161
  }
55114
55162
  );
55115
- output2(result, ({ preview: preview2 }) => console.log(import_chalk27.default.green(`Preview created: ${preview2.publicUrl}`)));
55163
+ output2(result, ({ preview: preview2 }) => console.log(import_chalk28.default.green(`Preview created: ${preview2.publicUrl}`)));
55116
55164
  }
55117
55165
  async function previewDeleteCommand(port) {
55118
55166
  const portNum = parsePreviewPort(port);
@@ -55127,11 +55175,11 @@ async function previewRemoveCommand(workspaceId, options) {
55127
55175
  );
55128
55176
  outputSuccess(`Preview deleted on port ${portNum}`);
55129
55177
  }
55130
- var import_chalk27, parsePreviewPort;
55178
+ var import_chalk28, parsePreviewPort;
55131
55179
  var init_preview = __esm({
55132
55180
  "src/commands/preview.ts"() {
55133
55181
  "use strict";
55134
- import_chalk27 = __toESM(require("chalk"));
55182
+ import_chalk28 = __toESM(require("chalk"));
55135
55183
  init_config();
55136
55184
  init_agent_api();
55137
55185
  init_api2();
@@ -55791,10 +55839,10 @@ function parseEnv(values) {
55791
55839
  return values?.length ? parseKeyValuePairs(values) : void 0;
55792
55840
  }
55793
55841
  function describe3(sandbox) {
55794
- console.log(`${import_chalk28.default.bold(sandbox.id)} ${sandbox.status} ${sandbox.gpu ?? "no GPU"} ${sandbox.image}`);
55795
- console.log(import_chalk28.default.gray(` expires ${new Date(sandbox.expiresAt).toLocaleString()}`));
55842
+ console.log(`${import_chalk29.default.bold(sandbox.id)} ${sandbox.status} ${sandbox.gpu ?? "no GPU"} ${sandbox.image}`);
55843
+ console.log(import_chalk29.default.gray(` expires ${new Date(sandbox.expiresAt).toLocaleString()}`));
55796
55844
  for (const tunnel of sandbox.tunnels) console.log(` port ${tunnel.port}: ${tunnel.url}`);
55797
- if (sandbox.error) console.log(import_chalk28.default.red(` ${sandbox.error}`));
55845
+ if (sandbox.error) console.log(import_chalk29.default.red(` ${sandbox.error}`));
55798
55846
  }
55799
55847
  async function resolveSandboxId(options) {
55800
55848
  if (options.sandbox) return options.sandbox;
@@ -55815,7 +55863,7 @@ async function createSandbox(options) {
55815
55863
  };
55816
55864
  let { sandbox } = await agentFetch(BASE, { method: "POST", body: request });
55817
55865
  if (options.wait === false) return sandbox;
55818
- process.stderr.write(import_chalk28.default.gray(`Starting ${sandbox.gpu} sandbox ${sandbox.id} (a new image can take a few minutes to pull)...
55866
+ process.stderr.write(import_chalk29.default.gray(`Starting ${sandbox.gpu} sandbox ${sandbox.id} (a new image can take a few minutes to pull)...
55819
55867
  `));
55820
55868
  const deadline = Date.now() + CREATE_WAIT_TIMEOUT_MS;
55821
55869
  while (sandbox.status === "creating") {
@@ -55879,8 +55927,8 @@ async function gpuExecCommand(command, options) {
55879
55927
  if (options.detach) {
55880
55928
  const { jobId } = await response.json();
55881
55929
  output2({ jobId, sandboxId }, () => {
55882
- console.log(`Started job ${import_chalk28.default.bold(jobId)} in ${sandboxId}`);
55883
- console.log(import_chalk28.default.gray(`Follow it with: replicas gpu logs ${jobId} -f`));
55930
+ console.log(`Started job ${import_chalk29.default.bold(jobId)} in ${sandboxId}`);
55931
+ console.log(import_chalk29.default.gray(`Follow it with: replicas gpu logs ${jobId} -f`));
55884
55932
  });
55885
55933
  return;
55886
55934
  }
@@ -55900,13 +55948,13 @@ async function gpuLogsCommand(jobId, options) {
55900
55948
  return;
55901
55949
  }
55902
55950
  if (exitCode === null) {
55903
- process.stderr.write(import_chalk28.default.gray(`
55951
+ process.stderr.write(import_chalk29.default.gray(`
55904
55952
  Job ${jobId} is still running.
55905
55953
  `));
55906
55954
  return;
55907
55955
  }
55908
55956
  if (options.follow) process.exitCode = exitCode;
55909
- process.stderr.write(import_chalk28.default.gray(`
55957
+ process.stderr.write(import_chalk29.default.gray(`
55910
55958
  Job ${jobId} exited with code ${exitCode}.
55911
55959
  `));
55912
55960
  }
@@ -56014,7 +56062,7 @@ async function gpuRunCommand(command, options) {
56014
56062
  const { env, ...createOptions } = options;
56015
56063
  const sandbox = await createSandbox({ ...createOptions, wait: true });
56016
56064
  try {
56017
- process.stderr.write(import_chalk28.default.gray(`Copying ${process.cwd()} to ${COMPUTE_SANDBOX_WORKDIR}...
56065
+ process.stderr.write(import_chalk29.default.gray(`Copying ${process.cwd()} to ${COMPUTE_SANDBOX_WORKDIR}...
56018
56066
  `));
56019
56067
  await push(sandbox.id, ".", COMPUTE_SANDBOX_WORKDIR);
56020
56068
  const exitCode = await streamOutput(await exec(sandbox.id, command.join(" "), { env }));
@@ -56025,16 +56073,16 @@ async function gpuRunCommand(command, options) {
56025
56073
  if (isJsonMode()) output2({ sandboxId: sandbox.id, exitCode }, () => {
56026
56074
  });
56027
56075
  } finally {
56028
- if (options.keep) process.stderr.write(import_chalk28.default.gray(`Kept GPU sandbox ${sandbox.id} running.
56076
+ if (options.keep) process.stderr.write(import_chalk29.default.gray(`Kept GPU sandbox ${sandbox.id} running.
56029
56077
  `));
56030
56078
  else await agentRequest(`${BASE}/${sandbox.id}`, { method: "DELETE" });
56031
56079
  }
56032
56080
  }
56033
- var import_chalk28, import_node_child_process2, import_node_crypto2, import_node_fs2, import_node_os2, import_node_path2, import_node_stream, import_promises, BASE, CREATE_POLL_INTERVAL_MS, CREATE_WAIT_TIMEOUT_MS;
56081
+ var import_chalk29, import_node_child_process2, import_node_crypto2, import_node_fs2, import_node_os2, import_node_path2, import_node_stream, import_promises, BASE, CREATE_POLL_INTERVAL_MS, CREATE_WAIT_TIMEOUT_MS;
56034
56082
  var init_gpu2 = __esm({
56035
56083
  "src/commands/gpu.ts"() {
56036
56084
  "use strict";
56037
- import_chalk28 = __toESM(require("chalk"));
56085
+ import_chalk29 = __toESM(require("chalk"));
56038
56086
  import_node_child_process2 = require("child_process");
56039
56087
  import_node_crypto2 = require("crypto");
56040
56088
  import_node_fs2 = require("fs");
@@ -56066,16 +56114,16 @@ function printSource({ source }) {
56066
56114
  console.log(`Managed variables: ${source.managed.variables.join(", ") || "(none)"}`);
56067
56115
  console.log(`Managed MCPs: ${source.managed.mcps.join(", ") || "(none)"}`);
56068
56116
  if (source.required_secrets.length) console.log(`Required secrets: ${source.required_secrets.join(", ")}`);
56069
- if (source.pending_rebuild) console.log(import_chalk29.default.yellow("Configuration saved; environment rebuild pending."));
56070
- if (source.last_error) console.log(import_chalk29.default.red(source.last_error));
56117
+ if (source.pending_rebuild) console.log(import_chalk30.default.yellow("Configuration saved; environment rebuild pending."));
56118
+ if (source.last_error) console.log(import_chalk30.default.red(source.last_error));
56071
56119
  }
56072
56120
  function printPreview({ preview: preview2 }) {
56073
56121
  console.log(preview2.kind === "file" ? `${preview2.filename} @ ${preview2.file_sha}` : `${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
56074
56122
  if (preview2.source_url) console.log(preview2.source_url);
56075
56123
  if (!preview2.changes.length) console.log("No setting changes. Applying records this configuration.");
56076
56124
  for (const change of preview2.changes) console.log(` ${change.operation}: ${change.kind} ${change.key}`);
56077
- if (preview2.missing_secrets.length) console.log(import_chalk29.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
56078
- for (const blocker of preview2.blockers) console.log(import_chalk29.default.red(` Cannot apply: ${blocker}`));
56125
+ if (preview2.missing_secrets.length) console.log(import_chalk30.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
56126
+ for (const blocker of preview2.blockers) console.log(import_chalk30.default.red(` Cannot apply: ${blocker}`));
56079
56127
  }
56080
56128
  async function sourceInput2(options) {
56081
56129
  if (options.file && options.repository) throw new Error("Choose either --file or --repository");
@@ -56146,11 +56194,11 @@ async function environmentConfigDisconnectCommand(environment2, options) {
56146
56194
  console.log("Configuration source disconnected. Current settings preserved.");
56147
56195
  });
56148
56196
  }
56149
- var import_chalk29, import_promises2, import_node_path3;
56197
+ var import_chalk30, import_promises2, import_node_path3;
56150
56198
  var init_environment_config2 = __esm({
56151
56199
  "src/commands/environment-config.ts"() {
56152
56200
  "use strict";
56153
- import_chalk29 = __toESM(require("chalk"));
56201
+ import_chalk30 = __toESM(require("chalk"));
56154
56202
  import_promises2 = require("fs/promises");
56155
56203
  import_node_path3 = require("path");
56156
56204
  init_src();
@@ -56205,12 +56253,12 @@ async function skillsSuggestCommand(file2, options) {
56205
56253
  async function skillsListCommand() {
56206
56254
  output2(await orgAuthenticatedFetch("/v1/learned-skills"), ({ skills: skills2, suggestions }) => {
56207
56255
  for (const skill of skills2) console.log(`${skill.id} ${skill.name} ${skill.title}`);
56208
- if (suggestions.length > 0) console.log(import_chalk30.default.gray(`${suggestions.length} pending suggestion(s) to review in the dashboard.`));
56256
+ if (suggestions.length > 0) console.log(import_chalk31.default.gray(`${suggestions.length} pending suggestion(s) to review in the dashboard.`));
56209
56257
  });
56210
56258
  }
56211
56259
  async function skillsCreateCommand(file2, options) {
56212
56260
  const body = { content: (0, import_node_fs4.readFileSync)(file2, "utf-8"), title: options.title };
56213
- output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body }), ({ id, name }) => console.log(import_chalk30.default.green(`Saved learning '${name}' (${id})`)));
56261
+ output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body }), ({ id, name }) => console.log(import_chalk31.default.green(`Saved learning '${name}' (${id})`)));
56214
56262
  }
56215
56263
  async function skillsUpdateCommand(id, options) {
56216
56264
  const { skills: skills2 } = await orgAuthenticatedFetch("/v1/learned-skills");
@@ -56220,18 +56268,18 @@ async function skillsUpdateCommand(id, options) {
56220
56268
  title: options.title ?? existing.title,
56221
56269
  content: options.file ? (0, import_node_fs4.readFileSync)(options.file, "utf-8") : existing.content
56222
56270
  };
56223
- output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body }), ({ name }) => console.log(import_chalk30.default.green(`Updated learning '${name}'`)));
56271
+ output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body }), ({ name }) => console.log(import_chalk31.default.green(`Updated learning '${name}'`)));
56224
56272
  }
56225
56273
  async function skillsDeleteCommand(id) {
56226
56274
  await orgAuthenticatedFetch(`/v1/learned-skills/${id}`, { method: "DELETE" });
56227
56275
  outputSuccess(`Deleted learning ${id}`);
56228
56276
  }
56229
- var import_node_fs4, import_chalk30;
56277
+ var import_node_fs4, import_chalk31;
56230
56278
  var init_skills = __esm({
56231
56279
  "src/commands/skills.ts"() {
56232
56280
  "use strict";
56233
56281
  import_node_fs4 = require("fs");
56234
- import_chalk30 = __toESM(require("chalk"));
56282
+ import_chalk31 = __toESM(require("chalk"));
56235
56283
  init_agent_api();
56236
56284
  init_api2();
56237
56285
  init_monolith_url();
@@ -56257,10 +56305,10 @@ async function attachThread(request) {
56257
56305
  body: request
56258
56306
  });
56259
56307
  output2(response, ({ thread, workspace }) => {
56260
- console.log(import_chalk31.default.green("Slack thread attached."));
56261
- console.log(import_chalk31.default.gray(` Channel: ${thread.channel_id}`));
56262
- console.log(import_chalk31.default.gray(` Thread: ${thread.thread_ts}`));
56263
- console.log(import_chalk31.default.gray(` Workspace: ${workspace.name} (${workspace.id})`));
56308
+ console.log(import_chalk32.default.green("Slack thread attached."));
56309
+ console.log(import_chalk32.default.gray(` Channel: ${thread.channel_id}`));
56310
+ console.log(import_chalk32.default.gray(` Thread: ${thread.thread_ts}`));
56311
+ console.log(import_chalk32.default.gray(` Workspace: ${workspace.name} (${workspace.id})`));
56264
56312
  });
56265
56313
  }
56266
56314
  async function slackThreadAttachCommand(options) {
@@ -56288,11 +56336,11 @@ async function slackThreadSwitchCommand(workspace, options) {
56288
56336
  workspace_id: workspaceId
56289
56337
  });
56290
56338
  }
56291
- var import_chalk31;
56339
+ var import_chalk32;
56292
56340
  var init_slack4 = __esm({
56293
56341
  "src/commands/slack.ts"() {
56294
56342
  "use strict";
56295
- import_chalk31 = __toESM(require("chalk"));
56343
+ import_chalk32 = __toESM(require("chalk"));
56296
56344
  init_api2();
56297
56345
  init_config();
56298
56346
  init_output();
@@ -56447,7 +56495,7 @@ async function serviceListCommand() {
56447
56495
  return;
56448
56496
  }
56449
56497
  for (const service of services) {
56450
- const status = service.running ? import_chalk32.default.green("running") : import_chalk32.default.red("stopped");
56498
+ const status = service.running ? import_chalk33.default.green("running") : import_chalk33.default.red("stopped");
56451
56499
  console.log(`${service.name} ${status} pid ${service.pid} started ${service.startedAt}`);
56452
56500
  console.log(` command: ${service.command} (cwd: ${service.cwd})`);
56453
56501
  console.log(` logs: ${service.logFile}`);
@@ -56467,11 +56515,11 @@ async function serviceLogsCommand(name, options) {
56467
56515
  console.log(logs || "(no log output yet)");
56468
56516
  });
56469
56517
  }
56470
- var import_chalk32, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path5, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
56518
+ var import_chalk33, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path5, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
56471
56519
  var init_service = __esm({
56472
56520
  "src/commands/service.ts"() {
56473
56521
  "use strict";
56474
- import_chalk32 = __toESM(require("chalk"));
56522
+ import_chalk33 = __toESM(require("chalk"));
56475
56523
  import_node_child_process3 = require("child_process");
56476
56524
  import_node_fs5 = require("fs");
56477
56525
  import_node_os3 = require("os");
@@ -56528,7 +56576,7 @@ async function deviceConnectCommand() {
56528
56576
  stream.destroy();
56529
56577
  };
56530
56578
  sshd.once("error", (error62) => {
56531
- console.log(import_chalk33.default.yellow(`A workspace couldn't reach SSH on port ${port} here (${error62.message}). ${REMOTE_LOGIN_HINT}`));
56579
+ console.log(import_chalk34.default.yellow(`A workspace couldn't reach SSH on port ${port} here (${error62.message}). ${REMOTE_LOGIN_HINT}`));
56532
56580
  });
56533
56581
  sshd.on("error", close).on("close", close);
56534
56582
  stream.on("error", close).on("close", close);
@@ -56572,16 +56620,16 @@ async function deviceConnectCommand() {
56572
56620
  }
56573
56621
  }
56574
56622
  const next = problem ?? `\u2713 ${device?.name}: ready for ${waiting.size} ${waiting.size === 1 ? "workspace" : "workspaces"}, forwarding to SSH on port ${port}`;
56575
- if (next !== summary) console.log(problem ? import_chalk33.default.yellow(next) : import_chalk33.default.green(next));
56623
+ if (next !== summary) console.log(problem ? import_chalk34.default.yellow(next) : import_chalk34.default.green(next));
56576
56624
  summary = next;
56577
56625
  await (0, import_promises3.setTimeout)(POLL_INTERVAL_MS);
56578
56626
  }
56579
56627
  }
56580
- var import_chalk33, import_node_child_process4, import_node_net, import_promises3, import_node_util, import_ws, POLL_INTERVAL_MS, HEARTBEAT_MS, MAX_RETRY_DELAY_MS, REMOTE_LOGIN_HINT;
56628
+ var import_chalk34, import_node_child_process4, import_node_net, import_promises3, import_node_util, import_ws, POLL_INTERVAL_MS, HEARTBEAT_MS, MAX_RETRY_DELAY_MS, REMOTE_LOGIN_HINT;
56581
56629
  var init_device = __esm({
56582
56630
  "src/commands/device.ts"() {
56583
56631
  "use strict";
56584
- import_chalk33 = __toESM(require("chalk"));
56632
+ import_chalk34 = __toESM(require("chalk"));
56585
56633
  import_node_child_process4 = require("child_process");
56586
56634
  import_node_net = require("net");
56587
56635
  import_promises3 = require("timers/promises");
@@ -56639,8 +56687,8 @@ async function localControlRequestCommand(options) {
56639
56687
  await orgAuthenticatedFetch("/v1/local-control-request", { method: "DELETE" });
56640
56688
  output2({ status: "connected", computers: computers2 }, () => {
56641
56689
  console.log(`
56642
- ${import_chalk34.default.green("Connected:")} ${computers2.join(", ")}`);
56643
- console.log(import_chalk34.default.gray(` Run commands there with: ssh ${computers2[0]} '<command>'
56690
+ ${import_chalk35.default.green("Connected:")} ${computers2.join(", ")}`);
56691
+ console.log(import_chalk35.default.gray(` Run commands there with: ssh ${computers2[0]} '<command>'
56644
56692
  `));
56645
56693
  });
56646
56694
  };
@@ -56668,10 +56716,10 @@ async function localControlRequestCommand(options) {
56668
56716
  }
56669
56717
  output2({ status: pending ? "pending" : "declined", computers: [], url: created.url }, () => {
56670
56718
  if (!pending) {
56671
- console.log(import_chalk34.default.yellow("\n The user declined. Continue without their computer, or ask how they want to proceed.\n"));
56719
+ console.log(import_chalk35.default.yellow("\n The user declined. Continue without their computer, or ask how they want to proceed.\n"));
56672
56720
  return;
56673
56721
  }
56674
- console.log(import_chalk34.default.gray(options.wait === false ? `
56722
+ console.log(import_chalk35.default.gray(options.wait === false ? `
56675
56723
  Asked above the chat composer (${created.url}). Keep working, and run this command again when you need the computer.
56676
56724
  ` : created.wait ? `
56677
56725
  The request stays open above the chat composer (${created.url}). End your turn and say what you need the computer for. When the user answers, you get a message; run this command again then.
@@ -56681,7 +56729,7 @@ async function localControlRequestCommand(options) {
56681
56729
  `));
56682
56730
  });
56683
56731
  }
56684
- var import_child_process6, import_fs11, import_os5, import_path10, import_util10, import_chalk34, execFileAsync2;
56732
+ var import_child_process6, import_fs11, import_os5, import_path10, import_util10, import_chalk35, execFileAsync2;
56685
56733
  var init_local_control = __esm({
56686
56734
  "src/commands/local-control.ts"() {
56687
56735
  "use strict";
@@ -56690,7 +56738,7 @@ var init_local_control = __esm({
56690
56738
  import_os5 = __toESM(require("os"));
56691
56739
  import_path10 = __toESM(require("path"));
56692
56740
  import_util10 = require("util");
56693
- import_chalk34 = __toESM(require("chalk"));
56741
+ import_chalk35 = __toESM(require("chalk"));
56694
56742
  init_src();
56695
56743
  init_api2();
56696
56744
  init_command_utils();
@@ -56732,7 +56780,7 @@ function registerEnvironmentHookCommands(parent, config3) {
56732
56780
  }
56733
56781
  hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
56734
56782
  }
56735
- var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, media, environment, envConfig, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
56783
+ var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, billing, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, media, environment, envConfig, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
56736
56784
  var init_src2 = __esm({
56737
56785
  "src/index.ts"() {
56738
56786
  "use strict";
@@ -56741,6 +56789,7 @@ var init_src2 = __esm({
56741
56789
  init_login3();
56742
56790
  init_logout();
56743
56791
  init_whoami();
56792
+ init_billing2();
56744
56793
  init_identity();
56745
56794
  init_connect();
56746
56795
  init_code();
@@ -56830,6 +56879,9 @@ var init_src2 = __esm({
56830
56879
  program.command("whoami").description("Display current authenticated user").action(run(whoamiCommand));
56831
56880
  program.command("codex-auth").description("Connect your Codex credentials to Replicas (personal by default)").option("-u, --user", "Store credentials for your personal account (default)").option("-o, --org", "Share credentials with the whole organization (admins only)").option("-y, --yes", "Skip the destination confirmation prompt").action(run(codexAuthCommand));
56832
56881
  program.command("claude-auth").description("Connect your Claude Code credentials to Replicas (personal by default)").option("-u, --user", "Store credentials for your personal account (default)").option("-o, --org", "Share credentials with the whole organization (admins only)").option("-y, --yes", "Skip the destination confirmation prompt").action(run(claudeAuthCommand));
56882
+ billing = program.command("billing").description("Show the organization's balance and the limit new workspaces are checked against");
56883
+ billing.command("usage").description("Show usage cost by day and source for the current period (admins only)").option("-b, --bucket <bucket>", "day, week, or month").option("--start <date>", "Start date (ISO 8601)").option("--end <date>", "End date (ISO 8601)").action(run(billingUsageCommand));
56884
+ billing.action(run(billingCommand));
56833
56885
  org = program.command("org").description("Manage organizations");
56834
56886
  org.command("switch").description("Switch to a different organization").action(run(orgSwitchCommand));
56835
56887
  org.command("members").description("List organization members and their user IDs").action(run(orgMembersCommand));
@@ -57097,7 +57149,8 @@ ${VISUAL_PAGE_RULES}`).action(run(visualizeCommand));
57097
57149
  "share",
57098
57150
  "pr",
57099
57151
  "canvas",
57100
- "plugins"
57152
+ "plugins",
57153
+ "billing"
57101
57154
  ]);
57102
57155
  const kept = program.commands.filter((cmd) => allowed.has(cmd.name()));
57103
57156
  const cmds = program.commands;
@@ -57111,11 +57164,11 @@ ${VISUAL_PAGE_RULES}`).action(run(visualizeCommand));
57111
57164
 
57112
57165
  // src/bin.ts
57113
57166
  var import_node_child_process5 = require("child_process");
57114
- var import_chalk35 = __toESM(require("chalk"));
57167
+ var import_chalk36 = __toESM(require("chalk"));
57115
57168
  init_config();
57116
57169
  if (process.argv[2] === "computer" && isAgentMode()) {
57117
57170
  const result = (0, import_node_child_process5.spawnSync)("replicas-computer", process.argv.slice(3), { stdio: "inherit" });
57118
- if (result.error) console.error(import_chalk35.default.red(`
57171
+ if (result.error) console.error(import_chalk36.default.red(`
57119
57172
  \u2717 replicas-computer is unavailable in this workspace image
57120
57173
  `));
57121
57174
  process.exitCode = result.error ? 1 : result.status ?? 1;