{"_id":"@agentcave/otel","name":"@agentcave/otel","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@agentcave/otel","version":"0.0.1","description":"Vendor-neutral OpenTelemetry instrumentation for AI agents","keywords":["agents","ai","effect","observability","opentelemetry"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/agentcave/agentcave.git","directory":"packages/otel"},"type":"module","sideEffects":false,"publishConfig":{"access":"public"},"peerDependencies":{"effect":"4.0.0-rc.112"},"peerDependenciesMeta":{"effect":{"optional":true}},"exports":{".":{"types":"./model-request.d.ts","import":"./model-request.js"},"./cloudflare":{"types":"./cloudflare.d.ts","import":"./cloudflare.js"},"./http":{"types":"./http.d.ts","import":"./http.js"},"./json":{"types":"./json.d.ts","import":"./json.js"}},"_id":"@agentcave/otel@0.0.1","gitHead":"d52c9ff1be6e17e7f28a30602c2977a68ddcf637","bugs":{"url":"https://github.com/agentcave/agentcave/issues"},"homepage":"https://github.com/agentcave/agentcave#readme","_nodeVersion":"26.5.1","_npmVersion":"10.9.9","dist":{"integrity":"sha512-xVZhYrR3WHMSsHpM3gzpfAr4aX2AwpitF8AKcjqBUdz58NZYYwDMUTjyjYAhEn38nq8M1pAsahyPW7aMsiFedw==","shasum":"8b4c62daaad1b592f3e7f2893e6ed3ae8ec1ebc2","tarball":"https://registry.npmjs.org/@agentcave/otel/-/otel-0.0.1.tgz","fileCount":27,"unpackedSize":67462,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHCZMTAQlK04DwQPcd7wU/KPyovUlJXvD1l8+S2XPxGXAiA37nJfuIPPFrpToUROOX9umEA5K/ZbPIEHUWkvNjSVWg=="}]},"_npmUser":{"name":"crqr","email":"joao@crqr.com"},"directories":{},"maintainers":[{"name":"crqr","email":"joao@crqr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/otel_0.0.1_1788369201530_0.4205458203896191"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-02T17:13:21.374Z","0.0.1":"2026-09-02T17:13:21.664Z","modified":"2026-09-02T17:13:21.885Z"},"maintainers":[{"name":"crqr","email":"joao@crqr.com"}],"description":"Vendor-neutral OpenTelemetry instrumentation for AI agents","homepage":"https://github.com/agentcave/agentcave#readme","keywords":["agents","ai","effect","observability","opentelemetry"],"repository":{"type":"git","url":"git+https://github.com/agentcave/agentcave.git","directory":"packages/otel"},"bugs":{"url":"https://github.com/agentcave/agentcave/issues"},"license":"Apache-2.0","readme":"# `@agentcave/otel`\n\nOptional OpenTelemetry instrumentation for agent applications. The package emits ordinary OTel\nspans and remains independent of the backend that receives them.\n\n```sh\nnpm install @agentcave/otel\n```\n\n## Effect\n\n`withModelRequest` creates an exact identity for one model invocation and makes its span active for\nthe supplied Effect. Standard GenAI attributes are included only when supplied by the caller. Effect\napplications should install the optional `effect@4.0.0-rc.112` peer dependency.\n\n```ts\nimport { Effect } from 'effect';\nimport { withModelRequest } from '@agentcave/otel';\n\nconst program = Effect.gen(function* () {\n  return yield* withModelRequest(\n    {\n      conversationId: 'conversation_123',\n      operationName: 'chat',\n      providerName: 'openai',\n      requestModel: 'gpt-5',\n    },\n    ({ id }) => callModel({ correlationId: id }),\n  );\n});\n```\n\nApplications are responsible for configuring their normal Effect or OpenTelemetry exporter. No\nAgentCave-specific wire protocol is required.\n\n## Cloudflare Workers AI\n\nThe Cloudflare adapter instruments the public Workers AI binding. It creates a native Workers span\ninside the currently active framework span and adds the same identity to AI Gateway metadata.\n\n```ts\nimport { instrumentWorkersAI } from '@agentcave/otel/cloudflare';\n\nconst ai = instrumentWorkersAI(env.AI);\n```\n\nPass `ai` to any library that accepts a Workers AI binding, such as `workers-ai-provider`:\n\n```ts\nconst model = createWorkersAI({\n  binding: instrumentWorkersAI(env.AI),\n  gateway: {\n    id: 'default',\n    metadata: { agent: 'support', service: 'worker' },\n  },\n})('@cf/meta/llama');\n```\n\nEvery actual `AI.run()` invocation receives a new `agentcave.model_request.id`. The adapter never\nmutates caller-owned options or metadata. It rejects an existing reserved key or five occupied\nmetadata entries instead of silently losing identity. Readable-stream spans end on completion,\nfailure, or cancellation.\n\nCloudflare Workers tracing and AI Gateway OTEL export must both be enabled for cross-source\ncorrelation. Sampling can leave one side unavailable; consumers must keep that request unlinked\nrather than infer a relationship.\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md","_rev":"1-668670b94f8da068d64a08ce6e6e48a2"}