cencori 1.8.0 → 1.8.2

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.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CencoriConfig, i as RequestOptions } from './types-CZSIg4JQ.mjs';
2
- export { j as ChatMessage, a as ChatRequest, b as ChatResponse, o as CodeInterpreterTool, c as CompletionRequest, E as EmbeddingRequest, d as EmbeddingResponse, F as FileSearchTool, l as ResponseInputItem, k as ResponsesOutputItem, R as ResponsesRequest, g as ResponsesResponse, m as ResponsesTool, U as UrlCitation, n as WebSearchTool } from './types-CZSIg4JQ.mjs';
1
+ import { C as CencoriConfig, i as RequestOptions } from './types-CAhDuNTz.mjs';
2
+ export { j as ChatMessage, a as ChatRequest, b as ChatResponse, o as CodeInterpreterTool, c as CompletionRequest, E as EmbeddingRequest, d as EmbeddingResponse, F as FileSearchTool, l as ResponseInputItem, k as ResponsesOutputItem, R as ResponsesRequest, g as ResponsesResponse, m as ResponsesTool, U as UrlCitation, n as WebSearchTool } from './types-CAhDuNTz.mjs';
3
3
  import { AINamespace } from './ai/index.mjs';
4
4
  export { StreamChunk } from './ai/index.mjs';
5
5
  import { VisionNamespace } from './vision/index.mjs';
@@ -256,6 +256,16 @@ interface ChatCompletionCreateParams {
256
256
  name: string;
257
257
  variables?: Record<string, string>;
258
258
  };
259
+ /**
260
+ * Per-request provider timeout in milliseconds (positive, capped
261
+ * server-side at 300000). Bounds one provider attempt.
262
+ */
263
+ timeout_ms?: number;
264
+ /**
265
+ * Per-request cost budget in USD (non-negative). Unary calls fail before
266
+ * returning; streams surface HTTP 402 `budget_exceeded` at final tally.
267
+ */
268
+ max_cost_usd?: number;
259
269
  }
260
270
  interface ChatCompletionResponse {
261
271
  id: string;
@@ -287,6 +297,20 @@ interface ChatCompletionResponse {
287
297
  content: string;
288
298
  }>;
289
299
  write_status: 'pending' | 'disabled';
300
+ /** Chat request id backing the async writeback — poll GET /v1/memory/writes/:id. Null when write is disabled. */
301
+ write_request_id?: string | null;
302
+ };
303
+ /** Request id for support correlation (X-Request-Id). */
304
+ requestId?: string | null;
305
+ /** Input-guard classification the gateway verdicts (absent when unstreamed/skipped). */
306
+ safety?: {
307
+ scanned: boolean;
308
+ input?: {
309
+ safe: boolean;
310
+ layer: string;
311
+ riskScore: number;
312
+ reasons: string[];
313
+ };
290
314
  };
291
315
  }
292
316
  interface ChatCompletionChunk {
@@ -296,6 +320,14 @@ interface ChatCompletionChunk {
296
320
  interface ChatCompletionStream extends AsyncIterable<ChatCompletionChunk> {
297
321
  /** Number of memories injected into this request (from X-Cencori-Memory-Retrieved). */
298
322
  memoriesRetrieved: number;
323
+ /** Input-guard verdict from the stream-open headers (absent when unscanned). */
324
+ safety?: {
325
+ scanned: boolean;
326
+ input?: {
327
+ safe: boolean;
328
+ riskScore: number;
329
+ };
330
+ };
299
331
  }
300
332
  declare class Completions {
301
333
  private config;
@@ -1157,32 +1189,54 @@ declare class Cencori {
1157
1189
  /**
1158
1190
  * Cencori Error Classes
1159
1191
  *
1160
- * Custom error types for better error handling
1192
+ * Custom error types for better error handling. Every API failure carries
1193
+ * the HTTP status, the machine-readable code, the request id (for support
1194
+ * correlation), and any retry hint the server sent — so callers never have
1195
+ * to guess from a bare message again.
1161
1196
  */
1162
1197
  declare class CencoriError extends Error {
1163
1198
  statusCode?: number | undefined;
1164
1199
  code?: string | undefined;
1165
- constructor(message: string, statusCode?: number | undefined, code?: string | undefined);
1200
+ options?: {
1201
+ requestId?: string | null;
1202
+ retryAfterMs?: number | null;
1203
+ errorBody?: unknown;
1204
+ } | undefined;
1205
+ constructor(message: string, statusCode?: number | undefined, code?: string | undefined, options?: {
1206
+ requestId?: string | null;
1207
+ retryAfterMs?: number | null;
1208
+ errorBody?: unknown;
1209
+ } | undefined);
1210
+ /** Request id for support correlation (X-Request-Id), when the server sent one. */
1211
+ get requestId(): string | null;
1212
+ /** Server-advised wait before retrying, when sent (Retry-After / retry_after_ms). */
1213
+ get retryAfterMs(): number | null;
1214
+ /** True for failures worth retrying: rate limits, bad gateway, unavailable, timeouts. */
1215
+ get isRetryable(): boolean;
1166
1216
  }
1167
1217
  declare class AuthenticationError extends CencoriError {
1168
- constructor(message?: string);
1218
+ constructor(message?: string, options?: {
1219
+ requestId?: string | null;
1220
+ });
1169
1221
  }
1170
1222
  declare class RateLimitError extends CencoriError {
1171
1223
  retryAfterSeconds?: number | null | undefined;
1172
- constructor(message?: string, retryAfterSeconds?: number | null | undefined);
1224
+ constructor(message?: string, retryAfterSeconds?: number | null | undefined, options?: {
1225
+ requestId?: string | null;
1226
+ errorBody?: unknown;
1227
+ });
1173
1228
  }
1174
1229
  declare class SafetyError extends CencoriError {
1175
1230
  reasons?: string[] | undefined;
1176
- constructor(message?: string, reasons?: string[] | undefined);
1231
+ constructor(message?: string, reasons?: string[] | undefined, options?: {
1232
+ requestId?: string | null;
1233
+ errorBody?: unknown;
1234
+ });
1177
1235
  }
1178
1236
 
1179
1237
  /**
1180
1238
  * Utility functions for Cencori SDK
1181
1239
  */
1182
- /**
1183
- * Fetch with automatic retry on 5xx errors
1184
- * Uses exponential backoff: 1s, 2s, 4s
1185
- */
1186
1240
  declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number): Promise<Response>;
1187
1241
 
1188
1242
  export { AINamespace, ActionsNamespace, type Agent, type AgentConfig, type AgentKey, type AgentListItem, AgentVersionsNamespace, AgentsNamespace, AuthenticationError, Cencori, CencoriConfig, CencoriEmbeddedApiError, CencoriError, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionResponse, type ChatCompletionStream, type ChatMemoryOptions, ChatNamespace, ClientTokensNamespace, ComputeNamespace, ConnectionsNamespace, type CreateAgentKeyParams, type CreateAgentParams, type CreateSessionParams, DocumentsNamespace, type EmbeddedRequestOptions, EndUsersNamespace, InstallationsNamespace, KnowledgeNamespace, McpServersNamespace, MemoryClient, ModelsNamespace, type PaginatedResponse, ProviderConnectionsNamespace, RateLimitError, RatePlansNamespace, RequestOptions, RunsNamespace, SafetyError, type Session, type SessionEvent, type SessionListParams, SessionsNamespace, SkillImportsNamespace, SkillsNamespace, StorageNamespace, TelemetryClient, type Tenant, TenantsNamespace, type TurnParams, type UnifiedModel, type UpdateAgentParams, UsageNamespace, VisionNamespace, VoiceNamespace, WebNamespace, WebhooksNamespace, WorkflowNamespace, Cencori as default, fetchWithRetry };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CencoriConfig, i as RequestOptions } from './types-CZSIg4JQ.js';
2
- export { j as ChatMessage, a as ChatRequest, b as ChatResponse, o as CodeInterpreterTool, c as CompletionRequest, E as EmbeddingRequest, d as EmbeddingResponse, F as FileSearchTool, l as ResponseInputItem, k as ResponsesOutputItem, R as ResponsesRequest, g as ResponsesResponse, m as ResponsesTool, U as UrlCitation, n as WebSearchTool } from './types-CZSIg4JQ.js';
1
+ import { C as CencoriConfig, i as RequestOptions } from './types-CAhDuNTz.js';
2
+ export { j as ChatMessage, a as ChatRequest, b as ChatResponse, o as CodeInterpreterTool, c as CompletionRequest, E as EmbeddingRequest, d as EmbeddingResponse, F as FileSearchTool, l as ResponseInputItem, k as ResponsesOutputItem, R as ResponsesRequest, g as ResponsesResponse, m as ResponsesTool, U as UrlCitation, n as WebSearchTool } from './types-CAhDuNTz.js';
3
3
  import { AINamespace } from './ai/index.js';
4
4
  export { StreamChunk } from './ai/index.js';
5
5
  import { VisionNamespace } from './vision/index.js';
@@ -256,6 +256,16 @@ interface ChatCompletionCreateParams {
256
256
  name: string;
257
257
  variables?: Record<string, string>;
258
258
  };
259
+ /**
260
+ * Per-request provider timeout in milliseconds (positive, capped
261
+ * server-side at 300000). Bounds one provider attempt.
262
+ */
263
+ timeout_ms?: number;
264
+ /**
265
+ * Per-request cost budget in USD (non-negative). Unary calls fail before
266
+ * returning; streams surface HTTP 402 `budget_exceeded` at final tally.
267
+ */
268
+ max_cost_usd?: number;
259
269
  }
260
270
  interface ChatCompletionResponse {
261
271
  id: string;
@@ -287,6 +297,20 @@ interface ChatCompletionResponse {
287
297
  content: string;
288
298
  }>;
289
299
  write_status: 'pending' | 'disabled';
300
+ /** Chat request id backing the async writeback — poll GET /v1/memory/writes/:id. Null when write is disabled. */
301
+ write_request_id?: string | null;
302
+ };
303
+ /** Request id for support correlation (X-Request-Id). */
304
+ requestId?: string | null;
305
+ /** Input-guard classification the gateway verdicts (absent when unstreamed/skipped). */
306
+ safety?: {
307
+ scanned: boolean;
308
+ input?: {
309
+ safe: boolean;
310
+ layer: string;
311
+ riskScore: number;
312
+ reasons: string[];
313
+ };
290
314
  };
291
315
  }
292
316
  interface ChatCompletionChunk {
@@ -296,6 +320,14 @@ interface ChatCompletionChunk {
296
320
  interface ChatCompletionStream extends AsyncIterable<ChatCompletionChunk> {
297
321
  /** Number of memories injected into this request (from X-Cencori-Memory-Retrieved). */
298
322
  memoriesRetrieved: number;
323
+ /** Input-guard verdict from the stream-open headers (absent when unscanned). */
324
+ safety?: {
325
+ scanned: boolean;
326
+ input?: {
327
+ safe: boolean;
328
+ riskScore: number;
329
+ };
330
+ };
299
331
  }
300
332
  declare class Completions {
301
333
  private config;
@@ -1157,32 +1189,54 @@ declare class Cencori {
1157
1189
  /**
1158
1190
  * Cencori Error Classes
1159
1191
  *
1160
- * Custom error types for better error handling
1192
+ * Custom error types for better error handling. Every API failure carries
1193
+ * the HTTP status, the machine-readable code, the request id (for support
1194
+ * correlation), and any retry hint the server sent — so callers never have
1195
+ * to guess from a bare message again.
1161
1196
  */
1162
1197
  declare class CencoriError extends Error {
1163
1198
  statusCode?: number | undefined;
1164
1199
  code?: string | undefined;
1165
- constructor(message: string, statusCode?: number | undefined, code?: string | undefined);
1200
+ options?: {
1201
+ requestId?: string | null;
1202
+ retryAfterMs?: number | null;
1203
+ errorBody?: unknown;
1204
+ } | undefined;
1205
+ constructor(message: string, statusCode?: number | undefined, code?: string | undefined, options?: {
1206
+ requestId?: string | null;
1207
+ retryAfterMs?: number | null;
1208
+ errorBody?: unknown;
1209
+ } | undefined);
1210
+ /** Request id for support correlation (X-Request-Id), when the server sent one. */
1211
+ get requestId(): string | null;
1212
+ /** Server-advised wait before retrying, when sent (Retry-After / retry_after_ms). */
1213
+ get retryAfterMs(): number | null;
1214
+ /** True for failures worth retrying: rate limits, bad gateway, unavailable, timeouts. */
1215
+ get isRetryable(): boolean;
1166
1216
  }
1167
1217
  declare class AuthenticationError extends CencoriError {
1168
- constructor(message?: string);
1218
+ constructor(message?: string, options?: {
1219
+ requestId?: string | null;
1220
+ });
1169
1221
  }
1170
1222
  declare class RateLimitError extends CencoriError {
1171
1223
  retryAfterSeconds?: number | null | undefined;
1172
- constructor(message?: string, retryAfterSeconds?: number | null | undefined);
1224
+ constructor(message?: string, retryAfterSeconds?: number | null | undefined, options?: {
1225
+ requestId?: string | null;
1226
+ errorBody?: unknown;
1227
+ });
1173
1228
  }
1174
1229
  declare class SafetyError extends CencoriError {
1175
1230
  reasons?: string[] | undefined;
1176
- constructor(message?: string, reasons?: string[] | undefined);
1231
+ constructor(message?: string, reasons?: string[] | undefined, options?: {
1232
+ requestId?: string | null;
1233
+ errorBody?: unknown;
1234
+ });
1177
1235
  }
1178
1236
 
1179
1237
  /**
1180
1238
  * Utility functions for Cencori SDK
1181
1239
  */
1182
- /**
1183
- * Fetch with automatic retry on 5xx errors
1184
- * Uses exponential backoff: 1s, 2s, 4s
1185
- */
1186
1240
  declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number): Promise<Response>;
1187
1241
 
1188
1242
  export { AINamespace, ActionsNamespace, type Agent, type AgentConfig, type AgentKey, type AgentListItem, AgentVersionsNamespace, AgentsNamespace, AuthenticationError, Cencori, CencoriConfig, CencoriEmbeddedApiError, CencoriError, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionResponse, type ChatCompletionStream, type ChatMemoryOptions, ChatNamespace, ClientTokensNamespace, ComputeNamespace, ConnectionsNamespace, type CreateAgentKeyParams, type CreateAgentParams, type CreateSessionParams, DocumentsNamespace, type EmbeddedRequestOptions, EndUsersNamespace, InstallationsNamespace, KnowledgeNamespace, McpServersNamespace, MemoryClient, ModelsNamespace, type PaginatedResponse, ProviderConnectionsNamespace, RateLimitError, RatePlansNamespace, RequestOptions, RunsNamespace, SafetyError, type Session, type SessionEvent, type SessionListParams, SessionsNamespace, SkillImportsNamespace, SkillsNamespace, StorageNamespace, TelemetryClient, type Tenant, TenantsNamespace, type TurnParams, type UnifiedModel, type UpdateAgentParams, UsageNamespace, VisionNamespace, VoiceNamespace, WebNamespace, WebhooksNamespace, WorkflowNamespace, Cencori as default, fetchWithRetry };