{"_id":"@agent-rewind/gateway","_rev":"4-94520281049e348e4c24f8dbec39e783","name":"@agent-rewind/gateway","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"name":"@agent-rewind/gateway","version":"0.1.0","keywords":["llm","proxy","record-replay","prompt-cache","token-savings","anthropic","ai-agents"],"license":"FSL-1.1-ALv2","_id":"@agent-rewind/gateway@0.1.0","maintainers":[{"name":"darkstar616","email":"rgburls@gmail.com"}],"homepage":"https://github.com/DarkStar616/rewind","bugs":{"url":"https://github.com/DarkStar616/rewind/issues"},"dist":{"shasum":"4d3ed4a65bf13e49e5a764d4e35192593bf8efed","tarball":"https://registry.npmjs.org/@agent-rewind/gateway/-/gateway-0.1.0.tgz","fileCount":5,"integrity":"sha512-dD46/C/yBRkdhn+/QqhXCpdR/cwfcruJQKVYS7Spk7UNN6hYDrs/Ld+nIzAu8XeS2hjscKk55WZ2pYgR/A5EEA==","signatures":[{"sig":"MEYCIQCEFTvar/P8LMNV3Quh35QRxUtTv6xxQMAyNX/km2k4ywIhAOF264u+peoA9q8kGsJMEPmPrlhdf2Vu8mXs3GmYazKQ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":195183},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"6474bd46ee505c684fab9c1167e6f3277d0496a0","scripts":{"build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"darkstar616","email":"rgburls@gmail.com"},"repository":{"url":"git+https://github.com/DarkStar616/rewind.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.18.0","description":"Local byte-exact record/replay LLM proxy for AI coding agents: zero-cost replay after a rewind, prompt-cache preservation, deterministic tool-output pruning, and verifiable token-savings accounting.","directories":{},"_nodeVersion":"26.6.0","dependencies":{"@agent-rewind/core":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/gateway_0.1.0_1787127183690_0.3116561642273856","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agent-rewind/gateway","version":"0.1.1","keywords":["llm","proxy","record-replay","prompt-cache","token-savings","anthropic","ai-agents"],"license":"FSL-1.1-ALv2","_id":"@agent-rewind/gateway@0.1.1","maintainers":[{"name":"darkstar616","email":"rgburls@gmail.com"}],"homepage":"https://github.com/DarkStar616/rewind","bugs":{"url":"https://github.com/DarkStar616/rewind/issues"},"dist":{"shasum":"ff4fbe94cd65fdb898b1401de8fff4669be3159c","tarball":"https://registry.npmjs.org/@agent-rewind/gateway/-/gateway-0.1.1.tgz","fileCount":5,"integrity":"sha512-0KYnGvtJb6jPGcPLiRAvNXwUQKqmm6Ma0D7VJfnnEDIZ3eY97SZJmF2WR2Zu1iWR5hT4pYaGUlsiqoyvk2l/6Q==","signatures":[{"sig":"MEYCIQDhzbPTVAt4IrCKKJX8Qt0hU+ypAbMzzyAJUaXe2+JLTAIhAMSu81oG0xg/Z5vhL4inCc48K0tKtUHkT9ivtKMwJrmv","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":195183},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"b38f54ce178a0b43c871539957c2e6dabde29c44","scripts":{"build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"darkstar616","email":"rgburls@gmail.com"},"repository":{"url":"git+https://github.com/DarkStar616/rewind.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.18.0","description":"Local byte-exact record/replay LLM proxy for AI coding agents: zero-cost replay after a rewind, prompt-cache preservation, deterministic tool-output pruning, and verifiable token-savings accounting.","directories":{},"_nodeVersion":"26.6.0","dependencies":{"@agent-rewind/core":"^0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/gateway_0.1.1_1787129955905_0.8868617073155387","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@agent-rewind/gateway","version":"1.0.0","keywords":["llm","proxy","record-replay","prompt-cache","token-savings","anthropic","ai-agents"],"license":"FSL-1.1-ALv2","_id":"@agent-rewind/gateway@1.0.0","maintainers":[{"name":"darkstar616","email":"rgburls@gmail.com"}],"homepage":"https://github.com/DarkStar616/rewind","bugs":{"url":"https://github.com/DarkStar616/rewind/issues"},"dist":{"shasum":"632d4a7c0b607c7fc56c4a96ca38d8319ae23666","tarball":"https://registry.npmjs.org/@agent-rewind/gateway/-/gateway-1.0.0.tgz","fileCount":5,"integrity":"sha512-JtH41zRI42TtAUEKbM0mIWG+Hnai7bdVlK+DvldnIgxdyO7b3W9o1RAAMTD91OKSgJvny4ZNJEWQwOUqW9r/ZQ==","signatures":[{"sig":"MEQCIHZstM6w29FdZ+o0Bg8PCkEv51jprLVpBPtJWnqROKYPAiAGlXukqGp4B1eWu0mh1OQlZsKW9gq0XfXhNcQJsfHNcA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":269619},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"329f1505e9e73a4301ede9178cc3f2490e7d00b7","scripts":{"build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"darkstar616","email":"rgburls@gmail.com"},"repository":{"url":"git+https://github.com/DarkStar616/rewind.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.18.0","description":"Local byte-exact record/replay LLM proxy for AI coding agents: zero-cost replay after a rewind, prompt-cache preservation, deterministic tool-output pruning, and verifiable token-savings accounting.","directories":{},"_nodeVersion":"26.6.0","dependencies":{"@agent-rewind/core":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/gateway_1.0.0_1787177913718_0.7396884904822127","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"_id":"@agent-rewind/gateway@1.1.0","bugs":{"url":"https://github.com/DarkStar616/rewind/issues"},"dist":{"shasum":"cca2dd018cdd7d055a91632225d6d39cf894d108","tarball":"https://registry.npmjs.org/@agent-rewind/gateway/-/gateway-1.1.0.tgz","fileCount":9,"integrity":"sha512-BKcvP7u2LprCR70kmuCUh22wC4chIcB/CPE4zo0BZP/dasf9KKhiWM84IHwU1Ra0cHxysTCft+sc/MFQQdTSGQ==","signatures":[{"sig":"MEUCIGSzmCmY2g3SYktZV2ufcVA0Ft9jg+arTTgPuzutadCSAiEAsjfJLbgVaYd7OQDLYFdlzIi0lveC7xE76AStss6KT3o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFg5QdbiL5xVngNv0li/x1gltz+NVFcCS8IV2qZ/t1yBAiBL+LCYcJCf3WgZIzPiO/4jJANT9dQRFGiveziXYeqgSQ=="}],"unpackedSize":489302},"main":"./dist/index.js","name":"@agent-rewind/gateway","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js","development":"./src/index.ts"}},"gitHead":"3eca060db407d97b12cbcf0df7d99c1266030a64","license":"FSL-1.1-ALv2","scripts":{"build":"tsup","prepublishOnly":"npm run build"},"version":"1.1.0","_npmUser":{"name":"darkstar616","email":"rgburls@gmail.com"},"homepage":"https://github.com/DarkStar616/rewind","keywords":["llm","proxy","record-replay","prompt-cache","token-savings","anthropic","ai-agents"],"repository":{"url":"git+https://github.com/DarkStar616/rewind.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.18.0","description":"Local byte-exact record/replay LLM proxy for AI coding agents: zero-cost replay after a rewind, prompt-cache preservation, deterministic tool-output pruning, and verifiable token-savings accounting.","directories":{},"maintainers":[{"name":"darkstar616","email":"rgburls@gmail.com"}],"_nodeVersion":"26.6.0","dependencies":{"@agent-rewind/core":"^1.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"optionalDependencies":{"better-sqlite3":"12.11.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gateway_1.1.0_1789028667620_0.9858317177011129"}}},"time":{"created":"2026-08-19T08:13:03.537Z","modified":"2026-09-10T08:24:27.928Z","0.1.0":"2026-08-19T08:13:03.839Z","0.1.1":"2026-08-19T08:59:16.084Z","1.0.0":"2026-08-19T22:18:33.876Z","1.1.0":"2026-09-10T08:24:27.755Z"},"bugs":{"url":"https://github.com/DarkStar616/rewind/issues"},"license":"FSL-1.1-ALv2","homepage":"https://github.com/DarkStar616/rewind","keywords":["llm","proxy","record-replay","prompt-cache","token-savings","anthropic","ai-agents"],"repository":{"url":"git+https://github.com/DarkStar616/rewind.git","type":"git","directory":"packages/gateway"},"description":"Local byte-exact record/replay LLM proxy for AI coding agents: zero-cost replay after a rewind, prompt-cache preservation, deterministic tool-output pruning, and verifiable token-savings accounting.","maintainers":[{"name":"darkstar616","email":"rgburls@gmail.com"}],"readme":"# @agent-rewind/gateway\n\nThe token-saving LLM proxy of [Agent Rewind](https://github.com/DarkStar616/rewind) — local, **byte-exact**\nrecord/replay for AI coding agents, plus prompt-cache preservation, deterministic pruning, and\nverifiable savings accounting.\n\nProvides:\n\n- **Byte-exact record/replay** (`canonicalizeRequest`, `createReplayer`, `createMemoryRecordStore`) —\n  a request's replay key is a SHA-256 over a **deny-list** projection, so a byte-equivalent request\n  after a rewind is served from record at zero upstream cost, while a semantically different request\n  is **never** served a stale answer (false-miss over false-hit, by design).\n- **Prompt-cache preservation** (`planCacheBreakpoints`) — inject one cache breakpoint on the static\n  prefix when the agent set none; credit only what it actually caused.\n- **Deterministic, lossless pruning** (`pruneToolOutputs`) — collapse duplicate `tool_result` blocks,\n  replay-safe by construction.\n- **Honest metering & gainshare surface** (`avoidedCostMicros`, `billableSavedTokens`, `analyzeTraffic`\n  + `attestAnalysis`, `reconcileAgainstProviderBill`) — priced from the provider's own usage, floored,\n  never over-crediting; reports fold into a verifiable hash chain.\n\n**Provider-neutral.** Three built-in adapters cover **Anthropic** (`/v1/messages`), **OpenAI**\n(`/v1/chat/completions` and `/v1/responses`), and **Google Gemini** (`:generateContent`), auto-selected per request or pinned\nexplicitly. Any **OpenAI-compatible** endpoint (Kimi / Moonshot, DeepSeek, Together, Fireworks, Groq,\nOpenRouter, Nebius, xAI, vLLM, Ollama, …) is handled by the OpenAI adapter. The byte-exact replay key is\nprovider-agnostic; unlisted models meter against a conservative default rate (under-bills, never over).\n\n```bash\nnpm install @agent-rewind/gateway\n```\n\nRequires Node ≥ 20. Licence: **FSL-1.1-ALv2**. See the [monorepo](https://github.com/DarkStar616/rewind)\nfor architecture and the full product breakdown.\n\n## Optional encrypted storage foundation\n\n`openSqliteStorage({ directory, tenant, wrappingKey })` opens an asynchronous SQLite worker. Use an\nabsolute, dedicated owner-only directory and a 32-byte key supplied by your application; do not put\nkeys in request headers, command-line arguments or source control. Values are binary and encrypted;\nnamespace names remain public. The optional `better-sqlite3@12.11.1` driver may need a compiler and\nNode headers (Node 20 prebuilt coverage is incomplete). A requested durable open fails if the driver\ncannot load; compatibility installations do not require it.\n\nUse `commit(transactionId, mutations)` for atomic writes, `expectedRevision: null` for absence, or a\nreturned revision for compare-and-swap. Reuse the same transaction ID and exact mutations after an\nambiguous completion; conflicting retries fail. `get` and paginated `scan` exclude expired values.\n`createEncryptedStaging(storage)` adds bounded, ordered encrypted chunks and an explicit seal before\nreading. Schedule `collectExpired()` to remove abandoned/expired stages. Always await `close()`.\n\nThis is a storage API foundation, not yet the CLI replay backend. Physical erasure, key rotation,\ntransaction-receipt retention and the full packaging/crash-test matrix remain future work. Managed WAL writes have a separate `maxWalBytes` allowance; pinned readers can cause explicit write\nrefusal. This is not a whole-directory quota or a constraint on arbitrary external SQLite writers. See `docs/STABILITY.md` for the contract.\n\n### Responses clients\n\nThe gateway records completed Responses JSON and SSE without rewriting tool calls, reasoning items,\nor output bytes. Failed, incomplete and malformed streams remain live and are not recorded. Inclusive\ninput counts split into ordinary input, cache reads and cache writes; reasoning tokens are already\nincluded in output and are not added again. See the provider's\n[prompt caching accounting](https://developers.openai.com/api/docs/guides/prompt-caching) and\n[streaming protocol](https://developers.openai.com/api/docs/guides/streaming-responses).\n\nCodex CLI 0.153.4 was exercised through this gateway with a local scripted provider: its Responses\nrequest completed and an identical request replayed with no second upstream call. This is a local\nprotocol smoke test, not evidence of paid-provider savings. Configure a Codex model provider with\n`base_url = \"http://127.0.0.1:8788/v1\"` and `wire_api = \"responses\"`; the gateway's upstream remains\nthe provider origin. Stateful provider conversations and stored response IDs still belong to that\nupstream account; Rewind does not recreate provider-side objects after deletion.\n","readmeFilename":"README.md"}