cencori 1.12.0 → 1.13.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/agents/index.d.mts +119 -1
- package/dist/agents/index.d.ts +119 -1
- package/dist/agents/index.js +365 -44
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/index.mjs +353 -44
- package/dist/agents/index.mjs.map +1 -1
- package/dist/react/index.d.mts +9 -3
- package/dist/react/index.d.ts +9 -3
- package/dist/react/index.js +191 -76
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +192 -77
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -6
package/dist/agents/index.d.mts
CHANGED
|
@@ -117,6 +117,111 @@ interface FunctionTool<Ctx = unknown> {
|
|
|
117
117
|
*/
|
|
118
118
|
declare function tool<S extends SchemaLike, Ctx = unknown, Out = unknown>(options: ToolOptions<S, Ctx, Out>): FunctionTool<Ctx>;
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* MCP servers as agent tools.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* const linear = new MCPServerStreamableHttp({ url: 'https://mcp.linear.app/mcp', headers: { Authorization: `Bearer ${token}` } });
|
|
125
|
+
* const files = new MCPServerStdio({ command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', './docs'] });
|
|
126
|
+
* const agent = new Agent({ name: 'Ops', mcpServers: [linear, files] });
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* Servers connect from your process, like your other tools: their
|
|
130
|
+
* credentials never reach Cencori. Their tools join the agent's own, with the
|
|
131
|
+
* same argument checks, approvals and traces.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
interface MCPTool {
|
|
135
|
+
name: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
inputSchema?: JsonSchema;
|
|
138
|
+
annotations?: {
|
|
139
|
+
readOnlyHint?: boolean;
|
|
140
|
+
destructiveHint?: boolean;
|
|
141
|
+
idempotentHint?: boolean;
|
|
142
|
+
openWorldHint?: boolean;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface MCPServerOptions {
|
|
146
|
+
/** A name for traces and to keep tool names apart between servers. Default from the URL or command. */
|
|
147
|
+
name?: string;
|
|
148
|
+
/** Only these tools (by their MCP name). Default: all. */
|
|
149
|
+
allowedTools?: string[];
|
|
150
|
+
/**
|
|
151
|
+
* Ask a person before calling: true for every tool, a list of tool names,
|
|
152
|
+
* or a function. Tools marked destructive by the server always ask unless
|
|
153
|
+
* this is false.
|
|
154
|
+
*/
|
|
155
|
+
requireApproval?: boolean | string[] | ((tool: MCPTool) => boolean);
|
|
156
|
+
/** Keep the tools list after the first fetch (default true). */
|
|
157
|
+
cacheToolsList?: boolean;
|
|
158
|
+
/** Per request, in ms. Default 30000. */
|
|
159
|
+
timeoutMs?: number;
|
|
160
|
+
}
|
|
161
|
+
/** What an agent needs from an MCP server. */
|
|
162
|
+
interface MCPServer {
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly options: MCPServerOptions;
|
|
165
|
+
connect(): Promise<void>;
|
|
166
|
+
listTools(): Promise<MCPTool[]>;
|
|
167
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
168
|
+
close(): Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
interface MCPCallResult {
|
|
171
|
+
content?: Array<{
|
|
172
|
+
type: string;
|
|
173
|
+
text?: string;
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
}>;
|
|
176
|
+
structuredContent?: unknown;
|
|
177
|
+
isError?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface MCPServerStreamableHttpOptions extends MCPServerOptions {
|
|
180
|
+
url: string;
|
|
181
|
+
/** Sent on every request: auth goes here. */
|
|
182
|
+
headers?: Record<string, string>;
|
|
183
|
+
fetch?: typeof fetch;
|
|
184
|
+
}
|
|
185
|
+
/** A remote MCP server over Streamable HTTP. Speaks stateless MCP, and falls back to the session handshake for older servers. */
|
|
186
|
+
declare class MCPServerStreamableHttp implements MCPServer {
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly options: MCPServerStreamableHttpOptions;
|
|
189
|
+
private mode;
|
|
190
|
+
private sessionHeaders;
|
|
191
|
+
private tools;
|
|
192
|
+
constructor(options: MCPServerStreamableHttpOptions);
|
|
193
|
+
connect(): Promise<void>;
|
|
194
|
+
listTools(): Promise<MCPTool[]>;
|
|
195
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
196
|
+
close(): Promise<void>;
|
|
197
|
+
private request;
|
|
198
|
+
private handshake;
|
|
199
|
+
private post;
|
|
200
|
+
}
|
|
201
|
+
interface MCPServerStdioOptions extends MCPServerOptions {
|
|
202
|
+
command: string;
|
|
203
|
+
args?: string[];
|
|
204
|
+
env?: Record<string, string>;
|
|
205
|
+
cwd?: string;
|
|
206
|
+
}
|
|
207
|
+
/** A local MCP server started as a process (Node only). */
|
|
208
|
+
declare class MCPServerStdio implements MCPServer {
|
|
209
|
+
readonly name: string;
|
|
210
|
+
readonly options: MCPServerStdioOptions;
|
|
211
|
+
private child;
|
|
212
|
+
private starting;
|
|
213
|
+
private pending;
|
|
214
|
+
private tools;
|
|
215
|
+
private stderr;
|
|
216
|
+
constructor(options: MCPServerStdioOptions);
|
|
217
|
+
connect(): Promise<void>;
|
|
218
|
+
listTools(): Promise<MCPTool[]>;
|
|
219
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
220
|
+
close(): Promise<void>;
|
|
221
|
+
private start;
|
|
222
|
+
private request;
|
|
223
|
+
}
|
|
224
|
+
|
|
120
225
|
interface TransportOptions {
|
|
121
226
|
/** Secret project key (csk_...). Defaults to the CENCORI_API_KEY environment variable. */
|
|
122
227
|
apiKey?: string;
|
|
@@ -390,6 +495,12 @@ interface AgentOptions<Ctx = unknown, Out = string> {
|
|
|
390
495
|
* add here run in your process on top. Usually set with Agent.fromCencori().
|
|
391
496
|
*/
|
|
392
497
|
cencoriAgentId?: string;
|
|
498
|
+
/**
|
|
499
|
+
* MCP servers whose tools this agent can use, next to its own. They connect
|
|
500
|
+
* from your process (MCPServerStreamableHttp for remote servers,
|
|
501
|
+
* MCPServerStdio for local ones).
|
|
502
|
+
*/
|
|
503
|
+
mcpServers?: MCPServer[];
|
|
393
504
|
}
|
|
394
505
|
/** The model an agent uses when none is given: GPT OSS 120B on Cerebras, chosen for speed. */
|
|
395
506
|
declare const DEFAULT_MODEL = "gpt-oss-120b";
|
|
@@ -419,6 +530,7 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
419
530
|
readonly outputGuardrails: OutputGuardrail<Ctx>[];
|
|
420
531
|
readonly widgets: boolean;
|
|
421
532
|
readonly cencoriAgentId?: string;
|
|
533
|
+
readonly mcpServers: MCPServer[];
|
|
422
534
|
constructor(options: AgentOptions<Ctx, Out>);
|
|
423
535
|
/** A copy with some options changed. */
|
|
424
536
|
clone(overrides: Partial<AgentOptions<Ctx, Out>>): Agent<Ctx, Out>;
|
|
@@ -435,6 +547,12 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
435
547
|
static fromCencori<Ctx = unknown>(agentId: string, options?: Omit<AgentOptions<Ctx, string>, 'cencoriAgentId' | 'name'> & {
|
|
436
548
|
name?: string;
|
|
437
549
|
}): Agent<Ctx, string>;
|
|
550
|
+
/**
|
|
551
|
+
* Every tool this agent can call: its own, then its MCP servers' (fetched
|
|
552
|
+
* from each server, once per server unless it says otherwise). An MCP tool
|
|
553
|
+
* whose name is taken gets its server's name in front.
|
|
554
|
+
*/
|
|
555
|
+
resolveTools(): Promise<FunctionTool<Ctx>[]>;
|
|
438
556
|
/** The tool name a handoff to this agent goes by. */
|
|
439
557
|
static handoffToolName(agent: Agent<any>): string;
|
|
440
558
|
/** Instructions for this run, resolving a function if given. */
|
|
@@ -521,4 +639,4 @@ declare function toAgentChatStream(streamed: StreamedRunResult<unknown>, options
|
|
|
521
639
|
secret: string;
|
|
522
640
|
}): ReadableStream<Uint8Array>;
|
|
523
641
|
|
|
524
|
-
export { Agent, type AgentChatHandlerOptions, type AgentOptions, AgentsError, CencoriRunError, DEFAULT_MODEL, type FunctionTool, type GuardrailResult, GuardrailTripwireTriggered, type InputGuardrail, type JsonSchema, MaxTurnsExceededError, type ModelSettings, type NeedsApproval, type OutputGuardrail, type RunContext, type RunItem, type RunOptions, type RunResult, RunState, type RunStreamEvent, type SchemaLike, SchemaValidationError, type StandardSchemaV1, type StreamedRunResult, type ToolApprovalItem, type ToolOptions, type Usage, WidgetNode, createAgentChatHandler, run, toAgentChatStream, tool };
|
|
642
|
+
export { Agent, type AgentChatHandlerOptions, type AgentOptions, AgentsError, CencoriRunError, DEFAULT_MODEL, type FunctionTool, type GuardrailResult, GuardrailTripwireTriggered, type InputGuardrail, type JsonSchema, type MCPCallResult, type MCPServer, type MCPServerOptions, MCPServerStdio, type MCPServerStdioOptions, MCPServerStreamableHttp, type MCPServerStreamableHttpOptions, type MCPTool, MaxTurnsExceededError, type ModelSettings, type NeedsApproval, type OutputGuardrail, type RunContext, type RunItem, type RunOptions, type RunResult, RunState, type RunStreamEvent, type SchemaLike, SchemaValidationError, type StandardSchemaV1, type StreamedRunResult, type ToolApprovalItem, type ToolOptions, type Usage, WidgetNode, createAgentChatHandler, run, toAgentChatStream, tool };
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -117,6 +117,111 @@ interface FunctionTool<Ctx = unknown> {
|
|
|
117
117
|
*/
|
|
118
118
|
declare function tool<S extends SchemaLike, Ctx = unknown, Out = unknown>(options: ToolOptions<S, Ctx, Out>): FunctionTool<Ctx>;
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* MCP servers as agent tools.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* const linear = new MCPServerStreamableHttp({ url: 'https://mcp.linear.app/mcp', headers: { Authorization: `Bearer ${token}` } });
|
|
125
|
+
* const files = new MCPServerStdio({ command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', './docs'] });
|
|
126
|
+
* const agent = new Agent({ name: 'Ops', mcpServers: [linear, files] });
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* Servers connect from your process, like your other tools: their
|
|
130
|
+
* credentials never reach Cencori. Their tools join the agent's own, with the
|
|
131
|
+
* same argument checks, approvals and traces.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
interface MCPTool {
|
|
135
|
+
name: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
inputSchema?: JsonSchema;
|
|
138
|
+
annotations?: {
|
|
139
|
+
readOnlyHint?: boolean;
|
|
140
|
+
destructiveHint?: boolean;
|
|
141
|
+
idempotentHint?: boolean;
|
|
142
|
+
openWorldHint?: boolean;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface MCPServerOptions {
|
|
146
|
+
/** A name for traces and to keep tool names apart between servers. Default from the URL or command. */
|
|
147
|
+
name?: string;
|
|
148
|
+
/** Only these tools (by their MCP name). Default: all. */
|
|
149
|
+
allowedTools?: string[];
|
|
150
|
+
/**
|
|
151
|
+
* Ask a person before calling: true for every tool, a list of tool names,
|
|
152
|
+
* or a function. Tools marked destructive by the server always ask unless
|
|
153
|
+
* this is false.
|
|
154
|
+
*/
|
|
155
|
+
requireApproval?: boolean | string[] | ((tool: MCPTool) => boolean);
|
|
156
|
+
/** Keep the tools list after the first fetch (default true). */
|
|
157
|
+
cacheToolsList?: boolean;
|
|
158
|
+
/** Per request, in ms. Default 30000. */
|
|
159
|
+
timeoutMs?: number;
|
|
160
|
+
}
|
|
161
|
+
/** What an agent needs from an MCP server. */
|
|
162
|
+
interface MCPServer {
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly options: MCPServerOptions;
|
|
165
|
+
connect(): Promise<void>;
|
|
166
|
+
listTools(): Promise<MCPTool[]>;
|
|
167
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
168
|
+
close(): Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
interface MCPCallResult {
|
|
171
|
+
content?: Array<{
|
|
172
|
+
type: string;
|
|
173
|
+
text?: string;
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
}>;
|
|
176
|
+
structuredContent?: unknown;
|
|
177
|
+
isError?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface MCPServerStreamableHttpOptions extends MCPServerOptions {
|
|
180
|
+
url: string;
|
|
181
|
+
/** Sent on every request: auth goes here. */
|
|
182
|
+
headers?: Record<string, string>;
|
|
183
|
+
fetch?: typeof fetch;
|
|
184
|
+
}
|
|
185
|
+
/** A remote MCP server over Streamable HTTP. Speaks stateless MCP, and falls back to the session handshake for older servers. */
|
|
186
|
+
declare class MCPServerStreamableHttp implements MCPServer {
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly options: MCPServerStreamableHttpOptions;
|
|
189
|
+
private mode;
|
|
190
|
+
private sessionHeaders;
|
|
191
|
+
private tools;
|
|
192
|
+
constructor(options: MCPServerStreamableHttpOptions);
|
|
193
|
+
connect(): Promise<void>;
|
|
194
|
+
listTools(): Promise<MCPTool[]>;
|
|
195
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
196
|
+
close(): Promise<void>;
|
|
197
|
+
private request;
|
|
198
|
+
private handshake;
|
|
199
|
+
private post;
|
|
200
|
+
}
|
|
201
|
+
interface MCPServerStdioOptions extends MCPServerOptions {
|
|
202
|
+
command: string;
|
|
203
|
+
args?: string[];
|
|
204
|
+
env?: Record<string, string>;
|
|
205
|
+
cwd?: string;
|
|
206
|
+
}
|
|
207
|
+
/** A local MCP server started as a process (Node only). */
|
|
208
|
+
declare class MCPServerStdio implements MCPServer {
|
|
209
|
+
readonly name: string;
|
|
210
|
+
readonly options: MCPServerStdioOptions;
|
|
211
|
+
private child;
|
|
212
|
+
private starting;
|
|
213
|
+
private pending;
|
|
214
|
+
private tools;
|
|
215
|
+
private stderr;
|
|
216
|
+
constructor(options: MCPServerStdioOptions);
|
|
217
|
+
connect(): Promise<void>;
|
|
218
|
+
listTools(): Promise<MCPTool[]>;
|
|
219
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPCallResult>;
|
|
220
|
+
close(): Promise<void>;
|
|
221
|
+
private start;
|
|
222
|
+
private request;
|
|
223
|
+
}
|
|
224
|
+
|
|
120
225
|
interface TransportOptions {
|
|
121
226
|
/** Secret project key (csk_...). Defaults to the CENCORI_API_KEY environment variable. */
|
|
122
227
|
apiKey?: string;
|
|
@@ -390,6 +495,12 @@ interface AgentOptions<Ctx = unknown, Out = string> {
|
|
|
390
495
|
* add here run in your process on top. Usually set with Agent.fromCencori().
|
|
391
496
|
*/
|
|
392
497
|
cencoriAgentId?: string;
|
|
498
|
+
/**
|
|
499
|
+
* MCP servers whose tools this agent can use, next to its own. They connect
|
|
500
|
+
* from your process (MCPServerStreamableHttp for remote servers,
|
|
501
|
+
* MCPServerStdio for local ones).
|
|
502
|
+
*/
|
|
503
|
+
mcpServers?: MCPServer[];
|
|
393
504
|
}
|
|
394
505
|
/** The model an agent uses when none is given: GPT OSS 120B on Cerebras, chosen for speed. */
|
|
395
506
|
declare const DEFAULT_MODEL = "gpt-oss-120b";
|
|
@@ -419,6 +530,7 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
419
530
|
readonly outputGuardrails: OutputGuardrail<Ctx>[];
|
|
420
531
|
readonly widgets: boolean;
|
|
421
532
|
readonly cencoriAgentId?: string;
|
|
533
|
+
readonly mcpServers: MCPServer[];
|
|
422
534
|
constructor(options: AgentOptions<Ctx, Out>);
|
|
423
535
|
/** A copy with some options changed. */
|
|
424
536
|
clone(overrides: Partial<AgentOptions<Ctx, Out>>): Agent<Ctx, Out>;
|
|
@@ -435,6 +547,12 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
435
547
|
static fromCencori<Ctx = unknown>(agentId: string, options?: Omit<AgentOptions<Ctx, string>, 'cencoriAgentId' | 'name'> & {
|
|
436
548
|
name?: string;
|
|
437
549
|
}): Agent<Ctx, string>;
|
|
550
|
+
/**
|
|
551
|
+
* Every tool this agent can call: its own, then its MCP servers' (fetched
|
|
552
|
+
* from each server, once per server unless it says otherwise). An MCP tool
|
|
553
|
+
* whose name is taken gets its server's name in front.
|
|
554
|
+
*/
|
|
555
|
+
resolveTools(): Promise<FunctionTool<Ctx>[]>;
|
|
438
556
|
/** The tool name a handoff to this agent goes by. */
|
|
439
557
|
static handoffToolName(agent: Agent<any>): string;
|
|
440
558
|
/** Instructions for this run, resolving a function if given. */
|
|
@@ -521,4 +639,4 @@ declare function toAgentChatStream(streamed: StreamedRunResult<unknown>, options
|
|
|
521
639
|
secret: string;
|
|
522
640
|
}): ReadableStream<Uint8Array>;
|
|
523
641
|
|
|
524
|
-
export { Agent, type AgentChatHandlerOptions, type AgentOptions, AgentsError, CencoriRunError, DEFAULT_MODEL, type FunctionTool, type GuardrailResult, GuardrailTripwireTriggered, type InputGuardrail, type JsonSchema, MaxTurnsExceededError, type ModelSettings, type NeedsApproval, type OutputGuardrail, type RunContext, type RunItem, type RunOptions, type RunResult, RunState, type RunStreamEvent, type SchemaLike, SchemaValidationError, type StandardSchemaV1, type StreamedRunResult, type ToolApprovalItem, type ToolOptions, type Usage, WidgetNode, createAgentChatHandler, run, toAgentChatStream, tool };
|
|
642
|
+
export { Agent, type AgentChatHandlerOptions, type AgentOptions, AgentsError, CencoriRunError, DEFAULT_MODEL, type FunctionTool, type GuardrailResult, GuardrailTripwireTriggered, type InputGuardrail, type JsonSchema, type MCPCallResult, type MCPServer, type MCPServerOptions, MCPServerStdio, type MCPServerStdioOptions, MCPServerStreamableHttp, type MCPServerStreamableHttpOptions, type MCPTool, MaxTurnsExceededError, type ModelSettings, type NeedsApproval, type OutputGuardrail, type RunContext, type RunItem, type RunOptions, type RunResult, RunState, type RunStreamEvent, type SchemaLike, SchemaValidationError, type StandardSchemaV1, type StreamedRunResult, type ToolApprovalItem, type ToolOptions, type Usage, WidgetNode, createAgentChatHandler, run, toAgentChatStream, tool };
|