free-pi-cli 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14811,14 +14811,26 @@ async function postJson(baseUrl, path, body) {
14811
14811
  body: JSON.stringify(body)
14812
14812
  });
14813
14813
  }
14814
+ async function postJsonRetry(baseUrl, path, body, attempts = 4, sleep = (ms) => new Promise((r) => setTimeout(r, ms))) {
14815
+ for (let attempt = 1;; attempt++) {
14816
+ try {
14817
+ return await postJson(baseUrl, path, body);
14818
+ } catch (err) {
14819
+ if (attempt >= attempts) {
14820
+ throw new Error(`network unreachable after ${attempts} attempts (${err instanceof Error ? err.message : String(err)})`);
14821
+ }
14822
+ await sleep(1500 * attempt);
14823
+ }
14824
+ }
14825
+ }
14814
14826
  async function startDeviceFlow(baseUrl) {
14815
- const res = await postJson(baseUrl, "/auth/github/device", {});
14827
+ const res = await postJsonRetry(baseUrl, "/auth/github/device", {});
14816
14828
  if (!res.ok)
14817
14829
  throw new Error(`device flow start failed: HTTP ${res.status}`);
14818
14830
  return GithubDeviceResponseSchema.parse(await res.json());
14819
14831
  }
14820
14832
  async function submitConsent(baseUrl, sessionId, consentVersion) {
14821
- const res = await postJson(baseUrl, "/auth/consent", {
14833
+ const res = await postJsonRetry(baseUrl, "/auth/consent", {
14822
14834
  session_id: sessionId,
14823
14835
  consent_version: consentVersion
14824
14836
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-pi-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Free, ad-supported distribution of the pi coding agent. Inference paid for by ads.",
5
5
  "license": "MIT",
6
6
  "type": "module",