@agentionai/agents 0.3.0-beta
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/README.md +517 -0
- package/dist/agents/Agent.d.ts +29 -0
- package/dist/agents/Agent.js +28 -0
- package/dist/agents/AgentConfig.d.ts +118 -0
- package/dist/agents/AgentConfig.js +3 -0
- package/dist/agents/AgentEvent.d.ts +18 -0
- package/dist/agents/AgentEvent.js +26 -0
- package/dist/agents/BaseAgent.d.ts +82 -0
- package/dist/agents/BaseAgent.js +121 -0
- package/dist/agents/anthropic/ClaudeAgent.d.ts +46 -0
- package/dist/agents/anthropic/ClaudeAgent.js +262 -0
- package/dist/agents/errors/AgentError.d.ts +47 -0
- package/dist/agents/errors/AgentError.js +74 -0
- package/dist/agents/google/GeminiAgent.d.ts +63 -0
- package/dist/agents/google/GeminiAgent.js +395 -0
- package/dist/agents/mistral/MistralAgent.d.ts +47 -0
- package/dist/agents/mistral/MistralAgent.js +313 -0
- package/dist/agents/model-types.d.ts +30 -0
- package/dist/agents/model-types.js +8 -0
- package/dist/agents/openai/OpenAiAgent.d.ts +48 -0
- package/dist/agents/openai/OpenAiAgent.js +338 -0
- package/dist/chunkers/Chunker.d.ts +53 -0
- package/dist/chunkers/Chunker.js +174 -0
- package/dist/chunkers/RecursiveChunker.d.ts +52 -0
- package/dist/chunkers/RecursiveChunker.js +166 -0
- package/dist/chunkers/TextChunker.d.ts +27 -0
- package/dist/chunkers/TextChunker.js +50 -0
- package/dist/chunkers/TokenChunker.d.ts +60 -0
- package/dist/chunkers/TokenChunker.js +176 -0
- package/dist/chunkers/index.d.ts +6 -0
- package/dist/chunkers/index.js +14 -0
- package/dist/chunkers/types.d.ts +95 -0
- package/dist/chunkers/types.js +3 -0
- package/dist/graph/AgentGraph.d.ts +99 -0
- package/dist/graph/AgentGraph.js +115 -0
- package/dist/graph/BaseExecutor.d.ts +86 -0
- package/dist/graph/BaseExecutor.js +61 -0
- package/dist/graph/GraphMetrics.d.ts +143 -0
- package/dist/graph/GraphMetrics.js +264 -0
- package/dist/graph/MapExecutor.d.ts +39 -0
- package/dist/graph/MapExecutor.js +123 -0
- package/dist/graph/ParallelExecutor.d.ts +51 -0
- package/dist/graph/ParallelExecutor.js +103 -0
- package/dist/graph/Pipeline.d.ts +44 -0
- package/dist/graph/Pipeline.js +109 -0
- package/dist/graph/RouterExecutor.d.ts +89 -0
- package/dist/graph/RouterExecutor.js +209 -0
- package/dist/graph/SequentialExecutor.d.ts +44 -0
- package/dist/graph/SequentialExecutor.js +115 -0
- package/dist/graph/VotingSystem.d.ts +54 -0
- package/dist/graph/VotingSystem.js +106 -0
- package/dist/history/History.d.ts +107 -0
- package/dist/history/History.js +166 -0
- package/dist/history/RedisHistory.d.ts +27 -0
- package/dist/history/RedisHistory.js +55 -0
- package/dist/history/transformers.d.ts +102 -0
- package/dist/history/transformers.js +415 -0
- package/dist/history/types.d.ts +130 -0
- package/dist/history/types.js +55 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +48 -0
- package/dist/ingestion/IngestionPipeline.d.ts +86 -0
- package/dist/ingestion/IngestionPipeline.js +266 -0
- package/dist/ingestion/index.d.ts +3 -0
- package/dist/ingestion/index.js +7 -0
- package/dist/ingestion/types.d.ts +74 -0
- package/dist/ingestion/types.js +3 -0
- package/dist/team/Team.d.ts +46 -0
- package/dist/team/Team.js +104 -0
- package/dist/tools/Tool.d.ts +75 -0
- package/dist/tools/Tool.js +137 -0
- package/dist/vectorstore/Embeddings.d.ts +67 -0
- package/dist/vectorstore/Embeddings.js +54 -0
- package/dist/vectorstore/LanceDBVectorStore.d.ts +149 -0
- package/dist/vectorstore/LanceDBVectorStore.js +338 -0
- package/dist/vectorstore/OpenAIEmbeddings.d.ts +45 -0
- package/dist/vectorstore/OpenAIEmbeddings.js +109 -0
- package/dist/vectorstore/VectorStore.d.ts +255 -0
- package/dist/vectorstore/VectorStore.js +216 -0
- package/dist/vectorstore/index.d.ts +28 -0
- package/dist/vectorstore/index.js +35 -0
- package/dist/viz/VizConfig.d.ts +54 -0
- package/dist/viz/VizConfig.js +100 -0
- package/dist/viz/VizReporter.d.ts +127 -0
- package/dist/viz/VizReporter.js +595 -0
- package/dist/viz/index.d.ts +31 -0
- package/dist/viz/index.js +51 -0
- package/dist/viz/types.d.ts +105 -0
- package/dist/viz/types.js +7 -0
- package/package.json +109 -0
- package/readme.md +1 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MistralAgent = void 0;
|
|
4
|
+
const mistralai_1 = require("@mistralai/mistralai");
|
|
5
|
+
const BaseAgent_1 = require("../BaseAgent");
|
|
6
|
+
const AgentEvent_1 = require("../AgentEvent");
|
|
7
|
+
const AgentError_1 = require("../errors/AgentError");
|
|
8
|
+
const transformers_1 = require("../../history/transformers");
|
|
9
|
+
const components_1 = require("@mistralai/mistralai/models/components");
|
|
10
|
+
const promises_1 = require("timers/promises");
|
|
11
|
+
const VizReporter_1 = require("../../viz/VizReporter");
|
|
12
|
+
const VizConfig_1 = require("../../viz/VizConfig");
|
|
13
|
+
/**
|
|
14
|
+
* Agent for Mistral models.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const agent = new MistralAgent({
|
|
19
|
+
* id: "1",
|
|
20
|
+
* name: "Assistant",
|
|
21
|
+
* description: "A helpful assistant",
|
|
22
|
+
* apiKey: process.env.MISTRAL_API_KEY,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const response = await agent.execute("Hello!");
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class MistralAgent extends BaseAgent_1.BaseAgent {
|
|
29
|
+
constructor(config, history) {
|
|
30
|
+
super({ ...config, vendor: "mistral" }, history);
|
|
31
|
+
/** Count of tool calls in current execution */
|
|
32
|
+
this.currentToolCallCount = 0;
|
|
33
|
+
this.client = new mistralai_1.Mistral({
|
|
34
|
+
apiKey: config.apiKey,
|
|
35
|
+
});
|
|
36
|
+
// Merge flat config (deprecated) with nested vendorConfig
|
|
37
|
+
// Flat config takes precedence for backward compatibility
|
|
38
|
+
const vendorConfig = config.vendorConfig?.mistral || {};
|
|
39
|
+
const disableParallelToolUse = config.disableParallelToolUse ??
|
|
40
|
+
vendorConfig.disableParallelToolUse ??
|
|
41
|
+
false;
|
|
42
|
+
const safePrompt = config.safePrompt ?? vendorConfig.safePrompt;
|
|
43
|
+
const randomSeed = config.randomSeed ?? vendorConfig.randomSeed ?? config.seed;
|
|
44
|
+
const rateLimitDelay = config.rateLimitDelay ?? vendorConfig.rateLimitDelay ?? 1500;
|
|
45
|
+
this.config = {
|
|
46
|
+
model: config.model || "mistral-small-latest",
|
|
47
|
+
maxTokens: config.maxTokens || 1024,
|
|
48
|
+
disableParallelToolUse,
|
|
49
|
+
safePrompt,
|
|
50
|
+
randomSeed,
|
|
51
|
+
rateLimitDelay,
|
|
52
|
+
apiKey: config.apiKey,
|
|
53
|
+
temperature: config.temperature,
|
|
54
|
+
topP: config.topP,
|
|
55
|
+
stopSequences: config.stopSequences,
|
|
56
|
+
};
|
|
57
|
+
// Add system message to history (skips if already exists with same content)
|
|
58
|
+
this.addSystemMessage(this.getSystemMessage());
|
|
59
|
+
}
|
|
60
|
+
getToolDefinitions() {
|
|
61
|
+
return Array.from(this.tools.values()).map((tool) => ({
|
|
62
|
+
type: components_1.ToolTypes.Function,
|
|
63
|
+
function: {
|
|
64
|
+
name: tool.getPrompt().name,
|
|
65
|
+
description: tool.getPrompt().description,
|
|
66
|
+
parameters: tool.getPrompt().input_schema,
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
async process(_input) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
async execute(input) {
|
|
74
|
+
this.emit(AgentEvent_1.AgentEvent.BEFORE_EXECUTE, input);
|
|
75
|
+
// Reset token usage for this execution
|
|
76
|
+
this.lastTokenUsage = undefined;
|
|
77
|
+
this.currentToolCallCount = 0;
|
|
78
|
+
// Start visualization reporting
|
|
79
|
+
if (VizConfig_1.vizConfig.isEnabled()) {
|
|
80
|
+
this.vizEventId = VizReporter_1.vizReporter.agentStart(this.id, this.name, this.config.model, "mistral", input);
|
|
81
|
+
}
|
|
82
|
+
if (this.history.transient) {
|
|
83
|
+
this.history.clear();
|
|
84
|
+
// Re-add system message after clear
|
|
85
|
+
this.addSystemMessage(this.getSystemMessage());
|
|
86
|
+
}
|
|
87
|
+
this.addTextToHistory("user", input);
|
|
88
|
+
try {
|
|
89
|
+
const messages = transformers_1.mistralTransformer.toProvider(this.history.entries);
|
|
90
|
+
const response = await this.client.chat.complete({
|
|
91
|
+
model: this.config.model,
|
|
92
|
+
messages: messages,
|
|
93
|
+
tools: this.getToolDefinitions(),
|
|
94
|
+
temperature: this.config.temperature,
|
|
95
|
+
topP: this.config.topP,
|
|
96
|
+
maxTokens: this.config.maxTokens,
|
|
97
|
+
randomSeed: this.config.randomSeed,
|
|
98
|
+
safePrompt: this.config.safePrompt,
|
|
99
|
+
stop: this.config.stopSequences,
|
|
100
|
+
});
|
|
101
|
+
this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, response);
|
|
102
|
+
return await this.handleResponse(response);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const err = error;
|
|
106
|
+
if (err.status) {
|
|
107
|
+
const apiError = new AgentError_1.ApiError(`Mistral API error: ${err.message || "Unknown error"}`, err.status, error);
|
|
108
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, apiError);
|
|
109
|
+
// Report error to viz
|
|
110
|
+
if (this.vizEventId) {
|
|
111
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "ApiError", apiError.message, err.status === 429);
|
|
112
|
+
this.vizEventId = undefined;
|
|
113
|
+
}
|
|
114
|
+
throw apiError;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const executionError = new AgentError_1.ExecutionError(`Error executing agent: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
118
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, executionError);
|
|
119
|
+
// Report error to viz
|
|
120
|
+
if (this.vizEventId) {
|
|
121
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "ExecutionError", executionError.message, false);
|
|
122
|
+
this.vizEventId = undefined;
|
|
123
|
+
}
|
|
124
|
+
throw executionError;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async handleResponse(response) {
|
|
129
|
+
if (!response.choices || response.choices.length === 0) {
|
|
130
|
+
const error = new AgentError_1.ExecutionError("Empty response from Mistral API");
|
|
131
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
const choice = response.choices[0];
|
|
135
|
+
const usage = this.parseUsage(response.usage);
|
|
136
|
+
// Track token usage
|
|
137
|
+
if (this.lastTokenUsage) {
|
|
138
|
+
this.lastTokenUsage.input_tokens += usage.input_tokens;
|
|
139
|
+
this.lastTokenUsage.output_tokens += usage.output_tokens;
|
|
140
|
+
this.lastTokenUsage.total_tokens += usage.total_tokens;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.lastTokenUsage = { ...usage };
|
|
144
|
+
}
|
|
145
|
+
if (choice.finishReason === "length") {
|
|
146
|
+
const error = new AgentError_1.MaxTokensExceededError("Response exceeded maximum token limit", this.config.maxTokens || 1024);
|
|
147
|
+
this.emit(AgentEvent_1.AgentEvent.MAX_TOKENS_EXCEEDED, error);
|
|
148
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
149
|
+
// Report error to viz
|
|
150
|
+
if (this.vizEventId) {
|
|
151
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "MaxTokensExceededError", error.message, false);
|
|
152
|
+
this.vizEventId = undefined;
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
const message = choice.message;
|
|
157
|
+
if (choice.finishReason !== "tool_calls" && !message.toolCalls) {
|
|
158
|
+
// Regular text response
|
|
159
|
+
let textContent;
|
|
160
|
+
if (typeof message.content === "string") {
|
|
161
|
+
textContent = message.content;
|
|
162
|
+
}
|
|
163
|
+
else if (Array.isArray(message.content)) {
|
|
164
|
+
textContent = message.content
|
|
165
|
+
.filter((chunk) => typeof chunk === "string" || chunk.type === "text")
|
|
166
|
+
.map((chunk) => typeof chunk === "string" ? chunk : chunk.text)
|
|
167
|
+
.join("");
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const error = new AgentError_1.ExecutionError(`Unexpected response format: ${JSON.stringify(message.content)}`);
|
|
171
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
// Add to history in normalized format
|
|
175
|
+
const entry = transformers_1.mistralTransformer.fromProviderMessage(message);
|
|
176
|
+
this.addToHistory(entry);
|
|
177
|
+
this.emit(AgentEvent_1.AgentEvent.DONE, message, usage);
|
|
178
|
+
// Report completion to viz
|
|
179
|
+
if (this.vizEventId) {
|
|
180
|
+
VizReporter_1.vizReporter.agentComplete(this.vizEventId, {
|
|
181
|
+
input: this.lastTokenUsage?.input_tokens || 0,
|
|
182
|
+
output: this.lastTokenUsage?.output_tokens || 0,
|
|
183
|
+
total: this.lastTokenUsage?.total_tokens || 0,
|
|
184
|
+
}, "end_turn", this.currentToolCallCount > 0, this.currentToolCallCount, textContent);
|
|
185
|
+
this.vizEventId = undefined;
|
|
186
|
+
}
|
|
187
|
+
return textContent;
|
|
188
|
+
}
|
|
189
|
+
else if (choice.finishReason === "tool_calls" || message.toolCalls) {
|
|
190
|
+
try {
|
|
191
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_USE, message.toolCalls);
|
|
192
|
+
// Add assistant message with tool calls to history (normalized)
|
|
193
|
+
const assistantEntry = transformers_1.mistralTransformer.fromProviderMessage(message);
|
|
194
|
+
this.addToHistory(assistantEntry);
|
|
195
|
+
const toolResults = await this.handleToolCalls(message.toolCalls || []);
|
|
196
|
+
// Add tool results to history (normalized)
|
|
197
|
+
for (const result of toolResults) {
|
|
198
|
+
const resultEntry = transformers_1.mistralTransformer.toolResultEntry(result.toolCallId, result.name, result.content);
|
|
199
|
+
this.addToHistory(resultEntry);
|
|
200
|
+
}
|
|
201
|
+
// Rate limiting delay for Mistral
|
|
202
|
+
await (0, promises_1.setTimeout)(this.config.rateLimitDelay || 1500);
|
|
203
|
+
// Continue conversation
|
|
204
|
+
try {
|
|
205
|
+
const messages = transformers_1.mistralTransformer.toProvider(this.history.entries);
|
|
206
|
+
const newResponse = await this.client.chat.complete({
|
|
207
|
+
model: this.config.model,
|
|
208
|
+
messages: messages,
|
|
209
|
+
tools: this.getToolDefinitions(),
|
|
210
|
+
temperature: this.config.temperature,
|
|
211
|
+
topP: this.config.topP,
|
|
212
|
+
maxTokens: this.config.maxTokens,
|
|
213
|
+
randomSeed: this.config.randomSeed,
|
|
214
|
+
safePrompt: this.config.safePrompt,
|
|
215
|
+
stop: this.config.stopSequences,
|
|
216
|
+
});
|
|
217
|
+
this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, newResponse);
|
|
218
|
+
return this.handleResponse(newResponse);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
const err = error;
|
|
222
|
+
if (err.status) {
|
|
223
|
+
const apiError = new AgentError_1.ApiError(`Mistral API error during tool response: ${err.message || "Unknown error"}`, err.status, error);
|
|
224
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, apiError);
|
|
225
|
+
throw apiError;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
throw new AgentError_1.ExecutionError(`Error handling tool response: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
if (error instanceof AgentError_1.ToolExecutionError) {
|
|
234
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, error);
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
const toolError = new AgentError_1.ExecutionError(`Error during tool execution: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
238
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, toolError);
|
|
239
|
+
throw toolError;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const error = new AgentError_1.ExecutionError(`Unexpected finish_reason: ${choice.finishReason}`);
|
|
243
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
244
|
+
// Report error to viz
|
|
245
|
+
if (this.vizEventId) {
|
|
246
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "ExecutionError", error.message, false);
|
|
247
|
+
this.vizEventId = undefined;
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
async handleToolCalls(toolCalls) {
|
|
252
|
+
if (!toolCalls.length) {
|
|
253
|
+
throw new AgentError_1.ExecutionError("No tool calls found in response");
|
|
254
|
+
}
|
|
255
|
+
// Track tool call count for viz reporting
|
|
256
|
+
this.currentToolCallCount += toolCalls.length;
|
|
257
|
+
const toolResults = await Promise.all(toolCalls.map(async (toolCall) => {
|
|
258
|
+
const toolName = toolCall.function.name;
|
|
259
|
+
const tool = this.tools.get(toolName);
|
|
260
|
+
const toolCallId = toolCall.id || "";
|
|
261
|
+
if (!tool) {
|
|
262
|
+
const errorMessage = `Tool '${toolName}' not found`;
|
|
263
|
+
const error = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.function.arguments);
|
|
264
|
+
if (this.debug) {
|
|
265
|
+
console.error(error);
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
name: toolName,
|
|
269
|
+
toolCallId,
|
|
270
|
+
content: errorMessage,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
let args;
|
|
275
|
+
if (typeof toolCall.function.arguments === "string") {
|
|
276
|
+
args = JSON.parse(toolCall.function.arguments);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
args = toolCall.function.arguments;
|
|
280
|
+
}
|
|
281
|
+
const result = await tool.execute(this.getId(), this.getName(), args, toolCallId, this.config.model, "mistral");
|
|
282
|
+
return {
|
|
283
|
+
name: toolName,
|
|
284
|
+
toolCallId,
|
|
285
|
+
content: JSON.stringify(result),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
const errorMessage = `Error executing tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
290
|
+
if (this.debug) {
|
|
291
|
+
console.error(errorMessage);
|
|
292
|
+
}
|
|
293
|
+
const toolError = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.function.arguments);
|
|
294
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, toolError);
|
|
295
|
+
return {
|
|
296
|
+
name: toolName,
|
|
297
|
+
toolCallId,
|
|
298
|
+
content: errorMessage,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}));
|
|
302
|
+
return toolResults;
|
|
303
|
+
}
|
|
304
|
+
parseUsage(input) {
|
|
305
|
+
return {
|
|
306
|
+
input_tokens: input.promptTokens ?? 0,
|
|
307
|
+
output_tokens: input.completionTokens ?? 0,
|
|
308
|
+
total_tokens: input.totalTokens ?? 0,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
exports.MistralAgent = MistralAgent;
|
|
313
|
+
//# sourceMappingURL=MistralAgent.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for supported models across different AI providers.
|
|
3
|
+
* These types provide autocomplete and type safety when configuring agents.
|
|
4
|
+
* All types also accept custom string values for new/unlisted models.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supported Claude/Anthropic models.
|
|
8
|
+
* You can also provide any custom string for newer models not yet listed.
|
|
9
|
+
* @see https://docs.anthropic.com/en/docs/about-claude/models
|
|
10
|
+
*/
|
|
11
|
+
export type ClaudeModel = "claude-opus-4-5" | "claude-sonnet-4-5" | "claude-haiku-4-5" | (string & Record<never, never>);
|
|
12
|
+
/**
|
|
13
|
+
* Supported Google Gemini models.
|
|
14
|
+
* You can also provide any custom string for newer models not yet listed.
|
|
15
|
+
* @see https://ai.google.dev/gemini-api/docs/models/gemini
|
|
16
|
+
*/
|
|
17
|
+
export type GeminiModel = "gemini-flash-latest" | "gemini-flash-lite-latest" | "gemini-3.0-pro" | "gemini-3.0-flash" | "gemini-2.5-flash-lite" | "gemini-2.0-flash-exp" | "gemini-2.0-flash" | "gemini-2.0-flash-lite" | (string & {});
|
|
18
|
+
/**
|
|
19
|
+
* Supported Mistral models.
|
|
20
|
+
* You can also provide any custom string for newer models not yet listed.
|
|
21
|
+
* @see https://docs.mistral.ai/getting-started/models/
|
|
22
|
+
*/
|
|
23
|
+
export type MistralModel = "mistral-large-latest" | "mistral-small-latest" | "ministral-8b-latest" | "ministral-8b-2410" | "ministral-3b-latest" | "ministral-3b-2410" | "codestral-latest" | "codestral-2405" | "mistral-embed" | "mistral-moderation-latest" | "mistral-moderation-2411" | (string & {});
|
|
24
|
+
/**
|
|
25
|
+
* Supported OpenAI models.
|
|
26
|
+
* You can also provide any custom string for newer models not yet listed.
|
|
27
|
+
* @see https://platform.openai.com/docs/models
|
|
28
|
+
*/
|
|
29
|
+
export type OpenAIModel = "gpt-5.2" | "gpt-5" | "gpt-4.1" | "gpt-5-mini" | "gpt-5-nano" | "gpt-4o" | "gpt-4o-mini" | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-1106" | "o1" | "o1-preview" | "o1-mini" | "o3-mini" | (string & {});
|
|
30
|
+
//# sourceMappingURL=model-types.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for supported models across different AI providers.
|
|
4
|
+
* These types provide autocomplete and type safety when configuring agents.
|
|
5
|
+
* All types also accept custom string values for new/unlisted models.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
//# sourceMappingURL=model-types.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaseAgent, BaseAgentConfig, TokenUsage } from "../BaseAgent";
|
|
2
|
+
import { History } from "../../history/History";
|
|
3
|
+
import { Tool, Response, ResponseUsage } from "openai/resources/responses/responses";
|
|
4
|
+
import { OpenAIModel } from "../model-types";
|
|
5
|
+
type AgentConfig = BaseAgentConfig & {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
model?: OpenAIModel;
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
disableParallelToolUse?: boolean;
|
|
10
|
+
/** Disable extended thinking/reasoning for models that support it (like gpt-5-nano) */
|
|
11
|
+
disableReasoning?: boolean;
|
|
12
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
13
|
+
user?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Agent for OpenAI models using the Responses API.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const agent = new OpenAiAgent({
|
|
21
|
+
* id: "1",
|
|
22
|
+
* name: "Assistant",
|
|
23
|
+
* description: "A helpful assistant",
|
|
24
|
+
* apiKey: process.env.OPENAI_API_KEY,
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const response = await agent.execute("Hello!");
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class OpenAiAgent extends BaseAgent {
|
|
31
|
+
private client;
|
|
32
|
+
protected config: Partial<AgentConfig>;
|
|
33
|
+
/** Token usage from the last execution (for metrics tracking) */
|
|
34
|
+
lastTokenUsage?: TokenUsage;
|
|
35
|
+
/** Current visualization event ID for tracking */
|
|
36
|
+
private vizEventId?;
|
|
37
|
+
/** Count of tool calls in current execution */
|
|
38
|
+
private currentToolCallCount;
|
|
39
|
+
constructor(config: Omit<AgentConfig, "vendor">, history?: History);
|
|
40
|
+
protected getToolDefinitions(): Tool[];
|
|
41
|
+
protected process(_input: string): Promise<string>;
|
|
42
|
+
execute(input: string): Promise<string>;
|
|
43
|
+
protected handleResponse(response: Response): Promise<string>;
|
|
44
|
+
private handleToolUse;
|
|
45
|
+
protected parseUsage(input: ResponseUsage): TokenUsage;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=OpenAiAgent.d.ts.map
|