netra-sdk 1.1.0 → 1.3.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.cjs +224 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -3
- package/dist/index.d.ts +60 -3
- package/dist/index.js +224 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1061,6 +1061,32 @@ interface DecoratorOptions {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
type SpanCallback<T> = (span: SpanWrapper) => T;
|
|
1063
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Raw file metadata received from the backend.
|
|
1066
|
+
*
|
|
1067
|
+
* Contains a pre-signed download URL that the SDK uses to fetch the actual
|
|
1068
|
+
* file content. Instances are produced by parsing the `attachments` array
|
|
1069
|
+
* returned on each user message from the simulation API.
|
|
1070
|
+
*/
|
|
1071
|
+
interface FileData {
|
|
1072
|
+
fileName: string;
|
|
1073
|
+
contentType: string;
|
|
1074
|
+
description?: string;
|
|
1075
|
+
downloadUrl: string;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* File after download and base64 encoding, delivered to the user task.
|
|
1079
|
+
*
|
|
1080
|
+
* The `data` field contains the raw file bytes encoded as a base64 ASCII
|
|
1081
|
+
* string. Consumers should decode with `Buffer.from(data, "base64")` before
|
|
1082
|
+
* passing to an LLM or other downstream system.
|
|
1083
|
+
*/
|
|
1084
|
+
interface ProcessedFile {
|
|
1085
|
+
fileName: string;
|
|
1086
|
+
contentType: string;
|
|
1087
|
+
description?: string;
|
|
1088
|
+
data: string;
|
|
1089
|
+
}
|
|
1064
1090
|
/**
|
|
1065
1091
|
* Represents a single item in a simulation run.
|
|
1066
1092
|
*/
|
|
@@ -1068,6 +1094,7 @@ interface SimulationItem {
|
|
|
1068
1094
|
runItemId: string;
|
|
1069
1095
|
message: string;
|
|
1070
1096
|
turnId: string;
|
|
1097
|
+
files?: FileData[];
|
|
1071
1098
|
}
|
|
1072
1099
|
/**
|
|
1073
1100
|
* Response from the conversation trigger API.
|
|
@@ -1078,6 +1105,7 @@ interface ConversationResponse {
|
|
|
1078
1105
|
nextTurnId?: string;
|
|
1079
1106
|
nextUserMessage?: string;
|
|
1080
1107
|
nextRunItemId?: string;
|
|
1108
|
+
nextFiles?: FileData[];
|
|
1081
1109
|
}
|
|
1082
1110
|
/**
|
|
1083
1111
|
* Result returned from the user's task function.
|
|
@@ -1108,13 +1136,17 @@ interface SimulationResult {
|
|
|
1108
1136
|
|
|
1109
1137
|
declare abstract class BaseTask {
|
|
1110
1138
|
/**
|
|
1139
|
+
* Process a simulation turn and return the agent's response.
|
|
1140
|
+
*
|
|
1111
1141
|
* @param message - The input message from the simulation.
|
|
1112
|
-
* @param sessionId - The
|
|
1142
|
+
* @param sessionId - The session identifier.
|
|
1143
|
+
* @param files - Optional list of base64-encoded file attachments from the
|
|
1144
|
+
* dataset item. Will be `null` when no files are attached.
|
|
1113
1145
|
* @returns The task result containing:
|
|
1114
1146
|
* - message (string): The response message from the task.
|
|
1115
1147
|
* - sessionId (string): The session identifier.
|
|
1116
1148
|
*/
|
|
1117
|
-
abstract run(message: string, sessionId?: string | null): Promise<TaskResult> | TaskResult;
|
|
1149
|
+
abstract run(message: string, sessionId?: string | null, files?: ProcessedFile[] | null): Promise<TaskResult> | TaskResult;
|
|
1118
1150
|
}
|
|
1119
1151
|
|
|
1120
1152
|
/**
|
|
@@ -1182,6 +1214,28 @@ declare function span(target: AnyClass): void;
|
|
|
1182
1214
|
declare function span<T extends AnyFunction>(target: T): T;
|
|
1183
1215
|
declare function span(options?: DecoratorOptions): UnifiedDecorator;
|
|
1184
1216
|
|
|
1217
|
+
/**
|
|
1218
|
+
* Shared utility functions for instrumentation.
|
|
1219
|
+
* Handles setting OTel span attributes for LLM request/response tracing.
|
|
1220
|
+
*/
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Controls where native traces are sent.
|
|
1224
|
+
*
|
|
1225
|
+
* - `"netra"` -- Replace the SDK's default processors so traces go
|
|
1226
|
+
* only to Netra. If the SDK does not expose the required APIs, falls back
|
|
1227
|
+
* to additive mode (both Netra and native) and logs a warning.
|
|
1228
|
+
* - `"netra-strict"` (default) -- Same replacement as `"netra"`, but if the SDK APIs
|
|
1229
|
+
* are unavailable the processor is **not** registered at all, ensuring
|
|
1230
|
+
* traces never reach native even at the cost of no tracing.
|
|
1231
|
+
* - `"both"` -- The Netra processor is added alongside the native defaults;
|
|
1232
|
+
* traces go to both Netra and native.
|
|
1233
|
+
*
|
|
1234
|
+
* Can also be set via the `NATIVE_TRACING_MODE` environment
|
|
1235
|
+
* variable using the same string values.
|
|
1236
|
+
*/
|
|
1237
|
+
type NativeTracingMode = "both" | "netra" | "netra-strict";
|
|
1238
|
+
|
|
1185
1239
|
/**
|
|
1186
1240
|
* Custom MistralAI instrumentor for Netra SDK
|
|
1187
1241
|
*
|
|
@@ -1296,12 +1350,15 @@ interface TracingProcessor {
|
|
|
1296
1350
|
forceFlush(): Promise<void> | void;
|
|
1297
1351
|
shutdown(timeout?: number): Promise<void> | void;
|
|
1298
1352
|
}
|
|
1353
|
+
|
|
1299
1354
|
interface InstrumentorOptions {
|
|
1300
1355
|
tracerProvider?: {
|
|
1301
1356
|
getTracer(name: string, version?: string): any;
|
|
1302
1357
|
};
|
|
1303
1358
|
/** Override the `llm.system` attribute value (default: `"openai"`). */
|
|
1304
1359
|
systemName?: string;
|
|
1360
|
+
/** Controls where traces are sent. See {@link NativeTracingMode}. */
|
|
1361
|
+
nativeTracing?: NativeTracingMode;
|
|
1305
1362
|
}
|
|
1306
1363
|
|
|
1307
1364
|
declare class NetraAgentsTracingProcessor implements TracingProcessor {
|
|
@@ -1528,4 +1585,4 @@ declare class Netra {
|
|
|
1528
1585
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1529
1586
|
}
|
|
1530
1587
|
|
|
1531
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, 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, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, 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, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
|
1588
|
+
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, 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, 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, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, 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, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
package/dist/index.d.ts
CHANGED
|
@@ -1061,6 +1061,32 @@ interface DecoratorOptions {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
type SpanCallback<T> = (span: SpanWrapper) => T;
|
|
1063
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Raw file metadata received from the backend.
|
|
1066
|
+
*
|
|
1067
|
+
* Contains a pre-signed download URL that the SDK uses to fetch the actual
|
|
1068
|
+
* file content. Instances are produced by parsing the `attachments` array
|
|
1069
|
+
* returned on each user message from the simulation API.
|
|
1070
|
+
*/
|
|
1071
|
+
interface FileData {
|
|
1072
|
+
fileName: string;
|
|
1073
|
+
contentType: string;
|
|
1074
|
+
description?: string;
|
|
1075
|
+
downloadUrl: string;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* File after download and base64 encoding, delivered to the user task.
|
|
1079
|
+
*
|
|
1080
|
+
* The `data` field contains the raw file bytes encoded as a base64 ASCII
|
|
1081
|
+
* string. Consumers should decode with `Buffer.from(data, "base64")` before
|
|
1082
|
+
* passing to an LLM or other downstream system.
|
|
1083
|
+
*/
|
|
1084
|
+
interface ProcessedFile {
|
|
1085
|
+
fileName: string;
|
|
1086
|
+
contentType: string;
|
|
1087
|
+
description?: string;
|
|
1088
|
+
data: string;
|
|
1089
|
+
}
|
|
1064
1090
|
/**
|
|
1065
1091
|
* Represents a single item in a simulation run.
|
|
1066
1092
|
*/
|
|
@@ -1068,6 +1094,7 @@ interface SimulationItem {
|
|
|
1068
1094
|
runItemId: string;
|
|
1069
1095
|
message: string;
|
|
1070
1096
|
turnId: string;
|
|
1097
|
+
files?: FileData[];
|
|
1071
1098
|
}
|
|
1072
1099
|
/**
|
|
1073
1100
|
* Response from the conversation trigger API.
|
|
@@ -1078,6 +1105,7 @@ interface ConversationResponse {
|
|
|
1078
1105
|
nextTurnId?: string;
|
|
1079
1106
|
nextUserMessage?: string;
|
|
1080
1107
|
nextRunItemId?: string;
|
|
1108
|
+
nextFiles?: FileData[];
|
|
1081
1109
|
}
|
|
1082
1110
|
/**
|
|
1083
1111
|
* Result returned from the user's task function.
|
|
@@ -1108,13 +1136,17 @@ interface SimulationResult {
|
|
|
1108
1136
|
|
|
1109
1137
|
declare abstract class BaseTask {
|
|
1110
1138
|
/**
|
|
1139
|
+
* Process a simulation turn and return the agent's response.
|
|
1140
|
+
*
|
|
1111
1141
|
* @param message - The input message from the simulation.
|
|
1112
|
-
* @param sessionId - The
|
|
1142
|
+
* @param sessionId - The session identifier.
|
|
1143
|
+
* @param files - Optional list of base64-encoded file attachments from the
|
|
1144
|
+
* dataset item. Will be `null` when no files are attached.
|
|
1113
1145
|
* @returns The task result containing:
|
|
1114
1146
|
* - message (string): The response message from the task.
|
|
1115
1147
|
* - sessionId (string): The session identifier.
|
|
1116
1148
|
*/
|
|
1117
|
-
abstract run(message: string, sessionId?: string | null): Promise<TaskResult> | TaskResult;
|
|
1149
|
+
abstract run(message: string, sessionId?: string | null, files?: ProcessedFile[] | null): Promise<TaskResult> | TaskResult;
|
|
1118
1150
|
}
|
|
1119
1151
|
|
|
1120
1152
|
/**
|
|
@@ -1182,6 +1214,28 @@ declare function span(target: AnyClass): void;
|
|
|
1182
1214
|
declare function span<T extends AnyFunction>(target: T): T;
|
|
1183
1215
|
declare function span(options?: DecoratorOptions): UnifiedDecorator;
|
|
1184
1216
|
|
|
1217
|
+
/**
|
|
1218
|
+
* Shared utility functions for instrumentation.
|
|
1219
|
+
* Handles setting OTel span attributes for LLM request/response tracing.
|
|
1220
|
+
*/
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Controls where native traces are sent.
|
|
1224
|
+
*
|
|
1225
|
+
* - `"netra"` -- Replace the SDK's default processors so traces go
|
|
1226
|
+
* only to Netra. If the SDK does not expose the required APIs, falls back
|
|
1227
|
+
* to additive mode (both Netra and native) and logs a warning.
|
|
1228
|
+
* - `"netra-strict"` (default) -- Same replacement as `"netra"`, but if the SDK APIs
|
|
1229
|
+
* are unavailable the processor is **not** registered at all, ensuring
|
|
1230
|
+
* traces never reach native even at the cost of no tracing.
|
|
1231
|
+
* - `"both"` -- The Netra processor is added alongside the native defaults;
|
|
1232
|
+
* traces go to both Netra and native.
|
|
1233
|
+
*
|
|
1234
|
+
* Can also be set via the `NATIVE_TRACING_MODE` environment
|
|
1235
|
+
* variable using the same string values.
|
|
1236
|
+
*/
|
|
1237
|
+
type NativeTracingMode = "both" | "netra" | "netra-strict";
|
|
1238
|
+
|
|
1185
1239
|
/**
|
|
1186
1240
|
* Custom MistralAI instrumentor for Netra SDK
|
|
1187
1241
|
*
|
|
@@ -1296,12 +1350,15 @@ interface TracingProcessor {
|
|
|
1296
1350
|
forceFlush(): Promise<void> | void;
|
|
1297
1351
|
shutdown(timeout?: number): Promise<void> | void;
|
|
1298
1352
|
}
|
|
1353
|
+
|
|
1299
1354
|
interface InstrumentorOptions {
|
|
1300
1355
|
tracerProvider?: {
|
|
1301
1356
|
getTracer(name: string, version?: string): any;
|
|
1302
1357
|
};
|
|
1303
1358
|
/** Override the `llm.system` attribute value (default: `"openai"`). */
|
|
1304
1359
|
systemName?: string;
|
|
1360
|
+
/** Controls where traces are sent. See {@link NativeTracingMode}. */
|
|
1361
|
+
nativeTracing?: NativeTracingMode;
|
|
1305
1362
|
}
|
|
1306
1363
|
|
|
1307
1364
|
declare class NetraAgentsTracingProcessor implements TracingProcessor {
|
|
@@ -1528,4 +1585,4 @@ declare class Netra {
|
|
|
1528
1585
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1529
1586
|
}
|
|
1530
1587
|
|
|
1531
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, 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, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraAgentsTracingProcessor, NetraInstruments, NetraOpenAIAgentsInstrumentor, type NumberResponse, Operator, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, 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, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|
|
1588
|
+
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, 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, 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, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, 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, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, netraExpressMiddleware, openaiAgentsInstrumentor, runWithExtractedContext, span, task, workflow };
|