@ryan_nookpi/pi-extension-headroom 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.
package/README.md CHANGED
@@ -63,6 +63,6 @@ Example:
63
63
  | `command` | `PI_HEADROOM_COMMAND` | `headroom` | Command used to launch the proxy. |
64
64
  | `minContextTokens` | `PI_HEADROOM_MIN_CONTEXT_TOKENS` | `20000` | Skip compression below this context token count. |
65
65
  | `minMessageChars` | `PI_HEADROOM_MIN_MESSAGE_CHARS` | `2000` | Only compress tool results at or above this size. |
66
- | `timeoutMs` | `PI_HEADROOM_TIMEOUT_MS` | `15000` | HTTP timeout for proxy requests. |
66
+ | `timeoutMs` | `PI_HEADROOM_TIMEOUT_MS` | `30000` | HTTP timeout for proxy requests. |
67
67
 
68
68
  Boolean values accept JSON booleans, or strings such as `1/0`, `true/false`, `yes/no`, `on/off`.
package/config.ts CHANGED
@@ -6,7 +6,7 @@ import type { HeadroomConfig } from "./types.ts";
6
6
  const DEFAULT_BASE_URL = "http://127.0.0.1:8788";
7
7
  const DEFAULT_MIN_CONTEXT_TOKENS = 20_000;
8
8
  const DEFAULT_MIN_MESSAGE_CHARS = 2_000;
9
- const DEFAULT_TIMEOUT_MS = 15_000;
9
+ const DEFAULT_TIMEOUT_MS = 30_000;
10
10
 
11
11
  export const HEADROOM_SETTINGS_DIR = path.join(os.homedir(), ".pi", "agent", "headroom");
12
12
  export const HEADROOM_SETTINGS_FILE = path.join(HEADROOM_SETTINGS_DIR, "settings.json");
package/index.ts CHANGED
@@ -250,8 +250,13 @@ function recordAppliedCompression(stats: HeadroomStats, result: CompressResult,
250
250
  }
251
251
 
252
252
  function recordCompressionError(runtime: HeadroomRuntime, ctx: ExtensionContext, error: unknown): void {
253
+ runtime.state.stats.lastError = getErrorMessage(error);
254
+ if (isAbortOrTimeoutError(error)) {
255
+ runtime.refreshStatus(ctx);
256
+ return;
257
+ }
258
+
253
259
  runtime.state.proxyOnline = false;
254
- runtime.state.stats.lastError = error instanceof Error ? error.message : String(error);
255
260
  if (!runtime.state.offlineWarningShown) {
256
261
  runtime.state.offlineWarningShown = true;
257
262
  ctx.ui.notify(
@@ -262,6 +267,23 @@ function recordCompressionError(runtime: HeadroomRuntime, ctx: ExtensionContext,
262
267
  runtime.refreshStatus(ctx);
263
268
  }
264
269
 
270
+ function getErrorMessage(error: unknown): string {
271
+ return error instanceof Error ? error.message : String(error);
272
+ }
273
+
274
+ function isAbortOrTimeoutError(error: unknown): boolean {
275
+ if (!error || typeof error !== "object") return false;
276
+ const candidate = error as { cause?: unknown; message?: unknown; name?: unknown };
277
+ if (candidate.name === "TimeoutError" || candidate.name === "AbortError") return true;
278
+ if (
279
+ typeof candidate.message === "string" &&
280
+ /aborted due to timeout|operation was aborted/i.test(candidate.message)
281
+ ) {
282
+ return true;
283
+ }
284
+ return candidate.cause !== undefined && candidate.cause !== error && isAbortOrTimeoutError(candidate.cause);
285
+ }
286
+
265
287
  async function handleCommand(runtime: HeadroomRuntime, command: Subcommand, ctx: ExtensionContext): Promise<void> {
266
288
  if (command === "on") {
267
289
  runtime.state.enabled = true;
@@ -430,5 +452,6 @@ function parseSubcommand(args: string): Subcommand {
430
452
  }
431
453
 
432
454
  export const __test__ = {
455
+ isAbortOrTimeoutError,
433
456
  renderFooterStatus,
434
457
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryan_nookpi/pi-extension-headroom",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Headroom token compression for pi — compress large tool results via a local Headroom proxy to reclaim context window.",
5
5
  "license": "MIT",
6
6
  "repository": {