{"_id":"@coopah/bentley-langfuse","_rev":"4-b7b364545fb08bedaaf20b0030d67d75","name":"@coopah/bentley-langfuse","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@coopah/bentley-langfuse","version":"0.2.0","keywords":["ai","agent","llm","bentley"],"license":"MIT","_id":"@coopah/bentley-langfuse@0.2.0","maintainers":[{"name":"coopah","email":"tibo6c04@gmail.com"}],"homepage":"https://github.com/CoopahG/bentley#readme","bugs":{"url":"https://github.com/CoopahG/bentley/issues"},"dist":{"shasum":"fcd7db6b3e22f344b8a6d0f556e728603851ddd5","tarball":"https://registry.npmjs.org/@coopah/bentley-langfuse/-/bentley-langfuse-0.2.0.tgz","fileCount":38,"integrity":"sha512-R8KaepcySalFIEtuBbo0ExZJxvCU4VaPA6KFvk4WnowRyBi03ZFFLTQpZa5PSoXbLs/H73pMfb5e0/j+P/WX+Q==","signatures":[{"sig":"MEYCIQDH0g/RiwM18LaCXs39fBJFpZczoWiSl9VBpcsPMoEdkQIhAOROCNsbR+nEIX3A4KQ4AQfwNdUi9t4GLymTyNj4uTXh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24822},"main":"dist/index.js","type":"module","_from":"file:coopah-bentley-langfuse-0.2.0.tgz","types":"dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"coopah","email":"tibo6c04@gmail.com"},"_resolved":"/private/var/folders/k4/9fdyr38j4gv59whg5k3w4fgm0000gn/T/5c5da7b378c473f905607217b4d5cbd6/coopah-bentley-langfuse-0.2.0.tgz","_integrity":"sha512-R8KaepcySalFIEtuBbo0ExZJxvCU4VaPA6KFvk4WnowRyBi03ZFFLTQpZa5PSoXbLs/H73pMfb5e0/j+P/WX+Q==","repository":{"url":"git+https://github.com/CoopahG/bentley.git","type":"git","directory":"packages/langfuse"},"_npmVersion":"10.9.4","description":"LangFuse observability integration via OpenTelemetry","directories":{},"_nodeVersion":"22.22.0","dependencies":{"langfuse":"^3.38.6","@langfuse/otel":"^4.6.1","@langfuse/client":"^4.6.1","@opentelemetry/api":"^1.9.0","@coopah/bentley-core":"0.2.0","@opentelemetry/sdk-node":"^0.213.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.3.5"},"_npmOperationalInternal":{"tmp":"tmp/bentley-langfuse_0.2.0_1773093157747_0.5308758758811709","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@coopah/bentley-langfuse","version":"0.2.1","keywords":["ai","agent","llm","bentley"],"license":"MIT","_id":"@coopah/bentley-langfuse@0.2.1","maintainers":[{"name":"coopah","email":"tibo6c04@gmail.com"}],"homepage":"https://github.com/CoopahG/bentley#readme","bugs":{"url":"https://github.com/CoopahG/bentley/issues"},"dist":{"shasum":"4857933dfa776149c06798a1dd5e134758898a24","tarball":"https://registry.npmjs.org/@coopah/bentley-langfuse/-/bentley-langfuse-0.2.1.tgz","fileCount":39,"integrity":"sha512-++jN4SILgl7OPin3ErMAmjImx+SevwjTN/hu5kQl/AQLkHY3A5kXr7uWCywEvlvgPfzGfPILfOoLkx47NTZ6IQ==","signatures":[{"sig":"MEUCIQD5xJHNgW61TaLHDzNVhCvEWnf3A2ZeX40fqp8dkHeDQwIgWHF9SM0TpvTmzzNigg/AGZUBVXx4GhPUizw3NLgYdYk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26128},"main":"dist/index.js","type":"module","_from":"file:coopah-bentley-langfuse-0.2.1.tgz","types":"dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"coopah","email":"tibo6c04@gmail.com"},"_resolved":"/private/var/folders/k4/9fdyr38j4gv59whg5k3w4fgm0000gn/T/cf8d9376c91a35ed54b785690cc7208f/coopah-bentley-langfuse-0.2.1.tgz","_integrity":"sha512-++jN4SILgl7OPin3ErMAmjImx+SevwjTN/hu5kQl/AQLkHY3A5kXr7uWCywEvlvgPfzGfPILfOoLkx47NTZ6IQ==","repository":{"url":"git+https://github.com/CoopahG/bentley.git","type":"git","directory":"packages/langfuse"},"_npmVersion":"10.9.4","description":"LangFuse observability integration via OpenTelemetry","directories":{},"_nodeVersion":"22.22.0","dependencies":{"langfuse":"^3.38.6","@langfuse/otel":"^4.6.1","@langfuse/client":"^4.6.1","@opentelemetry/api":"^1.9.0","@coopah/bentley-core":"0.2.1","@opentelemetry/sdk-node":"^0.213.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.3.5"},"_npmOperationalInternal":{"tmp":"tmp/bentley-langfuse_0.2.1_1773093586657_0.1283163137174339","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@coopah/bentley-langfuse","version":"0.2.2","keywords":["ai","agent","llm","bentley"],"license":"MIT","_id":"@coopah/bentley-langfuse@0.2.2","maintainers":[{"name":"coopah","email":"tibo6c04@gmail.com"}],"homepage":"https://github.com/CoopahG/bentley#readme","bugs":{"url":"https://github.com/CoopahG/bentley/issues"},"dist":{"shasum":"3887317ab9cae218579a2be751b9f5ae4d226c29","tarball":"https://registry.npmjs.org/@coopah/bentley-langfuse/-/bentley-langfuse-0.2.2.tgz","fileCount":39,"integrity":"sha512-z7epXBUn3YxXt4kkDz0zsX669sjP1a9yJs0RhBs4VkwDbrc1F4/76nFBF3Xb1rDtd313tkFgGg1KaeZQaJOC7g==","signatures":[{"sig":"MEUCIQDcCwQmDVkzEJfzMG2NvMtzMwXFpfYcZk0uhKFFvdB02AIgGG/fp4+I5/qG7EqX5ddzV8ExOWHpBdH9rqKx8sisRr0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27890},"main":"dist/index.js","type":"module","_from":"file:coopah-bentley-langfuse-0.2.2.tgz","types":"dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","lint":"eslint src","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"coopah","email":"tibo6c04@gmail.com"},"_resolved":"/private/var/folders/k4/9fdyr38j4gv59whg5k3w4fgm0000gn/T/4af082dfe05ad3bbbbb21f688e9d297d/coopah-bentley-langfuse-0.2.2.tgz","_integrity":"sha512-z7epXBUn3YxXt4kkDz0zsX669sjP1a9yJs0RhBs4VkwDbrc1F4/76nFBF3Xb1rDtd313tkFgGg1KaeZQaJOC7g==","repository":{"url":"git+https://github.com/CoopahG/bentley.git","type":"git","directory":"packages/langfuse"},"_npmVersion":"10.9.4","description":"LangFuse observability integration via OpenTelemetry","directories":{},"_nodeVersion":"22.22.0","dependencies":{"langfuse":"^3.38.6","@langfuse/otel":"^4.6.1","@langfuse/client":"^4.6.1","@opentelemetry/api":"^1.9.0","@coopah/bentley-core":"0.2.2","@opentelemetry/sdk-node":"^0.213.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.3.5"},"_npmOperationalInternal":{"tmp":"tmp/bentley-langfuse_0.2.2_1773093910854_0.6316258638371399","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@coopah/bentley-langfuse","version":"0.3.0","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"dependencies":{"@langfuse/client":"^5.0.0","@langfuse/otel":"^5.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/sdk-node":"^0.213.0","@coopah/bentley-core":"0.3.0"},"devDependencies":{"@types/node":"^25.4.0","typescript":"^5.9.3"},"description":"LangFuse observability integration via OpenTelemetry","license":"MIT","repository":{"type":"git","url":"git+https://github.com/CoopahG/bentley.git","directory":"packages/langfuse"},"engines":{"node":">=20.0.0"},"keywords":["ai","agent","llm","bentley"],"scripts":{"build":"tsc","dev":"tsc --watch","lint":"eslint src","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@coopah/bentley-langfuse@0.3.0","bugs":{"url":"https://github.com/CoopahG/bentley/issues"},"homepage":"https://github.com/CoopahG/bentley#readme","_integrity":"sha512-TSCXW+rUPtg06e6vCCA4MEaE5oauj9mAgsXZ4MnYfBBex8CYbfw+6PSrMIjSEb4fu2+oHKS1OxexwuVAlJMvrg==","_resolved":"/private/var/folders/k4/9fdyr38j4gv59whg5k3w4fgm0000gn/T/733357942c148393bcd99b93e35c1df1/coopah-bentley-langfuse-0.3.0.tgz","_from":"file:coopah-bentley-langfuse-0.3.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-TSCXW+rUPtg06e6vCCA4MEaE5oauj9mAgsXZ4MnYfBBex8CYbfw+6PSrMIjSEb4fu2+oHKS1OxexwuVAlJMvrg==","shasum":"95e7ec6a519be808146856230f2ac57706d97089","tarball":"https://registry.npmjs.org/@coopah/bentley-langfuse/-/bentley-langfuse-0.3.0.tgz","fileCount":39,"unpackedSize":27863,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCK/GUMFu3HiaHcMnCo/QrqtrUfchlYfL7n4t5CaMGZvAIhANNhVCUfzT3VhclX/gEKIyAMdYnldLF0ThNK8Nq+wv2K"}]},"_npmUser":{"name":"coopah","email":"tibo6c04@gmail.com"},"directories":{},"maintainers":[{"name":"coopah","email":"tibo6c04@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bentley-langfuse_0.3.0_1773178075675_0.981753301731233"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-09T21:52:37.633Z","modified":"2026-03-10T21:27:55.972Z","0.2.0":"2026-03-09T21:52:37.886Z","0.2.1":"2026-03-09T21:59:46.807Z","0.2.2":"2026-03-09T22:05:11.155Z","0.3.0":"2026-03-10T21:27:55.839Z"},"bugs":{"url":"https://github.com/CoopahG/bentley/issues"},"license":"MIT","homepage":"https://github.com/CoopahG/bentley#readme","keywords":["ai","agent","llm","bentley"],"repository":{"type":"git","url":"git+https://github.com/CoopahG/bentley.git","directory":"packages/langfuse"},"description":"LangFuse observability integration via OpenTelemetry","maintainers":[{"name":"coopah","email":"tibo6c04@gmail.com"}],"readme":"# @coopah/bentley-langfuse\n\n[LangFuse](https://langfuse.com) observability integration for [Bentley](https://github.com/CoopahG/bentley), built on OpenTelemetry. Traces agent invocations, scores runs, manages prompt versions, and runs evaluation experiments.\n\n> Uses `@langfuse/otel` + `@langfuse/client` (the modern OTel-based API), **not** the deprecated v3 `Langfuse` class.\n\n## Install\n\n```bash\npnpm add @coopah/bentley-langfuse\n```\n\n### Dependencies\n\n- [`@coopah/bentley-core`](https://www.npmjs.com/package/@coopah/bentley-core)\n- `@langfuse/client` ^4.6.1\n- `@langfuse/otel` ^4.6.1\n- `@opentelemetry/api` ^1.9.0\n- `@opentelemetry/sdk-node` ^0.213.0\n\n## Usage\n\n```ts\nimport { initBentleyTracing, shutdownBentleyTracing } from \"@coopah/bentley-langfuse\";\n\n// Initialize before creating your Bentley instance\ninitBentleyTracing({\n  publicKey: process.env.LANGFUSE_PUBLIC_KEY!,\n  secretKey: process.env.LANGFUSE_SECRET_KEY!,\n  baseUrl: process.env.LANGFUSE_BASE_URL, // optional, defaults to LangFuse cloud\n});\n\n// ... use bentley ...\n\n// On shutdown\nawait shutdownBentleyTracing();\n```\n\n### Tracing Middleware\n\n```ts\nimport { bentleyTracingMiddleware } from \"@coopah/bentley-langfuse\";\n\n// Add to your shell middleware pipeline for automatic span collection\nconst bentley = createBentley({\n  plugins: [/* ... */],\n  middleware: [bentleyTracingMiddleware],\n});\n```\n\n### Traced Functions\n\n```ts\nimport { bentleyTraced } from \"@coopah/bentley-langfuse\";\n\nconst myFunction = bentleyTraced(async () => {\n  // This function call is wrapped in a trace span\n  return await doExpensiveWork();\n});\n```\n\n## API\n\n### Setup\n\n- **`initBentleyTracing(config: BentleyLangfuseConfig)`** — Initialize OTel + LangFuse\n- **`shutdownBentleyTracing()`** — Flush pending spans and shut down\n- **`getSpanProcessor()`** — Access the raw OTel span processor\n\n### Tracing\n\n- **`bentleyTracingMiddleware`** — Shell middleware for automatic tracing\n- **`bentleyTraced(fn)`** — Wrap any async function with a trace span\n\n### Prompts\n\n- **`BentleyPromptManager`** — Manage and compile versioned LangFuse prompts\n\n### Scoring & Cost\n\n- **`BentleyScoringService`** — Score agent runs programmatically\n- **`bentleyAutoScoringMiddleware`** — Automatic scoring middleware\n- **`calculateCost(model, usage)`** — Token cost calculation\n- **`MODEL_COSTS`** — Cost-per-token constants for supported models\n\n### Experiments\n\n- **`BentleyExperimentRunner`** — Run A/B evaluation experiments\n- **`BentleyExperimentEvaluator`** — Custom evaluator interface\n\n### Configuration\n\n```ts\ninterface BentleyLangfuseConfig {\n  publicKey: string;\n  secretKey: string;\n  baseUrl?: string;       // LangFuse endpoint\n  environment?: string;\n  exportMode?: \"batched\" | \"immediate\";\n}\n```\n\n## Related Packages\n\n| Package | Role |\n|---------|------|\n| [`@coopah/bentley-core`](https://www.npmjs.com/package/@coopah/bentley-core) | Core runtime (required) |\n| [`@coopah/bentley-server`](https://www.npmjs.com/package/@coopah/bentley-server) | Server with built-in LangFuse support |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}