@brizz/sdk 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,7 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
18
18
  - [Supported Libraries](#supported-libraries)
19
19
  - [PII Masking](#pii-masking)
20
20
  - [Session Tracking](#session-tracking)
21
+ - [Mute Messages](#mute-messages)
21
22
  - [Custom Events & Logging](#custom-events--logging)
22
23
  - [Environment Variables](#environment-variables)
23
24
  - [Disable Span Export](#disable-span-export)
@@ -199,6 +200,7 @@ pulled in when you need them. Install the matching package(s) to enable them:
199
200
 
200
201
  | To trace | Install |
201
202
  | --- | --- |
203
+ | **Vercel AI SDK v7+** (`ai@7`) — required for span capture | `npm install @ai-sdk/otel` |
202
204
  | **Google Vertex AI** (`@google-cloud/vertexai`) | `npm install @traceloop/instrumentation-vertexai` |
203
205
  | **MCP** (Model Context Protocol) | `npm install @arizeai/openinference-instrumentation-mcp @modelcontextprotocol/sdk` |
204
206
 
@@ -209,6 +211,10 @@ so the misconfiguration is visible.
209
211
 
210
212
  ### Vercel AI SDK Integration
211
213
 
214
+ On `ai@7` and newer, also install `@ai-sdk/otel` — v7 moved AI SDK span collection
215
+ into that package, so without it your `generateText` / `streamText` calls produce no
216
+ spans. It isn't needed on `ai@6`.
217
+
212
218
  For Vercel AI SDK instrumentation, you need to enable telemetry in your function calls:
213
219
 
214
220
  ```typescript
@@ -237,6 +243,47 @@ This enables automatic tracing of:
237
243
  - Tool calls and executions
238
244
  - Streaming data
239
245
 
246
+ ### Vercel eve
247
+
248
+ [Vercel `eve`](https://eve.dev) agents emit standard OpenTelemetry GenAI spans, so Brizz ingests
249
+ their traces, message content, and cost as soon as you point eve's exporter at your Brizz endpoint.
250
+ `@brizz/sdk/eve` gives you a one-line `registerOTel` config that reads `BRIZZ_DSN` — it wires the
251
+ exporter and the session grouping that makes each agent run render as a single conversation:
252
+
253
+ ```typescript
254
+ // agent/instrumentation.ts
255
+ import { defineInstrumentation } from 'eve/instrumentation';
256
+ import { registerOTel } from '@vercel/otel';
257
+ import { createEveOtelConfig } from '@brizz/sdk/eve';
258
+
259
+ export default defineInstrumentation({
260
+ setup: ({ agentName }) => registerOTel(createEveOtelConfig({ serviceName: agentName })),
261
+ });
262
+ ```
263
+
264
+ Then set your DSN in the environment — a single pasted credential:
265
+
266
+ ```bash
267
+ BRIZZ_DSN=https://<bearer>@<gateway-host>/<service-name>
268
+ ```
269
+
270
+ `createEveOtelConfig` derives the bearer and endpoint from the DSN and ignores its service segment —
271
+ eve's `agentName` stays the service name. Prefer to compose it yourself? The pieces are exported too:
272
+
273
+ ```typescript
274
+ import { createEveTraceExporter, createEveSessionProcessor } from '@brizz/sdk/eve';
275
+
276
+ registerOTel({
277
+ serviceName: agentName,
278
+ traceExporter: createEveTraceExporter(),
279
+ // 'auto' keeps the default exporter processor.
280
+ spanProcessors: [createEveSessionProcessor(), 'auto'],
281
+ });
282
+ ```
283
+
284
+ `@brizz/sdk/eve` is a standalone, side-effect-free export: it does not initialize the full SDK, so
285
+ it won't duplicate the spans eve already emits.
286
+
240
287
  ## PII Masking
241
288
 
242
289
  Optional masking for span attributes.
@@ -507,6 +554,23 @@ const sessionedProcess = withSessionId(
507
554
  **Note:** The arrow function approach (Option 1) is recommended as it's more explicit, avoids lint
508
555
  warnings, and is less prone to `this` binding issues.
509
556
 
557
+ ## Mute Messages
558
+
559
+ Keep internal or unrelated LLM calls — summarization, title generation, classification, guardrail checks — out of the captured conversation. The call still runs and its telemetry (latency, tokens, cost) is recorded; only the user and/or assistant content is left out.
560
+
561
+ ```typescript
562
+ import { callWithMute, withMute } from '@brizz/sdk';
563
+
564
+ // Hide both sides of an internal call
565
+ await callWithMute({}, () => agent.run('Summarize this conversation for internal logging.'));
566
+
567
+ // Keep the assistant reply, drop the prompt
568
+ await callWithMute({ output: false }, () => agent.run('…a long internal prompt…'));
569
+
570
+ // Pre-wrap a function to reuse the same muting
571
+ const muteTitle = withMute({}, agent.run, agent);
572
+ ```
573
+
510
574
  ## Deployment Environment
511
575
 
512
576
  Optionally specify the deployment environment for better filtering and organization:
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
@@ -0,0 +1,8 @@
1
+ // src/internal/version.ts
2
+ function getSDKVersion() {
3
+ return "0.1.32";
4
+ }
5
+
6
+ export {
7
+ getSDKVersion
8
+ };
@@ -0,0 +1,36 @@
1
+ // src/internal/dsn.ts
2
+ var PLACEHOLDER_SERVICE = "<service-name>";
3
+ var SERVICE_NAME_HEADER = "X-Brizz-Service-Name";
4
+ function parseDSN(dsn, options = {}) {
5
+ let parsed;
6
+ try {
7
+ parsed = new globalThis.URL(dsn);
8
+ } catch {
9
+ return null;
10
+ }
11
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:" || !parsed.username || !parsed.host) {
12
+ return null;
13
+ }
14
+ const scheme = parsed.protocol === "https:" ? "https" : "http";
15
+ let service;
16
+ try {
17
+ service = decodeURIComponent(parsed.pathname.replace(/^\//, ""));
18
+ } catch {
19
+ return null;
20
+ }
21
+ if (!options.allowPlaceholderService && (service === "" || service === PLACEHOLDER_SERVICE)) {
22
+ return null;
23
+ }
24
+ return {
25
+ scheme,
26
+ host: parsed.host,
27
+ bearer: decodeURIComponent(parsed.username),
28
+ service,
29
+ baseUrl: `${scheme}://${parsed.host}`
30
+ };
31
+ }
32
+
33
+ export {
34
+ SERVICE_NAME_HEADER,
35
+ parseDSN
36
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkGCORRK6Bcjs = require('./chunk-GCORRK6B.cjs');
3
+ var _chunkOZCOXBB7cjs = require('./chunk-OZCOXBB7.cjs');
4
4
 
5
5
  // src/internal/instrumentation/vercel-ai/interrupt.ts
6
6
  var _api = require('@opentelemetry/api');
@@ -17,6 +17,8 @@ function isInnerLLMSpan(span) {
17
17
  }
18
18
  var MAX_PENDING_ENTRIES = 1024;
19
19
  var pendingByParentSpanId = /* @__PURE__ */ new Map();
20
+ var needsApprovalToolNames = /* @__PURE__ */ new Set();
21
+ var versionState = { sawActiveSpan: false };
20
22
  function setPending(parentSpanId, value) {
21
23
  pendingByParentSpanId.set(parentSpanId, value);
22
24
  while (pendingByParentSpanId.size > MAX_PENDING_ENTRIES) {
@@ -35,21 +37,52 @@ function extractInterruptTools(tools) {
35
37
  ([, t]) => !!t && typeof t === "object" && t.needsApproval
36
38
  ).map(([name]) => name);
37
39
  }
40
+ function parsePromptToolNames(raw) {
41
+ if (!Array.isArray(raw)) {
42
+ return null;
43
+ }
44
+ const names = [];
45
+ for (const element of raw) {
46
+ if (typeof element !== "string") {
47
+ continue;
48
+ }
49
+ try {
50
+ const parsed = JSON.parse(element);
51
+ if (parsed && typeof parsed.name === "string") {
52
+ names.push(parsed.name);
53
+ }
54
+ } catch (e) {
55
+ }
56
+ }
57
+ return names.length > 0 ? names : null;
58
+ }
38
59
  function createInterruptIntegration() {
60
+ const onStart = (event) => {
61
+ for (const name of extractInterruptTools(event.tools)) {
62
+ needsApprovalToolNames.add(name);
63
+ }
64
+ };
39
65
  const onStepStart = (event) => {
66
+ const span = _api.trace.getActiveSpan();
67
+ if (span) {
68
+ versionState.sawActiveSpan = true;
69
+ }
40
70
  const names = extractInterruptTools(event.tools);
41
71
  if (names.length === 0) {
42
72
  return;
43
73
  }
44
- const value = JSON.stringify(names);
45
- const span = _api.trace.getActiveSpan();
74
+ for (const name of names) {
75
+ needsApprovalToolNames.add(name);
76
+ }
46
77
  if (!span) {
47
78
  return;
48
79
  }
49
- span.setAttribute(_chunkGCORRK6Bcjs.INTERRUPT_TOOLS, value);
80
+ const value = JSON.stringify(names);
81
+ span.setAttribute(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, value);
50
82
  setPending(span.spanContext().spanId, value);
51
83
  };
52
84
  return {
85
+ onStart,
53
86
  onStepStart
54
87
  };
55
88
  }
@@ -59,15 +92,20 @@ var InterruptPropagator = class {
59
92
  return;
60
93
  }
61
94
  const parentSpanId = _optionalChain([span, 'access', _ => _.parentSpanContext, 'optionalAccess', _2 => _2.spanId]);
62
- if (!parentSpanId) {
95
+ const stashed = parentSpanId && pendingByParentSpanId.get(parentSpanId);
96
+ if (stashed) {
97
+ span.setAttribute(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, stashed);
98
+ pendingByParentSpanId.delete(parentSpanId);
63
99
  return;
64
100
  }
65
- const value = pendingByParentSpanId.get(parentSpanId);
66
- if (!value) {
101
+ if (versionState.sawActiveSpan || needsApprovalToolNames.size === 0) {
67
102
  return;
68
103
  }
69
- span.setAttribute(_chunkGCORRK6Bcjs.INTERRUPT_TOOLS, value);
70
- pendingByParentSpanId.delete(parentSpanId);
104
+ const scoped = parsePromptToolNames(span.attributes["ai.prompt.tools"]);
105
+ const names = scoped === null ? [...needsApprovalToolNames] : scoped.filter((n) => needsApprovalToolNames.has(n));
106
+ if (names.length > 0) {
107
+ span.setAttribute(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, JSON.stringify(names));
108
+ }
71
109
  }
72
110
  onEnd() {
73
111
  }
@@ -81,6 +119,8 @@ function _resetInterruptState() {
81
119
  return;
82
120
  }
83
121
  pendingByParentSpanId.clear();
122
+ needsApprovalToolNames.clear();
123
+ versionState.sawActiveSpan = false;
84
124
  }
85
125
 
86
126