@agentionai/agents 0.12.0 → 0.14.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,249 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OpenAICompatibleAgent = void 0;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ const BaseAgent_1 = require("../BaseAgent");
9
+ const AgentEvent_1 = require("../AgentEvent");
10
+ const AgentError_1 = require("../errors/AgentError");
11
+ const transformers_1 = require("../../history/transformers");
12
+ const VizReporter_1 = require("../../viz/VizReporter");
13
+ const VizConfig_1 = require("../../viz/VizConfig");
14
+ /**
15
+ * Abstract base class for agents that talk to any OpenAI-compatible
16
+ * `/v1/chat/completions` endpoint (llama.cpp, vLLM, LM Studio, etc.).
17
+ *
18
+ * Subclasses must implement:
19
+ * - `getVendorName()` — human-readable name used in error messages (e.g. `"llama.cpp"`)
20
+ *
21
+ * Subclasses may override:
22
+ * - `buildExtraRequestParams()` — extra fields merged into the completions request
23
+ */
24
+ class OpenAICompatibleAgent extends BaseAgent_1.BaseAgent {
25
+ constructor(config, history) {
26
+ super(config, history);
27
+ this.currentToolCallCount = 0;
28
+ this.client = new openai_1.default({
29
+ apiKey: config.apiKey || "not-needed",
30
+ baseURL: config.baseURL,
31
+ });
32
+ this.config = {
33
+ model: config.model,
34
+ baseURL: config.baseURL,
35
+ maxTokens: config.maxTokens,
36
+ temperature: config.temperature,
37
+ topP: config.topP,
38
+ stopSequences: config.stopSequences,
39
+ seed: config.seed,
40
+ presencePenalty: config.presencePenalty,
41
+ frequencyPenalty: config.frequencyPenalty,
42
+ apiKey: config.apiKey,
43
+ };
44
+ this.addSystemMessage(this.getSystemMessage());
45
+ }
46
+ /** Extra fields to merge into the chat completions request. Override for vendor-specific params. */
47
+ buildExtraRequestParams() {
48
+ return {};
49
+ }
50
+ /**
51
+ * List the models available on the server via the `/v1/models` endpoint.
52
+ */
53
+ async listModels() {
54
+ try {
55
+ const page = await this.client.models.list();
56
+ return page.data;
57
+ }
58
+ catch (error) {
59
+ throw new AgentError_1.ExecutionError(`Failed to list ${this.getVendorName()} models: ${error instanceof Error ? error.message : "Unknown error"}`);
60
+ }
61
+ }
62
+ getToolDefinitions() {
63
+ return Array.from(this.tools.values()).map((tool) => {
64
+ const prompt = tool.getPrompt();
65
+ return {
66
+ type: "function",
67
+ function: {
68
+ name: prompt.name,
69
+ description: prompt.description,
70
+ parameters: prompt.input_schema,
71
+ },
72
+ };
73
+ });
74
+ }
75
+ async process(_input) {
76
+ return "";
77
+ }
78
+ async execute(input) {
79
+ this.emit(AgentEvent_1.AgentEvent.BEFORE_EXECUTE, input);
80
+ this.lastTokenUsage = undefined;
81
+ this.currentToolCallCount = 0;
82
+ const inputPreview = typeof input === "string" ? input : JSON.stringify(input);
83
+ if (VizConfig_1.vizConfig.isEnabled()) {
84
+ this.vizEventId = VizReporter_1.vizReporter.agentStart(this.id, this.name, this.config.model, this.vendor, inputPreview);
85
+ }
86
+ if (this.history.transient) {
87
+ this.history.clear();
88
+ this.addSystemMessage(this.getSystemMessage());
89
+ }
90
+ if (typeof input === "string") {
91
+ this.addTextToHistory("user", input);
92
+ }
93
+ else {
94
+ this.addMessageToHistory("user", input);
95
+ }
96
+ this.history.setSessionAnchor();
97
+ this.history.beginExecution();
98
+ try {
99
+ const response = await this.callProvider();
100
+ this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, response);
101
+ return await this.handleResponse(response);
102
+ }
103
+ catch (error) {
104
+ if (error instanceof openai_1.default.APIError) {
105
+ const apiError = new AgentError_1.ApiError(`${this.getVendorName()} API error: ${error.message}`, error.status, error);
106
+ this.emit(AgentEvent_1.AgentEvent.ERROR, apiError);
107
+ if (this.vizEventId) {
108
+ VizReporter_1.vizReporter.agentError(this.vizEventId, "ApiError", apiError.message, error.status === 429);
109
+ this.vizEventId = undefined;
110
+ }
111
+ throw apiError;
112
+ }
113
+ if (error instanceof AgentError_1.AgentError) {
114
+ this.emit(AgentEvent_1.AgentEvent.ERROR, error);
115
+ if (this.vizEventId) {
116
+ VizReporter_1.vizReporter.agentError(this.vizEventId, error.constructor.name, error.message, false);
117
+ this.vizEventId = undefined;
118
+ }
119
+ throw error;
120
+ }
121
+ const executionError = new AgentError_1.ExecutionError(`${this.getVendorName()} error: ${error instanceof Error ? error.message : "Unknown error"}`);
122
+ this.emit(AgentEvent_1.AgentEvent.ERROR, executionError);
123
+ if (this.vizEventId) {
124
+ VizReporter_1.vizReporter.agentError(this.vizEventId, "ExecutionError", executionError.message, false);
125
+ this.vizEventId = undefined;
126
+ }
127
+ throw executionError;
128
+ }
129
+ finally {
130
+ this.history.endExecution();
131
+ }
132
+ }
133
+ async callProvider() {
134
+ const messages = transformers_1.chatCompletionsTransformer.toProvider(this.history.getEntries());
135
+ const tools = this.tools.size > 0 ? this.getToolDefinitions() : undefined;
136
+ return this.client.chat.completions.create({
137
+ model: this.config.model,
138
+ messages,
139
+ tools,
140
+ stream: false,
141
+ max_tokens: this.config.maxTokens,
142
+ temperature: this.config.temperature,
143
+ top_p: this.config.topP,
144
+ stop: this.config.stopSequences,
145
+ seed: this.config.seed,
146
+ presence_penalty: this.config.presencePenalty,
147
+ frequency_penalty: this.config.frequencyPenalty,
148
+ ...this.buildExtraRequestParams(),
149
+ });
150
+ }
151
+ async handleResponse(response) {
152
+ const usage = this.parseUsage(response);
153
+ if (this.lastTokenUsage) {
154
+ this.lastTokenUsage.input_tokens += usage.input_tokens;
155
+ this.lastTokenUsage.output_tokens += usage.output_tokens;
156
+ this.lastTokenUsage.total_tokens += usage.total_tokens;
157
+ }
158
+ else {
159
+ this.lastTokenUsage = { ...usage };
160
+ }
161
+ const choice = response.choices[0];
162
+ const message = choice.message;
163
+ if (choice.finish_reason === "length") {
164
+ const error = new AgentError_1.MaxTokensExceededError("Response exceeded maximum token limit", this.config.maxTokens || 1024);
165
+ this.emit(AgentEvent_1.AgentEvent.MAX_TOKENS_EXCEEDED, error);
166
+ this.emit(AgentEvent_1.AgentEvent.ERROR, error);
167
+ if (this.vizEventId) {
168
+ VizReporter_1.vizReporter.agentError(this.vizEventId, "MaxTokensExceededError", error.message, false);
169
+ this.vizEventId = undefined;
170
+ }
171
+ throw error;
172
+ }
173
+ const hasToolCalls = message.tool_calls && message.tool_calls.length > 0;
174
+ if (!hasToolCalls) {
175
+ const textContent = message.content || "";
176
+ const entry = transformers_1.chatCompletionsTransformer.fromProviderMessage(message);
177
+ this.addToHistory(entry);
178
+ this.emit(AgentEvent_1.AgentEvent.DONE, message, usage);
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
+ const toolCalls = message.tool_calls;
190
+ this.emit(AgentEvent_1.AgentEvent.TOOL_USE, toolCalls);
191
+ this.currentToolCallCount += toolCalls.length;
192
+ const assistantEntry = transformers_1.chatCompletionsTransformer.fromProviderMessage(message);
193
+ this.addToHistory(assistantEntry);
194
+ const toolResults = await this.handleToolCalls(toolCalls);
195
+ for (const result of toolResults) {
196
+ const resultEntry = transformers_1.chatCompletionsTransformer.toolResultEntry(result.toolCallId, result.content);
197
+ this.addToHistory(resultEntry);
198
+ }
199
+ try {
200
+ const newResponse = await this.callProvider();
201
+ this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, newResponse);
202
+ return this.handleResponse(newResponse);
203
+ }
204
+ catch (error) {
205
+ const executionError = new AgentError_1.ExecutionError(`${this.getVendorName()} error during tool response: ${error instanceof Error ? error.message : "Unknown error"}`);
206
+ this.emit(AgentEvent_1.AgentEvent.ERROR, executionError);
207
+ throw executionError;
208
+ }
209
+ }
210
+ async handleToolCalls(toolCalls) {
211
+ return Promise.all(toolCalls.map(async (toolCall) => {
212
+ const toolName = toolCall.type === "function" ? toolCall.function.name : "";
213
+ const tool = this.tools.get(toolName);
214
+ const toolCallId = toolCall.id;
215
+ if (toolCall.type !== "function" || !tool) {
216
+ const errorMessage = `Tool '${toolName}' not found`;
217
+ const error = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.type === "function"
218
+ ? toolCall.function.arguments
219
+ : undefined);
220
+ this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, error);
221
+ return { toolCallId, content: errorMessage };
222
+ }
223
+ try {
224
+ const args = JSON.parse(toolCall.function.arguments || "{}");
225
+ const result = await tool.execute(this.getId(), this.getName(), args, toolCallId, this.config.model, this.vendor);
226
+ return { toolCallId, content: JSON.stringify(result) };
227
+ }
228
+ catch (error) {
229
+ const errorMessage = `Error executing tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`;
230
+ if (this.debug) {
231
+ console.error(errorMessage);
232
+ }
233
+ const toolError = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.function.arguments);
234
+ this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, toolError);
235
+ return { toolCallId, content: errorMessage };
236
+ }
237
+ }));
238
+ }
239
+ parseUsage(response) {
240
+ const usage = response.usage;
241
+ return {
242
+ input_tokens: usage?.prompt_tokens ?? 0,
243
+ output_tokens: usage?.completion_tokens ?? 0,
244
+ total_tokens: usage?.total_tokens ?? 0,
245
+ };
246
+ }
247
+ }
248
+ exports.OpenAICompatibleAgent = OpenAICompatibleAgent;
249
+ //# sourceMappingURL=OpenAICompatibleAgent.js.map
package/dist/core.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./history/History";
7
7
  export * from "./history/types";
8
8
  export * from "./graph/AgentGraph";
9
9
  export * from "./tools/Tool";
10
+ export * from "./tools/BuiltInTool";
10
11
  export * from "./mcp";
11
12
  export * from "./viz";
12
13
  export * from "./embeddings";
package/dist/core.js CHANGED
@@ -29,6 +29,7 @@ __exportStar(require("./history/types"), exports);
29
29
  __exportStar(require("./graph/AgentGraph"), exports);
30
30
  // Tools
31
31
  __exportStar(require("./tools/Tool"), exports);
32
+ __exportStar(require("./tools/BuiltInTool"), exports);
32
33
  // MCP (Model Context Protocol)
33
34
  __exportStar(require("./mcp"), exports);
34
35
  // Visualization
@@ -134,5 +134,69 @@ export declare const ollamaTransformer: {
134
134
  */
135
135
  toolResultEntry(tool_call_id: string, output: string): HistoryEntry;
136
136
  };
137
+ /**
138
+ * Convert normalized entries to/from the OpenAI Chat Completions message format
139
+ * (`/v1/chat/completions`). Used by `LlamaCppAgent` and any other agent that
140
+ * targets an OpenAI-compatible chat-completions endpoint.
141
+ */
142
+ export declare const chatCompletionsTransformer: {
143
+ /**
144
+ * Convert normalized entries to Chat Completions message format.
145
+ * Tool results become role:"tool" messages; tool calls are embedded in assistant messages.
146
+ */
147
+ toProvider(entries: HistoryEntry[]): ChatCompletionMessage[];
148
+ /**
149
+ * Convert a Chat Completions response message to a normalized HistoryEntry.
150
+ */
151
+ fromProviderMessage(message: ChatCompletionResponseMessage): HistoryEntry;
152
+ /**
153
+ * Create a normalized tool result entry for a Chat Completions tool call
154
+ */
155
+ toolResultEntry(tool_call_id: string, output: string): HistoryEntry;
156
+ };
157
+ type ChatCompletionToolCallParam = {
158
+ id: string;
159
+ type: "function";
160
+ function: {
161
+ name: string;
162
+ arguments: string;
163
+ };
164
+ };
165
+ type ChatCompletionContentPart = {
166
+ type: "text";
167
+ text: string;
168
+ } | {
169
+ type: "image_url";
170
+ image_url: {
171
+ url: string;
172
+ detail?: "auto" | "low" | "high";
173
+ };
174
+ };
175
+ type ChatCompletionMessage = {
176
+ role: "system";
177
+ content: string;
178
+ } | {
179
+ role: "user";
180
+ content: string | ChatCompletionContentPart[];
181
+ } | {
182
+ role: "assistant";
183
+ content: string | null;
184
+ tool_calls?: ChatCompletionToolCallParam[];
185
+ } | {
186
+ role: "tool";
187
+ tool_call_id: string;
188
+ content: string;
189
+ };
190
+ type ChatCompletionResponseMessage = {
191
+ role: string;
192
+ content: string | null;
193
+ tool_calls?: Array<{
194
+ id: string;
195
+ function?: {
196
+ name: string;
197
+ arguments: string;
198
+ };
199
+ }>;
200
+ };
137
201
  export {};
138
202
  //# sourceMappingURL=transformers.d.ts.map
@@ -5,7 +5,7 @@
5
5
  * Transform between normalized HistoryEntry format and provider-specific formats.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ollamaTransformer = exports.geminiTransformer = exports.mistralTransformer = exports.openAiTransformer = exports.anthropicTransformer = void 0;
8
+ exports.chatCompletionsTransformer = exports.ollamaTransformer = exports.geminiTransformer = exports.mistralTransformer = exports.openAiTransformer = exports.anthropicTransformer = void 0;
9
9
  const types_1 = require("./types");
10
10
  // =============================================================================
11
11
  // Anthropic Transformer
@@ -576,4 +576,121 @@ exports.ollamaTransformer = {
576
576
  };
577
577
  },
578
578
  };
579
+ // =============================================================================
580
+ // Chat Completions Transformer (OpenAI-compatible servers, e.g. llama.cpp)
581
+ // =============================================================================
582
+ /**
583
+ * Convert normalized entries to/from the OpenAI Chat Completions message format
584
+ * (`/v1/chat/completions`). Used by `LlamaCppAgent` and any other agent that
585
+ * targets an OpenAI-compatible chat-completions endpoint.
586
+ */
587
+ exports.chatCompletionsTransformer = {
588
+ /**
589
+ * Convert normalized entries to Chat Completions message format.
590
+ * Tool results become role:"tool" messages; tool calls are embedded in assistant messages.
591
+ */
592
+ toProvider(entries) {
593
+ const messages = [];
594
+ for (const entry of entries) {
595
+ const textBlocks = entry.content.filter(types_1.isTextContent);
596
+ const toolUseBlocks = entry.content.filter(types_1.isToolUseContent);
597
+ const toolResultBlocks = entry.content.filter(types_1.isToolResultContent);
598
+ const imageUrlBlocks = entry.content.filter(types_1.isImageUrlContent);
599
+ const imageBase64Blocks = entry.content.filter(types_1.isImageBase64Content);
600
+ const hasImages = imageUrlBlocks.length > 0 || imageBase64Blocks.length > 0;
601
+ if (entry.role === "system") {
602
+ messages.push({ role: "system", content: textBlocks.map((c) => c.text).join("\n") });
603
+ continue;
604
+ }
605
+ if (entry.role === "assistant") {
606
+ const msg = {
607
+ role: "assistant",
608
+ content: textBlocks.map((c) => c.text).join("\n") || null,
609
+ };
610
+ if (toolUseBlocks.length > 0) {
611
+ msg.tool_calls = toolUseBlocks.map((block) => ({
612
+ id: block.id,
613
+ type: "function",
614
+ function: {
615
+ name: block.name,
616
+ arguments: JSON.stringify(block.input),
617
+ },
618
+ }));
619
+ }
620
+ messages.push(msg);
621
+ continue;
622
+ }
623
+ // User role — could be text, images, or tool results
624
+ if (toolResultBlocks.length > 0) {
625
+ for (const result of toolResultBlocks) {
626
+ messages.push({
627
+ role: "tool",
628
+ tool_call_id: result.tool_use_id,
629
+ content: result.content,
630
+ });
631
+ }
632
+ }
633
+ else if (hasImages) {
634
+ const parts = [];
635
+ for (const block of entry.content) {
636
+ if ((0, types_1.isTextContent)(block)) {
637
+ parts.push({ type: "text", text: block.text });
638
+ }
639
+ else if ((0, types_1.isImageUrlContent)(block)) {
640
+ parts.push({
641
+ type: "image_url",
642
+ image_url: {
643
+ url: block.url,
644
+ ...(block.detail ? { detail: block.detail } : {}),
645
+ },
646
+ });
647
+ }
648
+ else if ((0, types_1.isImageBase64Content)(block)) {
649
+ parts.push({
650
+ type: "image_url",
651
+ image_url: { url: `data:${block.mimeType};base64,${block.data}` },
652
+ });
653
+ }
654
+ }
655
+ messages.push({ role: "user", content: parts });
656
+ }
657
+ else if (textBlocks.length > 0) {
658
+ messages.push({ role: "user", content: textBlocks.map((c) => c.text).join("\n") });
659
+ }
660
+ }
661
+ return messages;
662
+ },
663
+ /**
664
+ * Convert a Chat Completions response message to a normalized HistoryEntry.
665
+ */
666
+ fromProviderMessage(message) {
667
+ const content = [];
668
+ if (typeof message.content === "string" && message.content) {
669
+ content.push((0, types_1.text)(message.content));
670
+ }
671
+ if (message.tool_calls) {
672
+ message.tool_calls.forEach((call) => {
673
+ if (!call.function)
674
+ return;
675
+ const args = JSON.parse(call.function.arguments || "{}");
676
+ content.push((0, types_1.toolUse)(call.id, call.function.name, args));
677
+ });
678
+ }
679
+ return {
680
+ role: "assistant",
681
+ content,
682
+ meta: { provider: "llamacpp" },
683
+ };
684
+ },
685
+ /**
686
+ * Create a normalized tool result entry for a Chat Completions tool call
687
+ */
688
+ toolResultEntry(tool_call_id, output) {
689
+ return {
690
+ role: "user",
691
+ content: [(0, types_1.toolResult)(tool_call_id, output)],
692
+ meta: { provider: "llamacpp", tool_call_id },
693
+ };
694
+ },
695
+ };
579
696
  //# sourceMappingURL=transformers.js.map
@@ -94,10 +94,17 @@ export type OllamaMeta = {
94
94
  provider: "ollama";
95
95
  tool_call_id?: string;
96
96
  };
97
+ /**
98
+ * llama.cpp-specific metadata
99
+ */
100
+ export type LlamaCppMeta = {
101
+ provider: "llamacpp";
102
+ tool_call_id?: string;
103
+ };
97
104
  /**
98
105
  * Union of all provider metadata types
99
106
  */
100
- export type ProviderMeta = AnthropicMeta | OpenAiMeta | MistralMeta | GeminiMeta | OllamaMeta;
107
+ export type ProviderMeta = AnthropicMeta | OpenAiMeta | MistralMeta | GeminiMeta | OllamaMeta | LlamaCppMeta;
101
108
  /**
102
109
  * Valid roles for history entries
103
110
  */
package/dist/index.d.ts CHANGED
@@ -4,15 +4,19 @@ export { OpenAiAgent } from "./agents/openai/OpenAiAgent";
4
4
  export { MistralAgent } from "./agents/mistral/MistralAgent";
5
5
  export { GeminiAgent } from "./agents/google/GeminiAgent";
6
6
  export { OllamaAgent } from "./agents/ollama/OllamaAgent";
7
+ export { LlamaCppAgent } from "./agents/llamacpp/LlamaCppAgent";
8
+ export { OpenAICompatibleAgent } from "./agents/openai-compatible/OpenAICompatibleAgent";
9
+ export type { OpenAICompatibleConfig } from "./agents/openai-compatible/OpenAICompatibleAgent";
7
10
  export * from "./agents/model-types";
8
11
  export * from "./agents/AgentConfig";
9
12
  export * from "./agents/AgentEvent";
10
13
  export * from "./agents/errors/AgentError";
11
14
  export * from "./history/History";
12
15
  export * from "./history/types";
13
- export { anthropicTransformer, openAiTransformer, mistralTransformer, geminiTransformer, ollamaTransformer, } from "./history/transformers";
16
+ export { anthropicTransformer, openAiTransformer, mistralTransformer, geminiTransformer, ollamaTransformer, chatCompletionsTransformer, } from "./history/transformers";
14
17
  export * from "./graph/AgentGraph";
15
18
  export * from "./tools/Tool";
19
+ export * from "./tools/BuiltInTool";
16
20
  export * from "./mcp";
17
21
  export * from "./viz";
18
22
  export * from "./vectorstore";
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
22
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ollamaTransformer = exports.geminiTransformer = exports.mistralTransformer = exports.openAiTransformer = exports.anthropicTransformer = exports.OllamaAgent = exports.GeminiAgent = exports.MistralAgent = exports.OpenAiAgent = void 0;
25
+ exports.chatCompletionsTransformer = exports.ollamaTransformer = exports.geminiTransformer = exports.mistralTransformer = exports.openAiTransformer = exports.anthropicTransformer = exports.OpenAICompatibleAgent = exports.LlamaCppAgent = exports.OllamaAgent = exports.GeminiAgent = exports.MistralAgent = exports.OpenAiAgent = void 0;
26
26
  // Agents
27
27
  __exportStar(require("./agents/BaseAgent"), exports);
28
28
  __exportStar(require("./agents/anthropic/ClaudeAgent"), exports);
@@ -34,6 +34,10 @@ var GeminiAgent_1 = require("./agents/google/GeminiAgent");
34
34
  Object.defineProperty(exports, "GeminiAgent", { enumerable: true, get: function () { return GeminiAgent_1.GeminiAgent; } });
35
35
  var OllamaAgent_1 = require("./agents/ollama/OllamaAgent");
36
36
  Object.defineProperty(exports, "OllamaAgent", { enumerable: true, get: function () { return OllamaAgent_1.OllamaAgent; } });
37
+ var LlamaCppAgent_1 = require("./agents/llamacpp/LlamaCppAgent");
38
+ Object.defineProperty(exports, "LlamaCppAgent", { enumerable: true, get: function () { return LlamaCppAgent_1.LlamaCppAgent; } });
39
+ var OpenAICompatibleAgent_1 = require("./agents/openai-compatible/OpenAICompatibleAgent");
40
+ Object.defineProperty(exports, "OpenAICompatibleAgent", { enumerable: true, get: function () { return OpenAICompatibleAgent_1.OpenAICompatibleAgent; } });
37
41
  __exportStar(require("./agents/model-types"), exports);
38
42
  __exportStar(require("./agents/AgentConfig"), exports);
39
43
  __exportStar(require("./agents/AgentEvent"), exports);
@@ -47,10 +51,12 @@ Object.defineProperty(exports, "openAiTransformer", { enumerable: true, get: fun
47
51
  Object.defineProperty(exports, "mistralTransformer", { enumerable: true, get: function () { return transformers_1.mistralTransformer; } });
48
52
  Object.defineProperty(exports, "geminiTransformer", { enumerable: true, get: function () { return transformers_1.geminiTransformer; } });
49
53
  Object.defineProperty(exports, "ollamaTransformer", { enumerable: true, get: function () { return transformers_1.ollamaTransformer; } });
54
+ Object.defineProperty(exports, "chatCompletionsTransformer", { enumerable: true, get: function () { return transformers_1.chatCompletionsTransformer; } });
50
55
  // Graph
51
56
  __exportStar(require("./graph/AgentGraph"), exports);
52
57
  // Tools
53
58
  __exportStar(require("./tools/Tool"), exports);
59
+ __exportStar(require("./tools/BuiltInTool"), exports);
54
60
  // MCP (Model Context Protocol)
55
61
  __exportStar(require("./mcp"), exports);
56
62
  // Visualization
@@ -0,0 +1,6 @@
1
+ export * from "./core";
2
+ export { LlamaCppAgent } from "./agents/llamacpp/LlamaCppAgent";
3
+ export { OpenAICompatibleAgent } from "./agents/openai-compatible/OpenAICompatibleAgent";
4
+ export type { OpenAICompatibleConfig } from "./agents/openai-compatible/OpenAICompatibleAgent";
5
+ export { chatCompletionsTransformer } from "./history/transformers";
6
+ //# sourceMappingURL=llamacpp.d.ts.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.chatCompletionsTransformer = exports.OpenAICompatibleAgent = exports.LlamaCppAgent = void 0;
18
+ // llama.cpp / OpenAI-compatible Agent Entry Point
19
+ __exportStar(require("./core"), exports);
20
+ var LlamaCppAgent_1 = require("./agents/llamacpp/LlamaCppAgent");
21
+ Object.defineProperty(exports, "LlamaCppAgent", { enumerable: true, get: function () { return LlamaCppAgent_1.LlamaCppAgent; } });
22
+ var OpenAICompatibleAgent_1 = require("./agents/openai-compatible/OpenAICompatibleAgent");
23
+ Object.defineProperty(exports, "OpenAICompatibleAgent", { enumerable: true, get: function () { return OpenAICompatibleAgent_1.OpenAICompatibleAgent; } });
24
+ var transformers_1 = require("./history/transformers");
25
+ Object.defineProperty(exports, "chatCompletionsTransformer", { enumerable: true, get: function () { return transformers_1.chatCompletionsTransformer; } });
26
+ //# sourceMappingURL=llamacpp.js.map
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Provider-defined ("built-in" / server-side) tools.
3
+ *
4
+ * Unlike `Tool`, these are not executed locally — the provider runs them as
5
+ * part of generating its response (e.g. Anthropic's web search, bash, and
6
+ * text editor tools). They carry no `execute` function or input schema; the
7
+ * agent simply forwards their definition to the provider's API.
8
+ *
9
+ * Pass arbitrary built-in tool definitions straight through — only `type`
10
+ * and `name` are required, any other provider-specific fields are allowed:
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const agent = new ClaudeAgent({
15
+ * ...,
16
+ * builtInTools: [
17
+ * { type: "web_search_20250305", name: "web_search", max_uses: 5 },
18
+ * ],
19
+ * });
20
+ * ```
21
+ *
22
+ * Or use one of the helpers below for the well-known Anthropic tools.
23
+ */
24
+ export interface BuiltInTool {
25
+ /** Provider-specific tool type identifier, e.g. `"web_search_20250305"` */
26
+ type: string;
27
+ /** Name the model will use to refer to the tool, e.g. `"web_search"` */
28
+ name: string;
29
+ /** Any additional provider-specific configuration for this tool */
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Options for Anthropic's web search tool (`web_search_20250305`).
34
+ * @see https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool
35
+ */
36
+ export interface WebSearchToolOptions {
37
+ /** Maximum number of searches Claude can perform during the request */
38
+ maxUses?: number;
39
+ /** Only include results from these domains (mutually exclusive with `blockedDomains`) */
40
+ allowedDomains?: string[];
41
+ /** Never include results from these domains (mutually exclusive with `allowedDomains`) */
42
+ blockedDomains?: string[];
43
+ /** Approximate user location, used to localize search results */
44
+ userLocation?: {
45
+ type?: "approximate";
46
+ city?: string;
47
+ region?: string;
48
+ country?: string;
49
+ timezone?: string;
50
+ };
51
+ }
52
+ /**
53
+ * Anthropic's server-side web search tool.
54
+ * Claude decides when to search and the results are fetched and processed by Anthropic.
55
+ */
56
+ export declare function webSearchTool(options?: WebSearchToolOptions): BuiltInTool;
57
+ /**
58
+ * Anthropic's server-side bash tool — gives Claude a persistent shell session.
59
+ * Requires a compatible model (e.g. Claude 4 / 3.7 Sonnet) and beta header support.
60
+ */
61
+ export declare function bashTool(): BuiltInTool;
62
+ /**
63
+ * Anthropic's server-side text editor tool — lets Claude view and edit text files.
64
+ */
65
+ export declare function textEditorTool(version?: "20250124" | "20250429" | "20250728"): BuiltInTool;
66
+ /**
67
+ * Define an arbitrary provider-defined / built-in tool by its raw definition.
68
+ * Use this to pass through tools not covered by the helpers above (or for
69
+ * other providers that support server-side tools).
70
+ */
71
+ export declare function builtInTool(definition: BuiltInTool): BuiltInTool;
72
+ //# sourceMappingURL=BuiltInTool.d.ts.map