@brizz/sdk 0.1.52 → 0.1.54
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 +38 -0
- package/dist/chunk-DBN4NKIG.js +107 -0
- package/dist/{chunk-KFETJN5M.cjs → chunk-FQBVTIBR.cjs} +7 -0
- package/dist/{chunk-2T7OEV33.cjs → chunk-KGNFUQ6Z.cjs} +1 -1
- package/dist/{chunk-W7VSQ4KQ.js → chunk-MLMF2O5P.js} +1 -1
- package/dist/chunk-VZJNEST4.cjs +107 -0
- package/dist/{chunk-TEY6FAVZ.js → chunk-YGLDHCWC.js} +7 -0
- package/dist/google-genai-44O4QORJ.cjs +11 -0
- package/dist/{google-genai-T7I4FFIP.js → google-genai-PERR37LR.js} +2 -1
- package/dist/google-genai.cjs +3 -2
- package/dist/google-genai.js +2 -1
- package/dist/index.cjs +510 -107
- package/dist/index.js +486 -83
- package/dist/{mcp-MVZSP5NE.cjs → mcp-4M4XL46N.cjs} +39 -16
- package/dist/{mcp-TOZFTC5Y.js → mcp-KU7MFTOB.js} +29 -6
- package/dist/types/cjs/index.d.ts +1 -1
- package/dist/types/cjs/internal/config.d.ts +1 -0
- package/dist/types/cjs/internal/instrumentation/openai.d.ts +5 -0
- package/dist/types/cjs/internal/instrumentation/registry.d.ts +1 -0
- package/dist/types/cjs/internal/instrumentation/typesafe.d.ts +34 -0
- package/dist/types/cjs/internal/log/logging.d.ts +1 -0
- package/dist/types/cjs/internal/metric/metrics.d.ts +1 -0
- package/dist/types/cjs/internal/sdk.d.ts +3 -0
- package/dist/types/cjs/internal/trace/index.d.ts +1 -0
- package/dist/types/cjs/internal/trace/provider.d.ts +15 -0
- package/dist/types/cjs/internal/trace/tracing.d.ts +1 -0
- package/dist/types/esm/index.d.ts +1 -1
- package/dist/types/esm/internal/config.d.ts +1 -0
- package/dist/types/esm/internal/instrumentation/openai.d.ts +5 -0
- package/dist/types/esm/internal/instrumentation/registry.d.ts +1 -0
- package/dist/types/esm/internal/instrumentation/typesafe.d.ts +34 -0
- package/dist/types/esm/internal/log/logging.d.ts +1 -0
- package/dist/types/esm/internal/metric/metrics.d.ts +1 -0
- package/dist/types/esm/internal/sdk.d.ts +3 -0
- package/dist/types/esm/internal/trace/index.d.ts +1 -0
- package/dist/types/esm/internal/trace/provider.d.ts +15 -0
- package/dist/types/esm/internal/trace/tracing.d.ts +1 -0
- package/package.json +22 -15
- package/dist/google-genai-LMEZ62FB.cjs +0 -10
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkKGNFUQ6Zcjs = require('./chunk-KGNFUQ6Z.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunkVZJNEST4cjs = require('./chunk-VZJNEST4.cjs');
|
|
12
18
|
|
|
13
19
|
|
|
14
20
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
@@ -17,11 +23,10 @@ require('./chunk-OBGZSXTJ.cjs');
|
|
|
17
23
|
|
|
18
24
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
19
25
|
var _openinferenceinstrumentationmcp = require('@arizeai/openinference-instrumentation-mcp');
|
|
20
|
-
var _api = require('@opentelemetry/api');
|
|
21
26
|
var _instrumentation = require('@opentelemetry/instrumentation');
|
|
22
27
|
|
|
23
28
|
// src/internal/instrumentation/mcp/patches/protocol.ts
|
|
24
|
-
|
|
29
|
+
var _api = require('@opentelemetry/api');
|
|
25
30
|
|
|
26
31
|
// src/internal/instrumentation/mcp/schemas.ts
|
|
27
32
|
|
|
@@ -372,10 +377,27 @@ function wrapRequest(original, tracer) {
|
|
|
372
377
|
}
|
|
373
378
|
return executeAroundSpan(span, request.method, () => {
|
|
374
379
|
const ctx = _api.trace.setSpan(_api.context.active(), span);
|
|
375
|
-
return _api.context.with(ctx, () =>
|
|
380
|
+
return _api.context.with(ctx, () => {
|
|
381
|
+
injectMetaTraceContext(request, ctx);
|
|
382
|
+
return original.apply(this, args);
|
|
383
|
+
});
|
|
376
384
|
});
|
|
377
385
|
};
|
|
378
386
|
}
|
|
387
|
+
function injectMetaTraceContext(request, ctx) {
|
|
388
|
+
if (!_chunkVZJNEST4cjs.isPrivateTracerProvider.call(void 0, )) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
request.params ??= {};
|
|
393
|
+
request.params._meta ??= {};
|
|
394
|
+
if (request.params._meta["traceparent"] === void 0) {
|
|
395
|
+
_chunkVZJNEST4cjs.injectTraceContext.call(void 0, ctx, request.params._meta);
|
|
396
|
+
}
|
|
397
|
+
} catch (error) {
|
|
398
|
+
_chunkWC573FCIcjs.logger.debug(`Brizz MCP: failed to inject trace context into _meta: ${String(error)}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
379
401
|
function wrapOnRequest(original, tracer) {
|
|
380
402
|
return function wrappedOnRequest(...args) {
|
|
381
403
|
const request = args[0];
|
|
@@ -387,14 +409,14 @@ function wrapOnRequest(original, tracer) {
|
|
|
387
409
|
return original.apply(this, args);
|
|
388
410
|
}
|
|
389
411
|
const method = request.method;
|
|
390
|
-
if (method === METHOD_TOOLS_CALL &&
|
|
412
|
+
if (method === METHOD_TOOLS_CALL && _chunkKGNFUQ6Zcjs.isSessionToolCall.call(void 0, request)) {
|
|
391
413
|
return answerSessionToolCall(this, request, tracer, args, original);
|
|
392
414
|
}
|
|
393
415
|
const handler = _nullishCoalesce(handlers.get(method), () => ( this.fallbackRequestHandler));
|
|
394
416
|
if (!handler) {
|
|
395
417
|
return original.apply(this, args);
|
|
396
418
|
}
|
|
397
|
-
const tracking =
|
|
419
|
+
const tracking = _chunkKGNFUQ6Zcjs.isEnabled.call(void 0, ) && method === METHOD_TOOLS_CALL ? _chunkKGNFUQ6Zcjs.popTrackingArguments.call(void 0, request) : {};
|
|
398
420
|
const started = safeStartServerSpan(tracer, request, this, tracking);
|
|
399
421
|
if (!started) {
|
|
400
422
|
return original.apply(this, args);
|
|
@@ -404,9 +426,9 @@ function wrapOnRequest(original, tracer) {
|
|
|
404
426
|
if (method === METHOD_TOOLS_LIST) {
|
|
405
427
|
hooks.onResult = (result) => {
|
|
406
428
|
let advertised = result;
|
|
407
|
-
if (
|
|
429
|
+
if (_chunkKGNFUQ6Zcjs.isEnabled.call(void 0, )) {
|
|
408
430
|
try {
|
|
409
|
-
advertised =
|
|
431
|
+
advertised = _chunkKGNFUQ6Zcjs.patchListToolsResult.call(void 0, result);
|
|
410
432
|
} catch (error) {
|
|
411
433
|
_chunkWC573FCIcjs.logger.warn(
|
|
412
434
|
`Brizz MCP: failed to patch tools/list schemas: ${String(error)}`
|
|
@@ -417,7 +439,7 @@ function wrapOnRequest(original, tracer) {
|
|
|
417
439
|
try {
|
|
418
440
|
emitSchemaSpansFromListResponse(
|
|
419
441
|
advertised,
|
|
420
|
-
|
|
442
|
+
_chunkKGNFUQ6Zcjs.resolveTransportSessionId.call(void 0, this),
|
|
421
443
|
tracer
|
|
422
444
|
);
|
|
423
445
|
} catch (error) {
|
|
@@ -430,7 +452,7 @@ function wrapOnRequest(original, tracer) {
|
|
|
430
452
|
}
|
|
431
453
|
if (method !== METHOD_TOOLS_CALL) {
|
|
432
454
|
hooks.onError = () => {
|
|
433
|
-
|
|
455
|
+
_chunkKGNFUQ6Zcjs.stampAndPropagateSession.call(void 0, span, _chunkKGNFUQ6Zcjs.resolveSessionId.call(void 0, this, spanCtx), spanCtx);
|
|
434
456
|
};
|
|
435
457
|
}
|
|
436
458
|
const wrappedHandler = (req, extra) => _api.context.with(
|
|
@@ -464,7 +486,7 @@ function answerSessionToolCall(protocol, request, tracer, args, original) {
|
|
|
464
486
|
if (!handlers) {
|
|
465
487
|
return original.apply(protocol, args);
|
|
466
488
|
}
|
|
467
|
-
const { id, result } =
|
|
489
|
+
const { id, result } = _chunkKGNFUQ6Zcjs.sessionToolResult.call(void 0, );
|
|
468
490
|
const started = safeStartServerSpan(tracer, request, protocol, { sessionId: id });
|
|
469
491
|
const handler = () => started ? _api.context.with(started.spanCtx, () => result) : result;
|
|
470
492
|
const hadEntry = handlers.has(METHOD_TOOLS_CALL);
|
|
@@ -554,8 +576,8 @@ function safeStartServerSpan(tracer, request, protocol, tracking = {}) {
|
|
|
554
576
|
parentCtx
|
|
555
577
|
);
|
|
556
578
|
applyServerRequestAttributes(span, request, protocol);
|
|
557
|
-
const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => (
|
|
558
|
-
const { context: sessCtx } =
|
|
579
|
+
const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => ( _chunkKGNFUQ6Zcjs.resolveSessionId.call(void 0, protocol, parentCtx))) : void 0;
|
|
580
|
+
const { context: sessCtx } = _chunkKGNFUQ6Zcjs.stampAndPropagateSession.call(void 0,
|
|
559
581
|
span,
|
|
560
582
|
resolved,
|
|
561
583
|
parentCtx,
|
|
@@ -571,7 +593,7 @@ function extractParentContext(request) {
|
|
|
571
593
|
try {
|
|
572
594
|
const meta = _optionalChain([request, 'access', _24 => _24.params, 'optionalAccess', _25 => _25._meta]);
|
|
573
595
|
if (meta && typeof meta === "object") {
|
|
574
|
-
return
|
|
596
|
+
return _chunkVZJNEST4cjs.extractTraceContext.call(void 0, _api.context.active(), meta);
|
|
575
597
|
}
|
|
576
598
|
} catch (error) {
|
|
577
599
|
_chunkWC573FCIcjs.logger.debug(
|
|
@@ -611,7 +633,7 @@ function safeEnd(span) {
|
|
|
611
633
|
|
|
612
634
|
// src/internal/instrumentation/mcp/version.ts
|
|
613
635
|
var INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
|
|
614
|
-
var INSTRUMENTATION_VERSION =
|
|
636
|
+
var INSTRUMENTATION_VERSION = _chunkKGNFUQ6Zcjs.getSDKVersion.call(void 0, );
|
|
615
637
|
|
|
616
638
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
617
639
|
var PROTOCOL_MODULE_NAME = "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
@@ -630,7 +652,8 @@ var MCPInstrumentation = class extends _openinferenceinstrumentationmcp.MCPInstr
|
|
|
630
652
|
|
|
631
653
|
constructor(_config) {
|
|
632
654
|
super({ instrumentationConfig: _optionalChain([_config, 'optionalAccess', _26 => _26.instrumentationConfig]) });
|
|
633
|
-
this.
|
|
655
|
+
this.setTracerProvider(_chunkVZJNEST4cjs.brizzTracerProvider);
|
|
656
|
+
this.brizzTracer = _chunkVZJNEST4cjs.brizzTracerProvider.getTracer(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION);
|
|
634
657
|
}
|
|
635
658
|
/**
|
|
636
659
|
* Apply the SERVER + CLIENT patch to a loaded `protocol.js` module. Shared
|
|
@@ -8,7 +8,13 @@ import {
|
|
|
8
8
|
resolveTransportSessionId,
|
|
9
9
|
sessionToolResult,
|
|
10
10
|
stampAndPropagateSession
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MLMF2O5P.js";
|
|
12
|
+
import {
|
|
13
|
+
brizzTracerProvider,
|
|
14
|
+
extractTraceContext,
|
|
15
|
+
injectTraceContext,
|
|
16
|
+
isPrivateTracerProvider
|
|
17
|
+
} from "./chunk-DBN4NKIG.js";
|
|
12
18
|
import {
|
|
13
19
|
logger
|
|
14
20
|
} from "./chunk-Y4HNUX3Q.js";
|
|
@@ -17,11 +23,10 @@ import "./chunk-3RG5ZIWI.js";
|
|
|
17
23
|
|
|
18
24
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
19
25
|
import { MCPInstrumentation as BaseMCPInstrumentation } from "@arizeai/openinference-instrumentation-mcp";
|
|
20
|
-
import { trace as trace2 } from "@opentelemetry/api";
|
|
21
26
|
import { InstrumentationNodeModuleDefinition } from "@opentelemetry/instrumentation";
|
|
22
27
|
|
|
23
28
|
// src/internal/instrumentation/mcp/patches/protocol.ts
|
|
24
|
-
import { context,
|
|
29
|
+
import { context, SpanKind as SpanKind2, trace } from "@opentelemetry/api";
|
|
25
30
|
|
|
26
31
|
// src/internal/instrumentation/mcp/schemas.ts
|
|
27
32
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
@@ -372,10 +377,27 @@ function wrapRequest(original, tracer) {
|
|
|
372
377
|
}
|
|
373
378
|
return executeAroundSpan(span, request.method, () => {
|
|
374
379
|
const ctx = trace.setSpan(context.active(), span);
|
|
375
|
-
return context.with(ctx, () =>
|
|
380
|
+
return context.with(ctx, () => {
|
|
381
|
+
injectMetaTraceContext(request, ctx);
|
|
382
|
+
return original.apply(this, args);
|
|
383
|
+
});
|
|
376
384
|
});
|
|
377
385
|
};
|
|
378
386
|
}
|
|
387
|
+
function injectMetaTraceContext(request, ctx) {
|
|
388
|
+
if (!isPrivateTracerProvider()) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
request.params ??= {};
|
|
393
|
+
request.params._meta ??= {};
|
|
394
|
+
if (request.params._meta["traceparent"] === void 0) {
|
|
395
|
+
injectTraceContext(ctx, request.params._meta);
|
|
396
|
+
}
|
|
397
|
+
} catch (error) {
|
|
398
|
+
logger.debug(`Brizz MCP: failed to inject trace context into _meta: ${String(error)}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
379
401
|
function wrapOnRequest(original, tracer) {
|
|
380
402
|
return function wrappedOnRequest(...args) {
|
|
381
403
|
const request = args[0];
|
|
@@ -571,7 +593,7 @@ function extractParentContext(request) {
|
|
|
571
593
|
try {
|
|
572
594
|
const meta = request.params?._meta;
|
|
573
595
|
if (meta && typeof meta === "object") {
|
|
574
|
-
return
|
|
596
|
+
return extractTraceContext(context.active(), meta);
|
|
575
597
|
}
|
|
576
598
|
} catch (error) {
|
|
577
599
|
logger.debug(
|
|
@@ -630,7 +652,8 @@ var MCPInstrumentation = class extends BaseMCPInstrumentation {
|
|
|
630
652
|
brizzTracer;
|
|
631
653
|
constructor(_config) {
|
|
632
654
|
super({ instrumentationConfig: _config?.instrumentationConfig });
|
|
633
|
-
this.
|
|
655
|
+
this.setTracerProvider(brizzTracerProvider);
|
|
656
|
+
this.brizzTracer = brizzTracerProvider.getTracer(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION);
|
|
634
657
|
}
|
|
635
658
|
/**
|
|
636
659
|
* Apply the SERVER + CLIENT patch to a loaded `protocol.js` module. Shared
|
|
@@ -2,7 +2,7 @@ import './internal/instrumentation/auto-init.js';
|
|
|
2
2
|
export { Brizz, type IBrizzInitializeOptions } from './internal/sdk.js';
|
|
3
3
|
export { type IInstrumentModules, type IMCPManualModules, } from './internal/instrumentation/index.js';
|
|
4
4
|
export { emitEvent, emitEventWithSessionId } from './internal/log/index.js';
|
|
5
|
-
export { getSpanExporter, getSpanProcessor, withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startAgent, withAgent, setAgent, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './internal/trace/index.js';
|
|
5
|
+
export { getSpanExporter, getSpanProcessor, getTracerProvider, withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startAgent, withAgent, setAgent, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './internal/trace/index.js';
|
|
6
6
|
export type { IMuteOptions, AgentRef, IAgent, IAgentOptions } from './internal/trace/index.js';
|
|
7
7
|
export { getMetricsExporter, getMetricsReader } from './internal/metric/index.js';
|
|
8
8
|
export type { IMaskingConfig, ISpanMaskingConfig, ILogMaskingConfig, IEventMaskingConfig, IEventMaskingRule, MaskingMode, IAttributesMaskingRule, } from './internal/masking/index.js';
|
|
@@ -14,6 +14,7 @@ export interface IResolvedBrizzConfig extends Omit<IBrizzInitializeOptions, 'mas
|
|
|
14
14
|
masking?: IMaskingConfig;
|
|
15
15
|
resourceAttributes?: Record<string, AttributeValue>;
|
|
16
16
|
beforeSendSpan?: (span: ReadableSpan) => boolean | Promise<boolean>;
|
|
17
|
+
setGlobalTracerProvider: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare function resolveConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
|
|
19
20
|
export declare function processEnvironmentConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
4
|
+
export declare const INSTRUMENTATION_NAME = "@brizz/sdk/typesafe";
|
|
5
|
+
export declare const SPAN_NAME = "typesafe.system_one";
|
|
6
|
+
export declare const PROVIDER_NAME = "typesafe";
|
|
7
|
+
export declare const OPERATION_NAME = "classify";
|
|
8
|
+
export declare const ATTR_OPERATION_NAME = "gen_ai.operation.name";
|
|
9
|
+
export declare const ATTR_PROVIDER_NAME = "gen_ai.provider.name";
|
|
10
|
+
export declare const ATTR_REQUEST_MODEL = "gen_ai.request.model";
|
|
11
|
+
export declare const ATTR_RESPONSE_MODEL = "gen_ai.response.model";
|
|
12
|
+
export declare const ATTR_INPUT_TOKENS = "gen_ai.usage.input_tokens";
|
|
13
|
+
export declare const ATTR_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
|
|
14
|
+
export declare const ATTR_INPUT_MESSAGES = "gen_ai.input.messages";
|
|
15
|
+
export declare const ATTR_QUESTIONS = "typesafe.questions";
|
|
16
|
+
export declare const ATTR_ANSWERS = "typesafe.answers";
|
|
17
|
+
interface ISystemOneRequestLike {
|
|
18
|
+
state?: unknown;
|
|
19
|
+
questions?: Record<string, unknown>;
|
|
20
|
+
model?: unknown;
|
|
21
|
+
}
|
|
22
|
+
type SystemOne = (this: ITypeSafeClientLike, request: ISystemOneRequestLike, ...rest: unknown[]) => unknown;
|
|
23
|
+
interface ITypeSafeClientLike {
|
|
24
|
+
systemOne: SystemOne;
|
|
25
|
+
}
|
|
26
|
+
export declare class TypeSafeInstrumentation extends InstrumentationBase<InstrumentationConfig> {
|
|
27
|
+
constructor(config?: InstrumentationConfig);
|
|
28
|
+
protected init(): InstrumentationNodeModuleDefinition[];
|
|
29
|
+
manuallyInstrument(moduleExports: unknown): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function patchInstalledTypeSafe(): void;
|
|
32
|
+
export declare function isSupportedVersion(version: string): boolean;
|
|
33
|
+
export declare function patchSystemOne(proto: ITypeSafeClientLike, getTracer: () => Tracer): boolean;
|
|
34
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export declare class LoggingModule {
|
|
|
15
15
|
emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
|
|
16
16
|
isInitialized(): boolean;
|
|
17
17
|
getLoggerProvider(): LoggerProvider | null;
|
|
18
|
+
forceFlush(): Promise<void>;
|
|
18
19
|
shutdown(): Promise<void>;
|
|
19
20
|
}
|
|
20
21
|
export declare function emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
|
|
@@ -11,6 +11,7 @@ export declare class MetricsModule {
|
|
|
11
11
|
setup(config: IResolvedBrizzConfig): void;
|
|
12
12
|
getMetricsExporter(): OTLPMetricExporter;
|
|
13
13
|
getMetricsReader(): MetricReader;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
14
15
|
shutdown(): void;
|
|
15
16
|
}
|
|
16
17
|
export declare function getMetricsExporter(): OTLPMetricExporter;
|
|
@@ -20,6 +20,7 @@ export interface IBrizzInitializeOptions {
|
|
|
20
20
|
logLevel?: LogLevel | string;
|
|
21
21
|
instrumentModules?: IInstrumentModules;
|
|
22
22
|
disableNodeSdk?: boolean;
|
|
23
|
+
setGlobalTracerProvider?: boolean;
|
|
23
24
|
customSpanExporter?: SpanExporter;
|
|
24
25
|
customLogExporter?: LogRecordExporter;
|
|
25
26
|
customMetricReader?: MetricReader;
|
|
@@ -35,10 +36,12 @@ export declare class _Brizz {
|
|
|
35
36
|
private _meterProvider;
|
|
36
37
|
private setupInstrumentation;
|
|
37
38
|
private createAndStartProviders;
|
|
39
|
+
private registerGlobalTracerProvider;
|
|
38
40
|
private initializeModules;
|
|
39
41
|
private detectModuleSystem;
|
|
40
42
|
private shutdownModules;
|
|
41
43
|
initialize(options: IBrizzInitializeOptions): void;
|
|
44
|
+
flush(timeoutMillis?: number): Promise<boolean>;
|
|
42
45
|
shutdown(): Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
export declare const Brizz: _Brizz;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { TracingModule, getSpanExporter, getSpanProcessor } from './tracing.js';
|
|
2
|
+
export { getTracerProvider } from './provider.js';
|
|
2
3
|
export { BrizzBatchSpanProcessor, BrizzSimpleSpanProcessor } from './processors/span-processor.js';
|
|
3
4
|
export { withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './session.js';
|
|
4
5
|
export type { IMuteOptions } from './session.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context, Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
export declare class BrizzTracerProvider implements TracerProvider {
|
|
3
|
+
private readonly tracers;
|
|
4
|
+
getTracer(name: string, version?: string, options?: TracerOptions): Tracer;
|
|
5
|
+
}
|
|
6
|
+
export declare const brizzTracerProvider: BrizzTracerProvider;
|
|
7
|
+
export declare function getTracerProvider(): TracerProvider;
|
|
8
|
+
export declare function bindToBrizz<T extends {
|
|
9
|
+
setTracerProvider(provider: TracerProvider): void;
|
|
10
|
+
}>(instrumentation: T): T;
|
|
11
|
+
export declare function setPrivateTracerProvider(provider: TracerProvider | null): void;
|
|
12
|
+
export declare function isPrivateTracerProvider(): boolean;
|
|
13
|
+
export declare function ensureContextManager(): 'existing' | 'installed' | 'failed';
|
|
14
|
+
export declare function injectTraceContext(ctx: Context, carrier: Record<string, unknown>): void;
|
|
15
|
+
export declare function extractTraceContext(ctx: Context, carrier: Record<string, unknown>): Context;
|
|
@@ -11,6 +11,7 @@ export declare class TracingModule {
|
|
|
11
11
|
setup(config: IResolvedBrizzConfig): void;
|
|
12
12
|
getSpanExporter(): SpanExporter;
|
|
13
13
|
getSpanProcessor(): SpanProcessor;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
14
15
|
shutdown(): Promise<void>;
|
|
15
16
|
}
|
|
16
17
|
export declare function getSpanExporter(): SpanExporter;
|
|
@@ -2,7 +2,7 @@ import './internal/instrumentation/auto-init.js';
|
|
|
2
2
|
export { Brizz, type IBrizzInitializeOptions } from './internal/sdk.js';
|
|
3
3
|
export { type IInstrumentModules, type IMCPManualModules, } from './internal/instrumentation/index.js';
|
|
4
4
|
export { emitEvent, emitEventWithSessionId } from './internal/log/index.js';
|
|
5
|
-
export { getSpanExporter, getSpanProcessor, withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startAgent, withAgent, setAgent, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './internal/trace/index.js';
|
|
5
|
+
export { getSpanExporter, getSpanProcessor, getTracerProvider, withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startAgent, withAgent, setAgent, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './internal/trace/index.js';
|
|
6
6
|
export type { IMuteOptions, AgentRef, IAgent, IAgentOptions } from './internal/trace/index.js';
|
|
7
7
|
export { getMetricsExporter, getMetricsReader } from './internal/metric/index.js';
|
|
8
8
|
export type { IMaskingConfig, ISpanMaskingConfig, ILogMaskingConfig, IEventMaskingConfig, IEventMaskingRule, MaskingMode, IAttributesMaskingRule, } from './internal/masking/index.js';
|
|
@@ -14,6 +14,7 @@ export interface IResolvedBrizzConfig extends Omit<IBrizzInitializeOptions, 'mas
|
|
|
14
14
|
masking?: IMaskingConfig;
|
|
15
15
|
resourceAttributes?: Record<string, AttributeValue>;
|
|
16
16
|
beforeSendSpan?: (span: ReadableSpan) => boolean | Promise<boolean>;
|
|
17
|
+
setGlobalTracerProvider: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare function resolveConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
|
|
19
20
|
export declare function processEnvironmentConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
4
|
+
export declare const INSTRUMENTATION_NAME = "@brizz/sdk/typesafe";
|
|
5
|
+
export declare const SPAN_NAME = "typesafe.system_one";
|
|
6
|
+
export declare const PROVIDER_NAME = "typesafe";
|
|
7
|
+
export declare const OPERATION_NAME = "classify";
|
|
8
|
+
export declare const ATTR_OPERATION_NAME = "gen_ai.operation.name";
|
|
9
|
+
export declare const ATTR_PROVIDER_NAME = "gen_ai.provider.name";
|
|
10
|
+
export declare const ATTR_REQUEST_MODEL = "gen_ai.request.model";
|
|
11
|
+
export declare const ATTR_RESPONSE_MODEL = "gen_ai.response.model";
|
|
12
|
+
export declare const ATTR_INPUT_TOKENS = "gen_ai.usage.input_tokens";
|
|
13
|
+
export declare const ATTR_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
|
|
14
|
+
export declare const ATTR_INPUT_MESSAGES = "gen_ai.input.messages";
|
|
15
|
+
export declare const ATTR_QUESTIONS = "typesafe.questions";
|
|
16
|
+
export declare const ATTR_ANSWERS = "typesafe.answers";
|
|
17
|
+
interface ISystemOneRequestLike {
|
|
18
|
+
state?: unknown;
|
|
19
|
+
questions?: Record<string, unknown>;
|
|
20
|
+
model?: unknown;
|
|
21
|
+
}
|
|
22
|
+
type SystemOne = (this: ITypeSafeClientLike, request: ISystemOneRequestLike, ...rest: unknown[]) => unknown;
|
|
23
|
+
interface ITypeSafeClientLike {
|
|
24
|
+
systemOne: SystemOne;
|
|
25
|
+
}
|
|
26
|
+
export declare class TypeSafeInstrumentation extends InstrumentationBase<InstrumentationConfig> {
|
|
27
|
+
constructor(config?: InstrumentationConfig);
|
|
28
|
+
protected init(): InstrumentationNodeModuleDefinition[];
|
|
29
|
+
manuallyInstrument(moduleExports: unknown): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function patchInstalledTypeSafe(): void;
|
|
32
|
+
export declare function isSupportedVersion(version: string): boolean;
|
|
33
|
+
export declare function patchSystemOne(proto: ITypeSafeClientLike, getTracer: () => Tracer): boolean;
|
|
34
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export declare class LoggingModule {
|
|
|
15
15
|
emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
|
|
16
16
|
isInitialized(): boolean;
|
|
17
17
|
getLoggerProvider(): LoggerProvider | null;
|
|
18
|
+
forceFlush(): Promise<void>;
|
|
18
19
|
shutdown(): Promise<void>;
|
|
19
20
|
}
|
|
20
21
|
export declare function emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
|
|
@@ -11,6 +11,7 @@ export declare class MetricsModule {
|
|
|
11
11
|
setup(config: IResolvedBrizzConfig): void;
|
|
12
12
|
getMetricsExporter(): OTLPMetricExporter;
|
|
13
13
|
getMetricsReader(): MetricReader;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
14
15
|
shutdown(): void;
|
|
15
16
|
}
|
|
16
17
|
export declare function getMetricsExporter(): OTLPMetricExporter;
|
|
@@ -20,6 +20,7 @@ export interface IBrizzInitializeOptions {
|
|
|
20
20
|
logLevel?: LogLevel | string;
|
|
21
21
|
instrumentModules?: IInstrumentModules;
|
|
22
22
|
disableNodeSdk?: boolean;
|
|
23
|
+
setGlobalTracerProvider?: boolean;
|
|
23
24
|
customSpanExporter?: SpanExporter;
|
|
24
25
|
customLogExporter?: LogRecordExporter;
|
|
25
26
|
customMetricReader?: MetricReader;
|
|
@@ -35,10 +36,12 @@ export declare class _Brizz {
|
|
|
35
36
|
private _meterProvider;
|
|
36
37
|
private setupInstrumentation;
|
|
37
38
|
private createAndStartProviders;
|
|
39
|
+
private registerGlobalTracerProvider;
|
|
38
40
|
private initializeModules;
|
|
39
41
|
private detectModuleSystem;
|
|
40
42
|
private shutdownModules;
|
|
41
43
|
initialize(options: IBrizzInitializeOptions): void;
|
|
44
|
+
flush(timeoutMillis?: number): Promise<boolean>;
|
|
42
45
|
shutdown(): Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
export declare const Brizz: _Brizz;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { TracingModule, getSpanExporter, getSpanProcessor } from './tracing.js';
|
|
2
|
+
export { getTracerProvider } from './provider.js';
|
|
2
3
|
export { BrizzBatchSpanProcessor, BrizzSimpleSpanProcessor } from './processors/span-processor.js';
|
|
3
4
|
export { withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, setServiceName, withServiceName, callWithServiceName, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './session.js';
|
|
4
5
|
export type { IMuteOptions } from './session.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context, Tracer, TracerOptions, TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
export declare class BrizzTracerProvider implements TracerProvider {
|
|
3
|
+
private readonly tracers;
|
|
4
|
+
getTracer(name: string, version?: string, options?: TracerOptions): Tracer;
|
|
5
|
+
}
|
|
6
|
+
export declare const brizzTracerProvider: BrizzTracerProvider;
|
|
7
|
+
export declare function getTracerProvider(): TracerProvider;
|
|
8
|
+
export declare function bindToBrizz<T extends {
|
|
9
|
+
setTracerProvider(provider: TracerProvider): void;
|
|
10
|
+
}>(instrumentation: T): T;
|
|
11
|
+
export declare function setPrivateTracerProvider(provider: TracerProvider | null): void;
|
|
12
|
+
export declare function isPrivateTracerProvider(): boolean;
|
|
13
|
+
export declare function ensureContextManager(): 'existing' | 'installed' | 'failed';
|
|
14
|
+
export declare function injectTraceContext(ctx: Context, carrier: Record<string, unknown>): void;
|
|
15
|
+
export declare function extractTraceContext(ctx: Context, carrier: Record<string, unknown>): Context;
|
|
@@ -11,6 +11,7 @@ export declare class TracingModule {
|
|
|
11
11
|
setup(config: IResolvedBrizzConfig): void;
|
|
12
12
|
getSpanExporter(): SpanExporter;
|
|
13
13
|
getSpanProcessor(): SpanProcessor;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
14
15
|
shutdown(): Promise<void>;
|
|
15
16
|
}
|
|
16
17
|
export declare function getSpanExporter(): SpanExporter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brizz/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenTelemetry-based observability SDK for AI applications",
|
|
6
6
|
"keywords": [
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"check:types-package": "attw --pack . --entrypoints . eve google-genai --ignore-rules no-resolution",
|
|
61
61
|
"check:types-consumer": "node scripts/check-consumer-types.mjs",
|
|
62
62
|
"check:types": "pnpm run check:types-package && pnpm run check:types-consumer",
|
|
63
|
-
"check:esm-langgraph": "node scripts/check-esm-langgraph.mjs"
|
|
63
|
+
"check:esm-langgraph": "node scripts/check-esm-langgraph.mjs",
|
|
64
|
+
"check:typesafe": "node scripts/check-typesafe.mjs"
|
|
64
65
|
},
|
|
65
66
|
"exports": {
|
|
66
67
|
".": {
|
|
@@ -103,9 +104,9 @@
|
|
|
103
104
|
"registry": "https://registry.npmjs.org/"
|
|
104
105
|
},
|
|
105
106
|
"devDependencies": {
|
|
106
|
-
"@ai-sdk/anthropic": "^4.0.
|
|
107
|
-
"@ai-sdk/openai": "^4.0.
|
|
108
|
-
"@ai-sdk/otel": "^1.0.
|
|
107
|
+
"@ai-sdk/anthropic": "^4.0.82",
|
|
108
|
+
"@ai-sdk/openai": "^4.0.96",
|
|
109
|
+
"@ai-sdk/otel": "^1.0.143",
|
|
109
110
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
110
111
|
"@arizeai/openinference-instrumentation-mcp": "^0.2.36",
|
|
111
112
|
"@babel/core": "^8.0.7",
|
|
@@ -113,26 +114,27 @@
|
|
|
113
114
|
"@babel/preset-typescript": "^8.0.7",
|
|
114
115
|
"@changesets/changelog-github": "^1.0.1",
|
|
115
116
|
"@changesets/cli": "^3.0.3",
|
|
116
|
-
"@google/genai": "^2.
|
|
117
|
-
"@langchain/core": "^1.2.
|
|
118
|
-
"@langchain/langgraph": "^1.
|
|
117
|
+
"@google/genai": "^2.30.0",
|
|
118
|
+
"@langchain/core": "^1.2.18",
|
|
119
|
+
"@langchain/langgraph": "^1.5.1",
|
|
119
120
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
120
121
|
"@traceloop/instrumentation-google-generativeai": "^0.27.0",
|
|
121
122
|
"@traceloop/instrumentation-vertexai": "^0.27.0",
|
|
122
123
|
"@types/jest": "^30.0.0",
|
|
123
124
|
"@types/node": "^26.6.5",
|
|
124
|
-
"ai": "^7.0
|
|
125
|
+
"@typesafe-ai/sdk": "^0.7.0",
|
|
126
|
+
"ai": "^7.0.143",
|
|
125
127
|
"babel-jest": "^30.5.2",
|
|
126
|
-
"babel-plugin-transform-import-meta": "^3.
|
|
128
|
+
"babel-plugin-transform-import-meta": "^3.1.0",
|
|
127
129
|
"jest": "^30.5.2",
|
|
128
130
|
"jest-environment-jsdom": "^30.5.2",
|
|
129
|
-
"openai": "^7.
|
|
130
|
-
"oxlint": "^1.
|
|
131
|
+
"openai": "^7.39.0",
|
|
132
|
+
"oxlint": "^1.88.0",
|
|
131
133
|
"prettier": "^3.9.10",
|
|
132
|
-
"tsup": "^
|
|
134
|
+
"tsup": "^9.0.0",
|
|
133
135
|
"typescript": "^7.0.2",
|
|
134
|
-
"vitest": "^5.0.
|
|
135
|
-
"zod": "^4.6.
|
|
136
|
+
"vitest": "^5.0.5",
|
|
137
|
+
"zod": "^4.6.7"
|
|
136
138
|
},
|
|
137
139
|
"peerDependencies": {
|
|
138
140
|
"@ai-sdk/otel": "^1",
|
|
@@ -142,6 +144,7 @@
|
|
|
142
144
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
143
145
|
"@traceloop/instrumentation-google-generativeai": "^0.27.0",
|
|
144
146
|
"@traceloop/instrumentation-vertexai": "^0.27.0",
|
|
147
|
+
"@typesafe-ai/sdk": ">=0.5.7 <1",
|
|
145
148
|
"ai": "*",
|
|
146
149
|
"typescript": ">=5.0.0"
|
|
147
150
|
},
|
|
@@ -167,6 +170,9 @@
|
|
|
167
170
|
"@traceloop/instrumentation-vertexai": {
|
|
168
171
|
"optional": true
|
|
169
172
|
},
|
|
173
|
+
"@typesafe-ai/sdk": {
|
|
174
|
+
"optional": true
|
|
175
|
+
},
|
|
170
176
|
"ai": {
|
|
171
177
|
"optional": true
|
|
172
178
|
},
|
|
@@ -179,6 +185,7 @@
|
|
|
179
185
|
"@arizeai/openinference-instrumentation-openai": "^2.3.1",
|
|
180
186
|
"@opentelemetry/api": "^1.9.0",
|
|
181
187
|
"@opentelemetry/api-logs": "^0.223.0",
|
|
188
|
+
"@opentelemetry/context-async-hooks": "^2.12.0",
|
|
182
189
|
"@opentelemetry/core": "^2.12.0",
|
|
183
190
|
"@opentelemetry/exporter-logs-otlp-http": "^0.223.0",
|
|
184
191
|
"@opentelemetry/exporter-metrics-otlp-http": "^0.223.0",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkKFETJN5Mcjs = require('./chunk-KFETJN5M.cjs');
|
|
5
|
-
require('./chunk-WC573FCI.cjs');
|
|
6
|
-
require('./chunk-OBGZSXTJ.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.GoogleGenAIInstrumentation = _chunkKFETJN5Mcjs.GoogleGenAIInstrumentation; exports.instrumentGoogleGenAI = _chunkKFETJN5Mcjs.instrumentGoogleGenAI;
|