@meetsmore-oss/use-ai-server 1.15.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.
- package/dist/agents/AISDKAgent.d.ts +123 -144
- package/dist/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/testing/MockReasoningModel.d.ts +1 -1
- package/dist/agents/testing/MockReasoningModel.d.ts.map +1 -1
- package/dist/attachmentResolution.d.ts +22 -0
- package/dist/attachmentResolution.d.ts.map +1 -0
- package/dist/attachmentResolution.test.d.ts +2 -0
- package/dist/attachmentResolution.test.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -59
- package/dist/plugins/FeedbackPlugin.d.ts +1 -1
- package/dist/server.d.ts +3 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/src/agents/AISDKAgent.d.ts +123 -144
- package/dist/src/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/src/agents/index.d.ts +1 -1
- package/dist/src/agents/index.d.ts.map +1 -1
- package/dist/src/agents/testing/MockReasoningModel.d.ts +1 -1
- package/dist/src/agents/testing/MockReasoningModel.d.ts.map +1 -1
- package/dist/src/attachmentResolution.d.ts +22 -0
- package/dist/src/attachmentResolution.d.ts.map +1 -0
- package/dist/src/attachmentResolution.test.d.ts +2 -0
- package/dist/src/attachmentResolution.test.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/FeedbackPlugin.d.ts +1 -1
- package/dist/src/server.d.ts +3 -2
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/types.d.ts +12 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/toolFilters.d.ts +5 -5
- package/dist/test/integration-test-utils.d.ts +2 -1
- package/dist/test/integration-test-utils.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +12 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/toolFilters.d.ts +5 -5
- package/package.json +2 -2
|
@@ -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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
16
|
-
*
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
-
|
|
36
|
+
systemPrompt?: string;
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
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
|
-
* {
|
|
42
|
-
* {
|
|
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
|
-
|
|
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
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
-
*
|
|
52
|
-
*
|
|
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
|
-
*
|
|
57
|
-
*
|
|
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
|
|
62
|
-
* {
|
|
63
|
-
* systemPrompt: 'You are a helpful assistant.'
|
|
64
|
-
* }
|
|
95
|
+
* // Static
|
|
96
|
+
* { loadConfig: () => ({ model: anthropic('claude-3-5-sonnet-20241022') }) }
|
|
65
97
|
*
|
|
66
|
-
* //
|
|
98
|
+
* // Dynamic, fetched from Langfuse (with a fallback owned by the host)
|
|
67
99
|
* {
|
|
68
|
-
*
|
|
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
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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;
|
|
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;AA4IjF;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;OAYG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;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BAA4B,CAWhD;IAEJ;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAW1C;IAEJ,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAQtC;IAEH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAM1B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAqC;IAEhF;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -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;
|
|
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,
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Message, ResolveAttachments, ResolveAttachmentsContext } from '@meetsmore-oss/use-ai-core';
|
|
2
|
+
/**
|
|
3
|
+
* Counts the `image_ref` / `file_ref` parts left in the history, for observability.
|
|
4
|
+
* After resolution these become `image_url` / `file_url`; any that remain were not
|
|
5
|
+
* resolved and are dropped during conversion (the attachment never reaches the model).
|
|
6
|
+
*/
|
|
7
|
+
export declare function countRefParts(messages: Message[]): number;
|
|
8
|
+
/**
|
|
9
|
+
* Collects ref-bearing attachment parts across the run's whole message history,
|
|
10
|
+
* calls the host's `resolve` once, and puts the returned parts back in place.
|
|
11
|
+
* The input is not mutated. See core's {@link ResolveAttachments} for the
|
|
12
|
+
* details of the resolve contract.
|
|
13
|
+
*
|
|
14
|
+
* Returns the original `messages` reference as-is when there are no refs. When
|
|
15
|
+
* there are, it returns a new array but clones only the messages and content
|
|
16
|
+
* arrays it actually touches, so the caller's input is left unchanged.
|
|
17
|
+
*
|
|
18
|
+
* @throws When `resolve` returns a different number of parts than it was given
|
|
19
|
+
* (a contract violation; the host must return one replacement per input).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAttachmentParts(messages: Message[], resolve: ResolveAttachments, context: ResolveAttachmentsContext): Promise<Message[]>;
|
|
22
|
+
//# sourceMappingURL=attachmentResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachmentResolution.d.ts","sourceRoot":"","sources":["../../src/attachmentResolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAkBpC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAWzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,OAAO,EAAE,CAAC,CA2CpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachmentResolution.test.d.ts","sourceRoot":"","sources":["../../src/attachmentResolution.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { UseAIServer } from './server';
|
|
2
2
|
export type { UseAIServerConfig, McpEndpointConfig, ToolDefinition, CorsOptions } from './types';
|
|
3
3
|
export type { ClientSession } from './server';
|
|
4
|
+
export { resolveAttachmentParts } from './attachmentResolution';
|
|
5
|
+
export type { ResolveAttachments, ResolveAttachmentsContext, MultimodalContent } from './types';
|
|
4
6
|
export type { Agent, AgentInput, EventEmitter, AgentResult } from './agents';
|
|
5
|
-
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';
|
|
6
8
|
export type { UseAIServerPlugin, MessageHandler, BeforeRunAgentResult } from './plugins';
|
|
7
9
|
export { FeedbackPlugin } from './plugins';
|
|
8
10
|
export type { SpanProcessor } from './instrumentation';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;A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