mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Add pxpipe as an experimental fifth Token Saver: Claude-format request bodies above a configurable size threshold are rendered as dense PNGs via the pxpipe-proxy library API (transformAnthropicMessages) before dispatch, cutting estimated input tokens by ~35-60% on token-dense contexts. Integration follows the Headroom pattern: applied to the final body in chatCore just before dispatch, fail-open on any error/timeout. Managed npm install into DATA_DIR/pxpipe, dynamic loader with per-version cache-bust, JSONL event log with rotation, /api/pxpipe/* endpoints, Token Saver card (marked experimental) + /dashboard/pxpipe page, and per-request Activated/Skipped annotation in Request Details. Disabled by default.
19 lines
607 B
JavaScript
19 lines
607 B
JavaScript
import { NextResponse } from "next/server";
|
|
import { getInstallLogTail } from "@/lib/pxpipe/install.js";
|
|
import { readPxpipeEvents } from "@/lib/pxpipe/events.js";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(request) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const limit = Math.min(Number(searchParams.get("limit")) || 100, 500);
|
|
return NextResponse.json({
|
|
installLog: getInstallLogTail(),
|
|
events: readPxpipeEvents({ limit }).reverse(),
|
|
});
|
|
} catch (error) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
}
|