@preplabsai/rovara-code 0.5.13 → 0.5.15
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/bin/agentx-cli.mjs +98 -33
- package/package.json +1 -1
package/bin/agentx-cli.mjs
CHANGED
|
@@ -385024,7 +385024,7 @@ init_dist2();
|
|
|
385024
385024
|
import { realpathSync } from "node:fs";
|
|
385025
385025
|
|
|
385026
385026
|
// packages/cli/src/version.ts
|
|
385027
|
-
var RELEASE_VERSION = true ? "0.5.
|
|
385027
|
+
var RELEASE_VERSION = true ? "0.5.15" : void 0;
|
|
385028
385028
|
var CLI_VERSION = RELEASE_VERSION ?? "0.1.0";
|
|
385029
385029
|
function isPrereleaseVersion(version3) {
|
|
385030
385030
|
return /^\d+\.\d+\.\d+-/.test(version3);
|
|
@@ -397731,24 +397731,34 @@ function proposeCommands(files, cwd) {
|
|
|
397731
397731
|
if (readiness.length === 0 && has3("Makefile") && /^test:/m.test(files.Makefile)) add(readiness, "make test", "the Makefile's test target");
|
|
397732
397732
|
return { setup, readiness, basis };
|
|
397733
397733
|
}
|
|
397734
|
-
|
|
397735
|
-
const name3 = githubAppSecretName(input2.env);
|
|
397736
|
-
const raw2 = await input2.secrets.get(name3);
|
|
397734
|
+
function appJwtFromSecret(raw2, name3, nowSeconds) {
|
|
397737
397735
|
if (raw2 === void 0) {
|
|
397738
397736
|
throw agentXError("CONFIG_INVALID", `secret ${name3} does not exist; run agentx init again so the GitHub App step stores it`);
|
|
397739
397737
|
}
|
|
397740
397738
|
const app = parseAppSecret(raw2, name3);
|
|
397741
|
-
|
|
397742
|
-
|
|
397743
|
-
|
|
397744
|
-
|
|
397745
|
-
|
|
397746
|
-
throw agentXError("CONFIG_INVALID", installations2.length === 0 ? "the GitHub App is not installed anywhere; install it on your organization and choose repositories, then run this again" : `the GitHub App is installed on ${installations2.length} accounts (${installations2.map((entry) => entry.account.login).join(", ")}); AgentX uses one, so uninstall the others`);
|
|
397747
|
-
}
|
|
397748
|
-
installationId = String(installations2[0].id);
|
|
397739
|
+
return githubAppJwt({ appId: app.appId, privateKey: app.privateKey, nowSeconds });
|
|
397740
|
+
}
|
|
397741
|
+
function onlyInstallation(installations2) {
|
|
397742
|
+
if (installations2.length !== 1) {
|
|
397743
|
+
throw agentXError("CONFIG_INVALID", installations2.length === 0 ? "the GitHub App is not installed anywhere; install it on your organization and choose repositories, then run this again" : `the GitHub App is installed on ${installations2.length} accounts (${installations2.map((entry) => entry.account.login).join(", ")}); AgentX uses one, so uninstall the others`);
|
|
397749
397744
|
}
|
|
397745
|
+
return installations2[0];
|
|
397746
|
+
}
|
|
397747
|
+
async function installationToken(input2) {
|
|
397748
|
+
const name3 = githubAppSecretName(input2.env);
|
|
397749
|
+
const jwt2 = appJwtFromSecret(await input2.secrets.get(name3), name3, input2.nowSeconds);
|
|
397750
|
+
const installationId = input2.installationId ?? String(onlyInstallation(await input2.github.listInstallations(jwt2)).id);
|
|
397750
397751
|
return (await input2.github.installationToken(jwt2, installationId)).token;
|
|
397751
397752
|
}
|
|
397753
|
+
async function installationAccess(input2) {
|
|
397754
|
+
const name3 = githubAppSecretName(input2.env);
|
|
397755
|
+
const jwt2 = appJwtFromSecret(await input2.secrets.get(name3), name3, input2.nowSeconds);
|
|
397756
|
+
const installation = onlyInstallation(await input2.github.listInstallations(jwt2));
|
|
397757
|
+
const installationId = String(installation.id);
|
|
397758
|
+
const token = (await input2.github.installationToken(jwt2, installationId)).token;
|
|
397759
|
+
const accountType = installation.account.type === "Organization" ? "organization" : "user";
|
|
397760
|
+
return { token, installationId, settingsUrl: installationSettingsUrl(accountType, installation.account.login, installationId) };
|
|
397761
|
+
}
|
|
397752
397762
|
|
|
397753
397763
|
// packages/cli/src/setup/services.ts
|
|
397754
397764
|
var import_client_cognito_identity_provider = __toESM(require_dist_cjs47(), 1);
|
|
@@ -399772,20 +399782,58 @@ async function registerRevision(request) {
|
|
|
399772
399782
|
return { revision: input2.definition.revision, preflight: preflight.success ? preflight.data.connectors : [], warnings, file: file2 };
|
|
399773
399783
|
}
|
|
399774
399784
|
var REPOSITORY_EXAMPLES = 5;
|
|
399775
|
-
|
|
399776
|
-
|
|
399785
|
+
var REPOSITORY_ACCESS_WAIT_MS = 10 * 60 * 1e3;
|
|
399786
|
+
var REPOSITORY_ACCESS_POLL_MS = 5e3;
|
|
399787
|
+
var findRepository = (repositories, wanted) => repositories.find((repo) => repo.fullName.toLowerCase() === wanted.toLowerCase());
|
|
399788
|
+
var addAt = (access10) => access10 === void 0 ? "" : ` at ${access10.settingsUrl}`;
|
|
399789
|
+
function notVisible(wanted, names, access10, waited = "") {
|
|
399790
|
+
const seen = names.length === 0 ? "it sees no repositories" : `it sees ${names.join(", ")}`;
|
|
399791
|
+
return agentXError("CONFIG_INVALID", `the GitHub App cannot see ${wanted}${waited}; ${seen}. Add the repository to the app's installation${addAt(access10)}, or choose one of those`);
|
|
399792
|
+
}
|
|
399793
|
+
async function waitForRepository(input2) {
|
|
399794
|
+
const { wanted, wait: wait2, access: access10 } = input2;
|
|
399795
|
+
input2.write(`The GitHub App can't see ${wanted} yet.`);
|
|
399796
|
+
input2.write(wait2.openBrowser === void 0 ? `Add it to the app's installation on GitHub: ${access10.settingsUrl}` : `Opening GitHub so you can add it: ${access10.settingsUrl}`);
|
|
399797
|
+
if (wait2.openBrowser !== void 0) await wait2.openBrowser(access10.settingsUrl);
|
|
399798
|
+
input2.write("Waiting for access\u2026 (Ctrl-C to stop)");
|
|
399799
|
+
const timeoutMs = wait2.timeoutMs ?? REPOSITORY_ACCESS_WAIT_MS;
|
|
399800
|
+
const deadline = wait2.now() + timeoutMs;
|
|
399801
|
+
let names = [];
|
|
399802
|
+
for (; ; ) {
|
|
399803
|
+
await wait2.sleep(wait2.pollMs ?? REPOSITORY_ACCESS_POLL_MS);
|
|
399804
|
+
const repositories = await input2.list().catch((error64) => {
|
|
399805
|
+
if (error64 instanceof AgentXError) return void 0;
|
|
399806
|
+
throw error64;
|
|
399807
|
+
});
|
|
399808
|
+
const found = repositories === void 0 ? void 0 : findRepository(repositories, wanted);
|
|
399809
|
+
if (found !== void 0) {
|
|
399810
|
+
input2.write(`The app can see ${found.fullName} now.`);
|
|
399811
|
+
return found;
|
|
399812
|
+
}
|
|
399813
|
+
if (repositories !== void 0) names = repositories.map((repo) => repo.fullName);
|
|
399814
|
+
if (wait2.now() >= deadline) throw notVisible(wanted, names, access10, ` after ${Math.round(timeoutMs / 6e4)} minutes of waiting`);
|
|
399815
|
+
}
|
|
399816
|
+
}
|
|
399817
|
+
async function chooseRepository(input2) {
|
|
399818
|
+
const { prompter, flag, access: access10 } = input2;
|
|
399819
|
+
const repositories = await input2.list();
|
|
399777
399820
|
const names = repositories.map((repo) => repo.fullName);
|
|
399821
|
+
if (flag !== void 0) {
|
|
399822
|
+
const found2 = findRepository(repositories, flag);
|
|
399823
|
+
if (found2 !== void 0) return found2;
|
|
399824
|
+
if (access10?.wait === void 0) throw notVisible(flag, names, access10);
|
|
399825
|
+
return waitForRepository({ wanted: flag, list: input2.list, access: access10, wait: access10.wait, write: input2.write });
|
|
399826
|
+
}
|
|
399827
|
+
if (repositories.length === 0) throw agentXError("CONFIG_INVALID", `the GitHub App sees no repositories; choose at least one in the app's installation settings${addAt(access10)}, then run this again`);
|
|
399778
399828
|
const examples = names.slice(0, REPOSITORY_EXAMPLES).join(", ") + (names.length > REPOSITORY_EXAMPLES ? `, and ${names.length - REPOSITORY_EXAMPLES} more` : "");
|
|
399779
|
-
const wanted =
|
|
399829
|
+
const wanted = await prompter.choose("Which repository is the first project's?", names.map((fullName) => ({ value: fullName, label: fullName })), {
|
|
399780
399830
|
flag: "--repository",
|
|
399781
399831
|
defaultValue: names[0],
|
|
399782
399832
|
// With --yes (or no terminal) the first of several repositories is never guessed.
|
|
399783
399833
|
unattendedRefusal: `the GitHub App sees ${names.length} repositories (for example ${examples}); pass --repository <owner/name> to choose the first project's`
|
|
399784
399834
|
});
|
|
399785
|
-
const found = repositories
|
|
399786
|
-
if (found === void 0)
|
|
399787
|
-
throw agentXError("CONFIG_INVALID", `the GitHub App cannot see ${wanted}; it sees ${names.join(", ")}. Add the repository to the app's installation, or choose one of those`);
|
|
399788
|
-
}
|
|
399835
|
+
const found = findRepository(repositories, wanted);
|
|
399836
|
+
if (found === void 0) throw notVisible(wanted, names, access10);
|
|
399789
399837
|
return found;
|
|
399790
399838
|
}
|
|
399791
399839
|
async function existingProject(configDir, name3) {
|
|
@@ -400013,7 +400061,13 @@ async function addProject(input2) {
|
|
|
400013
400061
|
}
|
|
400014
400062
|
let repository;
|
|
400015
400063
|
const chosenRepository = async () => {
|
|
400016
|
-
const picked = await chooseRepository(
|
|
400064
|
+
const picked = await chooseRepository({
|
|
400065
|
+
list: () => input2.services.repositories.list(input2.githubToken),
|
|
400066
|
+
prompter,
|
|
400067
|
+
flag: flags.repository,
|
|
400068
|
+
write: input2.write,
|
|
400069
|
+
...input2.repositoryAccess === void 0 ? {} : { access: input2.repositoryAccess }
|
|
400070
|
+
});
|
|
400017
400071
|
input2.onRepository?.(picked.fullName);
|
|
400018
400072
|
return picked;
|
|
400019
400073
|
};
|
|
@@ -405383,6 +405437,13 @@ function projectModelChecker(settings, input2) {
|
|
|
405383
405437
|
};
|
|
405384
405438
|
}
|
|
405385
405439
|
function realSetupContext(input2) {
|
|
405440
|
+
const openBrowser = async (url2) => {
|
|
405441
|
+
try {
|
|
405442
|
+
await openSystemBrowser(url2);
|
|
405443
|
+
} catch {
|
|
405444
|
+
input2.stderr.write("could not open a browser; open the address above\n");
|
|
405445
|
+
}
|
|
405446
|
+
};
|
|
405386
405447
|
const openAws = async (command5) => {
|
|
405387
405448
|
const globals = command5.optsWithGlobals();
|
|
405388
405449
|
const settings = await readEnvironmentSettings(input2.parameterStore(globals.region), globals.env);
|
|
@@ -405411,7 +405472,9 @@ function realSetupContext(input2) {
|
|
|
405411
405472
|
now: Date.now,
|
|
405412
405473
|
print: (result4, text16) => {
|
|
405413
405474
|
input2.stdout.write(globals.json ? formatSuccess(result4, true) : text16);
|
|
405414
|
-
}
|
|
405475
|
+
},
|
|
405476
|
+
interactive: process.stdin.isTTY === true && !globals.json,
|
|
405477
|
+
openBrowser
|
|
405415
405478
|
};
|
|
405416
405479
|
};
|
|
405417
405480
|
return {
|
|
@@ -405423,15 +405486,7 @@ function realSetupContext(input2) {
|
|
|
405423
405486
|
services: run2.services,
|
|
405424
405487
|
write: run2.write,
|
|
405425
405488
|
now: run2.now,
|
|
405426
|
-
|
|
405427
|
-
// already printed.
|
|
405428
|
-
openBrowser: async (url2) => {
|
|
405429
|
-
try {
|
|
405430
|
-
await openSystemBrowser(url2);
|
|
405431
|
-
} catch {
|
|
405432
|
-
run2.write("could not open a browser; open the address above");
|
|
405433
|
-
}
|
|
405434
|
-
}
|
|
405489
|
+
openBrowser
|
|
405435
405490
|
});
|
|
405436
405491
|
return { ...run2, session };
|
|
405437
405492
|
}
|
|
@@ -406262,11 +406317,21 @@ function projectOption(command5, what) {
|
|
|
406262
406317
|
}
|
|
406263
406318
|
function registerSetupCommands(program2, context) {
|
|
406264
406319
|
const project3 = program2.command("project").description("AgentX projects");
|
|
406265
|
-
withRegion(project3.command("add").description("register a new project from a repository the GitHub App sees, on EC2 workers")).option("--repository <owner/name>", "the repository").option("--project-name <name>", "the project's name (default: the repository's)").option("--setup-command <command>", 'the setup command, or "" for none').option("--test-command <command>", 'the test command, or "" for none').action(async (options, command5) => {
|
|
406320
|
+
withRegion(project3.command("add").description("register a new project from a repository the GitHub App sees, on EC2 workers")).option("--repository <owner/name>", "the repository").option("--project-name <name>", "the project's name (default: the repository's)").option("--setup-command <command>", 'the setup command, or "" for none').option("--test-command <command>", 'the test command, or "" for none').option("--no-browser", "when the GitHub App cannot see the repository yet, print the page where it is added instead of opening it").action(async (options, command5) => {
|
|
406266
406321
|
const run2 = await context.open(command5);
|
|
406267
|
-
const
|
|
406322
|
+
const access10 = await installationAccess({ env: run2.env, secrets: run2.secrets, github: run2.services.github, nowSeconds: Math.floor(Date.now() / 1e3) });
|
|
406268
406323
|
const flags = definedEntries({ repository: options.repository, projectName: options.projectName, setupCommand: options.setupCommand, testCommand: options.testCommand });
|
|
406269
|
-
const
|
|
406324
|
+
const wait2 = run2.interactive === true ? { sleep: run2.sleep, now: run2.now, ...options.browser === false || run2.openBrowser === void 0 ? {} : { openBrowser: run2.openBrowser } } : void 0;
|
|
406325
|
+
const result4 = await addProject({
|
|
406326
|
+
env: run2.env,
|
|
406327
|
+
session: run2.session,
|
|
406328
|
+
githubToken: access10.token,
|
|
406329
|
+
prompter: run2.prompter,
|
|
406330
|
+
write: run2.write,
|
|
406331
|
+
services: run2.services,
|
|
406332
|
+
flags,
|
|
406333
|
+
repositoryAccess: { settingsUrl: access10.settingsUrl, ...wait2 === void 0 ? {} : { wait: wait2 } }
|
|
406334
|
+
});
|
|
406270
406335
|
run2.print(result4, `Registered project ${result4.name} (revision ${result4.revision}); file ${result4.file}
|
|
406271
406336
|
`);
|
|
406272
406337
|
});
|