{"_id":"@agent-trace-cache/sdk","_rev":"2-44051055b7c5d674ff13f8bd52664296","name":"@agent-trace-cache/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agent-trace-cache/sdk","version":"0.1.0","keywords":["agent","cache","sdk","withCache","mastra","langgraph","openai-agents","trajectory","typescript"],"author":{"name":"Kyle Ma"},"license":"MIT","_id":"@agent-trace-cache/sdk@0.1.0","maintainers":[{"name":"kylepma","email":"kylephuma@gmail.com"}],"homepage":"https://github.com/kylemaa/agent-trace-cache#readme","bugs":{"url":"https://github.com/kylemaa/agent-trace-cache/issues"},"dist":{"shasum":"d4b8a5d93b5b2ef2b00f85d7b40cbb6d5c98e16b","tarball":"https://registry.npmjs.org/@agent-trace-cache/sdk/-/sdk-0.1.0.tgz","fileCount":13,"integrity":"sha512-V9I0T1QlAXlaTv0rzrKt5W9K5QhmaCMpcdHLbGC5+GABfcfUXRHbErFNdRwuN27im5bgQsp79PYbvYqsx+3i+w==","signatures":[{"sig":"MEUCIH+nQuS61h49RaeadMUyqyAzim+DXsfpf7AGwMBuLn0zAiEA98rAkJZZ15naEPloLINZqqENOYZasxfic7kR4wovRQI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17097},"main":"./dist/index.js","type":"module","_from":"file:agent-trace-cache-sdk-0.1.0.tgz","types":"./dist/index.d.ts","scripts":{"build":"tsc --build","typecheck":"tsc --build"},"_npmUser":{"name":"kylepma","email":"kylephuma@gmail.com"},"_resolved":"C:\\Users\\kylep\\AppData\\Local\\Temp\\e6e8834ff6fd7bec6bf7f0790eddcc38\\agent-trace-cache-sdk-0.1.0.tgz","_integrity":"sha512-V9I0T1QlAXlaTv0rzrKt5W9K5QhmaCMpcdHLbGC5+GABfcfUXRHbErFNdRwuN27im5bgQsp79PYbvYqsx+3i+w==","repository":{"url":"git+https://github.com/kylemaa/agent-trace-cache.git","type":"git","directory":"packages/sdk"},"_npmVersion":"10.2.4","description":"Framework-agnostic SDK for AgentTrace-Cache. createCache + withCache wrap any agent function (Mastra, LangGraph, raw OpenAI Agents SDK, custom loops) with a deterministic trajectory cache.","directories":{},"_nodeVersion":"20.11.1","dependencies":{"@agent-trace-cache/core":"0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1777337955608_0.5277735692324717","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @pomerene/sdk — install @pomerene/sdk instead"}},"time":{"created":"2026-04-28T00:59:15.503Z","modified":"2026-06-02T03:50:04.959Z","0.1.0":"2026-04-28T00:59:15.775Z"},"bugs":{"url":"https://github.com/kylemaa/agent-trace-cache/issues"},"author":{"name":"Kyle Ma"},"license":"MIT","homepage":"https://github.com/kylemaa/agent-trace-cache#readme","keywords":["agent","cache","sdk","withCache","mastra","langgraph","openai-agents","trajectory","typescript"],"repository":{"url":"git+https://github.com/kylemaa/agent-trace-cache.git","type":"git","directory":"packages/sdk"},"description":"Framework-agnostic SDK for AgentTrace-Cache. createCache + withCache wrap any agent function (Mastra, LangGraph, raw OpenAI Agents SDK, custom loops) with a deterministic trajectory cache.","maintainers":[{"name":"kylepma","email":"kylephuma@gmail.com"}],"readme":"# @agent-trace-cache/sdk\n\nFramework-agnostic SDK for AgentTrace-Cache. Wraps any agent function — Mastra `agent.generate.bind(agent)`, a LangGraph node, a raw OpenAI Agents SDK call, a custom loop — with a deterministic trajectory cache that returns cached outcomes when the new query is semantically similar to a cached one.\n\nThe cache hit path is zero-LLM by design. No plan adaptation, no parameter rewriting, no runtime LLM judgment.\n\n## Install\n\n```bash\npnpm add @agent-trace-cache/sdk\n# or: npm install @agent-trace-cache/sdk\n```\n\n## Quickstart\n\n```ts\nimport { createCache, withCache } from '@agent-trace-cache/sdk'\n\nconst cache = await createCache({\n  apiKey: process.env.OPENAI_API_KEY,\n  storage: 'memory', // or 'libsql:file:./traj.db' for persistence\n})\n\nconst cachedAgent = withCache(myAgent, {\n  cache,\n  extractGoal: (input) => input.question,\n  extractContext: (input) => ({ user_id: input.userId }),\n  toOutput: (cached) => ({ answer: cached.outcome }),\n  recordTrajectory: (input, output) => ({\n    id: `${input.userId}-${Date.now()}`,\n    goal: input.question,\n    goalEmbedding: [], // auto-filled by cache.store\n    contextSnapshot: [],\n    steps: [],\n    taintMap: [],\n    outcome: output.answer,\n    cost: { promptTokens: 0, completionTokens: 0, totalTokens: 0, estimatedUsd: 0 },\n    replayAccuracy: null,\n    timestamp: new Date(),\n    metadata: { source: 'my-agent' },\n  }),\n})\n\n// First call: miss → runs your agent → trajectory recorded\n// Second call with similar input: L1 hit → cached outcome returned, no agent run\nconst result = await cachedAgent({ question: 'cancel my flight', userId: 'u1' })\n```\n\n## Storage shorthands\n\n- `'memory'` → in-process HNSW + Map (no persistence)\n- `'libsql:file:./traj.db'` → LibSQL with separate columns + opt-in HNSW persistence\n- `{ kind: 'libsql', url, authToken? }` → structured config\n- `{ kind: 'custom', store }` → bring your own `TrajectoryStore`\n\n## Documentation + benchmarks\n\n- Project overview: [github.com/kylemaa/agent-trace-cache](https://github.com/kylemaa/agent-trace-cache)\n- Methodology + headline numbers (69% hit rate, 90% precision, 62.7% L2 partial replay): see `blog/agent-trace-cache.md` in the repo\n\n## License\n\nMIT\n","readmeFilename":"README.md"}