replicas-cli 0.2.712 → 0.2.714

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 +610 -442
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7363,9 +7363,9 @@ var require_dist = __commonJS({
7363
7363
 
7364
7364
  // src/index.ts
7365
7365
  var import_config22 = require("dotenv/config");
7366
- var import_node_child_process2 = require("child_process");
7366
+ var import_node_child_process3 = require("child_process");
7367
7367
  var import_commander = require("commander");
7368
- var import_chalk23 = __toESM(require("chalk"));
7368
+ var import_chalk24 = __toESM(require("chalk"));
7369
7369
 
7370
7370
  // ../shared/src/urls.ts
7371
7371
  var DEFAULT_WEB_APP_URL = "https://app.replicas.dev";
@@ -24685,6 +24685,10 @@ In agent mode the CLI hides commands that don't make sense for in-workspace agen
24685
24685
  | Command | What it does |
24686
24686
  | --- | --- |
24687
24687
  | \`replicas whoami\` | Print the workspace + org identity |
24688
+ | \`replicas identity token [--audience <aud>]\` | Print the current short-lived workspace identity token for an audience |
24689
+ | \`replicas identity token --format gcp --audience <aud>\` | Supply a current token to Google's executable credential source |
24690
+ | \`replicas identity aws-credentials --role-arn <arn> [--region <region>]\` | Exchange the current token for AWS credential_process JSON (requires AWS CLI) |
24691
+ | \`replicas identity exec [--audience <aud>] -- <command>\` | Run a command with the current token and audience in its environment |
24688
24692
  | \`replicas init\` | Create a \`replicas.json\` / \`replicas.yaml\` in the current directory |
24689
24693
  | \`replicas connect <name>\` | SSH into another workspace (requires user creds \u2014 usually only useful when scripting locally) |
24690
24694
  | \`replicas repos\` | List repos connected to the org |
@@ -27435,7 +27439,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
27435
27439
  });
27436
27440
 
27437
27441
  // ../shared/src/cli-version.ts
27438
- var CLI_VERSION = "0.2.712";
27442
+ var CLI_VERSION = "0.2.714";
27439
27443
 
27440
27444
  // ../shared/src/version.ts
27441
27445
  function compareVersions(v1, v2) {
@@ -28100,6 +28104,54 @@ async function readSseStream(body, onEvent, shouldContinue = () => true) {
28100
28104
  // ../shared/src/frontmatter.ts
28101
28105
  var import_yaml2 = __toESM(require_dist());
28102
28106
 
28107
+ // ../shared/src/workspace-identity.ts
28108
+ var WORKSPACE_IDENTITY_AUDIENCE = "replicas:workspace";
28109
+ var WORKSPACE_TOKEN_TTL_SECONDS = 15 * 60;
28110
+ var WORKSPACE_TOKEN_FILE = `${SANDBOX_PATHS.REPLICAS_DIR}/credentials/tokens.json`;
28111
+ var WORKSPACE_TOKEN_ENV = {
28112
+ TOKEN: "REPLICAS_WORKSPACE_TOKEN",
28113
+ TOKEN_FILE: "REPLICAS_WORKSPACE_TOKEN_FILE",
28114
+ AUDIENCE: "REPLICAS_WORKSPACE_TOKEN_AUDIENCE",
28115
+ ISSUER: "REPLICAS_WORKSPACE_IDENTITY_ISSUER"
28116
+ };
28117
+ var workspaceTokenClaimsSchema = external_exports.object({
28118
+ iss: external_exports.string(),
28119
+ sub: external_exports.string(),
28120
+ aud: external_exports.string(),
28121
+ iat: external_exports.number().int(),
28122
+ nbf: external_exports.number().int(),
28123
+ exp: external_exports.number().int(),
28124
+ jti: external_exports.string(),
28125
+ organization_id: external_exports.string().uuid(),
28126
+ workspace_id: external_exports.string().uuid(),
28127
+ environment_id: external_exports.string().uuid(),
28128
+ creator_id: external_exports.string().uuid().nullable()
28129
+ }).passthrough();
28130
+ var workspaceTokenBundleSchema = external_exports.strictObject({
28131
+ version: external_exports.literal(1),
28132
+ issuer: external_exports.string(),
28133
+ default_audience: external_exports.string(),
28134
+ tokens: external_exports.record(
28135
+ external_exports.string(),
28136
+ external_exports.strictObject({ token: external_exports.string(), expires_at: external_exports.string() })
28137
+ )
28138
+ });
28139
+ var workloadAudienceInput = external_exports.strictObject({
28140
+ name: external_exports.string().trim().min(1).max(64),
28141
+ audience: external_exports.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces").refine((value) => value !== WORKSPACE_IDENTITY_AUDIENCE, "Reserved audience"),
28142
+ enabled: external_exports.boolean(),
28143
+ is_default: external_exports.boolean()
28144
+ });
28145
+ var mcpWorkloadAuthSchema = external_exports.strictObject({
28146
+ type: external_exports.literal("workspace_identity"),
28147
+ audience: external_exports.string().min(1)
28148
+ });
28149
+ function currentWorkspaceToken(bundle, audience = bundle.default_audience, now = Date.now()) {
28150
+ const entry = bundle.tokens[audience];
28151
+ if (!entry || Date.parse(entry.expires_at) <= now) return null;
28152
+ return entry.token;
28153
+ }
28154
+
28103
28155
  // src/lib/monolith-url.ts
28104
28156
  var MONOLITH_URL = process.env.REPLICAS_MONOLITH_URL || process.env.MONOLITH_URL || "https://api.replicas.dev";
28105
28157
 
@@ -28595,8 +28647,119 @@ async function whoamiCommand() {
28595
28647
  }
28596
28648
  }
28597
28649
 
28650
+ // src/commands/identity.ts
28651
+ var import_node_fs = require("fs");
28652
+ var import_node_child_process = require("child_process");
28653
+ var import_node_os = require("os");
28654
+ var import_node_path = require("path");
28655
+ var import_chalk5 = __toESM(require("chalk"));
28656
+ function readToken(audience) {
28657
+ const file2 = process.env[WORKSPACE_TOKEN_ENV.TOKEN_FILE] ?? WORKSPACE_TOKEN_FILE;
28658
+ let bundle;
28659
+ try {
28660
+ bundle = workspaceTokenBundleSchema.parse(JSON.parse((0, import_node_fs.readFileSync)(file2, "utf8")));
28661
+ } catch {
28662
+ return createErrorResult({ message: `No valid workspace token bundle at ${file2}. Check that workspace identity is enabled.` });
28663
+ }
28664
+ const selected = audience ?? bundle.default_audience;
28665
+ const token = currentWorkspaceToken(bundle, selected);
28666
+ const expiresAt = Date.parse(bundle.tokens[selected]?.expires_at);
28667
+ if (!token || !Number.isFinite(expiresAt)) {
28668
+ return createErrorResult({
28669
+ message: bundle.tokens[selected] ? `The workspace token for ${selected} has expired or has an invalid expiry and has not been renewed yet.` : `No workspace token is issued for audience ${selected}. Registered: ${Object.keys(bundle.tokens).join(", ")}`
28670
+ });
28671
+ }
28672
+ return createSuccessResult({ token, audience: selected, expiresAt });
28673
+ }
28674
+ function identityTokenCommand(options) {
28675
+ const result = readToken(options.audience);
28676
+ if (!result.ok) {
28677
+ if (options.format === "gcp") {
28678
+ process.stdout.write(`${JSON.stringify({ version: 1, success: false, code: "TOKEN_UNAVAILABLE", message: result.error.message })}
28679
+ `);
28680
+ } else {
28681
+ console.error(import_chalk5.default.red(result.error.message));
28682
+ }
28683
+ process.exitCode = 1;
28684
+ return;
28685
+ }
28686
+ const { token, expiresAt } = result.data;
28687
+ const output = options.format === "gcp" ? JSON.stringify({
28688
+ version: 1,
28689
+ success: true,
28690
+ token_type: "urn:ietf:params:oauth:token-type:jwt",
28691
+ id_token: token,
28692
+ expiration_time: Math.floor(expiresAt / 1e3)
28693
+ }) : token;
28694
+ process.stdout.write(`${output}
28695
+ `);
28696
+ }
28697
+ function identityExecCommand(command, options) {
28698
+ if (command.length === 0) {
28699
+ console.error(import_chalk5.default.red("Provide a command to run: replicas identity exec -- <command>"));
28700
+ process.exit(1);
28701
+ }
28702
+ const tokenResult = readToken(options.audience);
28703
+ if (!tokenResult.ok) {
28704
+ console.error(import_chalk5.default.red(tokenResult.error.message));
28705
+ process.exitCode = 1;
28706
+ return;
28707
+ }
28708
+ const { token, audience } = tokenResult.data;
28709
+ const result = (0, import_node_child_process.spawnSync)(command[0], command.slice(1), {
28710
+ stdio: "inherit",
28711
+ env: { ...process.env, [WORKSPACE_TOKEN_ENV.TOKEN]: token, [WORKSPACE_TOKEN_ENV.AUDIENCE]: audience }
28712
+ });
28713
+ process.exit(result.status ?? 1);
28714
+ }
28715
+ function identityAwsCredentialsCommand(options) {
28716
+ const result = readToken(options.audience);
28717
+ if (!result.ok) {
28718
+ console.error(import_chalk5.default.red(result.error.message));
28719
+ process.exitCode = 1;
28720
+ return;
28721
+ }
28722
+ const directory = (0, import_node_fs.mkdtempSync)((0, import_node_path.join)((0, import_node_os.tmpdir)(), "replicas-aws-identity-"));
28723
+ try {
28724
+ const file2 = (0, import_node_path.join)(directory, "request.json");
28725
+ (0, import_node_fs.writeFileSync)(file2, JSON.stringify({
28726
+ RoleArn: options.roleArn,
28727
+ RoleSessionName: options.sessionName,
28728
+ WebIdentityToken: result.data.token
28729
+ }), { mode: 384 });
28730
+ const env = {
28731
+ ...process.env,
28732
+ AWS_CONFIG_FILE: "/dev/null",
28733
+ AWS_SHARED_CREDENTIALS_FILE: "/dev/null",
28734
+ AWS_PAGER: ""
28735
+ };
28736
+ delete env.AWS_PROFILE;
28737
+ delete env.AWS_DEFAULT_PROFILE;
28738
+ const credentials = (0, import_node_child_process.spawnSync)("aws", [
28739
+ "sts",
28740
+ "assume-role-with-web-identity",
28741
+ "--cli-input-json",
28742
+ `file://${file2}`,
28743
+ "--no-sign-request",
28744
+ "--query",
28745
+ "Credentials.{Version: `1`, AccessKeyId: AccessKeyId, SecretAccessKey: SecretAccessKey, SessionToken: SessionToken, Expiration: Expiration}",
28746
+ "--output",
28747
+ "json",
28748
+ ...options.region ? ["--region", options.region] : []
28749
+ ], { env, encoding: "utf8", timeout: 3e4 });
28750
+ if (credentials.error || credentials.status !== 0) {
28751
+ console.error(credentials.error ? `AWS credential exchange failed: ${credentials.error.message}. Ensure the AWS CLI is installed.` : credentials.stderr.trim());
28752
+ process.exitCode = credentials.status || 1;
28753
+ return;
28754
+ }
28755
+ process.stdout.write(credentials.stdout);
28756
+ } finally {
28757
+ (0, import_node_fs.rmSync)(directory, { recursive: true, force: true });
28758
+ }
28759
+ }
28760
+
28598
28761
  // src/commands/connect.ts
28599
- var import_chalk6 = __toESM(require("chalk"));
28762
+ var import_chalk7 = __toESM(require("chalk"));
28600
28763
 
28601
28764
  // src/lib/ssh.ts
28602
28765
  var import_child_process = require("child_process");
@@ -28634,7 +28797,7 @@ async function connectSSH(token, host, proxyCommand, localForward) {
28634
28797
  }
28635
28798
 
28636
28799
  // src/lib/workspace-connection.ts
28637
- var import_chalk5 = __toESM(require("chalk"));
28800
+ var import_chalk6 = __toESM(require("chalk"));
28638
28801
  var import_prompts5 = __toESM(require("prompts"));
28639
28802
 
28640
28803
  // src/lib/api.ts
@@ -28736,7 +28899,7 @@ async function resolveWorkspaceRecord(workspaceName) {
28736
28899
  const exactWorkspace = await fetchWorkspaceById(workspaceName);
28737
28900
  if (exactWorkspace) return exactWorkspace;
28738
28901
  }
28739
- console.log(import_chalk5.default.blue(workspaceName ? `
28902
+ console.log(import_chalk6.default.blue(workspaceName ? `
28740
28903
  Searching for workspace: ${workspaceName}...` : "\nLoading workspaces..."));
28741
28904
  const params = new URLSearchParams({ limit: "100" });
28742
28905
  if (workspaceName) params.set("name", workspaceName);
@@ -28755,7 +28918,7 @@ Searching for workspace: ${workspaceName}...` : "\nLoading workspaces..."));
28755
28918
  selectedWorkspace = workspaces[0];
28756
28919
  } else {
28757
28920
  if (workspaceName) {
28758
- console.log(import_chalk5.default.yellow(`
28921
+ console.log(import_chalk6.default.yellow(`
28759
28922
  Found ${workspaces.length} workspaces matching "${workspaceName}":`));
28760
28923
  }
28761
28924
  const selectResponse = await (0, import_prompts5.default)({
@@ -28777,9 +28940,9 @@ Found ${workspaces.length} workspaces matching "${workspaceName}":`));
28777
28940
  }
28778
28941
  selectedWorkspace = selected;
28779
28942
  }
28780
- console.log(import_chalk5.default.green(`
28943
+ console.log(import_chalk6.default.green(`
28781
28944
  \u2713 Selected workspace: ${selectedWorkspace.name}`));
28782
- console.log(import_chalk5.default.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
28945
+ console.log(import_chalk6.default.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
28783
28946
  return selectedWorkspace;
28784
28947
  }
28785
28948
  async function prepareWorkspaceConnection(workspaceName) {
@@ -28789,12 +28952,12 @@ async function prepareWorkspaceConnection(workspaceName) {
28789
28952
  `Workspace is currently ${selectedWorkspace.status}. Wake it at ${DEFAULT_WEB_APP_URL}`
28790
28953
  );
28791
28954
  }
28792
- console.log(import_chalk5.default.blue("\nRequesting SSH access token..."));
28955
+ console.log(import_chalk6.default.blue("\nRequesting SSH access token..."));
28793
28956
  const tokenResponse = await orgAuthenticatedFetch(
28794
28957
  `/v1/workspaces/${selectedWorkspace.id}/ssh-token`,
28795
28958
  { method: "POST" }
28796
28959
  );
28797
- console.log(import_chalk5.default.green("\u2713 SSH token received"));
28960
+ console.log(import_chalk6.default.green("\u2713 SSH token received"));
28798
28961
  let repoName = null;
28799
28962
  if (isInsideGitRepo()) {
28800
28963
  try {
@@ -28814,27 +28977,27 @@ async function prepareWorkspaceConnection(workspaceName) {
28814
28977
  // src/commands/connect.ts
28815
28978
  async function connectCommand(workspaceName) {
28816
28979
  if (!isAuthenticated()) {
28817
- console.log(import_chalk6.default.red('Not logged in. Please run "replicas login" first.'));
28980
+ console.log(import_chalk7.default.red('Not logged in. Please run "replicas login" first.'));
28818
28981
  process.exit(1);
28819
28982
  }
28820
28983
  try {
28821
28984
  const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
28822
- console.log(import_chalk6.default.blue(`
28985
+ console.log(import_chalk7.default.blue(`
28823
28986
  Connecting to ${workspace.name}...`));
28824
28987
  const sshCommand = `ssh ${sshToken}@${sshHost}`;
28825
- console.log(import_chalk6.default.gray(`SSH command: ${sshCommand}`));
28826
- console.log(import_chalk6.default.gray("\nPress Ctrl+D to disconnect.\n"));
28988
+ console.log(import_chalk7.default.gray(`SSH command: ${sshCommand}`));
28989
+ console.log(import_chalk7.default.gray("\nPress Ctrl+D to disconnect.\n"));
28827
28990
  await connectSSH(sshToken, sshHost, sshProxyCommand);
28828
- console.log(import_chalk6.default.green("\n\u2713 Disconnected from workspace.\n"));
28991
+ console.log(import_chalk7.default.green("\n\u2713 Disconnected from workspace.\n"));
28829
28992
  } catch (error51) {
28830
- console.error(import_chalk6.default.red(`
28993
+ console.error(import_chalk7.default.red(`
28831
28994
  Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28832
28995
  process.exit(1);
28833
28996
  }
28834
28997
  }
28835
28998
 
28836
28999
  // src/commands/code.ts
28837
- var import_chalk7 = __toESM(require("chalk"));
29000
+ var import_chalk8 = __toESM(require("chalk"));
28838
29001
  var import_child_process3 = require("child_process");
28839
29002
 
28840
29003
  // src/lib/ssh-config.ts
@@ -28928,32 +29091,32 @@ function getWorkspaceHostAlias(workspaceName) {
28928
29091
  // src/commands/code.ts
28929
29092
  async function codeCommand(workspaceName) {
28930
29093
  if (!isAuthenticated()) {
28931
- console.log(import_chalk7.default.red('Not logged in. Please run "replicas login" first.'));
29094
+ console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
28932
29095
  process.exit(1);
28933
29096
  }
28934
29097
  if (!workspaceName && !process.stdin.isTTY) {
28935
- console.error(import_chalk7.default.red('Pass a workspace name or ID, or run "replicas code" in an interactive terminal.'));
29098
+ console.error(import_chalk8.default.red('Pass a workspace name or ID, or run "replicas code" in an interactive terminal.'));
28936
29099
  process.exit(1);
28937
29100
  }
28938
29101
  try {
28939
29102
  const { workspace, sshToken, sshHost, sshProxyCommand, repoName } = await prepareWorkspaceConnection(workspaceName);
28940
29103
  const hostAlias = getWorkspaceHostAlias(workspace.name);
28941
- console.log(import_chalk7.default.blue("\nConfiguring SSH connection..."));
29104
+ console.log(import_chalk8.default.blue("\nConfiguring SSH connection..."));
28942
29105
  addOrUpdateSSHConfigEntry({
28943
29106
  host: hostAlias,
28944
29107
  hostname: sshHost,
28945
29108
  user: sshToken,
28946
29109
  proxyCommand: sshProxyCommand
28947
29110
  });
28948
- console.log(import_chalk7.default.green(`\u2713 SSH config entry created: ${hostAlias}`));
29111
+ console.log(import_chalk8.default.green(`\u2713 SSH config entry created: ${hostAlias}`));
28949
29112
  const paths = SANDBOX_PATHS;
28950
29113
  const remotePath = repoName ? `${paths.WORKSPACES_DIR}/${repoName}` : paths.HOME_DIR;
28951
29114
  const ideCommand = getIdeCommand();
28952
29115
  const fullCommand = `${ideCommand} --remote ssh-remote+${hostAlias} ${remotePath}`;
28953
- console.log(import_chalk7.default.blue(`
29116
+ console.log(import_chalk8.default.blue(`
28954
29117
  Opening ${ideCommand} for workspace ${workspace.name}...`));
28955
- console.log(import_chalk7.default.gray(`Command: ${fullCommand}`));
28956
- console.log(import_chalk7.default.yellow(`
29118
+ console.log(import_chalk8.default.gray(`Command: ${fullCommand}`));
29119
+ console.log(import_chalk8.default.yellow(`
28957
29120
  Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
28958
29121
  const ide = (0, import_child_process3.spawn)(ideCommand, [
28959
29122
  "--remote",
@@ -28964,29 +29127,29 @@ Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
28964
29127
  detached: false
28965
29128
  });
28966
29129
  ide.on("error", (error51) => {
28967
- console.error(import_chalk7.default.red(`
29130
+ console.error(import_chalk8.default.red(`
28968
29131
  Failed to launch ${ideCommand}: ${error51.message}`));
28969
- console.log(import_chalk7.default.yellow(`
29132
+ console.log(import_chalk8.default.yellow(`
28970
29133
  Make sure ${ideCommand} is installed and available in your PATH.`));
28971
- console.log(import_chalk7.default.gray(`You can configure a different IDE with: replicas config set ide <command>`));
29134
+ console.log(import_chalk8.default.gray(`You can configure a different IDE with: replicas config set ide <command>`));
28972
29135
  process.exit(1);
28973
29136
  });
28974
29137
  ide.on("close", (code) => {
28975
29138
  if (code === 0) {
28976
- console.log(import_chalk7.default.green(`
29139
+ console.log(import_chalk8.default.green(`
28977
29140
  \u2713 ${ideCommand} closed successfully.
28978
29141
  `));
28979
29142
  }
28980
29143
  });
28981
29144
  } catch (error51) {
28982
- console.error(import_chalk7.default.red(`
29145
+ console.error(import_chalk8.default.red(`
28983
29146
  Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
28984
29147
  process.exit(1);
28985
29148
  }
28986
29149
  }
28987
29150
 
28988
29151
  // src/commands/tunnel.ts
28989
- var import_chalk8 = __toESM(require("chalk"));
29152
+ var import_chalk9 = __toESM(require("chalk"));
28990
29153
  async function tunnelCommand(workspaceName, options) {
28991
29154
  if (!isAuthenticated()) {
28992
29155
  throw new Error('Not logged in. Please run "replicas login" first.');
@@ -28994,32 +29157,32 @@ async function tunnelCommand(workspaceName, options) {
28994
29157
  const remotePort = parsePort(options.port);
28995
29158
  const localPort = options.localPort ? parsePort(options.localPort) : remotePort;
28996
29159
  const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
28997
- console.log(import_chalk8.default.green(`
29160
+ console.log(import_chalk9.default.green(`
28998
29161
  \u2713 Forwarding localhost:${localPort} to ${workspace.name}:${remotePort}`));
28999
- console.log(import_chalk8.default.gray(" Press Ctrl+C to stop.\n"));
29162
+ console.log(import_chalk9.default.gray(" Press Ctrl+C to stop.\n"));
29000
29163
  await connectSSH(sshToken, sshHost, sshProxyCommand, { localPort, remotePort });
29001
29164
  }
29002
29165
 
29003
29166
  // src/commands/org.ts
29004
- var import_chalk9 = __toESM(require("chalk"));
29167
+ var import_chalk10 = __toESM(require("chalk"));
29005
29168
  async function orgCommand() {
29006
29169
  if (!isAuthenticated()) {
29007
- console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
29170
+ console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
29008
29171
  process.exit(1);
29009
29172
  }
29010
29173
  try {
29011
29174
  const currentOrgId = getConfirmedOrganizationId();
29012
29175
  const organizations = await fetchOrganizations();
29013
29176
  if (!currentOrgId) {
29014
- console.log(import_chalk9.default.yellow("\n No organization selected."));
29015
- console.log(import_chalk9.default.gray(' Run "replicas org switch" to select one.\n'));
29177
+ console.log(import_chalk10.default.yellow("\n No organization selected."));
29178
+ console.log(import_chalk10.default.gray(' Run "replicas org switch" to select one.\n'));
29016
29179
  return;
29017
29180
  }
29018
29181
  const currentOrg = organizations.find((org2) => org2.id === currentOrgId);
29019
29182
  if (!currentOrg) {
29020
29183
  clearOrganizationId();
29021
- console.log(import_chalk9.default.yellow("\n The selected organization is no longer available to you."));
29022
- console.log(import_chalk9.default.gray(' Run "replicas org switch" to select another.\n'));
29184
+ console.log(import_chalk10.default.yellow("\n The selected organization is no longer available to you."));
29185
+ console.log(import_chalk10.default.gray(' Run "replicas org switch" to select another.\n'));
29023
29186
  return;
29024
29187
  }
29025
29188
  const [account, role] = await Promise.all([
@@ -29030,26 +29193,26 @@ async function orgCommand() {
29030
29193
  renderIdentity({ account, role, organizationName: currentOrg.name });
29031
29194
  if (organizations.length > 1) {
29032
29195
  console.log(
29033
- import_chalk9.default.gray(`
29196
+ import_chalk10.default.gray(`
29034
29197
  ${organizations.length} organizations available. "replicas org switch" to change.`)
29035
29198
  );
29036
29199
  }
29037
29200
  console.log();
29038
29201
  } catch (error51) {
29039
- console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29202
+ console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29040
29203
  process.exit(1);
29041
29204
  }
29042
29205
  }
29043
29206
  async function orgSwitchCommand() {
29044
29207
  if (!isAuthenticated()) {
29045
- console.log(import_chalk9.default.red('Not logged in. Please run "replicas login" first.'));
29208
+ console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
29046
29209
  process.exit(1);
29047
29210
  }
29048
29211
  try {
29049
29212
  const organizations = await fetchOrganizations();
29050
29213
  if (organizations.length === 0) {
29051
- console.log(import_chalk9.default.yellow("\n You are not a member of any organization."));
29052
- console.log(import_chalk9.default.gray(" Please contact support.\n"));
29214
+ console.log(import_chalk10.default.yellow("\n You are not a member of any organization."));
29215
+ console.log(import_chalk10.default.gray(" Please contact support.\n"));
29053
29216
  return;
29054
29217
  }
29055
29218
  const currentOrgId = getConfirmedOrganizationId();
@@ -29057,7 +29220,7 @@ async function orgSwitchCommand() {
29057
29220
  if (organizations.length > 1) {
29058
29221
  const chosen = await promptForOrganization(organizations, currentOrgId);
29059
29222
  if (!chosen) {
29060
- console.log(import_chalk9.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
29223
+ console.log(import_chalk10.default.yellow("\n Cancelled. The active organization is unchanged.\n"));
29061
29224
  return;
29062
29225
  }
29063
29226
  selectedId = chosen.id;
@@ -29072,72 +29235,72 @@ async function orgSwitchCommand() {
29072
29235
  renderIdentity({ account, role, organizationName: selected?.name });
29073
29236
  console.log();
29074
29237
  } catch (error51) {
29075
- console.error(import_chalk9.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29238
+ console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29076
29239
  process.exit(1);
29077
29240
  }
29078
29241
  }
29079
29242
 
29080
29243
  // src/commands/config.ts
29081
- var import_chalk10 = __toESM(require("chalk"));
29244
+ var import_chalk11 = __toESM(require("chalk"));
29082
29245
  async function configGetCommand(key) {
29083
29246
  if (!isAuthenticated()) {
29084
- console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
29247
+ console.log(import_chalk11.default.red('Not logged in. Please run "replicas login" first.'));
29085
29248
  process.exit(1);
29086
29249
  }
29087
29250
  try {
29088
29251
  if (key === "ide") {
29089
29252
  const ideCommand = getIdeCommand();
29090
- console.log(import_chalk10.default.green(`
29253
+ console.log(import_chalk11.default.green(`
29091
29254
  IDE command: ${ideCommand}
29092
29255
  `));
29093
29256
  } else {
29094
- console.log(import_chalk10.default.red(`Unknown config key: ${key}`));
29095
- console.log(import_chalk10.default.gray("Available keys: ide"));
29257
+ console.log(import_chalk11.default.red(`Unknown config key: ${key}`));
29258
+ console.log(import_chalk11.default.gray("Available keys: ide"));
29096
29259
  process.exit(1);
29097
29260
  }
29098
29261
  } catch (error51) {
29099
- console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29262
+ console.error(import_chalk11.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29100
29263
  process.exit(1);
29101
29264
  }
29102
29265
  }
29103
29266
  async function configSetCommand(key, value) {
29104
29267
  if (!isAuthenticated()) {
29105
- console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
29268
+ console.log(import_chalk11.default.red('Not logged in. Please run "replicas login" first.'));
29106
29269
  process.exit(1);
29107
29270
  }
29108
29271
  try {
29109
29272
  if (key === "ide") {
29110
29273
  setIdeCommand(value);
29111
- console.log(import_chalk10.default.green(`
29274
+ console.log(import_chalk11.default.green(`
29112
29275
  \u2713 IDE command set to: ${value}
29113
29276
  `));
29114
29277
  } else {
29115
- console.log(import_chalk10.default.red(`Unknown config key: ${key}`));
29116
- console.log(import_chalk10.default.gray("Available keys: ide"));
29278
+ console.log(import_chalk11.default.red(`Unknown config key: ${key}`));
29279
+ console.log(import_chalk11.default.gray("Available keys: ide"));
29117
29280
  process.exit(1);
29118
29281
  }
29119
29282
  } catch (error51) {
29120
- console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29283
+ console.error(import_chalk11.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29121
29284
  process.exit(1);
29122
29285
  }
29123
29286
  }
29124
29287
  async function configListCommand() {
29125
29288
  if (!isAuthenticated()) {
29126
- console.log(import_chalk10.default.red('Not logged in. Please run "replicas login" first.'));
29289
+ console.log(import_chalk11.default.red('Not logged in. Please run "replicas login" first.'));
29127
29290
  process.exit(1);
29128
29291
  }
29129
29292
  try {
29130
29293
  const config3 = readConfig();
29131
29294
  if (!config3) {
29132
- console.log(import_chalk10.default.red("No config found. Please login first."));
29295
+ console.log(import_chalk11.default.red("No config found. Please login first."));
29133
29296
  process.exit(1);
29134
29297
  }
29135
- console.log(import_chalk10.default.green("\nCurrent configuration:"));
29136
- console.log(import_chalk10.default.gray(` Organization ID: ${config3.organization_id || "(not set)"}`));
29137
- console.log(import_chalk10.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
29298
+ console.log(import_chalk11.default.green("\nCurrent configuration:"));
29299
+ console.log(import_chalk11.default.gray(` Organization ID: ${config3.organization_id || "(not set)"}`));
29300
+ console.log(import_chalk11.default.gray(` IDE command: ${config3.ide_command || "code (default)"}`));
29138
29301
  console.log();
29139
29302
  } catch (error51) {
29140
- console.error(import_chalk10.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29303
+ console.error(import_chalk11.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29141
29304
  process.exit(1);
29142
29305
  }
29143
29306
  }
@@ -29300,7 +29463,7 @@ async function runCodexOAuthFlow(totalSteps, save) {
29300
29463
  }
29301
29464
 
29302
29465
  // src/lib/credential-upload.ts
29303
- var import_chalk11 = __toESM(require("chalk"));
29466
+ var import_chalk12 = __toESM(require("chalk"));
29304
29467
  var UPLOAD_STEPS = 1;
29305
29468
  async function withAuthRecovery(operation, afterReauthentication) {
29306
29469
  try {
@@ -29310,11 +29473,11 @@ async function withAuthRecovery(operation, afterReauthentication) {
29310
29473
  throw error51;
29311
29474
  }
29312
29475
  const message = error51 instanceof NotAuthenticatedError ? "You're not signed in to Replicas. Signing in..." : "Your Replicas session expired. Re-authenticating...";
29313
- console.log(import_chalk11.default.yellow(`
29476
+ console.log(import_chalk12.default.yellow(`
29314
29477
  ${message}`));
29315
29478
  await loginCommand();
29316
29479
  await afterReauthentication?.();
29317
- console.log(import_chalk11.default.gray(" Retrying..."));
29480
+ console.log(import_chalk12.default.gray(" Retrying..."));
29318
29481
  return { result: await operation(), reauthenticated: true };
29319
29482
  }
29320
29483
  }
@@ -29388,7 +29551,7 @@ async function runCredentialAuthFlow(options, flow) {
29388
29551
  return completionUrl.toString();
29389
29552
  });
29390
29553
  } catch (error51) {
29391
- console.log(import_chalk11.default.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
29554
+ console.log(import_chalk12.default.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
29392
29555
  process.exit(1);
29393
29556
  }
29394
29557
  }
@@ -29414,7 +29577,7 @@ async function codexAuthCommand(options = {}) {
29414
29577
 
29415
29578
  // src/lib/claude-oauth.ts
29416
29579
  var import_readline = __toESM(require("readline"));
29417
- var import_chalk12 = __toESM(require("chalk"));
29580
+ var import_chalk13 = __toESM(require("chalk"));
29418
29581
  var DEFAULT_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
29419
29582
  var CLAUDE_CLIENT_ID = process.env.CLAUDE_OAUTH_CLIENT_ID || DEFAULT_CLIENT_ID;
29420
29583
  var AUTHORIZATION_ENDPOINT2 = "https://claude.ai/oauth/authorize";
@@ -29443,7 +29606,7 @@ async function promptForAuthorizationCode() {
29443
29606
  const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
29444
29607
  return new Promise((resolve2) => {
29445
29608
  rl.on("close", () => resolve2(""));
29446
- rl.question(import_chalk12.default.gray(" Paste code here: "), (answer) => {
29609
+ rl.question(import_chalk13.default.gray(" Paste code here: "), (answer) => {
29447
29610
  resolve2(answer.trim());
29448
29611
  rl.close();
29449
29612
  });
@@ -29637,7 +29800,7 @@ async function museAuthCommand(options = {}) {
29637
29800
  }
29638
29801
 
29639
29802
  // src/commands/init.ts
29640
- var import_chalk13 = __toESM(require("chalk"));
29803
+ var import_chalk14 = __toESM(require("chalk"));
29641
29804
  var import_fs3 = __toESM(require("fs"));
29642
29805
  var import_path4 = __toESM(require("path"));
29643
29806
  function getDefaultConfig() {
@@ -29669,11 +29832,11 @@ function initCommand(options) {
29669
29832
  const existingPath = import_path4.default.join(process.cwd(), filename);
29670
29833
  if (import_fs3.default.existsSync(existingPath) && !options.force) {
29671
29834
  console.log(
29672
- import_chalk13.default.yellow(
29835
+ import_chalk14.default.yellow(
29673
29836
  `${filename} already exists in this directory.`
29674
29837
  )
29675
29838
  );
29676
- console.log(import_chalk13.default.gray("Use --force to overwrite the existing file."));
29839
+ console.log(import_chalk14.default.gray("Use --force to overwrite the existing file."));
29677
29840
  return;
29678
29841
  }
29679
29842
  }
@@ -29686,31 +29849,31 @@ function initCommand(options) {
29686
29849
  }
29687
29850
  try {
29688
29851
  import_fs3.default.writeFileSync(configPath, configContent, "utf-8");
29689
- console.log(import_chalk13.default.green(`\u2713 Created ${targetFilename}`));
29852
+ console.log(import_chalk14.default.green(`\u2713 Created ${targetFilename}`));
29690
29853
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
29691
29854
  if (filename === targetFilename) break;
29692
29855
  const higherPath = import_path4.default.join(process.cwd(), filename);
29693
29856
  if (import_fs3.default.existsSync(higherPath)) {
29694
29857
  console.log("");
29695
29858
  console.log(
29696
- import_chalk13.default.yellow(
29859
+ import_chalk14.default.yellow(
29697
29860
  `Warning: ${filename} already exists and takes priority over ${targetFilename}.`
29698
29861
  )
29699
29862
  );
29700
- console.log(import_chalk13.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
29863
+ console.log(import_chalk14.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
29701
29864
  }
29702
29865
  }
29703
29866
  console.log("");
29704
- console.log(import_chalk13.default.gray("Configuration options:"));
29867
+ console.log(import_chalk14.default.gray("Configuration options:"));
29705
29868
  console.log(
29706
- import_chalk13.default.gray(" systemPrompt - Custom instructions for AI coding assistants")
29869
+ import_chalk14.default.gray(" systemPrompt - Custom instructions for AI coding assistants")
29707
29870
  );
29708
29871
  console.log(
29709
- import_chalk13.default.gray(" startHook - Commands to run on workspace startup")
29872
+ import_chalk14.default.gray(" startHook - Commands to run on workspace startup")
29710
29873
  );
29711
29874
  if (!isYaml) {
29712
29875
  console.log("");
29713
- console.log(import_chalk13.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
29876
+ console.log(import_chalk14.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
29714
29877
  }
29715
29878
  } catch (error51) {
29716
29879
  throw new Error(
@@ -29720,7 +29883,7 @@ function initCommand(options) {
29720
29883
  }
29721
29884
 
29722
29885
  // src/lib/version-check.ts
29723
- var import_chalk14 = __toESM(require("chalk"));
29886
+ var import_chalk15 = __toESM(require("chalk"));
29724
29887
  var VERSION_CHECK_TIMEOUT = 2e3;
29725
29888
  function startUpdateCheck(currentVersion) {
29726
29889
  let notice = null;
@@ -29741,7 +29904,7 @@ function startUpdateCheck(currentVersion) {
29741
29904
  }
29742
29905
  const latestVersion = payload.version;
29743
29906
  if (compareVersions(latestVersion, currentVersion) > 0) {
29744
- notice = import_chalk14.default.dim(
29907
+ notice = import_chalk15.default.dim(
29745
29908
  `
29746
29909
  Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm install -g replicas-cli@latest
29747
29910
  `
@@ -29753,7 +29916,7 @@ Replicas CLI ${currentVersion} \u2192 ${latestVersion} available. Update: npm in
29753
29916
  }
29754
29917
 
29755
29918
  // src/commands/replica.ts
29756
- var import_chalk15 = __toESM(require("chalk"));
29919
+ var import_chalk16 = __toESM(require("chalk"));
29757
29920
  var import_prompts6 = __toESM(require("prompts"));
29758
29921
  var CLI_CODING_AGENT_LABEL = getCodingAgentDisplayNames();
29759
29922
  function parseReplicaAgent(value) {
@@ -29762,15 +29925,15 @@ function parseReplicaAgent(value) {
29762
29925
  if (isValidCodingAgentProvider(normalized)) {
29763
29926
  return normalized;
29764
29927
  }
29765
- console.log(import_chalk15.default.red(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`));
29928
+ console.log(import_chalk16.default.red(`Invalid coding agent: ${value}. Must be one of: ${CLI_CODING_AGENT_LABEL}`));
29766
29929
  process.exit(1);
29767
29930
  }
29768
29931
  function formatDate(dateString) {
29769
29932
  return new Date(dateString).toLocaleString();
29770
29933
  }
29771
29934
  function formatStatus(status) {
29772
- if (status === "active") return import_chalk15.default.green(status);
29773
- if (isWorkspaceSuspendedStatus(status)) return import_chalk15.default.gray(status);
29935
+ if (status === "active") return import_chalk16.default.green(status);
29936
+ if (isWorkspaceSuspendedStatus(status)) return import_chalk16.default.gray(status);
29774
29937
  return status;
29775
29938
  }
29776
29939
  function truncate(text, maxLength) {
@@ -29781,95 +29944,95 @@ function formatDisplayMessage(message) {
29781
29944
  const time3 = new Date(message.timestamp).toLocaleTimeString();
29782
29945
  switch (message.type) {
29783
29946
  case "user":
29784
- console.log(import_chalk15.default.blue(`
29947
+ console.log(import_chalk16.default.blue(`
29785
29948
  [${time3}] USER:`));
29786
- console.log(import_chalk15.default.white(` ${truncate(message.content, 500)}`));
29949
+ console.log(import_chalk16.default.white(` ${truncate(message.content, 500)}`));
29787
29950
  break;
29788
29951
  case "agent":
29789
- console.log(import_chalk15.default.green(`
29952
+ console.log(import_chalk16.default.green(`
29790
29953
  [${time3}] ASSISTANT:`));
29791
- console.log(import_chalk15.default.white(` ${truncate(message.content, 500)}`));
29954
+ console.log(import_chalk16.default.white(` ${truncate(message.content, 500)}`));
29792
29955
  break;
29793
29956
  case "reasoning":
29794
- console.log(import_chalk15.default.gray(`
29957
+ console.log(import_chalk16.default.gray(`
29795
29958
  [${time3}] THINKING:`));
29796
- console.log(import_chalk15.default.gray(` ${truncate(message.content, 300)}`));
29959
+ console.log(import_chalk16.default.gray(` ${truncate(message.content, 300)}`));
29797
29960
  break;
29798
29961
  case "command":
29799
- console.log(import_chalk15.default.magenta(`
29962
+ console.log(import_chalk16.default.magenta(`
29800
29963
  [${time3}] COMMAND:`));
29801
- console.log(import_chalk15.default.white(` $ ${message.command}`));
29964
+ console.log(import_chalk16.default.white(` $ ${message.command}`));
29802
29965
  if (message.output) {
29803
- console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
29966
+ console.log(import_chalk16.default.gray(` ${truncate(message.output, 200)}`));
29804
29967
  }
29805
29968
  if (message.exitCode !== void 0) {
29806
- const exitColor = message.exitCode === 0 ? import_chalk15.default.green : import_chalk15.default.red;
29969
+ const exitColor = message.exitCode === 0 ? import_chalk16.default.green : import_chalk16.default.red;
29807
29970
  console.log(exitColor(` Exit code: ${message.exitCode}`));
29808
29971
  }
29809
29972
  break;
29810
29973
  case "file_change":
29811
- console.log(import_chalk15.default.yellow(`
29974
+ console.log(import_chalk16.default.yellow(`
29812
29975
  [${time3}] FILE CHANGES:`));
29813
29976
  for (const change of message.changes) {
29814
29977
  const icon = change.kind === "add" ? "+" : change.kind === "delete" ? "-" : "~";
29815
- const color = change.kind === "add" ? import_chalk15.default.green : change.kind === "delete" ? import_chalk15.default.red : import_chalk15.default.yellow;
29978
+ const color = change.kind === "add" ? import_chalk16.default.green : change.kind === "delete" ? import_chalk16.default.red : import_chalk16.default.yellow;
29816
29979
  console.log(color(` ${icon} ${change.path}`));
29817
29980
  }
29818
29981
  break;
29819
29982
  case "patch":
29820
- console.log(import_chalk15.default.yellow(`
29983
+ console.log(import_chalk16.default.yellow(`
29821
29984
  [${time3}] PATCH:`));
29822
29985
  for (const op of message.operations) {
29823
29986
  const icon = op.action === "add" ? "+" : op.action === "delete" ? "-" : "~";
29824
- const color = op.action === "add" ? import_chalk15.default.green : op.action === "delete" ? import_chalk15.default.red : import_chalk15.default.yellow;
29987
+ const color = op.action === "add" ? import_chalk16.default.green : op.action === "delete" ? import_chalk16.default.red : import_chalk16.default.yellow;
29825
29988
  console.log(color(` ${icon} ${op.path}`));
29826
29989
  }
29827
29990
  break;
29828
29991
  case "tool_call":
29829
- console.log(import_chalk15.default.cyan(`
29992
+ console.log(import_chalk16.default.cyan(`
29830
29993
  [${time3}] TOOL: ${message.tool}`));
29831
29994
  if (message.output) {
29832
- console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
29995
+ console.log(import_chalk16.default.gray(` ${truncate(message.output, 200)}`));
29833
29996
  }
29834
29997
  break;
29835
29998
  case "web_search":
29836
- console.log(import_chalk15.default.cyan(`
29999
+ console.log(import_chalk16.default.cyan(`
29837
30000
  [${time3}] WEB SEARCH:`));
29838
- console.log(import_chalk15.default.white(` "${message.query}"`));
30001
+ console.log(import_chalk16.default.white(` "${message.query}"`));
29839
30002
  break;
29840
30003
  case "todo_list":
29841
- console.log(import_chalk15.default.blue(`
30004
+ console.log(import_chalk16.default.blue(`
29842
30005
  [${time3}] PLAN:`));
29843
30006
  for (const item of message.items) {
29844
- const icon = item.completed ? import_chalk15.default.green("[x]") : import_chalk15.default.gray("[ ]");
30007
+ const icon = item.completed ? import_chalk16.default.green("[x]") : import_chalk16.default.gray("[ ]");
29845
30008
  console.log(` ${icon} ${item.text}`);
29846
30009
  }
29847
30010
  break;
29848
30011
  case "subagent":
29849
- console.log(import_chalk15.default.magenta(`
30012
+ console.log(import_chalk16.default.magenta(`
29850
30013
  [${time3}] SUBAGENT: ${message.description}`));
29851
30014
  if (message.output) {
29852
- console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
30015
+ console.log(import_chalk16.default.gray(` ${truncate(message.output, 200)}`));
29853
30016
  }
29854
30017
  break;
29855
30018
  case "subagent_followup":
29856
- console.log(import_chalk15.default.magenta(`
30019
+ console.log(import_chalk16.default.magenta(`
29857
30020
  [${time3}] MESSAGE SUBAGENT: ${message.targetTitle ?? message.chatId}`));
29858
- console.log(import_chalk15.default.white(` ${truncate(message.message, 500)}`));
30021
+ console.log(import_chalk16.default.white(` ${truncate(message.message, 500)}`));
29859
30022
  if (message.output) {
29860
- console.log(import_chalk15.default.gray(` ${truncate(message.output, 200)}`));
30023
+ console.log(import_chalk16.default.gray(` ${truncate(message.output, 200)}`));
29861
30024
  }
29862
30025
  break;
29863
30026
  case "error":
29864
- console.log(import_chalk15.default.red(`
30027
+ console.log(import_chalk16.default.red(`
29865
30028
  [${time3}] ERROR:`));
29866
- console.log(import_chalk15.default.red(` ${message.message}`));
30029
+ console.log(import_chalk16.default.red(` ${message.message}`));
29867
30030
  break;
29868
30031
  }
29869
30032
  }
29870
30033
  async function replicaListCommand(options) {
29871
30034
  if (!canCallOrgApi()) {
29872
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30035
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
29873
30036
  process.exit(1);
29874
30037
  }
29875
30038
  try {
@@ -29881,86 +30044,86 @@ async function replicaListCommand(options) {
29881
30044
  `/v1/replica${query ? "?" + query : ""}`
29882
30045
  );
29883
30046
  if (response.replicas.length === 0) {
29884
- console.log(import_chalk15.default.yellow("\nNo replicas found.\n"));
30047
+ console.log(import_chalk16.default.yellow("\nNo replicas found.\n"));
29885
30048
  return;
29886
30049
  }
29887
- console.log(import_chalk15.default.green(`
30050
+ console.log(import_chalk16.default.green(`
29888
30051
  Replicas (Page ${response.page} of ${response.total_pages}, Total: ${response.total}):
29889
30052
  `));
29890
30053
  for (const replica of response.replicas) {
29891
- console.log(import_chalk15.default.white(` ${replica.name}`));
29892
- console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
30054
+ console.log(import_chalk16.default.white(` ${replica.name}`));
30055
+ console.log(import_chalk16.default.gray(` ID: ${replica.id}`));
29893
30056
  if (replica.repositories.length > 0) {
29894
- console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
30057
+ console.log(import_chalk16.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29895
30058
  }
29896
- console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
29897
- console.log(import_chalk15.default.gray(` Created: ${formatDate(replica.created_at)}`));
30059
+ console.log(import_chalk16.default.gray(` Status: ${formatStatus(replica.status)}`));
30060
+ console.log(import_chalk16.default.gray(` Created: ${formatDate(replica.created_at)}`));
29898
30061
  if (replica.pull_requests && replica.pull_requests.length > 0) {
29899
- console.log(import_chalk15.default.gray(` Pull Requests:`));
30062
+ console.log(import_chalk16.default.gray(` Pull Requests:`));
29900
30063
  for (const pr of replica.pull_requests) {
29901
- console.log(import_chalk15.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
30064
+ console.log(import_chalk16.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29902
30065
  }
29903
30066
  }
29904
30067
  console.log();
29905
30068
  }
29906
30069
  } catch (error51) {
29907
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30070
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29908
30071
  process.exit(1);
29909
30072
  }
29910
30073
  }
29911
30074
  async function replicaGetCommand(id) {
29912
30075
  if (!isAuthenticated()) {
29913
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30076
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
29914
30077
  process.exit(1);
29915
30078
  }
29916
30079
  try {
29917
30080
  const response = await orgAuthenticatedFetch(`/v1/replica/${id}`);
29918
30081
  const replica = response.replica;
29919
- console.log(import_chalk15.default.green(`
30082
+ console.log(import_chalk16.default.green(`
29920
30083
  Replica: ${replica.name}
29921
30084
  `));
29922
- console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
30085
+ console.log(import_chalk16.default.gray(` ID: ${replica.id}`));
29923
30086
  if (replica.repositories.length > 0) {
29924
- console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
30087
+ console.log(import_chalk16.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
29925
30088
  }
29926
- console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
29927
- console.log(import_chalk15.default.gray(` Created: ${formatDate(replica.created_at)}`));
30089
+ console.log(import_chalk16.default.gray(` Status: ${formatStatus(replica.status)}`));
30090
+ console.log(import_chalk16.default.gray(` Created: ${formatDate(replica.created_at)}`));
29928
30091
  if (replica.waking) {
29929
- console.log(import_chalk15.default.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
30092
+ console.log(import_chalk16.default.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
29930
30093
  } else {
29931
30094
  if (replica.coding_agent) {
29932
- console.log(import_chalk15.default.gray(` Coding Agent: ${replica.coding_agent}`));
30095
+ console.log(import_chalk16.default.gray(` Coding Agent: ${replica.coding_agent}`));
29933
30096
  }
29934
30097
  if (replica.repository_statuses && replica.repository_statuses.length > 0) {
29935
- console.log(import_chalk15.default.gray(" Repository Statuses:"));
30098
+ console.log(import_chalk16.default.gray(" Repository Statuses:"));
29936
30099
  for (const repositoryStatus of replica.repository_statuses) {
29937
- const changeText = repositoryStatus.git_diff ? ` (${import_chalk15.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk15.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
29938
- console.log(import_chalk15.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
30100
+ const changeText = repositoryStatus.git_diff ? ` (${import_chalk16.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk16.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
30101
+ console.log(import_chalk16.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
29939
30102
  }
29940
30103
  }
29941
30104
  }
29942
30105
  if (replica.pull_requests && replica.pull_requests.length > 0) {
29943
- console.log(import_chalk15.default.gray(` Pull Requests:`));
30106
+ console.log(import_chalk16.default.gray(` Pull Requests:`));
29944
30107
  for (const pr of replica.pull_requests) {
29945
- console.log(import_chalk15.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
30108
+ console.log(import_chalk16.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
29946
30109
  }
29947
30110
  }
29948
30111
  console.log();
29949
30112
  } catch (error51) {
29950
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30113
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
29951
30114
  process.exit(1);
29952
30115
  }
29953
30116
  }
29954
30117
  async function replicaCreateCommand(name, options) {
29955
30118
  if (!isAuthenticated()) {
29956
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30119
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
29957
30120
  process.exit(1);
29958
30121
  }
29959
30122
  try {
29960
30123
  const envResponse = await orgAuthenticatedFetch("/v1/environments");
29961
30124
  const environments = envResponse.environments;
29962
30125
  if (environments.length === 0) {
29963
- console.log(import_chalk15.default.red("No environments found. Please create an environment first."));
30126
+ console.log(import_chalk16.default.red("No environments found. Please create an environment first."));
29964
30127
  process.exit(1);
29965
30128
  }
29966
30129
  let replicaName = name;
@@ -29968,7 +30131,7 @@ async function replicaCreateCommand(name, options) {
29968
30131
  let selectedEnvironmentId = options.environment?.trim();
29969
30132
  let codingAgent = parseReplicaAgent(options.agent);
29970
30133
  if (replicaName && /\s/.test(replicaName)) {
29971
- console.log(import_chalk15.default.red("Replica name cannot contain spaces."));
30134
+ console.log(import_chalk16.default.red("Replica name cannot contain spaces."));
29972
30135
  process.exit(1);
29973
30136
  }
29974
30137
  if (!replicaName) {
@@ -29983,7 +30146,7 @@ async function replicaCreateCommand(name, options) {
29983
30146
  }
29984
30147
  });
29985
30148
  if (!response2.name) {
29986
- console.log(import_chalk15.default.yellow("\nCancelled."));
30149
+ console.log(import_chalk16.default.yellow("\nCancelled."));
29987
30150
  return;
29988
30151
  }
29989
30152
  replicaName = response2.name;
@@ -30000,7 +30163,7 @@ async function replicaCreateCommand(name, options) {
30000
30163
  }))
30001
30164
  });
30002
30165
  if (!response2.environment) {
30003
- console.log(import_chalk15.default.yellow("\nCancelled."));
30166
+ console.log(import_chalk16.default.yellow("\nCancelled."));
30004
30167
  return;
30005
30168
  }
30006
30169
  selectedEnvironmentId = response2.environment;
@@ -30013,7 +30176,7 @@ async function replicaCreateCommand(name, options) {
30013
30176
  validate: (value) => value.trim() ? true : "Message is required"
30014
30177
  });
30015
30178
  if (!response2.message) {
30016
- console.log(import_chalk15.default.yellow("\nCancelled."));
30179
+ console.log(import_chalk16.default.yellow("\nCancelled."));
30017
30180
  return;
30018
30181
  }
30019
30182
  message = response2.message;
@@ -30027,7 +30190,7 @@ async function replicaCreateCommand(name, options) {
30027
30190
  initial: 0
30028
30191
  });
30029
30192
  if (!response2.agent) {
30030
- console.log(import_chalk15.default.yellow("\nCancelled."));
30193
+ console.log(import_chalk16.default.yellow("\nCancelled."));
30031
30194
  return;
30032
30195
  }
30033
30196
  codingAgent = parseReplicaAgent(response2.agent);
@@ -30038,28 +30201,28 @@ async function replicaCreateCommand(name, options) {
30038
30201
  environment_id: selectedEnvironmentId,
30039
30202
  coding_agent: codingAgent
30040
30203
  };
30041
- console.log(import_chalk15.default.gray("\nCreating replica..."));
30204
+ console.log(import_chalk16.default.gray("\nCreating replica..."));
30042
30205
  const response = await orgAuthenticatedFetch("/v1/replica", {
30043
30206
  method: "POST",
30044
30207
  body
30045
30208
  });
30046
30209
  const replica = response.replica;
30047
- console.log(import_chalk15.default.green(`
30210
+ console.log(import_chalk16.default.green(`
30048
30211
  Created replica: ${replica.name}`));
30049
- console.log(import_chalk15.default.gray(` ID: ${replica.id}`));
30050
- console.log(import_chalk15.default.gray(` Status: ${formatStatus(replica.status)}`));
30212
+ console.log(import_chalk16.default.gray(` ID: ${replica.id}`));
30213
+ console.log(import_chalk16.default.gray(` Status: ${formatStatus(replica.status)}`));
30051
30214
  if (replica.repositories.length > 0) {
30052
- console.log(import_chalk15.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
30215
+ console.log(import_chalk16.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
30053
30216
  }
30054
30217
  console.log();
30055
30218
  } catch (error51) {
30056
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30219
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30057
30220
  process.exit(1);
30058
30221
  }
30059
30222
  }
30060
30223
  async function replicaSendCommand(id, options) {
30061
30224
  if (!isAuthenticated()) {
30062
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30225
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
30063
30226
  process.exit(1);
30064
30227
  }
30065
30228
  try {
@@ -30072,7 +30235,7 @@ async function replicaSendCommand(id, options) {
30072
30235
  validate: (value) => value.trim() ? true : "Message is required"
30073
30236
  });
30074
30237
  if (!response2.message) {
30075
- console.log(import_chalk15.default.yellow("\nCancelled."));
30238
+ console.log(import_chalk16.default.yellow("\nCancelled."));
30076
30239
  return;
30077
30240
  }
30078
30241
  message = response2.message;
@@ -30090,21 +30253,21 @@ async function replicaSendCommand(id, options) {
30090
30253
  body
30091
30254
  }
30092
30255
  );
30093
- const statusColor = response.status === "sent" ? import_chalk15.default.green : import_chalk15.default.yellow;
30256
+ const statusColor = response.status === "sent" ? import_chalk16.default.green : import_chalk16.default.yellow;
30094
30257
  console.log(statusColor(`
30095
30258
  Message ${response.status}`));
30096
30259
  if (response.position !== void 0 && response.position > 0) {
30097
- console.log(import_chalk15.default.gray(` Queue position: ${response.position}`));
30260
+ console.log(import_chalk16.default.gray(` Queue position: ${response.position}`));
30098
30261
  }
30099
30262
  console.log();
30100
30263
  } catch (error51) {
30101
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30264
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30102
30265
  process.exit(1);
30103
30266
  }
30104
30267
  }
30105
30268
  async function replicaDeleteCommand(id, options) {
30106
30269
  if (!isAuthenticated()) {
30107
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30270
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
30108
30271
  process.exit(1);
30109
30272
  }
30110
30273
  try {
@@ -30116,24 +30279,24 @@ async function replicaDeleteCommand(id, options) {
30116
30279
  initial: false
30117
30280
  });
30118
30281
  if (!response.confirm) {
30119
- console.log(import_chalk15.default.yellow("\nCancelled."));
30282
+ console.log(import_chalk16.default.yellow("\nCancelled."));
30120
30283
  return;
30121
30284
  }
30122
30285
  }
30123
30286
  await orgAuthenticatedFetch(`/v1/replica/${id}`, {
30124
30287
  method: "DELETE"
30125
30288
  });
30126
- console.log(import_chalk15.default.green(`
30289
+ console.log(import_chalk16.default.green(`
30127
30290
  Replica ${id} deleted.
30128
30291
  `));
30129
30292
  } catch (error51) {
30130
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30293
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30131
30294
  process.exit(1);
30132
30295
  }
30133
30296
  }
30134
30297
  async function replicaReadCommand(id, options) {
30135
30298
  if (!isAuthenticated()) {
30136
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
30299
+ console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
30137
30300
  process.exit(1);
30138
30301
  }
30139
30302
  try {
@@ -30145,53 +30308,53 @@ async function replicaReadCommand(id, options) {
30145
30308
  `/v1/replica/${id}/read${query ? "?" + query : ""}`
30146
30309
  );
30147
30310
  if (response.waking) {
30148
- console.log(import_chalk15.default.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
30311
+ console.log(import_chalk16.default.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
30149
30312
  return;
30150
30313
  }
30151
- console.log(import_chalk15.default.green(`
30314
+ console.log(import_chalk16.default.green(`
30152
30315
  Conversation History
30153
30316
  `));
30154
30317
  if (response.coding_agent) {
30155
- console.log(import_chalk15.default.gray(` Agent: ${response.coding_agent}`));
30318
+ console.log(import_chalk16.default.gray(` Agent: ${response.coding_agent}`));
30156
30319
  }
30157
30320
  if (response.thread_id) {
30158
- console.log(import_chalk15.default.gray(` Thread ID: ${response.thread_id}`));
30321
+ console.log(import_chalk16.default.gray(` Thread ID: ${response.thread_id}`));
30159
30322
  }
30160
- console.log(import_chalk15.default.gray(` Total Events: ${response.total}`));
30161
- console.log(import_chalk15.default.gray(` Showing: ${response.events.length} events`));
30323
+ console.log(import_chalk16.default.gray(` Total Events: ${response.total}`));
30324
+ console.log(import_chalk16.default.gray(` Showing: ${response.events.length} events`));
30162
30325
  if (response.has_more) {
30163
- console.log(import_chalk15.default.gray(` Has More: yes (--before-event ${response.eventsStartIndex} for the previous page)`));
30326
+ console.log(import_chalk16.default.gray(` Has More: yes (--before-event ${response.eventsStartIndex} for the previous page)`));
30164
30327
  }
30165
30328
  console.log();
30166
30329
  if (response.events.length === 0) {
30167
- console.log(import_chalk15.default.yellow(" No events found.\n"));
30330
+ console.log(import_chalk16.default.yellow(" No events found.\n"));
30168
30331
  return;
30169
30332
  }
30170
- console.log(import_chalk15.default.gray("-".repeat(60)));
30333
+ console.log(import_chalk16.default.gray("-".repeat(60)));
30171
30334
  const agentType = response.coding_agent || "claude";
30172
30335
  const displayMessages = parseDisplayMessages(response.events, agentType);
30173
30336
  for (const message of displayMessages) {
30174
30337
  formatDisplayMessage(message);
30175
30338
  }
30176
- console.log(import_chalk15.default.gray("\n" + "-".repeat(60)));
30339
+ console.log(import_chalk16.default.gray("\n" + "-".repeat(60)));
30177
30340
  console.log();
30178
30341
  } catch (error51) {
30179
- console.error(import_chalk15.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30342
+ console.error(import_chalk16.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30180
30343
  process.exit(1);
30181
30344
  }
30182
30345
  }
30183
30346
 
30184
30347
  // src/commands/repositories.ts
30185
- var import_chalk17 = __toESM(require("chalk"));
30348
+ var import_chalk18 = __toESM(require("chalk"));
30186
30349
 
30187
30350
  // src/lib/command-utils.ts
30188
- var import_chalk16 = __toESM(require("chalk"));
30351
+ var import_chalk17 = __toESM(require("chalk"));
30189
30352
  function formatDate2(dateString) {
30190
30353
  return new Date(dateString).toLocaleString();
30191
30354
  }
30192
30355
  function ensureOrgApiAuthenticated() {
30193
30356
  if (!canCallOrgApi()) {
30194
- console.log(import_chalk16.default.red('Not logged in. Please run "replicas login" first.'));
30357
+ console.log(import_chalk17.default.red('Not logged in. Please run "replicas login" first.'));
30195
30358
  process.exit(1);
30196
30359
  }
30197
30360
  }
@@ -30205,36 +30368,36 @@ async function repositoriesListCommand() {
30205
30368
  try {
30206
30369
  const response = await orgAuthenticatedFetch("/v1/repositories");
30207
30370
  if (response.repositories.length === 0) {
30208
- console.log(import_chalk17.default.yellow("\nNo repositories found.\n"));
30371
+ console.log(import_chalk18.default.yellow("\nNo repositories found.\n"));
30209
30372
  return;
30210
30373
  }
30211
- console.log(import_chalk17.default.green(`
30374
+ console.log(import_chalk18.default.green(`
30212
30375
  Repositories (${response.repositories.length}):
30213
30376
  `));
30214
30377
  for (const repo of response.repositories) {
30215
- console.log(import_chalk17.default.white(` ${repo.name}`));
30216
- console.log(import_chalk17.default.gray(` URL: ${repo.url}`));
30217
- console.log(import_chalk17.default.gray(` Default Branch: ${repo.default_branch}`));
30218
- console.log(import_chalk17.default.gray(` Created: ${formatDate2(repo.created_at)}`));
30378
+ console.log(import_chalk18.default.white(` ${repo.name}`));
30379
+ console.log(import_chalk18.default.gray(` URL: ${repo.url}`));
30380
+ console.log(import_chalk18.default.gray(` Default Branch: ${repo.default_branch}`));
30381
+ console.log(import_chalk18.default.gray(` Created: ${formatDate2(repo.created_at)}`));
30219
30382
  if (repo.github_repository_id) {
30220
- console.log(import_chalk17.default.gray(` GitHub ID: ${repo.github_repository_id}`));
30383
+ console.log(import_chalk18.default.gray(` GitHub ID: ${repo.github_repository_id}`));
30221
30384
  }
30222
30385
  console.log();
30223
30386
  }
30224
30387
  } catch (error51) {
30225
- console.error(import_chalk17.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30388
+ console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30226
30389
  process.exit(1);
30227
30390
  }
30228
30391
  }
30229
30392
 
30230
30393
  // src/commands/automation.ts
30231
- var import_chalk18 = __toESM(require("chalk"));
30394
+ var import_chalk19 = __toESM(require("chalk"));
30232
30395
  var import_prompts7 = __toESM(require("prompts"));
30233
30396
  function parseScopeFilter(value) {
30234
30397
  if (!value) return void 0;
30235
30398
  if (value === "org" || value === "user" || value === "all") return value;
30236
- console.log(import_chalk18.default.red(`Invalid --owner: ${value}`));
30237
- console.log(import_chalk18.default.gray("Valid options: org, user, all"));
30399
+ console.log(import_chalk19.default.red(`Invalid --owner: ${value}`));
30400
+ console.log(import_chalk19.default.gray("Valid options: org, user, all"));
30238
30401
  process.exit(1);
30239
30402
  }
30240
30403
  function parseAgentProviderOption(value) {
@@ -30243,8 +30406,8 @@ function parseAgentProviderOption(value) {
30243
30406
  if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
30244
30407
  const lower = trimmed.toLowerCase();
30245
30408
  if (!isValidAgentProvider(lower)) {
30246
- console.log(import_chalk18.default.red(`Invalid --agent-provider: ${value}`));
30247
- console.log(import_chalk18.default.gray(`Valid options: ${VALID_AGENT_PROVIDERS.join(", ")}, none`));
30409
+ console.log(import_chalk19.default.red(`Invalid --agent-provider: ${value}`));
30410
+ console.log(import_chalk19.default.gray(`Valid options: ${VALID_AGENT_PROVIDERS.join(", ")}, none`));
30248
30411
  process.exit(1);
30249
30412
  }
30250
30413
  return lower;
@@ -30255,8 +30418,8 @@ function parseThinkingLevelOption(value) {
30255
30418
  if (trimmed === "" || trimmed.toLowerCase() === "none") return null;
30256
30419
  const lower = trimmed.toLowerCase();
30257
30420
  if (!isValidThinkingLevel(lower)) {
30258
- console.log(import_chalk18.default.red(`Invalid --thinking-level: ${value}`));
30259
- console.log(import_chalk18.default.gray(`Valid options: ${VALID_THINKING_LEVELS.join(", ")}, none`));
30421
+ console.log(import_chalk19.default.red(`Invalid --thinking-level: ${value}`));
30422
+ console.log(import_chalk19.default.gray(`Valid options: ${VALID_THINKING_LEVELS.join(", ")}, none`));
30260
30423
  process.exit(1);
30261
30424
  }
30262
30425
  return lower;
@@ -30273,8 +30436,8 @@ function isAutomationLifecyclePolicy(value) {
30273
30436
  function parseWorkspaceLifecyclePolicyOption(value) {
30274
30437
  if (!value) return void 0;
30275
30438
  if (isAutomationLifecyclePolicy(value)) return value;
30276
- console.log(import_chalk18.default.red(`Invalid lifecycle policy: ${value}`));
30277
- console.log(import_chalk18.default.gray(`Valid options: ${AUTOMATION_LIFECYCLE_POLICIES.join(", ")}`));
30439
+ console.log(import_chalk19.default.red(`Invalid lifecycle policy: ${value}`));
30440
+ console.log(import_chalk19.default.gray(`Valid options: ${AUTOMATION_LIFECYCLE_POLICIES.join(", ")}`));
30278
30441
  process.exit(1);
30279
30442
  }
30280
30443
  function parseExcludedActorsOption(value) {
@@ -30293,7 +30456,7 @@ function withExcludedActors(config3, excludedActors) {
30293
30456
  }
30294
30457
  function parseAutomationLifecycleOptions(options) {
30295
30458
  if (options.sleepWhenDone && options.lifecycle && options.lifecycle !== "sleep_when_done") {
30296
- console.log(import_chalk18.default.red("--sleep-when-done cannot be combined with a different --lifecycle value"));
30459
+ console.log(import_chalk19.default.red("--sleep-when-done cannot be combined with a different --lifecycle value"));
30297
30460
  process.exit(1);
30298
30461
  }
30299
30462
  if (options.sleepWhenDone) return "sleep_when_done";
@@ -30302,7 +30465,7 @@ function parseAutomationLifecycleOptions(options) {
30302
30465
  function applyAgentSelection(body, existing) {
30303
30466
  const result = validateAgentSelection(body, existing);
30304
30467
  if (!result.ok) {
30305
- console.log(import_chalk18.default.red(result.error.message));
30468
+ console.log(import_chalk19.default.red(result.error.message));
30306
30469
  process.exit(1);
30307
30470
  }
30308
30471
  const out = {};
@@ -30343,8 +30506,8 @@ function resolveTriggerRepositoryIds(repositories, repoNamesInput, provider) {
30343
30506
  for (const repoName of repoNames) {
30344
30507
  const repo = providerRepos.find((r) => r.name === repoName);
30345
30508
  if (!repo) {
30346
- console.log(import_chalk18.default.red(`Repository not found for ${provider} trigger filter: ${repoName}`));
30347
- console.log(import_chalk18.default.gray(`Available: ${providerRepos.map((r) => r.name).join(", ")}`));
30509
+ console.log(import_chalk19.default.red(`Repository not found for ${provider} trigger filter: ${repoName}`));
30510
+ console.log(import_chalk19.default.gray(`Available: ${providerRepos.map((r) => r.name).join(", ")}`));
30348
30511
  process.exit(1);
30349
30512
  }
30350
30513
  repoIds.push(repo.id);
@@ -30377,43 +30540,43 @@ function formatModeSummary(automation2) {
30377
30540
  function resolveSelectableEnvironmentId(envInput, selectableEnvs) {
30378
30541
  const resolved = resolveByNameOrId(envInput, selectableEnvs);
30379
30542
  if (!resolved) {
30380
- console.log(import_chalk18.default.red(`Environment not found: ${envInput}`));
30543
+ console.log(import_chalk19.default.red(`Environment not found: ${envInput}`));
30381
30544
  const available = selectableEnvs.map((e) => e.name).join(", ");
30382
- console.log(import_chalk18.default.gray(`Available: ${available || "(none)"}`));
30545
+ console.log(import_chalk19.default.gray(`Available: ${available || "(none)"}`));
30383
30546
  process.exit(1);
30384
30547
  }
30385
30548
  return resolved.id;
30386
30549
  }
30387
30550
  function printAutomation(automation2) {
30388
- console.log(import_chalk18.default.white(` ${automation2.name}`));
30389
- console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
30390
- console.log(import_chalk18.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
30551
+ console.log(import_chalk19.default.white(` ${automation2.name}`));
30552
+ console.log(import_chalk19.default.gray(` ID: ${automation2.id}`));
30553
+ console.log(import_chalk19.default.gray(` Owner: ${automation2.user_id ? "personal" : "organization"}`));
30391
30554
  if (automation2.description) {
30392
- console.log(import_chalk18.default.gray(` Description: ${automation2.description}`));
30555
+ console.log(import_chalk19.default.gray(` Description: ${automation2.description}`));
30393
30556
  }
30394
- console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? import_chalk18.default.green("yes") : import_chalk18.default.red("no")}`));
30557
+ console.log(import_chalk19.default.gray(` Enabled: ${automation2.enabled ? import_chalk19.default.green("yes") : import_chalk19.default.red("no")}`));
30395
30558
  if (automation2.triggers.length > 0) {
30396
- console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30559
+ console.log(import_chalk19.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30397
30560
  }
30398
30561
  if (automation2.github_check_names.length > 0) {
30399
- console.log(import_chalk18.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
30562
+ console.log(import_chalk19.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
30400
30563
  }
30401
- console.log(import_chalk18.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
30564
+ console.log(import_chalk19.default.gray(` Prompt: ${truncate2(automation2.prompt, 80)}`));
30402
30565
  if (automation2.cron_next_fire_at) {
30403
- console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30566
+ console.log(import_chalk19.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30404
30567
  }
30405
30568
  if (automation2.workspace_lifecycle_policy && automation2.workspace_lifecycle_policy !== "default") {
30406
- console.log(import_chalk18.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
30569
+ console.log(import_chalk19.default.gray(` Lifecycle: ${automation2.workspace_lifecycle_policy}`));
30407
30570
  }
30408
30571
  if (automation2.agent_provider || automation2.model || automation2.thinking_level) {
30409
- console.log(import_chalk18.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
30572
+ console.log(import_chalk19.default.gray(` Agent: ${formatAgentSummary(automation2)}`));
30410
30573
  }
30411
30574
  if (automation2.plan_mode || automation2.goal_mode || automation2.fast_mode) {
30412
- console.log(import_chalk18.default.gray(` Modes: ${formatModeSummary(automation2)}`));
30575
+ console.log(import_chalk19.default.gray(` Modes: ${formatModeSummary(automation2)}`));
30413
30576
  }
30414
- console.log(import_chalk18.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk18.default.green("managed") : "read-only"}`));
30415
- console.log(import_chalk18.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
30416
- console.log(import_chalk18.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
30577
+ console.log(import_chalk19.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? import_chalk19.default.green("managed") : "read-only"}`));
30578
+ console.log(import_chalk19.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
30579
+ console.log(import_chalk19.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
30417
30580
  console.log();
30418
30581
  }
30419
30582
  async function automationListCommand(options) {
@@ -30432,17 +30595,17 @@ async function automationListCommand(options) {
30432
30595
  `/v1/automations${query ? "?" + query : ""}`
30433
30596
  );
30434
30597
  if (response.automations.length === 0) {
30435
- console.log(import_chalk18.default.yellow("\nNo automations found.\n"));
30598
+ console.log(import_chalk19.default.yellow("\nNo automations found.\n"));
30436
30599
  return;
30437
30600
  }
30438
- console.log(import_chalk18.default.green(`
30601
+ console.log(import_chalk19.default.green(`
30439
30602
  Automations (Page ${response.page} of ${response.totalPages}, Total: ${response.total}):
30440
30603
  `));
30441
30604
  for (const automation2 of response.automations) {
30442
30605
  printAutomation(automation2);
30443
30606
  }
30444
30607
  } catch (error51) {
30445
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30608
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30446
30609
  process.exit(1);
30447
30610
  }
30448
30611
  }
@@ -30451,50 +30614,50 @@ async function automationGetCommand(id) {
30451
30614
  try {
30452
30615
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`);
30453
30616
  const automation2 = response.automation;
30454
- console.log(import_chalk18.default.green(`
30617
+ console.log(import_chalk19.default.green(`
30455
30618
  Automation: ${automation2.name}
30456
30619
  `));
30457
- console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
30620
+ console.log(import_chalk19.default.gray(` ID: ${automation2.id}`));
30458
30621
  if (automation2.description) {
30459
- console.log(import_chalk18.default.gray(` Description: ${automation2.description}`));
30622
+ console.log(import_chalk19.default.gray(` Description: ${automation2.description}`));
30460
30623
  }
30461
- console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? import_chalk18.default.green("yes") : import_chalk18.default.red("no")}`));
30624
+ console.log(import_chalk19.default.gray(` Enabled: ${automation2.enabled ? import_chalk19.default.green("yes") : import_chalk19.default.red("no")}`));
30462
30625
  if (automation2.triggers.length > 0) {
30463
- console.log(import_chalk18.default.gray(` Triggers:`));
30626
+ console.log(import_chalk19.default.gray(` Triggers:`));
30464
30627
  for (const trigger of automation2.triggers) {
30465
- console.log(import_chalk18.default.gray(` - ${formatTrigger(trigger)}`));
30628
+ console.log(import_chalk19.default.gray(` - ${formatTrigger(trigger)}`));
30466
30629
  }
30467
30630
  }
30468
30631
  if (automation2.github_check_names.length > 0) {
30469
- console.log(import_chalk18.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
30632
+ console.log(import_chalk19.default.gray(` GitHub checks: ${automation2.github_check_names.join(", ")}`));
30470
30633
  }
30471
- console.log(import_chalk18.default.gray(` Prompt: ${automation2.prompt}`));
30472
- console.log(import_chalk18.default.gray(` Environment: ${automation2.environment_id}`));
30634
+ console.log(import_chalk19.default.gray(` Prompt: ${automation2.prompt}`));
30635
+ console.log(import_chalk19.default.gray(` Environment: ${automation2.environment_id}`));
30473
30636
  if (automation2.cron_expression) {
30474
- console.log(import_chalk18.default.gray(` Cron: ${automation2.cron_expression}`));
30637
+ console.log(import_chalk19.default.gray(` Cron: ${automation2.cron_expression}`));
30475
30638
  }
30476
30639
  if (automation2.cron_timezone) {
30477
- console.log(import_chalk18.default.gray(` Timezone: ${automation2.cron_timezone}`));
30640
+ console.log(import_chalk19.default.gray(` Timezone: ${automation2.cron_timezone}`));
30478
30641
  }
30479
30642
  if (automation2.cron_next_fire_at) {
30480
- console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30643
+ console.log(import_chalk19.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30481
30644
  }
30482
30645
  if (automation2.workspace_lifecycle_policy) {
30483
- console.log(import_chalk18.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
30646
+ console.log(import_chalk19.default.gray(` Lifecycle Policy: ${automation2.workspace_lifecycle_policy}`));
30484
30647
  }
30485
30648
  if (automation2.workspace_auto_stop_minutes) {
30486
- console.log(import_chalk18.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
30487
- }
30488
- console.log(import_chalk18.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
30489
- console.log(import_chalk18.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
30490
- console.log(import_chalk18.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
30491
- console.log(import_chalk18.default.gray(` Modes: ${formatModeSummary(automation2)}`));
30492
- console.log(import_chalk18.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
30493
- console.log(import_chalk18.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
30494
- console.log(import_chalk18.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
30649
+ console.log(import_chalk19.default.gray(` Auto-stop: ${automation2.workspace_auto_stop_minutes} minutes`));
30650
+ }
30651
+ console.log(import_chalk19.default.gray(` Agent: ${automation2.agent_provider ? getProviderDisplayName(automation2.agent_provider) : "organization default"}`));
30652
+ console.log(import_chalk19.default.gray(` Model: ${automation2.model ? MODEL_LABELS[automation2.model] ?? automation2.model : "agent default"}`));
30653
+ console.log(import_chalk19.default.gray(` Thinking Level: ${automation2.thinking_level ?? "agent default"}`));
30654
+ console.log(import_chalk19.default.gray(` Modes: ${formatModeSummary(automation2)}`));
30655
+ console.log(import_chalk19.default.gray(` PR Follow-ups: ${automation2.config.capabilities?.pr_followups === true ? "managed" : "read-only"}`));
30656
+ console.log(import_chalk19.default.gray(` Created: ${formatDate2(automation2.created_at)}`));
30657
+ console.log(import_chalk19.default.gray(` Updated: ${formatDate2(automation2.updated_at)}`));
30495
30658
  console.log();
30496
30659
  } catch (error51) {
30497
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30660
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30498
30661
  process.exit(1);
30499
30662
  }
30500
30663
  }
@@ -30619,22 +30782,22 @@ async function automationCreateCommand(name, options) {
30619
30782
  ensureOrgApiAuthenticated();
30620
30783
  const lifecyclePolicy = parseAutomationLifecycleOptions(options);
30621
30784
  if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(lifecyclePolicy ?? "default")) {
30622
- console.log(import_chalk18.default.red("--auto-stop-minutes requires --lifecycle default"));
30785
+ console.log(import_chalk19.default.red("--auto-stop-minutes requires --lifecycle default"));
30623
30786
  process.exit(1);
30624
30787
  }
30625
30788
  if (options.autoStopMinutes) {
30626
30789
  const minutes = parseInt(options.autoStopMinutes, 10);
30627
30790
  if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
30628
- console.log(import_chalk18.default.red("--auto-stop-minutes must be between 3 and 1440"));
30791
+ console.log(import_chalk19.default.red("--auto-stop-minutes must be between 3 and 1440"));
30629
30792
  process.exit(1);
30630
30793
  }
30631
30794
  }
30632
30795
  if (options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
30633
- console.log(import_chalk18.default.red("--trigger-github-exclude-users requires --trigger-github"));
30796
+ console.log(import_chalk19.default.red("--trigger-github-exclude-users requires --trigger-github"));
30634
30797
  process.exit(1);
30635
30798
  }
30636
30799
  if (options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
30637
- console.log(import_chalk18.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab"));
30800
+ console.log(import_chalk19.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab"));
30638
30801
  process.exit(1);
30639
30802
  }
30640
30803
  const hasConfirmation = options.confirmationChannel || options.confirmationThread || options.confirmationMessageTs || options.confirmationUser;
@@ -30661,7 +30824,7 @@ async function automationCreateCommand(name, options) {
30661
30824
  );
30662
30825
  const selectableEnvs = envResponse.environments;
30663
30826
  if (selectableEnvs.length === 0) {
30664
- console.log(import_chalk18.default.red("No environments found. Please create an environment first."));
30827
+ console.log(import_chalk19.default.red("No environments found. Please create an environment first."));
30665
30828
  process.exit(1);
30666
30829
  }
30667
30830
  const repoResponse = await orgAuthenticatedFetch("/v1/repositories");
@@ -30675,7 +30838,7 @@ async function automationCreateCommand(name, options) {
30675
30838
  validate: (value) => value.trim() ? true : "Name is required"
30676
30839
  });
30677
30840
  if (!response2.name) {
30678
- console.log(import_chalk18.default.yellow("\nCancelled."));
30841
+ console.log(import_chalk19.default.yellow("\nCancelled."));
30679
30842
  return;
30680
30843
  }
30681
30844
  automationName = response2.name;
@@ -30689,7 +30852,7 @@ async function automationCreateCommand(name, options) {
30689
30852
  validate: (value) => value.trim() ? true : "Prompt is required"
30690
30853
  });
30691
30854
  if (!response2.prompt) {
30692
- console.log(import_chalk18.default.yellow("\nCancelled."));
30855
+ console.log(import_chalk19.default.yellow("\nCancelled."));
30693
30856
  return;
30694
30857
  }
30695
30858
  automationPrompt = response2.prompt;
@@ -30709,7 +30872,7 @@ async function automationCreateCommand(name, options) {
30709
30872
  }))
30710
30873
  });
30711
30874
  if (!envResponse2.env) {
30712
- console.log(import_chalk18.default.yellow("\nCancelled."));
30875
+ console.log(import_chalk19.default.yellow("\nCancelled."));
30713
30876
  return;
30714
30877
  }
30715
30878
  selectedEnvironmentId = envResponse2.env;
@@ -30751,7 +30914,7 @@ async function automationCreateCommand(name, options) {
30751
30914
  if (triggers.length === 0) {
30752
30915
  triggers = await promptForTriggers(repositories.map((r) => ({ id: r.id, name: r.name, provider: r.provider })));
30753
30916
  if (triggers.length === 0) {
30754
- console.log(import_chalk18.default.red("At least one trigger is required."));
30917
+ console.log(import_chalk19.default.red("At least one trigger is required."));
30755
30918
  process.exit(1);
30756
30919
  }
30757
30920
  }
@@ -30782,25 +30945,25 @@ async function automationCreateCommand(name, options) {
30782
30945
  ...agentSelection,
30783
30946
  ...mothershipConfirmation ? { mothership_confirmation: mothershipConfirmation } : {}
30784
30947
  };
30785
- console.log(import_chalk18.default.gray("\nCreating automation..."));
30948
+ console.log(import_chalk19.default.gray("\nCreating automation..."));
30786
30949
  const response = await orgAuthenticatedFetch("/v1/automations", {
30787
30950
  method: "POST",
30788
30951
  body
30789
30952
  });
30790
30953
  const automation2 = response.automation;
30791
- console.log(import_chalk18.default.green(`
30954
+ console.log(import_chalk19.default.green(`
30792
30955
  Created automation: ${automation2.name}`));
30793
- console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
30794
- console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
30956
+ console.log(import_chalk19.default.gray(` ID: ${automation2.id}`));
30957
+ console.log(import_chalk19.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
30795
30958
  if (automation2.triggers.length > 0) {
30796
- console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30959
+ console.log(import_chalk19.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
30797
30960
  }
30798
30961
  if (automation2.cron_next_fire_at) {
30799
- console.log(import_chalk18.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30962
+ console.log(import_chalk19.default.gray(` Next Run: ${formatDate2(automation2.cron_next_fire_at)}`));
30800
30963
  }
30801
30964
  console.log();
30802
30965
  } catch (error51) {
30803
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30966
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
30804
30967
  process.exit(1);
30805
30968
  }
30806
30969
  }
@@ -30810,17 +30973,17 @@ async function automationEditCommand(id, options) {
30810
30973
  if (options.autoStopMinutes) {
30811
30974
  const minutes = parseInt(options.autoStopMinutes, 10);
30812
30975
  if (isNaN(minutes) || minutes < 3 || minutes > 1440) {
30813
- console.log(import_chalk18.default.red("--auto-stop-minutes must be between 3 and 1440"));
30976
+ console.log(import_chalk19.default.red("--auto-stop-minutes must be between 3 and 1440"));
30814
30977
  process.exit(1);
30815
30978
  }
30816
30979
  }
30817
30980
  const replacingTriggers = Boolean(options.triggerCron || options.triggerGithub || options.triggerGitlab);
30818
30981
  if (replacingTriggers && options.triggerGithubExcludeUsers !== void 0 && !options.triggerGithub) {
30819
- console.log(import_chalk18.default.red("--trigger-github-exclude-users requires --trigger-github when replacing triggers"));
30982
+ console.log(import_chalk19.default.red("--trigger-github-exclude-users requires --trigger-github when replacing triggers"));
30820
30983
  process.exit(1);
30821
30984
  }
30822
30985
  if (replacingTriggers && options.triggerGitlabExcludeUsers !== void 0 && !options.triggerGitlab) {
30823
- console.log(import_chalk18.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab when replacing triggers"));
30986
+ console.log(import_chalk19.default.red("--trigger-gitlab-exclude-users requires --trigger-gitlab when replacing triggers"));
30824
30987
  process.exit(1);
30825
30988
  }
30826
30989
  const parsedAgent = {
@@ -30832,7 +30995,7 @@ async function automationEditCommand(id, options) {
30832
30995
  const existing = await orgAuthenticatedFetch(`/v1/automations/${id}`);
30833
30996
  const autoStopLifecyclePolicy = lifecyclePolicy ?? toAutomationLifecyclePolicy(existing.automation.workspace_lifecycle_policy);
30834
30997
  if (options.autoStopMinutes && !lifecyclePolicySupportsAutoStop(autoStopLifecyclePolicy)) {
30835
- console.log(import_chalk18.default.red("--auto-stop-minutes requires --lifecycle default"));
30998
+ console.log(import_chalk19.default.red("--auto-stop-minutes requires --lifecycle default"));
30836
30999
  process.exit(1);
30837
31000
  }
30838
31001
  const agentSelection = applyAgentSelection(parsedAgent, {
@@ -30972,11 +31135,11 @@ async function automationEditCommand(id, options) {
30972
31135
  return trigger;
30973
31136
  });
30974
31137
  if (!matchedGithub) {
30975
- console.log(import_chalk18.default.red("No existing GitHub trigger found. Pass --trigger-github to create one."));
31138
+ console.log(import_chalk19.default.red("No existing GitHub trigger found. Pass --trigger-github to create one."));
30976
31139
  process.exit(1);
30977
31140
  }
30978
31141
  if (!matchedGitlab) {
30979
- console.log(import_chalk18.default.red("No existing GitLab trigger found. Pass --trigger-gitlab to create one."));
31142
+ console.log(import_chalk19.default.red("No existing GitLab trigger found. Pass --trigger-gitlab to create one."));
30980
31143
  process.exit(1);
30981
31144
  }
30982
31145
  }
@@ -31001,25 +31164,25 @@ async function automationEditCommand(id, options) {
31001
31164
  Object.assign(body, agentSelection);
31002
31165
  }
31003
31166
  if (Object.keys(body).length === 0) {
31004
- console.log(import_chalk18.default.yellow("\nNo changes made.\n"));
31167
+ console.log(import_chalk19.default.yellow("\nNo changes made.\n"));
31005
31168
  return;
31006
31169
  }
31007
- console.log(import_chalk18.default.gray("\nUpdating automation..."));
31170
+ console.log(import_chalk19.default.gray("\nUpdating automation..."));
31008
31171
  const response = await orgAuthenticatedFetch(`/v1/automations/${id}`, {
31009
31172
  method: "PATCH",
31010
31173
  body
31011
31174
  });
31012
31175
  const automation2 = response.automation;
31013
- console.log(import_chalk18.default.green(`
31176
+ console.log(import_chalk19.default.green(`
31014
31177
  Updated automation: ${automation2.name}`));
31015
- console.log(import_chalk18.default.gray(` ID: ${automation2.id}`));
31016
- console.log(import_chalk18.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
31178
+ console.log(import_chalk19.default.gray(` ID: ${automation2.id}`));
31179
+ console.log(import_chalk19.default.gray(` Enabled: ${automation2.enabled ? "yes" : "no"}`));
31017
31180
  if (automation2.triggers.length > 0) {
31018
- console.log(import_chalk18.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
31181
+ console.log(import_chalk19.default.gray(` Triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
31019
31182
  }
31020
31183
  console.log();
31021
31184
  } catch (error51) {
31022
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31185
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31023
31186
  process.exit(1);
31024
31187
  }
31025
31188
  }
@@ -31030,12 +31193,12 @@ async function automationRunCommand(id) {
31030
31193
  const automation2 = existing.automation;
31031
31194
  const hasCronTrigger = automation2.triggers.some((t) => t.type === "cron");
31032
31195
  if (!hasCronTrigger) {
31033
- console.log(import_chalk18.default.red("\nManual run is only allowed for automations with a cron trigger."));
31034
- console.log(import_chalk18.default.gray(`This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
31196
+ console.log(import_chalk19.default.red("\nManual run is only allowed for automations with a cron trigger."));
31197
+ console.log(import_chalk19.default.gray(`This automation has triggers: ${automation2.triggers.map(formatTrigger).join(", ")}`));
31035
31198
  console.log();
31036
31199
  process.exit(1);
31037
31200
  }
31038
- console.log(import_chalk18.default.gray(`
31201
+ console.log(import_chalk19.default.gray(`
31039
31202
  Triggering automation "${automation2.name}"...`));
31040
31203
  const response = await orgAuthenticatedFetch(
31041
31204
  `/v1/automations/${id}/trigger`,
@@ -31045,20 +31208,20 @@ Triggering automation "${automation2.name}"...`));
31045
31208
  }
31046
31209
  );
31047
31210
  if (!response.execution_id) {
31048
- console.log(import_chalk18.default.red(`
31211
+ console.log(import_chalk19.default.red(`
31049
31212
  Automation trigger returned no execution ID. The automation may not have started.`));
31050
31213
  console.log();
31051
31214
  process.exit(1);
31052
31215
  }
31053
- console.log(import_chalk18.default.green(`
31216
+ console.log(import_chalk19.default.green(`
31054
31217
  Automation triggered successfully.`));
31055
- console.log(import_chalk18.default.gray(` Execution ID: ${response.execution_id}`));
31218
+ console.log(import_chalk19.default.gray(` Execution ID: ${response.execution_id}`));
31056
31219
  if (response.workspace_id) {
31057
- console.log(import_chalk18.default.gray(` Workspace ID: ${response.workspace_id}`));
31220
+ console.log(import_chalk19.default.gray(` Workspace ID: ${response.workspace_id}`));
31058
31221
  }
31059
31222
  console.log();
31060
31223
  } catch (error51) {
31061
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31224
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31062
31225
  process.exit(1);
31063
31226
  }
31064
31227
  }
@@ -31075,38 +31238,38 @@ async function automationDeleteCommand(id, options) {
31075
31238
  initial: false
31076
31239
  });
31077
31240
  if (!response.confirm) {
31078
- console.log(import_chalk18.default.yellow("\nCancelled."));
31241
+ console.log(import_chalk19.default.yellow("\nCancelled."));
31079
31242
  return;
31080
31243
  }
31081
31244
  }
31082
31245
  await orgAuthenticatedFetch(`/v1/automations/${id}`, {
31083
31246
  method: "DELETE"
31084
31247
  });
31085
- console.log(import_chalk18.default.green(`
31248
+ console.log(import_chalk19.default.green(`
31086
31249
  Automation "${automationName}" (${id}) deleted.
31087
31250
  `));
31088
31251
  } catch (error51) {
31089
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31252
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31090
31253
  process.exit(1);
31091
31254
  }
31092
31255
  }
31093
31256
  async function automationCheckCommand(checkRunId, options) {
31094
31257
  const id = Number(checkRunId);
31095
31258
  if (!Number.isSafeInteger(id)) {
31096
- console.error(import_chalk18.default.red("Error: check run ID must be an integer"));
31259
+ console.error(import_chalk19.default.red("Error: check run ID must be an integer"));
31097
31260
  process.exit(1);
31098
31261
  }
31099
31262
  if (!options.token) {
31100
- console.error(import_chalk18.default.red("Error: --token is required"));
31263
+ console.error(import_chalk19.default.red("Error: --token is required"));
31101
31264
  process.exit(1);
31102
31265
  }
31103
31266
  const { conclusion } = options;
31104
31267
  if (!isAutomationCheckConclusion(conclusion)) {
31105
- console.error(import_chalk18.default.red(`Error: --conclusion must be one of ${AUTOMATION_CHECK_CONCLUSIONS.join(", ")}`));
31268
+ console.error(import_chalk19.default.red(`Error: --conclusion must be one of ${AUTOMATION_CHECK_CONCLUSIONS.join(", ")}`));
31106
31269
  process.exit(1);
31107
31270
  }
31108
31271
  if (!options.title?.trim()) {
31109
- console.error(import_chalk18.default.red("Error: --title is required"));
31272
+ console.error(import_chalk19.default.red("Error: --title is required"));
31110
31273
  process.exit(1);
31111
31274
  }
31112
31275
  const body = {
@@ -31120,19 +31283,19 @@ async function automationCheckCommand(checkRunId, options) {
31120
31283
  `/v1/automations/checks/${id}`,
31121
31284
  { method: "POST", body }
31122
31285
  );
31123
- console.log(response.reported ? import_chalk18.default.green(`
31286
+ console.log(response.reported ? import_chalk19.default.green(`
31124
31287
  Reported ${conclusion} for "${response.name}".
31125
- `) : import_chalk18.default.yellow(`
31288
+ `) : import_chalk19.default.yellow(`
31126
31289
  Skipped "${response.name}" \u2014 a newer run of this automation owns it and will report the verdict.
31127
31290
  `));
31128
31291
  } catch (error51) {
31129
- console.error(import_chalk18.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31292
+ console.error(import_chalk19.default.red(`Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
31130
31293
  process.exit(1);
31131
31294
  }
31132
31295
  }
31133
31296
 
31134
31297
  // src/commands/preview.ts
31135
- var import_chalk19 = __toESM(require("chalk"));
31298
+ var import_chalk20 = __toESM(require("chalk"));
31136
31299
 
31137
31300
  // src/lib/agent-api.ts
31138
31301
  var ENGINE_PORT = process.env.REPLICAS_ENGINE_PORT || "3737";
@@ -31226,11 +31389,11 @@ async function previewListCommand(workspaceId) {
31226
31389
  `/v1/workspaces/${workspaceId}/previews`
31227
31390
  );
31228
31391
  if (result.previews.length === 0) {
31229
- console.log(import_chalk19.default.dim("No active previews"));
31392
+ console.log(import_chalk20.default.dim("No active previews"));
31230
31393
  return;
31231
31394
  }
31232
31395
  for (const preview2 of result.previews) {
31233
- console.log(` ${import_chalk19.default.cyan(String(preview2.port))} \u2192 ${import_chalk19.default.underline(preview2.publicUrl)}`);
31396
+ console.log(` ${import_chalk20.default.cyan(String(preview2.port))} \u2192 ${import_chalk20.default.underline(preview2.publicUrl)}`);
31234
31397
  }
31235
31398
  }
31236
31399
  }
@@ -31243,7 +31406,7 @@ async function previewAddCommand(workspaceId, options) {
31243
31406
  body: { port: portNum, authenticated: options.authenticated ?? false }
31244
31407
  }
31245
31408
  );
31246
- console.log(import_chalk19.default.green(`Preview created: ${result.preview.publicUrl}`));
31409
+ console.log(import_chalk20.default.green(`Preview created: ${result.preview.publicUrl}`));
31247
31410
  }
31248
31411
  async function previewDeleteCommand(port) {
31249
31412
  const portNum = parsePreviewPort(port);
@@ -31256,7 +31419,7 @@ async function previewRemoveCommand(workspaceId, options) {
31256
31419
  `/v1/workspaces/${workspaceId}/previews/${portNum}`,
31257
31420
  { method: "DELETE" }
31258
31421
  );
31259
- console.log(import_chalk19.default.green(`Preview deleted on port ${portNum}`));
31422
+ console.log(import_chalk20.default.green(`Preview deleted on port ${portNum}`));
31260
31423
  }
31261
31424
 
31262
31425
  // src/commands/media.ts
@@ -31429,7 +31592,7 @@ async function mediaListCommand(options) {
31429
31592
  }
31430
31593
 
31431
31594
  // src/commands/slack.ts
31432
- var import_chalk20 = __toESM(require("chalk"));
31595
+ var import_chalk21 = __toESM(require("chalk"));
31433
31596
  function getThreadOptions(options) {
31434
31597
  const channelId = options.channel || process.env.REPLICAS_SLACK_CHANNEL_ID || process.env.SLACK_CHANNEL_ID;
31435
31598
  const threadTs = options.threadTs || process.env.REPLICAS_SLACK_THREAD_TS || process.env.SLACK_THREAD_TS;
@@ -31446,10 +31609,10 @@ async function attachThread(request) {
31446
31609
  method: "POST",
31447
31610
  body: request
31448
31611
  });
31449
- console.log(import_chalk20.default.green("Slack thread attached."));
31450
- console.log(import_chalk20.default.gray(` Channel: ${response.thread.channel_id}`));
31451
- console.log(import_chalk20.default.gray(` Thread: ${response.thread.thread_ts}`));
31452
- console.log(import_chalk20.default.gray(` Workspace: ${response.workspace.name} (${response.workspace.id})`));
31612
+ console.log(import_chalk21.default.green("Slack thread attached."));
31613
+ console.log(import_chalk21.default.gray(` Channel: ${response.thread.channel_id}`));
31614
+ console.log(import_chalk21.default.gray(` Thread: ${response.thread.thread_ts}`));
31615
+ console.log(import_chalk21.default.gray(` Workspace: ${response.workspace.name} (${response.workspace.id})`));
31453
31616
  }
31454
31617
  async function slackThreadAttachCommand(options) {
31455
31618
  const agentConfig = readAgentConfig();
@@ -31478,12 +31641,12 @@ async function slackThreadSwitchCommand(workspace, options) {
31478
31641
  }
31479
31642
 
31480
31643
  // src/commands/service.ts
31481
- var import_chalk21 = __toESM(require("chalk"));
31482
- var import_node_child_process = require("child_process");
31483
- var import_node_fs = require("fs");
31484
- var import_node_os = require("os");
31485
- var import_node_path = require("path");
31486
- var SERVICES_DIR = (0, import_node_path.join)((0, import_node_os.homedir)(), ".replicas", "services");
31644
+ var import_chalk22 = __toESM(require("chalk"));
31645
+ var import_node_child_process2 = require("child_process");
31646
+ var import_node_fs2 = require("fs");
31647
+ var import_node_os2 = require("os");
31648
+ var import_node_path2 = require("path");
31649
+ var SERVICES_DIR = (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".replicas", "services");
31487
31650
  var NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
31488
31651
  function isValidServiceName(name) {
31489
31652
  return NAME_PATTERN.test(name);
@@ -31494,7 +31657,7 @@ function tailLines(content, lines) {
31494
31657
  return all.slice(-lines).join("\n").trim();
31495
31658
  }
31496
31659
  function statePath(name) {
31497
- return (0, import_node_path.join)(SERVICES_DIR, `${name}.json`);
31660
+ return (0, import_node_path2.join)(SERVICES_DIR, `${name}.json`);
31498
31661
  }
31499
31662
  function isServiceState(value) {
31500
31663
  if (typeof value !== "object" || value === null) return false;
@@ -31504,7 +31667,7 @@ function isServiceState(value) {
31504
31667
  function readState(name) {
31505
31668
  let parsed;
31506
31669
  try {
31507
- parsed = JSON.parse((0, import_node_fs.readFileSync)(statePath(name), "utf-8"));
31670
+ parsed = JSON.parse((0, import_node_fs2.readFileSync)(statePath(name), "utf-8"));
31508
31671
  } catch {
31509
31672
  return null;
31510
31673
  }
@@ -31538,7 +31701,7 @@ async function killServiceGroup(pid) {
31538
31701
  }
31539
31702
  function tailLog(logFile, lines) {
31540
31703
  try {
31541
- return tailLines((0, import_node_fs.readFileSync)(logFile, "utf-8"), lines);
31704
+ return tailLines((0, import_node_fs2.readFileSync)(logFile, "utf-8"), lines);
31542
31705
  } catch {
31543
31706
  return "";
31544
31707
  }
@@ -31556,20 +31719,20 @@ async function serviceStartCommand(name, commandParts, options) {
31556
31719
  console.log(`Stopping existing "${name}" (pid ${existing.pid}) before restart`);
31557
31720
  await killServiceGroup(existing.pid);
31558
31721
  }
31559
- (0, import_node_fs.mkdirSync)(SERVICES_DIR, { recursive: true });
31560
- const cwd = (0, import_node_path.resolve)(options.cwd ?? process.cwd());
31561
- const logFile = (0, import_node_path.join)(SERVICES_DIR, `${name}.log`);
31562
- const logFd = (0, import_node_fs.openSync)(logFile, "a");
31563
- (0, import_node_fs.writeFileSync)(logFd, `
31722
+ (0, import_node_fs2.mkdirSync)(SERVICES_DIR, { recursive: true });
31723
+ const cwd = (0, import_node_path2.resolve)(options.cwd ?? process.cwd());
31724
+ const logFile = (0, import_node_path2.join)(SERVICES_DIR, `${name}.log`);
31725
+ const logFd = (0, import_node_fs2.openSync)(logFile, "a");
31726
+ (0, import_node_fs2.writeFileSync)(logFd, `
31564
31727
  === [replicas service] "${name}" started ${(/* @__PURE__ */ new Date()).toISOString()} in ${cwd}: ${command} ===
31565
31728
  `);
31566
- const child = (0, import_node_child_process.spawn)("bash", ["-lc", command], {
31729
+ const child = (0, import_node_child_process2.spawn)("bash", ["-lc", command], {
31567
31730
  cwd,
31568
31731
  detached: true,
31569
31732
  stdio: ["ignore", logFd, logFd],
31570
31733
  env: process.env
31571
31734
  });
31572
- (0, import_node_fs.closeSync)(logFd);
31735
+ (0, import_node_fs2.closeSync)(logFd);
31573
31736
  if (child.pid === void 0) {
31574
31737
  throw new Error("Failed to spawn service process");
31575
31738
  }
@@ -31582,11 +31745,11 @@ async function serviceStartCommand(name, commandParts, options) {
31582
31745
  logFile,
31583
31746
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
31584
31747
  };
31585
- (0, import_node_fs.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
31748
+ (0, import_node_fs2.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
31586
31749
  await sleep(1e3);
31587
31750
  if (!isRunning(child.pid)) {
31588
31751
  const logs = tailLog(logFile, 20);
31589
- (0, import_node_fs.rmSync)(statePath(name), { force: true });
31752
+ (0, import_node_fs2.rmSync)(statePath(name), { force: true });
31590
31753
  throw new Error(`Service "${name}" exited immediately.${logs ? `
31591
31754
 
31592
31755
  Last log output:
@@ -31606,12 +31769,12 @@ async function serviceStopCommand(name) {
31606
31769
  } else {
31607
31770
  console.log(`Service "${name}" was not running`);
31608
31771
  }
31609
- (0, import_node_fs.rmSync)(statePath(name), { force: true });
31772
+ (0, import_node_fs2.rmSync)(statePath(name), { force: true });
31610
31773
  }
31611
31774
  async function serviceListCommand() {
31612
31775
  let entries;
31613
31776
  try {
31614
- entries = (0, import_node_fs.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
31777
+ entries = (0, import_node_fs2.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
31615
31778
  } catch {
31616
31779
  entries = [];
31617
31780
  }
@@ -31621,7 +31784,7 @@ async function serviceListCommand() {
31621
31784
  return;
31622
31785
  }
31623
31786
  for (const state of states) {
31624
- const status = isRunning(state.pid) ? import_chalk21.default.green("running") : import_chalk21.default.red("stopped");
31787
+ const status = isRunning(state.pid) ? import_chalk22.default.green("running") : import_chalk22.default.red("stopped");
31625
31788
  console.log(`${state.name} ${status} pid ${state.pid} started ${state.startedAt}`);
31626
31789
  console.log(` command: ${state.command} (cwd: ${state.cwd})`);
31627
31790
  console.log(` logs: ${state.logFile}`);
@@ -31728,7 +31891,7 @@ Workspace: ${workspaceNameForOutput(result.workspace_name)} (${getWorkspaceDashb
31728
31891
 
31729
31892
  // src/commands/environment.ts
31730
31893
  var import_fs5 = __toESM(require("fs"));
31731
- var import_chalk22 = __toESM(require("chalk"));
31894
+ var import_chalk23 = __toESM(require("chalk"));
31732
31895
  var import_prompts8 = __toESM(require("prompts"));
31733
31896
  var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
31734
31897
  function maskValue(value) {
@@ -31741,38 +31904,38 @@ async function resolveEnvironmentId(input) {
31741
31904
  const response = await orgAuthenticatedFetch("/v1/environments");
31742
31905
  const resolved = resolveByNameOrId(input, response.environments);
31743
31906
  if (!resolved) {
31744
- console.log(import_chalk22.default.red(`Environment not found: ${input}`));
31907
+ console.log(import_chalk23.default.red(`Environment not found: ${input}`));
31745
31908
  const available = response.environments.map((e) => e.name).join(", ");
31746
- console.log(import_chalk22.default.gray(`Available: ${available || "(none)"}`));
31909
+ console.log(import_chalk23.default.gray(`Available: ${available || "(none)"}`));
31747
31910
  process.exit(1);
31748
31911
  }
31749
31912
  return resolved.id;
31750
31913
  }
31751
31914
  function printEnvironment(env) {
31752
- console.log(import_chalk22.default.white(` ${env.name}${env.is_global ? import_chalk22.default.gray(" (global)") : ""}`));
31753
- console.log(import_chalk22.default.gray(` ID: ${env.id}`));
31915
+ console.log(import_chalk23.default.white(` ${env.name}${env.is_global ? import_chalk23.default.gray(" (global)") : ""}`));
31916
+ console.log(import_chalk23.default.gray(` ID: ${env.id}`));
31754
31917
  if (env.description) {
31755
- console.log(import_chalk22.default.gray(` Description: ${env.description}`));
31918
+ console.log(import_chalk23.default.gray(` Description: ${env.description}`));
31756
31919
  }
31757
31920
  if (env.repository_id) {
31758
- console.log(import_chalk22.default.gray(` Repository: ${env.repository_id}`));
31921
+ console.log(import_chalk23.default.gray(` Repository: ${env.repository_id}`));
31759
31922
  } else if (env.repository_set_id) {
31760
- console.log(import_chalk22.default.gray(` Repository Set: ${env.repository_set_id}`));
31923
+ console.log(import_chalk23.default.gray(` Repository Set: ${env.repository_set_id}`));
31761
31924
  }
31762
31925
  if (env.variable_count !== void 0) {
31763
- console.log(import_chalk22.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
31926
+ console.log(import_chalk23.default.gray(` Variables: ${env.variable_count}, Files: ${env.file_count ?? 0}, Skills: ${env.skill_count ?? 0}, MCPs: ${env.mcp_count ?? 0}`));
31764
31927
  }
31765
- console.log(import_chalk22.default.gray(` Updated: ${formatDate2(env.updated_at)}`));
31928
+ console.log(import_chalk23.default.gray(` Updated: ${formatDate2(env.updated_at)}`));
31766
31929
  console.log();
31767
31930
  }
31768
31931
  async function environmentListCommand() {
31769
31932
  ensureOrgApiAuthenticated();
31770
31933
  const response = await orgAuthenticatedFetch("/v1/environments");
31771
31934
  if (response.environments.length === 0) {
31772
- console.log(import_chalk22.default.yellow("\nNo environments found.\n"));
31935
+ console.log(import_chalk23.default.yellow("\nNo environments found.\n"));
31773
31936
  return;
31774
31937
  }
31775
- console.log(import_chalk22.default.green(`
31938
+ console.log(import_chalk23.default.green(`
31776
31939
  Environments (${response.environments.length}):
31777
31940
  `));
31778
31941
  for (const env of response.environments) {
@@ -31783,7 +31946,7 @@ async function environmentGetCommand(idOrName) {
31783
31946
  ensureOrgApiAuthenticated();
31784
31947
  const id = await resolveEnvironmentId(idOrName);
31785
31948
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}`);
31786
- console.log(import_chalk22.default.green(`
31949
+ console.log(import_chalk23.default.green(`
31787
31950
  Environment: ${response.environment.name}
31788
31951
  `));
31789
31952
  printEnvironment(response.environment);
@@ -31799,7 +31962,7 @@ async function environmentCreateCommand(name, options) {
31799
31962
  validate: (v) => v.trim() ? true : "Name is required"
31800
31963
  });
31801
31964
  if (!r.name) {
31802
- console.log(import_chalk22.default.yellow("\nCancelled."));
31965
+ console.log(import_chalk23.default.yellow("\nCancelled."));
31803
31966
  return;
31804
31967
  }
31805
31968
  envName = r.name;
@@ -31812,8 +31975,8 @@ async function environmentCreateCommand(name, options) {
31812
31975
  const repos2 = await orgAuthenticatedFetch("/v1/repositories");
31813
31976
  const repo = repos2.repositories.find((r) => r.name === options.repository);
31814
31977
  if (!repo) {
31815
- console.log(import_chalk22.default.red(`Repository not found: ${options.repository}`));
31816
- console.log(import_chalk22.default.gray(`Available: ${repos2.repositories.map((r) => r.name).join(", ")}`));
31978
+ console.log(import_chalk23.default.red(`Repository not found: ${options.repository}`));
31979
+ console.log(import_chalk23.default.gray(`Available: ${repos2.repositories.map((r) => r.name).join(", ")}`));
31817
31980
  process.exit(1);
31818
31981
  }
31819
31982
  repositoryId = repo.id;
@@ -31843,9 +32006,9 @@ async function environmentCreateCommand(name, options) {
31843
32006
  method: "POST",
31844
32007
  body
31845
32008
  });
31846
- console.log(import_chalk22.default.green(`
32009
+ console.log(import_chalk23.default.green(`
31847
32010
  Created environment: ${response.environment.name}`));
31848
- console.log(import_chalk22.default.gray(` ID: ${response.environment.id}
32011
+ console.log(import_chalk23.default.gray(` ID: ${response.environment.id}
31849
32012
  `));
31850
32013
  }
31851
32014
  async function environmentEditCommand(idOrName, options) {
@@ -31864,21 +32027,21 @@ async function environmentEditCommand(idOrName, options) {
31864
32027
  const repos2 = await orgAuthenticatedFetch("/v1/repositories");
31865
32028
  const repo = repos2.repositories.find((r) => r.name === options.repository);
31866
32029
  if (!repo) {
31867
- console.log(import_chalk22.default.red(`Repository not found: ${options.repository}`));
32030
+ console.log(import_chalk23.default.red(`Repository not found: ${options.repository}`));
31868
32031
  process.exit(1);
31869
32032
  }
31870
32033
  body.repository_id = repo.id;
31871
32034
  }
31872
32035
  }
31873
32036
  if (Object.keys(body).length === 0) {
31874
- console.log(import_chalk22.default.yellow("\nNo changes specified. Pass --name, --description, --repository, or --system-prompt."));
32037
+ console.log(import_chalk23.default.yellow("\nNo changes specified. Pass --name, --description, --repository, or --system-prompt."));
31875
32038
  return;
31876
32039
  }
31877
32040
  const response = await orgAuthenticatedFetch(`/v1/environments/${id}`, {
31878
32041
  method: "PATCH",
31879
32042
  body
31880
32043
  });
31881
- console.log(import_chalk22.default.green(`
32044
+ console.log(import_chalk23.default.green(`
31882
32045
  Updated environment: ${response.environment.name}
31883
32046
  `));
31884
32047
  }
@@ -31893,20 +32056,20 @@ async function environmentDeleteCommand(idOrName, options) {
31893
32056
  initial: false
31894
32057
  });
31895
32058
  if (!r.confirm) {
31896
- console.log(import_chalk22.default.yellow("\nCancelled."));
32059
+ console.log(import_chalk23.default.yellow("\nCancelled."));
31897
32060
  return;
31898
32061
  }
31899
32062
  }
31900
32063
  await orgAuthenticatedFetch(`/v1/environments/${id}`, { method: "DELETE" });
31901
- console.log(import_chalk22.default.green(`
32064
+ console.log(import_chalk23.default.green(`
31902
32065
  Deleted environment ${idOrName}.
31903
32066
  `));
31904
32067
  }
31905
32068
  function printVariable(v, reveal) {
31906
- console.log(import_chalk22.default.white(` ${v.key}`));
31907
- console.log(import_chalk22.default.gray(` ID: ${v.id}`));
31908
- console.log(import_chalk22.default.gray(` Value: ${reveal ? v.value : maskValue(v.value)}`));
31909
- console.log(import_chalk22.default.gray(` Updated: ${formatDate2(v.updated_at)}`));
32069
+ console.log(import_chalk23.default.white(` ${v.key}`));
32070
+ console.log(import_chalk23.default.gray(` ID: ${v.id}`));
32071
+ console.log(import_chalk23.default.gray(` Value: ${reveal ? v.value : maskValue(v.value)}`));
32072
+ console.log(import_chalk23.default.gray(` Updated: ${formatDate2(v.updated_at)}`));
31910
32073
  console.log();
31911
32074
  }
31912
32075
  async function envVarsListCommand(envIdOrName, options) {
@@ -31916,14 +32079,14 @@ async function envVarsListCommand(envIdOrName, options) {
31916
32079
  `/v1/environments/${id}/variables`
31917
32080
  );
31918
32081
  if (response.environment_variables.length === 0) {
31919
- console.log(import_chalk22.default.yellow("\nNo variables.\n"));
32082
+ console.log(import_chalk23.default.yellow("\nNo variables.\n"));
31920
32083
  return;
31921
32084
  }
31922
- console.log(import_chalk22.default.green(`
32085
+ console.log(import_chalk23.default.green(`
31923
32086
  Variables (${response.environment_variables.length}):
31924
32087
  `));
31925
32088
  if (!options.reveal) {
31926
- console.log(import_chalk22.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
32089
+ console.log(import_chalk23.default.gray(" Values are masked. Pass --reveal to show full values.\n"));
31927
32090
  }
31928
32091
  for (const v of response.environment_variables) printVariable(v, !!options.reveal);
31929
32092
  }
@@ -31940,7 +32103,7 @@ async function envVarsSetCommand(envIdOrName, key, value) {
31940
32103
  `/v1/environments/${id}/variables/${match.id}`,
31941
32104
  { method: "PATCH", body: body2 }
31942
32105
  );
31943
- console.log(import_chalk22.default.green(`
32106
+ console.log(import_chalk23.default.green(`
31944
32107
  Updated variable ${response2.environment_variable.key}.
31945
32108
  `));
31946
32109
  return;
@@ -31954,7 +32117,7 @@ Updated variable ${response2.environment_variable.key}.
31954
32117
  `/v1/environments/${id}/variables`,
31955
32118
  { method: "POST", body }
31956
32119
  );
31957
- console.log(import_chalk22.default.green(`
32120
+ console.log(import_chalk23.default.green(`
31958
32121
  Created variable ${response.environment_variable.key}.
31959
32122
  `));
31960
32123
  }
@@ -31968,7 +32131,7 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
31968
32131
  );
31969
32132
  const match = existing.environment_variables.find((v) => v.key === keyOrId);
31970
32133
  if (!match) {
31971
- console.log(import_chalk22.default.red(`Variable not found: ${keyOrId}`));
32134
+ console.log(import_chalk23.default.red(`Variable not found: ${keyOrId}`));
31972
32135
  process.exit(1);
31973
32136
  }
31974
32137
  variableId = match.id;
@@ -31981,23 +32144,23 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
31981
32144
  initial: false
31982
32145
  });
31983
32146
  if (!r.confirm) {
31984
- console.log(import_chalk22.default.yellow("\nCancelled."));
32147
+ console.log(import_chalk23.default.yellow("\nCancelled."));
31985
32148
  return;
31986
32149
  }
31987
32150
  }
31988
32151
  await orgAuthenticatedFetch(`/v1/environments/${id}/variables/${variableId}`, {
31989
32152
  method: "DELETE"
31990
32153
  });
31991
- console.log(import_chalk22.default.green(`
32154
+ console.log(import_chalk23.default.green(`
31992
32155
  Deleted variable ${keyOrId}.
31993
32156
  `));
31994
32157
  }
31995
32158
  function printFile(f) {
31996
- console.log(import_chalk22.default.white(` ${f.path}`));
31997
- console.log(import_chalk22.default.gray(` ID: ${f.id}`));
31998
- console.log(import_chalk22.default.gray(` Name: ${f.name}`));
31999
- console.log(import_chalk22.default.gray(` Size: ${f.content.length} bytes`));
32000
- console.log(import_chalk22.default.gray(` Updated: ${formatDate2(f.updated_at)}`));
32159
+ console.log(import_chalk23.default.white(` ${f.path}`));
32160
+ console.log(import_chalk23.default.gray(` ID: ${f.id}`));
32161
+ console.log(import_chalk23.default.gray(` Name: ${f.name}`));
32162
+ console.log(import_chalk23.default.gray(` Size: ${f.content.length} bytes`));
32163
+ console.log(import_chalk23.default.gray(` Updated: ${formatDate2(f.updated_at)}`));
32001
32164
  console.log();
32002
32165
  }
32003
32166
  async function envFilesListCommand(envIdOrName) {
@@ -32007,10 +32170,10 @@ async function envFilesListCommand(envIdOrName) {
32007
32170
  `/v1/environments/${id}/files`
32008
32171
  );
32009
32172
  if (response.environment_files.length === 0) {
32010
- console.log(import_chalk22.default.yellow("\nNo files.\n"));
32173
+ console.log(import_chalk23.default.yellow("\nNo files.\n"));
32011
32174
  return;
32012
32175
  }
32013
- console.log(import_chalk22.default.green(`
32176
+ console.log(import_chalk23.default.green(`
32014
32177
  Files (${response.environment_files.length}):
32015
32178
  `));
32016
32179
  for (const f of response.environment_files) printFile(f);
@@ -32041,7 +32204,7 @@ async function envFilesSetCommand(envIdOrName, destinationPath, options) {
32041
32204
  `/v1/environments/${id}/files/${match.id}`,
32042
32205
  { method: "PATCH", body: body2 }
32043
32206
  );
32044
- console.log(import_chalk22.default.green(`
32207
+ console.log(import_chalk23.default.green(`
32045
32208
  Updated file ${response2.environment_file.path}.
32046
32209
  `));
32047
32210
  return;
@@ -32056,7 +32219,7 @@ Updated file ${response2.environment_file.path}.
32056
32219
  `/v1/environments/${id}/files`,
32057
32220
  { method: "POST", body }
32058
32221
  );
32059
- console.log(import_chalk22.default.green(`
32222
+ console.log(import_chalk23.default.green(`
32060
32223
  Created file ${response.environment_file.path}.
32061
32224
  `));
32062
32225
  }
@@ -32070,7 +32233,7 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
32070
32233
  );
32071
32234
  const match = existing.environment_files.find((f) => f.path === pathOrId);
32072
32235
  if (!match) {
32073
- console.log(import_chalk22.default.red(`File not found: ${pathOrId}`));
32236
+ console.log(import_chalk23.default.red(`File not found: ${pathOrId}`));
32074
32237
  process.exit(1);
32075
32238
  }
32076
32239
  fileId = match.id;
@@ -32083,14 +32246,14 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
32083
32246
  initial: false
32084
32247
  });
32085
32248
  if (!r.confirm) {
32086
- console.log(import_chalk22.default.yellow("\nCancelled."));
32249
+ console.log(import_chalk23.default.yellow("\nCancelled."));
32087
32250
  return;
32088
32251
  }
32089
32252
  }
32090
32253
  await orgAuthenticatedFetch(`/v1/environments/${id}/files/${fileId}`, {
32091
32254
  method: "DELETE"
32092
32255
  });
32093
- console.log(import_chalk22.default.green(`
32256
+ console.log(import_chalk23.default.green(`
32094
32257
  Deleted file ${pathOrId}.
32095
32258
  `));
32096
32259
  }
@@ -32099,16 +32262,16 @@ async function envHookGetCommand(envIdOrName, kind) {
32099
32262
  const id = await resolveEnvironmentId(envIdOrName);
32100
32263
  const hook = kind === "warm" ? (await orgAuthenticatedFetch(`/v1/environments/${id}/warm-hooks`)).warm_hook : (await orgAuthenticatedFetch(`/v1/environments/${id}/start-hooks`)).start_hook;
32101
32264
  if (!hook) {
32102
- console.log(import_chalk22.default.yellow(`
32265
+ console.log(import_chalk23.default.yellow(`
32103
32266
  No ${kind} hook configured.
32104
32267
  `));
32105
32268
  return;
32106
32269
  }
32107
- console.log(import_chalk22.default.green(`
32270
+ console.log(import_chalk23.default.green(`
32108
32271
  ${kind === "warm" ? "Warm" : "Start"} hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
32109
32272
  `));
32110
- console.log(import_chalk22.default.gray(` ID: ${hook.id}`));
32111
- console.log(import_chalk22.default.gray(` Created: ${formatDate2(hook.created_at)}
32273
+ console.log(import_chalk23.default.gray(` ID: ${hook.id}`));
32274
+ console.log(import_chalk23.default.gray(` Created: ${formatDate2(hook.created_at)}
32112
32275
  `));
32113
32276
  console.log(hook.content);
32114
32277
  console.log();
@@ -32123,7 +32286,7 @@ async function envHookSaveCommand(envIdOrName, options, kind) {
32123
32286
  `/v1/environments/${id}/warm-hooks/save`,
32124
32287
  { method: "POST", body: body2 }
32125
32288
  );
32126
- console.log(import_chalk22.default.green(`
32289
+ console.log(import_chalk23.default.green(`
32127
32290
  Saved warm hook v${response2.warm_hook.version}.
32128
32291
  `));
32129
32292
  return;
@@ -32133,7 +32296,7 @@ Saved warm hook v${response2.warm_hook.version}.
32133
32296
  `/v1/environments/${id}/start-hooks/save`,
32134
32297
  { method: "POST", body }
32135
32298
  );
32136
- console.log(import_chalk22.default.green(response.start_hook ? `
32299
+ console.log(import_chalk23.default.green(response.start_hook ? `
32137
32300
  Saved start hook v${response.start_hook.version}.
32138
32301
  ` : "\nCleared start hook.\n"));
32139
32302
  }
@@ -32150,7 +32313,7 @@ async function envHookTestCommand(envIdOrName, options, kind) {
32150
32313
  body: kind === "warm" ? { content, mode: options.save ? "save_test" : "test_only" } : { content },
32151
32314
  onEvent: (event) => {
32152
32315
  if (event.type === "progress" && event.message) {
32153
- console.log(import_chalk22.default.gray(event.message));
32316
+ console.log(import_chalk23.default.gray(event.message));
32154
32317
  } else if (event.type === "output" && event.output) {
32155
32318
  process.stdout.write(event.output);
32156
32319
  } else if (event.type === "complete") {
@@ -32163,23 +32326,23 @@ async function envHookTestCommand(envIdOrName, options, kind) {
32163
32326
  }
32164
32327
  );
32165
32328
  if (errorMessage) {
32166
- console.log(import_chalk22.default.red(`
32329
+ console.log(import_chalk23.default.red(`
32167
32330
  ${errorMessage}
32168
32331
  `));
32169
32332
  process.exit(1);
32170
32333
  }
32171
32334
  if (timedOut) {
32172
- console.log(import_chalk22.default.yellow(`
32335
+ console.log(import_chalk23.default.yellow(`
32173
32336
  ${kind === "warm" ? "Warm" : "Start"} hook timed out.
32174
32337
  `));
32175
32338
  process.exit(1);
32176
32339
  }
32177
32340
  if (exitCode === 0) {
32178
- console.log(import_chalk22.default.green(`
32341
+ console.log(import_chalk23.default.green(`
32179
32342
  ${kind === "warm" ? "Warm" : "Start"} hook passed${options.save ? " and was saved" : ""} (exit code ${exitCode}).
32180
32343
  `));
32181
32344
  } else {
32182
- console.log(import_chalk22.default.red(`
32345
+ console.log(import_chalk23.default.red(`
32183
32346
  ${kind === "warm" ? "Warm" : "Start"} hook failed (exit code ${exitCode ?? "unknown"}).
32184
32347
  `));
32185
32348
  process.exit(1);
@@ -32194,24 +32357,24 @@ async function envHookRepositoryHooksCommand(envIdOrName, kind) {
32194
32357
  `/v1/environments/${id}/start-hooks/repository-hooks`
32195
32358
  )).repositories.map((repository) => ({ ...repository, hook: repository.start_hook }));
32196
32359
  if (repositories.length === 0) {
32197
- console.log(import_chalk22.default.yellow("\nNo repositories bound to this environment.\n"));
32360
+ console.log(import_chalk23.default.yellow("\nNo repositories bound to this environment.\n"));
32198
32361
  return;
32199
32362
  }
32200
- console.log(import_chalk22.default.green(`
32363
+ console.log(import_chalk23.default.green(`
32201
32364
  Repository ${kind} hooks (${repositories.length}):
32202
32365
  `));
32203
32366
  for (const repo of repositories) {
32204
- console.log(import_chalk22.default.white(` ${repo.repository_name} @${repo.default_branch}`));
32367
+ console.log(import_chalk23.default.white(` ${repo.repository_name} @${repo.default_branch}`));
32205
32368
  if (repo.error) {
32206
- console.log(import_chalk22.default.red(` Error: ${repo.error}`));
32369
+ console.log(import_chalk23.default.red(` Error: ${repo.error}`));
32207
32370
  } else if (repo.hook) {
32208
- console.log(import_chalk22.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
32209
- console.log(import_chalk22.default.gray(` Commands (${repo.hook.commands.length}):`));
32371
+ console.log(import_chalk23.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
32372
+ console.log(import_chalk23.default.gray(` Commands (${repo.hook.commands.length}):`));
32210
32373
  for (const cmd of repo.hook.commands) {
32211
- console.log(import_chalk22.default.gray(` ${cmd}`));
32374
+ console.log(import_chalk23.default.gray(` ${cmd}`));
32212
32375
  }
32213
32376
  } else {
32214
- console.log(import_chalk22.default.gray(` No ${kind}Hook defined.`));
32377
+ console.log(import_chalk23.default.gray(` No ${kind}Hook defined.`));
32215
32378
  }
32216
32379
  console.log();
32217
32380
  }
@@ -32276,7 +32439,7 @@ program.hook("preAction", async (_command, actionCommand) => {
32276
32439
  throw new Error('No organization selected. Run "replicas org switch" to select one.');
32277
32440
  }
32278
32441
  } catch (error51) {
32279
- console.error(import_chalk23.default.red(`
32442
+ console.error(import_chalk24.default.red(`
32280
32443
  \u2717 ${error51 instanceof Error ? error51.message : "Unknown error"}
32281
32444
  `));
32282
32445
  process.exit(1);
@@ -32290,7 +32453,7 @@ function registerSlackCommands(parent) {
32290
32453
  await slackThreadAttachCommand(options);
32291
32454
  } catch (error51) {
32292
32455
  if (error51 instanceof Error) {
32293
- console.error(import_chalk23.default.red(`
32456
+ console.error(import_chalk24.default.red(`
32294
32457
  \u2717 ${error51.message}
32295
32458
  `));
32296
32459
  }
@@ -32302,7 +32465,7 @@ function registerSlackCommands(parent) {
32302
32465
  await slackThreadSwitchCommand(workspace, options);
32303
32466
  } catch (error51) {
32304
32467
  if (error51 instanceof Error) {
32305
- console.error(import_chalk23.default.red(`
32468
+ console.error(import_chalk24.default.red(`
32306
32469
  \u2717 ${error51.message}
32307
32470
  `));
32308
32471
  }
@@ -32316,7 +32479,7 @@ program.command("login").description("Authenticate with your Replicas account").
32316
32479
  await loginCommand();
32317
32480
  } catch (error51) {
32318
32481
  if (error51 instanceof Error) {
32319
- console.error(import_chalk23.default.red(`
32482
+ console.error(import_chalk24.default.red(`
32320
32483
  \u2717 ${error51.message}
32321
32484
  `));
32322
32485
  }
@@ -32328,7 +32491,7 @@ program.command("init").description("Create a replicas.json or replicas.yaml con
32328
32491
  initCommand(options);
32329
32492
  } catch (error51) {
32330
32493
  if (error51 instanceof Error) {
32331
- console.error(import_chalk23.default.red(`
32494
+ console.error(import_chalk24.default.red(`
32332
32495
  \u2717 ${error51.message}
32333
32496
  `));
32334
32497
  }
@@ -32340,7 +32503,7 @@ program.command("logout").description("Clear stored credentials").action(() => {
32340
32503
  logoutCommand();
32341
32504
  } catch (error51) {
32342
32505
  if (error51 instanceof Error) {
32343
- console.error(import_chalk23.default.red(`
32506
+ console.error(import_chalk24.default.red(`
32344
32507
  \u2717 ${error51.message}
32345
32508
  `));
32346
32509
  }
@@ -32351,7 +32514,7 @@ program.command("muse-auth").description("Connect your Muse Code subscription to
32351
32514
  try {
32352
32515
  await museAuthCommand(options);
32353
32516
  } catch (error51) {
32354
- if (error51 instanceof Error) console.error(import_chalk23.default.red(`
32517
+ if (error51 instanceof Error) console.error(import_chalk24.default.red(`
32355
32518
  \u2717 ${error51.message}
32356
32519
  `));
32357
32520
  process.exit(1);
@@ -32362,7 +32525,7 @@ program.command("whoami").description("Display current authenticated user").acti
32362
32525
  await whoamiCommand();
32363
32526
  } catch (error51) {
32364
32527
  if (error51 instanceof Error) {
32365
- console.error(import_chalk23.default.red(`
32528
+ console.error(import_chalk24.default.red(`
32366
32529
  \u2717 ${error51.message}
32367
32530
  `));
32368
32531
  }
@@ -32374,7 +32537,7 @@ program.command("codex-auth").description("Connect your Codex credentials to Rep
32374
32537
  await codexAuthCommand(options);
32375
32538
  } catch (error51) {
32376
32539
  if (error51 instanceof Error) {
32377
- console.error(import_chalk23.default.red(`
32540
+ console.error(import_chalk24.default.red(`
32378
32541
  \u2717 ${error51.message}
32379
32542
  `));
32380
32543
  }
@@ -32386,7 +32549,7 @@ program.command("claude-auth").description("Connect your Claude Code credentials
32386
32549
  await claudeAuthCommand(options);
32387
32550
  } catch (error51) {
32388
32551
  if (error51 instanceof Error) {
32389
- console.error(import_chalk23.default.red(`
32552
+ console.error(import_chalk24.default.red(`
32390
32553
  \u2717 ${error51.message}
32391
32554
  `));
32392
32555
  }
@@ -32399,7 +32562,7 @@ org.command("switch").description("Switch to a different organization").action(a
32399
32562
  await orgSwitchCommand();
32400
32563
  } catch (error51) {
32401
32564
  if (error51 instanceof Error) {
32402
- console.error(import_chalk23.default.red(`
32565
+ console.error(import_chalk24.default.red(`
32403
32566
  \u2717 ${error51.message}
32404
32567
  `));
32405
32568
  }
@@ -32411,7 +32574,7 @@ org.action(async () => {
32411
32574
  await orgCommand();
32412
32575
  } catch (error51) {
32413
32576
  if (error51 instanceof Error) {
32414
- console.error(import_chalk23.default.red(`
32577
+ console.error(import_chalk24.default.red(`
32415
32578
  \u2717 ${error51.message}
32416
32579
  `));
32417
32580
  }
@@ -32423,7 +32586,7 @@ program.command("connect <workspace-name...>").description("Connect to a workspa
32423
32586
  await connectCommand(workspaceName.join(" "));
32424
32587
  } catch (error51) {
32425
32588
  if (error51 instanceof Error) {
32426
- console.error(import_chalk23.default.red(`
32589
+ console.error(import_chalk24.default.red(`
32427
32590
  \u2717 ${error51.message}
32428
32591
  `));
32429
32592
  }
@@ -32434,7 +32597,7 @@ program.command("tunnel <workspace-name...>").description("Forward a workspace p
32434
32597
  try {
32435
32598
  await tunnelCommand(workspaceName.join(" "), options);
32436
32599
  } catch (error51) {
32437
- console.error(import_chalk23.default.red(`
32600
+ console.error(import_chalk24.default.red(`
32438
32601
  Error: ${error51 instanceof Error ? error51.message : "Unknown error"}`));
32439
32602
  process.exit(1);
32440
32603
  }
@@ -32444,7 +32607,7 @@ program.command("code [workspace-name...]").description("Open a workspace in VSC
32444
32607
  await codeCommand(workspaceName.join(" "));
32445
32608
  } catch (error51) {
32446
32609
  if (error51 instanceof Error) {
32447
- console.error(import_chalk23.default.red(`
32610
+ console.error(import_chalk24.default.red(`
32448
32611
  \u2717 ${error51.message}
32449
32612
  `));
32450
32613
  }
@@ -32457,7 +32620,7 @@ config2.command("get <key>").description("Get a configuration value").action(asy
32457
32620
  await configGetCommand(key);
32458
32621
  } catch (error51) {
32459
32622
  if (error51 instanceof Error) {
32460
- console.error(import_chalk23.default.red(`
32623
+ console.error(import_chalk24.default.red(`
32461
32624
  \u2717 ${error51.message}
32462
32625
  `));
32463
32626
  }
@@ -32469,7 +32632,7 @@ config2.command("set <key> <value>").description("Set a configuration value").ac
32469
32632
  await configSetCommand(key, value);
32470
32633
  } catch (error51) {
32471
32634
  if (error51 instanceof Error) {
32472
- console.error(import_chalk23.default.red(`
32635
+ console.error(import_chalk24.default.red(`
32473
32636
  \u2717 ${error51.message}
32474
32637
  `));
32475
32638
  }
@@ -32481,7 +32644,7 @@ config2.command("list").description("List all configuration values").action(asyn
32481
32644
  await configListCommand();
32482
32645
  } catch (error51) {
32483
32646
  if (error51 instanceof Error) {
32484
- console.error(import_chalk23.default.red(`
32647
+ console.error(import_chalk24.default.red(`
32485
32648
  \u2717 ${error51.message}
32486
32649
  `));
32487
32650
  }
@@ -32493,7 +32656,7 @@ program.command("list").description("List all replicas").option("-p, --page <pag
32493
32656
  await replicaListCommand(options);
32494
32657
  } catch (error51) {
32495
32658
  if (error51 instanceof Error) {
32496
- console.error(import_chalk23.default.red(`
32659
+ console.error(import_chalk24.default.red(`
32497
32660
  \u2717 ${error51.message}
32498
32661
  `));
32499
32662
  }
@@ -32505,7 +32668,7 @@ program.command("get <id>").description("Get replica details by ID").action(asyn
32505
32668
  await replicaGetCommand(id);
32506
32669
  } catch (error51) {
32507
32670
  if (error51 instanceof Error) {
32508
- console.error(import_chalk23.default.red(`
32671
+ console.error(import_chalk24.default.red(`
32509
32672
  \u2717 ${error51.message}
32510
32673
  `));
32511
32674
  }
@@ -32517,7 +32680,7 @@ program.command("create [name]").description("Create a new replica").option("-m,
32517
32680
  await replicaCreateCommand(name, options);
32518
32681
  } catch (error51) {
32519
32682
  if (error51 instanceof Error) {
32520
- console.error(import_chalk23.default.red(`
32683
+ console.error(import_chalk24.default.red(`
32521
32684
  \u2717 ${error51.message}
32522
32685
  `));
32523
32686
  }
@@ -32529,7 +32692,7 @@ program.command("send <id>").description("Send a message to a replica").option("
32529
32692
  await replicaSendCommand(id, options);
32530
32693
  } catch (error51) {
32531
32694
  if (error51 instanceof Error) {
32532
- console.error(import_chalk23.default.red(`
32695
+ console.error(import_chalk24.default.red(`
32533
32696
  \u2717 ${error51.message}
32534
32697
  `));
32535
32698
  }
@@ -32541,7 +32704,7 @@ program.command("delete <id>").description("Delete a replica").option("-f, --for
32541
32704
  await replicaDeleteCommand(id, options);
32542
32705
  } catch (error51) {
32543
32706
  if (error51 instanceof Error) {
32544
- console.error(import_chalk23.default.red(`
32707
+ console.error(import_chalk24.default.red(`
32545
32708
  \u2717 ${error51.message}
32546
32709
  `));
32547
32710
  }
@@ -32553,7 +32716,7 @@ program.command("read <id>").description("Read conversation history of a replica
32553
32716
  await replicaReadCommand(id, options);
32554
32717
  } catch (error51) {
32555
32718
  if (error51 instanceof Error) {
32556
- console.error(import_chalk23.default.red(`
32719
+ console.error(import_chalk24.default.red(`
32557
32720
  \u2717 ${error51.message}
32558
32721
  `));
32559
32722
  }
@@ -32566,7 +32729,7 @@ automation.command("list").description("List all automations").option("-p, --pag
32566
32729
  await automationListCommand(options);
32567
32730
  } catch (error51) {
32568
32731
  if (error51 instanceof Error) {
32569
- console.error(import_chalk23.default.red(`
32732
+ console.error(import_chalk24.default.red(`
32570
32733
  \u2717 ${error51.message}
32571
32734
  `));
32572
32735
  }
@@ -32578,7 +32741,7 @@ automation.command("get <id>").description("Get automation details by ID").actio
32578
32741
  await automationGetCommand(id);
32579
32742
  } catch (error51) {
32580
32743
  if (error51 instanceof Error) {
32581
- console.error(import_chalk23.default.red(`
32744
+ console.error(import_chalk24.default.red(`
32582
32745
  \u2717 ${error51.message}
32583
32746
  `));
32584
32747
  }
@@ -32593,7 +32756,7 @@ automation.command("create [name]").description("Create a new automation").optio
32593
32756
  });
32594
32757
  } catch (error51) {
32595
32758
  if (error51 instanceof Error) {
32596
- console.error(import_chalk23.default.red(`
32759
+ console.error(import_chalk24.default.red(`
32597
32760
  \u2717 ${error51.message}
32598
32761
  `));
32599
32762
  }
@@ -32605,7 +32768,7 @@ automation.command("edit <id>").description("Edit an existing automation").optio
32605
32768
  await automationEditCommand(id, options);
32606
32769
  } catch (error51) {
32607
32770
  if (error51 instanceof Error) {
32608
- console.error(import_chalk23.default.red(`
32771
+ console.error(import_chalk24.default.red(`
32609
32772
  \u2717 ${error51.message}
32610
32773
  `));
32611
32774
  }
@@ -32617,7 +32780,7 @@ automation.command("run <id>").description("Manually trigger an automation (cron
32617
32780
  await automationRunCommand(id);
32618
32781
  } catch (error51) {
32619
32782
  if (error51 instanceof Error) {
32620
- console.error(import_chalk23.default.red(`
32783
+ console.error(import_chalk24.default.red(`
32621
32784
  \u2717 ${error51.message}
32622
32785
  `));
32623
32786
  }
@@ -32629,7 +32792,7 @@ automation.command("delete <id>").description("Delete an automation").option("-f
32629
32792
  await automationDeleteCommand(id, options);
32630
32793
  } catch (error51) {
32631
32794
  if (error51 instanceof Error) {
32632
- console.error(import_chalk23.default.red(`
32795
+ console.error(import_chalk24.default.red(`
32633
32796
  \u2717 ${error51.message}
32634
32797
  `));
32635
32798
  }
@@ -32641,7 +32804,7 @@ automation.command("check <checkRunId>").description("Report this automation run
32641
32804
  await automationCheckCommand(checkRunId, options);
32642
32805
  } catch (error51) {
32643
32806
  if (error51 instanceof Error) {
32644
- console.error(import_chalk23.default.red(`
32807
+ console.error(import_chalk24.default.red(`
32645
32808
  \u2717 ${error51.message}
32646
32809
  `));
32647
32810
  }
@@ -32653,7 +32816,7 @@ automation.action(async () => {
32653
32816
  await automationListCommand({});
32654
32817
  } catch (error51) {
32655
32818
  if (error51 instanceof Error) {
32656
- console.error(import_chalk23.default.red(`
32819
+ console.error(import_chalk24.default.red(`
32657
32820
  \u2717 ${error51.message}
32658
32821
  `));
32659
32822
  }
@@ -32666,7 +32829,7 @@ repos.command("list").description("List all repositories").action(async () => {
32666
32829
  await repositoriesListCommand();
32667
32830
  } catch (error51) {
32668
32831
  if (error51 instanceof Error) {
32669
- console.error(import_chalk23.default.red(`
32832
+ console.error(import_chalk24.default.red(`
32670
32833
  \u2717 ${error51.message}
32671
32834
  `));
32672
32835
  }
@@ -32678,7 +32841,7 @@ repos.action(async () => {
32678
32841
  await repositoriesListCommand();
32679
32842
  } catch (error51) {
32680
32843
  if (error51 instanceof Error) {
32681
- console.error(import_chalk23.default.red(`
32844
+ console.error(import_chalk24.default.red(`
32682
32845
  \u2717 ${error51.message}
32683
32846
  `));
32684
32847
  }
@@ -32691,7 +32854,7 @@ environment.command("list").description("List all environments").action(async ()
32691
32854
  await environmentListCommand();
32692
32855
  } catch (error51) {
32693
32856
  if (error51 instanceof Error) {
32694
- console.error(import_chalk23.default.red(`
32857
+ console.error(import_chalk24.default.red(`
32695
32858
  \u2717 ${error51.message}
32696
32859
  `));
32697
32860
  }
@@ -32703,7 +32866,7 @@ environment.command("get <id-or-name>").description('Get an environment by ID or
32703
32866
  await environmentGetCommand(idOrName);
32704
32867
  } catch (error51) {
32705
32868
  if (error51 instanceof Error) {
32706
- console.error(import_chalk23.default.red(`
32869
+ console.error(import_chalk24.default.red(`
32707
32870
  \u2717 ${error51.message}
32708
32871
  `));
32709
32872
  }
@@ -32715,7 +32878,7 @@ environment.command("create [name]").description("Create a new environment").opt
32715
32878
  await environmentCreateCommand(name, options);
32716
32879
  } catch (error51) {
32717
32880
  if (error51 instanceof Error) {
32718
- console.error(import_chalk23.default.red(`
32881
+ console.error(import_chalk24.default.red(`
32719
32882
  \u2717 ${error51.message}
32720
32883
  `));
32721
32884
  }
@@ -32727,7 +32890,7 @@ environment.command("edit <id-or-name>").description("Edit an environment").opti
32727
32890
  await environmentEditCommand(idOrName, options);
32728
32891
  } catch (error51) {
32729
32892
  if (error51 instanceof Error) {
32730
- console.error(import_chalk23.default.red(`
32893
+ console.error(import_chalk24.default.red(`
32731
32894
  \u2717 ${error51.message}
32732
32895
  `));
32733
32896
  }
@@ -32739,7 +32902,7 @@ environment.command("delete <id-or-name>").description("Delete an environment").
32739
32902
  await environmentDeleteCommand(idOrName, options);
32740
32903
  } catch (error51) {
32741
32904
  if (error51 instanceof Error) {
32742
- console.error(import_chalk23.default.red(`
32905
+ console.error(import_chalk24.default.red(`
32743
32906
  \u2717 ${error51.message}
32744
32907
  `));
32745
32908
  }
@@ -32752,7 +32915,7 @@ envVars.command("list <env>").description("List variables in an environment (val
32752
32915
  await envVarsListCommand(env, options);
32753
32916
  } catch (error51) {
32754
32917
  if (error51 instanceof Error) {
32755
- console.error(import_chalk23.default.red(`
32918
+ console.error(import_chalk24.default.red(`
32756
32919
  \u2717 ${error51.message}
32757
32920
  `));
32758
32921
  }
@@ -32764,7 +32927,7 @@ envVars.command("set <env> <key> <value>").description("Create or update a varia
32764
32927
  await envVarsSetCommand(env, key, value);
32765
32928
  } catch (error51) {
32766
32929
  if (error51 instanceof Error) {
32767
- console.error(import_chalk23.default.red(`
32930
+ console.error(import_chalk24.default.red(`
32768
32931
  \u2717 ${error51.message}
32769
32932
  `));
32770
32933
  }
@@ -32776,7 +32939,7 @@ envVars.command("delete <env> <key-or-id>").description("Delete a variable by ke
32776
32939
  await envVarsDeleteCommand(env, keyOrId, options);
32777
32940
  } catch (error51) {
32778
32941
  if (error51 instanceof Error) {
32779
- console.error(import_chalk23.default.red(`
32942
+ console.error(import_chalk24.default.red(`
32780
32943
  \u2717 ${error51.message}
32781
32944
  `));
32782
32945
  }
@@ -32789,7 +32952,7 @@ envFiles.command("list <env>").description("List files in an environment").actio
32789
32952
  await envFilesListCommand(env);
32790
32953
  } catch (error51) {
32791
32954
  if (error51 instanceof Error) {
32792
- console.error(import_chalk23.default.red(`
32955
+ console.error(import_chalk24.default.red(`
32793
32956
  \u2717 ${error51.message}
32794
32957
  `));
32795
32958
  }
@@ -32801,7 +32964,7 @@ envFiles.command("set <env> <destination-path>").description("Create or update a
32801
32964
  await envFilesSetCommand(env, destinationPath, options);
32802
32965
  } catch (error51) {
32803
32966
  if (error51 instanceof Error) {
32804
- console.error(import_chalk23.default.red(`
32967
+ console.error(import_chalk24.default.red(`
32805
32968
  \u2717 ${error51.message}
32806
32969
  `));
32807
32970
  }
@@ -32813,7 +32976,7 @@ envFiles.command("delete <env> <path-or-id>").description("Delete a file by dest
32813
32976
  await envFilesDeleteCommand(env, pathOrId, options);
32814
32977
  } catch (error51) {
32815
32978
  if (error51 instanceof Error) {
32816
- console.error(import_chalk23.default.red(`
32979
+ console.error(import_chalk24.default.red(`
32817
32980
  \u2717 ${error51.message}
32818
32981
  `));
32819
32982
  }
@@ -32826,7 +32989,7 @@ function registerEnvironmentHookCommands(parent, config3) {
32826
32989
  try {
32827
32990
  await command();
32828
32991
  } catch (error51) {
32829
- if (error51 instanceof Error) console.error(import_chalk23.default.red(`
32992
+ if (error51 instanceof Error) console.error(import_chalk24.default.red(`
32830
32993
  \u2717 ${error51.message}
32831
32994
  `));
32832
32995
  process.exit(1);
@@ -32862,7 +33025,7 @@ environment.action(async () => {
32862
33025
  await environmentListCommand();
32863
33026
  } catch (error51) {
32864
33027
  if (error51 instanceof Error) {
32865
- console.error(import_chalk23.default.red(`
33028
+ console.error(import_chalk24.default.red(`
32866
33029
  \u2717 ${error51.message}
32867
33030
  `));
32868
33031
  }
@@ -32913,7 +33076,7 @@ if (isAgentMode()) {
32913
33076
  await previewAddCommand(workspaceId, options);
32914
33077
  } catch (error51) {
32915
33078
  if (error51 instanceof Error) {
32916
- console.error(import_chalk23.default.red(`
33079
+ console.error(import_chalk24.default.red(`
32917
33080
  \u2717 ${error51.message}
32918
33081
  `));
32919
33082
  }
@@ -32925,7 +33088,7 @@ if (isAgentMode()) {
32925
33088
  await previewListCommand(workspaceId);
32926
33089
  } catch (error51) {
32927
33090
  if (error51 instanceof Error) {
32928
- console.error(import_chalk23.default.red(`
33091
+ console.error(import_chalk24.default.red(`
32929
33092
  \u2717 ${error51.message}
32930
33093
  `));
32931
33094
  }
@@ -32937,7 +33100,7 @@ if (isAgentMode()) {
32937
33100
  await previewRemoveCommand(workspaceId, options);
32938
33101
  } catch (error51) {
32939
33102
  if (error51 instanceof Error) {
32940
- console.error(import_chalk23.default.red(`
33103
+ console.error(import_chalk24.default.red(`
32941
33104
  \u2717 ${error51.message}
32942
33105
  `));
32943
33106
  }
@@ -32946,6 +33109,10 @@ if (isAgentMode()) {
32946
33109
  });
32947
33110
  }
32948
33111
  if (isAgentMode()) {
33112
+ const identity = program.command("identity").description("Read the short-lived workspace identity token delivered by Replicas");
33113
+ identity.command("token").description("Print the current workspace token for an audience (defaults to the environment default audience)").option("-a, --audience <audience>", "Registered audience to read the token for").addOption(new import_commander.Option("--format <format>", "Output a raw token or Google executable credentials").choices(["text", "gcp"]).default("text")).action(identityTokenCommand);
33114
+ identity.command("aws-credentials").description("Exchange the current token for temporary AWS credentials (for AWS credential_process)").requiredOption("--role-arn <arn>", "IAM role that trusts the Replicas issuer").option("-a, --audience <audience>", "Registered audience accepted by the IAM OIDC provider", "sts.amazonaws.com").option("--region <region>", "AWS region for the STS exchange").option("--session-name <name>", "AWS role session name", "replicas").action(identityAwsCredentialsCommand);
33115
+ identity.command("exec [command...]").description("Run a command with REPLICAS_WORKSPACE_TOKEN set to a fresh token: replicas identity exec -- curl ...").option("-a, --audience <audience>", "Registered audience to read the token for").action((command, options) => identityExecCommand(command, options));
32949
33116
  const service = program.command("service").description("Run long-lived services (dev servers, daemons) detached from the agent session so they survive workspace sleep/wake");
32950
33117
  service.command("start <name> [command...]").description('Start (or restart) a named service as a detached daemon. Quote shell operators: replicas service start web "cd app && bun dev"').option("-d, --cwd <dir>", "Working directory for the service (defaults to the current directory)").action(async (name, commandParts, options) => {
32951
33118
  try {
@@ -32998,7 +33165,7 @@ if (isAgentMode()) {
32998
33165
  await mediaUploadCommand(files, options);
32999
33166
  } catch (error51) {
33000
33167
  if (error51 instanceof Error) {
33001
- console.error(import_chalk23.default.red(`
33168
+ console.error(import_chalk24.default.red(`
33002
33169
  \u2717 ${error51.message}
33003
33170
  `));
33004
33171
  }
@@ -33009,7 +33176,7 @@ if (isAgentMode()) {
33009
33176
  try {
33010
33177
  await mediaShareCommand(mediaId);
33011
33178
  } catch (error51) {
33012
- if (error51 instanceof Error) console.error(import_chalk23.default.red(`
33179
+ if (error51 instanceof Error) console.error(import_chalk24.default.red(`
33013
33180
  \u2717 ${error51.message}
33014
33181
  `));
33015
33182
  process.exit(1);
@@ -33019,7 +33186,7 @@ if (isAgentMode()) {
33019
33186
  try {
33020
33187
  await mediaRevokeCommand(mediaId);
33021
33188
  } catch (error51) {
33022
- if (error51 instanceof Error) console.error(import_chalk23.default.red(`
33189
+ if (error51 instanceof Error) console.error(import_chalk24.default.red(`
33023
33190
  \u2717 ${error51.message}
33024
33191
  `));
33025
33192
  process.exit(1);
@@ -33030,7 +33197,7 @@ if (isAgentMode()) {
33030
33197
  await mediaListCommand(options);
33031
33198
  } catch (error51) {
33032
33199
  if (error51 instanceof Error) {
33033
- console.error(import_chalk23.default.red(`
33200
+ console.error(import_chalk24.default.red(`
33034
33201
  \u2717 ${error51.message}
33035
33202
  `));
33036
33203
  }
@@ -33043,7 +33210,7 @@ if (isAgentMode()) {
33043
33210
  await mothershipMonitorChannelCommand(options);
33044
33211
  } catch (error51) {
33045
33212
  if (error51 instanceof Error) {
33046
- console.error(import_chalk23.default.red(`
33213
+ console.error(import_chalk24.default.red(`
33047
33214
  \u2717 ${error51.message}
33048
33215
  `));
33049
33216
  }
@@ -33055,7 +33222,7 @@ if (isAgentMode()) {
33055
33222
  await mothershipSpawnCommand(options);
33056
33223
  } catch (error51) {
33057
33224
  if (error51 instanceof Error) {
33058
- console.error(import_chalk23.default.red(`
33225
+ console.error(import_chalk24.default.red(`
33059
33226
  \u2717 ${error51.message}
33060
33227
  `));
33061
33228
  }
@@ -33067,7 +33234,7 @@ if (isAgentMode()) {
33067
33234
  await mothershipRelayCommand(options);
33068
33235
  } catch (error51) {
33069
33236
  if (error51 instanceof Error) {
33070
- console.error(import_chalk23.default.red(`
33237
+ console.error(import_chalk24.default.red(`
33071
33238
  \u2717 ${error51.message}
33072
33239
  `));
33073
33240
  }
@@ -33076,6 +33243,7 @@ if (isAgentMode()) {
33076
33243
  });
33077
33244
  program.command("computer").description("Drive the workspace Linux desktop through replicas-computer");
33078
33245
  const allowed = /* @__PURE__ */ new Set([
33246
+ "identity",
33079
33247
  "init",
33080
33248
  "whoami",
33081
33249
  "list",
@@ -33097,9 +33265,9 @@ if (isAgentMode()) {
33097
33265
  }
33098
33266
  async function main() {
33099
33267
  if (process.argv[2] === "computer" && isAgentMode()) {
33100
- const result = (0, import_node_child_process2.spawnSync)("replicas-computer", process.argv.slice(3), { stdio: "inherit" });
33268
+ const result = (0, import_node_child_process3.spawnSync)("replicas-computer", process.argv.slice(3), { stdio: "inherit" });
33101
33269
  if (result.error) {
33102
- console.error(import_chalk23.default.red(`
33270
+ console.error(import_chalk24.default.red(`
33103
33271
  \u2717 replicas-computer is unavailable in this workspace image
33104
33272
  `));
33105
33273
  process.exitCode = 1;
@@ -33108,7 +33276,7 @@ async function main() {
33108
33276
  process.exitCode = result.status ?? 1;
33109
33277
  return;
33110
33278
  }
33111
- startUpdateCheck(CLI_VERSION);
33279
+ if (process.argv[2] !== "identity") startUpdateCheck(CLI_VERSION);
33112
33280
  program.parse();
33113
33281
  }
33114
33282
  main().catch(() => {