cencori 1.2.1 → 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.d.mts CHANGED
@@ -2,6 +2,8 @@ import { C as CencoriConfig, i as RequestOptions } from './types-kh1whvNH.mjs';
2
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-kh1whvNH.mjs';
3
3
  import { AINamespace } from './ai/index.mjs';
4
4
  export { StreamChunk } from './ai/index.mjs';
5
+ import { VisionNamespace } from './vision/index.mjs';
6
+ export { VisionClassification, VisionClassifyResult, VisionCost, VisionDescribeResult, VisionImage, VisionOcrResult, VisionProvider, VisionRequest, VisionResult, VisionTask, VisionUsage } from './vision/index.mjs';
5
7
  import { ComputeNamespace } from './compute/index.mjs';
6
8
  import { WorkflowNamespace } from './workflow/index.mjs';
7
9
  import { StorageNamespace } from './storage/index.mjs';
@@ -11,6 +13,171 @@ export { WebTelemetryPayload } from './telemetry/index.mjs';
11
13
  export { CencoriChatSettings, CencoriProvider, CencoriProviderSettings, cencori, createCencori } from './vercel/index.mjs';
12
14
  import '@ai-sdk/provider';
13
15
 
16
+ interface AgentConfig {
17
+ model: string;
18
+ system_prompt: string | null;
19
+ tools: string[];
20
+ temperature: number | null;
21
+ }
22
+ interface Agent {
23
+ id: string;
24
+ name: string;
25
+ description: string | null;
26
+ is_active: boolean;
27
+ shadow_mode: boolean;
28
+ created_at: string;
29
+ updated_at?: string;
30
+ config: AgentConfig;
31
+ }
32
+ interface AgentListItem {
33
+ id: string;
34
+ name: string;
35
+ description: string | null;
36
+ is_active: boolean;
37
+ shadow_mode: boolean;
38
+ created_at: string;
39
+ }
40
+ interface CreateAgentParams {
41
+ name: string;
42
+ description?: string;
43
+ config?: {
44
+ model?: string;
45
+ system_prompt?: string;
46
+ tools?: string[];
47
+ temperature?: number;
48
+ };
49
+ }
50
+ interface UpdateAgentParams {
51
+ name?: string;
52
+ description?: string;
53
+ is_active?: boolean;
54
+ shadow_mode?: boolean;
55
+ config?: {
56
+ model?: string;
57
+ system_prompt?: string;
58
+ tools?: string[];
59
+ temperature?: number;
60
+ };
61
+ }
62
+ interface AgentKey {
63
+ id: string;
64
+ name: string;
65
+ key_prefix: string;
66
+ full_key?: string;
67
+ environment: string;
68
+ key_type: string;
69
+ agent_id: string;
70
+ created_at: string;
71
+ }
72
+ interface CreateAgentKeyParams {
73
+ name?: string;
74
+ environment?: 'production' | 'test';
75
+ key_type?: 'secret' | 'publishable';
76
+ allowed_domains?: string[];
77
+ }
78
+ declare class AgentsNamespace {
79
+ private config;
80
+ constructor(config: Required<CencoriConfig>);
81
+ private request;
82
+ create(params: CreateAgentParams): Promise<Agent>;
83
+ list(): Promise<{
84
+ data: AgentListItem[];
85
+ }>;
86
+ get(agentId: string): Promise<Agent>;
87
+ updateConfig(agentId: string, params: UpdateAgentParams): Promise<Agent>;
88
+ delete(agentId: string): Promise<void>;
89
+ createKey(agentId: string, params?: CreateAgentKeyParams): Promise<AgentKey>;
90
+ }
91
+
92
+ interface Session {
93
+ id: string;
94
+ status: 'active' | 'paused' | 'completed' | 'failed';
95
+ turn_count: number;
96
+ created_at: string;
97
+ updated_at: string;
98
+ agent_id: string | null;
99
+ metadata: Record<string, unknown>;
100
+ total_cost: number;
101
+ }
102
+ interface SessionEvent {
103
+ id: string;
104
+ session_id: string;
105
+ turn_number: number;
106
+ sequence: number;
107
+ event_type: string;
108
+ payload: Record<string, unknown>;
109
+ created_at: string;
110
+ }
111
+ interface CreateSessionParams {
112
+ agent_id?: string;
113
+ metadata?: Record<string, unknown>;
114
+ }
115
+ interface TurnParams {
116
+ input: string | Array<Record<string, unknown>>;
117
+ tools?: Array<Record<string, unknown>>;
118
+ instructions?: string;
119
+ agent_id?: string;
120
+ model?: string;
121
+ temperature?: number;
122
+ max_output_tokens?: number;
123
+ tool_choice?: 'auto' | 'none' | 'required' | {
124
+ type: 'function';
125
+ name: string;
126
+ };
127
+ response_format?: Record<string, unknown>;
128
+ user?: string;
129
+ pause_on_tool_calls?: boolean;
130
+ }
131
+ interface ApproveRejectParams {
132
+ action_id: string;
133
+ tool_results?: Array<{
134
+ action_id: string;
135
+ output: string;
136
+ }>;
137
+ }
138
+ interface PaginatedResponse<T> {
139
+ data: T[];
140
+ pagination: {
141
+ page: number;
142
+ limit: number;
143
+ total: number;
144
+ total_pages: number;
145
+ };
146
+ }
147
+ interface SessionListParams {
148
+ page?: number;
149
+ limit?: number;
150
+ status?: 'active' | 'paused' | 'completed' | 'failed';
151
+ agent_id?: string;
152
+ }
153
+ declare class SessionsNamespace {
154
+ private config;
155
+ constructor(config: Required<CencoriConfig>);
156
+ private request;
157
+ create(params?: CreateSessionParams): Promise<Session>;
158
+ list(params?: SessionListParams): Promise<PaginatedResponse<Session>>;
159
+ get(sessionId: string): Promise<Session>;
160
+ delete(sessionId: string): Promise<{
161
+ id: string;
162
+ deleted: boolean;
163
+ }>;
164
+ submitTurn(sessionId: string, params: TurnParams): Promise<Response>;
165
+ submitTurnStream(sessionId: string, params: TurnParams): Promise<ReadableStream<Uint8Array> | null>;
166
+ getEvents(sessionId: string, params?: {
167
+ page?: number;
168
+ limit?: number;
169
+ turn_number?: number;
170
+ }): Promise<PaginatedResponse<SessionEvent>>;
171
+ approve(sessionId: string, params: ApproveRejectParams): Promise<Response>;
172
+ approveStream(sessionId: string, params: ApproveRejectParams): Promise<ReadableStream<Uint8Array> | null>;
173
+ reject(sessionId: string, params: ApproveRejectParams): Promise<{
174
+ id: string;
175
+ action_id: string;
176
+ resolution: string;
177
+ status: string;
178
+ }>;
179
+ }
180
+
14
181
  /**
15
182
  * Cencori - Unified AI Infrastructure SDK
16
183
  *
@@ -41,12 +208,40 @@ import '@ai-sdk/provider';
41
208
  declare class Cencori {
42
209
  private config;
43
210
  /**
44
- * AI Gateway - Chat, completions, embeddings with security & observability
211
+ * AI Gateway - Chat, completions, embeddings, responses with security & observability
45
212
  *
46
213
  * @example
47
214
  * await cencori.ai.chat({ model: 'gpt-4o', messages: [...] });
48
215
  */
49
216
  readonly ai: AINamespace;
217
+ /**
218
+ * Vision - Analyze, describe, OCR, and classify images
219
+ *
220
+ * @example
221
+ * const result = await cencori.vision.analyze({
222
+ * image: { url: 'https://example.com/photo.jpg' },
223
+ * prompt: 'What breed is this dog?'
224
+ * });
225
+ *
226
+ * @example
227
+ * const { text } = await cencori.vision.ocr({
228
+ * image: { base64, mimeType: 'image/png' }
229
+ * });
230
+ */
231
+ readonly vision: VisionNamespace;
232
+ /**
233
+ * Agents - Create and manage AI agents programmatically.
234
+ *
235
+ * @example
236
+ * const agent = await cencori.agents.create({
237
+ * name: 'my-agent',
238
+ * config: { model: 'gpt-4o', system_prompt: 'You are a helpful assistant.' }
239
+ * });
240
+ *
241
+ * @example
242
+ * const key = await cencori.agents.createKey(agent.id, { name: 'prod-key' });
243
+ */
244
+ readonly agents: AgentsNamespace;
50
245
  /**
51
246
  * Compute - Serverless functions & GPU access
52
247
  *
@@ -82,6 +277,15 @@ declare class Cencori {
82
277
  * await cencori.memory.search({ namespace: 'conversations', query: '...' });
83
278
  */
84
279
  readonly memory: MemoryClient;
280
+ /**
281
+ * Sessions - Durable execution sessions for AI agents with pause/resume and event sourcing
282
+ *
283
+ * @example
284
+ * const sessions = await cencori.sessions.list({ status: 'active' });
285
+ * const session = await cencori.sessions.create({ agent_id: 'ag_...' });
286
+ * await cencori.sessions.submitTurn(session.id, { input: 'Hello' });
287
+ */
288
+ readonly sessions: SessionsNamespace;
85
289
  /**
86
290
  * Telemetry - Report web traffic from your app to the Cencori dashboard
87
291
  *
@@ -165,4 +369,4 @@ declare class SafetyError extends CencoriError {
165
369
  */
166
370
  declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number): Promise<Response>;
167
371
 
168
- export { AINamespace, AuthenticationError, Cencori, CencoriConfig, CencoriError, ComputeNamespace, MemoryClient, RateLimitError, RequestOptions, SafetyError, StorageNamespace, TelemetryClient, WorkflowNamespace, Cencori as default, fetchWithRetry };
372
+ export { AINamespace, type Agent, type AgentConfig, type AgentKey, type AgentListItem, AgentsNamespace, AuthenticationError, Cencori, CencoriConfig, CencoriError, ComputeNamespace, type CreateAgentKeyParams, type CreateAgentParams, type CreateSessionParams, MemoryClient, type PaginatedResponse, RateLimitError, RequestOptions, SafetyError, type Session, type SessionEvent, type SessionListParams, SessionsNamespace, StorageNamespace, TelemetryClient, type TurnParams, type UpdateAgentParams, VisionNamespace, WorkflowNamespace, Cencori as default, fetchWithRetry };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import { C as CencoriConfig, i as RequestOptions } from './types-kh1whvNH.js';
2
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-kh1whvNH.js';
3
3
  import { AINamespace } from './ai/index.js';
4
4
  export { StreamChunk } from './ai/index.js';
5
+ import { VisionNamespace } from './vision/index.js';
6
+ export { VisionClassification, VisionClassifyResult, VisionCost, VisionDescribeResult, VisionImage, VisionOcrResult, VisionProvider, VisionRequest, VisionResult, VisionTask, VisionUsage } from './vision/index.js';
5
7
  import { ComputeNamespace } from './compute/index.js';
6
8
  import { WorkflowNamespace } from './workflow/index.js';
7
9
  import { StorageNamespace } from './storage/index.js';
@@ -11,6 +13,171 @@ export { WebTelemetryPayload } from './telemetry/index.js';
11
13
  export { CencoriChatSettings, CencoriProvider, CencoriProviderSettings, cencori, createCencori } from './vercel/index.js';
12
14
  import '@ai-sdk/provider';
13
15
 
16
+ interface AgentConfig {
17
+ model: string;
18
+ system_prompt: string | null;
19
+ tools: string[];
20
+ temperature: number | null;
21
+ }
22
+ interface Agent {
23
+ id: string;
24
+ name: string;
25
+ description: string | null;
26
+ is_active: boolean;
27
+ shadow_mode: boolean;
28
+ created_at: string;
29
+ updated_at?: string;
30
+ config: AgentConfig;
31
+ }
32
+ interface AgentListItem {
33
+ id: string;
34
+ name: string;
35
+ description: string | null;
36
+ is_active: boolean;
37
+ shadow_mode: boolean;
38
+ created_at: string;
39
+ }
40
+ interface CreateAgentParams {
41
+ name: string;
42
+ description?: string;
43
+ config?: {
44
+ model?: string;
45
+ system_prompt?: string;
46
+ tools?: string[];
47
+ temperature?: number;
48
+ };
49
+ }
50
+ interface UpdateAgentParams {
51
+ name?: string;
52
+ description?: string;
53
+ is_active?: boolean;
54
+ shadow_mode?: boolean;
55
+ config?: {
56
+ model?: string;
57
+ system_prompt?: string;
58
+ tools?: string[];
59
+ temperature?: number;
60
+ };
61
+ }
62
+ interface AgentKey {
63
+ id: string;
64
+ name: string;
65
+ key_prefix: string;
66
+ full_key?: string;
67
+ environment: string;
68
+ key_type: string;
69
+ agent_id: string;
70
+ created_at: string;
71
+ }
72
+ interface CreateAgentKeyParams {
73
+ name?: string;
74
+ environment?: 'production' | 'test';
75
+ key_type?: 'secret' | 'publishable';
76
+ allowed_domains?: string[];
77
+ }
78
+ declare class AgentsNamespace {
79
+ private config;
80
+ constructor(config: Required<CencoriConfig>);
81
+ private request;
82
+ create(params: CreateAgentParams): Promise<Agent>;
83
+ list(): Promise<{
84
+ data: AgentListItem[];
85
+ }>;
86
+ get(agentId: string): Promise<Agent>;
87
+ updateConfig(agentId: string, params: UpdateAgentParams): Promise<Agent>;
88
+ delete(agentId: string): Promise<void>;
89
+ createKey(agentId: string, params?: CreateAgentKeyParams): Promise<AgentKey>;
90
+ }
91
+
92
+ interface Session {
93
+ id: string;
94
+ status: 'active' | 'paused' | 'completed' | 'failed';
95
+ turn_count: number;
96
+ created_at: string;
97
+ updated_at: string;
98
+ agent_id: string | null;
99
+ metadata: Record<string, unknown>;
100
+ total_cost: number;
101
+ }
102
+ interface SessionEvent {
103
+ id: string;
104
+ session_id: string;
105
+ turn_number: number;
106
+ sequence: number;
107
+ event_type: string;
108
+ payload: Record<string, unknown>;
109
+ created_at: string;
110
+ }
111
+ interface CreateSessionParams {
112
+ agent_id?: string;
113
+ metadata?: Record<string, unknown>;
114
+ }
115
+ interface TurnParams {
116
+ input: string | Array<Record<string, unknown>>;
117
+ tools?: Array<Record<string, unknown>>;
118
+ instructions?: string;
119
+ agent_id?: string;
120
+ model?: string;
121
+ temperature?: number;
122
+ max_output_tokens?: number;
123
+ tool_choice?: 'auto' | 'none' | 'required' | {
124
+ type: 'function';
125
+ name: string;
126
+ };
127
+ response_format?: Record<string, unknown>;
128
+ user?: string;
129
+ pause_on_tool_calls?: boolean;
130
+ }
131
+ interface ApproveRejectParams {
132
+ action_id: string;
133
+ tool_results?: Array<{
134
+ action_id: string;
135
+ output: string;
136
+ }>;
137
+ }
138
+ interface PaginatedResponse<T> {
139
+ data: T[];
140
+ pagination: {
141
+ page: number;
142
+ limit: number;
143
+ total: number;
144
+ total_pages: number;
145
+ };
146
+ }
147
+ interface SessionListParams {
148
+ page?: number;
149
+ limit?: number;
150
+ status?: 'active' | 'paused' | 'completed' | 'failed';
151
+ agent_id?: string;
152
+ }
153
+ declare class SessionsNamespace {
154
+ private config;
155
+ constructor(config: Required<CencoriConfig>);
156
+ private request;
157
+ create(params?: CreateSessionParams): Promise<Session>;
158
+ list(params?: SessionListParams): Promise<PaginatedResponse<Session>>;
159
+ get(sessionId: string): Promise<Session>;
160
+ delete(sessionId: string): Promise<{
161
+ id: string;
162
+ deleted: boolean;
163
+ }>;
164
+ submitTurn(sessionId: string, params: TurnParams): Promise<Response>;
165
+ submitTurnStream(sessionId: string, params: TurnParams): Promise<ReadableStream<Uint8Array> | null>;
166
+ getEvents(sessionId: string, params?: {
167
+ page?: number;
168
+ limit?: number;
169
+ turn_number?: number;
170
+ }): Promise<PaginatedResponse<SessionEvent>>;
171
+ approve(sessionId: string, params: ApproveRejectParams): Promise<Response>;
172
+ approveStream(sessionId: string, params: ApproveRejectParams): Promise<ReadableStream<Uint8Array> | null>;
173
+ reject(sessionId: string, params: ApproveRejectParams): Promise<{
174
+ id: string;
175
+ action_id: string;
176
+ resolution: string;
177
+ status: string;
178
+ }>;
179
+ }
180
+
14
181
  /**
15
182
  * Cencori - Unified AI Infrastructure SDK
16
183
  *
@@ -41,12 +208,40 @@ import '@ai-sdk/provider';
41
208
  declare class Cencori {
42
209
  private config;
43
210
  /**
44
- * AI Gateway - Chat, completions, embeddings with security & observability
211
+ * AI Gateway - Chat, completions, embeddings, responses with security & observability
45
212
  *
46
213
  * @example
47
214
  * await cencori.ai.chat({ model: 'gpt-4o', messages: [...] });
48
215
  */
49
216
  readonly ai: AINamespace;
217
+ /**
218
+ * Vision - Analyze, describe, OCR, and classify images
219
+ *
220
+ * @example
221
+ * const result = await cencori.vision.analyze({
222
+ * image: { url: 'https://example.com/photo.jpg' },
223
+ * prompt: 'What breed is this dog?'
224
+ * });
225
+ *
226
+ * @example
227
+ * const { text } = await cencori.vision.ocr({
228
+ * image: { base64, mimeType: 'image/png' }
229
+ * });
230
+ */
231
+ readonly vision: VisionNamespace;
232
+ /**
233
+ * Agents - Create and manage AI agents programmatically.
234
+ *
235
+ * @example
236
+ * const agent = await cencori.agents.create({
237
+ * name: 'my-agent',
238
+ * config: { model: 'gpt-4o', system_prompt: 'You are a helpful assistant.' }
239
+ * });
240
+ *
241
+ * @example
242
+ * const key = await cencori.agents.createKey(agent.id, { name: 'prod-key' });
243
+ */
244
+ readonly agents: AgentsNamespace;
50
245
  /**
51
246
  * Compute - Serverless functions & GPU access
52
247
  *
@@ -82,6 +277,15 @@ declare class Cencori {
82
277
  * await cencori.memory.search({ namespace: 'conversations', query: '...' });
83
278
  */
84
279
  readonly memory: MemoryClient;
280
+ /**
281
+ * Sessions - Durable execution sessions for AI agents with pause/resume and event sourcing
282
+ *
283
+ * @example
284
+ * const sessions = await cencori.sessions.list({ status: 'active' });
285
+ * const session = await cencori.sessions.create({ agent_id: 'ag_...' });
286
+ * await cencori.sessions.submitTurn(session.id, { input: 'Hello' });
287
+ */
288
+ readonly sessions: SessionsNamespace;
85
289
  /**
86
290
  * Telemetry - Report web traffic from your app to the Cencori dashboard
87
291
  *
@@ -165,4 +369,4 @@ declare class SafetyError extends CencoriError {
165
369
  */
166
370
  declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number): Promise<Response>;
167
371
 
168
- export { AINamespace, AuthenticationError, Cencori, CencoriConfig, CencoriError, ComputeNamespace, MemoryClient, RateLimitError, RequestOptions, SafetyError, StorageNamespace, TelemetryClient, WorkflowNamespace, Cencori as default, fetchWithRetry };
372
+ export { AINamespace, type Agent, type AgentConfig, type AgentKey, type AgentListItem, AgentsNamespace, AuthenticationError, Cencori, CencoriConfig, CencoriError, ComputeNamespace, type CreateAgentKeyParams, type CreateAgentParams, type CreateSessionParams, MemoryClient, type PaginatedResponse, RateLimitError, RequestOptions, SafetyError, type Session, type SessionEvent, type SessionListParams, SessionsNamespace, StorageNamespace, TelemetryClient, type TurnParams, type UpdateAgentParams, VisionNamespace, WorkflowNamespace, Cencori as default, fetchWithRetry };