netra-sdk 1.8.0 → 1.10.0
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 +68 -0
- package/dist/index.cjs +248 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -17
- package/dist/index.d.ts +106 -17
- package/dist/index.js +222 -61
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -11,7 +11,6 @@ interface NetraConfig {
|
|
|
11
11
|
disableBatch?: boolean;
|
|
12
12
|
traceContent?: boolean;
|
|
13
13
|
debugMode?: boolean;
|
|
14
|
-
enableRootSpan?: boolean;
|
|
15
14
|
resourceAttributes?: Record<string, any>;
|
|
16
15
|
environment?: string;
|
|
17
16
|
enableScrubbing?: boolean;
|
|
@@ -33,10 +32,8 @@ interface NetraConfig {
|
|
|
33
32
|
* link is remote (cross-process) is kept as a root so an upstream distributed
|
|
34
33
|
* trace is not severed.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* occurs. Pass a set containing `NetraInstruments.ALL` to allow all
|
|
39
|
-
* instrumentations to produce root spans (legacy behaviour).
|
|
35
|
+
* Pass a set containing `NetraInstruments.ALL` to allow all instrumentations
|
|
36
|
+
* to produce root spans (legacy behaviour).
|
|
40
37
|
*/
|
|
41
38
|
rootInstruments?: Set<NetraInstruments>;
|
|
42
39
|
}
|
|
@@ -80,8 +77,10 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
80
77
|
declare class Config {
|
|
81
78
|
static readonly SDK_NAME = "netra";
|
|
82
79
|
static readonly LIBRARY_NAME = "netra";
|
|
83
|
-
static readonly LIBRARY_VERSION = "1.
|
|
80
|
+
static readonly LIBRARY_VERSION = "1.10.0";
|
|
84
81
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
82
|
+
static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
|
|
83
|
+
static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
|
|
85
84
|
private static _spanAttributeMaxSize;
|
|
86
85
|
/**
|
|
87
86
|
* Lazily reads NETRA_SPAN_ATTRIBUTE_MAX_SIZE from process.env on first
|
|
@@ -96,7 +95,6 @@ declare class Config {
|
|
|
96
95
|
disableBatch: boolean;
|
|
97
96
|
traceContent: boolean;
|
|
98
97
|
debugMode: boolean;
|
|
99
|
-
enableRootSpan: boolean;
|
|
100
98
|
enableScrubbing: boolean;
|
|
101
99
|
environment: string;
|
|
102
100
|
resourceAttributes: Record<string, any>;
|
|
@@ -821,6 +819,39 @@ interface SessionStatsData {
|
|
|
821
819
|
session_duration: string;
|
|
822
820
|
cursor: string;
|
|
823
821
|
}
|
|
822
|
+
interface SessionDetailsToolCall {
|
|
823
|
+
toolName: string;
|
|
824
|
+
toolCallCount: number;
|
|
825
|
+
}
|
|
826
|
+
interface SessionDetailsTrace {
|
|
827
|
+
traceId: string;
|
|
828
|
+
traceName: string;
|
|
829
|
+
startTime: string;
|
|
830
|
+
endTime: string;
|
|
831
|
+
latencyMs: number;
|
|
832
|
+
input: string | null;
|
|
833
|
+
output: string | null;
|
|
834
|
+
tokens: {
|
|
835
|
+
promptTokens: number;
|
|
836
|
+
completionTokens: number;
|
|
837
|
+
cachedTokens: number;
|
|
838
|
+
cacheCreationTokens: number;
|
|
839
|
+
totalTokens: number;
|
|
840
|
+
};
|
|
841
|
+
cost: {
|
|
842
|
+
promptTokensCost: number;
|
|
843
|
+
completionTokensCost: number;
|
|
844
|
+
cachedTokensCost: number;
|
|
845
|
+
cacheCreationTokensCost: number;
|
|
846
|
+
totalCost: number;
|
|
847
|
+
};
|
|
848
|
+
models: string[];
|
|
849
|
+
toolCalls: SessionDetailsToolCall[];
|
|
850
|
+
}
|
|
851
|
+
interface SessionDetailsResponse {
|
|
852
|
+
sessionId: string;
|
|
853
|
+
traces: SessionDetailsTrace[];
|
|
854
|
+
}
|
|
824
855
|
|
|
825
856
|
/**
|
|
826
857
|
* Public Dashboard API
|
|
@@ -840,6 +871,7 @@ declare class Dashboard {
|
|
|
840
871
|
getSessionStats(startTime: string, endTime: string, limit?: number, filters?: SessionFilter[], cursor?: string, sortField?: SortField, sortOrder?: SortOrder): Promise<SessionStatsResult | null>;
|
|
841
872
|
iterSessionStats(startTime: string, endTime: string, filters?: SessionFilter[], sortField?: SortField, sortOrder?: SortOrder): AsyncGenerator<SessionStatsData, void, unknown>;
|
|
842
873
|
getSessionSummary(filter: SessionFilterConfig): Promise<any | null>;
|
|
874
|
+
getSessionDetails(sessionId: string): Promise<SessionDetailsResponse | null>;
|
|
843
875
|
private isValidScope;
|
|
844
876
|
private isValidChartType;
|
|
845
877
|
private isValidMetrics;
|
|
@@ -851,9 +883,18 @@ declare class Dashboard {
|
|
|
851
883
|
/**
|
|
852
884
|
* Prompts API Models
|
|
853
885
|
*/
|
|
886
|
+
/** Default TTL (seconds) for prompt cache when useCache is true and cacheTtl is omitted. */
|
|
887
|
+
declare const PROMPT_CACHE_TTL_SECONDS = 60;
|
|
854
888
|
interface GetPromptParams {
|
|
855
889
|
name: string;
|
|
856
890
|
label?: string;
|
|
891
|
+
/** When true, serve from in-memory cache when available (default: false). */
|
|
892
|
+
useCache?: boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Per-call TTL in seconds.
|
|
895
|
+
* When omitted with useCache: true, uses PROMPT_CACHE_TTL_SECONDS (60).
|
|
896
|
+
*/
|
|
897
|
+
cacheTtl?: number;
|
|
857
898
|
}
|
|
858
899
|
/**
|
|
859
900
|
* Prompt response is intentionally flexible because
|
|
@@ -864,16 +905,67 @@ type PromptResponse = Record<string, any>;
|
|
|
864
905
|
declare class Prompts {
|
|
865
906
|
private config;
|
|
866
907
|
private client;
|
|
908
|
+
private cache;
|
|
867
909
|
constructor(config: Config);
|
|
910
|
+
/** Clear all cached prompt entries. */
|
|
911
|
+
clearCache(): void;
|
|
868
912
|
/**
|
|
869
913
|
* Fetch prompt version by name and label.
|
|
870
914
|
*
|
|
871
|
-
* @param params.name
|
|
872
|
-
* @param params.label
|
|
915
|
+
* @param params.name - Name of the prompt (required)
|
|
916
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
917
|
+
* @param params.useCache - When true, read/write the in-memory cache (default: false)
|
|
918
|
+
* @param params.cacheTtl - Per-call cache TTL in seconds (default: PROMPT_CACHE_TTL_SECONDS)
|
|
873
919
|
*/
|
|
874
920
|
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
875
921
|
}
|
|
876
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Models API Models
|
|
925
|
+
*/
|
|
926
|
+
/** Default TTL (seconds) for model pricing cache when useCache is true and cacheTtl is omitted. */
|
|
927
|
+
declare const MODEL_PRICING_CACHE_TTL_SECONDS = 300;
|
|
928
|
+
interface ModelPrice {
|
|
929
|
+
usageType: string;
|
|
930
|
+
minUnits: number;
|
|
931
|
+
maxUnits: number;
|
|
932
|
+
price: number;
|
|
933
|
+
unitValue: number;
|
|
934
|
+
}
|
|
935
|
+
interface ModelPricing {
|
|
936
|
+
name: string;
|
|
937
|
+
projectId: string | null;
|
|
938
|
+
matchPattern: string;
|
|
939
|
+
prices: ModelPrice[];
|
|
940
|
+
}
|
|
941
|
+
interface GetModelPricingParams {
|
|
942
|
+
name?: string;
|
|
943
|
+
/** When true, read/write in-memory cache (default: false). */
|
|
944
|
+
useCache?: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Per-call TTL in seconds.
|
|
947
|
+
* When omitted with useCache: true, uses MODEL_PRICING_CACHE_TTL_SECONDS (300).
|
|
948
|
+
*/
|
|
949
|
+
cacheTtl?: number;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
declare class Models {
|
|
953
|
+
private config;
|
|
954
|
+
private client;
|
|
955
|
+
private cache;
|
|
956
|
+
constructor(config: Config);
|
|
957
|
+
/** Clear all cached model pricing entries. */
|
|
958
|
+
clearCache(): void;
|
|
959
|
+
/**
|
|
960
|
+
* Fetch model pricing from the backend.
|
|
961
|
+
*
|
|
962
|
+
* @param params.name - Optional model name filter
|
|
963
|
+
* @param params.useCache - When true, read/write the in-memory cache (default: false)
|
|
964
|
+
* @param params.cacheTtl - Per-call cache TTL in seconds (default: MODEL_PRICING_CACHE_TTL_SECONDS)
|
|
965
|
+
*/
|
|
966
|
+
getModelPricing(params?: GetModelPricingParams): Promise<ModelPricing[] | null>;
|
|
967
|
+
}
|
|
968
|
+
|
|
877
969
|
/**
|
|
878
970
|
* Instrumentation Span Processor
|
|
879
971
|
*
|
|
@@ -1752,15 +1844,18 @@ declare class Netra {
|
|
|
1752
1844
|
private static _initialized;
|
|
1753
1845
|
private static _config;
|
|
1754
1846
|
private static _tracer;
|
|
1755
|
-
private static _rootSpan;
|
|
1756
1847
|
private static _metricsEnabled;
|
|
1757
1848
|
static usage: Usage;
|
|
1758
1849
|
static evaluation: Evaluation;
|
|
1759
1850
|
static dashboard: Dashboard;
|
|
1760
1851
|
static simulation: Simulation;
|
|
1761
1852
|
static prompts: Prompts;
|
|
1853
|
+
static models: Models;
|
|
1762
1854
|
static getConfig(): Config;
|
|
1763
1855
|
static isInitialized(): boolean;
|
|
1856
|
+
/**
|
|
1857
|
+
* Initialize the Netra SDK.
|
|
1858
|
+
*/
|
|
1764
1859
|
static init(config?: NetraConfig): Promise<void>;
|
|
1765
1860
|
static shutdown(): Promise<void>;
|
|
1766
1861
|
static getTraceId(): string | undefined;
|
|
@@ -1768,12 +1863,6 @@ declare class Netra {
|
|
|
1768
1863
|
static setOutput(value: any): void;
|
|
1769
1864
|
static setRootInput(value: any): void;
|
|
1770
1865
|
static setRootOutput(value: any): void;
|
|
1771
|
-
/**
|
|
1772
|
-
* Run a function with the root span as the active parent context.
|
|
1773
|
-
* All spans created within this function will be children of the root span.
|
|
1774
|
-
* Note: required in JS because OTel JS has no persistent context.attach()
|
|
1775
|
-
*/
|
|
1776
|
-
static runWithRootSpan<T>(fn: () => T): T;
|
|
1777
1866
|
static setSessionId(sessionId: string): void;
|
|
1778
1867
|
/**
|
|
1779
1868
|
* Set user_id context attributes for all spans.
|
|
@@ -1804,4 +1893,4 @@ declare class Netra {
|
|
|
1804
1893
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1805
1894
|
}
|
|
1806
1895
|
|
|
1807
|
-
export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
|
|
1896
|
+
export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetModelPricingParams, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, MODEL_PRICING_CACHE_TTL_SECONDS, Measure, type Metrics, type ModelPrice, type ModelPricing, Models, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, PROMPT_CACHE_TTL_SECONDS, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, type SessionDetailsResponse, type SessionDetailsToolCall, type SessionDetailsTrace, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ interface NetraConfig {
|
|
|
11
11
|
disableBatch?: boolean;
|
|
12
12
|
traceContent?: boolean;
|
|
13
13
|
debugMode?: boolean;
|
|
14
|
-
enableRootSpan?: boolean;
|
|
15
14
|
resourceAttributes?: Record<string, any>;
|
|
16
15
|
environment?: string;
|
|
17
16
|
enableScrubbing?: boolean;
|
|
@@ -33,10 +32,8 @@ interface NetraConfig {
|
|
|
33
32
|
* link is remote (cross-process) is kept as a root so an upstream distributed
|
|
34
33
|
* trace is not severed.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* occurs. Pass a set containing `NetraInstruments.ALL` to allow all
|
|
39
|
-
* instrumentations to produce root spans (legacy behaviour).
|
|
35
|
+
* Pass a set containing `NetraInstruments.ALL` to allow all instrumentations
|
|
36
|
+
* to produce root spans (legacy behaviour).
|
|
40
37
|
*/
|
|
41
38
|
rootInstruments?: Set<NetraInstruments>;
|
|
42
39
|
}
|
|
@@ -80,8 +77,10 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
80
77
|
declare class Config {
|
|
81
78
|
static readonly SDK_NAME = "netra";
|
|
82
79
|
static readonly LIBRARY_NAME = "netra";
|
|
83
|
-
static readonly LIBRARY_VERSION = "1.
|
|
80
|
+
static readonly LIBRARY_VERSION = "1.10.0";
|
|
84
81
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
82
|
+
static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
|
|
83
|
+
static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
|
|
85
84
|
private static _spanAttributeMaxSize;
|
|
86
85
|
/**
|
|
87
86
|
* Lazily reads NETRA_SPAN_ATTRIBUTE_MAX_SIZE from process.env on first
|
|
@@ -96,7 +95,6 @@ declare class Config {
|
|
|
96
95
|
disableBatch: boolean;
|
|
97
96
|
traceContent: boolean;
|
|
98
97
|
debugMode: boolean;
|
|
99
|
-
enableRootSpan: boolean;
|
|
100
98
|
enableScrubbing: boolean;
|
|
101
99
|
environment: string;
|
|
102
100
|
resourceAttributes: Record<string, any>;
|
|
@@ -821,6 +819,39 @@ interface SessionStatsData {
|
|
|
821
819
|
session_duration: string;
|
|
822
820
|
cursor: string;
|
|
823
821
|
}
|
|
822
|
+
interface SessionDetailsToolCall {
|
|
823
|
+
toolName: string;
|
|
824
|
+
toolCallCount: number;
|
|
825
|
+
}
|
|
826
|
+
interface SessionDetailsTrace {
|
|
827
|
+
traceId: string;
|
|
828
|
+
traceName: string;
|
|
829
|
+
startTime: string;
|
|
830
|
+
endTime: string;
|
|
831
|
+
latencyMs: number;
|
|
832
|
+
input: string | null;
|
|
833
|
+
output: string | null;
|
|
834
|
+
tokens: {
|
|
835
|
+
promptTokens: number;
|
|
836
|
+
completionTokens: number;
|
|
837
|
+
cachedTokens: number;
|
|
838
|
+
cacheCreationTokens: number;
|
|
839
|
+
totalTokens: number;
|
|
840
|
+
};
|
|
841
|
+
cost: {
|
|
842
|
+
promptTokensCost: number;
|
|
843
|
+
completionTokensCost: number;
|
|
844
|
+
cachedTokensCost: number;
|
|
845
|
+
cacheCreationTokensCost: number;
|
|
846
|
+
totalCost: number;
|
|
847
|
+
};
|
|
848
|
+
models: string[];
|
|
849
|
+
toolCalls: SessionDetailsToolCall[];
|
|
850
|
+
}
|
|
851
|
+
interface SessionDetailsResponse {
|
|
852
|
+
sessionId: string;
|
|
853
|
+
traces: SessionDetailsTrace[];
|
|
854
|
+
}
|
|
824
855
|
|
|
825
856
|
/**
|
|
826
857
|
* Public Dashboard API
|
|
@@ -840,6 +871,7 @@ declare class Dashboard {
|
|
|
840
871
|
getSessionStats(startTime: string, endTime: string, limit?: number, filters?: SessionFilter[], cursor?: string, sortField?: SortField, sortOrder?: SortOrder): Promise<SessionStatsResult | null>;
|
|
841
872
|
iterSessionStats(startTime: string, endTime: string, filters?: SessionFilter[], sortField?: SortField, sortOrder?: SortOrder): AsyncGenerator<SessionStatsData, void, unknown>;
|
|
842
873
|
getSessionSummary(filter: SessionFilterConfig): Promise<any | null>;
|
|
874
|
+
getSessionDetails(sessionId: string): Promise<SessionDetailsResponse | null>;
|
|
843
875
|
private isValidScope;
|
|
844
876
|
private isValidChartType;
|
|
845
877
|
private isValidMetrics;
|
|
@@ -851,9 +883,18 @@ declare class Dashboard {
|
|
|
851
883
|
/**
|
|
852
884
|
* Prompts API Models
|
|
853
885
|
*/
|
|
886
|
+
/** Default TTL (seconds) for prompt cache when useCache is true and cacheTtl is omitted. */
|
|
887
|
+
declare const PROMPT_CACHE_TTL_SECONDS = 60;
|
|
854
888
|
interface GetPromptParams {
|
|
855
889
|
name: string;
|
|
856
890
|
label?: string;
|
|
891
|
+
/** When true, serve from in-memory cache when available (default: false). */
|
|
892
|
+
useCache?: boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Per-call TTL in seconds.
|
|
895
|
+
* When omitted with useCache: true, uses PROMPT_CACHE_TTL_SECONDS (60).
|
|
896
|
+
*/
|
|
897
|
+
cacheTtl?: number;
|
|
857
898
|
}
|
|
858
899
|
/**
|
|
859
900
|
* Prompt response is intentionally flexible because
|
|
@@ -864,16 +905,67 @@ type PromptResponse = Record<string, any>;
|
|
|
864
905
|
declare class Prompts {
|
|
865
906
|
private config;
|
|
866
907
|
private client;
|
|
908
|
+
private cache;
|
|
867
909
|
constructor(config: Config);
|
|
910
|
+
/** Clear all cached prompt entries. */
|
|
911
|
+
clearCache(): void;
|
|
868
912
|
/**
|
|
869
913
|
* Fetch prompt version by name and label.
|
|
870
914
|
*
|
|
871
|
-
* @param params.name
|
|
872
|
-
* @param params.label
|
|
915
|
+
* @param params.name - Name of the prompt (required)
|
|
916
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
917
|
+
* @param params.useCache - When true, read/write the in-memory cache (default: false)
|
|
918
|
+
* @param params.cacheTtl - Per-call cache TTL in seconds (default: PROMPT_CACHE_TTL_SECONDS)
|
|
873
919
|
*/
|
|
874
920
|
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
875
921
|
}
|
|
876
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Models API Models
|
|
925
|
+
*/
|
|
926
|
+
/** Default TTL (seconds) for model pricing cache when useCache is true and cacheTtl is omitted. */
|
|
927
|
+
declare const MODEL_PRICING_CACHE_TTL_SECONDS = 300;
|
|
928
|
+
interface ModelPrice {
|
|
929
|
+
usageType: string;
|
|
930
|
+
minUnits: number;
|
|
931
|
+
maxUnits: number;
|
|
932
|
+
price: number;
|
|
933
|
+
unitValue: number;
|
|
934
|
+
}
|
|
935
|
+
interface ModelPricing {
|
|
936
|
+
name: string;
|
|
937
|
+
projectId: string | null;
|
|
938
|
+
matchPattern: string;
|
|
939
|
+
prices: ModelPrice[];
|
|
940
|
+
}
|
|
941
|
+
interface GetModelPricingParams {
|
|
942
|
+
name?: string;
|
|
943
|
+
/** When true, read/write in-memory cache (default: false). */
|
|
944
|
+
useCache?: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Per-call TTL in seconds.
|
|
947
|
+
* When omitted with useCache: true, uses MODEL_PRICING_CACHE_TTL_SECONDS (300).
|
|
948
|
+
*/
|
|
949
|
+
cacheTtl?: number;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
declare class Models {
|
|
953
|
+
private config;
|
|
954
|
+
private client;
|
|
955
|
+
private cache;
|
|
956
|
+
constructor(config: Config);
|
|
957
|
+
/** Clear all cached model pricing entries. */
|
|
958
|
+
clearCache(): void;
|
|
959
|
+
/**
|
|
960
|
+
* Fetch model pricing from the backend.
|
|
961
|
+
*
|
|
962
|
+
* @param params.name - Optional model name filter
|
|
963
|
+
* @param params.useCache - When true, read/write the in-memory cache (default: false)
|
|
964
|
+
* @param params.cacheTtl - Per-call cache TTL in seconds (default: MODEL_PRICING_CACHE_TTL_SECONDS)
|
|
965
|
+
*/
|
|
966
|
+
getModelPricing(params?: GetModelPricingParams): Promise<ModelPricing[] | null>;
|
|
967
|
+
}
|
|
968
|
+
|
|
877
969
|
/**
|
|
878
970
|
* Instrumentation Span Processor
|
|
879
971
|
*
|
|
@@ -1752,15 +1844,18 @@ declare class Netra {
|
|
|
1752
1844
|
private static _initialized;
|
|
1753
1845
|
private static _config;
|
|
1754
1846
|
private static _tracer;
|
|
1755
|
-
private static _rootSpan;
|
|
1756
1847
|
private static _metricsEnabled;
|
|
1757
1848
|
static usage: Usage;
|
|
1758
1849
|
static evaluation: Evaluation;
|
|
1759
1850
|
static dashboard: Dashboard;
|
|
1760
1851
|
static simulation: Simulation;
|
|
1761
1852
|
static prompts: Prompts;
|
|
1853
|
+
static models: Models;
|
|
1762
1854
|
static getConfig(): Config;
|
|
1763
1855
|
static isInitialized(): boolean;
|
|
1856
|
+
/**
|
|
1857
|
+
* Initialize the Netra SDK.
|
|
1858
|
+
*/
|
|
1764
1859
|
static init(config?: NetraConfig): Promise<void>;
|
|
1765
1860
|
static shutdown(): Promise<void>;
|
|
1766
1861
|
static getTraceId(): string | undefined;
|
|
@@ -1768,12 +1863,6 @@ declare class Netra {
|
|
|
1768
1863
|
static setOutput(value: any): void;
|
|
1769
1864
|
static setRootInput(value: any): void;
|
|
1770
1865
|
static setRootOutput(value: any): void;
|
|
1771
|
-
/**
|
|
1772
|
-
* Run a function with the root span as the active parent context.
|
|
1773
|
-
* All spans created within this function will be children of the root span.
|
|
1774
|
-
* Note: required in JS because OTel JS has no persistent context.attach()
|
|
1775
|
-
*/
|
|
1776
|
-
static runWithRootSpan<T>(fn: () => T): T;
|
|
1777
1866
|
static setSessionId(sessionId: string): void;
|
|
1778
1867
|
/**
|
|
1779
1868
|
* Set user_id context attributes for all spans.
|
|
@@ -1804,4 +1893,4 @@ declare class Netra {
|
|
|
1804
1893
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1805
1894
|
}
|
|
1806
1895
|
|
|
1807
|
-
export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
|
|
1896
|
+
export { type ActionModel, type AfterAllFn, type AfterFn, Aggregation, BaseTask, type BeforeAllFn, type BeforeFn, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, DEFAULT_INSTRUMENTS, DEFAULT_INSTRUMENTS_FOR_ROOT, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetModelPricingParams, type GetPromptParams, GroupBy, type InitializeRunResult, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, MODEL_PRICING_CACHE_TTL_SECONDS, Measure, type Metrics, type ModelPrice, type ModelPricing, Models, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, PROMPT_CACHE_TTL_SECONDS, type ProcessedFile, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, type SafeStringifyOptions, Scope, ScrubbingSpanProcessor, SerializationSpanProcessor, type SessionDetailsResponse, type SessionDetailsToolCall, type SessionDetailsTrace, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationHooks, type SimulationItem, type SimulationOptions, type SimulationResult, SpanIOProcessor, type SpanOptions, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, TruncatingSerializer, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, safeStringify, span, task, workflow };
|