@anvia/core 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.d.ts +5 -13
- package/dist/agent/index.js +6 -6
- package/dist/{agent-CBz3CRxa.d.ts → agent-Q7FT1xmG.d.ts} +2 -22
- package/dist/{chunk-3YJXLOGO.js → chunk-47UWISJU.js} +4 -4
- package/dist/{chunk-I7TM7TKX.js → chunk-4BGN6PYF.js} +2 -2
- package/dist/{chunk-QABIBFKE.js → chunk-6GIREB6Z.js} +5 -10
- package/dist/chunk-6GIREB6Z.js.map +1 -0
- package/dist/{chunk-DC2GJDPR.js → chunk-BCA4VZ5W.js} +2 -2
- package/dist/{chunk-DPTZ2MK4.js → chunk-EOIQXFGK.js} +3 -15
- package/dist/chunk-EOIQXFGK.js.map +1 -0
- package/dist/{chunk-7LCKIULT.js → chunk-GKPJ6FUL.js} +2 -30
- package/dist/chunk-GKPJ6FUL.js.map +1 -0
- package/dist/{chunk-JNJBKSLA.js → chunk-MB55EXYB.js} +3 -7
- package/dist/{chunk-JNJBKSLA.js.map → chunk-MB55EXYB.js.map} +1 -1
- package/dist/{chunk-YBBD4HZ3.js → chunk-MNWK2USR.js} +119 -15
- package/dist/chunk-MNWK2USR.js.map +1 -0
- package/dist/embeddings/index.d.ts +6 -3
- package/dist/embeddings/index.js +7 -1
- package/dist/evals/index.d.ts +4 -4
- package/dist/evals/index.js +7 -7
- package/dist/extractor/index.d.ts +4 -4
- package/dist/extractor/index.js +7 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -10
- package/dist/internal/agent.d.ts +4 -4
- package/dist/internal/agent.js +5 -5
- package/dist/{middleware-Cp0tm6zE.d.ts → middleware-DfMc30in.d.ts} +3 -15
- package/dist/pipeline/index.d.ts +4 -4
- package/dist/request/index.d.ts +4 -4
- package/dist/request/index.js +4 -4
- package/dist/skills/index.js +4 -4
- package/dist/tool/index.d.ts +3 -3
- package/dist/tool/index.js +3 -5
- package/dist/types-BCTRUGex.d.ts +47 -0
- package/dist/{types-DMGvEFRf.d.ts → types-BrxxAtcJ.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +3 -3
- package/dist/vector-store/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7LCKIULT.js.map +0 -1
- package/dist/chunk-DPTZ2MK4.js.map +0 -1
- package/dist/chunk-QABIBFKE.js.map +0 -1
- package/dist/chunk-YBBD4HZ3.js.map +0 -1
- package/dist/types-DHHZztGO.d.ts +0 -25
- /package/dist/{chunk-3YJXLOGO.js.map → chunk-47UWISJU.js.map} +0 -0
- /package/dist/{chunk-I7TM7TKX.js.map → chunk-4BGN6PYF.js.map} +0 -0
- /package/dist/{chunk-DC2GJDPR.js.map → chunk-BCA4VZ5W.js.map} +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DynamicContextOptions, b as DynamicToolOptions, c as AgentEventStore, d as AgentEventStoreOptions, A as Agent } from '../agent-
|
|
2
|
-
export { e as AgentEventAppendInput, f as AgentEventRecord, g as AgentEventStoreInclude, h as AgentSession, i as AgentToolOptions } from '../agent-
|
|
1
|
+
import { D as DynamicContextOptions, b as DynamicToolOptions, c as AgentEventStore, d as AgentEventStoreOptions, A as Agent } from '../agent-Q7FT1xmG.js';
|
|
2
|
+
export { e as AgentEventAppendInput, f as AgentEventRecord, g as AgentEventStoreInclude, h as AgentSession, i as AgentToolOptions } from '../agent-Q7FT1xmG.js';
|
|
3
3
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
4
4
|
import { C as CompletionModel, P as ProviderTool, i as JsonValue, z as ToolChoice } from '../types-XjIh933x.js';
|
|
5
5
|
import { GuardrailPolicyInput } from '../guardrails/index.js';
|
|
@@ -8,14 +8,14 @@ import { a as McpServer } from '../types-BBEf34DP.js';
|
|
|
8
8
|
import { m as MemoryStore, n as MemoryOptions } from '../types-DBHzPsbx.js';
|
|
9
9
|
import { i as AgentObserver, O as ObserveOptions } from '../index-XTUEMWhU.js';
|
|
10
10
|
import { a as SkillSet } from '../types-fBv8mhvP.js';
|
|
11
|
-
import {
|
|
11
|
+
import { i as ToolSearchDocument, j as ToolSet, A as AgentMiddleware } from '../middleware-DfMc30in.js';
|
|
12
12
|
import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-Dhwg__1L.js';
|
|
13
|
-
import { a as VectorSearchIndex } from '../types-
|
|
13
|
+
import { a as VectorSearchIndex } from '../types-BrxxAtcJ.js';
|
|
14
14
|
import 'zod';
|
|
15
15
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
16
16
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
17
17
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
18
|
-
import '../types-
|
|
18
|
+
import '../types-BCTRUGex.js';
|
|
19
19
|
|
|
20
20
|
declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
|
|
21
21
|
private readonly completionModel;
|
|
@@ -62,14 +62,6 @@ declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
|
|
|
62
62
|
hook(hook: PromptHook): this;
|
|
63
63
|
middleware(middleware: AgentMiddleware): this;
|
|
64
64
|
middlewares(middlewares: AgentMiddleware[]): this;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated Use `middleware` instead.
|
|
67
|
-
*/
|
|
68
|
-
toolMiddleware(middleware: ToolMiddleware): this;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Use `middlewares` instead.
|
|
71
|
-
*/
|
|
72
|
-
toolMiddlewares(middlewares: ToolMiddleware[]): this;
|
|
73
65
|
observe(observer: AgentObserver, options?: ObserveOptions): this;
|
|
74
66
|
approvals(options: ToolApprovalsOptions): this;
|
|
75
67
|
guardrails(policies: GuardrailPolicyInput): this;
|
package/dist/agent/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-EOIQXFGK.js";
|
|
4
|
+
import "../chunk-6GIREB6Z.js";
|
|
5
|
+
import "../chunk-GKPJ6FUL.js";
|
|
6
6
|
import "../chunk-YK4WAAS4.js";
|
|
7
7
|
import "../chunk-XUUY2L2D.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-MB55EXYB.js";
|
|
9
|
+
import "../chunk-4BGN6PYF.js";
|
|
10
10
|
import "../chunk-2ODTMRHP.js";
|
|
11
11
|
import "../chunk-ZNTIUOKL.js";
|
|
12
12
|
import "../chunk-TGLNXVII.js";
|
|
@@ -14,7 +14,7 @@ import "../chunk-MTGNA4OS.js";
|
|
|
14
14
|
import "../chunk-F56AMXMQ.js";
|
|
15
15
|
import "../chunk-PJDL5UT2.js";
|
|
16
16
|
import "../chunk-WQKHFADH.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-MNWK2USR.js";
|
|
18
18
|
import "../chunk-OIMLU4SF.js";
|
|
19
19
|
import "../chunk-CWUJUSOS.js";
|
|
20
20
|
export {
|
|
@@ -4,8 +4,8 @@ import { P as PromptHook } from './types-BCA8p0sb.js';
|
|
|
4
4
|
import { q as MemoryContext, s as MemoryRegistration, u as SessionOptions } from './types-DBHzPsbx.js';
|
|
5
5
|
import { j as AgentTraceOptions, P as PromptResponse, d as AgentStreamEvent, f as AgentStreamEventWithoutToolCallDeltas, g as AgentStreamOptions, k as AgentObserverRegistration } from './index-XTUEMWhU.js';
|
|
6
6
|
import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-Dhwg__1L.js';
|
|
7
|
-
import { A as AgentMiddleware,
|
|
8
|
-
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-
|
|
7
|
+
import { A as AgentMiddleware, i as ToolSearchDocument, j as ToolSet } from './middleware-DfMc30in.js';
|
|
8
|
+
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-BrxxAtcJ.js';
|
|
9
9
|
|
|
10
10
|
type CompletionRetryContext = {
|
|
11
11
|
error: unknown;
|
|
@@ -47,21 +47,9 @@ declare class PromptRequest<M extends CompletionModel = CompletionModel> {
|
|
|
47
47
|
withHook(hook: PromptHook): this;
|
|
48
48
|
approvals(options: ToolApprovalsOptions): this;
|
|
49
49
|
guardrails(policies: GuardrailPolicyInput): this;
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated Use `withHook` instead.
|
|
52
|
-
*/
|
|
53
|
-
requestHook(hook: PromptHook): this;
|
|
54
50
|
withToolConcurrency(concurrency: number): this;
|
|
55
51
|
withMiddleware(middleware: AgentMiddleware): this;
|
|
56
52
|
withMiddlewares(middlewares: AgentMiddleware[]): this;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated Use `withMiddleware` instead.
|
|
59
|
-
*/
|
|
60
|
-
withToolMiddleware(middleware: ToolMiddleware): this;
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated Use `withMiddlewares` instead.
|
|
63
|
-
*/
|
|
64
|
-
withToolMiddlewares(middlewares: ToolMiddleware[]): this;
|
|
65
53
|
withTrace(trace: AgentTraceOptions): this;
|
|
66
54
|
steer(input: string | Message | Message[]): boolean;
|
|
67
55
|
send(): Promise<PromptResponse>;
|
|
@@ -127,10 +115,6 @@ type AgentOptions<M extends CompletionModel = CompletionModel> = {
|
|
|
127
115
|
dynamicContexts?: DynamicContextRegistration[] | undefined;
|
|
128
116
|
dynamicTools?: DynamicToolRegistration[] | undefined;
|
|
129
117
|
middlewares?: AgentMiddleware[] | undefined;
|
|
130
|
-
/**
|
|
131
|
-
* @deprecated Use `middlewares` instead.
|
|
132
|
-
*/
|
|
133
|
-
toolMiddlewares?: AgentMiddleware[] | undefined;
|
|
134
118
|
memory?: MemoryRegistration | undefined;
|
|
135
119
|
eventStore?: AgentEventStoreRegistration | undefined;
|
|
136
120
|
};
|
|
@@ -209,10 +193,6 @@ declare class Agent<M extends CompletionModel = CompletionModel> {
|
|
|
209
193
|
readonly dynamicContexts: DynamicContextRegistration[];
|
|
210
194
|
readonly dynamicTools: DynamicToolRegistration[];
|
|
211
195
|
readonly middlewares: AgentMiddleware[];
|
|
212
|
-
/**
|
|
213
|
-
* @deprecated Use `middlewares` instead.
|
|
214
|
-
*/
|
|
215
|
-
readonly toolMiddlewares: AgentMiddleware[];
|
|
216
196
|
readonly memory: MemoryRegistration | undefined;
|
|
217
197
|
readonly eventStore: AgentEventStoreRegistration | undefined;
|
|
218
198
|
constructor(options: AgentOptions<M>);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EOIQXFGK.js";
|
|
4
4
|
import {
|
|
5
5
|
extractRagText
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GKPJ6FUL.js";
|
|
7
7
|
import {
|
|
8
8
|
createTool
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4BGN6PYF.js";
|
|
10
10
|
import {
|
|
11
11
|
CompletionRequestBuilder
|
|
12
12
|
} from "./chunk-MTGNA4OS.js";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
Extractor,
|
|
139
139
|
ExtractorBuilder
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-47UWISJU.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
cosineSimilarity,
|
|
6
6
|
embedText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MNWK2USR.js";
|
|
8
8
|
|
|
9
9
|
// src/vector-store/index.ts
|
|
10
10
|
import { z } from "zod";
|
|
@@ -334,4 +334,4 @@ export {
|
|
|
334
334
|
InMemoryVectorIndex,
|
|
335
335
|
createVectorSearchTool
|
|
336
336
|
};
|
|
337
|
-
//# sourceMappingURL=chunk-
|
|
337
|
+
//# sourceMappingURL=chunk-4BGN6PYF.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GKPJ6FUL.js";
|
|
4
4
|
import {
|
|
5
5
|
isSkillTool
|
|
6
6
|
} from "./chunk-YK4WAAS4.js";
|
|
7
7
|
import {
|
|
8
8
|
ToolSet
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MB55EXYB.js";
|
|
10
10
|
import {
|
|
11
11
|
createTool
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4BGN6PYF.js";
|
|
13
13
|
import {
|
|
14
14
|
isStreamingCompletionModel
|
|
15
15
|
} from "./chunk-F56AMXMQ.js";
|
|
@@ -53,10 +53,6 @@ var Agent = class {
|
|
|
53
53
|
dynamicContexts;
|
|
54
54
|
dynamicTools;
|
|
55
55
|
middlewares;
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated Use `middlewares` instead.
|
|
58
|
-
*/
|
|
59
|
-
toolMiddlewares;
|
|
60
56
|
memory;
|
|
61
57
|
eventStore;
|
|
62
58
|
constructor(options) {
|
|
@@ -80,8 +76,7 @@ var Agent = class {
|
|
|
80
76
|
this.guardrails = [...options.guardrails ?? []];
|
|
81
77
|
this.dynamicContexts = [...options.dynamicContexts ?? []];
|
|
82
78
|
this.dynamicTools = [...options.dynamicTools ?? []];
|
|
83
|
-
this.middlewares = [...options.middlewares ??
|
|
84
|
-
this.toolMiddlewares = this.middlewares;
|
|
79
|
+
this.middlewares = [...options.middlewares ?? []];
|
|
85
80
|
this.memory = options.memory;
|
|
86
81
|
this.eventStore = options.eventStore;
|
|
87
82
|
}
|
|
@@ -210,4 +205,4 @@ export {
|
|
|
210
205
|
Agent,
|
|
211
206
|
AgentSession
|
|
212
207
|
};
|
|
213
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-6GIREB6Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/agent.ts","../src/agent/ids.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isStreamingCompletionModel } from \"../completion/create-completion\";\nimport type {\n CompletionModel,\n Document,\n JsonObject,\n JsonValue,\n Message as MessageType,\n ProviderTool,\n ToolChoice,\n} from \"../completion/index\";\nimport type { GuardrailPolicy } from \"../guardrails\";\nimport type { PromptHook } from \"../hooks\";\nimport type { MemoryContext, MemoryRegistration, SessionOptions } from \"../memory/types\";\nimport type { AgentObserverRegistration } from \"../observability\";\nimport { PromptRequest } from \"../request\";\nimport { createTool } from \"../tool/create-tool\";\nimport type { ToolSearchDocument } from \"../tool/dynamic-tools\";\nimport type { AgentMiddleware } from \"../tool/middleware\";\nimport { isSkillTool } from \"../tool/skill-tool-marker\";\nimport type {\n AnyTool,\n NormalizedToolOutput,\n Tool,\n ToolApprovalsOptions,\n ToolCallContext,\n ToolCallStreamEvent,\n} from \"../tool/tool\";\nimport { ToolSet } from \"../tool/tool-set\";\nimport type { VectorSearchIndex } from \"../vector-store\";\nimport { normalizeAgentId } from \"./ids\";\nimport type {\n AgentEventStoreRegistration,\n AgentOptions,\n AgentToolOptions,\n DynamicContextRegistration,\n DynamicToolRegistration,\n} from \"./types\";\n\nexport const DEFAULT_MAX_TURNS = 20;\n\nexport class Agent<M extends CompletionModel = CompletionModel> {\n readonly id: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly model: M;\n readonly instructions: string | undefined;\n readonly staticContext: Document[];\n readonly temperature: number | undefined;\n readonly maxTokens: number | undefined;\n readonly additionalParams: JsonValue | undefined;\n readonly toolSet: ToolSet;\n readonly providerTools: ProviderTool[];\n readonly toolChoice: ToolChoice | undefined;\n readonly defaultMaxTurns: number | undefined;\n readonly hook: PromptHook | undefined;\n readonly outputSchema: JsonObject | undefined;\n readonly observers: AgentObserverRegistration[];\n readonly approvals: ToolApprovalsOptions | undefined;\n readonly guardrails: GuardrailPolicy[];\n readonly dynamicContexts: DynamicContextRegistration[];\n readonly dynamicTools: DynamicToolRegistration[];\n readonly middlewares: AgentMiddleware[];\n readonly memory: MemoryRegistration | undefined;\n readonly eventStore: AgentEventStoreRegistration | undefined;\n\n constructor(options: AgentOptions<M>) {\n this.id = normalizeAgentId(options.id);\n this.name = options.name;\n this.description = options.description;\n this.model = options.model;\n this.instructions = options.instructions;\n this.staticContext = [...(options.staticContext ?? [])];\n this.temperature = options.temperature;\n this.maxTokens = options.maxTokens;\n this.additionalParams = options.additionalParams;\n this.toolSet = options.toolSet ?? new ToolSet();\n this.providerTools = [...(options.providerTools ?? [])];\n this.toolChoice = options.toolChoice;\n this.defaultMaxTurns = options.defaultMaxTurns ?? DEFAULT_MAX_TURNS;\n this.hook = options.hook;\n this.outputSchema = options.outputSchema;\n this.observers = [...(options.observers ?? [])];\n this.approvals = options.approvals;\n this.guardrails = [...(options.guardrails ?? [])];\n this.dynamicContexts = [...(options.dynamicContexts ?? [])];\n this.dynamicTools = [...(options.dynamicTools ?? [])];\n this.middlewares = [...(options.middlewares ?? [])];\n this.memory = options.memory;\n this.eventStore = options.eventStore;\n }\n\n prompt(prompt: string | MessageType | MessageType[]): PromptRequest<M> {\n return PromptRequest.fromAgent(this, prompt);\n }\n\n session(sessionId: string, options: SessionOptions = {}): AgentSession<M> {\n if (this.memory === undefined) {\n throw new Error(`Agent \"${this.id}\" has no memory store configured.`);\n }\n const normalized = sessionId.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Session id must be a non-empty string.\");\n }\n const context: MemoryContext = {\n sessionId: normalized,\n };\n if (options.userId !== undefined) {\n context.userId = options.userId;\n }\n if (options.metadata !== undefined) {\n context.metadata = options.metadata;\n }\n return new AgentSession(this, context);\n }\n\n asTool(options: AgentToolOptions): Tool<{ prompt: string }, string> {\n const description =\n options.description ?? this.description ?? `Prompt the ${options.name} agent.`;\n\n return createTool({\n name: options.name,\n description,\n input: z.object({\n prompt: z.string().describe(\"The prompt to send to the agent.\"),\n }),\n output: z.string(),\n execute: async ({ prompt }, context: ToolCallContext) => {\n const request = this.prompt(prompt);\n const childRequest =\n options.maxTurns === undefined ? request : request.maxTurns(options.maxTurns);\n if (\n options.stream === true &&\n context.emitStreamEvent !== undefined &&\n this.model.capabilities.streaming &&\n isStreamingCompletionModel(this.model)\n ) {\n let output = \"\";\n const childStream =\n context.includeToolCallDeltas === false\n ? childRequest.stream({ includeToolCallDeltas: false })\n : childRequest.stream();\n for await (const event of childStream) {\n const streamEvent: ToolCallStreamEvent = {\n agentId: this.id,\n event,\n };\n if (this.name !== undefined) {\n streamEvent.agentName = this.name;\n }\n await context.emitStreamEvent(streamEvent);\n if (event.type === \"final\") {\n output = event.output;\n }\n }\n return output;\n }\n const response = await childRequest.send();\n return response.output;\n },\n });\n }\n\n getTool(toolName: string): AnyTool | undefined {\n const staticTool = this.toolSet.get(toolName);\n if (staticTool !== undefined) {\n return staticTool;\n }\n\n for (const registration of this.dynamicTools) {\n const dynamicTool = dynamicToolSetFromIndex(registration.index)?.get(toolName);\n if (dynamicTool !== undefined) {\n return dynamicTool;\n }\n }\n\n return undefined;\n }\n\n async callTool(\n toolName: string,\n args: string,\n context?: ToolCallContext,\n ): Promise<NormalizedToolOutput> {\n if (this.toolSet.contains(toolName)) {\n return this.toolSet.call(toolName, args, context);\n }\n\n for (const registration of this.dynamicTools) {\n const toolSet = dynamicToolSetFromIndex(registration.index);\n if (toolSet?.contains(toolName)) {\n return toolSet.call(toolName, args, context);\n }\n }\n\n return this.toolSet.call(toolName, args, context);\n }\n\n shouldApplyToolMiddleware(toolName: string): boolean {\n return !isSkillTool(this.getTool(toolName));\n }\n}\n\nexport class AgentSession<M extends CompletionModel = CompletionModel> {\n constructor(\n private readonly agent: Agent<M>,\n private readonly context: {\n sessionId: string;\n userId?: string | undefined;\n metadata?: JsonObject | undefined;\n },\n ) {}\n\n prompt(prompt: string | MessageType): PromptRequest<M> {\n if (Array.isArray(prompt)) {\n throw new TypeError(\"AgentSession.prompt does not accept Message[] transcripts.\");\n }\n return PromptRequest.fromAgent(this.agent, prompt, { memoryContext: this.context });\n }\n\n async messages(): Promise<MessageType[]> {\n const memory = this.agent.memory;\n if (memory === undefined) {\n throw new Error(`Agent \"${this.agent.id}\" has no memory store configured.`);\n }\n return memory.store.load(this.context);\n }\n\n async clear(): Promise<void> {\n const memory = this.agent.memory;\n if (memory === undefined) {\n throw new Error(`Agent \"${this.agent.id}\" has no memory store configured.`);\n }\n await memory.store.clear(this.context);\n }\n}\n\nfunction dynamicToolSetFromIndex(\n index: VectorSearchIndex<ToolSearchDocument>,\n): ToolSet | undefined {\n const maybeIndex = index as { toolSet?: unknown };\n return maybeIndex.toolSet instanceof ToolSet ? maybeIndex.toolSet : undefined;\n}\n","export function normalizeAgentId(id: string): string {\n if (typeof id !== \"string\") {\n throw new TypeError(\"Agent id must be a string.\");\n }\n\n const normalized = id.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Agent id must be a non-empty string.\");\n }\n\n return normalized;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;;;ACAX,SAAS,iBAAiB,IAAoB;AACnD,MAAI,OAAO,OAAO,UAAU;AAC1B,UAAM,IAAI,UAAU,4BAA4B;AAAA,EAClD;AAEA,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,WAAW,WAAW,GAAG;AAC3B,UAAM,IAAI,UAAU,sCAAsC;AAAA,EAC5D;AAEA,SAAO;AACT;;;AD4BO,IAAM,oBAAoB;AAE1B,IAAM,QAAN,MAAyD;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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,QAAW;AACxB,YAAM,IAAI,MAAM,UAAU,KAAK,MAAM,EAAE,mCAAmC;AAAA,IAC5E;AACA,WAAO,OAAO,MAAM,KAAK,KAAK,OAAO;AAAA,EACvC;AAAA,EAEA,MAAM,QAAuB;AAC3B,UAAM,SAAS,KAAK,MAAM;AAC1B,QAAI,WAAW,QAAW;AACxB,YAAM,IAAI,MAAM,UAAU,KAAK,MAAM,EAAE,mCAAmC;AAAA,IAC5E;AACA,UAAM,OAAO,MAAM,MAAM,KAAK,OAAO;AAAA,EACvC;AACF;AAEA,SAAS,wBACP,OACqB;AACrB,QAAM,aAAa;AACnB,SAAO,WAAW,mBAAmB,UAAU,WAAW,UAAU;AACtE;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-YK4WAAS4.js";
|
|
7
7
|
import {
|
|
8
8
|
createTool
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4BGN6PYF.js";
|
|
10
10
|
|
|
11
11
|
// src/skills/instructions.ts
|
|
12
12
|
function skillInstructions(skills) {
|
|
@@ -395,4 +395,4 @@ export {
|
|
|
395
395
|
SkillValidationError,
|
|
396
396
|
skill
|
|
397
397
|
};
|
|
398
|
-
//# sourceMappingURL=chunk-
|
|
398
|
+
//# sourceMappingURL=chunk-BCA4VZ5W.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent,
|
|
3
3
|
normalizeAgentId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6GIREB6Z.js";
|
|
5
5
|
import {
|
|
6
6
|
ToolSet
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MB55EXYB.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveMemoryOptions
|
|
10
10
|
} from "./chunk-ZNTIUOKL.js";
|
|
@@ -138,18 +138,6 @@ var AgentBuilder = class {
|
|
|
138
138
|
this.middlewareRegistrations.push(...middlewares);
|
|
139
139
|
return this;
|
|
140
140
|
}
|
|
141
|
-
/**
|
|
142
|
-
* @deprecated Use `middleware` instead.
|
|
143
|
-
*/
|
|
144
|
-
toolMiddleware(middleware) {
|
|
145
|
-
return this.middleware(middleware);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated Use `middlewares` instead.
|
|
149
|
-
*/
|
|
150
|
-
toolMiddlewares(middlewares) {
|
|
151
|
-
return this.middlewares(middlewares);
|
|
152
|
-
}
|
|
153
141
|
observe(observer, options = {}) {
|
|
154
142
|
this.observerRegistrations.push({
|
|
155
143
|
observer,
|
|
@@ -229,4 +217,4 @@ var AgentBuilder = class {
|
|
|
229
217
|
export {
|
|
230
218
|
AgentBuilder
|
|
231
219
|
};
|
|
232
|
-
//# sourceMappingURL=chunk-
|
|
220
|
+
//# sourceMappingURL=chunk-EOIQXFGK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/builder.ts"],"sourcesContent":["import {\n type CompletionModel,\n type Document,\n isProviderTool,\n type JsonObject,\n type JsonValue,\n type ProviderTool,\n type ToolChoice,\n} from \"../completion\";\nimport type { GuardrailPolicy, GuardrailPolicyInput } from \"../guardrails\";\nimport { appendGuardrailPolicies } from \"../guardrails\";\nimport type { PromptHook } from \"../hooks\";\nimport type { McpServer } from \"../mcp\";\nimport { resolveMemoryOptions } from \"../memory/options\";\nimport type { MemoryOptions, MemoryRegistration, MemoryStore } from \"../memory/types\";\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 { AgentMiddleware } from \"../tool/middleware\";\nimport type { AnyTool, ToolApprovalsOptions } from \"../tool/tool\";\nimport { ToolSet } from \"../tool/tool-set\";\nimport type { VectorSearchIndex } from \"../vector-store\";\nimport { Agent } from \"./agent\";\nimport { normalizeAgentId } from \"./ids\";\nimport type {\n AgentEventStore,\n AgentEventStoreOptions,\n AgentEventStoreRegistration,\n DynamicContextOptions,\n DynamicContextRegistration,\n DynamicToolOptions,\n DynamicToolRegistration,\n} from \"./types\";\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 approvalOptions: ToolApprovalsOptions | undefined;\n private guardrailPolicies: GuardrailPolicy[] = [];\n private skillInstructionBlocks: string[] = [];\n private observerRegistrations: AgentObserverRegistration[] = [];\n private dynamicContextRegistrations: DynamicContextRegistration[] = [];\n private dynamicToolRegistrations: DynamicToolRegistration[] = [];\n private middlewareRegistrations: AgentMiddleware[] = [];\n private memoryRegistration: MemoryRegistration | undefined;\n private eventStoreRegistration: AgentEventStoreRegistration | undefined;\n private activeToolSet = new ToolSet();\n private providerToolDefs: ProviderTool[] = [];\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 | ProviderTool): this {\n if (isProviderTool(tool)) {\n this.providerToolDefs.push(tool);\n } else {\n this.activeToolSet.addTool(tool);\n }\n return this;\n }\n\n tools(tools: Array<AnyTool | ProviderTool>): this {\n for (const tool of tools) {\n this.tool(tool);\n }\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 middleware(middleware: AgentMiddleware): this {\n this.middlewareRegistrations.push(middleware);\n return this;\n }\n\n middlewares(middlewares: AgentMiddleware[]): 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 approvals(options: ToolApprovalsOptions): this {\n this.approvalOptions = options;\n return this;\n }\n\n guardrails(policies: GuardrailPolicyInput): this {\n this.guardrailPolicies = appendGuardrailPolicies(this.guardrailPolicies, policies);\n return this;\n }\n\n memory(store: MemoryStore, options: MemoryOptions = {}): this {\n const resolvedOptions = resolveMemoryOptions(options);\n if (resolvedOptions.compaction !== undefined && store.compaction === undefined) {\n throw new TypeError(\n \"Memory compaction requires a store with the optional compaction capability.\",\n );\n }\n this.memoryRegistration = {\n store,\n options: resolvedOptions,\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 providerTools: this.providerToolDefs,\n toolChoice: this.choice,\n defaultMaxTurns: this.turns,\n hook: this.requestHook,\n outputSchema: this.schema,\n observers: this.observerRegistrations,\n approvals: this.approvalOptions,\n guardrails: this.guardrailPolicies,\n dynamicContexts: this.dynamicContextRegistrations,\n dynamicTools: this.dynamicToolRegistrations,\n middlewares: 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":";;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,eAAN,MAAgE;AAAA,EAyBrE,YACE,SACiB,iBACjB;AADiB;AAEjB,SAAK,UAAU,iBAAiB,OAAO;AAAA,EACzC;AAAA,EAHmB;AAAA,EA1BF;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;AAAA,EACA,oBAAuC,CAAC;AAAA,EACxC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ACA,WAAO,MAAM,WAAW,IAAI,SAAY,MAAM,KAAK,MAAM;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
parseToolArgs,
|
|
6
6
|
toolResultContentToText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MB55EXYB.js";
|
|
8
8
|
import {
|
|
9
9
|
runControl,
|
|
10
10
|
toolCallControl
|
|
@@ -1096,16 +1096,6 @@ var ToolCallExecutor = class {
|
|
|
1096
1096
|
}
|
|
1097
1097
|
replaced = true;
|
|
1098
1098
|
}
|
|
1099
|
-
const legacyReplacement = await middleware.onResult?.({
|
|
1100
|
-
...args,
|
|
1101
|
-
result,
|
|
1102
|
-
structuredResult
|
|
1103
|
-
});
|
|
1104
|
-
if (legacyReplacement !== void 0) {
|
|
1105
|
-
result = legacyReplacement;
|
|
1106
|
-
structuredResult = void 0;
|
|
1107
|
-
replaced = true;
|
|
1108
|
-
}
|
|
1109
1099
|
}
|
|
1110
1100
|
return replaced ? structuredResult ?? result : void 0;
|
|
1111
1101
|
}
|
|
@@ -1682,12 +1672,6 @@ var PromptRequest = class _PromptRequest {
|
|
|
1682
1672
|
this.guardrailPolicies = appendGuardrailPolicies(this.guardrailPolicies, policies);
|
|
1683
1673
|
return this;
|
|
1684
1674
|
}
|
|
1685
|
-
/**
|
|
1686
|
-
* @deprecated Use `withHook` instead.
|
|
1687
|
-
*/
|
|
1688
|
-
requestHook(hook) {
|
|
1689
|
-
return this.withHook(hook);
|
|
1690
|
-
}
|
|
1691
1675
|
withToolConcurrency(concurrency) {
|
|
1692
1676
|
this.concurrency = Math.max(1, concurrency);
|
|
1693
1677
|
return this;
|
|
@@ -1700,18 +1684,6 @@ var PromptRequest = class _PromptRequest {
|
|
|
1700
1684
|
this.requestMiddlewares.push(...middlewares);
|
|
1701
1685
|
return this;
|
|
1702
1686
|
}
|
|
1703
|
-
/**
|
|
1704
|
-
* @deprecated Use `withMiddleware` instead.
|
|
1705
|
-
*/
|
|
1706
|
-
withToolMiddleware(middleware) {
|
|
1707
|
-
return this.withMiddleware(middleware);
|
|
1708
|
-
}
|
|
1709
|
-
/**
|
|
1710
|
-
* @deprecated Use `withMiddlewares` instead.
|
|
1711
|
-
*/
|
|
1712
|
-
withToolMiddlewares(middlewares) {
|
|
1713
|
-
return this.withMiddlewares(middlewares);
|
|
1714
|
-
}
|
|
1715
1687
|
withTrace(trace) {
|
|
1716
1688
|
this.traceOptions = trace;
|
|
1717
1689
|
return this;
|
|
@@ -2750,4 +2722,4 @@ export {
|
|
|
2750
2722
|
extractRagText,
|
|
2751
2723
|
PromptRequest
|
|
2752
2724
|
};
|
|
2753
|
-
//# sourceMappingURL=chunk-
|
|
2725
|
+
//# sourceMappingURL=chunk-GKPJ6FUL.js.map
|