cencori 1.7.0 → 1.7.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/ai/index.d.mts +1 -1
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +7 -4
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/index.mjs +7 -4
- package/dist/ai/index.mjs.map +1 -1
- package/dist/compute/index.d.mts +1 -1
- package/dist/compute/index.d.ts +1 -1
- package/dist/documents/index.d.mts +1 -1
- package/dist/documents/index.d.ts +1 -1
- package/dist/index.d.mts +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -16
- package/dist/index.mjs.map +1 -1
- package/dist/memory/index.d.mts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/storage/index.d.mts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/telemetry/index.d.mts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/{types-xSwLRBZw.d.mts → types-CZSIg4JQ.d.mts} +8 -3
- package/dist/{types-xSwLRBZw.d.ts → types-CZSIg4JQ.d.ts} +8 -3
- package/dist/vision/index.d.mts +1 -1
- package/dist/vision/index.d.ts +1 -1
- package/dist/voice/index.d.mts +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/web/index.d.mts +1 -1
- package/dist/web/index.d.ts +1 -1
- package/dist/workflow/index.d.mts +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CencoriConfig, i as RequestOptions } from './types-
|
|
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-
|
|
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';
|
|
3
3
|
import { AINamespace } from './ai/index.js';
|
|
4
4
|
export { StreamChunk } from './ai/index.js';
|
|
5
5
|
import { VisionNamespace } from './vision/index.js';
|
|
@@ -103,6 +103,9 @@ interface Session {
|
|
|
103
103
|
created_at: string;
|
|
104
104
|
updated_at: string;
|
|
105
105
|
agent_id: string | null;
|
|
106
|
+
tenant_id: string | null;
|
|
107
|
+
external_user_id: string | null;
|
|
108
|
+
installation_id: string | null;
|
|
106
109
|
metadata: Record<string, unknown>;
|
|
107
110
|
total_cost: number;
|
|
108
111
|
}
|
|
@@ -117,6 +120,9 @@ interface SessionEvent {
|
|
|
117
120
|
}
|
|
118
121
|
interface CreateSessionParams {
|
|
119
122
|
agent_id?: string;
|
|
123
|
+
tenant_id?: string;
|
|
124
|
+
external_user_id?: string;
|
|
125
|
+
installation_id?: string;
|
|
120
126
|
metadata?: Record<string, unknown>;
|
|
121
127
|
}
|
|
122
128
|
interface TurnParams {
|
|
@@ -156,6 +162,7 @@ interface SessionListParams {
|
|
|
156
162
|
limit?: number;
|
|
157
163
|
status?: 'active' | 'paused' | 'completed' | 'failed';
|
|
158
164
|
agent_id?: string;
|
|
165
|
+
tenant_id?: string;
|
|
159
166
|
}
|
|
160
167
|
declare class SessionsNamespace {
|
|
161
168
|
private config;
|
|
@@ -310,6 +317,18 @@ declare class ChatNamespace {
|
|
|
310
317
|
constructor(config: Required<CencoriConfig>);
|
|
311
318
|
}
|
|
312
319
|
|
|
320
|
+
interface EmbeddedRequestOptions {
|
|
321
|
+
signal?: AbortSignal;
|
|
322
|
+
}
|
|
323
|
+
declare class CencoriEmbeddedApiError extends Error {
|
|
324
|
+
readonly status: number;
|
|
325
|
+
readonly code: string | null;
|
|
326
|
+
readonly requestId: string | null;
|
|
327
|
+
readonly type: string | null;
|
|
328
|
+
readonly param: string | null;
|
|
329
|
+
readonly name = "CencoriEmbeddedApiError";
|
|
330
|
+
constructor(message: string, status: number, code: string | null, requestId: string | null, type: string | null, param: string | null);
|
|
331
|
+
}
|
|
313
332
|
interface Tenant {
|
|
314
333
|
id: string;
|
|
315
334
|
external_id: string;
|
|
@@ -337,7 +356,7 @@ declare class TenantsNamespace {
|
|
|
337
356
|
data: Tenant[];
|
|
338
357
|
next_cursor: string | null;
|
|
339
358
|
}>;
|
|
340
|
-
get(tenantId: string): Promise<Tenant>;
|
|
359
|
+
get(tenantId: string, options?: EmbeddedRequestOptions): Promise<Tenant>;
|
|
341
360
|
update(tenantId: string, params: {
|
|
342
361
|
name?: string;
|
|
343
362
|
metadata?: Record<string, unknown>;
|
|
@@ -482,7 +501,7 @@ declare class AgentVersionsNamespace {
|
|
|
482
501
|
test(agentId: string, version: string, params?: {
|
|
483
502
|
input?: string;
|
|
484
503
|
test_connection_ids?: string[];
|
|
485
|
-
}): Promise<unknown>;
|
|
504
|
+
}, options?: EmbeddedRequestOptions): Promise<unknown>;
|
|
486
505
|
deprecate(agentId: string, version: string): Promise<unknown>;
|
|
487
506
|
retire(agentId: string, version: string): Promise<unknown>;
|
|
488
507
|
catalog(params?: {
|
|
@@ -528,8 +547,8 @@ declare class RunsNamespace {
|
|
|
528
547
|
input?: unknown;
|
|
529
548
|
response_format?: unknown;
|
|
530
549
|
session_id?: string;
|
|
531
|
-
}, idempotencyKey?: string): Promise<unknown>;
|
|
532
|
-
get(runId: string): Promise<unknown>;
|
|
550
|
+
}, idempotencyKey?: string, options?: EmbeddedRequestOptions): Promise<unknown>;
|
|
551
|
+
get(runId: string, options?: EmbeddedRequestOptions): Promise<unknown>;
|
|
533
552
|
events(runId: string, params?: {
|
|
534
553
|
after?: string;
|
|
535
554
|
limit?: number;
|
|
@@ -537,7 +556,7 @@ declare class RunsNamespace {
|
|
|
537
556
|
data: unknown[];
|
|
538
557
|
next_cursor: string | null;
|
|
539
558
|
}>;
|
|
540
|
-
cancel(runId: string): Promise<unknown>;
|
|
559
|
+
cancel(runId: string, options?: EmbeddedRequestOptions): Promise<unknown>;
|
|
541
560
|
delegate(runId: string, params: {
|
|
542
561
|
agent_version_id: string;
|
|
543
562
|
input?: unknown;
|
|
@@ -1114,4 +1133,4 @@ declare class SafetyError extends CencoriError {
|
|
|
1114
1133
|
*/
|
|
1115
1134
|
declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number): Promise<Response>;
|
|
1116
1135
|
|
|
1117
|
-
export { AINamespace, ActionsNamespace, type Agent, type AgentConfig, type AgentKey, type AgentListItem, AgentVersionsNamespace, AgentsNamespace, AuthenticationError, Cencori, CencoriConfig, CencoriError, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionResponse, type ChatCompletionStream, type ChatMemoryOptions, ChatNamespace, ClientTokensNamespace, ComputeNamespace, ConnectionsNamespace, type CreateAgentKeyParams, type CreateAgentParams, type CreateSessionParams, DocumentsNamespace, 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 };
|
|
1136
|
+
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.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(src_exports, {
|
|
|
26
26
|
AgentsNamespace: () => AgentsNamespace,
|
|
27
27
|
AuthenticationError: () => AuthenticationError,
|
|
28
28
|
Cencori: () => Cencori,
|
|
29
|
+
CencoriEmbeddedApiError: () => CencoriEmbeddedApiError,
|
|
29
30
|
CencoriError: () => CencoriError,
|
|
30
31
|
ChatNamespace: () => ChatNamespace,
|
|
31
32
|
ClientTokensNamespace: () => ClientTokensNamespace,
|
|
@@ -265,6 +266,7 @@ var AINamespace = class {
|
|
|
265
266
|
];
|
|
266
267
|
const response = await fetch(`${this.config.baseUrl}/api/ai/chat`, {
|
|
267
268
|
method: "POST",
|
|
269
|
+
signal: request2.signal,
|
|
268
270
|
headers: {
|
|
269
271
|
"CENCORI_API_KEY": this.config.apiKey,
|
|
270
272
|
"Content-Type": "application/json",
|
|
@@ -308,10 +310,12 @@ var AINamespace = class {
|
|
|
308
310
|
return {
|
|
309
311
|
object: parsedObject,
|
|
310
312
|
usage: {
|
|
311
|
-
promptTokens: data.usage?.prompt_tokens ??
|
|
312
|
-
completionTokens: data.usage?.completion_tokens ??
|
|
313
|
-
totalTokens: data.usage?.total_tokens ??
|
|
314
|
-
}
|
|
313
|
+
promptTokens: data.usage?.prompt_tokens ?? null,
|
|
314
|
+
completionTokens: data.usage?.completion_tokens ?? null,
|
|
315
|
+
totalTokens: data.usage?.total_tokens ?? null
|
|
316
|
+
},
|
|
317
|
+
costUsd: data.cost_usd ?? null,
|
|
318
|
+
requestId: response.headers.get("X-Request-Id")
|
|
315
319
|
};
|
|
316
320
|
}
|
|
317
321
|
/**
|
|
@@ -989,6 +993,7 @@ var SessionsNamespace = class {
|
|
|
989
993
|
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
990
994
|
if (params?.status) searchParams.set("status", params.status);
|
|
991
995
|
if (params?.agent_id) searchParams.set("agent_id", params.agent_id);
|
|
996
|
+
if (params?.tenant_id) searchParams.set("tenant_id", params.tenant_id);
|
|
992
997
|
const qs2 = searchParams.toString();
|
|
993
998
|
return this.request("GET", `/v1/sessions${qs2 ? `?${qs2}` : ""}`);
|
|
994
999
|
}
|
|
@@ -1828,9 +1833,21 @@ var WebNamespace = class {
|
|
|
1828
1833
|
};
|
|
1829
1834
|
|
|
1830
1835
|
// src/embedded/index.ts
|
|
1831
|
-
|
|
1836
|
+
var CencoriEmbeddedApiError = class extends Error {
|
|
1837
|
+
constructor(message, status, code, requestId, type, param) {
|
|
1838
|
+
super(`Cencori API error: ${message}`);
|
|
1839
|
+
this.status = status;
|
|
1840
|
+
this.code = code;
|
|
1841
|
+
this.requestId = requestId;
|
|
1842
|
+
this.type = type;
|
|
1843
|
+
this.param = param;
|
|
1844
|
+
this.name = "CencoriEmbeddedApiError";
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
async function request(config, method, path, body, extraHeaders, options) {
|
|
1832
1848
|
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
1833
1849
|
method,
|
|
1850
|
+
signal: options?.signal,
|
|
1834
1851
|
headers: {
|
|
1835
1852
|
"CENCORI_API_KEY": config.apiKey,
|
|
1836
1853
|
"Content-Type": "application/json",
|
|
@@ -1842,7 +1859,8 @@ async function request(config, method, path, body, extraHeaders) {
|
|
|
1842
1859
|
if (!response.ok) {
|
|
1843
1860
|
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1844
1861
|
const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message || response.statusText;
|
|
1845
|
-
|
|
1862
|
+
const details = typeof errorData.error === "object" ? errorData.error : null;
|
|
1863
|
+
throw new CencoriEmbeddedApiError(message, response.status, details?.code ?? null, details?.request_id ?? response.headers.get("X-Request-Id"), details?.type ?? null, details?.param ?? null);
|
|
1846
1864
|
}
|
|
1847
1865
|
if (response.status === 204) return void 0;
|
|
1848
1866
|
return response.json();
|
|
@@ -1865,8 +1883,8 @@ var TenantsNamespace = class {
|
|
|
1865
1883
|
list(params) {
|
|
1866
1884
|
return request(this.config, "GET", `/v1/tenants${qs({ limit: params?.limit, cursor: params?.cursor, status: params?.status })}`);
|
|
1867
1885
|
}
|
|
1868
|
-
get(tenantId) {
|
|
1869
|
-
return request(this.config, "GET", `/v1/tenants/${tenantId}
|
|
1886
|
+
get(tenantId, options) {
|
|
1887
|
+
return request(this.config, "GET", `/v1/tenants/${tenantId}`, void 0, void 0, options);
|
|
1870
1888
|
}
|
|
1871
1889
|
update(tenantId, params) {
|
|
1872
1890
|
return request(this.config, "PATCH", `/v1/tenants/${tenantId}`, params);
|
|
@@ -1969,8 +1987,8 @@ var AgentVersionsNamespace = class {
|
|
|
1969
1987
|
publish(agentId, version) {
|
|
1970
1988
|
return request(this.config, "POST", `/v1/agents/${agentId}/versions/${version}/publish`, {});
|
|
1971
1989
|
}
|
|
1972
|
-
test(agentId, version, params) {
|
|
1973
|
-
return request(this.config, "POST", `/v1/agents/${agentId}/versions/${version}/test`, params ?? {});
|
|
1990
|
+
test(agentId, version, params, options) {
|
|
1991
|
+
return request(this.config, "POST", `/v1/agents/${agentId}/versions/${version}/test`, params ?? {}, void 0, options);
|
|
1974
1992
|
}
|
|
1975
1993
|
deprecate(agentId, version) {
|
|
1976
1994
|
return request(this.config, "POST", `/v1/agents/${agentId}/versions/${version}/deprecate`, {});
|
|
@@ -2012,17 +2030,17 @@ var RunsNamespace = class {
|
|
|
2012
2030
|
constructor(config) {
|
|
2013
2031
|
this.config = config;
|
|
2014
2032
|
}
|
|
2015
|
-
create(agentId, params, idempotencyKey) {
|
|
2016
|
-
return request(this.config, "POST", `/v1/agents/${agentId}/runs`, params, idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0);
|
|
2033
|
+
create(agentId, params, idempotencyKey, options) {
|
|
2034
|
+
return request(this.config, "POST", `/v1/agents/${agentId}/runs`, params, idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0, options);
|
|
2017
2035
|
}
|
|
2018
|
-
get(runId) {
|
|
2019
|
-
return request(this.config, "GET", `/v1/runs/${runId}
|
|
2036
|
+
get(runId, options) {
|
|
2037
|
+
return request(this.config, "GET", `/v1/runs/${runId}`, void 0, void 0, options);
|
|
2020
2038
|
}
|
|
2021
2039
|
events(runId, params) {
|
|
2022
2040
|
return request(this.config, "GET", `/v1/runs/${runId}/events${qs({ after: params?.after, limit: params?.limit })}`);
|
|
2023
2041
|
}
|
|
2024
|
-
cancel(runId) {
|
|
2025
|
-
return request(this.config, "POST", `/v1/runs/${runId}/cancel`, {});
|
|
2042
|
+
cancel(runId, options) {
|
|
2043
|
+
return request(this.config, "POST", `/v1/runs/${runId}/cancel`, {}, void 0, options);
|
|
2026
2044
|
}
|
|
2027
2045
|
delegate(runId, params, idempotencyKey) {
|
|
2028
2046
|
return request(this.config, "POST", `/v1/runs/${runId}/delegate`, params, idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0);
|
|
@@ -2820,6 +2838,7 @@ cencori.chat = cencori;
|
|
|
2820
2838
|
AgentsNamespace,
|
|
2821
2839
|
AuthenticationError,
|
|
2822
2840
|
Cencori,
|
|
2841
|
+
CencoriEmbeddedApiError,
|
|
2823
2842
|
CencoriError,
|
|
2824
2843
|
ChatNamespace,
|
|
2825
2844
|
ClientTokensNamespace,
|