replicas-cli 0.2.630 → 0.2.633
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.cjs +51 -32
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27248,7 +27248,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
|
|
|
27248
27248
|
});
|
|
27249
27249
|
|
|
27250
27250
|
// ../shared/src/cli-version.ts
|
|
27251
|
-
var CLI_VERSION = "0.2.
|
|
27251
|
+
var CLI_VERSION = "0.2.633";
|
|
27252
27252
|
|
|
27253
27253
|
// ../shared/src/version.ts
|
|
27254
27254
|
function compareVersions(v1, v2) {
|
|
@@ -27967,6 +27967,10 @@ async function ensureOrganizationSelection(options = {}) {
|
|
|
27967
27967
|
if (organization) {
|
|
27968
27968
|
return { organization, total: organizations.length };
|
|
27969
27969
|
}
|
|
27970
|
+
if (organizations.length === 1) {
|
|
27971
|
+
setOrganizationId(organizations[0].id);
|
|
27972
|
+
return { organization: organizations[0], total: 1 };
|
|
27973
|
+
}
|
|
27970
27974
|
const canAsk = options.interactive === true && !!process.stdin.isTTY;
|
|
27971
27975
|
if (canAsk) {
|
|
27972
27976
|
const chosen = await promptForOrganization(organizations, null);
|
|
@@ -28971,7 +28975,7 @@ async function exchangeCodeForTokens(code, codeVerifier) {
|
|
|
28971
28975
|
refreshToken: data.refresh_token
|
|
28972
28976
|
};
|
|
28973
28977
|
}
|
|
28974
|
-
function startCallbackServer(expectedState, codeVerifier) {
|
|
28978
|
+
function startCallbackServer(expectedState, codeVerifier, save) {
|
|
28975
28979
|
return new Promise((resolve2, reject) => {
|
|
28976
28980
|
const server = import_http2.default.createServer(async (req, res) => {
|
|
28977
28981
|
try {
|
|
@@ -29012,10 +29016,11 @@ function startCallbackServer(expectedState, codeVerifier) {
|
|
|
29012
29016
|
}
|
|
29013
29017
|
try {
|
|
29014
29018
|
const tokens = await exchangeCodeForTokens(code, codeVerifier);
|
|
29015
|
-
|
|
29019
|
+
const completionUrl = await save(tokens);
|
|
29020
|
+
res.writeHead(302, { "Location": completionUrl });
|
|
29016
29021
|
res.end();
|
|
29017
29022
|
server.close();
|
|
29018
|
-
resolve2(
|
|
29023
|
+
resolve2();
|
|
29019
29024
|
} catch (tokenError) {
|
|
29020
29025
|
const errorMessage = encodeURIComponent(tokenError instanceof Error ? tokenError.message : "Unknown error");
|
|
29021
29026
|
res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
|
|
@@ -29044,11 +29049,11 @@ function startCallbackServer(expectedState, codeVerifier) {
|
|
|
29044
29049
|
server.listen(CALLBACK_PORT, "127.0.0.1");
|
|
29045
29050
|
});
|
|
29046
29051
|
}
|
|
29047
|
-
async function runCodexOAuthFlow(totalSteps) {
|
|
29052
|
+
async function runCodexOAuthFlow(totalSteps, save) {
|
|
29048
29053
|
const pkce = generatePkceCodes();
|
|
29049
29054
|
const state = generateState2();
|
|
29050
29055
|
const authUrl = buildAuthorizationUrl(pkce.codeChallenge, state);
|
|
29051
|
-
const tokensPromise = startCallbackServer(state, pkce.codeVerifier);
|
|
29056
|
+
const tokensPromise = startCallbackServer(state, pkce.codeVerifier, save);
|
|
29052
29057
|
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
29053
29058
|
renderAuthFlowStep(1, totalSteps, "Approve access in your browser");
|
|
29054
29059
|
await openForApproval("auth.openai.com", authUrl);
|
|
@@ -29112,31 +29117,38 @@ async function runCredentialAuthFlow(options, flow) {
|
|
|
29112
29117
|
if (!await verifyAuthFlowTarget(target, options.yes === true)) {
|
|
29113
29118
|
process.exit(1);
|
|
29114
29119
|
}
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
|
|
29118
|
-
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
29122
|
-
|
|
29123
|
-
|
|
29124
|
-
|
|
29125
|
-
|
|
29126
|
-
|
|
29127
|
-
|
|
29128
|
-
|
|
29129
|
-
|
|
29130
|
-
|
|
29131
|
-
|
|
29120
|
+
await flow.runOAuth(totalSteps, async (tokens) => {
|
|
29121
|
+
renderAuthFlowStep(totalSteps, totalSteps, "Saving credentials");
|
|
29122
|
+
const { result: response, reauthenticated } = await withAuthRecovery(
|
|
29123
|
+
() => orgAuthenticatedFetch(isUserScoped ? flow.userEndpoint : flow.orgEndpoint, {
|
|
29124
|
+
method: "POST",
|
|
29125
|
+
body: flow.toRequestBody(tokens)
|
|
29126
|
+
}),
|
|
29127
|
+
async () => {
|
|
29128
|
+
const current = await resolveAuthFlowTarget(identity);
|
|
29129
|
+
assertDestinationUnchanged(target, current);
|
|
29130
|
+
if (!destinationWasKnown(current)) {
|
|
29131
|
+
throw new Error(
|
|
29132
|
+
"Could not confirm where these credentials would be saved after signing in. Nothing was saved. Re-run the command."
|
|
29133
|
+
);
|
|
29134
|
+
}
|
|
29135
|
+
if (!destinationWasKnown(target) && !await verifyAuthFlowTarget(current, options.yes === true)) {
|
|
29136
|
+
process.exit(1);
|
|
29137
|
+
}
|
|
29132
29138
|
}
|
|
29133
|
-
|
|
29134
|
-
|
|
29135
|
-
|
|
29136
|
-
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
|
|
29139
|
+
);
|
|
29140
|
+
if (!response.success) {
|
|
29141
|
+
throw new Error(response.error || `Failed to upload ${providerLabel} credentials to Replicas`);
|
|
29142
|
+
}
|
|
29143
|
+
const saved = reauthenticated || !target.organization ? await resolveAuthFlowTarget(identity) : target;
|
|
29144
|
+
renderAuthFlowSuccess(providerLabel, response, saved);
|
|
29145
|
+
const completionUrl = new URL("/cli-login/success", process.env.REPLICAS_WEB_URL || "https://replicas.dev");
|
|
29146
|
+
completionUrl.searchParams.set("provider", flow.provider);
|
|
29147
|
+
completionUrl.searchParams.set("email", saved.replicasAccount ?? "");
|
|
29148
|
+
completionUrl.searchParams.set("scope", isUserScoped ? "user" : "org");
|
|
29149
|
+
if (saved.organization) completionUrl.searchParams.set("organizationId", saved.organization.id);
|
|
29150
|
+
return completionUrl.toString();
|
|
29151
|
+
});
|
|
29140
29152
|
} catch (error51) {
|
|
29141
29153
|
console.log(import_chalk11.default.red("\n \u2717 Error:"), error51 instanceof Error ? error51.message : error51);
|
|
29142
29154
|
process.exit(1);
|
|
@@ -29146,6 +29158,7 @@ async function runCredentialAuthFlow(options, flow) {
|
|
|
29146
29158
|
// src/commands/codex-auth.ts
|
|
29147
29159
|
async function codexAuthCommand(options = {}) {
|
|
29148
29160
|
await runCredentialAuthFlow(options, {
|
|
29161
|
+
provider: "codex",
|
|
29149
29162
|
providerLabel: "Codex",
|
|
29150
29163
|
credentialLabel: "Codex",
|
|
29151
29164
|
connectorLabel: "OAuth",
|
|
@@ -29275,13 +29288,16 @@ async function runClaudeOAuthFlow(totalSteps) {
|
|
|
29275
29288
|
// src/commands/claude-auth.ts
|
|
29276
29289
|
async function claudeAuthCommand(options = {}) {
|
|
29277
29290
|
await runCredentialAuthFlow(options, {
|
|
29291
|
+
provider: "claude",
|
|
29278
29292
|
providerLabel: "Claude",
|
|
29279
29293
|
credentialLabel: "Claude Code",
|
|
29280
29294
|
connectorLabel: "OAuth",
|
|
29281
29295
|
oauthSteps: 2,
|
|
29282
29296
|
orgEndpoint: "/v1/claude/credentials",
|
|
29283
29297
|
userEndpoint: "/v1/claude/user/credentials",
|
|
29284
|
-
runOAuth:
|
|
29298
|
+
runOAuth: async (steps, save) => {
|
|
29299
|
+
await openForApproval("Replicas", await save(await runClaudeOAuthFlow(steps)));
|
|
29300
|
+
},
|
|
29285
29301
|
toRequestBody: (tokens) => ({
|
|
29286
29302
|
access_token: tokens.accessToken,
|
|
29287
29303
|
refresh_token: tokens.refreshToken,
|
|
@@ -29368,13 +29384,16 @@ async function runMuseOAuthFlow(totalSteps) {
|
|
|
29368
29384
|
// src/commands/muse-auth.ts
|
|
29369
29385
|
async function museAuthCommand(options = {}) {
|
|
29370
29386
|
await runCredentialAuthFlow(options, {
|
|
29387
|
+
provider: "muse",
|
|
29371
29388
|
providerLabel: "Muse",
|
|
29372
29389
|
credentialLabel: "Muse Code",
|
|
29373
29390
|
connectorLabel: "OAuth",
|
|
29374
29391
|
oauthSteps: 1,
|
|
29375
29392
|
orgEndpoint: "/v1/muse/credentials",
|
|
29376
29393
|
userEndpoint: "/v1/muse/user/credentials",
|
|
29377
|
-
runOAuth:
|
|
29394
|
+
runOAuth: async (steps, save) => {
|
|
29395
|
+
await openForApproval("Replicas", await save(await runMuseOAuthFlow(steps)));
|
|
29396
|
+
},
|
|
29378
29397
|
toRequestBody: (tokens) => ({ access_token: tokens.accessToken })
|
|
29379
29398
|
});
|
|
29380
29399
|
}
|