← Catalog

@bismawy/pi-agentrouter

Unified frontier models. Self-healing WAF recovery. Zero workflow interruption. GPT-6 Astra, Claude, DeepSeek and GLM under one agentrouter/ namespace.

ExtensionProvider

Install

Install with PiG

pig install npm:@bismawy/pi-agentrouter

Install with Pi

pi install npm:@bismawy/pi-agentrouter
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.

{
  "image": "https://raw.githubusercontent.com/bismawy/pi-agentrouter/main/assets/banner.webp",
  "extensions": [
    "./index.ts"
  ]
}

README

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

AgentRouter

Unified frontier models. Self-healing WAF recovery. Zero workflow interruption.

Custom badge badge license

AgentRouter: unified frontier models and self-healing WAF recovery for Pi

Overview

pi-agentrouter provides a unified provider for AgentRouter in Pi — routing GPT-6 Astra, GPT-5.6 Sol, Claude Opus 4.8 / 5, DeepSeek V4 Flash, and GLM 5.3 under a single agentrouter/ namespace with self-healing WAF recovery.

  • Protocol Routing: GPT-6 Astra routes via OpenAI Responses, Claude models via Anthropic Messages, and others via OpenAI Completions under one provider.
  • WAF Header & Language Guard: Forces Pi's canonical system header to byte 0 and applies language framing on user turns.
  • Self-Healing Recovery: Redacts older history turns in two stages on content-filter triggers, and automatically translates the latest turn to English when needed.
  • Payload Sanitization: Strips ANSI escape codes, null bytes, control characters, and orphan Unicode surrogates before dispatch.
  • Session Affinity: Injects sendSessionAffinityHeaders: true by default to maximize server-side cache hits.

Model Catalog

The catalog is discovered live: on every pi model refresh (startup and right after /login), the extension probes GET https://agentrouter.org/v1/models with your key and registers exactly what the account lists — no manual model entries. Any probe failure (offline, missing key, WAF) falls back to the last confirmed snapshot. Current snapshot and verified wire configs:

ModelContextInputProtocolThinking
agentrouter/gpt-6-astra272ktext, imageOpenAI Responseslow – xhigh
agentrouter/gpt-5.6-sol272ktext, imageOpenAI Completionslow – xhigh
agentrouter/gpt-6.1-sol272ktext, imageOpenAI Responseslow – xhigh

Catalog ids without a verified config register with a conservative text-only default. Retired ids keep their wire configs in MODEL_BLUEPRINTS, so a relisted model (e.g. claude-opus-5, glm-5.3, deepseek-v4-flash) automatically comes back with the right protocol.

Install

pi install npm:@bismawy/pi-agentrouter

Supply your API key via /login agentrouter, export AGENTROUTER_API_KEY="your-key", or in ~/.pi/agent/models.json.

No account yet? Register on AgentRouter for a $50 bonus.

To test locally without installing:

pi -e ./index.ts

Commands

CommandAction
/agentrouterInteractive menu with Status and Usage panels
/agentrouter statusView active models, status, and balance in a styled TUI panel
/agentrouter usageInspect session usage metrics and cost estimates

Architecture

WAF Auto-Recovery Lifecycle
  1. Forces Pi's system prompt header to the very start of the payload.
  2. On content-blocked or sensitive-words errors, marks the turn retryable for automatic recovery.
  3. Stage 1 redacts older user turns; Stage 2 escalates to assistant turns while preserving tool pairs.
  4. Stage 3 translates the newest turn to English if redaction is exhausted, avoiding user turn deletion.
  5. Redaction depth resets on new conversations or compaction.
Development
npm test # Runs check-framing.ts self-checks

License

Distributed under the MIT license.

Author

Bisma