free-pi-cli 0.6.6 → 0.6.7
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.js
CHANGED
|
@@ -15095,7 +15095,7 @@ var HiveClassifyResponseSchema = exports_external.object({
|
|
|
15095
15095
|
// package.json
|
|
15096
15096
|
var package_default = {
|
|
15097
15097
|
name: "free-pi-cli",
|
|
15098
|
-
version: "0.6.
|
|
15098
|
+
version: "0.6.7",
|
|
15099
15099
|
description: "Free, ad-supported distribution of the pi coding agent. Inference paid for by ads.",
|
|
15100
15100
|
license: "MIT",
|
|
15101
15101
|
type: "module",
|
|
@@ -15706,6 +15706,7 @@ function buyMore(buyUrl) {
|
|
|
15706
15706
|
}
|
|
15707
15707
|
var CONFIRM_TURNS = 3;
|
|
15708
15708
|
var lastCreditUsd;
|
|
15709
|
+
var lastToken;
|
|
15709
15710
|
var confirm;
|
|
15710
15711
|
function creditAddedMessage(addedUsd) {
|
|
15711
15712
|
return `Payment received — ${usdToCredits(addedUsd).toLocaleString("en-US")} credits added to your balance.`;
|
|
@@ -15719,6 +15720,12 @@ async function renderMeter(deps, ctx) {
|
|
|
15719
15720
|
}
|
|
15720
15721
|
const theme = ctx.ui.theme;
|
|
15721
15722
|
const credit = typeof me.credit_usd === "number" ? me.credit_usd : undefined;
|
|
15723
|
+
const token = await deps.getToken();
|
|
15724
|
+
if (token !== lastToken) {
|
|
15725
|
+
lastToken = token;
|
|
15726
|
+
lastCreditUsd = undefined;
|
|
15727
|
+
confirm = undefined;
|
|
15728
|
+
}
|
|
15722
15729
|
const added = credit !== undefined && lastCreditUsd !== undefined ? credit - lastCreditUsd : 0;
|
|
15723
15730
|
lastCreditUsd = credit;
|
|
15724
15731
|
if (added > 0)
|
|
@@ -21445,6 +21452,14 @@ function mergeAttribution(a, b) {
|
|
|
21445
21452
|
|
|
21446
21453
|
// src/changelog.ts
|
|
21447
21454
|
var CHANGELOG_HIGHLIGHTS = [
|
|
21455
|
+
{
|
|
21456
|
+
version: "0.6.7",
|
|
21457
|
+
highlights: [
|
|
21458
|
+
"/logout now signs you out of free-pi: it removes your saved sign-in and exits. Restart free-pi to sign in again. Guests are told they are not signed in.",
|
|
21459
|
+
"The confirmation code shown during browser sign-in is now bold and bright, so it is easy to compare with the one on freepi.ai.",
|
|
21460
|
+
'Fixed a wrong "Payment received" line that could appear right after signing in.'
|
|
21461
|
+
]
|
|
21462
|
+
},
|
|
21448
21463
|
{
|
|
21449
21464
|
version: "0.6.6",
|
|
21450
21465
|
highlights: [
|
|
@@ -21721,6 +21736,9 @@ function highlightsFor(version3) {
|
|
|
21721
21736
|
return CHANGELOG_HIGHLIGHTS.find((e) => e.version === version3)?.highlights;
|
|
21722
21737
|
}
|
|
21723
21738
|
|
|
21739
|
+
// src/commands.ts
|
|
21740
|
+
import { access } from "node:fs/promises";
|
|
21741
|
+
|
|
21724
21742
|
// src/auth-flow.ts
|
|
21725
21743
|
class UnauthorizedError extends Error {
|
|
21726
21744
|
constructor() {
|
|
@@ -22228,7 +22246,10 @@ function browserLikelyAvailable(env = process.env, platform = process.platform)
|
|
|
22228
22246
|
return false;
|
|
22229
22247
|
return true;
|
|
22230
22248
|
}
|
|
22231
|
-
function
|
|
22249
|
+
function emphasize(text, color = !process.env.NO_COLOR && process.stdout.isTTY === true) {
|
|
22250
|
+
return color ? `\x1B[1;97m${text}\x1B[0m` : text;
|
|
22251
|
+
}
|
|
22252
|
+
function formatConnectPrompt(connect, color) {
|
|
22232
22253
|
return [
|
|
22233
22254
|
"",
|
|
22234
22255
|
LOGIN_REWARD_LINE,
|
|
@@ -22236,7 +22257,7 @@ function formatConnectPrompt(connect) {
|
|
|
22236
22257
|
" Opening your browser to connect this terminal. If it doesn't open, go to:",
|
|
22237
22258
|
` ${connect.connect_url}`,
|
|
22238
22259
|
"",
|
|
22239
|
-
` Confirmation code: ${connect.confirm_code}`,
|
|
22260
|
+
` Confirmation code: ${emphasize(connect.confirm_code, color)}`,
|
|
22240
22261
|
" (the page must show the same code)",
|
|
22241
22262
|
"",
|
|
22242
22263
|
DEVICE_LOGIN_HINT,
|
|
@@ -22480,6 +22501,33 @@ function installLoginHandler(mode, opts) {
|
|
|
22480
22501
|
return runLogin(opts, { ui: { notify } });
|
|
22481
22502
|
};
|
|
22482
22503
|
}
|
|
22504
|
+
var LOGOUT_DONE_LINE = "Signed out of free-pi. Restart free-pi to sign in again.";
|
|
22505
|
+
var LOGOUT_NOT_SIGNED_IN_LINE = "You're not signed in to free-pi.";
|
|
22506
|
+
function installLogoutHandler(mode, opts) {
|
|
22507
|
+
const printAtExit = opts.printAtExit ?? ((line) => void process.once("exit", () => process.stdout.write(`${line}
|
|
22508
|
+
`)));
|
|
22509
|
+
const m = mode;
|
|
22510
|
+
mode.showOAuthSelector = async () => {
|
|
22511
|
+
if (!opts.credentialsPath || opts.isGuest?.()) {
|
|
22512
|
+
m.showStatus(LOGOUT_NOT_SIGNED_IN_LINE);
|
|
22513
|
+
return;
|
|
22514
|
+
}
|
|
22515
|
+
try {
|
|
22516
|
+
try {
|
|
22517
|
+
await runLogout({ credentialsPath: opts.credentialsPath, loadJwt, clearJwt, log: () => {} });
|
|
22518
|
+
} catch (err) {
|
|
22519
|
+
if (await access(opts.credentialsPath).then(() => true, () => false)) {
|
|
22520
|
+
const reason = err instanceof Error && err.message ? err.message : "unknown error";
|
|
22521
|
+
m.showError(`Couldn't sign out: ${reason}. Try: npx free-pi-cli@latest logout`);
|
|
22522
|
+
return;
|
|
22523
|
+
}
|
|
22524
|
+
}
|
|
22525
|
+
m.showStatus(LOGOUT_DONE_LINE);
|
|
22526
|
+
printAtExit(LOGOUT_DONE_LINE);
|
|
22527
|
+
await m.shutdown();
|
|
22528
|
+
} catch {}
|
|
22529
|
+
};
|
|
22530
|
+
}
|
|
22483
22531
|
async function showUsage(opts, ctx) {
|
|
22484
22532
|
const r = await fetchUsageText(opts);
|
|
22485
22533
|
ctx.ui.notify(r.text, r.ok ? "info" : "error");
|
|
@@ -24811,6 +24859,7 @@ async function launchPi(opts) {
|
|
|
24811
24859
|
onLogin: (token) => auth.becomeSignedIn(token),
|
|
24812
24860
|
variant: () => opts.guestHandoffVariant
|
|
24813
24861
|
});
|
|
24862
|
+
installLogoutHandler(mode, { credentialsPath: opts.credentialsPath, isGuest: () => auth.isGuest() });
|
|
24814
24863
|
installModelAllowanceHandler(mode);
|
|
24815
24864
|
installFooterRightAlign(mode);
|
|
24816
24865
|
await mode.run();
|