netra-sdk 1.7.0 → 1.9.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/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
- * Note: when `enableRootSpan` is true, Netra attaches its own root span and
37
- * every auto-instrumentation span becomes its child, so no reparenting
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.6.0";
80
+ static readonly LIBRARY_VERSION = "1.8.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;
@@ -1101,7 +1133,11 @@ type SpanCallback<T> = (span: SpanWrapper) => T;
1101
1133
  * - beforeAll failure -> entire run is marked failed (prescript_failed), no scenarios run
1102
1134
  * - beforeEach failure -> that scenario is marked failed (prescript_failed), others continue
1103
1135
  * - before failure -> that scenario is marked failed (prescript_failed), others continue
1104
- * - after / afterEach / afterAll failures are logged as warnings and do not affect run/scenario status
1136
+ * - after / afterEach -> both always attempt to run; if the scenario otherwise
1137
+ * succeeded it is marked postscript_failed, otherwise the
1138
+ * existing failure status/reason is preserved
1139
+ * - afterAll failure -> successfully completed scenarios are marked
1140
+ * postscript_failed; already-failed scenarios keep their status
1105
1141
  */
1106
1142
  /** Hook that runs once before any scenario starts. May return shared context. */
1107
1143
  type BeforeAllFn = () => Record<string, any> | null | void | Promise<Record<string, any> | null | void>;
@@ -1197,6 +1233,7 @@ interface ConversationResult {
1197
1233
  runItemId: string;
1198
1234
  success: boolean;
1199
1235
  error?: string;
1236
+ status?: string;
1200
1237
  finalTurnId?: string;
1201
1238
  turnId?: string;
1202
1239
  }
@@ -1265,6 +1302,18 @@ declare class Simulation {
1265
1302
  * Orchestrate concurrent simulation execution with hooks support.
1266
1303
  */
1267
1304
  private _runSimulationAsync;
1305
+ /**
1306
+ * Report failures for many items concurrently, capped like other paths.
1307
+ */
1308
+ private _reportFailures;
1309
+ /**
1310
+ * Run after/afterEach hooks independently.
1311
+ *
1312
+ * Both hooks always attempt to run. `postscript_failed` is reported only
1313
+ * when the item otherwise succeeded — an existing failure status/reason is
1314
+ * never overwritten.
1315
+ */
1316
+ private _runAfterHooks;
1268
1317
  /**
1269
1318
  * Execute a multi-turn conversation for a single simulation item.
1270
1319
  *
@@ -1735,7 +1784,6 @@ declare class Netra {
1735
1784
  private static _initialized;
1736
1785
  private static _config;
1737
1786
  private static _tracer;
1738
- private static _rootSpan;
1739
1787
  private static _metricsEnabled;
1740
1788
  static usage: Usage;
1741
1789
  static evaluation: Evaluation;
@@ -1751,12 +1799,6 @@ declare class Netra {
1751
1799
  static setOutput(value: any): void;
1752
1800
  static setRootInput(value: any): void;
1753
1801
  static setRootOutput(value: any): void;
1754
- /**
1755
- * Run a function with the root span as the active parent context.
1756
- * All spans created within this function will be children of the root span.
1757
- * Note: required in JS because OTel JS has no persistent context.attach()
1758
- */
1759
- static runWithRootSpan<T>(fn: () => T): T;
1760
1802
  static setSessionId(sessionId: string): void;
1761
1803
  /**
1762
1804
  * Set user_id context attributes for all spans.
@@ -1787,4 +1829,4 @@ declare class Netra {
1787
1829
  static withBlockedSpansLocal: typeof withBlockedSpansLocal;
1788
1830
  }
1789
1831
 
1790
- 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 };
1832
+ 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, 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
- * Note: when `enableRootSpan` is true, Netra attaches its own root span and
37
- * every auto-instrumentation span becomes its child, so no reparenting
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.6.0";
80
+ static readonly LIBRARY_VERSION = "1.8.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;
@@ -1101,7 +1133,11 @@ type SpanCallback<T> = (span: SpanWrapper) => T;
1101
1133
  * - beforeAll failure -> entire run is marked failed (prescript_failed), no scenarios run
1102
1134
  * - beforeEach failure -> that scenario is marked failed (prescript_failed), others continue
1103
1135
  * - before failure -> that scenario is marked failed (prescript_failed), others continue
1104
- * - after / afterEach / afterAll failures are logged as warnings and do not affect run/scenario status
1136
+ * - after / afterEach -> both always attempt to run; if the scenario otherwise
1137
+ * succeeded it is marked postscript_failed, otherwise the
1138
+ * existing failure status/reason is preserved
1139
+ * - afterAll failure -> successfully completed scenarios are marked
1140
+ * postscript_failed; already-failed scenarios keep their status
1105
1141
  */
1106
1142
  /** Hook that runs once before any scenario starts. May return shared context. */
1107
1143
  type BeforeAllFn = () => Record<string, any> | null | void | Promise<Record<string, any> | null | void>;
@@ -1197,6 +1233,7 @@ interface ConversationResult {
1197
1233
  runItemId: string;
1198
1234
  success: boolean;
1199
1235
  error?: string;
1236
+ status?: string;
1200
1237
  finalTurnId?: string;
1201
1238
  turnId?: string;
1202
1239
  }
@@ -1265,6 +1302,18 @@ declare class Simulation {
1265
1302
  * Orchestrate concurrent simulation execution with hooks support.
1266
1303
  */
1267
1304
  private _runSimulationAsync;
1305
+ /**
1306
+ * Report failures for many items concurrently, capped like other paths.
1307
+ */
1308
+ private _reportFailures;
1309
+ /**
1310
+ * Run after/afterEach hooks independently.
1311
+ *
1312
+ * Both hooks always attempt to run. `postscript_failed` is reported only
1313
+ * when the item otherwise succeeded — an existing failure status/reason is
1314
+ * never overwritten.
1315
+ */
1316
+ private _runAfterHooks;
1268
1317
  /**
1269
1318
  * Execute a multi-turn conversation for a single simulation item.
1270
1319
  *
@@ -1735,7 +1784,6 @@ declare class Netra {
1735
1784
  private static _initialized;
1736
1785
  private static _config;
1737
1786
  private static _tracer;
1738
- private static _rootSpan;
1739
1787
  private static _metricsEnabled;
1740
1788
  static usage: Usage;
1741
1789
  static evaluation: Evaluation;
@@ -1751,12 +1799,6 @@ declare class Netra {
1751
1799
  static setOutput(value: any): void;
1752
1800
  static setRootInput(value: any): void;
1753
1801
  static setRootOutput(value: any): void;
1754
- /**
1755
- * Run a function with the root span as the active parent context.
1756
- * All spans created within this function will be children of the root span.
1757
- * Note: required in JS because OTel JS has no persistent context.attach()
1758
- */
1759
- static runWithRootSpan<T>(fn: () => T): T;
1760
1802
  static setSessionId(sessionId: string): void;
1761
1803
  /**
1762
1804
  * Set user_id context attributes for all spans.
@@ -1787,4 +1829,4 @@ declare class Netra {
1787
1829
  static withBlockedSpansLocal: typeof withBlockedSpansLocal;
1788
1830
  }
1789
1831
 
1790
- 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 };
1832
+ 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, 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 };