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