{"_id":"@agentrewind/codec-openrouter","_rev":"4-5f642f95f7830e24da4896e537d43e58","name":"@agentrewind/codec-openrouter","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@agentrewind/codec-openrouter","version":"0.1.0","keywords":["openrouter","chat-completions","llm","agents","replay"],"_id":"@agentrewind/codec-openrouter@0.1.0","maintainers":[{"name":"faizancodes","email":"faizanahmed80113@gmail.com"}],"homepage":"https://github.com/faizancodes/agent-rewind#readme","bugs":{"url":"https://github.com/faizancodes/agent-rewind/issues"},"dist":{"shasum":"a111ff254851dcce276ccac32fb91e6a9409a73f","tarball":"https://registry.npmjs.org/@agentrewind/codec-openrouter/-/codec-openrouter-0.1.0.tgz","fileCount":4,"integrity":"sha512-H8XxgtCj8NDuHMffFcCkcucF40M1mBTgVDAinW1Kzh76DipVOzZAagVDbdM3Dpcj3Deii8ri6diAVefXlyvn4w==","signatures":[{"sig":"MEUCIQCfJ2cov8EkiJnMptGeQehUW68iKjPzbFunEwjZPIEdZwIga2DKUviabBW6uk8GEVNBjd4qfLBdzKCWJgQNA/pS9cg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6571},"main":"./dist/index.js","type":"module","_from":"file:agentrewind-codec-openrouter-0.1.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format esm --dts --target node20 --tsconfig ../../tsconfig.base.json"},"_npmUser":{"name":"faizancodes","email":"faizanahmed80113@gmail.com"},"_resolved":"/private/var/folders/lx/9cfxw6t518v6pm64gzxsbrkm0000gn/T/4bab865dfe85383d42a4b53643a62f8f/agentrewind-codec-openrouter-0.1.0.tgz","_integrity":"sha512-H8XxgtCj8NDuHMffFcCkcucF40M1mBTgVDAinW1Kzh76DipVOzZAagVDbdM3Dpcj3Deii8ri6diAVefXlyvn4w==","repository":{"url":"git+https://github.com/faizancodes/agent-rewind.git","type":"git"},"_npmVersion":"10.9.7","description":"OpenRouter Chat Completions codec and OpenAI SDK client helpers for AgentRewind.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@agentrewind/core":"0.1.0","@agentrewind/codec-openai":"0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"openai":"^6.39.1"},"peerDependencies":{"openai":"*"},"_npmOperationalInternal":{"tmp":"tmp/codec-openrouter_0.1.0_1780220640591_0.6135480385787422","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agentrewind/codec-openrouter","version":"0.1.1","keywords":["openrouter","chat-completions","llm","agents","replay"],"_id":"@agentrewind/codec-openrouter@0.1.1","maintainers":[{"name":"faizancodes","email":"faizanahmed80113@gmail.com"}],"homepage":"https://github.com/faizancodes/agent-rewind#readme","bugs":{"url":"https://github.com/faizancodes/agent-rewind/issues"},"dist":{"shasum":"094ac3c292e9854a96cf882c0ece0078ac3390af","tarball":"https://registry.npmjs.org/@agentrewind/codec-openrouter/-/codec-openrouter-0.1.1.tgz","fileCount":4,"integrity":"sha512-0SXuH1JdstkdFGu+AfJLPj2hgpJpRR3ubkknYTQ3x99vHfllSLf4cQ6oURW8FXc7bw6pMM0TaU66B9vFKy4Kvg==","signatures":[{"sig":"MEYCIQDsa7ZDcDuTePlUpF6vwVbaVPqb8fthP+NGjVANrj1koAIhANAcuI8SDbNb5RNaw5cGTwav/XDALRuKVmoYkIFXqkU0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6526},"main":"./dist/index.js","type":"module","_from":"file:agentrewind-codec-openrouter-0.1.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format esm --dts --target node20 --tsconfig ../../tsconfig.base.json"},"_npmUser":{"name":"faizancodes","email":"faizanahmed80113@gmail.com"},"_resolved":"/private/var/folders/lx/9cfxw6t518v6pm64gzxsbrkm0000gn/T/e4a0fd8a4e862bbc63f7cf019138793b/agentrewind-codec-openrouter-0.1.1.tgz","_integrity":"sha512-0SXuH1JdstkdFGu+AfJLPj2hgpJpRR3ubkknYTQ3x99vHfllSLf4cQ6oURW8FXc7bw6pMM0TaU66B9vFKy4Kvg==","repository":{"url":"git+https://github.com/faizancodes/agent-rewind.git","type":"git"},"_npmVersion":"10.9.7","description":"OpenRouter Chat Completions codec and OpenAI SDK client helpers for AgentRewind.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@agentrewind/core":"0.1.1","@agentrewind/codec-openai":"0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"openai":"^6.39.1"},"peerDependencies":{"openai":"*"},"_npmOperationalInternal":{"tmp":"tmp/codec-openrouter_0.1.1_1780222213222_0.7708588761580015","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@agentrewind/codec-openrouter","version":"0.1.2","keywords":["openrouter","chat-completions","llm","agents","replay"],"_id":"@agentrewind/codec-openrouter@0.1.2","maintainers":[{"name":"faizancodes","email":"faizanahmed80113@gmail.com"}],"homepage":"https://github.com/faizancodes/agent-rewind#readme","bugs":{"url":"https://github.com/faizancodes/agent-rewind/issues"},"dist":{"shasum":"36c7a98e21e7400123b59c705de5668318f231e5","tarball":"https://registry.npmjs.org/@agentrewind/codec-openrouter/-/codec-openrouter-0.1.2.tgz","fileCount":4,"integrity":"sha512-p7VF4EhoON4+PBaglZFFd+3qIkYhmqk7GhG9QXnJEqbioesZLN1zqVidMlHZVhvdN5QiYGsnRXT/5Qljs/vnMQ==","signatures":[{"sig":"MEUCIDGnJSQu5dvPGRac43oNLsqEgoG+NfT4TkktQc6+PG8sAiEAz2sIpdyy5kgjHZ8yhf18eYPNva+y9sciqbRYAoHkVsw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6854},"main":"./dist/index.js","type":"module","_from":"file:agentrewind-codec-openrouter-0.1.2.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format esm --dts --target node20 --tsconfig ../../tsconfig.base.json"},"_npmUser":{"name":"faizancodes","email":"faizanahmed80113@gmail.com"},"_resolved":"/private/var/folders/lx/9cfxw6t518v6pm64gzxsbrkm0000gn/T/dcb4f695a9c881d5056cb4af64bec845/agentrewind-codec-openrouter-0.1.2.tgz","_integrity":"sha512-p7VF4EhoON4+PBaglZFFd+3qIkYhmqk7GhG9QXnJEqbioesZLN1zqVidMlHZVhvdN5QiYGsnRXT/5Qljs/vnMQ==","repository":{"url":"git+https://github.com/faizancodes/agent-rewind.git","type":"git"},"_npmVersion":"10.9.7","description":"OpenRouter Chat Completions codec and OpenAI SDK client helpers for AgentRewind.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@agentrewind/core":"0.1.2","@agentrewind/codec-openai":"0.1.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"openai":"^6.39.1"},"peerDependencies":{"openai":"*"},"_npmOperationalInternal":{"tmp":"tmp/codec-openrouter_0.1.2_1780348004855_0.4701588789960198","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@agentrewind/codec-openrouter","version":"0.1.4","description":"OpenRouter Chat Completions codec and OpenAI SDK client helpers for AgentRewind.","type":"module","keywords":["openrouter","chat-completions","llm","agents","replay"],"engines":{"node":">=20"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"publishConfig":{"access":"public"},"peerDependencies":{"openai":"*"},"dependencies":{"@agentrewind/codec-openai":"0.1.4","@agentrewind/core":"0.1.4"},"devDependencies":{"openai":"^6.39.1"},"repository":{"type":"git","url":"git+https://github.com/faizancodes/agent-rewind.git"},"homepage":"https://github.com/faizancodes/agent-rewind#readme","bugs":{"url":"https://github.com/faizancodes/agent-rewind/issues"},"scripts":{"build":"tsup src/index.ts --format esm --dts --target node20 --tsconfig ../../tsconfig.base.json"},"_id":"@agentrewind/codec-openrouter@0.1.4","_integrity":"sha512-I7A/U5n1HlPlRG+9/59H1j70mogjFGcTDQR+K8idDB0348jYfHCmuM+vVZ6gI3NnhqecYjp7mgBkaSlXy+e9ZQ==","_resolved":"/private/var/folders/lx/9cfxw6t518v6pm64gzxsbrkm0000gn/T/a142cf9840cb4e1a501f9f455b87d394/agentrewind-codec-openrouter-0.1.4.tgz","_from":"file:agentrewind-codec-openrouter-0.1.4.tgz","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-I7A/U5n1HlPlRG+9/59H1j70mogjFGcTDQR+K8idDB0348jYfHCmuM+vVZ6gI3NnhqecYjp7mgBkaSlXy+e9ZQ==","shasum":"b2c479e8127d2de93133db4584dccc78931cc086","tarball":"https://registry.npmjs.org/@agentrewind/codec-openrouter/-/codec-openrouter-0.1.4.tgz","fileCount":4,"unpackedSize":6854,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDhJjBf/9ztaMLxsb8+ExDtT3jQH2oZ4wqQNKLVPTCMsAiEAntrE+lTRgNUA98bMpU4NjGYqDOHvl9WAB/JCdINARaA="}]},"_npmUser":{"name":"faizancodes","email":"faizanahmed80113@gmail.com"},"directories":{},"maintainers":[{"name":"faizancodes","email":"faizanahmed80113@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codec-openrouter_0.1.4_1780376755891_0.0777933497107921"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-31T09:44:00.443Z","modified":"2026-06-02T05:05:56.149Z","0.1.0":"2026-05-31T09:44:00.723Z","0.1.1":"2026-05-31T10:10:13.369Z","0.1.2":"2026-06-01T21:06:45.027Z","0.1.4":"2026-06-02T05:05:56.025Z"},"bugs":{"url":"https://github.com/faizancodes/agent-rewind/issues"},"homepage":"https://github.com/faizancodes/agent-rewind#readme","keywords":["openrouter","chat-completions","llm","agents","replay"],"repository":{"type":"git","url":"git+https://github.com/faizancodes/agent-rewind.git"},"description":"OpenRouter Chat Completions codec and OpenAI SDK client helpers for AgentRewind.","maintainers":[{"name":"faizancodes","email":"faizanahmed80113@gmail.com"}],"readme":"# @agentrewind/codec-openrouter\n\nFirst-class OpenRouter Chat Completions support for AgentRewind.\n\nOpenRouter exposes an OpenAI-compatible Chat Completions API at\n`https://openrouter.ai/api/v1`. This package gives that integration its own\nAgentRewind provider identity, OpenRouter constants, and OpenAI SDK client\noption helper.\n\n## Install\n\nMost users get this codec through the SDK:\n\n```sh\nnpm install @agentrewind/sdk\n```\n\nUse this package directly only when a library needs granular dependency\nboundaries.\n\n## Recording\n\n```ts\nimport {\n  AgentRewind,\n  OpenAI,\n  assertProviderClient,\n  defineHarness,\n  openRouterChatCodec,\n  openRouterClientOptions\n} from \"@agentrewind/sdk\";\nimport type { ChatCompletion } from \"@agentrewind/sdk\";\n\nconst client = new OpenAI(\n  openRouterClientOptions({\n    apiKey: process.env.OPENROUTER_API_KEY,\n    appUrl: \"https://your-app.example\",\n    appTitle: \"Your Agent\"\n  })\n);\n\nconst codec = openRouterChatCodec();\nassertProviderClient(client, codec);\n\nconst harness = defineHarness(async (ctx) => {\n  const completion = await ctx.model.create<ChatCompletion>(\n    {\n      model: \"openrouter/model-id\",\n      messages: [{ role: \"user\", content: `Request ${ctx.uuid()}` }],\n      temperature: 0\n    },\n    { site: \"openrouter-answer\" }\n  );\n\n  return completion.choices[0]?.message.content ?? \"\";\n});\n\nconst recorded = await AgentRewind.recordRun(\n  {\n    id: \"openrouter-demo\",\n    store: \".rewind\",\n    model: client,\n    codec\n  },\n  harness\n);\n```\n\n## OpenRouter Options\n\n`openRouterClientOptions()` returns options for the OpenAI Node SDK:\n\n```ts\nconst options = openRouterClientOptions({\n  apiKey: process.env.OPENROUTER_API_KEY,\n  appUrl: \"https://your-app.example\",\n  appTitle: \"Your Agent\",\n  appCategories: [\"cli-agent\", \"debugging\"]\n});\n```\n\nIt sets:\n\n- `baseURL: \"https://openrouter.ai/api/v1\"`\n- `HTTP-Referer` when `appUrl` is provided\n- `X-OpenRouter-Title` when `appTitle` is provided\n- `X-OpenRouter-Categories` when `appCategories` is provided\n\n## OpenRouter Request Parameters\n\nOpenRouter-specific Chat Completions request parameters are preserved in\n`params` and replayed/forked with the request:\n\n```ts\nawait ctx.model.create(\n  {\n    model: \"openrouter/anthropic-model-id\",\n    messages: [{ role: \"user\", content: \"Classify this ticket.\" }],\n    provider: {\n      order: [\"Anthropic\"],\n      allow_fallbacks: false\n    },\n    plugins: [{ id: \"response-healing\" }],\n    response_format: { type: \"json_object\" }\n  },\n  { site: \"classify-ticket\" }\n);\n```\n\n`metadata` is treated as volatile, matching the OpenAI-compatible codec.\n\n## Replay\n\nStrict replay needs no live OpenRouter client:\n\n```ts\nconst replayed = await AgentRewind.replayRun(\n  recorded.path,\n  { codec: openRouterChatCodec() },\n  harness\n);\n```\n\n## Streaming\n\n`ctx.model.stream()` calls `client.chat.completions.stream()`:\n\n```ts\nassertProviderClient(client, codec, [\"stream\"]);\n```\n\n```ts\nfor await (const chunk of ctx.model.stream(\n  {\n    model: \"openrouter/model-id\",\n    messages: [{ role: \"user\", content: \"Stream one sentence.\" }]\n  },\n  { site: \"openrouter-stream\" }\n)) {\n  process.stdout.write(chunk.choices[0]?.delta?.content ?? \"\");\n}\n```\n","readmeFilename":"README.md"}