@meetsmore-oss/use-ai-server 1.16.0 → 1.17.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.
@@ -3,81 +3,141 @@ import type { Agent, AgentInput, EventEmitter, AgentResult } from './types';
3
3
  import type { ToolDefinition } from '../types';
4
4
  import { type CacheBreakpointFn } from './anthropicCache';
5
5
  /**
6
- * Configuration for AISDKAgent.
6
+ * The generation configuration for a single run(), returned by
7
+ * {@link AISDKAgentHooks.loadConfig}.
8
+ *
9
+ * Because `loadConfig` is called once per run, returning different values here
10
+ * changes the model / parameters for the next run without a server restart
11
+ * (e.g. values fetched from Langfuse prompt config).
12
+ *
13
+ * Only `model` is required. Omitted optional fields use library defaults.
7
14
  */
8
- export interface AISDKAgentConfig {
15
+ export interface AISDKRunConfig {
9
16
  /**
10
- * AI SDK Language Model (works with any provider).
17
+ * AI SDK Language Model (works with any provider). Accepts a model instance
18
+ * or a gateway model ID string.
19
+ *
20
+ * Required: use-ai is provider-agnostic and cannot pick a default model.
11
21
  *
12
22
  * @example
13
23
  * ```typescript
14
24
  * import { anthropic } from '@ai-sdk/anthropic';
15
- * import { openai } from '@ai-sdk/openai';
16
- * import { google } from '@ai-sdk/google';
17
- *
18
- * // With Anthropic Claude
19
- * { model: anthropic('claude-3-5-sonnet-20241022') }
20
- *
21
- * // With OpenAI GPT
22
- * { model: openai('gpt-4-turbo') }
23
- *
24
- * // With Google Gemini
25
- * { model: google('gemini-pro') }
25
+ * { model: anthropic('claude-3-5-sonnet-20241022') } // model instance
26
+ * { model: 'anthropic/claude-3-5-sonnet-20241022' } // gateway model ID
26
27
  * ```
27
28
  */
28
29
  model: LanguageModel;
29
30
  /**
30
- * Agent name for identification (defaults to 'ai-sdk').
31
- * Use this to differentiate multiple AI SDK agents.
31
+ * System prompt for this run, set on the backend and not exposed to the
32
+ * frontend (suitable for sensitive instructions). An empty string is treated
33
+ * as absent. When the request also carries a system prompt (AgentInput), the
34
+ * two are sent as separate system messages with this one first.
32
35
  */
33
- name?: string;
36
+ systemPrompt?: string;
34
37
  /**
35
- * Optional annotation/description for the agent.
36
- * Displayed in the use-ai agent selector UI to help users understand
37
- * the agent's capabilities or purpose.
38
+ * Temperature for model responses. Lower (e.g. 0) is more deterministic.
39
+ * @default undefined (uses the model's default)
40
+ */
41
+ temperature?: number;
42
+ /**
43
+ * Maximum number of tokens the model can output per response.
44
+ * @default 4096
45
+ */
46
+ maxOutputTokens?: number;
47
+ /**
48
+ * Maximum number of model step iterations per run. Each iteration performs
49
+ * one model invocation and may include tool calls.
50
+ * @default 10
51
+ */
52
+ maxSteps?: number;
53
+ /**
54
+ * Provider-specific options passed directly to `streamText`.
55
+ * Used for AI Gateway features like model fallbacks and provider routing.
38
56
  *
39
57
  * @example
40
58
  * ```typescript
41
- * { annotation: 'Fast responses for simple tasks' }
42
- * { annotation: 'Deep thinking mode for complex reasoning' }
59
+ * {
60
+ * providerOptions: {
61
+ * gateway: {
62
+ * models: ['anthropic/claude-opus-4.6', 'google/gemini-3.1-pro-preview'],
63
+ * order: ['azure', 'openai'],
64
+ * },
65
+ * },
66
+ * }
43
67
  * ```
44
68
  */
45
- annotation?: string;
69
+ providerOptions?: Record<string, Record<string, JSONValue>>;
70
+ }
71
+ /**
72
+ * Function-valued configuration points for {@link AISDKAgent}.
73
+ *
74
+ * Anything that can change at runtime is supplied through a hook rather than a
75
+ * static config field, so there is a single source of truth and no "static
76
+ * value vs. override" ambiguity.
77
+ */
78
+ export interface AISDKAgentHooks {
46
79
  /**
47
- * Optional system prompt to configure the agent's behavior.
48
- * This prompt is set on the backend and not exposed to the frontend,
49
- * making it suitable for sensitive instructions.
80
+ * Loads the generation config for a run.
81
+ *
82
+ * Called once at the start of every run(), so a value fetched from an external
83
+ * source (e.g. Langfuse prompt config) takes effect on the next request
84
+ * without a server restart. The agent does not cache the result.
50
85
  *
51
- * Can be a string, a function returning a string, or an async function
52
- * returning a Promise<string>. Use a function when the prompt needs to
53
- * be dynamically resolved (e.g., fetched from Langfuse or other external
54
- * sources) so updates take effect immediately without server restart.
86
+ * Required, because it is the only source of the model. For a static setup,
87
+ * return a constant object.
55
88
  *
56
- * When both this and the runtime systemPrompt (from AgentInput) are provided,
57
- * they are combined with this config prompt coming first.
89
+ * If it throws, the run fails with RUN_ERROR there is no static fallback.
90
+ * Implement resilience (e.g. return a default on a Langfuse outage) inside the
91
+ * hook itself.
58
92
  *
59
93
  * @example
60
94
  * ```typescript
61
- * // Static prompt
62
- * {
63
- * systemPrompt: 'You are a helpful assistant.'
64
- * }
95
+ * // Static
96
+ * { loadConfig: () => ({ model: anthropic('claude-3-5-sonnet-20241022') }) }
65
97
  *
66
- * // Sync function (e.g., reading from cache)
98
+ * // Dynamic, fetched from Langfuse (with a fallback owned by the host)
67
99
  * {
68
- * systemPrompt: () => promptCache.get('my-prompt')
100
+ * loadConfig: async () => {
101
+ * try {
102
+ * const prompt = await langfuse.prompt.get('my-prompt', { type: 'text' });
103
+ * return { model: prompt.config.model, systemPrompt: prompt.prompt };
104
+ * } catch {
105
+ * return { model: 'anthropic/claude-3-5-sonnet-20241022' };
106
+ * }
107
+ * },
69
108
  * }
109
+ * ```
110
+ */
111
+ loadConfig: () => AISDKRunConfig | Promise<AISDKRunConfig>;
112
+ }
113
+ /**
114
+ * Configuration for AISDKAgent.
115
+ *
116
+ * Structural settings (name, tool filtering, cache breakpoints) live here;
117
+ * everything that can vary per run is supplied via {@link AISDKAgentHooks}.
118
+ */
119
+ export interface AISDKAgentConfig {
120
+ /**
121
+ * Function-valued configuration. `hooks.loadConfig` (required) supplies the
122
+ * model and generation parameters for each run.
123
+ */
124
+ hooks: AISDKAgentHooks;
125
+ /**
126
+ * Agent name for identification (defaults to 'ai-sdk').
127
+ * Use this to differentiate multiple AI SDK agents.
128
+ */
129
+ name?: string;
130
+ /**
131
+ * Optional annotation/description for the agent.
132
+ * Displayed in the use-ai agent selector UI to help users understand
133
+ * the agent's capabilities or purpose.
70
134
  *
71
- * // Async function (e.g., fetching from Langfuse)
72
- * {
73
- * systemPrompt: async () => {
74
- * const prompt = await langfuse.getPrompt('my-prompt');
75
- * return prompt.compile();
76
- * }
77
- * }
135
+ * @example
136
+ * ```typescript
137
+ * { annotation: 'Fast responses for simple tasks' }
78
138
  * ```
79
139
  */
80
- systemPrompt?: string | (() => string | Promise<string>);
140
+ annotation?: string;
81
141
  /**
82
142
  * Optional filter function for tools.
83
143
  * Use this to control which tools are available to this agent.
@@ -86,17 +146,7 @@ export interface AISDKAgentConfig {
86
146
  * @example
87
147
  * ```typescript
88
148
  * // Only allow MCP tools starting with 'db_'
89
- * {
90
- * toolFilter: (tool) =>
91
- * !tool._remote || tool.name.startsWith('db_')
92
- * }
93
- *
94
- * // Block dangerous MCP tools
95
- * {
96
- * toolFilter: (tool) =>
97
- * !tool._remote ||
98
- * (!tool.name.includes('delete') && !tool.name.includes('drop'))
99
- * }
149
+ * { toolFilter: (tool) => !tool._remote || tool.name.startsWith('db_') }
100
150
  * ```
101
151
  */
102
152
  toolFilter?: (tool: ToolDefinition) => boolean;
@@ -105,36 +155,16 @@ export interface AISDKAgentConfig {
105
155
  * Only applies when using Anthropic models (Claude).
106
156
  *
107
157
  * Prompt caching reduces costs and latency by caching message prefixes.
108
- * Cache breakpoints mark where the cacheable prefix ends.
109
- *
110
158
  * The function receives each message with positional context and returns
111
- * true to add a cache breakpoint after that message.
112
- *
113
- * System prompt is included as role: 'system' at index 0 when present.
159
+ * true to add a cache breakpoint after that message. System prompt is
160
+ * included as role: 'system' at index 0 when present.
114
161
  *
115
162
  * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
116
163
  *
117
164
  * @example
118
165
  * ```typescript
119
166
  * // Cache system prompt + last message (most common pattern)
120
- * {
121
- * cacheBreakpoint: (msg) => msg.role === 'system' || msg.isLast
122
- * }
123
- *
124
- * // Cache only the last message
125
- * {
126
- * cacheBreakpoint: (msg) => msg.isLast
127
- * }
128
- *
129
- * // Cache system prompt only
130
- * {
131
- * cacheBreakpoint: (msg) => msg.role === 'system'
132
- * }
133
- *
134
- * // Cache first 3 messages + last
135
- * {
136
- * cacheBreakpoint: (msg) => msg.index < 3 || msg.isLast
137
- * }
167
+ * { cacheBreakpoint: (msg) => msg.role === 'system' || msg.isLast }
138
168
  *
139
169
  * // System prompt with 1h TTL, last message with 5m TTL
140
170
  * {
@@ -147,52 +177,6 @@ export interface AISDKAgentConfig {
147
177
  * ```
148
178
  */
149
179
  cacheBreakpoint?: CacheBreakpointFn;
150
- /**
151
- * Provider-specific options passed directly to `streamText`.
152
- * Can be used for AI Gateway features like model fallbacks, provider routing, etc.
153
- *
154
- * @example
155
- * ```typescript
156
- * // Model fallbacks via AI Gateway
157
- * {
158
- * providerOptions: {
159
- * gateway: {
160
- * models: ['anthropic/claude-opus-4.6', 'google/gemini-3.1-pro-preview'],
161
- * },
162
- * },
163
- * }
164
- *
165
- * // Model fallbacks + provider routing
166
- * {
167
- * providerOptions: {
168
- * gateway: {
169
- * models: ['openai/gpt-5-nano', 'anthropic/claude-opus-4.6'],
170
- * order: ['azure', 'openai'],
171
- * },
172
- * },
173
- * }
174
- * ```
175
- */
176
- providerOptions?: Record<string, Record<string, JSONValue>>;
177
- /**
178
- * Maximum number of tokens the model can output per response.
179
- * @default 4096
180
- */
181
- maxOutputTokens?: number;
182
- /**
183
- * Temperature for model responses.
184
- * Lower values (e.g., 0) make responses more deterministic.
185
- * Higher values (e.g., 1) make responses more creative/random.
186
- * Useful for testing where deterministic behavior is desired.
187
- * @default undefined (uses model's default)
188
- */
189
- temperature?: number;
190
- /**
191
- * Maximum number of model step iterations per run.
192
- * Each iteration performs one model invocation and may include tool calls.
193
- * @default 10
194
- */
195
- maxSteps?: number;
196
180
  }
197
181
  /**
198
182
  * Agent implementation for AI SDK models (Anthropic, OpenAI, Google, etc.).
@@ -226,12 +210,12 @@ export interface AISDKAgentConfig {
226
210
  * // With Claude
227
211
  * const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
228
212
  * const claudeAgent = new AISDKAgent({
229
- * model: anthropic('claude-3-5-sonnet-20241022'),
213
+ * hooks: { loadConfig: () => ({ model: anthropic('claude-3-5-sonnet-20241022') }) },
230
214
  * });
231
215
  *
232
216
  * // With GPT-4
233
217
  * const gptAgent = new AISDKAgent({
234
- * model: openai('gpt-4-turbo'),
218
+ * hooks: { loadConfig: () => ({ model: openai('gpt-4-turbo') }) },
235
219
  * });
236
220
  *
237
221
  * // Agent names come from agents object keys, not from agent config
@@ -245,16 +229,11 @@ export interface AISDKAgentConfig {
245
229
  * ```
246
230
  */
247
231
  export declare class AISDKAgent implements Agent {
248
- private model;
249
- private providerOptions?;
250
232
  private name;
251
233
  private annotation?;
252
234
  private toolFilter?;
253
- private systemPrompt?;
254
235
  private cacheBreakpoint?;
255
- private maxOutputTokens;
256
- private temperature?;
257
- private maxSteps;
236
+ private loadConfig;
258
237
  constructor(config: AISDKAgentConfig);
259
238
  getName(): string;
260
239
  getAnnotation(): string | undefined;
@@ -265,10 +244,17 @@ export declare class AISDKAgent implements Agent {
265
244
  flushTelemetry(): Promise<void>;
266
245
  run(input: AgentInput, events: EventEmitter): Promise<AgentResult>;
267
246
  /**
268
- * Creates the RunContext for a single run() invocation.
269
- * Resolves system prompt and initializes all mutable state.
247
+ * Creates the RunContext for a single run() invocation from the loaded run
248
+ * config. Builds the system messages and initializes all mutable state.
270
249
  */
271
250
  private createRunContext;
251
+ /**
252
+ * Handles a failure of the `hooks.loadConfig` hook, which runs before the
253
+ * RunContext exists. Emits a well-formed lifecycle (RUN_STARTED then
254
+ * RUN_ERROR) built from the input so the client is not left hanging, and
255
+ * returns a failed AgentResult.
256
+ */
257
+ private handleConfigLoadError;
272
258
  /**
273
259
  * Emits initial lifecycle events: RUN_STARTED, MESSAGES_SNAPSHOT, STATE_SNAPSHOT.
274
260
  */
@@ -359,18 +345,11 @@ export declare class AISDKAgent implements Agent {
359
345
  * emits RUN_ERROR, and returns the AgentResult.
360
346
  */
361
347
  private handleRunError;
362
- /**
363
- * Resolves the systemPrompt configuration value.
364
- * Handles string, sync function, and async function cases.
365
- *
366
- * @returns The resolved system prompt string, or undefined if not configured or empty
367
- */
368
- private resolveSystemPrompt;
369
348
  /**
370
349
  * Builds an array of static system messages from config and runtime prompts.
371
350
  * These are built once per run and remain constant across steps (cacheable prefix).
372
351
  *
373
- * @param configPrompt - Resolved system prompt from agent config (already resolved via resolveSystemPrompt)
352
+ * @param configPrompt - Resolved system prompt from the run config (empty string already normalized to undefined)
374
353
  * @param runtimePrompt - System prompt from AgentInput (static instructions from server)
375
354
  * @returns Array of SystemModelMessage objects, or undefined if both are empty
376
355
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AISDKAgent.d.ts","sourceRoot":"","sources":["../../../src/agents/AISDKAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,aAAa,EAA8G,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAMvL,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;AAgCpE,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA0HjF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,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OAQG;IACH,OAAO,CAAC,gBAAgB;CAgBzB"}
@@ -3,7 +3,7 @@
3
3
  * Provides pluggable AI agent backends that emit AG-UI protocol events.
4
4
  */
5
5
  export type { Agent, AgentInput, EventEmitter, AgentResult, ClientSession } from './types';
6
- export { AISDKAgent, type AISDKAgentConfig } from './AISDKAgent';
6
+ export { AISDKAgent, type AISDKAgentConfig, type AISDKAgentHooks, type AISDKRunConfig } from './AISDKAgent';
7
7
  export { createMockReasoningModel } from './testing/MockReasoningModel';
8
8
  export { applyCacheBreakpoints, isAnthropicModel, type MessageWithCacheContext, type CacheTtl, type CacheBreakpointResult, type CacheBreakpointFn, } from './anthropicCache';
9
9
  export { toolNeedsApproval, createApprovalWrapper, waitForApproval, type ToolArguments, type ToolResult, type ToolExecutor, } from './toolApproval';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC"}
@@ -14,8 +14,8 @@
14
14
  * import { createMockReasoningModel, AISDKAgent } from '@meetsmore-oss/use-ai-server';
15
15
  *
16
16
  * const agent = new AISDKAgent({
17
- * model: createMockReasoningModel(),
18
17
  * name: 'Mock (Reasoning)',
18
+ * hooks: { loadConfig: () => ({ model: createMockReasoningModel() }) },
19
19
  * });
20
20
  *
21
21
  * Enable in server-app with: USE_AI_ENABLE_MOCK_AGENT=true
@@ -1 +1 @@
1
- {"version":3,"file":"MockReasoningModel.d.ts","sourceRoot":"","sources":["../../../../src/agents/testing/MockReasoningModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,mBAAmB,EAA0B,MAAM,SAAS,CAAC;AAuItE;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,mBAAmB,CAqE9D"}
1
+ {"version":3,"file":"MockReasoningModel.d.ts","sourceRoot":"","sources":["../../../../src/agents/testing/MockReasoningModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAwI9C;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,mBAAmB,CAqE9D"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export type { ClientSession } from './server';
4
4
  export { resolveAttachmentParts } from './attachmentResolution';
5
5
  export type { ResolveAttachments, ResolveAttachmentsContext, MultimodalContent } from './types';
6
6
  export type { Agent, AgentInput, EventEmitter, AgentResult } from './agents';
7
- export { AISDKAgent, type AISDKAgentConfig, type MessageWithCacheContext, type CacheTtl, type CacheBreakpointResult, type CacheBreakpointFn, createMockReasoningModel } from './agents';
7
+ export { AISDKAgent, type AISDKAgentConfig, type AISDKAgentHooks, type AISDKRunConfig, type MessageWithCacheContext, type CacheTtl, type CacheBreakpointResult, type CacheBreakpointFn, createMockReasoningModel } from './agents';
8
8
  export type { UseAIServerPlugin, MessageHandler, BeforeRunAgentResult } from './plugins';
9
9
  export { FeedbackPlugin } from './plugins';
10
10
  export type { SpanProcessor } from './instrumentation';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGhG,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,KAAK,QAAQ,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGxL,YAAY,EAAE,iB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