@eduardo191labs/opencode-free-pi 0.7.35 → 0.7.36

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/plugin.js CHANGED
@@ -182,7 +182,9 @@ async function setup(ctx) {
182
182
  registrations.push(await tool.register());
183
183
  }
184
184
  catch (error) {
185
- log.warn(`Could not register the ${tool.name} tools`, error);
185
+ log.warn(`Could not register the ${tool.name} tools`, {
186
+ error: error instanceof Error ? error.message : String(error),
187
+ });
186
188
  }
187
189
  }
188
190
  const abort = new AbortController();
@@ -200,6 +202,8 @@ async function setup(ctx) {
200
202
  resolve();
201
203
  };
202
204
  const timer = setTimeout(finish, ms);
205
+ // The recovery wait must never be the reason the process stays alive.
206
+ timer.unref?.();
203
207
  abort.signal.addEventListener("abort", finish, { once: true });
204
208
  });
205
209
  const catalogRecovery = (async () => {
@@ -208,9 +208,9 @@ async function hookForProviders(ctx, name, callback, registrations) {
208
208
  }
209
209
  }
210
210
  /**
211
- * Handles every free-pi HTTP response: replays a busy session, rewrites
212
- * context overflows into something OpenCode compacts on, turns long-lived
213
- * limits into readable messages and watches for server notices.
211
+ * Handles every free-pi HTTP response: rewrites context overflows into
212
+ * something OpenCode compacts on, turns long-lived limits into readable
213
+ * messages and watches for server notices.
214
214
  *
215
215
  * Split from `registerSessionHooks` because the response path is the plugin's
216
216
  * most intricate logic and it was buried mid-function.
@@ -10,7 +10,8 @@
10
10
  * The mapping is also stored in plugin storage, which is how an OpenCode
11
11
  * session reopened after a restart reconnects to the same provider session
12
12
  * instead of starting a new one. If that old id turns out to be locked, the
13
- * existing replay path rotates it on the first `429 concurrent`.
13
+ * request fails with `429 concurrent` and OpenCode's retry finds the session
14
+ * marked dirty, which rotates the id before the next attempt.
14
15
  */
15
16
  import type { Deps } from "../deps.js";
16
17
  export declare function wireSessionID(deps: Deps, sessionID: string): string;
@@ -10,7 +10,8 @@
10
10
  * The mapping is also stored in plugin storage, which is how an OpenCode
11
11
  * session reopened after a restart reconnects to the same provider session
12
12
  * instead of starting a new one. If that old id turns out to be locked, the
13
- * existing replay path rotates it on the first `429 concurrent`.
13
+ * request fails with `429 concurrent` and OpenCode's retry finds the session
14
+ * marked dirty, which rotates the id before the next attempt.
14
15
  */
15
16
  import { trimSet } from "../utils/async.js";
16
17
  const DIRTY_LIMIT = 256;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduardo191labs/opencode-free-pi",
3
- "version": "0.7.35",
3
+ "version": "0.7.36",
4
4
  "description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/plugin.ts CHANGED
@@ -226,7 +226,9 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
226
226
  try {
227
227
  registrations.push(await tool.register());
228
228
  } catch (error) {
229
- log.warn(`Could not register the ${tool.name} tools`, error);
229
+ log.warn(`Could not register the ${tool.name} tools`, {
230
+ error: error instanceof Error ? error.message : String(error),
231
+ });
230
232
  }
231
233
  }
232
234
  const abort = new AbortController();
@@ -245,6 +247,8 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
245
247
  resolve();
246
248
  };
247
249
  const timer = setTimeout(finish, ms);
250
+ // The recovery wait must never be the reason the process stays alive.
251
+ (timer as { unref?: () => void }).unref?.();
248
252
  abort.signal.addEventListener("abort", finish, { once: true });
249
253
  });
250
254
  const catalogRecovery = (async () => {
@@ -295,9 +295,9 @@ async function hookForProviders(
295
295
 
296
296
 
297
297
  /**
298
- * Handles every free-pi HTTP response: replays a busy session, rewrites
299
- * context overflows into something OpenCode compacts on, turns long-lived
300
- * limits into readable messages and watches for server notices.
298
+ * Handles every free-pi HTTP response: rewrites context overflows into
299
+ * something OpenCode compacts on, turns long-lived limits into readable
300
+ * messages and watches for server notices.
301
301
  *
302
302
  * Split from `registerSessionHooks` because the response path is the plugin's
303
303
  * most intricate logic and it was buried mid-function.
@@ -10,7 +10,8 @@
10
10
  * The mapping is also stored in plugin storage, which is how an OpenCode
11
11
  * session reopened after a restart reconnects to the same provider session
12
12
  * instead of starting a new one. If that old id turns out to be locked, the
13
- * existing replay path rotates it on the first `429 concurrent`.
13
+ * request fails with `429 concurrent` and OpenCode's retry finds the session
14
+ * marked dirty, which rotates the id before the next attempt.
14
15
  */
15
16
 
16
17
  import type { Deps } from "../deps.js";