@anvia/core 0.11.3 → 0.12.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 +11 -8
- package/dist/agent/index.js +10 -9
- package/dist/{agent-Bcpuodu2.d.ts → agent-BWF8_O8k.d.ts} +14 -5
- package/dist/{chunk-MLMXQ2OV.js → chunk-4AJJIIAQ.js} +9 -7
- package/dist/chunk-4AJJIIAQ.js.map +1 -0
- package/dist/{chunk-7CQAERL3.js → chunk-KTTIPWE7.js} +457 -107
- package/dist/chunk-KTTIPWE7.js.map +1 -0
- package/dist/{chunk-2GXGB6U5.js → chunk-MIJUAWHU.js} +4 -4
- package/dist/{chunk-5EDHXYH5.js → chunk-PGFYN5ZX.js} +12 -7
- package/dist/chunk-PGFYN5ZX.js.map +1 -0
- package/dist/{chunk-FV5B4SGK.js → chunk-R7F2JF7J.js} +6 -6
- package/dist/chunk-R7F2JF7J.js.map +1 -0
- package/dist/{chunk-NI637AGP.js → chunk-TIH4QM55.js} +12 -3
- package/dist/chunk-TIH4QM55.js.map +1 -0
- package/dist/chunk-YRERPIA5.js +451 -0
- package/dist/chunk-YRERPIA5.js.map +1 -0
- package/dist/{chunk-V3WTT7TE.js → chunk-ZGIE73BH.js} +2 -2
- package/dist/evals/index.d.ts +6 -5
- package/dist/evals/index.js +14 -13
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +6 -5
- package/dist/extractor/index.js +11 -10
- package/dist/guardrails/index.d.ts +211 -0
- package/dist/guardrails/index.js +35 -0
- package/dist/guardrails/index.js.map +1 -0
- package/dist/{index-CD9jb9Or.d.ts → index-DsWWqP0Q.d.ts} +8 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +34 -16
- package/dist/internal/agent.d.ts +6 -5
- package/dist/internal/agent.js +9 -8
- package/dist/mcp/index.d.ts +4 -3
- package/dist/{middleware-ByyL6Rj0.d.ts → middleware-BTR0eRtx.d.ts} +2 -2
- package/dist/observability/index.d.ts +3 -2
- package/dist/pipeline/index.d.ts +6 -5
- package/dist/pipeline/index.js +3 -3
- package/dist/request/index.d.ts +6 -5
- package/dist/request/index.js +8 -7
- package/dist/skills/index.d.ts +4 -3
- package/dist/skills/index.js +6 -6
- package/dist/{think-tool-B065hm73.d.ts → think-tool-Bn3HHu_z.d.ts} +4 -1
- package/dist/tool/index.d.ts +5 -4
- package/dist/tool/index.js +5 -5
- package/dist/{tool-B8K543oQ.d.ts → tool-DGELXD2z.d.ts} +3 -0
- package/dist/{types-Pl4PFQWL.d.ts → types-9VPKg7ih.d.ts} +1 -1
- package/dist/{types-BzUuhjKr.d.ts → types-Bx_ZtjPi.d.ts} +1 -1
- package/dist/{types-7F_IKQQW.d.ts → types-Dc83Qzch.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +4 -3
- package/dist/vector-store/index.js +3 -3
- package/package.json +6 -2
- package/dist/chunk-5EDHXYH5.js.map +0 -1
- package/dist/chunk-7CQAERL3.js.map +0 -1
- package/dist/chunk-FV5B4SGK.js.map +0 -1
- package/dist/chunk-MLMXQ2OV.js.map +0 -1
- package/dist/chunk-NI637AGP.js.map +0 -1
- /package/dist/{chunk-2GXGB6U5.js.map → chunk-MIJUAWHU.js.map} +0 -0
- /package/dist/{chunk-V3WTT7TE.js.map → chunk-ZGIE73BH.js.map} +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-
|
|
2
|
-
export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-
|
|
1
|
+
import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-BWF8_O8k.js';
|
|
2
|
+
export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-BWF8_O8k.js';
|
|
3
3
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
4
4
|
import { C as CompletionModel, e as JsonValue, n as ToolChoice } from '../types-q9G7Bvwl.js';
|
|
5
|
+
import { GuardrailPolicyInput } from '../guardrails/index.js';
|
|
5
6
|
import { P as PromptHook } from '../types-CGML74sE.js';
|
|
6
|
-
import { a as McpServer } from '../types-
|
|
7
|
+
import { a as McpServer } from '../types-Dc83Qzch.js';
|
|
7
8
|
import { M as MemoryStore, a as MemoryOptions } from '../types-CqG6d7Ce.js';
|
|
8
|
-
import { b as AgentObserver, O as ObserveOptions } from '../index-
|
|
9
|
-
import { a as SkillSet } from '../types-
|
|
10
|
-
import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-
|
|
11
|
-
import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-
|
|
12
|
-
import { a as VectorSearchIndex } from '../types-
|
|
9
|
+
import { b as AgentObserver, O as ObserveOptions } from '../index-DsWWqP0Q.js';
|
|
10
|
+
import { a as SkillSet } from '../types-Bx_ZtjPi.js';
|
|
11
|
+
import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-BTR0eRtx.js';
|
|
12
|
+
import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-DGELXD2z.js';
|
|
13
|
+
import { a as VectorSearchIndex } from '../types-9VPKg7ih.js';
|
|
13
14
|
import 'zod';
|
|
14
15
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
15
16
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
@@ -31,6 +32,7 @@ declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
|
|
|
31
32
|
private requestHook;
|
|
32
33
|
private schema;
|
|
33
34
|
private approvalOptions;
|
|
35
|
+
private guardrailPolicies;
|
|
34
36
|
private skillInstructionBlocks;
|
|
35
37
|
private observerRegistrations;
|
|
36
38
|
private dynamicContextRegistrations;
|
|
@@ -69,6 +71,7 @@ declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
|
|
|
69
71
|
toolMiddlewares(middlewares: ToolMiddleware[]): this;
|
|
70
72
|
observe(observer: AgentObserver, options?: ObserveOptions): this;
|
|
71
73
|
approvals(options: ToolApprovalsOptions): this;
|
|
74
|
+
guardrails(policies: GuardrailPolicyInput): this;
|
|
72
75
|
memory(store: MemoryStore, options?: MemoryOptions): this;
|
|
73
76
|
eventStore(store: AgentEventStore, options?: AgentEventStoreOptions): this;
|
|
74
77
|
outputSchema(schema: ZodSchema): this;
|
package/dist/agent/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-TIH4QM55.js";
|
|
4
|
+
import "../chunk-4AJJIIAQ.js";
|
|
5
|
+
import "../chunk-KTTIPWE7.js";
|
|
6
6
|
import "../chunk-YK4WAAS4.js";
|
|
7
7
|
import "../chunk-XUUY2L2D.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-R7F2JF7J.js";
|
|
9
|
+
import "../chunk-PGFYN5ZX.js";
|
|
10
|
+
import "../chunk-NPZDYOE6.js";
|
|
11
|
+
import "../chunk-MMHG7WAM.js";
|
|
10
12
|
import "../chunk-M6RPFHG7.js";
|
|
11
|
-
import "../chunk-JS5MGVNM.js";
|
|
12
|
-
import "../chunk-OIMLU4SF.js";
|
|
13
13
|
import "../chunk-SRBW3LD7.js";
|
|
14
14
|
import "../chunk-5LFGEMIW.js";
|
|
15
15
|
import "../chunk-WQKHFADH.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-JS5MGVNM.js";
|
|
17
|
+
import "../chunk-OIMLU4SF.js";
|
|
18
|
+
import "../chunk-YRERPIA5.js";
|
|
18
19
|
export {
|
|
19
20
|
AgentBuilder
|
|
20
21
|
};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { C as CompletionModel, M as Message, D as Document, e as JsonValue, n as ToolChoice, J as JsonObject } from './types-q9G7Bvwl.js';
|
|
2
|
+
import { GuardrailPolicyInput, GuardrailPolicy } from './guardrails/index.js';
|
|
2
3
|
import { P as PromptHook } from './types-CGML74sE.js';
|
|
3
4
|
import { c as MemoryContext, e as MemoryRegistration, S as SessionOptions } from './types-CqG6d7Ce.js';
|
|
4
|
-
import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-
|
|
5
|
-
import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-
|
|
6
|
-
import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-
|
|
7
|
-
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-
|
|
5
|
+
import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-DsWWqP0Q.js';
|
|
6
|
+
import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-DGELXD2z.js';
|
|
7
|
+
import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-BTR0eRtx.js';
|
|
8
|
+
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-9VPKg7ih.js';
|
|
8
9
|
|
|
9
10
|
declare class PromptRequest<M extends CompletionModel = CompletionModel> {
|
|
10
11
|
private readonly agent;
|
|
11
|
-
private
|
|
12
|
+
private promptMessage;
|
|
12
13
|
private readonly memoryContext;
|
|
13
14
|
private chatHistory;
|
|
14
15
|
private maxTurnCount;
|
|
15
16
|
private activeHook;
|
|
16
17
|
private approvalOptions;
|
|
18
|
+
private guardrailPolicies;
|
|
19
|
+
private guardrailDecisions;
|
|
17
20
|
private concurrency;
|
|
18
21
|
private traceOptions;
|
|
19
22
|
private requestMiddlewares;
|
|
@@ -27,6 +30,7 @@ declare class PromptRequest<M extends CompletionModel = CompletionModel> {
|
|
|
27
30
|
maxTurns(maxTurns: number): this;
|
|
28
31
|
withHook(hook: PromptHook): this;
|
|
29
32
|
approvals(options: ToolApprovalsOptions): this;
|
|
33
|
+
guardrails(policies: GuardrailPolicyInput): this;
|
|
30
34
|
/**
|
|
31
35
|
* @deprecated Use `withHook` instead.
|
|
32
36
|
*/
|
|
@@ -50,6 +54,9 @@ declare class PromptRequest<M extends CompletionModel = CompletionModel> {
|
|
|
50
54
|
private runCompletion;
|
|
51
55
|
private providerTraceRequest;
|
|
52
56
|
private executeToolCalls;
|
|
57
|
+
private runOutputGuardrailsForResponse;
|
|
58
|
+
private recordGuardrailDecision;
|
|
59
|
+
private guardrailRunContext;
|
|
53
60
|
private startRunObservers;
|
|
54
61
|
private recordAgentEvent;
|
|
55
62
|
private runCompletionCallHook;
|
|
@@ -87,6 +94,7 @@ type AgentOptions<M extends CompletionModel = CompletionModel> = {
|
|
|
87
94
|
outputSchema?: JsonObject | undefined;
|
|
88
95
|
observers?: AgentObserverRegistration[] | undefined;
|
|
89
96
|
approvals?: ToolApprovalsOptions | undefined;
|
|
97
|
+
guardrails?: GuardrailPolicy[] | undefined;
|
|
90
98
|
dynamicContexts?: DynamicContextRegistration[] | undefined;
|
|
91
99
|
dynamicTools?: DynamicToolRegistration[] | undefined;
|
|
92
100
|
middlewares?: AgentMiddleware[] | undefined;
|
|
@@ -167,6 +175,7 @@ declare class Agent<M extends CompletionModel = CompletionModel> {
|
|
|
167
175
|
readonly outputSchema: JsonObject | undefined;
|
|
168
176
|
readonly observers: AgentObserverRegistration[];
|
|
169
177
|
readonly approvals: ToolApprovalsOptions | undefined;
|
|
178
|
+
readonly guardrails: GuardrailPolicy[];
|
|
170
179
|
readonly dynamicContexts: DynamicContextRegistration[];
|
|
171
180
|
readonly dynamicTools: DynamicToolRegistration[];
|
|
172
181
|
readonly middlewares: AgentMiddleware[];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KTTIPWE7.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-R7F2JF7J.js";
|
|
10
10
|
import {
|
|
11
11
|
createTool
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
isStreamingCompletionModel
|
|
15
|
-
} from "./chunk-SRBW3LD7.js";
|
|
12
|
+
} from "./chunk-PGFYN5ZX.js";
|
|
16
13
|
import {
|
|
17
14
|
compact
|
|
18
15
|
} from "./chunk-MMHG7WAM.js";
|
|
16
|
+
import {
|
|
17
|
+
isStreamingCompletionModel
|
|
18
|
+
} from "./chunk-SRBW3LD7.js";
|
|
19
19
|
|
|
20
20
|
// src/agent/agent.ts
|
|
21
21
|
import { z } from "zod";
|
|
@@ -51,6 +51,7 @@ var Agent = class {
|
|
|
51
51
|
outputSchema;
|
|
52
52
|
observers;
|
|
53
53
|
approvals;
|
|
54
|
+
guardrails;
|
|
54
55
|
dynamicContexts;
|
|
55
56
|
dynamicTools;
|
|
56
57
|
middlewares;
|
|
@@ -77,6 +78,7 @@ var Agent = class {
|
|
|
77
78
|
this.outputSchema = options.outputSchema;
|
|
78
79
|
this.observers = options.observers ?? [];
|
|
79
80
|
this.approvals = options.approvals;
|
|
81
|
+
this.guardrails = [...options.guardrails ?? []];
|
|
80
82
|
this.dynamicContexts = options.dynamicContexts ?? [];
|
|
81
83
|
this.dynamicTools = options.dynamicTools ?? [];
|
|
82
84
|
this.middlewares = options.middlewares ?? options.toolMiddlewares ?? [];
|
|
@@ -202,4 +204,4 @@ export {
|
|
|
202
204
|
Agent,
|
|
203
205
|
AgentSession
|
|
204
206
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-4AJJIIAQ.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 ToolChoice,\n} from \"../completion/index\";\nimport type { GuardrailPolicy } from \"../guardrails\";\nimport type { PromptHook } from \"../hooks\";\nimport { compact } from \"../internal/compact\";\nimport type { 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} 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 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 /**\n * @deprecated Use `middlewares` instead.\n */\n readonly toolMiddlewares: 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.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 ?? options.toolMiddlewares ?? [];\n this.toolMiddlewares = this.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 return new AgentSession(this, {\n sessionId: normalized,\n ...(options.userId !== undefined && { userId: options.userId }),\n ...(options.metadata !== undefined && { metadata: options.metadata }),\n });\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 for await (const event of childRequest.stream()) {\n await context.emitStreamEvent(\n compact({\n agentId: this.id,\n agentName: this.name,\n event,\n }),\n );\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;;;AD2BO,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;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAIA;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