@anvia/core 0.4.2 → 0.6.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/README.md +68 -0
- package/dist/agent/index.d.ts +20 -11
- package/dist/agent/index.js +11 -5
- package/dist/{agent-B-ls5y_g.d.ts → agent-BURoB-me.d.ts} +81 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-MOICCK3J.js → chunk-6NWNL2KM.js} +19 -7
- package/dist/chunk-6NWNL2KM.js.map +1 -0
- package/dist/{chunk-6GJDBBDC.js → chunk-A4GUJSEK.js} +95 -1
- package/dist/chunk-A4GUJSEK.js.map +1 -0
- package/dist/{chunk-35GF7P43.js → chunk-AER5FGPK.js} +6 -2
- package/dist/{chunk-35GF7P43.js.map → chunk-AER5FGPK.js.map} +1 -1
- package/dist/{chunk-P425B6GR.js → chunk-I47EHI45.js} +13 -19
- package/dist/chunk-I47EHI45.js.map +1 -0
- package/dist/{chunk-N7NMSGZI.js → chunk-IXK3TEHJ.js} +247 -38
- package/dist/chunk-IXK3TEHJ.js.map +1 -0
- package/dist/{chunk-LGETU3RG.js → chunk-OXYZDHNI.js} +4 -4
- package/dist/{chunk-DUP7FMAF.js → chunk-SHHSMV7O.js} +2 -2
- package/dist/chunk-WQKHFADH.js +12 -0
- package/dist/chunk-WQKHFADH.js.map +1 -0
- package/dist/completion/index.d.ts +5 -2
- package/dist/completion/index.js +8 -1
- package/dist/create-completion-Bog3ni7b.d.ts +36 -0
- package/dist/evals/index.d.ts +5 -5
- package/dist/evals/index.js +7 -6
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +4 -4
- package/dist/extractor/index.js +7 -6
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +19 -8
- package/dist/internal/agent.d.ts +4 -4
- package/dist/internal/agent.js +5 -4
- package/dist/loaders/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/index.d.ts +1 -1
- package/dist/middleware-C9QIms85.d.ts +102 -0
- package/dist/observability/index.d.ts +2 -2
- package/dist/pipeline/index.d.ts +4 -4
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +4 -3
- package/dist/{think-tool-ByArsrxe.d.ts → think-tool-DLTCqqJ6.d.ts} +1 -1
- package/dist/tool/index.d.ts +4 -4
- package/dist/tool/index.js +5 -2
- package/dist/{tool-C3ciF-VG.d.ts → tool-Dz-lHZon.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-UhcgW8Fo.d.ts → types-BfHZz1ZG.d.ts} +2 -2
- package/dist/{types-T9rlOIUc.d.ts → types-DUivppau.d.ts} +1 -1
- package/dist/{types-C54aNoCd.d.ts → types-Dmoq-Fhz.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +2 -2
- package/dist/vector-store/index.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-6GJDBBDC.js.map +0 -1
- package/dist/chunk-MOICCK3J.js.map +0 -1
- package/dist/chunk-N7NMSGZI.js.map +0 -1
- package/dist/chunk-P425B6GR.js.map +0 -1
- package/dist/middleware-CGiEIaBx.d.ts +0 -53
- /package/dist/{chunk-LGETU3RG.js.map → chunk-OXYZDHNI.js.map} +0 -0
- /package/dist/{chunk-DUP7FMAF.js.map → chunk-SHHSMV7O.js.map} +0 -0
package/dist/extractor/index.js
CHANGED
|
@@ -2,15 +2,16 @@ import {
|
|
|
2
2
|
ExtractionError,
|
|
3
3
|
Extractor,
|
|
4
4
|
ExtractorBuilder
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-OXYZDHNI.js";
|
|
6
|
+
import "../chunk-6NWNL2KM.js";
|
|
7
|
+
import "../chunk-IXK3TEHJ.js";
|
|
8
8
|
import "../chunk-XUUY2L2D.js";
|
|
9
9
|
import "../chunk-XXT2UCAR.js";
|
|
10
10
|
import "../chunk-YK4WAAS4.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-AER5FGPK.js";
|
|
12
|
+
import "../chunk-I47EHI45.js";
|
|
13
|
+
import "../chunk-A4GUJSEK.js";
|
|
14
|
+
import "../chunk-WQKHFADH.js";
|
|
14
15
|
import "../chunk-EFGX3EX5.js";
|
|
15
16
|
import "../chunk-OIMLU4SF.js";
|
|
16
17
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export { AgentBuilder, MaxTurnsError, PromptCancelledError } from './agent/index.js';
|
|
2
|
-
export { A as AgentChildStreamEvent, a as AgentStreamEvent, P as PromptResponse, c as cancelPrompt, b as createHook, r as requestToolApproval, d as runControl, s as skipTool, t as toolCallControl } from './agent-
|
|
3
|
-
export {
|
|
2
|
+
export { A as AgentChildStreamEvent, a as AgentStreamEvent, P as PromptResponse, c as cancelPrompt, b as createHook, r as requestToolApproval, d as runControl, s as skipTool, t as toolCallControl } from './agent-BURoB-me.js';
|
|
3
|
+
export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion } from './create-completion-Bog3ni7b.js';
|
|
4
|
+
export { A as AssistantContent, a as AssistantMessage, C as CompletionModel, b as CompletionRequest, c as CompletionResponse, D as Document, I as ImageContent, J as JsonObject, d as JsonPrimitive, e as JsonValue, M as Message, S as SystemMessage, T as Text, f as ToolCall, g as ToolDefinition, h as ToolMessage, i as ToolResult, j as ToolResultContent, U as Usage, k as UserContent, l as UserMessage } from './types-Dmoq-Fhz.js';
|
|
4
5
|
export { MemoryStore } from './memory/index.js';
|
|
5
6
|
export { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
6
7
|
export { loadSkills, skill } from './skills/index.js';
|
|
7
|
-
export { S as SkillValidationError } from './types-
|
|
8
|
-
export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-
|
|
9
|
-
export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, c as ToolCallContext, d as ToolCallStreamEvent } from './tool-
|
|
10
|
-
|
|
8
|
+
export { S as SkillValidationError } from './types-DUivppau.js';
|
|
9
|
+
export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-DLTCqqJ6.js';
|
|
10
|
+
export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, c as ToolCallContext, d as ToolCallStreamEvent } from './tool-Dz-lHZon.js';
|
|
11
|
+
export { A as AgentMiddleware, C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, e as ToolMiddleware, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, i as createMiddleware, j as createToolMiddleware } from './middleware-C9QIms85.js';
|
|
12
|
+
import './types-BfHZz1ZG.js';
|
|
11
13
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
12
14
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
13
15
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
14
16
|
import './observability/index.js';
|
|
15
|
-
import './middleware-CGiEIaBx.js';
|
|
16
|
-
import './types-IB2e9u5M.js';
|
|
17
17
|
import './vector-store/index.js';
|
|
18
|
+
import './types-IB2e9u5M.js';
|
|
18
19
|
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
SkillValidationError,
|
|
3
3
|
loadSkills,
|
|
4
4
|
skill
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SHHSMV7O.js";
|
|
6
6
|
import {
|
|
7
7
|
AgentBuilder
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6NWNL2KM.js";
|
|
9
9
|
import {
|
|
10
10
|
MaxTurnsError,
|
|
11
11
|
PromptCancelledError,
|
|
@@ -15,22 +15,28 @@ import {
|
|
|
15
15
|
runControl,
|
|
16
16
|
skipTool,
|
|
17
17
|
toolCallControl
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IXK3TEHJ.js";
|
|
19
19
|
import "./chunk-XUUY2L2D.js";
|
|
20
20
|
import "./chunk-XXT2UCAR.js";
|
|
21
21
|
import "./chunk-YK4WAAS4.js";
|
|
22
22
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
createMiddleware,
|
|
24
|
+
createThinkTool,
|
|
25
|
+
createToolMiddleware
|
|
26
|
+
} from "./chunk-AER5FGPK.js";
|
|
25
27
|
import {
|
|
26
28
|
createTool
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-I47EHI45.js";
|
|
28
30
|
import {
|
|
29
31
|
AssistantContent,
|
|
30
32
|
Message,
|
|
31
33
|
Usage,
|
|
32
|
-
UserContent
|
|
33
|
-
|
|
34
|
+
UserContent,
|
|
35
|
+
createCompletion,
|
|
36
|
+
createCompletionStream,
|
|
37
|
+
createParsedCompletion
|
|
38
|
+
} from "./chunk-A4GUJSEK.js";
|
|
39
|
+
import "./chunk-WQKHFADH.js";
|
|
34
40
|
import "./chunk-EFGX3EX5.js";
|
|
35
41
|
import "./chunk-OIMLU4SF.js";
|
|
36
42
|
export {
|
|
@@ -43,9 +49,14 @@ export {
|
|
|
43
49
|
Usage,
|
|
44
50
|
UserContent,
|
|
45
51
|
cancelPrompt,
|
|
52
|
+
createCompletion,
|
|
53
|
+
createCompletionStream,
|
|
46
54
|
createHook,
|
|
55
|
+
createMiddleware,
|
|
56
|
+
createParsedCompletion,
|
|
47
57
|
createThinkTool,
|
|
48
58
|
createTool,
|
|
59
|
+
createToolMiddleware,
|
|
49
60
|
loadSkills,
|
|
50
61
|
requestToolApproval,
|
|
51
62
|
runControl,
|
package/dist/internal/agent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { e as Agent, j as AgentEventAppendInput, k as AgentEventRecord, h as AgentEventStore, l as AgentEventStoreInclude, i as AgentEventStoreOptions,
|
|
2
|
-
import '../types-
|
|
1
|
+
export { e as Agent, j as AgentEventAppendInput, k as AgentEventRecord, h as AgentEventStore, l as AgentEventStoreInclude, i as AgentEventStoreOptions, I as AgentEventStoreRegistration, J as AgentOptions, K as AgentSession, L as AgentToolOptions, M as DEFAULT_MAX_TURNS, D as DynamicContextOptions, N as DynamicContextRegistration, f as DynamicToolOptions, O as DynamicToolRegistration } from '../agent-BURoB-me.js';
|
|
2
|
+
import '../types-Dmoq-Fhz.js';
|
|
3
3
|
import '../memory/index.js';
|
|
4
4
|
import '../observability/index.js';
|
|
5
|
-
import '../tool-
|
|
6
|
-
import '../middleware-
|
|
5
|
+
import '../tool-Dz-lHZon.js';
|
|
6
|
+
import '../middleware-C9QIms85.js';
|
|
7
7
|
import '../types-IB2e9u5M.js';
|
|
8
8
|
import '../vector-store/index.js';
|
package/dist/internal/agent.js
CHANGED
|
@@ -2,12 +2,13 @@ import {
|
|
|
2
2
|
Agent,
|
|
3
3
|
AgentSession,
|
|
4
4
|
DEFAULT_MAX_TURNS
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-IXK3TEHJ.js";
|
|
6
6
|
import "../chunk-XUUY2L2D.js";
|
|
7
7
|
import "../chunk-YK4WAAS4.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-AER5FGPK.js";
|
|
9
|
+
import "../chunk-I47EHI45.js";
|
|
10
|
+
import "../chunk-A4GUJSEK.js";
|
|
11
|
+
import "../chunk-WQKHFADH.js";
|
|
11
12
|
import "../chunk-EFGX3EX5.js";
|
|
12
13
|
import "../chunk-OIMLU4SF.js";
|
|
13
14
|
export {
|
package/dist/loaders/index.d.ts
CHANGED
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-
|
|
2
|
-
export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-
|
|
1
|
+
import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-BfHZz1ZG.js';
|
|
2
|
+
export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-BfHZz1ZG.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
|
-
import '../types-
|
|
7
|
-
import '../tool-
|
|
6
|
+
import '../types-Dmoq-Fhz.js';
|
|
7
|
+
import '../tool-Dz-lHZon.js';
|
|
8
8
|
|
|
9
9
|
declare function connectMcp(connection: McpConnection): Promise<McpServer>;
|
|
10
10
|
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { g as ToolDefinition, b as CompletionRequest, c as CompletionResponse, e as JsonValue, j as ToolResultContent } from './types-Dmoq-Fhz.js';
|
|
2
|
+
import { V as VectorMetadata, E as EmbeddingModel, b as EmbeddedDocument } from './types-IB2e9u5M.js';
|
|
3
|
+
import { VectorSearchIndex } from './vector-store/index.js';
|
|
4
|
+
import { A as AnyTool, c as ToolCallContext, N as NormalizedToolOutput } from './tool-Dz-lHZon.js';
|
|
5
|
+
|
|
6
|
+
declare class ToolSet {
|
|
7
|
+
private readonly tools;
|
|
8
|
+
static fromTools(tools: AnyTool[]): ToolSet;
|
|
9
|
+
addTool(tool: AnyTool): this;
|
|
10
|
+
addTools(tools: AnyTool[] | ToolSet): this;
|
|
11
|
+
deleteTool(toolName: string): boolean;
|
|
12
|
+
contains(toolName: string): boolean;
|
|
13
|
+
get(toolName: string): AnyTool | undefined;
|
|
14
|
+
values(): AnyTool[];
|
|
15
|
+
getToolDefinitions(prompt?: string): Promise<ToolDefinition[]>;
|
|
16
|
+
call(toolName: string, args: string, context?: ToolCallContext): Promise<NormalizedToolOutput>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ToolSearchDocument<Metadata extends VectorMetadata = VectorMetadata> = {
|
|
20
|
+
toolName: string;
|
|
21
|
+
definition: ToolDefinition;
|
|
22
|
+
text: string;
|
|
23
|
+
metadata?: Metadata | undefined;
|
|
24
|
+
};
|
|
25
|
+
type EmbedToolsOptions<Metadata extends VectorMetadata = VectorMetadata> = {
|
|
26
|
+
content?: ((tool: AnyTool, definition: ToolDefinition) => string | string[]) | undefined;
|
|
27
|
+
metadata?: ((tool: AnyTool, definition: ToolDefinition) => Metadata | undefined) | undefined;
|
|
28
|
+
concurrency?: number | undefined;
|
|
29
|
+
};
|
|
30
|
+
interface DynamicToolIndex<Metadata extends VectorMetadata = VectorMetadata> extends VectorSearchIndex<ToolSearchDocument<Metadata>, Metadata> {
|
|
31
|
+
readonly toolSet: ToolSet;
|
|
32
|
+
}
|
|
33
|
+
declare function embedTools<Metadata extends VectorMetadata = VectorMetadata>(model: EmbeddingModel, tools: AnyTool[] | ToolSet, options?: EmbedToolsOptions<Metadata>): Promise<Array<EmbeddedDocument<ToolSearchDocument<Metadata>, Metadata>>>;
|
|
34
|
+
declare function createToolIndex<Metadata extends VectorMetadata = VectorMetadata>(model: EmbeddingModel, tools: AnyTool[] | ToolSet, options?: EmbedToolsOptions<Metadata>): Promise<DynamicToolIndex<Metadata>>;
|
|
35
|
+
declare function isDynamicToolIndex(value: unknown): value is DynamicToolIndex;
|
|
36
|
+
|
|
37
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
38
|
+
type CompletionRequestMiddlewareArgs = {
|
|
39
|
+
turn: number;
|
|
40
|
+
request: CompletionRequest;
|
|
41
|
+
originalRequest: CompletionRequest;
|
|
42
|
+
};
|
|
43
|
+
type CompletionRequestMiddlewareResult = {
|
|
44
|
+
request: CompletionRequest;
|
|
45
|
+
} | undefined;
|
|
46
|
+
type CompletionResponseMiddlewareArgs<RawResponse = unknown> = {
|
|
47
|
+
turn: number;
|
|
48
|
+
request: CompletionRequest;
|
|
49
|
+
response: CompletionResponse<RawResponse>;
|
|
50
|
+
originalResponse: CompletionResponse<RawResponse>;
|
|
51
|
+
};
|
|
52
|
+
type CompletionResponseMiddlewareResult<RawResponse = unknown> = {
|
|
53
|
+
response: CompletionResponse<RawResponse>;
|
|
54
|
+
} | undefined;
|
|
55
|
+
type ToolInputMiddlewareArgs = {
|
|
56
|
+
toolName: string;
|
|
57
|
+
args: string;
|
|
58
|
+
originalArgs: string;
|
|
59
|
+
turn: number;
|
|
60
|
+
toolCallId?: string | undefined;
|
|
61
|
+
internalCallId: string;
|
|
62
|
+
};
|
|
63
|
+
type ToolInputMiddlewareResult = {
|
|
64
|
+
args: JsonValue | string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
type ToolResultMiddlewareArgs = {
|
|
67
|
+
toolName: string;
|
|
68
|
+
args: string;
|
|
69
|
+
result: string;
|
|
70
|
+
originalResult: string;
|
|
71
|
+
structuredResult?: ToolResultContent[] | undefined;
|
|
72
|
+
originalStructuredResult?: ToolResultContent[] | undefined;
|
|
73
|
+
turn: number;
|
|
74
|
+
toolCallId?: string | undefined;
|
|
75
|
+
internalCallId: string;
|
|
76
|
+
};
|
|
77
|
+
type ToolOutputMiddlewareArgs = ToolResultMiddlewareArgs;
|
|
78
|
+
type ToolOutputMiddlewareResult = string | {
|
|
79
|
+
result?: string | undefined;
|
|
80
|
+
structuredResult?: ToolResultContent[] | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
interface AgentMiddleware<RawResponse = unknown> {
|
|
83
|
+
onCompletionRequest?(args: CompletionRequestMiddlewareArgs): MaybePromise<CompletionRequestMiddlewareResult>;
|
|
84
|
+
onCompletionResponse?(args: CompletionResponseMiddlewareArgs<RawResponse>): MaybePromise<CompletionResponseMiddlewareResult<RawResponse>>;
|
|
85
|
+
onToolInput?(args: ToolInputMiddlewareArgs): MaybePromise<ToolInputMiddlewareResult>;
|
|
86
|
+
onToolOutput?(args: ToolOutputMiddlewareArgs): MaybePromise<ToolOutputMiddlewareResult>;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `onToolOutput` instead.
|
|
89
|
+
*/
|
|
90
|
+
onResult?(args: ToolResultMiddlewareArgs): string | undefined | Promise<string | undefined>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use `AgentMiddleware` instead.
|
|
94
|
+
*/
|
|
95
|
+
type ToolMiddleware<RawResponse = unknown> = AgentMiddleware<RawResponse>;
|
|
96
|
+
declare function createMiddleware<RawResponse = unknown>(middleware: AgentMiddleware<RawResponse>): AgentMiddleware<RawResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use `createMiddleware` instead.
|
|
99
|
+
*/
|
|
100
|
+
declare function createToolMiddleware<RawResponse = unknown>(middleware: ToolMiddleware<RawResponse>): ToolMiddleware<RawResponse>;
|
|
101
|
+
|
|
102
|
+
export { type AgentMiddleware as A, type CompletionRequestMiddlewareArgs as C, type DynamicToolIndex as D, type EmbedToolsOptions as E, type ToolInputMiddlewareArgs as T, type CompletionRequestMiddlewareResult as a, type CompletionResponseMiddlewareArgs as b, type CompletionResponseMiddlewareResult as c, type ToolInputMiddlewareResult as d, type ToolMiddleware as e, type ToolOutputMiddlewareArgs as f, type ToolOutputMiddlewareResult as g, type ToolResultMiddlewareArgs as h, createMiddleware as i, createToolMiddleware as j, type ToolSearchDocument as k, ToolSet as l, createToolIndex as m, embedTools as n, isDynamicToolIndex as o };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Message, b as CompletionRequest, J as JsonObject,
|
|
2
|
-
import { d as ToolCallStreamEvent } from '../tool-
|
|
1
|
+
import { M as Message, b as CompletionRequest, J as JsonObject, q as CompletionModelCapabilities, c as CompletionResponse, f as ToolCall, g as ToolDefinition, j as ToolResultContent, U as Usage } from '../types-Dmoq-Fhz.js';
|
|
2
|
+
import { d as ToolCallStreamEvent } from '../tool-Dz-lHZon.js';
|
|
3
3
|
|
|
4
4
|
type AgentTraceInfo = {
|
|
5
5
|
traceId?: string | undefined;
|
package/dist/pipeline/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { e as Agent } from '../agent-
|
|
2
|
-
import { J as JsonObject, C as CompletionModel } from '../types-
|
|
1
|
+
import { e as Agent } from '../agent-BURoB-me.js';
|
|
2
|
+
import { J as JsonObject, C as CompletionModel } from '../types-Dmoq-Fhz.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-Dz-lHZon.js';
|
|
7
|
+
import '../middleware-C9QIms85.js';
|
|
8
8
|
import '../types-IB2e9u5M.js';
|
|
9
9
|
import '../vector-store/index.js';
|
|
10
10
|
import '../zod-schema-C7F4clpm.js';
|
package/dist/skills/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SkillLoader, a as SkillSet } from '../types-
|
|
2
|
-
export { c as Skill, S as SkillValidationError, d as SkillValidationIssue } from '../types-
|
|
3
|
-
import '../tool-
|
|
4
|
-
import '../types-
|
|
1
|
+
import { b as SkillLoader, a as SkillSet } from '../types-DUivppau.js';
|
|
2
|
+
export { c as Skill, S as SkillValidationError, d as SkillValidationIssue } from '../types-DUivppau.js';
|
|
3
|
+
import '../tool-Dz-lHZon.js';
|
|
4
|
+
import '../types-Dmoq-Fhz.js';
|
|
5
5
|
|
|
6
6
|
declare function loadSkills(loaders: SkillLoader | SkillLoader[]): Promise<SkillSet>;
|
|
7
7
|
|
package/dist/skills/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
SkillValidationError,
|
|
3
3
|
loadSkills,
|
|
4
4
|
skill
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-SHHSMV7O.js";
|
|
6
6
|
import "../chunk-YK4WAAS4.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-AER5FGPK.js";
|
|
8
|
+
import "../chunk-I47EHI45.js";
|
|
9
|
+
import "../chunk-WQKHFADH.js";
|
|
9
10
|
import "../chunk-EFGX3EX5.js";
|
|
10
11
|
import "../chunk-OIMLU4SF.js";
|
|
11
12
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
3
|
-
import { b as ToolApprovalPolicy, c as ToolCallContext, T as Tool } from './tool-
|
|
3
|
+
import { b as ToolApprovalPolicy, c as ToolCallContext, T as Tool } from './tool-Dz-lHZon.js';
|
|
4
4
|
|
|
5
5
|
type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined, Output = unknown> = {
|
|
6
6
|
name: string;
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { b as CreateThinkToolOptions, C as CreateToolOptions, c as createThinkTool, a as createTool } from '../think-tool-
|
|
2
|
-
export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware,
|
|
3
|
-
export { A as AnyTool, N as NormalizedToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, e as ToolApprovalRunContext, c as ToolCallContext, d as ToolCallStreamEvent, f as ToolOutput, i as isToolResultContentArray, n as normalizeToolResultOutput, p as parseToolArgs, s as serializeToolOutput, t as toolResultContentToText } from '../tool-
|
|
1
|
+
export { b as CreateThinkToolOptions, C as CreateToolOptions, c as createThinkTool, a as createTool } from '../think-tool-DLTCqqJ6.js';
|
|
2
|
+
export { A as AgentMiddleware, C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, e as ToolMiddleware, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, k as ToolSearchDocument, l as ToolSet, i as createMiddleware, m as createToolIndex, j as createToolMiddleware, n as embedTools, o as isDynamicToolIndex } from '../middleware-C9QIms85.js';
|
|
3
|
+
export { A as AnyTool, N as NormalizedToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalPolicy, e as ToolApprovalRunContext, c as ToolCallContext, d as ToolCallStreamEvent, f as ToolOutput, i as isToolResultContentArray, n as normalizeToolResultOutput, p as parseToolArgs, s as serializeToolOutput, t as toolResultContentToText } from '../tool-Dz-lHZon.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../zod-schema-C7F4clpm.js';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-Dmoq-Fhz.js';
|
|
7
7
|
import '../types-IB2e9u5M.js';
|
|
8
8
|
import '../vector-store/index.js';
|
|
9
9
|
|
package/dist/tool/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ToolNotFoundError,
|
|
5
5
|
ToolOutput,
|
|
6
6
|
ToolSet,
|
|
7
|
+
createMiddleware,
|
|
7
8
|
createThinkTool,
|
|
8
9
|
createToolIndex,
|
|
9
10
|
createToolMiddleware,
|
|
@@ -14,10 +15,11 @@ import {
|
|
|
14
15
|
parseToolArgs,
|
|
15
16
|
serializeToolOutput,
|
|
16
17
|
toolResultContentToText
|
|
17
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-AER5FGPK.js";
|
|
18
19
|
import {
|
|
19
20
|
createTool
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-I47EHI45.js";
|
|
22
|
+
import "../chunk-WQKHFADH.js";
|
|
21
23
|
import "../chunk-EFGX3EX5.js";
|
|
22
24
|
import "../chunk-OIMLU4SF.js";
|
|
23
25
|
export {
|
|
@@ -26,6 +28,7 @@ export {
|
|
|
26
28
|
ToolNotFoundError,
|
|
27
29
|
ToolOutput,
|
|
28
30
|
ToolSet,
|
|
31
|
+
createMiddleware,
|
|
29
32
|
createThinkTool,
|
|
30
33
|
createTool,
|
|
31
34
|
createToolIndex,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonObject, g as ToolDefinition, j as ToolResultContent, e as JsonValue } from './types-
|
|
1
|
+
import { J as JsonObject, g as ToolDefinition, j as ToolResultContent, e as JsonValue } from './types-Dmoq-Fhz.js';
|
|
2
2
|
|
|
3
3
|
type ToolApprovalRunContext = {
|
|
4
4
|
agentId: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
2
2
|
import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
3
|
import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
|
-
import { J as JsonObject } from './types-
|
|
5
|
-
import { A as AnyTool } from './tool-
|
|
4
|
+
import { J as JsonObject } from './types-Dmoq-Fhz.js';
|
|
5
|
+
import { A as AnyTool } from './tool-Dz-lHZon.js';
|
|
6
6
|
|
|
7
7
|
type McpToolDefinition = {
|
|
8
8
|
name: string;
|
|
@@ -250,4 +250,4 @@ declare function assertCompletionRequestSupported(model: CompletionModel, reques
|
|
|
250
250
|
}): void;
|
|
251
251
|
declare function textFromAssistantContent(content: AssistantContent[]): string;
|
|
252
252
|
|
|
253
|
-
export { AssistantContent as A, type CompletionModel as C, type Document as D, type ImageContent as I, type JsonObject as J, Message as M, type Reasoning as R, type SystemMessage as S, type Text as T, Usage as U, type AssistantMessage as a, type CompletionRequest as b, type CompletionResponse as c, type JsonPrimitive as d, type JsonValue as e, type ToolCall as f, type ToolDefinition as g, type ToolMessage as h, type ToolResult as i, type ToolResultContent as j, UserContent as k, type UserMessage as l, type ToolChoice as m,
|
|
253
|
+
export { AssistantContent as A, type CompletionModel as C, type Document as D, type ImageContent as I, type JsonObject as J, Message as M, type Reasoning as R, type SystemMessage as S, type Text as T, Usage as U, type AssistantMessage as a, type CompletionRequest as b, type CompletionResponse as c, type JsonPrimitive as d, type JsonValue as e, type ToolCall as f, type ToolDefinition as g, type ToolMessage as h, type ToolResult as i, type ToolResultContent as j, UserContent as k, type UserMessage as l, type ToolChoice as m, type StreamingCompletionModel as n, type CompletionStreamEvent as o, CompletionCapabilityError as p, type CompletionModelCapabilities as q, type DocumentContent as r, type ImageDetail as s, type ReasoningContent as t, type ReasoningContentType as u, ToolContent as v, type ToolFunction as w, assertCompletionRequestSupported as x, reasoningDisplayText as y, textFromAssistantContent as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as VectorMetadataValue, V as VectorMetadata, E as EmbeddingModel, b as EmbeddedDocument, c as Embedding } from '../types-IB2e9u5M.js';
|
|
2
|
-
import { T as Tool } from '../tool-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { T as Tool } from '../tool-Dz-lHZon.js';
|
|
3
|
+
import '../types-Dmoq-Fhz.js';
|
|
4
4
|
|
|
5
5
|
type VectorFilter = {
|
|
6
6
|
type: "eq";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/completion/types.ts","../src/completion/documents.ts","../src/completion/request.ts"],"sourcesContent":["export type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\nexport type Document = {\n id: string;\n text: string;\n additionalProps?: Record<string, string>;\n};\n\nexport type Text = {\n type: \"text\";\n text: string;\n signature?: string;\n};\n\nexport type ImageDetail = \"auto\" | \"low\" | \"high\";\n\nexport type ImageContent = {\n type: \"image\";\n source:\n | {\n type: \"url\";\n url: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n };\n detail?: ImageDetail;\n};\n\nexport type DocumentContent = {\n type: \"document\";\n source:\n | {\n type: \"url\";\n url: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"text\";\n text: string;\n mediaType?: string;\n filename?: string;\n };\n};\n\nexport type Reasoning = {\n type: \"reasoning\";\n text: string;\n id?: string;\n content?: ReasoningContent[];\n};\n\nexport type ReasoningContent =\n | {\n type: \"text\";\n text: string;\n signature?: string;\n }\n | {\n type: \"summary\";\n text: string;\n }\n | {\n type: \"encrypted\";\n data: string;\n }\n | {\n type: \"redacted\";\n data: string;\n };\n\nexport type ReasoningContentType = ReasoningContent[\"type\"];\n\nexport type ToolFunction = {\n name: string;\n arguments: JsonValue;\n};\n\nexport type ToolCall = {\n type: \"tool_call\";\n id: string;\n callId?: string;\n function: ToolFunction;\n signature?: string;\n additionalParams?: JsonValue;\n};\n\nexport type ToolResultContent =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mediaType?: string };\n\nexport type ToolResult = {\n type: \"tool_result\";\n id: string;\n callId?: string;\n content: ToolResultContent[];\n};\n\nexport type UserContent = Text | ImageContent | DocumentContent;\nexport type AssistantContent = Text | ToolCall | Reasoning | ImageContent;\nexport type ToolContent = ToolResult;\n\nexport type SystemMessage = {\n role: \"system\";\n content: string;\n};\n\nexport type UserMessage = {\n role: \"user\";\n content: UserContent[];\n};\n\nexport type AssistantMessage = {\n role: \"assistant\";\n id?: string;\n content: AssistantContent[];\n};\n\nexport type ToolMessage = {\n role: \"tool\";\n content: ToolContent[];\n};\n\nexport type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;\n\nexport const UserContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n documentUrl(\n url: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"url\", url, mediaType }\n : { type: \"url\", url, mediaType, filename: options.filename },\n };\n },\n documentBase64(\n data: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"base64\", data, mediaType }\n : { type: \"base64\", data, mediaType, filename: options.filename },\n };\n },\n documentText(text: string): Text {\n return { type: \"text\", text };\n },\n};\n\nexport const ToolContent = {\n toolResult(id: string, content: string | ToolResultContent[], callId?: string): ToolResult {\n const normalized =\n typeof content === \"string\" ? [{ type: \"text\" as const, text: content }] : content;\n return callId === undefined\n ? { type: \"tool_result\", id, content: normalized }\n : { type: \"tool_result\", id, callId, content: normalized };\n },\n};\n\nexport const AssistantContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n reasoning(text: string, id?: string): Reasoning {\n return id === undefined ? { type: \"reasoning\", text } : { type: \"reasoning\", text, id };\n },\n reasoningFromContent(content: ReasoningContent[], id?: string): Reasoning {\n const text = reasoningDisplayText(content);\n const reasoning: Reasoning = { type: \"reasoning\", text, content };\n return id === undefined ? reasoning : { ...reasoning, id };\n },\n reasoningSummary(text: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"summary\", text }], id);\n },\n reasoningEncrypted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"encrypted\", data }], id);\n },\n reasoningRedacted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"redacted\", data }], id);\n },\n toolCall(id: string, name: string, args: JsonValue, callId?: string): ToolCall {\n const base: ToolCall = {\n type: \"tool_call\",\n id,\n function: {\n name,\n arguments: args,\n },\n };\n return callId === undefined ? base : { ...base, callId };\n },\n};\n\nexport function reasoningDisplayText(reasoning: Reasoning | ReasoningContent[]): string {\n const content = Array.isArray(reasoning) ? reasoning : reasoning.content;\n if (content === undefined) {\n return Array.isArray(reasoning) ? \"\" : reasoning.text;\n }\n return content\n .flatMap((item) => {\n if (item.type === \"text\" || item.type === \"summary\") {\n return [item.text];\n }\n return [];\n })\n .join(\"\");\n}\n\nexport const Message = {\n system(content: string): Message {\n return { role: \"system\", content };\n },\n user(content: string | UserContent[]): Message {\n return {\n role: \"user\",\n content: typeof content === \"string\" ? [UserContent.text(content)] : content,\n };\n },\n assistant(content: string | AssistantContent[], id?: string): Message {\n const normalized = typeof content === \"string\" ? [AssistantContent.text(content)] : content;\n return id === undefined\n ? { role: \"assistant\", content: normalized }\n : { role: \"assistant\", id, content: normalized };\n },\n tool(content: ToolContent | ToolContent[]): Message {\n return {\n role: \"tool\",\n content: Array.isArray(content) ? content : [content],\n };\n },\n};\n\nexport type ToolChoice =\n | \"auto\"\n | \"required\"\n | \"none\"\n | {\n type: \"function\";\n name: string;\n };\n\nexport type ToolDefinition = {\n name: string;\n description: string;\n parameters: JsonObject;\n};\n\nexport type Usage = {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n cachedInputTokens: number;\n cacheCreationInputTokens: number;\n};\n\nexport const Usage = {\n empty(): Usage {\n return {\n inputTokens: 0,\n outputTokens: 0,\n totalTokens: 0,\n cachedInputTokens: 0,\n cacheCreationInputTokens: 0,\n };\n },\n add(left: Usage, right: Usage): Usage {\n return {\n inputTokens: left.inputTokens + right.inputTokens,\n outputTokens: left.outputTokens + right.outputTokens,\n totalTokens: left.totalTokens + right.totalTokens,\n cachedInputTokens: left.cachedInputTokens + right.cachedInputTokens,\n cacheCreationInputTokens: left.cacheCreationInputTokens + right.cacheCreationInputTokens,\n };\n },\n};\n\nexport type CompletionRequest = {\n model?: string;\n instructions?: string;\n chatHistory: Message[];\n documents: Document[];\n tools: ToolDefinition[];\n temperature?: number;\n maxTokens?: number;\n toolChoice?: ToolChoice;\n additionalParams?: JsonValue;\n outputSchema?: JsonObject;\n};\n\nexport type CompletionResponse<RawResponse = unknown> = {\n choice: AssistantContent[];\n usage: Usage;\n rawResponse: RawResponse;\n messageId?: string;\n};\n\nexport type CompletionModelCapabilities = {\n streaming: boolean;\n tools: boolean;\n toolChoice: boolean;\n imageInput: boolean;\n documentInput: boolean;\n outputSchema: boolean;\n reasoning: boolean;\n};\n\nexport interface CompletionModel<RawResponse = unknown> {\n readonly provider: string;\n readonly defaultModel: string;\n readonly capabilities: CompletionModelCapabilities;\n traceRequest?(\n request: CompletionRequest,\n options?: { stream?: boolean | undefined },\n ): JsonObject | undefined;\n completion(request: CompletionRequest): Promise<CompletionResponse<RawResponse>>;\n}\n\nexport type CompletionStreamEvent<RawResponse = unknown> =\n | {\n type: \"text_delta\";\n delta: string;\n }\n | {\n type: \"reasoning_delta\";\n delta: string;\n id?: string;\n contentType?: ReasoningContentType;\n signature?: string;\n }\n | {\n type: \"tool_call_delta\";\n id: string;\n callId?: string;\n name?: string;\n argumentsDelta?: string;\n signature?: string;\n }\n | {\n type: \"tool_call\";\n toolCall: ToolCall;\n }\n | {\n type: \"message_id\";\n id: string;\n }\n | {\n type: \"final\";\n response: CompletionResponse<RawResponse>;\n }\n | {\n type: \"error\";\n error: unknown;\n };\n\nexport interface StreamingCompletionModel<RawResponse = unknown>\n extends CompletionModel<RawResponse> {\n streamCompletion(request: CompletionRequest): AsyncIterable<CompletionStreamEvent<RawResponse>>;\n}\n\nexport class CompletionCapabilityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CompletionCapabilityError\";\n }\n}\n\nexport function assertCompletionRequestSupported(\n model: CompletionModel,\n request: CompletionRequest,\n options: { streaming?: boolean | undefined } = {},\n): void {\n const modelLabel = `${model.provider}:${request.model ?? model.defaultModel}`;\n const capabilities = model.capabilities;\n\n if (options.streaming === true && !capabilities.streaming) {\n throw new CompletionCapabilityError(`${modelLabel} does not support streaming completions.`);\n }\n\n if (request.tools.length > 0 && !capabilities.tools) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool definitions.`);\n }\n\n if (request.toolChoice !== undefined && !capabilities.toolChoice) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool choice.`);\n }\n\n if (request.outputSchema !== undefined && !capabilities.outputSchema) {\n throw new CompletionCapabilityError(`${modelLabel} does not support output schemas.`);\n }\n\n if (!capabilities.imageInput && requestHasImageInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support image input.`);\n }\n\n if (!capabilities.documentInput && requestHasFileDocumentInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support document file input.`);\n }\n}\n\nexport function textFromAssistantContent(content: AssistantContent[]): string {\n return content.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\");\n}\n\nfunction requestHasImageInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"system\" ? false : message.content.some((content) => content.type === \"image\"),\n );\n}\n\nfunction requestHasFileDocumentInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"user\"\n ? message.content.some(\n (content) => content.type === \"document\" && content.source.type !== \"text\",\n )\n : false,\n );\n}\n","import { type Document, Message, type Message as MessageType } from \"./types\";\n\nexport function normalizeDocuments(documents: Document[]): MessageType | undefined {\n if (documents.length === 0) {\n return undefined;\n }\n\n return Message.user(documents.map(formatDocument).join(\"\\n\"));\n}\n\nexport function formatDocument(document: Document): string {\n return `<file id: ${document.id}>\\n${formatDocumentBody(document)}\\n</file>\\n`;\n}\n\nfunction formatDocumentBody(document: Document): string {\n const metadata = formatMetadata(document.additionalProps);\n return metadata === undefined ? document.text : `${metadata}\\n${document.text}`;\n}\n\nfunction formatMetadata(additionalProps: Record<string, string> | undefined): string | undefined {\n if (additionalProps === undefined) {\n return undefined;\n }\n\n const entries = Object.entries(additionalProps).sort(([left], [right]) =>\n left.localeCompare(right),\n );\n if (entries.length === 0) {\n return undefined;\n }\n\n const metadata = entries.map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(\" \");\n return `<metadata ${metadata} />`;\n}\n","import type {\n CompletionModel,\n CompletionRequest,\n CompletionResponse,\n Document,\n JsonObject,\n JsonValue,\n Message as MessageType,\n ToolChoice,\n ToolDefinition,\n} from \"./types\";\nimport { assertCompletionRequestSupported } from \"./types\";\n\nexport class CompletionRequestBuilder<M extends CompletionModel = CompletionModel> {\n private requestModel: string | undefined;\n private instructionBlocks: string[] = [];\n private history: MessageType[] = [];\n private docs: Document[] = [];\n private toolDefs: ToolDefinition[] = [];\n private temp: number | undefined;\n private maxTokenCount: number | undefined;\n private choice: ToolChoice | undefined;\n private params: JsonValue | undefined;\n private schema: JsonObject | undefined;\n\n constructor(\n private readonly model: M,\n private readonly promptMessage: MessageType,\n ) {}\n\n modelOverride(model: string | undefined): this {\n this.requestModel = model;\n return this;\n }\n\n instructions(instructions: string | undefined): this {\n if (instructions !== undefined && instructions.length > 0) {\n this.instructionBlocks.push(instructions);\n }\n return this;\n }\n\n messages(messages: MessageType[]): this {\n this.history.push(...messages);\n return this;\n }\n\n documents(documents: Document[]): this {\n this.docs.push(...documents);\n return this;\n }\n\n tools(tools: ToolDefinition[]): this {\n this.toolDefs.push(...tools);\n return this;\n }\n\n temperature(temperature: number | undefined): this {\n this.temp = temperature;\n return this;\n }\n\n maxTokens(maxTokens: number | undefined): this {\n this.maxTokenCount = maxTokens;\n return this;\n }\n\n toolChoice(toolChoice: ToolChoice | undefined): this {\n this.choice = toolChoice;\n return this;\n }\n\n additionalParams(additionalParams: JsonValue | undefined): this {\n this.params = additionalParams;\n return this;\n }\n\n outputSchema(outputSchema: JsonObject | undefined): this {\n this.schema = outputSchema;\n return this;\n }\n\n build(): CompletionRequest {\n const instructions = this.buildInstructions();\n const request: CompletionRequest = {\n chatHistory: [...this.history, this.promptMessage],\n documents: [...this.docs],\n tools: [...this.toolDefs],\n };\n\n if (this.requestModel !== undefined) request.model = this.requestModel;\n if (instructions !== undefined) request.instructions = instructions;\n if (this.temp !== undefined) request.temperature = this.temp;\n if (this.maxTokenCount !== undefined) request.maxTokens = this.maxTokenCount;\n if (this.choice !== undefined) request.toolChoice = this.choice;\n if (this.params !== undefined) request.additionalParams = this.params;\n if (this.schema !== undefined) request.outputSchema = this.schema;\n\n return request;\n }\n\n async send(): Promise<CompletionResponse> {\n const request = this.build();\n assertCompletionRequestSupported(this.model, request);\n return this.model.completion(request);\n }\n\n private buildInstructions(): string | undefined {\n return this.instructionBlocks.length === 0 ? undefined : this.instructionBlocks.join(\"\\n\\n\");\n }\n}\n"],"mappings":";AAwIO,IAAM,cAAc;AAAA,EACzB,KAAK,MAAoB;AACvB,WAAO,EAAE,MAAM,QAAQ,KAAK;AAAA,EAC9B;AAAA,EACA,SAAS,KAAa,UAAoC,CAAC,GAAiB;AAC1E,UAAM,QAAsB,EAAE,MAAM,SAAS,QAAQ,EAAE,MAAM,OAAO,IAAI,EAAE;AAC1E,QAAI,QAAQ,WAAW,QAAW;AAChC,YAAM,SAAS,QAAQ;AAAA,IACzB;AACA,WAAO;AAAA,EACT;AAAA,EACA,YACE,MACA,WACA,UAAoC,CAAC,GACvB;AACd,UAAM,QAAsB;AAAA,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,QAAQ,KAAK;AAC1D,QAAI,iBAAiB,OAAW,SAAQ,eAAe;AACvD,QAAI,KAAK,SAAS,OAAW,SAAQ,cAAc,KAAK;AACxD,QAAI,KAAK,kBAAkB,OAAW,SAAQ,YAAY,KAAK;AAC/D,QAAI,KAAK,WAAW,OAAW,SAAQ,aAAa,KAAK;AACzD,QAAI,KAAK,WAAW,OAAW,SAAQ,mBAAmB,KAAK;AAC/D,QAAI,KAAK,WAAW,OAAW,SAAQ,eAAe,KAAK;AAE3D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAoC;AACxC,UAAM,UAAU,KAAK,MAAM;AAC3B,qCAAiC,KAAK,OAAO,OAAO;AACpD,WAAO,KAAK,MAAM,WAAW,OAAO;AAAA,EACtC;AAAA,EAEQ,oBAAwC;AAC9C,WAAO,KAAK,kBAAkB,WAAW,IAAI,SAAY,KAAK,kBAAkB,KAAK,MAAM;AAAA,EAC7F;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agent/builder.ts"],"sourcesContent":["import type { CompletionModel, Document, JsonObject, JsonValue, ToolChoice } from \"../completion\";\nimport type { McpServer } from \"../mcp\";\nimport {\n type MemoryOptions,\n type MemoryRegistration,\n type MemoryStore,\n resolveMemoryOptions,\n} from \"../memory\";\nimport type { AgentObserver, AgentObserverRegistration, ObserveOptions } from \"../observability\";\nimport { toProviderJsonSchema, type ZodSchema } from \"../schema/zod-schema\";\nimport type { SkillSet } from \"../skills\";\nimport type { ToolSearchDocument } from \"../tool/dynamic-tools\";\nimport type { ToolMiddleware } from \"../tool/middleware\";\nimport type { AnyTool } from \"../tool/tool\";\nimport { ToolSet } from \"../tool/tool-set\";\nimport type { VectorSearchIndex } from \"../vector-store\";\nimport {\n Agent,\n type AgentEventStore,\n type AgentEventStoreOptions,\n type AgentEventStoreRegistration,\n type DynamicContextOptions,\n type DynamicContextRegistration,\n type DynamicToolOptions,\n type DynamicToolRegistration,\n} from \"./agent\";\nimport type { PromptHook } from \"./hooks\";\nimport { normalizeAgentId } from \"./ids\";\n\nexport class AgentBuilder<M extends CompletionModel = CompletionModel> {\n private readonly agentId: string;\n private agentName: string | undefined;\n private agentDescription: string | undefined;\n private instructionBlocks: string[] = [];\n private contextDocs: Document[] = [];\n private temp: number | undefined;\n private maxTokenCount: number | undefined;\n private params: JsonValue | undefined;\n private choice: ToolChoice | undefined;\n private turns: number | undefined;\n private requestHook: PromptHook | undefined;\n private schema: JsonObject | undefined;\n private skillInstructionBlocks: string[] = [];\n private observerRegistrations: AgentObserverRegistration[] = [];\n private dynamicContextRegistrations: DynamicContextRegistration[] = [];\n private dynamicToolRegistrations: DynamicToolRegistration[] = [];\n private middlewareRegistrations: ToolMiddleware[] = [];\n private memoryRegistration: MemoryRegistration | undefined;\n private eventStoreRegistration: AgentEventStoreRegistration | undefined;\n private activeToolSet = new ToolSet();\n\n constructor(\n agentId: string,\n private readonly completionModel: M,\n ) {\n this.agentId = normalizeAgentId(agentId);\n }\n\n name(name: string): this {\n this.agentName = name;\n return this;\n }\n\n description(description: string): this {\n this.agentDescription = description;\n return this;\n }\n\n instructions(instructions: string): this {\n if (instructions.length > 0) {\n this.instructionBlocks.push(instructions);\n }\n return this;\n }\n\n context(text: string, id = `static_doc_${this.contextDocs.length}`): this {\n this.contextDocs.push({ id, text });\n return this;\n }\n\n dynamicContext<T>(index: VectorSearchIndex<T>, options: DynamicContextOptions<T>): this {\n this.dynamicContextRegistrations.push({ index, options } as DynamicContextRegistration);\n return this;\n }\n\n dynamicTools(index: VectorSearchIndex<ToolSearchDocument>, options: DynamicToolOptions): this {\n this.dynamicToolRegistrations.push({ index, options });\n return this;\n }\n\n tool(tool: AnyTool): this {\n this.activeToolSet.addTool(tool);\n return this;\n }\n\n tools(tools: AnyTool[]): this {\n this.activeToolSet.addTools(tools);\n return this;\n }\n\n mcp(servers: McpServer[]): this {\n for (const server of servers) {\n this.activeToolSet.addTools(server.tools);\n }\n return this;\n }\n\n skills(skillSet: SkillSet): this {\n if (skillSet.instructions.length > 0) {\n this.skillInstructionBlocks.push(skillSet.instructions);\n }\n this.activeToolSet.addTools(skillSet.tools);\n return this;\n }\n\n useToolSet(toolSet: ToolSet): this {\n toolSet.addTools(this.activeToolSet);\n this.activeToolSet = toolSet;\n return this;\n }\n\n temperature(temperature: number): this {\n this.temp = temperature;\n return this;\n }\n\n maxTokens(maxTokens: number): this {\n this.maxTokenCount = maxTokens;\n return this;\n }\n\n additionalParams(params: JsonValue): this {\n this.params = params;\n return this;\n }\n\n toolChoice(toolChoice: ToolChoice): this {\n this.choice = toolChoice;\n return this;\n }\n\n defaultMaxTurns(defaultMaxTurns: number): this {\n this.turns = defaultMaxTurns;\n return this;\n }\n\n hook(hook: PromptHook): this {\n this.requestHook = hook;\n return this;\n }\n\n toolMiddleware(middleware: ToolMiddleware): this {\n this.middlewareRegistrations.push(middleware);\n return this;\n }\n\n toolMiddlewares(middlewares: ToolMiddleware[]): this {\n this.middlewareRegistrations.push(...middlewares);\n return this;\n }\n\n observe(observer: AgentObserver, options: ObserveOptions = {}): this {\n this.observerRegistrations.push({\n observer,\n failOnObserverError: options.failOnObserverError,\n });\n return this;\n }\n\n memory(store: MemoryStore, options: MemoryOptions = {}): this {\n this.memoryRegistration = {\n store,\n options: resolveMemoryOptions(options),\n };\n return this;\n }\n\n eventStore(store: AgentEventStore, options: AgentEventStoreOptions = {}): this {\n this.eventStoreRegistration = {\n store,\n options: {\n include: options.include ?? \"all\",\n },\n };\n return this;\n }\n\n outputSchema(schema: ZodSchema): this {\n this.schema = toProviderJsonSchema(schema);\n return this;\n }\n\n build(): Agent<M> {\n return new Agent({\n id: this.agentId,\n name: this.agentName,\n description: this.agentDescription,\n model: this.completionModel,\n instructions: this.buildInstructions(),\n staticContext: this.contextDocs,\n temperature: this.temp,\n maxTokens: this.maxTokenCount,\n additionalParams: this.params,\n toolSet: this.activeToolSet,\n toolChoice: this.choice,\n defaultMaxTurns: this.turns,\n hook: this.requestHook,\n outputSchema: this.schema,\n observers: this.observerRegistrations,\n dynamicContexts: this.dynamicContextRegistrations,\n dynamicTools: this.dynamicToolRegistrations,\n toolMiddlewares: this.middlewareRegistrations,\n memory: this.memoryRegistration,\n eventStore: this.eventStoreRegistration,\n });\n }\n\n private buildInstructions(): string | undefined {\n const parts = [...this.instructionBlocks, ...this.skillInstructionBlocks].filter(\n (part): part is string => part !== undefined && part.length > 0,\n );\n return parts.length === 0 ? undefined : parts.join(\"\\n\\n\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BO,IAAM,eAAN,MAAgE;AAAA,EAsBrE,YACE,SACiB,iBACjB;AADiB;AAEjB,SAAK,UAAU,iBAAiB,OAAO;AAAA,EACzC;AAAA,EAHmB;AAAA,EAvBF;AAAA,EACT;AAAA,EACA;AAAA,EACA,oBAA8B,CAAC;AAAA,EAC/B,cAA0B,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,yBAAmC,CAAC;AAAA,EACpC,wBAAqD,CAAC;AAAA,EACtD,8BAA4D,CAAC;AAAA,EAC7D,2BAAsD,CAAC;AAAA,EACvD,0BAA4C,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA,gBAAgB,IAAI,QAAQ;AAAA,EASpC,KAAK,MAAoB;AACvB,SAAK,YAAY;AACjB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,aAA2B;AACrC,SAAK,mBAAmB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,cAA4B;AACvC,QAAI,aAAa,SAAS,GAAG;AAC3B,WAAK,kBAAkB,KAAK,YAAY;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAc,KAAK,cAAc,KAAK,YAAY,MAAM,IAAU;AACxE,SAAK,YAAY,KAAK,EAAE,IAAI,KAAK,CAAC;AAClC,WAAO;AAAA,EACT;AAAA,EAEA,eAAkB,OAA6B,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