@copilotkitnext/agent 0.0.13-alpha.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.
@@ -0,0 +1,23 @@
1
+
2
+ 
3
+ > @copilotkitnext/agent@0.0.13-alpha.0 build /Users/mme/Projects/CopilotKit2/main/packages/agent
4
+ > tsup
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.0
9
+ CLI Using tsup config: /Users/mme/Projects/CopilotKit2/main/packages/agent/tsup.config.ts
10
+ CLI Target: es2022
11
+ CLI Cleaning output folder
12
+ CJS Build start
13
+ ESM Build start
14
+ CJS dist/index.js 21.08 KB
15
+ CJS dist/index.js.map 40.66 KB
16
+ CJS ⚡️ Build success in 13ms
17
+ ESM dist/index.mjs 19.33 KB
18
+ ESM dist/index.mjs.map 40.61 KB
19
+ ESM ⚡️ Build success in 14ms
20
+ DTS Build start
21
+ DTS ⚡️ Build success in 1950ms
22
+ DTS dist/index.d.ts 5.84 KB
23
+ DTS dist/index.d.mts 5.84 KB
package/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Note: This license does not apply to the whole project. Individual packages may contain their own licenses.
2
+
3
+ MIT License
4
+
5
+ Copyright 2025 Tawkit Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,187 @@
1
+ import { Message, RunAgentInput, AbstractAgent, BaseEvent } from '@ag-ui/client';
2
+ import { LanguageModel, ModelMessage, ToolSet, ToolChoice } from 'ai';
3
+ import { Observable } from 'rxjs';
4
+ import { z } from 'zod';
5
+ import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
+
7
+ /**
8
+ * Properties that can be overridden by forwardedProps
9
+ * These match the exact parameter names in streamText
10
+ */
11
+ type OverridableProperty = "model" | "toolChoice" | "maxOutputTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "maxRetries" | "prompt";
12
+ /**
13
+ * Supported model identifiers for BasicAgent
14
+ */
15
+ type BasicAgentModel = "openai/gpt-5" | "openai/gpt-5-mini" | "openai/gpt-4.1" | "openai/gpt-4.1-mini" | "openai/gpt-4.1-nano" | "openai/gpt-4o" | "openai/gpt-4o-mini" | "openai/o3" | "openai/o3-mini" | "openai/o4-mini" | "anthropic/claude-sonnet-4.5" | "anthropic/claude-sonnet-4" | "anthropic/claude-3.7-sonnet" | "anthropic/claude-opus-4.1" | "anthropic/claude-opus-4" | "anthropic/claude-3.5-haiku" | "google/gemini-2.5-pro" | "google/gemini-2.5-flash" | "google/gemini-2.5-flash-lite" | (string & {});
16
+ /**
17
+ * Model specifier - can be a string like "openai/gpt-4o" or a LanguageModel instance
18
+ */
19
+ type ModelSpecifier = string | LanguageModel;
20
+ /**
21
+ * MCP Client configuration for HTTP transport
22
+ */
23
+ interface MCPClientConfigHTTP {
24
+ /**
25
+ * Type of MCP client
26
+ */
27
+ type: "http";
28
+ /**
29
+ * URL of the MCP server
30
+ */
31
+ url: string;
32
+ /**
33
+ * Optional transport options for HTTP client
34
+ */
35
+ options?: StreamableHTTPClientTransportOptions;
36
+ }
37
+ /**
38
+ * MCP Client configuration for SSE transport
39
+ */
40
+ interface MCPClientConfigSSE {
41
+ /**
42
+ * Type of MCP client
43
+ */
44
+ type: "sse";
45
+ /**
46
+ * URL of the MCP server
47
+ */
48
+ url: string;
49
+ /**
50
+ * Optional HTTP headers (e.g., for authentication)
51
+ */
52
+ headers?: Record<string, string>;
53
+ }
54
+ /**
55
+ * MCP Client configuration
56
+ */
57
+ type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;
58
+ /**
59
+ * Resolves a model specifier to a LanguageModel instance
60
+ * @param spec - Model string (e.g., "openai/gpt-4o") or LanguageModel instance
61
+ * @returns LanguageModel instance
62
+ */
63
+ declare function resolveModel(spec: ModelSpecifier): LanguageModel;
64
+ /**
65
+ * Tool definition for BasicAgent
66
+ */
67
+ interface ToolDefinition<TParameters extends z.ZodTypeAny = z.ZodTypeAny> {
68
+ name: string;
69
+ description: string;
70
+ parameters: TParameters;
71
+ }
72
+ /**
73
+ * Define a tool for use with BasicAgent
74
+ * @param name - The name of the tool
75
+ * @param description - Description of what the tool does
76
+ * @param parameters - Zod schema for the tool's input parameters
77
+ * @returns Tool definition
78
+ */
79
+ declare function defineTool<TParameters extends z.ZodTypeAny>(config: {
80
+ name: string;
81
+ description: string;
82
+ parameters: TParameters;
83
+ }): ToolDefinition<TParameters>;
84
+ /**
85
+ * Converts AG-UI messages to Vercel AI SDK ModelMessage format
86
+ */
87
+ declare function convertMessagesToVercelAISDKMessages(messages: Message[]): ModelMessage[];
88
+ /**
89
+ * JSON Schema type definition
90
+ */
91
+ interface JsonSchema {
92
+ type: "object" | "string" | "number" | "boolean" | "array";
93
+ description?: string;
94
+ properties?: Record<string, JsonSchema>;
95
+ required?: string[];
96
+ items?: JsonSchema;
97
+ }
98
+ /**
99
+ * Converts JSON Schema to Zod schema
100
+ */
101
+ declare function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema;
102
+ declare function convertToolsToVercelAITools(tools: RunAgentInput["tools"]): ToolSet;
103
+ /**
104
+ * Converts ToolDefinition array to Vercel AI SDK ToolSet
105
+ */
106
+ declare function convertToolDefinitionsToVercelAITools(tools: ToolDefinition[]): ToolSet;
107
+ /**
108
+ * Configuration for BasicAgent
109
+ */
110
+ interface BasicAgentConfiguration {
111
+ /**
112
+ * The model to use
113
+ */
114
+ model: BasicAgentModel | LanguageModel;
115
+ /**
116
+ * Maximum number of steps/iterations for tool calling (default: 1)
117
+ */
118
+ maxSteps?: number;
119
+ /**
120
+ * Tool choice setting - how tools are selected for execution (default: "auto")
121
+ */
122
+ toolChoice?: ToolChoice<Record<string, unknown>>;
123
+ /**
124
+ * Maximum number of tokens to generate
125
+ */
126
+ maxOutputTokens?: number;
127
+ /**
128
+ * Temperature setting (range depends on provider)
129
+ */
130
+ temperature?: number;
131
+ /**
132
+ * Nucleus sampling (topP)
133
+ */
134
+ topP?: number;
135
+ /**
136
+ * Top K sampling
137
+ */
138
+ topK?: number;
139
+ /**
140
+ * Presence penalty
141
+ */
142
+ presencePenalty?: number;
143
+ /**
144
+ * Frequency penalty
145
+ */
146
+ frequencyPenalty?: number;
147
+ /**
148
+ * Sequences that will stop the generation
149
+ */
150
+ stopSequences?: string[];
151
+ /**
152
+ * Seed for deterministic results
153
+ */
154
+ seed?: number;
155
+ /**
156
+ * Maximum number of retries
157
+ */
158
+ maxRetries?: number;
159
+ /**
160
+ * Prompt for the agent
161
+ */
162
+ prompt?: string;
163
+ /**
164
+ * List of properties that can be overridden by forwardedProps.
165
+ */
166
+ overridableProperties?: OverridableProperty[];
167
+ /**
168
+ * Optional list of MCP server configurations
169
+ */
170
+ mcpServers?: MCPClientConfig[];
171
+ /**
172
+ * Optional tools available to the agent
173
+ */
174
+ tools?: ToolDefinition[];
175
+ }
176
+ declare class BasicAgent extends AbstractAgent {
177
+ private config;
178
+ constructor(config: BasicAgentConfiguration);
179
+ /**
180
+ * Check if a property can be overridden by forwardedProps
181
+ */
182
+ canOverride(property: OverridableProperty): boolean;
183
+ protected run(input: RunAgentInput): Observable<BaseEvent>;
184
+ clone(): BasicAgent;
185
+ }
186
+
187
+ export { BasicAgent, type BasicAgentConfiguration, type BasicAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
@@ -0,0 +1,187 @@
1
+ import { Message, RunAgentInput, AbstractAgent, BaseEvent } from '@ag-ui/client';
2
+ import { LanguageModel, ModelMessage, ToolSet, ToolChoice } from 'ai';
3
+ import { Observable } from 'rxjs';
4
+ import { z } from 'zod';
5
+ import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
+
7
+ /**
8
+ * Properties that can be overridden by forwardedProps
9
+ * These match the exact parameter names in streamText
10
+ */
11
+ type OverridableProperty = "model" | "toolChoice" | "maxOutputTokens" | "temperature" | "topP" | "topK" | "presencePenalty" | "frequencyPenalty" | "stopSequences" | "seed" | "maxRetries" | "prompt";
12
+ /**
13
+ * Supported model identifiers for BasicAgent
14
+ */
15
+ type BasicAgentModel = "openai/gpt-5" | "openai/gpt-5-mini" | "openai/gpt-4.1" | "openai/gpt-4.1-mini" | "openai/gpt-4.1-nano" | "openai/gpt-4o" | "openai/gpt-4o-mini" | "openai/o3" | "openai/o3-mini" | "openai/o4-mini" | "anthropic/claude-sonnet-4.5" | "anthropic/claude-sonnet-4" | "anthropic/claude-3.7-sonnet" | "anthropic/claude-opus-4.1" | "anthropic/claude-opus-4" | "anthropic/claude-3.5-haiku" | "google/gemini-2.5-pro" | "google/gemini-2.5-flash" | "google/gemini-2.5-flash-lite" | (string & {});
16
+ /**
17
+ * Model specifier - can be a string like "openai/gpt-4o" or a LanguageModel instance
18
+ */
19
+ type ModelSpecifier = string | LanguageModel;
20
+ /**
21
+ * MCP Client configuration for HTTP transport
22
+ */
23
+ interface MCPClientConfigHTTP {
24
+ /**
25
+ * Type of MCP client
26
+ */
27
+ type: "http";
28
+ /**
29
+ * URL of the MCP server
30
+ */
31
+ url: string;
32
+ /**
33
+ * Optional transport options for HTTP client
34
+ */
35
+ options?: StreamableHTTPClientTransportOptions;
36
+ }
37
+ /**
38
+ * MCP Client configuration for SSE transport
39
+ */
40
+ interface MCPClientConfigSSE {
41
+ /**
42
+ * Type of MCP client
43
+ */
44
+ type: "sse";
45
+ /**
46
+ * URL of the MCP server
47
+ */
48
+ url: string;
49
+ /**
50
+ * Optional HTTP headers (e.g., for authentication)
51
+ */
52
+ headers?: Record<string, string>;
53
+ }
54
+ /**
55
+ * MCP Client configuration
56
+ */
57
+ type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;
58
+ /**
59
+ * Resolves a model specifier to a LanguageModel instance
60
+ * @param spec - Model string (e.g., "openai/gpt-4o") or LanguageModel instance
61
+ * @returns LanguageModel instance
62
+ */
63
+ declare function resolveModel(spec: ModelSpecifier): LanguageModel;
64
+ /**
65
+ * Tool definition for BasicAgent
66
+ */
67
+ interface ToolDefinition<TParameters extends z.ZodTypeAny = z.ZodTypeAny> {
68
+ name: string;
69
+ description: string;
70
+ parameters: TParameters;
71
+ }
72
+ /**
73
+ * Define a tool for use with BasicAgent
74
+ * @param name - The name of the tool
75
+ * @param description - Description of what the tool does
76
+ * @param parameters - Zod schema for the tool's input parameters
77
+ * @returns Tool definition
78
+ */
79
+ declare function defineTool<TParameters extends z.ZodTypeAny>(config: {
80
+ name: string;
81
+ description: string;
82
+ parameters: TParameters;
83
+ }): ToolDefinition<TParameters>;
84
+ /**
85
+ * Converts AG-UI messages to Vercel AI SDK ModelMessage format
86
+ */
87
+ declare function convertMessagesToVercelAISDKMessages(messages: Message[]): ModelMessage[];
88
+ /**
89
+ * JSON Schema type definition
90
+ */
91
+ interface JsonSchema {
92
+ type: "object" | "string" | "number" | "boolean" | "array";
93
+ description?: string;
94
+ properties?: Record<string, JsonSchema>;
95
+ required?: string[];
96
+ items?: JsonSchema;
97
+ }
98
+ /**
99
+ * Converts JSON Schema to Zod schema
100
+ */
101
+ declare function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema;
102
+ declare function convertToolsToVercelAITools(tools: RunAgentInput["tools"]): ToolSet;
103
+ /**
104
+ * Converts ToolDefinition array to Vercel AI SDK ToolSet
105
+ */
106
+ declare function convertToolDefinitionsToVercelAITools(tools: ToolDefinition[]): ToolSet;
107
+ /**
108
+ * Configuration for BasicAgent
109
+ */
110
+ interface BasicAgentConfiguration {
111
+ /**
112
+ * The model to use
113
+ */
114
+ model: BasicAgentModel | LanguageModel;
115
+ /**
116
+ * Maximum number of steps/iterations for tool calling (default: 1)
117
+ */
118
+ maxSteps?: number;
119
+ /**
120
+ * Tool choice setting - how tools are selected for execution (default: "auto")
121
+ */
122
+ toolChoice?: ToolChoice<Record<string, unknown>>;
123
+ /**
124
+ * Maximum number of tokens to generate
125
+ */
126
+ maxOutputTokens?: number;
127
+ /**
128
+ * Temperature setting (range depends on provider)
129
+ */
130
+ temperature?: number;
131
+ /**
132
+ * Nucleus sampling (topP)
133
+ */
134
+ topP?: number;
135
+ /**
136
+ * Top K sampling
137
+ */
138
+ topK?: number;
139
+ /**
140
+ * Presence penalty
141
+ */
142
+ presencePenalty?: number;
143
+ /**
144
+ * Frequency penalty
145
+ */
146
+ frequencyPenalty?: number;
147
+ /**
148
+ * Sequences that will stop the generation
149
+ */
150
+ stopSequences?: string[];
151
+ /**
152
+ * Seed for deterministic results
153
+ */
154
+ seed?: number;
155
+ /**
156
+ * Maximum number of retries
157
+ */
158
+ maxRetries?: number;
159
+ /**
160
+ * Prompt for the agent
161
+ */
162
+ prompt?: string;
163
+ /**
164
+ * List of properties that can be overridden by forwardedProps.
165
+ */
166
+ overridableProperties?: OverridableProperty[];
167
+ /**
168
+ * Optional list of MCP server configurations
169
+ */
170
+ mcpServers?: MCPClientConfig[];
171
+ /**
172
+ * Optional tools available to the agent
173
+ */
174
+ tools?: ToolDefinition[];
175
+ }
176
+ declare class BasicAgent extends AbstractAgent {
177
+ private config;
178
+ constructor(config: BasicAgentConfiguration);
179
+ /**
180
+ * Check if a property can be overridden by forwardedProps
181
+ */
182
+ canOverride(property: OverridableProperty): boolean;
183
+ protected run(input: RunAgentInput): Observable<BaseEvent>;
184
+ clone(): BasicAgent;
185
+ }
186
+
187
+ export { BasicAgent, type BasicAgentConfiguration, type BasicAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };