@arvo-tools/agentic 0.4.1 → 1.0.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/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 +41 -6
- 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 +102 -25
- 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 +222 -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/AgentTool/index.d.ts +30 -0
- package/dist/AgentTool/index.d.ts.map +1 -0
- package/dist/{Agent/agentTool.js → AgentTool/index.js} +27 -1
- package/dist/AgentTool/index.js.map +1 -0
- package/dist/AgentTool/types.d.ts +59 -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 +1 -1
- package/dist/Agent/agentTool.d.ts +0 -4
- 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/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Agent/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4E;AAC5E,yDAI4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Agent/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4E;AAC5E,yDAI4B;AAG5B,+CAA2C;AAO3C,uCAIoB;AAcpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE;4CACjE,IAAI,EAAE,IAAI,CAAC,IAAI;4CACf,IAAI,wBACC,IAAI,CAAC,KAAK,KACb,eAAe,EAAE,2BAAyB,CAAC,cAAc,GAC1D;4CACD,MAAM,EAAE,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;4CACzC,cAAc,EAAE,UAAQ,CAAC,cAAc;yCACxC,CAAC,EATyC,CASzC,CAAC;qCACJ,EAAC;4BACJ,CAAC;4BAED,sBAAO;oCACL,OAAO,EAAE,2BAAyB;oCAClC,MAAM,aACJ,gBAAgB,EAAE,UAAQ,CAAC,cAAc,IACtC,UAAQ,CAAC,MAAM,CACnB;iCACF,EAAC;gCAEF,qBAAM,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,0CAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA,EAAA;;4BAAzD,SAAyD,CAAC;;;;;iBAE7D,CAIqB;SACvB,EAnMiD,CAmMjD,CAAC,CAKH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA7OW,QAAA,eAAe,mBA6O1B"}
|
package/dist/Agent/schema.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
/** Zod schema for standard text content within a message. */
|
|
2
3
|
export declare const AgentTextContentSchema: z.ZodObject<{
|
|
3
4
|
type: z.ZodLiteral<"text">;
|
|
4
5
|
content: z.ZodString;
|
|
@@ -9,6 +10,7 @@ export declare const AgentTextContentSchema: z.ZodObject<{
|
|
|
9
10
|
type: "text";
|
|
10
11
|
content: string;
|
|
11
12
|
}>;
|
|
13
|
+
/** Zod schema for multimodal inputs (Images, PDFs, Files) encoded as Base64. */
|
|
12
14
|
export declare const AgentMediaContentSchema: z.ZodObject<{
|
|
13
15
|
type: z.ZodLiteral<"media">;
|
|
14
16
|
content: z.ZodString;
|
|
@@ -72,6 +74,7 @@ export declare const AgentMediaContentSchema: z.ZodObject<{
|
|
|
72
74
|
format: "base64";
|
|
73
75
|
};
|
|
74
76
|
}>;
|
|
77
|
+
/** Zod schema for the output of a tool execution, correlated by ID to a specific tool call. */
|
|
75
78
|
export declare const AgentToolResultContentSchema: z.ZodObject<{
|
|
76
79
|
type: z.ZodLiteral<"tool_result">;
|
|
77
80
|
toolUseId: z.ZodString;
|
|
@@ -85,6 +88,7 @@ export declare const AgentToolResultContentSchema: z.ZodObject<{
|
|
|
85
88
|
content: string;
|
|
86
89
|
toolUseId: string;
|
|
87
90
|
}>;
|
|
91
|
+
/** Zod schema representing an LLM's request to execute a named tool with specific arguments. */
|
|
88
92
|
export declare const AgentToolCallContentSchema: z.ZodObject<{
|
|
89
93
|
type: z.ZodLiteral<"tool_use">;
|
|
90
94
|
toolUseId: z.ZodString;
|
|
@@ -101,6 +105,7 @@ export declare const AgentToolCallContentSchema: z.ZodObject<{
|
|
|
101
105
|
name: string;
|
|
102
106
|
input: Record<string, any>;
|
|
103
107
|
}>;
|
|
108
|
+
/** Discriminated union of all valid payload types (Text, Media, Tool Calls, and Results). */
|
|
104
109
|
export declare const AgentMessageContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
105
110
|
type: z.ZodLiteral<"text">;
|
|
106
111
|
content: z.ZodString;
|
|
@@ -200,6 +205,7 @@ export declare const AgentMessageContentSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
200
205
|
name: string;
|
|
201
206
|
input: Record<string, any>;
|
|
202
207
|
}>]>;
|
|
208
|
+
/** The primary data structure representing a single turn in the Agent's conversation history. */
|
|
203
209
|
export declare const AgentMessageSchema: z.ZodObject<{
|
|
204
210
|
role: z.ZodEnum<["user", "assistant"]>;
|
|
205
211
|
content: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -301,6 +307,7 @@ export declare const AgentMessageSchema: z.ZodObject<{
|
|
|
301
307
|
name: string;
|
|
302
308
|
input: Record<string, any>;
|
|
303
309
|
}>]>;
|
|
310
|
+
seenCount: z.ZodNumber;
|
|
304
311
|
}, "strip", z.ZodTypeAny, {
|
|
305
312
|
content: {
|
|
306
313
|
type: "text";
|
|
@@ -330,6 +337,7 @@ export declare const AgentMessageSchema: z.ZodObject<{
|
|
|
330
337
|
input: Record<string, any>;
|
|
331
338
|
};
|
|
332
339
|
role: "user" | "assistant";
|
|
340
|
+
seenCount: number;
|
|
333
341
|
}, {
|
|
334
342
|
content: {
|
|
335
343
|
type: "text";
|
|
@@ -359,5 +367,6 @@ export declare const AgentMessageSchema: z.ZodObject<{
|
|
|
359
367
|
input: Record<string, any>;
|
|
360
368
|
};
|
|
361
369
|
role: "user" | "assistant";
|
|
370
|
+
seenCount: number;
|
|
362
371
|
}>;
|
|
363
372
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/Agent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBlC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;EAIvC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKpC,CAAC;AAEH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/Agent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,gFAAgF;AAChF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBlC,CAAC;AAEH,+FAA+F;AAC/F,eAAO,MAAM,4BAA4B;;;;;;;;;;;;EAIvC,CAAC;AAEH,gGAAgG;AAChG,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAC;AAEH,6FAA6F;AAC7F,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKpC,CAAC;AAEH,iGAAiG;AACjG,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI7B,CAAC"}
|
package/dist/Agent/schema.js
CHANGED
|
@@ -5,10 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AgentMessageSchema = exports.AgentMessageContentSchema = exports.AgentToolCallContentSchema = exports.AgentToolResultContentSchema = exports.AgentMediaContentSchema = exports.AgentTextContentSchema = void 0;
|
|
7
7
|
var zod_1 = __importDefault(require("zod"));
|
|
8
|
+
/** Zod schema for standard text content within a message. */
|
|
8
9
|
exports.AgentTextContentSchema = zod_1.default.object({
|
|
9
10
|
type: zod_1.default.literal('text'),
|
|
10
11
|
content: zod_1.default.string(),
|
|
11
12
|
});
|
|
13
|
+
/** Zod schema for multimodal inputs (Images, PDFs, Files) encoded as Base64. */
|
|
12
14
|
exports.AgentMediaContentSchema = zod_1.default.object({
|
|
13
15
|
type: zod_1.default.literal('media'),
|
|
14
16
|
content: zod_1.default.string(),
|
|
@@ -27,25 +29,30 @@ exports.AgentMediaContentSchema = zod_1.default.object({
|
|
|
27
29
|
}),
|
|
28
30
|
]),
|
|
29
31
|
});
|
|
32
|
+
/** Zod schema for the output of a tool execution, correlated by ID to a specific tool call. */
|
|
30
33
|
exports.AgentToolResultContentSchema = zod_1.default.object({
|
|
31
34
|
type: zod_1.default.literal('tool_result'),
|
|
32
35
|
toolUseId: zod_1.default.string(),
|
|
33
36
|
content: zod_1.default.string(),
|
|
34
37
|
});
|
|
38
|
+
/** Zod schema representing an LLM's request to execute a named tool with specific arguments. */
|
|
35
39
|
exports.AgentToolCallContentSchema = zod_1.default.object({
|
|
36
40
|
type: zod_1.default.literal('tool_use'),
|
|
37
41
|
toolUseId: zod_1.default.string(),
|
|
38
42
|
name: zod_1.default.string(),
|
|
39
43
|
input: zod_1.default.record(zod_1.default.string(), zod_1.default.any()),
|
|
40
44
|
});
|
|
45
|
+
/** Discriminated union of all valid payload types (Text, Media, Tool Calls, and Results). */
|
|
41
46
|
exports.AgentMessageContentSchema = zod_1.default.discriminatedUnion('type', [
|
|
42
47
|
exports.AgentTextContentSchema,
|
|
43
48
|
exports.AgentMediaContentSchema,
|
|
44
49
|
exports.AgentToolResultContentSchema,
|
|
45
50
|
exports.AgentToolCallContentSchema,
|
|
46
51
|
]);
|
|
52
|
+
/** The primary data structure representing a single turn in the Agent's conversation history. */
|
|
47
53
|
exports.AgentMessageSchema = zod_1.default.object({
|
|
48
54
|
role: zod_1.default.enum(['user', 'assistant']),
|
|
49
55
|
content: exports.AgentMessageContentSchema,
|
|
56
|
+
seenCount: zod_1.default.number().describe('Then number of time the LLM integration has seen this message'),
|
|
50
57
|
});
|
|
51
58
|
//# sourceMappingURL=schema.js.map
|
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,kBAAkB,CAAC,MAAM,EAAE;QACxC,aAAC,CAAC,MAAM,CAAC;YACP,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;YACpB,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;YACpB,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;SAC3B,CAAC;QACF,aAAC,CAAC,MAAM,CAAC;YACP,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;YACpB,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;YACpB,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YACvB,MAAM,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;SAC3B,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,+FAA+F;AAClF,QAAA,4BAA4B,GAAG,aAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAC9B,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,gGAAgG;AACnF,QAAA,0BAA0B,GAAG,aAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,aAAC,CAAC,MAAM,CAAC,aAAC,CAAC,MAAM,EAAE,EAAE,aAAC,CAAC,GAAG,EAAE,CAAC;CACrC,CAAC,CAAC;AAEH,6FAA6F;AAChF,QAAA,yBAAyB,GAAG,aAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACpE,8BAAsB;IACtB,+BAAuB;IACvB,oCAA4B;IAC5B,kCAA0B;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,91 @@ 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
|
+
* The default mechanism to force 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 default llm integrations function which connect this agent to the intelligence layer
|
|
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
|
+
/**
|
|
285
|
+
* An optional override to forces the Agent to generate a specific output structure.
|
|
286
|
+
* - `'text'`: Standard conversational response.
|
|
287
|
+
* - `'json'`: Structured Output / JSON Mode (validated against the contract's output schema).
|
|
288
|
+
*/
|
|
289
|
+
llmResponseType?: AgentLLMIntegrationParam['outputFormat']['type'];
|
|
290
|
+
/** An optional override llm integration specific to this version. This allows to completely version an agent */
|
|
291
|
+
llm?: AgentLLMIntegration;
|
|
292
|
+
/** Generates the System Prompt and initial conversation context for this version. */
|
|
130
293
|
context: AgentContextBuilder<TSelfContract, K, TServiceContract, TTools>;
|
|
294
|
+
/** Maps the LLM's final response to the strict output contract for this version. */
|
|
131
295
|
output: AgentOutputBuilder<TSelfContract, K>;
|
|
132
296
|
};
|
|
133
297
|
};
|
|
@@ -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,E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AEzB;;;;;;;OAOG;IACH,OAAO,EAAE;SACN,CAAC,IAAI,MAAM,aAAa,CAAC,UAAU,CAAC,GAAG,mBAAmB,GAAG;YAC5D;;;;eAIG;YACH,eAAe,CAAC,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;YACnE,gHAAgH;YAChH,GAAG,CAAC,EAAE,mBAAmB,CAAC;YAC1B,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,
|
|
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,iBAAiB,EAAE,MAA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