@anvia/core 0.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.
Files changed (93) hide show
  1. package/README.md +101 -0
  2. package/dist/agent/index.d.ts +70 -0
  3. package/dist/agent/index.js +31 -0
  4. package/dist/agent/index.js.map +1 -0
  5. package/dist/agent-C6h6YrRU.d.ts +218 -0
  6. package/dist/audio-generation/index.d.ts +32 -0
  7. package/dist/audio-generation/index.js +9 -0
  8. package/dist/audio-generation/index.js.map +1 -0
  9. package/dist/chunk-7QI6ZAFI.js +61 -0
  10. package/dist/chunk-7QI6ZAFI.js.map +1 -0
  11. package/dist/chunk-A7VDIZQN.js +145 -0
  12. package/dist/chunk-A7VDIZQN.js.map +1 -0
  13. package/dist/chunk-B24Q2ZYM.js +43 -0
  14. package/dist/chunk-B24Q2ZYM.js.map +1 -0
  15. package/dist/chunk-B4QHQN5K.js +37 -0
  16. package/dist/chunk-B4QHQN5K.js.map +1 -0
  17. package/dist/chunk-CP47FBJV.js +324 -0
  18. package/dist/chunk-CP47FBJV.js.map +1 -0
  19. package/dist/chunk-FI2BTRT5.js +86 -0
  20. package/dist/chunk-FI2BTRT5.js.map +1 -0
  21. package/dist/chunk-GNWMOSNR.js +113 -0
  22. package/dist/chunk-GNWMOSNR.js.map +1 -0
  23. package/dist/chunk-I77SDTFE.js +43 -0
  24. package/dist/chunk-I77SDTFE.js.map +1 -0
  25. package/dist/chunk-IA76K5UX.js +142 -0
  26. package/dist/chunk-IA76K5UX.js.map +1 -0
  27. package/dist/chunk-IQBY2GCF.js +1207 -0
  28. package/dist/chunk-IQBY2GCF.js.map +1 -0
  29. package/dist/chunk-KSIY7KJA.js +387 -0
  30. package/dist/chunk-KSIY7KJA.js.map +1 -0
  31. package/dist/chunk-LMBOJMNB.js +304 -0
  32. package/dist/chunk-LMBOJMNB.js.map +1 -0
  33. package/dist/chunk-S55WOHX5.js +9 -0
  34. package/dist/chunk-S55WOHX5.js.map +1 -0
  35. package/dist/chunk-SRGJPXKT.js +256 -0
  36. package/dist/chunk-SRGJPXKT.js.map +1 -0
  37. package/dist/chunk-WZTPK5HV.js +125 -0
  38. package/dist/chunk-WZTPK5HV.js.map +1 -0
  39. package/dist/chunk-X6FBOU2P.js +96 -0
  40. package/dist/chunk-X6FBOU2P.js.map +1 -0
  41. package/dist/chunk-XUUY2L2D.js +42 -0
  42. package/dist/chunk-XUUY2L2D.js.map +1 -0
  43. package/dist/completion/index.d.ts +36 -0
  44. package/dist/completion/index.js +29 -0
  45. package/dist/completion/index.js.map +1 -0
  46. package/dist/embeddings/index.d.ts +34 -0
  47. package/dist/embeddings/index.js +23 -0
  48. package/dist/embeddings/index.js.map +1 -0
  49. package/dist/evals/index.d.ts +153 -0
  50. package/dist/evals/index.js +30 -0
  51. package/dist/evals/index.js.map +1 -0
  52. package/dist/extractor/index.d.ts +45 -0
  53. package/dist/extractor/index.js +19 -0
  54. package/dist/extractor/index.js.map +1 -0
  55. package/dist/image-generation/index.d.ts +37 -0
  56. package/dist/image-generation/index.js +9 -0
  57. package/dist/image-generation/index.js.map +1 -0
  58. package/dist/index.d.ts +24 -0
  59. package/dist/index.js +183 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/loaders/index.d.ts +82 -0
  62. package/dist/loaders/index.js +287 -0
  63. package/dist/loaders/index.js.map +1 -0
  64. package/dist/mcp/index.d.ts +15 -0
  65. package/dist/mcp/index.js +9 -0
  66. package/dist/mcp/index.js.map +1 -0
  67. package/dist/observability/index.d.ts +93 -0
  68. package/dist/observability/index.js +7 -0
  69. package/dist/observability/index.js.map +1 -0
  70. package/dist/pipeline/index.d.ts +51 -0
  71. package/dist/pipeline/index.js +9 -0
  72. package/dist/pipeline/index.js.map +1 -0
  73. package/dist/skills/index.d.ts +12 -0
  74. package/dist/skills/index.js +16 -0
  75. package/dist/skills/index.js.map +1 -0
  76. package/dist/streaming/index.d.ts +6 -0
  77. package/dist/streaming/index.js +7 -0
  78. package/dist/streaming/index.js.map +1 -0
  79. package/dist/tool/index.d.ts +42 -0
  80. package/dist/tool/index.js +33 -0
  81. package/dist/tool/index.js.map +1 -0
  82. package/dist/tool-DhuBQ3yb.d.ts +35 -0
  83. package/dist/transcription/index.d.ts +35 -0
  84. package/dist/transcription/index.js +9 -0
  85. package/dist/transcription/index.js.map +1 -0
  86. package/dist/types-B5B8Sdl4.d.ts +64 -0
  87. package/dist/types-BrxLd7ay.d.ts +250 -0
  88. package/dist/types-HvopERm0.d.ts +30 -0
  89. package/dist/vector-store/index.d.ts +111 -0
  90. package/dist/vector-store/index.js +15 -0
  91. package/dist/vector-store/index.js.map +1 -0
  92. package/dist/zod-schema-DJTEgQBq.d.ts +40 -0
  93. package/package.json +102 -0
@@ -0,0 +1,35 @@
1
+ import { J as JsonObject, q as ToolDefinition, j as JsonValue } from './types-BrxLd7ay.js';
2
+
3
+ type ToolApprovalRunContext = {
4
+ agentId: string;
5
+ runId: string;
6
+ sessionId?: string;
7
+ metadata?: JsonObject;
8
+ };
9
+ type ToolApprovalContext<Args = unknown> = {
10
+ toolName: string;
11
+ args: Args;
12
+ rawArgs: string;
13
+ toolCallId?: string;
14
+ internalCallId: string;
15
+ run: ToolApprovalRunContext;
16
+ };
17
+ type ToolApprovalPolicy<Args = unknown> = {
18
+ when(ctx: ToolApprovalContext<Args>): boolean | Promise<boolean>;
19
+ reason?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);
20
+ rejectMessage?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);
21
+ };
22
+ interface Tool<Args = unknown, Output = unknown> {
23
+ readonly name: string;
24
+ readonly approval?: ToolApprovalPolicy<Args>;
25
+ definition(prompt: string): ToolDefinition | Promise<ToolDefinition>;
26
+ call(args: Args): Output | Promise<Output>;
27
+ parseApprovalArgs?(args: unknown): Args;
28
+ }
29
+ type AnyTool = Omit<Tool<unknown, unknown>, "approval"> & {
30
+ readonly approval?: unknown;
31
+ };
32
+ declare function serializeToolOutput(output: unknown): string;
33
+ declare function parseToolArgs(args: string): JsonValue;
34
+
35
+ export { type AnyTool as A, type Tool as T, type ToolApprovalContext as a, type ToolApprovalPolicy as b, type ToolApprovalRunContext as c, parseToolArgs as p, serializeToolOutput as s };
@@ -0,0 +1,35 @@
1
+ import { j as JsonValue } from '../types-BrxLd7ay.js';
2
+
3
+ type TranscriptionRequest = {
4
+ data: Uint8Array;
5
+ filename: string;
6
+ language?: string | undefined;
7
+ prompt?: string | undefined;
8
+ temperature?: number | undefined;
9
+ additionalParams?: JsonValue | undefined;
10
+ };
11
+ type TranscriptionResponse<RawResponse = unknown> = {
12
+ text: string;
13
+ rawResponse: RawResponse;
14
+ };
15
+ interface TranscriptionModel<RawResponse = unknown> {
16
+ readonly provider?: string | undefined;
17
+ readonly defaultModel?: string | undefined;
18
+ transcription(request: TranscriptionRequest): Promise<TranscriptionResponse<RawResponse>>;
19
+ }
20
+ declare class TranscriptionRequestBuilder<Model extends TranscriptionModel = TranscriptionModel> {
21
+ private readonly model;
22
+ private request;
23
+ constructor(model: Model);
24
+ data(data: Uint8Array | ArrayBuffer): this;
25
+ filename(filename: string): this;
26
+ language(language: string): this;
27
+ prompt(prompt: string): this;
28
+ temperature(temperature: number): this;
29
+ additionalParams(additionalParams: JsonValue): this;
30
+ build(): TranscriptionRequest;
31
+ send(): Promise<Awaited<ReturnType<Model["transcription"]>>>;
32
+ }
33
+ declare function transcriptionRequest<Model extends TranscriptionModel>(model: Model): TranscriptionRequestBuilder<Model>;
34
+
35
+ export { type TranscriptionModel, type TranscriptionRequest, TranscriptionRequestBuilder, type TranscriptionResponse, transcriptionRequest };
@@ -0,0 +1,9 @@
1
+ import {
2
+ TranscriptionRequestBuilder,
3
+ transcriptionRequest
4
+ } from "../chunk-7QI6ZAFI.js";
5
+ export {
6
+ TranscriptionRequestBuilder,
7
+ transcriptionRequest
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,64 @@
1
+ import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
2
+ import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
3
+ import { J as JsonObject } from './types-BrxLd7ay.js';
4
+ import { A as AnyTool } from './tool-DhuBQ3yb.js';
5
+
6
+ type McpToolDefinition = {
7
+ name: string;
8
+ description?: string | undefined;
9
+ inputSchema: JsonObject;
10
+ };
11
+ type McpToolCallContent = {
12
+ type: "text";
13
+ text: string;
14
+ } | {
15
+ type: "image";
16
+ data: string;
17
+ mimeType: string;
18
+ } | {
19
+ type: "resource";
20
+ resource: {
21
+ uri: string;
22
+ text: string;
23
+ mimeType?: string | undefined;
24
+ } | {
25
+ uri: string;
26
+ blob: string;
27
+ mimeType?: string | undefined;
28
+ };
29
+ };
30
+ type McpToolCallResult = {
31
+ content: McpToolCallContent[];
32
+ isError?: boolean | undefined;
33
+ } | {
34
+ toolResult: unknown;
35
+ };
36
+ type McpClient = {
37
+ listTools(): Promise<{
38
+ tools: McpToolDefinition[];
39
+ }>;
40
+ callTool(params: {
41
+ name: string;
42
+ arguments?: Record<string, unknown>;
43
+ }): Promise<McpToolCallResult>;
44
+ close(): Promise<void>;
45
+ };
46
+ type McpConnection = {
47
+ readonly name: string;
48
+ connect(): Promise<McpClient>;
49
+ };
50
+ type McpServer = {
51
+ readonly name: string;
52
+ readonly tools: AnyTool[];
53
+ close(): Promise<void>;
54
+ };
55
+ type McpStdioOptions = StdioServerParameters & {
56
+ name: string;
57
+ };
58
+ type McpHttpOptions = {
59
+ name: string;
60
+ url: string | URL;
61
+ transport?: StreamableHTTPClientTransportOptions | undefined;
62
+ };
63
+
64
+ export type { McpClient as M, McpConnection as a, McpHttpOptions as b, McpServer as c, McpStdioOptions as d, McpToolCallContent as e, McpToolCallResult as f, McpToolDefinition as g };
@@ -0,0 +1,250 @@
1
+ type JsonPrimitive = string | number | boolean | null;
2
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
+ type JsonObject = {
4
+ [key: string]: JsonValue | undefined;
5
+ };
6
+ type Document = {
7
+ id: string;
8
+ text: string;
9
+ additionalProps?: Record<string, string>;
10
+ };
11
+ type Text = {
12
+ type: "text";
13
+ text: string;
14
+ signature?: string;
15
+ };
16
+ type ImageDetail = "auto" | "low" | "high";
17
+ type ImageContent = {
18
+ type: "image";
19
+ source: {
20
+ type: "url";
21
+ url: string;
22
+ } | {
23
+ type: "base64";
24
+ data: string;
25
+ mediaType: string;
26
+ };
27
+ detail?: ImageDetail;
28
+ };
29
+ type DocumentContent = {
30
+ type: "document";
31
+ source: {
32
+ type: "url";
33
+ url: string;
34
+ mediaType: string;
35
+ filename?: string;
36
+ } | {
37
+ type: "base64";
38
+ data: string;
39
+ mediaType: string;
40
+ filename?: string;
41
+ } | {
42
+ type: "text";
43
+ text: string;
44
+ mediaType?: string;
45
+ filename?: string;
46
+ };
47
+ };
48
+ type Reasoning = {
49
+ type: "reasoning";
50
+ text: string;
51
+ id?: string;
52
+ content?: ReasoningContent[];
53
+ };
54
+ type ReasoningContent = {
55
+ type: "text";
56
+ text: string;
57
+ signature?: string;
58
+ } | {
59
+ type: "summary";
60
+ text: string;
61
+ } | {
62
+ type: "encrypted";
63
+ data: string;
64
+ } | {
65
+ type: "redacted";
66
+ data: string;
67
+ };
68
+ type ReasoningContentType = ReasoningContent["type"];
69
+ type ToolFunction = {
70
+ name: string;
71
+ arguments: JsonValue;
72
+ };
73
+ type ToolCall = {
74
+ type: "tool_call";
75
+ id: string;
76
+ callId?: string;
77
+ function: ToolFunction;
78
+ signature?: string;
79
+ additionalParams?: JsonValue;
80
+ };
81
+ type ToolResultContent = {
82
+ type: "text";
83
+ text: string;
84
+ } | {
85
+ type: "image";
86
+ data: string;
87
+ mediaType?: string;
88
+ };
89
+ type ToolResult = {
90
+ type: "tool_result";
91
+ id: string;
92
+ callId?: string;
93
+ content: ToolResultContent[];
94
+ };
95
+ type SystemMessage = {
96
+ role: "system";
97
+ content: string;
98
+ };
99
+ type UserMessage = {
100
+ role: "user";
101
+ content: UserContent[];
102
+ };
103
+ type AssistantMessage = {
104
+ role: "assistant";
105
+ id?: string;
106
+ content: AssistantContent[];
107
+ };
108
+ type ToolMessage = {
109
+ role: "tool";
110
+ content: ToolContent[];
111
+ };
112
+ type UserContent = Text | ImageContent | DocumentContent;
113
+ declare const UserContent: {
114
+ text(text: string): Text;
115
+ imageUrl(url: string, options?: {
116
+ detail?: ImageDetail;
117
+ }): ImageContent;
118
+ imageBase64(data: string, mediaType: string, options?: {
119
+ detail?: ImageDetail;
120
+ }): ImageContent;
121
+ documentUrl(url: string, mediaType: string, options?: {
122
+ filename?: string | undefined;
123
+ }): DocumentContent;
124
+ documentBase64(data: string, mediaType: string, options?: {
125
+ filename?: string | undefined;
126
+ }): DocumentContent;
127
+ documentText(text: string): Text;
128
+ };
129
+ type ToolContent = ToolResult;
130
+ declare const ToolContent: {
131
+ toolResult(id: string, content: string | ToolResultContent[], callId?: string): ToolResult;
132
+ };
133
+ type AssistantContent = Text | ToolCall | Reasoning | ImageContent;
134
+ declare const AssistantContent: {
135
+ text(text: string): Text;
136
+ imageUrl(url: string, options?: {
137
+ detail?: ImageDetail;
138
+ }): ImageContent;
139
+ imageBase64(data: string, mediaType: string, options?: {
140
+ detail?: ImageDetail;
141
+ }): ImageContent;
142
+ reasoning(text: string, id?: string): Reasoning;
143
+ reasoningFromContent(content: ReasoningContent[], id?: string): Reasoning;
144
+ reasoningSummary(text: string, id?: string): Reasoning;
145
+ reasoningEncrypted(data: string, id?: string): Reasoning;
146
+ reasoningRedacted(data: string, id?: string): Reasoning;
147
+ toolCall(id: string, name: string, args: JsonValue, callId?: string): ToolCall;
148
+ };
149
+ declare function reasoningDisplayText(reasoning: Reasoning | ReasoningContent[]): string;
150
+ type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
151
+ declare const Message: {
152
+ system(content: string): Message;
153
+ user(content: string | UserContent[]): Message;
154
+ assistant(content: string | AssistantContent[], id?: string): Message;
155
+ tool(content: ToolContent | ToolContent[]): Message;
156
+ };
157
+ type ToolChoice = "auto" | "required" | "none" | {
158
+ type: "function";
159
+ name: string;
160
+ };
161
+ type ToolDefinition = {
162
+ name: string;
163
+ description: string;
164
+ parameters: JsonObject;
165
+ };
166
+ type Usage = {
167
+ inputTokens: number;
168
+ outputTokens: number;
169
+ totalTokens: number;
170
+ cachedInputTokens: number;
171
+ cacheCreationInputTokens: number;
172
+ };
173
+ declare const Usage: {
174
+ empty(): Usage;
175
+ add(left: Usage, right: Usage): Usage;
176
+ };
177
+ type CompletionRequest = {
178
+ model?: string;
179
+ instructions?: string;
180
+ chatHistory: Message[];
181
+ documents: Document[];
182
+ tools: ToolDefinition[];
183
+ temperature?: number;
184
+ maxTokens?: number;
185
+ toolChoice?: ToolChoice;
186
+ additionalParams?: JsonValue;
187
+ outputSchema?: JsonObject;
188
+ };
189
+ type CompletionResponse<RawResponse = unknown> = {
190
+ choice: AssistantContent[];
191
+ usage: Usage;
192
+ rawResponse: RawResponse;
193
+ messageId?: string;
194
+ };
195
+ type CompletionModelCapabilities = {
196
+ streaming: boolean;
197
+ tools: boolean;
198
+ toolChoice: boolean;
199
+ imageInput: boolean;
200
+ documentInput: boolean;
201
+ outputSchema: boolean;
202
+ reasoning: boolean;
203
+ };
204
+ interface CompletionModel<RawResponse = unknown> {
205
+ readonly provider: string;
206
+ readonly defaultModel: string;
207
+ readonly capabilities: CompletionModelCapabilities;
208
+ completion(request: CompletionRequest): Promise<CompletionResponse<RawResponse>>;
209
+ }
210
+ type CompletionStreamEvent<RawResponse = unknown> = {
211
+ type: "text_delta";
212
+ delta: string;
213
+ } | {
214
+ type: "reasoning_delta";
215
+ delta: string;
216
+ id?: string;
217
+ contentType?: ReasoningContentType;
218
+ signature?: string;
219
+ } | {
220
+ type: "tool_call_delta";
221
+ id: string;
222
+ callId?: string;
223
+ name?: string;
224
+ argumentsDelta?: string;
225
+ signature?: string;
226
+ } | {
227
+ type: "tool_call";
228
+ toolCall: ToolCall;
229
+ } | {
230
+ type: "message_id";
231
+ id: string;
232
+ } | {
233
+ type: "final";
234
+ response: CompletionResponse<RawResponse>;
235
+ } | {
236
+ type: "error";
237
+ error: unknown;
238
+ };
239
+ interface StreamingCompletionModel<RawResponse = unknown> extends CompletionModel<RawResponse> {
240
+ streamCompletion(request: CompletionRequest): AsyncIterable<CompletionStreamEvent<RawResponse>>;
241
+ }
242
+ declare class CompletionCapabilityError extends Error {
243
+ constructor(message: string);
244
+ }
245
+ declare function assertCompletionRequestSupported(model: CompletionModel, request: CompletionRequest, options?: {
246
+ streaming?: boolean | undefined;
247
+ }): void;
248
+ declare function textFromAssistantContent(content: AssistantContent[]): string;
249
+
250
+ export { AssistantContent as A, CompletionCapabilityError as C, type Document as D, type ImageContent as I, type JsonObject as J, Message as M, type Reasoning as R, type StreamingCompletionModel as S, type Text as T, Usage as U, type AssistantMessage as a, type CompletionModel as b, type CompletionModelCapabilities as c, type CompletionRequest as d, type CompletionResponse as e, type CompletionStreamEvent as f, type DocumentContent as g, type ImageDetail as h, type JsonPrimitive as i, type JsonValue as j, type ReasoningContent as k, type ReasoningContentType as l, type SystemMessage as m, type ToolCall as n, type ToolChoice as o, ToolContent as p, type ToolDefinition as q, type ToolFunction as r, type ToolMessage as s, type ToolResult as t, type ToolResultContent as u, UserContent as v, type UserMessage as w, assertCompletionRequestSupported as x, reasoningDisplayText as y, textFromAssistantContent as z };
@@ -0,0 +1,30 @@
1
+ import { A as AnyTool } from './tool-DhuBQ3yb.js';
2
+
3
+ type Skill = {
4
+ readonly name: string;
5
+ readonly description: string;
6
+ readonly instructions: string;
7
+ readonly directory: string;
8
+ readonly references: string[];
9
+ readonly scripts: string[];
10
+ readonly license?: string | undefined;
11
+ readonly metadata?: Record<string, unknown> | undefined;
12
+ };
13
+ type SkillLoader = {
14
+ load(): Promise<Skill[]>;
15
+ };
16
+ type SkillSet = {
17
+ readonly skills: Skill[];
18
+ readonly tools: AnyTool[];
19
+ readonly instructions: string;
20
+ };
21
+ type SkillValidationIssue = {
22
+ path: string;
23
+ message: string;
24
+ };
25
+ declare class SkillValidationError extends Error {
26
+ readonly issues: SkillValidationIssue[];
27
+ constructor(message: string, issues: SkillValidationIssue[]);
28
+ }
29
+
30
+ export { type Skill as S, type SkillLoader as a, type SkillSet as b, SkillValidationError as c, type SkillValidationIssue as d };
@@ -0,0 +1,111 @@
1
+ import { VectorMetadataValue, VectorMetadata, EmbeddingModel, EmbeddedDocument, Embedding } from '../embeddings/index.js';
2
+ import { T as Tool } from '../tool-DhuBQ3yb.js';
3
+ import '../types-BrxLd7ay.js';
4
+
5
+ type VectorFilter = {
6
+ type: "eq";
7
+ key: string;
8
+ value: VectorMetadataValue;
9
+ } | {
10
+ type: "gt";
11
+ key: string;
12
+ value: VectorMetadataValue;
13
+ } | {
14
+ type: "lt";
15
+ key: string;
16
+ value: VectorMetadataValue;
17
+ } | {
18
+ type: "and";
19
+ filters: [VectorFilter, VectorFilter];
20
+ } | {
21
+ type: "or";
22
+ filters: [VectorFilter, VectorFilter];
23
+ };
24
+ declare const vectorFilter: {
25
+ eq(key: string, value: VectorMetadataValue): VectorFilter;
26
+ gt(key: string, value: VectorMetadataValue): VectorFilter;
27
+ lt(key: string, value: VectorMetadataValue): VectorFilter;
28
+ and(left: VectorFilter, right: VectorFilter): VectorFilter;
29
+ or(left: VectorFilter, right: VectorFilter): VectorFilter;
30
+ };
31
+
32
+ type LshOptions = {
33
+ type: "lsh";
34
+ numTables: number;
35
+ numHyperplanes: number;
36
+ seed?: number | undefined;
37
+ };
38
+
39
+ type IndexStrategy = {
40
+ type: "bruteForce";
41
+ } | LshOptions;
42
+ type VectorSearchRequest = {
43
+ query: string;
44
+ topK: number;
45
+ threshold?: number | undefined;
46
+ filter?: VectorFilter | undefined;
47
+ };
48
+ type VectorSearchResult<T = unknown, Metadata extends VectorMetadata = VectorMetadata> = {
49
+ score: number;
50
+ id: string;
51
+ document: T;
52
+ metadata?: Metadata | undefined;
53
+ };
54
+ interface VectorSearchIndex<T = unknown, Metadata extends VectorMetadata = VectorMetadata> {
55
+ search(request: VectorSearchRequest): Promise<Array<VectorSearchResult<T, Metadata>>>;
56
+ searchIds(request: VectorSearchRequest): Promise<Array<{
57
+ score: number;
58
+ id: string;
59
+ }>>;
60
+ asTool(options: VectorSearchToolOptions): Tool<{
61
+ query: string;
62
+ topK?: number;
63
+ }, unknown>;
64
+ }
65
+ type VectorSearchToolOptions = {
66
+ name: string;
67
+ description?: string | undefined;
68
+ topK?: number | undefined;
69
+ threshold?: number | undefined;
70
+ filter?: VectorFilter | undefined;
71
+ };
72
+ type StoredDocument<T, Metadata extends VectorMetadata> = EmbeddedDocument<T, Metadata>;
73
+ declare class InMemoryVectorStore<T, Metadata extends VectorMetadata = VectorMetadata> {
74
+ private readonly documents;
75
+ private indexStrategy;
76
+ private lshIndex;
77
+ constructor(options?: {
78
+ index?: IndexStrategy;
79
+ });
80
+ static fromDocuments<T, Metadata extends VectorMetadata = VectorMetadata>(documents: Array<EmbeddedDocument<T, Metadata>>, options?: {
81
+ index?: IndexStrategy;
82
+ }): InMemoryVectorStore<T, Metadata>;
83
+ addDocuments(documents: Array<EmbeddedDocument<T, Metadata>>): this;
84
+ get(id: string): StoredDocument<T, Metadata> | undefined;
85
+ values(): Array<StoredDocument<T, Metadata>>;
86
+ len(): number;
87
+ isEmpty(): boolean;
88
+ index(model: EmbeddingModel): InMemoryVectorIndex<T, Metadata>;
89
+ candidates(queryEmbedding: Embedding): Array<StoredDocument<T, Metadata>>;
90
+ private rebuildLshIndex;
91
+ }
92
+ declare class InMemoryVectorIndex<T, Metadata extends VectorMetadata = VectorMetadata> implements VectorSearchIndex<T, Metadata> {
93
+ private readonly model;
94
+ private readonly store;
95
+ constructor(model: EmbeddingModel, store: InMemoryVectorStore<T, Metadata>);
96
+ search(request: VectorSearchRequest): Promise<Array<VectorSearchResult<T, Metadata>>>;
97
+ searchIds(request: VectorSearchRequest): Promise<Array<{
98
+ score: number;
99
+ id: string;
100
+ }>>;
101
+ asTool(options: VectorSearchToolOptions): Tool<{
102
+ query: string;
103
+ topK?: number;
104
+ }, unknown>;
105
+ }
106
+ declare function createVectorSearchTool<T, Metadata extends VectorMetadata>(index: VectorSearchIndex<T, Metadata>, options: VectorSearchToolOptions): Tool<{
107
+ query: string;
108
+ topK?: number;
109
+ }, Array<VectorSearchResult<T, Metadata>>>;
110
+
111
+ export { InMemoryVectorIndex, InMemoryVectorStore, type IndexStrategy, type VectorFilter, type VectorSearchIndex, type VectorSearchRequest, type VectorSearchResult, type VectorSearchToolOptions, createVectorSearchTool, vectorFilter };
@@ -0,0 +1,15 @@
1
+ import {
2
+ InMemoryVectorIndex,
3
+ InMemoryVectorStore,
4
+ createVectorSearchTool,
5
+ vectorFilter
6
+ } from "../chunk-SRGJPXKT.js";
7
+ import "../chunk-B4QHQN5K.js";
8
+ import "../chunk-A7VDIZQN.js";
9
+ export {
10
+ InMemoryVectorIndex,
11
+ InMemoryVectorStore,
12
+ createVectorSearchTool,
13
+ vectorFilter
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,40 @@
1
+ import { q as ToolDefinition } from './types-BrxLd7ay.js';
2
+ import { VectorMetadata, EmbeddingModel, EmbeddedDocument } from './embeddings/index.js';
3
+ import { VectorSearchIndex } from './vector-store/index.js';
4
+ import { A as AnyTool } from './tool-DhuBQ3yb.js';
5
+ import { z } from 'zod';
6
+
7
+ declare class ToolSet {
8
+ private readonly tools;
9
+ static fromTools(tools: AnyTool[]): ToolSet;
10
+ addTool(tool: AnyTool): this;
11
+ addTools(tools: AnyTool[] | ToolSet): this;
12
+ deleteTool(toolName: string): boolean;
13
+ contains(toolName: string): boolean;
14
+ get(toolName: string): AnyTool | undefined;
15
+ values(): AnyTool[];
16
+ getToolDefinitions(prompt?: string): Promise<ToolDefinition[]>;
17
+ call(toolName: string, args: string): Promise<string>;
18
+ }
19
+
20
+ type ToolSearchDocument<Metadata extends VectorMetadata = VectorMetadata> = {
21
+ toolName: string;
22
+ definition: ToolDefinition;
23
+ text: string;
24
+ metadata?: Metadata | undefined;
25
+ };
26
+ type EmbedToolsOptions<Metadata extends VectorMetadata = VectorMetadata> = {
27
+ content?: ((tool: AnyTool, definition: ToolDefinition) => string | string[]) | undefined;
28
+ metadata?: ((tool: AnyTool, definition: ToolDefinition) => Metadata | undefined) | undefined;
29
+ concurrency?: number | undefined;
30
+ };
31
+ interface DynamicToolIndex<Metadata extends VectorMetadata = VectorMetadata> extends VectorSearchIndex<ToolSearchDocument<Metadata>, Metadata> {
32
+ readonly toolSet: ToolSet;
33
+ }
34
+ declare function embedTools<Metadata extends VectorMetadata = VectorMetadata>(model: EmbeddingModel, tools: AnyTool[] | ToolSet, options?: EmbedToolsOptions<Metadata>): Promise<Array<EmbeddedDocument<ToolSearchDocument<Metadata>, Metadata>>>;
35
+ declare function createToolIndex<Metadata extends VectorMetadata = VectorMetadata>(model: EmbeddingModel, tools: AnyTool[] | ToolSet, options?: EmbedToolsOptions<Metadata>): Promise<DynamicToolIndex<Metadata>>;
36
+ declare function isDynamicToolIndex(value: unknown): value is DynamicToolIndex;
37
+
38
+ type ZodSchema<T = unknown> = z.ZodType<T>;
39
+
40
+ export { type DynamicToolIndex as D, type EmbedToolsOptions as E, type ToolSearchDocument as T, type ZodSchema as Z, ToolSet as a, createToolIndex as c, embedTools as e, isDynamicToolIndex as i };