@arvo-tools/agentic 0.3.0 → 0.4.1
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/Agent/agentTool.d.ts +4 -0
- package/dist/Agent/agentTool.d.ts.map +1 -0
- package/dist/Agent/agentTool.js +111 -0
- package/dist/Agent/agentTool.js.map +1 -0
- package/dist/Integrations/MCPClient.d.ts +80 -0
- package/dist/Integrations/MCPClient.d.ts.map +1 -0
- package/dist/Integrations/MCPClient.js +292 -0
- package/dist/Integrations/MCPClient.js.map +1 -0
- package/dist/Integrations/openai.d.ts +10 -0
- package/dist/Integrations/openai.d.ts.map +1 -0
- package/dist/Integrations/openai.js +353 -0
- package/dist/Integrations/openai.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { AgentInternalTool } from './types.js';
|
|
3
|
+
export declare const createAgentTool: <TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny>(param: AgentInternalTool<TInputSchema, TOutputSchema>) => AgentInternalTool<TInputSchema, TOutputSchema>;
|
|
4
|
+
//# sourceMappingURL=agentTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/Agent/agentTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,eAAe,GAC1B,YAAY,SAAS,CAAC,CAAC,UAAU,EACjC,aAAa,SAAS,CAAC,CAAC,UAAU,EAElC,OAAO,iBAAiB,CAAC,YAAY,EAAE,aAAa,CAAC,KAiD/C,iBAAiB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.createAgentTool = void 0;
|
|
51
|
+
var openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
52
|
+
var api_1 = require("@opentelemetry/api");
|
|
53
|
+
var arvo_core_1 = require("arvo-core");
|
|
54
|
+
var createAgentTool = function (param) {
|
|
55
|
+
return (__assign(__assign({}, param), { fn: function (input, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var _a;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan({
|
|
60
|
+
name: "AgentTool<".concat(param.name, ">.execute"),
|
|
61
|
+
disableSpanManagement: true,
|
|
62
|
+
context: {
|
|
63
|
+
inheritFrom: 'TRACE_HEADERS',
|
|
64
|
+
traceHeaders: config.otelInfo.headers,
|
|
65
|
+
},
|
|
66
|
+
spanOptions: {
|
|
67
|
+
attributes: (_a = {},
|
|
68
|
+
_a[openinference_semantic_conventions_1.SemanticConventions.OPENINFERENCE_SPAN_KIND] = openinference_semantic_conventions_1.OpenInferenceSpanKind.TOOL,
|
|
69
|
+
_a),
|
|
70
|
+
},
|
|
71
|
+
fn: function (span) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var inputValidation, result, err_1;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
_a.trys.push([0, 2, 3, 4]);
|
|
77
|
+
span.setAttribute(openinference_semantic_conventions_1.SemanticConventions.TOOL_CALL_FUNCTION_NAME, param.name);
|
|
78
|
+
span.setAttribute(openinference_semantic_conventions_1.SemanticConventions.TOOL_CALL_FUNCTION_ARGUMENTS_JSON, JSON.stringify(input));
|
|
79
|
+
span.setAttribute(openinference_semantic_conventions_1.SemanticConventions.INPUT_VALUE, JSON.stringify(input));
|
|
80
|
+
inputValidation = param.input.safeParse(input);
|
|
81
|
+
if (inputValidation.error)
|
|
82
|
+
throw new Error("Invalid tool input data. Please send the correct data and its structure as per the input schema. ".concat(inputValidation.error.toString()));
|
|
83
|
+
return [4 /*yield*/, param.fn(inputValidation.data, {
|
|
84
|
+
otelInfo: {
|
|
85
|
+
span: span,
|
|
86
|
+
headers: (0, arvo_core_1.getOtelHeaderFromSpan)(span),
|
|
87
|
+
},
|
|
88
|
+
})];
|
|
89
|
+
case 1:
|
|
90
|
+
result = _a.sent();
|
|
91
|
+
span.setAttribute(openinference_semantic_conventions_1.SemanticConventions.OUTPUT_VALUE, JSON.stringify(result));
|
|
92
|
+
return [2 /*return*/, result];
|
|
93
|
+
case 2:
|
|
94
|
+
err_1 = _a.sent();
|
|
95
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: err_1 === null || err_1 === void 0 ? void 0 : err_1.message });
|
|
96
|
+
throw err_1;
|
|
97
|
+
case 3:
|
|
98
|
+
span.end();
|
|
99
|
+
return [7 /*endfinally*/];
|
|
100
|
+
case 4: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); },
|
|
104
|
+
})];
|
|
105
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); } }));
|
|
109
|
+
};
|
|
110
|
+
exports.createAgentTool = createAgentTool;
|
|
111
|
+
//# sourceMappingURL=agentTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTool.js","sourceRoot":"","sources":["../../src/Agent/agentTool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAGqD;AACrD,0CAAoD;AACpD,uCAAqE;AAK9D,IAAM,eAAe,GAAG,UAI7B,KAAqD;IAErD,OAAA,uBACK,KAAK,KACR,EAAE,EAAE,UAAO,KAA4B,EAAE,MAAkC;;;;4BACzE,qBAAM,6BAAiB,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC;4BACpD,IAAI,EAAE,oBAAa,KAAK,CAAC,IAAI,cAAW;4BACxC,qBAAqB,EAAE,IAAI;4BAC3B,OAAO,EAAE;gCACP,WAAW,EAAE,eAAe;gCAC5B,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO;6BACtC;4BACD,WAAW,EAAE;gCACX,UAAU;oCACR,GAAC,wDAAgC,CAAC,uBAAuB,IAAG,0DAAqB,CAAC,IAAI;uCACvF;6BACF;4BACD,EAAE,EAAE,UAAO,IAAI;;;;;;4CAEX,IAAI,CAAC,YAAY,CAAC,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InfoType } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Model Context Protocol (MCP) client implementation for connecting to and interacting with MCP servers.
|
|
5
|
+
*
|
|
6
|
+
* This client provides a robust interface for establishing connections to MCP servers,
|
|
7
|
+
* discovering available tools, invoking those tools with arguments, and managing the
|
|
8
|
+
* connection lifecycle. It supports both Server-Sent Events (SSE) and streamable HTTP
|
|
9
|
+
* transport protocols, automatically selecting the appropriate transport based on the URL.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MCPClient implements IMCPClient {
|
|
12
|
+
private client;
|
|
13
|
+
private isConnected;
|
|
14
|
+
private availableTools;
|
|
15
|
+
private readonly url;
|
|
16
|
+
private readonly requestInit;
|
|
17
|
+
constructor(param: {
|
|
18
|
+
url: string;
|
|
19
|
+
requestInit?: RequestInit;
|
|
20
|
+
} | (() => {
|
|
21
|
+
url: string;
|
|
22
|
+
requestInit?: RequestInit;
|
|
23
|
+
}));
|
|
24
|
+
/**
|
|
25
|
+
* Establishes a connection to the MCP server and discovers available tools.
|
|
26
|
+
*
|
|
27
|
+
* This method performs the following operations:
|
|
28
|
+
* 1. Selects the appropriate transport (SSE or HTTP streaming) based on URL
|
|
29
|
+
* 2. Creates and configures the MCP client with capabilities
|
|
30
|
+
* 3. Establishes the connection to the server
|
|
31
|
+
* 4. Retrieves and caches the list of available tools
|
|
32
|
+
* 5. Logs all operations to the provided OpenTelemetry span
|
|
33
|
+
*
|
|
34
|
+
* @returns Promise that resolves when connection is established and tools are discovered
|
|
35
|
+
* @throws {Error} Throws an error if connection fails, with details logged to the span
|
|
36
|
+
*/
|
|
37
|
+
connect(config: {
|
|
38
|
+
otelInfo: OtelInfoType;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the list of available tool definitions from the connected MCP server.
|
|
42
|
+
*
|
|
43
|
+
* Transforms the cached MCP tools into the AgentToolDefinition format required
|
|
44
|
+
* by the agent system. Tools listed in restrictedTools will have requires_approval set to true.
|
|
45
|
+
* This method returns an empty array if not connected.
|
|
46
|
+
*/
|
|
47
|
+
getTools(config: {
|
|
48
|
+
otelInfo: OtelInfoType;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
inputSchema: Record<string, any>;
|
|
53
|
+
}[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Invokes a specific tool on the MCP server with the provided arguments.
|
|
56
|
+
*
|
|
57
|
+
* This method sends a tool invocation request to the connected MCP server and
|
|
58
|
+
* returns the result. All operations are logged to the OpenTelemetry span for
|
|
59
|
+
* observability. If an error occurs during invocation, it returns an error message
|
|
60
|
+
* rather than throwing, allowing the agent to handle tool failures gracefully.
|
|
61
|
+
*/
|
|
62
|
+
invokeTool(param: {
|
|
63
|
+
name: string;
|
|
64
|
+
arguments?: Record<string, unknown> | null;
|
|
65
|
+
}, config: {
|
|
66
|
+
otelInfo: OtelInfoType;
|
|
67
|
+
}): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Gracefully disconnects from the MCP server and cleans up resources.
|
|
70
|
+
*
|
|
71
|
+
* This method safely closes the connection to the MCP server if one exists,
|
|
72
|
+
* resets the connection state, and clears cached data. It's safe to call
|
|
73
|
+
* multiple times - subsequent calls will be no-ops if already disconnected.
|
|
74
|
+
*/
|
|
75
|
+
disconnect(config: {
|
|
76
|
+
otelInfo: OtelInfoType;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
getToolPriority(): Promise<{}>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=MCPClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MCPClient.d.ts","sourceRoot":"","sources":["../../src/Integrations/MCPClient.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;GAOG;AACH,qBAAa,SA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arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.MCPClient = void 0;
|
|
51
|
+
var index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
52
|
+
var sse_js_1 = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
53
|
+
var streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
54
|
+
var api_1 = require("@opentelemetry/api");
|
|
55
|
+
var arvo_core_1 = require("arvo-core");
|
|
56
|
+
/**
|
|
57
|
+
* Model Context Protocol (MCP) client implementation for connecting to and interacting with MCP servers.
|
|
58
|
+
*
|
|
59
|
+
* This client provides a robust interface for establishing connections to MCP servers,
|
|
60
|
+
* discovering available tools, invoking those tools with arguments, and managing the
|
|
61
|
+
* connection lifecycle. It supports both Server-Sent Events (SSE) and streamable HTTP
|
|
62
|
+
* transport protocols, automatically selecting the appropriate transport based on the URL.
|
|
63
|
+
*/
|
|
64
|
+
var MCPClient = /** @class */ (function () {
|
|
65
|
+
function MCPClient(param) {
|
|
66
|
+
this.client = null;
|
|
67
|
+
this.isConnected = false;
|
|
68
|
+
this.availableTools = [];
|
|
69
|
+
this.url = function () { return (typeof param === 'function' ? param() : param).url; };
|
|
70
|
+
this.requestInit = function () { var _a; return (_a = (typeof param === 'function' ? param() : param).requestInit) !== null && _a !== void 0 ? _a : {}; };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Establishes a connection to the MCP server and discovers available tools.
|
|
74
|
+
*
|
|
75
|
+
* This method performs the following operations:
|
|
76
|
+
* 1. Selects the appropriate transport (SSE or HTTP streaming) based on URL
|
|
77
|
+
* 2. Creates and configures the MCP client with capabilities
|
|
78
|
+
* 3. Establishes the connection to the server
|
|
79
|
+
* 4. Retrieves and caches the list of available tools
|
|
80
|
+
* 5. Logs all operations to the provided OpenTelemetry span
|
|
81
|
+
*
|
|
82
|
+
* @returns Promise that resolves when connection is established and tools are discovered
|
|
83
|
+
* @throws {Error} Throws an error if connection fails, with details logged to the span
|
|
84
|
+
*/
|
|
85
|
+
MCPClient.prototype.connect = function (config) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var url, requestInit, transport, tools, error_1;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
_a.trys.push([0, 3, , 4]);
|
|
92
|
+
url = this.url();
|
|
93
|
+
requestInit = this.requestInit();
|
|
94
|
+
transport = url.includes('/mcp')
|
|
95
|
+
? new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(url), { requestInit: requestInit })
|
|
96
|
+
: new sse_js_1.SSEClientTransport(new URL(url), { requestInit: requestInit });
|
|
97
|
+
this.client = new index_js_1.Client({
|
|
98
|
+
name: 'arvo-tools-agentic-mcp-client',
|
|
99
|
+
version: '1.0.0',
|
|
100
|
+
});
|
|
101
|
+
return [4 /*yield*/, this.client.connect(transport)];
|
|
102
|
+
case 1:
|
|
103
|
+
_a.sent();
|
|
104
|
+
(0, arvo_core_1.logToSpan)({
|
|
105
|
+
level: 'INFO',
|
|
106
|
+
message: "Connected to MCP Server@".concat(url),
|
|
107
|
+
}, config.otelInfo.span);
|
|
108
|
+
return [4 /*yield*/, this.client.listTools()];
|
|
109
|
+
case 2:
|
|
110
|
+
tools = _a.sent();
|
|
111
|
+
this.availableTools = tools.tools;
|
|
112
|
+
this.isConnected = true;
|
|
113
|
+
(0, arvo_core_1.logToSpan)({
|
|
114
|
+
level: 'INFO',
|
|
115
|
+
message: 'Available MCP tools:',
|
|
116
|
+
tools: JSON.stringify(this.availableTools.map(function (t) { return ({ name: t.name, description: t.description }); })),
|
|
117
|
+
}, config.otelInfo.span);
|
|
118
|
+
return [3 /*break*/, 4];
|
|
119
|
+
case 3:
|
|
120
|
+
error_1 = _a.sent();
|
|
121
|
+
(0, arvo_core_1.exceptionToSpan)(error_1, config.otelInfo.span);
|
|
122
|
+
this.isConnected = false;
|
|
123
|
+
throw new Error("Unable to connect to the MCP Server@".concat(this.url()));
|
|
124
|
+
case 4: return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves the list of available tool definitions from the connected MCP server.
|
|
131
|
+
*
|
|
132
|
+
* Transforms the cached MCP tools into the AgentToolDefinition format required
|
|
133
|
+
* by the agent system. Tools listed in restrictedTools will have requires_approval set to true.
|
|
134
|
+
* This method returns an empty array if not connected.
|
|
135
|
+
*/
|
|
136
|
+
MCPClient.prototype.getTools = function (config) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
var toolDef, _a, _b, item;
|
|
139
|
+
var e_1, _c;
|
|
140
|
+
var _d;
|
|
141
|
+
return __generator(this, function (_e) {
|
|
142
|
+
toolDef = [];
|
|
143
|
+
if (!this.isConnected) {
|
|
144
|
+
(0, arvo_core_1.logToSpan)({
|
|
145
|
+
level: 'WARNING',
|
|
146
|
+
message: "Cannot get tools - not connected to MCP Server@".concat(this.url()),
|
|
147
|
+
}, config.otelInfo.span);
|
|
148
|
+
return [2 /*return*/, toolDef];
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
for (_a = __values(this.availableTools), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
152
|
+
item = _b.value;
|
|
153
|
+
toolDef.push({
|
|
154
|
+
name: item.name,
|
|
155
|
+
description: (_d = item.description) !== null && _d !== void 0 ? _d : '',
|
|
156
|
+
inputSchema: item.inputSchema,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
161
|
+
finally {
|
|
162
|
+
try {
|
|
163
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
164
|
+
}
|
|
165
|
+
finally { if (e_1) throw e_1.error; }
|
|
166
|
+
}
|
|
167
|
+
(0, arvo_core_1.logToSpan)({
|
|
168
|
+
level: 'INFO',
|
|
169
|
+
message: "Retrieved ".concat(toolDef.length, " tool definitions from MCP Server@").concat(this.url()),
|
|
170
|
+
}, config.otelInfo.span);
|
|
171
|
+
return [2 /*return*/, toolDef];
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Invokes a specific tool on the MCP server with the provided arguments.
|
|
177
|
+
*
|
|
178
|
+
* This method sends a tool invocation request to the connected MCP server and
|
|
179
|
+
* returns the result. All operations are logged to the OpenTelemetry span for
|
|
180
|
+
* observability. If an error occurs during invocation, it returns an error message
|
|
181
|
+
* rather than throwing, allowing the agent to handle tool failures gracefully.
|
|
182
|
+
*/
|
|
183
|
+
MCPClient.prototype.invokeTool = function (param, config) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
var _this = this;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0: return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan({
|
|
189
|
+
name: "MCP.invoke<".concat(param.name, ">"),
|
|
190
|
+
disableSpanManagement: true,
|
|
191
|
+
context: {
|
|
192
|
+
inheritFrom: 'TRACE_HEADERS',
|
|
193
|
+
traceHeaders: config.otelInfo.headers,
|
|
194
|
+
},
|
|
195
|
+
fn: function (span) { return __awaiter(_this, void 0, void 0, function () {
|
|
196
|
+
var result, error_2, err;
|
|
197
|
+
var _a, _b;
|
|
198
|
+
return __generator(this, function (_c) {
|
|
199
|
+
switch (_c.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
_c.trys.push([0, 2, 3, 4]);
|
|
202
|
+
span.setAttribute(arvo_core_1.OpenInference.ATTR_SPAN_KIND, arvo_core_1.OpenInferenceSpanKind.TOOL);
|
|
203
|
+
span.setStatus({
|
|
204
|
+
code: api_1.SpanStatusCode.OK,
|
|
205
|
+
});
|
|
206
|
+
(0, arvo_core_1.logToSpan)({
|
|
207
|
+
level: 'INFO',
|
|
208
|
+
message: "Invoking tool<".concat(param.name, "> with arguments on MCP Server@").concat(this.url()),
|
|
209
|
+
param: JSON.stringify(param),
|
|
210
|
+
}, span);
|
|
211
|
+
if (!this.isConnected || !this.client) {
|
|
212
|
+
throw new Error("MCP Server@".concat(this.url(), " not connected"));
|
|
213
|
+
}
|
|
214
|
+
return [4 /*yield*/, this.client.callTool({
|
|
215
|
+
name: param.name,
|
|
216
|
+
arguments: (_a = param.arguments) !== null && _a !== void 0 ? _a : undefined,
|
|
217
|
+
})];
|
|
218
|
+
case 1:
|
|
219
|
+
result = _c.sent();
|
|
220
|
+
(0, arvo_core_1.logToSpan)({
|
|
221
|
+
level: 'INFO',
|
|
222
|
+
message: "Successfully invoked tool<".concat(param.name, "> on MCP Server@").concat(this.url()),
|
|
223
|
+
}, span);
|
|
224
|
+
return [2 /*return*/, JSON.stringify(result)];
|
|
225
|
+
case 2:
|
|
226
|
+
error_2 = _c.sent();
|
|
227
|
+
err = new Error("Error occurred while invoking MCP tool <".concat(param.name, "@").concat(this.url(), "> -> ").concat((_b = error_2 === null || error_2 === void 0 ? void 0 : error_2.message) !== null && _b !== void 0 ? _b : 'Something went wrong'));
|
|
228
|
+
(0, arvo_core_1.exceptionToSpan)(err, span);
|
|
229
|
+
span.setStatus({
|
|
230
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
231
|
+
message: err.message,
|
|
232
|
+
});
|
|
233
|
+
return [2 /*return*/, err.message];
|
|
234
|
+
case 3:
|
|
235
|
+
span.end();
|
|
236
|
+
return [7 /*endfinally*/];
|
|
237
|
+
case 4: return [2 /*return*/];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}); },
|
|
241
|
+
})];
|
|
242
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Gracefully disconnects from the MCP server and cleans up resources.
|
|
249
|
+
*
|
|
250
|
+
* This method safely closes the connection to the MCP server if one exists,
|
|
251
|
+
* resets the connection state, and clears cached data. It's safe to call
|
|
252
|
+
* multiple times - subsequent calls will be no-ops if already disconnected.
|
|
253
|
+
*/
|
|
254
|
+
MCPClient.prototype.disconnect = function (config) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
return __generator(this, function (_a) {
|
|
257
|
+
switch (_a.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
if (!(this.client && this.isConnected)) return [3 /*break*/, 2];
|
|
260
|
+
return [4 /*yield*/, this.client.close()];
|
|
261
|
+
case 1:
|
|
262
|
+
_a.sent();
|
|
263
|
+
this.isConnected = false;
|
|
264
|
+
this.availableTools = [];
|
|
265
|
+
this.client = null;
|
|
266
|
+
(0, arvo_core_1.logToSpan)({
|
|
267
|
+
level: 'INFO',
|
|
268
|
+
message: "Disconnected from MCP Server@".concat(this.url()),
|
|
269
|
+
}, config.otelInfo.span);
|
|
270
|
+
return [3 /*break*/, 3];
|
|
271
|
+
case 2:
|
|
272
|
+
(0, arvo_core_1.logToSpan)({
|
|
273
|
+
level: 'INFO',
|
|
274
|
+
message: "MCP Server@".concat(this.url(), " already disconnected"),
|
|
275
|
+
}, config.otelInfo.span);
|
|
276
|
+
_a.label = 3;
|
|
277
|
+
case 3: return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
MCPClient.prototype.getToolPriority = function () {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
+
return __generator(this, function (_a) {
|
|
285
|
+
return [2 /*return*/, {}];
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
return MCPClient;
|
|
290
|
+
}());
|
|
291
|
+
exports.MCPClient = MCPClient;
|
|
292
|
+
//# sourceMappingURL=MCPClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MCPClient.js","sourceRoot":"","sources":["../../src/Integrations/MCPClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAmE;AACnE,kEAA6E;AAC7E,wFAAmG;AAEnG,0CAAoD;AACpD,uCAMmB;AAInB;;;;;;;GAOG;AACH;IAOE,mBACE,KAEsD;QAEtD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,cAAM,OAAA,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,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ACtD,EACD,MAAM,CAAC,QAAQ,CAAC,IAAI,CACrB,CAAC;;;wBAEF,IAAA,qBAAS,EACP;4BACE,KAAK,EAAE,MAAM;4BACb,OAAO,EAAE,qBAAc,IAAI,CAAC,GAAG,EAAE,0BAAuB;yBACzD,EACD,MAAM,CAAC,QAAQ,CAAC,IAAI,CACrB,CAAC;;;;;;KAEL;IACK,mCAAe,GAArB;;;gBACE,sBAAO,EAAE,EAAC;;;KACX;IACH,gBAAC;AAAD,CAAC,AA1OD,IA0OC;AA1OY,8BAAS"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type OpenAI from 'openai';
|
|
2
|
+
import type { ChatModel } from 'openai/resources/shared.mjs';
|
|
3
|
+
import type { AgentLLMIntegration } from '../Agent/types';
|
|
4
|
+
export declare const openaiLLMIntegration: (client: OpenAI, config?: {
|
|
5
|
+
model: ChatModel;
|
|
6
|
+
temperature?: number;
|
|
7
|
+
maxTokens?: number;
|
|
8
|
+
executionunits?: (prompt: number, completion: number) => number;
|
|
9
|
+
}) => AgentLLMIntegration;
|
|
10
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/Integrations/openai.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,KAAK,EACV,mBAAmB,EAMpB,MAAM,gBAAgB,CAAC;AA+FxB,eAAO,MAAM,oBAAoB,GAE7B,QAAQ,MAAM,EACd,SAAS;IACP,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACjE,KACA,mBA8KC,CAAC"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.openaiLLMIntegration = void 0;
|
|
51
|
+
var openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
52
|
+
var api_1 = require("@opentelemetry/api");
|
|
53
|
+
var arvo_core_1 = require("arvo-core");
|
|
54
|
+
var zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
55
|
+
var utils_1 = require("../Agent/utils");
|
|
56
|
+
var formatMessagesForOpenAI = function (messages, systemPrompt) {
|
|
57
|
+
var e_1, _a, e_2, _b;
|
|
58
|
+
var _c;
|
|
59
|
+
var formattedMessages = [];
|
|
60
|
+
if (systemPrompt) {
|
|
61
|
+
formattedMessages.push({
|
|
62
|
+
role: 'system',
|
|
63
|
+
content: systemPrompt,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var toolResponseMap = {};
|
|
67
|
+
try {
|
|
68
|
+
for (var messages_1 = __values(messages), messages_1_1 = messages_1.next(); !messages_1_1.done; messages_1_1 = messages_1.next()) {
|
|
69
|
+
var message = messages_1_1.value;
|
|
70
|
+
if (message.role === 'user' && message.content.type === 'tool_result') {
|
|
71
|
+
toolResponseMap[message.content.toolUseId] = message.content;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
76
|
+
finally {
|
|
77
|
+
try {
|
|
78
|
+
if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) _a.call(messages_1);
|
|
79
|
+
}
|
|
80
|
+
finally { if (e_1) throw e_1.error; }
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
for (var messages_2 = __values(messages), messages_2_1 = messages_2.next(); !messages_2_1.done; messages_2_1 = messages_2.next()) {
|
|
84
|
+
var message = messages_2_1.value;
|
|
85
|
+
if (message.role === 'user') {
|
|
86
|
+
if (message.content.type === 'text') {
|
|
87
|
+
formattedMessages.push({
|
|
88
|
+
role: 'user',
|
|
89
|
+
content: message.content.content,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (message.content.type === 'media' && message.content.contentType.type === 'image') {
|
|
93
|
+
formattedMessages.push({
|
|
94
|
+
role: 'user',
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'image_url',
|
|
98
|
+
image_url: {
|
|
99
|
+
url: message.content.content,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else if (message.content.type === 'media' && message.content.contentType.type === 'file') {
|
|
106
|
+
formattedMessages.push({
|
|
107
|
+
role: 'user',
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: 'file',
|
|
111
|
+
file: {
|
|
112
|
+
filename: message.content.contentType.filename,
|
|
113
|
+
file_data: message.content.content,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (message.role === 'assistant') {
|
|
121
|
+
if (message.content.type === 'text') {
|
|
122
|
+
formattedMessages.push({
|
|
123
|
+
role: 'assistant',
|
|
124
|
+
content: message.content.content,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else if (message.content.type === 'tool_use') {
|
|
128
|
+
formattedMessages.push({
|
|
129
|
+
role: 'assistant',
|
|
130
|
+
tool_calls: [
|
|
131
|
+
{
|
|
132
|
+
type: 'function',
|
|
133
|
+
id: message.content.toolUseId,
|
|
134
|
+
function: {
|
|
135
|
+
name: message.content.name,
|
|
136
|
+
arguments: JSON.stringify(message.content.input),
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
var toolResult = toolResponseMap[message.content.toolUseId];
|
|
142
|
+
formattedMessages.push({
|
|
143
|
+
role: 'tool',
|
|
144
|
+
tool_call_id: message.content.toolUseId,
|
|
145
|
+
content: (_c = toolResult === null || toolResult === void 0 ? void 0 : toolResult.content) !== null && _c !== void 0 ? _c : JSON.stringify({ error: 'No tool response' }),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
152
|
+
finally {
|
|
153
|
+
try {
|
|
154
|
+
if (messages_2_1 && !messages_2_1.done && (_b = messages_2.return)) _b.call(messages_2);
|
|
155
|
+
}
|
|
156
|
+
finally { if (e_2) throw e_2.error; }
|
|
157
|
+
}
|
|
158
|
+
return formattedMessages;
|
|
159
|
+
};
|
|
160
|
+
var openaiLLMIntegration = function (client, config) {
|
|
161
|
+
return function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
|
|
162
|
+
var _e;
|
|
163
|
+
var _messages = _c.messages, _system = _c.system, tools = _c.tools, outputFormat = _c.outputFormat, lifecycle = _c.lifecycle, toolInteractions = _c.toolInteractions;
|
|
164
|
+
var otelInfo = _d.otelInfo;
|
|
165
|
+
return __generator(this, function (_f) {
|
|
166
|
+
switch (_f.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan({
|
|
168
|
+
name: "LLM.invoke<".concat(lifecycle === 'init' ? 'init' : lifecycle === 'tool_result' ? 'resume' : 'output_validation_feedback', ">"),
|
|
169
|
+
disableSpanManagement: true,
|
|
170
|
+
context: {
|
|
171
|
+
inheritFrom: 'TRACE_HEADERS',
|
|
172
|
+
traceHeaders: otelInfo.headers,
|
|
173
|
+
},
|
|
174
|
+
spanOptions: {
|
|
175
|
+
attributes: (_e = {},
|
|
176
|
+
_e[openinference_semantic_conventions_1.SemanticConventions.OPENINFERENCE_SPAN_KIND] = openinference_semantic_conventions_1.OpenInferenceSpanKind.LLM,
|
|
177
|
+
_e),
|
|
178
|
+
},
|
|
179
|
+
fn: function (span) { return __awaiter(void 0, void 0, void 0, function () {
|
|
180
|
+
var llmModel, llmInvocationParams, messages, system, limitMessage, toolDef, tools_1, tools_1_1, tool, formattedMessages, responseFormat, completion, choice, llmUsage, executionUnits, toolRequests, _a, _b, toolCall, content, e_3;
|
|
181
|
+
var e_4, _c, e_5, _d;
|
|
182
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
183
|
+
return __generator(this, function (_s) {
|
|
184
|
+
switch (_s.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
llmModel = (_e = config === null || config === void 0 ? void 0 : config.model) !== null && _e !== void 0 ? _e : 'gpt-4o';
|
|
187
|
+
llmInvocationParams = {
|
|
188
|
+
temperature: (_f = config === null || config === void 0 ? void 0 : config.temperature) !== null && _f !== void 0 ? _f : 0,
|
|
189
|
+
maxTokens: (_g = config === null || config === void 0 ? void 0 : config.maxTokens) !== null && _g !== void 0 ? _g : 4096,
|
|
190
|
+
};
|
|
191
|
+
messages = _messages.map(function (item) {
|
|
192
|
+
if (lifecycle === 'init')
|
|
193
|
+
return item;
|
|
194
|
+
if (item.content.type === 'media') {
|
|
195
|
+
return {
|
|
196
|
+
role: item.role,
|
|
197
|
+
content: {
|
|
198
|
+
type: 'text',
|
|
199
|
+
content: "Media file (type: ".concat(item.content.contentType.type, "@").concat(item.content.contentType.format, ") already parsed and looked at. No need for you to look at it again"),
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return item;
|
|
204
|
+
});
|
|
205
|
+
system = _system;
|
|
206
|
+
if (toolInteractions.exhausted) {
|
|
207
|
+
limitMessage = (0, arvo_core_1.cleanString)("\n **CRITICAL WARNING: You have reached your tool interaction limit!**\n You must answer the original question using all the data available to you. \n You have run out of tool call budget. No more tool calls are allowed any more.\n If you cannot answer the query well. Then mention what you have done briefly, what\n can you answer based on the collected data, what data is missing and why you cannot \n answer any further. \n ");
|
|
208
|
+
messages.push({
|
|
209
|
+
role: 'user',
|
|
210
|
+
content: {
|
|
211
|
+
type: 'text',
|
|
212
|
+
content: limitMessage,
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
system = "".concat(system, "\n\n").concat(limitMessage);
|
|
216
|
+
}
|
|
217
|
+
(0, utils_1.setOpenInferenceInputAttr)({
|
|
218
|
+
llm: {
|
|
219
|
+
provider: 'openai',
|
|
220
|
+
system: 'openai',
|
|
221
|
+
model: llmModel,
|
|
222
|
+
invocationParam: llmInvocationParams,
|
|
223
|
+
},
|
|
224
|
+
messages: messages,
|
|
225
|
+
system: system,
|
|
226
|
+
tools: tools,
|
|
227
|
+
}, span);
|
|
228
|
+
_s.label = 1;
|
|
229
|
+
case 1:
|
|
230
|
+
_s.trys.push([1, 3, 4, 5]);
|
|
231
|
+
toolDef = [];
|
|
232
|
+
try {
|
|
233
|
+
for (tools_1 = __values(tools), tools_1_1 = tools_1.next(); !tools_1_1.done; tools_1_1 = tools_1.next()) {
|
|
234
|
+
tool = tools_1_1.value;
|
|
235
|
+
toolDef.push({
|
|
236
|
+
type: 'function',
|
|
237
|
+
function: {
|
|
238
|
+
name: tool.name,
|
|
239
|
+
description: tool.description,
|
|
240
|
+
parameters: tool.inputSchema,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
246
|
+
finally {
|
|
247
|
+
try {
|
|
248
|
+
if (tools_1_1 && !tools_1_1.done && (_c = tools_1.return)) _c.call(tools_1);
|
|
249
|
+
}
|
|
250
|
+
finally { if (e_4) throw e_4.error; }
|
|
251
|
+
}
|
|
252
|
+
formattedMessages = formatMessagesForOpenAI(messages, system);
|
|
253
|
+
responseFormat = outputFormat.type === 'json'
|
|
254
|
+
? {
|
|
255
|
+
type: 'json_schema',
|
|
256
|
+
json_schema: {
|
|
257
|
+
name: 'response_schema',
|
|
258
|
+
description: 'The required response schema',
|
|
259
|
+
// biome-ignore lint/suspicious/noExplicitAny: Make the typescript compiler ignore. Otherwise, it emits error "Type instantiation is excessively deep and possibly infinite. ts(2589)"
|
|
260
|
+
schema: (0, zod_to_json_schema_1.zodToJsonSchema)(outputFormat.format),
|
|
261
|
+
},
|
|
262
|
+
}
|
|
263
|
+
: undefined;
|
|
264
|
+
return [4 /*yield*/, client.chat.completions.create({
|
|
265
|
+
model: llmModel,
|
|
266
|
+
max_tokens: llmInvocationParams.maxTokens,
|
|
267
|
+
temperature: llmInvocationParams.temperature,
|
|
268
|
+
tools: toolDef.length ? toolDef : undefined,
|
|
269
|
+
messages: formattedMessages,
|
|
270
|
+
response_format: responseFormat,
|
|
271
|
+
})];
|
|
272
|
+
case 2:
|
|
273
|
+
completion = _s.sent();
|
|
274
|
+
choice = completion.choices[0];
|
|
275
|
+
llmUsage = {
|
|
276
|
+
tokens: {
|
|
277
|
+
prompt: (_j = (_h = completion.usage) === null || _h === void 0 ? void 0 : _h.prompt_tokens) !== null && _j !== void 0 ? _j : 0,
|
|
278
|
+
completion: (_l = (_k = completion.usage) === null || _k === void 0 ? void 0 : _k.completion_tokens) !== null && _l !== void 0 ? _l : 0,
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
executionUnits = (_o = (_m = config === null || config === void 0 ? void 0 : config.executionunits) === null || _m === void 0 ? void 0 : _m.call(config, llmUsage.tokens.prompt, llmUsage.tokens.completion)) !== null && _o !== void 0 ? _o : llmUsage.tokens.prompt + llmUsage.tokens.completion;
|
|
282
|
+
(0, utils_1.setOpenInferenceUsageOutputAttr)(llmUsage, span);
|
|
283
|
+
if ((_p = choice === null || choice === void 0 ? void 0 : choice.message) === null || _p === void 0 ? void 0 : _p.tool_calls) {
|
|
284
|
+
toolRequests = [];
|
|
285
|
+
try {
|
|
286
|
+
for (_a = __values(choice.message
|
|
287
|
+
.tool_calls), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
288
|
+
toolCall = _b.value;
|
|
289
|
+
try {
|
|
290
|
+
toolRequests.push({
|
|
291
|
+
toolUseId: toolCall.id,
|
|
292
|
+
name: toolCall.function.name,
|
|
293
|
+
input: JSON.parse(toolCall.function.arguments),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (_t) {
|
|
297
|
+
// Skip malformed tool calls
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
302
|
+
finally {
|
|
303
|
+
try {
|
|
304
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
305
|
+
}
|
|
306
|
+
finally { if (e_5) throw e_5.error; }
|
|
307
|
+
}
|
|
308
|
+
if (toolRequests.length) {
|
|
309
|
+
(0, utils_1.setOpenInferenceToolCallOutputAttr)({ toolCalls: toolRequests }, span);
|
|
310
|
+
return [2 /*return*/, {
|
|
311
|
+
type: 'tool_call',
|
|
312
|
+
toolRequests: toolRequests,
|
|
313
|
+
usage: llmUsage,
|
|
314
|
+
executionUnits: executionUnits,
|
|
315
|
+
}];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
content = (_r = (_q = choice === null || choice === void 0 ? void 0 : choice.message) === null || _q === void 0 ? void 0 : _q.content) !== null && _r !== void 0 ? _r : '';
|
|
319
|
+
(0, utils_1.setOpenInferenceResponseOutputAttr)({ response: content }, span);
|
|
320
|
+
if (outputFormat.type === 'json') {
|
|
321
|
+
return [2 /*return*/, {
|
|
322
|
+
type: 'json',
|
|
323
|
+
content: content || '{}',
|
|
324
|
+
parsedContent: (0, utils_1.tryParseJson)(content || '{}'),
|
|
325
|
+
usage: llmUsage,
|
|
326
|
+
executionUnits: executionUnits,
|
|
327
|
+
}];
|
|
328
|
+
}
|
|
329
|
+
return [2 /*return*/, {
|
|
330
|
+
type: 'text',
|
|
331
|
+
content: content,
|
|
332
|
+
usage: llmUsage,
|
|
333
|
+
executionUnits: executionUnits,
|
|
334
|
+
}];
|
|
335
|
+
case 3:
|
|
336
|
+
e_3 = _s.sent();
|
|
337
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e_3 === null || e_3 === void 0 ? void 0 : e_3.message });
|
|
338
|
+
throw e_3;
|
|
339
|
+
case 4:
|
|
340
|
+
span.end();
|
|
341
|
+
return [7 /*endfinally*/];
|
|
342
|
+
case 5: return [2 /*return*/];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}); },
|
|
346
|
+
})];
|
|
347
|
+
case 1: return [2 /*return*/, _f.sent()];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}); };
|
|
351
|
+
};
|
|
352
|
+
exports.openaiLLMIntegration = openaiLLMIntegration;
|
|
353
|
+
//# sourceMappingURL=openai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|
3
|
+
export { createAgentTool } from './Agent/agentTool';
|
|
3
4
|
export { AgentMediaContentSchema, AgentMessageContentSchema, AgentMessageSchema, AgentTextContentSchema, AgentToolCallContentSchema, AgentToolResultContentSchema, } from './Agent/schema';
|
|
4
5
|
export type { AgentContextBuilder, AgentInternalTool, AgentLLMContext, AgentLLMIntegration, AgentLLMIntegrationOutput, AgentLLMIntegrationParam, AgentMediaContent, AgentMessage, AgentMessageContent, AgentOutputBuilder, AgentServiceContract, AgentTextContent, AgentToolCallContent, AgentToolDefinition, AgentToolResultContent, AnyArvoContract, AnyArvoOrchestratorContract, CreateArvoAgentParam, NonEmptyArray, PromiseLike, } from './Agent/types';
|
|
6
|
+
export { setOpenInferenceInputAttr, setOpenInferenceResponseOutputAttr, setOpenInferenceToolCallOutputAttr, setOpenInferenceUsageOutputAttr, tryParseJson, } from './Agent/utils';
|
|
7
|
+
export { MCPClient } from './Integrations/MCPClient';
|
|
8
|
+
export { openaiLLMIntegration } from './Integrations/openai';
|
|
5
9
|
export type { IMCPClient } from './interfaces.mcp';
|
|
6
10
|
export type { OtelInfoType } from './types';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,EACpB,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,kCAAkC,EAClC,kCAAkC,EAClC,+BAA+B,EAC/B,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgentToolResultContentSchema = exports.AgentToolCallContentSchema = exports.AgentTextContentSchema = exports.AgentMessageSchema = exports.AgentMessageContentSchema = exports.AgentMediaContentSchema = exports.AgentDefaults = exports.createArvoAgent = void 0;
|
|
3
|
+
exports.openaiLLMIntegration = exports.MCPClient = exports.tryParseJson = exports.setOpenInferenceUsageOutputAttr = exports.setOpenInferenceToolCallOutputAttr = exports.setOpenInferenceResponseOutputAttr = exports.setOpenInferenceInputAttr = exports.AgentToolResultContentSchema = exports.AgentToolCallContentSchema = exports.AgentTextContentSchema = exports.AgentMessageSchema = exports.AgentMessageContentSchema = exports.AgentMediaContentSchema = exports.createAgentTool = exports.AgentDefaults = exports.createArvoAgent = void 0;
|
|
4
4
|
var Agent_1 = require("./Agent");
|
|
5
5
|
Object.defineProperty(exports, "createArvoAgent", { enumerable: true, get: function () { return Agent_1.createArvoAgent; } });
|
|
6
6
|
var AgentDefaults_1 = require("./Agent/AgentDefaults");
|
|
7
7
|
Object.defineProperty(exports, "AgentDefaults", { enumerable: true, get: function () { return AgentDefaults_1.AgentDefaults; } });
|
|
8
|
+
var agentTool_1 = require("./Agent/agentTool");
|
|
9
|
+
Object.defineProperty(exports, "createAgentTool", { enumerable: true, get: function () { return agentTool_1.createAgentTool; } });
|
|
8
10
|
var schema_1 = require("./Agent/schema");
|
|
9
11
|
Object.defineProperty(exports, "AgentMediaContentSchema", { enumerable: true, get: function () { return schema_1.AgentMediaContentSchema; } });
|
|
10
12
|
Object.defineProperty(exports, "AgentMessageContentSchema", { enumerable: true, get: function () { return schema_1.AgentMessageContentSchema; } });
|
|
@@ -12,4 +14,14 @@ Object.defineProperty(exports, "AgentMessageSchema", { enumerable: true, get: fu
|
|
|
12
14
|
Object.defineProperty(exports, "AgentTextContentSchema", { enumerable: true, get: function () { return schema_1.AgentTextContentSchema; } });
|
|
13
15
|
Object.defineProperty(exports, "AgentToolCallContentSchema", { enumerable: true, get: function () { return schema_1.AgentToolCallContentSchema; } });
|
|
14
16
|
Object.defineProperty(exports, "AgentToolResultContentSchema", { enumerable: true, get: function () { return schema_1.AgentToolResultContentSchema; } });
|
|
17
|
+
var utils_1 = require("./Agent/utils");
|
|
18
|
+
Object.defineProperty(exports, "setOpenInferenceInputAttr", { enumerable: true, get: function () { return utils_1.setOpenInferenceInputAttr; } });
|
|
19
|
+
Object.defineProperty(exports, "setOpenInferenceResponseOutputAttr", { enumerable: true, get: function () { return utils_1.setOpenInferenceResponseOutputAttr; } });
|
|
20
|
+
Object.defineProperty(exports, "setOpenInferenceToolCallOutputAttr", { enumerable: true, get: function () { return utils_1.setOpenInferenceToolCallOutputAttr; } });
|
|
21
|
+
Object.defineProperty(exports, "setOpenInferenceUsageOutputAttr", { enumerable: true, get: function () { return utils_1.setOpenInferenceUsageOutputAttr; } });
|
|
22
|
+
Object.defineProperty(exports, "tryParseJson", { enumerable: true, get: function () { return utils_1.tryParseJson; } });
|
|
23
|
+
var MCPClient_1 = require("./Integrations/MCPClient");
|
|
24
|
+
Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return MCPClient_1.MCPClient; } });
|
|
25
|
+
var openai_1 = require("./Integrations/openai");
|
|
26
|
+
Object.defineProperty(exports, "openaiLLMIntegration", { enumerable: true, get: function () { return openai_1.openaiLLMIntegration; } });
|
|
15
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,4GAAA,eAAe,OAAA;AACxB,yCAOwB;AANtB,iHAAA,uBAAuB,OAAA;AACvB,mHAAA,yBAAyB,OAAA;AACzB,4GAAA,kBAAkB,OAAA;AAClB,gHAAA,sBAAsB,OAAA;AACtB,oHAAA,0BAA0B,OAAA;AAC1B,sHAAA,4BAA4B,OAAA;AAwB9B,uCAMuB;AALrB,kHAAA,yBAAyB,OAAA;AACzB,2HAAA,kCAAkC,OAAA;AAClC,2HAAA,kCAAkC,OAAA;AAClC,wHAAA,+BAA+B,OAAA;AAC/B,qGAAA,YAAY,OAAA;AAEd,sDAAqD;AAA5C,sGAAA,SAAS,OAAA;AAClB,gDAA6D;AAApD,8GAAA,oBAAoB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arvo-tools/agentic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Agentic toolset for building applications using arvo-core and arvo-event-handler",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@arizeai/openinference-semantic-conventions": "^2.1.2",
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
29
30
|
"@opentelemetry/api": "1.9.0",
|
|
30
31
|
"arvo-core": "^3.0.19",
|
|
31
32
|
"arvo-event-handler": "^3.0.19",
|
|
32
33
|
"openai": "^6.9.1",
|
|
33
|
-
"uuid": "^
|
|
34
|
+
"uuid": "^11.1.0",
|
|
34
35
|
"zod": "^3.25.74",
|
|
35
36
|
"zod-to-json-schema": "^3.24.6"
|
|
36
37
|
},
|