{"_id":"@anjor-labs/sdk","name":"@anjor-labs/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@anjor-labs/sdk","version":"0.1.0","description":"JavaScript/TypeScript SDK for the Anjor observability platform","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts","test":"node --test src/__tests__/*.test.ts","typecheck":"tsc --noEmit"},"keywords":["observability","llm","agents","monitoring","anjor"],"author":{"name":"Anjor Labs"},"license":"MIT","devDependencies":{"@types/node":"^22.0.0","tsup":"^8.0.0","typescript":"^5.0.0"},"gitHead":"ebd97389cf3726eec0d6e48d846b0059a1fec133","_id":"@anjor-labs/sdk@0.1.0","_nodeVersion":"25.6.1","_npmVersion":"11.9.0","dist":{"integrity":"sha512-cg2a6EC713fj4Jo0llpHQF1mDWre1j5hXKfLbMQd0jpXQTVaX5LYhMBo+G+UHv/eIyoxUU1sUkD5/FzJO4s3Yw==","shasum":"6f87f6ca0f43626eaee431108fd5040afb2cf84d","tarball":"https://registry.npmjs.org/@anjor-labs/sdk/-/sdk-0.1.0.tgz","fileCount":10,"unpackedSize":35106,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCbIXk+H3pJWQCa5qxXH3W2ybjGEWIMfOh4eDoxY6+CMAIgJxuhAGLGAVFGrg0tgtlBKWwS7dCC0xKMyHhzr9Nr6tk="}]},"_npmUser":{"name":"anjistic","email":"anjistic@gmail.com"},"directories":{},"maintainers":[{"name":"anjistic","email":"anjistic@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1776434101045_0.1585842449597863"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-17T13:55:00.945Z","0.1.0":"2026-04-17T13:55:01.176Z","modified":"2026-04-17T13:55:01.793Z"},"maintainers":[{"name":"anjistic","email":"anjistic@gmail.com"}],"description":"JavaScript/TypeScript SDK for the Anjor observability platform","keywords":["observability","llm","agents","monitoring","anjor"],"author":{"name":"Anjor Labs"},"license":"MIT","readme":"# @anjor-labs/sdk\n\nJavaScript/TypeScript SDK for the [Anjor](https://github.com/anjor-labs/anjor) observability platform. Lets AI agents running in Node.js post tool-call and LLM-call events to the Anjor collector with zero overhead on the agent critical path.\n\n## Installation\n\n```bash\nnpm install @anjor-labs/sdk\n```\n\nRequires Node 18+ (uses the built-in `fetch` and `crypto` APIs — no runtime dependencies).\n\n## Prerequisites\n\nThe Anjor collector must be running locally before events will be stored:\n\n```bash\nanjor start --watch-transcripts\n# collector now listening at http://localhost:7843\n```\n\n## Quick start\n\n```typescript\nimport { anjor } from '@anjor-labs/sdk'\n\n// Create a client — each instance gets its own session + trace IDs\nconst client = anjor({\n  project: 'my-agent',\n  agentId:  'worker-1',\n})\n\n// --- Tracing a tool call ---------------------------------------------------\n// Wrap any async function. On success, a tool_call event is posted.\n// On failure, a tool_call event with status: 'error' is posted, then the\n// error is rethrown so your agent handles it normally.\n\nconst results = await client.traceTool(\n  'web_search',                         // tool name shown in the dashboard\n  () => mySearchFunction('query'),      // the actual call\n  { inputPayload: { query: 'hello' } }  // optional — logged as input\n)\n\n// --- Tracing an LLM call ---------------------------------------------------\n// Works with OpenAI and Anthropic response shapes out of the box.\n// Token usage is extracted automatically and stored.\n\nimport Anthropic from '@anthropic-ai/sdk'\nconst anthropic = new Anthropic()\n\nconst message = await client.traceCall(\n  'anthropic',                          // provider label shown in dashboard\n  () =>\n    anthropic.messages.create({\n      model: 'claude-opus-4-5',\n      max_tokens: 1024,\n      messages: [{ role: 'user', content: 'Hello!' }],\n    })\n)\n\n// Works the same way with OpenAI:\nimport OpenAI from 'openai'\nconst openai = new OpenAI()\n\nconst completion = await client.traceCall(\n  'openai',\n  () =>\n    openai.chat.completions.create({\n      model: 'gpt-4o',\n      messages: [{ role: 'user', content: 'Hello!' }],\n    })\n)\n```\n\n## Configuration\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `collectorUrl` | `string` | `\"http://localhost:7843\"` | URL of the running Anjor collector |\n| `project` | `string` | `\"\"` | Tag all events with this project name (shows in dashboard project filter) |\n| `agentId` | `string` | `\"default\"` | Identifier for this agent instance |\n\n## Fire-and-forget guarantee\n\n`@anjor-labs/sdk` **never throws into your agent code** as a result of observability work. If the collector is not running, if the network is unavailable, or if event serialisation fails, the error is silently swallowed. Your agent always gets back the result it expects from `traceTool` / `traceCall`.\n\nThis mirrors the `anjor.patch()` contract in the Python SDK.\n\n## Token extraction\n\n`traceCall` automatically detects the response shape and maps tokens to Anjor's fields:\n\n| Provider | Input field | Output field | Cache read | Cache write |\n|---|---|---|---|---|\n| OpenAI | `usage.prompt_tokens` | `usage.completion_tokens` | — | — |\n| Anthropic | `usage.input_tokens` | `usage.output_tokens` | `usage.cache_read_input_tokens` | `usage.cache_creation_input_tokens` |\n\n## TypeScript\n\nFull type definitions are included. The package is written in strict TypeScript and ships `.d.ts` files — no `@types/` package needed.\n\n```typescript\nimport type { AnjorConfig, ToolCallEvent, LLMCallEvent } from '@anjor-labs/sdk'\n```\n","readmeFilename":"README.md","_rev":"1-6a3ba3e5a1469adf572c2aae15bfb3ce"}