@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
package/dist/Agent/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/Agent/schema.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/Agent/schema.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,6DAA6D;AAChD,QAAA,sBAAsB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,aAAC,CAAC,k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AA0B;CAC3B,CAAC,CAAC;AAEH,iGAAiG;AACpF,QAAA,kBAAkB,GAAG,aAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,EAAE,iCAAyB;IAClC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;CAChG,CAAC,CAAC"}
|
package/dist/Agent/types.d.ts
CHANGED
|
@@ -2,38 +2,135 @@ import type { Span } from '@opentelemetry/api';
|
|
|
2
2
|
import type { ArvoContract, ArvoOrchestratorContract, ArvoSemanticVersion, CreateArvoEvent, InferVersionedArvoContract, VersionedArvoContract } from 'arvo-core';
|
|
3
3
|
import type { IMachineMemory } from 'arvo-event-handler';
|
|
4
4
|
import type z from 'zod';
|
|
5
|
+
import type { AgentInternalTool } from '../AgentTool/types';
|
|
6
|
+
import type { AgentLLMIntegration, AgentLLMIntegrationOutput, AgentLLMIntegrationParam } from '../Integrations/types';
|
|
5
7
|
import type { IMCPClient } from '../interfaces.mcp';
|
|
6
|
-
import type {
|
|
8
|
+
import type { NonEmptyArray, PromiseAble } from '../types';
|
|
7
9
|
import type { AgentMediaContentSchema, AgentMessageContentSchema, AgentMessageSchema, AgentTextContentSchema, AgentToolCallContentSchema, AgentToolResultContentSchema } from './schema';
|
|
10
|
+
/** Represents a pure text block in the conversation history. */
|
|
8
11
|
export type AgentTextContent = z.infer<typeof AgentTextContentSchema>;
|
|
12
|
+
/** Represents media (images/files) passed to the Agent, usually for multimodal models. */
|
|
9
13
|
export type AgentMediaContent = z.infer<typeof AgentMediaContentSchema>;
|
|
14
|
+
/** Represents the output from a tool execution, fed back to the LLM. */
|
|
10
15
|
export type AgentToolResultContent = z.infer<typeof AgentToolResultContentSchema>;
|
|
16
|
+
/** Represents the LLM's request to execute a tool. */
|
|
11
17
|
export type AgentToolCallContent = z.infer<typeof AgentToolCallContentSchema>;
|
|
18
|
+
/** Union of all possible content types within an Agent's conversation message. */
|
|
12
19
|
export type AgentMessageContent = z.infer<typeof AgentMessageContentSchema>;
|
|
20
|
+
/**
|
|
21
|
+
* A single message in the Agent's conversation history (User, Assistant, or Tool role).
|
|
22
|
+
* This is the Arvo-standard format which is adapted to specific LLM provider formats (e.g., OpenAI, Anthropic)
|
|
23
|
+
* by the integration layer.
|
|
24
|
+
*/
|
|
13
25
|
export type AgentMessage = z.infer<typeof AgentMessageSchema>;
|
|
14
26
|
export type AnyArvoOrchestratorContract = ArvoOrchestratorContract<any, any>;
|
|
15
27
|
export type AnyArvoContract = ArvoContract<any, any, any>;
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Defines a Distributed Tool (Arvo Service) available to the Agent.
|
|
30
|
+
*
|
|
31
|
+
* Unlike Internal Tools, these reference remote Event Handlers in your system.
|
|
32
|
+
* When an Agent invokes a Service Contract:
|
|
33
|
+
* 1. The Agent emits an event to the broker.
|
|
34
|
+
* 2. **The Agent Suspends (Sleeps)** and persists state to memory.
|
|
35
|
+
* 3. The remote Service processes the event and replies.
|
|
36
|
+
* 4. The Agent Resumes.
|
|
37
|
+
*/
|
|
18
38
|
export type AgentServiceContract = {
|
|
39
|
+
/** The Versioned Contract of the service the agent can call. */
|
|
19
40
|
contract: VersionedArvoContract<any, any>;
|
|
41
|
+
/**
|
|
42
|
+
* Specific event domains to route the request to.
|
|
43
|
+
* Useful for distinguishing between event deliver channels (e.g. `human.interaction`).
|
|
44
|
+
*/
|
|
20
45
|
domains?: NonEmptyArray<string>;
|
|
46
|
+
/**
|
|
47
|
+
* The execution priority of the tool (Default: 0).
|
|
48
|
+
*
|
|
49
|
+
* Arvo enforces **Priority-Based Batch execution**. If the LLM generates multiple tool calls
|
|
50
|
+
* in a single turn, Arvo will sort them by priority and **only execute the highest priority batch**.
|
|
51
|
+
* All lower priority tool calls in that turn are **dropped**.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* This is critical for enforcing "Human-in-the-loop-first" or "Auth-first" workflows.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* **Scenario:** LLM wants to call `calculate_refund` (Priority 0) and `human_approval` (Priority 100) simultaneously.
|
|
58
|
+
* 1. Arvo sees both calls.
|
|
59
|
+
* 2. `human_approval` has higher priority.
|
|
60
|
+
* 3. Arvo emits `human_approval` event and drops `calculate_refund`.
|
|
61
|
+
* 4. Agent suspends.
|
|
62
|
+
* 5. Human approves -> Agent resumes.
|
|
63
|
+
* 6. LLM sees approval, and *now* re-issues the `calculate_refund` call.
|
|
64
|
+
*/
|
|
21
65
|
priority?: number;
|
|
22
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Internal metadata used by the Agent Orchestrator to control execution strategy and flow.
|
|
69
|
+
*
|
|
70
|
+
* This configuration determines whether the Agent should Execute immediately (Internal/MCP)
|
|
71
|
+
* or Emit & Suspend (Arvo Service), as well as which tools take precedence in a batch.
|
|
72
|
+
*/
|
|
73
|
+
export type AgentToolServerConfig<T> = {
|
|
74
|
+
/**
|
|
75
|
+
* The Execution Strategy:
|
|
76
|
+
* - `'arvo'`: Asynchronous (Event-driven) / Distributed. The Agent emits an event and **suspends**.
|
|
77
|
+
* - `'mcp'`: Async / Synchronous / External. The Agent calls the MCP Client and awaits the result.
|
|
78
|
+
* - `'internal'`: Async / Synchronous / Local. The Agent runs the JS function and awaits the result.
|
|
79
|
+
*/
|
|
80
|
+
kind: 'arvo' | 'mcp' | 'internal';
|
|
81
|
+
/** The internal identifier for the tool resource. */
|
|
82
|
+
name: string;
|
|
83
|
+
/** The original definition source (Contract or Tool object) used to validate inputs. */
|
|
84
|
+
contract: T;
|
|
85
|
+
/**
|
|
86
|
+
* The Priority Level (Higher = More Important).
|
|
87
|
+
*
|
|
88
|
+
* In the Agentic Orchestration loop, if the LLM generates multiple tool calls in a single turn,
|
|
89
|
+
* the Orchestrator sorts them by priority. It executes the highest priority batch and
|
|
90
|
+
* **silently drops/ignores** all lower priority calls.
|
|
91
|
+
*
|
|
92
|
+
* This is the mechanism used to enforce "Verification First" or "Human Approval First" patterns.
|
|
93
|
+
*/
|
|
94
|
+
priority: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The unified definition of a Tool as presented to the LLM Context.
|
|
98
|
+
*
|
|
99
|
+
* This type abstracts away the difference between:
|
|
100
|
+
* - **Arvo Services** (Async/Distributed)
|
|
101
|
+
* - **Internal Tools** (Sync/Local)
|
|
102
|
+
* - **MCP Tools** (External/Standardized)
|
|
103
|
+
*
|
|
104
|
+
* The Agent logic uses `serverConfig.kind` to determine execution strategy.
|
|
105
|
+
*/
|
|
23
106
|
export type AgentToolDefinition<T extends VersionedArvoContract<AnyArvoContract, ArvoSemanticVersion> | AgentInternalTool | null = null> = {
|
|
107
|
+
/** The function name the LLM sees (e.g., `service_calculator_add` or `internal_check_time`). */
|
|
24
108
|
name: string;
|
|
109
|
+
/** The description instructing the LLM on when/how to use this tool. */
|
|
25
110
|
description: string;
|
|
111
|
+
/** JSON Schema defining the tool's arguments. */
|
|
26
112
|
inputSchema: Record<string, any>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
name: string;
|
|
30
|
-
contract: T;
|
|
31
|
-
priority: number;
|
|
32
|
-
};
|
|
113
|
+
/** Internal configuration for execution strategy. */
|
|
114
|
+
serverConfig: AgentToolServerConfig<T>;
|
|
33
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* The runtime context provided to the Developer during the Agent's Context Building phase.
|
|
118
|
+
*
|
|
119
|
+
* This object gives you access to the current state of the conversation and the
|
|
120
|
+
* complete list of tools available to the Agent. This allows for dynamic System Prompting
|
|
121
|
+
* (e.g., "You have access to tool X and Y, please use X for..." where X and Y are dynamically retrieved).
|
|
122
|
+
*/
|
|
34
123
|
export type AgentLLMContext<TServiceContract extends Record<string, AgentServiceContract> = Record<string, AgentServiceContract>, TTools extends Record<string, AgentInternalTool> = Record<string, AgentInternalTool>> = {
|
|
124
|
+
/** The current System Prompt (can be null if not yet set). */
|
|
35
125
|
system: string | null;
|
|
36
|
-
|
|
126
|
+
/** The full conversation history up to this point. */
|
|
127
|
+
messages: (Omit<AgentMessage, 'seenCount'> & {
|
|
128
|
+
seenCount?: number;
|
|
129
|
+
})[];
|
|
130
|
+
/**
|
|
131
|
+
* Catalog of all tools available to the Agent, categorized by type.
|
|
132
|
+
* Useful for meta-prompting (telling the Agent about its own capabilities).
|
|
133
|
+
*/
|
|
37
134
|
tools: {
|
|
38
135
|
services: {
|
|
39
136
|
[K in keyof TServiceContract]: AgentToolDefinition<TServiceContract[K]['contract']>;
|
|
@@ -43,70 +140,66 @@ export type AgentLLMContext<TServiceContract extends Record<string, AgentService
|
|
|
43
140
|
[K in keyof TTools]: AgentToolDefinition<TTools[K]>;
|
|
44
141
|
};
|
|
45
142
|
};
|
|
143
|
+
/** Tracking for the recursion limit loop. */
|
|
46
144
|
toolInteractions: {
|
|
47
145
|
max: number;
|
|
48
146
|
current: number;
|
|
49
147
|
};
|
|
50
148
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
content: string;
|
|
83
|
-
parsedContent: Record<string, unknown> | null;
|
|
84
|
-
});
|
|
85
|
-
export type AgentInternalTool<TInputSchema extends z.ZodTypeAny = any, TOutputSchema extends z.ZodTypeAny = any> = {
|
|
86
|
-
name: string;
|
|
87
|
-
description: string;
|
|
88
|
-
input: TInputSchema;
|
|
89
|
-
output: TOutputSchema;
|
|
90
|
-
priority?: number;
|
|
91
|
-
fn: (input: z.infer<TInputSchema>, config: {
|
|
92
|
-
otelInfo: OtelInfoType;
|
|
93
|
-
}) => PromiseLike<z.infer<TOutputSchema>>;
|
|
94
|
-
};
|
|
95
|
-
export type AgentLLMIntegration = (param: AgentLLMIntegrationParam, config: {
|
|
96
|
-
otelInfo: OtelInfoType;
|
|
97
|
-
}) => Promise<AgentLLMIntegrationOutput>;
|
|
149
|
+
/**
|
|
150
|
+
* The "Context Engineering" Hook.
|
|
151
|
+
*
|
|
152
|
+
* This function executes **once** when a new Agent workflow is initialized.
|
|
153
|
+
* Its primary responsibility is to the context engineering for the agent.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* **Function Lifecycle:**
|
|
157
|
+
* 1. **Ingest:** Arvo receives an event matching your Contract's `init` schema.
|
|
158
|
+
* 2. **Transform:** This function transforms that typed data (e.g. `{ userId: "123", query: "help" }`)
|
|
159
|
+
* into the Agent's foundational state (System Prompt + Initial Message Thread).
|
|
160
|
+
* 3. **Persist:** The result is stored in `memory`. Future steps in this workflow (e.g. returning from tools)
|
|
161
|
+
* will simply append to this history, they will not run this builder again.
|
|
162
|
+
*
|
|
163
|
+
* @param param - Context parameters.
|
|
164
|
+
*
|
|
165
|
+
* @returns The initial state object containing the `system` string and `messages` array.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* context: async ({ input, tools }) => ({
|
|
170
|
+
* // Dynamic System Prompt based on available tools
|
|
171
|
+
* system: `You are a helpful assistant. You have access to: ${Object.keys(tools.services).join(', ')}`,
|
|
172
|
+
*
|
|
173
|
+
* // Map the Event Data into the first User Message
|
|
174
|
+
* messages: [
|
|
175
|
+
* { role: 'user', content: { type: 'text', content: input.data.userQuery } }
|
|
176
|
+
* ]
|
|
177
|
+
* })
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
98
180
|
export type AgentContextBuilder<T extends AnyArvoOrchestratorContract = AnyArvoOrchestratorContract, V extends ArvoSemanticVersion = ArvoSemanticVersion, TServiceContract extends Record<string, AgentServiceContract> = Record<string, AgentServiceContract>, TTools extends Record<string, AgentInternalTool> = Record<string, AgentInternalTool>> = (param: {
|
|
99
181
|
lifecycle: AgentLLMIntegrationParam['lifecycle'];
|
|
182
|
+
/** The fully typed input event data for this specific contract version. */
|
|
100
183
|
input: InferVersionedArvoContract<VersionedArvoContract<T, V>>['accepts'];
|
|
184
|
+
/** Catalog of available tools for dynamic prompt injection. */
|
|
101
185
|
tools: AgentLLMContext<TServiceContract, TTools>['tools'];
|
|
186
|
+
/** The Otel span to add logs to */
|
|
102
187
|
span: Span;
|
|
103
188
|
}) => PromiseLike<Partial<Pick<AgentLLMContext<TServiceContract>, 'messages' | 'system'>> | void>;
|
|
189
|
+
/**
|
|
190
|
+
* The "Output Validation" Hook.
|
|
191
|
+
*
|
|
192
|
+
* This function when the agent resolves the user request and generates the final response (Text or JSON).
|
|
193
|
+
* It is responsible for mapping the Agent's raw output into the strict Output Schema
|
|
194
|
+
* defined by the Agent's Contract.
|
|
195
|
+
*/
|
|
104
196
|
export type AgentOutputBuilder<T extends AnyArvoOrchestratorContract = AnyArvoOrchestratorContract, V extends ArvoSemanticVersion = ArvoSemanticVersion> = (param: Extract<AgentLLMIntegrationOutput, {
|
|
105
197
|
type: 'text' | 'json';
|
|
106
198
|
}> & {
|
|
107
199
|
outputFormat: z.ZodTypeAny;
|
|
108
200
|
span: Span;
|
|
109
|
-
}) =>
|
|
201
|
+
}) => PromiseAble<{
|
|
202
|
+
/** The data matching the Contract's 'emits' schema. */
|
|
110
203
|
data: InferVersionedArvoContract<VersionedArvoContract<T, V>>['emits'][T['metadata']['completeEventType']]['data'] & {
|
|
111
204
|
__id?: CreateArvoEvent<Record<string, unknown>, string>['id'];
|
|
112
205
|
__executionunits?: CreateArvoEvent<Record<string, unknown>, string>['executionunits'];
|
|
@@ -114,20 +207,83 @@ export type AgentOutputBuilder<T extends AnyArvoOrchestratorContract = AnyArvoOr
|
|
|
114
207
|
} | {
|
|
115
208
|
error: Error;
|
|
116
209
|
}>;
|
|
210
|
+
/**
|
|
211
|
+
* Configuration object for instantiating a new Arvo Agent.
|
|
212
|
+
*
|
|
213
|
+
* This configuration is strictly typed against your Contract Versions. You cannot instantiate
|
|
214
|
+
* an Agent that does not fully implement all versions defined in its interface.
|
|
215
|
+
*/
|
|
117
216
|
export type CreateArvoAgentParam<TSelfContract extends AnyArvoOrchestratorContract = AnyArvoOrchestratorContract, TServiceContract extends Record<string, AgentServiceContract> = Record<string, AgentServiceContract>, TTools extends Record<string, AgentInternalTool> = Record<string, AgentInternalTool>> = {
|
|
217
|
+
/**
|
|
218
|
+
* The Agent's interface in the Arvo Event Fabric.
|
|
219
|
+
*/
|
|
118
220
|
contracts: {
|
|
221
|
+
/**
|
|
222
|
+
* The Orchestrator Contract that defines:
|
|
223
|
+
* - The events this Agent accepts (`init`).
|
|
224
|
+
* - The events this Agent emits (`complete`).
|
|
225
|
+
* - The specific semantic versions supported (e.g., `'1.0.0'`, `'2.0.0'`).
|
|
226
|
+
*/
|
|
119
227
|
self: TSelfContract;
|
|
228
|
+
/**
|
|
229
|
+
* A map of external Arvo Services this Agent is permitted to call.
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* Unlike local `tools`, calling a service here causes the Agent to **emit an event and suspend**.
|
|
233
|
+
* It allows the Agent to orchestrate long-running or distributed workflows.
|
|
234
|
+
*/
|
|
120
235
|
services: TServiceContract;
|
|
121
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Because Agents function as "Resumables" (they sleep while waiting for async tools),
|
|
239
|
+
* they require a backend to persist the conversation history and interaction state.
|
|
240
|
+
* - Dev: `SimpleMachineMemory` (In-Memory).
|
|
241
|
+
* - Prod: Redis, PostgreSQL, DynamoDB implementation.
|
|
242
|
+
*/
|
|
122
243
|
memory: IMachineMemory<Record<string, unknown>>;
|
|
244
|
+
/**
|
|
245
|
+
* The maximum number of tool-execution loops allowed for a single user request.
|
|
246
|
+
* Prevents the Agent from getting stuck in infinite reasoning loops or burning excessive tokens.
|
|
247
|
+
*
|
|
248
|
+
* @defaultValue 5
|
|
249
|
+
*/
|
|
123
250
|
maxToolInteractions?: number;
|
|
251
|
+
/**
|
|
252
|
+
* An optional Model Context Protocol (MCP) client.
|
|
253
|
+
* Gives the agent standardized access to external data sources (Filesystems, GitHub, Databases)
|
|
254
|
+
* without writing custom tool wrappers.
|
|
255
|
+
*/
|
|
124
256
|
mcp?: IMCPClient;
|
|
257
|
+
/**
|
|
258
|
+
* A map of JavaScript functions executed synchronously within the Agent's process.
|
|
259
|
+
* Best for lightweight logic (math, date checks, regex).
|
|
260
|
+
*/
|
|
125
261
|
tools?: TTools;
|
|
262
|
+
/**
|
|
263
|
+
* Forces the Agent to generate a specific output structure.
|
|
264
|
+
* - `'text'`: Standard conversational response.
|
|
265
|
+
* - `'json'`: Structured Output / JSON Mode (validated against the contract's output schema).
|
|
266
|
+
* @defaultValue 'text'
|
|
267
|
+
*/
|
|
126
268
|
llmResponseType?: AgentLLMIntegrationParam['outputFormat']['type'];
|
|
269
|
+
/**
|
|
270
|
+
* The integration function that connects this generic loop to a specific provider
|
|
271
|
+
* (e.g., `openaiLLMIntegration`, `anthropicLLMIntegration`).
|
|
272
|
+
*/
|
|
127
273
|
llm: AgentLLMIntegration;
|
|
274
|
+
/**
|
|
275
|
+
* Arvo enforces strict version compliance. You must provide specific logic
|
|
276
|
+
* (System Prompt Building & Output Mapping) for **every semantic version**
|
|
277
|
+
* defined in `contracts.self`.
|
|
278
|
+
*
|
|
279
|
+
* This allows you to upgrade prompts or change output schemas in `v2` without
|
|
280
|
+
* breaking consumers of `v1`.
|
|
281
|
+
*/
|
|
128
282
|
handler: {
|
|
129
283
|
[K in keyof TSelfContract['versions'] & ArvoSemanticVersion]: {
|
|
284
|
+
/** Generates the System Prompt and initial conversation context for this version. */
|
|
130
285
|
context: AgentContextBuilder<TSelfContract, K, TServiceContract, TTools>;
|
|
286
|
+
/** Maps the LLM's final response to the strict output contract for this version. */
|
|
131
287
|
output: AgentOutputBuilder<TSelfContract, K>;
|
|
132
288
|
};
|
|
133
289
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Agent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Agent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,C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AAE,OAAO,CAAC,CAAC,CAAC;IAEhD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,GAAG,CAAC,EAAE,UAAU,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnE;;;OAGG;IACH,GAAG,EAAE,mBAAmB,CAAC;IAEzB;;;;;;;OAOG;IACH,OAAO,EAAE;SACN,CAAC,IAAI,MAAM,aAAa,CAAC,UAAU,CAAC,GAAG,mBAAmB,GAAG;YAC5D,qFAAqF;YACrF,OAAO,EAAE,mBAAmB,CAAC,aAAa,EAAE,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;YACzE,oFAAoF;YACpF,MAAM,EAAE,kBAAkB,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;SAC9C;KACF,CAAC;CACH,CAAC"}
|
package/dist/Agent/utils.d.ts
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import type { Span } from '@opentelemetry/api';
|
|
2
|
+
import type { AgentInternalTool } from '../AgentTool/types';
|
|
3
|
+
import type { AgentLLMIntegrationOutput } from '../Integrations/types';
|
|
2
4
|
import type { IMCPClient } from '../interfaces.mcp';
|
|
3
5
|
import type { OtelInfoType } from '../types';
|
|
4
|
-
import type {
|
|
6
|
+
import type { AgentMessage, AgentServiceContract, AgentToolCallContent, AgentToolDefinition } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Transforms a map of Arvo Service Contracts into LLM-compatible Tool Definitions.
|
|
9
|
+
*
|
|
10
|
+
* This function extracts the `accepts` schema from the contract, strips out internal
|
|
11
|
+
* Arvo fields (like `parentSubject$$`), and formats it for the LLM's context window.
|
|
12
|
+
*/
|
|
5
13
|
export declare const generateServiceToolDefinitions: <TServiceContract extends Record<string, AgentServiceContract>>(services: TServiceContract) => { [K in keyof TServiceContract]: AgentToolDefinition<TServiceContract[K]["contract"]>; };
|
|
14
|
+
/**
|
|
15
|
+
* Fetches available tools from a connected MCP Client and adapts them to the Agent's internal format.
|
|
16
|
+
*
|
|
17
|
+
* This runs at runtime during the Agent execution loop to ensure the tool list is current.
|
|
18
|
+
*/
|
|
6
19
|
export declare const generateMcpToolDefinitions: (mcp: IMCPClient | null, config: {
|
|
7
20
|
otelInfo: OtelInfoType;
|
|
8
21
|
}) => Promise<Record<string, AgentToolDefinition<null>>>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts local `AgentInternalTool` definitions (Zod schemas) into JSON Schema for the LLM.
|
|
24
|
+
* Uses `zod-to-json-schema` for the conversion.
|
|
25
|
+
*/
|
|
9
26
|
export declare const generateAgentInternalToolDefinitions: <TTools extends Record<string, AgentInternalTool>>(tools: Record<string, AgentInternalTool>) => { [K in keyof TTools]: AgentToolDefinition<TTools[K]>; };
|
|
27
|
+
/** Helper utility to truncate long strings (e.g. Base64 images) in logs/traces. */
|
|
10
28
|
export declare const clampStr: (s: string, len: number) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Populates the OpenTelemetry Span with all LLM Input data using OpenInference Semantic Conventions.
|
|
31
|
+
*
|
|
32
|
+
* This records:
|
|
33
|
+
* 1. The LLM Config (Provider, Model, System Prompt).
|
|
34
|
+
* 2. The full Conversation History (mapped from Arvo format to OpenInference format).
|
|
35
|
+
* 3. Tool Definitions (so traces show what tools were available).
|
|
36
|
+
* 4. Multi-modal content (Image/File placeholders).
|
|
37
|
+
*/
|
|
11
38
|
export declare const setOpenInferenceInputAttr: (param: {
|
|
12
39
|
llm: {
|
|
13
40
|
provider: string;
|
|
@@ -19,13 +46,31 @@ export declare const setOpenInferenceInputAttr: (param: {
|
|
|
19
46
|
system: string | null;
|
|
20
47
|
tools: AgentToolDefinition[];
|
|
21
48
|
}, span: Span) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Records the LLM's generated Tool Calls to the OpenTelemetry Span.
|
|
51
|
+
* Adds attributes for Function Name and JSON Arguments.
|
|
52
|
+
*/
|
|
22
53
|
export declare const setOpenInferenceToolCallOutputAttr: (param: {
|
|
23
54
|
toolCalls: Omit<AgentToolCallContent, "type">[];
|
|
24
55
|
}, span: Span) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Records Token Usage metrics (Prompt, Completion, Total) to the OpenTelemetry Span.
|
|
58
|
+
*/
|
|
25
59
|
export declare const setOpenInferenceUsageOutputAttr: (param: AgentLLMIntegrationOutput["usage"], span: Span) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Records the LLM's final textual response to the OpenTelemetry Span.
|
|
62
|
+
*/
|
|
26
63
|
export declare const setOpenInferenceResponseOutputAttr: (param: {
|
|
27
64
|
response: string;
|
|
28
65
|
}, span: Span) => void;
|
|
66
|
+
/** Safe wrapper around JSON.parse that returns null instead of throwing. */
|
|
29
67
|
export declare const tryParseJson: (str: string) => Record<string, unknown> | null;
|
|
68
|
+
/**
|
|
69
|
+
* Implements the Priority-Based Execution logic.
|
|
70
|
+
*
|
|
71
|
+
* Takes a list of requested tool calls, groups them by their configured priority,
|
|
72
|
+
* and returns **only** the batch with the highest priority. All lower priority
|
|
73
|
+
* calls are discarded.
|
|
74
|
+
*/
|
|
30
75
|
export declare const prioritizeToolCalls: (toolCalls: Omit<AgentToolCallContent, "type">[], nameToToolMap: Record<string, AgentToolDefinition>) => Omit<AgentToolCallContent, "type">[];
|
|
31
76
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/Agent/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EACV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,MAAM,yBAAyB,GACpC,OAAO;IACL,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C,CAAC;IACF,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B,EACD,MAAM,IAAI,SAgFX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kCAAkC,GAC7C,OAAO;IACL,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,EAAE,CAAC;CACjD,EACD,MAAM,IAAI,SAyBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAC1C,OAAO,yBAAyB,CAAC,OAAO,CAAC,EACzC,MAAM,IAAI,SAUX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,GAC7C,OAAO;IACL,QAAQ,EAAE,MAAM,CAAC;CAClB,EACD,MAAM,IAAI,SAUX,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAMpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,EAAE,EAC/C,eAAe,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,KACjD,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,EAWpC,CAAC"}
|
package/dist/Agent/utils.js
CHANGED
|
@@ -88,6 +88,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
88
88
|
exports.prioritizeToolCalls = exports.tryParseJson = exports.setOpenInferenceResponseOutputAttr = exports.setOpenInferenceUsageOutputAttr = exports.setOpenInferenceToolCallOutputAttr = exports.setOpenInferenceInputAttr = exports.clampStr = exports.generateAgentInternalToolDefinitions = exports.generateMcpToolDefinitions = exports.generateServiceToolDefinitions = void 0;
|
|
89
89
|
var openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
90
90
|
var zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
91
|
+
/**
|
|
92
|
+
* Transforms a map of Arvo Service Contracts into LLM-compatible Tool Definitions.
|
|
93
|
+
*
|
|
94
|
+
* This function extracts the `accepts` schema from the contract, strips out internal
|
|
95
|
+
* Arvo fields (like `parentSubject$$`), and formats it for the LLM's context window.
|
|
96
|
+
*/
|
|
91
97
|
var generateServiceToolDefinitions = function (services) {
|
|
92
98
|
var e_1, _a;
|
|
93
99
|
var _b, _c, _d;
|
|
@@ -124,6 +130,11 @@ var generateServiceToolDefinitions = function (services) {
|
|
|
124
130
|
return serviceTools;
|
|
125
131
|
};
|
|
126
132
|
exports.generateServiceToolDefinitions = generateServiceToolDefinitions;
|
|
133
|
+
/**
|
|
134
|
+
* Fetches available tools from a connected MCP Client and adapts them to the Agent's internal format.
|
|
135
|
+
*
|
|
136
|
+
* This runs at runtime during the Agent execution loop to ensure the tool list is current.
|
|
137
|
+
*/
|
|
127
138
|
var generateMcpToolDefinitions = function (mcp, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
128
139
|
var mcpToolList, mcpToolPriorityMap;
|
|
129
140
|
var _a, _b;
|
|
@@ -156,6 +167,10 @@ var generateMcpToolDefinitions = function (mcp, config) { return __awaiter(void
|
|
|
156
167
|
});
|
|
157
168
|
}); };
|
|
158
169
|
exports.generateMcpToolDefinitions = generateMcpToolDefinitions;
|
|
170
|
+
/**
|
|
171
|
+
* Converts local `AgentInternalTool` definitions (Zod schemas) into JSON Schema for the LLM.
|
|
172
|
+
* Uses `zod-to-json-schema` for the conversion.
|
|
173
|
+
*/
|
|
159
174
|
var generateAgentInternalToolDefinitions = function (tools) {
|
|
160
175
|
var e_2, _a;
|
|
161
176
|
var _b;
|
|
@@ -186,10 +201,20 @@ var generateAgentInternalToolDefinitions = function (tools) {
|
|
|
186
201
|
return toolDef;
|
|
187
202
|
};
|
|
188
203
|
exports.generateAgentInternalToolDefinitions = generateAgentInternalToolDefinitions;
|
|
204
|
+
/** Helper utility to truncate long strings (e.g. Base64 images) in logs/traces. */
|
|
189
205
|
var clampStr = function (s, len) {
|
|
190
206
|
return s.length > len ? "".concat(s.slice(0, len), "...") : s;
|
|
191
207
|
};
|
|
192
208
|
exports.clampStr = clampStr;
|
|
209
|
+
/**
|
|
210
|
+
* Populates the OpenTelemetry Span with all LLM Input data using OpenInference Semantic Conventions.
|
|
211
|
+
*
|
|
212
|
+
* This records:
|
|
213
|
+
* 1. The LLM Config (Provider, Model, System Prompt).
|
|
214
|
+
* 2. The full Conversation History (mapped from Arvo format to OpenInference format).
|
|
215
|
+
* 3. Tool Definitions (so traces show what tools were available).
|
|
216
|
+
* 4. Multi-modal content (Image/File placeholders).
|
|
217
|
+
*/
|
|
193
218
|
var setOpenInferenceInputAttr = function (param, span) {
|
|
194
219
|
var _a, e_3, _b, _c, e_4, _d, _e, _f, _g, _h;
|
|
195
220
|
span.setAttributes((_a = {},
|
|
@@ -264,6 +289,10 @@ var setOpenInferenceInputAttr = function (param, span) {
|
|
|
264
289
|
}
|
|
265
290
|
};
|
|
266
291
|
exports.setOpenInferenceInputAttr = setOpenInferenceInputAttr;
|
|
292
|
+
/**
|
|
293
|
+
* Records the LLM's generated Tool Calls to the OpenTelemetry Span.
|
|
294
|
+
* Adds attributes for Function Name and JSON Arguments.
|
|
295
|
+
*/
|
|
267
296
|
var setOpenInferenceToolCallOutputAttr = function (param, span) {
|
|
268
297
|
var _a;
|
|
269
298
|
var _b;
|
|
@@ -287,6 +316,9 @@ var setOpenInferenceToolCallOutputAttr = function (param, span) {
|
|
|
287
316
|
}
|
|
288
317
|
};
|
|
289
318
|
exports.setOpenInferenceToolCallOutputAttr = setOpenInferenceToolCallOutputAttr;
|
|
319
|
+
/**
|
|
320
|
+
* Records Token Usage metrics (Prompt, Completion, Total) to the OpenTelemetry Span.
|
|
321
|
+
*/
|
|
290
322
|
var setOpenInferenceUsageOutputAttr = function (param, span) {
|
|
291
323
|
var _a;
|
|
292
324
|
if (param) {
|
|
@@ -298,6 +330,9 @@ var setOpenInferenceUsageOutputAttr = function (param, span) {
|
|
|
298
330
|
}
|
|
299
331
|
};
|
|
300
332
|
exports.setOpenInferenceUsageOutputAttr = setOpenInferenceUsageOutputAttr;
|
|
333
|
+
/**
|
|
334
|
+
* Records the LLM's final textual response to the OpenTelemetry Span.
|
|
335
|
+
*/
|
|
301
336
|
var setOpenInferenceResponseOutputAttr = function (param, span) {
|
|
302
337
|
var _a, _b;
|
|
303
338
|
span.setAttributes((_a = {},
|
|
@@ -308,6 +343,7 @@ var setOpenInferenceResponseOutputAttr = function (param, span) {
|
|
|
308
343
|
_b));
|
|
309
344
|
};
|
|
310
345
|
exports.setOpenInferenceResponseOutputAttr = setOpenInferenceResponseOutputAttr;
|
|
346
|
+
/** Safe wrapper around JSON.parse that returns null instead of throwing. */
|
|
311
347
|
var tryParseJson = function (str) {
|
|
312
348
|
try {
|
|
313
349
|
return JSON.parse(str);
|
|
@@ -317,6 +353,13 @@ var tryParseJson = function (str) {
|
|
|
317
353
|
}
|
|
318
354
|
};
|
|
319
355
|
exports.tryParseJson = tryParseJson;
|
|
356
|
+
/**
|
|
357
|
+
* Implements the Priority-Based Execution logic.
|
|
358
|
+
*
|
|
359
|
+
* Takes a list of requested tool calls, groups them by their configured priority,
|
|
360
|
+
* and returns **only** the batch with the highest priority. All lower priority
|
|
361
|
+
* calls are discarded.
|
|
362
|
+
*/
|
|
320
363
|
var prioritizeToolCalls = function (toolCalls, nameToToolMap) {
|
|
321
364
|
var e_5, _a;
|
|
322
365
|
var _b, _c, _d, _e, _f;
|
package/dist/Agent/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Agent/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAAsH;AAGtH,yDAAqD;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Agent/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAAsH;AAGtH,yDAAqD;AAarD;;;;;GAKG;AACI,IAAM,8BAA8B,GAAG,UAG5C,QAA0B;;;IAE1B,IAAM,YAAY,GAGd,EAAE,CAAC;;QACP,KAA2B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAA3C,IAAA,KAAA,mBAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;YACpB,IAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;YACjE,iHAAiH;YACjH,IAAM,KACJ,WAAW,IAAI,YAAY,IAAI,WAAW,IAAI,WAAW,CAAC,UAAU;gBAClE,CAAC,CAAC,WAAW,CAAC,UAAU;gBACxB,CAAC,CAAC,EAAE,EAHA,eAAe,qBAAA,EAAK,iBAAiB,cAAvC,mBAAyC,CAGvC,CAAC;YACT,IAAM,eAAe,GAAG,CACtB,WAAW,IAAI,UAAU,IAAI,WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAC7F,CAAC,MAAM,CAAC,UAAC,IAAY,IAAK,OAAA,IAAI,KAAK,iBAAiB,EAA1B,CAA0B,CAAC,CAAC;YACvD,YAAY,CAA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GAAG,UACjC,SAA+C,EAC/C,aAAkD;;;IAElD,IAAM,OAAO,GAAG,IAAI,GAAG,EAAgD,CAAC;;QACxE,KAAsB,IAAA,cAAA,SAAA,SAAS,CAAA,oCAAA,2DAAE,CAAC;YAA7B,IAAM,OAAO,sBAAA;YAChB,IAAM,QAAQ,GAAG,MAAA,MAAA,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,0CAAE,YAAY,CAAC,QAAQ,mCAAI,CAAC,CAAC;YACzE,IAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;;;;;;;;;IACD,IAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC,CAAC;IACpE,IAAM,eAAe,GAAG,MAAA,UAAU,CAAC,CAAC,CAAC,mCAAI,CAAC,CAAC;IAC3C,OAAO,MAAA,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,mCAAI,EAAE,CAAC;AAC5C,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type z from 'zod';
|
|
2
|
-
import type { AgentInternalTool } from './types
|
|
1
|
+
import type z from 'zod/v3/external.cjs';
|
|
2
|
+
import type { AgentInternalTool } from './types';
|
|
3
3
|
export declare const createAgentTool: <TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny>(param: AgentInternalTool<TInputSchema, TOutputSchema>) => AgentInternalTool<TInputSchema, TOutputSchema>;
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/AgentTool/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,qBAAqB,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,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"}
|