@sentrial/sdk 0.4.2 → 0.4.4

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
@@ -1120,7 +1120,13 @@ type GenerateTextParams = {
1120
1120
  temperature?: number;
1121
1121
  [key: string]: unknown;
1122
1122
  };
1123
+ /**
1124
+ * Usage info — supports both AI SDK v3/v4 (promptTokens/completionTokens)
1125
+ * and v5/v6 (inputTokens/outputTokens) field names.
1126
+ */
1123
1127
  type UsageInfo = {
1128
+ inputTokens?: number;
1129
+ outputTokens?: number;
1124
1130
  promptTokens?: number;
1125
1131
  completionTokens?: number;
1126
1132
  totalTokens?: number;
@@ -1181,11 +1187,13 @@ type StreamTextResult = {
1181
1187
  }>;
1182
1188
  [key: string]: unknown;
1183
1189
  };
1190
+ /** String or function that returns a string (for dynamic per-request values) */
1191
+ type StringOrFn = string | (() => string | undefined);
1184
1192
  /** Per-instance config passed through closures (not global) */
1185
1193
  type WrapperConfig = {
1186
1194
  defaultAgent?: string;
1187
- userId?: string;
1188
- convoId?: string;
1195
+ userId?: StringOrFn;
1196
+ convoId?: StringOrFn;
1189
1197
  };
1190
1198
  /**
1191
1199
  * Configure the Sentrial SDK for Vercel AI SDK integration.
@@ -1205,8 +1213,8 @@ declare function configureVercel(config: {
1205
1213
  apiKey?: string;
1206
1214
  apiUrl?: string;
1207
1215
  defaultAgent?: string;
1208
- userId?: string;
1209
- convoId?: string;
1216
+ userId?: StringOrFn;
1217
+ convoId?: StringOrFn;
1210
1218
  failSilently?: boolean;
1211
1219
  }): void;
1212
1220
  declare function wrapGenerateText(originalFn: Function, client: SentrialClient, config: WrapperConfig): (params: GenerateTextParams) => Promise<GenerateTextResult>;
@@ -1240,8 +1248,8 @@ declare function wrapStreamObject(originalFn: Function, client: SentrialClient,
1240
1248
  declare function wrapAISDK(ai: AIModule, options?: {
1241
1249
  client?: SentrialClient;
1242
1250
  defaultAgent?: string;
1243
- userId?: string;
1244
- convoId?: string;
1251
+ userId?: StringOrFn;
1252
+ convoId?: StringOrFn;
1245
1253
  }): {
1246
1254
  generateText: ReturnType<typeof wrapGenerateText>;
1247
1255
  streamText: ReturnType<typeof wrapStreamText>;
package/dist/index.d.ts CHANGED
@@ -1120,7 +1120,13 @@ type GenerateTextParams = {
1120
1120
  temperature?: number;
1121
1121
  [key: string]: unknown;
1122
1122
  };
1123
+ /**
1124
+ * Usage info — supports both AI SDK v3/v4 (promptTokens/completionTokens)
1125
+ * and v5/v6 (inputTokens/outputTokens) field names.
1126
+ */
1123
1127
  type UsageInfo = {
1128
+ inputTokens?: number;
1129
+ outputTokens?: number;
1124
1130
  promptTokens?: number;
1125
1131
  completionTokens?: number;
1126
1132
  totalTokens?: number;
@@ -1181,11 +1187,13 @@ type StreamTextResult = {
1181
1187
  }>;
1182
1188
  [key: string]: unknown;
1183
1189
  };
1190
+ /** String or function that returns a string (for dynamic per-request values) */
1191
+ type StringOrFn = string | (() => string | undefined);
1184
1192
  /** Per-instance config passed through closures (not global) */
1185
1193
  type WrapperConfig = {
1186
1194
  defaultAgent?: string;
1187
- userId?: string;
1188
- convoId?: string;
1195
+ userId?: StringOrFn;
1196
+ convoId?: StringOrFn;
1189
1197
  };
1190
1198
  /**
1191
1199
  * Configure the Sentrial SDK for Vercel AI SDK integration.
@@ -1205,8 +1213,8 @@ declare function configureVercel(config: {
1205
1213
  apiKey?: string;
1206
1214
  apiUrl?: string;
1207
1215
  defaultAgent?: string;
1208
- userId?: string;
1209
- convoId?: string;
1216
+ userId?: StringOrFn;
1217
+ convoId?: StringOrFn;
1210
1218
  failSilently?: boolean;
1211
1219
  }): void;
1212
1220
  declare function wrapGenerateText(originalFn: Function, client: SentrialClient, config: WrapperConfig): (params: GenerateTextParams) => Promise<GenerateTextResult>;
@@ -1240,8 +1248,8 @@ declare function wrapStreamObject(originalFn: Function, client: SentrialClient,
1240
1248
  declare function wrapAISDK(ai: AIModule, options?: {
1241
1249
  client?: SentrialClient;
1242
1250
  defaultAgent?: string;
1243
- userId?: string;
1244
- convoId?: string;
1251
+ userId?: StringOrFn;
1252
+ convoId?: StringOrFn;
1245
1253
  }): {
1246
1254
  generateText: ReturnType<typeof wrapGenerateText>;
1247
1255
  streamText: ReturnType<typeof wrapStreamText>;