@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
package/dist/index.js
CHANGED
|
@@ -116744,6 +116744,62 @@ function isUseAIInternalResponse(value) {
|
|
|
116744
116744
|
return isMcpConfirmationResponse(value);
|
|
116745
116745
|
}
|
|
116746
116746
|
|
|
116747
|
+
// src/attachmentResolution.ts
|
|
116748
|
+
function hasRef(part) {
|
|
116749
|
+
if (typeof part !== "object" || part === null) {
|
|
116750
|
+
return false;
|
|
116751
|
+
}
|
|
116752
|
+
const p = part;
|
|
116753
|
+
return (p.type === "image_ref" || p.type === "file_ref") && typeof p.ref === "string" && p.ref.length > 0;
|
|
116754
|
+
}
|
|
116755
|
+
function countRefParts(messages) {
|
|
116756
|
+
let count = 0;
|
|
116757
|
+
for (const msg of messages) {
|
|
116758
|
+
const content = msg.content;
|
|
116759
|
+
if (Array.isArray(content)) {
|
|
116760
|
+
for (const part of content) {
|
|
116761
|
+
if (hasRef(part))
|
|
116762
|
+
count++;
|
|
116763
|
+
}
|
|
116764
|
+
}
|
|
116765
|
+
}
|
|
116766
|
+
return count;
|
|
116767
|
+
}
|
|
116768
|
+
async function resolveAttachmentParts(messages, resolve, context) {
|
|
116769
|
+
const refParts = [];
|
|
116770
|
+
const locations = [];
|
|
116771
|
+
messages.forEach((msg, message) => {
|
|
116772
|
+
const content = msg.content;
|
|
116773
|
+
if (Array.isArray(content)) {
|
|
116774
|
+
content.forEach((part, partIndex) => {
|
|
116775
|
+
if (hasRef(part)) {
|
|
116776
|
+
refParts.push(part);
|
|
116777
|
+
locations.push({ message, part: partIndex });
|
|
116778
|
+
}
|
|
116779
|
+
});
|
|
116780
|
+
}
|
|
116781
|
+
});
|
|
116782
|
+
if (refParts.length === 0) {
|
|
116783
|
+
return messages;
|
|
116784
|
+
}
|
|
116785
|
+
const resolved = await resolve(refParts, context);
|
|
116786
|
+
if (!Array.isArray(resolved) || resolved.length !== refParts.length) {
|
|
116787
|
+
throw new Error(`resolveAttachments must return one part per input ref (expected ${refParts.length})`);
|
|
116788
|
+
}
|
|
116789
|
+
const out = messages.slice();
|
|
116790
|
+
const clonedContent = new Map;
|
|
116791
|
+
locations.forEach((loc, i) => {
|
|
116792
|
+
let content = clonedContent.get(loc.message);
|
|
116793
|
+
if (!content) {
|
|
116794
|
+
content = out[loc.message].content.slice();
|
|
116795
|
+
clonedContent.set(loc.message, content);
|
|
116796
|
+
out[loc.message] = { ...out[loc.message], content };
|
|
116797
|
+
}
|
|
116798
|
+
content[loc.part] = resolved[i];
|
|
116799
|
+
});
|
|
116800
|
+
return out;
|
|
116801
|
+
}
|
|
116802
|
+
|
|
116747
116803
|
// src/rateLimiter.ts
|
|
116748
116804
|
class RateLimiter {
|
|
116749
116805
|
requests = new Map;
|
|
@@ -120925,6 +120981,7 @@ class UseAIServer {
|
|
|
120925
120981
|
messageHandlers = new Map;
|
|
120926
120982
|
mcpEndpoints = [];
|
|
120927
120983
|
serverTools = [];
|
|
120984
|
+
resolveAttachments;
|
|
120928
120985
|
clientIpTracker;
|
|
120929
120986
|
constructor(config) {
|
|
120930
120987
|
startTracing(config.spanProcessors);
|
|
@@ -120973,6 +121030,7 @@ class UseAIServer {
|
|
|
120973
121030
|
names: this.serverTools.map((t) => t.name)
|
|
120974
121031
|
});
|
|
120975
121032
|
}
|
|
121033
|
+
this.resolveAttachments = config.resolveAttachments;
|
|
120976
121034
|
this.plugins = config.plugins ?? [];
|
|
120977
121035
|
this.initializePlugins();
|
|
120978
121036
|
this.runtimeAdapter = createRuntimeAdapter(config.runtime ?? "auto");
|
|
@@ -121231,9 +121289,9 @@ class UseAIServer {
|
|
|
121231
121289
|
for (const block of content) {
|
|
121232
121290
|
if (block.type === "text" && "text" in block) {
|
|
121233
121291
|
parts.push({ type: "text", text: block.text });
|
|
121234
|
-
} else if (block.type === "
|
|
121292
|
+
} else if (block.type === "image_url" && "url" in block) {
|
|
121235
121293
|
parts.push({ type: "image", image: block.url });
|
|
121236
|
-
} else if (block.type === "
|
|
121294
|
+
} else if (block.type === "file_url" && "url" in block) {
|
|
121237
121295
|
parts.push({
|
|
121238
121296
|
type: "file",
|
|
121239
121297
|
data: block.url,
|
|
@@ -121261,7 +121319,29 @@ ${block.text}`
|
|
|
121261
121319
|
}
|
|
121262
121320
|
return "";
|
|
121263
121321
|
};
|
|
121264
|
-
|
|
121322
|
+
let resolvedMessages = messages;
|
|
121323
|
+
let resolveErrored = false;
|
|
121324
|
+
if (this.resolveAttachments) {
|
|
121325
|
+
try {
|
|
121326
|
+
resolvedMessages = await resolveAttachmentParts(messages, this.resolveAttachments, { forwardedProps });
|
|
121327
|
+
} catch (error) {
|
|
121328
|
+
resolveErrored = true;
|
|
121329
|
+
logger2.error("resolveAttachments failed; proceeding without resolved attachments", {
|
|
121330
|
+
runId,
|
|
121331
|
+
error: error instanceof Error ? error.message : String(error)
|
|
121332
|
+
});
|
|
121333
|
+
resolvedMessages = messages;
|
|
121334
|
+
}
|
|
121335
|
+
}
|
|
121336
|
+
const unresolvedRefs = countRefParts(resolvedMessages);
|
|
121337
|
+
if (unresolvedRefs > 0) {
|
|
121338
|
+
logger2.warn("Attachment refs left unresolved; attachments will not reach the model", {
|
|
121339
|
+
runId,
|
|
121340
|
+
unresolvedRefs,
|
|
121341
|
+
reason: resolveErrored ? "resolver-errored" : this.resolveAttachments ? "resolver-returned-ref" : "no-resolver-wired"
|
|
121342
|
+
});
|
|
121343
|
+
}
|
|
121344
|
+
const incomingMessages = resolvedMessages.map((msg, msgIndex) => {
|
|
121265
121345
|
if (msg.role === "user") {
|
|
121266
121346
|
return {
|
|
121267
121347
|
role: "user",
|
|
@@ -121338,7 +121418,7 @@ ${block.text}`
|
|
|
121338
121418
|
let toolName;
|
|
121339
121419
|
let toolEncryptedValue;
|
|
121340
121420
|
for (let i = msgIndex - 1;i >= 0; i--) {
|
|
121341
|
-
const prevToolCalls =
|
|
121421
|
+
const prevToolCalls = resolvedMessages[i].toolCalls;
|
|
121342
121422
|
if (prevToolCalls) {
|
|
121343
121423
|
const match = prevToolCalls.find((tc) => tc.id === toolCallId);
|
|
121344
121424
|
if (match) {
|
|
@@ -144871,6 +144951,26 @@ var uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(export
|
|
|
144871
144951
|
])).nonempty("Message must contain at least one part")
|
|
144872
144952
|
})).nonempty("Messages array must not be empty")));
|
|
144873
144953
|
var originalGenerateId3 = createIdGenerator({ prefix: "aiobj", size: 24 });
|
|
144954
|
+
function simulateReadableStream({
|
|
144955
|
+
chunks,
|
|
144956
|
+
initialDelayInMs = 0,
|
|
144957
|
+
chunkDelayInMs = 0,
|
|
144958
|
+
_internal
|
|
144959
|
+
}) {
|
|
144960
|
+
var _a152;
|
|
144961
|
+
const delay2 = (_a152 = _internal == null ? undefined : _internal.delay) != null ? _a152 : delay;
|
|
144962
|
+
let index = 0;
|
|
144963
|
+
return new ReadableStream({
|
|
144964
|
+
async pull(controller) {
|
|
144965
|
+
if (index < chunks.length) {
|
|
144966
|
+
await delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);
|
|
144967
|
+
controller.enqueue(chunks[index++]);
|
|
144968
|
+
} else {
|
|
144969
|
+
controller.close();
|
|
144970
|
+
}
|
|
144971
|
+
}
|
|
144972
|
+
});
|
|
144973
|
+
}
|
|
144874
144974
|
var originalGenerateId4 = createIdGenerator({ prefix: "aiobj", size: 24 });
|
|
144875
144975
|
var name142 = "AI_NoSuchProviderError";
|
|
144876
144976
|
var marker142 = `vercel.ai.error.${name142}`;
|
|
@@ -145087,27 +145187,17 @@ function extractReasoningSignature(providerMetadata) {
|
|
|
145087
145187
|
}
|
|
145088
145188
|
|
|
145089
145189
|
class AISDKAgent {
|
|
145090
|
-
model;
|
|
145091
|
-
providerOptions;
|
|
145092
145190
|
name;
|
|
145093
145191
|
annotation;
|
|
145094
145192
|
toolFilter;
|
|
145095
|
-
systemPrompt;
|
|
145096
145193
|
cacheBreakpoint;
|
|
145097
|
-
|
|
145098
|
-
temperature;
|
|
145099
|
-
maxSteps;
|
|
145194
|
+
loadConfig;
|
|
145100
145195
|
constructor(config2) {
|
|
145101
|
-
this.model = config2.model;
|
|
145102
|
-
this.providerOptions = config2.providerOptions;
|
|
145103
145196
|
this.name = config2.name || "ai-sdk";
|
|
145104
145197
|
this.annotation = config2.annotation;
|
|
145105
145198
|
this.toolFilter = config2.toolFilter;
|
|
145106
|
-
this.systemPrompt = config2.systemPrompt;
|
|
145107
145199
|
this.cacheBreakpoint = config2.cacheBreakpoint;
|
|
145108
|
-
this.
|
|
145109
|
-
this.temperature = config2.temperature;
|
|
145110
|
-
this.maxSteps = config2.maxSteps ?? DEFAULT_MAX_STEPS;
|
|
145200
|
+
this.loadConfig = config2.hooks.loadConfig;
|
|
145111
145201
|
}
|
|
145112
145202
|
getName() {
|
|
145113
145203
|
return this.name;
|
|
@@ -145119,7 +145209,13 @@ class AISDKAgent {
|
|
|
145119
145209
|
await flushTelemetry();
|
|
145120
145210
|
}
|
|
145121
145211
|
async run(input, events) {
|
|
145122
|
-
|
|
145212
|
+
let runConfig;
|
|
145213
|
+
try {
|
|
145214
|
+
runConfig = await this.loadConfig();
|
|
145215
|
+
} catch (error40) {
|
|
145216
|
+
return this.handleConfigLoadError(error40, input, events);
|
|
145217
|
+
}
|
|
145218
|
+
const ctx = this.createRunContext(input, runConfig);
|
|
145123
145219
|
this.emitRunStartEvents(ctx, events);
|
|
145124
145220
|
const span = this.startTelemetrySpan(ctx);
|
|
145125
145221
|
try {
|
|
@@ -145130,12 +145226,12 @@ class AISDKAgent {
|
|
|
145130
145226
|
return this.handleRunError(error40, ctx, events, span);
|
|
145131
145227
|
}
|
|
145132
145228
|
}
|
|
145133
|
-
|
|
145229
|
+
createRunContext(input, runConfig) {
|
|
145134
145230
|
const { session, runId, messages, tools, state, systemPrompt: runtimeSystemPrompt, originalInput } = input;
|
|
145135
145231
|
if (session.tools.length === 0 && tools.length > 0) {
|
|
145136
145232
|
session.tools = tools;
|
|
145137
145233
|
}
|
|
145138
|
-
const configSystemPrompt =
|
|
145234
|
+
const configSystemPrompt = runConfig.systemPrompt || undefined;
|
|
145139
145235
|
const staticSystemMessages = this.buildStaticSystemMessages(configSystemPrompt, runtimeSystemPrompt);
|
|
145140
145236
|
const sanitizedInputMessages = this.sanitizeMessages(messages);
|
|
145141
145237
|
return {
|
|
@@ -145146,6 +145242,13 @@ class AISDKAgent {
|
|
|
145146
145242
|
state,
|
|
145147
145243
|
originalInput,
|
|
145148
145244
|
staticSystemMessages,
|
|
145245
|
+
resolved: {
|
|
145246
|
+
model: runConfig.model,
|
|
145247
|
+
temperature: runConfig.temperature,
|
|
145248
|
+
maxOutputTokens: runConfig.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,
|
|
145249
|
+
maxSteps: runConfig.maxSteps ?? DEFAULT_MAX_STEPS,
|
|
145250
|
+
providerOptions: runConfig.providerOptions
|
|
145251
|
+
},
|
|
145149
145252
|
streamTextStarted: false,
|
|
145150
145253
|
finalText: "",
|
|
145151
145254
|
currentStepNumber: 0,
|
|
@@ -145158,6 +145261,30 @@ class AISDKAgent {
|
|
|
145158
145261
|
pendingTextMessageId: null
|
|
145159
145262
|
};
|
|
145160
145263
|
}
|
|
145264
|
+
handleConfigLoadError(error40, input, events) {
|
|
145265
|
+
const errorMessage = error40 instanceof Error ? error40.message : String(error40);
|
|
145266
|
+
logger2.error("hooks.loadConfig failed; aborting run", {
|
|
145267
|
+
clientId: input.session.clientId,
|
|
145268
|
+
error: errorMessage
|
|
145269
|
+
});
|
|
145270
|
+
events.emit({
|
|
145271
|
+
type: EventType.RUN_STARTED,
|
|
145272
|
+
threadId: input.session.threadId,
|
|
145273
|
+
runId: input.runId,
|
|
145274
|
+
input: input.originalInput,
|
|
145275
|
+
timestamp: Date.now()
|
|
145276
|
+
});
|
|
145277
|
+
events.emit({
|
|
145278
|
+
type: EventType.RUN_ERROR,
|
|
145279
|
+
message: ErrorCode.UNKNOWN_ERROR,
|
|
145280
|
+
timestamp: Date.now()
|
|
145281
|
+
});
|
|
145282
|
+
return {
|
|
145283
|
+
success: false,
|
|
145284
|
+
error: errorMessage,
|
|
145285
|
+
conversationHistory: input.messages
|
|
145286
|
+
};
|
|
145287
|
+
}
|
|
145161
145288
|
emitRunStartEvents(ctx, events) {
|
|
145162
145289
|
events.emit({
|
|
145163
145290
|
type: EventType.RUN_STARTED,
|
|
@@ -145202,8 +145329,8 @@ class AISDKAgent {
|
|
|
145202
145329
|
});
|
|
145203
145330
|
}
|
|
145204
145331
|
async executeStepLoop(ctx, events, span) {
|
|
145205
|
-
for (let stepIteration = 0;stepIteration <=
|
|
145206
|
-
const isGracefulSummaryStep = stepIteration ===
|
|
145332
|
+
for (let stepIteration = 0;stepIteration <= ctx.resolved.maxSteps; stepIteration++) {
|
|
145333
|
+
const isGracefulSummaryStep = stepIteration === ctx.resolved.maxSteps;
|
|
145207
145334
|
if (isGracefulSummaryStep && !ctx.lastStepHadToolCalls)
|
|
145208
145335
|
break;
|
|
145209
145336
|
const isTruncationFallbackStep = ctx.truncationFallbackPending;
|
|
@@ -145244,18 +145371,18 @@ class AISDKAgent {
|
|
|
145244
145371
|
this.applyGracefulSummaryOverrides(isGracefulSummaryStep, stepConfig);
|
|
145245
145372
|
this.applyTruncationFallbackOverrides(isTruncationFallbackStep, stepConfig);
|
|
145246
145373
|
logger2.debug("Starting step iteration", { stepIteration, ...stepConfig.metadata });
|
|
145247
|
-
const messagesWithCache = applyCacheBreakpoints(stepConfig.messages, this.cacheBreakpoint,
|
|
145374
|
+
const messagesWithCache = applyCacheBreakpoints(stepConfig.messages, this.cacheBreakpoint, ctx.resolved.model);
|
|
145248
145375
|
ctx.streamTextStarted = true;
|
|
145249
|
-
const stepMaxOutputTokens = isTruncationFallbackStep ? Math.min(
|
|
145376
|
+
const stepMaxOutputTokens = isTruncationFallbackStep ? Math.min(ctx.resolved.maxOutputTokens, TRUNCATION_FALLBACK_MAX_TOKENS) : ctx.resolved.maxOutputTokens;
|
|
145250
145377
|
const createStream = () => streamText({
|
|
145251
|
-
model:
|
|
145378
|
+
model: ctx.resolved.model,
|
|
145252
145379
|
messages: messagesWithCache,
|
|
145253
145380
|
tools: stepConfig.tools,
|
|
145254
145381
|
stopWhen: stepCountIs(1),
|
|
145255
145382
|
maxOutputTokens: stepMaxOutputTokens,
|
|
145256
|
-
temperature:
|
|
145383
|
+
temperature: ctx.resolved.temperature,
|
|
145257
145384
|
abortSignal: ctx.session.abortController?.signal,
|
|
145258
|
-
providerOptions:
|
|
145385
|
+
providerOptions: ctx.resolved.providerOptions,
|
|
145259
145386
|
experimental_telemetry: span.active ? { isEnabled: true, functionId: "use-ai", metadata: stepConfig.metadata } : undefined,
|
|
145260
145387
|
onStepFinish: ({ usage, finishReason }) => {
|
|
145261
145388
|
logger2.debug("Step finished", { usage, finishReason, stepIteration });
|
|
@@ -145355,14 +145482,14 @@ class AISDKAgent {
|
|
|
145355
145482
|
ctx.currentMessages = [...ctx.currentMessages, fallbackMessage];
|
|
145356
145483
|
ctx.truncationFallbackPending = true;
|
|
145357
145484
|
logger2.warn("Output truncated mid-text/reasoning by maxOutputTokens; running fallback iteration", {
|
|
145358
|
-
maxOutputTokens:
|
|
145485
|
+
maxOutputTokens: ctx.resolved.maxOutputTokens,
|
|
145359
145486
|
appendingToMessageId: ctx.pendingTextMessageId ?? undefined
|
|
145360
145487
|
});
|
|
145361
145488
|
return true;
|
|
145362
145489
|
}
|
|
145363
145490
|
handleIncompleteToolCalls(ctx, stepCtx) {
|
|
145364
145491
|
const incompleteToolCalls = [...stepCtx.activeToolCalls.entries()].filter(([id]) => !stepCtx.completedToolCalls.has(id)).map(([id, call]) => ({ id, ...call }));
|
|
145365
|
-
const recoveryMessages = buildRecoveryToolResults(incompleteToolCalls, stepCtx.stepFinishReason,
|
|
145492
|
+
const recoveryMessages = buildRecoveryToolResults(incompleteToolCalls, stepCtx.stepFinishReason, ctx.resolved.maxOutputTokens);
|
|
145366
145493
|
if (recoveryMessages.length === 0) {
|
|
145367
145494
|
return false;
|
|
145368
145495
|
}
|
|
@@ -145695,16 +145822,6 @@ class AISDKAgent {
|
|
|
145695
145822
|
conversationHistory: ctx.messages
|
|
145696
145823
|
};
|
|
145697
145824
|
}
|
|
145698
|
-
async resolveSystemPrompt() {
|
|
145699
|
-
if (!this.systemPrompt) {
|
|
145700
|
-
return;
|
|
145701
|
-
}
|
|
145702
|
-
if (typeof this.systemPrompt === "string") {
|
|
145703
|
-
return this.systemPrompt;
|
|
145704
|
-
}
|
|
145705
|
-
const result = await this.systemPrompt();
|
|
145706
|
-
return result || undefined;
|
|
145707
|
-
}
|
|
145708
145825
|
buildStaticSystemMessages(configPrompt, runtimePrompt) {
|
|
145709
145826
|
const messages = [];
|
|
145710
145827
|
if (configPrompt) {
|
|
@@ -145984,26 +146101,6 @@ var MockLanguageModelV3 = class {
|
|
|
145984
146101
|
return this._supportedUrls();
|
|
145985
146102
|
}
|
|
145986
146103
|
};
|
|
145987
|
-
function simulateReadableStream({
|
|
145988
|
-
chunks,
|
|
145989
|
-
initialDelayInMs = 0,
|
|
145990
|
-
chunkDelayInMs = 0,
|
|
145991
|
-
_internal
|
|
145992
|
-
}) {
|
|
145993
|
-
const delay2 = _internal?.delay ?? delay;
|
|
145994
|
-
let index = 0;
|
|
145995
|
-
return new ReadableStream({
|
|
145996
|
-
async pull(controller) {
|
|
145997
|
-
if (index < chunks.length) {
|
|
145998
|
-
await delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);
|
|
145999
|
-
controller.enqueue(chunks[index++]);
|
|
146000
|
-
} else {
|
|
146001
|
-
controller.close();
|
|
146002
|
-
}
|
|
146003
|
-
}
|
|
146004
|
-
});
|
|
146005
|
-
}
|
|
146006
|
-
var simulateReadableStream2 = simulateReadableStream;
|
|
146007
146104
|
|
|
146008
146105
|
// src/agents/testing/MockReasoningModel.ts
|
|
146009
146106
|
var CHUNK_DELAY_MS = 100;
|
|
@@ -146081,7 +146178,7 @@ function toolCallChunks(toolCallId, toolName, input) {
|
|
|
146081
146178
|
}
|
|
146082
146179
|
function makeStreamResponse(chunks, content) {
|
|
146083
146180
|
return {
|
|
146084
|
-
stream:
|
|
146181
|
+
stream: simulateReadableStream({ chunks, chunkDelayInMs: CHUNK_DELAY_MS }),
|
|
146085
146182
|
response: {
|
|
146086
146183
|
id: `mock-response-${Date.now()}`,
|
|
146087
146184
|
timestamp: new Date,
|
|
@@ -147431,6 +147528,7 @@ function defineServerTool(description, schemaOrExecute, executeOrOptions, option
|
|
|
147431
147528
|
}
|
|
147432
147529
|
export {
|
|
147433
147530
|
startRunSpan,
|
|
147531
|
+
resolveAttachmentParts,
|
|
147434
147532
|
or,
|
|
147435
147533
|
not,
|
|
147436
147534
|
logger2 as logger,
|
|
@@ -17,7 +17,7 @@ import type { ClientSession } from '../agents/types';
|
|
|
17
17
|
* import { FeedbackPlugin } from '@meetsmore-oss/use-ai-server';
|
|
18
18
|
*
|
|
19
19
|
* const server = new UseAIServer({
|
|
20
|
-
* agents: { claude: new AISDKAgent({ model }) },
|
|
20
|
+
* agents: { claude: new AISDKAgent({ hooks: { loadConfig: () => ({ model }) } }) },
|
|
21
21
|
* defaultAgent: 'claude',
|
|
22
22
|
* plugins: [
|
|
23
23
|
* new FeedbackPlugin(),
|
package/dist/server.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type { ClientSession } from './agents/types';
|
|
|
26
26
|
* apiKey: process.env.ANTHROPIC_API_KEY,
|
|
27
27
|
* });
|
|
28
28
|
* const claudeAgent = new AISDKAgent({
|
|
29
|
-
* model: anthropic('claude-sonnet-4-20250514'),
|
|
29
|
+
* hooks: { loadConfig: () => ({ model: anthropic('claude-sonnet-4-20250514') }) },
|
|
30
30
|
* });
|
|
31
31
|
* const server = new UseAIServer({
|
|
32
32
|
* port: 8081,
|
|
@@ -36,7 +36,7 @@ export type { ClientSession } from './agents/types';
|
|
|
36
36
|
*
|
|
37
37
|
* // Multiple agents (Claude + OpenAI)
|
|
38
38
|
* const gptAgent = new AISDKAgent({
|
|
39
|
-
* model: openai('gpt-4-turbo'),
|
|
39
|
+
* hooks: { loadConfig: () => ({ model: openai('gpt-4-turbo') }) },
|
|
40
40
|
* });
|
|
41
41
|
* const multiServer = new UseAIServer({
|
|
42
42
|
* port: 8081,
|
|
@@ -64,6 +64,7 @@ export declare class UseAIServer {
|
|
|
64
64
|
private messageHandlers;
|
|
65
65
|
private mcpEndpoints;
|
|
66
66
|
private serverTools;
|
|
67
|
+
private resolveAttachments?;
|
|
67
68
|
private clientIpTracker;
|
|
68
69
|
/**
|
|
69
70
|
* Creates a new UseAI server instance.
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iBAAiB,EAYlB,MAAM,SAAS,CAAC;AAOjB,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAezE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,MAAM,CAIZ;IACF,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,WAAW,CAA8B;IAEjD,OAAO,CAAC,kBAAkB,CAAC,CAAqB;IAEhD,OAAO,CAAC,eAAe,CAAkB;IAEzC;;;;;OAKG;gBACS,MAAM,EAAE,iBAAiB;IAsGrC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBjC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;;;;;OAMG;IACI,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAS1E,OAAO,CAAC,mBAAmB;YAqGb,mBAAmB;YA8BnB,cAAc;IA6a5B,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,gBAAgB;IAiDxB,OAAO,CAAC,0BAA0B;IAqBlC,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,SAAS;IAMjB;;;;;;;;;;;OAWG;YACW,qBAAqB;IA+CnC;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAwC5B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAoBtB;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAYjC;;;OAGG;IACU,KAAK;CAsBnB"}
|