@brizz/sdk 0.1.57 → 0.1.59

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.
Files changed (43) hide show
  1. package/README.md +52 -3
  2. package/dist/chunk-4QNEI7VZ.cjs +984 -0
  3. package/dist/{chunk-DCXOK7PX.cjs → chunk-5QZM5EVP.cjs} +8 -8
  4. package/dist/{chunk-O2IBZJOJ.cjs → chunk-6QXPHZEO.cjs} +4 -4
  5. package/dist/chunk-EZCNPWKM.js +984 -0
  6. package/dist/{chunk-7PRTTYWM.js → chunk-GABRGNAU.js} +1 -1
  7. package/dist/{chunk-GUKWVI53.js → chunk-GISL4K6Z.js} +27 -1
  8. package/dist/{chunk-RV7JIIDG.cjs → chunk-NF52RMLW.cjs} +27 -1
  9. package/dist/{chunk-42KYS2LU.js → chunk-ZGX52S4U.js} +2 -2
  10. package/dist/index.cjs +280 -966
  11. package/dist/index.js +238 -924
  12. package/dist/interrupt-36U5562Z.cjs +12 -0
  13. package/dist/{interrupt-UKJK5WOA.js → interrupt-6BSXUK3O.js} +2 -2
  14. package/dist/{mcp-FBTQYIOL.js → mcp-TTECBPGZ.js} +4 -3
  15. package/dist/{mcp-WHXEBLRI.cjs → mcp-UPBKSTB7.cjs} +19 -18
  16. package/dist/session.cjs +78 -0
  17. package/dist/session.js +78 -0
  18. package/dist/types/cjs/index.d.ts +2 -2
  19. package/dist/types/cjs/internal/error-type.d.ts +1 -0
  20. package/dist/types/cjs/internal/instrumentation/mcp/semantic-conventions.d.ts +1 -1
  21. package/dist/types/cjs/internal/instrumentation/typesafe.d.ts +0 -8
  22. package/dist/types/cjs/internal/log/emit.d.ts +8 -0
  23. package/dist/types/cjs/internal/log/logging.d.ts +2 -2
  24. package/dist/types/cjs/internal/semantic-conventions.d.ts +13 -0
  25. package/dist/types/cjs/internal/serialization.d.ts +2 -0
  26. package/dist/types/cjs/internal/trace/decision-call.d.ts +24 -0
  27. package/dist/types/cjs/internal/trace/index.d.ts +2 -0
  28. package/dist/types/cjs/internal/trace/session.d.ts +2 -1
  29. package/dist/types/cjs/session.d.ts +6 -0
  30. package/dist/types/esm/index.d.ts +2 -2
  31. package/dist/types/esm/internal/error-type.d.ts +1 -0
  32. package/dist/types/esm/internal/instrumentation/mcp/semantic-conventions.d.ts +1 -1
  33. package/dist/types/esm/internal/instrumentation/typesafe.d.ts +0 -8
  34. package/dist/types/esm/internal/log/emit.d.ts +8 -0
  35. package/dist/types/esm/internal/log/logging.d.ts +2 -2
  36. package/dist/types/esm/internal/semantic-conventions.d.ts +13 -0
  37. package/dist/types/esm/internal/serialization.d.ts +2 -0
  38. package/dist/types/esm/internal/trace/decision-call.d.ts +24 -0
  39. package/dist/types/esm/internal/trace/index.d.ts +2 -0
  40. package/dist/types/esm/internal/trace/session.d.ts +2 -1
  41. package/dist/types/esm/session.d.ts +6 -0
  42. package/package.json +29 -18
  43. package/dist/interrupt-BYLSBXTV.cjs +0 -12
package/README.md CHANGED
@@ -360,8 +360,8 @@ addExternalLink('https://sentry.io/issues/456', { sessionId: 'session-123', link
360
360
 
361
361
  ### Session Title Generation
362
362
 
363
- If you use an LLM call to generate session titles, wrap it so those spans don't appear as part of
364
- the conversation:
363
+ If you use an LLM call to generate session titles, wrap it so its spans show as one "Title generated"
364
+ row instead of turns of the conversation:
365
365
 
366
366
  ```typescript
367
367
  import { startSession, startSessionTitle } from '@brizz/sdk';
@@ -369,7 +369,7 @@ import { startSession, startSessionTitle } from '@brizz/sdk';
369
369
  await startSession('session-123', async (session) => {
370
370
  const response = await openai.chat.completions.create({...});
371
371
 
372
- // Title generation — excluded from conversation view
372
+ // Title generation — shown as one row, not as turns
373
373
  await startSessionTitle(async (title) => {
374
374
  const t = await openai.chat.completions.create({
375
375
  model: 'gpt-4',
@@ -412,6 +412,17 @@ await startSession('session-123', async () => {
412
412
  getActiveSession(); // undefined
413
413
  ```
414
414
 
415
+ ### Lightweight Session Helpers
416
+
417
+ `@brizz/sdk/session` exports the session and context helpers without loading the rest of the SDK,
418
+ which keeps module-heavy setups such as Jest test suites fast and small:
419
+
420
+ ```typescript
421
+ import { callWithSessionId, getActiveSession } from '@brizz/sdk/session';
422
+ ```
423
+
424
+ Keep `Brizz.initialize()` on the main `@brizz/sdk` entry at startup. Nothing is sent until it runs.
425
+
415
426
  ### Function Wrapper Pattern
416
427
 
417
428
  For simpler cases where you just need to tag traces with a session ID:
@@ -558,6 +569,44 @@ await startSession(sessionId, async () => {
558
569
  });
559
570
  ```
560
571
 
572
+ ### Recording Classification Calls
573
+
574
+ When you call a classification model through your own HTTP code, wrap the call in `decisionCall` so it shows up in the conversation with its questions, answers, tokens and cost. The callback's return value is passed through, and an error it throws is recorded and rethrown:
575
+
576
+ ```typescript
577
+ import { decisionCall } from '@brizz/sdk';
578
+
579
+ const response = await decisionCall(
580
+ { provider: 'microsoft', model: 'microsoft-decision-1', state, questions },
581
+ async (call) => {
582
+ const r = await client.decide(state, questions);
583
+ call.setAnswers(r.answers);
584
+ call.setUsage({ inputTokens: r.usage.input, outputTokens: r.usage.output });
585
+ call.setCost(0.0001); // optional, USD
586
+ return r;
587
+ },
588
+ );
589
+ ```
590
+
591
+ `state` is a string or any JSON value; `questions` and answers are sent as you pass them. The optional `requestModel` is the model name you requested, when it differs from `model`. The call joins the current session and carries the current custom properties; to set them for one call, wrap it in `callWithSessionId` or `callWithProperties`.
592
+
593
+ To record a call that already happened, pass everything at once, with optional `startTime` / `endTime` (`Date`s):
594
+
595
+ ```typescript
596
+ import { recordDecisionCall } from '@brizz/sdk';
597
+
598
+ recordDecisionCall({
599
+ provider: 'microsoft',
600
+ model: 'microsoft-decision-1',
601
+ state,
602
+ questions,
603
+ answers: r.answers,
604
+ inputTokens: 555,
605
+ outputTokens: 6,
606
+ startTime: startedAt,
607
+ });
608
+ ```
609
+
561
610
  ### Custom Properties
562
611
 
563
612
  Add custom properties to telemetry context: