nexo-code 0.1.0 → 0.1.1
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/nexo.mjs +35 -4
- package/package.json +1 -1
package/nexo.mjs
CHANGED
|
@@ -14688,7 +14688,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
14688
14688
|
import { join } from "node:path";
|
|
14689
14689
|
|
|
14690
14690
|
// dist/version.js
|
|
14691
|
-
var VERSION = "0.1.
|
|
14691
|
+
var VERSION = "0.1.1";
|
|
14692
14692
|
|
|
14693
14693
|
// dist/update.js
|
|
14694
14694
|
var PACKAGE = "nexo-code";
|
|
@@ -44245,7 +44245,9 @@ async function login(io, opts) {
|
|
|
44245
44245
|
io.err(`${s.error(s.sym.fail)} Use an https:// API URL (plain http is only allowed for localhost).`);
|
|
44246
44246
|
return 2;
|
|
44247
44247
|
}
|
|
44248
|
-
const token = await io.readSecret(`Paste your Nexo token (input hidden): `);
|
|
44248
|
+
const token = !opts.token && io.interactive && io.readLine ? await emailSignIn(io, apiUrl) : await io.readSecret(`Paste your Nexo token (input hidden): `);
|
|
44249
|
+
if (token === null)
|
|
44250
|
+
return 1;
|
|
44249
44251
|
if (!TOKEN2.test(token)) {
|
|
44250
44252
|
io.err(`${s.error(s.sym.fail)} That doesn't look like a Nexo token (it starts with nexo_). Ask the account owner for one.`);
|
|
44251
44253
|
return 2;
|
|
@@ -44257,6 +44259,34 @@ async function login(io, opts) {
|
|
|
44257
44259
|
io.out(s.dim(` user ${me.userId}`));
|
|
44258
44260
|
return 0;
|
|
44259
44261
|
}
|
|
44262
|
+
async function emailSignIn(io, apiUrl) {
|
|
44263
|
+
const { style: s } = io;
|
|
44264
|
+
const email3 = (await io.readLine(`${s.primary("\u203A")} Your email: `))?.trim();
|
|
44265
|
+
if (!email3)
|
|
44266
|
+
return null;
|
|
44267
|
+
if (!await io.confirm("Nexo is for adults. Are you 18 or older?")) {
|
|
44268
|
+
io.err(s.dim(" Nexo is only for people 18 and older."));
|
|
44269
|
+
return null;
|
|
44270
|
+
}
|
|
44271
|
+
const post = (path2, body) => (io.fetch ?? fetch)(new URL(path2, apiUrl), { method: "POST", headers: { "content-type": "application/json", "x-nexo-client": "cli" }, body: JSON.stringify(body) });
|
|
44272
|
+
const started = await post("/v1/auth/email/start", { email: email3, adult: true });
|
|
44273
|
+
if (!started.ok)
|
|
44274
|
+
throw await errorFromResponse(started);
|
|
44275
|
+
io.err(s.dim(` If ${email3} has a Nexo account, a six-digit code is on its way. No account yet? Sign up at https://usenexoai.com`));
|
|
44276
|
+
for (let tries = 0; tries < 3; tries++) {
|
|
44277
|
+
const code = (await io.readLine(`${s.primary("\u203A")} Code from the email: `))?.replace(/\s+/g, "");
|
|
44278
|
+
if (!code)
|
|
44279
|
+
return null;
|
|
44280
|
+
const res = await post("/v1/auth/email/verify", { email: email3, code });
|
|
44281
|
+
if (res.ok)
|
|
44282
|
+
return String((await res.json()).token ?? "");
|
|
44283
|
+
const err = await errorFromResponse(res);
|
|
44284
|
+
io.err(`${s.error(s.sym.fail)} ${err.message}`);
|
|
44285
|
+
if (err.code !== "UNAUTHENTICATED" && err.code !== "INVALID_INPUT")
|
|
44286
|
+
return null;
|
|
44287
|
+
}
|
|
44288
|
+
return null;
|
|
44289
|
+
}
|
|
44260
44290
|
async function authStatus(io) {
|
|
44261
44291
|
const { style: s } = io;
|
|
44262
44292
|
const creds = await loadCredentials(io.env);
|
|
@@ -46442,7 +46472,7 @@ Usage:
|
|
|
46442
46472
|
nexo remote Take tasks from the Nexo app (Code) in this folder: they run here, and
|
|
46443
46473
|
every file change and command is approved on your phone
|
|
46444
46474
|
nexo models The models you can put in a team (nexo run --team)
|
|
46445
|
-
nexo login
|
|
46475
|
+
nexo login Sign in with your email and the code it receives (--token to paste a token)
|
|
46446
46476
|
nexo auth status Show login and this month's usage against your cap
|
|
46447
46477
|
nexo logout Revoke the token and remove it from this machine
|
|
46448
46478
|
nexo update Install the latest Nexo Code (npm install -g nexo-code@latest)
|
|
@@ -46544,6 +46574,7 @@ async function run2(argv, io) {
|
|
|
46544
46574
|
print: { type: "string", short: "p" },
|
|
46545
46575
|
output: { type: "string" },
|
|
46546
46576
|
"api-url": { type: "string" },
|
|
46577
|
+
token: { type: "boolean" },
|
|
46547
46578
|
"no-color": { type: "boolean" },
|
|
46548
46579
|
debug: { type: "boolean" }
|
|
46549
46580
|
}
|
|
@@ -46656,7 +46687,7 @@ async function run2(argv, io) {
|
|
|
46656
46687
|
return remote(io, budget);
|
|
46657
46688
|
}
|
|
46658
46689
|
if (cmd === "login")
|
|
46659
|
-
return login(io, values["api-url"] ? { apiUrl: values["api-url"] } : {});
|
|
46690
|
+
return login(io, { ...values["api-url"] ? { apiUrl: values["api-url"] } : {}, ...values.token ? { token: true } : {} });
|
|
46660
46691
|
if (cmd === "models")
|
|
46661
46692
|
return listModels(io);
|
|
46662
46693
|
if (cmd === "logout")
|