@arvo-tools/agentic 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Agent/AgentDefaults.d.ts +4 -2
- package/dist/Agent/AgentDefaults.d.ts.map +1 -1
- package/dist/Agent/AgentDefaults.js +3 -0
- package/dist/Agent/AgentDefaults.js.map +1 -1
- package/dist/Agent/agentLoop.d.ts +22 -1
- package/dist/Agent/agentLoop.d.ts.map +1 -1
- package/dist/Agent/agentLoop.js +39 -4
- package/dist/Agent/agentLoop.js.map +1 -1
- package/dist/Agent/index.d.ts +76 -3
- package/dist/Agent/index.d.ts.map +1 -1
- package/dist/Agent/index.js +77 -2
- package/dist/Agent/index.js.map +1 -1
- package/dist/Agent/schema.d.ts +9 -0
- package/dist/Agent/schema.d.ts.map +1 -1
- package/dist/Agent/schema.js +7 -0
- package/dist/Agent/schema.js.map +1 -1
- package/dist/Agent/types.d.ts +214 -58
- package/dist/Agent/types.d.ts.map +1 -1
- package/dist/Agent/utils.d.ts +46 -1
- package/dist/Agent/utils.d.ts.map +1 -1
- package/dist/Agent/utils.js +43 -0
- package/dist/Agent/utils.js.map +1 -1
- package/dist/{Agent/agentTool.d.ts → AgentTool/index.d.ts} +3 -3
- package/dist/AgentTool/index.d.ts.map +1 -0
- package/dist/{Agent/agentTool.js → AgentTool/index.js} +1 -1
- package/dist/AgentTool/index.js.map +1 -0
- package/dist/AgentTool/types.d.ts +21 -0
- package/dist/AgentTool/types.d.ts.map +1 -0
- package/dist/AgentTool/types.js +3 -0
- package/dist/AgentTool/types.js.map +1 -0
- package/dist/Integrations/MCPClient.d.ts +62 -29
- package/dist/Integrations/MCPClient.d.ts.map +1 -1
- package/dist/Integrations/MCPClient.js +60 -29
- package/dist/Integrations/MCPClient.js.map +1 -1
- package/dist/Integrations/openai/index.d.ts +25 -0
- package/dist/Integrations/openai/index.d.ts.map +1 -0
- package/dist/Integrations/{openai.js → openai/index.js} +64 -28
- package/dist/Integrations/openai/index.js.map +1 -0
- package/dist/Integrations/prompts.d.ts +8 -0
- package/dist/Integrations/prompts.d.ts.map +1 -0
- package/dist/Integrations/prompts.js +12 -0
- package/dist/Integrations/prompts.js.map +1 -0
- package/dist/Integrations/types.d.ts +101 -0
- package/dist/Integrations/types.d.ts.map +1 -0
- package/dist/Integrations/types.js +3 -0
- package/dist/Integrations/types.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces.mcp.d.ts +29 -0
- package/dist/interfaces.mcp.d.ts.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/Agent/agentTool.d.ts.map +0 -1
- package/dist/Agent/agentTool.js.map +0 -1
- package/dist/Integrations/openai.d.ts +0 -10
- package/dist/Integrations/openai.d.ts.map +0 -1
- package/dist/Integrations/openai.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/AgentTool/index.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,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,eAAe,mBAqD2B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { OtelInfoType, PromiseAble } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Defines a Synchronous Internal Tool.
|
|
5
|
+
*
|
|
6
|
+
* Internal tools are standard JavaScript functions that run within the Agent's process.
|
|
7
|
+
* Unlike Services, the Agent **does not suspend** when calling these. They are awaited immediately.
|
|
8
|
+
*
|
|
9
|
+
* Use cases: Mathematical calculations, Date/Time checks, Regex validation, lightweight logic.
|
|
10
|
+
*/
|
|
11
|
+
export type AgentInternalTool<TInputSchema extends z.ZodTypeAny = any, TOutputSchema extends z.ZodTypeAny = any> = {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
input: TInputSchema;
|
|
15
|
+
output: TOutputSchema;
|
|
16
|
+
priority?: number;
|
|
17
|
+
fn: (input: z.infer<TInputSchema>, config: {
|
|
18
|
+
otelInfo: OtelInfoType;
|
|
19
|
+
}) => PromiseAble<z.infer<TOutputSchema>>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/AgentTool/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,CAE3B,YAAY,SAAS,CAAC,CAAC,UAAU,GAAG,GAAG,EAEvC,aAAa,SAAS,CAAC,CAAC,UAAU,GAAG,GAAG,IACtC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,CACF,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAC5B,MAAM,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,KAC/B,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/AgentTool/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import type { IMCPClient } from '../interfaces.mcp.js';
|
|
2
2
|
import type { OtelInfoType } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* A Production-grade Client for the Model Context Protocol (MCP).
|
|
5
5
|
*
|
|
6
|
-
* This
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* This class bridges Arvo Agents with the external MCP ecosystem, allowing agents to
|
|
7
|
+
* interact with filesystem, databases, GitHub, Slack, and other standardized MCP servers.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Key Features:**
|
|
11
|
+
* - **Auto-Transport Selection:** Automatically chooses between `SSEClientTransport` and
|
|
12
|
+
* `StreamableHTTPClientTransport` based on the URL pattern (checks for `/mcp` suffix).
|
|
13
|
+
* - **Orchestration Control:** Supports mapping priorities to external tools, allowing
|
|
14
|
+
* MCP tools to participate in Arvo's **Priority Batch Execution** logic.
|
|
15
|
+
* - **Observability:** Deep integration with Arvo's OpenTelemetry system to trace
|
|
16
|
+
* connection status and tool execution metrics.
|
|
17
|
+
* - **Tool Caching:** Discovers and caches tool definitions upon connection to minimize latency
|
|
18
|
+
* during the Agent's reasoning loop.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const mcp = new MCPClient({
|
|
23
|
+
* url: 'http://localhost:8080/sse',
|
|
24
|
+
* // Give the 'delete_file' tool high priority so it executes before other tools
|
|
25
|
+
* toolPriority: {
|
|
26
|
+
* 'delete_file': 100
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
10
30
|
*/
|
|
11
31
|
export declare class MCPClient implements IMCPClient {
|
|
12
32
|
private client;
|
|
@@ -14,35 +34,45 @@ export declare class MCPClient implements IMCPClient {
|
|
|
14
34
|
private availableTools;
|
|
15
35
|
private readonly url;
|
|
16
36
|
private readonly requestInit;
|
|
37
|
+
private readonly toolPriority;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new MCP Client.
|
|
40
|
+
*
|
|
41
|
+
* @param param - Configuration object or a Lazy Configuration function.
|
|
42
|
+
*
|
|
43
|
+
* **Why use a function?**
|
|
44
|
+
* Using a function is recommended if the URL, Auth Headers, or Tool Priorities
|
|
45
|
+
* need to be resolved at **Runtime** (e.g., fetched from a Secrets Manager or Env Var)
|
|
46
|
+
* rather than at **Instantiation time**.
|
|
47
|
+
*/
|
|
17
48
|
constructor(param: {
|
|
18
49
|
url: string;
|
|
50
|
+
toolPriority?: Record<string, number>;
|
|
19
51
|
requestInit?: RequestInit;
|
|
20
52
|
} | (() => {
|
|
21
53
|
url: string;
|
|
54
|
+
toolPriority?: Record<string, number>;
|
|
22
55
|
requestInit?: RequestInit;
|
|
23
56
|
}));
|
|
24
57
|
/**
|
|
25
|
-
*
|
|
58
|
+
* Initializes the connection to the remote MCP Server.
|
|
26
59
|
*
|
|
27
|
-
* This method
|
|
28
|
-
* 1.
|
|
29
|
-
* 2.
|
|
30
|
-
* 3.
|
|
31
|
-
* 4. Retrieves and caches the list of available tools
|
|
32
|
-
* 5. Logs all operations to the provided OpenTelemetry span
|
|
60
|
+
* This lifecycle method:
|
|
61
|
+
* 1. Resolves the Transport (SSE vs HTTP).
|
|
62
|
+
* 2. Performs the protocol handshake.
|
|
63
|
+
* 3. Fetches the list of available tools immediately (to populate the Agent's context).
|
|
33
64
|
*
|
|
34
|
-
* @
|
|
35
|
-
* @throws
|
|
65
|
+
* @param config - Trace context.
|
|
66
|
+
* @throws Error if the connection fails or handshake is rejected.
|
|
36
67
|
*/
|
|
37
68
|
connect(config: {
|
|
38
69
|
otelInfo: OtelInfoType;
|
|
39
70
|
}): Promise<void>;
|
|
40
71
|
/**
|
|
41
|
-
*
|
|
72
|
+
* Returns the Tool Definitions discovered during the `connect()` phase.
|
|
42
73
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* This method returns an empty array if not connected.
|
|
74
|
+
* This maps the raw MCP Tool format into Arvo's `AgentToolDefinition` structure
|
|
75
|
+
* so they can be injected into the LLM's context window.
|
|
46
76
|
*/
|
|
47
77
|
getTools(config: {
|
|
48
78
|
otelInfo: OtelInfoType;
|
|
@@ -52,12 +82,13 @@ export declare class MCPClient implements IMCPClient {
|
|
|
52
82
|
inputSchema: Record<string, any>;
|
|
53
83
|
}[]>;
|
|
54
84
|
/**
|
|
55
|
-
*
|
|
85
|
+
* Executes a tool on the remote MCP Server.
|
|
56
86
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
87
|
+
* Wraps the execution in a dedicated OpenTelemetry Child Span (`MCP.invoke<tool_name>`)
|
|
88
|
+
* to track latency and success/failure rates of the external system.
|
|
89
|
+
*
|
|
90
|
+
* @param param - The tool name and argument payload generated by the LLM.
|
|
91
|
+
* @returns The simplified JSON string result to be fed back to the LLM.
|
|
61
92
|
*/
|
|
62
93
|
invokeTool(param: {
|
|
63
94
|
name: string;
|
|
@@ -66,15 +97,17 @@ export declare class MCPClient implements IMCPClient {
|
|
|
66
97
|
otelInfo: OtelInfoType;
|
|
67
98
|
}): Promise<string>;
|
|
68
99
|
/**
|
|
69
|
-
*
|
|
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.
|
|
100
|
+
* Terminates the transport session and resets clients state.
|
|
101
|
+
* Safe to call multiple times (idempotent).
|
|
74
102
|
*/
|
|
75
103
|
disconnect(config: {
|
|
76
104
|
otelInfo: OtelInfoType;
|
|
77
105
|
}): Promise<void>;
|
|
78
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves the priority configuration for MCP Tools.
|
|
108
|
+
*
|
|
109
|
+
* This allows external MCP tools to explicitly participate in Arvo's **Priority Batch Execution**.
|
|
110
|
+
*/
|
|
111
|
+
getToolPriority(): Promise<Record<string, number>>;
|
|
79
112
|
}
|
|
80
113
|
//# sourceMappingURL=MCPClient.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,SAAU,YAAW,UAAU;IAC1C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+B;IAE5D;;;;;;;;;OASG;gBAED,KAAK,EACD;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE,GACjF,CAAC,MAAM;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;IAU/F;;;;;;;;;;OAUG;IACG,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ChE;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,GAAG,OAAO,CACzD;QACE,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QAEpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAClC,EAAE,CACJ;IAsCD;;;;;;;;OAQG;IACG,UAAU,CACd,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;KAAE,EACnE,MAAM,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,GACjC,OAAO,CAAC,MAAM,CAAC;IA6DlB;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBnE;;;;OAIG;IACG,eAAe;CAGtB"}
|
|
@@ -54,33 +54,62 @@ var streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHt
|
|
|
54
54
|
var api_1 = require("@opentelemetry/api");
|
|
55
55
|
var arvo_core_1 = require("arvo-core");
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* A Production-grade Client for the Model Context Protocol (MCP).
|
|
58
58
|
*
|
|
59
|
-
* This
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
59
|
+
* This class bridges Arvo Agents with the external MCP ecosystem, allowing agents to
|
|
60
|
+
* interact with filesystem, databases, GitHub, Slack, and other standardized MCP servers.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* **Key Features:**
|
|
64
|
+
* - **Auto-Transport Selection:** Automatically chooses between `SSEClientTransport` and
|
|
65
|
+
* `StreamableHTTPClientTransport` based on the URL pattern (checks for `/mcp` suffix).
|
|
66
|
+
* - **Orchestration Control:** Supports mapping priorities to external tools, allowing
|
|
67
|
+
* MCP tools to participate in Arvo's **Priority Batch Execution** logic.
|
|
68
|
+
* - **Observability:** Deep integration with Arvo's OpenTelemetry system to trace
|
|
69
|
+
* connection status and tool execution metrics.
|
|
70
|
+
* - **Tool Caching:** Discovers and caches tool definitions upon connection to minimize latency
|
|
71
|
+
* during the Agent's reasoning loop.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const mcp = new MCPClient({
|
|
76
|
+
* url: 'http://localhost:8080/sse',
|
|
77
|
+
* // Give the 'delete_file' tool high priority so it executes before other tools
|
|
78
|
+
* toolPriority: {
|
|
79
|
+
* 'delete_file': 100
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
63
83
|
*/
|
|
64
84
|
var MCPClient = /** @class */ (function () {
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new MCP Client.
|
|
87
|
+
*
|
|
88
|
+
* @param param - Configuration object or a Lazy Configuration function.
|
|
89
|
+
*
|
|
90
|
+
* **Why use a function?**
|
|
91
|
+
* Using a function is recommended if the URL, Auth Headers, or Tool Priorities
|
|
92
|
+
* need to be resolved at **Runtime** (e.g., fetched from a Secrets Manager or Env Var)
|
|
93
|
+
* rather than at **Instantiation time**.
|
|
94
|
+
*/
|
|
65
95
|
function MCPClient(param) {
|
|
66
96
|
this.client = null;
|
|
67
97
|
this.isConnected = false;
|
|
68
98
|
this.availableTools = [];
|
|
69
99
|
this.url = function () { return (typeof param === 'function' ? param() : param).url; };
|
|
70
100
|
this.requestInit = function () { var _a; return (_a = (typeof param === 'function' ? param() : param).requestInit) !== null && _a !== void 0 ? _a : {}; };
|
|
101
|
+
this.toolPriority = function () { var _a; return (_a = (typeof param === 'function' ? param() : param).toolPriority) !== null && _a !== void 0 ? _a : {}; };
|
|
71
102
|
}
|
|
72
103
|
/**
|
|
73
|
-
*
|
|
104
|
+
* Initializes the connection to the remote MCP Server.
|
|
74
105
|
*
|
|
75
|
-
* This method
|
|
76
|
-
* 1.
|
|
77
|
-
* 2.
|
|
78
|
-
* 3.
|
|
79
|
-
* 4. Retrieves and caches the list of available tools
|
|
80
|
-
* 5. Logs all operations to the provided OpenTelemetry span
|
|
106
|
+
* This lifecycle method:
|
|
107
|
+
* 1. Resolves the Transport (SSE vs HTTP).
|
|
108
|
+
* 2. Performs the protocol handshake.
|
|
109
|
+
* 3. Fetches the list of available tools immediately (to populate the Agent's context).
|
|
81
110
|
*
|
|
82
|
-
* @
|
|
83
|
-
* @throws
|
|
111
|
+
* @param config - Trace context.
|
|
112
|
+
* @throws Error if the connection fails or handshake is rejected.
|
|
84
113
|
*/
|
|
85
114
|
MCPClient.prototype.connect = function (config) {
|
|
86
115
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -127,11 +156,10 @@ var MCPClient = /** @class */ (function () {
|
|
|
127
156
|
});
|
|
128
157
|
};
|
|
129
158
|
/**
|
|
130
|
-
*
|
|
159
|
+
* Returns the Tool Definitions discovered during the `connect()` phase.
|
|
131
160
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* This method returns an empty array if not connected.
|
|
161
|
+
* This maps the raw MCP Tool format into Arvo's `AgentToolDefinition` structure
|
|
162
|
+
* so they can be injected into the LLM's context window.
|
|
135
163
|
*/
|
|
136
164
|
MCPClient.prototype.getTools = function (config) {
|
|
137
165
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -173,12 +201,13 @@ var MCPClient = /** @class */ (function () {
|
|
|
173
201
|
});
|
|
174
202
|
};
|
|
175
203
|
/**
|
|
176
|
-
*
|
|
204
|
+
* Executes a tool on the remote MCP Server.
|
|
177
205
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
206
|
+
* Wraps the execution in a dedicated OpenTelemetry Child Span (`MCP.invoke<tool_name>`)
|
|
207
|
+
* to track latency and success/failure rates of the external system.
|
|
208
|
+
*
|
|
209
|
+
* @param param - The tool name and argument payload generated by the LLM.
|
|
210
|
+
* @returns The simplified JSON string result to be fed back to the LLM.
|
|
182
211
|
*/
|
|
183
212
|
MCPClient.prototype.invokeTool = function (param, config) {
|
|
184
213
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -245,11 +274,8 @@ var MCPClient = /** @class */ (function () {
|
|
|
245
274
|
});
|
|
246
275
|
};
|
|
247
276
|
/**
|
|
248
|
-
*
|
|
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.
|
|
277
|
+
* Terminates the transport session and resets clients state.
|
|
278
|
+
* Safe to call multiple times (idempotent).
|
|
253
279
|
*/
|
|
254
280
|
MCPClient.prototype.disconnect = function (config) {
|
|
255
281
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -279,10 +305,15 @@ var MCPClient = /** @class */ (function () {
|
|
|
279
305
|
});
|
|
280
306
|
});
|
|
281
307
|
};
|
|
308
|
+
/**
|
|
309
|
+
* Retrieves the priority configuration for MCP Tools.
|
|
310
|
+
*
|
|
311
|
+
* This allows external MCP tools to explicitly participate in Arvo's **Priority Batch Execution**.
|
|
312
|
+
*/
|
|
282
313
|
MCPClient.prototype.getToolPriority = function () {
|
|
283
314
|
return __awaiter(this, void 0, void 0, function () {
|
|
284
315
|
return __generator(this, function (_a) {
|
|
285
|
-
return [2 /*return*/,
|
|
316
|
+
return [2 /*return*/, this.toolPriority()];
|
|
286
317
|
});
|
|
287
318
|
});
|
|
288
319
|
};
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IAQE;;;;;;;;;OASG;IACH,mBACE,KAE6F;QAE7F,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,CAAC,CAAC,GAAG,EAAnD,CAAmD,CAAC;QACrE,IAAI,CAAC,WAAW,GAAG,sBAAM,OAAA,MAAA,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,mCAAI,EAAE,CAAA,EAAA,CAAC;QAC3F,IAAI,CAAC,YAAY,GAAG,sBAAM,OAAA,MAAA,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK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,EAAE,0BAAuB;yBACzD,EACD,MAAM,CAAC,QAAQ,CAAC,IAAI,CACrB,CAAC;;;;;;KAEL;IAED;;;;OAIG;IACG,mCAAe,GAArB;;;gBACE,sBAAO,IAAI,CAAC,YAAY,EAAE,EAAC;;;KAC5B;IACH,gBAAC;AAAD,CAAC,AAvPD,IAuPC;AAvPY,8BAAS"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type OpenAI from 'openai';
|
|
2
|
+
import type { ChatModel } from 'openai/resources/shared.mjs';
|
|
3
|
+
import type { AgentLLMIntegration, AgentLLMIntegrationParam } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an Arvo-compatible LLM Adapter for OpenAI models (GPT-4, GPT-3.5, etc.).
|
|
6
|
+
*
|
|
7
|
+
* This integration handles the complexity of:
|
|
8
|
+
* 1. **Structured Outputs:** Automatically converts Zod schemas to OpenAI `json_schema` format when required.
|
|
9
|
+
* 2. **Context Optimization:** Automatically strips large media payloads (images/files) from the history during resume/tool-result cycles to save tokens.
|
|
10
|
+
* 3. **Observability:** Instruments every call with OpenInference-compliant OpenTelemetry attributes.
|
|
11
|
+
* 4. **Safety:** Injects a tool limit prompt when the Agent exhausts its tool budget (customizable via `toolLimitPrompt`).
|
|
12
|
+
*
|
|
13
|
+
* @param client - An initialized `OpenAI` SDK client instance.
|
|
14
|
+
* @param config - Configuration for model behavior (Model ID, Temperature, Max Tokens) and cost calculation logic.
|
|
15
|
+
* @param config.toolLimitPrompt - Custom system instruction to inject when `maxToolInteractions` logic is triggered. useful for guiding the model to summarize or fail gracefully.
|
|
16
|
+
* @returns An `AgentLLMIntegration` function ready to be passed to `createArvoAgent`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const openaiLLMIntegration: (client: OpenAI, config?: {
|
|
19
|
+
model?: ChatModel;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
executionunits?: (prompt: number, completion: number) => number;
|
|
23
|
+
toolLimitPrompt?: (toolInteractions: AgentLLMIntegrationParam["toolInteractions"]) => string;
|
|
24
|
+
}) => AgentLLMIntegration;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Integrations/openai/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAY7D,OAAO,KAAK,EACV,mBAAmB,EAEnB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAiGlB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAE7B,QAAQ,MAAM,EACd,SAAS;IACP,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,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;IAChE,eAAe,CAAC,EAAE,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,kBAAkB,CAAC,KAAK,MAAM,CAAC;CAC9F,KACA,mBAiLC,CAAC"}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -52,7 +63,17 @@ var openinference_semantic_conventions_1 = require("@arizeai/openinference-seman
|
|
|
52
63
|
var api_1 = require("@opentelemetry/api");
|
|
53
64
|
var arvo_core_1 = require("arvo-core");
|
|
54
65
|
var zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
55
|
-
var utils_1 = require("
|
|
66
|
+
var utils_1 = require("../../Agent/utils");
|
|
67
|
+
var prompts_1 = require("../prompts");
|
|
68
|
+
/**
|
|
69
|
+
* Internal Adapter: Maps Arvo's generic Agent Message format to OpenAI's specific API format.
|
|
70
|
+
*
|
|
71
|
+
* Handles:
|
|
72
|
+
* - System Prompt injection.
|
|
73
|
+
* - Mapping Tool Results to their originating Tool Call IDs.
|
|
74
|
+
* - Multimodal Content (converting Arvo media objects to OpenAI Image/File URLs).
|
|
75
|
+
* - Reconstructs the specific message ordering OpenAI expects (User -> Assistant(ToolCall) -> Tool(Result)).
|
|
76
|
+
*/
|
|
56
77
|
var formatMessagesForOpenAI = function (messages, systemPrompt) {
|
|
57
78
|
var e_1, _a, e_2, _b;
|
|
58
79
|
var _c;
|
|
@@ -157,6 +178,20 @@ var formatMessagesForOpenAI = function (messages, systemPrompt) {
|
|
|
157
178
|
}
|
|
158
179
|
return formattedMessages;
|
|
159
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Creates an Arvo-compatible LLM Adapter for OpenAI models (GPT-4, GPT-3.5, etc.).
|
|
183
|
+
*
|
|
184
|
+
* This integration handles the complexity of:
|
|
185
|
+
* 1. **Structured Outputs:** Automatically converts Zod schemas to OpenAI `json_schema` format when required.
|
|
186
|
+
* 2. **Context Optimization:** Automatically strips large media payloads (images/files) from the history during resume/tool-result cycles to save tokens.
|
|
187
|
+
* 3. **Observability:** Instruments every call with OpenInference-compliant OpenTelemetry attributes.
|
|
188
|
+
* 4. **Safety:** Injects a tool limit prompt when the Agent exhausts its tool budget (customizable via `toolLimitPrompt`).
|
|
189
|
+
*
|
|
190
|
+
* @param client - An initialized `OpenAI` SDK client instance.
|
|
191
|
+
* @param config - Configuration for model behavior (Model ID, Temperature, Max Tokens) and cost calculation logic.
|
|
192
|
+
* @param config.toolLimitPrompt - Custom system instruction to inject when `maxToolInteractions` logic is triggered. useful for guiding the model to summarize or fail gracefully.
|
|
193
|
+
* @returns An `AgentLLMIntegration` function ready to be passed to `createArvoAgent`.
|
|
194
|
+
*/
|
|
160
195
|
var openaiLLMIntegration = function (client, config) {
|
|
161
196
|
return function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
|
|
162
197
|
var _e;
|
|
@@ -179,9 +214,9 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
179
214
|
fn: function (span) { return __awaiter(void 0, void 0, void 0, function () {
|
|
180
215
|
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
216
|
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 (
|
|
184
|
-
switch (
|
|
217
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
218
|
+
return __generator(this, function (_u) {
|
|
219
|
+
switch (_u.label) {
|
|
185
220
|
case 0:
|
|
186
221
|
llmModel = (_e = config === null || config === void 0 ? void 0 : config.model) !== null && _e !== void 0 ? _e : 'gpt-4o';
|
|
187
222
|
llmInvocationParams = {
|
|
@@ -189,28 +224,28 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
189
224
|
maxTokens: (_g = config === null || config === void 0 ? void 0 : config.maxTokens) !== null && _g !== void 0 ? _g : 4096,
|
|
190
225
|
};
|
|
191
226
|
messages = _messages.map(function (item) {
|
|
192
|
-
if (
|
|
193
|
-
return item;
|
|
194
|
-
if (item.content.type === 'media') {
|
|
227
|
+
if (item.content.type === 'media' && item.seenCount > 0) {
|
|
195
228
|
return {
|
|
196
229
|
role: item.role,
|
|
197
230
|
content: {
|
|
198
231
|
type: 'text',
|
|
199
232
|
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
233
|
},
|
|
234
|
+
seenCount: item.seenCount,
|
|
201
235
|
};
|
|
202
236
|
}
|
|
203
237
|
return item;
|
|
204
238
|
});
|
|
205
239
|
system = _system;
|
|
206
240
|
if (toolInteractions.exhausted) {
|
|
207
|
-
limitMessage = (
|
|
241
|
+
limitMessage = (_j = (_h = config === null || config === void 0 ? void 0 : config.toolLimitPrompt) === null || _h === void 0 ? void 0 : _h.call(config, toolInteractions)) !== null && _j !== void 0 ? _j : prompts_1.DEFAULT_TOOL_LIMIT_PROMPT;
|
|
208
242
|
messages.push({
|
|
209
243
|
role: 'user',
|
|
210
244
|
content: {
|
|
211
245
|
type: 'text',
|
|
212
246
|
content: limitMessage,
|
|
213
247
|
},
|
|
248
|
+
seenCount: 0,
|
|
214
249
|
});
|
|
215
250
|
system = "".concat(system, "\n\n").concat(limitMessage);
|
|
216
251
|
}
|
|
@@ -225,9 +260,9 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
225
260
|
system: system,
|
|
226
261
|
tools: tools,
|
|
227
262
|
}, span);
|
|
228
|
-
|
|
263
|
+
_u.label = 1;
|
|
229
264
|
case 1:
|
|
230
|
-
|
|
265
|
+
_u.trys.push([1, 3, 4, 5]);
|
|
231
266
|
toolDef = [];
|
|
232
267
|
try {
|
|
233
268
|
for (tools_1 = __values(tools), tools_1_1 = tools_1.next(); !tools_1_1.done; tools_1_1 = tools_1.next()) {
|
|
@@ -261,26 +296,21 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
261
296
|
},
|
|
262
297
|
}
|
|
263
298
|
: undefined;
|
|
264
|
-
return [4 /*yield*/, client.chat.completions.create({
|
|
265
|
-
|
|
266
|
-
max_tokens: llmInvocationParams.maxTokens,
|
|
267
|
-
temperature: llmInvocationParams.temperature,
|
|
268
|
-
tools: toolDef.length ? toolDef : undefined,
|
|
269
|
-
messages: formattedMessages,
|
|
270
|
-
response_format: responseFormat,
|
|
271
|
-
})];
|
|
299
|
+
return [4 /*yield*/, client.chat.completions.create(__assign(__assign({ model: llmModel }, (llmModel.includes('gpt-5')
|
|
300
|
+
? { max_completion_tokens: llmInvocationParams.maxTokens }
|
|
301
|
+
: { max_tokens: llmInvocationParams.maxTokens })), { temperature: llmModel.includes('gpt-5') ? 1 : llmInvocationParams.temperature, tools: toolDef.length ? toolDef : undefined, messages: formattedMessages, response_format: responseFormat }))];
|
|
272
302
|
case 2:
|
|
273
|
-
completion =
|
|
303
|
+
completion = _u.sent();
|
|
274
304
|
choice = completion.choices[0];
|
|
275
305
|
llmUsage = {
|
|
276
306
|
tokens: {
|
|
277
|
-
prompt: (
|
|
278
|
-
completion: (
|
|
307
|
+
prompt: (_l = (_k = completion.usage) === null || _k === void 0 ? void 0 : _k.prompt_tokens) !== null && _l !== void 0 ? _l : 0,
|
|
308
|
+
completion: (_o = (_m = completion.usage) === null || _m === void 0 ? void 0 : _m.completion_tokens) !== null && _o !== void 0 ? _o : 0,
|
|
279
309
|
},
|
|
280
310
|
};
|
|
281
|
-
executionUnits = (
|
|
311
|
+
executionUnits = (_q = (_p = config === null || config === void 0 ? void 0 : config.executionunits) === null || _p === void 0 ? void 0 : _p.call(config, llmUsage.tokens.prompt, llmUsage.tokens.completion)) !== null && _q !== void 0 ? _q : llmUsage.tokens.prompt + llmUsage.tokens.completion;
|
|
282
312
|
(0, utils_1.setOpenInferenceUsageOutputAttr)(llmUsage, span);
|
|
283
|
-
if ((
|
|
313
|
+
if ((_r = choice === null || choice === void 0 ? void 0 : choice.message) === null || _r === void 0 ? void 0 : _r.tool_calls) {
|
|
284
314
|
toolRequests = [];
|
|
285
315
|
try {
|
|
286
316
|
for (_a = __values(choice.message
|
|
@@ -293,8 +323,8 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
293
323
|
input: JSON.parse(toolCall.function.arguments),
|
|
294
324
|
});
|
|
295
325
|
}
|
|
296
|
-
catch (
|
|
297
|
-
|
|
326
|
+
catch (err) {
|
|
327
|
+
(0, arvo_core_1.exceptionToSpan)(err, span);
|
|
298
328
|
}
|
|
299
329
|
}
|
|
300
330
|
}
|
|
@@ -315,7 +345,13 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
315
345
|
}];
|
|
316
346
|
}
|
|
317
347
|
}
|
|
318
|
-
content = (
|
|
348
|
+
content = (_t = (_s = choice === null || choice === void 0 ? void 0 : choice.message) === null || _s === void 0 ? void 0 : _s.content) !== null && _t !== void 0 ? _t : '';
|
|
349
|
+
if (choice.finish_reason === 'length') {
|
|
350
|
+
content = "".concat(content, " [Max response token limit ").concat(llmInvocationParams.maxTokens, " reached]");
|
|
351
|
+
}
|
|
352
|
+
if (choice.finish_reason === 'content_filter') {
|
|
353
|
+
content = "".concat(content, " [Request blocked due to OpenAI content filtering policies]");
|
|
354
|
+
}
|
|
319
355
|
(0, utils_1.setOpenInferenceResponseOutputAttr)({ response: content }, span);
|
|
320
356
|
if (outputFormat.type === 'json') {
|
|
321
357
|
return [2 /*return*/, {
|
|
@@ -333,7 +369,7 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
333
369
|
executionUnits: executionUnits,
|
|
334
370
|
}];
|
|
335
371
|
case 3:
|
|
336
|
-
e_3 =
|
|
372
|
+
e_3 = _u.sent();
|
|
337
373
|
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e_3 === null || e_3 === void 0 ? void 0 : e_3.message });
|
|
338
374
|
throw e_3;
|
|
339
375
|
case 4:
|
|
@@ -350,4 +386,4 @@ var openaiLLMIntegration = function (client, config) {
|
|
|
350
386
|
}); };
|
|
351
387
|
};
|
|
352
388
|
exports.openaiLLMIntegration = openaiLLMIntegration;
|
|
353
|
-
//# sourceMappingURL=
|
|
389
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Integrations/openai/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAGqD;AACrD,0CAAoD;AACpD,uCAA+D;AAK/D,yDAAqD;AAErD,2CAM2B;AAC3B,sCAAuD;AAOvD;;;;;;;;GAQG;AACH,IAAM,uBAAuB,GAAG,UAC9B,QAA8C,EAC9C,YAA2B;;;IAE3B,IAAM,iBAAiB,GAAiC,EAAE,CAAC;IAE3D,IAAI,YAAY,EAAE,CAAC;QACjB,iBAAiB,CAAC,IAAI,CAAC;YACrB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC;IACL,CAAC;IAED,IAAM,eAAe,GAA2C,EAAE,CAAC;;QACnE,KAAsB,IAAA,aAAA,SAAA,QAAQ,CAAA,kCAAA,wDAAE,CAAC;YAA5B,IAAM,OAAO,qBAAA;YAChB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;gBACtE,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;YAC/D,CAAC;QACH,CAAC;;;;;;;;;;QAED,KAAsB,IAAA,aAAA,SAAA,QAAQ,CAAA,kCAAA,wDAAE,CAAC;YAA5B,IAAM,OAAO,qBAAA;YAChB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC5B,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACpC,iBAAiB,CAAC,IAAI,CAAC;wBACrB,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;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E,OAAO,IAAI,IAAI;oDACxB,aAAa,EAAE,IAAA,oBAAY,EAAC,OAAO,IAAI,IAAI,CAAC;oDAC5C,KAAK,EAAE,QAAQ;oDACf,cAAc,gBAAA;iDACf,EAAC;wCACJ,CAAC;wCAED,sBAAO;gDACL,IAAI,EAAE,MAAM;gDACZ,OAAO,SAAA;gDACP,KAAK,EAAE,QAAQ;gDACf,cAAc,gBAAA;6CACf,EAAC;;;wCAEF,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,oBAAc,CAAC,KAAK,EAAE,OAAO,EAAG,GAAW,aAAX,GAAC,uBAAD,GAAC,CAAY,OAAO,EAAE,CAAC,CAAC;wCAC/E,MAAM,GAAC,CAAC;;wCAER,IAAI,CAAC,GAAG,EAAE,CAAC;;;;;6BAEd;qBACF,CAAC,EAAA;wBA5KF,sBAAA,SA4KE,EAAA;;;SAAA;AAhLJ,CAgLI,CAAC;AA3LM,QAAA,oBAAoB,wBA2L1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard System Instruction injected when the Agent reaches its `maxToolInteractions` limit.
|
|
3
|
+
*
|
|
4
|
+
* This prompt overrides the Agent's natural tendency to keep calling tools, forcing it to
|
|
5
|
+
* synthesize a final response based on whatever partial data it has managed to collect so far.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_TOOL_LIMIT_PROMPT: string;
|
|
8
|
+
//# sourceMappingURL=prompts.d.ts.map
|