@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.
- package/README.md +52 -3
- package/dist/chunk-4QNEI7VZ.cjs +984 -0
- package/dist/{chunk-DCXOK7PX.cjs → chunk-5QZM5EVP.cjs} +8 -8
- package/dist/{chunk-O2IBZJOJ.cjs → chunk-6QXPHZEO.cjs} +4 -4
- package/dist/chunk-EZCNPWKM.js +984 -0
- package/dist/{chunk-7PRTTYWM.js → chunk-GABRGNAU.js} +1 -1
- package/dist/{chunk-GUKWVI53.js → chunk-GISL4K6Z.js} +27 -1
- package/dist/{chunk-RV7JIIDG.cjs → chunk-NF52RMLW.cjs} +27 -1
- package/dist/{chunk-42KYS2LU.js → chunk-ZGX52S4U.js} +2 -2
- package/dist/index.cjs +280 -966
- package/dist/index.js +238 -924
- package/dist/interrupt-36U5562Z.cjs +12 -0
- package/dist/{interrupt-UKJK5WOA.js → interrupt-6BSXUK3O.js} +2 -2
- package/dist/{mcp-FBTQYIOL.js → mcp-TTECBPGZ.js} +4 -3
- package/dist/{mcp-WHXEBLRI.cjs → mcp-UPBKSTB7.cjs} +19 -18
- package/dist/session.cjs +78 -0
- package/dist/session.js +78 -0
- package/dist/types/cjs/index.d.ts +2 -2
- package/dist/types/cjs/internal/error-type.d.ts +1 -0
- package/dist/types/cjs/internal/instrumentation/mcp/semantic-conventions.d.ts +1 -1
- package/dist/types/cjs/internal/instrumentation/typesafe.d.ts +0 -8
- package/dist/types/cjs/internal/log/emit.d.ts +8 -0
- package/dist/types/cjs/internal/log/logging.d.ts +2 -2
- package/dist/types/cjs/internal/semantic-conventions.d.ts +13 -0
- package/dist/types/cjs/internal/serialization.d.ts +2 -0
- package/dist/types/cjs/internal/trace/decision-call.d.ts +24 -0
- package/dist/types/cjs/internal/trace/index.d.ts +2 -0
- package/dist/types/cjs/internal/trace/session.d.ts +2 -1
- package/dist/types/cjs/session.d.ts +6 -0
- package/dist/types/esm/index.d.ts +2 -2
- package/dist/types/esm/internal/error-type.d.ts +1 -0
- package/dist/types/esm/internal/instrumentation/mcp/semantic-conventions.d.ts +1 -1
- package/dist/types/esm/internal/instrumentation/typesafe.d.ts +0 -8
- package/dist/types/esm/internal/log/emit.d.ts +8 -0
- package/dist/types/esm/internal/log/logging.d.ts +2 -2
- package/dist/types/esm/internal/semantic-conventions.d.ts +13 -0
- package/dist/types/esm/internal/serialization.d.ts +2 -0
- package/dist/types/esm/internal/trace/decision-call.d.ts +24 -0
- package/dist/types/esm/internal/trace/index.d.ts +2 -0
- package/dist/types/esm/internal/trace/session.d.ts +2 -1
- package/dist/types/esm/session.d.ts +6 -0
- package/package.json +29 -18
- 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
|
|
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 —
|
|
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:
|