mirror of
https://github.com/teamchong/pxpipe.git
synced 2026-07-22 02:02:51 +02:00
f91c149d05
Runtime is pure Web Standard APIs (fetch, Request, Response, Uint8Array,
CompressionStream, crypto.subtle, btoa) — zero runtime dependencies.
Core (src/core/, runs identically on Node 18+ and Workers):
- atlas.ts auto-generated 9x15 JBM glyph atlas, base64-inlined (17KB)
- png.ts minimal grayscale PNG encoder via CompressionStream
- render.ts text → packed PNG, soft-wraps at 100 cols, ≤1568px tall
- transform.ts request body rewriter (system + tool docs → image blocks)
- proxy.ts fetch-handler that transforms then forwards to Anthropic
- types.ts Anthropic Messages API types we touch
Adapters:
- src/node.ts node:http server + CLI flag parsing
- src/worker.ts export default { fetch } for wrangler dev/deploy
Build tooling:
- scripts/gen-atlas.ts @napi-rs/canvas → atlas.ts (build-time only)
- scripts/build.mjs esbuild Node bundle; wrangler handles Worker
- tsconfig.json strict, ES2022, Workers types
Tests (vitest): 8 passing — PNG signature, base64 round-trip, single +
multi-image renders, transform no-op + compress paths, billing-line strip,
tool fold + stub.
E2E smoke: 16K char system → 2 PNGs (36KB) → mock upstream, 34ms.
Next: replace docs, then verify byte-output parity against legacy/python.
22 lines
582 B
TOML
22 lines
582 B
TOML
name = "pixelpipe"
|
|
main = "src/worker.ts"
|
|
compatibility_date = "2024-09-23"
|
|
compatibility_flags = ["nodejs_compat_v2"]
|
|
|
|
# Anthropic upstream is fetched via global fetch — no special bindings needed.
|
|
# Set secrets via: wrangler secret put ANTHROPIC_API_KEY (optional passthrough)
|
|
|
|
[vars]
|
|
ANTHROPIC_UPSTREAM = "https://api.anthropic.com"
|
|
COMPRESS = "1"
|
|
MIN_COMPRESS_CHARS = "2000"
|
|
FONT_PX = "15"
|
|
|
|
# Uncomment to ship to a workers.dev subdomain
|
|
# workers_dev = true
|
|
|
|
# Or attach a custom route:
|
|
# routes = [
|
|
# { pattern = "pixelpipe.example.com/*", zone_name = "example.com" }
|
|
# ]
|