@preplabsai/rovara-code 0.5.14 → 0.5.16
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 +240 -45
- package/package.json +1 -1
package/bin/agentx-cli.mjs
CHANGED
|
@@ -25808,6 +25808,8 @@ var init_routes = __esm({
|
|
|
25808
25808
|
{ method: "POST", path: "/v1/dev/tasks/{taskId}/workflow/feedback-decision", requires: "decisions:decide" },
|
|
25809
25809
|
// T3: invite administration is full-access only; live company admin/owner membership is still required.
|
|
25810
25810
|
{ method: "POST", path: "/v1/dev/company/preapprovals", requires: "full" },
|
|
25811
|
+
// #1647: the company's invites (a live owner or admin), for `rovara company invites`.
|
|
25812
|
+
{ method: "GET", path: "/v1/dev/company/preapprovals", requires: "full" },
|
|
25811
25813
|
// INVITE-RESEND (DEC 254zzz184): the website-only resend remains behind full access and the route's live company role check.
|
|
25812
25814
|
{ method: "POST", path: "/v1/dev/company/preapprovals/{inviteId}/resend", requires: "full" },
|
|
25813
25815
|
{ method: "DELETE", path: "/v1/dev/company/preapprovals/{emailHash}", requires: "full" },
|
|
@@ -43285,7 +43287,7 @@ var init_intake = __esm({
|
|
|
43285
43287
|
/** A `tracker` names its system; `jira` and `github_issue` are fixed and may leave it out. */
|
|
43286
43288
|
system: IntakeSystemSchema.optional(),
|
|
43287
43289
|
connection: external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9 ._-]{0,63}$/, "a connection is a name or id, never an address").optional(),
|
|
43288
|
-
when: external_exports.object({ label: LabelSchema2.optional(), assignedToRovara: external_exports.literal(true).optional() }).strict().refine((
|
|
43290
|
+
when: external_exports.object({ label: LabelSchema2.optional(), assignedToRovara: external_exports.literal(true).optional() }).strict().refine((when3) => when3.label !== void 0 || when3.assignedToRovara === true, "name the label, or assignment to Rovara, that asks for work"),
|
|
43289
43291
|
poll: IntakePollSettingsSchema.optional()
|
|
43290
43292
|
}).strict().superRefine((ref, context) => {
|
|
43291
43293
|
if (ref.channel === "tracker" && ref.system === void 0)
|
|
@@ -61939,7 +61941,10 @@ function newCompanyInviteCode() {
|
|
|
61939
61941
|
const codeHash = companyInviteCodeHash(code2);
|
|
61940
61942
|
return { code: code2, codeHash, codeId: companyInviteCodeId(codeHash) };
|
|
61941
61943
|
}
|
|
61942
|
-
|
|
61944
|
+
function companyInviteEmailHash(email4) {
|
|
61945
|
+
return createHash12("sha256").update(email4.trim().toLowerCase(), "utf8").digest("hex");
|
|
61946
|
+
}
|
|
61947
|
+
var COMPANY_INVITE_CODE_PREFIX, CODE_BYTES, CompanyInviteCodeHashSchema, CompanyInviteCodeIdSchema, CompanyInviteExpiryHoursSchema, companyInviteCodeId, CompanyInviteViewSchema, CompanyInviteListSchema, CompanySelfServeNameSchema, CompanySelfCreateBodySchema, CompanySelfCreateResponseSchema, COMPANY_INVITE_LINK_PREFIX, COMPANY_INVITE_LINK_MAX, CompanyPreapprovalCreatedSchema, COMPANY_PREAPPROVALS_PATH, CompanyInviteEmailHashSchema, CompanyPreapprovalViewSchema, CompanyPreapprovalListSchema;
|
|
61943
61948
|
var init_company_invites = __esm({
|
|
61944
61949
|
"packages/contracts/dist/company-invites.js"() {
|
|
61945
61950
|
"use strict";
|
|
@@ -61963,7 +61968,20 @@ var init_company_invites = __esm({
|
|
|
61963
61968
|
CompanySelfCreateBodySchema = external_exports.object({ name: CompanySelfServeNameSchema, inviteCode: external_exports.unknown().optional() }).strict();
|
|
61964
61969
|
CompanySelfCreateResponseSchema = external_exports.object({ companyId: external_exports.string(), companyName: external_exports.string().min(1).max(80), companyRole: external_exports.literal("owner") }).strict();
|
|
61965
61970
|
COMPANY_INVITE_LINK_PREFIX = "rvlink_";
|
|
61971
|
+
COMPANY_INVITE_LINK_MAX = 256;
|
|
61966
61972
|
CompanyPreapprovalCreatedSchema = external_exports.object({ ok: external_exports.literal(true), invite: external_exports.object({ secret: external_exports.string().startsWith(COMPANY_INVITE_LINK_PREFIX), expiresAt: external_exports.iso.datetime() }).strict() }).strict();
|
|
61973
|
+
COMPANY_PREAPPROVALS_PATH = "/v1/dev/company/preapprovals";
|
|
61974
|
+
CompanyInviteEmailHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
61975
|
+
CompanyPreapprovalViewSchema = external_exports.object({
|
|
61976
|
+
emailHash: CompanyInviteEmailHashSchema,
|
|
61977
|
+
role: external_exports.enum(["admin", "member"]),
|
|
61978
|
+
/** pending: the link still works; used: someone joined with it; withdrawn: an owner or admin ended it (or it was replaced); expired: its time ran out unused. */
|
|
61979
|
+
status: external_exports.enum(["pending", "used", "withdrawn", "expired"]),
|
|
61980
|
+
expiresAt: external_exports.iso.datetime(),
|
|
61981
|
+
createdAt: external_exports.iso.datetime(),
|
|
61982
|
+
usedAt: external_exports.iso.datetime().optional()
|
|
61983
|
+
}).strict();
|
|
61984
|
+
CompanyPreapprovalListSchema = external_exports.object({ invites: external_exports.array(CompanyPreapprovalViewSchema).max(100), more: external_exports.boolean() }).strict();
|
|
61967
61985
|
}
|
|
61968
61986
|
});
|
|
61969
61987
|
|
|
@@ -377081,6 +377099,17 @@ function chatGptDisconnectText(result4) {
|
|
|
377081
377099
|
|
|
377082
377100
|
// packages/cli/src/developer/login.ts
|
|
377083
377101
|
init_dist2();
|
|
377102
|
+
function loginInvite(companyId, secret) {
|
|
377103
|
+
if (companyId === void 0 && secret === void 0) return void 0;
|
|
377104
|
+
if (companyId === void 0 || secret === void 0) throw agentXError("CONFIG_INVALID", "an invite needs both --company and --invite; copy the whole command the person who invited you sent");
|
|
377105
|
+
if (!OrgIdSchema.safeParse(companyId).success) throw agentXError("CONFIG_INVALID", "--company is not a company ID (org_ and 20 letters or digits); copy the whole command the person who invited you sent");
|
|
377106
|
+
if (!secret.startsWith(COMPANY_INVITE_LINK_PREFIX) || secret.length > COMPANY_INVITE_LINK_MAX) throw agentXError("CONFIG_INVALID", `--invite is not an invite (it starts with ${COMPANY_INVITE_LINK_PREFIX}); copy the whole command the person who invited you sent`);
|
|
377107
|
+
return { companyId, secret };
|
|
377108
|
+
}
|
|
377109
|
+
var INVITE_REFUSED = "this invite did not work: it may have expired, been used already or been withdrawn. Ask the person who invited you for a new one";
|
|
377110
|
+
function inviteRefusal(error64) {
|
|
377111
|
+
return error64 instanceof AgentXError && error64.code === "AUTH_REQUIRED" && /: not invited$/u.test(error64.message) ? agentXError("AUTH_REQUIRED", `sign-in refused: ${INVITE_REFUSED}`) : error64;
|
|
377112
|
+
}
|
|
377084
377113
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
377085
377114
|
async function readConfiguration(options, base3, url2) {
|
|
377086
377115
|
let configuration;
|
|
@@ -377129,7 +377158,8 @@ async function developerLogin(options) {
|
|
|
377129
377158
|
redirect_uri: listener.redirectUri,
|
|
377130
377159
|
state: pkce.state,
|
|
377131
377160
|
code_challenge: pkce.challenge,
|
|
377132
|
-
code_challenge_method: "S256"
|
|
377161
|
+
code_challenge_method: "S256",
|
|
377162
|
+
...options.invite === void 0 ? {} : { company: options.invite.companyId, invite: options.invite.secret }
|
|
377133
377163
|
})) authorize.searchParams.set(key2, value);
|
|
377134
377164
|
if (options.browser) {
|
|
377135
377165
|
options.write(`Opening your browser to sign in to AgentX environment ${configuration.env}. If it does not open, open this link: ${authorize.toString()}`);
|
|
@@ -377137,7 +377167,9 @@ async function developerLogin(options) {
|
|
|
377137
377167
|
} else {
|
|
377138
377168
|
options.write(`Open this link in a browser on this computer to sign in to AgentX environment ${configuration.env}: ${authorize.toString()}`);
|
|
377139
377169
|
}
|
|
377140
|
-
const code2 = await listener.code
|
|
377170
|
+
const code2 = await listener.code.catch((error64) => {
|
|
377171
|
+
throw options.invite === void 0 ? error64 : inviteRefusal(error64);
|
|
377172
|
+
});
|
|
377141
377173
|
let response;
|
|
377142
377174
|
try {
|
|
377143
377175
|
response = await options.fetch(configuration.tokenEndpoint, {
|
|
@@ -378737,6 +378769,98 @@ function registerSessionCommands(program2, context) {
|
|
|
378737
378769
|
|
|
378738
378770
|
// packages/cli/src/company/commands.ts
|
|
378739
378771
|
init_dist2();
|
|
378772
|
+
|
|
378773
|
+
// packages/cli/src/company/invites.ts
|
|
378774
|
+
init_dist2();
|
|
378775
|
+
init_zod();
|
|
378776
|
+
var DEFAULT_INVITE_HOURS = 168;
|
|
378777
|
+
var Email = external_exports.string().trim().min(3).max(320).email();
|
|
378778
|
+
var ADMIN_ONLY = "Only a company owner or admin can invite people or see the company's invites.";
|
|
378779
|
+
var UNEXPECTED2 = `AgentX answered with something unexpected; try again, or upgrade: npx ${CLI_PACKAGE_NAME}@latest whoami`;
|
|
378780
|
+
function inviteEmail(email4) {
|
|
378781
|
+
const parsed = Email.safeParse(email4);
|
|
378782
|
+
if (!parsed.success) throw agentXError("CONFIG_INVALID", "give the teammate's email address, for example dev@example.com");
|
|
378783
|
+
return parsed.data;
|
|
378784
|
+
}
|
|
378785
|
+
function inviteHours(value) {
|
|
378786
|
+
if (value === void 0) return DEFAULT_INVITE_HOURS;
|
|
378787
|
+
const hours = /^\d{1,3}$/u.test(value) ? Number(value) : Number.NaN;
|
|
378788
|
+
if (!Number.isInteger(hours) || hours < 1 || hours > 720) throw agentXError("CONFIG_INVALID", "--expires-in-hours takes a whole number of hours from 1 to 720 (30 days)");
|
|
378789
|
+
return hours;
|
|
378790
|
+
}
|
|
378791
|
+
function emailHashOf(value) {
|
|
378792
|
+
const trimmed = value.trim().toLowerCase();
|
|
378793
|
+
if (CompanyInviteEmailHashSchema.safeParse(trimmed).success) return trimmed;
|
|
378794
|
+
return companyInviteEmailHash(inviteEmail(value));
|
|
378795
|
+
}
|
|
378796
|
+
function routeFields(body) {
|
|
378797
|
+
return Object.fromEntries(Object.entries(body).filter(([key2]) => key2 !== "requestId"));
|
|
378798
|
+
}
|
|
378799
|
+
var when2 = (iso8) => `${iso8.slice(0, 10)} ${iso8.slice(11, 16)} UTC`;
|
|
378800
|
+
var STATUS_WORDS2 = { pending: "pending", used: "joined", withdrawn: "withdrawn", expired: "expired" };
|
|
378801
|
+
function inviteLine(invite) {
|
|
378802
|
+
const times = invite.status === "used" && invite.usedAt !== void 0 ? `joined ${when2(invite.usedAt)}` : invite.status === "pending" ? `made ${when2(invite.createdAt)}, ends ${when2(invite.expiresAt)}` : invite.status === "expired" ? `ended ${when2(invite.expiresAt)}` : `made ${when2(invite.createdAt)}`;
|
|
378803
|
+
return ` ${STATUS_WORDS2[invite.status].padEnd(9)} ${invite.emailHash.slice(0, 12)} ${invite.role.padEnd(6)} ${times}`;
|
|
378804
|
+
}
|
|
378805
|
+
async function companyOf(deps, env3) {
|
|
378806
|
+
const answer2 = await appRequest(deps, env3, COMPANY_DETAILS_PATH);
|
|
378807
|
+
const details2 = CompanyDetailsViewSchema.safeParse(routeFields(answer2.body));
|
|
378808
|
+
if (!details2.success) throw agentXError("RUNTIME_UNAVAILABLE", UNEXPECTED2);
|
|
378809
|
+
if (details2.data.role === "member") throw new ReportedFailure("FORBIDDEN", ADMIN_ONLY, 1);
|
|
378810
|
+
return { companyId: details2.data.companyId, name: details2.data.name };
|
|
378811
|
+
}
|
|
378812
|
+
async function inviteList(deps, env3) {
|
|
378813
|
+
const answer2 = await appRequest(deps, env3, COMPANY_PREAPPROVALS_PATH);
|
|
378814
|
+
const list4 = CompanyPreapprovalListSchema.safeParse(routeFields(answer2.body));
|
|
378815
|
+
if (!list4.success) throw agentXError("RUNTIME_UNAVAILABLE", UNEXPECTED2);
|
|
378816
|
+
return { env: answer2.env, url: answer2.url, list: list4.data };
|
|
378817
|
+
}
|
|
378818
|
+
async function companyInvite(deps, env3, email4, hours) {
|
|
378819
|
+
const address = inviteEmail(email4);
|
|
378820
|
+
const company = await companyOf(deps, env3);
|
|
378821
|
+
const hash9 = companyInviteEmailHash(address);
|
|
378822
|
+
const pending = (await inviteList(deps, env3)).list.invites.find((invite) => invite.emailHash === hash9 && invite.status === "pending");
|
|
378823
|
+
if (pending !== void 0) {
|
|
378824
|
+
throw agentXError("CONFIG_INVALID", `${address} already has an invite that ends ${when2(pending.expiresAt)}. To send a new one, withdraw it first: ${CLI_COMMAND_NAME} company invites withdraw ${address}`);
|
|
378825
|
+
}
|
|
378826
|
+
const answer2 = await appRequest(deps, env3, COMPANY_PREAPPROVALS_PATH, { method: "POST", body: { email: address, role: "member", expiresInHours: hours } });
|
|
378827
|
+
const created = CompanyPreapprovalCreatedSchema.safeParse(routeFields(answer2.body));
|
|
378828
|
+
if (!created.success) throw agentXError("RUNTIME_UNAVAILABLE", UNEXPECTED2);
|
|
378829
|
+
const { secret, expiresAt } = created.data.invite;
|
|
378830
|
+
const command5 = `npx ${CLI_PACKAGE_NAME}@latest login ${answer2.url} --company ${company.companyId} --invite ${secret}`;
|
|
378831
|
+
const companyName2 = company.name === null ? "your company" : terminalSafe(company.name);
|
|
378832
|
+
const text16 = [
|
|
378833
|
+
`Invited ${address} to ${companyName2} as a member. The invite works once and ends ${when2(expiresAt)}.`,
|
|
378834
|
+
"Send them this command to run on their computer. It is shown only now, so copy it:",
|
|
378835
|
+
"",
|
|
378836
|
+
` ${command5}`,
|
|
378837
|
+
"",
|
|
378838
|
+
`They sign in with GitHub or your company login, using the email ${address}. Slack works for an invite only from this Rovara's own Slack workspace.`,
|
|
378839
|
+
`To see your invites: ${CLI_COMMAND_NAME} company invites. To withdraw this one: ${CLI_COMMAND_NAME} company invites withdraw ${address}`
|
|
378840
|
+
].join("\n") + "\n";
|
|
378841
|
+
return result(answer2, { companyId: company.companyId, email: address, emailHash: hash9, role: "member", expiresAt, invite: secret, command: command5 }, text16);
|
|
378842
|
+
}
|
|
378843
|
+
async function companyInvites(deps, env3, email4) {
|
|
378844
|
+
const hash9 = email4 === void 0 ? void 0 : emailHashOf(email4);
|
|
378845
|
+
const answer2 = await inviteList(deps, env3);
|
|
378846
|
+
const invites = hash9 === void 0 ? answer2.list.invites : answer2.list.invites.filter((invite) => invite.emailHash === hash9);
|
|
378847
|
+
const lines = invites.length === 0 ? [hash9 === void 0 ? "Your company has no invites." : "No invites for that email."] : [`Invites (Rovara keeps only a hash of each email; find one with --email <email>):`, ...invites.map(inviteLine)];
|
|
378848
|
+
if (answer2.list.more && hash9 === void 0) lines.push("More invites are not shown.");
|
|
378849
|
+
return result(answer2, { invites, more: answer2.list.more }, lines.join("\n") + "\n");
|
|
378850
|
+
}
|
|
378851
|
+
async function companyInviteWithdraw(deps, env3, emailOrHash) {
|
|
378852
|
+
const hash9 = emailHashOf(emailOrHash);
|
|
378853
|
+
let answer2;
|
|
378854
|
+
try {
|
|
378855
|
+
answer2 = await appRequest(deps, env3, `${COMPANY_PREAPPROVALS_PATH}/${hash9}`, { method: "DELETE" });
|
|
378856
|
+
} catch (error64) {
|
|
378857
|
+
if (error64 instanceof ReportedFailure && error64.failureCode === "NOT_FOUND") throw new ReportedFailure("NOT_FOUND", "No invite to withdraw for that email in your company (only a company owner or admin can withdraw one).", error64.exitCode);
|
|
378858
|
+
throw error64;
|
|
378859
|
+
}
|
|
378860
|
+
return result(answer2, { emailHash: hash9, withdrawn: true }, "Withdrew the invite. Its command no longer works.\n");
|
|
378861
|
+
}
|
|
378862
|
+
|
|
378863
|
+
// packages/cli/src/company/commands.ts
|
|
378740
378864
|
var ROLE_WORDS = { owner: "owner", admin: "administrator", member: "member" };
|
|
378741
378865
|
function detailsText(body, renamed) {
|
|
378742
378866
|
const members2 = typeof body.members === "number" ? body.members : 0;
|
|
@@ -378762,9 +378886,12 @@ async function companyRename(deps, env3, name3) {
|
|
|
378762
378886
|
}
|
|
378763
378887
|
function registerCompanyCommands(program2, context) {
|
|
378764
378888
|
const print = (command5, answer2) => context.write(context.globalOptions(command5).json ? formatSuccess({ env: answer2.env, url: answer2.url, ...answer2.data }, true) : answer2.text);
|
|
378765
|
-
const company = program2.command("company").description("your company on this Rovara: its name, ID, your role
|
|
378889
|
+
const company = program2.command("company").description("your company on this Rovara: its name, ID, your role, how many members it has, and inviting teammates");
|
|
378766
378890
|
company.command("show").description("show your company's name, ID, your role in it and how many members it has").action(async (_options, command5) => print(command5, await companyShow(context.developerSession(), context.developerEnv(command5))));
|
|
378767
378891
|
company.command("rename").description("give your company a new name (a company owner or administrator only)").argument("<name>", "the new name, 1 to 80 characters").action(async (name3, _options, command5) => print(command5, await companyRename(context.developerSession(), context.developerEnv(command5), name3)));
|
|
378892
|
+
company.command("invite").description("invite a teammate to your company as a member, by email; prints the one-time command they run to join (a company owner or administrator only)").argument("<email>", "the email the teammate signs in with").option("--expires-in-hours <hours>", "how long the invite works, 1 to 720 hours (default 168, one week)").action(async (email4, options, command5) => print(command5, await companyInvite(context.developerSession(), context.developerEnv(command5), email4, inviteHours(options.expiresInHours))));
|
|
378893
|
+
const invites = company.command("invites").description("list your company's invites: pending, joined, withdrawn and expired (a company owner or administrator only)").option("--email <email>", "only the invites for this email").action(async (options, command5) => print(command5, await companyInvites(context.developerSession(), context.developerEnv(command5), options.email)));
|
|
378894
|
+
invites.command("withdraw").description("withdraw an invite, so its command no longer works (a company owner or administrator only)").argument("<email>", "the invited email (or the invite's full hash)").action(async (email4, _options, command5) => print(command5, await companyInviteWithdraw(context.developerSession(), context.developerEnv(command5), email4)));
|
|
378768
378895
|
}
|
|
378769
378896
|
|
|
378770
378897
|
// packages/cli/src/admin/workspaces.ts
|
|
@@ -385024,7 +385151,7 @@ init_dist2();
|
|
|
385024
385151
|
import { realpathSync } from "node:fs";
|
|
385025
385152
|
|
|
385026
385153
|
// packages/cli/src/version.ts
|
|
385027
|
-
var RELEASE_VERSION = true ? "0.5.
|
|
385154
|
+
var RELEASE_VERSION = true ? "0.5.16" : void 0;
|
|
385028
385155
|
var CLI_VERSION = RELEASE_VERSION ?? "0.1.0";
|
|
385029
385156
|
function isPrereleaseVersion(version3) {
|
|
385030
385157
|
return /^\d+\.\d+\.\d+-/.test(version3);
|
|
@@ -390174,7 +390301,7 @@ var PHASE_TITLES = {
|
|
|
390174
390301
|
connect: "Connect GitHub and Slack",
|
|
390175
390302
|
finish: "Finish"
|
|
390176
390303
|
};
|
|
390177
|
-
var
|
|
390304
|
+
var STATUS_WORDS3 = {
|
|
390178
390305
|
done: "Done",
|
|
390179
390306
|
now: "Now",
|
|
390180
390307
|
waiting: "Waiting for you",
|
|
@@ -390299,7 +390426,7 @@ function journeyOf(input2) {
|
|
|
390299
390426
|
id: id12,
|
|
390300
390427
|
title: PHASE_TITLES[id12],
|
|
390301
390428
|
status,
|
|
390302
|
-
statusWord:
|
|
390429
|
+
statusWord: STATUS_WORDS3[status],
|
|
390303
390430
|
timeText: minutesText(toMinutes(phaseSeconds(id12))),
|
|
390304
390431
|
needsYou: id12 === "get-started" || id12 === "your-choices" || stepsIn(id12).some((step3) => STEP_PLAN[step3].needsYou)
|
|
390305
390432
|
};
|
|
@@ -396911,7 +397038,7 @@ function createSlackWorkspaceBindings(deps) {
|
|
|
396911
397038
|
await send3(indexTransaction(deps.tableName, winner, false));
|
|
396912
397039
|
}
|
|
396913
397040
|
};
|
|
396914
|
-
const
|
|
397041
|
+
const companyOf2 = (team) => operation2(async (send3) => {
|
|
396915
397042
|
if (!slackWorkspaceTeam(team))
|
|
396916
397043
|
throw new SlackWorkspaceRefused();
|
|
396917
397044
|
const company = (await storedBinding(send3, team))?.companyId;
|
|
@@ -396920,14 +397047,14 @@ function createSlackWorkspaceBindings(deps) {
|
|
|
396920
397047
|
return !await complete(send3) && team === legacy ? IMPLICIT_COMPANY_ID : void 0;
|
|
396921
397048
|
});
|
|
396922
397049
|
return {
|
|
396923
|
-
companyOf,
|
|
397050
|
+
companyOf: companyOf2,
|
|
396924
397051
|
async requireCompany(team) {
|
|
396925
|
-
const company = await
|
|
397052
|
+
const company = await companyOf2(team);
|
|
396926
397053
|
if (company === void 0)
|
|
396927
397054
|
throw new SlackWorkspaceRefused();
|
|
396928
397055
|
return company;
|
|
396929
397056
|
},
|
|
396930
|
-
channelCompanyOf: (where) => where !== null && typeof where === "object" && where.channel === "slack" ?
|
|
397057
|
+
channelCompanyOf: (where) => where !== null && typeof where === "object" && where.channel === "slack" ? companyOf2(where.tenant) : void 0,
|
|
396931
397058
|
bind: (company, team, by) => operation2(async (send3) => {
|
|
396932
397059
|
if (!OrgIdSchema.safeParse(company).success || !slackWorkspaceTeam(team) || !operator.safeParse(by).success)
|
|
396933
397060
|
throw new SlackWorkspaceRefused();
|
|
@@ -397731,24 +397858,34 @@ function proposeCommands(files, cwd) {
|
|
|
397731
397858
|
if (readiness.length === 0 && has3("Makefile") && /^test:/m.test(files.Makefile)) add(readiness, "make test", "the Makefile's test target");
|
|
397732
397859
|
return { setup, readiness, basis };
|
|
397733
397860
|
}
|
|
397734
|
-
|
|
397735
|
-
const name3 = githubAppSecretName(input2.env);
|
|
397736
|
-
const raw2 = await input2.secrets.get(name3);
|
|
397861
|
+
function appJwtFromSecret(raw2, name3, nowSeconds) {
|
|
397737
397862
|
if (raw2 === void 0) {
|
|
397738
397863
|
throw agentXError("CONFIG_INVALID", `secret ${name3} does not exist; run agentx init again so the GitHub App step stores it`);
|
|
397739
397864
|
}
|
|
397740
397865
|
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);
|
|
397866
|
+
return githubAppJwt({ appId: app.appId, privateKey: app.privateKey, nowSeconds });
|
|
397867
|
+
}
|
|
397868
|
+
function onlyInstallation(installations2) {
|
|
397869
|
+
if (installations2.length !== 1) {
|
|
397870
|
+
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
397871
|
}
|
|
397872
|
+
return installations2[0];
|
|
397873
|
+
}
|
|
397874
|
+
async function installationToken(input2) {
|
|
397875
|
+
const name3 = githubAppSecretName(input2.env);
|
|
397876
|
+
const jwt2 = appJwtFromSecret(await input2.secrets.get(name3), name3, input2.nowSeconds);
|
|
397877
|
+
const installationId = input2.installationId ?? String(onlyInstallation(await input2.github.listInstallations(jwt2)).id);
|
|
397750
397878
|
return (await input2.github.installationToken(jwt2, installationId)).token;
|
|
397751
397879
|
}
|
|
397880
|
+
async function installationAccess(input2) {
|
|
397881
|
+
const name3 = githubAppSecretName(input2.env);
|
|
397882
|
+
const jwt2 = appJwtFromSecret(await input2.secrets.get(name3), name3, input2.nowSeconds);
|
|
397883
|
+
const installation = onlyInstallation(await input2.github.listInstallations(jwt2));
|
|
397884
|
+
const installationId = String(installation.id);
|
|
397885
|
+
const token = (await input2.github.installationToken(jwt2, installationId)).token;
|
|
397886
|
+
const accountType = installation.account.type === "Organization" ? "organization" : "user";
|
|
397887
|
+
return { token, installationId, settingsUrl: installationSettingsUrl(accountType, installation.account.login, installationId) };
|
|
397888
|
+
}
|
|
397752
397889
|
|
|
397753
397890
|
// packages/cli/src/setup/services.ts
|
|
397754
397891
|
var import_client_cognito_identity_provider = __toESM(require_dist_cjs47(), 1);
|
|
@@ -399772,20 +399909,58 @@ async function registerRevision(request) {
|
|
|
399772
399909
|
return { revision: input2.definition.revision, preflight: preflight.success ? preflight.data.connectors : [], warnings, file: file2 };
|
|
399773
399910
|
}
|
|
399774
399911
|
var REPOSITORY_EXAMPLES = 5;
|
|
399775
|
-
|
|
399776
|
-
|
|
399912
|
+
var REPOSITORY_ACCESS_WAIT_MS = 10 * 60 * 1e3;
|
|
399913
|
+
var REPOSITORY_ACCESS_POLL_MS = 5e3;
|
|
399914
|
+
var findRepository = (repositories, wanted) => repositories.find((repo) => repo.fullName.toLowerCase() === wanted.toLowerCase());
|
|
399915
|
+
var addAt = (access10) => access10 === void 0 ? "" : ` at ${access10.settingsUrl}`;
|
|
399916
|
+
function notVisible(wanted, names, access10, waited = "") {
|
|
399917
|
+
const seen = names.length === 0 ? "it sees no repositories" : `it sees ${names.join(", ")}`;
|
|
399918
|
+
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`);
|
|
399919
|
+
}
|
|
399920
|
+
async function waitForRepository(input2) {
|
|
399921
|
+
const { wanted, wait: wait2, access: access10 } = input2;
|
|
399922
|
+
input2.write(`The GitHub App can't see ${wanted} yet.`);
|
|
399923
|
+
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}`);
|
|
399924
|
+
if (wait2.openBrowser !== void 0) await wait2.openBrowser(access10.settingsUrl);
|
|
399925
|
+
input2.write("Waiting for access\u2026 (Ctrl-C to stop)");
|
|
399926
|
+
const timeoutMs = wait2.timeoutMs ?? REPOSITORY_ACCESS_WAIT_MS;
|
|
399927
|
+
const deadline = wait2.now() + timeoutMs;
|
|
399928
|
+
let names = [];
|
|
399929
|
+
for (; ; ) {
|
|
399930
|
+
await wait2.sleep(wait2.pollMs ?? REPOSITORY_ACCESS_POLL_MS);
|
|
399931
|
+
const repositories = await input2.list().catch((error64) => {
|
|
399932
|
+
if (error64 instanceof AgentXError) return void 0;
|
|
399933
|
+
throw error64;
|
|
399934
|
+
});
|
|
399935
|
+
const found = repositories === void 0 ? void 0 : findRepository(repositories, wanted);
|
|
399936
|
+
if (found !== void 0) {
|
|
399937
|
+
input2.write(`The app can see ${found.fullName} now.`);
|
|
399938
|
+
return found;
|
|
399939
|
+
}
|
|
399940
|
+
if (repositories !== void 0) names = repositories.map((repo) => repo.fullName);
|
|
399941
|
+
if (wait2.now() >= deadline) throw notVisible(wanted, names, access10, ` after ${Math.round(timeoutMs / 6e4)} minutes of waiting`);
|
|
399942
|
+
}
|
|
399943
|
+
}
|
|
399944
|
+
async function chooseRepository(input2) {
|
|
399945
|
+
const { prompter, flag, access: access10 } = input2;
|
|
399946
|
+
const repositories = await input2.list();
|
|
399777
399947
|
const names = repositories.map((repo) => repo.fullName);
|
|
399948
|
+
if (flag !== void 0) {
|
|
399949
|
+
const found2 = findRepository(repositories, flag);
|
|
399950
|
+
if (found2 !== void 0) return found2;
|
|
399951
|
+
if (access10?.wait === void 0) throw notVisible(flag, names, access10);
|
|
399952
|
+
return waitForRepository({ wanted: flag, list: input2.list, access: access10, wait: access10.wait, write: input2.write });
|
|
399953
|
+
}
|
|
399954
|
+
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
399955
|
const examples = names.slice(0, REPOSITORY_EXAMPLES).join(", ") + (names.length > REPOSITORY_EXAMPLES ? `, and ${names.length - REPOSITORY_EXAMPLES} more` : "");
|
|
399779
|
-
const wanted =
|
|
399956
|
+
const wanted = await prompter.choose("Which repository is the first project's?", names.map((fullName) => ({ value: fullName, label: fullName })), {
|
|
399780
399957
|
flag: "--repository",
|
|
399781
399958
|
defaultValue: names[0],
|
|
399782
399959
|
// With --yes (or no terminal) the first of several repositories is never guessed.
|
|
399783
399960
|
unattendedRefusal: `the GitHub App sees ${names.length} repositories (for example ${examples}); pass --repository <owner/name> to choose the first project's`
|
|
399784
399961
|
});
|
|
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
|
-
}
|
|
399962
|
+
const found = findRepository(repositories, wanted);
|
|
399963
|
+
if (found === void 0) throw notVisible(wanted, names, access10);
|
|
399789
399964
|
return found;
|
|
399790
399965
|
}
|
|
399791
399966
|
async function existingProject(configDir, name3) {
|
|
@@ -400013,7 +400188,13 @@ async function addProject(input2) {
|
|
|
400013
400188
|
}
|
|
400014
400189
|
let repository;
|
|
400015
400190
|
const chosenRepository = async () => {
|
|
400016
|
-
const picked = await chooseRepository(
|
|
400191
|
+
const picked = await chooseRepository({
|
|
400192
|
+
list: () => input2.services.repositories.list(input2.githubToken),
|
|
400193
|
+
prompter,
|
|
400194
|
+
flag: flags.repository,
|
|
400195
|
+
write: input2.write,
|
|
400196
|
+
...input2.repositoryAccess === void 0 ? {} : { access: input2.repositoryAccess }
|
|
400197
|
+
});
|
|
400017
400198
|
input2.onRepository?.(picked.fullName);
|
|
400018
400199
|
return picked;
|
|
400019
400200
|
};
|
|
@@ -405383,6 +405564,13 @@ function projectModelChecker(settings, input2) {
|
|
|
405383
405564
|
};
|
|
405384
405565
|
}
|
|
405385
405566
|
function realSetupContext(input2) {
|
|
405567
|
+
const openBrowser = async (url2) => {
|
|
405568
|
+
try {
|
|
405569
|
+
await openSystemBrowser(url2);
|
|
405570
|
+
} catch {
|
|
405571
|
+
input2.stderr.write("could not open a browser; open the address above\n");
|
|
405572
|
+
}
|
|
405573
|
+
};
|
|
405386
405574
|
const openAws = async (command5) => {
|
|
405387
405575
|
const globals = command5.optsWithGlobals();
|
|
405388
405576
|
const settings = await readEnvironmentSettings(input2.parameterStore(globals.region), globals.env);
|
|
@@ -405411,7 +405599,9 @@ function realSetupContext(input2) {
|
|
|
405411
405599
|
now: Date.now,
|
|
405412
405600
|
print: (result4, text16) => {
|
|
405413
405601
|
input2.stdout.write(globals.json ? formatSuccess(result4, true) : text16);
|
|
405414
|
-
}
|
|
405602
|
+
},
|
|
405603
|
+
interactive: process.stdin.isTTY === true && !globals.json,
|
|
405604
|
+
openBrowser
|
|
405415
405605
|
};
|
|
405416
405606
|
};
|
|
405417
405607
|
return {
|
|
@@ -405423,15 +405613,7 @@ function realSetupContext(input2) {
|
|
|
405423
405613
|
services: run2.services,
|
|
405424
405614
|
write: run2.write,
|
|
405425
405615
|
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
|
-
}
|
|
405616
|
+
openBrowser
|
|
405435
405617
|
});
|
|
405436
405618
|
return { ...run2, session };
|
|
405437
405619
|
}
|
|
@@ -406262,11 +406444,21 @@ function projectOption(command5, what) {
|
|
|
406262
406444
|
}
|
|
406263
406445
|
function registerSetupCommands(program2, context) {
|
|
406264
406446
|
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) => {
|
|
406447
|
+
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
406448
|
const run2 = await context.open(command5);
|
|
406267
|
-
const
|
|
406449
|
+
const access10 = await installationAccess({ env: run2.env, secrets: run2.secrets, github: run2.services.github, nowSeconds: Math.floor(Date.now() / 1e3) });
|
|
406268
406450
|
const flags = definedEntries({ repository: options.repository, projectName: options.projectName, setupCommand: options.setupCommand, testCommand: options.testCommand });
|
|
406269
|
-
const
|
|
406451
|
+
const wait2 = run2.interactive === true ? { sleep: run2.sleep, now: run2.now, ...options.browser === false || run2.openBrowser === void 0 ? {} : { openBrowser: run2.openBrowser } } : void 0;
|
|
406452
|
+
const result4 = await addProject({
|
|
406453
|
+
env: run2.env,
|
|
406454
|
+
session: run2.session,
|
|
406455
|
+
githubToken: access10.token,
|
|
406456
|
+
prompter: run2.prompter,
|
|
406457
|
+
write: run2.write,
|
|
406458
|
+
services: run2.services,
|
|
406459
|
+
flags,
|
|
406460
|
+
repositoryAccess: { settingsUrl: access10.settingsUrl, ...wait2 === void 0 ? {} : { wait: wait2 } }
|
|
406461
|
+
});
|
|
406270
406462
|
run2.print(result4, `Registered project ${result4.name} (revision ${result4.revision}); file ${result4.file}
|
|
406271
406463
|
`);
|
|
406272
406464
|
});
|
|
@@ -412401,13 +412593,16 @@ ${ROOT_HELP_DOCS_LINES.join("\n")}`);
|
|
|
412401
412593
|
throw agentXError("CONFIG_INVALID", `--env ${JSON.stringify(env3)} is reserved for published templates and cannot be used as a real environment`);
|
|
412402
412594
|
}
|
|
412403
412595
|
});
|
|
412404
|
-
program2.command("login").description("sign in: agentx login <url> for developers; agentx login --admin (or no URL) for administrators").argument("[url]", "your AgentX URL, for developer sign-in").option("--admin", "sign in as an administrator with the admin identity provider (the default when no URL is given)", false).option("--no-browser", "developer sign-in: print the sign-in link instead of opening a browser").option("--callback-port <port>", "fixed loopback callback port registered with the OIDC client", parsePort, DEFAULT_CALLBACK_PORT).action(async (url2, options, command5) => {
|
|
412596
|
+
program2.command("login").description("sign in: agentx login <url> for developers; agentx login --admin (or no URL) for administrators").argument("[url]", "your AgentX URL, for developer sign-in").option("--admin", "sign in as an administrator with the admin identity provider (the default when no URL is given)", false).option("--no-browser", "developer sign-in: print the sign-in link instead of opening a browser").option("--callback-port <port>", "fixed loopback callback port registered with the OIDC client", parsePort, DEFAULT_CALLBACK_PORT).option("--company <id>", "developer sign-in with an invite: the company's ID, from the invite").option("--invite <secret>", "developer sign-in with an invite: the invite itself (rvlink_...), which works once").action(async (url2, options, command5) => {
|
|
412405
412597
|
const globals = globalOptions2(command5);
|
|
412406
412598
|
if (url2 !== void 0 && options.admin) {
|
|
412407
412599
|
throw agentXError("CONFIG_INVALID", "use either agentx login <url> (developer sign-in) or agentx login --admin, not both");
|
|
412408
412600
|
}
|
|
412601
|
+
const invite = loginInvite(options.company, options.invite);
|
|
412602
|
+
if (invite !== void 0 && url2 === void 0) throw agentXError("CONFIG_INVALID", "an invite is for developer sign-in: agentx login <url> --company <id> --invite <invite>");
|
|
412409
412603
|
if (url2 !== void 0) {
|
|
412410
412604
|
const result4 = await developerLogin({
|
|
412605
|
+
...invite === void 0 ? {} : { invite },
|
|
412411
412606
|
url: url2,
|
|
412412
412607
|
allowLoopback: globals.allowLoopback,
|
|
412413
412608
|
browser: options.browser,
|