@arvo-tools/agentic 1.0.0 → 1.1.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 +10 -2
- package/dist/Agent/AgentDefaults.d.ts.map +1 -1
- package/dist/Agent/AgentDefaults.js +27 -11
- package/dist/Agent/AgentDefaults.js.map +1 -1
- package/dist/Agent/agentLoop.d.ts +25 -11
- package/dist/Agent/agentLoop.d.ts.map +1 -1
- package/dist/Agent/agentLoop.js +84 -23
- package/dist/Agent/agentLoop.js.map +1 -1
- package/dist/Agent/index.d.ts +5 -1
- package/dist/Agent/index.d.ts.map +1 -1
- package/dist/Agent/index.js +61 -30
- package/dist/Agent/index.js.map +1 -1
- package/dist/Agent/schema.d.ts +76 -76
- package/dist/Agent/schema.js +4 -4
- package/dist/Agent/schema.js.map +1 -1
- package/dist/Agent/stream/schema.d.ts +456 -0
- package/dist/Agent/stream/schema.d.ts.map +1 -0
- package/dist/Agent/stream/schema.js +88 -0
- package/dist/Agent/stream/schema.js.map +1 -0
- package/dist/Agent/stream/types.d.ts +13 -0
- package/dist/Agent/stream/types.d.ts.map +1 -0
- package/dist/Agent/stream/types.js +3 -0
- package/dist/Agent/stream/types.js.map +1 -0
- package/dist/Agent/stream/utils.d.ts +23 -0
- package/dist/Agent/stream/utils.d.ts.map +1 -0
- package/dist/Agent/stream/utils.js +37 -0
- package/dist/Agent/stream/utils.js.map +1 -0
- package/dist/Agent/types.d.ts +15 -2
- package/dist/Agent/types.d.ts.map +1 -1
- package/dist/AgentTool/index.d.ts +26 -0
- package/dist/AgentTool/index.d.ts.map +1 -1
- package/dist/AgentTool/index.js +26 -0
- package/dist/AgentTool/index.js.map +1 -1
- package/dist/AgentTool/types.d.ts +42 -4
- package/dist/AgentTool/types.d.ts.map +1 -1
- package/dist/Integrations/anthropic/index.d.ts +24 -0
- package/dist/Integrations/anthropic/index.d.ts.map +1 -0
- package/dist/Integrations/anthropic/index.js +278 -0
- package/dist/Integrations/anthropic/index.js.map +1 -0
- package/dist/Integrations/anthropic/types.d.ts +17 -0
- package/dist/Integrations/anthropic/types.d.ts.map +1 -0
- package/dist/Integrations/anthropic/types.js +3 -0
- package/dist/Integrations/anthropic/types.js.map +1 -0
- package/dist/Integrations/anthropic/utils.d.ts +14 -0
- package/dist/Integrations/anthropic/utils.d.ts.map +1 -0
- package/dist/Integrations/anthropic/utils.js +158 -0
- package/dist/Integrations/anthropic/utils.js.map +1 -0
- package/dist/Integrations/openai/index.d.ts +15 -19
- package/dist/Integrations/openai/index.d.ts.map +1 -1
- package/dist/Integrations/openai/index.js +74 -179
- package/dist/Integrations/openai/index.js.map +1 -1
- package/dist/Integrations/openai/types.d.ts +33 -0
- package/dist/Integrations/openai/types.d.ts.map +1 -0
- package/dist/Integrations/openai/types.js +3 -0
- package/dist/Integrations/openai/types.js.map +1 -0
- package/dist/Integrations/openai/utils.d.ts +13 -0
- package/dist/Integrations/openai/utils.d.ts.map +1 -0
- package/dist/Integrations/openai/utils.js +133 -0
- package/dist/Integrations/openai/utils.js.map +1 -0
- package/dist/Integrations/prompts.d.ts +1 -0
- package/dist/Integrations/prompts.d.ts.map +1 -1
- package/dist/Integrations/prompts.js +5 -1
- package/dist/Integrations/prompts.js.map +1 -1
- package/dist/Integrations/types.d.ts +41 -1
- package/dist/Integrations/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/Agent/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { AgentLLMIntegration, AgentLLMIntegrationOutput, AgentLLMIntegratio
|
|
|
7
7
|
import type { IMCPClient } from '../interfaces.mcp';
|
|
8
8
|
import type { NonEmptyArray, PromiseAble } from '../types';
|
|
9
9
|
import type { AgentMediaContentSchema, AgentMessageContentSchema, AgentMessageSchema, AgentTextContentSchema, AgentToolCallContentSchema, AgentToolResultContentSchema } from './schema';
|
|
10
|
+
import type { AgentStreamListener } from './stream/types';
|
|
10
11
|
/** Represents a pure text block in the conversation history. */
|
|
11
12
|
export type AgentTextContent = z.infer<typeof AgentTextContentSchema>;
|
|
12
13
|
/** Represents media (images/files) passed to the Agent, usually for multimodal models. */
|
|
@@ -181,6 +182,8 @@ export type AgentContextBuilder<T extends AnyArvoOrchestratorContract = AnyArvoO
|
|
|
181
182
|
lifecycle: AgentLLMIntegrationParam['lifecycle'];
|
|
182
183
|
/** The fully typed input event data for this specific contract version. */
|
|
183
184
|
input: InferVersionedArvoContract<VersionedArvoContract<T, V>>['accepts'];
|
|
185
|
+
/** The agent's self contract reference */
|
|
186
|
+
selfContract: VersionedArvoContract<T, V>;
|
|
184
187
|
/** Catalog of available tools for dynamic prompt injection. */
|
|
185
188
|
tools: AgentLLMContext<TServiceContract, TTools>['tools'];
|
|
186
189
|
/** The Otel span to add logs to */
|
|
@@ -260,17 +263,19 @@ export type CreateArvoAgentParam<TSelfContract extends AnyArvoOrchestratorContra
|
|
|
260
263
|
*/
|
|
261
264
|
tools?: TTools;
|
|
262
265
|
/**
|
|
263
|
-
*
|
|
266
|
+
* The default mechanism to force the Agent to generate a specific output structure.
|
|
264
267
|
* - `'text'`: Standard conversational response.
|
|
265
268
|
* - `'json'`: Structured Output / JSON Mode (validated against the contract's output schema).
|
|
266
269
|
* @defaultValue 'text'
|
|
267
270
|
*/
|
|
268
271
|
llmResponseType?: AgentLLMIntegrationParam['outputFormat']['type'];
|
|
269
272
|
/**
|
|
270
|
-
* The
|
|
273
|
+
* The default llm integrations function which connect this agent to the intelligence layer
|
|
271
274
|
* (e.g., `openaiLLMIntegration`, `anthropicLLMIntegration`).
|
|
272
275
|
*/
|
|
273
276
|
llm: AgentLLMIntegration;
|
|
277
|
+
/** A agent stream listener hook */
|
|
278
|
+
onStream?: AgentStreamListener;
|
|
274
279
|
/**
|
|
275
280
|
* Arvo enforces strict version compliance. You must provide specific logic
|
|
276
281
|
* (System Prompt Building & Output Mapping) for **every semantic version**
|
|
@@ -281,6 +286,14 @@ export type CreateArvoAgentParam<TSelfContract extends AnyArvoOrchestratorContra
|
|
|
281
286
|
*/
|
|
282
287
|
handler: {
|
|
283
288
|
[K in keyof TSelfContract['versions'] & ArvoSemanticVersion]: {
|
|
289
|
+
/**
|
|
290
|
+
* An optional override to forces the Agent to generate a specific output structure.
|
|
291
|
+
* - `'text'`: Standard conversational response.
|
|
292
|
+
* - `'json'`: Structured Output / JSON Mode (validated against the contract's output schema).
|
|
293
|
+
*/
|
|
294
|
+
llmResponseType?: AgentLLMIntegrationParam['outputFormat']['type'];
|
|
295
|
+
/** An optional override llm integration specific to this version. This allows to completely version an agent */
|
|
296
|
+
llm?: AgentLLMIntegration;
|
|
284
297
|
/** Generates the System Prompt and initial conversation context for this version. */
|
|
285
298
|
context: AgentContextBuilder<TSelfContract, K, TServiceContract, TTools>;
|
|
286
299
|
/** Maps the LLM's final response to the strict output contract for this version. */
|
|
@@ -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,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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AAmB,CAAC;IAEzB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAE/B;;;;;;;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"}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import type z from 'zod/v3/external.cjs';
|
|
2
2
|
import type { AgentInternalTool } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Factory function to create an Instrumented Agent Tool.
|
|
5
|
+
*
|
|
6
|
+
* Wraps your raw tool logic with **OpenTelemetry Auto-Instrumentation** and **Input Validation**.
|
|
7
|
+
*
|
|
8
|
+
* **Why use this instead of a raw object?**
|
|
9
|
+
* 1. **Observability:** Automatically creates a child Span (`OpenInferenceSpanKind.TOOL`).
|
|
10
|
+
* It records input arguments, output values, and execution duration to your tracing backend.
|
|
11
|
+
* 2. **Safety:** Automatically validates `input` against the Zod schema *before* your function runs.
|
|
12
|
+
* Throws a clear error if the LLM hallucinated invalid arguments.
|
|
13
|
+
* 3. **Type Safety:** Infers generic types for `input` and `output` automatically.
|
|
14
|
+
*
|
|
15
|
+
* @param param - The tool definition.
|
|
16
|
+
* @returns The wrapped, production-ready tool.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const timeTool = createAgentTool({
|
|
21
|
+
* name: 'get_time',
|
|
22
|
+
* description: 'Returns current server time',
|
|
23
|
+
* input: z.object({}),
|
|
24
|
+
* output: z.object({ time: z.string() }),
|
|
25
|
+
* fn: () => ({ time: new Date().toISOString() })
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
3
29
|
export declare const createAgentTool: <TInputSchema extends z.ZodTypeAny, TOutputSchema extends z.ZodTypeAny>(param: AgentInternalTool<TInputSchema, TOutputSchema>) => AgentInternalTool<TInputSchema, TOutputSchema>;
|
|
4
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,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"}
|
package/dist/AgentTool/index.js
CHANGED
|
@@ -51,6 +51,32 @@ exports.createAgentTool = void 0;
|
|
|
51
51
|
var openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
52
52
|
var api_1 = require("@opentelemetry/api");
|
|
53
53
|
var arvo_core_1 = require("arvo-core");
|
|
54
|
+
/**
|
|
55
|
+
* Factory function to create an Instrumented Agent Tool.
|
|
56
|
+
*
|
|
57
|
+
* Wraps your raw tool logic with **OpenTelemetry Auto-Instrumentation** and **Input Validation**.
|
|
58
|
+
*
|
|
59
|
+
* **Why use this instead of a raw object?**
|
|
60
|
+
* 1. **Observability:** Automatically creates a child Span (`OpenInferenceSpanKind.TOOL`).
|
|
61
|
+
* It records input arguments, output values, and execution duration to your tracing backend.
|
|
62
|
+
* 2. **Safety:** Automatically validates `input` against the Zod schema *before* your function runs.
|
|
63
|
+
* Throws a clear error if the LLM hallucinated invalid arguments.
|
|
64
|
+
* 3. **Type Safety:** Infers generic types for `input` and `output` automatically.
|
|
65
|
+
*
|
|
66
|
+
* @param param - The tool definition.
|
|
67
|
+
* @returns The wrapped, production-ready tool.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const timeTool = createAgentTool({
|
|
72
|
+
* name: 'get_time',
|
|
73
|
+
* description: 'Returns current server time',
|
|
74
|
+
* input: z.object({}),
|
|
75
|
+
* output: z.object({ time: z.string() }),
|
|
76
|
+
* fn: () => ({ time: new Date().toISOString() })
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
54
80
|
var createAgentTool = function (param) {
|
|
55
81
|
return (__assign(__assign({}, param), { fn: function (input, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
82
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/AgentTool/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAGqD;AACrD,0CAAoD;AACpD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AAM,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE;oDAClD,QAAQ,EAAE;wDACR,IAAI,MAAA;wDACJ,OAAO,EAAE,IAAA,iCAAqB,EAAC,IAAI,CAAC;qDACrC;iDACF,CAAC,EAAA;;4CALI,MAAM,GAAG,SAKb;4CACF,IAAI,CAAC,YAAY,CACf,wDAAgC,CAAC,YAAY,EAC7C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CACvB,CAAC;4CACF,sBAAO,MAAM,EAAC;;;4CAEd,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,oBAAc,CAAC,KAAK,EAAE,OAAO,EAAG,KAAa,aAAb,KAAG,uBAAH,KAAG,CAAY,OAAO,EAAE,CAAC,CAAC;4CACjF,MAAM,KAAG,CAAC;;4CAEV,IAAI,CAAC,GAAG,EAAE,CAAC;;;;;iCAEd;yBACF,CAAC,EAAA;4BA3CF,sBAAA,SA2CE,EAAA;;;aAAA,IAC8C;AA/CpD,CA+CoD,CAAC;AArD1C,QAAA,eAAe,mBAqD2B"}
|
|
@@ -1,19 +1,57 @@
|
|
|
1
1
|
import type z from 'zod';
|
|
2
2
|
import type { OtelInfoType, PromiseAble } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
* Defines a Synchronous Internal Tool
|
|
4
|
+
* Defines the structure of a **Synchronous Internal Tool**.
|
|
5
5
|
*
|
|
6
|
-
* Internal tools are
|
|
7
|
-
* Unlike Services, the Agent **does not suspend** when calling these. They are awaited immediately.
|
|
6
|
+
* Internal tools are JavaScript/TypeScript functions that execute *inside* the Agent's loop.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* **Architectural Note:**
|
|
10
|
+
* Unlike Arvo Services (which trigger a "Suspend & Emit" lifecycle), Internal Tools are atomic.
|
|
11
|
+
* The Agent calls them, awaits the result, and continues reasoning in the same execution tick.
|
|
12
|
+
*
|
|
13
|
+
* **Best Practices:**
|
|
14
|
+
* - Use for **Fast, CPU-bound** logic (Math, Data Transformation, Regex).
|
|
15
|
+
* - Use for **Read-only** operations that don't require distributed consensus.
|
|
16
|
+
* - Do **not** use for long-running tasks, as this blocks the Agent execution.
|
|
10
17
|
*/
|
|
11
18
|
export type AgentInternalTool<TInputSchema extends z.ZodTypeAny = any, TOutputSchema extends z.ZodTypeAny = any> = {
|
|
19
|
+
/**
|
|
20
|
+
* The unique identifier for this tool (e.g. `calculator`, `get_current_time`).
|
|
21
|
+
* This name is injected into the LLM's system prompt.
|
|
22
|
+
*/
|
|
12
23
|
name: string;
|
|
24
|
+
/**
|
|
25
|
+
* This string is critical. It tells the LLM *when* and *why* to use this tool.
|
|
26
|
+
* @example
|
|
27
|
+
* "Calculate the MD5 hash of a string. Use this whenever the user asks for a checksum."
|
|
28
|
+
*/
|
|
13
29
|
description: string;
|
|
30
|
+
/**
|
|
31
|
+
* Zod Schema defining the arguments the LLM must provide.
|
|
32
|
+
* Arvo automatically validates the LLM's JSON output against this schema before calling `fn`.
|
|
33
|
+
*/
|
|
14
34
|
input: TInputSchema;
|
|
35
|
+
/**
|
|
36
|
+
* Zod Schema defining what this tool returns.
|
|
37
|
+
* Used for type inference and documentation, though runtime validation of the result is optional.
|
|
38
|
+
*/
|
|
15
39
|
output: TOutputSchema;
|
|
40
|
+
/**
|
|
41
|
+
* If the LLM attempts to call multiple tools in parallel (e.g. `delete_user` + `human_approval`),
|
|
42
|
+
* Arvo sorts calls by priority and **only executes the highest priority batch**.
|
|
43
|
+
* Lower priority calls are silently dropped to enforce safety/auth guardrails.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue 0
|
|
46
|
+
*/
|
|
16
47
|
priority?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The implementation logic.
|
|
50
|
+
*
|
|
51
|
+
* @param input - The validated arguments matching `TInputSchema`. You do not need to re-validate.
|
|
52
|
+
* @param config - Observability context (Span/Headers) to link any internal logging or network calls.
|
|
53
|
+
* @returns The result matching `TOutputSchema`.
|
|
54
|
+
*/
|
|
17
55
|
fn: (input: z.infer<TInputSchema>, config: {
|
|
18
56
|
otelInfo: OtelInfoType;
|
|
19
57
|
}) => PromiseAble<z.infer<TOutputSchema>>;
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,CAE3B,YAAY,SAAS,CAAC,CAAC,UAAU,GAAG,GAAG,EAEvC,aAAa,SAAS,CAAC,CAAC,UAAU,GAAG,GAAG,IACtC;IACF;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,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,24 @@
|
|
|
1
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type { AgentLLMIntegration } from '../types';
|
|
3
|
+
import type { AnthropicLlmIntegrationConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an Arvo-compatible LLM Adapter for Anthropic Claude models.
|
|
6
|
+
*
|
|
7
|
+
* This factory configures an integration that bridges the generic `Arvo` agent runner with the specific
|
|
8
|
+
* Anthropic API requirements. It includes built-in features for:
|
|
9
|
+
*
|
|
10
|
+
* - **Structured Outputs:** Automatically converts Zod schemas to JSON schema format and instructs
|
|
11
|
+
* Claude to respond with valid JSON matching the schema.
|
|
12
|
+
* - **Token Optimization:** Automatically replaces large media payloads (images/files) with placeholder
|
|
13
|
+
* text in the conversational history after they have been processed once to reduce context window usage.
|
|
14
|
+
* - **Observability:** Instruments calls with OpenInference-compliant OpenTelemetry attributes,
|
|
15
|
+
* including detailed input/output recording and token usage.
|
|
16
|
+
* - **Safety:** Automatically injects a "tool limit reached" system instruction when the agent
|
|
17
|
+
* exhausts its configured tool budget.
|
|
18
|
+
*
|
|
19
|
+
* @param client - An initialized `Anthropic` SDK client instance.
|
|
20
|
+
* @param config - Configuration for model parameters (e.g., temperature, max tokens), cost calculations, and telemetry metadata.
|
|
21
|
+
* @returns An `AgentLLMIntegration` function ready for use with `createArvoAgent`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const anthropicLLMIntegration: (client: Anthropic, config?: AnthropicLlmIntegrationConfig) => AgentLLMIntegration;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Integrations/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAiB/C,OAAO,KAAK,EAAE,mBAAmB,EAA6B,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAG7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB,GACjC,QAAQ,SAAS,EAAE,SAAS,6BAA6B,KAAG,mBAoLzD,CAAC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __values = (this && this.__values) || function(o) {
|
|
50
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
+
if (m) return m.call(o);
|
|
52
|
+
if (o && typeof o.length === "number") return {
|
|
53
|
+
next: function () {
|
|
54
|
+
if (o && i >= o.length) o = void 0;
|
|
55
|
+
return { value: o && o[i++], done: !o };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.anthropicLLMIntegration = void 0;
|
|
62
|
+
var openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
63
|
+
var api_1 = require("@opentelemetry/api");
|
|
64
|
+
var arvo_core_1 = require("arvo-core");
|
|
65
|
+
var zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
66
|
+
var utils_1 = require("../../Agent/utils");
|
|
67
|
+
var prompts_1 = require("../prompts");
|
|
68
|
+
var utils_2 = require("./utils");
|
|
69
|
+
/**
|
|
70
|
+
* Creates an Arvo-compatible LLM Adapter for Anthropic Claude models.
|
|
71
|
+
*
|
|
72
|
+
* This factory configures an integration that bridges the generic `Arvo` agent runner with the specific
|
|
73
|
+
* Anthropic API requirements. It includes built-in features for:
|
|
74
|
+
*
|
|
75
|
+
* - **Structured Outputs:** Automatically converts Zod schemas to JSON schema format and instructs
|
|
76
|
+
* Claude to respond with valid JSON matching the schema.
|
|
77
|
+
* - **Token Optimization:** Automatically replaces large media payloads (images/files) with placeholder
|
|
78
|
+
* text in the conversational history after they have been processed once to reduce context window usage.
|
|
79
|
+
* - **Observability:** Instruments calls with OpenInference-compliant OpenTelemetry attributes,
|
|
80
|
+
* including detailed input/output recording and token usage.
|
|
81
|
+
* - **Safety:** Automatically injects a "tool limit reached" system instruction when the agent
|
|
82
|
+
* exhausts its configured tool budget.
|
|
83
|
+
*
|
|
84
|
+
* @param client - An initialized `Anthropic` SDK client instance.
|
|
85
|
+
* @param config - Configuration for model parameters (e.g., temperature, max tokens), cost calculations, and telemetry metadata.
|
|
86
|
+
* @returns An `AgentLLMIntegration` function ready for use with `createArvoAgent`.
|
|
87
|
+
*/
|
|
88
|
+
var anthropicLLMIntegration = function (client, config) {
|
|
89
|
+
return function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
|
|
90
|
+
var _e;
|
|
91
|
+
var _messages = _c.messages, _system = _c.system, tools = _c.tools, outputFormat = _c.outputFormat, lifecycle = _c.lifecycle, toolInteractions = _c.toolInteractions;
|
|
92
|
+
var otelInfo = _d.otelInfo;
|
|
93
|
+
return __generator(this, function (_f) {
|
|
94
|
+
switch (_f.label) {
|
|
95
|
+
case 0: return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan({
|
|
96
|
+
name: "LLM.invoke<".concat(lifecycle === 'init' ? 'init' : lifecycle === 'tool_result' ? 'resume' : 'output_validation_feedback', ">"),
|
|
97
|
+
disableSpanManagement: true,
|
|
98
|
+
context: {
|
|
99
|
+
inheritFrom: 'TRACE_HEADERS',
|
|
100
|
+
traceHeaders: otelInfo.headers,
|
|
101
|
+
},
|
|
102
|
+
spanOptions: {
|
|
103
|
+
attributes: (_e = {},
|
|
104
|
+
_e[openinference_semantic_conventions_1.SemanticConventions.OPENINFERENCE_SPAN_KIND] = openinference_semantic_conventions_1.OpenInferenceSpanKind.LLM,
|
|
105
|
+
_e),
|
|
106
|
+
},
|
|
107
|
+
fn: function (span) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
var messageCreateParams, _a, messages, system, limitMessage, jsonSchema, schemaInstruction, toolDef, tools_1, tools_1_1, tool, formattedMessages, response, llmUsage, executionUnits, toolUseBlocks, toolRequests, toolUseBlocks_1, toolUseBlocks_1_1, toolCall, textBlocks, content, e_1;
|
|
109
|
+
var e_2, _b, e_3, _c;
|
|
110
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
111
|
+
return __generator(this, function (_l) {
|
|
112
|
+
switch (_l.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
messageCreateParams = (_d = config === null || config === void 0 ? void 0 : config.invocationParam) !== null && _d !== void 0 ? _d : {
|
|
115
|
+
model: 'claude-sonnet-4-20250514',
|
|
116
|
+
max_tokens: 4096,
|
|
117
|
+
temperature: 0,
|
|
118
|
+
};
|
|
119
|
+
return [4 /*yield*/, ((_e = config === null || config === void 0 ? void 0 : config.contextTransformer) === null || _e === void 0 ? void 0 : _e.call(config, {
|
|
120
|
+
messages: _messages,
|
|
121
|
+
system: _system,
|
|
122
|
+
}))];
|
|
123
|
+
case 1:
|
|
124
|
+
_a = (_f = (_l.sent())) !== null && _f !== void 0 ? _f : {
|
|
125
|
+
messages: _messages.map(function (item) {
|
|
126
|
+
if (item.content.type === 'media' && item.seenCount > 0) {
|
|
127
|
+
return {
|
|
128
|
+
role: item.role,
|
|
129
|
+
content: {
|
|
130
|
+
type: 'text',
|
|
131
|
+
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"),
|
|
132
|
+
},
|
|
133
|
+
seenCount: item.seenCount,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return item;
|
|
137
|
+
}),
|
|
138
|
+
system: _system,
|
|
139
|
+
}, messages = _a.messages, system = _a.system;
|
|
140
|
+
if (toolInteractions.exhausted) {
|
|
141
|
+
limitMessage = (_h = (_g = config === null || config === void 0 ? void 0 : config.toolLimitPrompt) === null || _g === void 0 ? void 0 : _g.call(config, toolInteractions)) !== null && _h !== void 0 ? _h : prompts_1.DEFAULT_TOOL_LIMIT_PROMPT;
|
|
142
|
+
messages.push({
|
|
143
|
+
role: 'user',
|
|
144
|
+
content: {
|
|
145
|
+
type: 'text',
|
|
146
|
+
content: limitMessage,
|
|
147
|
+
},
|
|
148
|
+
seenCount: 0,
|
|
149
|
+
});
|
|
150
|
+
system = "".concat(system, "\n\n").concat(limitMessage);
|
|
151
|
+
}
|
|
152
|
+
// For JSON output format, append schema instructions to the system prompt
|
|
153
|
+
if (outputFormat.type === 'json') {
|
|
154
|
+
jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(outputFormat.format);
|
|
155
|
+
schemaInstruction = (0, prompts_1.jsonPrompt)(JSON.stringify(jsonSchema));
|
|
156
|
+
system = system ? "".concat(system).concat(schemaInstruction) : schemaInstruction;
|
|
157
|
+
}
|
|
158
|
+
(0, utils_1.setOpenInferenceInputAttr)({
|
|
159
|
+
llm: {
|
|
160
|
+
provider: 'anthropic',
|
|
161
|
+
system: 'anthropic',
|
|
162
|
+
model: messageCreateParams === null || messageCreateParams === void 0 ? void 0 : messageCreateParams.model,
|
|
163
|
+
invocationParam: messageCreateParams,
|
|
164
|
+
},
|
|
165
|
+
messages: messages,
|
|
166
|
+
system: system,
|
|
167
|
+
tools: tools,
|
|
168
|
+
}, span);
|
|
169
|
+
_l.label = 2;
|
|
170
|
+
case 2:
|
|
171
|
+
_l.trys.push([2, 4, 5, 6]);
|
|
172
|
+
toolDef = [];
|
|
173
|
+
try {
|
|
174
|
+
for (tools_1 = __values(tools), tools_1_1 = tools_1.next(); !tools_1_1.done; tools_1_1 = tools_1.next()) {
|
|
175
|
+
tool = tools_1_1.value;
|
|
176
|
+
toolDef.push({
|
|
177
|
+
name: tool.name,
|
|
178
|
+
description: tool.description,
|
|
179
|
+
input_schema: tool.inputSchema,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
184
|
+
finally {
|
|
185
|
+
try {
|
|
186
|
+
if (tools_1_1 && !tools_1_1.done && (_b = tools_1.return)) _b.call(tools_1);
|
|
187
|
+
}
|
|
188
|
+
finally { if (e_2) throw e_2.error; }
|
|
189
|
+
}
|
|
190
|
+
formattedMessages = (0, utils_2.formatMessagesForAnthropic)(messages);
|
|
191
|
+
return [4 /*yield*/, client.messages.create(__assign(__assign({}, messageCreateParams), { system: system !== null && system !== void 0 ? system : undefined, tools: toolDef.length ? toolDef : undefined, messages: formattedMessages }))];
|
|
192
|
+
case 3:
|
|
193
|
+
response = _l.sent();
|
|
194
|
+
llmUsage = {
|
|
195
|
+
tokens: {
|
|
196
|
+
prompt: response.usage.input_tokens,
|
|
197
|
+
completion: response.usage.output_tokens,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
executionUnits = (_k = (_j = config === null || config === void 0 ? void 0 : config.executionunits) === null || _j === void 0 ? void 0 : _j.call(config, llmUsage.tokens.prompt, llmUsage.tokens.completion)) !== null && _k !== void 0 ? _k : llmUsage.tokens.prompt + llmUsage.tokens.completion;
|
|
201
|
+
(0, utils_1.setOpenInferenceUsageOutputAttr)(llmUsage, span);
|
|
202
|
+
toolUseBlocks = response.content.filter(function (block) { return block.type === 'tool_use'; });
|
|
203
|
+
if (toolUseBlocks.length > 0) {
|
|
204
|
+
toolRequests = [];
|
|
205
|
+
try {
|
|
206
|
+
for (toolUseBlocks_1 = __values(toolUseBlocks), toolUseBlocks_1_1 = toolUseBlocks_1.next(); !toolUseBlocks_1_1.done; toolUseBlocks_1_1 = toolUseBlocks_1.next()) {
|
|
207
|
+
toolCall = toolUseBlocks_1_1.value;
|
|
208
|
+
try {
|
|
209
|
+
toolRequests.push({
|
|
210
|
+
toolUseId: toolCall.id,
|
|
211
|
+
name: toolCall.name,
|
|
212
|
+
input: toolCall.input,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
(0, arvo_core_1.exceptionToSpan)(err, span);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
221
|
+
finally {
|
|
222
|
+
try {
|
|
223
|
+
if (toolUseBlocks_1_1 && !toolUseBlocks_1_1.done && (_c = toolUseBlocks_1.return)) _c.call(toolUseBlocks_1);
|
|
224
|
+
}
|
|
225
|
+
finally { if (e_3) throw e_3.error; }
|
|
226
|
+
}
|
|
227
|
+
if (toolRequests.length) {
|
|
228
|
+
(0, utils_1.setOpenInferenceToolCallOutputAttr)({ toolCalls: toolRequests }, span);
|
|
229
|
+
return [2 /*return*/, {
|
|
230
|
+
type: 'tool_call',
|
|
231
|
+
toolRequests: toolRequests,
|
|
232
|
+
usage: llmUsage,
|
|
233
|
+
executionUnits: executionUnits,
|
|
234
|
+
}];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
textBlocks = response.content.filter(function (block) { return block.type === 'text'; });
|
|
238
|
+
content = textBlocks.map(function (block) { return block.text; }).join('');
|
|
239
|
+
// Handle stop reasons
|
|
240
|
+
if (response.stop_reason === 'max_tokens') {
|
|
241
|
+
content = "".concat(content, " [Max response token limit (<= ").concat(messageCreateParams.max_tokens, ") reached]");
|
|
242
|
+
throw new Error("Agent reached max token limit. The partial response is \"".concat(content, "\""));
|
|
243
|
+
}
|
|
244
|
+
(0, utils_1.setOpenInferenceResponseOutputAttr)({ response: content }, span);
|
|
245
|
+
if (outputFormat.type === 'json') {
|
|
246
|
+
return [2 /*return*/, {
|
|
247
|
+
type: 'json',
|
|
248
|
+
content: content || '{}',
|
|
249
|
+
parsedContent: (0, utils_1.tryParseJson)(content || '{}'),
|
|
250
|
+
usage: llmUsage,
|
|
251
|
+
executionUnits: executionUnits,
|
|
252
|
+
}];
|
|
253
|
+
}
|
|
254
|
+
return [2 /*return*/, {
|
|
255
|
+
type: 'text',
|
|
256
|
+
content: content,
|
|
257
|
+
usage: llmUsage,
|
|
258
|
+
executionUnits: executionUnits,
|
|
259
|
+
}];
|
|
260
|
+
case 4:
|
|
261
|
+
e_1 = _l.sent();
|
|
262
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e_1 === null || e_1 === void 0 ? void 0 : e_1.message });
|
|
263
|
+
throw e_1;
|
|
264
|
+
case 5:
|
|
265
|
+
span.end();
|
|
266
|
+
return [7 /*endfinally*/];
|
|
267
|
+
case 6: return [2 /*return*/];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}); },
|
|
271
|
+
})];
|
|
272
|
+
case 1: return [2 /*return*/, _f.sent()];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}); };
|
|
276
|
+
};
|
|
277
|
+
exports.anthropicLLMIntegration = anthropicLLMIntegration;
|
|
278
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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AAnLJ,CAmLI,CAAC;AArLM,QAAA,uBAAuB,2BAqL7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type { CommonIntegrationConfig } from '../types';
|
|
3
|
+
export type AnthropicLlmIntegrationConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Configuration strictly for the model invocation parameters passed to the Anthropic SDK.
|
|
6
|
+
*
|
|
7
|
+
* Common parameters include:
|
|
8
|
+
* - `model`: The model ID (e.g., `claude-sonnet-4-20250514`, `claude-3-5-sonnet-20241022`).
|
|
9
|
+
* - `temperature`: Controls randomness (0-1).
|
|
10
|
+
* - `max_tokens`: Limits the generation length (required by Anthropic).
|
|
11
|
+
*
|
|
12
|
+
* @default
|
|
13
|
+
* { model: 'claude-sonnet-4-20250514', max_tokens: 4096, temperature: 0 }
|
|
14
|
+
*/
|
|
15
|
+
invocationParam?: Pick<Anthropic.MessageCreateParamsNonStreaming, 'model' | 'temperature' | 'max_tokens'>;
|
|
16
|
+
} & CommonIntegrationConfig;
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Integrations/anthropic/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,IAAI,CACpB,SAAS,CAAC,+BAA+B,EACzC,OAAO,GAAG,aAAa,GAAG,YAAY,CACvC,CAAC;CACH,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Integrations/anthropic/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type { AgentLLMIntegrationParam } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal Adapter: Maps Arvo's generic Agent Message format to Anthropic's specific API format.
|
|
5
|
+
*
|
|
6
|
+
* Handles:
|
|
7
|
+
* - Mapping Tool Results to their originating Tool Call IDs.
|
|
8
|
+
* - Multimodal Content (converting Arvo media objects to Anthropic Image source format).
|
|
9
|
+
* - Reconstructs the specific message ordering Anthropic expects (User -> Assistant(ToolUse) -> User(ToolResult)).
|
|
10
|
+
*
|
|
11
|
+
* Note: Anthropic does not use a system message in the messages array - it's passed separately.
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatMessagesForAnthropic: (messages: AgentLLMIntegrationParam["messages"]) => Anthropic.MessageParam[];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/Integrations/anthropic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,wBAAwB,CAAC,UAAU,CAAC,KAC7C,SAAS,CAAC,YAAY,EA0FxB,CAAC"}
|