free-pi-cli 0.6.17 → 0.6.18
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
|
@@ -515,7 +515,7 @@ function folderMatches(cwd, sessionCwd) {
|
|
|
515
515
|
// package.json
|
|
516
516
|
var package_default = {
|
|
517
517
|
name: "free-pi-cli",
|
|
518
|
-
version: "0.6.
|
|
518
|
+
version: "0.6.18",
|
|
519
519
|
description: "Free AI coding agent for your terminal. Ads and a daily free allowance pay for the models; sign in with GitHub and run npx free-pi-cli.",
|
|
520
520
|
keywords: [
|
|
521
521
|
"coding agent",
|
|
@@ -6614,7 +6614,7 @@ async function runFreePiMcp(args, deps) {
|
|
|
6614
6614
|
}
|
|
6615
6615
|
|
|
6616
6616
|
// src/gravity-pixel.ts
|
|
6617
|
-
import { createHash } from "node:crypto";
|
|
6617
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6618
6618
|
var GRAVITY_PIXEL_ID = "6cd74804-0541-4d9b-899d-d7fceb465b6f";
|
|
6619
6619
|
function userIdFromJwt(jwt) {
|
|
6620
6620
|
try {
|
|
@@ -6661,14 +6661,15 @@ function startGravityPixel(jwt, storageDir, env = process.env, load = () => impo
|
|
|
6661
6661
|
pixel = undefined;
|
|
6662
6662
|
}
|
|
6663
6663
|
})();
|
|
6664
|
+
const fallbackSessionId = randomUUID();
|
|
6664
6665
|
return () => {
|
|
6665
6666
|
try {
|
|
6666
|
-
|
|
6667
|
-
if (!sdk || !pixel || !sessionId)
|
|
6667
|
+
if (!sdk)
|
|
6668
6668
|
return;
|
|
6669
|
+
const sessionId = pixel?.getSessionId();
|
|
6669
6670
|
const ctx = sdk.gravityContext({
|
|
6670
|
-
sessionId,
|
|
6671
|
-
user: { userId: userHash, gruid: pixel.getVisitorId(), grclid: pixel.getClickId(), graid: pixel.getGraid() }
|
|
6671
|
+
sessionId: sessionId || fallbackSessionId,
|
|
6672
|
+
user: sessionId && pixel ? { userId: userHash, gruid: pixel.getVisitorId(), grclid: pixel.getClickId(), graid: pixel.getGraid() } : { userId: userHash }
|
|
6672
6673
|
});
|
|
6673
6674
|
const encoded = Buffer.from(JSON.stringify(ctx)).toString("base64url");
|
|
6674
6675
|
return encoded.length <= GRAVITY_CONTEXT_MAX_BYTES ? encoded : undefined;
|
|
@@ -6706,6 +6707,7 @@ function loadConfig(env = process.env) {
|
|
|
6706
6707
|
}
|
|
6707
6708
|
|
|
6708
6709
|
// ../pi-ads/src/api.ts
|
|
6710
|
+
import { arch } from "node:os";
|
|
6709
6711
|
var REQUEST_TIMEOUT_MS = 5000;
|
|
6710
6712
|
async function authedFetch(deps, path, init) {
|
|
6711
6713
|
const token = await deps.getToken();
|
|
@@ -6719,10 +6721,18 @@ async function authedFetch(deps, path, init) {
|
|
|
6719
6721
|
Authorization: `Bearer ${token}`,
|
|
6720
6722
|
"Content-Type": "application/json",
|
|
6721
6723
|
...deps.sessionId && (path.startsWith("/ads/next") || path === "/ads/impression") ? { "x-session-id": deps.sessionId } : {},
|
|
6722
|
-
...path.startsWith("/ads/next") ? gravityHeader(deps) : {}
|
|
6724
|
+
...path.startsWith("/ads/next") ? { ...deps.clientVersion ? { "x-client-version": deps.clientVersion } : {}, "x-client-os": process.platform, "x-client-arch": arch(), ...localeHeaders(), ...gravityHeader(deps) } : {}
|
|
6723
6725
|
}
|
|
6724
6726
|
});
|
|
6725
6727
|
}
|
|
6728
|
+
function localeHeaders() {
|
|
6729
|
+
try {
|
|
6730
|
+
const o = Intl.DateTimeFormat().resolvedOptions();
|
|
6731
|
+
return { ...o.timeZone ? { "x-client-timezone": o.timeZone } : {}, ...o.locale ? { "x-client-locale": o.locale } : {} };
|
|
6732
|
+
} catch {
|
|
6733
|
+
return {};
|
|
6734
|
+
}
|
|
6735
|
+
}
|
|
6726
6736
|
function gravityHeader(deps) {
|
|
6727
6737
|
try {
|
|
6728
6738
|
const ctx = deps.getGravityContext?.();
|
|
@@ -7126,6 +7136,7 @@ function createAdsExtension(opts) {
|
|
|
7126
7136
|
baseUrl: opts.baseUrl,
|
|
7127
7137
|
getToken: opts.getToken,
|
|
7128
7138
|
sessionId: opts.sessionId,
|
|
7139
|
+
clientVersion: opts.clientVersion,
|
|
7129
7140
|
fetchImpl: opts.fetchImpl,
|
|
7130
7141
|
getGravityContext: opts.getGravityContext,
|
|
7131
7142
|
onMe: opts.onMe
|
|
@@ -9848,6 +9859,10 @@ function mergeAttribution(a, b) {
|
|
|
9848
9859
|
|
|
9849
9860
|
// src/changelog.ts
|
|
9850
9861
|
var CHANGELOG_HIGHLIGHTS = [
|
|
9862
|
+
{
|
|
9863
|
+
version: "0.6.18",
|
|
9864
|
+
highlights: ["Ads load correctly from your first prompt."]
|
|
9865
|
+
},
|
|
9851
9866
|
{
|
|
9852
9867
|
version: "0.6.17",
|
|
9853
9868
|
highlights: [
|
|
@@ -14271,6 +14286,7 @@ function buildRuntimeOptions(opts, sessionId) {
|
|
|
14271
14286
|
baseUrl: opts.baseUrl,
|
|
14272
14287
|
getToken: () => auth.getJwt(),
|
|
14273
14288
|
sessionId,
|
|
14289
|
+
clientVersion: CLI_VERSION,
|
|
14274
14290
|
getGravityContext: opts.getGravityContext,
|
|
14275
14291
|
onBannerAd: (u) => {
|
|
14276
14292
|
advertiserUrl = u;
|
package/package.json
CHANGED