@anvia/core 0.2.3 → 0.3.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/LICENSE +21 -0
- package/dist/agent/index.d.ts +6 -6
- package/dist/agent/index.js +5 -4
- package/dist/{agent-ufaeGoaz.d.ts → agent-D_jXqPAZ.d.ts} +6 -4
- package/dist/{chunk-4F7RVGFR.js → chunk-65QV627O.js} +44 -13
- package/dist/chunk-65QV627O.js.map +1 -0
- package/dist/{chunk-BKDDAOQH.js → chunk-6JCCM2K4.js} +2 -2
- package/dist/{chunk-T6GLJU5W.js → chunk-GSFQZYS7.js} +86 -17
- package/dist/chunk-GSFQZYS7.js.map +1 -0
- package/dist/chunk-I2HOMD3R.js +240 -0
- package/dist/chunk-I2HOMD3R.js.map +1 -0
- package/dist/{chunk-QKYU4L4V.js → chunk-QRZ2HPUX.js} +3 -3
- package/dist/{chunk-2VCWYCPV.js → chunk-TILE6Z2N.js} +2 -2
- package/dist/{chunk-OD6TY44B.js → chunk-ZSYIQYTV.js} +1 -1
- package/dist/chunk-ZSYIQYTV.js.map +1 -0
- package/dist/evals/index.d.ts +3 -3
- package/dist/evals/index.js +6 -8
- package/dist/extractor/index.d.ts +3 -3
- package/dist/extractor/index.js +5 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +35 -31
- package/dist/mcp/index.d.ts +3 -3
- package/dist/{middleware-CKsY_zZE.d.ts → middleware-2FR89muX.d.ts} +5 -3
- package/dist/observability/index.d.ts +3 -2
- package/dist/observability/index.js +1 -1
- package/dist/pipeline/index.d.ts +3 -3
- package/dist/skills/index.d.ts +3 -3
- package/dist/skills/index.js +3 -5
- package/dist/tool/index.d.ts +10 -8
- package/dist/tool/index.js +17 -12
- package/dist/{tool-FEHplpd9.d.ts → tool-ClZYES-Z.d.ts} +9 -2
- package/dist/{types-CW3K1MJm.d.ts → types-B0iXLkqi.d.ts} +1 -1
- package/dist/{types-DpFoVF_g.d.ts → types-fLi8uM5R.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +1 -1
- package/dist/vector-store/index.js +1 -2
- package/package.json +15 -7
- package/dist/chunk-3H7FVGHU.js +0 -113
- package/dist/chunk-3H7FVGHU.js.map +0 -1
- package/dist/chunk-445TT5Q5.js +0 -37
- package/dist/chunk-445TT5Q5.js.map +0 -1
- package/dist/chunk-4F7RVGFR.js.map +0 -1
- package/dist/chunk-OD6TY44B.js.map +0 -1
- package/dist/chunk-T6GLJU5W.js.map +0 -1
- package/dist/chunk-V5EETE3U.js +0 -106
- package/dist/chunk-V5EETE3U.js.map +0 -1
- /package/dist/{chunk-BKDDAOQH.js.map → chunk-6JCCM2K4.js.map} +0 -0
- /package/dist/{chunk-QKYU4L4V.js.map → chunk-QRZ2HPUX.js.map} +0 -0
- /package/dist/{chunk-2VCWYCPV.js.map → chunk-TILE6Z2N.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { U as Usage, M as Message, b as CompletionModel, j as JsonValue, o as ToolChoice } from '../types-BM8-Y8Hy.js';
|
|
2
|
-
import { A as Agent } from '../agent-
|
|
3
|
-
import { Z as ZodSchema } from '../middleware-
|
|
2
|
+
import { A as Agent } from '../agent-D_jXqPAZ.js';
|
|
3
|
+
import { Z as ZodSchema } from '../middleware-2FR89muX.js';
|
|
4
4
|
import '../memory/index.js';
|
|
5
5
|
import '../observability/index.js';
|
|
6
|
-
import '../tool-
|
|
6
|
+
import '../tool-ClZYES-Z.js';
|
|
7
7
|
import '../vector-store/index.js';
|
|
8
8
|
import '../embeddings/index.js';
|
|
9
9
|
import 'zod';
|
package/dist/extractor/index.js
CHANGED
|
@@ -2,14 +2,12 @@ import {
|
|
|
2
2
|
ExtractionError,
|
|
3
3
|
Extractor,
|
|
4
4
|
ExtractorBuilder
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-4F7RVGFR.js";
|
|
8
|
-
import "../chunk-T6GLJU5W.js";
|
|
9
|
-
import "../chunk-YK4WAAS4.js";
|
|
10
|
-
import "../chunk-3H7FVGHU.js";
|
|
11
|
-
import "../chunk-445TT5Q5.js";
|
|
5
|
+
} from "../chunk-QRZ2HPUX.js";
|
|
6
|
+
import "../chunk-GSFQZYS7.js";
|
|
12
7
|
import "../chunk-XXT2UCAR.js";
|
|
8
|
+
import "../chunk-YK4WAAS4.js";
|
|
9
|
+
import "../chunk-I2HOMD3R.js";
|
|
10
|
+
import "../chunk-65QV627O.js";
|
|
13
11
|
import "../chunk-XUUY2L2D.js";
|
|
14
12
|
import "../chunk-6GJDBBDC.js";
|
|
15
13
|
import "../chunk-A7VDIZQN.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MemoryAppendInput, MemoryContext, MemoryErrorInput, MemoryOptions, MemoryRegistration, MemorySavePolicy, MemoryStore, ResolvedMemoryOptions, SessionOptions, resolveMemoryOptions } from './memory/index.js';
|
|
2
|
-
export { A as Agent, a as AgentChildStreamEvent, b as AgentEventAppendInput, c as AgentEventRecord, d as AgentEventStore, e as AgentEventStoreInclude, f as AgentEventStoreOptions, g as AgentEventStoreRegistration, h as AgentOptions, i as AgentSession, j as AgentStreamEvent, k as AgentToolOptions, C as CompletionCallHookArgs, l as CompletionResponseHookArgs, D as DEFAULT_MAX_TURNS, m as DynamicContextOptions, n as DynamicContextRegistration, o as DynamicToolOptions, p as DynamicToolRegistration, H as HookAction, q as HookResult, P as PromptHook, r as PromptRequest, s as PromptResponse, R as RunControl, T as ToolApprovalRequestOptions, t as ToolCallControl, u as ToolCallHookAction, v as ToolCallHookArgs, w as ToolCallHookResult, x as ToolHookArgs, y as ToolResultHookArgs, z as cancelPrompt, B as createHook, E as requestToolApproval, F as runControl, G as skipTool, I as toolCallControl } from './agent-
|
|
2
|
+
export { A as Agent, a as AgentChildStreamEvent, b as AgentEventAppendInput, c as AgentEventRecord, d as AgentEventStore, e as AgentEventStoreInclude, f as AgentEventStoreOptions, g as AgentEventStoreRegistration, h as AgentOptions, i as AgentSession, j as AgentStreamEvent, k as AgentToolOptions, C as CompletionCallHookArgs, l as CompletionResponseHookArgs, D as DEFAULT_MAX_TURNS, m as DynamicContextOptions, n as DynamicContextRegistration, o as DynamicToolOptions, p as DynamicToolRegistration, H as HookAction, q as HookResult, P as PromptHook, r as PromptRequest, s as PromptResponse, R as RunControl, T as ToolApprovalRequestOptions, t as ToolCallControl, u as ToolCallHookAction, v as ToolCallHookArgs, w as ToolCallHookResult, x as ToolHookArgs, y as ToolResultHookArgs, z as cancelPrompt, B as createHook, E as requestToolApproval, F as runControl, G as skipTool, I as toolCallControl } from './agent-D_jXqPAZ.js';
|
|
3
3
|
export { AgentBuilder, MaxTurnsError, PromptCancelledError } from './agent/index.js';
|
|
4
4
|
export { AudioGenerationModel, AudioGenerationRequest, AudioGenerationRequestBuilder, AudioGenerationResponse, audioGenerationRequest } from './audio-generation/index.js';
|
|
5
5
|
export { CompletionRequestBuilder, formatDocument, normalizeDocuments } from './completion/index.js';
|
|
@@ -9,16 +9,16 @@ export { AgentEvalTargetOptions, ContainsOptions, EvalCase, EvalCaseResult, Eval
|
|
|
9
9
|
export { ExtractionError, ExtractionResponse, Extractor, ExtractorBuilder } from './extractor/index.js';
|
|
10
10
|
export { GeneratedImage, ImageGenerationModel, ImageGenerationRequest, ImageGenerationRequestBuilder, ImageGenerationResponse, imageGenerationRequest } from './image-generation/index.js';
|
|
11
11
|
export { connectMcp, mcp } from './mcp/index.js';
|
|
12
|
-
export { M as McpClient, a as McpConnection, b as McpHttpOptions, c as McpServer, d as McpSseOptions, e as McpStdioOptions, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from './types-
|
|
12
|
+
export { M as McpClient, a as McpConnection, b as McpHttpOptions, c as McpServer, d as McpSseOptions, e as McpStdioOptions, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from './types-fLi8uM5R.js';
|
|
13
13
|
export { ListedModel, ModelList, ModelListingClient, ModelListingError } from './model-listing/index.js';
|
|
14
14
|
export { AgentGenerationEndArgs, AgentGenerationErrorArgs, AgentGenerationObserver, AgentGenerationStartArgs, AgentObserver, AgentObserverRegistration, AgentRunEndArgs, AgentRunErrorArgs, AgentRunObserver, AgentRunStartArgs, AgentToolEndArgs, AgentToolErrorArgs, AgentToolObserver, AgentToolStartArgs, AgentToolStreamEventArgs, AgentTraceInfo, AgentTraceOptions, ObserveOptions, createObserver } from './observability/index.js';
|
|
15
15
|
export { Pipeline, PipelineBatchOptions, PipelineBuilder, PipelineGraph, PipelineGraphEdge, PipelineGraphNode, PipelineMetadata, PipelineOp, PipelineRunEvent, PipelineRunObserver, PipelineRunOptions, PipelineStageKind, PipelineStageMetadata } from './pipeline/index.js';
|
|
16
|
-
export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, Z as ZodSchema, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from './middleware-
|
|
16
|
+
export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, Z as ZodSchema, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from './middleware-2FR89muX.js';
|
|
17
17
|
export { loadSkills, skill } from './skills/index.js';
|
|
18
|
-
export { S as Skill, a as SkillLoader, b as SkillSet, c as SkillValidationError, d as SkillValidationIssue } from './types-
|
|
18
|
+
export { S as Skill, a as SkillLoader, b as SkillSet, c as SkillValidationError, d as SkillValidationIssue } from './types-B0iXLkqi.js';
|
|
19
19
|
export { ReadableStreamOptions, toReadableStream } from './streaming/index.js';
|
|
20
20
|
export { CreateThinkToolOptions, CreateToolOptions, ToolCallError, ToolJsonError, ToolNotFoundError, createThinkTool, createTool } from './tool/index.js';
|
|
21
|
-
export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, c as ToolApprovalRunContext, d as ToolCallContext, e as ToolCallStreamEvent, p as parseToolArgs, s as serializeToolOutput } from './tool-
|
|
21
|
+
export { A as AnyTool, N as NormalizedToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, c as ToolApprovalRunContext, d as ToolCallContext, e as ToolCallStreamEvent, f as ToolOutput, i as isToolResultContentArray, n as normalizeToolResultOutput, p as parseToolArgs, s as serializeToolOutput, t as toolResultContentToText } from './tool-ClZYES-Z.js';
|
|
22
22
|
export { TranscriptionModel, TranscriptionRequest, TranscriptionRequestBuilder, TranscriptionResponse, transcriptionRequest } from './transcription/index.js';
|
|
23
23
|
export { InMemoryVectorIndex, InMemoryVectorStore, IndexStrategy, VectorFilter, VectorInspectItem, VectorInspectPage, VectorInspectRequest, VectorSearchIndex, VectorSearchRequest, VectorSearchResult, VectorSearchToolOptions, createVectorSearchTool, vectorFilter } from './vector-store/index.js';
|
|
24
24
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-2VCWYCPV.js";
|
|
2
|
+
TranscriptionRequestBuilder,
|
|
3
|
+
transcriptionRequest
|
|
4
|
+
} from "./chunk-7QI6ZAFI.js";
|
|
6
5
|
import {
|
|
7
6
|
connectMcp,
|
|
8
7
|
mcp
|
|
@@ -12,15 +11,16 @@ import {
|
|
|
12
11
|
} from "./chunk-WJT22R3T.js";
|
|
13
12
|
import {
|
|
14
13
|
createObserver
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZSYIQYTV.js";
|
|
16
15
|
import {
|
|
17
16
|
Pipeline,
|
|
18
17
|
PipelineBuilder
|
|
19
18
|
} from "./chunk-RTOGIJH2.js";
|
|
20
19
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
SkillValidationError,
|
|
21
|
+
loadSkills,
|
|
22
|
+
skill
|
|
23
|
+
} from "./chunk-TILE6Z2N.js";
|
|
24
24
|
import {
|
|
25
25
|
AudioGenerationRequestBuilder,
|
|
26
26
|
audioGenerationRequest
|
|
@@ -34,25 +34,12 @@ import {
|
|
|
34
34
|
llmScore,
|
|
35
35
|
runEvalSuite,
|
|
36
36
|
semanticSimilarity
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-6JCCM2K4.js";
|
|
38
38
|
import {
|
|
39
39
|
ExtractionError,
|
|
40
40
|
Extractor,
|
|
41
41
|
ExtractorBuilder
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import {
|
|
44
|
-
createThinkTool,
|
|
45
|
-
createToolIndex,
|
|
46
|
-
createToolMiddleware,
|
|
47
|
-
embedTools,
|
|
48
|
-
isDynamicToolIndex
|
|
49
|
-
} from "./chunk-V5EETE3U.js";
|
|
50
|
-
import {
|
|
51
|
-
InMemoryVectorIndex,
|
|
52
|
-
InMemoryVectorStore,
|
|
53
|
-
createVectorSearchTool,
|
|
54
|
-
vectorFilter
|
|
55
|
-
} from "./chunk-4F7RVGFR.js";
|
|
42
|
+
} from "./chunk-QRZ2HPUX.js";
|
|
56
43
|
import {
|
|
57
44
|
Agent,
|
|
58
45
|
AgentBuilder,
|
|
@@ -67,22 +54,35 @@ import {
|
|
|
67
54
|
runControl,
|
|
68
55
|
skipTool,
|
|
69
56
|
toolCallControl
|
|
70
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-GSFQZYS7.js";
|
|
58
|
+
import {
|
|
59
|
+
resolveMemoryOptions
|
|
60
|
+
} from "./chunk-XXT2UCAR.js";
|
|
71
61
|
import "./chunk-YK4WAAS4.js";
|
|
72
62
|
import {
|
|
73
63
|
ToolCallError,
|
|
74
64
|
ToolJsonError,
|
|
75
65
|
ToolNotFoundError,
|
|
66
|
+
ToolOutput,
|
|
76
67
|
ToolSet,
|
|
68
|
+
createThinkTool,
|
|
69
|
+
createToolIndex,
|
|
70
|
+
createToolMiddleware,
|
|
71
|
+
embedTools,
|
|
72
|
+
isDynamicToolIndex,
|
|
73
|
+
isToolResultContentArray,
|
|
74
|
+
normalizeToolResultOutput,
|
|
77
75
|
parseToolArgs,
|
|
78
|
-
serializeToolOutput
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
createTool
|
|
82
|
-
} from "./chunk-445TT5Q5.js";
|
|
76
|
+
serializeToolOutput,
|
|
77
|
+
toolResultContentToText
|
|
78
|
+
} from "./chunk-I2HOMD3R.js";
|
|
83
79
|
import {
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
InMemoryVectorIndex,
|
|
81
|
+
InMemoryVectorStore,
|
|
82
|
+
createTool,
|
|
83
|
+
createVectorSearchTool,
|
|
84
|
+
vectorFilter
|
|
85
|
+
} from "./chunk-65QV627O.js";
|
|
86
86
|
import {
|
|
87
87
|
toReadableStream
|
|
88
88
|
} from "./chunk-XUUY2L2D.js";
|
|
@@ -143,6 +143,7 @@ export {
|
|
|
143
143
|
ToolContent,
|
|
144
144
|
ToolJsonError,
|
|
145
145
|
ToolNotFoundError,
|
|
146
|
+
ToolOutput,
|
|
146
147
|
ToolSet,
|
|
147
148
|
TranscriptionRequestBuilder,
|
|
148
149
|
Usage,
|
|
@@ -173,12 +174,14 @@ export {
|
|
|
173
174
|
formatDocument,
|
|
174
175
|
imageGenerationRequest,
|
|
175
176
|
isDynamicToolIndex,
|
|
177
|
+
isToolResultContentArray,
|
|
176
178
|
llmJudge,
|
|
177
179
|
llmScore,
|
|
178
180
|
loadSkills,
|
|
179
181
|
manhattanDistance,
|
|
180
182
|
mcp,
|
|
181
183
|
normalizeDocuments,
|
|
184
|
+
normalizeToolResultOutput,
|
|
182
185
|
parseToolArgs,
|
|
183
186
|
reasoningDisplayText,
|
|
184
187
|
requestToolApproval,
|
|
@@ -192,6 +195,7 @@ export {
|
|
|
192
195
|
textFromAssistantContent,
|
|
193
196
|
toReadableStream,
|
|
194
197
|
toolCallControl,
|
|
198
|
+
toolResultContentToText,
|
|
195
199
|
transcriptionRequest,
|
|
196
200
|
vectorFilter
|
|
197
201
|
};
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as McpConnection, c as McpServer, e as McpStdioOptions, b as McpHttpOptions, d as McpSseOptions } from '../types-
|
|
2
|
-
export { M as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-
|
|
1
|
+
import { a as McpConnection, c as McpServer, e as McpStdioOptions, b as McpHttpOptions, d as McpSseOptions } from '../types-fLi8uM5R.js';
|
|
2
|
+
export { M as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-fLi8uM5R.js';
|
|
3
3
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
4
4
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
6
6
|
import '../types-BM8-Y8Hy.js';
|
|
7
|
-
import '../tool-
|
|
7
|
+
import '../tool-ClZYES-Z.js';
|
|
8
8
|
|
|
9
9
|
declare function connectMcp(connection: McpConnection): Promise<McpServer>;
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { q as ToolDefinition } from './types-BM8-Y8Hy.js';
|
|
2
|
+
import { q as ToolDefinition, u as ToolResultContent } from './types-BM8-Y8Hy.js';
|
|
3
3
|
import { VectorMetadata, EmbeddingModel, EmbeddedDocument } from './embeddings/index.js';
|
|
4
4
|
import { VectorSearchIndex } from './vector-store/index.js';
|
|
5
|
-
import { A as AnyTool, d as ToolCallContext } from './tool-
|
|
5
|
+
import { A as AnyTool, d as ToolCallContext, N as NormalizedToolOutput } from './tool-ClZYES-Z.js';
|
|
6
6
|
|
|
7
7
|
type ZodSchema<T = unknown> = z.ZodType<T>;
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ declare class ToolSet {
|
|
|
16
16
|
get(toolName: string): AnyTool | undefined;
|
|
17
17
|
values(): AnyTool[];
|
|
18
18
|
getToolDefinitions(prompt?: string): Promise<ToolDefinition[]>;
|
|
19
|
-
call(toolName: string, args: string, context?: ToolCallContext): Promise<
|
|
19
|
+
call(toolName: string, args: string, context?: ToolCallContext): Promise<NormalizedToolOutput>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
type ToolSearchDocument<Metadata extends VectorMetadata = VectorMetadata> = {
|
|
@@ -42,6 +42,8 @@ type ToolResultMiddlewareArgs = {
|
|
|
42
42
|
args: string;
|
|
43
43
|
result: string;
|
|
44
44
|
originalResult: string;
|
|
45
|
+
structuredResult?: ToolResultContent[] | undefined;
|
|
46
|
+
originalStructuredResult?: ToolResultContent[] | undefined;
|
|
45
47
|
turn: number;
|
|
46
48
|
toolCallId?: string | undefined;
|
|
47
49
|
internalCallId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Message, d as CompletionRequest, J as JsonObject, c as CompletionModelCapabilities, e as CompletionResponse, n as ToolCall, q as ToolDefinition, U as Usage } from '../types-BM8-Y8Hy.js';
|
|
2
|
-
import { e as ToolCallStreamEvent } from '../tool-
|
|
1
|
+
import { M as Message, d as CompletionRequest, J as JsonObject, c as CompletionModelCapabilities, e as CompletionResponse, n as ToolCall, q as ToolDefinition, u as ToolResultContent, U as Usage } from '../types-BM8-Y8Hy.js';
|
|
2
|
+
import { e as ToolCallStreamEvent } from '../tool-ClZYES-Z.js';
|
|
3
3
|
|
|
4
4
|
type AgentTraceInfo = {
|
|
5
5
|
traceId?: string | undefined;
|
|
@@ -65,6 +65,7 @@ type AgentToolStartArgs = {
|
|
|
65
65
|
};
|
|
66
66
|
type AgentToolEndArgs = AgentToolStartArgs & {
|
|
67
67
|
result: string;
|
|
68
|
+
structuredResult?: ToolResultContent[] | undefined;
|
|
68
69
|
skipped: boolean;
|
|
69
70
|
};
|
|
70
71
|
type AgentToolErrorArgs = AgentToolStartArgs & {
|
package/dist/pipeline/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { J as JsonObject, b as CompletionModel } from '../types-BM8-Y8Hy.js';
|
|
2
|
-
import { A as Agent } from '../agent-
|
|
2
|
+
import { A as Agent } from '../agent-D_jXqPAZ.js';
|
|
3
3
|
import { Extractor } from '../extractor/index.js';
|
|
4
4
|
import '../memory/index.js';
|
|
5
5
|
import '../observability/index.js';
|
|
6
|
-
import '../tool-
|
|
7
|
-
import '../middleware-
|
|
6
|
+
import '../tool-ClZYES-Z.js';
|
|
7
|
+
import '../middleware-2FR89muX.js';
|
|
8
8
|
import 'zod';
|
|
9
9
|
import '../embeddings/index.js';
|
|
10
10
|
import '../vector-store/index.js';
|
package/dist/skills/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as SkillLoader, b as SkillSet } from '../types-
|
|
2
|
-
export { S as Skill, c as SkillValidationError, d as SkillValidationIssue } from '../types-
|
|
3
|
-
import '../tool-
|
|
1
|
+
import { a as SkillLoader, b as SkillSet } from '../types-B0iXLkqi.js';
|
|
2
|
+
export { S as Skill, c as SkillValidationError, d as SkillValidationIssue } from '../types-B0iXLkqi.js';
|
|
3
|
+
import '../tool-ClZYES-Z.js';
|
|
4
4
|
import '../types-BM8-Y8Hy.js';
|
|
5
5
|
|
|
6
6
|
declare function loadSkills(loaders: SkillLoader | SkillLoader[]): Promise<SkillSet>;
|
package/dist/skills/index.js
CHANGED
|
@@ -2,12 +2,10 @@ import {
|
|
|
2
2
|
SkillValidationError,
|
|
3
3
|
loadSkills,
|
|
4
4
|
skill
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-V5EETE3U.js";
|
|
7
|
-
import "../chunk-4F7RVGFR.js";
|
|
5
|
+
} from "../chunk-TILE6Z2N.js";
|
|
8
6
|
import "../chunk-YK4WAAS4.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-I2HOMD3R.js";
|
|
8
|
+
import "../chunk-65QV627O.js";
|
|
11
9
|
import "../chunk-A7VDIZQN.js";
|
|
12
10
|
export {
|
|
13
11
|
SkillValidationError,
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Z as ZodSchema } from '../middleware-
|
|
3
|
-
export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from '../middleware-
|
|
4
|
-
import { b as ToolApprovalPolicy, d as ToolCallContext, T as Tool } from '../tool-
|
|
5
|
-
export { A as AnyTool, a as ToolApprovalContext, c as ToolApprovalRunContext, e as ToolCallStreamEvent, p as parseToolArgs, s as serializeToolOutput } from '../tool-
|
|
2
|
+
import { Z as ZodSchema } from '../middleware-2FR89muX.js';
|
|
3
|
+
export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from '../middleware-2FR89muX.js';
|
|
4
|
+
import { b as ToolApprovalPolicy, d as ToolCallContext, T as Tool } from '../tool-ClZYES-Z.js';
|
|
5
|
+
export { A as AnyTool, N as NormalizedToolOutput, a as ToolApprovalContext, c as ToolApprovalRunContext, e as ToolCallStreamEvent, f as ToolOutput, i as isToolResultContentArray, n as normalizeToolResultOutput, p as parseToolArgs, s as serializeToolOutput, t as toolResultContentToText } from '../tool-ClZYES-Z.js';
|
|
6
6
|
import '../types-BM8-Y8Hy.js';
|
|
7
7
|
import '../embeddings/index.js';
|
|
8
8
|
import '../vector-store/index.js';
|
|
9
9
|
|
|
10
|
-
type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined> = {
|
|
10
|
+
type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined, Output = unknown> = {
|
|
11
11
|
name: string;
|
|
12
12
|
description: string;
|
|
13
13
|
input: InputSchema;
|
|
14
14
|
output?: OutputSchema;
|
|
15
15
|
approval?: ToolApprovalPolicy<z.output<InputSchema>>;
|
|
16
|
-
execute(args: z.output<InputSchema>, context: ToolCallContext): OutputSchema extends ZodSchema ? z.input<OutputSchema> | Promise<z.input<OutputSchema>> :
|
|
16
|
+
execute(args: z.output<InputSchema>, context: ToolCallContext): OutputSchema extends ZodSchema ? z.input<OutputSchema> | Promise<z.input<OutputSchema>> : Output | Promise<Output>;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
declare function createTool<InputSchema extends ZodSchema, Output = unknown>(options: CreateToolOptions<InputSchema, undefined, Output> & {
|
|
19
|
+
output?: undefined;
|
|
20
|
+
}): Tool<z.output<InputSchema>, Output>;
|
|
21
|
+
declare function createTool<InputSchema extends ZodSchema, OutputSchema extends ZodSchema>(options: CreateToolOptions<InputSchema, OutputSchema>): Tool<z.output<InputSchema>, z.output<OutputSchema>>;
|
|
20
22
|
|
|
21
23
|
declare class ToolCallError extends Error {
|
|
22
24
|
readonly cause?: unknown | undefined;
|
package/dist/tool/index.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createThinkTool,
|
|
3
|
-
createToolIndex,
|
|
4
|
-
createToolMiddleware,
|
|
5
|
-
embedTools,
|
|
6
|
-
isDynamicToolIndex
|
|
7
|
-
} from "../chunk-V5EETE3U.js";
|
|
8
|
-
import "../chunk-4F7RVGFR.js";
|
|
9
1
|
import {
|
|
10
2
|
ToolCallError,
|
|
11
3
|
ToolJsonError,
|
|
12
4
|
ToolNotFoundError,
|
|
5
|
+
ToolOutput,
|
|
13
6
|
ToolSet,
|
|
7
|
+
createThinkTool,
|
|
8
|
+
createToolIndex,
|
|
9
|
+
createToolMiddleware,
|
|
10
|
+
embedTools,
|
|
11
|
+
isDynamicToolIndex,
|
|
12
|
+
isToolResultContentArray,
|
|
13
|
+
normalizeToolResultOutput,
|
|
14
14
|
parseToolArgs,
|
|
15
|
-
serializeToolOutput
|
|
16
|
-
|
|
15
|
+
serializeToolOutput,
|
|
16
|
+
toolResultContentToText
|
|
17
|
+
} from "../chunk-I2HOMD3R.js";
|
|
17
18
|
import {
|
|
18
19
|
createTool
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-65QV627O.js";
|
|
20
21
|
import "../chunk-A7VDIZQN.js";
|
|
21
22
|
export {
|
|
22
23
|
ToolCallError,
|
|
23
24
|
ToolJsonError,
|
|
24
25
|
ToolNotFoundError,
|
|
26
|
+
ToolOutput,
|
|
25
27
|
ToolSet,
|
|
26
28
|
createThinkTool,
|
|
27
29
|
createTool,
|
|
@@ -29,7 +31,10 @@ export {
|
|
|
29
31
|
createToolMiddleware,
|
|
30
32
|
embedTools,
|
|
31
33
|
isDynamicToolIndex,
|
|
34
|
+
isToolResultContentArray,
|
|
35
|
+
normalizeToolResultOutput,
|
|
32
36
|
parseToolArgs,
|
|
33
|
-
serializeToolOutput
|
|
37
|
+
serializeToolOutput,
|
|
38
|
+
toolResultContentToText
|
|
34
39
|
};
|
|
35
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonObject, q as ToolDefinition, j as JsonValue } from './types-BM8-Y8Hy.js';
|
|
1
|
+
import { J as JsonObject, q as ToolDefinition, u as ToolResultContent, j as JsonValue } from './types-BM8-Y8Hy.js';
|
|
2
2
|
|
|
3
3
|
type ToolApprovalRunContext = {
|
|
4
4
|
agentId: string;
|
|
@@ -37,7 +37,14 @@ interface Tool<Args = unknown, Output = unknown> {
|
|
|
37
37
|
type AnyTool = Omit<Tool<unknown, unknown>, "approval"> & {
|
|
38
38
|
readonly approval?: unknown;
|
|
39
39
|
};
|
|
40
|
+
type NormalizedToolOutput = string | ToolResultContent[];
|
|
41
|
+
declare const ToolOutput: {
|
|
42
|
+
content(content: ToolResultContent[]): ToolResultContent[];
|
|
43
|
+
};
|
|
40
44
|
declare function serializeToolOutput(output: unknown): string;
|
|
45
|
+
declare function isToolResultContentArray(value: unknown): value is ToolResultContent[];
|
|
46
|
+
declare function normalizeToolResultOutput(output: unknown): NormalizedToolOutput;
|
|
47
|
+
declare function toolResultContentToText(content: ToolResultContent[]): string;
|
|
41
48
|
declare function parseToolArgs(args: string): JsonValue;
|
|
42
49
|
|
|
43
|
-
export { type AnyTool as A, type Tool as T, type ToolApprovalContext as a, type ToolApprovalPolicy as b, type ToolApprovalRunContext as c, type ToolCallContext as d, type ToolCallStreamEvent as e, parseToolArgs as p, serializeToolOutput as s };
|
|
50
|
+
export { type AnyTool as A, type NormalizedToolOutput as N, type Tool as T, type ToolApprovalContext as a, type ToolApprovalPolicy as b, type ToolApprovalRunContext as c, type ToolCallContext as d, type ToolCallStreamEvent as e, ToolOutput as f, isToolResultContentArray as i, normalizeToolResultOutput as n, parseToolArgs as p, serializeToolOutput as s, toolResultContentToText as t };
|
|
@@ -2,7 +2,7 @@ import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.
|
|
|
2
2
|
import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
3
|
import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
4
|
import { J as JsonObject } from './types-BM8-Y8Hy.js';
|
|
5
|
-
import { A as AnyTool } from './tool-
|
|
5
|
+
import { A as AnyTool } from './tool-ClZYES-Z.js';
|
|
6
6
|
|
|
7
7
|
type McpToolDefinition = {
|
|
8
8
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VectorMetadataValue, VectorMetadata, EmbeddingModel, EmbeddedDocument, Embedding } from '../embeddings/index.js';
|
|
2
|
-
import { T as Tool } from '../tool-
|
|
2
|
+
import { T as Tool } from '../tool-ClZYES-Z.js';
|
|
3
3
|
import '../types-BM8-Y8Hy.js';
|
|
4
4
|
|
|
5
5
|
type VectorFilter = {
|
package/package.json
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvia/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Core runtime primitives for context-aware Anvia agents.",
|
|
5
5
|
"author": "anvia",
|
|
6
6
|
"maintainer": "Indra Zulfi",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/anvia-hq/anvia",
|
|
11
|
+
"directory": "packages/core"
|
|
12
|
+
},
|
|
8
13
|
"files": [
|
|
9
14
|
"dist"
|
|
10
15
|
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
11
19
|
"type": "module",
|
|
12
20
|
"main": "./dist/index.js",
|
|
13
21
|
"types": "./dist/index.d.ts",
|
|
@@ -89,11 +97,6 @@
|
|
|
89
97
|
"import": "./dist/vector-store/index.js"
|
|
90
98
|
}
|
|
91
99
|
},
|
|
92
|
-
"scripts": {
|
|
93
|
-
"build": "tsup src/index.ts src/agent/index.ts src/audio-generation/index.ts src/completion/index.ts src/embeddings/index.ts src/evals/index.ts src/image-generation/index.ts src/loaders/index.ts src/extractor/index.ts src/mcp/index.ts src/memory/index.ts src/model-listing/index.ts src/observability/index.ts src/pipeline/index.ts src/skills/index.ts src/streaming/index.ts src/tool/index.ts src/transcription/index.ts src/vector-store/index.ts --format esm --dts --sourcemap --clean",
|
|
94
|
-
"test": "vitest run",
|
|
95
|
-
"typecheck": "tsc --noEmit"
|
|
96
|
-
},
|
|
97
100
|
"dependencies": {
|
|
98
101
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
99
102
|
"pdfjs-dist": "^5.7.284",
|
|
@@ -106,5 +109,10 @@
|
|
|
106
109
|
"tsup": "^8.5.0",
|
|
107
110
|
"typescript": "^5.9.3",
|
|
108
111
|
"vitest": "^4.0.8"
|
|
112
|
+
},
|
|
113
|
+
"scripts": {
|
|
114
|
+
"build": "tsup src/index.ts src/agent/index.ts src/audio-generation/index.ts src/completion/index.ts src/embeddings/index.ts src/evals/index.ts src/image-generation/index.ts src/loaders/index.ts src/extractor/index.ts src/mcp/index.ts src/memory/index.ts src/model-listing/index.ts src/observability/index.ts src/pipeline/index.ts src/skills/index.ts src/streaming/index.ts src/tool/index.ts src/transcription/index.ts src/vector-store/index.ts --format esm --dts --sourcemap --clean",
|
|
115
|
+
"test": "vitest run",
|
|
116
|
+
"typecheck": "tsc --noEmit"
|
|
109
117
|
}
|
|
110
|
-
}
|
|
118
|
+
}
|
package/dist/chunk-3H7FVGHU.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// src/tool/errors.ts
|
|
2
|
-
var ToolCallError = class extends Error {
|
|
3
|
-
constructor(message, cause) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.cause = cause;
|
|
6
|
-
this.name = "ToolCallError";
|
|
7
|
-
}
|
|
8
|
-
cause;
|
|
9
|
-
};
|
|
10
|
-
var ToolNotFoundError = class extends Error {
|
|
11
|
-
constructor(toolName) {
|
|
12
|
-
super(`Tool not found: ${toolName}`);
|
|
13
|
-
this.toolName = toolName;
|
|
14
|
-
this.name = "ToolNotFoundError";
|
|
15
|
-
}
|
|
16
|
-
toolName;
|
|
17
|
-
};
|
|
18
|
-
var ToolJsonError = class extends Error {
|
|
19
|
-
constructor(message, cause) {
|
|
20
|
-
super(message);
|
|
21
|
-
this.cause = cause;
|
|
22
|
-
this.name = "ToolJsonError";
|
|
23
|
-
}
|
|
24
|
-
cause;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// src/tool/tool.ts
|
|
28
|
-
function serializeToolOutput(output) {
|
|
29
|
-
if (typeof output === "string") {
|
|
30
|
-
return output;
|
|
31
|
-
}
|
|
32
|
-
const serialized = JSON.stringify(output);
|
|
33
|
-
return serialized === void 0 ? String(output) : serialized;
|
|
34
|
-
}
|
|
35
|
-
function parseToolArgs(args) {
|
|
36
|
-
if (args.trim() === "") {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
return JSON.parse(args);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/tool/tool-set.ts
|
|
43
|
-
var ToolSet = class _ToolSet {
|
|
44
|
-
tools = /* @__PURE__ */ new Map();
|
|
45
|
-
static fromTools(tools) {
|
|
46
|
-
const toolSet = new _ToolSet();
|
|
47
|
-
for (const tool of tools) {
|
|
48
|
-
toolSet.addTool(tool);
|
|
49
|
-
}
|
|
50
|
-
return toolSet;
|
|
51
|
-
}
|
|
52
|
-
addTool(tool) {
|
|
53
|
-
this.tools.set(tool.name, tool);
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
addTools(tools) {
|
|
57
|
-
const values = Array.isArray(tools) ? tools : tools.values();
|
|
58
|
-
for (const tool of values) {
|
|
59
|
-
this.addTool(tool);
|
|
60
|
-
}
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
deleteTool(toolName) {
|
|
64
|
-
return this.tools.delete(toolName);
|
|
65
|
-
}
|
|
66
|
-
contains(toolName) {
|
|
67
|
-
return this.tools.has(toolName);
|
|
68
|
-
}
|
|
69
|
-
get(toolName) {
|
|
70
|
-
return this.tools.get(toolName);
|
|
71
|
-
}
|
|
72
|
-
values() {
|
|
73
|
-
return [...this.tools.values()];
|
|
74
|
-
}
|
|
75
|
-
async getToolDefinitions(prompt = "") {
|
|
76
|
-
const defs = [];
|
|
77
|
-
for (const tool of this.tools.values()) {
|
|
78
|
-
defs.push(await tool.definition(prompt));
|
|
79
|
-
}
|
|
80
|
-
return defs;
|
|
81
|
-
}
|
|
82
|
-
async call(toolName, args, context) {
|
|
83
|
-
const tool = this.tools.get(toolName);
|
|
84
|
-
if (tool === void 0) {
|
|
85
|
-
throw new ToolNotFoundError(toolName);
|
|
86
|
-
}
|
|
87
|
-
let parsedArgs;
|
|
88
|
-
try {
|
|
89
|
-
parsedArgs = parseToolArgs(args);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
throw new ToolJsonError(`Invalid JSON arguments for tool ${toolName}`, error);
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const output = await tool.call(parsedArgs, context);
|
|
95
|
-
return serializeToolOutput(output);
|
|
96
|
-
} catch (error) {
|
|
97
|
-
if (error instanceof Error) {
|
|
98
|
-
throw new ToolCallError(error.message, error);
|
|
99
|
-
}
|
|
100
|
-
throw new ToolCallError(`Tool ${toolName} failed`, error);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export {
|
|
106
|
-
ToolCallError,
|
|
107
|
-
ToolNotFoundError,
|
|
108
|
-
ToolJsonError,
|
|
109
|
-
serializeToolOutput,
|
|
110
|
-
parseToolArgs,
|
|
111
|
-
ToolSet
|
|
112
|
-
};
|
|
113
|
-
//# sourceMappingURL=chunk-3H7FVGHU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tool/errors.ts","../src/tool/tool.ts","../src/tool/tool-set.ts"],"sourcesContent":["export class ToolCallError extends Error {\n constructor(\n message: string,\n readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"ToolCallError\";\n }\n}\n\nexport class ToolNotFoundError extends Error {\n constructor(readonly toolName: string) {\n super(`Tool not found: ${toolName}`);\n this.name = \"ToolNotFoundError\";\n }\n}\n\nexport class ToolJsonError extends Error {\n constructor(\n message: string,\n readonly cause?: unknown,\n ) {\n super(message);\n this.name = \"ToolJsonError\";\n }\n}\n","import type { JsonObject, JsonValue, ToolDefinition } from \"../completion/types\";\n\nexport type ToolApprovalRunContext = {\n agentId: string;\n runId: string;\n sessionId?: string;\n metadata?: JsonObject;\n};\n\nexport type ToolApprovalContext<Args = unknown> = {\n toolName: string;\n args: Args;\n rawArgs: string;\n toolCallId?: string;\n internalCallId: string;\n run: ToolApprovalRunContext;\n};\n\nexport type ToolApprovalPolicy<Args = unknown> = {\n when(ctx: ToolApprovalContext<Args>): boolean | Promise<boolean>;\n reason?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);\n rejectMessage?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);\n};\n\nexport type ToolCallStreamEvent = {\n agentId: string;\n agentName?: string | undefined;\n event: unknown;\n};\n\nexport type ToolCallContext = {\n emitStreamEvent?(event: ToolCallStreamEvent): void | Promise<void>;\n};\n\nexport interface Tool<Args = unknown, Output = unknown> {\n readonly name: string;\n readonly approval?: ToolApprovalPolicy<Args>;\n definition(prompt: string): ToolDefinition | Promise<ToolDefinition>;\n call(args: Args, context?: ToolCallContext): Output | Promise<Output>;\n parseApprovalArgs?(args: unknown): Args;\n}\n\nexport type AnyTool = Omit<Tool<unknown, unknown>, \"approval\"> & {\n readonly approval?: unknown;\n};\n\nexport function serializeToolOutput(output: unknown): string {\n if (typeof output === \"string\") {\n return output;\n }\n\n const serialized = JSON.stringify(output);\n return serialized === undefined ? String(output) : serialized;\n}\n\nexport function parseToolArgs(args: string): JsonValue {\n if (args.trim() === \"\") {\n return {};\n }\n\n return JSON.parse(args) as JsonValue;\n}\n","import type { ToolDefinition } from \"../completion/types\";\nimport { ToolCallError, ToolJsonError, ToolNotFoundError } from \"./errors\";\nimport { type AnyTool, parseToolArgs, serializeToolOutput, type ToolCallContext } from \"./tool\";\n\nexport class ToolSet {\n private readonly tools = new Map<string, AnyTool>();\n\n static fromTools(tools: AnyTool[]): ToolSet {\n const toolSet = new ToolSet();\n for (const tool of tools) {\n toolSet.addTool(tool);\n }\n return toolSet;\n }\n\n addTool(tool: AnyTool): this {\n this.tools.set(tool.name, tool);\n return this;\n }\n\n addTools(tools: AnyTool[] | ToolSet): this {\n const values = Array.isArray(tools) ? tools : tools.values();\n for (const tool of values) {\n this.addTool(tool);\n }\n return this;\n }\n\n deleteTool(toolName: string): boolean {\n return this.tools.delete(toolName);\n }\n\n contains(toolName: string): boolean {\n return this.tools.has(toolName);\n }\n\n get(toolName: string): AnyTool | undefined {\n return this.tools.get(toolName);\n }\n\n values(): AnyTool[] {\n return [...this.tools.values()];\n }\n\n async getToolDefinitions(prompt = \"\"): Promise<ToolDefinition[]> {\n const defs: ToolDefinition[] = [];\n for (const tool of this.tools.values()) {\n defs.push(await tool.definition(prompt));\n }\n return defs;\n }\n\n async call(toolName: string, args: string, context?: ToolCallContext): Promise<string> {\n const tool = this.tools.get(toolName);\n if (tool === undefined) {\n throw new ToolNotFoundError(toolName);\n }\n\n let parsedArgs: unknown;\n try {\n parsedArgs = parseToolArgs(args);\n } catch (error) {\n throw new ToolJsonError(`Invalid JSON arguments for tool ${toolName}`, error);\n }\n\n try {\n const output = await tool.call(parsedArgs, context);\n return serializeToolOutput(output);\n } catch (error) {\n if (error instanceof Error) {\n throw new ToolCallError(error.message, error);\n }\n throw new ToolCallError(`Tool ${toolName} failed`, error);\n }\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,OACT;AACA,UAAM,OAAO;AAFJ;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EAJW;AAKb;AAEO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAAqB,UAAkB;AACrC,UAAM,mBAAmB,QAAQ,EAAE;AADhB;AAEnB,SAAK,OAAO;AAAA,EACd;AAAA,EAHqB;AAIvB;AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,OACT;AACA,UAAM,OAAO;AAFJ;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EAJW;AAKb;;;ACqBO,SAAS,oBAAoB,QAAyB;AAC3D,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,UAAU,MAAM;AACxC,SAAO,eAAe,SAAY,OAAO,MAAM,IAAI;AACrD;AAEO,SAAS,cAAc,MAAyB;AACrD,MAAI,KAAK,KAAK,MAAM,IAAI;AACtB,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,KAAK,MAAM,IAAI;AACxB;;;ACzDO,IAAM,UAAN,MAAM,SAAQ;AAAA,EACF,QAAQ,oBAAI,IAAqB;AAAA,EAElD,OAAO,UAAU,OAA2B;AAC1C,UAAM,UAAU,IAAI,SAAQ;AAC5B,eAAW,QAAQ,OAAO;AACxB,cAAQ,QAAQ,IAAI;AAAA,IACtB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAqB;AAC3B,SAAK,MAAM,IAAI,KAAK,MAAM,IAAI;AAC9B,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,OAAkC;AACzC,UAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,MAAM,OAAO;AAC3D,eAAW,QAAQ,QAAQ;AACzB,WAAK,QAAQ,IAAI;AAAA,IACnB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,UAA2B;AACpC,WAAO,KAAK,MAAM,OAAO,QAAQ;AAAA,EACnC;AAAA,EAEA,SAAS,UAA2B;AAClC,WAAO,KAAK,MAAM,IAAI,QAAQ;AAAA,EAChC;AAAA,EAEA,IAAI,UAAuC;AACzC,WAAO,KAAK,MAAM,IAAI,QAAQ;AAAA,EAChC;AAAA,EAEA,SAAoB;AAClB,WAAO,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC;AAAA,EAChC;AAAA,EAEA,MAAM,mBAAmB,SAAS,IAA+B;AAC/D,UAAM,OAAyB,CAAC;AAChC,eAAW,QAAQ,KAAK,MAAM,OAAO,GAAG;AACtC,WAAK,KAAK,MAAM,KAAK,WAAW,MAAM,CAAC;AAAA,IACzC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,UAAkB,MAAc,SAA4C;AACrF,UAAM,OAAO,KAAK,MAAM,IAAI,QAAQ;AACpC,QAAI,SAAS,QAAW;AACtB,YAAM,IAAI,kBAAkB,QAAQ;AAAA,IACtC;AAEA,QAAI;AACJ,QAAI;AACF,mBAAa,cAAc,IAAI;AAAA,IACjC,SAAS,OAAO;AACd,YAAM,IAAI,cAAc,mCAAmC,QAAQ,IAAI,KAAK;AAAA,IAC9E;AAEA,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,KAAK,YAAY,OAAO;AAClD,aAAO,oBAAoB,MAAM;AAAA,IACnC,SAAS,OAAO;AACd,UAAI,iBAAiB,OAAO;AAC1B,cAAM,IAAI,cAAc,MAAM,SAAS,KAAK;AAAA,MAC9C;AACA,YAAM,IAAI,cAAc,QAAQ,QAAQ,WAAW,KAAK;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|