← Catalog

pi-stealth

Universal zero-fingerprint privacy client & transparent rate-limit retry engine for pi

Extension

Install

Install with PiG

pig install npm:pi-stealth

Install with Pi

pi install npm:pi-stealth
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/pi-stealth.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.1 (README.md). PiG does not review it.

pi-stealth 🥷

Universal zero-fingerprint privacy client and transparent stream-layer retry engine for pi.

pi-stealth turns Pi into a silent, resilient client. It scrubs all tracking, attribution, and SDK fingerprinting metadata before requests leave your machine, and absorbs API rate limits (HTTP 429) across providers using an extensible Provider Resolver Architecture.


Key Superpowers

  1. Zero-Fingerprint Header Stripping

    • Hooks into Pi's before_provider_headers event.
    • Drops all OpenRouter attribution (X-OpenRouter-Title, HTTP-Referer, X-OpenRouter-Categories).
    • Drops all OpenAI Stainless SDK fingerprinting metadata (X-Stainless-Lang, X-Stainless-OS, X-Stainless-Arch, X-Stainless-Runtime, X-Stainless-Package-Version, X-Stainless-Retry-Count, X-Stainless-Timeout).
    • Drops provider session affinity tags (x-session-id, X-BILLING-INVOKE-ORIGIN, cf-aig-metadata).
    • Outgoing requests retain only Authorization: Bearer <key> and Content-Type: application/json.
  2. Transparent Rate-Limit Resiliency (HTTP 429)

    • Intercepts rate limits at the stream layer with jittered exponential backoff (2s → 4s → 8s → 16s → 32s → 60s cap).
    • Up to 20 attempts by default (~5–6 minutes wall-clock), keeping your agent working through aggressive API cooldowns.
    • Prevents partial-stream replays (only retries if an error occurs before token generation starts).
    • Session messages are kept clean; exhaustion errors are rewritten with user-friendly notices without corrupting conversation history.
  3. Extensible Provider Resolver Architecture

    • Automatically adapts to the user's active model (openrouter, nvidia, anthropic, cloudflare, stealth/ox-alpha, custom proxies).
    • Third-party extensions and scripts can register custom resolvers via the global registry.

Provider Resolvers

pi-stealth ships with built-in resolvers out of the box:

ResolverTarget / Match PatternStripped Attribution HeadersRate-Limit Detection
openrouteropenrouter, stealth/*, ox-alpha/*, 0x-alpha/*X-OpenRouter-Title, HTTP-Referer, X-OpenRouter-Categories, x-session-id429, rate limit, credits, free-tier limit, overloaded
nvidianvidia, nvidia/*, *.nvidia.comX-BILLING-INVOKE-ORIGIN, x-session-affinity429, rate limit, please wait
cloudflarecloudflare*, gateway.ai.cloudflare.comUser-Agent: pi-coding-agent, cf-aig-metadata429, exceeded quota
anthropicanthropic, api.anthropic.comanthropic-client-version, x-session-id429, rate_limit_error, overloaded_error
universalAny model / OpenAI-compatible endpointAll X-Stainless-*, OpenAI-Organization, OpenAI-Project, User-Agent, AcceptStandard HTTP 429, too many requests, server is busy

Writing Custom Resolvers

You can easily register a custom resolver from any Pi extension or configuration script:

import { registry, type StealthResolver } from "pi-stealth";

const MyCustomGatewayResolver: StealthResolver = {
  id: "my-gateway",
  name: "Corporate AI Gateway",
  matches(model) {
    return model.baseUrl?.includes("gateway.internal.corp") ?? false;
  },
  stripHeaders(headers, model) {
    headers["x-corp-tracking-id"] = null;
    headers["x-user-telemetry"] = null;
  },
  isRateLimit(error) {
    return error?.status === 429 || error?.message?.includes("gateway_concurrency_limit");
  },
  getRetryDelayMs(attempt, error) {
    // Custom backoff curve: 3s, 6s, 12s...
    return 3000 * (2 ** (attempt - 1));
  }
};

// Register directly
registry.register(MyCustomGatewayResolver);

Configuration (Environment Variables)

Customize behavior dynamically without editing configuration files:

VariableAliasDefaultDescription
PI_STEALTH_RETRY_MAXSTEALTH_RETRY_MAX20Max attempts per burst before giving up
PI_STEALTH_RETRY_BASE_MSSTEALTH_RETRY_BASE_MS2000Base backoff in milliseconds
PI_STEALTH_RETRY_CAP_MSSTEALTH_RETRY_CAP_MS60000Delay ceiling per retry in milliseconds
PI_STEALTH_RETRY_JITTERSTEALTH_RETRY_JITTER0.2Random jitter fraction (0.0–1.0)
PI_STEALTH_STRIP_HEADERSSTEALTH_STRIP_HEADERStrueEnables/disables header sanitization

Installation

Option 1 — Install via Pi CLI

pi install git:github.com/kelvinpraises/pi-stealth@v1

Option 2 — Drop Directly Into Pi Extensions

cp extensions/pi-stealth.ts ~/.pi/agent/extensions/

Then run /reload in your active Pi session.


Verification

When Pi boots or /reload is run:

[pi-stealth] loaded — stealth privacy & retries active [max: 20, base: 2000ms, cap: 60000ms, jitter: 20%]. Resolvers: [openrouter, nvidia, cloudflare, anthropic, universal].

When an active rate limit is intercepted:

[pi-stealth] stealth/ox-alpha — rate limited on attempt 1/20; 19 attempt(s) remaining.

Acknowledgements